@project-trans/suggestion-box
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,11 +0,1 @@ | ||
declare function mount(props: { | ||
attachImageButtonText?: string; | ||
sendButtonText?: string; | ||
sendingButtonText?: string; | ||
sentSuccessButtonText?: string; | ||
sentFailedButtonText?: string; | ||
targetUrl?: string; | ||
textContentPlaceholder?: string; | ||
contactContentPlaceholder?: string; | ||
}, rootContainer: string | Element): void; | ||
export default mount; | ||
export {}; |
@@ -1,4 +0,3 @@ | ||
import App from './App.vue'; | ||
import '@unocss/reset/tailwind.css'; | ||
import 'virtual:uno.css'; | ||
export default App; | ||
import './aio'; | ||
export {}; |
import App from './App.vue'; | ||
import 'uno.css'; | ||
export default App; |
@@ -1,2 +0,336 @@ | ||
import{defineComponent as w,ref as o,watch as T,openBlock as u,createElementBlock as i,withModifiers as E,createElementVNode as t,withDirectives as y,vModelText as g,toDisplayString as m,Fragment as b,renderList as D,createCommentVNode as j,normalizeClass as A,createVNode as U,Transition as _,withCtx as P}from"vue";const L=["placeholder"],R={class:"inline-grid items-stretch sb-auto-height"},S=["placeholder"],V={class:"m-2"},I={key:0},N={class:"cursor-pointer appearance-none m-0!"},O={class:"flex overflow-x-scroll space-x-4"},M=["onClick"],$=["src"],q={class:"flex justify-around gap-2 rounded-b-md p-2 !<sm:flex-col",bg:"zinc-50 dark:zinc-900"},G=["aria-label"],H={text:"sm"},J=["aria-label","disabled"],K={class:"flex items-center justify-center"},Q={key:0,flex:"","items-center":"","space-x-1":""},W={text:"sm"},X={key:1,flex:"","items-center":"","space-x-1":""},Y={text:"sm"},Z={key:2,flex:"","items-center":"","space-x-1":""},ee={text:"sm"},te={text:"sm"};var ae=w({__name:"App",props:{attachImageButtonText:{default:"\u9644\u52A0\u56FE\u7247"},sendButtonText:{default:"\u53D1\u9001"},sendingButtonText:{default:"\u53D1\u9001\u4E2D..."},sentSuccessButtonText:{default:"\u53D1\u9001\u6210\u529F\uFF0C\u8C22\u8C22\u53CD\u9988"},sentFailedButtonText:{default:"\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"},targetUrl:{default:""},textContentPlaceholder:{default:"\u8F93\u5165\u5185\u5BB9"},contactContentPlaceholder:{default:"\uFF08\u53EF\u9009\uFF09\u7559\u4E0B\u60A8\u7684\u8054\u7CFB\u65B9\u5F0F\uFF0C\u65B9\u4FBF\u6211\u4EEC\u76F4\u63A5\u4E0E\u60A8\u8054\u7CFB"}},setup(z){const c=z,p=o(),v=o(""),x=o(""),l=o([]),f=o([]),d=o(!1),s=o(!1),r=o(!1);T(l,a=>{f.value.forEach(e=>URL.revokeObjectURL(e)),f.value=a.map(e=>URL.createObjectURL(e))},{deep:!0});function k(a){const e=Array.from(a.target.files??[]);if(l.value.length===0){l.value=e;return}e.forEach(n=>{l.value.find(h=>h.name===n.name)||l.value.push(n)})}function F(){p.value&&(p.value.value="",p?.value.click())}function C(a){f.value.splice(a,1),l.value.splice(a,1)}async function B(){if(s.value=!1,r.value=!1,!v.value)return;const a=new FormData;if(a.append("textContent",v.value),x.value&&a.append("contactContent",x.value),l.value)for(let e=0;e<l.value.length;e+=1)a.append("images",l.value[e]);try{d.value=!0,await fetch(c.targetUrl||"",{method:"POST",body:a,mode:"no-cors"}),d.value=!1}catch(e){d.value=!1,r.value=!0,console.error(e),setTimeout(()=>{s.value=!1,r.value=!1},2e3);return}s.value=!0,setTimeout(()=>{s.value=!1,r.value=!1},2e3)}return(a,e)=>(u(),i("form",{class:"flex flex-col overflow-hidden rounded-lg",border:"2 solid zinc-200 dark:zinc-800",onSubmit:E(()=>{},["prevent"])},[t("label",null,[y(t("input",{"onUpdate:modelValue":e[0]||(e[0]=n=>x.value=n),class:"min-h-0 w-full resize-none rounded-t-md border-none p-2 outline-none",bg:"zinc-100 dark:zinc-900",text:"sm",placeholder:a.contactContentPlaceholder},null,8,L),[[g,x.value]])]),t("label",R,[y(t("textarea",{"onUpdate:modelValue":e[1]||(e[1]=n=>v.value=n),class:"min-h-0 resize-none rounded-t-md border-none p-2 outline-none",bg:"$vp-c-bg",placeholder:a.textContentPlaceholder},null,8,S),[[g,v.value]])]),t("div",V,[f.value.length!==0?(u(),i("details",I,[t("summary",N,[t("span",null," \u5F53\u524D\u9009\u4E2D\u4E86 "+m(f.value.length)+" \u5F20\u56FE\u7247 ",1)]),t("div",O,[(u(!0),i(b,null,D(f.value,(n,h)=>(u(),i("div",{key:n,class:"relative"},[t("button",{class:"absolute right-1 top-1 h-8 w-8 inline-flex items-center justify-center rounded-md duration-250",transition:"all ease-in-out",bg:"zinc-800 opacity-60 hover:opacity-80 active:opacity-50",text:"zinc-100",onClick:le=>C(h)},e[2]||(e[2]=[t("div",{"i-octicon:trash-24":"",class:"h-4 w-4 flex items-center justify-center"},null,-1)]),8,M),t("img",{src:n,class:"block aspect-video h-full max-h-40 min-h-40 min-w-60 w-full overflow-hidden rounded-md object-cover",alt:"\u56FE\u7247"},null,8,$)]))),128))])])):j("v-if",!0)]),t("div",q,[t("label",{"aria-label":c.attachImageButtonText,class:"w-full flex justify-center"},[t("input",{ref_key:"inputFile",ref:p,type:"file",accept:"image/*",multiple:"",hidden:"",onChange:k},null,544),t("button",{class:"w-full flex items-center justify-center rounded-md px-2 py-2 duration-250",transition:"all ease-in-out",bg:"zinc-200 hover:zinc-300 active:zinc-400 dark:zinc-800 dark:hover:zinc-700 dark:active:zinc-600",text:"zinc-700 dark:zinc-300 base",onClick:F},[e[3]||(e[3]=t("div",{"i-octicon:image-24":"",class:"mr-1 flex items-center justify-center"},null,-1)),t("span",H,m(c.attachImageButtonText),1)])],8,G),t("button",{type:"submit","aria-label":c.sendButtonText,class:A([[!v.value||d.value||s.value||r.value?"cursor-not-allowed":"",d.value||s.value||r.value?"text-zinc-700 disabled:text-zinc-700 dark:text-zinc-300 dark:disabled:text-zinc-300":"text-zinc-700 disabled:text-zinc-400 dark:text-zinc-300 dark:disabled:text-zinc-600"],"block w-full flex cursor-pointer justify-center rounded-md px-2 py-2 duration-250"]),transition:"all ease-in-out",bg:"zinc-200 hover:zinc-300 active:zinc-400 dark:zinc-800 dark:hover:zinc-700 dark:active:zinc-600",text:"base",disabled:!v.value||d.value||s.value||r.value,onClick:B},[t("div",K,[U(_,{mode:"out-in","enter-active-class":"transition-all duration-200 ease-out","leave-active-class":"transition-all duration-200 ease-out","enter-from-class":"transform translate-y-10px opacity-0","leave-to-class":"transform translate-y--10px opacity-0","enter-to-class":"opacity-100","leave-from-class":"opacity-100"},{default:P(()=>[s.value?(u(),i("span",Q,[e[4]||(e[4]=t("div",{"i-octicon:check-circle-fill-24":"",class:"mr-1 flex items-center justify-center text-green-600"},null,-1)),t("span",W,m(c.sentSuccessButtonText),1)])):r.value?(u(),i("span",X,[e[5]||(e[5]=t("div",{"i-octicon:alert-fill-24":"",class:"mr-1 flex items-center justify-center text-red-600"},null,-1)),t("span",Y,m(c.sentFailedButtonText),1)])):(u(),i("span",Z,[d.value?(u(),i(b,{key:1},[e[7]||(e[7]=t("div",{"i-svg-spinners:180-ring-with-bg":"",class:"mr-1 flex items-center justify-center"},null,-1)),t("span",te,m(c.sendingButtonText),1)],64)):(u(),i(b,{key:0},[e[6]||(e[6]=t("div",{"i-octicon:paper-airplane-24":"",class:"mr-1 flex items-center justify-center"},null,-1)),t("span",ee,m(c.sendButtonText),1)],64))]))]),_:1})])],10,J)])],32))}});export{ae as default}; | ||
//# sourceMappingURL=index.js.map | ||
import { defineComponent as j, ref as u, watch as B, openBlock as s, createElementBlock as o, withModifiers as U, createElementVNode as t, withDirectives as y, vModelText as k, toDisplayString as p, Fragment as h, renderList as S, createCommentVNode as F, normalizeClass as I, createVNode as L, Transition as P, withCtx as R } from "vue"; | ||
const V = ["placeholder"], D = { class: "inline-grid items-stretch sb-auto-height" }, E = ["placeholder"], N = { class: "m-2" }, O = { key: 0 }, A = { class: "cursor-pointer appearance-none m-0!" }, M = { class: "flex overflow-x-scroll space-x-4" }, $ = ["onClick"], q = ["src"], G = { | ||
class: "flex justify-around gap-2 rounded-b-md p-2 !<sm:flex-col", | ||
bg: "zinc-50 dark:zinc-900" | ||
}, H = ["aria-label"], J = { text: "sm" }, K = ["aria-label", "disabled"], Q = { class: "flex items-center justify-center" }, W = { | ||
key: 0, | ||
flex: "", | ||
"items-center": "", | ||
"space-x-1": "" | ||
}, X = { text: "sm" }, Y = { | ||
key: 1, | ||
flex: "", | ||
"items-center": "", | ||
"space-x-1": "" | ||
}, Z = { text: "sm" }, ee = { | ||
key: 2, | ||
flex: "", | ||
"items-center": "", | ||
"space-x-1": "" | ||
}, te = { text: "sm" }, ne = { text: "sm" }, le = /* @__PURE__ */ j({ | ||
__name: "App", | ||
props: { | ||
attachImageButtonText: { default: "附加图片" }, | ||
sendButtonText: { default: "发送" }, | ||
sendingButtonText: { default: "发送中..." }, | ||
sentSuccessButtonText: { default: "发送成功,谢谢反馈" }, | ||
sentFailedButtonText: { default: "发送失败,请稍后再试" }, | ||
targetUrl: { default: "" }, | ||
textContentPlaceholder: { default: "输入内容" }, | ||
contactContentPlaceholder: { default: "(可选)留下您的联系方式,方便我们直接与您联系" } | ||
}, | ||
setup(z) { | ||
const i = z, f = u(), v = u(""), x = u(""), a = u([]), m = u([]), d = u(!1), r = u(!1), c = u(!1); | ||
B( | ||
a, | ||
(n) => { | ||
m.value.forEach((e) => URL.revokeObjectURL(e)), m.value = n.map((e) => URL.createObjectURL(e)); | ||
}, | ||
{ | ||
deep: !0 | ||
} | ||
); | ||
function _(n) { | ||
const e = Array.from(n.target.files ?? []); | ||
if (a.value.length === 0) { | ||
a.value = e; | ||
return; | ||
} | ||
e.forEach((l) => { | ||
a.value.find((g) => g.name === l.name) || a.value.push(l); | ||
}); | ||
} | ||
function w() { | ||
f.value && (f.value.value = "", f == null || f.value.click()); | ||
} | ||
function C(n) { | ||
m.value.splice(n, 1), a.value.splice(n, 1); | ||
} | ||
async function T() { | ||
if (r.value = !1, c.value = !1, !v.value) | ||
return; | ||
const n = new FormData(); | ||
if (n.append("textContent", v.value), x.value && n.append("contactContent", x.value), a.value) | ||
for (let e = 0; e < a.value.length; e += 1) | ||
n.append("images", a.value[e]); | ||
try { | ||
d.value = !0, await fetch(i.targetUrl || "", { | ||
method: "POST", | ||
body: n, | ||
// otherwise the fetch() call will failed even | ||
// when the request has been sent successfully | ||
// due to the CORS policy | ||
mode: "no-cors" | ||
}), d.value = !1; | ||
} catch (e) { | ||
d.value = !1, c.value = !0, console.error(e), setTimeout(() => { | ||
r.value = !1, c.value = !1; | ||
}, 2e3); | ||
return; | ||
} | ||
r.value = !0, setTimeout(() => { | ||
r.value = !1, c.value = !1; | ||
}, 2e3); | ||
} | ||
return (n, e) => (s(), o( | ||
"form", | ||
{ | ||
class: "flex flex-col overflow-hidden rounded-lg", | ||
border: "2 solid zinc-200 dark:zinc-800", | ||
onSubmit: U(() => { | ||
}, ["prevent"]) | ||
}, | ||
[ | ||
t("label", null, [ | ||
y(t("input", { | ||
"onUpdate:modelValue": e[0] || (e[0] = (l) => x.value = l), | ||
class: "min-h-0 w-full resize-none rounded-t-md border-none p-2 text-inherit outline-none", | ||
bg: "zinc-100 dark:zinc-900", | ||
text: "sm", | ||
placeholder: n.contactContentPlaceholder | ||
}, null, 8, V), [ | ||
[k, x.value] | ||
]) | ||
]), | ||
t("label", D, [ | ||
y(t("textarea", { | ||
"onUpdate:modelValue": e[1] || (e[1] = (l) => v.value = l), | ||
class: "min-h-0 resize-none rounded-t-md border-none p-2 text-inherit outline-none", | ||
bg: "$vp-c-bg", | ||
placeholder: n.textContentPlaceholder | ||
}, null, 8, E), [ | ||
[k, v.value] | ||
]) | ||
]), | ||
t("div", N, [ | ||
m.value.length !== 0 ? (s(), o("details", O, [ | ||
t("summary", A, [ | ||
t( | ||
"span", | ||
null, | ||
" 当前选中了 " + p(m.value.length) + " 张图片 ", | ||
1 | ||
/* TEXT */ | ||
) | ||
]), | ||
t("div", M, [ | ||
(s(!0), o( | ||
h, | ||
null, | ||
S(m.value, (l, b) => (s(), o("div", { | ||
key: l, | ||
class: "relative" | ||
}, [ | ||
t("button", { | ||
class: "absolute right-1 top-1 h-8 w-8 inline-flex items-center justify-center rounded-md border-none duration-250", | ||
transition: "all ease-in-out", | ||
bg: "zinc-800 opacity-60 hover:opacity-80 active:opacity-50", | ||
text: "zinc-100", | ||
onClick: (g) => C(b) | ||
}, e[2] || (e[2] = [ | ||
t( | ||
"div", | ||
{ | ||
"i-octicon:trash-24": "", | ||
class: "h-4 w-4 flex items-center justify-center" | ||
}, | ||
null, | ||
-1 | ||
/* HOISTED */ | ||
) | ||
]), 8, $), | ||
t("img", { | ||
src: l, | ||
class: "block aspect-video h-full max-h-40 min-h-40 min-w-60 w-full overflow-hidden rounded-md object-cover", | ||
alt: "图片" | ||
}, null, 8, q) | ||
]))), | ||
128 | ||
/* KEYED_FRAGMENT */ | ||
)) | ||
]) | ||
])) : F("v-if", !0) | ||
]), | ||
t("div", G, [ | ||
t("label", { | ||
"aria-label": i.attachImageButtonText, | ||
class: "w-full flex justify-center" | ||
}, [ | ||
t( | ||
"input", | ||
{ | ||
ref_key: "inputFile", | ||
ref: f, | ||
type: "file", | ||
accept: "image/*", | ||
multiple: "", | ||
hidden: "", | ||
onChange: _ | ||
}, | ||
null, | ||
544 | ||
/* NEED_HYDRATION, NEED_PATCH */ | ||
), | ||
t("button", { | ||
class: "w-full flex items-center justify-center rounded-md border-none px-2 py-2 duration-250", | ||
transition: "all ease-in-out", | ||
bg: "zinc-200 hover:zinc-300 active:zinc-400 dark:zinc-800 dark:hover:zinc-700 dark:active:zinc-600", | ||
text: "zinc-700 dark:zinc-300 base", | ||
onClick: w | ||
}, [ | ||
e[3] || (e[3] = t( | ||
"div", | ||
{ | ||
"i-octicon:image-24": "", | ||
class: "mr-1 flex items-center justify-center" | ||
}, | ||
null, | ||
-1 | ||
/* HOISTED */ | ||
)), | ||
t( | ||
"span", | ||
J, | ||
p(i.attachImageButtonText), | ||
1 | ||
/* TEXT */ | ||
) | ||
]) | ||
], 8, H), | ||
t("button", { | ||
type: "submit", | ||
"aria-label": i.sendButtonText, | ||
class: I([[ | ||
!v.value || d.value || r.value || c.value ? "cursor-not-allowed" : "", | ||
d.value || r.value || c.value ? "text-zinc-700 disabled:text-zinc-700 dark:text-zinc-300 dark:disabled:text-zinc-300" : "text-zinc-700 disabled:text-zinc-400 dark:text-zinc-300 dark:disabled:text-zinc-600" | ||
], "block w-full flex cursor-pointer justify-center rounded-md border-none px-2 py-2 duration-250"]), | ||
transition: "all ease-in-out", | ||
bg: "zinc-200 hover:zinc-300 active:zinc-400 dark:zinc-800 dark:hover:zinc-700 dark:active:zinc-600", | ||
text: "base", | ||
disabled: !v.value || d.value || r.value || c.value, | ||
onClick: T | ||
}, [ | ||
t("div", Q, [ | ||
L(P, { | ||
mode: "out-in", | ||
"enter-active-class": "transition-all duration-200 ease-out", | ||
"leave-active-class": "transition-all duration-200 ease-out", | ||
"enter-from-class": "transform translate-y-10px opacity-0", | ||
"leave-to-class": "transform translate-y--10px opacity-0", | ||
"enter-to-class": "opacity-100", | ||
"leave-from-class": "opacity-100" | ||
}, { | ||
default: R(() => [ | ||
r.value ? (s(), o("span", W, [ | ||
e[4] || (e[4] = t( | ||
"div", | ||
{ | ||
"i-octicon:check-circle-fill-24": "", | ||
class: "mr-1 flex items-center justify-center text-green-600" | ||
}, | ||
null, | ||
-1 | ||
/* HOISTED */ | ||
)), | ||
t( | ||
"span", | ||
X, | ||
p(i.sentSuccessButtonText), | ||
1 | ||
/* TEXT */ | ||
) | ||
])) : c.value ? (s(), o("span", Y, [ | ||
e[5] || (e[5] = t( | ||
"div", | ||
{ | ||
"i-octicon:alert-fill-24": "", | ||
class: "mr-1 flex items-center justify-center text-red-600" | ||
}, | ||
null, | ||
-1 | ||
/* HOISTED */ | ||
)), | ||
t( | ||
"span", | ||
Z, | ||
p(i.sentFailedButtonText), | ||
1 | ||
/* TEXT */ | ||
) | ||
])) : (s(), o("span", ee, [ | ||
d.value ? (s(), o( | ||
h, | ||
{ key: 1 }, | ||
[ | ||
e[7] || (e[7] = t( | ||
"div", | ||
{ | ||
"i-svg-spinners:180-ring-with-bg": "", | ||
class: "mr-1 flex items-center justify-center" | ||
}, | ||
null, | ||
-1 | ||
/* HOISTED */ | ||
)), | ||
t( | ||
"span", | ||
ne, | ||
p(i.sendingButtonText), | ||
1 | ||
/* TEXT */ | ||
) | ||
], | ||
64 | ||
/* STABLE_FRAGMENT */ | ||
)) : (s(), o( | ||
h, | ||
{ key: 0 }, | ||
[ | ||
e[6] || (e[6] = t( | ||
"div", | ||
{ | ||
"i-octicon:paper-airplane-24": "", | ||
class: "mr-1 flex items-center justify-center" | ||
}, | ||
null, | ||
-1 | ||
/* HOISTED */ | ||
)), | ||
t( | ||
"span", | ||
te, | ||
p(i.sendButtonText), | ||
1 | ||
/* TEXT */ | ||
) | ||
], | ||
64 | ||
/* STABLE_FRAGMENT */ | ||
)) | ||
])) | ||
]), | ||
_: 1 | ||
/* STABLE */ | ||
}) | ||
]) | ||
], 10, K) | ||
]) | ||
], | ||
32 | ||
/* NEED_HYDRATION */ | ||
)); | ||
} | ||
}); | ||
export { | ||
le as default | ||
}; |
@@ -1,2 +0,8 @@ | ||
function t(){return{name:"preset-suggestion-box",rules:[[/sb-auto-height/,([e])=>` | ||
function t() { | ||
return { | ||
name: "preset-suggestion-box", | ||
rules: [ | ||
[ | ||
/sb-auto-height/, | ||
([e]) => ` | ||
.${e}::after { | ||
@@ -11,3 +17,9 @@ content: attr(data-value) ' '; | ||
} | ||
`]]}}export{t as default}; | ||
//# sourceMappingURL=preset.js.map | ||
` | ||
] | ||
] | ||
}; | ||
} | ||
export { | ||
t as default | ||
}; |
{ | ||
"name": "@project-trans/suggestion-box", | ||
"type": "module", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Suggestion box for Project Trans", | ||
@@ -60,4 +60,2 @@ "author": { | ||
"@iconify-json/svg-spinners": "^1.2.0", | ||
"@rollup/plugin-node-resolve": "^15.3.0", | ||
"@rollup/plugin-replace": "^6.0.1", | ||
"@types/node": "^22.7.4", | ||
@@ -68,6 +66,5 @@ "@unocss/eslint-plugin": "^0.63.1", | ||
"eslint": "^9.11.1", | ||
"eslint-plugin-format": "^0.1.2", | ||
"lightningcss": "^1.27.0", | ||
"rimraf": "^6.0.1", | ||
"rollup": "^4.22.5", | ||
"rollup-plugin-esbuild": "^6.1.1", | ||
"tsx": "^4.19.1", | ||
@@ -82,6 +79,3 @@ "typescript": "^5.6.2", | ||
"dev:server": "pnpm -F server run dev", | ||
"build": "pnpm build:script && pnpm build:style && pnpm build:types", | ||
"build:style": "tsx ./script/buildStyle.ts", | ||
"build:script": "rollup -c rollup.config.ts --configPlugin esbuild", | ||
"build:types": "vue-tsc", | ||
"build": "tsx ./script/buildStyle.ts && vue-tsc --declaration --emitDeclarationOnly", | ||
"preview": "vite preview", | ||
@@ -88,0 +82,0 @@ "lint": "eslint --cache . && pnpm -F server run lint", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
16
6987
362784
15
5