@vizel/vue 0.0.1-alpha.1 → 0.0.1-alpha.5
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/dist/index.d.ts +7 -7
- package/dist/index.js +69 -61
- package/dist/index10.js +80 -127
- package/dist/index11.js +55 -24
- package/dist/index12.js +28 -8
- package/dist/index13.js +60 -75
- package/dist/index14.js +98 -124
- package/dist/index15.js +9 -31
- package/dist/index16.js +184 -14
- package/dist/index17.js +14 -77
- package/dist/index18.js +28 -113
- package/dist/index19.js +128 -14
- package/dist/index2.js +73 -82
- package/dist/index20.js +24 -46
- package/dist/index21.js +10 -41
- package/dist/index22.js +12 -10
- package/dist/index23.js +89 -14
- package/dist/index24.js +130 -33
- package/dist/index25.js +34 -45
- package/dist/index26.js +19 -22
- package/dist/index27.js +77 -8
- package/dist/index28.js +118 -44
- package/dist/index29.js +18 -20
- package/dist/index3.js +49 -56
- package/dist/index30.js +50 -13
- package/dist/index31.js +41 -2
- package/dist/index32.js +36 -2
- package/dist/index33.js +46 -2
- package/dist/index34.js +22 -2
- package/dist/index35.js +8 -2
- package/dist/index36.js +44 -2
- package/dist/index37.js +21 -2
- package/dist/index38.js +13 -2
- package/dist/index39.js +15 -2
- package/dist/index4.js +236 -30
- package/dist/index40.js +2 -2
- package/dist/index41.js +1 -1
- package/dist/index42.js +1 -1
- package/dist/index43.js +1 -1
- package/dist/index44.js +1 -1
- package/dist/index45.js +1 -1
- package/dist/index46.js +1 -1
- package/dist/index47.js +1 -1
- package/dist/index5.js +78 -70
- package/dist/index51.js +1 -1
- package/dist/index52.js +4 -0
- package/dist/index53.js +4 -0
- package/dist/index54.js +4 -0
- package/dist/index55.js +4 -0
- package/dist/index56.js +4 -0
- package/dist/index57.js +4 -0
- package/dist/index58.js +4 -0
- package/dist/index59.js +4 -0
- package/dist/index6.js +72 -103
- package/dist/index60.js +4 -0
- package/dist/index7.js +62 -11
- package/dist/index8.js +57 -186
- package/dist/index9.js +2 -35
- package/package.json +25 -32
package/dist/index13.js
CHANGED
|
@@ -1,91 +1,76 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class: "vizel-link-button",
|
|
7
|
-
title: "Apply"
|
|
8
|
-
}, A = {
|
|
1
|
+
import { defineComponent as w, ref as i, computed as n, watch as b, onMounted as x, onUnmounted as z, createElementBlock as d, openBlock as a, normalizeClass as h, createElementVNode as R, createCommentVNode as V, normalizeStyle as E, createBlock as v, createVNode as H } from "vue";
|
|
2
|
+
import { VIZEL_TEXT_COLORS as L, VIZEL_HIGHLIGHT_COLORS as T, getVizelRecentColors as B, addVizelRecentColor as f } from "@vizel/core";
|
|
3
|
+
import O from "./index16.js";
|
|
4
|
+
import m from "./index20.js";
|
|
5
|
+
const S = ["data-type"], I = ["title", "data-action"], $ = {
|
|
9
6
|
key: 0,
|
|
10
|
-
class: "vizel-
|
|
11
|
-
},
|
|
12
|
-
__name: "
|
|
7
|
+
class: "vizel-color-picker-dropdown"
|
|
8
|
+
}, Z = /* @__PURE__ */ w({
|
|
9
|
+
__name: "VizelBubbleMenuColorPicker",
|
|
13
10
|
props: {
|
|
14
11
|
editor: {},
|
|
12
|
+
type: {},
|
|
13
|
+
colors: {},
|
|
15
14
|
class: {},
|
|
16
|
-
|
|
15
|
+
allowCustomColor: { type: Boolean, default: !0 },
|
|
16
|
+
showRecentColors: { type: Boolean, default: !0 }
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
s.value && !s.value.contains(t.target) && o("close");
|
|
23
|
-
}
|
|
24
|
-
function b(t) {
|
|
25
|
-
t.key === "Escape" && (t.preventDefault(), t.stopImmediatePropagation(), o("close"));
|
|
26
|
-
}
|
|
27
|
-
V(() => {
|
|
28
|
-
f.value?.focus(), setTimeout(() => {
|
|
29
|
-
document.addEventListener("mousedown", k);
|
|
30
|
-
}, 0), document.addEventListener("keydown", b, !0);
|
|
31
|
-
}), C(() => {
|
|
32
|
-
document.removeEventListener("mousedown", k), document.removeEventListener("keydown", b, !0);
|
|
18
|
+
setup(C) {
|
|
19
|
+
const e = C, o = i(!1), c = i([]), s = i(null), g = n(() => e.colors ?? (e.type === "textColor" ? L : T)), r = n(() => e.type === "textColor" ? e.editor.getAttributes("textStyle").color : e.editor.getAttributes("highlight").color), l = n(() => e.type === "textColor"), y = n(() => l.value ? ["inherit"] : ["transparent"]);
|
|
20
|
+
b(o, (t) => {
|
|
21
|
+
t && e.showRecentColors && (c.value = B(e.type));
|
|
33
22
|
});
|
|
34
23
|
function _(t) {
|
|
35
|
-
t.
|
|
36
|
-
const e = l.value.trim();
|
|
37
|
-
if (!e) {
|
|
38
|
-
n.editor.chain().focus().unsetLink().run(), o("close");
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
u.value && p.value ? n.editor.chain().focus().unsetLink().setEmbed({ url: e }).run() : n.editor.chain().focus().setLink({ href: e }).run(), o("close");
|
|
24
|
+
e.type === "textColor" ? t === "inherit" ? e.editor.chain().focus().unsetColor().run() : (e.editor.chain().focus().setColor(t).run(), f(e.type, t)) : t === "transparent" ? e.editor.chain().focus().unsetHighlight().run() : (e.editor.chain().focus().toggleHighlight({ color: t }).run(), f(e.type, t)), o.value = !1;
|
|
42
25
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
26
|
+
function u(t) {
|
|
27
|
+
s.value && !s.value.contains(t.target) && (o.value = !1);
|
|
28
|
+
}
|
|
29
|
+
x(() => {
|
|
30
|
+
document.addEventListener("mousedown", u);
|
|
31
|
+
}), z(() => {
|
|
32
|
+
document.removeEventListener("mousedown", u);
|
|
33
|
+
});
|
|
34
|
+
function k() {
|
|
35
|
+
return l.value ? { color: r.value || "inherit" } : { "--highlight-color": r.value || "transparent" };
|
|
45
36
|
}
|
|
46
|
-
return (t,
|
|
47
|
-
ref_key: "
|
|
37
|
+
return (t, p) => (a(), d("div", {
|
|
38
|
+
ref_key: "containerRef",
|
|
48
39
|
ref: s,
|
|
49
|
-
class:
|
|
50
|
-
|
|
40
|
+
class: h(["vizel-color-picker", t.$props.class]),
|
|
41
|
+
"data-type": e.type
|
|
51
42
|
}, [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
[U, l.value]
|
|
62
|
-
]),
|
|
63
|
-
i("button", P, [
|
|
64
|
-
y(g, { name: "check" })
|
|
65
|
-
]),
|
|
66
|
-
v.value ? (c(), m("button", {
|
|
43
|
+
R("button", {
|
|
44
|
+
type: "button",
|
|
45
|
+
class: h(["vizel-bubble-menu-button", "vizel-color-picker-trigger", { "has-color": r.value }]),
|
|
46
|
+
title: l.value ? "Text Color" : "Highlight",
|
|
47
|
+
"data-action": e.type,
|
|
48
|
+
style: E(k()),
|
|
49
|
+
onClick: p[0] || (p[0] = (N) => o.value = !o.value)
|
|
50
|
+
}, [
|
|
51
|
+
l.value ? (a(), v(m, {
|
|
67
52
|
key: 0,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
])) :
|
|
86
|
-
],
|
|
53
|
+
name: "textColor"
|
|
54
|
+
})) : (a(), v(m, {
|
|
55
|
+
key: 1,
|
|
56
|
+
name: "highlighter"
|
|
57
|
+
}))
|
|
58
|
+
], 14, I),
|
|
59
|
+
o.value ? (a(), d("div", $, [
|
|
60
|
+
H(O, {
|
|
61
|
+
colors: g.value,
|
|
62
|
+
value: r.value,
|
|
63
|
+
label: l.value ? "Text color palette" : "Highlight color palette",
|
|
64
|
+
"allow-custom-color": e.allowCustomColor,
|
|
65
|
+
"recent-colors": c.value,
|
|
66
|
+
"show-recent-colors": e.showRecentColors,
|
|
67
|
+
"none-values": y.value,
|
|
68
|
+
onChange: _
|
|
69
|
+
}, null, 8, ["colors", "value", "label", "allow-custom-color", "recent-colors", "show-recent-colors", "none-values"])
|
|
70
|
+
])) : V("", !0)
|
|
71
|
+
], 10, S));
|
|
87
72
|
}
|
|
88
73
|
});
|
|
89
74
|
export {
|
|
90
|
-
|
|
75
|
+
Z as default
|
|
91
76
|
};
|
package/dist/index14.js
CHANGED
|
@@ -1,134 +1,108 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class: "vizel-node-selector-check",
|
|
11
|
-
"aria-hidden": "true"
|
|
12
|
-
}, X = /* @__PURE__ */ E({
|
|
13
|
-
__name: "VizelNodeSelector",
|
|
1
|
+
import { defineComponent as $, computed as l, ref as A, createBlock as B, createElementBlock as _, openBlock as u, normalizeClass as y, createVNode as i, withCtx as r } from "vue";
|
|
2
|
+
import { useVizelState as E } from "./index37.js";
|
|
3
|
+
import a from "./index12.js";
|
|
4
|
+
import c from "./index13.js";
|
|
5
|
+
import d from "./index20.js";
|
|
6
|
+
import S from "./index23.js";
|
|
7
|
+
import z from "./index24.js";
|
|
8
|
+
const D = /* @__PURE__ */ $({
|
|
9
|
+
__name: "VizelBubbleMenuDefault",
|
|
14
10
|
props: {
|
|
15
11
|
editor: {},
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
class: {},
|
|
13
|
+
enableEmbed: { type: Boolean }
|
|
18
14
|
},
|
|
19
|
-
setup(
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
e && S(() => {
|
|
30
|
-
y.value?.focus();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
function w(e) {
|
|
34
|
-
if (!n.value) {
|
|
35
|
-
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), n.value = !0, t.value = 0);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
switch (e.key) {
|
|
39
|
-
case "Escape":
|
|
40
|
-
e.preventDefault(), n.value = !1;
|
|
41
|
-
break;
|
|
42
|
-
case "ArrowDown":
|
|
43
|
-
e.preventDefault(), t.value = (t.value + 1) % o.nodeTypes.length;
|
|
44
|
-
break;
|
|
45
|
-
case "ArrowUp":
|
|
46
|
-
e.preventDefault(), t.value = (t.value - 1 + o.nodeTypes.length) % o.nodeTypes.length;
|
|
47
|
-
break;
|
|
48
|
-
case "Enter":
|
|
49
|
-
case " ": {
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
const s = o.nodeTypes[t.value];
|
|
52
|
-
s && z(s);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
case "Home":
|
|
56
|
-
e.preventDefault(), t.value = 0;
|
|
57
|
-
break;
|
|
58
|
-
case "End":
|
|
59
|
-
e.preventDefault(), t.value = o.nodeTypes.length - 1;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function z(e) {
|
|
64
|
-
e.command(o.editor), n.value = !1;
|
|
65
|
-
}
|
|
66
|
-
function v(e) {
|
|
67
|
-
return k.value, e.isActive(o.editor);
|
|
68
|
-
}
|
|
69
|
-
return (e, s) => (c(), r("div", {
|
|
70
|
-
ref_key: "containerRef",
|
|
71
|
-
ref: p,
|
|
72
|
-
class: D(["vizel-node-selector", e.$props.class]),
|
|
73
|
-
"data-vizel-node-selector": ""
|
|
15
|
+
setup(v) {
|
|
16
|
+
const e = v, o = E(() => e.editor), m = l(() => (o.value, e.editor.isActive("bold"))), f = l(() => (o.value, e.editor.isActive("italic"))), k = l(() => (o.value, e.editor.isActive("strike"))), p = l(() => (o.value, e.editor.isActive("underline"))), C = l(() => (o.value, e.editor.isActive("code"))), b = l(() => (o.value, e.editor.isActive("link"))), s = A(!1);
|
|
17
|
+
return (g, t) => s.value ? (u(), B(S, {
|
|
18
|
+
key: 0,
|
|
19
|
+
editor: e.editor,
|
|
20
|
+
"enable-embed": e.enableEmbed,
|
|
21
|
+
onClose: t[0] || (t[0] = (n) => s.value = !1)
|
|
22
|
+
}, null, 8, ["editor", "enable-embed"])) : (u(), _("div", {
|
|
23
|
+
key: 1,
|
|
24
|
+
class: y(["vizel-bubble-menu-toolbar", g.$props.class])
|
|
74
25
|
}, [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
title: "
|
|
82
|
-
onClick:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
d(u, { name: C.value }, null, 8, ["name"])
|
|
26
|
+
i(z, {
|
|
27
|
+
editor: e.editor
|
|
28
|
+
}, null, 8, ["editor"]),
|
|
29
|
+
i(a, {
|
|
30
|
+
action: "bold",
|
|
31
|
+
"is-active": m.value,
|
|
32
|
+
title: "Bold (Cmd+B)",
|
|
33
|
+
onClick: t[1] || (t[1] = (n) => e.editor.chain().focus().toggleBold().run())
|
|
34
|
+
}, {
|
|
35
|
+
default: r(() => [
|
|
36
|
+
i(d, { name: "bold" })
|
|
87
37
|
]),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]
|
|
128
|
-
|
|
38
|
+
_: 1
|
|
39
|
+
}, 8, ["is-active"]),
|
|
40
|
+
i(a, {
|
|
41
|
+
action: "italic",
|
|
42
|
+
"is-active": f.value,
|
|
43
|
+
title: "Italic (Cmd+I)",
|
|
44
|
+
onClick: t[2] || (t[2] = (n) => e.editor.chain().focus().toggleItalic().run())
|
|
45
|
+
}, {
|
|
46
|
+
default: r(() => [
|
|
47
|
+
i(d, { name: "italic" })
|
|
48
|
+
]),
|
|
49
|
+
_: 1
|
|
50
|
+
}, 8, ["is-active"]),
|
|
51
|
+
i(a, {
|
|
52
|
+
action: "strike",
|
|
53
|
+
"is-active": k.value,
|
|
54
|
+
title: "Strikethrough",
|
|
55
|
+
onClick: t[3] || (t[3] = (n) => e.editor.chain().focus().toggleStrike().run())
|
|
56
|
+
}, {
|
|
57
|
+
default: r(() => [
|
|
58
|
+
i(d, { name: "strikethrough" })
|
|
59
|
+
]),
|
|
60
|
+
_: 1
|
|
61
|
+
}, 8, ["is-active"]),
|
|
62
|
+
i(a, {
|
|
63
|
+
action: "underline",
|
|
64
|
+
"is-active": p.value,
|
|
65
|
+
title: "Underline (Cmd+U)",
|
|
66
|
+
onClick: t[4] || (t[4] = (n) => e.editor.chain().focus().toggleUnderline().run())
|
|
67
|
+
}, {
|
|
68
|
+
default: r(() => [
|
|
69
|
+
i(d, { name: "underline" })
|
|
70
|
+
]),
|
|
71
|
+
_: 1
|
|
72
|
+
}, 8, ["is-active"]),
|
|
73
|
+
i(a, {
|
|
74
|
+
action: "code",
|
|
75
|
+
"is-active": C.value,
|
|
76
|
+
title: "Code (Cmd+E)",
|
|
77
|
+
onClick: t[5] || (t[5] = (n) => e.editor.chain().focus().toggleCode().run())
|
|
78
|
+
}, {
|
|
79
|
+
default: r(() => [
|
|
80
|
+
i(d, { name: "code" })
|
|
81
|
+
]),
|
|
82
|
+
_: 1
|
|
83
|
+
}, 8, ["is-active"]),
|
|
84
|
+
i(a, {
|
|
85
|
+
action: "link",
|
|
86
|
+
"is-active": b.value,
|
|
87
|
+
title: "Link (Cmd+K)",
|
|
88
|
+
onClick: t[6] || (t[6] = (n) => s.value = !0)
|
|
89
|
+
}, {
|
|
90
|
+
default: r(() => [
|
|
91
|
+
i(d, { name: "link" })
|
|
92
|
+
]),
|
|
93
|
+
_: 1
|
|
94
|
+
}, 8, ["is-active"]),
|
|
95
|
+
i(c, {
|
|
96
|
+
editor: e.editor,
|
|
97
|
+
type: "textColor"
|
|
98
|
+
}, null, 8, ["editor"]),
|
|
99
|
+
i(c, {
|
|
100
|
+
editor: e.editor,
|
|
101
|
+
type: "highlight"
|
|
102
|
+
}, null, 8, ["editor"])
|
|
129
103
|
], 2));
|
|
130
104
|
}
|
|
131
105
|
});
|
|
132
106
|
export {
|
|
133
|
-
|
|
107
|
+
D as default
|
|
134
108
|
};
|
package/dist/index15.js
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__name: "VizelPortal",
|
|
1
|
+
import { defineComponent as s, createElementBlock as l, openBlock as n, normalizeClass as r } from "vue";
|
|
2
|
+
const c = /* @__PURE__ */ s({
|
|
3
|
+
__name: "VizelBubbleMenuDivider",
|
|
5
4
|
props: {
|
|
6
|
-
|
|
7
|
-
class: {},
|
|
8
|
-
disabled: { type: Boolean, default: !1 }
|
|
5
|
+
class: {}
|
|
9
6
|
},
|
|
10
|
-
setup(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
const s = o(() => `#${_}`), n = o(() => ({
|
|
16
|
-
position: "absolute",
|
|
17
|
-
top: 0,
|
|
18
|
-
left: 0,
|
|
19
|
-
zIndex: I[r.layer]
|
|
20
|
-
}));
|
|
21
|
-
return (t, k) => l.value && !e.disabled ? (c(), u(f, {
|
|
22
|
-
key: 0,
|
|
23
|
-
to: s.value
|
|
24
|
-
}, [
|
|
25
|
-
m("div", {
|
|
26
|
-
"data-vizel-portal-layer": e.layer,
|
|
27
|
-
class: v(t.$props.class),
|
|
28
|
-
style: y(n.value)
|
|
29
|
-
}, [
|
|
30
|
-
a(t.$slots, "default")
|
|
31
|
-
], 14, V)
|
|
32
|
-
], 8, ["to"])) : a(t.$slots, "default", { key: 1 });
|
|
7
|
+
setup(o) {
|
|
8
|
+
return (e, a) => (n(), l("span", {
|
|
9
|
+
class: r(["vizel-bubble-menu-divider", e.$props.class])
|
|
10
|
+
}, null, 2));
|
|
33
11
|
}
|
|
34
12
|
});
|
|
35
13
|
export {
|
|
36
|
-
|
|
14
|
+
c as default
|
|
37
15
|
};
|
package/dist/index16.js
CHANGED
|
@@ -1,21 +1,191 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { defineComponent as U, computed as k, ref as C, watch as N, onMounted as F, createElementBlock as s, openBlock as i, normalizeClass as _, createCommentVNode as b, createElementVNode as u, Fragment as B, renderList as M, normalizeStyle as z, createVNode as V } from "vue";
|
|
2
|
+
import { isVizelValidHexColor as S, normalizeVizelHexColor as g } from "@vizel/core";
|
|
3
|
+
import x from "./index20.js";
|
|
4
|
+
const G = ["aria-label"], P = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "vizel-color-picker-section"
|
|
7
|
+
}, j = { class: "vizel-color-picker-recent" }, q = ["aria-selected", "aria-label", "tabindex", "data-color", "onClick", "onKeydown"], J = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "vizel-color-picker-none"
|
|
10
|
+
}, Q = { class: "vizel-color-picker-section" }, T = { class: "vizel-color-picker-grid" }, W = ["aria-selected", "aria-label", "tabindex", "data-color", "onClick", "onKeydown"], X = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "vizel-color-picker-none"
|
|
13
|
+
}, Y = {
|
|
14
|
+
key: 1,
|
|
15
|
+
class: "vizel-color-picker-input-row"
|
|
16
|
+
}, Z = ["value"], D = ["disabled"], $ = 4, te = /* @__PURE__ */ U({
|
|
17
|
+
__name: "VizelColorPicker",
|
|
5
18
|
props: {
|
|
6
|
-
|
|
7
|
-
|
|
19
|
+
colors: {},
|
|
20
|
+
value: {},
|
|
21
|
+
modelValue: {},
|
|
22
|
+
label: { default: "Color palette" },
|
|
23
|
+
class: {},
|
|
24
|
+
allowCustomColor: { type: Boolean, default: !0 },
|
|
25
|
+
recentColors: { default: () => [] },
|
|
26
|
+
showRecentColors: { type: Boolean, default: !0 },
|
|
27
|
+
noneValues: { default: () => ["transparent", "inherit"] }
|
|
8
28
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
29
|
+
emits: ["change", "update:modelValue"],
|
|
30
|
+
setup(d, { emit: H }) {
|
|
31
|
+
const a = d, f = H, c = k(() => a.modelValue ?? a.value), r = C(""), v = C(-1), p = C([]), I = C(null), m = k(() => [
|
|
32
|
+
...a.showRecentColors ? a.recentColors : [],
|
|
33
|
+
...a.colors.map((e) => e.color)
|
|
34
|
+
]);
|
|
35
|
+
N(
|
|
36
|
+
() => m.value.length,
|
|
37
|
+
(e) => {
|
|
38
|
+
p.value.length > e && (p.value.length = e);
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
const y = k(() => a.showRecentColors ? a.recentColors.length : 0);
|
|
42
|
+
function h(e) {
|
|
43
|
+
return a.noneValues.includes(e);
|
|
44
|
+
}
|
|
45
|
+
function w(e) {
|
|
46
|
+
f("change", e), f("update:modelValue", e), r.value = "";
|
|
47
|
+
}
|
|
48
|
+
function R() {
|
|
49
|
+
const e = g(r.value);
|
|
50
|
+
S(e) && (f("change", e), f("update:modelValue", e), r.value = "");
|
|
51
|
+
}
|
|
52
|
+
function O(e) {
|
|
53
|
+
e.key === "Enter" && (e.preventDefault(), R());
|
|
54
|
+
}
|
|
55
|
+
function K(e, n) {
|
|
56
|
+
const l = m.value.length;
|
|
57
|
+
if (l === 0) return;
|
|
58
|
+
let t = n, o = !1;
|
|
59
|
+
switch (e.key) {
|
|
60
|
+
case "ArrowRight":
|
|
61
|
+
t = (n + 1) % l, o = !0;
|
|
62
|
+
break;
|
|
63
|
+
case "ArrowLeft":
|
|
64
|
+
t = (n - 1 + l) % l, o = !0;
|
|
65
|
+
break;
|
|
66
|
+
case "ArrowDown":
|
|
67
|
+
t = Math.min(n + $, l - 1), o = !0;
|
|
68
|
+
break;
|
|
69
|
+
case "ArrowUp":
|
|
70
|
+
t = Math.max(n - $, 0), o = !0;
|
|
71
|
+
break;
|
|
72
|
+
case "Home":
|
|
73
|
+
t = 0, o = !0;
|
|
74
|
+
break;
|
|
75
|
+
case "End":
|
|
76
|
+
t = l - 1, o = !0;
|
|
77
|
+
break;
|
|
78
|
+
case "Enter":
|
|
79
|
+
case " ": {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
const E = m.value[n];
|
|
82
|
+
E && w(E);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
o && (e.preventDefault(), v.value = t, p.value[t]?.focus());
|
|
87
|
+
}
|
|
88
|
+
N(
|
|
89
|
+
c,
|
|
90
|
+
(e) => {
|
|
91
|
+
e && !h(e) ? r.value = e : r.value = "";
|
|
92
|
+
},
|
|
93
|
+
{ immediate: !0 }
|
|
94
|
+
), F(() => {
|
|
95
|
+
const e = c.value ? m.value.indexOf(c.value) : -1;
|
|
96
|
+
e >= 0 ? v.value = e : m.value.length > 0 && (v.value = 0);
|
|
97
|
+
});
|
|
98
|
+
const A = k(() => S(g(r.value))), L = k(
|
|
99
|
+
() => A.value ? g(r.value) : void 0
|
|
100
|
+
);
|
|
101
|
+
return (e, n) => (i(), s("div", {
|
|
102
|
+
class: _(["vizel-color-picker-content", e.$props.class]),
|
|
103
|
+
role: "listbox",
|
|
104
|
+
"aria-label": a.label
|
|
14
105
|
}, [
|
|
15
|
-
|
|
16
|
-
|
|
106
|
+
d.showRecentColors && a.recentColors && a.recentColors.length > 0 ? (i(), s("div", P, [
|
|
107
|
+
n[1] || (n[1] = u("div", { class: "vizel-color-picker-label" }, "Recent", -1)),
|
|
108
|
+
u("div", j, [
|
|
109
|
+
(i(!0), s(B, null, M(d.recentColors, (l, t) => (i(), s("button", {
|
|
110
|
+
key: l,
|
|
111
|
+
ref_for: !0,
|
|
112
|
+
ref: (o) => {
|
|
113
|
+
p.value[t] = o;
|
|
114
|
+
},
|
|
115
|
+
type: "button",
|
|
116
|
+
role: "option",
|
|
117
|
+
"aria-selected": c.value === l,
|
|
118
|
+
"aria-label": l,
|
|
119
|
+
tabindex: v.value === t ? 0 : -1,
|
|
120
|
+
class: _(["vizel-color-picker-swatch", { "is-active": c.value === l }]),
|
|
121
|
+
style: z({ backgroundColor: h(l) ? "transparent" : l }),
|
|
122
|
+
"data-color": l,
|
|
123
|
+
onClick: (o) => w(l),
|
|
124
|
+
onKeydown: (o) => K(o, t)
|
|
125
|
+
}, [
|
|
126
|
+
h(l) ? (i(), s("span", J, [
|
|
127
|
+
V(x, { name: "x" })
|
|
128
|
+
])) : b("", !0)
|
|
129
|
+
], 46, q))), 128))
|
|
130
|
+
])
|
|
131
|
+
])) : b("", !0),
|
|
132
|
+
u("div", Q, [
|
|
133
|
+
u("div", T, [
|
|
134
|
+
(i(!0), s(B, null, M(d.colors, (l, t) => (i(), s("button", {
|
|
135
|
+
key: l.color,
|
|
136
|
+
ref_for: !0,
|
|
137
|
+
ref: (o) => {
|
|
138
|
+
p.value[y.value + t] = o;
|
|
139
|
+
},
|
|
140
|
+
type: "button",
|
|
141
|
+
role: "option",
|
|
142
|
+
"aria-selected": c.value === l.color,
|
|
143
|
+
"aria-label": l.name,
|
|
144
|
+
tabindex: v.value === y.value + t ? 0 : -1,
|
|
145
|
+
class: _(["vizel-color-picker-swatch", { "is-active": c.value === l.color }]),
|
|
146
|
+
style: z({ backgroundColor: h(l.color) ? "transparent" : l.color }),
|
|
147
|
+
"data-color": l.color,
|
|
148
|
+
onClick: (o) => w(l.color),
|
|
149
|
+
onKeydown: (o) => K(o, y.value + t)
|
|
150
|
+
}, [
|
|
151
|
+
h(l.color) ? (i(), s("span", X, [
|
|
152
|
+
V(x, { name: "x" })
|
|
153
|
+
])) : b("", !0)
|
|
154
|
+
], 46, W))), 128))
|
|
155
|
+
])
|
|
156
|
+
]),
|
|
157
|
+
d.allowCustomColor ? (i(), s("div", Y, [
|
|
158
|
+
u("span", {
|
|
159
|
+
class: "vizel-color-picker-preview",
|
|
160
|
+
style: z({ backgroundColor: L.value || "transparent" }),
|
|
161
|
+
"aria-hidden": "true"
|
|
162
|
+
}, null, 4),
|
|
163
|
+
u("input", {
|
|
164
|
+
ref_key: "inputRef",
|
|
165
|
+
ref: I,
|
|
166
|
+
type: "text",
|
|
167
|
+
class: "vizel-color-picker-input",
|
|
168
|
+
placeholder: "#000000",
|
|
169
|
+
value: r.value,
|
|
170
|
+
maxlength: "7",
|
|
171
|
+
"aria-label": "Custom color hex value",
|
|
172
|
+
onInput: n[0] || (n[0] = (l) => r.value = l.target.value),
|
|
173
|
+
onKeydown: O
|
|
174
|
+
}, null, 40, Z),
|
|
175
|
+
u("button", {
|
|
176
|
+
type: "button",
|
|
177
|
+
class: "vizel-color-picker-apply",
|
|
178
|
+
disabled: !A.value,
|
|
179
|
+
title: "Apply",
|
|
180
|
+
"aria-label": "Apply custom color",
|
|
181
|
+
onClick: R
|
|
182
|
+
}, [
|
|
183
|
+
V(x, { name: "check" })
|
|
184
|
+
], 8, D)
|
|
185
|
+
])) : b("", !0)
|
|
186
|
+
], 10, G));
|
|
17
187
|
}
|
|
18
188
|
});
|
|
19
189
|
export {
|
|
20
|
-
|
|
190
|
+
te as default
|
|
21
191
|
};
|