@king-design/vue 3.7.0 → 3.8.0-beta.1

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 (227) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +399 -0
  2. package/components/bubble/bubble.d.ts +62 -0
  3. package/components/bubble/bubble.js +81 -0
  4. package/components/bubble/bubble.vdt.js +89 -0
  5. package/components/bubble/index.d.ts +1 -0
  6. package/components/bubble/index.js +1 -0
  7. package/components/bubble/index.spec.d.ts +1 -0
  8. package/components/bubble/index.spec.js +824 -0
  9. package/components/bubble/styles.d.ts +5 -0
  10. package/components/bubble/styles.js +53 -0
  11. package/components/bubble/useBubbleDisplay.d.ts +19 -0
  12. package/components/bubble/useBubbleDisplay.js +308 -0
  13. package/components/bubbleList/bubbleList.d.ts +87 -0
  14. package/components/bubbleList/bubbleList.js +75 -0
  15. package/components/bubbleList/bubbleList.vdt.js +145 -0
  16. package/components/bubbleList/index.d.ts +1 -0
  17. package/components/bubbleList/index.js +1 -0
  18. package/components/bubbleList/index.spec.d.ts +1 -0
  19. package/components/bubbleList/index.spec.js +1332 -0
  20. package/components/bubbleList/item.d.ts +16 -0
  21. package/components/bubbleList/item.js +27 -0
  22. package/components/bubbleList/item.vdt.js +36 -0
  23. package/components/bubbleList/styles.d.ts +5 -0
  24. package/components/bubbleList/styles.js +33 -0
  25. package/components/bubbleList/useBubbleList.d.ts +28 -0
  26. package/components/bubbleList/useBubbleList.js +462 -0
  27. package/components/checkbox/index.d.ts +3 -3
  28. package/components/fileCard/fileCard.d.ts +65 -0
  29. package/components/fileCard/fileCard.js +72 -0
  30. package/components/fileCard/fileCard.vdt.js +161 -0
  31. package/components/fileCard/fileCardAssets.d.ts +1 -0
  32. package/components/fileCard/fileCardAssets.js +54 -0
  33. package/components/fileCard/fileCardUtils.d.ts +14 -0
  34. package/components/fileCard/fileCardUtils.js +94 -0
  35. package/components/fileCard/index.d.ts +2 -0
  36. package/components/fileCard/index.js +2 -0
  37. package/components/fileCard/index.spec.d.ts +1 -0
  38. package/components/fileCard/index.spec.js +1168 -0
  39. package/components/fileCard/list.d.ts +30 -0
  40. package/components/fileCard/list.js +46 -0
  41. package/components/fileCard/list.vdt.js +73 -0
  42. package/components/fileCard/styles.d.ts +5 -0
  43. package/components/fileCard/styles.js +85 -0
  44. package/components/fileCard/useFileCard.d.ts +45 -0
  45. package/components/fileCard/useFileCard.js +301 -0
  46. package/components/fileCard/useFileCardList.d.ts +14 -0
  47. package/components/fileCard/useFileCardList.js +49 -0
  48. package/components/form/form.js +2 -1
  49. package/components/media/context.d.ts +6 -0
  50. package/components/media/context.js +2 -0
  51. package/components/media/group.d.ts +12 -0
  52. package/components/media/group.js +32 -0
  53. package/components/media/group.vdt.js +50 -0
  54. package/components/media/index.d.ts +2 -0
  55. package/components/media/index.js +2 -0
  56. package/components/media/index.spec.d.ts +1 -0
  57. package/components/media/index.spec.js +1880 -0
  58. package/components/media/media.d.ts +37 -0
  59. package/components/media/media.js +67 -0
  60. package/components/media/media.vdt.js +213 -0
  61. package/components/media/mediaAssets.d.ts +6 -0
  62. package/components/media/mediaAssets.js +13 -0
  63. package/components/media/mediaUtils.d.ts +6 -0
  64. package/components/media/mediaUtils.js +66 -0
  65. package/components/media/styles.d.ts +13 -0
  66. package/components/media/styles.js +54 -0
  67. package/components/media/types.d.ts +37 -0
  68. package/components/media/types.js +1 -0
  69. package/components/media/useMedia.d.ts +74 -0
  70. package/components/media/useMedia.js +493 -0
  71. package/components/media/useMediaGroup.d.ts +15 -0
  72. package/components/media/useMediaGroup.js +136 -0
  73. package/components/media/useMediaViewer.d.ts +14 -0
  74. package/components/media/useMediaViewer.js +129 -0
  75. package/components/media/viewer.d.ts +24 -0
  76. package/components/media/viewer.js +54 -0
  77. package/components/media/viewer.vdt.js +100 -0
  78. package/components/radio/index.d.ts +3 -3
  79. package/components/sender/icons.d.ts +3 -0
  80. package/components/sender/icons.js +17 -0
  81. package/components/sender/index.d.ts +1 -0
  82. package/components/sender/index.js +1 -0
  83. package/components/sender/index.spec.d.ts +1 -0
  84. package/components/sender/index.spec.js +2201 -0
  85. package/components/sender/sender.d.ts +127 -0
  86. package/components/sender/sender.js +122 -0
  87. package/components/sender/sender.vdt.js +302 -0
  88. package/components/sender/styles.d.ts +5 -0
  89. package/components/sender/styles.js +65 -0
  90. package/components/sender/useAutoResize.d.ts +4 -0
  91. package/components/sender/useAutoResize.js +99 -0
  92. package/components/sender/useSenderDrag.d.ts +6 -0
  93. package/components/sender/useSenderDrag.js +329 -0
  94. package/components/sender/useSenderInput.d.ts +19 -0
  95. package/components/sender/useSenderInput.js +118 -0
  96. package/components/sender/useSenderPaste.d.ts +5 -0
  97. package/components/sender/useSenderPaste.js +36 -0
  98. package/components/sender/useSenderUpload.d.ts +11 -0
  99. package/components/sender/useSenderUpload.js +404 -0
  100. package/components/skeleton/skeleton.d.ts +2 -1
  101. package/components/skeleton/skeleton.js +1 -1
  102. package/components/think/index.d.ts +1 -0
  103. package/components/think/index.js +1 -0
  104. package/components/think/index.spec.d.ts +1 -0
  105. package/components/think/index.spec.js +345 -0
  106. package/components/think/index.vdt.js +82 -0
  107. package/components/think/styles.d.ts +5 -0
  108. package/components/think/styles.js +25 -0
  109. package/components/think/think.d.ts +28 -0
  110. package/components/think/think.js +48 -0
  111. package/components/think/useThinkExpand.d.ts +10 -0
  112. package/components/think/useThinkExpand.js +56 -0
  113. package/components/types.d.ts +4 -2
  114. package/components/upload/ajaxUploader.d.ts +1 -0
  115. package/components/upload/ajaxUploader.js +6 -0
  116. package/components/xmarkdown/index.d.ts +2 -0
  117. package/components/xmarkdown/index.js +1 -0
  118. package/components/xmarkdown/index.spec.d.ts +1 -0
  119. package/components/xmarkdown/index.spec.js +1797 -0
  120. package/components/xmarkdown/markdown/codeBlockRenderer.d.ts +8 -0
  121. package/components/xmarkdown/markdown/codeBlockRenderer.js +52 -0
  122. package/components/xmarkdown/markdown/codeblock.d.ts +8 -0
  123. package/components/xmarkdown/markdown/codeblock.js +74 -0
  124. package/components/xmarkdown/markdown/highlight.d.ts +17 -0
  125. package/components/xmarkdown/markdown/highlight.js +83 -0
  126. package/components/xmarkdown/markdown/index.d.ts +14 -0
  127. package/components/xmarkdown/markdown/index.js +14 -0
  128. package/components/xmarkdown/markdown/mermaid.d.ts +8 -0
  129. package/components/xmarkdown/markdown/mermaid.js +104 -0
  130. package/components/xmarkdown/markdown/renderTree.d.ts +54 -0
  131. package/components/xmarkdown/markdown/renderTree.js +386 -0
  132. package/components/xmarkdown/markdown/renderer.d.ts +18 -0
  133. package/components/xmarkdown/markdown/renderer.js +461 -0
  134. package/components/xmarkdown/markdown/streaming.d.ts +24 -0
  135. package/components/xmarkdown/markdown/streaming.js +546 -0
  136. package/components/xmarkdown/markdown/types.d.ts +124 -0
  137. package/components/xmarkdown/markdown/types.js +6 -0
  138. package/components/xmarkdown/markdown/utils.d.ts +7 -0
  139. package/components/xmarkdown/markdown/utils.js +9 -0
  140. package/components/xmarkdown/markdown.d.ts +1 -0
  141. package/components/xmarkdown/markdown.js +1 -0
  142. package/components/xmarkdown/styles.d.ts +5 -0
  143. package/components/xmarkdown/styles.js +50 -0
  144. package/components/xmarkdown/useMermaid.d.ts +27 -0
  145. package/components/xmarkdown/useMermaid.js +745 -0
  146. package/components/xmarkdown/useXMarkdownContent.d.ts +14 -0
  147. package/components/xmarkdown/useXMarkdownContent.js +218 -0
  148. package/components/xmarkdown/useXMarkdownDisplay.d.ts +27 -0
  149. package/components/xmarkdown/useXMarkdownDisplay.js +577 -0
  150. package/components/xmarkdown/xmarkdown.d.ts +62 -0
  151. package/components/xmarkdown/xmarkdown.js +109 -0
  152. package/components/xmarkdown/xmarkdown.vdt.js +47 -0
  153. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  154. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  155. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  156. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  157. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  158. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  159. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  160. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  161. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  162. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  163. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  164. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  165. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  166. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  167. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  168. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  169. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  170. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  171. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  172. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  173. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  174. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  175. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  176. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  177. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  178. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  179. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  180. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  181. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  182. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  183. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  184. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  185. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  186. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  187. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  188. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  189. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  190. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  191. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  192. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  193. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  194. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  195. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  196. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  197. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  198. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  199. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  200. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  201. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  202. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  203. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  204. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  205. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  206. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  207. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  208. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  209. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  210. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  211. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  212. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  213. package/dist/i18n/en-US.js +30 -1
  214. package/dist/i18n/en-US.js.map +1 -1
  215. package/dist/i18n/en-US.min.js +1 -1
  216. package/dist/index.js +100694 -37438
  217. package/dist/index.js.map +1 -1
  218. package/dist/index.min.js +1569 -1
  219. package/dist/kpc.css +4 -0
  220. package/dist/ksyun.css +4 -0
  221. package/i18n/en-US.d.ts +28 -0
  222. package/i18n/en-US.js +30 -1
  223. package/index.d.ts +9 -2
  224. package/index.js +9 -2
  225. package/package.json +8 -2
  226. package/styles/global.js +12 -6
  227. package/yarn-error.log +0 -1012
@@ -0,0 +1,1332 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
3
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
4
+ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
5
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
6
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
7
+ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
8
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
9
+ import _atInstanceProperty from "@babel/runtime-corejs3/core-js/instance/at";
10
+ import { Component } from 'intact-vue-next';
11
+ import { dispatchEvent, mount, unmount, wait } from '../../test/utils';
12
+ import { BubbleList } from '.';
13
+ describe('BubbleList', function () {
14
+ afterEach(function () {
15
+ unmount();
16
+ });
17
+ it('should render items with role defaults and forward bubble footer, extra and bottom slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
18
+ var Demo, _mount, element, bubbles, bottoms, footers, extras, texts, firstBubble, firstFooter, firstExtra;
19
+ return _regeneratorRuntime.wrap(function _callee$(_context2) {
20
+ while (1) switch (_context2.prev = _context2.next) {
21
+ case 0:
22
+ Demo = /*#__PURE__*/function (_Component) {
23
+ _inheritsLoose(Demo, _Component);
24
+ function Demo() {
25
+ var _context;
26
+ var _this;
27
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
+ args[_key] = arguments[_key];
29
+ }
30
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
31
+ _this.BubbleList = BubbleList;
32
+ return _this;
33
+ }
34
+ Demo.defaults = function defaults() {
35
+ return {
36
+ roles: {
37
+ ai: {
38
+ placement: 'start',
39
+ avatar: true,
40
+ roleName: 'AI'
41
+ },
42
+ user: {
43
+ placement: 'end',
44
+ avatar: true,
45
+ roleName: 'Me',
46
+ variant: 'outlined'
47
+ }
48
+ },
49
+ items: [{
50
+ key: 1,
51
+ role: 'ai',
52
+ content: 'hello'
53
+ }, {
54
+ key: 2,
55
+ role: 'user',
56
+ content: 'world'
57
+ }]
58
+ };
59
+ };
60
+ return Demo;
61
+ }(Component);
62
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 240px;\"\n items={this.get('items')}\n roles={this.get('roles')}\n >\n <b:bottom args=\"scope\">\n <span class=\"custom-bubble-bottom\">{scope.item.role}</span>\n </b:bottom>\n <b:footer args=\"scope\">\n <span class=\"custom-bubble-footer\">{scope.item.key}</span>\n </b:footer>\n <b:extra args=\"scope\">\n <span class=\"custom-bubble-extra\">{scope.item.content}</span>\n </b:extra>\n </BubbleList>\n ";
63
+ _mount = mount(Demo), element = _mount[1];
64
+ _context2.next = 5;
65
+ return wait(50);
66
+ case 5:
67
+ bubbles = element.querySelectorAll('.k-bubble');
68
+ bottoms = element.querySelectorAll('.custom-bubble-bottom');
69
+ footers = element.querySelectorAll('.custom-bubble-footer');
70
+ extras = element.querySelectorAll('.custom-bubble-extra');
71
+ texts = element.querySelectorAll('.k-bubble-text');
72
+ firstBubble = bubbles[0];
73
+ firstFooter = firstBubble.querySelector('.custom-bubble-footer');
74
+ firstExtra = firstBubble.querySelector('.custom-bubble-extra');
75
+ expect(bubbles.length).to.eql(2);
76
+ expect(bubbles[0].classList.contains('k-bubble-start')).to.be.true;
77
+ expect(bubbles[1].classList.contains('k-bubble-end')).to.be.true;
78
+ expect(bubbles[1].classList.contains('k-bubble-outlined')).to.be.true;
79
+ expect(texts.length).to.eql(2);
80
+ expect(texts[0].textContent).to.contain('hello');
81
+ expect(texts[1].textContent).to.contain('world');
82
+ expect(bottoms.length).to.eql(2);
83
+ expect(bottoms[0].textContent).to.eql('ai');
84
+ expect(bottoms[1].textContent).to.eql('user');
85
+ expect(footers.length).to.eql(2);
86
+ expect(footers[0].textContent).to.eql('1');
87
+ expect(footers[1].textContent).to.eql('2');
88
+ expect(extras.length).to.eql(2);
89
+ expect(extras[0].textContent).to.eql('hello');
90
+ expect(extras[1].textContent).to.eql('world');
91
+ expect(firstFooter.compareDocumentPosition(firstExtra) & Node.DOCUMENT_POSITION_FOLLOWING).to.not.eql(0);
92
+ case 30:
93
+ case "end":
94
+ return _context2.stop();
95
+ }
96
+ }, _callee);
97
+ })));
98
+ it('should stay at bottom when the last bubble keeps growing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
99
+ var _context5, _context6;
100
+ var Demo, _mount2, instance, element, scrollBox, nextItems;
101
+ return _regeneratorRuntime.wrap(function _callee2$(_context7) {
102
+ while (1) switch (_context7.prev = _context7.next) {
103
+ case 0:
104
+ Demo = /*#__PURE__*/function (_Component2) {
105
+ _inheritsLoose(Demo, _Component2);
106
+ function Demo() {
107
+ var _context3;
108
+ var _this2;
109
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
110
+ args[_key2] = arguments[_key2];
111
+ }
112
+ _this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context3 = [this]).call(_context3, args)) || this;
113
+ _this2.listRef = null;
114
+ _this2.BubbleList = BubbleList;
115
+ return _this2;
116
+ }
117
+ Demo.defaults = function defaults() {
118
+ var _context4;
119
+ var items = _mapInstanceProperty(_context4 = _Array$from({
120
+ length: 12
121
+ })).call(_context4, function (_, index) {
122
+ return {
123
+ key: index,
124
+ role: index % 2 ? 'ai' : 'user',
125
+ content: "line " + index
126
+ };
127
+ });
128
+ return {
129
+ roles: {
130
+ ai: {
131
+ placement: 'start',
132
+ avatar: true,
133
+ roleName: 'AI'
134
+ },
135
+ user: {
136
+ placement: 'end',
137
+ avatar: true,
138
+ roleName: 'Me',
139
+ variant: 'outlined'
140
+ }
141
+ },
142
+ items: items
143
+ };
144
+ };
145
+ return Demo;
146
+ }(Component);
147
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n ref={(i) => this.listRef = i}\n style=\"height: 220px;\"\n items={this.get('items')}\n roles={this.get('roles')}\n />\n ";
148
+ _mount2 = mount(Demo), instance = _mount2[0], element = _mount2[1];
149
+ _context7.next = 5;
150
+ return wait(80);
151
+ case 5:
152
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
153
+ expect(scrollBox.scrollTop).to.be.greaterThan(0);
154
+ expect(instance.listRef.isAtBottom()).to.be.true;
155
+ nextItems = _sliceInstanceProperty(_context5 = instance.get('items')).call(_context5);
156
+ nextItems[nextItems.length - 1] = _extends({}, nextItems[nextItems.length - 1], {
157
+ content: _mapInstanceProperty(_context6 = _Array$from({
158
+ length: 32
159
+ })).call(_context6, function (_, index) {
160
+ return "grow " + index;
161
+ }).join('\n'),
162
+ typing: true
163
+ });
164
+ instance.set('items', nextItems);
165
+ _context7.next = 13;
166
+ return wait(120);
167
+ case 13:
168
+ expect(instance.listRef.isAtBottom()).to.be.true;
169
+ expect(scrollBox.scrollHeight - scrollBox.scrollTop - scrollBox.clientHeight).to.be.lessThan(90);
170
+ case 15:
171
+ case "end":
172
+ return _context7.stop();
173
+ }
174
+ }, _callee2);
175
+ })));
176
+ it('should keep short content at the top when list has fixed height', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
177
+ var Demo, _mount3, element, scrollBox, firstRow, offset;
178
+ return _regeneratorRuntime.wrap(function _callee3$(_context9) {
179
+ while (1) switch (_context9.prev = _context9.next) {
180
+ case 0:
181
+ Demo = /*#__PURE__*/function (_Component3) {
182
+ _inheritsLoose(Demo, _Component3);
183
+ function Demo() {
184
+ var _context8;
185
+ var _this3;
186
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
187
+ args[_key3] = arguments[_key3];
188
+ }
189
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context8 = [this]).call(_context8, args)) || this;
190
+ _this3.BubbleList = BubbleList;
191
+ return _this3;
192
+ }
193
+ Demo.defaults = function defaults() {
194
+ return {
195
+ items: [{
196
+ key: 1,
197
+ content: 'first'
198
+ }, {
199
+ key: 2,
200
+ content: 'second'
201
+ }]
202
+ };
203
+ };
204
+ return Demo;
205
+ }(Component);
206
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 400px;\"\n items={this.get('items')}\n >\n <b:item args=\"scope\">\n <div class=\"short-row\" style=\"height: 40px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
207
+ _mount3 = mount(Demo), element = _mount3[1];
208
+ _context9.next = 5;
209
+ return wait(50);
210
+ case 5:
211
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
212
+ firstRow = element.querySelector('.short-row');
213
+ offset = firstRow.getBoundingClientRect().top - scrollBox.getBoundingClientRect().top;
214
+ expect(offset).to.be.lessThan(16);
215
+ case 9:
216
+ case "end":
217
+ return _context9.stop();
218
+ }
219
+ }, _callee3);
220
+ })));
221
+ it('should scroll to bottom on mount when initial content overflows', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
222
+ var Demo, _mount4, element, scrollBox;
223
+ return _regeneratorRuntime.wrap(function _callee4$(_context12) {
224
+ while (1) switch (_context12.prev = _context12.next) {
225
+ case 0:
226
+ Demo = /*#__PURE__*/function (_Component4) {
227
+ _inheritsLoose(Demo, _Component4);
228
+ function Demo() {
229
+ var _context10;
230
+ var _this4;
231
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
232
+ args[_key4] = arguments[_key4];
233
+ }
234
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context10 = [this]).call(_context10, args)) || this;
235
+ _this4.BubbleList = BubbleList;
236
+ return _this4;
237
+ }
238
+ Demo.defaults = function defaults() {
239
+ var _context11;
240
+ return {
241
+ items: _mapInstanceProperty(_context11 = _Array$from({
242
+ length: 8
243
+ })).call(_context11, function (_, index) {
244
+ return {
245
+ key: index,
246
+ content: "initial-" + index
247
+ };
248
+ })
249
+ };
250
+ };
251
+ return Demo;
252
+ }(Component);
253
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 160px;\"\n items={this.get('items')}\n >\n <b:item args=\"scope\">\n <div class=\"initial-row\" style=\"height: 48px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
254
+ _mount4 = mount(Demo), element = _mount4[1];
255
+ _context12.next = 5;
256
+ return wait(80);
257
+ case 5:
258
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
259
+ expect(scrollBox.scrollTop).to.be.greaterThan(0);
260
+ expect(scrollBox.scrollHeight - scrollBox.scrollTop - scrollBox.clientHeight).to.be.lessThan(4);
261
+ case 8:
262
+ case "end":
263
+ return _context12.stop();
264
+ }
265
+ }, _callee4);
266
+ })));
267
+ it('should stop sticky scrolling after user scrolls away from the bottom', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
268
+ var _context15, _context16;
269
+ var Demo, _mount5, instance, element, scrollBox, nextItems;
270
+ return _regeneratorRuntime.wrap(function _callee5$(_context17) {
271
+ while (1) switch (_context17.prev = _context17.next) {
272
+ case 0:
273
+ Demo = /*#__PURE__*/function (_Component5) {
274
+ _inheritsLoose(Demo, _Component5);
275
+ function Demo() {
276
+ var _context13;
277
+ var _this5;
278
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
279
+ args[_key5] = arguments[_key5];
280
+ }
281
+ _this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context13 = [this]).call(_context13, args)) || this;
282
+ _this5.listRef = null;
283
+ _this5.BubbleList = BubbleList;
284
+ return _this5;
285
+ }
286
+ Demo.defaults = function defaults() {
287
+ var _context14;
288
+ return {
289
+ items: _mapInstanceProperty(_context14 = _Array$from({
290
+ length: 10
291
+ })).call(_context14, function (_, index) {
292
+ return {
293
+ key: index,
294
+ content: "row-" + index
295
+ };
296
+ })
297
+ };
298
+ };
299
+ return Demo;
300
+ }(Component);
301
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n ref={(i) => this.listRef = i}\n style=\"height: 220px;\"\n items={this.get('items')}\n >\n <b:item args=\"scope\">\n <div class=\"custom-row\" style=\"height: 48px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
302
+ _mount5 = mount(Demo), instance = _mount5[0], element = _mount5[1];
303
+ _context17.next = 5;
304
+ return wait(80);
305
+ case 5:
306
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
307
+ scrollBox.scrollTop = 40;
308
+ dispatchEvent(scrollBox, 'scroll');
309
+ _context17.next = 10;
310
+ return wait(30);
311
+ case 10:
312
+ expect(instance.listRef.isAtBottom()).to.be.false;
313
+ nextItems = _sliceInstanceProperty(_context15 = instance.get('items')).call(_context15);
314
+ nextItems[nextItems.length - 1] = _extends({}, nextItems[nextItems.length - 1], {
315
+ content: _mapInstanceProperty(_context16 = _Array$from({
316
+ length: 8
317
+ })).call(_context16, function (_, index) {
318
+ return "row-9-" + index;
319
+ }).join(' ')
320
+ });
321
+ instance.set('items', nextItems);
322
+ _context17.next = 16;
323
+ return wait(100);
324
+ case 16:
325
+ expect(instance.listRef.isAtBottom()).to.be.false;
326
+ expect(scrollBox.scrollTop).to.be.lessThan(120);
327
+ case 18:
328
+ case "end":
329
+ return _context17.stop();
330
+ }
331
+ }, _callee5);
332
+ })));
333
+ it('should preserve viewport position when prepending history while reading older messages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
334
+ var _context20;
335
+ var Demo, _mount6, instance, element, scrollBox, prevScrollTop;
336
+ return _regeneratorRuntime.wrap(function _callee6$(_context21) {
337
+ while (1) switch (_context21.prev = _context21.next) {
338
+ case 0:
339
+ Demo = /*#__PURE__*/function (_Component6) {
340
+ _inheritsLoose(Demo, _Component6);
341
+ function Demo() {
342
+ var _context18;
343
+ var _this6;
344
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
345
+ args[_key6] = arguments[_key6];
346
+ }
347
+ _this6 = _Component6.call.apply(_Component6, _concatInstanceProperty(_context18 = [this]).call(_context18, args)) || this;
348
+ _this6.listRef = null;
349
+ _this6.BubbleList = BubbleList;
350
+ return _this6;
351
+ }
352
+ Demo.defaults = function defaults() {
353
+ var _context19;
354
+ return {
355
+ items: _mapInstanceProperty(_context19 = _Array$from({
356
+ length: 8
357
+ })).call(_context19, function (_, index) {
358
+ return {
359
+ key: index,
360
+ content: "history-" + index
361
+ };
362
+ })
363
+ };
364
+ };
365
+ return Demo;
366
+ }(Component);
367
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n ref={(i) => this.listRef = i}\n style=\"height: 160px;\"\n items={this.get('items')}\n >\n <b:item args=\"scope\">\n <div class=\"history-row\" style=\"height: 40px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
368
+ _mount6 = mount(Demo), instance = _mount6[0], element = _mount6[1];
369
+ _context21.next = 5;
370
+ return wait(80);
371
+ case 5:
372
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
373
+ scrollBox.scrollTop = 40;
374
+ dispatchEvent(scrollBox, 'scroll');
375
+ _context21.next = 10;
376
+ return wait(30);
377
+ case 10:
378
+ prevScrollTop = scrollBox.scrollTop;
379
+ instance.set('items', _concatInstanceProperty(_context20 = [{
380
+ key: -2,
381
+ content: 'history--2'
382
+ }, {
383
+ key: -1,
384
+ content: 'history--1'
385
+ }]).call(_context20, instance.get('items')));
386
+ _context21.next = 14;
387
+ return wait(120);
388
+ case 14:
389
+ expect(scrollBox.scrollTop).to.be.greaterThan(prevScrollTop + 40);
390
+ case 15:
391
+ case "end":
392
+ return _context21.stop();
393
+ }
394
+ }, _callee6);
395
+ })));
396
+ it('should keep existing item dom nodes stable when prepending history without explicit keys', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
397
+ var _context23;
398
+ var Demo, _mount7, instance, element, initialRows, firstExistingRow, secondExistingRow, currentItems, rowsAfterPrepend;
399
+ return _regeneratorRuntime.wrap(function _callee7$(_context24) {
400
+ while (1) switch (_context24.prev = _context24.next) {
401
+ case 0:
402
+ Demo = /*#__PURE__*/function (_Component7) {
403
+ _inheritsLoose(Demo, _Component7);
404
+ function Demo() {
405
+ var _context22;
406
+ var _this7;
407
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
408
+ args[_key7] = arguments[_key7];
409
+ }
410
+ _this7 = _Component7.call.apply(_Component7, _concatInstanceProperty(_context22 = [this]).call(_context22, args)) || this;
411
+ _this7.BubbleList = BubbleList;
412
+ return _this7;
413
+ }
414
+ Demo.defaults = function defaults() {
415
+ return {
416
+ items: [{
417
+ content: 'row-1'
418
+ }, {
419
+ content: 'row-2'
420
+ }, {
421
+ content: 'row-3'
422
+ }]
423
+ };
424
+ };
425
+ return Demo;
426
+ }(Component);
427
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 180px;\"\n items={this.get('items')}\n >\n <b:item args=\"scope\">\n <div class=\"fallback-key-row\" style=\"height: 40px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
428
+ _mount7 = mount(Demo), instance = _mount7[0], element = _mount7[1];
429
+ _context24.next = 5;
430
+ return wait(80);
431
+ case 5:
432
+ initialRows = element.querySelectorAll('.fallback-key-row');
433
+ firstExistingRow = initialRows[0];
434
+ secondExistingRow = initialRows[1];
435
+ currentItems = instance.get('items');
436
+ instance.set('items', _concatInstanceProperty(_context23 = [{
437
+ content: 'history-a'
438
+ }, {
439
+ content: 'history-b'
440
+ }]).call(_context23, currentItems));
441
+ _context24.next = 12;
442
+ return wait(80);
443
+ case 12:
444
+ rowsAfterPrepend = element.querySelectorAll('.fallback-key-row');
445
+ expect(rowsAfterPrepend[2]).to.eql(firstExistingRow);
446
+ expect(rowsAfterPrepend[3]).to.eql(secondExistingRow);
447
+ expect(rowsAfterPrepend[2].textContent).to.eql('row-1');
448
+ expect(rowsAfterPrepend[3].textContent).to.eql('row-2');
449
+ case 17:
450
+ case "end":
451
+ return _context24.stop();
452
+ }
453
+ }, _callee7);
454
+ })));
455
+ it('should limit the root height when maxHeight is set', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
456
+ var Demo, _mount8, element, root, scrollBox;
457
+ return _regeneratorRuntime.wrap(function _callee8$(_context27) {
458
+ while (1) switch (_context27.prev = _context27.next) {
459
+ case 0:
460
+ Demo = /*#__PURE__*/function (_Component8) {
461
+ _inheritsLoose(Demo, _Component8);
462
+ function Demo() {
463
+ var _context25;
464
+ var _this8;
465
+ for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
466
+ args[_key8] = arguments[_key8];
467
+ }
468
+ _this8 = _Component8.call.apply(_Component8, _concatInstanceProperty(_context25 = [this]).call(_context25, args)) || this;
469
+ _this8.BubbleList = BubbleList;
470
+ return _this8;
471
+ }
472
+ Demo.defaults = function defaults() {
473
+ var _context26;
474
+ return {
475
+ roles: {
476
+ ai: {
477
+ placement: 'start',
478
+ avatar: true,
479
+ roleName: 'AI'
480
+ },
481
+ user: {
482
+ placement: 'end',
483
+ avatar: true,
484
+ roleName: 'Me',
485
+ variant: 'outlined'
486
+ }
487
+ },
488
+ items: _mapInstanceProperty(_context26 = _Array$from({
489
+ length: 12
490
+ })).call(_context26, function (_, index) {
491
+ return {
492
+ key: index + 1,
493
+ role: index % 2 ? 'user' : 'ai',
494
+ content: "row-" + (index + 1)
495
+ };
496
+ })
497
+ };
498
+ };
499
+ return Demo;
500
+ }(Component);
501
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"border: 1px solid transparent;\"\n maxHeight={180}\n items={this.get('items')}\n roles={this.get('roles')}\n />\n ";
502
+ _mount8 = mount(Demo), element = _mount8[1];
503
+ _context27.next = 5;
504
+ return wait(80);
505
+ case 5:
506
+ root = element;
507
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
508
+ expect(root.getBoundingClientRect().height).to.be.lessThan(181);
509
+ expect(scrollBox.scrollHeight).to.be.greaterThan(scrollBox.clientHeight);
510
+ case 9:
511
+ case "end":
512
+ return _context27.stop();
513
+ }
514
+ }, _callee8);
515
+ })));
516
+ it('should keep scroll content flush and add gap only when scrollbar appears', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
517
+ var Demo, _mount9, instance, element, scrollBox, scrollContent, contentStyle;
518
+ return _regeneratorRuntime.wrap(function _callee9$(_context30) {
519
+ while (1) switch (_context30.prev = _context30.next) {
520
+ case 0:
521
+ Demo = /*#__PURE__*/function (_Component9) {
522
+ _inheritsLoose(Demo, _Component9);
523
+ function Demo() {
524
+ var _context28;
525
+ var _this9;
526
+ for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
527
+ args[_key9] = arguments[_key9];
528
+ }
529
+ _this9 = _Component9.call.apply(_Component9, _concatInstanceProperty(_context28 = [this]).call(_context28, args)) || this;
530
+ _this9.BubbleList = BubbleList;
531
+ return _this9;
532
+ }
533
+ Demo.defaults = function defaults() {
534
+ var _context29;
535
+ return {
536
+ items: _mapInstanceProperty(_context29 = _Array$from({
537
+ length: 6
538
+ })).call(_context29, function (_, index) {
539
+ return {
540
+ key: index,
541
+ content: "row-" + index
542
+ };
543
+ })
544
+ };
545
+ };
546
+ return Demo;
547
+ }(Component);
548
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 120px;\"\n items={this.get('items')}\n >\n <b:item args=\"scope\">\n <div class=\"scrollbar-gap-row\" style=\"height: 48px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
549
+ _mount9 = mount(Demo), instance = _mount9[0], element = _mount9[1];
550
+ _context30.next = 5;
551
+ return wait(80);
552
+ case 5:
553
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
554
+ scrollContent = element.querySelector('.k-bubble-list-scroll-content');
555
+ contentStyle = getComputedStyle(scrollContent);
556
+ expect(scrollBox.scrollHeight).to.be.greaterThan(scrollBox.clientHeight);
557
+ expect(scrollBox.classList.contains('k-bubble-list-scroll-has-scrollbar')).to.be.true;
558
+ expect(getComputedStyle(scrollBox).paddingInlineEnd).to.eql('6px');
559
+ expect(contentStyle.paddingInlineStart).to.eql('0px');
560
+ expect(contentStyle.paddingInlineEnd).to.eql('0px');
561
+ instance.set('items', [{
562
+ key: 'short',
563
+ content: 'short'
564
+ }]);
565
+ _context30.next = 16;
566
+ return wait(120);
567
+ case 16:
568
+ contentStyle = getComputedStyle(scrollContent);
569
+ expect(scrollBox.scrollHeight - scrollBox.clientHeight).to.be.lessThan(2);
570
+ expect(scrollBox.classList.contains('k-bubble-list-scroll-has-scrollbar')).to.be.false;
571
+ expect(getComputedStyle(scrollBox).paddingInlineEnd).to.eql('0px');
572
+ expect(contentStyle.paddingInlineStart).to.eql('0px');
573
+ expect(contentStyle.paddingInlineEnd).to.eql('0px');
574
+ case 22:
575
+ case "end":
576
+ return _context30.stop();
577
+ }
578
+ }, _callee9);
579
+ })));
580
+ it('should scroll correctly when using a custom item slot', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
581
+ var Demo, _mount10, instance, element, scrollBox, targetRow, scrollBoxRect, targetRect;
582
+ return _regeneratorRuntime.wrap(function _callee10$(_context33) {
583
+ while (1) switch (_context33.prev = _context33.next) {
584
+ case 0:
585
+ Demo = /*#__PURE__*/function (_Component10) {
586
+ _inheritsLoose(Demo, _Component10);
587
+ function Demo() {
588
+ var _context31;
589
+ var _this10;
590
+ for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
591
+ args[_key10] = arguments[_key10];
592
+ }
593
+ _this10 = _Component10.call.apply(_Component10, _concatInstanceProperty(_context31 = [this]).call(_context31, args)) || this;
594
+ _this10.listRef = null;
595
+ _this10.BubbleList = BubbleList;
596
+ return _this10;
597
+ }
598
+ Demo.defaults = function defaults() {
599
+ var _context32;
600
+ return {
601
+ items: _mapInstanceProperty(_context32 = _Array$from({
602
+ length: 12
603
+ })).call(_context32, function (_, index) {
604
+ return {
605
+ key: index + 1,
606
+ content: "row-" + (index + 1)
607
+ };
608
+ })
609
+ };
610
+ };
611
+ return Demo;
612
+ }(Component);
613
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n ref={(i) => this.listRef = i}\n style=\"height: 180px;\"\n items={this.get('items')}\n >\n <b:item args=\"scope\">\n <div class=\"custom-item-shell\" style=\"height: 48px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
614
+ _mount10 = mount(Demo), instance = _mount10[0], element = _mount10[1];
615
+ _context33.next = 5;
616
+ return wait(80);
617
+ case 5:
618
+ instance.listRef.scrollToKey(6, 'auto');
619
+ _context33.next = 8;
620
+ return wait(30);
621
+ case 8:
622
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
623
+ targetRow = element.querySelectorAll('.custom-item-shell')[5];
624
+ scrollBoxRect = scrollBox.getBoundingClientRect();
625
+ targetRect = targetRow.getBoundingClientRect();
626
+ expect(Math.abs(targetRect.top - scrollBoxRect.top)).to.be.lessThan(4);
627
+ case 13:
628
+ case "end":
629
+ return _context33.stop();
630
+ }
631
+ }, _callee10);
632
+ })));
633
+ it('should scroll the target item near the top when calling scrollToKey', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
634
+ var Demo, _mount11, instance, element, scrollBox, targetRow, scrollBoxRect, targetRect;
635
+ return _regeneratorRuntime.wrap(function _callee11$(_context36) {
636
+ while (1) switch (_context36.prev = _context36.next) {
637
+ case 0:
638
+ Demo = /*#__PURE__*/function (_Component11) {
639
+ _inheritsLoose(Demo, _Component11);
640
+ function Demo() {
641
+ var _context34;
642
+ var _this11;
643
+ for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
644
+ args[_key11] = arguments[_key11];
645
+ }
646
+ _this11 = _Component11.call.apply(_Component11, _concatInstanceProperty(_context34 = [this]).call(_context34, args)) || this;
647
+ _this11.listRef = null;
648
+ _this11.BubbleList = BubbleList;
649
+ return _this11;
650
+ }
651
+ Demo.defaults = function defaults() {
652
+ var _context35;
653
+ return {
654
+ roles: {
655
+ ai: {
656
+ placement: 'start',
657
+ avatar: true,
658
+ roleName: 'AI'
659
+ },
660
+ user: {
661
+ placement: 'end',
662
+ avatar: true,
663
+ roleName: 'Me',
664
+ variant: 'outlined'
665
+ }
666
+ },
667
+ items: _mapInstanceProperty(_context35 = _Array$from({
668
+ length: 12
669
+ })).call(_context35, function (_, index) {
670
+ return {
671
+ key: index + 1,
672
+ role: index % 2 ? 'user' : 'ai',
673
+ content: "row-" + (index + 1)
674
+ };
675
+ })
676
+ };
677
+ };
678
+ return Demo;
679
+ }(Component);
680
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n ref={(i) => this.listRef = i}\n style=\"height: 180px;\"\n items={this.get('items')}\n roles={this.get('roles')}\n />\n ";
681
+ _mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
682
+ _context36.next = 5;
683
+ return wait(80);
684
+ case 5:
685
+ instance.listRef.scrollToKey(6, 'auto');
686
+ _context36.next = 8;
687
+ return wait(30);
688
+ case 8:
689
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
690
+ targetRow = element.querySelectorAll('.k-bubble-list-item')[5];
691
+ scrollBoxRect = scrollBox.getBoundingClientRect();
692
+ targetRect = targetRow.getBoundingClientRect();
693
+ expect(Math.abs(targetRect.top - scrollBoxRect.top)).to.be.lessThan(4);
694
+ case 13:
695
+ case "end":
696
+ return _context36.stop();
697
+ }
698
+ }, _callee11);
699
+ })));
700
+ it('should support resolving keys from itemKey function when scrolling to a message', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
701
+ var Demo, _mount12, instance, element, scrollBox, targetRow, scrollBoxRect, targetRect;
702
+ return _regeneratorRuntime.wrap(function _callee12$(_context39) {
703
+ while (1) switch (_context39.prev = _context39.next) {
704
+ case 0:
705
+ Demo = /*#__PURE__*/function (_Component12) {
706
+ _inheritsLoose(Demo, _Component12);
707
+ function Demo() {
708
+ var _context37;
709
+ var _this12;
710
+ for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
711
+ args[_key12] = arguments[_key12];
712
+ }
713
+ _this12 = _Component12.call.apply(_Component12, _concatInstanceProperty(_context37 = [this]).call(_context37, args)) || this;
714
+ _this12.listRef = null;
715
+ _this12.BubbleList = BubbleList;
716
+ return _this12;
717
+ }
718
+ Demo.defaults = function defaults() {
719
+ var _context38;
720
+ return {
721
+ roles: {
722
+ ai: {
723
+ placement: 'start',
724
+ avatar: true,
725
+ roleName: 'AI'
726
+ },
727
+ user: {
728
+ placement: 'end',
729
+ avatar: true,
730
+ roleName: 'Me',
731
+ variant: 'outlined'
732
+ }
733
+ },
734
+ items: _mapInstanceProperty(_context38 = _Array$from({
735
+ length: 12
736
+ })).call(_context38, function (_, index) {
737
+ return {
738
+ id: "msg-" + (index + 1),
739
+ role: index % 2 ? 'user' : 'ai',
740
+ content: "row-" + (index + 1)
741
+ };
742
+ })
743
+ };
744
+ };
745
+ return Demo;
746
+ }(Component);
747
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n ref={(i) => this.listRef = i}\n style=\"height: 180px;\"\n items={this.get('items')}\n itemKey={(item) => item.id}\n roles={this.get('roles')}\n />\n ";
748
+ _mount12 = mount(Demo), instance = _mount12[0], element = _mount12[1];
749
+ _context39.next = 5;
750
+ return wait(80);
751
+ case 5:
752
+ instance.listRef.scrollToKey('msg-6', 'auto');
753
+ _context39.next = 8;
754
+ return wait(30);
755
+ case 8:
756
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
757
+ targetRow = element.querySelectorAll('.k-bubble-list-item')[5];
758
+ scrollBoxRect = scrollBox.getBoundingClientRect();
759
+ targetRect = targetRow.getBoundingClientRect();
760
+ expect(Math.abs(targetRect.top - scrollBoxRect.top)).to.be.lessThan(4);
761
+ case 13:
762
+ case "end":
763
+ return _context39.stop();
764
+ }
765
+ }, _callee12);
766
+ })));
767
+ it('should keep per-item slot updates working when list boundaries change', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
768
+ var _context41, _context42, _context43;
769
+ var Demo, _mount13, instance, element;
770
+ return _regeneratorRuntime.wrap(function _callee13$(_context44) {
771
+ while (1) switch (_context44.prev = _context44.next) {
772
+ case 0:
773
+ Demo = /*#__PURE__*/function (_Component13) {
774
+ _inheritsLoose(Demo, _Component13);
775
+ function Demo() {
776
+ var _context40;
777
+ var _this13;
778
+ for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
779
+ args[_key13] = arguments[_key13];
780
+ }
781
+ _this13 = _Component13.call.apply(_Component13, _concatInstanceProperty(_context40 = [this]).call(_context40, args)) || this;
782
+ _this13.BubbleList = BubbleList;
783
+ return _this13;
784
+ }
785
+ Demo.defaults = function defaults() {
786
+ return {
787
+ items: [{
788
+ key: 1,
789
+ content: 'first'
790
+ }, {
791
+ key: 2,
792
+ content: 'second'
793
+ }]
794
+ };
795
+ };
796
+ return Demo;
797
+ }(Component);
798
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList items={this.get('items')}>\n <b:footer args=\"scope\">\n <span class=\"last-flag\">{scope.item.key}:{scope.isLast ? 'last' : 'normal'}</span>\n </b:footer>\n </BubbleList>\n ";
799
+ _mount13 = mount(Demo), instance = _mount13[0], element = _mount13[1];
800
+ _context44.next = 5;
801
+ return wait(50);
802
+ case 5:
803
+ expect(_mapInstanceProperty(_context41 = _Array$from(element.querySelectorAll('.last-flag'))).call(_context41, function (item) {
804
+ return item.textContent;
805
+ })).to.eql(['1:normal', '2:last']);
806
+ instance.set('items', _concatInstanceProperty(_context42 = []).call(_context42, instance.get('items'), [{
807
+ key: 3,
808
+ content: 'third'
809
+ }]));
810
+ _context44.next = 9;
811
+ return wait(50);
812
+ case 9:
813
+ expect(_mapInstanceProperty(_context43 = _Array$from(element.querySelectorAll('.last-flag'))).call(_context43, function (item) {
814
+ return item.textContent;
815
+ })).to.eql(['1:normal', '2:normal', '3:last']);
816
+ case 10:
817
+ case "end":
818
+ return _context44.stop();
819
+ }
820
+ }, _callee13);
821
+ })));
822
+ it('should trigger loadHistory once when scrolling near the top', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
823
+ var Demo, _mount14, instance, element, scrollBox;
824
+ return _regeneratorRuntime.wrap(function _callee14$(_context47) {
825
+ while (1) switch (_context47.prev = _context47.next) {
826
+ case 0:
827
+ Demo = /*#__PURE__*/function (_Component14) {
828
+ _inheritsLoose(Demo, _Component14);
829
+ function Demo() {
830
+ var _context45;
831
+ var _this14;
832
+ for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
833
+ args[_key14] = arguments[_key14];
834
+ }
835
+ _this14 = _Component14.call.apply(_Component14, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
836
+ _this14.BubbleList = BubbleList;
837
+ return _this14;
838
+ }
839
+ Demo.defaults = function defaults() {
840
+ var _context46;
841
+ return {
842
+ count: 0,
843
+ loadingHistory: false,
844
+ items: _mapInstanceProperty(_context46 = _Array$from({
845
+ length: 10
846
+ })).call(_context46, function (_, index) {
847
+ return {
848
+ key: index,
849
+ content: "history-" + index
850
+ };
851
+ })
852
+ };
853
+ };
854
+ return Demo;
855
+ }(Component);
856
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 180px;\"\n items={this.get('items')}\n hasMoreHistory={true}\n loadingHistory={this.get('loadingHistory')}\n ev-loadHistory={() => this.set({count: this.get('count') + 1, loadingHistory: true})}\n >\n <b:item args=\"scope\">\n <div style=\"height: 44px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
857
+ _mount14 = mount(Demo), instance = _mount14[0], element = _mount14[1];
858
+ _context47.next = 5;
859
+ return wait(80);
860
+ case 5:
861
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
862
+ scrollBox.scrollTop = 0;
863
+ dispatchEvent(scrollBox, 'scroll');
864
+ dispatchEvent(scrollBox, 'scroll');
865
+ _context47.next = 11;
866
+ return wait(40);
867
+ case 11:
868
+ expect(instance.get('count')).to.eql(1);
869
+ case 12:
870
+ case "end":
871
+ return _context47.stop();
872
+ }
873
+ }, _callee14);
874
+ })));
875
+ it('should show the default history loading text only while loadingHistory is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
876
+ var Demo, _mount15, instance, element;
877
+ return _regeneratorRuntime.wrap(function _callee15$(_context49) {
878
+ while (1) switch (_context49.prev = _context49.next) {
879
+ case 0:
880
+ Demo = /*#__PURE__*/function (_Component15) {
881
+ _inheritsLoose(Demo, _Component15);
882
+ function Demo() {
883
+ var _context48;
884
+ var _this15;
885
+ for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
886
+ args[_key15] = arguments[_key15];
887
+ }
888
+ _this15 = _Component15.call.apply(_Component15, _concatInstanceProperty(_context48 = [this]).call(_context48, args)) || this;
889
+ _this15.BubbleList = BubbleList;
890
+ return _this15;
891
+ }
892
+ Demo.defaults = function defaults() {
893
+ return {
894
+ loadingHistory: false,
895
+ items: [{
896
+ key: 1,
897
+ content: 'hello'
898
+ }]
899
+ };
900
+ };
901
+ return Demo;
902
+ }(Component);
903
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 180px;\"\n items={this.get('items')}\n loadingHistory={this.get('loadingHistory')}\n />\n ";
904
+ _mount15 = mount(Demo), instance = _mount15[0], element = _mount15[1];
905
+ _context49.next = 5;
906
+ return wait(50);
907
+ case 5:
908
+ expect(element.querySelector('.k-bubble-list-history')).to.be.null;
909
+ instance.set('loadingHistory', true);
910
+ _context49.next = 9;
911
+ return wait(50);
912
+ case 9:
913
+ expect(element.querySelector('.k-bubble-list-history span').textContent).to.eql('加载历史中...');
914
+ instance.set('loadingHistory', false);
915
+ _context49.next = 13;
916
+ return wait(50);
917
+ case 13:
918
+ expect(element.querySelector('.k-bubble-list-history')).to.be.null;
919
+ case 14:
920
+ case "end":
921
+ return _context49.stop();
922
+ }
923
+ }, _callee15);
924
+ })));
925
+ it('should warn only once when items are missing stable keys', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
926
+ var warn, spy, Demo;
927
+ return _regeneratorRuntime.wrap(function _callee16$(_context51) {
928
+ while (1) switch (_context51.prev = _context51.next) {
929
+ case 0:
930
+ warn = console.warn;
931
+ spy = sinon.spy();
932
+ console.warn = spy;
933
+ Demo = /*#__PURE__*/function (_Component16) {
934
+ _inheritsLoose(Demo, _Component16);
935
+ function Demo() {
936
+ var _context50;
937
+ var _this16;
938
+ for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
939
+ args[_key16] = arguments[_key16];
940
+ }
941
+ _this16 = _Component16.call.apply(_Component16, _concatInstanceProperty(_context50 = [this]).call(_context50, args)) || this;
942
+ _this16.BubbleList = BubbleList;
943
+ return _this16;
944
+ }
945
+ Demo.defaults = function defaults() {
946
+ return {
947
+ items: [{
948
+ content: 'a'
949
+ }, {
950
+ content: 'b'
951
+ }]
952
+ };
953
+ };
954
+ return Demo;
955
+ }(Component);
956
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList items={this.get('items')}>\n <b:item args=\"scope\">\n <div style=\"height: 40px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
957
+ _context51.prev = 5;
958
+ mount(Demo);
959
+ _context51.next = 9;
960
+ return wait(50);
961
+ case 9:
962
+ expect(spy.callCount).to.eql(1);
963
+ expect(spy.args[0][0]).to.contain('stable `key`');
964
+ case 11:
965
+ _context51.prev = 11;
966
+ console.warn = warn;
967
+ return _context51.finish(11);
968
+ case 14:
969
+ case "end":
970
+ return _context51.stop();
971
+ }
972
+ }, _callee16, null, [[5,, 11, 14]]);
973
+ })));
974
+ it('should render empty slot only when there are no items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
975
+ var Demo, _mount16, instance, element;
976
+ return _regeneratorRuntime.wrap(function _callee17$(_context53) {
977
+ while (1) switch (_context53.prev = _context53.next) {
978
+ case 0:
979
+ Demo = /*#__PURE__*/function (_Component17) {
980
+ _inheritsLoose(Demo, _Component17);
981
+ function Demo() {
982
+ var _context52;
983
+ var _this17;
984
+ for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
985
+ args[_key17] = arguments[_key17];
986
+ }
987
+ _this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(_context52 = [this]).call(_context52, args)) || this;
988
+ _this17.BubbleList = BubbleList;
989
+ return _this17;
990
+ }
991
+ Demo.defaults = function defaults() {
992
+ return {
993
+ items: []
994
+ };
995
+ };
996
+ return Demo;
997
+ }(Component);
998
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n items={this.get('items')}\n >\n <b:empty>\n <div class=\"custom-empty\">empty</div>\n </b:empty>\n </BubbleList>\n ";
999
+ _mount16 = mount(Demo), instance = _mount16[0], element = _mount16[1];
1000
+ _context53.next = 5;
1001
+ return wait(50);
1002
+ case 5:
1003
+ expect(element.querySelector('.custom-empty').textContent).to.eql('empty');
1004
+ instance.set('items', [{
1005
+ key: 1,
1006
+ content: 'hello'
1007
+ }]);
1008
+ _context53.next = 9;
1009
+ return wait(50);
1010
+ case 9:
1011
+ expect(element.querySelector('.custom-empty')).to.be.null;
1012
+ case 10:
1013
+ case "end":
1014
+ return _context53.stop();
1015
+ }
1016
+ }, _callee17);
1017
+ })));
1018
+ it('should keep custom historyLoading slot visible for final no-more-history text', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
1019
+ var Demo, _mount17, element;
1020
+ return _regeneratorRuntime.wrap(function _callee18$(_context55) {
1021
+ while (1) switch (_context55.prev = _context55.next) {
1022
+ case 0:
1023
+ Demo = /*#__PURE__*/function (_Component18) {
1024
+ _inheritsLoose(Demo, _Component18);
1025
+ function Demo() {
1026
+ var _context54;
1027
+ var _this18;
1028
+ for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
1029
+ args[_key18] = arguments[_key18];
1030
+ }
1031
+ _this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context54 = [this]).call(_context54, args)) || this;
1032
+ _this18.BubbleList = BubbleList;
1033
+ return _this18;
1034
+ }
1035
+ Demo.defaults = function defaults() {
1036
+ return {
1037
+ items: [{
1038
+ key: 1,
1039
+ content: 'hello'
1040
+ }]
1041
+ };
1042
+ };
1043
+ return Demo;
1044
+ }(Component);
1045
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n style=\"height: 180px;\"\n items={this.get('items')}\n hasMoreHistory={false}\n loadingHistory={false}\n >\n <b:historyLoading args=\"scope\">\n <div class=\"history-status\">\n {scope.loadingHistory ? 'loading' : scope.hasMoreHistory ? 'more' : 'done'}\n </div>\n </b:historyLoading>\n </BubbleList>\n ";
1046
+ _mount17 = mount(Demo), element = _mount17[1];
1047
+ _context55.next = 5;
1048
+ return wait(50);
1049
+ case 5:
1050
+ expect(element.querySelector('.history-status').textContent).to.eql('done');
1051
+ case 6:
1052
+ case "end":
1053
+ return _context55.stop();
1054
+ }
1055
+ }, _callee18);
1056
+ })));
1057
+ it('should not render bubble wrappers for empty scoped slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
1058
+ var Demo, _mount18, element;
1059
+ return _regeneratorRuntime.wrap(function _callee19$(_context57) {
1060
+ while (1) switch (_context57.prev = _context57.next) {
1061
+ case 0:
1062
+ Demo = /*#__PURE__*/function (_Component19) {
1063
+ _inheritsLoose(Demo, _Component19);
1064
+ function Demo() {
1065
+ var _context56;
1066
+ var _this19;
1067
+ for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
1068
+ args[_key19] = arguments[_key19];
1069
+ }
1070
+ _this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context56 = [this]).call(_context56, args)) || this;
1071
+ _this19.BubbleList = BubbleList;
1072
+ return _this19;
1073
+ }
1074
+ Demo.defaults = function defaults() {
1075
+ return {
1076
+ roles: {
1077
+ ai: {
1078
+ placement: 'start'
1079
+ }
1080
+ },
1081
+ items: [{
1082
+ key: 1,
1083
+ role: 'ai',
1084
+ content: '生成中',
1085
+ completed: false
1086
+ }, {
1087
+ key: 2,
1088
+ role: 'ai',
1089
+ content: '已完成',
1090
+ completed: true
1091
+ }]
1092
+ };
1093
+ };
1094
+ return Demo;
1095
+ }(Component);
1096
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n items={this.get('items')}\n roles={this.get('roles')}\n >\n <b:extra args=\"scope\">\n <span v-if={scope.item.completed} class=\"scoped-extra\">\u5DF2\u5B8C\u6210</span>\n </b:extra>\n </BubbleList>\n ";
1097
+ _mount18 = mount(Demo), element = _mount18[1];
1098
+ _context57.next = 5;
1099
+ return wait(50);
1100
+ case 5:
1101
+ expect(element.querySelectorAll('.k-bubble-extra').length).to.eql(1);
1102
+ expect(element.querySelector('.scoped-extra').textContent).to.eql('已完成');
1103
+ case 7:
1104
+ case "end":
1105
+ return _context57.stop();
1106
+ }
1107
+ }, _callee19);
1108
+ })));
1109
+ it('should not render wrappers for empty outer slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
1110
+ var Demo, _mount19, element;
1111
+ return _regeneratorRuntime.wrap(function _callee20$(_context59) {
1112
+ while (1) switch (_context59.prev = _context59.next) {
1113
+ case 0:
1114
+ Demo = /*#__PURE__*/function (_Component20) {
1115
+ _inheritsLoose(Demo, _Component20);
1116
+ function Demo() {
1117
+ var _context58;
1118
+ var _this20;
1119
+ for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
1120
+ args[_key20] = arguments[_key20];
1121
+ }
1122
+ _this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context58 = [this]).call(_context58, args)) || this;
1123
+ _this20.BubbleList = BubbleList;
1124
+ return _this20;
1125
+ }
1126
+ Demo.defaults = function defaults() {
1127
+ return {
1128
+ items: [{
1129
+ key: 1,
1130
+ content: 'hello'
1131
+ }]
1132
+ };
1133
+ };
1134
+ return Demo;
1135
+ }(Component);
1136
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n items={this.get('items')}\n loadingHistory={true}\n >\n <b:header>\n <span v-if={false} class=\"empty-header\">header</span>\n </b:header>\n <b:historyLoading>\n <span v-if={false} class=\"empty-history\">history</span>\n </b:historyLoading>\n <b:listFooter>\n <span v-if={false} class=\"empty-footer\">footer</span>\n </b:listFooter>\n </BubbleList>\n ";
1137
+ _mount19 = mount(Demo), element = _mount19[1];
1138
+ _context59.next = 5;
1139
+ return wait(50);
1140
+ case 5:
1141
+ expect(element.querySelector('.k-bubble-list-header')).to.eql(null);
1142
+ expect(element.querySelector('.k-bubble-list-history')).to.eql(null);
1143
+ expect(element.querySelector('.k-bubble-list-footer')).to.eql(null);
1144
+ expect(element.querySelector('.k-bubble')).not.to.eql(null);
1145
+ case 9:
1146
+ case "end":
1147
+ return _context59.stop();
1148
+ }
1149
+ }, _callee20);
1150
+ })));
1151
+ it('should not render empty wrapper when empty slot is empty', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
1152
+ var Demo, _mount20, element;
1153
+ return _regeneratorRuntime.wrap(function _callee21$(_context61) {
1154
+ while (1) switch (_context61.prev = _context61.next) {
1155
+ case 0:
1156
+ Demo = /*#__PURE__*/function (_Component21) {
1157
+ _inheritsLoose(Demo, _Component21);
1158
+ function Demo() {
1159
+ var _context60;
1160
+ var _this21;
1161
+ for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
1162
+ args[_key21] = arguments[_key21];
1163
+ }
1164
+ _this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context60 = [this]).call(_context60, args)) || this;
1165
+ _this21.BubbleList = BubbleList;
1166
+ return _this21;
1167
+ }
1168
+ return Demo;
1169
+ }(Component);
1170
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList items={[]}>\n <b:empty>\n <span v-if={false} class=\"empty-content\">empty</span>\n </b:empty>\n </BubbleList>\n ";
1171
+ _mount20 = mount(Demo), element = _mount20[1];
1172
+ _context61.next = 5;
1173
+ return wait(50);
1174
+ case 5:
1175
+ expect(element.querySelector('.k-bubble-list-empty')).to.eql(null);
1176
+ expect(element.querySelector('.k-bubble-list-items')).not.to.eql(null);
1177
+ case 7:
1178
+ case "end":
1179
+ return _context61.stop();
1180
+ }
1181
+ }, _callee21);
1182
+ })));
1183
+ it('should emit scroll state events and honor showScrollToBottom=false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
1184
+ var _context64, _context65;
1185
+ var Demo, _mount21, instance, element, scrollBox;
1186
+ return _regeneratorRuntime.wrap(function _callee22$(_context66) {
1187
+ while (1) switch (_context66.prev = _context66.next) {
1188
+ case 0:
1189
+ Demo = /*#__PURE__*/function (_Component22) {
1190
+ _inheritsLoose(Demo, _Component22);
1191
+ function Demo() {
1192
+ var _context62;
1193
+ var _this22;
1194
+ for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
1195
+ args[_key22] = arguments[_key22];
1196
+ }
1197
+ _this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context62 = [this]).call(_context62, args)) || this;
1198
+ _this22.listRef = null;
1199
+ _this22.BubbleList = BubbleList;
1200
+ return _this22;
1201
+ }
1202
+ Demo.defaults = function defaults() {
1203
+ var _context63;
1204
+ return {
1205
+ scrollCount: 0,
1206
+ bottomStates: [],
1207
+ autoStates: [],
1208
+ items: _mapInstanceProperty(_context63 = _Array$from({
1209
+ length: 12
1210
+ })).call(_context63, function (_, index) {
1211
+ return {
1212
+ key: index,
1213
+ content: "row-" + index
1214
+ };
1215
+ })
1216
+ };
1217
+ };
1218
+ return Demo;
1219
+ }(Component);
1220
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n ref={(i) => this.listRef = i}\n style=\"height: 180px;\"\n items={this.get('items')}\n showScrollToBottom={false}\n ev-scroll={() => this.set('scrollCount', this.get('scrollCount') + 1)}\n ev-scrollBottomChange={(value) => this.set('bottomStates', [...this.get('bottomStates'), value])}\n ev-autoScrollChange={(value) => this.set('autoStates', [...this.get('autoStates'), value])}\n >\n <b:item args=\"scope\">\n <div style=\"height: 44px;\">{scope.item.content}</div>\n </b:item>\n </BubbleList>\n ";
1221
+ _mount21 = mount(Demo), instance = _mount21[0], element = _mount21[1];
1222
+ _context66.next = 5;
1223
+ return wait(80);
1224
+ case 5:
1225
+ instance.set({
1226
+ scrollCount: 0,
1227
+ bottomStates: [],
1228
+ autoStates: []
1229
+ });
1230
+ scrollBox = element.querySelector('.k-bubble-list-scroll');
1231
+ scrollBox.scrollTop = 40;
1232
+ dispatchEvent(scrollBox, 'scroll');
1233
+ dispatchEvent(scrollBox, 'scroll');
1234
+ _context66.next = 12;
1235
+ return wait(40);
1236
+ case 12:
1237
+ _atInstanceProperty(expect(instance.get('scrollCount')).to.be).least(2);
1238
+ expect(instance.get('bottomStates')).to.eql([false]);
1239
+ expect(instance.get('autoStates')).to.eql([false]);
1240
+ expect(element.querySelector('.k-bubble-list-scroll-to-bottom')).to.be.null;
1241
+ instance.listRef.scrollToBottom('auto');
1242
+ _context66.next = 19;
1243
+ return wait(50);
1244
+ case 19:
1245
+ expect(_sliceInstanceProperty(_context64 = instance.get('bottomStates')).call(_context64, -1)[0]).to.eql(true);
1246
+ expect(_sliceInstanceProperty(_context65 = instance.get('autoStates')).call(_context65, -1)[0]).to.eql(true);
1247
+ expect(instance.listRef.isAtBottom()).to.be.true;
1248
+ expect(element.querySelector('.k-bubble-list-scroll-to-bottom')).to.be.null;
1249
+ case 23:
1250
+ case "end":
1251
+ return _context66.stop();
1252
+ }
1253
+ }, _callee22);
1254
+ })));
1255
+ it('should forward typing events to role handlers and component events', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1256
+ var roleTypingPayload, roleTypingCompletePayload, Demo, _mount22, instance;
1257
+ return _regeneratorRuntime.wrap(function _callee23$(_context68) {
1258
+ while (1) switch (_context68.prev = _context68.next) {
1259
+ case 0:
1260
+ roleTypingPayload = null;
1261
+ roleTypingCompletePayload = null;
1262
+ Demo = /*#__PURE__*/function (_Component23) {
1263
+ _inheritsLoose(Demo, _Component23);
1264
+ function Demo() {
1265
+ var _context67;
1266
+ var _this23;
1267
+ for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
1268
+ args[_key23] = arguments[_key23];
1269
+ }
1270
+ _this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context67 = [this]).call(_context67, args)) || this;
1271
+ _this23.BubbleList = BubbleList;
1272
+ return _this23;
1273
+ }
1274
+ Demo.defaults = function defaults() {
1275
+ return {
1276
+ typingCount: 0,
1277
+ completeCount: 0,
1278
+ completedContent: '',
1279
+ roles: {
1280
+ ai: {
1281
+ placement: 'start',
1282
+ onTyping: function onTyping(renderedContent, currentContent, item, index) {
1283
+ roleTypingPayload = {
1284
+ renderedContent: renderedContent,
1285
+ currentContent: currentContent,
1286
+ item: item,
1287
+ index: index
1288
+ };
1289
+ },
1290
+ onTypingComplete: function onTypingComplete(content, item, index) {
1291
+ roleTypingCompletePayload = {
1292
+ content: content,
1293
+ item: item,
1294
+ index: index
1295
+ };
1296
+ }
1297
+ }
1298
+ },
1299
+ items: [{
1300
+ key: 1,
1301
+ role: 'ai',
1302
+ content: 'abcd',
1303
+ typing: {
1304
+ interval: 16,
1305
+ step: 1
1306
+ }
1307
+ }]
1308
+ };
1309
+ };
1310
+ return Demo;
1311
+ }(Component);
1312
+ Demo.template = "\n const { BubbleList } = this;\n <BubbleList\n items={this.get('items')}\n roles={this.get('roles')}\n ev-typing={() => this.set('typingCount', this.get('typingCount') + 1)}\n ev-typingComplete={(item, content) => this.set({\n completeCount: this.get('completeCount') + 1,\n completedContent: item.key + ':' + content,\n })}\n />\n ";
1313
+ _mount22 = mount(Demo), instance = _mount22[0];
1314
+ _context68.next = 7;
1315
+ return wait(120);
1316
+ case 7:
1317
+ expect(instance.get('typingCount')).to.be.greaterThan(0);
1318
+ expect(instance.get('completeCount')).to.eql(1);
1319
+ expect(instance.get('completedContent')).to.eql('1:abcd');
1320
+ expect(roleTypingPayload.currentContent).to.eql('abcd');
1321
+ expect(roleTypingPayload.item.key).to.eql(1);
1322
+ expect(roleTypingPayload.index).to.eql(0);
1323
+ expect(roleTypingCompletePayload.content).to.eql('abcd');
1324
+ expect(roleTypingCompletePayload.item.key).to.eql(1);
1325
+ expect(roleTypingCompletePayload.index).to.eql(0);
1326
+ case 16:
1327
+ case "end":
1328
+ return _context68.stop();
1329
+ }
1330
+ }, _callee23);
1331
+ })));
1332
+ });