lantern-harness 0.1.44 → 0.2.2
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 +224 -0
- package/README.md +25 -8
- package/builtin/session/lh-fs.mjs +93 -4
- package/builtin/session/lh-nav-groups.mjs +3 -0
- package/builtin/session/mcp-client.mjs +7 -3
- package/builtin/session/session-runs.mjs +5 -1
- package/builtin/session/skill-validation.mjs +72 -0
- package/builtin/session/space-skills.mjs +751 -0
- package/cli/data-root.mjs +21 -4
- package/cli/lantern.mjs +26 -1
- package/cli/mcp-server.mjs +2779 -0
- package/cli/server.mjs +8 -2
- package/config/app.defaults.json +4 -2
- package/dist/500.html +9 -6
- package/dist/_astro/Base.Du_-4L-4.css +1 -0
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.XUV2H6ea.js +2 -0
- package/dist/_astro/BusinessMapBoard.mRxl2G3D.js +5 -0
- package/dist/_astro/CaseExecBoard.Cqkxuf5c.js +1 -0
- package/dist/_astro/CaseExecutionBoard.CjX4CoKd.js +5 -0
- package/dist/_astro/CaseGenerateApp.acgnxl79.js +10 -0
- package/dist/_astro/CasesLibrary.zmzOQwdn.js +21 -0
- package/dist/_astro/ChatApp.Ben9LFra.js +1 -0
- package/dist/_astro/ChatApp.DBi6q7Qv.js +262 -0
- package/dist/_astro/{ConfirmDialog.DrrPf1MB.js → ConfirmDialog.DQFd6g2r.js} +1 -1
- package/dist/_astro/DashboardBoard.CAJVE2G4.js +5 -0
- package/dist/_astro/{DatePicker.Bkl71M49.js → DatePicker.BRO_CjVQ.js} +1 -1
- package/dist/_astro/DefectSubmitEntry.BzKXJ-zq.js +2 -0
- package/dist/_astro/DocsFileBrowser.apKMbGVf.js +1 -0
- package/dist/_astro/{DocsPager.Duf4I68E.js → DocsPager.DMN9-Tjg.js} +1 -1
- package/dist/_astro/{DrawerField.BH3p4Q4D.js → DrawerField.CLdvmHc6.js} +1 -1
- package/dist/_astro/KnowledgeLibrary.BcoMQeUd.js +1 -0
- package/dist/_astro/LifeKrTasksBoard.DJU0-QI-.js +1 -0
- package/dist/_astro/LifeKrTodosBoard.GK7KRAO3.js +1 -0
- package/dist/_astro/LifeObjectivesBoard.DuKa6Q3k.js +1 -0
- package/dist/_astro/LifePlanTypeSelect.Cm2lUmnH.js +1 -0
- package/dist/_astro/{LifeReviewsBoard.BPXeVpg1.js → LifeReviewsBoard.BWOOVMtz.js} +3 -3
- package/dist/_astro/{LifeShared.tnT7aQON.js → LifeShared.bY2l01Ha.js} +2 -2
- package/dist/_astro/LifeStagesBoard.CIzxPOJB.js +1 -0
- package/dist/_astro/LifeYearCycleSelect.BlsyPmmI.js +1 -0
- package/dist/_astro/LifeYearPlansBoard.DaA9O08j.js +1 -0
- package/dist/_astro/MultiSelectDropdown.D-rbpivp.js +1 -0
- package/dist/_astro/{NamePromptDialog.Csfnh5eM.js → NamePromptDialog.KPCeXmri.js} +1 -1
- package/dist/_astro/NavLibraries.DVR5Ua-S.js +1 -0
- package/dist/_astro/PluginsPage.B063QIlQ.js +18 -0
- package/dist/_astro/PmBugsBoard.Cu-v0Gfd.js +1 -0
- package/dist/_astro/PmIterationsBoard.CgRzkP-j.js +1 -0
- package/dist/_astro/{PmProjectDetail.DneFVBpy.js → PmProjectDetail.DVCEh0Lm.js} +1 -1
- package/dist/_astro/PmProjectsBoard.z-bQa98r.js +1 -0
- package/dist/_astro/PmRequirementsBoard.B0W6bsW2.js +1 -0
- package/dist/_astro/PmRequirementsBoard.CyfBI0u_.js +1 -0
- package/dist/_astro/PmShared.BQVzwsiz.js +1 -0
- package/dist/_astro/ReportsPage.najSzJeT.js +1 -0
- package/dist/_astro/ReqAnalysisBoard.BQb8dHFD.js +39 -0
- package/dist/_astro/RequirementBreakdownLibrary.Cn6OV6xt.js +2 -0
- package/dist/_astro/RequirementsLibrary.CqKNFVsP.js +1 -0
- package/dist/_astro/SearchableSelect.DXclLMJI.js +1 -0
- package/dist/_astro/SelectDropdown.D7IeyHDI.js +1 -0
- package/dist/_astro/SettingsDialog.db3BpFw0.js +1 -0
- package/dist/_astro/SlideOverDrawer.BMg2tce6.js +1 -0
- package/dist/_astro/SpaceSwitcher.DSUVAPOi.js +7 -0
- package/dist/_astro/{TableFieldConfig.C7O-mL-p.js → TableFieldConfig.72AL-8p-.js} +1 -1
- package/dist/_astro/{TagSelect.UUXgkMqJ.js → TagSelect.B_r2p0fp.js} +1 -1
- package/dist/_astro/TasksBoard.CCDhCSR7.js +1 -0
- package/dist/_astro/TemplatesLibrary.peYzrHZ2.js +1 -0
- package/dist/_astro/TestReportsLibrary.fWiEyCRx.js +1 -0
- package/dist/_astro/TestStatsBoard.BSUBsWSu.js +1 -0
- package/dist/_astro/Toast.BydY-X7T.js +1 -0
- package/dist/_astro/TodosBoard.By5YdlUe.js +1 -0
- package/dist/_astro/UiAutoBoard.BGdlp5Sr.js +3 -0
- package/dist/_astro/UiAutoEnvPanel.BUASgPLB.js +10 -0
- package/dist/_astro/UiAutoGenerationDialog.D1PyCgrD.js +12 -0
- package/dist/_astro/UiAutoProjectsPage.B6A9NlVK.js +3 -0
- package/dist/_astro/app-config.Dvfzl5_N.js +1 -0
- package/dist/_astro/app-version.CNpnKIb9.js +1 -0
- package/dist/_astro/{bash-tools.D9HCzC_7.js → bash-tools.CS2w8LOb.js} +1 -1
- package/dist/_astro/business-map.BiJ85oxm.js +1 -0
- package/dist/_astro/business-map.DKwdW1VL.css +1 -0
- package/dist/_astro/case-gen-run.Cvvdv_kv.js +26 -0
- package/dist/_astro/case-prompt.CZ3vWUju.js +2 -0
- package/dist/_astro/{case-review.TdDs1WFM.js → case-review.DFWZkoR9.js} +1 -1
- package/dist/_astro/{case-template.Cd2xNbgy.js → case-template.Clb7HrDB.js} +1 -1
- package/dist/_astro/defect-submit.Dc49lFjm.css +1 -0
- package/dist/_astro/defect-workbench.CjTb4FDv.js +6 -0
- package/dist/_astro/dialog.XgRGNF_Q.js +1 -0
- package/dist/_astro/doc-roots.C-20VD0x.js +1 -0
- package/dist/_astro/{hydrate-cache.B15Nrpq0.js → hydrate-cache.O4CIma9y.js} +1 -1
- package/dist/_astro/i18n.Cp4so7KR.js +7 -0
- package/dist/_astro/{llm.DN5S1KBK.js → llm.BCYNgppW.js} +1 -1
- package/dist/_astro/mcp-tools.Kf-lupGn.js +7 -0
- package/dist/_astro/{open-docs-in-session.CRiZT022.js → open-docs-in-session.BpcAcBSI.js} +1 -1
- package/dist/_astro/plugins.Db9xoFZb.js +1 -0
- package/dist/_astro/project-docs.bB9lQ1Ki.js +1 -0
- package/dist/_astro/prompts-meta.VAjE4OET.js +2 -0
- package/dist/_astro/report-prompt.CwHuOcRN.js +1 -0
- package/dist/_astro/req-analysis.C_gARMrB.js +31 -0
- package/dist/_astro/requirement-breakdown-library.l0rPd7b3.js +1 -0
- package/dist/_astro/{settings.38J2uD5M.js → settings.D02wZj3w.js} +2 -2
- package/dist/_astro/space-skills.CPucW8zt.js +1 -0
- package/dist/_astro/{spaces-client.DV04tRyD.js → spaces-client.BAtG6PkW.js} +1 -1
- package/dist/_astro/story-review.DTN91Vl9.js +7 -0
- package/dist/_astro/test-points.C7ZgggQT.js +8 -0
- package/dist/_astro/test-reports.0gr6-c_0.js +19 -0
- package/dist/_astro/ui-auto-prompt.BmO3ja2m.js +8 -0
- package/dist/_astro/{view-prefs.DhdLZjGh.js → view-prefs.COAKEQtZ.js} +1 -1
- package/dist/business-map/index.html +983 -0
- package/dist/case-exec/index.html +10 -7
- package/dist/{prompts → case-execution}/index.html +12 -9
- package/dist/cases/generate/index.html +9 -6
- package/dist/cases/library/index.html +10 -7
- package/dist/dashboard/index.html +10 -7
- package/dist/defect-rules/index.html +690 -0
- package/dist/defect-submit/index.html +690 -0
- package/dist/defect-submit/templates/index.html +690 -0
- package/dist/docs/changelog/index.html +265 -51
- package/dist/docs/install/index.html +44 -12
- package/dist/docs/manual/index.html +213 -75
- package/dist/knowledge/index.html +10 -7
- package/dist/life/kr-tasks/index.html +10 -7
- package/dist/life/kr-todos/index.html +10 -7
- package/dist/life/objectives/index.html +10 -7
- package/dist/life/reviews/index.html +10 -7
- package/dist/life/stages/index.html +10 -7
- package/dist/life/year-plans/index.html +10 -7
- package/dist/plugins/index.html +10 -7
- package/dist/pm/bugs/index.html +10 -7
- package/dist/pm/iterations/index.html +10 -7
- package/dist/pm/projects/detail/index.html +10 -7
- package/dist/pm/projects/index.html +10 -7
- package/dist/pm/requirements/index.html +10 -7
- package/dist/reports/index.html +10 -7
- package/dist/requirement-analysis/index.html +10 -7
- package/dist/requirement-breakdowns/index.html +983 -0
- package/dist/requirements/index.html +10 -7
- package/dist/tasks/index.html +10 -7
- package/dist/templates/index.html +10 -7
- package/dist/test-automation/index.html +10 -7
- package/dist/test-automation/projects/index.html +10 -7
- package/dist/test-reports/index.html +10 -7
- package/dist/test-stats/index.html +10 -7
- package/dist/todos/index.html +10 -7
- package/dist/workbench/index.html +9 -6
- package/docs/Codex-MCP/351/233/206/346/210/220.md +296 -0
- package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/204/344/274/260.md +39 -0
- package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/206/345/210/253/351/207/215/346/236/204/346/226/271/346/241/210.md +88 -0
- package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +22 -3
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +41 -1
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +63 -17
- package/docs//346/217/222/344/273/266/344/273/223/345/272/223/344/270/216/346/212/200/350/203/275/346/225/264/345/220/210/346/226/271/346/241/210.md +187 -0
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +208 -69
- package/lh-plugins/business-map/assistant.mjs +958 -0
- package/lh-plugins/business-map/auth-paths.mjs +61 -0
- package/lh-plugins/business-map/jobs.mjs +749 -0
- package/lh-plugins/business-map/login.mjs +295 -0
- package/lh-plugins/business-map/sources.mjs +1014 -0
- package/lh-plugins/case-execution/files.mjs +777 -0
- package/lh-plugins/case-execution/service.mjs +959 -0
- package/lh-plugins/case-execution-prompt.mjs +33 -0
- package/lh-plugins/lh-business-map.mjs +2431 -0
- package/lh-plugins/lh-case-execution.mjs +304 -0
- package/lh-plugins/lh-config.mjs +13 -0
- package/lh-plugins/lh-defect-submit.mjs +989 -0
- package/lh-plugins/lh-project-docs.mjs +31 -140
- package/lh-plugins/lh-reports.mjs +29 -57
- package/lh-plugins/lh-req-analysis.mjs +32 -3
- package/lh-plugins/lh-req-breakdown-library.mjs +1084 -0
- package/lh-plugins/lh-uiauto.mjs +514 -22
- package/lh-plugins/plugin-prompts.mjs +19 -15
- package/lh-plugins/req-analysis-revision.mjs +24 -0
- package/lh-plugins/test-points-prompt.mjs +2 -3
- package/lh-plugins/uiauto-auth-setup.mjs +218 -0
- package/lh-plugins/uiauto-explorer/apps.mjs +13 -2
- package/lh-plugins/uiauto-explorer/runner.mjs +15 -2
- package/lh-plugins/uiauto-explorer/sessions.mjs +305 -17
- package/lh-plugins/uiauto-node.mjs +102 -11
- package/lh-plugins/uiauto-prompt.mjs +20 -15
- package/lh-plugins/uiauto-sso.mjs +407 -0
- package/package.json +5 -2
- package/skills/case-execution/SKILL.md +30 -0
- package/skills/lantern-defect-submit/SKILL.md +15 -0
- package/skills/lantern-workflow/SKILL.md +57 -0
- package/skills/office/SKILL.md +26 -0
- package/dist/_astro/Base.DIbzr8uT.css +0 -1
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CPR_CfsE.js +0 -2
- package/dist/_astro/CaseExecBoard.DICluCbK.js +0 -1
- package/dist/_astro/CaseGenerateApp.CcAtVSQJ.js +0 -10
- package/dist/_astro/CasesLibrary.Ci_0hYqL.js +0 -21
- package/dist/_astro/ChatApp.DFKZOkZy.js +0 -227
- package/dist/_astro/DashboardBoard.Qvf8o4v1.js +0 -5
- package/dist/_astro/DocsFileBrowser.DwKBffbM.js +0 -1
- package/dist/_astro/KnowledgeLibrary.MDpMqeOd.js +0 -1
- package/dist/_astro/LifeKrTasksBoard.DsvW_S66.js +0 -1
- package/dist/_astro/LifeKrTodosBoard.D2KTqvg1.js +0 -1
- package/dist/_astro/LifeObjectivesBoard.B0cDK934.js +0 -1
- package/dist/_astro/LifePlanTypeSelect.BELDvMWU.js +0 -1
- package/dist/_astro/LifeStagesBoard.CZftLR9K.js +0 -1
- package/dist/_astro/LifeYearCycleSelect.Bw2eRbSm.js +0 -1
- package/dist/_astro/LifeYearPlansBoard.DB-RJFEl.js +0 -1
- package/dist/_astro/MultiSelectDropdown.CBC7aNOv.js +0 -1
- package/dist/_astro/NavLibraries.DdQYsZbe.js +0 -1
- package/dist/_astro/OverflowHint.CHZeFfUj.js +0 -1
- package/dist/_astro/PluginsPage.BVrMtkLi.js +0 -17
- package/dist/_astro/PluginsPage.xdbDGigE.js +0 -1
- package/dist/_astro/PmBugsBoard.CGpXUTPu.js +0 -1
- package/dist/_astro/PmIterationsBoard.BaKiFIam.js +0 -1
- package/dist/_astro/PmProjectsBoard.BxoMF9gK.js +0 -1
- package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +0 -1
- package/dist/_astro/PmRequirementsBoard.DsK6RF7Q.js +0 -1
- package/dist/_astro/PmShared.BK8kWRSV.js +0 -1
- package/dist/_astro/PromptMountDialog.mrTx3U5T.js +0 -1
- package/dist/_astro/PromptsLibrary.B2LMGsrj.js +0 -1
- package/dist/_astro/ReportsPage.B9lGg1_s.js +0 -16
- package/dist/_astro/ReqAnalysisBoard.D-KmRwQM.js +0 -39
- package/dist/_astro/RequirementsLibrary.cJc-bnGQ.js +0 -1
- package/dist/_astro/SearchableSelect.SyLRS-Jj.js +0 -1
- package/dist/_astro/SelectDropdown.T3CKHaLt.js +0 -1
- package/dist/_astro/SettingsDialog.C62iJkMt.js +0 -1
- package/dist/_astro/SpaceSwitcher.C47_S1g9.js +0 -7
- package/dist/_astro/TasksBoard.BUEg2BYk.js +0 -1
- package/dist/_astro/TemplatesLibrary.BLVIphXO.js +0 -1
- package/dist/_astro/TestReportsLibrary.DVq30Jae.js +0 -1
- package/dist/_astro/TestStatsBoard.-5BWQ6bI.js +0 -1
- package/dist/_astro/Toast.BO2NFckG.js +0 -1
- package/dist/_astro/TodosBoard.DI_lTp2e.js +0 -1
- package/dist/_astro/UiAutoBoard.ChFdgv7s.js +0 -2
- package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +0 -19
- package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +0 -1
- package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +0 -3
- package/dist/_astro/app-config.DkyjuL-S.js +0 -1
- package/dist/_astro/app-version.3eY3FSw1.js +0 -1
- package/dist/_astro/case-gen-run.BQeK-XUw.js +0 -22
- package/dist/_astro/case-types.DlFkbZJN.js +0 -1
- package/dist/_astro/dialog.DZHZCe_T.js +0 -1
- package/dist/_astro/doc-roots.CO3IBiY6.js +0 -1
- package/dist/_astro/i18n.D_aOCHSN.js +0 -7
- package/dist/_astro/markdown-client.BS19nLL3.js +0 -62
- package/dist/_astro/plugins.BRvXWHLe.js +0 -1
- package/dist/_astro/project-docs.CCjtiFjB.js +0 -1
- package/dist/_astro/prompts-meta.BUGutlsk.js +0 -2
- package/dist/_astro/report-prompt.B9C4cv84.js +0 -1
- package/dist/_astro/req-analysis.FrD6BfwK.js +0 -31
- package/dist/_astro/story-review.R8iWiFzl.js +0 -14
- package/dist/_astro/test-reports.CuIjlEyK.js +0 -19
- package/dist/_astro/ui-auto-prompt.H9_yhau9.js +0 -9
- package/dist/_astro/ui-auto.DMv940x4.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
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"./ConfirmDialog.DrrPf1MB.js";import{t as i}from"./OverflowHint.CHZeFfUj.js";import{t as ee}from"./SelectDropdown.T3CKHaLt.js";import{m as a}from"./PmShared.BK8kWRSV.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as l,l as u,n as d,o as f,t as p}from"./ColumnResize.CkE59sGq.js";import{t as m}from"./NamePromptDialog.Csfnh5eM.js";import{$ as h,A as te,B as g,C as ne,E as _,G as re,H as v,J as y,L as b,M as x,N as S,O as C,Q as w,S as T,T as E,U as D,V as O,X as ie,Y as ae,Z as oe,_ as se,b as k,bt as ce,c as le,et as ue,f as A,gt as de,h as j,k as fe,pt as pe,w as me,x as he,xt as ge,y as _e,yt as ve,z as M}from"./LifeShared.tnT7aQON.js";import{c as N,l as P,n as F,t as I}from"./DrawerField.BH3p4Q4D.js";import{t as ye}from"./LifePlanTypeSelect.BELDvMWU.js";var L=e(t(),1),R=n(),z=j;function be(e){let{lifeCycles:t,value:n,onChange:s,mutate:c,flat:l,unstyled:u,pill:d,className:f,triggerClassName:p,ariaLabel:h=`人生周期`,searchPlaceholder:te=`搜索人生周期…`,placeholder:ne=z,renderTrigger:_}=e,[re,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(null),[x,S]=(0,L.useState)(``),[C,w]=(0,L.useState)(null),T=(0,L.useMemo)(()=>ce(t),[t]),E=(0,L.useMemo)(()=>T.map(e=>({value:e.id,label:e.name})),[T]),D=n&&E.some(e=>e.value===n)?n:``,O=!D,ie=O?ne:de(T,D);async function ae(e){let t=e.trim();if(!t)return;let n=T.find(e=>e.name===t);if(n)s(n.id);else{v(!0);try{let e=(await c.createItems(`lifeCycles`,[{name:t}])).items[0];e?.id&&s(e.id),o(`已新增「${t}」`,`success`)}catch(e){o(e instanceof Error?e.message:String(e),`error`)}finally{v(!1)}}}async function oe(e){let t=y;if(!t)return;let n=e.trim();if(!n||n===t.name)b(null),S(``);else{v(!0),S(``);try{await c.updateItem(`lifeCycles`,t.id,{name:n}),b(null),o(`已修改人生周期`,`success`)}catch(e){S(e instanceof Error?e.message:String(e))}finally{v(!1)}}}async function se(){let e=C;if(e){w(null),v(!0);try{await c.deleteItems(`lifeCycles`,[e.id]),D===e.id&&s(``),o(`已删除人生周期`,`success`)}catch(e){o(e instanceof Error?e.message:String(e),`error`)}finally{v(!1)}}}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ee,{flat:l,unstyled:u,fitContent:!(!d||O),centerContent:!1,className:f,triggerClassName:(d?O?`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#3370ff]/30`:`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`:void 0)??p,searchable:!0,searchPlaceholder:te,ariaLabel:h,options:E,value:D,onChange:s,onSearchCreate:e=>void ae(e),renderTrigger:_?(e,t)=>_(ie,{...t,empty:O}):()=>d&&!O?(0,R.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${g(D)}`,children:(0,R.jsx)(i,{text:ie,className:`block min-w-0 truncate`})}):(0,R.jsx)(i,{text:ie,className:`block min-w-0 truncate ${O||E.length===0?`text-stone-400`:`text-stone-800`}`}),renderOptionAction:e=>(0,R.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:re,"aria-label":`修改 ${e.label}`,className:`rounded p-1 text-stone-400 opacity-0 transition-opacity hover:bg-stone-100 hover:text-stone-700 focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0`,onClick:()=>{let t=T.find(t=>t.id===e.value);t&&(S(``),b(t))},children:(0,R.jsx)(a,{name:`pencil`,size:13})}),(0,R.jsx)(`button`,{type:`button`,disabled:re,"aria-label":`删除 ${e.label}`,className:`tw-icon-danger rounded p-1 opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0 disabled:group-hover:opacity-40`,onClick:()=>{let t=T.find(t=>t.id===e.value);t&&w(t)},children:(0,R.jsx)(a,{name:`trash`,size:13})})]})}),(0,R.jsx)(m,{open:y!=null,title:`修改人生周期`,label:`人生周期`,placeholder:`例如 第一辈子(29-34)`,initialValue:y?.name??``,confirmLabel:`保存`,cancelLabel:`取消`,error:x,onClose:()=>{b(null),S(``)},onConfirm:e=>void oe(e)}),(0,R.jsx)(r,{open:C!=null,title:`删除人生周期`,message:`删除「${C?.name??``}」?已引用该周期的人生阶段会清空周期。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>w(null),onConfirm:()=>void se()})]})}var xe=[{key:`select`,width:36,min:32},{key:`title`,width:220,min:160},{key:`lifeCycle`,width:160,min:120},{key:`planType`,width:140,min:100},{key:`progress`,width:160,min:120},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Se=[{key:`lifeCycle`,label:`人生周期`},{key:`planType`,label:`计划类型`},{key:`progress`,label:`进度`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ce=`life.stages.fields`,we=`life.stages.search`,Te=`life.stages.group`,Ee=[`lifeCycle`,`planType`,`none`],De=[{value:`none`,label:`不分组`},{value:`lifeCycle`,label:`按人生周期分组`},{value:`planType`,label:`按计划类型分组`}];function Oe(e){return{title:``,lifeCycle:e?.lifeCycle??``,planType:e?.planType??``,progress:e?.progress??0}}function ke(e){let t={},n=/(?:^|\|)lifeCycle:([^|]+)/.exec(e)?.[1];n===`unset`?t.lifeCycle=``:n&&(t.lifeCycle=n);let r=/(?:^|\|)planType:([^|]+)/.exec(e)?.[1];return r===`unset`?t.planType=``:r&&(t.planType=r),t}function Ae(e){let{open:t,item:n,planTypes:r,lifeCycles:ee,mutate:a,isVisible:o,onClose:s,onSave:c}=e,[l,u]=(0,L.useState)(Oe()),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(``);(0,L.useEffect)(()=>{t&&(m(``),f(!1),u({title:n.title,lifeCycle:n.lifeCycle||``,planType:n.planType||``,progress:n.progress}))},[t,n]);async function h(){let e=l.title.trim();if(!e)m(`请填写阶段名称`);else{f(!0);try{await c({...l,title:e,progress:Math.max(0,Math.min(100,l.progress))},n.id),s()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}}return(0,R.jsxs)(k,{open:t,title:`阶段详情`,onClose:s,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:s,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,R.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:d?`保存中…`:`保存`})]}),children:[p?(0,R.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:p}):null,(0,R.jsx)(F,{icon:(0,R.jsx)(P,{}),label:`阶段名称`,children:(0,R.jsx)(`input`,{autoFocus:!0,value:l.title,onChange:e=>u({...l,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),h())},placeholder:`如 第一辈子`,className:I})}),o(`lifeCycle`)?(0,R.jsx)(F,{icon:(0,R.jsx)(N,{}),label:`人生周期`,children:(0,R.jsx)(be,{flat:!0,className:`w-full`,lifeCycles:ee,value:l.lifeCycle,onChange:e=>u({...l,lifeCycle:e}),mutate:a,renderTrigger:(e,{empty:t})=>(0,R.jsx)(i,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,o(`planType`)?(0,R.jsx)(F,{icon:(0,R.jsx)(N,{}),label:`计划类型`,children:(0,R.jsx)(ye,{flat:!0,className:`w-full`,planTypes:r,value:l.planType,onChange:e=>u({...l,planType:e}),mutate:a,renderTrigger:(e,{empty:t})=>(0,R.jsx)(i,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,o(`progress`)?(0,R.jsx)(F,{icon:(0,R.jsx)(N,{}),label:`进度`,children:(0,R.jsx)(`div`,{className:`px-1 py-1`,children:(0,R.jsx)(C,{value:l.progress,onChange:e=>u({...l,progress:e})})})}):null,o(`createdAt`)?(0,R.jsx)(F,{icon:(0,R.jsx)(N,{}),label:`创建日期`,children:(0,R.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:M(n.createdAt)})}):null,o(`updatedAt`)?(0,R.jsx)(F,{icon:(0,R.jsx)(N,{}),label:`修改日期`,children:(0,R.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:M(n.updatedAt)})}):null]})}function je(){let e=w(),{store:t,live:n,error:i,setError:a,updateItem:m,createItems:k,deleteItems:N}=ue(e.ready&&e.on),P=(0,L.useMemo)(()=>({createItems:k,updateItem:m,deleteItems:N}),[k,m,N]),F=ae(Ce,Se),I=(0,L.useMemo)(()=>b(xe,F.isVisible),[F.isVisible]),[z,je]=oe(we),[B,Me]=y(Te,Ee,`none`),[Ne,Pe]=(0,L.useState)({}),Fe=D(),[V,H]=(0,L.useState)(null),[Ie,Le]=(0,L.useState)(null),[U,Re]=(0,L.useState)(!1),[W,ze]=(0,L.useState)(!1),[Be,Ve]=(0,L.useState)({}),[G,K]=(0,L.useState)(null),q=u(`life.stages.cols.v14`,I),He=c(`life.stages`),{submit:Ue}=ie({row:G,setRow:K,submitting:W,isPristine:e=>{let t=e.base;return!e.title.trim()&&e.lifeCycle===t.lifeCycle&&e.planType===t.planType&&e.progress===t.progress},onSubmit:async e=>{ze(!0);try{await k(`lifeStages`,[{title:e.title,lifeCycle:e.lifeCycle,planType:e.planType,progress:Math.max(0,Math.min(100,e.progress))}]),K(null),o(`已新增人生阶段`,`success`),a(``)}catch(e){let t=e instanceof Error?e.message:String(e);a(t),o(`新增失败:${t}`,`error`)}finally{ze(!1)}}});function J(e,t){let n=Oe(t);K({groupKey:e,...n,base:n}),Pe(t=>({...t,[e]:!1}))}let Y=(0,L.useMemo)(()=>{let e=z.trim().toLowerCase(),n=t.lifeStages;return n=e?n.filter(n=>{let r=de(t.lifeCycles,n.lifeCycle).toLowerCase(),i=ve(t.planTypes,n.planType).toLowerCase();return n.title.toLowerCase().includes(e)||r.includes(e)||i.includes(e)}):pe(n,z),re(n)},[t.lifeStages,t.lifeCycles,t.planTypes,z]),X=(0,L.useMemo)(()=>{if(B===`none`)return[{key:`all`,label:`全部阶段`,pill:`bg-stone-500 text-white`,items:Y}];if(B===`lifeCycle`){let e=ce(t.lifeCycles),n=new Set(e.map(e=>e.id)),r=e.map(e=>({key:`lifeCycle:${e.id}`,label:e.name,pill:g(e.id),items:Y.filter(t=>t.lifeCycle===e.id)})).filter(e=>e.items.length>0),i=Y.filter(e=>!e.lifeCycle||!n.has(e.lifeCycle));return i.length>0&&r.push({key:`lifeCycle:unset`,label:j,pill:g(``),items:i}),r}let e=ge(t.planTypes),n=new Set(e.map(e=>e.id)),r=e.map(e=>({key:`planType:${e.id}`,label:e.name,pill:g(e.id),items:Y.filter(t=>t.planType===e.id)})).filter(e=>e.items.length>0),i=Y.filter(e=>!e.planType||!n.has(e.planType));return i.length>0&&r.push({key:`planType:unset`,label:j,pill:g(``),items:i}),r},[B,Y,t.lifeCycles,t.planTypes]),Z=(0,L.useMemo)(()=>{let e=X.filter(e=>e.items.length>0);return e.length>0?e:B===`none`?X.length>0?X:[{key:`all`,label:`全部阶段`,pill:`bg-stone-500 text-white`,items:[]}]:B===`lifeCycle`?[{key:`lifeCycle:unset`,label:j,pill:g(``),items:[]}]:[{key:`planType:unset`,label:j,pill:g(``),items:[]}]},[B,X]),We=(0,L.useMemo)(()=>Z.flatMap(e=>e.items.map(e=>e.id)),[Z]),Q=h(We);async function Ge(e,t){try{await m(`lifeStages`,e,t),Ve(t=>{let n={...t};return delete n[e],n}),a(``)}catch(e){let t=e instanceof Error?e.message:String(e);a(t),o(`保存失败:${t}`,`error`)}}function Ke(e){return{...e,...Be[e.id]}}function qe(e,t){Ve(n=>({...n,[e]:{...n[e],...t}}))}async function Je(e){let t=Be[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Ge(e.id,{...t,title:n}):a(`阶段名称不能为空`)}async function Ye(e,t){await m(`lifeStages`,t,e),o(`已保存`,`success`)}function Xe(){return G?(0,R.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,R.jsx)(`td`,{className:d,style:Fe,children:(0,R.jsx)(`input`,{autoFocus:!0,disabled:W,value:G.title,placeholder:`输入阶段名称,回车或点空白处保存`,onChange:e=>K(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Ue()):e.key===`Escape`&&(e.preventDefault(),K(null))},className:le})}),F.isVisible(`lifeCycle`)?(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(be,{unstyled:!0,pill:!0,lifeCycles:t.lifeCycles,value:G.lifeCycle,onChange:e=>K(t=>t&&{...t,lifeCycle:e}),mutate:P})}):null,F.isVisible(`planType`)?(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(ye,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:G.planType,onChange:e=>K(t=>t&&{...t,planType:e}),mutate:P})}):null,F.isVisible(`progress`)?(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,R.jsx)(C,{value:G.progress,onChange:e=>K(t=>t&&{...t,progress:e})})}):null,F.isVisible(`createdAt`)?(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(x,{text:`—`,muted:!0})}):null,F.isVisible(`updatedAt`)?(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(x,{text:`—`,muted:!0})}):null,(0,R.jsx)(`td`,{"aria-hidden":`true`}),(0,R.jsx)(`td`,{className:l})]}):null}async function Ze(){let e=V;if(e?.length){H(null),Re(!0);try{await N(`lifeStages`,e.map(e=>e.id)),Q.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){a(e instanceof Error?e.message:String(e))}finally{Re(!1)}}}function Qe(e,n){let r=Ke(e),i=(Be[e.id]?.progress,r.progress);return(0,R.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,R.jsx)(fe,{checked:!!Q.selected[e.id],onChange:()=>Q.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:Q.selectedIds.length>0}),(0,R.jsx)(`td`,{className:d,style:Fe,children:(0,R.jsx)(S,{value:r.title,placeholder:`如 第一辈子`,onChange:t=>qe(e.id,{title:t}),onCommit:()=>void Je(e),onCancel:()=>Ve(t=>{let n={...t};return delete n[e.id],n})})}),F.isVisible(`lifeCycle`)?(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(be,{unstyled:!0,pill:!0,lifeCycles:t.lifeCycles,value:r.lifeCycle||``,onChange:t=>void Ge(e.id,{lifeCycle:t}),mutate:P})}):null,F.isVisible(`planType`)?(0,R.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,R.jsx)(ye,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:r.planType,onChange:t=>void Ge(e.id,{planType:t}),mutate:P})}):null,F.isVisible(`progress`)?(0,R.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,R.jsx)(C,{value:i,onChange:t=>qe(e.id,{progress:t}),onCommit:t=>void Ge(e.id,{progress:t})})}):null,F.isVisible(`createdAt`)?(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(x,{text:M(e.createdAt),muted:!e.createdAt})}):null,F.isVisible(`updatedAt`)?(0,R.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,R.jsx)(x,{text:M(e.updatedAt),muted:!e.updatedAt})}):null,(0,R.jsx)(`td`,{"aria-hidden":`true`}),(0,R.jsx)(`td`,{className:l,children:(0,R.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,R.jsx)(T,{label:`编辑 ${e.title}`,disabled:U,onClick:()=>Le(e)}),(0,R.jsx)(_e,{label:`删除 ${e.title}`,disabled:U,onClick:()=>H([e])})]})})]},e.id)}if(!e.ready)return(0,R.jsx)(E,{label:`正在读取插件开关`});if(!e.on)return(0,R.jsx)(_,{children:O()});if(n===null)return(0,R.jsx)(E,{label:`正在连接人生管理服务`});if(!n)return(0,R.jsx)(_,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=I.length;return(0,R.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,R.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.lifeStages.length}),` 条`]}),(0,R.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`input`,{value:z,onChange:e=>je(e.target.value),placeholder:`搜索人生阶段…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,R.jsx)(ee,{flat:!0,className:`w-[168px]`,ariaLabel:`分组方式`,options:De,value:B,onChange:e=>Me(e)}),(0,R.jsx)(ne,{fields:F.fields,isVisible:F.isVisible,onToggle:F.toggle}),(0,R.jsx)(`button`,{type:`button`,disabled:U||Q.selectedIds.length===0,onClick:()=>H(t.lifeStages.filter(e=>Q.selected[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,R.jsx)(`button`,{type:`button`,disabled:U||W,onClick:()=>{if(B===`none`)J(`all`);else{let e=Z[0];J(e?.key??`all`,e?ke(e.key):void 0)}},className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建阶段`})]})]}),(0,R.jsx)(he,{error:i,onDismiss:()=>a(``)}),(0,R.jsx)(`div`,{ref:He,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,R.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,R.jsx)(`colgroup`,{children:I.map(e=>(0,R.jsx)(`col`,{style:e.key===`select`?{width:v(!1)}:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,R.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(te,{checked:Q.allVisibleSelected,indeterminate:Q.selectedIds.length>0&&!Q.allVisibleSelected,onChange:()=>Q.toggleAllVisible()}),(0,R.jsxs)(`th`,{className:`${f} text-xs text-stone-500`,style:Fe,children:[`阶段名称`,(0,R.jsx)(p,{...q.resizeProps(`title`)})]}),F.isVisible(`lifeCycle`)?(0,R.jsxs)(`th`,{className:A,children:[`人生周期`,(0,R.jsx)(p,{...q.resizeProps(`lifeCycle`)})]}):null,F.isVisible(`planType`)?(0,R.jsxs)(`th`,{className:A,children:[`计划类型`,(0,R.jsx)(p,{...q.resizeProps(`planType`)})]}):null,F.isVisible(`progress`)?(0,R.jsxs)(`th`,{className:A,children:[`进度`,(0,R.jsx)(p,{...q.resizeProps(`progress`)})]}):null,F.isVisible(`createdAt`)?(0,R.jsxs)(`th`,{className:A,children:[`创建日期`,(0,R.jsx)(p,{...q.resizeProps(`createdAt`)})]}):null,F.isVisible(`updatedAt`)?(0,R.jsxs)(`th`,{className:A,children:[`修改日期`,(0,R.jsx)(p,{...q.resizeProps(`updatedAt`)})]}):null,(0,R.jsx)(`th`,{"aria-hidden":`true`}),(0,R.jsx)(`th`,{className:s,children:`操作`})]})}),(0,R.jsx)(`tbody`,{children:Y.length===0&&!G?(0,R.jsx)(`tr`,{children:(0,R.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.lifeStages.length===0?`还没有人生阶段`:`没有匹配的记录`})}):Y.length===0&&G?Xe():B===`none`?(0,R.jsxs)(R.Fragment,{children:[Y.map((e,t)=>Qe(e,t+1)),G?Xe():(0,R.jsx)(se,{colSpan:$,disabled:U||W,onClick:()=>J(`all`)})]}):Z.map(e=>{let n=!Ne[e.key];return(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(me,{label:e.label,pill:e.pill,count:e.items.length,open:n,kind:`tag`,colSpan:$,onToggle:()=>Pe(t=>({...t,[e.key]:!t[e.key]}))}),n?(0,R.jsxs)(R.Fragment,{children:[e.items.map((e,t)=>Qe(e,t+1)),G?.groupKey===e.key?Xe():Y.length>0||t.lifeStages.length===0?(0,R.jsx)(se,{colSpan:$,disabled:U||W,onClick:()=>J(e.key,ke(e.key))}):null]}):null]},e.key)})})]})}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,R.jsxs)(`span`,{children:[`显示 `,Y.length,` 条`,Q.selectedIds.length?` · 已选 ${Q.selectedIds.length}`:``]}),(0,R.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`可添加多个阶段并分别维护进度`})]}),Ie?(0,R.jsx)(Ae,{open:!0,item:Ie,planTypes:t.planTypes,lifeCycles:t.lifeCycles,mutate:P,isVisible:F.isVisible,onClose:()=>Le(null),onSave:Ye}):null,(0,R.jsx)(r,{open:V!=null,title:V&&V.length>1?`批量删除`:`删除人生阶段`,message:V&&V.length>1?`删除选中的 ${V.length} 条阶段?`:`删除「${V?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>H(null),onConfirm:()=>void Ze()})]})}export{je as default};
|
|
@@ -1 +0,0 @@
|
|
|
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"./ConfirmDialog.DrrPf1MB.js";import{t as i}from"./OverflowHint.CHZeFfUj.js";import{t as a}from"./SelectDropdown.T3CKHaLt.js";import{m as o}from"./PmShared.BK8kWRSV.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{t as c}from"./NamePromptDialog.Csfnh5eM.js";import{B as l,St as u,h as d,wt as f}from"./LifeShared.tnT7aQON.js";var p=e(t(),1),m=n(),h=d;function g(e){let{yearCycles:t,value:n,onChange:d,mutate:g,flat:_,unstyled:v,pill:y,className:b,triggerClassName:x,ariaLabel:S=`年度周期`,searchPlaceholder:C=`搜索年度…`,placeholder:w=h,renderTrigger:T}=e,[E,D]=(0,p.useState)(!1),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(``),[M,N]=(0,p.useState)(null),P=(0,p.useMemo)(()=>u(t),[t]),F=(0,p.useMemo)(()=>P.map(e=>({value:e.id,label:e.name})),[P]),I=n&&F.some(e=>e.value===n)?n:``,L=!I,R=L?w:f(P,I);async function z(e){let t=e.trim();if(!t)return;let n=P.find(e=>e.name===t);if(n)d(n.id);else{D(!0);try{let e=(await g.createItems(`yearCycles`,[{name:t}])).items[0];e?.id&&d(e.id),s(`已新增「${t}」`,`success`)}catch(e){s(e instanceof Error?e.message:String(e),`error`)}finally{D(!1)}}}async function B(e){let t=O;if(!t)return;let n=e.trim();if(!n||n===t.name)k(null),j(``);else{D(!0),j(``);try{await g.updateItem(`yearCycles`,t.id,{name:n}),k(null),s(`已修改年度周期`,`success`)}catch(e){j(e instanceof Error?e.message:String(e))}finally{D(!1)}}}async function V(){let e=M;if(e){N(null),D(!0);try{await g.deleteItems(`yearCycles`,[e.id]),I===e.id&&d(``),s(`已删除年度周期`,`success`)}catch(e){s(e instanceof Error?e.message:String(e),`error`)}finally{D(!1)}}}return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a,{flat:_,unstyled:v,fitContent:!(!y||L),centerContent:!1,className:b,triggerClassName:(y?L?`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#3370ff]/30`:`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`:void 0)??x,searchable:!0,searchPlaceholder:C,ariaLabel:S,options:F,value:I,onChange:d,onSearchCreate:e=>void z(e),renderTrigger:T?(e,t)=>T(R,{...t,empty:L}):()=>y&&!L?(0,m.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${l(I)}`,children:(0,m.jsx)(i,{text:R,className:`block min-w-0 truncate`})}):(0,m.jsx)(i,{text:R,className:`block min-w-0 truncate ${L||F.length===0?`text-stone-400`:`text-stone-800`}`}),renderOptionAction:e=>(0,m.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,m.jsx)(`button`,{type:`button`,disabled:E,"aria-label":`修改 ${e.label}`,className:`rounded p-1 text-stone-400 opacity-0 transition-opacity hover:bg-stone-100 hover:text-stone-700 focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0`,onClick:()=>{let t=P.find(t=>t.id===e.value);t&&(j(``),k(t))},children:(0,m.jsx)(o,{name:`pencil`,size:13})}),(0,m.jsx)(`button`,{type:`button`,disabled:E,"aria-label":`删除 ${e.label}`,className:`tw-icon-danger rounded p-1 opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0 disabled:group-hover:opacity-40`,onClick:()=>{let t=P.find(t=>t.id===e.value);t&&N(t)},children:(0,m.jsx)(o,{name:`trash`,size:13})})]})}),(0,m.jsx)(c,{open:O!=null,title:`修改年度周期`,label:`年度周期`,placeholder:`例如 2026年`,initialValue:O?.name??``,confirmLabel:`保存`,cancelLabel:`取消`,error:A,onClose:()=>{k(null),j(``)},onConfirm:e=>void B(e)}),(0,m.jsx)(r,{open:M!=null,title:`删除年度周期`,message:`删除「${M?.name??``}」?已引用该周期的年度计划与 Objective 会清空周期。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>N(null),onConfirm:()=>void V()})]})}export{g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DrrPf1MB.js";import{t as a}from"./OverflowHint.CHZeFfUj.js";import{t as o}from"./SelectDropdown.T3CKHaLt.js";import{showToast as s}from"./Toast.BO2NFckG.js";import{c,d as l,i as u,l as d,n as f,o as p,t as m}from"./ColumnResize.CkE59sGq.js";import{$ as h,A as g,B as _,C as v,E as ee,F as y,H as te,J as ne,K as re,L as ie,M as b,N as ae,P as oe,Q as se,S as ce,St as le,T as ue,U as de,V as fe,X as pe,Y as me,Z as he,_ as ge,b as x,c as _e,dt as S,et as ve,f as C,g as ye,k as be,pt as xe,ut as w,w as Se,x as Ce,y as we,z as T}from"./LifeShared.tnT7aQON.js";import{c as E,l as D,n as O,r as k,s as A,t as j}from"./DrawerField.BH3p4Q4D.js";import{t as M}from"./LifePlanTypeSelect.BELDvMWU.js";import{t as Te}from"./LifeYearCycleSelect.Bw2eRbSm.js";var N=e(t(),1),P=e(n(),1),F=r(),Ee=[{key:`select`,width:36,min:32},{key:`title`,width:220,min:160},{key:`yearCycle`,width:120,min:88},{key:`planType`,width:112,min:88},{key:`status`,width:104,min:76},{key:`objectives`,width:280,min:180},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[{key:`yearCycle`,label:`年度周期`},{key:`planType`,label:`计划类型`},{key:`status`,label:`状态`},{key:`objectives`,label:`关联 Objective`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Oe=`life.year-plans.fields`,ke=`life.year-plans.search`,Ae=`life.year-plans.group`,je=[`status`,`yearCycle`,`none`],I=w.map(e=>({value:e,label:S[e]})),Me={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,done:`bg-[#d9f5d2] text-[#1d7a12]`},Ne=[{value:`none`,label:`不分组`},{value:`status`,label:`按状态分组`},{value:`yearCycle`,label:`按年度分组`}];function L(e){return{title:``,yearCycle:e?.yearCycle??``,planType:e?.planType??``,status:e?.status??`in_progress`,objectiveIds:e?.objectiveIds??[]}}function Pe(e){let t=(0,N.useMemo)(()=>{let t=new Set(e.values);return e.objectives.filter(n=>t.has(n.id)||!!e.yearPlanId&&n.yearPlanId===e.yearPlanId)},[e.objectives,e.values,e.yearPlanId]),n=!e.yearCycle,r=t.length===0,i=n?`先选年度周期`:r?`暂无关联 Objective`:`已关联 ${t.length} 个目标`,[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)({left:0,top:0,width:280,openUp:!1}),u=(0,N.useRef)(null),d=(0,N.useRef)(null),f=n;(0,N.useEffect)(()=>{if(!o)return;function e(e){let t=e.target;u.current?.contains(t)||d.current?.contains(t)||s(!1)}function t(e){e.target instanceof Node&&d.current?.contains(e.target)||s(!1)}function n(){s(!1)}return document.addEventListener(`mousedown`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,n)}},[o]);function p(){if(f)return;if(o){s(!1);return}let e=u.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.max(t.width,260),r=Math.min(t.left,Math.max(8,window.innerWidth-n-8)),i=t.bottom+4,a=i+200>window.innerHeight&&t.top>200;l({left:r,top:a?t.top-4:i,width:n,openUp:a}),s(!0)}function m(n,r){r.stopPropagation(),e.onChange(t.filter(e=>e.id!==n).map(e=>e.id))}let h=f?`w-full min-h-8 flex items-center justify-start rounded-lg border border-stone-200 bg-stone-50 px-2.5 py-1.5 text-sm text-left text-stone-400 cursor-not-allowed`:e.flat?`tw-field-trigger w-full min-h-9 flex items-center justify-start rounded-lg border border-stone-200 bg-white px-3 py-1.5 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`:`tw-field-trigger w-full min-h-8 flex items-center justify-start rounded-lg border border-stone-200 bg-white px-2.5 py-1.5 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-1 focus:ring-[#3370ff]/30`,g=null;return o&&typeof document<`u`&&(g=(0,P.createPortal)((0,F.jsx)(`div`,{ref:d,className:`tw-select-menu tw-popover-anim fixed z-[1000] overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200`,style:{left:c.left,width:c.width,...c.openUp?{bottom:window.innerHeight-c.top}:{top:c.top}},children:(0,F.jsx)(`div`,{className:`tw-dsh-scroll max-h-[120px] overflow-y-auto bg-white px-2.5 py-2`,onWheel:e=>e.stopPropagation(),children:r?(0,F.jsx)(`p`,{className:`px-1 py-1 text-sm text-stone-400`,children:n?`先选年度周期`:`暂无关联 Objective,可在 Objective 里选年度计划`}):(0,F.jsx)(`div`,{className:`flex flex-wrap content-start gap-1.5`,children:t.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-full bg-[#e8f0fe] px-2.5 py-0.5 text-[12px] leading-5 text-[#1f4ec2]`,children:[(0,F.jsx)(`span`,{className:`min-w-0 break-words whitespace-pre-wrap`,children:e.title}),(0,F.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`移除 ${e.title}`,className:`shrink-0 rounded-full px-0.5 text-[#5b7fd4] hover:bg-[#d2e3fc] hover:text-[#1f4ec2]`,onClick:t=>m(e.id,t),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m(e.id,t))},children:`×`})]},e.id))})})}),document.body)),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`button`,{ref:u,type:`button`,disabled:f,"aria-expanded":o,onClick:p,className:h,children:r||f?(0,F.jsx)(`span`,{className:`text-stone-400`,children:i}):(0,F.jsx)(a,{text:t.map(e=>e.title).join(`、`),className:`block min-w-0 flex-1 truncate text-left text-stone-700`})}),g]})}function Fe(e){let t={},n=/(?:^|\|)status:([^|]+)/.exec(e)?.[1];n&&w.includes(n)&&(t.status=n);let r=/(?:^|\|)year:([^|]+)/.exec(e)?.[1];return r&&r!==`unset`&&(t.yearCycle=r),t}function Ie(e){let{open:t,item:n,yearCycles:r,yearCycleMutate:i,objectives:o,planTypes:s,planTypeMutate:c,isVisible:l,onClose:u,onSave:d}=e,[f,p]=(0,N.useState)(L()),[m,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(``);(0,N.useEffect)(()=>{t&&(_(``),h(!1),p({title:n.title,yearCycle:n.yearCycle,planType:n.planType||``,status:n.status,objectiveIds:n.objectiveIds??[]}))},[t,n]);async function v(){let e=f.title.trim();if(!e)_(`请填写计划标题`);else{h(!0);try{await d({...f,title:e,yearCycle:f.yearCycle,objectiveIds:f.objectiveIds},n.id),u()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,F.jsxs)(x,{open:t,title:`计划详情`,onClose:u,footer:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:u,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>void v(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:`保存`})]}),children:[g?(0,F.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:g}):null,(0,F.jsx)(O,{icon:(0,F.jsx)(D,{}),label:`标题`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:f.title,onChange:e=>p({...f,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),v())},placeholder:`请输入内容`,className:j})}),l(`yearCycle`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`年度周期`,children:(0,F.jsx)(Te,{flat:!0,className:`w-full`,yearCycles:r,value:f.yearCycle,onChange:e=>p({...f,yearCycle:e}),mutate:i,renderTrigger:(e,{empty:t})=>(0,F.jsx)(a,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,l(`planType`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`计划类型`,children:(0,F.jsx)(M,{flat:!0,className:`w-full`,planTypes:s,value:f.planType,onChange:e=>p({...f,planType:e}),mutate:c,renderTrigger:(e,{empty:t})=>(0,F.jsx)(a,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,l(`status`)?(0,F.jsx)(O,{icon:(0,F.jsx)(A,{}),label:`状态`,children:(0,F.jsx)(k,{ariaLabel:`计划状态`,options:I,value:f.status,onChange:e=>p({...f,status:e}),label:S[f.status],optionDotClassName:e=>y[e]})}):null,l(`objectives`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`关联 Objective`,children:(0,F.jsxs)(`div`,{className:`w-full px-0.5 py-0.5`,children:[(0,F.jsx)(Pe,{flat:!0,yearCycle:f.yearCycle,yearPlanId:n.id,objectives:o,values:f.objectiveIds,onChange:e=>p({...f,objectiveIds:e})}),(0,F.jsx)(`p`,{className:`mt-1 px-1.5 text-[11px] leading-4 text-stone-400`,children:`点击查看已关联目标;在 Objective 里选「年度计划」后会自动出现。`})]})}):null,l(`createdAt`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`创建日期`,children:(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:T(n.createdAt)})}):null,l(`updatedAt`)?(0,F.jsx)(O,{icon:(0,F.jsx)(E,{}),label:`修改日期`,children:(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:T(n.updatedAt)})}):null]})}function Le(){let e=se(),{store:t,live:n,error:r,setError:x,updateItem:E,createItems:D,deleteItems:O}=ve(e.ready&&e.on),k=(0,N.useMemo)(()=>({createItems:D,updateItem:E,deleteItems:O}),[D,E,O]),A=(0,N.useMemo)(()=>({createItems:D,updateItem:E,deleteItems:O}),[D,E,O]),j=me(Oe,De),P=(0,N.useMemo)(()=>ie(Ee,j.isVisible),[j.isVisible]),[L,Le]=he(ke),Re=de(),[R,ze]=ne(Ae,je,`none`),[Be,Ve]=(0,N.useState)({}),[z,B]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(null),[V,We]=(0,N.useState)(!1),[H,Ge]=(0,N.useState)(!1),[Ke,U]=(0,N.useState)({}),[W,G]=(0,N.useState)(null),K=d(`life.year-plans.cols.v13`,P),qe=l(`life.year-plans`),q=(0,N.useMemo)(()=>re(xe(t.yearPlans,L),w),[t.yearPlans,L]),J=(0,N.useMemo)(()=>{if(R===`none`)return[{key:`all`,label:`全部计划`,pill:`bg-stone-500 text-white`,items:q}];if(R===`yearCycle`){let e=le(t.yearCycles),n=new Set(e.map(e=>e.id)),r=e.map(e=>({key:`year:${e.id}`,label:e.name,pill:_(e.id),items:q.filter(t=>t.yearCycle===e.id)})).filter(e=>e.items.length>0),i=q.filter(e=>!e.yearCycle||!n.has(e.yearCycle));return i.length>0&&r.push({key:`year:unset`,label:ye,pill:_(``),items:i}),r}return w.map(e=>({key:`status:${e}`,label:S[e],pill:Me[e],items:q.filter(t=>t.status===e)}))},[R,q,t.yearCycles]),Y=(0,N.useMemo)(()=>{if(R===`status`)return J;let e=J.filter(e=>e.items.length>0);return e.length>0?e:R===`none`?J.length>0?J:[{key:`all`,label:`全部计划`,pill:`bg-stone-500 text-white`,items:[]}]:[{key:`year:unset`,label:ye,pill:`bg-stone-300 text-stone-600`,items:[]}]},[R,J]),Je=(0,N.useMemo)(()=>Y.flatMap(e=>e.items.map(e=>e.id)),[Y]),X=h(Je),{submit:Ye}=pe({row:W,setRow:G,submitting:H,isPristine:e=>!e.title.trim()&&e.yearCycle===e.baseYearCycle&&e.planType===e.basePlanType&&e.status===e.baseStatus&&e.objectiveIds.join(`|`)===e.baseObjectiveIds.join(`|`),onSubmit:async e=>{Ge(!0);try{await D(`yearPlans`,[{title:e.title,yearCycle:e.yearCycle,planType:e.planType,status:e.status,objectiveIds:e.objectiveIds}]),G(null),s(`已新增年度计划`,`success`),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),s(`新增失败:${t}`,`error`)}finally{Ge(!1)}}});function Xe(e,t){let n=t?.planType??``,r=t?.status??`in_progress`,i=t?.yearCycle??``;G({groupKey:e,title:``,yearCycle:i,planType:n,status:r,objectiveIds:[],baseYearCycle:i,basePlanType:n,baseStatus:r,baseObjectiveIds:[]}),Ve(t=>({...t,[e]:!1}))}async function Z(e,t){try{await E(`yearPlans`,e,t),U(t=>{let n={...t};return delete n[e],n}),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),s(`保存失败:${t}`,`error`)}}function Ze(e){return{...e,...Ke[e.id]}}function Qe(e,t){U(n=>({...n,[e]:{...n[e],...t}}))}async function $e(e){let t=Ke[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):x(`标题不能为空`)}async function et(e,t){await E(`yearPlans`,t,e),s(`已保存`,`success`)}function Q(){return W?(0,F.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:f,style:Re,children:(0,F.jsx)(`input`,{autoFocus:!0,disabled:H,value:W.title,placeholder:`输入计划名称,回车或点空白处保存`,onChange:e=>G(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Ye()):e.key===`Escape`&&(e.preventDefault(),G(null))},className:_e})}),j.isVisible(`yearCycle`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Te,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:W.yearCycle,onChange:e=>G(t=>t&&{...t,yearCycle:e}),mutate:A})}):null,j.isVisible(`planType`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(M,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:W.planType,onChange:e=>G(t=>t&&{...t,planType:e}),mutate:k})}):null,j.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(o,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`计划状态`,menuMinWidth:120,options:I,value:W.status,onChange:e=>G(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${oe[W.status]}`,renderTrigger:()=>(0,F.jsx)(a,{text:S[W.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${y[e.value]}`})})}):null,j.isVisible(`objectives`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Pe,{yearCycle:W.yearCycle,objectives:t.objectives,values:W.objectiveIds,onChange:e=>G(t=>t&&{...t,objectiveIds:e})})}):null,j.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:`—`,muted:!0})}):null,j.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:`—`,muted:!0})}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:u})]}):null}async function tt(){let e=z;if(e?.length){B(null),We(!0);try{await O(`yearPlans`,e.map(e=>e.id)),X.clear(),s(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){x(e instanceof Error?e.message:String(e))}finally{We(!1)}}}function nt(e,n){let r=Ze(e);return(0,F.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(be,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0}),(0,F.jsx)(`td`,{className:f,style:Re,children:(0,F.jsx)(ae,{value:r.title,placeholder:`标题`,onChange:t=>Qe(e.id,{title:t}),onCommit:()=>void $e(e),onCancel:()=>U(t=>{let n={...t};return delete n[e.id],n})})}),j.isVisible(`yearCycle`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Te,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:r.yearCycle,onChange:t=>void Z(e.id,{yearCycle:t}),mutate:A})}):null,j.isVisible(`planType`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(M,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:r.planType,onChange:t=>void Z(e.id,{planType:t}),mutate:k})}):null,j.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(o,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`计划状态`,menuMinWidth:120,options:I,value:r.status,onChange:t=>void Z(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${oe[r.status]}`,renderTrigger:()=>(0,F.jsx)(a,{text:S[r.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${y[e.value]}`})})}):null,j.isVisible(`objectives`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Pe,{yearCycle:r.yearCycle,yearPlanId:e.id,objectives:t.objectives,values:r.objectiveIds??[],onChange:t=>void Z(e.id,{objectiveIds:t})})}):null,j.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:T(e.createdAt),muted:!e.createdAt})}):null,j.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(b,{text:T(e.updatedAt),muted:!e.updatedAt})}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:u,children:(0,F.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,F.jsx)(ce,{label:`编辑 ${e.title}`,disabled:V,onClick:()=>Ue(e)}),(0,F.jsx)(we,{label:`删除 ${e.title}`,disabled:V,onClick:()=>B([e])})]})})]},e.id)}if(!e.ready)return(0,F.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,F.jsx)(ee,{children:fe()});if(n===null)return(0,F.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,F.jsx)(ee,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=P.length;return(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.yearPlans.length}),` 条`]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:L,onChange:e=>Le(e.target.value),placeholder:`搜索年度计划…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,F.jsx)(o,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Ne,value:R,onChange:e=>ze(e)}),(0,F.jsx)(v,{fields:j.fields,isVisible:j.isVisible,onToggle:j.toggle}),(0,F.jsx)(`button`,{type:`button`,disabled:V||X.selectedIds.length===0,onClick:()=>B(t.yearPlans.filter(e=>X.selected[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,F.jsx)(`button`,{type:`button`,disabled:V||H,onClick:()=>{let e=Y[0];Xe(e?.key??`all`,e?Fe(e.key):void 0)},className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建计划`})]})]}),(0,F.jsx)(Ce,{error:r,onDismiss:()=>x(``)}),(0,F.jsx)(`div`,{ref:qe,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,F.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:K.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:P.map(e=>(0,F.jsx)(`col`,{style:e.key===`select`?{width:te(!1)}:K.widthOf(e.key)?{width:K.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(g,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible()}),(0,F.jsxs)(`th`,{className:`${p} text-xs text-stone-500`,style:Re,children:[`标题`,(0,F.jsx)(m,{...K.resizeProps(`title`)})]}),j.isVisible(`yearCycle`)?(0,F.jsxs)(`th`,{className:C,children:[`年度周期`,(0,F.jsx)(m,{...K.resizeProps(`yearCycle`)})]}):null,j.isVisible(`planType`)?(0,F.jsxs)(`th`,{className:C,children:[`计划类型`,(0,F.jsx)(m,{...K.resizeProps(`planType`)})]}):null,j.isVisible(`status`)?(0,F.jsxs)(`th`,{className:C,children:[`状态`,(0,F.jsx)(m,{...K.resizeProps(`status`)})]}):null,j.isVisible(`objectives`)?(0,F.jsxs)(`th`,{className:C,children:[`关联 Objective`,(0,F.jsx)(m,{...K.resizeProps(`objectives`)})]}):null,j.isVisible(`createdAt`)?(0,F.jsxs)(`th`,{className:C,children:[`创建日期`,(0,F.jsx)(m,{...K.resizeProps(`createdAt`)})]}):null,j.isVisible(`updatedAt`)?(0,F.jsxs)(`th`,{className:C,children:[`修改日期`,(0,F.jsx)(m,{...K.resizeProps(`updatedAt`)})]}):null,(0,F.jsx)(`th`,{"aria-hidden":`true`}),(0,F.jsx)(`th`,{className:c,children:`操作`})]})}),(0,F.jsx)(`tbody`,{children:q.length===0&&!W?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.yearPlans.length===0?`还没有年度计划`:`没有匹配的记录`})}):q.length===0&&W?Q():R===`none`?(0,F.jsxs)(F.Fragment,{children:[q.map((e,t)=>nt(e,t+1)),W?Q():(0,F.jsx)(ge,{colSpan:$,disabled:V||H,onClick:()=>Xe(`all`)})]}):Y.length===0?W?Q():null:Y.map(e=>{let t=!Be[e.key];return(0,F.jsxs)(N.Fragment,{children:[(0,F.jsx)(Se,{label:e.label,pill:e.pill,count:e.items.length,open:t,kind:`tag`,colSpan:$,onToggle:()=>Ve(t=>({...t,[e.key]:!t[e.key]}))}),t?(0,F.jsxs)(F.Fragment,{children:[e.items.map((e,t)=>nt(e,t+1)),W?.groupKey===e.key?Q():q.length>0?(0,F.jsx)(ge,{colSpan:$,disabled:V||H,onClick:()=>Xe(e.key,Fe(e.key))}):null]}):null]},e.key)})})]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`显示 `,q.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`关联 Objective:点击弹出胶囊框;在 Objective 选年度计划后自动带出`})]}),He?(0,F.jsx)(Ie,{open:!0,item:He,yearCycles:t.yearCycles,yearCycleMutate:A,objectives:t.objectives,planTypes:t.planTypes,planTypeMutate:k,isVisible:j.isVisible,onClose:()=>Ue(null),onSave:et}):null,(0,F.jsx)(i,{open:z!=null,title:z&&z.length>1?`批量删除`:`删除年度计划`,message:z&&z.length>1?`删除选中的 ${z.length} 条计划?`:`删除「${z?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>B(null),onConfirm:()=>void tt()})]})}export{Le as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./OverflowHint.CHZeFfUj.js";var a=e(t(),1),o=e(n(),1),s=r();function c({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:c=!1,chips:l=!1,multiline:u=!1,chipsMaxHeight:d,searchable:f=!1,searchPlaceholder:p=`搜索…`,triggerClassName:m=``}){let[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(``),[y,b]=(0,a.useState)({left:0,top:0,width:220,openUp:!1}),x=(0,a.useRef)(null),S=(0,a.useRef)(null),C=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!h){v(``);return}function e(e){let t=e.target;x.current?.contains(t)||S.current?.contains(t)||g(!1)}function t(e){e.target instanceof Node&&S.current?.contains(e.target)||g(!1)}function n(){g(!1)}return document.addEventListener(`mousedown`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,n)}},[h]),(0,a.useEffect)(()=>{if(!h||!f)return;let e=window.setTimeout(()=>C.current?.focus(),0);return()=>window.clearTimeout(e)},[h,f]);let w=(0,a.useMemo)(()=>e.filter(e=>t.includes(e.value)),[e,t]),T=w.map(e=>e.label),E=c||T.length===0?r:T.length<=2?T.join(`、`):`已选 ${T.length} 项`,D=(0,a.useMemo)(()=>{let t=_.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,_]);function O(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}function k(e,r){r.stopPropagation(),n(t.filter(t=>t!==e))}function A(){if(c)return;if(h){g(!1);return}let e=x.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.max(t.width,180),r=Math.min(t.left,Math.max(8,window.innerWidth-n-8)),i=t.bottom+4,a=i+280>window.innerHeight&&t.top>280;b({left:r,top:a?t.top-4:i,width:n,openUp:a}),g(!0)}let j=l||u?`items-start`:`items-center`,M=`${c?`w-full min-h-9 flex ${j} justify-start gap-1 rounded-lg border border-stone-200 bg-stone-50 px-3 py-1.5 text-sm text-left text-stone-400 cursor-not-allowed`:`tw-field-trigger w-full min-h-9 flex ${j} justify-start gap-1 rounded-lg border border-stone-200 bg-white px-3 py-1.5 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`} ${m}`,N=null;return h&&typeof document<`u`&&(N=(0,o.createPortal)((0,s.jsxs)(`div`,{ref:S,className:`tw-select-menu tw-dsh-scroll tw-popover-anim fixed z-[1000] max-h-72 overflow-auto rounded-lg p-1.5 shadow-lg ring-1 ring-stone-200`,style:{left:y.left,width:y.width,...y.openUp?{bottom:window.innerHeight-y.top}:{top:y.top}},children:[f?(0,s.jsx)(`div`,{className:`sticky top-0 z-10 bg-white px-0.5 pb-2 pt-0.5`,children:(0,s.jsx)(`input`,{ref:C,type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:p,className:`h-8 w-full rounded-md border border-stone-200 bg-stone-50 px-2.5 text-xs text-stone-700 outline-none focus:border-[#4176e6]/40 focus:bg-white`,onClick:e=>e.stopPropagation()})}):null,D.length===0?(0,s.jsx)(`div`,{className:`px-3 py-2.5 text-sm text-stone-400`,children:`暂无可选项`}):(0,s.jsx)(`div`,{className:`flex flex-col gap-1`,children:D.map(e=>{let n=t.includes(e.value);return l?(0,s.jsxs)(`button`,{type:`button`,onClick:()=>O(e.value),className:`flex w-full items-start gap-2 rounded-md px-3 py-2.5 text-left text-sm transition-colors ${n?`bg-[#e8f0fe] text-[#1f4ec2]`:`text-stone-700 hover:bg-stone-50`}`,children:[(0,s.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words leading-5`,children:e.label}),n?(0,s.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[12px] font-medium text-[#3370ff]`,"aria-hidden":!0,children:`✓`}):null]},e.value):(0,s.jsxs)(`label`,{className:`flex cursor-pointer gap-2 rounded-md px-3 py-2 text-sm text-stone-700 hover:bg-stone-50 ${u?`items-start`:`items-center`}`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>O(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40 ${u?`mt-0.5`:``}`}),u?(0,s.jsx)(`span`,{className:`block min-w-0 flex-1 whitespace-pre-wrap break-words leading-5`,children:e.label}):(0,s.jsx)(i,{text:e.label,className:`block min-w-0 flex-1 truncate`})]},e.value)})})]}),document.body)),(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`button`,{ref:x,type:`button`,disabled:c,"aria-expanded":h,onClick:A,className:M,children:l?(0,s.jsx)(`span`,{className:`tw-dsh-scroll flex min-w-0 flex-1 flex-wrap content-start items-center gap-1.5 py-0.5 text-left`,style:d?{maxHeight:d,overflowY:`auto`}:void 0,onWheel:e=>{d&&e.stopPropagation()},children:w.length===0?(0,s.jsx)(`span`,{className:`text-stone-400`,children:r}):w.map(e=>(0,s.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-full bg-[#e8f0fe] px-2.5 py-0.5 text-[12px] leading-5 text-[#1f4ec2]`,children:[(0,s.jsx)(`span`,{className:`min-w-0 break-words whitespace-pre-wrap`,children:e.label}),c?null:(0,s.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`移除 ${e.label}`,className:`shrink-0 rounded-full px-0.5 text-[#5b7fd4] hover:bg-[#d2e3fc] hover:text-[#1f4ec2]`,onClick:t=>k(e.value,t),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),k(e.value,t))},children:`×`})]},e.value))}):u?(0,s.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 py-0.5 text-left`,children:w.length===0?(0,s.jsx)(`span`,{className:`text-stone-400`,children:r}):w.map(e=>(0,s.jsx)(`span`,{className:`block min-w-0 whitespace-pre-wrap break-words leading-5`,children:e.label},e.value))}):(0,s.jsx)(i,{text:E,className:`block min-w-0 flex-1 truncate ${c||T.length?``:`text-stone-400`}`})}),N]})}export{c as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{A as n,C as r,D as i,E as a,F as o,I as s,L as c,M as l,N as u,O as d,P as f,R as p,S as m,T as h,_ as g,a as _,b as v,g as y,h as b,i as x,j as S,k as C,m as w,p as T,r as E,t as D,u as O,v as ee,w as te,x as k,y as A}from"./app-config.DkyjuL-S.js";import{a as j,i as M,o as ne}from"./plugins.BRvXWHLe.js";import{t as N}from"./react-dom.DLW9pGCF.js";import{i as P,n as F,r as I,t as L}from"./dialog.DZHZCe_T.js";import{t as R}from"./jsx-runtime.DUg_B_vD.js";import{t as re}from"./ConfirmDialog.DrrPf1MB.js";import{showToast as z}from"./Toast.BO2NFckG.js";import{n as B}from"./i18n.D_aOCHSN.js";import{n as ie}from"./hydrate-cache.B15Nrpq0.js";var V=e(t(),1),H=e(N(),1),U=`/__tb_nav/groups`;function ae(){return E().navGroups}function oe(){return d(E().navIcons)}function se(e,t){let n={...oe(),[e]:t};return O({navIcons:n}),D(),n}function ce(){return E().navOrder}function le(e,t){let n=i(e),r=C(t,n);return O({navGroups:n,navOrder:r}),D(),{groups:n,order:r}}function W(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function ue(e){if(!_())return null;try{let t=await fetch(U,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groups:e}),signal:AbortSignal.timeout(4e3)});if(!t.ok)return null;let n=await t.json();return{groups:i(n.groups,!1),warnings:Array.isArray(n.warnings)?n.warnings.filter(e=>typeof e==`string`):[]}}catch{return null}}async function de(){if(!_())return;let e=E(),t=null;try{let e=await fetch(U,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=i(t.groups,!1),r=C(e.navOrder,n);(!W(n,e.navGroups)||!W(r,e.navOrder))&&(O({navGroups:n,navOrder:r}),D());return}if(!e.navGroups.length)return;let n=await ue(e.navGroups);n&&!W(n.groups,e.navGroups)&&(O({navGroups:n.groups,navOrder:C(e.navOrder,n.groups)}),D())}function G(e,t,n){let[r,i]=(0,V.useState)(null),a=(0,V.useRef)(null),o=(0,V.useRef)(e);o.current=e;let s=(0,V.useRef)(t);s.current=t;let l=(0,V.useRef)(n);l.current=n;function u(e,t){if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let n=a.current;if(!n)return;i(e);let r=e=>{let t=[...n.querySelectorAll(`[data-sort-key]`)];for(let n of t){let t=n.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return n.dataset.sortKey}return null},u=t=>{let n=r(t.clientY);if(!n||n===e)return;let i=c(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,s.current(i))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),i(null),l.current?.()};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)}return{listRef:a,dragId:r,onPointerDown:u}}var K=R(),q=`/`;function fe(e){return`${q.endsWith(`/`)?q:`${q}/`}${e.replace(/^\//,``)}`}function pe(e,t){let n=q.replace(/\/$/,``),r=e.slice(n.length).replace(/^\/+/,``);return r===t||r.startsWith(`${t}/`)}function me(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function he(e){return T(`tw.nav.groupOpen.${e}`)}function ge(){return T(`tw.nav.docsOpen`)}function _e(e,t){try{let t=localStorage.getItem(he(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(ge());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function ve(e,t){try{localStorage.setItem(he(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(ge(),t?`1`:`0`)}catch{}}function J(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?B(`nav.docs`):e.name.replace(/ \(\d+\)$/,``).replace(/ \(分组\)$/,``).trim()||e.name}function Y(e){return e.type===`group`?J(e.group):B(v(e.id).i18n)}function X(e){return e.type===`item`?te(e.id):k(e.group.id)}function ye(){let[e,t]=(0,V.useState)(()=>window.location.pathname);return(0,V.useEffect)(()=>{let e=()=>t(window.location.pathname);return document.addEventListener(`astro:page-load`,e),document.addEventListener(`astro:after-swap`,e),window.addEventListener(`popstate`,e),()=>{document.removeEventListener(`astro:page-load`,e),document.removeEventListener(`astro:after-swap`,e),window.removeEventListener(`popstate`,e)}},[]),e}function Z({children:e}){return(0,K.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function Q({id:e,icon:t}){return(0,K.jsx)(Z,{children:be[t??w[e]]})}var be={dashboard:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,K.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,K.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,K.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),check:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,K.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]}),pencil:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 20h9`}),(0,K.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,K.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),fileText:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M14 3v5h5`}),(0,K.jsx)(`path`,{d:`M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z`}),(0,K.jsx)(`path`,{d:`M8 13h8`}),(0,K.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,K.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M8 6h13`}),(0,K.jsx)(`path`,{d:`M8 12h13`}),(0,K.jsx)(`path`,{d:`M8 18h13`}),(0,K.jsx)(`path`,{d:`M3 6h.01`}),(0,K.jsx)(`path`,{d:`M3 12h.01`}),(0,K.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,K.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`}),star:(0,K.jsx)(`path`,{d:`m12 3 2.1 5.9L20 11l-5 4.3 1.7 6.2-5.7-3.9-5.7 3.9L7 15.3 2 11l5.9-2.1L12 3z`}),database:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,K.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,K.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,K.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M9 3h6`}),(0,K.jsx)(`path`,{d:`M10 3v6l-5 8a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-8V3`}),(0,K.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,K.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,K.jsx)(`path`,{d:`M8 4H6a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2`})]}),bug:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,K.jsx)(`path`,{d:`M9 6l2 2`}),(0,K.jsx)(`path`,{d:`M15 6l-2 2`}),(0,K.jsx)(`path`,{d:`M7 11H4`}),(0,K.jsx)(`path`,{d:`M20 11h-3`}),(0,K.jsx)(`path`,{d:`M7 17H4`}),(0,K.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,K.jsx)(`path`,{d:`M8 3v4`}),(0,K.jsx)(`path`,{d:`M16 3v4`}),(0,K.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M4 20V10`}),(0,K.jsx)(`path`,{d:`M10 20V4`}),(0,K.jsx)(`path`,{d:`M16 20v-7`}),(0,K.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,K.jsx)(`path`,{d:`M3 12h18`}),(0,K.jsx)(`path`,{d:`M12 3c2.5 2.5 4 5.7 4 9s-1.5 6.5-4 9c-2.5-2.5-4-5.7-4-9s1.5-6.5 4-9z`})]}),link:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M10 13a4 4 0 0 0 5.7 0l2.3-2.3a4 4 0 0 0-5.7-5.7L11 6.3`}),(0,K.jsx)(`path`,{d:`M14 11a4 4 0 0 0-5.7 0L6 13.3a4 4 0 0 0 5.7 5.7L13 17.7`})]}),users:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,K.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,K.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,K.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,K.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0l-7.2-7.2a2 2 0 0 1-.6-1.4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 1.4.6l6.2 6.2a2 2 0 0 1 0 2.6z`}),(0,K.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M5 21V4`}),(0,K.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,K.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`}),search:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,K.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),settings:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,K.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.1-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.9.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),bell:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M18 8a6 6 0 1 0-12 0c0 5-2 6-2 6h16s-2-1-2-6`}),(0,K.jsx)(`path`,{d:`M10.3 20a2 2 0 0 0 3.4 0`})]}),clock:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,K.jsx)(`path`,{d:`M12 7v5l3.5 2`})]}),mail:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),(0,K.jsx)(`path`,{d:`m3.5 7 8.5 6 8.5-6`})]}),message:(0,K.jsx)(`path`,{d:`M21 12a8 8 0 0 1-8 8H8l-5 3 1.4-4.6A8 8 0 1 1 21 12z`}),image:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,K.jsx)(`circle`,{cx:`8.5`,cy:`9.5`,r:`1.5`}),(0,K.jsx)(`path`,{d:`m4 17 5-5 3.5 3.5L16 11l4 4.5`})]}),video:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`6`,width:`12`,height:`12`,rx:`2`}),(0,K.jsx)(`path`,{d:`m15 11 6-3.5v9L15 13`})]}),download:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 3v12`}),(0,K.jsx)(`path`,{d:`m7 10 5 5 5-5`}),(0,K.jsx)(`path`,{d:`M4 20h16`})]}),upload:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 16V4`}),(0,K.jsx)(`path`,{d:`m7 9 5-5 5 5`}),(0,K.jsx)(`path`,{d:`M4 20h16`})]}),plus:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 5v14`}),(0,K.jsx)(`path`,{d:`M5 12h14`})]}),trash:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M4 7h16`}),(0,K.jsx)(`path`,{d:`M9 7V4h6v3`}),(0,K.jsx)(`path`,{d:`M6 7l1 13h10l1-13`}),(0,K.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),lock:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`4`,y:`10`,width:`16`,height:`11`,rx:`2`}),(0,K.jsx)(`path`,{d:`M8 10V7a4 4 0 0 1 8 0v3`})]}),shield:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 3l7 3v6c0 4.2-2.9 7.5-7 9-4.1-1.5-7-4.8-7-9V6l7-3z`}),(0,K.jsx)(`path`,{d:`m9 12 2 2 4-4`})]}),key:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`8`,cy:`12`,r:`4`}),(0,K.jsx)(`path`,{d:`M12 12h9`}),(0,K.jsx)(`path`,{d:`M17 12v4M20 12v3`})]}),cloud:(0,K.jsx)(`path`,{d:`M7 18h10a4 4 0 0 0 .5-8 6 6 0 0 0-11.4 1.5A3.5 3.5 0 0 0 7 18z`}),box:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`m12 3 8 4.5v9L12 21l-8-4.5v-9L12 3z`}),(0,K.jsx)(`path`,{d:`m4 7.5 8 4.5 8-4.5`}),(0,K.jsx)(`path`,{d:`M12 12v9`})]}),filter:(0,K.jsx)(`path`,{d:`M3 5h18l-7 8v6l-4 2v-8L3 5z`}),grid:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`4`,y:`4`,width:`6.5`,height:`6.5`,rx:`1`}),(0,K.jsx)(`rect`,{x:`13.5`,y:`4`,width:`6.5`,height:`6.5`,rx:`1`}),(0,K.jsx)(`rect`,{x:`4`,y:`13.5`,width:`6.5`,height:`6.5`,rx:`1`}),(0,K.jsx)(`rect`,{x:`13.5`,y:`13.5`,width:`6.5`,height:`6.5`,rx:`1`})]}),pin:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 21v-7`}),(0,K.jsx)(`path`,{d:`M8 4h8l-1 6 3 3H6l3-3-1-6z`})]}),sparkle:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`m12 3 1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z`}),(0,K.jsx)(`path`,{d:`M18 16.5 18.7 18.3 20.5 19 18.7 19.7 18 21.5 17.3 19.7 15.5 19 17.3 18.3 18 16.5z`})]}),rocket:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M13.5 4.5c3-2 5.5-1.5 5.5-1.5s.5 2.5-1.5 5.5c-1.6 2.4-4.5 5-6.5 6.5l-3.5-3.5c1.5-2 4.1-4.9 6-7z`}),(0,K.jsx)(`path`,{d:`M8 12 5 13l-2 4 5-1`}),(0,K.jsx)(`path`,{d:`M12 16l-1 3 4-2 1-3`}),(0,K.jsx)(`circle`,{cx:`15`,cy:`9`,r:`1.2`})]}),eye:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M2.5 12S6 6 12 6s9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6z`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.8`})]}),bookmark:(0,K.jsx)(`path`,{d:`M7 3h10a1 1 0 0 1 1 1v17l-6-4-6 4V4a1 1 0 0 1 1-1z`}),archive:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`4`,rx:`1`}),(0,K.jsx)(`path`,{d:`M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8`}),(0,K.jsx)(`path`,{d:`M10 12h4`})]}),refresh:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M20 12a8 8 0 1 1-2.4-5.7`}),(0,K.jsx)(`path`,{d:`M20 4v5h-5`})]}),play:(0,K.jsx)(`path`,{d:`M8 5v14l11-7L8 5z`}),map:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`m3 6 6-2 6 2 6-2v14l-6 2-6-2-6 2V6z`}),(0,K.jsx)(`path`,{d:`M9 4v14M15 6v14`})]}),activity:(0,K.jsx)(`path`,{d:`M3 12h4l3-7 4 14 3-7h4`}),cpu:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`}),(0,K.jsx)(`path`,{d:`M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4`})]}),briefcase:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`8`,width:`18`,height:`12`,rx:`2`}),(0,K.jsx)(`path`,{d:`M9 8V5h6v3`}),(0,K.jsx)(`path`,{d:`M3 13h18`})]}),presentation:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,K.jsx)(`path`,{d:`M12 16v4`}),(0,K.jsx)(`path`,{d:`m8 22 4-4 4 4`}),(0,K.jsx)(`path`,{d:`M8 8h8M8 12h5`})]}),copy:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,K.jsx)(`path`,{d:`M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2`})]}),save:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z`}),(0,K.jsx)(`path`,{d:`M7 3v6h9`}),(0,K.jsx)(`path`,{d:`M8 21v-6h8v6`})]})};function xe(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--closed`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,K.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`})}),(0,K.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--open`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,K.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`})})]})}function Se(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,K.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function Ce(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,K.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function we(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,K.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,K.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function Te(){return(0,K.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,K.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 Ee(){return(0,K.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,K.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,K.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function De(){return(0,K.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,K.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,K.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function Oe(){return(0,K.jsxs)(Z,{children:[(0,K.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,K.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,K.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function ke(){return(0,K.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,K.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function $(e,t){if(r(e))return!1;let n=v(e).plugin;return!n||t[n]!==!1}function Ae({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let o=v(e),s=a(n,q)?.id===e;return(0,K.jsxs)(`div`,{className:[me(s),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":o.plugin,children:[(0,K.jsxs)(`a`,{href:fe(o.href),className:`tw-nav-item-main`,children:[(0,K.jsx)(Q,{id:e,icon:t}),(0,K.jsx)(`span`,{className:`tw-nav-label`,children:B(o.i18n)})]}),(0,K.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":B(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,K.jsx)(we,{})})]})}function je(e,t,n){return e.items.some(e=>{if(r(e))return!1;let t=v(e).plugin;return(!t||M(t))&&pe(n,v(e).match)})?!0:h(t,e.id).some(e=>je(e,t,n))}function Me(e,t){return e.items.some(e=>{if(r(e))return!1;let t=v(e).plugin;return!t||M(t)})?!0:h(t,e.id).some(e=>Me(e,t))}function Ne({group:e,groups:t,order:n,icons:i,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l}){let u=e.items.filter(e=>{if(r(e))return!1;let t=v(e).plugin;return!t||M(t)}),d=f(t,e.id,n),p=je(e,t,a),[m,h]=(0,V.useState)(()=>_e(e.id,!0)),[g,_]=(0,V.useState)(!1),y=(0,V.useRef)(null),b=(0,V.useRef)(null),x=(0,V.useRef)(null);if((0,V.useEffect)(()=>S,[]),!Me(e,t))return null;function S(){x.current&&y.current&&y.current.removeEventListener(`transitionend`,x.current),x.current=null,b.current!==null&&(window.clearTimeout(b.current),b.current=null)}function C(){S(),ve(e.id,!0),_(!1),h(!0)}function w(t){if(t.preventDefault(),!m||g){C();return}_(!0),ve(e.id,!1);let n=y.current,r=!1,i=()=>{r||(r=!0,S(),h(!1),_(!1))},a=e=>{e.target===n&&e.propertyName===`grid-template-rows`&&i()};S(),x.current=a,n?.addEventListener(`transitionend`,a),b.current=window.setTimeout(i,360)}return(0,K.jsxs)(`details`,{className:`tw-nav-details ${g?`is-closing`:``}`,open:m||g,"data-nav-group":e.id,children:[(0,K.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,p?`is-branch-active`:``,s===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:w,children:[(0,K.jsx)(xe,{}),(0,K.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:J(e)}),(0,K.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":B(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),c(e,t.currentTarget)},children:(0,K.jsx)(Se,{})}),(0,K.jsx)(`svg`,{className:`tw-nav-chevron opacity-70`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,K.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,K.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:y,children:(0,K.jsxs)(`div`,{className:`tw-nav-subtree`,children:[u.map(e=>(0,K.jsx)(Ae,{id:e,icon:i[e],pathname:a,actionOpen:o===e,onMenu:t=>l(e,t)},e)),d.map(e=>(0,K.jsx)(Ne,{group:e,groups:t,order:n,icons:i,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l},e.id))]})})]})}function Pe({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)([]),[f,p]=(0,V.useState)(``),m=(0,V.useRef)(null),h=new Set(n.filter(e=>e.id!==t?.id).flatMap(e=>e.items)),g=b.filter(e=>$(e.id,r)&&(!h.has(e.id)||u.includes(e.id))),_=G(u,d);(0,V.useEffect)(()=>{if(!e||!t)return;l(t.name),d(t.items.filter(e=>$(e,r))),p(``);let n=window.setTimeout(()=>{m.current?.focus(),m.current?.select()},50);return()=>window.clearTimeout(n)},[e,t,r]);function v(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function y(){let e=c.trim();if(!e){p(B(`nav.groupNameRequired`));return}if(!u.length){p(B(`nav.groupItemsRequired`));return}let n=(t?.items??[]).filter(e=>!$(e,r));o({id:t?.id,name:e,items:[...n,...u],parentId:t?.parentId})}let x=[...u.map(e=>g.find(t=>t.id===e)).filter(e=>!!e),...g.filter(e=>!u.includes(e.id))];return(0,K.jsxs)(I,{open:e,onClose:a,className:`relative z-110`,children:[(0,K.jsx)(L,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,K.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,K.jsxs)(P,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,K.jsx)(F,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?B(`nav.editGroupTitle`):t?.parentId?B(`nav.addSubgroup`):B(`nav.createGroup`)}),(0,K.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[B(`nav.groupName`),(0,K.jsx)(`input`,{ref:m,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),y())},className:`mt-1.5 w-full h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`})]}),(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:B(`nav.groupItems`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:B(`nav.groupItemsHint`)}),(0,K.jsxs)(`div`,{ref:_.listRef,className:`mt-2 max-h-52 overflow-auto rounded-lg border border-stone-200 p-1`,children:[x.map(e=>{let t=u.includes(e.id);return(0,K.jsxs)(`label`,{"data-sort-key":t?e.id:void 0,className:[`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,t?`tw-nav-drag-row`:``,_.dragId===e.id?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t?t=>{t.target.closest(`input`)||_.onPointerDown(e.id,t)}:void 0,children:[t?(0,K.jsx)(ke,{}):(0,K.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,K.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>v(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,K.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,K.jsx)(Q,{id:e.id,icon:i[e.id]})}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B(e.i18n)})]},e.id)}),x.length?null:(0,K.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:B(`nav.noAddableItems`)})]})]}),f?(0,K.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,K.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,K.jsx)(`button`,{type:`button`,onClick:s,className:`h-8 px-3 text-sm rounded-lg border border-red-200 text-red-600 hover:bg-red-50`,children:B(`nav.deleteGroup`)}):null,(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsx)(`button`,{type:`button`,onClick:a,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100`,children:B(`nav.groupCancel`)}),(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:B(`nav.groupSave`)})]})]})})]})}function Fe({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=G(e,n,r);return(0,K.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,K.jsxs)(`div`,{"data-sort-key":e,className:[`tw-nav-drag-row px-3 py-2 text-sm text-stone-700 hover:bg-stone-50`,i?`tw-nav-drag-row--nested`:``,a.dragId===e?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t=>a.onPointerDown(e,t),children:[(0,K.jsx)(ke,{}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function Ie({open:e,focusGroupId:t,nodes:n,groups:r,order:i,visible:a,onClose:o,onCommit:s,onChildCommit:c}){let l=e=>!a||a(e),u=e=>e.items.some(l)||r.filter(t=>t.parentId===e.id).some(e=>u(e)),d=n.filter(e=>e.type===`item`?l(e.id):u(e.group)),[p,m]=(0,V.useState)(()=>d.map(X)),[h,g]=(0,V.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),[_,y]=(0,V.useState)([]),b=(0,V.useRef)(p);b.current=p;let x=(0,V.useRef)(h);x.current=h;let S=(0,V.useRef)(r);S.current=r;let C=(0,V.useRef)(i);C.current=i;let w=(0,V.useRef)(d);w.current=d;let T=(0,V.useRef)(_);T.current=_;let E=()=>{let e=S.current.map(e=>({...e,items:x.current[e.id]??e.items}));s(b.current,e)},D=()=>{t&&c(t,T.current)};(0,V.useEffect)(()=>{if(!e)return;let n=w.current.map(X);b.current=n,m(n);let r=Object.fromEntries(S.current.map(e=>[e.id,[...e.items]]));x.current=r,g(r);let i=t?f(S.current,t,C.current).map(e=>e.id):[];T.current=i,y(i)},[e,t]);let O=e=>{b.current=e,m(e)},ee=e=>{T.current=e,y(e)},te=(e,t)=>{let n=(x.current[e]??[]).filter(e=>!l(e)),r={...x.current,[e]:t.length?[...t,...n]:n};x.current=r,g(r)},k=new Map(d.map(e=>[X(e),Y(e)])),A=t?r.find(e=>e.id===t):void 0,j=A?(h[A.id]??A.items).filter(l):[],M=A?f(r,A.id,i):[],ne=_.length?_:M.map(e=>e.id);return(0,K.jsxs)(I,{open:e,onClose:o,className:`relative z-110`,children:[(0,K.jsx)(L,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,K.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,K.jsxs)(P,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,K.jsx)(F,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:B(`nav.sortMenuTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:B(`nav.sortHint`)}),(0,K.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:A?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Fe,{ids:j,labelOf:e=>B(v(e).i18n),onChange:e=>te(A.id,e),onEnd:E,indent:!0}),ne.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mt-1 border-t border-stone-100 px-3 pb-1 pt-2 text-[11px] font-medium text-stone-400`,children:B(`nav.subgroups`)}),(0,K.jsx)(Fe,{ids:ne,labelOf:e=>{let t=r.find(t=>t.id===e);return t?J(t):e},onChange:ee,onEnd:D,indent:!0})]}):null]}):(0,K.jsx)(Fe,{ids:p,labelOf:e=>k.get(e)??e,onChange:O,onEnd:E})})]})})]})}function Le(e,t){let n=[];for(let r of e.filter(e=>!e.parentId)){n.push({group:r,indent:!1});for(let i of f(e,r.id,t))n.push({group:i,indent:!0})}return n}function Re(){return(0,K.jsx)(`svg`,{className:`tw-nav-group-pop-arrow`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,K.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var ze=120;function Be(){let[e,t]=(0,V.useState)(null),n=(0,V.useRef)(null),r=(0,V.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,V.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,V.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},ze)},[r]),o=(0,V.useCallback)(()=>{r(),t(null)},[r]);return(0,V.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Ve(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function He({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,V.useRef)(null),[c,l]=(0,V.useState)({top:e.top,left:e.right+8});return(0,V.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+8,a=e.top-6;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),a<8&&(a=8),l({top:a,left:i})},[e]),(0,H.createPortal)((0,K.jsxs)(`div`,{ref:s,className:[`tw-nav-group-pop`,`tw-nav-icon-pop`,r?`is-closing`:``].filter(Boolean).join(` `),style:{top:c.top,left:c.left},...Ve(a,o),children:[(0,K.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:B(`nav.chooseIcon`)}),(0,K.jsx)(`div`,{className:`tw-nav-icon-grid`,children:y.map(e=>(0,K.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,K.jsx)(Q,{id:n,icon:e})},e))})]}),document.body)}function Ue({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,V.useRef)(null),[s,c]=(0,V.useState)({top:e.top,left:e.right+6});return(0,V.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+6,a=e.top;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),c({top:a,left:i})},[e]),(0,V.useEffect)(()=>{let e=e=>{let t=e.target;o.current?.contains(t)||t?.closest?.(`.tw-nav-icon-pop`)||t?.closest?.(`.tw-nav-hover-btn`)||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n)}},[n]),(0,H.createPortal)((0,K.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Ve(r,i),children:a}),document.body)}function We(){let e=ye(),[t,r]=(0,V.useState)(()=>ae()),[i,a]=(0,V.useState)(()=>oe()),[c,d]=(0,V.useState)(()=>ce()),[f,h]=(0,V.useState)(()=>j()),[_,y]=(0,V.useState)(null),[b,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)(!1),[O,te]=(0,V.useState)(null),k=Be(),M=Be(),N=k.value,P=M.value,F=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{F.current!==null&&window.clearTimeout(F.current)},[]);function I(e){te(e),D(!0)}function L(e){y(e),C(!0)}function R(){C(!1),T(null)}(0,V.useEffect)(()=>{let e=!0,t=ne(e=>{h({...e})});return x().then(async()=>{e&&(await de(),e&&(r(ae()),d(ce()),a(oe()),h(j())))}),()=>{e=!1,t()}},[]);let H=ee(t,c);(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{let e=document.querySelector(`.tw-nav-libraries > astro-island`);e&&e.querySelector(`.tw-nav-item-main`)&&ie(`nav`,e.innerHTML)},400);return()=>window.clearTimeout(e)});function U(e,t){let n=le(e,t);r(n.groups),d(n.order),ue(n.groups).then(e=>{if(!e||(e.warnings.length&&z(`分组已保存,但${e.warnings[0]}`,`error`),JSON.stringify(e.groups)===JSON.stringify(n.groups)))return;let t=le(e.groups,n.order);r(t.groups),d(t.order)})}function W(){G(),M.close(),k.close()}function G(){F.current!==null&&(window.clearTimeout(F.current),F.current=null)}function q(){G(),F.current=window.setTimeout(()=>{F.current=null,M.close()},220)}function fe(e,t){G(),M.open({itemId:e,rect:t.getBoundingClientRect()})}function pe(e,t){N?.kind===`itemMenu`&&N.itemId===e?W():(M.closeNow(),k.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function me(e,t){N?.kind===`groupMenu`&&N.group.id===e.id?W():(M.closeNow(),k.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function he(e,n){U(g(t,e,n),c),W();let r=t.find(t=>t.id===e);z(`已加入分组「${r?J(r):``}」`,`success`)}function ge(e){let{groups:n,owner:r}=o(t,e);U(n,r?S(c,e,r,n):c),W(),z(`已移出分组`,`success`)}let _e=N?.kind===`assign`||N?.kind===`itemMenu`?N.itemId:void 0,ve=N?.kind===`groupMenu`?N.group.id:void 0,Y=N?.kind===`itemMenu`?N:null,X=N?.kind===`groupMenu`?N:null,Z=N?.kind===`assign`?N:null,Q=Y?t.find(e=>e.items.includes(Y.itemId))??null:null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),H.map(n=>n.type===`item`?$(n.id,f)?(0,K.jsx)(Ae,{id:n.id,icon:i[n.id],pathname:e,actionOpen:_e===n.id,onMenu:e=>pe(n.id,e)},n.id):null:(0,K.jsx)(Ne,{group:n.group,groups:t,order:c,icons:i,pathname:e,openItem:_e,openGroupId:ve,onMenu:me,onItemMenu:pe},n.group.id)),Y?(0,K.jsxs)(Ue,{rect:Y.rect,closing:k.closing,onClose:W,onHoverEnter:G,onHoverLeave:q,children:[(0,K.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:B(v(Y.itemId).i18n)}),(0,K.jsxs)(`div`,{className:`tw-nav-group-pop-list`,onMouseOver:e=>{let t=e.target.closest(`.tw-nav-group-pop-item`);t&&t.getAttribute(`data-submenu`)!==`icons`&&(G(),M.close())},children:[Q?(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>ge(Y.itemId),children:[(0,K.jsx)(Ee,{}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.leaveGroup`)})]}):null,(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>k.open({kind:`assign`,itemId:Y.itemId,rect:Y.rect}),children:[(0,K.jsx)(Te,{}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.assignGroup`)})]}),Q?null:(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Y.itemId;W(),L({name:``,items:[e]})},children:[(0,K.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,K.jsx)(Ce,{})}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.addToGroup`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Q?.id??null;W(),I(e)},children:[(0,K.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,K.jsx)(Oe,{})}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.sortMenu`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,"data-submenu":`icons`,onMouseEnter:e=>fe(Y.itemId,e.currentTarget),onClick:e=>fe(Y.itemId,e.currentTarget),children:[(0,K.jsx)(De,{}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.chooseIcon`)}),(0,K.jsx)(Re,{})]})]})]}):null,P&&Y&&P.itemId===Y.itemId?(0,K.jsx)(He,{anchor:P.rect,itemId:P.itemId,current:i[P.itemId],closing:M.closing,onHoverEnter:G,onHoverLeave:q,onPick:e=>{a(se(P.itemId,e)),W(),z(`已更换图标`,`success`)}}):null,X?(0,K.jsxs)(Ue,{rect:X.rect,closing:k.closing,onClose:W,children:[(0,K.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:J(X.group)}),(0,K.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[X.group.parentId?null:(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-create`,onClick:()=>{let e=X.group.id;W(),L({name:``,items:[],parentId:e})},children:[(0,K.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,K.jsx)(Ce,{})}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.addSubgroup`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.group;W(),I(e.parentId??null)},children:[(0,K.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,K.jsx)(Oe,{})}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.sortMenu`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.group;W(),L({id:e.id,name:e.name,items:[...e.items],parentId:e.parentId})},children:[(0,K.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,K.jsx)(Se,{})}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:B(`nav.editGroupTitle`)})]})]})]}):null,Z?(0,K.jsxs)(Ue,{rect:Z.rect,closing:k.closing,onClose:W,children:[(0,K.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:B(`nav.assignGroup`)}),(0,K.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:(()=>{let e=t.find(e=>e.items.includes(Z.itemId))?.id??null,n=Le(t,c).filter(({group:t})=>t.id!==e);return n.length?n.map(({group:e,indent:t})=>(0,K.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>he(e.id,Z.itemId),children:[(0,K.jsx)(Te,{}),(0,K.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:J(e)})]},e.id)):(0,K.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:B(e?`nav.noOtherGroups`:`nav.noGroups`)})})()})]}):null,(0,K.jsx)(Pe,{open:b&&!w,draft:_,groups:t,plugins:f,icons:i,onClose:R,onSave:e=>{let n=!t.some(t=>t.id===e.id),r=p(t,e);U(r.groups,u(c,r.groups,r.id));let i=r.groups.find(e=>e.id===r.id);z(n?`已新增分组「${i?J(i):e.name}」`:`已保存分组`,`success`),R()},onDelete:_?.id?()=>T(_.id):void 0}),(0,K.jsx)(Ie,{open:E,focusGroupId:O,nodes:H,groups:t,order:c,visible:e=>$(e,f),onClose:()=>D(!1),onCommit:(e,t)=>{let n=c.filter(e=>m(e,t));U(t,[...e,...n.filter(t=>!e.includes(t))])},onChildCommit:(e,r)=>U(t,n(c,t,e,r))}),(0,K.jsx)(re,{open:!!w,title:B(`nav.deleteGroup`),message:t.find(e=>e.id===w)?.parentId?B(`nav.deleteSubgroupMsg`):B(`nav.deleteGroupMsg`),confirmLabel:B(`nav.deleteGroup`),cancelLabel:B(`nav.groupCancel`),danger:`outline`,onClose:()=>T(null),onConfirm:()=>{if(w){let e=t.find(e=>e.id===w),n=A(t,w),r=s(t,w);U(r,e?l(c,e,r,n):c),e&&z(`已删除分组「${J(e)}」`,`success`)}R()}})]})}export{We as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";var i=e(t(),1),a=e(n(),1),o=r(),s=80,c=420,l=14,u=150;function d({text:e,className:t,disabled:n=!1,matchAnchorWidth:r=!1,clamp:d=`x`,zIndex:f=s}){let p=(0,i.useRef)(null),[m,h]=(0,i.useState)(!1),[g,_]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[b,x]=(0,i.useState)(!1),[S,C]=(0,i.useState)(null);(0,i.useLayoutEffect)(()=>{let e=p.current;if(!e)return;let t=()=>h(d!==`y`&&e.scrollWidth>e.clientWidth+1||d!==`x`&&e.scrollHeight>e.clientHeight+1);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[e,d]),(0,i.useLayoutEffect)(()=>{(n||!m)&&_(!1)},[n,m]),(0,i.useLayoutEffect)(()=>{if(g){y(!0);let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>x(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}}x(!1);let e=window.setTimeout(()=>y(!1),u);return()=>window.clearTimeout(e)},[g]);let w=(0,i.useCallback)(()=>{let e=p.current;if(!e)return;let t=e.getBoundingClientRect(),n=(r?e.closest(`[data-hint-width]`)??e:e).getBoundingClientRect(),i=r?n.width:t.width,a=Math.min(Math.max(i,160),c),o=t.bottom+72>window.innerHeight-8,s=o?t.top-6:t.bottom+6,u=r?n.left:t.left,d=Math.max(8,Math.min(u,Math.max(8,window.innerWidth-a-8))),f=Math.max(l,Math.min(t.left+t.width/2-d,a-l));C(e=>e&&e.top===s&&e.left===d&&e.maxWidth===a&&e.openUp===o&&e.arrowLeft===f?e:{top:s,left:d,maxWidth:a,openUp:o,arrowLeft:f})},[r]);return(0,i.useLayoutEffect)(()=>{v?w():C(null)}),(0,i.useLayoutEffect)(()=>{if(!v)return;let e=()=>w();return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[v,w]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{ref:p,className:t,onMouseEnter:()=>{m&&!n&&_(!0)},onMouseLeave:()=>_(!1),children:e}),v&&S&&typeof document<`u`?(0,a.createPortal)((0,o.jsxs)(`div`,{role:`tooltip`,"data-closed":b?void 0:``,className:`tw-tooltip tw-tooltip-anim ${S.openUp?`is-up`:`is-down`} pointer-events-none fixed rounded-md px-2 py-1 text-[12px] leading-5 break-all text-stone-700 shadow-lg`,style:{zIndex:f,top:S.top,left:S.left,maxWidth:S.maxWidth,...r?{width:S.maxWidth}:null},children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`tw-tooltip-arrow ${S.openUp?`is-up`:`is-down`} absolute h-2 w-2`,style:{left:S.arrowLeft,...S.openUp?{bottom:-5}:{top:-5},transform:`translateX(-50%) rotate(45deg)`}}),(0,o.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e})]}),document.body):null]})}export{d as t};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.DkyjuL-S.js";import{a as i,l as a,o,r as s,t as c}from"./plugins.BRvXWHLe.js";import{f as l}from"./case-exec.BMNk9OyF.js";import{n as u,o as d}from"./view-prefs.DhdLZjGh.js";import{i as f,n as p,r as m,t as h}from"./dialog.DZHZCe_T.js";import{t as g}from"./jsx-runtime.DUg_B_vD.js";import{t as _}from"./OverflowHint.CHZeFfUj.js";import{I as v,v as y}from"./pm.BXmOiFfW.js";import{showToast as b}from"./Toast.BO2NFckG.js";import"./settings.38J2uD5M.js";import{at as x}from"./req-analysis.FrD6BfwK.js";import{F as S,I as C}from"./case-review.TdDs1WFM.js";import{s as w}from"./fs-tools.3F9MFrLf.js";import{s as T,w as E}from"./tasks.DEyD8pmq.js";import{l as D}from"./report-prompt.B9C4cv84.js";import{a as O}from"./test-stats.Cf3_L4wu.js";import{o as k}from"./ui-auto-prompt.H9_yhau9.js";import{s as ee,y as A}from"./story-review.R8iWiFzl.js";var j=e(t(),1),M=`/__tb_memory`,N=3e3,P=`你可以使用跨会话长期记忆(本机五轨:user / memory / key / project / daily):
|
|
2
|
-
- 系统可能已在 <memory_snapshot> 注入用户档案、全局事实与项目关键记忆;优先参考。
|
|
3
|
-
- 查历史进展:memory_search 或 memory_read(project / daily 不自动注入)。
|
|
4
|
-
- 用户明确要求记住偏好/全局事实/项目约定:调用 memory_suggest(进待确认,确认后才注入)。
|
|
5
|
-
- 回合进展写入:memory_append 到 project 或 daily(无需确认)。
|
|
6
|
-
- 不要把寒暄、一次性闲聊写入记忆。`,te=[{type:`function`,function:{name:`memory_search`,description:`在五轨记忆中按关键词搜索条目。`,parameters:{type:`object`,properties:{query:{type:`string`,description:`搜索关键词`}},required:[`query`]}}},{type:`function`,function:{name:`memory_read`,description:`读取某一轨的全部条目。target: user|memory|key|project|daily`,parameters:{type:`object`,properties:{target:{type:`string`,enum:[`user`,`memory`,`key`,`project`,`daily`]}},required:[`target`]}}},{type:`function`,function:{name:`memory_suggest`,description:`提议写入用户档案/全局事实/项目关键(user|memory|key)。写入待确认队列,用户采纳后才生效。`,parameters:{type:`object`,properties:{target:{type:`string`,enum:[`user`,`memory`,`key`]},content:{type:`string`,description:`要记住的事实(简洁)`},reason:{type:`string`,description:`为何值得记住`}},required:[`target`,`content`]}}},{type:`function`,function:{name:`memory_append`,description:`向项目日志或每日日志追加进展(直写,无需确认)。`,parameters:{type:`object`,properties:{target:{type:`string`,enum:[`project`,`daily`]},content:{type:`string`}},required:[`target`,`content`]}}}];async function F(e,t={},n){let r=await fetch(`${M}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:n}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);return i}async function I(e){let t=await fetch(`${M}${e}`),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error??`HTTP ${t.status}`);return n}async function L(){try{let e=await fetch(`${M}/health`,{signal:AbortSignal.timeout(1500)});return e.ok?await e.json():null}catch{return null}}async function R(){try{return(await I(`/config`)).config??null}catch{return null}}async function z(e){return(await F(`/config`,e)).config}async function B(e=``){try{let t=await F(`/snapshot`,{cwd:e},AbortSignal.timeout(N));return typeof t.text==`string`?t.text:``}catch{return``}}async function ne(e=``,t=`all`){let n=await F(`/tracks`,{cwd:e,target:t});return t===`all`?{tracks:n.tracks??{},projectId:n.projectId}:{tracks:{[t]:{entries:n.entries??[],path:n.path,target:t}},projectId:n.projectId}}async function V(){return(await I(`/suggestions`)).suggestions??[]}async function re(e){await F(`/suggestions/approve`,{id:e})}async function ie(e){await F(`/suggestions/reject`,{id:e})}async function H(e,t,n=``){await F(`/archive`,{target:e,index:t,cwd:n})}async function U(e,t,n=``){await F(`/delete`,{target:e,index:t,cwd:n})}async function ae(e,t,n=``){await F(`/archives/delete`,{target:e,index:t,cwd:n})}async function oe(e,t=``){return(await F(`/archives`,{target:e,cwd:t})).entries??[]}async function se(e,t,n=``){await F(`/promote`,{target:e,index:t,cwd:n})}async function ce(e,t,n=``){await F(`/manual-add`,{target:e,content:t,cwd:n})}async function le(e,t){let n=t?.cwd??``,r=t?.maxChars??8e3;try{let e=await B(n);return e.length>r&&(e=`${e.slice(0,r-20)}\n…\n</memory_snapshot>`),{context:e,hits:[]}}catch{return{context:``,hits:[]}}}var ue=/记住|记下|别忘了|以后都|请记得|我喜欢|我的偏好|默认用|默认显示|默认城市|约定|不要再|以后默认/;async function de(e,t=``){let n=e.trim();if(!n||n.length<4||!ue.test(n))return!1;let r=n.length>400?`${n.slice(0,400)}…`:n;try{return await F(`/suggest`,{cwd:t,target:/偏好|喜欢|习惯|称呼|默认/.test(n)?`user`:`memory`,content:r,reason:`用户话术触发自动沉淀`}),!0}catch{return!1}}async function fe(e,t,n=``){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}try{switch(e){case`memory_search`:{let e=await F(`/search`,{query:r.query,cwd:n});return JSON.stringify(e)}case`memory_read`:{let e=await F(`/tracks`,{target:r.target,cwd:n});return JSON.stringify(e)}case`memory_suggest`:{let e=await F(`/suggest`,{target:r.target,content:r.content,reason:r.reason,cwd:n});return JSON.stringify(e)}case`memory_append`:{let e=await F(`/append`,{target:r.target,content:r.content,cwd:n});return JSON.stringify(e)}case`memory_create_entities`:case`memory_add_observations`:{let e=Array.isArray(r.entities)?r.entities:[],t=Array.isArray(r.observations)?r.observations:[],i=[];for(let t of e){let e=t,n=(e.observations??[]).join(`;`);i.push(n?`${e.name}: ${n}`:String(e.name??``))}for(let e of t){let t=e;i.push(`${t.entityName}: ${(t.contents??[]).join(`;`)}`)}let a=i.filter(Boolean).join(`
|
|
7
|
-
`);if(!a)return JSON.stringify({error:`empty`});let o=await F(`/suggest`,{target:`memory`,content:a,reason:`兼容旧工具调用`,cwd:n});return JSON.stringify(o)}case`memory_create_relations`:return JSON.stringify({ok:!0,skipped:!0,note:`五轨模式不使用关系图`});case`memory_open_nodes`:{let e=await F(`/search`,{query:Array.isArray(r.names)?r.names.join(` `):``,cwd:n});return JSON.stringify(e)}default:return JSON.stringify({error:`unknown tool: ${e}`})}}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}async function pe(e){}var W=`/__tb_mcp`,me="你可以使用 MCP 工具(名称形如 mcp__服务器__工具名)。它们来自当前数据空间 `.lantern/local/mcp.json` 配置的外部 MCP 服务。",G={name:`tencent-docs`,transport:`http`,url:`https://docs.qq.com/openapi/mcp`};function K(e){let t=e.name.trim()||`mcp`,n=e.transport===`stdio`?{command:e.command||``,args:e.args||[],...e.env&&Object.keys(e.env).length?{env:e.env}:{env:{}}}:{url:e.url||``,...e.headers&&Object.keys(e.headers).length?{headers:e.headers}:{}};return`${JSON.stringify({mcpServers:{[t]:n}},null,2)}\n`}function q(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`JSON 无法解析`}}if(!t||typeof t!=`object`)return{ok:!1,error:`JSON 必须是对象`};let n=t,r=[];if(n.mcpServers&&typeof n.mcpServers==`object`&&!Array.isArray(n.mcpServers))for(let[e,t]of Object.entries(n.mcpServers))t&&typeof t==`object`&&r.push({name:e,...t});else if(Array.isArray(n.servers))r=n.servers.filter(e=>e&&typeof e==`object`);else if(Array.isArray(t))r=t.filter(e=>e&&typeof e==`object`);else if(`command`in n||`url`in n||`transport`in n)r=[n];else return{ok:!1,error:`未识别的格式,请使用 mcpServers 或 servers[]`};let i=[];for(let e of r){let t=String(e.name||``).trim();if(!t)return{ok:!1,error:`缺少 name`};let n=String(e.transport||(e.url?`http`:`stdio`)).trim().toLowerCase();if(n===`stdio`||!e.url&&e.command){let n=String(e.command||``).trim();if(!n)return{ok:!1,error:`「${t}」缺少 command`};i.push({name:t,transport:`stdio`,command:n,args:Array.isArray(e.args)?e.args.map(e=>String(e)):[],env:e.env&&typeof e.env==`object`?Object.fromEntries(Object.entries(e.env).filter(([,e])=>typeof e==`string`)):void 0})}else if(n===`http`||n===`streamable-http`||n===`sse`){let n=String(e.url||``).trim();if(!n)return{ok:!1,error:`「${t}」缺少 url`};i.push({name:t,transport:`http`,url:n,headers:e.headers&&typeof e.headers==`object`?Object.fromEntries(Object.entries(e.headers).filter(([,e])=>typeof e==`string`)):void 0})}else return{ok:!1,error:`「${t}」不支持的 transport`}}return i.length?{ok:!0,servers:i}:{ok:!1,error:`没有有效的服务器配置`}}async function J(){try{let e=await fetch(`${W}/health`,{signal:AbortSignal.timeout(2e3)});return e.ok?await e.json():null}catch{return null}}async function he(){try{let e=await fetch(`${W}/servers`,{signal:AbortSignal.timeout(2e4)}),t=await e.json();return e.ok?{ok:!0,path:t.path,servers:Array.isArray(t.servers)?t.servers:[],connected:t.connected,errors:t.errors}:{ok:!1,servers:[],error:t.error||`HTTP ${e.status}`}}catch(e){return{ok:!1,servers:[],error:e instanceof Error?e.message:String(e)}}}async function ge(e,t){try{let n=await fetch(`${W}/servers`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({server:e,previousName:t}),signal:AbortSignal.timeout(3e4)}),r=await n.json();return n.ok?{ok:!0,path:r.path,servers:Array.isArray(r.servers)?r.servers:[]}:{ok:!1,servers:[],error:r.error||`HTTP ${n.status}`}}catch(e){return{ok:!1,servers:[],error:e instanceof Error?e.message:String(e)}}}async function _e(e){try{let t=await fetch(`${W}/servers`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e}),signal:AbortSignal.timeout(2e4)}),n=await t.json();return t.ok?{ok:!0,path:n.path,servers:Array.isArray(n.servers)?n.servers:[]}:{ok:!1,servers:[],error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,servers:[],error:e instanceof Error?e.message:String(e)}}}async function ve(e){try{let t=await fetch(`${W}/reload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{name:e}:{}),signal:AbortSignal.timeout(3e4)}),n=await t.json();return t.ok?{ok:!0,connected:n.connected,errors:n.errors}:{ok:!1,error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function ye(){try{let e=await fetch(`${W}/tools`,{signal:AbortSignal.timeout(15e3)});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.tools)?t.tools:[]}catch{return[]}}function be(e){return e.map(e=>({type:`function`,function:{name:e.name,description:e.description||e.name,parameters:e.inputSchema&&typeof e.inputSchema==`object`?e.inputSchema:{type:`object`,properties:{}}}}))}async function xe(e,t){let n={};try{n=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}try{let t=await(await fetch(`${W}/call`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,arguments:n}),signal:AbortSignal.timeout(6e4)})).json();return t.error&&!t.text?JSON.stringify({error:t.error}):t.text??JSON.stringify(t,null,2)}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}var Y=g(),Se=`mcp.list.cache`;function Ce(){try{let e=sessionStorage.getItem(r(Se));if(!e)return null;let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function we(e){try{sessionStorage.setItem(r(Se),JSON.stringify(e))}catch{}}function Te(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
|
|
8
|
-
`):``}function Ee(e){let t={};for(let n of e.split(`
|
|
9
|
-
`)){let e=n.trim();if(!e||e.startsWith(`#`))continue;let r=e.indexOf(`=`);r<=0||(t[e.slice(0,r).trim()]=e.slice(r+1).trim())}return Object.keys(t).length?t:void 0}function X(e){let t={};return e.authHeader.trim()&&(t.Authorization=e.authHeader.trim()),{name:e.name.trim()||(e.mode===`tencent`?G.name:`mcp`),transport:e.transport,command:e.command,args:e.argsText.trim().split(/\s+/).filter(Boolean),env:Ee(e.envText),url:e.url,headers:Object.keys(t).length?t:void 0}}function Z(e=`create`){let t=e===`tencent`?{mode:e,view:`form`,name:G.name,transport:`http`,url:G.url,command:``,argsText:``,authHeader:``,envText:``,jsonText:``}:{mode:e,view:`form`,name:``,transport:`http`,url:``,command:``,argsText:``,authHeader:``,envText:``,jsonText:``};return{...t,jsonText:K(X(t))}}function De(e){let t={mode:`edit`,view:`form`,previousName:e.name,name:e.name,transport:e.transport===`stdio`?`stdio`:`http`,url:e.url||``,command:e.command||``,argsText:Array.isArray(e.args)?e.args.join(` `):``,authHeader:e.headers?.Authorization||e.headers?.authorization||``,envText:Te(e.env),jsonText:``};return t.jsonText=K(X(t)),t}function Oe(e,t){return{...e,name:t.name,transport:t.transport,command:t.command||``,argsText:Array.isArray(t.args)?t.args.join(` `):``,envText:Te(t.env),url:t.url||``,authHeader:t.headers?.Authorization||t.headers?.authorization||``}}function ke({onServersChange:e}){let[t,n]=(0,j.useState)(()=>Ce()),[r,i]=(0,j.useState)(``),[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1),[d,g]=(0,j.useState)(null),[_,v]=(0,j.useState)(null),y=(0,j.useRef)(null);_&&(y.current=_);let x=_??y.current,[S,C]=(0,j.useState)(null),w=(0,j.useRef)(null);S&&(w.current=S);let T=S??w.current,E=(0,j.useRef)(!1),D=(0,j.useCallback)(async()=>{E.current&&c(!0);try{let e=await he();n(e.servers),we(e.servers),i(e.path||``),o(e.errors||(e.error?[e.error]:[])),E.current=!0}finally{c(!1)}},[]);(0,j.useEffect)(()=>{D()},[D]);function O(e){if(!_||_.view===e)return;if(e===`json`){v({..._,view:`json`,jsonText:K(X(_))});return}let t=q(_.jsonText);t.ok?t.servers.length>1&&_.mode===`edit`?b(`编辑时 JSON 里请只保留一台服务器`,`error`):v({...Oe(_,t.servers[0]),view:`form`,jsonText:_.jsonText}):b(t.error,`error`)}async function k(){if(_){u(!0);try{let e;if(_.view===`json`){let t=q(_.jsonText);if(!t.ok){b(t.error,`error`);return}if(t.servers.length>1&&_.mode===`edit`){b(`编辑时 JSON 里请只保留一台服务器`,`error`);return}e=t.servers}else{let t=X(_),n=t.name.trim();if(!n){b(`请填写名称`,`error`);return}if(_.mode===`tencent`&&!_.authHeader.trim()){b(`请粘贴腾讯文档 MCP Token`,`error`);return}if(t.transport===`stdio`&&!t.command.trim()){b(`stdio 需要填写 command`,`error`);return}if(t.transport===`http`&&!t.url.trim()){b(`HTTP 需要填写 URL`,`error`);return}e=[t.transport===`stdio`?{name:n,transport:`stdio`,command:t.command.trim(),args:t.args,env:t.env}:{name:n,transport:`http`,url:t.url.trim(),headers:t.headers}]}let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=await ge(r,_.mode===`edit`&&n===0?_.previousName:void 0);if(!i.ok){t=i.error||`保存失败`;break}}if(t){b(t,`error`),await D();return}v(null),b(e.length>1?`已保存 ${e.length} 台并重新连接`:`已保存并重新连接`,`success`),await D()}finally{u(!1)}}}async function ee(e){u(!0);try{let t=await _e(e);if(!t.ok){b(t.error||`删除失败`,`error`);return}n(t=>{let n=(t??[]).filter(t=>t.name!==e);return we(n),n}),C(null),b(`已删除`,`success`),await D()}finally{u(!1)}}async function A(e){e?g(e):u(!0);try{let t=await ve(e);if(!t.ok){b(t.error||`连接失败`,`error`);return}let n=t.errors?.find(t=>!e||t.startsWith(`${e}:`));if(n)b(n,`error`);else if(e){let n=t.connected?.includes(e);b(n?`「${e}」已连接`:`「${e}」未连上`,n?`success`:`error`)}else t.errors?.length?b(t.errors[0],`error`):b(e?`已重新连接`:`刷新成功`,`success`);await D()}finally{g(null),u(!1)}}let M=(0,j.useMemo)(()=>{if(t===null)return[{name:G.name,displayName:`腾讯文档`,transport:`http`,url:G.url,booting:!0,connected:!1,toolCount:0}];let e=t.some(e=>e.name===G.name),n=t.filter(e=>e.name!==G.name);return[e?{...t.find(e=>e.name===G.name),displayName:`腾讯文档`}:{name:G.name,displayName:`腾讯文档`,transport:`http`,url:G.url,pending:!0,connected:!1,toolCount:0},...n]},[t]);return(0,j.useEffect)(()=>{e?.(M.length)},[M.length,e]),(0,Y.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l||s,onClick:()=>v(Z(`create`)),className:`h-8 rounded-lg bg-[#4176e6] px-3 text-[13px] font-medium text-white hover:bg-[#3566cc] disabled:opacity-60`,children:`添加 MCP`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l||s,onClick:()=>void A(),className:`h-8 rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-600 hover:bg-stone-50 disabled:opacity-60`,children:s&&!d?`刷新中…`:`刷新连接`}),r?(0,Y.jsx)(`span`,{className:`ml-auto max-w-full truncate font-mono text-[11px] text-stone-400`,title:r,children:r}):null]}),a.length?(0,Y.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] leading-5 text-amber-800`,children:a.map(e=>(0,Y.jsx)(`p`,{children:e},e))}):null,(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-stone-200 bg-white`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-[640px] border-collapse text-left text-[13px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-stone-100 bg-stone-50/80 text-[12px] text-stone-500`,children:[(0,Y.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:`名称`}),(0,Y.jsx)(`th`,{className:`w-20 px-3 py-2.5 font-medium`,children:`类型`}),(0,Y.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:`地址 / 命令`}),(0,Y.jsx)(`th`,{className:`w-16 px-3 py-2.5 font-medium tabular-nums`,children:`工具`}),(0,Y.jsx)(`th`,{className:`w-24 px-3 py-2.5 font-medium`,children:`状态`}),(0,Y.jsx)(`th`,{className:`w-32 px-3 py-2.5 font-medium text-right`,children:`操作`})]})}),(0,Y.jsx)(`tbody`,{children:M.map(e=>{let t=e.transport===`stdio`?[e.command,...e.args||[]].filter(Boolean).join(` `):e.url||``;return(0,Y.jsxs)(`tr`,{className:`border-b border-stone-100 last:border-b-0 hover:bg-stone-50/70`,children:[(0,Y.jsxs)(`td`,{className:`max-w-[10rem] px-3 py-2.5`,children:[(0,Y.jsx)(`div`,{className:`truncate font-medium text-stone-900`,children:e.displayName||e.name}),(0,Y.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-stone-400`,children:[e.name,e.booting?``:e.pending?` · 待配置`:e.hasSecrets?` · 已配置密钥`:``]})]}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Y.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] uppercase text-stone-400`,children:e.transport})}),(0,Y.jsx)(`td`,{className:`max-w-[18rem] px-3 py-2.5`,children:(0,Y.jsx)(`span`,{className:`block truncate font-mono text-[12px] text-stone-500`,title:t,children:t||`—`})}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5 tabular-nums text-stone-600`,children:e.pending||e.booting?`—`:e.toolCount??0}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5`,children:e.booting?(0,Y.jsx)(`span`,{className:`rounded-md bg-stone-100 px-2 py-0.5 text-[12px] text-stone-500`,children:`同步中…`}):e.pending?(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>v(Z(`tencent`)),className:`rounded-md bg-amber-50 px-2 py-0.5 text-[12px] text-amber-700 hover:bg-amber-100`,children:`需配置`}):(0,Y.jsx)(`button`,{type:`button`,disabled:l||d!==null||s,onClick:()=>void A(e.name),className:`rounded-md px-2 py-0.5 text-[12px] transition-colors ${d===e.name?`bg-sky-50 text-sky-700`:e.connected?`bg-emerald-50 text-emerald-700 hover:bg-emerald-100`:`bg-stone-100 text-stone-600 hover:bg-[#4176e6]/10 hover:text-[#4176e6]`} disabled:opacity-60`,children:d===e.name?`连接中…`:e.connected?`已连接`:`连接`})}),(0,Y.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l||!!e.booting,onClick:()=>v(e.pending?Z(`tencent`):De(e)),className:`text-[13px] text-[#4176e6] hover:underline disabled:opacity-60`,children:e.pending?`配置`:`编辑`}),e.pending||e.booting?null:(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>C(e.name),className:`text-[13px] text-rose-600 hover:underline disabled:opacity-60`,children:`删除`})]})})]},e.name)})})]})}),(0,Y.jsxs)(m,{open:!!_,onClose:()=>{l||v(null)},className:`relative z-110`,children:[(0,Y.jsx)(h,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Y.jsx)(f,{transition:!0,className:`tw-dialog-panel-anim flex max-h-[85vh] w-full max-w-lg flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:x?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(p,{className:`text-[15px] font-semibold text-stone-900`,children:x.mode===`tencent`?`配置腾讯文档 MCP`:x.mode===`edit`?`编辑 MCP`:`添加 MCP`}),x.mode===`tencent`?(0,Y.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-5 text-stone-500`,children:`在腾讯文档空间菜单「使用 MCP」复制 Token,粘贴到下方。Token 约一年有效,有日调用限额。`}):x.view===`json`?(0,Y.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-5 text-stone-500`,children:`可粘贴 Trae / Claude Desktop 的 mcpServers JSON,也支持灵光 servers[]。`}):null]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-pills shrink-0`,role:`group`,"aria-label":`编辑方式`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.view===`form`,onClick:()=>O(`form`),children:`表单`}),(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.view===`json`,onClick:()=>O(`json`),children:`JSON`})]})]}),x.view===`json`?(0,Y.jsx)(`div`,{className:`mt-4 min-h-0 flex-1`,children:(0,Y.jsx)(`textarea`,{value:x.jsonText,onChange:e=>_&&v({..._,jsonText:e.target.value}),spellCheck:!1,className:`h-72 w-full resize-y rounded-lg border border-stone-200 bg-stone-50 px-3 py-2 font-mono text-[12px] leading-5 text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`{
|
|
10
|
-
"mcpServers": {
|
|
11
|
-
"demo": {
|
|
12
|
-
"command": "npx",
|
|
13
|
-
"args": ["-y", "some-mcp-server"],
|
|
14
|
-
"env": {}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}`})}):(0,Y.jsxs)(`div`,{className:`mt-4 space-y-3 overflow-y-auto`,children:[(0,Y.jsx)(Q,{label:`名称`,children:(0,Y.jsx)(`input`,{value:x.name,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,name:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`tencent-docs`})}),x.mode===`tencent`?null:(0,Y.jsx)(Q,{label:`传输`,children:(0,Y.jsx)(`div`,{className:`flex gap-2`,children:[`http`,`stdio`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":x.transport===e,onClick:()=>_&&v({..._,transport:e}),className:`h-8 rounded-md border px-3 text-[12px] ${x.transport===e?`border-[#4176e6] bg-[#4176e6]/10 text-[#4176e6]`:`border-stone-200 text-stone-600`}`,children:e},e))})}),x.transport===`http`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`URL`,children:(0,Y.jsx)(`input`,{value:x.url,disabled:x.mode===`tencent`,onChange:e=>_&&v({..._,url:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`https://…`})}),(0,Y.jsx)(Q,{label:x.mode===`tencent`?`MCP Token(Authorization)`:`Authorization`,children:(0,Y.jsx)(`input`,{value:x.authHeader,onChange:e=>_&&v({..._,authHeader:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:x.mode===`edit`&&x.authHeader.startsWith(`••••`)?`留脱敏值表示不改密钥`:`粘贴 Token`,autoComplete:`off`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:`command`,children:(0,Y.jsx)(`input`,{value:x.command,onChange:e=>_&&v({..._,command:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`npx`})}),(0,Y.jsx)(Q,{label:`args(空格分隔)`,children:(0,Y.jsx)(`input`,{value:x.argsText,onChange:e=>_&&v({..._,argsText:e.target.value}),className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`-y some-mcp-server`})}),(0,Y.jsx)(Q,{label:`env(每行 KEY=VALUE)`,children:(0,Y.jsx)(`textarea`,{value:x.envText,onChange:e=>_&&v({..._,envText:e.target.value}),spellCheck:!1,rows:3,className:`w-full resize-y rounded-lg border border-stone-200 bg-white px-3 py-2 font-mono text-[12px] text-stone-800 outline-none focus:border-[#4176e6]`,placeholder:`TAVILY_API_KEY=…`})})]})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>v(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void k(),className:`h-9 rounded-lg bg-[#4176e6] px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:l?`保存中…`:`保存`})]})]}):null})})]}),(0,Y.jsxs)(m,{open:!!S,onClose:()=>{l||C(null)},className:`relative z-110`,children:[(0,Y.jsx)(h,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Y.jsxs)(f,{transition:!0,className:`tw-dialog-panel-anim w-full max-w-sm rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Y.jsx)(p,{className:`text-[15px] font-semibold text-stone-900`,children:`删除 MCP?`}),(0,Y.jsxs)(`p`,{className:`mt-2 text-[13px] text-stone-500`,children:[`将从当前空间配置中移除「`,T,`」,对话里对应工具会立即消失。`]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>C(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-[13px] text-stone-600`,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,disabled:l||!T,onClick:()=>T&&void ee(T),className:`h-9 rounded-lg bg-rose-600 px-3 text-[13px] font-medium text-white disabled:opacity-60`,children:`删除`})]})]})})]})]})}function Q({label:e,children:t}){return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-[12px] text-stone-500`,children:e}),t]})}var Ae=[`extensions`,`mcp`],je=[{id:`extensions`,label:`扩展插件`},{id:`mcp`,label:`MCP`}],Me={tasks:`侧栏「任务管理」按状态列出任务;工作台可直接增删改`,todos:`侧栏「待办事项」按状态 / 紧急程度分组;工作台可直接增删改`,projects:`侧栏「项目列表」管理项目并汇总迭代 / 需求 / 缺陷;工作台可直接增删改`,iterations:`侧栏「迭代管理」按项目维护迭代周期、进度与逾期;工作台可直接增删改`,pmRequirements:`侧栏「需求管理」维护需求编号 / 优先级 / 状态与验收标准;工作台可直接增删改`,bugs:`侧栏「缺陷管理」记录严重程度 / 重现步骤与修复状态;工作台可直接增删改`,testStats:`侧栏「测试统计」按维度记录每天的统计数量`,caseExec:`侧栏「用例执行统计」按项目记录用例执行情况`,dashboard:`侧栏「仪表盘」聚合待办 / 任务 / 测试统计;卡片可拖动排序、拖角改宽高,右上角编辑组件`},$={tasks:T,todos:E,projects:y,iterations:y,pmRequirements:y,bugs:y,testStats:O,caseExec:l,dashboard:E},Ne=[{id:`all`,label:`全部`},{id:`on`,label:`已启用`},{id:`off`,label:`未启用`}],Pe=s();function Fe({embedded:e=!1}){let[t,r]=(0,j.useState)(()=>u(`plugins.pageTab`,Ae,`extensions`)),[s,l]=(0,j.useState)(()=>i()),[f,p]=(0,j.useState)(null),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[y,T]=(0,j.useState)(!0),[E,O]=(0,j.useState)(``),[M,N]=(0,j.useState)(`all`),[P,te]=(0,j.useState)(null),[F,I]=(0,j.useState)({}),[R,z]=(0,j.useState)(null);function B(e){r(e),d(`plugins.pageTab`,e)}async function ne(){T(!0);try{let[e,t,n,r,i,a,o,s,c,l,u]=await Promise.all([L(),w(),$.tasks(),$.todos(),$.projects(),$.iterations(),$.pmRequirements(),$.bugs(),$.testStats(),$.caseExec(),$.dashboard()]);p(e),h(t),_({tasks:n,todos:r,projects:i,iterations:a,pmRequirements:o,bugs:s,testStats:c,caseExec:l,dashboard:u})}finally{T(!1)}}(0,j.useEffect)(()=>{let e=o(e=>l(e));return n().then(()=>{l(i()),ne()}),J().then(e=>{e?.ok&&z(e.serversConfigured??0)}),()=>{e()}},[]),(0,j.useEffect)(()=>{t===`mcp`&&J().then(e=>{e?.ok&&z(e.serversConfigured??0)})},[t]);function V(e){if(e===`cases`)return{available:!0,detail:`侧栏「用例管理」浏览与维护本空间用例库`};if(e===`caseGen`)return s.cases?{available:!0,detail:`对话输入 / 打开配置面板,生成用例并写入用例库`}:{available:!1,detail:`需先启用「用例管理」,生成结果才能写入用例列表`};if(e===`prompts`)return{available:!0,detail:`侧栏「提示词管理」浏览与维护本空间提示词库`};if(e===`promptGen`)return s.prompts?{available:!0,detail:`对话输入 / 打开配置面板,生成提示词并写入提示词库`}:{available:!1,detail:`需先启用「提示词管理」,生成结果才能写入提示词列表`};if(e===`knowledgeLib`)return{available:!0,detail:`侧栏「知识库管理」浏览与维护本空间知识库`};if(e===`requirements`)return{available:!0,detail:`侧栏「需求文档库」浏览与维护本空间需求文档`};if(e===`templates`)return{available:!0,detail:`侧栏「测试模板库」浏览与维护本空间用例模板`};if(e===`testReports`)return{available:!0,detail:`侧栏「报告管理」按功能 / 接口 / 性能归档报告,可挂载提示词并在会话中打开`};if(e===`reports`)return{available:!0,detail:`侧栏「工作汇报」按日报 / 周报 / 月报列出汇报文件`};if(e===`tasks`||e===`todos`||e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`||e===`testStats`||e===`caseExec`||e===`dashboard`){let t=g?.[e];return t===void 0?{available:y?null:!1,detail:y?`探测中…`:`需本地服务`}:t?{available:!0,detail:Me[e]}:{available:!1,detail:`需本地服务(npm run dev / lantern web)`}}return e===`knowledgeGen`?s.knowledgeLib?{available:!0,detail:`对话输入 / 打开配置面板,生成文档并写入知识库`}:{available:!1,detail:`需先启用「知识库管理」,生成结果才能写入知识库列表`}:e===`memory`?y&&f===null?{available:null,detail:`探测中…`}:f?.ok?{available:!0,detail:`已连接 · ${f.entryCount??f.entityCount??0} 条记忆 / 待确认 ${f.suggestionCount??0}`}:{available:!1,detail:`本地记忆服务未就绪`}:e===`knowledge`?{available:!0,detail:`对话输入 @ 可引用知识库与模板文档`}:e===`pluginDev`?y&&m===null?{available:null,detail:`探测中…`}:m?.ok?{available:!0,detail:`固定提示词开发扩展插件;先评估确认,再改代码并入「扩展插件」`}:{available:!1,detail:`需本地文件服务:开发要读写项目源码`}:{available:!1,detail:`未知`}}function re(e){let t=a(e,!s[e]),n=!!t[e],r=c.find(t=>t.id===e)?.name??e;l(t),b(n?`已启用「${r}」`:`已停用「${r}」`,`success`),e===`reports`&&D(!!t.reports).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`工作汇报提示词没生成成功:${t}`,`error`)}),e===`uiAuto`&&k(!!t.uiAuto).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`UI自动化测试提示词没生成成功:${t}`,`error`)}),e===`reqAnalysis`&&x(!!t.reqAnalysis).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`需求分析提示词没生成成功:${t}`,`error`)}),e===`storyReview`&&ee(!!t.storyReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用户故事审查提示词没生成成功:${t}`,`error`)}),e===`testPoints`&&A(!!t.testPoints).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`测试点生成提示词没生成成功:${t}`,`error`)}),(e===`caseReview`||e===`cases`)&&C(!!t.caseReview).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`用例质量评审提示词没生成成功:${t}`,`error`)}),(e===`caseBlindspot`||e===`cases`)&&S(!!t.caseBlindspot).catch(e=>{let t=e instanceof Error?e.message:String(e);b(`场景遗漏补全提示词没生成成功:${t}`,`error`)}),(e===`projects`||e===`iterations`||e===`pmRequirements`||e===`bugs`)&&t[e]&&v().catch(e=>{console.warn(`[pm] 同步项目管理数据目录失败`,e)})}let ie=(0,j.useMemo)(()=>c.filter(e=>s[e.id]).length,[s]),H=E.trim().toLowerCase(),U=(0,j.useMemo)(()=>Pe.map(e=>({...e,items:e.items.filter(e=>{let t=!H||e.name.toLowerCase().includes(H)||e.id.toLowerCase().includes(H)||e.description.toLowerCase().includes(H),n=M===`all`||(M===`on`?s[e.id]:!s[e.id]);return t&&n})})).filter(e=>e.items.length>0),[s,H,M]);return(0,Y.jsx)(`div`,{className:`tw-plugins-page overflow-y-auto ${e?`h-full min-h-0 flex-1`:`min-h-screen`}`,children:(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-[1320px] ${e?`px-4 py-5`:`px-4 py-7 sm:px-5`}`,children:[(0,Y.jsxs)(`header`,{className:`tw-plugins-head`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-[20px] font-semibold tracking-tight text-stone-900`,children:`我的插件`}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-6 text-stone-500`,children:t===`extensions`?(0,Y.jsxs)(Y.Fragment,{children:[`按用途分组的扩展能力,开关保存在本机;会话 / 全局内置能力在`,(0,Y.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 text-[12px] text-stone-600`,children:`设置 → 内置插件`}),`里查看。`]}):(0,Y.jsxs)(Y.Fragment,{children:[`管理当前数据空间的外接 MCP(写入`,(0,Y.jsx)(`span`,{className:`mx-1 rounded bg-stone-100 px-1 py-0.5 font-mono text-[12px] text-stone-600`,children:`.lantern/local/mcp.json`}),`),对话里会出现对应工具。`]})})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stats`,"aria-label":`插件概览`,children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:c.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个插件`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num is-on`,children:ie}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`已启用`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:Pe.length}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`个分类`})]}),(0,Y.jsxs)(`div`,{className:`tw-plugins-stat`,children:[(0,Y.jsx)(`span`,{className:`tw-plugins-stat-num`,children:R??`—`}),(0,Y.jsx)(`span`,{className:`tw-plugins-stat-label`,children:`MCP`})]})]})]}),(0,Y.jsx)(`div`,{className:`tw-plugins-tabs`,role:`tablist`,"aria-label":`插件页分类`,children:je.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,className:t===e.id?`is-active`:void 0,onClick:()=>B(e.id),children:[e.label,(0,Y.jsx)(`span`,{className:`tw-plugins-tab-count`,children:e.id===`extensions`?c.length:R??`—`})]},e.id))}),(0,Y.jsx)(`div`,{className:`tw-plugins-tab-panel`,children:t===`mcp`?(0,Y.jsx)(ke,{onServersChange:z}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`tw-plugins-toolbar`,children:[(0,Y.jsxs)(`label`,{className:`relative block w-full max-w-72`,children:[(0,Y.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 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`,children:[(0,Y.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,Y.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,Y.jsx)(`input`,{value:E,onChange:e=>O(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-9 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-[13px] text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]}),(0,Y.jsx)(`div`,{className:`tw-plugins-pills`,role:`group`,"aria-label":`按状态筛选`,children:Ne.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":M===e.id,onClick:()=>N(e.id),children:e.label},e.id))})]}),(0,Y.jsxs)(`div`,{className:`mt-4 space-y-6`,children:[U.map(e=>{let t=!!F[e.category],n=e.items.filter(e=>s[e.id]).length;return(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":!t,onClick:()=>I(n=>({...n,[e.category]:!t})),className:`mb-2.5 flex w-full items-center gap-2 text-left`,children:[(0,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform ${t?`-rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold text-stone-800`,children:e.category}),(0,Y.jsxs)(`span`,{className:`rounded-full bg-stone-100 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-500`,children:[n,`/`,e.items.length]}),(0,Y.jsx)(`span`,{className:`ml-1 h-px flex-1 bg-stone-200/70`,"aria-hidden":`true`})]}),t?null:(0,Y.jsx)(`ul`,{className:`tw-anim-list tw-plugin-grid`,children:e.items.map(e=>{let t=s[e.id],n=V(e.id),r=P===`ext:${e.id}`;return(0,Y.jsx)(`li`,{className:`relative z-0 min-w-0 overflow-visible hover:z-40 focus-within:z-40${r?` z-40`:``}`,children:(0,Y.jsx)(Ie,{open:r,onToggleOpen:()=>te(r?null:`ext:${e.id}`),title:e.name,subtitle:e.description,badge:(0,Y.jsxs)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] tabular-nums text-stone-400`,children:[`v`,e.version]}),trailing:e.alwaysOn?(0,Y.jsx)(`span`,{className:`rounded border border-stone-200 px-1.5 py-0.5 text-[11px] text-stone-500`,children:`内置`}):(0,Y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`${t?`关闭`:`打开`} ${e.name}`,onClick:()=>re(e.id),className:`tw-toggle`,children:(0,Y.jsx)(`span`,{className:`tw-toggle-knob`})}),fullName:`@lh-plugins/${e.id}`,configLabel:e.alwaysOn?`内置常开`:t?`已启用`:`未启用`,runLabel:t&&n.available===!0?`运行中`:`已停用`,extra:n.detail})},e.id)})})]},e.category)}),U.length?null:(0,Y.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-white/60 px-4 py-12 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-stone-600`,children:`没有匹配的插件`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`换个关键词,或把状态筛选切回「全部」。`})]})]})]})},t)]})})}function Ie(e){let{open:t,onToggleOpen:n,title:r,subtitle:i,badge:a,trailing:o,fullName:s,configLabel:c,runLabel:l,extra:u}=e;return(0,Y.jsxs)(`div`,{className:`tw-plugin-card group/card relative z-0 self-start w-full overflow-visible rounded-xl border bg-white transition-colors hover:z-40 focus-within:z-40 ${t?`z-40 border-[#4176e6]/50 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,Y.jsxs)(`div`,{className:`relative flex h-17 items-start gap-3 overflow-visible px-4 py-3`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`relative h-full min-w-0 flex-1 overflow-visible text-left outline-none focus:outline-none`,"aria-expanded":t,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-medium text-stone-900`,children:r}),a,(0,Y.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-300 ease-out ${t?`rotate-180`:``}`})]}),(0,Y.jsx)(_,{text:i,className:`mt-1 block min-w-0 truncate text-[13px] leading-5 text-stone-500`,disabled:t})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 self-start pt-0.5`,children:o})]}),(0,Y.jsx)(`div`,{className:`tw-collapse ${t?`is-open`:``}`,"aria-hidden":!t,children:(0,Y.jsx)(`div`,{className:`tw-collapse-inner`,children:(0,Y.jsx)(`div`,{className:`border-t border-stone-100 px-4 pb-3 pt-0`,children:(0,Y.jsxs)(`dl`,{className:`mt-2.5 space-y-1.5 text-[13px]`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`完整名称`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px] text-stone-700`,children:s})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`配置状态`}),(0,Y.jsx)(`dd`,{className:`text-stone-700`,children:c})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`运行状态`}),(0,Y.jsx)(`dd`,{className:l===`运行中`?`text-emerald-600`:`text-stone-500`,children:l})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`简介`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:i})]}),u?(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`dt`,{className:`w-18 shrink-0 text-stone-400`,children:`说明`}),(0,Y.jsx)(`dd`,{className:`text-[12px] leading-5 text-stone-500`,children:u})]}):null]})})})})]})}function Le({className:e}){return(0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:e,"aria-hidden":!0,children:(0,Y.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}export{fe as C,ie as S,V as _,xe as a,se as b,re as c,U as d,pe as f,ne as g,L as h,be as i,H as l,R as m,me as n,P as o,oe as p,ye as r,te as s,Fe as t,ae as u,ce as v,z as w,le as x,de as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PluginsPage.BVrMtkLi.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.DkyjuL-S.js";import{s as r}from"./plugins.BRvXWHLe.js";import{t as i}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.DrrPf1MB.js";import{n as te,t as ne}from"./DocsPager.Duf4I68E.js";import{t as a}from"./SelectDropdown.T3CKHaLt.js";import{A as re,D as ie,N as ae,P as oe,R as o,b as se,g as ce,h as le,i as ue,j as de,m as s,n as fe,p as pe,r as c,t as l,x as me,z as he}from"./pm.BXmOiFfW.js";import{A as ge,C as _e,D as ve,E as u,O as ye,S as be,_ as d,a as xe,c as Se,d as Ce,f,g as we,h as Te,j as Ee,k as p,l as De,m,n as Oe,p as ke,s as Ae,t as je,u as Me,y as h}from"./PmShared.BK8kWRSV.js";import{n as Ne,r as Pe,t as Fe}from"./TableFieldConfig.C7O-mL-p.js";import{showToast as g}from"./Toast.BO2NFckG.js";import{c as Ie,d as Le,i as Re,l as ze,n as Be,o as Ve,r as He,s as Ue,t as _}from"./ColumnResize.CkE59sGq.js";var v=e(t(),1),y=i(),b=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`severity`,width:100,min:80},{key:`status`,width:120,min:96}],We={key:`project`,width:140,min:100},Ge=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ke=new Set([`id`,`title`,`filler`,`action`]),qe=[{key:`severity`,label:`严重程度`},{key:`status`,label:`缺陷状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Je=`pm.bugs.fields`,Ye=20,Xe=`tw.pm-bugs.page-size.v1`,Ze=[`all`,...c],Qe=[`all`,...l],$e=`pm.bugs.project`,et=`pm.bugs.iteration`,tt=`pm.bugs.status`,nt=`pm.bugs.severity`,rt=`pm.bugs.keyword`,it=l.map(e=>({value:e,label:fe[e]})),at=c.map(e=>({value:e,label:ue[e]}));function x(e=``){return{projectId:e,iterationId:``,requirementId:``,title:``,severity:`minor`,status:`pending`,reproduceSteps:``,expectedResult:``,actualResult:``,environment:``,githubIssue:``,attachment:``,remark:``}}function S(){return n(`pm.bugs.create-draft.v1`)}function ot(e){return!!(e.reproduceSteps.trim()||e.attachment.trim()||e.remark.trim()||e.iterationId||e.requirementId||e.expectedResult.trim()||e.actualResult.trim()||e.environment.trim()||e.githubIssue.trim())}function C(){try{let e=sessionStorage.getItem(S());if(!e)return null;let t=JSON.parse(e);return!t||typeof t!=`object`||t.id?null:{...x(),...t,id:void 0}}catch{return null}}function w(e){try{let t=S();if(!e||e.id||!ot(e)){sessionStorage.removeItem(t);return}sessionStorage.setItem(t,JSON.stringify({...e,id:void 0}))}catch{}}function st(e){let t=C();return t?e&&t.projectId!==e?{...t,projectId:e,iterationId:``,requirementId:``}:t:x(e)}function T({scopeProjectId:e=``}={}){let t=!!e,n=ge(`bugs`),{store:i,live:c,loading:l,error:x,setError:S,reload:C}=Ee(),[T,E]=p($e,`all`),D=e||T,[O,k]=p(et,`all`),[A,ct]=ye(tt,Ze,`all`),[j,lt]=ye(nt,Qe,`all`),[M,ut]=p(rt),[dt,N]=(0,v.useState)(1),[P,ft]=te(Ye,Xe),[F,I]=(0,v.useState)(null),[L,R]=(0,v.useState)(!1),[z,pt]=(0,v.useState)(!1),B=(0,v.useRef)(null),V=(0,v.useRef)(new Set),[H,U]=(0,v.useState)(null),[mt,W]=(0,v.useState)(null),G=(0,v.useMemo)(()=>de(F?.attachment??``),[F?.attachment]),ht=(0,v.useMemo)(()=>t?qe:[{key:`project`,label:`所属项目`},...qe],[t]),K=Pe(Je,ht,Ke),gt=(0,v.useMemo)(()=>t?[...b,...Ge]:[...b,We,...Ge],[t]),q=(0,v.useMemo)(()=>Ne(gt,K.isVisible),[gt,K.isVisible]),J=ze(t?`pm.bugs.cols.scoped.v2`:`pm.bugs.cols.v2`,q),_t=Le(t?`pm.bugs.scroll.scoped`:`pm.bugs.scroll`),vt=J.widthOf(`id`)??88;(0,v.useEffect)(()=>{for(let e of G)V.current.add(e.url)},[G]);let yt=(0,v.useMemo)(()=>[{value:`all`,label:`全部项目`},...i.projects.map(e=>({value:e.id,label:e.name}))],[i.projects]),bt=(0,v.useMemo)(()=>[{value:`all`,label:`全部迭代`},...i.iterations.filter(e=>D===`all`||e.projectId===D).map(e=>({value:e.id,label:e.name}))],[i.iterations,D]),xt=(0,v.useMemo)(()=>{let e=new Map(i.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[i.projects]),St=(0,v.useMemo)(()=>{let e=new Map(i.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[i.iterations]),Y=(0,v.useMemo)(()=>ae(me(i.bugs,{projectId:D,iterationId:O,status:A,severity:j,keyword:M})),[i.bugs,D,O,A,j,M]),X=t?i.bugs.filter(e=>e.projectId===D).length:i.bugs.length,Ct=Math.max(1,Math.ceil(Y.length/P)),Z=Math.min(dt,Ct),wt=Y.slice((Z-1)*P,Z*P);(0,v.useEffect)(()=>{t||c===!0&&T!==`all`&&!i.projects.some(e=>e.id===T)&&E(`all`)},[c,i.projects,T,E,t]),(0,v.useEffect)(()=>{c===!0&&O!==`all`&&!i.iterations.some(e=>e.id===O&&(D===`all`||e.projectId===D))&&k(`all`)},[c,i.iterations,D,O,k]);let Tt=F?oe(i.iterations.filter(e=>e.projectId===F.projectId)):[],Et=F?i.requirements.filter(e=>e.projectId===F.projectId):[];async function Dt(){if(!F)return;if(!F.projectId){S(`请先选择所属项目`);return}let e=F.reproduceSteps.trim();if(!e){S(`缺陷描述不能为空`);return}let t=pe(e);R(!0);try{let n={projectId:F.projectId,iterationId:F.iterationId,requirementId:F.requirementId,title:t,severity:F.severity,status:F.status,reproduceSteps:e,expectedResult:F.expectedResult,actualResult:F.actualResult,environment:F.environment,githubIssue:F.githubIssue,attachment:F.attachment,remark:F.remark};F.id?await o(`bugs`,F.id,n):await le(`bugs`,[n]);let r=!!F.id;r||w(null),I(null),V.current.clear(),S(``),await C(!0),g(r?`已保存缺陷`:`已新建缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`保存缺陷失败:${t}`,`error`)}finally{R(!1)}}let Q=(0,v.useCallback)(async e=>{if(e&&e.length){pt(!0);try{let t=await he(Array.from(e));I(e=>{if(!e)return e;let n=de(e.attachment);return{...e,attachment:re([...n,...t])}}),S(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{pt(!1),B.current&&(B.current.value=``)}}},[S]),Ot=F!==null;(0,v.useEffect)(()=>{if(!Ot)return;let e=e=>{let t=se(e.clipboardData);t.length&&(e.preventDefault(),Q(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Ot,Q]);async function kt(e){if(!F)return;let t=re(G.filter(t=>t.url!==e));if(F.id)try{await o(`bugs`,F.id,{attachment:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e));return}I(e=>{if(!e)return e;let n={...e,attachment:t};return n.id||w(n),n}),s([e],F.id??``)}function At(){if(F&&!F.id){if(w(F),V.current.clear(),I(null),!ot(F)){let e=G.map(e=>e.url);e.length&&s(e)}return}let e=[...V.current,...G.map(e=>e.url)];V.current.clear(),I(null),e.length&&s(e)}function $(){I(st(D===`all`?``:D))}async function jt(e,t){R(!0);try{await o(`bugs`,e.id,{status:t}),await C(!0)}catch(e){S(e instanceof Error?e.message:String(e))}finally{R(!1)}}async function Mt(){let e=H;if(e){U(null),R(!0);try{await ce(`bugs`,[e.id]),await C(!0),g(`已删除缺陷`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),g(`删除缺陷失败:${t}`,`error`)}finally{R(!1)}}}if(!n.ready)return(0,y.jsx)(we,{label:`正在读取插件开关`});if(!n.on)return(0,y.jsx)(d,{children:r(`bugs`)});if(c===null)return(0,y.jsx)(we,{label:`正在连接项目管理服务`});if(!c)return(0,y.jsx)(d,{children:`缺陷管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(i.projects.length===0&&!l&&!t)return(0,y.jsx)(d,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来记录缺陷。`});let Nt=[{value:`all`,label:`全部`},...at];return(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-600`,children:X}),` 条缺陷`,Y.length===X?``:` · 筛选出 ${Y.length} 条`]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选缺陷`,className:`w-36`,options:yt,value:T,onChange:e=>{E(e),k(`all`),N(1)}}),(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选缺陷`,className:`w-32`,options:bt,value:O,onChange:e=>{k(e),N(1)}}),(0,y.jsx)(a,{flat:!0,showCheck:!1,ariaLabel:`按严重程度筛选缺陷`,className:`w-32`,options:[{value:`all`,label:`全部严重程度`},...it],value:j,onChange:e=>{lt(e),N(1)}}),(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(m,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,y.jsx)(`input`,{value:M,onChange:e=>{ut(e.target.value),N(1)},placeholder:`搜索编号 / 标题…`,className:`h-9 w-48 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,y.jsx)(Fe,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,y.jsxs)(`button`,{type:`button`,disabled:L,onClick:$,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,y.jsx)(m,{name:`plus`,size:14}),`新建缺陷`]})]})]}),(0,y.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,y.jsx)(ke,{ariaLabel:`按状态筛选缺陷`,options:Nt,value:A,onChange:e=>{ct(e),N(1)}})}),x?(0,y.jsx)(Ce,{message:x,onClose:()=>S(``)}):null,(0,y.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,y.jsx)(`div`,{ref:_t,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,y.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:J.tableStyle,children:[(0,y.jsx)(`colgroup`,{children:q.map(e=>(0,y.jsx)(`col`,{style:J.widthOf(e.key)?{width:J.widthOf(e.key)}:void 0},e.key))}),(0,y.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsxs)(`th`,{className:`${Ue} relative`,children:[`ID`,(0,y.jsx)(_,{...J.resizeProps(`id`)})]}),(0,y.jsxs)(`th`,{className:Ve,style:{"--tw-sticky-left":`${vt}px`},children:[`缺陷标题`,(0,y.jsx)(_,{...J.resizeProps(`title`)})]}),K.isVisible(`severity`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`严重程度`,(0,y.jsx)(_,{...J.resizeProps(`severity`)})]}):null,K.isVisible(`status`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`缺陷状态`,(0,y.jsx)(_,{...J.resizeProps(`status`)})]}):null,!t&&K.isVisible(`project`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,y.jsx)(_,{...J.resizeProps(`project`)})]}):null,K.isVisible(`iteration`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,y.jsx)(_,{...J.resizeProps(`iteration`)})]}):null,K.isVisible(`createdAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,y.jsx)(_,{...J.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,y.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,y.jsx)(_,{...J.resizeProps(`updatedAt`)})]}):null,(0,y.jsx)(`th`,{"aria-hidden":`true`}),(0,y.jsx)(`th`,{className:Ie,children:`操作`})]})}),(0,y.jsxs)(`tbody`,{children:[l&&!i.bugs.length?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,className:`px-4 py-16 text-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):wt.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:q.length,children:X?(0,y.jsx)(De,{children:`没有符合筛选条件的缺陷。`}):(0,y.jsx)(Me,{icon:`bug`,title:`暂无缺陷`,hint:`记录第一个缺陷,跟踪严重程度与修复状态。`,action:(0,y.jsxs)(`button`,{type:`button`,onClick:$,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,y.jsx)(m,{name:`plus`,size:13}),`新建缺陷`]})})})}):null,wt.map(e=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,y.jsx)(`td`,{className:`${He} font-mono text-xs text-stone-400`,children:e.autoId}),(0,y.jsx)(`td`,{className:Be,style:{"--tw-sticky-left":`${vt}px`},children:(0,y.jsx)(_e,{text:e.title,onClick:()=>I({id:e.id,projectId:e.projectId,iterationId:e.iterationId,requirementId:e.requirementId,title:e.title,severity:e.severity,status:e.status,reproduceSteps:e.reproduceSteps||e.title,expectedResult:e.expectedResult,actualResult:e.actualResult,environment:e.environment,githubIssue:e.githubIssue,attachment:e.attachment,remark:e.remark})})}),K.isVisible(`severity`)?(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(be,{tone:je[e.severity],children:fe[e.severity]})}):null,K.isVisible(`status`)?(0,y.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,y.jsx)(a,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:L,options:at,value:e.status,onChange:t=>void jt(e,t),renderOptionPrefix:e=>(0,y.jsx)(Ae,{tone:Oe[e.value]}),renderTrigger:()=>(0,y.jsx)(be,{tone:Oe[e.status],children:ue[e.status]})})}):null,!t&&K.isVisible(`project`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,y.jsx)(`a`,{href:ve(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:xt(e.projectId)})}):null,K.isVisible(`iteration`)?(0,y.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:St(e.iterationId)}):null,K.isVisible(`createdAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.createdAt)}):null,K.isVisible(`updatedAt`)?(0,y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:u(e.updatedAt)}):null,(0,y.jsx)(`td`,{"aria-hidden":`true`}),(0,y.jsx)(`td`,{className:Re,children:(0,y.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:L,onClick:()=>U(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,y.jsx)(m,{name:`trash`,size:15})})})]},e.id))]})]})}),Y.length>0?(0,y.jsx)(ne,{page:Z,totalPages:Ct,pageSize:P,busy:L,onPage:N,onPageSize:e=>{ft(e),N(1)}}):null]}),(0,y.jsx)(Se,{open:F!==null,title:F?.id?`编辑缺陷`:`新建缺陷`,busy:L,submitLabel:F?.id?`保存`:`创建`,onClose:At,onSubmit:()=>void Dt(),children:F?(0,y.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,y.jsx)(f,{label:`所属项目`,required:!0,children:(0,y.jsx)(h,{ariaLabel:`所属项目`,options:i.projects.map(e=>({value:e.id,label:e.name})),value:F.projectId,onChange:e=>I({...F,projectId:e,iterationId:``,requirementId:``})})}),(0,y.jsx)(f,{label:`所属迭代`,children:(0,y.jsx)(h,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...Tt.map(e=>({value:e.id,label:e.name}))],value:F.iterationId,onChange:e=>I({...F,iterationId:e}),disabled:Tt.length===0})}),(0,y.jsx)(f,{label:`关联需求`,children:(0,y.jsx)(h,{ariaLabel:`关联需求`,options:[{value:``,label:`不关联需求`},...Et.map(e=>({value:e.id,label:`${e.autoId} ${e.title}`}))],value:F.requirementId,onChange:e=>I({...F,requirementId:e}),disabled:Et.length===0})}),(0,y.jsx)(f,{label:`缺陷描述`,required:!0,children:(0,y.jsx)(`textarea`,{autoFocus:!0,value:F.reproduceSteps,onChange:e=>I({...F,reproduceSteps:e.target.value}),placeholder:`描述问题现象、复现步骤与影响范围`,rows:5,className:xe})}),(0,y.jsx)(f,{label:`严重程度`,children:(0,y.jsx)(h,{ariaLabel:`严重程度`,options:it,value:F.severity,onChange:e=>I({...F,severity:e}),renderOptionPrefix:e=>(0,y.jsx)(Ae,{tone:je[e.value]})})}),(0,y.jsx)(f,{label:`附件`,children:(0,y.jsxs)(`div`,{className:`space-y-2`,children:[G.length?(0,y.jsx)(`ul`,{className:`space-y-1.5`,children:G.map(e=>{let t=ie(e.url);return(0,y.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,y.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,y.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,y.jsx)(m,{name:`file`,size:15})}),t?(0,y.jsx)(`button`,{type:`button`,onClick:()=>W(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,y.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,y.jsx)(`button`,{type:`button`,"aria-label":`移除附件 ${e.name}`,onClick:()=>kt(e.url),className:`tw-icon-danger flex h-6 w-6 shrink-0 items-center justify-center rounded`,children:`✕`})]},e.url)})}):null,(0,y.jsx)(`input`,{ref:B,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void Q(e.target.files)}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>B.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,y.jsx)(m,{name:z?`file`:`plus`,size:13}),z?`上传中…`:`上传文件 / 图片`]}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可直接粘贴截图 / 图片(⌘V / Ctrl+V),支持多张`})]})]})}),(0,y.jsx)(f,{label:`备注`,children:(0,y.jsx)(`textarea`,{value:F.remark,onChange:e=>I({...F,remark:e.target.value}),rows:2,className:xe})}),F.id?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f,{label:`创建日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(i.bugs.find(e=>e.id===F.id)?.createdAt)})}),(0,y.jsx)(f,{label:`修改日期`,children:(0,y.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:u(i.bugs.find(e=>e.id===F.id)?.updatedAt)})})]}):null]}):null}),(0,y.jsx)(ee,{open:H!==null,title:`删除缺陷`,message:`确定删除「${H?.title??``}」?此操作无法恢复。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>U(null),onConfirm:()=>void Mt()}),(0,y.jsx)(Te,{file:mt,onClose:()=>W(null)})]})}export{T as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.BRvXWHLe.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DrrPf1MB.js";import{t as a}from"./DatePicker.Bkl71M49.js";import{t as o}from"./SelectDropdown.T3CKHaLt.js";import{L as s,O as ee,P as te,R as c,S as l,a as u,g as ne,h as re,k as ie,o as d}from"./pm.BXmOiFfW.js";import{A as ae,D as oe,O as se,S as f,_ as p,a as ce,c as le,d as ue,f as m,g as h,i as g,j as _,k as v,l as de,m as y,r as b,s as fe,u as pe,v as x,y as S}from"./PmShared.BK8kWRSV.js";import{showToast as C}from"./Toast.BO2NFckG.js";var w=e(t(),1),T=r(),E=10,me=[`all`,...u],he=`pm.iterations.project`,ge=`pm.iterations.status`,_e=`pm.iterations.keyword`,D=u.map(e=>({value:e,label:d[e]}));function O(e=``){return{projectId:e,name:``,startDate:``,endDate:``,status:`planning`,remark:``}}function k({scopeProjectId:e=``}={}){let t=!!e,r=ae(`iterations`),{store:u,live:k,loading:A,error:j,setError:M,reload:N}=_(),[P,F]=v(he,`all`),I=e||P,[L,ve]=se(ge,me,`all`),[R,ye]=v(_e),[be,z]=(0,w.useState)(1),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(null),K=s(),q=(0,w.useMemo)(()=>{let e=new Map(u.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`未关联项目`},[u.projects]),xe=(0,w.useMemo)(()=>[{value:`all`,label:`全部项目`},...u.projects.map(e=>({value:e.id,label:e.name}))],[u.projects]),J=(0,w.useMemo)(()=>te(l(u.iterations,{projectId:I,status:L,keyword:R})),[u.iterations,I,L,R]),Y=t?u.iterations.filter(e=>e.projectId===I).length:u.iterations.length,X=Math.max(1,Math.ceil(J.length/E)),Z=Math.min(be,X),Q=J.slice((Z-1)*E,Z*E);(0,w.useEffect)(()=>{t||k===!0&&P!==`all`&&!u.projects.some(e=>e.id===P)&&F(`all`)},[k,u.projects,P,F,t]);async function Se(){if(!B)return;if(!B.projectId){M(`请先选择所属项目`);return}let e=B.name.trim();if(!e)M(`迭代名称不能为空`);else if(B.startDate&&B.endDate&&B.endDate<B.startDate)M(`迭代结束日期不能早于开始日期`);else{U(!0);try{let t={projectId:B.projectId,name:e,startDate:B.startDate,endDate:B.endDate,status:B.status,remark:B.remark};B.id?await c(`iterations`,B.id,t):await re(`iterations`,[t]),V(null),M(``),await N(!0),C(B.id?`已保存迭代`:`已新建迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`保存迭代失败:${t}`,`error`)}finally{U(!1)}}}async function $(e,t){U(!0);try{await c(`iterations`,e.id,{status:t}),await N(!0),C(`已更新迭代状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`更新迭代失败:${t}`,`error`)}finally{U(!1)}}async function Ce(){let e=W;if(e){G(null),U(!0);try{await ne(`iterations`,[e.id]),await N(!0),C(`已删除迭代`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),C(`删除迭代失败:${t}`,`error`)}finally{U(!1)}}}return r.ready?r.on?k===null?(0,T.jsx)(h,{label:`正在连接项目管理服务`}):k?u.projects.length===0&&!A&&!t?(0,T.jsx)(p,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护迭代。`}):(0,T.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-600`,children:Y}),` 个迭代`,J.length===Y?``:` · 筛选出 ${J.length} 个`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选迭代`,className:`w-36`,options:xe,value:P,onChange:e=>{F(e),z(1)}}),(0,T.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按状态筛选迭代`,className:`w-28`,options:[{value:`all`,label:`全部状态`},...D],value:L,onChange:e=>{ve(e),z(1)}}),(0,T.jsxs)(`label`,{className:`relative block`,children:[(0,T.jsx)(y,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,T.jsx)(`input`,{value:R,onChange:e=>{ye(e.target.value),z(1)},placeholder:`搜索迭代名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>V(O(I===`all`?``:I)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`plus`,size:14}),`新建迭代`]})]})]}),j?(0,T.jsx)(ue,{message:j,onClose:()=>M(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pb-4`,children:A&&!u.iterations.length?(0,T.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):Q.length===0?Y?(0,T.jsx)(de,{children:`没有符合筛选条件的迭代。`}):(0,T.jsx)(pe,{icon:`calendar`,title:`暂无迭代`,hint:`新建一个迭代,用开始 / 截止日期跟踪进度。`,action:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(O(I===`all`?``:I)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,T.jsx)(y,{name:`plus`,size:13}),`新建迭代`]})}):(0,T.jsx)(`div`,{className:`space-y-3`,children:Q.map(e=>{let n=ie(e,K),r=ee(e,K),i=e.endDate&&e.status!==`done`?Math.round((Date.parse(`${e.endDate}T00:00:00`)-Date.parse(`${K}T00:00:00`))/864e5):null;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3.5 transition-[border-color,box-shadow] hover:border-[#ddd6fe] hover:shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate text-[15px] font-medium text-stone-800`,children:e.name}),(0,T.jsx)(f,{tone:b[e.status],children:d[e.status]})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-500`,children:[t?null:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`a`,{href:oe(e.projectId),className:`transition-colors hover:text-[#3370ff]`,children:q(e.projectId)}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`})]}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[e.startDate||`—`,` → `,e.endDate||`—`]}),r===null?i!==null&&i>=0&&e.endDate?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[`还剩 `,i,` 天`]}):null:(0,T.jsxs)(`span`,{className:`text-red-500`,children:[`逾期 `,r,` 天`]})]}),e.remark?(0,T.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-stone-400`,children:e.remark}):null]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status===`planning`?(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>void $(e,`in_progress`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`play`,size:12}),`开始`]}):null,e.status===`in_progress`?(0,T.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>void $(e,`done`),className:`inline-flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:[(0,T.jsx)(y,{name:`check`,size:12}),`完成`]}):null,(0,T.jsx)(`button`,{type:`button`,"aria-label":`编辑 ${e.name}`,onClick:()=>V({id:e.id,projectId:e.projectId,name:e.name,startDate:e.startDate,endDate:e.endDate,status:e.status,remark:e.remark}),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(y,{name:`pencil`,size:15})}),(0,T.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.name}`,disabled:H,onClick:()=>G(e),className:`tw-icon-danger flex h-8 w-8 items-center justify-center rounded-lg`,children:(0,T.jsx)(y,{name:`trash`,size:15})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,T.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-300`,style:{width:`${n}%`}})}),(0,T.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[n,`%`]})]})]},e.id)})})}),J.length>0?(0,T.jsx)(x,{page:Z,totalPages:X,busy:H,onPage:z}):null,(0,T.jsx)(le,{open:B!==null,title:B?.id?`编辑迭代`:`新建迭代`,busy:H,submitLabel:B?.id?`保存`:`创建`,onClose:()=>V(null),onSubmit:()=>void Se(),children:B?(0,T.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,T.jsx)(m,{label:`所属项目`,required:!0,children:(0,T.jsx)(S,{ariaLabel:`所属项目`,options:u.projects.map(e=>({value:e.id,label:e.name})),value:B.projectId,onChange:e=>V({...B,projectId:e}),disabled:u.projects.length===0})}),(0,T.jsx)(m,{label:`迭代名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:B.name,onChange:e=>V({...B,name:e.target.value}),placeholder:`如:v1.0 迭代`,className:g})}),(0,T.jsx)(m,{label:`开始日期`,children:(0,T.jsx)(a,{value:B.startDate,onChange:e=>V({...B,startDate:e}),placeholder:`选择开始日期`,className:`${g} tabular-nums`})}),(0,T.jsx)(m,{label:`截止日期`,children:(0,T.jsx)(a,{value:B.endDate,onChange:e=>V({...B,endDate:e}),placeholder:`选择截止日期`,className:`${g} tabular-nums`})}),(0,T.jsx)(m,{label:`状态`,children:(0,T.jsx)(S,{ariaLabel:`迭代状态`,options:D,value:B.status,onChange:e=>V({...B,status:e}),renderOptionPrefix:e=>(0,T.jsx)(fe,{tone:b[e.value]})})}),(0,T.jsx)(m,{label:`备注`,children:(0,T.jsx)(`textarea`,{value:B.remark,onChange:e=>V({...B,remark:e.target.value}),placeholder:`迭代目标、范围等(可选)`,rows:3,className:ce})})]}):null}),(0,T.jsx)(i,{open:W!==null,title:`删除迭代`,message:`确定删除「${W?.name??``}」?关联的需求与缺陷会保留,但不再关联到这个迭代。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>G(null),onConfirm:()=>void Ce()})]}):(0,T.jsx)(p,{children:`迭代管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(p,{children:n(`iterations`)}):(0,T.jsx)(h,{label:`正在读取插件开关`})}export{k as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.BRvXWHLe.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.DrrPf1MB.js";import{t as te}from"./SelectDropdown.T3CKHaLt.js";import{C as i,M as a,R as o,c as s,g as ne,h as re,s as c}from"./pm.BXmOiFfW.js";import{A as ie,D as ae,O as l,S as u,_ as d,a as f,c as p,d as m,f as h,g,i as _,j as v,k as y,l as b,m as x,o as S,s as oe,u as se,v as ce,y as le}from"./PmShared.BK8kWRSV.js";import{showToast as C}from"./Toast.BO2NFckG.js";var w=e(t(),1),T=r(),E=10,D=c.map(e=>({value:e,label:s[e]})),O=[`all`,...c],k=`pm.projects.status`,A=`pm.projects.keyword`;function j(){return{name:``,description:``,status:`planning`}}function M(){let e=ie(`projects`),{store:t,live:r,loading:c,error:M,setError:N,reload:P}=v(),[F,I]=l(k,O,`all`),[L,R]=y(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)(()=>a(t),[t]),X=(0,w.useMemo)(()=>i(t.projects,{status:F,keyword:L}),[t.projects,F,L]),Z=Math.max(1,Math.ceil(X.length/E)),Q=Math.min(z,Z),$=X.slice((Q-1)*E,Q*E);(0,w.useEffect)(()=>{if(!q)return;function e(e){Y.current?.contains(e.target)||J(null)}function t(e){e.key===`Escape`&&J(null)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[q]);async function de(){if(!V)return;let e=V.name.trim();if(!e)N(`项目名称不能为空`);else{W(!0);try{V.id?await o(`projects`,V.id,{name:e,description:V.description,status:V.status}):await re(`projects`,[{name:e,description:V.description,status:V.status}]),H(null),N(``),await P(!0),C(V.id?`已保存项目`:`已新建项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`保存项目失败:${t}`,`error`)}finally{W(!1)}}}async function fe(e){J(null),W(!0);try{let t=e.status!==`archived`;await o(`projects`,e.id,{status:t?`archived`:`planning`}),await P(!0),C(t?`已归档「${e.name}」`:`已取消归档「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`更新项目失败:${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),C(`已删除项目`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);N(t),C(`删除项目失败:${t}`,`error`)}finally{W(!1)}}}return e.ready?e.on?r===null?(0,T.jsx)(g,{label:`正在连接项目管理服务`}):r?(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)(x,{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)(x,{name:`plus`,size:14}),`新建项目`]})]})]}),M?(0,T.jsx)(m,{message:M,onClose:()=>N(``)}):null,(0,T.jsx)(`div`,{className:`mt-4 min-h-0 flex-1 overflow-auto pt-1 pb-4`,children:c&&!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)(b,{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)(x,{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:ae(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)(u,{tone:S[e.status],children:s[e.status]})]}),(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-[40px] text-sm ${e.description?`text-stone-500`:`italic text-stone-300`}`,children:e.description||`暂无描述`}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-stone-500`,children:[(0,T.jsxs)(`span`,{children:[t?.iterations??0,` 迭代`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.requirements??0,` 需求`]}),(0,T.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,T.jsxs)(`span`,{children:[t?.bugs??0,` 缺陷`]})]}),(0,T.jsxs)(`div`,{className:`mt-auto flex items-center justify-between pt-4`,children:[(0,T.jsxs)(`div`,{className:`pointer-events-auto relative`,ref:q===e.id?Y:void 0,children:[(0,T.jsx)(`button`,{type:`button`,"aria-label":`${e.name} 的操作`,"aria-haspopup":`menu`,"aria-expanded":q===e.id,onClick:()=>J(q===e.id?null:e.id),className:`flex h-8 w-8 items-center justify-center rounded-lg text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,children:(0,T.jsx)(x,{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)(x,{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)(x,{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)(x,{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)(x,{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)(p,{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)(h,{label:`项目名称`,required:!0,children:(0,T.jsx)(`input`,{autoFocus:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),placeholder:`输入项目名称`,className:_})}),(0,T.jsx)(h,{label:`描述`,children:(0,T.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),placeholder:`项目描述(可选)`,rows:4,className:f})}),(0,T.jsx)(h,{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:S[e.value]})})})]}):null}),(0,T.jsx)(ee,{open:G!==null,title:`删除项目`,message:`确定删除「${G?.name??``}」?该项目下的迭代、需求与缺陷会一并删除,且无法恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:`solid`,onClose:()=>K(null),onConfirm:()=>void pe()})]}):(0,T.jsx)(d,{children:`项目列表需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,T.jsx)(d,{children:n(`projects`)}):(0,T.jsx)(g,{label:`正在读取插件开关`})}export{M as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PmRequirementsBoard.DsK6RF7Q.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{s as n}from"./plugins.BRvXWHLe.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./ConfirmDialog.DrrPf1MB.js";import{n as a,t as ee}from"./DocsPager.Duf4I68E.js";import{t as o}from"./SelectDropdown.T3CKHaLt.js";import{A as s,D as c,F as l,P as u,R as d,b as f,d as p,f as m,g as te,h,j as g,l as _,m as ne,u as v,w as re,z as y}from"./pm.BXmOiFfW.js";import{A as ie,C as ae,D as oe,E as b,O as se,S as ce,T as x,_ as S,a as le,c as ue,d as de,f as C,g as fe,h as w,j as pe,k as T,l as me,m as E,p as he,s as D,u as ge,w as _e,y as O}from"./PmShared.BK8kWRSV.js";import{n as ve,r as ye,t as be}from"./TableFieldConfig.C7O-mL-p.js";import{showToast as k}from"./Toast.BO2NFckG.js";import{c as xe,d as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe,t as A}from"./ColumnResize.CkE59sGq.js";var j=e(t(),1),M=r();function ke({value:e,onChange:t,entity:n,recordId:r=``,seenUrls:i,onError:a,onPersisted:ee}){let o=g(e),[l,u]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),[te,h]=(0,j.useState)(null),_=(0,j.useRef)(null);(0,j.useEffect)(()=>{for(let t of g(e))i.current.add(t.url)},[e,i]);let v=(0,j.useCallback)(async n=>{if(n&&n.length){u(!0);try{let r=await y(Array.from(n));t(s([...g(e),...r])),a(``)}catch(e){a(e instanceof Error?e.message:String(e))}finally{u(!1),_.current&&(_.current.value=``)}}},[t,a,e]);(0,j.useEffect)(()=>{let e=e=>{let t=f(e.clipboardData);t.length&&(e.preventDefault(),v(t))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[v]);async function re(e){let i=s(o.filter(t=>t.url!==e));if(r)try{await d(n,r,{attachment:i}),ee?.()}catch(e){a(e instanceof Error?e.message:String(e));return}t(i),ne([e],r)}return(0,M.jsxs)(`div`,{className:`space-y-2 rounded-lg transition-colors ${p?`bg-[#3370ff]/5 ring-1 ring-[#3370ff]/40`:``}`,onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{e.preventDefault(),m(!1),v(e.dataTransfer?.files??null)},children:[o.length?(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-stone-200 px-2 py-1.5`,children:[c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(e),"aria-label":`预览附件 ${e.name}`,className:`shrink-0 cursor-zoom-in`,children:(0,M.jsx)(`img`,{src:e.url,alt:e.name,className:`h-9 w-9 rounded-md border border-stone-100 object-cover`})}):(0,M.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-stone-100 text-stone-400`,children:(0,M.jsx)(E,{name:`file`,size:15})}),c(e.url)?(0,M.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`min-w-0 flex-1 truncate text-left text-sm text-stone-700 hover:text-[#3370ff]`,children:e.name}):(0,M.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,M.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,M.jsx)(`input`,{ref:_,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void v(e.target.files)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>_.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,M.jsx)(E,{name:l?`file`:`plus`,size:13}),l?`上传中…`:`上传文件 / 图片`]}),(0,M.jsx)(`span`,{className:`text-xs text-stone-400`,children:`可拖拽到这里,或直接粘贴截图(⌘V / Ctrl+V),支持多张`})]}),(0,M.jsx)(w,{file:te,onClose:()=>h(null)})]})}var Ae=[{key:`id`,width:88,min:72},{key:`title`,width:280,min:160},{key:`priority`,width:100,min:80},{key:`status`,width:120,min:96}],je={key:`project`,width:140,min:100},Me=[{key:`iteration`,width:120,min:88},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],Ne=new Set([`id`,`title`,`filler`,`action`]),Pe=[{key:`priority`,label:`优先级`},{key:`status`,label:`需求状态`},{key:`iteration`,label:`所属迭代`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Fe=`pm.requirements.fields`,Ie=20,Le=`tw.pm-requirements.page-size.v1`,Re=[`all`,...p],ze=[`all`,..._],Be=`pm.requirements.project`,Ve=`pm.requirements.iteration`,He=`pm.requirements.status`,Ue=`pm.requirements.priority`,We=`pm.requirements.keyword`,Ge=_.map(e=>({value:e,label:v[e]})),N=p.map(e=>({value:e,label:m[e]}));function Ke(e=``){return{projectId:e,iterationId:``,title:``,priority:`medium`,status:`pending`,description:``,acceptanceCriteria:[],githubIssue:``,attachment:``}}function P({scopeProjectId:e=``}={}){let t=!!e,r=ie(`pmRequirements`),{store:s,live:c,loading:f,error:p,setError:_,reload:y}=pe(),[w,P]=T(Be,`all`),F=e||w,[I,L]=T(Ve,`all`),[R,qe]=se(He,Re,`all`),[z,Je]=se(Ue,ze,`all`),[B,Ye]=T(We),[Xe,V]=(0,j.useState)(1),[H,Ze]=a(Ie,Le),[U,W]=(0,j.useState)(null),[G,K]=(0,j.useState)(!1),[q,J]=(0,j.useState)(null),Y=(0,j.useRef)(new Set),Qe=(0,j.useMemo)(()=>t?Pe:[{key:`project`,label:`所属项目`},...Pe],[t]),X=ye(Fe,Qe,Ne),$e=(0,j.useMemo)(()=>t?[...Ae,...Me]:[...Ae,je,...Me],[t]),Z=(0,j.useMemo)(()=>ve($e,X.isVisible),[$e,X.isVisible]),Q=we(t?`pm.requirements.cols.scoped.v2`:`pm.requirements.cols.v2`,Z),et=Se(t?`pm.requirements.scroll.scoped`:`pm.requirements.scroll`),tt=Q.widthOf(`id`)??88,nt=(0,j.useMemo)(()=>[{value:`all`,label:`全部项目`},...s.projects.map(e=>({value:e.id,label:e.name}))],[s.projects]),rt=(0,j.useMemo)(()=>[{value:`all`,label:`全部迭代`},...u(s.iterations.filter(e=>F===`all`||e.projectId===F)).map(e=>({value:e.id,label:e.name}))],[s.iterations,F]),it=(0,j.useMemo)(()=>{let e=new Map(s.projects.map(e=>[e.id,e.name]));return t=>e.get(t)??`—`},[s.projects]),at=(0,j.useMemo)(()=>{let e=new Map(s.iterations.map(e=>[e.id,e.name]));return t=>t?e.get(t)??`—`:`—`},[s.iterations]),$=(0,j.useMemo)(()=>l(re(s.requirements,{projectId:F,iterationId:I,status:R,priority:z,keyword:B})),[s.requirements,F,I,R,z,B]),ot=t?s.requirements.filter(e=>e.projectId===F).length:s.requirements.length,st=Math.max(1,Math.ceil($.length/H)),ct=Math.min(Xe,st),lt=$.slice((ct-1)*H,ct*H);(0,j.useEffect)(()=>{t||c===!0&&w!==`all`&&!s.projects.some(e=>e.id===w)&&P(`all`)},[c,s.projects,w,P,t]),(0,j.useEffect)(()=>{c===!0&&I!==`all`&&!s.iterations.some(e=>e.id===I&&(F===`all`||e.projectId===F))&&L(`all`)},[c,s.iterations,F,I,L]);let ut=U?u(s.iterations.filter(e=>e.projectId===U.projectId)):[];async function dt(){if(!U)return;if(!U.projectId){_(`请先选择所属项目`);return}let e=U.title.trim();if(!e)_(`需求描述不能为空`);else{K(!0);try{let t={projectId:U.projectId,iterationId:U.iterationId,title:e,priority:U.priority,status:U.status,description:U.description,acceptanceCriteria:U.acceptanceCriteria.filter(e=>e.text.trim()),githubIssue:U.githubIssue,attachment:U.attachment};U.id?await d(`requirements`,U.id,t):await h(`requirements`,[t]);let n=!!U.id;W(null),Y.current.clear(),_(``),await y(!0),k(n?`已保存需求`:`已新建需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`保存需求失败:${t}`,`error`)}finally{K(!1)}}}function ft(){let e=[...Y.current,...g(U?.attachment??``).map(e=>e.url)];Y.current.clear(),W(null),e.length&&ne(e)}async function pt(e,t){K(!0);try{await d(`requirements`,e.id,{status:t}),await y(!0),k(`已更新需求状态为「${t}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`更新状态失败:${t}`,`error`)}finally{K(!1)}}async function mt(){let e=q;if(e){J(null),K(!0);try{await te(`requirements`,[e.id]),await y(!0),k(`已删除需求`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),k(`删除需求失败:${t}`,`error`)}finally{K(!1)}}}if(!r.ready)return(0,M.jsx)(fe,{label:`正在读取插件开关`});if(!r.on)return(0,M.jsx)(S,{children:n(`pmRequirements`)});if(c===null)return(0,M.jsx)(fe,{label:`正在连接项目管理服务`});if(!c)return(0,M.jsx)(S,{children:`需求管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});if(s.projects.length===0&&!f&&!t)return(0,M.jsx)(S,{children:`还没有项目。请先在「项目列表」里新建一个项目,再回来维护需求。`});let ht=[{value:`all`,label:`全部`},...N];return(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`div`,{className:`text-xs text-stone-400`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:ot}),` 条需求`,$.length===ot?``:` · 筛选出 ${$.length} 条`]}),(0,M.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[t?null:(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按项目筛选需求`,className:`w-36`,options:nt,value:w,onChange:e=>{P(e),L(`all`),V(1)}}),(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按迭代筛选需求`,className:`w-32`,options:rt,value:I,onChange:e=>{L(e),V(1)}}),(0,M.jsx)(o,{flat:!0,showCheck:!1,ariaLabel:`按优先级筛选需求`,className:`w-28`,options:[{value:`all`,label:`全部优先级`},...Ge],value:z,onChange:e=>{Je(e),V(1)}}),(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(E,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:B,onChange:e=>{Ye(e.target.value),V(1)},placeholder:`搜索编号 / 名称…`,className:`h-9 w-44 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,M.jsx)(be,{fields:X.fields,isVisible:X.isVisible,onToggle:X.toggle}),(0,M.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:[(0,M.jsx)(E,{name:`plus`,size:14}),`新建需求`]})]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex shrink-0 flex-wrap items-center gap-2`,children:(0,M.jsx)(he,{ariaLabel:`按状态筛选需求`,options:ht,value:R,onChange:e=>{qe(e),V(1)}})}),p?(0,M.jsx)(de,{message:p,onClose:()=>_(``)}):null,(0,M.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,M.jsx)(`div`,{ref:et,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,M.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:Q.tableStyle,children:[(0,M.jsx)(`colgroup`,{children:Z.map(e=>(0,M.jsx)(`col`,{style:Q.widthOf(e.key)?{width:Q.widthOf(e.key)}:void 0},e.key))}),(0,M.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,M.jsxs)(`tr`,{children:[(0,M.jsxs)(`th`,{className:`${Oe} relative`,children:[`ID`,(0,M.jsx)(A,{...Q.resizeProps(`id`)})]}),(0,M.jsxs)(`th`,{className:Ee,style:{"--tw-sticky-left":`${tt}px`},children:[`需求描述`,(0,M.jsx)(A,{...Q.resizeProps(`title`)})]}),X.isVisible(`priority`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`优先级`,(0,M.jsx)(A,{...Q.resizeProps(`priority`)})]}):null,X.isVisible(`status`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`需求状态`,(0,M.jsx)(A,{...Q.resizeProps(`status`)})]}):null,!t&&X.isVisible(`project`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属项目`,(0,M.jsx)(A,{...Q.resizeProps(`project`)})]}):null,X.isVisible(`iteration`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属迭代`,(0,M.jsx)(A,{...Q.resizeProps(`iteration`)})]}):null,X.isVisible(`createdAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,M.jsx)(A,{...Q.resizeProps(`createdAt`)})]}):null,X.isVisible(`updatedAt`)?(0,M.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,M.jsx)(A,{...Q.resizeProps(`updatedAt`)})]}):null,(0,M.jsx)(`th`,{"aria-hidden":`true`}),(0,M.jsx)(`th`,{className:xe,children:`操作`})]})}),(0,M.jsxs)(`tbody`,{children:[f&&!s.requirements.length?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,className:`px-4 py-16 text-center`,children:(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):lt.length===0?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:Z.length,children:ot?(0,M.jsx)(me,{children:`没有符合筛选条件的需求。`}):(0,M.jsx)(ge,{icon:`file`,title:`暂无需求`,hint:`拆出第一条需求,再关联迭代、补充描述。`,action:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>W(Ke(F===`all`?``:F)),className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(E,{name:`plus`,size:13}),`新建需求`]})})})}):null,lt.map(e=>(0,M.jsxs)(`tr`,{className:`border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,M.jsx)(`td`,{className:`${De} font-mono text-xs text-stone-400`,children:e.autoId}),(0,M.jsx)(`td`,{className:Te,style:{"--tw-sticky-left":`${tt}px`},children:(0,M.jsx)(ae,{text:e.title,onClick:()=>W({id:e.id,projectId:e.projectId,iterationId:e.iterationId,title:e.title,priority:e.priority,status:e.status,description:e.description,acceptanceCriteria:e.acceptanceCriteria.map(e=>({...e})),githubIssue:e.githubIssue,attachment:e.attachment})})}),X.isVisible(`priority`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,M.jsx)(ce,{tone:_e[e.priority],children:v[e.priority]})}):null,X.isVisible(`status`)?(0,M.jsx)(`td`,{className:`min-w-0 overflow-hidden px-2 py-1 align-middle`,children:(0,M.jsx)(o,{unstyled:!0,fitContent:!0,hideChevron:!0,ariaLabel:`修改 ${e.title} 的状态`,disabled:G,options:N,value:e.status,onChange:t=>void pt(e,t),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]}),renderTrigger:()=>(0,M.jsx)(ce,{tone:x[e.status],children:m[e.status]})})}):null,!t&&X.isVisible(`project`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-600`,children:(0,M.jsx)(`a`,{href:oe(e.projectId),className:`block truncate transition-colors hover:text-[#3370ff]`,children:it(e.projectId)})}):null,X.isVisible(`iteration`)?(0,M.jsx)(`td`,{className:`min-w-0 truncate px-2 py-1 align-middle text-sm text-stone-500`,children:at(e.iterationId)}):null,X.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.createdAt)}):null,X.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:b(e.updatedAt)}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:Ce,children:(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,disabled:G,onClick:()=>J(e),className:`tw-icon-danger inline-flex h-7 w-7 items-center justify-center rounded-md`,children:(0,M.jsx)(E,{name:`trash`,size:15})})})]},e.id))]})]})}),$.length>0?(0,M.jsx)(ee,{page:ct,totalPages:st,pageSize:H,busy:G,onPage:V,onPageSize:e=>{Ze(e),V(1)}}):null]}),(0,M.jsx)(ue,{open:U!==null,title:U?.id?`编辑需求`:`新建需求`,busy:G,submitLabel:U?.id?`保存`:`创建`,onClose:()=>ft(),onSubmit:()=>void dt(),children:U?(0,M.jsxs)(`div`,{className:`space-y-1`,children:[t?null:(0,M.jsx)(C,{label:`所属项目`,required:!0,children:(0,M.jsx)(O,{ariaLabel:`所属项目`,options:s.projects.map(e=>({value:e.id,label:e.name})),value:U.projectId,onChange:e=>{let t=s.iterations.some(t=>t.id===U.iterationId&&t.projectId===e);W({...U,projectId:e,iterationId:t?U.iterationId:``})}})}),(0,M.jsx)(C,{label:`所属迭代`,children:(0,M.jsx)(O,{ariaLabel:`所属迭代`,options:[{value:``,label:`不关联迭代`},...ut.map(e=>({value:e.id,label:e.name}))],value:U.iterationId,onChange:e=>W({...U,iterationId:e}),disabled:ut.length===0})}),(0,M.jsx)(C,{label:`需求描述`,required:!0,children:(0,M.jsx)(`textarea`,{autoFocus:!0,value:U.title,onChange:e=>W({...U,title:e.target.value}),placeholder:`一句话写清要做什么`,rows:3,className:le})}),(0,M.jsx)(C,{label:`优先级`,children:(0,M.jsx)(O,{ariaLabel:`优先级`,options:Ge,value:U.priority,onChange:e=>W({...U,priority:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:_e[e.value]})})}),(0,M.jsx)(C,{label:`需求状态`,children:(0,M.jsx)(O,{ariaLabel:`需求状态`,options:N,value:U.status,onChange:e=>W({...U,status:e}),renderOptionPrefix:e=>(0,M.jsx)(D,{tone:x[e.value]})})}),(0,M.jsx)(C,{label:`附件`,children:(0,M.jsx)(ke,{value:U.attachment,onChange:e=>W(t=>t&&{...t,attachment:e}),entity:`requirements`,recordId:U.id??``,seenUrls:Y,onError:_,onPersisted:()=>void y(!0)})}),(0,M.jsx)(C,{label:`备注`,children:(0,M.jsx)(`textarea`,{value:U.description,onChange:e=>W({...U,description:e.target.value}),placeholder:`补充背景、目标与范围(可选)`,rows:4,className:le})}),U.id?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(C,{label:`创建日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(s.requirements.find(e=>e.id===U.id)?.createdAt)})}),(0,M.jsx)(C,{label:`修改日期`,children:(0,M.jsx)(`div`,{className:`px-0.5 py-1.5 text-sm text-stone-500`,children:b(s.requirements.find(e=>e.id===U.id)?.updatedAt)})})]}):null]}):null}),(0,M.jsx)(i,{open:q!==null,title:`删除需求`,message:`确定删除「${q?.title??``}」?关联的缺陷会保留,但不再关联到这条需求。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>J(null),onConfirm:()=>void mt()})]})}export{P as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DkyjuL-S.js";import{i as r,o as i}from"./plugins.BRvXWHLe.js";import{n as a,o,r as s,s as c}from"./view-prefs.DhdLZjGh.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.CHZeFfUj.js";import{t as f}from"./SelectDropdown.T3CKHaLt.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";var g=e(t(),1),_=e(l(),1),v=u(),y=280;function b({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,widthClass:i=`max-w-md`,escDisabled:a=!1,bodyClassName:o,children:s,footer:c}){let[l,u]=(0,g.useState)(e),[d,f]=(0,g.useState)(!1);if((0,g.useEffect)(()=>{if(e){u(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>f(!0))});return()=>window.cancelAnimationFrame(e)}f(!1);let t=window.setTimeout(()=>u(!1),y);return()=>window.clearTimeout(t)},[e]),(0,g.useEffect)(()=>{if(!e||a)return;function n(e){e.key===`Escape`&&(document.querySelector(`[aria-haspopup="listbox"][aria-expanded="true"]`)||document.querySelector(`[data-pm-image-preview]`)||(e.preventDefault(),e.stopPropagation(),t()))}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,a]),!l)return null;let p=(0,v.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,v.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-[280ms] ease-out ${d?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,v.jsxs)(`aside`,{className:`tw-slide-over relative w-full ${i} h-full shadow-2xl border-l border-stone-200 flex flex-col transition-[translate] duration-[280ms] ease-[cubic-bezier(0.32,0.72,0,1)] will-change-[translate] ${d?`translate-x-0`:`translate-x-full`}`,children:[(0,v.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,v.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,v.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,v.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 ${o??`space-y-4`}`.trim(),children:s}),c]})]});return typeof document>`u`?p:(0,_.createPortal)(p,document.body)}var x=8e3;function S(e,t,n){let[r,i]=(0,g.useState)(()=>a(e,t,n));return[r,(0,g.useCallback)(t=>{i(t),o(e,t)},[e])]}function C(e,t=``){let[n,r]=(0,g.useState)(()=>s(e)||t);return[n,(0,g.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function w(e){let[t,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(()=>r(e));return(0,g.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 T=(0,g.createContext)(null);function E(e){let[t,n]=(0,g.useState)(p),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(``),l=(0,g.useRef)(!0),u=(0,g.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,g.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),x))):(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 D({children:e}){let t=E(!0);return(0,v.jsx)(T.Provider,{value:t,children:e})}function O(){let e=(0,g.useContext)(T),t=E(e===null);return e??t}var k={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`},A={planning:`blue`,in_progress:`amber`,archived:`gray`},j={planning:`blue`,in_progress:`amber`,done:`green`},M={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},N={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},P={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},F={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},I={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function L({tone:e}){return(0,v.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:I[e]}})}function ee({tone:e,children:t}){return(0,v.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${k[e]}`,children:t})}var R={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`],chat:[`M4 6.5A2.5 2.5 0 0 1 6.5 4h11A2.5 2.5 0 0 1 20 6.5v7a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 3.5V16H6.5A2.5 2.5 0 0 1 4 13.5Z`],terminal:[`m5 8 4 4-4 4`,`M13 16h6`],paste:[`M9 3.5h6v2.5H9Z`,`M8 4.8H6.6A1.6 1.6 0 0 0 5 6.4v12.5a1.6 1.6 0 0 0 1.6 1.6h10.8a1.6 1.6 0 0 0 1.6-1.6V6.4a1.6 1.6 0 0 0-1.6-1.6H16`,`M8.5 11h7`,`M8.5 15h7`],download:[`M12 4v10`,`m7.5 10 4.5 4.5 4.5-4.5`,`M5 20h14`],sliders:[`M4 8h6`,`M14 8h6`,`M4 16h10`,`M18 16h2`,`M10 8a2 2 0 1 0 4 0 2 2 0 1 0-4 0`,`M14 16a2 2 0 1 0 4 0 2 2 0 1 0-4 0`]};function z({name:e,size:t=16,className:n=``}){return e===`more`?(0,v.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,v.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,v.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:R[e].map(e=>(0,v.jsx)(`path`,{d:e},e))})}function B({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,v.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,v.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function V({options:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function H({icon:e,title:t,hint:n,action:r}){return(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,v.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,v.jsx)(z,{name:e,size:30})}),(0,v.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,v.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function U(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var W=`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`,G=`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 K(e){return(0,v.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 q({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,v.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,v.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function J({label:e}){return(0,v.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,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function Y({children:e}){return(0,v.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 X({children:e}){return(0,v.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function Z({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,v.jsx)(b,{open:e,onClose:i,title:t,footer:(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,v.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,v.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 Q({label:e,required:t,children:n}){return(0,v.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,v.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,v.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,v.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,v.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var $=180;function te({file:e,onClose:t}){let n=!!e,[r,i]=(0,g.useState)(n),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(e);return(0,g.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)},$);return()=>window.clearTimeout(t)},[e]),(0,g.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,_.createPortal)((0,v.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,v.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,v.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,v.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 ne({message:e,onClose:t}){return(0,v.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,v.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,v.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 re(e){let t=(e??``).trim();if(!t)return`—`;let n=Date.parse(t);if(!Number.isFinite(n)){let e=t.slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.replace(/-/g,`/`):`—`}let r=new Date(n);return`${r.getFullYear()}/${String(r.getMonth()+1).padStart(2,`0`)}/${String(r.getDate()).padStart(2,`0`)} ${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`}function ie({text:e,onClick:t}){let n=(0,v.jsx)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});return t?(0,v.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{w as A,ie as C,U as D,re as E,b as M,S as O,ee as S,N as T,Y as _,G as a,D as b,Z as c,ne as d,Q as f,J as g,te as h,W as i,O as j,C as k,X as l,z as m,F as n,A as o,V as p,j as r,L as s,P as t,H as u,q as v,M as w,B as x,K as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./dialog.DZHZCe_T.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.CHZeFfUj.js";var c=e(t(),1),l=o(),u=`bg-[var(--tw-surface-panel)] border-[var(--tw-border)]`,d=`text-[var(--tw-label-primary)]`,f=`text-[var(--tw-label-secondary)]`,p=`text-[var(--tw-label-tertiary)]`,m=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,h=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tw-border)] px-3 text-sm text-[var(--tw-label-secondary)] transition-colors hover:bg-[var(--tw-session-hover-bg)] disabled:cursor-not-allowed disabled:opacity-50`,g=`h-8 w-full rounded-lg border border-[var(--tw-border)] bg-[var(--tw-surface-panel)] px-2.5 text-sm text-[var(--tw-label-primary)] outline-none transition-colors placeholder:text-[var(--tw-label-tertiary)] focus:border-[#4176e6]`;function _({open:e,prompts:t,value:o,force:_=!1,onClose:v,onMount:y,onCreate:b,target:x=`项目`,createHint:S=`会按插件自带的模板生成(规划 / 探索 / 生成代码三段),之后可在「提示词管理」里改。`}){let[C,w]=(0,c.useState)(o),[T,E]=(0,c.useState)(``),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(``),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(``);(0,c.useEffect)(()=>{e&&(w(o),O(!1),A(``),M(!1),P(``),E(``))},[e,o]);let F=T.trim()?t.filter(e=>e.toLowerCase().includes(T.trim().toLowerCase())):t,I=e=>{w(e),M(!1),P(``),A(``)},L=()=>{w(``),M(!0),P(`我的提示词.md`),A(``)},R=()=>{M(!1),P(``),A(``),w(o)},z=async()=>{if(!D&&C){O(!0),A(``);try{await y(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}}},B=async()=>{if(!b||D)return;let e=N.trim();if(!e)A(`先给新提示词起个文件名`);else{O(!0),A(``);try{await y(await b(e)),M(!1),P(``)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}}};return(0,l.jsxs)(i,{open:e,onClose:D?()=>void 0:v,className:`relative z-110`,children:[(0,l.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,l.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,l.jsxs)(n,{transition:!0,className:`tw-dialog-panel-anim flex max-h-[min(80vh,620px)] w-full max-w-xl flex-col overflow-hidden rounded-xl border shadow-xl ${u}`,children:[(0,l.jsxs)(`div`,{className:`shrink-0 border-b border-[var(--tw-border)] px-5 py-4`,children:[(0,l.jsx)(r,{className:`text-base font-semibold ${d}`,children:_?`先挂载提示词`:`挂载提示词`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${f}`,children:_?`这个${x}还没有挂载提示词,选一份挂上才能开始生成;也可以先取消,稍后再挂。`:`一个${x}只挂一份提示词,换新的会立即取消上一份的引用`})]}),(0,l.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[t.length?(0,l.jsx)(`input`,{className:`${g} shrink-0`,value:T,onChange:e=>E(e.target.value),placeholder:`搜索提示词文件名`,"aria-label":`搜索提示词`,disabled:D}):null,t.length?(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto overscroll-contain rounded-lg border border-[var(--tw-border)] p-1`,children:[F.map(e=>{let t=C===e;return(0,l.jsxs)(`button`,{type:`button`,disabled:D,onClick:()=>I(e),"aria-pressed":t,className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed ${t?`bg-(--tw-accent-soft) font-medium text-(--tw-accent)`:`text-[var(--tw-label-primary)] hover:bg-[var(--tw-session-hover-bg)]`}`,children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-3 shrink-0 rounded-full border ${t?`border-[#4176e6] bg-[#4176e6] shadow-[inset_0_0_0_2px_var(--tw-surface-panel)]`:`border-[var(--tw-border)]`}`}),(0,l.jsx)(s,{text:e,className:`min-w-0 flex-1 truncate`})]},e)}),F.length?null:(0,l.jsxs)(`p`,{className:`px-2.5 py-6 text-center text-xs ${p}`,children:[`没有匹配「`,T.trim(),`」的提示词`]})]}):(0,l.jsx)(`p`,{className:`rounded-lg border border-dashed border-[var(--tw-border)] px-3 py-6 text-center text-xs ${p}`,children:`「提示词管理」里还没有可用的提示词,用下面的卡片新建一份再挂上。`}),b?j?(0,l.jsxs)(`div`,{className:`shrink-0 rounded-lg border border-[var(--tw-border)] p-3`,children:[(0,l.jsx)(`p`,{className:`text-xs font-medium ${d}`,children:`新建提示词并挂载`}),(0,l.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed ${f}`,children:S}),(0,l.jsx)(`input`,{className:`${g} mt-2`,value:N,autoFocus:!0,placeholder:`文件名,例如 我的登录流程.md`,"aria-label":`新提示词文件名`,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()}})]}):(0,l.jsxs)(`button`,{type:`button`,disabled:D,onClick:L,className:`flex w-full shrink-0 items-center gap-3 rounded-lg border border-dashed border-[var(--tw-border)] px-3 py-3 text-left transition-colors hover:border-[#4176e6] hover:bg-[var(--tw-session-hover-bg)] disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-(--tw-accent-soft) text-(--tw-accent)`,children:(0,l.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:(0,l.jsx)(`path`,{d:`M12 5v14M5 12h14`})})}),(0,l.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`block text-sm font-medium ${d}`,children:`新建提示词并挂载`}),(0,l.jsx)(`span`,{className:`mt-0.5 block text-[11px] ${f}`,children:`按插件模板生成一份新的,建完直接挂到当前项目`})]})]}):null,k?(0,l.jsx)(`p`,{className:`mt-3 rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed break-words text-red-600`,children:k}):null]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--tw-border)] px-5 py-3`,children:[_&&!j?(0,l.jsx)(`span`,{className:`mr-auto text-[11px] ${p}`,children:`不挂载时生成会被拦下`}):null,j?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:h,onClick:R,disabled:D,children:`取消`}),(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>void B(),disabled:D||!N.trim(),children:D?`创建中…`:`创建并挂载`})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:h,onClick:v,disabled:D,children:`取消`}),(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>void z(),disabled:D||!C||!t.length,children:D?`保存中…`:`挂载`})]})]})]})})]})}export{_ as t};
|