@ddict/bubble
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -1,39 +0,48 @@ | ||
import { openBlock as r, createElementBlock as i, createElementVNode as o, toDisplayString as _, createCommentVNode as p, Fragment as w, renderList as $, createBlock as u, createVNode as m, pushScopeId as v, popScopeId as k } from "vue"; | ||
const f = "/ddict-logo.png", c = (t, n) => { | ||
const e = t.__vccOpts || t; | ||
for (const [l, s] of n) | ||
e[l] = s; | ||
import { openBlock as t, createElementBlock as i, createElementVNode as u, Fragment as $, renderList as m, toDisplayString as g, normalizeClass as _, createBlock as c, createCommentVNode as v, createVNode as p } from "vue"; | ||
const L = "/assets/icons/ddict-logo.svg", d = (n, s) => { | ||
const e = n.__vccOpts || n; | ||
for (const [o, r] of s) | ||
e[o] = r; | ||
return e; | ||
}, y = { | ||
}, w = { | ||
name: "Logo" | ||
}, x = { | ||
src: f, | ||
}, C = { | ||
src: L, | ||
alt: "DDict Logo", | ||
class: "w-6 h-6 cursor-pointer" | ||
}; | ||
function b(t, n, e, l, s, a) { | ||
return r(), i("img", x); | ||
function U(n, s, e, o, r, a) { | ||
return t(), i("img", C); | ||
} | ||
const C = /* @__PURE__ */ c(y, [["render", b]]), j = "/ddict-loading.gif", B = { | ||
const D = /* @__PURE__ */ d(w, [["render", U]]), E = "/ddict-loading.gif", B = { | ||
name: "Loading" | ||
}, L = { class: "rounded bg-white p-1" }, M = /* @__PURE__ */ o("img", { | ||
src: j, | ||
}, P = { class: "rounded bg-white p-1" }, j = /* @__PURE__ */ u("img", { | ||
src: E, | ||
alt: "Loading", | ||
class: "w-12" | ||
}, null, -1), z = [ | ||
M | ||
}, null, -1), N = [ | ||
j | ||
]; | ||
function S(t, n, e, l, s, a) { | ||
return r(), i("div", L, z); | ||
function V(n, s, e, o, r, a) { | ||
return t(), i("div", P, N); | ||
} | ||
const V = /* @__PURE__ */ c(B, [["render", S]]), D = { | ||
name: "Translit", | ||
props: ["translits"] | ||
}, I = { class: "text-sm font-mono truncate p-0 m-0 w-2/3" }, N = { class: "text-slate-500" }; | ||
function A(t, n, e, l, s, a) { | ||
return r(), i("p", I, [ | ||
o("span", N, "/" + _(e.translits) + "/", 1) | ||
const z = /* @__PURE__ */ d(B, [["render", V]]), O = { | ||
name: "Dict", | ||
props: ["dictionary"] | ||
}, A = { class: "capitalize text-base italic font-normal text-slate-400" }; | ||
function H(n, s, e, o, r, a) { | ||
return t(), i("div", null, [ | ||
(t(!0), i($, null, m(e.dictionary, (l, k) => (t(), i("div", { | ||
key: k, | ||
class: "mt-2" | ||
}, [ | ||
u("p", A, g(l.pos), 1), | ||
(t(!0), i($, null, m(l.terms, (F, x) => (t(), i("span", { | ||
key: x, | ||
class: "text-base leading-6 text-textCustom" | ||
}, g(F) + ", ", 1))), 128)) | ||
]))), 128)) | ||
]); | ||
} | ||
const E = /* @__PURE__ */ c(D, [["render", A]]), O = { | ||
const I = /* @__PURE__ */ d(O, [["render", H]]), q = "/assets/icons/volume.svg", G = "/assets/icons/volume-stop.svg", J = { | ||
name: "Player", | ||
@@ -49,4 +58,4 @@ props: ["tts"], | ||
watch: { | ||
playing(t) { | ||
if (!t) { | ||
playing(n) { | ||
if (!n) { | ||
this.player.pause(); | ||
@@ -61,4 +70,4 @@ return; | ||
this.playing = !1; | ||
}, this.player.onerror = (t) => { | ||
this.err = t; | ||
}, this.player.onerror = (n) => { | ||
this.err = n; | ||
}; | ||
@@ -71,208 +80,217 @@ }, | ||
} | ||
}, P = { | ||
}, K = { | ||
key: 0, | ||
xmlns: "http://www.w3.org/2000/svg", | ||
class: "h-4 w-4 inline mr-1", | ||
fill: "none", | ||
viewBox: "0 0 24 24", | ||
stroke: "currentColor", | ||
"stroke-width": "2" | ||
}, T = /* @__PURE__ */ o("path", { | ||
"stroke-linecap": "round", | ||
"stroke-linejoin": "round", | ||
d: "M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z" | ||
}, null, -1), F = [ | ||
T | ||
], G = { | ||
class: "w-5", | ||
src: q, | ||
alt: "Play" | ||
}, M = { | ||
key: 1, | ||
xmlns: "http://www.w3.org/2000/svg", | ||
class: "h-4 w-4 inline mr-1", | ||
fill: "none", | ||
viewBox: "0 0 24 24", | ||
stroke: "currentColor", | ||
"stroke-width": "2" | ||
}, H = /* @__PURE__ */ o("path", { | ||
"stroke-linecap": "round", | ||
"stroke-linejoin": "round", | ||
d: "M21 12a9 9 0 11-18 0 9 9 0 0118 0z" | ||
}, null, -1), q = /* @__PURE__ */ o("path", { | ||
"stroke-linecap": "round", | ||
"stroke-linejoin": "round", | ||
d: "M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z" | ||
}, null, -1), J = [ | ||
H, | ||
q | ||
]; | ||
function K(t, n, e, l, s, a) { | ||
return s.err ? p("", !0) : (r(), i("span", { | ||
key: 0, | ||
onClick: n[0] || (n[0] = (...d) => a.play && a.play(...d)) | ||
class: "w-5", | ||
src: G, | ||
alt: "Stop" | ||
}; | ||
function Q(n, s, e, o, r, a) { | ||
return t(), i("button", { | ||
class: "btn btn-xs btn-ghost btn-circle", | ||
onClick: s[0] || (s[0] = (...l) => a.play && a.play(...l)) | ||
}, [ | ||
s.playing ? p("", !0) : (r(), i("svg", P, F)), | ||
s.playing ? (r(), i("svg", G, J)) : p("", !0) | ||
])); | ||
r.playing ? (t(), i("img", M)) : (t(), i("img", K)) | ||
]); | ||
} | ||
const Q = /* @__PURE__ */ c(O, [["render", K]]), R = { | ||
const f = /* @__PURE__ */ d(J, [["render", Q]]), R = "/assets/icons/favorite-filled.svg", T = "/assets/icons/favorite.svg", W = { | ||
name: "Favorite", | ||
props: ["isFilled"] | ||
}, X = { class: "btn btn-xs btn-circle btn-ghost" }, Y = { | ||
key: 0, | ||
class: "w-5", | ||
src: R, | ||
alt: "Clear" | ||
}, Z = { | ||
key: 1, | ||
class: "w-5", | ||
src: T, | ||
alt: "Clear" | ||
}; | ||
function ee(n, s, e, o, r, a) { | ||
return t(), i("button", X, [ | ||
e.isFilled ? (t(), i("img", Y)) : (t(), i("img", Z)) | ||
]); | ||
} | ||
const b = /* @__PURE__ */ d(W, [["render", ee]]), te = "/assets/icons/setting.svg", se = {}, ne = { class: "btn btn-xs btn-ghost btn-circle" }, ie = /* @__PURE__ */ u("img", { | ||
class: "w-5", | ||
src: te, | ||
alt: "Icon description" | ||
}, null, -1), oe = [ | ||
ie | ||
]; | ||
function ae(n, s) { | ||
return t(), i("button", ne, oe); | ||
} | ||
const y = /* @__PURE__ */ d(se, [["render", ae]]), re = "/assets/icons/cancel.svg", le = {}, ce = { class: "btn btn-xs btn-circle btn-ghost" }, de = /* @__PURE__ */ u("img", { | ||
class: "w-5", | ||
src: re, | ||
alt: "Clear" | ||
}, null, -1), ue = [ | ||
de | ||
]; | ||
function ve(n, s) { | ||
return t(), i("button", ce, ue); | ||
} | ||
const h = /* @__PURE__ */ d(le, [["render", ve]]), pe = { | ||
name: "Sentences", | ||
props: ["sentences"] | ||
}; | ||
function U(t, n, e, l, s, a) { | ||
return r(!0), i(w, null, $(e.sentences, (d, g) => (r(), i("p", { | ||
key: g, | ||
class: "text-base leading-tight p-0 m-0" | ||
}, _(d), 1))), 128); | ||
}, $e = { class: "text-base text-textCustom leading-tight p-0 mr-2" }; | ||
function ge(n, s, e, o, r, a) { | ||
return t(), i("p", $e, g(e.sentences), 1); | ||
} | ||
const W = /* @__PURE__ */ c(R, [["render", U]]), X = { | ||
name: "Dict", | ||
props: ["dicts"] | ||
}, Y = { class: "text-base font-serif italic text-slate-400 capitalize p-0 m-0" }, Z = { class: "text-sm p-0 m-0" }; | ||
function tt(t, n, e, l, s, a) { | ||
return r(), i("div", null, [ | ||
(r(!0), i(w, null, $(e.dicts, (d, g) => (r(), i("div", { | ||
key: g, | ||
class: "mt-2" | ||
}, [ | ||
o("p", Y, _(d.pos), 1), | ||
o("p", Z, _(d.terms), 1) | ||
]))), 128)) | ||
const _e = /* @__PURE__ */ d(pe, [["render", ge]]), me = { | ||
name: "Phonetic", | ||
props: ["phonetic"] | ||
}, fe = { class: "p-0 m-0" }, be = { class: "text-sm font-md text-slate-400" }; | ||
function ye(n, s, e, o, r, a) { | ||
return t(), i("p", fe, [ | ||
u("span", be, "/" + g(e.phonetic) + "/", 1) | ||
]); | ||
} | ||
const et = /* @__PURE__ */ c(X, [["render", tt]]), st = { | ||
revise: nt | ||
}; | ||
function nt(t) { | ||
const n = t.sentences.filter((s) => s.trans).map((s) => s.trans), e = t.sentences.filter((s) => s.src_translit).map((s) => s.src_translit).join(); | ||
let l; | ||
return t.dict && (l = t.dict.map((s) => ({ | ||
pos: s.pos, | ||
terms: s.terms.join(", ") | ||
}))), { | ||
sentences: n, | ||
translits: e, | ||
dicts: l | ||
}; | ||
} | ||
const h = (t) => (v("data-v-55035939"), t = t(), k(), t), ot = { | ||
const he = /* @__PURE__ */ d(me, [["render", ye]]), Se = { class: "flex flex-col" }, ke = { | ||
key: 0, | ||
class: "flex flex-row pb-2 border-b border-[#D3D4D9] pl-10" | ||
}, S = { | ||
__name: "Header", | ||
props: { | ||
tts: String, | ||
sentences: String, | ||
phonetic: String, | ||
isLongSentence: Boolean, | ||
isServiceUnavailable: Boolean, | ||
isFavorite: Boolean, | ||
isFavoriteFeatureEnabled: Boolean | ||
}, | ||
emits: ["favorite", "setting", "close"], | ||
setup(n, { emit: s }) { | ||
const e = n, o = s; | ||
return (r, a) => (t(), i("div", Se, [ | ||
u("div", { | ||
class: _(["flex p-2 pt-2 pb-0", { | ||
"flex-row-reverse": e.isLongSentence, | ||
"flex-row justify-between": !e.isLongSentence | ||
}]) | ||
}, [ | ||
u("div", { | ||
class: _(["flex flex-row gap-2", { "order-2": e.isLongSentence, "items-center": !e.isLongSentence }]) | ||
}, [ | ||
e.tts && !n.isLongSentence ? (t(), c(f, { | ||
key: 0, | ||
tts: e.tts | ||
}, null, 8, ["tts"])) : v("", !0), | ||
p(_e, { | ||
sentences: n.isServiceUnavailable ? ["Service Unavailable"] : e.sentences | ||
}, null, 8, ["sentences"]) | ||
], 2), | ||
u("div", { | ||
class: _(["flex", { | ||
"flex-col items-end": e.isLongSentence, | ||
"flex-row justify-right items-center ml-2": !e.isLongSentence | ||
}]) | ||
}, [ | ||
e.isLongSentence ? (t(), i($, { key: 0 }, [ | ||
p(h, { | ||
onClick: a[0] || (a[0] = (l) => o("close")) | ||
}), | ||
e.tts ? (t(), c(f, { | ||
key: 0, | ||
tts: e.tts | ||
}, null, 8, ["tts"])) : v("", !0), | ||
!n.isServiceUnavailable && e.isFavoriteFeatureEnabled ? (t(), c(b, { | ||
key: 1, | ||
isFilled: e.isFavorite, | ||
onClick: a[1] || (a[1] = (l) => o("favorite")) | ||
}, null, 8, ["isFilled"])) : v("", !0), | ||
p(y, { | ||
onClick: a[2] || (a[2] = (l) => o("setting")) | ||
}) | ||
], 64)) : (t(), i($, { key: 1 }, [ | ||
!n.isServiceUnavailable && e.isFavoriteFeatureEnabled ? (t(), c(b, { | ||
key: 0, | ||
isFilled: e.isFavorite, | ||
onClick: a[3] || (a[3] = (l) => o("favorite")) | ||
}, null, 8, ["isFilled"])) : v("", !0), | ||
p(y, { | ||
onClick: a[4] || (a[4] = (l) => o("setting")) | ||
}), | ||
p(h, { | ||
onClick: a[5] || (a[5] = (l) => o("close")) | ||
}) | ||
], 64)) | ||
], 2) | ||
], 2), | ||
e.isLongSentence ? v("", !0) : (t(), i("div", ke, [ | ||
e.phonetic ? (t(), c(he, { | ||
key: 0, | ||
phonetic: e.phonetic | ||
}, null, 8, ["phonetic"])) : v("", !0) | ||
])) | ||
])); | ||
} | ||
}, Fe = { | ||
key: 0, | ||
class: "flex justify-center" | ||
}, rt = { | ||
}, xe = { | ||
key: 1, | ||
class: "wrapper drop-shadow-2xl rounded text-slate-900 bg-white text-sm" | ||
}, it = { class: "rounded" }, lt = { class: "absolute top-0 right-0 p-2 w-auto bg-slate-200 rounded-bs-lg rounded-te-lg opacity-0 hover:opacity-100" }, at = { | ||
key: 0, | ||
xmlns: "http://www.w3.org/2000/svg", | ||
fill: "none", | ||
viewBox: "0 0 24 24", | ||
"stroke-width": "1.5", | ||
stroke: "currentColor", | ||
class: "h-4 w-4 inline mr-1" | ||
}, ct = /* @__PURE__ */ h(() => /* @__PURE__ */ o("path", { | ||
"stroke-linecap": "round", | ||
"stroke-linejoin": "round", | ||
d: "M17.593 3.322c1.1.128 1.907 1.077 1.907 2.185V21L12 17.25 4.5 21V5.507c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0111.186 0z" | ||
}, null, -1)), dt = [ | ||
ct | ||
], pt = { | ||
key: 1, | ||
xmlns: "http://www.w3.org/2000/svg", | ||
viewBox: "0 0 24 24", | ||
fill: "currentColor", | ||
class: "h-4 w-4 inline mr-1" | ||
}, ut = /* @__PURE__ */ h(() => /* @__PURE__ */ o("path", { | ||
"fill-rule": "evenodd", | ||
d: "M6.32 2.577a49.255 49.255 0 0111.36 0c1.497.174 2.57 1.46 2.57 2.93V21a.75.75 0 01-1.085.67L12 18.089l-7.165 3.583A.75.75 0 013.75 21V5.507c0-1.47 1.073-2.756 2.57-2.93z", | ||
"clip-rule": "evenodd" | ||
}, null, -1)), _t = [ | ||
ut | ||
], ht = /* @__PURE__ */ h(() => /* @__PURE__ */ o("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
class: "h-4 w-4 inline mr-1", | ||
fill: "none", | ||
viewBox: "0 0 24 24", | ||
stroke: "currentColor", | ||
"stroke-width": "2" | ||
}, [ | ||
/* @__PURE__ */ o("path", { | ||
"stroke-linecap": "round", | ||
"stroke-linejoin": "round", | ||
d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" | ||
}), | ||
/* @__PURE__ */ o("path", { | ||
"stroke-linecap": "round", | ||
"stroke-linejoin": "round", | ||
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" | ||
}) | ||
], -1)), gt = [ | ||
ht | ||
], mt = /* @__PURE__ */ h(() => /* @__PURE__ */ o("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
class: "h-4 w-4 inline", | ||
fill: "none", | ||
viewBox: "0 0 24 24", | ||
stroke: "currentColor", | ||
"stroke-width": "2" | ||
}, [ | ||
/* @__PURE__ */ o("path", { | ||
"stroke-linecap": "round", | ||
"stroke-linejoin": "round", | ||
d: "M6 18L18 6M6 6l12 12" | ||
}) | ||
], -1)), wt = [ | ||
mt | ||
], $t = { class: "body" }, vt = { | ||
class: "wrapper drop-shadow-2xl rounded-lg text-slate-900 bg-white text-sm border border-solid border-neutral-300" | ||
}, Le = { | ||
name: "Bubble", | ||
props: ["google", "tts", "status", "isSaved"], | ||
emits: ["logo", "save", "settings", "close"], | ||
props: ["translationData", "tts", "status", "isFavorite", "isFavoriteFeatureEnabled"], | ||
emits: ["logo", "favorite", "settings", "close"], | ||
data() { | ||
return { | ||
data: null | ||
data: null, | ||
isLongSentence: !1, | ||
isServiceUnavailable: !1 | ||
}; | ||
}, | ||
created() { | ||
this.data = st.revise(this.google); | ||
try { | ||
this.data = this.translationData, !this.data.dictionary || this.data.dictionary.length === 0 ? this.isLongSentence = !0 : this.isLongSentence = !1, this.isServiceUnavailable = !1; | ||
} catch { | ||
this.isServiceUnavailable = !0; | ||
} | ||
} | ||
}, kt = /* @__PURE__ */ Object.assign(vt, { | ||
setup(t) { | ||
return (n, e) => t.status < 2 ? (r(), i("div", ot, [ | ||
t.status === 0 ? (r(), u(C, { | ||
}, Ce = /* @__PURE__ */ Object.assign(Le, { | ||
setup(n) { | ||
return (s, e) => n.status < 2 ? (t(), i("div", Fe, [ | ||
n.status === 0 ? (t(), c(D, { | ||
key: 0, | ||
onClick: e[0] || (e[0] = (l) => n.$emit("logo")) | ||
})) : (r(), u(V, { key: 1 })) | ||
])) : (r(), i("div", rt, [ | ||
o("div", it, [ | ||
o("div", lt, [ | ||
t.tts ? (r(), u(Q, { | ||
key: 0, | ||
tts: t.tts | ||
}, null, 8, ["tts"])) : p("", !0), | ||
o("span", { | ||
onClick: e[1] || (e[1] = (l) => n.$emit("save")) | ||
}, [ | ||
t.isSaved ? (r(), i("svg", pt, _t)) : (r(), i("svg", at, dt)) | ||
]), | ||
o("span", { | ||
onClick: e[2] || (e[2] = (l) => n.$emit("settings")) | ||
}, gt), | ||
o("span", { | ||
onClick: e[3] || (e[3] = (l) => n.$emit("close")) | ||
}, wt) | ||
]), | ||
o("div", $t, [ | ||
n.data.translits ? (r(), u(E, { | ||
key: 0, | ||
translits: n.data.translits | ||
}, null, 8, ["translits"])) : p("", !0), | ||
m(W, { | ||
sentences: n.data.sentences | ||
}, null, 8, ["sentences"]), | ||
m(et, { | ||
dicts: n.data.dicts | ||
}, null, 8, ["dicts"]) | ||
]) | ||
]) | ||
onClick: e[0] || (e[0] = (o) => s.$emit("logo")) | ||
})) : (t(), c(z, { key: 1 })) | ||
])) : (t(), i("div", xe, [ | ||
s.isServiceUnavailable ? (t(), c(S, { | ||
key: 0, | ||
isServiceUnavailable: s.isServiceUnavailable, | ||
isLongSentence: !1, | ||
onFavorite: e[1] || (e[1] = (o) => s.$emit("favorite")), | ||
onSetting: e[2] || (e[2] = (o) => s.$emit("settings")), | ||
onClose: e[3] || (e[3] = (o) => s.$emit("close")) | ||
}, null, 8, ["isServiceUnavailable"])) : (t(), c(S, { | ||
key: 1, | ||
tts: n.tts, | ||
sentences: s.data.result, | ||
phonetic: s.data.phonetic.src, | ||
isFavorite: n.isFavorite, | ||
isFavoriteFeatureEnabled: n.isFavoriteFeatureEnabled, | ||
onFavorite: e[4] || (e[4] = (o) => s.$emit("favorite")), | ||
onSetting: e[5] || (e[5] = (o) => s.$emit("settings")), | ||
onClose: e[6] || (e[6] = (o) => s.$emit("close")), | ||
isLongSentence: s.isLongSentence | ||
}, null, 8, ["tts", "sentences", "phonetic", "isFavorite", "isFavoriteFeatureEnabled", "isLongSentence"])), | ||
s.isServiceUnavailable ? v("", !0) : (t(), c(I, { | ||
key: 2, | ||
class: "p-3 pt-0", | ||
dictionary: s.data.dictionary | ||
}, null, 8, ["dictionary"])) | ||
])); | ||
} | ||
}), yt = /* @__PURE__ */ c(kt, [["__scopeId", "data-v-55035939"]]); | ||
}); | ||
export { | ||
yt as default | ||
Ce as default | ||
}; |
@@ -1,1 +0,1 @@ | ||
(function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.Bubble={},c.Vue))})(this,function(c,e){"use strict";const _="/ddict-logo.png",l=(t,s)=>{const o=t.__vccOpts||t;for(const[r,n]of s)o[r]=n;return o},m={name:"Logo"},h={src:_,alt:"DDict Logo",class:"w-6 h-6 cursor-pointer"};function k(t,s,o,r,n,i){return e.openBlock(),e.createElementBlock("img",h)}const g=l(m,[["render",k]]),f="/ddict-loading.gif",$={name:"Loading"},w={class:"rounded bg-white p-1"},B=[e.createElementVNode("img",{src:f,alt:"Loading",class:"w-12"},null,-1)];function y(t,s,o,r,n,i){return e.openBlock(),e.createElementBlock("div",w,B)}const u=l($,[["render",y]]),E={name:"Translit",props:["translits"]},V={class:"text-sm font-mono truncate p-0 m-0 w-2/3"},N={class:"text-slate-500"};function x(t,s,o,r,n,i){return e.openBlock(),e.createElementBlock("p",V,[e.createElementVNode("span",N,"/"+e.toDisplayString(o.translits)+"/",1)])}const b=l(E,[["render",x]]),C={name:"Player",props:["tts"],data(){return{playing:!1,player:new Audio(this.tts),err:null}},watch:{playing(t){if(!t){this.player.pause();return}this.player.play()}},created(){this.player.onended=()=>{this.playing=!1},this.player.onerror=t=>{this.err=t}},methods:{play(){this.playing=!this.playing}}},j={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},S=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"},null,-1)],L={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},M=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"},null,-1)];function z(t,s,o,r,n,i){return n.err?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,onClick:s[0]||(s[0]=(...a)=>i.play&&i.play(...a))},[n.playing?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("svg",j,S)),n.playing?(e.openBlock(),e.createElementBlock("svg",L,M)):e.createCommentVNode("",!0)]))}const D=l(C,[["render",z]]),T={name:"Sentences",props:["sentences"]};function I(t,s,o,r,n,i){return e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.sentences,(a,p)=>(e.openBlock(),e.createElementBlock("p",{key:p,class:"text-base leading-tight p-0 m-0"},e.toDisplayString(a),1))),128)}const O=l(T,[["render",I]]),P={name:"Dict",props:["dicts"]},A={class:"text-base font-serif italic text-slate-400 capitalize p-0 m-0"},F={class:"text-sm p-0 m-0"};function q(t,s,o,r,n,i){return e.openBlock(),e.createElementBlock("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.dicts,(a,p)=>(e.openBlock(),e.createElementBlock("div",{key:p,class:"mt-2"},[e.createElementVNode("p",A,e.toDisplayString(a.pos),1),e.createElementVNode("p",F,e.toDisplayString(a.terms),1)]))),128))])}const G=l(P,[["render",q]]),H={revise:J};function J(t){const s=t.sentences.filter(n=>n.trans).map(n=>n.trans),o=t.sentences.filter(n=>n.src_translit).map(n=>n.src_translit).join();let r;return t.dict&&(r=t.dict.map(n=>({pos:n.pos,terms:n.terms.join(", ")}))),{sentences:s,translits:o,dicts:r}}const d=t=>(e.pushScopeId("data-v-55035939"),t=t(),e.popScopeId(),t),K={key:0,class:"flex justify-center"},Q={key:1,class:"wrapper drop-shadow-2xl rounded text-slate-900 bg-white text-sm"},R={class:"rounded"},U={class:"absolute top-0 right-0 p-2 w-auto bg-slate-200 rounded-bs-lg rounded-te-lg opacity-0 hover:opacity-100"},W={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"h-4 w-4 inline mr-1"},X=[d(()=>e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.593 3.322c1.1.128 1.907 1.077 1.907 2.185V21L12 17.25 4.5 21V5.507c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0111.186 0z"},null,-1))],Y={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:"h-4 w-4 inline mr-1"},Z=[d(()=>e.createElementVNode("path",{"fill-rule":"evenodd",d:"M6.32 2.577a49.255 49.255 0 0111.36 0c1.497.174 2.57 1.46 2.57 2.93V21a.75.75 0 01-1.085.67L12 18.089l-7.165 3.583A.75.75 0 013.75 21V5.507c0-1.47 1.073-2.756 2.57-2.93z","clip-rule":"evenodd"},null,-1))],v=[d(()=>e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1))],ee=[d(()=>e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1))],te={class:"body"},oe=l(Object.assign({name:"Bubble",props:["google","tts","status","isSaved"],emits:["logo","save","settings","close"],data(){return{data:null}},created(){this.data=H.revise(this.google)}},{setup(t){return(s,o)=>t.status<2?(e.openBlock(),e.createElementBlock("div",K,[t.status===0?(e.openBlock(),e.createBlock(g,{key:0,onClick:o[0]||(o[0]=r=>s.$emit("logo"))})):(e.openBlock(),e.createBlock(u,{key:1}))])):(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("div",R,[e.createElementVNode("div",U,[t.tts?(e.openBlock(),e.createBlock(D,{key:0,tts:t.tts},null,8,["tts"])):e.createCommentVNode("",!0),e.createElementVNode("span",{onClick:o[1]||(o[1]=r=>s.$emit("save"))},[t.isSaved?(e.openBlock(),e.createElementBlock("svg",Y,Z)):(e.openBlock(),e.createElementBlock("svg",W,X))]),e.createElementVNode("span",{onClick:o[2]||(o[2]=r=>s.$emit("settings"))},v),e.createElementVNode("span",{onClick:o[3]||(o[3]=r=>s.$emit("close"))},ee)]),e.createElementVNode("div",te,[s.data.translits?(e.openBlock(),e.createBlock(b,{key:0,translits:s.data.translits},null,8,["translits"])):e.createCommentVNode("",!0),e.createVNode(O,{sentences:s.data.sentences},null,8,["sentences"]),e.createVNode(G,{dicts:s.data.dicts},null,8,["dicts"])])])]))}}),[["__scopeId","data-v-55035939"]]);c.default=oe,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.Bubble={},r.Vue))})(this,function(r,e){"use strict";const $="/assets/icons/ddict-logo.svg",a=(o,n)=>{const t=o.__vccOpts||o;for(const[s,l]of n)t[s]=l;return t},g={name:"Logo"},f={src:$,alt:"DDict Logo",class:"w-6 h-6 cursor-pointer"};function B(o,n,t,s,l,i){return e.openBlock(),e.createElementBlock("img",f)}const b=a(g,[["render",B]]),y="/ddict-loading.gif",h={name:"Loading"},S={class:"rounded bg-white p-1"},E=[e.createElementVNode("img",{src:y,alt:"Loading",class:"w-12"},null,-1)];function F(o,n,t,s,l,i){return e.openBlock(),e.createElementBlock("div",S,E)}const x=a(h,[["render",F]]),C={name:"Dict",props:["dictionary"]},L={class:"capitalize text-base italic font-normal text-slate-400"};function V(o,n,t,s,l,i){return e.openBlock(),e.createElementBlock("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.dictionary,(c,ke)=>(e.openBlock(),e.createElementBlock("div",{key:ke,class:"mt-2"},[e.createElementVNode("p",L,e.toDisplayString(c.pos),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.terms,(_e,$e)=>(e.openBlock(),e.createElementBlock("span",{key:$e,class:"text-base leading-6 text-textCustom"},e.toDisplayString(_e)+", ",1))),128))]))),128))])}const w=a(C,[["render",V]]),N="/assets/icons/volume.svg",u="/assets/icons/volume-stop.svg",D={name:"Player",props:["tts"],data(){return{playing:!1,player:new Audio(this.tts),err:null}},watch:{playing(o){if(!o){this.player.pause();return}this.player.play()}},created(){this.player.onended=()=>{this.playing=!1},this.player.onerror=o=>{this.err=o}},methods:{play(){this.playing=!this.playing}}},U={key:0,class:"w-5",src:N,alt:"Play"},j={key:1,class:"w-5",src:u,alt:"Stop"};function P(o,n,t,s,l,i){return e.openBlock(),e.createElementBlock("button",{class:"btn btn-xs btn-ghost btn-circle",onClick:n[0]||(n[0]=(...c)=>i.play&&i.play(...c))},[l.playing?(e.openBlock(),e.createElementBlock("img",j)):(e.openBlock(),e.createElementBlock("img",U))])}const d=a(D,[["render",P]]),z="/assets/icons/favorite-filled.svg",O="/assets/icons/favorite.svg",T={name:"Favorite",props:["isFilled"]},M={class:"btn btn-xs btn-circle btn-ghost"},q={key:0,class:"w-5",src:z,alt:"Clear"},A={key:1,class:"w-5",src:O,alt:"Clear"};function H(o,n,t,s,l,i){return e.openBlock(),e.createElementBlock("button",M,[t.isFilled?(e.openBlock(),e.createElementBlock("img",q)):(e.openBlock(),e.createElementBlock("img",A))])}const p=a(T,[["render",H]]),I="/assets/icons/setting.svg",G={},J={class:"btn btn-xs btn-ghost btn-circle"},K=[e.createElementVNode("img",{class:"w-5",src:I,alt:"Icon description"},null,-1)];function Q(o,n){return e.openBlock(),e.createElementBlock("button",J,K)}const m=a(G,[["render",Q]]),R="/assets/icons/cancel.svg",W={},X={class:"btn btn-xs btn-circle btn-ghost"},Y=[e.createElementVNode("img",{class:"w-5",src:R,alt:"Clear"},null,-1)];function Z(o,n){return e.openBlock(),e.createElementBlock("button",X,Y)}const k=a(W,[["render",Z]]),v={name:"Sentences",props:["sentences"]},ee={class:"text-base text-textCustom leading-tight p-0 mr-2"};function te(o,n,t,s,l,i){return e.openBlock(),e.createElementBlock("p",ee,e.toDisplayString(t.sentences),1)}const ne=a(v,[["render",te]]),oe={name:"Phonetic",props:["phonetic"]},se={class:"p-0 m-0"},ie={class:"text-sm font-md text-slate-400"};function le(o,n,t,s,l,i){return e.openBlock(),e.createElementBlock("p",se,[e.createElementVNode("span",ie,"/"+e.toDisplayString(t.phonetic)+"/",1)])}const ce=a(oe,[["render",le]]),ae={class:"flex flex-col"},re={key:0,class:"flex flex-row pb-2 border-b border-[#D3D4D9] pl-10"},_={__name:"Header",props:{tts:String,sentences:String,phonetic:String,isLongSentence:Boolean,isServiceUnavailable:Boolean,isFavorite:Boolean,isFavoriteFeatureEnabled:Boolean},emits:["favorite","setting","close"],setup(o,{emit:n}){const t=o,s=n;return(l,i)=>(e.openBlock(),e.createElementBlock("div",ae,[e.createElementVNode("div",{class:e.normalizeClass(["flex p-2 pt-2 pb-0",{"flex-row-reverse":t.isLongSentence,"flex-row justify-between":!t.isLongSentence}])},[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-row gap-2",{"order-2":t.isLongSentence,"items-center":!t.isLongSentence}])},[t.tts&&!o.isLongSentence?(e.openBlock(),e.createBlock(d,{key:0,tts:t.tts},null,8,["tts"])):e.createCommentVNode("",!0),e.createVNode(ne,{sentences:o.isServiceUnavailable?["Service Unavailable"]:t.sentences},null,8,["sentences"])],2),e.createElementVNode("div",{class:e.normalizeClass(["flex",{"flex-col items-end":t.isLongSentence,"flex-row justify-right items-center ml-2":!t.isLongSentence}])},[t.isLongSentence?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(k,{onClick:i[0]||(i[0]=c=>s("close"))}),t.tts?(e.openBlock(),e.createBlock(d,{key:0,tts:t.tts},null,8,["tts"])):e.createCommentVNode("",!0),!o.isServiceUnavailable&&t.isFavoriteFeatureEnabled?(e.openBlock(),e.createBlock(p,{key:1,isFilled:t.isFavorite,onClick:i[1]||(i[1]=c=>s("favorite"))},null,8,["isFilled"])):e.createCommentVNode("",!0),e.createVNode(m,{onClick:i[2]||(i[2]=c=>s("setting"))})],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[!o.isServiceUnavailable&&t.isFavoriteFeatureEnabled?(e.openBlock(),e.createBlock(p,{key:0,isFilled:t.isFavorite,onClick:i[3]||(i[3]=c=>s("favorite"))},null,8,["isFilled"])):e.createCommentVNode("",!0),e.createVNode(m,{onClick:i[4]||(i[4]=c=>s("setting"))}),e.createVNode(k,{onClick:i[5]||(i[5]=c=>s("close"))})],64))],2)],2),t.isLongSentence?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",re,[t.phonetic?(e.openBlock(),e.createBlock(ce,{key:0,phonetic:t.phonetic},null,8,["phonetic"])):e.createCommentVNode("",!0)]))]))}},de={key:0,class:"flex justify-center"},pe={key:1,class:"wrapper drop-shadow-2xl rounded-lg text-slate-900 bg-white text-sm border border-solid border-neutral-300"},me=Object.assign({name:"Bubble",props:["translationData","tts","status","isFavorite","isFavoriteFeatureEnabled"],emits:["logo","favorite","settings","close"],data(){return{data:null,isLongSentence:!1,isServiceUnavailable:!1}},created(){try{this.data=this.translationData,!this.data.dictionary||this.data.dictionary.length===0?this.isLongSentence=!0:this.isLongSentence=!1,this.isServiceUnavailable=!1}catch{this.isServiceUnavailable=!0}}},{setup(o){return(n,t)=>o.status<2?(e.openBlock(),e.createElementBlock("div",de,[o.status===0?(e.openBlock(),e.createBlock(b,{key:0,onClick:t[0]||(t[0]=s=>n.$emit("logo"))})):(e.openBlock(),e.createBlock(x,{key:1}))])):(e.openBlock(),e.createElementBlock("div",pe,[n.isServiceUnavailable?(e.openBlock(),e.createBlock(_,{key:0,isServiceUnavailable:n.isServiceUnavailable,isLongSentence:!1,onFavorite:t[1]||(t[1]=s=>n.$emit("favorite")),onSetting:t[2]||(t[2]=s=>n.$emit("settings")),onClose:t[3]||(t[3]=s=>n.$emit("close"))},null,8,["isServiceUnavailable"])):(e.openBlock(),e.createBlock(_,{key:1,tts:o.tts,sentences:n.data.result,phonetic:n.data.phonetic.src,isFavorite:o.isFavorite,isFavoriteFeatureEnabled:o.isFavoriteFeatureEnabled,onFavorite:t[4]||(t[4]=s=>n.$emit("favorite")),onSetting:t[5]||(t[5]=s=>n.$emit("settings")),onClose:t[6]||(t[6]=s=>n.$emit("close")),isLongSentence:n.isLongSentence},null,8,["tts","sentences","phonetic","isFavorite","isFavoriteFeatureEnabled","isLongSentence"])),n.isServiceUnavailable?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(w,{key:2,class:"p-3 pt-0",dictionary:n.data.dictionary},null,8,["dictionary"]))]))}});r.default=me,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "@ddict/bubble", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"type": "module", | ||
@@ -23,2 +23,3 @@ "files": [ | ||
"daisyui": "^4.12.10", | ||
"textarea-caret": "^3.1.0", | ||
"vue": "^3.4.31" | ||
@@ -25,0 +26,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85536
21
435
7
1
+ Addedtextarea-caret@^3.1.0
+ Addedtextarea-caret@3.1.0(transitive)