@antdv-next/x 0.0.2 → 0.0.4

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.
@@ -1,7 +1,5 @@
1
+ import { SenderFocusOptions } from '../interface';
1
2
  export type InsertPosition = "start" | "end" | "cursor";
2
- export interface SenderFocusOptions extends FocusOptions {
3
- cursor?: "start" | "end" | "all";
4
- }
5
3
  export interface TextAreaRef {
6
4
  nativeElement: HTMLTextAreaElement | null;
7
5
  focus: (options?: SenderFocusOptions) => void;
@@ -2,6 +2,7 @@ import { ComputedRef, InjectionKey } from 'vue';
2
2
  import { SenderProps } from './interface';
3
3
  export interface SenderContextValue extends SenderProps {
4
4
  triggerSend?: () => void;
5
+ setSubmitDisabled?: (disabled: boolean) => void;
5
6
  }
6
7
  export declare const SenderContextKey: InjectionKey<ComputedRef<SenderContextValue>>;
7
8
  export declare function useSenderContext(): ComputedRef<SenderContextValue>;
@@ -1,8 +1,8 @@
1
- import { SenderProps, SenderRef } from './interface';
1
+ import { SenderProps, SenderRef, SlotConfigType } from './interface';
2
2
  import { default as ForwardSender } from './Sender';
3
3
  import { default as SenderHeader } from './SenderHeader';
4
4
  import { default as SenderSwitch } from './SenderSwitch';
5
- export type { SenderProps, SenderRef };
5
+ export type { SenderProps, SenderRef, SlotConfigType };
6
6
  type CompoundedSender = typeof ForwardSender & {
7
7
  Header: typeof SenderHeader;
8
8
  Switch: typeof SenderSwitch;
@@ -120,7 +120,8 @@ export interface SenderProps {
120
120
  placeholder?: string;
121
121
  }
122
122
  export interface SenderFocusOptions extends FocusOptions {
123
- cursor?: "start" | "end" | "all";
123
+ cursor?: "start" | "end" | "all" | "slot";
124
+ key?: string;
124
125
  }
125
126
  export interface SenderRef {
126
127
  nativeElement: HTMLDivElement;
@@ -1,5 +1,12 @@
1
1
  import { FullToken, GetDefaultToken } from '../../theme/interface';
2
2
  export interface ComponentToken {
3
+ colorBgSlot: string;
4
+ colorTextSlot: string;
5
+ colorTextSlotPlaceholder: string;
6
+ colorBorderSlot: string;
7
+ colorBorderSlotHover: string;
8
+ colorBgSkill: string;
9
+ colorBgSkillHover: string;
3
10
  colorBorderInput: string;
4
11
  switchCheckedBg: string;
5
12
  switchCheckedHoverBg: string;
@@ -1,5 +1,6 @@
1
1
  import { genStyleHooks } from "../../theme/genStyleUtils.js";
2
2
  import genSenderHeaderStyle from "./header.js";
3
+ import genSlotTextAreaStyle from "./slot-textarea.js";
3
4
  import genSenderSwitchStyle from "./switch.js";
4
5
  import { mergeToken } from "@antdv-next/cssinjs/cssinjs-utils";
5
6
  import { FastColor } from "@ant-design/fast-color";
@@ -85,12 +86,26 @@ var genSenderStyle = (token) => {
85
86
  };
86
87
  var prepareComponentToken = (token) => {
87
88
  const { colorPrimary, colorFillTertiary } = token;
89
+ const colorBgSlot = new FastColor(colorPrimary).setA(.06).toRgbString();
90
+ const colorBgSkill = new FastColor(colorPrimary).setA(.08).toRgbString();
91
+ const colorBgSkillHover = new FastColor(colorPrimary).setA(.15).toRgbString();
92
+ const colorTextSlot = colorPrimary;
93
+ const colorTextSlotPlaceholder = new FastColor(colorPrimary).setA(.25).toRgbString();
94
+ const colorBorderSlotHover = new FastColor(colorPrimary).setA(.1).toRgbString();
95
+ const colorBorderSlot = colorBgSlot;
88
96
  const colorBorderInput = new FastColor(colorFillTertiary).setA(.1).toRgbString();
89
97
  const switchCheckedBg = new FastColor(colorPrimary).setA(.08).toRgbString();
90
98
  const switchCheckedHoverBg = new FastColor(colorPrimary).setA(.1).toRgbString();
91
99
  const switchUncheckedHoverBg = new FastColor(colorFillTertiary).setA(.04).toRgbString();
92
100
  const colorBgActionsDisabled = new FastColor(colorPrimary).setA(.45).toRgbString();
93
101
  return {
102
+ colorBgSlot,
103
+ colorBgSkill,
104
+ colorBgSkillHover,
105
+ colorTextSlot,
106
+ colorTextSlotPlaceholder,
107
+ colorBorderSlotHover,
108
+ colorBorderSlot,
94
109
  colorBorderInput,
95
110
  switchCheckedBg,
96
111
  switchCheckedHoverBg,
@@ -105,7 +120,8 @@ var style_default = genStyleHooks("Sender", (token) => {
105
120
  return [
106
121
  genSenderStyle(senderToken),
107
122
  genSenderHeaderStyle(senderToken),
108
- genSenderSwitchStyle(senderToken)
123
+ genSenderSwitchStyle(senderToken),
124
+ genSlotTextAreaStyle(senderToken)
109
125
  ];
110
126
  }, prepareComponentToken);
111
127
  //#endregion
@@ -0,0 +1,4 @@
1
+ import { SenderToken } from '.';
2
+ import { GenerateStyle } from '../../theme/interface';
3
+ declare const genSlotTextAreaStyle: GenerateStyle<SenderToken>;
4
+ export default genSlotTextAreaStyle;
@@ -0,0 +1,187 @@
1
+ import { unit } from "@antdv-next/cssinjs";
2
+ //#region components/sender/style/slot-textarea.ts
3
+ var genSlotTextAreaStyle = (token) => {
4
+ const { componentCls, antCls, calc } = token;
5
+ const slotCls = `${componentCls}-slot`;
6
+ const antInputCls = `${antCls}-input`;
7
+ const antDropdownCls = `${antCls}-dropdown-trigger`;
8
+ const slotInputCls = `${componentCls}-slot-input`;
9
+ const slotSelectCls = `${componentCls}-slot-select`;
10
+ const slotTagCls = `${componentCls}-slot-tag`;
11
+ const slotContentCls = `${componentCls}-slot-content`;
12
+ const skillCls = `${componentCls}-skill`;
13
+ return { [componentCls]: {
14
+ [`${componentCls}-input-slot`]: {
15
+ outline: "none",
16
+ cursor: "text",
17
+ whiteSpace: "pre-wrap",
18
+ width: "100%",
19
+ caretColor: token.colorPrimary,
20
+ fontSize: token.fontSize,
21
+ lineHeight: token.lineHeight,
22
+ [`&:empty::before`]: {
23
+ content: "attr(data-placeholder)",
24
+ color: token.colorTextPlaceholder
25
+ }
26
+ },
27
+ [`${slotCls}:not(${slotContentCls})`]: {
28
+ display: "inline-block",
29
+ verticalAlign: "middle",
30
+ alignItems: "center",
31
+ marginBlock: 1,
32
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
33
+ wordBreak: "break-all",
34
+ marginInline: token.marginXXS
35
+ },
36
+ [`${antInputCls}${slotInputCls}`]: {
37
+ height: "100%",
38
+ background: token.colorBgSlot,
39
+ outline: "none",
40
+ color: token.colorTextSlot,
41
+ borderRadius: token.borderRadius,
42
+ paddingInline: token.paddingXXS,
43
+ fontSize: "inherit",
44
+ lineHeight: "inherit",
45
+ position: "relative",
46
+ [`&::placeholder`]: {
47
+ color: token.colorTextSlotPlaceholder,
48
+ fontSize: "inherit",
49
+ lineHeight: "inherit"
50
+ }
51
+ },
52
+ [slotSelectCls]: {
53
+ fontSize: token.fontSize,
54
+ lineHeight: token.lineHeight,
55
+ paddingInline: token.paddingXXS,
56
+ transition: `border-color ${token.motionDurationMid}`,
57
+ position: "relative",
58
+ display: "inline-flex",
59
+ alignItems: "center",
60
+ cursor: "pointer",
61
+ background: token.colorBgSlot,
62
+ height: "100%",
63
+ boxSizing: "border-box",
64
+ borderRadius: token.borderRadius,
65
+ color: token.colorTextSlot,
66
+ border: `1px solid ${token.colorBorderSlot}`,
67
+ [`&.placeholder`]: { color: token.colorTextSlotPlaceholder },
68
+ [`&${antDropdownCls}-open`]: { borderColor: token.colorBorderSlotHover }
69
+ },
70
+ [`${slotSelectCls}-value`]: {
71
+ flex: 1,
72
+ fontSize: token.fontSize,
73
+ lineHeight: token.lineHeight,
74
+ [`&:empty::before`]: { content: "attr(data-placeholder)" }
75
+ },
76
+ [`${slotSelectCls}-arrow`]: {
77
+ marginInlineStart: token.marginXXS,
78
+ fontSize: token.fontSize,
79
+ lineHeight: token.lineHeight,
80
+ display: "inline-flex",
81
+ alignItems: "center",
82
+ justifyContent: "center"
83
+ },
84
+ [slotTagCls]: {
85
+ background: token.colorBgSlot,
86
+ border: `1px solid ${token.colorBorderSlot}`,
87
+ outline: "none",
88
+ color: token.colorTextSlot,
89
+ borderRadius: token.borderRadius,
90
+ padding: `0 ${unit(token.paddingXXS)}`,
91
+ fontSize: token.fontSize,
92
+ lineHeight: token.lineHeight,
93
+ height: "100%",
94
+ boxSizing: "border-box",
95
+ position: "relative",
96
+ cursor: "default"
97
+ },
98
+ [slotContentCls]: {
99
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
100
+ caretColor: token.colorPrimary,
101
+ background: token.colorBgSlot,
102
+ outline: "none",
103
+ color: token.colorTextSlot,
104
+ borderRadius: token.borderRadius,
105
+ paddingInline: token.paddingXXS,
106
+ boxSizing: "border-box",
107
+ verticalAlign: "middle",
108
+ fontSize: token.fontSize,
109
+ marginBlock: 1,
110
+ lineHeight: token.lineHeight,
111
+ display: "inline-block",
112
+ position: "relative",
113
+ cursor: "text",
114
+ [`&:empty`]: {
115
+ width: "fit-content",
116
+ [`&::after`]: {
117
+ display: "inline-block",
118
+ height: "inherit",
119
+ content: "attr(data-placeholder)",
120
+ color: token.colorTextSlotPlaceholder
121
+ }
122
+ }
123
+ },
124
+ [`${slotCls}-no-width`]: {
125
+ userSelect: "none",
126
+ width: "3px",
127
+ display: "inline-block",
128
+ lineHeight: "inherit"
129
+ },
130
+ [skillCls]: {
131
+ display: "inline-block",
132
+ verticalAlign: "baseline",
133
+ alignItems: "center",
134
+ marginBlock: 1,
135
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
136
+ wordBreak: "break-all",
137
+ paddingInlineEnd: 0,
138
+ paddingInlineStart: 0,
139
+ marginInlineEnd: 0,
140
+ marginInlineStart: -1,
141
+ [`&${skillCls}-empty`]: { [`&::after`]: {
142
+ display: "inline-block",
143
+ pointerEvents: "none",
144
+ height: "inherit",
145
+ content: "attr(data-placeholder)",
146
+ color: token.colorTextPlaceholder
147
+ } }
148
+ },
149
+ [`${skillCls}-wrapper`]: {
150
+ height: "100%",
151
+ display: "inline-flex"
152
+ },
153
+ [`${skillCls}-tag`]: {
154
+ paddingInline: token.paddingXS,
155
+ height: "100%",
156
+ backgroundColor: token.colorBgSkill,
157
+ borderRadius: token.borderRadius,
158
+ color: token.colorPrimary,
159
+ alignItems: "center",
160
+ fontWeight: 500,
161
+ display: "inline-flex",
162
+ cursor: "pointer",
163
+ gap: token.marginXXS,
164
+ transition: `background-color ${token.motionDurationMid}`,
165
+ [`&:hover`]: {
166
+ backgroundColor: token.colorBgSkillHover,
167
+ [`${skillCls}-close:not(${skillCls}-close-disabled)`]: { color: token.colorPrimaryHover }
168
+ }
169
+ },
170
+ [`${skillCls}-close`]: {
171
+ fontSize: token.fontSizeSM,
172
+ display: "inline-flex",
173
+ transition: `color ${token.motionDurationMid}`,
174
+ color: token.colorPrimary
175
+ },
176
+ [`${skillCls}-close-disabled`]: {
177
+ cursor: "not-allowed",
178
+ color: token.colorTextDisabled
179
+ },
180
+ [`${skillCls}-holder`]: {
181
+ width: token.marginXS,
182
+ height: "100%"
183
+ }
184
+ } };
185
+ };
186
+ //#endregion
187
+ export { genSlotTextAreaStyle as default };
@@ -37,20 +37,24 @@ function useActive(items, open, rtl, onCancel) {
37
37
  case "ArrowDown":
38
38
  offsetRow(1);
39
39
  event.preventDefault();
40
+ event.stopPropagation();
40
41
  break;
41
42
  case "ArrowUp":
42
43
  offsetRow(-1);
43
44
  event.preventDefault();
45
+ event.stopPropagation();
44
46
  break;
45
47
  case "ArrowRight":
46
48
  if (rtl.value) offsetPrev();
47
49
  else offsetNext();
48
50
  event.preventDefault();
51
+ event.stopPropagation();
49
52
  break;
50
53
  case "ArrowLeft":
51
54
  if (rtl.value) offsetNext();
52
55
  else offsetPrev();
53
56
  event.preventDefault();
57
+ event.stopPropagation();
54
58
  break;
55
59
  case "Enter":
56
60
  event.preventDefault();
@@ -105,15 +105,15 @@ declare const XProvider: import('vue').DefineComponent<import('vue').ExtractProp
105
105
  override?: import('../theme/context').DesignTokenProviderProps["override"];
106
106
  }) | undefined;
107
107
  iconPrefixCls: string;
108
- attachments: Pick<import('../attachments').AttachmentsProps<any>, "style" | "classes" | "styles"> | undefined;
109
- bubble: Pick<import('../bubble').BubbleProps<string>, "style" | "classes" | "styles"> | undefined;
110
- conversations: Pick<import('../conversations').ConversationsProps, "style" | "classes" | "styles" | "shortcutKeys"> | undefined;
111
- actions: Pick<import('../actions').ActionsProps, "style" | "classes" | "styles"> | undefined;
112
- fileCard: Pick<import('../file-card').FileCardProps, "style" | "classes" | "styles"> | undefined;
113
- mermaid: Pick<import('../mermaid').MermaidProps, "style" | "classes" | "styles"> | undefined;
114
- prompts: Pick<import('../prompts').PromptsProps, "style" | "classes" | "styles"> | undefined;
115
- suggestion: Pick<import('../suggestion').SuggestionProps<any>, "style" | "classes" | "styles"> | undefined;
116
- welcome: Pick<import('../welcome').WelcomeProps, "style" | "classes" | "styles"> | undefined;
108
+ attachments: Pick<import('..').AttachmentsProps<any>, "style" | "classes" | "styles"> | undefined;
109
+ bubble: Pick<import('..').BubbleProps<string>, "style" | "classes" | "styles"> | undefined;
110
+ conversations: Pick<import('..').ConversationsProps, "style" | "classes" | "styles" | "shortcutKeys"> | undefined;
111
+ actions: Pick<import('..').ActionsProps, "style" | "classes" | "styles"> | undefined;
112
+ fileCard: Pick<import('..').FileCardProps, "style" | "classes" | "styles"> | undefined;
113
+ mermaid: Pick<import('..').MermaidProps, "style" | "classes" | "styles"> | undefined;
114
+ prompts: Pick<import('..').PromptsProps, "style" | "classes" | "styles"> | undefined;
115
+ suggestion: Pick<import('..').SuggestionProps<any>, "style" | "classes" | "styles"> | undefined;
116
+ welcome: Pick<import('..').WelcomeProps, "style" | "classes" | "styles"> | undefined;
117
117
  locale: any;
118
118
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
119
119
  export { defaultPrefixCls, useXProviderContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antdv-next/x",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "files": [
5
5
  "dist",
6
6
  "global.d.ts"