@opentiny/tiny-robot 0.1.0-alpha.0 → 0.2.0-alpha.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 (244) hide show
  1. package/dist/{bubble-item → bubble}/components/actions/copy.vue.d.ts +3 -3
  2. package/dist/{bubble-item → bubble}/components/actions/refresh.vue.d.ts +1 -1
  3. package/dist/bubble/index.d.ts +12 -0
  4. package/dist/bubble/index.type.d.ts +53 -0
  5. package/dist/bubble/useScroll.d.ts +4 -0
  6. package/dist/container/index.d.ts +7 -0
  7. package/dist/container/index.type.d.ts +16 -0
  8. package/dist/container/index.vue.d.ts +26 -0
  9. package/dist/index.d.ts +10 -5
  10. package/dist/index.js +31 -20
  11. package/dist/node_modules/.pnpm/@opentiny_utils@1.0.0/node_modules/@opentiny/utils/dist/opentiny-utils.es.js +832 -0
  12. package/dist/node_modules/.pnpm/@opentiny_utils@3.22.0/node_modules/@opentiny/utils/dist/index.es.js +959 -1496
  13. package/dist/node_modules/.pnpm/{@opentiny_vue-button@3.22.0 → @opentiny_vue-button@3.21.0}/node_modules/@opentiny/vue-button/lib/index.js +21 -21
  14. package/dist/node_modules/.pnpm/{@opentiny_vue-button@3.22.0 → @opentiny_vue-button@3.21.0}/node_modules/@opentiny/vue-button/lib/pc.js +3 -3
  15. package/dist/node_modules/.pnpm/@opentiny_vue-common@3.21.0/node_modules/@opentiny/vue-common/lib/index.js +727 -0
  16. package/dist/node_modules/.pnpm/@opentiny_vue-common@3.22.0/node_modules/@opentiny/vue-common/lib/index.js +144 -675
  17. package/dist/node_modules/.pnpm/{@opentiny_vue-dialog-box@3.22.0 → @opentiny_vue-dialog-box@3.21.0}/node_modules/@opentiny/vue-dialog-box/lib/index.js +9 -9
  18. package/dist/node_modules/.pnpm/{@opentiny_vue-dialog-box@3.22.0 → @opentiny_vue-dialog-box@3.21.0}/node_modules/@opentiny/vue-dialog-box/lib/pc.js +5 -5
  19. package/dist/node_modules/.pnpm/@opentiny_vue-icon@3.21.0/node_modules/@opentiny/vue-icon/lib/close.js +29 -0
  20. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/eyeclose.js +1 -1
  21. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/eyeopen.js +1 -1
  22. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/finish.js +1 -1
  23. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/fullscreen.js +1 -1
  24. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/loading-shadow.js +21 -22
  25. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/minscreen.js +1 -1
  26. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-column-after.js +1 -1
  27. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-column-before.js +1 -1
  28. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-row-after.js +1 -1
  29. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-row-before.js +1 -1
  30. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-align-center.js +1 -1
  31. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-align-left.js +1 -1
  32. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-align-right.js +1 -1
  33. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-bold.js +1 -1
  34. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-code-block.js +1 -1
  35. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-code-view.js +1 -1
  36. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-color.js +1 -1
  37. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-delete-column.js +1 -1
  38. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-delete-row.js +1 -1
  39. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-delete-table.js +1 -1
  40. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-font-size.js +1 -1
  41. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-format-clear.js +1 -1
  42. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h1.js +1 -1
  43. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h2.js +1 -1
  44. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h3.js +1 -1
  45. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h4.js +1 -1
  46. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h5.js +1 -1
  47. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h6.js +1 -1
  48. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-heading.js +1 -1
  49. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-high-light.js +1 -1
  50. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-image.js +1 -1
  51. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-italic.js +1 -1
  52. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-line-height.js +1 -1
  53. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-link-unlink.js +1 -1
  54. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-link.js +1 -1
  55. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-list-ordered.js +1 -1
  56. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-list-unordered.js +1 -1
  57. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-merge-cells-vertical.js +1 -1
  58. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-merge-cells.js +1 -1
  59. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-node-delete.js +1 -1
  60. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-paragraph.js +1 -1
  61. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-quote-text.js +1 -1
  62. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-redo.js +1 -1
  63. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-split-cells-horizontal.js +1 -1
  64. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-split-cells-vertical.js +1 -1
  65. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-strike-through.js +1 -1
  66. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-subscript.js +1 -1
  67. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-superscript.js +1 -1
  68. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-table.js +1 -1
  69. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-task-list.js +1 -1
  70. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-underline.js +1 -1
  71. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-undo.js +1 -1
  72. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/sub-script.js +1 -1
  73. package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/warn.js +1 -1
  74. package/dist/node_modules/.pnpm/{@opentiny_vue-input@3.22.0 → @opentiny_vue-input@3.21.0}/node_modules/@opentiny/vue-input/lib/index.js +3 -3
  75. package/dist/node_modules/.pnpm/{@opentiny_vue-input@3.22.0 → @opentiny_vue-input@3.21.0}/node_modules/@opentiny/vue-input/lib/pc.js +36 -36
  76. package/dist/node_modules/.pnpm/{@opentiny_vue-locale@3.22.0 → @opentiny_vue-locale@3.21.0}/node_modules/@opentiny/vue-locale/lib/index.js +63 -63
  77. package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/button/index.js +1 -1
  78. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/browser.js +36 -0
  79. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/clickoutside.js +47 -0
  80. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/debounce.js +7 -0
  81. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/dom.js +45 -0
  82. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/popper.js +320 -0
  83. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/popup-manager.js +118 -0
  84. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/throttle.js +23 -0
  85. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/useEventListener.js +9 -0
  86. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/useInstanceSlots.js +14 -0
  87. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/useRelation.js +54 -0
  88. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/vue-popper.js +84 -0
  89. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/vue-popup.js +73 -0
  90. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/event.js +13 -0
  91. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/function.js +5 -0
  92. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/index.js +11 -0
  93. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/object.js +84 -0
  94. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/string.js +28 -0
  95. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/type.js +28 -0
  96. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/dialog-box/index.js +136 -0
  97. package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/dialog-box/vue.js +33 -34
  98. package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/input/index.js +22 -22
  99. package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/input/vue.js +9 -9
  100. package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tall-storage/index.js +1 -1
  101. package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tall-storage/vue.js +5 -5
  102. package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tooltip/index.js +41 -40
  103. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/tooltip/vue.js +90 -0
  104. package/dist/node_modules/.pnpm/{@opentiny_vue-tooltip@3.22.0 → @opentiny_vue-tooltip@3.21.0}/node_modules/@opentiny/vue-tooltip/lib/index.js +3 -6
  105. package/dist/node_modules/.pnpm/{@opentiny_vue-tooltip@3.22.0 → @opentiny_vue-tooltip@3.21.0}/node_modules/@opentiny/vue-tooltip/lib/pc.js +2 -2
  106. package/dist/packages/components/src/{bubble-list → bubble}/bubble-list.vue.js +2 -2
  107. package/dist/packages/components/src/bubble/bubble-list.vue2.js +37 -0
  108. package/dist/packages/components/src/bubble/bubble.vue.js +7 -0
  109. package/dist/packages/components/src/bubble/bubble.vue2.js +118 -0
  110. package/dist/packages/components/src/bubble/components/actions/copy.vue.js +7 -0
  111. package/dist/packages/components/src/bubble/components/actions/copy.vue2.js +35 -0
  112. package/dist/packages/components/src/bubble/components/actions/refresh.vue.js +7 -0
  113. package/dist/packages/components/src/bubble/components/actions/refresh.vue2.js +16 -0
  114. package/dist/packages/components/src/bubble/index.js +18 -0
  115. package/dist/packages/components/src/bubble/useScroll.js +13 -0
  116. package/dist/packages/components/src/container/index.js +9 -0
  117. package/dist/packages/components/src/container/index.vue.js +7 -0
  118. package/dist/packages/components/src/container/index.vue2.js +55 -0
  119. package/dist/packages/components/src/conversations/index.js +1 -1
  120. package/dist/packages/components/src/prompts/index.js +18 -0
  121. package/dist/packages/components/src/prompts/prompt.vue.js +7 -0
  122. package/dist/packages/components/src/prompts/prompt.vue2.js +37 -0
  123. package/dist/packages/components/src/prompts/prompts.vue.js +7 -0
  124. package/dist/packages/components/src/prompts/prompts.vue2.js +36 -0
  125. package/dist/packages/components/src/question/components/CommonQuestions.vue.js +89 -0
  126. package/dist/packages/components/src/question/components/CommonQuestions.vue2.js +4 -0
  127. package/dist/packages/components/src/question/components/HotQuestions.vue.js +140 -0
  128. package/dist/packages/components/src/question/components/HotQuestions.vue2.js +4 -0
  129. package/dist/packages/components/src/question/composables/useQuestions.js +48 -0
  130. package/dist/packages/components/src/question/index.js +9 -0
  131. package/dist/packages/components/src/question/index.vue.js +113 -0
  132. package/dist/packages/components/src/question/index.vue2.js +4 -0
  133. package/dist/packages/components/src/sender/components/ActionButtons.vue.js +105 -123
  134. package/dist/packages/components/src/sender/composables/useInputHandler.js +26 -22
  135. package/dist/packages/components/src/sender/composables/useKeyboardHandler.js +11 -11
  136. package/dist/packages/components/src/sender/composables/useSpeechHandler.js +9 -9
  137. package/dist/packages/components/src/sender/index.vue.js +67 -66
  138. package/dist/packages/components/src/welcome/index.vue.js +5 -7
  139. package/dist/packages/components/src/welcome/index.vue2.js +32 -0
  140. package/dist/packages/svgs/dist/tiny-robot-svgs.js +223 -0
  141. package/dist/prompts/index.d.ts +12 -0
  142. package/dist/prompts/index.type.d.ts +55 -0
  143. package/dist/prompts/prompt.vue.d.ts +3 -0
  144. package/dist/prompts/prompts.vue.d.ts +20 -0
  145. package/dist/question/components/CommonQuestions.vue.d.ts +32 -0
  146. package/dist/question/components/HotQuestions.vue.d.ts +89 -0
  147. package/dist/question/composables/useQuestions.d.ts +17 -0
  148. package/dist/question/index.d.ts +7 -0
  149. package/dist/question/index.type.d.ts +74 -0
  150. package/dist/question/index.vue.d.ts +46 -0
  151. package/dist/sender/components/ActionButtons.vue.d.ts +6 -4
  152. package/dist/sender/composables/useSpeechHandler.d.ts +0 -6
  153. package/dist/sender/index.type.d.ts +1 -1
  154. package/dist/sender/index.vue.d.ts +3 -4
  155. package/dist/style.css +1 -1
  156. package/dist/welcome/index.type.d.ts +10 -0
  157. package/dist/welcome/index.vue.d.ts +17 -1
  158. package/package.json +6 -5
  159. package/src/bubble/bubble-list.vue +42 -0
  160. package/src/bubble/bubble.vue +247 -0
  161. package/src/bubble/components/actions/copy.vue +54 -0
  162. package/src/bubble/components/actions/refresh.vue +31 -0
  163. package/src/bubble/index.ts +23 -0
  164. package/src/bubble/index.type.ts +63 -0
  165. package/src/bubble/useScroll.ts +14 -0
  166. package/src/container/index.ts +12 -0
  167. package/src/container/index.type.ts +17 -0
  168. package/src/container/index.vue +135 -0
  169. package/src/conversations/index.ts +1 -1
  170. package/src/index.ts +26 -12
  171. package/src/prompts/index.ts +25 -0
  172. package/src/prompts/index.type.ts +59 -0
  173. package/src/prompts/prompt.vue +115 -0
  174. package/src/prompts/prompts.vue +50 -0
  175. package/src/question/components/CommonQuestions.vue +146 -0
  176. package/src/question/components/HotQuestions.vue +148 -0
  177. package/src/question/composables/useQuestions.ts +106 -0
  178. package/src/question/index.less +448 -0
  179. package/src/question/index.ts +12 -0
  180. package/src/question/index.type.ts +86 -0
  181. package/src/question/index.vue +140 -0
  182. package/src/question/vars.less +135 -0
  183. package/src/sender/components/ActionButtons.vue +42 -39
  184. package/src/sender/composables/useInputHandler.ts +15 -10
  185. package/src/sender/composables/useKeyboardHandler.ts +6 -4
  186. package/src/sender/composables/useSpeechHandler.ts +5 -11
  187. package/src/sender/index.less +3 -5
  188. package/src/sender/index.type.ts +1 -1
  189. package/src/sender/index.vue +3 -2
  190. package/src/welcome/index.type.ts +12 -0
  191. package/src/welcome/index.vue +68 -2
  192. package/.vscode/extensions.json +0 -3
  193. package/dist/bubble-item/components/icons/ai.vue.d.ts +0 -2
  194. package/dist/bubble-item/components/icons/index.d.ts +0 -2
  195. package/dist/bubble-item/components/icons/user.vue.d.ts +0 -2
  196. package/dist/bubble-item/index.d.ts +0 -7
  197. package/dist/bubble-list/index.d.ts +0 -8
  198. package/dist/bubble-list/index.type.d.ts +0 -55
  199. package/dist/node_modules/.pnpm/@opentiny_vue-directive@3.22.0/node_modules/@opentiny/vue-directive/index.js +0 -57
  200. package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popper.js +0 -85
  201. package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popup.js +0 -69
  202. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/dialog-box/index.js +0 -135
  203. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/vue.js +0 -90
  204. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +0 -5
  205. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +0 -10
  206. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTrim.js +0 -8
  207. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +0 -4
  208. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +0 -15
  209. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +0 -7
  210. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +0 -5
  211. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_trimmedEndIndex.js +0 -9
  212. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/debounce.js +0 -54
  213. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +0 -7
  214. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js +0 -6
  215. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSymbol.js +0 -9
  216. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js +0 -7
  217. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/toNumber.js +0 -22
  218. package/dist/packages/components/src/bubble-item/bubble-item.vue.js +0 -7
  219. package/dist/packages/components/src/bubble-item/bubble-item.vue2.js +0 -111
  220. package/dist/packages/components/src/bubble-item/components/actions/copy.vue.js +0 -46
  221. package/dist/packages/components/src/bubble-item/components/actions/copy.vue2.js +0 -4
  222. package/dist/packages/components/src/bubble-item/components/actions/refresh.vue.js +0 -12
  223. package/dist/packages/components/src/bubble-item/components/icons/ai.vue.js +0 -45
  224. package/dist/packages/components/src/bubble-item/components/icons/user.vue.js +0 -63
  225. package/dist/packages/components/src/bubble-item/index.js +0 -9
  226. package/dist/packages/components/src/bubble-list/bubble-list.vue2.js +0 -52
  227. package/dist/packages/components/src/bubble-list/index.js +0 -9
  228. package/src/bubble-item/bubble-item.vue +0 -264
  229. package/src/bubble-item/components/actions/copy.vue +0 -47
  230. package/src/bubble-item/components/actions/refresh.vue +0 -27
  231. package/src/bubble-item/components/icons/ai.vue +0 -30
  232. package/src/bubble-item/components/icons/index.ts +0 -2
  233. package/src/bubble-item/components/icons/user.vue +0 -78
  234. package/src/bubble-item/index.ts +0 -12
  235. package/src/bubble-list/bubble-list.vue +0 -53
  236. package/src/bubble-list/index.ts +0 -14
  237. package/src/bubble-list/index.type.ts +0 -65
  238. package/src/sender/global.d.ts +0 -44
  239. /package/dist/{bubble-list → bubble}/bubble-list.vue.d.ts +0 -0
  240. /package/dist/{bubble-item → bubble}/components/actions/index.d.ts +0 -0
  241. /package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/button/vue.js +0 -0
  242. /package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/chunk-G2ADBYYC.js +0 -0
  243. /package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tall-storage/vue-storage-box.js +0 -0
  244. /package/src/{bubble-item → bubble}/components/actions/index.ts +0 -0
@@ -0,0 +1,135 @@
1
+ <script setup lang="ts">
2
+ import { IconCancelFullScreen, IconClose, IconFullScreen } from '@opentiny/tiny-robot-svgs'
3
+ import { computed } from 'vue'
4
+ import { ContainerProps, ContainerSlots } from './index.type'
5
+
6
+ const show = defineModel<ContainerProps['show']>('show', { required: true })
7
+ const fullscreen = defineModel<ContainerProps['fullscreen']>('fullscreen')
8
+
9
+ defineSlots<ContainerSlots>()
10
+
11
+ const IconFullScreenSwitcher = computed(() => (fullscreen.value ? IconCancelFullScreen : IconFullScreen))
12
+ </script>
13
+
14
+ <template>
15
+ <div class="tr-container">
16
+ <div class="tr-container__dragging-bar-wrapper">
17
+ <div class="tr-container__dragging-bar"></div>
18
+ </div>
19
+ <div class="tr-container__header">
20
+ <slot name="title">
21
+ <h3 class="tr-container__title">OpenTiny NEXT</h3>
22
+ </slot>
23
+ <div class="tr-container__header-operations">
24
+ <slot name="operations"></slot>
25
+ <button class="icon-btn" @click="$emit('update:fullscreen', !fullscreen)">
26
+ <IconFullScreenSwitcher />
27
+ </button>
28
+ <button class="icon-btn" @click="$emit('update:show', false)">
29
+ <IconClose />
30
+ </button>
31
+ </div>
32
+ </div>
33
+ <div class="tr-container__body">
34
+ <slot></slot>
35
+ </div>
36
+ <div class="tr-container__footer">
37
+ <slot name="footer"></slot>
38
+ </div>
39
+ </div>
40
+ </template>
41
+
42
+ <style lang="less" scoped>
43
+ .tr-container {
44
+ --tr-container-width: 480px;
45
+
46
+ background-color: rgb(248, 248, 248);
47
+ border: 1px solid rgba(0, 0, 0, 0.08);
48
+ position: fixed;
49
+ top: 0;
50
+ bottom: 0;
51
+ right: 0;
52
+ left: v-bind('fullscreen? "0" : "unset"');
53
+ width: v-bind('fullscreen? "unset" : "var(--tr-container-width)"');
54
+ z-index: v-bind('show? "100":"-1"');
55
+ opacity: v-bind('show? "1":"0"');
56
+ display: flex;
57
+ flex-direction: column;
58
+
59
+ .tr-container__dragging-bar-wrapper {
60
+ flex-shrink: 0;
61
+
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ padding: 6px;
66
+
67
+ // TODO 拖拽条的逻辑
68
+ .tr-container__dragging-bar {
69
+ width: 40px;
70
+ height: 4px;
71
+ background-color: rgb(217, 217, 217);
72
+ border-radius: 999px;
73
+ cursor: grab;
74
+ }
75
+ }
76
+
77
+ .tr-container__header {
78
+ flex-shrink: 0;
79
+
80
+ display: flex;
81
+ align-items: center;
82
+ justify-content: space-between;
83
+ padding: 4px 24px;
84
+ }
85
+
86
+ .tr-container__title {
87
+ margin: 0;
88
+ padding: 0;
89
+ color: rgb(25, 25, 25);
90
+ font-weight: 600;
91
+ font-size: 14px;
92
+ line-height: 22px;
93
+ }
94
+
95
+ .tr-container__header-operations {
96
+ display: flex;
97
+ gap: 8px;
98
+
99
+ button.icon-btn {
100
+ width: 28px;
101
+ height: 28px;
102
+ display: inline-flex;
103
+ align-items: center;
104
+ justify-content: center;
105
+ border: none;
106
+ border-radius: 8px;
107
+ cursor: pointer;
108
+ padding: 0;
109
+ transition: background-color 0.3s;
110
+
111
+ &:hover {
112
+ background-color: rgba(0, 0, 0, 0.04);
113
+ }
114
+
115
+ &:active {
116
+ background-color: rgba(0, 0, 0, 0.15);
117
+ }
118
+
119
+ svg {
120
+ width: 20px;
121
+ height: 20px;
122
+ }
123
+ }
124
+ }
125
+
126
+ .tr-container__body {
127
+ flex: 1;
128
+ overflow-y: auto;
129
+ }
130
+
131
+ .tr-container__footer {
132
+ flex-shrink: 0;
133
+ }
134
+ }
135
+ </style>
@@ -1,7 +1,7 @@
1
1
  import { App } from 'vue'
2
2
  import Conversations from './index.vue'
3
3
 
4
- Conversations.name = 'TrConversations'
4
+ Conversations.name = 'Conversations'
5
5
 
6
6
  const install = function <T>(app: App<T>) {
7
7
  app.component(Conversations.name!, Conversations)
package/src/index.ts CHANGED
@@ -1,30 +1,44 @@
1
1
  import { App } from 'vue'
2
- import Welcome from './welcome'
2
+ import { Bubble, BubbleList } from './bubble'
3
+ import Container from './container'
3
4
  import Conversations from './conversations'
4
- import BubbleItem from './bubble-item'
5
- import BubbleList from './bubble-list'
5
+ import { Prompt, Prompts } from './prompts'
6
+ import Question from './question'
6
7
  import Sender from './sender'
8
+ import Welcome from './welcome'
7
9
 
8
- export * from './bubble-list/index.type'
10
+ export * from './bubble/index.type'
11
+ export * from './prompts/index.type'
12
+ export * from './sender/index.type'
13
+ export * from './welcome/index.type'
9
14
 
10
- const components = [Welcome, Conversations, BubbleItem, BubbleList, Sender]
15
+ const components = [Bubble, BubbleList, Container, Conversations, Prompt, Prompts, Question, Sender, Welcome]
11
16
 
12
17
  export default {
13
18
  install<T>(app: App<T>) {
14
19
  components.forEach((component) => {
15
- const name = component.name?.replace(/^Tiny/, '').replace(/^Tr/, '')
20
+ const name = component.name!.replace(/^Tiny/, '').replace(/^Tr/, '')
16
21
  app.component(`Tr${name}`, component)
17
- app.component(`Tiny${name}`, component)
18
22
  })
19
23
  },
20
24
  }
21
25
 
22
26
  export {
23
- Welcome as TrWelcome,
24
- Conversations as TrConversations,
25
- BubbleItem as TrBubbleItem,
26
- BubbleItem as TinyBubbleItem,
27
+ Bubble,
28
+ Bubble as TrBubble,
29
+ BubbleList,
27
30
  BubbleList as TrBubbleList,
28
- BubbleList as TinyBubbleList,
31
+ Container,
32
+ Container as TrContainer,
33
+ Conversations,
34
+ Conversations as TrConversations,
35
+ Prompt,
36
+ Prompt as TrPrompt,
37
+ Prompts,
38
+ Prompts as TrPrompts,
39
+ Sender,
29
40
  Sender as TrSender,
41
+ Welcome,
42
+ Welcome as TrWelcome,
43
+ Question,
30
44
  }
@@ -0,0 +1,25 @@
1
+ import { App } from 'vue'
2
+ import PromptComp from './prompt.vue'
3
+ import PromptsComp from './prompts.vue'
4
+
5
+ // TrPrompt
6
+ PromptComp.name = 'TrPrompt'
7
+
8
+ const installPrompt = function <T>(app: App<T>) {
9
+ app.component(PromptComp.name!, PromptComp)
10
+ }
11
+
12
+ PromptComp.install = installPrompt
13
+
14
+ export const Prompt = PromptComp as typeof PromptComp & { install: typeof installPrompt }
15
+
16
+ // TrPrompts
17
+ PromptsComp.name = 'TrPrompts'
18
+
19
+ const installPrompts = function <T>(app: App<T>) {
20
+ app.component(PromptsComp.name!, PromptsComp)
21
+ }
22
+
23
+ PromptsComp.install = installPrompts
24
+
25
+ export const Prompts = PromptsComp as typeof PromptsComp & { install: typeof installPrompts }
@@ -0,0 +1,59 @@
1
+ import { CSSProperties, VNode } from 'vue'
2
+
3
+ export interface PromptProps {
4
+ /**
5
+ * 提示标签,显示提示的主要内容
6
+ */
7
+ label: string
8
+ /**
9
+ * 唯一标识用于区分每个提示项,用于 Prompts 列表。如果不传此参数,则使用 index 作为 key
10
+ */
11
+ id?: string
12
+ /**
13
+ * 提示描述,提供额外的信息
14
+ */
15
+ description?: string
16
+ /**
17
+ * 提示图标,显示在提示项的左侧
18
+ */
19
+ icon?: VNode
20
+ /**
21
+ * 是否禁用。默认 false
22
+ */
23
+ disabled?: boolean
24
+ /**
25
+ * 提示徽章,显示在提示项的右上角
26
+ */
27
+ badge?: string | VNode
28
+ }
29
+
30
+ export interface PromptsProps {
31
+ /**
32
+ * 包含多个提示项的列表
33
+ */
34
+ items: PromptProps[]
35
+ /**
36
+ * 自定义样式,用于各个提示项的不同部分
37
+ */
38
+ itemStyle?: string | CSSProperties
39
+ /**
40
+ * 自定义类名,用于各个提示项的不同部分
41
+ */
42
+ itemClass?: string | string[]
43
+ /**
44
+ * 提示列表是否垂直排列。默认 false
45
+ */
46
+ vertical?: boolean
47
+ /**
48
+ * 提示列表是否折行。默认 false
49
+ */
50
+ wrap?: boolean
51
+ }
52
+
53
+ export interface PromptsEvents {
54
+ (e: 'item-click', ev: MouseEvent, item: PromptProps): void
55
+ }
56
+
57
+ export interface PromptsSlots {
58
+ footer?: () => unknown
59
+ }
@@ -0,0 +1,115 @@
1
+ <script setup lang="ts">
2
+ import { computed, defineComponent, VNode } from 'vue'
3
+ import { PromptProps } from './index.type'
4
+
5
+ const props = defineProps<PromptProps>()
6
+
7
+ const vnodeToComponent = (vnode?: VNode | string) => {
8
+ if (!vnode) {
9
+ return null
10
+ }
11
+
12
+ return defineComponent(() => {
13
+ return () => vnode
14
+ })
15
+ }
16
+
17
+ const iconComp = computed(() => {
18
+ return vnodeToComponent(props.icon)
19
+ })
20
+
21
+ const badgeComp = computed(() => {
22
+ return vnodeToComponent(props.badge)
23
+ })
24
+ </script>
25
+
26
+ <template>
27
+ <div :class="['tr-prompt', { disabled: props.disabled }]">
28
+ <div class="tr-prompt__icon">
29
+ <component :is="iconComp"></component>
30
+ </div>
31
+ <div class="tr-prompt__content">
32
+ <h6 class="tr-prompt__content-label">{{ props.label }}</h6>
33
+ <p v-if="props.description" class="tr-prompt__content-description">{{ props.description }}</p>
34
+ </div>
35
+ <div :class="['tr-prompt__badge', { label: typeof props.badge === 'string' }]">
36
+ <component :is="badgeComp"></component>
37
+ </div>
38
+ </div>
39
+ </template>
40
+
41
+ <style lang="less" scoped>
42
+ .tr-prompt {
43
+ --tr-prompt-bg-color: white;
44
+ --tr-prompt-hover-color: rgba(0, 0, 0, 0.04);
45
+ --tr-prompt-active-color: rgba(0, 0, 0, 0.15);
46
+ --tr-prompt-disabled-color: rgba(0, 0, 0, 0.04);
47
+ --tr-prompt-box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
48
+ --tr-prompt-text: rgb(25, 25, 25);
49
+ --tr-prompt-text-muted: rgb(89, 89, 89);
50
+
51
+ flex: none;
52
+ display: flex;
53
+ gap: 12px;
54
+ border-radius: 16px;
55
+ box-shadow: var(--tr-prompt-box-shadow);
56
+ padding: 16px 24px;
57
+ position: relative;
58
+ cursor: pointer;
59
+ transition: background 0.3s;
60
+ background-color: var(--tr-prompt-bg-color);
61
+
62
+ &:hover {
63
+ background-color: var(--tr-prompt-hover-color);
64
+ }
65
+
66
+ &.disabled {
67
+ cursor: default;
68
+ pointer-events: none;
69
+ background-color: var(--tr-prompt-disabled-color);
70
+ }
71
+
72
+ &:active {
73
+ background-color: var(--tr-prompt-active-color);
74
+ }
75
+ }
76
+
77
+ .tr-prompt__content {
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: 4px;
81
+ align-items: start;
82
+
83
+ font-size: 14px;
84
+ line-height: 24px;
85
+ color: var(--tr-prompt-text);
86
+ }
87
+
88
+ .tr-prompt__content-label {
89
+ margin: 0;
90
+ padding: 0;
91
+ font-weight: 500;
92
+ }
93
+
94
+ .tr-prompt__content-description {
95
+ margin: 0;
96
+ padding: 0;
97
+ color: var(--tr-prompt-text-muted);
98
+ }
99
+
100
+ .tr-prompt__badge {
101
+ position: absolute;
102
+ top: 0;
103
+ right: 0;
104
+ padding: 0 12px;
105
+ border-top-right-radius: 16px;
106
+ border-bottom-left-radius: 16px;
107
+ background-color: rgb(255, 234, 232);
108
+
109
+ &.label {
110
+ color: rgb(242, 48, 48);
111
+ font-size: 14px;
112
+ line-height: 22px;
113
+ }
114
+ }
115
+ </style>
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ import { toRaw } from 'vue'
3
+ import { PromptProps, PromptsEvents, PromptsProps, PromptsSlots } from './index.type'
4
+ import Prompt from './prompt.vue'
5
+
6
+ const props = defineProps<PromptsProps>()
7
+
8
+ const emit = defineEmits<PromptsEvents>()
9
+
10
+ defineSlots<PromptsSlots>()
11
+
12
+ const handleClick = (ev: MouseEvent, item: PromptProps) => {
13
+ emit('item-click', ev, toRaw(item))
14
+ }
15
+ </script>
16
+
17
+ <template>
18
+ <div class="tr-prompts">
19
+ <div :class="['tr-prompts__list-container', { wrap: props.wrap, vertical: props.vertical }]">
20
+ <Prompt
21
+ v-for="(item, index) in props.items"
22
+ :key="item.id || index"
23
+ v-bind="item"
24
+ :style="props.itemStyle"
25
+ :class="props.itemClass"
26
+ @click="handleClick($event, item)"
27
+ ></Prompt>
28
+ </div>
29
+ <slot name="footer"></slot>
30
+ </div>
31
+ </template>
32
+
33
+ <style lang="less" scoped>
34
+ .tr-prompts {
35
+ .tr-prompts__list-container {
36
+ display: flex;
37
+ gap: 16px;
38
+ overflow-x: auto;
39
+
40
+ &.wrap {
41
+ flex-wrap: wrap;
42
+ }
43
+
44
+ &.vertical {
45
+ flex-direction: column;
46
+ align-items: flex-start;
47
+ }
48
+ }
49
+ }
50
+ </style>
@@ -0,0 +1,146 @@
1
+ <script setup lang="ts">
2
+ import { ref, watch, onMounted, onBeforeUnmount, nextTick, PropType } from 'vue'
3
+ import type { Question } from '../index.type'
4
+ import { IconEdit } from '@opentiny/tiny-robot-svgs'
5
+
6
+ const props = defineProps({
7
+ questions: {
8
+ type: Array as PropType<Question[]>,
9
+ required: true,
10
+ },
11
+ isExpanded: {
12
+ type: Boolean,
13
+ default: false,
14
+ },
15
+ })
16
+
17
+ const emit = defineEmits(['question-click', 'show-expand-button'])
18
+
19
+ const commonQuestionsRef = ref<HTMLElement | null>(null)
20
+ const showExpandButton = ref(false)
21
+ const isExpandedRef = ref(false)
22
+ const visibleQuestions = ref<Question[]>([])
23
+ const hiddenQuestions = ref<Question[]>([])
24
+
25
+ watch(
26
+ () => props.isExpanded,
27
+ (val) => {
28
+ isExpandedRef.value = val
29
+ },
30
+ )
31
+
32
+ // 检查是否需要显示展开/收起按钮并计算能够容纳的最大胶囊数
33
+ const checkOverflow = async () => {
34
+ await nextTick()
35
+ if (commonQuestionsRef.value) {
36
+ const container = commonQuestionsRef.value
37
+ const containerWidth = container.clientWidth
38
+
39
+ // 重置胶囊分组
40
+ visibleQuestions.value = []
41
+ hiddenQuestions.value = []
42
+
43
+ if (props.questions.length === 0) {
44
+ showExpandButton.value = false
45
+ return
46
+ }
47
+
48
+ // 计算一行可以容纳多少个胶囊
49
+ let accumulatedWidth = 0
50
+ const margin = 8 // 胶囊之间的间距
51
+
52
+ // 克隆一个胶囊元素来测量其基本尺寸
53
+ const tempItem = document.createElement('div')
54
+ tempItem.className = 'tr-common-questions_item'
55
+ tempItem.style.visibility = 'hidden'
56
+ tempItem.style.position = 'absolute'
57
+ container.appendChild(tempItem)
58
+
59
+ // 计算每个胶囊的宽度并确定一行能容纳多少个
60
+ for (let i = 0; i < props.questions.length; i++) {
61
+ const question = props.questions[i]
62
+
63
+ // 设置临时元素内容来测量其宽度
64
+ tempItem.textContent = question.text
65
+ const itemWidth = tempItem.offsetWidth + margin
66
+
67
+ // 检查是否还能容纳下一个胶囊
68
+ if (accumulatedWidth + itemWidth <= containerWidth) {
69
+ accumulatedWidth += itemWidth
70
+ visibleQuestions.value.push(question)
71
+ } else {
72
+ hiddenQuestions.value.push(question)
73
+ }
74
+ }
75
+
76
+ // 移除临时元素
77
+ container.removeChild(tempItem)
78
+
79
+ // 如果有隐藏的胶囊,显示展开按钮
80
+ showExpandButton.value = hiddenQuestions.value.length > 0
81
+ // 初始状态设为未展开
82
+ isExpandedRef.value = false
83
+
84
+ emit('show-expand-button', showExpandButton.value)
85
+ }
86
+ }
87
+
88
+ // 处理问题点击
89
+ const handleQuestionClick = (question: Question) => {
90
+ emit('question-click', question)
91
+ }
92
+
93
+ // 监听 props 变化
94
+ watch(
95
+ () => props.questions,
96
+ () => {
97
+ // 当问题列表变化时重新计算
98
+ checkOverflow()
99
+ },
100
+ { deep: true },
101
+ )
102
+
103
+ // 处理窗口大小变化
104
+ const handleResize = () => {
105
+ checkOverflow()
106
+ }
107
+
108
+ // 组件挂载时添加窗口大小变化监听
109
+ onMounted(() => {
110
+ checkOverflow()
111
+ window.addEventListener('resize', handleResize)
112
+ })
113
+
114
+ // 组件卸载时移除监听器
115
+ onBeforeUnmount(() => {
116
+ window.removeEventListener('resize', handleResize)
117
+ })
118
+ </script>
119
+
120
+ <template>
121
+ <div class="tr-common-questions" ref="commonQuestionsRef" :class="{ expanded: isExpandedRef }">
122
+ <!-- 渲染可见的胶囊 -->
123
+ <div
124
+ v-for="(question, index) in visibleQuestions"
125
+ :key="`visible-${question.id}-${index}`"
126
+ class="tr-common-questions_item"
127
+ @click="handleQuestionClick(question)"
128
+ >
129
+ <div style="display: flex; align-items: center"><IconEdit /></div>
130
+ {{ question.text }}
131
+ </div>
132
+
133
+ <!-- 渲染被隐藏的胶囊(展开时显示) -->
134
+ <div v-if="isExpandedRef">
135
+ <div
136
+ v-for="(question, index) in hiddenQuestions"
137
+ :key="`hidden-${question.id}-${index}`"
138
+ class="tr-common-questions_item"
139
+ @click="handleQuestionClick(question)"
140
+ >
141
+ <IconEdit />
142
+ {{ question.text }}
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </template>