@fibrae/semi-foundation 0.1.1 → 0.2.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 -1
- package/dist/anchor/foundation.js +21 -21
- package/dist/audio-player/foundation.d.ts +10 -10
- package/dist/audio-player/foundation.js +19 -19
- package/dist/auto-complete/foundation.d.ts +12 -12
- package/dist/auto-complete/foundation.js +51 -51
- package/dist/avatar/foundation.d.ts +5 -5
- package/dist/avatar/foundation.js +16 -16
- package/dist/backtop/foundation.d.ts +2 -2
- package/dist/backtop/foundation.js +7 -7
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -8
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -3
- package/dist/base/foundation.js +12 -11
- 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.js +1 -1
- package/dist/calendar/foundation.js +4 -4
- package/dist/calendar/month-foundation.d.ts +2 -2
- package/dist/calendar/month-foundation.js +6 -6
- package/dist/carousel/foundation.d.ts +17 -17
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +34 -26
- package/dist/cascader/foundation.js +143 -121
- package/dist/checkbox/checkbox-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-foundation.js +15 -15
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -1
- 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-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/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/cropper/foundation.d.ts +15 -15
- package/dist/cropper/foundation.js +26 -23
- package/dist/date-picker/_utils/picker-type.d.ts +1 -1
- package/dist/date-picker/foundation.d.ts +36 -36
- package/dist/date-picker/foundation.js +125 -129
- package/dist/date-picker/input-foundation.d.ts +9 -9
- package/dist/date-picker/input-foundation.js +28 -28
- package/dist/date-picker/months-grid-foundation.d.ts +16 -16
- package/dist/date-picker/months-grid-foundation.js +64 -65
- 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 -2
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -5
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -1
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -9
- package/dist/feedback/foundation.js +33 -33
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -61
- package/dist/highlight/foundation.js +1 -1
- package/dist/hot-keys/foundation.d.ts +2 -2
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -4
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -3
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -8
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -9
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -10
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -3
- package/dist/input/text-entry-foundation.js +14 -14
- package/dist/input/textarea-foundation.d.ts +7 -7
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/foundation.d.ts +16 -14
- package/dist/input-number/foundation.js +54 -53
- package/dist/json-viewer/foundation.d.ts +8 -8
- package/dist/json-viewer/foundation.js +23 -23
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +1 -1
- package/dist/markdown-render/foundation.js +4 -4
- 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 -1
- package/dist/navigation/foundation.js +14 -14
- 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 -3
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -7
- package/dist/notification/notification-list-foundation.js +12 -12
- package/dist/overflow-list/foundation.d.ts +4 -4
- package/dist/overflow-list/foundation.js +18 -18
- package/dist/pagination/foundation.d.ts +8 -8
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +5 -5
- package/dist/pincode/foundation.js +22 -22
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/radio/radio-foundation.d.ts +5 -5
- package/dist/radio/radio-foundation.js +15 -15
- package/dist/radio/radio-group-foundation.d.ts +2 -2
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -10
- package/dist/rating/foundation.js +35 -35
- package/dist/resizable/group/index.d.ts +6 -6
- package/dist/resizable/group/index.js +40 -40
- package/dist/resizable/single/index.d.ts +2 -2
- package/dist/resizable/single/index.js +9 -9
- package/dist/scroll-list/item-foundation.d.ts +7 -7
- package/dist/scroll-list/item-foundation.js +35 -35
- package/dist/select/foundation.d.ts +42 -56
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -27
- package/dist/select/option-foundation.js +10 -18
- package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
- package/dist/side-sheet/side-sheet-foundation.js +22 -22
- package/dist/slider/foundation.d.ts +16 -16
- package/dist/slider/foundation.js +46 -46
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -2
- package/dist/spin/foundation.js +6 -6
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -2
- package/dist/switch/foundation.js +7 -7
- package/dist/table/foundation.d.ts +14 -14
- package/dist/table/foundation.js +93 -93
- package/dist/table/utils.d.ts +2 -2
- package/dist/tabs/foundation.d.ts +5 -5
- package/dist/tabs/foundation.js +17 -17
- package/dist/tag-input/foundation.d.ts +11 -11
- package/dist/tag-input/foundation.js +52 -52
- package/dist/time-picker/foundation.d.ts +13 -13
- package/dist/time-picker/foundation.js +39 -39
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/foundation.d.ts +9 -9
- package/dist/tooltip/foundation.js +67 -61
- package/dist/transfer/foundation.d.ts +22 -9
- package/dist/transfer/foundation.js +38 -23
- package/dist/tree/foundation.d.ts +14 -14
- package/dist/tree/foundation.js +61 -61
- package/dist/tree/shared.d.ts +1 -1
- package/dist/tree-select/foundation.d.ts +26 -20
- package/dist/tree-select/foundation.js +91 -83
- package/dist/typography/ellipsis.d.ts +4 -4
- package/dist/typography/ellipsis.js +8 -8
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -17
- package/dist/upload/foundation.js +92 -92
- package/dist/upload/utils.d.ts +3 -3
- package/dist/upload/utils.js +6 -6
- package/dist/user-guide/foundation.d.ts +3 -3
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +1 -1
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/focus-handle.d.ts +1 -1
- package/dist/utils/focus-handle.js +1 -2
- package/dist/utils/focus-scope.d.ts +5 -5
- package/dist/utils/focus-scope.js +10 -10
- 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/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -2
- package/dist/video-player/progress-foundation.js +12 -12
- package/package.json +2 -2
|
@@ -202,7 +202,7 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
202
202
|
static getAllRowKeys<R>(props: BaseTableDataProps<R>, dataSource: R[]): BaseRowKeyType[];
|
|
203
203
|
/** scrollLeft is 0 at the start edge and negative in RTL; a pixel of slack absorbs fractional scroll positions */
|
|
204
204
|
static getScrollableEdges({ scrollLeft, scrollWidth, clientWidth, rtl }: TableScrollMetrics): TableScrollableEdges;
|
|
205
|
-
static readScrollMetrics(body
|
|
205
|
+
static readScrollMetrics(body?: HTMLElement | null): TableScrollMetrics | null;
|
|
206
206
|
/** The attributes sit on the container, the ancestor shared by the header and body scrollers */
|
|
207
207
|
static writeScrollableEdges(body: HTMLElement | null | undefined, { left, right }: TableScrollableEdges): void;
|
|
208
208
|
static hasRowSelected(selectedRowKeys: BaseRowKeyType[], allRowKeysSet: Set<BaseRowKeyType>): boolean;
|
|
@@ -239,35 +239,35 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
239
239
|
*/
|
|
240
240
|
static getInitialState<R, C extends BaseColumnProps<R> = BaseColumnProps<R>>(props: TableBaseProps<R>, flattenColumns: C[], queries: C[]): TableColumnsState<R, C>;
|
|
241
241
|
/** Hosts call it after mount, on body scroll and when the table or its content resizes */
|
|
242
|
-
syncScrollEdges()
|
|
242
|
+
syncScrollEdges: () => void;
|
|
243
243
|
init(): void;
|
|
244
244
|
/**
|
|
245
245
|
* @param prevProps the props of the previous commit
|
|
246
246
|
* @param prevFlattenColumns the flattenColumns state of the previous commit
|
|
247
247
|
*/
|
|
248
|
-
handleUpdate(prevProps:
|
|
248
|
+
handleUpdate: (prevProps: TableBaseProps<RecordType>, prevFlattenColumns: TableBaseState<RecordType>["flattenColumns"]) => void;
|
|
249
249
|
initExpandedRowKeys({ groups }?: {
|
|
250
250
|
groups?: Map<string | number, Set<BaseRowKeyType>>;
|
|
251
251
|
}): void;
|
|
252
|
-
getCurrentPageData(dataSource?: RecordType[], pagination?: BasePagination, queries?: BaseColumnProps<RecordType>[])
|
|
252
|
+
getCurrentPageData: (dataSource?: RecordType[], pagination?: BasePagination, queries?: BaseColumnProps<RecordType>[]) => BasePageData<RecordType>;
|
|
253
253
|
/** Scrolls back to the first row; a pagination.onChange that takes over paging still gets the scroll */
|
|
254
|
-
resetScrollY()
|
|
254
|
+
resetScrollY: () => void;
|
|
255
255
|
setPage: (currentPage: number, currentPageSize: number) => void;
|
|
256
|
-
handleSelectRow(realKey: BaseRowKeyType, selected: boolean, e
|
|
257
|
-
handleSelectAllRow(selected: boolean, e
|
|
258
|
-
handleRowExpanded(expanded: boolean, realKey: BaseRowKeyType, domEvent: any)
|
|
259
|
-
toggleShowFilter(dataIndex: string, visible: boolean)
|
|
260
|
-
handleFilterSelect(dataIndex: string, data?: {
|
|
256
|
+
handleSelectRow: (realKey: BaseRowKeyType, selected: boolean, e?: Pick<Event, "stopPropagation">) => void;
|
|
257
|
+
handleSelectAllRow: (selected: boolean, e?: Pick<Event, "stopPropagation">) => void;
|
|
258
|
+
handleRowExpanded: (expanded: boolean, realKey: BaseRowKeyType, domEvent: any) => void;
|
|
259
|
+
toggleShowFilter: (dataIndex: string, visible: boolean) => void;
|
|
260
|
+
handleFilterSelect: (dataIndex: string, data?: {
|
|
261
261
|
filteredValue?: string[];
|
|
262
|
-
})
|
|
263
|
-
handleSort({ dataIndex }?: {
|
|
262
|
+
}) => void;
|
|
263
|
+
handleSort: ({ dataIndex }?: {
|
|
264
264
|
dataIndex?: string;
|
|
265
265
|
sortOrder?: BaseSortOrder;
|
|
266
|
-
})
|
|
266
|
+
}) => void;
|
|
267
267
|
/**
|
|
268
268
|
* Select or deselect a row by clicking it when rowSelection.clickRow is set
|
|
269
269
|
*/
|
|
270
|
-
handleRowClickSelection(rowKey: BaseRowKeyType, selected: boolean, e: Pick<Event,
|
|
270
|
+
handleRowClickSelection: (rowKey: BaseRowKeyType, selected: boolean, e: Pick<Event, "stopPropagation">) => void;
|
|
271
271
|
}
|
|
272
272
|
export type BaseRowKeyType = string | number;
|
|
273
273
|
export type BaseRowKey<RecordType> = BaseRowKeyType | ((record: RecordType) => BaseRowKeyType);
|
package/dist/table/foundation.js
CHANGED
|
@@ -36,8 +36,8 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
36
36
|
pagination = pagination == null ? this.#getPagination() : pagination;
|
|
37
37
|
filters = filters == null ? this.#getAllFilters() : filters;
|
|
38
38
|
sorter = sorter == null ? this.#getAllSorters()[0] : sorter;
|
|
39
|
-
if (this.getProp("scroll")?.scrollToFirstRowOnChange) this.
|
|
40
|
-
this.
|
|
39
|
+
if (this.getProp("scroll")?.scrollToFirstRowOnChange) this.adapter.resetScrollY();
|
|
40
|
+
this.adapter.notifyChange({
|
|
41
41
|
pagination: { ...pagination },
|
|
42
42
|
filters: [...filters],
|
|
43
43
|
sorter,
|
|
@@ -109,7 +109,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
109
109
|
return queries;
|
|
110
110
|
}
|
|
111
111
|
#getGroups() {
|
|
112
|
-
if (this.
|
|
112
|
+
if (this.adapter.getProp("groupBy") !== null) return this.adapter.getState("groups");
|
|
113
113
|
return null;
|
|
114
114
|
}
|
|
115
115
|
#initSelectedRowKeys(keyEntities) {
|
|
@@ -122,7 +122,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
122
122
|
if (controlled) this.#addNoDuplicatedItemsToArr(rowKeys, selectedRowKeys);
|
|
123
123
|
else if (Array.isArray(defaultSelectedRowKeys)) this.#addNoDuplicatedItemsToArr(rowKeys, defaultSelectedRowKeys);
|
|
124
124
|
let halfCheckedRowKeys = [];
|
|
125
|
-
if (this.
|
|
125
|
+
if (this.adapter.getCheckRelation() === "related") {
|
|
126
126
|
const related = TableFoundation.#getRelatedCheckedRowKeys(rowKeys, keyEntities);
|
|
127
127
|
halfCheckedRowKeys = related.halfCheckedRowKeys;
|
|
128
128
|
if (!controlled) {
|
|
@@ -130,24 +130,24 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
130
130
|
rowKeys = [...rowKeys, ...related.checkedRowKeys.filter((key) => !known.has(String(key)))];
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
this.
|
|
134
|
-
this.
|
|
133
|
+
this.adapter.setSelectedRowKeys(rowKeys);
|
|
134
|
+
this.adapter.setHalfCheckedRowKeys(halfCheckedRowKeys);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
#setAdapterPageData({ pagination, dataSource, disabledRowKeys, allRowKeys, groups } = {}) {
|
|
138
|
-
this.
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
138
|
+
this.adapter.setPageDisabledRowKeys(disabledRowKeys);
|
|
139
|
+
this.adapter.setAllRowKeys(allRowKeys);
|
|
140
|
+
this.adapter.setPagination(pagination);
|
|
141
|
+
this.adapter.setGroups(groups);
|
|
142
|
+
this.adapter.setDataSource(dataSource);
|
|
143
143
|
}
|
|
144
144
|
#setCachedFilteredSortedDataSource(filteredSortedDataSource) {
|
|
145
|
-
this.
|
|
145
|
+
this.adapter.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
146
146
|
const filteredSortedRowKeys = this.getAllRowKeys(filteredSortedDataSource);
|
|
147
|
-
this.
|
|
147
|
+
this.adapter.setCachedFilteredSortedRowKeys(filteredSortedRowKeys);
|
|
148
148
|
}
|
|
149
149
|
#setFilteredDisabledRowKeys(disabledRowKeys) {
|
|
150
|
-
this.
|
|
150
|
+
this.adapter.setFilteredDisabledRowKeys(disabledRowKeys);
|
|
151
151
|
}
|
|
152
152
|
#applyQueries(queries) {
|
|
153
153
|
const dataSource = [...this.getProp("dataSource")];
|
|
@@ -161,8 +161,8 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
161
161
|
/** Rebuilds the tree of a related selection; the half-checked rows follow from it and the selected keys */
|
|
162
162
|
#updateKeyEntities() {
|
|
163
163
|
const keyEntities = this.buildKeyEntities(this.getProp("dataSource"));
|
|
164
|
-
this.
|
|
165
|
-
this.
|
|
164
|
+
this.adapter.setKeyEntities(keyEntities);
|
|
165
|
+
this.adapter.setHalfCheckedRowKeys(TableFoundation.#getRelatedCheckedRowKeys(this.#getSelectedRowKeys(), keyEntities).halfCheckedRowKeys);
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* @param dataSourceChanged the dataSource prop changed: the uncontrolled page goes back to 1
|
|
@@ -178,7 +178,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
178
178
|
this.#setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
179
179
|
this.#setFilteredDisabledRowKeys(allDataDisabledRowKeys);
|
|
180
180
|
states.dataSource = filteredSortedDataSource;
|
|
181
|
-
if (this.
|
|
181
|
+
if (this.adapter.getCheckRelation() === "related") this.#updateKeyEntities();
|
|
182
182
|
if (groupBy) states.groups = null;
|
|
183
183
|
}
|
|
184
184
|
if (dataSourceChanged) states.pagination = isObject(statePagination) ? {
|
|
@@ -187,15 +187,15 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
187
187
|
} : statePagination;
|
|
188
188
|
if (Object.keys(states).length) {
|
|
189
189
|
const pageData = this.getCurrentPageData(states.dataSource ?? null, states.pagination ?? (statePagination && { ...statePagination }), null);
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
190
|
+
this.adapter.setAllRowKeys(pageData.allRowKeys);
|
|
191
|
+
this.adapter.setPageDisabledRowKeys(pageData.disabledRowKeys);
|
|
192
192
|
if ("dataSource" in states) {
|
|
193
193
|
if (defaultExpandAllRows && dataSourceChanged && pageData.groups?.size && !this.#rowExpansionIsControlled() || expandAllRows || expandAllGroupRows) this.initExpandedRowKeys(pageData);
|
|
194
|
-
this.
|
|
194
|
+
this.adapter.setDataSource(pageData.dataSource);
|
|
195
195
|
states.pagination = pageData.pagination;
|
|
196
196
|
}
|
|
197
|
-
if ("groups" in states) this.
|
|
198
|
-
if ("pagination" in states) this.
|
|
197
|
+
if ("groups" in states) this.adapter.setGroups(pageData.groups);
|
|
198
|
+
if ("pagination" in states) this.adapter.setPagination(pageData.pagination);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
getFilteredSortedDataSource(dataSource, queries) {
|
|
@@ -229,7 +229,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
229
229
|
return keyEntities;
|
|
230
230
|
}
|
|
231
231
|
calcCheckedKeysForSelect(realKey, selected, checkedKeys, halfCheckedKeys) {
|
|
232
|
-
const keyEntities = this.
|
|
232
|
+
const keyEntities = this.adapter.getKeyEntities();
|
|
233
233
|
const keyStr = String(realKey);
|
|
234
234
|
if (!keyEntities || !keyEntities[keyStr]) {
|
|
235
235
|
if (selected) checkedKeys.add(keyStr);
|
|
@@ -526,7 +526,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
526
526
|
const stateSortOrder = query?.sortOrder;
|
|
527
527
|
return {
|
|
528
528
|
query,
|
|
529
|
-
sortOrder: TableFoundation.isSortOrderValid(stateSortOrder) ? stateSortOrder :
|
|
529
|
+
sortOrder: TableFoundation.isSortOrderValid(stateSortOrder) ? stateSortOrder : query?.defaultSortOrder ?? false,
|
|
530
530
|
filteredValue: query?.filteredValue ? query.filteredValue : query?.defaultFilteredValue
|
|
531
531
|
};
|
|
532
532
|
}
|
|
@@ -603,7 +603,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
603
603
|
preExpandedRowKeys: props.expandedRowKeys,
|
|
604
604
|
rowSelection: props.rowSelection ? isObject(props.rowSelection) ? { ...props.rowSelection } : {} : null,
|
|
605
605
|
pagination: pageData.pagination,
|
|
606
|
-
groups: null,
|
|
606
|
+
groups: pageData.groups ?? null,
|
|
607
607
|
allRowKeys: [],
|
|
608
608
|
pageDisabledRowKeys: [],
|
|
609
609
|
pageDisabledRowKeysSet: /* @__PURE__ */ new Set(),
|
|
@@ -626,14 +626,14 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
626
626
|
};
|
|
627
627
|
}
|
|
628
628
|
/** Hosts call it after mount, on body scroll and when the table or its content resizes */
|
|
629
|
-
syncScrollEdges() {
|
|
629
|
+
syncScrollEdges = () => {
|
|
630
630
|
this.#trackScrollEdges ??= !CSS.supports("container-type", "scroll-state");
|
|
631
|
-
const metrics = this.#trackScrollEdges ? this.
|
|
632
|
-
if (metrics) this.
|
|
633
|
-
}
|
|
631
|
+
const metrics = this.#trackScrollEdges ? this.adapter.getScrollMetrics() : null;
|
|
632
|
+
if (metrics) this.adapter.setScrollableEdges(TableFoundation.getScrollableEdges(metrics));
|
|
633
|
+
};
|
|
634
634
|
init() {
|
|
635
635
|
const dataSource = this.getProp("dataSource");
|
|
636
|
-
const { queries } = this.
|
|
636
|
+
const { queries } = this.adapter.getStates();
|
|
637
637
|
const filteredSortedDataSource = this.getFilteredSortedDataSource(dataSource, queries);
|
|
638
638
|
const allDataDisabledRowKeys = this.getAllDisabledRowKeys(filteredSortedDataSource);
|
|
639
639
|
const pageData = this.getCurrentPageData(filteredSortedDataSource);
|
|
@@ -643,9 +643,9 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
643
643
|
this.#defaultKeysApplied = true;
|
|
644
644
|
if (applyDefaultKeys && !(defaultExpandAllRows && !expandAllRows && !expandAllGroupRows && pageData.groups?.size && this.#rowExpansionIsControlled())) this.initExpandedRowKeys(pageData);
|
|
645
645
|
let keyEntities = {};
|
|
646
|
-
if (this.
|
|
646
|
+
if (this.adapter.getCheckRelation() === "related" && dataSource && dataSource.length) {
|
|
647
647
|
keyEntities = this.buildKeyEntities(dataSource);
|
|
648
|
-
this.
|
|
648
|
+
this.adapter.setKeyEntities(keyEntities);
|
|
649
649
|
}
|
|
650
650
|
if (applyDefaultKeys) this.#initSelectedRowKeys(keyEntities);
|
|
651
651
|
this.#setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
@@ -655,7 +655,7 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
655
655
|
* @param prevProps the props of the previous commit
|
|
656
656
|
* @param prevFlattenColumns the flattenColumns state of the previous commit
|
|
657
657
|
*/
|
|
658
|
-
handleUpdate(prevProps, prevFlattenColumns) {
|
|
658
|
+
handleUpdate = (prevProps, prevFlattenColumns) => {
|
|
659
659
|
const props = this.getProps();
|
|
660
660
|
const flattenColumns = this.getState("flattenColumns");
|
|
661
661
|
if ((props.rowSelection || props.expandedRowRender || flattenColumns.some((column) => column.onFilter)) && props.dataSource?.some((record) => TableFoundation.getRecordKey(props, record) == null)) {
|
|
@@ -664,9 +664,9 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
664
664
|
if (props.expandAllRows !== prevProps.expandAllRows || props.expandAllGroupRows !== prevProps.expandAllGroupRows) this.initExpandedRowKeys({ groups: this.getState("groups") });
|
|
665
665
|
const dataSourceChanged = props.dataSource !== prevProps.dataSource;
|
|
666
666
|
const recompute = dataSourceChanged || flattenColumns !== prevFlattenColumns;
|
|
667
|
-
if (this.
|
|
667
|
+
if (this.adapter.getCheckRelation() === "related" && !(isObject(prevProps.rowSelection) && prevProps.rowSelection.checkRelation === "related") && !recompute) this.#updateKeyEntities();
|
|
668
668
|
this.#handleDataUpdate(dataSourceChanged, recompute);
|
|
669
|
-
}
|
|
669
|
+
};
|
|
670
670
|
initExpandedRowKeys({ groups } = {}) {
|
|
671
671
|
const { defaultExpandAllRows, defaultExpandedRowKeys = [], expandedRowKeys: propExpandedRowKeys = [], dataSource = [], expandAllRows, defaultExpandAllGroupRows, expandAllGroupRows } = this.getProps();
|
|
672
672
|
const expandedRowKeys = [];
|
|
@@ -674,21 +674,21 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
674
674
|
else if (defaultExpandAllGroupRows || expandAllGroupRows) this.#addNoDuplicatedItemsToArr(expandedRowKeys, propExpandedRowKeys, groups && groups instanceof Map && groups.size ? Array.from(groups.keys()) : []);
|
|
675
675
|
else if (Array.isArray(defaultExpandedRowKeys) && defaultExpandedRowKeys.length) this.#addNoDuplicatedItemsToArr(expandedRowKeys, defaultExpandedRowKeys);
|
|
676
676
|
else if (Array.isArray(propExpandedRowKeys) && propExpandedRowKeys.length) this.#addNoDuplicatedItemsToArr(expandedRowKeys, propExpandedRowKeys);
|
|
677
|
-
this.
|
|
677
|
+
this.adapter.setExpandedRowKeys(expandedRowKeys);
|
|
678
678
|
}
|
|
679
|
-
getCurrentPageData(dataSource, pagination, queries) {
|
|
680
|
-
const filteredSortedDataSource = this.
|
|
679
|
+
getCurrentPageData = (dataSource, pagination, queries) => {
|
|
680
|
+
const filteredSortedDataSource = this.adapter.getCachedFilteredSortedDataSource();
|
|
681
681
|
dataSource = dataSource == null ? [...filteredSortedDataSource] : dataSource;
|
|
682
682
|
pagination = pagination == null ? this.getState("pagination") && { ...this.getState("pagination") } : pagination;
|
|
683
683
|
queries = queries == null ? [...this.getState("queries")] : queries;
|
|
684
684
|
return TableFoundation.getPageData(this.getProps(), dataSource, pagination, queries);
|
|
685
|
-
}
|
|
685
|
+
};
|
|
686
686
|
/** Scrolls back to the first row; a pagination.onChange that takes over paging still gets the scroll */
|
|
687
|
-
resetScrollY() {
|
|
688
|
-
this.
|
|
689
|
-
}
|
|
687
|
+
resetScrollY = () => {
|
|
688
|
+
this.adapter.resetScrollY();
|
|
689
|
+
};
|
|
690
690
|
setPage = (currentPage, currentPageSize) => {
|
|
691
|
-
currentPage = currentPage || this.
|
|
691
|
+
currentPage = currentPage || this.adapter.getCurrentPage();
|
|
692
692
|
const currentPagination = this.getState("pagination");
|
|
693
693
|
const { dataSource, pagination, disabledRowKeys, allRowKeys } = this.getCurrentPageData(null, {
|
|
694
694
|
...currentPagination,
|
|
@@ -696,19 +696,19 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
696
696
|
pageSize: currentPageSize
|
|
697
697
|
});
|
|
698
698
|
if (!TableFoundation.#pagerIsControlled(this.getProps()) && currentPage > 0) {
|
|
699
|
-
this.
|
|
700
|
-
this.
|
|
701
|
-
this.
|
|
702
|
-
this.
|
|
699
|
+
this.adapter.setPageDisabledRowKeys(disabledRowKeys);
|
|
700
|
+
this.adapter.setAllRowKeys(allRowKeys);
|
|
701
|
+
this.adapter.setPagination(pagination);
|
|
702
|
+
this.adapter.setDataSource(dataSource);
|
|
703
703
|
}
|
|
704
704
|
this.#notifyChange(pagination, void 0, void 0, { changeType: "pagination" });
|
|
705
705
|
};
|
|
706
|
-
handleSelectRow(realKey, selected, e) {
|
|
706
|
+
handleSelectRow = (realKey, selected, e) => {
|
|
707
707
|
e?.stopPropagation();
|
|
708
708
|
if (typeof selected === "boolean" && realKey != null) {
|
|
709
|
-
const checkRelation = this.
|
|
709
|
+
const checkRelation = this.adapter.getCheckRelation();
|
|
710
710
|
const selectedRowKeys = this.#getSelectedRowKeys();
|
|
711
|
-
const halfCheckedRowKeys = [...this.
|
|
711
|
+
const halfCheckedRowKeys = [...this.adapter.getHalfCheckedRowKeys() || []];
|
|
712
712
|
let foundIdx = -1;
|
|
713
713
|
const selectedRow = this.getRecordsByKeys(null, [realKey])[0];
|
|
714
714
|
let selectedRows;
|
|
@@ -716,43 +716,43 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
716
716
|
const checkedKeysSet = new Set(selectedRowKeys.map((key) => String(key)));
|
|
717
717
|
const halfCheckedKeysSet = new Set(halfCheckedRowKeys.map((key) => String(key)));
|
|
718
718
|
const { checkedKeys, halfCheckedKeys } = this.calcCheckedKeysForSelect(String(realKey), selected, checkedKeysSet, halfCheckedKeysSet);
|
|
719
|
-
const keyEntities = this.
|
|
719
|
+
const keyEntities = this.adapter.getKeyEntities();
|
|
720
720
|
const newSelectedRowKeys = TableFoundation.#restoreRowKeys(checkedKeys, [...selectedRowKeys, realKey], keyEntities);
|
|
721
721
|
const newHalfCheckedRowKeys = TableFoundation.#restoreRowKeys(halfCheckedKeys, halfCheckedRowKeys, keyEntities);
|
|
722
722
|
selectedRows = this.getRecordsByKeys(null, newSelectedRowKeys);
|
|
723
723
|
if (!this.#selectionIsControlled()) {
|
|
724
|
-
this.
|
|
725
|
-
this.
|
|
724
|
+
this.adapter.setSelectedRowKeys(newSelectedRowKeys);
|
|
725
|
+
this.adapter.setHalfCheckedRowKeys(newHalfCheckedRowKeys);
|
|
726
726
|
}
|
|
727
|
-
this.
|
|
728
|
-
this.
|
|
727
|
+
this.adapter.notifySelect(selectedRow, selected, selectedRows, e);
|
|
728
|
+
this.adapter.notifySelectionChange(newSelectedRowKeys, selectedRows);
|
|
729
729
|
} else if ((foundIdx = selectedRowKeys.indexOf(realKey)) > -1 && selected === false) {
|
|
730
730
|
selectedRowKeys.splice(foundIdx, 1);
|
|
731
731
|
selectedRows = this.getRecordsByKeys(null, selectedRowKeys);
|
|
732
|
-
if (!this.#selectionIsControlled()) this.
|
|
733
|
-
this.
|
|
734
|
-
this.
|
|
732
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
733
|
+
this.adapter.notifySelect(selectedRow, selected, selectedRows, e);
|
|
734
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
735
735
|
} else if (selectedRowKeys.indexOf(realKey) === -1 && selected === true) {
|
|
736
736
|
selectedRowKeys.push(realKey);
|
|
737
737
|
selectedRows = this.getRecordsByKeys(null, selectedRowKeys);
|
|
738
|
-
if (!this.#selectionIsControlled()) this.
|
|
739
|
-
this.
|
|
740
|
-
this.
|
|
738
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
739
|
+
this.adapter.notifySelect(selectedRow, selected, selectedRows, e);
|
|
740
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
|
-
}
|
|
744
|
-
handleSelectAllRow(selected, e) {
|
|
743
|
+
};
|
|
744
|
+
handleSelectAllRow = (selected, e) => {
|
|
745
745
|
e?.stopPropagation();
|
|
746
746
|
if (typeof selected === "boolean") {
|
|
747
|
-
const checkRelation = this.
|
|
747
|
+
const checkRelation = this.adapter.getCheckRelation();
|
|
748
748
|
const curSelectedRowKeys = this.#getSelectedRowKeys();
|
|
749
749
|
let selectedRowKeys = [...curSelectedRowKeys];
|
|
750
750
|
const selectedRowKeysSet = this.#getSelectedRowKeysSet();
|
|
751
|
-
const disabledRowKeysSet = this.
|
|
752
|
-
const scopeRowKeys = this.
|
|
751
|
+
const disabledRowKeysSet = this.adapter.getFilteredDisabledRowKeysSet();
|
|
752
|
+
const scopeRowKeys = this.adapter.getCachedFilteredSortedRowKeys().filter((key) => !disabledRowKeysSet.has(key));
|
|
753
753
|
if (checkRelation === "related") {
|
|
754
|
-
const keyEntities = this.
|
|
755
|
-
const halfCheckedRowKeys = [...this.
|
|
754
|
+
const keyEntities = this.adapter.getKeyEntities();
|
|
755
|
+
const halfCheckedRowKeys = [...this.adapter.getHalfCheckedRowKeys() || []];
|
|
756
756
|
let checkedKeysSet = new Set(selectedRowKeys.map((key) => String(key)));
|
|
757
757
|
let halfCheckedKeysSet = new Set(halfCheckedRowKeys.map((key) => String(key)));
|
|
758
758
|
if (selected) {
|
|
@@ -771,31 +771,31 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
771
771
|
const changedRows = this.getRecordsByKeys(null, getChangedRowKeys(curSelectedRowKeys, selectedRowKeys));
|
|
772
772
|
const selectedRows = this.getRecordsByKeys(null, selectedRowKeys || []);
|
|
773
773
|
if (!this.#selectionIsControlled()) {
|
|
774
|
-
this.
|
|
775
|
-
this.
|
|
774
|
+
this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
775
|
+
this.adapter.setHalfCheckedRowKeys(newHalfCheckedRowKeys);
|
|
776
776
|
}
|
|
777
|
-
this.
|
|
778
|
-
this.
|
|
777
|
+
this.adapter.notifySelectAll(selected, selectedRows, changedRows, e);
|
|
778
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
779
779
|
} else {
|
|
780
780
|
if (selected) {
|
|
781
781
|
for (const key of scopeRowKeys) if (!selectedRowKeysSet.has(key)) selectedRowKeys.push(key);
|
|
782
782
|
} else selectedRowKeys = differenceUnique(selectedRowKeys, scopeRowKeys);
|
|
783
783
|
const changedRows = this.getRecordsByKeys(null, getChangedRowKeys(curSelectedRowKeys, selectedRowKeys));
|
|
784
784
|
const selectedRows = this.getRecordsByKeys(null, selectedRowKeys || []);
|
|
785
|
-
if (!this.#selectionIsControlled()) this.
|
|
786
|
-
this.
|
|
787
|
-
this.
|
|
785
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
786
|
+
this.adapter.notifySelectAll(selected, selectedRows, changedRows, e);
|
|
787
|
+
this.adapter.notifySelectionChange(selectedRowKeys, selectedRows);
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
|
-
}
|
|
791
|
-
handleRowExpanded(expanded, realKey, domEvent) {
|
|
790
|
+
};
|
|
791
|
+
handleRowExpanded = (expanded, realKey, domEvent) => {
|
|
792
792
|
domEvent?.stopPropagation();
|
|
793
793
|
const expandedRowKeys = [...this.getState("expandedRowKeys")];
|
|
794
794
|
const index = expandedRowKeys.indexOf(realKey);
|
|
795
795
|
const keyIsValid = typeof realKey === "string" || typeof realKey === "number";
|
|
796
796
|
if (keyIsValid && expanded && index === -1) expandedRowKeys.push(realKey);
|
|
797
797
|
else if (keyIsValid && !expanded && index > -1) expandedRowKeys.splice(index, 1);
|
|
798
|
-
if (!this.#rowExpansionIsControlled()) this.
|
|
798
|
+
if (!this.#rowExpansionIsControlled()) this.adapter.setExpandedRowKeys(expandedRowKeys);
|
|
799
799
|
const expandedRows = this.getRecordsByKeys(null, expandedRowKeys);
|
|
800
800
|
let expandedRow = this.getRecordsByKeys(null, [realKey])[0];
|
|
801
801
|
const groups = this.#getGroups();
|
|
@@ -803,13 +803,13 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
803
803
|
if (groups.has(realKey)) expandedRow = { groupKey: realKey };
|
|
804
804
|
for (const groupKey of expandedRowKeys) if (groups.has(groupKey)) expandedRows.push({ groupKey });
|
|
805
805
|
}
|
|
806
|
-
this.
|
|
807
|
-
this.
|
|
808
|
-
}
|
|
809
|
-
toggleShowFilter(dataIndex, visible) {
|
|
810
|
-
this.
|
|
811
|
-
}
|
|
812
|
-
handleFilterSelect(dataIndex, data = {}) {
|
|
806
|
+
this.adapter.notifyExpand(expanded, expandedRow, domEvent);
|
|
807
|
+
this.adapter.notifyExpandedRowsChange(expandedRows, [...expandedRowKeys]);
|
|
808
|
+
};
|
|
809
|
+
toggleShowFilter = (dataIndex, visible) => {
|
|
810
|
+
this.adapter.notifyFilterDropdownVisibleChange(visible, dataIndex);
|
|
811
|
+
};
|
|
812
|
+
handleFilterSelect = (dataIndex, data = {}) => {
|
|
813
813
|
const query = {
|
|
814
814
|
...this.getQuery(dataIndex),
|
|
815
815
|
filteredValue: data.filteredValue
|
|
@@ -819,12 +819,12 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
819
819
|
const pagination = this.#getPagination();
|
|
820
820
|
const sorter = this.#getAllSorters()[0];
|
|
821
821
|
if (!this.#filterIsControlled(dataIndex)) {
|
|
822
|
-
this.
|
|
822
|
+
this.adapter.setQueries(queries);
|
|
823
823
|
this.#applyQueries(queries);
|
|
824
824
|
}
|
|
825
825
|
this.#notifyChange(pagination, filters, sorter, { changeType: "filter" });
|
|
826
|
-
}
|
|
827
|
-
handleSort({ dataIndex } = {}) {
|
|
826
|
+
};
|
|
827
|
+
handleSort = ({ dataIndex } = {}) => {
|
|
828
828
|
let queries = this.getState("queries");
|
|
829
829
|
let curQuery = null;
|
|
830
830
|
queries = [...queries];
|
|
@@ -849,22 +849,22 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
849
849
|
const pagination = this.#getPagination();
|
|
850
850
|
const filters = this.#getAllFilters();
|
|
851
851
|
if (!this.#sorterIsControlled(dataIndex)) {
|
|
852
|
-
this.
|
|
852
|
+
this.adapter.setQueries(queries);
|
|
853
853
|
this.#applyQueries(queries);
|
|
854
854
|
}
|
|
855
855
|
this.#notifyChange(pagination, filters, curQuery, { changeType: "sorter" });
|
|
856
|
-
}
|
|
856
|
+
};
|
|
857
857
|
/**
|
|
858
858
|
* Select or deselect a row by clicking it when rowSelection.clickRow is set
|
|
859
859
|
*/
|
|
860
|
-
handleRowClickSelection(rowKey, selected, e) {
|
|
860
|
+
handleRowClickSelection = (rowKey, selected, e) => {
|
|
861
861
|
const rowSelection = this.getState("rowSelection");
|
|
862
862
|
if (rowSelection?.clickRow && !rowSelection.disabled) {
|
|
863
863
|
const getCheckboxProps = rowSelection?.getCheckboxProps;
|
|
864
|
-
const record = this.
|
|
864
|
+
const record = this.adapter.getCachedFilteredSortedDataSource().find((r) => this.getRecordKey(r) === rowKey);
|
|
865
865
|
if (record && typeof getCheckboxProps === "function" && getCheckboxProps(record).disabled) return;
|
|
866
866
|
this.handleSelectRow(rowKey, selected, e);
|
|
867
867
|
}
|
|
868
|
-
}
|
|
868
|
+
};
|
|
869
869
|
};
|
|
870
870
|
export { TableFoundation as default };
|
package/dist/table/utils.d.ts
CHANGED
|
@@ -48,9 +48,9 @@ export declare function placeInnerColumns<T extends {
|
|
|
48
48
|
fixed?: unknown;
|
|
49
49
|
}>(columns: T[], innerColumns: (T | null)[]): T[];
|
|
50
50
|
/** The measured widths of the columns in order; a column not measured yet is skipped */
|
|
51
|
-
export declare function getCellWidths(headWidths
|
|
51
|
+
export declare function getCellWidths(headWidths?: BaseHeadWidth[][], columns?: {
|
|
52
52
|
key?: unknown;
|
|
53
|
-
}[]
|
|
53
|
+
}[]): number[];
|
|
54
54
|
export declare function sliceColumnsByLevel(columns: any[], targetLevel?: number, childrenColumnName?: string, currentLevel?: number): any[];
|
|
55
55
|
export declare function getColumnsByLevel(columns: Record<string, any>[], targetLevel?: number, targetColumns?: Record<string, any>[], currentLevel?: number, childrenColumnName?: string): Record<string, any>[];
|
|
56
56
|
export declare function findColumn(columns: Record<string, any>[], column: Record<string, any>, childrenColumnName?: string): any;
|
|
@@ -13,7 +13,7 @@ export type MotionViewInput = Pick<MotionView, 'activeKey' | 'propsActiveKey' |
|
|
|
13
13
|
export type TabKeyEvent = Pick<KeyboardEvent, 'key' | 'altKey' | 'ctrlKey' | 'metaKey' | 'target' | 'currentTarget' | 'preventDefault' | 'stopPropagation'>;
|
|
14
14
|
/** What a pane's slide-in depends on */
|
|
15
15
|
export interface PaneMotionInput {
|
|
16
|
-
itemKey
|
|
16
|
+
itemKey?: string;
|
|
17
17
|
activeKey: string | null;
|
|
18
18
|
/** The key selected before activeKey, null on mount */
|
|
19
19
|
prevActiveKey: string | null;
|
|
@@ -82,10 +82,10 @@ export default class TabsFoundation<P extends TabsBaseProps = TabsBaseProps, S e
|
|
|
82
82
|
isShowInViewport: boolean;
|
|
83
83
|
hasHidden: boolean;
|
|
84
84
|
};
|
|
85
|
-
handleTabClick(activeKey: string, event: E)
|
|
86
|
-
syncActiveKey(activeKey?: string | null)
|
|
87
|
-
handleTabPanesChange(panes: ReadonlyArray<TabEntry>)
|
|
88
|
-
handleTabDelete(tabKey: string)
|
|
85
|
+
handleTabClick: (activeKey: string, event: E) => void;
|
|
86
|
+
syncActiveKey: (activeKey?: string | null) => void;
|
|
87
|
+
handleTabPanesChange: (panes: ReadonlyArray<TabEntry>) => void;
|
|
88
|
+
handleTabDelete: (tabKey: string) => void;
|
|
89
89
|
handleKeyDown: (event: E & TabKeyEvent, itemKey: string, closable: boolean) => void;
|
|
90
90
|
}
|
|
91
91
|
export {};
|
package/dist/tabs/foundation.js
CHANGED
|
@@ -8,7 +8,7 @@ const OVERFLOW_LIST_SCROLL_WRAPPER = `${BASE_CLASS_PREFIX}-overflow-list-scroll-
|
|
|
8
8
|
var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
9
9
|
#notifyChange(activeKey) {
|
|
10
10
|
const { activeKey: stateActiveKey } = this.getStates();
|
|
11
|
-
if (stateActiveKey !== activeKey) this.
|
|
11
|
+
if (stateActiveKey !== activeKey) this.adapter.notifyChange(activeKey);
|
|
12
12
|
}
|
|
13
13
|
#handlePrevent(event) {
|
|
14
14
|
event.stopPropagation();
|
|
@@ -37,7 +37,7 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
|
37
37
|
}
|
|
38
38
|
#switchTabOnArrowPress(key, tab, allTabs) {
|
|
39
39
|
const { preventScroll } = this.getProps();
|
|
40
|
-
const rtl = this.
|
|
40
|
+
const rtl = this.adapter.getContext("direction") === "rtl";
|
|
41
41
|
const step = {
|
|
42
42
|
ArrowLeft: rtl ? 1 : -1,
|
|
43
43
|
ArrowUp: -1,
|
|
@@ -55,7 +55,7 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
|
55
55
|
}
|
|
56
56
|
handleNewActiveKey(activeKey) {
|
|
57
57
|
const { activeKey: stateActiveKey } = this.getStates();
|
|
58
|
-
if (stateActiveKey !== activeKey) this.
|
|
58
|
+
if (stateActiveKey !== activeKey) this.adapter.setNewActiveKey(activeKey);
|
|
59
59
|
}
|
|
60
60
|
/** activeKey, else defaultActiveKey, else the first enabled entry of `list` that has a key */
|
|
61
61
|
static getDefaultActiveKey(props, list) {
|
|
@@ -136,28 +136,28 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
|
|
|
136
136
|
hasHidden: visibles.some((visible) => !visible)
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
handleTabClick(activeKey, event) {
|
|
139
|
+
handleTabClick = (activeKey, event) => {
|
|
140
140
|
this.#notifyChange(activeKey);
|
|
141
|
-
if (!this.
|
|
142
|
-
this.
|
|
143
|
-
}
|
|
144
|
-
syncActiveKey(activeKey) {
|
|
141
|
+
if (!this.isControlledComponent("activeKey")) this.handleNewActiveKey(activeKey);
|
|
142
|
+
this.adapter.notifyTabClick(activeKey, event);
|
|
143
|
+
};
|
|
144
|
+
syncActiveKey = (activeKey) => {
|
|
145
145
|
if (activeKey !== void 0) this.handleNewActiveKey(activeKey);
|
|
146
|
-
}
|
|
147
|
-
handleTabPanesChange(panes) {
|
|
148
|
-
if (this.
|
|
146
|
+
};
|
|
147
|
+
handleTabPanesChange = (panes) => {
|
|
148
|
+
if (this.isControlledComponent("activeKey")) return;
|
|
149
149
|
const { activeKey } = this.getStates();
|
|
150
150
|
if (!panes.some((pane) => pane.itemKey === activeKey)) this.handleNewActiveKey(TabsFoundation.getDefaultActiveKey({}, panes));
|
|
151
|
-
}
|
|
152
|
-
handleTabDelete(tabKey) {
|
|
153
|
-
this.
|
|
154
|
-
}
|
|
151
|
+
};
|
|
152
|
+
handleTabDelete = (tabKey) => {
|
|
153
|
+
this.adapter.notifyTabDelete(tabKey);
|
|
154
|
+
};
|
|
155
155
|
handleKeyDown = (event, itemKey, closable) => {
|
|
156
156
|
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
157
157
|
const tab = event.currentTarget;
|
|
158
|
-
if (event.target !== tab) return;
|
|
158
|
+
if (!(tab instanceof HTMLElement) || event.target !== tab) return;
|
|
159
159
|
const { preventScroll } = this.getProps();
|
|
160
|
-
const allTabs = [...tab.
|
|
160
|
+
const allTabs = [...tab.closest("[role=\"tablist\"]").querySelectorAll(`[data-tabkey^="${TAB_DATA_KEY_PREFIX}"]`)];
|
|
161
161
|
const tabs = allTabs.filter((item) => item.getAttribute("aria-disabled") !== "true");
|
|
162
162
|
switch (event.key) {
|
|
163
163
|
case "ArrowLeft":
|
|
@@ -74,18 +74,18 @@ export default class TagInputFoundation<P extends TagInputBaseProps = TagInputBa
|
|
|
74
74
|
init(): void;
|
|
75
75
|
destroy(): void;
|
|
76
76
|
/** Re-fits the inline input width without field-sizing; hosts call it when the typed text changes */
|
|
77
|
-
fitInputWidth()
|
|
78
|
-
handleInputChange(value: string, e: E)
|
|
79
|
-
handleInputCompositionStart: (_e:
|
|
77
|
+
fitInputWidth: () => void;
|
|
78
|
+
handleInputChange: (value: string, e: E) => void;
|
|
79
|
+
handleInputCompositionStart: (_e: unknown) => void;
|
|
80
80
|
handleInputCompositionEnd: (e: any) => void;
|
|
81
81
|
handleKeyDown: (e: TagInputKeyboardEvent) => void;
|
|
82
|
-
handleInputBlur(e: TagInputCursorEvent)
|
|
83
|
-
handleInputFocus(e: TagInputCursorEvent)
|
|
84
|
-
handleClearBtn(e: TagInputMouseEvent)
|
|
85
|
-
handleTagClose(index: number)
|
|
86
|
-
handleClick()
|
|
82
|
+
handleInputBlur: (e: TagInputCursorEvent) => void;
|
|
83
|
+
handleInputFocus: (e: TagInputCursorEvent) => void;
|
|
84
|
+
handleClearBtn: (e: TagInputMouseEvent) => void;
|
|
85
|
+
handleTagClose: (index: number) => void;
|
|
86
|
+
handleClick: () => void;
|
|
87
87
|
/** Ends the active session started by a click: on a mousedown outside the TagInput, or on blur() */
|
|
88
|
-
deactivate()
|
|
89
|
-
handleClickPrefixOrSuffix()
|
|
90
|
-
handleSortEnd({ oldIndex, newIndex }: OnSortEndProps)
|
|
88
|
+
deactivate: () => void;
|
|
89
|
+
handleClickPrefixOrSuffix: () => void;
|
|
90
|
+
handleSortEnd: ({ oldIndex, newIndex }: OnSortEndProps) => void;
|
|
91
91
|
}
|