@esportsplus/ui 0.53.0 → 0.55.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 (328) hide show
  1. package/README.md +51 -6
  2. package/build/components/accordion/index.d.ts +714 -23
  3. package/build/components/accordion/index.js +22 -11
  4. package/build/components/accordion/scss/index.scss +1 -1
  5. package/build/components/anchor/scss/index.scss +1 -1
  6. package/build/components/button/scss/index.scss +1 -1
  7. package/build/components/card/scss/index.scss +1 -1
  8. package/build/components/checkbox/constants.d.ts +2 -0
  9. package/build/components/checkbox/constants.js +2 -0
  10. package/build/components/checkbox/index.d.ts +16 -10
  11. package/build/components/checkbox/index.js +53 -39
  12. package/build/components/checkbox/scss/index.scss +1 -1
  13. package/build/components/checkbox/svg/check.svg +1 -0
  14. package/build/components/clipboard/copy.d.ts +11 -0
  15. package/build/components/clipboard/copy.js +54 -0
  16. package/build/components/clipboard/index.d.ts +1435 -1229
  17. package/build/components/clipboard/index.js +3 -2
  18. package/build/components/clipboard/onclick.d.ts +4 -38
  19. package/build/components/clipboard/onclick.js +10 -12
  20. package/build/components/counter/index.d.ts +1 -1
  21. package/build/components/counter/index.js +59 -71
  22. package/build/components/counter/scss/index.scss +1 -1
  23. package/build/components/form/action.d.ts +1 -1
  24. package/build/components/form/action.js +9 -12
  25. package/build/components/form/index.d.ts +5 -5
  26. package/build/components/form/input.d.ts +4 -4
  27. package/build/components/grid/scss/index.scss +1 -1
  28. package/build/components/icon/index.d.ts +2 -19
  29. package/build/components/icon/index.js +6 -6
  30. package/build/components/icon/scss/index.scss +1 -1
  31. package/build/components/index.d.ts +0 -7
  32. package/build/components/index.js +0 -7
  33. package/build/components/input/index.d.ts +1 -1
  34. package/build/components/input/index.js +12 -13
  35. package/build/components/input/scss/index.scss +1 -1
  36. package/build/components/link/scss/index.scss +1 -1
  37. package/build/components/loading/index.js +5 -5
  38. package/build/components/modal/scss/index.scss +1 -1
  39. package/build/components/normalize/scss/index.scss +1 -1
  40. package/build/components/overlay/index.d.ts +2 -19
  41. package/build/components/overlay/index.js +7 -7
  42. package/build/components/page/scss/index.scss +1 -1
  43. package/build/components/radio/index.d.ts +3 -10
  44. package/build/components/radio/index.js +2 -2
  45. package/build/components/range/index.d.ts +1 -1
  46. package/build/components/range/index.js +13 -13
  47. package/build/components/range/scss/index.scss +1 -1
  48. package/build/components/root/scss/index.scss +1 -1
  49. package/build/components/select/constants.d.ts +4 -0
  50. package/build/components/select/constants.js +4 -0
  51. package/build/components/select/index.d.ts +15 -52
  52. package/build/components/select/index.js +65 -94
  53. package/build/components/select/scss/index.scss +1 -1
  54. package/build/components/sidebar/index.d.ts +2 -19
  55. package/build/components/sidebar/index.js +7 -7
  56. package/build/components/sidebar/scss/index.scss +1 -1
  57. package/build/components/switch/index.d.ts +3 -10
  58. package/build/components/switch/index.js +2 -2
  59. package/build/components/tabs/scss/index.scss +2 -0
  60. package/build/components/text/scss/index.scss +1 -1
  61. package/build/components/textarea/index.d.ts +719 -6
  62. package/build/components/textarea/index.js +36 -17
  63. package/build/components/textarea/scss/index.scss +1 -1
  64. package/build/components/toast/index.js +43 -43
  65. package/build/components/toast/scss/index.scss +1 -1
  66. package/build/components/tooltip/constants.d.ts +3 -0
  67. package/build/components/tooltip/constants.js +3 -0
  68. package/build/components/tooltip/index.d.ts +8 -2546
  69. package/build/components/tooltip/index.js +2 -1
  70. package/build/components/tooltip/menu.d.ts +9 -21
  71. package/build/components/tooltip/menu.js +26 -29
  72. package/build/components/tooltip/onclick.d.ts +717 -1229
  73. package/build/components/tooltip/onclick.js +18 -60
  74. package/build/components/tooltip/onhover.d.ts +716 -20
  75. package/build/components/tooltip/onhover.js +14 -19
  76. package/build/components/tooltip/scss/index.scss +1 -1
  77. package/build/components/typewriter/index.d.ts +2 -19
  78. package/build/components/typewriter/index.js +8 -8
  79. package/build/css-utilities/background/scss/index.scss +1 -1
  80. package/build/css-utilities/border/scss/index.scss +1 -1
  81. package/build/css-utilities/color/scss/index.scss +1 -1
  82. package/build/css-utilities/font/geist/scss/Geist-Italic-Variable.woff2 +0 -0
  83. package/build/css-utilities/font/geist/scss/Geist-Variable.woff2 +0 -0
  84. package/build/css-utilities/font/geist/scss/GeistMono-Italic-Variable.woff2 +0 -0
  85. package/build/css-utilities/font/geist/scss/GeistMono-Variable.woff2 +0 -0
  86. package/build/css-utilities/font/geist/scss/index.scss +2 -0
  87. package/build/css-utilities/font/montserrat/index.d.ts +1 -0
  88. package/build/css-utilities/font/montserrat/index.js +1 -0
  89. package/build/css-utilities/font/montserrat/scss/index.scss +2 -0
  90. package/build/css-utilities/index.scss +1 -1
  91. package/build/css-utilities/inline/scss/index.scss +1 -1
  92. package/build/css-utilities/scrollbar/scss/index.scss +1 -1
  93. package/build/css-utilities/tabular/scss/index.scss +2 -0
  94. package/build/css-utilities/text/scss/index.scss +1 -1
  95. package/build/themes/dark/index.d.ts +0 -1
  96. package/build/themes/dark/index.js +0 -1
  97. package/build/themes/dark/input.d.ts +709 -115
  98. package/build/themes/dark/select.d.ts +3 -1409
  99. package/build/themes/dark/select.js +12 -9
  100. package/build/themes/dark/textarea.d.ts +716 -119
  101. package/package.json +12 -12
  102. package/pnpm-workspace.yaml +4 -3
  103. package/scripts/css-variables.test.mjs +50 -0
  104. package/scripts/sort-scss.md +57 -0
  105. package/scripts/sort-scss.mjs +233 -0
  106. package/scripts/sort-scss.test.mjs +217 -0
  107. package/src/components/accordion/index.ts +7 -14
  108. package/src/components/accordion/scss/index.scss +3 -1
  109. package/src/components/anchor/scss/index.scss +2 -2
  110. package/src/components/button/scss/index.scss +23 -57
  111. package/src/components/button/scss/variables.scss +1 -19
  112. package/src/components/card/scss/index.scss +11 -46
  113. package/src/components/card/scss/variables.scss +1 -2
  114. package/src/components/checkbox/constants.ts +4 -0
  115. package/src/components/checkbox/index.ts +20 -35
  116. package/src/components/checkbox/scss/index.scss +86 -28
  117. package/src/components/checkbox/scss/variables.scss +71 -30
  118. package/src/components/checkbox/svg/check.svg +1 -0
  119. package/src/components/clipboard/copy.ts +55 -0
  120. package/src/components/clipboard/index.ts +3 -2
  121. package/src/components/clipboard/onclick.ts +4 -9
  122. package/src/components/counter/index.ts +57 -66
  123. package/src/components/counter/scss/index.scss +4 -5
  124. package/src/components/counter/scss/variables.scss +0 -1
  125. package/src/components/form/action.ts +2 -8
  126. package/src/components/form/input.ts +4 -3
  127. package/src/components/grid/scss/index.scss +1 -1
  128. package/src/components/icon/scss/variables.scss +0 -1
  129. package/src/components/index.ts +1 -8
  130. package/src/components/input/index.ts +8 -6
  131. package/src/components/input/scss/index.scss +8 -7
  132. package/src/components/input/scss/variables.scss +0 -1
  133. package/src/components/link/scss/index.scss +9 -34
  134. package/src/components/link/scss/variables.scss +0 -12
  135. package/src/components/modal/scss/index.scss +4 -4
  136. package/src/components/normalize/scss/index.scss +0 -1
  137. package/src/components/page/scss/index.scss +0 -6
  138. package/src/components/page/scss/variables.scss +0 -2
  139. package/src/components/radio/index.ts +5 -3
  140. package/src/components/range/index.ts +1 -1
  141. package/src/components/range/scss/index.scss +5 -5
  142. package/src/components/root/scss/index.scss +37 -63
  143. package/src/components/root/scss/variables.scss +37 -67
  144. package/src/components/select/constants.ts +8 -0
  145. package/src/components/select/index.ts +49 -70
  146. package/src/components/select/scss/index.scss +10 -7
  147. package/src/components/select/scss/variables.scss +0 -1
  148. package/src/components/sidebar/scss/index.scss +3 -3
  149. package/src/components/switch/index.ts +5 -3
  150. package/src/components/tabs/scss/index.scss +62 -0
  151. package/src/components/tabs/scss/variables.scss +4 -0
  152. package/src/components/text/scss/index.scss +8 -1
  153. package/src/components/text/scss/variables.scss +5 -3
  154. package/src/components/textarea/index.ts +45 -13
  155. package/src/components/textarea/scss/index.scss +24 -13
  156. package/src/components/textarea/scss/variables.scss +0 -1
  157. package/src/components/toast/scss/index.scss +1 -1
  158. package/src/components/tooltip/constants.ts +6 -0
  159. package/src/components/tooltip/index.ts +4 -1
  160. package/src/components/tooltip/menu.ts +18 -29
  161. package/src/components/tooltip/onclick.ts +21 -88
  162. package/src/components/tooltip/onhover.ts +18 -29
  163. package/src/components/tooltip/scss/index.scss +2 -3
  164. package/src/css-utilities/background/scss/variables.scss +2 -2
  165. package/src/css-utilities/border/scss/index.scss +1 -27
  166. package/src/css-utilities/border/scss/variables.scss +3 -34
  167. package/src/css-utilities/color/scss/variables.scss +2 -6
  168. package/src/css-utilities/font/geist/scss/Geist-Italic-Variable.woff2 +0 -0
  169. package/src/css-utilities/font/geist/scss/Geist-Variable.woff2 +0 -0
  170. package/src/css-utilities/font/geist/scss/GeistMono-Italic-Variable.woff2 +0 -0
  171. package/src/css-utilities/font/geist/scss/GeistMono-Variable.woff2 +0 -0
  172. package/src/css-utilities/font/geist/scss/index.scss +55 -0
  173. package/src/css-utilities/font/montserrat/index.ts +1 -0
  174. package/src/{fonts → css-utilities/font}/montserrat/scss/index.scss +15 -0
  175. package/src/css-utilities/index.scss +6 -12
  176. package/src/css-utilities/inline/scss/index.scss +0 -1
  177. package/src/css-utilities/scrollbar/scss/index.scss +42 -0
  178. package/src/css-utilities/tabular/scss/index.scss +3 -0
  179. package/src/css-utilities/text/scss/index.scss +30 -71
  180. package/src/lib/scss/css-variables.scss +29 -5
  181. package/src/themes/dark/index.ts +0 -1
  182. package/src/themes/dark/select.ts +14 -9
  183. package/src/tokens/index.scss +1 -3
  184. package/src/tokens/scss/border-radius.scss +1 -6
  185. package/src/tokens/scss/color.scss +3 -3
  186. package/src/tokens/scss/scale.scss +1 -1
  187. package/src/tokens/scss/size.scss +7 -0
  188. package/src/tokens/scss/transition.scss +4 -0
  189. package/storage/svg/arrow-left.svg +1 -0
  190. package/storage/svg/arrow-right.svg +1 -0
  191. package/storage/svg/book.svg +1 -0
  192. package/storage/svg/cube.svg +1 -0
  193. package/storage/svg/github.svg +1 -0
  194. package/storage/svg/info.svg +1 -0
  195. package/storage/svg/palette.svg +1 -0
  196. package/storage/svg/search.svg +2 -0
  197. package/storage/svg/type.svg +1 -0
  198. package/vite.config.ts +8 -3
  199. package/build/components/back/index.d.ts +0 -21
  200. package/build/components/back/index.js +0 -16
  201. package/build/components/back/scss/index.scss +0 -2
  202. package/build/components/back/svg/arrow.svg +0 -15
  203. package/build/components/bubble/scss/index.scss +0 -2
  204. package/build/components/button/index.d.ts +0 -103
  205. package/build/components/button/index.js +0 -60
  206. package/build/components/ellipsis/index.d.ts +0 -4
  207. package/build/components/ellipsis/index.js +0 -8
  208. package/build/components/ellipsis/scss/index.scss +0 -2
  209. package/build/components/frame/index.d.ts +0 -21
  210. package/build/components/frame/index.js +0 -13
  211. package/build/components/frame/scss/index.scss +0 -2
  212. package/build/components/highlight/index.d.ts +0 -22
  213. package/build/components/highlight/index.js +0 -56
  214. package/build/components/highlight/scss/index.scss +0 -2
  215. package/build/components/loader/index.d.ts +0 -22
  216. package/build/components/loader/index.js +0 -78
  217. package/build/components/loader/scss/index.scss +0 -2
  218. package/build/components/radio/scss/index.scss +0 -2
  219. package/build/components/root/index.d.ts +0 -7
  220. package/build/components/root/index.js +0 -4
  221. package/build/components/root/onclick.d.ts +0 -5
  222. package/build/components/root/onclick.js +0 -12
  223. package/build/components/switch/scss/index.scss +0 -2
  224. package/build/css-utilities/[margin,padding]/scss/index.scss +0 -2
  225. package/build/css-utilities/error/scss/index.scss +0 -2
  226. package/build/css-utilities/flicker/scss/index.scss +0 -2
  227. package/build/css-utilities/focus/scss/index.scss +0 -2
  228. package/build/css-utilities/gap/scss/index.scss +0 -2
  229. package/build/css-utilities/line-height/scss/index.scss +0 -2
  230. package/build/css-utilities/pointer/scss/index.scss +0 -2
  231. package/build/css-utilities/scroll-fade/scss/index.scss +0 -2
  232. package/build/css-utilities/size/scss/index.scss +0 -2
  233. package/build/css-utilities/viewport/scss/index.scss +0 -2
  234. package/build/css-utilities/width/scss/index.scss +0 -2
  235. package/build/fonts/index.d.ts +0 -1
  236. package/build/fonts/index.js +0 -1
  237. package/build/fonts/montserrat/scss/index.scss +0 -2
  238. package/build/themes/dark/back.d.ts +0 -19
  239. package/build/themes/dark/back.js +0 -7
  240. package/build/themes/dark/button/scss/index.scss +0 -2
  241. package/build/themes/dark/link/scss/index.scss +0 -2
  242. package/src/components/back/index.ts +0 -20
  243. package/src/components/back/scss/index.scss +0 -17
  244. package/src/components/back/svg/arrow.svg +0 -15
  245. package/src/components/bubble/scss/index.scss +0 -32
  246. package/src/components/bubble/scss/variables.scss +0 -20
  247. package/src/components/button/index.ts +0 -53
  248. package/src/components/ellipsis/index.ts +0 -11
  249. package/src/components/ellipsis/scss/index.scss +0 -30
  250. package/src/components/ellipsis/scss/variables.scss +0 -5
  251. package/src/components/frame/index.ts +0 -13
  252. package/src/components/frame/scss/index.scss +0 -39
  253. package/src/components/frame/scss/variables.scss +0 -4
  254. package/src/components/highlight/index.ts +0 -66
  255. package/src/components/highlight/scss/index.scss +0 -7
  256. package/src/components/highlight/scss/variables.scss +0 -4
  257. package/src/components/loader/index.ts +0 -80
  258. package/src/components/loader/scss/index.scss +0 -71
  259. package/src/components/loader/scss/variables.scss +0 -6
  260. package/src/components/radio/scss/index.scss +0 -50
  261. package/src/components/radio/scss/variables.scss +0 -67
  262. package/src/components/root/index.ts +0 -6
  263. package/src/components/root/onclick.ts +0 -20
  264. package/src/components/switch/scss/index.scss +0 -48
  265. package/src/components/switch/scss/variables.scss +0 -74
  266. package/src/css-utilities/[margin,padding]/scss/index.scss +0 -43
  267. package/src/css-utilities/[margin,padding]/scss/variables.scss +0 -54
  268. package/src/css-utilities/error/scss/index.scss +0 -24
  269. package/src/css-utilities/error/scss/variables.scss +0 -3
  270. package/src/css-utilities/flicker/scss/index.scss +0 -15
  271. package/src/css-utilities/flicker/scss/variables.scss +0 -5
  272. package/src/css-utilities/focus/scss/index.scss +0 -7
  273. package/src/css-utilities/focus/scss/variables.scss +0 -5
  274. package/src/css-utilities/gap/scss/index.scss +0 -13
  275. package/src/css-utilities/gap/scss/variables.scss +0 -39
  276. package/src/css-utilities/line-height/scss/index.scss +0 -1
  277. package/src/css-utilities/line-height/scss/variables.scss +0 -10
  278. package/src/css-utilities/pointer/scss/index.scss +0 -5
  279. package/src/css-utilities/scroll-fade/scss/index.scss +0 -47
  280. package/src/css-utilities/scroll-fade/scss/variables.scss +0 -3
  281. package/src/css-utilities/size/scss/index.scss +0 -1
  282. package/src/css-utilities/size/scss/variables.scss +0 -12
  283. package/src/css-utilities/text/scss/variables.scss +0 -31
  284. package/src/css-utilities/viewport/scss/index.scss +0 -5
  285. package/src/css-utilities/width/scss/index.scss +0 -5
  286. package/src/css-utilities/width/scss/variables.scss +0 -9
  287. package/src/fonts/index.ts +0 -1
  288. package/src/themes/dark/back.ts +0 -9
  289. package/src/themes/dark/button/scss/index.scss +0 -46
  290. package/src/themes/dark/link/scss/index.scss +0 -26
  291. package/src/tokens/scss/font-weight.scss +0 -6
  292. package/src/tokens/scss/line-height.scss +0 -9
  293. package/src/tokens/scss/transition-duration.scss +0 -1
  294. /package/build/{fonts/montserrat → css-utilities/font/geist}/index.d.ts +0 -0
  295. /package/build/{fonts/montserrat → css-utilities/font/geist}/index.js +0 -0
  296. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff +0 -0
  297. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff2 +0 -0
  298. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
  299. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
  300. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff +0 -0
  301. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff2 +0 -0
  302. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff +0 -0
  303. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff2 +0 -0
  304. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
  305. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
  306. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff +0 -0
  307. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff2 +0 -0
  308. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff +0 -0
  309. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
  310. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
  311. /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
  312. /package/src/{fonts/montserrat → css-utilities/font/geist}/index.ts +0 -0
  313. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff +0 -0
  314. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff2 +0 -0
  315. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
  316. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
  317. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff +0 -0
  318. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff2 +0 -0
  319. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff +0 -0
  320. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff2 +0 -0
  321. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
  322. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
  323. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff +0 -0
  324. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff2 +0 -0
  325. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff +0 -0
  326. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
  327. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
  328. /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
@@ -0,0 +1,55 @@
1
+ import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
2
+ import { reactive } from '@esportsplus/reactivity';
3
+ import write from './write';
4
+
5
+
6
+ type A = Attributes & {
7
+ timeout?: number;
8
+ value: string;
9
+ };
10
+
11
+
12
+ export default component<A, (state: { copied: boolean, failed: boolean }) => Renderable<unknown>>(
13
+ ({ timeout = 3000, value, ...attributes }, content) => {
14
+ let state = reactive({ copied: false, failed: false }),
15
+ timer: ReturnType<typeof setTimeout> | undefined,
16
+ connected = true;
17
+
18
+ return html`
19
+ <button
20
+ type='button'
21
+ ${attributes}
22
+ ${{
23
+ onconnect: () => { connected = true; },
24
+ ondisconnect: () => {
25
+ connected = false;
26
+ clearTimeout(timer);
27
+ state.copied = false;
28
+ },
29
+ onclick: async (event: MouseEvent) => {
30
+ event.preventDefault();
31
+ event.stopPropagation();
32
+
33
+ let copied = await write(value);
34
+
35
+ if (!connected) {
36
+ return;
37
+ }
38
+
39
+ clearTimeout(timer);
40
+ state.copied = copied;
41
+
42
+ if (!copied) {
43
+ state.failed = true;
44
+ return;
45
+ }
46
+
47
+ timer = setTimeout(() => { state.copied = false; }, timeout);
48
+ }
49
+ }}
50
+ >
51
+ ${() => content(state)}
52
+ </button>
53
+ `;
54
+ }
55
+ );
@@ -1,6 +1,7 @@
1
+ import copy from './copy';
1
2
  import onclick from './onclick';
2
3
  import write from './write';
3
4
 
4
5
 
5
- export default { onclick, write };
6
- export { onclick, write };
6
+ export default { copy, onclick, write };
7
+ export { copy, onclick, write };
@@ -1,30 +1,25 @@
1
1
  import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
2
2
  import { reactive } from '@esportsplus/reactivity';
3
- import { omit } from '@esportsplus/utilities';
4
3
  import write from './write';
5
4
 
6
5
 
7
6
  type A = { timeout?: number, value: string } & Attributes;
8
7
 
9
8
 
10
- const OMIT = ['timeout', 'value'];
11
-
12
-
13
9
  export default component<A, (state: { copied: boolean }) => Renderable<unknown>>(
14
- function(attributes, content) {
10
+ function({ timeout = 1000 * 2, value, ...attributes }, content) {
15
11
  let state = reactive({
16
12
  copied: false
17
- }),
18
- timeout = attributes.timeout || 1000 * 2;
13
+ });
19
14
 
20
15
  return html`
21
16
  <div
22
- ${omit(attributes, OMIT)}
17
+ ${attributes}
23
18
  onclick=${(e: MouseEvent) => {
24
19
  e.preventDefault();
25
20
  e.stopPropagation();
26
21
 
27
- void write(attributes.value).then(() => {
22
+ void write(value).then(() => {
28
23
  state.copied = true;
29
24
 
30
25
  setTimeout(() => {
@@ -1,16 +1,12 @@
1
1
  import { html, type Attributes } from '@esportsplus/template';
2
- import { effect, reactive } from '@esportsplus/reactivity';
3
- import { omit } from '@esportsplus/utilities';
2
+ import { effect, onCleanup, reactive, untrack } from '@esportsplus/reactivity';
4
3
  import './scss/index.scss';
5
4
 
6
5
 
7
- const OMIT = ['currency', 'decimals', 'delay', 'max', 'state', 'suffix', 'value'];
8
-
9
-
10
6
  let formatters: Record<string, Intl.NumberFormat> = {};
11
7
 
12
8
 
13
- export default (attributes: Attributes & {
9
+ export default ({ currency, decimals = 2, delay, max, state: api = reactive({ value: -1 }), suffix, value, ...attributes }: Attributes & {
14
10
  currency?: 'IGNORE' | 'EUR' | 'GBP' | 'USD';
15
11
  decimals?: number;
16
12
  delay?: number;
@@ -19,96 +15,91 @@ export default (attributes: Attributes & {
19
15
  suffix?: string;
20
16
  value: number;
21
17
  }) => {
22
- let { currency, decimals, delay, max, suffix, value } = attributes,
23
- api = attributes.state || reactive({ value: -1 }),
24
- formatter = currency === 'IGNORE'
18
+ let formatter = currency === 'IGNORE'
25
19
  ? undefined
26
20
  : formatters[currency || 'USD'] ??= new Intl.NumberFormat('en-US', {
27
21
  style: 'currency',
28
22
  currency: currency || 'USD'
29
23
  }),
30
- rendering = true,
31
- state = reactive({
32
- length: 0,
33
- test: () => 'sds',
34
- render: [] as string[]
35
- }),
36
- render = reactive([] as string[]);
24
+ animation = reactive({ started: false }),
25
+ render = reactive([] as { digit: boolean; value: string }[]),
26
+ stop = effect(() => {
27
+ let target = api.value === -1 ? value : api.value,
28
+ started = animation.started;
37
29
 
38
- decimals ??= 2;
30
+ let padding = (max || target).toFixed(decimals).length - target.toFixed(decimals).length,
31
+ values = target.toString().padStart(target.toString().length + padding, '1') as any;
39
32
 
40
- effect(() => {
41
- if (api.value !== -1) {
42
- value = api.value;
43
- }
44
-
45
- let padding = (max || value).toFixed(decimals).length - value.toFixed(decimals).length,
46
- values = value.toString().padStart( value.toString().length + padding, '1') as any;
33
+ if (formatter) {
34
+ values = formatter.format(values);
35
+ }
36
+ else {
37
+ values = Number(values).toLocaleString([], {
38
+ minimumFractionDigits: 0,
39
+ maximumFractionDigits: decimals
40
+ });
41
+ }
47
42
 
48
- if (formatter) {
49
- values = formatter.format(values);
50
- }
51
- else {
52
- values = Number(values).toLocaleString([], {
53
- minimumFractionDigits: 0,
54
- maximumFractionDigits: decimals
55
- });
56
- }
43
+ values = values.split('');
57
44
 
58
- values = values.split('');
45
+ if (suffix) {
46
+ values.push(' ', ...suffix.split(''));
47
+ }
59
48
 
60
- if (suffix) {
61
- values.push(' ', ...suffix.split(''));
62
- }
49
+ untrack(() => {
50
+ for (let i = 0, n = values.length; i < n; i++) {
51
+ let value = values[i],
52
+ digit = !isNaN(parseInt(value, 10));
63
53
 
64
- state.length = values.length;
54
+ if (digit && (!started || padding > 0)) {
55
+ padding--;
56
+ value = '0';
57
+ }
65
58
 
66
- for (let i = 0, n = values.length; i < n; i++) {
67
- let value = values[i];
59
+ // Preserve the track so CSS can transition between digit positions.
60
+ if (render[i]?.digit === digit) {
61
+ render[i].value = value;
62
+ }
63
+ else {
64
+ let character = reactive({ digit, value });
68
65
 
69
- if (!isNaN(parseInt(value, 10)) && (rendering === true || padding > 0)) {
70
- padding--;
71
- value = '0';
72
- }
66
+ render[i] = character;
67
+ }
68
+ }
73
69
 
74
- render[i] = value;
75
- }
70
+ if (render.length > values.length) {
71
+ render.splice(values.length);
72
+ }
73
+ });
74
+ }),
75
+ timer = setTimeout(() => animation.started = true, delay ?? 1000);
76
76
 
77
- if (rendering === true) {
78
- rendering = false;
79
- setTimeout(() => api.value = value, delay || 1000);
80
- }
77
+ onCleanup(() => {
78
+ clearTimeout(timer);
79
+ stop();
81
80
  });
82
81
 
83
82
  return html`
84
- <div class='counter' ${omit(attributes, OMIT)}>
85
- ${() => {
86
- let n = state.length;
87
-
88
- if (n === 0) {
89
- return '';
90
- }
91
-
92
- return html.reactive(render, function (value) {
93
- if (isNaN(parseInt(value, 10))) {
83
+ <div class='counter' ${attributes}>
84
+ ${html.reactive(render, function (character) {
85
+ if (!character.digit) {
94
86
  return html`
95
87
  <span class='counter-character counter-character--symbol'>
96
- ${value}
88
+ ${() => character.value}
97
89
  </span>
98
90
  `;
99
91
  }
100
92
 
101
93
  return html`
102
- <div class=' counter-character'>
103
- <div class='counter-character-track' style='${`--value: ${value}`}'>
94
+ <div class='counter-character'>
95
+ <div class='counter-character-track' style='${() => `--value: ${character.value}`}'>
104
96
  <span>9</span>
105
97
  ${[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((value) => html`<span>${value}</span>`)}
106
98
  <span>0</span>
107
99
  </div>
108
100
  </div>
109
101
  `;
110
- });
111
- }}
102
+ })}
112
103
  </div>
113
104
  `;
114
- };
105
+ };
@@ -22,7 +22,6 @@
22
22
  font-variant: tabular-nums;
23
23
  font-weight: var(--font-weight);
24
24
  height: 1lh;
25
- line-height: var(--line-height);
26
25
  mask: linear-gradient(transparent, white calc(1lh * var(--mask-size)) calc(100% - (1lh * var(--mask-size))), transparent);
27
26
  overflow: hidden;
28
27
  transform-style: flat;
@@ -32,14 +31,14 @@
32
31
  font-weight: var(--font-weight-300);
33
32
  opacity: var(--opacity);
34
33
  overflow: visible;
35
- height: var(--line-height);
34
+ height: 1lh;
36
35
 
37
36
  .counter-character-track {
38
37
  span {
39
38
  display: flex;
40
39
  flex-direction: column;
41
40
  align-items: end;
42
- padding: calc((var(--line-height) - var(--font-size)) * 0.2) 0;
41
+ padding: calc((1lh - 1em) * 0.2) 0;
43
42
  }
44
43
  }
45
44
  }
@@ -52,7 +51,7 @@
52
51
 
53
52
  &-track {
54
53
  display: grid;
55
- translate: 0 calc((var(--value) + 1) * (var(--line-height) * -1));
54
+ translate: 0 calc((var(--value) + 1) * (1lh * -1));
56
55
  transition: translate var(--transition-duration) var(--timing-function);
57
56
 
58
57
  span {
@@ -61,4 +60,4 @@
61
60
  }
62
61
  }
63
62
  }
64
- }
63
+ }
@@ -2,7 +2,6 @@
2
2
  // TODO: Switch to clamped font size css variables
3
3
  --font-size: clamp(2rem, 4vw + 1rem, 8rem);
4
4
  --font-weight: var(--font-weight-400);
5
- --line-height: calc(var(--font-size) * 1.5);
6
5
  --mask-size: 0.24;
7
6
  --timing-function: var(--timing-bounce-out);
8
7
  --transition-duration: 2s;
@@ -1,15 +1,11 @@
1
1
  import response, { Response } from '@esportsplus/action';
2
2
  import { html, Attributes, Element, Renderable } from '@esportsplus/template';
3
- import { omit } from '@esportsplus/utilities';
4
3
  import input from './input';
5
4
 
6
5
 
7
6
  type Errors = { errors: Response<unknown>['errors'] };
8
7
 
9
8
 
10
- const OMIT = ['action', 'state'];
11
-
12
-
13
9
  function parse(input: ReturnType<FormData['entries']>) {
14
10
  let data: Record<string, any> = {};
15
11
 
@@ -41,18 +37,16 @@ function parse(input: ReturnType<FormData['entries']>) {
41
37
 
42
38
 
43
39
  export default <T extends Record<string, any>>(
44
- attributes: {
40
+ { action, state, ...attributes }: {
45
41
  action: (data: { input: T, response: typeof response }) => (Promise<Errors> | Errors),
46
42
  state?: { processing: boolean }
47
43
  } & Attributes,
48
44
  content: Renderable<any>
49
45
  ) => {
50
- let { action, state } = attributes;
51
-
52
46
  return html`
53
47
  <form
54
48
  class='form'
55
- ${omit(attributes, OMIT)}
49
+ ${attributes}
56
50
  ${{
57
51
  onclick: function(event) {
58
52
  let trigger = event.target as HTMLButtonElement;
@@ -1,18 +1,19 @@
1
1
  import { Element } from '@esportsplus/template';
2
2
 
3
3
 
4
+ // TODO: Needs to be expanded and we need better type for template
4
5
  const KEY = Symbol();
5
6
 
6
7
 
7
- const get = (element?: Element) => {
8
+ const get = <T extends { error: string }>(element?: Element) => {
8
9
  if (element) {
9
- return element[KEY] as { error: string } | undefined;
10
+ return element[KEY] as T | undefined;
10
11
  }
11
12
 
12
13
  return undefined;
13
14
  };
14
15
 
15
- const onrender = (reactive: { error: string }) => {
16
+ const onrender = <T extends { error: string }>(reactive: T) => {
16
17
  return (element: Element) => {
17
18
  element[KEY] = reactive;
18
19
  };
@@ -2,7 +2,7 @@
2
2
 
3
3
  .grid {
4
4
  display: grid;
5
- grid-gap: var(--gap-horizontal) var(--gap-vertical);
5
+ grid-gap: var(--gap-vertical) var(--gap-horizontal);
6
6
  grid-template-columns: repeat(auto-fit, minmax(var(--min-width), var(--max-width)));
7
7
  position: relative;
8
8
 
@@ -1,7 +1,6 @@
1
1
  .icon {
2
2
  --color: inherit;
3
3
  --height: var(--size);
4
- --margin-horizontal: var(--size-300);
5
4
  --size: var(--size-400);
6
5
  --width: var(--size);
7
6
  }
@@ -1,23 +1,16 @@
1
1
  export { default as accordion } from './accordion';
2
- export { default as back } from './back';
3
- export { default as button } from './button';
4
2
  export { default as checkbox } from './checkbox';
5
3
  export { default as clipboard } from './clipboard';
6
4
  export { default as counter } from './counter';
7
- export { default as ellipsis } from './ellipsis';
8
5
  export { default as form } from './form';
9
- export { default as frame } from './frame';
10
- export { default as highlight } from './highlight';
11
6
  export { default as icon } from './icon';
12
7
  export { default as input } from './input';
13
8
  export { default as json } from './json';
14
- export { default as loader } from './loader';
15
9
  export { default as loading } from './loading';
16
10
  export { default as number } from './number';
17
11
  export { default as overlay } from './overlay';
18
12
  export { default as radio } from './radio';
19
13
  export { default as range } from './range';
20
- export { default as root } from './root';
21
14
  export { default as select } from './select';
22
15
  export { default as switch } from './switch';
23
16
  export { default as sidebar } from './sidebar';
@@ -25,4 +18,4 @@ export { default as textarea } from './textarea';
25
18
  export { default as toaster, toast } from './toast';
26
19
  export { default as tooltip } from './tooltip';
27
20
  export { default as truncate } from './truncate';
28
- export { default as typewriter } from './typewriter';
21
+ export { default as typewriter } from './typewriter';
@@ -5,13 +5,16 @@ import './scss/index.scss';
5
5
 
6
6
 
7
7
  export default function (
8
- this: { attributes?: Attributes },
9
- attributes: Attributes & { state?: { active: boolean, error: string } }
10
- ) {
11
- let state = attributes.state || reactive({
8
+ this: { attributes?: Attributes } | void,
9
+ {
10
+ state = reactive({
12
11
  active: false,
13
12
  error: ''
14
- });
13
+ }),
14
+ ...attributes
15
+ }: Attributes & { state?: { active: boolean, error: string } }
16
+ ) {
17
+ attributes.type ??= 'text';
15
18
 
16
19
  return html`
17
20
  <input
@@ -27,7 +30,6 @@ export default function (
27
30
  state.active = false;
28
31
  },
29
32
  onrender: form.input.onrender(state),
30
- type: (attributes.type || 'text') as string
31
33
  }}
32
34
  />
33
35
  `;
@@ -11,21 +11,22 @@
11
11
  flex: 1 1 auto;
12
12
  flex-wrap: wrap;
13
13
  font-size: var(--font-size);
14
- line-height: var(--line-height);
15
14
  // Necessary To Maintain Height Of Hidden Password Fields In Floating Modals
16
15
  // - Password Managers Cause Problems When Fields Are Not Using 'display:hidden' On Password Fields
17
16
  min-height: calc((var(--padding-vertical) * 2) + var(--size));
18
17
  min-width: 0;
19
18
  overflow: hidden;
20
- padding: var(--padding-vertical) var(--padding-horizontal);
19
+ padding:
20
+ max(0px, calc(var(--padding-vertical) - var(--border-width)))
21
+ max(0px, calc(var(--padding-horizontal) - var(--border-width)));
21
22
  position: relative;
22
23
  text-overflow: ellipsis;
23
24
  transition:
24
- background var(--transition-duration) ease-in-out,
25
- border-color var(--transition-duration) ease-in-out,
26
- box-shadow var(--transition-duration) ease-in-out,
27
- opacity var(--transition-duration) ease-in-out,
28
- transform var(--transition-duration) ease-in-out;
25
+ background var(--transition-duration) var(--transition-timing-function),
26
+ border-color var(--transition-duration) var(--transition-timing-function),
27
+ box-shadow var(--transition-duration) var(--transition-timing-function),
28
+ opacity var(--transition-duration) var(--transition-timing-function),
29
+ transform var(--transition-duration) var(--transition-timing-function);
29
30
  white-space: nowrap;
30
31
  width: 100%;
31
32
 
@@ -19,7 +19,6 @@
19
19
  --color-hover: var(--color-default);
20
20
  --color-pressed: var(--color-default);
21
21
  --font-size: var(--font-size-400);
22
- --line-height: var(--line-height-400);
23
22
  --padding-horizontal: var(--size-400);
24
23
  --padding-vertical: var(--size-400);
25
24
  --size: var(--size-400);
@@ -1,47 +1,22 @@
1
1
  @use '/lib';
2
2
  @use '/tokens';
3
3
  @use 'variables';
4
+ @use '../../text/scss/index';
4
5
 
5
6
  .link {
7
+ @extend .text;
6
8
  align-content: center;
7
9
  background: var(--background);
8
- color: var(--color);
9
10
  cursor: pointer;
10
- display: flex;
11
11
  flex-wrap: wrap;
12
- font-size: var(--font-size);
13
12
  justify-content: flex-start;
14
- line-height: var(--line-height);
15
- padding: calc(var(--padding-vertical) - var(--border-width)) calc(var(--padding-horizontal) - var(--border-width));
13
+ padding:
14
+ max(0px, calc(var(--padding-vertical) - var(--border-width)))
15
+ max(0px, calc(var(--padding-horizontal) - var(--border-width)));
16
16
  position: relative;
17
17
  transition:
18
- background var(--transition-duration) ease-in-out,
19
- border-color var(--transition-duration) ease-in-out,
20
- color var(--transition-duration) ease-in-out,
21
- opacity var(--transition-duration) ease-in-out;
22
- width: var(--width);
23
-
24
-
25
- &--underline {
26
- @include tokens.state(active hover) {
27
- text-decoration: underline;
28
- }
29
- }
30
-
31
-
32
- &-hover {
33
- transition: opacity 0.3s ease-in-out, 0.3s cubic-bezier(0.23, 0.65, 0.74, 1.09);
34
-
35
- &--one {
36
- transform: translateY(0);
37
- }
38
-
39
- &--two {
40
- @include lib.position(absolute, center);
41
- opacity: 0;
42
- padding: 0 var(--padding-horizontal);
43
- transform: translate(50%, 125%);
44
- white-space: nowrap;
45
- }
46
- }
18
+ background var(--transition-duration) var(--transition-timing-function),
19
+ border-color var(--transition-duration) var(--transition-timing-function),
20
+ color var(--transition-duration) var(--transition-timing-function),
21
+ opacity var(--transition-duration) var(--transition-timing-function);
47
22
  }
@@ -11,19 +11,7 @@
11
11
  --border-color-default: var(--background);
12
12
  --border-color-hover: var(--border-color-default);
13
13
  --border-color-pressed: var(--border-color-default);
14
- --border-radius: var(--border-radius-400);
15
- --border-width: 0px;
16
- --color: var(--color-default);
17
- --color-active: var(--color-default);
18
- --color-default: var(--color-text-400);
19
- --color-hover: var(--color-default);
20
- --color-pressed: var(--color-default);
21
- --font-size: var(--font-size-400);
22
- --font-weight: var(--font-weight-500);
23
- --line-height: var(--line-height-400);
24
14
  --padding-horizontal: 0px;
25
- --padding-vertical: var(--size-400);
26
- --width: auto;
27
15
 
28
16
 
29
17
  @include tokens.state(active) {
@@ -5,8 +5,8 @@
5
5
  .modal {
6
6
  margin: auto;
7
7
  transition:
8
- opacity var(--transition-duration) ease-in-out,
9
- transform var(--transition-duration) ease-in-out;
8
+ opacity var(--transition-duration) var(--transition-timing-function),
9
+ transform var(--transition-duration) var(--transition-timing-function);
10
10
  transform-origin: center;
11
11
  width: min(var(--max-width), calc(100% - (var(--margin-horizontal) * 2)));
12
12
  z-index: 9;
@@ -23,8 +23,8 @@
23
23
 
24
24
  &-frame {
25
25
  transition:
26
- opacity var(--transition-duration) ease-in-out,
27
- transform var(--transition-duration) ease-in-out;
26
+ opacity var(--transition-duration) var(--transition-timing-function),
27
+ transform var(--transition-duration) var(--transition-timing-function);
28
28
  transform-origin: center;
29
29
 
30
30
  @include tokens.state(inactive) {
@@ -9,7 +9,6 @@ textarea {
9
9
  border: 0;
10
10
  font-family: inherit;
11
11
  font-size: inherit;
12
- line-height: inherit;
13
12
  margin: 0;
14
13
  padding: 0;
15
14
 
@@ -14,7 +14,6 @@
14
14
  &-title {
15
15
  color: var(--color);
16
16
  display: block;
17
- line-height: var(--line-height);
18
17
  position: relative;
19
18
  width: 100%;
20
19
  z-index: 1;
@@ -25,11 +24,6 @@
25
24
  font-size: var(--font-size);
26
25
  }
27
26
 
28
- &-suptitle + &-title,
29
- &-title + &-subtitle {
30
- margin-top: var(--margin-vertical);
31
- }
32
-
33
27
  &-title {
34
28
  text-wrap: balance;
35
29
  }
@@ -7,12 +7,10 @@
7
7
  --color: var(--color-default);
8
8
  --color-default: var(--color-text-400);
9
9
  --font-size: var(--font-size-400);
10
- --line-height: var(--line-height-400);
11
10
  }
12
11
 
13
12
  &-title {
14
13
  --color: var(--color-default);
15
14
  --color-default: var(--color-text-500);
16
- --line-height: var(--line-height-400);
17
15
  }
18
16
  }
@@ -1,5 +1,7 @@
1
- import { factory } from '~/components/checkbox';
2
- import './scss/index.scss';
1
+ import checkbox, { factory } from '~/components/checkbox';
3
2
 
4
3
 
5
- export default factory('radio');
4
+ const radio: typeof checkbox = factory('radio');
5
+
6
+
7
+ export default radio;