@davidsouther/jiffies 2.2.5 → 2026.4.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.
- package/LICENSE +1 -1
- package/package.json +22 -25
- package/src/assert.ts +5 -5
- package/src/components/button_bar.ts +28 -30
- package/src/components/inline_edit.ts +8 -7
- package/src/components/logger.ts +6 -6
- package/src/components/select.ts +7 -7
- package/src/components/test.ts +5 -0
- package/src/components/virtual_scroll.test.ts +9 -6
- package/src/components/virtual_scroll.ts +29 -24
- package/src/context.test.ts +4 -4
- package/src/context.ts +16 -11
- package/src/debounce.ts +9 -3
- package/src/diff.test.ts +4 -4
- package/src/diff.ts +14 -16
- package/src/dom/css/border.ts +11 -11
- package/src/dom/css/core.ts +1 -1
- package/src/dom/css/fstyle.ts +4 -4
- package/src/dom/css/sizing.ts +1 -1
- package/src/dom/dom.ts +59 -47
- package/src/dom/fc.test.ts +8 -8
- package/src/dom/fc.ts +32 -35
- package/src/dom/form/form.app.ts +9 -9
- package/src/dom/form/form.ts +21 -15
- package/src/dom/form/index.html +3 -2
- package/src/dom/html.test.ts +12 -10
- package/src/dom/html.ts +2 -3
- package/src/dom/index.ts +2 -0
- package/src/dom/observable.test.ts +6 -6
- package/src/dom/observable.ts +2 -2
- package/src/dom/provide.ts +1 -1
- package/src/dom/router/link.ts +3 -3
- package/src/dom/router/router.ts +5 -5
- package/src/dom/svg.ts +7 -6
- package/src/dom/test.ts +3 -0
- package/src/dom/types/css.ts +43 -61
- package/src/dom/types/html.ts +2 -4
- package/src/dom/xml.ts +2 -2
- package/src/equal.test.ts +3 -3
- package/src/equal.ts +27 -14
- package/src/flags.test.ts +2 -2
- package/src/flags.ts +2 -2
- package/src/fs.test.ts +5 -5
- package/src/fs.ts +26 -20
- package/src/fs_node.ts +4 -4
- package/src/fs_win.test.ts +1 -1
- package/src/generator.test.ts +4 -3
- package/src/generator.ts +1 -1
- package/src/hooks/_notes +4 -1
- package/src/index.html +7 -7
- package/src/lock.test.ts +4 -4
- package/src/lock.ts +8 -7
- package/src/log.ts +17 -18
- package/src/observable/event.ts +7 -7
- package/src/observable/observable.test.ts +3 -3
- package/src/observable/observable.ts +73 -52
- package/src/result.test.ts +7 -10
- package/src/result.ts +51 -47
- package/src/safe.ts +1 -1
- package/src/scope/describe.ts +12 -11
- package/src/scope/display/console.ts +4 -4
- package/src/scope/display/dom.ts +9 -9
- package/src/scope/display/junit.ts +21 -24
- package/src/scope/execute.ts +17 -12
- package/src/scope/expect.ts +22 -22
- package/src/scope/fix.ts +8 -7
- package/src/scope/index.ts +3 -3
- package/src/scope/scope.ts +2 -2
- package/src/scope/state.ts +2 -2
- package/src/server/http/apps.ts +5 -5
- package/src/server/http/css.ts +10 -26
- package/src/server/http/index.ts +30 -24
- package/src/server/http/response.ts +12 -5
- package/src/server/http/sitemap.ts +8 -8
- package/src/server/http/static.ts +9 -6
- package/src/server/http/typescript.ts +25 -25
- package/src/server/main.ts +7 -4
- package/src/test.mjs +8 -8
- package/src/test_all.ts +16 -13
- package/src/transpile.mjs +5 -18
- package/tsconfig.json +34 -0
- package/build/pico.css +0 -2466
- package/build/pico.css.map +0 -1
- package/lib/cjs/assert.d.ts +0 -26
- package/lib/cjs/assert.js +0 -46
- package/lib/cjs/awaitable.d.ts +0 -1
- package/lib/cjs/awaitable.js +0 -2
- package/lib/cjs/case.d.ts +0 -1
- package/lib/cjs/case.js +0 -9
- package/lib/cjs/components/button_bar.d.ts +0 -8
- package/lib/cjs/components/button_bar.js +0 -29
- package/lib/cjs/components/inline_edit.d.ts +0 -12
- package/lib/cjs/components/inline_edit.js +0 -51
- package/lib/cjs/components/logger.d.ts +0 -6
- package/lib/cjs/components/logger.js +0 -27
- package/lib/cjs/components/select.d.ts +0 -13
- package/lib/cjs/components/select.js +0 -6
- package/lib/cjs/components/test.d.ts +0 -1
- package/lib/cjs/components/test.js +0 -7
- package/lib/cjs/components/virtual_scroll.d.ts +0 -40
- package/lib/cjs/components/virtual_scroll.js +0 -102
- package/lib/cjs/components/virtual_scroll.test.d.ts +0 -1
- package/lib/cjs/components/virtual_scroll.test.js +0 -22
- package/lib/cjs/context.d.ts +0 -15
- package/lib/cjs/context.js +0 -48
- package/lib/cjs/context.test.d.ts +0 -1
- package/lib/cjs/context.test.js +0 -48
- package/lib/cjs/debounce.d.ts +0 -1
- package/lib/cjs/debounce.js +0 -12
- package/lib/cjs/diff.d.ts +0 -15
- package/lib/cjs/diff.js +0 -58
- package/lib/cjs/diff.test.d.ts +0 -1
- package/lib/cjs/diff.test.js +0 -41
- package/lib/cjs/display.d.ts +0 -5
- package/lib/cjs/display.js +0 -16
- package/lib/cjs/dom/css/border.d.ts +0 -11
- package/lib/cjs/dom/css/border.js +0 -33
- package/lib/cjs/dom/css/constants.d.ts +0 -31
- package/lib/cjs/dom/css/constants.js +0 -31
- package/lib/cjs/dom/css/core.d.ts +0 -5
- package/lib/cjs/dom/css/core.js +0 -31
- package/lib/cjs/dom/css/fstyle.d.ts +0 -5
- package/lib/cjs/dom/css/fstyle.js +0 -36
- package/lib/cjs/dom/css/sizing.d.ts +0 -5
- package/lib/cjs/dom/css/sizing.js +0 -14
- package/lib/cjs/dom/dom.d.ts +0 -27
- package/lib/cjs/dom/dom.js +0 -110
- package/lib/cjs/dom/fc.d.ts +0 -14
- package/lib/cjs/dom/fc.js +0 -39
- package/lib/cjs/dom/fc.test.d.ts +0 -1
- package/lib/cjs/dom/fc.test.js +0 -23
- package/lib/cjs/dom/form/form.app.d.ts +0 -1
- package/lib/cjs/dom/form/form.app.js +0 -27
- package/lib/cjs/dom/form/form.d.ts +0 -26
- package/lib/cjs/dom/form/form.js +0 -49
- package/lib/cjs/dom/form/form.test.d.ts +0 -0
- package/lib/cjs/dom/form/form.test.js +0 -1
- package/lib/cjs/dom/html.d.ts +0 -113
- package/lib/cjs/dom/html.js +0 -119
- package/lib/cjs/dom/html.test.d.ts +0 -1
- package/lib/cjs/dom/html.test.js +0 -60
- package/lib/cjs/dom/observable.d.ts +0 -2
- package/lib/cjs/dom/observable.js +0 -10
- package/lib/cjs/dom/observable.test.d.ts +0 -1
- package/lib/cjs/dom/observable.test.js +0 -35
- package/lib/cjs/dom/provide.d.ts +0 -3
- package/lib/cjs/dom/provide.js +0 -12
- package/lib/cjs/dom/router/link.d.ts +0 -6
- package/lib/cjs/dom/router/link.js +0 -7
- package/lib/cjs/dom/router/router.d.ts +0 -13
- package/lib/cjs/dom/router/router.js +0 -55
- package/lib/cjs/dom/svg.d.ts +0 -64
- package/lib/cjs/dom/svg.js +0 -69
- package/lib/cjs/dom/test.d.ts +0 -1
- package/lib/cjs/dom/test.js +0 -13
- package/lib/cjs/dom/types/css.d.ts +0 -6612
- package/lib/cjs/dom/types/css.js +0 -24
- package/lib/cjs/dom/types/dom.d.ts +0 -0
- package/lib/cjs/dom/types/dom.js +0 -1
- package/lib/cjs/dom/types/html.d.ts +0 -616
- package/lib/cjs/dom/types/html.js +0 -2
- package/lib/cjs/dom/xml.d.ts +0 -1
- package/lib/cjs/dom/xml.js +0 -8
- package/lib/cjs/equal.d.ts +0 -8
- package/lib/cjs/equal.js +0 -48
- package/lib/cjs/equal.test.d.ts +0 -1
- package/lib/cjs/equal.test.js +0 -22
- package/lib/cjs/flags.d.ts +0 -7
- package/lib/cjs/flags.js +0 -52
- package/lib/cjs/flags.test.d.ts +0 -1
- package/lib/cjs/flags.test.js +0 -37
- package/lib/cjs/fs.d.ts +0 -72
- package/lib/cjs/fs.js +0 -235
- package/lib/cjs/fs.test.d.ts +0 -1
- package/lib/cjs/fs.test.js +0 -86
- package/lib/cjs/fs_node.d.ts +0 -15
- package/lib/cjs/fs_node.js +0 -50
- package/lib/cjs/fs_win.test.d.ts +0 -1
- package/lib/cjs/fs_win.test.js +0 -10
- package/lib/cjs/generator.d.ts +0 -1
- package/lib/cjs/generator.js +0 -14
- package/lib/cjs/generator.test.d.ts +0 -1
- package/lib/cjs/generator.test.js +0 -26
- package/lib/cjs/is_browser.d.ts +0 -1
- package/lib/cjs/is_browser.js +0 -4
- package/lib/cjs/loader-register.d.mts +0 -1
- package/lib/cjs/loader-register.d.ts +0 -1
- package/lib/cjs/loader-register.js +0 -4
- package/lib/cjs/loader-register.mjs +0 -4
- package/lib/cjs/loader.d.mts +0 -23
- package/lib/cjs/loader.mjs +0 -41
- package/lib/cjs/lock.d.ts +0 -1
- package/lib/cjs/lock.js +0 -27
- package/lib/cjs/lock.test.d.ts +0 -1
- package/lib/cjs/lock.test.js +0 -18
- package/lib/cjs/log.d.ts +0 -56
- package/lib/cjs/log.js +0 -103
- package/lib/cjs/observable/event.d.ts +0 -35
- package/lib/cjs/observable/event.js +0 -61
- package/lib/cjs/observable/observable.d.ts +0 -132
- package/lib/cjs/observable/observable.js +0 -363
- package/lib/cjs/observable/observable.test.d.ts +0 -1
- package/lib/cjs/observable/observable.test.js +0 -65
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/range.d.ts +0 -1
- package/lib/cjs/range.js +0 -11
- package/lib/cjs/result.d.ts +0 -31
- package/lib/cjs/result.js +0 -80
- package/lib/cjs/result.test.d.ts +0 -1
- package/lib/cjs/result.test.js +0 -78
- package/lib/cjs/safe.d.ts +0 -1
- package/lib/cjs/safe.js +0 -14
- package/lib/cjs/scope/describe.d.ts +0 -18
- package/lib/cjs/scope/describe.js +0 -73
- package/lib/cjs/scope/display/console.d.ts +0 -2
- package/lib/cjs/scope/display/console.js +0 -25
- package/lib/cjs/scope/display/dom.d.ts +0 -3
- package/lib/cjs/scope/display/dom.js +0 -30
- package/lib/cjs/scope/display/junit.d.ts +0 -2
- package/lib/cjs/scope/display/junit.js +0 -21
- package/lib/cjs/scope/execute.d.ts +0 -12
- package/lib/cjs/scope/execute.js +0 -91
- package/lib/cjs/scope/expect.d.ts +0 -23
- package/lib/cjs/scope/expect.js +0 -110
- package/lib/cjs/scope/fix.d.ts +0 -4
- package/lib/cjs/scope/fix.js +0 -26
- package/lib/cjs/scope/index.d.ts +0 -3
- package/lib/cjs/scope/index.js +0 -15
- package/lib/cjs/scope/scope.d.ts +0 -17
- package/lib/cjs/scope/scope.js +0 -2
- package/lib/cjs/scope/state.d.ts +0 -2
- package/lib/cjs/scope/state.js +0 -12
- package/lib/cjs/server/http/apps.d.ts +0 -5
- package/lib/cjs/server/http/apps.js +0 -27
- package/lib/cjs/server/http/css.d.ts +0 -5
- package/lib/cjs/server/http/css.js +0 -54
- package/lib/cjs/server/http/index.d.ts +0 -21
- package/lib/cjs/server/http/index.js +0 -77
- package/lib/cjs/server/http/response.d.ts +0 -4
- package/lib/cjs/server/http/response.js +0 -45
- package/lib/cjs/server/http/sitemap.d.ts +0 -2
- package/lib/cjs/server/http/sitemap.js +0 -46
- package/lib/cjs/server/http/static.d.ts +0 -2
- package/lib/cjs/server/http/static.js +0 -25
- package/lib/cjs/server/http/typescript.d.ts +0 -5
- package/lib/cjs/server/http/typescript.js +0 -44
- package/lib/cjs/server/main.d.ts +0 -2
- package/lib/cjs/server/main.js +0 -14
- package/lib/cjs/test.d.mts +0 -2
- package/lib/cjs/test.mjs +0 -28
- package/lib/cjs/test_all.d.ts +0 -9
- package/lib/cjs/test_all.js +0 -30
- package/lib/cjs/transpile.d.mts +0 -3
- package/lib/cjs/transpile.mjs +0 -22
- package/lib/cjs/tsconfig.tsbuildinfo +0 -1
- package/lib/esm/assert.d.ts +0 -26
- package/lib/esm/assert.js +0 -38
- package/lib/esm/awaitable.d.ts +0 -1
- package/lib/esm/awaitable.js +0 -1
- package/lib/esm/case.d.ts +0 -1
- package/lib/esm/case.js +0 -5
- package/lib/esm/components/button_bar.d.ts +0 -8
- package/lib/esm/components/button_bar.js +0 -27
- package/lib/esm/components/inline_edit.d.ts +0 -12
- package/lib/esm/components/inline_edit.js +0 -48
- package/lib/esm/components/logger.d.ts +0 -6
- package/lib/esm/components/logger.js +0 -22
- package/lib/esm/components/select.d.ts +0 -10
- package/lib/esm/components/select.js +0 -3
- package/lib/esm/components/test.d.ts +0 -1
- package/lib/esm/components/test.js +0 -3
- package/lib/esm/components/virtual_scroll.d.ts +0 -40
- package/lib/esm/components/virtual_scroll.js +0 -94
- package/lib/esm/components/virtual_scroll.test.d.ts +0 -1
- package/lib/esm/components/virtual_scroll.test.js +0 -20
- package/lib/esm/context.d.ts +0 -15
- package/lib/esm/context.js +0 -43
- package/lib/esm/context.test.d.ts +0 -1
- package/lib/esm/context.test.js +0 -46
- package/lib/esm/debounce.d.ts +0 -2
- package/lib/esm/debounce.js +0 -8
- package/lib/esm/diff.d.ts +0 -15
- package/lib/esm/diff.js +0 -54
- package/lib/esm/diff.test.d.ts +0 -1
- package/lib/esm/diff.test.js +0 -39
- package/lib/esm/display.d.ts +0 -5
- package/lib/esm/display.js +0 -11
- package/lib/esm/dom/css/border.d.ts +0 -11
- package/lib/esm/dom/css/border.js +0 -27
- package/lib/esm/dom/css/constants.d.ts +0 -31
- package/lib/esm/dom/css/constants.js +0 -28
- package/lib/esm/dom/css/core.d.ts +0 -5
- package/lib/esm/dom/css/core.js +0 -24
- package/lib/esm/dom/css/fstyle.d.ts +0 -5
- package/lib/esm/dom/css/fstyle.js +0 -32
- package/lib/esm/dom/css/sizing.d.ts +0 -5
- package/lib/esm/dom/css/sizing.js +0 -10
- package/lib/esm/dom/dom.d.ts +0 -27
- package/lib/esm/dom/dom.js +0 -104
- package/lib/esm/dom/fc.d.ts +0 -14
- package/lib/esm/dom/fc.js +0 -35
- package/lib/esm/dom/fc.test.d.ts +0 -1
- package/lib/esm/dom/fc.test.js +0 -21
- package/lib/esm/dom/form/form.app.d.ts +0 -1
- package/lib/esm/dom/form/form.app.js +0 -23
- package/lib/esm/dom/form/form.d.ts +0 -26
- package/lib/esm/dom/form/form.js +0 -34
- package/lib/esm/dom/form/form.test.d.ts +0 -0
- package/lib/esm/dom/form/form.test.js +0 -1
- package/lib/esm/dom/html.d.ts +0 -113
- package/lib/esm/dom/html.js +0 -114
- package/lib/esm/dom/html.test.d.ts +0 -1
- package/lib/esm/dom/html.test.js +0 -58
- package/lib/esm/dom/observable.d.ts +0 -2
- package/lib/esm/dom/observable.js +0 -6
- package/lib/esm/dom/observable.test.d.ts +0 -1
- package/lib/esm/dom/observable.test.js +0 -33
- package/lib/esm/dom/provide.d.ts +0 -3
- package/lib/esm/dom/provide.js +0 -7
- package/lib/esm/dom/router/link.d.ts +0 -6
- package/lib/esm/dom/router/link.js +0 -3
- package/lib/esm/dom/router/router.d.ts +0 -13
- package/lib/esm/dom/router/router.js +0 -52
- package/lib/esm/dom/svg.d.ts +0 -64
- package/lib/esm/dom/svg.js +0 -65
- package/lib/esm/dom/test.d.ts +0 -1
- package/lib/esm/dom/test.js +0 -9
- package/lib/esm/dom/types/css.d.ts +0 -6612
- package/lib/esm/dom/types/css.js +0 -23
- package/lib/esm/dom/types/dom.d.ts +0 -0
- package/lib/esm/dom/types/dom.js +0 -1
- package/lib/esm/dom/types/html.d.ts +0 -616
- package/lib/esm/dom/types/html.js +0 -1
- package/lib/esm/dom/xml.d.ts +0 -1
- package/lib/esm/dom/xml.js +0 -4
- package/lib/esm/equal.d.ts +0 -8
- package/lib/esm/equal.js +0 -41
- package/lib/esm/equal.test.d.ts +0 -1
- package/lib/esm/equal.test.js +0 -20
- package/lib/esm/flags.d.ts +0 -7
- package/lib/esm/flags.js +0 -48
- package/lib/esm/flags.test.d.ts +0 -1
- package/lib/esm/flags.test.js +0 -35
- package/lib/esm/fs.d.ts +0 -72
- package/lib/esm/fs.js +0 -226
- package/lib/esm/fs.test.d.ts +0 -1
- package/lib/esm/fs.test.js +0 -84
- package/lib/esm/fs_node.d.ts +0 -15
- package/lib/esm/fs_node.js +0 -45
- package/lib/esm/fs_win.test.d.ts +0 -1
- package/lib/esm/fs_win.test.js +0 -8
- package/lib/esm/generator.d.ts +0 -1
- package/lib/esm/generator.js +0 -10
- package/lib/esm/generator.test.d.ts +0 -1
- package/lib/esm/generator.test.js +0 -24
- package/lib/esm/is_browser.d.ts +0 -1
- package/lib/esm/is_browser.js +0 -1
- package/lib/esm/loader-register.d.mts +0 -1
- package/lib/esm/loader-register.mjs +0 -2
- package/lib/esm/loader.d.mts +0 -23
- package/lib/esm/loader.mjs +0 -36
- package/lib/esm/lock.d.ts +0 -1
- package/lib/esm/lock.js +0 -23
- package/lib/esm/lock.test.d.ts +0 -1
- package/lib/esm/lock.test.js +0 -16
- package/lib/esm/log.d.ts +0 -56
- package/lib/esm/log.js +0 -93
- package/lib/esm/observable/event.d.ts +0 -35
- package/lib/esm/observable/event.js +0 -46
- package/lib/esm/observable/observable.d.ts +0 -132
- package/lib/esm/observable/observable.js +0 -343
- package/lib/esm/observable/observable.test.d.ts +0 -1
- package/lib/esm/observable/observable.test.js +0 -63
- package/lib/esm/range.d.ts +0 -1
- package/lib/esm/range.js +0 -7
- package/lib/esm/result.d.ts +0 -31
- package/lib/esm/result.js +0 -65
- package/lib/esm/result.test.d.ts +0 -1
- package/lib/esm/result.test.js +0 -76
- package/lib/esm/safe.d.ts +0 -1
- package/lib/esm/safe.js +0 -10
- package/lib/esm/scope/describe.d.ts +0 -18
- package/lib/esm/scope/describe.js +0 -60
- package/lib/esm/scope/display/console.d.ts +0 -2
- package/lib/esm/scope/display/console.js +0 -21
- package/lib/esm/scope/display/dom.d.ts +0 -3
- package/lib/esm/scope/display/dom.js +0 -26
- package/lib/esm/scope/display/junit.d.ts +0 -2
- package/lib/esm/scope/display/junit.js +0 -17
- package/lib/esm/scope/execute.d.ts +0 -12
- package/lib/esm/scope/execute.js +0 -85
- package/lib/esm/scope/expect.d.ts +0 -23
- package/lib/esm/scope/expect.js +0 -104
- package/lib/esm/scope/fix.d.ts +0 -4
- package/lib/esm/scope/fix.js +0 -22
- package/lib/esm/scope/index.d.ts +0 -3
- package/lib/esm/scope/index.js +0 -3
- package/lib/esm/scope/scope.d.ts +0 -17
- package/lib/esm/scope/scope.js +0 -1
- package/lib/esm/scope/state.d.ts +0 -2
- package/lib/esm/scope/state.js +0 -8
- package/lib/esm/server/http/apps.d.ts +0 -5
- package/lib/esm/server/http/apps.js +0 -23
- package/lib/esm/server/http/css.d.ts +0 -5
- package/lib/esm/server/http/css.js +0 -50
- package/lib/esm/server/http/index.d.ts +0 -21
- package/lib/esm/server/http/index.js +0 -73
- package/lib/esm/server/http/response.d.ts +0 -4
- package/lib/esm/server/http/response.js +0 -40
- package/lib/esm/server/http/sitemap.d.ts +0 -2
- package/lib/esm/server/http/sitemap.js +0 -42
- package/lib/esm/server/http/static.d.ts +0 -2
- package/lib/esm/server/http/static.js +0 -21
- package/lib/esm/server/http/typescript.d.ts +0 -5
- package/lib/esm/server/http/typescript.js +0 -40
- package/lib/esm/server/main.d.ts +0 -2
- package/lib/esm/server/main.js +0 -12
- package/lib/esm/test.d.mts +0 -2
- package/lib/esm/test.mjs +0 -26
- package/lib/esm/test_all.d.ts +0 -9
- package/lib/esm/test_all.js +0 -28
- package/lib/esm/transpile.d.mts +0 -3
- package/lib/esm/transpile.mjs +0 -18
- package/lib/esm/tsconfig.tsbuildinfo +0 -1
- package/src/components/test.js +0 -3
- package/src/loader-register.mjs +0 -3
- package/src/loader.mjs +0 -46
package/src/dom/css/border.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Properties } from "../types/css.
|
|
2
|
-
import { Side, Size } from "./constants.
|
|
3
|
-
import {
|
|
1
|
+
import type { Properties } from "../types/css.ts";
|
|
2
|
+
import type { Side, Size } from "./constants.ts";
|
|
3
|
+
import { getSide, getSize, isSide } from "./core.ts";
|
|
4
4
|
|
|
5
5
|
export function rounded(size: Size = "", side: Side = "") {
|
|
6
6
|
if (isSide(size)) {
|
|
@@ -12,7 +12,7 @@ export function rounded(size: Size = "", side: Side = "") {
|
|
|
12
12
|
if (curr === "") {
|
|
13
13
|
prev.borderRadius = sized;
|
|
14
14
|
} else {
|
|
15
|
-
// @ts-
|
|
15
|
+
// @ts-expect-error
|
|
16
16
|
prev[`border${curr}Radius`] = sized;
|
|
17
17
|
}
|
|
18
18
|
return prev;
|
|
@@ -20,11 +20,11 @@ export function rounded(size: Size = "", side: Side = "") {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function border({
|
|
23
|
-
side = "",
|
|
24
|
-
style = "solid",
|
|
25
|
-
radius = "",
|
|
26
|
-
width = 1,
|
|
27
|
-
color = "black",
|
|
23
|
+
side: _side = "",
|
|
24
|
+
style: _style = "solid",
|
|
25
|
+
radius: _radius = "",
|
|
26
|
+
width: _width = 1,
|
|
27
|
+
color: _color = "black",
|
|
28
28
|
}: {
|
|
29
29
|
side?: Side;
|
|
30
30
|
style?: "solid" | "dotted" | "dashed" | "double" | "none";
|
|
@@ -37,8 +37,8 @@ export function border({
|
|
|
37
37
|
|
|
38
38
|
export function inset(
|
|
39
39
|
width: 0 | 1 | 2 | 4 | 8,
|
|
40
|
-
color1
|
|
41
|
-
color2
|
|
40
|
+
color1 = "gray",
|
|
41
|
+
color2 = "lightgray",
|
|
42
42
|
) {
|
|
43
43
|
return {
|
|
44
44
|
...border({ side: "tl", width, color: color1, radius: "none" }),
|
package/src/dom/css/core.ts
CHANGED
package/src/dom/css/fstyle.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dashCase } from "../../case.
|
|
2
|
-
import { Properties } from "../types/css.
|
|
1
|
+
import { dashCase } from "../../case.ts";
|
|
2
|
+
import type { Properties } from "../types/css.ts";
|
|
3
3
|
|
|
4
4
|
export type FStyle =
|
|
5
5
|
| Properties
|
|
@@ -12,7 +12,7 @@ export function compileFStyle(fstyle: FStyle, prefix = ""): string {
|
|
|
12
12
|
const rules: { key: string; value: FStyle }[] = [];
|
|
13
13
|
|
|
14
14
|
for (const [key, value] of Object.entries(fstyle)) {
|
|
15
|
-
if (typeof value
|
|
15
|
+
if (typeof value === "string") {
|
|
16
16
|
properties.push({ key, value });
|
|
17
17
|
} else {
|
|
18
18
|
rules.push({ key, value });
|
|
@@ -33,7 +33,7 @@ export function compileFStyle(fstyle: FStyle, prefix = ""): string {
|
|
|
33
33
|
if (key.startsWith("@media")) {
|
|
34
34
|
rule += `${key} {\n`;
|
|
35
35
|
rule += compileFStyle(value, " ");
|
|
36
|
-
rule +=
|
|
36
|
+
rule += "}\n\n";
|
|
37
37
|
} else {
|
|
38
38
|
rule += compileFStyle(value, `${prefix} ${key}`);
|
|
39
39
|
}
|
package/src/dom/css/sizing.ts
CHANGED
package/src/dom/dom.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assertExists } from "../assert.ts";
|
|
2
|
+
import type { Properties as SVGProperties } from "./types/css.ts";
|
|
3
|
+
|
|
4
|
+
export const XHTML_NAMESPACE_URI = "http://www.w3.org/1999/xhtml";
|
|
5
|
+
export const SVG_NAMESPACE_URI = "http://www.w3.org/2000/svg";
|
|
2
6
|
|
|
3
7
|
const Events = Symbol("events");
|
|
4
8
|
export const CLEAR = Symbol("Clear children");
|
|
@@ -10,18 +14,20 @@ export type DOMElement = Element & ElementCSSInlineStyle;
|
|
|
10
14
|
|
|
11
15
|
export type DomAttrs = {
|
|
12
16
|
class: string | string[];
|
|
13
|
-
style: Partial<
|
|
17
|
+
style: Partial<SVGProperties> | string;
|
|
14
18
|
role: "button" | "list" | "listbox";
|
|
15
19
|
events: Partial<{
|
|
16
20
|
[K in keyof HTMLElementEventMap]: EventHandler | null;
|
|
17
21
|
}>;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
export type Attrs<E extends Omit<Element, "update">, S =
|
|
21
|
-
Omit<E, "style"
|
|
24
|
+
export type Attrs<E extends Omit<Element, "update">, S = object> = Partial<
|
|
25
|
+
Omit<{ [k in keyof E]: string | number | boolean }, "style" | "toString"> &
|
|
26
|
+
S &
|
|
27
|
+
DomAttrs
|
|
22
28
|
>;
|
|
23
29
|
|
|
24
|
-
export type DenormAttrs<E extends Omit<Element, "update">, S =
|
|
30
|
+
export type DenormAttrs<E extends Omit<Element, "update">, S = object> =
|
|
25
31
|
| Attrs<E, S>
|
|
26
32
|
| DenormChildren;
|
|
27
33
|
|
|
@@ -79,57 +85,63 @@ export function update(
|
|
|
79
85
|
children: DenormChildren[]
|
|
80
86
|
): Element {
|
|
81
87
|
// Track events, to remove later
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
element.addEventListener(k as keyof ElementEventMap, v);
|
|
94
|
-
$events.set(k, v);
|
|
88
|
+
element[Events] ??= new Map<string, EventHandler>();
|
|
89
|
+
const $events = element[Events];
|
|
90
|
+
// const { style = {}, events = {}, ...rest } = attrs;
|
|
91
|
+
|
|
92
|
+
for (const [k, v] of Object.entries(
|
|
93
|
+
(attrs.events as NonNullable<typeof attrs.events>) ?? {}
|
|
94
|
+
)) {
|
|
95
|
+
if (v === null) {
|
|
96
|
+
if ($events.has(k)) {
|
|
97
|
+
const listener = assertExists($events.get(k));
|
|
98
|
+
element.removeEventListener(k, listener);
|
|
95
99
|
}
|
|
100
|
+
} else if (v !== undefined) {
|
|
101
|
+
element.addEventListener(k as keyof ElementEventMap, v);
|
|
102
|
+
$events.set(k, v);
|
|
96
103
|
}
|
|
97
|
-
|
|
104
|
+
}
|
|
98
105
|
|
|
99
106
|
const _style = (element as { style?: Partial<CSSStyleDeclaration> }).style;
|
|
100
107
|
if (_style) {
|
|
101
|
-
if (typeof style === "string") {
|
|
102
|
-
_style.cssText = style;
|
|
108
|
+
if (typeof attrs.style === "string") {
|
|
109
|
+
_style.cssText = attrs.style;
|
|
103
110
|
} else {
|
|
104
|
-
|
|
105
|
-
(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
for (const [k, v] of Object.entries(
|
|
112
|
+
(attrs.style as Partial<CSSStyleDeclaration>) ?? {}
|
|
113
|
+
)) {
|
|
114
|
+
// @ts-expect-error Object.entries is unable to statically look into args
|
|
115
|
+
_style[k] = v;
|
|
116
|
+
}
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
119
|
|
|
113
|
-
|
|
120
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
121
|
+
if (k === "style") {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (k === "events") {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
|
|
114
129
|
if (k === "class") {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
element.classList.add(c);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return;
|
|
130
|
+
const cs = Array.isArray(v) ? v : String(v).split(/\s+/m).filter(Boolean);
|
|
131
|
+
for (const c of cs) {
|
|
132
|
+
if (c.startsWith("!")) {
|
|
133
|
+
element.classList.remove(c.substring(1));
|
|
134
|
+
} else {
|
|
135
|
+
element.classList.add(c);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
continue;
|
|
128
139
|
}
|
|
129
140
|
|
|
130
|
-
const useNamespace =
|
|
131
|
-
|
|
132
|
-
element.namespaceURI
|
|
141
|
+
const useNamespace = false;
|
|
142
|
+
element.namespaceURI &&
|
|
143
|
+
element.namespaceURI !== XHTML_NAMESPACE_URI &&
|
|
144
|
+
element.namespaceURI !== SVG_NAMESPACE_URI;
|
|
133
145
|
const remove = !v;
|
|
134
146
|
|
|
135
147
|
if (useNamespace) {
|
|
@@ -138,7 +150,7 @@ export function update(
|
|
|
138
150
|
} else if (v === true) {
|
|
139
151
|
element.setAttributeNS(element.namespaceURI, k, k);
|
|
140
152
|
} else {
|
|
141
|
-
element.setAttributeNS(element.namespaceURI, k, v
|
|
153
|
+
element.setAttributeNS(element.namespaceURI, k, String(v));
|
|
142
154
|
}
|
|
143
155
|
} else {
|
|
144
156
|
if (remove) {
|
|
@@ -146,10 +158,10 @@ export function update(
|
|
|
146
158
|
} else if (v === true) {
|
|
147
159
|
element.setAttribute(k, k);
|
|
148
160
|
} else {
|
|
149
|
-
element.setAttribute(k, v
|
|
161
|
+
element.setAttribute(k, String(v));
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
|
-
}
|
|
164
|
+
}
|
|
153
165
|
|
|
154
166
|
if (children?.length > 0) {
|
|
155
167
|
element.replaceChildren(
|
package/src/dom/fc.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { describe, expect, it } from "../scope/index.ts";
|
|
2
|
+
import { FC } from "./fc.ts";
|
|
3
|
+
import { button, div, form, input, label, small } from "./html.ts";
|
|
4
4
|
|
|
5
5
|
describe("FC", () => {
|
|
6
6
|
it("creates FCs", () => {
|
|
@@ -9,8 +9,8 @@ describe("FC", () => {
|
|
|
9
9
|
name: string;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
type?: string;
|
|
12
|
-
}>("fc-input", (
|
|
13
|
-
label(attrs.placeholder ?? attrs.name, input(attrs), ...children)
|
|
12
|
+
}>("fc-input", (_el, attrs, children) =>
|
|
13
|
+
label(attrs.placeholder ?? attrs.name, input(attrs), ...children),
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
const f = form(
|
|
@@ -26,13 +26,13 @@ describe("FC", () => {
|
|
|
26
26
|
name: "lastName",
|
|
27
27
|
placeholder: "Last Name",
|
|
28
28
|
required: true,
|
|
29
|
-
})
|
|
29
|
+
}),
|
|
30
30
|
),
|
|
31
31
|
Input(
|
|
32
32
|
{ name: "email", type: "email", placeholder: "E-Mail" },
|
|
33
|
-
small("We'll never share your information.")
|
|
33
|
+
small("We'll never share your information."),
|
|
34
34
|
),
|
|
35
|
-
button({ type: "submit" }, "Submit")
|
|
35
|
+
button({ type: "submit" }, "Submit"),
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
// document.body.appendChild(f);
|
package/src/dom/fc.ts
CHANGED
|
@@ -1,59 +1,56 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CLEAR,
|
|
3
|
-
DenormChildren,
|
|
4
|
-
DomAttrs,
|
|
3
|
+
type DenormChildren,
|
|
4
|
+
type DomAttrs,
|
|
5
5
|
normalizeArguments,
|
|
6
6
|
update,
|
|
7
|
-
} from "./dom.
|
|
7
|
+
} from "./dom.ts";
|
|
8
8
|
|
|
9
9
|
export type Attrs<S> = S & Partial<DomAttrs>;
|
|
10
10
|
|
|
11
11
|
export const State = Symbol();
|
|
12
|
-
export interface FCComponent<
|
|
12
|
+
export interface FCComponent<Props extends object, State extends object>
|
|
13
13
|
extends Element {
|
|
14
|
-
[State]?: Partial<
|
|
14
|
+
[State]?: Partial<State>;
|
|
15
15
|
update(
|
|
16
|
-
attrs?: Partial<Attrs<
|
|
16
|
+
attrs?: Partial<Attrs<Props> & DomAttrs> | DenormChildren,
|
|
17
17
|
...children: DenormChildren[]
|
|
18
18
|
): this;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
export type RenderFn<Props extends object, State extends object> = (
|
|
21
|
+
el: FCComponent<Props, State>,
|
|
22
|
+
attrs: Attrs<Props>,
|
|
23
|
+
children: DenormChildren[],
|
|
24
|
+
) => Element | Element[];
|
|
25
25
|
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
): FCComponent<P, S>;
|
|
31
|
-
}
|
|
26
|
+
export type FCComponentCtor<Props extends object, State extends object> = (
|
|
27
|
+
attrs?: Attrs<Props> | DenormChildren,
|
|
28
|
+
...children: DenormChildren[]
|
|
29
|
+
) => FCComponent<Props, State>;
|
|
32
30
|
|
|
33
|
-
export function FC<
|
|
31
|
+
export function FC<Props extends object, State extends object = object>(
|
|
34
32
|
name: string,
|
|
35
|
-
component: RenderFn<
|
|
36
|
-
): FCComponentCtor<
|
|
37
|
-
class FCImpl extends HTMLElement implements FCComponent<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
[State]: Partial<S> = {};
|
|
43
|
-
#attrs: Attrs<P> = {} as Attrs<P>;
|
|
33
|
+
component: RenderFn<Props, State>,
|
|
34
|
+
): FCComponentCtor<Props, State> {
|
|
35
|
+
class FCImpl extends HTMLElement implements FCComponent<Props, State> {
|
|
36
|
+
[State]: Partial<State> = {};
|
|
37
|
+
#attrs: Attrs<Props> = {} as Attrs<Props>;
|
|
44
38
|
#children: DenormChildren[] = [];
|
|
45
39
|
|
|
46
|
-
update(
|
|
40
|
+
update(
|
|
41
|
+
attrs?: Attrs<Props> | DenormChildren,
|
|
42
|
+
...children: DenormChildren[]
|
|
43
|
+
) {
|
|
47
44
|
[attrs, children] = normalizeArguments(attrs, children) as [
|
|
48
|
-
Attrs<
|
|
49
|
-
DenormChildren[]
|
|
45
|
+
Attrs<Props>,
|
|
46
|
+
DenormChildren[],
|
|
50
47
|
];
|
|
51
48
|
if (children[0] === CLEAR) {
|
|
52
49
|
this.#children = [];
|
|
53
50
|
} else if (children.length > 0) {
|
|
54
51
|
this.#children = children;
|
|
55
52
|
}
|
|
56
|
-
this.#attrs = { ...this.#attrs, ...(attrs as Attrs<
|
|
53
|
+
this.#attrs = { ...this.#attrs, ...(attrs as Attrs<Props>) };
|
|
57
54
|
|
|
58
55
|
// Apply updates from the attrs to the dom node itself
|
|
59
56
|
update(this, this.#attrs, []);
|
|
@@ -67,11 +64,11 @@ export function FC<P extends object, S extends object = {}>(
|
|
|
67
64
|
|
|
68
65
|
customElements.define(name, FCImpl);
|
|
69
66
|
|
|
70
|
-
const ctor: FCComponentCtor<
|
|
71
|
-
attrs?: Attrs<
|
|
67
|
+
const ctor: FCComponentCtor<Props, State> = (
|
|
68
|
+
attrs?: Attrs<Props> | DenormChildren,
|
|
72
69
|
...children: DenormChildren[]
|
|
73
|
-
): FCComponent<
|
|
74
|
-
const element = document.createElement(name) as FCComponent<
|
|
70
|
+
): FCComponent<Props, State> => {
|
|
71
|
+
const element = document.createElement(name) as FCComponent<Props, State>;
|
|
75
72
|
element.update(attrs, ...children);
|
|
76
73
|
return element;
|
|
77
74
|
};
|
package/src/dom/form/form.app.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { article, button, div, main, small } from "../html.
|
|
2
|
-
import { Form, Input } from "./form.
|
|
1
|
+
import { article, button, div, main, small } from "../html.ts";
|
|
2
|
+
import { Form, Input } from "./form.ts";
|
|
3
3
|
|
|
4
4
|
export const App = () =>
|
|
5
5
|
main(
|
|
@@ -10,7 +10,7 @@ export const App = () =>
|
|
|
10
10
|
events: {
|
|
11
11
|
submit(event) {
|
|
12
12
|
console.log(
|
|
13
|
-
"Should see fields for firstname, lastname, email, etc"
|
|
13
|
+
"Should see fields for firstname, lastname, email, etc",
|
|
14
14
|
);
|
|
15
15
|
console.log(event);
|
|
16
16
|
},
|
|
@@ -19,7 +19,7 @@ export const App = () =>
|
|
|
19
19
|
div(
|
|
20
20
|
{ class: "grid" },
|
|
21
21
|
Input({ id: "firstname", placeholder: "First name" }),
|
|
22
|
-
Input({ id: "lastname", placeholder: "Last name" })
|
|
22
|
+
Input({ id: "lastname", placeholder: "Last name" }),
|
|
23
23
|
),
|
|
24
24
|
Input(
|
|
25
25
|
{
|
|
@@ -28,7 +28,7 @@ export const App = () =>
|
|
|
28
28
|
placeholder: "Email address",
|
|
29
29
|
required: true,
|
|
30
30
|
},
|
|
31
|
-
small("We will never share your email with anyone.")
|
|
31
|
+
small("We will never share your email with anyone."),
|
|
32
32
|
),
|
|
33
33
|
button({ type: "submit" }, "Submit"),
|
|
34
34
|
div(
|
|
@@ -40,11 +40,11 @@ export const App = () =>
|
|
|
40
40
|
"aria-invalid": "true",
|
|
41
41
|
}),
|
|
42
42
|
Input({ id: "disabled", placeholder: "Disabled", disabled: true }),
|
|
43
|
-
Input({ id: "readonly", value: "Readonly", readOnly: true })
|
|
44
|
-
)
|
|
43
|
+
Input({ id: "readonly", value: "Readonly", readOnly: true }),
|
|
44
|
+
),
|
|
45
45
|
// Dropdown({id: 'fruit', label: "Fruit", placeholder: "Select a fruit...", options: ['Banana', 'Watermelon', 'Apple', 'Orange', 'Mango']}),
|
|
46
46
|
// Radios({legend: 'Size', options: {small: 'Small', medium: 'Medium', large: 'Large', extralarge: "Extra Large"}, checked: 'small'}),
|
|
47
47
|
// Checkboxes({options: {terms: 'I agree to the Terms and Conditions', termsSharing: {label: 'I agree to share my information with partners', disabled: true, checked: true}}),
|
|
48
|
-
)
|
|
49
|
-
)
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
50
|
);
|
package/src/dom/form/form.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Attrs, DenormChildren } from "../dom.
|
|
2
|
-
import { form, input, label, option, select } from "../html.
|
|
3
|
-
import {
|
|
1
|
+
import type { Attrs, DenormChildren } from "../dom.ts";
|
|
2
|
+
import { form, input, label, option, select } from "../html.ts";
|
|
3
|
+
import type {
|
|
4
4
|
FormAttributes,
|
|
5
5
|
InputAttributes,
|
|
6
6
|
LabelAttributes,
|
|
7
7
|
OptionAttributes,
|
|
8
8
|
SelectAttributes,
|
|
9
|
-
} from "../types/html"
|
|
9
|
+
} from "../types/html";
|
|
10
10
|
|
|
11
11
|
export const Form = (attrs: FormAttributes, ...children: DenormChildren[]) => {
|
|
12
12
|
if (attrs.events?.submit) {
|
|
@@ -19,18 +19,24 @@ export const Form = (attrs: FormAttributes, ...children: DenormChildren[]) => {
|
|
|
19
19
|
return form(attrs as Attrs<HTMLFormElement>, ...children);
|
|
20
20
|
};
|
|
21
21
|
export const Input = (attrs: InputAttributes, ...children: DenormChildren[]) =>
|
|
22
|
-
label(
|
|
22
|
+
label(
|
|
23
|
+
input(
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
attrs as Attrs<HTMLInputElement>,
|
|
26
|
+
),
|
|
27
|
+
...children,
|
|
28
|
+
);
|
|
23
29
|
|
|
24
30
|
export const Select = (
|
|
25
|
-
attrs: { options: string[] |
|
|
26
|
-
LabelAttributes
|
|
31
|
+
attrs: { options: string[] | object; selected?: string } & SelectAttributes &
|
|
32
|
+
LabelAttributes,
|
|
27
33
|
) =>
|
|
28
34
|
label(
|
|
29
35
|
{ style: attrs.style ?? {} },
|
|
30
36
|
select(
|
|
31
37
|
{ events: attrs.events ?? {} },
|
|
32
|
-
...prepareOptions(attrs.options, attrs.selected).map(Option)
|
|
33
|
-
)
|
|
38
|
+
...prepareOptions(attrs.options as string[], attrs.selected).map(Option),
|
|
39
|
+
),
|
|
34
40
|
);
|
|
35
41
|
export const Button = () => {};
|
|
36
42
|
|
|
@@ -41,18 +47,18 @@ const prepareOptions = (
|
|
|
41
47
|
string,
|
|
42
48
|
string | { label: string; disabled?: boolean; selected?: boolean }
|
|
43
49
|
>,
|
|
44
|
-
selected?: string
|
|
50
|
+
selected?: string,
|
|
45
51
|
): Parameters<typeof Option>[0][] =>
|
|
46
52
|
Array.isArray(attrs)
|
|
47
53
|
? attrs.map((value) => ({
|
|
48
54
|
value,
|
|
49
55
|
label: value,
|
|
50
|
-
selected: selected
|
|
56
|
+
selected: selected === value,
|
|
51
57
|
}))
|
|
52
58
|
: Object.entries(attrs).map(([value, label]) =>
|
|
53
59
|
typeof label === "string"
|
|
54
60
|
? { value, label, selected: selected === value }
|
|
55
|
-
: { value, ...label }
|
|
61
|
+
: { value, ...label },
|
|
56
62
|
);
|
|
57
63
|
export const Option = (attrs: OptionAttributes) =>
|
|
58
64
|
option(attrs as Attrs<HTMLOptionElement>);
|
|
@@ -63,14 +69,14 @@ export const Dropdown = (
|
|
|
63
69
|
) =>
|
|
64
70
|
Select({
|
|
65
71
|
...attrs,
|
|
66
|
-
options: typeof options[0]
|
|
72
|
+
options: typeof options[0] === "string" ? options : options[0],
|
|
67
73
|
});
|
|
68
74
|
export const Radios = () => {};
|
|
69
75
|
export const Checks = () => {};
|
|
70
76
|
export const Switches = () => {};
|
|
71
77
|
|
|
72
|
-
export const Radio = (
|
|
78
|
+
export const Radio = (_attrs: Omit<InputAttributes, "type">) =>
|
|
73
79
|
Input({ type: "radio" });
|
|
74
|
-
export const Checkbox = (
|
|
80
|
+
export const Checkbox = (_attrs: Omit<InputAttributes, "type">) =>
|
|
75
81
|
Input({ type: "checkbox" });
|
|
76
82
|
export const Switch = () => Checkbox({ role: "switch" });
|
package/src/dom/form/index.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
2
|
+
<html lang="en-us">
|
|
3
3
|
<head>
|
|
4
4
|
<title>Jiffies Form</title>
|
|
5
5
|
<base href="/dom/form/" />
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<script type="module">
|
|
10
|
-
import {App} from './form.app.
|
|
10
|
+
import {App} from './form.app.ts';
|
|
11
|
+
|
|
11
12
|
document.body.appendChild(App());
|
|
12
13
|
</script>
|
|
13
14
|
</body>
|
package/src/dom/html.test.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { describe, it } from "../scope/describe.
|
|
2
|
-
import { expect } from "../scope/expect.
|
|
3
|
-
import { table, tbody, td, th, thead, tr
|
|
1
|
+
import { describe, it } from "../scope/describe.ts";
|
|
2
|
+
import { expect } from "../scope/expect.ts";
|
|
3
|
+
import { button, table, tbody, td, th, thead, tr } from "./html.ts";
|
|
4
4
|
|
|
5
5
|
describe("html", () => {
|
|
6
6
|
it("creates HTML Elements", () => {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
(tableBody = tbody())
|
|
11
|
-
);
|
|
7
|
+
const tableBody = tbody();
|
|
8
|
+
const tableHead = thead(tr(th("Col A"), th("Col B")));
|
|
9
|
+
const myTable = table(tableHead, tableBody);
|
|
12
10
|
for (let x = 1; x <= 3; x++) {
|
|
13
11
|
tableBody.appendChild(tr(td(`${x}`), td(`${x * 2}`)));
|
|
14
12
|
}
|
|
@@ -59,13 +57,17 @@ describe("html", () => {
|
|
|
59
57
|
const btn = button({
|
|
60
58
|
class: "test-class",
|
|
61
59
|
style: { flexDirection: "column" },
|
|
62
|
-
events: {
|
|
60
|
+
events: {
|
|
61
|
+
click: () => {
|
|
62
|
+
clicked = true;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
63
65
|
});
|
|
64
66
|
btn.dispatchEvent(new Event("click"));
|
|
65
67
|
|
|
66
68
|
expect(btn.classList.contains("test-class")).toBe(true);
|
|
67
69
|
expect((btn as unknown as HTMLButtonElement).style.flexDirection).toBe(
|
|
68
|
-
"column"
|
|
70
|
+
"column",
|
|
69
71
|
);
|
|
70
72
|
expect(clicked).toBe(true);
|
|
71
73
|
});
|
package/src/dom/html.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DenormAttrs, DenormChildren, up } from "./dom.
|
|
1
|
+
import { type DenormAttrs, type DenormChildren, up } from "./dom.ts";
|
|
2
2
|
|
|
3
3
|
const makeHTMLElement =
|
|
4
4
|
<K extends keyof HTMLElementTagNameMap>(name: K) =>
|
|
@@ -9,7 +9,7 @@ const makeHTMLElement =
|
|
|
9
9
|
up(
|
|
10
10
|
document.createElement(name),
|
|
11
11
|
attrs,
|
|
12
|
-
...children
|
|
12
|
+
...children,
|
|
13
13
|
) as HTMLElementTagNameMap[K];
|
|
14
14
|
|
|
15
15
|
export const a = makeHTMLElement("a");
|
|
@@ -85,7 +85,6 @@ export const optgroup = makeHTMLElement("optgroup");
|
|
|
85
85
|
export const option = makeHTMLElement("option");
|
|
86
86
|
export const output = makeHTMLElement("output");
|
|
87
87
|
export const p = makeHTMLElement("p");
|
|
88
|
-
export const param = makeHTMLElement("param");
|
|
89
88
|
export const picture = makeHTMLElement("picture");
|
|
90
89
|
export const pre = makeHTMLElement("pre");
|
|
91
90
|
export const progress = makeHTMLElement("progress");
|
package/src/dom/index.ts
ADDED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { div, span } from "./html.
|
|
6
|
-
import {
|
|
1
|
+
import { map, Subject } from "../observable/observable.ts";
|
|
2
|
+
import { describe, it } from "../scope/describe.ts";
|
|
3
|
+
import { expect } from "../scope/expect.ts";
|
|
4
|
+
import type { DOMUpdates } from "./dom.ts";
|
|
5
|
+
import { div, span } from "./html.ts";
|
|
6
|
+
import { O } from "./observable.ts";
|
|
7
7
|
|
|
8
8
|
describe("DOM Observable", () => {
|
|
9
9
|
it("updates a dom node with observable results", async () => {
|
package/src/dom/observable.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Observable } from "../observable/observable.
|
|
1
|
+
import type { Observable } from "../observable/observable.ts";
|
|
2
2
|
|
|
3
3
|
export function O<E extends Element>(
|
|
4
4
|
element: E,
|
|
5
|
-
observable: Observable<Parameters<E["update"]
|
|
5
|
+
observable: Observable<Parameters<E["update"]>>,
|
|
6
6
|
): E {
|
|
7
7
|
observable.subscribe((t) => {
|
|
8
8
|
element.update(...t);
|
package/src/dom/provide.ts
CHANGED