@king-design/vue 2.0.16 → 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.
Files changed (74) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +115 -91
  2. package/__tests__/components/editable.spec.ts +45 -0
  3. package/components/cascader/index.d.ts +22 -11
  4. package/components/cascader/index.js +9 -12
  5. package/components/cascader/index.spec.js +81 -0
  6. package/components/cascader/index.vdt.js +10 -8
  7. package/components/cascader/styles.js +1 -1
  8. package/components/cascader/useFields.d.ts +2 -0
  9. package/components/cascader/useFields.js +18 -0
  10. package/components/cascader/useFilterable.d.ts +2 -1
  11. package/components/cascader/useFilterable.js +17 -6
  12. package/components/cascader/useLabel.d.ts +2 -1
  13. package/components/cascader/useLabel.js +4 -4
  14. package/components/cascader/useLoad.d.ts +2 -1
  15. package/components/cascader/useLoad.js +9 -7
  16. package/components/colorpicker/index.d.ts +2 -0
  17. package/components/colorpicker/index.js +7 -2
  18. package/components/colorpicker/index.vdt.js +3 -6
  19. package/components/dialog/index.spec.js +2 -2
  20. package/components/dropdown/dropdown.d.ts +0 -1
  21. package/components/dropdown/dropdown.js +19 -8
  22. package/components/dropdown/item.js +3 -3
  23. package/components/dropdown/menu.js +1 -1
  24. package/components/dropdown/usePosition.js +8 -1
  25. package/components/editable/index.d.ts +1 -0
  26. package/components/editable/index.js +20 -6
  27. package/components/editable/index.vdt.js +2 -1
  28. package/components/input/index.d.ts +10 -2
  29. package/components/input/index.js +10 -3
  30. package/components/input/index.spec.js +169 -1
  31. package/components/input/index.vdt.js +26 -7
  32. package/components/input/styles.js +8 -3
  33. package/components/input/useAutoRows.d.ts +2 -0
  34. package/components/input/useAutoRows.js +79 -0
  35. package/components/input/useAutoWidth.js +13 -3
  36. package/components/input/useShowPassword.d.ts +7 -0
  37. package/components/input/useShowPassword.js +31 -0
  38. package/components/pagination/index.js +1 -3
  39. package/components/pagination/index.spec.js +2 -4
  40. package/components/portal.d.ts +6 -2
  41. package/components/portal.js +4 -3
  42. package/components/position.js +2 -1
  43. package/components/select/base.d.ts +2 -1
  44. package/components/select/base.js +3 -1
  45. package/components/select/base.vdt.js +3 -1
  46. package/components/table/cell.js +1 -6
  47. package/components/table/index.spec.js +130 -19
  48. package/components/table/row.d.ts +1 -1
  49. package/components/table/row.js +2 -1
  50. package/components/table/styles.js +1 -1
  51. package/components/table/table.d.ts +15 -0
  52. package/components/table/table.js +16 -7
  53. package/components/table/table.vdt.js +20 -6
  54. package/components/table/useChecked.d.ts +3 -2
  55. package/components/table/useChecked.js +23 -12
  56. package/components/table/useDisableRow.d.ts +2 -1
  57. package/components/table/useDisableRow.js +4 -4
  58. package/components/table/useDraggable.d.ts +3 -2
  59. package/components/table/useDraggable.js +11 -8
  60. package/components/table/useGroup.js +3 -0
  61. package/components/table/useMerge.d.ts +2 -1
  62. package/components/table/useMerge.js +5 -4
  63. package/components/table/usePagination.d.ts +8 -0
  64. package/components/table/usePagination.js +81 -0
  65. package/components/table/useTree.d.ts +2 -1
  66. package/components/table/useTree.js +3 -4
  67. package/components/tooltip/index.spec.js +9 -10
  68. package/components/tooltip/tooltip.d.ts +0 -1
  69. package/components/tooltip/tooltip.js +1 -12
  70. package/index.d.ts +3 -3
  71. package/index.js +3 -3
  72. package/package.json +2 -2
  73. package/styles/fonts/ionicons.js +1 -1
  74. package/yarn-error.log +0 -899
@@ -0,0 +1,31 @@
1
+ import { useInstance } from 'intact-vue-next';
2
+ import { useState } from '../../hooks/useState';
3
+ import { useReceive } from '../../hooks/useReceive';
4
+ export function useShowPassword() {
5
+ var instance = useInstance();
6
+ var isShow = useState(false);
7
+ var type = useState(undefined);
8
+ var showIcon = useState(false);
9
+ instance.on('$receive:type', function (_type) {
10
+ type.set(_type);
11
+ });
12
+ useReceive(['type', 'showPassword'], function () {
13
+ var _instance$get = instance.get(),
14
+ showPassword = _instance$get.showPassword,
15
+ type = _instance$get.type;
16
+
17
+ showIcon.set(type === 'password' && !!showPassword);
18
+ });
19
+
20
+ function toggleShow() {
21
+ isShow.set(!isShow.value);
22
+ type.set(isShow.value ? 'text' : 'password');
23
+ }
24
+
25
+ return {
26
+ isShow: isShow,
27
+ type: type,
28
+ toggleShow: toggleShow,
29
+ showIcon: showIcon
30
+ };
31
+ }
@@ -105,9 +105,7 @@ export var Pagination = /*#__PURE__*/function (_Component) {
105
105
 
106
106
  if (page > totalPages) {
107
107
  page = totalPages;
108
- }
109
-
110
- if (page < 1) {
108
+ } else if (page < 1) {
111
109
  page = 1;
112
110
  }
113
111
 
@@ -4,11 +4,9 @@ import BasicDemo from '~/components/pagination/demos/basic';
4
4
  import GotoDemo from '~/components/pagination/demos/goto';
5
5
  import CurrentDemo from '~/components/pagination/demos/current';
6
6
  import DisableDemo from '~/components/pagination/demos/disable';
7
- import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
7
+ import { mount, dispatchEvent, wait } from '../../test/utils';
8
8
  describe('Pagination', function () {
9
- afterEach(function () {
10
- return unmount();
11
- });
9
+ // afterEach(() => unmount());
12
10
  it('basic test', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
13
11
  var _mount, instance, element, pagination, btns, prev, next;
14
12
 
@@ -11,8 +11,12 @@ export declare class Portal<T extends PortalProps = PortalProps> extends Compone
11
11
  mountedQueue?: Function[];
12
12
  mountedDone?: boolean;
13
13
  $isPortal: boolean;
14
- $render(lastVNode: VNodeComponentClass<this> | null, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[]): void;
15
- $update(lastVNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[], force: boolean): void;
14
+ $render(lastVNode: VNodeComponentClass<this> | null, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[] & {
15
+ priority?: Function[];
16
+ }): void;
17
+ $update(lastVNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[] & {
18
+ priority?: Function[];
19
+ }, force: boolean): void;
16
20
  $unmount(vNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this> | null): void;
17
21
  private initContainer;
18
22
  }
@@ -38,7 +38,8 @@ export var Portal = /*#__PURE__*/function (_Component) {
38
38
 
39
39
  var _proto = Portal.prototype;
40
40
 
41
- _proto.$render = function $render(lastVNode, nextVNode, parentDom, anchor, mountedQueue) {
41
+ _proto.$render = function $render(lastVNode, nextVNode, parentDom, anchor, mountedQueue // in React, it has priority property to add some prior functions
42
+ ) {
42
43
  var _this2 = this;
43
44
 
44
45
  /**
@@ -47,7 +48,7 @@ export var Portal = /*#__PURE__*/function (_Component) {
47
48
  */
48
49
  var nextProps = nextVNode.props;
49
50
  var fakeContainer = document.createDocumentFragment();
50
- mountedQueue.push(function () {
51
+ (mountedQueue.priority || mountedQueue).push(function () {
51
52
  var parentDom = _this2.$lastInput.dom.parentElement;
52
53
 
53
54
  _this2.initContainer(nextProps.container, parentDom, anchor);
@@ -87,7 +88,7 @@ export var Portal = /*#__PURE__*/function (_Component) {
87
88
 
88
89
  if (!this.container) {
89
90
  // in react, sometimes $update will be called before mountedQueue in $render
90
- mountedQueue.push(update);
91
+ (mountedQueue.priority || mountedQueue).push(update);
91
92
  } else {
92
93
  update();
93
94
  }
@@ -1,6 +1,7 @@
1
1
  import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
2
2
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
3
  import _atInstanceProperty from "@babel/runtime-corejs3/core-js/instance/at";
4
+ import { isArray } from 'intact-shared';
4
5
  var max = Math.max;
5
6
  var abs = Math.abs;
6
7
  var rHorizontal = /left|center|right/;
@@ -191,7 +192,7 @@ export default function position(elem, options) {
191
192
  var basePosition = _Object$assign({}, targetOffset); // don't detect collison if the target is not in viewport
192
193
 
193
194
 
194
- var collision = isInViewport(targetRect) ? (options.collision || 'flip').split(' ') : ['none', 'none'];
195
+ var collision = isInViewport(targetRect) ? !isArray(options.collision) ? (options.collision || 'flip').split(' ') : options.collision : ['none', 'none'];
195
196
  var offsets = {};
196
197
  var within = getWithinInfo(options.within);
197
198
  var scrollInfo = getScrollInfo(within);
@@ -1,7 +1,7 @@
1
1
  import { Component, Children, TypeDefs, RefObject } from 'intact-vue-next';
2
2
  import { Sizes } from '../../styles/utils';
3
3
  import type { Input } from '../input';
4
- import { Dropdown } from '../dropdown';
4
+ import { Dropdown, DropdownProps } from '../dropdown';
5
5
  import { State } from '../../hooks/useState';
6
6
  import { Container } from '../portal';
7
7
  import type { Events } from '../types';
@@ -21,6 +21,7 @@ export interface BaseSelectProps<V, Multipe extends boolean = boolean, Attach =
21
21
  container?: Container;
22
22
  width?: string | number;
23
23
  show?: boolean;
24
+ position?: DropdownProps['position'];
24
25
  }
25
26
  export interface BaseSelectEvents {
26
27
  keydown: [KeyboardEvent];
@@ -9,6 +9,7 @@ import { sizes } from '../../styles/utils';
9
9
  import { SELECT } from './constants';
10
10
  import { useShowHideEvents } from '../../hooks/useShowHideEvents';
11
11
  import { bind } from '../utils';
12
+ import { Dropdown } from '../dropdown';
12
13
  import { useInput } from './useInput';
13
14
  import { useFocusout } from './useFocusout';
14
15
  import { isNullOrUndefined } from 'intact-shared';
@@ -27,7 +28,8 @@ var typeDefs = {
27
28
  placeholder: [String, Number],
28
29
  container: [Function, String],
29
30
  width: [String, Number],
30
- show: Boolean
31
+ show: Boolean,
32
+ position: Dropdown.typeDefs.position
31
33
  };
32
34
 
33
35
  var defaults = function defaults() {
@@ -40,7 +40,8 @@ export default function ($props, $blocks, $__proto__) {
40
40
  inline = _this$get.inline,
41
41
  style = _this$get.style,
42
42
  width = _this$get.width,
43
- show = _this$get.show;
43
+ show = _this$get.show,
44
+ position = _this$get.position;
44
45
 
45
46
  var classNameObj = (_classNameObj = {
46
47
  'k-select': true,
@@ -67,6 +68,7 @@ export default function ($props, $blocks, $__proto__) {
67
68
  'ref': _this.dropdownRef,
68
69
  'disabled': disabled,
69
70
  'container': container,
71
+ 'position': position,
70
72
  'children': [_$cv('div', _extends({}, getRestProps(_this), {
71
73
  'className': _$cn(classNameObj),
72
74
  'tabindex': disabled ? '-1' : '0',
@@ -16,12 +16,7 @@ export var TableCell = /*#__PURE__*/function (_Component) {
16
16
  var isSame = true;
17
17
 
18
18
  for (var key in lastProps) {
19
- if (lastProps[key] !== nextProps[key]) {
20
- isSame = false;
21
- break;
22
- }
23
-
24
- if (key === 'props' && nextProps.props.$blocks) {
19
+ if (lastProps[key] !== nextProps[key] || key === 'props' && nextProps.props.$blocks) {
25
20
  isSame = false;
26
21
  break;
27
22
  }
@@ -23,13 +23,14 @@ import { Table, TableColumn } from './';
23
23
  import DraggableTable from '~/components/table/demos/draggable';
24
24
  import MergeCellDemo from '~/components/table/demos/mergeCell';
25
25
  import { AllCheckedStatus } from './useChecked';
26
+ import PaginationDemo from '~/components/table/demos/pagination';
26
27
  describe('Table', function () {
27
28
  afterEach(function () {
28
29
  unmount();
29
30
  localStorage.removeItem('resizableTable');
30
31
  });
31
32
  it('check & uncheck', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
32
- var _mount, instance, element, table, checked, spy, _element$querySelecto, tr1, tr2, all;
33
+ var _mount, instance, element, table, checked, spy, spyCheckRow, spyUncheckRow, spyCheckAll, spyUncheckAll, _element$querySelecto, tr1, tr2, all;
33
34
 
34
35
  return _regeneratorRuntime.wrap(function _callee$(_context) {
35
36
  while (1) {
@@ -42,54 +43,76 @@ describe('Table', function () {
42
43
  spy = sinon.spy(function (v) {
43
44
  return console.log(v);
44
45
  });
45
- table.on('$change:checkedKeys', spy); // click row
46
+ table.on('$change:checkedKeys', spy);
47
+ spyCheckRow = sinon.spy(function (data, index, key) {
48
+ return console.log('checkRow', data, index, key);
49
+ });
50
+ table.on('checkRow', spyCheckRow);
51
+ spyUncheckRow = sinon.spy(function (data, index, key) {
52
+ return console.log('uncheckRow', data, index, key);
53
+ });
54
+ table.on('uncheckRow', spyUncheckRow);
55
+ spyCheckAll = sinon.spy(function () {
56
+ return console.log('checkAll');
57
+ });
58
+ table.on('checkAll', spyCheckAll);
59
+ spyUncheckAll = sinon.spy(function () {
60
+ return console.log('uncheckAll');
61
+ });
62
+ table.on('uncheckAll', spyUncheckAll); // click row
46
63
 
47
64
  _element$querySelecto = element.querySelectorAll('tbody tr'), tr1 = _element$querySelecto[0], tr2 = _element$querySelecto[1];
48
65
  tr1.click();
49
- _context.next = 9;
66
+ _context.next = 17;
50
67
  return wait();
51
68
 
52
- case 9:
69
+ case 17:
53
70
  expect(table.get('checkedKeys')).to.eql([0]);
71
+ expect(spyCheckRow.callCount).to.eql(1);
54
72
  tr2.click();
55
- _context.next = 13;
73
+ _context.next = 22;
56
74
  return wait();
57
75
 
58
- case 13:
76
+ case 22:
59
77
  expect(table.get('checkedKeys')).to.eql([0, 1]);
60
78
  expect(checked.getAllCheckedStatus()).eql(AllCheckedStatus.All);
79
+ expect(spyCheckRow.callCount).to.eql(2);
80
+ expect(spyCheckAll.callCount).to.eq(0);
61
81
  tr1.click();
62
- _context.next = 18;
82
+ _context.next = 29;
63
83
  return wait();
64
84
 
65
- case 18:
85
+ case 29:
66
86
  expect(table.get('checkedKeys')).to.eql([1]);
67
87
  expect(checked.getAllCheckedStatus()).eql(AllCheckedStatus.Indeterminate);
88
+ expect(spyUncheckRow.callCount).to.eql(1);
68
89
  all = element.querySelector('.k-checkbox');
69
90
  all.click();
70
- _context.next = 24;
91
+ _context.next = 36;
71
92
  return wait();
72
93
 
73
- case 24:
94
+ case 36:
74
95
  expect(checked.getAllCheckedStatus()).eql(AllCheckedStatus.All);
96
+ expect(spyCheckAll.callCount).to.eql(1);
75
97
  all.click();
76
- _context.next = 28;
98
+ _context.next = 41;
77
99
  return wait();
78
100
 
79
- case 28:
101
+ case 41:
80
102
  expect(checked.getAllCheckedStatus()).eql(AllCheckedStatus.None);
81
103
  expect(table.get('checkedKeys')).to.eql([]);
104
+ expect(spyUncheckAll.callCount).to.eql(1);
82
105
  expect(spy.callCount).to.eql(5); // clear data of table should only trigger $change:checked event once, #407
83
106
 
84
107
  all.click();
85
- table.set('data', []);
86
- _context.next = 35;
108
+ instance.set('data', []);
109
+ _context.next = 49;
87
110
  return wait();
88
111
 
89
- case 35:
112
+ case 49:
90
113
  expect(spy.callCount).to.eql(7);
91
114
 
92
- case 36:
115
+ case 50:
93
116
  case "end":
94
117
  return _context.stop();
95
118
  }
@@ -342,7 +365,7 @@ describe('Table', function () {
342
365
  }, _callee6);
343
366
  })));
344
367
  it('group', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
345
- var _mount7, instance, element, _instance$refs4, __test1, __test2, _element$querySelecto8, table1, table2, icon, dropdown, item, icon2, dropdown2, _dropdown2$querySelec, item1, item2;
368
+ var _mount7, instance, element, _instance$refs4, __test1, __test2, _element$querySelecto8, table1, table2, icon, dropdown, item, icon2, dropdown2, _dropdown2$querySelec, item1, item2, newDropdown;
346
369
 
347
370
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
348
371
  while (1) {
@@ -395,9 +418,21 @@ describe('Table', function () {
395
418
  expect(instance.get('multipleGroup')).to.eql({
396
419
  status: ['active', 'stopped']
397
420
  });
398
- expect(table2.innerHTML).to.matchSnapshot();
421
+ expect(table2.innerHTML).to.matchSnapshot(); // update group
399
422
 
400
- case 32:
423
+ instance.set('statusGroup', [{
424
+ label: 'label',
425
+ value: 'value'
426
+ }]);
427
+ dispatchEvent(icon, 'click');
428
+ _context7.next = 36;
429
+ return wait(500);
430
+
431
+ case 36:
432
+ newDropdown = getElement('.k-table-group-dropdown');
433
+ expect(newDropdown.innerHTML).to.matchSnapshot();
434
+
435
+ case 38:
401
436
  case "end":
402
437
  return _context7.stop();
403
438
  }
@@ -1064,4 +1099,80 @@ describe('Table', function () {
1064
1099
  }
1065
1100
  }, _callee22);
1066
1101
  })));
1102
+ it('pagination', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1103
+ var _mount25, instance, element, table, pagination, spy;
1104
+
1105
+ return _regeneratorRuntime.wrap(function _callee23$(_context26) {
1106
+ while (1) {
1107
+ switch (_context26.prev = _context26.next) {
1108
+ case 0:
1109
+ _mount25 = mount(PaginationDemo), instance = _mount25[0], element = _mount25[1];
1110
+ table = instance.refs.table;
1111
+ pagination = table.pagination.paginationRef;
1112
+ spy = sinon.spy();
1113
+ table.on('changePage', spy); // check all
1114
+
1115
+ table.checkAll();
1116
+ expect(table.getCheckedData()).to.have.length(10); // next page
1117
+
1118
+ table.set('pagination', {
1119
+ value: 2
1120
+ });
1121
+ table.trigger('$receive:pagination');
1122
+ _context26.next = 11;
1123
+ return wait();
1124
+
1125
+ case 11:
1126
+ expect(table.getCheckedData()).to.have.length(0); // check all again
1127
+
1128
+ table.checkAll();
1129
+ expect(table.getCheckedData()).to.have.length(10); // change limit
1130
+
1131
+ table.set('pagination', {
1132
+ value: 1,
1133
+ limit: 20
1134
+ });
1135
+ table.trigger('$receive:pagination');
1136
+ _context26.next = 18;
1137
+ return wait();
1138
+
1139
+ case 18:
1140
+ expect(table.getCheckedData()).to.have.length(10); // check all again
1141
+
1142
+ table.checkAll();
1143
+ expect(table.getCheckedData()).to.have.length(20); // change limit from pagination
1144
+
1145
+ pagination.value.set('limit', 10);
1146
+ _context26.next = 24;
1147
+ return wait();
1148
+
1149
+ case 24:
1150
+ expect(table.getCheckedData()).to.have.length(10); // FIXME: Pagination component should no trigger change event multiple times
1151
+ // when we set value and limit at the same time
1152
+
1153
+ expect(spy.callCount).to.eql(4);
1154
+ expect(spy.lastCall.lastArg).to.eql({
1155
+ value: 1,
1156
+ limit: 10
1157
+ }); // change page from pagination
1158
+
1159
+ _context26.next = 29;
1160
+ return wait();
1161
+
1162
+ case 29:
1163
+ pagination.value.changePage(2);
1164
+ expect(table.getCheckedData()).to.have.length(0);
1165
+ expect(spy.callCount).to.eql(5);
1166
+ expect(spy.lastCall.lastArg).to.eql({
1167
+ value: 2,
1168
+ limit: 10
1169
+ });
1170
+
1171
+ case 33:
1172
+ case "end":
1173
+ return _context26.stop();
1174
+ }
1175
+ }
1176
+ }, _callee23);
1177
+ })));
1067
1178
  });
@@ -14,7 +14,7 @@ export interface TableRowProps {
14
14
  index: number;
15
15
  disabled: boolean;
16
16
  allDisabled: boolean;
17
- onChangeChecked: (index: number, checked: boolean) => void;
17
+ onChangeChecked: (index: number, checked: boolean, key: TableRowKey) => void;
18
18
  grid: TableGrid;
19
19
  selected: boolean;
20
20
  spreaded: boolean;
@@ -56,9 +56,10 @@ export var TableRow = /*#__PURE__*/function (_Component) {
56
56
  _proto.onChangeChecked = function onChangeChecked(v) {
57
57
  var _this$get2 = this.get(),
58
58
  index = _this$get2.index,
59
+ key = _this$get2.key,
59
60
  onChangeChecked = _this$get2.onChangeChecked;
60
61
 
61
- onChangeChecked(index, v);
62
+ onChangeChecked(index, v, key);
62
63
  };
63
64
 
64
65
  _proto.onClickArrow = function onClickArrow(e) {
@@ -92,7 +92,7 @@ setDefault(function () {
92
92
  export function makeStyles() {
93
93
  return /*#__PURE__*/css("font-size:", table.fontSize, ";color:", table.color, ";border-top:", table.border, ";position:relative;z-index:0;.k-table-wrapper{border-bottom:", table.border, ";overflow:auto;}table{width:100%;border-spacing:0;table-layout:fixed;td,th{transition:all ", table.transition, ";}}thead{text-align:", table.thead.textAlign, ";font-size:", table.thead.fontSize, ";font-weight:", table.thead.fontWeight, ";position:sticky;top:0;z-index:2;tr{height:", table.thead.height, ";}}th{padding:", table.thead.padding, ";position:relative;background:", table.thead.bgColor, ";border-bottom:", table.border, ";&:before{content:'';height:", table.thead.delimiterHeight, ";position:absolute;background-color:", table.thead.delimiterColor, ";width:1px;left:1px;top:50%;transform:translateY(-50%);}&:first-of-type:before{display:none;}}.k-table-title{display:inline-flex;align-items:center;max-width:100%;}.k-table-title-text{flex:1;}tbody{tr{&:hover td{background:", table.tbody.hoverBgcolor, ";}&:last-of-type td{border-bottom-color:transparent;}}}td{padding:", table.tbody.padding, ";border-bottom:", table.border, ";background:", table.bgColor, ";word-wrap:break-word;}.k-fixed-left,.k-fixed-right{position:sticky;z-index:1;&:after{content:'';display:block;transition:box-shadow ", table.transition, ";position:absolute;top:0;bottom:0px;width:10px;pointer-events:none;}}.k-fixed-left:after{right:-11px;}.k-fixed-right:after{left:-11px;}&.k-scroll-left .k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}&.k-scroll-right .k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}&.k-scroll-middle{.k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}.k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}}.k-fixed-right+.k-fixed-right:after{display:none;}.k-table-affix-header{position:sticky;top:0;left:0;.k-affix-wrapper{overflow:hidden;}&.k-fixed{position:relative;}}&.k-border,&.k-grid{.k-table-wrapper{border-left:", table.border, ";border-right:", table.border, ";}}&.k-grid{td:not(:last-of-type),th:not(:last-of-type){border-right:", table.border, ";}th:before{display:none;}}&.k-stripe{tr:nth-child(even):not(:hover) td{background:", table.stripeBgColor, ";}}.k-table-group{width:", table.group.width, "!important;height:", table.group.width, "!important;margin-left:", table.group.gap, ";position:relative;color:", table.group.color, ";&:hover{color:", theme.color.primary, ";}.k-icon{transition:transform ", table.transition, ";}&.k-dropdown-open .k-icon{transform:rotate(180deg);}}.k-table-check{.k-checkbox,.k-radio{position:relative;top:-1px;}}.k-column-sortable{cursor:pointer;}.k-column-sort{.k-icon{display:block;height:", _sortInstanceProperty(table).iconHeight, ";line-height:", _sortInstanceProperty(table).iconHeight, ";margin-left:", _sortInstanceProperty(table).gap, ";color:", _sortInstanceProperty(table).color, ";}&.k-asc .k-icon.k-desc,&.k-desc .k-icon.k-asc{color:", _sortInstanceProperty(table).disabledColor, ";}}.k-table-spin.k-overlay{z-index:2;}.k-table-empty{text-align:center;}tr.k-expand{td{padding:0;background:#fdfcff;}}&.k-with-expand{tr:not(.k-expand){td{border-bottom:none;}}}.k-table-expand{border-top:", table.border, ";box-sizing:content-box;}tbody tr.k-selected td{background:", table.selectedBgColor, ";}.k-table-arrow{margin-right:", table.arrow.gap, ";transition:transform ", table.transition, ";position:relative;top:-1px;}tr.k-spreaded{.k-table-arrow{transform:rotate(90deg);}}.k-table-resize{height:100%;width:", table.resizeWidth, ";position:absolute;top:0;left:-1px;cursor:ew-resize;}tr.k-dragging{opacity:", table.draggingOpacity, ";}.k-table-scrollbar{overflow-x:auto;overflow-y:hidden;}.k-table-scrollbar-inner{height:1px;}", _mapInstanceProperty(aligns).call(aligns, function (type) {
94
94
  return /*#__PURE__*/css(".k-align-", type, "{text-align:", type, ";}");
95
- }), ";");
95
+ }), ">.k-pagination{margin:16px 0;}");
96
96
  }
97
97
  export function makeGroupMenuStyles() {
98
98
  return /*#__PURE__*/css("max-height:", table.group.menuMaxHeight, ";overflow:auto;.k-dropdown-item.k-active{color:", table.group.activeColor, ";}.k-table-group-header{padding:", table.group.headerPadding, ";border-bottom:", table.group.headerBorder, ";}");
@@ -2,6 +2,7 @@ import { Component, TypeDefs } from 'intact-vue-next';
2
2
  import { TableMerge } from './useMerge';
3
3
  import { TooltipProps } from '../tooltip/tooltip';
4
4
  import type { Events } from '../types';
5
+ import type { PaginationProps, PaginationChangeData } from '../pagination';
5
6
  export interface TableProps<T = any, K extends TableRowKey = TableRowKey, C extends CheckType = CheckType, S extends string = string, G extends TableGroupValue = TableGroupValue> {
6
7
  data?: T[];
7
8
  fixHeader?: boolean | string | number;
@@ -35,6 +36,8 @@ export interface TableProps<T = any, K extends TableRowKey = TableRowKey, C exte
35
36
  widthStoreKey?: string;
36
37
  draggable?: boolean;
37
38
  animation?: boolean | [boolean, boolean];
39
+ hideHeader?: boolean;
40
+ pagination?: boolean | PaginationProps;
38
41
  }
39
42
  export interface TableEvents<T = any, K extends TableRowKey = number> {
40
43
  clickRow: [T, number, K];
@@ -47,6 +50,11 @@ export interface TableEvents<T = any, K extends TableRowKey = number> {
47
50
  from: number;
48
51
  to: number;
49
52
  }];
53
+ checkRow: [T, number, K];
54
+ uncheckRow: [T, number, K];
55
+ checkAll: [];
56
+ uncheckAll: [];
57
+ changePage: [PaginationChangeData];
50
58
  }
51
59
  export interface TableBlocks<T = unknown> {
52
60
  empty: null;
@@ -66,6 +74,13 @@ export declare class Table<T = any, RowKey extends TableRowKey = TableRowKey, Ch
66
74
  static typeDefs: Required<TypeDefs<TableProps<unknown, TableRowKey, CheckType, string, TableGroupValue<string | number | symbol>>>>;
67
75
  static defaults: () => Partial<TableProps<any, TableRowKey, CheckType, string, TableGroupValue<string | number | symbol>>>;
68
76
  static events: Events<TableEvents<any, number>>;
77
+ pagination: {
78
+ data: import("../../hooks/useState").State<any[] | undefined>;
79
+ value: import("../../hooks/useState").State<number>;
80
+ limit: import("../../hooks/useState").State<number>;
81
+ onChange: (data: PaginationChangeData) => void;
82
+ paginationRef: import("intact").RefObject<import("../pagination").Pagination>;
83
+ };
69
84
  private tree;
70
85
  private columns;
71
86
  private scroll;
@@ -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.tree = useTree();
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-vue-next';
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(Transition, {
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;