@mlightcad/ui-components 0.0.7 → 0.0.8

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.
package/README.md CHANGED
@@ -6,8 +6,60 @@ This is one common UI component library based on Element Plus.
6
6
 
7
7
  The following components are included in this package.
8
8
 
9
+ - Tool Palette: one dockable, resizable, and floating window, which is quite similar to AutoCAD Tool Palette.
9
10
  - Toolbar: one toolbar which can be easily customized by one array of button data.
10
11
 
12
+ ### Tool Palette
13
+
14
+ AutoCAD uses [tool palettes](https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-167A8594-92CB-4FCC-B72C-0F546383E97C) to organize blocks, hatches, and custom tools in a tabbed window. Tool Palette component is quite similar to one in AutoCAD. It supports the following features.
15
+
16
+ - Dockable: dock to the left or right side of the window
17
+ - Folderable: roll open or closed as your need
18
+ - Auto-hide: roll open and closed as the cursor moves across it. When this option is cleared, the full tool palette stays open continuously.
19
+
20
+ <img src="./doc/palette.jpg" width="400" height="92" alt="Tool Palette Example">
21
+
22
+ You can customize tool palette by the following properties. More properties will be coming soon.
23
+
24
+ ```javascript
25
+ /**
26
+ * Properties of MlToolPalette component
27
+ */
28
+ interface Props {
29
+ /**
30
+ * The title of tool palette dialog
31
+ */
32
+ title?: string
33
+ }
34
+ ```
35
+
36
+ It is quite easy to use it.
37
+
38
+ ```javascript
39
+ <script lang="ts" setup>
40
+ import { MlToolPalette } from '@mlightcad/ui-components'
41
+ const toolPaletteVisible = ref<boolean>(false)
42
+ </script>
43
+
44
+ <template>
45
+ <ml-tool-palette
46
+ class="tool-palette"
47
+ v-model="toolPaletteVisible"
48
+ title="Tool Palette Test"
49
+ >
50
+ <span>Tool Palette Test</span>
51
+ </ml-tool-palette>
52
+ </template>
53
+
54
+ <style scoped>
55
+ .tool-palette {
56
+ position: fixed;
57
+ top: 55px;
58
+ width: 400px;
59
+ }
60
+ </style>
61
+ ```
62
+
11
63
  ### Toolbar
12
64
 
13
65
  Toolbar component has the followiing features.
@@ -1,26 +1,83 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ml-dropdown-icon[data-v-05cd92db],.ml-dropdown-icon[data-v-05cd92db]:hover{outline:none;border:none}.ml-vertical-toolbar-button-group[data-v-7e12291d]{display:flex;flex-direction:column}.ml-horizontal-toolbar-button-group[data-v-7e12291d]{display:flex;flex-direction:row}.ml-toolbar-button[data-v-7e12291d]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:5px}.ml-toolbar-button-text[data-v-7e12291d]{margin-left:0;margin-top:5px}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { ElIcon as k, ElDropdownItem as B, ElDropdownMenu as S, ElDropdown as V, ElButton as D, ElTooltip as N, ElButtonGroup as $ } from "element-plus/es";
1
+ (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ml-dropdown-icon[data-v-3fc33b5d],.ml-dropdown-icon[data-v-3fc33b5d]:hover{outline:none;border:none}.ml-vertical-toolbar-button-group[data-v-27b5412a]{display:flex;flex-direction:column}.ml-horizontal-toolbar-button-group[data-v-27b5412a]{display:flex;flex-direction:row}.ml-toolbar-button[data-v-27b5412a]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:5px}.ml-toolbar-button-text[data-v-27b5412a]{margin-left:0;margin-top:5px}.ml-tool-palette-dialog[data-v-d69f63b3]{cursor:default;width:300px;min-width:var(--collapsed-width);position:absolute;border:1px solid;border-radius:4px}.ml-tool-palette-dialog-icon[data-v-d69f63b3]{border-bottom:1px solid}.ml-tool-palette-dialog-layout[data-v-d69f63b3]{display:flex;height:100%}.ml-tool-palette-title-bar[data-v-d69f63b3]{width:var(--collapsed-width);display:flex;justify-content:left;align-items:center;cursor:move;writing-mode:vertical-rl;text-align:center;border:1px}.ml-tool-palette-title[data-v-d69f63b3]{pointer-events:none;margin-top:10px;margin-bottom:10px;font-size:small;-webkit-user-select:none;user-select:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ml-tool-palette-content[data-v-d69f63b3]{pointer-events:none;-webkit-user-select:none;user-select:none;flex-grow:1;display:flex;justify-content:space-around;align-items:center;background-color:#fff;overflow:hidden}.ml-tool-palette-dialog-layout.left .ml-tool-palette-title-bar[data-v-d69f63b3]{order:1}.ml-tool-palette-dialog-layout.left .ml-tool-palette-content[data-v-d69f63b3],.ml-tool-palette-dialog-layout.right .ml-tool-palette-title-bar[data-v-d69f63b3]{order:2}.ml-tool-palette-dialog-layout.right .ml-tool-palette-content[data-v-d69f63b3]{order:1}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import { ElIcon as S, ElDropdownItem as ee, ElDropdownMenu as te, ElDropdown as le, ElButton as ne, ElTooltip as oe, ElButtonGroup as ie } from "element-plus/es";
3
3
  import "element-plus/es/components/base/style/css";
4
+ import "element-plus/es/components/icon/style/css";
5
+ import { openBlock as _, createElementBlock as b, createElementVNode as g, defineComponent as D, mergeModels as W, useModel as N, computed as L, createBlock as E, withCtx as M, resolveDynamicComponent as se, createVNode as $, Fragment as O, renderList as F, createTextVNode as ae, toDisplayString as A, pushScopeId as j, popScopeId as q, normalizeClass as J, normalizeStyle as K, createCommentVNode as Q, ref as f, onMounted as I, nextTick as H, watch as C, onBeforeUnmount as Z, onUnmounted as R, unref as ue, renderSlot as ce } from "vue";
4
6
  import "element-plus/es/components/dropdown/style/css";
5
7
  import "element-plus/es/components/dropdown-menu/style/css";
6
8
  import "element-plus/es/components/dropdown-item/style/css";
7
- import "element-plus/es/components/icon/style/css";
8
- import { defineComponent as w, computed as p, openBlock as n, createBlock as u, withCtx as c, createVNode as v, createElementBlock as g, Fragment as z, renderList as M, createTextVNode as G, toDisplayString as C, pushScopeId as H, popScopeId as R, createElementVNode as f, normalizeClass as Y, normalizeStyle as F, createCommentVNode as O } from "vue";
9
9
  import "element-plus/es/components/button-group/style/css";
10
10
  import "element-plus/es/components/tooltip/style/css";
11
11
  import "element-plus/es/components/button/style/css";
12
- const j = (t) => (H("data-v-05cd92db"), t = t(), R(), t), q = /* @__PURE__ */ j(() => /* @__PURE__ */ f("svg", {
12
+ const re = {
13
+ xmlns: "http://www.w3.org/2000/svg",
14
+ width: "1em",
15
+ height: "1em",
16
+ viewBox: "0 0 1024 1024"
17
+ }, ve = /* @__PURE__ */ g("path", {
18
+ fill: "currentColor",
19
+ d: "M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.59 30.59 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.59 30.59 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0"
20
+ }, null, -1), de = [
21
+ ve
22
+ ];
23
+ function me(e, l) {
24
+ return _(), b("svg", re, [...de]);
25
+ }
26
+ const X = { render: me }, he = {
27
+ xmlns: "http://www.w3.org/2000/svg",
28
+ width: "1em",
29
+ height: "1em",
30
+ viewBox: "0 0 1024 1024"
31
+ }, pe = /* @__PURE__ */ g("path", {
32
+ fill: "currentColor",
33
+ d: "M340.864 149.312a30.59 30.59 0 0 0 0 42.752L652.736 512 340.864 831.872a30.59 30.59 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"
34
+ }, null, -1), fe = [
35
+ pe
36
+ ];
37
+ function _e(e, l) {
38
+ return _(), b("svg", he, [...fe]);
39
+ }
40
+ const U = { render: _e }, we = /* @__PURE__ */ D({
41
+ __name: "MlCollapse",
42
+ props: /* @__PURE__ */ W({
43
+ size: { default: 18 },
44
+ reverse: { type: Boolean, default: !1 }
45
+ }, {
46
+ modelValue: { default: !0 },
47
+ modelModifiers: {}
48
+ }),
49
+ emits: /* @__PURE__ */ W({
50
+ change: null
51
+ }, ["update:modelValue"]),
52
+ setup(e, { emit: l }) {
53
+ const n = e, t = N(e, "modelValue"), o = l, c = L(() => n.reverse ? t.value ? X : U : t.value ? U : X), s = L(() => `${n.size}px`), v = () => {
54
+ o("change", t.value), t.value = !t.value;
55
+ };
56
+ return (u, h) => {
57
+ const r = S;
58
+ return _(), E(r, {
59
+ size: s.value,
60
+ onClick: v
61
+ }, {
62
+ default: M(() => [
63
+ (_(), E(se(c.value)))
64
+ ]),
65
+ _: 1
66
+ }, 8, ["size"]);
67
+ };
68
+ }
69
+ }), xe = (e) => (j("data-v-3fc33b5d"), e = e(), q(), e), Le = /* @__PURE__ */ xe(() => /* @__PURE__ */ g("svg", {
13
70
  preserveAspectRatio: "xMidYMid meet",
14
71
  viewBox: "0 0 24 24",
15
72
  width: "1.2em",
16
73
  height: "1.2em",
17
74
  "data-v-63d067da": ""
18
75
  }, [
19
- /* @__PURE__ */ f("path", {
76
+ /* @__PURE__ */ g("path", {
20
77
  fill: "currentColor",
21
78
  d: "m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"
22
79
  })
23
- ], -1)), J = /* @__PURE__ */ w({
80
+ ], -1)), ge = /* @__PURE__ */ D({
24
81
  __name: "MlDropdown",
25
82
  props: {
26
83
  icon: {},
@@ -30,22 +87,22 @@ const j = (t) => (H("data-v-05cd92db"), t = t(), R(), t), q = /* @__PURE__ */ j(
30
87
  emits: {
31
88
  click: null
32
89
  },
33
- setup(t, { emit: r }) {
34
- const e = t, a = r, s = p(() => e.items.filter((l) => l.name !== e.current)), i = (l) => {
35
- a("click", l);
90
+ setup(e, { emit: l }) {
91
+ const n = e, t = l, o = L(() => n.items.filter((s) => s.name !== n.current)), c = (s) => {
92
+ t("click", s);
36
93
  };
37
- return (l, x) => {
38
- const _ = k, h = B, o = S, b = V;
39
- return n(), u(b, { onCommand: i }, {
40
- dropdown: c(() => [
41
- v(o, null, {
42
- default: c(() => [
43
- (n(!0), g(z, null, M(s.value, (d) => (n(), u(h, {
44
- key: d.text,
45
- command: d.name
94
+ return (s, v) => {
95
+ const u = S, h = ee, r = te, i = le;
96
+ return _(), E(i, { onCommand: c }, {
97
+ dropdown: M(() => [
98
+ $(r, null, {
99
+ default: M(() => [
100
+ (_(!0), b(O, null, F(o.value, (a) => (_(), E(h, {
101
+ key: a.text,
102
+ command: a.name
46
103
  }, {
47
- default: c(() => [
48
- G(C(d.text), 1)
104
+ default: M(() => [
105
+ ae(A(a.text), 1)
49
106
  ]),
50
107
  _: 2
51
108
  }, 1032, ["command"]))), 128))
@@ -53,13 +110,13 @@ const j = (t) => (H("data-v-05cd92db"), t = t(), R(), t), q = /* @__PURE__ */ j(
53
110
  _: 1
54
111
  })
55
112
  ]),
56
- default: c(() => [
57
- v(_, {
113
+ default: M(() => [
114
+ $(u, {
58
115
  size: "30",
59
116
  class: "ml-dropdown-icon"
60
117
  }, {
61
- default: c(() => [
62
- q
118
+ default: M(() => [
119
+ Le
63
120
  ]),
64
121
  _: 1
65
122
  })
@@ -68,12 +125,12 @@ const j = (t) => (H("data-v-05cd92db"), t = t(), R(), t), q = /* @__PURE__ */ j(
68
125
  });
69
126
  };
70
127
  }
71
- }), L = (t, r) => {
72
- const e = t.__vccOpts || t;
73
- for (const [a, s] of r)
74
- e[a] = s;
75
- return e;
76
- }, y = /* @__PURE__ */ L(J, [["__scopeId", "data-v-05cd92db"]]), K = '<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" width="1.2em" height="1.2em" data-v-63d067da=""><path fill="currentColor" d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"></path></svg>', P = /* @__PURE__ */ w({
128
+ }), G = (e, l) => {
129
+ const n = e.__vccOpts || e;
130
+ for (const [t, o] of l)
131
+ n[t] = o;
132
+ return n;
133
+ }, Y = /* @__PURE__ */ G(ge, [["__scopeId", "data-v-3fc33b5d"]]), Me = '<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" width="1.2em" height="1.2em" data-v-63d067da=""><path fill="currentColor" d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"></path></svg>', ye = /* @__PURE__ */ D({
77
134
  __name: "MlLanguage",
78
135
  props: {
79
136
  languages: {},
@@ -82,21 +139,21 @@ const j = (t) => (H("data-v-05cd92db"), t = t(), R(), t), q = /* @__PURE__ */ j(
82
139
  emits: {
83
140
  click: null
84
141
  },
85
- setup(t, { emit: r }) {
86
- const e = t, a = r, s = (i) => {
87
- a("click", i);
142
+ setup(e, { emit: l }) {
143
+ const n = e, t = l, o = (c) => {
144
+ t("click", c);
88
145
  };
89
- return (i, l) => (n(), u(y, {
90
- icon: K,
91
- items: e.languages,
92
- current: e.current,
93
- onClick: s
146
+ return (c, s) => (_(), E(Y, {
147
+ icon: Me,
148
+ items: n.languages,
149
+ current: n.current,
150
+ onClick: o
94
151
  }, null, 8, ["items", "current"]));
95
152
  }
96
- }), Q = {
153
+ }), ze = {
97
154
  key: 0,
98
155
  class: "ml-toolbar-button-text"
99
- }, U = /* @__PURE__ */ w({
156
+ }, Ee = /* @__PURE__ */ D({
100
157
  __name: "MlToolbar",
101
158
  props: {
102
159
  items: {},
@@ -106,43 +163,43 @@ const j = (t) => (H("data-v-05cd92db"), t = t(), R(), t), q = /* @__PURE__ */ j(
106
163
  emits: {
107
164
  click: null
108
165
  },
109
- setup(t, { emit: r }) {
110
- const e = t, a = r, s = p(() => e.direction === "vertical" ? "ml-vertical-toolbar-button-group" : "ml-horizontal-toolbar-button-group"), i = p(() => e.size === "small" ? 20 : 30), l = p(() => {
111
- switch (e.size) {
166
+ setup(e, { emit: l }) {
167
+ const n = e, t = l, o = L(() => n.direction === "vertical" ? "ml-vertical-toolbar-button-group" : "ml-horizontal-toolbar-button-group"), c = L(() => n.size === "small" ? 20 : 30), s = L(() => {
168
+ switch (n.size) {
112
169
  case "small":
113
170
  return 30;
114
171
  case "medium":
115
172
  return 50;
116
173
  }
117
174
  return 70;
118
- }), x = (o) => o.description ? o.description : o.text, _ = p(() => e.size === "large"), h = (o) => {
119
- a("click", o);
175
+ }), v = (r) => r.description ? r.description : r.text, u = L(() => n.size === "large"), h = (r) => {
176
+ t("click", r);
120
177
  };
121
- return (o, b) => {
122
- const d = k, E = D, I = N, T = $;
123
- return n(), u(T, {
124
- class: Y(s.value)
178
+ return (r, i) => {
179
+ const a = S, p = ne, x = oe, y = ie;
180
+ return _(), E(y, {
181
+ class: J(o.value)
125
182
  }, {
126
- default: c(() => [
127
- (n(!0), g(z, null, M(o.items, (m, A) => (n(), u(I, {
128
- key: m.text,
129
- content: x(m),
183
+ default: M(() => [
184
+ (_(!0), b(O, null, F(r.items, (w, d) => (_(), E(x, {
185
+ key: w.text,
186
+ content: v(w),
130
187
  "hide-after": 0
131
188
  }, {
132
- default: c(() => [
133
- (n(), u(E, {
189
+ default: M(() => [
190
+ (_(), E(p, {
134
191
  class: "ml-toolbar-button",
135
- style: F({ width: l.value + "px", height: l.value + "px" }),
136
- key: A,
137
- onClick: (X) => h(m.command)
192
+ style: K({ width: s.value + "px", height: s.value + "px" }),
193
+ key: d,
194
+ onClick: (m) => h(w.command)
138
195
  }, {
139
- default: c(() => [
140
- f("div", null, [
141
- v(d, {
142
- size: i.value,
143
- innerHTML: m.icon
196
+ default: M(() => [
197
+ g("div", null, [
198
+ $(a, {
199
+ size: c.value,
200
+ innerHTML: w.icon
144
201
  }, null, 8, ["size", "innerHTML"]),
145
- _.value ? (n(), g("div", Q, C(m.text), 1)) : O("", !0)
202
+ u.value ? (_(), b("div", ze, A(w.text), 1)) : Q("", !0)
146
203
  ])
147
204
  ]),
148
205
  _: 2
@@ -155,14 +212,294 @@ const j = (t) => (H("data-v-05cd92db"), t = t(), R(), t), q = /* @__PURE__ */ j(
155
212
  }, 8, ["class"]);
156
213
  };
157
214
  }
158
- }), W = /* @__PURE__ */ L(U, [["__scopeId", "data-v-7e12291d"]]), it = {
215
+ }), Ce = /* @__PURE__ */ G(Ee, [["__scopeId", "data-v-27b5412a"]]), V = 20;
216
+ function be(e) {
217
+ const l = f({});
218
+ let n = !1;
219
+ const t = () => {
220
+ if (!n && e.value) {
221
+ const o = e.value.getBoundingClientRect();
222
+ l.value.left = o.left, l.value.top = o.top, l.value.width = o.width, l.value.height = o.height, n = !0;
223
+ }
224
+ };
225
+ return I(() => {
226
+ e.value && H(() => {
227
+ t();
228
+ });
229
+ }), C(e, (o) => {
230
+ o && H(() => {
231
+ t();
232
+ });
233
+ }), {
234
+ isIntialized: n,
235
+ initialRect: l
236
+ };
237
+ }
238
+ function ke(e, l = f(!1), n = { width: 20, height: 40 }) {
239
+ const t = f({
240
+ width: null,
241
+ height: null,
242
+ left: null,
243
+ top: null
244
+ }), o = f(!1);
245
+ let c = 0, s = 0, v = 0, u = 0, h = 0;
246
+ const r = 5, i = f(
247
+ null
248
+ ), a = (d) => {
249
+ if (e.value)
250
+ if (o.value) {
251
+ const m = d.clientX - u, z = d.clientY - h;
252
+ (i.value === "left" || i.value === "left-bottom-corner") && (t.value.width = Math.max(
253
+ n.width,
254
+ s - m
255
+ ), t.value.left = c + m, e.value.style.left = t.value.left + "px", e.value.style.width = t.value.width + "px"), (i.value === "right" || i.value === "right-bottom-corner") && (t.value.width = Math.max(
256
+ n.width,
257
+ s + m
258
+ ), e.value.style.width = t.value.width + "px"), (i.value === "bottom" || i.value === "left-bottom-corner" || i.value === "right-bottom-corner") && (t.value.height = Math.max(
259
+ n.height,
260
+ v + z
261
+ ), e.value.style.height = t.value.height + "px");
262
+ } else {
263
+ const m = e.value.getBoundingClientRect(), z = d.clientX - m.left, k = d.clientY - m.top, B = z <= r, T = z >= m.width - r, P = k >= m.height - r;
264
+ B && P && l.value ? (e.value.style.cursor = "nesw-resize", i.value = "left-bottom-corner") : T && P && !l.value ? (e.value.style.cursor = "nwse-resize", i.value = "right-bottom-corner") : B && l.value ? (e.value.style.cursor = "ew-resize", i.value = "left") : T && !l.value ? (e.value.style.cursor = "ew-resize", i.value = "right") : P ? (e.value.style.cursor = "ns-resize", i.value = "bottom") : (e.value.style.cursor = "", i.value = null);
265
+ }
266
+ }, p = (d) => {
267
+ if (!e.value || !i.value) return;
268
+ const m = e.value.getBoundingClientRect();
269
+ u = d.clientX, h = d.clientY, s = m.width, v = m.height, c = m.left, t.value.width = s, t.value.height = v, t.value.left = m.left, t.value.top = m.top, o.value = !0, document.addEventListener("mousemove", a), document.addEventListener("mouseup", x);
270
+ }, x = () => {
271
+ o.value = !1, i.value = null, e.value && (e.value.style.cursor = ""), document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", x);
272
+ }, y = () => {
273
+ e.value && (e.value.removeEventListener("mousedown", p), e.value.removeEventListener("mousemove", a)), document.removeEventListener("mouseup", x);
274
+ }, w = () => {
275
+ e.value && (e.value.addEventListener("mousedown", p), e.value.addEventListener("mousemove", a));
276
+ };
277
+ return I(() => {
278
+ e.value && w();
279
+ }), Z(() => {
280
+ y();
281
+ }), C(e, (d) => {
282
+ d ? w() : y();
283
+ }), { rect: t, isResizing: o };
284
+ }
285
+ function Be(e, l, n) {
286
+ function t() {
287
+ e.value && (e.value.style.transition = "");
288
+ }
289
+ const o = () => {
290
+ e.value && e.value.removeEventListener("transitionend", t);
291
+ }, c = () => {
292
+ e.value && e.value.addEventListener("transitionend", t);
293
+ };
294
+ I(() => {
295
+ e.value && e.value.addEventListener("transitionend", t);
296
+ }), Z(() => {
297
+ e.value && e.value.removeEventListener("transitionend", t);
298
+ }), C(e, (s) => {
299
+ s ? c() : o();
300
+ }), C(n, () => {
301
+ if (e.value) {
302
+ const s = e.value;
303
+ l.value ? s.style.transition = "width 0.3s ease-out, left 0.3s ease-out" : s.style.transition = "width 0.3s ease";
304
+ }
305
+ });
306
+ }
307
+ function Te(e, l, n, t) {
308
+ const o = f(window.innerWidth), c = f(window.innerHeight), { initialRect: s } = be(e), { rect: v } = ke(e, l);
309
+ Be(e, l, n);
310
+ const u = L(() => v.value.width && v.value.height ? v.value : s.value), h = (a) => {
311
+ if (e.value && l.value) {
312
+ const p = e.value.getBoundingClientRect();
313
+ e.value.style.left = p.left + a + "px";
314
+ }
315
+ }, r = () => {
316
+ const a = window.innerWidth - o.value;
317
+ o.value = window.innerWidth, c.value = window.innerHeight, h(a);
318
+ };
319
+ I(() => {
320
+ window.addEventListener("resize", r);
321
+ }), R(() => {
322
+ window.removeEventListener("resize", r);
323
+ });
324
+ let i = null;
325
+ return C(n, (a) => {
326
+ a ? (i = u.value.width, u.value.width = V, l.value && u.value.left && i && (u.value.left = u.value.left + i - V)) : (u.value.width = i, l.value && u.value.left && i && (u.value.left = u.value.left - i + V), i = null);
327
+ }), C(t, (a) => {
328
+ if (a && e.value) {
329
+ const x = e.value.getBoundingClientRect();
330
+ u.value.left = x.left, u.value.top = x.top;
331
+ }
332
+ }), { rect: u };
333
+ }
334
+ function $e(e, l) {
335
+ const n = f(!1), t = f({ x: 0, y: 0 }), o = f({ x: 0, y: 0 }), c = L(() => ({
336
+ x: t.value.x - o.value.x,
337
+ y: t.value.y - o.value.y
338
+ })), s = () => {
339
+ if (e.value) {
340
+ const a = e.value.getBoundingClientRect();
341
+ o.value.x = a.left, o.value.y = a.top, t.value.x = a.left, t.value.y = a.top;
342
+ }
343
+ }, v = () => {
344
+ e.value && e.value.addEventListener("mousedown", h);
345
+ }, u = () => {
346
+ e.value && e.value.removeEventListener("mousedown", h);
347
+ }, h = () => {
348
+ n.value = !0, document.addEventListener("mousemove", r), document.addEventListener("mouseup", i);
349
+ }, r = (a) => {
350
+ if (n.value) {
351
+ const p = window.innerWidth, x = window.innerHeight, y = e.value, w = y.offsetWidth, d = y.offsetHeight, m = t.value.x + a.movementX, z = t.value.y + a.movementY;
352
+ t.value.x = Math.max(
353
+ l ? l.value.leftGap : 0,
354
+ Math.min(m, p - w)
355
+ );
356
+ const k = l && l.value.container ? l.value.container.clientWidth : 0, B = p - k - w;
357
+ if (t.value.x = Math.min(
358
+ l ? B - l.value.rightGap : B,
359
+ t.value.x
360
+ ), t.value.y = Math.max(
361
+ 0,
362
+ Math.min(z, x - d)
363
+ ), l != null && l.value.container) {
364
+ const T = l == null ? void 0 : l.value.container;
365
+ T.style.left = t.value.x + "px", T.style.top = t.value.y + "px";
366
+ }
367
+ }
368
+ }, i = () => {
369
+ n.value = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", i);
370
+ };
371
+ return I(() => {
372
+ e.value && H(() => {
373
+ s(), v();
374
+ });
375
+ }), R(() => {
376
+ e.value && (s(), e.value.removeEventListener("mousedown", h));
377
+ }), C(e, (a) => {
378
+ a ? H(() => {
379
+ s(), v();
380
+ }) : u();
381
+ }), {
382
+ isDragging: n,
383
+ movement: c,
384
+ position: t
385
+ };
386
+ }
387
+ function De(e, l) {
388
+ const n = f(!1), t = f("left"), { isDragging: o, movement: c, position: s } = $e(e, l);
389
+ return C(c, (v) => {
390
+ if (v && l.value.container) {
391
+ const h = l.value.container.getBoundingClientRect();
392
+ h.left <= l.value.leftGap ? (t.value = "left", n.value = !0) : window.innerWidth - h.left - h.width - V <= l.value.rightGap ? (t.value = "right", n.value = !0) : n.value = !1;
393
+ }
394
+ }), {
395
+ docked: n,
396
+ orientation: t,
397
+ isDragging: o,
398
+ movement: c,
399
+ position: s
400
+ };
401
+ }
402
+ const Ie = (e) => (j("data-v-d69f63b3"), e = e(), q(), e), Ve = /* @__PURE__ */ Ie(() => /* @__PURE__ */ g("svg", {
403
+ xmlns: "http://www.w3.org/2000/svg",
404
+ width: "1em",
405
+ height: "1em",
406
+ viewBox: "0 0 1024 1024"
407
+ }, [
408
+ /* @__PURE__ */ g("path", {
409
+ fill: "currentColor",
410
+ d: "M764.288 214.592L512 466.88L259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512L214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
411
+ })
412
+ ], -1)), We = { class: "ml-tool-palette-title" }, He = { class: "ml-tool-palette-content" }, Se = /* @__PURE__ */ D({
413
+ __name: "MlToolPalette",
414
+ props: /* @__PURE__ */ W({
415
+ title: { default: "" }
416
+ }, {
417
+ modelValue: { default: !0 },
418
+ modelModifiers: {}
419
+ }),
420
+ emits: /* @__PURE__ */ W(["close"], ["update:modelValue"]),
421
+ setup(e, { emit: l }) {
422
+ const n = e, t = N(e, "modelValue"), o = l, c = f(!1), s = f(null), v = f(null), u = L(() => i.value === "right"), h = L(() => ({
423
+ leftGap: 0,
424
+ rightGap: 0,
425
+ container: v.value
426
+ })), { docked: r, orientation: i, movement: a } = De(
427
+ s,
428
+ h
429
+ ), { rect: p } = Te(
430
+ v,
431
+ u,
432
+ c,
433
+ a
434
+ ), x = L(() => ({
435
+ left: `${p.value.left}px`,
436
+ top: `${p.value.top}px`,
437
+ width: `${p.value.width}px`,
438
+ height: r.value ? "100%" : `${p.value.height}px`
439
+ })), y = (d) => {
440
+ c.value = d;
441
+ }, w = () => {
442
+ t.value = !1;
443
+ const d = v.value;
444
+ o("close", {
445
+ x: d ? d.clientLeft : 0,
446
+ y: d ? d.clientTop : 0
447
+ });
448
+ };
449
+ return (d, m) => {
450
+ const z = S;
451
+ return t.value ? (_(), b("div", {
452
+ key: 0,
453
+ ref_key: "toolPaletteElement",
454
+ ref: v,
455
+ style: K([x.value]),
456
+ class: "ml-tool-palette-dialog"
457
+ }, [
458
+ g("div", {
459
+ class: J(["ml-tool-palette-dialog-layout", ue(i)])
460
+ }, [
461
+ g("div", {
462
+ ref_key: "titleBarElement",
463
+ ref: s,
464
+ class: "ml-tool-palette-title-bar"
465
+ }, [
466
+ $(z, {
467
+ size: 18,
468
+ class: "ml-tool-palette-dialog-icon",
469
+ onClick: w
470
+ }, {
471
+ default: M(() => [
472
+ Ve
473
+ ]),
474
+ _: 1
475
+ }),
476
+ $(we, {
477
+ class: "ml-tool-palette-dialog-icon",
478
+ modelValue: c.value,
479
+ "onUpdate:modelValue": m[0] || (m[0] = (k) => c.value = k),
480
+ reverse: u.value,
481
+ onChange: y
482
+ }, null, 8, ["modelValue", "reverse"]),
483
+ g("span", We, A(n.title), 1)
484
+ ], 512),
485
+ g("div", He, [
486
+ ce(d.$slots, "default", {}, void 0, !0)
487
+ ])
488
+ ], 2)
489
+ ], 4)) : Q("", !0);
490
+ };
491
+ }
492
+ }), Pe = /* @__PURE__ */ G(Se, [["__scopeId", "data-v-d69f63b3"]]), Je = {
159
493
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
160
- install(t) {
161
- t.component("MlDropdown", y), t.component("MlLanguage", P), t.component("MlToolbar", W);
494
+ install(e) {
495
+ e.component("MlCollapse", Y), e.component("MlDropdown", Y), e.component("MlLanguage", ye), e.component("MlToolbar", Ce), e.component("MlToolPalette", Pe);
162
496
  }
163
497
  };
164
498
  export {
165
- P as MlLanguage,
166
- W as MlToolbar,
167
- it as default
499
+ we as MlCollapse,
500
+ Y as MlDropdown,
501
+ ye as MlLanguage,
502
+ Pe as MlToolPalette,
503
+ Ce as MlToolbar,
504
+ Je as default
168
505
  };