godown 3.0.0-canary.8 → 3.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.
- package/README.md +38 -9
- package/alert.d.ts +1 -0
- package/alert.d.ts.map +1 -1
- package/alert.js +1 -5
- package/alert.js.map +1 -1
- package/avatar.d.ts +1 -0
- package/avatar.d.ts.map +1 -1
- package/avatar.js +1 -5
- package/avatar.js.map +1 -1
- package/badge.d.ts +9 -0
- package/badge.d.ts.map +1 -0
- package/badge.js +2 -0
- package/badge.js.map +1 -0
- package/breath.js +1 -5
- package/breath.js.map +1 -1
- package/build/godown+lit.iife.js +59 -0
- package/build/godown+lit.iife.js.map +1 -0
- package/build/godown+lit.js +59 -0
- package/build/godown+lit.js.map +1 -0
- package/build/godown+lit.umd.js +59 -0
- package/build/godown+lit.umd.js.map +1 -0
- package/build/godown.iife.js +47 -0
- package/build/godown.js +48 -0
- package/build/godown.js.map +1 -0
- package/build/godown.umd.js +48 -0
- package/build/godown.umd.js.map +1 -0
- package/button.d.ts +1 -0
- package/button.d.ts.map +1 -1
- package/button.js +1 -5
- package/button.js.map +1 -1
- package/card.d.ts +1 -0
- package/card.d.ts.map +1 -1
- package/card.js +1 -5
- package/card.js.map +1 -1
- package/carousel.d.ts +1 -0
- package/carousel.d.ts.map +1 -1
- package/carousel.js +1 -5
- package/carousel.js.map +1 -1
- package/components/alert.d.ts +4 -1
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +1 -176
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts +8 -2
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +1 -61
- package/components/avatar.js.map +1 -1
- package/components/badge.d.ts +23 -0
- package/components/badge.d.ts.map +1 -0
- package/components/badge.js +2 -0
- package/components/badge.js.map +1 -0
- package/components/breath.d.ts +7 -4
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +1 -79
- package/components/breath.js.map +1 -1
- package/components/button.d.ts +19 -10
- package/components/button.d.ts.map +1 -1
- package/components/button.js +1 -165
- package/components/button.js.map +1 -1
- package/components/card.d.ts +3 -2
- package/components/card.d.ts.map +1 -1
- package/components/card.js +1 -53
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts +10 -5
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +1 -112
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts +6 -2
- package/components/details.d.ts.map +1 -1
- package/components/details.js +1 -49
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +8 -3
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +1 -93
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts +3 -3
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +1 -36
- package/components/divider.js.map +1 -1
- package/components/dragbox.d.ts +11 -9
- package/components/dragbox.d.ts.map +1 -1
- package/components/dragbox.js +1 -109
- package/components/dragbox.js.map +1 -1
- package/components/flex.d.ts +4 -1
- package/components/flex.d.ts.map +1 -1
- package/components/flex.js +1 -54
- package/components/flex.js.map +1 -1
- package/components/form.d.ts +3 -3
- package/components/form.d.ts.map +1 -1
- package/components/form.js +1 -77
- package/components/form.js.map +1 -1
- package/components/grid.d.ts +10 -3
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js +1 -55
- package/components/grid.js.map +1 -1
- package/components/heading.d.ts +29 -0
- package/components/heading.d.ts.map +1 -0
- package/components/heading.js +2 -0
- package/components/heading.js.map +1 -0
- package/components/input.d.ts +7 -3
- package/components/input.d.ts.map +1 -1
- package/components/input.js +1 -50
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +8 -9
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +1 -46
- package/components/layout.js.map +1 -1
- package/components/link.d.ts +8 -1
- package/components/link.d.ts.map +1 -1
- package/components/link.js +1 -42
- package/components/link.js.map +1 -1
- package/components/progress.d.ts +4 -11
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +1 -67
- package/components/progress.js.map +1 -1
- package/components/range.d.ts +22 -15
- package/components/range.d.ts.map +1 -1
- package/components/range.js +1 -273
- package/components/range.js.map +1 -1
- package/components/rotate.d.ts +4 -2
- package/components/rotate.d.ts.map +1 -1
- package/components/rotate.js +1 -56
- package/components/rotate.js.map +1 -1
- package/components/router.d.ts +20 -24
- package/components/router.d.ts.map +1 -1
- package/components/router.js +1 -250
- package/components/router.js.map +1 -1
- package/components/select.d.ts +8 -4
- package/components/select.d.ts.map +1 -1
- package/components/select.js +1 -212
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts +3 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +1 -54
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +25 -2
- package/components/split.d.ts.map +1 -1
- package/components/split.js +1 -128
- package/components/split.js.map +1 -1
- package/components/switch.d.ts +8 -5
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +1 -92
- package/components/switch.js.map +1 -1
- package/components/text.d.ts +3 -1
- package/components/text.d.ts.map +1 -1
- package/components/text.js +1 -43
- package/components/text.js.map +1 -1
- package/components/time.d.ts +8 -6
- package/components/time.d.ts.map +1 -1
- package/components/time.js +1 -85
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +14 -2
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +1 -66
- package/components/tooltip.js.map +1 -1
- package/components/typewriter.d.ts +8 -14
- package/components/typewriter.d.ts.map +1 -1
- package/components/typewriter.js +1 -129
- package/components/typewriter.js.map +1 -1
- package/core/global-style.d.ts +2 -2
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +1 -45
- package/core/global-style.js.map +1 -1
- package/core/super-anchor.d.ts +2 -1
- package/core/super-anchor.d.ts.map +1 -1
- package/core/super-anchor.js +1 -38
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +6 -5
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +1 -111
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts +1 -1
- package/core/super-openable.d.ts.map +1 -1
- package/core/super-openable.js +1 -37
- package/core/super-openable.js.map +1 -1
- package/custom-elements.json +1 -1
- package/details.d.ts +1 -0
- package/details.d.ts.map +1 -1
- package/details.js +1 -5
- package/details.js.map +1 -1
- package/dev/alert.d.ts +1 -0
- package/dev/alert.d.ts.map +1 -1
- package/dev/alert.js +1 -0
- package/dev/alert.js.map +1 -1
- package/dev/avatar.d.ts +1 -0
- package/dev/avatar.d.ts.map +1 -1
- package/dev/avatar.js +1 -0
- package/dev/avatar.js.map +1 -1
- package/dev/badge.d.ts +9 -0
- package/dev/badge.d.ts.map +1 -0
- package/dev/badge.js +5 -0
- package/dev/badge.js.map +1 -0
- package/dev/button.d.ts +1 -0
- package/dev/button.d.ts.map +1 -1
- package/dev/button.js +1 -0
- package/dev/button.js.map +1 -1
- package/dev/card.d.ts +1 -0
- package/dev/card.d.ts.map +1 -1
- package/dev/card.js +1 -0
- package/dev/card.js.map +1 -1
- package/dev/carousel.d.ts +1 -0
- package/dev/carousel.d.ts.map +1 -1
- package/dev/carousel.js +1 -0
- package/dev/carousel.js.map +1 -1
- package/dev/components/alert.d.ts +4 -1
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +20 -23
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts +8 -2
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +23 -13
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/badge.d.ts +23 -0
- package/dev/components/badge.d.ts.map +1 -0
- package/dev/components/badge.js +107 -0
- package/dev/components/badge.js.map +1 -0
- package/dev/components/breath.d.ts +7 -4
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +30 -26
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +19 -10
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +47 -28
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +3 -2
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +23 -33
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +10 -5
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +33 -26
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +6 -2
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +24 -26
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +8 -3
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +21 -17
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts +3 -3
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +29 -17
- package/dev/components/divider.js.map +1 -1
- package/dev/components/dragbox.d.ts +11 -9
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js +11 -4
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts +4 -1
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +25 -9
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts +3 -3
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +2 -5
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts +10 -3
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +18 -10
- package/dev/components/grid.js.map +1 -1
- package/dev/components/heading.d.ts +29 -0
- package/dev/components/heading.d.ts.map +1 -0
- package/dev/components/heading.js +103 -0
- package/dev/components/heading.js.map +1 -0
- package/dev/components/input.d.ts +7 -3
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +18 -18
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +8 -9
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +38 -25
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.d.ts +8 -1
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +15 -3
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +4 -11
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +43 -49
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +22 -15
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +56 -61
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +4 -2
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +3 -5
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +20 -24
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +23 -36
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +8 -4
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +44 -32
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts +3 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +9 -9
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +25 -2
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +71 -38
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +8 -5
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +28 -31
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.d.ts +3 -1
- package/dev/components/text.d.ts.map +1 -1
- package/dev/components/text.js +12 -15
- package/dev/components/text.js.map +1 -1
- package/dev/components/time.d.ts +8 -6
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +8 -14
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +14 -2
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +54 -24
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts +8 -14
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +22 -37
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts +2 -2
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +18 -14
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-anchor.d.ts +2 -1
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +25 -23
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +6 -5
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +43 -36
- package/dev/core/super-input.js.map +1 -1
- package/dev/core/super-openable.d.ts +1 -1
- package/dev/core/super-openable.d.ts.map +1 -1
- package/dev/core/super-openable.js +2 -2
- package/dev/core/super-openable.js.map +1 -1
- package/dev/details.d.ts +1 -0
- package/dev/details.d.ts.map +1 -1
- package/dev/details.js +1 -0
- package/dev/details.js.map +1 -1
- package/dev/dialog.d.ts +1 -0
- package/dev/dialog.d.ts.map +1 -1
- package/dev/dialog.js +1 -0
- package/dev/dialog.js.map +1 -1
- package/dev/divider.d.ts +1 -0
- package/dev/divider.d.ts.map +1 -1
- package/dev/divider.js +1 -0
- package/dev/divider.js.map +1 -1
- package/dev/dragbox.d.ts +1 -0
- package/dev/dragbox.d.ts.map +1 -1
- package/dev/dragbox.js +1 -0
- package/dev/dragbox.js.map +1 -1
- package/dev/flex.d.ts +1 -0
- package/dev/flex.d.ts.map +1 -1
- package/dev/flex.js +1 -0
- package/dev/flex.js.map +1 -1
- package/dev/form.d.ts +1 -0
- package/dev/form.d.ts.map +1 -1
- package/dev/form.js +1 -0
- package/dev/form.js.map +1 -1
- package/dev/grid.d.ts +1 -0
- package/dev/grid.d.ts.map +1 -1
- package/dev/grid.js +1 -0
- package/dev/grid.js.map +1 -1
- package/dev/heading.d.ts +9 -0
- package/dev/heading.d.ts.map +1 -0
- package/dev/heading.js +5 -0
- package/dev/heading.js.map +1 -0
- package/dev/index.d.ts +2 -0
- package/dev/index.d.ts.map +1 -1
- package/dev/index.js +2 -0
- package/dev/index.js.map +1 -1
- package/dev/layout.d.ts.map +1 -1
- package/dev/progress.d.ts.map +1 -1
- package/dev/router.d.ts.map +1 -1
- package/dev/split.d.ts +1 -1
- package/dev/split.d.ts.map +1 -1
- package/dev/typewriter.d.ts +1 -0
- package/dev/typewriter.d.ts.map +1 -1
- package/dev/typewriter.js +1 -0
- package/dev/typewriter.js.map +1 -1
- package/dialog.d.ts +1 -0
- package/dialog.d.ts.map +1 -1
- package/dialog.js +1 -5
- package/dialog.js.map +1 -1
- package/divider.d.ts +1 -0
- package/divider.d.ts.map +1 -1
- package/divider.js +1 -5
- package/divider.js.map +1 -1
- package/dragbox.d.ts +1 -0
- package/dragbox.d.ts.map +1 -1
- package/dragbox.js +1 -5
- package/dragbox.js.map +1 -1
- package/flex.d.ts +1 -0
- package/flex.d.ts.map +1 -1
- package/flex.js +1 -5
- package/flex.js.map +1 -1
- package/form.d.ts +1 -0
- package/form.d.ts.map +1 -1
- package/form.js +1 -5
- package/form.js.map +1 -1
- package/grid.d.ts +1 -0
- package/grid.d.ts.map +1 -1
- package/grid.js +1 -5
- package/grid.js.map +1 -1
- package/heading.d.ts +9 -0
- package/heading.d.ts.map +1 -0
- package/heading.js +2 -0
- package/heading.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -56
- package/index.js.map +1 -1
- package/input.js +1 -5
- package/input.js.map +1 -1
- package/layout.d.ts.map +1 -1
- package/layout.js +1 -5
- package/layout.js.map +1 -1
- package/link.js +1 -5
- package/link.js.map +1 -1
- package/package.json +11 -6
- package/progress.d.ts.map +1 -1
- package/progress.js +1 -5
- package/progress.js.map +1 -1
- package/range.js +1 -5
- package/range.js.map +1 -1
- package/rotate.js +1 -5
- package/rotate.js.map +1 -1
- package/router.d.ts.map +1 -1
- package/router.js +1 -5
- package/router.js.map +1 -1
- package/select.js +1 -5
- package/select.js.map +1 -1
- package/skeleton.js +1 -5
- package/skeleton.js.map +1 -1
- package/split.d.ts +1 -1
- package/split.d.ts.map +1 -1
- package/split.js +1 -5
- package/split.js.map +1 -1
- package/src/alert.ts +2 -0
- package/src/avatar.ts +2 -0
- package/src/badge.ts +13 -0
- package/src/button.ts +2 -0
- package/src/card.ts +2 -0
- package/src/carousel.ts +2 -0
- package/src/components/alert.ts +26 -29
- package/src/components/avatar.ts +28 -17
- package/src/components/badge.ts +107 -0
- package/src/components/breath.ts +38 -31
- package/src/components/button.ts +55 -46
- package/src/components/card.ts +26 -34
- package/src/components/carousel.ts +48 -38
- package/src/components/details.ts +27 -28
- package/src/components/dialog.ts +30 -26
- package/src/components/divider.ts +29 -17
- package/src/components/dragbox.ts +25 -19
- package/src/components/flex.ts +26 -11
- package/src/components/form.ts +7 -9
- package/src/components/grid.ts +31 -13
- package/src/components/heading.ts +105 -0
- package/src/components/input.ts +23 -22
- package/src/components/layout.ts +26 -31
- package/src/components/link.ts +15 -4
- package/src/components/progress.ts +51 -52
- package/src/components/range.ts +82 -94
- package/src/components/rotate.ts +12 -11
- package/src/components/router.ts +59 -48
- package/src/components/select.ts +59 -47
- package/src/components/skeleton.ts +13 -11
- package/src/components/split.ts +90 -49
- package/src/components/switch.ts +38 -37
- package/src/components/text.ts +14 -21
- package/src/components/time.ts +20 -14
- package/src/components/tooltip.ts +54 -29
- package/src/components/typewriter.ts +41 -47
- package/src/core/global-style.ts +33 -19
- package/src/core/super-anchor.ts +30 -26
- package/src/core/super-input.ts +54 -54
- package/src/core/super-openable.ts +7 -7
- package/src/details.ts +2 -0
- package/src/dialog.ts +2 -0
- package/src/divider.ts +2 -0
- package/src/dragbox.ts +2 -0
- package/src/flex.ts +2 -0
- package/src/form.ts +2 -0
- package/src/grid.ts +2 -0
- package/src/heading.ts +13 -0
- package/src/index.ts +2 -0
- package/src/layout.ts +1 -0
- package/src/progress.ts +1 -0
- package/src/router.ts +1 -0
- package/src/split.ts +1 -1
- package/src/typewriter.ts +2 -0
- package/switch.js +1 -5
- package/switch.js.map +1 -1
- package/text.js +1 -5
- package/text.js.map +1 -1
- package/time.js +1 -5
- package/time.js.map +1 -1
- package/tooltip.js +1 -5
- package/tooltip.js.map +1 -1
- package/typewriter.d.ts +1 -0
- package/typewriter.d.ts.map +1 -1
- package/typewriter.js +1 -5
- package/typewriter.js.map +1 -1
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/src/components/split.ts
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
import { godown } from "@godown/element
|
2
|
-
import {
|
3
|
-
import { classList } from "@godown/element/directives/class-list.js";
|
4
|
-
import { type HandlerEvent } from "@godown/element/element.js";
|
5
|
-
import { css, html, nothing } from "lit";
|
1
|
+
import { attr, classList, godown, type HandlerEvent, styles } from "@godown/element";
|
2
|
+
import { css, html, nothing, type TemplateResult } from "lit";
|
6
3
|
import { property, state } from "lit/decorators.js";
|
7
4
|
|
8
5
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
@@ -26,6 +23,10 @@ const loop = <T>(len: number, fn: (index?: number) => T) => {
|
|
26
23
|
*
|
27
24
|
* Delete: will move the focus box forward until the first and no inputs for each.
|
28
25
|
*
|
26
|
+
* @fires input - Fires when the input value changes.
|
27
|
+
* @fires change - Fires when the input value changes.
|
28
|
+
* @fires focus - Fires when the input is focused.
|
29
|
+
* @fires blur - Fires when the input is blurred.
|
29
30
|
* @category input
|
30
31
|
*/
|
31
32
|
@godown(protoName)
|
@@ -40,17 +41,21 @@ const loop = <T>(len: number, fn: (index?: number) => T) => {
|
|
40
41
|
${cssScope}--gap: .25em;
|
41
42
|
}
|
42
43
|
|
43
|
-
[part=
|
44
|
+
:host([contents]) [part=root] {
|
45
|
+
width: fit-content;
|
46
|
+
}
|
47
|
+
|
48
|
+
[part=root] {
|
44
49
|
gap: var(${cssScope}--gap);
|
45
50
|
width: 100%;
|
46
51
|
position: relative;
|
47
52
|
vertical-align: top;
|
48
|
-
display:
|
53
|
+
display: flex;
|
49
54
|
justify-content: space-between;
|
50
55
|
border-radius: inherit;
|
51
56
|
}
|
52
57
|
|
53
|
-
[part=
|
58
|
+
[part=input-box] {
|
54
59
|
width: var(${cssScope}--size);
|
55
60
|
height: var(${cssScope}--size);
|
56
61
|
vertical-align: top;
|
@@ -59,7 +64,7 @@ const loop = <T>(len: number, fn: (index?: number) => T) => {
|
|
59
64
|
border-radius: inherit;
|
60
65
|
}
|
61
66
|
|
62
|
-
[part=
|
67
|
+
[part=input] {
|
63
68
|
width: 100%;
|
64
69
|
height: 100%;
|
65
70
|
opacity: 0;
|
@@ -79,6 +84,7 @@ class Split extends SuperInput {
|
|
79
84
|
*/
|
80
85
|
@property({ type: Number })
|
81
86
|
len = 6;
|
87
|
+
|
82
88
|
/**
|
83
89
|
* Focus index.
|
84
90
|
*/
|
@@ -87,30 +93,34 @@ class Split extends SuperInput {
|
|
87
93
|
|
88
94
|
@state()
|
89
95
|
current = -1;
|
96
|
+
|
90
97
|
@state()
|
91
98
|
currentValue: (string | void)[] = [];
|
92
99
|
|
93
|
-
protected render() {
|
94
|
-
return html
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
100
|
+
protected render(): TemplateResult<1> {
|
101
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
102
|
+
${
|
103
|
+
loop(
|
104
|
+
this.len,
|
105
|
+
(index: number) =>
|
106
|
+
html`<span
|
107
|
+
part="input-box"
|
108
|
+
@click="${this.disabled ? null : () => this.focusAt(index)}"
|
109
|
+
class="${classList({ focus: this.current === index }) || nothing}"
|
110
|
+
>${this.currentValue[index]}</span
|
111
|
+
>`,
|
112
|
+
)
|
102
113
|
}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
114
|
+
<input
|
115
|
+
part="input"
|
116
|
+
id="${this.makeId}"
|
117
|
+
@blur=${this.blur}
|
118
|
+
@input="${this._handleInput}"
|
119
|
+
.value="${
|
109
120
|
/* Ensure that input always has a value of length this.len */
|
110
121
|
this.value.padStart(this.len, " ")}"
|
111
|
-
|
112
|
-
|
113
|
-
`;
|
122
|
+
>
|
123
|
+
</div> `;
|
114
124
|
}
|
115
125
|
|
116
126
|
connectedCallback(): void {
|
@@ -118,12 +128,36 @@ class Split extends SuperInput {
|
|
118
128
|
this.reset();
|
119
129
|
}
|
120
130
|
|
121
|
-
protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>) {
|
131
|
+
protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>): void {
|
122
132
|
e.stopPropagation();
|
123
133
|
if (this.compositing) {
|
124
134
|
return;
|
125
135
|
}
|
126
|
-
|
136
|
+
|
137
|
+
this.fillInput(e.data);
|
138
|
+
this.value = this.currentValue.join("");
|
139
|
+
|
140
|
+
this.dispatchEvent(new CustomEvent("input", { detail: this.value, composed: true, bubbles: true }));
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Fill input with data.
|
145
|
+
*
|
146
|
+
* If data is null
|
147
|
+
* - If current value is null, move to before.
|
148
|
+
* - If current value is not null, delete it.
|
149
|
+
*
|
150
|
+
* If data is not null
|
151
|
+
* - If current value is null, input data.
|
152
|
+
* - If current value is not null, input data and move to after.
|
153
|
+
*
|
154
|
+
* If data is multiple characters,
|
155
|
+
* Fill input with data[0] and call fillInput with data.slice(1).
|
156
|
+
*
|
157
|
+
* @param data Input event data.
|
158
|
+
*/
|
159
|
+
protected fillInput(data: string | null): void {
|
160
|
+
if (data === null) {
|
127
161
|
// delete
|
128
162
|
|
129
163
|
if (this.currentValue[this.current] !== null) {
|
@@ -137,47 +171,53 @@ class Split extends SuperInput {
|
|
137
171
|
const lastNotNull = this.currentValue.findLastIndex(a => a !== null);
|
138
172
|
this.current = this.current - 1 < 0 ? lastNotNull < 0 ? 0 : lastNotNull : this.current - 1;
|
139
173
|
}
|
140
|
-
|
141
|
-
|
174
|
+
return;
|
175
|
+
}
|
142
176
|
|
143
|
-
|
144
|
-
if (this.current + 1 >= this.len) {
|
145
|
-
// index overflow
|
177
|
+
const multiple = data.length > 1;
|
146
178
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
} else {
|
152
|
-
// go to after
|
179
|
+
// input
|
180
|
+
this.currentValue[this.current] = data[0];
|
181
|
+
if (this.current + 1 >= this.len) {
|
182
|
+
// index overflow
|
153
183
|
|
154
|
-
|
184
|
+
this.current = this.currentValue.indexOf(null);
|
185
|
+
if (this.current === -1) {
|
186
|
+
this.blur();
|
155
187
|
}
|
156
|
-
}
|
188
|
+
} else {
|
189
|
+
// go to after
|
157
190
|
|
158
|
-
|
191
|
+
this.current += 1;
|
192
|
+
}
|
159
193
|
|
160
|
-
|
161
|
-
|
194
|
+
if (multiple) {
|
195
|
+
const after = data.slice(1);
|
196
|
+
if (after) {
|
197
|
+
this.fillInput(after);
|
198
|
+
}
|
199
|
+
}
|
162
200
|
}
|
163
201
|
|
164
|
-
focus() {
|
202
|
+
focus(): void {
|
165
203
|
this.focusAt(this.current);
|
166
204
|
super.focus();
|
167
205
|
}
|
168
206
|
|
169
|
-
focusAt(i: number) {
|
207
|
+
focusAt(i: number): void {
|
170
208
|
this.current = i;
|
171
209
|
this._input.focus();
|
210
|
+
this.dispatchEvent(new CustomEvent("focus", { detail: i, bubbles: true, composed: true }));
|
172
211
|
}
|
173
212
|
|
174
|
-
blur() {
|
213
|
+
blur(): void {
|
175
214
|
this._input.blur();
|
176
215
|
this.current = -1;
|
177
216
|
super.blur();
|
217
|
+
this.dispatchEvent(new CustomEvent("blur", { bubbles: true, composed: true }));
|
178
218
|
}
|
179
219
|
|
180
|
-
reset() {
|
220
|
+
reset(): void {
|
181
221
|
this.current = -1;
|
182
222
|
this.value = this.default;
|
183
223
|
this.currentValue = this.value.split("").concat(Array(this.len - this.value.length).fill(null));
|
@@ -188,3 +228,4 @@ class Split extends SuperInput {
|
|
188
228
|
}
|
189
229
|
|
190
230
|
export default Split;
|
231
|
+
export { Split };
|
package/src/components/switch.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import { godown } from "@godown/element
|
2
|
-
import {
|
3
|
-
import { css, html } from "lit";
|
1
|
+
import { attr, godown, styles } from "@godown/element";
|
2
|
+
import { css, html, type TemplateResult } from "lit";
|
4
3
|
import { property, query } from "lit/decorators.js";
|
5
4
|
|
6
5
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
@@ -15,47 +14,49 @@ const cssScope = scopePrefix(protoName);
|
|
15
14
|
* The switch is rectangular by default,
|
16
15
|
* set the round property to rounded switch.
|
17
16
|
*
|
17
|
+
* @fires change - Fires when the switch is switched.
|
18
18
|
* @category input
|
19
19
|
*/
|
20
20
|
@godown(protoName)
|
21
21
|
@styles(
|
22
22
|
css`
|
23
|
+
:host,
|
24
|
+
:host([contents]) [part=root] {
|
25
|
+
width: var(${cssScope}-width);
|
26
|
+
height: var(${cssScope}-height);
|
27
|
+
display: inline-block;
|
28
|
+
}
|
29
|
+
|
23
30
|
:host {
|
24
31
|
${cssScope}-width: 3em;
|
25
32
|
${cssScope}-height: calc(var(${cssScope}-width) / 2);
|
26
33
|
${cssScope}-handle-size: 1.25em;
|
34
|
+
${cssScope}-handle-space: .125em;
|
27
35
|
${cssScope}-transition: .2s ease-in-out;
|
28
36
|
background: var(${cssGlobalVars.input}-background);
|
29
|
-
width: var(${cssScope}-width);
|
30
|
-
height: var(${cssScope}-height);
|
31
|
-
display: inline-block;
|
32
37
|
vertical-align: bottom;
|
33
38
|
border-radius: 0;
|
34
39
|
}
|
35
40
|
|
36
|
-
[part=
|
37
|
-
|
41
|
+
[part=root],
|
42
|
+
[part=handle] {
|
38
43
|
transition: var(${cssScope}-transition);
|
39
44
|
}
|
40
45
|
|
41
|
-
[part=
|
46
|
+
[part=root] {
|
42
47
|
border-radius: inherit;
|
43
48
|
position: relative;
|
44
49
|
height: inherit;
|
45
50
|
}
|
46
|
-
|
47
|
-
[part=
|
48
|
-
input {
|
49
|
-
width: 100%;
|
50
|
-
}
|
51
|
-
|
52
|
-
input {
|
51
|
+
|
52
|
+
[part=input] {
|
53
53
|
opacity: 0;
|
54
|
+
width: 100%;
|
54
55
|
height: 100%;
|
55
56
|
appearance: none;
|
56
57
|
}
|
57
58
|
|
58
|
-
|
59
|
+
[part=handle] {
|
59
60
|
height: 100%;
|
60
61
|
display: inline-flex;
|
61
62
|
align-items: center;
|
@@ -69,10 +70,11 @@ const cssScope = scopePrefix(protoName);
|
|
69
70
|
|
70
71
|
:host([round]) {
|
71
72
|
border-radius: calc(var(${cssScope}-height) / 2);
|
73
|
+
background: var(${cssGlobalVars.passive});
|
72
74
|
}
|
73
75
|
|
74
|
-
:host([checked])
|
75
|
-
|
76
|
+
:host([checked]) [part=handle] {
|
77
|
+
left: 50%;
|
76
78
|
}
|
77
79
|
|
78
80
|
.rect .true {
|
@@ -83,17 +85,13 @@ const cssScope = scopePrefix(protoName);
|
|
83
85
|
background: var(${cssGlobalVars.passive});
|
84
86
|
}
|
85
87
|
|
86
|
-
.round
|
88
|
+
.round [part=handle] {
|
87
89
|
--size: var(${cssScope}-handle-size);
|
88
|
-
content:"";
|
89
90
|
border-radius: 100%;
|
90
91
|
background: var(--godown--input-control);
|
91
92
|
width: var(--size);
|
92
93
|
height: var(--size);
|
93
|
-
|
94
|
-
|
95
|
-
.round {
|
96
|
-
background: var(${cssGlobalVars.passive});
|
94
|
+
margin: var(${cssScope}-handle-space);
|
97
95
|
}
|
98
96
|
|
99
97
|
:host([checked]) .round {
|
@@ -103,25 +101,29 @@ const cssScope = scopePrefix(protoName);
|
|
103
101
|
)
|
104
102
|
class Switch extends SuperInput {
|
105
103
|
/**
|
106
|
-
*
|
104
|
+
* Display rounded.
|
107
105
|
*/
|
108
106
|
@property({ type: Boolean, reflect: true })
|
109
107
|
round = false;
|
108
|
+
|
110
109
|
/**
|
111
110
|
* Whether this element is selected or not.
|
112
111
|
*/
|
113
112
|
@property({ type: Boolean, reflect: true })
|
114
113
|
checked = false;
|
114
|
+
|
115
115
|
/**
|
116
|
-
*
|
116
|
+
* Disable this element.
|
117
117
|
*/
|
118
118
|
@property({ type: Boolean, reflect: true })
|
119
119
|
disabled = false;
|
120
|
+
|
120
121
|
/**
|
121
|
-
*
|
122
|
+
* Default checked state.
|
122
123
|
*/
|
123
124
|
@property()
|
124
125
|
default = "false";
|
126
|
+
|
125
127
|
/**
|
126
128
|
* Input value.
|
127
129
|
*/
|
@@ -129,10 +131,10 @@ class Switch extends SuperInput {
|
|
129
131
|
value = "on";
|
130
132
|
|
131
133
|
@query("input")
|
132
|
-
_input: HTMLInputElement;
|
134
|
+
protected _input: HTMLInputElement;
|
133
135
|
|
134
|
-
protected render() {
|
135
|
-
return html`<div part="root" class="${this.round ? "round" : "rect"}">
|
136
|
+
protected render(): TemplateResult<1> {
|
137
|
+
return html`<div part="root" ${attr(this.observedRecord)} class="${this.round ? "round" : "rect"}">
|
136
138
|
<input
|
137
139
|
part="input"
|
138
140
|
@change="${this._handleChange}"
|
@@ -142,17 +144,16 @@ class Switch extends SuperInput {
|
|
142
144
|
id="${this.makeId}"
|
143
145
|
type="checkbox"
|
144
146
|
>
|
145
|
-
<span class="${this.checked}">
|
146
|
-
</span>
|
147
|
+
<span part="handle" class="${this.checked}"></span>
|
147
148
|
</div>`;
|
148
149
|
}
|
149
150
|
|
150
|
-
reset() {
|
151
|
+
reset(): void {
|
151
152
|
this.checked = this.default === "true";
|
152
153
|
this._input.checked = this.checked;
|
153
154
|
}
|
154
155
|
|
155
|
-
connectedCallback() {
|
156
|
+
connectedCallback(): void {
|
156
157
|
super.connectedCallback();
|
157
158
|
if (this.checked) {
|
158
159
|
this.default = "true";
|
@@ -162,9 +163,8 @@ class Switch extends SuperInput {
|
|
162
163
|
}
|
163
164
|
}
|
164
165
|
|
165
|
-
protected _handleChange() {
|
166
|
+
protected _handleChange(): void {
|
166
167
|
this.checked = this._input.checked;
|
167
|
-
this.dispatchEvent(new CustomEvent("input", { detail: this.checked, bubbles: true, composed: true }));
|
168
168
|
this.dispatchEvent(new CustomEvent("change", { detail: this.checked, composed: true }));
|
169
169
|
}
|
170
170
|
|
@@ -174,3 +174,4 @@ class Switch extends SuperInput {
|
|
174
174
|
}
|
175
175
|
|
176
176
|
export default Switch;
|
177
|
+
export { Switch };
|
package/src/components/text.ts
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
import { godown } from "@godown/element
|
2
|
-
import {
|
3
|
-
import { classList } from "@godown/element/directives/class-list.js";
|
4
|
-
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
-
import { css, html } from "lit";
|
1
|
+
import { attr, classList, godown, htmlSlot, styles } from "@godown/element";
|
2
|
+
import { css, html, type TemplateResult } from "lit";
|
6
3
|
import { property } from "lit/decorators.js";
|
7
4
|
|
8
5
|
import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
|
@@ -17,7 +14,8 @@ const cssScope = scopePrefix(protoName);
|
|
17
14
|
* @category display
|
18
15
|
*/
|
19
16
|
@godown(protoName)
|
20
|
-
@styles(
|
17
|
+
@styles(
|
18
|
+
css`
|
21
19
|
:host {
|
22
20
|
${cssScope}--color: currentColor;
|
23
21
|
${cssScope}--color-hover: currentColor;
|
@@ -27,7 +25,7 @@ const cssScope = scopePrefix(protoName);
|
|
27
25
|
overflow-wrap: break-word;
|
28
26
|
}
|
29
27
|
|
30
|
-
[part=
|
28
|
+
[part=root] {
|
31
29
|
white-space: nowrap;
|
32
30
|
width: 100%;
|
33
31
|
vertical-align: bottom;
|
@@ -38,11 +36,11 @@ const cssScope = scopePrefix(protoName);
|
|
38
36
|
color: var(${cssScope}--color);
|
39
37
|
}
|
40
38
|
|
41
|
-
[part=
|
39
|
+
[part=root]:hover {
|
42
40
|
color: var(${cssScope}--color-hover, var(${cssScope}--color));
|
43
41
|
}
|
44
42
|
|
45
|
-
[part=
|
43
|
+
[part=root]:active {
|
46
44
|
color: var(${cssScope}--color-active, var(${cssScope}--color));
|
47
45
|
}
|
48
46
|
|
@@ -56,7 +54,7 @@ const cssScope = scopePrefix(protoName);
|
|
56
54
|
text-decoration: none;
|
57
55
|
}
|
58
56
|
|
59
|
-
|
57
|
+
[clip] {
|
60
58
|
background: var(${cssGlobalVars.clipBackground});
|
61
59
|
display: inline-block;
|
62
60
|
color: transparent;
|
@@ -64,7 +62,8 @@ const cssScope = scopePrefix(protoName);
|
|
64
62
|
background-clip: text;
|
65
63
|
-webkit-background-clip: text;
|
66
64
|
}
|
67
|
-
|
65
|
+
`,
|
66
|
+
)
|
68
67
|
class Text extends GlobalStyle {
|
69
68
|
/**
|
70
69
|
* Underline behavior.
|
@@ -76,20 +75,14 @@ class Text extends GlobalStyle {
|
|
76
75
|
* Set background-clip to text.
|
77
76
|
*/
|
78
77
|
@property({ type: Boolean })
|
79
|
-
clip
|
78
|
+
clip = false;
|
80
79
|
|
81
|
-
protected render() {
|
82
|
-
return html`<span
|
83
|
-
part="root"
|
84
|
-
class="${
|
85
|
-
classList(this.underline, {
|
86
|
-
clip: this.clip,
|
87
|
-
})
|
88
|
-
}"
|
89
|
-
>
|
80
|
+
protected render(): TemplateResult<1> {
|
81
|
+
return html`<span part="root" ${attr(this.observedRecord)} class="${classList(this.underline)}">
|
90
82
|
${htmlSlot()}
|
91
83
|
</span>`;
|
92
84
|
}
|
93
85
|
}
|
94
86
|
|
95
87
|
export default Text;
|
88
|
+
export { Text };
|
package/src/components/time.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { godown } from "@godown/element
|
2
|
-
import { styles } from "@godown/element/decorators/styles.js";
|
1
|
+
import { attr, godown, styles } from "@godown/element";
|
3
2
|
import fmtime from "fmtime";
|
4
|
-
import { css, type PropertyValues } from "lit";
|
3
|
+
import { css, html, type PropertyValues, type TemplateResult } from "lit";
|
5
4
|
import { property } from "lit/decorators.js";
|
6
5
|
|
7
6
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -11,44 +10,49 @@ const protoName = "time";
|
|
11
10
|
/**
|
12
11
|
* {@linkcode Time} renders a formatting time.
|
13
12
|
*
|
13
|
+
* @fires time - Fires when the time changes.
|
14
14
|
* @category display
|
15
15
|
*/
|
16
16
|
@godown(protoName)
|
17
17
|
@styles(css`:host{text-align: center;}`)
|
18
18
|
class Time extends GlobalStyle {
|
19
19
|
/**
|
20
|
-
*
|
20
|
+
* Escape symbol.
|
21
21
|
*/
|
22
22
|
@property()
|
23
23
|
escape = "%";
|
24
|
+
|
24
25
|
/**
|
25
26
|
* Format strings.
|
26
27
|
*/
|
27
28
|
@property()
|
28
29
|
format = "YYYY-MM-DD hh:mm:ss UTFZ";
|
30
|
+
|
29
31
|
/**
|
30
32
|
* Time.
|
31
33
|
*/
|
32
34
|
@property({ type: Object })
|
33
|
-
time = new Date();
|
35
|
+
time: Date = new Date();
|
36
|
+
|
34
37
|
/**
|
35
38
|
* If there is a value, update every gap or timeout.
|
36
39
|
*/
|
37
40
|
@property({ type: Number })
|
38
|
-
timeout
|
41
|
+
timeout: any;
|
42
|
+
|
39
43
|
/**
|
40
44
|
* The number of milliseconds that change with each update.
|
41
45
|
*/
|
42
46
|
@property({ type: Number })
|
43
|
-
gap
|
47
|
+
gap: any;
|
44
48
|
|
45
|
-
timeoutId: number;
|
49
|
+
protected timeoutId: number;
|
46
50
|
|
47
|
-
protected render():
|
48
|
-
return fmtime(this.format, this.time, this.escape)
|
51
|
+
protected render(): TemplateResult<1> {
|
52
|
+
return html`<span part="root" ${attr(this.observedRecord)}>${fmtime(this.format, this.time, this.escape)}</span>`;
|
49
53
|
}
|
50
54
|
|
51
|
-
protected firstUpdated() {
|
55
|
+
protected firstUpdated(): void {
|
52
56
|
if (this.timeout) {
|
53
57
|
this.timeoutId = this.startTimeout();
|
54
58
|
}
|
@@ -63,15 +67,17 @@ class Time extends GlobalStyle {
|
|
63
67
|
}
|
64
68
|
}
|
65
69
|
|
66
|
-
disconnectedCallback() {
|
70
|
+
disconnectedCallback(): void {
|
67
71
|
clearInterval(this.timeoutId);
|
68
72
|
}
|
69
73
|
|
70
|
-
startTimeout() {
|
71
|
-
return
|
74
|
+
startTimeout(): number {
|
75
|
+
return setInterval(() => {
|
76
|
+
this.dispatchEvent(new CustomEvent("time", { detail: this.time, composed: true }));
|
72
77
|
this.time = new Date(this.time.getTime() + (this.gap || this.timeout));
|
73
78
|
}, Math.abs(this.timeout));
|
74
79
|
}
|
75
80
|
}
|
76
81
|
|
77
82
|
export default Time;
|
83
|
+
export { Time };
|