@yewdiel21/motion-kit 0.10.0 → 0.15.0

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 (459) hide show
  1. package/README.md +81 -0
  2. package/bin/motion-kit.mjs +3 -3
  3. package/dist/auto/index.d.ts +56 -3
  4. package/dist/auto/index.js +107 -3
  5. package/dist/auto/index.js.map +1 -1
  6. package/dist/{chunk-XAKC2QY7.js → chunk-6IRJYXJU.js} +3 -28
  7. package/dist/chunk-6IRJYXJU.js.map +1 -0
  8. package/dist/chunk-A6QQCF6V.js +21333 -0
  9. package/dist/chunk-A6QQCF6V.js.map +1 -0
  10. package/dist/chunk-JXRS3OEA.js +3638 -0
  11. package/dist/chunk-JXRS3OEA.js.map +1 -0
  12. package/dist/chunk-QP4QJOEN.js +72 -0
  13. package/dist/chunk-QP4QJOEN.js.map +1 -0
  14. package/dist/css/components/activity-feed.css +240 -0
  15. package/dist/css/components/add-to-cart.css +72 -0
  16. package/dist/css/components/attachment.css +266 -0
  17. package/dist/css/components/bidirectional-slider.css +168 -0
  18. package/dist/css/components/breadcrumb.css +110 -0
  19. package/dist/css/components/chart-tooltip.css +168 -0
  20. package/dist/css/components/chart.css +296 -0
  21. package/dist/css/components/code-block.css +264 -0
  22. package/dist/css/components/color-area.css +82 -0
  23. package/dist/css/components/color-field.css +67 -0
  24. package/dist/css/components/color-picker.css +131 -0
  25. package/dist/css/components/color-slider.css +113 -0
  26. package/dist/css/components/command-search.css +252 -0
  27. package/dist/css/components/context-menu.css +23 -0
  28. package/dist/css/components/credit-card.css +288 -0
  29. package/dist/css/components/data-table.css +686 -0
  30. package/dist/css/components/date-range-picker.css +168 -0
  31. package/dist/css/components/date-time-picker.css +178 -0
  32. package/dist/css/components/drawer.css +58 -0
  33. package/dist/css/components/editable-table.css +201 -0
  34. package/dist/css/components/empty-state.css +61 -0
  35. package/dist/css/components/file-explorer.css +633 -0
  36. package/dist/css/components/filter-builder.css +227 -0
  37. package/dist/css/components/heatmap-chart.css +391 -0
  38. package/dist/css/components/hold-confirm.css +87 -0
  39. package/dist/css/components/hover-card.css +19 -7
  40. package/dist/css/components/image-preview.css +283 -0
  41. package/dist/css/components/json-viewer.css +304 -0
  42. package/dist/css/components/like-button.css +78 -0
  43. package/dist/css/components/link-preview.css +275 -0
  44. package/dist/css/components/loading-button.css +77 -0
  45. package/dist/css/components/multi-select.css +267 -0
  46. package/dist/css/components/nav.css +102 -102
  47. package/dist/css/components/notification-bell.css +127 -0
  48. package/dist/css/components/orbit-menu.css +130 -0
  49. package/dist/css/components/pagination.css +10 -5
  50. package/dist/css/components/password-strength.css +183 -0
  51. package/dist/css/components/pie-chart.css +390 -0
  52. package/dist/css/components/pill-button.css +135 -0
  53. package/dist/css/components/popover.css +25 -0
  54. package/dist/css/components/progress.css +140 -0
  55. package/dist/css/components/questionnaire.css +217 -0
  56. package/dist/css/components/radar-chart.css +370 -0
  57. package/dist/css/components/radial-chart.css +398 -0
  58. package/dist/css/components/range-calendar.css +186 -0
  59. package/dist/css/components/range-slider.css +192 -0
  60. package/dist/css/components/resizable-panel.css +243 -0
  61. package/dist/css/components/rich-text-editor.css +284 -0
  62. package/dist/css/components/sankey-chart.css +358 -0
  63. package/dist/css/components/scratch-card.css +75 -0
  64. package/dist/css/components/scroll-island.css +111 -0
  65. package/dist/css/components/select.css +136 -0
  66. package/dist/css/components/skeleton.css +108 -0
  67. package/dist/css/components/split-view.css +19 -0
  68. package/dist/css/components/star-rating.css +80 -0
  69. package/dist/css/components/stat-card.css +164 -0
  70. package/dist/css/components/swipe-actions.css +105 -0
  71. package/dist/css/components/tag-input.css +244 -0
  72. package/dist/css/components/time-field.css +88 -0
  73. package/dist/css/components/timeline.css +219 -0
  74. package/dist/css/components/toolbar.css +122 -0
  75. package/dist/css/components/tooltip.css +79 -0
  76. package/dist/css/components/tree-view.css +289 -0
  77. package/dist/css/components/virtual-list.css +195 -0
  78. package/dist/css/components/voice-dots.css +70 -0
  79. package/dist/css/tokens.css +185 -181
  80. package/dist/elements/index.d.ts +849 -7
  81. package/dist/elements/index.js +1642 -8
  82. package/dist/elements/index.js.map +1 -1
  83. package/dist/{engine-GDGwQnJE.d.ts → engine-5zRIssTO.d.ts} +11 -1
  84. package/dist/engine-QECQnGz1.d.ts +33 -0
  85. package/dist/index.css +10890 -311
  86. package/dist/index.d.ts +89 -5
  87. package/dist/index.js +273 -9
  88. package/dist/index.js.map +1 -1
  89. package/dist/react/index.d.ts +686 -24
  90. package/dist/react/index.js +2345 -9
  91. package/dist/react/index.js.map +1 -1
  92. package/dist/{reduced-BmBzKH94.d.ts → reduced-6X_bns60.d.ts} +9 -2
  93. package/dist/reveal-BfyKKsw4.d.ts +2474 -0
  94. package/dist/store-CA2Qcun_.d.ts +453 -0
  95. package/package.json +9 -16
  96. package/registry.json +1096 -543
  97. package/src/auto/auto-init.ts +104 -0
  98. package/src/components/activity-feed/README.md +56 -0
  99. package/src/components/activity-feed/activity-feed.css +239 -0
  100. package/src/components/activity-feed/element.ts +36 -0
  101. package/src/components/activity-feed/engine.ts +351 -0
  102. package/src/components/activity-feed/react.tsx +32 -0
  103. package/src/components/add-to-cart/README.md +34 -0
  104. package/src/components/add-to-cart/add-to-cart.css +71 -0
  105. package/src/components/add-to-cart/element.ts +20 -0
  106. package/src/components/add-to-cart/engine.ts +206 -0
  107. package/src/components/add-to-cart/react.tsx +29 -0
  108. package/src/components/attachment/README.md +27 -0
  109. package/src/components/attachment/attachment.css +265 -0
  110. package/src/components/attachment/element.ts +50 -0
  111. package/src/components/attachment/engine.ts +469 -0
  112. package/src/components/attachment/react.tsx +65 -0
  113. package/src/components/bidirectional-slider/README.md +46 -0
  114. package/src/components/bidirectional-slider/bidirectional-slider.css +167 -0
  115. package/src/components/bidirectional-slider/element.ts +42 -0
  116. package/src/components/bidirectional-slider/engine.ts +289 -0
  117. package/src/components/bidirectional-slider/react.tsx +45 -0
  118. package/src/components/breadcrumb/README.md +38 -0
  119. package/src/components/breadcrumb/breadcrumb.css +109 -0
  120. package/src/components/breadcrumb/element.ts +27 -0
  121. package/src/components/breadcrumb/engine.ts +249 -0
  122. package/src/components/breadcrumb/react.tsx +30 -0
  123. package/src/components/chart/README.md +34 -0
  124. package/src/components/chart/chart.css +295 -0
  125. package/src/components/chart/element.ts +43 -0
  126. package/src/components/chart/engine.ts +838 -0
  127. package/src/components/chart/parts.ts +237 -0
  128. package/src/components/chart/react.tsx +50 -0
  129. package/src/components/chart/use-chart.ts +55 -0
  130. package/src/components/chart-tooltip/README.md +53 -0
  131. package/src/components/chart-tooltip/chart-tooltip.css +167 -0
  132. package/src/components/chart-tooltip/element.ts +37 -0
  133. package/src/components/chart-tooltip/engine.ts +442 -0
  134. package/src/components/chart-tooltip/react.tsx +47 -0
  135. package/src/components/code-block/README.md +19 -0
  136. package/src/components/code-block/code-block.css +263 -0
  137. package/src/components/code-block/element.ts +34 -0
  138. package/src/components/code-block/engine.ts +254 -0
  139. package/src/components/code-block/highlight.ts +244 -0
  140. package/src/components/code-block/react.tsx +94 -0
  141. package/src/components/color-area/README.md +50 -0
  142. package/src/components/color-area/color-area.css +81 -0
  143. package/src/components/color-area/element.ts +26 -0
  144. package/src/components/color-area/engine.ts +246 -0
  145. package/src/components/color-area/react.tsx +42 -0
  146. package/src/components/color-field/README.md +43 -0
  147. package/src/components/color-field/color-field.css +66 -0
  148. package/src/components/color-field/element.ts +26 -0
  149. package/src/components/color-field/engine.ts +174 -0
  150. package/src/components/color-field/react.tsx +42 -0
  151. package/src/components/color-picker/README.md +45 -0
  152. package/src/components/color-picker/color-picker.css +130 -0
  153. package/src/components/color-picker/element.ts +45 -0
  154. package/src/components/color-picker/engine.ts +314 -0
  155. package/src/components/color-picker/react.tsx +47 -0
  156. package/src/components/color-slider/README.md +55 -0
  157. package/src/components/color-slider/color-slider.css +112 -0
  158. package/src/components/color-slider/element.ts +26 -0
  159. package/src/components/color-slider/engine.ts +234 -0
  160. package/src/components/color-slider/react.tsx +45 -0
  161. package/src/components/command-search/README.md +15 -0
  162. package/src/components/command-search/command-search.css +251 -0
  163. package/src/components/command-search/element.ts +36 -0
  164. package/src/components/command-search/engine.ts +356 -0
  165. package/src/components/command-search/match.ts +53 -0
  166. package/src/components/command-search/react.tsx +66 -0
  167. package/src/components/context-menu/README.md +31 -0
  168. package/src/components/context-menu/context-menu.css +22 -0
  169. package/src/components/context-menu/element.ts +40 -0
  170. package/src/components/context-menu/engine.ts +153 -0
  171. package/src/components/context-menu/react.tsx +57 -0
  172. package/src/components/credit-card/README.md +20 -0
  173. package/src/components/credit-card/card.ts +77 -0
  174. package/src/components/credit-card/credit-card.css +287 -0
  175. package/src/components/credit-card/element.ts +33 -0
  176. package/src/components/credit-card/engine.ts +410 -0
  177. package/src/components/credit-card/react.tsx +36 -0
  178. package/src/components/data-table/README.md +83 -0
  179. package/src/components/data-table/data-table.css +685 -0
  180. package/src/components/data-table/element.ts +54 -0
  181. package/src/components/data-table/engine.ts +1111 -0
  182. package/src/components/data-table/react.tsx +94 -0
  183. package/src/components/date-range-picker/README.md +51 -0
  184. package/src/components/date-range-picker/date-range-picker.css +167 -0
  185. package/src/components/date-range-picker/element.ts +52 -0
  186. package/src/components/date-range-picker/engine.ts +352 -0
  187. package/src/components/date-range-picker/react.tsx +57 -0
  188. package/src/components/date-time-picker/README.md +48 -0
  189. package/src/components/date-time-picker/date-time-picker.css +177 -0
  190. package/src/components/date-time-picker/element.ts +47 -0
  191. package/src/components/date-time-picker/engine.ts +350 -0
  192. package/src/components/date-time-picker/react.tsx +54 -0
  193. package/src/components/dialog/README.md +103 -102
  194. package/src/components/dialog/element.ts +123 -118
  195. package/src/components/dialog/engine.ts +449 -432
  196. package/src/components/drawer/README.md +28 -0
  197. package/src/components/drawer/drawer.css +57 -0
  198. package/src/components/drawer/element.ts +21 -0
  199. package/src/components/drawer/engine.ts +56 -0
  200. package/src/components/drawer/react.tsx +85 -0
  201. package/src/components/editable-table/README.md +67 -0
  202. package/src/components/editable-table/editable-table.css +200 -0
  203. package/src/components/editable-table/element.ts +45 -0
  204. package/src/components/editable-table/engine.ts +831 -0
  205. package/src/components/editable-table/react.tsx +79 -0
  206. package/src/components/empty-state/README.md +41 -0
  207. package/src/components/empty-state/element.ts +23 -0
  208. package/src/components/empty-state/empty-state.css +60 -0
  209. package/src/components/empty-state/engine.ts +232 -0
  210. package/src/components/empty-state/react.tsx +34 -0
  211. package/src/components/file-explorer/README.md +67 -0
  212. package/src/components/file-explorer/element.ts +39 -0
  213. package/src/components/file-explorer/engine.ts +1307 -0
  214. package/src/components/file-explorer/file-explorer.css +632 -0
  215. package/src/components/file-explorer/react.tsx +77 -0
  216. package/src/components/filter-builder/README.md +47 -0
  217. package/src/components/filter-builder/element.ts +34 -0
  218. package/src/components/filter-builder/engine.ts +396 -0
  219. package/src/components/filter-builder/filter-builder.css +226 -0
  220. package/src/components/filter-builder/react.tsx +36 -0
  221. package/src/components/heatmap-chart/README.md +48 -0
  222. package/src/components/heatmap-chart/element.ts +21 -0
  223. package/src/components/heatmap-chart/engine.ts +281 -0
  224. package/src/components/heatmap-chart/heatmap-chart.css +93 -0
  225. package/src/components/heatmap-chart/react.tsx +14 -0
  226. package/src/components/hold-confirm/README.md +13 -0
  227. package/src/components/hold-confirm/element.ts +24 -0
  228. package/src/components/hold-confirm/engine.ts +216 -0
  229. package/src/components/hold-confirm/hold-confirm.css +86 -0
  230. package/src/components/hold-confirm/react.tsx +28 -0
  231. package/src/components/hover-card/README.md +6 -2
  232. package/src/components/hover-card/engine.ts +98 -7
  233. package/src/components/hover-card/hover-card.css +19 -7
  234. package/src/components/image-preview/README.md +16 -0
  235. package/src/components/image-preview/element.ts +26 -0
  236. package/src/components/image-preview/engine.ts +405 -0
  237. package/src/components/image-preview/image-preview.css +282 -0
  238. package/src/components/image-preview/react.tsx +43 -0
  239. package/src/components/json-viewer/README.md +56 -0
  240. package/src/components/json-viewer/element.ts +37 -0
  241. package/src/components/json-viewer/engine.ts +449 -0
  242. package/src/components/json-viewer/json-viewer.css +303 -0
  243. package/src/components/json-viewer/react.tsx +56 -0
  244. package/src/components/like-button/README.md +13 -0
  245. package/src/components/like-button/element.ts +47 -0
  246. package/src/components/like-button/engine.ts +145 -0
  247. package/src/components/like-button/like-button.css +77 -0
  248. package/src/components/like-button/react.tsx +39 -0
  249. package/src/components/link-preview/README.md +19 -0
  250. package/src/components/link-preview/element.ts +29 -0
  251. package/src/components/link-preview/engine.ts +192 -0
  252. package/src/components/link-preview/link-preview.css +274 -0
  253. package/src/components/link-preview/react.tsx +101 -0
  254. package/src/components/loading-button/README.md +45 -0
  255. package/src/components/loading-button/element.ts +34 -0
  256. package/src/components/loading-button/engine.ts +201 -0
  257. package/src/components/loading-button/loading-button.css +76 -0
  258. package/src/components/loading-button/react.tsx +43 -0
  259. package/src/components/multi-select/README.md +48 -0
  260. package/src/components/multi-select/element.ts +28 -0
  261. package/src/components/multi-select/engine.ts +294 -0
  262. package/src/components/multi-select/multi-select.css +266 -0
  263. package/src/components/multi-select/react.tsx +39 -0
  264. package/src/components/nav/README.md +12 -10
  265. package/src/components/nav/element.ts +5 -5
  266. package/src/components/nav/engine.ts +21 -14
  267. package/src/components/nav/nav.css +102 -102
  268. package/src/components/nav/react.tsx +4 -4
  269. package/src/components/notification-bell/README.md +14 -0
  270. package/src/components/notification-bell/element.ts +48 -0
  271. package/src/components/notification-bell/engine.ts +202 -0
  272. package/src/components/notification-bell/notification-bell.css +126 -0
  273. package/src/components/notification-bell/react.tsx +57 -0
  274. package/src/components/orbit-menu/README.md +46 -0
  275. package/src/components/orbit-menu/element.ts +27 -0
  276. package/src/components/orbit-menu/engine.ts +179 -0
  277. package/src/components/orbit-menu/orbit-menu.css +129 -0
  278. package/src/components/orbit-menu/react.tsx +44 -0
  279. package/src/components/pagination/README.md +1 -1
  280. package/src/components/pagination/engine.ts +50 -4
  281. package/src/components/pagination/pagination.css +10 -5
  282. package/src/components/password-strength/README.md +17 -0
  283. package/src/components/password-strength/element.ts +22 -0
  284. package/src/components/password-strength/engine.ts +212 -0
  285. package/src/components/password-strength/password-strength.css +182 -0
  286. package/src/components/password-strength/react.tsx +36 -0
  287. package/src/components/password-strength/score.ts +62 -0
  288. package/src/components/pie-chart/README.md +48 -0
  289. package/src/components/pie-chart/element.ts +30 -0
  290. package/src/components/pie-chart/engine.ts +283 -0
  291. package/src/components/pie-chart/pie-chart.css +92 -0
  292. package/src/components/pie-chart/react.tsx +14 -0
  293. package/src/components/pill-button/README.md +46 -0
  294. package/src/components/pill-button/element.ts +16 -0
  295. package/src/components/pill-button/engine.ts +77 -0
  296. package/src/components/pill-button/pill-button.css +134 -0
  297. package/src/components/pill-button/react.tsx +32 -0
  298. package/src/components/popover/README.md +44 -0
  299. package/src/components/popover/element.ts +31 -0
  300. package/src/components/popover/engine.ts +114 -0
  301. package/src/components/popover/popover.css +24 -0
  302. package/src/components/popover/react.tsx +50 -0
  303. package/src/components/progress/README.md +17 -0
  304. package/src/components/progress/element.ts +30 -0
  305. package/src/components/progress/engine.ts +173 -0
  306. package/src/components/progress/progress.css +139 -0
  307. package/src/components/progress/react.tsx +35 -0
  308. package/src/components/questionnaire/README.md +32 -0
  309. package/src/components/questionnaire/element.ts +118 -0
  310. package/src/components/questionnaire/engine.ts +255 -0
  311. package/src/components/questionnaire/questionnaire.css +216 -0
  312. package/src/components/questionnaire/react.tsx +140 -0
  313. package/src/components/radar-chart/README.md +48 -0
  314. package/src/components/radar-chart/element.ts +30 -0
  315. package/src/components/radar-chart/engine.ts +327 -0
  316. package/src/components/radar-chart/radar-chart.css +72 -0
  317. package/src/components/radar-chart/react.tsx +14 -0
  318. package/src/components/radial-chart/README.md +48 -0
  319. package/src/components/radial-chart/element.ts +30 -0
  320. package/src/components/radial-chart/engine.ts +290 -0
  321. package/src/components/radial-chart/radial-chart.css +100 -0
  322. package/src/components/radial-chart/react.tsx +14 -0
  323. package/src/components/range-calendar/README.md +58 -0
  324. package/src/components/range-calendar/element.ts +42 -0
  325. package/src/components/range-calendar/engine.ts +390 -0
  326. package/src/components/range-calendar/range-calendar.css +185 -0
  327. package/src/components/range-calendar/react.tsx +56 -0
  328. package/src/components/range-slider/README.md +23 -0
  329. package/src/components/range-slider/element.ts +53 -0
  330. package/src/components/range-slider/engine.ts +316 -0
  331. package/src/components/range-slider/range-slider.css +191 -0
  332. package/src/components/range-slider/react.tsx +66 -0
  333. package/src/components/resizable-panel/README.md +61 -0
  334. package/src/components/resizable-panel/element.ts +36 -0
  335. package/src/components/resizable-panel/engine.ts +551 -0
  336. package/src/components/resizable-panel/react.tsx +74 -0
  337. package/src/components/resizable-panel/resizable-panel.css +242 -0
  338. package/src/components/rich-text-editor/README.md +57 -0
  339. package/src/components/rich-text-editor/element.ts +34 -0
  340. package/src/components/rich-text-editor/engine.ts +673 -0
  341. package/src/components/rich-text-editor/react.tsx +60 -0
  342. package/src/components/rich-text-editor/rich-text-editor.css +283 -0
  343. package/src/components/sankey-chart/README.md +48 -0
  344. package/src/components/sankey-chart/element.ts +31 -0
  345. package/src/components/sankey-chart/engine.ts +401 -0
  346. package/src/components/sankey-chart/react.tsx +14 -0
  347. package/src/components/sankey-chart/sankey-chart.css +60 -0
  348. package/src/components/scratch-card/README.md +15 -0
  349. package/src/components/scratch-card/element.ts +30 -0
  350. package/src/components/scratch-card/engine.ts +257 -0
  351. package/src/components/scratch-card/react.tsx +40 -0
  352. package/src/components/scratch-card/scratch-card.css +74 -0
  353. package/src/components/scroll-island/README.md +34 -0
  354. package/src/components/scroll-island/element.ts +16 -0
  355. package/src/components/scroll-island/engine.ts +252 -0
  356. package/src/components/scroll-island/react.tsx +26 -0
  357. package/src/components/scroll-island/scroll-island.css +110 -0
  358. package/src/components/select/README.md +34 -0
  359. package/src/components/select/element.ts +26 -0
  360. package/src/components/select/engine.ts +267 -0
  361. package/src/components/select/react.tsx +33 -0
  362. package/src/components/select/select.css +135 -0
  363. package/src/components/skeleton/README.md +15 -0
  364. package/src/components/skeleton/element.ts +32 -0
  365. package/src/components/skeleton/engine.ts +104 -0
  366. package/src/components/skeleton/react.tsx +41 -0
  367. package/src/components/skeleton/skeleton.css +107 -0
  368. package/src/components/split-view/README.md +50 -0
  369. package/src/components/split-view/element.ts +34 -0
  370. package/src/components/split-view/engine.ts +114 -0
  371. package/src/components/split-view/react.tsx +63 -0
  372. package/src/components/split-view/split-view.css +18 -0
  373. package/src/components/star-rating/README.md +14 -0
  374. package/src/components/star-rating/element.ts +26 -0
  375. package/src/components/star-rating/engine.ts +217 -0
  376. package/src/components/star-rating/react.tsx +33 -0
  377. package/src/components/star-rating/star-rating.css +79 -0
  378. package/src/components/stat-card/README.md +42 -0
  379. package/src/components/stat-card/element.ts +40 -0
  380. package/src/components/stat-card/engine.ts +283 -0
  381. package/src/components/stat-card/react.tsx +36 -0
  382. package/src/components/stat-card/stat-card.css +163 -0
  383. package/src/components/swipe-actions/README.md +19 -0
  384. package/src/components/swipe-actions/element.ts +26 -0
  385. package/src/components/swipe-actions/engine.ts +260 -0
  386. package/src/components/swipe-actions/react.tsx +80 -0
  387. package/src/components/swipe-actions/swipe-actions.css +104 -0
  388. package/src/components/tag-input/README.md +42 -0
  389. package/src/components/tag-input/element.ts +39 -0
  390. package/src/components/tag-input/engine.ts +313 -0
  391. package/src/components/tag-input/react.tsx +54 -0
  392. package/src/components/tag-input/tag-input.css +243 -0
  393. package/src/components/time-field/README.md +54 -0
  394. package/src/components/time-field/element.ts +38 -0
  395. package/src/components/time-field/engine.ts +110 -0
  396. package/src/components/time-field/react.tsx +45 -0
  397. package/src/components/time-field/time-field.css +87 -0
  398. package/src/components/timeline/README.md +57 -0
  399. package/src/components/timeline/element.ts +31 -0
  400. package/src/components/timeline/engine.ts +300 -0
  401. package/src/components/timeline/react.tsx +59 -0
  402. package/src/components/timeline/timeline.css +218 -0
  403. package/src/components/toolbar/README.md +46 -0
  404. package/src/components/toolbar/element.ts +30 -0
  405. package/src/components/toolbar/engine.ts +230 -0
  406. package/src/components/toolbar/react.tsx +34 -0
  407. package/src/components/toolbar/toolbar.css +121 -0
  408. package/src/components/tooltip/README.md +46 -0
  409. package/src/components/tooltip/element.ts +22 -0
  410. package/src/components/tooltip/engine.ts +288 -0
  411. package/src/components/tooltip/react.tsx +30 -0
  412. package/src/components/tooltip/tooltip.css +78 -0
  413. package/src/components/tree-view/README.md +61 -0
  414. package/src/components/tree-view/element.ts +32 -0
  415. package/src/components/tree-view/engine.ts +743 -0
  416. package/src/components/tree-view/react.tsx +82 -0
  417. package/src/components/tree-view/tree-view.css +288 -0
  418. package/src/components/virtual-list/README.md +81 -0
  419. package/src/components/virtual-list/element.ts +42 -0
  420. package/src/components/virtual-list/engine.ts +678 -0
  421. package/src/components/virtual-list/react.tsx +101 -0
  422. package/src/components/virtual-list/virtual-list.css +194 -0
  423. package/src/components/voice-dots/README.md +48 -0
  424. package/src/components/voice-dots/element.ts +45 -0
  425. package/src/components/voice-dots/engine.ts +243 -0
  426. package/src/components/voice-dots/react.tsx +52 -0
  427. package/src/components/voice-dots/voice-dots.css +69 -0
  428. package/src/core/chips.ts +196 -0
  429. package/src/core/color.ts +304 -0
  430. package/src/core/date-range.ts +67 -0
  431. package/src/core/dates.ts +11 -1
  432. package/src/core/files.ts +107 -0
  433. package/src/core/filter.ts +229 -0
  434. package/src/core/gsap.ts +80 -65
  435. package/src/core/listbox.ts +332 -0
  436. package/src/core/mark.ts +29 -0
  437. package/src/core/position.ts +89 -0
  438. package/src/core/relative-time.ts +77 -0
  439. package/src/core/segment-field.ts +373 -0
  440. package/src/core/segments.ts +153 -0
  441. package/src/core/tree.ts +116 -0
  442. package/src/core/virtual.ts +79 -0
  443. package/src/css/tokens.css +186 -182
  444. package/src/elements/index.ts +186 -0
  445. package/src/index.ts +88 -0
  446. package/src/motion/liquid.ts +14 -4
  447. package/src/motion/micro.ts +248 -0
  448. package/src/motion/sheet.ts +88 -65
  449. package/src/motion/surface.ts +9 -0
  450. package/src/react/index.ts +71 -1
  451. package/dist/chunk-IKQ5FODN.js +0 -1617
  452. package/dist/chunk-IKQ5FODN.js.map +0 -1
  453. package/dist/chunk-J6OCFNGU.js +0 -177
  454. package/dist/chunk-J6OCFNGU.js.map +0 -1
  455. package/dist/chunk-TFNRIZHU.js +0 -3977
  456. package/dist/chunk-TFNRIZHU.js.map +0 -1
  457. package/dist/chunk-XAKC2QY7.js.map +0 -1
  458. package/dist/reveal-jsX-uwUz.d.ts +0 -625
  459. package/dist/store-DYb3tTsZ.d.ts +0 -195
@@ -0,0 +1,401 @@
1
+ import { gsap, EASE, registerMotion } from '../../core/gsap';
2
+ import { reduced } from '../../core/reduced';
3
+ import { createScope } from '../../core/scope';
4
+ import { inert, type Instance } from '../../core/types';
5
+ import { chartFrame, finite, formatNumber, onWidth, round, slotColor, svg, SVG_NS } from '../chart/parts';
6
+
7
+ /*
8
+ * Sankey chart: flows between stages as bands as wide as their value, in
9
+ * chart's family. Nodes stand in columns by their depth (the ones that lead
10
+ * nowhere end at the right), stacked in the given order and centred; each
11
+ * band fades from its source's colour to its target's. The nodes grow from
12
+ * their middles, column after column, while the bands are wiped in from the
13
+ * left (.9 s); new data with the same nodes and flows glides every node and
14
+ * band. Pointing at a band (or the arrows) lights it and dims the rest, with
15
+ * "A → B" and its share in the tooltip; pointing at a node lights its bands.
16
+ */
17
+
18
+ export interface SankeyNode {
19
+ id: string;
20
+ label?: string;
21
+ color?: string;
22
+ }
23
+
24
+ export interface SankeyLink {
25
+ source: string;
26
+ target: string;
27
+ value: number;
28
+ }
29
+
30
+ export interface SankeyChartOptions {
31
+ nodes?: SankeyNode[];
32
+ links?: SankeyLink[];
33
+ /** Plot height in px (default 320). */
34
+ height?: number;
35
+ /** Node width in px (default 12). */
36
+ nodeWidth?: number;
37
+ /** Space between nodes in a column, px (default 14). */
38
+ nodePadding?: number;
39
+ label?: string;
40
+ formatValue?: (value: number) => string;
41
+ emptyLabel?: string;
42
+ /** A flow was chosen (its index in `links`), or none. */
43
+ onSelect?: (index: number | null) => void;
44
+ }
45
+
46
+ export interface SankeyChartInstance extends Instance {
47
+ update(options: SankeyChartOptions): void;
48
+ select(index: number | null): void;
49
+ readonly selected: number | null;
50
+ }
51
+
52
+ interface Layout {
53
+ nodes: Array<{ x: number; y0: number; y1: number }>;
54
+ links: Array<{ sy: number; ty: number; width: number }>;
55
+ }
56
+
57
+ export function createSankeyChart(root: HTMLElement | null, initial: SankeyChartOptions = {}): SankeyChartInstance {
58
+ if (!root) return inert({ update() {}, select() {}, selected: null });
59
+ registerMotion();
60
+ const scope = createScope();
61
+ const frame = chartFrame(root, scope, 'sankey');
62
+ const { plot, canvas } = frame;
63
+ let options: SankeyChartOptions = { ...initial };
64
+ let selected: number | null = null;
65
+ let hoverNode: number | null = null;
66
+ const uid = `mk-sankey-${Math.random().toString(36).slice(2, 8)}`;
67
+
68
+ const format = (value: number) => (options.formatValue ? options.formatValue(value) : formatNumber(value));
69
+ const modelOf = () => {
70
+ const nodes = (options.nodes ?? []).map((node, i, all) => ({ id: String(node.id), label: String(node.label ?? node.id), color: node.color ?? slotColor(i, Math.max(2, all.length)) }));
71
+ const index = new Map(nodes.map((node, i) => [node.id, i]));
72
+ const links = (options.links ?? [])
73
+ .map((link, i) => ({ source: index.get(String(link.source)) ?? -1, target: index.get(String(link.target)) ?? -1, value: link.value, given: i }))
74
+ .filter((link) => link.source >= 0 && link.target >= 0 && link.source !== link.target && finite(link.value) && link.value > 0);
75
+ // Depth: the longest way in from a source (bounded, so a loop cannot run away).
76
+ const depth = nodes.map(() => 0);
77
+ for (let pass = 0; pass < nodes.length; pass++) {
78
+ let moved = false;
79
+ for (const link of links) {
80
+ if (depth[link.target]! < depth[link.source]! + 1 && depth[link.source]! + 1 < nodes.length) {
81
+ depth[link.target] = depth[link.source]! + 1;
82
+ moved = true;
83
+ }
84
+ }
85
+ if (!moved) break;
86
+ }
87
+ const columns = Math.max(0, ...depth) + 1;
88
+ // The ones that lead nowhere end at the right.
89
+ nodes.forEach((_, i) => {
90
+ if (links.some((link) => link.source === i) || !links.some((link) => link.target === i)) return;
91
+ depth[i] = columns - 1;
92
+ });
93
+ const used = nodes.map((_, i) => links.some((link) => link.source === i || link.target === i));
94
+ const value = nodes.map((_, i) => Math.max(links.filter((link) => link.target === i).reduce((s, l) => s + l.value, 0), links.filter((link) => link.source === i).reduce((s, l) => s + l.value, 0)));
95
+ return { nodes, links, depth, columns, used, value };
96
+ };
97
+ let model = modelOf();
98
+ const hasData = () => model.links.length > 0;
99
+
100
+ let width = 600;
101
+ let height = 320;
102
+ const layoutOf = (): Layout => {
103
+ width = Math.max(240, Math.round(plot.clientWidth || root.clientWidth || 600));
104
+ height = Math.max(160, finite(options.height) ? options.height : 320);
105
+ const nodeWidth = Math.max(4, finite(options.nodeWidth) ? options.nodeWidth : 12);
106
+ const pad = Math.max(2, finite(options.nodePadding) ? options.nodePadding : 14);
107
+ const top = 6;
108
+ const usable = height - top * 2;
109
+ const columns = Array.from({ length: model.columns }, (_, c) => model.nodes.map((_, i) => i).filter((i) => model.used[i] && model.depth[i] === c));
110
+ const ky = Math.min(...columns.filter((list) => list.length).map((list) => (usable - pad * (list.length - 1)) / list.reduce((sum, i) => sum + model.value[i]!, 0)));
111
+ const step = model.columns > 1 ? (width - nodeWidth) / (model.columns - 1) : 0;
112
+ const nodes = model.nodes.map(() => ({ x: 0, y0: 0, y1: 0 }));
113
+ for (const list of columns) {
114
+ const total = list.reduce((sum, i) => sum + model.value[i]! * ky, 0) + pad * Math.max(0, list.length - 1);
115
+ let y = top + (usable - total) / 2;
116
+ for (const i of list) {
117
+ const h = Math.max(1, model.value[i]! * ky);
118
+ nodes[i] = { x: model.depth[i]! * step, y0: y, y1: y + h };
119
+ y += h + pad;
120
+ }
121
+ }
122
+ // Bands leave a node in the order of their targets and arrive in the order of their sources.
123
+ const out = new Map<number, number>();
124
+ const into = new Map<number, number>();
125
+ const centre = (i: number) => (nodes[i]!.y0 + nodes[i]!.y1) / 2;
126
+ const links = model.links.map(() => ({ sy: 0, ty: 0, width: 0 }));
127
+ const order = model.links.map((_, k) => k);
128
+ for (const k of [...order].sort((a, b) => centre(model.links[a]!.target) - centre(model.links[b]!.target))) {
129
+ const link = model.links[k]!;
130
+ const w = link.value * ky;
131
+ const at = out.get(link.source) ?? nodes[link.source]!.y0;
132
+ links[k]!.sy = at + w / 2;
133
+ links[k]!.width = w;
134
+ out.set(link.source, at + w);
135
+ }
136
+ for (const k of [...order].sort((a, b) => centre(model.links[a]!.source) - centre(model.links[b]!.source))) {
137
+ const link = model.links[k]!;
138
+ const at = into.get(link.target) ?? nodes[link.target]!.y0;
139
+ links[k]!.ty = at + links[k]!.width / 2;
140
+ into.set(link.target, at + links[k]!.width);
141
+ }
142
+ return { nodes, links };
143
+ };
144
+
145
+ let shown: Layout | null = null;
146
+ let rects: SVGRectElement[] = [];
147
+ let bands: SVGPathElement[] = [];
148
+ let names: SVGTextElement[] = [];
149
+ let glide: gsap.core.Animation | null = null;
150
+ scope.add(() => glide?.kill());
151
+ const nodeWidth = () => Math.max(4, finite(options.nodeWidth) ? options.nodeWidth : 12);
152
+
153
+ const build = () => {
154
+ canvas.replaceChildren();
155
+ canvas.setAttribute('viewBox', `0 0 ${width} ${height}`);
156
+ canvas.setAttribute('width', String(width));
157
+ canvas.setAttribute('height', String(height));
158
+ const defs = svg('defs');
159
+ const flows = svg('g', { 'data-mk-part': 'links' });
160
+ bands = model.links.map((link, k) => {
161
+ const gradient = svg('linearGradient', { id: `${uid}-${k}`, gradientUnits: 'userSpaceOnUse' });
162
+ const from = svg('stop', { offset: '0' });
163
+ from.style.stopColor = model.nodes[link.source]!.color;
164
+ const to = svg('stop', { offset: '1' });
165
+ to.style.stopColor = model.nodes[link.target]!.color;
166
+ gradient.append(from, to);
167
+ defs.append(gradient);
168
+ const band = svg('path', { 'data-mk-index': k });
169
+ band.style.fill = `url(#${uid}-${k})`;
170
+ flows.append(band);
171
+ return band;
172
+ });
173
+ const nodesLayer = svg('g', { 'data-mk-part': 'nodes' });
174
+ rects = model.nodes.map((node, i) => {
175
+ const rect = svg('rect', { width: nodeWidth(), rx: 3, 'data-mk-node': i });
176
+ rect.style.fill = node.color;
177
+ if (!model.used[i]) rect.style.display = 'none';
178
+ nodesLayer.append(rect);
179
+ return rect;
180
+ });
181
+ const labels = svg('g', { 'data-mk-part': 'labels' });
182
+ names = model.nodes.map((node, i) => {
183
+ const text = svg('text', { 'dominant-baseline': 'middle' });
184
+ text.textContent = node.label;
185
+ const amount = document.createElementNS(SVG_NS, 'tspan');
186
+ amount.setAttribute('data-mk-part', 'amount');
187
+ amount.textContent = ` ${format(model.value[i]!)}`;
188
+ text.append(amount);
189
+ if (!model.used[i]) text.style.display = 'none';
190
+ labels.append(text);
191
+ return text;
192
+ });
193
+ canvas.append(defs, flows, nodesLayer, labels);
194
+ };
195
+
196
+ const paint = (layout: Layout) => {
197
+ shown = layout;
198
+ const w = nodeWidth();
199
+ layout.nodes.forEach((node, i) => {
200
+ const rect = rects[i]!;
201
+ rect.setAttribute('x', String(round(node.x)));
202
+ rect.setAttribute('y', String(round(node.y0)));
203
+ rect.setAttribute('height', String(round(Math.max(1, node.y1 - node.y0))));
204
+ const last = model.depth[i] === model.columns - 1 && model.columns > 1;
205
+ const name = names[i]!;
206
+ const first = model.depth[i] === 0;
207
+ const x = round(last ? node.x - 8 : first ? node.x + w + 8 : node.x + w / 2);
208
+ const available = model.columns > 1 ? (width - w) / (model.columns - 1) - 20 : width - w - 16;
209
+ const characters = Math.max(3, Math.floor(available / 7));
210
+ const label = model.nodes[i]!.label;
211
+ if (name.firstChild) name.firstChild.textContent = label.length > characters ? `${label.slice(0, characters - 1)}…` : label;
212
+ name.setAttribute('x', String(x));
213
+ name.setAttribute('y', String(round((node.y0 + node.y1) / 2 - 7)));
214
+ name.setAttribute('text-anchor', last ? 'end' : first ? 'start' : 'middle');
215
+ const amount = name.querySelector('tspan');
216
+ amount?.setAttribute('x', String(x));
217
+ amount?.setAttribute('dy', '14');
218
+ });
219
+ layout.links.forEach((link, k) => {
220
+ const { source, target } = model.links[k]!;
221
+ const x0 = layout.nodes[source]!.x + w;
222
+ const x1 = layout.nodes[target]!.x;
223
+ const xm = (x0 + x1) / 2;
224
+ const h = link.width / 2;
225
+ const [s0, s1, t0, t1] = [link.sy - h, link.sy + h, link.ty - h, link.ty + h].map(round);
226
+ bands[k]!.setAttribute('d', `M${round(x0)},${s0}C${round(xm)},${s0} ${round(xm)},${t0} ${round(x1)},${t0}L${round(x1)},${t1}C${round(xm)},${t1} ${round(xm)},${s1} ${round(x0)},${s1}Z`);
227
+ const gradient = canvas.querySelector(`#${uid}-${k}`);
228
+ gradient?.setAttribute('x1', String(round(x0)));
229
+ gradient?.setAttribute('x2', String(round(x1)));
230
+ });
231
+ };
232
+
233
+ const share = (part: number, whole: number) => new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 1 }).format(part / (whole || 1));
234
+ const paintSelection = (announce: boolean) => {
235
+ const lit = (k: number) => (selected !== null ? k === selected : hoverNode !== null ? model.links[k]!.source === hoverNode || model.links[k]!.target === hoverNode : false);
236
+ const any = selected !== null || hoverNode !== null;
237
+ bands.forEach((band, k) => {
238
+ band.toggleAttribute('data-mk-on', lit(k));
239
+ band.toggleAttribute('data-mk-dim', any && !lit(k));
240
+ });
241
+ rects.forEach((rect, i) => rect.toggleAttribute('data-mk-dim', any && !model.links.some((link, k) => lit(k) && (link.source === i || link.target === i))));
242
+ if (!shown || (selected === null && hoverNode === null)) {
243
+ frame.tip(null);
244
+ return;
245
+ }
246
+ if (selected !== null) {
247
+ const link = model.links[selected]!;
248
+ const geometry = shown.links[selected]!;
249
+ const x = (shown.nodes[link.source]!.x + shown.nodes[link.target]!.x + nodeWidth()) / 2;
250
+ const y = (geometry.sy + geometry.ty) / 2 - geometry.width / 2;
251
+ const from = model.nodes[link.source]!;
252
+ const to = model.nodes[link.target]!;
253
+ const rows = [{ name: `${share(link.value, model.value[link.source]!)} de ${from.label}`, color: from.color, value: format(link.value) }];
254
+ frame.tip({ x: round(x), y: round(y), title: `${from.label} → ${to.label}`, rows });
255
+ if (announce) frame.live.textContent = `${from.label} a ${to.label}: ${format(link.value)}`;
256
+ } else {
257
+ const i = hoverNode!;
258
+ const node = shown.nodes[i]!;
259
+ frame.tip({ x: round(node.x + nodeWidth() / 2), y: round(node.y0), title: model.nodes[i]!.label, rows: [{ name: 'Total', color: model.nodes[i]!.color, value: format(model.value[i]!) }] });
260
+ }
261
+ };
262
+
263
+ const draw = (animate: boolean) => {
264
+ glide?.kill();
265
+ const name = options.label ?? 'Diagrama de flujo';
266
+ canvas.setAttribute('aria-label', hasData() ? `${name}. ${model.links.length} flujos entre ${model.used.filter(Boolean).length} etapas. Usa las flechas para recorrer los flujos.` : `${name}: ${options.emptyLabel ?? 'sin datos'}`);
267
+ frame.fillTable(name, ['Flujo', 'Valor'], model.links.map((link) => [`${model.nodes[link.source]!.label} → ${model.nodes[link.target]!.label}`, format(link.value)]));
268
+ frame.fillLegend([], false);
269
+ const ok = hasData();
270
+ frame.empty.hidden = ok;
271
+ frame.empty.textContent = options.emptyLabel ?? 'Sin datos para mostrar';
272
+ plot.hidden = !ok;
273
+ if (!ok) {
274
+ canvas.replaceChildren();
275
+ shown = null;
276
+ selected = null;
277
+ return;
278
+ }
279
+ if (selected !== null && selected >= model.links.length) selected = null;
280
+ const before = shown;
281
+ const target = layoutOf();
282
+ const comparable = before && before.nodes.length === target.nodes.length && before.links.length === target.links.length;
283
+ build();
284
+ const done = () => {
285
+ paint(target);
286
+ paintSelection(false);
287
+ };
288
+ if (!animate || reduced()) return done();
289
+ if (comparable) {
290
+ // Same nodes and flows: every node and band glides to its new place.
291
+ const state = { t: 0 };
292
+ const mix = (a: number, b: number) => a + (b - a) * state.t;
293
+ glide = gsap.to(state, {
294
+ t: 1,
295
+ duration: 0.6,
296
+ ease: EASE.swatch,
297
+ onUpdate: () =>
298
+ paint({
299
+ nodes: target.nodes.map((node, i) => ({ x: mix(before!.nodes[i]!.x, node.x), y0: mix(before!.nodes[i]!.y0, node.y0), y1: mix(before!.nodes[i]!.y1, node.y1) })),
300
+ links: target.links.map((link, k) => ({ sy: mix(before!.links[k]!.sy, link.sy), ty: mix(before!.links[k]!.ty, link.ty), width: mix(before!.links[k]!.width, link.width) })),
301
+ }),
302
+ onComplete: done,
303
+ });
304
+ return;
305
+ }
306
+ // First appearance: nodes grow from their middles column by column; the bands are wiped in from the left.
307
+ done();
308
+ const timeline = gsap.timeline();
309
+ rects.forEach((rect, i) => {
310
+ timeline.fromTo(rect, { scaleY: 0, transformOrigin: '50% 50%' }, { scaleY: 1, duration: 0.5, ease: EASE.swatch, clearProps: 'transform' }, (model.depth[i] ?? 0) * 0.12);
311
+ });
312
+ timeline.fromTo(names, { opacity: 0 }, { opacity: 1, duration: 0.4, stagger: 0.02, clearProps: 'opacity' }, 0.2);
313
+ const clip = svg('clipPath', { id: `${uid}-wipe` });
314
+ const rect = svg('rect', { x: 0, y: 0, width: 0, height });
315
+ clip.append(rect);
316
+ canvas.prepend(clip);
317
+ const flows = canvas.querySelector('[data-mk-part="links"]')!;
318
+ flows.setAttribute('clip-path', `url(#${uid}-wipe)`);
319
+ timeline.to(rect, { attr: { width }, duration: 0.9, ease: EASE.wipe, onComplete: () => {
320
+ flows.removeAttribute('clip-path');
321
+ clip.remove();
322
+ } }, 0.1);
323
+ glide = timeline;
324
+ };
325
+
326
+ const select = (index: number | null, announce = false) => {
327
+ if (scope.disposed) return;
328
+ const n = model.links.length;
329
+ const next = index === null || !n ? null : ((Math.round(index) % n) + n) % n;
330
+ if (next === selected) return;
331
+ selected = next;
332
+ paintSelection(announce);
333
+ options.onSelect?.(selected === null ? null : model.links[selected]!.given);
334
+ const link = selected === null ? null : model.links[selected]!;
335
+ root.dispatchEvent(new CustomEvent('mk:select', { bubbles: true, detail: { index: link?.given ?? null, source: link ? model.nodes[link.source]!.id : null, target: link ? model.nodes[link.target]!.id : null, value: link?.value ?? null } }));
336
+ };
337
+
338
+ scope.on(canvas, 'pointermove', (event) => {
339
+ const target = event.target as Element;
340
+ const band = target.closest('[data-mk-index]');
341
+ const node = target.closest('[data-mk-node]');
342
+ if (node) {
343
+ const i = Number(node.getAttribute('data-mk-node'));
344
+ if (selected !== null) select(null);
345
+ if (hoverNode !== i) {
346
+ hoverNode = i;
347
+ paintSelection(false);
348
+ }
349
+ return;
350
+ }
351
+ if (hoverNode !== null) {
352
+ hoverNode = null;
353
+ paintSelection(false);
354
+ }
355
+ select(band ? Number(band.getAttribute('data-mk-index')) : null);
356
+ });
357
+ scope.on(canvas, 'pointerleave', (event) => {
358
+ if ((event as PointerEvent).pointerType !== 'mouse') return;
359
+ hoverNode = null;
360
+ select(null);
361
+ paintSelection(false);
362
+ });
363
+ scope.on(canvas, 'focus', () => {
364
+ if (selected === null && hasData()) select(0, true);
365
+ });
366
+ scope.on(canvas, 'blur', () => select(null));
367
+ scope.on(canvas, 'keydown', (event) => {
368
+ const key = (event as KeyboardEvent).key;
369
+ const moves: Record<string, number | null> = { ArrowDown: (selected ?? -1) + 1, ArrowRight: (selected ?? -1) + 1, ArrowUp: (selected ?? 1) - 1, ArrowLeft: (selected ?? 1) - 1, Home: 0, End: model.links.length - 1, Escape: null };
370
+ if (!(key in moves) || !hasData()) return;
371
+ event.preventDefault();
372
+ select(moves[key]!, true);
373
+ });
374
+ onWidth(root, scope, () => {
375
+ if (!hasData()) return;
376
+ const layout = layoutOf();
377
+ build();
378
+ paint(layout);
379
+ paintSelection(false);
380
+ });
381
+
382
+ draw(true);
383
+
384
+ return {
385
+ update(next) {
386
+ if (scope.disposed) return;
387
+ options = { ...options, ...next };
388
+ model = modelOf();
389
+ draw(true);
390
+ },
391
+ select: (index) => {
392
+ // `index` is the flow's place in `links`.
393
+ const at = index === null ? null : model.links.findIndex((link) => link.given === index);
394
+ select(at === null || at < 0 ? null : at);
395
+ },
396
+ get selected() {
397
+ return selected === null ? null : model.links[selected]!.given;
398
+ },
399
+ destroy: () => scope.dispose(),
400
+ };
401
+ }
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import type { HTMLAttributes } from 'react';
3
+ import { useChart } from '../chart/use-chart';
4
+ import { createSankeyChart, type SankeyChartInstance, type SankeyChartOptions } from './engine';
5
+
6
+ export interface SankeyChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect' | 'children'>, SankeyChartOptions {
7
+ instanceRef?: { current: SankeyChartInstance | null };
8
+ }
9
+
10
+ /** <SankeyChart label="Embudo" nodes={[{ id: 'visitas' }, …]} links={[{ source: 'visitas', target: 'carrito', value: 420 }, …]} /> */
11
+ export function SankeyChart({ nodes, links, height, nodeWidth, nodePadding, label, emptyLabel, formatValue, onSelect, instanceRef, className, ...props }: SankeyChartProps) {
12
+ const ref = useChart(createSankeyChart, { nodes, links, height, nodeWidth, nodePadding, label, emptyLabel } as SankeyChartOptions, { formatValue, onSelect }, instanceRef);
13
+ return <div {...props} ref={ref} className={['mk-chart mk-sankey-chart', className].filter(Boolean).join(' ')} />;
14
+ }
@@ -0,0 +1,60 @@
1
+ /* sankey-chart — bands that fade from their source's colour to their target's (35 %), nodes with 3 px corners;
2
+ needs chart.css for the family. The flow under the pointer lights up, the rest step back. */
3
+ .mk-sankey-chart,
4
+ mk-sankey-chart {
5
+ display: grid;
6
+ gap: 1rem;
7
+ }
8
+
9
+ [data-mk-chart-type='sankey'] [data-mk-chart-svg] {
10
+ cursor: pointer;
11
+ }
12
+
13
+ [data-mk-chart-type='sankey'] [data-mk-part='links'] path {
14
+ opacity: 0.35;
15
+ transition: opacity 0.2s ease;
16
+ }
17
+
18
+ [data-mk-chart-type='sankey'] [data-mk-part='links'] path[data-mk-on] {
19
+ opacity: 0.7;
20
+ }
21
+
22
+ [data-mk-chart-type='sankey'] [data-mk-part='links'] path[data-mk-dim] {
23
+ opacity: 0.1;
24
+ }
25
+
26
+ [data-mk-chart-type='sankey'] [data-mk-part='nodes'] rect {
27
+ transition: opacity 0.2s ease;
28
+ }
29
+
30
+ [data-mk-chart-type='sankey'] [data-mk-part='nodes'] rect[data-mk-dim] {
31
+ opacity: 0.45;
32
+ }
33
+
34
+ [data-mk-chart-type='sankey'] [data-mk-part='labels'] text {
35
+ fill: var(--mk-text);
36
+ font-size: 12px;
37
+ font-weight: 500;
38
+ paint-order: stroke;
39
+ stroke: var(--mk-chart-surface);
40
+ stroke-width: 3px;
41
+ stroke-linejoin: round;
42
+ pointer-events: none;
43
+ }
44
+
45
+ [data-mk-chart-type='sankey'] [data-mk-part='amount'] {
46
+ fill: var(--mk-muted);
47
+ font-weight: 400;
48
+ }
49
+
50
+ @media (prefers-reduced-motion: reduce) {
51
+ [data-mk-chart-type='sankey'] :is([data-mk-part='links'] path, [data-mk-part='nodes'] rect) {
52
+ transition: none;
53
+ }
54
+ }
55
+
56
+ @media (forced-colors: active) {
57
+ [data-mk-chart-type='sankey'] [data-mk-part='nodes'] rect {
58
+ fill: CanvasText !important;
59
+ }
60
+ }
@@ -0,0 +1,15 @@
1
+ # scratch-card
2
+
3
+ Rasca y gana para cupones: el contenido HTML real queda bajo una cubierta metalizada dibujada en canvas con brillo y «Rasca aquí». El puntero rasca con un pincel redondo y el progreso se mide por muestreo. Al pasar el umbral, el resto se disuelve con blur, el cupón entra con `pop` y salta confeti. Mientras está cubierto, el contenido es `inert`; el botón «Revelar» es la vía para teclado y lectores de pantalla, y la revelación se anuncia. Sin canvas 2D, la cubierta es CSS y el botón la retira.
4
+
5
+ ```html
6
+ <mk-scratch-card class="mk-scratch-card">
7
+ <div data-mk-scratch-content><strong>OTOÑO25</strong> · 25 % de descuento</div>
8
+ </mk-scratch-card>
9
+ ```
10
+
11
+ `defineElements()`, `createScratchCard(root, options)` (sin `[data-mk-scratch-content]`, los hijos del root pasan a uno) o `<ScratchCard onReveal={claim}>…</ScratchCard>`.
12
+
13
+ Opciones: `threshold=0.5`, `brush=22` px, `coverLabel='Rasca aquí'`, `revealLabel='Revelar'`, `revealedLabel='Premio revelado'`, `celebrate=true`, `onProgress(p)`, `onReveal()`. API: `reveal()`, `reset()`, `revealed`, `progress`, `destroy()`. Eventos `mk:progress` `{progress}` y `mk:reveal`. El premio es de la app: el componente sólo lo tapa.
14
+
15
+ Movimiento reducido: la cubierta desaparece sin blur ni confeti.
@@ -0,0 +1,30 @@
1
+ import { MkElement, defineElement, type OptionType } from '../../elements/base';
2
+ import { createScratchCard, type ScratchCardInstance } from './engine';
3
+
4
+ /**
5
+ * <mk-scratch-card class="mk-scratch-card" threshold="0.5">
6
+ * <div data-mk-scratch-content>…the coupon…</div>
7
+ * </mk-scratch-card>
8
+ * Emits mk:progress ({progress}) and mk:reveal.
9
+ */
10
+ export class MkScratchCardElement extends MkElement<ScratchCardInstance> {
11
+ static options: Record<string, OptionType> = { threshold: 'number', brush: 'number', coverLabel: 'string', revealLabel: 'string', revealedLabel: 'string', celebrate: 'boolean' };
12
+
13
+ protected create(options: Record<string, unknown>) {
14
+ return createScratchCard(this, options);
15
+ }
16
+
17
+ reveal() {
18
+ this.instance?.reveal();
19
+ }
20
+
21
+ reset() {
22
+ this.instance?.reset();
23
+ }
24
+
25
+ get revealed() {
26
+ return this.instance?.revealed ?? false;
27
+ }
28
+ }
29
+
30
+ export const defineScratchCard = () => defineElement('mk-scratch-card', MkScratchCardElement);