@20baht/stickers 0.0.0-stage → 0.1.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 (409) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +173 -2
  3. package/dist/all.d.ts +4 -0
  4. package/dist/all.js +7 -0
  5. package/dist/element.d.ts +103 -0
  6. package/dist/element.js +181 -0
  7. package/dist/graph.d.ts +172 -0
  8. package/dist/graph.js +374 -0
  9. package/dist/icons/access-point.d.ts +2 -0
  10. package/dist/icons/access-point.js +34 -0
  11. package/dist/icons/ai-agent.d.ts +2 -0
  12. package/dist/icons/ai-agent.js +50 -0
  13. package/dist/icons/alarm-clock.d.ts +2 -0
  14. package/dist/icons/alarm-clock.js +46 -0
  15. package/dist/icons/all-in-one.d.ts +2 -0
  16. package/dist/icons/all-in-one.js +37 -0
  17. package/dist/icons/angpao.d.ts +2 -0
  18. package/dist/icons/angpao.js +46 -0
  19. package/dist/icons/badge-reader.d.ts +2 -0
  20. package/dist/icons/badge-reader.js +51 -0
  21. package/dist/icons/baht-note.d.ts +2 -0
  22. package/dist/icons/baht-note.js +42 -0
  23. package/dist/icons/bamboo.d.ts +2 -0
  24. package/dist/icons/bamboo.js +57 -0
  25. package/dist/icons/banana-leaf.d.ts +2 -0
  26. package/dist/icons/banana-leaf.js +87 -0
  27. package/dist/icons/banana-tree.d.ts +2 -0
  28. package/dist/icons/banana-tree.js +75 -0
  29. package/dist/icons/bear.d.ts +2 -0
  30. package/dist/icons/bear.js +39 -0
  31. package/dist/icons/blade-chassis.d.ts +2 -0
  32. package/dist/icons/blade-chassis.js +43 -0
  33. package/dist/icons/bond.d.ts +2 -0
  34. package/dist/icons/bond.js +48 -0
  35. package/dist/icons/books.d.ts +2 -0
  36. package/dist/icons/books.js +44 -0
  37. package/dist/icons/bts-card.d.ts +2 -0
  38. package/dist/icons/bts-card.js +47 -0
  39. package/dist/icons/budget-jar.d.ts +2 -0
  40. package/dist/icons/budget-jar.js +43 -0
  41. package/dist/icons/cactus.d.ts +2 -0
  42. package/dist/icons/cactus.js +42 -0
  43. package/dist/icons/calculator.d.ts +2 -0
  44. package/dist/icons/calculator.js +46 -0
  45. package/dist/icons/calendar-month.d.ts +2 -0
  46. package/dist/icons/calendar-month.js +66 -0
  47. package/dist/icons/campfire.d.ts +2 -0
  48. package/dist/icons/campfire.js +63 -0
  49. package/dist/icons/cctv.d.ts +2 -0
  50. package/dist/icons/cctv.js +38 -0
  51. package/dist/icons/certificate.d.ts +2 -0
  52. package/dist/icons/certificate.js +50 -0
  53. package/dist/icons/cha-yen.d.ts +2 -0
  54. package/dist/icons/cha-yen.js +68 -0
  55. package/dist/icons/chedi.d.ts +2 -0
  56. package/dist/icons/chedi.js +56 -0
  57. package/dist/icons/classic-phone.d.ts +2 -0
  58. package/dist/icons/classic-phone.js +32 -0
  59. package/dist/icons/clipboard.d.ts +2 -0
  60. package/dist/icons/clipboard.js +61 -0
  61. package/dist/icons/cloud.d.ts +2 -0
  62. package/dist/icons/cloud.js +28 -0
  63. package/dist/icons/coins.d.ts +2 -0
  64. package/dist/icons/coins.js +34 -0
  65. package/dist/icons/compare.d.ts +2 -0
  66. package/dist/icons/compare.js +33 -0
  67. package/dist/icons/confetti.d.ts +2 -0
  68. package/dist/icons/confetti.js +72 -0
  69. package/dist/icons/convenience-bag.d.ts +2 -0
  70. package/dist/icons/convenience-bag.js +51 -0
  71. package/dist/icons/cooling.d.ts +2 -0
  72. package/dist/icons/cooling.js +46 -0
  73. package/dist/icons/copy-files.d.ts +2 -0
  74. package/dist/icons/copy-files.js +37 -0
  75. package/dist/icons/core-switch.d.ts +2 -0
  76. package/dist/icons/core-switch.js +48 -0
  77. package/dist/icons/cursor.d.ts +2 -0
  78. package/dist/icons/cursor.js +27 -0
  79. package/dist/icons/database.d.ts +2 -0
  80. package/dist/icons/database.js +24 -0
  81. package/dist/icons/desktop-tower.d.ts +2 -0
  82. package/dist/icons/desktop-tower.js +41 -0
  83. package/dist/icons/disc-image.d.ts +2 -0
  84. package/dist/icons/disc-image.js +54 -0
  85. package/dist/icons/dollar-note.d.ts +2 -0
  86. package/dist/icons/dollar-note.js +44 -0
  87. package/dist/icons/electric-bill.d.ts +2 -0
  88. package/dist/icons/electric-bill.js +51 -0
  89. package/dist/icons/email.d.ts +2 -0
  90. package/dist/icons/email.js +57 -0
  91. package/dist/icons/empty-state.d.ts +2 -0
  92. package/dist/icons/empty-state.js +75 -0
  93. package/dist/icons/expense.d.ts +2 -0
  94. package/dist/icons/expense.js +36 -0
  95. package/dist/icons/export-file.d.ts +2 -0
  96. package/dist/icons/export-file.js +35 -0
  97. package/dist/icons/eyedropper.d.ts +2 -0
  98. package/dist/icons/eyedropper.js +69 -0
  99. package/dist/icons/face-id.d.ts +2 -0
  100. package/dist/icons/face-id.js +51 -0
  101. package/dist/icons/file.d.ts +2 -0
  102. package/dist/icons/file.js +15 -0
  103. package/dist/icons/finance-b-coins.d.ts +8 -0
  104. package/dist/icons/finance-b-coins.js +14 -0
  105. package/dist/icons/finance-tray.d.ts +11 -0
  106. package/dist/icons/finance-tray.js +41 -0
  107. package/dist/icons/fingerprint.d.ts +2 -0
  108. package/dist/icons/fingerprint.js +45 -0
  109. package/dist/icons/firewall.d.ts +2 -0
  110. package/dist/icons/firewall.js +76 -0
  111. package/dist/icons/floating-ip.d.ts +2 -0
  112. package/dist/icons/floating-ip.js +59 -0
  113. package/dist/icons/flower.d.ts +2 -0
  114. package/dist/icons/flower.js +49 -0
  115. package/dist/icons/food.d.ts +6 -0
  116. package/dist/icons/food.js +18 -0
  117. package/dist/icons/freelance.d.ts +2 -0
  118. package/dist/icons/freelance.js +51 -0
  119. package/dist/icons/fuel.d.ts +2 -0
  120. package/dist/icons/fuel.js +46 -0
  121. package/dist/icons/goal.d.ts +2 -0
  122. package/dist/icons/goal.js +51 -0
  123. package/dist/icons/gold-bar.d.ts +2 -0
  124. package/dist/icons/gold-bar.js +60 -0
  125. package/dist/icons/hard-drive.d.ts +2 -0
  126. package/dist/icons/hard-drive.js +42 -0
  127. package/dist/icons/highlighter.d.ts +2 -0
  128. package/dist/icons/highlighter.js +75 -0
  129. package/dist/icons/home-router.d.ts +2 -0
  130. package/dist/icons/home-router.js +32 -0
  131. package/dist/icons/hot-drink.d.ts +2 -0
  132. package/dist/icons/hot-drink.js +33 -0
  133. package/dist/icons/hsm.d.ts +2 -0
  134. package/dist/icons/hsm.js +54 -0
  135. package/dist/icons/id-card.d.ts +2 -0
  136. package/dist/icons/id-card.js +36 -0
  137. package/dist/icons/income.d.ts +2 -0
  138. package/dist/icons/income.js +28 -0
  139. package/dist/icons/index.d.ts +185 -0
  140. package/dist/icons/index.js +366 -0
  141. package/dist/icons/interest.d.ts +2 -0
  142. package/dist/icons/interest.js +66 -0
  143. package/dist/icons/iot-sensor.d.ts +2 -0
  144. package/dist/icons/iot-sensor.js +35 -0
  145. package/dist/icons/ip-phone.d.ts +2 -0
  146. package/dist/icons/ip-phone.js +47 -0
  147. package/dist/icons/ipad-gen8.d.ts +2 -0
  148. package/dist/icons/ipad-gen8.js +58 -0
  149. package/dist/icons/iphone-17.d.ts +2 -0
  150. package/dist/icons/iphone-17.js +37 -0
  151. package/dist/icons/iso.d.ts +2 -0
  152. package/dist/icons/iso.js +3 -0
  153. package/dist/icons/kaprao.d.ts +2 -0
  154. package/dist/icons/kaprao.js +70 -0
  155. package/dist/icons/key-pair.d.ts +2 -0
  156. package/dist/icons/key-pair.js +54 -0
  157. package/dist/icons/key.d.ts +3 -0
  158. package/dist/icons/key.js +37 -0
  159. package/dist/icons/keyboard.d.ts +2 -0
  160. package/dist/icons/keyboard.js +35 -0
  161. package/dist/icons/kite.d.ts +2 -0
  162. package/dist/icons/kite.js +53 -0
  163. package/dist/icons/kvm.d.ts +2 -0
  164. package/dist/icons/kvm.js +53 -0
  165. package/dist/icons/lamp.d.ts +2 -0
  166. package/dist/icons/lamp.js +49 -0
  167. package/dist/icons/laptop.d.ts +2 -0
  168. package/dist/icons/laptop.js +44 -0
  169. package/dist/icons/load-balancer.d.ts +2 -0
  170. package/dist/icons/load-balancer.js +50 -0
  171. package/dist/icons/lock-screen.d.ts +2 -0
  172. package/dist/icons/lock-screen.js +44 -0
  173. package/dist/icons/long-tail-boat.d.ts +2 -0
  174. package/dist/icons/long-tail-boat.js +66 -0
  175. package/dist/icons/lottery.d.ts +2 -0
  176. package/dist/icons/lottery.js +51 -0
  177. package/dist/icons/lotus.d.ts +2 -0
  178. package/dist/icons/lotus.js +70 -0
  179. package/dist/icons/mac-mini.d.ts +2 -0
  180. package/dist/icons/mac-mini.js +31 -0
  181. package/dist/icons/macbook-air.d.ts +2 -0
  182. package/dist/icons/macbook-air.js +41 -0
  183. package/dist/icons/mailbox-thai.d.ts +2 -0
  184. package/dist/icons/mailbox-thai.js +66 -0
  185. package/dist/icons/mango-sticky-rice.d.ts +2 -0
  186. package/dist/icons/mango-sticky-rice.js +41 -0
  187. package/dist/icons/marigold.d.ts +2 -0
  188. package/dist/icons/marigold.js +69 -0
  189. package/dist/icons/market-basket.d.ts +2 -0
  190. package/dist/icons/market-basket.js +69 -0
  191. package/dist/icons/media-player.d.ts +2 -0
  192. package/dist/icons/media-player.js +71 -0
  193. package/dist/icons/metrics.d.ts +2 -0
  194. package/dist/icons/metrics.js +58 -0
  195. package/dist/icons/mini-pc.d.ts +2 -0
  196. package/dist/icons/mini-pc.js +26 -0
  197. package/dist/icons/modem.d.ts +2 -0
  198. package/dist/icons/modem.js +37 -0
  199. package/dist/icons/monitor.d.ts +2 -0
  200. package/dist/icons/monitor.js +40 -0
  201. package/dist/icons/monstera.d.ts +2 -0
  202. package/dist/icons/monstera.js +47 -0
  203. package/dist/icons/moon.d.ts +2 -0
  204. package/dist/icons/moon.js +55 -0
  205. package/dist/icons/motorbike-taxi.d.ts +2 -0
  206. package/dist/icons/motorbike-taxi.js +42 -0
  207. package/dist/icons/music-note.d.ts +2 -0
  208. package/dist/icons/music-note.js +63 -0
  209. package/dist/icons/nas-2bay.d.ts +2 -0
  210. package/dist/icons/nas-2bay.js +49 -0
  211. package/dist/icons/nas.d.ts +2 -0
  212. package/dist/icons/nas.js +41 -0
  213. package/dist/icons/nature-iso.d.ts +29 -0
  214. package/dist/icons/nature-iso.js +74 -0
  215. package/dist/icons/noodle-soup.d.ts +2 -0
  216. package/dist/icons/noodle-soup.js +52 -0
  217. package/dist/icons/notebook.d.ts +2 -0
  218. package/dist/icons/notebook.js +44 -0
  219. package/dist/icons/object-drum.d.ts +18 -0
  220. package/dist/icons/object-drum.js +63 -0
  221. package/dist/icons/otp.d.ts +2 -0
  222. package/dist/icons/otp.js +46 -0
  223. package/dist/icons/over-budget.d.ts +2 -0
  224. package/dist/icons/over-budget.js +48 -0
  225. package/dist/icons/pad-see-ew.d.ts +2 -0
  226. package/dist/icons/pad-see-ew.js +56 -0
  227. package/dist/icons/palm-tree.d.ts +2 -0
  228. package/dist/icons/palm-tree.js +52 -0
  229. package/dist/icons/paper-boat.d.ts +2 -0
  230. package/dist/icons/paper-boat.js +67 -0
  231. package/dist/icons/paper.d.ts +3 -0
  232. package/dist/icons/paper.js +45 -0
  233. package/dist/icons/password.d.ts +2 -0
  234. package/dist/icons/password.js +45 -0
  235. package/dist/icons/patch-panel.d.ts +2 -0
  236. package/dist/icons/patch-panel.js +41 -0
  237. package/dist/icons/pdu.d.ts +2 -0
  238. package/dist/icons/pdu.js +40 -0
  239. package/dist/icons/phone-topup.d.ts +2 -0
  240. package/dist/icons/phone-topup.js +55 -0
  241. package/dist/icons/photo.d.ts +2 -0
  242. package/dist/icons/photo.js +48 -0
  243. package/dist/icons/phuang-malai.d.ts +2 -0
  244. package/dist/icons/phuang-malai.js +59 -0
  245. package/dist/icons/pie-chart.d.ts +2 -0
  246. package/dist/icons/pie-chart.js +36 -0
  247. package/dist/icons/piggy-bank.d.ts +2 -0
  248. package/dist/icons/piggy-bank.js +64 -0
  249. package/dist/icons/plant-kit.d.ts +23 -0
  250. package/dist/icons/plant-kit.js +112 -0
  251. package/dist/icons/plastic-stool.d.ts +2 -0
  252. package/dist/icons/plastic-stool.js +67 -0
  253. package/dist/icons/pointer.d.ts +1 -0
  254. package/dist/icons/pointer.js +12 -0
  255. package/dist/icons/pos.d.ts +2 -0
  256. package/dist/icons/pos.js +59 -0
  257. package/dist/icons/potted-plant.d.ts +2 -0
  258. package/dist/icons/potted-plant.js +31 -0
  259. package/dist/icons/power-pole.d.ts +2 -0
  260. package/dist/icons/power-pole.js +60 -0
  261. package/dist/icons/power-station.d.ts +2 -0
  262. package/dist/icons/power-station.js +56 -0
  263. package/dist/icons/printer.d.ts +2 -0
  264. package/dist/icons/printer.js +46 -0
  265. package/dist/icons/qr-code.d.ts +2 -0
  266. package/dist/icons/qr-code.js +45 -0
  267. package/dist/icons/rack.d.ts +2 -0
  268. package/dist/icons/rack.js +39 -0
  269. package/dist/icons/rain-cloud.d.ts +2 -0
  270. package/dist/icons/rain-cloud.js +31 -0
  271. package/dist/icons/rainbow.d.ts +2 -0
  272. package/dist/icons/rainbow.js +46 -0
  273. package/dist/icons/receipt.d.ts +2 -0
  274. package/dist/icons/receipt.js +56 -0
  275. package/dist/icons/redmi-note-9s-pro.d.ts +2 -0
  276. package/dist/icons/redmi-note-9s-pro.js +37 -0
  277. package/dist/icons/register.d.ts +2 -0
  278. package/dist/icons/register.js +40 -0
  279. package/dist/icons/remote-desktop.d.ts +2 -0
  280. package/dist/icons/remote-desktop.js +62 -0
  281. package/dist/icons/remote-folder.d.ts +2 -0
  282. package/dist/icons/remote-folder.js +55 -0
  283. package/dist/icons/rent.d.ts +2 -0
  284. package/dist/icons/rent.js +50 -0
  285. package/dist/icons/rock.d.ts +2 -0
  286. package/dist/icons/rock.js +80 -0
  287. package/dist/icons/router.d.ts +2 -0
  288. package/dist/icons/router.js +59 -0
  289. package/dist/icons/salary.d.ts +2 -0
  290. package/dist/icons/salary.js +54 -0
  291. package/dist/icons/saving-streak.d.ts +2 -0
  292. package/dist/icons/saving-streak.js +66 -0
  293. package/dist/icons/scan-slip.d.ts +2 -0
  294. package/dist/icons/scan-slip.js +53 -0
  295. package/dist/icons/scissors.d.ts +2 -0
  296. package/dist/icons/scissors.js +52 -0
  297. package/dist/icons/server-cabinet.d.ts +2 -0
  298. package/dist/icons/server-cabinet.js +49 -0
  299. package/dist/icons/server.d.ts +2 -0
  300. package/dist/icons/server.js +41 -0
  301. package/dist/icons/shared.d.ts +8 -0
  302. package/dist/icons/shared.js +18 -0
  303. package/dist/icons/shield.d.ts +3 -0
  304. package/dist/icons/shield.js +28 -0
  305. package/dist/icons/shooting-star.d.ts +2 -0
  306. package/dist/icons/shooting-star.js +37 -0
  307. package/dist/icons/shopping-box.d.ts +2 -0
  308. package/dist/icons/shopping-box.js +46 -0
  309. package/dist/icons/sky-kit.d.ts +19 -0
  310. package/dist/icons/sky-kit.js +72 -0
  311. package/dist/icons/smart-tv.d.ts +2 -0
  312. package/dist/icons/smart-tv.js +39 -0
  313. package/dist/icons/smartphone.d.ts +2 -0
  314. package/dist/icons/smartphone.js +30 -0
  315. package/dist/icons/sms.d.ts +2 -0
  316. package/dist/icons/sms.js +45 -0
  317. package/dist/icons/snapshots.d.ts +2 -0
  318. package/dist/icons/snapshots.js +45 -0
  319. package/dist/icons/snip.d.ts +2 -0
  320. package/dist/icons/snip.js +63 -0
  321. package/dist/icons/spirit-house.d.ts +2 -0
  322. package/dist/icons/spirit-house.js +73 -0
  323. package/dist/icons/ssl-certificate.d.ts +2 -0
  324. package/dist/icons/ssl-certificate.js +56 -0
  325. package/dist/icons/star.d.ts +2 -0
  326. package/dist/icons/star.js +16 -0
  327. package/dist/icons/stock.d.ts +2 -0
  328. package/dist/icons/stock.js +62 -0
  329. package/dist/icons/storage-array.d.ts +2 -0
  330. package/dist/icons/storage-array.js +40 -0
  331. package/dist/icons/storm.d.ts +2 -0
  332. package/dist/icons/storm.js +43 -0
  333. package/dist/icons/street-food-cart.d.ts +2 -0
  334. package/dist/icons/street-food-cart.js +66 -0
  335. package/dist/icons/street-kit.d.ts +19 -0
  336. package/dist/icons/street-kit.js +67 -0
  337. package/dist/icons/street-sign.d.ts +2 -0
  338. package/dist/icons/street-sign.js +42 -0
  339. package/dist/icons/studio-monitors.d.ts +2 -0
  340. package/dist/icons/studio-monitors.js +67 -0
  341. package/dist/icons/sun.d.ts +2 -0
  342. package/dist/icons/sun.js +40 -0
  343. package/dist/icons/support.d.ts +2 -0
  344. package/dist/icons/support.js +48 -0
  345. package/dist/icons/switch.d.ts +2 -0
  346. package/dist/icons/switch.js +34 -0
  347. package/dist/icons/tablet.d.ts +2 -0
  348. package/dist/icons/tablet.js +44 -0
  349. package/dist/icons/tape-library.d.ts +2 -0
  350. package/dist/icons/tape-library.js +48 -0
  351. package/dist/icons/temple-donation.d.ts +2 -0
  352. package/dist/icons/temple-donation.js +60 -0
  353. package/dist/icons/tent.d.ts +2 -0
  354. package/dist/icons/tent.js +66 -0
  355. package/dist/icons/terminal.d.ts +2 -0
  356. package/dist/icons/terminal.js +56 -0
  357. package/dist/icons/thai-house.d.ts +2 -0
  358. package/dist/icons/thai-house.js +85 -0
  359. package/dist/icons/thai-lantern.d.ts +2 -0
  360. package/dist/icons/thai-lantern.js +61 -0
  361. package/dist/icons/thinkpad-l380.d.ts +2 -0
  362. package/dist/icons/thinkpad-l380.js +54 -0
  363. package/dist/icons/timer.d.ts +2 -0
  364. package/dist/icons/timer.js +59 -0
  365. package/dist/icons/train-ticket.d.ts +2 -0
  366. package/dist/icons/train-ticket.js +57 -0
  367. package/dist/icons/trash.d.ts +2 -0
  368. package/dist/icons/trash.js +62 -0
  369. package/dist/icons/tree.d.ts +2 -0
  370. package/dist/icons/tree.js +40 -0
  371. package/dist/icons/tuk-tuk.d.ts +2 -0
  372. package/dist/icons/tuk-tuk.js +45 -0
  373. package/dist/icons/tulip.d.ts +2 -0
  374. package/dist/icons/tulip.js +56 -0
  375. package/dist/icons/tunnel.d.ts +2 -0
  376. package/dist/icons/tunnel.js +50 -0
  377. package/dist/icons/two-factor.d.ts +2 -0
  378. package/dist/icons/two-factor.js +81 -0
  379. package/dist/icons/ups.d.ts +2 -0
  380. package/dist/icons/ups.js +37 -0
  381. package/dist/icons/usb-drive.d.ts +2 -0
  382. package/dist/icons/usb-drive.js +35 -0
  383. package/dist/icons/verified.d.ts +2 -0
  384. package/dist/icons/verified.js +32 -0
  385. package/dist/icons/virtual-machine.d.ts +2 -0
  386. package/dist/icons/virtual-machine.js +66 -0
  387. package/dist/icons/volume.d.ts +6 -0
  388. package/dist/icons/volume.js +35 -0
  389. package/dist/icons/vpn-gateway.d.ts +2 -0
  390. package/dist/icons/vpn-gateway.js +51 -0
  391. package/dist/icons/wake-on-lan.d.ts +2 -0
  392. package/dist/icons/wake-on-lan.js +40 -0
  393. package/dist/icons/wallet.d.ts +3 -0
  394. package/dist/icons/wallet.js +55 -0
  395. package/dist/icons/water-jar.d.ts +2 -0
  396. package/dist/icons/water-jar.js +72 -0
  397. package/dist/icons/wooden-window.d.ts +2 -0
  398. package/dist/icons/wooden-window.js +65 -0
  399. package/dist/index.d.ts +2 -0
  400. package/dist/index.js +4 -0
  401. package/dist/iso.d.ts +32 -0
  402. package/dist/iso.js +64 -0
  403. package/dist/load.d.ts +197 -0
  404. package/dist/load.js +197 -0
  405. package/dist/motions.d.ts +68 -0
  406. package/dist/motions.js +446 -0
  407. package/dist/sticker.d.ts +269 -0
  408. package/dist/sticker.js +1009 -0
  409. package/package.json +101 -4
@@ -0,0 +1,172 @@
1
+ import { LitElement } from 'lit';
2
+ import type { PropertyValues } from 'lit';
3
+ import './element.js';
4
+ import type { Icon, Vec } from './sticker.js';
5
+ /**
6
+ * A sticker at a grid cell. `x` runs along the floor to the right, `y` towards the viewer.
7
+ * Give it `sticker` (a registered name) or `icon` (the icon object); `icon` wins when both are set.
8
+ */
9
+ export interface GraphNode {
10
+ id: string;
11
+ /** Name of a registered sticker (`import '@20baht/stickers/all'`, or `registerSticker`). */
12
+ sticker?: string;
13
+ /** The icon itself (`import { server } from '@20baht/stickers/icons/server'`); needs no registry. */
14
+ icon?: Icon;
15
+ /** First caption line, under the sticker. */
16
+ label?: string;
17
+ /** Second caption line, muted: an address, a port. */
18
+ sub?: string;
19
+ x: number;
20
+ y: number;
21
+ }
22
+ /** A dashed line between two nodes; `dir` puts arrowheads on it. */
23
+ export interface GraphLink {
24
+ from: string;
25
+ to: string;
26
+ dir?: 'none' | 'forward' | 'both';
27
+ }
28
+ /** Packet colours, the sticker accents: they follow the same --baht-* tokens. */
29
+ export type GraphTone = 'main' | 'deep' | 'gold' | 'ok' | 'hot';
30
+ /** One packet: from a node to a node, in the order of `flow`. */
31
+ export interface GraphStep {
32
+ from: string;
33
+ to: string;
34
+ tone?: GraphTone;
35
+ /** What the packet is, for the host's own list (`baht-step` carries it). */
36
+ label?: string;
37
+ }
38
+ /** The whole diagram, as JSON. */
39
+ export interface StickerGraph {
40
+ nodes: readonly GraphNode[];
41
+ links?: readonly GraphLink[];
42
+ flow?: readonly GraphStep[];
43
+ }
44
+ /** Floor units per grid cell, and the sticker's width in the same units. */
45
+ export declare const CELL = 150;
46
+ export declare const STICKER = 150;
47
+ /** A grid cell on the floor, where it lands in the drawing. */
48
+ export declare const toScreen: ([x, y]: Vec) => Vec;
49
+ /** A point in the drawing back to the floor, in cells (not rounded). */
50
+ export declare const toGrid: ([sx, sy]: Vec) => Vec;
51
+ export declare const TONES: Record<GraphTone, string>;
52
+ export interface PlacedNode {
53
+ node: GraphNode;
54
+ at: Vec;
55
+ }
56
+ export interface PlacedLink {
57
+ link: GraphLink;
58
+ a: Vec;
59
+ b: Vec;
60
+ }
61
+ export interface GraphLayout {
62
+ /** viewBox of the drawing: x, y, width, height. */
63
+ box: readonly [number, number, number, number];
64
+ nodes: PlacedNode[];
65
+ links: PlacedLink[];
66
+ /** The floor grid under the nodes, as one path. */
67
+ grid: string;
68
+ }
69
+ /** The segment between two nodes, cut back so it starts and ends beside the stickers, not under them. */
70
+ export declare function segment(a: Vec, b: Vec, gap?: number): [Vec, Vec];
71
+ /** Where every node, link and grid line lands; pure, so hosts and tests can measure a graph without a DOM. */
72
+ export declare function layoutGraph(graph: StickerGraph): GraphLayout;
73
+ /**
74
+ * A network-style diagram drawn with stickers. Light DOM, like every `<baht-*>` element.
75
+ *
76
+ * Set `graph` as a property: `{ nodes: [{ id, sticker | icon, label, sub, x, y }], links: [{ from, to, dir }],
77
+ * flow: [{ from, to, tone, label }] }`. Nodes sit on grid cells of the floor plane the stickers lean on; links are
78
+ * dashed; `flow` sends one packet at a time along it, then rests and loops. Register the stickers it names first
79
+ * (`import '@20baht/stickers/all'`), or give a node its `icon` object. Colours follow the --baht-* tokens; under
80
+ * reduced motion no packet moves, and the flow waits (no packet moves, no `baht-step` fires) while the element is
81
+ * scrolled out of view. With `interactive` every node is a button (Tab, Enter, Space, click) that fires
82
+ * `baht-node`, and the stage is a group instead of one image.
83
+ *
84
+ * @fires {CustomEvent<{ index: number; step: GraphStep }>} baht-step - A packet set off on step `index` of `flow`.
85
+ * @fires {CustomEvent<{ id: string; node: GraphNode }>} baht-node - A node was clicked or pressed (Enter, Space); only with `interactive`.
86
+ * @attr step-ms - Milliseconds a packet takes along one step (default 900).
87
+ * @attr paused - Holds the packets where they are.
88
+ * @attr hide-grid - Leaves out the floor grid.
89
+ * @attr label - Accessible name of the diagram.
90
+ * @attr interactive - Nodes are focusable buttons that fire `baht-node`.
91
+ */
92
+ export declare class BahtStickerGraph extends LitElement {
93
+ static properties: {
94
+ graph: {
95
+ attribute: boolean;
96
+ };
97
+ stepMs: {
98
+ type: NumberConstructor;
99
+ attribute: string;
100
+ };
101
+ paused: {
102
+ type: BooleanConstructor;
103
+ };
104
+ hideGrid: {
105
+ type: BooleanConstructor;
106
+ attribute: string;
107
+ };
108
+ label: {
109
+ type: StringConstructor;
110
+ };
111
+ interactive: {
112
+ type: BooleanConstructor;
113
+ };
114
+ };
115
+ /** The diagram to draw. */
116
+ graph: StickerGraph | undefined;
117
+ stepMs: number;
118
+ paused: boolean;
119
+ hideGrid: boolean;
120
+ label: string | undefined;
121
+ interactive: boolean;
122
+ private layout;
123
+ /** Where each node sits, by id; rebuilt with the layout. */
124
+ private places;
125
+ private packet;
126
+ private frame;
127
+ private clock;
128
+ private last;
129
+ private index;
130
+ /** In the viewport, as far as the observer has said. */
131
+ private inView;
132
+ private sight;
133
+ private motion;
134
+ constructor();
135
+ protected createRenderRoot(): HTMLElement;
136
+ connectedCallback(): void;
137
+ disconnectedCallback(): void;
138
+ protected willUpdate(changed: PropertyValues<this>): void;
139
+ protected updated(): void;
140
+ /** The grid cell under a page point (`clientX`, `clientY`), rounded; for builders that place nodes by pointer. */
141
+ gridAt(clientX: number, clientY: number): Vec;
142
+ /** Asks for one frame, unless one is on its way. Whatever changes where the packet is, or whether it moves, calls this. */
143
+ private readonly wake;
144
+ /** The packets' own loop, apart from the sticker clock; it runs only while a packet can move. */
145
+ private readonly tick;
146
+ private reduced;
147
+ /** Whether packets are travelling: a flow, not paused, motion allowed, and the element in view. */
148
+ private moving;
149
+ /** Puts the packet where the clock says, and announces each step as it sets off. */
150
+ private movePacket;
151
+ private enter;
152
+ private pick;
153
+ private readonly onNodeKey;
154
+ /** One node: its sticker, its caption, and its button role when `interactive`. */
155
+ private renderNode;
156
+ protected render(): unknown;
157
+ }
158
+ declare global {
159
+ interface HTMLElementTagNameMap {
160
+ 'baht-sticker-graph': BahtStickerGraph;
161
+ }
162
+ interface HTMLElementEventMap {
163
+ 'baht-step': CustomEvent<{
164
+ index: number;
165
+ step: GraphStep;
166
+ }>;
167
+ 'baht-node': CustomEvent<{
168
+ id: string;
169
+ node: GraphNode;
170
+ }>;
171
+ }
172
+ }
package/dist/graph.js ADDED
@@ -0,0 +1,374 @@
1
+ // <baht-sticker-graph>: stickers placed on the house floor plane, joined by dashed links, with packets that travel
2
+ // them one step after another. A diagram of how machines talk, drawn in the sticker look.
3
+ import { html, LitElement, nothing, svg } from 'lit';
4
+ import './element.js';
5
+ import { onFace, VIEWS } from './sticker.js';
6
+ /** Floor units per grid cell, and the sticker's width in the same units. */
7
+ export const CELL = 150;
8
+ export const STICKER = 150;
9
+ const PAD = 70;
10
+ const CAPTION = 56;
11
+ const PLANE = VIEWS.right.tilt;
12
+ const [AX, AY] = onFace(PLANE, [CELL, 0]);
13
+ const [BX, BY] = onFace(PLANE, [0, CELL]);
14
+ const DET = AX * BY - BX * AY;
15
+ /** A grid cell on the floor, where it lands in the drawing. */
16
+ export const toScreen = ([x, y]) => [AX * x + BX * y, AY * x + BY * y];
17
+ /** A point in the drawing back to the floor, in cells (not rounded). */
18
+ export const toGrid = ([sx, sy]) => [
19
+ (BY * sx - BX * sy) / DET,
20
+ (AX * sy - AY * sx) / DET,
21
+ ];
22
+ export const TONES = {
23
+ main: 'var(--baht-primary, #2e4a9e)',
24
+ deep: 'var(--baht-neutral, #1c2a55)',
25
+ gold: 'var(--baht-gold-400, #f2b632)',
26
+ ok: 'var(--baht-success, #1f7a4d)',
27
+ hot: 'var(--baht-error, #c8102e)',
28
+ };
29
+ const r1 = (n) => Math.round(n * 10) / 10;
30
+ /** The segment between two nodes, cut back so it starts and ends beside the stickers, not under them. */
31
+ export function segment(a, b, gap = STICKER * 0.42) {
32
+ const [dx, dy] = [b[0] - a[0], b[1] - a[1]];
33
+ const len = Math.hypot(dx, dy);
34
+ if (len <= gap * 2)
35
+ return [a, b];
36
+ const [ux, uy] = [dx / len, dy / len];
37
+ return [
38
+ [r1(a[0] + ux * gap), r1(a[1] + uy * gap)],
39
+ [r1(b[0] - ux * gap), r1(b[1] - uy * gap)],
40
+ ];
41
+ }
42
+ /** Floor lines between cells, two cells past the outermost nodes; the stage clips them at its edge. */
43
+ function gridPath(x0, x1, y0, y1) {
44
+ const line = (p, q) => {
45
+ const [a, b] = [toScreen(p), toScreen(q)];
46
+ return `M${String(r1(a[0]))} ${String(r1(a[1]))}L${String(r1(b[0]))} ${String(r1(b[1]))}`;
47
+ };
48
+ let d = '';
49
+ for (let x = x0; x <= x1 + 1; x++)
50
+ d += line([x - 0.5, y0 - 0.5], [x - 0.5, y1 + 0.5]);
51
+ for (let y = y0; y <= y1 + 1; y++)
52
+ d += line([x0 - 0.5, y - 0.5], [x1 + 0.5, y - 0.5]);
53
+ return d;
54
+ }
55
+ /** Where every node, link and grid line lands; pure, so hosts and tests can measure a graph without a DOM. */
56
+ export function layoutGraph(graph) {
57
+ const nodes = graph.nodes.map((node) => ({ node, at: toScreen([node.x, node.y]) }));
58
+ const byId = new Map(nodes.map((n) => [n.node.id, n.at]));
59
+ const links = [];
60
+ for (const link of graph.links ?? []) {
61
+ const [a, b] = [byId.get(link.from), byId.get(link.to)];
62
+ if (a && b)
63
+ links.push({ link, a, b });
64
+ }
65
+ if (!nodes.length)
66
+ return { box: [0, 0, 400, 300], nodes, links, grid: '' };
67
+ const xs = graph.nodes.map((n) => n.x);
68
+ const ys = graph.nodes.map((n) => n.y);
69
+ const [gx0, gx1, gy0, gy1] = [
70
+ Math.min(...xs) - 1,
71
+ Math.max(...xs) + 1,
72
+ Math.min(...ys) - 1,
73
+ Math.max(...ys) + 1,
74
+ ];
75
+ const sx = nodes.map((n) => n.at[0]);
76
+ const sy = nodes.map((n) => n.at[1]);
77
+ const half = STICKER / 2;
78
+ const left = Math.min(...sx) - half - PAD;
79
+ const top = Math.min(...sy) - half - PAD;
80
+ const right = Math.max(...sx) + half + PAD;
81
+ const bottom = Math.max(...sy) + half + CAPTION + PAD;
82
+ return {
83
+ box: [r1(left), r1(top), r1(right - left), r1(bottom - top)],
84
+ nodes,
85
+ links,
86
+ grid: gridPath(gx0, gx1, gy0, gy1),
87
+ };
88
+ }
89
+ const TAG = 'baht-sticker-graph';
90
+ const STYLE_ID = 'baht-sticker-graph-style';
91
+ const GAP_MS = 260;
92
+ const REST_MS = 1400;
93
+ function injectStyle() {
94
+ if (document.getElementById(STYLE_ID))
95
+ return;
96
+ const style = document.createElement('style');
97
+ style.id = STYLE_ID;
98
+ style.textContent = `
99
+ :where(${TAG}){display:block;position:relative;font-family:var(--baht-font-mono,ui-monospace,monospace)}
100
+ :where(${TAG}) .bsg-stage{position:relative;width:100%;overflow:hidden}
101
+ :where(${TAG}) .bsg-svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
102
+ :where(${TAG}) .bsg-grid{fill:none;stroke:var(--baht-color-border,#e2e5ec);stroke-width:1;vector-effect:non-scaling-stroke}
103
+ :where(${TAG}) .bsg-link{fill:none;stroke:var(--baht-color-primary,#2e4a9e);stroke-width:2;stroke-dasharray:6 6;opacity:.55;vector-effect:non-scaling-stroke}
104
+ :where(${TAG}) .bsg-head{fill:var(--baht-color-primary,#2e4a9e);opacity:.55}
105
+ :where(${TAG}) .bsg-packet{stroke:#0a0a0a;stroke-width:2.5;vector-effect:non-scaling-stroke}
106
+ :where(${TAG}) .bsg-node{position:absolute;margin:0;display:flex;flex-direction:column;align-items:center;transform:translate(-50%,-50%);transition:filter .2s}
107
+ :where(${TAG}) .bsg-node baht-sticker{width:100%}
108
+ :where(${TAG}) .bsg-node figcaption{position:absolute;top:92%;white-space:nowrap;text-align:center;line-height:1.25;font-size:var(--baht-text-xs,12px);color:var(--baht-color-text,#1c2a55)}
109
+ :where(${TAG}) .bsg-node figcaption b{font-weight:600;display:block}
110
+ :where(${TAG}) .bsg-node figcaption span{color:var(--baht-color-text-muted,#5b6478)}
111
+ :where(${TAG}) .bsg-node[data-active] figcaption b{color:var(--baht-color-primary,#2e4a9e)}
112
+ :where(${TAG}) .bsg-node[role=button]{cursor:pointer;border-radius:var(--baht-radius-md,8px)}
113
+ :where(${TAG}) .bsg-node[role=button]:focus-visible{outline:var(--baht-focus-ring,2px solid var(--baht-color-primary,#2e4a9e));outline-offset:2px}
114
+ `;
115
+ document.head.append(style);
116
+ }
117
+ /** The node's sticker: the `icon` object when it has one, else the registered `sticker` name. */
118
+ function nodeSticker(node, i) {
119
+ const offset = String(i * 20);
120
+ return node.icon
121
+ ? html `<baht-sticker .icon=${node.icon} offset=${offset} label=${node.label ?? node.icon.name}></baht-sticker>`
122
+ : html `<baht-sticker name=${node.sticker ?? ''} offset=${offset} label=${node.label ?? node.sticker ?? node.id}></baht-sticker>`;
123
+ }
124
+ function nodeCaption(node) {
125
+ if (!node.label && !node.sub)
126
+ return nothing;
127
+ return html `<figcaption>
128
+ ${node.label ? html `<b>${node.label}</b>` : nothing}${node.sub ? html `<span>${node.sub}</span>` : nothing}
129
+ </figcaption>`;
130
+ }
131
+ /** A pressable node's accessible name: its caption lines, else its id. */
132
+ const nodeName = (node) => [node.label, node.sub].filter(Boolean).join(', ') || node.id;
133
+ const pct = (v, of) => `${String(r1((v / of) * 1000) / 10)}%`;
134
+ function arrow(from, to) {
135
+ const [dx, dy] = [to[0] - from[0], to[1] - from[1]];
136
+ const len = Math.hypot(dx, dy) || 1;
137
+ const [ux, uy] = [dx / len, dy / len];
138
+ const [bx, by] = [to[0] - ux * 12, to[1] - uy * 12];
139
+ const [px, py] = [-uy * 6, ux * 6];
140
+ return `M${String(r1(to[0]))} ${String(r1(to[1]))}L${String(r1(bx + px))} ${String(r1(by + py))}L${String(r1(bx - px))} ${String(r1(by - py))}Z`;
141
+ }
142
+ /**
143
+ * A network-style diagram drawn with stickers. Light DOM, like every `<baht-*>` element.
144
+ *
145
+ * Set `graph` as a property: `{ nodes: [{ id, sticker | icon, label, sub, x, y }], links: [{ from, to, dir }],
146
+ * flow: [{ from, to, tone, label }] }`. Nodes sit on grid cells of the floor plane the stickers lean on; links are
147
+ * dashed; `flow` sends one packet at a time along it, then rests and loops. Register the stickers it names first
148
+ * (`import '@20baht/stickers/all'`), or give a node its `icon` object. Colours follow the --baht-* tokens; under
149
+ * reduced motion no packet moves, and the flow waits (no packet moves, no `baht-step` fires) while the element is
150
+ * scrolled out of view. With `interactive` every node is a button (Tab, Enter, Space, click) that fires
151
+ * `baht-node`, and the stage is a group instead of one image.
152
+ *
153
+ * @fires {CustomEvent<{ index: number; step: GraphStep }>} baht-step - A packet set off on step `index` of `flow`.
154
+ * @fires {CustomEvent<{ id: string; node: GraphNode }>} baht-node - A node was clicked or pressed (Enter, Space); only with `interactive`.
155
+ * @attr step-ms - Milliseconds a packet takes along one step (default 900).
156
+ * @attr paused - Holds the packets where they are.
157
+ * @attr hide-grid - Leaves out the floor grid.
158
+ * @attr label - Accessible name of the diagram.
159
+ * @attr interactive - Nodes are focusable buttons that fire `baht-node`.
160
+ */
161
+ export class BahtStickerGraph extends LitElement {
162
+ static { this.properties = {
163
+ graph: { attribute: false },
164
+ stepMs: { type: Number, attribute: 'step-ms' },
165
+ paused: { type: Boolean },
166
+ hideGrid: { type: Boolean, attribute: 'hide-grid' },
167
+ label: { type: String },
168
+ interactive: { type: Boolean },
169
+ }; }
170
+ constructor() {
171
+ super();
172
+ /** Where each node sits, by id; rebuilt with the layout. */
173
+ this.places = new Map();
174
+ this.packet = null;
175
+ this.frame = 0;
176
+ this.clock = 0;
177
+ this.last = 0;
178
+ this.index = -1;
179
+ /** In the viewport, as far as the observer has said. */
180
+ this.inView = true;
181
+ /** Asks for one frame, unless one is on its way. Whatever changes where the packet is, or whether it moves, calls this. */
182
+ this.wake = () => {
183
+ if (this.frame || !this.isConnected || typeof requestAnimationFrame === 'undefined')
184
+ return;
185
+ this.frame = requestAnimationFrame(this.tick);
186
+ };
187
+ /** The packets' own loop, apart from the sticker clock; it runs only while a packet can move. */
188
+ this.tick = (now) => {
189
+ const dt = this.last ? Math.min(now - this.last, 100) : 0;
190
+ this.last = now;
191
+ if (!this.paused)
192
+ this.clock += dt;
193
+ this.movePacket();
194
+ this.frame = this.moving() ? requestAnimationFrame(this.tick) : 0;
195
+ // time spent at rest is not time a packet travelled
196
+ if (!this.frame)
197
+ this.last = 0;
198
+ };
199
+ this.onNodeKey = (e, node) => {
200
+ if (e.key !== 'Enter' && e.key !== ' ')
201
+ return;
202
+ e.preventDefault(); // Space would scroll the page
203
+ this.pick(node);
204
+ };
205
+ this.graph = undefined;
206
+ this.stepMs = 900;
207
+ this.paused = false;
208
+ this.hideGrid = false;
209
+ this.label = undefined;
210
+ this.interactive = false;
211
+ }
212
+ createRenderRoot() {
213
+ return this;
214
+ }
215
+ connectedCallback() {
216
+ super.connectedCallback();
217
+ injectStyle();
218
+ if (typeof matchMedia !== 'undefined') {
219
+ this.motion = matchMedia('(prefers-reduced-motion: reduce)');
220
+ this.motion.addEventListener('change', this.wake);
221
+ }
222
+ if (typeof IntersectionObserver !== 'undefined') {
223
+ this.sight = new IntersectionObserver((entries) => {
224
+ this.inView = entries.at(-1)?.isIntersecting ?? this.inView;
225
+ this.wake();
226
+ });
227
+ this.sight.observe(this);
228
+ }
229
+ this.wake();
230
+ }
231
+ disconnectedCallback() {
232
+ super.disconnectedCallback();
233
+ cancelAnimationFrame(this.frame);
234
+ this.frame = 0;
235
+ this.last = 0;
236
+ this.motion?.removeEventListener('change', this.wake);
237
+ this.motion = undefined;
238
+ this.sight?.disconnect();
239
+ this.sight = undefined;
240
+ this.inView = true;
241
+ }
242
+ willUpdate(changed) {
243
+ if (changed.has('graph')) {
244
+ this.layout = layoutGraph(this.graph ?? { nodes: [] });
245
+ this.places = new Map(this.layout.nodes.map((n) => [n.node.id, n.at]));
246
+ this.clock = 0;
247
+ this.index = -1;
248
+ }
249
+ }
250
+ updated() {
251
+ this.packet = this.querySelector('.bsg-packet');
252
+ // a new graph, pause or step time: one frame puts the packet right, and the loop goes on from there if it should
253
+ this.wake();
254
+ }
255
+ /** The grid cell under a page point (`clientX`, `clientY`), rounded; for builders that place nodes by pointer. */
256
+ gridAt(clientX, clientY) {
257
+ const stage = this.querySelector('.bsg-stage');
258
+ const box = this.layout?.box;
259
+ if (!stage || !box)
260
+ return [0, 0];
261
+ const rect = stage.getBoundingClientRect();
262
+ const sx = box[0] + ((clientX - rect.left) / (rect.width || 1)) * box[2];
263
+ const sy = box[1] + ((clientY - rect.top) / (rect.height || 1)) * box[3];
264
+ const [gx, gy] = toGrid([sx, sy]);
265
+ return [Math.round(gx), Math.round(gy)];
266
+ }
267
+ reduced() {
268
+ return this.motion?.matches ?? false;
269
+ }
270
+ /** Whether packets are travelling: a flow, not paused, motion allowed, and the element in view. */
271
+ moving() {
272
+ const steps = this.graph?.flow?.length ?? 0;
273
+ return steps > 0 && !this.paused && this.inView && !this.reduced();
274
+ }
275
+ /** Puts the packet where the clock says, and announces each step as it sets off. */
276
+ movePacket() {
277
+ const packet = this.packet;
278
+ const flow = this.graph?.flow ?? [];
279
+ if (!packet || !flow.length || this.reduced()) {
280
+ packet?.setAttribute('r', '0');
281
+ return;
282
+ }
283
+ const each = Math.max(this.stepMs, 1) + GAP_MS;
284
+ const t = this.clock % (each * flow.length + REST_MS);
285
+ const index = Math.floor(t / each);
286
+ const step = flow[index];
287
+ const at = this.places;
288
+ const [a, b] = step ? [at.get(step.from), at.get(step.to)] : [undefined, undefined];
289
+ if (index !== this.index)
290
+ this.enter(index, step);
291
+ if (!step || !a || !b) {
292
+ packet.setAttribute('r', '0');
293
+ return;
294
+ }
295
+ const k = Math.min((t - index * each) / Math.max(this.stepMs, 1), 1);
296
+ const ease = k < 0.5 ? 2 * k * k : 1 - (-2 * k + 2) ** 2 / 2;
297
+ const [p, q] = segment(a, b);
298
+ packet.setAttribute('cx', String(r1(p[0] + (q[0] - p[0]) * ease)));
299
+ packet.setAttribute('cy', String(r1(p[1] + (q[1] - p[1]) * ease)));
300
+ packet.setAttribute('r', k >= 1 ? '0' : '13');
301
+ packet.style.fill = TONES[step.tone ?? 'main'];
302
+ }
303
+ enter(index, step) {
304
+ this.index = index;
305
+ for (const el of this.querySelectorAll('.bsg-node')) {
306
+ const id = el.getAttribute('data-id');
307
+ el.toggleAttribute('data-active', !!step && (id === step.from || id === step.to));
308
+ }
309
+ if (step)
310
+ this.dispatchEvent(new CustomEvent('baht-step', { detail: { index, step }, bubbles: true, composed: true }));
311
+ }
312
+ pick(node) {
313
+ this.dispatchEvent(new CustomEvent('baht-node', {
314
+ detail: { id: node.id, node },
315
+ bubbles: true,
316
+ composed: true,
317
+ }));
318
+ }
319
+ /** One node: its sticker, its caption, and its button role when `interactive`. */
320
+ renderNode(node, [left, top], i, w, h) {
321
+ const on = this.interactive;
322
+ return html `<figure
323
+ class="bsg-node"
324
+ data-id=${node.id}
325
+ style=${`left:${pct(left, w)};top:${pct(top, h)};width:${pct(STICKER, w)}`}
326
+ role=${on ? 'button' : nothing}
327
+ tabindex=${on ? '0' : nothing}
328
+ aria-label=${on ? nodeName(node) : nothing}
329
+ @click=${() => {
330
+ if (this.interactive)
331
+ this.pick(node);
332
+ }}
333
+ @keydown=${(e) => {
334
+ if (this.interactive)
335
+ this.onNodeKey(e, node);
336
+ }}
337
+ >
338
+ ${nodeSticker(node, i)} ${nodeCaption(node)}
339
+ </figure>`;
340
+ }
341
+ render() {
342
+ const layout = this.layout ?? layoutGraph({ nodes: [] });
343
+ const [x, y, w, h] = layout.box;
344
+ const links = layout.links.map(({ link, a, b }) => {
345
+ const [p, q] = segment(a, b);
346
+ const dir = link.dir ?? 'none';
347
+ return svg `<path class="bsg-link" d=${`M${String(p[0])} ${String(p[1])}L${String(q[0])} ${String(q[1])}`} />
348
+ ${dir === 'none' ? nothing : svg `<path class="bsg-head" d=${arrow(p, q)} />`}
349
+ ${dir === 'both' ? svg `<path class="bsg-head" d=${arrow(q, p)} />` : nothing}`;
350
+ });
351
+ const names = (this.graph?.nodes ?? []).map((n) => n.label ?? n.id).join(', ');
352
+ return html `<div
353
+ class="bsg-stage"
354
+ role=${this.interactive ? 'group' : 'img'}
355
+ aria-label=${this.label ?? (names === '' ? 'diagram' : names)}
356
+ style=${`aspect-ratio:${String(w)}/${String(h)}`}
357
+ >
358
+ <svg class="bsg-svg" viewBox=${`${String(x)} ${String(y)} ${String(w)} ${String(h)}`} aria-hidden="true">
359
+ ${this.hideGrid ? nothing : svg `<path class="bsg-grid" d=${layout.grid} />`}
360
+ ${links}
361
+ <circle class="bsg-packet" r="0" cx="0" cy="0" />
362
+ </svg>
363
+ ${layout.nodes.map(({ node, at }, i) => this.renderNode(node, [at[0] - x, at[1] - y], i, w, h))}
364
+ </div>`;
365
+ }
366
+ }
367
+ if (typeof customElements !== 'undefined') {
368
+ const existing = customElements.get(TAG);
369
+ if (!existing)
370
+ customElements.define(TAG, BahtStickerGraph);
371
+ else if (existing !== BahtStickerGraph) {
372
+ console.warn(`[bahtui] <${TAG}> is already defined; skipping the copy from @20baht/stickers`);
373
+ }
374
+ }
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const accessPoint: Icon;
@@ -0,0 +1,34 @@
1
+ // Drawn for @20baht/stickers, modelled in 3d (see iso.ts).
2
+ import { erase, float, twinkle } from '../motions.js';
3
+ import { arc } from '../sticker.js';
4
+ import { block, dot, faceOf, solid } from '../iso.js';
5
+ import { glow, LINE } from './shared.js';
6
+ // A ceiling Wi-Fi access point: a flat rounded white puck, a light ring on top, the signal redrawn over it
7
+ const PUCK = block([-120, -120, 0], [240, 0, 0], [0, 240, 0], [0, 0, 34]);
8
+ const top = faceOf(PUCK, 'top');
9
+ const WAVES = [40, 70, 100].map((r, i) => ({
10
+ d: arc(0, 0, r, 220, 320),
11
+ trim: erase(30 + i * 6, 96 + i * 6),
12
+ round: true,
13
+ }));
14
+ export const accessPoint = {
15
+ name: 'access-point',
16
+ frames: 180,
17
+ still: 150,
18
+ line: LINE,
19
+ extrude: [0, 0],
20
+ layers: [
21
+ { id: 'ap', p: [250, 330], m: float, shapes: [] },
22
+ {
23
+ parent: 'ap',
24
+ shapes: [
25
+ ...solid(PUCK, { fill: 'grey', top: 'white' }, 8),
26
+ { d: dot(top, 0.5, 0.5, 0.24), fill: 'tint' },
27
+ { d: dot(top, 0.5, 0.5, 0.15), fill: 'white' },
28
+ { d: dot(top, 0.5, 0.5, 0.05), fill: 'ok' },
29
+ ],
30
+ },
31
+ { parent: 'ap', p: [0, -120], shapes: WAVES },
32
+ glow('ap', [170, -150], 22, [twinkle(48), twinkle(140, true)]),
33
+ ],
34
+ };
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const aiAgent: Icon;
@@ -0,0 +1,50 @@
1
+ import { press, twinkle, wobble } from '../motions.js';
2
+ import { block, dot, faceOf, quad } from '../iso.js';
3
+ import { glow, LINE } from './shared.js';
4
+ import { box, drum, wire } from './volume.js';
5
+ const head = block([-100, -52, 80], [200, 0, 0], [0, 112, 0], [0, 0, 152]);
6
+ const face = faceOf(head, 'front');
7
+ export const aiAgent = {
8
+ name: 'ai-agent',
9
+ frames: 180,
10
+ line: LINE,
11
+ extrude: [0, 0],
12
+ layers: [
13
+ { id: 'bot', p: [245, 365], m: wobble, shapes: [] },
14
+ {
15
+ parent: 'bot',
16
+ shapes: [
17
+ ...box([-56, -30, 0], [112, 80, 50], 'main', 'tint'),
18
+ ...box([-20, -10, 50], [40, 40, 30], 'grey', 'white'),
19
+ ...box([100, -14, 120], [22, 60, 65], 'main', 'tint'),
20
+ ...box([-100, -52, 80], [200, 112, 152], 'grey', 'white', 'white'),
21
+ { d: quad(face, 0.08, 0.16, 0.84, 0.7, 16), fill: 'deep' },
22
+ ...[0.32, 0.68].map((s) => ({
23
+ d: dot(face, s, 0.54, 0.085, 0.13),
24
+ fill: 'white',
25
+ line: false,
26
+ })),
27
+ { d: quad(face, 0.4, 0.27, 0.2, 0.055, 3), fill: 'ok', line: false },
28
+ ...box([-122, -14, 120], [22, 60, 65], 'main', 'tint'),
29
+ wire([
30
+ [0, 15, 232],
31
+ [0, 15, 273],
32
+ ], 8),
33
+ ...drum([0, 8, 280], 14, 14, 14, 'hot', 'main'),
34
+ ],
35
+ },
36
+ {
37
+ parent: 'bot',
38
+ m: { ...press, at: 20, k: 0.5 },
39
+ shapes: [
40
+ ...box([76, -100, 12], [58, 48, 24], 'deep', 'tint'),
41
+ wire([
42
+ [93, -90, 38],
43
+ [101, -78, 38],
44
+ [117, -86, 38],
45
+ ], 4),
46
+ ],
47
+ },
48
+ glow('bot', [-145, -235], 20, [twinkle(40), twinkle(140, true)]),
49
+ ],
50
+ };
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const alarmClock: Icon;