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 +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +25 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_react.md +5 -3
- data/dist/chunks/_typeahead-CVIBi3oA.js +22 -0
- data/dist/chunks/_weekday_stacked-BknM0ZnU.js +45 -0
- data/dist/chunks/lib-D7Va7yqa.js +29 -0
- data/dist/chunks/{pb_form_validation-CbyL4Bqa.js → pb_form_validation-DSkdRDMf.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +3 -3
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +5 -5
- data/dist/chunks/_typeahead-BXD634Vm.js +0 -22
- data/dist/chunks/_weekday_stacked-BxnkrDBG.js +0 -45
- data/dist/chunks/lib-9VvC3Rp0.js +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775191059b582c0fb74cc6d654e3b563226fbe855b9b9f267fa4cd982955fa2f
|
4
|
+
data.tar.gz: fca502f3f539f439b6471b266cc211b46bb0fcba13d00189e89ce0893df0a9be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
67
|
-
const
|
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;
|
@@ -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
|
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:**
|
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:
|
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.
|