@opentiny/tiny-robot 0.2.11 → 0.2.12

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,6 +1,6 @@
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";
2
- import { o as L, c as k, d as P } from "../index2.js";
3
- import T from "../base-popper/index.js";
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 D, renderList as M, toDisplayString as H, renderSlot as L } from "vue";
2
+ import { o as P, c as k, d as T } from "../index2.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",
@@ -16,30 +16,30 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
16
16
  set: (e) => {
17
17
  t.trigger !== "manual" && (u.value = e);
18
18
  }
19
- }), i = g(null), p = n(() => {
19
+ }), i = g(null), d = n(() => {
20
20
  var e;
21
21
  return (e = i.value) == null ? void 0 : e.triggerRef;
22
- }), d = n(() => {
22
+ }), p = n(() => {
23
23
  var e;
24
24
  return (e = i.value) == null ? void 0 : e.popperRef;
25
25
  });
26
26
  if (t.trigger === "click" || t.trigger === "manual")
27
- L(
28
- d,
27
+ P(
28
+ p,
29
29
  (e) => {
30
30
  c("click-outside", e), r.value = !1;
31
31
  },
32
- { ignore: [p] }
32
+ { ignore: [d] }
33
33
  );
34
34
  else if (t.trigger === "hover") {
35
35
  const e = k(
36
- n(() => P(p.value)),
36
+ n(() => T(d.value)),
37
37
  { delayEnter: 100, delayLeave: 300 }
38
- ), m = k(d, { delayEnter: 100, delayLeave: 300 });
38
+ ), f = k(p, { delayEnter: 100, delayLeave: 300 });
39
39
  R(
40
- () => [e.value, m.value],
41
- ([o, f]) => {
42
- r.value = o || f;
40
+ () => [e.value, f.value],
41
+ ([o, m]) => {
42
+ r.value = o || m;
43
43
  }
44
44
  );
45
45
  }
@@ -48,7 +48,7 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
48
48
  }, y = (e) => {
49
49
  r.value = !1, c("item-click", e);
50
50
  };
51
- return (e, m) => (a(), E(b(T), {
51
+ return (e, f) => (a(), E(x(b), {
52
52
  show: r.value,
53
53
  class: "tr-dropdown-menu",
54
54
  ref_key: "basePopperRef",
@@ -60,21 +60,21 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
60
60
  "trigger-events": { onClick: h }
61
61
  }, {
62
62
  trigger: v(() => [
63
- H(e.$slots, "trigger", {}, void 0, !0)
63
+ L(e.$slots, "trigger", {}, void 0, !0)
64
64
  ]),
65
65
  content: v(() => [
66
- x("ul", S, [
67
- (a(!0), _(B, null, D(t.items, (o) => (a(), _("li", {
66
+ B("ul", S, [
67
+ (a(!0), _(D, null, M(t.items, (o) => (a(), _("li", {
68
68
  class: "tr-dropdown-menu__list-item",
69
69
  key: o.id,
70
- onClick: (f) => y(o)
71
- }, M(o.text), 9, $))), 128))
70
+ onClick: (m) => y(o)
71
+ }, H(o.text), 9, $))), 128))
72
72
  ])
73
73
  ]),
74
74
  _: 3
75
75
  }, 8, ["show", "trigger-events"]));
76
76
  }
77
- }), s = /* @__PURE__ */ I(F, [["__scopeId", "data-v-b5b6a7b9"]]);
77
+ }), s = /* @__PURE__ */ I(F, [["__scopeId", "data-v-f8df9a66"]]);
78
78
  s.name = "TrDropdownMenu";
79
79
  const N = function(l) {
80
80
  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';
@@ -243,7 +241,6 @@ submit: () => void;
243
241
  startSpeech: () => void;
244
242
  stopSpeech: () => void;
245
243
  activateTemplateFirstField: () => void;
246
- setTemplate: (template: string, initialValues?: Record<string, string>) => void;
247
244
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
248
245
  [x: string]: any;
249
246
  } & {
@@ -260,7 +257,6 @@ autofocus: boolean;
260
257
  clearable: boolean;
261
258
  showWordLimit: boolean;
262
259
  theme: ThemeType_2;
263
- placeholder: string;
264
260
  hasContent: boolean;
265
261
  allowSpeech: boolean;
266
262
  allowFiles: boolean;
@@ -268,39 +264,27 @@ submitType: SubmitTrigger_2;
268
264
  stopText: string;
269
265
  autoSize: AutoSize_2;
270
266
  maxLength: number;
267
+ placeholder: string;
271
268
  suggestions: string[];
272
269
  suggestionPopupWidth: string | number;
273
- templateInitialValues: Record<string, string>;
270
+ templateData: UserItem[];
274
271
  }, {}, {}, {}, string, ComponentProvideOptions, false, {
275
272
  senderRef: HTMLDivElement;
276
273
  inputWrapperRef: HTMLDivElement;
277
274
  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;
275
+ modelValue?: UserItem[];
276
+ }> & Readonly<{
277
+ onSubmit?: (() => any) | undefined;
278
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
287
279
  }>, {
288
- focus: () => void;
289
- resetFields: () => void;
280
+ clearHistory: () => void;
290
281
  activateFirstField: () => void;
291
- getValueFromDOM: () => string;
292
- setTemplate: (params: SetTemplateParams_2) => void;
293
282
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
294
- "update:value": (value: string) => any;
283
+ "update:modelValue": (value: UserItem[]) => any;
295
284
  } & {
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;
285
+ submit: () => any;
302
286
  }, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
303
- contentEditableRef: HTMLDivElement;
287
+ editorRef: HTMLDivElement;
304
288
  }, HTMLDivElement, ComponentProvideOptions, {
305
289
  P: {};
306
290
  B: {};
@@ -309,21 +293,13 @@ C: {};
309
293
  M: {};
310
294
  Defaults: {};
311
295
  }, 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;
296
+ modelValue?: UserItem[];
297
+ }> & Readonly<{
298
+ onSubmit?: (() => any) | undefined;
299
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
321
300
  }>, {
322
- focus: () => void;
323
- resetFields: () => void;
301
+ clearHistory: () => void;
324
302
  activateFirstField: () => void;
325
- getValueFromDOM: () => string;
326
- setTemplate: (params: SetTemplateParams_2) => void;
327
303
  }, {}, {}, {}, {}> | null;
328
304
  inputRef: CreateComponentPublicInstanceWithMixins<Readonly<ExtractPropTypes< {
329
305
  _constants: {
@@ -1179,32 +1155,19 @@ declare function __VLS_template_5(): {
1179
1155
  senderRef: HTMLDivElement;
1180
1156
  inputWrapperRef: HTMLDivElement;
1181
1157
  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;
1158
+ modelValue?: UserItem[];
1159
+ }> & Readonly<{
1160
+ onSubmit?: (() => any) | undefined;
1161
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
1191
1162
  }>, {
1192
- focus: () => void;
1193
- resetFields: () => void;
1163
+ clearHistory: () => void;
1194
1164
  activateFirstField: () => void;
1195
- getValueFromDOM: () => string;
1196
- setTemplate: (params: SetTemplateParams_2) => void;
1197
1165
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
1198
- "update:value": (value: string) => any;
1166
+ "update:modelValue": (value: UserItem[]) => any;
1199
1167
  } & {
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;
1168
+ submit: () => any;
1206
1169
  }, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
1207
- contentEditableRef: HTMLDivElement;
1170
+ editorRef: HTMLDivElement;
1208
1171
  }, HTMLDivElement, ComponentProvideOptions, {
1209
1172
  P: {};
1210
1173
  B: {};
@@ -1213,21 +1176,13 @@ declare function __VLS_template_5(): {
1213
1176
  M: {};
1214
1177
  Defaults: {};
1215
1178
  }, 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;
1179
+ modelValue?: UserItem[];
1180
+ }> & Readonly<{
1181
+ onSubmit?: (() => any) | undefined;
1182
+ "onUpdate:modelValue"?: ((value: UserItem[]) => any) | undefined;
1225
1183
  }>, {
1226
- focus: () => void;
1227
- resetFields: () => void;
1184
+ clearHistory: () => void;
1228
1185
  activateFirstField: () => void;
1229
- getValueFromDOM: () => string;
1230
- setTemplate: (params: SetTemplateParams_2) => void;
1231
1186
  }, {}, {}, {}, {}> | null;
1232
1187
  inputRef: CreateComponentPublicInstanceWithMixins<Readonly<ExtractPropTypes< {
1233
1188
  _constants: {
@@ -1992,6 +1947,12 @@ declare interface BaseHistoryProps {
1992
1947
  selected?: string;
1993
1948
  }
1994
1949
 
1950
+ declare interface BaseTextItem {
1951
+ id: string;
1952
+ type: string;
1953
+ content: string;
1954
+ }
1955
+
1995
1956
  declare const Bubble: typeof _default_14 & {
1996
1957
  install: typeof bubbleInstall;
1997
1958
  };
@@ -2501,6 +2462,7 @@ declare interface QuestionProps {
2501
2462
 
2502
2463
  export declare type SenderEmits = {
2503
2464
  (e: 'update:modelValue', value: string): void;
2465
+ (e: 'update:templateData', value: UserItem[]): void;
2504
2466
  (e: 'submit', value: string): void;
2505
2467
  (e: 'clear'): void;
2506
2468
  (e: 'speech-start'): void;
@@ -2536,20 +2498,10 @@ export declare interface SenderProps {
2536
2498
  theme?: ThemeType;
2537
2499
  template?: string;
2538
2500
  hasContent?: boolean;
2539
- templateInitialValues?: Record<string, string>;
2501
+ templateData?: UserItem[];
2540
2502
  stopText?: string;
2541
2503
  }
2542
2504
 
2543
- /**
2544
- * 设置模板的参数接口
2545
- */
2546
- export declare interface SetTemplateParams {
2547
- /** 模板字符串,格式为普通文本与 [占位符] 的组合 */
2548
- template: string;
2549
- /** 字段初始值,键为占位符文本,值为初始内容 */
2550
- initialValues?: Record<string, string>;
2551
- }
2552
-
2553
2505
  export declare type SingleTabHistoryProps = {
2554
2506
  tabTitle: string;
2555
2507
  data: HistoryData;
@@ -2818,62 +2770,14 @@ export declare interface SuggestionProps {
2818
2770
  defaultExpanded?: boolean;
2819
2771
  }
2820
2772
 
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;
2773
+ declare interface TemplateItem extends BaseTextItem {
2774
+ type: 'template';
2775
+ prefix: string;
2776
+ suffix: string;
2837
2777
  }
2838
2778
 
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;
2779
+ declare interface TextItem extends BaseTextItem {
2780
+ type: 'text';
2877
2781
  }
2878
2782
 
2879
2783
  /**
@@ -2899,6 +2803,12 @@ export declare type TriggerHandler = (info: TriggerInfo) => void;
2899
2803
  /** 触发信息类型 */
2900
2804
  export declare type TriggerInfo = TriggerContext | false;
2901
2805
 
2806
+ export declare type UserItem = UserTextItem | UserTemplateItem;
2807
+
2808
+ export declare type UserTemplateItem = Pick<TemplateItem, 'type' | 'content'>;
2809
+
2810
+ export declare type UserTextItem = Omit<TextItem, 'id'>;
2811
+
2902
2812
  export declare interface WelcomeProps {
2903
2813
  title: string;
2904
2814
  description: string;