@fibrae/semi-foundation 0.1.1 → 0.3.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/anchor/foundation.d.ts +1 -4
- package/dist/anchor/foundation.js +21 -22
- package/dist/audio-player/foundation.d.ts +10 -13
- package/dist/audio-player/foundation.js +19 -20
- package/dist/auto-complete/foundation.d.ts +12 -14
- package/dist/auto-complete/foundation.js +51 -52
- package/dist/avatar/foundation.d.ts +5 -6
- package/dist/avatar/foundation.js +16 -16
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +2 -5
- package/dist/backtop/foundation.js +7 -8
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -9
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -4
- package/dist/base/foundation.js +12 -11
- package/dist/base/list-store.d.ts +0 -1
- package/dist/breadcrumb/foundation.d.ts +5 -5
- package/dist/breadcrumb/foundation.js +9 -10
- package/dist/breadcrumb/item-foundation.d.ts +3 -3
- package/dist/breadcrumb/item-foundation.js +6 -6
- package/dist/calendar/event-util.d.ts +0 -10
- package/dist/calendar/event-util.js +1 -11
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +5 -9
- package/dist/calendar/month-foundation.d.ts +2 -3
- package/dist/calendar/month-foundation.js +6 -7
- package/dist/carousel/foundation.d.ts +17 -19
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +36 -32
- package/dist/cascader/foundation.js +145 -132
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +3 -7
- package/dist/checkbox/checkbox-foundation.js +15 -17
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -3
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -2
- package/dist/code-highlight/index.js +3 -3
- package/dist/collapse/foundation.d.ts +2 -2
- package/dist/collapse/foundation.js +7 -7
- package/dist/collapsible/foundation.d.ts +3 -3
- package/dist/collapsible/foundation.js +8 -8
- package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
- package/dist/color-picker/alpha-slider-foundation.js +10 -10
- package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
- package/dist/color-picker/color-choose-area-foundation.js +14 -14
- package/dist/color-picker/color-picker.scss +0 -2
- package/dist/color-picker/color-slider-foundation.d.ts +2 -4
- package/dist/color-picker/color-slider-foundation.js +10 -10
- package/dist/color-picker/data-part-foundation.d.ts +5 -5
- package/dist/color-picker/data-part-foundation.js +11 -11
- package/dist/color-picker/foundation.d.ts +4 -4
- package/dist/color-picker/foundation.js +10 -10
- package/dist/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +15 -16
- package/dist/cropper/foundation.js +26 -24
- package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
- package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
- package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
- package/dist/date-picker/_utils/parser.d.ts +0 -3
- package/dist/date-picker/_utils/parser.js +0 -7
- package/dist/date-picker/_utils/picker-type.d.ts +1 -3
- package/dist/date-picker/_utils/picker-type.js +0 -2
- package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
- package/dist/date-picker/_utils/to-callback-args.js +0 -1
- package/dist/date-picker/date-picker.scss +0 -3
- package/dist/date-picker/foundation.d.ts +39 -58
- package/dist/date-picker/foundation.js +126 -153
- package/dist/date-picker/input-foundation.d.ts +10 -16
- package/dist/date-picker/input-foundation.js +28 -30
- package/dist/date-picker/month-foundation.d.ts +0 -3
- package/dist/date-picker/month-foundation.js +0 -2
- package/dist/date-picker/months-grid-foundation.d.ts +17 -26
- package/dist/date-picker/months-grid-foundation.js +65 -75
- package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
- package/dist/date-picker/year-and-month-foundation.js +11 -11
- package/dist/drag-move/foundation.d.ts +2 -3
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -7
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -2
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -10
- package/dist/feedback/foundation.js +33 -33
- package/dist/feedback/variables.scss +1 -5
- package/dist/float-button/float-button.css +0 -1
- package/dist/float-button/float-button.scss +0 -2
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -76
- package/dist/form/interface.d.ts +2 -15
- package/dist/form/utils.d.ts +0 -8
- package/dist/form/utils.js +0 -7
- package/dist/form/variables.scss +1 -4
- package/dist/grid/variables.scss +0 -10
- package/dist/highlight/foundation.d.ts +0 -2
- package/dist/highlight/foundation.js +1 -3
- package/dist/hot-keys/foundation.d.ts +2 -3
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -6
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -4
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -9
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -10
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -11
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -5
- package/dist/input/text-entry-foundation.js +14 -15
- package/dist/input/textarea-foundation.d.ts +7 -8
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +16 -19
- package/dist/input-number/foundation.js +54 -58
- package/dist/json-viewer/foundation.d.ts +8 -10
- package/dist/json-viewer/foundation.js +23 -24
- package/dist/locale/interface.d.ts +0 -3
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +2 -7
- package/dist/markdown-render/foundation.js +5 -9
- package/dist/modal/modal-content-foundation.d.ts +7 -7
- package/dist/modal/modal-content-foundation.js +20 -20
- package/dist/modal/modal-foundation.d.ts +6 -6
- package/dist/modal/modal-foundation.js +24 -24
- package/dist/navigation/foundation.d.ts +1 -8
- package/dist/navigation/foundation.js +14 -20
- package/dist/navigation/item-foundation.d.ts +1 -1
- package/dist/navigation/item-foundation.js +8 -8
- package/dist/navigation/sub-nav-foundation.d.ts +3 -4
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -8
- package/dist/notification/notification-list-foundation.js +12 -13
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +4 -6
- package/dist/overflow-list/foundation.js +18 -19
- package/dist/pagination/foundation.d.ts +8 -10
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +6 -9
- package/dist/pincode/foundation.js +23 -26
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -9
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/progress/generates.d.ts +1 -4
- package/dist/progress/generates.js +1 -4
- package/dist/progress/utils.d.ts +1 -1
- package/dist/progress/utils.js +1 -1
- package/dist/radio/radio-foundation.d.ts +5 -9
- package/dist/radio/radio-foundation.js +15 -16
- package/dist/radio/radio-group-foundation.d.ts +2 -3
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -15
- package/dist/rating/foundation.js +35 -38
- package/dist/resizable/group/index.d.ts +6 -10
- package/dist/resizable/group/index.js +40 -44
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +3 -7
- package/dist/resizable/single/index.js +10 -13
- package/dist/scroll-list/item-foundation.d.ts +7 -9
- package/dist/scroll-list/item-foundation.js +35 -36
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +42 -57
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -28
- package/dist/select/option-foundation.js +10 -19
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +7 -12
- package/dist/side-sheet/side-sheet-foundation.js +23 -27
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +17 -28
- package/dist/slider/foundation.js +47 -59
- package/dist/slider/variables.scss +1 -5
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -4
- package/dist/spin/foundation.js +6 -7
- package/dist/spin/variables.scss +1 -3
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -3
- package/dist/switch/foundation.js +7 -7
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +24 -33
- package/dist/table/foundation.js +144 -108
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +2 -10
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +5 -14
- package/dist/tabs/foundation.js +17 -21
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +11 -13
- package/dist/tag-input/foundation.js +52 -53
- package/dist/tag-input/tag-input.scss +0 -1
- package/dist/tag-input/utils/tag-focus.d.ts +0 -1
- package/dist/tag-input/utils/tag-focus.js +0 -1
- package/dist/time-picker/combox-foundation.d.ts +3 -11
- package/dist/time-picker/combox-foundation.js +3 -10
- package/dist/time-picker/foundation.d.ts +13 -23
- package/dist/time-picker/foundation.js +39 -48
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/adjust-position.d.ts +1 -2
- package/dist/tooltip/constants.d.ts +0 -3
- package/dist/tooltip/constants.js +0 -3
- package/dist/tooltip/foundation.d.ts +9 -12
- package/dist/tooltip/foundation.js +67 -63
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +22 -13
- package/dist/transfer/foundation.js +38 -24
- package/dist/tree/foundation.d.ts +14 -16
- package/dist/tree/foundation.js +61 -62
- package/dist/tree/shared.d.ts +2 -4
- package/dist/tree/shared.js +0 -2
- package/dist/tree/tree-util.d.ts +0 -5
- package/dist/tree/tree-util.js +0 -5
- package/dist/tree-select/foundation.d.ts +26 -22
- package/dist/tree-select/foundation.js +91 -86
- package/dist/typography/ellipsis.d.ts +5 -7
- package/dist/typography/ellipsis.js +8 -10
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -23
- package/dist/upload/foundation.js +93 -103
- package/dist/upload/utils.d.ts +3 -8
- package/dist/upload/utils.js +6 -11
- package/dist/user-guide/foundation.d.ts +3 -5
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +2 -6
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/array.d.ts +0 -6
- package/dist/utils/array.js +0 -6
- package/dist/utils/date-fns-extra.js +1 -5
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/dom.js +0 -1
- package/dist/utils/escape-html.js +0 -3
- package/dist/utils/field-sizing.d.ts +0 -2
- package/dist/utils/field-sizing.js +0 -2
- package/dist/utils/focus-handle.d.ts +1 -2
- package/dist/utils/focus-handle.js +1 -3
- package/dist/utils/focus-scope.d.ts +5 -6
- package/dist/utils/focus-scope.js +10 -11
- package/dist/utils/is-promise.d.ts +1 -1
- package/dist/utils/release-holder.d.ts +2 -2
- package/dist/utils/release-holder.js +4 -4
- package/dist/utils/scroll-lock.d.ts +3 -4
- package/dist/utils/scroll-lock.js +3 -4
- package/dist/utils/tween.d.ts +0 -1
- package/dist/utils/tween.js +0 -1
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -1
- package/dist/utils/warning.d.ts +0 -1
- package/dist/utils/warning.js +0 -1
- package/dist/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -3
- package/dist/video-player/progress-foundation.js +12 -13
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
package/dist/table/foundation.js
CHANGED
|
@@ -4,13 +4,17 @@ import isObject from "../utils/is-object.js";
|
|
|
4
4
|
import { calcCheckedKeysForChecked, calcCheckedKeysForCheckedKeys, calcCheckedKeysForUnchecked, convertDataToEntities } from "../tree/tree-util.js";
|
|
5
5
|
import { numbers, strings } from "./constants.js";
|
|
6
6
|
import { differenceUnique, withOrderSort } from "../utils/array.js";
|
|
7
|
-
import { getChangedRowKeys, mergeColumns } from "./utils.js";
|
|
7
|
+
import { buildRecordsByKey, flattenBodyRows, getChangedRowKeys, mergeColumns } from "./utils.js";
|
|
8
8
|
import { merge, pick } from "es-toolkit";
|
|
9
9
|
import { get } from "es-toolkit/compat";
|
|
10
10
|
// src/table/foundation.ts
|
|
11
11
|
var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
12
12
|
#defaultKeysApplied = false;
|
|
13
13
|
#trackScrollEdges;
|
|
14
|
+
#rangeAnchor = null;
|
|
15
|
+
#rangeBase = null;
|
|
16
|
+
#rangeResult = null;
|
|
17
|
+
#spaceShiftKey = false;
|
|
14
18
|
static #pagerIsControlled(props) {
|
|
15
19
|
return props.pagination?.currentPage != null;
|
|
16
20
|
}
|
|
@@ -18,7 +22,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
18
22
|
const knownMap = new Map(known.map((key) => [String(key), key]));
|
|
19
23
|
return [...keys].map((key) => keyEntities?.[key]?.data?.rowKey ?? knownMap.get(key) ?? key);
|
|
20
24
|
}
|
|
21
|
-
/** The checked and half-checked keys that `rowKeys` imply in a related tree selection, as the rowKey values of the data */
|
|
22
25
|
static #getRelatedCheckedRowKeys(rowKeys = [], keyEntities = {}) {
|
|
23
26
|
const { checkedKeys, halfCheckedKeys } = calcCheckedKeysForCheckedKeys(rowKeys.map(String), keyEntities, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set());
|
|
24
27
|
return {
|
|
@@ -26,6 +29,9 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
26
29
|
halfCheckedRowKeys: TableFoundation.#restoreRowKeys(halfCheckedKeys, rowKeys, keyEntities)
|
|
27
30
|
};
|
|
28
31
|
}
|
|
32
|
+
static #sameKeys(a, b) {
|
|
33
|
+
return a.size === b.size && [...a].every((key) => b.has(key));
|
|
34
|
+
}
|
|
29
35
|
#addNoDuplicatedItemsToArr(srcArr = [], ...objArrs) {
|
|
30
36
|
for (const objArr of objArrs) if (Array.isArray(objArr)) {
|
|
31
37
|
for (const item of objArr) if (!srcArr.includes(item)) srcArr.push(item);
|
|
@@ -36,8 +42,8 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
36
42
|
pagination = pagination == null ? this.#getPagination() : pagination;
|
|
37
43
|
filters = filters == null ? this.#getAllFilters() : filters;
|
|
38
44
|
sorter = sorter == null ? this.#getAllSorters()[0] : sorter;
|
|
39
|
-
if (this.getProp("scroll")?.scrollToFirstRowOnChange) this.
|
|
40
|
-
this.
|
|
45
|
+
if (this.getProp("scroll")?.scrollToFirstRowOnChange) this.adapter.resetScrollY();
|
|
46
|
+
this.adapter.notifyChange({
|
|
41
47
|
pagination: { ...pagination },
|
|
42
48
|
filters: [...filters],
|
|
43
49
|
sorter,
|
|
@@ -65,6 +71,40 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
65
71
|
#getSelectedRowKeysSet() {
|
|
66
72
|
return this.getState("rowSelection")?.selectedRowKeysSet ?? /* @__PURE__ */ new Set();
|
|
67
73
|
}
|
|
74
|
+
#getVisibleRowKeys() {
|
|
75
|
+
const { rowKey, childrenRecordName } = this.getProps();
|
|
76
|
+
const dataSource = this.getState("dataSource");
|
|
77
|
+
const options = {
|
|
78
|
+
rowKey,
|
|
79
|
+
childrenRecordName,
|
|
80
|
+
expandedRowKeys: this.getState("expandedRowKeys"),
|
|
81
|
+
hasExpandedRow: false
|
|
82
|
+
};
|
|
83
|
+
return flattenBodyRows(options, dataSource, this.getState("groups"), buildRecordsByKey(dataSource, rowKey)).flatMap((row) => row.kind === "base" ? [row.key] : []);
|
|
84
|
+
}
|
|
85
|
+
/** Gives every enabled row from the anchor to `rowKey` the anchor's state; false when either row is not shown */
|
|
86
|
+
#selectRange(rowKey) {
|
|
87
|
+
const visibleRowKeys = this.#getVisibleRowKeys();
|
|
88
|
+
const anchorIndex = visibleRowKeys.indexOf(this.#rangeAnchor);
|
|
89
|
+
const index = visibleRowKeys.indexOf(rowKey);
|
|
90
|
+
if (anchorIndex === -1 || index === -1) return false;
|
|
91
|
+
const currentKeys = this.#getSelectedRowKeysSet();
|
|
92
|
+
if (!this.#rangeBase || !this.#rangeResult || !TableFoundation.#sameKeys(this.#rangeResult, currentKeys)) this.#rangeBase = new Set(this.#getSelectedRowKeys());
|
|
93
|
+
const selected = this.#rangeBase.has(this.#rangeAnchor);
|
|
94
|
+
const disabledRowKeys = this.adapter.getFilteredDisabledRowKeysSet();
|
|
95
|
+
const nextKeys = new Set(this.#rangeBase);
|
|
96
|
+
for (const key of visibleRowKeys.slice(Math.min(anchorIndex, index), Math.max(anchorIndex, index) + 1)) if (!disabledRowKeys.has(key)) {
|
|
97
|
+
if (selected) nextKeys.add(key);
|
|
98
|
+
else nextKeys.delete(key);
|
|
99
|
+
}
|
|
100
|
+
window.getSelection()?.removeAllRanges();
|
|
101
|
+
this.#rangeResult = nextKeys;
|
|
102
|
+
if (TableFoundation.#sameKeys(nextKeys, currentKeys)) return true;
|
|
103
|
+
const selectedRowKeys = [...nextKeys];
|
|
104
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
105
|
+
this.adapter.notifySelectionChange(selectedRowKeys, this.getRecordsByKeys(null, selectedRowKeys));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
68
108
|
#getDataSource() {
|
|
69
109
|
return this.getProp("dataSource") || [];
|
|
70
110
|
}
|
|
@@ -109,7 +149,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
109
149
|
return queries;
|
|
110
150
|
}
|
|
111
151
|
#getGroups() {
|
|
112
|
-
if (this.
|
|
152
|
+
if (this.adapter.getProp("groupBy") !== null) return this.adapter.getState("groups");
|
|
113
153
|
return null;
|
|
114
154
|
}
|
|
115
155
|
#initSelectedRowKeys(keyEntities) {
|
|
@@ -122,7 +162,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
122
162
|
if (controlled) this.#addNoDuplicatedItemsToArr(rowKeys, selectedRowKeys);
|
|
123
163
|
else if (Array.isArray(defaultSelectedRowKeys)) this.#addNoDuplicatedItemsToArr(rowKeys, defaultSelectedRowKeys);
|
|
124
164
|
let halfCheckedRowKeys = [];
|
|
125
|
-
if (this.
|
|
165
|
+
if (this.adapter.getCheckRelation() === "related") {
|
|
126
166
|
const related = TableFoundation.#getRelatedCheckedRowKeys(rowKeys, keyEntities);
|
|
127
167
|
halfCheckedRowKeys = related.halfCheckedRowKeys;
|
|
128
168
|
if (!controlled) {
|
|
@@ -130,24 +170,24 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
130
170
|
rowKeys = [...rowKeys, ...related.checkedRowKeys.filter((key) => !known.has(String(key)))];
|
|
131
171
|
}
|
|
132
172
|
}
|
|
133
|
-
this.
|
|
134
|
-
this.
|
|
173
|
+
this.adapter.setSelectedRowKeys(rowKeys);
|
|
174
|
+
this.adapter.setHalfCheckedRowKeys(halfCheckedRowKeys);
|
|
135
175
|
}
|
|
136
176
|
}
|
|
137
177
|
#setAdapterPageData({ pagination, dataSource, disabledRowKeys, allRowKeys, groups } = {}) {
|
|
138
|
-
this.
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
178
|
+
this.adapter.setPageDisabledRowKeys(disabledRowKeys);
|
|
179
|
+
this.adapter.setAllRowKeys(allRowKeys);
|
|
180
|
+
this.adapter.setPagination(pagination);
|
|
181
|
+
this.adapter.setGroups(groups);
|
|
182
|
+
this.adapter.setDataSource(dataSource);
|
|
143
183
|
}
|
|
144
184
|
#setCachedFilteredSortedDataSource(filteredSortedDataSource) {
|
|
145
|
-
this.
|
|
185
|
+
this.adapter.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
146
186
|
const filteredSortedRowKeys = this.getAllRowKeys(filteredSortedDataSource);
|
|
147
|
-
this.
|
|
187
|
+
this.adapter.setCachedFilteredSortedRowKeys(filteredSortedRowKeys);
|
|
148
188
|
}
|
|
149
189
|
#setFilteredDisabledRowKeys(disabledRowKeys) {
|
|
150
|
-
this.
|
|
190
|
+
this.adapter.setFilteredDisabledRowKeys(disabledRowKeys);
|
|
151
191
|
}
|
|
152
192
|
#applyQueries(queries) {
|
|
153
193
|
const dataSource = [...this.getProp("dataSource")];
|
|
@@ -158,11 +198,10 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
158
198
|
const pageData = this.getCurrentPageData(sortedDataSource);
|
|
159
199
|
this.#setAdapterPageData(pageData);
|
|
160
200
|
}
|
|
161
|
-
/** Rebuilds the tree of a related selection; the half-checked rows follow from it and the selected keys */
|
|
162
201
|
#updateKeyEntities() {
|
|
163
202
|
const keyEntities = this.buildKeyEntities(this.getProp("dataSource"));
|
|
164
|
-
this.
|
|
165
|
-
this.
|
|
203
|
+
this.adapter.setKeyEntities(keyEntities);
|
|
204
|
+
this.adapter.setHalfCheckedRowKeys(TableFoundation.#getRelatedCheckedRowKeys(this.#getSelectedRowKeys(), keyEntities).halfCheckedRowKeys);
|
|
166
205
|
}
|
|
167
206
|
/**
|
|
168
207
|
* @param dataSourceChanged the dataSource prop changed: the uncontrolled page goes back to 1
|
|
@@ -178,7 +217,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
178
217
|
this.#setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
179
218
|
this.#setFilteredDisabledRowKeys(allDataDisabledRowKeys);
|
|
180
219
|
states.dataSource = filteredSortedDataSource;
|
|
181
|
-
if (this.
|
|
220
|
+
if (this.adapter.getCheckRelation() === "related") this.#updateKeyEntities();
|
|
182
221
|
if (groupBy) states.groups = null;
|
|
183
222
|
}
|
|
184
223
|
if (dataSourceChanged) states.pagination = isObject(statePagination) ? {
|
|
@@ -187,15 +226,15 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
187
226
|
} : statePagination;
|
|
188
227
|
if (Object.keys(states).length) {
|
|
189
228
|
const pageData = this.getCurrentPageData(states.dataSource ?? null, states.pagination ?? (statePagination && { ...statePagination }), null);
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
229
|
+
this.adapter.setAllRowKeys(pageData.allRowKeys);
|
|
230
|
+
this.adapter.setPageDisabledRowKeys(pageData.disabledRowKeys);
|
|
192
231
|
if ("dataSource" in states) {
|
|
193
232
|
if (defaultExpandAllRows && dataSourceChanged && pageData.groups?.size && !this.#rowExpansionIsControlled() || expandAllRows || expandAllGroupRows) this.initExpandedRowKeys(pageData);
|
|
194
|
-
this.
|
|
233
|
+
this.adapter.setDataSource(pageData.dataSource);
|
|
195
234
|
states.pagination = pageData.pagination;
|
|
196
235
|
}
|
|
197
|
-
if ("groups" in states) this.
|
|
198
|
-
if ("pagination" in states) this.
|
|
236
|
+
if ("groups" in states) this.adapter.setGroups(pageData.groups);
|
|
237
|
+
if ("pagination" in states) this.adapter.setPagination(pageData.pagination);
|
|
199
238
|
}
|
|
200
239
|
}
|
|
201
240
|
getFilteredSortedDataSource(dataSource, queries) {
|
|
@@ -229,7 +268,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
229
268
|
return keyEntities;
|
|
230
269
|
}
|
|
231
270
|
calcCheckedKeysForSelect(realKey, selected, checkedKeys, halfCheckedKeys) {
|
|
232
|
-
const keyEntities = this.
|
|
271
|
+
const keyEntities = this.adapter.getKeyEntities();
|
|
233
272
|
const keyStr = String(realKey);
|
|
234
273
|
if (!keyEntities || !keyEntities[keyStr]) {
|
|
235
274
|
if (selected) checkedKeys.add(keyStr);
|
|
@@ -298,9 +337,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
298
337
|
}));
|
|
299
338
|
return TableFoundation.sortDataSource(props, filteredDataSource, queries.filter((query) => query && typeof query.sorter === "function"));
|
|
300
339
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Group, paginate and collect the row keys of filtered and sorted data
|
|
303
|
-
*/
|
|
304
340
|
static getPageData(props, dataSource, pagination, queries) {
|
|
305
341
|
let groups;
|
|
306
342
|
if (props.groupBy != null) {
|
|
@@ -520,13 +556,12 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
520
556
|
static isSortOrderValid(sortOrder) {
|
|
521
557
|
return typeof sortOrder === "string" && strings.SORT_DIRECTIONS.includes(sortOrder) || sortOrder === false;
|
|
522
558
|
}
|
|
523
|
-
/** The sort and filter state a header cell shows: the column's query by dataIndex, its sort order and filtered values */
|
|
524
559
|
static getColumnQueryState(column, queries) {
|
|
525
560
|
const query = column.dataIndex != null ? queries?.find((item) => item.dataIndex === column.dataIndex) : void 0;
|
|
526
561
|
const stateSortOrder = query?.sortOrder;
|
|
527
562
|
return {
|
|
528
563
|
query,
|
|
529
|
-
sortOrder: TableFoundation.isSortOrderValid(stateSortOrder) ? stateSortOrder :
|
|
564
|
+
sortOrder: TableFoundation.isSortOrderValid(stateSortOrder) ? stateSortOrder : query?.defaultSortOrder ?? false,
|
|
530
565
|
filteredValue: query?.filteredValue ? query.filteredValue : query?.defaultFilteredValue
|
|
531
566
|
};
|
|
532
567
|
}
|
|
@@ -588,7 +623,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
588
623
|
return Object.keys(changes).length ? changes : null;
|
|
589
624
|
}
|
|
590
625
|
/**
|
|
591
|
-
* @param flattenColumns the leaf columns of the props
|
|
592
626
|
* @param queries copies of flattenColumns with initColumnsFilteredValueAndSorterOrder applied; the framework copies
|
|
593
627
|
* them, since a deep clone would break framework values held by a column
|
|
594
628
|
*/
|
|
@@ -603,7 +637,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
603
637
|
preExpandedRowKeys: props.expandedRowKeys,
|
|
604
638
|
rowSelection: props.rowSelection ? isObject(props.rowSelection) ? { ...props.rowSelection } : {} : null,
|
|
605
639
|
pagination: pageData.pagination,
|
|
606
|
-
groups: null,
|
|
640
|
+
groups: pageData.groups ?? null,
|
|
607
641
|
allRowKeys: [],
|
|
608
642
|
pageDisabledRowKeys: [],
|
|
609
643
|
pageDisabledRowKeysSet: /* @__PURE__ */ new Set(),
|
|
@@ -626,14 +660,14 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
626
660
|
};
|
|
627
661
|
}
|
|
628
662
|
/** Hosts call it after mount, on body scroll and when the table or its content resizes */
|
|
629
|
-
syncScrollEdges() {
|
|
663
|
+
syncScrollEdges = () => {
|
|
630
664
|
this.#trackScrollEdges ??= !CSS.supports("container-type", "scroll-state");
|
|
631
|
-
const metrics = this.#trackScrollEdges ? this.
|
|
632
|
-
if (metrics) this.
|
|
633
|
-
}
|
|
665
|
+
const metrics = this.#trackScrollEdges ? this.adapter.getScrollMetrics() : null;
|
|
666
|
+
if (metrics) this.adapter.setScrollableEdges(TableFoundation.getScrollableEdges(metrics));
|
|
667
|
+
};
|
|
634
668
|
init() {
|
|
635
669
|
const dataSource = this.getProp("dataSource");
|
|
636
|
-
const { queries } = this.
|
|
670
|
+
const { queries } = this.adapter.getStates();
|
|
637
671
|
const filteredSortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
|
|
638
672
|
const allDataDisabledRowKeys = this.getAllDisabledRowKeys(filteredSortedDataSource);
|
|
639
673
|
const pageData = this.getCurrentPageData(filteredSortedDataSource);
|
|
@@ -643,19 +677,15 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
643
677
|
this.#defaultKeysApplied = true;
|
|
644
678
|
if (applyDefaultKeys && !(defaultExpandAllRows && !expandAllRows && !expandAllGroupRows && pageData.groups?.size && this.#rowExpansionIsControlled())) this.initExpandedRowKeys(pageData);
|
|
645
679
|
let keyEntities = {};
|
|
646
|
-
if (this.
|
|
680
|
+
if (this.adapter.getCheckRelation() === "related" && dataSource && dataSource.length) {
|
|
647
681
|
keyEntities = this.buildKeyEntities(dataSource);
|
|
648
|
-
this.
|
|
682
|
+
this.adapter.setKeyEntities(keyEntities);
|
|
649
683
|
}
|
|
650
684
|
if (applyDefaultKeys) this.#initSelectedRowKeys(keyEntities);
|
|
651
685
|
this.#setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
652
686
|
this.#setFilteredDisabledRowKeys(allDataDisabledRowKeys);
|
|
653
687
|
}
|
|
654
|
-
|
|
655
|
-
* @param prevProps the props of the previous commit
|
|
656
|
-
* @param prevFlattenColumns the flattenColumns state of the previous commit
|
|
657
|
-
*/
|
|
658
|
-
handleUpdate(prevProps, prevFlattenColumns) {
|
|
688
|
+
handleUpdate = (prevProps, prevFlattenColumns) => {
|
|
659
689
|
const props = this.getProps();
|
|
660
690
|
const flattenColumns = this.getState("flattenColumns");
|
|
661
691
|
if ((props.rowSelection || props.expandedRowRender || flattenColumns.some((column) => column.onFilter)) && props.dataSource?.some((record) => TableFoundation.getRecordKey(props, record) == null)) {
|
|
@@ -664,9 +694,9 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
664
694
|
if (props.expandAllRows !== prevProps.expandAllRows || props.expandAllGroupRows !== prevProps.expandAllGroupRows) this.initExpandedRowKeys({ groups: this.getState("groups") });
|
|
665
695
|
const dataSourceChanged = props.dataSource !== prevProps.dataSource;
|
|
666
696
|
const recompute = dataSourceChanged || flattenColumns !== prevFlattenColumns;
|
|
667
|
-
if (this.
|
|
697
|
+
if (this.adapter.getCheckRelation() === "related" && !(isObject(prevProps.rowSelection) && prevProps.rowSelection.checkRelation === "related") && !recompute) this.#updateKeyEntities();
|
|
668
698
|
this.#handleDataUpdate(dataSourceChanged, recompute);
|
|
669
|
-
}
|
|
699
|
+
};
|
|
670
700
|
initExpandedRowKeys({ groups } = {}) {
|
|
671
701
|
const { defaultExpandAllRows, defaultExpandedRowKeys = [], expandedRowKeys: propExpandedRowKeys = [], dataSource = [], expandAllRows, defaultExpandAllGroupRows, expandAllGroupRows } = this.getProps();
|
|
672
702
|
const expandedRowKeys = [];
|
|
@@ -674,21 +704,21 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
674
704
|
else if (defaultExpandAllGroupRows || expandAllGroupRows) this.#addNoDuplicatedItemsToArr(expandedRowKeys, propExpandedRowKeys, groups && groups instanceof Map && groups.size ? Array.from(groups.keys()) : []);
|
|
675
705
|
else if (Array.isArray(defaultExpandedRowKeys) && defaultExpandedRowKeys.length) this.#addNoDuplicatedItemsToArr(expandedRowKeys, defaultExpandedRowKeys);
|
|
676
706
|
else if (Array.isArray(propExpandedRowKeys) && propExpandedRowKeys.length) this.#addNoDuplicatedItemsToArr(expandedRowKeys, propExpandedRowKeys);
|
|
677
|
-
this.
|
|
707
|
+
this.adapter.setExpandedRowKeys(expandedRowKeys);
|
|
678
708
|
}
|
|
679
|
-
getCurrentPageData(dataSource, pagination, queries) {
|
|
680
|
-
const filteredSortedDataSource = this.
|
|
709
|
+
getCurrentPageData = (dataSource, pagination, queries) => {
|
|
710
|
+
const filteredSortedDataSource = this.adapter.getCachedFilteredSortedDataSource();
|
|
681
711
|
dataSource = dataSource == null ? [...filteredSortedDataSource] : dataSource;
|
|
682
712
|
pagination = pagination == null ? this.getState("pagination") && { ...this.getState("pagination") } : pagination;
|
|
683
713
|
queries = queries == null ? [...this.getState("queries")] : queries;
|
|
684
714
|
return TableFoundation.getPageData(this.getProps(), dataSource, pagination, queries);
|
|
685
|
-
}
|
|
715
|
+
};
|
|
686
716
|
/** Scrolls back to the first row; a pagination.onChange that takes over paging still gets the scroll */
|
|
687
|
-
resetScrollY() {
|
|
688
|
-
this.
|
|
689
|
-
}
|
|
717
|
+
resetScrollY = () => {
|
|
718
|
+
this.adapter.resetScrollY();
|
|
719
|
+
};
|
|
690
720
|
setPage = (currentPage, currentPageSize) => {
|
|
691
|
-
currentPage = currentPage || this.
|
|
721
|
+
currentPage = currentPage || this.adapter.getCurrentPage();
|
|
692
722
|
const currentPagination = this.getState("pagination");
|
|
693
723
|
const { dataSource, pagination, disabledRowKeys, allRowKeys } = this.getCurrentPageData(null, {
|
|
694
724
|
...currentPagination,
|
|
@@ -696,19 +726,28 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
696
726
|
pageSize: currentPageSize
|
|
697
727
|
});
|
|
698
728
|
if (!TableFoundation.#pagerIsControlled(this.getProps()) && currentPage > 0) {
|
|
699
|
-
this.
|
|
700
|
-
this.
|
|
701
|
-
this.
|
|
702
|
-
this.
|
|
729
|
+
this.adapter.setPageDisabledRowKeys(disabledRowKeys);
|
|
730
|
+
this.adapter.setAllRowKeys(allRowKeys);
|
|
731
|
+
this.adapter.setPagination(pagination);
|
|
732
|
+
this.adapter.setDataSource(dataSource);
|
|
703
733
|
}
|
|
704
734
|
this.#notifyChange(pagination, void 0, void 0, { changeType: "pagination" });
|
|
705
735
|
};
|
|
706
|
-
|
|
736
|
+
handleSelectionKeyUp = (e) => {
|
|
737
|
+
if (e.key === " ") this.#spaceShiftKey = e.shiftKey;
|
|
738
|
+
};
|
|
739
|
+
handleSelectRow = (realKey, selected, e) => {
|
|
707
740
|
e?.stopPropagation();
|
|
708
741
|
if (typeof selected === "boolean" && realKey != null) {
|
|
709
|
-
const checkRelation = this.
|
|
742
|
+
const checkRelation = this.adapter.getCheckRelation();
|
|
743
|
+
const native = e?.nativeEvent;
|
|
744
|
+
const shiftKey = e?.shiftKey ?? (native?.shiftKey || native?.detail === 0 && this.#spaceShiftKey);
|
|
745
|
+
this.#spaceShiftKey = false;
|
|
746
|
+
if (shiftKey && checkRelation !== "related" && this.#rangeAnchor != null && this.#selectRange(realKey)) return;
|
|
747
|
+
this.#rangeAnchor = realKey;
|
|
748
|
+
this.#rangeResult = null;
|
|
710
749
|
const selectedRowKeys = this.#getSelectedRowKeys();
|
|
711
|
-
const halfCheckedRowKeys = [...this.
|
|
750
|
+
const halfCheckedRowKeys = [...this.adapter.getHalfCheckedRowKeys() || []];
|
|
712
751
|
let foundIdx = -1;
|
|
713
752
|
const selectedRow = this.getRecordsByKeys(null, [realKey])[0];
|
|
714
753
|
let selectedRows;
|
|
@@ -716,43 +755,43 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
716
755
|
const checkedKeysSet = new Set(selectedRowKeys.map((key) => String(key)));
|
|
717
756
|
const halfCheckedKeysSet = new Set(halfCheckedRowKeys.map((key) => String(key)));
|
|
718
757
|
const { checkedKeys, halfCheckedKeys } = this.calcCheckedKeysForSelect(String(realKey), selected, checkedKeysSet, halfCheckedKeysSet);
|
|
719
|
-
const keyEntities = this.
|
|
758
|
+
const keyEntities = this.adapter.getKeyEntities();
|
|
720
759
|
const newSelectedRowKeys = TableFoundation.#restoreRowKeys(checkedKeys, [...selectedRowKeys, realKey], keyEntities);
|
|
721
760
|
const newHalfCheckedRowKeys = TableFoundation.#restoreRowKeys(halfCheckedKeys, halfCheckedRowKeys, keyEntities);
|
|
722
761
|
selectedRows = this.getRecordsByKeys(null, newSelectedRowKeys);
|
|
723
762
|
if (!this.#selectionIsControlled()) {
|
|
724
|
-
this.
|
|
725
|
-
this.
|
|
763
|
+
this.adapter.setSelectedRowKeys(newSelectedRowKeys);
|
|
764
|
+
this.adapter.setHalfCheckedRowKeys(newHalfCheckedRowKeys);
|
|
726
765
|
}
|
|
727
|
-
this.
|
|
728
|
-
this.
|
|
766
|
+
this.adapter.notifySelect(selectedRow, selected, selectedRows, e);
|
|
767
|
+
this.adapter.notifySelectionChange(newSelectedRowKeys, selectedRows);
|
|
729
768
|
} else if ((foundIdx = selectedRowKeys.indexOf(realKey)) > -1 && selected === false) {
|
|
730
769
|
selectedRowKeys.splice(foundIdx, 1);
|
|
731
770
|
selectedRows = this.getRecordsByKeys(null, selectedRowKeys);
|
|
732
|
-
if (!this.#selectionIsControlled()) this.
|
|
733
|
-
this.
|
|
734
|
-
this.
|
|
771
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
772
|
+
this.adapter.notifySelect(selectedRow, selected, selectedRows, e);
|
|
773
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
735
774
|
} else if (selectedRowKeys.indexOf(realKey) === -1 && selected === true) {
|
|
736
775
|
selectedRowKeys.push(realKey);
|
|
737
776
|
selectedRows = this.getRecordsByKeys(null, selectedRowKeys);
|
|
738
|
-
if (!this.#selectionIsControlled()) this.
|
|
739
|
-
this.
|
|
740
|
-
this.
|
|
777
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
778
|
+
this.adapter.notifySelect(selectedRow, selected, selectedRows, e);
|
|
779
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
741
780
|
}
|
|
742
781
|
}
|
|
743
|
-
}
|
|
744
|
-
handleSelectAllRow(selected, e) {
|
|
782
|
+
};
|
|
783
|
+
handleSelectAllRow = (selected, e) => {
|
|
745
784
|
e?.stopPropagation();
|
|
746
785
|
if (typeof selected === "boolean") {
|
|
747
|
-
const checkRelation = this.
|
|
786
|
+
const checkRelation = this.adapter.getCheckRelation();
|
|
748
787
|
const curSelectedRowKeys = this.#getSelectedRowKeys();
|
|
749
788
|
let selectedRowKeys = [...curSelectedRowKeys];
|
|
750
789
|
const selectedRowKeysSet = this.#getSelectedRowKeysSet();
|
|
751
|
-
const disabledRowKeysSet = this.
|
|
752
|
-
const scopeRowKeys = this.
|
|
790
|
+
const disabledRowKeysSet = this.adapter.getFilteredDisabledRowKeysSet();
|
|
791
|
+
const scopeRowKeys = this.adapter.getCachedFilteredSortedRowKeys().filter((key) => !disabledRowKeysSet.has(key));
|
|
753
792
|
if (checkRelation === "related") {
|
|
754
|
-
const keyEntities = this.
|
|
755
|
-
const halfCheckedRowKeys = [...this.
|
|
793
|
+
const keyEntities = this.adapter.getKeyEntities();
|
|
794
|
+
const halfCheckedRowKeys = [...this.adapter.getHalfCheckedRowKeys() || []];
|
|
756
795
|
let checkedKeysSet = new Set(selectedRowKeys.map((key) => String(key)));
|
|
757
796
|
let halfCheckedKeysSet = new Set(halfCheckedRowKeys.map((key) => String(key)));
|
|
758
797
|
if (selected) {
|
|
@@ -771,31 +810,31 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
771
810
|
const changedRows = this.getRecordsByKeys(null, getChangedRowKeys(curSelectedRowKeys, selectedRowKeys));
|
|
772
811
|
const selectedRows = this.getRecordsByKeys(null, selectedRowKeys || []);
|
|
773
812
|
if (!this.#selectionIsControlled()) {
|
|
774
|
-
this.
|
|
775
|
-
this.
|
|
813
|
+
this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
814
|
+
this.adapter.setHalfCheckedRowKeys(newHalfCheckedRowKeys);
|
|
776
815
|
}
|
|
777
|
-
this.
|
|
778
|
-
this.
|
|
816
|
+
this.adapter.notifySelectAll(selected, selectedRows, changedRows, e);
|
|
817
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
779
818
|
} else {
|
|
780
819
|
if (selected) {
|
|
781
820
|
for (const key of scopeRowKeys) if (!selectedRowKeysSet.has(key)) selectedRowKeys.push(key);
|
|
782
821
|
} else selectedRowKeys = differenceUnique(selectedRowKeys, scopeRowKeys);
|
|
783
822
|
const changedRows = this.getRecordsByKeys(null, getChangedRowKeys(curSelectedRowKeys, selectedRowKeys));
|
|
784
823
|
const selectedRows = this.getRecordsByKeys(null, selectedRowKeys || []);
|
|
785
|
-
if (!this.#selectionIsControlled()) this.
|
|
786
|
-
this.
|
|
787
|
-
this.
|
|
824
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
825
|
+
this.adapter.notifySelectAll(selected, selectedRows, changedRows, e);
|
|
826
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
788
827
|
}
|
|
789
828
|
}
|
|
790
|
-
}
|
|
791
|
-
handleRowExpanded(expanded, realKey, domEvent) {
|
|
829
|
+
};
|
|
830
|
+
handleRowExpanded = (expanded, realKey, domEvent) => {
|
|
792
831
|
domEvent?.stopPropagation();
|
|
793
832
|
const expandedRowKeys = [...this.getState("expandedRowKeys")];
|
|
794
833
|
const index = expandedRowKeys.indexOf(realKey);
|
|
795
834
|
const keyIsValid = typeof realKey === "string" || typeof realKey === "number";
|
|
796
835
|
if (keyIsValid && expanded && index === -1) expandedRowKeys.push(realKey);
|
|
797
836
|
else if (keyIsValid && !expanded && index > -1) expandedRowKeys.splice(index, 1);
|
|
798
|
-
if (!this.#rowExpansionIsControlled()) this.
|
|
837
|
+
if (!this.#rowExpansionIsControlled()) this.adapter.setExpandedRowKeys(expandedRowKeys);
|
|
799
838
|
const expandedRows = this.getRecordsByKeys(null, expandedRowKeys);
|
|
800
839
|
let expandedRow = this.getRecordsByKeys(null, [realKey])[0];
|
|
801
840
|
const groups = this.#getGroups();
|
|
@@ -803,13 +842,13 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
803
842
|
if (groups.has(realKey)) expandedRow = { groupKey: realKey };
|
|
804
843
|
for (const groupKey of expandedRowKeys) if (groups.has(groupKey)) expandedRows.push({ groupKey });
|
|
805
844
|
}
|
|
806
|
-
this.
|
|
807
|
-
this.
|
|
808
|
-
}
|
|
809
|
-
toggleShowFilter(dataIndex, visible) {
|
|
810
|
-
this.
|
|
811
|
-
}
|
|
812
|
-
handleFilterSelect(dataIndex, data = {}) {
|
|
845
|
+
this.adapter.notifyExpand(expanded, expandedRow, domEvent);
|
|
846
|
+
this.adapter.notifyExpandedRowsChange(expandedRows, [...expandedRowKeys]);
|
|
847
|
+
};
|
|
848
|
+
toggleShowFilter = (dataIndex, visible) => {
|
|
849
|
+
this.adapter.notifyFilterDropdownVisibleChange(visible, dataIndex);
|
|
850
|
+
};
|
|
851
|
+
handleFilterSelect = (dataIndex, data = {}) => {
|
|
813
852
|
const query = {
|
|
814
853
|
...this.getQuery(dataIndex),
|
|
815
854
|
filteredValue: data.filteredValue
|
|
@@ -819,12 +858,12 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
819
858
|
const pagination = this.#getPagination();
|
|
820
859
|
const sorter = this.#getAllSorters()[0];
|
|
821
860
|
if (!this.#filterIsControlled(dataIndex)) {
|
|
822
|
-
this.
|
|
861
|
+
this.adapter.setQueries(queries);
|
|
823
862
|
this.#applyQueries(queries);
|
|
824
863
|
}
|
|
825
864
|
this.#notifyChange(pagination, filters, sorter, { changeType: "filter" });
|
|
826
|
-
}
|
|
827
|
-
handleSort({ dataIndex } = {}) {
|
|
865
|
+
};
|
|
866
|
+
handleSort = ({ dataIndex } = {}) => {
|
|
828
867
|
let queries = this.getState("queries");
|
|
829
868
|
let curQuery = null;
|
|
830
869
|
queries = [...queries];
|
|
@@ -849,22 +888,19 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
849
888
|
const pagination = this.#getPagination();
|
|
850
889
|
const filters = this.#getAllFilters();
|
|
851
890
|
if (!this.#sorterIsControlled(dataIndex)) {
|
|
852
|
-
this.
|
|
891
|
+
this.adapter.setQueries(queries);
|
|
853
892
|
this.#applyQueries(queries);
|
|
854
893
|
}
|
|
855
894
|
this.#notifyChange(pagination, filters, curQuery, { changeType: "sorter" });
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
* Select or deselect a row by clicking it when rowSelection.clickRow is set
|
|
859
|
-
*/
|
|
860
|
-
handleRowClickSelection(rowKey, selected, e) {
|
|
895
|
+
};
|
|
896
|
+
handleRowClickSelection = (rowKey, selected, e) => {
|
|
861
897
|
const rowSelection = this.getState("rowSelection");
|
|
862
898
|
if (rowSelection?.clickRow && !rowSelection.disabled) {
|
|
863
899
|
const getCheckboxProps = rowSelection?.getCheckboxProps;
|
|
864
|
-
const record = this.
|
|
900
|
+
const record = this.adapter.getCachedFilteredSortedDataSource().find((r) => this.getRecordKey(r) === rowKey);
|
|
865
901
|
if (record && typeof getCheckboxProps === "function" && getCheckboxProps(record).disabled) return;
|
|
866
902
|
this.handleSelectRow(rowKey, selected, e);
|
|
867
903
|
}
|
|
868
|
-
}
|
|
904
|
+
};
|
|
869
905
|
};
|
|
870
906
|
export { TableFoundation as default };
|
package/dist/table/table.scss
CHANGED
package/dist/table/utils.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export interface VirtualizedRowKind {
|
|
|
32
32
|
expandedRow: boolean;
|
|
33
33
|
sectionRow: boolean;
|
|
34
34
|
}
|
|
35
|
-
/** The height of a virtualized row from the itemSize option; the size preset's default stands in when it gives none */
|
|
36
35
|
export declare function resolveVirtualizedItemSize(itemSize: number | ((index: number, row: VirtualizedRowKind) => number) | undefined, size: string | undefined, index: number, row: VirtualizedRowKind): {
|
|
37
36
|
size: number;
|
|
38
37
|
minHeight: number;
|
|
@@ -48,9 +47,9 @@ export declare function placeInnerColumns<T extends {
|
|
|
48
47
|
fixed?: unknown;
|
|
49
48
|
}>(columns: T[], innerColumns: (T | null)[]): T[];
|
|
50
49
|
/** The measured widths of the columns in order; a column not measured yet is skipped */
|
|
51
|
-
export declare function getCellWidths(headWidths
|
|
50
|
+
export declare function getCellWidths(headWidths?: BaseHeadWidth[][], columns?: {
|
|
52
51
|
key?: unknown;
|
|
53
|
-
}[]
|
|
52
|
+
}[]): number[];
|
|
54
53
|
export declare function sliceColumnsByLevel(columns: any[], targetLevel?: number, childrenColumnName?: string, currentLevel?: number): any[];
|
|
55
54
|
export declare function getColumnsByLevel(columns: Record<string, any>[], targetLevel?: number, targetColumns?: Record<string, any>[], currentLevel?: number, childrenColumnName?: string): Record<string, any>[];
|
|
56
55
|
export declare function findColumn(columns: Record<string, any>[], column: Record<string, any>, childrenColumnName?: string): any;
|
|
@@ -78,7 +77,6 @@ export declare function getRTLFlexAlign(align: (typeof strings.ALIGNS)[number],
|
|
|
78
77
|
export declare function shouldShowEllipsisTitle(ellipsis: BaseEllipsis): boolean;
|
|
79
78
|
/** Merges new columns over old ones with the same key or dataIndex, so state kept on a column survives */
|
|
80
79
|
export declare function mergeColumns<C extends Record<string, any>>(oldColumns?: C[], newColumns?: C[]): C[];
|
|
81
|
-
/** The number of header rows: the depth of the column tree */
|
|
82
80
|
export declare function getHeaderRowCount(columns: Record<string, any>[]): number;
|
|
83
81
|
/** The next sort order, named as the locale texts of the sort tooltip */
|
|
84
82
|
export declare function getNextSortOrder(sortOrder: string | boolean): "ascend" | "descend" | "cancelSort";
|
|
@@ -87,7 +85,6 @@ export declare function toggleFilteredValue<V>(filteredValue: V[], value: V, fil
|
|
|
87
85
|
export interface TableHeaderCell<Column extends Record<string, any> = Record<string, any>> {
|
|
88
86
|
key: string | number;
|
|
89
87
|
className: string;
|
|
90
|
-
/** The column title, or what a title function returns */
|
|
91
88
|
children: any;
|
|
92
89
|
column: Column;
|
|
93
90
|
colStart: number;
|
|
@@ -101,11 +98,7 @@ export interface TableHeaderCell<Column extends Record<string, any> = Record<str
|
|
|
101
98
|
last?: boolean;
|
|
102
99
|
title?: string;
|
|
103
100
|
}
|
|
104
|
-
/**
|
|
105
|
-
* The header cells by row, with the colSpan and rowSpan that merge the cells of grouped columns
|
|
106
|
-
*/
|
|
107
101
|
export declare function parseHeaderRows<Column extends Record<string, any>>(columns: Column[]): TableHeaderCell<Column>[][];
|
|
108
|
-
/** The keys whose selection state differs between two selections */
|
|
109
102
|
export declare function getChangedRowKeys(before: Array<string | number>, after: Array<string | number>): (string | number)[];
|
|
110
103
|
export interface FlattenDataProps {
|
|
111
104
|
rowKey?: string | number | ((record: any) => string | number);
|
|
@@ -138,7 +131,6 @@ export interface FlattenData {
|
|
|
138
131
|
expanded?: boolean;
|
|
139
132
|
sectionRow?: boolean;
|
|
140
133
|
}
|
|
141
|
-
/** The first record of each row key; an empty or missing key cannot be looked up */
|
|
142
134
|
export declare function buildRecordsByKey(dataSource: Record<string, any>[] | undefined, rowKey: FlattenDataProps['rowKey']): Map<BaseRowKeyType, Record<string, any>>;
|
|
143
135
|
export interface BodyRowsOptions {
|
|
144
136
|
rowKey?: FlattenDataProps['rowKey'];
|
package/dist/table/utils.js
CHANGED
|
@@ -97,7 +97,6 @@ function getDefaultVirtualizedRowConfig(size = "", sectionRow = false) {
|
|
|
97
97
|
}
|
|
98
98
|
return config;
|
|
99
99
|
}
|
|
100
|
-
/** The height of a virtualized row from the itemSize option; the size preset's default stands in when it gives none */
|
|
101
100
|
function resolveVirtualizedItemSize(itemSize, size, index, row) {
|
|
102
101
|
const config = getDefaultVirtualizedRowConfig(size, row.sectionRow);
|
|
103
102
|
return {
|
|
@@ -232,7 +231,6 @@ function mergeColumns(oldColumns = [], newColumns = []) {
|
|
|
232
231
|
return column;
|
|
233
232
|
});
|
|
234
233
|
}
|
|
235
|
-
/** The number of header rows: the depth of the column tree */
|
|
236
234
|
function getHeaderRowCount(columns) {
|
|
237
235
|
return Math.max(0, ...columns.map((column) => column.children?.length ? 1 + getHeaderRowCount(column.children) : 1));
|
|
238
236
|
}
|
|
@@ -254,9 +252,6 @@ function toggleFilteredValue(filteredValue, value, filterMultiple) {
|
|
|
254
252
|
}
|
|
255
253
|
return filterMultiple ? [...values, value] : [value];
|
|
256
254
|
}
|
|
257
|
-
/**
|
|
258
|
-
* The header cells by row, with the colSpan and rowSpan that merge the cells of grouped columns
|
|
259
|
-
*/
|
|
260
255
|
function parseHeaderRows(columns) {
|
|
261
256
|
const rows = [];
|
|
262
257
|
const fillRowCells = (columns, colIndex, parents = [], rowIndex = 0, level = 0) => {
|
|
@@ -273,9 +268,6 @@ function parseHeaderRows(columns) {
|
|
|
273
268
|
parents
|
|
274
269
|
};
|
|
275
270
|
let colSpan = 1;
|
|
276
|
-
/**
|
|
277
|
-
* colSpan: the sum of the children's colSpan, or 1 without children
|
|
278
|
-
*/
|
|
279
271
|
const subColumns = column.children;
|
|
280
272
|
if (subColumns && subColumns.length > 0) {
|
|
281
273
|
colSpan = fillRowCells(subColumns, currentColIndex, [...parents, cell], rowIndex + 1, level + 1).reduce((total, count) => total + count, 0);
|
|
@@ -291,9 +283,6 @@ function parseHeaderRows(columns) {
|
|
|
291
283
|
});
|
|
292
284
|
};
|
|
293
285
|
const columnCount = fillRowCells(columns, 0).reduce((total, count) => total + count, 0);
|
|
294
|
-
/**
|
|
295
|
-
* rowSpan: a cell without children spans the remaining rows; a cell with children needs none
|
|
296
|
-
*/
|
|
297
286
|
const rowCount = rows.length;
|
|
298
287
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) rows[rowIndex].forEach((cell) => {
|
|
299
288
|
if (!cell.hasSubColumns) cell.rowSpan = rowCount - rowIndex;
|
|
@@ -301,7 +290,6 @@ function parseHeaderRows(columns) {
|
|
|
301
290
|
});
|
|
302
291
|
return rows;
|
|
303
292
|
}
|
|
304
|
-
/** The keys whose selection state differs between two selections */
|
|
305
293
|
function getChangedRowKeys(before, after) {
|
|
306
294
|
return xor(before, after);
|
|
307
295
|
}
|
|
@@ -355,7 +343,6 @@ function flattenRecords(props, expandedKeys, dataSource, level) {
|
|
|
355
343
|
return rows;
|
|
356
344
|
});
|
|
357
345
|
}
|
|
358
|
-
/** The first record of each row key; an empty or missing key cannot be looked up */
|
|
359
346
|
function buildRecordsByKey(dataSource, rowKey) {
|
|
360
347
|
const recordsByKey = /* @__PURE__ */ new Map();
|
|
361
348
|
dataSource?.forEach((record) => {
|