@tensor_1/react 2.57.0 → 2.58.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.
package/README.md CHANGED
@@ -45,6 +45,15 @@ workflow surfaces, the main entry exports `Pipeline`/`PipelineStage` (compact or
45
45
  Large fixed-height tables can use `useVirtualRows(rows, { rowHeight })`; attach its `containerRef` to
46
46
  `TableWrap` and render the returned row window between spacer rows.
47
47
 
48
+ `PageHeader` keeps complete record names readable in a narrow container: long words wrap,
49
+ including a title passed as a React node, while the help control stays beside the heading
50
+ and actions can move below it. Set the document's `lang` for language-aware hyphenation;
51
+ no consumer CSS override or plain-string-only title is needed. The default and display
52
+ presets are exercised with German names, help and actions in the live specimen at
53
+ `tests/page-header/harness.html` (build it with `node tests/page-header/build.mjs` and
54
+ serve the repo with `npm run serve:styleguide`). The browser regression checks the title's
55
+ text fragments as well as page width, so clipping by an ancestor cannot hide an overflow.
56
+
48
57
  ## Rich text, markdown and emoji
49
58
 
50
59
  Three optional entries (RTE-01). None of them is imported by the root entry.
@@ -119,7 +119,7 @@ function DashboardCanvas({
119
119
  const placed = placeCanvasItem(live.current.layout, item.id, targetFor(move)).find((candidate) => candidate.id === item.id);
120
120
  if (!placed) return;
121
121
  last = { col: placed.col, row: placed.row, w: placed.w, h: placed.h };
122
- setPreview({ id: item.id, placement: last });
122
+ setPreview({ id: item.id, kind, placement: last });
123
123
  };
124
124
  const finish = (drop) => {
125
125
  drag.stop();
@@ -182,10 +182,12 @@ function DashboardCanvas({
182
182
  layout.map((item) => {
183
183
  const name = itemLabel(item);
184
184
  const dragging = preview?.id === item.id;
185
+ const lifted = dragging && preview.kind === "move";
185
186
  return /* @__PURE__ */ jsxs(
186
187
  "div",
187
188
  {
188
189
  className: cx("uix-dashboard-canvas__item", dragging && "uix-dashboard-canvas__item--dragging"),
190
+ "data-uix-drag": lifted ? "lifted" : void 0,
189
191
  style: placementStyle(item, order.get(item.id) ?? 0),
190
192
  "data-canvas-id": item.id,
191
193
  children: [
@@ -317,6 +317,17 @@ interface DataWorkspaceProps<T, S extends DataWorkspaceSortState = DataWorkspace
317
317
  status?: 'ready' | 'loading' | 'error';
318
318
  /** A refetch (filter, sort, page, saved view): the rows stay under `TableWrap refreshing`. */
319
319
  refreshing?: boolean;
320
+ /**
321
+ * Row motion (HAR-2755, list motion of the motion standard §2.5): a row that arrives (a live
322
+ * update, the "new items" pill) rises in; a row that leaves (a bulk close, a row handled
323
+ * elsewhere) fades out while the rows after it glide into its place, and the empty state waits
324
+ * for the last one; a re-sort glides. A new page, filter or view that replaces most rows swaps
325
+ * at once. Focus moves to a neighbour when its row leaves. Reduced motion keeps the fades only.
326
+ * Not for grouped or windowed bodies, which keep plain rows. A leaving row stays in the DOM
327
+ * (inert, `aria-hidden`) until its exit ends, so a test that counts rows right after a removal
328
+ * sees it for up to a second. Default `false`.
329
+ */
330
+ rowMotion?: boolean;
320
331
  onRetry?: () => void;
321
332
  /** Skeleton rows on a first load. Default 6. */
322
333
  loadingRows?: number;
@@ -376,6 +387,6 @@ interface DataWorkspaceProps<T, S extends DataWorkspaceSortState = DataWorkspace
376
387
  * rich id cell, multi-column sort, the product's state bodies and `beforeBody`, row groups,
377
388
  * windowing (`virtualize`) and a keyboard row model (`onRowActivate`).
378
389
  */
379
- declare function DataWorkspace<T, S extends DataWorkspaceSortState = DataWorkspaceSort | null>({ label, rows, getRowId, rowLabel, columns, idColumn, sort, onSortChange, selection, onSelectionChange, maxSelection, bulkActions, rowActions, rowActionsColumn, getRowProps, density, zebra, freezeFirstColumn, fixed, mobile, search, filters, savedViews, viewMenu, viewChanged, onSaveView, onSaveViewAs, saveViewAs, maximized, onMaximizedChange, toolbarEnd, beforeBody, pagination, status, refreshing, onRetry, loadingRows, empty, emptyAction, filteredEmpty, filteredEmptyAction, error, stateOverride, groups, collapsedGroups, onCollapsedGroupsChange, virtualize, rowNavigation, onRowActivate, activateOnClick, activeRowId, onActiveRowChange, multiSort, labels: labelOverrides, className, ...props }: DataWorkspaceProps<T, S>): react.JSX.Element;
390
+ declare function DataWorkspace<T, S extends DataWorkspaceSortState = DataWorkspaceSort | null>({ label, rows, getRowId, rowLabel, columns, idColumn, sort, onSortChange, selection, onSelectionChange, maxSelection, bulkActions, rowActions, rowActionsColumn, getRowProps, density, zebra, freezeFirstColumn, fixed, mobile, search, filters, savedViews, viewMenu, viewChanged, onSaveView, onSaveViewAs, saveViewAs, maximized, onMaximizedChange, toolbarEnd, beforeBody, pagination, status, refreshing, rowMotion, onRetry, loadingRows, empty, emptyAction, filteredEmpty, filteredEmptyAction, error, stateOverride, groups, collapsedGroups, onCollapsedGroupsChange, virtualize, rowNavigation, onRowActivate, activateOnClick, activeRowId, onActiveRowChange, multiSort, labels: labelOverrides, className, ...props }: DataWorkspaceProps<T, S>): react.JSX.Element;
380
391
 
381
392
  export { DEFAULT_DATA_WORKSPACE_LABELS, DataWorkspace, type DataWorkspaceColumn, type DataWorkspaceGroup, type DataWorkspaceIdColumn, type DataWorkspaceLabels, type DataWorkspacePagination, type DataWorkspaceProps, type DataWorkspaceRowActionsContext, type DataWorkspaceSort, type DataWorkspaceSortState, type DataWorkspaceSortValue, type DataWorkspaceVirtualize };
@@ -15,6 +15,7 @@ import { Checkbox } from "./Checkbox.js";
15
15
  import { Chip } from "./Chip.js";
16
16
  import { FilterEditor } from "./FilterEditor.js";
17
17
  import { Menu, MenuItem } from "./Menu.js";
18
+ import { MotionList } from "./MotionList.js";
18
19
  import { Pagination } from "./Pagination.js";
19
20
  import { Popover } from "./Popover.js";
20
21
  import { SearchBar } from "./SearchBar.js";
@@ -74,6 +75,7 @@ const hiddenBy = (ladder, priority) => ladder === "priority" && priority === "lo
74
75
  const ROW_HEIGHT = { compact: 44, standard: 56, comfortable: 68 };
75
76
  const CONTROLS = 'a, button, input, select, textarea, label, summary, dialog, [role="button"], [role="menuitem"], [contenteditable="true"], [popover], td.uix-table__selcell, td.uix-table__actions';
76
77
  const RESERVED_COLS = /* @__PURE__ */ new Set(["select", "id", "actions", "expand"]);
78
+ const MOTION_ROW_LIMIT = 12;
77
79
  const textOf = (node) => typeof node === "string" ? node : void 0;
78
80
  const columnLabel = (column) => column.label ?? textOf(column.header);
79
81
  const ladderAttrs = (on, column, body) => on ? {
@@ -117,6 +119,7 @@ function DataWorkspace({
117
119
  pagination,
118
120
  status = "ready",
119
121
  refreshing = false,
122
+ rowMotion = false,
120
123
  onRetry,
121
124
  loadingRows = 6,
122
125
  empty,
@@ -203,6 +206,13 @@ function DataWorkspace({
203
206
  const view = flat.length > 0 ? current : refreshing || source === settled.source ? settled : current;
204
207
  const shownRows = view.flat;
205
208
  const shownGroups = view.groups;
209
+ const [exitHold, setExitHold] = useState({ count: shownRows.length, filtered: view.filtered, refreshing, held: false });
210
+ if (exitHold.count !== shownRows.length || exitHold.filtered !== view.filtered || exitHold.refreshing !== refreshing) {
211
+ const held = rowMotion && shownRows.length === 0 && exitHold.count > 0 && exitHold.filtered === view.filtered && !exitHold.refreshing && !refreshing && !shownGroups && status === "ready" && stateOverride == null;
212
+ setExitHold({ count: shownRows.length, filtered: view.filtered, refreshing, held });
213
+ }
214
+ const holdingExit = exitHold.held && shownRows.length === 0;
215
+ const onRowsExited = useCallback(() => setExitHold((current2) => current2.held ? { ...current2, held: false } : current2), []);
206
216
  const [ownCollapsed, setOwnCollapsed] = useState(() => /* @__PURE__ */ new Set());
207
217
  const collapsed = collapsedGroups ?? ownCollapsed;
208
218
  const toggleGroupOpen = (groupId) => {
@@ -317,7 +327,7 @@ function DataWorkspace({
317
327
  if (stateOverride != null) body = busy(stateOverride);
318
328
  else if (status === "loading") body = /* @__PURE__ */ jsx(LoadingState, { rows: loadingRows, label: labels.loading, className: "uix-data-workspace__loading" });
319
329
  else if (status === "error") body = error != null ? busy(error) : /* @__PURE__ */ jsx(ErrorState, { title: labels.error, action: onRetry && /* @__PURE__ */ jsx(Button, { size: "sm", onClick: onRetry, children: labels.retry }) });
320
- else if (shownRows.length === 0) {
330
+ else if (shownRows.length === 0 && !holdingExit) {
321
331
  const clear = /* @__PURE__ */ jsx(Button, { size: "sm", onClick: clearAll, children: labels.clearFilters });
322
332
  body = busy(view.filtered ? filteredEmpty ?? /* @__PURE__ */ jsx(
323
333
  FilteredEmptyState,
@@ -352,6 +362,7 @@ function DataWorkspace({
352
362
  ladderOn: mobile != null,
353
363
  ladder,
354
364
  refreshing,
365
+ rowMotion,
355
366
  selectable,
356
367
  selected,
357
368
  onPage,
@@ -372,7 +383,8 @@ function DataWorkspace({
372
383
  activateOnClick,
373
384
  activeRowId,
374
385
  onActiveRowChange,
375
- labels
386
+ labels,
387
+ onRowsExited
376
388
  }
377
389
  );
378
390
  }
@@ -445,6 +457,7 @@ function WorkspaceTable({
445
457
  ladderOn,
446
458
  ladder,
447
459
  refreshing,
460
+ rowMotion,
448
461
  selectable,
449
462
  selected,
450
463
  onPage,
@@ -466,7 +479,8 @@ function WorkspaceTable({
466
479
  onActiveRowChange,
467
480
  labels,
468
481
  windowing,
469
- virtual
482
+ virtual,
483
+ onRowsExited
470
484
  }) {
471
485
  const cards = ladder === "cards";
472
486
  const wrapRef = useRef(null);
@@ -791,6 +805,44 @@ function WorkspaceTable({
791
805
  rowId
792
806
  );
793
807
  };
808
+ const renderLeavingRow = (row) => {
809
+ const rowId = getRowId(row);
810
+ return /* @__PURE__ */ jsx(
811
+ WorkspaceRow,
812
+ {
813
+ row,
814
+ rowId,
815
+ rowLabel,
816
+ columns,
817
+ idColumn,
818
+ getRowProps,
819
+ selectable,
820
+ selected: false,
821
+ selectDisabled: true,
822
+ hasActions,
823
+ actions: null,
824
+ ladder,
825
+ ladderOn,
826
+ selectRowLabel,
827
+ openLabel,
828
+ marked: false,
829
+ nav: false,
830
+ tabStop: false,
831
+ handlers
832
+ },
833
+ rowId
834
+ );
835
+ };
836
+ const indexById = useMemo(() => new Map(ids.map((rowId, index) => [rowId, index])), [ids]);
837
+ const motion = useRef({ ids, generation: 0 });
838
+ if (motion.current.ids !== ids) {
839
+ const before = new Set(motion.current.ids);
840
+ const kept = ids.reduce((count, rowId) => count + (before.has(rowId) ? 1 : 0), 0);
841
+ const changed = ids.length - kept + (before.size - kept);
842
+ const replaced = before.size > 0 && ids.length > 0 && (kept === 0 || changed > MOTION_ROW_LIMIT);
843
+ motion.current = { ids, generation: motion.current.generation + (replaced ? 1 : 0) };
844
+ }
845
+ const motionGeneration = motion.current.generation;
794
846
  let tbody;
795
847
  if (groups) {
796
848
  let offset = 0;
@@ -843,12 +895,30 @@ function WorkspaceTable({
843
895
  });
844
896
  } else {
845
897
  const spacer = (height, key) => /* @__PURE__ */ jsx("tr", { "aria-hidden": "true", className: "uix-data-workspace__spacer", children: /* @__PURE__ */ jsx("td", { colSpan: colCount, style: { height } }) }, key);
846
- tbody = /* @__PURE__ */ jsxs("tbody", { children: [
847
- virtual && windowed && start > 0 && spacer(virtual.padTop, "pad-top"),
848
- windowed && start > 0 && start % 2 === 0 && spacer(0, "pad-zebra"),
898
+ tbody = windowed || !rowMotion ? /* @__PURE__ */ jsxs("tbody", { children: [
899
+ virtual && start > 0 && spacer(virtual.padTop, "pad-top"),
900
+ start > 0 && start % 2 === 0 && spacer(0, "pad-zebra"),
849
901
  mountedRows.map((row, at) => renderRow(row, start + at)),
850
- virtual && windowed && virtual.padBottom > 0 && spacer(virtual.padBottom, "pad-bottom")
851
- ] });
902
+ virtual && virtual.padBottom > 0 && spacer(virtual.padBottom, "pad-bottom")
903
+ ] }) : (
904
+ // Row motion (HAR-2755): a row a live update adds rises in, a row a bulk action removes fades
905
+ // out while the rows after it glide up, a re-sort glides. A new page, filter or view that
906
+ // replaces most rows remounts the body instead (`motionGeneration`), so it swaps at once.
907
+ /* @__PURE__ */ jsx(
908
+ MotionList,
909
+ {
910
+ as: "tbody",
911
+ items: rows,
912
+ getKey: getRowId,
913
+ onExited: onRowsExited,
914
+ renderItem: (row, { exiting }) => {
915
+ const index = exiting ? void 0 : indexById.get(getRowId(row));
916
+ return index === void 0 ? renderLeavingRow(row) : renderRow(row, index);
917
+ }
918
+ },
919
+ motionGeneration
920
+ )
921
+ );
852
922
  }
853
923
  const wrapStyle = long ? { "--uix-table-max-height": `${maxHeight}px` } : void 0;
854
924
  return /* @__PURE__ */ jsx(
@@ -944,7 +1014,10 @@ function WorkspaceRowInner({
944
1014
  ariaRowIndex,
945
1015
  nav,
946
1016
  tabStop,
947
- handlers
1017
+ handlers,
1018
+ "data-uix-key": motionKey,
1019
+ "data-uix-exiting": motionExiting,
1020
+ "aria-hidden": motionHidden
948
1021
  }) {
949
1022
  const renderedActions = useMemo(
950
1023
  () => lazyRowActions ? lazyRowActions(row, { ladder, compact: ladder === "priority-mid" }) : actions,
@@ -971,22 +1044,35 @@ function WorkspaceRowInner({
971
1044
  handlers.blur(rowId, event);
972
1045
  }
973
1046
  } : {};
974
- return /* @__PURE__ */ jsxs(Tr, { selected, "data-uix-row-id": marked ? rowId : void 0, "aria-rowindex": ariaRowIndex, ...extra, ...navProps, children: [
975
- selectable && /* @__PURE__ */ jsx("td", { className: "uix-table__selcell", "data-col": ladderOn ? "select" : void 0, children: /* @__PURE__ */ jsx(
976
- Checkbox,
977
- {
978
- "aria-label": fillLabel(selectRowLabel, { label: text }),
979
- checked: selected,
980
- disabled: selectDisabled,
981
- onClick: (event) => handlers.toggle(rowId, event.currentTarget.checked, event),
982
- onChange: () => {
983
- }
984
- }
985
- ) }),
986
- idColumn && /* @__PURE__ */ jsx(Td, { className: "uix-id-cell", "data-col": ladderOn ? "id" : void 0, children: /* @__PURE__ */ jsx(IdCell, { row, text, idColumn, openLabel }) }),
987
- columns.map((column) => /* @__PURE__ */ jsx(Td, { className: cx(column.align === "end" && "uix-col--num", column.className) || void 0, ...ladderAttrs(ladderOn, column, true), children: column.cell(row) }, column.id)),
988
- hasActions && /* @__PURE__ */ jsx(RowActions, { "data-col": ladderOn ? "actions" : void 0, children: renderedActions })
989
- ] });
1047
+ return /* @__PURE__ */ jsxs(
1048
+ Tr,
1049
+ {
1050
+ selected,
1051
+ "data-uix-row-id": marked ? rowId : void 0,
1052
+ "aria-rowindex": ariaRowIndex,
1053
+ ...extra,
1054
+ ...navProps,
1055
+ "data-uix-key": motionKey,
1056
+ "data-uix-exiting": motionExiting,
1057
+ "aria-hidden": motionHidden,
1058
+ children: [
1059
+ selectable && /* @__PURE__ */ jsx("td", { className: "uix-table__selcell", "data-col": ladderOn ? "select" : void 0, children: /* @__PURE__ */ jsx(
1060
+ Checkbox,
1061
+ {
1062
+ "aria-label": fillLabel(selectRowLabel, { label: text }),
1063
+ checked: selected,
1064
+ disabled: selectDisabled,
1065
+ onClick: (event) => handlers.toggle(rowId, event.currentTarget.checked, event),
1066
+ onChange: () => {
1067
+ }
1068
+ }
1069
+ ) }),
1070
+ idColumn && /* @__PURE__ */ jsx(Td, { className: "uix-id-cell", "data-col": ladderOn ? "id" : void 0, children: /* @__PURE__ */ jsx(IdCell, { row, text, idColumn, openLabel }) }),
1071
+ columns.map((column) => /* @__PURE__ */ jsx(Td, { className: cx(column.align === "end" && "uix-col--num", column.className) || void 0, ...ladderAttrs(ladderOn, column, true), children: column.cell(row) }, column.id)),
1072
+ hasActions && /* @__PURE__ */ jsx(RowActions, { "data-col": ladderOn ? "actions" : void 0, children: renderedActions })
1073
+ ]
1074
+ }
1075
+ );
990
1076
  }
991
1077
  const WorkspaceRow = memo(WorkspaceRowInner);
992
1078
  function IdCell({ row, text, idColumn, openLabel }) {
@@ -17,6 +17,12 @@ interface MotionListProps<T> extends Omit<HTMLAttributes<HTMLElement>, 'children
17
17
  }) => ReactElement;
18
18
  /** The list element (default `ul`). */
19
19
  as?: 'ul' | 'ol' | 'div' | 'tbody';
20
+ /**
21
+ * Called once the last leaving item has gone (its exit ended, or its deadline passed). A list
22
+ * that shows an empty state in its place keeps rendering the list, with no items, until this
23
+ * fires, so its last item leaves visibly too (HAR-2755).
24
+ */
25
+ onExited?: () => void;
20
26
  }
21
27
  /**
22
28
  * A list whose items arrive, leave and move visibly (HAR-2586, motion standard §2.5):
@@ -31,7 +37,7 @@ interface MotionListProps<T> extends Omit<HTMLAttributes<HTMLElement>, 'children
31
37
  * Reduced motion keeps the fades and drops every glide and rise. For a list that re-sorts
32
38
  * itself (live data), hold the order while the person is pointing at it: `useDeferredReorder`.
33
39
  */
34
- declare function MotionList<T>({ items, getKey, renderItem, as, className, ...props }: MotionListProps<T>): react.DetailedReactHTMLElement<{
40
+ declare function MotionList<T>({ items, getKey, renderItem, as, onExited, className, ...props }: MotionListProps<T>): react.DetailedReactHTMLElement<{
35
41
  ref: react.RefObject<HTMLElement>;
36
42
  className: string;
37
43
  onTransitionEnd: (event: TransitionEvent<HTMLElement>) => void;
@@ -5,7 +5,7 @@ import { prefersReducedMotion } from "../hooks/useReducedMotion.js";
5
5
  const useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
6
6
  const EXIT_FALLBACK_MS = 1e3;
7
7
  const FOCUSABLE = 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';
8
- function MotionList({ items, getKey, renderItem, as = "ul", className, ...props }) {
8
+ function MotionList({ items, getKey, renderItem, as = "ul", onExited, className, ...props }) {
9
9
  const containerRef = useRef(null);
10
10
  const [state, setState] = useState(() => ({
11
11
  items,
@@ -93,6 +93,14 @@ function MotionList({ items, getKey, renderItem, as = "ul", className, ...props
93
93
  const deadlines = useRef(/* @__PURE__ */ new Map());
94
94
  const exitingKeys = entries.filter((e) => e.exiting).map((e) => e.key);
95
95
  const exitingSignature = exitingKeys.join("\n");
96
+ const exitedRef = useRef(onExited);
97
+ exitedRef.current = onExited;
98
+ const wasExiting = useRef(false);
99
+ useEffect(() => {
100
+ const leaving = exitingSignature !== "";
101
+ if (wasExiting.current && !leaving) exitedRef.current?.();
102
+ wasExiting.current = leaving;
103
+ }, [exitingSignature]);
96
104
  useEffect(() => {
97
105
  const container = containerRef.current;
98
106
  const now = Date.now();
package/dist/index.cjs CHANGED
@@ -7555,7 +7555,7 @@ function DashboardCanvas({
7555
7555
  const placed = placeCanvasItem(live.current.layout, item.id, targetFor(move)).find((candidate) => candidate.id === item.id);
7556
7556
  if (!placed) return;
7557
7557
  last = { col: placed.col, row: placed.row, w: placed.w, h: placed.h };
7558
- setPreview({ id: item.id, placement: last });
7558
+ setPreview({ id: item.id, kind, placement: last });
7559
7559
  };
7560
7560
  const finish = (drop) => {
7561
7561
  drag.stop();
@@ -7618,10 +7618,12 @@ function DashboardCanvas({
7618
7618
  layout.map((item) => {
7619
7619
  const name = itemLabel(item);
7620
7620
  const dragging = preview?.id === item.id;
7621
+ const lifted = dragging && preview.kind === "move";
7621
7622
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
7622
7623
  "div",
7623
7624
  {
7624
7625
  className: cx("uix-dashboard-canvas__item", dragging && "uix-dashboard-canvas__item--dragging"),
7626
+ "data-uix-drag": lifted ? "lifted" : void 0,
7625
7627
  style: placementStyle(item, order.get(item.id) ?? 0),
7626
7628
  "data-canvas-id": item.id,
7627
7629
  children: [
@@ -12918,7 +12920,7 @@ var import_react85 = require("react");
12918
12920
  var useIsomorphicLayoutEffect20 = typeof document !== "undefined" ? import_react85.useLayoutEffect : import_react85.useEffect;
12919
12921
  var EXIT_FALLBACK_MS = 1e3;
12920
12922
  var FOCUSABLE = 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';
12921
- function MotionList({ items, getKey, renderItem, as = "ul", className, ...props }) {
12923
+ function MotionList({ items, getKey, renderItem, as = "ul", onExited, className, ...props }) {
12922
12924
  const containerRef = (0, import_react85.useRef)(null);
12923
12925
  const [state, setState] = (0, import_react85.useState)(() => ({
12924
12926
  items,
@@ -13006,6 +13008,14 @@ function MotionList({ items, getKey, renderItem, as = "ul", className, ...props
13006
13008
  const deadlines = (0, import_react85.useRef)(/* @__PURE__ */ new Map());
13007
13009
  const exitingKeys = entries.filter((e) => e.exiting).map((e) => e.key);
13008
13010
  const exitingSignature = exitingKeys.join("\n");
13011
+ const exitedRef = (0, import_react85.useRef)(onExited);
13012
+ exitedRef.current = onExited;
13013
+ const wasExiting = (0, import_react85.useRef)(false);
13014
+ (0, import_react85.useEffect)(() => {
13015
+ const leaving = exitingSignature !== "";
13016
+ if (wasExiting.current && !leaving) exitedRef.current?.();
13017
+ wasExiting.current = leaving;
13018
+ }, [exitingSignature]);
13009
13019
  (0, import_react85.useEffect)(() => {
13010
13020
  const container = containerRef.current;
13011
13021
  const now2 = Date.now();
@@ -15400,6 +15410,7 @@ var hiddenBy = (ladder, priority) => ladder === "priority" && priority === "low"
15400
15410
  var ROW_HEIGHT = { compact: 44, standard: 56, comfortable: 68 };
15401
15411
  var CONTROLS = 'a, button, input, select, textarea, label, summary, dialog, [role="button"], [role="menuitem"], [contenteditable="true"], [popover], td.uix-table__selcell, td.uix-table__actions';
15402
15412
  var RESERVED_COLS = /* @__PURE__ */ new Set(["select", "id", "actions", "expand"]);
15413
+ var MOTION_ROW_LIMIT = 12;
15403
15414
  var textOf2 = (node) => typeof node === "string" ? node : void 0;
15404
15415
  var columnLabel = (column) => column.label ?? textOf2(column.header);
15405
15416
  var ladderAttrs = (on, column, body) => on ? {
@@ -15443,6 +15454,7 @@ function DataWorkspace({
15443
15454
  pagination,
15444
15455
  status = "ready",
15445
15456
  refreshing = false,
15457
+ rowMotion = false,
15446
15458
  onRetry,
15447
15459
  loadingRows = 6,
15448
15460
  empty,
@@ -15529,6 +15541,13 @@ function DataWorkspace({
15529
15541
  const view = flat.length > 0 ? current : refreshing || source === settled.source ? settled : current;
15530
15542
  const shownRows = view.flat;
15531
15543
  const shownGroups = view.groups;
15544
+ const [exitHold, setExitHold] = (0, import_react93.useState)({ count: shownRows.length, filtered: view.filtered, refreshing, held: false });
15545
+ if (exitHold.count !== shownRows.length || exitHold.filtered !== view.filtered || exitHold.refreshing !== refreshing) {
15546
+ const held = rowMotion && shownRows.length === 0 && exitHold.count > 0 && exitHold.filtered === view.filtered && !exitHold.refreshing && !refreshing && !shownGroups && status === "ready" && stateOverride == null;
15547
+ setExitHold({ count: shownRows.length, filtered: view.filtered, refreshing, held });
15548
+ }
15549
+ const holdingExit = exitHold.held && shownRows.length === 0;
15550
+ const onRowsExited = (0, import_react93.useCallback)(() => setExitHold((current2) => current2.held ? { ...current2, held: false } : current2), []);
15532
15551
  const [ownCollapsed, setOwnCollapsed] = (0, import_react93.useState)(() => /* @__PURE__ */ new Set());
15533
15552
  const collapsed = collapsedGroups ?? ownCollapsed;
15534
15553
  const toggleGroupOpen = (groupId) => {
@@ -15643,7 +15662,7 @@ function DataWorkspace({
15643
15662
  if (stateOverride != null) body = busy(stateOverride);
15644
15663
  else if (status === "loading") body = /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(LoadingState, { rows: loadingRows, label: labels.loading, className: "uix-data-workspace__loading" });
15645
15664
  else if (status === "error") body = error != null ? busy(error) : /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(ErrorState, { title: labels.error, action: onRetry && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(Button, { size: "sm", onClick: onRetry, children: labels.retry }) });
15646
- else if (shownRows.length === 0) {
15665
+ else if (shownRows.length === 0 && !holdingExit) {
15647
15666
  const clear = /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(Button, { size: "sm", onClick: clearAll, children: labels.clearFilters });
15648
15667
  body = busy(view.filtered ? filteredEmpty ?? /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
15649
15668
  FilteredEmptyState,
@@ -15678,6 +15697,7 @@ function DataWorkspace({
15678
15697
  ladderOn: mobile != null,
15679
15698
  ladder,
15680
15699
  refreshing,
15700
+ rowMotion,
15681
15701
  selectable,
15682
15702
  selected,
15683
15703
  onPage,
@@ -15698,7 +15718,8 @@ function DataWorkspace({
15698
15718
  activateOnClick,
15699
15719
  activeRowId,
15700
15720
  onActiveRowChange,
15701
- labels
15721
+ labels,
15722
+ onRowsExited
15702
15723
  }
15703
15724
  );
15704
15725
  }
@@ -15771,6 +15792,7 @@ function WorkspaceTable({
15771
15792
  ladderOn,
15772
15793
  ladder,
15773
15794
  refreshing,
15795
+ rowMotion,
15774
15796
  selectable,
15775
15797
  selected,
15776
15798
  onPage,
@@ -15792,7 +15814,8 @@ function WorkspaceTable({
15792
15814
  onActiveRowChange,
15793
15815
  labels,
15794
15816
  windowing,
15795
- virtual
15817
+ virtual,
15818
+ onRowsExited
15796
15819
  }) {
15797
15820
  const cards = ladder === "cards";
15798
15821
  const wrapRef = (0, import_react93.useRef)(null);
@@ -16117,6 +16140,44 @@ function WorkspaceTable({
16117
16140
  rowId
16118
16141
  );
16119
16142
  };
16143
+ const renderLeavingRow = (row) => {
16144
+ const rowId = getRowId(row);
16145
+ return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
16146
+ WorkspaceRow,
16147
+ {
16148
+ row,
16149
+ rowId,
16150
+ rowLabel,
16151
+ columns,
16152
+ idColumn,
16153
+ getRowProps,
16154
+ selectable,
16155
+ selected: false,
16156
+ selectDisabled: true,
16157
+ hasActions,
16158
+ actions: null,
16159
+ ladder,
16160
+ ladderOn,
16161
+ selectRowLabel,
16162
+ openLabel,
16163
+ marked: false,
16164
+ nav: false,
16165
+ tabStop: false,
16166
+ handlers: handlers2
16167
+ },
16168
+ rowId
16169
+ );
16170
+ };
16171
+ const indexById = (0, import_react93.useMemo)(() => new Map(ids.map((rowId, index) => [rowId, index])), [ids]);
16172
+ const motion = (0, import_react93.useRef)({ ids, generation: 0 });
16173
+ if (motion.current.ids !== ids) {
16174
+ const before = new Set(motion.current.ids);
16175
+ const kept = ids.reduce((count2, rowId) => count2 + (before.has(rowId) ? 1 : 0), 0);
16176
+ const changed = ids.length - kept + (before.size - kept);
16177
+ const replaced = before.size > 0 && ids.length > 0 && (kept === 0 || changed > MOTION_ROW_LIMIT);
16178
+ motion.current = { ids, generation: motion.current.generation + (replaced ? 1 : 0) };
16179
+ }
16180
+ const motionGeneration = motion.current.generation;
16120
16181
  let tbody;
16121
16182
  if (groups) {
16122
16183
  let offset = 0;
@@ -16169,12 +16230,30 @@ function WorkspaceTable({
16169
16230
  });
16170
16231
  } else {
16171
16232
  const spacer = (height, key) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("tr", { "aria-hidden": "true", className: "uix-data-workspace__spacer", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("td", { colSpan: colCount, style: { height } }) }, key);
16172
- tbody = /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)("tbody", { children: [
16173
- virtual && windowed && start > 0 && spacer(virtual.padTop, "pad-top"),
16174
- windowed && start > 0 && start % 2 === 0 && spacer(0, "pad-zebra"),
16233
+ tbody = windowed || !rowMotion ? /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)("tbody", { children: [
16234
+ virtual && start > 0 && spacer(virtual.padTop, "pad-top"),
16235
+ start > 0 && start % 2 === 0 && spacer(0, "pad-zebra"),
16175
16236
  mountedRows.map((row, at2) => renderRow(row, start + at2)),
16176
- virtual && windowed && virtual.padBottom > 0 && spacer(virtual.padBottom, "pad-bottom")
16177
- ] });
16237
+ virtual && virtual.padBottom > 0 && spacer(virtual.padBottom, "pad-bottom")
16238
+ ] }) : (
16239
+ // Row motion (HAR-2755): a row a live update adds rises in, a row a bulk action removes fades
16240
+ // out while the rows after it glide up, a re-sort glides. A new page, filter or view that
16241
+ // replaces most rows remounts the body instead (`motionGeneration`), so it swaps at once.
16242
+ /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
16243
+ MotionList,
16244
+ {
16245
+ as: "tbody",
16246
+ items: rows,
16247
+ getKey: getRowId,
16248
+ onExited: onRowsExited,
16249
+ renderItem: (row, { exiting }) => {
16250
+ const index = exiting ? void 0 : indexById.get(getRowId(row));
16251
+ return index === void 0 ? renderLeavingRow(row) : renderRow(row, index);
16252
+ }
16253
+ },
16254
+ motionGeneration
16255
+ )
16256
+ );
16178
16257
  }
16179
16258
  const wrapStyle = long ? { "--uix-table-max-height": `${maxHeight}px` } : void 0;
16180
16259
  return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
@@ -16270,7 +16349,10 @@ function WorkspaceRowInner({
16270
16349
  ariaRowIndex,
16271
16350
  nav,
16272
16351
  tabStop,
16273
- handlers: handlers2
16352
+ handlers: handlers2,
16353
+ "data-uix-key": motionKey,
16354
+ "data-uix-exiting": motionExiting,
16355
+ "aria-hidden": motionHidden
16274
16356
  }) {
16275
16357
  const renderedActions = (0, import_react93.useMemo)(
16276
16358
  () => lazyRowActions ? lazyRowActions(row, { ladder, compact: ladder === "priority-mid" }) : actions,
@@ -16297,22 +16379,35 @@ function WorkspaceRowInner({
16297
16379
  handlers2.blur(rowId, event);
16298
16380
  }
16299
16381
  } : {};
16300
- return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(Tr, { selected, "data-uix-row-id": marked ? rowId : void 0, "aria-rowindex": ariaRowIndex, ...extra, ...navProps, children: [
16301
- selectable && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("td", { className: "uix-table__selcell", "data-col": ladderOn ? "select" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
16302
- Checkbox,
16303
- {
16304
- "aria-label": fillLabel(selectRowLabel, { label: text }),
16305
- checked: selected,
16306
- disabled: selectDisabled,
16307
- onClick: (event) => handlers2.toggle(rowId, event.currentTarget.checked, event),
16308
- onChange: () => {
16309
- }
16310
- }
16311
- ) }),
16312
- idColumn && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(Td, { className: "uix-id-cell", "data-col": ladderOn ? "id" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(IdCell, { row, text, idColumn, openLabel }) }),
16313
- columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(Td, { className: cx(column.align === "end" && "uix-col--num", column.className) || void 0, ...ladderAttrs(ladderOn, column, true), children: column.cell(row) }, column.id)),
16314
- hasActions && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(RowActions, { "data-col": ladderOn ? "actions" : void 0, children: renderedActions })
16315
- ] });
16382
+ return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
16383
+ Tr,
16384
+ {
16385
+ selected,
16386
+ "data-uix-row-id": marked ? rowId : void 0,
16387
+ "aria-rowindex": ariaRowIndex,
16388
+ ...extra,
16389
+ ...navProps,
16390
+ "data-uix-key": motionKey,
16391
+ "data-uix-exiting": motionExiting,
16392
+ "aria-hidden": motionHidden,
16393
+ children: [
16394
+ selectable && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("td", { className: "uix-table__selcell", "data-col": ladderOn ? "select" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
16395
+ Checkbox,
16396
+ {
16397
+ "aria-label": fillLabel(selectRowLabel, { label: text }),
16398
+ checked: selected,
16399
+ disabled: selectDisabled,
16400
+ onClick: (event) => handlers2.toggle(rowId, event.currentTarget.checked, event),
16401
+ onChange: () => {
16402
+ }
16403
+ }
16404
+ ) }),
16405
+ idColumn && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(Td, { className: "uix-id-cell", "data-col": ladderOn ? "id" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(IdCell, { row, text, idColumn, openLabel }) }),
16406
+ columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(Td, { className: cx(column.align === "end" && "uix-col--num", column.className) || void 0, ...ladderAttrs(ladderOn, column, true), children: column.cell(row) }, column.id)),
16407
+ hasActions && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(RowActions, { "data-col": ladderOn ? "actions" : void 0, children: renderedActions })
16408
+ ]
16409
+ }
16410
+ );
16316
16411
  }
16317
16412
  var WorkspaceRow = (0, import_react93.memo)(WorkspaceRowInner);
16318
16413
  function IdCell({ row, text, idColumn, openLabel }) {
package/dist/index.d.cts CHANGED
@@ -5553,6 +5553,17 @@ interface DataWorkspaceProps<T, S extends DataWorkspaceSortState = DataWorkspace
5553
5553
  status?: 'ready' | 'loading' | 'error';
5554
5554
  /** A refetch (filter, sort, page, saved view): the rows stay under `TableWrap refreshing`. */
5555
5555
  refreshing?: boolean;
5556
+ /**
5557
+ * Row motion (HAR-2755, list motion of the motion standard §2.5): a row that arrives (a live
5558
+ * update, the "new items" pill) rises in; a row that leaves (a bulk close, a row handled
5559
+ * elsewhere) fades out while the rows after it glide into its place, and the empty state waits
5560
+ * for the last one; a re-sort glides. A new page, filter or view that replaces most rows swaps
5561
+ * at once. Focus moves to a neighbour when its row leaves. Reduced motion keeps the fades only.
5562
+ * Not for grouped or windowed bodies, which keep plain rows. A leaving row stays in the DOM
5563
+ * (inert, `aria-hidden`) until its exit ends, so a test that counts rows right after a removal
5564
+ * sees it for up to a second. Default `false`.
5565
+ */
5566
+ rowMotion?: boolean;
5556
5567
  onRetry?: () => void;
5557
5568
  /** Skeleton rows on a first load. Default 6. */
5558
5569
  loadingRows?: number;
@@ -5612,7 +5623,7 @@ interface DataWorkspaceProps<T, S extends DataWorkspaceSortState = DataWorkspace
5612
5623
  * rich id cell, multi-column sort, the product's state bodies and `beforeBody`, row groups,
5613
5624
  * windowing (`virtualize`) and a keyboard row model (`onRowActivate`).
5614
5625
  */
5615
- declare function DataWorkspace<T, S extends DataWorkspaceSortState = DataWorkspaceSort | null>({ label, rows, getRowId, rowLabel, columns, idColumn, sort, onSortChange, selection, onSelectionChange, maxSelection, bulkActions, rowActions, rowActionsColumn, getRowProps, density, zebra, freezeFirstColumn, fixed, mobile, search, filters, savedViews, viewMenu, viewChanged, onSaveView, onSaveViewAs, saveViewAs, maximized, onMaximizedChange, toolbarEnd, beforeBody, pagination, status, refreshing, onRetry, loadingRows, empty, emptyAction, filteredEmpty, filteredEmptyAction, error, stateOverride, groups, collapsedGroups, onCollapsedGroupsChange, virtualize, rowNavigation, onRowActivate, activateOnClick, activeRowId, onActiveRowChange, multiSort, labels: labelOverrides, className, ...props }: DataWorkspaceProps<T, S>): react.JSX.Element;
5626
+ declare function DataWorkspace<T, S extends DataWorkspaceSortState = DataWorkspaceSort | null>({ label, rows, getRowId, rowLabel, columns, idColumn, sort, onSortChange, selection, onSelectionChange, maxSelection, bulkActions, rowActions, rowActionsColumn, getRowProps, density, zebra, freezeFirstColumn, fixed, mobile, search, filters, savedViews, viewMenu, viewChanged, onSaveView, onSaveViewAs, saveViewAs, maximized, onMaximizedChange, toolbarEnd, beforeBody, pagination, status, refreshing, rowMotion, onRetry, loadingRows, empty, emptyAction, filteredEmpty, filteredEmptyAction, error, stateOverride, groups, collapsedGroups, onCollapsedGroupsChange, virtualize, rowNavigation, onRowActivate, activateOnClick, activeRowId, onActiveRowChange, multiSort, labels: labelOverrides, className, ...props }: DataWorkspaceProps<T, S>): react.JSX.Element;
5616
5627
 
5617
5628
  /**
5618
5629
  * Kit chrome strings by component (HAR-1358; TENSOR C20, MOTUS executive summary #3).
@@ -8251,6 +8262,12 @@ interface MotionListProps<T> extends Omit<HTMLAttributes<HTMLElement>, 'children
8251
8262
  }) => ReactElement;
8252
8263
  /** The list element (default `ul`). */
8253
8264
  as?: 'ul' | 'ol' | 'div' | 'tbody';
8265
+ /**
8266
+ * Called once the last leaving item has gone (its exit ended, or its deadline passed). A list
8267
+ * that shows an empty state in its place keeps rendering the list, with no items, until this
8268
+ * fires, so its last item leaves visibly too (HAR-2755).
8269
+ */
8270
+ onExited?: () => void;
8254
8271
  }
8255
8272
  /**
8256
8273
  * A list whose items arrive, leave and move visibly (HAR-2586, motion standard §2.5):
@@ -8265,7 +8282,7 @@ interface MotionListProps<T> extends Omit<HTMLAttributes<HTMLElement>, 'children
8265
8282
  * Reduced motion keeps the fades and drops every glide and rise. For a list that re-sorts
8266
8283
  * itself (live data), hold the order while the person is pointing at it: `useDeferredReorder`.
8267
8284
  */
8268
- declare function MotionList<T>({ items, getKey, renderItem, as, className, ...props }: MotionListProps<T>): react.DetailedReactHTMLElement<{
8285
+ declare function MotionList<T>({ items, getKey, renderItem, as, onExited, className, ...props }: MotionListProps<T>): react.DetailedReactHTMLElement<{
8269
8286
  ref: react.RefObject<HTMLElement>;
8270
8287
  className: string;
8271
8288
  onTransitionEnd: (event: TransitionEvent<HTMLElement>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensor_1/react",
3
- "version": "2.57.0",
3
+ "version": "2.58.0",
4
4
  "description": "Thin React wrappers over the UIx v2 CSS component library.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",