@antdv-next/x 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/actions/Actions.js +1 -1
  2. package/dist/actions/ActionsAudio.js +1 -1
  3. package/dist/actions/ActionsCopy.js +1 -1
  4. package/dist/actions/ActionsFeedback.js +1 -1
  5. package/dist/actions/ActionsItem.js +1 -1
  6. package/dist/attachments/index.js +1 -1
  7. package/dist/bubble/Bubble.js +1 -1
  8. package/dist/bubble/BubbleList.js +1 -1
  9. package/dist/bubble/Divider.js +1 -1
  10. package/dist/bubble/System.js +1 -1
  11. package/dist/code-highlighter/CodeHighlighter.js +3 -14
  12. package/dist/code-highlighter/shiki.d.ts +4 -0
  13. package/dist/code-highlighter/shiki.js +72 -0
  14. package/dist/conversations/Creation.js +1 -1
  15. package/dist/conversations/index.js +1 -1
  16. package/dist/file-card/FileCard.js +1 -1
  17. package/dist/file-card/List.js +1 -1
  18. package/dist/index.esm.js +1224 -118
  19. package/dist/index.js +0 -25
  20. package/dist/index.umd.js +1228 -121
  21. package/dist/mermaid/Mermaid.d.ts +1 -1
  22. package/dist/mermaid/Mermaid.js +5 -5
  23. package/dist/mermaid/loader.d.ts +6 -0
  24. package/dist/mermaid/loader.js +33 -0
  25. package/dist/mermaid/mermaid-core.d.js +0 -0
  26. package/dist/package.js +1 -1
  27. package/dist/prompts/Prompts.js +6 -4
  28. package/dist/sender/Sender.d.ts +25 -7
  29. package/dist/sender/Sender.js +60 -14
  30. package/dist/sender/SenderHeader.js +1 -1
  31. package/dist/sender/SenderSwitch.js +2 -2
  32. package/dist/sender/components/ActionButton.d.ts +0 -9
  33. package/dist/sender/components/ActionButton.js +1 -5
  34. package/dist/sender/components/Skill.d.ts +30 -0
  35. package/dist/sender/components/Skill.js +61 -0
  36. package/dist/sender/components/SlotTextArea.d.ts +20 -0
  37. package/dist/sender/components/SlotTextArea.js +747 -0
  38. package/dist/sender/components/TextArea.d.ts +1 -3
  39. package/dist/sender/context.d.ts +1 -0
  40. package/dist/sender/index.d.ts +2 -2
  41. package/dist/sender/interface.d.ts +2 -1
  42. package/dist/sender/style/index.d.ts +7 -0
  43. package/dist/sender/style/index.js +17 -1
  44. package/dist/sender/style/slot-textarea.d.ts +4 -0
  45. package/dist/sender/style/slot-textarea.js +187 -0
  46. package/dist/sources/Sources.js +1 -1
  47. package/dist/suggestion/Suggestion.js +1 -1
  48. package/dist/suggestion/useActive.js +4 -0
  49. package/dist/think/Think.js +1 -1
  50. package/dist/thought-chain/Item.js +1 -1
  51. package/dist/thought-chain/ThoughtChain.js +1 -1
  52. package/dist/welcome/index.js +1 -1
  53. package/dist/x-provider/index.js +1 -1
  54. package/global.d.ts +61 -18
  55. package/package.json +2 -2
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("antdv-next/dist/config-provider/context"), require("antdv-next"), require("@antdv-next/icons"), require("@antdv-next/cssinjs"), require("@antdv-next/cssinjs/cssinjs-utils"), require("@ant-design/fast-color"), require("antdv-next/dist/theme/useToken"), require("@vueuse/core"), require("@v-c/util"), require("mermaid")) : typeof define === "function" && define.amd ? define([
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("antdv-next/dist/config-provider/context"), require("antdv-next"), require("@antdv-next/icons"), require("@antdv-next/cssinjs"), require("@antdv-next/cssinjs/cssinjs-utils"), require("@ant-design/fast-color"), require("antdv-next/dist/theme/useToken"), require("@vueuse/core"), require("shiki/core"), require("shiki/dist/themes/vitesse-dark.mjs"), require("shiki/dist/themes/vitesse-light.mjs"), require("shiki/engine/javascript"), require("@v-c/util")) : typeof define === "function" && define.amd ? define([
3
3
  "exports",
4
4
  "vue",
5
5
  "antdv-next/dist/config-provider/context",
@@ -10,10 +10,13 @@
10
10
  "@ant-design/fast-color",
11
11
  "antdv-next/dist/theme/useToken",
12
12
  "@vueuse/core",
13
- "@v-c/util",
14
- "mermaid"
15
- ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.AntdComponents = {}, global.Vue, global.antdv_next_dist_config_provider_context, global.antd, global.AntdIcons, global._antdv_next_cssinjs, global._antdv_next_cssinjs_cssinjs_utils, global._ant_design_fast_color, global.antdv_next_dist_theme_useToken, global._vueuse_core, global._v_c_util, global.mermaid));
16
- })(this, function(exports, vue, antdv_next_dist_config_provider_context, antdv_next, _antdv_next_icons, _antdv_next_cssinjs, _antdv_next_cssinjs_cssinjs_utils, _ant_design_fast_color, antdv_next_dist_theme_useToken, _vueuse_core, _v_c_util, mermaid) {
13
+ "shiki/core",
14
+ "shiki/dist/themes/vitesse-dark.mjs",
15
+ "shiki/dist/themes/vitesse-light.mjs",
16
+ "shiki/engine/javascript",
17
+ "@v-c/util"
18
+ ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.AntdComponents = {}, global.Vue, global.antdv_next_dist_config_provider_context, global.antd, global.AntdIcons, global._antdv_next_cssinjs, global._antdv_next_cssinjs_cssinjs_utils, global._ant_design_fast_color, global.antdv_next_dist_theme_useToken, global._vueuse_core, global.shiki_core, global.shiki_dist_themes_vitesse_dark_mjs, global.shiki_dist_themes_vitesse_light_mjs, global.shiki_engine_javascript, global._v_c_util));
19
+ })(this, function(exports, vue, antdv_next_dist_config_provider_context, antdv_next, _antdv_next_icons, _antdv_next_cssinjs, _antdv_next_cssinjs_cssinjs_utils, _ant_design_fast_color, antdv_next_dist_theme_useToken, _vueuse_core, shiki_core, shiki_dist_themes_vitesse_dark_mjs, shiki_dist_themes_vitesse_light_mjs, shiki_engine_javascript, _v_c_util) {
17
20
  Object.defineProperties(exports, {
18
21
  __esModule: { value: true },
19
22
  [Symbol.toStringTag]: { value: "Module" }
@@ -42,9 +45,10 @@
42
45
  //#endregion
43
46
  _antdv_next_icons = __toESM(_antdv_next_icons);
44
47
  antdv_next_dist_theme_useToken = __toESM(antdv_next_dist_theme_useToken);
45
- mermaid = __toESM(mermaid);
48
+ shiki_dist_themes_vitesse_dark_mjs = __toESM(shiki_dist_themes_vitesse_dark_mjs);
49
+ shiki_dist_themes_vitesse_light_mjs = __toESM(shiki_dist_themes_vitesse_light_mjs);
46
50
  //#region package.json
47
- var version = "0.0.3";
51
+ var version = "0.1.0";
48
52
  //#endregion
49
53
  //#region components/x-provider/context.ts
50
54
  var XProviderContextKey = Symbol("antdv-next-x-provider-context");
@@ -523,7 +527,7 @@
523
527
  }, prepareComponentToken$13);
524
528
  //#endregion
525
529
  //#region components/actions/Actions.tsx
526
- function _isSlot$6(s) {
530
+ function _isSlot$7(s) {
527
531
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
528
532
  }
529
533
  function getMotionTransitionProps(motionName) {
@@ -539,7 +543,7 @@
539
543
  };
540
544
  }
541
545
  var XActions = /* @__PURE__ */ (0, vue.defineComponent)({
542
- name: "XActions",
546
+ name: "AxActions",
543
547
  inheritAttrs: false,
544
548
  props: {
545
549
  items: {
@@ -683,7 +687,7 @@
683
687
  attrs.style,
684
688
  props.style
685
689
  ]
686
- }), [transitionProps.value ? (0, vue.createVNode)(vue.Transition, transitionProps.value, _isSlot$6(_slot = renderList()) ? _slot : { default: () => [_slot] }) : renderList()]);
690
+ }), [transitionProps.value ? (0, vue.createVNode)(vue.Transition, transitionProps.value, _isSlot$7(_slot = renderList()) ? _slot : { default: () => [_slot] }) : renderList()]);
687
691
  };
688
692
  }
689
693
  });
@@ -697,7 +701,7 @@
697
701
  return ACTIONS_ITEM_STATUS;
698
702
  }({});
699
703
  var XActionsItem = /* @__PURE__ */ (0, vue.defineComponent)({
700
- name: "XActionsItem",
704
+ name: "AxActionsItem",
701
705
  inheritAttrs: false,
702
706
  props: {
703
707
  status: {
@@ -807,7 +811,7 @@
807
811
  //#endregion
808
812
  //#region components/actions/ActionsAudio.tsx
809
813
  var XActionsAudio = /* @__PURE__ */ (0, vue.defineComponent)({
810
- name: "XActionsAudio",
814
+ name: "AxActionsAudio",
811
815
  props: {
812
816
  status: {
813
817
  type: String,
@@ -881,7 +885,7 @@
881
885
  return [icon, icon];
882
886
  };
883
887
  var XActionsCopy = /* @__PURE__ */ (0, vue.defineComponent)({
884
- name: "XActionsCopy",
888
+ name: "AxActionsCopy",
885
889
  inheritAttrs: false,
886
890
  props: {
887
891
  text: {
@@ -986,7 +990,7 @@
986
990
  return FEEDBACK_VALUE;
987
991
  }(FEEDBACK_VALUE || {});
988
992
  var XActionsFeedback = /* @__PURE__ */ (0, vue.defineComponent)({
989
- name: "XActionsFeedback",
993
+ name: "AxActionsFeedback",
990
994
  inheritAttrs: false,
991
995
  props: {
992
996
  value: {
@@ -1964,7 +1968,7 @@
1964
1968
  key: "default"
1965
1969
  };
1966
1970
  var XFileCard = /* @__PURE__ */ (0, vue.defineComponent)({
1967
- name: "XFileCard",
1971
+ name: "AxFileCard",
1968
1972
  inheritAttrs: false,
1969
1973
  props: {
1970
1974
  prefixCls: {
@@ -2199,11 +2203,11 @@
2199
2203
  });
2200
2204
  //#endregion
2201
2205
  //#region components/file-card/List.tsx
2202
- function _isSlot$5(s) {
2206
+ function _isSlot$6(s) {
2203
2207
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
2204
2208
  }
2205
2209
  var XFileCardList = /* @__PURE__ */ (0, vue.defineComponent)({
2206
- name: "XFileCardList",
2210
+ name: "AxFileCardList",
2207
2211
  props: {
2208
2212
  prefixCls: {
2209
2213
  type: String,
@@ -2367,7 +2371,7 @@
2367
2371
  "style": [props.style, splitStyles.value.root],
2368
2372
  "onScroll": checkPing
2369
2373
  }, [
2370
- (0, vue.createVNode)(vue.TransitionGroup, { "name": `${compCls.value}-motion` }, _isSlot$5(_slot = list.value.map((item, itemIndex) => {
2374
+ (0, vue.createVNode)(vue.TransitionGroup, { "name": `${compCls.value}-motion` }, _isSlot$6(_slot = list.value.map((item, itemIndex) => {
2371
2375
  const { __key, ...fileItem } = item;
2372
2376
  const cardSlots = {
2373
2377
  description: slots.description ? (slotInfo) => slots.description?.({
@@ -2694,7 +2698,7 @@
2694
2698
  });
2695
2699
  //#endregion
2696
2700
  //#region components/attachments/PlaceholderUploader.tsx
2697
- function _isSlot$4(s) {
2701
+ function _isSlot$5(s) {
2698
2702
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
2699
2703
  }
2700
2704
  var PlaceholderUploader = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -2789,7 +2793,7 @@
2789
2793
  border: 0,
2790
2794
  background: "transparent"
2791
2795
  }
2792
- }), _isSlot$4(node) ? node : { default: () => [node] })]);
2796
+ }), _isSlot$5(node) ? node : { default: () => [node] })]);
2793
2797
  };
2794
2798
  }
2795
2799
  });
@@ -2906,11 +2910,11 @@
2906
2910
  }, prepareComponentToken$11);
2907
2911
  //#endregion
2908
2912
  //#region components/attachments/index.tsx
2909
- function _isSlot$3(s) {
2913
+ function _isSlot$4(s) {
2910
2914
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
2911
2915
  }
2912
2916
  var XAttachments = /* @__PURE__ */ (0, vue.defineComponent)({
2913
- name: "XAttachments",
2917
+ name: "AxAttachments",
2914
2918
  inheritAttrs: false,
2915
2919
  props: {
2916
2920
  prefixCls: {
@@ -3132,7 +3136,7 @@
3132
3136
  props.rootClass,
3133
3137
  mergedClasses.value.root
3134
3138
  ]
3135
- }, _isSlot$3(_slot = getPlaceholderNode("drop")) ? _slot : { default: () => [_slot] })]);
3139
+ }, _isSlot$4(_slot = getPlaceholderNode("drop")) ? _slot : { default: () => [_slot] })]);
3136
3140
  };
3137
3141
  const renderNormalMode = () => {
3138
3142
  let _slot2;
@@ -3171,7 +3175,7 @@
3171
3175
  "getDropContainer": props.getDropContainer || (() => containerRef.value),
3172
3176
  "prefixCls": props.prefixCls,
3173
3177
  "class": [hashId.value, cssVarCls.value]
3174
- }, _isSlot$3(_slot2 = getPlaceholderNode("drop")) ? _slot2 : { default: () => [_slot2] })
3178
+ }, _isSlot$4(_slot2 = getPlaceholderNode("drop")) ? _slot2 : { default: () => [_slot2] })
3175
3179
  ]);
3176
3180
  };
3177
3181
  return () => slots.default ? renderWithChildren() : renderNormalMode();
@@ -3854,7 +3858,7 @@
3854
3858
  return node !== null && node !== void 0 && node !== false;
3855
3859
  }
3856
3860
  var XBubble = /* @__PURE__ */ (0, vue.defineComponent)({
3857
- name: "XBubble",
3861
+ name: "AxBubble",
3858
3862
  inheritAttrs: false,
3859
3863
  props: {
3860
3864
  prefixCls: {
@@ -4191,11 +4195,11 @@
4191
4195
  });
4192
4196
  //#endregion
4193
4197
  //#region components/bubble/Divider.tsx
4194
- function _isSlot$2(s) {
4198
+ function _isSlot$3(s) {
4195
4199
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
4196
4200
  }
4197
4201
  var XBubbleDivider = /* @__PURE__ */ (0, vue.defineComponent)({
4198
- name: "XBubbleDivider",
4202
+ name: "AxBubbleDivider",
4199
4203
  props: {
4200
4204
  prefixCls: {
4201
4205
  type: String,
@@ -4257,7 +4261,7 @@
4257
4261
  "class": [`${props.prefixCls}-divider`, props.class],
4258
4262
  "styles": props.styles,
4259
4263
  "classes": props.classes
4260
- }), { contentRender: ({ content }) => (0, vue.createVNode)(antdv_next.Divider, props.dividerProps, _isSlot$2(content) ? content : { default: () => [content] }) });
4264
+ }), { contentRender: ({ content }) => (0, vue.createVNode)(antdv_next.Divider, props.dividerProps, _isSlot$3(content) ? content : { default: () => [content] }) });
4261
4265
  }
4262
4266
  });
4263
4267
  //#endregion
@@ -4385,7 +4389,7 @@
4385
4389
  //#endregion
4386
4390
  //#region components/bubble/System.tsx
4387
4391
  var XBubbleSystem = /* @__PURE__ */ (0, vue.defineComponent)({
4388
- name: "XBubbleSystem",
4392
+ name: "AxBubbleSystem",
4389
4393
  props: {
4390
4394
  prefixCls: {
4391
4395
  type: String,
@@ -4474,7 +4478,7 @@
4474
4478
  "extra"
4475
4479
  ];
4476
4480
  var XBubbleList = /* @__PURE__ */ (0, vue.defineComponent)({
4477
- name: "XBubbleList",
4481
+ name: "AxBubbleList",
4478
4482
  inheritAttrs: false,
4479
4483
  props: {
4480
4484
  prefixCls: {
@@ -4712,6 +4716,73 @@
4712
4716
  BubbleWithSub.System = XBubbleSystem;
4713
4717
  BubbleWithSub.Divider = XBubbleDivider;
4714
4718
  //#endregion
4719
+ //#region components/code-highlighter/shiki.ts
4720
+ var SUPPORTED_LANG_ALIASES = {
4721
+ ts: "typescript",
4722
+ js: "javascript",
4723
+ py: "python",
4724
+ md: "markdown",
4725
+ yml: "yaml",
4726
+ shell: "bash",
4727
+ zsh: "bash",
4728
+ sh: "bash",
4729
+ vue: "vue"
4730
+ };
4731
+ var LANG_LOADERS = {
4732
+ javascript: () => import("shiki/dist/langs/javascript.mjs"),
4733
+ typescript: () => import("shiki/dist/langs/typescript.mjs"),
4734
+ jsx: () => import("shiki/dist/langs/jsx.mjs"),
4735
+ tsx: () => import("shiki/dist/langs/tsx.mjs"),
4736
+ json: () => import("shiki/dist/langs/json.mjs"),
4737
+ bash: () => import("shiki/dist/langs/bash.mjs"),
4738
+ markdown: () => import("shiki/dist/langs/markdown.mjs"),
4739
+ html: () => import("shiki/dist/langs/html.mjs"),
4740
+ css: () => import("shiki/dist/langs/css.mjs"),
4741
+ vue: () => import("shiki/dist/langs/vue.mjs"),
4742
+ "vue-html": () => import("shiki/dist/langs/vue-html.mjs"),
4743
+ python: () => import("shiki/dist/langs/python.mjs"),
4744
+ mermaid: () => import("shiki/dist/langs/mermaid.mjs"),
4745
+ yaml: () => import("shiki/dist/langs/yaml.mjs"),
4746
+ diff: () => import("shiki/dist/langs/diff.mjs")
4747
+ };
4748
+ var highlighter = null;
4749
+ var highlighterPromise = null;
4750
+ var loadedLangs = /* @__PURE__ */ new Set();
4751
+ function normalizeLanguage(language) {
4752
+ const input = (language || "text").toLowerCase();
4753
+ return SUPPORTED_LANG_ALIASES[input] || input;
4754
+ }
4755
+ function escapeHtml(str) {
4756
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
4757
+ }
4758
+ async function getHighlighter() {
4759
+ if (highlighter) return highlighter;
4760
+ if (!highlighterPromise) highlighterPromise = (0, shiki_core.createHighlighterCore)({
4761
+ themes: [shiki_dist_themes_vitesse_light_mjs.default, shiki_dist_themes_vitesse_dark_mjs.default],
4762
+ langs: [],
4763
+ engine: (0, shiki_engine_javascript.createJavaScriptRegexEngine)()
4764
+ });
4765
+ highlighter = await highlighterPromise;
4766
+ return highlighter;
4767
+ }
4768
+ async function loadLang(lang) {
4769
+ const loader = LANG_LOADERS[lang];
4770
+ if (!loader || loadedLangs.has(lang)) return false;
4771
+ const instance = await getHighlighter();
4772
+ const mod = await loader();
4773
+ await instance.loadLanguage(mod.default);
4774
+ loadedLangs.add(lang);
4775
+ return true;
4776
+ }
4777
+ async function codeToHtml(code, options = {}) {
4778
+ const lang = normalizeLanguage(options.lang);
4779
+ if (!await loadLang(lang)) return `<pre><code>${escapeHtml(code)}</code></pre>`;
4780
+ return (await getHighlighter()).codeToHtml(code, {
4781
+ lang,
4782
+ theme: options.theme || "vitesse-light"
4783
+ });
4784
+ }
4785
+ //#endregion
4715
4786
  //#region components/code-highlighter/style/index.ts
4716
4787
  var genCodeHighlighterStyle = (token) => {
4717
4788
  const { componentCls } = token;
@@ -4822,21 +4893,9 @@
4822
4893
  return [genCodeHighlighterStyle((0, _antdv_next_cssinjs_cssinjs_utils.mergeToken)(token, {}))];
4823
4894
  }, prepareComponentToken$9);
4824
4895
  //#endregion
4825
- //#region components/code-highlighter/CodeHighlighter.tsx
4826
- var shikiHighlighter = null;
4827
- var shikiPromise = null;
4828
- async function initShiki() {
4829
- if (shikiHighlighter) return;
4830
- if (shikiPromise) return shikiPromise;
4831
- shikiPromise = (async () => {
4832
- shikiHighlighter = (await import("shiki")).codeToHtml;
4833
- })();
4834
- return shikiPromise;
4835
- }
4836
- //#endregion
4837
4896
  //#region components/code-highlighter/index.tsx
4838
4897
  var code_highlighter_default = /* @__PURE__ */ (0, vue.defineComponent)({
4839
- name: "XCodeHighlighter",
4898
+ name: "AxCodeHighlighter",
4840
4899
  inheritAttrs: false,
4841
4900
  props: {
4842
4901
  prefixCls: {
@@ -4917,9 +4976,7 @@
4917
4976
  const highlightedHtml = (0, vue.shallowRef)("");
4918
4977
  const highlightCode = async () => {
4919
4978
  try {
4920
- await initShiki();
4921
- if (!shikiHighlighter) return;
4922
- highlightedHtml.value = await shikiHighlighter(props.content, {
4979
+ highlightedHtml.value = await codeToHtml(props.content, {
4923
4980
  lang: props.language,
4924
4981
  theme: props.theme === "dark" ? "vitesse-dark" : "vitesse-light"
4925
4982
  });
@@ -5362,7 +5419,7 @@
5362
5419
  //#endregion
5363
5420
  //#region components/conversations/Creation.tsx
5364
5421
  var Creation = /* @__PURE__ */ (0, vue.defineComponent)({
5365
- name: "XConversationsCreation",
5422
+ name: "AxConversationsCreation",
5366
5423
  props: {
5367
5424
  label: {
5368
5425
  type: [
@@ -5579,7 +5636,7 @@
5579
5636
  }
5580
5637
  //#endregion
5581
5638
  //#region components/conversations/Item.tsx
5582
- function _isSlot$1(s) {
5639
+ function _isSlot$2(s) {
5583
5640
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
5584
5641
  }
5585
5642
  var stopPropagation = (event) => {
@@ -5720,14 +5777,14 @@
5720
5777
  }
5721
5778
  }, [
5722
5779
  hasRenderableNode$6(iconNode) && (0, vue.createVNode)("div", { "class": `${props.prefixCls}-icon` }, [iconNode]),
5723
- (0, vue.createVNode)(antdv_next.Typography.Text, { "class": `${props.prefixCls}-label` }, _isSlot$1(labelNode) ? labelNode : { default: () => [labelNode] }),
5780
+ (0, vue.createVNode)(antdv_next.Typography.Text, { "class": `${props.prefixCls}-label` }, _isSlot$2(labelNode) ? labelNode : { default: () => [labelNode] }),
5724
5781
  !disabled && props.menu && (0, vue.createVNode)("div", { "onClick": stopPropagation }, [(0, vue.createVNode)(antdv_next.Dropdown, {
5725
5782
  "menu": menuProps.value,
5726
5783
  "placement": props.direction === "rtl" ? "bottomLeft" : "bottomRight",
5727
5784
  "trigger": ["click"],
5728
5785
  "disabled": disabled,
5729
5786
  "getPopupContainer": menuProps.value?.getPopupContainer
5730
- }, _isSlot$1(_slot = renderMenuTrigger(props.info)) ? _slot : { default: () => [_slot] })])
5787
+ }, _isSlot$2(_slot = renderMenuTrigger(props.info)) ? _slot : { default: () => [_slot] })])
5731
5788
  ]);
5732
5789
  };
5733
5790
  }
@@ -5901,7 +5958,7 @@
5901
5958
  return tagName === "input" || tagName === "textarea" || tagName === "select";
5902
5959
  }
5903
5960
  var ConversationsWithSub = /* @__PURE__ */ (0, vue.defineComponent)({
5904
- name: "XConversations",
5961
+ name: "AxConversations",
5905
5962
  inheritAttrs: false,
5906
5963
  props: {
5907
5964
  items: {
@@ -6138,6 +6195,38 @@
6138
6195
  }
6139
6196
  };
6140
6197
  //#endregion
6198
+ //#region components/mermaid/loader.ts
6199
+ var mermaidInstance = null;
6200
+ var mermaidPromise = null;
6201
+ var pendingInitializeConfig = null;
6202
+ async function loadMermaid() {
6203
+ if (mermaidInstance) return mermaidInstance;
6204
+ if (!mermaidPromise) mermaidPromise = import("mermaid/dist/mermaid.core.mjs").then((mod) => mod.default).then((instance) => {
6205
+ mermaidInstance = instance;
6206
+ if (pendingInitializeConfig) {
6207
+ instance.initialize(pendingInitializeConfig);
6208
+ pendingInitializeConfig = null;
6209
+ }
6210
+ return instance;
6211
+ });
6212
+ return mermaidPromise;
6213
+ }
6214
+ function initializeMermaid(config) {
6215
+ pendingInitializeConfig = config;
6216
+ if (mermaidInstance) {
6217
+ mermaidInstance.initialize(config);
6218
+ pendingInitializeConfig = null;
6219
+ return;
6220
+ }
6221
+ loadMermaid();
6222
+ }
6223
+ async function parseMermaid(content, options) {
6224
+ return (await loadMermaid()).parse(content, options);
6225
+ }
6226
+ async function renderMermaid(id, content, container) {
6227
+ return (await loadMermaid()).render(id, content, container);
6228
+ }
6229
+ //#endregion
6141
6230
  //#region components/mermaid/style/index.ts
6142
6231
  var genMermaidStyle = (token) => {
6143
6232
  const { componentCls } = token;
@@ -6244,7 +6333,7 @@
6244
6333
  //#endregion
6245
6334
  //#region components/mermaid/index.tsx
6246
6335
  var mermaid_default = /* @__PURE__ */ (0, vue.defineComponent)({
6247
- name: "XMermaid",
6336
+ name: "AxMermaid",
6248
6337
  inheritAttrs: false,
6249
6338
  props: {
6250
6339
  content: {
@@ -6375,8 +6464,8 @@
6375
6464
  const graphEl = graphRef.value;
6376
6465
  if (!graphEl) return;
6377
6466
  try {
6378
- if (await mermaid.default.parse(props.content, { suppressErrors: true }) === false) throw new Error("Invalid Mermaid syntax");
6379
- const { svg } = await mermaid.default.render(`${renderBaseId}-${idSeed++}-${props.content.length || 0}`, props.content);
6467
+ if (await parseMermaid(props.content, { suppressErrors: true }) === false) throw new Error("Invalid Mermaid syntax");
6468
+ const { svg } = await renderMermaid(`${renderBaseId}-${idSeed++}-${props.content.length || 0}`, props.content);
6380
6469
  graphEl.innerHTML = svg;
6381
6470
  applySvgTransform();
6382
6471
  } catch (error) {
@@ -6509,7 +6598,7 @@
6509
6598
  if (next !== void 0) internalRenderType.value = next;
6510
6599
  });
6511
6600
  (0, vue.watch)(() => props.config, (nextConfig) => {
6512
- mermaid.default.initialize({
6601
+ initializeMermaid({
6513
6602
  startOnLoad: false,
6514
6603
  securityLevel: "strict",
6515
6604
  theme: "default",
@@ -6831,7 +6920,7 @@
6831
6920
  //#endregion
6832
6921
  //#region components/prompts/index.tsx
6833
6922
  var prompts_default = /* @__PURE__ */ (0, vue.defineComponent)({
6834
- name: "XPrompts",
6923
+ name: "AxPrompts",
6835
6924
  inheritAttrs: false,
6836
6925
  props: {
6837
6926
  items: {
@@ -6951,8 +7040,10 @@
6951
7040
  };
6952
7041
  });
6953
7042
  const triggerItemClick = (item, nested) => {
6954
- if (nested || item.disabled) return;
6955
- emit("itemClick", { data: item });
7043
+ if (item.disabled || !nested && hasChildren(item)) return;
7044
+ const info = { data: item };
7045
+ props.onItemClick?.(info);
7046
+ emit("itemClick", info);
6956
7047
  };
6957
7048
  const renderTitle = () => {
6958
7049
  if (slots.title) return slots.title({ originNode: props.title });
@@ -6997,7 +7088,7 @@
6997
7088
  }
6998
7089
  ],
6999
7090
  "style": [nested ? mergedStyles.value.subItem : mergedStyles.value.item, item.style],
7000
- "onClick": () => triggerItemClick(item, itemHasChildren)
7091
+ "onClick": () => triggerItemClick(item, nested)
7001
7092
  }), [hasRenderableNode$5(iconNode) && (0, vue.createVNode)("div", { "class": `${props.prefixCls}-icon` }, [iconNode]), (0, vue.createVNode)("div", {
7002
7093
  "class": [`${props.prefixCls}-content`, mergedClasses.value.itemContent],
7003
7094
  "style": mergedStyles.value.itemContent
@@ -7074,10 +7165,6 @@
7074
7165
  variant: {
7075
7166
  type: String,
7076
7167
  default: void 0
7077
- },
7078
- class: {
7079
- type: String,
7080
- default: void 0
7081
7168
  }
7082
7169
  },
7083
7170
  setup(props, { attrs }) {
@@ -7100,7 +7187,7 @@
7100
7187
  "disabled": mergedDisabled.value,
7101
7188
  "class": [
7102
7189
  prefixCls,
7103
- props.class,
7190
+ attrs.class,
7104
7191
  { [`${prefixCls}-disabled`]: mergedDisabled.value }
7105
7192
  ],
7106
7193
  "onClick": (e) => {
@@ -7211,6 +7298,811 @@
7211
7298
  }
7212
7299
  });
7213
7300
  //#endregion
7301
+ //#region components/sender/context.ts
7302
+ var SenderContextKey = Symbol("sender-context");
7303
+ function useSenderContext() {
7304
+ return (0, vue.inject)(SenderContextKey, (0, vue.computed)(() => ({})));
7305
+ }
7306
+ function provideSenderContext(value) {
7307
+ (0, vue.provide)(SenderContextKey, value);
7308
+ }
7309
+ //#endregion
7310
+ //#region components/sender/components/Skill.tsx
7311
+ function _isSlot$1(s) {
7312
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
7313
+ }
7314
+ var Skill_default = /* @__PURE__ */ (0, vue.defineComponent)({
7315
+ name: "SenderSkill",
7316
+ props: {
7317
+ prefixCls: {
7318
+ type: String,
7319
+ required: true
7320
+ },
7321
+ skill: {
7322
+ type: Object,
7323
+ required: true
7324
+ },
7325
+ removeSkill: {
7326
+ type: Function,
7327
+ required: true
7328
+ }
7329
+ },
7330
+ setup(props) {
7331
+ const componentCls = (0, vue.computed)(() => `${props.prefixCls}-skill`);
7332
+ const closeNode = (0, vue.computed)(() => {
7333
+ const closable = props.skill.closable;
7334
+ if (!closable) return null;
7335
+ const config = typeof closable === "boolean" ? {} : closable;
7336
+ const closeIcon = config.closeIcon ?? (0, vue.createVNode)(_antdv_next_icons.CloseOutlined, { "class": `${componentCls.value}-close-icon` }, null);
7337
+ return (0, vue.createVNode)("div", {
7338
+ "class": (0, _v_c_util.classNames)([`${componentCls.value}-close`, { [`${componentCls.value}-close-disabled`]: config.disabled }]),
7339
+ "role": "button",
7340
+ "aria-label": "Close skill",
7341
+ "tabindex": 0,
7342
+ "onClick": (event) => {
7343
+ if (config.disabled) return;
7344
+ event.stopPropagation();
7345
+ props.removeSkill();
7346
+ config.onClose?.(event);
7347
+ }
7348
+ }, [closeIcon]);
7349
+ });
7350
+ return () => {
7351
+ const mergeTitle = props.skill.title ?? props.skill.value;
7352
+ const titleNode = props.skill.toolTip ? (0, vue.createVNode)(antdv_next.Tooltip, props.skill.toolTip, _isSlot$1(mergeTitle) ? mergeTitle : { default: () => [mergeTitle] }) : mergeTitle;
7353
+ return (0, vue.createVNode)("div", {
7354
+ "class": `${componentCls.value}-wrapper`,
7355
+ "contenteditable": false
7356
+ }, [(0, vue.createVNode)("div", {
7357
+ "class": `${componentCls.value}-tag`,
7358
+ "contenteditable": false,
7359
+ "role": "button",
7360
+ "tabindex": 0
7361
+ }, [(0, vue.createVNode)("span", { "class": `${componentCls.value}-tag-text` }, [titleNode]), closeNode.value]), (0, vue.createVNode)("div", { "class": `${componentCls.value}-holder` }, null)]);
7362
+ };
7363
+ }
7364
+ });
7365
+ //#endregion
7366
+ //#region components/sender/components/SlotTextArea.tsx
7367
+ var SUPPORTED_INPUT_TYPES = new Set([
7368
+ "input",
7369
+ "select",
7370
+ "custom",
7371
+ "content"
7372
+ ]);
7373
+ function stringifyValue(value) {
7374
+ if (value === void 0 || value === null) return "";
7375
+ if (typeof value === "string") return value;
7376
+ if (typeof value === "number" || typeof value === "boolean") return `${value}`;
7377
+ try {
7378
+ return JSON.stringify(value);
7379
+ } catch {
7380
+ return "";
7381
+ }
7382
+ }
7383
+ function getDefaultSlotValue(config) {
7384
+ if (!config.key) return void 0;
7385
+ const props = config.props ?? {};
7386
+ if (SUPPORTED_INPUT_TYPES.has(config.type)) return props.defaultValue ?? "";
7387
+ return props.value ?? props.label ?? "";
7388
+ }
7389
+ var SlotTextArea_default = /* @__PURE__ */ (0, vue.defineComponent)({
7390
+ name: "SlotTextArea",
7391
+ setup(_, { expose }) {
7392
+ const senderCtx = useSenderContext();
7393
+ const editableRef = (0, vue.ref)();
7394
+ const slotDomMap = (0, vue.ref)(/* @__PURE__ */ new Map());
7395
+ const slotConfigMap = (0, vue.ref)(/* @__PURE__ */ new Map());
7396
+ const slotValues = (0, vue.ref)({});
7397
+ const mountedDomSet = (0, vue.ref)(/* @__PURE__ */ new Set());
7398
+ const skillDomRef = (0, vue.ref)(null);
7399
+ const currentSkillRef = (0, vue.ref)(void 0);
7400
+ const lastSlotConfigRef = (0, vue.ref)(void 0);
7401
+ const lastSkillRef = (0, vue.ref)(void 0);
7402
+ const isComposing = (0, vue.ref)(false);
7403
+ const keyLock = (0, vue.ref)(false);
7404
+ const prefixCls = (0, vue.computed)(() => senderCtx.value.prefixCls || "antd-sender");
7405
+ const mergeInputStyle = (0, vue.computed)(() => ({
7406
+ ...senderCtx.value.styles?.input,
7407
+ ...getAutoSizeStyle()
7408
+ }));
7409
+ const getAutoSizeStyle = () => {
7410
+ const autoSize = senderCtx.value.autoSize;
7411
+ if (autoSize === true) return { height: "auto" };
7412
+ if (!autoSize || typeof autoSize !== "object") return {};
7413
+ const lineHeight = 22;
7414
+ return {
7415
+ minHeight: autoSize.minRows ? `${autoSize.minRows * lineHeight}px` : void 0,
7416
+ maxHeight: autoSize.maxRows ? `${autoSize.maxRows * lineHeight}px` : void 0,
7417
+ overflowY: "auto"
7418
+ };
7419
+ };
7420
+ const getNodeInfo = (targetNode) => {
7421
+ if (!targetNode?.dataset) return null;
7422
+ const slotKey = targetNode.dataset.slotKey;
7423
+ return {
7424
+ slotKey,
7425
+ skillKey: targetNode.dataset.skillKey,
7426
+ nodeType: targetNode.dataset.nodeType,
7427
+ slotConfig: slotKey ? slotConfigMap.value.get(slotKey) : void 0
7428
+ };
7429
+ };
7430
+ const unmountDom = (container) => {
7431
+ if (!container) return;
7432
+ (0, vue.render)(null, container);
7433
+ mountedDomSet.value.delete(container);
7434
+ };
7435
+ const unmountAllPortals = () => {
7436
+ mountedDomSet.value.forEach((container) => {
7437
+ (0, vue.render)(null, container);
7438
+ });
7439
+ mountedDomSet.value.clear();
7440
+ };
7441
+ const buildSkillSpan = (key) => {
7442
+ const span = document.createElement("span");
7443
+ span.setAttribute("contenteditable", "false");
7444
+ span.dataset.skillKey = key;
7445
+ span.dataset.placeholder = senderCtx.value.placeholder || "";
7446
+ span.className = `${prefixCls.value}-skill`;
7447
+ return span;
7448
+ };
7449
+ const buildSlotSpan = (key) => {
7450
+ const span = document.createElement("span");
7451
+ span.setAttribute("contenteditable", "false");
7452
+ span.dataset.slotKey = key;
7453
+ span.className = `${prefixCls.value}-slot`;
7454
+ return span;
7455
+ };
7456
+ const buildEditSlotSpan = (config) => {
7457
+ const span = document.createElement("span");
7458
+ span.setAttribute("contenteditable", senderCtx.value.readOnly ? "false" : "true");
7459
+ span.dataset.slotKey = config.key;
7460
+ span.className = `${prefixCls.value}-slot ${prefixCls.value}-slot-content`;
7461
+ return span;
7462
+ };
7463
+ const buildSpaceSpan = (slotKey, position) => {
7464
+ const span = document.createElement("span");
7465
+ span.setAttribute("contenteditable", "false");
7466
+ span.dataset.slotKey = slotKey;
7467
+ span.dataset.nodeType = "nbsp";
7468
+ span.className = `${prefixCls.value}-slot-${position} ${prefixCls.value}-slot-no-width`;
7469
+ span.textContent = "\xA0";
7470
+ return span;
7471
+ };
7472
+ const getNodeTextValue = (node) => {
7473
+ if (node.nodeType === Node.TEXT_NODE) return node.textContent ?? "";
7474
+ if (node.nodeType !== Node.ELEMENT_NODE) return "";
7475
+ const element = node;
7476
+ const nodeInfo = getNodeInfo(element);
7477
+ if (!nodeInfo) return element.innerText || "";
7478
+ if (nodeInfo.skillKey) return "";
7479
+ if (nodeInfo.slotKey) {
7480
+ if (nodeInfo.nodeType === "nbsp") return " ";
7481
+ const config = nodeInfo.slotConfig;
7482
+ if (!config || config.type === "content") return element.innerText || "";
7483
+ const rawValue = slotValues.value[nodeInfo.slotKey];
7484
+ return config.formatResult?.(rawValue) ?? stringifyValue(rawValue);
7485
+ }
7486
+ return element.innerText || "";
7487
+ };
7488
+ const getEditorValue = () => {
7489
+ const editable = editableRef.value;
7490
+ const emptyResult = {
7491
+ value: "",
7492
+ slotConfig: [],
7493
+ skill: void 0
7494
+ };
7495
+ if (!editable) return emptyResult;
7496
+ const childNodes = editable.childNodes;
7497
+ if (childNodes.length === 0) return emptyResult;
7498
+ const textList = [];
7499
+ const currentSlotConfig = [];
7500
+ let currentSkill;
7501
+ childNodes.forEach((node) => {
7502
+ const textValue = getNodeTextValue(node);
7503
+ textList.push(textValue);
7504
+ if (node.nodeType === Node.TEXT_NODE) {
7505
+ if (textValue) currentSlotConfig.push({
7506
+ type: "text",
7507
+ value: textValue
7508
+ });
7509
+ return;
7510
+ }
7511
+ if (node.nodeType === Node.ELEMENT_NODE) {
7512
+ const info = getNodeInfo(node);
7513
+ if (!info) return;
7514
+ if (info.skillKey && currentSkillRef.value) currentSkill = currentSkillRef.value;
7515
+ if (info.slotKey && info.nodeType !== "nbsp") {
7516
+ const cfg = slotConfigMap.value.get(info.slotKey);
7517
+ if (cfg) currentSlotConfig.push({
7518
+ ...cfg,
7519
+ value: textValue
7520
+ });
7521
+ }
7522
+ }
7523
+ });
7524
+ return {
7525
+ value: textList.join(""),
7526
+ slotConfig: currentSlotConfig,
7527
+ skill: currentSkill
7528
+ };
7529
+ };
7530
+ const updateSubmitDisabled = () => {
7531
+ const value = getEditorValue();
7532
+ senderCtx.value.setSubmitDisabled?.(!value.value && value.slotConfig.length === 0 && !value.skill);
7533
+ };
7534
+ const triggerValueChange = (event) => {
7535
+ const value = getEditorValue();
7536
+ senderCtx.value.onChange?.(value.value, event, value.slotConfig, value.skill);
7537
+ updateSkillEmptyStatus(value);
7538
+ updateSubmitDisabled();
7539
+ };
7540
+ const updateSlot = (key, value, event) => {
7541
+ slotValues.value = {
7542
+ ...slotValues.value,
7543
+ [key]: value
7544
+ };
7545
+ const config = slotConfigMap.value.get(key);
7546
+ const dom = slotDomMap.value.get(key);
7547
+ if (config && dom && config.type !== "content") renderSlot(config, dom);
7548
+ triggerValueChange(event);
7549
+ };
7550
+ const buildSelectMenuItems = (options) => {
7551
+ return (options ?? []).map((option) => ({
7552
+ label: option,
7553
+ key: option
7554
+ }));
7555
+ };
7556
+ const renderSlot = (config, slotDom) => {
7557
+ if (!("key" in config) || !config.key) return;
7558
+ const slotValue = slotValues.value[config.key];
7559
+ let node = null;
7560
+ switch (config.type) {
7561
+ case "input":
7562
+ node = (0, vue.createVNode)(antdv_next.Input, {
7563
+ "class": `${prefixCls.value}-slot-input`,
7564
+ "placeholder": config.props?.placeholder,
7565
+ "value": slotValue ?? "",
7566
+ "size": "small",
7567
+ "variant": "borderless",
7568
+ "readonly": senderCtx.value.readOnly,
7569
+ "disabled": senderCtx.value.disabled,
7570
+ "onKeydown": onInternalKeyDown,
7571
+ "onChange": (e) => {
7572
+ updateSlot(config.key, e?.target?.value ?? "", e);
7573
+ }
7574
+ }, null);
7575
+ break;
7576
+ case "select": {
7577
+ const displayValue = stringifyValue(slotValue);
7578
+ node = (0, vue.createVNode)(antdv_next.Dropdown, {
7579
+ "disabled": senderCtx.value.readOnly || senderCtx.value.disabled,
7580
+ "trigger": ["click"],
7581
+ "menu": {
7582
+ items: buildSelectMenuItems(config.props?.options),
7583
+ selectable: true,
7584
+ selectedKeys: displayValue ? [displayValue] : [],
7585
+ onSelect: ({ key, domEvent }) => {
7586
+ updateSlot(config.key, key, domEvent);
7587
+ }
7588
+ }
7589
+ }, { default: () => [(0, vue.createVNode)("span", { "class": (0, _v_c_util.classNames)([`${prefixCls.value}-slot-select`, {
7590
+ placeholder: !displayValue,
7591
+ [`${prefixCls.value}-slot-select-selector-value`]: !!displayValue
7592
+ }]) }, [(0, vue.createVNode)("span", {
7593
+ "data-placeholder": config.props?.placeholder,
7594
+ "class": `${prefixCls.value}-slot-select-value`
7595
+ }, [displayValue]), (0, vue.createVNode)("span", { "class": `${prefixCls.value}-slot-select-arrow` }, [(0, vue.createTextVNode)("▼")])])] });
7596
+ break;
7597
+ }
7598
+ case "tag":
7599
+ node = (0, vue.createVNode)("span", { "class": `${prefixCls.value}-slot-tag` }, [config.props?.label ?? config.props?.value ?? ""]);
7600
+ break;
7601
+ case "custom":
7602
+ node = config.customRender?.(slotValue, (nextValue) => {
7603
+ updateSlot(config.key, nextValue);
7604
+ }, {
7605
+ disabled: senderCtx.value.disabled,
7606
+ readOnly: senderCtx.value.readOnly
7607
+ }, config);
7608
+ break;
7609
+ case "content":
7610
+ slotDom.innerText = stringifyValue(slotValue);
7611
+ slotDom.dataset.placeholder = config.props?.placeholder ?? "";
7612
+ return;
7613
+ default: return;
7614
+ }
7615
+ if (!node) return;
7616
+ mountedDomSet.value.add(slotDom);
7617
+ (0, vue.render)(node, slotDom);
7618
+ };
7619
+ const buildSlotNodes = (configs) => {
7620
+ const list = [];
7621
+ configs.forEach((config) => {
7622
+ if (config.type === "text") {
7623
+ list.push(document.createTextNode(config.value || ""));
7624
+ return;
7625
+ }
7626
+ if (!("key" in config) || !config.key) {
7627
+ warning(false, "Sender", "Slot key is missing");
7628
+ return;
7629
+ }
7630
+ slotConfigMap.value.set(config.key, config);
7631
+ if (config.type === "content") {
7632
+ const before = buildSpaceSpan(config.key, "before");
7633
+ const slot = buildEditSlotSpan(config);
7634
+ const after = buildSpaceSpan(config.key, "after");
7635
+ slotValues.value[config.key] = slotValues.value[config.key] ?? getDefaultSlotValue(config);
7636
+ slot.innerText = stringifyValue(slotValues.value[config.key]);
7637
+ slot.dataset.placeholder = config.props?.placeholder ?? "";
7638
+ slotDomMap.value.set(`${config.key}_before`, before);
7639
+ slotDomMap.value.set(config.key, slot);
7640
+ slotDomMap.value.set(`${config.key}_after`, after);
7641
+ list.push(before, slot, after);
7642
+ return;
7643
+ }
7644
+ const slot = buildSlotSpan(config.key);
7645
+ slotValues.value[config.key] = slotValues.value[config.key] ?? getDefaultSlotValue(config);
7646
+ slotDomMap.value.set(config.key, slot);
7647
+ renderSlot(config, slot);
7648
+ list.push(slot);
7649
+ });
7650
+ return list;
7651
+ };
7652
+ const mergeSlotConfig = (configs) => {
7653
+ const nextValues = { ...slotValues.value };
7654
+ configs.forEach((config) => {
7655
+ if ("key" in config && config.key) {
7656
+ slotConfigMap.value.set(config.key, config);
7657
+ if (!(config.key in nextValues)) nextValues[config.key] = getDefaultSlotValue(config);
7658
+ }
7659
+ });
7660
+ slotValues.value = nextValues;
7661
+ };
7662
+ const clearEditor = () => {
7663
+ unmountAllPortals();
7664
+ slotDomMap.value.clear();
7665
+ slotConfigMap.value.clear();
7666
+ slotValues.value = {};
7667
+ currentSkillRef.value = void 0;
7668
+ if (skillDomRef.value) unmountDom(skillDomRef.value);
7669
+ skillDomRef.value = null;
7670
+ if (editableRef.value) editableRef.value.innerHTML = "";
7671
+ };
7672
+ const getSelection = () => {
7673
+ if (typeof window === "undefined") return null;
7674
+ return window.getSelection();
7675
+ };
7676
+ const setRange = (range, selection) => {
7677
+ selection.removeAllRanges();
7678
+ selection.addRange(range);
7679
+ };
7680
+ const setCursorPosition = (targetNode, offset, preventScroll) => {
7681
+ const editable = editableRef.value;
7682
+ if (!editable) return;
7683
+ editable.focus({ preventScroll });
7684
+ const selection = getSelection();
7685
+ if (!selection) return;
7686
+ const range = document.createRange();
7687
+ range.setStart(targetNode, offset);
7688
+ range.collapse(true);
7689
+ setRange(range, selection);
7690
+ };
7691
+ const setStartCursor = (preventScroll) => {
7692
+ const editable = editableRef.value;
7693
+ if (!editable) return;
7694
+ setCursorPosition(editable, skillDomRef.value ? 1 : 0, preventScroll);
7695
+ };
7696
+ const setEndCursor = (preventScroll) => {
7697
+ const editable = editableRef.value;
7698
+ if (!editable) return;
7699
+ editable.focus({ preventScroll });
7700
+ const selection = getSelection();
7701
+ if (!selection) return;
7702
+ const range = document.createRange();
7703
+ range.selectNodeContents(editable);
7704
+ range.collapse(false);
7705
+ setRange(range, selection);
7706
+ };
7707
+ const selectAll = (preventScroll) => {
7708
+ const editable = editableRef.value;
7709
+ if (!editable) return;
7710
+ editable.focus({ preventScroll });
7711
+ const selection = getSelection();
7712
+ if (!selection) return;
7713
+ const range = document.createRange();
7714
+ range.selectNodeContents(editable);
7715
+ if (skillDomRef.value) range.setStart(editable, 1);
7716
+ setRange(range, selection);
7717
+ };
7718
+ const focusSlot = (key, preventScroll) => {
7719
+ const editable = editableRef.value;
7720
+ if (!editable) return;
7721
+ const resolveTarget = (slotKey) => {
7722
+ const slotDom = slotDomMap.value.get(slotKey);
7723
+ const slotCfg = slotConfigMap.value.get(slotKey);
7724
+ if (!slotDom || !slotCfg) return null;
7725
+ if (slotCfg.type === "input") return slotDom.querySelector("input");
7726
+ if (slotCfg.type === "content") return slotDom;
7727
+ return null;
7728
+ };
7729
+ if (key) {
7730
+ const target = resolveTarget(key);
7731
+ if (target instanceof HTMLInputElement) {
7732
+ target.focus({ preventScroll });
7733
+ return;
7734
+ }
7735
+ if (target instanceof HTMLSpanElement) {
7736
+ setCursorPosition(target, 0, preventScroll);
7737
+ return;
7738
+ }
7739
+ }
7740
+ for (const node of Array.from(editable.childNodes)) {
7741
+ if (!(node instanceof HTMLElement)) continue;
7742
+ const slotKey = node.dataset.slotKey;
7743
+ const nodeType = node.dataset.nodeType;
7744
+ if (!slotKey || nodeType === "nbsp") continue;
7745
+ const target = resolveTarget(slotKey);
7746
+ if (target instanceof HTMLInputElement) {
7747
+ target.focus({ preventScroll });
7748
+ return;
7749
+ }
7750
+ if (target instanceof HTMLSpanElement) {
7751
+ setCursorPosition(target, 0, preventScroll);
7752
+ return;
7753
+ }
7754
+ }
7755
+ setEndCursor(preventScroll);
7756
+ };
7757
+ const removeSlot = (key, event) => {
7758
+ const editable = editableRef.value;
7759
+ if (!editable) return;
7760
+ editable.querySelectorAll(`[data-slot-key="${key}"]`).forEach((element) => {
7761
+ unmountDom(element);
7762
+ element.remove();
7763
+ });
7764
+ const nextValues = { ...slotValues.value };
7765
+ delete nextValues[key];
7766
+ slotValues.value = nextValues;
7767
+ slotConfigMap.value.delete(key);
7768
+ slotDomMap.value.delete(key);
7769
+ slotDomMap.value.delete(`${key}_before`);
7770
+ slotDomMap.value.delete(`${key}_after`);
7771
+ triggerValueChange(event);
7772
+ };
7773
+ const removeSkill = (triggerChange = true) => {
7774
+ const skillDom = skillDomRef.value;
7775
+ if (!skillDom) return;
7776
+ unmountDom(skillDom);
7777
+ skillDom.remove();
7778
+ skillDomRef.value = null;
7779
+ currentSkillRef.value = void 0;
7780
+ if (triggerChange) triggerValueChange();
7781
+ };
7782
+ const renderSkill = () => {
7783
+ const editable = editableRef.value;
7784
+ const skill = senderCtx.value.skill;
7785
+ if (!editable) return;
7786
+ if (!skill) {
7787
+ removeSkill(false);
7788
+ return;
7789
+ }
7790
+ let skillDom = skillDomRef.value;
7791
+ if (!skillDom) {
7792
+ skillDom = buildSkillSpan(skill.value);
7793
+ editable.insertBefore(skillDom, editable.firstChild);
7794
+ skillDomRef.value = skillDom;
7795
+ }
7796
+ currentSkillRef.value = skill;
7797
+ mountedDomSet.value.add(skillDom);
7798
+ (0, vue.render)((0, vue.createVNode)(Skill_default, {
7799
+ "prefixCls": prefixCls.value,
7800
+ "skill": skill,
7801
+ "removeSkill": () => removeSkill(true)
7802
+ }, null), skillDom);
7803
+ };
7804
+ const updateSkillEmptyStatus = (value = getEditorValue()) => {
7805
+ const skillDom = skillDomRef.value;
7806
+ if (!skillDom) return;
7807
+ if (!value.value && value.slotConfig.length === 0 && !!senderCtx.value.placeholder) {
7808
+ skillDom.setAttribute("contenteditable", "true");
7809
+ skillDom.classList.add(`${prefixCls.value}-skill-empty`);
7810
+ } else {
7811
+ skillDom.setAttribute("contenteditable", "false");
7812
+ skillDom.classList.remove(`${prefixCls.value}-skill-empty`);
7813
+ }
7814
+ };
7815
+ const initFromSlotConfig = (configs) => {
7816
+ const editable = editableRef.value;
7817
+ if (!editable) return;
7818
+ clearEditor();
7819
+ const mergeConfigs = configs ?? [];
7820
+ mergeConfigs.forEach((config) => {
7821
+ if ("key" in config && config.key) {
7822
+ slotConfigMap.value.set(config.key, config);
7823
+ const defaultValue = getDefaultSlotValue(config);
7824
+ if (defaultValue !== void 0) slotValues.value[config.key] = defaultValue;
7825
+ }
7826
+ });
7827
+ buildSlotNodes(mergeConfigs).forEach((node) => {
7828
+ editable.appendChild(node);
7829
+ });
7830
+ renderSkill();
7831
+ (0, vue.nextTick)(() => {
7832
+ triggerValueChange();
7833
+ });
7834
+ };
7835
+ const removeSpecificBRs = () => {
7836
+ if (senderCtx.value.submitType !== "enter") return;
7837
+ editableRef.value?.querySelectorAll("br").forEach((br) => br.remove());
7838
+ };
7839
+ const shouldSubmit = (event) => {
7840
+ const { key, shiftKey, ctrlKey, altKey, metaKey } = event;
7841
+ if (key !== "Enter") return false;
7842
+ const isModifierPressed = ctrlKey || altKey || metaKey;
7843
+ const submitType = senderCtx.value.submitType ?? "enter";
7844
+ return submitType === "enter" && !shiftKey && !isModifierPressed || submitType === "shiftEnter" && shiftKey && !isModifierPressed;
7845
+ };
7846
+ const findOuterContainer = (node) => {
7847
+ const editable = editableRef.value;
7848
+ if (!node || !editable) return null;
7849
+ let current = node;
7850
+ if (current.nodeType === Node.TEXT_NODE) current = current.parentNode;
7851
+ while (current && current !== editable) {
7852
+ if (current instanceof HTMLElement && current.tagName === "SPAN") return current;
7853
+ current = current.parentNode;
7854
+ }
7855
+ return null;
7856
+ };
7857
+ const handleBackspaceDelete = (event) => {
7858
+ const selection = getSelection();
7859
+ if (!selection || !selection.isCollapsed) return false;
7860
+ const editable = editableRef.value;
7861
+ if (!editable) return false;
7862
+ let anchorNode = selection.anchorNode;
7863
+ let offset = selection.anchorOffset;
7864
+ if (!anchorNode || !editable.contains(anchorNode)) return false;
7865
+ if (anchorNode === editable && offset > 0) {
7866
+ anchorNode = editable.childNodes[offset - 1] ?? anchorNode;
7867
+ offset = 0;
7868
+ }
7869
+ if (anchorNode.nodeType === Node.TEXT_NODE && offset > 0) return false;
7870
+ const target = anchorNode.nodeType === Node.TEXT_NODE ? anchorNode.parentNode : anchorNode;
7871
+ const previous = target === editable ? editable.childNodes[Math.max(0, selection.anchorOffset - 1)] : target?.previousSibling;
7872
+ if (!(previous instanceof HTMLElement)) return false;
7873
+ const info = getNodeInfo(previous);
7874
+ if (info?.slotKey) {
7875
+ event.preventDefault();
7876
+ removeSlot(info.slotKey, event);
7877
+ return true;
7878
+ }
7879
+ if (info?.skillKey) {
7880
+ event.preventDefault();
7881
+ removeSkill(true);
7882
+ return true;
7883
+ }
7884
+ return false;
7885
+ };
7886
+ const onInternalKeyDown = (event) => {
7887
+ if (senderCtx.value.onKeyDown?.(event) === false || keyLock.value || isComposing.value) return;
7888
+ if (event.key === "Backspace" && handleBackspaceDelete(event)) return;
7889
+ if (shouldSubmit(event)) {
7890
+ event.preventDefault();
7891
+ keyLock.value = true;
7892
+ senderCtx.value.triggerSend?.();
7893
+ return;
7894
+ }
7895
+ if ((event.key === "a" || event.key === "A") && (event.ctrlKey || event.metaKey)) {
7896
+ event.preventDefault();
7897
+ selectAll(true);
7898
+ }
7899
+ };
7900
+ const onInternalKeyUp = (event) => {
7901
+ if (event.key === "Enter") keyLock.value = false;
7902
+ senderCtx.value.onKeyUp?.(event);
7903
+ };
7904
+ const onInternalInput = (event) => {
7905
+ removeSpecificBRs();
7906
+ triggerValueChange(event);
7907
+ };
7908
+ const onInternalPaste = (event) => {
7909
+ event.preventDefault();
7910
+ const files = event.clipboardData?.files;
7911
+ const text = event.clipboardData?.getData("text/plain") ?? "";
7912
+ if (!text && files?.length && senderCtx.value.onPasteFile) {
7913
+ senderCtx.value.onPasteFile(files);
7914
+ return;
7915
+ }
7916
+ if (text) {
7917
+ const selection = getSelection();
7918
+ if (selection && selection.rangeCount > 0) {
7919
+ const range = selection.getRangeAt(0);
7920
+ range.deleteContents();
7921
+ const textNode = document.createTextNode(text.replace(/\u200B/g, ""));
7922
+ range.insertNode(textNode);
7923
+ range.setStartAfter(textNode);
7924
+ range.collapse(true);
7925
+ selection.removeAllRanges();
7926
+ selection.addRange(range);
7927
+ }
7928
+ }
7929
+ onInternalInput(event);
7930
+ senderCtx.value.onPaste?.(event);
7931
+ };
7932
+ const onInternalSelect = () => {
7933
+ const selection = getSelection();
7934
+ const editable = editableRef.value;
7935
+ if (!selection || !editable) return;
7936
+ if (selection.focusNode === editable && selection.focusOffset === 0 && getEditorValue().skill) setCursorPosition(editable, 1);
7937
+ };
7938
+ const getRangeForInsert = (position = "cursor") => {
7939
+ const editable = editableRef.value;
7940
+ if (!editable) return null;
7941
+ const selection = getSelection();
7942
+ const range = document.createRange();
7943
+ if (position === "start") {
7944
+ const index = skillDomRef.value ? 1 : 0;
7945
+ range.setStart(editable, index);
7946
+ range.collapse(true);
7947
+ return {
7948
+ range,
7949
+ selection
7950
+ };
7951
+ }
7952
+ if (position === "end") {
7953
+ range.selectNodeContents(editable);
7954
+ range.collapse(false);
7955
+ return {
7956
+ range,
7957
+ selection
7958
+ };
7959
+ }
7960
+ if (selection && selection.rangeCount > 0 && editable.contains(selection.getRangeAt(0).startContainer)) {
7961
+ const currentRange = selection.getRangeAt(0).cloneRange();
7962
+ const outer = findOuterContainer(currentRange.startContainer);
7963
+ const outerInfo = outer ? getNodeInfo(outer) : null;
7964
+ if (outer && outerInfo?.slotKey && outerInfo.slotConfig?.type !== "content") {
7965
+ currentRange.setStartAfter(outer);
7966
+ currentRange.collapse(true);
7967
+ }
7968
+ return {
7969
+ range: currentRange,
7970
+ selection
7971
+ };
7972
+ }
7973
+ range.selectNodeContents(editable);
7974
+ range.collapse(false);
7975
+ return {
7976
+ range,
7977
+ selection
7978
+ };
7979
+ };
7980
+ const insert = (slotConfig, position = "cursor", replaceCharacters, preventScroll) => {
7981
+ const editable = editableRef.value;
7982
+ if (!editable || !slotConfig.length) return;
7983
+ mergeSlotConfig(slotConfig);
7984
+ const nodes = buildSlotNodes(slotConfig);
7985
+ if (!nodes.length) return;
7986
+ const insertContext = getRangeForInsert(position);
7987
+ if (!insertContext?.range) return;
7988
+ const { range, selection } = insertContext;
7989
+ editable.focus({ preventScroll });
7990
+ if (replaceCharacters) {
7991
+ if ((getSelection()?.toString() ?? "").endsWith(replaceCharacters)) range.setStart(range.startContainer, Math.max(0, range.startOffset - replaceCharacters.length));
7992
+ }
7993
+ range.deleteContents();
7994
+ nodes.forEach((node) => {
7995
+ range.insertNode(node);
7996
+ range.setStartAfter(node);
7997
+ });
7998
+ range.collapse(true);
7999
+ if (selection) {
8000
+ selection.removeAllRanges();
8001
+ selection.addRange(range);
8002
+ }
8003
+ onInternalInput();
8004
+ };
8005
+ const focus = (options) => {
8006
+ const cursor = options?.cursor ?? "end";
8007
+ if (cursor === "start") {
8008
+ setStartCursor(options?.preventScroll);
8009
+ return;
8010
+ }
8011
+ if (cursor === "all") {
8012
+ selectAll(options?.preventScroll);
8013
+ return;
8014
+ }
8015
+ if (cursor === "slot") {
8016
+ focusSlot(options?.key, options?.preventScroll);
8017
+ return;
8018
+ }
8019
+ setEndCursor(options?.preventScroll);
8020
+ };
8021
+ const clear = () => {
8022
+ clearEditor();
8023
+ renderSkill();
8024
+ onInternalInput();
8025
+ };
8026
+ expose({
8027
+ get nativeElement() {
8028
+ return editableRef.value ?? null;
8029
+ },
8030
+ focus,
8031
+ blur() {
8032
+ editableRef.value?.blur();
8033
+ },
8034
+ insert,
8035
+ clear,
8036
+ getValue: getEditorValue
8037
+ });
8038
+ const applySlotConfig = (configs, force = false) => {
8039
+ if (!force && configs === lastSlotConfigRef.value) return;
8040
+ lastSlotConfigRef.value = configs;
8041
+ initFromSlotConfig(configs);
8042
+ };
8043
+ (0, vue.watch)(() => editableRef.value, (editable) => {
8044
+ if (!editable) return;
8045
+ applySlotConfig(senderCtx.value.slotConfig, true);
8046
+ }, { immediate: true });
8047
+ (0, vue.watch)(() => senderCtx.value.slotConfig, (configs) => {
8048
+ applySlotConfig(configs);
8049
+ }, { immediate: true });
8050
+ (0, vue.watch)(() => senderCtx.value.skill, (skill) => {
8051
+ if (skill === lastSkillRef.value && skillDomRef.value) return;
8052
+ lastSkillRef.value = skill;
8053
+ renderSkill();
8054
+ (0, vue.nextTick)(() => {
8055
+ triggerValueChange();
8056
+ });
8057
+ }, { immediate: true });
8058
+ (0, vue.watch)(() => senderCtx.value.readOnly, (readOnly) => {
8059
+ slotConfigMap.value.forEach((config, key) => {
8060
+ if (config.type === "content") slotDomMap.value.get(key)?.setAttribute("contenteditable", readOnly ? "false" : "true");
8061
+ });
8062
+ });
8063
+ (0, vue.onBeforeUnmount)(() => {
8064
+ unmountAllPortals();
8065
+ });
8066
+ return () => {
8067
+ const inputCls = `${prefixCls.value}-input`;
8068
+ return (0, vue.createVNode)("div", {
8069
+ "ref": editableRef,
8070
+ "role": "textbox",
8071
+ "tabindex": 0,
8072
+ "class": (0, _v_c_util.classNames)([
8073
+ inputCls,
8074
+ `${inputCls}-slot`,
8075
+ senderCtx.value.classNames?.input
8076
+ ]),
8077
+ "style": mergeInputStyle.value,
8078
+ "data-placeholder": senderCtx.value.placeholder,
8079
+ "contenteditable": !senderCtx.value.readOnly,
8080
+ "spellcheck": false,
8081
+ "onInput": onInternalInput,
8082
+ "onKeydown": onInternalKeyDown,
8083
+ "onKeyup": onInternalKeyUp,
8084
+ "onPaste": onInternalPaste,
8085
+ "onCut": onInternalInput,
8086
+ "onSelect": onInternalSelect,
8087
+ "onFocus": (e) => {
8088
+ senderCtx.value.onFocus?.(e);
8089
+ },
8090
+ "onBlur": (e) => {
8091
+ keyLock.value = false;
8092
+ senderCtx.value.onBlur?.(e);
8093
+ },
8094
+ "onCompositionstart": () => {
8095
+ isComposing.value = true;
8096
+ },
8097
+ "onCompositionend": () => {
8098
+ isComposing.value = false;
8099
+ keyLock.value = false;
8100
+ }
8101
+ }, null);
8102
+ };
8103
+ }
8104
+ });
8105
+ //#endregion
7214
8106
  //#region components/sender/components/SpeechButton/RecordingIcon.tsx
7215
8107
  var SIZE = 1e3;
7216
8108
  var COUNT = 4;
@@ -7287,15 +8179,6 @@
7287
8179
  }
7288
8180
  });
7289
8181
  //#endregion
7290
- //#region components/sender/context.ts
7291
- var SenderContextKey = Symbol("sender-context");
7292
- function useSenderContext() {
7293
- return (0, vue.inject)(SenderContextKey, (0, vue.computed)(() => ({})));
7294
- }
7295
- function provideSenderContext(value) {
7296
- (0, vue.provide)(SenderContextKey, value);
7297
- }
7298
- //#endregion
7299
8182
  //#region components/sender/components/TextArea.tsx
7300
8183
  var TextArea_default = /* @__PURE__ */ (0, vue.defineComponent)({
7301
8184
  name: "SenderTextArea",
@@ -7506,6 +8389,191 @@
7506
8389
  } };
7507
8390
  };
7508
8391
  //#endregion
8392
+ //#region components/sender/style/slot-textarea.ts
8393
+ var genSlotTextAreaStyle = (token) => {
8394
+ const { componentCls, antCls, calc } = token;
8395
+ const slotCls = `${componentCls}-slot`;
8396
+ const antInputCls = `${antCls}-input`;
8397
+ const antDropdownCls = `${antCls}-dropdown-trigger`;
8398
+ const slotInputCls = `${componentCls}-slot-input`;
8399
+ const slotSelectCls = `${componentCls}-slot-select`;
8400
+ const slotTagCls = `${componentCls}-slot-tag`;
8401
+ const slotContentCls = `${componentCls}-slot-content`;
8402
+ const skillCls = `${componentCls}-skill`;
8403
+ return { [componentCls]: {
8404
+ [`${componentCls}-input-slot`]: {
8405
+ outline: "none",
8406
+ cursor: "text",
8407
+ whiteSpace: "pre-wrap",
8408
+ width: "100%",
8409
+ caretColor: token.colorPrimary,
8410
+ fontSize: token.fontSize,
8411
+ lineHeight: token.lineHeight,
8412
+ [`&:empty::before`]: {
8413
+ content: "attr(data-placeholder)",
8414
+ color: token.colorTextPlaceholder
8415
+ }
8416
+ },
8417
+ [`${slotCls}:not(${slotContentCls})`]: {
8418
+ display: "inline-block",
8419
+ verticalAlign: "middle",
8420
+ alignItems: "center",
8421
+ marginBlock: 1,
8422
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
8423
+ wordBreak: "break-all",
8424
+ marginInline: token.marginXXS
8425
+ },
8426
+ [`${antInputCls}${slotInputCls}`]: {
8427
+ height: "100%",
8428
+ background: token.colorBgSlot,
8429
+ outline: "none",
8430
+ color: token.colorTextSlot,
8431
+ borderRadius: token.borderRadius,
8432
+ paddingInline: token.paddingXXS,
8433
+ fontSize: "inherit",
8434
+ lineHeight: "inherit",
8435
+ position: "relative",
8436
+ [`&::placeholder`]: {
8437
+ color: token.colorTextSlotPlaceholder,
8438
+ fontSize: "inherit",
8439
+ lineHeight: "inherit"
8440
+ }
8441
+ },
8442
+ [slotSelectCls]: {
8443
+ fontSize: token.fontSize,
8444
+ lineHeight: token.lineHeight,
8445
+ paddingInline: token.paddingXXS,
8446
+ transition: `border-color ${token.motionDurationMid}`,
8447
+ position: "relative",
8448
+ display: "inline-flex",
8449
+ alignItems: "center",
8450
+ cursor: "pointer",
8451
+ background: token.colorBgSlot,
8452
+ height: "100%",
8453
+ boxSizing: "border-box",
8454
+ borderRadius: token.borderRadius,
8455
+ color: token.colorTextSlot,
8456
+ border: `1px solid ${token.colorBorderSlot}`,
8457
+ [`&.placeholder`]: { color: token.colorTextSlotPlaceholder },
8458
+ [`&${antDropdownCls}-open`]: { borderColor: token.colorBorderSlotHover }
8459
+ },
8460
+ [`${slotSelectCls}-value`]: {
8461
+ flex: 1,
8462
+ fontSize: token.fontSize,
8463
+ lineHeight: token.lineHeight,
8464
+ [`&:empty::before`]: { content: "attr(data-placeholder)" }
8465
+ },
8466
+ [`${slotSelectCls}-arrow`]: {
8467
+ marginInlineStart: token.marginXXS,
8468
+ fontSize: token.fontSize,
8469
+ lineHeight: token.lineHeight,
8470
+ display: "inline-flex",
8471
+ alignItems: "center",
8472
+ justifyContent: "center"
8473
+ },
8474
+ [slotTagCls]: {
8475
+ background: token.colorBgSlot,
8476
+ border: `1px solid ${token.colorBorderSlot}`,
8477
+ outline: "none",
8478
+ color: token.colorTextSlot,
8479
+ borderRadius: token.borderRadius,
8480
+ padding: `0 ${(0, _antdv_next_cssinjs.unit)(token.paddingXXS)}`,
8481
+ fontSize: token.fontSize,
8482
+ lineHeight: token.lineHeight,
8483
+ height: "100%",
8484
+ boxSizing: "border-box",
8485
+ position: "relative",
8486
+ cursor: "default"
8487
+ },
8488
+ [slotContentCls]: {
8489
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
8490
+ caretColor: token.colorPrimary,
8491
+ background: token.colorBgSlot,
8492
+ outline: "none",
8493
+ color: token.colorTextSlot,
8494
+ borderRadius: token.borderRadius,
8495
+ paddingInline: token.paddingXXS,
8496
+ boxSizing: "border-box",
8497
+ verticalAlign: "middle",
8498
+ fontSize: token.fontSize,
8499
+ marginBlock: 1,
8500
+ lineHeight: token.lineHeight,
8501
+ display: "inline-block",
8502
+ position: "relative",
8503
+ cursor: "text",
8504
+ [`&:empty`]: {
8505
+ width: "fit-content",
8506
+ [`&::after`]: {
8507
+ display: "inline-block",
8508
+ height: "inherit",
8509
+ content: "attr(data-placeholder)",
8510
+ color: token.colorTextSlotPlaceholder
8511
+ }
8512
+ }
8513
+ },
8514
+ [`${slotCls}-no-width`]: {
8515
+ userSelect: "none",
8516
+ width: "3px",
8517
+ display: "inline-block",
8518
+ lineHeight: "inherit"
8519
+ },
8520
+ [skillCls]: {
8521
+ display: "inline-block",
8522
+ verticalAlign: "baseline",
8523
+ alignItems: "center",
8524
+ marginBlock: 1,
8525
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
8526
+ wordBreak: "break-all",
8527
+ paddingInlineEnd: 0,
8528
+ paddingInlineStart: 0,
8529
+ marginInlineEnd: 0,
8530
+ marginInlineStart: -1,
8531
+ [`&${skillCls}-empty`]: { [`&::after`]: {
8532
+ display: "inline-block",
8533
+ pointerEvents: "none",
8534
+ height: "inherit",
8535
+ content: "attr(data-placeholder)",
8536
+ color: token.colorTextPlaceholder
8537
+ } }
8538
+ },
8539
+ [`${skillCls}-wrapper`]: {
8540
+ height: "100%",
8541
+ display: "inline-flex"
8542
+ },
8543
+ [`${skillCls}-tag`]: {
8544
+ paddingInline: token.paddingXS,
8545
+ height: "100%",
8546
+ backgroundColor: token.colorBgSkill,
8547
+ borderRadius: token.borderRadius,
8548
+ color: token.colorPrimary,
8549
+ alignItems: "center",
8550
+ fontWeight: 500,
8551
+ display: "inline-flex",
8552
+ cursor: "pointer",
8553
+ gap: token.marginXXS,
8554
+ transition: `background-color ${token.motionDurationMid}`,
8555
+ [`&:hover`]: {
8556
+ backgroundColor: token.colorBgSkillHover,
8557
+ [`${skillCls}-close:not(${skillCls}-close-disabled)`]: { color: token.colorPrimaryHover }
8558
+ }
8559
+ },
8560
+ [`${skillCls}-close`]: {
8561
+ fontSize: token.fontSizeSM,
8562
+ display: "inline-flex",
8563
+ transition: `color ${token.motionDurationMid}`,
8564
+ color: token.colorPrimary
8565
+ },
8566
+ [`${skillCls}-close-disabled`]: {
8567
+ cursor: "not-allowed",
8568
+ color: token.colorTextDisabled
8569
+ },
8570
+ [`${skillCls}-holder`]: {
8571
+ width: token.marginXS,
8572
+ height: "100%"
8573
+ }
8574
+ } };
8575
+ };
8576
+ //#endregion
7509
8577
  //#region components/sender/style/switch.ts
7510
8578
  var genSenderSwitchStyle = (token) => {
7511
8579
  const { componentCls, antCls } = token;
@@ -7613,12 +8681,26 @@
7613
8681
  };
7614
8682
  var prepareComponentToken$5 = (token) => {
7615
8683
  const { colorPrimary, colorFillTertiary } = token;
8684
+ const colorBgSlot = new _ant_design_fast_color.FastColor(colorPrimary).setA(.06).toRgbString();
8685
+ const colorBgSkill = new _ant_design_fast_color.FastColor(colorPrimary).setA(.08).toRgbString();
8686
+ const colorBgSkillHover = new _ant_design_fast_color.FastColor(colorPrimary).setA(.15).toRgbString();
8687
+ const colorTextSlot = colorPrimary;
8688
+ const colorTextSlotPlaceholder = new _ant_design_fast_color.FastColor(colorPrimary).setA(.25).toRgbString();
8689
+ const colorBorderSlotHover = new _ant_design_fast_color.FastColor(colorPrimary).setA(.1).toRgbString();
8690
+ const colorBorderSlot = colorBgSlot;
7616
8691
  const colorBorderInput = new _ant_design_fast_color.FastColor(colorFillTertiary).setA(.1).toRgbString();
7617
8692
  const switchCheckedBg = new _ant_design_fast_color.FastColor(colorPrimary).setA(.08).toRgbString();
7618
8693
  const switchCheckedHoverBg = new _ant_design_fast_color.FastColor(colorPrimary).setA(.1).toRgbString();
7619
8694
  const switchUncheckedHoverBg = new _ant_design_fast_color.FastColor(colorFillTertiary).setA(.04).toRgbString();
7620
8695
  const colorBgActionsDisabled = new _ant_design_fast_color.FastColor(colorPrimary).setA(.45).toRgbString();
7621
8696
  return {
8697
+ colorBgSlot,
8698
+ colorBgSkill,
8699
+ colorBgSkillHover,
8700
+ colorTextSlot,
8701
+ colorTextSlotPlaceholder,
8702
+ colorBorderSlotHover,
8703
+ colorBorderSlot,
7622
8704
  colorBorderInput,
7623
8705
  switchCheckedBg,
7624
8706
  switchCheckedHoverBg,
@@ -7633,7 +8715,8 @@
7633
8715
  return [
7634
8716
  genSenderStyle(senderToken),
7635
8717
  genSenderHeaderStyle(senderToken),
7636
- genSenderSwitchStyle(senderToken)
8718
+ genSenderSwitchStyle(senderToken),
8719
+ genSlotTextAreaStyle(senderToken)
7637
8720
  ];
7638
8721
  }, prepareComponentToken$5);
7639
8722
  //#endregion
@@ -7645,7 +8728,7 @@
7645
8728
  SpeechButton: SpeechButton_default
7646
8729
  };
7647
8730
  var Sender_default = /* @__PURE__ */ (0, vue.defineComponent)({
7648
- name: "XSender",
8731
+ name: "AxSender",
7649
8732
  inheritAttrs: false,
7650
8733
  props: {
7651
8734
  prefixCls: {
@@ -7692,6 +8775,14 @@
7692
8775
  type: Boolean,
7693
8776
  default: false
7694
8777
  },
8778
+ slotConfig: {
8779
+ type: Array,
8780
+ default: void 0
8781
+ },
8782
+ skill: {
8783
+ type: Object,
8784
+ default: void 0
8785
+ },
7695
8786
  placeholder: {
7696
8787
  type: String,
7697
8788
  default: void 0
@@ -7790,21 +8881,40 @@
7790
8881
  const [hashId, cssVarCls] = style_default$5(prefixCls);
7791
8882
  const containerRef = (0, vue.ref)();
7792
8883
  const inputRef = (0, vue.ref)();
8884
+ const isSlotMode = (0, vue.computed)(() => Array.isArray(props.slotConfig) || !!props.skill?.value);
7793
8885
  const innerValue = (0, vue.ref)(props.defaultValue);
7794
8886
  const mergedValue = (0, vue.computed)(() => props.value ?? innerValue.value);
7795
- const triggerValueChange = (nextValue, event) => {
8887
+ const triggerValueChange = (nextValue, event, slotConfig, skill) => {
7796
8888
  innerValue.value = nextValue;
7797
- props.onChange?.(nextValue, event);
8889
+ props.onChange?.(nextValue, event, slotConfig, skill);
7798
8890
  };
8891
+ const submitDisabled = (0, vue.ref)(!mergedValue.value);
8892
+ (0, vue.watch)(() => mergedValue.value, (next) => {
8893
+ if (!isSlotMode.value) submitDisabled.value = !next;
8894
+ }, { immediate: true });
7799
8895
  const [speechPermission, triggerSpeech, speechRecording] = useSpeech((transcript) => {
8896
+ if (isSlotMode.value) {
8897
+ inputRef.value?.insert?.([{
8898
+ type: "text",
8899
+ value: transcript
8900
+ }]);
8901
+ return;
8902
+ }
7800
8903
  triggerValueChange(`${mergedValue.value} ${transcript}`);
7801
8904
  }, () => props.allowSpeech);
7802
8905
  const triggerSend = () => {
7803
- if (props.onSubmit && !props.loading && mergedValue.value) props.onSubmit(mergedValue.value);
8906
+ if (!props.onSubmit || props.loading || submitDisabled.value) return;
8907
+ const value = inputRef.value?.getValue?.() ?? { value: "" };
8908
+ const slotConfig = "slotConfig" in value ? value.slotConfig : void 0;
8909
+ const skill = "skill" in value ? value.skill : void 0;
8910
+ props.onSubmit(value.value, slotConfig, skill);
7804
8911
  };
7805
8912
  const triggerClear = () => {
8913
+ if (inputRef.value?.clear) {
8914
+ inputRef.value.clear();
8915
+ return;
8916
+ }
7806
8917
  triggerValueChange("");
7807
- inputRef.value?.clear();
7808
8918
  };
7809
8919
  expose({
7810
8920
  get nativeElement() {
@@ -7820,7 +8930,19 @@
7820
8930
  triggerClear();
7821
8931
  },
7822
8932
  insert(text, position) {
7823
- inputRef.value?.insert(text, position);
8933
+ if (isSlotMode.value) {
8934
+ const slotList = Array.isArray(text) ? text : [{
8935
+ type: "text",
8936
+ value: text
8937
+ }];
8938
+ inputRef.value?.insert?.(slotList, position);
8939
+ return;
8940
+ }
8941
+ const textValue = Array.isArray(text) ? text.map((config) => {
8942
+ if (config.type === "text") return config.value ?? "";
8943
+ return config.formatResult?.(config.props?.defaultValue) ?? "";
8944
+ }).join("") : text;
8945
+ inputRef.value?.insert?.(textValue, position);
7824
8946
  },
7825
8947
  getValue() {
7826
8948
  return inputRef.value?.getValue() ?? { value: "" };
@@ -7843,15 +8965,20 @@
7843
8965
  triggerSend,
7844
8966
  placeholder: props.placeholder,
7845
8967
  onFocus: props.onFocus,
7846
- onBlur: props.onBlur
8968
+ onBlur: props.onBlur,
8969
+ slotConfig: props.slotConfig,
8970
+ skill: props.skill,
8971
+ setSubmitDisabled: (disabled) => {
8972
+ submitDisabled.value = disabled;
8973
+ }
7847
8974
  })));
7848
8975
  const actionBtnCls = (0, vue.computed)(() => `${prefixCls.value}-actions-btn`);
7849
8976
  provideActionButtonContext((0, vue.computed)(() => ({
7850
8977
  prefixCls: actionBtnCls.value,
7851
8978
  onSend: triggerSend,
7852
- onSendDisabled: !mergedValue.value,
8979
+ onSendDisabled: submitDisabled.value,
7853
8980
  onClear: triggerClear,
7854
- onClearDisabled: !mergedValue.value,
8981
+ onClearDisabled: submitDisabled.value,
7855
8982
  onCancel: props.onCancel,
7856
8983
  onCancelDisabled: !props.loading,
7857
8984
  onSpeech: () => triggerSpeech(false),
@@ -7904,8 +9031,9 @@
7904
9031
  "class": [`${cls}-content`, props.classNames.content],
7905
9032
  "style": props.styles.content,
7906
9033
  "onMousedown": (e) => {
7907
- if (e.target !== containerRef.value?.querySelector(`.${cls}-input`)) e.preventDefault();
7908
- inputRef.value?.focus();
9034
+ const inputNode = containerRef.value?.querySelector(`.${cls}-input`);
9035
+ if (!isSlotMode.value && e.target !== inputNode) e.preventDefault();
9036
+ if (e.target === inputNode || e.target === containerRef.value) inputRef.value?.focus();
7909
9037
  }
7910
9038
  }, [
7911
9039
  prefixNode && (0, vue.createVNode)("div", {
@@ -7916,7 +9044,7 @@
7916
9044
  ],
7917
9045
  "style": [contextConfig.value.styles?.prefix, props.styles.prefix]
7918
9046
  }, [prefixNode]),
7919
- (0, vue.createVNode)(TextArea_default, { "ref": inputRef }, null),
9047
+ isSlotMode.value ? (0, vue.createVNode)(SlotTextArea_default, { "ref": inputRef }, null) : (0, vue.createVNode)(TextArea_default, { "ref": inputRef }, null),
7920
9048
  suffixNode && (0, vue.createVNode)("div", {
7921
9049
  "class": [
7922
9050
  actionListCls,
@@ -7941,7 +9069,7 @@
7941
9069
  //#endregion
7942
9070
  //#region components/sender/SenderHeader.tsx
7943
9071
  var SenderHeader_default = /* @__PURE__ */ (0, vue.defineComponent)({
7944
- name: "XSenderHeader",
9072
+ name: "AxSenderHeader",
7945
9073
  props: {
7946
9074
  open: {
7947
9075
  type: Boolean,
@@ -8045,7 +9173,7 @@
8045
9173
  //#endregion
8046
9174
  //#region components/sender/SenderSwitch.tsx
8047
9175
  var SenderSwitch_default = /* @__PURE__ */ (0, vue.defineComponent)({
8048
- name: "XSenderSwitch",
9176
+ name: "AxSenderSwitch",
8049
9177
  inheritAttrs: false,
8050
9178
  props: {
8051
9179
  prefixCls: {
@@ -8161,7 +9289,7 @@
8161
9289
  "class": [`${cls}-content`, props.classNames.content],
8162
9290
  "style": props.styles.content
8163
9291
  }, {
8164
- classNames: {
9292
+ classes: {
8165
9293
  icon: props.classNames.icon,
8166
9294
  content: props.classNames.title
8167
9295
  },
@@ -8416,7 +9544,7 @@
8416
9544
  //#endregion
8417
9545
  //#region components/sources/index.tsx
8418
9546
  var sources_default = /* @__PURE__ */ (0, vue.defineComponent)({
8419
- name: "XSources",
9547
+ name: "AxSources",
8420
9548
  inheritAttrs: false,
8421
9549
  props: {
8422
9550
  prefixCls: {
@@ -8681,20 +9809,24 @@
8681
9809
  case "ArrowDown":
8682
9810
  offsetRow(1);
8683
9811
  event.preventDefault();
9812
+ event.stopPropagation();
8684
9813
  break;
8685
9814
  case "ArrowUp":
8686
9815
  offsetRow(-1);
8687
9816
  event.preventDefault();
9817
+ event.stopPropagation();
8688
9818
  break;
8689
9819
  case "ArrowRight":
8690
9820
  if (rtl.value) offsetPrev();
8691
9821
  else offsetNext();
8692
9822
  event.preventDefault();
9823
+ event.stopPropagation();
8693
9824
  break;
8694
9825
  case "ArrowLeft":
8695
9826
  if (rtl.value) offsetNext();
8696
9827
  else offsetPrev();
8697
9828
  event.preventDefault();
9829
+ event.stopPropagation();
8698
9830
  break;
8699
9831
  case "Enter":
8700
9832
  event.preventDefault();
@@ -8720,7 +9852,7 @@
8720
9852
  //#endregion
8721
9853
  //#region components/suggestion/index.tsx
8722
9854
  var suggestion_default = /* @__PURE__ */ (0, vue.defineComponent)({
8723
- name: "XSuggestion",
9855
+ name: "AxSuggestion",
8724
9856
  inheritAttrs: false,
8725
9857
  props: {
8726
9858
  prefixCls: {
@@ -8998,7 +10130,7 @@
8998
10130
  //#endregion
8999
10131
  //#region components/think/index.tsx
9000
10132
  var think_default = /* @__PURE__ */ (0, vue.defineComponent)({
9001
- name: "XThink",
10133
+ name: "AxThink",
9002
10134
  inheritAttrs: false,
9003
10135
  props: {
9004
10136
  prefixCls: {
@@ -9408,7 +10540,7 @@
9408
10540
  return node !== null && node !== void 0 && node !== false;
9409
10541
  }
9410
10542
  var XThoughtChainItem = /* @__PURE__ */ (0, vue.defineComponent)({
9411
- name: "XThoughtChainItem",
10543
+ name: "AxThoughtChainItem",
9412
10544
  props: {
9413
10545
  prefixCls: {
9414
10546
  type: String,
@@ -9738,7 +10870,7 @@
9738
10870
  //#endregion
9739
10871
  //#region components/thought-chain/index.tsx
9740
10872
  var ThoughtChainWithSub = /* @__PURE__ */ (0, vue.defineComponent)({
9741
- name: "XThoughtChain",
10873
+ name: "AxThoughtChain",
9742
10874
  inheritAttrs: false,
9743
10875
  props: {
9744
10876
  prefixCls: {
@@ -9956,7 +11088,7 @@
9956
11088
  return Array.isArray(value) ? value.length > 0 : value !== null && value !== void 0;
9957
11089
  }
9958
11090
  var XWelcome = /* @__PURE__ */ (0, vue.defineComponent)({
9959
- name: "XWelcome",
11091
+ name: "AxWelcome",
9960
11092
  inheritAttrs: false,
9961
11093
  props: {
9962
11094
  prefixCls: {
@@ -10121,7 +11253,7 @@
10121
11253
  //#endregion
10122
11254
  //#region components/x-provider/index.tsx
10123
11255
  var XProvider = /* @__PURE__ */ (0, vue.defineComponent)({
10124
- name: "XProvider",
11256
+ name: "AxProvider",
10125
11257
  inheritAttrs: false,
10126
11258
  props: {
10127
11259
  attachments: {
@@ -10226,36 +11358,11 @@
10226
11358
  ThoughtChainWithSub,
10227
11359
  XThoughtChainItem
10228
11360
  ];
10229
- var componentAliases = new Map([
10230
- ["XBubble", ["ABubble"]],
10231
- ["XBubbleList", ["ABubbleList"]],
10232
- ["XBubbleSystem", ["ABubbleSystem"]],
10233
- ["XBubbleDivider", ["ABubbleDivider"]],
10234
- ["XActions", ["AActions"]],
10235
- ["XActionsAudio", ["AActionsAudio"]],
10236
- ["XActionsCopy", ["AActionsCopy"]],
10237
- ["XActionsFeedback", ["AActionsFeedback"]],
10238
- ["XActionsItem", ["AActionsItem"]],
10239
- ["XFileCard", ["AFileCard"]],
10240
- ["XFileCardList", ["AFileCardList"]],
10241
- ["XMermaid", ["AMermaid"]],
10242
- ["XAttachments", ["AAttachments"]],
10243
- ["XSender", ["ASender"]],
10244
- ["XSenderHeader", ["ASenderHeader"]],
10245
- ["XSenderSwitch", ["ASenderSwitch"]],
10246
- ["XSuggestion", ["ASuggestion"]],
10247
- ["XThink", ["AThink"]],
10248
- ["XThoughtChain", ["AThoughtChain"]],
10249
- ["XThoughtChainItem", ["AThoughtChainItem"]]
10250
- ]);
10251
11361
  var components_default = {
10252
11362
  install(app) {
10253
11363
  components.forEach((component) => {
10254
11364
  if (!component.name) return;
10255
11365
  app.component(component.name, component);
10256
- componentAliases.get(component.name)?.forEach((alias) => {
10257
- app.component(alias, component);
10258
- });
10259
11366
  });
10260
11367
  },
10261
11368
  version