@fibrae/semi-foundation 0.2.0 → 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 +0 -3
- package/dist/anchor/foundation.js +0 -1
- package/dist/audio-player/foundation.d.ts +0 -3
- package/dist/audio-player/foundation.js +0 -1
- package/dist/auto-complete/foundation.d.ts +0 -2
- package/dist/auto-complete/foundation.js +0 -1
- package/dist/avatar/foundation.d.ts +0 -1
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +0 -3
- package/dist/backtop/foundation.js +0 -1
- package/dist/base/auto-close-foundation.d.ts +0 -1
- package/dist/base/foundation.d.ts +0 -1
- package/dist/base/list-store.d.ts +0 -1
- package/dist/calendar/event-util.d.ts +0 -10
- package/dist/calendar/event-util.js +0 -10
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +1 -5
- package/dist/calendar/month-foundation.d.ts +0 -1
- package/dist/calendar/month-foundation.js +0 -1
- package/dist/carousel/foundation.d.ts +0 -2
- package/dist/cascader/foundation.d.ts +2 -6
- package/dist/cascader/foundation.js +2 -11
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +1 -5
- package/dist/checkbox/checkbox-foundation.js +0 -2
- package/dist/checkbox/checkbox-group-foundation.d.ts +0 -1
- package/dist/code-highlight/index.d.ts +0 -1
- package/dist/color-picker/color-picker.scss +0 -2
- package/dist/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +0 -1
- package/dist/cropper/foundation.js +0 -1
- 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 +0 -2
- 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 +3 -22
- package/dist/date-picker/foundation.js +1 -24
- package/dist/date-picker/input-foundation.d.ts +1 -7
- package/dist/date-picker/input-foundation.js +0 -2
- 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 +1 -10
- package/dist/date-picker/months-grid-foundation.js +1 -10
- package/dist/drag-move/foundation.d.ts +0 -1
- package/dist/dropdown/foundation.d.ts +0 -2
- package/dist/dropdown/menu-foundation.d.ts +0 -1
- package/dist/feedback/foundation.d.ts +0 -1
- 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.scss +0 -12
- package/dist/form/foundation.js +0 -15
- 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 +0 -2
- package/dist/hot-keys/foundation.d.ts +0 -1
- package/dist/image/image-foundation.d.ts +0 -2
- package/dist/image/preview-footer-foundation.d.ts +0 -1
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-image-foundation.d.ts +0 -1
- package/dist/image/preview-inner-foundation.d.ts +0 -1
- package/dist/input/foundation.d.ts +0 -1
- package/dist/input/text-entry-foundation.d.ts +0 -2
- package/dist/input/text-entry-foundation.js +0 -1
- package/dist/input/textarea-foundation.d.ts +0 -1
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +0 -5
- package/dist/input-number/foundation.js +0 -5
- package/dist/json-viewer/foundation.d.ts +0 -2
- package/dist/json-viewer/foundation.js +0 -1
- package/dist/locale/interface.d.ts +0 -3
- package/dist/markdown-render/foundation.d.ts +1 -6
- package/dist/markdown-render/foundation.js +1 -5
- package/dist/navigation/foundation.d.ts +0 -7
- package/dist/navigation/foundation.js +0 -6
- package/dist/navigation/sub-nav-foundation.d.ts +0 -1
- package/dist/notification/notification-list-foundation.d.ts +0 -1
- package/dist/notification/notification-list-foundation.js +0 -1
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +0 -2
- package/dist/overflow-list/foundation.js +0 -1
- package/dist/pagination/foundation.d.ts +0 -2
- package/dist/pincode/foundation.d.ts +1 -4
- package/dist/pincode/foundation.js +1 -4
- package/dist/popconfirm/popconfirm-foundation.d.ts +0 -2
- 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 +0 -4
- package/dist/radio/radio-foundation.js +0 -1
- package/dist/radio/radio-group-foundation.d.ts +0 -1
- package/dist/rating/foundation.d.ts +0 -5
- package/dist/rating/foundation.js +0 -3
- package/dist/resizable/group/index.d.ts +0 -4
- package/dist/resizable/group/index.js +0 -4
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +1 -5
- package/dist/resizable/single/index.js +1 -4
- package/dist/scroll-list/item-foundation.d.ts +0 -2
- package/dist/scroll-list/item-foundation.js +0 -1
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +0 -1
- package/dist/select/option-foundation.d.ts +2 -3
- package/dist/select/option-foundation.js +0 -1
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +1 -6
- package/dist/side-sheet/side-sheet-foundation.js +1 -5
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +1 -12
- package/dist/slider/foundation.js +1 -13
- package/dist/slider/variables.scss +1 -5
- package/dist/spin/foundation.d.ts +0 -2
- package/dist/spin/foundation.js +0 -1
- package/dist/spin/variables.scss +1 -3
- package/dist/switch/foundation.d.ts +0 -1
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +12 -21
- package/dist/table/foundation.js +51 -15
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +0 -8
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +0 -9
- package/dist/tabs/foundation.js +0 -4
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +0 -2
- package/dist/tag-input/foundation.js +0 -1
- 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 +0 -10
- package/dist/time-picker/foundation.js +0 -9
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- 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 +0 -3
- package/dist/tooltip/foundation.js +0 -2
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +0 -4
- package/dist/transfer/foundation.js +0 -1
- package/dist/tree/foundation.d.ts +0 -2
- package/dist/tree/foundation.js +0 -1
- package/dist/tree/shared.d.ts +1 -3
- 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 +0 -2
- package/dist/tree-select/foundation.js +0 -3
- package/dist/typography/ellipsis.d.ts +1 -3
- package/dist/typography/ellipsis.js +0 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +0 -6
- package/dist/upload/foundation.js +1 -11
- package/dist/upload/utils.d.ts +0 -5
- package/dist/upload/utils.js +0 -5
- package/dist/user-guide/foundation.d.ts +0 -2
- package/dist/utils/a11y.d.ts +1 -5
- package/dist/utils/a11y.js +1 -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 +0 -1
- package/dist/utils/focus-handle.js +0 -1
- package/dist/utils/focus-scope.d.ts +0 -1
- package/dist/utils/focus-scope.js +0 -1
- 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/progress-foundation.d.ts +0 -1
- package/dist/video-player/progress-foundation.js +0 -1
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
|
@@ -100,7 +100,6 @@ export interface BaseTableDataProps<RecordType> {
|
|
|
100
100
|
getCheckboxProps?: GetCheckboxProps<RecordType>;
|
|
101
101
|
} | boolean;
|
|
102
102
|
}
|
|
103
|
-
/** The rowSelection options the foundation reads */
|
|
104
103
|
export interface TableBaseRowSelection<RecordType> {
|
|
105
104
|
selectedRowKeys?: BaseRowKeyType[];
|
|
106
105
|
defaultSelectedRowKeys?: BaseRowKeyType[];
|
|
@@ -138,22 +137,17 @@ export interface TableBaseState<RecordType> {
|
|
|
138
137
|
/** Group key (what groupBy returns) -> the row keys in that group */
|
|
139
138
|
groups?: Map<string | number, Set<BaseRowKeyType>>;
|
|
140
139
|
allRowKeys?: BaseRowKeyType[];
|
|
141
|
-
/** Disabled row keys of the current page */
|
|
142
140
|
pageDisabledRowKeys?: BaseRowKeyType[];
|
|
143
141
|
pageDisabledRowKeysSet?: Set<BaseRowKeyType>;
|
|
144
142
|
headWidths?: BaseHeadWidth[][];
|
|
145
143
|
bodyHasScrollBar?: boolean;
|
|
146
|
-
/** The props the derived state was last computed from */
|
|
147
144
|
prePropRowSelection?: TableBaseProps<RecordType>['rowSelection'];
|
|
148
145
|
prePagination?: TableBaseProps<RecordType>['pagination'];
|
|
149
146
|
preExpandedRowKeys?: BaseRowKeyType[];
|
|
150
|
-
/** Disabled row keys in sorted and filtered data */
|
|
151
147
|
filteredDisabledRowKeys?: BaseRowKeyType[];
|
|
152
148
|
filteredDisabledRowKeysSet?: Set<BaseRowKeyType>;
|
|
153
|
-
/** Half-checked row keys for tree selection (checkRelation='related') */
|
|
154
149
|
halfCheckedRowKeys?: BaseRowKeyType[];
|
|
155
150
|
halfCheckedRowKeysSet?: Set<BaseRowKeyType>;
|
|
156
|
-
/** Key entities map for tree data structure */
|
|
157
151
|
keyEntities?: BaseEntitys;
|
|
158
152
|
filteredSortedDataSource?: RecordType[];
|
|
159
153
|
filteredSortedRowKeys?: BaseRowKeyType[];
|
|
@@ -185,9 +179,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
185
179
|
static initFilteredValue<R>(column: BaseColumnProps<R>): void;
|
|
186
180
|
static initSorterOrder<R>(column: BaseColumnProps<R>): void;
|
|
187
181
|
static getFilteredSortedDataSource<R>(props: BaseTableDataProps<R>, dataSource: R[], queries: BaseColumnProps<R>[]): R[];
|
|
188
|
-
/**
|
|
189
|
-
* Group, paginate and collect the row keys of filtered and sorted data
|
|
190
|
-
*/
|
|
191
182
|
static getPageData<R>(props: BaseTableDataProps<R>, dataSource: R[], pagination: BasePagination, queries: BaseColumnProps<R>[]): BasePageData<R>;
|
|
192
183
|
static groupDataSource<R>(props: BaseTableDataProps<R>, dataSource: R[]): {
|
|
193
184
|
groups: Map<string | number, Set<BaseRowKeyType>>;
|
|
@@ -213,7 +204,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
213
204
|
total?: number;
|
|
214
205
|
}) => any)): string;
|
|
215
206
|
static isSortOrderValid(sortOrder: BaseSortOrder): boolean;
|
|
216
|
-
/** The sort and filter state a header cell shows: the column's query by dataIndex, its sort order and filtered values */
|
|
217
207
|
static getColumnQueryState<Q extends {
|
|
218
208
|
dataIndex?: unknown;
|
|
219
209
|
sortOrder?: unknown;
|
|
@@ -233,7 +223,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
233
223
|
*/
|
|
234
224
|
static deriveState<R, C extends BaseColumnProps<R> = BaseColumnProps<R>>(props: TableBaseProps<R>, state: TableColumnsState<R, C>, flattenColumns: C[]): Partial<TableColumnsState<R, C>> | null;
|
|
235
225
|
/**
|
|
236
|
-
* @param flattenColumns the leaf columns of the props
|
|
237
226
|
* @param queries copies of flattenColumns with initColumnsFilteredValueAndSorterOrder applied; the framework copies
|
|
238
227
|
* them, since a deep clone would break framework values held by a column
|
|
239
228
|
*/
|
|
@@ -241,10 +230,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
241
230
|
/** Hosts call it after mount, on body scroll and when the table or its content resizes */
|
|
242
231
|
syncScrollEdges: () => void;
|
|
243
232
|
init(): void;
|
|
244
|
-
/**
|
|
245
|
-
* @param prevProps the props of the previous commit
|
|
246
|
-
* @param prevFlattenColumns the flattenColumns state of the previous commit
|
|
247
|
-
*/
|
|
248
233
|
handleUpdate: (prevProps: TableBaseProps<RecordType>, prevFlattenColumns: TableBaseState<RecordType>["flattenColumns"]) => void;
|
|
249
234
|
initExpandedRowKeys({ groups }?: {
|
|
250
235
|
groups?: Map<string | number, Set<BaseRowKeyType>>;
|
|
@@ -253,7 +238,8 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
253
238
|
/** Scrolls back to the first row; a pagination.onChange that takes over paging still gets the scroll */
|
|
254
239
|
resetScrollY: () => void;
|
|
255
240
|
setPage: (currentPage: number, currentPageSize: number) => void;
|
|
256
|
-
|
|
241
|
+
handleSelectionKeyUp: (e: Pick<KeyboardEvent, "key" | "shiftKey">) => void;
|
|
242
|
+
handleSelectRow: (realKey: BaseRowKeyType, selected: boolean, e?: BaseSelectRowEvent) => void;
|
|
257
243
|
handleSelectAllRow: (selected: boolean, e?: Pick<Event, "stopPropagation">) => void;
|
|
258
244
|
handleRowExpanded: (expanded: boolean, realKey: BaseRowKeyType, domEvent: any) => void;
|
|
259
245
|
toggleShowFilter: (dataIndex: string, visible: boolean) => void;
|
|
@@ -264,12 +250,18 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
264
250
|
dataIndex?: string;
|
|
265
251
|
sortOrder?: BaseSortOrder;
|
|
266
252
|
}) => void;
|
|
267
|
-
|
|
268
|
-
* Select or deselect a row by clicking it when rowSelection.clickRow is set
|
|
269
|
-
*/
|
|
270
|
-
handleRowClickSelection: (rowKey: BaseRowKeyType, selected: boolean, e: Pick<Event, "stopPropagation">) => void;
|
|
253
|
+
handleRowClickSelection: (rowKey: BaseRowKeyType, selected: boolean, e: BaseSelectRowEvent) => void;
|
|
271
254
|
}
|
|
272
255
|
export type BaseRowKeyType = string | number;
|
|
256
|
+
/** A row click passes its mouse event; a checkbox change passes its change event, with the click in nativeEvent */
|
|
257
|
+
export interface BaseSelectRowEvent {
|
|
258
|
+
stopPropagation: () => void;
|
|
259
|
+
shiftKey?: boolean;
|
|
260
|
+
nativeEvent?: {
|
|
261
|
+
shiftKey?: boolean;
|
|
262
|
+
detail?: number;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
273
265
|
export type BaseRowKey<RecordType> = BaseRowKeyType | ((record: RecordType) => BaseRowKeyType);
|
|
274
266
|
export interface BasePagination {
|
|
275
267
|
total?: number;
|
|
@@ -285,7 +277,6 @@ export interface BaseHeadWidth {
|
|
|
285
277
|
}
|
|
286
278
|
export interface BasePageData<RecordType> {
|
|
287
279
|
dataSource?: RecordType[];
|
|
288
|
-
/** Group key (what groupBy returns) -> the row keys in that group */
|
|
289
280
|
groups?: Map<string | number, Set<BaseRowKeyType>>;
|
|
290
281
|
pagination?: BasePagination;
|
|
291
282
|
disabledRowKeys?: BaseRowKeyType[];
|
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);
|
|
@@ -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
|
}
|
|
@@ -158,7 +198,6 @@ 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
203
|
this.adapter.setKeyEntities(keyEntities);
|
|
@@ -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,7 +556,6 @@ 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;
|
|
@@ -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
|
*/
|
|
@@ -651,10 +685,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
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
688
|
handleUpdate = (prevProps, prevFlattenColumns) => {
|
|
659
689
|
const props = this.getProps();
|
|
660
690
|
const flattenColumns = this.getState("flattenColumns");
|
|
@@ -703,10 +733,19 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
703
733
|
}
|
|
704
734
|
this.#notifyChange(pagination, void 0, void 0, { changeType: "pagination" });
|
|
705
735
|
};
|
|
736
|
+
handleSelectionKeyUp = (e) => {
|
|
737
|
+
if (e.key === " ") this.#spaceShiftKey = e.shiftKey;
|
|
738
|
+
};
|
|
706
739
|
handleSelectRow = (realKey, selected, e) => {
|
|
707
740
|
e?.stopPropagation();
|
|
708
741
|
if (typeof selected === "boolean" && realKey != null) {
|
|
709
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
750
|
const halfCheckedRowKeys = [...this.adapter.getHalfCheckedRowKeys() || []];
|
|
712
751
|
let foundIdx = -1;
|
|
@@ -854,9 +893,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
854
893
|
}
|
|
855
894
|
this.#notifyChange(pagination, filters, curQuery, { changeType: "sorter" });
|
|
856
895
|
};
|
|
857
|
-
/**
|
|
858
|
-
* Select or deselect a row by clicking it when rowSelection.clickRow is set
|
|
859
|
-
*/
|
|
860
896
|
handleRowClickSelection = (rowKey, selected, e) => {
|
|
861
897
|
const rowSelection = this.getState("rowSelection");
|
|
862
898
|
if (rowSelection?.clickRow && !rowSelection.disabled) {
|
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;
|
|
@@ -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) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$spacing-table-paddingY: $spacing-base; // 表格空数据占位及虚拟列表分组垂直内边距
|
|
4
4
|
$spacing-table-paddingX: $spacing-base-tight; // 表格空数据占位及虚拟列表分组水平内边距
|
|
5
5
|
$spacing-table_middle-paddingY: $spacing-base-tight; // 中尺寸表格单元格垂直内边距
|
|
@@ -26,11 +26,9 @@ $spacing-table_expand_icon-marginRight: 8px; // 行展开按钮右侧外边距
|
|
|
26
26
|
$spacing-table_panel_operation-paddingX: $spacing-base; // 表格操作栏水平内边距
|
|
27
27
|
$spacing-table_panel_operation-paddingY: $spacing-tight; // 表格操作栏垂直内边距
|
|
28
28
|
|
|
29
|
-
// Size
|
|
30
29
|
$width-table_base_border: 1px; // 表格单元格分割线宽度
|
|
31
30
|
$width-table_header_border: 1px; // 表格表头分割线宽度
|
|
32
31
|
$width-table_resizer_border: 2px; // 表格拉伸列标示线宽度
|
|
33
|
-
// $radius-table_base: 4px;
|
|
34
32
|
$width-table_column_selection: 48px; // 表格选择列及展开列宽度
|
|
35
33
|
$width-table_column_sorter-icon: 16px; // 表格排序按钮宽度
|
|
36
34
|
$height-table_column_sorter-icon: 16px; // 表格排序按钮高度
|
|
@@ -42,7 +40,6 @@ $width-table_react_resizable_handle: 9px; // 表格伸缩列调节热区宽度
|
|
|
42
40
|
$height-table_pagination_outer_min: 60px; // 表格分页器高度
|
|
43
41
|
$height-table_column_filter_dropdown: 290px; // 表格过滤筛选列表最大高度
|
|
44
42
|
|
|
45
|
-
// Color no need to change
|
|
46
43
|
$color-table_panel-bg-default: var(--semi-color-primary); // 操作区域样式默认背景颜色
|
|
47
44
|
$color-table_panel-text-default: var(--semi-color-primary-light-active); // 表格操作栏选中项文本颜色
|
|
48
45
|
$color-table-bg-default: var(--semi-color-bg-1); // 表格固定列及吸顶表头背景颜色
|
|
@@ -77,7 +74,6 @@ $color-table_placeholder-text-default: var(--semi-color-text-2); // 表格空数
|
|
|
77
74
|
|
|
78
75
|
$color-table_cell-bg-hover: var(--semi-color-bg-0); // 让表格在 hover 时正确显示 $color-table_body-bg-hover 颜色,如无必要不要修改
|
|
79
76
|
|
|
80
|
-
// Other
|
|
81
77
|
$font-table_base-fontSize: 14px; // 表格默认文本字号
|
|
82
78
|
$border-table_base-borderStyle: solid; // 表格描边样式
|
|
83
79
|
$width-table_fixed_shadow: 6px; // 表格固定列滚动阴影宽度
|
|
@@ -11,13 +11,10 @@ export interface MotionView {
|
|
|
11
11
|
export type MotionViewInput = Pick<MotionView, 'activeKey' | 'propsActiveKey' | 'paneKeys'>;
|
|
12
12
|
/** The members of a keyboard event the foundation reads; DOM and synthetic events both satisfy it */
|
|
13
13
|
export type TabKeyEvent = Pick<KeyboardEvent, 'key' | 'altKey' | 'ctrlKey' | 'metaKey' | 'target' | 'currentTarget' | 'preventDefault' | 'stopPropagation'>;
|
|
14
|
-
/** What a pane's slide-in depends on */
|
|
15
14
|
export interface PaneMotionInput {
|
|
16
15
|
itemKey?: string;
|
|
17
16
|
activeKey: string | null;
|
|
18
|
-
/** The key selected before activeKey, null on mount */
|
|
19
17
|
prevActiveKey: string | null;
|
|
20
|
-
/** The itemKeys of the panes in order */
|
|
21
18
|
paneKeys: ReadonlyArray<string | undefined>;
|
|
22
19
|
tabPosition: 'top' | 'left';
|
|
23
20
|
tabPaneMotion: boolean;
|
|
@@ -35,20 +32,17 @@ interface TabEntry {
|
|
|
35
32
|
itemKey?: string;
|
|
36
33
|
disabled?: boolean;
|
|
37
34
|
}
|
|
38
|
-
/** The props the foundation reads */
|
|
39
35
|
export interface TabsBaseProps {
|
|
40
36
|
activeKey?: string | null;
|
|
41
37
|
tabPosition?: 'top' | 'left';
|
|
42
38
|
preventScroll?: boolean;
|
|
43
39
|
}
|
|
44
|
-
/** The state the foundation reads */
|
|
45
40
|
export interface TabsBaseState {
|
|
46
41
|
activeKey: string | null;
|
|
47
42
|
}
|
|
48
43
|
export default class TabsFoundation<P extends TabsBaseProps = TabsBaseProps, S extends TabsBaseState = TabsBaseState, E = unknown> extends BaseFoundation<TabsAdapter<P, S, E>, P, S> {
|
|
49
44
|
#private;
|
|
50
45
|
protected handleNewActiveKey(activeKey: string | null): void;
|
|
51
|
-
/** activeKey, else defaultActiveKey, else the first enabled entry of `list` that has a key */
|
|
52
46
|
static getDefaultActiveKey(props: {
|
|
53
47
|
activeKey?: string | null;
|
|
54
48
|
defaultActiveKey?: string;
|
|
@@ -58,14 +52,12 @@ export default class TabsFoundation<P extends TabsBaseProps = TabsBaseProps, S e
|
|
|
58
52
|
* null, matches no tab, or the tab sits in the more menu), the first enabled one takes it.
|
|
59
53
|
*/
|
|
60
54
|
static getTabbableKey(tabs: ReadonlyArray<TabEntry>, activeKey: string | null): string | undefined;
|
|
61
|
-
/** The slide-in class of a pane and whether it plays: only the selected pane slides, from the side of the previous one */
|
|
62
55
|
static getPaneMotion({ itemKey, activeKey, prevActiveKey, paneKeys, tabPosition, tabPaneMotion, forceDisableMotion }: PaneMotionInput): {
|
|
63
56
|
startClassName: string;
|
|
64
57
|
hasMotion: boolean;
|
|
65
58
|
};
|
|
66
59
|
/** The next MotionView; `prev` itself when nothing it records changed, so hosts can compare by reference */
|
|
67
60
|
static getMotionView(prev: MotionView | undefined, { activeKey, propsActiveKey, paneKeys }: MotionViewInput): MotionView;
|
|
68
|
-
/** Splits `list` into the tabs that stay in the bar and the last `more` ones (or `more.count`) that move into the menu */
|
|
69
61
|
static splitMore<T>(list: readonly T[], more: number | {
|
|
70
62
|
count: number;
|
|
71
63
|
}): {
|
|
@@ -76,7 +68,6 @@ export default class TabsFoundation<P extends TabsBaseProps = TabsBaseProps, S e
|
|
|
76
68
|
static isTabsOverflowing(barEl: HTMLElement, tabPosition?: 'top' | 'left'): boolean;
|
|
77
69
|
/** `barItemKey` is the data-scrollkey of the tab, see getBarItemKey */
|
|
78
70
|
static scrollTabIntoView(barEl: HTMLElement | null | undefined, barItemKey: string, position?: ScrollLogicalPosition, behavior?: ScrollBehavior): void;
|
|
79
|
-
/** Re-keys the OverflowList visibility map by itemKey; `hasHidden` and `isShowInViewport` summarize it */
|
|
80
71
|
static readVisibleState(visibleMap: ReadonlyMap<string, boolean>): {
|
|
81
72
|
visibleState: Map<string, boolean>;
|
|
82
73
|
isShowInViewport: boolean;
|
package/dist/tabs/foundation.js
CHANGED
|
@@ -57,7 +57,6 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
|
57
57
|
const { activeKey: stateActiveKey } = this.getStates();
|
|
58
58
|
if (stateActiveKey !== activeKey) this.adapter.setNewActiveKey(activeKey);
|
|
59
59
|
}
|
|
60
|
-
/** activeKey, else defaultActiveKey, else the first enabled entry of `list` that has a key */
|
|
61
60
|
static getDefaultActiveKey(props, list) {
|
|
62
61
|
if (props.activeKey !== void 0) return props.activeKey;
|
|
63
62
|
if (props.defaultActiveKey !== void 0) return props.defaultActiveKey;
|
|
@@ -71,7 +70,6 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
|
71
70
|
if (tabs.some((tab) => tab.itemKey === activeKey)) return;
|
|
72
71
|
return tabs.find((tab) => !tab.disabled)?.itemKey;
|
|
73
72
|
}
|
|
74
|
-
/** The slide-in class of a pane and whether it plays: only the selected pane slides, from the side of the previous one */
|
|
75
73
|
static getPaneMotion({ itemKey, activeKey, prevActiveKey, paneKeys, tabPosition, tabPaneMotion, forceDisableMotion }) {
|
|
76
74
|
const activeIndex = activeKey === null ? -1 : paneKeys.indexOf(activeKey);
|
|
77
75
|
const itemIndex = itemKey === void 0 ? -1 : paneKeys.indexOf(itemKey);
|
|
@@ -100,7 +98,6 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
|
100
98
|
forceDisableMotion: propsActiveKey === prev.propsActiveKey ? prev.forceDisableMotion : paneKeys.includes(propsActiveKey) && !prev.paneKeys.includes(propsActiveKey)
|
|
101
99
|
};
|
|
102
100
|
}
|
|
103
|
-
/** Splits `list` into the tabs that stay in the bar and the last `more` ones (or `more.count`) that move into the menu */
|
|
104
101
|
static splitMore(list, more) {
|
|
105
102
|
if (typeof more !== "number" && typeof more !== "object") throw new Error("[Semi Tabs]: invalid tab props format: more");
|
|
106
103
|
const keep = list.length - Math.min(typeof more === "number" ? more : more.count, list.length);
|
|
@@ -126,7 +123,6 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
|
126
123
|
inline: position
|
|
127
124
|
});
|
|
128
125
|
}
|
|
129
|
-
/** Re-keys the OverflowList visibility map by itemKey; `hasHidden` and `isShowInViewport` summarize it */
|
|
130
126
|
static readVisibleState(visibleMap) {
|
|
131
127
|
const visibleState = new Map([...visibleMap].map(([barItemKey, visible]) => [getItemKeyByBarItemKey(barItemKey), visible]));
|
|
132
128
|
const visibles = [...visibleState.values()];
|
package/dist/tabs/tabs.scss
CHANGED
|
@@ -56,12 +56,12 @@ $ignoreIcon: '.#{$prefix}-icon-checkbox_tick, .#{$prefix}-icon-radio, .#{$prefix
|
|
|
56
56
|
display: flex;
|
|
57
57
|
align-content: center;
|
|
58
58
|
|
|
59
|
+
// :not(:not(&-icon)) outranks the generic icon rules
|
|
59
60
|
&-icon:not(:not(&-icon)) {
|
|
60
61
|
display: flex;
|
|
61
62
|
flex-shrink: 0;
|
|
62
63
|
align-items: center;
|
|
63
64
|
margin-inline: $spacing-tabs_tab-more_trigger_icon-marginLeft $spacing-tabs_tab-more_trigger_icon-marginRight;
|
|
64
|
-
// :not(:not(&-icon)) outranks the generic icon rules
|
|
65
65
|
margin-top: $spacing-tabs_tab-more_trigger_icon-marginTop;
|
|
66
66
|
margin-bottom: $spacing-tabs_tab-more_trigger_icon-marginBottom;
|
|
67
67
|
}
|
package/dist/tag/focus.js
CHANGED
|
@@ -5,7 +5,6 @@ const tagCls = cssClasses.PREFIX;
|
|
|
5
5
|
function isReachableTag(node) {
|
|
6
6
|
return node instanceof HTMLElement && node.matches(`.${tagCls}:not(.${tagCls}-invisible)`) && node.tabIndex >= 0;
|
|
7
7
|
}
|
|
8
|
-
/** Prefers the following tag, falling back to the preceding one. */
|
|
9
8
|
function findAdjacentTag(tag) {
|
|
10
9
|
for (let node = tag.nextElementSibling; node; node = node.nextElementSibling) if (isReachableTag(node)) return node;
|
|
11
10
|
for (let node = tag.previousElementSibling; node; node = node.previousElementSibling) if (isReachableTag(node)) return node;
|
|
@@ -13,7 +13,6 @@ export interface TagSortIds {
|
|
|
13
13
|
ids: string[];
|
|
14
14
|
move?: OnSortEndProps;
|
|
15
15
|
}
|
|
16
|
-
/** The props the foundation reads with getProps */
|
|
17
16
|
export interface TagInputBaseProps {
|
|
18
17
|
value?: string[] | null;
|
|
19
18
|
inputValue?: string;
|
|
@@ -65,7 +64,6 @@ export default class TagInputFoundation<P extends TagInputBaseProps = TagInputBa
|
|
|
65
64
|
* values return `prev` itself, so a caller can skip the update and an untaken sort stays pending.
|
|
66
65
|
*/
|
|
67
66
|
static getSortIds(values: string[], prev?: TagSortIds): TagSortIds;
|
|
68
|
-
/** The input text on screen: a string `inputValue` prop wins over state */
|
|
69
67
|
static getInputValue(props: {
|
|
70
68
|
inputValue?: string;
|
|
71
69
|
}, state: {
|
|
@@ -107,7 +107,6 @@ var TagInputFoundation = class TagInputFoundation extends BaseFoundation {
|
|
|
107
107
|
ids: values.map((value) => unused.get(value)?.shift() ?? newId(value))
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
/** The input text on screen: a string `inputValue` prop wins over state */
|
|
111
110
|
static getInputValue(props, state) {
|
|
112
111
|
return typeof props.inputValue === "string" ? props.inputValue : state.inputValue;
|
|
113
112
|
}
|
|
@@ -5,7 +5,6 @@ import { tabbable } from "tabbable";
|
|
|
5
5
|
function tagStops(wrapper) {
|
|
6
6
|
return tabbable(wrapper, { displayCheck: "none" }).filter((node) => !node.closest(`.${cssClasses.PREFIX}-wrapper-input, .${cssClasses.PREFIX}-sortable-handle`));
|
|
7
7
|
}
|
|
8
|
-
/** The place of the focused element among the tags' tab stops in the TagInput's wrapper, or -1 */
|
|
9
8
|
function getFocusedTagStop(wrapper) {
|
|
10
9
|
return wrapper ? tagStops(wrapper).indexOf(FocusTrapHandle.getActiveElement(wrapper)) : -1;
|
|
11
10
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export type TimeStamp = Date | string | number;
|
|
2
2
|
export type ColumnType = 'ampm' | 'hour' | 'minute' | 'second';
|
|
3
|
-
/** The props one time panel is computed from */
|
|
4
3
|
export interface ComboboxBaseProps {
|
|
5
4
|
timeStampValue?: TimeStamp;
|
|
6
5
|
format?: string;
|
|
@@ -19,17 +18,15 @@ export declare function formatOption(option: number, disabledOptions: number[]):
|
|
|
19
18
|
value: string;
|
|
20
19
|
disabled: boolean;
|
|
21
20
|
};
|
|
22
|
-
/** Pure calculations for one time panel: which columns show, what each lists, and the time a picked item makes */
|
|
23
21
|
export default class ComboboxFoundation {
|
|
24
|
-
/** The columns `format` asks for */
|
|
25
22
|
static getColumns(format: string): {
|
|
26
23
|
showHour: boolean;
|
|
27
24
|
showMinute: boolean;
|
|
28
25
|
showSecond: boolean;
|
|
29
26
|
};
|
|
30
27
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
28
|
+
* Every column reads the shown time (midnight, or noon in a PM panel, while there is no value), the time a picked
|
|
29
|
+
* item is applied to.
|
|
33
30
|
*/
|
|
34
31
|
static getOptions(props: ComboboxBaseProps): {
|
|
35
32
|
isAM: boolean;
|
|
@@ -58,10 +55,7 @@ export default class ComboboxFoundation {
|
|
|
58
55
|
showMinute: boolean;
|
|
59
56
|
showSecond: boolean;
|
|
60
57
|
};
|
|
61
|
-
/**
|
|
62
|
-
* The time after picking `itemValue` in column `type`. A 12-hour hour keeps the half day `isAM` names; AM/PM moves
|
|
63
|
-
* the time by 12 hours only when it is in the other half day.
|
|
64
|
-
*/
|
|
58
|
+
/** A 12-hour hour keeps the half day `isAM` names; AM/PM moves the time by 12 hours only when it is in the other half day */
|
|
65
59
|
static applyItem(timeStampValue: TimeStamp, type: ColumnType, itemValue: string, use12Hours: boolean, isAM: boolean): Date;
|
|
66
60
|
/**
|
|
67
61
|
* `disabledHours()`, mapped onto the 12-hour column of the half day `isAM` names when `use12Hours`; the hours of
|
|
@@ -70,10 +64,8 @@ export default class ComboboxFoundation {
|
|
|
70
64
|
static getDisabledHours({ use12Hours, disabledHours, isAM }: Pick<ComboboxBaseProps, 'use12Hours' | 'disabledHours'> & {
|
|
71
65
|
isAM?: boolean;
|
|
72
66
|
}): number[];
|
|
73
|
-
/** The half day of the value; `defaultIsAM` applies while there is no value */
|
|
74
67
|
static isAM(timeStamp: TimeStamp, defaultIsAM?: boolean): boolean;
|
|
75
68
|
/** A timestamp of 0 is a value; only nothing and '' are not */
|
|
76
69
|
static hasValue(timeStamp: unknown): boolean;
|
|
77
|
-
/** The time a panel shows; without a value, today's midnight, or noon when the panel shows PM */
|
|
78
70
|
static getDisplayDateFromTimeStamp(timeStamp: TimeStamp, defaultIsPM?: boolean): Date;
|
|
79
71
|
}
|