@king-design/intact 2.0.17-beta.0 → 2.1.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/components/cascader/index.md +18 -0
- package/components/cascader/index.spec.ts +56 -0
- package/components/cascader/index.ts +35 -12
- package/components/cascader/index.vdt +9 -8
- package/components/cascader/useFields.ts +22 -0
- package/components/cascader/useFilterable.ts +23 -8
- package/components/cascader/useLabel.ts +7 -4
- package/components/cascader/useLoad.ts +4 -2
- package/components/code/demos/basic.md +1 -1
- package/components/colorpicker/index.md +16 -0
- package/components/colorpicker/index.ts +4 -0
- package/components/colorpicker/index.vdt +3 -2
- package/components/datepicker/index.md +11 -0
- package/components/dialog/index.spec.ts +2 -2
- package/components/dropdown/dropdown.ts +0 -1
- package/components/dropdown/item.ts +3 -2
- package/components/dropdown/usePosition.ts +9 -1
- package/components/editable/index.ts +17 -3
- package/components/editable/index.vdt +1 -0
- package/components/input/demos/autoRows.md +44 -0
- package/components/input/demos/password.md +12 -0
- package/components/input/demos/textarea.md +2 -2
- package/components/input/index.md +1 -0
- package/components/input/index.spec.ts +97 -1
- package/components/input/index.ts +17 -3
- package/components/input/index.vdt +29 -6
- package/components/input/styles.ts +18 -1
- package/components/input/useAutoRows.ts +65 -0
- package/components/input/useAutoWidth.ts +12 -3
- package/components/input/useShowPassword.ts +27 -0
- package/components/pagination/index.spec.ts +1 -1
- package/components/pagination/index.ts +1 -2
- package/components/portal.ts +4 -4
- package/components/position.ts +5 -1
- package/components/select/base.ts +3 -1
- package/components/select/base.vdt +2 -0
- package/components/select/index.md +11 -1
- package/components/table/cell.ts +4 -5
- package/components/table/demos/hideHeader.md +33 -0
- package/components/table/demos/pagination.md +53 -0
- package/components/table/index.md +22 -0
- package/components/table/index.spec.ts +73 -1
- package/components/table/row.ts +3 -3
- package/components/table/styles.ts +5 -0
- package/components/table/table.ts +29 -4
- package/components/table/table.vdt +21 -3
- package/components/table/useChecked.ts +21 -6
- package/components/table/useDisableRow.ts +3 -2
- package/components/table/useDraggable.ts +11 -8
- package/components/table/useGroup.ts +2 -0
- package/components/table/useMerge.ts +6 -3
- package/components/table/usePagination.ts +71 -0
- package/components/table/useRestRowStatus.ts +4 -1
- package/components/table/useTree.ts +4 -3
- package/components/timepicker/index.md +11 -0
- package/components/tooltip/demos/trigger.md +1 -1
- package/components/tooltip/index.md +1 -1
- package/components/tooltip/index.spec.ts +8 -5
- package/components/treeSelect/index.md +9 -0
- package/es/components/cascader/index.d.ts +22 -11
- package/es/components/cascader/index.js +9 -12
- package/es/components/cascader/index.spec.js +81 -0
- package/es/components/cascader/index.vdt.js +10 -8
- package/es/components/cascader/useFields.d.ts +2 -0
- package/es/components/cascader/useFields.js +18 -0
- package/es/components/cascader/useFilterable.d.ts +2 -1
- package/es/components/cascader/useFilterable.js +17 -6
- package/es/components/cascader/useLabel.d.ts +2 -1
- package/es/components/cascader/useLabel.js +4 -4
- package/es/components/cascader/useLoad.d.ts +2 -1
- package/es/components/cascader/useLoad.js +9 -7
- package/es/components/colorpicker/index.d.ts +2 -0
- package/es/components/colorpicker/index.js +7 -2
- package/es/components/colorpicker/index.vdt.js +3 -6
- package/es/components/dialog/index.spec.js +2 -2
- package/es/components/dropdown/dropdown.js +0 -1
- package/es/components/dropdown/item.js +3 -3
- package/es/components/dropdown/usePosition.js +8 -1
- package/es/components/editable/index.d.ts +1 -0
- package/es/components/editable/index.js +20 -6
- package/es/components/editable/index.vdt.js +2 -1
- package/es/components/input/index.d.ts +10 -2
- package/es/components/input/index.js +10 -3
- package/es/components/input/index.spec.js +169 -1
- package/es/components/input/index.vdt.js +26 -7
- package/es/components/input/styles.js +8 -3
- package/es/components/input/useAutoRows.d.ts +2 -0
- package/es/components/input/useAutoRows.js +79 -0
- package/es/components/input/useAutoWidth.js +13 -3
- package/es/components/input/useShowPassword.d.ts +7 -0
- package/es/components/input/useShowPassword.js +31 -0
- package/es/components/pagination/index.js +1 -3
- package/es/components/pagination/index.spec.js +2 -4
- package/es/components/portal.d.ts +6 -2
- package/es/components/portal.js +4 -3
- package/es/components/position.js +2 -1
- package/es/components/select/base.d.ts +2 -1
- package/es/components/select/base.js +3 -1
- package/es/components/select/base.vdt.js +3 -1
- package/es/components/table/cell.js +1 -6
- package/es/components/table/index.spec.js +130 -19
- package/es/components/table/row.d.ts +1 -1
- package/es/components/table/row.js +2 -1
- package/es/components/table/styles.js +1 -1
- package/es/components/table/table.d.ts +15 -0
- package/es/components/table/table.js +16 -7
- package/es/components/table/table.vdt.js +20 -6
- package/es/components/table/useChecked.d.ts +3 -2
- package/es/components/table/useChecked.js +23 -12
- package/es/components/table/useDisableRow.d.ts +2 -1
- package/es/components/table/useDisableRow.js +4 -4
- package/es/components/table/useDraggable.d.ts +3 -2
- package/es/components/table/useDraggable.js +11 -8
- package/es/components/table/useGroup.js +3 -0
- package/es/components/table/useMerge.d.ts +2 -1
- package/es/components/table/useMerge.js +5 -4
- package/es/components/table/usePagination.d.ts +8 -0
- package/es/components/table/usePagination.js +81 -0
- package/es/components/table/useTree.d.ts +2 -1
- package/es/components/table/useTree.js +3 -4
- package/es/components/tooltip/index.spec.js +9 -10
- package/es/index.d.ts +3 -3
- package/es/index.js +3 -3
- package/es/packages/kpc-react/__tests__/components/cascader.spec.d.ts +1 -0
- package/es/packages/kpc-react/__tests__/components/cascader.spec.js +79 -0
- package/es/site/data/components/dialog/demos/basic/react.js +4 -1
- package/es/site/data/components/input/demos/autoRows/index.d.ts +9 -0
- package/es/site/data/components/input/demos/autoRows/index.js +24 -0
- package/es/site/data/components/input/demos/autoRows/react.d.ts +8 -0
- package/es/site/data/components/input/demos/autoRows/react.js +62 -0
- package/es/site/data/components/input/demos/password/index.d.ts +5 -0
- package/es/site/data/components/input/demos/password/index.js +17 -0
- package/es/site/data/components/input/demos/password/react.d.ts +5 -0
- package/es/site/data/components/input/demos/password/react.js +41 -0
- package/es/site/data/components/input/demos/textarea/react.js +4 -2
- package/es/site/data/components/table/demos/hideHeader/index.d.ts +12 -0
- package/es/site/data/components/table/demos/hideHeader/index.js +30 -0
- package/es/site/data/components/table/demos/hideHeader/react.d.ts +11 -0
- package/es/site/data/components/table/demos/hideHeader/react.js +60 -0
- package/es/site/data/components/table/demos/pagination/index.d.ts +12 -0
- package/es/site/data/components/table/demos/pagination/index.js +35 -0
- package/es/site/data/components/table/demos/pagination/react.d.ts +16 -0
- package/es/site/data/components/table/demos/pagination/react.js +65 -0
- package/es/styles/fonts/ionicons.js +1 -1
- package/index.ts +3 -3
- package/package.json +4 -4
- package/styles/fonts/ionicons.ts +0 -1
|
@@ -25,6 +25,7 @@ import { useDraggable } from './useDraggable';
|
|
|
25
25
|
import { useStickyScrollbar } from './useStickyScrollbar';
|
|
26
26
|
import { useWidth } from './useWidth';
|
|
27
27
|
import { useScroll } from './useScroll';
|
|
28
|
+
import { usePagination } from './usePagination';
|
|
28
29
|
var typeDefs = {
|
|
29
30
|
data: Array,
|
|
30
31
|
fixHeader: [Boolean, String, Number],
|
|
@@ -57,7 +58,9 @@ var typeDefs = {
|
|
|
57
58
|
minColWidth: Number,
|
|
58
59
|
widthStoreKey: String,
|
|
59
60
|
draggable: Boolean,
|
|
60
|
-
animation: [Boolean, Array]
|
|
61
|
+
animation: [Boolean, Array],
|
|
62
|
+
hideHeader: Boolean,
|
|
63
|
+
pagination: [Boolean, Object]
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
var defaults = function defaults() {
|
|
@@ -78,7 +81,12 @@ var defaults = function defaults() {
|
|
|
78
81
|
var events = {
|
|
79
82
|
clickRow: true,
|
|
80
83
|
dragstart: true,
|
|
81
|
-
dragend: true
|
|
84
|
+
dragend: true,
|
|
85
|
+
checkRow: true,
|
|
86
|
+
uncheckRow: true,
|
|
87
|
+
checkAll: true,
|
|
88
|
+
uncheckAll: true,
|
|
89
|
+
changePage: true
|
|
82
90
|
};
|
|
83
91
|
export var Table = /*#__PURE__*/function (_Component) {
|
|
84
92
|
_inheritsLoose(Table, _Component);
|
|
@@ -93,21 +101,22 @@ export var Table = /*#__PURE__*/function (_Component) {
|
|
|
93
101
|
}
|
|
94
102
|
|
|
95
103
|
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
96
|
-
_this.
|
|
104
|
+
_this.pagination = usePagination();
|
|
105
|
+
_this.tree = useTree(_this.pagination.data);
|
|
97
106
|
_this.columns = useColumns();
|
|
98
107
|
_this.scroll = useScroll();
|
|
99
108
|
_this.stickyHeader = useStickyHeader(_this.scroll.callbacks);
|
|
100
109
|
_this.width = useWidth(_this.scroll.scrollRef, _this.columns.getColumns);
|
|
101
110
|
_this.resizable = useResizable(_this.scroll.scrollRef, _this.width.tableRef, _this.width.tableWidth, _this.width.widthMap, _this.width.storeWidth);
|
|
102
111
|
_this.fixedColumns = useFixedColumns(_this.columns.getColumns, _this.scroll, _this.width.widthMap);
|
|
103
|
-
_this.disableRow = useDisableRow(_this.tree.loopData);
|
|
104
|
-
_this.merge = useMerge(_this.columns.getCols);
|
|
105
|
-
_this.checked = useChecked(_this.disableRow.getEnableKeys, _this.disableRow.getAllKeys, _this.disableRow.isDisabledKey, _this.merge.getGrid, _this.tree.loopData);
|
|
112
|
+
_this.disableRow = useDisableRow(_this.tree.loopData, _this.pagination.data);
|
|
113
|
+
_this.merge = useMerge(_this.columns.getCols, _this.pagination.data);
|
|
114
|
+
_this.checked = useChecked(_this.disableRow.getEnableKeys, _this.disableRow.getAllKeys, _this.disableRow.isDisabledKey, _this.merge.getGrid, _this.tree.loopData, _this.pagination.data);
|
|
106
115
|
_this.sortable = useSortable();
|
|
107
116
|
_this.expandable = useExpandable();
|
|
108
117
|
_this.selected = useSelected();
|
|
109
118
|
_this.resetRowStatus = useRestRowStatus(_this.disableRow.getAllKeys);
|
|
110
|
-
_this.draggable = useDraggable();
|
|
119
|
+
_this.draggable = useDraggable(_this.pagination.data);
|
|
111
120
|
_this.stickyScrollbar = useStickyScrollbar(_this.stickyHeader.elementRef, _this.scroll, _this.width.tableRef, _this.fixedColumns.setScrollPosition);
|
|
112
121
|
return _this;
|
|
113
122
|
}
|
|
@@ -3,7 +3,7 @@ import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort"
|
|
|
3
3
|
import { createElementVNode as _$ce, map as _$ma, className as _$cn, createUnknownComponentVNode as _$cc, createVNode as _$cv, noop as _$no, extend as _$ex, EMPTY_OBJ as _$em } from 'intact';
|
|
4
4
|
import { eachChildren } from '../utils';
|
|
5
5
|
import { makeStyles } from './styles';
|
|
6
|
-
import { isStringOrNumber, isNull } from 'intact-shared';
|
|
6
|
+
import { isStringOrNumber, isNull, isObject, EMPTY_OBJ } from 'intact-shared';
|
|
7
7
|
import { getClassAndStyleForFixed } from './useFixedColumns';
|
|
8
8
|
import { Affix } from '../affix';
|
|
9
9
|
import { TableRow } from './row';
|
|
@@ -19,6 +19,7 @@ import { Tooltip } from '../tooltip';
|
|
|
19
19
|
import { AllCheckedStatus } from './useChecked';
|
|
20
20
|
import { context as ResizableContext } from './useResizable';
|
|
21
21
|
import { context as FixedColumnsContext } from './useFixedColumns';
|
|
22
|
+
import { Pagination } from '../pagination';
|
|
22
23
|
var _$tmp0 = {
|
|
23
24
|
'width': '40'
|
|
24
25
|
};
|
|
@@ -58,7 +59,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
58
59
|
showIndeterminate = _this$get.showIndeterminate,
|
|
59
60
|
resizable = _this$get.resizable,
|
|
60
61
|
draggable = _this$get.draggable,
|
|
61
|
-
_animation = _this$get.animation
|
|
62
|
+
_animation = _this$get.animation,
|
|
63
|
+
hideHeader = _this$get.hideHeader,
|
|
64
|
+
pagination = _this$get.pagination;
|
|
62
65
|
|
|
63
66
|
var animation = !Array.isArray(_animation) ? [_animation, _animation] : _animation;
|
|
64
67
|
|
|
@@ -112,8 +115,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
112
115
|
onChangeChecked = _this$checked.onChangeChecked;
|
|
113
116
|
var allCheckedStatus = getAllCheckedStatus();
|
|
114
117
|
var offsetMap = getOffsetMap();
|
|
115
|
-
|
|
116
|
-
var thead = _$cc(TableContext.Provider, {
|
|
118
|
+
var thead = hideHeader ? null : _$cc(TableContext.Provider, {
|
|
117
119
|
'value': checkType,
|
|
118
120
|
'children': _$cc(GroupContext.Provider, {
|
|
119
121
|
'value': {
|
|
@@ -157,7 +159,6 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
157
159
|
})
|
|
158
160
|
})
|
|
159
161
|
});
|
|
160
|
-
|
|
161
162
|
var getAllKeys = this.disableRow.getAllKeys;
|
|
162
163
|
var getGrid = this.merge.getGrid;
|
|
163
164
|
var allStatus = getAllStatus();
|
|
@@ -306,6 +307,11 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
306
307
|
scrollbarRef = _this$stickyScrollbar.scrollbarRef,
|
|
307
308
|
onScrollbarScroll = _this$stickyScrollbar.onScroll,
|
|
308
309
|
tableActualWidth = _this$stickyScrollbar.tableActualWidth;
|
|
310
|
+
var _this$pagination = this.pagination,
|
|
311
|
+
pageValue = _this$pagination.value,
|
|
312
|
+
pageLimit = _this$pagination.limit,
|
|
313
|
+
onPageChange = _this$pagination.onChange,
|
|
314
|
+
paginationRef = _this$pagination.paginationRef;
|
|
309
315
|
return _$ce(2, 'div', [_$ce(2, 'div', [!isNull(stickHeader.value) ? _$cc(Affix, {
|
|
310
316
|
'top': stickHeader.value,
|
|
311
317
|
'exclude': excludeStickHeader,
|
|
@@ -321,7 +327,15 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
321
327
|
}
|
|
322
328
|
}, null, tableRef)], 0, 'k-table-wrapper', {
|
|
323
329
|
'style': style
|
|
324
|
-
}, null, scrollRef), _$cc(
|
|
330
|
+
}, null, scrollRef), pagination ? _$cc(Pagination, _extends({
|
|
331
|
+
'ref': paginationRef,
|
|
332
|
+
'total': data ? data.length : 0,
|
|
333
|
+
'size': 'small'
|
|
334
|
+
}, isObject(pagination) ? pagination : EMPTY_OBJ, {
|
|
335
|
+
'value': pageValue.value,
|
|
336
|
+
'limit': pageLimit.value,
|
|
337
|
+
'ev-change': onPageChange
|
|
338
|
+
}), null, paginationRef) : undefined, _$cc(Transition, {
|
|
325
339
|
'name': 'k-fade',
|
|
326
340
|
'children': loading ? _$cc(Spin, _$tmp1) : undefined
|
|
327
341
|
}), !isNull(stickScrollbar.value) ? _$cc(Affix, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { State } from '../../hooks/useState';
|
|
1
2
|
import type { TableRowKey } from './';
|
|
2
3
|
import type { TableGrid } from './useMerge';
|
|
3
4
|
import type { useTree } from './useTree';
|
|
@@ -12,12 +13,12 @@ export declare enum AllCheckedStatus {
|
|
|
12
13
|
Indeterminate = 1,
|
|
13
14
|
None = 2
|
|
14
15
|
}
|
|
15
|
-
export declare function useChecked(getEnableKeys: () => TableRowKey[], getAllKeys: () => TableRowKey[], isDisabledKey: (key: TableRowKey) => boolean, getGrid: () => TableGrid, loopData: ReturnType<typeof useTree>['loopData']): {
|
|
16
|
+
export declare function useChecked(getEnableKeys: () => TableRowKey[], getAllKeys: () => TableRowKey[], isDisabledKey: (key: TableRowKey) => boolean, getGrid: () => TableGrid, loopData: ReturnType<typeof useTree>['loopData'], data: State<any[] | undefined>): {
|
|
16
17
|
isChecked: (key: TableRowKey) => boolean;
|
|
17
18
|
getAllCheckedStatus: () => AllCheckedStatus;
|
|
18
19
|
toggleCheckedAll: (v: boolean) => void;
|
|
19
20
|
getAllStatus: () => RowStatus[];
|
|
20
|
-
onChangeChecked: (rowIndex: number, v: boolean) => void;
|
|
21
|
+
onChangeChecked: (rowIndex: number, v: boolean, key: TableRowKey) => void;
|
|
21
22
|
};
|
|
22
23
|
export declare function inArray<T>(arr: T[] | undefined, v: T): boolean;
|
|
23
24
|
export declare function addOrRemove(keys: TableRowKey[], key: TableRowKey, isAdd: boolean): void;
|
|
@@ -2,6 +2,7 @@ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/i
|
|
|
2
2
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
3
3
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
4
4
|
import { useInstance } from 'intact';
|
|
5
|
+
import { watchState } from '../../hooks/useState';
|
|
5
6
|
import { toggleArray } from '../utils';
|
|
6
7
|
export var AllCheckedStatus;
|
|
7
8
|
|
|
@@ -11,7 +12,7 @@ export var AllCheckedStatus;
|
|
|
11
12
|
AllCheckedStatus[AllCheckedStatus["None"] = 2] = "None";
|
|
12
13
|
})(AllCheckedStatus || (AllCheckedStatus = {}));
|
|
13
14
|
|
|
14
|
-
export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, loopData) {
|
|
15
|
+
export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, loopData, data) {
|
|
15
16
|
var instance = useInstance();
|
|
16
17
|
var allStatus = [];
|
|
17
18
|
|
|
@@ -21,7 +22,10 @@ export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, lo
|
|
|
21
22
|
|
|
22
23
|
function toggleChecked(key, rowIndex) {
|
|
23
24
|
if (instance.get('checkType') === 'checkbox') {
|
|
24
|
-
instance.set('checkedKeys', toggleArray(instance.get('checkedKeys'), key));
|
|
25
|
+
instance.set('checkedKeys', toggleArray(instance.get('checkedKeys'), key)); // trigger check event for checkbox,
|
|
26
|
+
// radio check event trigger in onChangeChecked function
|
|
27
|
+
|
|
28
|
+
triggerEvent(isChecked(key), key, rowIndex);
|
|
25
29
|
} else {
|
|
26
30
|
if (isChecked(key)) return;
|
|
27
31
|
var grid = getGrid();
|
|
@@ -34,7 +38,7 @@ export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, lo
|
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
onChangeChecked(rowIndex, true);
|
|
41
|
+
onChangeChecked(rowIndex, true, key);
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -61,6 +65,7 @@ export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, lo
|
|
|
61
65
|
|
|
62
66
|
function toggleCheckedAll(v) {
|
|
63
67
|
instance.set('checkedKeys', getCheckedAllOrUncheckedAllKeys(v));
|
|
68
|
+
instance.trigger(v ? 'checkAll' : 'uncheckAll');
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
66
71
|
* keep the original keys which don't exist in the enableKeys,
|
|
@@ -92,12 +97,11 @@ export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, lo
|
|
|
92
97
|
allStatus = [];
|
|
93
98
|
|
|
94
99
|
var _instance$get2 = instance.get(),
|
|
95
|
-
data = _instance$get2.data,
|
|
96
100
|
rowKey = _instance$get2.rowKey,
|
|
97
101
|
checkType = _instance$get2.checkType,
|
|
98
102
|
merge = _instance$get2.merge;
|
|
99
103
|
|
|
100
|
-
if (!data || !data.length) return;
|
|
104
|
+
if (!data.value || !data.value.length) return;
|
|
101
105
|
var allKeys = getAllKeys();
|
|
102
106
|
allKeys.forEach(function (key) {
|
|
103
107
|
var disabled = isDisabledKey(key);
|
|
@@ -161,7 +165,7 @@ export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, lo
|
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
function onChangeChecked(rowIndex, v) {
|
|
168
|
+
function onChangeChecked(rowIndex, v, key) {
|
|
165
169
|
var _context;
|
|
166
170
|
|
|
167
171
|
// should check or uncheck all grouped rows
|
|
@@ -172,9 +176,9 @@ export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, lo
|
|
|
172
176
|
|
|
173
177
|
if (checkType === 'radio') {
|
|
174
178
|
for (var i = 0; i < checkedKeys.length; i++) {
|
|
175
|
-
var
|
|
179
|
+
var _key = checkedKeys[i]; // FIXME: should ignore the disabled status, if we remove the radio keys
|
|
176
180
|
|
|
177
|
-
if (isDisabledKey(
|
|
181
|
+
if (isDisabledKey(_key)) continue;
|
|
178
182
|
|
|
179
183
|
_spliceInstanceProperty(checkedKeys).call(checkedKeys, i, 1);
|
|
180
184
|
|
|
@@ -189,27 +193,34 @@ export function useChecked(getEnableKeys, getAllKeys, isDisabledKey, getGrid, lo
|
|
|
189
193
|
if ((rowspan = grid[rowIndex]) && (rowspan = rowspan[0]) && (rowspan = rowspan.spans) && (rowspan = rowspan.rowspan) && rowspan > 1) {
|
|
190
194
|
for (var _i = rowIndex; _i < rowspan + rowIndex; _i++) {
|
|
191
195
|
var status = allStatus[_i];
|
|
192
|
-
var
|
|
196
|
+
var _key2 = allKeys[_i];
|
|
193
197
|
|
|
194
198
|
if (!status.disabled) {
|
|
195
|
-
addOrRemove(checkedKeys,
|
|
199
|
+
addOrRemove(checkedKeys, _key2, v);
|
|
196
200
|
}
|
|
197
201
|
}
|
|
198
202
|
} else {
|
|
199
203
|
addOrRemove(checkedKeys, allKeys[rowIndex], v);
|
|
200
204
|
}
|
|
201
205
|
|
|
202
|
-
instance.set('checkedKeys', checkedKeys);
|
|
206
|
+
instance.set('checkedKeys', checkedKeys); // onChangeChecked will be called in clickRow and check in Row component
|
|
207
|
+
|
|
208
|
+
triggerEvent(v, key, rowIndex);
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
function getAllStatus() {
|
|
206
212
|
return allStatus;
|
|
207
213
|
}
|
|
208
214
|
|
|
215
|
+
function triggerEvent(isChecked, key, rowIndex) {
|
|
216
|
+
instance.trigger(isChecked ? 'checkRow' : 'uncheckRow', data.value[rowIndex], rowIndex, key);
|
|
217
|
+
}
|
|
218
|
+
|
|
209
219
|
instance.on('$receive:children', updateAllCheckedStatus);
|
|
210
220
|
instance.on('$change:checkedKeys', updateAllCheckedStatus); // for draggable
|
|
211
221
|
|
|
212
|
-
instance.on('$change:data', updateAllCheckedStatus);
|
|
222
|
+
watchState(data, updateAllCheckedStatus); // instance.on('$change:data', updateAllCheckedStatus);
|
|
223
|
+
|
|
213
224
|
instance.on('clickRow', function (data, index, key) {
|
|
214
225
|
if (instance.get('rowCheckable') && instance.get('checkType') !== 'none') {
|
|
215
226
|
toggleChecked(key, index);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TableRowKey } from './table';
|
|
2
2
|
import type { useTree } from './useTree';
|
|
3
|
-
|
|
3
|
+
import { State } from '../../hooks/useState';
|
|
4
|
+
export declare function useDisableRow(loopData: ReturnType<typeof useTree>['loopData'], data: State<any[] | undefined>): {
|
|
4
5
|
isDisabled: (data: any, index: number, key: TableRowKey) => boolean;
|
|
5
6
|
getEnableKeys: () => TableRowKey[];
|
|
6
7
|
isDisabledKey: (key: TableRowKey) => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useInstance } from 'intact';
|
|
2
|
-
|
|
2
|
+
import { watchState } from '../../hooks/useState';
|
|
3
|
+
export function useDisableRow(loopData, data) {
|
|
3
4
|
var instance = useInstance();
|
|
4
5
|
var enabledKeys = [];
|
|
5
6
|
var disabledKeys = [];
|
|
@@ -45,9 +46,8 @@ export function useDisableRow(loopData) {
|
|
|
45
46
|
return allKeys;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
instance.on('$receive:children', setDisabledKeys);
|
|
49
|
-
|
|
50
|
-
instance.on('$change:data', setDisabledKeys);
|
|
49
|
+
instance.on('$receive:children', setDisabledKeys);
|
|
50
|
+
watchState(data, setDisabledKeys);
|
|
51
51
|
return {
|
|
52
52
|
isDisabled: isDisabled,
|
|
53
53
|
getEnableKeys: getEnableKeys,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { TableRowKey } from './table';
|
|
2
|
+
import { State } from '../../hooks/useState';
|
|
2
3
|
import type { TableRow } from './row';
|
|
3
|
-
export declare function useDraggable(): {
|
|
4
|
+
export declare function useDraggable(data: State<unknown[] | undefined>): {
|
|
4
5
|
onRowDragStart: (e: MouseEvent, tableRow: TableRow) => void;
|
|
5
6
|
onRowDragOver: (e: MouseEvent, tableRow: TableRow) => void;
|
|
6
7
|
onRowDragEnd: (e: MouseEvent, tableRow: TableRow) => void;
|
|
7
|
-
draggingKey:
|
|
8
|
+
draggingKey: State<TableRowKey | null>;
|
|
8
9
|
};
|
|
@@ -2,7 +2,7 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slic
|
|
|
2
2
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
3
3
|
import { useInstance, nextTick } from 'intact';
|
|
4
4
|
import { useState } from '../../hooks/useState';
|
|
5
|
-
export function useDraggable() {
|
|
5
|
+
export function useDraggable(data) {
|
|
6
6
|
var instance = useInstance();
|
|
7
7
|
var draggingKey = useState(null);
|
|
8
8
|
var originIndex;
|
|
@@ -13,7 +13,7 @@ export function useDraggable() {
|
|
|
13
13
|
draggingIndex = originIndex = tableRow.get('index');
|
|
14
14
|
var key = tableRow.get('key');
|
|
15
15
|
draggingKey.set(key);
|
|
16
|
-
originData =
|
|
16
|
+
originData = data.value;
|
|
17
17
|
instance.trigger('dragstart', {
|
|
18
18
|
key: key,
|
|
19
19
|
from: draggingIndex
|
|
@@ -28,20 +28,23 @@ export function useDraggable() {
|
|
|
28
28
|
var newIndex = tableRow.get('index');
|
|
29
29
|
if (newIndex === draggingIndex) return; // swap data
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var newData = _sliceInstanceProperty(_context = data.value).call(_context);
|
|
32
32
|
|
|
33
|
-
var item = _spliceInstanceProperty(
|
|
33
|
+
var item = _spliceInstanceProperty(newData).call(newData, draggingIndex, 1)[0];
|
|
34
34
|
|
|
35
|
-
_spliceInstanceProperty(
|
|
35
|
+
_spliceInstanceProperty(newData).call(newData, newIndex, 0, item);
|
|
36
36
|
|
|
37
37
|
draggingIndex = newIndex;
|
|
38
|
-
|
|
38
|
+
data.set(newData);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function onRowDragEnd(e, tableRow) {
|
|
42
|
-
e.preventDefault();
|
|
43
|
-
|
|
42
|
+
e.preventDefault(); // revert to origin data, then set to new data to trigger animation
|
|
43
|
+
|
|
44
|
+
var newData = data.value;
|
|
45
|
+
data.set(originData);
|
|
44
46
|
nextTick(function () {
|
|
47
|
+
data.set(newData);
|
|
45
48
|
draggingKey.set(null);
|
|
46
49
|
instance.trigger('dragend', {
|
|
47
50
|
key: tableRow.get('key'),
|
|
@@ -12,6 +12,9 @@ export function useGroup() {
|
|
|
12
12
|
var instance = useInstance();
|
|
13
13
|
var keywords = useState('');
|
|
14
14
|
var filteredGroup = useState(instance.get('group'));
|
|
15
|
+
instance.on('$receive:group', function (group) {
|
|
16
|
+
return filteredGroup.set(group);
|
|
17
|
+
});
|
|
15
18
|
|
|
16
19
|
function onSelect(value, groupValue, onChange) {
|
|
17
20
|
var _instance$get = instance.get(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Props } from 'intact';
|
|
2
2
|
import type { TableColumnProps } from './column';
|
|
3
|
+
import { State } from '../../hooks/useState';
|
|
3
4
|
export declare type TableMerge<T = any, CheckType = 'checkbox'> = (row: T, column: CheckType extends 'none' ? Props<TableColumnProps> : Props<TableColumnProps> | null, rowIndex: number, columnIndex: number) => TableMergeConfig | undefined;
|
|
4
5
|
export declare type TableMergeConfig = {
|
|
5
6
|
colspan?: number;
|
|
@@ -10,6 +11,6 @@ export declare type TableGridItem = {
|
|
|
10
11
|
spans: TableMergeConfig | undefined;
|
|
11
12
|
};
|
|
12
13
|
export declare type TableGrid = TableGridItem[][];
|
|
13
|
-
export declare function useMerge(getCols: () => Props<TableColumnProps>[]): {
|
|
14
|
+
export declare function useMerge(getCols: () => Props<TableColumnProps>[], data: State<unknown[] | undefined>): {
|
|
14
15
|
getGrid: () => TableGrid;
|
|
15
16
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useInstance } from 'intact';
|
|
2
|
-
|
|
2
|
+
import { watchState } from '../../hooks/useState';
|
|
3
|
+
export function useMerge(getCols, data) {
|
|
3
4
|
var instance = useInstance();
|
|
4
5
|
var grid = [];
|
|
5
6
|
|
|
@@ -8,12 +9,11 @@ export function useMerge(getCols) {
|
|
|
8
9
|
|
|
9
10
|
var _instance$get = instance.get(),
|
|
10
11
|
merge = _instance$get.merge,
|
|
11
|
-
data = _instance$get.data,
|
|
12
12
|
checkType = _instance$get.checkType;
|
|
13
13
|
|
|
14
|
-
if (!data || !data.length || !merge) return;
|
|
14
|
+
if (!data.value || !data.value.length || !merge) return;
|
|
15
15
|
var cols = getCols();
|
|
16
|
-
data.forEach(function (data, rowIndex) {
|
|
16
|
+
data.value.forEach(function (data, rowIndex) {
|
|
17
17
|
var currentRow = [];
|
|
18
18
|
grid.push(currentRow);
|
|
19
19
|
var columnIndexOffset = 0;
|
|
@@ -71,6 +71,7 @@ export function useMerge(getCols) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
instance.on('$receive:children', handleSpans);
|
|
74
|
+
watchState(data, handleSpans);
|
|
74
75
|
return {
|
|
75
76
|
getGrid: getGrid
|
|
76
77
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Pagination, PaginationChangeData } from '../pagination';
|
|
2
|
+
export declare function usePagination(): {
|
|
3
|
+
data: import("../../hooks/useState").State<any[] | undefined>;
|
|
4
|
+
value: import("../../hooks/useState").State<number>;
|
|
5
|
+
limit: import("../../hooks/useState").State<number>;
|
|
6
|
+
onChange: (data: PaginationChangeData) => void;
|
|
7
|
+
paginationRef: import("intact").RefObject<Pagination>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
3
|
+
import { useInstance, createRef } from 'intact';
|
|
4
|
+
import { useState } from '../../hooks/useState';
|
|
5
|
+
import { Pagination } from '../pagination';
|
|
6
|
+
import { isObject } from 'intact-shared';
|
|
7
|
+
import { useReceive } from '../../hooks/useReceive';
|
|
8
|
+
var defaultPagination = Pagination.defaults();
|
|
9
|
+
export function usePagination() {
|
|
10
|
+
var instance = useInstance();
|
|
11
|
+
var data = useState(instance.get('data'));
|
|
12
|
+
var value = useState(defaultPagination.value);
|
|
13
|
+
var limit = useState(defaultPagination.limit);
|
|
14
|
+
var paginationRef = createRef(); // for unit test
|
|
15
|
+
|
|
16
|
+
useReceive(['data', 'pagination'], function () {
|
|
17
|
+
handleData();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function handleData() {
|
|
21
|
+
var _instance$get = instance.get(),
|
|
22
|
+
_data = _instance$get.data,
|
|
23
|
+
pagination = _instance$get.pagination;
|
|
24
|
+
|
|
25
|
+
if (!_data) {
|
|
26
|
+
data.set(undefined);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!pagination) {
|
|
31
|
+
data.set(_data);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (isObject(pagination)) {
|
|
36
|
+
if (pagination.value) {
|
|
37
|
+
value.set(pagination.value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (pagination.limit) {
|
|
41
|
+
limit.set(pagination.limit);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
updateDataByPage();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function updateDataByPage() {
|
|
49
|
+
var _instance$get2 = instance.get(),
|
|
50
|
+
_data = _instance$get2.data;
|
|
51
|
+
|
|
52
|
+
var index = (value.value - 1) * limit.value;
|
|
53
|
+
data.set(_sliceInstanceProperty(_data).call(_data, index, index + limit.value));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function onChange(data) {
|
|
57
|
+
var _instance$get3 = instance.get(),
|
|
58
|
+
pagination = _instance$get3.pagination;
|
|
59
|
+
|
|
60
|
+
value.set(data.value);
|
|
61
|
+
limit.set(data.limit);
|
|
62
|
+
updateDataByPage();
|
|
63
|
+
|
|
64
|
+
if (isObject(pagination)) {
|
|
65
|
+
instance.set('pagination', _extends({}, pagination, {
|
|
66
|
+
value: value.value,
|
|
67
|
+
limit: limit.value
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
instance.trigger('changePage', data);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
data: data,
|
|
76
|
+
value: value,
|
|
77
|
+
limit: limit,
|
|
78
|
+
onChange: onChange,
|
|
79
|
+
paginationRef: paginationRef
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TableRowKey } from './table';
|
|
2
|
-
|
|
2
|
+
import { State } from '../../hooks/useState';
|
|
3
|
+
export declare function useTree(data: State<any[] | undefined>): {
|
|
3
4
|
isSpreaded: (key: TableRowKey) => boolean;
|
|
4
5
|
toggleSpreadRow: (key: TableRowKey) => void;
|
|
5
6
|
loopData: <T>(cb: (value: any, index: number, level: number, meta: T | null) => T, shouldBreak?: boolean) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useInstance } from 'intact';
|
|
2
2
|
import { inArray } from './useChecked';
|
|
3
3
|
import { toggleArray } from '../utils';
|
|
4
|
-
export function useTree() {
|
|
4
|
+
export function useTree(data) {
|
|
5
5
|
var instance = useInstance();
|
|
6
6
|
|
|
7
7
|
function isSpreaded(key) {
|
|
@@ -18,10 +18,9 @@ export function useTree() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
var _instance$get = instance.get(),
|
|
21
|
-
childrenKey = _instance$get.childrenKey
|
|
22
|
-
data = _instance$get.data;
|
|
21
|
+
childrenKey = _instance$get.childrenKey;
|
|
23
22
|
|
|
24
|
-
loopDataWithChildrenKey(data, childrenKey, cb, shouldBreak);
|
|
23
|
+
loopDataWithChildrenKey(data.value, childrenKey, cb, shouldBreak);
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
return {
|
|
@@ -540,8 +540,10 @@ describe('Tooltip', function () {
|
|
|
540
540
|
|
|
541
541
|
_proto.mounted = function mounted() {
|
|
542
542
|
var element = findDomFromVNode(this.$lastInput, true);
|
|
543
|
-
var
|
|
544
|
-
|
|
543
|
+
var style = element.style;
|
|
544
|
+
style.position = 'fixed';
|
|
545
|
+
style.top = '-200px'; // const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
546
|
+
// (element.parentNode as HTMLElement).style.height = `${windowHeight * 2}px`;
|
|
545
547
|
};
|
|
546
548
|
|
|
547
549
|
return Demo;
|
|
@@ -555,23 +557,20 @@ describe('Tooltip', function () {
|
|
|
555
557
|
};
|
|
556
558
|
};
|
|
557
559
|
|
|
558
|
-
_mount9 = mount(Demo), i = _mount9[0];
|
|
559
|
-
|
|
560
|
-
return wait(500);
|
|
560
|
+
_mount9 = mount(Demo), i = _mount9[0]; // await wait(500);
|
|
561
|
+
// window.scrollTo(0, 10000);
|
|
561
562
|
|
|
562
|
-
case 6:
|
|
563
|
-
window.scrollTo(0, 10000);
|
|
564
563
|
i.set('show', true);
|
|
565
|
-
_context11.next =
|
|
564
|
+
_context11.next = 7;
|
|
566
565
|
return wait(500);
|
|
567
566
|
|
|
568
|
-
case
|
|
567
|
+
case 7:
|
|
569
568
|
content = getElement('.k-tooltip-content');
|
|
570
569
|
console.log(content.outerHTML);
|
|
571
570
|
console.log(_JSON$stringify(content.getBoundingClientRect()));
|
|
572
571
|
expect(content.getBoundingClientRect().top < 0).to.be.true;
|
|
573
572
|
|
|
574
|
-
case
|
|
573
|
+
case 11:
|
|
575
574
|
case "end":
|
|
576
575
|
return _context11.stop();
|
|
577
576
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.
|
|
2
|
+
* @king-design v2.1.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Kingsoft Cloud
|
|
5
5
|
* Released under the MIT License
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export { _$, localize } from './i18n';
|
|
11
11
|
export { bind } from './components/utils';
|
|
12
|
-
export { setTheme } from './styles/theme';
|
|
12
|
+
export { setTheme, theme } from './styles/theme';
|
|
13
13
|
export * from './components/affix';
|
|
14
14
|
export * from './components/badge';
|
|
15
15
|
export * from './components/breadcrumb';
|
|
@@ -57,4 +57,4 @@ export * from './components/tree';
|
|
|
57
57
|
export * from './components/treeSelect';
|
|
58
58
|
export * from './components/upload';
|
|
59
59
|
export * from './components/wave';
|
|
60
|
-
export declare const version = "2.
|
|
60
|
+
export declare const version = "2.1.0";
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.
|
|
2
|
+
* @king-design v2.1.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Kingsoft Cloud
|
|
5
5
|
* Released under the MIT License
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export { _$, localize } from './i18n';
|
|
11
11
|
export { bind } from './components/utils';
|
|
12
|
-
export { setTheme } from './styles/theme';
|
|
12
|
+
export { setTheme, theme } from './styles/theme';
|
|
13
13
|
/* generate start */
|
|
14
14
|
|
|
15
15
|
export * from './components/affix';
|
|
@@ -59,5 +59,5 @@ export * from './components/tree';
|
|
|
59
59
|
export * from './components/treeSelect';
|
|
60
60
|
export * from './components/upload';
|
|
61
61
|
export * from './components/wave';
|
|
62
|
-
export var version = '2.
|
|
62
|
+
export var version = '2.1.0';
|
|
63
63
|
/* generate end */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|