@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,28 @@
1
+ import { getRestProps } from '../utils';
2
+ import { context as VirtualRowsContext } from './useVirtualRows';
3
+ import { cx } from '@emotion/css';
4
+ import { createVNode } from 'intact';
5
+ import { makePhantomStyles } from './styles';
6
+
7
+ const { className, tagName } = this.get();
8
+ const { k } = this.config;
9
+
10
+ const classNameObj = {
11
+ [`${k}-virtual-phantom`]: true,
12
+ [makePhantomStyles()]: true,
13
+ [className]: className,
14
+ }
15
+
16
+ <VirtualRowsContext.Consumer>
17
+ {({ getTotalHeight, disabled }) => {
18
+ if (disabled) return;
19
+
20
+ return createVNode(tagName || 'div', {
21
+ ...getRestProps(this),
22
+ className: cx(classNameObj),
23
+ style: {
24
+ height: getTotalHeight() + 'px',
25
+ },
26
+ });
27
+ }}
28
+ </VirtualRowsContext.Consumer>
@@ -0,0 +1,13 @@
1
+ import { Component } from 'intact';
2
+ import { useRows } from './useRows';
3
+ import template from './rows.vdt';
4
+
5
+ export interface VirtualListRowsProps {
6
+ tagName?: string
7
+ }
8
+
9
+ export class VirtualListRows extends Component<VirtualListRowsProps> {
10
+ static template = template;
11
+
12
+ private rows = useRows();
13
+ }
@@ -0,0 +1,20 @@
1
+ import { createFragment, createVNode } from 'intact';
2
+ import { isNullOrUndefined } from 'intact-shared';
3
+ import { context as VirtualRowsContext } from './useVirtualRows';
4
+
5
+ let { tagName, children } = this.get();
6
+ const rows = this.rows;
7
+
8
+ <VirtualRowsContext.Consumer>
9
+ {({ notifyRows, startIndex, length, disabled }) => {
10
+ if (!disabled) {
11
+ children = rows.value.slice(startIndex, startIndex + length);
12
+ notifyRows(rows.value);
13
+ }
14
+
15
+ if (isNullOrUndefined(tagName)) {
16
+ return createFragment(children, 8 /* ChildrenTypes.HasKeyedChildren */);
17
+ }
18
+ return createVNode(tagName, null, children);
19
+ }}
20
+ </VirtualRowsContext.Consumer>
@@ -0,0 +1,29 @@
1
+ import {css} from '@emotion/css';
2
+ import '../../styles/global';
3
+ import { cache } from '../utils';
4
+
5
+ export const makeContainerStyles = cache(() => {
6
+ return css`
7
+ overflow: auto;
8
+ position: relative;
9
+ height: 100%;
10
+ `;
11
+ });
12
+
13
+ export const makePhantomStyles = cache(() => {
14
+ return css`
15
+ position: absolute;
16
+ left: 0;
17
+ top: 0;
18
+ right: 0;
19
+ z-index: -1;
20
+ pointer-events: none;
21
+ `;
22
+ });
23
+
24
+ export const makeWrapperStyles = cache(() => {
25
+ return css`
26
+ width: 100%;
27
+ will-change: transform;
28
+ `;
29
+ });
@@ -0,0 +1,24 @@
1
+ import { useInstance, VNode, createRef, createFragment } from 'intact';
2
+ import { VirtualListRows } from './rows';
3
+
4
+ export function useRows() {
5
+ const instance = useInstance() as VirtualListRows;
6
+ const rows = createRef<VNode[]>([]);
7
+
8
+ instance.on('$receive:children', (children) => {
9
+ // use fragment vnode to normalize children
10
+ const vNode = createFragment(children, 0 /* ChildrenTypes.UnknownChildren */);
11
+
12
+ // convert to array if it has only one child
13
+ const childrenType = vNode.childrenType;
14
+ if (childrenType & 2 /* ChildrenTypes.HasVNodeChildren */) {
15
+ rows.value = [vNode.children as unknown as VNode];
16
+ } else if (childrenType & 1 /* ChildrenTypes.HasInvalidChildren */) {
17
+ rows.value = [];
18
+ } else {
19
+ rows.value = vNode.children as VNode[];
20
+ }
21
+ });
22
+
23
+ return rows;
24
+ }
@@ -0,0 +1,145 @@
1
+ import { createContext } from '../context';
2
+ import { useState, watchState, State } from '../../hooks/useState';
3
+ import { useInstance, nextTick, VNode, onMounted, onUnmounted, Key, findDomFromVNode } from 'intact';
4
+ import { VirtualListContainer } from './container';
5
+ import { isNullOrUndefined } from 'intact-shared';
6
+
7
+ type ContextValue = {
8
+ notifyRows: (rows: State<VNode[]>) => void;
9
+ startIndex: number;
10
+ endIndex: number;
11
+ }
12
+
13
+ export const context = createContext<ContextValue>();
14
+
15
+ const MIN_LENGTH = 10;
16
+ const BUFFER_SIZE = 3;
17
+
18
+ export function useVirtualRows() {
19
+ const instance = useInstance() as unknown as VirtualListContainer;
20
+ const rowsHeightMap = new Map<Key, number>();
21
+ const startIndex = useState(0);
22
+ const length = useState(MIN_LENGTH);
23
+
24
+ let calculatedHeight = 0;
25
+ let rowAvgHeight = 0;
26
+ let rows: VNode[] = [];
27
+ function notifyRows(_rows: VNode[]) {
28
+ const oldRows = rows;
29
+ const oldLength = rows.length;
30
+ rows = _rows;
31
+ // diff oldRows, newRows
32
+ const newKeys = new Set(_rows.map(row => row.key));
33
+
34
+ for (let i = 0; i < oldLength; i++) {
35
+ const oldKey = oldRows[i].key!;
36
+ if (!newKeys.has(oldKey)) {
37
+ const height = rowsHeightMap.get(oldKey);
38
+ if (!isNullOrUndefined(height)) {
39
+ calculatedHeight -= height;
40
+ rowsHeightMap.delete(oldKey);
41
+ }
42
+ }
43
+ }
44
+
45
+ // update rowAvgHeight
46
+ if (rowsHeightMap.size === 0) {
47
+ rowAvgHeight = calculatedHeight = 0;
48
+ } else {
49
+ rowAvgHeight = calculatedHeight / rowsHeightMap.size;
50
+ }
51
+
52
+ if (_rows.length < oldLength) {
53
+ const maxStartIndex = Math.max(0, _rows.length - length.value);
54
+ if (startIndex.value > maxStartIndex) {
55
+ startIndex.set(maxStartIndex);
56
+ // 重新计算位置
57
+ nextTick(() => {
58
+ handleScroll();
59
+ });
60
+ }
61
+ }
62
+ }
63
+
64
+ function calculateRowsHeight() {
65
+ for (
66
+ let i = startIndex.value;
67
+ i < startIndex.value + length.value && i < rows.length;
68
+ i++
69
+ ) {
70
+ const row = rows[i];
71
+ const key = row.key!;
72
+ if (!rowsHeightMap.has(key)) {
73
+ const rowDom = findDomFromVNode(row, true) as HTMLElement;
74
+ const height = rowDom.offsetHeight;
75
+ rowsHeightMap.set(key, height);
76
+ calculatedHeight += height;
77
+ }
78
+ }
79
+
80
+ // use the average height to estimate the row height
81
+ rowAvgHeight = calculatedHeight / rowsHeightMap.size;
82
+ }
83
+
84
+ watchState(startIndex, () => {
85
+ nextTick(calculateRowsHeight);
86
+ });
87
+
88
+ let containerDom: HTMLElement;
89
+ onMounted(() => {
90
+ // get contains height
91
+ containerDom = findDomFromVNode(instance.$lastInput!, true) as HTMLElement;
92
+ const containerHeight = containerDom.offsetHeight;
93
+
94
+ calculateRowsHeight();
95
+
96
+ // calculate the length of rows we should render
97
+ length.set(Math.max(Math.ceil(containerHeight / rowAvgHeight) + BUFFER_SIZE * 2, MIN_LENGTH));
98
+
99
+ containerDom.addEventListener('scroll', handleScroll);
100
+ });
101
+
102
+ onUnmounted(() => {
103
+ containerDom.removeEventListener('scroll', handleScroll);
104
+ });
105
+
106
+ function getTotalHeight() {
107
+ return calculatedHeight + rowAvgHeight * (rows.length - rowsHeightMap.size);
108
+ }
109
+
110
+ const translateY = useState(0);
111
+ function handleScroll() {
112
+ const { disabled } = instance.get();
113
+ if (disabled) return;
114
+
115
+ const scrollTop = containerDom.scrollTop;
116
+
117
+ let accumulatedHeight = 0;
118
+ let start = 0;
119
+
120
+ while (start < rows.length) {
121
+ accumulatedHeight += getRowHeightByIndex(start);
122
+ if (accumulatedHeight > scrollTop) {
123
+ break;
124
+ }
125
+
126
+ start++;
127
+ }
128
+
129
+ startIndex.set(Math.max(start - BUFFER_SIZE, 0));
130
+
131
+ // translateY should substract the buffer size rows height
132
+ for (let i = start; i >= startIndex.value; i--) {
133
+ accumulatedHeight -= getRowHeightByIndex(i);
134
+ }
135
+
136
+ translateY.set(accumulatedHeight);
137
+ }
138
+
139
+ function getRowHeightByIndex(index: number) {
140
+ const key = rows[index].key!;
141
+ return rowsHeightMap.get(key) || rowAvgHeight;
142
+ }
143
+
144
+ return { notifyRows, startIndex, length, getTotalHeight, translateY };
145
+ }
@@ -0,0 +1,19 @@
1
+ import { Component, TypeDefs, createRef } from 'intact';
2
+ import template from './virtual.vdt';
3
+
4
+ export interface VirtualListProps {
5
+ disabled?: boolean
6
+ }
7
+
8
+ const typeDefs: Required<TypeDefs<VirtualListProps>> = {
9
+ disabled: Boolean,
10
+ };
11
+
12
+ export class VirtualList extends Component<VirtualListProps> {
13
+ static template = template;
14
+ static typeDefs = typeDefs;
15
+
16
+ // public scrollToIndex(index: number, behavior: ScrollBehavior = 'auto') {
17
+ // this.containerRef.value?.scrollToIndex(index, behavior);
18
+ // }
19
+ }
@@ -0,0 +1,17 @@
1
+ import { getRestProps } from '../utils';
2
+ import { VirtualListContainer } from './container';
3
+ import { VirtualListWrapper } from './wrapper';
4
+ import { VirtualListRows } from './rows';
5
+ import { VirtualListPhantom } from './phantom';
6
+
7
+ const { children, disabled } = this.get();
8
+
9
+ if (disabled) {
10
+ return children;
11
+ }
12
+ <VirtualListContainer {...getRestProps(this)}>
13
+ <VirtualListPhantom />
14
+ <VirtualListWrapper>
15
+ <VirtualListRows>{children}</VirtualListRows>
16
+ </VirtualListWrapper>
17
+ </VirtualListContainer>
@@ -0,0 +1,17 @@
1
+ import { Component, TypeDefs, ComponentConstructor } from 'intact';
2
+ import template from './wrapper.vdt';
3
+ import { useConfigContext } from '../config';
4
+ export interface VirtualListWrapperProps {
5
+ tagName?: string | ComponentConstructor,
6
+ }
7
+
8
+ const typeDefs: Required<TypeDefs<VirtualListWrapperProps>> = {
9
+ tagName: String,
10
+ };
11
+
12
+ export class VirtualListWrapper extends Component<VirtualListWrapperProps> {
13
+ static template = template;
14
+ static typeDefs = typeDefs;
15
+
16
+ private config = useConfigContext();
17
+ }
@@ -0,0 +1,24 @@
1
+ import { addStyle, getRestProps } from '../utils';
2
+ import { context as VirtualRowsContext } from './useVirtualRows';
3
+ import { createVNode } from 'intact';
4
+ import { cx } from '@emotion/css';
5
+
6
+ const { children, className, tagName, style } = this.get();
7
+ const { k } = this.config;
8
+
9
+ <VirtualRowsContext.Consumer>
10
+ {({ translateY, disabled }) => {
11
+ const classNameObj = {
12
+ [`${k}-virtual-wrapper`]: !disabled,
13
+ [className]: className,
14
+ }
15
+
16
+ const _style = !disabled ? { transform: `translateY(${translateY}px)` } : {};
17
+
18
+ return createVNode(tagName || 'div', {
19
+ ...getRestProps(this),
20
+ className: cx(classNameObj),
21
+ style: addStyle(style, _style)
22
+ }, children);
23
+ }}
24
+ </VirtualRowsContext.Consumer>
@@ -4,6 +4,7 @@ export interface AffixProps {
4
4
  bottom?: number;
5
5
  exclude?: (data: ExcludeParam) => boolean;
6
6
  shouldFix?: (data: ShouldFixParam) => boolean;
7
+ disabled?: boolean;
7
8
  }
8
9
  export interface AffixEvents {
9
10
  change: [boolean];
@@ -8,7 +8,8 @@ var typeDefs = {
8
8
  top: Number,
9
9
  bottom: Number,
10
10
  exclude: Function,
11
- shouldFix: Function
11
+ shouldFix: Function,
12
+ disabled: Boolean
12
13
  };
13
14
  export var Affix = /*#__PURE__*/function (_Component) {
14
15
  _inheritsLoose(Affix, _Component);
@@ -14,54 +14,57 @@ export function useStyle(elementRef) {
14
14
  offsetTop = _instance$get.top,
15
15
  offsetBottom = _instance$get.bottom,
16
16
  exclude = _instance$get.exclude,
17
- shouldFix = _instance$get.shouldFix;
18
- var _elementRef$value$get = elementRef.value.getBoundingClientRect(),
19
- top = _elementRef$value$get.top,
20
- bottom = _elementRef$value$get.bottom,
21
- width = _elementRef$value$get.width,
22
- height = _elementRef$value$get.height;
23
- var setStyle = function setStyle(styles) {
24
- if (!exclude || exclude && !exclude({
25
- offsetTop: offsetTop,
26
- offsetBottom: offsetBottom,
27
- top: top,
28
- bottom: bottom,
29
- width: width,
30
- height: height
31
- })) {
32
- style.set(_extends({
33
- position: 'fixed',
34
- width: width + "px"
35
- }, styles));
36
- containerStyle.set({
37
- height: height + "px"
38
- });
39
- } else {
40
- resetStyle();
41
- }
42
- };
43
- if (isNullOrUndefined(offsetTop) && isNullOrUndefined(offsetBottom)) {
44
- offsetTop = 0;
45
- }
46
- if (!isNullOrUndefined(offsetTop)) {
47
- if (shouldFix && shouldFix({
48
- offsetTop: offsetTop,
49
- offsetBottom: offsetBottom
50
- }) || !shouldFix && top < offsetTop) {
51
- return setStyle({
52
- top: offsetTop + "px"
53
- });
17
+ shouldFix = _instance$get.shouldFix,
18
+ disabled = _instance$get.disabled;
19
+ if (!disabled) {
20
+ var _elementRef$value$get = elementRef.value.getBoundingClientRect(),
21
+ top = _elementRef$value$get.top,
22
+ bottom = _elementRef$value$get.bottom,
23
+ width = _elementRef$value$get.width,
24
+ height = _elementRef$value$get.height;
25
+ var setStyle = function setStyle(styles) {
26
+ if (!exclude || exclude && !exclude({
27
+ offsetTop: offsetTop,
28
+ offsetBottom: offsetBottom,
29
+ top: top,
30
+ bottom: bottom,
31
+ width: width,
32
+ height: height
33
+ })) {
34
+ style.set(_extends({
35
+ position: 'fixed',
36
+ width: width + "px"
37
+ }, styles));
38
+ containerStyle.set({
39
+ height: height + "px"
40
+ });
41
+ } else {
42
+ resetStyle();
43
+ }
44
+ };
45
+ if (isNullOrUndefined(offsetTop) && isNullOrUndefined(offsetBottom)) {
46
+ offsetTop = 0;
54
47
  }
55
- } else {
56
- var viewportHeight = document.documentElement.clientHeight;
57
- if (shouldFix && shouldFix({
58
- offsetTop: offsetTop,
59
- offsetBottom: offsetBottom,
60
- viewportHeight: viewportHeight
61
- }) || !shouldFix && !isNullOrUndefined(offsetBottom) && viewportHeight - bottom <= offsetBottom) {
62
- return setStyle({
63
- bottom: offsetBottom + "px"
64
- });
48
+ if (!isNullOrUndefined(offsetTop)) {
49
+ if (shouldFix && shouldFix({
50
+ offsetTop: offsetTop,
51
+ offsetBottom: offsetBottom
52
+ }) || !shouldFix && top < offsetTop) {
53
+ return setStyle({
54
+ top: offsetTop + "px"
55
+ });
56
+ }
57
+ } else {
58
+ var viewportHeight = document.documentElement.clientHeight;
59
+ if (shouldFix && shouldFix({
60
+ offsetTop: offsetTop,
61
+ offsetBottom: offsetBottom,
62
+ viewportHeight: viewportHeight
63
+ }) || !shouldFix && !isNullOrUndefined(offsetBottom) && viewportHeight - bottom <= offsetBottom) {
64
+ return setStyle({
65
+ bottom: offsetBottom + "px"
66
+ });
67
+ }
65
68
  }
66
69
  }
67
70
  resetStyle();
@@ -15,13 +15,13 @@ import { findValueIndex } from './helpers';
15
15
  import { isEqualArray, last, bind } from '../utils';
16
16
  import { BaseSelect } from '../select/base';
17
17
  var typeDefs = _extends({}, BaseSelect.typeDefs, {
18
- value: [String, Array, Date, Number, dayjs.Dayjs],
18
+ value: [String, Array, Date, Number, dayjs],
19
19
  range: Boolean,
20
20
  format: String,
21
21
  valueFormat: String,
22
22
  showFormat: String,
23
- min: [String, Date, Number, dayjs.Dayjs],
24
- max: [String, Date, Number, dayjs.Dayjs],
23
+ min: [String, Date, Number, dayjs],
24
+ max: [String, Date, Number, dayjs],
25
25
  disabledDate: Function
26
26
  });
27
27
  var defaults = function defaults() {
@@ -58,8 +58,8 @@ var defaults = {
58
58
  padding: "0 24px",
59
59
  bodyMarginTop: "-25px",
60
60
  tipIconMarginBottom: '10px',
61
- tipIconFontSize: '24px',
62
- tipIconLineHeight: '24px',
61
+ tipIconFontSize: '40px',
62
+ tipIconLineHeight: '40px',
63
63
  // with title
64
64
  titleFontWeight: '500',
65
65
  titleTipIconFontSize: '24px',
@@ -91,6 +91,7 @@ export function useMenuKeyboard() {
91
91
  function reset() {
92
92
  var item = items[focusIndex];
93
93
  if (focusIndex > -1 && item) {
94
+ // TODO(find bug)
94
95
  itemEvents.get(item).onFocusout();
95
96
  focusIndex = -1;
96
97
  }
@@ -141,6 +142,8 @@ export function useItemKeyboard(itemEvents) {
141
142
  onMouseLeave: function onMouseLeave(e) {
142
143
  instance.trigger('mouseleave', e);
143
144
  keyboard.reset();
145
+ // If it is a virtual item, it needs to be reset manually because the DOM is reused.
146
+ isFocus.set(false);
144
147
  },
145
148
  isFocus: isFocus
146
149
  };
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
3
3
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
4
4
  import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
5
5
  import BasicDemo from '~/components/input/demos/basic';
6
- import { mount, dispatchEvent, wait, getElement } from '../../test/utils';
6
+ import { mount, unmount, dispatchEvent, wait, getElement } from '../../test/utils';
7
7
  import SearchDemo from '~/components/input/demos/search';
8
8
  import FrozenDemo from '~/components/input/demos/frozen';
9
9
  import AutoRowsDemo from '~/components/input/demos/autoRows';
@@ -13,7 +13,9 @@ import { Input } from './';
13
13
  import { Dialog } from '../dialog';
14
14
  import { Component } from 'intact';
15
15
  describe('Input', function () {
16
- // afterEach(() => {unmount()});
16
+ afterEach(function () {
17
+ unmount();
18
+ });
17
19
  it('basic test', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
18
20
  var _mount, instance, element, input;
19
21
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -60,7 +60,7 @@ export var makeAsideStyles = cache(function makeAsideStyles(k) {
60
60
  if (theme === 'dark') return;
61
61
  var styles = layout.light;
62
62
  return /*#__PURE__*/css("&.", k, "-", theme, "{background:", styles.bgColor, ";color:", styles.color, ";border-right:", styles.border, ";}");
63
- }), " &.", k, "-fixed{position:fixed;overflow:auto;left:0;top:0;bottom:0;z-index:", theme.midZIndex, ";}.", k, "-menu{width:auto!important;}");
63
+ }), " &.", k, "-fixed{position:fixed;overflow:auto;left:0;top:0;bottom:0;z-index:", theme.midZIndex, ";}.", k, "-menu{width:auto!important;border-right:none!important;}");
64
64
  });
65
65
  export var makeBodyStyles = cache(function makeBodyStyles(k) {
66
66
  return /*#__PURE__*/css("transition:padding-left ", layout.transition, ";");
@@ -24,6 +24,7 @@ export interface BaseSelectProps<V, Multipe extends boolean = boolean, Attach =
24
24
  flat?: boolean;
25
25
  nowrap?: boolean;
26
26
  draggable?: boolean;
27
+ virtual?: boolean;
27
28
  }
28
29
  export interface BaseSelectEvents {
29
30
  keydown: [KeyboardEvent];
@@ -37,7 +37,8 @@ var typeDefs = {
37
37
  position: Dropdown.typeDefs.position,
38
38
  flat: Boolean,
39
39
  nowrap: Boolean,
40
- draggable: Boolean
40
+ draggable: Boolean,
41
+ virtual: Boolean
41
42
  };
42
43
  var defaults = function defaults() {
43
44
  return {
@@ -71,8 +71,7 @@ export default function ($props, $blocks, $__proto__) {
71
71
  'key': 'filter',
72
72
  'readonly': !show,
73
73
  'waveDisabled': true,
74
- 'flat': flat,
75
- 'frozenOnInput': true
74
+ 'flat': flat
76
75
  }, 'filter', inputRef) : undefined;
77
76
  return _$cc(ErrorContext.Consumer, {
78
77
  'defaultValue': false,
@@ -123,8 +122,7 @@ export default function ($props, $blocks, $__proto__) {
123
122
  'key': 'input',
124
123
  'readonly': !show,
125
124
  'waveDisabled': true,
126
- 'flat': flat,
127
- 'frozenOnInput': true
125
+ 'flat': flat
128
126
  }, 'input', inputRef) : !filterable && !hasValue ? _$ce(2, 'div', placeholder, 0, _$cn(k + "-select-placeholder c-ellipsis"), null, 'placeholder') : !multiple ? _$ce(2, 'div', (_$blocks['value'] = function ($super) {
129
127
  return label;
130
128
  }, __$blocks['value'] = function ($super, data) {
@@ -1,7 +1,8 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
- import { createVNode as _$cv, className as _$cn, createElementVNode as _$ce, noop as _$no } from 'intact';
2
+ import { createVNode as _$cv, className as _$cn, createElementVNode as _$ce, noop as _$no, createUnknownComponentVNode as _$cc } from 'intact';
3
3
  import { makeGroupStyles } from './styles';
4
4
  import { getRestProps } from '../utils';
5
+ import { VirtualList } from '../virtualList';
5
6
  export default function ($props, $blocks, $__proto__) {
6
7
  var _classNameObj;
7
8
  $blocks || ($blocks = {});
@@ -14,7 +15,8 @@ export default function ($props, $blocks, $__proto__) {
14
15
  label = _this$get.label,
15
16
  className = _this$get.className;
16
17
  var _this$select$get = this.select.get(),
17
- card = _this$select$get.card;
18
+ card = _this$select$get.card,
19
+ virtual = _this$select$get.virtual;
18
20
  var k = this.config.k;
19
21
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-select-group"] = true, _classNameObj[className] = className, _classNameObj[makeGroupStyles(k)] = true, _classNameObj);
20
22
  return _$cv('div', _extends({}, getRestProps(this), {
@@ -27,6 +29,9 @@ export default function ($props, $blocks, $__proto__) {
27
29
  return _$blocks['label'].call($this, $super, data);
28
30
  };
29
31
  return block ? block.call($this, callBlock, data) : callBlock();
30
- }, __$blocks['label'](_$no)), 0, _$cn(k + "-select-group-label")) : undefined, children]);
32
+ }, __$blocks['label'](_$no)), 0, _$cn(k + "-select-group-label")) : undefined, _$cc(VirtualList, {
33
+ 'disabled': !virtual,
34
+ 'children': children
35
+ })]);
31
36
  }
32
37
  ;
@@ -10,6 +10,7 @@ import { Button } from '../button';
10
10
  import { Icon } from '../icon';
11
11
  import { context } from './useSearchable';
12
12
  import { Tabs, Tab } from '../tabs';
13
+ import { VirtualList } from '../virtualList';
13
14
  export default function ($props, $blocks, $__proto__) {
14
15
  var _classNameObj;
15
16
  $blocks || ($blocks = {});
@@ -21,7 +22,8 @@ export default function ($props, $blocks, $__proto__) {
21
22
  var _this$select$get = this.select.get(),
22
23
  card = _this$select$get.card,
23
24
  searchable = _this$select$get.searchable,
24
- multiple = _this$select$get.multiple;
25
+ multiple = _this$select$get.multiple,
26
+ virtual = _this$select$get.virtual;
25
27
  var k = this.config.k;
26
28
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-select-menu"] = true, _classNameObj[k + "-card"] = card, _classNameObj[k + "-searchable"] = searchable, _classNameObj[className] = className, _classNameObj[makeMenuStyles(k)] = true, _classNameObj);
27
29
  if (card) {
@@ -43,9 +45,16 @@ export default function ($props, $blocks, $__proto__) {
43
45
  });
44
46
  }, $this)
45
47
  }), group];
46
- }
47
- if (isEmptyChildren(children)) {
48
+ } else if (isEmptyChildren(children)) {
48
49
  children = _$ce(2, 'div', _$('无数据'), 0, _$cn(k + "-select-empty"));
50
+ } else {
51
+ children = _$cc(VirtualList, {
52
+ 'style': {
53
+ maxHeight: '200px'
54
+ },
55
+ 'disabled': !virtual,
56
+ 'children': children
57
+ });
49
58
  }
50
59
  if (searchable) {
51
60
  var _this$searchable = this.searchable,