@ostack.tech/ui 0.14.2 → 0.15.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/dist/ostack-ui.js +188 -91
- package/dist/ostack-ui.js.map +1 -1
- package/dist/types/components/DataTable/DataTable.d.ts +50 -4
- package/dist/types/components/DataTable/DataTableContext.d.ts +16 -37
- package/dist/types/components/DataTable/DataTableSelectionTrigger.d.ts +3 -1
- package/package.json +1 -1
- /package/dist/types/components/DataTable/{transformRows.d.ts → processRows.d.ts} +0 -0
package/dist/ostack-ui.js
CHANGED
|
@@ -238,47 +238,6 @@ function useStartPrintingTask({
|
|
|
238
238
|
[enabled, finishPrintingTask]
|
|
239
239
|
);
|
|
240
240
|
}
|
|
241
|
-
function spliceWindow(totalCount, offset, limit, window2, startIndex, deleted = 0, added = 0) {
|
|
242
|
-
const deletedCount = Math.min(deleted, totalCount - startIndex);
|
|
243
|
-
const addedCount = typeof added === "number" ? added : added.length;
|
|
244
|
-
const countDiff = addedCount - deletedCount;
|
|
245
|
-
const newTotalCount = totalCount + countDiff;
|
|
246
|
-
if (startIndex >= offset + limit || startIndex + deletedCount <= offset && countDiff === 0) {
|
|
247
|
-
return { totalCount: newTotalCount, window: window2 };
|
|
248
|
-
}
|
|
249
|
-
const newLimit = Math.min(newTotalCount - offset, limit);
|
|
250
|
-
if (newLimit < 0) {
|
|
251
|
-
return { totalCount: newTotalCount, window: [] };
|
|
252
|
-
}
|
|
253
|
-
let newWindow;
|
|
254
|
-
if (startIndex + deletedCount <= offset && countDiff < 0) {
|
|
255
|
-
newWindow = window2.slice(-countDiff);
|
|
256
|
-
} else {
|
|
257
|
-
const relativeStartIndex = startIndex - offset;
|
|
258
|
-
const spliceStartIndex = Math.max(0, relativeStartIndex);
|
|
259
|
-
const spliceDeleteCount = Math.max(
|
|
260
|
-
0,
|
|
261
|
-
relativeStartIndex + deletedCount - spliceStartIndex
|
|
262
|
-
);
|
|
263
|
-
const ignoreAddedCount = Math.max(
|
|
264
|
-
0,
|
|
265
|
-
Math.min(offset - startIndex, addedCount)
|
|
266
|
-
);
|
|
267
|
-
const padRightCount = Math.max(
|
|
268
|
-
0,
|
|
269
|
-
countDiff - addedCount + ignoreAddedCount
|
|
270
|
-
);
|
|
271
|
-
const spliceToAdd = typeof added === "number" ? Array.from({ length: added - ignoreAddedCount + padRightCount }) : added.slice(ignoreAddedCount).concat(Array.from({ length: padRightCount }));
|
|
272
|
-
newWindow = window2.slice();
|
|
273
|
-
newWindow.splice(spliceStartIndex, spliceDeleteCount, ...spliceToAdd);
|
|
274
|
-
}
|
|
275
|
-
const newWindowLength = newWindow.length;
|
|
276
|
-
newWindow.length = newLimit;
|
|
277
|
-
if (newWindowLength < newLimit) {
|
|
278
|
-
newWindow.fill(void 0, newWindowLength);
|
|
279
|
-
}
|
|
280
|
-
return { totalCount: newTotalCount, window: newWindow };
|
|
281
|
-
}
|
|
282
241
|
function matchAgainstFilter(value, filter, locale7) {
|
|
283
242
|
if (value === "" || filter === "") {
|
|
284
243
|
return null;
|
|
@@ -392,6 +351,47 @@ function sortRows(leafColumns2, rows, sortBy, sortDirection) {
|
|
|
392
351
|
sortDirection ?? column.defaultSortDirection ?? "asc"
|
|
393
352
|
);
|
|
394
353
|
}
|
|
354
|
+
function spliceWindow(totalCount, offset, limit, window2, startIndex, deleted = 0, added = 0) {
|
|
355
|
+
const deletedCount = Math.min(deleted, totalCount - startIndex);
|
|
356
|
+
const addedCount = typeof added === "number" ? added : added.length;
|
|
357
|
+
const countDiff = addedCount - deletedCount;
|
|
358
|
+
const newTotalCount = totalCount + countDiff;
|
|
359
|
+
if (startIndex >= offset + limit || startIndex + deletedCount <= offset && countDiff === 0) {
|
|
360
|
+
return { totalCount: newTotalCount, window: window2 };
|
|
361
|
+
}
|
|
362
|
+
const newLimit = Math.min(newTotalCount - offset, limit);
|
|
363
|
+
if (newLimit < 0) {
|
|
364
|
+
return { totalCount: newTotalCount, window: [] };
|
|
365
|
+
}
|
|
366
|
+
let newWindow;
|
|
367
|
+
if (startIndex + deletedCount <= offset && countDiff < 0) {
|
|
368
|
+
newWindow = window2.slice(-countDiff);
|
|
369
|
+
} else {
|
|
370
|
+
const relativeStartIndex = startIndex - offset;
|
|
371
|
+
const spliceStartIndex = Math.max(0, relativeStartIndex);
|
|
372
|
+
const spliceDeleteCount = Math.max(
|
|
373
|
+
0,
|
|
374
|
+
relativeStartIndex + deletedCount - spliceStartIndex
|
|
375
|
+
);
|
|
376
|
+
const ignoreAddedCount = Math.max(
|
|
377
|
+
0,
|
|
378
|
+
Math.min(offset - startIndex, addedCount)
|
|
379
|
+
);
|
|
380
|
+
const padRightCount = Math.max(
|
|
381
|
+
0,
|
|
382
|
+
countDiff - addedCount + ignoreAddedCount
|
|
383
|
+
);
|
|
384
|
+
const spliceToAdd = typeof added === "number" ? Array.from({ length: added - ignoreAddedCount + padRightCount }) : added.slice(ignoreAddedCount).concat(Array.from({ length: padRightCount }));
|
|
385
|
+
newWindow = window2.slice();
|
|
386
|
+
newWindow.splice(spliceStartIndex, spliceDeleteCount, ...spliceToAdd);
|
|
387
|
+
}
|
|
388
|
+
const newWindowLength = newWindow.length;
|
|
389
|
+
newWindow.length = newLimit;
|
|
390
|
+
if (newWindowLength < newLimit) {
|
|
391
|
+
newWindow.fill(void 0, newWindowLength);
|
|
392
|
+
}
|
|
393
|
+
return { totalCount: newTotalCount, window: newWindow };
|
|
394
|
+
}
|
|
395
395
|
const DataTableContext = createContext(
|
|
396
396
|
null
|
|
397
397
|
);
|
|
@@ -399,6 +399,8 @@ function useCreateDataTableContext({
|
|
|
399
399
|
displayMode,
|
|
400
400
|
columns,
|
|
401
401
|
rows,
|
|
402
|
+
onVisibleRowsChange,
|
|
403
|
+
onProcessedRowsChange,
|
|
402
404
|
getRows,
|
|
403
405
|
rowKey,
|
|
404
406
|
loadingCount,
|
|
@@ -428,9 +430,12 @@ function useCreateDataTableContext({
|
|
|
428
430
|
sortDirection,
|
|
429
431
|
onSort,
|
|
430
432
|
showSelectionColumn,
|
|
433
|
+
selectionMode,
|
|
431
434
|
defaultSelectedRows,
|
|
432
435
|
selectedRows,
|
|
433
436
|
onSelectedRowsChange,
|
|
437
|
+
selectAllChecked,
|
|
438
|
+
onSelectAll,
|
|
434
439
|
disabledSelections,
|
|
435
440
|
selectAllRowsLabel,
|
|
436
441
|
selectRowLabel
|
|
@@ -439,6 +444,8 @@ function useCreateDataTableContext({
|
|
|
439
444
|
const latest = useLatestValues({
|
|
440
445
|
startPrintingTask,
|
|
441
446
|
finishPrintingTask,
|
|
447
|
+
onVisibleRowsChange,
|
|
448
|
+
onProcessedRowsChange,
|
|
442
449
|
onOffsetChange,
|
|
443
450
|
onLimitChange,
|
|
444
451
|
onSort,
|
|
@@ -500,6 +507,7 @@ function useCreateDataTableContext({
|
|
|
500
507
|
filter: filter ?? defaultFilter2,
|
|
501
508
|
sortBy: initialSortBy,
|
|
502
509
|
sortDirection: sortDirection ?? defaultSortDirection ?? (initialSortBy !== null && columns[initialSortBy].defaultSortDirection || "asc"),
|
|
510
|
+
selectionMode,
|
|
503
511
|
selectedRows: [
|
|
504
512
|
new Set(selectedRows ?? defaultSelectedRows ?? void 0)
|
|
505
513
|
],
|
|
@@ -509,7 +517,7 @@ function useCreateDataTableContext({
|
|
|
509
517
|
() => [get().leafColumns, get()._rows, get().filter],
|
|
510
518
|
(leafColumns22, rows2, filter2) => filterRows(leafColumns22, rows2, filter2)
|
|
511
519
|
),
|
|
512
|
-
|
|
520
|
+
processedRows: computed(
|
|
513
521
|
() => [
|
|
514
522
|
get().leafColumns,
|
|
515
523
|
get()._filteredRows(),
|
|
@@ -525,15 +533,33 @@ function useCreateDataTableContext({
|
|
|
525
533
|
ongoingGetRows: void 0,
|
|
526
534
|
abortController: void 0,
|
|
527
535
|
cachedRows: void 0,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
(
|
|
532
|
-
|
|
533
|
-
|
|
536
|
+
visibleRows: computed(
|
|
537
|
+
() => [
|
|
538
|
+
displayMode,
|
|
539
|
+
get().pageOffset(),
|
|
540
|
+
get().pageLimit(),
|
|
541
|
+
get().limit(),
|
|
542
|
+
get().totalCount(),
|
|
543
|
+
get().scrolledRangeStart,
|
|
544
|
+
get().scrolledRangeEnd
|
|
545
|
+
],
|
|
546
|
+
(displayMode2, pageOffset, pageLimit, limit2, totalCount, scrolledRangeStart, scrolledRangeEnd) => {
|
|
547
|
+
if (displayMode2 === "paged") {
|
|
548
|
+
return get().actions.getRowsWindow(
|
|
549
|
+
pageOffset,
|
|
550
|
+
pageLimit ?? limit2
|
|
551
|
+
);
|
|
552
|
+
} else {
|
|
553
|
+
const total = totalCount ?? limit2;
|
|
554
|
+
const start = Math.min(scrolledRangeStart, total - 1);
|
|
555
|
+
const end = Math.min(scrolledRangeEnd, total - 1);
|
|
556
|
+
return get().actions.getRowsWindow(start, end - start + 1);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
),
|
|
534
560
|
_totalCount: void 0,
|
|
535
561
|
totalCount: computed(
|
|
536
|
-
() => [get().
|
|
562
|
+
() => [get().processedRows(), get()._totalCount],
|
|
537
563
|
(rows2, totalCount) => rows2?.length ?? totalCount
|
|
538
564
|
),
|
|
539
565
|
bodyCount: computed(
|
|
@@ -549,6 +575,12 @@ function useCreateDataTableContext({
|
|
|
549
575
|
tableHeadHeight: void 0,
|
|
550
576
|
tableFootHeight: void 0,
|
|
551
577
|
actions: {
|
|
578
|
+
getRowsWindow: (offset2, limit2) => {
|
|
579
|
+
return get()._rows ? get().processedRows().slice(offset2, offset2 + limit2) : Array.from(
|
|
580
|
+
{ length: limit2 },
|
|
581
|
+
(_, i) => get().cachedRows?.[offset2 + i]
|
|
582
|
+
);
|
|
583
|
+
},
|
|
552
584
|
setGetRows: (getRows2) => {
|
|
553
585
|
if (get().offset() > 0) {
|
|
554
586
|
get().actions.setOffset(0);
|
|
@@ -557,12 +589,26 @@ function useCreateDataTableContext({
|
|
|
557
589
|
get().actions.refresh(null);
|
|
558
590
|
},
|
|
559
591
|
setOffset: (offset2) => {
|
|
592
|
+
const oldOffset = get().offset();
|
|
560
593
|
set({ updateCounter: get().updateCounter + 1, _offset: offset2 });
|
|
561
|
-
|
|
594
|
+
const newOffset = get().offset();
|
|
595
|
+
if (oldOffset !== newOffset) {
|
|
596
|
+
latest.onOffsetChange?.(newOffset);
|
|
597
|
+
if (get()._rows) {
|
|
598
|
+
latest.onVisibleRowsChange?.(get().visibleRows());
|
|
599
|
+
}
|
|
600
|
+
}
|
|
562
601
|
},
|
|
563
602
|
setLimit: (limit2) => {
|
|
603
|
+
const oldLimit = get().limit();
|
|
564
604
|
set({ updateCounter: get().updateCounter + 1, _limit: limit2 });
|
|
565
|
-
|
|
605
|
+
const newLimit = get().limit();
|
|
606
|
+
if (oldLimit !== limit2) {
|
|
607
|
+
latest.onLimitChange?.(newLimit);
|
|
608
|
+
if (get()._rows) {
|
|
609
|
+
latest.onVisibleRowsChange?.(get().visibleRows());
|
|
610
|
+
}
|
|
611
|
+
}
|
|
566
612
|
},
|
|
567
613
|
setFilter: (filter2) => {
|
|
568
614
|
if (get().offset() > 0) {
|
|
@@ -571,6 +617,10 @@ function useCreateDataTableContext({
|
|
|
571
617
|
set({ filter: filter2 });
|
|
572
618
|
get().actions.refresh(null);
|
|
573
619
|
latest.onFilterChange?.(filter2);
|
|
620
|
+
if (get()._rows) {
|
|
621
|
+
latest.onVisibleRowsChange?.(get().visibleRows());
|
|
622
|
+
latest.onProcessedRowsChange?.(get().processedRows());
|
|
623
|
+
}
|
|
574
624
|
},
|
|
575
625
|
setSort: (sortBy2, sortDirection2) => {
|
|
576
626
|
if (get().offset() > 0) {
|
|
@@ -579,38 +629,61 @@ function useCreateDataTableContext({
|
|
|
579
629
|
set({ sortBy: sortBy2, sortDirection: sortDirection2 });
|
|
580
630
|
get().actions.refresh();
|
|
581
631
|
latest.onSort?.(sortBy2, sortDirection2);
|
|
632
|
+
if (get()._rows) {
|
|
633
|
+
latest.onVisibleRowsChange?.(get().visibleRows());
|
|
634
|
+
latest.onProcessedRowsChange?.(get().processedRows());
|
|
635
|
+
}
|
|
582
636
|
},
|
|
583
637
|
selectRows: (keys) => {
|
|
584
638
|
const {
|
|
639
|
+
selectionMode: selectionMode2,
|
|
585
640
|
selectedRows: [selectedRows2],
|
|
586
641
|
disabledSelections: disabledSelections2
|
|
587
642
|
} = get();
|
|
588
|
-
let
|
|
643
|
+
let selectionChanged = false;
|
|
589
644
|
for (const key of keys) {
|
|
590
|
-
if (
|
|
645
|
+
if (disabledSelections2?.has(key)) {
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
if (selectionMode2 === "additive" && !selectedRows2.has(key)) {
|
|
591
649
|
selectedRows2.add(key);
|
|
592
|
-
|
|
650
|
+
selectionChanged = true;
|
|
651
|
+
} else if (selectionMode2 === "subtractive" && selectedRows2.delete(key)) {
|
|
652
|
+
selectionChanged = true;
|
|
593
653
|
}
|
|
594
654
|
}
|
|
595
|
-
if (
|
|
655
|
+
if (selectionChanged) {
|
|
596
656
|
set({ selectedRows: [selectedRows2] });
|
|
597
|
-
latest.onSelectedRowsChange?.(
|
|
657
|
+
latest.onSelectedRowsChange?.(
|
|
658
|
+
Array.from(selectedRows2).sort(),
|
|
659
|
+
selectionMode2
|
|
660
|
+
);
|
|
598
661
|
}
|
|
599
662
|
},
|
|
600
663
|
unselectRows: (keys) => {
|
|
601
664
|
const {
|
|
665
|
+
selectionMode: selectionMode2,
|
|
602
666
|
selectedRows: [selectedRows2],
|
|
603
667
|
disabledSelections: disabledSelections2
|
|
604
668
|
} = get();
|
|
605
|
-
let
|
|
669
|
+
let selectionChanged = false;
|
|
606
670
|
for (const key of keys) {
|
|
607
|
-
if (
|
|
608
|
-
|
|
671
|
+
if (disabledSelections2?.has(key)) {
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
if (selectionMode2 === "additive" && selectedRows2.delete(key)) {
|
|
675
|
+
selectionChanged = true;
|
|
676
|
+
} else if (selectionMode2 === "subtractive" && !selectedRows2.has(key)) {
|
|
677
|
+
selectedRows2.add(key);
|
|
678
|
+
selectionChanged = true;
|
|
609
679
|
}
|
|
610
680
|
}
|
|
611
|
-
if (
|
|
681
|
+
if (selectionChanged) {
|
|
612
682
|
set({ selectedRows: [selectedRows2] });
|
|
613
|
-
latest.onSelectedRowsChange?.(
|
|
683
|
+
latest.onSelectedRowsChange?.(
|
|
684
|
+
Array.from(selectedRows2).sort(),
|
|
685
|
+
selectionMode2
|
|
686
|
+
);
|
|
614
687
|
}
|
|
615
688
|
},
|
|
616
689
|
updateWindow: (offset2, limit2) => {
|
|
@@ -778,6 +851,7 @@ function useCreateDataTableContext({
|
|
|
778
851
|
loading,
|
|
779
852
|
loadingCount,
|
|
780
853
|
headCount,
|
|
854
|
+
selectionMode,
|
|
781
855
|
...selectedRows === void 0 ? {} : { selectedRows: [new Set(selectedRows)] },
|
|
782
856
|
disabledSelections: disabledSelections && new Set(disabledSelections)
|
|
783
857
|
});
|
|
@@ -792,8 +866,16 @@ function useCreateDataTableContext({
|
|
|
792
866
|
offset,
|
|
793
867
|
rows,
|
|
794
868
|
selectedRows,
|
|
795
|
-
store
|
|
869
|
+
store,
|
|
870
|
+
selectionMode
|
|
796
871
|
]);
|
|
872
|
+
useEffect(() => {
|
|
873
|
+
if (store.getState()._rows) {
|
|
874
|
+
const { visibleRows, processedRows } = store.getState();
|
|
875
|
+
latest.onVisibleRowsChange?.(visibleRows());
|
|
876
|
+
latest.onProcessedRowsChange?.(processedRows());
|
|
877
|
+
}
|
|
878
|
+
}, [latest, store]);
|
|
797
879
|
const generatedId = useId();
|
|
798
880
|
return useMemo(
|
|
799
881
|
() => ({
|
|
@@ -806,6 +888,8 @@ function useCreateDataTableContext({
|
|
|
806
888
|
dynamicRowHeight,
|
|
807
889
|
estimatedRowHeight,
|
|
808
890
|
overscan,
|
|
891
|
+
selectAllChecked,
|
|
892
|
+
onSelectAll,
|
|
809
893
|
selectAllRowsLabel,
|
|
810
894
|
selectRowLabel,
|
|
811
895
|
generatedId,
|
|
@@ -823,6 +907,8 @@ function useCreateDataTableContext({
|
|
|
823
907
|
dynamicRowHeight,
|
|
824
908
|
estimatedRowHeight,
|
|
825
909
|
overscan,
|
|
910
|
+
onSelectAll,
|
|
911
|
+
selectAllChecked,
|
|
826
912
|
selectAllRowsLabel,
|
|
827
913
|
selectRowLabel,
|
|
828
914
|
generatedId,
|
|
@@ -4742,6 +4828,8 @@ const DataTable = forwardRef(
|
|
|
4742
4828
|
displayMode = "paged",
|
|
4743
4829
|
columns,
|
|
4744
4830
|
rows,
|
|
4831
|
+
onVisibleRowsChange,
|
|
4832
|
+
onProcessedRowsChange,
|
|
4745
4833
|
getRows,
|
|
4746
4834
|
rowKey,
|
|
4747
4835
|
loadingCount = 2,
|
|
@@ -4762,9 +4850,12 @@ const DataTable = forwardRef(
|
|
|
4762
4850
|
sortDirection,
|
|
4763
4851
|
onSort,
|
|
4764
4852
|
showSelectionColumn = false,
|
|
4853
|
+
selectionMode = "additive",
|
|
4765
4854
|
defaultSelectedRows,
|
|
4766
4855
|
selectedRows,
|
|
4767
4856
|
onSelectedRowsChange,
|
|
4857
|
+
selectAllChecked,
|
|
4858
|
+
onSelectAll,
|
|
4768
4859
|
disabledSelections,
|
|
4769
4860
|
selectAllRowsLabel,
|
|
4770
4861
|
selectRowLabel,
|
|
@@ -4794,6 +4885,8 @@ const DataTable = forwardRef(
|
|
|
4794
4885
|
displayMode: printing ? "paged" : displayMode,
|
|
4795
4886
|
columns,
|
|
4796
4887
|
rows,
|
|
4888
|
+
onVisibleRowsChange,
|
|
4889
|
+
onProcessedRowsChange,
|
|
4797
4890
|
getRows,
|
|
4798
4891
|
rowKey,
|
|
4799
4892
|
loadingCount,
|
|
@@ -4823,9 +4916,12 @@ const DataTable = forwardRef(
|
|
|
4823
4916
|
sortDirection,
|
|
4824
4917
|
onSort,
|
|
4825
4918
|
showSelectionColumn,
|
|
4919
|
+
selectionMode,
|
|
4826
4920
|
defaultSelectedRows,
|
|
4827
4921
|
selectedRows,
|
|
4828
4922
|
onSelectedRowsChange,
|
|
4923
|
+
selectAllChecked,
|
|
4924
|
+
onSelectAll,
|
|
4829
4925
|
disabledSelections,
|
|
4830
4926
|
selectAllRowsLabel,
|
|
4831
4927
|
selectRowLabel
|
|
@@ -5861,15 +5957,17 @@ function useDataTableSelectionColumn() {
|
|
|
5861
5957
|
const prefix = usePrefix();
|
|
5862
5958
|
const [locale7] = useLocale();
|
|
5863
5959
|
const {
|
|
5864
|
-
displayMode,
|
|
5865
5960
|
rowKey,
|
|
5866
5961
|
showSelectionColumn,
|
|
5962
|
+
selectAllChecked,
|
|
5963
|
+
onSelectAll,
|
|
5867
5964
|
selectAllRowsLabel,
|
|
5868
5965
|
selectRowLabel,
|
|
5869
5966
|
store
|
|
5870
5967
|
} = useDataTableContext();
|
|
5871
5968
|
const actualSelectAllRowsLabel = selectAllRowsLabel ?? locale7.DataTable.selectAllRowsLabel;
|
|
5872
5969
|
const actualSelectRowLabel = selectRowLabel ?? locale7.DataTable.selectRowLabel;
|
|
5970
|
+
const selectionMode = useStore$1(store, (state) => state.selectionMode);
|
|
5873
5971
|
const [selectedRows] = useStore$1(store, (state) => state.selectedRows);
|
|
5874
5972
|
const disabledSelections = useStore$1(
|
|
5875
5973
|
store,
|
|
@@ -5885,17 +5983,20 @@ function useDataTableSelectionColumn() {
|
|
|
5885
5983
|
if (state.loading || !showSelectionColumn) {
|
|
5886
5984
|
return "loading";
|
|
5887
5985
|
}
|
|
5888
|
-
const
|
|
5889
|
-
|
|
5986
|
+
const {
|
|
5987
|
+
selectionMode: selectionMode2,
|
|
5988
|
+
selectedRows: [selectedRows2]
|
|
5989
|
+
} = state;
|
|
5990
|
+
const visibleRows = state.visibleRows();
|
|
5890
5991
|
let selectedCount = 0;
|
|
5891
5992
|
let disabledCount = 0;
|
|
5892
5993
|
let allEnabledChecked = true;
|
|
5893
|
-
for (const row of
|
|
5994
|
+
for (const row of visibleRows) {
|
|
5894
5995
|
if (row === void 0) {
|
|
5895
5996
|
return "loading";
|
|
5896
5997
|
}
|
|
5897
5998
|
const key = getRowKey(row, rowKey);
|
|
5898
|
-
const isSelected = selectedRows2.has(key);
|
|
5999
|
+
const isSelected = selectedRows2.has(key) === (selectionMode2 === "additive");
|
|
5899
6000
|
const isDisabled = disabledSelections?.has(key) ?? false;
|
|
5900
6001
|
selectedCount += +isSelected;
|
|
5901
6002
|
disabledCount += +isDisabled;
|
|
@@ -5904,8 +6005,8 @@ function useDataTableSelectionColumn() {
|
|
|
5904
6005
|
}
|
|
5905
6006
|
}
|
|
5906
6007
|
return {
|
|
5907
|
-
allDisabled: disabledCount ===
|
|
5908
|
-
allChecked:
|
|
6008
|
+
allDisabled: disabledCount === visibleRows.length,
|
|
6009
|
+
allChecked: visibleRows.length > 0 && selectedCount === visibleRows.length ? true : selectedCount === 0 ? false : "indeterminate",
|
|
5909
6010
|
allEnabledChecked
|
|
5910
6011
|
};
|
|
5911
6012
|
})
|
|
@@ -5916,15 +6017,16 @@ function useDataTableSelectionColumn() {
|
|
|
5916
6017
|
label: allCheckedStatus === "loading" ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(
|
|
5917
6018
|
Checkbox,
|
|
5918
6019
|
{
|
|
5919
|
-
checked: allCheckedStatus.allChecked,
|
|
6020
|
+
checked: selectAllChecked ?? allCheckedStatus.allChecked,
|
|
5920
6021
|
onCheckedChange: () => {
|
|
5921
|
-
const
|
|
5922
|
-
const keys =
|
|
6022
|
+
const visibleRows = store.getState().visibleRows();
|
|
6023
|
+
const keys = visibleRows.map((row) => getRowKey(row, rowKey));
|
|
5923
6024
|
if (allCheckedStatus.allEnabledChecked) {
|
|
5924
6025
|
unselectRows(keys);
|
|
5925
6026
|
} else {
|
|
5926
6027
|
selectRows(keys);
|
|
5927
6028
|
}
|
|
6029
|
+
onSelectAll?.(!allCheckedStatus.allEnabledChecked);
|
|
5928
6030
|
},
|
|
5929
6031
|
disabled: allCheckedStatus.allDisabled,
|
|
5930
6032
|
labelProps: {
|
|
@@ -5944,7 +6046,7 @@ function useDataTableSelectionColumn() {
|
|
|
5944
6046
|
return /* @__PURE__ */ jsx(
|
|
5945
6047
|
Checkbox,
|
|
5946
6048
|
{
|
|
5947
|
-
checked: selectedRows.has(key),
|
|
6049
|
+
checked: selectedRows.has(key) === (selectionMode === "additive"),
|
|
5948
6050
|
onCheckedChange: (checked) => {
|
|
5949
6051
|
if (checked) {
|
|
5950
6052
|
selectRows([key]);
|
|
@@ -5967,19 +6069,6 @@ function useDataTableSelectionColumnId() {
|
|
|
5967
6069
|
const prefix = usePrefix();
|
|
5968
6070
|
return prefix("data-table-selection-column");
|
|
5969
6071
|
}
|
|
5970
|
-
function selectionWindow(displayMode, state) {
|
|
5971
|
-
if (displayMode === "paged") {
|
|
5972
|
-
return state.rowsWindow(
|
|
5973
|
-
state.pageOffset(),
|
|
5974
|
-
state.pageLimit() ?? state.limit()
|
|
5975
|
-
);
|
|
5976
|
-
} else {
|
|
5977
|
-
const totalCount = state.totalCount() ?? state.limit();
|
|
5978
|
-
const start = Math.min(state.scrolledRangeStart, totalCount - 1);
|
|
5979
|
-
const end = Math.min(state.scrolledRangeEnd, totalCount - 1);
|
|
5980
|
-
return state.rowsWindow(start, end - start + 1);
|
|
5981
|
-
}
|
|
5982
|
-
}
|
|
5983
6072
|
const DataTableRow = memo(
|
|
5984
6073
|
forwardRef(
|
|
5985
6074
|
function DataTableRow2({ row, index, className, ...otherProps }, forwardedRef) {
|
|
@@ -6172,7 +6261,7 @@ function PagedDataTableRows() {
|
|
|
6172
6261
|
const rowsWindow = useStore$1(
|
|
6173
6262
|
store,
|
|
6174
6263
|
useShallow(
|
|
6175
|
-
(state) => state.
|
|
6264
|
+
(state) => state.actions.getRowsWindow(
|
|
6176
6265
|
showAllRows ? 0 : state.pageOffset(),
|
|
6177
6266
|
(showAllRows ? state.totalCount() : state.pageLimit()) ?? state.loadingCount
|
|
6178
6267
|
)
|
|
@@ -6291,7 +6380,10 @@ function ScrolledDataTableRows({
|
|
|
6291
6380
|
const rowsWindow = useStore$1(
|
|
6292
6381
|
store,
|
|
6293
6382
|
useShallow(
|
|
6294
|
-
(state) => state.
|
|
6383
|
+
(state) => state.actions.getRowsWindow(
|
|
6384
|
+
firstVirtualItem?.index ?? 0,
|
|
6385
|
+
virtualItems.length
|
|
6386
|
+
)
|
|
6295
6387
|
)
|
|
6296
6388
|
);
|
|
6297
6389
|
useEffect(
|
|
@@ -6414,7 +6506,7 @@ const DataTableFoot = forwardRef(function DataTableFoot2({ footContent, showWhen
|
|
|
6414
6506
|
);
|
|
6415
6507
|
const rows = useStore$1(
|
|
6416
6508
|
store,
|
|
6417
|
-
({
|
|
6509
|
+
({ processedRows }) => processedRows()
|
|
6418
6510
|
);
|
|
6419
6511
|
const combinedTableFootRef = useCombinedRef(setTableFootEl, forwardedRef);
|
|
6420
6512
|
return shouldShow && (hasFooterCells || footContent) && /* @__PURE__ */ jsxs(TableFoot, { ...otherProps, ref: combinedTableFootRef, children: [
|
|
@@ -6929,11 +7021,15 @@ const DataTableSelectionTrigger = forwardRef(function DataTableSelectionTrigger2
|
|
|
6929
7021
|
const { store } = useDataTableContext();
|
|
6930
7022
|
const hasSelected = useStore$1(
|
|
6931
7023
|
store,
|
|
6932
|
-
(
|
|
7024
|
+
({ totalCount, selectionMode, selectedRows }) => totalCount() !== 0 && (selectionMode === "subtractive" || selectedRows[0].size > 0)
|
|
6933
7025
|
);
|
|
6934
7026
|
const handleClick = useCallback(
|
|
6935
7027
|
(event) => {
|
|
6936
|
-
onClick(
|
|
7028
|
+
onClick(
|
|
7029
|
+
Array.from(store.getState().selectedRows[0]).sort(),
|
|
7030
|
+
store.getState().selectionMode,
|
|
7031
|
+
event
|
|
7032
|
+
);
|
|
6937
7033
|
},
|
|
6938
7034
|
[onClick, store]
|
|
6939
7035
|
);
|
|
@@ -9418,6 +9514,7 @@ const Select = forwardRef(function Select2({
|
|
|
9418
9514
|
printHidden,
|
|
9419
9515
|
arrowProps?.className
|
|
9420
9516
|
),
|
|
9517
|
+
onClick: (evt) => evt.preventDefault(),
|
|
9421
9518
|
"data-status": status,
|
|
9422
9519
|
"data-disabled": boolDataAttr(disabled || softDisabled)
|
|
9423
9520
|
}
|