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.
Files changed (244) hide show
  1. package/CHANGELOG.md +224 -0
  2. package/README.md +25 -8
  3. package/builtin/session/lh-fs.mjs +93 -4
  4. package/builtin/session/lh-nav-groups.mjs +3 -0
  5. package/builtin/session/mcp-client.mjs +7 -3
  6. package/builtin/session/session-runs.mjs +5 -1
  7. package/builtin/session/skill-validation.mjs +72 -0
  8. package/builtin/session/space-skills.mjs +751 -0
  9. package/cli/data-root.mjs +21 -4
  10. package/cli/lantern.mjs +26 -1
  11. package/cli/mcp-server.mjs +2779 -0
  12. package/cli/server.mjs +8 -2
  13. package/config/app.defaults.json +4 -2
  14. package/dist/500.html +9 -6
  15. package/dist/_astro/Base.Du_-4L-4.css +1 -0
  16. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.XUV2H6ea.js +2 -0
  17. package/dist/_astro/BusinessMapBoard.mRxl2G3D.js +5 -0
  18. package/dist/_astro/CaseExecBoard.Cqkxuf5c.js +1 -0
  19. package/dist/_astro/CaseExecutionBoard.CjX4CoKd.js +5 -0
  20. package/dist/_astro/CaseGenerateApp.acgnxl79.js +10 -0
  21. package/dist/_astro/CasesLibrary.zmzOQwdn.js +21 -0
  22. package/dist/_astro/ChatApp.Ben9LFra.js +1 -0
  23. package/dist/_astro/ChatApp.DBi6q7Qv.js +262 -0
  24. package/dist/_astro/{ConfirmDialog.DrrPf1MB.js → ConfirmDialog.DQFd6g2r.js} +1 -1
  25. package/dist/_astro/DashboardBoard.CAJVE2G4.js +5 -0
  26. package/dist/_astro/{DatePicker.Bkl71M49.js → DatePicker.BRO_CjVQ.js} +1 -1
  27. package/dist/_astro/DefectSubmitEntry.BzKXJ-zq.js +2 -0
  28. package/dist/_astro/DocsFileBrowser.apKMbGVf.js +1 -0
  29. package/dist/_astro/{DocsPager.Duf4I68E.js → DocsPager.DMN9-Tjg.js} +1 -1
  30. package/dist/_astro/{DrawerField.BH3p4Q4D.js → DrawerField.CLdvmHc6.js} +1 -1
  31. package/dist/_astro/KnowledgeLibrary.BcoMQeUd.js +1 -0
  32. package/dist/_astro/LifeKrTasksBoard.DJU0-QI-.js +1 -0
  33. package/dist/_astro/LifeKrTodosBoard.GK7KRAO3.js +1 -0
  34. package/dist/_astro/LifeObjectivesBoard.DuKa6Q3k.js +1 -0
  35. package/dist/_astro/LifePlanTypeSelect.Cm2lUmnH.js +1 -0
  36. package/dist/_astro/{LifeReviewsBoard.BPXeVpg1.js → LifeReviewsBoard.BWOOVMtz.js} +3 -3
  37. package/dist/_astro/{LifeShared.tnT7aQON.js → LifeShared.bY2l01Ha.js} +2 -2
  38. package/dist/_astro/LifeStagesBoard.CIzxPOJB.js +1 -0
  39. package/dist/_astro/LifeYearCycleSelect.BlsyPmmI.js +1 -0
  40. package/dist/_astro/LifeYearPlansBoard.DaA9O08j.js +1 -0
  41. package/dist/_astro/MultiSelectDropdown.D-rbpivp.js +1 -0
  42. package/dist/_astro/{NamePromptDialog.Csfnh5eM.js → NamePromptDialog.KPCeXmri.js} +1 -1
  43. package/dist/_astro/NavLibraries.DVR5Ua-S.js +1 -0
  44. package/dist/_astro/PluginsPage.B063QIlQ.js +18 -0
  45. package/dist/_astro/PmBugsBoard.Cu-v0Gfd.js +1 -0
  46. package/dist/_astro/PmIterationsBoard.CgRzkP-j.js +1 -0
  47. package/dist/_astro/{PmProjectDetail.DneFVBpy.js → PmProjectDetail.DVCEh0Lm.js} +1 -1
  48. package/dist/_astro/PmProjectsBoard.z-bQa98r.js +1 -0
  49. package/dist/_astro/PmRequirementsBoard.B0W6bsW2.js +1 -0
  50. package/dist/_astro/PmRequirementsBoard.CyfBI0u_.js +1 -0
  51. package/dist/_astro/PmShared.BQVzwsiz.js +1 -0
  52. package/dist/_astro/ReportsPage.najSzJeT.js +1 -0
  53. package/dist/_astro/ReqAnalysisBoard.BQb8dHFD.js +39 -0
  54. package/dist/_astro/RequirementBreakdownLibrary.Cn6OV6xt.js +2 -0
  55. package/dist/_astro/RequirementsLibrary.CqKNFVsP.js +1 -0
  56. package/dist/_astro/SearchableSelect.DXclLMJI.js +1 -0
  57. package/dist/_astro/SelectDropdown.D7IeyHDI.js +1 -0
  58. package/dist/_astro/SettingsDialog.db3BpFw0.js +1 -0
  59. package/dist/_astro/SlideOverDrawer.BMg2tce6.js +1 -0
  60. package/dist/_astro/SpaceSwitcher.DSUVAPOi.js +7 -0
  61. package/dist/_astro/{TableFieldConfig.C7O-mL-p.js → TableFieldConfig.72AL-8p-.js} +1 -1
  62. package/dist/_astro/{TagSelect.UUXgkMqJ.js → TagSelect.B_r2p0fp.js} +1 -1
  63. package/dist/_astro/TasksBoard.CCDhCSR7.js +1 -0
  64. package/dist/_astro/TemplatesLibrary.peYzrHZ2.js +1 -0
  65. package/dist/_astro/TestReportsLibrary.fWiEyCRx.js +1 -0
  66. package/dist/_astro/TestStatsBoard.BSUBsWSu.js +1 -0
  67. package/dist/_astro/Toast.BydY-X7T.js +1 -0
  68. package/dist/_astro/TodosBoard.By5YdlUe.js +1 -0
  69. package/dist/_astro/UiAutoBoard.BGdlp5Sr.js +3 -0
  70. package/dist/_astro/UiAutoEnvPanel.BUASgPLB.js +10 -0
  71. package/dist/_astro/UiAutoGenerationDialog.D1PyCgrD.js +12 -0
  72. package/dist/_astro/UiAutoProjectsPage.B6A9NlVK.js +3 -0
  73. package/dist/_astro/app-config.Dvfzl5_N.js +1 -0
  74. package/dist/_astro/app-version.CNpnKIb9.js +1 -0
  75. package/dist/_astro/{bash-tools.D9HCzC_7.js → bash-tools.CS2w8LOb.js} +1 -1
  76. package/dist/_astro/business-map.BiJ85oxm.js +1 -0
  77. package/dist/_astro/business-map.DKwdW1VL.css +1 -0
  78. package/dist/_astro/case-gen-run.Cvvdv_kv.js +26 -0
  79. package/dist/_astro/case-prompt.CZ3vWUju.js +2 -0
  80. package/dist/_astro/{case-review.TdDs1WFM.js → case-review.DFWZkoR9.js} +1 -1
  81. package/dist/_astro/{case-template.Cd2xNbgy.js → case-template.Clb7HrDB.js} +1 -1
  82. package/dist/_astro/defect-submit.Dc49lFjm.css +1 -0
  83. package/dist/_astro/defect-workbench.CjTb4FDv.js +6 -0
  84. package/dist/_astro/dialog.XgRGNF_Q.js +1 -0
  85. package/dist/_astro/doc-roots.C-20VD0x.js +1 -0
  86. package/dist/_astro/{hydrate-cache.B15Nrpq0.js → hydrate-cache.O4CIma9y.js} +1 -1
  87. package/dist/_astro/i18n.Cp4so7KR.js +7 -0
  88. package/dist/_astro/{llm.DN5S1KBK.js → llm.BCYNgppW.js} +1 -1
  89. package/dist/_astro/mcp-tools.Kf-lupGn.js +7 -0
  90. package/dist/_astro/{open-docs-in-session.CRiZT022.js → open-docs-in-session.BpcAcBSI.js} +1 -1
  91. package/dist/_astro/plugins.Db9xoFZb.js +1 -0
  92. package/dist/_astro/project-docs.bB9lQ1Ki.js +1 -0
  93. package/dist/_astro/prompts-meta.VAjE4OET.js +2 -0
  94. package/dist/_astro/report-prompt.CwHuOcRN.js +1 -0
  95. package/dist/_astro/req-analysis.C_gARMrB.js +31 -0
  96. package/dist/_astro/requirement-breakdown-library.l0rPd7b3.js +1 -0
  97. package/dist/_astro/{settings.38J2uD5M.js → settings.D02wZj3w.js} +2 -2
  98. package/dist/_astro/space-skills.CPucW8zt.js +1 -0
  99. package/dist/_astro/{spaces-client.DV04tRyD.js → spaces-client.BAtG6PkW.js} +1 -1
  100. package/dist/_astro/story-review.DTN91Vl9.js +7 -0
  101. package/dist/_astro/test-points.C7ZgggQT.js +8 -0
  102. package/dist/_astro/test-reports.0gr6-c_0.js +19 -0
  103. package/dist/_astro/ui-auto-prompt.BmO3ja2m.js +8 -0
  104. package/dist/_astro/{view-prefs.DhdLZjGh.js → view-prefs.COAKEQtZ.js} +1 -1
  105. package/dist/business-map/index.html +983 -0
  106. package/dist/case-exec/index.html +10 -7
  107. package/dist/{prompts → case-execution}/index.html +12 -9
  108. package/dist/cases/generate/index.html +9 -6
  109. package/dist/cases/library/index.html +10 -7
  110. package/dist/dashboard/index.html +10 -7
  111. package/dist/defect-rules/index.html +690 -0
  112. package/dist/defect-submit/index.html +690 -0
  113. package/dist/defect-submit/templates/index.html +690 -0
  114. package/dist/docs/changelog/index.html +265 -51
  115. package/dist/docs/install/index.html +44 -12
  116. package/dist/docs/manual/index.html +213 -75
  117. package/dist/knowledge/index.html +10 -7
  118. package/dist/life/kr-tasks/index.html +10 -7
  119. package/dist/life/kr-todos/index.html +10 -7
  120. package/dist/life/objectives/index.html +10 -7
  121. package/dist/life/reviews/index.html +10 -7
  122. package/dist/life/stages/index.html +10 -7
  123. package/dist/life/year-plans/index.html +10 -7
  124. package/dist/plugins/index.html +10 -7
  125. package/dist/pm/bugs/index.html +10 -7
  126. package/dist/pm/iterations/index.html +10 -7
  127. package/dist/pm/projects/detail/index.html +10 -7
  128. package/dist/pm/projects/index.html +10 -7
  129. package/dist/pm/requirements/index.html +10 -7
  130. package/dist/reports/index.html +10 -7
  131. package/dist/requirement-analysis/index.html +10 -7
  132. package/dist/requirement-breakdowns/index.html +983 -0
  133. package/dist/requirements/index.html +10 -7
  134. package/dist/tasks/index.html +10 -7
  135. package/dist/templates/index.html +10 -7
  136. package/dist/test-automation/index.html +10 -7
  137. package/dist/test-automation/projects/index.html +10 -7
  138. package/dist/test-reports/index.html +10 -7
  139. package/dist/test-stats/index.html +10 -7
  140. package/dist/todos/index.html +10 -7
  141. package/dist/workbench/index.html +9 -6
  142. package/docs/Codex-MCP/351/233/206/346/210/220.md +296 -0
  143. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/204/344/274/260.md +39 -0
  144. 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
  145. package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +22 -3
  146. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +41 -1
  147. package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +63 -17
  148. 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
  149. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +208 -69
  150. package/lh-plugins/business-map/assistant.mjs +958 -0
  151. package/lh-plugins/business-map/auth-paths.mjs +61 -0
  152. package/lh-plugins/business-map/jobs.mjs +749 -0
  153. package/lh-plugins/business-map/login.mjs +295 -0
  154. package/lh-plugins/business-map/sources.mjs +1014 -0
  155. package/lh-plugins/case-execution/files.mjs +777 -0
  156. package/lh-plugins/case-execution/service.mjs +959 -0
  157. package/lh-plugins/case-execution-prompt.mjs +33 -0
  158. package/lh-plugins/lh-business-map.mjs +2431 -0
  159. package/lh-plugins/lh-case-execution.mjs +304 -0
  160. package/lh-plugins/lh-config.mjs +13 -0
  161. package/lh-plugins/lh-defect-submit.mjs +989 -0
  162. package/lh-plugins/lh-project-docs.mjs +31 -140
  163. package/lh-plugins/lh-reports.mjs +29 -57
  164. package/lh-plugins/lh-req-analysis.mjs +32 -3
  165. package/lh-plugins/lh-req-breakdown-library.mjs +1084 -0
  166. package/lh-plugins/lh-uiauto.mjs +514 -22
  167. package/lh-plugins/plugin-prompts.mjs +19 -15
  168. package/lh-plugins/req-analysis-revision.mjs +24 -0
  169. package/lh-plugins/test-points-prompt.mjs +2 -3
  170. package/lh-plugins/uiauto-auth-setup.mjs +218 -0
  171. package/lh-plugins/uiauto-explorer/apps.mjs +13 -2
  172. package/lh-plugins/uiauto-explorer/runner.mjs +15 -2
  173. package/lh-plugins/uiauto-explorer/sessions.mjs +305 -17
  174. package/lh-plugins/uiauto-node.mjs +102 -11
  175. package/lh-plugins/uiauto-prompt.mjs +20 -15
  176. package/lh-plugins/uiauto-sso.mjs +407 -0
  177. package/package.json +5 -2
  178. package/skills/case-execution/SKILL.md +30 -0
  179. package/skills/lantern-defect-submit/SKILL.md +15 -0
  180. package/skills/lantern-workflow/SKILL.md +57 -0
  181. package/skills/office/SKILL.md +26 -0
  182. package/dist/_astro/Base.DIbzr8uT.css +0 -1
  183. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CPR_CfsE.js +0 -2
  184. package/dist/_astro/CaseExecBoard.DICluCbK.js +0 -1
  185. package/dist/_astro/CaseGenerateApp.CcAtVSQJ.js +0 -10
  186. package/dist/_astro/CasesLibrary.Ci_0hYqL.js +0 -21
  187. package/dist/_astro/ChatApp.DFKZOkZy.js +0 -227
  188. package/dist/_astro/DashboardBoard.Qvf8o4v1.js +0 -5
  189. package/dist/_astro/DocsFileBrowser.DwKBffbM.js +0 -1
  190. package/dist/_astro/KnowledgeLibrary.MDpMqeOd.js +0 -1
  191. package/dist/_astro/LifeKrTasksBoard.DsvW_S66.js +0 -1
  192. package/dist/_astro/LifeKrTodosBoard.D2KTqvg1.js +0 -1
  193. package/dist/_astro/LifeObjectivesBoard.B0cDK934.js +0 -1
  194. package/dist/_astro/LifePlanTypeSelect.BELDvMWU.js +0 -1
  195. package/dist/_astro/LifeStagesBoard.CZftLR9K.js +0 -1
  196. package/dist/_astro/LifeYearCycleSelect.Bw2eRbSm.js +0 -1
  197. package/dist/_astro/LifeYearPlansBoard.DB-RJFEl.js +0 -1
  198. package/dist/_astro/MultiSelectDropdown.CBC7aNOv.js +0 -1
  199. package/dist/_astro/NavLibraries.DdQYsZbe.js +0 -1
  200. package/dist/_astro/OverflowHint.CHZeFfUj.js +0 -1
  201. package/dist/_astro/PluginsPage.BVrMtkLi.js +0 -17
  202. package/dist/_astro/PluginsPage.xdbDGigE.js +0 -1
  203. package/dist/_astro/PmBugsBoard.CGpXUTPu.js +0 -1
  204. package/dist/_astro/PmIterationsBoard.BaKiFIam.js +0 -1
  205. package/dist/_astro/PmProjectsBoard.BxoMF9gK.js +0 -1
  206. package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +0 -1
  207. package/dist/_astro/PmRequirementsBoard.DsK6RF7Q.js +0 -1
  208. package/dist/_astro/PmShared.BK8kWRSV.js +0 -1
  209. package/dist/_astro/PromptMountDialog.mrTx3U5T.js +0 -1
  210. package/dist/_astro/PromptsLibrary.B2LMGsrj.js +0 -1
  211. package/dist/_astro/ReportsPage.B9lGg1_s.js +0 -16
  212. package/dist/_astro/ReqAnalysisBoard.D-KmRwQM.js +0 -39
  213. package/dist/_astro/RequirementsLibrary.cJc-bnGQ.js +0 -1
  214. package/dist/_astro/SearchableSelect.SyLRS-Jj.js +0 -1
  215. package/dist/_astro/SelectDropdown.T3CKHaLt.js +0 -1
  216. package/dist/_astro/SettingsDialog.C62iJkMt.js +0 -1
  217. package/dist/_astro/SpaceSwitcher.C47_S1g9.js +0 -7
  218. package/dist/_astro/TasksBoard.BUEg2BYk.js +0 -1
  219. package/dist/_astro/TemplatesLibrary.BLVIphXO.js +0 -1
  220. package/dist/_astro/TestReportsLibrary.DVq30Jae.js +0 -1
  221. package/dist/_astro/TestStatsBoard.-5BWQ6bI.js +0 -1
  222. package/dist/_astro/Toast.BO2NFckG.js +0 -1
  223. package/dist/_astro/TodosBoard.DI_lTp2e.js +0 -1
  224. package/dist/_astro/UiAutoBoard.ChFdgv7s.js +0 -2
  225. package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +0 -19
  226. package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +0 -1
  227. package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +0 -3
  228. package/dist/_astro/app-config.DkyjuL-S.js +0 -1
  229. package/dist/_astro/app-version.3eY3FSw1.js +0 -1
  230. package/dist/_astro/case-gen-run.BQeK-XUw.js +0 -22
  231. package/dist/_astro/case-types.DlFkbZJN.js +0 -1
  232. package/dist/_astro/dialog.DZHZCe_T.js +0 -1
  233. package/dist/_astro/doc-roots.CO3IBiY6.js +0 -1
  234. package/dist/_astro/i18n.D_aOCHSN.js +0 -7
  235. package/dist/_astro/markdown-client.BS19nLL3.js +0 -62
  236. package/dist/_astro/plugins.BRvXWHLe.js +0 -1
  237. package/dist/_astro/project-docs.CCjtiFjB.js +0 -1
  238. package/dist/_astro/prompts-meta.BUGutlsk.js +0 -2
  239. package/dist/_astro/report-prompt.B9C4cv84.js +0 -1
  240. package/dist/_astro/req-analysis.FrD6BfwK.js +0 -31
  241. package/dist/_astro/story-review.R8iWiFzl.js +0 -14
  242. package/dist/_astro/test-reports.CuIjlEyK.js +0 -19
  243. package/dist/_astro/ui-auto-prompt.H9_yhau9.js +0 -9
  244. package/dist/_astro/ui-auto.DMv940x4.js +0 -1
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{n as i,t as a}from"./SelectDropdown.D7IeyHDI.js";import{showToast as o}from"./Toast.BydY-X7T.js";import{c as s,d as c,i as ee,l,n as u,o as te,t as d}from"./ColumnResize.CkE59sGq.js";import{$ as ne,A as f,B as p,C as re,Ct as m,E as h,H as g,I as ie,J as ae,K as oe,L as se,M as _,N as ce,Q as le,R as ue,S as de,T as fe,U as pe,V as me,W as v,X as he,Y as ge,Z as _e,_ as ve,a as ye,b as be,c as xe,ct as Se,et as Ce,f as y,ft as b,g as we,i as Te,it as x,j as Ee,k as De,l as Oe,m as S,mt as ke,o as Ae,ot as C,p as je,pt as Me,q as Ne,rt as w,t as T,v as Pe,w as Fe,wt as Ie,x as Le,y as Re,z as E}from"./LifeShared.bY2l01Ha.js";import{a as D,c as O,l as k,n as A,r as j,s as ze,t as M}from"./DrawerField.CLdvmHc6.js";var N=e(t(),1),P=n(),Be=[{key:`select`,width:36,min:32},{key:`title`,width:240,min:160},{key:`status`,width:104,min:76},{key:`krTask`,width:160,min:100},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:72,min:56},{key:`note`,width:140,min:88},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ve=[{key:`status`,label:`状态`},{key:`krTask`,label:`所属任务`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`priority`,label:`重要紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`cycle`,label:`待办周期`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],He=`life.kr-todos.fields`,Ue=`life.kr-todos.search`,We=`life.kr-todos.group`,Ge=`life.kr-todos.status`,Ke=[`yearStatus`,`status`,`none`],qe=w.map(e=>({value:e,label:x[e]})),Je=Te,Ye=[{value:`none`,label:`不分组`},{value:`yearStatus`,label:`按年度 → 状态`},{value:`status`,label:`按状态分组`}],Xe=[`all`,...w],Ze=[{value:`all`,label:`全部状态`},...w.map(e=>({value:e,label:x[e]}))];function Qe(e){let t=/(?:^|\|)status:([^|]+)/.exec(e);if(!t)return{};let n=t[1];return w.includes(n)?{status:n}:{}}function $e(e){return{title:``,status:e?.status??`pending`,krTaskId:e?.krTaskId??``,startDate:e?.startDate??m(),dueDate:e?.dueDate??m(),note:e?.note??``}}function F(e,t){let n=t.krTasks.find(t=>t.id===e.krTaskId);return{task:n,objective:n?v(t,n.objectiveId):void 0}}function et(e){let{open:t,item:n,taskOptions:r,store:o,isVisible:s,onClose:c,onSave:ee}=e,[l,u]=(0,N.useState)($e()),[te,d]=(0,N.useState)(!1),[ne,f]=(0,N.useState)(``);(0,N.useEffect)(()=>{t&&(f(``),d(!1),u({title:n.title,status:n.status,krTaskId:n.krTaskId,startDate:n.startDate||m(),dueDate:n.dueDate||m(),note:n.note}))},[t,n]);let p=F(l,o),re=ke(b(l.startDate,l.dueDate));async function h(){let e=l.title.trim();if(!e)f(`请填写待办描述`);else{d(!0);try{await ee({...l,title:e},n.id),c()}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{d(!1)}}}return(0,P.jsxs)(be,{open:t,title:`待办详情`,onClose:c,footer:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:c,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,P.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>void h(),className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white hover:bg-[#3566d0] disabled:opacity-40`,children:te?`保存中…`:`保存`})]}),children:[ne?(0,P.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:ne}):null,(0,P.jsx)(A,{icon:(0,P.jsx)(k,{}),label:`待办描述`,children:(0,P.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:M})}),s(`status`)?(0,P.jsx)(A,{icon:(0,P.jsx)(ze,{}),label:`待办状态`,children:(0,P.jsx)(j,{ariaLabel:`待办状态`,options:qe,value:l.status,onChange:e=>u({...l,status:e}),label:x[l.status],optionDotClassName:e=>ye[e]})}):null,s(`krTask`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`所属任务`,children:(0,P.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`所属任务`,options:r,value:l.krTaskId,onChange:e=>u({...l,krTaskId:e}),className:`w-full`,triggerClassName:l.krTaskId?void 0:Ae,renderTrigger:()=>{let e=o.krTasks.find(e=>e.id===l.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,s(`year`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`年度周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.objective?.yearCycle?.trim()&&Ie(o.yearCycles,p.objective.yearCycle)||`—`})}):null,s(`quarter`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`季度周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.objective?.quarter?Se[p.objective.quarter]:`—`})}):null,s(`priority`)?(0,P.jsx)(A,{icon:(0,P.jsx)(ze,{}),label:`重要紧急程度`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.task?.priority?C[p.task.priority]:`—`})}):null,s(`start`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`开始日期`,children:(0,P.jsx)(T,{value:l.startDate,onChange:e=>u({...l,startDate:e})})}):null,s(`due`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`截止日期`,children:(0,P.jsx)(T,{value:l.dueDate,onChange:e=>u({...l,dueDate:e})})}):null,s(`cycle`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`待办周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:re})}):null,s(`note`)?(0,P.jsx)(A,{icon:(0,P.jsx)(k,{}),label:`备注`,children:(0,P.jsx)(`textarea`,{value:l.note,onChange:e=>u({...l,note:e.target.value}),rows:3,className:`w-full rounded-md border border-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,s(`createdAt`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`创建日期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,s(`updatedAt`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`修改日期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function I(){let e=le(),{store:t,live:n,error:m,setError:v,updateItem:be,createItems:D,deleteItems:O}=Ce(e.ready&&e.on),[k,A]=_e(Ue),[j,ze]=ae(We,Ke,`none`),M=j===`yearStatus`,I=pe(M),[L,tt]=ae(Ge,Xe,`all`),[R,nt]=(0,N.useState)({}),[z,B]=(0,N.useState)(null),[rt,it]=(0,N.useState)(null),[V,at]=(0,N.useState)(!1),[H,ot]=(0,N.useState)(!1),[U,W]=(0,N.useState)(null),[st,G]=(0,N.useState)({}),K=ge(He,Ve),ct=(0,N.useMemo)(()=>{let e=g(M);return se(Be,K.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[K.isVisible,M]),q=l(`life.kr-todos.cols.v12`,ct),lt=(e,n=`随任务`)=>{let r=e?.yearCycle?.trim()||``;return r&&Ie(t.yearCycles,r)||n},{submit:ut}=he({row:U,setRow:W,submitting:H,isPristine:e=>{let t=e.base;return!e.title.trim()&&e.status===t.status&&e.krTaskId===t.krTaskId&&e.startDate===t.startDate&&e.dueDate===t.dueDate&&e.note===t.note},onSubmit:async e=>{ot(!0);try{await D(`krTodos`,[{title:e.title,status:e.status,krTaskId:e.krTaskId,startDate:e.startDate,dueDate:e.dueDate,note:e.note}]),W(null),o(`已新增 KR 待办`,`success`),v(``)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`新增失败:${t}`,`error`)}finally{ot(!1)}}});function dt(e,t){let n=$e(t);W({groupKey:e,...n,base:n}),nt(t=>({...t,[e]:!1}))}let ft=c(`life.kr-todos`),pt=(0,N.useMemo)(()=>[{value:``,label:S},...Ne(t.krTasks).map(e=>({value:e.id,label:e.title}))],[t.krTasks]),J=(0,N.useMemo)(()=>{let e=Me(t.krTodos,k);return L!==`all`&&(e=e.filter(e=>e.status===L)),oe(e,w)},[t.krTodos,k,L]),Y=(0,N.useMemo)(()=>{if(j===`none`)return[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:J}];if(j===`status`)return w.map(e=>({key:`status:${e}`,label:x[e],pill:Je[e],items:J.filter(t=>t.status===e)}));let e=e=>F(e,t).objective?.yearCycle?.trim()||``,n=e=>e?Ie(t.yearCycles,e)||`未设置年度`:we,r=[...new Set(J.map(e))];return r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0?[{key:`year:`,label:we,pill:p(``),items:[]}]:r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t),a=w.map(e=>({key:`year:${t}|status:${e}`,label:x[e],pill:Je[e],items:r.filter(t=>t.status===e)})).filter(e=>e.items.length>0);return{key:`year:${t}`,label:i,pill:p(t),children:a}}).filter(e=>(e.children?.length??0)>0)},[j,J,t]),mt=(0,N.useMemo)(()=>ue(Y,j===`none`?{}:R),[Y,R,j]),ht=(0,N.useMemo)(()=>ie(Y,j===`none`?{}:R),[Y,R,j]),X=ne(ht);async function Z(e,t){try{await be(`krTodos`,e,t),G(t=>{let n={...t};return delete n[e],n}),v(``)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`保存失败:${t}`,`error`)}}function gt(e){return{...e,...st[e.id]}}function _t(e,t){G(n=>({...n,[e]:{...n[e],...t}}))}async function vt(e){let t=st[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):v(`待办描述不能为空`)}async function yt(e,t){await be(`krTodos`,t,e),o(`已保存`,`success`)}function Q(){if(!U)return null;let e=F(U,t),n=ke(b(U.startDate,U.dueDate)),r=e.task?.priority??``;return(0,P.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,P.jsx)(`td`,{className:u,style:I,children:(0,P.jsx)(`input`,{autoFocus:!0,disabled:H,value:U.title,placeholder:`输入待办描述,回车或点空白处保存`,onChange:e=>W(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ut()):e.key===`Escape`&&(e.preventDefault(),W(null))},className:xe})}),K.isVisible(`status`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:qe,value:U.status,onChange:e=>W(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-[#4176e6]/30 ${Te[U.status]}`,renderTrigger:()=>(0,P.jsx)(i,{text:x[U.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ye[e.value]}`})})}):null,K.isVisible(`krTask`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`KR 任务`,menuMinWidth:220,options:pt,value:U.krTaskId,onChange:e=>W(t=>t&&{...t,krTaskId:e}),triggerClassName:U.krTaskId?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:Ae,renderTrigger:()=>{let e=t.krTasks.find(e=>e.id===U.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,K.isVisible(`year`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Pe,{id:e.objective?.yearCycle?.trim()||``,label:lt(e.objective),emptyLabel:`随任务`})}):null,K.isVisible(`quarter`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(_,{text:e.objective?.quarter?Se[e.objective.quarter]:`随任务`,muted:!e.objective?.quarter})}):null,K.isVisible(`priority`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:r?(0,P.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${Oe[r]}`,children:C[r]}):(0,P.jsx)(_,{text:`随任务`,muted:!0})}):null,K.isVisible(`start`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:U.startDate,onChange:e=>W(t=>t&&{...t,startDate:e})})}):null,K.isVisible(`due`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:U.dueDate,onChange:e=>W(t=>t&&{...t,dueDate:e})})}):null,K.isVisible(`cycle`)?(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:n}):null,K.isVisible(`note`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Ee,{value:U.note,onChange:e=>W(t=>t&&{...t,note:e}),onCommit:()=>void 0,onCancel:()=>void 0})}):null,K.isVisible(`createdAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:`—`,muted:!0})}):null,K.isVisible(`updatedAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:`—`,muted:!0})}):null,(0,P.jsx)(`td`,{"aria-hidden":`true`}),(0,P.jsx)(`td`,{className:ee})]})}async function bt(){let e=z;if(e?.length){B(null),at(!0);try{await O(`krTodos`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`删除失败:${t}`,`error`)}finally{at(!1)}}}function xt(e,n,r=0){let o=gt(e),s=F(o,t),c=ke(b(o.startDate,o.dueDate)),l=s.task?.priority??``;return(0,P.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,P.jsx)(De,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0,depth:r}),(0,P.jsx)(`td`,{className:u,style:I,children:(0,P.jsx)(ce,{value:o.title,placeholder:`待办描述`,onChange:t=>_t(e.id,{title:t}),onCommit:()=>void vt(e),onCancel:()=>G(t=>{let n={...t};return delete n[e.id],n})})}),K.isVisible(`status`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:qe,value:o.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-[#4176e6]/30 ${Te[o.status]}`,renderTrigger:()=>(0,P.jsx)(i,{text:x[o.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ye[e.value]}`})})}):null,K.isVisible(`krTask`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`KR 任务`,menuMinWidth:220,options:pt,value:o.krTaskId,onChange:t=>void Z(e.id,{krTaskId:t}),triggerClassName:o.krTaskId?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:Ae,renderTrigger:()=>{let e=t.krTasks.find(e=>e.id===o.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,K.isVisible(`year`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Pe,{id:s.objective?.yearCycle?.trim()||``,label:lt(s.objective),emptyLabel:`随任务`})}):null,K.isVisible(`quarter`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(_,{text:s.objective?.quarter?Se[s.objective.quarter]:`随任务`,muted:!s.objective?.quarter})}):null,K.isVisible(`priority`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:l?(0,P.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${Oe[l]}`,children:C[l]}):(0,P.jsx)(_,{text:`随任务`,muted:!0})}):null,K.isVisible(`start`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:o.startDate,onChange:t=>void Z(e.id,{startDate:t})})}):null,K.isVisible(`due`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:o.dueDate,onChange:t=>void Z(e.id,{dueDate:t})})}):null,K.isVisible(`cycle`)?(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:c}):null,K.isVisible(`note`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Ee,{value:o.note,onChange:t=>_t(e.id,{note:t}),onCommit:()=>void vt(e),onCancel:()=>G(t=>{let n={...t};return delete n[e.id],n})})}):null,K.isVisible(`createdAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:E(e.createdAt),muted:!e.createdAt})}):null,K.isVisible(`updatedAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,P.jsx)(`td`,{"aria-hidden":`true`}),(0,P.jsx)(`td`,{className:ee,children:(0,P.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,P.jsx)(de,{label:`编辑 ${e.title}`,disabled:V,onClick:()=>it(e)}),(0,P.jsx)(Re,{label:`删除 ${e.title}`,disabled:V,onClick:()=>B([e])})]})})]},e.id)}let St=(0,N.useMemo)(()=>{let e={};for(let n of t.krTodos)e[n.status]=(e[n.status]??0)+1;return w.filter(t=>(e[t]??0)>0).map(t=>`${x[t]} ${e[t]}`).join(` · `)},[t.krTodos]);if(!e.ready)return(0,P.jsx)(fe,{label:`正在读取插件开关`});if(!e.on)return(0,P.jsx)(h,{children:me()});if(n===null)return(0,P.jsx)(fe,{label:`正在连接人生管理服务`});if(!n)return(0,P.jsx)(h,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=ct.length;return(0,P.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 text-sm text-stone-600`,children:[`共 `,(0,P.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.krTodos.length}),` 条`,St?(0,P.jsxs)(`span`,{className:`text-stone-400`,children:[` · `,St]}):null]}),(0,P.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`input`,{value:k,onChange:e=>A(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-[#4176e6]`}),(0,P.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:Ye,value:j,onChange:e=>ze(e)}),(0,P.jsx)(re,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,P.jsx)(a,{flat:!0,className:`w-[120px]`,ariaLabel:`状态筛选`,options:Ze,value:L,onChange:e=>tt(e)}),(0,P.jsx)(`button`,{type:`button`,disabled:V||X.selectedIds.length===0,onClick:()=>B(t.krTodos.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,P.jsx)(`button`,{type:`button`,disabled:V||H,onClick:()=>{let e=mt.find(e=>e.items!==void 0);dt(e?.key??`all`,e?Qe(e.key):void 0)},className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 新建待办`})]})]}),(0,P.jsx)(Le,{error:m,onDismiss:()=>v(``)}),(0,P.jsx)(`div`,{ref:ft,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,P.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,P.jsx)(`colgroup`,{children:ct.map(e=>(0,P.jsx)(`col`,{style:e.key===`select`?{width:g(M)}:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,P.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(f,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible(),nested:M}),(0,P.jsxs)(`th`,{className:`${te} text-xs text-stone-500`,style:I,children:[`待办描述`,(0,P.jsx)(d,{...q.resizeProps(`title`)})]}),K.isVisible(`status`)?(0,P.jsxs)(`th`,{className:y,children:[`状态`,(0,P.jsx)(d,{...q.resizeProps(`status`)})]}):null,K.isVisible(`krTask`)?(0,P.jsxs)(`th`,{className:je,children:[`KR 任务`,(0,P.jsx)(d,{...q.resizeProps(`krTask`)})]}):null,K.isVisible(`year`)?(0,P.jsxs)(`th`,{className:y,children:[`年度周期`,(0,P.jsx)(d,{...q.resizeProps(`year`)})]}):null,K.isVisible(`quarter`)?(0,P.jsxs)(`th`,{className:y,children:[`季度周期`,(0,P.jsx)(d,{...q.resizeProps(`quarter`)})]}):null,K.isVisible(`priority`)?(0,P.jsxs)(`th`,{className:y,children:[`重要紧急程度`,(0,P.jsx)(d,{...q.resizeProps(`priority`)})]}):null,K.isVisible(`start`)?(0,P.jsxs)(`th`,{className:je,children:[`开始日期`,(0,P.jsx)(d,{...q.resizeProps(`start`)})]}):null,K.isVisible(`due`)?(0,P.jsxs)(`th`,{className:y,children:[`截止日期`,(0,P.jsx)(d,{...q.resizeProps(`due`)})]}):null,K.isVisible(`cycle`)?(0,P.jsxs)(`th`,{className:y,children:[`周期`,(0,P.jsx)(d,{...q.resizeProps(`cycle`)})]}):null,K.isVisible(`note`)?(0,P.jsxs)(`th`,{className:je,children:[`备注`,(0,P.jsx)(d,{...q.resizeProps(`note`)})]}):null,K.isVisible(`createdAt`)?(0,P.jsxs)(`th`,{className:y,children:[`创建日期`,(0,P.jsx)(d,{...q.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,P.jsxs)(`th`,{className:y,children:[`修改日期`,(0,P.jsx)(d,{...q.resizeProps(`updatedAt`)})]}):null,(0,P.jsx)(`th`,{"aria-hidden":`true`}),(0,P.jsx)(`th`,{className:s,children:`操作`})]})}),(0,P.jsx)(`tbody`,{children:J.length===0&&!U?(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.krTodos.length===0?`还没有 KR 待办`:`没有匹配的记录`})}):J.length===0&&U?Q():j===`none`?(0,P.jsxs)(P.Fragment,{children:[J.map((e,t)=>xt(e,t+1)),U?Q():(0,P.jsx)(ve,{colSpan:$,depth:0,selectColPx:g(M),disabled:V||H,onClick:()=>dt(`all`)})]}):mt.length===0?U?Q():null:mt.map(e=>{let t=!R[e.key];return(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(Fe,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:$,selectColPx:g(M),onToggle:()=>nt(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>xt(t,n+1,e.depth)),e.items?U?.groupKey===e.key?Q():J.length>0?(0,P.jsx)(ve,{colSpan:$,depth:e.depth,selectColPx:g(M),disabled:V||H,onClick:()=>dt(e.key,Qe(e.key))}):null:null]},e.key)})})]})}),(0,P.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,P.jsxs)(`span`,{children:[`显示 `,J.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,P.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`年度周期 / 季度周期 / 重要紧急程度跟随关联 KR 任务与 Objective`})]}),rt?(0,P.jsx)(et,{open:!0,item:rt,taskOptions:pt,store:t,isVisible:K.isVisible,onClose:()=>it(null),onSave:yt}):null,(0,P.jsx)(r,{open:z!=null,title:z&&z.length>1?`批量删除`:`删除 KR 待办`,message:z&&z.length>1?`删除选中的 ${z.length} 条待办?此操作不可恢复。`:`删除「${z?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>B(null),onConfirm:()=>void bt()})]})}export{I as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{n as i,t as a}from"./SelectDropdown.D7IeyHDI.js";import{showToast as o}from"./Toast.BydY-X7T.js";import{c as s,d as c,i as l,l as ee,n as u,o as d,t as f}from"./ColumnResize.CkE59sGq.js";import{$ as p,A as m,B as h,C as te,D as g,E as _,G as ne,H as v,I as re,J as ie,L as ae,M as y,N as oe,Q as se,R as ce,S as le,T as ue,U as de,V as fe,X as pe,Y as me,Z as he,_ as ge,_t as _e,b as ve,c as ye,ct as b,et as be,f as x,g as xe,h as S,k as Se,o as C,pt as Ce,s as w,st as T,vt as we,w as Te,wt as Ee,x as De,y as Oe,z as E}from"./LifeShared.bY2l01Ha.js";import{c as D,l as O,n as k,t as A}from"./DrawerField.CLdvmHc6.js";import{t as j}from"./LifeYearCycleSelect.BlsyPmmI.js";var M=e(t(),1),N=n(),ke=[{key:`select`,width:36,min:32},{key:`title`,width:260,min:180},{key:`yearCycle`,width:120,min:88},{key:`yearPlanId`,width:160,min:120},{key:`quarter`,width:140,min:100},{key:`keyResults`,width:220,min:140},{key:`progress`,width:120,min:96},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ae=[{key:`yearCycle`,label:`年度周期`},{key:`yearPlanId`,label:`年度计划`},{key:`quarter`,label:`季度周期`},{key:`keyResults`,label:`关键结果`},{key:`progress`,label:`完成度`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],je=`life.objectives.fields`,Me=`life.objectives.search`,Ne=`life.objectives.group`,Pe=[`yearQuarter`,`yearCycle`,`none`],Fe=[`Q1`,`Q2`,`Q3`,`Q4`,`unset`],P={Q1:`bg-[#e1eaff] text-[#1f4ec2]`,Q2:`bg-[#d9f5d2] text-[#1d7a12]`,Q3:`bg-[#fff1e3] text-[#a85b00]`,Q4:`bg-[#fee4e3] text-[#c02a26]`,unset:`bg-stone-300 text-stone-600`};function Ie(e){return e===`Q1`||e===`Q2`||e===`Q3`||e===`Q4`?e:`unset`}var F=T.filter(e=>e!==``).map(e=>({value:e,label:b[e]})),Le=[{value:`none`,label:`不分组`},{value:`yearQuarter`,label:`按年度 → 季度周期`},{value:`yearCycle`,label:`按年度周期分组`}];function I(e){return{title:``,yearCycle:e?.yearCycle??``,yearPlanId:e?.yearPlanId??``,quarter:e?.quarter??``}}function Re(e){return[...e].sort((e,t)=>(t.updatedAt||``).localeCompare(e.updatedAt||``)).map(e=>({value:e.id,label:e.title}))}function ze(e,t){return t?e.find(e=>e.id===t)?.title??``:``}function Be(e){let t={},n=/(?:^|\|)year:([^|]*)/.exec(e);n&&(t.yearCycle=n[1]??``);let r=/(?:^|\|)quarter:([^|]+)/.exec(e)?.[1];return r===`unset`||r===`other`?t.quarter=``:(r===`Q1`||r===`Q2`||r===`Q3`||r===`Q4`)&&(t.quarter=r),t}function Ve(e){for(let t of e)if(t.children?.length){let e=Ve(t.children);if(e)return e}else if(t.items!==void 0)return t.key;return`all`}function He(e){let{open:t,item:n,yearCycles:r,yearCycleMutate:o,yearPlans:s,isVisible:c,onClose:l,onSave:ee}=e,[u,d]=(0,M.useState)(I()),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(``),te=(0,M.useMemo)(()=>Re(s),[s]);(0,M.useEffect)(()=>{t&&(h(``),p(!1),d({title:n.title,yearCycle:n.yearCycle,yearPlanId:n.yearPlanId||``,quarter:n.quarter}))},[t,n]);async function g(){let e=u.title.trim();if(!e)h(`请填写目标描述`);else{p(!0);try{await ee({...u,title:e,yearCycle:u.yearCycle,yearPlanId:u.yearPlanId},n.id),l()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}}function _(e){let t=s.find(t=>t.id===e);d({...u,yearPlanId:e,yearCycle:t?.yearCycle||u.yearCycle})}return(0,N.jsxs)(ve,{open:t,title:`目标详情`,onClose:l,footer:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:l,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,N.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>void g(),className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white hover:bg-[#3566d0] disabled:opacity-40`,children:f?`保存中…`:`保存`})]}),children:[m?(0,N.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:m}):null,(0,N.jsx)(k,{icon:(0,N.jsx)(O,{}),label:`目标描述`,children:(0,N.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>d({...u,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:`请输入内容`,className:A})}),c(`yearCycle`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`年度周期`,children:(0,N.jsx)(j,{flat:!0,className:`w-full`,yearCycles:r,value:u.yearCycle,onChange:e=>{let t=s.find(e=>e.id===u.yearPlanId),n=!!(u.yearPlanId&&t?.yearCycle&&t.yearCycle!==e);d({...u,yearCycle:e,...n?{yearPlanId:``}:null})},mutate:o,renderTrigger:(e,{empty:t})=>(0,N.jsx)(i,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,c(`yearPlanId`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`年度计划`,children:(0,N.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:te,value:u.yearPlanId,onChange:_,className:`w-full`,renderTrigger:()=>{let e=ze(s,u.yearPlanId);return(0,N.jsx)(i,{text:e||`未选择`,className:`block min-w-0 truncate ${e?`text-stone-800`:`text-stone-400`}`})}})}):null,c(`quarter`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`季度周期`,children:(0,N.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:u.quarter,onChange:e=>d({...u,quarter:e}),className:`w-full`,renderTrigger:()=>(0,N.jsx)(i,{text:u.quarter?b[u.quarter]:S,className:`block min-w-0 truncate ${u.quarter?`text-stone-800`:`text-stone-400`}`})})}):null,c(`createdAt`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`创建日期`,children:(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,c(`updatedAt`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`修改日期`,children:(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function L(){let e=se(),{store:t,live:n,error:ve,setError:T,updateItem:D,createItems:O,deleteItems:k}=be(e.ready&&e.on),A=(0,M.useMemo)(()=>({createItems:O,updateItem:D,deleteItems:k}),[O,D,k]),I=me(je,Ae),[L,Ue]=he(Me),[R,We]=ie(Ne,Pe,`none`),[z,Ge]=(0,M.useState)({}),B=R===`yearQuarter`,Ke=de(B),qe=(0,M.useMemo)(()=>{let e=v(B);return ae(ke,I.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[I.isVisible,B]),[V,H]=(0,M.useState)(null),[Je,Ye]=(0,M.useState)(null),[U,Xe]=(0,M.useState)(!1),[W,Ze]=(0,M.useState)(!1),[Qe,$e]=(0,M.useState)({}),[G,K]=(0,M.useState)(null),q=ee(`life.objectives.cols.v13`,qe),et=(0,M.useMemo)(()=>Re(t.yearPlans),[t.yearPlans]),tt=c(`life.objectives`),J=(0,M.useMemo)(()=>ne(Ce(t.objectives,L)),[t.objectives,L]),Y=(0,M.useMemo)(()=>{if(R===`none`)return[{key:`all`,label:`全部目标`,pill:`bg-stone-500 text-white`,items:J}];let e=e=>e.yearCycle.trim(),n=e=>e?Ee(t.yearCycles,e)||`未设置年度`:xe,r=[...new Set(J.map(e))];return r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0?[{key:`year:`,label:xe,pill:h(``),items:[]}]:R===`yearCycle`?r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t);return{key:`year:${t}`,label:i,pill:h(t),items:r}}):r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t),a=Fe.map(e=>{let n=e===`unset`?S:b[e],i=r.filter(t=>(t.quarter||`unset`)===(e===`unset`?`unset`:e));return{key:`year:${t}|quarter:${e}`,label:n,pill:P[e],items:i}}),o=new Set(a.flatMap(e=>e.items.map(e=>e.id))),s=r.filter(e=>!o.has(e.id));return s.length>0&&a.push({key:`year:${t}|quarter:other`,label:`其它`,pill:P.unset,items:s}),{key:`year:${t}`,label:i,pill:h(t),children:a.filter(e=>e.items.length>0)}}).filter(e=>(e.children?.length??0)>0)},[R,J,t.yearCycles]),nt=(0,M.useMemo)(()=>ce(Y,R===`none`?{}:z),[Y,z,R]),rt=(0,M.useMemo)(()=>re(Y,R===`none`?{}:z),[Y,z,R]),X=p(rt),{submit:it}=pe({row:G,setRow:K,submitting:W,isPristine:e=>!e.title.trim()&&e.yearCycle===e.baseYearCycle&&e.yearPlanId===e.baseYearPlanId&&e.quarter===e.baseQuarter,onSubmit:async e=>{Ze(!0);try{await O(`objectives`,[{title:e.title,yearCycle:e.yearCycle,yearPlanId:e.yearPlanId,quarter:e.quarter}]),K(null),o(`已新增 Objective`,`success`),T(``)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),o(`新增失败:${t}`,`error`)}finally{Ze(!1)}}});function at(e,t){let n=t?.yearCycle??``,r=t?.yearPlanId??``,i=t?.quarter??``;K({groupKey:e,title:``,yearCycle:n,yearPlanId:r,quarter:i,baseYearCycle:n,baseYearPlanId:r,baseQuarter:i}),Ge(t=>({...t,[e]:!1}))}function ot(e,n){return{yearPlanId:e,yearCycle:t.yearPlans.find(t=>t.id===e)?.yearCycle||n}}async function Z(e,t){try{await D(`objectives`,e,t),$e(t=>{let n={...t};return delete n[e],n}),T(``)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),o(`保存失败:${t}`,`error`)}}function st(e){return{...e,...Qe[e.id]}}function ct(e,t){$e(n=>({...n,[e]:{...n[e],...t}}))}async function lt(e){let t=Qe[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):T(`目标描述不能为空`)}async function ut(e,t){await D(`objectives`,t,e),o(`已保存`,`success`)}async function dt(){let e=V;if(e?.length){H(null),Xe(!0);try{await k(`objectives`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){T(e instanceof Error?e.message:String(e))}finally{Xe(!1)}}}function Q(){return G?(0,N.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,N.jsx)(`td`,{className:u,style:Ke,children:(0,N.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(),it()):e.key===`Escape`&&(e.preventDefault(),K(null))},className:ye})}),I.isVisible(`yearCycle`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(j,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:G.yearCycle,onChange:e=>K(n=>{if(!n)return n;let r=t.yearPlans.find(e=>e.id===n.yearPlanId),i=!!(n.yearPlanId&&r?.yearCycle&&r.yearCycle!==e);return{...n,yearCycle:e,...i?{yearPlanId:``}:null}}),mutate:A})}):null,I.isVisible(`yearPlanId`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,fitContent:!!G.yearPlanId,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:et,value:G.yearPlanId,onChange:e=>K(t=>t&&{...t,...ot(e,t.yearCycle)}),triggerClassName:G.yearPlanId?w:C,renderTrigger:()=>{let e=ze(t.yearPlans,G.yearPlanId);return e?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md bg-[#e8f0fe] px-2 text-xs font-medium text-[#1f4ec2]`,children:(0,N.jsx)(i,{text:e,className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,I.isVisible(`quarter`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,fitContent:!!G.quarter,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:G.quarter,onChange:e=>K(t=>t&&{...t,quarter:e}),triggerClassName:G.quarter?w:C,renderTrigger:()=>G.quarter?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${P[Ie(G.quarter)]}`,children:(0,N.jsx)(i,{text:b[G.quarter],className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})})}):null,I.isVisible(`keyResults`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,I.isVisible(`progress`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(g,{value:0})}):null,I.isVisible(`createdAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:`—`,muted:!0})}):null,I.isVisible(`updatedAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:`—`,muted:!0})}):null,(0,N.jsx)(`td`,{"aria-hidden":`true`}),(0,N.jsx)(`td`,{className:l})]}):null}function ft(e,n,r=0){let o=st(e),s=_e(o.id,t.krTasks),c=we(o.id,t.krTasks,t.krTodos);return(0,N.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,N.jsx)(Se,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0,depth:r}),(0,N.jsx)(`td`,{className:u,style:Ke,children:(0,N.jsx)(oe,{value:o.title,placeholder:`目标描述`,onChange:t=>ct(e.id,{title:t}),onCommit:()=>void lt(e),onCancel:()=>$e(t=>{let n={...t};return delete n[e.id],n})})}),I.isVisible(`yearCycle`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(j,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:o.yearCycle,onChange:n=>{let r=t.yearPlans.find(e=>e.id===o.yearPlanId),i=o.yearPlanId&&r?.yearCycle&&r.yearCycle!==n?{yearCycle:n,yearPlanId:``}:{yearCycle:n};Qe[e.id]?ct(e.id,i):Z(e.id,i)},mutate:A})}):null,I.isVisible(`yearPlanId`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,fitContent:!!o.yearPlanId,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:et,value:o.yearPlanId||``,onChange:t=>{let n=ot(t,o.yearCycle);Z(e.id,n)},triggerClassName:o.yearPlanId?w:C,renderTrigger:()=>{let e=ze(t.yearPlans,o.yearPlanId||``);return e?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md bg-[#e8f0fe] px-2 text-xs font-medium text-[#1f4ec2]`,children:(0,N.jsx)(i,{text:e,className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,I.isVisible(`quarter`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,fitContent:!!o.quarter,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:o.quarter,onChange:t=>void Z(e.id,{quarter:t}),triggerClassName:o.quarter?w:C,renderTrigger:()=>o.quarter?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${P[Ie(o.quarter)]}`,children:(0,N.jsx)(i,{text:b[o.quarter],className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})})}):null,I.isVisible(`keyResults`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(i,{text:s.length?s.join(` · `):`暂无 KR 任务`,className:`block min-w-0 truncate text-xs text-stone-600`})}):null,I.isVisible(`progress`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(g,{value:c})}):null,I.isVisible(`createdAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:E(e.createdAt),muted:!e.createdAt})}):null,I.isVisible(`updatedAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,N.jsx)(`td`,{"aria-hidden":`true`}),(0,N.jsx)(`td`,{className:l,children:(0,N.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,N.jsx)(le,{label:`编辑 ${e.title}`,disabled:U,onClick:()=>Ye(e)}),(0,N.jsx)(Oe,{label:`删除 ${e.title}`,disabled:U,onClick:()=>H([e])})]})})]},e.id)}if(!e.ready)return(0,N.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,N.jsx)(_,{children:fe()});if(n===null)return(0,N.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,N.jsx)(_,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=qe.length;return(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,N.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.objectives.length}),` 条`]}),(0,N.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`input`,{value:L,onChange:e=>Ue(e.target.value),placeholder:`搜索 Objective…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#4176e6]`}),(0,N.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:Le,value:R,onChange:e=>We(e)}),(0,N.jsx)(te,{fields:I.fields,isVisible:I.isVisible,onToggle:I.toggle}),(0,N.jsx)(`button`,{type:`button`,disabled:U||X.selectedIds.length===0,onClick:()=>H(t.objectives.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,N.jsx)(`button`,{type:`button`,disabled:U||W,onClick:()=>{let e=Ve(Y);at(e,Be(e))},className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 新建目标`})]})]}),(0,N.jsx)(De,{error:ve,onDismiss:()=>T(``)}),(0,N.jsx)(`div`,{ref:tt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,N.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,N.jsx)(`colgroup`,{children:qe.map(e=>(0,N.jsx)(`col`,{style:e.key===`select`?{width:v(B)}:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,N.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(m,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible(),nested:B}),(0,N.jsxs)(`th`,{className:`${d} text-xs text-stone-500`,style:Ke,children:[`目标描述`,(0,N.jsx)(f,{...q.resizeProps(`title`)})]}),I.isVisible(`yearCycle`)?(0,N.jsxs)(`th`,{className:x,children:[`年度周期`,(0,N.jsx)(f,{...q.resizeProps(`yearCycle`)})]}):null,I.isVisible(`yearPlanId`)?(0,N.jsxs)(`th`,{className:x,children:[`年度计划`,(0,N.jsx)(f,{...q.resizeProps(`yearPlanId`)})]}):null,I.isVisible(`quarter`)?(0,N.jsxs)(`th`,{className:x,children:[`季度周期`,(0,N.jsx)(f,{...q.resizeProps(`quarter`)})]}):null,I.isVisible(`keyResults`)?(0,N.jsxs)(`th`,{className:x,children:[`关键结果(KR 任务)`,(0,N.jsx)(f,{...q.resizeProps(`keyResults`)})]}):null,I.isVisible(`progress`)?(0,N.jsxs)(`th`,{className:x,children:[`完成度`,(0,N.jsx)(f,{...q.resizeProps(`progress`)})]}):null,I.isVisible(`createdAt`)?(0,N.jsxs)(`th`,{className:x,children:[`创建日期`,(0,N.jsx)(f,{...q.resizeProps(`createdAt`)})]}):null,I.isVisible(`updatedAt`)?(0,N.jsxs)(`th`,{className:x,children:[`修改日期`,(0,N.jsx)(f,{...q.resizeProps(`updatedAt`)})]}):null,(0,N.jsx)(`th`,{"aria-hidden":`true`}),(0,N.jsx)(`th`,{className:s,children:`操作`})]})}),(0,N.jsx)(`tbody`,{children:J.length===0&&!G?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.objectives.length===0?`还没有 Objective`:`没有匹配的记录`})}):J.length===0&&G?Q():R===`none`?(0,N.jsxs)(N.Fragment,{children:[J.map((e,t)=>ft(e,t+1)),G?Q():(0,N.jsx)(ge,{colSpan:$,depth:0,selectColPx:v(B),disabled:U||W,onClick:()=>at(`all`)})]}):nt.length===0?G?Q():null:nt.map(e=>{let t=!z[e.key];return(0,N.jsxs)(M.Fragment,{children:[(0,N.jsx)(Te,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:$,selectColPx:v(B),onToggle:()=>Ge(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>ft(t,n+1,e.depth)),e.items&&e.items.length>0?G?.groupKey===e.key?Q():(0,N.jsx)(ge,{colSpan:$,depth:e.depth,selectColPx:v(B),disabled:U||W,onClick:()=>at(e.key,Be(e.key))}):G?.groupKey===e.key?Q():null]},e.key)})})]})}),(0,N.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,N.jsxs)(`span`,{children:[`显示 `,J.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,N.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`选「年度计划」后,对应计划的关联 Objective 会自动带出`})]}),Je?(0,N.jsx)(He,{open:!0,item:Je,yearCycles:t.yearCycles,yearCycleMutate:A,yearPlans:t.yearPlans,isVisible:I.isVisible,onClose:()=>Ye(null),onSave:ut}):null,(0,N.jsx)(r,{open:V!=null,title:V&&V.length>1?`批量删除`:`删除 Objective`,message:V&&V.length>1?`删除选中的 ${V.length} 条目标?`:`删除「${V?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>H(null),onConfirm:()=>void dt()})]})}export{L as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{n as i,t as a}from"./SelectDropdown.D7IeyHDI.js";import{m as o}from"./PmShared.BQVzwsiz.js";import{showToast as s}from"./Toast.BydY-X7T.js";import{t as c}from"./NamePromptDialog.KPCeXmri.js";import{B as l,h as u,xt as d,yt as f}from"./LifeShared.bY2l01Ha.js";var p=e(t(),1),m=n(),h=u;function g(e){let{planTypes:t,value:n,onChange:u,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)(()=>d(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)u(n.id);else{D(!0);try{let e=(await g.createItems(`planTypes`,[{name:t}])).items[0];e?.id&&u(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(`planTypes`,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(`planTypes`,[e.id]),I===e.id&&u(``),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-[#4176e6]/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:u,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:`请输入类型名称`,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??``}」?已引用该类型的记录会清空类型。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>N(null),onConfirm:()=>void V()})]})}export{g as t};
@@ -1,5 +1,5 @@
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{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 ee,t as f}from"./ColumnResize.CkE59sGq.js";import{$ as p,A as m,B as h,C as te,D as g,E as ne,G as re,H as ie,J as ae,L as oe,M as _,N as se,Q as ce,S as le,T as ue,U as de,V as fe,W as v,X as pe,Y as me,Z as he,_ as ge,b as _e,c as ve,ct as y,et as ye,f as b,g as x,k as be,lt as S,m as C,o as w,pt as xe,q as Se,v as Ce,vt as T,w as we,wt as Te,x as Ee,y as De,z as E}from"./LifeShared.tnT7aQON.js";import{c as D,l as O,n as k,t as A}from"./DrawerField.BH3p4Q4D.js";var j=e(t(),1),M=n(),Oe=[{key:`select`,width:36,min:32},{key:`title`,width:200,min:140},{key:`objective`,width:180,min:120},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`progress`,width:120,min:96},{key:`score`,width:72,min:56},{key:`experience`,width:220,min:140},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],ke=[{key:`objective`,label:`Objective`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`progress`,label:`完成度`},{key:`score`,label:`评分`},{key:`experience`,label:`经验收获`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ae=`life.reviews.fields`,je=`life.reviews.search`,Me=`life.reviews.group`,Ne=[`year`,`none`],Pe=[{value:`none`,label:`不分组`},{value:`year`,label:`按年度周期分组`}];function Fe(e){return{title:``,objectiveId:e?.objectiveId??``,score:e?.score??0,experience:e?.experience??`1) 有什么是做得好的
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{n as i,t as a}from"./SelectDropdown.D7IeyHDI.js";import{showToast as o}from"./Toast.BydY-X7T.js";import{c as s,d as c,i as l,l as u,n as d,o as ee,t as f}from"./ColumnResize.CkE59sGq.js";import{$ as p,A as m,B as h,C as te,D as g,E as ne,G as re,H as ie,J as ae,L as oe,M as _,N as se,Q as ce,S as le,T as ue,U as de,V as fe,W as v,X as pe,Y as me,Z as he,_ as ge,b as _e,c as ve,ct as y,et as ye,f as b,g as x,k as be,lt as S,m as C,o as w,pt as xe,q as Se,v as Ce,vt as T,w as we,wt as Te,x as Ee,y as De,z as E}from"./LifeShared.bY2l01Ha.js";import{c as D,l as O,n as k,t as A}from"./DrawerField.CLdvmHc6.js";var j=e(t(),1),M=n(),Oe=[{key:`select`,width:36,min:32},{key:`title`,width:200,min:140},{key:`objective`,width:180,min:120},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`progress`,width:120,min:96},{key:`score`,width:72,min:56},{key:`experience`,width:220,min:140},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],ke=[{key:`objective`,label:`Objective`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`progress`,label:`完成度`},{key:`score`,label:`评分`},{key:`experience`,label:`经验收获`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ae=`life.reviews.fields`,je=`life.reviews.search`,Me=`life.reviews.group`,Ne=[`year`,`none`],Pe=[{value:`none`,label:`不分组`},{value:`year`,label:`按年度周期分组`}];function Fe(e){return{title:``,objectiveId:e?.objectiveId??``,score:e?.score??0,experience:e?.experience??`1) 有什么是做得好的
2
2
  2) 有什么是做得不够好的
3
- 3) 总结如何下次做得更好`}}function N(e,t,n){if(e.trim()||!t)return;let r=n.find(e=>e.id===t)?.title.trim();return r?`${r} 复盘`:void 0}function P(e){return Math.max(0,Math.min(100,Number.isFinite(e)?e:0))}function Ie(e,t){let n=t?.yearCycle?.trim()||``;return n&&Te(e.yearCycles,n)||`—`}function Le(e){let{open:t,item:n,objectiveOptions:r,store:o,isVisible:s,onClose:c,onSave:l}=e,[u,d]=(0,j.useState)(Fe()),[ee,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``);(0,j.useEffect)(()=>{t&&(m(``),f(!1),d({title:n.title,objectiveId:n.objectiveId,score:n.score,experience:n.experience}))},[t,n]);let h=v(o,u.objectiveId),te=h?T(h.id,o.krTasks,o.krTodos):0;async function g(){let e=u.title.trim();if(!e)m(`请填写复盘标题`);else{f(!0);try{await l({...u,title:e,score:P(u.score)},n.id),c()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}}return(0,M.jsxs)(_e,{open:t,title:`复盘详情`,onClose:c,footer:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,onClick:c,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,M.jsx)(`button`,{type:`button`,disabled:ee,onClick:()=>void g(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:ee?`保存中…`:`保存`})]}),children:[p?(0,M.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:p}):null,(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`标题`,children:(0,M.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>d({...u,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:`请输入内容`,className:A})}),s(`objective`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`Objective`,children:(0,M.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,options:r,value:u.objectiveId,onChange:e=>{let t=N(u.title,e,o.objectives);d({...u,objectiveId:e,...t?{title:t}:null})},className:`w-full`,triggerClassName:u.objectiveId?void 0:w,renderTrigger:()=>u.objectiveId&&h?(0,M.jsx)(i,{text:h.title,className:`block min-w-0 truncate text-stone-800`}):(0,M.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`})})}):null,s(`year`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`年度周期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?Ie(o,h):`跟随所属目标`})}):null,s(`quarter`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`季度周期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?h.quarter?y[h.quarter]:`—`:`跟随所属目标`})}):null,s(`progress`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`完成度`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?`${te}%(按关联 KR 任务完成度)`:`关联 Objective 后自动计算`})}):null,s(`score`)?(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`评分`,children:(0,M.jsx)(`input`,{type:`number`,min:0,max:100,value:u.score,onChange:e=>{let t=e.target.value;if(t===``){d({...u,score:0});return}let n=Number(t);Number.isFinite(n)&&d({...u,score:P(n)})},className:A})}):null,s(`experience`)?(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`经验收获`,children:(0,M.jsx)(`textarea`,{value:u.experience,onChange:e=>d({...u,experience:e.target.value}),placeholder:S,rows:4,className:`w-full rounded-md border border-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}):null,s(`createdAt`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`创建日期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,s(`updatedAt`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`修改日期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function F(){let e=ce(),{store:t,live:n,error:_e,setError:S,updateItem:D,createItems:O,deleteItems:k}=ye(e.ready&&e.on),[A,Fe]=he(je),F=de(),[I,Re]=ae(Me,Ne,`none`),[ze,Be]=(0,j.useState)({}),[L,R]=(0,j.useState)(null),[Ve,He]=(0,j.useState)(null),[z,Ue]=(0,j.useState)(!1),[B,We]=(0,j.useState)(!1),[V,H]=(0,j.useState)({}),[U,W]=(0,j.useState)(null),G=me(Ae,ke),Ge=(0,j.useMemo)(()=>oe(Oe,G.isVisible),[G.isVisible]),K=u(`life.reviews.cols.v12`,Ge),Ke=c(`life.reviews`),qe=(0,j.useMemo)(()=>[{value:``,label:C},...Se(t.objectives).map(e=>({value:e.id,label:e.title}))],[t.objectives]),q=(0,j.useMemo)(()=>re(xe(t.reviews,A)),[t.reviews,A]),J=(0,j.useMemo)(()=>{if(I===`none`)return[{key:`all`,label:`全部复盘`,pill:`bg-stone-500 text-white`,items:q}];let e=e=>v(t,e.objectiveId)?.yearCycle?.trim()||``,n=e=>e?Te(t.yearCycles,e)||e:x,r=[...new Set(q.map(e))];r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1);let i=r.filter(Boolean).map(t=>({key:`year:${t}`,label:n(t),pill:h(t),items:q.filter(n=>e(n)===t)})),a=q.filter(e=>!v(t,e.objectiveId)?.yearCycle?.trim());return a.length&&i.push({key:`year:unset`,label:x,pill:h(``),items:a}),i},[I,q,t,t.yearCycles]),Y=(0,j.useMemo)(()=>{if(I===`none`)return J;let e=J.filter(e=>e.items.length>0);return e.length>0?e:[{key:`year:unset`,label:x,pill:h(``),items:[]}]},[I,J]),Je=(0,j.useMemo)(()=>Y.flatMap(e=>e.items.map(e=>e.id)),[Y]),X=p(Je),{submit:Ye}=pe({row:U,setRow:W,submitting:B,isPristine:e=>!e.title.trim()&&e.objectiveId===e.baseObjectiveId&&e.score===e.baseScore&&e.experience===e.baseExperience,onSubmit:async e=>{We(!0);try{await O(`reviews`,[{title:e.title,objectiveId:e.objectiveId,score:P(e.score),experience:e.experience}]),W(null),o(`已新增复盘`,`success`),S(``)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),o(`新增失败:${t}`,`error`)}finally{We(!1)}}});function Xe(e,t){let n=t?.objectiveId??``,r=t?.score??0,i=t?.experience??`1) 有什么是做得好的
3
+ 3) 总结如何下次做得更好`}}function N(e,t,n){if(e.trim()||!t)return;let r=n.find(e=>e.id===t)?.title.trim();return r?`${r} 复盘`:void 0}function P(e){return Math.max(0,Math.min(100,Number.isFinite(e)?e:0))}function Ie(e,t){let n=t?.yearCycle?.trim()||``;return n&&Te(e.yearCycles,n)||`—`}function Le(e){let{open:t,item:n,objectiveOptions:r,store:o,isVisible:s,onClose:c,onSave:l}=e,[u,d]=(0,j.useState)(Fe()),[ee,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``);(0,j.useEffect)(()=>{t&&(m(``),f(!1),d({title:n.title,objectiveId:n.objectiveId,score:n.score,experience:n.experience}))},[t,n]);let h=v(o,u.objectiveId),te=h?T(h.id,o.krTasks,o.krTodos):0;async function g(){let e=u.title.trim();if(!e)m(`请填写复盘标题`);else{f(!0);try{await l({...u,title:e,score:P(u.score)},n.id),c()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}}return(0,M.jsxs)(_e,{open:t,title:`复盘详情`,onClose:c,footer:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,onClick:c,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,M.jsx)(`button`,{type:`button`,disabled:ee,onClick:()=>void g(),className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white hover:bg-[#3566d0] disabled:opacity-40`,children:ee?`保存中…`:`保存`})]}),children:[p?(0,M.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:p}):null,(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`标题`,children:(0,M.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>d({...u,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:`请输入内容`,className:A})}),s(`objective`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`Objective`,children:(0,M.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,options:r,value:u.objectiveId,onChange:e=>{let t=N(u.title,e,o.objectives);d({...u,objectiveId:e,...t?{title:t}:null})},className:`w-full`,triggerClassName:u.objectiveId?void 0:w,renderTrigger:()=>u.objectiveId&&h?(0,M.jsx)(i,{text:h.title,className:`block min-w-0 truncate text-stone-800`}):(0,M.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`})})}):null,s(`year`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`年度周期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?Ie(o,h):`跟随所属目标`})}):null,s(`quarter`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`季度周期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?h.quarter?y[h.quarter]:`—`:`跟随所属目标`})}):null,s(`progress`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`完成度`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?`${te}%(按关联 KR 任务完成度)`:`关联 Objective 后自动计算`})}):null,s(`score`)?(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`评分`,children:(0,M.jsx)(`input`,{type:`number`,min:0,max:100,value:u.score,onChange:e=>{let t=e.target.value;if(t===``){d({...u,score:0});return}let n=Number(t);Number.isFinite(n)&&d({...u,score:P(n)})},className:A})}):null,s(`experience`)?(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`经验收获`,children:(0,M.jsx)(`textarea`,{value:u.experience,onChange:e=>d({...u,experience:e.target.value}),placeholder:S,rows:4,className:`w-full rounded-md border border-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,s(`createdAt`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`创建日期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,s(`updatedAt`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`修改日期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function F(){let e=ce(),{store:t,live:n,error:_e,setError:S,updateItem:D,createItems:O,deleteItems:k}=ye(e.ready&&e.on),[A,Fe]=he(je),F=de(),[I,Re]=ae(Me,Ne,`none`),[ze,Be]=(0,j.useState)({}),[L,R]=(0,j.useState)(null),[Ve,He]=(0,j.useState)(null),[z,Ue]=(0,j.useState)(!1),[B,We]=(0,j.useState)(!1),[V,H]=(0,j.useState)({}),[U,W]=(0,j.useState)(null),G=me(Ae,ke),Ge=(0,j.useMemo)(()=>oe(Oe,G.isVisible),[G.isVisible]),K=u(`life.reviews.cols.v12`,Ge),Ke=c(`life.reviews`),qe=(0,j.useMemo)(()=>[{value:``,label:C},...Se(t.objectives).map(e=>({value:e.id,label:e.title}))],[t.objectives]),q=(0,j.useMemo)(()=>re(xe(t.reviews,A)),[t.reviews,A]),J=(0,j.useMemo)(()=>{if(I===`none`)return[{key:`all`,label:`全部复盘`,pill:`bg-stone-500 text-white`,items:q}];let e=e=>v(t,e.objectiveId)?.yearCycle?.trim()||``,n=e=>e?Te(t.yearCycles,e)||e:x,r=[...new Set(q.map(e))];r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1);let i=r.filter(Boolean).map(t=>({key:`year:${t}`,label:n(t),pill:h(t),items:q.filter(n=>e(n)===t)})),a=q.filter(e=>!v(t,e.objectiveId)?.yearCycle?.trim());return a.length&&i.push({key:`year:unset`,label:x,pill:h(``),items:a}),i},[I,q,t,t.yearCycles]),Y=(0,j.useMemo)(()=>{if(I===`none`)return J;let e=J.filter(e=>e.items.length>0);return e.length>0?e:[{key:`year:unset`,label:x,pill:h(``),items:[]}]},[I,J]),Je=(0,j.useMemo)(()=>Y.flatMap(e=>e.items.map(e=>e.id)),[Y]),X=p(Je),{submit:Ye}=pe({row:U,setRow:W,submitting:B,isPristine:e=>!e.title.trim()&&e.objectiveId===e.baseObjectiveId&&e.score===e.baseScore&&e.experience===e.baseExperience,onSubmit:async e=>{We(!0);try{await O(`reviews`,[{title:e.title,objectiveId:e.objectiveId,score:P(e.score),experience:e.experience}]),W(null),o(`已新增复盘`,`success`),S(``)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),o(`新增失败:${t}`,`error`)}finally{We(!1)}}});function Xe(e,t){let n=t?.objectiveId??``,r=t?.score??0,i=t?.experience??`1) 有什么是做得好的
4
4
  2) 有什么是做得不够好的
5
- 3) 总结如何下次做得更好`;W({groupKey:e,title:``,objectiveId:n,score:r,experience:i,baseObjectiveId:n,baseScore:r,baseExperience:i}),Be(t=>({...t,[e]:!1}))}async function Ze(e,t){try{await D(`reviews`,e,t),H(t=>{let n={...t};return delete n[e],n}),S(``)}catch(e){S(e instanceof Error?e.message:String(e)),o(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Qe(e,t){try{await D(`reviews`,e,{score:t}),H(t=>{let n=t[e];if(!n||!(`score`in n))return t;let r={...n};if(delete r.score,Object.keys(r).length===0){let n={...t};return delete n[e],n}return{...t,[e]:r}}),S(``)}catch(e){S(e instanceof Error?e.message:String(e)),o(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}}function $e(e){return{...e,...V[e.id]}}function Z(e,t){H(n=>({...n,[e]:{...n[e],...t}}))}async function et(e){let t=V[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Ze(e.id,{...t,title:n}):S(`标题不能为空`)}async function tt(e,t){await D(`reviews`,t,e),o(`已保存`,`success`)}function Q(){if(!U)return null;let e=v(t,U.objectiveId),n=e?T(e.id,t.krTasks,t.krTodos):0;return(0,M.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,M.jsx)(`td`,{className:d,style:F,children:(0,M.jsx)(`input`,{autoFocus:!0,disabled:B,value:U.title,placeholder:`输入复盘名称,回车或点空白处保存`,onChange:e=>W(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Ye()):e.key===`Escape`&&(e.preventDefault(),W(null))},className:ve})}),G.isVisible(`objective`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:qe,value:U.objectiveId,onChange:e=>W(n=>{if(!n)return n;let r=N(n.title,e,t.objectives);return{...n,objectiveId:e,...r?{title:r}:null}}),triggerClassName:e?`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`:w,renderTrigger:()=>e?(0,M.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,M.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`})})}):null,G.isVisible(`year`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(Ce,{id:e?.yearCycle?.trim()||``,label:Ie(t,e)})}):null,G.isVisible(`quarter`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(_,{text:e?.quarter?y[e.quarter]:`—`,muted:!e?.quarter})}):null,G.isVisible(`progress`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:e?(0,M.jsx)(g,{value:n}):(0,M.jsx)(_,{text:`—`,muted:!0})}):null,G.isVisible(`score`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(`input`,{type:`number`,min:0,max:100,disabled:B,value:U.score,onChange:e=>{let t=e.target.value;if(t===``){W(e=>e&&{...e,score:0});return}let n=Number(t);Number.isFinite(n)&&W(e=>e&&{...e,score:P(n)})},className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm tabular-nums hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}):null,G.isVisible(`experience`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(se,{value:U.experience,placeholder:`经验收获`,onChange:e=>W(t=>t&&{...t,experience:e}),onCommit:()=>void 0,onCancel:()=>void 0})}):null,G.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:`—`,muted:!0})}):null,G.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:`—`,muted:!0})}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:l})]})}async function nt(){let e=L;if(e?.length){R(null),Ue(!0);try{await k(`reviews`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){S(e instanceof Error?e.message:String(e))}finally{Ue(!1)}}}function rt(e,n){let r=$e(e),o=v(t,r.objectiveId),s=o?T(o.id,t.krTasks,t.krTodos):0;return(0,M.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,M.jsx)(be,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0}),(0,M.jsx)(`td`,{className:d,style:F,children:(0,M.jsx)(se,{value:r.title,placeholder:`标题`,onChange:t=>Z(e.id,{title:t}),onCommit:()=>void et(e),onCancel:()=>H(t=>{let n={...t};return delete n[e.id],n})})}),G.isVisible(`objective`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:qe,value:r.objectiveId,onChange:n=>{let i={objectiveId:n},a=N(r.title,n,t.objectives);a&&(i.title=a),Ze(e.id,i)},triggerClassName:o?`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`:w,renderTrigger:()=>o?(0,M.jsx)(i,{text:o.title,className:`block min-w-0 truncate text-stone-800`}):(0,M.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`})})}):null,G.isVisible(`year`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(Ce,{id:o?.yearCycle?.trim()||``,label:Ie(t,o)})}):null,G.isVisible(`quarter`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(_,{text:o?.quarter?y[o.quarter]:`—`,muted:!o?.quarter})}):null,G.isVisible(`progress`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:o?(0,M.jsx)(g,{value:s}):(0,M.jsx)(_,{text:`—`,muted:!0})}):null,G.isVisible(`score`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(`input`,{type:`number`,min:0,max:100,value:r.score,onChange:t=>{let n=t.target.value;if(n===``){Z(e.id,{score:0});return}let r=Number(n);Number.isFinite(r)&&Z(e.id,{score:P(r)})},onBlur:t=>{let n=P(Number(t.currentTarget.value)||0);n===e.score?V[e.id]&&`score`in V[e.id]&&H(t=>{let n=t[e.id];if(!n||!(`score`in n))return t;let r={...n};if(delete r.score,Object.keys(r).length===0){let n={...t};return delete n[e.id],n}return{...t,[e.id]:r}}):Qe(e.id,n)},className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm tabular-nums hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}):null,G.isVisible(`experience`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(se,{value:r.experience,placeholder:`经验收获`,onChange:t=>Z(e.id,{experience:t}),onCommit:()=>void et(e),onCancel:()=>H(t=>{let n={...t};return delete n[e.id],n})})}):null,G.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:E(e.createdAt),muted:!e.createdAt})}):null,G.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:l,children:(0,M.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,M.jsx)(le,{label:`编辑 ${e.title}`,disabled:z,onClick:()=>He(e)}),(0,M.jsx)(De,{label:`删除 ${e.title}`,disabled:z,onClick:()=>R([e])})]})})]},e.id)}if(!e.ready)return(0,M.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(ne,{children:fe()});if(n===null)return(0,M.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,M.jsx)(ne,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=Ge.length;return(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.reviews.length}),` 条`]}),(0,M.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`input`,{value:A,onChange:e=>Fe(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,M.jsx)(a,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Pe,value:I,onChange:e=>Re(e)}),(0,M.jsx)(te,{fields:G.fields,isVisible:G.isVisible,onToggle:G.toggle}),(0,M.jsx)(`button`,{type:`button`,disabled:z||X.selectedIds.length===0,onClick:()=>R(t.reviews.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,M.jsx)(`button`,{type:`button`,disabled:z||B,onClick:()=>{Xe((Y[0]??J[0])?.key??`all`)},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,M.jsx)(Ee,{error:_e,onDismiss:()=>S(``)}),(0,M.jsx)(`div`,{ref:Ke,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,M.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:K.tableStyle,children:[(0,M.jsx)(`colgroup`,{children:Ge.map(e=>(0,M.jsx)(`col`,{style:e.key===`select`?{width:ie(!1)}:K.widthOf(e.key)?{width:K.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.jsx)(m,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible()}),(0,M.jsxs)(`th`,{className:`${ee} text-xs text-stone-500`,style:F,children:[`标题`,(0,M.jsx)(f,{...K.resizeProps(`title`)})]}),G.isVisible(`objective`)?(0,M.jsxs)(`th`,{className:b,children:[`Objective`,(0,M.jsx)(f,{...K.resizeProps(`objective`)})]}):null,G.isVisible(`year`)?(0,M.jsxs)(`th`,{className:b,children:[`年度周期`,(0,M.jsx)(f,{...K.resizeProps(`year`)})]}):null,G.isVisible(`quarter`)?(0,M.jsxs)(`th`,{className:b,children:[`季度周期`,(0,M.jsx)(f,{...K.resizeProps(`quarter`)})]}):null,G.isVisible(`progress`)?(0,M.jsxs)(`th`,{className:b,children:[`完成度`,(0,M.jsx)(f,{...K.resizeProps(`progress`)})]}):null,G.isVisible(`score`)?(0,M.jsxs)(`th`,{className:b,children:[`评分`,(0,M.jsx)(f,{...K.resizeProps(`score`)})]}):null,G.isVisible(`experience`)?(0,M.jsxs)(`th`,{className:b,children:[`经验收获`,(0,M.jsx)(f,{...K.resizeProps(`experience`)})]}):null,G.isVisible(`createdAt`)?(0,M.jsxs)(`th`,{className:b,children:[`创建日期`,(0,M.jsx)(f,{...K.resizeProps(`createdAt`)})]}):null,G.isVisible(`updatedAt`)?(0,M.jsxs)(`th`,{className:b,children:[`修改日期`,(0,M.jsx)(f,{...K.resizeProps(`updatedAt`)})]}):null,(0,M.jsx)(`th`,{"aria-hidden":`true`}),(0,M.jsx)(`th`,{className:s,children:`操作`})]})}),(0,M.jsx)(`tbody`,{children:q.length===0&&!U?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.reviews.length===0?`还没有 OKR 复盘`:`没有匹配的记录`})}):q.length===0&&U?Q():I===`none`?(0,M.jsxs)(M.Fragment,{children:[q.map((e,t)=>rt(e,t+1)),U?Q():(0,M.jsx)(ge,{colSpan:$,disabled:z||B,onClick:()=>Xe(`all`)})]}):Y.length===0?U?Q():null:Y.map(e=>{let t=!ze[e.key];return(0,M.jsxs)(j.Fragment,{children:[(0,M.jsx)(we,{label:e.label,pill:e.pill,count:e.items.length,open:t,kind:`tag`,colSpan:$,onToggle:()=>Be(t=>({...t,[e.key]:!t[e.key]}))}),t?(0,M.jsxs)(M.Fragment,{children:[e.items.map((e,t)=>rt(e,t+1)),U?.groupKey===e.key?Q():q.length>0?(0,M.jsx)(ge,{colSpan:$,disabled:z||B,onClick:()=>Xe(e.key)}):null]}):null]},e.key)})})]})}),(0,M.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,M.jsxs)(`span`,{children:[`显示 `,q.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,M.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`新建时经验收获带三段提纲,可按需改写`})]}),Ve?(0,M.jsx)(Le,{open:!0,item:Ve,objectiveOptions:qe,store:t,isVisible:G.isVisible,onClose:()=>He(null),onSave:tt}):null,(0,M.jsx)(r,{open:L!=null,title:L&&L.length>1?`批量删除`:`删除复盘`,message:L&&L.length>1?`删除选中的 ${L.length} 条复盘?`:`删除「${L?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>R(null),onConfirm:()=>void nt()})]})}export{F as default};
5
+ 3) 总结如何下次做得更好`;W({groupKey:e,title:``,objectiveId:n,score:r,experience:i,baseObjectiveId:n,baseScore:r,baseExperience:i}),Be(t=>({...t,[e]:!1}))}async function Ze(e,t){try{await D(`reviews`,e,t),H(t=>{let n={...t};return delete n[e],n}),S(``)}catch(e){S(e instanceof Error?e.message:String(e)),o(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Qe(e,t){try{await D(`reviews`,e,{score:t}),H(t=>{let n=t[e];if(!n||!(`score`in n))return t;let r={...n};if(delete r.score,Object.keys(r).length===0){let n={...t};return delete n[e],n}return{...t,[e]:r}}),S(``)}catch(e){S(e instanceof Error?e.message:String(e)),o(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}}function $e(e){return{...e,...V[e.id]}}function Z(e,t){H(n=>({...n,[e]:{...n[e],...t}}))}async function et(e){let t=V[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Ze(e.id,{...t,title:n}):S(`标题不能为空`)}async function tt(e,t){await D(`reviews`,t,e),o(`已保存`,`success`)}function Q(){if(!U)return null;let e=v(t,U.objectiveId),n=e?T(e.id,t.krTasks,t.krTodos):0;return(0,M.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,M.jsx)(`td`,{className:d,style:F,children:(0,M.jsx)(`input`,{autoFocus:!0,disabled:B,value:U.title,placeholder:`输入复盘名称,回车或点空白处保存`,onChange:e=>W(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Ye()):e.key===`Escape`&&(e.preventDefault(),W(null))},className:ve})}),G.isVisible(`objective`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:qe,value:U.objectiveId,onChange:e=>W(n=>{if(!n)return n;let r=N(n.title,e,t.objectives);return{...n,objectiveId:e,...r?{title:r}:null}}),triggerClassName:e?`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`:w,renderTrigger:()=>e?(0,M.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,M.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`})})}):null,G.isVisible(`year`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(Ce,{id:e?.yearCycle?.trim()||``,label:Ie(t,e)})}):null,G.isVisible(`quarter`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(_,{text:e?.quarter?y[e.quarter]:`—`,muted:!e?.quarter})}):null,G.isVisible(`progress`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:e?(0,M.jsx)(g,{value:n}):(0,M.jsx)(_,{text:`—`,muted:!0})}):null,G.isVisible(`score`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(`input`,{type:`number`,min:0,max:100,disabled:B,value:U.score,onChange:e=>{let t=e.target.value;if(t===``){W(e=>e&&{...e,score:0});return}let n=Number(t);Number.isFinite(n)&&W(e=>e&&{...e,score:P(n)})},className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm tabular-nums hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,G.isVisible(`experience`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(se,{value:U.experience,placeholder:`经验收获`,onChange:e=>W(t=>t&&{...t,experience:e}),onCommit:()=>void 0,onCancel:()=>void 0})}):null,G.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:`—`,muted:!0})}):null,G.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:`—`,muted:!0})}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:l})]})}async function nt(){let e=L;if(e?.length){R(null),Ue(!0);try{await k(`reviews`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){S(e instanceof Error?e.message:String(e))}finally{Ue(!1)}}}function rt(e,n){let r=$e(e),o=v(t,r.objectiveId),s=o?T(o.id,t.krTasks,t.krTodos):0;return(0,M.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,M.jsx)(be,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0}),(0,M.jsx)(`td`,{className:d,style:F,children:(0,M.jsx)(se,{value:r.title,placeholder:`标题`,onChange:t=>Z(e.id,{title:t}),onCommit:()=>void et(e),onCancel:()=>H(t=>{let n={...t};return delete n[e.id],n})})}),G.isVisible(`objective`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:qe,value:r.objectiveId,onChange:n=>{let i={objectiveId:n},a=N(r.title,n,t.objectives);a&&(i.title=a),Ze(e.id,i)},triggerClassName:o?`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`:w,renderTrigger:()=>o?(0,M.jsx)(i,{text:o.title,className:`block min-w-0 truncate text-stone-800`}):(0,M.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`})})}):null,G.isVisible(`year`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(Ce,{id:o?.yearCycle?.trim()||``,label:Ie(t,o)})}):null,G.isVisible(`quarter`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(_,{text:o?.quarter?y[o.quarter]:`—`,muted:!o?.quarter})}):null,G.isVisible(`progress`)?(0,M.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:o?(0,M.jsx)(g,{value:s}):(0,M.jsx)(_,{text:`—`,muted:!0})}):null,G.isVisible(`score`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(`input`,{type:`number`,min:0,max:100,value:r.score,onChange:t=>{let n=t.target.value;if(n===``){Z(e.id,{score:0});return}let r=Number(n);Number.isFinite(r)&&Z(e.id,{score:P(r)})},onBlur:t=>{let n=P(Number(t.currentTarget.value)||0);n===e.score?V[e.id]&&`score`in V[e.id]&&H(t=>{let n=t[e.id];if(!n||!(`score`in n))return t;let r={...n};if(delete r.score,Object.keys(r).length===0){let n={...t};return delete n[e.id],n}return{...t,[e.id]:r}}):Qe(e.id,n)},className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm tabular-nums hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}):null,G.isVisible(`experience`)?(0,M.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,M.jsx)(se,{value:r.experience,placeholder:`经验收获`,onChange:t=>Z(e.id,{experience:t}),onCommit:()=>void et(e),onCancel:()=>H(t=>{let n={...t};return delete n[e.id],n})})}):null,G.isVisible(`createdAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:E(e.createdAt),muted:!e.createdAt})}):null,G.isVisible(`updatedAt`)?(0,M.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,M.jsx)(_,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,M.jsx)(`td`,{"aria-hidden":`true`}),(0,M.jsx)(`td`,{className:l,children:(0,M.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,M.jsx)(le,{label:`编辑 ${e.title}`,disabled:z,onClick:()=>He(e)}),(0,M.jsx)(De,{label:`删除 ${e.title}`,disabled:z,onClick:()=>R([e])})]})})]},e.id)}if(!e.ready)return(0,M.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(ne,{children:fe()});if(n===null)return(0,M.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,M.jsx)(ne,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=Ge.length;return(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.reviews.length}),` 条`]}),(0,M.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`input`,{value:A,onChange:e=>Fe(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-[#4176e6]`}),(0,M.jsx)(a,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Pe,value:I,onChange:e=>Re(e)}),(0,M.jsx)(te,{fields:G.fields,isVisible:G.isVisible,onToggle:G.toggle}),(0,M.jsx)(`button`,{type:`button`,disabled:z||X.selectedIds.length===0,onClick:()=>R(t.reviews.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,M.jsx)(`button`,{type:`button`,disabled:z||B,onClick:()=>{Xe((Y[0]??J[0])?.key??`all`)},className:`h-9 shrink-0 rounded-lg bg-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] disabled:opacity-40`,children:`+ 新建复盘`})]})]}),(0,M.jsx)(Ee,{error:_e,onDismiss:()=>S(``)}),(0,M.jsx)(`div`,{ref:Ke,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,M.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:K.tableStyle,children:[(0,M.jsx)(`colgroup`,{children:Ge.map(e=>(0,M.jsx)(`col`,{style:e.key===`select`?{width:ie(!1)}:K.widthOf(e.key)?{width:K.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.jsx)(m,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible()}),(0,M.jsxs)(`th`,{className:`${ee} text-xs text-stone-500`,style:F,children:[`标题`,(0,M.jsx)(f,{...K.resizeProps(`title`)})]}),G.isVisible(`objective`)?(0,M.jsxs)(`th`,{className:b,children:[`Objective`,(0,M.jsx)(f,{...K.resizeProps(`objective`)})]}):null,G.isVisible(`year`)?(0,M.jsxs)(`th`,{className:b,children:[`年度周期`,(0,M.jsx)(f,{...K.resizeProps(`year`)})]}):null,G.isVisible(`quarter`)?(0,M.jsxs)(`th`,{className:b,children:[`季度周期`,(0,M.jsx)(f,{...K.resizeProps(`quarter`)})]}):null,G.isVisible(`progress`)?(0,M.jsxs)(`th`,{className:b,children:[`完成度`,(0,M.jsx)(f,{...K.resizeProps(`progress`)})]}):null,G.isVisible(`score`)?(0,M.jsxs)(`th`,{className:b,children:[`评分`,(0,M.jsx)(f,{...K.resizeProps(`score`)})]}):null,G.isVisible(`experience`)?(0,M.jsxs)(`th`,{className:b,children:[`经验收获`,(0,M.jsx)(f,{...K.resizeProps(`experience`)})]}):null,G.isVisible(`createdAt`)?(0,M.jsxs)(`th`,{className:b,children:[`创建日期`,(0,M.jsx)(f,{...K.resizeProps(`createdAt`)})]}):null,G.isVisible(`updatedAt`)?(0,M.jsxs)(`th`,{className:b,children:[`修改日期`,(0,M.jsx)(f,{...K.resizeProps(`updatedAt`)})]}):null,(0,M.jsx)(`th`,{"aria-hidden":`true`}),(0,M.jsx)(`th`,{className:s,children:`操作`})]})}),(0,M.jsx)(`tbody`,{children:q.length===0&&!U?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.reviews.length===0?`还没有 OKR 复盘`:`没有匹配的记录`})}):q.length===0&&U?Q():I===`none`?(0,M.jsxs)(M.Fragment,{children:[q.map((e,t)=>rt(e,t+1)),U?Q():(0,M.jsx)(ge,{colSpan:$,disabled:z||B,onClick:()=>Xe(`all`)})]}):Y.length===0?U?Q():null:Y.map(e=>{let t=!ze[e.key];return(0,M.jsxs)(j.Fragment,{children:[(0,M.jsx)(we,{label:e.label,pill:e.pill,count:e.items.length,open:t,kind:`tag`,colSpan:$,onToggle:()=>Be(t=>({...t,[e.key]:!t[e.key]}))}),t?(0,M.jsxs)(M.Fragment,{children:[e.items.map((e,t)=>rt(e,t+1)),U?.groupKey===e.key?Q():q.length>0?(0,M.jsx)(ge,{colSpan:$,disabled:z||B,onClick:()=>Xe(e.key)}):null]}):null]},e.key)})})]})}),(0,M.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,M.jsxs)(`span`,{children:[`显示 `,q.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,M.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`新建时经验收获带三段提纲,可按需改写`})]}),Ve?(0,M.jsx)(Le,{open:!0,item:Ve,objectiveOptions:qe,store:t,isVisible:G.isVisible,onClose:()=>He(null),onSave:tt}):null,(0,M.jsx)(r,{open:L!=null,title:L&&L.length>1?`批量删除`:`删除复盘`,message:L&&L.length>1?`删除选中的 ${L.length} 条复盘?`:`删除「${L?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>R(null),onConfirm:()=>void nt()})]})}export{F as default};
@@ -1,3 +1,3 @@
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,s as a}from"./plugins.BRvXWHLe.js";import{n as o,o as s,r as c,s as l}from"./view-prefs.DhdLZjGh.js";import{i as u,n as d,r as f,t as p}from"./dialog.DZHZCe_T.js";import{t as ee}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./DatePicker.Bkl71M49.js";import{t as h}from"./OverflowHint.CHZeFfUj.js";import{n as te,r as ne,t as re}from"./TableFieldConfig.C7O-mL-p.js";var g=e(t(),1),_=`/__tb_life`,v=[`pending`,`in_progress`,`overdue`,`stalled`,`done`,`closed`],y=[`pool`,`in_progress`,`incomplete`,`done`,`closed`],b=[`in_progress`,`incomplete`,`done`],ie=[`urgent_important`,`urgent`,`important`,`normal`],ae={learning:`pt_learning`,work:`pt_work`,family:`pt_family`,side:`pt_side`},oe=[`Q1`,`Q2`,`Q3`,`Q4`],x={pending:`待开始`,in_progress:`进行中`,overdue:`已延期`,done:`已完成`,stalled:`已停滞`,closed:`已关闭`},se={pool:`任务池`,in_progress:`进行中`,done:`已完成`,incomplete:`未完成`,closed:`已关闭`},ce={in_progress:`进行中`,incomplete:`未完成`,done:`已完成`},le={urgent_important:`重要紧急`,urgent:`紧急不重要`,important:`重要不紧急`,normal:`不重要不紧急`,"":`—`},ue={learning:`学习成长`,work:`工作管理`,family:`家庭生活`,side:`副业赚钱`,pt_learning:`学习成长`,pt_work:`工作管理`,pt_family:`家庭生活`,pt_side:`副业赚钱`,"":`—`};function S(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function C(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function w(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function T(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:ue[t]||t}function E(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:t}function D(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:t}function O(e,t){let n=P(e,40);return n?t.some(e=>e.id===n)?n:t.find(e=>e.name===n)?.id??``:``}function k(e,t){let n=P(e,60);return n?t.some(e=>e.id===n)?n:t.find(e=>e.name===n)?.id??``:``}function A(e,t){let n=P(e,64);if(!n)return``;if(t.has(n))return n;let r=ae[n];return r&&t.has(r)?r:``}var j=`1) 有什么是做得好的
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{i as o}from"./app-config.Dvfzl5_N.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{a as c,o as l,r as u}from"./plugins.Db9xoFZb.js";import{n as d,o as f,r as p,s as ee}from"./view-prefs.COAKEQtZ.js";import{n as m}from"./SelectDropdown.D7IeyHDI.js";import{t as h}from"./DatePicker.BRO_CjVQ.js";import{n as te,r as ne,t as re}from"./TableFieldConfig.72AL-8p-.js";var g=e(t(),1),_=`/__tb_life`,v=[`pending`,`in_progress`,`overdue`,`stalled`,`done`,`closed`],y=[`pool`,`in_progress`,`incomplete`,`done`,`closed`],b=[`in_progress`,`incomplete`,`done`],ie=[`urgent_important`,`urgent`,`important`,`normal`],ae={learning:`pt_learning`,work:`pt_work`,family:`pt_family`,side:`pt_side`},oe=[`Q1`,`Q2`,`Q3`,`Q4`],x={pending:`待开始`,in_progress:`进行中`,overdue:`已延期`,done:`已完成`,stalled:`已停滞`,closed:`已关闭`},se={pool:`任务池`,in_progress:`进行中`,done:`已完成`,incomplete:`未完成`,closed:`已关闭`},ce={in_progress:`进行中`,incomplete:`未完成`,done:`已完成`},le={urgent_important:`重要紧急`,urgent:`紧急不重要`,important:`重要不紧急`,normal:`不重要不紧急`,"":`—`},ue={learning:`学习成长`,work:`工作管理`,family:`家庭生活`,side:`副业赚钱`,pt_learning:`学习成长`,pt_work:`工作管理`,pt_family:`家庭生活`,pt_side:`副业赚钱`,"":`—`};function S(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function C(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function w(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function T(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:ue[t]||t}function E(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:t}function D(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:t}function O(e,t){let n=P(e,40);return n?t.some(e=>e.id===n)?n:t.find(e=>e.name===n)?.id??``:``}function k(e,t){let n=P(e,60);return n?t.some(e=>e.id===n)?n:t.find(e=>e.name===n)?.id??``:``}function A(e,t){let n=P(e,64);if(!n)return``;if(t.has(n))return n;let r=ae[n];return r&&t.has(r)?r:``}var j=`1) 有什么是做得好的
2
2
  2) 有什么是做得不够好的
3
- 3) 总结如何下次做得更好`,M={Q1:`Q1(1月-3月)`,Q2:`Q2(4月-6月)`,Q3:`Q3(7月-9月)`,Q4:`Q4(10月-12月)`,"":`—`},N=/^\d{4}-\d{2}-\d{2}$/;function P(e,t=2e3){return typeof e==`string`?e.trim().slice(0,t):``}function F(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function I(e,t){if(!N.test(e)||!N.test(t))return null;let n=Date.parse(`${e}T00:00:00`),r=Date.parse(`${t}T00:00:00`);return!Number.isFinite(n)||!Number.isFinite(r)?null:Math.max(1,Math.round((r-n)/864e5)+1)}function L(e){return e==null?`—`:`${e} 天`}function R(){return{krTodos:[],krTasks:[],objectives:[],reviews:[],yearPlans:[],lifeStages:[],planTypes:[],yearCycles:[],lifeCycles:[]}}function z(e){return Array.isArray(e)?e:[]}function B(e){if(!e||typeof e!=`object`)return null;let t=e,n=P(t.name,40),r=P(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:P(t.createdAt,40),updatedAt:P(t.updatedAt,40)}}function V(e){if(!e||typeof e!=`object`)return null;let t=e,n=P(t.name,40),r=P(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:P(t.createdAt,40),updatedAt:P(t.updatedAt,40)}}function H(e){if(!e||typeof e!=`object`)return null;let t=e,n=P(t.name,60),r=P(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:P(t.createdAt,40),updatedAt:P(t.updatedAt,40)}}function U(e){if(!e||typeof e!=`object`)return R();let t=e,n=z(t.planTypes).map(B).filter(e=>!!e),r=new Set(n.map(e=>e.id)),i=z(t.yearCycles).map(V).filter(e=>!!e),a=z(t.lifeCycles).map(H).filter(e=>!!e),o=e=>({...e,planType:A(e.planType,r)}),s=e=>({...e,yearCycle:O(e.yearCycle,i)}),c=e=>{let t=e.lifeCycle||e.ageRange,{ageRange:n,...r}=e;return{...r,lifeCycle:k(t,a)}},l=z(t.yearPlans).map(o).map(s),u=new Set(l.map(e=>e.id)),d=z(t.objectives).map(s).map(e=>{let t=P(e.yearPlanId,64);return{...e,yearPlanId:t&&u.has(t)?t:``}});return{krTodos:z(t.krTodos),krTasks:z(t.krTasks).map(o),objectives:d,reviews:z(t.reviews),yearPlans:l,lifeStages:z(t.lifeStages).map(o).map(c),planTypes:n,yearCycles:i,lifeCycles:a}}async function de(){let e=await fetch(_,{headers:{Accept:`application/json`}}),t=await e.json().catch(()=>({}));if(!e.ok||!t?.ok)throw Error(P(t?.error)||`读取失败(${e.status})`);return U(t)}async function fe(){let e=await(await fetch(`${_}?health=1`,{headers:{Accept:`application/json`}})).json().catch(()=>({}));return{ok:!!e?.ok,files:e?.files}}async function pe(e,t){let n=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,items:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r?.ok)throw Error(P(r?.error)||`创建失败(${n.status})`);return{items:z(r.items),total:Number(r.total)||0}}async function me(e,t,n){let r=await fetch(_,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,id:t,...n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i?.ok)throw Error(P(i?.error)||`更新失败(${r.status})`);return i.item}async function he(e,t){let n=await fetch(_,{method:`DELETE`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,ids:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r?.ok)throw Error(P(r?.error)||`删除失败(${n.status})`);return{removed:Number(r.removed)||0,total:Number(r.total)||0}}function W(e,t){let n=t.filter(t=>t.krTaskId===e),r=n.filter(e=>e.status===`done`).length,i=n.length,a=i===0?0:Math.round(r/i*100),o=n.map(e=>e.title),s=new Map;for(let e of n)s.set(e.status,(s.get(e.status)??0)+1);return{count:i,done:r,progress:a,titles:o,summary:i===0?`暂无待办`:[...s.entries()].map(([e,t])=>`${x[e]??e} ${t}`).join(` · `)}}function ge(e,t,n){let r=t.filter(t=>t.objectiveId===e);if(!r.length)return 0;let i=r.reduce((e,t)=>e+W(t.id,n).progress,0);return Math.round(i/r.length)}function _e(e,t){return t.filter(t=>t.objectiveId===e).map(e=>e.title)}function ve(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.title.toLowerCase().includes(n)||(e.note??``).toLowerCase().includes(n)):e}var G=ee(),ye=8e3;function be(){return a(`life`)}function xe(){let[e,t]=(0,g.useState)(!1),[a,o]=(0,g.useState)(()=>r(`life`));return(0,g.useEffect)(()=>{let e=!0,a=i(()=>o(r(`life`)));return n().then(()=>{e&&(o(r(`life`)),t(!0))}),()=>{e=!1,a()}},[]),{ready:e,on:a}}function Se(e){let[t,n]=(0,g.useState)(R),[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 de();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)}},[]),d=(0,g.useCallback)(async(e,t)=>{let n=await pe(e,t);return await u(!0),n},[u]),f=(0,g.useCallback)(async(e,t,n)=>{await me(e,t,n),await u(!0)},[u]),p=(0,g.useCallback)(async(e,t)=>{await he(e,t),await u(!0)},[u]);return(0,g.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{try{let e=await fe();if(!l.current)return;if(!e.ok){i(!1),o(!1);return}if(await u(),!l.current)return;i(!0),t=window.setInterval(()=>void u(!0),ye)}catch{if(!l.current)return;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,createItems:d,updateItem:f,deleteItems:p}}function Ce(e){let[t,n]=(0,g.useState)(()=>c(e));return[t,(0,g.useCallback)(t=>{n(t),l(e,t)},[e])]}function we(e,t,n){let[r,i]=(0,g.useState)(()=>o(e,t,n));return[r,(0,g.useCallback)(t=>{i(t),s(e,t)},[e])]}function Te(e){let[t,n]=(0,g.useState)({}),r=(0,g.useMemo)(()=>new Set(e),[e]);(0,g.useEffect)(()=>{n(e=>{let t=!1,n={};for(let[i,a]of Object.entries(e))r.has(i)&&a?n[i]=!0:a&&(t=!0);return t||Object.keys(n).length!==Object.keys(e).length?n:e})},[r]);let i=(0,g.useMemo)(()=>Object.keys(t).filter(e=>t[e]),[t]),a=e.length>0&&e.every(e=>t[e]);function o(e){n(t=>({...t,[e]:!t[e]}))}function s(){n(t=>{let n={...t},r=!a;for(let t of e)n[t]=r;return n})}function c(){n({})}return{selected:t,selectedIds:i,allVisibleSelected:a,toggle:o,toggleAllVisible:s,clear:c}}function K(e){return e.items?e.items.length:(e.children??[]).reduce((e,t)=>e+K(t),0)}function q(e,t){let n=[],r=(e,i)=>{for(let a of e){let e=!!a.children?.length,o=K(a);if(o===0&&e||o===0&&a.items===void 0)continue;let s=!t[a.key];n.push({key:a.key,label:a.label,pill:a.pill,depth:i,count:o,kind:e?`section`:`tag`,items:e||!s?void 0:a.items??[]}),s&&e&&r(a.children,i+1)}};return r(e,0),n}function Ee(e,t){return q(e,t).flatMap(e=>e.items?e.items.map(e=>e.id):[])}function J(e=!1){return 36+(e?28:0)}function Y(e=!1){return{"--tw-sticky-left":`${J(e)}px`}}Y(!1);var De=`relative px-2 py-2 text-left text-xs font-medium whitespace-nowrap text-stone-500`,X=`relative border-l border-stone-200/90 px-2 py-2 text-left text-xs font-medium whitespace-nowrap text-stone-500`,Oe=new Set([`select`,`title`,`filler`,`action`]);function ke(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 Ae(e,t){return ne(e,t,Oe)}function je(e,t){return te(e,t)}function Me(e){return(0,G.jsx)(re,{...e})}var Ne=`tw-sticky-l px-0 py-1 align-middle`,Pe=`tw-sticky-l px-0 py-2 text-left font-medium whitespace-nowrap`,Fe=`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`,Ie=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,Le=`未选择`,Re=`未关联`,ze=`未设置年度`;function Be(e){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform duration-200 ease-out ${e.open?`rotate-0`:`-rotate-90`}`,children:(0,G.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}function Ve(e){let t=(e.depth??0)>0,n=e.selectColPx??36;e.kind;let r=(0,G.jsx)(`span`,{className:`max-w-[min(100%,16rem)] truncate rounded-full px-2.5 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),i=(0,G.jsxs)(`span`,{className:`shrink-0 text-xs text-stone-400 tabular-nums`,children:[e.count,` 条记录`]}),a=(0,G.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center`,children:(0,G.jsx)(Be,{open:e.open})});if(!t){let t=Math.max(0,e.colSpan-2);return(0,G.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":e.open,"aria-label":e.open?`收起分组`:`展开分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`${n}px`},onClick:e.onToggle,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onToggle())},children:[(0,G.jsx)(`td`,{colSpan:2,className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 pb-1.5 pt-3 align-middle`,style:{left:0,"--tw-sticky-left":`0px`},children:(0,G.jsxs)(`div`,{className:`flex w-full items-center gap-2 py-1.5 pr-2 text-left`,children:[a,r,i]})}),t>0?(0,G.jsx)(`td`,{colSpan:t,className:`border-b border-stone-100 bg-white pb-1.5 pt-3`,"aria-hidden":`true`}):null]})}let o=Math.max(0,e.colSpan-2);return(0,G.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":e.open,"aria-label":e.open?`收起分组`:`展开分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`${n}px`},onClick:e.onToggle,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onToggle())},children:[(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 py-0.5 align-middle`,style:{left:0,width:n,minWidth:n,maxWidth:n,"--tw-sticky-left":`0px`},children:(0,G.jsxs)(`div`,{className:`flex w-full items-center py-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}),a]})}),(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-label border-b border-stone-100 px-2 py-0.5 align-middle`,style:{left:n,"--tw-sticky-left":`${n}px`},children:(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 py-1.5 text-left`,children:[r,i]})}),o>0?(0,G.jsx)(`td`,{colSpan:o,className:`border-b border-stone-100 bg-white py-0.5`,"aria-hidden":`true`}):null]})}function He(e){let t=(e.depth??0)>0,n=e.selectColPx??36,r=Math.max(0,e.colSpan-2);return(0,G.jsxs)(`tr`,{className:`tw-life-group-body`,style:{"--life-select-w":`${n}px`},children:[(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-lead px-0 py-0.5 align-middle`,style:{left:0,width:n,minWidth:n,maxWidth:n,"--tw-sticky-left":`0px`},children:(0,G.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":`新增记录`,className:`flex w-full items-center py-0.5 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[t?(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,G.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center text-sm leading-none`,children:`+`})]})}),(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-label px-2 py-0.5 align-middle`,style:{left:n,"--tw-sticky-left":`${n}px`},children:(0,G.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,className:`rounded py-0.5 text-xs text-stone-400 transition-colors hover:text-stone-600 disabled:opacity-40`,children:`新增记录`})}),r>0?(0,G.jsx)(`td`,{colSpan:r,className:`bg-white py-0.5`,"aria-hidden":`true`}):null]})}var Ue=`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff] disabled:opacity-50`;function We(e){let t=(0,g.useRef)(e.row);t.current=e.row;let n=(0,g.useRef)(e.submitting);n.current=e.submitting;let r=(0,g.useRef)(e.onSubmit);r.current=e.onSubmit;let i=(0,g.useRef)(e.isPristine);i.current=e.isPristine;let a=(0,g.useRef)(e.setRow);a.current=e.setRow;let o=(0,g.useCallback)(async()=>{let e=t.current;if(!e||n.current)return;let i=e.title.trim();i&&await r.current({...e,title:i})},[]);return(0,g.useEffect)(()=>{if(e.row==null)return;let n=e=>{let n=e.target;if(!(n instanceof Element)||n.closest(`.tw-new-row`)||n.closest(`.tw-select-menu`)||n.closest(`.tw-date-panel`)||n.closest(`.tw-confirm-dialog`)||n.closest(`[data-headlessui-portal]`))return;let r=t.current;r&&(r.title.trim()?o():i.current(r)&&a.current(null))};return document.addEventListener(`pointerdown`,n,!0),()=>document.removeEventListener(`pointerdown`,n,!0)},[e.row,o]),{submit:o}}function Ge(e){let t=Math.max(0,Math.min(100,Math.round(e.value)));return(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 ${e.className??``}`,children:[(0,G.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,G.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff]`,style:{width:`${t}%`}})}),(0,G.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[t,`%`]})]})}function Ke(e){let t=Math.max(0,Math.min(100,Math.round(e.value)));return(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 ${e.className??``}`,children:[(0,G.jsxs)(`div`,{className:`relative flex h-6 min-w-0 flex-1 items-center`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 h-1.5 overflow-hidden rounded-full bg-stone-100`,"aria-hidden":`true`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-75`,style:{width:`${t}%`}})}),(0,G.jsx)(`input`,{type:`range`,min:0,max:100,value:t,"aria-label":e.ariaLabel??`进度`,onChange:t=>e.onChange(Number(t.target.value)),onMouseUp:t=>e.onCommit?.(Number(t.target.value)),onTouchEnd:t=>e.onCommit?.(Number(t.target.value)),onKeyUp:t=>{(t.key===`ArrowLeft`||t.key===`ArrowRight`||t.key===`Home`||t.key===`End`)&&e.onCommit?.(Number(t.target.value))},className:`tw-life-range relative z-1 w-full`})]}),(0,G.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[t,`%`]})]})}function qe(e){let t=(0,g.useRef)(null);return(0,g.useEffect)(()=>{t.current&&(t.current.indeterminate=!!e.indeterminate&&!e.checked)},[e.checked,e.indeterminate]),(0,G.jsx)(`th`,{className:Pe,"aria-label":`全选`,children:(0,G.jsxs)(`div`,{className:`flex items-center`,children:[e.nested?(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,G.jsx)(`div`,{className:`flex h-7 w-9 items-center justify-center`,children:(0,G.jsx)(`input`,{ref:t,type:`checkbox`,checked:e.checked,onChange:e.onChange,"aria-label":`全选`,className:`h-3.5 w-3.5 rounded border-stone-300 text-[#3370ff] focus:ring-[#3370ff]/30`})})]})})}function Je(e){let t=!!(e.selecting||e.checked),n=(e.depth??0)>0;return(0,G.jsx)(`td`,{className:Ne,children:(0,G.jsxs)(`div`,{className:`flex items-center`,children:[n?(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,G.jsxs)(`div`,{className:`relative flex h-7 w-9 shrink-0 items-center justify-center`,children:[(0,G.jsx)(`span`,{className:`text-xs tabular-nums text-stone-400 transition-opacity ${t?`opacity-0`:`opacity-100 group-hover/row:opacity-0`}`,children:e.index}),(0,G.jsx)(`input`,{type:`checkbox`,checked:e.checked,onChange:e.onChange,"aria-label":e.label,className:`absolute h-3.5 w-3.5 rounded border-stone-300 text-[#3370ff] focus:ring-[#3370ff]/30 transition-opacity ${t?`opacity-100`:`opacity-0 group-hover/row:opacity-100`}`})]})]})})}function Ye(e){return(0,G.jsxs)(f,{open:e.open,onClose:e.onClose,transition:!0,className:`relative z-100`,children:[(0,G.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25 duration-[280ms]`,"aria-hidden":`true`}),(0,G.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,G.jsxs)(u,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl duration-[280ms]`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,G.jsx)(d,{className:`text-base font-semibold text-stone-900`,children:e.title}),(0,G.jsx)(`button`,{type:`button`,onClick:e.onClose,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:e.children}),e.footer?(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-4`,children:e.footer}):null]})})]})}function Xe(e){return(0,G.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":e.label,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700 disabled:opacity-40`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M15 3h6v6`}),(0,G.jsx)(`path`,{d:`M9 21H3v-6`}),(0,G.jsx)(`path`,{d:`M21 3l-7 7`}),(0,G.jsx)(`path`,{d:`M3 21l7-7`})]})})}function Ze(e){return[...e].sort((e,t)=>{let n=e.updatedAt||e.createdAt||``;return(t.updatedAt||t.createdAt||``).localeCompare(n)})}function Qe(e){return[...e].sort((e,t)=>{let n=e.createdAt||``,r=t.createdAt||``;return n===r?String(e.id||``).localeCompare(String(t.id||``)):n.localeCompare(r)})}function $e(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,r)=>{let i=n.get(e.status??``)??t.length,a=n.get(r.status??``)??t.length;if(i!==a)return i-a;let o=e.createdAt||``,s=r.createdAt||``;return o===s?String(e.id||``).localeCompare(String(r.id||``)):o.localeCompare(s)})}function et(e,t){return e.objectives.find(e=>e.id===t)}var tt={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,overdue:`bg-[#fee4e3] text-[#c02a26]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,stalled:`bg-[#fff7d6] text-[#8a6100]`,closed:`bg-stone-100 text-stone-400`},nt={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,overdue:`bg-[#f54a45]`,done:`bg-[#34c724]`,stalled:`bg-[#f7ba1e]`,closed:`bg-stone-300`},rt={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,closed:`bg-stone-100 text-stone-400`},it={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,incomplete:`bg-[#ff8800]`,closed:`bg-stone-300`},at={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,done:`bg-[#d9f5d2] text-[#1d7a12]`},ot={in_progress:`bg-[#3370ff]`,incomplete:`bg-[#ff8800]`,done:`bg-[#34c724]`},st={urgent_important:`bg-[#fee4e3] text-[#c02a26]`,important:`bg-[#fff1e3] text-[#a85b00]`,urgent:`bg-[#fff7d6] text-[#8a6100]`,normal:`bg-stone-100 text-stone-600`,"":`bg-stone-50 text-stone-400`},ct={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},lt={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},Z=[{cell:`bg-[#e1eaff] text-[#1f4ec2]`,pill:`bg-[#3370ff] text-white`},{cell:`bg-[#d9f5d2] text-[#1d7a12]`,pill:`bg-[#34c724] text-white`},{cell:`bg-[#fff1e3] text-[#a85b00]`,pill:`bg-[#ff8800] text-white`},{cell:`bg-[#e0f2fe] text-[#0369a1]`,pill:`bg-[#0ea5e9] text-white`},{cell:`bg-[#fce7f3] text-[#9d174d]`,pill:`bg-[#db2777] text-white`},{cell:`bg-[#ecfdf5] text-[#047857]`,pill:`bg-[#10b981] text-white`},{cell:`bg-[#fff7d6] text-[#8a6100]`,pill:`bg-[#f7ba1e] text-stone-800`},{cell:`bg-[#fee4e3] text-[#c02a26]`,pill:`bg-[#f54a45] text-white`}],ut={cell:`bg-stone-50 text-stone-400`,pill:`bg-stone-300 text-stone-600`};function dt(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return t}function Q(e){return e.trim()?Z[dt(e)%Z.length].cell:ut.cell}function ft(e){return!e.id.trim()||!e.label.trim()||e.label===`—`?(0,G.jsx)(`span`,{className:`text-sm text-stone-300`,children:e.emptyLabel??`—`}):(0,G.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center rounded-md px-2 text-xs font-medium ${Q(e.id)}`,children:(0,G.jsx)(h,{text:e.label,className:`block min-w-0 truncate`})})}var pt=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function $(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,G.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${pt} ${r&&!t?`text-stone-300`:``}`})}function mt(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,g.useState)(!1);return a?(0,G.jsx)($,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex h-8 w-full min-w-0 items-center rounded-md border border-transparent px-1.5 text-left text-sm text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:(0,G.jsx)(h,{text:t||`—`,className:`block min-w-0 truncate ${t?``:`text-stone-300`}`})})}function ht(e){return(0,G.jsx)(m,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function gt(e){return(0,G.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e.label??`正在加载`,children:(0,G.jsx)(`div`,{className:`flex min-h-[240px] flex-1 items-center justify-center`,children:(0,G.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function _t(e){return(0,G.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.children})}function vt(e){return(0,G.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":e.label,className:`tw-icon-danger rounded p-1`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M3 6h18`}),(0,G.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,G.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,G.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})}function yt(e){return(0,G.jsx)(h,{text:e.text,className:`block min-w-0 truncate px-1.5 text-sm ${e.muted?`text-stone-300`:`text-stone-600`}`})}function bt(e){return e.error?(0,G.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,G.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.error}),(0,G.jsx)(`button`,{type:`button`,onClick:e.onDismiss,"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null}export{Te as $,qe as A,Q as B,Me as C,F as Ct,Ge as D,_t as E,ot as F,Qe as G,J as H,Ee as I,we as J,$e as K,je as L,yt as M,$ as N,Ke as O,at as P,xe as Q,q as R,Xe as S,C as St,gt as T,Y as U,be as V,et as W,We as X,Ae as Y,Ce as Z,He as _,_e as _t,nt as a,ie as at,Ye as b,w as bt,Ue as c,M as ct,ct as d,ce as dt,Se as et,De as f,I as ft,ze as g,D as gt,Le as h,W as ht,tt as i,x as it,mt as j,Je as k,st as l,j as lt,Re as m,L as mt,rt as n,se as nt,Fe as o,le as ot,X as p,ve as pt,Ze as q,it as r,v as rt,Ie as s,oe as st,ht as t,y as tt,lt as u,b as ut,ft as v,ge as vt,Ve as w,E as wt,bt as x,S as xt,vt as y,T as yt,ke as z};
3
+ 3) 总结如何下次做得更好`,M={Q1:`Q1(1月-3月)`,Q2:`Q2(4月-6月)`,Q3:`Q3(7月-9月)`,Q4:`Q4(10月-12月)`,"":`—`},N=/^\d{4}-\d{2}-\d{2}$/;function P(e,t=2e3){return typeof e==`string`?e.trim().slice(0,t):``}function F(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function I(e,t){if(!N.test(e)||!N.test(t))return null;let n=Date.parse(`${e}T00:00:00`),r=Date.parse(`${t}T00:00:00`);return!Number.isFinite(n)||!Number.isFinite(r)?null:Math.max(1,Math.round((r-n)/864e5)+1)}function L(e){return e==null?`—`:`${e} 天`}function R(){return{krTodos:[],krTasks:[],objectives:[],reviews:[],yearPlans:[],lifeStages:[],planTypes:[],yearCycles:[],lifeCycles:[]}}function z(e){return Array.isArray(e)?e:[]}function B(e){if(!e||typeof e!=`object`)return null;let t=e,n=P(t.name,40),r=P(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:P(t.createdAt,40),updatedAt:P(t.updatedAt,40)}}function V(e){if(!e||typeof e!=`object`)return null;let t=e,n=P(t.name,40),r=P(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:P(t.createdAt,40),updatedAt:P(t.updatedAt,40)}}function H(e){if(!e||typeof e!=`object`)return null;let t=e,n=P(t.name,60),r=P(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:P(t.createdAt,40),updatedAt:P(t.updatedAt,40)}}function U(e){if(!e||typeof e!=`object`)return R();let t=e,n=z(t.planTypes).map(B).filter(e=>!!e),r=new Set(n.map(e=>e.id)),i=z(t.yearCycles).map(V).filter(e=>!!e),a=z(t.lifeCycles).map(H).filter(e=>!!e),o=e=>({...e,planType:A(e.planType,r)}),s=e=>({...e,yearCycle:O(e.yearCycle,i)}),c=e=>{let t=e.lifeCycle||e.ageRange,{ageRange:n,...r}=e;return{...r,lifeCycle:k(t,a)}},l=z(t.yearPlans).map(o).map(s),u=new Set(l.map(e=>e.id)),d=z(t.objectives).map(s).map(e=>{let t=P(e.yearPlanId,64);return{...e,yearPlanId:t&&u.has(t)?t:``}});return{krTodos:z(t.krTodos),krTasks:z(t.krTasks).map(o),objectives:d,reviews:z(t.reviews),yearPlans:l,lifeStages:z(t.lifeStages).map(o).map(c),planTypes:n,yearCycles:i,lifeCycles:a}}async function de(){let e=await fetch(_,{headers:{Accept:`application/json`}}),t=await e.json().catch(()=>({}));if(!e.ok||!t?.ok)throw Error(P(t?.error)||`读取失败(${e.status})`);return U(t)}async function fe(){let e=await(await fetch(`${_}?health=1`,{headers:{Accept:`application/json`}})).json().catch(()=>({}));return{ok:!!e?.ok,files:e?.files}}async function pe(e,t){let n=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,items:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r?.ok)throw Error(P(r?.error)||`创建失败(${n.status})`);return{items:z(r.items),total:Number(r.total)||0}}async function me(e,t,n){let r=await fetch(_,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,id:t,...n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i?.ok)throw Error(P(i?.error)||`更新失败(${r.status})`);return i.item}async function he(e,t){let n=await fetch(_,{method:`DELETE`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,ids:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r?.ok)throw Error(P(r?.error)||`删除失败(${n.status})`);return{removed:Number(r.removed)||0,total:Number(r.total)||0}}function W(e,t){let n=t.filter(t=>t.krTaskId===e),r=n.filter(e=>e.status===`done`).length,i=n.length,a=i===0?0:Math.round(r/i*100),o=n.map(e=>e.title),s=new Map;for(let e of n)s.set(e.status,(s.get(e.status)??0)+1);return{count:i,done:r,progress:a,titles:o,summary:i===0?`暂无待办`:[...s.entries()].map(([e,t])=>`${x[e]??e} ${t}`).join(` · `)}}function ge(e,t,n){let r=t.filter(t=>t.objectiveId===e);if(!r.length)return 0;let i=r.reduce((e,t)=>e+W(t.id,n).progress,0);return Math.round(i/r.length)}function _e(e,t){return t.filter(t=>t.objectiveId===e).map(e=>e.title)}function ve(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.title.toLowerCase().includes(n)||(e.note??``).toLowerCase().includes(n)):e}var G=s(),ye=8e3;function be(){return l(`life`)}function xe(){let[e,t]=(0,g.useState)(!1),[n,r]=(0,g.useState)(()=>u(`life`));return(0,g.useEffect)(()=>{let e=!0,n=c(()=>r(u(`life`)));return o().then(()=>{e&&(r(u(`life`)),t(!0))}),()=>{e=!1,n()}},[]),{ready:e,on:n}}function Se(e){let[t,n]=(0,g.useState)(R),[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 de();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)}},[]),d=(0,g.useCallback)(async(e,t)=>{let n=await pe(e,t);return await u(!0),n},[u]),f=(0,g.useCallback)(async(e,t,n)=>{await me(e,t,n),await u(!0)},[u]),p=(0,g.useCallback)(async(e,t)=>{await he(e,t),await u(!0)},[u]);return(0,g.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{try{let e=await fe();if(!l.current)return;if(!e.ok){i(!1),o(!1);return}if(await u(),!l.current)return;i(!0),t=window.setInterval(()=>void u(!0),ye)}catch{if(!l.current)return;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,createItems:d,updateItem:f,deleteItems:p}}function Ce(e){let[t,n]=(0,g.useState)(()=>p(e));return[t,(0,g.useCallback)(t=>{n(t),ee(e,t)},[e])]}function we(e,t,n){let[r,i]=(0,g.useState)(()=>d(e,t,n));return[r,(0,g.useCallback)(t=>{i(t),f(e,t)},[e])]}function Te(e){let[t,n]=(0,g.useState)({}),r=(0,g.useMemo)(()=>new Set(e),[e]);(0,g.useEffect)(()=>{n(e=>{let t=!1,n={};for(let[i,a]of Object.entries(e))r.has(i)&&a?n[i]=!0:a&&(t=!0);return t||Object.keys(n).length!==Object.keys(e).length?n:e})},[r]);let i=(0,g.useMemo)(()=>Object.keys(t).filter(e=>t[e]),[t]),a=e.length>0&&e.every(e=>t[e]);function o(e){n(t=>({...t,[e]:!t[e]}))}function s(){n(t=>{let n={...t},r=!a;for(let t of e)n[t]=r;return n})}function c(){n({})}return{selected:t,selectedIds:i,allVisibleSelected:a,toggle:o,toggleAllVisible:s,clear:c}}function K(e){return e.items?e.items.length:(e.children??[]).reduce((e,t)=>e+K(t),0)}function q(e,t){let n=[],r=(e,i)=>{for(let a of e){let e=!!a.children?.length,o=K(a);if(o===0&&e||o===0&&a.items===void 0)continue;let s=!t[a.key];n.push({key:a.key,label:a.label,pill:a.pill,depth:i,count:o,kind:e?`section`:`tag`,items:e||!s?void 0:a.items??[]}),s&&e&&r(a.children,i+1)}};return r(e,0),n}function Ee(e,t){return q(e,t).flatMap(e=>e.items?e.items.map(e=>e.id):[])}function J(e=!1){return 36+(e?28:0)}function Y(e=!1){return{"--tw-sticky-left":`${J(e)}px`}}Y(!1);var De=`relative px-2 py-2 text-left text-xs font-medium whitespace-nowrap text-stone-500`,X=`relative border-l border-stone-200/90 px-2 py-2 text-left text-xs font-medium whitespace-nowrap text-stone-500`,Oe=new Set([`select`,`title`,`filler`,`action`]);function ke(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 Ae(e,t){return ne(e,t,Oe)}function je(e,t){return te(e,t)}function Me(e){return(0,G.jsx)(re,{...e})}var Ne=`tw-sticky-l px-0 py-1 align-middle`,Pe=`tw-sticky-l px-0 py-2 text-left font-medium whitespace-nowrap`,Fe=`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-[#4176e6]/30`,Ie=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,Le=`未选择`,Re=`未关联`,ze=`未设置年度`;function Be(e){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform duration-200 ease-out ${e.open?`rotate-0`:`-rotate-90`}`,children:(0,G.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}function Ve(e){let t=(e.depth??0)>0,n=e.selectColPx??36;e.kind;let r=(0,G.jsx)(`span`,{className:`max-w-[min(100%,16rem)] truncate rounded-full px-2.5 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),i=(0,G.jsxs)(`span`,{className:`shrink-0 text-xs text-stone-400 tabular-nums`,children:[e.count,` 条记录`]}),a=(0,G.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center`,children:(0,G.jsx)(Be,{open:e.open})});if(!t){let t=Math.max(0,e.colSpan-2);return(0,G.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":e.open,"aria-label":e.open?`收起分组`:`展开分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`${n}px`},onClick:e.onToggle,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onToggle())},children:[(0,G.jsx)(`td`,{colSpan:2,className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 pb-1.5 pt-3 align-middle`,style:{left:0,"--tw-sticky-left":`0px`},children:(0,G.jsxs)(`div`,{className:`flex w-full items-center gap-2 py-1.5 pr-2 text-left`,children:[a,r,i]})}),t>0?(0,G.jsx)(`td`,{colSpan:t,className:`border-b border-stone-100 bg-white pb-1.5 pt-3`,"aria-hidden":`true`}):null]})}let o=Math.max(0,e.colSpan-2);return(0,G.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":e.open,"aria-label":e.open?`收起分组`:`展开分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`${n}px`},onClick:e.onToggle,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onToggle())},children:[(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 py-0.5 align-middle`,style:{left:0,width:n,minWidth:n,maxWidth:n,"--tw-sticky-left":`0px`},children:(0,G.jsxs)(`div`,{className:`flex w-full items-center py-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}),a]})}),(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-label border-b border-stone-100 px-2 py-0.5 align-middle`,style:{left:n,"--tw-sticky-left":`${n}px`},children:(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 py-1.5 text-left`,children:[r,i]})}),o>0?(0,G.jsx)(`td`,{colSpan:o,className:`border-b border-stone-100 bg-white py-0.5`,"aria-hidden":`true`}):null]})}function He(e){let t=(e.depth??0)>0,n=e.selectColPx??36,r=Math.max(0,e.colSpan-2);return(0,G.jsxs)(`tr`,{className:`tw-life-group-body`,style:{"--life-select-w":`${n}px`},children:[(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-lead px-0 py-0.5 align-middle`,style:{left:0,width:n,minWidth:n,maxWidth:n,"--tw-sticky-left":`0px`},children:(0,G.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":`新增记录`,className:`flex w-full items-center py-0.5 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[t?(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,G.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center text-sm leading-none`,children:`+`})]})}),(0,G.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-label px-2 py-0.5 align-middle`,style:{left:n,"--tw-sticky-left":`${n}px`},children:(0,G.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,className:`rounded py-0.5 text-xs text-stone-400 transition-colors hover:text-stone-600 disabled:opacity-40`,children:`新增记录`})}),r>0?(0,G.jsx)(`td`,{colSpan:r,className:`bg-white py-0.5`,"aria-hidden":`true`}):null]})}var Ue=`h-8 w-full truncate rounded-md border border-[#4176e6]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#4176e6] disabled:opacity-50`;function We(e){let t=(0,g.useRef)(e.row);t.current=e.row;let n=(0,g.useRef)(e.submitting);n.current=e.submitting;let r=(0,g.useRef)(e.onSubmit);r.current=e.onSubmit;let i=(0,g.useRef)(e.isPristine);i.current=e.isPristine;let a=(0,g.useRef)(e.setRow);a.current=e.setRow;let o=(0,g.useCallback)(async()=>{let e=t.current;if(!e||n.current)return;let i=e.title.trim();i&&await r.current({...e,title:i})},[]);return(0,g.useEffect)(()=>{if(e.row==null)return;let n=e=>{let n=e.target;if(!(n instanceof Element)||n.closest(`.tw-new-row`)||n.closest(`.tw-select-menu`)||n.closest(`.tw-date-panel`)||n.closest(`.tw-confirm-dialog`)||n.closest(`[data-headlessui-portal]`))return;let r=t.current;r&&(r.title.trim()?o():i.current(r)&&a.current(null))};return document.addEventListener(`pointerdown`,n,!0),()=>document.removeEventListener(`pointerdown`,n,!0)},[e.row,o]),{submit:o}}function Ge(e){let t=Math.max(0,Math.min(100,Math.round(e.value)));return(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 ${e.className??``}`,children:[(0,G.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,G.jsx)(`span`,{className:`block h-full rounded-full bg-[#4176e6]`,style:{width:`${t}%`}})}),(0,G.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[t,`%`]})]})}function Ke(e){let t=Math.max(0,Math.min(100,Math.round(e.value)));return(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 ${e.className??``}`,children:[(0,G.jsxs)(`div`,{className:`relative flex h-6 min-w-0 flex-1 items-center`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 h-1.5 overflow-hidden rounded-full bg-stone-100`,"aria-hidden":`true`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-[#4176e6] transition-[width] duration-75`,style:{width:`${t}%`}})}),(0,G.jsx)(`input`,{type:`range`,min:0,max:100,value:t,"aria-label":e.ariaLabel??`进度`,onChange:t=>e.onChange(Number(t.target.value)),onMouseUp:t=>e.onCommit?.(Number(t.target.value)),onTouchEnd:t=>e.onCommit?.(Number(t.target.value)),onKeyUp:t=>{(t.key===`ArrowLeft`||t.key===`ArrowRight`||t.key===`Home`||t.key===`End`)&&e.onCommit?.(Number(t.target.value))},className:`tw-life-range relative z-1 w-full`})]}),(0,G.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[t,`%`]})]})}function qe(e){let t=(0,g.useRef)(null);return(0,g.useEffect)(()=>{t.current&&(t.current.indeterminate=!!e.indeterminate&&!e.checked)},[e.checked,e.indeterminate]),(0,G.jsx)(`th`,{className:Pe,"aria-label":`全选`,children:(0,G.jsxs)(`div`,{className:`flex items-center`,children:[e.nested?(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,G.jsx)(`div`,{className:`flex h-7 w-9 items-center justify-center`,children:(0,G.jsx)(`input`,{ref:t,type:`checkbox`,checked:e.checked,onChange:e.onChange,"aria-label":`全选`,className:`h-3.5 w-3.5 rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/30`})})]})})}function Je(e){let t=!!(e.selecting||e.checked),n=(e.depth??0)>0;return(0,G.jsx)(`td`,{className:Ne,children:(0,G.jsxs)(`div`,{className:`flex items-center`,children:[n?(0,G.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,G.jsxs)(`div`,{className:`relative flex h-7 w-9 shrink-0 items-center justify-center`,children:[(0,G.jsx)(`span`,{className:`text-xs tabular-nums text-stone-400 transition-opacity ${t?`opacity-0`:`opacity-100 group-hover/row:opacity-0`}`,children:e.index}),(0,G.jsx)(`input`,{type:`checkbox`,checked:e.checked,onChange:e.onChange,"aria-label":e.label,className:`absolute h-3.5 w-3.5 rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/30 transition-opacity ${t?`opacity-100`:`opacity-0 group-hover/row:opacity-100`}`})]})]})})}function Ye(e){return(0,G.jsxs)(i,{open:e.open,onClose:e.onClose,transition:!0,className:`relative z-100`,children:[(0,G.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25 duration-[280ms]`,"aria-hidden":`true`}),(0,G.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,G.jsxs)(n,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl duration-[280ms]`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,G.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:e.title}),(0,G.jsx)(`button`,{type:`button`,onClick:e.onClose,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:e.children}),e.footer?(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-4`,children:e.footer}):null]})})]})}function Xe(e){return(0,G.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":e.label,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700 disabled:opacity-40`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M15 3h6v6`}),(0,G.jsx)(`path`,{d:`M9 21H3v-6`}),(0,G.jsx)(`path`,{d:`M21 3l-7 7`}),(0,G.jsx)(`path`,{d:`M3 21l7-7`})]})})}function Ze(e){return[...e].sort((e,t)=>{let n=e.updatedAt||e.createdAt||``;return(t.updatedAt||t.createdAt||``).localeCompare(n)})}function Qe(e){return[...e].sort((e,t)=>{let n=e.createdAt||``,r=t.createdAt||``;return n===r?String(e.id||``).localeCompare(String(t.id||``)):n.localeCompare(r)})}function $e(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,r)=>{let i=n.get(e.status??``)??t.length,a=n.get(r.status??``)??t.length;if(i!==a)return i-a;let o=e.createdAt||``,s=r.createdAt||``;return o===s?String(e.id||``).localeCompare(String(r.id||``)):o.localeCompare(s)})}function et(e,t){return e.objectives.find(e=>e.id===t)}var tt={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,overdue:`bg-[#fee4e3] text-[#c02a26]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,stalled:`bg-[#fff7d6] text-[#8a6100]`,closed:`bg-stone-100 text-stone-400`},nt={pending:`bg-stone-400`,in_progress:`bg-[#4176e6]`,overdue:`bg-[#f54a45]`,done:`bg-[#34c724]`,stalled:`bg-[#f7ba1e]`,closed:`bg-stone-300`},rt={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,closed:`bg-stone-100 text-stone-400`},it={pool:`bg-stone-400`,in_progress:`bg-[#4176e6]`,done:`bg-[#34c724]`,incomplete:`bg-[#ff8800]`,closed:`bg-stone-300`},at={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,done:`bg-[#d9f5d2] text-[#1d7a12]`},ot={in_progress:`bg-[#4176e6]`,incomplete:`bg-[#ff8800]`,done:`bg-[#34c724]`},st={urgent_important:`bg-[#fee4e3] text-[#c02a26]`,important:`bg-[#fff1e3] text-[#a85b00]`,urgent:`bg-[#fff7d6] text-[#8a6100]`,normal:`bg-stone-100 text-stone-600`,"":`bg-stone-50 text-stone-400`},ct={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},lt={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},Z=[{cell:`bg-[#e1eaff] text-[#1f4ec2]`,pill:`bg-[#4176e6] text-white`},{cell:`bg-[#d9f5d2] text-[#1d7a12]`,pill:`bg-[#34c724] text-white`},{cell:`bg-[#fff1e3] text-[#a85b00]`,pill:`bg-[#ff8800] text-white`},{cell:`bg-[#e0f2fe] text-[#0369a1]`,pill:`bg-[#0ea5e9] text-white`},{cell:`bg-[#fce7f3] text-[#9d174d]`,pill:`bg-[#db2777] text-white`},{cell:`bg-[#ecfdf5] text-[#047857]`,pill:`bg-[#10b981] text-white`},{cell:`bg-[#fff7d6] text-[#8a6100]`,pill:`bg-[#f7ba1e] text-stone-800`},{cell:`bg-[#fee4e3] text-[#c02a26]`,pill:`bg-[#f54a45] text-white`}],ut={cell:`bg-stone-50 text-stone-400`,pill:`bg-stone-300 text-stone-600`};function dt(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return t}function Q(e){return e.trim()?Z[dt(e)%Z.length].cell:ut.cell}function ft(e){return!e.id.trim()||!e.label.trim()||e.label===`—`?(0,G.jsx)(`span`,{className:`text-sm text-stone-300`,children:e.emptyLabel??`—`}):(0,G.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center rounded-md px-2 text-xs font-medium ${Q(e.id)}`,children:(0,G.jsx)(m,{text:e.label,className:`block min-w-0 truncate`})})}var pt=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white placeholder:text-stone-300`;function $(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,G.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${pt} ${r&&!t?`text-stone-300`:``}`})}function mt(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,g.useState)(!1);return a?(0,G.jsx)($,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex h-8 w-full min-w-0 items-center rounded-md border border-transparent px-1.5 text-left text-sm text-stone-700 transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:outline-none`,children:(0,G.jsx)(m,{text:t||`—`,className:`block min-w-0 truncate ${t?``:`text-stone-300`}`})})}function ht(e){return(0,G.jsx)(h,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#4176e6] focus:bg-white`})}function gt(e){return(0,G.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e.label??`正在加载`,children:(0,G.jsx)(`div`,{className:`flex min-h-[240px] flex-1 items-center justify-center`,children:(0,G.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function _t(e){return(0,G.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.children})}function vt(e){return(0,G.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":e.label,className:`tw-icon-danger rounded p-1`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M3 6h18`}),(0,G.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,G.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,G.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})}function yt(e){return(0,G.jsx)(m,{text:e.text,className:`block min-w-0 truncate px-1.5 text-sm ${e.muted?`text-stone-300`:`text-stone-600`}`})}function bt(e){return e.error?(0,G.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,G.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.error}),(0,G.jsx)(`button`,{type:`button`,onClick:e.onDismiss,"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null}export{Te as $,qe as A,Q as B,Me as C,F as Ct,Ge as D,_t as E,ot as F,Qe as G,J as H,Ee as I,we as J,$e as K,je as L,yt as M,$ as N,Ke as O,at as P,xe as Q,q as R,Xe as S,C as St,gt as T,Y as U,be as V,et as W,We as X,Ae as Y,Ce as Z,He as _,_e as _t,nt as a,ie as at,Ye as b,w as bt,Ue as c,M as ct,ct as d,ce as dt,Se as et,De as f,I as ft,ze as g,D as gt,Le as h,W as ht,tt as i,x as it,mt as j,Je as k,st as l,j as lt,Re as m,L as mt,rt as n,se as nt,Fe as o,le as ot,X as p,ve as pt,Ze as q,it as r,v as rt,Ie as s,oe as st,ht as t,y as tt,lt as u,b as ut,ft as v,ge as vt,Ve as w,E as wt,bt as x,S as xt,vt as y,T as yt,ke as z};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{n as i,t as ee}from"./SelectDropdown.D7IeyHDI.js";import{m as a}from"./PmShared.BQVzwsiz.js";import{showToast as o}from"./Toast.BydY-X7T.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.KPCeXmri.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.bY2l01Ha.js";import{c as N,l as P,n as F,t as I}from"./DrawerField.CLdvmHc6.js";import{t as ye}from"./LifePlanTypeSelect.Cm2lUmnH.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-[#4176e6]/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-[#4176e6] px-4 text-sm font-medium text-white hover:bg-[#3566d0] 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-[#4176e6]`}),(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-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] 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};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.DQFd6g2r.js";import{n as i,t as a}from"./SelectDropdown.D7IeyHDI.js";import{m as o}from"./PmShared.BQVzwsiz.js";import{showToast as s}from"./Toast.BydY-X7T.js";import{t as c}from"./NamePromptDialog.KPCeXmri.js";import{B as l,St as u,h as d,wt as f}from"./LifeShared.bY2l01Ha.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-[#4176e6]/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};
@@ -0,0 +1 @@
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.DQFd6g2r.js";import{n as a,t as o}from"./SelectDropdown.D7IeyHDI.js";import{showToast as s}from"./Toast.BydY-X7T.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.bY2l01Ha.js";import{c as E,l as D,n as O,r as k,s as A,t as j}from"./DrawerField.CLdvmHc6.js";import{t as M}from"./LifePlanTypeSelect.Cm2lUmnH.js";import{t as Te}from"./LifeYearCycleSelect.BlsyPmmI.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-[#4176e6]/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-[#4176e6] px-4 text-sm font-medium text-white hover:bg-[#3566d0] 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-[#4176e6]/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-[#4176e6]/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-[#4176e6]`}),(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-[#4176e6] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#3566d0] 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};
@@ -0,0 +1 @@
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{n as i}from"./SelectDropdown.D7IeyHDI.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=`搜索…`,renderOptionAction:m,triggerClassName:h=``}){let[g,_]=(0,a.useState)(!1),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)({left:0,top:0,width:220,openUp:!1}),S=(0,a.useRef)(null),C=(0,a.useRef)(null),w=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!g){y(``);return}function e(e){let t=e.target;S.current?.contains(t)||C.current?.contains(t)||_(!1)}function t(e){e.target instanceof Node&&C.current?.contains(e.target)||_(!1)}function n(){_(!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)}},[g]),(0,a.useEffect)(()=>{if(!g||!f)return;let e=window.setTimeout(()=>w.current?.focus(),0);return()=>window.clearTimeout(e)},[g,f]);let T=(0,a.useMemo)(()=>e.filter(e=>t.includes(e.value)),[e,t]),E=T.map(e=>e.label),D=c||E.length===0?r:E.length<=2?E.join(`、`):`已选 ${E.length} 项`,O=(0,a.useMemo)(()=>{let t=v.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,v]);function k(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}function A(e,r){r.stopPropagation(),n(t.filter(t=>t!==e))}function j(){if(c)return;if(g){_(!1);return}let e=S.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;x({left:r,top:a?t.top-4:i,width:n,openUp:a}),_(!0)}let M=u?`items-start`:`items-center`,N=`${c?`w-full min-h-9 flex ${M} 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 ${M} 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`} ${h}`,P=null;return g&&typeof document<`u`&&(P=(0,o.createPortal)((0,s.jsxs)(`div`,{ref:C,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:b.left,width:b.width,...b.openUp?{bottom:window.innerHeight-b.top}:{top:b.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:w,type:`text`,value:v,onChange:e=>y(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,O.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:O.map(e=>{let n=t.includes(e.value);return l?(0,s.jsxs)(`div`,{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.jsxs)(`button`,{type:`button`,onClick:()=>k(e.value),className:`flex min-w-0 flex-1 items-start gap-2 text-left`,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-[#4176e6]`,"aria-hidden":!0,children:`✓`}):null]}),m?(0,s.jsx)(`span`,{className:`flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:m(e)}):null]},e.value):(0,s.jsxs)(`div`,{className:`flex 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.jsxs)(`label`,{className:`flex min-w-0 flex-1 cursor-pointer gap-2 ${u?`items-start`:`items-center`}`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>k(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`})]}),m?(0,s.jsx)(`span`,{className:`flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:m(e)}):null]},e.value)})})]}),document.body)),(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`button`,{ref:S,type:`button`,disabled:c,"aria-expanded":g,onClick:j,className:N,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:T.length===0?(0,s.jsx)(`span`,{className:`text-stone-400`,children:r}):T.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=>A(e.value,t),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),A(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:T.length===0?(0,s.jsx)(`span`,{className:`text-stone-400`,children:r}):T.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:D,className:`block min-w-0 flex-1 truncate ${c||E.length?``:`text-stone-400`}`})}),P]})}export{c as t};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./dialog.DZHZCe_T.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";var s=e(t(),1),c=o();function l({open:e,title:t=`新建文件夹`,label:o=`文件夹名称`,placeholder:l=`请输入名称`,initialValue:u=``,lockExtension:d=!1,confirmLabel:f=`创建`,cancelLabel:p=`取消`,error:m=``,onClose:h,onConfirm:g}){let[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(``),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){let e=u,t=``;if(d){let n=u.lastIndexOf(`.`);n>0&&(e=u.slice(0,n),t=u.slice(n))}v(e),b(t);let n=window.setTimeout(()=>{x.current?.focus(),x.current?.select()},50);return()=>window.clearTimeout(n)}},[e,u,d]);function S(){let e=_.trim();e&&g(e+y)}return(0,c.jsxs)(i,{open:e,onClose:h,className:`relative z-110`,children:[(0,c.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,c.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,c.jsxs)(n,{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,c.jsx)(r,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t}),(0,c.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[o,(0,c.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-0 rounded-lg border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6] transition-colors`,children:[(0,c.jsx)(`input`,{ref:x,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},placeholder:l,className:`flex-1 min-w-0 h-9 px-3 text-sm rounded-lg border-0 bg-transparent text-stone-800 outline-none`}),y?(0,c.jsx)(`span`,{className:`shrink-0 pr-3 text-sm text-stone-400 select-none`,children:y}):null]}),m?(0,c.jsx)(`span`,{className:`mt-1.5 block text-[11px] font-normal leading-relaxed text-red-600`,children:m}):null]}),(0,c.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:h,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg text-stone-600 hover:bg-stone-100 transition-colors`,children:p}),(0,c.jsx)(`button`,{type:`button`,disabled:!_.trim(),onClick:S,className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:f})]})]})})]})}export{l as t};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";var s=e(t(),1),c=o();function l({open:e,title:t=`新建文件夹`,label:o=`文件夹名称`,placeholder:l=`请输入名称`,initialValue:u=``,lockExtension:d=!1,confirmLabel:f=`创建`,cancelLabel:p=`取消`,error:m=``,onClose:h,onConfirm:g}){let[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(``),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){let e=u,t=``;if(d){let n=u.lastIndexOf(`.`);n>0&&(e=u.slice(0,n),t=u.slice(n))}v(e),b(t);let n=window.setTimeout(()=>{x.current?.focus(),x.current?.select()},50);return()=>window.clearTimeout(n)}},[e,u,d]);function S(){let e=_.trim();e&&g(e+y)}return(0,c.jsxs)(i,{open:e,onClose:h,className:`relative z-110`,children:[(0,c.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,c.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,c.jsxs)(n,{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,c.jsx)(r,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t}),(0,c.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[o,(0,c.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-0 rounded-lg border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6] transition-colors`,children:[(0,c.jsx)(`input`,{ref:x,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},placeholder:l,className:`flex-1 min-w-0 h-9 px-3 text-sm rounded-lg border-0 bg-transparent text-stone-800 outline-none`}),y?(0,c.jsx)(`span`,{className:`shrink-0 pr-3 text-sm text-stone-400 select-none`,children:y}):null]}),m?(0,c.jsx)(`span`,{className:`mt-1.5 block text-[11px] font-normal leading-relaxed text-red-600`,children:m}):null]}),(0,c.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:h,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg text-stone-600 hover:bg-stone-100 transition-colors`,children:p}),(0,c.jsx)(`button`,{type:`button`,disabled:!_.trim(),onClick:S,className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:f})]})]})})]})}export{l as t};