@mittwald/flow-react-components 1.6.0-next.20 → 1.6.0-next.21

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 (32) hide show
  1. package/dist/assets/component-index.json +1 -1
  2. package/dist/assets/doc-properties.json +1 -1
  3. package/dist/js/default.mjs +1 -1
  4. package/dist/js/packages/components/src/components/List/components/Items/Items.mjs +3 -0
  5. package/dist/js/packages/components/src/components/List/components/Items/Items.mjs.map +1 -1
  6. package/dist/js/packages/components/src/components/List/components/Items/components/Item/Item.mjs +1 -1
  7. package/dist/js/packages/components/src/components/List/components/Items/components/Item/Item.mjs.map +1 -1
  8. package/dist/js/packages/components/src/components/List/components/Items/components/Item/hooks/useGridItemProps.mjs +1 -2
  9. package/dist/js/packages/components/src/components/List/components/Items/components/Item/hooks/useGridItemProps.mjs.map +1 -1
  10. package/dist/js/packages/components/src/components/List/components/Table/Table.mjs +8 -12
  11. package/dist/js/packages/components/src/components/List/components/Table/Table.mjs.map +1 -1
  12. package/dist/js/packages/components/src/components/List/components/Table/components/Row.mjs +31 -0
  13. package/dist/js/packages/components/src/components/List/components/Table/components/Row.mjs.map +1 -0
  14. package/dist/js/packages/components/src/components/List/hooks/useLatestOnAction.mjs +21 -0
  15. package/dist/js/packages/components/src/components/List/hooks/useLatestOnAction.mjs.map +1 -0
  16. package/dist/js/packages/components/src/components/List/model/List.mjs +1 -0
  17. package/dist/js/packages/components/src/components/List/model/List.mjs.map +1 -1
  18. package/dist/js/packages/components/src/components/List/model/item/ItemView.mjs +20 -7
  19. package/dist/js/packages/components/src/components/List/model/item/ItemView.mjs.map +1 -1
  20. package/dist/js/packages/components/src/components/List/model/table/TableCell.mjs +1 -1
  21. package/dist/js/packages/components/src/components/List/model/table/TableCell.mjs.map +1 -1
  22. package/dist/js/packages/components/src/components/List/model/table/TableRow.mjs +28 -1
  23. package/dist/js/packages/components/src/components/List/model/table/TableRow.mjs.map +1 -1
  24. package/dist/types/components/List/components/Items/components/Item/Item.d.ts +2 -0
  25. package/dist/types/components/List/components/Items/components/Item/hooks/useGridItemProps.d.ts +1 -0
  26. package/dist/types/components/List/components/Table/components/Row.d.ts +13 -0
  27. package/dist/types/components/List/hooks/useLatestOnAction.d.ts +7 -0
  28. package/dist/types/components/List/model/item/ItemView.d.ts +34 -11
  29. package/dist/types/components/List/model/table/TableRow.d.ts +14 -0
  30. package/dist/types/components/List/model/table/types.d.ts +17 -1
  31. package/dist/types/components/List/typedList.d.ts +1 -0
  32. package/package.json +10 -10
@@ -2,7 +2,15 @@ import { DependencyList, HTMLAttributeAnchorTarget, ReactElement, ReactNode } fr
2
2
  import { RenderItemFn } from './types';
3
3
  import { default as List } from '../List';
4
4
  export interface ItemViewShape<T> {
5
+ /**
6
+ * Runs on every render of the list to tell whether the item changed, so it
7
+ * should be cheap and pure.
8
+ */
5
9
  textValue?: (data: T) => string;
10
+ /**
11
+ * Runs on every render of the list to tell whether the item changed, so it
12
+ * should be cheap and pure.
13
+ */
6
14
  href?: (data: T) => string;
7
15
  target?: HTMLAttributeAnchorTarget;
8
16
  defaultExpanded?: (data: T) => boolean;
@@ -14,14 +22,23 @@ export interface ItemViewShape<T> {
14
22
  showTiles?: boolean;
15
23
  tileMaxWidth?: number;
16
24
  /**
17
- * Values this item's content depends on besides its own data.
25
+ * Everything the render function reads besides the item's data.
18
26
  *
19
- * An item re-renders when its data changes, or when one of the render
20
- * functions on its `List.Item` changes identity — which a function written
21
- * inline in JSX does on every render of its parent. A render function with a
22
- * stable identity (hoisted out of the component, wrapped in `useCallback`, or
23
- * reading from an external store) has to list what it reads here, or the item
24
- * keeps the values it first saw.
27
+ * With `renderDependencies`, an item re-renders only when its data or one of
28
+ * these values changes. The render function's identity no longer counts, so a
29
+ * function written inline in JSX keeps the item from re-rendering on every
30
+ * render of its parent. List every value it reads from outside the item,
31
+ * including state read through the `list` argument — one left out keeps the
32
+ * item on the value it last rendered.
33
+ *
34
+ * Without it, an item re-renders whenever its render function changes
35
+ * identity, which an inline function does on every render of its parent.
36
+ */
37
+ renderDependencies?: DependencyList;
38
+ /**
39
+ * @deprecated Use `renderDependencies` instead. `dependencies` only adds to
40
+ * the render function's identity, so an inline render function still
41
+ * re-renders the item on every render of its parent.
25
42
  */
26
43
  dependencies?: DependencyList;
27
44
  }
@@ -35,15 +52,21 @@ export declare class ItemView<T> {
35
52
  readonly showTiles?: boolean;
36
53
  readonly showList?: boolean;
37
54
  readonly tileMaxWidth: number;
55
+ readonly renderDependencies?: DependencyList;
38
56
  readonly dependencies?: DependencyList;
39
57
  private readonly renderFn?;
58
+ private lastComparison?;
40
59
  constructor(list: List<T>, shape?: ItemViewShape<T>);
41
60
  private static fallbackRenderItemFn;
42
61
  /**
43
- * Whether `other` would render this item identically — i.e. all render
44
- * functions taken from the consumer's `ListItem` element are still the same,
45
- * and the dependencies it declared have not changed.
62
+ * Whether `other` would render the item holding `data` identically. The
63
+ * render function counts by its `renderDependencies` where given, otherwise
64
+ * by its identity and the deprecated `dependencies`. `textValue` and `href`
65
+ * count by what they return for `data`, so inline functions do not re-render
66
+ * the item. `defaultExpanded` is read on mount only, so it does not count at
67
+ * all.
46
68
  */
47
- rendersSameAs(other?: ItemView<T>): boolean;
69
+ rendersSameFor(other: ItemView<T> | undefined, data: T): boolean;
70
+ private rendersSameContentAs;
48
71
  render(data: T): ReactNode;
49
72
  }
@@ -1,9 +1,23 @@
1
1
  import { TableRowShape, TableRowSupportedComponentProps } from './types';
2
2
  import { TableCell } from './TableCell';
3
3
  import { TableBody } from './TableBody';
4
+ import { DependencyList } from 'react';
4
5
  export declare class TableRow<T> {
5
6
  readonly tableBody: TableBody<T>;
6
7
  readonly cells: TableCell<T>[];
7
8
  readonly componentProps: TableRowSupportedComponentProps;
9
+ readonly renderDependencies?: DependencyList;
10
+ private lastComparison?;
8
11
  constructor(tableBody: TableBody<T>, shape?: TableRowShape<T>);
12
+ /**
13
+ * Whether `other` would render a row identically. Only rows that declare
14
+ * `renderDependencies` can tell, since the cells' render functions count by
15
+ * those instead of their identity. Rows without them always re-render. Row
16
+ * and cell props count by identity, one by one.
17
+ *
18
+ * Every row of a render shares one model, so the result is cached for the
19
+ * last `other`.
20
+ */
21
+ rendersSameAs(other?: TableRow<T>): boolean;
22
+ private compareWith;
9
23
  }
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, ReactElement } from 'react';
1
+ import { DependencyList, PropsWithChildren, ReactElement } from 'react';
2
2
  import { TableBodyProps, TableCellProps, TableColumnProps, TableHeaderProps, TableProps, TableRowProps } from '../../../Table';
3
3
  import { RenderItemFn } from '../..';
4
4
  /** Cell */
@@ -13,6 +13,22 @@ export type TableRowSupportedComponentProps = Omit<TableRowProps, "onAction" | "
13
13
  };
14
14
  export interface TableRowShape<T> extends TableRowSupportedComponentProps, PropsWithChildren {
15
15
  cells?: TableCellShape<T>[];
16
+ /**
17
+ * Everything the cells' render functions read besides the row's data.
18
+ *
19
+ * With `renderDependencies`, a row re-renders only when its data, one of
20
+ * these values, or a cell's props change. The render functions' identity does
21
+ * not count, so functions written inline in JSX keep the row from
22
+ * re-rendering on every render of its parent. List every value they read from
23
+ * outside the row, including state read through the `list` argument — one
24
+ * left out keeps the row on the value it last rendered.
25
+ *
26
+ * Row and cell props count by identity, so an inline `style` object or
27
+ * callback on `List.TableRow` or `List.TableCell` re-renders every row.
28
+ *
29
+ * Without it, every row re-renders whenever the list does.
30
+ */
31
+ renderDependencies?: DependencyList;
16
32
  }
17
33
  /** Column */
18
34
  export type TableColumnSupportedComponentProps = TableColumnProps;
@@ -127,6 +127,7 @@ export declare const typedList: <T, TMeta = unknown>() => {
127
127
  columns?: Iterable<never> | undefined;
128
128
  disabledBehavior?: import('react-stately').DisabledBehavior | undefined;
129
129
  hasChildItems?: boolean | undefined;
130
+ renderDependencies?: import('react').DependencyList | undefined;
130
131
  }) => null;
131
132
  TableCell: (ignoredProps: Omit<import('./model/table/types').TableCellShape<T>, "renderFn"> & {
132
133
  children: import('.').RenderItemFn<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "1.6.0-next.20",
3
+ "version": "1.6.0-next.21",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://flow.mittwald.de",
@@ -84,9 +84,9 @@
84
84
  "@internationalized/string-compiler": "^3.4.1",
85
85
  "@lezer/common": "^1.5.2",
86
86
  "@lezer/highlight": "^1.2.3",
87
- "@mittwald/flow-icons": "^1.6.0-next.20",
87
+ "@mittwald/flow-icons": "^1.6.0-next.21",
88
88
  "@mittwald/password-tools-js": "^3.0.0",
89
- "@mittwald/react-tunnel": "^1.6.0-next.20",
89
+ "@mittwald/react-tunnel": "^1.6.0-next.21",
90
90
  "@mittwald/react-use-promise": "^4.2.2",
91
91
  "@react-aria/form": "^3.2.1",
92
92
  "@react-aria/i18n": "^3.13.1",
@@ -139,13 +139,13 @@
139
139
  "@internationalized/date": "^3.12.3",
140
140
  "@lezer/generator": "^1.8.0",
141
141
  "@lezer/lr": "^1.4.10",
142
- "@mittwald/flow-components-base": "1.6.0-next.20",
143
- "@mittwald/flow-core": "1.6.0-next.20",
144
- "@mittwald/flow-design-tokens": "1.6.0-next.20",
145
- "@mittwald/flow-icons-base": "1.6.0-next.20",
142
+ "@mittwald/flow-components-base": "1.6.0-next.21",
143
+ "@mittwald/flow-core": "1.6.0-next.21",
144
+ "@mittwald/flow-design-tokens": "1.6.0-next.21",
145
+ "@mittwald/flow-icons-base": "1.6.0-next.21",
146
146
  "@mittwald/react-use-promise": "^4.2.2",
147
147
  "@mittwald/remote-dom-react": "1.2.2-mittwald.10",
148
- "@mittwald/typescript-config": "1.6.0-next.20",
148
+ "@mittwald/typescript-config": "1.6.0-next.21",
149
149
  "@nx/storybook": "^22.7.6",
150
150
  "@storybook/addon-a11y": "^10.5.10",
151
151
  "@storybook/addon-actions": "^9.0.8",
@@ -199,7 +199,7 @@
199
199
  },
200
200
  "peerDependencies": {
201
201
  "@internationalized/date": "^3.12.2",
202
- "@mittwald/flow-icons-pro": "1.6.0-next.20",
202
+ "@mittwald/flow-icons-pro": "1.6.0-next.21",
203
203
  "@mittwald/react-use-promise": "^4.2.2",
204
204
  "next": "^16.2.3",
205
205
  "react": "^19.2.0",
@@ -223,5 +223,5 @@
223
223
  "browserslist": [
224
224
  "baseline widely available"
225
225
  ],
226
- "gitHead": "151ddc103234bdf6b7832702e594639431c27fbd"
226
+ "gitHead": "c75ca489f4a68d285b3a7513fab391ef31978680"
227
227
  }