@canvas-components/list-table 0.3.3 → 0.3.5

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/index.d.cts CHANGED
@@ -1843,6 +1843,15 @@ declare class ListTable<RecordType = Record<string, unknown>> {
1843
1843
  destroy(): void;
1844
1844
  }
1845
1845
 
1846
+ /**
1847
+ * 将持久化的列设置恢复为传入列定义中的宽度、显隐和固定状态。
1848
+ * 排序、过滤、缩放、密度以及其他列展示配置保持不变。
1849
+ */
1850
+ declare function resetListTableStoredColumnConfig<RecordType>(params: {
1851
+ storageKey?: string;
1852
+ columns: ListTableOptions<RecordType>["columns"];
1853
+ }): Promise<void>;
1854
+
1846
1855
  interface ListTableValidationError<RecordType> {
1847
1856
  rowIndex: number;
1848
1857
  rowKey: string | number;
@@ -1872,4 +1881,4 @@ interface ListTableValidationTarget {
1872
1881
  columnKey: string;
1873
1882
  }
1874
1883
 
1875
- export { type CreateCellEditorSessionParams, type DebugHitTestResult, type FilterPanelConfig, type FilterPanelOptionItem, type FilterPanelTexts, type FixedPopupConfig, type HeaderContextMenuColumnItem, type HeaderContextMenuConfig, type HeaderContextMenuDensity, ListTable, type ListTableAutoMergeRule, type ListTableBarcodeCellContent, type ListTableBarcodeFormat, type ListTableButtonCellContent, type ListTableButtonPopconfirmOptions, type ListTableButtonSize, type ListTableButtonType, type ListTableCarouselScrollOptions, type ListTableCellContent, type ListTableCellContentClickContext, type ListTableCellEditorSession, type ListTableCellSpan, type ListTableCellStyle, type ListTableChartCellContent, type ListTableChartSize, type ListTableChartType, type ListTableColorCellContent, type ListTableColumn, type ListTableContextMenuFeature, type ListTableContextMenuOptions, type ListTableCustomChartCellContent, type ListTableDangerConfirmRequest, type ListTableDataFormat, type ListTableDataFormatOptions, type ListTableDataFormatType, type ListTableDebugOptions, type ListTableDebugSnapshot, type ListTableDensity, type ListTableEditAutoCompleteEnter, type ListTableEditFilterOption, type ListTableEditOption, type ListTableEditValueType, type ListTableEditable, type ListTableEditorAutoCompleteEnter, type ListTableEditorConfig, type ListTableEditorFactory, type ListTableEditorFilterOption, type ListTableEditorNavigateDirection, type ListTableEditorOption, type ListTableEditorRect, type ListTableEditorRequest, type ListTableEditorTheme, type ListTableEditorValueType, type ListTableExportXlsxOptions, type ListTableFilterCondition$1 as ListTableFilterCondition, type ListTableFilterConditionOperator, type ListTableFilterConditionRelation, type ListTableFilterMatchMode, type ListTableFilterOption, type ListTableFilterOptionValue, type ListTableFilterPanelAdapter, type ListTableFilterState, type ListTableFilterType, type ListTableFilterValue$1 as ListTableFilterValue, type ListTableFixedPopupAdapter, type ListTableFormItemProps, type ListTableFormItemPropsConfig, type ListTableFormRule, type ListTableFormRules, type ListTableGroupingOptions, type ListTableHeaderContextMenuAdapter, type ListTableHighlightMode, type ListTableHorizontalAlign, type ListTableIconCellContent, type ListTableImageCellContent, type ListTableImageObjectFit, type ListTableImagePreviewRequest, type ListTableLoadingAdapter, type ListTableLoadingRequest, type ListTableMergeCellOptions, type ListTableNestedTableCellContent, type ListTableNestedTableColumn, type ListTableOptions, type ListTablePaginationAdapter, type ListTablePaginationOptions, type ListTablePerformanceMetric, type ListTableProgressCellContent, type ListTableProgressShape, type ListTableProgressSize, type ListTableQrCodeCellContent, type ListTableQrCodeLevel, type ListTableQueryChange, type ListTableQueryChangeExtra, type ListTableQueryFilters, type ListTableQueryOptions, type ListTableQueryPagination, type ListTableQuerySorter, type ListTableRateCellContent, type ListTableRateSize, type ListTableRateSymbolType, type ListTableRowDragMode, type ListTableRowDragOptions, type ListTableRowDragPayload, type ListTableRowDragSourceInfo, type ListTableRowDragZone, type ListTableRowEventProps, type ListTableRowSelectionChangeInfo, type ListTableRowSelectionOptions, type ListTableRowSelectorOptions, type ListTableScrollToOptions, type ListTableScrollbarOptions, type ListTableSearchRequest, type ListTableSelectionState, type ListTableSortItem, type ListTableSortState, type ListTableSparklineChartCellContent, type ListTableSparklineSize, type ListTableSummaryConfig, type ListTableSummaryRoundingMode, type ListTableSummaryType, type ListTableSymbolType, type ListTableTagCellContent, type ListTableTheme, type ListTableTooltipAdapter, type ListTableTooltipRequest, type ListTableUiOptions, type ListTableValidationError, type ListTableValidationErrorField, type ListTableValidationFailure, type ListTableValidationTarget, type PaginationConfig, type RenderCellDescriptor };
1884
+ export { type CreateCellEditorSessionParams, type DebugHitTestResult, type FilterPanelConfig, type FilterPanelOptionItem, type FilterPanelTexts, type FixedPopupConfig, type HeaderContextMenuColumnItem, type HeaderContextMenuConfig, type HeaderContextMenuDensity, ListTable, type ListTableAutoMergeRule, type ListTableBarcodeCellContent, type ListTableBarcodeFormat, type ListTableButtonCellContent, type ListTableButtonPopconfirmOptions, type ListTableButtonSize, type ListTableButtonType, type ListTableCarouselScrollOptions, type ListTableCellContent, type ListTableCellContentClickContext, type ListTableCellEditorSession, type ListTableCellSpan, type ListTableCellStyle, type ListTableChartCellContent, type ListTableChartSize, type ListTableChartType, type ListTableColorCellContent, type ListTableColumn, type ListTableContextMenuFeature, type ListTableContextMenuOptions, type ListTableCustomChartCellContent, type ListTableDangerConfirmRequest, type ListTableDataFormat, type ListTableDataFormatOptions, type ListTableDataFormatType, type ListTableDebugOptions, type ListTableDebugSnapshot, type ListTableDensity, type ListTableEditAutoCompleteEnter, type ListTableEditFilterOption, type ListTableEditOption, type ListTableEditValueType, type ListTableEditable, type ListTableEditorAutoCompleteEnter, type ListTableEditorConfig, type ListTableEditorFactory, type ListTableEditorFilterOption, type ListTableEditorNavigateDirection, type ListTableEditorOption, type ListTableEditorRect, type ListTableEditorRequest, type ListTableEditorTheme, type ListTableEditorValueType, type ListTableExportXlsxOptions, type ListTableFilterCondition$1 as ListTableFilterCondition, type ListTableFilterConditionOperator, type ListTableFilterConditionRelation, type ListTableFilterMatchMode, type ListTableFilterOption, type ListTableFilterOptionValue, type ListTableFilterPanelAdapter, type ListTableFilterState, type ListTableFilterType, type ListTableFilterValue$1 as ListTableFilterValue, type ListTableFixedPopupAdapter, type ListTableFormItemProps, type ListTableFormItemPropsConfig, type ListTableFormRule, type ListTableFormRules, type ListTableGroupingOptions, type ListTableHeaderContextMenuAdapter, type ListTableHighlightMode, type ListTableHorizontalAlign, type ListTableIconCellContent, type ListTableImageCellContent, type ListTableImageObjectFit, type ListTableImagePreviewRequest, type ListTableLoadingAdapter, type ListTableLoadingRequest, type ListTableMergeCellOptions, type ListTableNestedTableCellContent, type ListTableNestedTableColumn, type ListTableOptions, type ListTablePaginationAdapter, type ListTablePaginationOptions, type ListTablePerformanceMetric, type ListTableProgressCellContent, type ListTableProgressShape, type ListTableProgressSize, type ListTableQrCodeCellContent, type ListTableQrCodeLevel, type ListTableQueryChange, type ListTableQueryChangeExtra, type ListTableQueryFilters, type ListTableQueryOptions, type ListTableQueryPagination, type ListTableQuerySorter, type ListTableRateCellContent, type ListTableRateSize, type ListTableRateSymbolType, type ListTableRowDragMode, type ListTableRowDragOptions, type ListTableRowDragPayload, type ListTableRowDragSourceInfo, type ListTableRowDragZone, type ListTableRowEventProps, type ListTableRowSelectionChangeInfo, type ListTableRowSelectionOptions, type ListTableRowSelectorOptions, type ListTableScrollToOptions, type ListTableScrollbarOptions, type ListTableSearchRequest, type ListTableSelectionState, type ListTableSortItem, type ListTableSortState, type ListTableSparklineChartCellContent, type ListTableSparklineSize, type ListTableSummaryConfig, type ListTableSummaryRoundingMode, type ListTableSummaryType, type ListTableSymbolType, type ListTableTagCellContent, type ListTableTheme, type ListTableTooltipAdapter, type ListTableTooltipRequest, type ListTableUiOptions, type ListTableValidationError, type ListTableValidationErrorField, type ListTableValidationFailure, type ListTableValidationTarget, type PaginationConfig, type RenderCellDescriptor, resetListTableStoredColumnConfig };
package/dist/index.d.ts CHANGED
@@ -1843,6 +1843,15 @@ declare class ListTable<RecordType = Record<string, unknown>> {
1843
1843
  destroy(): void;
1844
1844
  }
1845
1845
 
1846
+ /**
1847
+ * 将持久化的列设置恢复为传入列定义中的宽度、显隐和固定状态。
1848
+ * 排序、过滤、缩放、密度以及其他列展示配置保持不变。
1849
+ */
1850
+ declare function resetListTableStoredColumnConfig<RecordType>(params: {
1851
+ storageKey?: string;
1852
+ columns: ListTableOptions<RecordType>["columns"];
1853
+ }): Promise<void>;
1854
+
1846
1855
  interface ListTableValidationError<RecordType> {
1847
1856
  rowIndex: number;
1848
1857
  rowKey: string | number;
@@ -1872,4 +1881,4 @@ interface ListTableValidationTarget {
1872
1881
  columnKey: string;
1873
1882
  }
1874
1883
 
1875
- export { type CreateCellEditorSessionParams, type DebugHitTestResult, type FilterPanelConfig, type FilterPanelOptionItem, type FilterPanelTexts, type FixedPopupConfig, type HeaderContextMenuColumnItem, type HeaderContextMenuConfig, type HeaderContextMenuDensity, ListTable, type ListTableAutoMergeRule, type ListTableBarcodeCellContent, type ListTableBarcodeFormat, type ListTableButtonCellContent, type ListTableButtonPopconfirmOptions, type ListTableButtonSize, type ListTableButtonType, type ListTableCarouselScrollOptions, type ListTableCellContent, type ListTableCellContentClickContext, type ListTableCellEditorSession, type ListTableCellSpan, type ListTableCellStyle, type ListTableChartCellContent, type ListTableChartSize, type ListTableChartType, type ListTableColorCellContent, type ListTableColumn, type ListTableContextMenuFeature, type ListTableContextMenuOptions, type ListTableCustomChartCellContent, type ListTableDangerConfirmRequest, type ListTableDataFormat, type ListTableDataFormatOptions, type ListTableDataFormatType, type ListTableDebugOptions, type ListTableDebugSnapshot, type ListTableDensity, type ListTableEditAutoCompleteEnter, type ListTableEditFilterOption, type ListTableEditOption, type ListTableEditValueType, type ListTableEditable, type ListTableEditorAutoCompleteEnter, type ListTableEditorConfig, type ListTableEditorFactory, type ListTableEditorFilterOption, type ListTableEditorNavigateDirection, type ListTableEditorOption, type ListTableEditorRect, type ListTableEditorRequest, type ListTableEditorTheme, type ListTableEditorValueType, type ListTableExportXlsxOptions, type ListTableFilterCondition$1 as ListTableFilterCondition, type ListTableFilterConditionOperator, type ListTableFilterConditionRelation, type ListTableFilterMatchMode, type ListTableFilterOption, type ListTableFilterOptionValue, type ListTableFilterPanelAdapter, type ListTableFilterState, type ListTableFilterType, type ListTableFilterValue$1 as ListTableFilterValue, type ListTableFixedPopupAdapter, type ListTableFormItemProps, type ListTableFormItemPropsConfig, type ListTableFormRule, type ListTableFormRules, type ListTableGroupingOptions, type ListTableHeaderContextMenuAdapter, type ListTableHighlightMode, type ListTableHorizontalAlign, type ListTableIconCellContent, type ListTableImageCellContent, type ListTableImageObjectFit, type ListTableImagePreviewRequest, type ListTableLoadingAdapter, type ListTableLoadingRequest, type ListTableMergeCellOptions, type ListTableNestedTableCellContent, type ListTableNestedTableColumn, type ListTableOptions, type ListTablePaginationAdapter, type ListTablePaginationOptions, type ListTablePerformanceMetric, type ListTableProgressCellContent, type ListTableProgressShape, type ListTableProgressSize, type ListTableQrCodeCellContent, type ListTableQrCodeLevel, type ListTableQueryChange, type ListTableQueryChangeExtra, type ListTableQueryFilters, type ListTableQueryOptions, type ListTableQueryPagination, type ListTableQuerySorter, type ListTableRateCellContent, type ListTableRateSize, type ListTableRateSymbolType, type ListTableRowDragMode, type ListTableRowDragOptions, type ListTableRowDragPayload, type ListTableRowDragSourceInfo, type ListTableRowDragZone, type ListTableRowEventProps, type ListTableRowSelectionChangeInfo, type ListTableRowSelectionOptions, type ListTableRowSelectorOptions, type ListTableScrollToOptions, type ListTableScrollbarOptions, type ListTableSearchRequest, type ListTableSelectionState, type ListTableSortItem, type ListTableSortState, type ListTableSparklineChartCellContent, type ListTableSparklineSize, type ListTableSummaryConfig, type ListTableSummaryRoundingMode, type ListTableSummaryType, type ListTableSymbolType, type ListTableTagCellContent, type ListTableTheme, type ListTableTooltipAdapter, type ListTableTooltipRequest, type ListTableUiOptions, type ListTableValidationError, type ListTableValidationErrorField, type ListTableValidationFailure, type ListTableValidationTarget, type PaginationConfig, type RenderCellDescriptor };
1884
+ export { type CreateCellEditorSessionParams, type DebugHitTestResult, type FilterPanelConfig, type FilterPanelOptionItem, type FilterPanelTexts, type FixedPopupConfig, type HeaderContextMenuColumnItem, type HeaderContextMenuConfig, type HeaderContextMenuDensity, ListTable, type ListTableAutoMergeRule, type ListTableBarcodeCellContent, type ListTableBarcodeFormat, type ListTableButtonCellContent, type ListTableButtonPopconfirmOptions, type ListTableButtonSize, type ListTableButtonType, type ListTableCarouselScrollOptions, type ListTableCellContent, type ListTableCellContentClickContext, type ListTableCellEditorSession, type ListTableCellSpan, type ListTableCellStyle, type ListTableChartCellContent, type ListTableChartSize, type ListTableChartType, type ListTableColorCellContent, type ListTableColumn, type ListTableContextMenuFeature, type ListTableContextMenuOptions, type ListTableCustomChartCellContent, type ListTableDangerConfirmRequest, type ListTableDataFormat, type ListTableDataFormatOptions, type ListTableDataFormatType, type ListTableDebugOptions, type ListTableDebugSnapshot, type ListTableDensity, type ListTableEditAutoCompleteEnter, type ListTableEditFilterOption, type ListTableEditOption, type ListTableEditValueType, type ListTableEditable, type ListTableEditorAutoCompleteEnter, type ListTableEditorConfig, type ListTableEditorFactory, type ListTableEditorFilterOption, type ListTableEditorNavigateDirection, type ListTableEditorOption, type ListTableEditorRect, type ListTableEditorRequest, type ListTableEditorTheme, type ListTableEditorValueType, type ListTableExportXlsxOptions, type ListTableFilterCondition$1 as ListTableFilterCondition, type ListTableFilterConditionOperator, type ListTableFilterConditionRelation, type ListTableFilterMatchMode, type ListTableFilterOption, type ListTableFilterOptionValue, type ListTableFilterPanelAdapter, type ListTableFilterState, type ListTableFilterType, type ListTableFilterValue$1 as ListTableFilterValue, type ListTableFixedPopupAdapter, type ListTableFormItemProps, type ListTableFormItemPropsConfig, type ListTableFormRule, type ListTableFormRules, type ListTableGroupingOptions, type ListTableHeaderContextMenuAdapter, type ListTableHighlightMode, type ListTableHorizontalAlign, type ListTableIconCellContent, type ListTableImageCellContent, type ListTableImageObjectFit, type ListTableImagePreviewRequest, type ListTableLoadingAdapter, type ListTableLoadingRequest, type ListTableMergeCellOptions, type ListTableNestedTableCellContent, type ListTableNestedTableColumn, type ListTableOptions, type ListTablePaginationAdapter, type ListTablePaginationOptions, type ListTablePerformanceMetric, type ListTableProgressCellContent, type ListTableProgressShape, type ListTableProgressSize, type ListTableQrCodeCellContent, type ListTableQrCodeLevel, type ListTableQueryChange, type ListTableQueryChangeExtra, type ListTableQueryFilters, type ListTableQueryOptions, type ListTableQueryPagination, type ListTableQuerySorter, type ListTableRateCellContent, type ListTableRateSize, type ListTableRateSymbolType, type ListTableRowDragMode, type ListTableRowDragOptions, type ListTableRowDragPayload, type ListTableRowDragSourceInfo, type ListTableRowDragZone, type ListTableRowEventProps, type ListTableRowSelectionChangeInfo, type ListTableRowSelectionOptions, type ListTableRowSelectorOptions, type ListTableScrollToOptions, type ListTableScrollbarOptions, type ListTableSearchRequest, type ListTableSelectionState, type ListTableSortItem, type ListTableSortState, type ListTableSparklineChartCellContent, type ListTableSparklineSize, type ListTableSummaryConfig, type ListTableSummaryRoundingMode, type ListTableSummaryType, type ListTableSymbolType, type ListTableTagCellContent, type ListTableTheme, type ListTableTooltipAdapter, type ListTableTooltipRequest, type ListTableUiOptions, type ListTableValidationError, type ListTableValidationErrorField, type ListTableValidationFailure, type ListTableValidationTarget, type PaginationConfig, type RenderCellDescriptor, resetListTableStoredColumnConfig };
package/dist/index.js CHANGED
@@ -664,6 +664,40 @@ function cloneColumns(columns) {
664
664
  children: column.children ? cloneColumns(column.children) : void 0
665
665
  }));
666
666
  }
667
+ function preserveRuntimeColumnWidths(params) {
668
+ const runtimeByKey = collectColumnsByKey(params.runtimeColumns);
669
+ const initialByKey = collectColumnsByKey(params.initialColumns);
670
+ let changed = false;
671
+ const visit = (columns) => {
672
+ columns.forEach((column) => {
673
+ const key = resolveColumnKey(column);
674
+ const runtimeColumn = runtimeByKey.get(key);
675
+ const initialColumn = initialByKey.get(key);
676
+ if (runtimeColumn && initialColumn && column.width === initialColumn.width && runtimeColumn.width !== initialColumn.width) {
677
+ column.width = runtimeColumn.width;
678
+ changed = true;
679
+ }
680
+ if (column.children?.length) {
681
+ visit(column.children);
682
+ }
683
+ });
684
+ };
685
+ visit(params.nextColumns);
686
+ return changed;
687
+ }
688
+ function collectColumnsByKey(columns) {
689
+ const result = /* @__PURE__ */ new Map();
690
+ const visit = (items) => {
691
+ items.forEach((column) => {
692
+ result.set(resolveColumnKey(column), column);
693
+ if (column.children?.length) {
694
+ visit(column.children);
695
+ }
696
+ });
697
+ };
698
+ visit(columns);
699
+ return result;
700
+ }
667
701
  function applyInitialColumnVisibility(columns) {
668
702
  columns.forEach((column) => {
669
703
  if (column.hidden === void 0 && column.initialHide) {
@@ -1782,11 +1816,20 @@ function clampPageNumber(page, totalPages) {
1782
1816
  }
1783
1817
  var maximumTreeDepthCache = /* @__PURE__ */ new WeakMap();
1784
1818
  var sourceRowIndexCache = /* @__PURE__ */ new WeakMap();
1819
+ var selectedRowKeySetCache = /* @__PURE__ */ new WeakMap();
1785
1820
  var headerSelectionStateCache = /* @__PURE__ */ new WeakMap();
1786
1821
  var ROW_SELECTION_COLUMN_KEY = "__row_selection__";
1787
1822
  var ROW_SELECTOR_COLUMN_KEY = "__row_selector__";
1788
1823
  var EXPAND_COLUMN_KEY = "__row_expand__";
1789
1824
  var DEFAULT_ROW_SELECTOR_WIDTH = DEFAULT_SCROLLBAR_THICKNESS;
1825
+ function getSelectedRowKeySet(selectedRowKeys) {
1826
+ let cached = selectedRowKeySetCache.get(selectedRowKeys);
1827
+ if (!cached) {
1828
+ cached = new Set(selectedRowKeys);
1829
+ selectedRowKeySetCache.set(selectedRowKeys, cached);
1830
+ }
1831
+ return cached;
1832
+ }
1790
1833
  function getInitialSelectedRowKeys(options) {
1791
1834
  const rowSelection = options.rowSelection;
1792
1835
  if (!rowSelection) {
@@ -1849,6 +1892,7 @@ function createRowSelectionColumn(params) {
1849
1892
  const { options, selectedRowKeys } = params;
1850
1893
  const rowSelection = options.rowSelection;
1851
1894
  const type = rowSelection?.type === "radio" ? "radio" : "checkbox";
1895
+ const selectedRowKeySet = getSelectedRowKeySet(selectedRowKeys);
1852
1896
  const selectionColumn = {
1853
1897
  key: ROW_SELECTION_COLUMN_KEY,
1854
1898
  dataIndex: ROW_SELECTION_COLUMN_KEY,
@@ -1865,7 +1909,7 @@ function createRowSelectionColumn(params) {
1865
1909
  const rowKey = getRowKey(options, record, rowIndex);
1866
1910
  return {
1867
1911
  type,
1868
- checked: selectedRowKeys.includes(rowKey),
1912
+ checked: selectedRowKeySet.has(rowKey),
1869
1913
  disabled: isRowSelectionDisabled(rowSelection, record)
1870
1914
  };
1871
1915
  },
@@ -1984,40 +2028,39 @@ function getResolvedColumns(options, selectedRowKeys) {
1984
2028
  return rowSelectorColumn ? [rowSelectorColumn, ...resolvedColumns] : resolvedColumns;
1985
2029
  }
1986
2030
  function getSelectedRows(options, selectedRowKeys) {
2031
+ const selectedRowKeySet = getSelectedRowKeySet(selectedRowKeys);
1987
2032
  return options.dataSource.filter(
1988
- (record, index) => selectedRowKeys.includes(getRowKey(options, record, index))
2033
+ (record, index) => selectedRowKeySet.has(getRowKey(options, record, index))
1989
2034
  );
1990
2035
  }
1991
- function getVisibleSelectableRows(params) {
1992
- const { rowSelection, displayData } = params;
1993
- return displayData.filter((record) => !isRowSelectionDisabled(rowSelection, record));
1994
- }
1995
2036
  function getHeaderSelectionState(params) {
1996
- const { options, selectedRowKeys, displayData } = params;
1997
- const cached = headerSelectionStateCache.get(displayData);
2037
+ const { options, selectedRowKeys } = params;
2038
+ const selectableData = options.dataSource;
2039
+ const cached = headerSelectionStateCache.get(selectableData);
1998
2040
  if (cached && cached.options === options && cached.selectedRowKeys === selectedRowKeys) {
1999
2041
  return cached.state;
2000
2042
  }
2001
2043
  const rowSelection = options.rowSelection;
2002
- const visibleRows = getVisibleSelectableRows({
2003
- rowSelection,
2004
- displayData
2005
- });
2006
- const selectedKeySet = new Set(selectedRowKeys);
2007
- let selectedVisibleCount = 0;
2008
- visibleRows.forEach((record, index) => {
2044
+ const selectedKeySet = getSelectedRowKeySet(selectedRowKeys);
2045
+ let selectableCount = 0;
2046
+ let selectedCount = 0;
2047
+ selectableData.forEach((record, index) => {
2048
+ if (isRowSelectionDisabled(rowSelection, record)) {
2049
+ return;
2050
+ }
2051
+ selectableCount += 1;
2009
2052
  if (selectedKeySet.has(getRowKey(options, record, index))) {
2010
- selectedVisibleCount += 1;
2053
+ selectedCount += 1;
2011
2054
  }
2012
2055
  });
2013
2056
  const type = rowSelection?.type === "radio" ? "radio" : "checkbox";
2014
2057
  const state = {
2015
2058
  type,
2016
- checked: visibleRows.length > 0 && selectedVisibleCount === visibleRows.length,
2017
- indeterminate: selectedVisibleCount > 0 && selectedVisibleCount < visibleRows.length,
2018
- disabled: visibleRows.length === 0
2059
+ checked: selectableCount > 0 && selectedCount === selectableCount,
2060
+ indeterminate: selectedCount > 0 && selectedCount < selectableCount,
2061
+ disabled: selectableCount === 0
2019
2062
  };
2020
- headerSelectionStateCache.set(displayData, {
2063
+ headerSelectionStateCache.set(selectableData, {
2021
2064
  options,
2022
2065
  selectedRowKeys,
2023
2066
  state
@@ -2040,24 +2083,31 @@ function resolveToggledRowSelectionKeys(params) {
2040
2083
  };
2041
2084
  }
2042
2085
  function resolveToggleAllVisibleRowKeys(params) {
2043
- const { options, selectedRowKeys, displayData } = params;
2086
+ const { options, selectedRowKeys } = params;
2044
2087
  const rowSelection = options.rowSelection;
2045
2088
  if (!rowSelection || rowSelection.type === "radio") {
2046
2089
  return null;
2047
2090
  }
2048
- const visibleRows = getVisibleSelectableRows({
2049
- rowSelection,
2050
- displayData
2051
- });
2052
- const visibleKeys = visibleRows.map(
2053
- (record, index) => getRowKey(options, record, index)
2054
- );
2055
- const headerState = getHeaderSelectionState({
2056
- options,
2057
- selectedRowKeys,
2058
- displayData
2091
+ const selectedKeySet = getSelectedRowKeySet(selectedRowKeys);
2092
+ const selectableKeys = [];
2093
+ let allSelected = true;
2094
+ options.dataSource.forEach((record, index) => {
2095
+ if (isRowSelectionDisabled(rowSelection, record)) {
2096
+ return;
2097
+ }
2098
+ const key = getRowKey(options, record, index);
2099
+ selectableKeys.push(key);
2100
+ if (!selectedKeySet.has(key)) {
2101
+ allSelected = false;
2102
+ }
2059
2103
  });
2060
- return headerState.checked ? selectedRowKeys.filter((key) => !visibleKeys.includes(key)) : Array.from(/* @__PURE__ */ new Set([...selectedRowKeys, ...visibleKeys]));
2104
+ if (allSelected && selectableKeys.length > 0) {
2105
+ const selectableKeySet = new Set(selectableKeys);
2106
+ return selectedRowKeys.filter((key) => !selectableKeySet.has(key));
2107
+ }
2108
+ const nextKeySet = new Set(selectedRowKeys);
2109
+ selectableKeys.forEach((key) => nextKeySet.add(key));
2110
+ return Array.from(nextKeySet);
2061
2111
  }
2062
2112
 
2063
2113
  // src/engine/store/state.ts
@@ -13590,7 +13640,7 @@ async function getBaseDisplayRowsAsync(params) {
13590
13640
  }
13591
13641
  function getDisplayRows(params) {
13592
13642
  const rows = getBaseDisplayRows(params);
13593
- if (!params.options.pagination || params.options.query?.mode === "remote") {
13643
+ if (!params.options.pagination || isRemotePaginationResult(params.options)) {
13594
13644
  return rows;
13595
13645
  }
13596
13646
  return sliceDisplayRowsByPagination({
@@ -13600,7 +13650,7 @@ function getDisplayRows(params) {
13600
13650
  });
13601
13651
  }
13602
13652
  function sliceDisplayRowsFromBaseRows(params) {
13603
- if (!params.options.pagination || params.options.query?.mode === "remote") {
13653
+ if (!params.options.pagination || isRemotePaginationResult(params.options)) {
13604
13654
  return params.rows;
13605
13655
  }
13606
13656
  return sliceDisplayRowsByPagination({
@@ -13609,6 +13659,13 @@ function sliceDisplayRowsFromBaseRows(params) {
13609
13659
  state: params.query.pagination
13610
13660
  });
13611
13661
  }
13662
+ function isRemotePaginationResult(options) {
13663
+ if (options.query?.mode === "remote") {
13664
+ return true;
13665
+ }
13666
+ const total = options.pagination && options.pagination.total;
13667
+ return typeof total === "number" && Number.isFinite(total) && total > options.dataSource.length;
13668
+ }
13612
13669
  function emitListTableQueryChange(params) {
13613
13670
  const {
13614
13671
  options,
@@ -15136,6 +15193,7 @@ var TEXT_SELECTION_DRAG_THRESHOLD = 5;
15136
15193
  var TEXT_SELECTION_AUTO_SCROLL_EDGE_SIZE = 36;
15137
15194
  var TEXT_SELECTION_AUTO_SCROLL_MAX_VERTICAL_SPEED = 1200;
15138
15195
  var TEXT_SELECTION_AUTO_SCROLL_MAX_HORIZONTAL_SPEED = 900;
15196
+ var EDITABLE_CELL_ROW_SELECTION_DELAY = 300;
15139
15197
  var ListTableEventController = class {
15140
15198
  constructor(host) {
15141
15199
  __publicField(this, "searchKeyword", "");
@@ -15157,6 +15215,7 @@ var ListTableEventController = class {
15157
15215
  __publicField(this, "cellSelectionAutoScrollVelocity", { x: 0, y: 0 });
15158
15216
  __publicField(this, "cellSelectionAutoScrollTargetVelocity", { x: 0, y: 0 });
15159
15217
  __publicField(this, "continuousScrollTimer", null);
15218
+ __publicField(this, "pendingEditableCellRowSelectionTimer", null);
15160
15219
  __publicField(this, "outsideClickDocument", null);
15161
15220
  __publicField(this, "outsideClickStarted", null);
15162
15221
  __publicField(this, "host");
@@ -15558,6 +15617,7 @@ var ListTableEventController = class {
15558
15617
  );
15559
15618
  });
15560
15619
  __publicField(this, "handleDoubleClick", (event) => {
15620
+ this.cancelPendingEditableCellRowSelection();
15561
15621
  if (!this.host.canvasElement) {
15562
15622
  return;
15563
15623
  }
@@ -16087,7 +16147,24 @@ var ListTableEventController = class {
16087
16147
  if ((result.area === "body" || result.area === "body-content") && typeof result.rowIndex === "number" && this.host.options.rowSelection?.selectRowByClick && result.columnKey && !isSystemColumnKey(result.columnKey)) {
16088
16148
  const record = this.host.getDisplayData()[result.rowIndex];
16089
16149
  if (record !== void 0) {
16090
- this.host.toggleRowSelection(record, result.rowIndex);
16150
+ const column = this.host.leafColumns.find(
16151
+ (item) => item.key === result.columnKey
16152
+ );
16153
+ const value = column?.dataIndex != null ? getValueByDataIndex(record, column.dataIndex) : void 0;
16154
+ const canOpenEditorByDoubleClick = shouldOpenCellEditorOnClick(
16155
+ column,
16156
+ 2,
16157
+ {
16158
+ value,
16159
+ record,
16160
+ rowIndex: result.rowIndex
16161
+ }
16162
+ );
16163
+ if (canOpenEditorByDoubleClick && event.detail === 1) {
16164
+ this.scheduleEditableCellRowSelection(record, result.rowIndex);
16165
+ } else if (!canOpenEditorByDoubleClick || event.detail !== 2) {
16166
+ this.host.toggleRowSelection(record, result.rowIndex);
16167
+ }
16091
16168
  }
16092
16169
  }
16093
16170
  if (result.area === "body" && typeof result.rowIndex === "number" && this.host.options.expandable?.expandRowByClick && result.columnKey && !isSystemColumnKey(result.columnKey) && this.host.toggleRowExpand(result.rowIndex)) {
@@ -16561,6 +16638,7 @@ var ListTableEventController = class {
16561
16638
  this.host.render();
16562
16639
  }
16563
16640
  destroy() {
16641
+ this.cancelPendingEditableCellRowSelection();
16564
16642
  this.stopContinuousScroll();
16565
16643
  this.stopTextSelectionAutoScroll();
16566
16644
  this.stopCellSelectionAutoScroll();
@@ -16625,6 +16703,20 @@ var ListTableEventController = class {
16625
16703
  event.preventDefault();
16626
16704
  this.host.editingController.open(rowIndex, columnKey, event.key);
16627
16705
  }
16706
+ scheduleEditableCellRowSelection(record, rowIndex) {
16707
+ this.cancelPendingEditableCellRowSelection();
16708
+ this.pendingEditableCellRowSelectionTimer = globalThis.setTimeout(() => {
16709
+ this.pendingEditableCellRowSelectionTimer = null;
16710
+ this.host.toggleRowSelection(record, rowIndex);
16711
+ }, EDITABLE_CELL_ROW_SELECTION_DELAY);
16712
+ }
16713
+ cancelPendingEditableCellRowSelection() {
16714
+ if (this.pendingEditableCellRowSelectionTimer == null) {
16715
+ return;
16716
+ }
16717
+ globalThis.clearTimeout(this.pendingEditableCellRowSelectionTimer);
16718
+ this.pendingEditableCellRowSelectionTimer = null;
16719
+ }
16628
16720
  async autoFitColumnWidths(columnKey) {
16629
16721
  const ctx = this.host.canvasElement?.getContext("2d");
16630
16722
  if (!ctx) {
@@ -18363,6 +18455,47 @@ function persistListTableColumnConfig(params) {
18363
18455
  )
18364
18456
  );
18365
18457
  }
18458
+ async function resetListTableStoredColumnConfig(params) {
18459
+ const { storageKey, columns } = params;
18460
+ if (!storageKey) {
18461
+ return;
18462
+ }
18463
+ const initialColumnTree = columns.map(cloneColumnTree);
18464
+ ensureColumnKeysInPlace(initialColumnTree);
18465
+ const stored = await getColumnConfig(storageKey);
18466
+ if (!stored) {
18467
+ return;
18468
+ }
18469
+ const initialColumns = buildStoredColumnConfig(
18470
+ initialColumnTree,
18471
+ { key: null, order: null },
18472
+ {}
18473
+ ).columns;
18474
+ const nextColumns = {};
18475
+ Object.entries(initialColumns).forEach(([key, initial]) => {
18476
+ const next = {
18477
+ ...stored.columns[key] ?? initial,
18478
+ width: initial.width,
18479
+ hidden: initial.hidden
18480
+ };
18481
+ if (initial.fixed) {
18482
+ next.fixed = initial.fixed;
18483
+ } else {
18484
+ delete next.fixed;
18485
+ }
18486
+ nextColumns[key] = next;
18487
+ });
18488
+ await saveColumnConfig(storageKey, {
18489
+ ...stored,
18490
+ columns: nextColumns
18491
+ });
18492
+ }
18493
+ function cloneColumnTree(column) {
18494
+ return {
18495
+ ...column,
18496
+ children: column.children?.map(cloneColumnTree)
18497
+ };
18498
+ }
18366
18499
  async function loadListTableStoredConfig(params) {
18367
18500
  const { storageKey, columns } = params;
18368
18501
  if (!storageKey) {
@@ -21188,13 +21321,14 @@ function syncListTablePagination(params) {
21188
21321
  scrollPageSize
21189
21322
  },
21190
21323
  onChange: (page, nextPageSize) => {
21191
- store.dispatch(setPaginationAction(updatePaginationState(
21192
- store.getSnapshot().query.pagination,
21193
- {
21194
- currentPage: page,
21195
- pageSize: nextPageSize
21196
- }
21197
- )));
21324
+ store.dispatch(
21325
+ setPaginationAction(
21326
+ updatePaginationState(store.getSnapshot().query.pagination, {
21327
+ currentPage: page,
21328
+ pageSize: nextPageSize
21329
+ })
21330
+ )
21331
+ );
21198
21332
  if (options.pagination) {
21199
21333
  options.pagination.onChange?.(page, nextPageSize);
21200
21334
  }
@@ -21205,15 +21339,17 @@ function syncListTablePagination(params) {
21205
21339
  }
21206
21340
  },
21207
21341
  onPageSizeChange: (page, nextPageSize) => {
21208
- store.dispatch(setPaginationAction(updatePaginationState(
21209
- store.getSnapshot().query.pagination,
21210
- {
21211
- currentPage: page,
21212
- pageSize: nextPageSize
21213
- }
21214
- )));
21342
+ store.dispatch(
21343
+ setPaginationAction(
21344
+ updatePaginationState(store.getSnapshot().query.pagination, {
21345
+ currentPage: page,
21346
+ pageSize: nextPageSize
21347
+ })
21348
+ )
21349
+ );
21215
21350
  if (options.pagination) {
21216
21351
  options.pagination.onShowSizeChange?.(page, nextPageSize);
21352
+ options.pagination.onChange?.(page, nextPageSize);
21217
21353
  }
21218
21354
  if (options.query?.onChange) {
21219
21355
  emitQueryChange("paginate");
@@ -23961,9 +24097,7 @@ function drawListTableHeader(params) {
23961
24097
  columnKey: ROW_SELECTION_COLUMN_KEY,
23962
24098
  ...getHeaderSelectionState({
23963
24099
  options,
23964
- selectedRowKeys,
23965
- displayData
23966
- })
24100
+ selectedRowKeys})
23967
24101
  } : null,
23968
24102
  inlineContentInset,
23969
24103
  collapsedColumnMarkers,
@@ -27023,6 +27157,19 @@ var ListTableCore = class {
27023
27157
  */
27024
27158
  updateOptions(options) {
27025
27159
  this.animationController.stopCarouselScroll();
27160
+ const host = this.asAssemblyHost();
27161
+ const incomingColumnsAreRuntimeColumns = options.columns === this.options.columns;
27162
+ const nextInitialColumns = incomingColumnsAreRuntimeColumns ? cloneColumns(host.initialColumns) : cloneColumns(options.columns);
27163
+ const nextInitialStretchColumns = incomingColumnsAreRuntimeColumns ? host.initialStretchColumns : options.stretchColumns;
27164
+ const shouldPreserveRuntimeWidths = this.options.stretchColumns === false && options.stretchColumns === host.initialStretchColumns;
27165
+ if (shouldPreserveRuntimeWidths) {
27166
+ preserveRuntimeColumnWidths({
27167
+ nextColumns: options.columns,
27168
+ runtimeColumns: this.options.columns,
27169
+ initialColumns: host.initialColumns
27170
+ });
27171
+ options.stretchColumns = false;
27172
+ }
27026
27173
  applyInitialColumnVisibility(options.columns);
27027
27174
  ensureColumnKeysInPlace(options.columns);
27028
27175
  if (options.expandable?.expandedRowKeys !== void 0 && !areSameRowKeySet(
@@ -27038,10 +27185,9 @@ var ListTableCore = class {
27038
27185
  this.queryController.reset();
27039
27186
  this.summaryController.reset();
27040
27187
  this.options = options;
27041
- const host = this.asAssemblyHost();
27042
27188
  host.syncGroupingFromOptions();
27043
- host.initialColumns = cloneColumns(options.columns);
27044
- host.initialStretchColumns = options.stretchColumns;
27189
+ host.initialColumns = nextInitialColumns;
27190
+ host.initialStretchColumns = nextInitialStretchColumns;
27045
27191
  this.store.dispatch(
27046
27192
  replaceStateAction(
27047
27193
  resolveListTableStateOnOptionsUpdate(options, this.store.getSnapshot())
@@ -27244,6 +27390,6 @@ var ListTable = class {
27244
27390
  }
27245
27391
  };
27246
27392
 
27247
- export { ListTable };
27393
+ export { ListTable, resetListTableStoredColumnConfig };
27248
27394
  //# sourceMappingURL=index.js.map
27249
27395
  //# sourceMappingURL=index.js.map