@opentiny/tiny-robot 0.2.11 → 0.2.13

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.
@@ -13,6 +13,7 @@ const ce = /* @__PURE__ */ j({
13
13
  inheritAttrs: !1,
14
14
  __name: "index",
15
15
  props: {
16
+ appendTo: {},
16
17
  offset: {},
17
18
  placement: { default: "top-center" },
18
19
  preventOverflow: { type: Boolean },
@@ -84,7 +85,7 @@ const ce = /* @__PURE__ */ j({
84
85
  default: X(() => [
85
86
  e.show ? (d(), V(ee, {
86
87
  key: 0,
87
- to: te(D)
88
+ to: o.appendTo || te(D)
88
89
  }, [
89
90
  oe("div", k({
90
91
  class: "tr-base-popper",
@@ -100,7 +101,7 @@ const ce = /* @__PURE__ */ j({
100
101
  }, 16)
101
102
  ], 64));
102
103
  }
103
- }), ue = /* @__PURE__ */ ie(ce, [["__scopeId", "data-v-21605fe2"]]);
104
+ }), ue = /* @__PURE__ */ ie(ce, [["__scopeId", "data-v-9984ba18"]]);
104
105
  ue.name = "TrBasePopper";
105
106
  export {
106
107
  ue as default
@@ -1,22 +1,23 @@
1
- import { defineComponent as C, ref as g, computed as n, watch as R, createBlock as E, openBlock as a, unref as b, withCtx as v, createElementVNode as x, createElementBlock as _, Fragment as B, renderList as D, toDisplayString as M, renderSlot as H } from "vue";
1
+ import { defineComponent as C, ref as g, computed as n, watch as R, createBlock as E, openBlock as a, unref as x, withCtx as v, createElementVNode as B, createElementBlock as _, Fragment as T, renderList as D, toDisplayString as M, renderSlot as H } from "vue";
2
2
  import { o as L, c as k, d as P } from "../index2.js";
3
- import T from "../base-popper/index.js";
3
+ import b from "../base-popper/index.js";
4
4
  import { _ as I } from "../_plugin-vue_export-helper.js";
5
5
  const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__ */ C({
6
6
  __name: "index",
7
7
  props: {
8
+ appendTo: {},
8
9
  items: {},
9
10
  show: { type: Boolean },
10
11
  trigger: { default: "click" }
11
12
  },
12
13
  emits: ["item-click", "click-outside"],
13
14
  setup(l, { emit: w }) {
14
- const t = l, c = w, u = g(!1), r = n({
15
- get: () => t.trigger === "manual" ? t.show : u.value,
15
+ const t = l, c = w, p = g(!1), r = n({
16
+ get: () => t.trigger === "manual" ? t.show : p.value,
16
17
  set: (e) => {
17
- t.trigger !== "manual" && (u.value = e);
18
+ t.trigger !== "manual" && (p.value = e);
18
19
  }
19
- }), i = g(null), p = n(() => {
20
+ }), i = g(null), u = n(() => {
20
21
  var e;
21
22
  return (e = i.value) == null ? void 0 : e.triggerRef;
22
23
  }), d = n(() => {
@@ -29,11 +30,11 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
29
30
  (e) => {
30
31
  c("click-outside", e), r.value = !1;
31
32
  },
32
- { ignore: [p] }
33
+ { ignore: [u] }
33
34
  );
34
35
  else if (t.trigger === "hover") {
35
36
  const e = k(
36
- n(() => P(p.value)),
37
+ n(() => P(u.value)),
37
38
  { delayEnter: 100, delayLeave: 300 }
38
39
  ), m = k(d, { delayEnter: 100, delayLeave: 300 });
39
40
  R(
@@ -48,12 +49,13 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
48
49
  }, y = (e) => {
49
50
  r.value = !1, c("item-click", e);
50
51
  };
51
- return (e, m) => (a(), E(b(T), {
52
+ return (e, m) => (a(), E(x(b), {
52
53
  show: r.value,
53
54
  class: "tr-dropdown-menu",
54
55
  ref_key: "basePopperRef",
55
56
  ref: i,
56
57
  placement: "top-left",
58
+ "append-to": t.appendTo,
57
59
  offset: 8,
58
60
  "transition-props": { name: "tr-dropdown-menu" },
59
61
  "prevent-overflow": !0,
@@ -63,8 +65,8 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
63
65
  H(e.$slots, "trigger", {}, void 0, !0)
64
66
  ]),
65
67
  content: v(() => [
66
- x("ul", S, [
67
- (a(!0), _(B, null, D(t.items, (o) => (a(), _("li", {
68
+ B("ul", S, [
69
+ (a(!0), _(T, null, D(t.items, (o) => (a(), _("li", {
68
70
  class: "tr-dropdown-menu__list-item",
69
71
  key: o.id,
70
72
  onClick: (f) => y(o)
@@ -72,9 +74,9 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
72
74
  ])
73
75
  ]),
74
76
  _: 3
75
- }, 8, ["show", "trigger-events"]));
77
+ }, 8, ["show", "append-to", "trigger-events"]));
76
78
  }
77
- }), s = /* @__PURE__ */ I(F, [["__scopeId", "data-v-b5b6a7b9"]]);
79
+ }), s = /* @__PURE__ */ I(F, [["__scopeId", "data-v-ea33ed82"]]);
78
80
  s.name = "TrDropdownMenu";
79
81
  const N = function(l) {
80
82
  l.component(s.name, s);
package/dist/index.d.ts CHANGED
@@ -28,11 +28,9 @@ import { PublicProps } from 'vue';
28
28
  import { Ref } from 'vue';
29
29
  import { RendererElement } from 'vue';
30
30
  import { RendererNode } from 'vue';
31
- import { SetTemplateParams as SetTemplateParams_2 } from './index.type';
32
31
  import { ShallowUnwrapRef } from 'vue';
33
32
  import { Slot } from 'vue';
34
33
  import { SubmitTrigger as SubmitTrigger_2 } from './index.type';
35
- import { TemplateEditorProps as TemplateEditorProps_2 } from './index.type';
36
34
  import { ThemeType as ThemeType_2 } from './index.type';
37
35
  import { TooltipContentProps } from './components/Tooltip.vue';
38
36
  import { TransitionProps } from 'vue';
@@ -137,6 +135,7 @@ basePopperRef: ({
137
135
  $: ComponentInternalInstance;
138
136
  $data: {};
139
137
  $props: {
138
+ readonly appendTo?: (string | HTMLElement) | undefined;
140
139
  readonly offset?: number | {
141
140
  mainAxis?: number;
142
141
  crossAxis?: number;
@@ -165,6 +164,7 @@ $host: Element | null;
165
164
  $emit: (event: string, ...args: any[]) => void;
166
165
  $el: any;
167
166
  $options: ComponentOptionsBase<Readonly<{
167
+ appendTo?: string | HTMLElement;
168
168
  offset?: number | {
169
169
  mainAxis?: number;
170
170
  crossAxis?: number;
@@ -204,6 +204,7 @@ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...
204
204
  } & Readonly<{
205
205
  placement: "top-center" | "bottom-center" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
206
206
  }> & Omit<Readonly<{
207
+ appendTo?: string | HTMLElement;
207
208
  offset?: number | {
208
209
  mainAxis?: number;
209
210
  crossAxis?: number;
@@ -243,7 +244,6 @@ submit: () => void;
243
244
  startSpeech: () => void;
244
245
  stopSpeech: () => void;
245
246
  activateTemplateFirstField: () => void;
246
- setTemplate: (template: string, initialValues?: Record<string, string>) => void;
247
247
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
248
248
  [x: string]: any;
249
249
  } & {
@@ -260,7 +260,6 @@ autofocus: boolean;
260
260
  clearable: boolean;
261
261
  showWordLimit: boolean;
262
262
  theme: ThemeType_2;
263
- placeholder: string;
264
263
  hasContent: boolean;
265
264
  allowSpeech: boolean;
266
265
  allowFiles: boolean;
@@ -268,39 +267,27 @@ submitType: SubmitTrigger_2;
268
267
  stopText: string;
269
268
  autoSize: AutoSize_2;
270
269
  maxLength: number;
270
+ placeholder: string;
271
271
  suggestions: string[];
272
272
  suggestionPopupWidth: string | number;
273
- templateInitialValues: Record<string, string>;
273
+ templateData: UserItem[];
274
274
  }, {}, {}, {}, string, ComponentProvideOptions, false, {
275
275
  senderRef: HTMLDivElement;
276
276
  inputWrapperRef: HTMLDivElement;
277
277
  templateEditorRef: CreateComponentPublicInstanceWithMixins<Readonly<{
278
- value?: string;
279
- } & TemplateEditorProps_2> & Readonly<{
280
- onBlur?: ((event: FocusEvent) => any) | undefined;
281
- onFocus?: ((event: FocusEvent) => any) | undefined;
282
- onInput?: ((value: string) => any) | undefined;
283
- onSubmit?: ((value: string) => any) | undefined;
284
- "onContent-status"?: ((hasContent: boolean) => any) | undefined;
285
- "onEmpty-content"?: (() => any) | undefined;
286
- "onUpdate:value"?: ((value: string) => any) | undefined;
278
+ modelValue?: UserItem[];
279
+ }> & Readonly<{
280
+ onSubmit?: (() => any) | undefined;
281
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
287
282
  }>, {
288
- focus: () => void;
289
- resetFields: () => void;
283
+ clearHistory: () => void;
290
284
  activateFirstField: () => void;
291
- getValueFromDOM: () => string;
292
- setTemplate: (params: SetTemplateParams_2) => void;
293
285
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
294
- "update:value": (value: string) => any;
286
+ "update:modelValue": (value: UserItem[]) => any;
295
287
  } & {
296
- blur: (event: FocusEvent) => any;
297
- focus: (event: FocusEvent) => any;
298
- input: (value: string) => any;
299
- submit: (value: string) => any;
300
- "content-status": (hasContent: boolean) => any;
301
- "empty-content": () => any;
288
+ submit: () => any;
302
289
  }, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
303
- contentEditableRef: HTMLDivElement;
290
+ editorRef: HTMLDivElement;
304
291
  }, HTMLDivElement, ComponentProvideOptions, {
305
292
  P: {};
306
293
  B: {};
@@ -309,21 +296,13 @@ C: {};
309
296
  M: {};
310
297
  Defaults: {};
311
298
  }, Readonly<{
312
- value?: string;
313
- } & TemplateEditorProps_2> & Readonly<{
314
- onBlur?: ((event: FocusEvent) => any) | undefined;
315
- onFocus?: ((event: FocusEvent) => any) | undefined;
316
- onInput?: ((value: string) => any) | undefined;
317
- onSubmit?: ((value: string) => any) | undefined;
318
- "onContent-status"?: ((hasContent: boolean) => any) | undefined;
319
- "onEmpty-content"?: (() => any) | undefined;
320
- "onUpdate:value"?: ((value: string) => any) | undefined;
299
+ modelValue?: UserItem[];
300
+ }> & Readonly<{
301
+ onSubmit?: (() => any) | undefined;
302
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
321
303
  }>, {
322
- focus: () => void;
323
- resetFields: () => void;
304
+ clearHistory: () => void;
324
305
  activateFirstField: () => void;
325
- getValueFromDOM: () => string;
326
- setTemplate: (params: SetTemplateParams_2) => void;
327
306
  }, {}, {}, {}, {}> | null;
328
307
  inputRef: CreateComponentPublicInstanceWithMixins<Readonly<ExtractPropTypes< {
329
308
  _constants: {
@@ -1063,6 +1042,7 @@ declare function __VLS_template_3(): {
1063
1042
  $: ComponentInternalInstance;
1064
1043
  $data: {};
1065
1044
  $props: {
1045
+ readonly appendTo?: (string | HTMLElement) | undefined;
1066
1046
  readonly offset?: number | {
1067
1047
  mainAxis?: number;
1068
1048
  crossAxis?: number;
@@ -1091,6 +1071,7 @@ declare function __VLS_template_3(): {
1091
1071
  $emit: (event: string, ...args: any[]) => void;
1092
1072
  $el: any;
1093
1073
  $options: ComponentOptionsBase<Readonly<{
1074
+ appendTo?: string | HTMLElement;
1094
1075
  offset?: number | {
1095
1076
  mainAxis?: number;
1096
1077
  crossAxis?: number;
@@ -1130,6 +1111,7 @@ declare function __VLS_template_3(): {
1130
1111
  } & Readonly<{
1131
1112
  placement: "top-center" | "bottom-center" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
1132
1113
  }> & Omit<Readonly<{
1114
+ appendTo?: string | HTMLElement;
1133
1115
  offset?: number | {
1134
1116
  mainAxis?: number;
1135
1117
  crossAxis?: number;
@@ -1179,32 +1161,19 @@ declare function __VLS_template_5(): {
1179
1161
  senderRef: HTMLDivElement;
1180
1162
  inputWrapperRef: HTMLDivElement;
1181
1163
  templateEditorRef: CreateComponentPublicInstanceWithMixins<Readonly<{
1182
- value?: string;
1183
- } & TemplateEditorProps_2> & Readonly<{
1184
- onBlur?: ((event: FocusEvent) => any) | undefined;
1185
- onFocus?: ((event: FocusEvent) => any) | undefined;
1186
- onInput?: ((value: string) => any) | undefined;
1187
- onSubmit?: ((value: string) => any) | undefined;
1188
- "onContent-status"?: ((hasContent: boolean) => any) | undefined;
1189
- "onEmpty-content"?: (() => any) | undefined;
1190
- "onUpdate:value"?: ((value: string) => any) | undefined;
1164
+ modelValue?: UserItem[];
1165
+ }> & Readonly<{
1166
+ onSubmit?: (() => any) | undefined;
1167
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
1191
1168
  }>, {
1192
- focus: () => void;
1193
- resetFields: () => void;
1169
+ clearHistory: () => void;
1194
1170
  activateFirstField: () => void;
1195
- getValueFromDOM: () => string;
1196
- setTemplate: (params: SetTemplateParams_2) => void;
1197
1171
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
1198
- "update:value": (value: string) => any;
1172
+ "update:modelValue": (value: UserItem[]) => any;
1199
1173
  } & {
1200
- blur: (event: FocusEvent) => any;
1201
- focus: (event: FocusEvent) => any;
1202
- input: (value: string) => any;
1203
- submit: (value: string) => any;
1204
- "content-status": (hasContent: boolean) => any;
1205
- "empty-content": () => any;
1174
+ submit: () => any;
1206
1175
  }, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
1207
- contentEditableRef: HTMLDivElement;
1176
+ editorRef: HTMLDivElement;
1208
1177
  }, HTMLDivElement, ComponentProvideOptions, {
1209
1178
  P: {};
1210
1179
  B: {};
@@ -1213,21 +1182,13 @@ declare function __VLS_template_5(): {
1213
1182
  M: {};
1214
1183
  Defaults: {};
1215
1184
  }, Readonly<{
1216
- value?: string;
1217
- } & TemplateEditorProps_2> & Readonly<{
1218
- onBlur?: ((event: FocusEvent) => any) | undefined;
1219
- onFocus?: ((event: FocusEvent) => any) | undefined;
1220
- onInput?: ((value: string) => any) | undefined;
1221
- onSubmit?: ((value: string) => any) | undefined;
1222
- "onContent-status"?: ((hasContent: boolean) => any) | undefined;
1223
- "onEmpty-content"?: (() => any) | undefined;
1224
- "onUpdate:value"?: ((value: string) => any) | undefined;
1185
+ modelValue?: UserItem[];
1186
+ }> & Readonly<{
1187
+ onSubmit?: (() => any) | undefined;
1188
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
1225
1189
  }>, {
1226
- focus: () => void;
1227
- resetFields: () => void;
1190
+ clearHistory: () => void;
1228
1191
  activateFirstField: () => void;
1229
- getValueFromDOM: () => string;
1230
- setTemplate: (params: SetTemplateParams_2) => void;
1231
1192
  }, {}, {}, {}, {}> | null;
1232
1193
  inputRef: CreateComponentPublicInstanceWithMixins<Readonly<ExtractPropTypes< {
1233
1194
  _constants: {
@@ -1992,6 +1953,12 @@ declare interface BaseHistoryProps {
1992
1953
  selected?: string;
1993
1954
  }
1994
1955
 
1956
+ declare interface BaseTextItem {
1957
+ id: string;
1958
+ type: string;
1959
+ content: string;
1960
+ }
1961
+
1995
1962
  declare const Bubble: typeof _default_14 & {
1996
1963
  install: typeof bubbleInstall;
1997
1964
  };
@@ -2256,6 +2223,7 @@ export declare interface DropdownMenuItem {
2256
2223
  }
2257
2224
 
2258
2225
  export declare interface DropdownMenuProps {
2226
+ appendTo?: string | HTMLElement;
2259
2227
  items: DropdownMenuItem[];
2260
2228
  /**
2261
2229
  * 是否显示菜单,仅在 trigger 为 'manual' 时有效
@@ -2501,6 +2469,7 @@ declare interface QuestionProps {
2501
2469
 
2502
2470
  export declare type SenderEmits = {
2503
2471
  (e: 'update:modelValue', value: string): void;
2472
+ (e: 'update:templateData', value: UserItem[]): void;
2504
2473
  (e: 'submit', value: string): void;
2505
2474
  (e: 'clear'): void;
2506
2475
  (e: 'speech-start'): void;
@@ -2536,20 +2505,10 @@ export declare interface SenderProps {
2536
2505
  theme?: ThemeType;
2537
2506
  template?: string;
2538
2507
  hasContent?: boolean;
2539
- templateInitialValues?: Record<string, string>;
2508
+ templateData?: UserItem[];
2540
2509
  stopText?: string;
2541
2510
  }
2542
2511
 
2543
- /**
2544
- * 设置模板的参数接口
2545
- */
2546
- export declare interface SetTemplateParams {
2547
- /** 模板字符串,格式为普通文本与 [占位符] 的组合 */
2548
- template: string;
2549
- /** 字段初始值,键为占位符文本,值为初始内容 */
2550
- initialValues?: Record<string, string>;
2551
- }
2552
-
2553
2512
  export declare type SingleTabHistoryProps = {
2554
2513
  tabTitle: string;
2555
2514
  data: HistoryData;
@@ -2818,62 +2777,14 @@ export declare interface SuggestionProps {
2818
2777
  defaultExpanded?: boolean;
2819
2778
  }
2820
2779
 
2821
- /**
2822
- * 模板编辑器事件
2823
- */
2824
- export declare interface TemplateEditorEmits {
2825
- /** 输入事件 */
2826
- (e: 'input', value: string): void;
2827
- /** 内容变更状态 - 通知父组件是否有内容 */
2828
- (e: 'content-status', hasContent: boolean): void;
2829
- /** 提交事件 */
2830
- (e: 'submit', value: string): void;
2831
- /** 聚焦事件 */
2832
- (e: 'focus', event: FocusEvent): void;
2833
- /** 失焦事件 */
2834
- (e: 'blur', event: FocusEvent): void;
2835
- /** 模板内容为空时触发,通知父组件可以退出模板编辑模式 */
2836
- (e: 'empty-content'): void;
2780
+ declare interface TemplateItem extends BaseTextItem {
2781
+ type: 'template';
2782
+ prefix: string;
2783
+ suffix: string;
2837
2784
  }
2838
2785
 
2839
- /**
2840
- * 模板编辑器暴露的方法
2841
- */
2842
- export declare interface TemplateEditorExpose {
2843
- /** 聚焦到编辑器 */
2844
- focus: () => void;
2845
- /** 重置所有字段 */
2846
- resetFields: () => void;
2847
- /** 激活第一个字段 */
2848
- activateFirstField: () => void;
2849
- /** 获取当前DOM中的值 */
2850
- getValueFromDOM: () => string;
2851
- /** 设置模板和初始值 */
2852
- setTemplate: (params: SetTemplateParams) => void;
2853
- }
2854
-
2855
- /**
2856
- * 模板编辑器属性
2857
- */
2858
- export declare interface TemplateEditorProps {
2859
- /** 当前值 */
2860
- value?: string;
2861
- /** 是否自动聚焦 */
2862
- autofocus?: boolean;
2863
- }
2864
-
2865
- /**
2866
- * 模板部分定义
2867
- */
2868
- export declare interface TemplatePart {
2869
- /** 内容文本 */
2870
- content: string;
2871
- /** 是否为可编辑字段 */
2872
- isField: boolean;
2873
- /** 占位符文本 (当字段为空时显示) */
2874
- placeholder?: string;
2875
- /** 字段索引 (用于标识可编辑字段) */
2876
- fieldIndex?: number;
2786
+ declare interface TextItem extends BaseTextItem {
2787
+ type: 'text';
2877
2788
  }
2878
2789
 
2879
2790
  /**
@@ -2899,6 +2810,12 @@ export declare type TriggerHandler = (info: TriggerInfo) => void;
2899
2810
  /** 触发信息类型 */
2900
2811
  export declare type TriggerInfo = TriggerContext | false;
2901
2812
 
2813
+ export declare type UserItem = UserTextItem | UserTemplateItem;
2814
+
2815
+ export declare type UserTemplateItem = Pick<TemplateItem, 'type' | 'content'>;
2816
+
2817
+ export declare type UserTextItem = Omit<TextItem, 'id'>;
2818
+
2902
2819
  export declare interface WelcomeProps {
2903
2820
  title: string;
2904
2821
  description: string;