@vizel/vue 0.0.1-alpha.1 → 0.0.1-alpha.4

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.
Files changed (55) hide show
  1. package/dist/index.d.ts +7 -7
  2. package/dist/index.js +69 -61
  3. package/dist/index10.js +80 -127
  4. package/dist/index11.js +55 -24
  5. package/dist/index12.js +28 -8
  6. package/dist/index13.js +60 -75
  7. package/dist/index14.js +98 -124
  8. package/dist/index15.js +9 -31
  9. package/dist/index16.js +184 -14
  10. package/dist/index17.js +14 -77
  11. package/dist/index18.js +28 -113
  12. package/dist/index19.js +128 -14
  13. package/dist/index2.js +73 -82
  14. package/dist/index20.js +24 -46
  15. package/dist/index21.js +10 -41
  16. package/dist/index22.js +12 -10
  17. package/dist/index23.js +89 -14
  18. package/dist/index24.js +130 -33
  19. package/dist/index25.js +34 -45
  20. package/dist/index26.js +19 -22
  21. package/dist/index27.js +77 -8
  22. package/dist/index28.js +118 -44
  23. package/dist/index29.js +18 -20
  24. package/dist/index3.js +49 -56
  25. package/dist/index30.js +50 -13
  26. package/dist/index31.js +41 -2
  27. package/dist/index32.js +36 -2
  28. package/dist/index33.js +46 -2
  29. package/dist/index34.js +22 -2
  30. package/dist/index35.js +8 -2
  31. package/dist/index36.js +44 -2
  32. package/dist/index37.js +21 -2
  33. package/dist/index38.js +13 -2
  34. package/dist/index39.js +15 -2
  35. package/dist/index4.js +236 -30
  36. package/dist/index47.js +1 -1
  37. package/dist/index48.js +1 -1
  38. package/dist/index49.js +1 -1
  39. package/dist/index5.js +78 -70
  40. package/dist/index50.js +1 -1
  41. package/dist/index51.js +1 -1
  42. package/dist/index52.js +4 -0
  43. package/dist/index53.js +4 -0
  44. package/dist/index54.js +4 -0
  45. package/dist/index55.js +4 -0
  46. package/dist/index56.js +4 -0
  47. package/dist/index57.js +4 -0
  48. package/dist/index58.js +4 -0
  49. package/dist/index59.js +4 -0
  50. package/dist/index6.js +72 -103
  51. package/dist/index60.js +4 -0
  52. package/dist/index7.js +62 -11
  53. package/dist/index8.js +57 -186
  54. package/dist/index9.js +2 -35
  55. package/package.json +25 -32
package/dist/index13.js CHANGED
@@ -1,91 +1,76 @@
1
- import { defineComponent as R, ref as r, computed as d, onMounted as V, onUnmounted as C, createElementBlock as m, openBlock as c, normalizeClass as M, createElementVNode as i, createCommentVNode as E, withDirectives as h, vModelText as U, createVNode as y, vModelCheckbox as D } from "vue";
2
- import { detectVizelEmbedProvider as B } from "@vizel/core";
3
- import g from "./index11.js";
4
- const N = { class: "vizel-link-editor-row" }, P = {
5
- type: "submit",
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-link-editor-embed-toggle"
11
- }, H = /* @__PURE__ */ R({
12
- __name: "VizelLinkEditor",
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
- enableEmbed: { type: Boolean, default: !1 }
15
+ allowCustomColor: { type: Boolean, default: !0 },
16
+ showRecentColors: { type: Boolean, default: !0 }
17
17
  },
18
- emits: ["close"],
19
- setup(z, { emit: L }) {
20
- const n = z, o = L, s = r(null), f = r(null), v = d(() => n.editor.getAttributes("link").href || ""), l = r(v.value), u = r(!1), p = d(() => n.enableEmbed ? n.editor.extensionManager.extensions.some((e) => e.name === "embed") : !1), x = d(() => l.value.trim() ? B(l.value.trim()) !== null : !1);
21
- function k(t) {
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.preventDefault();
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 w() {
44
- n.editor.chain().focus().unsetLink().run(), o("close");
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, e) => (c(), m("form", {
47
- ref_key: "formRef",
37
+ return (t, p) => (a(), d("div", {
38
+ ref_key: "containerRef",
48
39
  ref: s,
49
- class: M(["vizel-link-editor", t.$props.class]),
50
- onSubmit: _
40
+ class: h(["vizel-color-picker", t.$props.class]),
41
+ "data-type": e.type
51
42
  }, [
52
- i("div", N, [
53
- h(i("input", {
54
- ref_key: "inputRef",
55
- ref: f,
56
- "onUpdate:modelValue": e[0] || (e[0] = (a) => l.value = a),
57
- type: "url",
58
- placeholder: "Enter URL...",
59
- class: "vizel-link-input"
60
- }, null, 512), [
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
- type: "button",
69
- class: "vizel-link-button vizel-link-remove",
70
- title: "Remove link",
71
- onClick: w
72
- }, [
73
- y(g, { name: "x" })
74
- ])) : E("", !0)
75
- ]),
76
- p.value && x.value ? (c(), m("div", A, [
77
- h(i("input", {
78
- id: "vizel-embed-toggle",
79
- "onUpdate:modelValue": e[1] || (e[1] = (a) => u.value = a),
80
- type: "checkbox"
81
- }, null, 512), [
82
- [D, u.value]
83
- ]),
84
- e[2] || (e[2] = i("label", { for: "vizel-embed-toggle" }, "Embed as rich content", -1))
85
- ])) : E("", !0)
86
- ], 34));
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
- H as default
75
+ Z as default
91
76
  };
package/dist/index14.js CHANGED
@@ -1,134 +1,108 @@
1
- import { defineComponent as E, ref as i, computed as m, onMounted as V, onUnmounted as A, watch as $, nextTick as S, createElementBlock as r, openBlock as c, normalizeClass as D, createElementVNode as l, createCommentVNode as g, createVNode as d, toDisplayString as N, Fragment as L, renderList as R } from "vue";
2
- import { vizelDefaultNodeTypes as B, getVizelActiveNodeType as K } from "@vizel/core";
3
- import { useVizelState as M } from "./index29.js";
4
- import u from "./index11.js";
5
- const I = ["aria-expanded", "aria-label"], O = { class: "vizel-node-selector-icon" }, U = { class: "vizel-node-selector-label" }, F = {
6
- class: "vizel-node-selector-chevron",
7
- "aria-hidden": "true"
8
- }, H = ["aria-selected", "tabindex", "onClick", "onMouseenter"], j = { class: "vizel-node-selector-option-icon" }, q = { class: "vizel-node-selector-option-label" }, G = {
9
- key: 0,
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
- nodeTypes: { default: () => B },
17
- class: {}
12
+ class: {},
13
+ enableEmbed: { type: Boolean }
18
14
  },
19
- setup(T) {
20
- const o = T, k = M(() => o.editor), n = i(!1), t = i(0), p = i(null), y = i(null), h = m(() => (k.value, K(o.editor, o.nodeTypes))), b = m(() => h.value?.label ?? "Text"), C = m(() => h.value?.icon ?? "paragraph");
21
- function _(e) {
22
- p.value && !p.value.contains(e.target) && (n.value = !1);
23
- }
24
- V(() => {
25
- document.addEventListener("mousedown", _);
26
- }), A(() => {
27
- document.removeEventListener("mousedown", _);
28
- }), $(n, (e) => {
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
- l("button", {
76
- type: "button",
77
- class: "vizel-node-selector-trigger",
78
- "aria-haspopup": !0,
79
- "aria-expanded": n.value,
80
- "aria-label": `Current block type: ${b.value}`,
81
- title: "Change block type",
82
- onClick: s[0] || (s[0] = (a) => n.value = !n.value),
83
- onKeydown: w
84
- }, [
85
- l("span", O, [
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
- l("span", U, N(b.value), 1),
89
- l("span", F, [
90
- d(u, { name: "chevronDown" })
91
- ])
92
- ], 40, I),
93
- n.value ? (c(), r("div", {
94
- key: 0,
95
- ref_key: "dropdownRef",
96
- ref: y,
97
- class: "vizel-node-selector-dropdown",
98
- role: "listbox",
99
- "aria-label": "Block types",
100
- "data-vizel-node-selector-dropdown": "",
101
- tabindex: "-1",
102
- onKeydown: w
103
- }, [
104
- (c(!0), r(L, null, R(o.nodeTypes, (a, f) => (c(), r("button", {
105
- key: a.name,
106
- type: "button",
107
- role: "option",
108
- "aria-selected": v(a),
109
- class: D([
110
- "vizel-node-selector-option",
111
- { "is-active": v(a) },
112
- { "is-focused": f === t.value }
113
- ]),
114
- tabindex: f === t.value ? 0 : -1,
115
- onClick: (x) => z(a),
116
- onMouseenter: (x) => t.value = f
117
- }, [
118
- l("span", j, [
119
- d(u, {
120
- name: a.icon
121
- }, null, 8, ["name"])
122
- ]),
123
- l("span", q, N(a.label), 1),
124
- v(a) ? (c(), r("span", G, [
125
- d(u, { name: "check" })
126
- ])) : g("", !0)
127
- ], 42, H))), 128))
128
- ], 544)) : g("", !0)
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
- X as default
107
+ D as default
134
108
  };
package/dist/index15.js CHANGED
@@ -1,37 +1,15 @@
1
- import { defineComponent as d, ref as p, onMounted as i, computed as o, createBlock as u, renderSlot as a, openBlock as c, Teleport as f, createElementVNode as m, normalizeStyle as y, normalizeClass as v } from "vue";
2
- import { getVizelPortalContainer as z, VIZEL_PORTAL_ID as _, VIZEL_PORTAL_Z_INDEX as I } from "@vizel/core";
3
- const V = ["data-vizel-portal-layer"], P = /* @__PURE__ */ d({
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
- layer: { default: "dropdown" },
7
- class: {},
8
- disabled: { type: Boolean, default: !1 }
5
+ class: {}
9
6
  },
10
- setup(e) {
11
- const r = e, l = p(!1);
12
- i(() => {
13
- z(), l.value = !0;
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
- P as default
14
+ c as default
37
15
  };
package/dist/index16.js CHANGED
@@ -1,21 +1,191 @@
1
- import { defineComponent as s, provide as t, createElementBlock as a, openBlock as l, normalizeClass as n, renderSlot as p } from "vue";
2
- import { VIZEL_CONTEXT_KEY as i } from "./index23.js";
3
- const f = /* @__PURE__ */ s({
4
- __name: "VizelProvider",
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
- editor: {},
7
- class: {}
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
- setup(o) {
10
- const r = o;
11
- return t(i, () => r.editor), (e, c) => (l(), a("div", {
12
- class: n(e.$props.class),
13
- "data-vizel-root": ""
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
- p(e.$slots, "default")
16
- ], 2));
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
- f as default
190
+ te as default
21
191
  };