godown 2.7.5 → 2.7.7
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 +18 -45
- package/{.deps.d.ts → _deps.d.ts} +1 -2
- package/{.deps.d.ts.map → _deps.d.ts.map} +1 -1
- package/{.deps.js → _deps.js} +1 -2
- package/_deps.js.map +1 -0
- package/alert.d.ts +8 -1
- package/alert.d.ts.map +1 -1
- package/alert.js +4 -1
- package/alert.js.map +1 -1
- package/avatar-group.d.ts +8 -1
- package/avatar-group.d.ts.map +1 -1
- package/avatar-group.js +4 -1
- package/avatar-group.js.map +1 -1
- package/avatar.d.ts +8 -1
- package/avatar.d.ts.map +1 -1
- package/avatar.js +4 -1
- package/avatar.js.map +1 -1
- package/button.d.ts +8 -1
- package/button.d.ts.map +1 -1
- package/button.js +4 -1
- package/button.js.map +1 -1
- package/card.d.ts +8 -1
- package/card.d.ts.map +1 -1
- package/card.js +4 -1
- package/card.js.map +1 -1
- package/carousel.d.ts +8 -1
- package/carousel.d.ts.map +1 -1
- package/carousel.js +4 -1
- package/carousel.js.map +1 -1
- package/components.json +194 -0
- package/conf.d.ts +6 -75
- package/conf.d.ts.map +1 -1
- package/conf.js +8 -34
- package/conf.js.map +1 -1
- package/decorators/godown.d.ts +4 -0
- package/decorators/godown.d.ts.map +1 -0
- package/decorators/godown.js +9 -0
- package/decorators/godown.js.map +1 -0
- package/decorators/part.d.ts +7 -0
- package/decorators/part.d.ts.map +1 -0
- package/decorators/part.js +8 -0
- package/decorators/part.js.map +1 -0
- package/decorators/styles.d.ts +3 -0
- package/decorators/styles.d.ts.map +1 -0
- package/decorators/styles.js +8 -0
- package/decorators/styles.js.map +1 -0
- package/details.d.ts +8 -1
- package/details.d.ts.map +1 -1
- package/details.js +4 -1
- package/details.js.map +1 -1
- package/dialog.d.ts +8 -1
- package/dialog.d.ts.map +1 -1
- package/dialog.js +4 -1
- package/dialog.js.map +1 -1
- package/divider.d.ts +8 -1
- package/divider.d.ts.map +1 -1
- package/divider.js +4 -1
- package/divider.js.map +1 -1
- package/dragbox.d.ts +8 -1
- package/dragbox.d.ts.map +1 -1
- package/dragbox.js +4 -1
- package/dragbox.js.map +1 -1
- package/flex-flow.d.ts +8 -1
- package/flex-flow.d.ts.map +1 -1
- package/flex-flow.js +4 -1
- package/flex-flow.js.map +1 -1
- package/form.d.ts +8 -1
- package/form.d.ts.map +1 -1
- package/form.js +4 -1
- package/form.js.map +1 -1
- package/grid-flow.d.ts +9 -0
- package/grid-flow.d.ts.map +1 -0
- package/grid-flow.js +5 -0
- package/grid-flow.js.map +1 -0
- package/index.d.ts +32 -3
- package/index.d.ts.map +1 -1
- package/index.js +32 -3
- package/index.js.map +1 -1
- package/input.d.ts +8 -1
- package/input.d.ts.map +1 -1
- package/input.js +4 -1
- package/input.js.map +1 -1
- package/label-input.d.ts +8 -1
- package/label-input.d.ts.map +1 -1
- package/label-input.js +4 -1
- package/label-input.js.map +1 -1
- package/layout.d.ts +9 -0
- package/layout.d.ts.map +1 -0
- package/layout.js +5 -0
- package/layout.js.map +1 -0
- package/lib/css.d.ts +13 -0
- package/lib/css.d.ts.map +1 -0
- package/lib/css.js +29 -0
- package/lib/css.js.map +1 -0
- package/lib/directives.d.ts +16 -20
- package/lib/directives.d.ts.map +1 -1
- package/lib/directives.js +33 -31
- package/lib/directives.js.map +1 -1
- package/lib/event-coll.d.ts +13 -0
- package/lib/event-coll.d.ts.map +1 -0
- package/lib/event-coll.js +45 -0
- package/lib/event-coll.js.map +1 -0
- package/lib/{templates.d.ts → icons.d.ts} +1 -17
- package/lib/icons.d.ts.map +1 -0
- package/lib/icons.js +73 -0
- package/lib/icons.js.map +1 -0
- package/lib/jsx.d.ts +4 -0
- package/lib/jsx.d.ts.map +1 -0
- package/lib/jsx.js +52 -0
- package/lib/jsx.js.map +1 -0
- package/lib/route-tree.d.ts +5 -5
- package/lib/route-tree.js +5 -5
- package/lib/route-tree.js.map +1 -1
- package/lib/utils.d.ts +6 -46
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +25 -110
- package/lib/utils.js.map +1 -1
- package/link.d.ts +9 -0
- package/link.d.ts.map +1 -0
- package/link.js +5 -0
- package/link.js.map +1 -0
- package/overbreath.d.ts +8 -1
- package/overbreath.d.ts.map +1 -1
- package/overbreath.js +4 -1
- package/overbreath.js.map +1 -1
- package/package.json +18 -23
- package/progress.d.ts +8 -1
- package/progress.d.ts.map +1 -1
- package/progress.js +4 -1
- package/progress.js.map +1 -1
- package/proto/godown-config.d.ts +41 -0
- package/proto/godown-config.d.ts.map +1 -0
- package/proto/godown-config.js +27 -0
- package/proto/godown-config.js.map +1 -0
- package/{godown-element.d.ts → proto/godown-element.d.ts} +48 -16
- package/proto/godown-element.d.ts.map +1 -0
- package/{godown-element.js → proto/godown-element.js} +82 -26
- package/proto/godown-element.js.map +1 -0
- package/proto/super-a.d.ts +30 -0
- package/proto/super-a.d.ts.map +1 -0
- package/proto/super-a.js +141 -0
- package/proto/super-a.js.map +1 -0
- package/proto/super-input.d.ts +44 -0
- package/proto/super-input.d.ts.map +1 -0
- package/proto/super-input.js +119 -0
- package/proto/super-input.js.map +1 -0
- package/proto/super-openable.d.ts +23 -0
- package/proto/super-openable.d.ts.map +1 -0
- package/proto/super-openable.js +43 -0
- package/proto/super-openable.js.map +1 -0
- package/range-input.d.ts +9 -0
- package/range-input.d.ts.map +1 -0
- package/range-input.js +5 -0
- package/range-input.js.map +1 -0
- package/react/create.d.ts.map +1 -1
- package/react/create.js +4 -1
- package/react/create.js.map +1 -1
- package/react/index.d.ts +64 -34
- package/react/index.d.ts.map +1 -1
- package/react/index.js +78 -51
- package/react/index.js.map +1 -1
- package/rotate.d.ts +9 -0
- package/rotate.d.ts.map +1 -0
- package/rotate.js +5 -0
- package/rotate.js.map +1 -0
- package/router-link.d.ts +9 -0
- package/router-link.d.ts.map +1 -0
- package/router-link.js +5 -0
- package/router-link.js.map +1 -0
- package/router.d.ts +8 -1
- package/router.d.ts.map +1 -1
- package/router.js +4 -1
- package/router.js.map +1 -1
- package/search-input.d.ts +8 -1
- package/search-input.d.ts.map +1 -1
- package/search-input.js +4 -1
- package/search-input.js.map +1 -1
- package/select-input.d.ts +8 -1
- package/select-input.d.ts.map +1 -1
- package/select-input.js +4 -1
- package/select-input.js.map +1 -1
- package/skeleton.d.ts +8 -1
- package/skeleton.d.ts.map +1 -1
- package/skeleton.js +4 -1
- package/skeleton.js.map +1 -1
- package/split-input.d.ts +8 -1
- package/split-input.d.ts.map +1 -1
- package/split-input.js +4 -1
- package/split-input.js.map +1 -1
- package/styles/colors/presets.d.ts +13 -0
- package/styles/colors/presets.d.ts.map +1 -0
- package/styles/colors/presets.js +6 -0
- package/styles/colors/presets.js.map +1 -0
- package/styles/colors/presetsRGB.d.ts +16 -0
- package/styles/colors/presetsRGB.d.ts.map +1 -0
- package/styles/colors/presetsRGB.js +134 -0
- package/styles/colors/presetsRGB.js.map +1 -0
- package/styles/global.d.ts +18 -0
- package/styles/global.d.ts.map +1 -0
- package/styles/global.js +78 -0
- package/styles/global.js.map +1 -0
- package/styles/inputStyle.d.ts +3 -0
- package/styles/inputStyle.d.ts.map +1 -0
- package/styles/inputStyle.js +59 -0
- package/styles/inputStyle.js.map +1 -0
- package/switch-input.d.ts +8 -1
- package/switch-input.d.ts.map +1 -1
- package/switch-input.js +4 -1
- package/switch-input.js.map +1 -1
- package/text.d.ts +8 -1
- package/text.d.ts.map +1 -1
- package/text.js +4 -1
- package/text.js.map +1 -1
- package/time.d.ts +8 -1
- package/time.d.ts.map +1 -1
- package/time.js +4 -1
- package/time.js.map +1 -1
- package/tooltip.d.ts +8 -1
- package/tooltip.d.ts.map +1 -1
- package/tooltip.js +4 -1
- package/tooltip.js.map +1 -1
- package/typewriter.d.ts +8 -1
- package/typewriter.d.ts.map +1 -1
- package/typewriter.js +4 -1
- package/typewriter.js.map +1 -1
- package/web-components/alert/alert.d.ts +2 -10
- package/web-components/alert/alert.d.ts.map +1 -1
- package/web-components/alert/alert.js +93 -91
- package/web-components/alert/alert.js.map +1 -1
- package/web-components/avatar/avatar-group.d.ts +21 -0
- package/web-components/avatar/avatar-group.d.ts.map +1 -0
- package/web-components/avatar/avatar-group.js +86 -0
- package/web-components/avatar/avatar-group.js.map +1 -0
- package/web-components/avatar/avatar.d.ts +5 -18
- package/web-components/avatar/avatar.d.ts.map +1 -1
- package/web-components/avatar/avatar.js +70 -85
- package/web-components/avatar/avatar.js.map +1 -1
- package/web-components/button/button.d.ts +10 -43
- package/web-components/button/button.d.ts.map +1 -1
- package/web-components/button/button.js +183 -226
- package/web-components/button/button.js.map +1 -1
- package/web-components/card/card.d.ts +2 -27
- package/web-components/card/card.d.ts.map +1 -1
- package/web-components/card/card.js +57 -132
- package/web-components/card/card.js.map +1 -1
- package/web-components/carousel/carousel.d.ts +5 -16
- package/web-components/carousel/carousel.d.ts.map +1 -1
- package/web-components/carousel/carousel.js +102 -106
- package/web-components/carousel/carousel.js.map +1 -1
- package/web-components/details/details.d.ts +4 -15
- package/web-components/details/details.d.ts.map +1 -1
- package/web-components/details/details.js +91 -97
- package/web-components/details/details.js.map +1 -1
- package/web-components/dialog/dialog.d.ts +6 -17
- package/web-components/dialog/dialog.d.ts.map +1 -1
- package/web-components/dialog/dialog.js +87 -137
- package/web-components/dialog/dialog.js.map +1 -1
- package/web-components/divider/divider.d.ts +13 -0
- package/web-components/divider/divider.d.ts.map +1 -0
- package/web-components/divider/divider.js +95 -0
- package/web-components/divider/divider.js.map +1 -0
- package/web-components/form/form.d.ts +15 -22
- package/web-components/form/form.d.ts.map +1 -1
- package/web-components/form/form.js +47 -117
- package/web-components/form/form.js.map +1 -1
- package/web-components/input/input.d.ts +5 -18
- package/web-components/input/input.d.ts.map +1 -1
- package/web-components/input/input.js +74 -169
- package/web-components/input/input.js.map +1 -1
- package/web-components/input/label-input.d.ts +5 -19
- package/web-components/input/label-input.d.ts.map +1 -1
- package/web-components/input/label-input.js +74 -141
- package/web-components/input/label-input.js.map +1 -1
- package/web-components/input/range-input.d.ts +53 -0
- package/web-components/input/range-input.d.ts.map +1 -0
- package/web-components/input/range-input.js +316 -0
- package/web-components/input/range-input.js.map +1 -0
- package/web-components/input/search-input.d.ts +4 -12
- package/web-components/input/search-input.d.ts.map +1 -1
- package/web-components/input/search-input.js +118 -113
- package/web-components/input/search-input.js.map +1 -1
- package/web-components/input/select-input.d.ts +17 -32
- package/web-components/input/select-input.d.ts.map +1 -1
- package/web-components/input/select-input.js +154 -286
- package/web-components/input/select-input.js.map +1 -1
- package/web-components/input/split-input.d.ts +8 -15
- package/web-components/input/split-input.d.ts.map +1 -1
- package/web-components/input/split-input.js +82 -72
- package/web-components/input/split-input.js.map +1 -1
- package/web-components/input/switch-input.d.ts +8 -17
- package/web-components/input/switch-input.d.ts.map +1 -1
- package/web-components/input/switch-input.js +122 -158
- package/web-components/input/switch-input.js.map +1 -1
- package/web-components/layout/flex-flow.d.ts +11 -19
- package/web-components/layout/flex-flow.d.ts.map +1 -1
- package/web-components/layout/flex-flow.js +57 -35
- package/web-components/layout/flex-flow.js.map +1 -1
- package/web-components/layout/grid-flow.d.ts +14 -0
- package/web-components/layout/grid-flow.d.ts.map +1 -0
- package/web-components/layout/grid-flow.js +56 -0
- package/web-components/layout/grid-flow.js.map +1 -0
- package/web-components/layout/layout.d.ts +18 -0
- package/web-components/layout/layout.d.ts.map +1 -0
- package/web-components/layout/layout.js +76 -0
- package/web-components/layout/layout.js.map +1 -0
- package/web-components/link/link.d.ts +10 -0
- package/web-components/link/link.d.ts.map +1 -0
- package/web-components/link/link.js +17 -0
- package/web-components/link/link.js.map +1 -0
- package/web-components/link/router-link.d.ts +19 -0
- package/web-components/link/router-link.d.ts.map +1 -0
- package/web-components/link/router-link.js +60 -0
- package/web-components/link/router-link.js.map +1 -0
- package/web-components/progress/progress.d.ts +2 -12
- package/web-components/progress/progress.d.ts.map +1 -1
- package/web-components/progress/progress.js +52 -48
- package/web-components/progress/progress.js.map +1 -1
- package/web-components/router/router.d.ts +15 -21
- package/web-components/router/router.d.ts.map +1 -1
- package/web-components/router/router.js +35 -37
- package/web-components/router/router.js.map +1 -1
- package/web-components/skeleton/skeleton.d.ts +5 -12
- package/web-components/skeleton/skeleton.d.ts.map +1 -1
- package/web-components/skeleton/skeleton.js +90 -98
- package/web-components/skeleton/skeleton.js.map +1 -1
- package/web-components/text/overbreath.d.ts +15 -20
- package/web-components/text/overbreath.d.ts.map +1 -1
- package/web-components/text/overbreath.js +108 -202
- package/web-components/text/overbreath.js.map +1 -1
- package/web-components/text/text.d.ts +5 -18
- package/web-components/text/text.d.ts.map +1 -1
- package/web-components/text/text.js +70 -80
- package/web-components/text/text.js.map +1 -1
- package/web-components/text/time.d.ts +5 -14
- package/web-components/text/time.d.ts.map +1 -1
- package/web-components/text/time.js +32 -31
- package/web-components/text/time.js.map +1 -1
- package/web-components/text/typewriter.d.ts +3 -11
- package/web-components/text/typewriter.d.ts.map +1 -1
- package/web-components/text/typewriter.js +42 -40
- package/web-components/text/typewriter.js.map +1 -1
- package/web-components/tooltip/tooltip.d.ts +21 -17
- package/web-components/tooltip/tooltip.d.ts.map +1 -1
- package/web-components/tooltip/tooltip.js +98 -60
- package/web-components/tooltip/tooltip.js.map +1 -1
- package/web-components/wrapper/dragbox.d.ts +5 -10
- package/web-components/wrapper/dragbox.d.ts.map +1 -1
- package/web-components/wrapper/dragbox.js +40 -31
- package/web-components/wrapper/dragbox.js.map +1 -1
- package/web-components/wrapper/rotate.d.ts +30 -0
- package/web-components/wrapper/rotate.d.ts.map +1 -0
- package/web-components/wrapper/rotate.js +92 -0
- package/web-components/wrapper/rotate.js.map +1 -0
- package/.deps.js.map +0 -1
- package/a.d.ts +0 -2
- package/a.d.ts.map +0 -1
- package/a.js +0 -2
- package/a.js.map +0 -1
- package/clip.d.ts +0 -2
- package/clip.d.ts.map +0 -1
- package/clip.js +0 -2
- package/clip.js.map +0 -1
- package/decorators/define.d.ts +0 -7
- package/decorators/define.d.ts.map +0 -1
- package/decorators/define.js +0 -11
- package/decorators/define.js.map +0 -1
- package/details-group.d.ts +0 -2
- package/details-group.d.ts.map +0 -1
- package/details-group.js +0 -2
- package/details-group.js.map +0 -1
- package/godown-element.d.ts.map +0 -1
- package/godown-element.js.map +0 -1
- package/lib/event-collection.d.ts +0 -14
- package/lib/event-collection.d.ts.map +0 -1
- package/lib/event-collection.js +0 -71
- package/lib/event-collection.js.map +0 -1
- package/lib/templates.d.ts.map +0 -1
- package/lib/templates.js +0 -76
- package/lib/templates.js.map +0 -1
- package/naming.d.ts +0 -91
- package/naming.d.ts.map +0 -1
- package/naming.js +0 -67
- package/naming.js.map +0 -1
- package/nav-layout.d.ts +0 -2
- package/nav-layout.d.ts.map +0 -1
- package/nav-layout.js +0 -2
- package/nav-layout.js.map +0 -1
- package/open-offset.d.ts +0 -2
- package/open-offset.d.ts.map +0 -1
- package/open-offset.js +0 -2
- package/open-offset.js.map +0 -1
- package/router-a.d.ts +0 -2
- package/router-a.d.ts.map +0 -1
- package/router-a.js +0 -2
- package/router-a.js.map +0 -1
- package/supers/anchor.d.ts +0 -26
- package/supers/anchor.d.ts.map +0 -1
- package/supers/anchor.js +0 -124
- package/supers/anchor.js.map +0 -1
- package/supers/input.d.ts +0 -28
- package/supers/input.d.ts.map +0 -1
- package/supers/input.js +0 -117
- package/supers/input.js.map +0 -1
- package/supers/openable.d.ts +0 -38
- package/supers/openable.d.ts.map +0 -1
- package/supers/openable.js +0 -77
- package/supers/openable.js.map +0 -1
- package/supers/root.d.ts +0 -18
- package/supers/root.d.ts.map +0 -1
- package/supers/root.js +0 -76
- package/supers/root.js.map +0 -1
- package/tabs.d.ts +0 -2
- package/tabs.d.ts.map +0 -1
- package/tabs.js +0 -2
- package/tabs.js.map +0 -1
- package/web-components/a/a.d.ts +0 -16
- package/web-components/a/a.d.ts.map +0 -1
- package/web-components/a/a.js +0 -17
- package/web-components/a/a.js.map +0 -1
- package/web-components/group/avatar-group.d.ts +0 -29
- package/web-components/group/avatar-group.d.ts.map +0 -1
- package/web-components/group/avatar-group.js +0 -88
- package/web-components/group/avatar-group.js.map +0 -1
- package/web-components/group/details-group.d.ts +0 -28
- package/web-components/group/details-group.d.ts.map +0 -1
- package/web-components/group/details-group.js +0 -59
- package/web-components/group/details-group.js.map +0 -1
- package/web-components/index.d.ts +0 -35
- package/web-components/index.d.ts.map +0 -1
- package/web-components/index.js +0 -35
- package/web-components/index.js.map +0 -1
- package/web-components/layout/divider.d.ts +0 -22
- package/web-components/layout/divider.d.ts.map +0 -1
- package/web-components/layout/divider.js +0 -85
- package/web-components/layout/divider.js.map +0 -1
- package/web-components/layout/nav-layout.d.ts +0 -38
- package/web-components/layout/nav-layout.d.ts.map +0 -1
- package/web-components/layout/nav-layout.js +0 -69
- package/web-components/layout/nav-layout.js.map +0 -1
- package/web-components/offset/open-offset.d.ts +0 -27
- package/web-components/offset/open-offset.d.ts.map +0 -1
- package/web-components/offset/open-offset.js +0 -130
- package/web-components/offset/open-offset.js.map +0 -1
- package/web-components/router/router-a.d.ts +0 -25
- package/web-components/router/router-a.d.ts.map +0 -1
- package/web-components/router/router-a.js +0 -70
- package/web-components/router/router-a.js.map +0 -1
- package/web-components/tabs/tabs.d.ts +0 -52
- package/web-components/tabs/tabs.d.ts.map +0 -1
- package/web-components/tabs/tabs.js +0 -165
- package/web-components/tabs/tabs.js.map +0 -1
- package/web-components/text/clip.d.ts +0 -22
- package/web-components/text/clip.d.ts.map +0 -1
- package/web-components/text/clip.js +0 -45
- package/web-components/text/clip.js.map +0 -1
- package/web-components/wrapper/wrapper.d.ts +0 -27
- package/web-components/wrapper/wrapper.d.ts.map +0 -1
- package/web-components/wrapper/wrapper.js +0 -95
- package/web-components/wrapper/wrapper.js.map +0 -1
- package/wrapper.d.ts +0 -2
- package/wrapper.d.ts.map +0 -1
- package/wrapper.js +0 -2
- package/wrapper.js.map +0 -1
@@ -1,15 +1,17 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
|
-
import { css, html, property, query, queryAll } from "
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import
|
2
|
+
import { css, html, property, query, queryAll } from "../../_deps.js";
|
3
|
+
import { godown } from "../../decorators/godown.js";
|
4
|
+
import { styles } from "../../decorators/styles.js";
|
5
|
+
import GodownSuperInput from "../../proto/super-input.js";
|
6
|
+
import { createScope, cssGlobalVars } from "../../styles/global.js";
|
7
|
+
import { inputStyle } from "../../styles/inputStyle.js";
|
6
8
|
const FOCUS = "focus";
|
7
|
-
const
|
8
|
-
const cssScope = createScope(
|
9
|
+
const protoName = "split-input";
|
10
|
+
const cssScope = createScope(protoName);
|
9
11
|
/**
|
10
12
|
* {@linkcode SplitInput } renders multiple inputs.
|
11
13
|
*/
|
12
|
-
let SplitInput = class SplitInput extends
|
14
|
+
let SplitInput = class SplitInput extends GodownSuperInput {
|
13
15
|
constructor() {
|
14
16
|
super(...arguments);
|
15
17
|
/**
|
@@ -25,11 +27,18 @@ let SplitInput = class SplitInput extends GodownInput {
|
|
25
27
|
}
|
26
28
|
render() {
|
27
29
|
return html `
|
28
|
-
<div>
|
30
|
+
<div part="root">
|
29
31
|
${Array(this.max)
|
30
32
|
.fill(0)
|
31
|
-
.map(() => html `<span><i></i></span>`)}
|
32
|
-
<input
|
33
|
+
.map(() => html `<span part="outline"><i part="inside"></i></span>`)}
|
34
|
+
<input
|
35
|
+
part="input"
|
36
|
+
id="${this.makeId}"
|
37
|
+
@blur=${() => {
|
38
|
+
this.blurAt(this.current);
|
39
|
+
}}
|
40
|
+
@input="${this._handleInput}"
|
41
|
+
/>
|
33
42
|
</div>
|
34
43
|
`;
|
35
44
|
}
|
@@ -39,15 +48,10 @@ let SplitInput = class SplitInput extends GodownInput {
|
|
39
48
|
this._spans.forEach((span, index) => {
|
40
49
|
this.addEvent(span, "click", () => {
|
41
50
|
this.current = index;
|
42
|
-
this.focusAt();
|
51
|
+
this.focusAt(this.current);
|
43
52
|
this._input.focus();
|
44
53
|
});
|
45
54
|
});
|
46
|
-
this.addEvent(document, "click", (e) => {
|
47
|
-
if (!this.contains(e.target)) {
|
48
|
-
this.blur();
|
49
|
-
}
|
50
|
-
});
|
51
55
|
}
|
52
56
|
_handleInput(e) {
|
53
57
|
if (e.data === null) {
|
@@ -64,7 +68,7 @@ let SplitInput = class SplitInput extends GodownInput {
|
|
64
68
|
if (this.current + 1 >= this.max) {
|
65
69
|
this.current = this.currentValue.indexOf(null);
|
66
70
|
if (this.current === -1) {
|
67
|
-
this.
|
71
|
+
this.blurAt(this.current);
|
68
72
|
}
|
69
73
|
}
|
70
74
|
else {
|
@@ -80,16 +84,19 @@ let SplitInput = class SplitInput extends GodownInput {
|
|
80
84
|
this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
|
81
85
|
}
|
82
86
|
focus() {
|
83
|
-
this.focusAt();
|
87
|
+
this.focusAt(this.current);
|
84
88
|
}
|
85
|
-
focusAt(i
|
89
|
+
focusAt(i) {
|
86
90
|
this._spans.forEach((span) => {
|
87
91
|
span.classList.remove(FOCUS);
|
88
92
|
});
|
89
93
|
this._spans[i]?.classList.add(FOCUS);
|
90
94
|
this._input.value = "";
|
91
95
|
}
|
92
|
-
blur(
|
96
|
+
blur() {
|
97
|
+
this.blurAt(this.current);
|
98
|
+
}
|
99
|
+
blurAt(i) {
|
93
100
|
this._spans[i]?.classList.remove(FOCUS);
|
94
101
|
this._input.blur();
|
95
102
|
}
|
@@ -103,57 +110,6 @@ let SplitInput = class SplitInput extends GodownInput {
|
|
103
110
|
this.dispatchEvent(new CustomEvent("change", { detail: this.value }));
|
104
111
|
}
|
105
112
|
};
|
106
|
-
SplitInput.styles = [
|
107
|
-
GodownInput.styles,
|
108
|
-
css `
|
109
|
-
:host {
|
110
|
-
${cssScope}--outline: .15em solid var( ${cssvarValues.input}--outline-color);
|
111
|
-
margin: var(${cssvarValues.input}--outline-width);
|
112
|
-
width: fit-content;
|
113
|
-
border-radius: 1px;
|
114
|
-
}
|
115
|
-
|
116
|
-
* {
|
117
|
-
font-size: 1em;
|
118
|
-
border-radius: inherit;
|
119
|
-
}
|
120
|
-
|
121
|
-
div {
|
122
|
-
vertical-align: top;
|
123
|
-
position: relative;
|
124
|
-
display: inline-flex;
|
125
|
-
gap: 0.25em;
|
126
|
-
}
|
127
|
-
|
128
|
-
span {
|
129
|
-
box-sizing: content-box;
|
130
|
-
vertical-align: top;
|
131
|
-
display: inline-flex;
|
132
|
-
width: 1.45em;
|
133
|
-
height: 1.45em;
|
134
|
-
pointer-events: all;
|
135
|
-
}
|
136
|
-
|
137
|
-
i {
|
138
|
-
height: inherit;
|
139
|
-
width: 100%;
|
140
|
-
z-index: 1;
|
141
|
-
background-color: var(${cssvarValues.input}--false);
|
142
|
-
text-align: center;
|
143
|
-
}
|
144
|
-
|
145
|
-
input {
|
146
|
-
position: absolute;
|
147
|
-
opacity: 0;
|
148
|
-
left: 0;
|
149
|
-
top: 0;
|
150
|
-
}
|
151
|
-
|
152
|
-
.focus i {
|
153
|
-
outline: var(${cssScope}--outline);
|
154
|
-
}
|
155
|
-
`,
|
156
|
-
];
|
157
113
|
__decorate([
|
158
114
|
property({ type: Number })
|
159
115
|
], SplitInput.prototype, "max", void 0);
|
@@ -167,7 +123,61 @@ __decorate([
|
|
167
123
|
queryAll("span")
|
168
124
|
], SplitInput.prototype, "_spans", void 0);
|
169
125
|
SplitInput = __decorate([
|
170
|
-
|
126
|
+
godown(protoName),
|
127
|
+
styles([
|
128
|
+
inputStyle,
|
129
|
+
css `
|
130
|
+
:host {
|
131
|
+
--${cssScope}--outline: .15em solid var( --${cssGlobalVars.input}--outline-color);
|
132
|
+
margin: var(--${cssGlobalVars.input}--outline-width);
|
133
|
+
color: var(--${cssGlobalVars.foreground});
|
134
|
+
display: inline-block;
|
135
|
+
width: -moz-fit-content;
|
136
|
+
width: fit-content;
|
137
|
+
border-radius: 1px;
|
138
|
+
}
|
139
|
+
|
140
|
+
* {
|
141
|
+
font-size: 1em;
|
142
|
+
border-radius: inherit;
|
143
|
+
}
|
144
|
+
|
145
|
+
div {
|
146
|
+
gap: 0.25em;
|
147
|
+
position: relative;
|
148
|
+
vertical-align: top;
|
149
|
+
display: inline-flex;
|
150
|
+
}
|
151
|
+
|
152
|
+
span {
|
153
|
+
width: 1.45em;
|
154
|
+
height: 1.45em;
|
155
|
+
vertical-align: top;
|
156
|
+
display: inline-flex;
|
157
|
+
box-sizing: content-box;
|
158
|
+
}
|
159
|
+
|
160
|
+
i {
|
161
|
+
z-index: 1;
|
162
|
+
width: 100%;
|
163
|
+
height: inherit;
|
164
|
+
text-align: center;
|
165
|
+
background-color: var(--${cssGlobalVars.input}--background);
|
166
|
+
}
|
167
|
+
|
168
|
+
input {
|
169
|
+
width: 100%;
|
170
|
+
height: 100%;
|
171
|
+
opacity: 0;
|
172
|
+
background: none;
|
173
|
+
position: absolute;
|
174
|
+
}
|
175
|
+
|
176
|
+
.focus i {
|
177
|
+
outline: var(--${cssScope}--outline);
|
178
|
+
}
|
179
|
+
`,
|
180
|
+
])
|
171
181
|
], SplitInput);
|
172
182
|
export { SplitInput };
|
173
183
|
export default SplitInput;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"split-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/split-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,
|
1
|
+
{"version":3,"file":"split-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/split-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAA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U,CAuGtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, html, property, query, queryAll } from \"../../_deps.js\";\nimport { godown } from \"../../decorators/godown.js\";\nimport { styles } from \"../../decorators/styles.js\";\nimport { type HTMLEvent } from \"../../proto/godown-element\";\nimport GodownSuperInput from \"../../proto/super-input.js\";\nimport { createScope, cssGlobalVars } from \"../../styles/global.js\";\nimport { inputStyle } from \"../../styles/inputStyle.js\";\n\nconst FOCUS = \"focus\";\n\nconst protoName = \"split-input\";\n\nconst cssScope = createScope(protoName);\n\n/**\n * {@linkcode SplitInput } renders multiple inputs.\n */\n@godown(protoName)\n@styles([\n inputStyle,\n css`\n :host {\n --${cssScope}--outline: .15em solid var( --${cssGlobalVars.input}--outline-color);\n margin: var(--${cssGlobalVars.input}--outline-width);\n color: var(--${cssGlobalVars.foreground});\n display: inline-block;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 1px;\n }\n\n * {\n font-size: 1em;\n border-radius: inherit;\n }\n\n div {\n gap: 0.25em;\n position: relative;\n vertical-align: top;\n display: inline-flex;\n }\n\n span {\n width: 1.45em;\n height: 1.45em;\n vertical-align: top;\n display: inline-flex;\n box-sizing: content-box;\n }\n\n i {\n z-index: 1;\n width: 100%;\n height: inherit;\n text-align: center;\n background-color: var(--${cssGlobalVars.input}--background);\n }\n\n input {\n width: 100%;\n height: 100%;\n opacity: 0;\n background: none;\n position: absolute;\n }\n\n .focus i {\n outline: var(--${cssScope}--outline);\n }\n `,\n])\nexport class SplitInput extends GodownSuperInput {\n /**\n * The number of simulated input boxes.\n */\n @property({ type: Number }) max = 6;\n /**\n * Active index.\n */\n @property({ type: Number }) index = -1;\n\n @query(\"input\") _input: HTMLInputElement;\n @queryAll(\"span\") _spans: NodeListOf<HTMLSpanElement>;\n current = 0;\n currentValue: (string | null)[] = [];\n\n protected render() {\n return html`\n <div part=\"root\">\n ${Array(this.max)\n .fill(0)\n .map(() => html`<span part=\"outline\"><i part=\"inside\"></i></span>`)}\n <input\n part=\"input\"\n id=\"${this.makeId}\"\n @blur=${() => {\n this.blurAt(this.current);\n }}\n @input=\"${this._handleInput}\"\n />\n </div>\n `;\n }\n\n protected firstUpdated() {\n this.currentValue = this.value.split(\"\").concat(Array(this.max - this.value.length).fill(null));\n this.current = this.index < 0 || this.index > this.max ? this.currentValue.indexOf(null) : this.index;\n this._spans.forEach((span, index) => {\n this.addEvent(span, \"click\", () => {\n this.current = index;\n this.focusAt(this.current);\n this._input.focus();\n });\n });\n }\n\n protected _handleInput(e: HTMLEvent<HTMLInputElement>) {\n if (e.data === null) {\n if (this.currentValue[this.current] !== null) {\n this.currentValue[this.current] = null;\n } else {\n this.currentValue[this.current - 1] = null;\n this.current = this.current - 1 < 0 ? 0 : this.current - 1;\n }\n } else {\n this.currentValue[this.current] = e.data as string;\n if (this.current + 1 >= this.max) {\n this.current = this.currentValue.indexOf(null);\n if (this.current === -1) {\n this.blurAt(this.current);\n }\n } else {\n this.current += 1;\n }\n }\n this.focus();\n this._spans.forEach((span, index) => {\n span.querySelector(\"i\").innerText = this.currentValue[index] || \"\";\n });\n this.value = this.currentValue.join(\"\");\n this.dispatchEvent(new CustomEvent(\"input\", { detail: this.value, bubbles: true, composed: true }));\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.value, composed: true }));\n }\n\n focus() {\n this.focusAt(this.current);\n }\n\n focusAt(i: number) {\n this._spans.forEach((span) => {\n span.classList.remove(FOCUS);\n });\n this._spans[i]?.classList.add(FOCUS);\n this._input.value = \"\";\n }\n\n blur() {\n this.blurAt(this.current);\n }\n\n blurAt(i: number) {\n this._spans[i]?.classList.remove(FOCUS);\n this._input.blur();\n }\n\n reset() {\n this.currentValue = Array(this.max).fill(null);\n this.current = 0;\n this._spans.forEach((span) => {\n span.querySelector(\"i\").innerText = \"\";\n });\n this.value = \"\";\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.value }));\n }\n}\n\nexport default SplitInput;\n"]}
|
@@ -1,6 +1,4 @@
|
|
1
|
-
import
|
2
|
-
import { type HTMLTemplate } from "../../lib/templates.js";
|
3
|
-
import { GodownInput } from "../../supers/input.js";
|
1
|
+
import GodownInput from "../../proto/super-input.js";
|
4
2
|
/**
|
5
3
|
* {@linkcode SwitchInput } renders a switch.
|
6
4
|
*
|
@@ -8,9 +6,13 @@ import { GodownInput } from "../../supers/input.js";
|
|
8
6
|
*/
|
9
7
|
export declare class SwitchInput extends GodownInput {
|
10
8
|
/**
|
11
|
-
*
|
9
|
+
* @deprecated
|
12
10
|
*/
|
13
11
|
base: "fat" | "rect";
|
12
|
+
/**
|
13
|
+
* Border style.
|
14
|
+
*/
|
15
|
+
round: boolean;
|
14
16
|
/**
|
15
17
|
* Whether this element is selected or not.
|
16
18
|
*/
|
@@ -22,28 +24,17 @@ export declare class SwitchInput extends GodownInput {
|
|
22
24
|
/**
|
23
25
|
* Parsed by JSON.parse to checked.
|
24
26
|
*/
|
25
|
-
|
26
|
-
/**
|
27
|
-
* Input name.
|
28
|
-
*/
|
29
|
-
name: string;
|
27
|
+
default: string;
|
30
28
|
/**
|
31
29
|
* Input value.
|
32
30
|
*/
|
33
31
|
value: string;
|
34
32
|
_input: HTMLInputElement;
|
35
|
-
|
36
|
-
protected render(): HTMLTemplate;
|
33
|
+
protected render(): import("lit").TemplateResult<1>;
|
37
34
|
reset(): void;
|
38
35
|
connectedCallback(): void;
|
39
36
|
protected _handleChange(): void;
|
40
37
|
namevalue(): [string, boolean];
|
41
38
|
}
|
42
39
|
export default SwitchInput;
|
43
|
-
declare global {
|
44
|
-
interface HTMLElementTagNameMap {
|
45
|
-
"switch-input": SwitchInput;
|
46
|
-
"g-switch-input": SwitchInput;
|
47
|
-
}
|
48
|
-
}
|
49
40
|
//# sourceMappingURL=switch-input.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"switch-input.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/switch-input.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"switch-input.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/switch-input.ts"],"names":[],"mappings":"AAGA,OAAO,WAAW,MAAM,4BAA4B,CAAC;AAMrD;;;;GAIG;AACH,qBA0Fa,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB;;OAEG;IAEyC,KAAK,UAAS;IAC1D;;OAEG;IACyC,OAAO,UAAS;IAC5D;;OAEG;IACyC,QAAQ,UAAS;IAC7D;;OAEG;IACS,OAAO,SAAW;IAC9B;;OAEG;IACS,KAAK,SAAQ;IAET,MAAM,EAAE,gBAAgB,CAAC;IAEzC,SAAS,CAAC,MAAM;IAiBhB,KAAK;IAKL,iBAAiB;IAUjB,SAAS,CAAC,aAAa;IAMvB,SAAS,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;CAG/B;AAED,eAAe,WAAW,CAAC"}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
|
-
import { css, html, property, query } from "
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
|
8
|
-
const
|
2
|
+
import { css, html, property, query } from "../../_deps.js";
|
3
|
+
import { godown } from "../../decorators/godown.js";
|
4
|
+
import { styles } from "../../decorators/styles.js";
|
5
|
+
import GodownInput from "../../proto/super-input.js";
|
6
|
+
import { cssGlobalVars } from "../../styles/global.js";
|
7
|
+
import { inputStyle } from "../../styles/inputStyle.js";
|
8
|
+
const protoName = "switch-input";
|
9
9
|
/**
|
10
10
|
* {@linkcode SwitchInput } renders a switch.
|
11
11
|
*
|
@@ -17,7 +17,8 @@ let SwitchInput = class SwitchInput extends GodownInput {
|
|
17
17
|
/**
|
18
18
|
* Border style.
|
19
19
|
*/
|
20
|
-
|
20
|
+
// @property() variant: "fat" | "rect" = "rect";
|
21
|
+
this.round = false;
|
21
22
|
/**
|
22
23
|
* Whether this element is selected or not.
|
23
24
|
*/
|
@@ -29,36 +30,38 @@ let SwitchInput = class SwitchInput extends GodownInput {
|
|
29
30
|
/**
|
30
31
|
* Parsed by JSON.parse to checked.
|
31
32
|
*/
|
32
|
-
this.
|
33
|
-
/**
|
34
|
-
* Input name.
|
35
|
-
*/
|
36
|
-
this.name = "checkbox";
|
33
|
+
this.default = "false";
|
37
34
|
/**
|
38
35
|
* Input value.
|
39
36
|
*/
|
40
37
|
this.value = "on";
|
41
38
|
}
|
42
39
|
render() {
|
43
|
-
return html `<
|
44
|
-
<input
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
40
|
+
return html `<div part="root" class="${this.round ? "round" : "rect"}">
|
41
|
+
<input
|
42
|
+
part="input"
|
43
|
+
@change="${this._handleChange}"
|
44
|
+
?disabled="${this.disabled}"
|
45
|
+
?checked="${this.checked}"
|
46
|
+
name="${this.name}"
|
47
|
+
id="${this.makeId}"
|
48
|
+
type="checkbox"
|
49
|
+
/>
|
50
|
+
<span>
|
51
|
+
<i class="${this.checked}"><i></i></i>
|
52
|
+
</span>
|
53
|
+
</div>`;
|
51
54
|
}
|
52
55
|
reset() {
|
53
|
-
this.checked = this.
|
56
|
+
this.checked = this.default === "true";
|
54
57
|
this._input.checked = this.checked;
|
55
58
|
}
|
56
59
|
connectedCallback() {
|
57
60
|
super.connectedCallback();
|
58
61
|
if (this.checked) {
|
59
|
-
this.
|
62
|
+
this.default = "true";
|
60
63
|
}
|
61
|
-
|
64
|
+
if (this.default === "true") {
|
62
65
|
this.checked = true;
|
63
66
|
}
|
64
67
|
}
|
@@ -71,146 +74,18 @@ let SwitchInput = class SwitchInput extends GodownInput {
|
|
71
74
|
return [this.name, this.checked];
|
72
75
|
}
|
73
76
|
};
|
74
|
-
SwitchInput.styles = [
|
75
|
-
GodownInput.styles,
|
76
|
-
css `
|
77
|
-
:host {
|
78
|
-
${cssScope}--width: 3em;
|
79
|
-
${cssScope}--height: calc(var(${cssScope}--width) / 2);
|
80
|
-
width: var(${cssScope}--width);
|
81
|
-
height: var(${cssScope}--height);
|
82
|
-
}
|
83
|
-
|
84
|
-
:host,
|
85
|
-
span {
|
86
|
-
display: inline-flex;
|
87
|
-
font-size: inherit;
|
88
|
-
position: relative;
|
89
|
-
align-items: center;
|
90
|
-
border-radius: inherit;
|
91
|
-
}
|
92
|
-
|
93
|
-
span {
|
94
|
-
width: inherit;
|
95
|
-
height: inherit;
|
96
|
-
}
|
97
|
-
|
98
|
-
input {
|
99
|
-
width: inherit;
|
100
|
-
height: inherit;
|
101
|
-
margin: 0;
|
102
|
-
outline: none;
|
103
|
-
appearance: none;
|
104
|
-
-webkit-appearance: none;
|
105
|
-
-moz-appearance: none;
|
106
|
-
position: relative;
|
107
|
-
font-size: inherit;
|
108
|
-
background: var(${cssvarValues.input}--false);
|
109
|
-
border-radius: inherit;
|
110
|
-
transition: all 0.3s;
|
111
|
-
}
|
112
|
-
|
113
|
-
aside {
|
114
|
-
pointer-events: none;
|
115
|
-
transition: 0.3s;
|
116
|
-
display: inline-flex;
|
117
|
-
align-items: center;
|
118
|
-
justify-content: center;
|
119
|
-
position: absolute;
|
120
|
-
font-size: inherit;
|
121
|
-
overflow: hidden;
|
122
|
-
border-radius: inherit;
|
123
|
-
}
|
124
|
-
|
125
|
-
aside div {
|
126
|
-
height: 100%;
|
127
|
-
}
|
128
|
-
|
129
|
-
input[disabled] ~ aside {
|
130
|
-
filter: brightness(0.87);
|
131
|
-
}
|
132
|
-
|
133
|
-
.rect div.always {
|
134
|
-
display: none;
|
135
|
-
}
|
136
|
-
|
137
|
-
.always {
|
138
|
-
position: absolute;
|
139
|
-
}
|
140
|
-
|
141
|
-
.rect aside {
|
142
|
-
height: 100%;
|
143
|
-
width: 100%;
|
144
|
-
left: 0;
|
145
|
-
}
|
146
|
-
|
147
|
-
.rect .true,
|
148
|
-
.rect .false {
|
149
|
-
width: 50%;
|
150
|
-
text-align: center;
|
151
|
-
transition: all 0.3s;
|
152
|
-
}
|
153
|
-
|
154
|
-
.rect input:checked ~ aside div.true,
|
155
|
-
.rect .false {
|
156
|
-
background-color: var(${cssvarValues.input}--true);
|
157
|
-
}
|
158
|
-
|
159
|
-
.rect input:checked ~ aside div.false,
|
160
|
-
.rect .true {
|
161
|
-
background: var(${cssvarValues.input}--false);
|
162
|
-
}
|
163
|
-
|
164
|
-
.fat aside {
|
165
|
-
width: 1.2em;
|
166
|
-
height: 1.2em;
|
167
|
-
border-radius: 50%;
|
168
|
-
background: var(${cssvarValues.input}--control);
|
169
|
-
transition: 0.3s;
|
170
|
-
left: 0.15em;
|
171
|
-
top: 0.15em;
|
172
|
-
bottom: 0.15em;
|
173
|
-
}
|
174
|
-
|
175
|
-
.fat {
|
176
|
-
border-radius: 0.75em;
|
177
|
-
}
|
178
|
-
|
179
|
-
.fat input:checked {
|
180
|
-
background: var(${cssvarValues.input}--true);
|
181
|
-
}
|
182
|
-
|
183
|
-
.fat input:checked ~ aside {
|
184
|
-
left: calc(100% - 0.15em - 1.2em);
|
185
|
-
right: 0.15em;
|
186
|
-
}
|
187
|
-
|
188
|
-
.fat input:checked ~ aside div.true,
|
189
|
-
.fat div.false {
|
190
|
-
display: block;
|
191
|
-
}
|
192
|
-
|
193
|
-
.fat input:checked ~ aside div.false,
|
194
|
-
.fat div.true {
|
195
|
-
display: none;
|
196
|
-
}
|
197
|
-
`,
|
198
|
-
];
|
199
77
|
__decorate([
|
200
|
-
property()
|
201
|
-
], SwitchInput.prototype, "
|
78
|
+
property({ type: Boolean, reflect: true })
|
79
|
+
], SwitchInput.prototype, "round", void 0);
|
202
80
|
__decorate([
|
203
|
-
property({ type: Boolean })
|
81
|
+
property({ type: Boolean, reflect: true })
|
204
82
|
], SwitchInput.prototype, "checked", void 0);
|
205
83
|
__decorate([
|
206
|
-
property({ type: Boolean })
|
84
|
+
property({ type: Boolean, reflect: true })
|
207
85
|
], SwitchInput.prototype, "disabled", void 0);
|
208
86
|
__decorate([
|
209
87
|
property()
|
210
|
-
], SwitchInput.prototype, "
|
211
|
-
__decorate([
|
212
|
-
property()
|
213
|
-
], SwitchInput.prototype, "name", void 0);
|
88
|
+
], SwitchInput.prototype, "default", void 0);
|
214
89
|
__decorate([
|
215
90
|
property()
|
216
91
|
], SwitchInput.prototype, "value", void 0);
|
@@ -218,7 +93,96 @@ __decorate([
|
|
218
93
|
query("input")
|
219
94
|
], SwitchInput.prototype, "_input", void 0);
|
220
95
|
SwitchInput = __decorate([
|
221
|
-
|
96
|
+
godown(protoName),
|
97
|
+
styles([
|
98
|
+
inputStyle,
|
99
|
+
css `
|
100
|
+
:host {
|
101
|
+
--${cssGlobalVars.input}--width: 3em;
|
102
|
+
--${cssGlobalVars.input}--height: calc(var(--${cssGlobalVars.input}--width) / 2);
|
103
|
+
--${cssGlobalVars.input}--gap: calc(var(--${cssGlobalVars.input}--width) / 25);
|
104
|
+
--${cssGlobalVars.input}--transition: all .25s ease-in-out;
|
105
|
+
background: var(--${cssGlobalVars.input}--background);
|
106
|
+
width: var(--${cssGlobalVars.input}--width);
|
107
|
+
height: var(--${cssGlobalVars.input}--height);
|
108
|
+
display: inline-block;
|
109
|
+
vertical-align: bottom;
|
110
|
+
}
|
111
|
+
|
112
|
+
[part="root"],
|
113
|
+
span,
|
114
|
+
i {
|
115
|
+
transition: var(--${cssGlobalVars.input}--transition);
|
116
|
+
}
|
117
|
+
|
118
|
+
[part="root"] {
|
119
|
+
border-radius: inherit;
|
120
|
+
position: relative;
|
121
|
+
height: inherit;
|
122
|
+
}
|
123
|
+
|
124
|
+
[part="root"],
|
125
|
+
input,
|
126
|
+
i {
|
127
|
+
width: 100%;
|
128
|
+
}
|
129
|
+
|
130
|
+
input {
|
131
|
+
margin: 0;
|
132
|
+
height: 100%;
|
133
|
+
outline: none;
|
134
|
+
appearance: none;
|
135
|
+
-webkit-appearance: none;
|
136
|
+
-moz-appearance: none;
|
137
|
+
}
|
138
|
+
|
139
|
+
span {
|
140
|
+
height: 100%;
|
141
|
+
display: inline-flex;
|
142
|
+
position: absolute;
|
143
|
+
left: 0;
|
144
|
+
width: 50%;
|
145
|
+
pointer-events: none;
|
146
|
+
border-radius: inherit;
|
147
|
+
}
|
148
|
+
|
149
|
+
:host([round]) {
|
150
|
+
border-radius: calc(var(--${cssGlobalVars.input}--height) / 2);
|
151
|
+
}
|
152
|
+
|
153
|
+
:host([checked]) span {
|
154
|
+
transform: translateX(100%);
|
155
|
+
}
|
156
|
+
|
157
|
+
.rect * {
|
158
|
+
border-radius: inherit;
|
159
|
+
}
|
160
|
+
|
161
|
+
.rect .true {
|
162
|
+
background: var(--${cssGlobalVars.input}--true);
|
163
|
+
}
|
164
|
+
|
165
|
+
.rect .false {
|
166
|
+
background: var(--${cssGlobalVars.input}--false);
|
167
|
+
}
|
168
|
+
|
169
|
+
.round i {
|
170
|
+
border-radius: 100%;
|
171
|
+
margin: var(--${cssGlobalVars.input}--gap);
|
172
|
+
background: var(--${cssGlobalVars.input}--control);
|
173
|
+
width: calc(var(--${cssGlobalVars.input}--height) - var(--${cssGlobalVars.input}--gap) * 2);
|
174
|
+
height: calc(var(--${cssGlobalVars.input}--height) - var(--${cssGlobalVars.input}--gap) * 2);
|
175
|
+
}
|
176
|
+
|
177
|
+
.round {
|
178
|
+
background: var(--${cssGlobalVars.input}--false);
|
179
|
+
}
|
180
|
+
|
181
|
+
:host([checked]) .round {
|
182
|
+
background: var(--${cssGlobalVars.input}--true);
|
183
|
+
}
|
184
|
+
`,
|
185
|
+
])
|
222
186
|
], SwitchInput);
|
223
187
|
export { SwitchInput };
|
224
188
|
export default SwitchInput;
|