@opentiny/tiny-robot 0.2.7 → 0.2.9

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,59 +1,66 @@
1
- import { defineComponent as B, useCssVars as E, unref as f, useAttrs as N, computed as _, ref as m, watch as O, createElementBlock as o, openBlock as s, Fragment as w, createElementVNode as h, createVNode as W, normalizeStyle as v, normalizeClass as z, renderSlot as I, Transition as A, withCtx as F, createCommentVNode as H, renderList as L, toDisplayString as P } from "vue";
2
- import { c as g, o as U } from "../index2.js";
1
+ import { defineComponent as E, useCssVars as N, unref as w, useAttrs as O, computed as m, ref as p, watch as W, createElementBlock as r, openBlock as s, Fragment as h, createElementVNode as v, createVNode as z, normalizeStyle as k, normalizeClass as I, renderSlot as P, Transition as A, withCtx as F, createCommentVNode as H, renderList as L, toDisplayString as U } from "vue";
2
+ import { c as y, o as b } from "../index2.js";
3
3
  import { t as n } from "../utils.js";
4
- import { _ as b } from "../_plugin-vue_export-helper.js";
5
- const j = { class: "tr-dropdown-menu__list" }, q = ["onClick"], G = /* @__PURE__ */ B({
4
+ import { _ as j } from "../_plugin-vue_export-helper.js";
5
+ const q = { class: "tr-dropdown-menu__list" }, G = ["onClick"], J = /* @__PURE__ */ E({
6
6
  __name: "index",
7
7
  props: {
8
8
  items: {},
9
+ show: { type: Boolean },
10
+ trigger: { default: "click" },
9
11
  minWidth: { default: 160 },
10
12
  topOffset: { default: 0 }
11
13
  },
12
- emits: ["item-click"],
13
- setup(l, { emit: k }) {
14
- E((e) => ({
15
- d82a8430: f(n)(a.minWidth)
14
+ emits: ["item-click", "click-outside"],
15
+ setup(a, { emit: x }) {
16
+ N((e) => ({
17
+ "1cd1e3f9": w(n)(t.minWidth)
16
18
  }));
17
- const a = l, p = N(), y = _(() => p.style), t = m(!1), C = k, i = m(null), d = m(null), { x, y: $, update: S } = g(i), { width: D, height: T } = g(d), M = _(() => ({
18
- left: `min(${n(x.value)}, 100% - ${n(D.value)})`,
19
- top: `max(${n($.value)} - ${n(T.value)} + ${n(a.topOffset)} - 8px, 0px)`
19
+ const t = a, f = O(), C = m(() => f.style), _ = p(!1), o = m({
20
+ get: () => t.trigger === "manual" ? t.show : _.value,
21
+ set: (e) => {
22
+ t.trigger !== "manual" && (_.value = e);
23
+ }
24
+ }), g = x, i = p(null), u = p(null), { x: $, y: S, update: D } = y(i), { width: R, height: T } = y(u), B = m(() => ({
25
+ left: `min(${n($.value)}, 100% - ${n(R.value)})`,
26
+ top: `max(${n(S.value)} - ${n(T.value)} + ${n(t.topOffset)} - 8px, 0px)`
20
27
  }));
21
- U(d, (e) => {
22
- var u;
23
- (u = i.value) != null && u.contains(e.target) && e.stopPropagation(), t.value = !1;
24
- }), O(t, (e) => {
25
- e && S();
28
+ b(u, (e) => {
29
+ var c;
30
+ g("click-outside", e), t.trigger === "click" && ((c = i.value) != null && c.contains(e.target) && e.stopPropagation(), o.value = !1);
31
+ }), W(o, (e) => {
32
+ e && D();
26
33
  });
27
- const R = () => {
28
- t.value = !t.value;
34
+ const M = () => {
35
+ o.value = !o.value;
29
36
  }, V = (e) => {
30
- t.value = !1, C("item-click", e);
37
+ o.value = !1, g("item-click", e);
31
38
  };
32
- return (e, u) => (s(), o(w, null, [
33
- h("div", {
34
- class: z(["tr-dropdown-menu__wrapper", f(p).class]),
35
- style: v(y.value),
39
+ return (e, c) => (s(), r(h, null, [
40
+ v("div", {
41
+ class: I(["tr-dropdown-menu__wrapper", w(f).class]),
42
+ style: k(C.value),
36
43
  ref_key: "dropDownTriggerRef",
37
44
  ref: i,
38
- onClick: R
45
+ onPointerup: M
39
46
  }, [
40
- I(e.$slots, "default", {}, void 0, !0)
41
- ], 6),
42
- W(A, { name: "tr-dropdown-menu" }, {
47
+ P(e.$slots, "default", {}, void 0, !0)
48
+ ], 38),
49
+ z(A, { name: "tr-dropdown-menu" }, {
43
50
  default: F(() => [
44
- t.value ? (s(), o("div", {
51
+ o.value ? (s(), r("div", {
45
52
  key: 0,
46
53
  class: "tr-dropdown-menu",
47
- style: v(M.value),
54
+ style: k(B.value),
48
55
  ref_key: "dropdownMenuRef",
49
- ref: d
56
+ ref: u
50
57
  }, [
51
- h("ul", j, [
52
- (s(!0), o(w, null, L(a.items, (c) => (s(), o("li", {
58
+ v("ul", q, [
59
+ (s(!0), r(h, null, L(t.items, (d) => (s(), r("li", {
53
60
  class: "tr-dropdown-menu__list-item",
54
- key: c.id,
55
- onClick: (K) => V(c)
56
- }, P(c.text), 9, q))), 128))
61
+ key: d.id,
62
+ onClick: (Q) => V(d)
63
+ }, U(d.text), 9, G))), 128))
57
64
  ])
58
65
  ], 4)) : H("", !0)
59
66
  ]),
@@ -61,12 +68,12 @@ const j = { class: "tr-dropdown-menu__list" }, q = ["onClick"], G = /* @__PURE__
61
68
  })
62
69
  ], 64));
63
70
  }
64
- }), r = /* @__PURE__ */ b(G, [["__scopeId", "data-v-620f91f9"]]);
65
- r.name = "TrDropdownMenu";
66
- const J = function(l) {
67
- l.component(r.name, r);
71
+ }), l = /* @__PURE__ */ j(J, [["__scopeId", "data-v-8add3dc5"]]);
72
+ l.name = "TrDropdownMenu";
73
+ const K = function(a) {
74
+ a.component(l.name, l);
68
75
  };
69
- r.install = J;
76
+ l.install = K;
70
77
  export {
71
- r as default
78
+ l as default
72
79
  };
package/dist/index.d.ts CHANGED
@@ -73,17 +73,19 @@ declare const __VLS_component_11: DefineComponent<__VLS_PublicProps_3, {}, {}, {
73
73
  close: () => any;
74
74
  open: () => any;
75
75
  "item-click": (item: SuggestionItem_2<Record<string, unknown>>) => any;
76
+ "click-outside": (event: MouseEvent) => any;
76
77
  "group-click": (group: SuggestionGroup<Record<string, unknown>>) => any;
77
78
  }, string, PublicProps, Readonly<__VLS_PublicProps_3> & Readonly<{
78
79
  onClose?: (() => any) | undefined;
79
80
  onOpen?: (() => any) | undefined;
80
81
  "onItem-click"?: ((item: SuggestionItem_2<Record<string, unknown>>) => any) | undefined;
82
+ "onClick-outside"?: ((event: MouseEvent) => any) | undefined;
81
83
  "onGroup-click"?: ((group: SuggestionGroup<Record<string, unknown>>) => any) | undefined;
82
84
  "onUpdate:selectedGroup"?: ((value: string) => any) | undefined;
83
85
  }>, {
84
86
  title: string;
85
- topOffset: string | number;
86
87
  trigger: "click" | "manual";
88
+ topOffset: string | number;
87
89
  groupShowMoreTrigger: "click" | "hover";
88
90
  popoverWidth: string | number;
89
91
  popoverHeight: string | number;
@@ -121,9 +123,12 @@ declare const __VLS_component_2: DefineComponent<__VLS_PublicProps, {}, {}, {},
121
123
 
122
124
  declare const __VLS_component_3: DefineComponent<DropdownMenuProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
123
125
  "item-click": (item: DropdownMenuItem) => any;
126
+ "click-outside": (event: MouseEvent) => any;
124
127
  }, string, PublicProps, Readonly<DropdownMenuProps> & Readonly<{
125
128
  "onItem-click"?: ((item: DropdownMenuItem) => any) | undefined;
129
+ "onClick-outside"?: ((event: MouseEvent) => any) | undefined;
126
130
  }>, {
131
+ trigger: "click" | "manual";
127
132
  minWidth: string | number;
128
133
  topOffset: string | number;
129
134
  }, {}, {}, {}, string, ComponentProvideOptions, false, {
@@ -692,18 +697,18 @@ toggleExpand: () => void;
692
697
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
693
698
  close: () => any;
694
699
  select: (value: string, context?: TriggerContext | undefined) => any;
700
+ trigger: (handler: TriggerHandler) => any;
695
701
  "suggestion-select": (item: SuggestionItem) => any;
696
702
  "update:open": (value: boolean) => any;
697
- trigger: (handler: TriggerHandler) => any;
698
703
  "category-select": (category: Category) => any;
699
704
  "update:expanded": (expanded: boolean) => any;
700
705
  "fill-template": (template: string) => any;
701
706
  }, string, PublicProps, Readonly<SuggestionProps> & Readonly<{
702
707
  onClose?: (() => any) | undefined;
703
708
  onSelect?: ((value: string, context?: TriggerContext | undefined) => any) | undefined;
709
+ onTrigger?: ((handler: TriggerHandler) => any) | undefined;
704
710
  "onSuggestion-select"?: ((item: SuggestionItem) => any) | undefined;
705
711
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
706
- onTrigger?: ((handler: TriggerHandler) => any) | undefined;
707
712
  "onCategory-select"?: ((category: Category) => any) | undefined;
708
713
  "onUpdate:expanded"?: ((expanded: boolean) => any) | undefined;
709
714
  "onFill-template"?: ((template: string) => any) | undefined;
@@ -2031,10 +2036,12 @@ export { _default_9 as Welcome }
2031
2036
 
2032
2037
  export declare interface DropdownMenuEmits {
2033
2038
  (e: 'item-click', item: DropdownMenuItem): void;
2039
+ (e: 'click-outside', event: MouseEvent): void;
2034
2040
  }
2035
2041
 
2036
2042
  export declare interface DropdownMenuEvents {
2037
2043
  itemClick?: (item: DropdownMenuItem) => void;
2044
+ clickOutside?: (event: MouseEvent) => void;
2038
2045
  }
2039
2046
 
2040
2047
  export declare interface DropdownMenuItem {
@@ -2044,6 +2051,14 @@ export declare interface DropdownMenuItem {
2044
2051
 
2045
2052
  export declare interface DropdownMenuProps {
2046
2053
  items: DropdownMenuItem[];
2054
+ /**
2055
+ * 是否显示菜单,仅在 trigger 为 'manual' 时有效
2056
+ */
2057
+ show?: boolean;
2058
+ /**
2059
+ * 触发方式。默认值为 'click'
2060
+ */
2061
+ trigger?: 'click' | 'manual';
2047
2062
  minWidth?: string | number;
2048
2063
  topOffset?: string | number;
2049
2064
  }
@@ -2491,7 +2506,9 @@ export declare interface SuggestionPillsSlots {
2491
2506
  declare interface SuggestionPopoverEvents {
2492
2507
  itemClick?: (item: SuggestionItem_2) => void;
2493
2508
  groupClick?: (group: SuggestionGroup) => void;
2509
+ open?: () => void;
2494
2510
  close?: () => void;
2511
+ clickOutside?: (event: MouseEvent) => void;
2495
2512
  }
2496
2513
 
2497
2514
  declare interface SuggestionPopoverProps<T = Record<string, unknown>> {