@king-design/intact 3.6.2-beta.1 → 3.7.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/.DS_Store +0 -0
- package/components/anchor/constants.ts +3 -0
- package/components/anchor/demos/basic.md +34 -0
- package/components/anchor/demos/container.md +76 -0
- package/components/anchor/demos/events.md +100 -0
- package/components/anchor/demos/horizontal.md +33 -0
- package/components/anchor/demos/nested.md +132 -0
- package/components/anchor/index.md +38 -0
- package/components/anchor/index.spec.ts +171 -0
- package/components/anchor/index.ts +159 -0
- package/components/anchor/index.vdt +24 -0
- package/components/anchor/link.ts +44 -0
- package/components/anchor/link.vdt +49 -0
- package/components/anchor/styles.ts +50 -0
- package/components/anchor/useScroll.ts +221 -0
- package/components/config/demos/basic.md +11 -3
- package/components/descriptions/.DS_Store +0 -0
- package/components/dialog/base.vdt +3 -1
- package/components/drawer/demos/resizable.md +67 -0
- package/components/drawer/index.md +1 -0
- package/components/drawer/index.spec.ts +43 -0
- package/components/drawer/index.ts +14 -0
- package/components/drawer/index.vdt +20 -3
- package/components/drawer/styles.ts +44 -0
- package/components/drawer/useDrawerResizable.ts +190 -0
- package/components/icon/demos/color.md +1 -1
- package/components/icon/demos/icons.md +18 -0
- package/components/menu/.DS_Store +0 -0
- package/components/menu/demos/.DS_Store +0 -0
- package/components/menu/demos/collapse.md +2 -2
- package/components/menu/demos/showCollapseArrow.md +3 -3
- package/components/menu/demos/size.md +4 -4
- package/components/menu/styles.ts +7 -3
- package/components/notification/demos/basic.md +27 -0
- package/components/notification/demos/close.md +52 -0
- package/components/notification/demos/duration.md +43 -0
- package/components/notification/demos/events.md +39 -0
- package/components/notification/demos/hideClose.md +30 -0
- package/components/notification/demos/icon.md +47 -0
- package/components/notification/demos/position.md +39 -0
- package/components/notification/demos/types.md +38 -0
- package/components/notification/index.md +62 -0
- package/components/notification/index.spec.ts +211 -0
- package/components/notification/index.ts +2 -0
- package/components/notification/notification.ts +185 -0
- package/components/notification/notification.vdt +62 -0
- package/components/notification/notifications.ts +46 -0
- package/components/notification/notifications.vdt +16 -0
- package/components/notification/styles.ts +179 -0
- package/components/select/styles.ts +2 -0
- package/components/table/.DS_Store +0 -0
- package/components/table/demos/hidden.md +8 -2
- package/components/table/demos/sort.md +4 -4
- package/components/table/styles.ts +6 -2
- package/components/tabs/useActiveBar.ts +3 -3
- package/components/tag/base.ts +4 -0
- package/components/tag/demos/border.md +1 -1
- package/components/tag/demos/color.md +40 -0
- package/components/tag/demos/draggable.md +1 -1
- package/components/tag/demos/tags.md +1 -1
- package/components/tag/index.md +1 -0
- package/components/tag/index.spec.ts +8 -0
- package/components/tag/index.vdt +6 -4
- package/components/tag/styles.ts +23 -0
- package/components/tag/useColor.ts +79 -0
- package/components/timepicker/index.spec.ts +16 -5
- package/components/timepicker/useDefaultValue.ts +16 -7
- package/components/timepicker/useStep.ts +3 -2
- package/components/tour/.DS_Store +0 -0
- package/components/transfer/demos/customFilter.md +1 -1
- package/components/transfer/demos/customList.md +1 -1
- package/components/transfer/demos/getData.md +1 -1
- package/components/transfer/demos/leftChecked.md +1 -1
- package/components/transfer/demos/pagination.md +63 -0
- package/components/transfer/demos/table.md +248 -0
- package/components/transfer/demos/tree.md +1 -1
- package/components/transfer/index.md +2 -0
- package/components/transfer/index.spec.ts +147 -0
- package/components/transfer/index.ts +7 -0
- package/components/transfer/index.vdt +30 -4
- package/components/transfer/styles.ts +11 -1
- package/components/transfer/useCheck.ts +5 -5
- package/components/transfer/usePagination.ts +92 -0
- package/components/virtualList/.DS_Store +0 -0
- package/components/virtualList/demos/.DS_Store +0 -0
- package/dist/fonts/iconfont.eot +0 -0
- package/dist/fonts/iconfont.svg +235 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/iconfont.woff2 +0 -0
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +2230 -0
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/fonts/ionicons.woff2 +0 -0
- package/dist/i18n/en-US.js +1411 -0
- package/dist/i18n/en-US.js.map +1 -0
- package/dist/i18n/en-US.min.js +1 -0
- package/dist/i18n/index.js +283 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/index.min.js +1 -0
- package/dist/kpc.js +50764 -0
- package/dist/kpc.js.map +1 -0
- package/dist/kpc.min.js +1 -0
- package/dist/kpc.react.js +58380 -0
- package/dist/kpc.react.js.map +1 -0
- package/dist/kpc.react.min.js +1 -0
- package/dist/kpc.tmp.js.map +1 -0
- package/dist/kpc.vue-legacy.js +58272 -0
- package/dist/kpc.vue-legacy.js.map +1 -0
- package/dist/kpc.vue-legacy.min.js +1 -0
- package/dist/kpc.vue.js +58128 -0
- package/dist/kpc.vue.js.map +1 -0
- package/dist/kpc.vue.min.js +1 -0
- package/es/components/anchor/constants.d.ts +2 -0
- package/es/components/anchor/constants.js +2 -0
- package/es/components/anchor/index.d.ts +41 -0
- package/es/components/anchor/index.js +141 -0
- package/es/components/anchor/index.spec.d.ts +1 -0
- package/es/components/anchor/index.spec.js +230 -0
- package/es/components/anchor/index.vdt.js +31 -0
- package/es/components/anchor/link.d.ts +16 -0
- package/es/components/anchor/link.js +52 -0
- package/es/components/anchor/link.vdt.js +49 -0
- package/es/components/anchor/styles.d.ts +5 -0
- package/es/components/anchor/styles.js +30 -0
- package/es/components/anchor/useScroll.d.ts +7 -0
- package/es/components/anchor/useScroll.js +218 -0
- package/es/components/dialog/base.vdt.js +1 -1
- package/es/components/drawer/index.d.ts +3 -0
- package/es/components/drawer/index.js +22 -3
- package/es/components/drawer/index.spec.js +83 -0
- package/es/components/drawer/index.vdt.js +23 -3
- package/es/components/drawer/styles.js +1 -1
- package/es/components/drawer/useDrawerResizable.d.ts +10 -0
- package/es/components/drawer/useDrawerResizable.js +162 -0
- package/es/components/menu/styles.d.ts +1 -0
- package/es/components/menu/styles.js +4 -1
- package/es/components/notification/index.d.ts +1 -0
- package/es/components/notification/index.js +1 -0
- package/es/components/notification/index.spec.d.ts +1 -0
- package/es/components/notification/index.spec.js +317 -0
- package/es/components/notification/notification.d.ts +39 -0
- package/es/components/notification/notification.js +183 -0
- package/es/components/notification/notification.vdt.js +56 -0
- package/es/components/notification/notifications.d.ts +16 -0
- package/es/components/notification/notifications.js +51 -0
- package/es/components/notification/notifications.vdt.js +24 -0
- package/es/components/notification/styles.d.ts +9 -0
- package/es/components/notification/styles.js +110 -0
- package/es/components/select/styles.js +1 -1
- package/es/components/table/styles.js +1 -1
- package/es/components/tabs/useActiveBar.js +7 -3
- package/es/components/tag/base.d.ts +2 -0
- package/es/components/tag/base.js +3 -0
- package/es/components/tag/index.spec.js +17 -0
- package/es/components/tag/index.vdt.js +12 -5
- package/es/components/tag/styles.d.ts +9 -0
- package/es/components/tag/styles.js +14 -1
- package/es/components/tag/useColor.d.ts +7 -0
- package/es/components/tag/useColor.js +71 -0
- package/es/components/timepicker/index.spec.js +70 -42
- package/es/components/timepicker/useDefaultValue.js +12 -7
- package/es/components/timepicker/useStep.js +4 -2
- package/es/components/transfer/index.d.ts +13 -0
- package/es/components/transfer/index.js +6 -2
- package/es/components/transfer/index.spec.js +197 -0
- package/es/components/transfer/index.vdt.js +28 -5
- package/es/components/transfer/styles.js +4 -1
- package/es/components/transfer/useCheck.js +2 -1
- package/es/components/transfer/usePagination.d.ts +12 -0
- package/es/components/transfer/usePagination.js +79 -0
- package/es/index.d.ts +4 -2
- package/es/index.js +4 -2
- package/es/site/data/components/anchor/demos/basic/index.d.ts +11 -0
- package/es/site/data/components/anchor/demos/basic/index.js +18 -0
- package/es/site/data/components/anchor/demos/basic/react.d.ts +11 -0
- package/es/site/data/components/anchor/demos/basic/react.js +46 -0
- package/es/site/data/components/anchor/demos/container/index.d.ts +12 -0
- package/es/site/data/components/anchor/demos/container/index.js +19 -0
- package/es/site/data/components/anchor/demos/container/react.d.ts +12 -0
- package/es/site/data/components/anchor/demos/container/react.js +52 -0
- package/es/site/data/components/anchor/demos/events/index.d.ts +17 -0
- package/es/site/data/components/anchor/demos/events/index.js +36 -0
- package/es/site/data/components/anchor/demos/events/react.d.ts +17 -0
- package/es/site/data/components/anchor/demos/events/react.js +88 -0
- package/es/site/data/components/anchor/demos/horizontal/index.d.ts +11 -0
- package/es/site/data/components/anchor/demos/horizontal/index.js +18 -0
- package/es/site/data/components/anchor/demos/horizontal/react.d.ts +11 -0
- package/es/site/data/components/anchor/demos/horizontal/react.js +46 -0
- package/es/site/data/components/anchor/demos/nested/index.d.ts +12 -0
- package/es/site/data/components/anchor/demos/nested/index.js +19 -0
- package/es/site/data/components/anchor/demos/nested/react.d.ts +12 -0
- package/es/site/data/components/anchor/demos/nested/react.js +100 -0
- package/es/site/data/components/anchor/index.d.ts +57 -0
- package/es/site/data/components/anchor/index.js +32 -0
- package/es/site/data/components/config/demos/basic/index.d.ts +1 -0
- package/es/site/data/components/config/demos/basic/index.js +8 -1
- package/es/site/data/components/config/demos/basic/react.d.ts +1 -0
- package/es/site/data/components/config/demos/basic/react.js +15 -3
- package/es/site/data/components/drawer/demos/resizable/index.d.ts +15 -0
- package/es/site/data/components/drawer/demos/resizable/index.js +26 -0
- package/es/site/data/components/drawer/demos/resizable/react.d.ts +15 -0
- package/es/site/data/components/drawer/demos/resizable/react.js +63 -0
- package/es/site/data/components/icon/demos/icons/index.js +1 -1
- package/es/site/data/components/menu/demos/collapse/index.d.ts +6 -1
- package/es/site/data/components/menu/demos/collapse/react.d.ts +6 -1
- package/es/site/data/components/menu/demos/showCollapseArrow/index.d.ts +8 -1
- package/es/site/data/components/menu/demos/showCollapseArrow/react.d.ts +8 -1
- package/es/site/data/components/menu/demos/size/index.d.ts +7 -2
- package/es/site/data/components/menu/demos/size/react.d.ts +7 -2
- package/es/site/data/components/notification/demos/basic/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/basic/index.js +21 -0
- package/es/site/data/components/notification/demos/basic/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/basic/react.js +24 -0
- package/es/site/data/components/notification/demos/close/index.d.ts +13 -0
- package/es/site/data/components/notification/demos/close/index.js +38 -0
- package/es/site/data/components/notification/demos/close/react.d.ts +13 -0
- package/es/site/data/components/notification/demos/close/react.js +52 -0
- package/es/site/data/components/notification/demos/duration/index.d.ts +7 -0
- package/es/site/data/components/notification/demos/duration/index.js +33 -0
- package/es/site/data/components/notification/demos/duration/react.d.ts +6 -0
- package/es/site/data/components/notification/demos/duration/react.js +38 -0
- package/es/site/data/components/notification/demos/events/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/events/index.js +31 -0
- package/es/site/data/components/notification/demos/events/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/events/react.js +34 -0
- package/es/site/data/components/notification/demos/hideClose/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/hideClose/index.js +25 -0
- package/es/site/data/components/notification/demos/hideClose/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/hideClose/react.js +28 -0
- package/es/site/data/components/notification/demos/icon/index.d.ts +7 -0
- package/es/site/data/components/notification/demos/icon/index.js +33 -0
- package/es/site/data/components/notification/demos/icon/react.d.ts +6 -0
- package/es/site/data/components/notification/demos/icon/react.js +42 -0
- package/es/site/data/components/notification/demos/position/index.d.ts +9 -0
- package/es/site/data/components/notification/demos/position/index.js +27 -0
- package/es/site/data/components/notification/demos/position/react.d.ts +8 -0
- package/es/site/data/components/notification/demos/position/react.js +40 -0
- package/es/site/data/components/notification/demos/types/index.d.ts +9 -0
- package/es/site/data/components/notification/demos/types/index.js +26 -0
- package/es/site/data/components/notification/demos/types/react.d.ts +8 -0
- package/es/site/data/components/notification/demos/types/react.js +39 -0
- package/es/site/data/components/notification/index.d.ts +57 -0
- package/es/site/data/components/notification/index.js +32 -0
- package/es/site/data/components/table/demos/hidden/react.js +21 -3
- package/es/site/data/components/tag/demos/color/index.d.ts +10 -0
- package/es/site/data/components/tag/demos/color/index.js +19 -0
- package/es/site/data/components/tag/demos/color/react.d.ts +10 -0
- package/es/site/data/components/tag/demos/color/react.js +34 -0
- package/es/site/data/components/transfer/demos/pagination/index.d.ts +19 -0
- package/es/site/data/components/transfer/demos/pagination/index.js +42 -0
- package/es/site/data/components/transfer/demos/pagination/react.d.ts +20 -0
- package/es/site/data/components/transfer/demos/pagination/react.js +65 -0
- package/es/site/data/components/transfer/demos/table/index.d.ts +33 -0
- package/es/site/data/components/transfer/demos/table/index.js +132 -0
- package/es/site/data/components/transfer/demos/table/react.d.ts +35 -0
- package/es/site/data/components/transfer/demos/table/react.js +246 -0
- package/es/site/src/router/index.js +4 -33
- package/es/styles/fonts/iconfont.eot +0 -0
- package/es/styles/fonts/iconfont.js +1 -1
- package/es/styles/fonts/iconfont.svg +38 -0
- package/es/styles/fonts/iconfont.ttf +0 -0
- package/es/styles/fonts/iconfont.woff +0 -0
- package/es/styles/fonts/iconfont.woff2 +0 -0
- package/es/styles/theme.d.ts +8 -0
- package/es/styles/theme.js +5 -1
- package/index.ts +4 -2
- package/package.json +2 -2
- package/styles/.DS_Store +0 -0
- package/styles/fonts/demo_index.html +443 -6
- package/styles/fonts/iconfont.css +82 -6
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.json +133 -0
- package/styles/fonts/iconfont.svg +38 -0
- package/styles/fonts/iconfont.ts +76 -0
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/theme.ts +4 -0
|
@@ -4,7 +4,9 @@ import {_$} from '../../i18n';
|
|
|
4
4
|
import {useTransfer} from './useTransfer';
|
|
5
5
|
import {useFilter, Model} from './useFilter';
|
|
6
6
|
import {useCheck, CheckedKeys} from './useCheck';
|
|
7
|
+
import {usePagination} from './usePagination';
|
|
7
8
|
import type {Events} from '../types';
|
|
9
|
+
import type {PaginationProps, PaginationChangeData} from '../pagination';
|
|
8
10
|
import { useConfigContext } from '../config';
|
|
9
11
|
|
|
10
12
|
// type KeysOfType<T, U> = {
|
|
@@ -32,6 +34,7 @@ export interface TransferProps<
|
|
|
32
34
|
rightTitle?: string | VNode,
|
|
33
35
|
enableAdd?: () => boolean,
|
|
34
36
|
enableRemove?: () => boolean,
|
|
37
|
+
pagination?: boolean | PaginationProps,
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
export type TransferDataItem<
|
|
@@ -48,6 +51,7 @@ export type TransferDataItem<
|
|
|
48
51
|
export interface TransferEvents {
|
|
49
52
|
add: []
|
|
50
53
|
remove: []
|
|
54
|
+
page: [Model, PaginationChangeData]
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
export interface TransferBlocks<T, V> {
|
|
@@ -73,6 +77,7 @@ const typeDefs: Required<TypeDefs<TransferProps>> = {
|
|
|
73
77
|
rightTitle: [String, VNode],
|
|
74
78
|
enableAdd: Function,
|
|
75
79
|
enableRemove: Function,
|
|
80
|
+
pagination: [Boolean, Object],
|
|
76
81
|
};
|
|
77
82
|
|
|
78
83
|
const defaults = (): Partial<TransferProps> => ({
|
|
@@ -90,6 +95,7 @@ const defaults = (): Partial<TransferProps> => ({
|
|
|
90
95
|
const events: Events<TransferEvents> = {
|
|
91
96
|
add: true,
|
|
92
97
|
remove: true,
|
|
98
|
+
page: true,
|
|
93
99
|
};
|
|
94
100
|
|
|
95
101
|
export class Transfer<
|
|
@@ -105,6 +111,7 @@ export class Transfer<
|
|
|
105
111
|
|
|
106
112
|
private transfer = useTransfer();
|
|
107
113
|
private filter = useFilter(this.transfer.rightData);
|
|
114
|
+
public paginationState = usePagination();
|
|
108
115
|
private check = useCheck(this.filter);
|
|
109
116
|
private config = useConfigContext();
|
|
110
117
|
|
|
@@ -6,14 +6,21 @@ import {Checkbox} from '../checkbox';
|
|
|
6
6
|
import {Button} from '../button';
|
|
7
7
|
import {Tree} from '../tree';
|
|
8
8
|
import {Icon} from '../icon';
|
|
9
|
+
import {Pagination} from '../pagination';
|
|
10
|
+
import {isObject, EMPTY_OBJ} from 'intact-shared';
|
|
9
11
|
|
|
10
12
|
const {
|
|
11
13
|
data, className, keyName, labelName,
|
|
12
|
-
filterable, filter, placeholder
|
|
14
|
+
filterable, filter, placeholder, pagination
|
|
13
15
|
} = this.get();
|
|
14
16
|
const {getShowedData} = this.filter;
|
|
15
17
|
const {enableAdd, enableRemove, add, remove} = this.transfer;
|
|
16
18
|
const {isCheckAll, toggleCheckAll, onCheckboxChange, isIndeterminate} = this.check;
|
|
19
|
+
const {
|
|
20
|
+
getPagedData,
|
|
21
|
+
leftValue, leftLimit, rightValue, rightLimit,
|
|
22
|
+
onChange: onPageChange
|
|
23
|
+
} = this.paginationState;
|
|
17
24
|
const { k } = this.config;
|
|
18
25
|
|
|
19
26
|
const classNameObj = {
|
|
@@ -24,14 +31,19 @@ const classNameObj = {
|
|
|
24
31
|
|
|
25
32
|
const Panel = (model) => {
|
|
26
33
|
const title = this.get(`${model}Title`);
|
|
27
|
-
|
|
34
|
+
|
|
35
|
+
const allData = getShowedData(model) || [];
|
|
36
|
+
const hasPagination = !!pagination;
|
|
37
|
+
const displayData = hasPagination
|
|
38
|
+
? getPagedData(model, allData)
|
|
39
|
+
: allData;
|
|
28
40
|
|
|
29
41
|
return <div class={`${k}-transfer-panel`}>
|
|
30
42
|
<div class={`${k}-transfer-title`}>
|
|
31
43
|
<b:header params={model}>
|
|
32
44
|
<div class={`${k}-transfer-count`}>
|
|
33
45
|
{this.get(`${model}CheckedKeys.length`)} /
|
|
34
|
-
{
|
|
46
|
+
{allData.length}
|
|
35
47
|
</div>
|
|
36
48
|
<Checkbox class="c-ellipsis"
|
|
37
49
|
value={isCheckAll(model)}
|
|
@@ -54,7 +66,7 @@ const Panel = (model) => {
|
|
|
54
66
|
<div class={`${k}-transfer-list`}>
|
|
55
67
|
<b:list params={model}>
|
|
56
68
|
<TransitionGroup name="k-fade">
|
|
57
|
-
<div v-for={
|
|
69
|
+
<div v-for={displayData}
|
|
58
70
|
class={{[`${k}-transfer-item`]: true, [`${k}-disabled`]: $value.disabled}}
|
|
59
71
|
key={$value[keyName] || $value[labelName] || $value}
|
|
60
72
|
>
|
|
@@ -73,6 +85,20 @@ const Panel = (model) => {
|
|
|
73
85
|
</TransitionGroup>
|
|
74
86
|
</b:list>
|
|
75
87
|
</div>
|
|
88
|
+
<div class={`${k}-transfer-pagination-wrapper`} v-if={hasPagination}>
|
|
89
|
+
<Pagination
|
|
90
|
+
ref={model === 'left' ? this.paginationState.leftPaginationRef : this.paginationState.rightPaginationRef}
|
|
91
|
+
total={allData.length}
|
|
92
|
+
size="mini"
|
|
93
|
+
flat
|
|
94
|
+
showTotal={false}
|
|
95
|
+
showLimits={false}
|
|
96
|
+
{...(isObject(pagination) ? pagination : EMPTY_OBJ)}
|
|
97
|
+
value={model === 'left' ? leftValue.value : rightValue.value}
|
|
98
|
+
limit={model === 'left' ? leftLimit.value : rightLimit.value}
|
|
99
|
+
ev-change={onPageChange.bind(null, model)}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
76
102
|
</div>
|
|
77
103
|
};
|
|
78
104
|
|
|
@@ -36,6 +36,10 @@ const defaults = {
|
|
|
36
36
|
|
|
37
37
|
arrow: {
|
|
38
38
|
gap: '16px 10px',
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
pagination: {
|
|
42
|
+
padding: '6px 0',
|
|
39
43
|
}
|
|
40
44
|
};
|
|
41
45
|
|
|
@@ -60,7 +64,7 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
60
64
|
height: ${transfer.panel.height};
|
|
61
65
|
display: inline-flex;
|
|
62
66
|
flex-direction: column;
|
|
63
|
-
overflow:
|
|
67
|
+
overflow: hidden;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
.${k}-transfer-title {
|
|
@@ -118,5 +122,11 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
118
122
|
margin: ${transfer.arrow.gap};
|
|
119
123
|
}
|
|
120
124
|
}
|
|
125
|
+
.${k}-transfer-pagination-wrapper {
|
|
126
|
+
padding: ${transfer.pagination.padding};
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
}
|
|
121
131
|
`;
|
|
122
132
|
});
|
|
@@ -34,10 +34,10 @@ export function useCheck({getEnabledData, getShowedData}: ReturnType<typeof useF
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function isIndeterminate(model: Model) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const checked = instance.get(`${model}CheckedKeys` as CheckedKeys)!;
|
|
38
|
+
const data = getEnabledData(model);
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
return checked.length > 0 && checked.length < data.length;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function onCheckboxChange(model: Model, index: number, e: MouseEvent) {
|
|
@@ -47,8 +47,8 @@ export function useCheck({getEnabledData, getShowedData}: ReturnType<typeof useF
|
|
|
47
47
|
checked = (e.target as HTMLInputElement).checked;
|
|
48
48
|
} else if (e.shiftKey) {
|
|
49
49
|
e.preventDefault();
|
|
50
|
-
|
|
51
|
-
const values =
|
|
50
|
+
const allData = getShowedData(model)!;
|
|
51
|
+
const values = instance.get('pagination') ? instance.paginationState.getPagedData(model, allData) : allData;
|
|
52
52
|
const checkedKeys = instance.get(`${model}CheckedKeys` as CheckedKeys)!.slice(0);
|
|
53
53
|
const lastEndIndex = endIndex;
|
|
54
54
|
const keyName = instance.get('keyName')!;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {useInstance, createRef} from 'intact';
|
|
2
|
+
import type {Transfer} from './index';
|
|
3
|
+
import type {Model} from './useFilter';
|
|
4
|
+
import {useState} from '../../hooks/useState';
|
|
5
|
+
import {Pagination, PaginationChangeData} from '../pagination';
|
|
6
|
+
import {isObject} from 'intact-shared';
|
|
7
|
+
import { useReceive } from '../../hooks/useReceive';
|
|
8
|
+
|
|
9
|
+
const defaultPagination = Pagination.defaults();
|
|
10
|
+
|
|
11
|
+
export function usePagination() {
|
|
12
|
+
const instance = useInstance() as Transfer;
|
|
13
|
+
|
|
14
|
+
const leftValue = useState<number>(defaultPagination.value!);
|
|
15
|
+
const leftLimit = useState<number>(defaultPagination.limit!);
|
|
16
|
+
const rightValue = useState<number>(defaultPagination.value!);
|
|
17
|
+
const rightLimit = useState<number>(defaultPagination.limit!);
|
|
18
|
+
|
|
19
|
+
const leftPaginationRef = createRef<Pagination>();
|
|
20
|
+
const rightPaginationRef = createRef<Pagination>();
|
|
21
|
+
|
|
22
|
+
useReceive<Transfer>(['pagination'], () => {
|
|
23
|
+
const pagination = instance.get('pagination');
|
|
24
|
+
if (isObject(pagination)) {
|
|
25
|
+
if (pagination.value !== undefined) {
|
|
26
|
+
leftValue.set(pagination.value);
|
|
27
|
+
rightValue.set(pagination.value);
|
|
28
|
+
}
|
|
29
|
+
if (pagination.limit !== undefined) {
|
|
30
|
+
leftLimit.set(pagination.limit);
|
|
31
|
+
rightLimit.set(pagination.limit);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
instance.watch('leftKeywords', () => {
|
|
37
|
+
leftValue.set(1);;
|
|
38
|
+
});
|
|
39
|
+
instance.watch('rightKeywords', () => {
|
|
40
|
+
rightValue.set(1);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// 计算分页数据
|
|
44
|
+
function getPagedData(model: Model, allData: any[]) {
|
|
45
|
+
if (!instance.get('pagination')) {
|
|
46
|
+
return allData;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const value = model === 'left' ? leftValue.value : rightValue.value;
|
|
50
|
+
const limit = model === 'left' ? leftLimit.value : rightLimit.value;
|
|
51
|
+
const totalPages = Math.ceil(allData.length / limit) || 1;
|
|
52
|
+
|
|
53
|
+
// 如果当前页超出总页数,跳转到最后一页
|
|
54
|
+
let currentPage = value;
|
|
55
|
+
if (currentPage > totalPages && totalPages > 0) {
|
|
56
|
+
currentPage = totalPages;
|
|
57
|
+
if (model === 'left') {
|
|
58
|
+
leftValue.set(currentPage);
|
|
59
|
+
} else {
|
|
60
|
+
rightValue.set(currentPage);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 切片数据
|
|
65
|
+
const index = (currentPage - 1) * limit;
|
|
66
|
+
return allData.slice(index, index + limit);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function onChange(model: Model, data: PaginationChangeData) {
|
|
70
|
+
if (model === 'left') {
|
|
71
|
+
leftValue.set(data.value);
|
|
72
|
+
leftLimit.set(data.limit);
|
|
73
|
+
} else {
|
|
74
|
+
rightValue.set(data.value);
|
|
75
|
+
rightLimit.set(data.limit);
|
|
76
|
+
}
|
|
77
|
+
// 触发分页事件
|
|
78
|
+
instance.trigger('page', model, data);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
getPagedData,
|
|
83
|
+
leftValue,
|
|
84
|
+
leftLimit,
|
|
85
|
+
rightValue,
|
|
86
|
+
rightLimit,
|
|
87
|
+
onChange,
|
|
88
|
+
leftPaginationRef,
|
|
89
|
+
rightPaginationRef,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|