godown 3.0.0-canary.0 → 3.0.0-canary.10

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 (431) hide show
  1. package/README.md +37 -8
  2. package/components/alert.d.ts +5 -3
  3. package/components/alert.d.ts.map +1 -1
  4. package/components/alert.js +24 -14
  5. package/components/alert.js.map +1 -1
  6. package/components/avatar.d.ts +5 -1
  7. package/components/avatar.d.ts.map +1 -1
  8. package/components/avatar.js +7 -3
  9. package/components/avatar.js.map +1 -1
  10. package/components/breath.d.ts +2 -1
  11. package/components/breath.d.ts.map +1 -1
  12. package/components/breath.js +5 -4
  13. package/components/breath.js.map +1 -1
  14. package/components/button.d.ts +16 -9
  15. package/components/button.d.ts.map +1 -1
  16. package/components/button.js +22 -20
  17. package/components/button.js.map +1 -1
  18. package/components/card.d.ts +1 -2
  19. package/components/card.d.ts.map +1 -1
  20. package/components/card.js +5 -11
  21. package/components/card.js.map +1 -1
  22. package/components/carousel.d.ts +6 -5
  23. package/components/carousel.d.ts.map +1 -1
  24. package/components/carousel.js +3 -2
  25. package/components/carousel.js.map +1 -1
  26. package/components/details.d.ts +5 -2
  27. package/components/details.d.ts.map +1 -1
  28. package/components/details.js +5 -2
  29. package/components/details.js.map +1 -1
  30. package/components/dialog.d.ts +8 -4
  31. package/components/dialog.d.ts.map +1 -1
  32. package/components/dialog.js +17 -12
  33. package/components/dialog.js.map +1 -1
  34. package/components/divider.d.ts +1 -1
  35. package/components/divider.js +1 -1
  36. package/components/divider.js.map +1 -1
  37. package/components/dragbox.d.ts +7 -7
  38. package/components/dragbox.d.ts.map +1 -1
  39. package/components/dragbox.js +1 -1
  40. package/components/dragbox.js.map +1 -1
  41. package/components/flex.d.ts +2 -1
  42. package/components/flex.d.ts.map +1 -1
  43. package/components/flex.js +8 -0
  44. package/components/flex.js.map +1 -1
  45. package/components/form.d.ts +0 -2
  46. package/components/form.d.ts.map +1 -1
  47. package/components/form.js +0 -2
  48. package/components/form.js.map +1 -1
  49. package/components/grid.d.ts +8 -3
  50. package/components/grid.d.ts.map +1 -1
  51. package/components/grid.js +1 -0
  52. package/components/grid.js.map +1 -1
  53. package/components/input.d.ts +2 -3
  54. package/components/input.d.ts.map +1 -1
  55. package/components/input.js +3 -6
  56. package/components/input.js.map +1 -1
  57. package/components/layout.d.ts +3 -6
  58. package/components/layout.d.ts.map +1 -1
  59. package/components/layout.js +21 -10
  60. package/components/layout.js.map +1 -1
  61. package/components/link.d.ts +3 -1
  62. package/components/link.d.ts.map +1 -1
  63. package/components/link.js +3 -1
  64. package/components/link.js.map +1 -1
  65. package/components/progress.d.ts +2 -11
  66. package/components/progress.d.ts.map +1 -1
  67. package/components/progress.js +6 -15
  68. package/components/progress.js.map +1 -1
  69. package/components/range.d.ts +43 -17
  70. package/components/range.d.ts.map +1 -1
  71. package/components/range.js +132 -58
  72. package/components/range.js.map +1 -1
  73. package/components/rotate.d.ts +1 -1
  74. package/components/rotate.d.ts.map +1 -1
  75. package/components/rotate.js +1 -1
  76. package/components/rotate.js.map +1 -1
  77. package/components/router.d.ts +6 -8
  78. package/components/router.d.ts.map +1 -1
  79. package/components/router.js +10 -10
  80. package/components/router.js.map +1 -1
  81. package/components/select.d.ts +4 -8
  82. package/components/select.d.ts.map +1 -1
  83. package/components/select.js +42 -41
  84. package/components/select.js.map +1 -1
  85. package/components/skeleton.d.ts.map +1 -1
  86. package/components/skeleton.js +3 -4
  87. package/components/skeleton.js.map +1 -1
  88. package/components/split.d.ts +18 -1
  89. package/components/split.d.ts.map +1 -1
  90. package/components/split.js +52 -19
  91. package/components/split.js.map +1 -1
  92. package/components/switch.d.ts +4 -4
  93. package/components/switch.d.ts.map +1 -1
  94. package/components/switch.js +6 -6
  95. package/components/switch.js.map +1 -1
  96. package/components/text.js +3 -3
  97. package/components/text.js.map +1 -1
  98. package/components/time.d.ts +4 -20
  99. package/components/time.d.ts.map +1 -1
  100. package/components/time.js +5 -66
  101. package/components/time.js.map +1 -1
  102. package/components/tooltip.d.ts +11 -1
  103. package/components/tooltip.d.ts.map +1 -1
  104. package/components/tooltip.js +23 -5
  105. package/components/tooltip.js.map +1 -1
  106. package/components/typewriter.d.ts +2 -2
  107. package/components/typewriter.d.ts.map +1 -1
  108. package/components/typewriter.js +2 -2
  109. package/components/typewriter.js.map +1 -1
  110. package/core/global-style.d.ts.map +1 -1
  111. package/core/global-style.js +8 -1
  112. package/core/global-style.js.map +1 -1
  113. package/core/super-anchor.js +1 -1
  114. package/core/super-anchor.js.map +1 -1
  115. package/core/super-input.d.ts +2 -3
  116. package/core/super-input.d.ts.map +1 -1
  117. package/core/super-input.js +3 -6
  118. package/core/super-input.js.map +1 -1
  119. package/core/super-openable.js.map +1 -1
  120. package/custom-elements.json +1 -1
  121. package/dev/alert.d.ts +8 -0
  122. package/dev/alert.d.ts.map +1 -0
  123. package/dev/alert.js +4 -0
  124. package/dev/alert.js.map +1 -0
  125. package/dev/avatar.d.ts +8 -0
  126. package/dev/avatar.d.ts.map +1 -0
  127. package/dev/avatar.js +4 -0
  128. package/dev/avatar.js.map +1 -0
  129. package/dev/breath.d.ts +9 -0
  130. package/dev/breath.d.ts.map +1 -0
  131. package/dev/breath.js +5 -0
  132. package/dev/breath.js.map +1 -0
  133. package/dev/button.d.ts +8 -0
  134. package/dev/button.d.ts.map +1 -0
  135. package/dev/button.js +4 -0
  136. package/dev/button.js.map +1 -0
  137. package/dev/card.d.ts +8 -0
  138. package/dev/card.d.ts.map +1 -0
  139. package/dev/card.js +4 -0
  140. package/dev/card.js.map +1 -0
  141. package/dev/carousel.d.ts +8 -0
  142. package/dev/carousel.d.ts.map +1 -0
  143. package/dev/carousel.js +4 -0
  144. package/dev/carousel.js.map +1 -0
  145. package/dev/components/alert.d.ts +52 -0
  146. package/dev/components/alert.d.ts.map +1 -0
  147. package/dev/components/alert.js +245 -0
  148. package/dev/components/alert.js.map +1 -0
  149. package/dev/components/avatar.d.ts +30 -0
  150. package/dev/components/avatar.d.ts.map +1 -0
  151. package/dev/components/avatar.js +92 -0
  152. package/dev/components/avatar.js.map +1 -0
  153. package/dev/components/breath.d.ts +35 -0
  154. package/dev/components/breath.d.ts.map +1 -0
  155. package/dev/components/breath.js +135 -0
  156. package/dev/components/breath.js.map +1 -0
  157. package/dev/components/button.d.ts +52 -0
  158. package/dev/components/button.d.ts.map +1 -0
  159. package/dev/components/button.js +260 -0
  160. package/dev/components/button.js.map +1 -0
  161. package/dev/components/card.d.ts +19 -0
  162. package/dev/components/card.d.ts.map +1 -0
  163. package/dev/components/card.js +81 -0
  164. package/dev/components/card.js.map +1 -0
  165. package/dev/components/carousel.d.ts +41 -0
  166. package/dev/components/carousel.d.ts.map +1 -0
  167. package/dev/components/carousel.js +157 -0
  168. package/dev/components/carousel.js.map +1 -0
  169. package/dev/components/details.d.ts +23 -0
  170. package/dev/components/details.d.ts.map +1 -0
  171. package/dev/components/details.js +118 -0
  172. package/dev/components/details.js.map +1 -0
  173. package/dev/components/dialog.d.ts +37 -0
  174. package/dev/components/dialog.d.ts.map +1 -0
  175. package/dev/components/dialog.js +159 -0
  176. package/dev/components/dialog.js.map +1 -0
  177. package/dev/components/divider.d.ts +17 -0
  178. package/dev/components/divider.d.ts.map +1 -0
  179. package/dev/components/divider.js +46 -0
  180. package/dev/components/divider.js.map +1 -0
  181. package/dev/components/dragbox.d.ts +40 -0
  182. package/dev/components/dragbox.d.ts.map +1 -0
  183. package/dev/components/dragbox.js +117 -0
  184. package/dev/components/dragbox.js.map +1 -0
  185. package/dev/components/flex.d.ts +32 -0
  186. package/dev/components/flex.d.ts.map +1 -0
  187. package/dev/components/flex.js +60 -0
  188. package/dev/components/flex.js.map +1 -0
  189. package/dev/components/form.d.ts +22 -0
  190. package/dev/components/form.d.ts.map +1 -0
  191. package/dev/components/form.js +77 -0
  192. package/dev/components/form.js.map +1 -0
  193. package/dev/components/grid.d.ts +36 -0
  194. package/dev/components/grid.d.ts.map +1 -0
  195. package/dev/components/grid.js +54 -0
  196. package/dev/components/grid.js.map +1 -0
  197. package/dev/components/input.d.ts +19 -0
  198. package/dev/components/input.d.ts.map +1 -0
  199. package/dev/components/input.js +70 -0
  200. package/dev/components/input.js.map +1 -0
  201. package/dev/components/layout.d.ts +26 -0
  202. package/dev/components/layout.d.ts.map +1 -0
  203. package/dev/components/layout.js +82 -0
  204. package/dev/components/layout.js.map +1 -0
  205. package/dev/components/link.d.ts +22 -0
  206. package/dev/components/link.d.ts.map +1 -0
  207. package/dev/components/link.js +42 -0
  208. package/dev/components/link.js.map +1 -0
  209. package/dev/components/progress.d.ts +21 -0
  210. package/dev/components/progress.d.ts.map +1 -0
  211. package/dev/components/progress.js +99 -0
  212. package/dev/components/progress.js.map +1 -0
  213. package/dev/components/range.d.ts +86 -0
  214. package/dev/components/range.d.ts.map +1 -0
  215. package/dev/components/range.js +364 -0
  216. package/dev/components/range.js.map +1 -0
  217. package/dev/components/rotate.d.ts +26 -0
  218. package/dev/components/rotate.d.ts.map +1 -0
  219. package/dev/components/rotate.js +86 -0
  220. package/dev/components/rotate.js.map +1 -0
  221. package/dev/components/router.d.ts +119 -0
  222. package/dev/components/router.d.ts.map +1 -0
  223. package/dev/components/router.js +248 -0
  224. package/dev/components/router.js.map +1 -0
  225. package/dev/components/select.d.ts +46 -0
  226. package/dev/components/select.d.ts.map +1 -0
  227. package/dev/components/select.js +245 -0
  228. package/dev/components/select.js.map +1 -0
  229. package/dev/components/skeleton.d.ts +26 -0
  230. package/dev/components/skeleton.d.ts.map +1 -0
  231. package/dev/components/skeleton.js +118 -0
  232. package/dev/components/skeleton.js.map +1 -0
  233. package/dev/components/split.d.ts +49 -0
  234. package/dev/components/split.d.ts.map +1 -0
  235. package/dev/components/split.js +206 -0
  236. package/dev/components/split.js.map +1 -0
  237. package/dev/components/switch.d.ts +39 -0
  238. package/dev/components/switch.d.ts.map +1 -0
  239. package/dev/components/switch.js +182 -0
  240. package/dev/components/switch.js.map +1 -0
  241. package/dev/components/text.d.ts +19 -0
  242. package/dev/components/text.d.ts.map +1 -0
  243. package/dev/components/text.js +93 -0
  244. package/dev/components/text.js.map +1 -0
  245. package/dev/components/time.d.ts +37 -0
  246. package/dev/components/time.d.ts.map +1 -0
  247. package/dev/components/time.js +75 -0
  248. package/dev/components/time.js.map +1 -0
  249. package/dev/components/tooltip.d.ts +48 -0
  250. package/dev/components/tooltip.d.ts.map +1 -0
  251. package/dev/components/tooltip.js +137 -0
  252. package/dev/components/tooltip.js.map +1 -0
  253. package/dev/components/typewriter.d.ts +55 -0
  254. package/dev/components/typewriter.d.ts.map +1 -0
  255. package/dev/components/typewriter.js +155 -0
  256. package/dev/components/typewriter.js.map +1 -0
  257. package/dev/core/global-style.d.ts +21 -0
  258. package/dev/core/global-style.d.ts.map +1 -0
  259. package/dev/core/global-style.js +76 -0
  260. package/dev/core/global-style.js.map +1 -0
  261. package/dev/core/super-anchor.d.ts +15 -0
  262. package/dev/core/super-anchor.d.ts.map +1 -0
  263. package/dev/core/super-anchor.js +58 -0
  264. package/dev/core/super-anchor.js.map +1 -0
  265. package/dev/core/super-input.d.ts +38 -0
  266. package/dev/core/super-input.d.ts.map +1 -0
  267. package/dev/core/super-input.js +182 -0
  268. package/dev/core/super-input.js.map +1 -0
  269. package/dev/core/super-openable.d.ts +19 -0
  270. package/dev/core/super-openable.d.ts.map +1 -0
  271. package/dev/core/super-openable.js +36 -0
  272. package/dev/core/super-openable.js.map +1 -0
  273. package/dev/details.d.ts +8 -0
  274. package/dev/details.d.ts.map +1 -0
  275. package/dev/details.js +4 -0
  276. package/dev/details.js.map +1 -0
  277. package/dev/dialog.d.ts +8 -0
  278. package/dev/dialog.d.ts.map +1 -0
  279. package/dev/dialog.js +4 -0
  280. package/dev/dialog.js.map +1 -0
  281. package/dev/divider.d.ts +8 -0
  282. package/dev/divider.d.ts.map +1 -0
  283. package/dev/divider.js +4 -0
  284. package/dev/divider.js.map +1 -0
  285. package/dev/dragbox.d.ts +8 -0
  286. package/dev/dragbox.d.ts.map +1 -0
  287. package/dev/dragbox.js +4 -0
  288. package/dev/dragbox.js.map +1 -0
  289. package/dev/flex.d.ts +8 -0
  290. package/dev/flex.d.ts.map +1 -0
  291. package/dev/flex.js +4 -0
  292. package/dev/flex.js.map +1 -0
  293. package/dev/form.d.ts +8 -0
  294. package/dev/form.d.ts.map +1 -0
  295. package/dev/form.js +4 -0
  296. package/dev/form.js.map +1 -0
  297. package/dev/grid.d.ts +8 -0
  298. package/dev/grid.d.ts.map +1 -0
  299. package/dev/grid.js +4 -0
  300. package/dev/grid.js.map +1 -0
  301. package/dev/index.d.ts +29 -0
  302. package/dev/index.d.ts.map +1 -0
  303. package/dev/index.js +29 -0
  304. package/dev/index.js.map +1 -0
  305. package/dev/input.d.ts +9 -0
  306. package/dev/input.d.ts.map +1 -0
  307. package/dev/input.js +5 -0
  308. package/dev/input.js.map +1 -0
  309. package/dev/layout.d.ts +9 -0
  310. package/dev/layout.d.ts.map +1 -0
  311. package/dev/layout.js +5 -0
  312. package/dev/layout.js.map +1 -0
  313. package/dev/link.d.ts +9 -0
  314. package/dev/link.d.ts.map +1 -0
  315. package/dev/link.js +5 -0
  316. package/dev/link.js.map +1 -0
  317. package/dev/progress.d.ts +9 -0
  318. package/dev/progress.d.ts.map +1 -0
  319. package/dev/progress.js +5 -0
  320. package/dev/progress.js.map +1 -0
  321. package/dev/range.d.ts +9 -0
  322. package/dev/range.d.ts.map +1 -0
  323. package/dev/range.js +5 -0
  324. package/dev/range.js.map +1 -0
  325. package/dev/rotate.d.ts +9 -0
  326. package/dev/rotate.d.ts.map +1 -0
  327. package/dev/rotate.js +5 -0
  328. package/dev/rotate.js.map +1 -0
  329. package/dev/router.d.ts +9 -0
  330. package/dev/router.d.ts.map +1 -0
  331. package/dev/router.js +5 -0
  332. package/dev/router.js.map +1 -0
  333. package/dev/select.d.ts +9 -0
  334. package/dev/select.d.ts.map +1 -0
  335. package/dev/select.js +5 -0
  336. package/dev/select.js.map +1 -0
  337. package/dev/skeleton.d.ts +9 -0
  338. package/dev/skeleton.d.ts.map +1 -0
  339. package/dev/skeleton.js +5 -0
  340. package/dev/skeleton.js.map +1 -0
  341. package/dev/split.d.ts +9 -0
  342. package/dev/split.d.ts.map +1 -0
  343. package/dev/split.js +5 -0
  344. package/dev/split.js.map +1 -0
  345. package/dev/switch.d.ts +9 -0
  346. package/dev/switch.d.ts.map +1 -0
  347. package/dev/switch.js +5 -0
  348. package/dev/switch.js.map +1 -0
  349. package/dev/text.d.ts +9 -0
  350. package/dev/text.d.ts.map +1 -0
  351. package/dev/text.js +5 -0
  352. package/dev/text.js.map +1 -0
  353. package/dev/time.d.ts +9 -0
  354. package/dev/time.d.ts.map +1 -0
  355. package/dev/time.js +5 -0
  356. package/dev/time.js.map +1 -0
  357. package/dev/tooltip.d.ts +9 -0
  358. package/dev/tooltip.d.ts.map +1 -0
  359. package/dev/tooltip.js +5 -0
  360. package/dev/tooltip.js.map +1 -0
  361. package/dev/typewriter.d.ts +8 -0
  362. package/dev/typewriter.d.ts.map +1 -0
  363. package/dev/typewriter.js +4 -0
  364. package/dev/typewriter.js.map +1 -0
  365. package/index.js +13 -13
  366. package/package.json +10 -8
  367. package/range.d.ts +1 -1
  368. package/range.d.ts.map +1 -1
  369. package/src/alert.ts +11 -0
  370. package/src/avatar.ts +11 -0
  371. package/src/breath.ts +13 -0
  372. package/src/button.ts +11 -0
  373. package/src/card.ts +11 -0
  374. package/src/carousel.ts +11 -0
  375. package/src/components/alert.ts +282 -0
  376. package/src/components/avatar.ts +95 -0
  377. package/src/components/breath.ts +153 -0
  378. package/src/components/button.ts +286 -0
  379. package/src/components/card.ts +80 -0
  380. package/src/components/carousel.ts +169 -0
  381. package/src/components/details.ts +116 -0
  382. package/src/components/dialog.ts +165 -0
  383. package/src/components/divider.ts +44 -0
  384. package/src/components/dragbox.ts +127 -0
  385. package/src/components/flex.ts +70 -0
  386. package/src/components/form.ts +82 -0
  387. package/src/components/grid.ts +75 -0
  388. package/src/components/input.ts +72 -0
  389. package/src/components/layout.ts +82 -0
  390. package/src/components/link.ts +38 -0
  391. package/src/components/progress.ts +95 -0
  392. package/src/components/range.ts +404 -0
  393. package/src/components/rotate.ts +92 -0
  394. package/src/components/router.ts +273 -0
  395. package/src/components/select.ts +268 -0
  396. package/src/components/skeleton.ts +118 -0
  397. package/src/components/split.ts +221 -0
  398. package/src/components/switch.ts +180 -0
  399. package/src/components/text.ts +95 -0
  400. package/src/components/time.ts +81 -0
  401. package/src/components/tooltip.ts +138 -0
  402. package/src/components/typewriter.ts +154 -0
  403. package/src/core/global-style.ts +86 -0
  404. package/src/core/super-anchor.ts +52 -0
  405. package/src/core/super-input.ts +230 -0
  406. package/src/core/super-openable.ts +51 -0
  407. package/src/details.ts +11 -0
  408. package/src/dialog.ts +11 -0
  409. package/src/divider.ts +11 -0
  410. package/src/dragbox.ts +11 -0
  411. package/src/flex.ts +11 -0
  412. package/src/form.ts +11 -0
  413. package/src/grid.ts +11 -0
  414. package/src/index.ts +28 -0
  415. package/src/input.ts +13 -0
  416. package/src/layout.ts +12 -0
  417. package/src/link.ts +13 -0
  418. package/src/progress.ts +12 -0
  419. package/src/range.ts +13 -0
  420. package/src/rotate.ts +13 -0
  421. package/src/router.ts +12 -0
  422. package/src/select.ts +13 -0
  423. package/src/skeleton.ts +13 -0
  424. package/src/split.ts +13 -0
  425. package/src/switch.ts +13 -0
  426. package/src/text.ts +13 -0
  427. package/src/time.ts +13 -0
  428. package/src/tooltip.ts +13 -0
  429. package/src/typewriter.ts +11 -0
  430. package/vscode.html-custom-data.json +1 -1
  431. package/web-types.json +1 -1
@@ -0,0 +1,138 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { styles } from "@godown/element/decorators/styles.js";
3
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
+ import { css, html } from "lit";
5
+ import { property } from "lit/decorators.js";
6
+
7
+ import { scopePrefix } from "../core/global-style.js";
8
+ import SuperOpenable, { type Direction8 } from "../core/super-openable.js";
9
+
10
+ const protoName = "tooltip";
11
+ const cssScope = scopePrefix(protoName);
12
+
13
+ /**
14
+ * {@linkcode Tooltip} provide tooltip for slot elements.
15
+ *
16
+ * If it has the tip property, ignore the slot tip.
17
+ *
18
+ * @slot tip - Tip element if no `tip` provided.
19
+ * @slot - Content.
20
+ * @category feedback
21
+ */
22
+ @godown(protoName)
23
+ @styles(
24
+ css`
25
+ :host {
26
+ ${cssScope}--tip-background: inherit;
27
+ display: inline-block;
28
+ width: fit-content;
29
+ }
30
+
31
+ [part=root] {
32
+ display: flex;
33
+ position: relative;
34
+ transition: inherit;
35
+ border-radius: inherit;
36
+ }
37
+
38
+ [part=tip] {
39
+ width: fit-content;
40
+ height: fit-content;
41
+ position: absolute;
42
+ visibility: hidden;
43
+ transition: inherit;
44
+ user-select: none;
45
+ }
46
+
47
+ :host([open]) [part=tip] {
48
+ visibility: visible;
49
+ }
50
+
51
+ .passive {
52
+ background: var(${cssScope}--tip-background);
53
+ }
54
+ `,
55
+ css`
56
+ [direction^=top] {
57
+ bottom: 100%;
58
+ }
59
+ [direction^=bottom] {
60
+ top: 100%;
61
+ }
62
+ [direction$=right] {
63
+ left: 100%;
64
+ }
65
+ [direction$=left] {
66
+ right: 100%;
67
+ }
68
+ `,
69
+ )
70
+ class Tooltip extends SuperOpenable {
71
+ /**
72
+ * Tip text, if there is a value, the slot will be ignored.
73
+ */
74
+ @property()
75
+ tip: string;
76
+
77
+ /**
78
+ * Direction of opening the tip.
79
+ */
80
+ @property()
81
+ direction: Direction8 = "top";
82
+
83
+ /**
84
+ * Content alignment.
85
+ */
86
+ @property()
87
+ align: "center" | "flex-start" | "flex-end" | "start" | "end" = "center";
88
+
89
+ /**
90
+ * If true, allow penetration of the tip.
91
+ */
92
+ @property({ type: Boolean })
93
+ propagation = false;
94
+
95
+ /**
96
+ * How can tips be triggered.
97
+ *
98
+ * If `focus`, element will be focusable, open tip when focused.
99
+ *
100
+ * If `hover`, element will open tip when hovered.
101
+ *
102
+ * @default "hover"
103
+ */
104
+ @property()
105
+ type: "hover" | "focus" = "hover";
106
+
107
+ static aligns = {
108
+ start: "flex-start",
109
+ end: "flex-end",
110
+ center: "center",
111
+ "flex-start": "flex-start",
112
+ "flex-end": "flex-end",
113
+ };
114
+
115
+ protected render() {
116
+ const align = Tooltip.aligns[this.align] || "inherit";
117
+ const isFocusable = this.type === "focus";
118
+ return html`<div part="root"
119
+ tabindex="${isFocusable ? 0 : -1}"
120
+ @focus="${isFocusable ? () => this.open = true : null}"
121
+ @blur="${isFocusable ? () => this.open = false : null}"
122
+ @mouseenter="${isFocusable ? null : () => this.open = true}"
123
+ @mouseleave="${isFocusable ? null : () => this.open = false}"
124
+ style="justify-content:${align};align-items:${align}">
125
+ ${htmlSlot()}
126
+ <div part="tip"
127
+ direction="${this.direction}"
128
+ style="pointer-events:${this.propagation ? "none" : "all"}">
129
+ ${
130
+ this.tip
131
+ ? html`<span class="passive">${this.tip}</span>`
132
+ : htmlSlot("tip")
133
+ }</div>
134
+ </div>`;
135
+ }
136
+ }
137
+
138
+ export default Tooltip;
@@ -0,0 +1,154 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { styles } from "@godown/element/decorators/styles.js";
3
+ import { classList } from "@godown/element/directives/class-list.js";
4
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
+ import { random } from "@godown/element/tools/lib.js";
6
+ import { css, html, type PropertyValueMap } from "lit";
7
+ import { property, query, state } from "lit/decorators.js";
8
+
9
+ import { GlobalStyle, scopePrefix } from "../core/global-style.js";
10
+
11
+ const protoName = "typewriter";
12
+ const cssScope = scopePrefix(protoName);
13
+
14
+ /**
15
+ * {@linkcode Typewriter} renders a typewriter effect to text.
16
+ *
17
+ * @category effect
18
+ */
19
+ @godown(protoName)
20
+ @styles(css`
21
+ :host {
22
+ ${cssScope}--cursor-width: .05em;
23
+ white-space: nowrap;
24
+ }
25
+
26
+ i {
27
+ border-right: var(${cssScope}--cursor-width) solid;
28
+ margin-left: 0.02em;
29
+ animation: s 1.5s steps(1) infinite;
30
+ }
31
+
32
+ @keyframes s {
33
+ 0% {
34
+ border-color: currentColor;
35
+ }
36
+ 50% {
37
+ border-color: transparent;
38
+ }
39
+ }
40
+
41
+ slot {
42
+ display: none;
43
+ }
44
+
45
+ .hidden {
46
+ visibility: hidden;
47
+ }
48
+ `)
49
+ class Typewriter extends GlobalStyle {
50
+ /**
51
+ * Raw text.
52
+ */
53
+ @property()
54
+ text = "";
55
+
56
+ /**
57
+ * Start immediately after {@linkcode Typewriter.firstUpdated}.
58
+ */
59
+ @property({ type: Boolean })
60
+ stopped = false;
61
+
62
+ /**
63
+ * If true, hide the cursor
64
+ */
65
+ @property({ type: Boolean })
66
+ ended = false;
67
+
68
+ /**
69
+ * Maximum random time.
70
+ */
71
+ @property({ type: Number })
72
+ max = 100;
73
+
74
+ /**
75
+ * Minimum random time.
76
+ */
77
+ @property({ type: Number })
78
+ min = 50;
79
+
80
+ /**
81
+ * Fixed time.
82
+ */
83
+ @property({ type: Number })
84
+ delay = 0;
85
+
86
+ /**
87
+ * The index at the beginning.
88
+ */
89
+ @property({ type: Number })
90
+ index = 0;
91
+
92
+ /**
93
+ * Internal text.
94
+ */
95
+ @state()
96
+ content = "";
97
+
98
+ protected timeoutID: number;
99
+
100
+ @query("i")
101
+ protected _i: HTMLElement;
102
+
103
+ /**
104
+ * {@linkcode Typewriter.text} length.
105
+ */
106
+ get len() {
107
+ return this.text.length;
108
+ }
109
+
110
+ protected render() {
111
+ return html`${htmlSlot()}${this.content}<i part="cursor" class="${
112
+ classList({
113
+ hidden: this.ended,
114
+ })
115
+ }"></i>`;
116
+ }
117
+
118
+ protected firstUpdated() {
119
+ if (!this.text) {
120
+ this.text = this._slot?.assignedNodes()[0]?.textContent.trim() || "";
121
+ }
122
+ if (!this.stopped && this.len) {
123
+ this.write();
124
+ }
125
+ }
126
+
127
+ protected updated(changedProperties: PropertyValueMap<this>) {
128
+ if (changedProperties.has("index")) {
129
+ this.dispatchEvent(new CustomEvent(this.index === this.len ? "done" : "write", { detail: this.content }));
130
+ }
131
+ }
132
+
133
+ write(at = this.index) {
134
+ this.content = this.text.slice(0, at + 1);
135
+ const timeout = this.delay || random(this.max, this.min);
136
+ this.timeoutID = window.setTimeout(() => {
137
+ const nx = at + 1;
138
+ if (nx <= this.len) {
139
+ this.index = nx;
140
+ this.write();
141
+ }
142
+ }, timeout);
143
+ }
144
+
145
+ stop() {
146
+ clearTimeout(this.timeoutID);
147
+ }
148
+
149
+ end() {
150
+ this.ended = true;
151
+ }
152
+ }
153
+
154
+ export default Typewriter;
@@ -0,0 +1,86 @@
1
+ import { type Gradients, presetsRGB } from "@godown/colors/presets-rgb.js";
2
+ import { travel } from "@godown/colors/travel.js";
3
+ import GodownElement from "@godown/element";
4
+ import GodownConfig from "@godown/element/config.js";
5
+ import { joinProperties } from "@godown/element/tools/css.js";
6
+ import { trim } from "@godown/element/tools/lib.js";
7
+ import { css, CSSResult, unsafeCSS } from "lit";
8
+
9
+ GodownElement.godownConfig ||= new GodownConfig();
10
+
11
+ export class GlobalStyle extends GodownElement {
12
+ }
13
+
14
+ const cssvar = trim(GlobalStyle.godownConfig.prefix, "-");
15
+
16
+ export function scopePrefix(scope: string, len = 1) {
17
+ return variablePrefix(cssvar + "-".repeat(len) + scope);
18
+ }
19
+
20
+ export function variablePrefix(variable: string) {
21
+ return unsafeCSS("--" + variable);
22
+ }
23
+
24
+ export const cssGlobalVars = {
25
+ foreground: scopePrefix("foreground", 2),
26
+ background: scopePrefix("background", 2),
27
+ clipBackground: scopePrefix("clip-background", 2),
28
+ active: scopePrefix("active", 2),
29
+ passive: scopePrefix("passive", 2),
30
+ _colors: {} as PresetsGradientsCSSResult,
31
+ input: scopePrefix("input", 2),
32
+ white: scopePrefix("color-white", 2),
33
+ black: scopePrefix("color-black", 2),
34
+ };
35
+
36
+ type PresetsGradientsCSSResult = Record<keyof typeof presetsRGB, Gradients<CSSResult>>;
37
+ GlobalStyle.styles = [
38
+ unsafeCSS(
39
+ ":host{"
40
+ + `${cssGlobalVars.black}:rgb(0 0 0);`
41
+ + `${cssGlobalVars.white}:rgb(255 255 255);`
42
+ + travel((key, gradient, rgb) => {
43
+ cssGlobalVars._colors[key] ||= [] as any;
44
+ cssGlobalVars._colors[key].push(unsafeCSS(scopePrefix("color", 2) + "-" + key + "-" + gradient));
45
+ const endKey = `-${key}-${gradient}`;
46
+ const colorKey = scopePrefix("color", 2) + endKey;
47
+ return `${colorKey}:rgb(${rgb});`;
48
+ }, presetsRGB).join("")
49
+ + joinProperties({
50
+ [cssGlobalVars.background + ""]: `var(${cssGlobalVars._colors.darkgray[9]})`,
51
+ [cssGlobalVars.foreground + ""]: `var(${cssGlobalVars._colors.lightgray[0]})`,
52
+ [cssGlobalVars.active + ""]: `var(${cssGlobalVars._colors.blue[6]})`,
53
+ [cssGlobalVars.passive + ""]: `var(${cssGlobalVars._colors.darkgray[6]})`,
54
+ [cssGlobalVars.clipBackground + ""]:
55
+ `linear-gradient(to bottom, var(${cssGlobalVars.foreground}), var(${cssGlobalVars.passive}))`,
56
+ })
57
+ + "}",
58
+ ),
59
+ css`
60
+ * {
61
+ border: 0;
62
+ outline: 0;
63
+ margin: 0;
64
+ padding: 0;
65
+ font-size: 100%;
66
+ font-style: normal;
67
+ box-sizing: border-box;
68
+ }
69
+
70
+ :host {
71
+ box-sizing: border-box;
72
+ }
73
+
74
+ a {
75
+ text-decoration: none;
76
+ }
77
+
78
+ span {
79
+ white-space: nowrap;
80
+ }
81
+
82
+ svg {
83
+ user-select: none;
84
+ }
85
+ `,
86
+ ];
@@ -0,0 +1,52 @@
1
+ import { styles } from "@godown/element/decorators/index.js";
2
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
3
+ import { css, html } from "lit";
4
+ import { property } from "lit/decorators.js";
5
+ import { ifDefined } from "lit/directives/if-defined.js";
6
+
7
+ import { GlobalStyle } from "./global-style.js";
8
+
9
+ @styles(css`
10
+ :host {
11
+ display: inline-block;
12
+ color: currentColor;
13
+ text-decoration: none;
14
+ cursor: default;
15
+ }
16
+
17
+ :host([href]) {
18
+ cursor: pointer;
19
+ }
20
+
21
+ a {
22
+ width: 100%;
23
+ display: flex;
24
+ color: inherit;
25
+ text-decoration: inherit;
26
+ justify-content: space-between;
27
+ align-items: center;
28
+ }
29
+ `)
30
+ class SuperAnchor extends GlobalStyle {
31
+ /**
32
+ * A element href.
33
+ */
34
+ @property()
35
+ href: string = undefined;
36
+ /**
37
+ * A element target.
38
+ */
39
+ @property()
40
+ target: "_blank" | "_self" | "_parent" | "_top" = "_self";
41
+
42
+ protected render() {
43
+ return html`<a part="root" href="${ifDefined(this.href)}" target="${this.target}" @click=${this._handleClick}>
44
+ ${htmlSlot()}
45
+ </a>`;
46
+ }
47
+
48
+ // eslint-disable-next-line
49
+ protected _handleClick(_: MouseEvent) {}
50
+ }
51
+
52
+ export default SuperAnchor;
@@ -0,0 +1,230 @@
1
+ import { part } from "@godown/element/decorators/part.js";
2
+ import { styles } from "@godown/element/decorators/styles.js";
3
+ import { htmlSlot } from "@godown/element/directives/index.js";
4
+ import { type HandlerEvent } from "@godown/element/element.js";
5
+ import iconEyeSlashFill from "@godown/f7-icon/icons/eye-slash-fill.js";
6
+ import { css, html } from "lit";
7
+ import { property } from "lit/decorators.js";
8
+
9
+ import { cssGlobalVars, GlobalStyle } from "./global-style.js";
10
+
11
+ const fieldStyle = css`
12
+ .input-field {
13
+ display: flex;
14
+ position: relative;
15
+ align-items: center;
16
+ border-radius: inherit;
17
+ height: inherit;
18
+ }
19
+
20
+ .input-field [part=input] {
21
+ background: transparent;
22
+ height: 100%;
23
+ width: 100%;
24
+ color: inherit;
25
+ }
26
+
27
+ .input-field:focus-within,
28
+ .input-field.outline {
29
+ box-shadow: var(${cssGlobalVars.input}-box-shadow);
30
+ }
31
+
32
+ .input-field [part=icon] {
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ }
37
+
38
+ .input-field [part=prefix],
39
+ .input-field [part=suffix] {
40
+ height: 100%;
41
+ display: flex;
42
+ }
43
+
44
+ .input-field [part=space]{
45
+ width: var(${cssGlobalVars.input}-space);
46
+ }
47
+ `;
48
+
49
+ const inputStyle = css`
50
+ :host {
51
+ ${cssGlobalVars.input}-width: 10em;
52
+ ${cssGlobalVars.input}-height: 1.6em;
53
+ ${cssGlobalVars.input}-space: 0.2em;
54
+ ${cssGlobalVars.input}-background: var(${cssGlobalVars.background});
55
+ ${cssGlobalVars.input}-control: var(${cssGlobalVars.foreground});
56
+ ${cssGlobalVars.input}-control-edge: var(${cssGlobalVars.active});
57
+ ${cssGlobalVars.input}-radius: 0.2em;
58
+ ${cssGlobalVars.input}-box-shadow: 0px 0px 0px .1em var(${cssGlobalVars.active});
59
+ border-radius: var(${cssGlobalVars.input}-radius);
60
+ }
61
+
62
+ :host([disabled]) {
63
+ cursor: not-allowed;
64
+ filter: brightness(0.85);
65
+ }
66
+
67
+ input:disabled {
68
+ cursor: inherit;
69
+ }
70
+
71
+ input::-ms-reveal,
72
+ input::-ms-clear {
73
+ display: none;
74
+ }
75
+ `;
76
+
77
+ @styles(fieldStyle, inputStyle)
78
+ class SuperInput extends GlobalStyle {
79
+ autofocus: boolean;
80
+ @property()
81
+ autocomplete: string | boolean;
82
+
83
+ @property({ type: Boolean, reflect: true })
84
+ disabled: boolean;
85
+
86
+ @property({ reflect: true })
87
+ type: InputType;
88
+
89
+ @property({ reflect: true })
90
+ placeholder: string;
91
+
92
+ @property({ reflect: true })
93
+ name: string;
94
+
95
+ @property()
96
+ value: any;
97
+
98
+ /**
99
+ * default property records the default or initial value and is used to reset the input.
100
+ */
101
+ @property()
102
+ default: any;
103
+
104
+ @part("input")
105
+ protected _input: HTMLInputElement;
106
+
107
+ /**
108
+ * Returns true when the input is compositing.
109
+ */
110
+ compositing: boolean;
111
+
112
+ set defaultValue(value: typeof this.default) {
113
+ this.default = value;
114
+ }
115
+
116
+ get defaultValue() {
117
+ return this.default;
118
+ }
119
+
120
+ protected makeId = Math.random().toString(36).slice(1);
121
+
122
+ namevalue(): [string, any] {
123
+ return [this.name, this.value];
124
+ }
125
+
126
+ nameValue = this.namevalue;
127
+
128
+ reset() {
129
+ this.value = this.default;
130
+ this._input.value = this.default;
131
+ }
132
+
133
+ protected _handleInput(e: HandlerEvent<HTMLInputElement>) {
134
+ e.stopPropagation();
135
+ if (this.compositing) {
136
+ return;
137
+ }
138
+ this.value = e.target.value?.trim();
139
+ this.dispatchEvent(
140
+ new CustomEvent("input", {
141
+ detail: this.value,
142
+ bubbles: true,
143
+ composed: true,
144
+ }),
145
+ );
146
+ this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
147
+ }
148
+
149
+ connectedCallback() {
150
+ super.connectedCallback();
151
+ this._connectedInit();
152
+ }
153
+
154
+ protected _connectedInit() {
155
+ this.default ??= this.value || "";
156
+ this.value ??= this.default;
157
+ }
158
+
159
+ protected _compositionInit() {
160
+ if (this._input) {
161
+ this.events.add(this._input, "compositionstart", () => this.compositing = true);
162
+ this.events.add(this._input, "compositionend", (e: HandlerEvent<HTMLInputElement>) => {
163
+ this.compositing = false;
164
+ this._handleInput(e);
165
+ });
166
+ }
167
+ }
168
+
169
+ protected _changeInputType(t: typeof this.type) {
170
+ if (this._input) {
171
+ this._input.type = t;
172
+ }
173
+ }
174
+
175
+ focus(options?: FocusOptions) {
176
+ this._input?.focus(options);
177
+ }
178
+
179
+ protected firstUpdated() {
180
+ this._compositionInit();
181
+ }
182
+
183
+ protected _renderPrefix() {
184
+ return html`<label for=${this.makeId} part="prefix">
185
+ <i part="space"></i>
186
+ ${htmlSlot("prefix")}</label>`;
187
+ }
188
+
189
+ protected _renderSuffix() {
190
+ const PASSWORD = "password";
191
+ return html`<label for=${this.makeId} part="suffix">${
192
+ this.type === "password"
193
+ ? html`
194
+ <i part="space"></i>
195
+ <i
196
+ part="icon"
197
+ @mousedown="${() => this._changeInputType("text")}"
198
+ @mouseup="${() => this._changeInputType(PASSWORD)}"
199
+ @mouseleave="${() => this._changeInputType(PASSWORD)}"
200
+ >${iconEyeSlashFill()}</i>`
201
+ : htmlSlot("suffix")
202
+ }
203
+ <i part="space"></i>
204
+ </label>`;
205
+ }
206
+ }
207
+
208
+ export default SuperInput;
209
+
210
+ type InputType =
211
+ | "hidden"
212
+ | "text"
213
+ | "search"
214
+ | "tel"
215
+ | "url"
216
+ | "email"
217
+ | "password"
218
+ | "datetime"
219
+ | "date"
220
+ | "month"
221
+ | "week"
222
+ | "time"
223
+ | "datetime-local"
224
+ | "number"
225
+ | "range"
226
+ | "color"
227
+ | "checkbox"
228
+ | "radio"
229
+ | "file"
230
+ | "image";
@@ -0,0 +1,51 @@
1
+ import { type PropertyValueMap } from "lit";
2
+ import { property } from "lit/decorators.js";
3
+
4
+ import { GlobalStyle } from "./global-style.js";
5
+
6
+ class SuperOpenable extends GlobalStyle {
7
+ /**
8
+ * Open the content.
9
+ */
10
+ @property({ type: Boolean, reflect: true })
11
+ open = false;
12
+
13
+ toggle(to = !this.open) {
14
+ this.open = to;
15
+ }
16
+
17
+ close() {
18
+ this.open = false;
19
+ }
20
+
21
+ show() {
22
+ this.open = true;
23
+ }
24
+
25
+ protected updated(changedProperties: PropertyValueMap<this>) {
26
+ const open = changedProperties.get("open");
27
+ if (open !== undefined) {
28
+ this.dispatchEvent(new CustomEvent("change", { detail: this.open }));
29
+ }
30
+ }
31
+
32
+ // eslint-disable-next-line
33
+ protected _handelClick(_: MouseEvent) {
34
+ this.toggle();
35
+ }
36
+ }
37
+
38
+ export default SuperOpenable;
39
+
40
+ export type Direction4 = "left" | "right" | "top" | "bottom";
41
+
42
+ export type Direction5 = Direction4 | "center";
43
+
44
+ export type Direction8 =
45
+ | Direction4
46
+ | "top-left"
47
+ | "top-right"
48
+ | "bottom-left"
49
+ | "bottom-right";
50
+
51
+ export type Direction9 = Direction8 | Direction5;