lantern-harness 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +2 -2
- package/builtin/session/lh-nav-groups.mjs +9 -0
- package/builtin/session/mcp-client.mjs +291 -2
- package/cli/server.mjs +2 -0
- package/config/app.defaults.json +2 -1
- package/dist/500.html +72 -9
- package/dist/_astro/Base.DjXU-4S_.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.BQ1EoZdo.js → Base.astro_astro_type_script_index_0_lang.CiZNg228.js} +1 -1
- package/dist/_astro/{CaseExecBoard.CTVdi8MV.js → CaseExecBoard.DzNtPCwr.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.CJK7V6iA.js → CaseGenerateApp.BvRwwxhs.js} +1 -1
- package/dist/_astro/{CasesLibrary.Don-Cnus.js → CasesLibrary.B9I31b7C.js} +1 -1
- package/dist/_astro/ChatApp.79JSgx7d.js +226 -0
- package/dist/_astro/ColumnResize.CkE59sGq.js +1 -0
- package/dist/_astro/{DashboardBoard.BaJyXPXA.js → DashboardBoard.BuyuI8WW.js} +1 -1
- package/dist/_astro/{DocsFileBrowser.D2Cff2LP.js → DocsFileBrowser.9WTBumS5.js} +1 -1
- package/dist/_astro/{DocsPager.CnXEnQqa.js → DocsPager.BS20yicJ.js} +1 -1
- package/dist/_astro/{DrawerField.C0MkN-LW.js → DrawerField.CiHAvXHQ.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.CWxIHa8I.js → KnowledgeLibrary.CQ8ULHI5.js} +1 -1
- package/dist/_astro/LifeKrTasksBoard.BWoB442i.js +1 -0
- package/dist/_astro/LifeKrTodosBoard.rDbG9XcJ.js +1 -0
- package/dist/_astro/LifeObjectivesBoard.DUDQg_RD.js +1 -0
- package/dist/_astro/LifePlanTypeSelect.BtXnXOkz.js +1 -0
- package/dist/_astro/LifeReviewsBoard.p-dp_NXl.js +5 -0
- package/dist/_astro/LifeShared.Di9sdb_T.js +3 -0
- package/dist/_astro/LifeStagesBoard.BSvhzmp_.js +1 -0
- package/dist/_astro/LifeYearCycleSelect.Q4VvLY8X.js +1 -0
- package/dist/_astro/LifeYearPlansBoard.CYN2gZKp.js +1 -0
- package/dist/_astro/MultiSelectDropdown.y8JMbCxO.js +1 -0
- package/dist/_astro/{NavLibraries.CZlA6Z1w.js → NavLibraries.D9EKoN80.js} +1 -1
- package/dist/_astro/PluginsPage.DE3qbeY5.js +17 -0
- package/dist/_astro/PluginsPage.r98lZChB.js +1 -0
- package/dist/_astro/{PmBugsBoard.ChL0RBVn.js → PmBugsBoard.Cu1uf0TC.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.hTKVnMgh.js → PmIterationsBoard.RzRKkAH0.js} +1 -1
- package/dist/_astro/{PmProjectDetail.Saj76lNM.js → PmProjectDetail.DH8Z3nHb.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.CCtClGM1.js → PmProjectsBoard.Dokaj4V1.js} +1 -1
- package/dist/_astro/{PmRequirementsBoard.DGXYC1Te.js → PmRequirementsBoard.DET5YIVX.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.i203nmYC.js +1 -0
- package/dist/_astro/{PmShared.BuhrL7Gb.js → PmShared.BJpoEYvk.js} +1 -1
- package/dist/_astro/{PromptsLibrary.DJtTAFz_.js → PromptsLibrary.Dp1S_lHQ.js} +1 -1
- package/dist/_astro/{ReportsPage.BjD8w0zS.js → ReportsPage.C8uufWVb.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.BsQ4A1Lt.js → ReqAnalysisBoard.B3bhMWmE.js} +1 -1
- package/dist/_astro/{RequirementsLibrary.WxAFCP3X.js → RequirementsLibrary.BnY7_YXU.js} +1 -1
- package/dist/_astro/{SearchableSelect.D3ODywC4.js → SearchableSelect.5SfNLwNW.js} +1 -1
- package/dist/_astro/SelectDropdown.TgxIOKMD.js +1 -0
- package/dist/_astro/{SettingsDialog.CR7rv0mg.js → SettingsDialog.BzGBZlo2.js} +1 -1
- package/dist/_astro/{SpaceSwitcher.BCZbiL7o.js → SpaceSwitcher.Cy4UrzbH.js} +1 -1
- package/dist/_astro/TasksBoard.CWkx5cD1.js +1 -0
- package/dist/_astro/{TemplatesLibrary.y_RtSjYC.js → TemplatesLibrary.phzK5kho.js} +1 -1
- package/dist/_astro/{TestStatsBoard.C3vkF9vc.js → TestStatsBoard.Dp1TWEf7.js} +1 -1
- package/dist/_astro/TodosBoard.Bkuw_LDW.js +1 -0
- package/dist/_astro/{UiAutoBoard._og5jRon.js → UiAutoBoard.Cpb_EF46.js} +1 -1
- package/dist/_astro/app-config.C4rpn1Ix.js +1 -0
- package/dist/_astro/app-version.CXqYg1a3.js +1 -0
- package/dist/_astro/{bash-tools.cciCC33C.js → bash-tools.RQcI4_42.js} +1 -1
- package/dist/_astro/{case-gen-run.DDhoxXlU.js → case-gen-run.CH0ldlsU.js} +1 -1
- package/dist/_astro/{case-types.CJ5PHz59.js → case-types.CprZTsyX.js} +1 -1
- package/dist/_astro/{hydrate-cache.B7--LFB_.js → hydrate-cache.DI6vqM0o.js} +1 -1
- package/dist/_astro/i18n.BJeTr39S.js +7 -0
- package/dist/_astro/{open-docs-in-session.DQ2_5fkC.js → open-docs-in-session.BdihMTEh.js} +1 -1
- package/dist/_astro/plugins.C0NrHGZv.js +1 -0
- package/dist/_astro/{req-analysis.D9EOpleR.js → req-analysis.CjhgP3jI.js} +1 -1
- package/dist/_astro/{settings.Cu00if4D.js → settings.NTeTjmxg.js} +2 -2
- package/dist/_astro/{spaces-client.Czm-VPh5.js → spaces-client.CMGNsQJ-.js} +1 -1
- package/dist/_astro/{story-review.COs6QaUe.js → story-review.BBfB1qYF.js} +1 -1
- package/dist/_astro/tasks.DefXqRfI.js +1 -0
- package/dist/_astro/{view-prefs.SdItxolG.js → view-prefs.8MPl3A7e.js} +1 -1
- package/dist/case-exec/index.html +141 -15
- package/dist/cases/generate/index.html +73 -10
- package/dist/cases/library/index.html +141 -15
- package/dist/dashboard/index.html +141 -15
- package/dist/docs/changelog/index.html +148 -44
- package/dist/docs/install/index.html +86 -12
- package/dist/docs/manual/index.html +150 -17
- package/dist/knowledge/index.html +141 -15
- package/dist/life/kr-tasks/index.html +921 -0
- package/dist/life/kr-todos/index.html +921 -0
- package/dist/life/objectives/index.html +921 -0
- package/dist/life/reviews/index.html +921 -0
- package/dist/life/stages/index.html +921 -0
- package/dist/life/year-plans/index.html +921 -0
- package/dist/plugins/index.html +73 -10
- package/dist/pm/bugs/index.html +141 -15
- package/dist/pm/iterations/index.html +141 -15
- package/dist/pm/projects/detail/index.html +141 -15
- package/dist/pm/projects/index.html +141 -15
- package/dist/pm/requirements/index.html +141 -15
- package/dist/prompts/index.html +141 -15
- package/dist/reports/index.html +141 -15
- package/dist/requirement-analysis/index.html +141 -15
- package/dist/requirements/index.html +141 -15
- package/dist/tasks/index.html +141 -15
- package/dist/templates/index.html +141 -15
- package/dist/test-automation/index.html +141 -15
- package/dist/test-stats/index.html +141 -15
- package/dist/todos/index.html +141 -15
- package/dist/workbench/index.html +73 -10
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +3 -3
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +10 -3
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +53 -14
- package/lh-plugins/lh-life.mjs +1130 -0
- package/lh-plugins/lh-mcp.mjs +67 -2
- package/package.json +1 -1
- package/dist/_astro/Base.Dlgbb4Ry.css +0 -1
- package/dist/_astro/ChatApp.BTcAJ7PK.js +0 -226
- package/dist/_astro/ColumnResize._Iq05ix_.js +0 -1
- package/dist/_astro/MultiSelectDropdown.BHxW9XLR.js +0 -1
- package/dist/_astro/PluginsPage.CyjR13X6.js +0 -7
- package/dist/_astro/PluginsPage.DMEvFLnP.js +0 -1
- package/dist/_astro/PmRequirementsBoard.BNNq671Z.js +0 -1
- package/dist/_astro/SelectDropdown.apWlFGbA.js +0 -1
- package/dist/_astro/TasksBoard.CdWQSwlg.js +0 -1
- package/dist/_astro/TodosBoard.CSupMlTp.js +0 -1
- package/dist/_astro/app-config.Bg6v8zQQ.js +0 -1
- package/dist/_astro/app-version.DpWEt8o3.js +0 -1
- package/dist/_astro/i18n.CH6ZNsHf.js +0 -7
- package/dist/_astro/plugins.CVnHeKyf.js +0 -1
- package/dist/_astro/tasks.jfnSAEmg.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as ee}from"./plugins.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as ee}from"./plugins.C0NrHGZv.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as te}from"./SelectDropdown.TgxIOKMD.js";import{showToast as i}from"./Toast.BO2NFckG.js";import{C as a,M as o,R as s,c,g as ne,h as re,s as l}from"./pm.BXmOiFfW.js";import{A as ie,D as u,E as d,O as f,S as p,_ as m,a as h,c as g,d as _,f as v,g as y,i as b,k as x,l as ae,m as S,o as C,s as oe,u as se,v as ce,y as le}from"./PmShared.BJpoEYvk.js";var w=e(t(),1),T=n(),E=10,D=l.map(e=>({value:e,label:c[e]})),O=[`all`,...l],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=x(`projects`),{store:t,live:n,loading:l,error:M,setError:N,reload:P}=ie(),[F,I]=u(k,O,`all`),[L,R]=f(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)(()=>o(t),[t]),X=(0,w.useMemo)(()=>a(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 s(`projects`,V.id,{name:e,description:V.description,status:V.status}):await re(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0),i(V.id?`已保存项目`:`已新建项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),i(`保存项目失败:${t}`,`error`)}finally{W(!1)}}}async function fe(e){J(null),W(!0);try{let t=e.status!==`archived`;await s(`projects`,e.id,{status:t?`archived`:`planning`}),await P(!0),i(t?`已归档「${e.name}」`:`已取消归档「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),i(`更新项目失败:${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),i(`已删除项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),i(`删除项目失败:${t}`,`error`)}finally{W(!1)}}}return e.ready?e.on?n===null?(0,T.jsx)(y,{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)(te,{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)(S,{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)(S,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(_,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:l&&!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)(ae,{children:`没有符合筛选条件的项目。`}):(0,T.jsx)(se,{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)(S,{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:d(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)(p,{tone:C[e.status],children:c[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)(S,{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)(S,{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)(S,{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)(S,{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)(S,{name:`chevronRight`,size:14,className:`tw-pm-card-chevron text-stone-300`})]})]})]})]},e.id)})})}),X.length>0?(0,T.jsx)(ce,{page:Q,totalPages:Z,busy:U,onPage:B}):null,(0,T.jsx)(g,{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)(v,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:b})}),(0,T.jsx)(v,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:h})}),(0,T.jsx)(v,{label:`状态`,children:(0,T.jsx)(le,{ariaLabel:`项目状态`,options:D,value:V.status,onChange:e=>H({...V,status:e}),renderOptionPrefix:e=>(0,T.jsx)(oe,{tone:C[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)(m,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(m,{children:ee(`projects`)}):(0,T.jsx)(y,{label:`正在读取插件开关`})}export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.CVnHeKyf.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{n as a,t as ee}from"./DocsPager.CnXEnQqa.js";import{t as o}from"./SelectDropdown.apWlFGbA.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{c,d as te,i as l,l as ne,n as u,o as d,r as f,s as re,t as p}from"./ColumnResize._Iq05ix_.js";import{A as m,D as h,F as ie,P as ae,R as g,b as _,d as v,f as oe,g as se,h as ce,j as y,l as b,m as le,u as ue,w as de,z as x}from"./pm.BXmOiFfW.js";import{A as fe,C as pe,D as me,E as he,O as S,S as ge,T as C,_ as w,a as _e,c as ve,d as ye,f as T,g as be,h as E,k as xe,l as Se,m as D,p as Ce,s as O,u as we,w as Te,y as k}from"./PmShared.BuhrL7Gb.js";var A=e(t(),1),j=r();function Ee({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=y(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 y(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 x(Array.from(n));t(m([...y(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=_(e.clipboardData);t.length&&(e.preventDefault(),f(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[f]);async function re(e){let i=m(o.filter(t=>t.url!==e));if(r)try{await g(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:[h(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})}),h(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 re(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 De=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],Oe={key:`project`,width:140,min:100},ke=[{key:`iteration`,width:120,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ae=20,je=`tw.pm-requirements.page-size.v1`,Me=[`all`,...v],Ne=[`all`,...b],Pe=`pm.requirements.project`,Fe=`pm.requirements.iteration`,Ie=`pm.requirements.status`,Le=`pm.requirements.priority`,Re=`pm.requirements.keyword`,ze=b.map(e=>({value:e,label:ue[e]})),M=v.map(e=>({value:e,label:oe[e]}));function Be(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function N({scopeProjectId:e=``}={}){let t=!!e,r=xe(`pmRequirements`),{store:m,live:h,loading:_,error:v,setError:b,reload:x}=fe(),[E,N]=S(Pe,`all`),P=e||E,[F,I]=S(Fe,`all`),[L,Ve]=me(Ie,Me,`all`),[R,He]=me(Le,Ne,`all`),[z,Ue]=S(Re),[We,B]=(0,A.useState)(1),[V,Ge]=a(Ae,je),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(!1),[K,q]=(0,A.useState)(null),J=(0,A.useRef)(new Set),Y=(0,A.useMemo)(()=>t?[...De,...ke]:[...De,Oe,...ke],[t]),X=ne(t?`pm.requirements.cols.scoped.v1`:`pm.requirements.cols.v1`,Y),Ke=te(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),qe=X.widthOf(`id`)??88,Je=(0,A.useMemo)(()=>[{value:`all`,label:`全部项目`},...m.projects.map(e=>({value:e.id,label:e.name}))],[m.projects]),Ye=(0,A.useMemo)(()=>[{value:`all`,label:`全部迭代`},...ae(m.iterations.filter(e=>P===`all`||e.projectId===P)).map(e=>({value:e.id,label:e.name}))],[m.iterations,P]),Xe=(0,A.useMemo)(()=>{let e=new Map(m.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[m.projects]),Ze=(0,A.useMemo)(()=>{let e=new Map(m.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[m.iterations]),Z=(0,A.useMemo)(()=>ie(de(m.requirements,{projectId:P,iterationId:F,status:L,priority:R,keyword:z})),[m.requirements,P,F,L,R,z]),Q=t?m.requirements.filter(e=>e.projectId===P).length:m.requirements.length,Qe=Math.max(1,Math.ceil(Z.length/V)),$=Math.min(We,Qe),$e=Z.slice(($-1)*V,$*V);(0,A.useEffect)(()=>{t||h===!0&&E!==`all`&&!m.projects.some(e=>e.id===E)&&N(`all`)},[h,m.projects,E,N,t]),(0,A.useEffect)(()=>{h===!0&&F!==`all`&&!m.iterations.some(e=>e.id===F&&(P===`all`||e.projectId===P))&&I(`all`)},[h,m.iterations,P,F,I]);let et=H?ae(m.iterations.filter(e=>e.projectId===H.projectId)):[];async function tt(){if(!H)return;if(!H.projectId){b(`请先选择所属项目`);return}let e=H.title.trim();if(!e)b(`需求描述不能为空`);else{G(!0);try{let t={projectId:H.projectId,iterationId:H.iterationId,title:e,priority:H.priority,status:H.status,description:H.description,acceptanceCriteria:H.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:H.githubIssue,attachment:H.attachment};H.id?await g(`requirements`,H.id,t):await ce(`requirements`,[t]);let n=!!H.id;U(null),J.current.clear(),b(``),await x(!0),s(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);b(t),s(`保存需求失败:${t}`,`error`)}finally{G(!1)}}}function nt(){let e=[...J.current,...y(H?.attachment??``).map(e=>e.url)];J.current.clear(),U(null),e.length&&le(e)}async function rt(e,t){G(!0);try{await g(`requirements`,e.id,{status:t}),await x(!0),s(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);b(t),s(`更新状态失败:${t}`,`error`)}finally{G(!1)}}async function it(){let e=K;if(e){q(null),G(!0);try{await se(`requirements`,[e.id]),await x(!0),s(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);b(t),s(`删除需求失败:${t}`,`error`)}finally{G(!1)}}}if(!r.ready)return(0,j.jsx)(be,{label:`正在读取插件开关`});if(!r.on)return(0,j.jsx)(w,{children:n(`pmRequirements`)});if(h===null)return(0,j.jsx)(be,{label:`正在连接项目管理服务`});if(!h)return(0,j.jsx)(w,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(m.projects.length===0&&!_&&!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}),` 条需求`,Z.length===Q?``:` · 筛选出 ${Z.length} 条`]}),(0,j.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:Je,value:E,onChange:e=>{N(e),I(`all`),B(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:Ye,value:F,onChange:e=>{I(e),B(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...ze],value:R,onChange:e=>{He(e),B(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:z,onChange:e=>{Ue(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,j.jsxs)(`button`,{type:`button`,disabled:W,onClick:()=>U(Be(P===`all`?``:P)),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)(Ce,{ariaLabel:`按状态筛选需求`,options:at,value:L,onChange:e=>{Ve(e),B(1)}})}),v?(0,j.jsx)(ye,{message:v,onClose:()=>b(``)}):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:Ke,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:X.tableStyle,children:[(0,j.jsx)(`colgroup`,{children:Y.map(e=>(0,j.jsx)(`col`,{style:X.widthOf(e.key)?{width:X.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:`${re} relative`,children:[`ID`,(0,j.jsx)(p,{...X.resizeProps(`id`)})]}),(0,j.jsxs)(`th`,{className:d,style:{"--tw-sticky-left":`${qe}px`},children:[`需求描述`,(0,j.jsx)(p,{...X.resizeProps(`title`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,j.jsx)(p,{...X.resizeProps(`priority`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,j.jsx)(p,{...X.resizeProps(`status`)})]}),t?null:(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,j.jsx)(p,{...X.resizeProps(`project`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,j.jsx)(p,{...X.resizeProps(`iteration`)})]}),(0,j.jsx)(`th`,{"aria-hidden":`true`}),(0,j.jsx)(`th`,{className:c,children:`操作`})]})}),(0,j.jsxs)(`tbody`,{children:[_&&!m.requirements.length?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:Y.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:Y.length,children:Q?(0,j.jsx)(Se,{children:`没有符合筛选条件的需求。`}):(0,j.jsx)(we,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,j.jsxs)(`button`,{type:`button`,onClick:()=>U(Be(P===`all`?``:P)),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:`${f} font-mono text-xs text-stone-400`,children:e.autoId}),(0,j.jsx)(`td`,{className:u,style:{"--tw-sticky-left":`${qe}px`},children:(0,j.jsx)(pe,{text:e.title,onClick:()=>U({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)(ge,{tone:Te[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)(o,{unstyled:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:W,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)(ge,{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:he(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:Xe(e.projectId)})}),(0,j.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:Ze(e.iterationId)}),(0,j.jsx)(`td`,{"aria-hidden":`true`}),(0,j.jsx)(`td`,{className:l,children:(0,j.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:W,onClick:()=>q(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))]})]})}),Z.length>0?(0,j.jsx)(ee,{page:$,totalPages:Qe,pageSize:V,busy:W,onPage:B,onPageSize:e=>{Ge(e),B(1)}}):null]}),(0,j.jsx)(ve,{open:H!==null,title:H?.id?`编辑需求`:`新建需求`,busy:W,submitLabel:H?.id?`保存`:`创建`,onClose:()=>nt(),onSubmit:()=>void tt(),children:H?(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:m.projects.map(e=>({value:e.id,label:e.name})),value:H.projectId,onChange:e=>{let t=m.iterations.some(t=>t.id===H.iterationId&&t.projectId===e);U({...H,projectId:e,iterationId:t?H.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:H.iterationId,onChange:e=>U({...H,iterationId:e}),disabled:et.length===0})}),(0,j.jsx)(T,{label:`需求描述`,required:!0,children:(0,j.jsx)(`textarea`,{autoFocus:!0,value:H.title,onChange:e=>U({...H,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:_e})}),(0,j.jsx)(T,{label:`优先级`,children:(0,j.jsx)(k,{ariaLabel:`优先级`,options:ze,value:H.priority,onChange:e=>U({...H,priority:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:Te[e.value]})})}),(0,j.jsx)(T,{label:`需求状态`,children:(0,j.jsx)(k,{ariaLabel:`需求状态`,options:M,value:H.status,onChange:e=>U({...H,status:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:C[e.value]})})}),(0,j.jsx)(T,{label:`附件`,children:(0,j.jsx)(Ee,{value:H.attachment,onChange:e=>U(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:H.id??``,seenUrls:J,onError:b,onPersisted:()=>void x(!0)})}),(0,j.jsx)(T,{label:`备注`,children:(0,j.jsx)(`textarea`,{value:H.description,onChange:e=>U({...H,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:_e})})]}):null}),(0,j.jsx)(i,{open:K!==null,title:`删除需求`,message:`确定删除「${K?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>q(null),onConfirm:()=>void it()})]})}export{N as t};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.C0NrHGZv.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.D5qXeML0.js";import{n as a,t as ee}from"./DocsPager.BS20yicJ.js";import{t as o}from"./SelectDropdown.TgxIOKMD.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{c,d as te,i as l,l as ne,n as u,o as d,r as f,s as re,t as p}from"./ColumnResize.CkE59sGq.js";import{A as m,D as h,F as ie,P as ae,R as g,b as _,d as v,f as oe,g as se,h as ce,j as y,l as b,m as le,u as ue,w as de,z as x}from"./pm.BXmOiFfW.js";import{A as fe,C as pe,D as me,E as he,O as S,S as ge,T as C,_ as w,a as _e,c as ve,d as ye,f as T,g as be,h as E,k as xe,l as Se,m as D,p as Ce,s as O,u as we,w as Te,y as k}from"./PmShared.BJpoEYvk.js";var A=e(t(),1),j=r();function Ee({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=y(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 y(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 x(Array.from(n));t(m([...y(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=_(e.clipboardData);t.length&&(e.preventDefault(),f(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[f]);async function re(e){let i=m(o.filter(t=>t.url!==e));if(r)try{await g(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:[h(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})}),h(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 re(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 De=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],Oe={key:`project`,width:140,min:100},ke=[{key:`iteration`,width:120,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ae=20,je=`tw.pm-requirements.page-size.v1`,Me=[`all`,...v],Ne=[`all`,...b],Pe=`pm.requirements.project`,Fe=`pm.requirements.iteration`,Ie=`pm.requirements.status`,Le=`pm.requirements.priority`,Re=`pm.requirements.keyword`,ze=b.map(e=>({value:e,label:ue[e]})),M=v.map(e=>({value:e,label:oe[e]}));function Be(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function N({scopeProjectId:e=``}={}){let t=!!e,r=xe(`pmRequirements`),{store:m,live:h,loading:_,error:v,setError:b,reload:x}=fe(),[E,N]=S(Pe,`all`),P=e||E,[F,I]=S(Fe,`all`),[L,Ve]=me(Ie,Me,`all`),[R,He]=me(Le,Ne,`all`),[z,Ue]=S(Re),[We,B]=(0,A.useState)(1),[V,Ge]=a(Ae,je),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(!1),[K,q]=(0,A.useState)(null),J=(0,A.useRef)(new Set),Y=(0,A.useMemo)(()=>t?[...De,...ke]:[...De,Oe,...ke],[t]),X=ne(t?`pm.requirements.cols.scoped.v1`:`pm.requirements.cols.v1`,Y),Ke=te(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),qe=X.widthOf(`id`)??88,Je=(0,A.useMemo)(()=>[{value:`all`,label:`全部项目`},...m.projects.map(e=>({value:e.id,label:e.name}))],[m.projects]),Ye=(0,A.useMemo)(()=>[{value:`all`,label:`全部迭代`},...ae(m.iterations.filter(e=>P===`all`||e.projectId===P)).map(e=>({value:e.id,label:e.name}))],[m.iterations,P]),Xe=(0,A.useMemo)(()=>{let e=new Map(m.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[m.projects]),Ze=(0,A.useMemo)(()=>{let e=new Map(m.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[m.iterations]),Z=(0,A.useMemo)(()=>ie(de(m.requirements,{projectId:P,iterationId:F,status:L,priority:R,keyword:z})),[m.requirements,P,F,L,R,z]),Q=t?m.requirements.filter(e=>e.projectId===P).length:m.requirements.length,Qe=Math.max(1,Math.ceil(Z.length/V)),$=Math.min(We,Qe),$e=Z.slice(($-1)*V,$*V);(0,A.useEffect)(()=>{t||h===!0&&E!==`all`&&!m.projects.some(e=>e.id===E)&&N(`all`)},[h,m.projects,E,N,t]),(0,A.useEffect)(()=>{h===!0&&F!==`all`&&!m.iterations.some(e=>e.id===F&&(P===`all`||e.projectId===P))&&I(`all`)},[h,m.iterations,P,F,I]);let et=H?ae(m.iterations.filter(e=>e.projectId===H.projectId)):[];async function tt(){if(!H)return;if(!H.projectId){b(`请先选择所属项目`);return}let e=H.title.trim();if(!e)b(`需求描述不能为空`);else{G(!0);try{let t={projectId:H.projectId,iterationId:H.iterationId,title:e,priority:H.priority,status:H.status,description:H.description,acceptanceCriteria:H.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:H.githubIssue,attachment:H.attachment};H.id?await g(`requirements`,H.id,t):await ce(`requirements`,[t]);let n=!!H.id;U(null),J.current.clear(),b(``),await x(!0),s(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);b(t),s(`保存需求失败:${t}`,`error`)}finally{G(!1)}}}function nt(){let e=[...J.current,...y(H?.attachment??``).map(e=>e.url)];J.current.clear(),U(null),e.length&&le(e)}async function rt(e,t){G(!0);try{await g(`requirements`,e.id,{status:t}),await x(!0),s(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);b(t),s(`更新状态失败:${t}`,`error`)}finally{G(!1)}}async function it(){let e=K;if(e){q(null),G(!0);try{await se(`requirements`,[e.id]),await x(!0),s(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);b(t),s(`删除需求失败:${t}`,`error`)}finally{G(!1)}}}if(!r.ready)return(0,j.jsx)(be,{label:`正在读取插件开关`});if(!r.on)return(0,j.jsx)(w,{children:n(`pmRequirements`)});if(h===null)return(0,j.jsx)(be,{label:`正在连接项目管理服务`});if(!h)return(0,j.jsx)(w,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(m.projects.length===0&&!_&&!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}),` 条需求`,Z.length===Q?``:` · 筛选出 ${Z.length} 条`]}),(0,j.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:Je,value:E,onChange:e=>{N(e),I(`all`),B(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:Ye,value:F,onChange:e=>{I(e),B(1)}}),(0,j.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...ze],value:R,onChange:e=>{He(e),B(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:z,onChange:e=>{Ue(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,j.jsxs)(`button`,{type:`button`,disabled:W,onClick:()=>U(Be(P===`all`?``:P)),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)(Ce,{ariaLabel:`按状态筛选需求`,options:at,value:L,onChange:e=>{Ve(e),B(1)}})}),v?(0,j.jsx)(ye,{message:v,onClose:()=>b(``)}):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:Ke,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:X.tableStyle,children:[(0,j.jsx)(`colgroup`,{children:Y.map(e=>(0,j.jsx)(`col`,{style:X.widthOf(e.key)?{width:X.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:`${re} relative`,children:[`ID`,(0,j.jsx)(p,{...X.resizeProps(`id`)})]}),(0,j.jsxs)(`th`,{className:d,style:{"--tw-sticky-left":`${qe}px`},children:[`需求描述`,(0,j.jsx)(p,{...X.resizeProps(`title`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,j.jsx)(p,{...X.resizeProps(`priority`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,j.jsx)(p,{...X.resizeProps(`status`)})]}),t?null:(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,j.jsx)(p,{...X.resizeProps(`project`)})]}),(0,j.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,j.jsx)(p,{...X.resizeProps(`iteration`)})]}),(0,j.jsx)(`th`,{"aria-hidden":`true`}),(0,j.jsx)(`th`,{className:c,children:`操作`})]})}),(0,j.jsxs)(`tbody`,{children:[_&&!m.requirements.length?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:Y.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:Y.length,children:Q?(0,j.jsx)(Se,{children:`没有符合筛选条件的需求。`}):(0,j.jsx)(we,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,j.jsxs)(`button`,{type:`button`,onClick:()=>U(Be(P===`all`?``:P)),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:`${f} font-mono text-xs text-stone-400`,children:e.autoId}),(0,j.jsx)(`td`,{className:u,style:{"--tw-sticky-left":`${qe}px`},children:(0,j.jsx)(pe,{text:e.title,onClick:()=>U({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)(ge,{tone:Te[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)(o,{unstyled:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:W,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)(ge,{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:he(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:Xe(e.projectId)})}),(0,j.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:Ze(e.iterationId)}),(0,j.jsx)(`td`,{"aria-hidden":`true`}),(0,j.jsx)(`td`,{className:l,children:(0,j.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:W,onClick:()=>q(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))]})]})}),Z.length>0?(0,j.jsx)(ee,{page:$,totalPages:Qe,pageSize:V,busy:W,onPage:B,onPageSize:e=>{Ge(e),B(1)}}):null]}),(0,j.jsx)(ve,{open:H!==null,title:H?.id?`编辑需求`:`新建需求`,busy:W,submitLabel:H?.id?`保存`:`创建`,onClose:()=>nt(),onSubmit:()=>void tt(),children:H?(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:m.projects.map(e=>({value:e.id,label:e.name})),value:H.projectId,onChange:e=>{let t=m.iterations.some(t=>t.id===H.iterationId&&t.projectId===e);U({...H,projectId:e,iterationId:t?H.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:H.iterationId,onChange:e=>U({...H,iterationId:e}),disabled:et.length===0})}),(0,j.jsx)(T,{label:`需求描述`,required:!0,children:(0,j.jsx)(`textarea`,{autoFocus:!0,value:H.title,onChange:e=>U({...H,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:_e})}),(0,j.jsx)(T,{label:`优先级`,children:(0,j.jsx)(k,{ariaLabel:`优先级`,options:ze,value:H.priority,onChange:e=>U({...H,priority:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:Te[e.value]})})}),(0,j.jsx)(T,{label:`需求状态`,children:(0,j.jsx)(k,{ariaLabel:`需求状态`,options:M,value:H.status,onChange:e=>U({...H,status:e}),renderOptionPrefix:e=>(0,j.jsx)(O,{tone:C[e.value]})})}),(0,j.jsx)(T,{label:`附件`,children:(0,j.jsx)(Ee,{value:H.attachment,onChange:e=>U(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:H.id??``,seenUrls:J,onError:b,onPersisted:()=>void x(!0)})}),(0,j.jsx)(T,{label:`备注`,children:(0,j.jsx)(`textarea`,{value:H.description,onChange:e=>U({...H,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:_e})})]}):null}),(0,j.jsx)(i,{open:K!==null,title:`删除需求`,message:`确定删除「${K?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>q(null),onConfirm:()=>void it()})]})}export{N as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PmRequirementsBoard.DET5YIVX.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bg6v8zQQ.js";import{i as r,o as i}from"./plugins.CVnHeKyf.js";import{n as a,o,r as s,s as c}from"./view-prefs.SdItxolG.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.pvo2Xc8R.js";import{t as f}from"./SelectDropdown.apWlFGbA.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";import{t as g}from"./SlideOverDrawer.C1IVOc_8.js";var _=e(t(),1),v=e(l(),1),y=u(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>a(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),o(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>s(e)||t);return[n,(0,_.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function C(e){let[t,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>r(e));return(0,_.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(p),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),b))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function E({children:e}){let t=T(!0);return(0,y.jsx)(w.Provider,{value:t,children:e})}function D(){let e=(0,_.useContext)(w),t=T(e===null);return e??t}var O={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},k={planning:`blue`,in_progress:`amber`,archived:`gray`},A={planning:`blue`,in_progress:`amber`,done:`green`},j={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},M={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},N={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},P={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},F={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function I({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:F[e]}})}function ee({tone:e,children:t}){return(0,y.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${O[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,y.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,y.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,y.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,y.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,y.jsx)(R,{name:e,size:30})}),(0,y.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,y.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(f,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,y.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,y.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,y.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:e})}function Y({children:e}){return(0,y.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,y.jsx)(g,{open:e,onClose:i,title:t,footer:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,y.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,y.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,y.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,y.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,y.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var Q=180;function $({file:e,onClose:t}){let n=!!e,[r,i]=(0,_.useState)(n),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e){c(e),i(!0);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o(!0))});return()=>window.cancelAnimationFrame(t)}o(!1);let t=window.setTimeout(()=>{i(!1),c(null)},Q);return()=>window.clearTimeout(t)},[e]),(0,_.useEffect)(()=>{if(!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),!r||!s?null:(0,v.createPortal)((0,y.jsxs)(`div`,{"data-pm-image-preview":``,className:`fixed inset-0 z-[70] flex items-center justify-center p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":s.name,onClick:t,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-stone-900/70 transition-opacity duration-[180ms] ease-out ${a?`opacity-100`:`opacity-0`}`,"aria-hidden":`true`}),(0,y.jsx)(`img`,{src:s.url,alt:s.name,className:`relative max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl transition-[opacity,scale] duration-[180ms] ease-out ${a?`scale-100 opacity-100`:`scale-95 opacity-0`}`,onClick:e=>e.stopPropagation()}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-opacity duration-[180ms] ease-out hover:bg-white hover:text-stone-900 ${a?`opacity-100`:`opacity-0`}`,children:`✕`})]}),document.body)}function te({message:e,onClose:t}){return(0,y.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,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,y.jsx)(`button`,{type:`button`,onClick:t,"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:`✕`})]})}function ne({text:e,onClick:t}){let n=(0,y.jsx)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});return t?(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{D as A,ne as C,x as D,H as E,S as O,ee as S,M as T,J as _,W as a,E as b,X as c,te as d,Z as f,q as g,$ as h,U as i,C as k,Y as l,R as m,P as n,k as o,B as p,A as r,I as s,N as t,V as u,K as v,j as w,z as x,G as y};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i}from"./plugins.C0NrHGZv.js";import{n as a,o,r as s,s as c}from"./view-prefs.8MPl3A7e.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.pvo2Xc8R.js";import{t as f}from"./SelectDropdown.TgxIOKMD.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";import{t as g}from"./SlideOverDrawer.C1IVOc_8.js";var _=e(t(),1),v=e(l(),1),y=u(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>a(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),o(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>s(e)||t);return[n,(0,_.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function C(e){let[t,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>r(e));return(0,_.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(p),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),b))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function E({children:e}){let t=T(!0);return(0,y.jsx)(w.Provider,{value:t,children:e})}function D(){let e=(0,_.useContext)(w),t=T(e===null);return e??t}var O={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},k={planning:`blue`,in_progress:`amber`,archived:`gray`},A={planning:`blue`,in_progress:`amber`,done:`green`},j={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},M={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},N={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},P={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},F={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function I({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:F[e]}})}function ee({tone:e,children:t}){return(0,y.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${O[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,y.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,y.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,y.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,y.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,y.jsx)(R,{name:e,size:30})}),(0,y.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,y.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(f,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,y.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,y.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,y.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:e})}function Y({children:e}){return(0,y.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,y.jsx)(g,{open:e,onClose:i,title:t,footer:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,y.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,y.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,y.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,y.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,y.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var Q=180;function $({file:e,onClose:t}){let n=!!e,[r,i]=(0,_.useState)(n),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e){c(e),i(!0);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o(!0))});return()=>window.cancelAnimationFrame(t)}o(!1);let t=window.setTimeout(()=>{i(!1),c(null)},Q);return()=>window.clearTimeout(t)},[e]),(0,_.useEffect)(()=>{if(!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),!r||!s?null:(0,v.createPortal)((0,y.jsxs)(`div`,{"data-pm-image-preview":``,className:`fixed inset-0 z-[70] flex items-center justify-center p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":s.name,onClick:t,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-stone-900/70 transition-opacity duration-[180ms] ease-out ${a?`opacity-100`:`opacity-0`}`,"aria-hidden":`true`}),(0,y.jsx)(`img`,{src:s.url,alt:s.name,className:`relative max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl transition-[opacity,scale] duration-[180ms] ease-out ${a?`scale-100 opacity-100`:`scale-95 opacity-0`}`,onClick:e=>e.stopPropagation()}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-opacity duration-[180ms] ease-out hover:bg-white hover:text-stone-900 ${a?`opacity-100`:`opacity-0`}`,children:`✕`})]}),document.body)}function te({message:e,onClose:t}){return(0,y.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,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,y.jsx)(`button`,{type:`button`,onClick:t,"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:`✕`})]})}function ne({text:e,onClick:t}){let n=(0,y.jsx)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});return t?(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{D as A,ne as C,x as D,H as E,S as O,ee as S,M as T,J as _,W as a,E as b,X as c,te as d,Z as f,q as g,$ as h,U as i,C as k,Y as l,R as m,P as n,k as o,B as p,A as r,I as s,N as t,V as u,K as v,j as w,z as x,G as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.Bg6v8zQQ.js";import{a as i,i as a,n as o,o as s,s as c}from"./plugins.CVnHeKyf.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{showToast as u}from"./Toast.BO2NFckG.js";import{i as te}from"./case-types.CJ5PHz59.js";import{a as ne,at as re,c as ie}from"./req-analysis.D9EOpleR.js";import{c as d,d as f,h as ae,n as p,p as oe,r as se,u as ce,v as le}from"./project-docs.DAw9bzgk.js";import{n as ue}from"./doc-roots.DAJP9Svr.js";import{a as m,c as h,d as de,i as g,l as _,o as v,s as y,u as b}from"./prompts-meta.Dnmq-SnF.js";import{i as fe,n as pe,r as me,t as he}from"./DocsFileBrowser.D2Cff2LP.js";import{d as ge,t as _e}from"./open-docs-in-session.DQ2_5fkC.js";import{F as ve,I as ye,i as be,r as xe}from"./case-review.s1w_mD4l.js";import{t as x}from"./NamePromptDialog.Csfnh5eM.js";import{m as S}from"./PmShared.BuhrL7Gb.js";import{r as Se}from"./report-prompt.CAfZ6RIo.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{f as Te,s as Ee,t as De,y as Oe}from"./story-review.COs6QaUe.js";var C=e(t(),1),w=`tw.prompts.mounted.v1`;function ke(){try{let e=sessionStorage.getItem(r(w));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Ae(e){try{sessionStorage.setItem(r(w),JSON.stringify(e))}catch{}}var T=l(),je=10;async function E(e=`.`){let{entries:t}=await d(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await E(e.path));return n}function Me({path:e,enabled:t,mounted:n}){let r=b(e,n);if(!r)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,s=v(e,n);return(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),s&&a?(0,T.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function D(){let e=me(`prompts`),[t,r]=(0,C.useState)(!1),[l,d]=(0,C.useState)(!0),[v,w]=(0,C.useState)(e?!0:null),[D,Ne]=(0,C.useState)(()=>e??[]),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)({}),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(()=>i()),[R,Pe]=(0,C.useState)(()=>ke()),[z,B]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(``),G=pe(D,je,`prompts`),K=(0,C.useRef)(!1),q=(0,C.useRef)(!1),Fe=(0,C.useRef)(!1),J=(0,C.useRef)(!1),Ie=(0,C.useRef)(!1),Y=(0,C.useCallback)(async()=>{k(null);try{let e=await E(`.`);Ne(e),fe(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e))}},[]);(0,C.useEffect)(()=>{if(!v||I.reqAnalysis!==!0||K.current)return;let e=new Set(D.map(e=>e.name));e.has(`需求分析提示词.md`)&&e.has(`原文结构提示词.md`)||(K.current=!0,re(!0).then(()=>Y()).catch(()=>void 0))},[v,I.reqAnalysis,D,Y]),(0,C.useEffect)(()=>{v&&I.storyReview===!0&&!q.current&&(D.some(e=>e.name===`用户故事审查提示词.md`)||(q.current=!0,Ee(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.storyReview,D,Y]),(0,C.useEffect)(()=>{v&&I.testPoints===!0&&!Fe.current&&(D.some(e=>e.name===`测试点生成提示词.md`)||(Fe.current=!0,Oe(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.testPoints,D,Y]),(0,C.useEffect)(()=>{v&&I.caseReview===!0&&!J.current&&(D.some(e=>e.name===`用例质量评审提示词.md`)||(J.current=!0,ye(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.caseReview,D,Y]),(0,C.useEffect)(()=>{v&&I.caseBlindspot===!0&&!Ie.current&&(D.some(e=>e.name===`场景遗漏补全提示词.md`)||(Ie.current=!0,ve(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.caseBlindspot,D,Y]),(0,C.useEffect)(()=>{let e=s(e=>{d(!!e.prompts),L(e)});return n().then(()=>{d(a(`prompts`)),L(i()),r(!0)}),e},[]),(0,C.useEffect)(()=>{t&&l&&(async()=>{await se(`prompts`)?(await ge().catch(()=>null),await Y(),w(!0)):w(!1)})()},[t,l,Y]);let X=(0,C.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=t?await Se().catch(()=>null):null;Pe(r=>{let i={};if(e)for(let t of e)i[h(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[h(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(I.reqAnalysis&&(i[h(ne)]=`reqAnalysis`,i[h(ie)]=`reqAnalysis`),I.storyReview&&(i[h(De)]=`storyReview`),I.testPoints&&(i[h(Te)]=`testPoints`),I.caseReview&&(i[h(be)]=`caseReview`),I.caseBlindspot&&(i[h(xe)]=`caseBlindspot`),I.caseGen)for(let e of te()){let t=(e.promptPath??``).trim();t&&(i[h(t)]=`caseGen`)}return Ae(i),i})},[I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen]);(0,C.useEffect)(()=>{if(!t||!l)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,l,I.uiAuto,I.reports,I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen,X]);let Z=(0,C.useMemo)(()=>Object.keys(M).filter(e=>M[e]),[M]),Q=(0,C.useCallback)(e=>{let t=b(e,R);return!t||t===`system`||de(e)?``:I[t]===!0?t:``},[R,I]);async function Le(e){j(!0),k(null);try{await ce(`prompts`,e.path)}catch(e){k(e instanceof Error?e.message:String(e))}finally{j(!1)}}async function Re(e){j(!0),k(null);try{await _e(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e)),j(!1)}}function ze(e){if(y(e.path)){k(`默认提示词不可删除`);return}if(g(e.path,I)){k(_(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else F({kind:`one`,entry:e})}function Be(e){if(y(e.path)){k(`默认提示词不可改名`);return}if(g(e.path,I)){k(_(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else B(e),W(``)}function Ve(e){H(e),W(``)}async function He(){let e=P;if(e){F(null),j(!0),k(null);try{if(e.kind===`one`)await p(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)y(n)||g(n,I)||Q(n)?t+=1:await p(`prompts`,n);t&&k(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),N({})}await Y(),u(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),u(`删除失败:${t}`,`error`)}finally{j(!1)}}}function Ue(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:k(c(`promptGen`))}let $=(0,C.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=D.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[D]);async function We(e){let t=z;if(!t)return;let n=e.trim();if(!n||n===t.name){B(null),W(``);return}let r=$(f(t.path),n,t.path);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{await ae(`prompts`,t.path,n),B(null),await Y(),u(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),u(`重命名失败:${t}`,`error`)}finally{j(!1)}}}async function Ge(e){let t=V;if(!t)return;let n=e.trim();if(!n)return;let r=$(f(t.path),n);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{let{content:e}=await oe(`prompts`,t.path);await le(`prompts`,f(t.path)===`.`?n:`${f(t.path)}/${n}`,e),H(null),await Y(),u(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),u(`复制失败:${t}`,`error`)}finally{j(!1)}}}let Ke=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${ue(`prompts`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?v===null?(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):v?(0,T.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,T.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[G.query.trim()?(0,T.jsxs)(T.Fragment,{children:[`匹配 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.filtered.length}),` 个`,(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),Z.length>0?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,T.jsx)(`button`,{type:`button`,disabled:A||Z.length===0,onClick:()=>F({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:Ue,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),O?(0,T.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:O}):null,(0,T.jsx)(he,{resizeKey:`docs:prompts:cols:v1`,files:D,filtered:G.filtered,pageFiles:G.pageFiles,query:G.query,onQuery:G.setQuery,sortBy:G.sortBy,onSortBy:G.setSortBy,page:G.page,totalPages:G.totalPages,pageSize:G.pageSize,onPage:G.setPage,onPageSize:G.setPageSize,busy:A,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!m(e.path,I)&&!Q(e.path),selected:M,onToggleRow:e=>N(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>N(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Le(e),extraColumn:{header:`关联插件`,render:e=>(0,T.jsx)(Me,{path:e.path,enabled:I,mounted:R})},renderNameAction:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`重命名 ${e.name}`,onClick:()=>Be(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(S,{name:`pencil`,size:12})}),(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`复制 ${e.name}`,onClick:()=>Ve(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(S,{name:`copy`,size:12})})]}),renderActions:e=>{let t=m(e.path,I)||!!Q(e.path);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>void Re(e),className:`inline-flex h-6 items-center whitespace-nowrap rounded bg-[#4176e6] px-2 text-xs text-white hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,T.jsx)(`button`,{type:`button`,disabled:A||t,"aria-label":`删除 ${e.name}`,onClick:()=>ze(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,T.jsx)(S,{name:`trash`,size:12})})]})}}),(0,T.jsx)(x,{open:z!=null,title:`重命名提示词`,label:`文件名称`,initialValue:z?.name??``,lockExtension:!0,confirmLabel:`保存`,error:U,onClose:()=>{B(null),W(``)},onConfirm:e=>void We(e)}),(0,T.jsx)(x,{open:V!=null,title:`复制提示词`,label:`新文件名称`,initialValue:V?V.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:U,onClose:()=>{H(null),W(``)},onConfirm:e=>void Ge(e)}),(0,T.jsx)(ee,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除提示词`,message:Ke,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void He()})]}):(0,T.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,T.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:c(`prompts`)}):(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{D as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.C4rpn1Ix.js";import{a as i,i as a,n as o,o as s,s as c}from"./plugins.C0NrHGZv.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{showToast as u}from"./Toast.BO2NFckG.js";import{i as te}from"./case-types.CprZTsyX.js";import{a as ne,at as re,c as ie}from"./req-analysis.CjhgP3jI.js";import{c as d,d as f,h as ae,n as p,p as oe,r as se,u as ce,v as le}from"./project-docs.DAw9bzgk.js";import{n as ue}from"./doc-roots.DAJP9Svr.js";import{a as m,c as h,d as de,i as g,l as _,o as v,s as y,u as b}from"./prompts-meta.Dnmq-SnF.js";import{i as fe,n as pe,r as me,t as he}from"./DocsFileBrowser.9WTBumS5.js";import{d as ge,t as _e}from"./open-docs-in-session.BdihMTEh.js";import{F as ve,I as ye,i as be,r as xe}from"./case-review.s1w_mD4l.js";import{t as x}from"./NamePromptDialog.Csfnh5eM.js";import{m as S}from"./PmShared.BJpoEYvk.js";import{r as Se}from"./report-prompt.CAfZ6RIo.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{f as Te,s as Ee,t as De,y as Oe}from"./story-review.BBfB1qYF.js";var C=e(t(),1),w=`tw.prompts.mounted.v1`;function ke(){try{let e=sessionStorage.getItem(r(w));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Ae(e){try{sessionStorage.setItem(r(w),JSON.stringify(e))}catch{}}var T=l(),je=10;async function E(e=`.`){let{entries:t}=await d(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await E(e.path));return n}function Me({path:e,enabled:t,mounted:n}){let r=b(e,n);if(!r)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,s=v(e,n);return(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),s&&a?(0,T.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function D(){let e=me(`prompts`),[t,r]=(0,C.useState)(!1),[l,d]=(0,C.useState)(!0),[v,w]=(0,C.useState)(e?!0:null),[D,Ne]=(0,C.useState)(()=>e??[]),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)({}),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(()=>i()),[R,Pe]=(0,C.useState)(()=>ke()),[z,B]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(``),G=pe(D,je,`prompts`),K=(0,C.useRef)(!1),q=(0,C.useRef)(!1),Fe=(0,C.useRef)(!1),J=(0,C.useRef)(!1),Ie=(0,C.useRef)(!1),Y=(0,C.useCallback)(async()=>{k(null);try{let e=await E(`.`);Ne(e),fe(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e))}},[]);(0,C.useEffect)(()=>{if(!v||I.reqAnalysis!==!0||K.current)return;let e=new Set(D.map(e=>e.name));e.has(`需求分析提示词.md`)&&e.has(`原文结构提示词.md`)||(K.current=!0,re(!0).then(()=>Y()).catch(()=>void 0))},[v,I.reqAnalysis,D,Y]),(0,C.useEffect)(()=>{v&&I.storyReview===!0&&!q.current&&(D.some(e=>e.name===`用户故事审查提示词.md`)||(q.current=!0,Ee(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.storyReview,D,Y]),(0,C.useEffect)(()=>{v&&I.testPoints===!0&&!Fe.current&&(D.some(e=>e.name===`测试点生成提示词.md`)||(Fe.current=!0,Oe(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.testPoints,D,Y]),(0,C.useEffect)(()=>{v&&I.caseReview===!0&&!J.current&&(D.some(e=>e.name===`用例质量评审提示词.md`)||(J.current=!0,ye(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.caseReview,D,Y]),(0,C.useEffect)(()=>{v&&I.caseBlindspot===!0&&!Ie.current&&(D.some(e=>e.name===`场景遗漏补全提示词.md`)||(Ie.current=!0,ve(!0).then(()=>Y()).catch(()=>void 0)))},[v,I.caseBlindspot,D,Y]),(0,C.useEffect)(()=>{let e=s(e=>{d(!!e.prompts),L(e)});return n().then(()=>{d(a(`prompts`)),L(i()),r(!0)}),e},[]),(0,C.useEffect)(()=>{t&&l&&(async()=>{await se(`prompts`)?(await ge().catch(()=>null),await Y(),w(!0)):w(!1)})()},[t,l,Y]);let X=(0,C.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=t?await Se().catch(()=>null):null;Pe(r=>{let i={};if(e)for(let t of e)i[h(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[h(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(I.reqAnalysis&&(i[h(ne)]=`reqAnalysis`,i[h(ie)]=`reqAnalysis`),I.storyReview&&(i[h(De)]=`storyReview`),I.testPoints&&(i[h(Te)]=`testPoints`),I.caseReview&&(i[h(be)]=`caseReview`),I.caseBlindspot&&(i[h(xe)]=`caseBlindspot`),I.caseGen)for(let e of te()){let t=(e.promptPath??``).trim();t&&(i[h(t)]=`caseGen`)}return Ae(i),i})},[I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen]);(0,C.useEffect)(()=>{if(!t||!l)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,l,I.uiAuto,I.reports,I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen,X]);let Z=(0,C.useMemo)(()=>Object.keys(M).filter(e=>M[e]),[M]),Q=(0,C.useCallback)(e=>{let t=b(e,R);return!t||t===`system`||de(e)?``:I[t]===!0?t:``},[R,I]);async function Le(e){j(!0),k(null);try{await ce(`prompts`,e.path)}catch(e){k(e instanceof Error?e.message:String(e))}finally{j(!1)}}async function Re(e){j(!0),k(null);try{await _e(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e)),j(!1)}}function ze(e){if(y(e.path)){k(`默认提示词不可删除`);return}if(g(e.path,I)){k(_(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else F({kind:`one`,entry:e})}function Be(e){if(y(e.path)){k(`默认提示词不可改名`);return}if(g(e.path,I)){k(_(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else B(e),W(``)}function Ve(e){H(e),W(``)}async function He(){let e=P;if(e){F(null),j(!0),k(null);try{if(e.kind===`one`)await p(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)y(n)||g(n,I)||Q(n)?t+=1:await p(`prompts`,n);t&&k(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),N({})}await Y(),u(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),u(`删除失败:${t}`,`error`)}finally{j(!1)}}}function Ue(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:k(c(`promptGen`))}let $=(0,C.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=D.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[D]);async function We(e){let t=z;if(!t)return;let n=e.trim();if(!n||n===t.name){B(null),W(``);return}let r=$(f(t.path),n,t.path);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{await ae(`prompts`,t.path,n),B(null),await Y(),u(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),u(`重命名失败:${t}`,`error`)}finally{j(!1)}}}async function Ge(e){let t=V;if(!t)return;let n=e.trim();if(!n)return;let r=$(f(t.path),n);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{let{content:e}=await oe(`prompts`,t.path);await le(`prompts`,f(t.path)===`.`?n:`${f(t.path)}/${n}`,e),H(null),await Y(),u(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),u(`复制失败:${t}`,`error`)}finally{j(!1)}}}let Ke=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${ue(`prompts`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?v===null?(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):v?(0,T.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,T.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[G.query.trim()?(0,T.jsxs)(T.Fragment,{children:[`匹配 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.filtered.length}),` 个`,(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),Z.length>0?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,T.jsx)(`button`,{type:`button`,disabled:A||Z.length===0,onClick:()=>F({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:Ue,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),O?(0,T.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:O}):null,(0,T.jsx)(he,{resizeKey:`docs:prompts:cols:v1`,files:D,filtered:G.filtered,pageFiles:G.pageFiles,query:G.query,onQuery:G.setQuery,sortBy:G.sortBy,onSortBy:G.setSortBy,page:G.page,totalPages:G.totalPages,pageSize:G.pageSize,onPage:G.setPage,onPageSize:G.setPageSize,busy:A,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!m(e.path,I)&&!Q(e.path),selected:M,onToggleRow:e=>N(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>N(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Le(e),extraColumn:{header:`关联插件`,render:e=>(0,T.jsx)(Me,{path:e.path,enabled:I,mounted:R})},renderNameAction:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`重命名 ${e.name}`,onClick:()=>Be(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(S,{name:`pencil`,size:12})}),(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`复制 ${e.name}`,onClick:()=>Ve(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(S,{name:`copy`,size:12})})]}),renderActions:e=>{let t=m(e.path,I)||!!Q(e.path);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>void Re(e),className:`inline-flex h-6 items-center whitespace-nowrap rounded bg-[#4176e6] px-2 text-xs text-white hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,T.jsx)(`button`,{type:`button`,disabled:A||t,"aria-label":`删除 ${e.name}`,onClick:()=>ze(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,T.jsx)(S,{name:`trash`,size:12})})]})}}),(0,T.jsx)(x,{open:z!=null,title:`重命名提示词`,label:`文件名称`,initialValue:z?.name??``,lockExtension:!0,confirmLabel:`保存`,error:U,onClose:()=>{B(null),W(``)},onConfirm:e=>void We(e)}),(0,T.jsx)(x,{open:V!=null,title:`复制提示词`,label:`新文件名称`,initialValue:V?V.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:U,onClose:()=>{H(null),W(``)},onConfirm:e=>void Ge(e)}),(0,T.jsx)(ee,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除提示词`,message:Ke,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void He()})]}):(0,T.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,T.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:c(`prompts`)}):(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{D as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.C4rpn1Ix.js";import{i,o as a,s as o}from"./plugins.C0NrHGZv.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{n as c,t as l}from"./DocsPager.BS20yicJ.js";import{t as u}from"./SelectDropdown.TgxIOKMD.js";import{showToast as d}from"./Toast.BO2NFckG.js";import{a as ee,c as te,i as ne,o as re,s as f,t as p}from"./report-prompt.CAfZ6RIo.js";var m=e(t(),1),h=`tw.reports.kind.v1`,g=Object.keys(p);function _(e){return typeof e==`string`&&g.includes(e)}function v(e=`day`){try{let t=localStorage.getItem(r(h));return _(t)?t:e}catch{return e}}function y(e){if(_(e))try{localStorage.setItem(r(h),e)}catch{}}var b=s(),x=[`day`,`week`,`month`],S=20,C=`tw.reports.page-size.v1`;function w(e){return e.replace(/\.(md|markdown|txt)$/i,``)}function T(e){return e.replace(/\.(md|markdown|txt|html?)$/i,``)}function E(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}/${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function ie(e){return!Number.isFinite(e)||e<=0?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var ae={day:`日`,week:`周`,month:`月`};function D(){let[e,t]=(0,m.useState)(!1),[r,s]=(0,m.useState)(!0),[h,g]=(0,m.useState)(()=>v()),_=(0,m.useRef)(h),[D,O]=(0,m.useState)([]),[k,A]=(0,m.useState)(``),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(``),[L,R]=(0,m.useState)([]),[z,B]=(0,m.useState)(``),[V,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)(1),[G,K]=c(S,C),q=(0,m.useCallback)(async(e,t)=>{M(!0),P(null);try{if(t?.ensure)try{await te(!0)}catch{}let n=await ee(e);O(n.items),A(n.dir)}catch(e){let t=e instanceof Error?e.message:String(e);P(t.includes(`404`)?`工作汇报需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`:t),O([])}finally{M(!1)}},[]);(0,m.useEffect)(()=>{let e=a(e=>s(!!e.reports));return n().then(()=>{s(i(`reports`)),t(!0)}),e},[]);let J=(0,m.useCallback)(async()=>{try{let e=await ne();R(e.items),B(e.promptFile),e.promptFile||d(`没有读到「提示词管理」里的工作汇报提示词,写汇报前请先在提示词管理里补一份。`,`error`)}catch(e){let t=e instanceof Error?e.message:String(e);d(`读取工作汇报提示词失败:${t}`,`error`)}},[]);(0,m.useEffect)(()=>{e&&r&&(async()=>{await q(_.current,{ensure:!0}),await J()})()},[e,r,q,J]);function oe(e){y(e),e!==h&&(g(e),W(1),O([]),q(e))}async function se(e){if(e&&e!==z){H(!0),P(null);try{let t=await f(e);B(t),R(e=>e.map(e=>({...e,selected:e.name===t})))}catch(e){let t=e instanceof Error?e.message:String(e);P(t),d(`切换提示词失败:${t}`,`error`)}finally{H(!1)}}}let ce=(0,m.useMemo)(()=>L.length?L.map(e=>({value:e.name,label:w(e.name)})):[{value:``,label:`暂无提示词`}],[L]),Y=(0,m.useMemo)(()=>[...D].sort((e,t)=>t.generatedAt-e.generatedAt),[D]),X=Math.max(1,Math.ceil(Y.length/G)),Z=Math.min(U,X),le=(0,m.useMemo)(()=>Y.slice((Z-1)*G,Z*G),[Y,Z,G]),ue=`/workbench/?report=${h}`;async function Q(e){if(!F){I(e.name),P(null);try{await re(e.kind,e.name)}catch(e){P(e instanceof Error?e.message:String(e))}finally{I(``)}}}if(!e)return(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex items-center justify-center min-h-[220px]`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!r)return(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:o(`reports`)});let $=Y[0];return(0,b.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,b.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:x.map(e=>(0,b.jsx)(`button`,{type:`button`,onClick:()=>oe(e),className:`h-8 rounded-md px-3 text-sm transition-colors ${h===e?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:p[e]},e))}),(0,b.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,b.jsx)(u,{className:`w-[172px]`,flat:!0,options:ce,value:z,onChange:e=>void se(e),disabled:!L.length||V,ariaLabel:`选择工作汇报提示词`,menuMinWidth:200}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>void(async()=>{await q(h),await J()})(),disabled:j,"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 disabled:opacity-40`,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)(`a`,{href:ue,className:`inline-flex h-9 items-center whitespace-nowrap rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9]`,children:`去工作台写汇报`})]})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-400`,children:[(0,b.jsxs)(`span`,{children:[p[h],` · 共 `,D.length,` 篇`]}),$?(0,b.jsxs)(`span`,{className:`tabular-nums`,children:[`最近生成 `,E($.generatedAt)]}):null,(0,b.jsx)(`span`,{className:`min-w-0 truncate`,children:k||`—`}),(0,b.jsx)(`span`,{className:`ml-auto hidden shrink-0 sm:inline`,children:`点击卡片用系统默认程序打开`})]})]}),N?(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:N}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>P(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`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/60 p-3 sm:p-4`,children:j&&D.length===0?(0,b.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center`,"aria-busy":`true`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):D.length===0?(0,b.jsxs)(`div`,{className:`flex min-h-[260px] flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-stone-300 px-6 py-10 text-center`,children:[(0,b.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-stone-100 text-stone-400`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,b.jsx)(`path`,{d:`M14 3v5h5`}),(0,b.jsx)(`path`,{d:`M9 13h6M9 17h4`})]})}),(0,b.jsxs)(`div`,{className:`text-sm font-medium text-stone-700`,children:[`还没有`,p[h]]}),(0,b.jsxs)(`p`,{className:`max-w-md text-xs leading-5 text-stone-400`,children:[`保存到 `,k||`工作汇报/${p[h]}`,` 后会自动出现在这里。`]})]}):(0,b.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,380px),1fr))] gap-2.5`,children:le.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>void Q(e),disabled:!!F,className:`group flex w-full items-center gap-3 rounded-xl border border-stone-200 bg-white px-3.5 py-3 text-left transition-colors hover:border-[#3370ff]/50 hover:bg-stone-50 disabled:cursor-progress disabled:opacity-60`,children:[(0,b.jsx)(`span`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-stone-100 text-[13px] font-semibold text-stone-600`,children:ae[e.kind]}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`span`,{className:`block truncate text-sm font-medium text-stone-800 transition-colors group-hover:text-[#3370ff]`,children:T(e.name)}),(0,b.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-stone-400 tabular-nums`,children:[E(e.generatedAt),` · `,ie(e.size)]})]}),(0,b.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-xs text-stone-400 transition-colors group-hover:text-[#3370ff]`,children:[F===e.name?`打开中…`:`打开`,(0,b.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,b.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})]})},e.name))})}),D.length>0?(0,b.jsx)(l,{page:Z,totalPages:X,pageSize:G,busy:j,onPage:W,onPageSize:e=>{K(e),W(1)}}):(0,b.jsx)(`div`,{className:`pb-2.5`})]})}export{D as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{s as r}from"./plugins.C0NrHGZv.js";import{a as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./view-prefs.8MPl3A7e.js";import{i as d,n as f,r as p,t as m}from"./dialog.DZHZCe_T.js";import{t as h}from"./jsx-runtime.DUg_B_vD.js";import{t as g}from"./ConfirmDialog.D5qXeML0.js";import{t as _}from"./OverflowHint.pvo2Xc8R.js";import{t as v}from"./SelectDropdown.TgxIOKMD.js";import{showToast as y}from"./Toast.BO2NFckG.js";import{m as ee,p as te,u as b}from"./settings.NTeTjmxg.js";import{$ as x,A as S,B as ne,C,D as re,E as ie,F as ae,G as oe,H as se,I as ce,J as le,K as ue,L as de,M as fe,N as pe,O as w,P as me,Q as he,R as ge,S as _e,T as ve,U as ye,V as be,W as xe,X as Se,Y as Ce,Z as we,_ as Te,a as Ee,at as De,b as Oe,c as ke,ct as T,d as Ae,et as je,f as Me,g as Ne,h as Pe,i as Fe,it as Ie,j as Le,k as Re,l as ze,m as Be,n as E,nt as Ve,o as He,ot as Ue,p as We,q as Ge,r as D,s as Ke,st as qe,t as Je,tt as Ye,u as Xe,w as Ze,x as Qe,y as $e}from"./req-analysis.CjhgP3jI.js";import{o as et}from"./project-docs.DAw9bzgk.js";import{s as tt}from"./llm.DyweO-KK.js";import{t as nt}from"./MultiSelectDropdown.y8JMbCxO.js";import{S as rt,_ as it,g as at,k as ot,m as st,u as ct}from"./PmShared.BJpoEYvk.js";import{_ as lt,a as ut,c as dt,d as ft,f as pt,g as mt,h as ht,i as gt,l as _t,m as vt,n as yt,o as bt,p as xt,r as St,s as Ct,u as wt,y as Tt}from"./story-review.BBfB1qYF.js";import{t as Et}from"./hydrate-cache.DI6vqM0o.js";var O=e(t(),1),Dt=`可用工具(只调用这些,不要自己编工具名):
|
|
2
2
|
- req_set_outline:在已播种的文档条目下提交查询/修改子点(带 parentId、kind),返回 id 供 sourceRefs 引用。不要另造文档里没有的条目标题。同一 parentId 下按能力点拆多条子点(可多个 query、多个 mutate),勿把多个能力点合并成一条。
|
|
3
3
|
- req_insert_outline_after:在指定已有子点下方插入新的查询/修改子点(用户补充需求内容时用);afterId 固定为消息里给出的锚点;插入后同父级子点 id 按序号顺延。
|
|
4
4
|
- req_update_outline_point:按 id 更新已有查询/修改子点的标题 / 类型 / 原文(id 不变);用户变更当前点内容时用。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bg6v8zQQ.js";import{i as r,o as i,s as a}from"./plugins.CVnHeKyf.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.D5qXeML0.js";import{n as c,t as ee}from"./DocsPager.CnXEnQqa.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as te,c as u,d as ne,g as re,h as ie,i as ae,l as oe,m as se,n as ce,p as le,r as ue,s as d,t as de,u as fe}from"./project-docs.DAw9bzgk.js";import{n as pe}from"./doc-roots.DAJP9Svr.js";import{t as f}from"./NamePromptDialog.Csfnh5eM.js";import{n as me,t as he}from"./docs-format.BlGh-XA_.js";import{t as ge}from"./useListAnim.BoerpmsB.js";var p=e(t(),1),m=o(),_e=5;function h({className:e=`w-4 h-4`,open:t=!1}){return(0,m.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,m.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,m.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function g({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,m.jsx)(`path`,{d:`m15 5 4 4`})]})}function _({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,m.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,m.jsx)(`path`,{d:`M10 11v6`}),(0,m.jsx)(`path`,{d:`M14 11v6`})]})}function v({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,m.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,m.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,m.jsx)(h,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,m.jsx)(v,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function y(){let[e,t]=(0,p.useState)(()=>r(`requirements`)),[o,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(null),[S,ve]=(0,p.useState)([]),[ye,be]=(0,p.useState)(0),[C,w]=(0,p.useState)(`.`),[T,E]=(0,p.useState)([]),[xe,D]=(0,p.useState)({}),[O,Se]=(0,p.useState)(!0),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[N,P]=(0,p.useState)(null),[Ce,F]=(0,p.useState)(!1),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[we,B]=(0,p.useState)(1),[V,Te]=c(_e),[Ee,H]=(0,p.useState)(null),U=(0,p.useRef)(null),{cls:De,play:W}=ge(),G=(0,p.useCallback)(async()=>{let e=await ae(`requirements`);ve(e.tree),be(e.totalFiles)},[]),K=(0,p.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([u(`requirements`,e),G()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,G]);(0,p.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),y(!0)}),e},[]),(0,p.useEffect)(()=>{o&&e&&(async()=>{if(!await ue(`requirements`))x(!1);else try{let[e]=await Promise.all([u(`requirements`,`.`),G()]);E(e.entries),w(e.path),x(!0)}catch(e){A(e instanceof Error?e.message:String(e)),x(!0)}})()},[o,e,G]);function Oe(){Se(e=>!e),D({})}async function q(e){W(),w(e),B(1),P(null),H(null),A(null);try{let t=await u(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function ke(e){F(!1),M(!0),A(null);try{await oe(`requirements`,C,e),await K(C),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`新建文件夹失败:${t}`,`error`)}finally{M(!1)}}async function Ae(e){if(e.type===`file`){M(!0),A(null);try{await fe(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function je(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await re(`requirements`,C,t);await K(C),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`上传失败:${t}`,`error`)}finally{M(!1),U.current&&(U.current.value=``)}}}function Me(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?de(t):0;L({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function J(e){L({name:e.name,path:e.path,isDir:!1})}function Y(e,t){z({...e,isDir:t})}async function Ne(){let e=I;if(e&&(L(null),!e.blocked)){M(!0),A(null);try{await ce(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ne(e.path):C;await K(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`删除失败:${t}`,`error`)}finally{M(!1)}}}async function Pe(e){let t=R;if(t&&(z(null),e!==t.name)){M(!0),A(null);try{let n=await ie(`requirements`,t.path,e);await K(se(C,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`重命名失败:${t}`,`error`)}finally{M(!1)}}}let Fe=(()=>{if(!I)return``;if(!I.isDir)return`删除文件「${I.name}」?将移入系统废纸篓,可随时找回。`;if(I.blocked){let e=[];return I.files&&e.push(`${I.files} 个文件`),I.dirs&&e.push(`${I.dirs} 个子文件夹`),`文件夹「${I.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${I.name}」?将移入系统废纸篓。`})();async function Ie(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){M(!0),A(null);try{let t=await le(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,m.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(`requirements`)});if(b===null)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!b)return(0,m.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:`需求文档库需要本地文档服务,当前未就绪。`});let X=T.filter(e=>e.type===`file`).slice().sort((e,t)=>(t.ctime??t.mtime??0)-(e.ctime??e.mtime??0)),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(we,Q),Le=X.slice(($-1)*V,$*V);function Re(e){W(),Te(e),B(1)}return(0,m.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,m.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>F(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,m.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),Oe()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,m.jsx)(h,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,ye,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:S.map(e=>(0,m.jsx)(v,{node:e,depth:0,activePath:C,expanded:xe,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,m.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,m.jsx)(`span`,{className:`text-stone-400`,children:pe(`requirements`)}),C===`.`?``:C]}),(0,m.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void je(e.target.files)}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>U.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),k?(0,m.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,m.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,m.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,m.jsx)(h,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Me({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,m.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,m.jsx)(`ul`,{className:`${De}space-y-1`,children:Le.map(e=>{let t=Ee===e.path;return(0,m.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{H(e.path),Ie(e)},onDoubleClick:t=>{t.preventDefault(),Ae(e)},children:[(0,m.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`div`,{className:`text-[11px] text-stone-400`,children:[he(e.size),e.ctime||e.mtime?` · ${me(e.ctime??e.mtime)}`:``]})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>J(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,m.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,m.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,m.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,m.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:j,onPage:e=>{W(),B(e)},onPageSize:Re}):null]}),(0,m.jsx)(f,{open:Ce,title:`新建文件夹`,onClose:()=>F(!1),onConfirm:e=>void ke(e)}),(0,m.jsx)(f,{open:R!=null,title:R?.isDir?`重命名文件夹`:`重命名文件`,label:R?.isDir?`文件夹名称`:`文件名称`,initialValue:R?.name??``,lockExtension:R!=null&&!R.isDir,confirmLabel:`保存`,onClose:()=>z(null),onConfirm:e=>void Pe(e)}),(0,m.jsx)(s,{open:I!=null,title:I?.blocked?`无法删除文件夹`:I?.isDir?`删除文件夹`:`删除需求文件`,message:Fe,confirmLabel:I?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!I?.blocked,hideCancel:!!I?.blocked,onClose:()=>L(null),onConfirm:()=>void Ne()})]})}export{y as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.D5qXeML0.js";import{n as c,t as ee}from"./DocsPager.BS20yicJ.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as te,c as u,d as ne,g as re,h as ie,i as ae,l as oe,m as se,n as ce,p as le,r as ue,s as d,t as de,u as fe}from"./project-docs.DAw9bzgk.js";import{n as pe}from"./doc-roots.DAJP9Svr.js";import{t as f}from"./NamePromptDialog.Csfnh5eM.js";import{n as me,t as he}from"./docs-format.BlGh-XA_.js";import{t as ge}from"./useListAnim.BoerpmsB.js";var p=e(t(),1),m=o(),_e=5;function h({className:e=`w-4 h-4`,open:t=!1}){return(0,m.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,m.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,m.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function g({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,m.jsx)(`path`,{d:`m15 5 4 4`})]})}function _({className:e=`w-3 h-3`}){return(0,m.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,m.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,m.jsx)(`path`,{d:`M10 11v6`}),(0,m.jsx)(`path`,{d:`M14 11v6`})]})}function v({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,m.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,m.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,m.jsx)(h,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,m.jsx)(v,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function y(){let[e,t]=(0,p.useState)(()=>r(`requirements`)),[o,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(null),[S,ve]=(0,p.useState)([]),[ye,be]=(0,p.useState)(0),[C,w]=(0,p.useState)(`.`),[T,E]=(0,p.useState)([]),[xe,D]=(0,p.useState)({}),[O,Se]=(0,p.useState)(!0),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[N,P]=(0,p.useState)(null),[Ce,F]=(0,p.useState)(!1),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[we,B]=(0,p.useState)(1),[V,Te]=c(_e),[Ee,H]=(0,p.useState)(null),U=(0,p.useRef)(null),{cls:De,play:W}=ge(),G=(0,p.useCallback)(async()=>{let e=await ae(`requirements`);ve(e.tree),be(e.totalFiles)},[]),K=(0,p.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([u(`requirements`,e),G()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,G]);(0,p.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),y(!0)}),e},[]),(0,p.useEffect)(()=>{o&&e&&(async()=>{if(!await ue(`requirements`))x(!1);else try{let[e]=await Promise.all([u(`requirements`,`.`),G()]);E(e.entries),w(e.path),x(!0)}catch(e){A(e instanceof Error?e.message:String(e)),x(!0)}})()},[o,e,G]);function Oe(){Se(e=>!e),D({})}async function q(e){W(),w(e),B(1),P(null),H(null),A(null);try{let t=await u(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function ke(e){F(!1),M(!0),A(null);try{await oe(`requirements`,C,e),await K(C),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`新建文件夹失败:${t}`,`error`)}finally{M(!1)}}async function Ae(e){if(e.type===`file`){M(!0),A(null);try{await fe(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function je(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await re(`requirements`,C,t);await K(C),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`上传失败:${t}`,`error`)}finally{M(!1),U.current&&(U.current.value=``)}}}function Me(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?de(t):0;L({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function J(e){L({name:e.name,path:e.path,isDir:!1})}function Y(e,t){z({...e,isDir:t})}async function Ne(){let e=I;if(e&&(L(null),!e.blocked)){M(!0),A(null);try{await ce(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ne(e.path):C;await K(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`删除失败:${t}`,`error`)}finally{M(!1)}}}async function Pe(e){let t=R;if(t&&(z(null),e!==t.name)){M(!0),A(null);try{let n=await ie(`requirements`,t.path,e);await K(se(C,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`重命名失败:${t}`,`error`)}finally{M(!1)}}}let Fe=(()=>{if(!I)return``;if(!I.isDir)return`删除文件「${I.name}」?将移入系统废纸篓,可随时找回。`;if(I.blocked){let e=[];return I.files&&e.push(`${I.files} 个文件`),I.dirs&&e.push(`${I.dirs} 个子文件夹`),`文件夹「${I.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${I.name}」?将移入系统废纸篓。`})();async function Ie(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){M(!0),A(null);try{let t=await le(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,m.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(`requirements`)});if(b===null)return(0,m.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!b)return(0,m.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:`需求文档库需要本地文档服务,当前未就绪。`});let X=T.filter(e=>e.type===`file`).slice().sort((e,t)=>(t.ctime??t.mtime??0)-(e.ctime??e.mtime??0)),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(we,Q),Le=X.slice(($-1)*V,$*V);function Re(e){W(),Te(e),B(1)}return(0,m.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,m.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>F(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,m.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,m.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),Oe()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,m.jsx)(h,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,m.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,ye,`)`]})]})}),(0,m.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,m.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:S.map(e=>(0,m.jsx)(v,{node:e,depth:0,activePath:C,expanded:xe,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,m.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,m.jsx)(`span`,{className:`text-stone-400`,children:pe(`requirements`)}),C===`.`?``:C]}),(0,m.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void je(e.target.files)}),(0,m.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>U.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),k?(0,m.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,m.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,m.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,m.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,m.jsx)(h,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,m.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,"data-hint":e.name,children:e.name})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Me({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,m.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,m.jsx)(`ul`,{className:`${De}space-y-1`,children:Le.map(e=>{let t=Ee===e.path;return(0,m.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{H(e.path),Ie(e)},onDoubleClick:t=>{t.preventDefault(),Ae(e)},children:[(0,m.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,m.jsxs)(`div`,{className:`text-[11px] text-stone-400`,children:[he(e.size),e.ctime||e.mtime?` · ${me(e.ctime??e.mtime)}`:``]})]}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,m.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,m.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>J(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,m.jsx)(_,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,m.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,m.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,m.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,m.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,m.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:j,onPage:e=>{W(),B(e)},onPageSize:Re}):null]}),(0,m.jsx)(f,{open:Ce,title:`新建文件夹`,onClose:()=>F(!1),onConfirm:e=>void ke(e)}),(0,m.jsx)(f,{open:R!=null,title:R?.isDir?`重命名文件夹`:`重命名文件`,label:R?.isDir?`文件夹名称`:`文件名称`,initialValue:R?.name??``,lockExtension:R!=null&&!R.isDir,confirmLabel:`保存`,onClose:()=>z(null),onConfirm:e=>void Pe(e)}),(0,m.jsx)(s,{open:I!=null,title:I?.blocked?`无法删除文件夹`:I?.isDir?`删除文件夹`:`删除需求文件`,message:Fe,confirmLabel:I?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!I?.blocked,hideCancel:!!I?.blocked,onClose:()=>L(null),onConfirm:()=>void Ne()})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./OverflowHint.pvo2Xc8R.js";import{t as i}from"./SelectDropdown.
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./OverflowHint.pvo2Xc8R.js";import{t as i}from"./SelectDropdown.TgxIOKMD.js";var a=e(t(),1),o=n();function s({options:e,value:t,onChange:n,placeholder:s=`搜索并选择…`,disabled:c=!1,allowEmpty:l=!0,emptyLabel:u=`不选择`}){let d=(0,a.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return l?[{value:``,label:u,muted:!0},...t]:t},[e,l,u]),f=t?d.find(e=>e.value===t):void 0;return(0,o.jsx)(i,{options:d,value:t,onChange:n,disabled:c,searchable:!0,searchPlaceholder:s,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>f?(0,o.jsx)(`span`,{className:`min-w-0 truncate ${t?`text-stone-400`:``}`,children:(0,o.jsx)(r,{text:f.label,className:`block truncate`})}):(0,o.jsx)(`span`,{className:`min-w-0 truncate text-stone-400`,children:s})})}export{s as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./listbox.DNxAJmEo.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.pvo2Xc8R.js";var c=e(t(),1),l=o();function u({value:e,onChange:t,placeholder:n,ariaLabel:r,onEnterCreate:i}){let a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=a.current;if(!e)return;e.focus();let t=requestAnimationFrame(()=>e.focus());return()=>cancelAnimationFrame(t)},[]),(0,l.jsx)(`div`,{className:`shrink-0 border-b border-stone-100 bg-white px-1.5 py-1.5`,children:(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`svg`,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,l.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,l.jsx)(`path`,{d:`m16.5 16.5 4 4`})]}),(0,l.jsx)(`input`,{ref:a,value:e,onChange:e=>t(e.target.value),onKeyDown:t=>{if(t.key===`Enter`&&i){let n=e.trim();if(n){t.preventDefault(),t.stopPropagation(),i(n);return}}[`Escape`,`Enter`,`ArrowDown`,`ArrowUp`].includes(t.key)||t.stopPropagation()},placeholder:n,"aria-label":r,spellCheck:!1,className:`h-8 w-full rounded-md border border-stone-200 bg-stone-50 pl-7 pr-2 text-sm text-stone-700 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})})}function d(){return(0,l.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function f({options:e,value:t,onChange:o,disabled:f=!1,className:p=``,compact:m=!1,ariaLabel:h,showCheck:g=!1,centerContent:_=!1,unstyled:v=!1,triggerClassName:y=``,hideChevron:b=!0,flat:x=!1,menuMinWidth:S,menuMatchTrigger:C=!0,renderTrigger:w,renderOptionPrefix:T,renderOptionAction:E,searchable:D=!1,searchPlaceholder:O=`搜索…`,onSearchCreate:k,triggerTitle:A,hideTriggerHint:j=!1,dimWhenOpen:M=!1}){let N=e.find(e=>e.value===t),[P,F]=(0,c.useState)(``),I=(0,c.useMemo)(()=>{let t=P.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,P]),L=(0,c.useMemo)(()=>{if(!k)return``;let t=P.trim();return!t||e.some(e=>e.label===t)?``:t},[k,e,P]),R=_?`justify-center`:`justify-start`,z=v?`flex w-full min-w-0 items-center overflow-hidden cursor-pointer outline-none disabled:cursor-not-allowed`:m?`tw-field-trigger w-full min-w-0 h-8 flex items-center gap-1.5 overflow-hidden rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:x?`tw-field-trigger w-full min-w-0 h-9 flex items-center gap-2 overflow-hidden rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`tw-field-trigger w-full min-w-0 h-9 flex items-center gap-2 overflow-hidden rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`;return(0,l.jsx)(i,{value:t,onChange:e=>{F(``),o(e)},disabled:f,children:({open:i})=>(0,l.jsxs)(`div`,{className:`relative ${v?`block w-full min-w-0`:m?`inline-block`:x?``:`mt-1`} ${p}`,children:[(0,l.jsx)(n,{"aria-label":h,onClick:()=>{D&&F(``)},className:`${z} ${R} ${y} ${M&&i?`text-stone-400`:``}`,children:w?w(N,{open:i}):(0,l.jsx)(s,{text:A??N?.label??t,className:`block min-w-0 flex-1 basis-0 truncate`,disabled:j})}),(0,l.jsxs)(a,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:C?{width:`max(12rem, var(--button-width, 12rem))`,minWidth:`max(12rem, var(--button-width, 12rem))`}:{width:`min(280px, max(12rem, var(--button-width, 12rem)))`,maxWidth:280,minWidth:S||150},className:`tw-select-menu tw-menu-anim z-[200] flex max-h-64 min-w-0 flex-col overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${C?`w-[max(12rem,var(--button-width,12rem))]`:`w-[min(280px,max(12rem,var(--button-width,12rem)))] max-w-[280px]`}`,children:[D?(0,l.jsx)(u,{value:P,onChange:F,placeholder:O,ariaLabel:h?`${h}搜索`:`搜索选项`,onEnterCreate:k?async t=>{let n=e.find(e=>e.label===t);return n?(F(``),o(n.value),!0):(await k(t),F(``),!0)}:void 0}):null,(0,l.jsxs)(`div`,{className:`min-h-0 w-full min-w-0 flex-1 space-y-1 overflow-x-hidden overflow-y-auto p-1 pb-2`,children:[L?(0,l.jsx)(`div`,{className:`min-w-0 px-3 py-1.5 text-xs text-stone-400`,children:(0,l.jsx)(s,{text:`回车新增「${L}」`,className:`block w-full truncate`})}):null,D&&I.length===0&&!L?(0,l.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):null,I.map(e=>(0,l.jsxs)(r,{value:e.value,disabled:e.disabled,className:`group flex w-full min-w-0 max-w-full select-none items-center gap-2 overflow-hidden rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${e.disabled?`cursor-not-allowed text-stone-300 data-[focus]:bg-transparent data-[selected]:bg-transparent data-[selected]:font-normal`:`cursor-pointer`} ${g?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${e.muted?`text-stone-400 data-[selected]:text-stone-500`:``} ${_&&!g&&!T?`justify-center px-2`:``}`,children:[g?(0,l.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,l.jsx)(d,{})}):T?(0,l.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:T(e)}):null,(0,l.jsxs)(`span`,{className:`min-w-0 flex-1 basis-0 overflow-hidden`,children:[(0,l.jsx)(s,{text:e.label,className:`block w-full truncate`}),e.secondary?(0,l.jsx)(s,{text:e.secondary,className:`mt-0.5 block w-full truncate font-mono text-[10px] font-normal leading-4 text-stone-400`}):null]}),E?(0,l.jsx)(`span`,{className:`ml-0.5 flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),e.preventDefault()},children:E(e)}):null]},e.value))]})]})]})})}export{f as t};
|