soma-kit 0.0.0-stage → 0.1.1

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 (352) hide show
  1. package/README.md +541 -2
  2. package/bin/soma-kit.mjs +27 -0
  3. package/package.json +66 -4
  4. package/packs/ai/agent-run-card.ts +64 -0
  5. package/packs/ai/evaluation-card.ts +51 -0
  6. package/packs/ai/guardrail-policy-card.ts +48 -0
  7. package/packs/ai/index.ts +31 -0
  8. package/packs/ai/model-card.ts +55 -0
  9. package/packs/ai/model-routing-card.ts +49 -0
  10. package/packs/ai/prompt-template-card.ts +49 -0
  11. package/packs/ai/texts.ts +19 -0
  12. package/packs/commerce/address-card.ts +58 -0
  13. package/packs/commerce/coupon-card.ts +64 -0
  14. package/packs/commerce/index.ts +25 -0
  15. package/packs/commerce/order-card.ts +60 -0
  16. package/packs/commerce/purchase-order-card.ts +74 -0
  17. package/packs/commerce/texts.ts +14 -0
  18. package/packs/finance/index.ts +30 -0
  19. package/packs/finance/invoice-summary-card.ts +48 -0
  20. package/packs/finance/reconcile-board.ts +450 -0
  21. package/packs/finance/reconcile-case-card.ts +70 -0
  22. package/packs/finance/reconcile-desk/compile.ts +208 -0
  23. package/packs/finance/reconcile-desk/index.ts +20 -0
  24. package/packs/finance/reconcile-desk/shell.ts +27 -0
  25. package/packs/finance/texts.ts +21 -0
  26. package/packs/ops/change-window-card.ts +54 -0
  27. package/packs/ops/dependency-status-card.ts +50 -0
  28. package/packs/ops/error-budget-card.ts +60 -0
  29. package/packs/ops/execution-task-runner.ts +61 -0
  30. package/packs/ops/index.ts +36 -0
  31. package/packs/ops/integration-status-card.ts +45 -0
  32. package/packs/ops/release-readiness-card.ts +63 -0
  33. package/packs/ops/runbook-execution-card.ts +81 -0
  34. package/packs/ops/texts.ts +21 -0
  35. package/packs/security/control-evidence-card.ts +54 -0
  36. package/packs/security/finding-card.ts +96 -0
  37. package/packs/security/index.ts +29 -0
  38. package/packs/security/texts.ts +31 -0
  39. package/packs/shared/card-util.ts +60 -0
  40. package/packs/shared/wrap.ts +12 -0
  41. package/spec/generated/kit-app.schema.json +84 -0
  42. package/spec/generated/kit-page.schema.json +2766 -0
  43. package/spec/kit-grammar.json +1357 -0
  44. package/spec/kit-grammar.schema.json +715 -0
  45. package/src/app/app-config.ts +108 -0
  46. package/src/app/compose-apps.ts +155 -0
  47. package/src/app/define-kit-actions.ts +89 -0
  48. package/src/app/define-kit-app.ts +383 -0
  49. package/src/app/define-kit-pack.ts +114 -0
  50. package/src/app/envelope.ts +138 -0
  51. package/src/app/index.ts +53 -0
  52. package/src/app/notify-renderer.ts +114 -0
  53. package/src/app/paged-list-adapter.ts +240 -0
  54. package/src/app/server-pages.ts +303 -0
  55. package/src/app/server.ts +244 -0
  56. package/src/app/submit.types.ts +87 -0
  57. package/src/base/action-busy.ts +159 -0
  58. package/src/base/action-gate.ts +267 -0
  59. package/src/base/action-status.ts +31 -0
  60. package/src/base/alert.ts +136 -0
  61. package/src/base/avatar.ts +271 -0
  62. package/src/base/button.ts +139 -0
  63. package/src/base/cascader.ts +523 -0
  64. package/src/base/check-core.ts +214 -0
  65. package/src/base/checkbox.ts +35 -0
  66. package/src/base/choice.ts +183 -0
  67. package/src/base/color-picker.ts +316 -0
  68. package/src/base/combobox.ts +61 -0
  69. package/src/base/command-palette.ts +371 -0
  70. package/src/base/context-menu.ts +103 -0
  71. package/src/base/countdown.ts +168 -0
  72. package/src/base/date-range.ts +444 -0
  73. package/src/base/date.ts +899 -0
  74. package/src/base/divider.ts +156 -0
  75. package/src/base/fab.ts +192 -0
  76. package/src/base/icons.ts +106 -0
  77. package/src/base/image.ts +177 -0
  78. package/src/base/index.ts +214 -0
  79. package/src/base/input.ts +316 -0
  80. package/src/base/kbd.ts +99 -0
  81. package/src/base/link.ts +167 -0
  82. package/src/base/listbox-core.ts +965 -0
  83. package/src/base/mentions.ts +323 -0
  84. package/src/base/menu-button.ts +240 -0
  85. package/src/base/menu-core.ts +341 -0
  86. package/src/base/month-grid.ts +171 -0
  87. package/src/base/motion/aura.ts +94 -0
  88. package/src/base/motion/hover-3d.ts +154 -0
  89. package/src/base/motion/hover-gallery.ts +185 -0
  90. package/src/base/motion/index.ts +27 -0
  91. package/src/base/motion/limits.ts +75 -0
  92. package/src/base/motion/marquee.ts +157 -0
  93. package/src/base/motion/text-rotate.ts +195 -0
  94. package/src/base/number.ts +121 -0
  95. package/src/base/otp.ts +259 -0
  96. package/src/base/permission-gate.ts +99 -0
  97. package/src/base/popover.ts +352 -0
  98. package/src/base/popup.ts +542 -0
  99. package/src/base/portal-core.ts +297 -0
  100. package/src/base/price-text.ts +126 -0
  101. package/src/base/progress.ts +216 -0
  102. package/src/base/qr-code.ts +446 -0
  103. package/src/base/qty-stepper.ts +241 -0
  104. package/src/base/radio.ts +33 -0
  105. package/src/base/range.ts +444 -0
  106. package/src/base/rating.ts +249 -0
  107. package/src/base/segmented.ts +286 -0
  108. package/src/base/select.ts +57 -0
  109. package/src/base/shared.ts +708 -0
  110. package/src/base/swap.ts +86 -0
  111. package/src/base/switch.ts +111 -0
  112. package/src/base/tag-input.ts +464 -0
  113. package/src/base/tag.ts +250 -0
  114. package/src/base/text.ts +126 -0
  115. package/src/base/textarea.ts +129 -0
  116. package/src/base/time-picker.ts +606 -0
  117. package/src/base/tree-select.ts +629 -0
  118. package/src/base/upload.ts +548 -0
  119. package/src/base/virtual-list.ts +286 -0
  120. package/src/biz/approval-desk/compile.ts +179 -0
  121. package/src/biz/approval-desk/index.ts +21 -0
  122. package/src/biz/approval-desk/shell.ts +50 -0
  123. package/src/biz/auth-panel/compile.ts +196 -0
  124. package/src/biz/auth-panel/index.ts +24 -0
  125. package/src/biz/auth-panel/shell.ts +46 -0
  126. package/src/biz/category-crud/compile.ts +173 -0
  127. package/src/biz/category-crud/index.ts +19 -0
  128. package/src/biz/category-crud/shell.ts +29 -0
  129. package/src/biz/checkout-page/compile.ts +111 -0
  130. package/src/biz/checkout-page/index.ts +20 -0
  131. package/src/biz/checkout-page/shell.ts +50 -0
  132. package/src/biz/compose.ts +313 -0
  133. package/src/biz/data-components.ts +26 -0
  134. package/src/biz/define.ts +23 -0
  135. package/src/biz/import-wizard/compile.ts +204 -0
  136. package/src/biz/import-wizard/hub.ts +540 -0
  137. package/src/biz/import-wizard/index.ts +24 -0
  138. package/src/biz/import-wizard/shell.ts +161 -0
  139. package/src/biz/index.ts +80 -0
  140. package/src/biz/landing-page/compile.ts +67 -0
  141. package/src/biz/landing-page/index.ts +20 -0
  142. package/src/biz/landing-page/shell.ts +48 -0
  143. package/src/biz/link/hub.ts +255 -0
  144. package/src/biz/link/shared.ts +493 -0
  145. package/src/biz/master-sub/compile.ts +232 -0
  146. package/src/biz/master-sub/index.ts +20 -0
  147. package/src/biz/master-sub/shell.ts +56 -0
  148. package/src/biz/multi-board/compile.ts +234 -0
  149. package/src/biz/multi-board/index.ts +19 -0
  150. package/src/biz/multi-board/shell.ts +70 -0
  151. package/src/biz/names.ts +30 -0
  152. package/src/biz/notification-center/compile.ts +138 -0
  153. package/src/biz/notification-center/index.ts +29 -0
  154. package/src/biz/notification-center/shell.ts +42 -0
  155. package/src/biz/page-templates/result-page/compile.ts +46 -0
  156. package/src/biz/page-templates/result-page/index.ts +19 -0
  157. package/src/biz/page-templates/result-page/shell.ts +31 -0
  158. package/src/biz/page-templates/shared.ts +121 -0
  159. package/src/biz/page-templates/sign-in-page/compile.ts +176 -0
  160. package/src/biz/page-templates/sign-in-page/index.ts +18 -0
  161. package/src/biz/page-templates/sign-in-page/shell.ts +116 -0
  162. package/src/biz/record-detail/compile.ts +290 -0
  163. package/src/biz/record-detail/index.ts +22 -0
  164. package/src/biz/record-detail/shell.ts +64 -0
  165. package/src/biz/settings-center/compile.ts +100 -0
  166. package/src/biz/settings-center/index.ts +18 -0
  167. package/src/biz/settings-center/shell.ts +51 -0
  168. package/src/biz/shared/action-host.ts +469 -0
  169. package/src/biz/shared/coordinator.ts +516 -0
  170. package/src/biz/shared/index.ts +9 -0
  171. package/src/biz/shared/pipes.ts +58 -0
  172. package/src/biz/shared/runtime-hub.ts +112 -0
  173. package/src/biz/shared/step-values.ts +25 -0
  174. package/src/biz/single-form/compile.ts +146 -0
  175. package/src/biz/single-form/index.ts +18 -0
  176. package/src/biz/single-form/shell.ts +38 -0
  177. package/src/biz/standard-crud/compile.ts +546 -0
  178. package/src/biz/standard-crud/index.ts +18 -0
  179. package/src/biz/standard-crud/shell.ts +157 -0
  180. package/src/biz/step-form/compile.ts +400 -0
  181. package/src/biz/step-form/hub.ts +412 -0
  182. package/src/biz/step-form/index.ts +23 -0
  183. package/src/biz/step-form/shell.ts +96 -0
  184. package/src/biz/step-form/steps-ref.ts +112 -0
  185. package/src/biz/types.ts +96 -0
  186. package/src/cli/kit-cli.ts +102 -0
  187. package/src/compile/action-host-attach.ts +76 -0
  188. package/src/compile/compile-page.ts +472 -0
  189. package/src/compile/component-candidates.ts +147 -0
  190. package/src/compile/fragment.ts +104 -0
  191. package/src/compile/hints.ts +255 -0
  192. package/src/compile/index.ts +16 -0
  193. package/src/compile/locate.ts +166 -0
  194. package/src/compile/page-params.ts +80 -0
  195. package/src/compile/parse.ts +355 -0
  196. package/src/compile/redirect.ts +90 -0
  197. package/src/compile/registry.ts +30 -0
  198. package/src/compile/remove-guard.ts +99 -0
  199. package/src/compile/styles.ts +244 -0
  200. package/src/compile/types.ts +106 -0
  201. package/src/data/amount-breakdown.ts +132 -0
  202. package/src/data/anchor-nav.ts +225 -0
  203. package/src/data/approval-flow.ts +269 -0
  204. package/src/data/assignment-picker.ts +652 -0
  205. package/src/data/async-result-panel.ts +308 -0
  206. package/src/data/breadcrumbs.ts +197 -0
  207. package/src/data/calendar.ts +363 -0
  208. package/src/data/carousel.ts +408 -0
  209. package/src/data/chart.ts +726 -0
  210. package/src/data/checklist.ts +215 -0
  211. package/src/data/code-view.ts +415 -0
  212. package/src/data/comment-thread.ts +342 -0
  213. package/src/data/confirm-dialog.ts +144 -0
  214. package/src/data/context-menu.ts +216 -0
  215. package/src/data/d9-limits.ts +42 -0
  216. package/src/data/d9-util.ts +81 -0
  217. package/src/data/diff.ts +239 -0
  218. package/src/data/display-util.ts +135 -0
  219. package/src/data/dock.ts +152 -0
  220. package/src/data/embed.ts +200 -0
  221. package/src/data/field-mapper.ts +544 -0
  222. package/src/data/flow-editor-contract.ts +41 -0
  223. package/src/data/flow-editor.ts +2622 -0
  224. package/src/data/flow-remote-options.ts +257 -0
  225. package/src/data/footer.ts +157 -0
  226. package/src/data/form-draft-registry.ts +76 -0
  227. package/src/data/gantt.ts +430 -0
  228. package/src/data/hero.ts +149 -0
  229. package/src/data/image-viewer.ts +333 -0
  230. package/src/data/index.ts +268 -0
  231. package/src/data/item-list.ts +335 -0
  232. package/src/data/kanban.ts +667 -0
  233. package/src/data/media-grid.ts +246 -0
  234. package/src/data/mega-menu.ts +257 -0
  235. package/src/data/menu-dom.ts +169 -0
  236. package/src/data/menu.ts +464 -0
  237. package/src/data/mockup.ts +176 -0
  238. package/src/data/modal-dialog.ts +182 -0
  239. package/src/data/navbar.ts +292 -0
  240. package/src/data/object-form.ts +1981 -0
  241. package/src/data/options-bus.ts +24 -0
  242. package/src/data/outcome-watch.ts +40 -0
  243. package/src/data/overlay-portal.ts +6 -0
  244. package/src/data/pager.ts +472 -0
  245. package/src/data/permission-matrix.ts +432 -0
  246. package/src/data/permission-tree.ts +916 -0
  247. package/src/data/pricing-table.ts +269 -0
  248. package/src/data/prompt-dialog.ts +235 -0
  249. package/src/data/reaction-bar.ts +236 -0
  250. package/src/data/record-card.ts +413 -0
  251. package/src/data/record-picker.ts +489 -0
  252. package/src/data/redirect.ts +109 -0
  253. package/src/data/remote-options.ts +54 -0
  254. package/src/data/request-console.ts +399 -0
  255. package/src/data/resident.ts +58 -0
  256. package/src/data/result-panel.ts +160 -0
  257. package/src/data/rich-text.ts +626 -0
  258. package/src/data/row-editor.ts +1066 -0
  259. package/src/data/rule-builder.ts +1135 -0
  260. package/src/data/shape-util.ts +221 -0
  261. package/src/data/staged-rows.ts +69 -0
  262. package/src/data/stat-group.ts +231 -0
  263. package/src/data/static-lazy.ts +63 -0
  264. package/src/data/static-registry.ts +227 -0
  265. package/src/data/steps.ts +195 -0
  266. package/src/data/survey.ts +455 -0
  267. package/src/data/system-switcher.ts +243 -0
  268. package/src/data/timeline.ts +204 -0
  269. package/src/data/tour-guide.ts +392 -0
  270. package/src/data/transfer.ts +597 -0
  271. package/src/data/tree-check.ts +30 -0
  272. package/src/data/tree-table.ts +674 -0
  273. package/src/data/tree.ts +656 -0
  274. package/src/data/trend-line.ts +147 -0
  275. package/src/data/virtual-rows.ts +556 -0
  276. package/src/data/watermark.ts +140 -0
  277. package/src/data/wrap.ts +264 -0
  278. package/src/data/wrapped-candidates.ts +96 -0
  279. package/src/frames/blank-frame.ts +19 -0
  280. package/src/frames/index.ts +44 -0
  281. package/src/frames/page-bar.ts +185 -0
  282. package/src/frames/page-header.ts +185 -0
  283. package/src/frames/page-status.ts +54 -0
  284. package/src/frames/resize-handle.ts +147 -0
  285. package/src/frames/shared.ts +216 -0
  286. package/src/frames/single-frame.ts +16 -0
  287. package/src/frames/split-frame/index.ts +4 -0
  288. package/src/frames/split-frame/shell.ts +219 -0
  289. package/src/frames/split-frame/span.ts +64 -0
  290. package/src/frames/split-frame/wiring.ts +164 -0
  291. package/src/frames/tabs-frame/index.ts +3 -0
  292. package/src/frames/tabs-frame/shell.ts +112 -0
  293. package/src/frames/tabs-frame/wiring.ts +69 -0
  294. package/src/frames/top-main-frame.ts +20 -0
  295. package/src/frames/types.ts +72 -0
  296. package/src/frames/workspace-frame/extras.ts +197 -0
  297. package/src/frames/workspace-frame/index.ts +13 -0
  298. package/src/frames/workspace-frame/shell.ts +282 -0
  299. package/src/frames/workspace-frame/state.ts +152 -0
  300. package/src/frames/workspace-frame/view.ts +1013 -0
  301. package/src/generated/kit-grammar-runtime.ts +2811 -0
  302. package/src/generated/page-origin.ts +57 -0
  303. package/src/i18n/index.ts +22 -0
  304. package/src/i18n/kit-text.ts +692 -0
  305. package/src/i18n/resolve-text-refs.ts +128 -0
  306. package/src/index.ts +6 -0
  307. package/src/object-renderer/action-gate.ts +216 -0
  308. package/src/object-renderer/adopt-gate.ts +333 -0
  309. package/src/object-renderer/arrange.ts +411 -0
  310. package/src/object-renderer/candidates.ts +68 -0
  311. package/src/object-renderer/collapse-wiring.ts +99 -0
  312. package/src/object-renderer/collection-expand.ts +185 -0
  313. package/src/object-renderer/collection-parts.ts +653 -0
  314. package/src/object-renderer/collection-table.ts +503 -0
  315. package/src/object-renderer/collection.ts +626 -0
  316. package/src/object-renderer/compile-data.ts +549 -0
  317. package/src/object-renderer/defaults.ts +252 -0
  318. package/src/object-renderer/display-checks.ts +169 -0
  319. package/src/object-renderer/emit-events.ts +498 -0
  320. package/src/object-renderer/emit-object.ts +98 -0
  321. package/src/object-renderer/emit-static.ts +1035 -0
  322. package/src/object-renderer/field-policy.ts +89 -0
  323. package/src/object-renderer/field-value.ts +581 -0
  324. package/src/object-renderer/form-detail.ts +116 -0
  325. package/src/object-renderer/index.ts +13 -0
  326. package/src/object-renderer/linkage.ts +370 -0
  327. package/src/object-renderer/merge-class.ts +126 -0
  328. package/src/object-renderer/mode.ts +25 -0
  329. package/src/object-renderer/outcome-draft.ts +61 -0
  330. package/src/object-renderer/parts.ts +136 -0
  331. package/src/object-renderer/pick-component.ts +36 -0
  332. package/src/object-renderer/render-object.ts +724 -0
  333. package/src/object-renderer/request-actions.ts +581 -0
  334. package/src/object-renderer/skeleton.ts +101 -0
  335. package/src/object-renderer/table-actions.ts +438 -0
  336. package/src/object-renderer/table-summary.ts +105 -0
  337. package/src/object-renderer/table-tools.ts +1072 -0
  338. package/src/object-renderer/types.ts +933 -0
  339. package/src/page-target/ai-surface.ts +154 -0
  340. package/src/page-target/compile.ts +354 -0
  341. package/src/page-target/drift.ts +186 -0
  342. package/src/page-target/index.ts +25 -0
  343. package/src/page-target/intent-map.ts +137 -0
  344. package/src/page-target/intent-schema.ts +711 -0
  345. package/src/page-target/origin.ts +17 -0
  346. package/src/page-target/target.ts +450 -0
  347. package/src/page-target/writer-policy.ts +315 -0
  348. package/src/theme/block-theme.ts +202 -0
  349. package/src/theme/kit-theme-text.ts +2 -0
  350. package/src/theme/kit-theme.css +275 -0
  351. package/src/theme/kit-theme.tpl +275 -0
  352. package/src/theme/theme-tokens.ts +135 -0
@@ -0,0 +1,243 @@
1
+ // SystemSwitcher:系统 / 应用切换面板(layer: data,写死形状,accept: single)。
2
+ //
3
+ // 数据:`data` 是 { items, keyword?, server_search?, favorites_max?, title?, hint? }(也可写在 `view.props`,data 优先):
4
+ // items [{ id, title, sub?, favorite?, disabled? }]:可切换的系统;favorite 真表示已在常用里;
5
+ // favorites [{ id, title, sub? }]:可选,常用独立给出(server_search 的结果里不一定含全部常用时用);不给就取 items 里 favorite 为真的;
6
+ // favorites_max:常用上限(缺省与上限同为真源 workspaceFrame.limits.systemFavorites);满额时「添加常用」置灰并提示,不静默吞;
7
+ // keyword:搜索框当前关键词(宿主给,外部变化时覆盖输入框);
8
+ // server_search:假(缺省)= 输入时本地按标题 / 标识过滤;真 = 不过滤,回车或点搜索钮抛 search { keyword },由宿主给回结果。
9
+ // 面板由「标题 + 已选常用(chip,点名字打开,× 移除)+ 搜索行 + 系统列表(行尾:打开 / 添加或移除常用)」组成,列表复用 ItemList。
10
+ // 组件不改数据,也不做乐观更新:点常用只抛 favorite { id, on, item }(on = 期望的新状态),宿主写成功后把 items 的 favorite 回传;
11
+ // 写失败宿主不回传即保持原状(失败回滚由 write 的结果决定,组件不猜)。点「打开」抛 open { id, item }。
12
+ // 数据只经 textContent 写入;无匹配显示空态文案。
13
+
14
+ import type { SomaComponentDefinition } from 'soma-core';
15
+ import { KIT_WORKSPACE_FRAME_LIMITS } from 'soma-foundation/kit-limits';
16
+ import { bool, createKitController, joinClass } from '../base/shared';
17
+ import { createButton, KIT_BUTTON_CLASS_CANDIDATES } from '../base/button';
18
+ import { createInput, KIT_INPUT_CLASS_CANDIDATES } from '../base/input';
19
+ import { kitIcon } from '../base/icons';
20
+ import { kitText } from '../i18n/kit-text';
21
+ import { mountKitComponent, type KitMount } from './embed';
22
+ import { singleOf, clampInt } from './display-util';
23
+ import { createItemList, KIT_ITEM_LIST_CLASS_CANDIDATES } from './item-list';
24
+ import { classTokens, mk, rowsOf, textOf, type Rec } from './shape-util';
25
+
26
+ const KEYS = ['items', 'favorites', 'keyword', 'server_search', 'favorites_max', 'title', 'hint'] as const;
27
+ const FAV_LIMIT = KIT_WORKSPACE_FRAME_LIMITS.limits.systemFavorites;
28
+
29
+ const ROOT_CLASS = '@container flex flex-col gap-3 rounded-lg border border-border-subtle bg-surface-raised p-4 shadow-sm';
30
+ const HEAD_CLASS = 'flex flex-col';
31
+ const TITLE_CLASS = 'text-base font-semibold text-fg';
32
+ const HINT_CLASS = 'text-xs text-fg-subtle';
33
+ const FAV_BOX_CLASS = 'flex flex-col gap-2 rounded-md bg-surface-sunken p-3';
34
+ const FAV_HEAD_CLASS = 'flex items-center justify-between gap-2 text-xs text-fg-muted';
35
+ const CHIPS_CLASS = 'flex flex-wrap gap-2';
36
+ const CHIP_CLASS = 'inline-flex items-center gap-1 rounded-full border border-border-subtle bg-surface ps-3 pe-1 text-sm text-fg';
37
+ const CHIP_OPEN_CLASS = 'cursor-pointer rounded-sm text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
38
+ const CHIP_REMOVE_CLASS = 'inline-flex size-6 cursor-pointer items-center justify-center rounded-full text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
39
+ const SEARCH_ROW_CLASS = 'flex items-center gap-2';
40
+ const SEARCH_FIELD_CLASS = 'min-w-0 flex-1';
41
+ const LIST_CLASS = 'grid grid-cols-1 gap-2 @2xl:grid-cols-2';
42
+ const HIDDEN = 'hidden';
43
+
44
+ export const KIT_SYSTEM_SWITCHER_CLASS_CANDIDATES: readonly string[] = classTokens(
45
+ ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, HINT_CLASS, FAV_BOX_CLASS, FAV_HEAD_CLASS, CHIPS_CLASS, CHIP_CLASS, CHIP_OPEN_CLASS,
46
+ CHIP_REMOVE_CLASS, SEARCH_ROW_CLASS, SEARCH_FIELD_CLASS, LIST_CLASS, HIDDEN,
47
+ KIT_ITEM_LIST_CLASS_CANDIDATES, KIT_INPUT_CLASS_CANDIDATES, KIT_BUTTON_CLASS_CANDIDATES,
48
+ );
49
+
50
+ export interface KitSystemItem { id: string; title: string; sub: string; favorite: boolean; disabled: boolean; raw: Rec }
51
+
52
+ /** 系统条目(纯函数,便于单测):缺 id 用下标,缺 title 退到 id */
53
+ export function systemItemsOf(raw: unknown): KitSystemItem[] {
54
+ return rowsOf(raw).map((r, i) => {
55
+ const id = textOf(r.id) === '' ? `s${i}` : textOf(r.id);
56
+ return { id, title: textOf(r.title) === '' ? id : textOf(r.title), sub: textOf(r.sub), favorite: r.favorite === true, disabled: r.disabled === true, raw: r };
57
+ });
58
+ }
59
+
60
+ /** 本地过滤:关键词(忽略大小写)命中标题或标识;空关键词原样返回 */
61
+ export function filterSystems(items: readonly KitSystemItem[], keyword: string): KitSystemItem[] {
62
+ const k = keyword.trim().toLowerCase();
63
+ if (k === '') return [...items];
64
+ return items.filter((i) => i.title.toLowerCase().includes(k) || i.sub.toLowerCase().includes(k) || i.id.toLowerCase().includes(k));
65
+ }
66
+
67
+ interface Parts {
68
+ input: KitMount;
69
+ searchBtn: KitMount;
70
+ searchBtnBox: HTMLElement;
71
+ list: KitMount;
72
+ title: HTMLElement;
73
+ hint: HTMLElement;
74
+ count: HTMLElement;
75
+ chips: HTMLElement;
76
+ typed: string;
77
+ given: string;
78
+ }
79
+
80
+ export function createSystemSwitcher(): SomaComponentDefinition {
81
+ const parts = new WeakMap<HTMLElement, Parts>();
82
+ return {
83
+ contract: {
84
+ name: 'SystemSwitcher',
85
+ layer: 'data',
86
+ props: {
87
+ data: { type: 'object', default: {}, desc: '{ items[{ id, title, sub?, favorite?, disabled? }], keyword?, server_search?, favorites_max?, title?, hint? }' },
88
+ items: { type: 'array', default: [], desc: '系统列表' },
89
+ favorites: { type: 'array', default: [], desc: '常用 [{ id, title, sub? }](可选;不给取 items 里 favorite 为真的)' },
90
+ keyword: { type: 'string', default: '', desc: '搜索关键词(外部变化时覆盖输入框)' },
91
+ server_search: { type: 'boolean', default: false, desc: '真 = 不本地过滤,回车 / 点搜索钮抛 search,由宿主给回结果' },
92
+ favorites_max: { type: 'number', default: 0, desc: '常用上限;0 或缺省 = 真源上限' },
93
+ title: { type: 'string', default: '', desc: '标题;空取内置词条' },
94
+ hint: { type: 'string', default: '', desc: '副标题;空取内置词条' },
95
+ class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
96
+ },
97
+ emits: {
98
+ open: { payload: { id: { type: 'string' }, item: { type: 'object' } }, desc: '打开某个系统' },
99
+ favorite: { payload: { id: { type: 'string' }, on: { type: 'boolean' }, item: { type: 'object' } }, desc: '请求加入 / 移出常用;on = 期望的新状态,组件不乐观更新,宿主写成功后回传 items' },
100
+ search: { payload: { keyword: { type: 'string' } }, desc: 'server_search 为真时,回车或点搜索钮' },
101
+ },
102
+ },
103
+ templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
104
+ controllerFactory: createKitController({
105
+ attach(root, api) {
106
+ const srcOf = (): Rec => singleOf(api.props().data, api.props(), KEYS);
107
+ const itemOf = (id: string): KitSystemItem | undefined => [...systemItemsOf(srcOf().items), ...systemItemsOf(srcOf().favorites)].find((i) => i.id === id);
108
+ const head = mk('div', HEAD_CLASS);
109
+ const title = mk('h2', TITLE_CLASS);
110
+ const hint = mk('p', HINT_CLASS);
111
+ head.append(title, hint);
112
+ const count = mk('span', '');
113
+ const chips = mk('div', CHIPS_CLASS);
114
+ const favBox = mk('div', FAV_BOX_CLASS);
115
+ const favHead = mk('div', FAV_HEAD_CLASS);
116
+ const favTitle = mk('span', '');
117
+ favHead.append(favTitle, count);
118
+ favBox.append(favHead, chips);
119
+ favBox.setAttribute('data-kit-sw-favorites', '');
120
+ const field = mk('div', SEARCH_FIELD_CLASS);
121
+ const searchBtnBox = mk('div', HIDDEN);
122
+ const searchRow = mk('div', SEARCH_ROW_CLASS);
123
+ searchRow.append(field, searchBtnBox);
124
+ const listBox = mk('div', LIST_CLASS);
125
+ root.replaceChildren(head, favBox, searchRow, listBox);
126
+ const self = {} as Parts;
127
+ self.typed = '';
128
+ self.given = '';
129
+ self.title = title;
130
+ self.hint = hint;
131
+ self.count = count;
132
+ self.chips = chips;
133
+ self.searchBtnBox = searchBtnBox;
134
+ const runSearch = (): void => api.emit('search', { keyword: self.typed });
135
+ self.input = mountKitComponent(createInput(), field, { value: '', clearable: true }, {
136
+ change: (e: { value: string }) => {
137
+ self.typed = e.value;
138
+ if (!bool(srcOf().server_search)) repaintList(root, api.props());
139
+ },
140
+ });
141
+ field.addEventListener('keydown', (e) => {
142
+ if ((e as KeyboardEvent).key === 'Enter' && bool(srcOf().server_search)) runSearch();
143
+ });
144
+ self.searchBtn = mountKitComponent(createButton(), searchBtnBox, { label: '', variant: 'primary', size: 'md' }, { click: runSearch });
145
+ self.list = mountKitComponent(createItemList(), listBox, { selectable: false }, {
146
+ action: (e: { key: string; id: string }) => {
147
+ const item = itemOf(e.id);
148
+ if (!item) return;
149
+ if (e.key === 'open') api.emit('open', { id: e.id, item: item.raw });
150
+ else api.emit('favorite', { id: e.id, on: e.key === 'favorite_on', item: item.raw });
151
+ },
152
+ });
153
+ parts.set(root, self);
154
+ const onChipClick = (event: Event): void => {
155
+ const t = event.target as HTMLElement | null;
156
+ const open = t?.closest<HTMLElement>('[data-kit-sw-open]');
157
+ const off = t?.closest<HTMLElement>('[data-kit-sw-unfav]');
158
+ const hit = open ?? off;
159
+ const item = hit ? itemOf(hit.getAttribute('data-kit-sw-id') ?? '') : undefined;
160
+ if (!hit || !item) return;
161
+ if (open) api.emit('open', { id: item.id, item: item.raw });
162
+ else api.emit('favorite', { id: item.id, on: false, item: item.raw });
163
+ };
164
+ chips.addEventListener('click', onChipClick);
165
+ return () => {
166
+ chips.removeEventListener('click', onChipClick);
167
+ self.input.destroy();
168
+ self.searchBtn.destroy();
169
+ self.list.destroy();
170
+ parts.delete(root);
171
+ };
172
+ },
173
+ render(root, p) {
174
+ const self = parts.get(root);
175
+ if (!self) return;
176
+ root.className = joinClass(ROOT_CLASS, p.class);
177
+ const src = singleOf(p.data, p, KEYS);
178
+ const server = bool(src.server_search);
179
+ const keyword = textOf(src.keyword);
180
+ if (keyword !== self.given) {
181
+ self.given = keyword;
182
+ self.typed = keyword;
183
+ self.input.setProps({ value: keyword });
184
+ }
185
+ const items = systemItemsOf(src.items);
186
+ const max = clampInt(src.favorites_max, 1, FAV_LIMIT, FAV_LIMIT);
187
+ // 常用独立给出(favorites)时以它为准(搜索结果里可能不含全部常用);否则取 items 里 favorite 为真的
188
+ const favs = Array.isArray(src.favorites) ? systemItemsOf(src.favorites) : items.filter((i) => i.favorite);
189
+ self.title.textContent = textOf(src.title) || kitText('soma.kit.sw_title', undefined, root);
190
+ self.hint.textContent = textOf(src.hint) || kitText('soma.kit.sw_hint', undefined, root);
191
+ self.count.textContent = kitText('soma.kit.sw_fav_count', { n: favs.length, max }, root);
192
+ const favTitle = self.count.previousElementSibling;
193
+ if (favTitle) favTitle.textContent = kitText('soma.kit.sw_favorites', undefined, root);
194
+ self.chips.replaceChildren(...favs.map((f) => {
195
+ const chip = mk('span', CHIP_CLASS);
196
+ const open = mk('button', CHIP_OPEN_CLASS, f.title);
197
+ open.type = 'button';
198
+ open.setAttribute('data-kit-sw-open', '');
199
+ open.setAttribute('data-kit-sw-id', f.id);
200
+ const off = mk('button', CHIP_REMOVE_CLASS);
201
+ off.type = 'button';
202
+ off.setAttribute('data-kit-sw-unfav', '');
203
+ off.setAttribute('data-kit-sw-id', f.id);
204
+ off.setAttribute('aria-label', `${kitText('soma.kit.sw_fav_remove', undefined, root)}:${f.title}`);
205
+ off.append(kitIcon('close', 'xs'));
206
+ chip.append(open, off);
207
+ return chip;
208
+ }));
209
+ self.searchBtnBox.className = server ? '' : HIDDEN;
210
+ self.searchBtn.setProps({ label: kitText('soma.kit.sw_search_btn', undefined, root) });
211
+ self.input.setProps({ placeholder: kitText('soma.kit.sw_search_ph', undefined, root), aria_label: kitText('soma.kit.sw_search_ph', undefined, root) });
212
+ repaintList(root, p);
213
+ },
214
+ }),
215
+ };
216
+
217
+ /** 只重画系统列表(本地过滤时输入每变一次调一次,不动输入框,保住焦点) */
218
+ function repaintList(root: HTMLElement, p: Rec): void {
219
+ const self = parts.get(root);
220
+ if (!self) return;
221
+ const src = singleOf(p.data, p, KEYS);
222
+ const items = systemItemsOf(src.items);
223
+ const max = clampInt(src.favorites_max, 1, FAV_LIMIT, FAV_LIMIT);
224
+ const favCount = Array.isArray(src.favorites) ? src.favorites.length : items.filter((i) => i.favorite).length;
225
+ const full = favCount >= max;
226
+ const shown = bool(src.server_search) ? items : filterSystems(items, self.typed);
227
+ self.list.setProps({
228
+ data: shown.map((s) => ({
229
+ id: s.id,
230
+ title: s.title,
231
+ sub: s.sub,
232
+ disabled: s.disabled,
233
+ actions: [
234
+ { key: 'open', label: kitText('soma.kit.sw_open', undefined, root), disabled: s.disabled },
235
+ s.favorite
236
+ ? { key: 'favorite_off', label: kitText('soma.kit.sw_fav_remove', undefined, root), tone: 'danger' }
237
+ : { key: 'favorite_on', label: full ? kitText('soma.kit.sw_fav_full', undefined, root) : kitText('soma.kit.sw_fav_add', undefined, root), disabled: full },
238
+ ],
239
+ })),
240
+ empty_text: kitText('soma.kit.sw_empty', undefined, root),
241
+ });
242
+ }
243
+ }
@@ -0,0 +1,204 @@
1
+ // Timeline:时间线(layer: data,写死形状,accept: list)。并入老版 ActivityFeed(actor / target 两个可选字段)。
2
+ //
3
+ // 数据:`data` 是 [{ id, time, title, text?, actor?, target?, tone?, icon? }];键名可由 `map` 改写(组件期望的键 -> 数据里的键)。
4
+ // 排序是显式配置:`order` = none(按给定顺序,默认)/ asc / desc;首项高亮(`highlight_first`,默认开)。
5
+ // 只做竖向;不做 alternate / boxed。`icon` 是短字符(≤2 个字)时替换圆点。
6
+ // `selectable` 为真时每条是可聚焦按钮,点击 / Enter 抛 `select { item }`(item 是源数据原对象);默认只展示。
7
+
8
+ import type { SomaComponentDefinition } from 'soma-core';
9
+ import { bool, createKitController, formatValue, joinClass, str } from '../base/shared';
10
+ import { kitText } from '../i18n/kit-text';
11
+ import {
12
+ classTokens, compareTime, emptyNode, keyMap, mk, rowsOf, shapeToneOf, textOf,
13
+ TONE_DOT, TONE_SOFT, type Rec, type ShapeTone,
14
+ } from './shape-util';
15
+ import { AVATAR_CLASS_TOKENS, avatarNode, dayNumOf, textOfDayNum, timeTail } from './d9-util';
16
+
17
+ export const KIT_TIMELINE_DEFAULT_MAP = Object.freeze({
18
+ id: 'id', time: 'time', title: 'title', text: 'text', actor: 'actor', target: 'target', tone: 'tone', icon: 'icon', avatar: 'avatar',
19
+ });
20
+ const DAY_CLASS = 'pb-2 pt-1 text-xs font-medium text-fg-muted';
21
+
22
+ const ROOT_CLASS = 'flex flex-col text-sm text-fg';
23
+ const ITEM_CLASS = 'flex gap-3';
24
+ const RAIL_CLASS = 'flex flex-col items-center gap-1 pt-1';
25
+ const DOT_CLASS = 'size-3 shrink-0 rounded-full ring-4 ring-surface';
26
+ const ICON_CLASS = 'flex size-6 shrink-0 items-center justify-center rounded-full text-xs font-medium ring-4 ring-surface';
27
+ const LINE_CLASS = 'w-0.5 flex-1 rounded-full bg-border-subtle';
28
+ const BODY_CLASS = 'flex flex-1 flex-col gap-1 pb-5';
29
+ const BODY_BUTTON_CLASS = 'flex flex-1 flex-col gap-1 rounded-md px-2 pb-5 text-start transition-colors hover:bg-surface-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
30
+ const HEAD_CLASS = 'flex flex-wrap items-baseline gap-x-2';
31
+ const ACTOR_CLASS = 'font-medium text-fg';
32
+ const TITLE_CLASS = 'text-fg';
33
+ const TARGET_CLASS = 'text-fg-muted';
34
+ const TIME_CLASS = 'text-xs text-fg-subtle';
35
+ const TEXT_CLASS = 'text-fg-muted';
36
+ // align: end / alternate 时,内容在轴线左侧的条目(右对齐文字);alternate 另一侧补一个等宽占位
37
+ const BODY_LEFT_CLASS = 'flex flex-1 flex-col gap-1 pb-5 text-end';
38
+ const BODY_BUTTON_LEFT_CLASS = 'flex flex-1 flex-col gap-1 rounded-md px-2 pb-5 text-end transition-colors hover:bg-surface-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
39
+ const HEAD_LEFT_CLASS = 'flex flex-wrap items-baseline justify-end gap-x-2';
40
+ const SPACER_CLASS = 'flex-1';
41
+
42
+ export const KIT_TIMELINE_ALIGNS: readonly string[] = Object.freeze(['start', 'alternate', 'end']);
43
+
44
+ export const KIT_TIMELINE_CLASS_CANDIDATES: readonly string[] = classTokens(
45
+ BODY_LEFT_CLASS, BODY_BUTTON_LEFT_CLASS, HEAD_LEFT_CLASS, SPACER_CLASS,
46
+ ROOT_CLASS, ITEM_CLASS, RAIL_CLASS, DOT_CLASS, ICON_CLASS, LINE_CLASS, BODY_CLASS, BODY_BUTTON_CLASS,
47
+ HEAD_CLASS, ACTOR_CLASS, TITLE_CLASS, TARGET_CLASS, TIME_CLASS, TEXT_CLASS,
48
+ Object.values(TONE_DOT), Object.values(TONE_SOFT), DAY_CLASS, AVATAR_CLASS_TOKENS,
49
+ );
50
+
51
+ export interface KitTimelineEntry {
52
+ key: string;
53
+ time: string;
54
+ title: string;
55
+ text: string;
56
+ actor: string;
57
+ target: string;
58
+ tone: ShapeTone | null;
59
+ icon: string;
60
+ avatar: string;
61
+ /** 原始 time 的日期部分(日序号);取不出为 null,按天分组用 */
62
+ day: number | null;
63
+ /** 原始 time 的时分(有则取),按天分组时作行内时间 */
64
+ clock: string;
65
+ raw: Rec;
66
+ }
67
+
68
+ /** 源数据 -> 条目(纯函数,便于单测);order 非 asc / desc 时保持给定顺序 */
69
+ export function timelineEntriesOf(data: unknown, mapRaw: unknown, order: string, timeFormat = '', locale = ''): KitTimelineEntry[] {
70
+ const m = keyMap(KIT_TIMELINE_DEFAULT_MAP, mapRaw);
71
+ const rows = rowsOf(data);
72
+ const indexed = rows.map((raw, i) => ({ raw, i }));
73
+ if (order === 'asc' || order === 'desc') {
74
+ indexed.sort((a, b) => {
75
+ const c = compareTime(a.raw[m.time], b.raw[m.time]);
76
+ return (order === 'asc' ? c : -c) || a.i - b.i;
77
+ });
78
+ }
79
+ return indexed.map(({ raw, i }) => {
80
+ const time = raw[m.time];
81
+ const id = raw[m.id];
82
+ return {
83
+ key: id === undefined || id === null || id === '' ? `t${i}` : String(id),
84
+ time: time === undefined || time === null || time === '' ? '' : formatValue(time, timeFormat, locale),
85
+ title: textOf(raw[m.title]),
86
+ text: textOf(raw[m.text]),
87
+ actor: textOf(raw[m.actor]),
88
+ target: textOf(raw[m.target]),
89
+ tone: raw[m.tone] === undefined || raw[m.tone] === null || raw[m.tone] === '' ? null : shapeToneOf(raw[m.tone]),
90
+ icon: textOf(raw[m.icon]),
91
+ avatar: textOf(raw[m.avatar]),
92
+ day: dayNumOf(time),
93
+ clock: timeTail(time),
94
+ raw,
95
+ };
96
+ });
97
+ }
98
+
99
+ export function createTimeline(): SomaComponentDefinition {
100
+ return {
101
+ contract: {
102
+ name: 'Timeline',
103
+ layer: 'data',
104
+ props: {
105
+ data: { type: 'array', default: [], desc: '条目 [{ id, time, title, text?, actor?, target?, tone?, icon? }]' },
106
+ map: { type: 'object', default: {}, desc: '键名对照:id / time / title / text / actor / target / tone / icon -> 数据里的键' },
107
+ order: { type: 'enum', values: ['none', 'asc', 'desc'], default: 'none', desc: '按 time 排序;none 保持给定顺序' },
108
+ align: { type: 'enum', values: ['start', 'alternate', 'end'], default: 'start', desc: '内容相对轴线的位置:start = 都在右侧(缺省);end = 都在左侧(文字右对齐);alternate = 左右交错(轴线居中)' },
109
+ highlight_first: { type: 'boolean', default: true, desc: '首项(最新态)用主色圆点' },
110
+ selectable: { type: 'boolean', default: false, desc: '条目可点(按钮),点击抛 select' },
111
+ group_by_day: { type: 'boolean', default: false, desc: '按天分组(动态流):日期变化处插入日期组头,行内时间只显示时分;配合 order: desc' },
112
+ today: { type: 'string', default: '', desc: '今天 YYYY-MM-DD;给了才有「今天 / 昨天」组头' },
113
+ today_text: { type: 'string', default: '', desc: '今天组头文案' },
114
+ yesterday_text: { type: 'string', default: '', desc: '昨天组头文案' },
115
+ other_text: { type: 'string', default: '', desc: '无日期行的组头文案' },
116
+ time_format: { type: 'string', default: '', desc: 'time 的格式化写法(datetime / date / relative 等,取 soma-foundation/values);空则原样' },
117
+ locale: { type: 'string', default: '', desc: '格式化语言;空则 zh-CN' },
118
+ empty_text: { type: 'string', default: '', desc: '无数据时的文案' },
119
+ class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
120
+ },
121
+ emits: {
122
+ select: { payload: { item: { type: 'object' } }, desc: '点某一条(selectable 时);item 是源数据里的原对象' },
123
+ },
124
+ },
125
+ templateHtml: `<ol data-soma-id="root" role="list" class="${ROOT_CLASS}"></ol>`,
126
+ controllerFactory: createKitController({
127
+ attach(root, api) {
128
+ const onClick = (event: Event): void => {
129
+ const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-pick]');
130
+ if (!hit) return;
131
+ const p = api.props();
132
+ const entries = timelineEntriesOf(p.data, p.map, str(p.order, 'none'));
133
+ const entry = entries.find((e) => e.key === hit.getAttribute('data-kit-pick'));
134
+ if (entry) api.emit('select', { item: entry.raw });
135
+ };
136
+ root.addEventListener('click', onClick);
137
+ return () => root.removeEventListener('click', onClick);
138
+ },
139
+ render(root, p) {
140
+ root.className = joinClass(ROOT_CLASS, p.class);
141
+ root.textContent = '';
142
+ const entries = timelineEntriesOf(p.data, p.map, str(p.order, 'none'), str(p.time_format), str(p.locale));
143
+ if (entries.length === 0) {
144
+ root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.tl_empty', undefined, root))));
145
+ return;
146
+ }
147
+ const highlight = p.highlight_first === undefined ? true : bool(p.highlight_first);
148
+ const selectable = bool(p.selectable);
149
+ const byDay = bool(p.group_by_day);
150
+ const align = KIT_TIMELINE_ALIGNS.includes(str(p.align)) ? str(p.align) : 'start';
151
+ const todayNum = dayNumOf(str(p.today));
152
+ const dayLabel = (day: number | null): string => {
153
+ if (day === null) return str(p.other_text, kitText('soma.kit.tl_other', undefined, root));
154
+ if (todayNum !== null && day === todayNum) return str(p.today_text, kitText('soma.kit.cal_today', undefined, root));
155
+ if (todayNum !== null && day === todayNum - 1) return str(p.yesterday_text, kitText('soma.kit.tl_yesterday', undefined, root));
156
+ return textOfDayNum(day);
157
+ };
158
+ entries.forEach((e, index) => {
159
+ if (byDay && (index === 0 || entries[index - 1]!.day !== e.day)) {
160
+ const head = mk('li', DAY_CLASS, dayLabel(e.day));
161
+ head.setAttribute('data-kit-day', e.day === null ? '' : textOfDayNum(e.day));
162
+ root.appendChild(head);
163
+ }
164
+ const li = mk('li', ITEM_CLASS);
165
+ const rail = mk('div', RAIL_CLASS);
166
+ const tone: ShapeTone = e.tone ?? (index === 0 && highlight ? 'primary' : 'neutral');
167
+ if (e.avatar !== '') {
168
+ rail.appendChild(avatarNode(e.actor || e.title, e.avatar, 'md'));
169
+ } else if (e.icon !== '' && [...e.icon].length <= 2) {
170
+ rail.appendChild(mk('span', `${ICON_CLASS} ${TONE_SOFT[tone]}`, e.icon));
171
+ } else {
172
+ rail.appendChild(mk('span', `${DOT_CLASS} ${TONE_DOT[tone]}`));
173
+ }
174
+ if (index < entries.length - 1) rail.appendChild(mk('span', LINE_CLASS));
175
+ const left = align === 'end' || (align === 'alternate' && index % 2 === 1);
176
+ const body = selectable ? mk('button', left ? BODY_BUTTON_LEFT_CLASS : BODY_BUTTON_CLASS) : mk('div', left ? BODY_LEFT_CLASS : BODY_CLASS);
177
+ if (body instanceof HTMLButtonElement) {
178
+ body.type = 'button';
179
+ body.setAttribute('data-kit-pick', e.key);
180
+ }
181
+ const head = mk('div', left ? HEAD_LEFT_CLASS : HEAD_CLASS);
182
+ if (e.actor !== '') head.appendChild(mk('span', ACTOR_CLASS, e.actor));
183
+ if (e.title !== '') head.appendChild(mk('span', TITLE_CLASS, e.title));
184
+ if (e.target !== '') head.appendChild(mk('span', TARGET_CLASS, e.target));
185
+ const shownTime = byDay && e.day !== null && e.clock !== '' ? e.clock : e.time;
186
+ if (shownTime !== '') head.appendChild(mk('span', TIME_CLASS, shownTime));
187
+ body.appendChild(head);
188
+ if (e.text !== '') body.appendChild(mk('p', TEXT_CLASS, e.text));
189
+ li.setAttribute('data-kit-entry', e.key);
190
+ if (left) {
191
+ li.appendChild(body);
192
+ li.appendChild(rail);
193
+ if (align === 'alternate') li.appendChild(mk('div', SPACER_CLASS));
194
+ } else {
195
+ if (align === 'alternate') li.appendChild(mk('div', SPACER_CLASS));
196
+ li.appendChild(rail);
197
+ li.appendChild(body);
198
+ }
199
+ root.appendChild(li);
200
+ });
201
+ },
202
+ }),
203
+ };
204
+ }