@king-design/intact 3.5.0-beta.0 → 3.5.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 (122) hide show
  1. package/components/affix/index.md +1 -0
  2. package/components/affix/index.ts +2 -0
  3. package/components/affix/useStyle.ts +38 -35
  4. package/components/datepicker/basepicker.ts +3 -3
  5. package/components/dialog/styles.ts +2 -2
  6. package/components/dropdown/useKeyboard.ts +3 -0
  7. package/components/layout/styles.ts +1 -0
  8. package/components/select/base.ts +2 -0
  9. package/components/select/base.vdt +0 -2
  10. package/components/select/demos/group.md +1 -1
  11. package/components/select/demos/virtual.md +47 -0
  12. package/components/select/group.vdt +3 -2
  13. package/components/select/index.md +1 -0
  14. package/components/select/menu.vdt +5 -4
  15. package/components/select/select.vdt +1 -1
  16. package/components/select/useFilterable.ts +2 -2
  17. package/components/select/useInput.ts +6 -1
  18. package/components/table/demos/fixHeader.md +25 -5
  19. package/components/table/demos/virtual.md +105 -0
  20. package/components/table/index.md +1 -0
  21. package/components/table/index.spec.ts +2 -1
  22. package/components/table/row.ts +2 -1
  23. package/components/table/styles.ts +4 -0
  24. package/components/table/table.ts +6 -4
  25. package/components/table/table.vdt +15 -11
  26. package/components/treeSelect/index.ts +1 -1
  27. package/components/virtualList/container.ts +36 -0
  28. package/components/virtualList/container.vdt +30 -0
  29. package/components/virtualList/demos/basic.md +67 -0
  30. package/components/virtualList/demos/combined.md +57 -0
  31. package/components/virtualList/demos/delete.md +70 -0
  32. package/components/virtualList/index.md +19 -0
  33. package/components/virtualList/index.spec.ts +263 -0
  34. package/components/virtualList/index.ts +5 -0
  35. package/components/virtualList/phantom.ts +18 -0
  36. package/components/virtualList/phantom.vdt +28 -0
  37. package/components/virtualList/rows.ts +13 -0
  38. package/components/virtualList/rows.vdt +20 -0
  39. package/components/virtualList/styles.ts +29 -0
  40. package/components/virtualList/useRows.ts +24 -0
  41. package/components/virtualList/useVirtualRows.ts +145 -0
  42. package/components/virtualList/virtual.ts +19 -0
  43. package/components/virtualList/virtual.vdt +17 -0
  44. package/components/virtualList/wrapper.ts +17 -0
  45. package/components/virtualList/wrapper.vdt +24 -0
  46. package/es/components/affix/index.d.ts +1 -0
  47. package/es/components/affix/index.js +2 -1
  48. package/es/components/affix/useStyle.js +50 -47
  49. package/es/components/datepicker/basepicker.js +3 -3
  50. package/es/components/dialog/styles.js +2 -2
  51. package/es/components/dropdown/useKeyboard.js +3 -0
  52. package/es/components/input/index.spec.js +4 -2
  53. package/es/components/layout/styles.js +1 -1
  54. package/es/components/select/base.d.ts +1 -0
  55. package/es/components/select/base.js +2 -1
  56. package/es/components/select/base.vdt.js +2 -4
  57. package/es/components/select/group.vdt.js +8 -3
  58. package/es/components/select/menu.vdt.js +12 -3
  59. package/es/components/select/select.vdt.js +2 -1
  60. package/es/components/select/useFilterable.js +7 -5
  61. package/es/components/select/useInput.js +6 -2
  62. package/es/components/table/index.spec.js +7 -6
  63. package/es/components/table/styles.js +1 -1
  64. package/es/components/table/table.d.ts +1 -0
  65. package/es/components/table/table.js +3 -2
  66. package/es/components/table/table.vdt.js +126 -114
  67. package/es/components/treeSelect/index.js +4 -3
  68. package/es/components/virtualList/container.d.ts +10 -0
  69. package/es/components/virtualList/container.js +26 -0
  70. package/es/components/virtualList/container.vdt.js +39 -0
  71. package/es/components/virtualList/index.d.ts +5 -0
  72. package/es/components/virtualList/index.js +5 -0
  73. package/es/components/virtualList/index.spec.d.ts +1 -0
  74. package/es/components/virtualList/index.spec.js +372 -0
  75. package/es/components/virtualList/phantom.d.ts +9 -0
  76. package/es/components/virtualList/phantom.js +24 -0
  77. package/es/components/virtualList/phantom.vdt.js +33 -0
  78. package/es/components/virtualList/rows.d.ts +8 -0
  79. package/es/components/virtualList/rows.js +20 -0
  80. package/es/components/virtualList/rows.vdt.js +32 -0
  81. package/es/components/virtualList/styles.d.ts +13 -0
  82. package/es/components/virtualList/styles.js +34 -0
  83. package/es/components/virtualList/useRows.d.ts +2 -0
  84. package/es/components/virtualList/useRows.js +19 -0
  85. package/es/components/virtualList/useVirtualRows.d.ts +20 -0
  86. package/es/components/virtualList/useVirtualRows.js +120 -0
  87. package/es/components/virtualList/virtual.d.ts +8 -0
  88. package/es/components/virtualList/virtual.js +15 -0
  89. package/es/components/virtualList/virtual.vdt.js +26 -0
  90. package/es/components/virtualList/wrapper.d.ts +9 -0
  91. package/es/components/virtualList/wrapper.js +24 -0
  92. package/es/components/virtualList/wrapper.vdt.js +34 -0
  93. package/es/index.d.ts +3 -2
  94. package/es/index.js +3 -2
  95. package/es/site/data/components/select/demos/virtual/index.d.ts +11 -0
  96. package/es/site/data/components/select/demos/virtual/index.js +32 -0
  97. package/es/site/data/components/select/demos/virtual/react.d.ts +11 -0
  98. package/es/site/data/components/select/demos/virtual/react.js +53 -0
  99. package/es/site/data/components/table/demos/fixHeader/index.d.ts +6 -0
  100. package/es/site/data/components/table/demos/fixHeader/index.js +14 -0
  101. package/es/site/data/components/table/demos/fixHeader/react.d.ts +6 -0
  102. package/es/site/data/components/table/demos/fixHeader/react.js +28 -11
  103. package/es/site/data/components/table/demos/virtual/index.d.ts +13 -0
  104. package/es/site/data/components/table/demos/virtual/index.js +76 -0
  105. package/es/site/data/components/table/demos/virtual/react.d.ts +14 -0
  106. package/es/site/data/components/table/demos/virtual/react.js +114 -0
  107. package/es/site/data/components/virtualList/demos/basic/index.d.ts +12 -0
  108. package/es/site/data/components/virtualList/demos/basic/index.js +42 -0
  109. package/es/site/data/components/virtualList/demos/basic/react.d.ts +12 -0
  110. package/es/site/data/components/virtualList/demos/basic/react.js +67 -0
  111. package/es/site/data/components/virtualList/demos/combined/index.d.ts +11 -0
  112. package/es/site/data/components/virtualList/demos/combined/index.js +32 -0
  113. package/es/site/data/components/virtualList/demos/combined/react.d.ts +11 -0
  114. package/es/site/data/components/virtualList/demos/combined/react.js +50 -0
  115. package/es/site/data/components/virtualList/demos/delete/index.d.ts +13 -0
  116. package/es/site/data/components/virtualList/demos/delete/index.js +51 -0
  117. package/es/site/data/components/virtualList/demos/delete/react.d.ts +13 -0
  118. package/es/site/data/components/virtualList/demos/delete/react.js +75 -0
  119. package/es/site/data/components/virtualList/index.d.ts +57 -0
  120. package/es/site/data/components/virtualList/index.js +32 -0
  121. package/index.ts +3 -2
  122. package/package.json +1 -1
@@ -0,0 +1,120 @@
1
+ import _Map from "@babel/runtime-corejs3/core-js/map";
2
+ import _Set from "@babel/runtime-corejs3/core-js/set";
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
4
+ import { createContext } from '../context';
5
+ import { useState, watchState } from '../../hooks/useState';
6
+ import { useInstance, nextTick, onMounted, onUnmounted, findDomFromVNode } from 'intact';
7
+ import { isNullOrUndefined } from 'intact-shared';
8
+ export var context = createContext();
9
+ var MIN_LENGTH = 10;
10
+ var BUFFER_SIZE = 3;
11
+ export function useVirtualRows() {
12
+ var instance = useInstance();
13
+ var rowsHeightMap = new _Map();
14
+ var startIndex = useState(0);
15
+ var length = useState(MIN_LENGTH);
16
+ var calculatedHeight = 0;
17
+ var rowAvgHeight = 0;
18
+ var rows = [];
19
+ function notifyRows(_rows) {
20
+ var oldRows = rows;
21
+ var oldLength = rows.length;
22
+ rows = _rows;
23
+ // diff oldRows, newRows
24
+ var newKeys = new _Set(_mapInstanceProperty(_rows).call(_rows, function (row) {
25
+ return row.key;
26
+ }));
27
+ for (var i = 0; i < oldLength; i++) {
28
+ var oldKey = oldRows[i].key;
29
+ if (!newKeys.has(oldKey)) {
30
+ var height = rowsHeightMap.get(oldKey);
31
+ if (!isNullOrUndefined(height)) {
32
+ calculatedHeight -= height;
33
+ rowsHeightMap.delete(oldKey);
34
+ }
35
+ }
36
+ }
37
+ // update rowAvgHeight
38
+ if (rowsHeightMap.size === 0) {
39
+ rowAvgHeight = calculatedHeight = 0;
40
+ } else {
41
+ rowAvgHeight = calculatedHeight / rowsHeightMap.size;
42
+ }
43
+ if (_rows.length < oldLength) {
44
+ var maxStartIndex = Math.max(0, _rows.length - length.value);
45
+ if (startIndex.value > maxStartIndex) {
46
+ startIndex.set(maxStartIndex);
47
+ // 重新计算位置
48
+ nextTick(function () {
49
+ handleScroll();
50
+ });
51
+ }
52
+ }
53
+ }
54
+ function calculateRowsHeight() {
55
+ for (var i = startIndex.value; i < startIndex.value + length.value && i < rows.length; i++) {
56
+ var row = rows[i];
57
+ var key = row.key;
58
+ if (!rowsHeightMap.has(key)) {
59
+ var rowDom = findDomFromVNode(row, true);
60
+ var height = rowDom.offsetHeight;
61
+ rowsHeightMap.set(key, height);
62
+ calculatedHeight += height;
63
+ }
64
+ }
65
+ // use the average height to estimate the row height
66
+ rowAvgHeight = calculatedHeight / rowsHeightMap.size;
67
+ }
68
+ watchState(startIndex, function () {
69
+ nextTick(calculateRowsHeight);
70
+ });
71
+ var containerDom;
72
+ onMounted(function () {
73
+ // get contains height
74
+ containerDom = findDomFromVNode(instance.$lastInput, true);
75
+ var containerHeight = containerDom.offsetHeight;
76
+ calculateRowsHeight();
77
+ // calculate the length of rows we should render
78
+ length.set(Math.max(Math.ceil(containerHeight / rowAvgHeight) + BUFFER_SIZE * 2, MIN_LENGTH));
79
+ containerDom.addEventListener('scroll', handleScroll);
80
+ });
81
+ onUnmounted(function () {
82
+ containerDom.removeEventListener('scroll', handleScroll);
83
+ });
84
+ function getTotalHeight() {
85
+ return calculatedHeight + rowAvgHeight * (rows.length - rowsHeightMap.size);
86
+ }
87
+ var translateY = useState(0);
88
+ function handleScroll() {
89
+ var _instance$get = instance.get(),
90
+ disabled = _instance$get.disabled;
91
+ if (disabled) return;
92
+ var scrollTop = containerDom.scrollTop;
93
+ var accumulatedHeight = 0;
94
+ var start = 0;
95
+ while (start < rows.length) {
96
+ accumulatedHeight += getRowHeightByIndex(start);
97
+ if (accumulatedHeight > scrollTop) {
98
+ break;
99
+ }
100
+ start++;
101
+ }
102
+ startIndex.set(Math.max(start - BUFFER_SIZE, 0));
103
+ // translateY should substract the buffer size rows height
104
+ for (var i = start; i >= startIndex.value; i--) {
105
+ accumulatedHeight -= getRowHeightByIndex(i);
106
+ }
107
+ translateY.set(accumulatedHeight);
108
+ }
109
+ function getRowHeightByIndex(index) {
110
+ var key = rows[index].key;
111
+ return rowsHeightMap.get(key) || rowAvgHeight;
112
+ }
113
+ return {
114
+ notifyRows: notifyRows,
115
+ startIndex: startIndex,
116
+ length: length,
117
+ getTotalHeight: getTotalHeight,
118
+ translateY: translateY
119
+ };
120
+ }
@@ -0,0 +1,8 @@
1
+ import { Component, TypeDefs } from 'intact';
2
+ export interface VirtualListProps {
3
+ disabled?: boolean;
4
+ }
5
+ export declare class VirtualList extends Component<VirtualListProps> {
6
+ static template: string | import("intact").Template<any>;
7
+ static typeDefs: Required<TypeDefs<VirtualListProps>>;
8
+ }
@@ -0,0 +1,15 @@
1
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ import { Component } from 'intact';
3
+ import template from './virtual.vdt';
4
+ var typeDefs = {
5
+ disabled: Boolean
6
+ };
7
+ export var VirtualList = /*#__PURE__*/function (_Component) {
8
+ _inheritsLoose(VirtualList, _Component);
9
+ function VirtualList() {
10
+ return _Component.apply(this, arguments) || this;
11
+ }
12
+ return VirtualList;
13
+ }(Component);
14
+ VirtualList.template = template;
15
+ VirtualList.typeDefs = typeDefs;
@@ -0,0 +1,26 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import { createUnknownComponentVNode as _$cc } from 'intact';
3
+ import { getRestProps } from '../utils';
4
+ import { VirtualListContainer } from './container';
5
+ import { VirtualListWrapper } from './wrapper';
6
+ import { VirtualListRows } from './rows';
7
+ import { VirtualListPhantom } from './phantom';
8
+ export default function ($props, $blocks, $__proto__) {
9
+ $blocks || ($blocks = {});
10
+ $props || ($props = {});
11
+ var $this = this;
12
+ var _this$get = this.get(),
13
+ children = _this$get.children,
14
+ disabled = _this$get.disabled;
15
+ if (disabled) {
16
+ return children;
17
+ }
18
+ return _$cc(VirtualListContainer, _extends({}, getRestProps(this), {
19
+ 'children': [_$cc(VirtualListPhantom), _$cc(VirtualListWrapper, {
20
+ 'children': _$cc(VirtualListRows, {
21
+ 'children': children
22
+ })
23
+ })]
24
+ }));
25
+ }
26
+ ;
@@ -0,0 +1,9 @@
1
+ import { Component, TypeDefs, ComponentConstructor } from 'intact';
2
+ export interface VirtualListWrapperProps {
3
+ tagName?: string | ComponentConstructor;
4
+ }
5
+ export declare class VirtualListWrapper extends Component<VirtualListWrapperProps> {
6
+ static template: string | import("intact").Template<any>;
7
+ static typeDefs: Required<TypeDefs<VirtualListWrapperProps>>;
8
+ private config;
9
+ }
@@ -0,0 +1,24 @@
1
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
+ import { Component } from 'intact';
4
+ import template from './wrapper.vdt';
5
+ import { useConfigContext } from '../config';
6
+ var typeDefs = {
7
+ tagName: String
8
+ };
9
+ export var VirtualListWrapper = /*#__PURE__*/function (_Component) {
10
+ _inheritsLoose(VirtualListWrapper, _Component);
11
+ function VirtualListWrapper() {
12
+ var _context;
13
+ var _this;
14
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15
+ args[_key] = arguments[_key];
16
+ }
17
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
18
+ _this.config = useConfigContext();
19
+ return _this;
20
+ }
21
+ return VirtualListWrapper;
22
+ }(Component);
23
+ VirtualListWrapper.template = template;
24
+ VirtualListWrapper.typeDefs = typeDefs;
@@ -0,0 +1,34 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import { createUnknownComponentVNode as _$cc } from 'intact';
3
+ import { addStyle, getRestProps } from '../utils';
4
+ import { context as VirtualRowsContext } from './useVirtualRows';
5
+ import { createVNode } from 'intact';
6
+ import { cx } from '@emotion/css';
7
+ export default function ($props, $blocks, $__proto__) {
8
+ var _this = this;
9
+ $blocks || ($blocks = {});
10
+ $props || ($props = {});
11
+ var $this = this;
12
+ var _this$get = this.get(),
13
+ _children = _this$get.children,
14
+ className = _this$get.className,
15
+ tagName = _this$get.tagName,
16
+ style = _this$get.style;
17
+ var k = this.config.k;
18
+ return _$cc(VirtualRowsContext.Consumer, {
19
+ 'children': function children(_ref) {
20
+ var _classNameObj;
21
+ var translateY = _ref.translateY,
22
+ disabled = _ref.disabled;
23
+ var classNameObj = (_classNameObj = {}, _classNameObj[k + "-virtual-wrapper"] = !disabled, _classNameObj[className] = className, _classNameObj);
24
+ var _style = !disabled ? {
25
+ transform: "translateY(" + translateY + "px)"
26
+ } : {};
27
+ return createVNode(tagName || 'div', _extends({}, getRestProps(_this), {
28
+ className: cx(classNameObj),
29
+ style: addStyle(style, _style)
30
+ }), _children);
31
+ }
32
+ });
33
+ }
34
+ ;
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.5.0-beta.0
2
+ * @king-design v3.5.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -63,5 +63,6 @@ export * from './components/tree';
63
63
  export * from './components/treeSelect';
64
64
  export * from './components/upload';
65
65
  export * from './components/view';
66
+ export * from './components/virtualList';
66
67
  export * from './components/wave';
67
- export declare const version = "3.5.0-beta.0";
68
+ export declare const version = "3.5.0";
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.5.0-beta.0
2
+ * @king-design v3.5.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -64,6 +64,7 @@ export * from './components/tree';
64
64
  export * from './components/treeSelect';
65
65
  export * from './components/upload';
66
66
  export * from './components/view';
67
+ export * from './components/virtualList';
67
68
  export * from './components/wave';
68
- export var version = '3.5.0-beta.0';
69
+ export var version = '3.5.0';
69
70
  /* generate end */
@@ -0,0 +1,11 @@
1
+ export { default as data } from './index.json';
2
+ import { Component } from 'intact';
3
+ interface Props {
4
+ day?: string | null;
5
+ data: any[];
6
+ }
7
+ export default class extends Component {
8
+ static template: string | import("intact").Template<any>;
9
+ static defaults(): Props;
10
+ init(): void;
11
+ }
@@ -0,0 +1,32 @@
1
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ export { default as data } from './index.json';
3
+ import { Component } from 'intact';
4
+ import template from './index.vdt';
5
+ var default_1 = /*#__PURE__*/function (_Component) {
6
+ _inheritsLoose(default_1, _Component);
7
+ function default_1() {
8
+ return _Component.apply(this, arguments) || this;
9
+ }
10
+ default_1.defaults = function defaults() {
11
+ return {
12
+ day: null,
13
+ data: []
14
+ };
15
+ };
16
+ var _proto = default_1.prototype;
17
+ _proto.init = function init() {
18
+ var arr = [];
19
+ for (var index = 0; index < 10000; index++) {
20
+ arr.push({
21
+ value: index,
22
+ label: "\u6D4B\u8BD5" + index
23
+ });
24
+ }
25
+ this.set({
26
+ data: arr
27
+ });
28
+ };
29
+ return default_1;
30
+ }(Component);
31
+ default_1.template = template;
32
+ export { default_1 as default };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ day?: string | null;
4
+ data: any[];
5
+ }
6
+ export default class Demo extends React.Component<{}, Props> {
7
+ state: Props;
8
+ componentDidMount(): void;
9
+ render(): React.JSX.Element;
10
+ }
11
+ export {};
@@ -0,0 +1,53 @@
1
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
4
+ import React from 'react';
5
+ import { Select, Option } from '@king-design/react';
6
+ var Demo = /*#__PURE__*/function (_React$Component) {
7
+ _inheritsLoose(Demo, _React$Component);
8
+ function Demo() {
9
+ var _context;
10
+ var _this;
11
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12
+ args[_key] = arguments[_key];
13
+ }
14
+ _this = _React$Component.call.apply(_React$Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
15
+ _this.state = {
16
+ day: null,
17
+ data: []
18
+ };
19
+ return _this;
20
+ }
21
+ var _proto = Demo.prototype;
22
+ _proto.componentDidMount = function componentDidMount() {
23
+ var arr = [];
24
+ for (var index = 0; index < 10000; index++) {
25
+ arr.push({
26
+ value: index,
27
+ label: "\u6D4B\u8BD5" + index
28
+ });
29
+ }
30
+ this.setState({
31
+ data: arr
32
+ });
33
+ };
34
+ _proto.render = function render() {
35
+ var _this2 = this,
36
+ _context2;
37
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, {
38
+ value: this.state.day,
39
+ onChangeValue: function onChangeValue(day) {
40
+ return _this2.setState({
41
+ day: day
42
+ });
43
+ },
44
+ virtual: true
45
+ }, _mapInstanceProperty(_context2 = this.state.data).call(_context2, function ($value, $key) {
46
+ return /*#__PURE__*/React.createElement(Option, {
47
+ value: $value.value
48
+ }, $value.label);
49
+ })));
50
+ };
51
+ return Demo;
52
+ }(React.Component);
53
+ export { Demo as default };
@@ -3,4 +3,10 @@ import { Component } from 'intact';
3
3
  import './index.styl';
4
4
  export default class extends Component {
5
5
  static template: string | import("intact").Template<any>;
6
+ static defaults(): {
7
+ data: {
8
+ name: string;
9
+ ip: string;
10
+ }[];
11
+ };
6
12
  }
@@ -1,13 +1,27 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ var _context;
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
2
4
  export { default as data } from './index.json';
3
5
  import { Component } from 'intact';
4
6
  import template from './index.vdt';
5
7
  import './index.styl';
8
+ import { range } from 'kpc/components/utils';
9
+ var data = _mapInstanceProperty(_context = range(1, 100)).call(_context, function (item) {
10
+ return {
11
+ name: 'name ' + item,
12
+ ip: '127.0.0.' + item
13
+ };
14
+ });
6
15
  var default_1 = /*#__PURE__*/function (_Component) {
7
16
  _inheritsLoose(default_1, _Component);
8
17
  function default_1() {
9
18
  return _Component.apply(this, arguments) || this;
10
19
  }
20
+ default_1.defaults = function defaults() {
21
+ return {
22
+ data: data
23
+ };
24
+ };
11
25
  return default_1;
12
26
  }(Component);
13
27
  default_1.template = template;
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
2
  import './index.styl';
3
3
  export default class Demo extends React.Component {
4
+ state: {
5
+ data: {
6
+ name: string;
7
+ ip: string;
8
+ }[];
9
+ };
4
10
  render(): React.JSX.Element;
5
11
  }
@@ -1,11 +1,30 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ var _context;
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
4
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
2
5
  import React from 'react';
3
6
  import { Table, TableColumn } from '@king-design/react';
4
7
  import './index.styl';
8
+ import { range } from '@king-design/react/components/utils';
9
+ var data = _mapInstanceProperty(_context = range(1, 100)).call(_context, function (item) {
10
+ return {
11
+ name: 'name ' + item,
12
+ ip: '127.0.0.' + item
13
+ };
14
+ });
5
15
  var Demo = /*#__PURE__*/function (_React$Component) {
6
16
  _inheritsLoose(Demo, _React$Component);
7
17
  function Demo() {
8
- return _React$Component.apply(this, arguments) || this;
18
+ var _context2;
19
+ var _this;
20
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21
+ args[_key] = arguments[_key];
22
+ }
23
+ _this = _React$Component.call.apply(_React$Component, _concatInstanceProperty(_context2 = [this]).call(_context2, args)) || this;
24
+ _this.state = {
25
+ data: data
26
+ };
27
+ return _this;
9
28
  }
10
29
  var _proto = Demo.prototype;
11
30
  _proto.render = function render() {
@@ -20,17 +39,15 @@ var Demo = /*#__PURE__*/function (_React$Component) {
20
39
  key: "a",
21
40
  title: "100px"
22
41
  })), /*#__PURE__*/React.createElement(Table, {
23
- data: [{
24
- a: '表头固定啦'
25
- }, {
26
- a: '下拉'
27
- }, {
28
- a: 'yeah!'
29
- }],
30
- fixHeader: "100"
42
+ data: this.state.data,
43
+ fixHeader: "300"
31
44
  }, /*#__PURE__*/React.createElement(TableColumn, {
32
- key: "a",
33
- title: "100px"
45
+ title: "Name",
46
+ key: "name",
47
+ fixed: "left"
48
+ }), /*#__PURE__*/React.createElement(TableColumn, {
49
+ title: "IP",
50
+ key: "ip"
34
51
  })));
35
52
  };
36
53
  return Demo;
@@ -0,0 +1,13 @@
1
+ export { default as data } from './index.json';
2
+ import { Component } from 'intact';
3
+ import './index.styl';
4
+ interface Props {
5
+ data: any[];
6
+ variableHeightData: any[];
7
+ }
8
+ export default class extends Component {
9
+ static template: string | import("intact").Template<any>;
10
+ static defaults(): Props;
11
+ init(): void;
12
+ scrollToRowByKey(): void;
13
+ }
@@ -0,0 +1,76 @@
1
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
3
+ import { __decorate } from "tslib";
4
+ export { default as data } from './index.json';
5
+ import { Component } from 'intact';
6
+ import template from './index.vdt';
7
+ import './index.styl';
8
+ import { bind } from 'kpc/components/utils';
9
+ var default_1 = /*#__PURE__*/function (_Component) {
10
+ _inheritsLoose(default_1, _Component);
11
+ function default_1() {
12
+ return _Component.apply(this, arguments) || this;
13
+ }
14
+ default_1.defaults = function defaults() {
15
+ return {
16
+ data: [],
17
+ variableHeightData: []
18
+ };
19
+ };
20
+ var _proto = default_1.prototype;
21
+ _proto.init = function init() {
22
+ var arr = [];
23
+ for (var index = 0; index < 10000; index++) {
24
+ arr.push({
25
+ a: "Cell " + index + "-1",
26
+ b: "Cell " + index + "-2"
27
+ });
28
+ }
29
+ this.set({
30
+ data: arr
31
+ });
32
+ var generateTreeData = function generateTreeData(count) {
33
+ var result = [];
34
+ var _loop = function _loop(i) {
35
+ var hasChildren = Math.random() > 0.5;
36
+ var node = {
37
+ name: "Node-" + i,
38
+ key: "node-" + i,
39
+ size: Math.floor(Math.random() * 100)
40
+ };
41
+ if (hasChildren) {
42
+ node.children = _Array$from({
43
+ length: 2
44
+ }, function (_, j) {
45
+ return {
46
+ name: "Node-" + i + "-" + j,
47
+ key: "node-" + i + "-" + j,
48
+ size: Math.floor(Math.random() * 100),
49
+ children: Math.random() > 0.5 ? [{
50
+ name: "Node-" + i + "-" + j + "-0",
51
+ key: "node-" + i + "-" + j + "-0",
52
+ size: Math.floor(Math.random() * 100)
53
+ }] : undefined
54
+ };
55
+ });
56
+ }
57
+ result.push(node);
58
+ };
59
+ for (var i = 0; i < count; i++) {
60
+ _loop(i);
61
+ }
62
+ return result;
63
+ };
64
+ var data = generateTreeData(10000);
65
+ this.set({
66
+ variableHeightData: data
67
+ });
68
+ };
69
+ _proto.scrollToRowByKey = function scrollToRowByKey() {
70
+ this.refs.table.scrollToRowByKey('Node-400');
71
+ };
72
+ return default_1;
73
+ }(Component);
74
+ default_1.template = template;
75
+ export { default_1 as default };
76
+ __decorate([bind], default_1.prototype, "scrollToRowByKey", null);
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import './index.styl';
3
+ interface Props {
4
+ data: any[];
5
+ variableHeightData: any[];
6
+ }
7
+ export default class Demo extends React.Component<{}, Props> {
8
+ state: Props;
9
+ private table;
10
+ componentDidMount(): void;
11
+ scrollToRowByKey(): void;
12
+ render(): React.JSX.Element;
13
+ }
14
+ export {};