playbook_ui 14.21.2.pre.alpha.PLAY21898327 → 14.21.2.pre.alpha.PLAY22358326

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e88a424221940101bf6f8b972a1627543b65d58fba0638a947531a44506f3d6
4
- data.tar.gz: 454248993cf3019183f4769daa8fb083c44fb744d531109b5b3f0dfacd0ea414
3
+ metadata.gz: 775191059b582c0fb74cc6d654e3b563226fbe855b9b9f267fa4cd982955fa2f
4
+ data.tar.gz: fca502f3f539f439b6471b266cc211b46bb0fcba13d00189e89ce0893df0a9be
5
5
  SHA512:
6
- metadata.gz: 255e3249796246518bf9cc2e4a5724dd35c16e00dd922840ced6bd1c62e97ab45b2063ddb98cc1bcff2f66b274be9a7631f45bc124999d12c9a4eaaa763dc8f0
7
- data.tar.gz: 93465c931d64989d3617881a1753b16a69b4f5d68554c53a74622bc32b223f4e582b2839c67438fad9fa0d2a302260c636f9015b37b48d02ef38690ed5d200d6
6
+ metadata.gz: 61fc896c9d0a0a65db99048f13c0ac4fe70a1bd3a036a807759a699bbdf7a10589898f04760eed3b77fab43f664d798bf9a7731dd20f761255d9f86be68317f5
7
+ data.tar.gz: 923bafc7292dbf1cd30e529e20add0175ca391d4e1630c9cacb1a4f26f2696209f80acc8aca8ba96e344c60eb7ef73e211778204a9aaab0b5159403a92bad7d5
@@ -1,4 +1,4 @@
1
- import { useState, useCallback, useMemo } from 'react';
1
+ import { useState, useCallback, useMemo, useEffect } from 'react';
2
2
  import {
3
3
  useReactTable,
4
4
  getCoreRowModel,
@@ -50,6 +50,7 @@ export function useTableState({
50
50
  columnVisibilityControl,
51
51
  pinnedRows,
52
52
  }: UseTableStateProps) {
53
+
53
54
  // Create a local state for expanded and setExpanded if expandedControl not used
54
55
  const [localExpanded, setLocalExpanded] = useState({});
55
56
  const [loadingStateRowCount, setLoadingStateRowCount] = useState(initialLoadingRowsCount);
@@ -63,8 +64,8 @@ export function useTableState({
63
64
  const setExpanded = expandedControl ? expandedControl.onChange : setLocalExpanded;
64
65
  const columnVisibility = (columnVisibilityControl && columnVisibilityControl.value) ? columnVisibilityControl.value : localColumnVisibility;
65
66
  const setColumnVisibility = (columnVisibilityControl && columnVisibilityControl.onChange) ? columnVisibilityControl.onChange : setLocalColumnVisibility;
66
- const rowPinning = pinnedRows && pinnedRows.value || localRowPinning;
67
- const setRowPinning = (pinnedRows && pinnedRows.onChange) ? pinnedRows.onChange : setLocalRowPinning;
67
+ const rowPinning = pinnedRows?.value ?? localRowPinning
68
+ const onRowPinningChange = pinnedRows?.onChange ?? setLocalRowPinning
68
69
 
69
70
  // Virtualized data handling (chunked loading)
70
71
  const fetchSize = 20; // Number of rows per "page"
@@ -165,6 +166,7 @@ export function useTableState({
165
166
  enableSortingRemoval: false,
166
167
  sortDescFirst: true,
167
168
  onRowSelectionChange: setRowSelection,
169
+ onRowPinningChange,
168
170
  getRowId: (selectableRows || pinnedRows) ? row => row.id : undefined,
169
171
  onColumnVisibilityChange: setColumnVisibility,
170
172
  meta: {
@@ -175,6 +177,26 @@ export function useTableState({
175
177
  ...tableOptions,
176
178
  });
177
179
 
180
+ // Handle row pinning changes
181
+ useEffect(() => {
182
+ const topPins = pinnedRows?.value?.top ?? [];
183
+ if (topPins.length === 0) {
184
+ onRowPinningChange({ top: [] });
185
+ return;
186
+ }
187
+ const rows = table.getRowModel().rows;
188
+ const collectAllDescendantIds = (subs: Row<GenericObject>[]): string[] =>
189
+ subs.flatMap(r => [r.id, ...collectAllDescendantIds(r.subRows)]);
190
+ const allPinned: string[] = [];
191
+ topPins.forEach(id => {
192
+ const parent = rows.find(r => r.id === id && r.depth === 0);
193
+ if (parent) {
194
+ allPinned.push(parent.id, ...collectAllDescendantIds(parent.subRows));
195
+ }
196
+ });
197
+ onRowPinningChange({ top: allPinned });
198
+ }, [table, pinnedRows?.value?.top?.join(',')]);
199
+
178
200
  // Check if table has any sub-rows
179
201
  const hasAnySubRows = table.getRowModel().rows.some(row => row.subRows && row.subRows.length > 0);
180
202
  const selectedRowsLength = Object.keys(table.getState().rowSelection).length;
@@ -35,7 +35,7 @@ const AdvancedTableRowPinning = (props) => {
35
35
  },
36
36
  ]
37
37
 
38
- const [pinnedRows, setPinnedRows] = useState({top: ["8", "9", "10", "11", "12", "13", "14"]})
38
+ const [pinnedRows, setPinnedRows] = useState({top: ["8"]})
39
39
 
40
40
  return (
41
41
  <div>
@@ -1,5 +1,7 @@
1
- Use the `pinnedRows` prop to pin specific rows to the top of an Advanced Table. Pinned rows will remain at the top when scrolling through table data and reorganizing via sorting.
1
+ Use the `pinnedRows` prop to pin specific rows to the top of an Advanced Table. Pinned rows will remain at the top when scrolling through table data and will not change position if sorting is used.
2
2
 
3
- **NOTE:** This prop is in Beta. Current Requirements for V1:
3
+ **NOTE:**
4
4
  - Sticky header required: Pinned rows must be used with `sticky: true` via `tableProps` (works with both responsive and non-responsive tables)
5
- - Row ids required: Pass an array of row ids to the `top` property. For expandable rows, both parent and all its child row ids must be included individually
5
+ - Row ids required: Each object within the `tableData` Array must contain a unique id in order to attach an id to all Rows for this to function.
6
+ - `pinnedRows` takes an array of row ids to the `top` property as shown in the code snippet below.
7
+ - For expandable rows, use the parent id in `pinnedRows`, all its children will automatically be pinned with it. If id for a child is passed in without parent being pinned, nothing will be pinned.