@moonwitness/ui 0.1.0 → 7.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 (768) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -0
  3. package/README.md +135 -260
  4. package/TOKENS.md +62 -0
  5. package/dist/cartoon/anime-avatar.d.ts +8 -0
  6. package/dist/cartoon/anime-avatar.js +135 -0
  7. package/dist/cartoon/anime-stage.d.ts +67 -0
  8. package/dist/cartoon/anime-stage.js +106 -0
  9. package/dist/cartoon/index.d.ts +113 -0
  10. package/dist/cartoon/index.js +119 -0
  11. package/dist/cartoon.d.ts +59 -0
  12. package/dist/cartoon.js +238 -0
  13. package/dist/characters.d.ts +71 -0
  14. package/dist/characters.js +543 -0
  15. package/dist/components/accordion.d.ts +11 -0
  16. package/dist/components/accordion.js +26 -0
  17. package/dist/components/alert.d.ts +14 -0
  18. package/dist/components/alert.js +36 -0
  19. package/dist/components/appearance-menu.d.ts +22 -0
  20. package/dist/components/appearance-menu.js +64 -0
  21. package/dist/components/artwork-frame.d.ts +10 -0
  22. package/dist/components/artwork-frame.js +12 -0
  23. package/dist/components/audio.d.ts +19 -0
  24. package/dist/components/audio.js +49 -0
  25. package/dist/components/avatar.d.ts +9 -0
  26. package/dist/components/avatar.js +28 -0
  27. package/dist/components/badge.d.ts +12 -0
  28. package/dist/components/badge.js +21 -0
  29. package/dist/components/brand-mark.d.ts +13 -0
  30. package/dist/components/brand-mark.js +32 -0
  31. package/dist/components/breadcrumbs.d.ts +15 -0
  32. package/dist/components/breadcrumbs.js +25 -0
  33. package/dist/components/button.d.ts +17 -0
  34. package/dist/components/button.js +119 -0
  35. package/dist/components/card.d.ts +20 -0
  36. package/dist/components/card.js +57 -0
  37. package/dist/components/character-badge.d.ts +9 -0
  38. package/dist/components/character-badge.js +19 -0
  39. package/dist/components/character-preview.d.ts +10 -0
  40. package/dist/components/character-preview.js +47 -0
  41. package/dist/components/character-stage.d.ts +54 -0
  42. package/dist/components/character-stage.js +38 -0
  43. package/dist/components/chart.d.ts +36 -0
  44. package/dist/components/chart.js +154 -0
  45. package/dist/components/checkbox.d.ts +7 -0
  46. package/dist/components/checkbox.js +15 -0
  47. package/dist/components/comic-panel.d.ts +17 -0
  48. package/dist/components/comic-panel.js +118 -0
  49. package/dist/components/comic-theater.d.ts +19 -0
  50. package/dist/components/comic-theater.js +54 -0
  51. package/dist/components/command.d.ts +32 -0
  52. package/dist/components/command.js +56 -0
  53. package/dist/components/confirm-dialog.d.ts +19 -0
  54. package/dist/components/confirm-dialog.js +32 -0
  55. package/dist/components/copy-button.d.ts +14 -0
  56. package/dist/components/copy-button.js +17 -0
  57. package/dist/components/date-picker.d.ts +21 -0
  58. package/dist/components/date-picker.js +45 -0
  59. package/dist/components/dialog.d.ts +20 -0
  60. package/dist/components/dialog.js +51 -0
  61. package/dist/components/dna-icon.d.ts +24 -0
  62. package/dist/components/dna-icon.js +14 -0
  63. package/dist/components/dropdown-menu.d.ts +13 -0
  64. package/dist/components/dropdown-menu.js +26 -0
  65. package/dist/components/effects.d.ts +143 -0
  66. package/dist/components/effects.js +248 -0
  67. package/dist/components/empty-state.d.ts +15 -0
  68. package/dist/components/empty-state.js +18 -0
  69. package/dist/components/epistemic-branch-panel.d.ts +10 -0
  70. package/dist/components/epistemic-branch-panel.js +45 -0
  71. package/dist/components/error-state.d.ts +20 -0
  72. package/dist/components/error-state.js +44 -0
  73. package/dist/components/field.d.ts +13 -0
  74. package/dist/components/field.js +35 -0
  75. package/dist/components/filter-facet-bar.d.ts +15 -0
  76. package/dist/components/filter-facet-bar.js +38 -0
  77. package/dist/components/inbox-popover.d.ts +28 -0
  78. package/dist/components/inbox-popover.js +14 -0
  79. package/dist/components/input.d.ts +7 -0
  80. package/dist/components/input.js +8 -0
  81. package/dist/components/kanban-board.d.ts +21 -0
  82. package/dist/components/kanban-board.js +38 -0
  83. package/dist/components/label.d.ts +6 -0
  84. package/dist/components/label.js +7 -0
  85. package/dist/components/layered-scene.d.ts +74 -0
  86. package/dist/components/layered-scene.js +316 -0
  87. package/dist/components/log-console.d.ts +29 -0
  88. package/dist/components/log-console.js +82 -0
  89. package/dist/components/metric-tile.d.ts +15 -0
  90. package/dist/components/metric-tile.js +30 -0
  91. package/dist/components/mode-picker.d.ts +9 -0
  92. package/dist/components/mode-picker.js +72 -0
  93. package/dist/components/motion-timeline.d.ts +56 -0
  94. package/dist/components/motion-timeline.js +215 -0
  95. package/dist/components/number-input.d.ts +29 -0
  96. package/dist/components/number-input.js +45 -0
  97. package/dist/components/page-header.d.ts +16 -0
  98. package/dist/components/page-header.js +48 -0
  99. package/dist/components/pagination.d.ts +10 -0
  100. package/dist/components/pagination.js +17 -0
  101. package/dist/components/panel.d.ts +18 -0
  102. package/dist/components/panel.js +28 -0
  103. package/dist/components/paper-note.d.ts +6 -0
  104. package/dist/components/paper-note.js +35 -0
  105. package/dist/components/popover.d.ts +11 -0
  106. package/dist/components/popover.js +29 -0
  107. package/dist/components/progress.d.ts +17 -0
  108. package/dist/components/progress.js +26 -0
  109. package/dist/components/quest-card.d.ts +82 -0
  110. package/dist/components/quest-card.js +89 -0
  111. package/dist/components/radio-group.d.ts +8 -0
  112. package/dist/components/radio-group.js +23 -0
  113. package/dist/components/riot-sticker.d.ts +28 -0
  114. package/dist/components/riot-sticker.js +61 -0
  115. package/dist/components/scene-particles.d.ts +31 -0
  116. package/dist/components/scene-particles.js +90 -0
  117. package/dist/components/scene-transitions.d.ts +16 -0
  118. package/dist/components/scene-transitions.js +51 -0
  119. package/dist/components/section-ribbon.d.ts +17 -0
  120. package/dist/components/section-ribbon.js +21 -0
  121. package/dist/components/select-field.d.ts +7 -0
  122. package/dist/components/select-field.js +8 -0
  123. package/dist/components/select.d.ts +14 -0
  124. package/dist/components/select.js +22 -0
  125. package/dist/components/separator.d.ts +9 -0
  126. package/dist/components/separator.js +12 -0
  127. package/dist/components/sheet.d.ts +14 -0
  128. package/dist/components/sheet.js +39 -0
  129. package/dist/components/skeleton.d.ts +7 -0
  130. package/dist/components/skeleton.js +11 -0
  131. package/dist/components/sketch-annotation.d.ts +22 -0
  132. package/dist/components/sketch-annotation.js +21 -0
  133. package/dist/components/smart-button-box.d.ts +24 -0
  134. package/dist/components/smart-button-box.js +26 -0
  135. package/dist/components/speech-bubble.d.ts +33 -0
  136. package/dist/components/speech-bubble.js +18 -0
  137. package/dist/components/spinner.d.ts +11 -0
  138. package/dist/components/spinner.js +10 -0
  139. package/dist/components/sprite-player.d.ts +50 -0
  140. package/dist/components/sprite-player.js +230 -0
  141. package/dist/components/status-bar.d.ts +14 -0
  142. package/dist/components/status-bar.js +16 -0
  143. package/dist/components/status-pill.d.ts +11 -0
  144. package/dist/components/status-pill.js +20 -0
  145. package/dist/components/switch.d.ts +15 -0
  146. package/dist/components/switch.js +16 -0
  147. package/dist/components/table.d.ts +15 -0
  148. package/dist/components/table.js +66 -0
  149. package/dist/components/tabs.d.ts +11 -0
  150. package/dist/components/tabs.js +24 -0
  151. package/dist/components/tag-input.d.ts +17 -0
  152. package/dist/components/tag-input.js +79 -0
  153. package/dist/components/textarea.d.ts +7 -0
  154. package/dist/components/textarea.js +8 -0
  155. package/dist/components/toast.d.ts +7 -0
  156. package/dist/components/toast.js +8 -0
  157. package/dist/components/toolbar.d.ts +8 -0
  158. package/dist/components/toolbar.js +11 -0
  159. package/dist/components/tooltip.d.ts +9 -0
  160. package/dist/components/tooltip.js +18 -0
  161. package/dist/components/update-banner.d.ts +14 -0
  162. package/dist/components/update-banner.js +39 -0
  163. package/dist/components/xv-primitives.d.ts +63 -0
  164. package/dist/components/xv-primitives.js +53 -0
  165. package/dist/dna.d.ts +26 -0
  166. package/dist/dna.js +79 -0
  167. package/dist/game/boss-hud.d.ts +73 -0
  168. package/dist/game/boss-hud.js +78 -0
  169. package/dist/game/index.d.ts +194 -0
  170. package/dist/game/index.js +222 -0
  171. package/dist/game/tactical.d.ts +41 -0
  172. package/dist/game/tactical.js +46 -0
  173. package/dist/game.d.ts +95 -0
  174. package/dist/game.js +263 -0
  175. package/dist/icons/activity.d.ts +7 -0
  176. package/dist/icons/activity.js +8 -0
  177. package/dist/icons/add.d.ts +7 -0
  178. package/dist/icons/add.js +8 -0
  179. package/dist/icons/addon.d.ts +7 -0
  180. package/dist/icons/addon.js +8 -0
  181. package/dist/icons/anime-anger.d.ts +7 -0
  182. package/dist/icons/anime-anger.js +8 -0
  183. package/dist/icons/anime-shock.d.ts +7 -0
  184. package/dist/icons/anime-shock.js +8 -0
  185. package/dist/icons/anime-sparkle.d.ts +7 -0
  186. package/dist/icons/anime-sparkle.js +8 -0
  187. package/dist/icons/anime-sweatdrop.d.ts +7 -0
  188. package/dist/icons/anime-sweatdrop.js +8 -0
  189. package/dist/icons/archive.d.ts +7 -0
  190. package/dist/icons/archive.js +8 -0
  191. package/dist/icons/arrow-left.d.ts +7 -0
  192. package/dist/icons/arrow-left.js +8 -0
  193. package/dist/icons/arrow-right.d.ts +7 -0
  194. package/dist/icons/arrow-right.js +8 -0
  195. package/dist/icons/attachment.d.ts +7 -0
  196. package/dist/icons/attachment.js +8 -0
  197. package/dist/icons/bank.d.ts +7 -0
  198. package/dist/icons/bank.js +8 -0
  199. package/dist/icons/bolt.d.ts +7 -0
  200. package/dist/icons/bolt.js +8 -0
  201. package/dist/icons/book-open.d.ts +7 -0
  202. package/dist/icons/book-open.js +8 -0
  203. package/dist/icons/bookmark.d.ts +7 -0
  204. package/dist/icons/bookmark.js +8 -0
  205. package/dist/icons/boss-skull.d.ts +7 -0
  206. package/dist/icons/boss-skull.js +8 -0
  207. package/dist/icons/calendar-clock.d.ts +7 -0
  208. package/dist/icons/calendar-clock.js +8 -0
  209. package/dist/icons/calendar.d.ts +7 -0
  210. package/dist/icons/calendar.js +8 -0
  211. package/dist/icons/check-circle.d.ts +7 -0
  212. package/dist/icons/check-circle.js +8 -0
  213. package/dist/icons/check-square.d.ts +7 -0
  214. package/dist/icons/check-square.js +8 -0
  215. package/dist/icons/check.d.ts +7 -0
  216. package/dist/icons/check.js +8 -0
  217. package/dist/icons/chevron-right.d.ts +7 -0
  218. package/dist/icons/chevron-right.js +8 -0
  219. package/dist/icons/chevrons-left.d.ts +7 -0
  220. package/dist/icons/chevrons-left.js +8 -0
  221. package/dist/icons/chevrons-right.d.ts +7 -0
  222. package/dist/icons/chevrons-right.js +8 -0
  223. package/dist/icons/clapperboard.d.ts +7 -0
  224. package/dist/icons/clapperboard.js +8 -0
  225. package/dist/icons/clock.d.ts +7 -0
  226. package/dist/icons/clock.js +8 -0
  227. package/dist/icons/close.d.ts +7 -0
  228. package/dist/icons/close.js +8 -0
  229. package/dist/icons/code.d.ts +7 -0
  230. package/dist/icons/code.js +8 -0
  231. package/dist/icons/columns.d.ts +7 -0
  232. package/dist/icons/columns.js +8 -0
  233. package/dist/icons/combo-flame.d.ts +7 -0
  234. package/dist/icons/combo-flame.js +8 -0
  235. package/dist/icons/company.d.ts +7 -0
  236. package/dist/icons/company.js +8 -0
  237. package/dist/icons/credit-card.d.ts +7 -0
  238. package/dist/icons/credit-card.js +8 -0
  239. package/dist/icons/critical-star.d.ts +7 -0
  240. package/dist/icons/critical-star.js +8 -0
  241. package/dist/icons/currency.d.ts +7 -0
  242. package/dist/icons/currency.js +8 -0
  243. package/dist/icons/delete.d.ts +7 -0
  244. package/dist/icons/delete.js +8 -0
  245. package/dist/icons/document.d.ts +7 -0
  246. package/dist/icons/document.js +8 -0
  247. package/dist/icons/download.d.ts +7 -0
  248. package/dist/icons/download.js +8 -0
  249. package/dist/icons/dpad.d.ts +7 -0
  250. package/dist/icons/dpad.js +8 -0
  251. package/dist/icons/edit.d.ts +7 -0
  252. package/dist/icons/edit.js +8 -0
  253. package/dist/icons/element-fire.d.ts +7 -0
  254. package/dist/icons/element-fire.js +8 -0
  255. package/dist/icons/element-ice.d.ts +7 -0
  256. package/dist/icons/element-ice.js +8 -0
  257. package/dist/icons/element-solar.d.ts +7 -0
  258. package/dist/icons/element-solar.js +8 -0
  259. package/dist/icons/element-void.d.ts +7 -0
  260. package/dist/icons/element-void.js +8 -0
  261. package/dist/icons/element-volt.d.ts +7 -0
  262. package/dist/icons/element-volt.js +8 -0
  263. package/dist/icons/element-wind.d.ts +7 -0
  264. package/dist/icons/element-wind.js +8 -0
  265. package/dist/icons/error.d.ts +7 -0
  266. package/dist/icons/error.js +8 -0
  267. package/dist/icons/external-link.d.ts +7 -0
  268. package/dist/icons/external-link.js +8 -0
  269. package/dist/icons/field.d.ts +7 -0
  270. package/dist/icons/field.js +8 -0
  271. package/dist/icons/file-spreadsheet.d.ts +7 -0
  272. package/dist/icons/file-spreadsheet.js +8 -0
  273. package/dist/icons/filter.d.ts +7 -0
  274. package/dist/icons/filter.js +8 -0
  275. package/dist/icons/gacha-ticket.d.ts +7 -0
  276. package/dist/icons/gacha-ticket.js +8 -0
  277. package/dist/icons/gamepad.d.ts +7 -0
  278. package/dist/icons/gamepad.js +8 -0
  279. package/dist/icons/globe.d.ts +7 -0
  280. package/dist/icons/globe.js +8 -0
  281. package/dist/icons/grid.d.ts +7 -0
  282. package/dist/icons/grid.js +8 -0
  283. package/dist/icons/hash.d.ts +7 -0
  284. package/dist/icons/hash.js +8 -0
  285. package/dist/icons/heart-hp.d.ts +7 -0
  286. package/dist/icons/heart-hp.js +8 -0
  287. package/dist/icons/history.d.ts +7 -0
  288. package/dist/icons/history.js +8 -0
  289. package/dist/icons/home.d.ts +7 -0
  290. package/dist/icons/home.js +8 -0
  291. package/dist/icons/image.d.ts +7 -0
  292. package/dist/icons/image.js +8 -0
  293. package/dist/icons/impact-slash.d.ts +7 -0
  294. package/dist/icons/impact-slash.js +8 -0
  295. package/dist/icons/inbox.d.ts +7 -0
  296. package/dist/icons/inbox.js +8 -0
  297. package/dist/icons/index.d.ts +120 -0
  298. package/dist/icons/index.js +120 -0
  299. package/dist/icons/info.d.ts +7 -0
  300. package/dist/icons/info.js +8 -0
  301. package/dist/icons/jobs.d.ts +7 -0
  302. package/dist/icons/jobs.js +8 -0
  303. package/dist/icons/katana.d.ts +7 -0
  304. package/dist/icons/katana.js +8 -0
  305. package/dist/icons/key.d.ts +7 -0
  306. package/dist/icons/key.js +8 -0
  307. package/dist/icons/keyboard.d.ts +7 -0
  308. package/dist/icons/keyboard.js +8 -0
  309. package/dist/icons/keyframe-diamond.d.ts +7 -0
  310. package/dist/icons/keyframe-diamond.js +8 -0
  311. package/dist/icons/knowledge.d.ts +7 -0
  312. package/dist/icons/knowledge.js +8 -0
  313. package/dist/icons/language.d.ts +7 -0
  314. package/dist/icons/language.js +8 -0
  315. package/dist/icons/lock.d.ts +7 -0
  316. package/dist/icons/lock.js +8 -0
  317. package/dist/icons/logout.d.ts +7 -0
  318. package/dist/icons/logout.js +8 -0
  319. package/dist/icons/loot-chest.d.ts +7 -0
  320. package/dist/icons/loot-chest.js +8 -0
  321. package/dist/icons/mail.d.ts +7 -0
  322. package/dist/icons/mail.js +8 -0
  323. package/dist/icons/mana-crystal.d.ts +7 -0
  324. package/dist/icons/mana-crystal.js +8 -0
  325. package/dist/icons/map-pin.d.ts +7 -0
  326. package/dist/icons/map-pin.js +8 -0
  327. package/dist/icons/mecha-helm.d.ts +7 -0
  328. package/dist/icons/mecha-helm.js +8 -0
  329. package/dist/icons/menu.d.ts +7 -0
  330. package/dist/icons/menu.js +8 -0
  331. package/dist/icons/message.d.ts +7 -0
  332. package/dist/icons/message.js +8 -0
  333. package/dist/icons/model.d.ts +7 -0
  334. package/dist/icons/model.js +8 -0
  335. package/dist/icons/moon.d.ts +7 -0
  336. package/dist/icons/moon.js +8 -0
  337. package/dist/icons/notification.d.ts +7 -0
  338. package/dist/icons/notification.js +8 -0
  339. package/dist/icons/partner.d.ts +7 -0
  340. package/dist/icons/partner.js +8 -0
  341. package/dist/icons/pause.d.ts +7 -0
  342. package/dist/icons/pause.js +8 -0
  343. package/dist/icons/phone.d.ts +7 -0
  344. package/dist/icons/phone.js +8 -0
  345. package/dist/icons/play.d.ts +7 -0
  346. package/dist/icons/play.js +8 -0
  347. package/dist/icons/potion-flask.d.ts +7 -0
  348. package/dist/icons/potion-flask.js +8 -0
  349. package/dist/icons/quest-scroll.d.ts +7 -0
  350. package/dist/icons/quest-scroll.js +8 -0
  351. package/dist/icons/radar-ping.d.ts +7 -0
  352. package/dist/icons/radar-ping.js +8 -0
  353. package/dist/icons/refresh.d.ts +7 -0
  354. package/dist/icons/refresh.js +8 -0
  355. package/dist/icons/relation.d.ts +7 -0
  356. package/dist/icons/relation.js +8 -0
  357. package/dist/icons/save.d.ts +7 -0
  358. package/dist/icons/save.js +8 -0
  359. package/dist/icons/search.d.ts +7 -0
  360. package/dist/icons/search.js +8 -0
  361. package/dist/icons/security.d.ts +7 -0
  362. package/dist/icons/security.js +8 -0
  363. package/dist/icons/send.d.ts +7 -0
  364. package/dist/icons/send.js +8 -0
  365. package/dist/icons/settings.d.ts +7 -0
  366. package/dist/icons/settings.js +8 -0
  367. package/dist/icons/shield-crest.d.ts +7 -0
  368. package/dist/icons/shield-crest.js +8 -0
  369. package/dist/icons/shuriken.d.ts +7 -0
  370. package/dist/icons/shuriken.js +8 -0
  371. package/dist/icons/signal-off.d.ts +7 -0
  372. package/dist/icons/signal-off.js +8 -0
  373. package/dist/icons/signal.d.ts +7 -0
  374. package/dist/icons/signal.js +8 -0
  375. package/dist/icons/skill-node.d.ts +7 -0
  376. package/dist/icons/skill-node.js +8 -0
  377. package/dist/icons/smartphone.d.ts +7 -0
  378. package/dist/icons/smartphone.js +8 -0
  379. package/dist/icons/sort-ascending.d.ts +7 -0
  380. package/dist/icons/sort-ascending.js +8 -0
  381. package/dist/icons/sort-descending.d.ts +7 -0
  382. package/dist/icons/sort-descending.js +8 -0
  383. package/dist/icons/sort.d.ts +7 -0
  384. package/dist/icons/sort.js +8 -0
  385. package/dist/icons/sparkle.d.ts +7 -0
  386. package/dist/icons/sparkle.js +8 -0
  387. package/dist/icons/speech-burst.d.ts +7 -0
  388. package/dist/icons/speech-burst.js +8 -0
  389. package/dist/icons/story.d.ts +7 -0
  390. package/dist/icons/story.js +8 -0
  391. package/dist/icons/sun.d.ts +7 -0
  392. package/dist/icons/sun.js +8 -0
  393. package/dist/icons/tag.d.ts +7 -0
  394. package/dist/icons/tag.js +8 -0
  395. package/dist/icons/team.d.ts +7 -0
  396. package/dist/icons/team.js +8 -0
  397. package/dist/icons/trophy-crown.d.ts +7 -0
  398. package/dist/icons/trophy-crown.js +8 -0
  399. package/dist/icons/upload.d.ts +7 -0
  400. package/dist/icons/upload.js +8 -0
  401. package/dist/icons/user.d.ts +7 -0
  402. package/dist/icons/user.js +8 -0
  403. package/dist/icons/users.d.ts +7 -0
  404. package/dist/icons/users.js +8 -0
  405. package/dist/icons/visibility-off.d.ts +7 -0
  406. package/dist/icons/visibility-off.js +8 -0
  407. package/dist/icons/visibility.d.ts +7 -0
  408. package/dist/icons/visibility.js +8 -0
  409. package/dist/icons/volume-off.d.ts +7 -0
  410. package/dist/icons/volume-off.js +8 -0
  411. package/dist/icons/volume.d.ts +7 -0
  412. package/dist/icons/volume.js +8 -0
  413. package/dist/icons/warning.d.ts +7 -0
  414. package/dist/icons/warning.js +8 -0
  415. package/dist/icons/workflow.d.ts +7 -0
  416. package/dist/icons/workflow.js +8 -0
  417. package/dist/icons.d.ts +124 -0
  418. package/dist/icons.js +361 -0
  419. package/dist/index.d.ts +81 -0
  420. package/dist/index.js +83 -0
  421. package/dist/lib/asset-registry.d.ts +104 -0
  422. package/dist/lib/asset-registry.js +328 -0
  423. package/dist/lib/audio-runtime.d.ts +23 -0
  424. package/dist/lib/audio-runtime.js +254 -0
  425. package/dist/lib/character-adapter.d.ts +63 -0
  426. package/dist/lib/character-adapter.js +232 -0
  427. package/dist/lib/character-registry.d.ts +159 -0
  428. package/dist/lib/character-registry.js +1950 -0
  429. package/dist/lib/cn.d.ts +2 -0
  430. package/dist/lib/cn.js +4 -0
  431. package/dist/lib/compose-refs.d.ts +7 -0
  432. package/dist/lib/compose-refs.js +14 -0
  433. package/dist/lib/sanitize-url.d.ts +6 -0
  434. package/dist/lib/sanitize-url.js +44 -0
  435. package/dist/lib/scene-camera.d.ts +70 -0
  436. package/dist/lib/scene-camera.js +317 -0
  437. package/dist/lib/scene-playback.d.ts +93 -0
  438. package/dist/lib/scene-playback.js +447 -0
  439. package/dist/lib/scene-soundscape.d.ts +35 -0
  440. package/dist/lib/scene-soundscape.js +117 -0
  441. package/dist/lib/scene-test-harness.d.ts +17 -0
  442. package/dist/lib/scene-test-harness.js +140 -0
  443. package/dist/lib/scene-timeline.d.ts +59 -0
  444. package/dist/lib/scene-timeline.js +280 -0
  445. package/dist/lib/use-animation-visibility.d.ts +7 -0
  446. package/dist/lib/use-animation-visibility.js +31 -0
  447. package/dist/lib/use-modal-focus.d.ts +6 -0
  448. package/dist/lib/use-modal-focus.js +211 -0
  449. package/dist/lib/use-reduced-motion.d.ts +5 -0
  450. package/dist/lib/use-reduced-motion.js +31 -0
  451. package/dist/motion/easing-presets.d.ts +21 -0
  452. package/dist/motion/easing-presets.js +207 -0
  453. package/dist/motion/index.d.ts +153 -0
  454. package/dist/motion/index.js +311 -0
  455. package/dist/motion/physics.d.ts +30 -0
  456. package/dist/motion/physics.js +178 -0
  457. package/dist/motion/timeline-math.d.ts +78 -0
  458. package/dist/motion/timeline-math.js +216 -0
  459. package/dist/motion.d.ts +76 -0
  460. package/dist/motion.js +316 -0
  461. package/dist/pixelfx-registry.d.ts +127 -0
  462. package/dist/pixelfx-registry.js +861 -0
  463. package/dist/pixelfx.d.ts +161 -0
  464. package/dist/pixelfx.js +510 -0
  465. package/dist/provider.d.ts +27 -0
  466. package/dist/provider.js +15 -0
  467. package/dist/skin-catalog.d.ts +20 -0
  468. package/dist/skin-catalog.js +215 -0
  469. package/dist/skin-tokens.d.ts +3 -0
  470. package/dist/skin-tokens.js +390 -0
  471. package/dist/tailwind-preset.css +109 -0
  472. package/dist/templates/battle-arena.d.ts +2 -0
  473. package/dist/templates/battle-arena.js +351 -0
  474. package/dist/templates/index.d.ts +3 -0
  475. package/dist/templates/index.js +77 -0
  476. package/dist/templates.d.ts +4 -0
  477. package/dist/templates.js +78 -0
  478. package/dist/themes/dna-presets.d.ts +18 -0
  479. package/dist/themes/dna-presets.js +84 -0
  480. package/dist/themes/index.d.ts +11 -0
  481. package/dist/themes/index.js +10 -0
  482. package/dist/themes/provider.d.ts +26 -0
  483. package/dist/themes/provider.js +96 -0
  484. package/dist/themes/types.d.ts +42 -0
  485. package/dist/themes/types.js +47 -0
  486. package/dist/themes.d.ts +2 -0
  487. package/dist/themes.js +2 -0
  488. package/dist/token-exporter.d.ts +5 -0
  489. package/dist/token-exporter.js +4 -0
  490. package/dist/token-exporters.d.ts +28 -0
  491. package/dist/token-exporters.js +257 -0
  492. package/dist/token-seeds.d.ts +38 -0
  493. package/dist/token-seeds.js +272 -0
  494. package/dist/token-snapshot.d.ts +21 -0
  495. package/dist/token-snapshot.js +131 -0
  496. package/dist/tokens.bundle.json +1669 -0
  497. package/dist/tokens.generated.css +599 -0
  498. package/dist/tokens.w3c.json +1931 -0
  499. package/dist/utils.d.ts +12 -0
  500. package/dist/utils.js +49 -0
  501. package/package.json +536 -43
  502. package/scripts/generate-icons.mjs +110 -0
  503. package/scripts/generate-token-artifacts.mjs +90 -0
  504. package/scripts/icon-svg-to-jsx.mjs +249 -0
  505. package/scripts/verification-diagnostics.mjs +40 -0
  506. package/scripts/verify-package.mjs +412 -0
  507. package/src/cartoon/anime-avatar.tsx +628 -0
  508. package/src/cartoon/anime-stage.tsx +458 -0
  509. package/src/cartoon/index.tsx +542 -0
  510. package/src/cartoon.tsx +645 -0
  511. package/src/characters.ts +625 -0
  512. package/src/components/accordion.tsx +77 -0
  513. package/src/components/alert.tsx +139 -0
  514. package/src/components/appearance-menu.tsx +181 -0
  515. package/src/components/artwork-frame.tsx +49 -0
  516. package/src/components/audio.tsx +97 -0
  517. package/src/components/avatar.tsx +75 -0
  518. package/src/components/badge.tsx +94 -0
  519. package/src/components/brand-mark.tsx +73 -0
  520. package/src/components/breadcrumbs.tsx +98 -0
  521. package/src/components/button.tsx +340 -0
  522. package/src/components/card.tsx +171 -0
  523. package/src/components/character-badge.tsx +58 -0
  524. package/src/components/character-preview.tsx +104 -0
  525. package/src/components/character-stage.tsx +225 -0
  526. package/src/components/chart.tsx +481 -0
  527. package/src/components/checkbox.tsx +64 -0
  528. package/src/components/comic-panel.tsx +301 -0
  529. package/src/components/comic-theater.tsx +170 -0
  530. package/src/components/command.tsx +189 -0
  531. package/src/components/confirm-dialog.tsx +129 -0
  532. package/src/components/copy-button.tsx +62 -0
  533. package/src/components/date-picker.tsx +126 -0
  534. package/src/components/dialog.tsx +164 -0
  535. package/src/components/dna-icon.tsx +77 -0
  536. package/src/components/dropdown-menu.tsx +87 -0
  537. package/src/components/effects.tsx +1021 -0
  538. package/src/components/empty-state.tsx +93 -0
  539. package/src/components/epistemic-branch-panel.tsx +101 -0
  540. package/src/components/error-state.tsx +137 -0
  541. package/src/components/field.tsx +96 -0
  542. package/src/components/filter-facet-bar.tsx +91 -0
  543. package/src/components/inbox-popover.tsx +146 -0
  544. package/src/components/input.tsx +25 -0
  545. package/src/components/kanban-board.tsx +190 -0
  546. package/src/components/label.tsx +19 -0
  547. package/src/components/layered-scene.tsx +555 -0
  548. package/src/components/log-console.tsx +261 -0
  549. package/src/components/metric-tile.tsx +99 -0
  550. package/src/components/mode-picker.tsx +149 -0
  551. package/src/components/motion-timeline.tsx +848 -0
  552. package/src/components/number-input.tsx +104 -0
  553. package/src/components/page-header.tsx +123 -0
  554. package/src/components/pagination.tsx +83 -0
  555. package/src/components/panel.tsx +121 -0
  556. package/src/components/paper-note.tsx +77 -0
  557. package/src/components/popover.tsx +72 -0
  558. package/src/components/progress.tsx +127 -0
  559. package/src/components/quest-card.tsx +319 -0
  560. package/src/components/radio-group.tsx +50 -0
  561. package/src/components/riot-sticker.tsx +151 -0
  562. package/src/components/scene-particles.tsx +196 -0
  563. package/src/components/scene-transitions.tsx +130 -0
  564. package/src/components/section-ribbon.tsx +94 -0
  565. package/src/components/select-field.tsx +27 -0
  566. package/src/components/select.tsx +81 -0
  567. package/src/components/separator.tsx +58 -0
  568. package/src/components/sheet.tsx +96 -0
  569. package/src/components/skeleton.tsx +35 -0
  570. package/src/components/sketch-annotation.tsx +87 -0
  571. package/src/components/smart-button-box.tsx +114 -0
  572. package/src/components/speech-bubble.tsx +116 -0
  573. package/src/components/spinner.tsx +69 -0
  574. package/src/components/sprite-player.tsx +412 -0
  575. package/src/components/status-bar.tsx +63 -0
  576. package/src/components/status-pill.tsx +68 -0
  577. package/src/components/switch.tsx +76 -0
  578. package/src/components/table.tsx +163 -0
  579. package/src/components/tabs.tsx +101 -0
  580. package/src/components/tag-input.tsx +170 -0
  581. package/src/components/textarea.tsx +25 -0
  582. package/src/components/toast.tsx +14 -0
  583. package/src/components/toolbar.tsx +39 -0
  584. package/src/components/tooltip.tsx +49 -0
  585. package/src/components/update-banner.tsx +220 -0
  586. package/src/components/xv-primitives.tsx +256 -0
  587. package/src/dna.tsx +137 -0
  588. package/src/game/boss-hud.tsx +384 -0
  589. package/src/game/index.tsx +886 -0
  590. package/src/game/tactical.tsx +245 -0
  591. package/src/game.tsx +770 -0
  592. package/src/icons/activity.tsx +38 -0
  593. package/src/icons/add.tsx +38 -0
  594. package/src/icons/addon.tsx +37 -0
  595. package/src/icons/anime-anger.tsx +37 -0
  596. package/src/icons/anime-shock.tsx +37 -0
  597. package/src/icons/anime-sparkle.tsx +38 -0
  598. package/src/icons/anime-sweatdrop.tsx +38 -0
  599. package/src/icons/archive.tsx +37 -0
  600. package/src/icons/arrow-left.tsx +37 -0
  601. package/src/icons/arrow-right.tsx +37 -0
  602. package/src/icons/attachment.tsx +38 -0
  603. package/src/icons/bank.tsx +37 -0
  604. package/src/icons/bolt.tsx +37 -0
  605. package/src/icons/book-open.tsx +37 -0
  606. package/src/icons/bookmark.tsx +37 -0
  607. package/src/icons/boss-skull.tsx +40 -0
  608. package/src/icons/calendar-clock.tsx +40 -0
  609. package/src/icons/calendar.tsx +38 -0
  610. package/src/icons/check-circle.tsx +38 -0
  611. package/src/icons/check-square.tsx +38 -0
  612. package/src/icons/check.tsx +37 -0
  613. package/src/icons/chevron-right.tsx +37 -0
  614. package/src/icons/chevrons-left.tsx +37 -0
  615. package/src/icons/chevrons-right.tsx +37 -0
  616. package/src/icons/clapperboard.tsx +38 -0
  617. package/src/icons/clock.tsx +38 -0
  618. package/src/icons/close.tsx +37 -0
  619. package/src/icons/code.tsx +37 -0
  620. package/src/icons/columns.tsx +38 -0
  621. package/src/icons/combo-flame.tsx +38 -0
  622. package/src/icons/company.tsx +38 -0
  623. package/src/icons/credit-card.tsx +38 -0
  624. package/src/icons/critical-star.tsx +37 -0
  625. package/src/icons/currency.tsx +38 -0
  626. package/src/icons/delete.tsx +37 -0
  627. package/src/icons/document.tsx +38 -0
  628. package/src/icons/download.tsx +37 -0
  629. package/src/icons/dpad.tsx +38 -0
  630. package/src/icons/edit.tsx +38 -0
  631. package/src/icons/element-fire.tsx +37 -0
  632. package/src/icons/element-ice.tsx +38 -0
  633. package/src/icons/element-solar.tsx +38 -0
  634. package/src/icons/element-void.tsx +38 -0
  635. package/src/icons/element-volt.tsx +38 -0
  636. package/src/icons/element-wind.tsx +37 -0
  637. package/src/icons/error.tsx +38 -0
  638. package/src/icons/external-link.tsx +38 -0
  639. package/src/icons/field.tsx +38 -0
  640. package/src/icons/file-spreadsheet.tsx +38 -0
  641. package/src/icons/filter.tsx +37 -0
  642. package/src/icons/gacha-ticket.tsx +38 -0
  643. package/src/icons/gamepad.tsx +40 -0
  644. package/src/icons/globe.tsx +38 -0
  645. package/src/icons/grid.tsx +40 -0
  646. package/src/icons/hash.tsx +37 -0
  647. package/src/icons/heart-hp.tsx +38 -0
  648. package/src/icons/history.tsx +37 -0
  649. package/src/icons/home.tsx +37 -0
  650. package/src/icons/image.tsx +39 -0
  651. package/src/icons/impact-slash.tsx +38 -0
  652. package/src/icons/inbox.tsx +38 -0
  653. package/src/icons/index.ts +120 -0
  654. package/src/icons/info.tsx +38 -0
  655. package/src/icons/jobs.tsx +38 -0
  656. package/src/icons/katana.tsx +38 -0
  657. package/src/icons/key.tsx +38 -0
  658. package/src/icons/keyboard.tsx +38 -0
  659. package/src/icons/keyframe-diamond.tsx +38 -0
  660. package/src/icons/knowledge.tsx +38 -0
  661. package/src/icons/language.tsx +39 -0
  662. package/src/icons/lock.tsx +38 -0
  663. package/src/icons/logout.tsx +37 -0
  664. package/src/icons/loot-chest.tsx +39 -0
  665. package/src/icons/mail.tsx +38 -0
  666. package/src/icons/mana-crystal.tsx +38 -0
  667. package/src/icons/map-pin.tsx +38 -0
  668. package/src/icons/mecha-helm.tsx +38 -0
  669. package/src/icons/menu.tsx +37 -0
  670. package/src/icons/message.tsx +38 -0
  671. package/src/icons/model.tsx +38 -0
  672. package/src/icons/moon.tsx +37 -0
  673. package/src/icons/notification.tsx +38 -0
  674. package/src/icons/partner.tsx +41 -0
  675. package/src/icons/pause.tsx +37 -0
  676. package/src/icons/phone.tsx +37 -0
  677. package/src/icons/play.tsx +37 -0
  678. package/src/icons/potion-flask.tsx +40 -0
  679. package/src/icons/quest-scroll.tsx +39 -0
  680. package/src/icons/radar-ping.tsx +40 -0
  681. package/src/icons/refresh.tsx +38 -0
  682. package/src/icons/relation.tsx +40 -0
  683. package/src/icons/save.tsx +38 -0
  684. package/src/icons/search.tsx +38 -0
  685. package/src/icons/security.tsx +38 -0
  686. package/src/icons/send.tsx +38 -0
  687. package/src/icons/settings.tsx +39 -0
  688. package/src/icons/shield-crest.tsx +38 -0
  689. package/src/icons/shuriken.tsx +38 -0
  690. package/src/icons/signal-off.tsx +37 -0
  691. package/src/icons/signal.tsx +37 -0
  692. package/src/icons/skill-node.tsx +40 -0
  693. package/src/icons/smartphone.tsx +38 -0
  694. package/src/icons/sort-ascending.tsx +37 -0
  695. package/src/icons/sort-descending.tsx +37 -0
  696. package/src/icons/sort.tsx +37 -0
  697. package/src/icons/sparkle.tsx +38 -0
  698. package/src/icons/speech-burst.tsx +37 -0
  699. package/src/icons/story.tsx +37 -0
  700. package/src/icons/sun.tsx +38 -0
  701. package/src/icons/tag.tsx +38 -0
  702. package/src/icons/team.tsx +40 -0
  703. package/src/icons/trophy-crown.tsx +39 -0
  704. package/src/icons/upload.tsx +37 -0
  705. package/src/icons/user.tsx +38 -0
  706. package/src/icons/users.tsx +39 -0
  707. package/src/icons/visibility-off.tsx +38 -0
  708. package/src/icons/visibility.tsx +38 -0
  709. package/src/icons/volume-off.tsx +37 -0
  710. package/src/icons/volume.tsx +37 -0
  711. package/src/icons/warning.tsx +38 -0
  712. package/src/icons/workflow.tsx +40 -0
  713. package/src/icons.tsx +965 -0
  714. package/src/index.ts +89 -0
  715. package/src/lib/asset-registry.ts +534 -0
  716. package/src/lib/audio-runtime.ts +314 -0
  717. package/src/lib/character-adapter.ts +370 -0
  718. package/src/lib/character-registry.ts +2368 -0
  719. package/src/lib/cn.ts +6 -0
  720. package/src/lib/compose-refs.ts +16 -0
  721. package/src/lib/sanitize-url.ts +51 -0
  722. package/src/lib/scene-camera.ts +483 -0
  723. package/src/lib/scene-playback.ts +622 -0
  724. package/src/lib/scene-soundscape.ts +151 -0
  725. package/src/lib/scene-test-harness.ts +200 -0
  726. package/src/lib/scene-timeline.ts +398 -0
  727. package/src/lib/use-animation-visibility.ts +45 -0
  728. package/src/lib/use-modal-focus.ts +270 -0
  729. package/src/lib/use-reduced-motion.ts +37 -0
  730. package/src/motion/easing-presets.ts +262 -0
  731. package/src/motion/index.tsx +894 -0
  732. package/src/motion/physics.ts +259 -0
  733. package/src/motion/timeline-math.ts +358 -0
  734. package/src/motion.tsx +639 -0
  735. package/src/pixelfx-registry.ts +1190 -0
  736. package/src/pixelfx-types.d.ts +73 -0
  737. package/src/pixelfx.tsx +994 -0
  738. package/src/provider.tsx +63 -0
  739. package/src/skin-catalog.ts +270 -0
  740. package/src/skin-tokens.ts +425 -0
  741. package/src/styles/components.css +8007 -0
  742. package/src/styles/tokens.css +952 -0
  743. package/src/styles/visual-universe.css +149 -0
  744. package/src/styles/xv-primitives.css +192 -0
  745. package/src/templates/battle-arena.tsx +688 -0
  746. package/src/templates/index.tsx +314 -0
  747. package/src/templates.tsx +225 -0
  748. package/src/themes/dna-presets.ts +119 -0
  749. package/src/themes/index.ts +43 -0
  750. package/src/themes/provider.tsx +162 -0
  751. package/src/themes/types.ts +111 -0
  752. package/src/themes.ts +9 -0
  753. package/src/token-exporter.ts +12 -0
  754. package/src/token-exporters.ts +343 -0
  755. package/src/token-seeds.ts +335 -0
  756. package/src/token-snapshot.ts +179 -0
  757. package/src/utils.ts +58 -0
  758. package/styles.css +3 -0
  759. package/src/components.d.ts +0 -588
  760. package/src/components.js +0 -2044
  761. package/src/index.d.ts +0 -3
  762. package/src/index.js +0 -13
  763. package/src/skins.d.ts +0 -4
  764. package/src/skins.js +0 -20
  765. package/src/styles.css +0 -587
  766. package/src/tailwind.css +0 -24
  767. package/src/theme.d.ts +0 -71
  768. package/src/theme.js +0 -257
package/src/components.js DELETED
@@ -1,2044 +0,0 @@
1
- 'use client';
2
-
3
- import React, { createContext, forwardRef, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from 'react';
4
- import { skins } from './skins.js';
5
- import { useTheme } from './theme.js';
6
-
7
- const h = React.createElement;
8
- const cx = (...values) => values.filter(Boolean).join(' ');
9
-
10
- function mergeRefs(...refs) {
11
- return (node) => {
12
- for (const ref of refs) {
13
- if (typeof ref === 'function') ref(node);
14
- else if (ref && typeof ref === 'object') ref.current = node;
15
- }
16
- };
17
- }
18
-
19
- /**
20
- * Polymorphic Slot primitive for Next.js `<Link>` (`asChild`) composition.
21
- * Merges classNames, styles, refs, and event handlers onto the single child element.
22
- */
23
- export const Slot = forwardRef(function Slot({ children, className, style, ...slotProps }, forwardedRef) {
24
- if (!React.isValidElement(children)) return null;
25
- const childProps = children.props || {};
26
- const mergedProps = { ...slotProps, ...childProps };
27
-
28
- for (const key of Object.keys(slotProps)) {
29
- if (/^on[A-Z]/.test(key) && typeof slotProps[key] === 'function' && typeof childProps[key] === 'function') {
30
- mergedProps[key] = (...args) => {
31
- childProps[key](...args);
32
- slotProps[key](...args);
33
- };
34
- }
35
- }
36
-
37
- mergedProps.className = cx(className, childProps.className) || undefined;
38
- if (style || childProps.style) {
39
- mergedProps.style = { ...(style || {}), ...(childProps.style || {}) };
40
- }
41
- const childRef = children.ref ?? childProps.ref;
42
- mergedProps.ref = childRef ? mergeRefs(forwardedRef, childRef) : forwardedRef;
43
-
44
- return React.cloneElement(children, mergedProps);
45
- });
46
-
47
- const element = (tag, baseClass) => forwardRef(function Element({ className, asChild = false, ...props }, ref) {
48
- const Comp = asChild ? Slot : tag;
49
- return h(Comp, { ...props, className: cx(baseClass, className), ref });
50
- });
51
-
52
- function useControllable(value, defaultValue, onChange) {
53
- const [internal, setInternal] = useState(defaultValue);
54
- const controlled = value !== undefined;
55
- const current = controlled ? value : internal;
56
- const set = useCallback((next) => {
57
- if (!controlled) setInternal(next);
58
- if (next !== current) onChange?.(next);
59
- }, [controlled, current, onChange]);
60
- return [current, set];
61
- }
62
-
63
- export const Button = forwardRef(function Button({ className, variant = 'primary', size = 'md', type = 'button', asChild = false, loading = false, disabled, children, ...props }, ref) {
64
- if (asChild) {
65
- return h(Slot, {
66
- ...props,
67
- ref,
68
- className: cx('mf-button', className),
69
- 'data-variant': variant,
70
- 'data-size': size,
71
- 'data-loading': loading || undefined,
72
- 'aria-busy': loading || undefined,
73
- 'aria-disabled': (disabled || loading) || undefined,
74
- }, children);
75
- }
76
- return h('button', {
77
- ...props,
78
- type,
79
- ref,
80
- disabled: disabled || loading,
81
- 'aria-busy': loading || undefined,
82
- 'data-loading': loading || undefined,
83
- className: cx('mf-button', className),
84
- 'data-variant': variant,
85
- 'data-size': size,
86
- }, children);
87
- });
88
-
89
- export const Card = element('section', 'mf-card');
90
- export const CardHeader = element('div', 'mf-card-header');
91
- export const CardTitle = element('h2', 'mf-card-title');
92
- export const CardDescription = element('p', 'mf-card-description');
93
- export const CardContent = element('div', 'mf-card-content');
94
- export const CardFooter = element('div', 'mf-card-footer');
95
-
96
- export const Input = forwardRef(function Input({ className, type = 'text', ...props }, ref) {
97
- return h('input', { ...props, type, ref, className: cx('mf-input', className) });
98
- });
99
- export const Textarea = element('textarea', 'mf-textarea');
100
- export const Label = element('label', 'mf-label');
101
- export const Select = element('select', 'mf-select');
102
-
103
- export const Badge = forwardRef(function Badge({ className, variant = 'secondary', asChild = false, ...props }, ref) {
104
- const Comp = asChild ? Slot : 'span';
105
- return h(Comp, { ...props, ref, className: cx('mf-badge', className), 'data-variant': variant });
106
- });
107
-
108
- export const Table = element('table', 'mf-table');
109
- export const TableHeader = element('thead', 'mf-table-header');
110
- export const TableBody = element('tbody', 'mf-table-body');
111
- export const TableFooter = element('tfoot', 'mf-table-footer');
112
- export const TableRow = element('tr', 'mf-table-row');
113
- export const TableHead = forwardRef(function TableHead({ scope = 'col', ...props }, ref) {
114
- return h('th', { ...props, scope, ref });
115
- });
116
- export const TableCell = element('td', 'mf-table-cell');
117
- export const TableCaption = element('caption', 'mf-table-caption');
118
-
119
- function checkable(baseClass, role) {
120
- return forwardRef(function Checkable({ label, className, id: providedId, onCheckedChange, onChange, ...props }, ref) {
121
- const generatedId = useId();
122
- const id = providedId ?? generatedId;
123
- const handleChange = (event) => {
124
- onChange?.(event);
125
- onCheckedChange?.(event.currentTarget.checked);
126
- };
127
- const input = h('input', { ...props, id, type: 'checkbox', role, className: cx(baseClass, className), onChange: handleChange, ref });
128
- return label == null ? input : h('label', { htmlFor: id, className: 'mf-check-label' }, input, h('span', null, label));
129
- });
130
- }
131
- export const Checkbox = checkable('mf-checkbox');
132
- export const Switch = checkable('mf-switch', 'switch');
133
-
134
- export const Progress = forwardRef(function Progress({ value = 0, max = 100, label = 'Progress', className, ...props }, ref) {
135
- const limit = Number.isFinite(max) && max > 0 ? max : 100;
136
- const amount = Math.min(limit, Math.max(0, Number.isFinite(value) ? value : 0));
137
- return h('div', { 'aria-label': label, ...props, ref, role: 'progressbar', 'aria-valuemin': 0, 'aria-valuemax': limit, 'aria-valuenow': amount, className: cx('mf-progress', className) },
138
- h('span', { className: 'mf-progress-fill', style: { width: `${amount / limit * 100}%` } }));
139
- });
140
-
141
- export const Avatar = forwardRef(function Avatar({ src, alt = '', fallback = '?', className, ...props }, ref) {
142
- const [failedSource, setFailedSource] = useState(null);
143
- return h('span', { ...props, ref, className: cx('mf-avatar', className) },
144
- src && src !== failedSource
145
- ? h('img', { src, alt, onError: () => setFailedSource(src) })
146
- : h('span', { role: alt ? 'img' : undefined, 'aria-label': alt || undefined }, fallback));
147
- });
148
-
149
- export const Separator = forwardRef(function Separator({ orientation = 'horizontal', decorative = true, className, ...props }, ref) {
150
- return h('div', { ...props, ref, className: cx('mf-separator', className), role: decorative ? 'none' : 'separator', 'aria-orientation': decorative ? undefined : orientation, 'data-orientation': orientation });
151
- });
152
-
153
- export const Alert = forwardRef(function Alert({ title, variant = 'secondary', className, children, role = 'status', ...props }, ref) {
154
- return h('div', { ...props, role, ref, className: cx('mf-alert', className), 'data-variant': variant }, title && h('strong', { className: 'mf-alert-title' }, title), children);
155
- });
156
-
157
- export const Skeleton = forwardRef(function Skeleton({ className, ...props }, ref) {
158
- return h('div', { ...props, ref, className: cx('mf-skeleton', className), 'aria-hidden': true });
159
- });
160
-
161
- /** Automatic-activation tabs. Item values must be unique stable strings. */
162
- export const Tabs = forwardRef(function Tabs({ items, value, defaultValue, onValueChange, orientation = 'horizontal', label = 'Sections', className, ...props }, ref) {
163
- const id = useId();
164
- const buttons = useRef([]);
165
- const [selected, setSelected] = useControllable(value, defaultValue ?? items.find(item => !item.disabled)?.value, onValueChange);
166
- const effective = items.some(item => item.value === selected && !item.disabled) ? selected : items.find(item => !item.disabled)?.value;
167
- function onKeyDown(event, index) {
168
- const enabled = items.map((item, i) => item.disabled ? -1 : i).filter(i => i >= 0);
169
- let target;
170
- const current = enabled.indexOf(index);
171
- const rtl = typeof getComputedStyle === 'function' && getComputedStyle(event.currentTarget).direction === 'rtl';
172
- const nextKey = orientation === 'vertical' ? 'ArrowDown' : rtl ? 'ArrowLeft' : 'ArrowRight';
173
- const previousKey = orientation === 'vertical' ? 'ArrowUp' : rtl ? 'ArrowRight' : 'ArrowLeft';
174
- if (event.key === nextKey) target = enabled[(current + 1) % enabled.length];
175
- if (event.key === previousKey) target = enabled[(current - 1 + enabled.length) % enabled.length];
176
- if (event.key === 'Home') target = enabled[0];
177
- if (event.key === 'End') target = enabled.at(-1);
178
- if (target !== undefined) {
179
- event.preventDefault();
180
- setSelected(items[target].value);
181
- buttons.current[target]?.focus();
182
- }
183
- }
184
- return h('div', { ...props, ref, className: cx('mf-tabs', className), 'data-orientation': orientation },
185
- h('div', { role: 'tablist', 'aria-label': label, 'aria-orientation': orientation, className: 'mf-tabs-list' }, items.map((item, index) => h('button', {
186
- key: item.value, ref: node => { buttons.current[index] = node; }, type: 'button', role: 'tab', className: 'mf-tabs-trigger',
187
- id: `${id}-tab-${index}`, 'aria-controls': `${id}-panel-${index}`, 'aria-selected': effective === item.value,
188
- tabIndex: effective === item.value ? 0 : -1, disabled: item.disabled, onClick: () => setSelected(item.value), onKeyDown: event => onKeyDown(event, index),
189
- }, item.label))),
190
- items.map((item, index) => h('div', { key: item.value, role: 'tabpanel', className: 'mf-tabs-content', id: `${id}-panel-${index}`, 'aria-labelledby': `${id}-tab-${index}`, hidden: effective !== item.value, tabIndex: 0 }, item.content)));
191
- });
192
-
193
- /** Native top-layer modal: focus trapping, inert background and Escape support. */
194
- export const Dialog = forwardRef(function Dialog({ open, defaultOpen = false, onOpenChange, title, description, trigger, closeLabel = 'Close dialog', children, className, onCancel, onClose, ...props }, forwardedRef) {
195
- const id = useId();
196
- const dialog = useRef(null);
197
- const returnFocus = useRef(null);
198
- const programmaticCloses = useRef([]);
199
- const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
200
- const currentOpen = useRef(isOpen);
201
- currentOpen.current = isOpen;
202
- const setRef = useCallback(node => {
203
- dialog.current = node;
204
- if (typeof forwardedRef === 'function') forwardedRef(node);
205
- else if (forwardedRef) forwardedRef.current = node;
206
- }, [forwardedRef]);
207
- useEffect(() => {
208
- const node = dialog.current;
209
- if (!node) return;
210
- if (isOpen && !node.open) {
211
- returnFocus.current = node.ownerDocument.activeElement;
212
- node.showModal();
213
- } else if (!isOpen && node.open) {
214
- programmaticCloses.current.push(false);
215
- node.close();
216
- returnFocus.current?.focus?.();
217
- }
218
- }, [isOpen]);
219
- useEffect(() => {
220
- const node = dialog.current;
221
- return () => {
222
- if (node?.open) {
223
- programmaticCloses.current.push(true);
224
- node.close();
225
- returnFocus.current?.focus?.();
226
- }
227
- };
228
- }, []);
229
- const triggerElement = React.isValidElement(trigger) ? React.cloneElement(trigger, {
230
- 'aria-haspopup': 'dialog', 'aria-expanded': Boolean(isOpen),
231
- onClick: event => { trigger.props.onClick?.(event); if (!event.defaultPrevented) setOpen(true); },
232
- }) : null;
233
- return h(React.Fragment, null, triggerElement,
234
- h('dialog', { ...props, ref: setRef, className: cx('mf-dialog', className), 'aria-labelledby': `${id}-title`, 'aria-describedby': description ? `${id}-description` : undefined,
235
- onKeyDown: event => {
236
- props.onKeyDown?.(event);
237
- if (event.defaultPrevented || event.key !== 'Tab') return;
238
- const node = dialog.current;
239
- if (!node) return;
240
- const focusables = Array.from(node.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(el => !el.disabled && (el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0));
241
- if (focusables.length === 0) return;
242
- const first = focusables[0];
243
- const last = focusables[focusables.length - 1];
244
- if (!event.shiftKey && (node.ownerDocument.activeElement === last || !node.contains(node.ownerDocument.activeElement))) {
245
- event.preventDefault();
246
- first.focus();
247
- } else if (event.shiftKey && (node.ownerDocument.activeElement === first || node.ownerDocument.activeElement === node)) {
248
- event.preventDefault();
249
- last.focus();
250
- }
251
- },
252
- onCancel: event => { onCancel?.(event); if (!event.defaultPrevented) { event.preventDefault(); setOpen(false); } },
253
- onClose: event => {
254
- const cleanupClose = programmaticCloses.current.shift();
255
- if (cleanupClose !== true) onClose?.(event);
256
- if (cleanupClose === undefined && currentOpen.current) setOpen(false);
257
- },
258
- },
259
- h('div', { className: 'mf-dialog-header' }, h('h2', { className: 'mf-dialog-title', id: `${id}-title` }, title), h(Button, { variant: 'ghost', className: 'mf-dialog-close', 'aria-label': closeLabel, onClick: () => setOpen(false) }, '×')),
260
- description && h('p', { className: 'mf-dialog-description', id: `${id}-description` }, description),
261
- h('div', { className: 'mf-dialog-content' }, children)));
262
- });
263
-
264
- /** Semantic disclosure group; native summary keyboard behavior is preserved. */
265
- export const Accordion = forwardRef(function Accordion({ items, multiple = false, defaultValue = [], className, ...props }, ref) {
266
- const [expanded, setExpanded] = useState(() => new Set(multiple ? defaultValue : defaultValue.slice(0, 1)));
267
- return h('div', { ...props, ref, className: cx('mf-accordion', className) }, items.map(item => h('details', {
268
- key: item.value, className: 'mf-accordion-item', open: expanded.has(item.value),
269
- onToggle: event => {
270
- const isExpanded = event.currentTarget.open;
271
- setExpanded(previous => {
272
- if (previous.has(item.value) === isExpanded) return previous;
273
- const next = isExpanded && !multiple ? new Set() : new Set(previous);
274
- if (isExpanded) next.add(item.value); else next.delete(item.value);
275
- return next;
276
- });
277
- },
278
- }, h('summary', { className: 'mf-accordion-trigger', 'aria-disabled': item.disabled || undefined, tabIndex: item.disabled ? -1 : undefined, onClick: event => { if (item.disabled) event.preventDefault(); } }, item.title), h('div', { className: 'mf-accordion-content' }, item.content))));
279
- });
280
-
281
- /* ============================================================================
282
- * Layout, Shell & Theme Controls for Next.js Consumers
283
- * ========================================================================== */
284
-
285
- export const AppShell = element('div', 'mf-shell');
286
- export const Sidebar = element('aside', 'mf-sidebar');
287
- export const Main = element('main', 'mf-main');
288
- export const Header = element('header', 'mf-header');
289
- export const Nav = element('nav', 'mf-nav');
290
- export const Hero = element('section', 'mf-hero');
291
-
292
- export const Grid = forwardRef(function Grid({ columns, className, style, ...props }, ref) {
293
- const gridStyle = columns ? { ...style, gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` } : style;
294
- return h('div', { ...props, ref, className: cx('mf-grid', className), style: gridStyle });
295
- });
296
-
297
- export const NavItem = forwardRef(function NavItem({ active = false, asChild = false, href, className, children, ...props }, ref) {
298
- const shared = {
299
- ...props,
300
- ref,
301
- href,
302
- className: cx('mf-nav-item', className),
303
- 'aria-current': active ? 'page' : props['aria-current'],
304
- 'data-active': active ? 'true' : undefined,
305
- };
306
- if (asChild) return h(Slot, shared, children);
307
- if (href) return h('a', shared, children);
308
- return h('button', { type: 'button', ...shared }, children);
309
- });
310
-
311
- export const StatCard = forwardRef(function StatCard({ label, value, detail, icon, className, children, ...props }, ref) {
312
- return h('section', { ...props, ref, className: cx('mf-card mf-stat', className) },
313
- (label || icon) && h('div', { className: 'mf-stat-header' }, label && h('span', { className: 'mf-stat-label' }, label), icon),
314
- value !== undefined && h('strong', { className: 'mf-stat-value' }, value),
315
- detail && h('span', { className: 'mf-stat-detail' }, detail),
316
- children
317
- );
318
- });
319
-
320
- export const SkinSelector = forwardRef(function SkinSelector({ value, onValueChange, variant = 'select', label = 'Skin', className, ...props }, ref) {
321
- const theme = useTheme();
322
- const activeSkin = value ?? theme.skin;
323
- const setSkin = onValueChange ?? theme.setSkin;
324
-
325
- if (variant === 'list') {
326
- return h('div', { ...props, ref, role: 'group', 'aria-label': label, className: cx('mf-skin-selector-list', className) },
327
- skins.map(skin => h('button', {
328
- key: skin.id,
329
- type: 'button',
330
- className: 'mf-nav-item',
331
- 'aria-pressed': activeSkin === skin.id,
332
- 'data-active': activeSkin === skin.id ? 'true' : undefined,
333
- onClick: () => setSkin(skin.id),
334
- }, skin.name))
335
- );
336
- }
337
-
338
- return h(Select, {
339
- 'aria-label': label,
340
- ...props,
341
- ref,
342
- className,
343
- value: activeSkin,
344
- onChange: event => {
345
- props.onChange?.(event);
346
- setSkin(event.currentTarget.value);
347
- },
348
- }, skins.map(skin => h('option', { key: skin.id, value: skin.id }, skin.name)));
349
- });
350
-
351
- export const ModeSelector = forwardRef(function ModeSelector({ value, onValueChange, variant = 'select', label = 'Appearance', className, ...props }, ref) {
352
- const theme = useTheme();
353
- const activeMode = value ?? theme.mode;
354
- const setMode = onValueChange ?? theme.setMode;
355
- const modes = [
356
- { value: 'light', label: 'Light' },
357
- { value: 'dark', label: 'Dark' },
358
- { value: 'system', label: 'System' },
359
- ];
360
-
361
- if (variant === 'segmented') {
362
- return h('div', { ...props, ref, role: 'group', 'aria-label': label, className: cx('mf-mode-segmented', className) },
363
- modes.map(m => h('button', {
364
- key: m.value,
365
- type: 'button',
366
- className: 'mf-tabs-trigger',
367
- 'aria-pressed': activeMode === m.value,
368
- 'aria-selected': activeMode === m.value,
369
- onClick: () => setMode(m.value),
370
- }, m.label))
371
- );
372
- }
373
-
374
- return h(Select, {
375
- 'aria-label': label,
376
- ...props,
377
- ref,
378
- className,
379
- value: activeMode,
380
- onChange: event => {
381
- props.onChange?.(event);
382
- setMode(event.currentTarget.value);
383
- },
384
- }, modes.map(m => h('option', { key: m.value, value: m.value }, m.label)));
385
- });
386
-
387
- /* ============================================================================
388
- * Form Field & RadioGroup
389
- * ========================================================================== */
390
-
391
- export const FieldDescription = element('p', 'mf-field-description');
392
- export const FieldError = forwardRef(function FieldError({ className, role = 'alert', ...props }, ref) {
393
- return h('p', { ...props, role, ref, className: cx('mf-field-error', className) });
394
- });
395
-
396
- export const Field = forwardRef(function Field({ label, description, error, required = false, htmlFor, className, children, ...props }, ref) {
397
- const generatedId = useId();
398
- const controlId = htmlFor ?? `${generatedId}-control`;
399
- const descId = description ? `${generatedId}-desc` : undefined;
400
- const errId = error ? `${generatedId}-err` : undefined;
401
- const describedBy = [descId, errId].filter(Boolean).join(' ') || undefined;
402
-
403
- const enhancedChildren = React.Children.map(children, child => {
404
- if (!React.isValidElement(child)) return child;
405
- return React.cloneElement(child, {
406
- id: child.props.id ?? controlId,
407
- 'aria-describedby': [child.props['aria-describedby'], describedBy].filter(Boolean).join(' ') || undefined,
408
- 'aria-invalid': error ? true : child.props['aria-invalid'],
409
- required: required || child.props.required,
410
- });
411
- });
412
-
413
- return h('div', { ...props, ref, className: cx('mf-field', className) },
414
- label && h(Label, { htmlFor: controlId }, label, required && h('span', { 'aria-hidden': true, className: 'mf-field-required' }, ' *')),
415
- enhancedChildren,
416
- description && h(FieldDescription, { id: descId }, description),
417
- error && h(FieldError, { id: errId }, error)
418
- );
419
- });
420
-
421
- export const RadioGroup = forwardRef(function RadioGroup({ items = [], name, value, defaultValue, onValueChange, label, orientation = 'vertical', className, ...props }, ref) {
422
- const generatedName = useId();
423
- const groupName = name ?? generatedName;
424
- const [selected, setSelected] = useControllable(value, defaultValue ?? items.find(i => !i.disabled)?.value, onValueChange);
425
-
426
- return h('div', {
427
- ...props,
428
- ref,
429
- role: 'radiogroup',
430
- 'aria-label': label,
431
- 'data-orientation': orientation,
432
- className: cx('mf-radio-group', className),
433
- }, items.map(item => {
434
- const id = `${groupName}-${item.value}`;
435
- const isChecked = selected === item.value;
436
- return h('label', { key: item.value, htmlFor: id, className: 'mf-check-label mf-radio-option', 'data-disabled': item.disabled || undefined },
437
- h('input', {
438
- id,
439
- type: 'radio',
440
- name: groupName,
441
- value: item.value,
442
- checked: isChecked,
443
- disabled: item.disabled,
444
- className: 'mf-radio',
445
- onChange: () => setSelected(item.value),
446
- }),
447
- h('span', { className: 'mf-radio-copy' },
448
- h('span', { className: 'mf-radio-label' }, item.label),
449
- item.description && h('small', { className: 'mf-field-description' }, item.description)
450
- )
451
- );
452
- }));
453
- });
454
-
455
- /* ============================================================================
456
- * Navigation, Overlays, Feedback & Data Display
457
- * ========================================================================== */
458
-
459
- export const Breadcrumb = forwardRef(function Breadcrumb({ label = 'Breadcrumb', className, children, ...props }, ref) {
460
- return h('nav', { ...props, ref, 'aria-label': label, className: cx('mf-breadcrumb', className) },
461
- h('ol', { className: 'mf-breadcrumb-list' }, children)
462
- );
463
- });
464
-
465
- export const BreadcrumbItem = element('li', 'mf-breadcrumb-item');
466
-
467
- export const BreadcrumbLink = forwardRef(function BreadcrumbLink({ current = false, asChild = false, href, className, children, ...props }, ref) {
468
- const shared = {
469
- ...props,
470
- ref,
471
- href: current ? undefined : href,
472
- 'aria-current': current ? 'page' : undefined,
473
- className: cx('mf-breadcrumb-link', className),
474
- };
475
- if (asChild) return h(Slot, shared, children);
476
- if (current || !href) return h('span', shared, children);
477
- return h('a', shared, children);
478
- });
479
-
480
- export const Pagination = forwardRef(function Pagination({ page = 1, totalPages = 1, onPageChange, label = 'Pagination', className, ...props }, ref) {
481
- const total = Math.max(1, Number(totalPages) || 1);
482
- const current = Math.min(total, Math.max(1, Number(page) || 1));
483
- const pages = Array.from({ length: total }, (_, idx) => idx + 1);
484
-
485
- return h('nav', { ...props, ref, 'aria-label': label, className: cx('mf-pagination', className) },
486
- h(Button, {
487
- variant: 'secondary',
488
- size: 'sm',
489
- disabled: current <= 1,
490
- onClick: () => onPageChange?.(current - 1),
491
- }, 'Previous'),
492
- h('div', { className: 'mf-pagination-pages' },
493
- pages.map(num => h(Button, {
494
- key: num,
495
- variant: num === current ? 'primary' : 'ghost',
496
- size: 'sm',
497
- 'aria-current': num === current ? 'page' : undefined,
498
- onClick: () => onPageChange?.(num),
499
- }, String(num)))
500
- ),
501
- h(Button, {
502
- variant: 'secondary',
503
- size: 'sm',
504
- disabled: current >= total,
505
- onClick: () => onPageChange?.(current + 1),
506
- }, 'Next')
507
- );
508
- });
509
-
510
- export const Drawer = forwardRef(function Drawer({ side = 'right', className, ...props }, ref) {
511
- return h(Dialog, {
512
- ...props,
513
- ref,
514
- 'data-side': side,
515
- className: cx('mf-drawer', className),
516
- });
517
- });
518
-
519
- export const Popover = forwardRef(function Popover({ trigger, title, open, defaultOpen = false, onOpenChange, align = 'start', className, children, ...props }, ref) {
520
- const id = useId();
521
- const wrapperRef = useRef(null);
522
- const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
523
-
524
- useEffect(() => {
525
- if (!isOpen) return;
526
- const onPointerDown = (event) => {
527
- if (wrapperRef.current && !wrapperRef.current.contains(event.target)) setOpen(false);
528
- };
529
- const onKeyDown = (event) => {
530
- if (event.key === 'Escape') setOpen(false);
531
- };
532
- document.addEventListener('pointerdown', onPointerDown);
533
- document.addEventListener('keydown', onKeyDown);
534
- return () => {
535
- document.removeEventListener('pointerdown', onPointerDown);
536
- document.removeEventListener('keydown', onKeyDown);
537
- };
538
- }, [isOpen, setOpen]);
539
-
540
- const triggerElement = React.isValidElement(trigger) ? React.cloneElement(trigger, {
541
- 'aria-expanded': Boolean(isOpen),
542
- 'aria-controls': `${id}-popover`,
543
- onClick: event => {
544
- trigger.props.onClick?.(event);
545
- if (!event.defaultPrevented) setOpen(!isOpen);
546
- },
547
- }) : null;
548
-
549
- return h('div', { ref: mergeRefs(wrapperRef, ref), className: cx('mf-popover-root', className) },
550
- triggerElement,
551
- isOpen && h('div', {
552
- ...props,
553
- id: `${id}-popover`,
554
- role: 'dialog',
555
- 'aria-label': typeof title === 'string' ? title : undefined,
556
- 'data-align': align,
557
- className: 'mf-popover-content',
558
- }, title && h('strong', { className: 'mf-popover-title' }, title), children)
559
- );
560
- });
561
-
562
- export const DropdownMenu = forwardRef(function DropdownMenu({ trigger, items = [], label = 'Menu', align = 'start', className, ...props }, ref) {
563
- const id = useId();
564
- const wrapperRef = useRef(null);
565
- const itemRefs = useRef([]);
566
- const [isOpen, setOpen] = useState(false);
567
-
568
- useEffect(() => {
569
- if (!isOpen) return;
570
- const onPointerDown = (event) => {
571
- if (wrapperRef.current && !wrapperRef.current.contains(event.target)) setOpen(false);
572
- };
573
- const onKeyDown = (event) => {
574
- if (event.key === 'Escape') setOpen(false);
575
- };
576
- document.addEventListener('pointerdown', onPointerDown);
577
- document.addEventListener('keydown', onKeyDown);
578
- return () => {
579
- document.removeEventListener('pointerdown', onPointerDown);
580
- document.removeEventListener('keydown', onKeyDown);
581
- };
582
- }, [isOpen]);
583
-
584
- function onMenuKeyDown(event, index) {
585
- const enabled = items.map((it, i) => it.disabled ? -1 : i).filter(i => i >= 0);
586
- if (!enabled.length) return;
587
- const pos = enabled.indexOf(index);
588
- if (event.key === 'ArrowDown') {
589
- event.preventDefault();
590
- itemRefs.current[enabled[(pos + 1) % enabled.length]]?.focus();
591
- } else if (event.key === 'ArrowUp') {
592
- event.preventDefault();
593
- itemRefs.current[enabled[(pos - 1 + enabled.length) % enabled.length]]?.focus();
594
- } else if (event.key === 'Home') {
595
- event.preventDefault();
596
- itemRefs.current[enabled[0]]?.focus();
597
- } else if (event.key === 'End') {
598
- event.preventDefault();
599
- itemRefs.current[enabled.at(-1)]?.focus();
600
- }
601
- }
602
-
603
- const triggerElement = React.isValidElement(trigger) ? React.cloneElement(trigger, {
604
- 'aria-haspopup': 'menu',
605
- 'aria-expanded': isOpen,
606
- 'aria-controls': `${id}-menu`,
607
- onClick: event => {
608
- trigger.props.onClick?.(event);
609
- if (!event.defaultPrevented) setOpen(prev => !prev);
610
- },
611
- }) : null;
612
-
613
- return h('div', { ref: mergeRefs(wrapperRef, ref), className: cx('mf-popover-root', className) },
614
- triggerElement,
615
- isOpen && h('div', {
616
- ...props,
617
- id: `${id}-menu`,
618
- role: 'menu',
619
- 'aria-label': label,
620
- 'data-align': align,
621
- className: 'mf-popover-content mf-dropdown-menu',
622
- }, items.map((item, index) => h('button', {
623
- key: item.value ?? index,
624
- ref: node => { itemRefs.current[index] = node; },
625
- type: 'button',
626
- role: 'menuitem',
627
- disabled: item.disabled,
628
- 'data-variant': item.variant,
629
- className: 'mf-dropdown-item',
630
- onKeyDown: event => onMenuKeyDown(event, index),
631
- onClick: () => {
632
- if (item.disabled) return;
633
- item.onSelect?.(item.value);
634
- setOpen(false);
635
- },
636
- }, item.label)))
637
- );
638
- });
639
-
640
- export const Tooltip = forwardRef(function Tooltip({ content, className, children, ...props }, ref) {
641
- const id = useId();
642
- const [visible, setVisible] = useState(false);
643
- const trigger = React.isValidElement(children) ? React.cloneElement(children, {
644
- 'aria-describedby': visible ? id : children.props['aria-describedby'],
645
- onMouseEnter: e => { children.props.onMouseEnter?.(e); setVisible(true); },
646
- onMouseLeave: e => { children.props.onMouseLeave?.(e); setVisible(false); },
647
- onFocus: e => { children.props.onFocus?.(e); setVisible(true); },
648
- onBlur: e => { children.props.onBlur?.(e); setVisible(false); },
649
- onKeyDown: e => {
650
- children.props.onKeyDown?.(e);
651
- if (e.key === 'Escape') setVisible(false);
652
- },
653
- }) : children;
654
-
655
- return h('span', { ...props, ref, className: cx('mf-tooltip-root', className) },
656
- trigger,
657
- visible && h('span', { id, role: 'tooltip', className: 'mf-tooltip-bubble' }, content)
658
- );
659
- });
660
-
661
- export const EmptyState = forwardRef(function EmptyState({ icon, title, description, action, className, children, ...props }, ref) {
662
- return h('div', { ...props, ref, className: cx('mf-empty-state', className) },
663
- icon && h('div', { className: 'mf-empty-icon', 'aria-hidden': true }, icon),
664
- title && h('strong', { className: 'mf-empty-title' }, title),
665
- description && h('p', { className: 'mf-empty-description' }, description),
666
- action && h('div', { className: 'mf-empty-action' }, action),
667
- children
668
- );
669
- });
670
-
671
- export const Kbd = element('kbd', 'mf-kbd');
672
-
673
- export const CodeBlock = forwardRef(function CodeBlock({ code, language, className, children, ...props }, ref) {
674
- return h('pre', { ...props, ref, 'data-language': language, className: cx('mf-code-block', className) },
675
- h('code', null, code ?? children)
676
- );
677
- });
678
-
679
- const ToastContext = createContext(null);
680
-
681
- export function ToastProvider({ children }) {
682
- const [toasts, setToasts] = useState([]);
683
- const dismiss = useCallback((id) => {
684
- setToasts(prev => prev.filter(item => item.id !== id));
685
- }, []);
686
- const toast = useCallback(({ title, description, variant = 'secondary', duration = 4500 }) => {
687
- const id = Math.random().toString(36).slice(2, 10);
688
- setToasts(prev => [...prev, { id, title, description, variant }]);
689
- if (duration > 0 && typeof window !== 'undefined') {
690
- window.setTimeout(() => dismiss(id), duration);
691
- }
692
- return id;
693
- }, [dismiss]);
694
-
695
- const value = useMemo(() => ({ toasts, toast, dismiss }), [toasts, toast, dismiss]);
696
-
697
- return h(ToastContext.Provider, { value },
698
- children,
699
- h('div', { className: 'mf-toast-viewport', role: 'status', 'aria-live': 'polite', 'aria-atomic': 'true' },
700
- toasts.map(item => h('div', { key: item.id, className: 'mf-toast', 'data-variant': item.variant },
701
- h('div', { className: 'mf-toast-body' },
702
- item.title && h('strong', { className: 'mf-toast-title' }, item.title),
703
- item.description && h('div', { className: 'mf-toast-description' }, item.description)
704
- ),
705
- h('button', { type: 'button', className: 'mf-toast-close', 'aria-label': 'Dismiss notification', onClick: () => dismiss(item.id) }, '×')
706
- ))
707
- )
708
- );
709
- }
710
-
711
- export function useToast() {
712
- const ctx = useContext(ToastContext);
713
- if (!ctx) throw new Error('useToast must be used within a Moonframe ToastProvider.');
714
- return ctx;
715
- }
716
-
717
- /**
718
- * Interactive DataTable component for Next.js data workspaces.
719
- * Supports searching, column sorting, pagination, and empty state out of the box.
720
- */
721
- export const DataTable = forwardRef(function DataTable({
722
- columns = [],
723
- data = [],
724
- rowKey = 'id',
725
- caption,
726
- searchable = false,
727
- searchPlaceholder = 'Search records…',
728
- emptyTitle = 'No matching records',
729
- emptyDescription = 'Try adjusting your search or filter criteria.',
730
- pageSize = 0,
731
- className,
732
- ...props
733
- }, ref) {
734
- const [query, setQuery] = useState('');
735
- const [sortBy, setSortBy] = useState(null);
736
- const [sortDirection, setSortDirection] = useState('asc');
737
- const [page, setPage] = useState(1);
738
-
739
- const filtered = useMemo(() => {
740
- const q = query.trim().toLowerCase();
741
- const rows = !q
742
- ? [...data]
743
- : data.filter(row => columns.some(col => {
744
- const val = col.accessor ? col.accessor(row) : row?.[col.key];
745
- return val != null && String(val).toLowerCase().includes(q);
746
- }));
747
-
748
- if (sortBy) {
749
- const col = columns.find(c => c.key === sortBy);
750
- rows.sort((a, b) => {
751
- const av = col?.accessor ? col.accessor(a) : a?.[sortBy];
752
- const bv = col?.accessor ? col.accessor(b) : b?.[sortBy];
753
- const cmp = typeof av === 'number' && typeof bv === 'number'
754
- ? av - bv
755
- : String(av ?? '').localeCompare(String(bv ?? ''));
756
- return sortDirection === 'asc' ? cmp : -cmp;
757
- });
758
- }
759
- return rows;
760
- }, [data, columns, query, sortBy, sortDirection]);
761
-
762
- const totalPages = pageSize > 0 ? Math.max(1, Math.ceil(filtered.length / pageSize)) : 1;
763
- const effectivePage = Math.min(page, totalPages);
764
- const visibleRows = pageSize > 0
765
- ? filtered.slice((effectivePage - 1) * pageSize, effectivePage * pageSize)
766
- : filtered;
767
-
768
- function toggleSort(key) {
769
- if (sortBy === key) {
770
- setSortDirection(prev => prev === 'asc' ? 'desc' : 'asc');
771
- } else {
772
- setSortBy(key);
773
- setSortDirection('asc');
774
- }
775
- }
776
-
777
- return h('div', { ...props, ref, className: cx('mf-data-table', className) },
778
- searchable && h('div', { className: 'mf-data-table-toolbar' },
779
- h(Input, {
780
- type: 'search',
781
- 'aria-label': searchPlaceholder,
782
- placeholder: searchPlaceholder,
783
- value: query,
784
- onChange: e => { setQuery(e.currentTarget.value); setPage(1); },
785
- })
786
- ),
787
- h('div', { className: 'mf-table-wrapper' },
788
- h(Table, null,
789
- caption && h(TableCaption, null, caption),
790
- h(TableHeader, null,
791
- h(TableRow, null,
792
- columns.map(col => h(TableHead, {
793
- key: col.key,
794
- 'aria-sort': sortBy === col.key ? (sortDirection === 'asc' ? 'ascending' : 'descending') : undefined,
795
- }, col.sortable
796
- ? h('button', {
797
- type: 'button',
798
- className: 'mf-table-sort',
799
- onClick: () => toggleSort(col.key),
800
- }, col.header, sortBy === col.key ? (sortDirection === 'asc' ? ' ↑' : ' ↓') : '')
801
- : col.header))
802
- )
803
- ),
804
- h(TableBody, null,
805
- visibleRows.length > 0
806
- ? visibleRows.map((row, index) => {
807
- const key = typeof rowKey === 'function' ? rowKey(row, index) : (row?.[rowKey] ?? index);
808
- return h(TableRow, { key },
809
- columns.map(col => h(TableCell, { key: col.key },
810
- col.render ? col.render(row, index) : String((col.accessor ? col.accessor(row) : row?.[col.key]) ?? '')
811
- ))
812
- );
813
- })
814
- : h(TableRow, null,
815
- h(TableCell, { colSpan: Math.max(1, columns.length) },
816
- h(EmptyState, { title: emptyTitle, description: emptyDescription })
817
- )
818
- )
819
- )
820
- )
821
- ),
822
- pageSize > 0 && totalPages > 1 && h('div', { className: 'mf-data-table-footer' },
823
- h(Pagination, { page: effectivePage, totalPages, onPageChange: setPage })
824
- )
825
- );
826
- });
827
-
828
- /* ============================================================================
829
- * Extended Inputs, Charts, Navigation & Level C Reusable Composite Blocks
830
- * ========================================================================== */
831
-
832
- export const OTPInput = forwardRef(function OTPInput({
833
- length = 6,
834
- value,
835
- defaultValue = '',
836
- onValueChange,
837
- onComplete,
838
- disabled = false,
839
- label = 'Verification code',
840
- className,
841
- ...props
842
- }, ref) {
843
- const count = Math.max(4, Math.min(8, Number(length) || 6));
844
- const [code, setCode] = useControllable(value, defaultValue, onValueChange);
845
- const inputsRef = useRef([]);
846
- const digits = Array.from({ length: count }, (_, idx) => (code || '')[idx] || '');
847
-
848
- function updateAt(index, char) {
849
- const clean = char.replace(/\D/g, '').slice(-1);
850
- const next = digits.slice();
851
- next[index] = clean;
852
- const joined = next.join('');
853
- setCode(joined);
854
- if (clean && index < count - 1) {
855
- inputsRef.current[index + 1]?.focus();
856
- }
857
- if (joined.length === count && !next.includes('')) {
858
- onComplete?.(joined);
859
- }
860
- }
861
-
862
- function onPaste(event) {
863
- const pasted = (event.clipboardData?.getData('text') || '').replace(/\D/g, '').slice(0, count);
864
- if (!pasted) return;
865
- event.preventDefault();
866
- setCode(pasted);
867
- const focusIdx = Math.min(pasted.length, count - 1);
868
- inputsRef.current[focusIdx]?.focus();
869
- if (pasted.length === count) {
870
- onComplete?.(pasted);
871
- }
872
- }
873
-
874
- return h('div', {
875
- ...props,
876
- ref,
877
- role: 'group',
878
- 'aria-label': label,
879
- className: cx('mf-otp-group', className),
880
- }, digits.map((digit, index) => h('input', {
881
- key: index,
882
- ref: node => { inputsRef.current[index] = node; },
883
- type: 'text',
884
- inputMode: 'numeric',
885
- pattern: '[0-9]*',
886
- maxLength: 1,
887
- disabled,
888
- value: digit,
889
- autoComplete: index === 0 ? 'one-time-code' : 'off',
890
- 'aria-label': `${label} digit ${index + 1} of ${count}`,
891
- className: 'mf-input mf-otp-slot',
892
- onPaste,
893
- onChange: e => updateAt(index, e.currentTarget.value),
894
- onKeyDown: e => {
895
- if (e.key === 'Backspace' && !digit && index > 0) {
896
- inputsRef.current[index - 1]?.focus();
897
- } else if (e.key === 'ArrowLeft' && index > 0) {
898
- e.preventDefault();
899
- inputsRef.current[index - 1]?.focus();
900
- } else if (e.key === 'ArrowRight' && index < count - 1) {
901
- e.preventDefault();
902
- inputsRef.current[index + 1]?.focus();
903
- }
904
- },
905
- })));
906
- });
907
-
908
- export const PasswordField = forwardRef(function PasswordField({
909
- defaultVisible = false,
910
- showStrength = false,
911
- toggleLabel,
912
- value,
913
- defaultValue,
914
- onChange,
915
- className,
916
- ...props
917
- }, ref) {
918
- const [visible, setVisible] = useState(defaultVisible);
919
- const [internal, setInternal] = useState(defaultValue ?? '');
920
- const current = value !== undefined ? String(value) : String(internal);
921
-
922
- const score = useMemo(() => {
923
- if (!current) return 0;
924
- let pts = 0;
925
- if (current.length >= 8) pts += 1;
926
- if (/[A-Z]/.test(current) && /[a-z]/.test(current)) pts += 1;
927
- if (/\d/.test(current)) pts += 1;
928
- if (/[^A-Za-z0-9]/.test(current)) pts += 1;
929
- return pts;
930
- }, [current]);
931
-
932
- const strengthLabels = ['Too short', 'Weak', 'Fair', 'Good', 'Strong'];
933
-
934
- return h('div', { className: cx('mf-password-root', className) },
935
- h('div', { className: 'mf-password-row' },
936
- h(Input, {
937
- ...props,
938
- ref,
939
- type: visible ? 'text' : 'password',
940
- value: value !== undefined ? value : internal,
941
- onChange: e => {
942
- if (value === undefined) setInternal(e.currentTarget.value);
943
- onChange?.(e);
944
- },
945
- }),
946
- h(Button, {
947
- type: 'button',
948
- variant: 'secondary',
949
- size: 'sm',
950
- className: 'mf-password-toggle',
951
- 'aria-label': toggleLabel ?? (visible ? 'Hide password' : 'Show password'),
952
- onClick: () => setVisible(v => !v),
953
- }, visible ? 'Hide' : 'Show')
954
- ),
955
- showStrength && h('div', { className: 'mf-password-strength', 'aria-live': 'polite' },
956
- h('div', { className: 'mf-password-bars' },
957
- [1, 2, 3, 4].map(level => h('span', {
958
- key: level,
959
- className: 'mf-password-bar',
960
- 'data-active': score >= level ? 'true' : undefined,
961
- }))
962
- ),
963
- h('span', { className: 'mf-field-description' }, strengthLabels[score])
964
- )
965
- );
966
- });
967
-
968
- export const SearchInput = forwardRef(function SearchInput({
969
- value,
970
- defaultValue = '',
971
- onValueChange,
972
- onClear,
973
- shortcut,
974
- placeholder = 'Search…',
975
- className,
976
- onChange,
977
- ...props
978
- }, ref) {
979
- const [query, setQuery] = useControllable(value, defaultValue, onValueChange);
980
-
981
- return h('div', { className: cx('mf-search-input-wrap', className) },
982
- h('span', { className: 'mf-search-icon', 'aria-hidden': true }, '⌕'),
983
- h(Input, {
984
- ...props,
985
- ref,
986
- type: 'search',
987
- placeholder,
988
- value: query,
989
- className: 'mf-search-input',
990
- onChange: e => {
991
- setQuery(e.currentTarget.value);
992
- onChange?.(e);
993
- },
994
- onKeyDown: e => {
995
- props.onKeyDown?.(e);
996
- if (e.key === 'Escape' && query) {
997
- setQuery('');
998
- onClear?.();
999
- }
1000
- },
1001
- }),
1002
- query
1003
- ? h('button', {
1004
- type: 'button',
1005
- className: 'mf-search-clear',
1006
- 'aria-label': 'Clear search',
1007
- onClick: () => {
1008
- setQuery('');
1009
- onClear?.();
1010
- },
1011
- }, '×')
1012
- : shortcut && h(Kbd, { className: 'mf-search-shortcut' }, shortcut)
1013
- );
1014
- });
1015
-
1016
- export const Slider = forwardRef(function Slider({
1017
- min = 0,
1018
- max = 100,
1019
- step = 1,
1020
- value,
1021
- defaultValue = 50,
1022
- onValueChange,
1023
- label,
1024
- showValue = false,
1025
- formatValue,
1026
- className,
1027
- onChange,
1028
- ...props
1029
- }, ref) {
1030
- const [current, setCurrent] = useControllable(value, defaultValue, onValueChange);
1031
- const display = formatValue ? formatValue(Number(current)) : `${current}`;
1032
-
1033
- return h('div', { className: cx('mf-slider-wrap', className) },
1034
- (label || showValue) && h('div', { className: 'mf-slider-header' },
1035
- label && h('span', { className: 'mf-label' }, label),
1036
- showValue && h('output', { className: 'mf-slider-output' }, display)
1037
- ),
1038
- h('input', {
1039
- ...props,
1040
- ref,
1041
- type: 'range',
1042
- min,
1043
- max,
1044
- step,
1045
- value: current,
1046
- 'aria-label': props['aria-label'] ?? (typeof label === 'string' ? label : 'Slider'),
1047
- className: 'mf-slider',
1048
- onChange: e => {
1049
- const next = Number(e.currentTarget.value);
1050
- setCurrent(next);
1051
- onChange?.(e);
1052
- },
1053
- })
1054
- );
1055
- });
1056
-
1057
- export const TagInput = forwardRef(function TagInput({
1058
- value,
1059
- defaultValue = [],
1060
- onValueChange,
1061
- placeholder = 'Add tag and press Enter…',
1062
- disabled = false,
1063
- label = 'Tags',
1064
- className,
1065
- ...props
1066
- }, ref) {
1067
- const [tags, setTags] = useControllable(value, defaultValue, onValueChange);
1068
- const [draft, setDraft] = useState('');
1069
-
1070
- function addTag(raw) {
1071
- const trimmed = String(raw || '').trim();
1072
- if (!trimmed) return;
1073
- if (!tags.includes(trimmed)) {
1074
- setTags([...tags, trimmed]);
1075
- }
1076
- setDraft('');
1077
- }
1078
-
1079
- function removeTag(target) {
1080
- setTags(tags.filter(t => t !== target));
1081
- }
1082
-
1083
- return h('div', {
1084
- ...props,
1085
- ref,
1086
- role: 'group',
1087
- 'aria-label': label,
1088
- className: cx('mf-tag-input', className),
1089
- },
1090
- tags.map(tag => h(Badge, { key: tag, variant: 'secondary', className: 'mf-tag-chip' },
1091
- h('span', null, tag),
1092
- !disabled && h('button', {
1093
- type: 'button',
1094
- className: 'mf-tag-remove',
1095
- 'aria-label': `Remove ${tag}`,
1096
- onClick: () => removeTag(tag),
1097
- }, '×')
1098
- )),
1099
- h('input', {
1100
- type: 'text',
1101
- disabled,
1102
- value: draft,
1103
- placeholder,
1104
- 'aria-label': placeholder,
1105
- className: 'mf-tag-field',
1106
- onChange: e => setDraft(e.currentTarget.value),
1107
- onKeyDown: e => {
1108
- if (e.key === 'Enter' || e.key === ',') {
1109
- e.preventDefault();
1110
- addTag(draft);
1111
- } else if (e.key === 'Backspace' && !draft && tags.length > 0) {
1112
- removeTag(tags[tags.length - 1]);
1113
- }
1114
- },
1115
- onBlur: () => {
1116
- if (draft.trim()) addTag(draft);
1117
- },
1118
- })
1119
- );
1120
- });
1121
-
1122
- export const SegmentedControl = forwardRef(function SegmentedControl({
1123
- items = [],
1124
- value,
1125
- defaultValue,
1126
- onValueChange,
1127
- label = 'Options',
1128
- size = 'md',
1129
- className,
1130
- ...props
1131
- }, ref) {
1132
- const [selected, setSelected] = useControllable(
1133
- value,
1134
- defaultValue ?? items.find(i => !i.disabled)?.value,
1135
- onValueChange,
1136
- );
1137
-
1138
- return h('div', {
1139
- ...props,
1140
- ref,
1141
- role: 'group',
1142
- 'aria-label': label,
1143
- 'data-size': size,
1144
- className: cx('mf-segmented', className),
1145
- }, items.map(item => {
1146
- const active = selected === item.value;
1147
- return h('button', {
1148
- key: item.value,
1149
- type: 'button',
1150
- disabled: item.disabled,
1151
- 'aria-pressed': active,
1152
- 'data-active': active ? 'true' : undefined,
1153
- className: 'mf-segmented-item',
1154
- onClick: () => setSelected(item.value),
1155
- }, item.label);
1156
- }));
1157
- });
1158
-
1159
- export const FileDropzone = forwardRef(function FileDropzone({
1160
- accept,
1161
- multiple = false,
1162
- disabled = false,
1163
- title = 'Drop files here or click to browse',
1164
- description = 'Supports standard documents and media files.',
1165
- onFilesSelected,
1166
- className,
1167
- ...props
1168
- }, ref) {
1169
- const inputRef = useRef(null);
1170
- const [dragging, setDragging] = useState(false);
1171
- const [selectedNames, setSelectedNames] = useState([]);
1172
-
1173
- function handleFiles(fileList) {
1174
- if (!fileList || disabled) return;
1175
- const files = Array.from(fileList);
1176
- setSelectedNames(files.map(f => f.name));
1177
- onFilesSelected?.(files);
1178
- }
1179
-
1180
- return h('div', {
1181
- ...props,
1182
- ref,
1183
- role: 'button',
1184
- tabIndex: disabled ? -1 : 0,
1185
- 'aria-disabled': disabled || undefined,
1186
- 'data-dragging': dragging ? 'true' : undefined,
1187
- className: cx('mf-dropzone', className),
1188
- onClick: () => { if (!disabled) inputRef.current?.click(); },
1189
- onKeyDown: e => {
1190
- if (!disabled && (e.key === 'Enter' || e.key === ' ')) {
1191
- e.preventDefault();
1192
- inputRef.current?.click();
1193
- }
1194
- },
1195
- onDragOver: e => {
1196
- e.preventDefault();
1197
- if (!disabled) setDragging(true);
1198
- },
1199
- onDragLeave: () => setDragging(false),
1200
- onDrop: e => {
1201
- e.preventDefault();
1202
- setDragging(false);
1203
- handleFiles(e.dataTransfer?.files);
1204
- },
1205
- },
1206
- h('input', {
1207
- ref: inputRef,
1208
- type: 'file',
1209
- accept,
1210
- multiple,
1211
- disabled,
1212
- hidden: true,
1213
- onChange: e => handleFiles(e.currentTarget.files),
1214
- }),
1215
- h('strong', { className: 'mf-dropzone-title' }, title),
1216
- description && h('span', { className: 'mf-dropzone-description' }, description),
1217
- selectedNames.length > 0 && h('div', { className: 'mf-dropzone-files' },
1218
- selectedNames.map(name => h(Badge, { key: name, variant: 'primary' }, name))
1219
- )
1220
- );
1221
- });
1222
-
1223
- export const BarChart = forwardRef(function BarChart({
1224
- data = [],
1225
- height = 180,
1226
- label = 'Bar chart',
1227
- formatValue,
1228
- className,
1229
- ...props
1230
- }, ref) {
1231
- const maxVal = Math.max(1, ...data.map(d => Number(d.value) || 0));
1232
- const width = Math.max(240, data.length * 56);
1233
- const chartHeight = Math.max(120, Number(height) || 180);
1234
- const plotHeight = chartHeight - 36;
1235
-
1236
- return h('div', { ...props, ref, className: cx('mf-chart-wrap', className) },
1237
- h('svg', {
1238
- role: 'img',
1239
- 'aria-label': label,
1240
- viewBox: `0 0 ${width} ${chartHeight}`,
1241
- className: 'mf-bar-chart',
1242
- },
1243
- h('title', null, label),
1244
- data.map((item, index) => {
1245
- const val = Math.max(0, Number(item.value) || 0);
1246
- const barHeight = Math.max(4, Math.round((val / maxVal) * (plotHeight - 20)));
1247
- const slotWidth = width / Math.max(1, data.length);
1248
- const barWidth = Math.max(16, Math.min(40, slotWidth * 0.58));
1249
- const x = index * slotWidth + (slotWidth - barWidth) / 2;
1250
- const y = plotHeight - barHeight;
1251
- return h('g', { key: item.label ?? index, className: 'mf-bar-group' },
1252
- h('rect', {
1253
- x,
1254
- y,
1255
- width: barWidth,
1256
- height: barHeight,
1257
- rx: 3,
1258
- className: 'mf-bar-rect',
1259
- 'data-tone': item.tone,
1260
- }),
1261
- h('text', {
1262
- x: x + barWidth / 2,
1263
- y: Math.max(12, y - 6),
1264
- textAnchor: 'middle',
1265
- className: 'mf-bar-value',
1266
- }, formatValue ? formatValue(val) : String(val)),
1267
- h('text', {
1268
- x: x + barWidth / 2,
1269
- y: chartHeight - 10,
1270
- textAnchor: 'middle',
1271
- className: 'mf-bar-label',
1272
- }, item.label)
1273
- );
1274
- })
1275
- )
1276
- );
1277
- });
1278
-
1279
- export const Sparkline = forwardRef(function Sparkline({
1280
- data = [],
1281
- width = 120,
1282
- height = 36,
1283
- label = 'Trend sparkline',
1284
- variant = 'primary',
1285
- className,
1286
- ...props
1287
- }, ref) {
1288
- const points = data.length >= 2 ? data.map(Number) : [0, 0];
1289
- const min = Math.min(...points);
1290
- const max = Math.max(...points);
1291
- const span = max - min || 1;
1292
- const pad = 4;
1293
- const w = Math.max(48, Number(width) || 120);
1294
- const hgt = Math.max(20, Number(height) || 36);
1295
-
1296
- const coords = points.map((val, idx) => {
1297
- const x = pad + (idx / (points.length - 1)) * (w - pad * 2);
1298
- const y = hgt - pad - ((val - min) / span) * (hgt - pad * 2);
1299
- return [Number(x.toFixed(1)), Number(y.toFixed(1))];
1300
- });
1301
- const polyline = coords.map(([x, y]) => `${x},${y}`).join(' ');
1302
- const area = `${coords[0][0]},${hgt - pad} ${polyline} ${coords[coords.length - 1][0]},${hgt - pad}`;
1303
-
1304
- return h('svg', {
1305
- ...props,
1306
- ref,
1307
- role: 'img',
1308
- 'aria-label': label,
1309
- viewBox: `0 0 ${w} ${hgt}`,
1310
- width: w,
1311
- height: hgt,
1312
- 'data-variant': variant,
1313
- className: cx('mf-sparkline', className),
1314
- },
1315
- h('title', null, label),
1316
- h('polygon', { points: area, className: 'mf-sparkline-area' }),
1317
- h('polyline', { points: polyline, fill: 'none', className: 'mf-sparkline-line' })
1318
- );
1319
- });
1320
-
1321
- export const Stepper = forwardRef(function Stepper({
1322
- steps = [],
1323
- currentStep = 0,
1324
- orientation = 'horizontal',
1325
- label = 'Progress steps',
1326
- className,
1327
- ...props
1328
- }, ref) {
1329
- return h('ol', {
1330
- ...props,
1331
- ref,
1332
- 'aria-label': label,
1333
- 'data-orientation': orientation,
1334
- className: cx('mf-stepper', className),
1335
- }, steps.map((step, index) => {
1336
- const status = step.status ?? (index < currentStep ? 'complete' : index === currentStep ? 'current' : 'upcoming');
1337
- return h('li', {
1338
- key: step.id ?? step.title ?? index,
1339
- 'aria-current': status === 'current' ? 'step' : undefined,
1340
- 'data-status': status,
1341
- className: 'mf-stepper-item',
1342
- },
1343
- h('span', { className: 'mf-stepper-indicator', 'aria-hidden': true },
1344
- status === 'complete' ? '✓' : String(index + 1)
1345
- ),
1346
- h('div', { className: 'mf-stepper-copy' },
1347
- h('strong', { className: 'mf-stepper-title' }, step.title),
1348
- step.description && h('span', { className: 'mf-stepper-description' }, step.description)
1349
- )
1350
- );
1351
- }));
1352
- });
1353
-
1354
- export const Timeline = forwardRef(function Timeline({
1355
- items = [],
1356
- className,
1357
- ...props
1358
- }, ref) {
1359
- return h('ol', { ...props, ref, className: cx('mf-timeline', className) },
1360
- items.map((item, index) => h('li', {
1361
- key: item.id ?? index,
1362
- 'data-tone': item.tone,
1363
- className: 'mf-timeline-item',
1364
- },
1365
- h('span', { className: 'mf-timeline-marker', 'aria-hidden': true }, item.icon ?? '•'),
1366
- h('div', { className: 'mf-timeline-body' },
1367
- h('div', { className: 'mf-timeline-header' },
1368
- h('strong', { className: 'mf-timeline-title' }, item.title),
1369
- item.badge && h(Badge, { variant: item.tone ?? 'secondary' }, item.badge),
1370
- item.time && h('time', { className: 'mf-timeline-time' }, item.time)
1371
- ),
1372
- item.description && h('p', { className: 'mf-timeline-description' }, item.description)
1373
- )
1374
- ))
1375
- );
1376
- });
1377
-
1378
- export const AvatarGroup = forwardRef(function AvatarGroup({
1379
- items = [],
1380
- max = 4,
1381
- label = 'Team members',
1382
- className,
1383
- ...props
1384
- }, ref) {
1385
- const limit = Math.max(1, Number(max) || 4);
1386
- const visible = items.slice(0, limit);
1387
- const remaining = Math.max(0, items.length - visible.length);
1388
-
1389
- return h('div', {
1390
- ...props,
1391
- ref,
1392
- role: 'group',
1393
- 'aria-label': label,
1394
- className: cx('mf-avatar-group', className),
1395
- },
1396
- visible.map((item, idx) => h(Avatar, {
1397
- key: item.id ?? item.alt ?? idx,
1398
- src: item.src,
1399
- alt: item.alt,
1400
- fallback: item.fallback,
1401
- className: 'mf-avatar-group-item',
1402
- })),
1403
- remaining > 0 && h('span', {
1404
- className: 'mf-avatar mf-avatar-group-item mf-avatar-overflow',
1405
- 'aria-label': `${remaining} more members`,
1406
- }, `+${remaining}`)
1407
- );
1408
- });
1409
-
1410
- export const DescriptionTerm = element('dt', 'mf-dl-term');
1411
- export const DescriptionDetails = element('dd', 'mf-dl-details');
1412
-
1413
- export const DescriptionList = forwardRef(function DescriptionList({
1414
- items,
1415
- columns = 2,
1416
- className,
1417
- children,
1418
- ...props
1419
- }, ref) {
1420
- return h('dl', {
1421
- ...props,
1422
- ref,
1423
- 'data-columns': columns,
1424
- className: cx('mf-dl', className),
1425
- },
1426
- Array.isArray(items)
1427
- ? items.map((item, idx) => h('div', { key: item.term ?? idx, className: 'mf-dl-row' },
1428
- h(DescriptionTerm, null, item.term),
1429
- h(DescriptionDetails, null, item.details)
1430
- ))
1431
- : children
1432
- );
1433
- });
1434
-
1435
- export const Callout = forwardRef(function Callout({
1436
- title,
1437
- variant = 'secondary',
1438
- icon,
1439
- action,
1440
- dismissible = false,
1441
- onDismiss,
1442
- className,
1443
- children,
1444
- ...props
1445
- }, ref) {
1446
- const [dismissed, setDismissed] = useState(false);
1447
- if (dismissed) return null;
1448
-
1449
- return h('section', {
1450
- ...props,
1451
- ref,
1452
- role: 'region',
1453
- 'aria-label': typeof title === 'string' ? title : 'Notice',
1454
- 'data-variant': variant,
1455
- className: cx('mf-callout', className),
1456
- },
1457
- icon && h('span', { className: 'mf-callout-icon', 'aria-hidden': true }, icon),
1458
- h('div', { className: 'mf-callout-body' },
1459
- title && h('strong', { className: 'mf-callout-title' }, title),
1460
- children && h('div', { className: 'mf-callout-content' }, children)
1461
- ),
1462
- action && h('div', { className: 'mf-callout-action' }, action),
1463
- dismissible && h('button', {
1464
- type: 'button',
1465
- className: 'mf-callout-dismiss',
1466
- 'aria-label': 'Dismiss notice',
1467
- onClick: () => {
1468
- setDismissed(true);
1469
- onDismiss?.();
1470
- },
1471
- }, '×')
1472
- );
1473
- });
1474
-
1475
- export const Banner = Callout;
1476
-
1477
- export const CommandPalette = forwardRef(function CommandPalette({
1478
- open,
1479
- defaultOpen = false,
1480
- onOpenChange,
1481
- items = [],
1482
- placeholder = 'Type a command or search…',
1483
- emptyText = 'No matching commands.',
1484
- title = 'Command Palette',
1485
- trigger,
1486
- enableHotkey = false,
1487
- className,
1488
- ...props
1489
- }, ref) {
1490
- const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
1491
- const [query, setQuery] = useState('');
1492
- const [activeIndex, setActiveIndex] = useState(0);
1493
-
1494
- useEffect(() => {
1495
- if (!enableHotkey) return;
1496
- const onKeyDown = (event) => {
1497
- if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k') {
1498
- event.preventDefault();
1499
- setOpen(!isOpen);
1500
- }
1501
- };
1502
- window.addEventListener('keydown', onKeyDown);
1503
- return () => window.removeEventListener('keydown', onKeyDown);
1504
- }, [enableHotkey, isOpen, setOpen]);
1505
-
1506
- const filtered = useMemo(() => {
1507
- const q = query.trim().toLowerCase();
1508
- if (!q) return items;
1509
- return items.filter(item => {
1510
- const hay = [item.label, item.group, ...(item.keywords || [])].filter(Boolean).join(' ').toLowerCase();
1511
- return hay.includes(q);
1512
- });
1513
- }, [items, query]);
1514
-
1515
- const enabledItems = filtered.filter(i => !i.disabled);
1516
-
1517
- return h(Dialog, {
1518
- ...props,
1519
- ref,
1520
- open: isOpen,
1521
- onOpenChange: next => {
1522
- setOpen(next);
1523
- if (!next) setQuery('');
1524
- },
1525
- title,
1526
- trigger,
1527
- className: cx('mf-command-palette', className),
1528
- },
1529
- h('div', { className: 'mf-command-search' },
1530
- h(SearchInput, {
1531
- placeholder,
1532
- value: query,
1533
- onValueChange: val => {
1534
- setQuery(val);
1535
- setActiveIndex(0);
1536
- },
1537
- onKeyDown: e => {
1538
- if (!enabledItems.length) return;
1539
- if (e.key === 'ArrowDown') {
1540
- e.preventDefault();
1541
- setActiveIndex(i => (i + 1) % enabledItems.length);
1542
- } else if (e.key === 'ArrowUp') {
1543
- e.preventDefault();
1544
- setActiveIndex(i => (i - 1 + enabledItems.length) % enabledItems.length);
1545
- } else if (e.key === 'Enter') {
1546
- const chosen = enabledItems[activeIndex];
1547
- if (chosen) {
1548
- e.preventDefault();
1549
- chosen.onSelect?.(chosen);
1550
- setOpen(false);
1551
- }
1552
- }
1553
- },
1554
- })
1555
- ),
1556
- h('div', { role: 'listbox', 'aria-label': title, className: 'mf-command-list' },
1557
- filtered.length > 0
1558
- ? filtered.map((item, idx) => {
1559
- const isSelected = enabledItems[activeIndex]?.id === item.id;
1560
- return h('button', {
1561
- key: item.id ?? idx,
1562
- type: 'button',
1563
- role: 'option',
1564
- disabled: item.disabled,
1565
- 'aria-selected': isSelected,
1566
- 'data-active': isSelected ? 'true' : undefined,
1567
- className: 'mf-command-item',
1568
- onClick: () => {
1569
- if (item.disabled) return;
1570
- item.onSelect?.(item);
1571
- setOpen(false);
1572
- },
1573
- },
1574
- h('div', { className: 'mf-command-item-copy' },
1575
- item.group && h('small', { className: 'mf-command-group' }, item.group),
1576
- h('span', { className: 'mf-command-label' }, item.label)
1577
- ),
1578
- item.shortcut && h(Kbd, null, item.shortcut)
1579
- );
1580
- })
1581
- : h('p', { className: 'mf-command-empty' }, emptyText)
1582
- )
1583
- );
1584
- });
1585
-
1586
- /* ============================================================================
1587
- * Level C Reusable Composite Blocks (Exported from @moonframe/ui)
1588
- * ========================================================================== */
1589
-
1590
- export const PageHeader = forwardRef(function PageHeader({
1591
- breadcrumbs,
1592
- eyebrow,
1593
- title,
1594
- description,
1595
- badge,
1596
- actions,
1597
- className,
1598
- children,
1599
- ...props
1600
- }, ref) {
1601
- return h('header', { ...props, ref, className: cx('mf-page-header', className) },
1602
- Array.isArray(breadcrumbs) && breadcrumbs.length > 0 && h(Breadcrumb, null,
1603
- breadcrumbs.map((bc, idx) => h(BreadcrumbItem, { key: bc.label ?? idx },
1604
- h(BreadcrumbLink, { href: bc.href, current: bc.current ?? idx === breadcrumbs.length - 1 }, bc.label)
1605
- ))
1606
- ),
1607
- !Array.isArray(breadcrumbs) && breadcrumbs,
1608
- h('div', { className: 'mf-page-header-row' },
1609
- h('div', { className: 'mf-page-header-copy' },
1610
- eyebrow && h('span', { className: 'mf-page-header-eyebrow' }, eyebrow),
1611
- h('div', { className: 'mf-page-header-title-row' },
1612
- h('h1', { className: 'mf-page-header-title' }, title),
1613
- badge && h(Badge, { variant: 'primary' }, badge)
1614
- ),
1615
- description && h('p', { className: 'mf-page-header-description' }, description)
1616
- ),
1617
- actions && h('div', { className: 'mf-page-header-actions' }, actions)
1618
- ),
1619
- children
1620
- );
1621
- });
1622
-
1623
- export const MetricGrid = forwardRef(function MetricGrid({
1624
- items = [],
1625
- columns,
1626
- className,
1627
- ...props
1628
- }, ref) {
1629
- return h(Grid, { ...props, ref, columns, className: cx('mf-metric-grid', className) },
1630
- items.map((item, idx) => h(StatCard, {
1631
- key: item.id ?? item.label ?? idx,
1632
- label: item.label,
1633
- value: item.value,
1634
- detail: item.detail,
1635
- icon: item.delta ? h(Badge, { variant: item.deltaTone ?? 'primary' }, item.delta) : item.icon,
1636
- },
1637
- Array.isArray(item.trend) && item.trend.length >= 2 && h('div', { className: 'mf-metric-spark' },
1638
- h(Sparkline, { data: item.trend, label: `${item.label} trend` })
1639
- )
1640
- ))
1641
- );
1642
- });
1643
-
1644
- export const AuthCard = forwardRef(function AuthCard({
1645
- eyebrow,
1646
- title,
1647
- description,
1648
- logo,
1649
- error,
1650
- status,
1651
- socialActions,
1652
- footer,
1653
- className,
1654
- children,
1655
- ...props
1656
- }, ref) {
1657
- return h(Card, { ...props, ref, className: cx('mf-auth-card', className) },
1658
- h(CardHeader, { className: 'mf-auth-card-header' },
1659
- logo && h('div', { className: 'mf-auth-logo' }, logo),
1660
- eyebrow && h(Badge, { variant: 'secondary' }, eyebrow),
1661
- h(CardTitle, null, title),
1662
- description && h(CardDescription, null, description)
1663
- ),
1664
- h(CardContent, { className: 'mf-auth-card-body' },
1665
- error && h(Alert, { variant: 'danger', title: 'Authentication error', role: 'alert' }, error),
1666
- status && h(Alert, { variant: 'primary', title: 'Status' }, status),
1667
- children,
1668
- socialActions && h('div', { className: 'mf-auth-social' },
1669
- h(Separator, null),
1670
- h('div', { className: 'mf-auth-social-buttons' }, socialActions)
1671
- )
1672
- ),
1673
- footer && h(CardFooter, { className: 'mf-auth-card-footer' }, footer)
1674
- );
1675
- });
1676
-
1677
- export const PricingCard = forwardRef(function PricingCard({
1678
- name,
1679
- price,
1680
- period = '/month',
1681
- description,
1682
- badge,
1683
- featured = false,
1684
- features = [],
1685
- ctaLabel = 'Select plan',
1686
- onSelect,
1687
- footer,
1688
- className,
1689
- ...props
1690
- }, ref) {
1691
- return h(Card, {
1692
- ...props,
1693
- ref,
1694
- 'data-featured': featured ? 'true' : undefined,
1695
- className: cx('mf-pricing-card', className),
1696
- },
1697
- h(CardHeader, null,
1698
- h('div', { className: 'mf-pricing-header-top' },
1699
- h(CardTitle, null, name),
1700
- badge && h(Badge, { variant: featured ? 'primary' : 'secondary' }, badge)
1701
- ),
1702
- description && h(CardDescription, null, description),
1703
- h('div', { className: 'mf-pricing-price' },
1704
- h('strong', { className: 'mf-pricing-amount' }, price),
1705
- period && h('span', { className: 'mf-pricing-period' }, period)
1706
- )
1707
- ),
1708
- h(CardContent, null,
1709
- h('ul', { className: 'mf-pricing-features' },
1710
- features.map((feat, idx) => h('li', { key: idx, className: 'mf-pricing-feature' },
1711
- h('span', { 'aria-hidden': true, className: 'mf-pricing-check' }, '✓'),
1712
- h('span', null, feat)
1713
- ))
1714
- )
1715
- ),
1716
- h(CardFooter, { className: 'mf-pricing-footer' },
1717
- h(Button, {
1718
- variant: featured ? 'primary' : 'secondary',
1719
- className: 'mf-pricing-cta',
1720
- onClick: onSelect,
1721
- }, ctaLabel),
1722
- footer
1723
- )
1724
- );
1725
- });
1726
-
1727
- export const SettingsSection = forwardRef(function SettingsSection({
1728
- title,
1729
- description,
1730
- badge,
1731
- footer,
1732
- action,
1733
- className,
1734
- children,
1735
- ...props
1736
- }, ref) {
1737
- return h('section', { ...props, ref, className: cx('mf-settings-section', className) },
1738
- h('div', { className: 'mf-settings-meta' },
1739
- h('div', { className: 'mf-settings-title-row' },
1740
- h('h2', { className: 'mf-settings-title' }, title),
1741
- badge && h(Badge, { variant: 'secondary' }, badge)
1742
- ),
1743
- description && h('p', { className: 'mf-settings-description' }, description)
1744
- ),
1745
- h(Card, { className: 'mf-settings-card' },
1746
- h(CardContent, { className: 'mf-settings-body' }, children),
1747
- (footer || action) && h(CardFooter, { className: 'mf-settings-footer' },
1748
- footer && h('span', { className: 'mf-field-description' }, footer),
1749
- action && h('div', { className: 'mf-settings-action' }, action)
1750
- )
1751
- )
1752
- );
1753
- });
1754
-
1755
- export const ActivityFeed = forwardRef(function ActivityFeed({
1756
- title = 'Recent activity',
1757
- description,
1758
- items = [],
1759
- action,
1760
- emptyTitle = 'No recent activity',
1761
- emptyDescription = 'Events and audit entries will appear here.',
1762
- className,
1763
- ...props
1764
- }, ref) {
1765
- return h(Card, { ...props, ref, className: cx('mf-activity-feed', className) },
1766
- h(CardHeader, { className: 'mf-activity-header' },
1767
- h('div', null,
1768
- h(CardTitle, null, title),
1769
- description && h(CardDescription, null, description)
1770
- ),
1771
- action
1772
- ),
1773
- h(CardContent, null,
1774
- items.length > 0
1775
- ? h(Timeline, { items })
1776
- : h(EmptyState, { title: emptyTitle, description: emptyDescription })
1777
- )
1778
- );
1779
- });
1780
-
1781
- /* M10 Original 15-Skin Vector Brand Marks & Decorative Artwork */
1782
-
1783
- const SKIN_VECTOR_PATHS = {
1784
- moonpunk: [
1785
- { tag: 'polygon', attrs: { points: '6,4 26,2 28,22 18,28 4,24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5' } },
1786
- { tag: 'path', attrs: { d: 'M18 5L10 17H16L13 27L23 14H16L18 5Z', fill: 'currentColor' } },
1787
- ],
1788
- moonriot: [
1789
- { tag: 'polygon', attrs: { points: '3,6 29,3 25,27 3,22', fill: 'none', stroke: 'currentColor', strokeWidth: '2.2' } },
1790
- { tag: 'polygon', attrs: { points: '8,11 24,8 20,21 8,19', fill: 'currentColor' } },
1791
- ],
1792
- moonzine: [
1793
- { tag: 'rect', attrs: { x: '4', y: '5', width: '22', height: '22', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeDasharray: '4 2' } },
1794
- { tag: 'path', attrs: { d: 'M8 11H22M8 16H19M8 21H15', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'square' } },
1795
- ],
1796
- moonhalftone: [
1797
- { tag: 'rect', attrs: { x: '3', y: '3', width: '26', height: '26', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5' } },
1798
- { tag: 'circle', attrs: { cx: '10', cy: '10', r: '2.5', fill: 'currentColor' } },
1799
- { tag: 'circle', attrs: { cx: '20', cy: '10', r: '1.8', fill: 'currentColor' } },
1800
- { tag: 'circle', attrs: { cx: '10', cy: '20', r: '1.8', fill: 'currentColor' } },
1801
- { tag: 'circle', attrs: { cx: '20', cy: '20', r: '3.2', fill: 'currentColor' } },
1802
- ],
1803
- moonglitch: [
1804
- { tag: 'path', attrs: { d: 'M4 10V4H10M22 4H28V10M28 22V28H22M10 28H4V22', fill: 'none', stroke: 'currentColor', strokeWidth: '2' } },
1805
- { tag: 'path', attrs: { d: 'M7 16H13L15 11L18 21L20 16H25', fill: 'none', stroke: 'currentColor', strokeWidth: '2' } },
1806
- ],
1807
- moonsmash: [
1808
- { tag: 'polygon', attrs: { points: '16,2 20,11 30,9 23,17 29,26 19,23 15,30 12,21 3,24 9,15 3,7 13,10', fill: 'currentColor' } },
1809
- ],
1810
- moonink: [
1811
- { tag: 'path', attrs: { d: 'M24 9C20 5 11 6 8 13C5 20 11 27 19 26C24 25 27 21 26 17', fill: 'none', stroke: 'currentColor', strokeWidth: '3.2', strokeLinecap: 'round' } },
1812
- { tag: 'circle', attrs: { cx: '18', cy: '15', r: '2.5', fill: 'currentColor' } },
1813
- ],
1814
- mooncrash: [
1815
- { tag: 'polygon', attrs: { points: '9,3 23,3 29,9 29,23 23,29 9,29 3,23 3,9', fill: 'none', stroke: 'currentColor', strokeWidth: '2.4' } },
1816
- { tag: 'path', attrs: { d: 'M9 21L16 10L23 21H9Z', fill: 'currentColor' } },
1817
- ],
1818
- moonpanel: [
1819
- { tag: 'rect', attrs: { x: '3', y: '3', width: '11', height: '11', fill: 'currentColor' } },
1820
- { tag: 'rect', attrs: { x: '17', y: '3', width: '12', height: '11', fill: 'none', stroke: 'currentColor', strokeWidth: '2.2' } },
1821
- { tag: 'rect', attrs: { x: '3', y: '17', width: '26', height: '12', fill: 'none', stroke: 'currentColor', strokeWidth: '2.2' } },
1822
- ],
1823
- moonscrawl: [
1824
- { tag: 'path', attrs: { d: 'M6 24C4 14 11 5 21 7C28 9 28 21 20 24C13 26 9 19 13 13C16 9 22 11 20 16', fill: 'none', stroke: 'currentColor', strokeWidth: '2.2', strokeLinecap: 'round' } },
1825
- ],
1826
- moonraw: [
1827
- { tag: 'rect', attrs: { x: '3', y: '3', width: '26', height: '26', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5' } },
1828
- { tag: 'path', attrs: { d: 'M3 16H29M16 3V29', stroke: 'currentColor', strokeWidth: '2.5' } },
1829
- ],
1830
- moonchrome: [
1831
- { tag: 'polygon', attrs: { points: '16,3 29,16 16,29 3,16', fill: 'none', stroke: 'currentColor', strokeWidth: '2' } },
1832
- { tag: 'polygon', attrs: { points: '16,8 24,16 16,24 8,16', fill: 'currentColor' } },
1833
- ],
1834
- classic: [
1835
- { tag: 'rect', attrs: { x: '4', y: '4', width: '24', height: '24', rx: '6', fill: 'none', stroke: 'currentColor', strokeWidth: '2.2' } },
1836
- { tag: 'circle', attrs: { cx: '16', cy: '16', r: '5', fill: 'currentColor' } },
1837
- ],
1838
- moonquest: [
1839
- { tag: 'path', attrs: { d: 'M16 3L27 7V16C27 23 22 27 16 29C10 27 5 23 5 16V7L16 3Z', fill: 'none', stroke: 'currentColor', strokeWidth: '2.2' } },
1840
- { tag: 'polygon', attrs: { points: '16,8 18,14 24,16 18,18 16,24 14,18 8,16 14,14', fill: 'currentColor' } },
1841
- ],
1842
- moonledger: [
1843
- { tag: 'rect', attrs: { x: '4', y: '4', width: '24', height: '24', rx: '2', fill: 'none', stroke: 'currentColor', strokeWidth: '2' } },
1844
- { tag: 'path', attrs: { d: 'M4 11H28M12 11V28M20 11V28M4 19H28', stroke: 'currentColor', strokeWidth: '1.8' } },
1845
- ],
1846
- };
1847
-
1848
- export const SkinBrandMark = forwardRef(function SkinBrandMark({
1849
- skin: skinProp,
1850
- size = 28,
1851
- decorative = true,
1852
- label,
1853
- className,
1854
- ...props
1855
- }, ref) {
1856
- let themeSkin = 'classic';
1857
- try {
1858
- const theme = useTheme();
1859
- if (theme?.skin) themeSkin = theme.skin;
1860
- } catch {
1861
- themeSkin = 'classic';
1862
- }
1863
- const activeSkin = skinProp && SKIN_VECTOR_PATHS[skinProp] ? skinProp : themeSkin;
1864
- const shapes = SKIN_VECTOR_PATHS[activeSkin] || SKIN_VECTOR_PATHS.classic;
1865
- const ariaLabel = label || `${activeSkin} brand mark`;
1866
-
1867
- return h('svg', {
1868
- ...props,
1869
- ref,
1870
- width: size,
1871
- height: size,
1872
- viewBox: '0 0 32 32',
1873
- role: decorative ? undefined : 'img',
1874
- 'aria-hidden': decorative ? 'true' : undefined,
1875
- 'aria-label': decorative ? undefined : ariaLabel,
1876
- 'data-skin-mark': activeSkin,
1877
- className: cx('mf-brand-mark', className),
1878
- }, shapes.map((shape, idx) => h(shape.tag, { key: idx, ...shape.attrs })));
1879
- });
1880
-
1881
- export const SkinArtwork = forwardRef(function SkinArtwork({
1882
- skin: skinProp,
1883
- title,
1884
- caption,
1885
- className,
1886
- ...props
1887
- }, ref) {
1888
- let themeSkin = 'classic';
1889
- try {
1890
- const theme = useTheme();
1891
- if (theme?.skin) themeSkin = theme.skin;
1892
- } catch {
1893
- themeSkin = 'classic';
1894
- }
1895
- const activeSkin = skinProp && SKIN_VECTOR_PATHS[skinProp] ? skinProp : themeSkin;
1896
-
1897
- return h('figure', {
1898
- ...props,
1899
- ref,
1900
- 'data-skin-artwork': activeSkin,
1901
- className: cx('mf-skin-artwork', className),
1902
- },
1903
- h('div', { className: 'mf-skin-artwork-canvas', 'aria-hidden': 'true' },
1904
- h(SkinBrandMark, { skin: activeSkin, size: 56, decorative: true }),
1905
- h('div', { className: 'mf-skin-artwork-grid' })
1906
- ),
1907
- (title || caption) && h('figcaption', { className: 'mf-skin-artwork-caption' },
1908
- title && h('strong', null, title),
1909
- caption && h('span', null, caption)
1910
- )
1911
- );
1912
- });
1913
-
1914
- /* M10 Opt-In, Muted-by-Default WebAudio Synthesizer SFX Runtime (MF-SFX-001) */
1915
-
1916
- const SFX_EVENT_PROFILES = {
1917
- success: { freq: [523.25, 659.25], durationMs: 110, type: 'sine' },
1918
- warning: { freq: [392.0, 349.23], durationMs: 130, type: 'triangle' },
1919
- error: { freq: [293.66, 246.94], durationMs: 140, type: 'triangle' },
1920
- notification: { freq: [587.33, 880.0], durationMs: 95, type: 'sine' },
1921
- confirmation: { freq: [440.0, 554.37], durationMs: 90, type: 'sine' },
1922
- 'quest-reward': { freq: [523.25, 659.25, 783.99], durationMs: 160, type: 'triangle' },
1923
- };
1924
-
1925
- const SFX_ALIASES = {
1926
- 'confirm.success': 'success',
1927
- 'confirm.warning': 'warning',
1928
- 'confirm.error': 'error',
1929
- 'notification.incoming': 'notification',
1930
- 'operation.progress-complete': 'success',
1931
- 'game.reward': 'quest-reward',
1932
- };
1933
-
1934
- const SFXContext = createContext({
1935
- enabled: false,
1936
- muted: true,
1937
- volume: 0.35,
1938
- consentGranted: false,
1939
- lastEvent: null,
1940
- grantConsent: () => {},
1941
- revokeConsent: () => {},
1942
- setMuted: () => {},
1943
- setVolume: () => {},
1944
- play: () => ({ played: false, reason: 'provider-missing' }),
1945
- });
1946
-
1947
- export function SFXProvider({
1948
- defaultEnabled = false,
1949
- defaultMuted = true,
1950
- defaultVolume = 0.35,
1951
- children,
1952
- }) {
1953
- const [consentGranted, setConsentGranted] = useState(Boolean(defaultEnabled));
1954
- const [muted, setMutedState] = useState(defaultEnabled ? Boolean(defaultMuted) : true);
1955
- const [volume, setVolumeState] = useState(() => Math.max(0, Math.min(1, Number(defaultVolume) || 0.35)));
1956
- const [lastEvent, setLastEvent] = useState(null);
1957
- const timingRef = useRef({ lastPlayedAt: 0, byEvent: {} });
1958
-
1959
- function setVolume(next) {
1960
- const clamped = Math.max(0, Math.min(1, Number(next)));
1961
- if (Number.isFinite(clamped)) setVolumeState(clamped);
1962
- }
1963
-
1964
- function grantConsent() {
1965
- setConsentGranted(true);
1966
- setMutedState(false);
1967
- }
1968
-
1969
- function revokeConsent() {
1970
- setConsentGranted(false);
1971
- setMutedState(true);
1972
- }
1973
-
1974
- function play(rawEventId) {
1975
- const canonicalId = SFX_ALIASES[rawEventId] || rawEventId;
1976
- const profile = SFX_EVENT_PROFILES[canonicalId];
1977
- if (!profile) return { played: false, reason: 'unknown-event' };
1978
- if (!consentGranted || muted || volume <= 0) return { played: false, reason: 'muted-or-no-consent' };
1979
- if (typeof window === 'undefined' || typeof document === 'undefined') return { played: false, reason: 'ssr' };
1980
- if (document.visibilityState === 'hidden') return { played: false, reason: 'background-tab' };
1981
-
1982
- const rootMotion = document.documentElement?.getAttribute('data-motion');
1983
- const prefersReduced = typeof window.matchMedia === 'function' &&
1984
- window.matchMedia('(prefers-reduced-motion: reduce)').matches;
1985
- if (rootMotion === 'reduced' || prefersReduced) {
1986
- return { played: false, reason: 'reduced-motion' };
1987
- }
1988
-
1989
- const now = Date.now();
1990
- const lastGlobal = timingRef.current.lastPlayedAt || 0;
1991
- const lastSame = timingRef.current.byEvent[canonicalId] || 0;
1992
- if (now - lastGlobal < 1000) return { played: false, reason: 'rate-limited' };
1993
- if (now - lastSame < 2000) return { played: false, reason: 'deduplicated' };
1994
-
1995
- timingRef.current.lastPlayedAt = now;
1996
- timingRef.current.byEvent[canonicalId] = now;
1997
- setLastEvent({ id: canonicalId, timestamp: now });
1998
-
1999
- try {
2000
- const AudioCtx = window.AudioContext || window.webkitAudioContext;
2001
- if (AudioCtx) {
2002
- const ctx = new AudioCtx();
2003
- const gain = ctx.createGain();
2004
- gain.gain.setValueAtTime(Math.max(0.01, volume * 0.25), ctx.currentTime);
2005
- gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + profile.durationMs / 1000);
2006
- gain.connect(ctx.destination);
2007
-
2008
- profile.freq.forEach((f, idx) => {
2009
- const osc = ctx.createOscillator();
2010
- osc.type = profile.type;
2011
- osc.frequency.setValueAtTime(f, ctx.currentTime + idx * 0.045);
2012
- osc.connect(gain);
2013
- osc.start(ctx.currentTime + idx * 0.045);
2014
- osc.stop(ctx.currentTime + (profile.durationMs / 1000) + idx * 0.045);
2015
- });
2016
- }
2017
- } catch {
2018
- // Graceful silent fallback per MF-SFX-001
2019
- }
2020
-
2021
- return { played: true, eventId: canonicalId };
2022
- }
2023
-
2024
- const value = useMemo(() => ({
2025
- enabled: consentGranted && !muted,
2026
- muted,
2027
- volume,
2028
- consentGranted,
2029
- lastEvent,
2030
- grantConsent,
2031
- revokeConsent,
2032
- setMuted: setMutedState,
2033
- setVolume,
2034
- play,
2035
- }), [consentGranted, muted, volume, lastEvent]);
2036
-
2037
- return h(SFXContext.Provider, { value }, children);
2038
- }
2039
-
2040
- export function useSFX() {
2041
- return useContext(SFXContext);
2042
- }
2043
-
2044
-