@antdv-next/x 1.2.2 → 1.2.3

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 (32) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.umd.js +13284 -863
  3. package/dist/mermaid/Mermaid.js +19 -4
  4. package/dist/package.js +1 -1
  5. package/dist/sender/Sender.d.ts +23 -5
  6. package/dist/sender/Sender.js +13 -3
  7. package/dist/sender/components/ActionButton.js +6 -3
  8. package/dist/sender/components/ClearButton.js +6 -3
  9. package/dist/sender/components/LoadingButton/index.js +6 -3
  10. package/dist/sender/components/SendButton.js +6 -3
  11. package/dist/sender/components/Skill.d.ts +11 -1
  12. package/dist/sender/components/Skill.js +31 -3
  13. package/dist/sender/components/SlotTextAreaProseMirror.js +1172 -0
  14. package/dist/sender/components/SpeechButton/index.js +6 -3
  15. package/dist/sender/components/TextArea.js +44 -3
  16. package/dist/sender/components/prosemirror/model.d.ts +15 -0
  17. package/dist/sender/components/prosemirror/model.js +276 -0
  18. package/dist/sender/components/prosemirror/value.d.ts +11 -0
  19. package/dist/sender/components/prosemirror/value.js +171 -0
  20. package/dist/sender/index.d.ts +2 -2
  21. package/dist/sender/interface.d.ts +14 -1
  22. package/dist/sender/style/slot-textarea.js +9 -2
  23. package/dist/thought-chain/style/index.d.ts +71 -3
  24. package/dist/thought-chain/style/index.js +25 -14
  25. package/dist/thought-chain/style/item.d.ts +5 -5
  26. package/dist/thought-chain/style/item.js +5 -5
  27. package/dist/thought-chain/style/thought-chain.d.ts +2 -1
  28. package/dist/thought-chain/style/thought-chain.js +8 -20
  29. package/es/antdv-next-x.esm.js +14983 -6917
  30. package/package.json +7 -1
  31. package/dist/sender/components/SlotTextArea.js +0 -808
  32. /package/dist/sender/components/{SlotTextArea.d.ts → SlotTextAreaProseMirror.d.ts} +0 -0
@@ -229,7 +229,7 @@ var XMermaid = /* @__PURE__ */ defineComponent({
229
229
  }
230
230
  function handleZoomIn() {
231
231
  if (mergedRenderType.value !== RenderType.Image) return;
232
- scale.value = Math.min(scale.value + .2, 3);
232
+ scale.value = scale.value + .2;
233
233
  }
234
234
  function handleZoomOut() {
235
235
  if (mergedRenderType.value !== RenderType.Image) return;
@@ -254,11 +254,26 @@ var XMermaid = /* @__PURE__ */ defineComponent({
254
254
  if (mergedRenderType.value !== RenderType.Image) return;
255
255
  const svgElement = graphRef.value?.querySelector("svg");
256
256
  if (!svgElement) return;
257
- const svgString = new XMLSerializer().serializeToString(svgElement);
257
+ const exportSvg = svgElement.cloneNode(true);
258
+ exportSvg.style.removeProperty("transform");
259
+ exportSvg.style.removeProperty("transform-origin");
260
+ exportSvg.style.removeProperty("transition");
261
+ exportSvg.style.removeProperty("cursor");
262
+ const viewBox = svgElement.viewBox.baseVal;
263
+ let width = viewBox.width || svgElement.width.baseVal.value;
264
+ let height = viewBox.height || svgElement.height.baseVal.value;
265
+ if (!width || !height) {
266
+ const bounds = svgElement.getBoundingClientRect();
267
+ width ||= bounds.width / scale.value;
268
+ height ||= bounds.height / scale.value;
269
+ }
270
+ if (!width || !height) return;
271
+ exportSvg.setAttribute("width", `${width}`);
272
+ exportSvg.setAttribute("height", `${height}`);
273
+ const svgString = new XMLSerializer().serializeToString(exportSvg);
258
274
  const canvas = document.createElement("canvas");
259
275
  const ctx = canvas.getContext("2d");
260
276
  if (!ctx) return;
261
- const { width, height } = svgElement.getBoundingClientRect();
262
277
  const dpr = globalThis.window?.devicePixelRatio || 1;
263
278
  canvas.width = width * dpr;
264
279
  canvas.height = height * dpr;
@@ -380,7 +395,7 @@ var XMermaid = /* @__PURE__ */ defineComponent({
380
395
  if (now - lastTime < 16) return;
381
396
  lastTime = now;
382
397
  const delta = event.deltaY > 0 ? -.1 : .1;
383
- scale.value = Math.max(.5, Math.min(3, scale.value + delta));
398
+ scale.value = Math.max(.5, scale.value + delta);
384
399
  };
385
400
  graphEl.addEventListener("wheel", wheelHandler, { passive: false });
386
401
  onCleanup(() => {
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.2.2";
2
+ var version = "1.2.3";
3
3
  //#endregion
4
4
  export { version };
@@ -1,5 +1,5 @@
1
1
  import { PropType, StyleValue, CSSProperties } from 'vue';
2
- import { AllowSpeech, BaseNode, NodeRender, SkillType, SlotConfigType, SubmitType } from './interface';
2
+ import { AllowSpeech, BaseNode, NodeRender, SenderCopyInfo, SenderPasteInfo, SkillType, SlotConfigType, SubmitType } from './interface';
3
3
  declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
4
  prefixCls: {
5
5
  type: StringConstructor;
@@ -111,13 +111,21 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
111
111
  default: undefined;
112
112
  };
113
113
  onPaste: {
114
- type: PropType<(event: ClipboardEvent) => void>;
114
+ type: PropType<(event: ClipboardEvent, info: SenderPasteInfo) => void>;
115
115
  default: undefined;
116
116
  };
117
117
  onPasteFile: {
118
118
  type: PropType<(files: FileList) => void>;
119
119
  default: undefined;
120
120
  };
121
+ onCopy: {
122
+ type: PropType<(event: ClipboardEvent, info: SenderCopyInfo) => void>;
123
+ default: undefined;
124
+ };
125
+ onCut: {
126
+ type: PropType<(event: ClipboardEvent, info: SenderCopyInfo) => void>;
127
+ default: undefined;
128
+ };
121
129
  onFocus: {
122
130
  type: PropType<(event: FocusEvent) => void>;
123
131
  default: undefined;
@@ -237,13 +245,21 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
237
245
  default: undefined;
238
246
  };
239
247
  onPaste: {
240
- type: PropType<(event: ClipboardEvent) => void>;
248
+ type: PropType<(event: ClipboardEvent, info: SenderPasteInfo) => void>;
241
249
  default: undefined;
242
250
  };
243
251
  onPasteFile: {
244
252
  type: PropType<(files: FileList) => void>;
245
253
  default: undefined;
246
254
  };
255
+ onCopy: {
256
+ type: PropType<(event: ClipboardEvent, info: SenderCopyInfo) => void>;
257
+ default: undefined;
258
+ };
259
+ onCut: {
260
+ type: PropType<(event: ClipboardEvent, info: SenderCopyInfo) => void>;
261
+ default: undefined;
262
+ };
247
263
  onFocus: {
248
264
  type: PropType<(event: FocusEvent) => void>;
249
265
  default: undefined;
@@ -265,7 +281,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
265
281
  styles: Record<string, CSSProperties>;
266
282
  footer: BaseNode | NodeRender;
267
283
  header: BaseNode | NodeRender;
268
- onPaste: (event: ClipboardEvent) => void;
284
+ onCopy: (event: ClipboardEvent, info: SenderCopyInfo) => void;
285
+ onCut: (event: ClipboardEvent, info: SenderCopyInfo) => void;
286
+ onPaste: (event: ClipboardEvent, info: SenderPasteInfo) => void;
269
287
  onFocus: (event: FocusEvent) => void;
270
288
  onBlur: (event: FocusEvent) => void;
271
289
  onChange: (value: string, event?: Event, slotConfig?: SlotConfigType[], skill?: SkillType) => void;
@@ -278,7 +296,6 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
278
296
  onKeyUp: (event: KeyboardEvent) => void;
279
297
  onKeyDown: (event: KeyboardEvent) => void | false;
280
298
  skill: SkillType;
281
- slotConfig: readonly SlotConfigType[];
282
299
  readOnly: boolean;
283
300
  autoSize: boolean | {
284
301
  minRows?: number;
@@ -286,6 +303,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
286
303
  };
287
304
  onCancel: () => void;
288
305
  submitType: SubmitType;
306
+ slotConfig: readonly SlotConfigType[];
289
307
  allowSpeech: AllowSpeech;
290
308
  onPasteFile: (files: FileList) => void;
291
309
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -4,7 +4,7 @@ import ClearButton_default from "./components/ClearButton.js";
4
4
  import LoadingButton_default from "./components/LoadingButton/index.js";
5
5
  import SendButton_default from "./components/SendButton.js";
6
6
  import { provideSenderContext } from "./context.js";
7
- import SlotTextArea_default from "./components/SlotTextArea.js";
7
+ import SlotTextAreaProseMirror_default from "./components/SlotTextAreaProseMirror.js";
8
8
  import SpeechButton_default from "./components/SpeechButton/index.js";
9
9
  import TextArea_default from "./components/TextArea.js";
10
10
  import useSpeech from "./hooks/use-speech.js";
@@ -155,6 +155,14 @@ var Sender_default = /* @__PURE__ */ defineComponent({
155
155
  type: Function,
156
156
  default: void 0
157
157
  },
158
+ onCopy: {
159
+ type: Function,
160
+ default: void 0
161
+ },
162
+ onCut: {
163
+ type: Function,
164
+ default: void 0
165
+ },
158
166
  onFocus: {
159
167
  type: Function,
160
168
  default: void 0
@@ -197,7 +205,7 @@ var Sender_default = /* @__PURE__ */ defineComponent({
197
205
  triggerValueChange(`${mergedValue.value} ${transcript}`);
198
206
  }, () => props.allowSpeech);
199
207
  const triggerSend = () => {
200
- if (!props.onSubmit || props.loading || submitDisabled.value) return;
208
+ if (!props.onSubmit || props.disabled || props.loading || submitDisabled.value) return;
201
209
  const value = inputRef.value?.getValue?.() ?? { value: "" };
202
210
  const slotConfig = "slotConfig" in value ? value.slotConfig : void 0;
203
211
  const skill = "skill" in value ? value.skill : void 0;
@@ -249,6 +257,8 @@ var Sender_default = /* @__PURE__ */ defineComponent({
249
257
  onKeyDown: props.onKeyDown,
250
258
  onPaste: props.onPaste,
251
259
  onPasteFile: props.onPasteFile,
260
+ onCopy: props.onCopy,
261
+ onCut: props.onCut,
252
262
  disabled: props.disabled,
253
263
  readOnly: props.readOnly,
254
264
  submitType: props.submitType,
@@ -338,7 +348,7 @@ var Sender_default = /* @__PURE__ */ defineComponent({
338
348
  ],
339
349
  "style": [contextConfig.value.styles?.prefix, props.styles.prefix]
340
350
  }, [prefixNode]),
341
- isSlotMode.value ? createVNode(SlotTextArea_default, { "ref": inputRef }, null) : createVNode(TextArea_default, { "ref": inputRef }, null),
351
+ isSlotMode.value ? createVNode(SlotTextAreaProseMirror_default, { "ref": inputRef }, null) : createVNode(TextArea_default, { "ref": inputRef }, null),
342
352
  suffixNode && createVNode("div", {
343
353
  "class": [
344
354
  actionListCls,
@@ -1,6 +1,9 @@
1
- import { computed, createVNode, defineComponent, inject, mergeProps, provide } from "vue";
1
+ import { computed, createVNode, defineComponent, inject, isVNode, mergeProps, provide } from "vue";
2
2
  import { Button } from "antdv-next";
3
3
  //#region components/sender/components/ActionButton.tsx
4
+ function _isSlot(s) {
5
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
6
+ }
4
7
  var ActionButtonContextKey = Symbol("action-button-context");
5
8
  function useActionButtonContext() {
6
9
  return inject(ActionButtonContextKey, computed(() => ({ prefixCls: "" })));
@@ -41,7 +44,7 @@ var ActionButton = /* @__PURE__ */ defineComponent({
41
44
  default: void 0
42
45
  }
43
46
  },
44
- setup(props, { attrs }) {
47
+ setup(props, { attrs, slots }) {
45
48
  const context = useActionButtonContext();
46
49
  const mergedDisabled = computed(() => {
47
50
  if (props.disabled !== void 0) return props.disabled;
@@ -70,7 +73,7 @@ var ActionButton = /* @__PURE__ */ defineComponent({
70
73
  if (typeof handler === "function") handler();
71
74
  attrs.onClick?.(e);
72
75
  }
73
- }), null);
76
+ }), _isSlot(slots) ? slots : { default: () => [slots] });
74
77
  };
75
78
  }
76
79
  });
@@ -1,12 +1,15 @@
1
1
  import ActionButton from "./ActionButton.js";
2
- import { createVNode, defineComponent, mergeProps } from "vue";
2
+ import { createVNode, defineComponent, isVNode, mergeProps } from "vue";
3
3
  import { ClearOutlined } from "@antdv-next/icons";
4
4
  //#region components/sender/components/ClearButton.tsx
5
+ function _isSlot(s) {
6
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
7
+ }
5
8
  var ClearButton_default = /* @__PURE__ */ defineComponent({
6
9
  name: "ClearButton",
7
10
  inheritAttrs: false,
8
- setup(_, { attrs }) {
9
- return () => createVNode(ActionButton, mergeProps({ "icon": createVNode(ClearOutlined, null, null) }, attrs, { "action": "onClear" }), null);
11
+ setup(_, { attrs, slots }) {
12
+ return () => createVNode(ActionButton, mergeProps({ "icon": createVNode(ClearOutlined, null, null) }, attrs, { "action": "onClear" }), _isSlot(slots) ? slots : { default: () => [slots] });
10
13
  }
11
14
  });
12
15
  //#endregion
@@ -1,12 +1,15 @@
1
1
  import ActionButton, { useActionButtonContext } from "../ActionButton.js";
2
2
  import StopLoading_default from "./StopLoading.js";
3
3
  import { classNames } from "@v-c/util";
4
- import { createVNode, defineComponent, mergeProps } from "vue";
4
+ import { createVNode, defineComponent, isVNode, mergeProps } from "vue";
5
5
  //#region components/sender/components/LoadingButton/index.tsx
6
+ function _isSlot(s) {
7
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
8
+ }
6
9
  var LoadingButton_default = /* @__PURE__ */ defineComponent({
7
10
  name: "LoadingButton",
8
11
  inheritAttrs: false,
9
- setup(_, { attrs }) {
12
+ setup(_, { attrs, slots }) {
10
13
  const context = useActionButtonContext();
11
14
  return () => {
12
15
  const { prefixCls } = context.value;
@@ -18,7 +21,7 @@ var LoadingButton_default = /* @__PURE__ */ defineComponent({
18
21
  }, attrs, {
19
22
  "class": classNames([attrs.class, `${prefixCls}-loading-button`]),
20
23
  "action": "onCancel"
21
- }), null);
24
+ }), _isSlot(slots) ? slots : { default: () => [slots] });
22
25
  };
23
26
  }
24
27
  });
@@ -1,16 +1,19 @@
1
1
  import ActionButton from "./ActionButton.js";
2
- import { createVNode, defineComponent, mergeProps } from "vue";
2
+ import { createVNode, defineComponent, isVNode, mergeProps } from "vue";
3
3
  import { ArrowUpOutlined } from "@antdv-next/icons";
4
4
  //#region components/sender/components/SendButton.tsx
5
+ function _isSlot(s) {
6
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
7
+ }
5
8
  var SendButton_default = /* @__PURE__ */ defineComponent({
6
9
  name: "SendButton",
7
10
  inheritAttrs: false,
8
- setup(_, { attrs }) {
11
+ setup(_, { attrs, slots }) {
9
12
  return () => createVNode(ActionButton, mergeProps({
10
13
  "icon": createVNode(ArrowUpOutlined, null, null),
11
14
  "type": "primary",
12
15
  "shape": "circle"
13
- }, attrs, { "action": "onSend" }), null);
16
+ }, attrs, { "action": "onSend" }), _isSlot(slots) ? slots : { default: () => [slots] });
14
17
  }
15
18
  });
16
19
  //#endregion
@@ -13,6 +13,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
13
13
  type: PropType<() => void>;
14
14
  required: true;
15
15
  };
16
+ disabled: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
16
20
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
17
21
  prefixCls: {
18
22
  type: StringConstructor;
@@ -26,5 +30,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
26
30
  type: PropType<() => void>;
27
31
  required: true;
28
32
  };
29
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
33
+ disabled: {
34
+ type: BooleanConstructor;
35
+ default: boolean;
36
+ };
37
+ }>> & Readonly<{}>, {
38
+ disabled: boolean;
39
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
30
40
  export default _default;
@@ -20,6 +20,10 @@ var Skill_default = /* @__PURE__ */ defineComponent({
20
20
  removeSkill: {
21
21
  type: Function,
22
22
  required: true
23
+ },
24
+ disabled: {
25
+ type: Boolean,
26
+ default: false
23
27
  }
24
28
  },
25
29
  setup(props) {
@@ -28,17 +32,41 @@ var Skill_default = /* @__PURE__ */ defineComponent({
28
32
  const closable = props.skill.closable;
29
33
  if (!closable) return null;
30
34
  const config = typeof closable === "boolean" ? {} : closable;
35
+ const disabled = !!(props.disabled || config.disabled);
31
36
  const closeIcon = config.closeIcon ?? createVNode(CloseOutlined, { "class": `${componentCls.value}-close-icon` }, null);
32
37
  return createVNode("div", {
33
- "class": classNames([`${componentCls.value}-close`, { [`${componentCls.value}-close-disabled`]: config.disabled }]),
38
+ "class": classNames([`${componentCls.value}-close`, { [`${componentCls.value}-close-disabled`]: disabled }]),
34
39
  "role": "button",
35
40
  "aria-label": "Close skill",
36
- "tabindex": 0,
41
+ "aria-disabled": disabled ? "true" : "false",
42
+ "tabindex": disabled ? -1 : 0,
37
43
  "onClick": (event) => {
38
- if (config.disabled) return;
39
44
  event.stopPropagation();
45
+ if (disabled) return;
40
46
  props.removeSkill();
41
47
  config.onClose?.(event);
48
+ },
49
+ "onKeydown": (event) => {
50
+ if (disabled) return;
51
+ if (event.key === "Enter" || event.key === " ") {
52
+ event.preventDefault();
53
+ event.stopPropagation();
54
+ const closeElement = event.currentTarget;
55
+ if (closeElement instanceof HTMLElement) closeElement.dispatchEvent(new MouseEvent("click", {
56
+ bubbles: true,
57
+ cancelable: true,
58
+ view: event.view,
59
+ detail: 1,
60
+ button: 0,
61
+ buttons: 0,
62
+ clientX: 0,
63
+ clientY: 0,
64
+ ctrlKey: event.ctrlKey,
65
+ altKey: event.altKey,
66
+ shiftKey: event.shiftKey,
67
+ metaKey: event.metaKey
68
+ }));
69
+ }
42
70
  }
43
71
  }, [closeIcon]);
44
72
  });