@gtkx/components 2.0.0-beta.12 → 2.0.0-beta.13

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 (100) hide show
  1. package/README.md +1 -1
  2. package/dist/column-view.d.ts.map +1 -1
  3. package/dist/column-view.js +7 -3
  4. package/dist/column-view.js.map +1 -1
  5. package/dist/combo-row.d.ts.map +1 -1
  6. package/dist/combo-row.js +3 -1
  7. package/dist/combo-row.js.map +1 -1
  8. package/dist/grid-view.d.ts.map +1 -1
  9. package/dist/grid-view.js +3 -2
  10. package/dist/grid-view.js.map +1 -1
  11. package/dist/index.d.ts +1 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +0 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/internal/cells.d.ts +5 -2
  16. package/dist/internal/cells.d.ts.map +1 -1
  17. package/dist/internal/cells.js +86 -43
  18. package/dist/internal/cells.js.map +1 -1
  19. package/dist/internal/collection-index.d.ts +3 -5
  20. package/dist/internal/collection-index.d.ts.map +1 -1
  21. package/dist/internal/collection-index.js +3 -7
  22. package/dist/internal/collection-index.js.map +1 -1
  23. package/dist/internal/collection-model.d.ts +15 -4
  24. package/dist/internal/collection-model.d.ts.map +1 -1
  25. package/dist/internal/collection-model.js +154 -73
  26. package/dist/internal/collection-model.js.map +1 -1
  27. package/dist/internal/collection.d.ts +3 -3
  28. package/dist/internal/collection.d.ts.map +1 -1
  29. package/dist/internal/collection.js +11 -9
  30. package/dist/internal/collection.js.map +1 -1
  31. package/dist/internal/controlled-sync.d.ts +2 -1
  32. package/dist/internal/controlled-sync.d.ts.map +1 -1
  33. package/dist/internal/controlled-sync.js +6 -1
  34. package/dist/internal/controlled-sync.js.map +1 -1
  35. package/dist/internal/drop-down.d.ts +10 -4
  36. package/dist/internal/drop-down.d.ts.map +1 -1
  37. package/dist/internal/drop-down.js +60 -8
  38. package/dist/internal/drop-down.js.map +1 -1
  39. package/dist/internal/expansion.d.ts.map +1 -1
  40. package/dist/internal/expansion.js +46 -19
  41. package/dist/internal/expansion.js.map +1 -1
  42. package/dist/internal/first-header.d.ts +11 -0
  43. package/dist/internal/first-header.d.ts.map +1 -0
  44. package/dist/internal/first-header.js +21 -0
  45. package/dist/internal/first-header.js.map +1 -0
  46. package/dist/internal/level-splice.d.ts +27 -0
  47. package/dist/internal/level-splice.d.ts.map +1 -0
  48. package/dist/internal/level-splice.js +98 -0
  49. package/dist/internal/level-splice.js.map +1 -0
  50. package/dist/internal/selection.d.ts.map +1 -1
  51. package/dist/internal/selection.js +23 -16
  52. package/dist/internal/selection.js.map +1 -1
  53. package/dist/internal/tree-expansion.d.ts +3 -1
  54. package/dist/internal/tree-expansion.d.ts.map +1 -1
  55. package/dist/internal/tree-expansion.js +31 -2
  56. package/dist/internal/tree-expansion.js.map +1 -1
  57. package/dist/internal/tree-order.d.ts +1 -0
  58. package/dist/internal/tree-order.d.ts.map +1 -1
  59. package/dist/internal/tree-order.js +2 -1
  60. package/dist/internal/tree-order.js.map +1 -1
  61. package/dist/internal/use-collection.d.ts +1 -0
  62. package/dist/internal/use-collection.d.ts.map +1 -1
  63. package/dist/internal/use-collection.js +6 -2
  64. package/dist/internal/use-collection.js.map +1 -1
  65. package/dist/list-item-factory.d.ts +1 -1
  66. package/dist/list-item-factory.d.ts.map +1 -1
  67. package/dist/list-item-factory.js +2 -2
  68. package/dist/list-item-factory.js.map +1 -1
  69. package/dist/list-view.d.ts.map +1 -1
  70. package/dist/list-view.js +8 -3
  71. package/dist/list-view.js.map +1 -1
  72. package/dist/types.d.ts +37 -47
  73. package/dist/types.d.ts.map +1 -1
  74. package/dist/types.js.map +1 -1
  75. package/package.json +8 -8
  76. package/src/column-view.tsx +8 -4
  77. package/src/combo-row.tsx +4 -1
  78. package/src/grid-view.tsx +3 -2
  79. package/src/index.ts +0 -4
  80. package/src/internal/cells.tsx +141 -53
  81. package/src/internal/collection-index.ts +7 -14
  82. package/src/internal/collection-model.ts +211 -76
  83. package/src/internal/collection.ts +14 -13
  84. package/src/internal/controlled-sync.ts +8 -1
  85. package/src/internal/drop-down.tsx +111 -14
  86. package/src/internal/expansion.ts +52 -20
  87. package/src/internal/first-header.ts +23 -0
  88. package/src/internal/level-splice.ts +157 -0
  89. package/src/internal/selection.tsx +24 -19
  90. package/src/internal/tree-expansion.ts +52 -2
  91. package/src/internal/tree-order.ts +3 -1
  92. package/src/internal/use-collection.tsx +8 -2
  93. package/src/list-item-factory.tsx +2 -1
  94. package/src/list-view.tsx +10 -2
  95. package/src/types.ts +39 -51
  96. package/dist/tab-collection.d.ts +0 -9
  97. package/dist/tab-collection.d.ts.map +0 -1
  98. package/dist/tab-collection.js +0 -114
  99. package/dist/tab-collection.js.map +0 -1
  100. package/src/tab-collection.tsx +0 -124
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Collection views, selection controls, tabs, and toasts for GTKX.
4
4
 
5
- Use `ListView`, `GridView`, and `ColumnView` with React data and render functions, or `DropDown` and `ComboRow` for selection controls. `createTabCollection` preserves tab state across windows. `ToastProvider` and `useToast` manage notifications.
5
+ Use `ListView`, `GridView`, and `ColumnView` with React data and render functions, or `DropDown` and `ComboRow` for selection controls. `ToastProvider` and `useToast` manage notifications.
6
6
 
7
7
  In an existing GTKX app:
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"column-view.d.ts","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAQlD,OAAO,KAAK,EAAoB,eAAe,EAAmC,MAAM,YAAY,CAAC;AA4LrG;;;;GAIG;AACH,iBAAS,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAiCrF;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"column-view.d.ts","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAQlD,OAAO,KAAK,EAAoB,eAAe,EAAmC,MAAM,YAAY,CAAC;AAgMrG;;;;GAIG;AACH,iBAAS,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAiCrF;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -7,6 +7,7 @@ import { useMemo, useRef } from "react";
7
7
  import { ItemPortals, useItemCells, useRowProps, useSectionHeader } from "./internal/cells.js";
8
8
  import { useControlledSync } from "./internal/controlled-sync.js";
9
9
  import { useCollection } from "./internal/use-collection.js";
10
+ import { showFirstHeader } from "./internal/first-header.js";
10
11
  import { useWidgetRef } from "./internal/use-widget-ref.js";
11
12
  const COLUMN_VIEW_PROPS = [
12
13
  "items",
@@ -27,7 +28,10 @@ const COLUMN_VIEW_PROPS = [
27
28
  "estimatedItemHeight",
28
29
  "ref",
29
30
  ];
30
- const expanderIndexFor = (columns) => columns.findIndex((column) => column.visible !== false);
31
+ const expanderIndexFor = (columns) => {
32
+ const marked = columns.findIndex((column) => column.hasExpander === true && column.visible !== false);
33
+ return marked === -1 ? columns.findIndex((column) => column.visible !== false) : marked;
34
+ };
31
35
  const columnById = (view, id) => {
32
36
  const columns = view.getColumns();
33
37
  for (let index = 0; index < columns.getNItems(); index++) {
@@ -94,7 +98,7 @@ const useColumnSorting = (view, sort, columns) => {
94
98
  };
95
99
  const ColumnCells = ({ column, hasExpander, collection, expandedIds, expanderDescriptions, size, }) => {
96
100
  const cells = useItemCells(size);
97
- const rest = omit(column, ["id", "renderCell", "isSortable"]);
101
+ const rest = omit(column, ["id", "renderCell", "isSortable", "hasExpander"]);
98
102
  return (_jsxs(_Fragment, { children: [_jsx(GtkColumnViewColumn, { id: column.id, factory: _jsx(GtkSignalListItemFactory, { ...cells.handlers }), sorter: column.isSortable === true ? _jsx(GtkCustomSorter, {}) : null, ...rest }), _jsx(ItemPortals, { registry: cells, render: column.renderCell, collection: collection, hasExpander: hasExpander, expandedIds: expandedIds, expanderDescriptions: expanderDescriptions })] }));
99
103
  };
100
104
  const ColumnList = ({ columns, collection, expandedIds, expanderDescriptions, size }) => {
@@ -112,7 +116,7 @@ function ColumnView(props) {
112
116
  const rest = omit(props, COLUMN_VIEW_PROPS);
113
117
  const size = { width: -1, height: props.estimatedItemHeight ?? -1 };
114
118
  const [view, refCallback] = useWidgetRef(ref);
115
- const { collection, selection } = useCollection(props);
119
+ const { collection, selection } = useCollection({ ...props, onSectionsFilled: () => showFirstHeader(view) });
116
120
  const header = useSectionHeader(renderHeader, collection, size);
117
121
  const rows = useRowProps(rowProps, collection, expandedIds);
118
122
  const columnList = columns;
@@ -1 +1 @@
1
- {"version":3,"file":"column-view.js","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIxC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAkB5D,MAAM,iBAAiB,GAAG;IACtB,OAAO;IACP,UAAU;IACV,QAAQ;IACR,cAA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,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,mBAAmB,IAAI,CAAC,CAAC,EAAE,CAAC;IACpE,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,YAAY,CAAiB,GAAG,CAAC,CAAC;IAC9D,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,gBAAgB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,OAAoC,CAAC;IACxD,gBAAgB,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,UAAU,CAAC,CAAC;IAE7E,OAAO,CACH,8BACI,KAAC,aAAa,IACV,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,SAAS,KACZ,MAAM,CAAC,YAAY,KACnB,IAAI,CAAC,YAAY,KACjB,IAAI,YAER,KAAC,UAAU,IACP,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,IAAI,EAAE,IAAI,GACZ,GACU,EACf,MAAM,CAAC,OAAO,EACd,IAAI,CAAC,OAAO,IACd,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkColumnView, GtkColumnViewColumn, GtkCustomSorter, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { useSignal } from \"@gtkx/react\";\nimport { omit } from \"@gtkx/utils\";\nimport { useMemo, useRef } from \"react\";\nimport type { CellSize } from \"./internal/cells.js\";\nimport type { Collection } from \"./internal/collection.js\";\nimport type { ColumnViewColumn, ColumnViewProps, ExpanderDescriptions, SortProps } from \"./types.js\";\nimport { ItemPortals, useItemCells, useRowProps, useSectionHeader } from \"./internal/cells.js\";\nimport { useControlledSync } from \"./internal/controlled-sync.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\nimport { useWidgetRef } from \"./internal/use-widget-ref.js\";\n\ntype SortTarget = { view: Gtk.ColumnView; column: Gtk.ColumnViewColumn | null };\ntype SortRequest = Pick<SortProps, \"sortColumn\" | \"sortOrder\">;\n\ntype ColumnCellsProps = {\n column: ColumnViewColumn<never>;\n hasExpander: boolean;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n expanderDescriptions: ExpanderDescriptions | null | undefined;\n size: CellSize;\n};\n\ntype ColumnListProps = Omit<ColumnCellsProps, \"column\" | \"hasExpander\"> & {\n columns: ColumnViewColumn<never>[];\n};\n\nconst COLUMN_VIEW_PROPS = [\n \"items\",\n \"sections\",\n \"isFlat\",\n \"renderHeader\",\n \"rowProps\",\n \"columns\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"expandedIds\",\n \"onExpandedChange\",\n \"expanderDescriptions\",\n \"sortColumn\",\n \"sortOrder\",\n \"onSortChanged\",\n \"estimatedItemHeight\",\n \"ref\",\n] as const satisfies (keyof ColumnViewProps)[];\n\nconst expanderIndexFor = (columns: ColumnViewColumn<never>[]): number =>\n columns.findIndex((column) => column.visible !== false);\n\nconst columnById = (view: Gtk.ColumnView, id: string): Gtk.ColumnViewColumn | null => {\n const columns = view.getColumns();\n\n for (let index = 0; index < columns.getNItems(); index++) {\n const column = columns.getItem(index);\n\n if (column instanceof Gtk.ColumnViewColumn && column.getId() === id) {\n return column;\n }\n }\n\n return null;\n};\n\nconst getSortTarget = (view: Gtk.ColumnView | null, sortColumn: string | null | undefined): SortTarget | null => {\n if (view === null || sortColumn === undefined) {\n return null;\n }\n\n if (sortColumn === null) {\n return { view, column: null };\n }\n\n const column = columnById(view, sortColumn);\n\n return column === null ? null : { view, column };\n};\n\nconst applySort = (\n sorting: RefObject<boolean>,\n view: Gtk.ColumnView,\n column: Gtk.ColumnViewColumn | null,\n order: Gtk.SortType | null | undefined,\n): void => {\n sorting.current = true;\n\n try {\n view.sortByColumn(column, order ?? Gtk.SortType.ASCENDING);\n } finally {\n sorting.current = false;\n }\n};\n\nconst didEmitSortChanged = (\n sorter: Gtk.ColumnViewSorter | null,\n sorting: RefObject<boolean>,\n sort: SortProps,\n): boolean => {\n if (sorter === null || sorting.current) {\n return false;\n }\n\n sort.onSortChanged?.(sorter.getPrimarySortColumn()?.getId() ?? null, sorter.getPrimarySortOrder());\n\n return true;\n};\n\nconst syncSort = (\n sorting: RefObject<boolean>,\n view: Gtk.ColumnView | null,\n sortColumn: string | null | undefined,\n sortOrder: Gtk.SortType | null | undefined,\n): void => {\n const target = getSortTarget(view, sortColumn);\n\n if (target === null) {\n return;\n }\n\n applySort(sorting, target.view, target.column, sortOrder);\n};\n\nconst useColumnSorting = (view: Gtk.ColumnView | null, sort: SortProps, columns: ColumnViewColumn<never>[]): void => {\n const sorting = useRef(false);\n const sorter = view?.getSorter() ?? null;\n const columnSorter = sorter instanceof Gtk.ColumnViewSorter ? sorter : null;\n const { sortColumn, sortOrder } = sort;\n const request = useMemo<SortRequest>(() => ({ sortColumn, sortOrder }), [sortColumn, sortOrder]);\n const markDrift = useControlledSync({\n value: request,\n source: columns,\n target: view,\n apply: (value) => {\n syncSort(sorting, view, value.sortColumn, value.sortOrder);\n },\n });\n\n useSignal(columnSorter, \"changed\", (): void => {\n const didEmit = didEmitSortChanged(columnSorter, sorting, sort);\n\n if (sortColumn !== undefined && didEmit) {\n markDrift();\n }\n });\n};\n\nconst ColumnCells = ({\n column,\n hasExpander,\n collection,\n expandedIds,\n expanderDescriptions,\n size,\n}: ColumnCellsProps): ReactNode => {\n const cells = useItemCells(size);\n const rest = omit(column, [\"id\", \"renderCell\", \"isSortable\"]);\n\n return (\n <>\n <GtkColumnViewColumn\n id={column.id}\n factory={<GtkSignalListItemFactory {...cells.handlers} />}\n sorter={column.isSortable === true ? <GtkCustomSorter /> : null}\n {...rest}\n />\n <ItemPortals\n registry={cells}\n render={column.renderCell}\n collection={collection}\n hasExpander={hasExpander}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n />\n </>\n );\n};\n\nconst ColumnList = ({ columns, collection, expandedIds, expanderDescriptions, size }: ColumnListProps): ReactNode => {\n const expanderIndex = expanderIndexFor(columns);\n\n return columns.map((column, index) => (\n <ColumnCells\n key={column.id}\n column={column}\n hasExpander={index === expanderIndex}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n size={size}\n />\n ));\n};\n\n/**\n * Renders a Gtk.ColumnView from declarative items or sections and a columns array,\n * with controlled selection, expansion, and sorting, per-column header menus,\n * section header rendering, and per-row props such as a screen-reader label.\n */\nfunction ColumnView<T = unknown, S = unknown>(props: ColumnViewProps<T, S>): ReactNode {\n const { renderHeader, rowProps, columns, expandedIds, expanderDescriptions } = props;\n const { sortColumn, sortOrder, onSortChanged, ref } = props;\n const rest = omit(props, COLUMN_VIEW_PROPS);\n const size = { width: -1, height: props.estimatedItemHeight ?? -1 };\n const [view, refCallback] = useWidgetRef<Gtk.ColumnView>(ref);\n const { collection, selection } = useCollection(props);\n const header = useSectionHeader(renderHeader, collection, size);\n const rows = useRowProps(rowProps, collection, expandedIds);\n const columnList = columns as ColumnViewColumn<never>[];\n useColumnSorting(view, { sortColumn, sortOrder, onSortChanged }, columnList);\n\n return (\n <>\n <GtkColumnView\n ref={refCallback}\n model={selection}\n {...header.factoryProps}\n {...rows.factoryProps}\n {...rest}\n >\n <ColumnList\n columns={columnList}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n size={size}\n />\n </GtkColumnView>\n {header.portals}\n {rows.portals}\n </>\n );\n}\n\nexport { ColumnView };\n"]}
1
+ {"version":3,"file":"column-view.js","sourceRoot":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AE,gBAAgB,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7G,MAAM,MAAM,GAAG,gBAAgB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,OAAoC,CAAC;IACxD,gBAAgB,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,UAAU,CAAC,CAAC;IAE7E,OAAO,CACH,8BACI,KAAC,aAAa,IACV,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,SAAS,KACZ,MAAM,CAAC,YAAY,KACnB,IAAI,CAAC,YAAY,KACjB,IAAI,YAER,KAAC,UAAU,IACP,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,IAAI,EAAE,IAAI,GACZ,GACU,EACf,MAAM,CAAC,OAAO,EACd,IAAI,CAAC,OAAO,IACd,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkColumnView, GtkColumnViewColumn, GtkCustomSorter, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { useSignal } from \"@gtkx/react\";\nimport { omit } from \"@gtkx/utils\";\nimport { useMemo, useRef } from \"react\";\nimport type { CellSize } from \"./internal/cells.js\";\nimport type { Collection } from \"./internal/collection.js\";\nimport type { ColumnViewColumn, ColumnViewProps, ExpanderDescriptions, SortProps } from \"./types.js\";\nimport { ItemPortals, useItemCells, useRowProps, useSectionHeader } from \"./internal/cells.js\";\nimport { useControlledSync } from \"./internal/controlled-sync.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\nimport { showFirstHeader } from \"./internal/first-header.js\";\nimport { useWidgetRef } from \"./internal/use-widget-ref.js\";\n\ntype SortTarget = { view: Gtk.ColumnView; column: Gtk.ColumnViewColumn | null };\ntype SortRequest = Pick<SortProps, \"sortColumn\" | \"sortOrder\">;\n\ntype ColumnCellsProps = {\n column: ColumnViewColumn<never>;\n hasExpander: boolean;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n expanderDescriptions: ExpanderDescriptions | null | undefined;\n size: CellSize;\n};\n\ntype ColumnListProps = Omit<ColumnCellsProps, \"column\" | \"hasExpander\"> & {\n columns: ColumnViewColumn<never>[];\n};\n\nconst COLUMN_VIEW_PROPS = [\n \"items\",\n \"sections\",\n \"isFlat\",\n \"renderHeader\",\n \"rowProps\",\n \"columns\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"expandedIds\",\n \"onExpandedChange\",\n \"expanderDescriptions\",\n \"sortColumn\",\n \"sortOrder\",\n \"onSortChanged\",\n \"estimatedItemHeight\",\n \"ref\",\n] as const satisfies (keyof ColumnViewProps)[];\n\nconst expanderIndexFor = (columns: ColumnViewColumn<never>[]): number => {\n const marked = columns.findIndex((column) => column.hasExpander === true && column.visible !== false);\n\n return marked === -1 ? columns.findIndex((column) => column.visible !== false) : marked;\n};\n\nconst columnById = (view: Gtk.ColumnView, id: string): Gtk.ColumnViewColumn | null => {\n const columns = view.getColumns();\n\n for (let index = 0; index < columns.getNItems(); index++) {\n const column = columns.getItem(index);\n\n if (column instanceof Gtk.ColumnViewColumn && column.getId() === id) {\n return column;\n }\n }\n\n return null;\n};\n\nconst getSortTarget = (view: Gtk.ColumnView | null, sortColumn: string | null | undefined): SortTarget | null => {\n if (view === null || sortColumn === undefined) {\n return null;\n }\n\n if (sortColumn === null) {\n return { view, column: null };\n }\n\n const column = columnById(view, sortColumn);\n\n return column === null ? null : { view, column };\n};\n\nconst applySort = (\n sorting: RefObject<boolean>,\n view: Gtk.ColumnView,\n column: Gtk.ColumnViewColumn | null,\n order: Gtk.SortType | null | undefined,\n): void => {\n sorting.current = true;\n\n try {\n view.sortByColumn(column, order ?? Gtk.SortType.ASCENDING);\n } finally {\n sorting.current = false;\n }\n};\n\nconst didEmitSortChanged = (\n sorter: Gtk.ColumnViewSorter | null,\n sorting: RefObject<boolean>,\n sort: SortProps,\n): boolean => {\n if (sorter === null || sorting.current) {\n return false;\n }\n\n sort.onSortChanged?.(sorter.getPrimarySortColumn()?.getId() ?? null, sorter.getPrimarySortOrder());\n\n return true;\n};\n\nconst syncSort = (\n sorting: RefObject<boolean>,\n view: Gtk.ColumnView | null,\n sortColumn: string | null | undefined,\n sortOrder: Gtk.SortType | null | undefined,\n): void => {\n const target = getSortTarget(view, sortColumn);\n\n if (target === null) {\n return;\n }\n\n applySort(sorting, target.view, target.column, sortOrder);\n};\n\nconst useColumnSorting = (view: Gtk.ColumnView | null, sort: SortProps, columns: ColumnViewColumn<never>[]): void => {\n const sorting = useRef(false);\n const sorter = view?.getSorter() ?? null;\n const columnSorter = sorter instanceof Gtk.ColumnViewSorter ? sorter : null;\n const { sortColumn, sortOrder } = sort;\n const request = useMemo<SortRequest>(() => ({ sortColumn, sortOrder }), [sortColumn, sortOrder]);\n const markDrift = useControlledSync({\n value: request,\n source: columns,\n target: view,\n apply: (value) => {\n syncSort(sorting, view, value.sortColumn, value.sortOrder);\n },\n });\n\n useSignal(columnSorter, \"changed\", (): void => {\n const didEmit = didEmitSortChanged(columnSorter, sorting, sort);\n\n if (sortColumn !== undefined && didEmit) {\n markDrift();\n }\n });\n};\n\nconst ColumnCells = ({\n column,\n hasExpander,\n collection,\n expandedIds,\n expanderDescriptions,\n size,\n}: ColumnCellsProps): ReactNode => {\n const cells = useItemCells(size);\n const rest = omit(column, [\"id\", \"renderCell\", \"isSortable\", \"hasExpander\"]);\n\n return (\n <>\n <GtkColumnViewColumn\n id={column.id}\n factory={<GtkSignalListItemFactory {...cells.handlers} />}\n sorter={column.isSortable === true ? <GtkCustomSorter /> : null}\n {...rest}\n />\n <ItemPortals\n registry={cells}\n render={column.renderCell}\n collection={collection}\n hasExpander={hasExpander}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n />\n </>\n );\n};\n\nconst ColumnList = ({ columns, collection, expandedIds, expanderDescriptions, size }: ColumnListProps): ReactNode => {\n const expanderIndex = expanderIndexFor(columns);\n\n return columns.map((column, index) => (\n <ColumnCells\n key={column.id}\n column={column}\n hasExpander={index === expanderIndex}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n size={size}\n />\n ));\n};\n\n/**\n * Renders a Gtk.ColumnView from declarative items or sections and a columns array,\n * with controlled selection, expansion, and sorting, per-column header menus,\n * section header rendering, and per-row props such as a screen-reader label.\n */\nfunction ColumnView<T = unknown, S = unknown>(props: ColumnViewProps<T, S>): ReactNode {\n const { renderHeader, rowProps, columns, expandedIds, expanderDescriptions } = props;\n const { sortColumn, sortOrder, onSortChanged, ref } = props;\n const rest = omit(props, COLUMN_VIEW_PROPS);\n const size = { width: -1, height: props.estimatedItemHeight ?? -1 };\n const [view, refCallback] = useWidgetRef<Gtk.ColumnView>(ref);\n const { collection, selection } = useCollection({ ...props, onSectionsFilled: () => showFirstHeader(view) });\n const header = useSectionHeader(renderHeader, collection, size);\n const rows = useRowProps(rowProps, collection, expandedIds);\n const columnList = columns as ColumnViewColumn<never>[];\n useColumnSorting(view, { sortColumn, sortOrder, onSortChanged }, columnList);\n\n return (\n <>\n <GtkColumnView\n ref={refCallback}\n model={selection}\n {...header.factoryProps}\n {...rows.factoryProps}\n {...rest}\n >\n <ColumnList\n columns={columnList}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n size={size}\n />\n </GtkColumnView>\n {header.portals}\n {rows.portals}\n </>\n );\n}\n\nexport { ColumnView };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"combo-row.d.ts","sourceRoot":"","sources":["../src/combo-row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,uFAAuF;AACvF,KAAK,iBAAiB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;AAE7F;;;;GAIG;AACH,QAAA,MAAM,QAAQ,EAAE,iBAAqD,CAAC;AAMtE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"combo-row.d.ts","sourceRoot":"","sources":["../src/combo-row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,uFAAuF;AACvF,KAAK,iBAAiB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;AAE7F;;;;GAIG;AACH,QAAA,MAAM,QAAQ,EAAE,iBAAqD,CAAC;AAQtE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/dist/combo-row.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as Pango from "@gtkx/gi/pango";
2
3
  import { AdwComboRow } from "@gtkx/jsx/adw";
3
4
  import { DropDownBase } from "./internal/drop-down.js";
4
5
  /**
@@ -7,8 +8,9 @@ import { DropDownBase } from "./internal/drop-down.js";
7
8
  * display, popup rows, and popup section headers, and controlled selection.
8
9
  */
9
10
  const ComboRow = ComboRowImpl;
11
+ const ITEM_LABEL = { ellipsize: Pango.EllipsizeMode.END, maxWidthChars: 20, widthChars: 1 };
10
12
  function ComboRowImpl(props) {
11
- return _jsx(DropDownBase, { ...props, component: AdwComboRow });
13
+ return _jsx(DropDownBase, { ...props, component: AdwComboRow, itemLabel: ITEM_LABEL });
12
14
  }
13
15
  export { ComboRow };
14
16
  //# sourceMappingURL=combo-row.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"combo-row.js","sourceRoot":"","sources":["../src/combo-row.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD;;;;GAIG;AACH,MAAM,QAAQ,GAAsB,YAAiC,CAAC;AAEtE,SAAS,YAAY,CAAC,KAAwB;IAC1C,OAAO,KAAC,YAAY,OAAK,KAAK,EAAE,SAAS,EAAE,WAAW,GAAI,CAAC;AAC/D,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { AdwComboRow } from \"@gtkx/jsx/adw\";\nimport type { DropDownBaseProps } from \"./internal/drop-down.js\";\nimport type { ComboRowProps } from \"./types.js\";\nimport { DropDownBase } from \"./internal/drop-down.js\";\n\n/** Call signature of {@link ComboRow}, generic in the item and section value types. */\ntype ComboRowComponent = <T = unknown, S = unknown>(props: ComboRowProps<T, S>) => ReactNode;\n\n/**\n * Renders an `Adw.ComboRow` backed by a collection model, presenting the same choice as a\n * `DropDown` in the shape of a preferences row, with customizable renderers for the row\n * display, popup rows, and popup section headers, and controlled selection.\n */\nconst ComboRow: ComboRowComponent = ComboRowImpl as ComboRowComponent;\n\nfunction ComboRowImpl(props: DropDownBaseProps): ReactNode {\n return <DropDownBase {...props} component={AdwComboRow} />;\n}\n\nexport { ComboRow };\n"]}
1
+ {"version":3,"file":"combo-row.js","sourceRoot":"","sources":["../src/combo-row.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD;;;;GAIG;AACH,MAAM,QAAQ,GAAsB,YAAiC,CAAC;AAEtE,MAAM,UAAU,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AAE5F,SAAS,YAAY,CAAC,KAAwB;IAC1C,OAAO,KAAC,YAAY,OAAK,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,GAAI,CAAC;AACtF,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport * as Pango from \"@gtkx/gi/pango\";\nimport { AdwComboRow } from \"@gtkx/jsx/adw\";\nimport type { DropDownBaseProps } from \"./internal/drop-down.js\";\nimport type { ComboRowProps } from \"./types.js\";\nimport { DropDownBase } from \"./internal/drop-down.js\";\n\n/** Call signature of {@link ComboRow}, generic in the item and section value types. */\ntype ComboRowComponent = <T = unknown, S = unknown>(props: ComboRowProps<T, S>) => ReactNode;\n\n/**\n * Renders an `Adw.ComboRow` backed by a collection model, presenting the same choice as a\n * `DropDown` in the shape of a preferences row, with customizable renderers for the row\n * display, popup rows, and popup section headers, and controlled selection.\n */\nconst ComboRow: ComboRowComponent = ComboRowImpl as ComboRowComponent;\n\nconst ITEM_LABEL = { ellipsize: Pango.EllipsizeMode.END, maxWidthChars: 20, widthChars: 1 };\n\nfunction ComboRowImpl(props: DropDownBaseProps): ReactNode {\n return <DropDownBase {...props} component={AdwComboRow} itemLabel={ITEM_LABEL} />;\n}\n\nexport { ComboRow };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"grid-view.d.ts","sourceRoot":"","sources":["../src/grid-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAchD;;;GAGG;AACH,iBAAS,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAajE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"grid-view.d.ts","sourceRoot":"","sources":["../src/grid-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAehD;;;GAGG;AACH,iBAAS,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAajE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/dist/grid-view.js CHANGED
@@ -6,6 +6,7 @@ import { useCollection } from "./internal/use-collection.js";
6
6
  const GRID_VIEW_PROPS = [
7
7
  "items",
8
8
  "renderItem",
9
+ "rowProps",
9
10
  "selectedIds",
10
11
  "onSelectionChanged",
11
12
  "selectionMode",
@@ -17,12 +18,12 @@ const GRID_VIEW_PROPS = [
17
18
  * rendering, controlled selection, and estimated item sizing.
18
19
  */
19
20
  function GridView(props) {
20
- const { renderItem, estimatedItemHeight, estimatedItemWidth } = props;
21
+ const { renderItem, rowProps, estimatedItemHeight, estimatedItemWidth } = props;
21
22
  const rest = omit(props, GRID_VIEW_PROPS);
22
23
  const size = { width: estimatedItemWidth ?? -1, height: estimatedItemHeight ?? -1 };
23
24
  const { collection, selection } = useCollection({ ...props, isFlat: true });
24
25
  const itemCells = useItemCells(size);
25
- return (_jsxs(_Fragment, { children: [_jsx(GtkGridView, { model: selection, factory: _jsx(GtkSignalListItemFactory, { ...itemCells.handlers }), ...rest }), _jsx(ItemPortals, { registry: itemCells, render: renderItem, collection: collection })] }));
26
+ return (_jsxs(_Fragment, { children: [_jsx(GtkGridView, { model: selection, factory: _jsx(GtkSignalListItemFactory, { ...itemCells.handlers }), ...rest }), _jsx(ItemPortals, { registry: itemCells, render: renderItem, rowProps: rowProps, collection: collection })] }));
26
27
  }
27
28
  export { GridView };
28
29
  //# sourceMappingURL=grid-view.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grid-view.js","sourceRoot":"","sources":["../src/grid-view.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,eAAe,GAAG;IACpB,OAAO;IACP,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,qBAAqB;IACrB,oBAAoB;CACoB,CAAC;AAE7C;;;GAGG;AACH,SAAS,QAAQ,CAAc,KAAuB;IAClD,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,kBAAkB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,IAAI,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO,CACH,8BACI,KAAC,WAAW,IAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,KAAC,wBAAwB,OAAK,SAAS,CAAC,QAAQ,GAAI,KAAM,IAAI,GAAI,EAC1G,KAAC,WAAW,IAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAI,IACjF,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { GtkGridView, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { omit } from \"@gtkx/utils\";\nimport type { GridViewProps } from \"./types.js\";\nimport { ItemPortals, useItemCells } from \"./internal/cells.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\n\nconst GRID_VIEW_PROPS = [\n \"items\",\n \"renderItem\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"estimatedItemHeight\",\n \"estimatedItemWidth\",\n] as const satisfies (keyof GridViewProps)[];\n\n/**\n * Renders a Gtk.GridView of uniform cells from declarative items, with per-cell\n * rendering, controlled selection, and estimated item sizing.\n */\nfunction GridView<T = unknown>(props: GridViewProps<T>): ReactNode {\n const { renderItem, estimatedItemHeight, estimatedItemWidth } = props;\n const rest = omit(props, GRID_VIEW_PROPS);\n const size = { width: estimatedItemWidth ?? -1, height: estimatedItemHeight ?? -1 };\n const { collection, selection } = useCollection({ ...props, isFlat: true });\n const itemCells = useItemCells(size);\n\n return (\n <>\n <GtkGridView model={selection} factory={<GtkSignalListItemFactory {...itemCells.handlers} />} {...rest} />\n <ItemPortals registry={itemCells} render={renderItem} collection={collection} />\n </>\n );\n}\n\nexport { GridView };\n"]}
1
+ {"version":3,"file":"grid-view.js","sourceRoot":"","sources":["../src/grid-view.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,eAAe,GAAG;IACpB,OAAO;IACP,YAAY;IACZ,UAAU;IACV,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,qBAAqB;IACrB,oBAAoB;CACoB,CAAC;AAE7C;;;GAGG;AACH,SAAS,QAAQ,CAAc,KAAuB;IAClD,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IAChF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,kBAAkB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,IAAI,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO,CACH,8BACI,KAAC,WAAW,IAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,KAAC,wBAAwB,OAAK,SAAS,CAAC,QAAQ,GAAI,KAAM,IAAI,GAAI,EAC1G,KAAC,WAAW,IAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAI,IACrG,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { GtkGridView, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { omit } from \"@gtkx/utils\";\nimport type { GridViewProps } from \"./types.js\";\nimport { ItemPortals, useItemCells } from \"./internal/cells.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\n\nconst GRID_VIEW_PROPS = [\n \"items\",\n \"renderItem\",\n \"rowProps\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"estimatedItemHeight\",\n \"estimatedItemWidth\",\n] as const satisfies (keyof GridViewProps)[];\n\n/**\n * Renders a Gtk.GridView of uniform cells from declarative items, with per-cell\n * rendering, controlled selection, and estimated item sizing.\n */\nfunction GridView<T = unknown>(props: GridViewProps<T>): ReactNode {\n const { renderItem, rowProps, estimatedItemHeight, estimatedItemWidth } = props;\n const rest = omit(props, GRID_VIEW_PROPS);\n const size = { width: estimatedItemWidth ?? -1, height: estimatedItemHeight ?? -1 };\n const { collection, selection } = useCollection({ ...props, isFlat: true });\n const itemCells = useItemCells(size);\n\n return (\n <>\n <GtkGridView model={selection} factory={<GtkSignalListItemFactory {...itemCells.handlers} />} {...rest} />\n <ItemPortals registry={itemCells} render={renderItem} rowProps={rowProps} collection={collection} />\n </>\n );\n}\n\nexport { GridView };\n"]}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,5 @@ export { GridView } from "./grid-view.js";
5
5
  export { ListItemFactory } from "./list-item-factory.js";
6
6
  export { ListView } from "./list-view.js";
7
7
  export { ToastProvider, useToast } from "./toast.js";
8
- export { createTabCollection } from "./tab-collection.js";
9
- export type { ColumnViewColumn, ColumnViewProps, ComboRowProps, DropDownProps, ExpanderDescriptions, GridViewProps, ListItem, ListItemFactoryProps, ListItemRenderArgs, ListItemRenderer, ListRowProps, ListRowPropsResolver, ListSection, ListSectionRenderArgs, ListSectionRenderer, ListViewProps, ToastController, ToastOptions, ToastProviderProps, TabAppendOptions, TabCollection, TabCollectionOptions, } from "./types.js";
8
+ export type { ColumnViewColumn, ColumnViewProps, ComboRowProps, DropDownProps, ExpanderDescriptions, GridViewProps, ListItem, ListItemFactoryProps, ListItemRenderArgs, ListItemRenderer, ListRowProps, ListRowPropsResolver, ListSection, ListSectionRenderArgs, ListSectionRenderer, ListViewProps, ToastController, ToastOptions, ToastProviderProps, } from "./types.js";
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts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ChB,eAAe,EACf,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,GACrB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -5,5 +5,4 @@ export { GridView } from "./grid-view.js";
5
5
  export { ListItemFactory } from "./list-item-factory.js";
6
6
  export { ListView } from "./list-view.js";
7
7
  export { ToastProvider, useToast } from "./toast.js";
8
- export { createTabCollection } from "./tab-collection.js";
9
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { ColumnView } from \"./column-view.js\";\nexport { ComboRow } from \"./combo-row.js\";\nexport { DropDown } from \"./drop-down.js\";\nexport { GridView } from \"./grid-view.js\";\nexport { ListItemFactory } from \"./list-item-factory.js\";\nexport { ListView } from \"./list-view.js\";\nexport { ToastProvider, useToast } from \"./toast.js\";\nexport { createTabCollection } from \"./tab-collection.js\";\nexport type {\n ColumnViewColumn,\n ColumnViewProps,\n ComboRowProps,\n DropDownProps,\n ExpanderDescriptions,\n GridViewProps,\n ListItem,\n ListItemFactoryProps,\n ListItemRenderArgs,\n ListItemRenderer,\n ListRowProps,\n ListRowPropsResolver,\n ListSection,\n ListSectionRenderArgs,\n ListSectionRenderer,\n ListViewProps,\n ToastController,\n ToastOptions,\n ToastProviderProps,\n TabAppendOptions,\n TabCollection,\n TabCollectionOptions,\n} from \"./types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { ColumnView } from \"./column-view.js\";\nexport { ComboRow } from \"./combo-row.js\";\nexport { DropDown } from \"./drop-down.js\";\nexport { GridView } from \"./grid-view.js\";\nexport { ListItemFactory } from \"./list-item-factory.js\";\nexport { ListView } from \"./list-view.js\";\nexport { ToastProvider, useToast } from \"./toast.js\";\nexport type {\n ColumnViewColumn,\n ColumnViewProps,\n ComboRowProps,\n DropDownProps,\n ExpanderDescriptions,\n GridViewProps,\n ListItem,\n ListItemFactoryProps,\n ListItemRenderArgs,\n ListItemRenderer,\n ListRowProps,\n ListRowPropsResolver,\n ListSection,\n ListSectionRenderArgs,\n ListSectionRenderer,\n ListViewProps,\n ToastController,\n ToastOptions,\n ToastProviderProps,\n} from \"./types.js\";\n"]}
@@ -30,11 +30,13 @@ type ItemIdentity = {
30
30
  itemKey: string;
31
31
  item: ListItem | undefined;
32
32
  position: number;
33
+ index: number;
33
34
  isExpanded: boolean;
34
35
  };
35
36
  type ItemPortalsProps = {
36
37
  registry: CellRegistry<Gtk.ListItem>;
37
38
  render: ListItemRenderer<never>;
39
+ rowProps?: ListRowPropsResolver<never> | null | undefined;
38
40
  collection: Collection;
39
41
  hasExpander?: boolean | undefined;
40
42
  expandedIds?: string[] | null | undefined;
@@ -43,6 +45,7 @@ type ItemPortalsProps = {
43
45
  type NativeItemPortalsProps<T extends GObject.Object> = {
44
46
  registry: CellRegistry<Gtk.ListItem>;
45
47
  render: ListItemRenderer<T>;
48
+ rowProps: ListRowPropsResolver<T> | null | undefined;
46
49
  size: CellSize;
47
50
  };
48
51
  type SectionHeaderSlot = {
@@ -58,8 +61,8 @@ type RowSlot = {
58
61
  portals: ReactNode;
59
62
  };
60
63
  declare function useItemCells(size: CellSize): CellRegistry<Gtk.ListItem>;
61
- declare const ItemPortals: ({ registry, render, collection, hasExpander, expandedIds, expanderDescriptions, }: ItemPortalsProps) => ReactNode;
62
- declare function NativeItemPortals<T extends GObject.Object>({ registry, render, size }: NativeItemPortalsProps<T>): ReactNode;
64
+ declare const ItemPortals: ({ registry, ...props }: ItemPortalsProps) => ReactNode;
65
+ declare function NativeItemPortals<T extends GObject.Object>({ registry, render, rowProps, size, }: NativeItemPortalsProps<T>): ReactNode;
63
66
  declare const useSectionHeader: (render: ListSectionRenderer<never> | null | undefined, collection: Collection, size: CellSize) => SectionHeaderSlot;
64
67
  declare const useRowProps: (rowProps: ListRowPropsResolver<never> | null | undefined, collection: Collection, expandedIds: string[] | null | undefined) => RowSlot;
65
68
  export { useItemCells, useRowProps, useSectionHeader, ItemPortals, NativeItemPortals, type CellSize };
@@ -1 +1 @@
1
- {"version":3,"file":"cells.d.ts","sourceRoot":"","sources":["../../src/internal/cells.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE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WAAW,EAAE,iBAAiB,EAAE,KAAK,QAAQ,EAAE,CAAC"}
@@ -4,16 +4,19 @@ import { GtkBox, GtkSignalListItemFactory, GtkTreeExpander } from "@gtkx/jsx/gtk
4
4
  import { createPortal, useProperty } from "@gtkx/react";
5
5
  import { useLatestRef } from "@gtkx/react/internal";
6
6
  import { createRef, Fragment, memo, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
7
- import { slotPathAt, slotRefFor } from "./collection-model.js";
7
+ import { levelStoreFor, slotRefFor } from "./collection-model.js";
8
8
  import { joinParts } from "./keys.js";
9
9
  const ItemCell = memo(ItemCellImpl, isSameItemCell);
10
10
  const ItemRow = memo(ItemRowImpl, isSameItemRow);
11
11
  const HeaderCell = memo(HeaderCellImpl);
12
+ const ItemCellList = memo(ItemCellListImpl, isWaitingForSync);
13
+ const ItemRowList = memo(ItemRowListImpl, isWaitingForSync);
12
14
  const CELL_OPTIONS = { isHost: isListItem, prepare: prepareCell };
13
15
  const HEADER_OPTIONS = { isHost: isListHeader, prepare: prepareCell };
14
16
  const ROW_OPTIONS = { isHost: isColumnViewRow };
15
17
  const NO_SIZE = { width: -1, height: -1 };
16
18
  const NO_ROW_PROPS = {};
19
+ const DEFAULT_ROW_PROPS = resolveRowProps(NO_ROW_PROPS);
17
20
  const placeholders = new WeakSet();
18
21
  const placeholder = (size) => {
19
22
  const widget = new Gtk.Box({ widthRequest: size.width, heightRequest: size.height });
@@ -132,8 +135,18 @@ function useHeaderCells(size) {
132
135
  function isRowWanted(options, item) {
133
136
  return options.expandedIds?.includes(item.id) ?? false;
134
137
  }
135
- function itemArgs(item, position, row, isExpanded) {
136
- const args = { item: item.value, index: position ?? 0 };
138
+ function collectionIndex(collection, item, position) {
139
+ if (position === undefined) {
140
+ return 0;
141
+ }
142
+ if (collection.idAt(position) === item.id) {
143
+ return position;
144
+ }
145
+ const index = collection.positionFor(item.id);
146
+ return index === -1 ? position : index;
147
+ }
148
+ function itemArgs(item, index, row, isExpanded) {
149
+ const args = { item: item.value, index };
137
150
  if (row === null) {
138
151
  return args;
139
152
  }
@@ -143,9 +156,6 @@ function itemArgs(item, position, row, isExpanded) {
143
156
  }
144
157
  return args;
145
158
  }
146
- function keyForItem(ref, item) {
147
- return joinParts([slotPathAt(ref.store, ref.slot), item.id]);
148
- }
149
159
  function slotFor(options) {
150
160
  const ref = slotRefFor(options.item);
151
161
  if (ref === null) {
@@ -156,36 +166,40 @@ function slotFor(options) {
156
166
  return null;
157
167
  }
158
168
  return {
159
- itemKey: keyForItem(ref, item),
169
+ itemKey: ref.key,
160
170
  item,
171
+ position: options.position,
161
172
  row: options.row,
162
- args: itemArgs(item, options.position, options.row, isRowWanted(options, item)),
173
+ args: itemArgs(item, collectionIndex(options.collection, item, options.position), options.row, isRowWanted(options, item)),
163
174
  };
164
175
  }
165
176
  function useItemSlot(entry, state, identity) {
166
177
  const position = useProperty(entry.host, "position");
167
178
  const item = useProperty(entry.host, "item") ?? null;
168
179
  const row = item instanceof Gtk.TreeListRow ? item : null;
180
+ const { collection, expandedIds } = state.current;
169
181
  if (position === identity.position) {
170
182
  return identity.item === undefined
171
183
  ? null
172
184
  : {
173
185
  itemKey: identity.itemKey,
174
186
  item: identity.item,
187
+ position,
175
188
  row,
176
- args: itemArgs(identity.item, position, row, identity.isExpanded),
189
+ args: itemArgs(identity.item, identity.index, row, identity.isExpanded),
177
190
  };
178
191
  }
179
- const { collection, expandedIds } = state.current;
180
192
  return slotFor({ item, position, row, collection, expandedIds });
181
193
  }
182
194
  function itemIdentity(entry, collection, expandedIds) {
183
195
  const ref = slotRefFor(entry.host.getItem());
184
196
  const item = ref === null ? undefined : collection.itemAt(ref);
197
+ const position = entry.host.getPosition();
185
198
  return {
186
- itemKey: ref === null || item === undefined ? "" : keyForItem(ref, item),
199
+ itemKey: ref === null || item === undefined ? "" : ref.key,
187
200
  item,
188
- position: entry.host.getPosition(),
201
+ position,
202
+ index: item === undefined ? 0 : collectionIndex(collection, item, position),
189
203
  isExpanded: item !== undefined && (expandedIds?.includes(item.id) ?? false),
190
204
  };
191
205
  }
@@ -193,16 +207,21 @@ function isSameItemIdentity(previous, next) {
193
207
  return (previous.item === next.item &&
194
208
  previous.itemKey === next.itemKey &&
195
209
  previous.position === next.position &&
210
+ previous.index === next.index &&
196
211
  previous.isExpanded === next.isExpanded);
197
212
  }
198
213
  function isSameItemCell(previous, next) {
199
214
  const identity = previous.entry.identity.current ?? previous;
200
215
  return (previous.entry === next.entry &&
201
216
  previous.render === next.render &&
217
+ previous.rowProps === next.rowProps &&
202
218
  previous.hasExpander === next.hasExpander &&
203
219
  previous.expanderDescriptions === next.expanderDescriptions &&
204
220
  isSameItemIdentity(identity, next));
205
221
  }
222
+ function isWaitingForSync(_previous, next) {
223
+ return next.isPending;
224
+ }
206
225
  function isSameItemRow(previous, next) {
207
226
  const identity = previous.entry.identity.current ?? previous;
208
227
  return previous.entry === next.entry && previous.rowProps === next.rowProps && isSameItemIdentity(identity, next);
@@ -227,7 +246,8 @@ function renderedIdentity(entry, slot) {
227
246
  return {
228
247
  itemKey: slot?.itemKey ?? "",
229
248
  item: slot?.item,
230
- position: slot?.args.index ?? entry.host.getPosition(),
249
+ position: slot?.position ?? entry.host.getPosition(),
250
+ index: slot?.args.index ?? 0,
231
251
  isExpanded: slot?.args.isExpanded ?? false,
232
252
  };
233
253
  }
@@ -263,9 +283,7 @@ function rowText(value) {
263
283
  function rowFlag(value) {
264
284
  return value ?? true;
265
285
  }
266
- function rowPropsFor(slot, rowProps) {
267
- const resolve = rowProps;
268
- const props = slot === null ? NO_ROW_PROPS : resolve(slot.args);
286
+ function resolveRowProps(props) {
269
287
  return {
270
288
  accessibleLabel: rowText(props.accessibleLabel),
271
289
  accessibleDescription: rowText(props.accessibleDescription),
@@ -274,6 +292,10 @@ function rowPropsFor(slot, rowProps) {
274
292
  isSelectable: rowFlag(props.isSelectable),
275
293
  };
276
294
  }
295
+ function rowPropsFor(slot, rowProps) {
296
+ const resolve = rowProps;
297
+ return resolveRowProps(slot === null ? NO_ROW_PROPS : resolve(slot.args));
298
+ }
277
299
  function applyRowProps(host, props, previous) {
278
300
  if (previous?.accessibleLabel !== props.accessibleLabel) {
279
301
  host.accessibleLabel = props.accessibleLabel;
@@ -291,68 +313,89 @@ function applyRowProps(host, props, previous) {
291
313
  host.setSelectable(props.isSelectable);
292
314
  }
293
315
  }
294
- function ItemCellImpl({ entry, render, state, hasExpander, expanderDescriptions, ...identity }) {
316
+ function useAppliedRowProps(host, props) {
317
+ const previous = useRef(null);
318
+ useLayoutEffect(() => {
319
+ if (props === null && previous.current === null) {
320
+ return;
321
+ }
322
+ const next = props ?? DEFAULT_ROW_PROPS;
323
+ applyRowProps(host, next, previous.current);
324
+ previous.current = props === null ? null : next;
325
+ }, [host, props]);
326
+ }
327
+ function ItemCellImpl({ entry, render, rowProps, state, hasExpander, expanderDescriptions, ...identity }) {
295
328
  const slot = useItemSlot(entry, state, identity);
296
329
  useRememberIdentity(entry, slot);
330
+ useAppliedRowProps(entry.host, rowProps == null ? null : rowPropsFor(slot, rowProps));
297
331
  const body = itemBody(slot, render, hasExpander, expanderDescriptions);
298
332
  return createPortal(body, entry.host, entry.key);
299
333
  }
300
334
  function ItemRowImpl({ entry, rowProps, state, ...identity }) {
301
335
  const slot = useItemSlot(entry, state, identity);
302
336
  useRememberIdentity(entry, slot);
303
- const props = rowPropsFor(slot, rowProps);
304
- const previous = useRef(null);
305
- useLayoutEffect(() => {
306
- applyRowProps(entry.host, props, previous.current);
307
- previous.current = props;
308
- }, [entry.host, props]);
337
+ useAppliedRowProps(entry.host, rowPropsFor(slot, rowProps));
309
338
  return null;
310
339
  }
311
- function HeaderCellImpl({ entry, render, collection }) {
340
+ function HeaderCellImpl({ entry, render }) {
312
341
  const item = useProperty(entry.host, "item") ?? null;
313
- return createPortal(headerBody(slotRefFor(item), render, collection), entry.host, entry.key);
342
+ return createPortal(headerBody(levelStoreFor(item), render), entry.host, entry.key);
314
343
  }
315
- function NativeItemCell({ entry, render, keys, size }) {
344
+ function NativeItemCell({ entry, render, rowProps, keys, size, }) {
316
345
  const position = useProperty(entry.host, "position");
317
346
  const item = useProperty(entry.host, "item") ?? null;
347
+ const args = item !== null && position !== undefined ? { item: item, index: position } : null;
348
+ useAppliedRowProps(entry.host, rowProps == null ? null : resolveRowProps(args === null ? NO_ROW_PROPS : rowProps(args)));
318
349
  let body = null;
319
- if (item !== null && position !== undefined) {
320
- const content = render({ item: item, index: position });
350
+ if (item !== null && args !== null) {
351
+ const content = render(args);
321
352
  const child = content == null || typeof content === "boolean" ? (_jsx(GtkBox, { widthRequest: size.width, heightRequest: size.height })) : (content);
322
353
  body = _jsx(Fragment, { children: child }, keys.keyFor(item));
323
354
  }
324
355
  return createPortal(body, entry.host, entry.key);
325
356
  }
326
- function headerBody(ref, render, collection) {
327
- if (ref === null) {
328
- return null;
329
- }
330
- const section = collection.sectionFor(ref.store.level.path);
331
- if (section === undefined) {
357
+ function headerBody(store, render) {
358
+ const section = store?.level.section;
359
+ if (store === null || section === undefined) {
332
360
  return null;
333
361
  }
334
362
  const renderHeader = render;
335
- const key = joinParts([ref.store.level.path, section.id]);
363
+ const key = joinParts([store.key, section.id]);
336
364
  return _jsx(Fragment, { children: renderHeader({ section: section.value }) }, key);
337
365
  }
338
366
  function usePortalEntries(registry) {
339
367
  return useSyncExternalStore(registry.subscribe, registry.getEntries);
340
368
  }
341
- const ItemPortals = ({ registry, render, collection, hasExpander, expandedIds, expanderDescriptions, }) => {
342
- const entries = usePortalEntries(registry);
369
+ function useCollectionVersion(collection) {
370
+ return useSyncExternalStore(collection.subscribe, collection.getVersion);
371
+ }
372
+ function ItemCellListImpl({ entries, render, rowProps, collection, hasExpander, expandedIds, expanderDescriptions, }) {
343
373
  const state = useLatestRef({ collection, expandedIds });
344
- return entries.map((entry) => (_jsx(ItemCell, { entry: entry, render: render, state: state, hasExpander: hasExpander ?? true, expanderDescriptions: expanderDescriptions, ...itemIdentity(entry, collection, expandedIds) }, entry.key)));
345
- };
346
- const RowPortals = ({ registry, rowProps, collection, expandedIds }) => {
374
+ return entries.map((entry) => (_jsx(ItemCell, { entry: entry, render: render, rowProps: rowProps, state: state, hasExpander: hasExpander ?? true, expanderDescriptions: expanderDescriptions, ...itemIdentity(entry, collection, expandedIds) }, entry.key)));
375
+ }
376
+ const ItemPortals = ({ registry, ...props }) => {
347
377
  const entries = usePortalEntries(registry);
378
+ useCollectionVersion(props.collection);
379
+ return _jsx(ItemCellList, { ...props, entries: entries, isPending: props.collection.isPending() });
380
+ };
381
+ function ItemRowListImpl({ entries, rowProps, collection, expandedIds }) {
348
382
  const state = useLatestRef({ collection, expandedIds });
349
383
  return entries.map((entry) => (_jsx(ItemRow, { entry: entry, rowProps: rowProps, state: state, ...itemIdentity(entry, collection, expandedIds) }, entry.key)));
384
+ }
385
+ const RowPortals = ({ registry, ...props }) => {
386
+ const entries = usePortalEntries(registry);
387
+ useCollectionVersion(props.collection);
388
+ return _jsx(ItemRowList, { ...props, entries: entries, isPending: props.collection.isPending() });
389
+ };
390
+ const HeaderPortals = ({ registry, render, collection }) => {
391
+ const entries = usePortalEntries(registry);
392
+ const version = useCollectionVersion(collection);
393
+ return entries.map((entry) => _jsx(HeaderCell, { entry: entry, render: render, version: version }, entry.key));
350
394
  };
351
- const HeaderPortals = ({ registry, render, collection }) => usePortalEntries(registry).map((entry) => (_jsx(HeaderCell, { entry: entry, render: render, collection: collection }, entry.key)));
352
- function NativeItemPortals({ registry, render, size }) {
395
+ function NativeItemPortals({ registry, render, rowProps, size, }) {
353
396
  const entries = usePortalEntries(registry);
354
397
  const [keys] = useState(createNativeItemKeyStore);
355
- return entries.map((entry) => (_jsx(NativeItemCell, { entry: entry, render: render, keys: keys, size: size }, entry.key)));
398
+ return entries.map((entry) => (_jsx(NativeItemCell, { entry: entry, render: render, rowProps: rowProps, keys: keys, size: size }, entry.key)));
356
399
  }
357
400
  const useSectionHeader = (render, collection, size) => {
358
401
  const registry = useHeaderCells(size);