lantern-harness 0.1.25 → 0.1.26

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 (68) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/500.html +4 -4
  3. package/dist/_astro/Base.Bilfw8As.css +1 -0
  4. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.Cb6ggViJ.js → Base.astro_astro_type_script_index_0_lang._n0VHShs.js} +1 -1
  5. package/dist/_astro/{CasesLibrary.e3vlOqSQ.js → CasesLibrary.BkQY421S.js} +1 -1
  6. package/dist/_astro/ChatApp.C_nGSCqd.js +226 -0
  7. package/dist/_astro/{DashboardBoard.CmxqpmzI.js → DashboardBoard.g_53rLV5.js} +2 -2
  8. package/dist/_astro/{PluginsPage.D5LXPMns.js → PluginsPage.Crrq4Ibd.js} +1 -1
  9. package/dist/_astro/PluginsPage.DzI3Xfa3.js +1 -0
  10. package/dist/_astro/PmBugsBoard.DVhrHxD2.js +1 -0
  11. package/dist/_astro/PmIterationsBoard.BQPHdbpp.js +1 -0
  12. package/dist/_astro/{PmProjectDetail.O44fnczN.js → PmProjectDetail.DZmqbZLO.js} +1 -1
  13. package/dist/_astro/PmProjectsBoard.tk8cI-lO.js +1 -0
  14. package/dist/_astro/PmRequirementsBoard.BjC9CEFr.js +1 -0
  15. package/dist/_astro/PmRequirementsBoard.CtuavIey.js +1 -0
  16. package/dist/_astro/{PmShared.Bwphj4KH.js → PmShared.DRYCFoRc.js} +1 -1
  17. package/dist/_astro/{PromptsLibrary.Dv5OABdK.js → PromptsLibrary.uvoZTwhi.js} +1 -1
  18. package/dist/_astro/{ReqAnalysisBoard.nUp89z1s.js → ReqAnalysisBoard.Bz2de2Vj.js} +1 -1
  19. package/dist/_astro/{SettingsDialog.D3f4EOwl.js → SettingsDialog.CC5S6knQ.js} +1 -1
  20. package/dist/_astro/SlideOverDrawer.C1IVOc_8.js +1 -0
  21. package/dist/_astro/TasksBoard.Uj4XWtWz.js +1 -0
  22. package/dist/_astro/TodosBoard.BkszTn-p.js +1 -0
  23. package/dist/_astro/{UiAutoBoard.BRMCH1zB.js → UiAutoBoard.DegcBc_3.js} +1 -1
  24. package/dist/_astro/app-version.D-te3dRV.js +1 -0
  25. package/dist/_astro/{pm.pMOkNqqK.js → pm.BXmOiFfW.js} +1 -1
  26. package/dist/_astro/{story-review.BvgXBApZ.js → story-review.B5I45C1T.js} +1 -1
  27. package/dist/_astro/tasks.jfnSAEmg.js +1 -0
  28. package/dist/case-exec/index.html +4 -4
  29. package/dist/cases/generate/index.html +4 -4
  30. package/dist/cases/library/index.html +5 -5
  31. package/dist/dashboard/index.html +5 -5
  32. package/dist/docs/changelog/index.html +23 -5
  33. package/dist/docs/install/index.html +4 -4
  34. package/dist/docs/manual/index.html +9 -9
  35. package/dist/knowledge/index.html +4 -4
  36. package/dist/plugins/index.html +5 -5
  37. package/dist/pm/bugs/index.html +5 -5
  38. package/dist/pm/iterations/index.html +5 -5
  39. package/dist/pm/projects/detail/index.html +5 -5
  40. package/dist/pm/projects/index.html +5 -5
  41. package/dist/pm/requirements/index.html +5 -5
  42. package/dist/prompts/index.html +5 -5
  43. package/dist/reports/index.html +4 -4
  44. package/dist/requirement-analysis/index.html +5 -5
  45. package/dist/requirements/index.html +4 -4
  46. package/dist/tasks/index.html +5 -5
  47. package/dist/templates/index.html +4 -4
  48. package/dist/test-automation/index.html +5 -5
  49. package/dist/test-stats/index.html +4 -4
  50. package/dist/todos/index.html +5 -5
  51. package/dist/workbench/index.html +5 -5
  52. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +5 -5
  53. package/lh-plugins/lh-pm.mjs +6 -2
  54. package/lh-plugins/lh-todos.mjs +59 -18
  55. package/package.json +1 -1
  56. package/dist/_astro/Base.COYvzmy5.css +0 -1
  57. package/dist/_astro/ChatApp.CECImcJo.js +0 -226
  58. package/dist/_astro/PluginsPage.B6dsHB44.js +0 -1
  59. package/dist/_astro/PmBugsBoard.B6w50MHD.js +0 -1
  60. package/dist/_astro/PmIterationsBoard.Dk7JheCU.js +0 -1
  61. package/dist/_astro/PmProjectsBoard.qgj9HAj8.js +0 -1
  62. package/dist/_astro/PmRequirementsBoard.BKY3h4CQ.js +0 -1
  63. package/dist/_astro/PmRequirementsBoard.DTL_RFxq.js +0 -1
  64. package/dist/_astro/SlideOverDrawer.CpQu7VMQ.js +0 -1
  65. package/dist/_astro/TasksBoard.rwdPWLAh.js +0 -1
  66. package/dist/_astro/TodosBoard.CrZMl6Ei.js +0 -1
  67. package/dist/_astro/app-version.BPkgRlbu.js +0 -1
  68. package/dist/_astro/tasks.BNBkrFC3.js +0 -1
@@ -1 +0,0 @@
1
- export{t as default}from"./PluginsPage.D5LXPMns.js";
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.Di6uuouN.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{c as te,d as ne,i as re,l as ie,n as ae,o as oe,r as se,s as ce,t as i}from"./ColumnResize.BgYkV9Iy.js";import{n as le,t as ue}from"./DocsPager.D55FTK9d.js";import{t as a}from"./SelectDropdown.apWlFGbA.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{A as s,L as c,M as de,N as fe,R as pe,b as me,g as he,h as ge,i as _e,k as l,m as ve,n as ye,p as be,r as u,t as d}from"./pm.pMOkNqqK.js";import{A as xe,C as Se,D as Ce,E as we,O as f,S as p,_ as m,a as h,c as Te,d as Ee,f as g,g as De,h as Oe,k as ke,l as Ae,m as _,n as je,p as Me,s as v,t as Ne,u as Pe,y}from"./PmShared.Bwphj4KH.js";var b=e(t(),1),x=r(),Fe=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],Ie={key:`project`,width:140,min:100},S=[{key:`iteration`,width:120,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Le=20,Re=`tw.pm-bugs.page-size.v1`,ze=[`all`,...u],Be=[`all`,...d],Ve=`pm.bugs.project`,He=`pm.bugs.iteration`,Ue=`pm.bugs.status`,We=`pm.bugs.severity`,Ge=`pm.bugs.keyword`,Ke=d.map(e=>({value:e,label:ye[e]})),qe=u.map(e=>({value:e,label:_e[e]}));function Je(e=``){return{projectId:e,iterationId:``,requirementId:``,title:``,severity:`minor`,status:`pending`,reproduceSteps:``,expectedResult:``,actualResult:``,environment:``,githubIssue:``,attachment:``,remark:``}}function Ye(e){try{let t=new URL(e,`http://localhost`).searchParams.get(`p`)??``;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(t)}catch{return!1}}function C({scopeProjectId:e=``}={}){let t=!!e,r=ke(`bugs`),{store:u,live:d,loading:C,error:Xe,setError:w,reload:T}=xe(),[E,D]=f(Ve,`all`),O=e||E,[k,A]=f(He,`all`),[j,Ze]=Ce(Ue,ze,`all`),[M,Qe]=Ce(We,Be,`all`),[N,$e]=f(Ge),[et,P]=(0,b.useState)(1),[F,tt]=le(Le,Re),[I,L]=(0,b.useState)(null),[R,z]=(0,b.useState)(!1),[B,V]=(0,b.useState)(!1),H=(0,b.useRef)(null),U=(0,b.useRef)(new Set),[W,G]=(0,b.useState)(null),[nt,K]=(0,b.useState)(null),q=(0,b.useMemo)(()=>s(I?.attachment??``),[I?.attachment]),J=(0,b.useMemo)(()=>t?[...Fe,...S]:[...Fe,Ie,...S],[t]),Y=ie(t?`pm.bugs.cols.scoped.v1`:`pm.bugs.cols.v1`,J),rt=ne(t?`pm.bugs.scroll.scoped`:`pm.bugs.scroll`),it=Y.widthOf(`id`)??88;(0,b.useEffect)(()=>{for(let e of q)U.current.add(e.url)},[q]);let at=(0,b.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),ot=(0,b.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u.iterations.filter(e=>O===`all`||e.projectId===O).map(e=>({value:e.id,label:e.name}))],[u.iterations,O]),st=(0,b.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[u.projects]),ct=(0,b.useMemo)(()=>{let e=new Map(u.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[u.iterations]),X=(0,b.useMemo)(()=>de(me(u.bugs,{projectId:O,iterationId:k,status:j,severity:M,keyword:N})),[u.bugs,O,k,j,M,N]),Z=t?u.bugs.filter(e=>e.projectId===O).length:u.bugs.length,lt=Math.max(1,Math.ceil(X.length/F)),Q=Math.min(et,lt),ut=X.slice((Q-1)*F,Q*F);(0,b.useEffect)(()=>{t||d===!0&&E!==`all`&&!u.projects.some(e=>e.id===E)&&D(`all`)},[d,u.projects,E,D,t]),(0,b.useEffect)(()=>{d===!0&&k!==`all`&&!u.iterations.some(e=>e.id===k&&(O===`all`||e.projectId===O))&&A(`all`)},[d,u.iterations,O,k,A]);let dt=I?fe(u.iterations.filter(e=>e.projectId===I.projectId)):[],ft=I?u.requirements.filter(e=>e.projectId===I.projectId):[];async function pt(){if(!I)return;if(!I.projectId){w(`请先选择所属项目`);return}let e=I.reproduceSteps.trim();if(!e){w(`缺陷描述不能为空`);return}let t=be(e);z(!0);try{let n={projectId:I.projectId,iterationId:I.iterationId,requirementId:I.requirementId,title:t,severity:I.severity,status:I.status,reproduceSteps:e,expectedResult:I.expectedResult,actualResult:I.actualResult,environment:I.environment,githubIssue:I.githubIssue,attachment:I.attachment,remark:I.remark};I.id?await c(`bugs`,I.id,n):await ge(`bugs`,[n]);let r=!!I.id;L(null),U.current.clear(),w(``),await T(!0),o(r?`已保存缺陷`:`已新建缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);w(t),o(`保存缺陷失败:${t}`,`error`)}finally{z(!1)}}let $=(0,b.useCallback)(async e=>{if(e&&e.length){V(!0);try{let t=await pe(Array.from(e));L(e=>{if(!e)return e;let n=s(e.attachment);return{...e,attachment:l([...n,...t])}}),w(``)}catch(e){w(e instanceof Error?e.message:String(e))}finally{V(!1),H.current&&(H.current.value=``)}}},[w]),mt=I!==null;(0,b.useEffect)(()=>{if(!mt)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),$(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[mt,$]);async function ht(e){if(!I)return;let t=l(q.filter(t=>t.url!==e));if(I.id)try{await c(`bugs`,I.id,{attachment:t}),await T(!0)}catch(e){w(e instanceof Error?e.message:String(e));return}L(e=>e&&{...e,attachment:t}),ve([e],I.id??``)}function gt(){let e=[...U.current,...q.map(e=>e.url)];U.current.clear(),L(null),e.length&&ve(e)}async function _t(e,t){z(!0);try{await c(`bugs`,e.id,{status:t}),await T(!0)}catch(e){w(e instanceof Error?e.message:String(e))}finally{z(!1)}}async function vt(){let e=W;if(e){G(null),z(!0);try{await he(`bugs`,[e.id]),await T(!0),o(`已删除缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);w(t),o(`删除缺陷失败:${t}`,`error`)}finally{z(!1)}}}if(!r.ready)return(0,x.jsx)(De,{label:`正在读取插件开关`});if(!r.on)return(0,x.jsx)(m,{children:n(`bugs`)});if(d===null)return(0,x.jsx)(De,{label:`正在连接项目管理服务`});if(!d)return(0,x.jsx)(m,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(u.projects.length===0&&!C&&!t)return(0,x.jsx)(m,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来记录缺陷。`});let yt=[{value:`all`,label:`全部`},...qe];return(0,x.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-600`,children:Z}),` 条缺陷`,X.length===Z?``:` · 筛选出 ${X.length} 条`]}),(0,x.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,x.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:at,value:E,onChange:e=>{D(e),A(`all`),P(1)}}),(0,x.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:ot,value:k,onChange:e=>{A(e),P(1)}}),(0,x.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按严重程度筛选缺陷`,className:`w-32`,options:[{value:`all`,label:`全部严重程度`},...Ke],value:M,onChange:e=>{Qe(e),P(1)}}),(0,x.jsxs)(`label`,{className:`relative block`,children:[(0,x.jsx)(_,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,x.jsx)(`input`,{value:N,onChange:e=>{$e(e.target.value),P(1)},placeholder:`搜索编号 / 标题…`,className:`h-9 w-48 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,x.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>L(Je(O===`all`?``:O)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,x.jsx)(_,{name:`plus`,size:14}),`新建缺陷`]})]})]}),(0,x.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,x.jsx)(Me,{ariaLabel:`按状态筛选缺陷`,options:yt,value:j,onChange:e=>{Ze(e),P(1)}})}),Xe?(0,x.jsx)(Ee,{message:Xe,onClose:()=>w(``)}):null,(0,x.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsx)(`div`,{ref:rt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,x.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,x.jsx)(`colgroup`,{children:J.map(e=>(0,x.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,x.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,x.jsxs)(`tr`,{children:[(0,x.jsxs)(`th`,{className:`${ce} relative`,children:[`ID`,(0,x.jsx)(i,{...Y.resizeProps(`id`)})]}),(0,x.jsxs)(`th`,{className:oe,style:{"--tw-sticky-left":`${it}px`},children:[`缺陷标题`,(0,x.jsx)(i,{...Y.resizeProps(`title`)})]}),(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`严重程度`,(0,x.jsx)(i,{...Y.resizeProps(`severity`)})]}),(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`缺陷状态`,(0,x.jsx)(i,{...Y.resizeProps(`status`)})]}),t?null:(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,x.jsx)(i,{...Y.resizeProps(`project`)})]}),(0,x.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,x.jsx)(i,{...Y.resizeProps(`iteration`)})]}),(0,x.jsx)(`th`,{"aria-hidden":`true`}),(0,x.jsx)(`th`,{className:te,children:`操作`})]})}),(0,x.jsxs)(`tbody`,{children:[C&&!u.bugs.length?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:J.length,className:`px-4 py-16 text-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):ut.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:J.length,children:Z?(0,x.jsx)(Ae,{children:`没有符合筛选条件的缺陷。`}):(0,x.jsx)(Pe,{icon:`bug`,title:`暂无缺陷`,hint:`记录第一个缺陷,跟踪严重程度与修复状态。`,action:(0,x.jsxs)(`button`,{type:`button`,onClick:()=>L(Je(O===`all`?``:O)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,x.jsx)(_,{name:`plus`,size:13}),`新建缺陷`]})})})}):null,ut.map(e=>(0,x.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,x.jsx)(`td`,{className:`${se} font-mono text-xs text-stone-400`,children:e.autoId}),(0,x.jsx)(`td`,{className:ae,style:{"--tw-sticky-left":`${it}px`},children:(0,x.jsx)(Se,{text:e.title,onClick:()=>L({id:e.id,projectId:e.projectId,iterationId:e.iterationId,requirementId:e.requirementId,title:e.title,severity:e.severity,status:e.status,reproduceSteps:e.reproduceSteps||e.title,expectedResult:e.expectedResult,actualResult:e.actualResult,environment:e.environment,githubIssue:e.githubIssue,attachment:e.attachment,remark:e.remark})})}),(0,x.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,x.jsx)(p,{tone:Ne[e.severity],children:ye[e.severity]})}),(0,x.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,x.jsx)(a,{unstyled:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:R,options:qe,value:e.status,onChange:t=>void _t(e,t),renderOptionPrefix:e=>(0,x.jsx)(v,{tone:je[e.value]}),renderTrigger:()=>(0,x.jsx)(p,{tone:je[e.status],children:_e[e.status]})})}),t?null:(0,x.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,x.jsx)(`a`,{href:we(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:st(e.projectId)})}),(0,x.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:ct(e.iterationId)}),(0,x.jsx)(`td`,{"aria-hidden":`true`}),(0,x.jsx)(`td`,{className:re,children:(0,x.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:R,onClick:()=>G(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,x.jsx)(_,{name:`trash`,size:15})})})]},e.id))]})]})}),X.length>0?(0,x.jsx)(ue,{page:Q,totalPages:lt,pageSize:F,busy:R,onPage:P,onPageSize:e=>{tt(e),P(1)}}):null]}),(0,x.jsx)(Te,{open:I!==null,title:I?.id?`编辑缺陷`:`新建缺陷`,busy:R,submitLabel:I?.id?`保存`:`创建`,onClose:gt,onSubmit:()=>void pt(),children:I?(0,x.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,x.jsx)(g,{label:`所属项目`,required:!0,children:(0,x.jsx)(y,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:I.projectId,onChange:e=>L({...I,projectId:e,iterationId:``,requirementId:``})})}),(0,x.jsx)(g,{label:`所属迭代`,children:(0,x.jsx)(y,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...dt.map(e=>({value:e.id,label:e.name}))],value:I.iterationId,onChange:e=>L({...I,iterationId:e}),disabled:dt.length===0})}),(0,x.jsx)(g,{label:`关联需求`,children:(0,x.jsx)(y,{ariaLabel:`关联需求`,options:[{value:``,label:`不关联需求`},...ft.map(e=>({value:e.id,label:`${e.autoId} ${e.title}`}))],value:I.requirementId,onChange:e=>L({...I,requirementId:e}),disabled:ft.length===0})}),(0,x.jsx)(g,{label:`缺陷描述`,required:!0,children:(0,x.jsx)(`textarea`,{autoFocus:!0,value:I.reproduceSteps,onChange:e=>L({...I,reproduceSteps:e.target.value}),placeholder:`描述问题现象、复现步骤与影响范围`,rows:5,className:h})}),(0,x.jsx)(g,{label:`严重程度`,children:(0,x.jsx)(y,{ariaLabel:`严重程度`,options:Ke,value:I.severity,onChange:e=>L({...I,severity:e}),renderOptionPrefix:e=>(0,x.jsx)(v,{tone:Ne[e.value]})})}),(0,x.jsx)(g,{label:`附件`,children:(0,x.jsxs)(`div`,{className:`space-y-2`,children:[q.length?(0,x.jsx)(`ul`,{className:`space-y-1.5`,children:q.map(e=>{let t=Ye(e.url);return(0,x.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[t?(0,x.jsx)(`button`,{type:`button`,onClick:()=>K(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,x.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,x.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,x.jsx)(_,{name:`file`,size:15})}),t?(0,x.jsx)(`button`,{type:`button`,onClick:()=>K(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,x.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>ht(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url)})}):null,(0,x.jsx)(`input`,{ref:H,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void $(e.target.files)}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`button`,{type:`button`,disabled:B,onClick:()=>H.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,x.jsx)(_,{name:B?`file`:`plus`,size:13}),B?`上传中…`:`上传文件 / 图片`]}),(0,x.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可直接粘贴截图 / 图片(⌘V / Ctrl+V),支持多张`})]})]})}),(0,x.jsx)(g,{label:`备注`,children:(0,x.jsx)(`textarea`,{value:I.remark,onChange:e=>L({...I,remark:e.target.value}),rows:2,className:h})})]}):null}),(0,x.jsx)(ee,{open:W!==null,title:`删除缺陷`,message:`确定删除「${W?.title??``}」?此操作无法恢复。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>G(null),onConfirm:()=>void vt()}),(0,x.jsx)(Oe,{file:nt,onClose:()=>K(null)})]})}export{C as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.Di6uuouN.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{t as a}from"./DatePicker.Bkl71M49.js";import{t as o}from"./SelectDropdown.apWlFGbA.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{D as c,I as ee,L as l,N as te,O as ne,a as u,g as re,h as ie,o as d,x as ae}from"./pm.pMOkNqqK.js";import{A as f,D as oe,E as se,O as p,S as m,_ as h,a as ce,c as le,d as ue,f as g,g as _,i as v,k as de,l as fe,m as y,r as b,s as x,u as S,v as pe,y as C}from"./PmShared.Bwphj4KH.js";var w=e(t(),1),T=r(),E=10,me=[`all`,...u],he=`pm.iterations.project`,D=`pm.iterations.status`,ge=`pm.iterations.keyword`,O=u.map(e=>({value:e,label:d[e]}));function k(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function A({scopeProjectId:e=``}={}){let t=!!e,r=de(`iterations`),{store:u,live:A,loading:j,error:M,setError:N,reload:P}=f(),[F,I]=p(he,`all`),L=e||F,[R,_e]=oe(D,me,`all`),[z,ve]=p(ge),[ye,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),q=ee(),be=(0,w.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[u.projects]),xe=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),J=(0,w.useMemo)(()=>te(ae(u.iterations,{projectId:L,status:R,keyword:z})),[u.iterations,L,R,z]),Y=t?u.iterations.filter(e=>e.projectId===L).length:u.iterations.length,X=Math.max(1,Math.ceil(J.length/E)),Z=Math.min(ye,X),Q=J.slice((Z-1)*E,Z*E);(0,w.useEffect)(()=>{t||A===!0&&F!==`all`&&!u.projects.some(e=>e.id===F)&&I(`all`)},[A,u.projects,F,I,t]);async function Se(){if(!V)return;if(!V.projectId){N(`请先选择所属项目`);return}let e=V.name.trim();if(!e)N(`迭代名称不能为空`);else if(V.startDate&&V.endDate&&V.endDate<V.startDate)N(`迭代结束日期不能早于开始日期`);else{W(!0);try{let t={projectId:V.projectId,name:e,startDate:V.startDate,endDate:V.endDate,status:V.status,remark:V.remark};V.id?await l(`iterations`,V.id,t):await ie(`iterations`,[t]),H(null),N(``),await P(!0),s(V.id?`已保存迭代`:`已新建迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),s(`保存迭代失败:${t}`,`error`)}finally{W(!1)}}}async function $(e,t){W(!0);try{await l(`iterations`,e.id,{status:t}),await P(!0),s(`已更新迭代状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),s(`更新迭代失败:${t}`,`error`)}finally{W(!1)}}async function Ce(){let e=G;if(e){K(null),W(!0);try{await re(`iterations`,[e.id]),await P(!0),s(`已删除迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),s(`删除迭代失败:${t}`,`error`)}finally{W(!1)}}}return r.ready?r.on?A===null?(0,T.jsx)(_,{label:`正在连接项目管理服务`}):A?u.projects.length===0&&!j&&!t?(0,T.jsx)(h,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护迭代。`}):(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 个迭代`,J.length===Y?``:` · 筛选出 ${J.length} 个`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选迭代`,className:`w-36`,options:xe,value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选迭代`,className:`w-28`,options:[{value:`all`,label:`全部状态`},...O],value:R,onChange:e=>{_e(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(y,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:z,onChange:e=>{ve(e.target.value),B(1)},placeholder:`搜索迭代名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(k(L===`all`?``:L)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`plus`,size:14}),`新建迭代`]})]})]}),M?(0,T.jsx)(ue,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pb-4`,children:j&&!u.iterations.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):Q.length===0?Y?(0,T.jsx)(fe,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(S,{icon:`calendar`,title:`暂无迭代`,hint:`新建一个迭代,用开始 / 截止日期跟踪进度。`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(k(L===`all`?``:L)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(y,{name:`plus`,size:13}),`新建迭代`]})}):(0,T.jsx)(`div`,{className:`space-y-3`,children:Q.map(e=>{let n=ne(e,q),r=c(e,q),i=e.endDate&&e.status!==`done`?Math.round((Date.parse(`${e.endDate}T00:00:00`)-Date.parse(`${q}T00:00:00`))/864e5):null;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3.5 transition-[border-color,box-shadow] hover:border-[#ddd6fe] hover:shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate text-[15px] font-medium text-stone-800`,children:e.name}),(0,T.jsx)(m,{tone:b[e.status],children:d[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:se(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:be(e.projectId)}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`})]}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[e.startDate||`—`,` → `,e.endDate||`—`]}),r===null?i!==null&&i>=0&&e.endDate?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[`还剩 `,i,` 天`]}):null:(0,T.jsxs)(`span`,{className:`text-red-500`,children:[`逾期 `,r,` 天`]})]}),e.remark?(0,T.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-stone-400`,children:e.remark}):null]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status===`planning`?(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>void $(e,`in_progress`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`play`,size:12}),`开始`]}):null,e.status===`in_progress`?(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>void $(e,`done`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`check`,size:12}),`完成`]}):null,(0,T.jsx)(`button`,{type:`button`,"aria-label":`编辑 ${e.name}`,onClick:()=>H({id:e.id,projectId:e.projectId,name:e.name,startDate:e.startDate,endDate:e.endDate,status:e.status,remark:e.remark}),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(y,{name:`pencil`,size:15})}),(0,T.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.name}`,disabled:U,onClick:()=>K(e),className:`tw-icon-danger flex h-8 w-8 items-center justify-center rounded-lg`,children:(0,T.jsx)(y,{name:`trash`,size:15})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-300`,style:{width:`${n}%`}})}),(0,T.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[n,`%`]})]})]},e.id)})})}),J.length>0?(0,T.jsx)(pe,{page:Z,totalPages:X,busy:U,onPage:B}):null,(0,T.jsx)(le,{open:V!==null,title:V?.id?`编辑迭代`:`新建迭代`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void Se(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,T.jsx)(g,{label:`所属项目`,required:!0,children:(0,T.jsx)(C,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:V.projectId,onChange:e=>H({...V,projectId:e}),disabled:u.projects.length===0})}),(0,T.jsx)(g,{label:`迭代名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`如:v1.0 迭代`,className:v})}),(0,T.jsx)(g,{label:`开始日期`,children:(0,T.jsx)(a,{value:V.startDate,onChange:e=>H({...V,startDate:e}),placeholder:`选择开始日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`截止日期`,children:(0,T.jsx)(a,{value:V.endDate,onChange:e=>H({...V,endDate:e}),placeholder:`选择截止日期`,className:`${v} tabular-nums`})}),(0,T.jsx)(g,{label:`状态`,children:(0,T.jsx)(C,{ariaLabel:`迭代状态`,options:O,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(x,{tone:b[e.value]})})}),(0,T.jsx)(g,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:V.remark,onChange:e=>H({...V,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:ce})})]}):null}),(0,T.jsx)(i,{open:G!==null,title:`删除迭代`,message:`确定删除「${G?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void Ce()})]}):(0,T.jsx)(h,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(h,{children:n(`iterations`)}):(0,T.jsx)(_,{label:`正在读取插件开关`})}export{A as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{s as ee}from"./plugins.Di6uuouN.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./SelectDropdown.apWlFGbA.js";import{showToast as a}from"./Toast.BO2NFckG.js";import{L as o,S as te,c as s,g as ne,h as c,j as l,s as u}from"./pm.pMOkNqqK.js";import{A as d,D as f,E as p,O as m,S as h,_ as g,a as re,c as ie,d as ae,f as _,g as v,i as oe,k as se,l as y,m as b,o as x,s as ce,u as le,v as S,y as C}from"./PmShared.Bwphj4KH.js";var w=e(t(),1),T=n(),E=10,D=u.map(e=>({value:e,label:s[e]})),O=[`all`,...u],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=se(`projects`),{store:t,live:n,loading:u,error:M,setError:N,reload:P}=d(),[F,I]=f(k,O,`all`),[L,R]=m(A),[z,B]=(0,w.useState)(1),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(!1),[G,K]=(0,w.useState)(null),[q,J]=(0,w.useState)(null),Y=(0,w.useRef)(null),ue=(0,w.useMemo)(()=>l(t),[t]),X=(0,w.useMemo)(()=>te(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function de(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await o(`projects`,V.id,{name:e,description:V.description,status:V.status}):await c(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0),a(V.id?`已保存项目`:`已新建项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),a(`保存项目失败:${t}`,`error`)}finally{W(!1)}}}async function fe(e){J(null),W(!0);try{let t=e.status!==`archived`;await o(`projects`,e.id,{status:t?`archived`:`planning`}),await P(!0),a(t?`已归档「${e.name}」`:`已取消归档「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),a(`更新项目失败:${t}`,`error`)}finally{W(!1)}}async function pe(){let e=G;if(e){K(null),W(!0);try{await ne(`projects`,[e.id]),await P(!0),a(`已删除项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),a(`删除项目失败:${t}`,`error`)}finally{W(!1)}}}return e.ready?e.on?n===null?(0,T.jsx)(v,{label:`正在连接项目管理服务`}):n?(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-stone-400`,children:t.projects.length?(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:t.projects.length}),` 个项目`,X.length===t.projects.length?``:` · 筛选出 ${X.length} 个`]}):`暂无项目`}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(i,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选项目`,className:`w-32`,options:[{value:`all`,label:`全部状态`},...D],value:F,onChange:e=>{I(e),B(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(b,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:L,onChange:e=>{R(e.target.value),B(1)},placeholder:`搜索项目名称 / 描述…`,className:`h-9 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:U,onClick:()=>H(j()),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(b,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(ae,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:u&&!t.projects.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):$.length===0?t.projects.length?(0,T.jsx)(y,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(le,{icon:`folder`,title:`暂无项目`,hint:`创建第一个项目开始吧`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>H(j()),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(b,{name:`plus`,size:13}),`新建项目`]})}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>{let t=ue[e.id];return(0,T.jsxs)(`article`,{className:`tw-pm-card group relative rounded-2xl border border-stone-200 bg-white`,children:[(0,T.jsx)(`span`,{className:`pointer-events-none absolute inset-0 overflow-hidden rounded-2xl`,"aria-hidden":`true`,children:(0,T.jsx)(`span`,{className:`tw-pm-card-accent absolute -right-6 -top-6 h-20 w-20 rounded-full bg-[#f1edff]`})}),(0,T.jsx)(`a`,{href:p(e.id),"aria-label":`打开项目 ${e.name}`,className:`absolute inset-0 z-0 rounded-2xl`}),(0,T.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex h-full flex-col p-5`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,T.jsx)(`span`,{className:`tw-pm-tile flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-xs font-bold`,children:e.name.slice(0,1)}),(0,T.jsx)(`h3`,{className:`truncate text-[15px] font-semibold text-stone-800`,children:e.name})]}),(0,T.jsx)(h,{tone:x[e.status],children:s[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(b,{name:`more`,size:18})}),q===e.id?(0,T.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-9 z-30 w-36 overflow-hidden rounded-lg border border-stone-200 bg-white py-1 shadow-lg`,children:[(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),H({id:e.id,name:e.name,description:e.description,status:e.status})},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(b,{name:`pencil`,size:14}),`编辑`]}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>void fe(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-stone-700 hover:bg-stone-50`,children:[(0,T.jsx)(b,{name:`folder`,size:14}),e.status===`archived`?`取消归档`:`归档`]}),(0,T.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,T.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{J(null),K(e)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-red-600 hover:bg-red-50`,children:[(0,T.jsx)(b,{name:`trash`,size:14}),`删除`]})]}):null]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-stone-400`,children:[`需求完成 `,t?.requirementPercent??0,`%`,(0,T.jsx)(b,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(S,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(ie,{open:V!==null,title:V?.id?`编辑项目`:`新建项目`,busy:U,submitLabel:V?.id?`保存`:`创建`,onClose:()=>H(null),onSubmit:()=>void de(),children:V?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(_,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:oe})}),(0,T.jsx)(_,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:re})}),(0,T.jsx)(_,{label:`状态`,children:(0,T.jsx)(C,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(ce,{tone:x[e.value]})})})]}):null}),(0,T.jsx)(r,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void pe()})]}):(0,T.jsx)(g,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(g,{children:ee(`projects`)}):(0,T.jsx)(v,{label:`正在读取插件开关`})}export{M as default};
@@ -1 +0,0 @@
1
- export{t as default}from"./PmRequirementsBoard.DTL_RFxq.js";
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.Di6uuouN.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{c as a,d as ee,i as o,l as s,n as c,o as te,r as l,s as ne,t as u}from"./ColumnResize.BgYkV9Iy.js";import{n as d,t as f}from"./DocsPager.D55FTK9d.js";import{t as p}from"./SelectDropdown.apWlFGbA.js";import{showToast as m}from"./Toast.BO2NFckG.js";import{A as h,C as re,E as g,L as _,N as ie,P as ae,R as v,d as y,f as oe,g as se,h as ce,k as b,l as x,m as le,u as ue}from"./pm.pMOkNqqK.js";import{A as de,C as fe,D as pe,E as me,O as S,S as he,T as C,_ as w,a as ge,c as _e,d as ve,f as T,g as ye,h as E,k as be,l as xe,m as D,p as Se,s as O,u as Ce,w as we,y as k}from"./PmShared.Bwphj4KH.js";var A=e(t(),1),j=r();function Te({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=h(e),[s,c]=(0,A.useState)(!1),[te,l]=(0,A.useState)(!1),[ne,u]=(0,A.useState)(null),d=(0,A.useRef)(null);(0,A.useEffect)(()=>{for(let t of h(e))i.current.add(t.url)},[e,i]);let f=(0,A.useCallback)(async n=>{if(n&&n.length){c(!0);try{let r=await v(Array.from(n));t(b([...h(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{c(!1),d.current&&(d.current.value=``)}}},[t,a,e]);(0,A.useEffect)(()=>{let e=e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),f(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[f]);async function p(e){let i=b(o.filter(t=>t.url!==e));if(r)try{await _(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),le([e],r)}return(0,j.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${te?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:e=>{e.preventDefault(),l(!1),f(e.dataTransfer?.files??null)},children:[o.length?(0,j.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,j.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[g(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>u(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,j.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,j.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,j.jsx)(D,{name:`file`,size:15})}),g(e.url)?(0,j.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,j.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 truncate text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}),(0,j.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>void p(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url))}):null,(0,j.jsx)(`input`,{ref:d,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void f(e.target.files)}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>d.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-dashed border-stone-300 px-2.5 text-xs text-stone-500 transition-colors hover:border-stone-400 hover:text-stone-700 disabled:opacity-40`,children:[(0,j.jsx)(D,{name:s?`file`:`plus`,size:13}),s?`上传中…`:`上传文件 / 图片`]}),(0,j.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,j.jsx)(E,{file:ne,onClose:()=>u(null)})]})}var Ee=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],De={key:`project`,width:140,min:100},Oe=[{key:`iteration`,width:120,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],ke=20,Ae=`tw.pm-requirements.page-size.v1`,je=[`all`,...y],Me=[`all`,...x],Ne=`pm.requirements.project`,Pe=`pm.requirements.iteration`,Fe=`pm.requirements.status`,Ie=`pm.requirements.priority`,Le=`pm.requirements.keyword`,Re=x.map(e=>({value:e,label:ue[e]})),M=y.map(e=>({value:e,label:oe[e]}));function ze(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function N({scopeProjectId:e=``}={}){let t=!!e,r=be(`pmRequirements`),{store:g,live:v,loading:y,error:b,setError:x,reload:E}=de(),[N,P]=S(Ne,`all`),F=e||N,[I,L]=S(Pe,`all`),[R,Be]=pe(Fe,je,`all`),[z,Ve]=pe(Ie,Me,`all`),[B,He]=S(Le),[Ue,V]=(0,A.useState)(1),[H,We]=d(ke,Ae),[U,W]=(0,A.useState)(null),[G,K]=(0,A.useState)(!1),[q,J]=(0,A.useState)(null),Y=(0,A.useRef)(new Set),X=(0,A.useMemo)(()=>t?[...Ee,...Oe]:[...Ee,De,...Oe],[t]),Z=s(t?`pm.requirements.cols.scoped.v1`:`pm.requirements.cols.v1`,X),Ge=ee(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),Ke=Z.widthOf(`id`)??88,qe=(0,A.useMemo)(()=>[{value:`all`,label:`全部项目`},...g.projects.map(e=>({value:e.id,label:e.name}))],[g.projects]),Je=(0,A.useMemo)(()=>[{value:`all`,label:`全部迭代`},...ie(g.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[g.iterations,F]),Ye=(0,A.useMemo)(()=>{let e=new Map(g.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[g.projects]),Xe=(0,A.useMemo)(()=>{let e=new Map(g.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[g.iterations]),Q=(0,A.useMemo)(()=>ae(re(g.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[g.requirements,F,I,R,z,B]),$=t?g.requirements.filter(e=>e.projectId===F).length:g.requirements.length,Ze=Math.max(1,Math.ceil(Q.length/H)),Qe=Math.min(Ue,Ze),$e=Q.slice((Qe-1)*H,Qe*H);(0,A.useEffect)(()=>{t||v===!0&&N!==`all`&&!g.projects.some(e=>e.id===N)&&P(`all`)},[v,g.projects,N,P,t]),(0,A.useEffect)(()=>{v===!0&&I!==`all`&&!g.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[v,g.iterations,F,I,L]);let et=U?ie(g.iterations.filter(e=>e.projectId===U.projectId)):[];async function tt(){if(!U)return;if(!U.projectId){x(`请先选择所属项目`);return}let e=U.title.trim();if(!e)x(`需求描述不能为空`);else{K(!0);try{let t={projectId:U.projectId,iterationId:U.iterationId,title:e,priority:U.priority,status:U.status,description:U.description,acceptanceCriteria:U.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:U.githubIssue,attachment:U.attachment};U.id?await _(`requirements`,U.id,t):await ce(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),x(``),await E(!0),m(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),m(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function nt(){let e=[...Y.current,...h(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&le(e)}async function rt(e,t){K(!0);try{await _(`requirements`,e.id,{status:t}),await E(!0),m(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),m(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function it(){let e=q;if(e){J(null),K(!0);try{await se(`requirements`,[e.id]),await E(!0),m(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),m(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!r.ready)return(0,j.jsx)(ye,{label:`正在读取插件开关`});if(!r.on)return(0,j.jsx)(w,{children:n(`pmRequirements`)});if(v===null)return(0,j.jsx)(ye,{label:`正在连接项目管理服务`});if(!v)return(0,j.jsx)(w,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(g.projects.length===0&&!y&&!t)return(0,j.jsx)(w,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let at=[{value:`all`,label:`全部`},...M];return(0,j.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,j.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,j.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,j.jsx)(`span`,{className:`font-medium text-stone-600`,children:$}),` 条需求`,Q.length===$?``:` · 筛选出 ${Q.length} 条`]}),(0,j.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,j.jsx)(p,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:qe,value:N,onChange:e=>{P(e),L(`all`),V(1)}}),(0,j.jsx)(p,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:Je,value:I,onChange:e=>{L(e),V(1)}}),(0,j.jsx)(p,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...Re],value:z,onChange:e=>{Ve(e),V(1)}}),(0,j.jsxs)(`label`,{className:`relative block`,children:[(0,j.jsx)(D,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,j.jsx)(`input`,{value:B,onChange:e=>{He(e.target.value),V(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,j.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>W(ze(F===`all`?``:F)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,j.jsx)(D,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,j.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,j.jsx)(Se,{ariaLabel:`按状态筛选需求`,options:at,value:R,onChange:e=>{Be(e),V(1)}})}),b?(0,j.jsx)(ve,{message:b,onClose:()=>x(``)}):null,(0,j.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,j.jsx)(`div`,{ref:Ge,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,j.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Z.tableStyle,children:[(0,j.jsx)(`colgroup`,{children:X.map(e=>(0,j.jsx)(`col`,{style:Z.widthOf(e.key)?{width:Z.widthOf(e.key)}:void 0},e.key))}),(0,j.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`th`,{className:`${ne} relative`,children:[`ID`,(0,j.jsx)(u,{...Z.resizeProps(`id`)})]}),(0,j.jsxs)(`th`,{className:te,style:{"--tw-sticky-left":`${Ke}px`},children:[`需求描述`,(0,j.jsx)(u,{...Z.resizeProps(`title`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,j.jsx)(u,{...Z.resizeProps(`priority`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,j.jsx)(u,{...Z.resizeProps(`status`)})]}),t?null:(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,j.jsx)(u,{...Z.resizeProps(`project`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,j.jsx)(u,{...Z.resizeProps(`iteration`)})]}),(0,j.jsx)(`th`,{"aria-hidden":`true`}),(0,j.jsx)(`th`,{className:a,children:`操作`})]})}),(0,j.jsxs)(`tbody`,{children:[y&&!g.requirements.length?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:X.length,className:`px-4 py-16 text-center`,children:(0,j.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):$e.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:X.length,children:$?(0,j.jsx)(xe,{children:`没有符合筛选条件的需求。`}):(0,j.jsx)(Ce,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,j.jsxs)(`button`,{type:`button`,onClick:()=>W(ze(F===`all`?``:F)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,j.jsx)(D,{name:`plus`,size:13}),`新建需求`]})})})}):null,$e.map(e=>(0,j.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,j.jsx)(`td`,{className:`${l} font-mono text-xs text-stone-400`,children:e.autoId}),(0,j.jsx)(`td`,{className:c,style:{"--tw-sticky-left":`${Ke}px`},children:(0,j.jsx)(fe,{text:e.title,onClick:()=>W({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment})})}),(0,j.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,j.jsx)(he,{tone:we[e.priority],children:ue[e.priority]})}),(0,j.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,j.jsx)(p,{unstyled:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:G,options:M,value:e.status,onChange:t=>void rt(e,t),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:C[e.value]}),renderTrigger:()=>(0,j.jsx)(he,{tone:C[e.status],children:oe[e.status]})})}),t?null:(0,j.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,j.jsx)(`a`,{href:me(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:Ye(e.projectId)})}),(0,j.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:Xe(e.iterationId)}),(0,j.jsx)(`td`,{"aria-hidden":`true`}),(0,j.jsx)(`td`,{className:o,children:(0,j.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:G,onClick:()=>J(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,j.jsx)(D,{name:`trash`,size:15})})})]},e.id))]})]})}),Q.length>0?(0,j.jsx)(f,{page:Qe,totalPages:Ze,pageSize:H,busy:G,onPage:V,onPageSize:e=>{We(e),V(1)}}):null]}),(0,j.jsx)(_e,{open:U!==null,title:U?.id?`编辑需求`:`新建需求`,busy:G,submitLabel:U?.id?`保存`:`创建`,onClose:()=>nt(),onSubmit:()=>void tt(),children:U?(0,j.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,j.jsx)(T,{label:`所属项目`,required:!0,children:(0,j.jsx)(k,{ariaLabel:`所属项目`,options:g.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=g.iterations.some(t=>t.id===U.iterationId&&t.projectId===e);W({...U,projectId:e,iterationId:t?U.iterationId:``})}})}),(0,j.jsx)(T,{label:`所属迭代`,children:(0,j.jsx)(k,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...et.map(e=>({value:e.id,label:e.name}))],value:U.iterationId,onChange:e=>W({...U,iterationId:e}),disabled:et.length===0})}),(0,j.jsx)(T,{label:`需求描述`,required:!0,children:(0,j.jsx)(`textarea`,{autoFocus:!0,value:U.title,onChange:e=>W({...U,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:ge})}),(0,j.jsx)(T,{label:`优先级`,children:(0,j.jsx)(k,{ariaLabel:`优先级`,options:Re,value:U.priority,onChange:e=>W({...U,priority:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:we[e.value]})})}),(0,j.jsx)(T,{label:`需求状态`,children:(0,j.jsx)(k,{ariaLabel:`需求状态`,options:M,value:U.status,onChange:e=>W({...U,status:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:C[e.value]})})}),(0,j.jsx)(T,{label:`附件`,children:(0,j.jsx)(Te,{value:U.attachment,onChange:e=>W(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:U.id??``,seenUrls:Y,onError:x,onPersisted:()=>void E(!0)})}),(0,j.jsx)(T,{label:`备注`,children:(0,j.jsx)(`textarea`,{value:U.description,onChange:e=>W({...U,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:ge})})]}):null}),(0,j.jsx)(i,{open:q!==null,title:`删除需求`,message:`确定删除「${q?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>J(null),onConfirm:()=>void it()})]})}export{N as t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";var i=e(t(),1),a=e(n(),1),o=r(),s=280;function c({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,widthClass:c=`max-w-md`,escDisabled:l=!1,bodyClassName:u,children:d,footer:f}){let[p,m]=(0,i.useState)(e),[h,g]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(e){m(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>g(!0))});return()=>window.cancelAnimationFrame(e)}g(!1);let t=window.setTimeout(()=>m(!1),s);return()=>window.clearTimeout(t)},[e]),(0,i.useEffect)(()=>{if(!e||l)return;function n(e){e.key===`Escape`&&(document.querySelector(`[aria-haspopup="listbox"][aria-expanded="true"]`)||(e.preventDefault(),e.stopPropagation(),t()))}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,l]),!p)return null;let _=(0,o.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,o.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-[280ms] ease-out ${h?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,o.jsxs)(`aside`,{className:`tw-slide-over relative w-full ${c} h-full shadow-2xl border-l border-stone-200 flex flex-col transition-[translate] duration-[280ms] ease-[cubic-bezier(0.32,0.72,0,1)] will-change-[translate] ${h?`translate-x-0`:`translate-x-full`}`,children:[(0,o.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,o.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,o.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,o.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 ${u??`space-y-4`}`.trim(),children:d}),f]})]});return typeof document>`u`?_:(0,a.createPortal)(_,document.body)}export{c as t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DAIyT--R.js";import{i as r,o as i,s as ee}from"./plugins.Di6uuouN.js";import{n as a,o,r as s,s as c}from"./view-prefs.DkS1ldnh.js";import{i as l,n as u,r as d,t as f}from"./dialog.DZHZCe_T.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.D5qXeML0.js";import{c as h,d as g,i as _,l as v,n as y,o as b,t as x}from"./ColumnResize.BgYkV9Iy.js";import{t as S}from"./DatePicker.Bkl71M49.js";import{t as C}from"./SelectDropdown.apWlFGbA.js";import{showToast as w}from"./Toast.BO2NFckG.js";import{A as T,C as E,D as te,P as ne,a as D,b as O,c as re,f as ie,g as ae,h as oe,i as k,m as se,n as A,o as ce,p as le,r as ue,s as de,t as j,u as fe}from"./tasks.BNBkrFC3.js";import{a as M,l as N,n as P,o as F,r as I,s as L,t as R}from"./DrawerField.C0MkN-LW.js";var z=e(t(),1),B=p(),pe=8e3,V=[{key:`title`,width:280,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],me={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},he={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},H={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},ge={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},_e={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},ve=ue.map(e=>({value:e,label:k[e]})),U=[{value:``,label:`未设置`},...j.map(e=>({value:e,label:A[e]}))],ye=[{value:`all`,label:`全部优先级`},...j.map(e=>({value:e,label:A[e]}))],be=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],xe=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],Se=`tasks.status-tab`,Ce=`tasks.priority-filter`,we=`tasks.search`,Te=ye.map(e=>e.value);function W(e){return(0,B.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,B.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,B.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function Ee(e){let{open:t,task:n,todos:r,onClose:i,onSaved:ee}=e,[a,o]=(0,z.useState)({title:``}),[s,c]=(0,z.useState)(``),[p,m]=(0,z.useState)(!1);(0,z.useEffect)(()=>{t&&(c(``),m(!1),o(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:T(),dueDate:T()}))},[t,n]);function h(e){o(t=>({...t,...e}))}let g=se({startDate:a.startDate??``,dueDate:a.dueDate??``}),_=n?r.filter(e=>e.taskId===n.id):[],v=_.filter(e=>e.status===`done`).length,y=_.length?Math.round(v/_.length*100):0;async function b(){let e=(a.title??``).trim();if(!e)c(`请填写任务名称`);else if(a.startDate&&a.dueDate&&a.dueDate<a.startDate)c(`截止日期不能早于开始日期`);else{m(!0),c(``);try{n?await ae(n.id,a):await D([{...a,title:e}],{mode:`manual`}),await ee(),w(n?`已保存任务`:`已新建任务`,`success`),i()}catch(e){let t=e instanceof Error?e.message:String(e);c(t),w(`保存任务失败:${t}`,`error`)}finally{m(!1)}}}return(0,B.jsxs)(d,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,B.jsx)(f,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,B.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,B.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,B.jsx)(u,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,B.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`任务名称`,children:(0,B.jsx)(`input`,{autoFocus:!0,value:a.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},placeholder:`请输入内容`,className:R})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`任务状态`,children:(0,B.jsx)(I,{ariaLabel:`任务状态`,menuMinWidth:140,options:ve,value:a.status??`pool`,onChange:e=>h({status:e}),label:k[a.status??`pool`],optionDotClassName:e=>ge[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`紧急程度`,children:(0,B.jsx)(I,{ariaLabel:`紧急程度`,menuMinWidth:140,options:U,value:a.priority??``,onChange:e=>h({priority:e}),label:a.priority?A[a.priority]:`未设置`,optionDotClassName:e=>_e[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`开始日期`,children:(0,B.jsx)(S,{value:a.startDate??``,onChange:e=>h({startDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`截止日期`,children:(0,B.jsx)(S,{value:a.dueDate??``,onChange:e=>h({dueDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`任务周期`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:g===null?`—`:`${g} 天`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`待办进度`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_.length?`${v}/${_.length} · ${y}%`:`还没有关联待办`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`备注`,children:(0,B.jsx)(`textarea`,{value:a.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&_.length?(0,B.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,B.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:_.map(e=>{let t=E(e,T());return(0,B.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,B.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${H[t]}`,children:O[t]})]},e.id)})})]}):null,s?(0,B.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:s}):null]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:i,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function De(){let[e,t]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!0),[d,f]=(0,z.useState)(!0),[p,T]=(0,z.useState)(null),[E,D]=(0,z.useState)([]),[O,ue]=(0,z.useState)([]),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(!1),[F,I]=(0,z.useState)(()=>s(we)),[L,R]=(0,z.useState)(()=>a(Se,xe,`all`)),[H,De]=(0,z.useState)(()=>a(Ce,Te,`all`)),[Oe,G]=(0,z.useState)(null),[K,q]=(0,z.useState)(null);function ke(e){o(Se,e),R(e)}function Ae(e){c(we,e),I(e)}function je(e){o(Ce,e),De(e)}let J=(0,z.useRef)(!0),Y=v(`lh:tasks:cols:v1`,V),Me=g(`tasks`);(0,z.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,z.useCallback)(async()=>{try{let[e,t]=await Promise.all([fe(),d?te().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;D(e),ue(t),M(null)}catch(e){if(!J.current)return;M(e instanceof Error?e.message:String(e))}},[d]);(0,z.useEffect)(()=>{let e=i(e=>{u(!!e.tasks),f(!!e.todos)});return n().then(()=>{u(r(`tasks`)),f(r(`todos`)),t(!0)}),e},[]),(0,z.useEffect)(()=>{e&&l&&(async()=>{let e=await de();J.current&&(e?(await X(),J.current&&T(!0)):T(!1))})()},[e,l,X]),(0,z.useEffect)(()=>{if(p!==!0)return;let e=window.setInterval(()=>void X(),pe),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[p,X]);let Ne=(0,z.useMemo)(()=>oe(O),[O]),Z=(0,z.useMemo)(()=>le(E),[E]),Pe=(0,z.useMemo)(()=>re(E,{status:L,priority:H,keyword:F}),[E,L,H,F]),Q=(0,z.useMemo)(()=>ie(Pe),[Pe]);async function $(e,t){D(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await ae(e,t);if(!J.current)return;D(t=>t.map(t=>t.id===e?n:t)),M(null)}catch(e){M(e instanceof Error?e.message:String(e)),await X()}}async function Fe(){let e=K;if(e){q(null),P(!0);try{await ce([e.id]),await Promise.all(O.filter(t=>t.taskId===e.id).map(e=>ne(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X(),w(`已删除任务「${e.title}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),w(`删除任务失败:${t}`,`error`)}finally{J.current&&P(!1)}}}return e?l?p===null?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):p?(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,B.jsx)(W,{label:`全部任务`,value:Z.total}),(0,B.jsx)(W,{label:`任务池`,value:Z.pool}),(0,B.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,B.jsx)(W,{label:`已完成`,value:Z.done}),(0,B.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,B.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,B.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,B.jsx)(`input`,{value:F,onChange:e=>Ae(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,B.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:be.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>ke(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${L===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,B.jsx)(C,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:ye,value:H,onChange:e=>je(e)}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,B.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),j?(0,B.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:j}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,B.jsx)(`div`,{ref:Me,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,B.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,B.jsx)(`colgroup`,{children:V.map(e=>(0,B.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,B.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`th`,{className:b,children:[`任务描述`,(0,B.jsx)(x,{...Y.resizeProps(`title`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,B.jsx)(x,{...Y.resizeProps(`status`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,B.jsx)(x,{...Y.resizeProps(`priority`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,B.jsx)(x,{...Y.resizeProps(`start`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,B.jsx)(x,{...Y.resizeProps(`due`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,B.jsx)(x,{...Y.resizeProps(`cycle`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,B.jsx)(x,{...Y.resizeProps(`todos`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,B.jsx)(x,{...Y.resizeProps(`progress`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,B.jsx)(x,{...Y.resizeProps(`note`)})]}),(0,B.jsx)(`th`,{"aria-hidden":`true`}),(0,B.jsx)(`th`,{className:h,children:`操作`})]})}),(0,B.jsxs)(`tbody`,{children:[Q.map(e=>{let t=se(e),n=Ne[e.id]??{total:0,done:0,percent:0};return(0,B.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,B.jsx)(`td`,{className:y,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,B.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:ve,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${me[e.status]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`truncate`,children:k[e.status]}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ge[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:U,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${he[e.priority]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`truncate`,children:e.priority?A[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${_e[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:d?n.total?`${n.total} 条`:`0`:(0,B.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:d?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,B.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,B.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,B.jsx)(`td`,{"aria-hidden":`true`}),(0,B.jsx)(`td`,{className:_,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M14 4h6v6`}),(0,B.jsx)(`path`,{d:`M20 4 13 11`}),(0,B.jsx)(`path`,{d:`M10 20H4v-6`}),(0,B.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M3 6h18`}),(0,B.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,B.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,B.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:11,className:`px-3 py-16 text-center text-sm text-stone-400`,children:E.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,B.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,B.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,B.jsx)(Ee,{open:Oe!==null,task:Oe?.task??null,todos:O,onClose:()=>G(null),onSaved:X}),(0,B.jsx)(m,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Fe()})]}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`tasks`)}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{De as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DAIyT--R.js";import{i as r,o as i,s as a}from"./plugins.Di6uuouN.js";import{n as o,o as s,r as c,s as ee}from"./view-prefs.DkS1ldnh.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DZHZCe_T.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{t as f}from"./ConfirmDialog.D5qXeML0.js";import{a as p,c as m,d as h,i as re,l as ie,n as g,o as ae,r as _,s as oe,t as v}from"./ColumnResize.BgYkV9Iy.js";import{n as se,t as y}from"./DatePicker.Bkl71M49.js";import{t as ce}from"./OverflowHint.pvo2Xc8R.js";import{t as b}from"./SelectDropdown.apWlFGbA.js";import{showToast as x}from"./Toast.BO2NFckG.js";import{A as S,C as le,D as ue,E as de,M as fe,N as pe,P as C,S as me,T as he,_ as ge,b as w,f as _e,g as ve,j as ye,k as be,n as T,u as xe,v as E,w as Se,x as Ce,y as D}from"./tasks.BNBkrFC3.js";import{a as O,c as k,i as we,l as A,n as j,o as M,r as N,s as P,t as F}from"./DrawerField.C0MkN-LW.js";var I=e(t(),1),L=d(),Te=8e3,Ee=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Oe={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},ke={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},R={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Ae={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},je={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},z={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Me=[`status`,`priority`,`none`],Ne=`todos.group-by`,Pe=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Fe=D.map(e=>({value:e,label:w[e]})),Ie=[{value:``,label:`未设置`},...ge.map(e=>({value:e,label:E[e]}))],Le=Object.keys(z).map(e=>({value:e,label:z[e]})),Re=[{value:`all`,label:`全部紧急程度`},...ge.map(e=>({value:e,label:E[e]}))],ze=Re.map(e=>e.value),Be=`todos.priority-filter`,Ve=`todos.search`,He=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Ue(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,L.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${He} ${r&&!t?`text-stone-300`:``}`})}function We(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,I.useState)(!1);return a?(0,L.jsx)(Ue,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,L.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ge(e){return(0,L.jsx)(y,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Ke(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,I.useState)({title:``}),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(!1),[h,re]=(0,I.useState)(!0);(0,I.useEffect)(()=>{t&&(f(``),m(!1),re(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:S(),dueDate:S(),...r}))},[t,n,r]);let ie=[{value:``,label:`不关联`},..._e(i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId)).map(e=>({value:e.id,label:e.title}))];function g(e){ee(t=>({...t,...e}))}let ae=ye({startDate:c.startDate??``,dueDate:c.dueDate??``}),_=pe({dueDate:c.dueDate??``}),oe=de(c.status??`pending`),v=oe?se((n&&de(n.status)?n.taskEndDate:``)||S()):``,le=_===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:_<0?`逾期 ${Math.abs(_)} 天`:_===0?`今天截止`:`${_} 天`;async function ue(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await C(n.id,t):await Ce([t],{mode:`manual`}),await s(),x(n?`已保存待办`:`已新建待办`,`success`),o()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),x(`保存待办失败:${t}`,`error`)}finally{m(!1)}}}return(0,L.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,L.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,L.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,L.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,L.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`待办名称`,children:(0,L.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())},placeholder:`请输入内容`,className:F})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`待办状态`,children:(0,L.jsx)(N,{ariaLabel:`待办状态`,menuMinWidth:140,options:Fe,value:c.status??`pending`,onChange:e=>g({status:e}),label:w[c.status??`pending`],optionDotClassName:e=>Ae[e]})}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>re(e=>!e),"aria-expanded":h,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,L.jsx)(k,{})}),(0,L.jsx)(`span`,{children:`任务详情`}),(0,L.jsx)(`span`,{className:`text-stone-400`,children:(0,L.jsx)(we,{open:h})})]}),h?(0,L.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(k,{}),label:`所属任务`,children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ie,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);g({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,L.jsx)(ce,{text:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`,className:`min-w-0 truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`})}),i.length===0?(0,L.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,L.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,L.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,L.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,L.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,L.jsx)(N,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ie,value:c.priority??``,onChange:e=>g({priority:e}),label:c.priority?E[c.priority]:`未设置`,optionDotClassName:e=>je[e]})})()}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`结束日期`,children:(0,L.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[v?(0,L.jsx)(`span`,{className:`text-stone-800`,children:v}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,L.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:oe?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`开始日期`,children:(0,L.jsx)(y,{value:c.startDate??``,onChange:e=>g({startDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`截止日期`,children:(0,L.jsx)(y,{value:c.dueDate??``,onChange:e=>g({dueDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`待办周期`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ae===null?`—`:`${ae} 天`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`剩余天数`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:le||`—`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`备注`,children:(0,L.jsx)(`textarea`,{value:c.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,L.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void ue(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function B(){let[e,t]=(0,I.useState)(!1),[l,te]=(0,I.useState)(!0),[u,ne]=(0,I.useState)(null),[d,T]=(0,I.useState)([]),[D,O]=(0,I.useState)([]),[k,we]=(0,I.useState)(!1),[A,j]=(0,I.useState)(null),[M,N]=(0,I.useState)(!1),[P,F]=(0,I.useState)(()=>c(Ve)),[z,He]=(0,I.useState)(()=>o(Be,ze,`all`)),[B,qe]=(0,I.useState)(()=>o(Ne,Me,`status`)),[Je,Ye]=(0,I.useState)({}),[V,Xe]=(0,I.useState)({});function Ze(e){s(Ne,e),qe(e)}function Qe(e){s(Be,e),He(e)}function $e(e){ee(Ve,e),F(e)}let[et,tt]=(0,I.useState)({}),[H,U]=(0,I.useState)(null),[W,G]=(0,I.useState)(null),[nt,rt]=(0,I.useState)(!1),[it,at]=(0,I.useState)(null),K=(0,I.useRef)(!0),ot=(0,I.useRef)(!1),st=(0,I.useRef)(!1),q=ie(`lh:todos:cols:v1`,Ee),ct=h(`todos`),lt=H!==null,ut=(0,I.useRef)(H);ut.current=H;let dt=(0,I.useRef)(!1),ft=(0,I.useRef)(async()=>{});ft.current=bt,(0,I.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]),(0,I.useEffect)(()=>{if(!lt)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=ut.current;if(!n)return;if(n.title.trim()){ft.current();return}let r=S();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&U(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[lt]);let J=(0,I.useCallback)(async()=>{try{let[e,t]=await Promise.all([ue(),k?xe().catch(()=>[]):Promise.resolve([])]);if(!K.current)return;let n=t;if(!ot.current&&k){ot.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>ve(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}T(e),O(n),j(null)}catch(e){if(!K.current)return;j(e instanceof Error?e.message:String(e))}},[k]);(0,I.useEffect)(()=>{let e=i(e=>{te(!!e.todos),we(!!e.tasks)});return n().then(()=>{te(r(`todos`)),we(r(`tasks`)),t(!0)}),e},[]),(0,I.useEffect)(()=>{e&&l&&(async()=>{let e=await Se();K.current&&(e?(await J(),K.current&&ne(!0)):ne(!1))})()},[e,l,J]),(0,I.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{st.current||J()},Te),t=()=>{st.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,J]),(0,I.useEffect)(()=>{if(!k||u!==!0||D.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=D.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await C(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&T(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[k,u,d,D]);function pt(e,t,n){tt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){tt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let mt=(0,I.useMemo)(()=>[{value:``,label:`不关联`},..._e(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function ht(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function gt(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function _t(e){let t=gt(e);return t?t.priority:e.priority}async function X(e,t){T(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await C(e,t);if(!K.current)return;T(t=>t.map(t=>t.id===e?n:t)),j(null),t.taskId&&await J()}catch(e){j(e instanceof Error?e.message:String(e)),await J()}}async function vt(e){let t=et[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of De){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())j(`待办名称不能为空`),Y(e);else try{let t=await C(e,r);if(!K.current)return;T(n=>n.map(n=>n.id===e?t:n)),tt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),j(null)}catch(t){j(t instanceof Error?t.message:String(t)),Y(e)}}function yt(e){let t=e.newStatus??`pending`,n=e.newPriority??``;U({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:S(),dueDate:S(),note:``,baseStatus:t,basePriority:n}),Ye(t=>({...t,[e.key]:!1}))}async function bt(){let e=ut.current;if(!e||dt.current)return;let t=e.title.trim();if(t){dt.current=!0,rt(!0);try{let n=D.find(t=>t.id===e.taskId);await Ce([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),ut.current===e&&U(null),j(null),await J()}catch(e){j(e instanceof Error?e.message:String(e))}finally{dt.current=!1,K.current&&rt(!1)}}}async function xt(){let e=W;if(e){G(null),N(!0),j(null);try{await me(e.map(e=>e.id)),Xe({}),await J(),x(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),x(`删除待办失败:${t}`,`error`)}finally{K.current&&N(!1)}}}let Z=S(),St=(0,I.useMemo)(()=>d.map(e=>{let t=e.taskId?D.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,D]),Ct=(0,I.useMemo)(()=>he(St,{status:`all`,priority:z,keyword:P,today:Z}),[St,z,P,Z]),Q=(0,I.useMemo)(()=>be(Ct),[Ct]),wt=(0,I.useMemo)(()=>B===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:B===`priority`?[...ge,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:`未设置`,pill:e?R[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Pe.map(e=>({key:`status:${e}`,label:w[e],pill:Oe[e],items:Q.filter(t=>le(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[B,Q,Z]).filter(e=>e.items.length>0||H?.groupKey===e.key&&!!H),Tt=Object.keys(V).filter(e=>V[e]),$=(0,I.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=le(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,L.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,L.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`input`,{value:P,onChange:e=>$e(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,L.jsx)(b,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Le,value:B,onChange:e=>Ze(e)}),(0,L.jsx)(b,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Re,value:z,onChange:e=>Qe(e)}),(0,L.jsx)(`button`,{type:`button`,disabled:M||Tt.length===0,onClick:()=>G(d.filter(e=>V[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>at({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),A?(0,L.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,L.jsx)(`div`,{ref:ct,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{st.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{st.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,L.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,L.jsx)(`colgroup`,{children:Ee.map(e=>(0,L.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,L.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:p,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>V[e.id]),onChange:e=>{let t=e.target.checked;Xe(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,L.jsx)(`th`,{className:oe,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,L.jsxs)(`th`,{className:ae,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,L.jsx)(v,{...q.resizeProps(`title`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,L.jsx)(v,{...q.resizeProps(`status`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,L.jsx)(v,{...q.resizeProps(`task`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,L.jsx)(v,{...q.resizeProps(`priority`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,L.jsx)(v,{...q.resizeProps(`start`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,L.jsx)(v,{...q.resizeProps(`due`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,L.jsx)(v,{...q.resizeProps(`end`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,L.jsx)(v,{...q.resizeProps(`cycle`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,L.jsx)(v,{...q.resizeProps(`remain`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,L.jsx)(v,{...q.resizeProps(`note`)})]}),(0,L.jsx)(`th`,{"aria-hidden":`true`}),(0,L.jsx)(`th`,{className:m,children:`操作`})]})}),wt.map(e=>{let t=Je[e.key]===!0;return(0,L.jsxs)(`tbody`,{children:[(0,L.jsx)(`tr`,{className:`bg-white`,children:(0,L.jsx)(`td`,{colSpan:14,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Ye(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,L.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,L.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,L.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=et[e.id]??{},r={...e,...n},i=le(r,Z),a=ye(r),o=pe(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,L.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,L.jsx)(`td`,{className:g,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!V[e.id],onChange:t=>Xe(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,L.jsx)(`td`,{className:`${_} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,L.jsx)(`td`,{className:g,style:{"--tw-sticky-left":`68px`},children:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,L.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,L.jsx)(Ue,{value:r.title,placeholder:`输入待办名称`,onChange:t=>pt(e.id,`title`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})]})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[i]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:w[i]}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:r.taskId,onChange:t=>{let n=D.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,L.jsx)(ce,{text:ht(r)||`未关联`,className:`min-w-0 truncate ${ht(r)?`text-stone-800`:`text-stone-300`}`})}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:ht(r)?`${ht(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:gt(r)?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[_t(r)]??`text-stone-300`}`,children:_t(r)?E[_t(r)]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[e.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:e.priority?E[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${je[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:fe(r)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(fe(r))}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(We,{value:r.note,onChange:t=>pt(e.id,`note`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:re,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>at({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M14 4h6v6`}),(0,L.jsx)(`path`,{d:`M20 4 13 11`}),(0,L.jsx)(`path`,{d:`M10 20H4v-6`}),(0,L.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M3 6h18`}),(0,L.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,L.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,L.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:H?.groupKey===e.key?(0,L.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,L.jsx)(`td`,{className:_,children:(0,L.jsx)(`input`,{autoFocus:!0,value:H.title,disabled:nt,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>U(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),bt()):e.key===`Escape`&&(e.preventDefault(),U(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:H.status,onChange:e=>U(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[H.status]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:w[H.status]})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:H.taskId,onChange:e=>U(t=>{if(!t)return t;let n=D.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=D.find(e=>e.id===H.taskId);return(0,L.jsx)(ce,{text:e?.title||`未关联`,className:`min-w-0 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===H.taskId);return e?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:H.priority,onChange:e=>U(t=>t&&{...t,priority:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[H.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`truncate`,children:H.priority?E[H.priority]:`未设置`})})})()}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.startDate,onChange:e=>U(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.dueDate,onChange:e=>U(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:de(H.status)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(S())}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(`input`,{value:H.note,disabled:nt,placeholder:`—`,onChange:e=>U(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`px-2 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:12,children:(0,L.jsxs)(`button`,{type:`button`,disabled:nt,onClick:()=>yt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,L.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),wt.length===0?(0,L.jsx)(`tbody`,{children:(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:14,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,L.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,Tt.length?` · 已选 ${Tt.length}`:``]}),(0,L.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,L.jsx)(Ke,{open:it!==null,item:it?.item??null,preset:it?.preset,tasks:D,tasksOn:k,onClose:()=>at(null),onSaved:J}),(0,L.jsx)(f,{open:W!=null,title:W&&W.length>1?`批量删除`:`删除待办`,message:W&&W.length>1?`确认删除已选中的 ${W.length} 条待办?此操作不可恢复。`:`删除「${W?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>G(null),onConfirm:()=>void xt()})]}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`todos`)}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{B as default};
@@ -1 +0,0 @@
1
- var e=`0.1.25`;export{e as t};
@@ -1 +0,0 @@
1
- var e=`/__tb_todos`,t=[`pending`,`in_progress`,`overdue`,`done`,`cancelled`],n=[`urgent_important`,`important`,`urgent`,`normal`],r={pending:`待开始`,in_progress:`进行中`,done:`已完成`,overdue:`已延期`,cancelled:`已取消`},i={urgent_important:`重要紧急`,important:`重要不紧急`,urgent:`紧急不重要`,normal:`普通`,"":`—`},a=new Set(t),o=new Set(n),s=/^\d{4}-\d{2}-\d{2}$/;function c(e,t=2e3){return typeof e==`string`?e.trim().slice(0,t):``}function l(e){let t=c(e,10);return s.test(t)?t:``}function u(e){return typeof e==`string`&&a.has(e)}function d(e){return typeof e==`string`&&o.has(e)}function f(e){return e===`done`||e===`cancelled`}function p(e){if(!e||typeof e!=`object`)return null;let t=e,n=c(t.title,200);if(!n)return null;let r={title:n};return u(t.status)&&(r.status=t.status),d(t.priority)&&(r.priority=t.priority),`linkedTask`in t&&(r.linkedTask=c(t.linkedTask,200)),`taskId`in t&&(r.taskId=c(t.taskId,64)),`startDate`in t&&(r.startDate=l(t.startDate)),`dueDate`in t&&(r.dueDate=l(t.dueDate)),`note`in t&&(r.note=c(t.note)),r}function m(e){if(!e||typeof e!=`object`)return null;let t=e,n=c(t.title,200);if(!n)return null;let r=new Date().toISOString(),i=u(t.status)?t.status:`pending`,a=l(t.dueDate),o=!f(i)&&a&&a<x()?`overdue`:i;return{id:c(t.id,64)||`td_${Math.random().toString(16).slice(2,10)}`,title:n,status:o,priority:d(t.priority)?t.priority:``,linkedTask:c(t.linkedTask,200),taskId:c(t.taskId,64),startDate:l(t.startDate),dueDate:a,taskEndDate:f(o)?l(t.taskEndDate):``,note:c(t.note),source:t.source===`ai`?`ai`:`manual`,sessionId:c(t.sessionId,120),createdAt:c(t.createdAt,40)||r,updatedAt:c(t.updatedAt,40)||r,doneAt:c(t.doneAt,40)||null}}async function h(t,n,r=``){let i=await fetch(`${e}${r}`,{method:t,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),a=await i.json().catch(()=>({}));if(!i.ok)throw Error(a.error||`HTTP ${i.status}`);return a}async function g(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function _(){let e=await h(`GET`);return(Array.isArray(e.items)?e.items:[]).map(m).filter(e=>!!e)}async function v(e,t){let n=await h(`POST`,{items:e,...t});return(Array.isArray(n.items)?n.items:[]).map(m).filter(e=>!!e)}async function y(e,t){let n=m((await h(`PUT`,{id:e,...t})).item);if(!n)throw Error(`更新待办失败`);return n}async function b(e){let t=await h(`DELETE`,{ids:e});return Number(t.removed??0)}function x(e=new Date){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function S(e){let[t,n,r]=e.split(`-`).map(Number);return Date.UTC(t,(n??1)-1,r??1)}function C(e,t){return!s.test(e)||!s.test(t)?null:Math.round((S(t)-S(e))/864e5)}function w(e){let t=C(e.startDate,e.dueDate);return t===null?null:t+1}function T(e,t=x()){return C(t,e.dueDate)}function E(e){return f(e.status)?e.taskEndDate:``}function D(e,t=x()){if(e.status===`done`||e.status===`cancelled`||e.status===`overdue`)return e.status;let n=T(e,t);return n!==null&&n<0?`overdue`:e.status}function O(e){let t=e=>e===`in_progress`?0:e===`pending`?1:e===`overdue`?2:e===`done`?3:4,n=e=>e===`urgent_important`?0:e===`important`?1:e===`urgent`?2:e===`normal`?3:4;return[...e].sort((e,r)=>{let i=t(e.status)-t(r.status);if(i!==0)return i;let a=e.dueDate||`9999-12-31`,o=r.dueDate||`9999-12-31`;if(a!==o)return a<o?-1:1;let s=n(e.priority)-n(r.priority);return s===0?e.createdAt<r.createdAt?1:-1:s})}function k(e,t={}){let n=t.status??`all`,r=t.priority??`all`,i=(t.keyword??``).trim().toLowerCase(),a=t.today??x();return e.filter(e=>!(n!==`all`&&D(e,a)!==n||r!==`all`&&e.priority!==r||i&&!`${e.title} ${e.linkedTask} ${e.note}`.toLowerCase().includes(i)))}var A=`/__tb_tasks`,j=[`pool`,`in_progress`,`done`,`closed`,`cancelled`],M=[`urgent_important`,`important`,`urgent`,`normal`],N={pool:`任务池`,in_progress:`进行中`,done:`已完成`,closed:`已关闭`,cancelled:`已取消`},P={urgent_important:`重要紧急`,important:`重要不紧急`,urgent:`紧急不重要`,normal:`普通`,"":`—`},F=new Set(j),I=new Set(M),L=/^\d{4}-\d{2}-\d{2}$/;function R(e,t=2e3){return typeof e==`string`?e.trim().slice(0,t):``}function z(e){let t=R(e,10);return L.test(t)?t:``}function B(e){return typeof e==`string`&&F.has(e)}function V(e){return typeof e==`string`&&I.has(e)}function H(e){if(!e||typeof e!=`object`)return null;let t=e,n=R(t.title,200);if(!n)return null;let r={title:n};return B(t.status)&&(r.status=t.status),V(t.priority)&&(r.priority=t.priority),`startDate`in t&&(r.startDate=z(t.startDate)),`dueDate`in t&&(r.dueDate=z(t.dueDate)),`note`in t&&(r.note=R(t.note)),r}function U(e){if(!e||typeof e!=`object`)return null;let t=e,n=R(t.title,200);if(!n)return null;let r=new Date().toISOString();return{id:R(t.id,64)||`tk_${Math.random().toString(16).slice(2,10)}`,title:n,status:B(t.status)?t.status:`pool`,priority:V(t.priority)?t.priority:``,startDate:z(t.startDate),dueDate:z(t.dueDate),note:R(t.note),source:t.source===`ai`?`ai`:`manual`,sessionId:R(t.sessionId,120),createdAt:R(t.createdAt,40)||r,updatedAt:R(t.updatedAt,40)||r,doneAt:R(t.doneAt,40)||null}}async function W(e,t){let n=await fetch(A,{method:e,headers:t===void 0?void 0:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`HTTP ${n.status}`);return r}async function G(){try{return(await fetch(`${A}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function K(){let e=await W(`GET`);return(Array.isArray(e.items)?e.items:[]).map(U).filter(e=>!!e)}async function q(e,t){let n=await W(`POST`,{items:e,...t});return(Array.isArray(n.items)?n.items:[]).map(U).filter(e=>!!e)}async function J(e,t){let n=U((await W(`PUT`,{id:e,...t})).item);if(!n)throw Error(`更新任务失败`);return n}async function Y(e){let t=await W(`DELETE`,{ids:e});return Number(t.removed??0)}function X(e){let[t,n,r]=e.split(`-`).map(Number);return Date.UTC(t,(n??1)-1,r??1)}function Z(e){return!L.test(e.startDate)||!L.test(e.dueDate)?null:Math.round((X(e.dueDate)-X(e.startDate))/864e5)+1}function Q(e){let t={};for(let n of e){let e=n.taskId?.trim();if(!e)continue;let r=t[e]??={total:0,done:0,percent:0};r.total+=1,n.status===`done`&&(r.done+=1)}for(let e of Object.values(t))e.percent=e.total?Math.round(e.done/e.total*100):0;return t}function $(e,t={}){let n=t.status??`all`,r=t.priority??`all`,i=(t.keyword??``).trim().toLowerCase();return e.filter(e=>{if(n===`urgent`){if(e.priority!==`urgent_important`&&e.priority!==`urgent`)return!1}else if(n!==`all`&&e.status!==n)return!1;return!(r!==`all`&&e.priority!==r||i&&!`${e.title} ${e.note}`.toLowerCase().includes(i))})}function ee(e){return[...e].sort((e,t)=>{let n=e.updatedAt||e.createdAt,r=t.updatedAt||t.createdAt;return n===r?e.createdAt===t.createdAt?0:e.createdAt<t.createdAt?1:-1:n<r?1:-1})}function te(e){let t={total:e.length,pool:0,in_progress:0,done:0,closed:0,cancelled:0,urgent:0};for(let n of e)t[n.status]+=1,(n.priority===`urgent_important`||n.priority===`urgent`)&&(t.urgent+=1);return t}export{x as A,D as C,_ as D,f as E,E as M,T as N,p as O,y as P,b as S,k as T,n as _,q as a,r as b,$ as c,H as d,ee as f,J as g,Q as h,N as i,w as j,O as k,V as l,Z as m,P as n,Y as o,te as p,j as r,G as s,M as t,K as u,i as v,g as w,v as x,t as y};