@davidsouther/jiffies 1.0.0-beta.1 → 2.0.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 (447) hide show
  1. package/{build → lib/cjs}/assert.d.ts +0 -0
  2. package/lib/cjs/assert.js +40 -0
  3. package/{build → lib/cjs}/case.d.ts +0 -0
  4. package/lib/cjs/case.js +9 -0
  5. package/{build → lib/cjs}/components/button_bar.d.ts +1 -1
  6. package/lib/cjs/components/button_bar.js +29 -0
  7. package/{build → lib/cjs}/components/inline_edit.d.ts +1 -1
  8. package/lib/cjs/components/inline_edit.js +51 -0
  9. package/{build → lib/cjs}/components/logger.d.ts +2 -3
  10. package/lib/cjs/components/logger.js +27 -0
  11. package/lib/cjs/components/select.d.ts +10 -0
  12. package/lib/cjs/components/select.js +6 -0
  13. package/lib/cjs/components/test.d.ts +1 -0
  14. package/lib/cjs/components/test.js +7 -0
  15. package/{build → lib/cjs}/components/virtual_scroll.d.ts +3 -4
  16. package/lib/cjs/components/virtual_scroll.js +102 -0
  17. package/{build → lib/cjs}/components/virtual_scroll.test.d.ts +0 -0
  18. package/lib/cjs/components/virtual_scroll.test.js +22 -0
  19. package/{build → lib/cjs}/context.d.ts +0 -0
  20. package/lib/cjs/context.js +48 -0
  21. package/{build → lib/cjs}/context.test.d.ts +0 -0
  22. package/lib/cjs/context.test.js +48 -0
  23. package/{build → lib/cjs}/debounce.d.ts +0 -0
  24. package/lib/cjs/debounce.js +11 -0
  25. package/lib/cjs/diff.d.ts +15 -0
  26. package/lib/cjs/diff.js +58 -0
  27. package/{build/components/index.d.ts → lib/cjs/diff.test.d.ts} +0 -0
  28. package/lib/cjs/diff.test.js +41 -0
  29. package/{build → lib/cjs}/display.d.ts +0 -0
  30. package/lib/cjs/display.js +16 -0
  31. package/{build → lib/cjs}/dom/css/border.d.ts +0 -0
  32. package/lib/cjs/dom/css/border.js +33 -0
  33. package/{build → lib/cjs}/dom/css/constants.d.ts +0 -0
  34. package/lib/cjs/dom/css/constants.js +31 -0
  35. package/{build → lib/cjs}/dom/css/core.d.ts +0 -0
  36. package/lib/cjs/dom/css/core.js +31 -0
  37. package/{build → lib/cjs}/dom/css/fstyle.d.ts +0 -0
  38. package/lib/cjs/dom/css/fstyle.js +36 -0
  39. package/{build → lib/cjs}/dom/css/sizing.d.ts +0 -0
  40. package/lib/cjs/dom/css/sizing.js +14 -0
  41. package/lib/cjs/dom/dom.d.ts +27 -0
  42. package/lib/cjs/dom/dom.js +110 -0
  43. package/{build → lib/cjs}/dom/fc.d.ts +5 -5
  44. package/lib/cjs/dom/fc.js +39 -0
  45. package/{build → lib/cjs}/dom/fc.test.d.ts +0 -0
  46. package/lib/cjs/dom/fc.test.js +23 -0
  47. package/lib/cjs/dom/form/form.app.d.ts +1 -0
  48. package/lib/cjs/dom/form/form.app.js +27 -0
  49. package/lib/cjs/dom/form/form.d.ts +26 -0
  50. package/lib/cjs/dom/form/form.js +49 -0
  51. package/{build → lib/cjs}/dom/form/form.test.d.ts +0 -0
  52. package/{build → lib/cjs}/dom/form/form.test.js +0 -0
  53. package/lib/cjs/dom/html.d.ts +113 -0
  54. package/lib/cjs/dom/html.js +119 -0
  55. package/{build → lib/cjs}/dom/html.test.d.ts +0 -0
  56. package/lib/cjs/dom/html.test.js +60 -0
  57. package/lib/cjs/dom/observable.d.ts +2 -0
  58. package/lib/cjs/dom/observable.js +10 -0
  59. package/{build/components/index.js → lib/cjs/dom/observable.test.d.ts} +0 -0
  60. package/lib/cjs/dom/observable.test.js +35 -0
  61. package/lib/cjs/dom/provide.d.ts +3 -0
  62. package/lib/cjs/dom/provide.js +12 -0
  63. package/lib/cjs/dom/router/link.d.ts +6 -0
  64. package/lib/cjs/dom/router/link.js +7 -0
  65. package/{build → lib/cjs}/dom/router/router.d.ts +3 -3
  66. package/lib/cjs/dom/router/router.js +52 -0
  67. package/lib/cjs/dom/svg.d.ts +64 -0
  68. package/lib/cjs/dom/svg.js +69 -0
  69. package/lib/cjs/dom/test.d.ts +1 -0
  70. package/lib/cjs/dom/test.js +13 -0
  71. package/{build → lib/cjs}/dom/types/css.d.ts +0 -0
  72. package/lib/cjs/dom/types/css.js +24 -0
  73. package/{build → lib/cjs}/dom/types/dom.d.ts +0 -0
  74. package/{build → lib/cjs}/dom/types/dom.js +0 -0
  75. package/{build → lib/cjs}/dom/types/html.d.ts +1 -1
  76. package/lib/cjs/dom/types/html.js +2 -0
  77. package/{build → lib/cjs}/dom/xml.d.ts +0 -0
  78. package/lib/cjs/dom/xml.js +8 -0
  79. package/lib/cjs/equal.d.ts +5 -0
  80. package/lib/cjs/equal.js +43 -0
  81. package/{build → lib/cjs}/equal.test.d.ts +0 -0
  82. package/lib/cjs/equal.test.js +22 -0
  83. package/{build → lib/cjs}/flags.d.ts +0 -0
  84. package/lib/cjs/flags.js +52 -0
  85. package/{build → lib/cjs}/flags.test.d.ts +0 -0
  86. package/lib/cjs/flags.test.js +37 -0
  87. package/lib/cjs/fs.d.ts +48 -0
  88. package/lib/cjs/fs.js +151 -0
  89. package/{build/components/test.d.ts → lib/cjs/fs.test.d.ts} +0 -0
  90. package/lib/cjs/fs.test.js +45 -0
  91. package/{build → lib/cjs}/generator.d.ts +0 -0
  92. package/lib/cjs/generator.js +14 -0
  93. package/{build → lib/cjs}/generator.test.d.ts +0 -0
  94. package/lib/cjs/generator.test.js +26 -0
  95. package/{build → lib/cjs}/is_browser.d.ts +0 -0
  96. package/lib/cjs/is_browser.js +4 -0
  97. package/{build → lib/cjs}/loader.d.mts +0 -0
  98. package/lib/cjs/loader.mjs +40 -0
  99. package/{build → lib/cjs}/lock.d.ts +0 -0
  100. package/lib/cjs/lock.js +27 -0
  101. package/{build → lib/cjs}/lock.test.d.ts +0 -0
  102. package/lib/cjs/lock.test.js +18 -0
  103. package/{build → lib/cjs}/log.d.ts +0 -0
  104. package/lib/cjs/log.js +54 -0
  105. package/lib/cjs/observable/event.d.ts +35 -0
  106. package/lib/cjs/observable/event.js +61 -0
  107. package/lib/cjs/observable/observable.d.ts +132 -0
  108. package/lib/cjs/observable/observable.js +363 -0
  109. package/{build/dom/test.d.ts → lib/cjs/observable/observable.test.d.ts} +0 -0
  110. package/lib/cjs/observable/observable.test.js +65 -0
  111. package/{build → lib/cjs}/range.d.ts +0 -0
  112. package/lib/cjs/range.js +11 -0
  113. package/{build → lib/cjs}/result.d.ts +11 -11
  114. package/lib/cjs/result.js +80 -0
  115. package/{build → lib/cjs}/result.test.d.ts +0 -0
  116. package/lib/cjs/result.test.js +73 -0
  117. package/{build → lib/cjs}/safe.d.ts +0 -0
  118. package/lib/cjs/safe.js +14 -0
  119. package/{build → lib/cjs}/scope/describe.d.ts +4 -0
  120. package/lib/cjs/scope/describe.js +73 -0
  121. package/{build → lib/cjs}/scope/display/console.d.ts +0 -0
  122. package/lib/cjs/scope/display/console.js +25 -0
  123. package/{build → lib/cjs}/scope/display/dom.d.ts +2 -2
  124. package/lib/cjs/scope/display/dom.js +30 -0
  125. package/{build → lib/cjs}/scope/display/junit.d.ts +0 -0
  126. package/lib/cjs/scope/display/junit.js +21 -0
  127. package/{build → lib/cjs}/scope/execute.d.ts +1 -1
  128. package/lib/cjs/scope/execute.js +91 -0
  129. package/{build → lib/cjs}/scope/expect.d.ts +1 -1
  130. package/lib/cjs/scope/expect.js +114 -0
  131. package/{build → lib/cjs}/scope/fix.d.ts +0 -0
  132. package/lib/cjs/scope/fix.js +26 -0
  133. package/{build → lib/cjs}/scope/index.d.ts +0 -0
  134. package/lib/cjs/scope/index.js +15 -0
  135. package/{build → lib/cjs}/scope/scope.d.ts +0 -0
  136. package/lib/cjs/scope/scope.js +2 -0
  137. package/lib/cjs/scope/state.d.ts +1 -0
  138. package/lib/cjs/scope/state.js +11 -0
  139. package/{build → lib/cjs}/server/http/apps.d.ts +0 -0
  140. package/lib/cjs/server/http/apps.js +27 -0
  141. package/lib/cjs/server/http/css.d.ts +5 -0
  142. package/lib/cjs/server/http/css.js +54 -0
  143. package/{build → lib/cjs}/server/http/index.d.ts +0 -0
  144. package/lib/cjs/server/http/index.js +77 -0
  145. package/{build → lib/cjs}/server/http/response.d.ts +0 -0
  146. package/lib/cjs/server/http/response.js +45 -0
  147. package/{build → lib/cjs}/server/http/sitemap.d.ts +0 -0
  148. package/lib/cjs/server/http/sitemap.js +46 -0
  149. package/{build → lib/cjs}/server/http/static.d.ts +0 -0
  150. package/lib/cjs/server/http/static.js +25 -0
  151. package/{build → lib/cjs}/server/http/typescript.d.ts +0 -0
  152. package/lib/cjs/server/http/typescript.js +44 -0
  153. package/{build → lib/cjs}/server/main.d.ts +0 -0
  154. package/lib/cjs/server/main.js +14 -0
  155. package/{build → lib/cjs}/test.d.mts +0 -0
  156. package/lib/cjs/test.mjs +28 -0
  157. package/lib/cjs/test_all.d.ts +9 -0
  158. package/lib/cjs/test_all.js +30 -0
  159. package/{build → lib/cjs}/transpile.d.mts +0 -0
  160. package/lib/cjs/transpile.mjs +22 -0
  161. package/lib/cjs/tsconfig.tsbuildinfo +1 -0
  162. package/lib/esm/assert.d.ts +23 -0
  163. package/{build → lib/esm}/assert.js +1 -1
  164. package/lib/esm/case.d.ts +1 -0
  165. package/{build → lib/esm}/case.js +0 -0
  166. package/lib/esm/components/button_bar.d.ts +8 -0
  167. package/lib/esm/components/button_bar.js +27 -0
  168. package/lib/esm/components/inline_edit.d.ts +12 -0
  169. package/{build → lib/esm}/components/inline_edit.js +3 -3
  170. package/lib/esm/components/logger.d.ts +6 -0
  171. package/{build → lib/esm}/components/logger.js +3 -3
  172. package/lib/esm/components/select.d.ts +10 -0
  173. package/{build → lib/esm}/components/select.js +2 -2
  174. package/lib/esm/components/test.d.ts +1 -0
  175. package/lib/esm/components/test.js +3 -0
  176. package/lib/esm/components/virtual_scroll.d.ts +40 -0
  177. package/{build → lib/esm}/components/virtual_scroll.js +3 -3
  178. package/{build/dom/types/html.js → lib/esm/components/virtual_scroll.test.d.ts} +0 -0
  179. package/{build → lib/esm}/components/virtual_scroll.test.js +3 -4
  180. package/lib/esm/context.d.ts +15 -0
  181. package/{build → lib/esm}/context.js +3 -3
  182. package/{build/scope/scope.js → lib/esm/context.test.d.ts} +0 -0
  183. package/{build → lib/esm}/context.test.js +0 -0
  184. package/lib/esm/debounce.d.ts +1 -0
  185. package/{build → lib/esm}/debounce.js +0 -0
  186. package/lib/esm/diff.d.ts +15 -0
  187. package/lib/esm/diff.js +54 -0
  188. package/{build/test_all.d.ts → lib/esm/diff.test.d.ts} +0 -0
  189. package/lib/esm/diff.test.js +39 -0
  190. package/lib/esm/display.d.ts +5 -0
  191. package/lib/esm/display.js +11 -0
  192. package/lib/esm/dom/css/border.d.ts +11 -0
  193. package/{build → lib/esm}/dom/css/border.js +0 -0
  194. package/lib/esm/dom/css/constants.d.ts +31 -0
  195. package/{build → lib/esm}/dom/css/constants.js +0 -0
  196. package/lib/esm/dom/css/core.d.ts +5 -0
  197. package/{build → lib/esm}/dom/css/core.js +0 -0
  198. package/lib/esm/dom/css/fstyle.d.ts +5 -0
  199. package/{build → lib/esm}/dom/css/fstyle.js +0 -0
  200. package/lib/esm/dom/css/sizing.d.ts +5 -0
  201. package/{build → lib/esm}/dom/css/sizing.js +0 -0
  202. package/lib/esm/dom/dom.d.ts +27 -0
  203. package/{build → lib/esm}/dom/dom.js +44 -34
  204. package/lib/esm/dom/fc.d.ts +14 -0
  205. package/{build → lib/esm}/dom/fc.js +1 -1
  206. package/lib/esm/dom/fc.test.d.ts +1 -0
  207. package/{build → lib/esm}/dom/fc.test.js +0 -0
  208. package/lib/esm/dom/form/form.app.d.ts +1 -0
  209. package/{build → lib/esm}/dom/form/form.app.js +0 -0
  210. package/lib/esm/dom/form/form.d.ts +26 -0
  211. package/{build → lib/esm}/dom/form/form.js +14 -5
  212. package/lib/esm/dom/form/form.test.d.ts +0 -0
  213. package/lib/esm/dom/form/form.test.js +1 -0
  214. package/lib/esm/dom/html.d.ts +113 -0
  215. package/{build → lib/esm}/dom/html.js +0 -0
  216. package/lib/esm/dom/html.test.d.ts +1 -0
  217. package/{build → lib/esm}/dom/html.test.js +4 -4
  218. package/lib/esm/dom/observable.d.ts +2 -0
  219. package/lib/esm/dom/observable.js +6 -0
  220. package/lib/esm/dom/observable.test.d.ts +1 -0
  221. package/lib/esm/dom/observable.test.js +33 -0
  222. package/lib/esm/dom/provide.d.ts +3 -0
  223. package/lib/esm/dom/provide.js +7 -0
  224. package/lib/esm/dom/router/link.d.ts +6 -0
  225. package/{build → lib/esm}/dom/router/link.js +0 -0
  226. package/lib/esm/dom/router/router.d.ts +12 -0
  227. package/{build → lib/esm}/dom/router/router.js +0 -0
  228. package/lib/esm/dom/svg.d.ts +64 -0
  229. package/{build → lib/esm}/dom/svg.js +0 -0
  230. package/lib/esm/dom/test.d.ts +1 -0
  231. package/lib/esm/dom/test.js +9 -0
  232. package/lib/esm/dom/types/css.d.ts +6612 -0
  233. package/{build → lib/esm}/dom/types/css.js +0 -0
  234. package/lib/esm/dom/types/dom.d.ts +0 -0
  235. package/lib/esm/dom/types/dom.js +1 -0
  236. package/lib/esm/dom/types/html.d.ts +616 -0
  237. package/lib/esm/dom/types/html.js +1 -0
  238. package/lib/esm/dom/xml.d.ts +1 -0
  239. package/{build → lib/esm}/dom/xml.js +1 -2
  240. package/lib/esm/equal.d.ts +5 -0
  241. package/lib/esm/equal.js +37 -0
  242. package/lib/esm/equal.test.d.ts +1 -0
  243. package/{build → lib/esm}/equal.test.js +0 -0
  244. package/lib/esm/flags.d.ts +7 -0
  245. package/{build → lib/esm}/flags.js +1 -1
  246. package/lib/esm/flags.test.d.ts +1 -0
  247. package/{build → lib/esm}/flags.test.js +0 -0
  248. package/lib/esm/fs.d.ts +48 -0
  249. package/lib/esm/fs.js +144 -0
  250. package/lib/esm/fs.test.d.ts +1 -0
  251. package/lib/esm/fs.test.js +43 -0
  252. package/lib/esm/generator.d.ts +1 -0
  253. package/{build → lib/esm}/generator.js +0 -0
  254. package/lib/esm/generator.test.d.ts +1 -0
  255. package/{build → lib/esm}/generator.test.js +0 -0
  256. package/lib/esm/is_browser.d.ts +1 -0
  257. package/{build → lib/esm}/is_browser.js +0 -0
  258. package/lib/esm/loader.d.mts +22 -0
  259. package/{build → lib/esm}/loader.mjs +0 -0
  260. package/lib/esm/lock.d.ts +1 -0
  261. package/{build → lib/esm}/lock.js +0 -0
  262. package/lib/esm/lock.test.d.ts +1 -0
  263. package/{build → lib/esm}/lock.test.js +0 -0
  264. package/lib/esm/log.d.ts +26 -0
  265. package/{build → lib/esm}/log.js +16 -4
  266. package/lib/esm/observable/event.d.ts +35 -0
  267. package/lib/esm/observable/event.js +46 -0
  268. package/lib/esm/observable/observable.d.ts +132 -0
  269. package/lib/esm/observable/observable.js +343 -0
  270. package/lib/esm/observable/observable.test.d.ts +1 -0
  271. package/lib/esm/observable/observable.test.js +63 -0
  272. package/lib/esm/range.d.ts +1 -0
  273. package/{build → lib/esm}/range.js +0 -0
  274. package/lib/esm/result.d.ts +31 -0
  275. package/{build → lib/esm}/result.js +3 -3
  276. package/lib/esm/result.test.d.ts +1 -0
  277. package/{build → lib/esm}/result.test.js +0 -0
  278. package/lib/esm/safe.d.ts +1 -0
  279. package/{build → lib/esm}/safe.js +0 -0
  280. package/lib/esm/scope/describe.d.ts +18 -0
  281. package/{build → lib/esm}/scope/describe.js +14 -6
  282. package/lib/esm/scope/display/console.d.ts +2 -0
  283. package/{build → lib/esm}/scope/display/console.js +0 -0
  284. package/lib/esm/scope/display/dom.d.ts +3 -0
  285. package/{build → lib/esm}/scope/display/dom.js +0 -0
  286. package/lib/esm/scope/display/junit.d.ts +2 -0
  287. package/{build → lib/esm}/scope/display/junit.js +0 -0
  288. package/lib/esm/scope/execute.d.ts +12 -0
  289. package/{build → lib/esm}/scope/execute.js +3 -3
  290. package/lib/esm/scope/expect.d.ts +23 -0
  291. package/{build → lib/esm}/scope/expect.js +4 -3
  292. package/lib/esm/scope/fix.d.ts +4 -0
  293. package/{build → lib/esm}/scope/fix.js +0 -0
  294. package/{build/scope/index.js → lib/esm/scope/index.d.ts} +0 -0
  295. package/lib/esm/scope/index.js +3 -0
  296. package/lib/esm/scope/scope.d.ts +17 -0
  297. package/lib/esm/scope/scope.js +1 -0
  298. package/lib/esm/scope/state.d.ts +1 -0
  299. package/lib/esm/scope/state.js +7 -0
  300. package/lib/esm/server/http/apps.d.ts +5 -0
  301. package/{build → lib/esm}/server/http/apps.js +0 -0
  302. package/lib/esm/server/http/css.d.ts +5 -0
  303. package/lib/esm/server/http/css.js +50 -0
  304. package/lib/esm/server/http/index.d.ts +21 -0
  305. package/{build → lib/esm}/server/http/index.js +4 -2
  306. package/lib/esm/server/http/response.d.ts +4 -0
  307. package/{build → lib/esm}/server/http/response.js +6 -3
  308. package/lib/esm/server/http/sitemap.d.ts +2 -0
  309. package/{build → lib/esm}/server/http/sitemap.js +0 -0
  310. package/lib/esm/server/http/static.d.ts +2 -0
  311. package/{build → lib/esm}/server/http/static.js +0 -0
  312. package/lib/esm/server/http/typescript.d.ts +5 -0
  313. package/{build → lib/esm}/server/http/typescript.js +0 -0
  314. package/lib/esm/server/main.d.ts +2 -0
  315. package/{build → lib/esm}/server/main.js +5 -2
  316. package/lib/esm/test.d.mts +2 -0
  317. package/lib/esm/test.mjs +26 -0
  318. package/lib/esm/test_all.d.ts +9 -0
  319. package/lib/esm/test_all.js +28 -0
  320. package/lib/esm/transpile.d.mts +3 -0
  321. package/{build → lib/esm}/transpile.mjs +0 -0
  322. package/lib/esm/tsconfig.tsbuildinfo +1 -0
  323. package/package.json +18 -16
  324. package/src/assert.ts +1 -1
  325. package/src/components/button_bar.ts +33 -27
  326. package/src/components/inline_edit.ts +3 -3
  327. package/src/components/logger.ts +5 -6
  328. package/src/components/select.ts +3 -3
  329. package/src/components/test.js +3 -2
  330. package/src/components/virtual_scroll.test.ts +4 -4
  331. package/src/components/virtual_scroll.ts +8 -8
  332. package/src/context.ts +3 -3
  333. package/src/diff.test.ts +48 -0
  334. package/src/diff.ts +84 -0
  335. package/src/display.ts +8 -2
  336. package/src/dom/css/border.ts +3 -3
  337. package/src/dom/css/core.ts +1 -1
  338. package/src/dom/css/fstyle.ts +2 -2
  339. package/src/dom/css/sizing.ts +1 -1
  340. package/src/dom/dom.ts +73 -60
  341. package/src/dom/fc.test.ts +3 -3
  342. package/src/dom/fc.ts +11 -10
  343. package/src/dom/form/form.app.ts +2 -2
  344. package/src/dom/form/form.ts +33 -10
  345. package/src/dom/html.test.ts +8 -8
  346. package/src/dom/html.ts +7 -10
  347. package/src/dom/observable.test.ts +43 -0
  348. package/src/dom/observable.ts +11 -0
  349. package/src/dom/provide.ts +11 -0
  350. package/src/dom/router/link.ts +2 -2
  351. package/src/dom/router/router.ts +5 -5
  352. package/src/dom/svg.ts +1 -1
  353. package/src/dom/test.ts +8 -2
  354. package/src/dom/types/html.ts +1 -1
  355. package/src/dom/xml.ts +1 -2
  356. package/src/equal.ts +22 -11
  357. package/src/flags.ts +1 -1
  358. package/src/fs.test.ts +53 -0
  359. package/src/fs.ts +180 -0
  360. package/src/index.html +16 -13
  361. package/src/log.ts +8 -4
  362. package/src/observable/_notes +21 -8
  363. package/src/observable/event.ts +93 -0
  364. package/src/observable/observable.test.ts +73 -0
  365. package/src/observable/observable.ts +463 -0
  366. package/src/pico/_variables.scss +66 -0
  367. package/src/pico/components/_accordion.scss +112 -0
  368. package/src/pico/components/_button-group.scss +51 -0
  369. package/src/pico/components/_card.scss +47 -0
  370. package/src/pico/components/_dropdown.scss +203 -0
  371. package/src/pico/components/_modal.scss +181 -0
  372. package/src/pico/components/_nav.scss +79 -0
  373. package/src/pico/components/_progress.scss +70 -0
  374. package/src/pico/components/_property.scss +34 -0
  375. package/src/pico/content/_button.scss +152 -0
  376. package/src/pico/content/_code.scss +63 -0
  377. package/src/pico/content/_embedded.scss +0 -0
  378. package/src/pico/content/_form-alt.scss +276 -0
  379. package/src/pico/content/_form.scss +259 -0
  380. package/src/pico/content/_misc.scss +0 -0
  381. package/src/pico/content/_table.scss +28 -0
  382. package/src/pico/content/_toggle.scss +132 -0
  383. package/src/pico/content/_typography.scss +232 -0
  384. package/src/pico/layout/_container.scss +40 -0
  385. package/src/pico/layout/_document.scss +0 -0
  386. package/src/pico/layout/_flex.scss +46 -0
  387. package/src/pico/layout/_grid.scss +24 -0
  388. package/src/pico/layout/_scroller.scss +16 -0
  389. package/src/pico/layout/_section.scss +8 -0
  390. package/src/pico/layout/_sectioning.scss +55 -0
  391. package/src/pico/pico.scss +60 -0
  392. package/src/pico/reset/_accessibility.scss +34 -0
  393. package/src/pico/reset/_button.scss +17 -0
  394. package/src/pico/reset/_code.scss +15 -0
  395. package/src/pico/reset/_document.scss +48 -0
  396. package/src/pico/reset/_embedded.scss +39 -0
  397. package/src/pico/reset/_form.scss +97 -0
  398. package/src/pico/reset/_misc.scss +23 -0
  399. package/src/pico/reset/_nav.scss +5 -0
  400. package/src/pico/reset/_progress.scss +4 -0
  401. package/src/pico/reset/_table.scss +8 -0
  402. package/src/pico/reset/_typography.scss +25 -0
  403. package/src/pico/themes/default/_colors.scss +65 -0
  404. package/src/pico/themes/default/_dark.scss +148 -0
  405. package/src/pico/themes/default/_light.scss +149 -0
  406. package/src/pico/themes/default/_styles.scss +272 -0
  407. package/src/pico/themes/default.scss +34 -0
  408. package/src/pico/utilities/_accessibility.scss +3 -0
  409. package/src/pico/utilities/_loading.scss +52 -0
  410. package/src/pico/utilities/_reduce-motion.scss +27 -0
  411. package/src/pico/utilities/_tooltip.scss +101 -0
  412. package/src/result.ts +17 -21
  413. package/src/scope/describe.ts +16 -6
  414. package/src/scope/display/console.ts +4 -4
  415. package/src/scope/display/dom.ts +7 -7
  416. package/src/scope/display/junit.ts +3 -3
  417. package/src/scope/execute.ts +5 -8
  418. package/src/scope/expect.ts +12 -11
  419. package/src/scope/state.ts +10 -0
  420. package/src/server/http/css.ts +65 -0
  421. package/src/server/http/index.ts +4 -2
  422. package/src/server/http/response.ts +7 -4
  423. package/src/server/http/sitemap.ts +1 -1
  424. package/src/server/main.ts +9 -2
  425. package/src/test.mjs +22 -18
  426. package/src/test_all.ts +20 -9
  427. package/src/zip/spec.txt +3260 -0
  428. package/build/components/button_bar.js +0 -16
  429. package/build/components/select.d.ts +0 -13
  430. package/build/components/test.js +0 -2
  431. package/build/display.js +0 -3
  432. package/build/dom/dom.d.ts +0 -27
  433. package/build/dom/form/form.app.d.ts +0 -1
  434. package/build/dom/form/form.d.ts +0 -25
  435. package/build/dom/html.d.ts +0 -117
  436. package/build/dom/router/link.d.ts +0 -6
  437. package/build/dom/svg.d.ts +0 -64
  438. package/build/dom/test.js +0 -2
  439. package/build/equal.d.ts +0 -4
  440. package/build/equal.js +0 -22
  441. package/build/index.d.ts +0 -13
  442. package/build/index.js +0 -13
  443. package/build/parcel_resolver.d.ts +0 -3
  444. package/build/parcel_resolver.js +0 -19
  445. package/build/test.mjs +0 -23
  446. package/build/test_all.js +0 -19
  447. package/src/observable/observable._js +0 -175
@@ -1,6 +1,6 @@
1
1
  import { debounce } from "../debounce.js";
2
2
  import { FC, State } from "../dom/fc.js";
3
- import { div, UHTMLElement } from "../dom/html.js";
3
+ import { div } from "../dom/html.js";
4
4
 
5
5
  export interface VirtualScrollSettings {
6
6
  minIndex: number;
@@ -22,7 +22,7 @@ export function arrayAdapter<T>(data: T[]): VirtualScrollDataAdapter<T> {
22
22
  export interface VirtualScrollProps<T, U extends HTMLElement> {
23
23
  settings: Partial<VirtualScrollSettings>;
24
24
  get: VirtualScrollDataAdapter<T>;
25
- row: (t: T) => UHTMLElement<U>;
25
+ row: (t: T) => U;
26
26
  }
27
27
 
28
28
  export function fillVirtualScrollSettings(
@@ -30,7 +30,7 @@ export function fillVirtualScrollSettings(
30
30
  ): VirtualScrollSettings {
31
31
  const {
32
32
  minIndex = 0,
33
- maxIndex = 1,
33
+ maxIndex = Number.MAX_SAFE_INTEGER,
34
34
  startIndex = 0,
35
35
  itemHeight = 20,
36
36
  count = maxIndex - minIndex + 1,
@@ -121,7 +121,7 @@ interface VirtualScrollState<T, U extends HTMLElement = HTMLElement> {
121
121
  bottomPaddingHeight: number; // px
122
122
  toleranceHeight: number; // px
123
123
  data: T[];
124
- rows: UHTMLElement<U>[];
124
+ rows: U[];
125
125
  }
126
126
 
127
127
  // export interface VirtualScroll<T, U extends HTMLElement> {
@@ -130,8 +130,8 @@ interface VirtualScrollState<T, U extends HTMLElement = HTMLElement> {
130
130
  // }
131
131
 
132
132
  export const VirtualScroll = FC<
133
- VirtualScrollProps<unknown, HTMLElement>,
134
- VirtualScrollState<unknown, HTMLElement>
133
+ VirtualScrollProps<any, HTMLElement>,
134
+ VirtualScrollState<any, HTMLElement>
135
135
  >("virtual-scroll", (element, props) => {
136
136
  const settings = fillVirtualScrollSettings(props.settings);
137
137
  const state = (element[State] = {
@@ -163,14 +163,14 @@ export const VirtualScroll = FC<
163
163
  state.topPaddingHeight = newState.topPaddingHeight;
164
164
  state.bottomPaddingHeight = newState.bottomPaddingHeight;
165
165
  state.data = newState.data;
166
- element[State].rows = state.data.map(props.row);
166
+ state.rows = state.data.map(props.row);
167
167
 
168
168
  viewportElement.update(
169
169
  div({
170
170
  class: "VirtualScroll__topPadding",
171
171
  style: { height: `${state.topPaddingHeight}px` },
172
172
  }),
173
- ...(element[State].rows ?? []).map((row, i) =>
173
+ ...(state.rows ?? []).map((row, i) =>
174
174
  div(
175
175
  {
176
176
  class: `VirtualScroll__item_${i}`,
package/src/context.ts CHANGED
@@ -21,8 +21,8 @@ export function using<T, E extends Error, C extends Context>(
21
21
  operation?: Operation<T, E, C>,
22
22
  normalizeError: (e: Error | unknown | any) => Err<E> = (e) => Err(e)
23
23
  ): Result<T, E> {
24
- if (typeof context == "function") {
25
- if (context.length == 1) {
24
+ if (typeof context === "function") {
25
+ if (context.length === 1) {
26
26
  operation = context as Operation<T, E, C>;
27
27
  context = {} as C;
28
28
  } else {
@@ -47,7 +47,7 @@ export async function asyncUsing<T, E extends Error, C extends Context>(
47
47
  operation: AsyncOperation<T, E, C>,
48
48
  normalizeError: (e: Error | unknown | any) => Err<E> = (e: E) => Err(e)
49
49
  ): Promise<Result<T, E>> {
50
- context = typeof context == "function" ? await context() : context;
50
+ context = typeof context === "function" ? await context() : context;
51
51
  let result: Result<T, E>;
52
52
  try {
53
53
  context[Enter]();
@@ -0,0 +1,48 @@
1
+ import { diff } from "./diff.js";
2
+ import { describe, it } from "./scope/describe.js";
3
+ import { expect } from "./scope/expect.js";
4
+
5
+ describe("diff", () => {
6
+ it("diffs primitives", () => {
7
+ const diffed = diff(1, 2);
8
+ expect(diffed).toEqual([{ key: "", left: 1, right: 2 }]);
9
+ });
10
+
11
+ it("diffs objects", () => {
12
+ const diffed = diff({ a: 1, b: 2 }, { a: 2, b: 2 });
13
+ expect(diffed).toEqual([{ key: "a", left: 1, right: 2 }]);
14
+ });
15
+
16
+ it("diffs nested objects", () => {
17
+ const diffed = diff({ a: { c: 1 }, b: 2 }, { a: { c: 2 }, b: 2 });
18
+ expect(diffed).toEqual([
19
+ { key: "a", children: [{ key: "c", left: 1, right: 2 }] },
20
+ ]);
21
+ });
22
+
23
+ it("diffs missing sides", () => {
24
+ const diffed = diff<{ a?: number; b?: number }>({ a: 1 }, { b: 2 });
25
+ expect(diffed).toEqual([
26
+ { key: "a", left: 1, right: undefined },
27
+ { key: "b", left: undefined, right: 2 },
28
+ ]);
29
+ });
30
+
31
+ it("diffs arrays", () => {
32
+ const diffed = diff<number[]>([1, 2, 3], [1, 4, 3]);
33
+ expect(diffed).toEqual([{ key: 1, left: 2, right: 4 }]);
34
+ });
35
+
36
+ it("diffs objects in an array", () => {
37
+ const diffed = diff(
38
+ [{ a: { b: 1 } }, { a: { b: 2 } }, { a: { b: 3 } }],
39
+ [{ a: { b: 1 } }, { a: { b: 4 } }, { a: { b: 3 } }]
40
+ );
41
+ expect(diffed).toEqual([
42
+ {
43
+ key: 1,
44
+ children: [{ key: "a", children: [{ key: "b", left: 2, right: 4 }] }],
45
+ },
46
+ ]);
47
+ });
48
+ });
package/src/diff.ts ADDED
@@ -0,0 +1,84 @@
1
+ import { range } from "./range.js";
2
+ import { isSome, None, Option, Some } from "./result.js";
3
+
4
+ export const DiffA = Symbol("A");
5
+ export const DiffB = Symbol("B");
6
+
7
+ export type DiffIndex = string | number;
8
+ export type DiffPrimitive = string | number | boolean | null | undefined;
9
+
10
+ interface DiffEntry {
11
+ key: DiffIndex;
12
+ left: DiffPrimitive;
13
+ right: DiffPrimitive;
14
+ }
15
+
16
+ interface DiffList {
17
+ key: DiffIndex;
18
+ children: (DiffEntry | DiffList)[];
19
+ }
20
+
21
+ function doDiff<T>(va: T, vb: T, k: DiffIndex): Option<DiffList | DiffEntry> {
22
+ if (Array.isArray(va)) {
23
+ // @ts-ignore
24
+ return diffArray(va, vb, k);
25
+ }
26
+ if (typeof va === "object") {
27
+ const d = diffObject(va, vb, k);
28
+ if (d.children.length === 0) {
29
+ return None();
30
+ } else {
31
+ return Some(d);
32
+ }
33
+ }
34
+ if (Object.is(va, vb)) {
35
+ return None();
36
+ } else {
37
+ // @ts-ignore
38
+ return { key: k, left: va, right: vb };
39
+ }
40
+ }
41
+
42
+ function diffArray<T>(
43
+ a: Partial<T>[],
44
+ b: Partial<T>[],
45
+ key: DiffIndex
46
+ ): Option<DiffList> {
47
+ const indexes = Math.max(a.length, b.length);
48
+ const children = range(0, indexes)
49
+ .map((i) => doDiff(a[i], b[i], i))
50
+ .filter(isSome);
51
+ return children.length > 0 ? { key, children } : None();
52
+ }
53
+
54
+ function diffObject<T>(
55
+ a: Partial<T>,
56
+ b: Partial<T>,
57
+ key: DiffIndex = ""
58
+ ): DiffList {
59
+ const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
60
+ const children = [...keys]
61
+ // @ts-ignore
62
+ .map((k) => doDiff(a[k], b[k], k))
63
+ .filter(isSome);
64
+ return {
65
+ key,
66
+ children,
67
+ };
68
+ }
69
+
70
+ export function diff<T>(
71
+ a: Partial<T>,
72
+ b: Partial<T>
73
+ ): (DiffEntry | DiffList)[] {
74
+ if (typeof a != "object" && !Object.is(a, b)) {
75
+ // @ts-ignore
76
+ return [{ key: "", left: a, right: b }];
77
+ }
78
+ return (
79
+ Array.isArray(a)
80
+ ? // @ts-ignore
81
+ diffArray(a, b, "") ?? { children: [] }
82
+ : diffObject(a, b, "")
83
+ ).children;
84
+ }
package/src/display.ts CHANGED
@@ -8,5 +8,11 @@ export const isDisplay = (/** @type unknown */ a: unknown): a is Display =>
8
8
  typeof (a as Display).toString === "function" ||
9
9
  typeof (a as Display) === "string";
10
10
 
11
- export const display = (a: unknown | Display): string =>
12
- isDisplay(a) ? a.toString() : JSON.stringify(a);
11
+ export const display = (a: unknown | Display): string => {
12
+ if (isDisplay(a)) {
13
+ const str = a.toString();
14
+ if (str === "[object Object]") return JSON.stringify(a);
15
+ return str;
16
+ }
17
+ return JSON.stringify(a);
18
+ };
@@ -1,6 +1,6 @@
1
- import { Properties } from "../types/css.js";
2
- import { Side, Size } from "./constants.js";
3
- import { isSide, getSize, getSide } from "./core.js";
1
+ import { Properties } from "../types/css.js"
2
+ import { Side, Size } from "./constants.js"
3
+ import { isSide, getSize, getSide } from "./core.js"
4
4
 
5
5
  export function rounded(size: Size = "", side: Side = "") {
6
6
  if (isSide(size)) {
@@ -1,4 +1,4 @@
1
- import { Side, Sides, Size, Sizes } from "./constants.js";
1
+ import { Side, Sides, Size, Sizes } from "./constants.js"
2
2
 
3
3
  export function isSide(v: string): v is Side {
4
4
  return Sides[v as keyof typeof Sides] !== undefined;
@@ -1,5 +1,5 @@
1
- import { dashCase } from "../../case.js";
2
- import { Properties } from "../types/css.js";
1
+ import { dashCase } from "../../case.js"
2
+ import { Properties } from "../types/css.js"
3
3
 
4
4
  export type FStyle =
5
5
  | Properties
@@ -1,4 +1,4 @@
1
- import { Width, Widths } from "./constants.js";
1
+ import { Width, Widths } from "./constants.js"
2
2
 
3
3
  export function width(amount: Width, block?: "inline") {
4
4
  if (amount === undefined && Widths[block as Width] !== undefined) {
package/src/dom/dom.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as CSS from "./types/css";
1
+ import { Properties } from "./types/css.js"
2
2
 
3
3
  const Events = Symbol("events");
4
4
  export const CLEAR = Symbol("Clear children");
@@ -10,40 +10,44 @@ export type DOMElement = Element &
10
10
  DocumentAndElementEventHandlers &
11
11
  ElementCSSInlineStyle;
12
12
 
13
- export type Updater<E extends DOMElement> = Omit<E, "style"> & {
14
- [Events]?: Map<string, EventHandler>;
15
- update?: (attrs?: DenormAttrs<E>, ...children: DenormChildren[]) => Node;
16
- };
17
-
18
- export type Updatable<E extends Element> = Omit<E, "style"> & {
19
- [Events]: Map<string, EventHandler>;
20
- update: (attrs?: DenormAttrs<E>, ...children: DenormChildren[]) => Node;
21
- };
22
-
23
13
  export type DomAttrs = {
24
- class: string;
25
- style: Partial<CSS.Properties>;
14
+ class: string | string[];
15
+ style: Partial<Properties> | string;
16
+ role: "button" | "list" | "listbox";
26
17
  events: Partial<{
27
- [K in keyof HTMLElementEventMap]: EventHandler;
18
+ [K in keyof HTMLElementEventMap]: EventHandler | null;
28
19
  }>;
29
20
  };
30
21
 
31
- export type Attrs<E extends Element, S = {}> = Partial<E & S & DomAttrs>;
22
+ export type Attrs<E extends Omit<Element, "update">, S = {}> = Partial<
23
+ Omit<E, "style"> & S & DomAttrs
24
+ >;
32
25
 
33
- export type DenormAttrs<E extends Element, S = {}> =
26
+ export type DenormAttrs<E extends Omit<Element, "update">, S = {}> =
34
27
  | Attrs<E, S>
35
28
  | DenormChildren;
36
29
 
30
+ declare global {
31
+ interface Element {
32
+ [Events]: Map<string, EventHandler>;
33
+ update(attrs?: DenormAttrs<Element>, ...children: DenormChildren[]): this;
34
+ }
35
+ }
36
+
37
+ export type DOMUpdates<E extends Element = Element> =
38
+ | [DenormAttrs<E>, ...DenormChildren[]]
39
+ | DenormChildren[];
40
+
37
41
  function isAttrs<E extends Element>(
38
42
  attrs: DenormAttrs<E> | undefined
39
43
  ): attrs is Attrs<E> {
40
44
  if (!attrs) {
41
45
  return false;
42
46
  }
43
- if (typeof attrs === "string") {
44
- return false;
47
+ if (typeof attrs === "object") {
48
+ return !(attrs as Node).nodeType;
45
49
  }
46
- return !(attrs as Node).nodeType;
50
+ return false;
47
51
  }
48
52
 
49
53
  export function normalizeArguments<E extends Element>(
@@ -63,29 +67,31 @@ export function normalizeArguments<E extends Element>(
63
67
  return [attributes, children.flat()];
64
68
  }
65
69
 
66
- export function up<E extends DOMElement>(
67
- element: E,
70
+ export function up<E extends Element>(
71
+ element: Omit<E, "update">,
68
72
  attrs?: DenormAttrs<E>,
69
73
  ...children: DenormChildren[]
70
- ): Updatable<E> {
71
- return update(element, ...normalizeArguments(attrs, children));
74
+ ): E {
75
+ return update(element, ...normalizeArguments(attrs, children)) as E;
72
76
  }
73
77
 
74
- export function update<E extends DOMElement>(
75
- element: Updater<E>,
76
- attrs: Attrs<E>,
78
+ export function update(
79
+ element: Omit<Element, "update">,
80
+ attrs: Attrs<Element>,
77
81
  children: DenormChildren[]
78
- ): Updatable<E> {
82
+ ): Element {
79
83
  // Track events, to remove later
80
84
  const $events = (element[Events] ??= new Map<string, EventHandler>());
81
85
  const { style = {}, events = {}, ...rest } = attrs;
82
86
 
83
87
  Object.entries(events as NonNullable<typeof attrs.events>).forEach(
84
88
  ([k, v]) => {
85
- if (v === null && $events.has(k)) {
86
- const listener = $events.get(k)!;
87
- element.removeEventListener(k, listener);
88
- } else if (!$events.has(k)) {
89
+ if (v === null) {
90
+ if ($events.has(k)) {
91
+ const listener = $events.get(k)!;
92
+ element.removeEventListener(k, listener);
93
+ }
94
+ } else if (v !== undefined) {
89
95
  element.addEventListener(k as keyof ElementEventMap, v);
90
96
  $events.set(k, v);
91
97
  }
@@ -107,47 +113,54 @@ export function update<E extends DOMElement>(
107
113
  }
108
114
 
109
115
  Object.entries(rest).forEach(([k, v]) => {
110
- if (k === "class" && typeof v === "string") {
111
- v.split(/\s+/m)
116
+ if (k === "class") {
117
+ v = Array.isArray(v)
118
+ ? v
119
+ : (typeof v === "string" ? v : `${v}`).split(/\s+/m);
120
+ (v as string[])
112
121
  .filter((s) => s !== "")
113
- .forEach((c) => element.classList.add(c));
122
+ .forEach((c) => {
123
+ if (c.startsWith("!")) {
124
+ element.classList.remove(c.substring(1));
125
+ } else {
126
+ element.classList.add(c);
127
+ }
128
+ });
129
+ return;
114
130
  }
115
131
 
116
- let useAttributes =
117
- k.startsWith("aria-") ||
132
+ const useNamespace =
133
+ element.namespaceURI &&
118
134
  element.namespaceURI != "http://www.w3.org/1999/xhtml";
119
-
120
- if (useAttributes) {
121
- switch (v) {
122
- case false:
123
- element.removeAttributeNS(element.namespaceURI, k);
124
- break;
125
- case true:
126
- element.setAttributeNS(element.namespaceURI, k, k);
127
- break;
128
- default:
129
- if (v === "") {
130
- element.removeAttributeNS(element.namespaceURI, k);
131
- } else {
132
- element.setAttributeNS(element.namespaceURI, k, v);
133
- }
135
+ const remove = !v;
136
+
137
+ if (useNamespace) {
138
+ if (remove) {
139
+ element.removeAttributeNS(element.namespaceURI, k);
140
+ } else if (v === true) {
141
+ element.setAttributeNS(element.namespaceURI, k, k);
142
+ } else {
143
+ element.setAttributeNS(element.namespaceURI, k, v);
134
144
  }
135
145
  } else {
136
- // @ts-ignore Object.entries is unable to statically look into args
137
- element[k] = v;
146
+ if (remove) {
147
+ element.removeAttribute(k);
148
+ } else if (v === true) {
149
+ element.setAttribute(k, k);
150
+ } else {
151
+ element.setAttribute(k, v);
152
+ }
138
153
  }
139
154
  });
140
155
 
141
156
  if (children?.length > 0) {
142
- if (children[0] === CLEAR) {
143
- element.replaceChildren();
144
- } else {
145
- element.replaceChildren(...(children as (string | Node)[]));
146
- }
157
+ element.replaceChildren(
158
+ ...(children[0] === CLEAR ? [] : (children as (string | Node)[]))
159
+ );
147
160
  }
148
161
 
149
- element.update ??= (attrs, ...children) =>
162
+ (element as Element).update ??= (attrs, ...children) =>
150
163
  update(element, ...normalizeArguments(attrs, children));
151
164
 
152
- return element as Updatable<E>;
165
+ return element as Element;
153
166
  }
@@ -1,6 +1,6 @@
1
- import { describe, it, expect } from "../scope/index.js";
2
- import { FC } from "./fc.js";
3
- import { button, div, form, input, label, small } from "./html.js";
1
+ import { describe, it, expect } from "../scope/index.js"
2
+ import { FC } from "./fc.js"
3
+ import { button, div, form, input, label, small } from "./html.js"
4
4
 
5
5
  describe("FC", () => {
6
6
  it("creates FCs", () => {
package/src/dom/fc.ts CHANGED
@@ -3,25 +3,24 @@ import {
3
3
  DenormChildren,
4
4
  DomAttrs,
5
5
  normalizeArguments,
6
- Updatable,
7
6
  update,
8
- } from "./dom.js";
7
+ } from "./dom.js"
9
8
 
10
9
  export type Attrs<S> = S & Partial<DomAttrs>;
11
10
 
12
11
  export const State = Symbol();
13
12
  export interface FCComponent<P extends object, S extends object>
14
- extends HTMLElement {
15
- [State]: Partial<S>;
13
+ extends Element {
14
+ [State]?: Partial<S>;
16
15
  update(
17
- attrs?: Partial<Attrs<P>> | DenormChildren,
16
+ attrs?: Partial<Attrs<P> & DomAttrs> | DenormChildren,
18
17
  ...children: DenormChildren[]
19
- ): void;
18
+ ): this;
20
19
  }
21
20
  export interface RenderFn<P extends object, S extends object> {
22
21
  (el: FCComponent<P, S>, attrs: Attrs<P>, children: DenormChildren[]):
23
- | Updatable<Element>
24
- | Updatable<Element>[];
22
+ | Element
23
+ | Element[];
25
24
  }
26
25
 
27
26
  export interface FCComponentCtor<P extends object, S extends object> {
@@ -35,7 +34,7 @@ export function FC<P extends object, S extends object = {}>(
35
34
  name: string,
36
35
  component: RenderFn<P, S>
37
36
  ): FCComponentCtor<P, S> {
38
- class FCImpl extends HTMLElement {
37
+ class FCImpl extends HTMLElement implements FCComponent<P, S> {
39
38
  constructor() {
40
39
  super();
41
40
  }
@@ -55,12 +54,14 @@ export function FC<P extends object, S extends object = {}>(
55
54
  this.#children = children;
56
55
  }
57
56
  this.#attrs = { ...this.#attrs, ...(attrs as Attrs<P>) };
57
+
58
58
  // Apply updates from the attrs to the dom node itself
59
- // @ts-ignore
60
59
  update(this, this.#attrs, []);
60
+
61
61
  // Re-run the component function using new element, attrs, and children.
62
62
  const replace = [component(this, this.#attrs, this.#children)];
63
63
  this.replaceChildren(...replace.flat());
64
+ return this;
64
65
  }
65
66
  }
66
67
 
@@ -1,5 +1,5 @@
1
- import { article, button, div, main, small } from "../html.js";
2
- import { Form, Input } from "./form.js";
1
+ import { article, button, div, main, small } from "../html.js"
2
+ import { Form, Input } from "./form.js"
3
3
 
4
4
  export const App = () =>
5
5
  main(
@@ -1,11 +1,12 @@
1
- import { Attrs, DenormChildren } from "../dom.js";
2
- import { form, input, label, option, select } from "../html.js";
1
+ import { Attrs, DenormChildren } from "../dom.js"
2
+ import { form, input, label, option, select } from "../html.js"
3
3
  import {
4
4
  FormAttributes,
5
5
  InputAttributes,
6
+ LabelAttributes,
6
7
  OptionAttributes,
7
8
  SelectAttributes,
8
- } from "../types/html.js";
9
+ } from "../types/html"
9
10
 
10
11
  export const Form = (attrs: FormAttributes, ...children: DenormChildren[]) => {
11
12
  if (attrs.events?.submit) {
@@ -19,8 +20,18 @@ export const Form = (attrs: FormAttributes, ...children: DenormChildren[]) => {
19
20
  };
20
21
  export const Input = (attrs: InputAttributes, ...children: DenormChildren[]) =>
21
22
  label(input(attrs as Attrs<HTMLInputElement>), ...children);
22
- export const Select = ({ options }: { options: string[] | {} }) =>
23
- label(select(...prepareOptions(options).map(Option)));
23
+
24
+ export const Select = (
25
+ attrs: { options: string[] | {}; selected?: string } & SelectAttributes &
26
+ LabelAttributes
27
+ ) =>
28
+ label(
29
+ { style: attrs.style ?? {} },
30
+ select(
31
+ { events: attrs.events ?? {} },
32
+ ...prepareOptions(attrs.options, attrs.selected).map(Option)
33
+ )
34
+ );
24
35
  export const Button = () => {};
25
36
 
26
37
  const prepareOptions = (
@@ -29,19 +40,31 @@ const prepareOptions = (
29
40
  | Record<
30
41
  string,
31
42
  string | { label: string; disabled?: boolean; selected?: boolean }
32
- >
43
+ >,
44
+ selected?: string
33
45
  ): Parameters<typeof Option>[0][] =>
34
46
  Array.isArray(attrs)
35
- ? attrs.map((value) => ({ value, label: value }))
47
+ ? attrs.map((value) => ({
48
+ value,
49
+ label: value,
50
+ selected: selected == value,
51
+ }))
36
52
  : Object.entries(attrs).map(([value, label]) =>
37
- typeof label === "string" ? { value, label } : { value, ...label }
53
+ typeof label === "string"
54
+ ? { value, label, selected: selected === value }
55
+ : { value, ...label }
38
56
  );
39
57
  export const Option = (attrs: OptionAttributes) =>
40
58
  option(attrs as Attrs<HTMLOptionElement>);
41
59
 
42
60
  export const Dropdown = (
43
- attrs: SelectAttributes | { options: Parameters<typeof prepareOptions>[0] }
44
- ) => {};
61
+ attrs: SelectAttributes | { selected?: string },
62
+ ...options: Parameters<typeof prepareOptions>[0][]
63
+ ) =>
64
+ Select({
65
+ ...attrs,
66
+ options: typeof options[0] == "string" ? options : options[0],
67
+ });
45
68
  export const Radios = () => {};
46
69
  export const Checks = () => {};
47
70
  export const Switches = () => {};
@@ -1,6 +1,6 @@
1
- import { describe, it } from "../scope/describe.js";
2
- import { expect } from "../scope/expect.js";
3
- import { table, tbody, td, th, thead, tr, button } from "./html.js";
1
+ import { describe, it } from "../scope/describe.js"
2
+ import { expect } from "../scope/expect.js"
3
+ import { table, tbody, td, th, thead, tr, button } from "./html.js"
4
4
 
5
5
  describe("html", () => {
6
6
  it("creates HTML Elements", () => {
@@ -16,16 +16,16 @@ describe("html", () => {
16
16
  });
17
17
 
18
18
  it("attaches event handlers", () => {
19
- let clicked = false;
19
+ let clicked = 0;
20
20
  const btn = button({
21
21
  events: {
22
22
  click: () => {
23
- clicked = true;
23
+ clicked += 1;
24
24
  },
25
25
  },
26
26
  });
27
27
  btn.dispatchEvent(new Event("click"));
28
- expect(clicked).toBe(true);
28
+ expect(clicked).toBe(1);
29
29
  });
30
30
 
31
31
  it("removes event handlers", () => {
@@ -41,7 +41,7 @@ describe("html", () => {
41
41
 
42
42
  expect(clicked).toBe(1);
43
43
 
44
- btn.update({ events: { click: undefined } });
44
+ btn.update({ events: { click: null } });
45
45
  btn.dispatchEvent(new Event("click"));
46
46
  expect(clicked).toBe(1);
47
47
  });
@@ -49,7 +49,7 @@ describe("html", () => {
49
49
  it("sets style properties", () => {
50
50
  const btn = button({
51
51
  style: { flexDirection: "column" },
52
- }) as unknown as HTMLButtonElement;
52
+ });
53
53
 
54
54
  expect(btn.style.flexDirection).toBe("column");
55
55
  });