godown 2.7.7 → 3.0.0-canary.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 +44 -80
- package/alert.d.ts +2 -3
- package/alert.d.ts.map +1 -1
- package/alert.js +5 -4
- package/alert.js.map +1 -1
- package/avatar.d.ts +2 -3
- package/avatar.d.ts.map +1 -1
- package/avatar.js +5 -4
- package/avatar.js.map +1 -1
- package/breath.d.ts +9 -0
- package/breath.d.ts.map +1 -0
- package/breath.js +6 -0
- package/breath.js.map +1 -0
- package/button.d.ts +2 -3
- package/button.d.ts.map +1 -1
- package/button.js +5 -4
- package/button.js.map +1 -1
- package/card.d.ts +2 -3
- package/card.d.ts.map +1 -1
- package/card.js +5 -4
- package/card.js.map +1 -1
- package/carousel.d.ts +2 -3
- package/carousel.d.ts.map +1 -1
- package/carousel.js +5 -4
- package/carousel.js.map +1 -1
- package/components/alert.d.ts +50 -0
- package/components/alert.d.ts.map +1 -0
- package/components/alert.js +167 -0
- package/components/alert.js.map +1 -0
- package/components/avatar.d.ts +26 -0
- package/components/avatar.d.ts.map +1 -0
- package/components/avatar.js +62 -0
- package/components/avatar.js.map +1 -0
- package/components/breath.d.ts +34 -0
- package/components/breath.d.ts.map +1 -0
- package/components/breath.js +80 -0
- package/components/breath.js.map +1 -0
- package/{web-components/button → components}/button.d.ts +6 -5
- package/components/button.d.ts.map +1 -0
- package/components/button.js +167 -0
- package/components/button.js.map +1 -0
- package/components/card.d.ts +20 -0
- package/components/card.d.ts.map +1 -0
- package/components/card.js +55 -0
- package/components/card.js.map +1 -0
- package/components/carousel.d.ts +40 -0
- package/components/carousel.d.ts.map +1 -0
- package/components/carousel.js +113 -0
- package/components/carousel.js.map +1 -0
- package/{web-components/details → components}/details.d.ts +5 -3
- package/components/details.d.ts.map +1 -0
- package/components/details.js +50 -0
- package/components/details.js.map +1 -0
- package/components/dialog.d.ts +33 -0
- package/components/dialog.d.ts.map +1 -0
- package/components/dialog.js +92 -0
- package/components/dialog.js.map +1 -0
- package/components/divider.d.ts +17 -0
- package/components/divider.d.ts.map +1 -0
- package/components/divider.js +37 -0
- package/components/divider.js.map +1 -0
- package/{web-components/wrapper → components}/dragbox.d.ts +15 -5
- package/components/dragbox.d.ts.map +1 -0
- package/{web-components/wrapper → components}/dragbox.js +32 -27
- package/components/dragbox.js.map +1 -0
- package/components/flex.d.ts +31 -0
- package/components/flex.d.ts.map +1 -0
- package/components/flex.js +55 -0
- package/components/flex.js.map +1 -0
- package/{web-components/form → components}/form.d.ts +4 -2
- package/components/form.d.ts.map +1 -0
- package/{web-components/form → components}/form.js +16 -17
- package/components/form.js.map +1 -0
- package/components/grid.d.ts +31 -0
- package/components/grid.d.ts.map +1 -0
- package/components/grid.js +56 -0
- package/components/grid.js.map +1 -0
- package/components/input.d.ts +20 -0
- package/components/input.d.ts.map +1 -0
- package/components/input.js +54 -0
- package/components/input.js.map +1 -0
- package/components/layout.d.ts +29 -0
- package/components/layout.d.ts.map +1 -0
- package/components/layout.js +48 -0
- package/components/layout.js.map +1 -0
- package/components/link.d.ts +20 -0
- package/components/link.d.ts.map +1 -0
- package/components/link.js +43 -0
- package/components/link.js.map +1 -0
- package/{web-components/progress → components}/progress.d.ts +5 -3
- package/components/progress.d.ts.map +1 -0
- package/components/progress.js +68 -0
- package/components/progress.js.map +1 -0
- package/components/range.d.ts +60 -0
- package/components/range.d.ts.map +1 -0
- package/components/range.js +193 -0
- package/components/range.js.map +1 -0
- package/{web-components/wrapper → components}/rotate.d.ts +4 -8
- package/components/rotate.d.ts.map +1 -0
- package/components/rotate.js +57 -0
- package/components/rotate.js.map +1 -0
- package/components/router.d.ts +121 -0
- package/components/router.d.ts.map +1 -0
- package/components/router.js +251 -0
- package/components/router.js.map +1 -0
- package/components/select.d.ts +50 -0
- package/components/select.d.ts.map +1 -0
- package/components/select.js +211 -0
- package/components/select.js.map +1 -0
- package/{web-components/skeleton → components}/skeleton.d.ts +6 -6
- package/components/skeleton.d.ts.map +1 -0
- package/components/skeleton.js +56 -0
- package/components/skeleton.js.map +1 -0
- package/components/split.d.ts +32 -0
- package/components/split.d.ts.map +1 -0
- package/components/split.js +121 -0
- package/components/split.js.map +1 -0
- package/{web-components/input/switch-input.d.ts → components/switch.d.ts} +9 -10
- package/components/switch.d.ts.map +1 -0
- package/components/switch.js +93 -0
- package/components/switch.js.map +1 -0
- package/{web-components/text → components}/text.d.ts +5 -3
- package/components/text.d.ts.map +1 -0
- package/components/text.js +44 -0
- package/components/text.js.map +1 -0
- package/{web-components/text → components}/time.d.ts +5 -3
- package/components/time.d.ts.map +1 -0
- package/{web-components/text → components}/time.js +18 -21
- package/components/time.js.map +1 -0
- package/components/tooltip.d.ts +38 -0
- package/components/tooltip.d.ts.map +1 -0
- package/components/tooltip.js +67 -0
- package/components/tooltip.js.map +1 -0
- package/{web-components/text → components}/typewriter.d.ts +5 -3
- package/components/typewriter.d.ts.map +1 -0
- package/{web-components/text → components}/typewriter.js +24 -48
- package/components/typewriter.js.map +1 -0
- package/core/global-style.d.ts +21 -0
- package/core/global-style.d.ts.map +1 -0
- package/core/global-style.js +46 -0
- package/core/global-style.js.map +1 -0
- package/core/super-anchor.d.ts +15 -0
- package/core/super-anchor.d.ts.map +1 -0
- package/core/super-anchor.js +39 -0
- package/core/super-anchor.js.map +1 -0
- package/core/super-input.d.ts +39 -0
- package/core/super-input.d.ts.map +1 -0
- package/core/super-input.js +115 -0
- package/core/super-input.js.map +1 -0
- package/{proto → core}/super-openable.d.ts +4 -8
- package/core/super-openable.d.ts.map +1 -0
- package/{proto → core}/super-openable.js +10 -15
- package/core/super-openable.js.map +1 -0
- package/custom-elements.json +1 -0
- package/details.d.ts +2 -3
- package/details.d.ts.map +1 -1
- package/details.js +5 -4
- package/details.js.map +1 -1
- package/dialog.d.ts +2 -3
- package/dialog.d.ts.map +1 -1
- package/dialog.js +5 -4
- package/dialog.js.map +1 -1
- package/divider.d.ts +2 -3
- package/divider.d.ts.map +1 -1
- package/divider.js +5 -4
- package/divider.js.map +1 -1
- package/dragbox.d.ts +2 -3
- package/dragbox.d.ts.map +1 -1
- package/dragbox.js +5 -4
- package/dragbox.js.map +1 -1
- package/flex.d.ts +8 -0
- package/flex.d.ts.map +1 -0
- package/flex.js +6 -0
- package/flex.js.map +1 -0
- package/form.d.ts +2 -3
- package/form.d.ts.map +1 -1
- package/form.js +5 -4
- package/form.js.map +1 -1
- package/grid.d.ts +8 -0
- package/grid.d.ts.map +1 -0
- package/grid.js +6 -0
- package/grid.js.map +1 -0
- package/index.d.ts +28 -32
- package/index.d.ts.map +1 -1
- package/index.js +57 -33
- package/index.js.map +1 -1
- package/input.d.ts +3 -3
- package/input.d.ts.map +1 -1
- package/input.js +5 -4
- package/input.js.map +1 -1
- package/layout.d.ts +3 -3
- package/layout.d.ts.map +1 -1
- package/layout.js +5 -4
- package/layout.js.map +1 -1
- package/link.d.ts +3 -3
- package/link.d.ts.map +1 -1
- package/link.js +5 -4
- package/link.js.map +1 -1
- package/package.json +42 -81
- package/progress.d.ts +3 -3
- package/progress.d.ts.map +1 -1
- package/progress.js +5 -4
- package/progress.js.map +1 -1
- package/range.d.ts +9 -0
- package/range.d.ts.map +1 -0
- package/range.js +6 -0
- package/range.js.map +1 -0
- package/rotate.d.ts +3 -3
- package/rotate.d.ts.map +1 -1
- package/rotate.js +5 -4
- package/rotate.js.map +1 -1
- package/router.d.ts +3 -3
- package/router.d.ts.map +1 -1
- package/router.js +5 -4
- package/router.js.map +1 -1
- package/select.d.ts +9 -0
- package/select.d.ts.map +1 -0
- package/select.js +6 -0
- package/select.js.map +1 -0
- package/skeleton.d.ts +3 -3
- package/skeleton.d.ts.map +1 -1
- package/skeleton.js +5 -4
- package/skeleton.js.map +1 -1
- package/split.d.ts +9 -0
- package/split.d.ts.map +1 -0
- package/split.js +6 -0
- package/split.js.map +1 -0
- package/switch.d.ts +9 -0
- package/switch.d.ts.map +1 -0
- package/switch.js +6 -0
- package/switch.js.map +1 -0
- package/text.d.ts +3 -3
- package/text.d.ts.map +1 -1
- package/text.js +5 -4
- package/text.js.map +1 -1
- package/time.d.ts +3 -3
- package/time.d.ts.map +1 -1
- package/time.js +5 -4
- package/time.js.map +1 -1
- package/tooltip.d.ts +3 -3
- package/tooltip.d.ts.map +1 -1
- package/tooltip.js +5 -4
- package/tooltip.js.map +1 -1
- package/typewriter.d.ts +2 -3
- package/typewriter.d.ts.map +1 -1
- package/typewriter.js +5 -4
- package/typewriter.js.map +1 -1
- package/vscode.css-custom-data.json +1 -0
- package/vscode.html-custom-data.json +1 -0
- package/web-types.json +1 -0
- package/_deps.d.ts +0 -4
- package/_deps.d.ts.map +0 -1
- package/_deps.js +0 -4
- package/_deps.js.map +0 -1
- package/avatar-group.d.ts +0 -9
- package/avatar-group.d.ts.map +0 -1
- package/avatar-group.js +0 -5
- package/avatar-group.js.map +0 -1
- package/components.json +0 -194
- package/conf.d.ts +0 -12
- package/conf.d.ts.map +0 -1
- package/conf.js +0 -24
- package/conf.js.map +0 -1
- package/decorators/godown.d.ts +0 -4
- package/decorators/godown.d.ts.map +0 -1
- package/decorators/godown.js +0 -9
- package/decorators/godown.js.map +0 -1
- package/decorators/part.d.ts +0 -7
- package/decorators/part.d.ts.map +0 -1
- package/decorators/part.js +0 -8
- package/decorators/part.js.map +0 -1
- package/decorators/styles.d.ts +0 -3
- package/decorators/styles.d.ts.map +0 -1
- package/decorators/styles.js +0 -8
- package/decorators/styles.js.map +0 -1
- package/flex-flow.d.ts +0 -9
- package/flex-flow.d.ts.map +0 -1
- package/flex-flow.js +0 -5
- package/flex-flow.js.map +0 -1
- package/grid-flow.d.ts +0 -9
- package/grid-flow.d.ts.map +0 -1
- package/grid-flow.js +0 -5
- package/grid-flow.js.map +0 -1
- package/label-input.d.ts +0 -9
- package/label-input.d.ts.map +0 -1
- package/label-input.js +0 -5
- package/label-input.js.map +0 -1
- package/lib/css.d.ts +0 -13
- package/lib/css.d.ts.map +0 -1
- package/lib/css.js +0 -29
- package/lib/css.js.map +0 -1
- package/lib/directives.d.ts +0 -25
- package/lib/directives.d.ts.map +0 -1
- package/lib/directives.js +0 -40
- package/lib/directives.js.map +0 -1
- package/lib/event-coll.d.ts +0 -13
- package/lib/event-coll.d.ts.map +0 -1
- package/lib/event-coll.js +0 -45
- package/lib/event-coll.js.map +0 -1
- package/lib/icons.d.ts +0 -25
- package/lib/icons.d.ts.map +0 -1
- package/lib/icons.js +0 -73
- package/lib/icons.js.map +0 -1
- package/lib/jsx.d.ts +0 -4
- package/lib/jsx.d.ts.map +0 -1
- package/lib/jsx.js +0 -52
- package/lib/jsx.js.map +0 -1
- package/lib/route-tree.d.ts +0 -28
- package/lib/route-tree.d.ts.map +0 -1
- package/lib/route-tree.js +0 -141
- package/lib/route-tree.js.map +0 -1
- package/lib/utils.d.ts +0 -10
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -71
- package/lib/utils.js.map +0 -1
- package/overbreath.d.ts +0 -9
- package/overbreath.d.ts.map +0 -1
- package/overbreath.js +0 -5
- package/overbreath.js.map +0 -1
- package/proto/godown-config.d.ts +0 -41
- package/proto/godown-config.d.ts.map +0 -1
- package/proto/godown-config.js +0 -27
- package/proto/godown-config.js.map +0 -1
- package/proto/godown-element.d.ts +0 -125
- package/proto/godown-element.d.ts.map +0 -1
- package/proto/godown-element.js +0 -204
- package/proto/godown-element.js.map +0 -1
- package/proto/super-a.d.ts +0 -30
- package/proto/super-a.d.ts.map +0 -1
- package/proto/super-a.js +0 -141
- package/proto/super-a.js.map +0 -1
- package/proto/super-input.d.ts +0 -44
- package/proto/super-input.d.ts.map +0 -1
- package/proto/super-input.js +0 -119
- package/proto/super-input.js.map +0 -1
- package/proto/super-openable.d.ts.map +0 -1
- package/proto/super-openable.js.map +0 -1
- package/range-input.d.ts +0 -9
- package/range-input.d.ts.map +0 -1
- package/range-input.js +0 -5
- package/range-input.js.map +0 -1
- package/react/create.d.ts +0 -5
- package/react/create.d.ts.map +0 -1
- package/react/create.js +0 -16
- package/react/create.js.map +0 -1
- package/react/index.d.ts +0 -65
- package/react/index.d.ts.map +0 -1
- package/react/index.js +0 -132
- package/react/index.js.map +0 -1
- package/router-link.d.ts +0 -9
- package/router-link.d.ts.map +0 -1
- package/router-link.js +0 -5
- package/router-link.js.map +0 -1
- package/search-input.d.ts +0 -9
- package/search-input.d.ts.map +0 -1
- package/search-input.js +0 -5
- package/search-input.js.map +0 -1
- package/select-input.d.ts +0 -9
- package/select-input.d.ts.map +0 -1
- package/select-input.js +0 -5
- package/select-input.js.map +0 -1
- package/split-input.d.ts +0 -9
- package/split-input.d.ts.map +0 -1
- package/split-input.js +0 -5
- package/split-input.js.map +0 -1
- package/styles/colors/presets.d.ts +0 -13
- package/styles/colors/presets.d.ts.map +0 -1
- package/styles/colors/presets.js +0 -6
- package/styles/colors/presets.js.map +0 -1
- package/styles/colors/presetsRGB.d.ts +0 -16
- package/styles/colors/presetsRGB.d.ts.map +0 -1
- package/styles/colors/presetsRGB.js +0 -134
- package/styles/colors/presetsRGB.js.map +0 -1
- package/styles/global.d.ts +0 -18
- package/styles/global.d.ts.map +0 -1
- package/styles/global.js +0 -78
- package/styles/global.js.map +0 -1
- package/styles/inputStyle.d.ts +0 -3
- package/styles/inputStyle.d.ts.map +0 -1
- package/styles/inputStyle.js +0 -59
- package/styles/inputStyle.js.map +0 -1
- package/switch-input.d.ts +0 -9
- package/switch-input.d.ts.map +0 -1
- package/switch-input.js +0 -5
- package/switch-input.js.map +0 -1
- package/web-components/alert/alert.d.ts +0 -36
- package/web-components/alert/alert.d.ts.map +0 -1
- package/web-components/alert/alert.js +0 -161
- package/web-components/alert/alert.js.map +0 -1
- package/web-components/avatar/avatar-group.d.ts +0 -21
- package/web-components/avatar/avatar-group.d.ts.map +0 -1
- package/web-components/avatar/avatar-group.js +0 -86
- package/web-components/avatar/avatar-group.js.map +0 -1
- package/web-components/avatar/avatar.d.ts +0 -28
- package/web-components/avatar/avatar.d.ts.map +0 -1
- package/web-components/avatar/avatar.js +0 -120
- package/web-components/avatar/avatar.js.map +0 -1
- package/web-components/button/button.d.ts.map +0 -1
- package/web-components/button/button.js +0 -256
- package/web-components/button/button.js.map +0 -1
- package/web-components/card/card.d.ts +0 -9
- package/web-components/card/card.d.ts.map +0 -1
- package/web-components/card/card.js +0 -75
- package/web-components/card/card.js.map +0 -1
- package/web-components/carousel/carousel.d.ts +0 -29
- package/web-components/carousel/carousel.d.ts.map +0 -1
- package/web-components/carousel/carousel.js +0 -185
- package/web-components/carousel/carousel.js.map +0 -1
- package/web-components/details/details.d.ts.map +0 -1
- package/web-components/details/details.js +0 -124
- package/web-components/details/details.js.map +0 -1
- package/web-components/dialog/dialog.d.ts +0 -31
- package/web-components/dialog/dialog.d.ts.map +0 -1
- package/web-components/dialog/dialog.js +0 -143
- package/web-components/dialog/dialog.js.map +0 -1
- package/web-components/divider/divider.d.ts +0 -13
- package/web-components/divider/divider.d.ts.map +0 -1
- package/web-components/divider/divider.js +0 -95
- package/web-components/divider/divider.js.map +0 -1
- package/web-components/form/form.d.ts.map +0 -1
- package/web-components/form/form.js.map +0 -1
- package/web-components/input/input.d.ts +0 -37
- package/web-components/input/input.d.ts.map +0 -1
- package/web-components/input/input.js +0 -152
- package/web-components/input/input.js.map +0 -1
- package/web-components/input/label-input.d.ts +0 -15
- package/web-components/input/label-input.d.ts.map +0 -1
- package/web-components/input/label-input.js +0 -96
- package/web-components/input/label-input.js.map +0 -1
- package/web-components/input/range-input.d.ts +0 -53
- package/web-components/input/range-input.d.ts.map +0 -1
- package/web-components/input/range-input.js +0 -316
- package/web-components/input/range-input.js.map +0 -1
- package/web-components/input/search-input.d.ts +0 -42
- package/web-components/input/search-input.d.ts.map +0 -1
- package/web-components/input/search-input.js +0 -214
- package/web-components/input/search-input.js.map +0 -1
- package/web-components/input/select-input.d.ts +0 -36
- package/web-components/input/select-input.d.ts.map +0 -1
- package/web-components/input/select-input.js +0 -210
- package/web-components/input/select-input.js.map +0 -1
- package/web-components/input/split-input.d.ts +0 -29
- package/web-components/input/split-input.d.ts.map +0 -1
- package/web-components/input/split-input.js +0 -184
- package/web-components/input/split-input.js.map +0 -1
- package/web-components/input/switch-input.d.ts.map +0 -1
- package/web-components/input/switch-input.js +0 -189
- package/web-components/input/switch-input.js.map +0 -1
- package/web-components/layout/flex-flow.d.ts +0 -17
- package/web-components/layout/flex-flow.d.ts.map +0 -1
- package/web-components/layout/flex-flow.js +0 -73
- package/web-components/layout/flex-flow.js.map +0 -1
- package/web-components/layout/grid-flow.d.ts +0 -14
- package/web-components/layout/grid-flow.d.ts.map +0 -1
- package/web-components/layout/grid-flow.js +0 -56
- package/web-components/layout/grid-flow.js.map +0 -1
- package/web-components/layout/layout.d.ts +0 -18
- package/web-components/layout/layout.d.ts.map +0 -1
- package/web-components/layout/layout.js +0 -76
- package/web-components/layout/layout.js.map +0 -1
- package/web-components/link/link.d.ts +0 -10
- package/web-components/link/link.d.ts.map +0 -1
- package/web-components/link/link.js +0 -17
- package/web-components/link/link.js.map +0 -1
- package/web-components/link/router-link.d.ts +0 -19
- package/web-components/link/router-link.d.ts.map +0 -1
- package/web-components/link/router-link.js +0 -60
- package/web-components/link/router-link.js.map +0 -1
- package/web-components/progress/progress.d.ts.map +0 -1
- package/web-components/progress/progress.js +0 -107
- package/web-components/progress/progress.js.map +0 -1
- package/web-components/router/router.d.ts +0 -86
- package/web-components/router/router.d.ts.map +0 -1
- package/web-components/router/router.js +0 -246
- package/web-components/router/router.js.map +0 -1
- package/web-components/skeleton/skeleton.d.ts.map +0 -1
- package/web-components/skeleton/skeleton.js +0 -130
- package/web-components/skeleton/skeleton.js.map +0 -1
- package/web-components/text/overbreath.d.ts +0 -22
- package/web-components/text/overbreath.d.ts.map +0 -1
- package/web-components/text/overbreath.js +0 -132
- package/web-components/text/overbreath.js.map +0 -1
- package/web-components/text/text.d.ts.map +0 -1
- package/web-components/text/text.js +0 -94
- package/web-components/text/text.js.map +0 -1
- package/web-components/text/time.d.ts.map +0 -1
- package/web-components/text/time.js.map +0 -1
- package/web-components/text/typewriter.d.ts.map +0 -1
- package/web-components/text/typewriter.js.map +0 -1
- package/web-components/tooltip/tooltip.d.ts +0 -30
- package/web-components/tooltip/tooltip.d.ts.map +0 -1
- package/web-components/tooltip/tooltip.js +0 -123
- package/web-components/tooltip/tooltip.js.map +0 -1
- package/web-components/wrapper/dragbox.d.ts.map +0 -1
- package/web-components/wrapper/dragbox.js.map +0 -1
- package/web-components/wrapper/rotate.d.ts.map +0 -1
- package/web-components/wrapper/rotate.js +0 -92
- package/web-components/wrapper/rotate.js.map +0 -1
@@ -1,210 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import { css, html, property } from "../../_deps.js";
|
3
|
-
import { godown } from "../../decorators/godown.js";
|
4
|
-
import { styles } from "../../decorators/styles.js";
|
5
|
-
import { htmlSlot } from "../../lib/directives.js";
|
6
|
-
import { svgDelta, svgX } from "../../lib/icons.js";
|
7
|
-
import GodownInput from "../../proto/super-input.js";
|
8
|
-
import { cssGlobalVars } from "../../styles/global.js";
|
9
|
-
import { fieldStyle, inputStyle } from "../../styles/inputStyle.js";
|
10
|
-
const protoName = "select-input";
|
11
|
-
/**
|
12
|
-
* {@linkcode SelectInput} select matched elements.
|
13
|
-
*
|
14
|
-
* This will not support multi-selection operations.
|
15
|
-
*
|
16
|
-
* @slot - Options.
|
17
|
-
*/
|
18
|
-
let SelectInput = class SelectInput extends GodownInput {
|
19
|
-
constructor() {
|
20
|
-
super(...arguments);
|
21
|
-
/**
|
22
|
-
* Open content.
|
23
|
-
*/
|
24
|
-
this.open = false;
|
25
|
-
}
|
26
|
-
render() {
|
27
|
-
return html `<div part="root" class="input-field">
|
28
|
-
<section part="selected">
|
29
|
-
${this.value &&
|
30
|
-
html `<div class="selected-item">
|
31
|
-
${this.value}
|
32
|
-
<i
|
33
|
-
@click="${() => {
|
34
|
-
this.value = "";
|
35
|
-
}}"
|
36
|
-
>${svgX()}</i
|
37
|
-
>
|
38
|
-
</div>`}
|
39
|
-
</section>
|
40
|
-
<input
|
41
|
-
part="input"
|
42
|
-
?autofocus="${this.autofocus}"
|
43
|
-
id="${this.makeId}"
|
44
|
-
@focus="${() => {
|
45
|
-
this.open = true;
|
46
|
-
}}"
|
47
|
-
@input="${this._handleInput}"
|
48
|
-
placeholder="${this.placeholder}"
|
49
|
-
/>
|
50
|
-
<label for="${this.makeId}"> <i>${svgDelta()}</i></label>
|
51
|
-
<div class="content" part="slot">${htmlSlot()}</div>
|
52
|
-
</div>`;
|
53
|
-
}
|
54
|
-
firstUpdated() {
|
55
|
-
super.firstUpdated();
|
56
|
-
this.addEvent(document, "click", (e) => {
|
57
|
-
const target = e.target;
|
58
|
-
if (!this.contains(e.target)) {
|
59
|
-
this.open = false;
|
60
|
-
}
|
61
|
-
else if (target !== this) {
|
62
|
-
const value = this.getOptionValue(target);
|
63
|
-
if (value) {
|
64
|
-
this.select(value, target.textContent);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
});
|
68
|
-
}
|
69
|
-
select(value, text) {
|
70
|
-
this.value = value;
|
71
|
-
this.text = text || value;
|
72
|
-
this._input.value = "";
|
73
|
-
this.filter();
|
74
|
-
this.dispatchEvent(new CustomEvent("change", { detail: this.namevalue() }));
|
75
|
-
}
|
76
|
-
filter(value) {
|
77
|
-
this.querySelectorAll("*").forEach((option) => {
|
78
|
-
const { style } = option;
|
79
|
-
if (!value) {
|
80
|
-
style.display = null;
|
81
|
-
return;
|
82
|
-
}
|
83
|
-
const optionValue = this.getOptionValue(option);
|
84
|
-
if (includesIgnoreCase(optionValue, value) || includesIgnoreCase(option.textContent, value)) {
|
85
|
-
style.display = null;
|
86
|
-
}
|
87
|
-
else {
|
88
|
-
style.display = "none";
|
89
|
-
}
|
90
|
-
});
|
91
|
-
}
|
92
|
-
reset() {
|
93
|
-
if (this.default) {
|
94
|
-
this.select(this.default, this.defaultText || this.default);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
_handleInput() {
|
98
|
-
this.filter(this._input.value.trim());
|
99
|
-
this.dispatchEvent(new CustomEvent("input", { detail: this.namevalue() }));
|
100
|
-
}
|
101
|
-
focus(options) {
|
102
|
-
this._input?.focus(options);
|
103
|
-
this.open = true;
|
104
|
-
}
|
105
|
-
getOptionValue(option) {
|
106
|
-
return option.value || option.getAttribute("value") || "";
|
107
|
-
}
|
108
|
-
};
|
109
|
-
__decorate([
|
110
|
-
property({ type: Boolean, reflect: true })
|
111
|
-
], SelectInput.prototype, "open", void 0);
|
112
|
-
__decorate([
|
113
|
-
property()
|
114
|
-
], SelectInput.prototype, "text", void 0);
|
115
|
-
__decorate([
|
116
|
-
property({
|
117
|
-
attribute: "default-text",
|
118
|
-
})
|
119
|
-
], SelectInput.prototype, "defaultText", void 0);
|
120
|
-
SelectInput = __decorate([
|
121
|
-
godown(protoName),
|
122
|
-
styles([
|
123
|
-
inputStyle,
|
124
|
-
fieldStyle,
|
125
|
-
css `
|
126
|
-
:host {
|
127
|
-
background: var(--${cssGlobalVars.input}--background);
|
128
|
-
margin: var(--${cssGlobalVars.input}--outline-width);
|
129
|
-
outline: var(--${cssGlobalVars.input}--outline-width) solid transparent;
|
130
|
-
border-radius: var(--${cssGlobalVars.input}--radius);
|
131
|
-
height: var(--${cssGlobalVars.input}--height);
|
132
|
-
width: var(--${cssGlobalVars.input}--width);
|
133
|
-
display: block;
|
134
|
-
}
|
135
|
-
|
136
|
-
:host([open]) {
|
137
|
-
outline-color: var(--${cssGlobalVars.input}--outline-color);
|
138
|
-
}
|
139
|
-
|
140
|
-
input {
|
141
|
-
flex: 1;
|
142
|
-
width: 100%;
|
143
|
-
height: 100%;
|
144
|
-
cursor: inherit;
|
145
|
-
border: inherit;
|
146
|
-
background: none;
|
147
|
-
padding: 0 0 0 0.25em;
|
148
|
-
box-sizing: border-box;
|
149
|
-
border-radius: inherit;
|
150
|
-
}
|
151
|
-
|
152
|
-
section {
|
153
|
-
height: 100%;
|
154
|
-
overflow: hidden;
|
155
|
-
z-index: inherit;
|
156
|
-
border-radius: inherit;
|
157
|
-
max-width: calc(100% - 1.2em);
|
158
|
-
}
|
159
|
-
|
160
|
-
[part="root"] {
|
161
|
-
width: 100%;
|
162
|
-
z-index: inherit;
|
163
|
-
position: relative;
|
164
|
-
display: inline-flex;
|
165
|
-
align-items: center;
|
166
|
-
border-radius: inherit;
|
167
|
-
}
|
168
|
-
|
169
|
-
.content {
|
170
|
-
top: 100%;
|
171
|
-
position: absolute;
|
172
|
-
width: 100%;
|
173
|
-
z-index: 1;
|
174
|
-
margin-top: 1px;
|
175
|
-
visibility: hidden;
|
176
|
-
border-radius: inherit;
|
177
|
-
}
|
178
|
-
|
179
|
-
:host([open]) .content {
|
180
|
-
visibility: visible;
|
181
|
-
}
|
182
|
-
`,
|
183
|
-
css `
|
184
|
-
.selected-item {
|
185
|
-
background: var(--${cssGlobalVars.input}--true);
|
186
|
-
border-radius: inherit;
|
187
|
-
height: 100%;
|
188
|
-
float: left;
|
189
|
-
display: inline-flex;
|
190
|
-
font-style: normal;
|
191
|
-
align-items: center;
|
192
|
-
padding: 0 0.1em 0 0.2em;
|
193
|
-
}
|
194
|
-
|
195
|
-
.selected-item i {
|
196
|
-
height: -moz-fit-content;
|
197
|
-
height: fit-content;
|
198
|
-
}
|
199
|
-
`,
|
200
|
-
])
|
201
|
-
], SelectInput);
|
202
|
-
export { SelectInput };
|
203
|
-
export default SelectInput;
|
204
|
-
function includesIgnoreCase(a, b) {
|
205
|
-
if (!a || !b) {
|
206
|
-
return false;
|
207
|
-
}
|
208
|
-
return a.toLowerCase().includes(b.toLowerCase());
|
209
|
-
}
|
210
|
-
//# sourceMappingURL=select-input.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"select-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/select-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,MAAM,E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6BAKX,aAAa,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6C7C;QACD,GAAG,CAAA;;0BAEqB,aAAa,CAAC,KAAK;;;;;;;;;;;;;;GAc1C;KACF,CAAC;GACW,WAAW,CA6GvB;;AAED,eAAe,WAAW,CAAC;AAE3B,SAAS,kBAAkB,CAAC,CAAS,EAAE,CAAS;IAC9C,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { css, html, property } from \"../../_deps.js\";\nimport { godown } from \"../../decorators/godown.js\";\nimport { styles } from \"../../decorators/styles.js\";\nimport { htmlSlot } from \"../../lib/directives.js\";\nimport { svgDelta, svgX } from \"../../lib/icons.js\";\nimport GodownInput from \"../../proto/super-input.js\";\nimport { cssGlobalVars } from \"../../styles/global.js\";\nimport { fieldStyle, inputStyle } from \"../../styles/inputStyle.js\";\n\nconst protoName = \"select-input\";\n\n/**\n * {@linkcode SelectInput} select matched elements.\n *\n * This will not support multi-selection operations.\n *\n * @slot - Options.\n */\n@godown(protoName)\n@styles([\n inputStyle,\n fieldStyle,\n css`\n :host {\n background: var(--${cssGlobalVars.input}--background);\n margin: var(--${cssGlobalVars.input}--outline-width);\n outline: var(--${cssGlobalVars.input}--outline-width) solid transparent;\n border-radius: var(--${cssGlobalVars.input}--radius);\n height: var(--${cssGlobalVars.input}--height);\n width: var(--${cssGlobalVars.input}--width);\n display: block;\n }\n\n :host([open]) {\n outline-color: var(--${cssGlobalVars.input}--outline-color);\n }\n\n input {\n flex: 1;\n width: 100%;\n height: 100%;\n cursor: inherit;\n border: inherit;\n background: none;\n padding: 0 0 0 0.25em;\n box-sizing: border-box;\n border-radius: inherit;\n }\n\n section {\n height: 100%;\n overflow: hidden;\n z-index: inherit;\n border-radius: inherit;\n max-width: calc(100% - 1.2em);\n }\n\n [part=\"root\"] {\n width: 100%;\n z-index: inherit;\n position: relative;\n display: inline-flex;\n align-items: center;\n border-radius: inherit;\n }\n\n .content {\n top: 100%;\n position: absolute;\n width: 100%;\n z-index: 1;\n margin-top: 1px;\n visibility: hidden;\n border-radius: inherit;\n }\n\n :host([open]) .content {\n visibility: visible;\n }\n `,\n css`\n .selected-item {\n background: var(--${cssGlobalVars.input}--true);\n border-radius: inherit;\n height: 100%;\n float: left;\n display: inline-flex;\n font-style: normal;\n align-items: center;\n padding: 0 0.1em 0 0.2em;\n }\n\n .selected-item i {\n height: -moz-fit-content;\n height: fit-content;\n }\n `,\n])\nexport class SelectInput extends GodownInput {\n /**\n * Open content.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Selected texts.\n */\n @property() text: string;\n /**\n * Selected texts.\n */\n @property({\n attribute: \"default-text\",\n })\n defaultText: string;\n\n protected render() {\n return html`<div part=\"root\" class=\"input-field\">\n <section part=\"selected\">\n ${this.value &&\n html`<div class=\"selected-item\">\n ${this.value}\n <i\n @click=\"${() => {\n this.value = \"\";\n }}\"\n >${svgX()}</i\n >\n </div>`}\n </section>\n <input\n part=\"input\"\n ?autofocus=\"${this.autofocus}\"\n id=\"${this.makeId}\"\n @focus=\"${() => {\n this.open = true;\n }}\"\n @input=\"${this._handleInput}\"\n placeholder=\"${this.placeholder}\"\n />\n <label for=\"${this.makeId}\"> <i>${svgDelta()}</i></label>\n <div class=\"content\" part=\"slot\">${htmlSlot()}</div>\n </div>`;\n }\n\n protected firstUpdated() {\n super.firstUpdated();\n this.addEvent(document, \"click\", (e) => {\n const target = e.target as HTMLElement;\n if (!this.contains(e.target as Node)) {\n this.open = false;\n } else if (target !== this) {\n const value = this.getOptionValue(target);\n if (value) {\n this.select(value, target.textContent);\n }\n }\n });\n }\n\n select(value: string, text?: string) {\n this.value = value;\n this.text = text || value;\n this._input.value = \"\";\n this.filter();\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.namevalue() }));\n }\n\n filter(value?: string) {\n this.querySelectorAll(\"*\").forEach((option: HTMLElement) => {\n const { style } = option;\n if (!value) {\n style.display = null;\n return;\n }\n const optionValue = this.getOptionValue(option);\n if (includesIgnoreCase(optionValue, value) || includesIgnoreCase(option.textContent, value)) {\n style.display = null;\n } else {\n style.display = \"none\";\n }\n });\n }\n\n reset() {\n if (this.default) {\n this.select(this.default, this.defaultText || this.default);\n }\n }\n\n protected _handleInput() {\n this.filter(this._input.value.trim());\n this.dispatchEvent(new CustomEvent(\"input\", { detail: this.namevalue() }));\n }\n\n focus(options?: FocusOptions) {\n this._input?.focus(options);\n this.open = true;\n }\n\n getOptionValue(option: Element) {\n return (option as HTMLOptionElement).value || option.getAttribute(\"value\") || \"\";\n }\n /**\n * @deprecated\n */\n only: boolean;\n}\n\nexport default SelectInput;\n\nfunction includesIgnoreCase(a: string, b: string): boolean {\n if (!a || !b) {\n return false;\n }\n return a.toLowerCase().includes(b.toLowerCase());\n}\n"]}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { type HTMLEvent } from "../../proto/godown-element";
|
2
|
-
import GodownSuperInput from "../../proto/super-input.js";
|
3
|
-
/**
|
4
|
-
* {@linkcode SplitInput } renders multiple inputs.
|
5
|
-
*/
|
6
|
-
export declare class SplitInput extends GodownSuperInput {
|
7
|
-
/**
|
8
|
-
* The number of simulated input boxes.
|
9
|
-
*/
|
10
|
-
max: number;
|
11
|
-
/**
|
12
|
-
* Active index.
|
13
|
-
*/
|
14
|
-
index: number;
|
15
|
-
_input: HTMLInputElement;
|
16
|
-
_spans: NodeListOf<HTMLSpanElement>;
|
17
|
-
current: number;
|
18
|
-
currentValue: (string | null)[];
|
19
|
-
protected render(): import("lit").TemplateResult<1>;
|
20
|
-
protected firstUpdated(): void;
|
21
|
-
protected _handleInput(e: HTMLEvent<HTMLInputElement>): void;
|
22
|
-
focus(): void;
|
23
|
-
focusAt(i: number): void;
|
24
|
-
blur(): void;
|
25
|
-
blurAt(i: number): void;
|
26
|
-
reset(): void;
|
27
|
-
}
|
28
|
-
export default SplitInput;
|
29
|
-
//# sourceMappingURL=split-input.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"split-input.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/split-input.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAU1D;;GAEG;AACH,qBAuDa,UAAW,SAAQ,gBAAgB;IAC9C;;OAEG;IACyB,GAAG,SAAK;IACpC;;OAEG;IACyB,KAAK,SAAM;IAEvB,MAAM,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IACtD,OAAO,SAAK;IACZ,YAAY,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAM;IAErC,SAAS,CAAC,MAAM;IAkBhB,SAAS,CAAC,YAAY;IAYtB,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC;IA4BrD,KAAK;IAIL,OAAO,CAAC,CAAC,EAAE,MAAM;IAQjB,IAAI;IAIJ,MAAM,CAAC,CAAC,EAAE,MAAM;IAKhB,KAAK;CASN;AAED,eAAe,UAAU,CAAC"}
|
@@ -1,184 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
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";
|
8
|
-
const FOCUS = "focus";
|
9
|
-
const protoName = "split-input";
|
10
|
-
const cssScope = createScope(protoName);
|
11
|
-
/**
|
12
|
-
* {@linkcode SplitInput } renders multiple inputs.
|
13
|
-
*/
|
14
|
-
let SplitInput = class SplitInput extends GodownSuperInput {
|
15
|
-
constructor() {
|
16
|
-
super(...arguments);
|
17
|
-
/**
|
18
|
-
* The number of simulated input boxes.
|
19
|
-
*/
|
20
|
-
this.max = 6;
|
21
|
-
/**
|
22
|
-
* Active index.
|
23
|
-
*/
|
24
|
-
this.index = -1;
|
25
|
-
this.current = 0;
|
26
|
-
this.currentValue = [];
|
27
|
-
}
|
28
|
-
render() {
|
29
|
-
return html `
|
30
|
-
<div part="root">
|
31
|
-
${Array(this.max)
|
32
|
-
.fill(0)
|
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
|
-
/>
|
42
|
-
</div>
|
43
|
-
`;
|
44
|
-
}
|
45
|
-
firstUpdated() {
|
46
|
-
this.currentValue = this.value.split("").concat(Array(this.max - this.value.length).fill(null));
|
47
|
-
this.current = this.index < 0 || this.index > this.max ? this.currentValue.indexOf(null) : this.index;
|
48
|
-
this._spans.forEach((span, index) => {
|
49
|
-
this.addEvent(span, "click", () => {
|
50
|
-
this.current = index;
|
51
|
-
this.focusAt(this.current);
|
52
|
-
this._input.focus();
|
53
|
-
});
|
54
|
-
});
|
55
|
-
}
|
56
|
-
_handleInput(e) {
|
57
|
-
if (e.data === null) {
|
58
|
-
if (this.currentValue[this.current] !== null) {
|
59
|
-
this.currentValue[this.current] = null;
|
60
|
-
}
|
61
|
-
else {
|
62
|
-
this.currentValue[this.current - 1] = null;
|
63
|
-
this.current = this.current - 1 < 0 ? 0 : this.current - 1;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
else {
|
67
|
-
this.currentValue[this.current] = e.data;
|
68
|
-
if (this.current + 1 >= this.max) {
|
69
|
-
this.current = this.currentValue.indexOf(null);
|
70
|
-
if (this.current === -1) {
|
71
|
-
this.blurAt(this.current);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
else {
|
75
|
-
this.current += 1;
|
76
|
-
}
|
77
|
-
}
|
78
|
-
this.focus();
|
79
|
-
this._spans.forEach((span, index) => {
|
80
|
-
span.querySelector("i").innerText = this.currentValue[index] || "";
|
81
|
-
});
|
82
|
-
this.value = this.currentValue.join("");
|
83
|
-
this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true, composed: true }));
|
84
|
-
this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
|
85
|
-
}
|
86
|
-
focus() {
|
87
|
-
this.focusAt(this.current);
|
88
|
-
}
|
89
|
-
focusAt(i) {
|
90
|
-
this._spans.forEach((span) => {
|
91
|
-
span.classList.remove(FOCUS);
|
92
|
-
});
|
93
|
-
this._spans[i]?.classList.add(FOCUS);
|
94
|
-
this._input.value = "";
|
95
|
-
}
|
96
|
-
blur() {
|
97
|
-
this.blurAt(this.current);
|
98
|
-
}
|
99
|
-
blurAt(i) {
|
100
|
-
this._spans[i]?.classList.remove(FOCUS);
|
101
|
-
this._input.blur();
|
102
|
-
}
|
103
|
-
reset() {
|
104
|
-
this.currentValue = Array(this.max).fill(null);
|
105
|
-
this.current = 0;
|
106
|
-
this._spans.forEach((span) => {
|
107
|
-
span.querySelector("i").innerText = "";
|
108
|
-
});
|
109
|
-
this.value = "";
|
110
|
-
this.dispatchEvent(new CustomEvent("change", { detail: this.value }));
|
111
|
-
}
|
112
|
-
};
|
113
|
-
__decorate([
|
114
|
-
property({ type: Number })
|
115
|
-
], SplitInput.prototype, "max", void 0);
|
116
|
-
__decorate([
|
117
|
-
property({ type: Number })
|
118
|
-
], SplitInput.prototype, "index", void 0);
|
119
|
-
__decorate([
|
120
|
-
query("input")
|
121
|
-
], SplitInput.prototype, "_input", void 0);
|
122
|
-
__decorate([
|
123
|
-
queryAll("span")
|
124
|
-
], SplitInput.prototype, "_spans", void 0);
|
125
|
-
SplitInput = __decorate([
|
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
|
-
])
|
181
|
-
], SplitInput);
|
182
|
-
export { SplitInput };
|
183
|
-
export default SplitInput;
|
184
|
-
//# sourceMappingURL=split-input.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"split-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/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AC;0CAA0B;AACvB;IAAjB,QAAQ,CAAC,MAAM,CAAC;0CAAqC;AAX3C,UAAU;IAvDtB,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CAAC;QACN,UAAU;QACV,GAAG,CAAA;;UAEK,QAAQ,iCAAiC,aAAa,CAAC,KAAK;sBAChD,aAAa,CAAC,KAAK;qBACpB,aAAa,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAgCb,aAAa,CAAC,KAAK;;;;;;;;;;;;uBAY5B,QAAQ;;GAE5B;KACF,CAAC;GACW,UAAU,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 +0,0 @@
|
|
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,189 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
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
|
-
/**
|
10
|
-
* {@linkcode SwitchInput } renders a switch.
|
11
|
-
*
|
12
|
-
* Inspired by Steam.
|
13
|
-
*/
|
14
|
-
let SwitchInput = class SwitchInput extends GodownInput {
|
15
|
-
constructor() {
|
16
|
-
super(...arguments);
|
17
|
-
/**
|
18
|
-
* Border style.
|
19
|
-
*/
|
20
|
-
// @property() variant: "fat" | "rect" = "rect";
|
21
|
-
this.round = false;
|
22
|
-
/**
|
23
|
-
* Whether this element is selected or not.
|
24
|
-
*/
|
25
|
-
this.checked = false;
|
26
|
-
/**
|
27
|
-
* Whether this element is disabled or not.
|
28
|
-
*/
|
29
|
-
this.disabled = false;
|
30
|
-
/**
|
31
|
-
* Parsed by JSON.parse to checked.
|
32
|
-
*/
|
33
|
-
this.default = "false";
|
34
|
-
/**
|
35
|
-
* Input value.
|
36
|
-
*/
|
37
|
-
this.value = "on";
|
38
|
-
}
|
39
|
-
render() {
|
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>`;
|
54
|
-
}
|
55
|
-
reset() {
|
56
|
-
this.checked = this.default === "true";
|
57
|
-
this._input.checked = this.checked;
|
58
|
-
}
|
59
|
-
connectedCallback() {
|
60
|
-
super.connectedCallback();
|
61
|
-
if (this.checked) {
|
62
|
-
this.default = "true";
|
63
|
-
}
|
64
|
-
if (this.default === "true") {
|
65
|
-
this.checked = true;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
_handleChange() {
|
69
|
-
this.checked = this._input.checked;
|
70
|
-
this.dispatchEvent(new CustomEvent("input", { detail: this.checked, bubbles: true, composed: true }));
|
71
|
-
this.dispatchEvent(new CustomEvent("change", { detail: this.checked, composed: true }));
|
72
|
-
}
|
73
|
-
namevalue() {
|
74
|
-
return [this.name, this.checked];
|
75
|
-
}
|
76
|
-
};
|
77
|
-
__decorate([
|
78
|
-
property({ type: Boolean, reflect: true })
|
79
|
-
], SwitchInput.prototype, "round", void 0);
|
80
|
-
__decorate([
|
81
|
-
property({ type: Boolean, reflect: true })
|
82
|
-
], SwitchInput.prototype, "checked", void 0);
|
83
|
-
__decorate([
|
84
|
-
property({ type: Boolean, reflect: true })
|
85
|
-
], SwitchInput.prototype, "disabled", void 0);
|
86
|
-
__decorate([
|
87
|
-
property()
|
88
|
-
], SwitchInput.prototype, "default", void 0);
|
89
|
-
__decorate([
|
90
|
-
property()
|
91
|
-
], SwitchInput.prototype, "value", void 0);
|
92
|
-
__decorate([
|
93
|
-
query("input")
|
94
|
-
], SwitchInput.prototype, "_input", void 0);
|
95
|
-
SwitchInput = __decorate([
|
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
|
-
])
|
186
|
-
], SwitchInput);
|
187
|
-
export { SwitchInput };
|
188
|
-
export default SwitchInput;
|
189
|
-
//# sourceMappingURL=switch-input.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"switch-input.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/input/switch-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,SAAS,GAAG,cAAc,CAAC;AAEjC;;;;GAIG;AA2FI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,WAAW;IAArC;;QAKL;;WAEG;QACH,gDAAgD;QACJ,UAAK,GAAG,KAAK,CAAC;QAC1D;;WAEG;QACyC,YAAO,GAAG,KAAK,CAAC;QAC5D;;WAEG;QACyC,aAAQ,GAAG,KAAK,CAAC;QAC7D;;WAEG;QACS,YAAO,GAAG,OAAO,CAAC;QAC9B;;WAEG;QACS,UAAK,GAAG,IAAI,CAAC;IA6C3B,CAAC;IAzCW,MAAM;QACd,OAAO,IAAI,CAAA,2BAA2B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;;;mBAGpD,IAAI,CAAC,aAAa;qBAChB,IAAI,CAAC,QAAQ;oBACd,IAAI,CAAC,OAAO;gBAChB,IAAI,CAAC,IAAI;cACX,IAAI,CAAC,MAAM;;;;oBAIL,IAAI,CAAC,OAAO;;WAErB,CAAC;IACV,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,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,EAAE;0CAAc;AAET;IAAf,KAAK,CAAC,OAAO,CAAC;2CAA0B;AA3B9B,WAAW;IA1FvB,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CAAC;QACN,UAAU;QACV,GAAG,CAAA;;UAEK,aAAa,CAAC,KAAK;UACnB,aAAa,CAAC,KAAK,wBAAwB,aAAa,CAAC,KAAK;UAC9D,aAAa,CAAC,KAAK,qBAAqB,aAAa,CAAC,KAAK;UAC3D,aAAa,CAAC,KAAK;0BACH,aAAa,CAAC,KAAK;qBACxB,aAAa,CAAC,KAAK;sBAClB,aAAa,CAAC,KAAK;;;;;;;;0BAQf,aAAa,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAmCX,aAAa,CAAC,KAAK;;;;;;;;;;;;0BAY3B,aAAa,CAAC,KAAK;;;;0BAInB,aAAa,CAAC,KAAK;;;;;sBAKvB,aAAa,CAAC,KAAK;0BACf,aAAa,CAAC,KAAK;0BACnB,aAAa,CAAC,KAAK,qBAAqB,aAAa,CAAC,KAAK;2BAC1D,aAAa,CAAC,KAAK,qBAAqB,aAAa,CAAC,KAAK;;;;0BAI5D,aAAa,CAAC,KAAK;;;;0BAInB,aAAa,CAAC,KAAK;;GAE1C;KACF,CAAC;GACW,WAAW,CAsEvB;;AAED,eAAe,WAAW,CAAC","sourcesContent":["import { css, html, property, query } from \"../../_deps.js\";\nimport { godown } from \"../../decorators/godown.js\";\nimport { styles } from \"../../decorators/styles.js\";\nimport GodownInput from \"../../proto/super-input.js\";\nimport { cssGlobalVars } from \"../../styles/global.js\";\nimport { inputStyle } from \"../../styles/inputStyle.js\";\n\nconst protoName = \"switch-input\";\n\n/**\n * {@linkcode SwitchInput } renders a switch.\n *\n * Inspired by Steam.\n */\n@godown(protoName)\n@styles([\n inputStyle,\n css`\n :host {\n --${cssGlobalVars.input}--width: 3em;\n --${cssGlobalVars.input}--height: calc(var(--${cssGlobalVars.input}--width) / 2);\n --${cssGlobalVars.input}--gap: calc(var(--${cssGlobalVars.input}--width) / 25);\n --${cssGlobalVars.input}--transition: all .25s ease-in-out;\n background: var(--${cssGlobalVars.input}--background);\n width: var(--${cssGlobalVars.input}--width);\n height: var(--${cssGlobalVars.input}--height);\n display: inline-block;\n vertical-align: bottom;\n }\n\n [part=\"root\"],\n span,\n i {\n transition: var(--${cssGlobalVars.input}--transition);\n }\n\n [part=\"root\"] {\n border-radius: inherit;\n position: relative;\n height: inherit;\n }\n\n [part=\"root\"],\n input,\n i {\n width: 100%;\n }\n\n input {\n margin: 0;\n height: 100%;\n outline: none;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n }\n\n span {\n height: 100%;\n display: inline-flex;\n position: absolute;\n left: 0;\n width: 50%;\n pointer-events: none;\n border-radius: inherit;\n }\n\n :host([round]) {\n border-radius: calc(var(--${cssGlobalVars.input}--height) / 2);\n }\n\n :host([checked]) span {\n transform: translateX(100%);\n }\n\n .rect * {\n border-radius: inherit;\n }\n\n .rect .true {\n background: var(--${cssGlobalVars.input}--true);\n }\n\n .rect .false {\n background: var(--${cssGlobalVars.input}--false);\n }\n\n .round i {\n border-radius: 100%;\n margin: var(--${cssGlobalVars.input}--gap);\n background: var(--${cssGlobalVars.input}--control);\n width: calc(var(--${cssGlobalVars.input}--height) - var(--${cssGlobalVars.input}--gap) * 2);\n height: calc(var(--${cssGlobalVars.input}--height) - var(--${cssGlobalVars.input}--gap) * 2);\n }\n\n .round {\n background: var(--${cssGlobalVars.input}--false);\n }\n\n :host([checked]) .round {\n background: var(--${cssGlobalVars.input}--true);\n }\n `,\n])\nexport class SwitchInput extends GodownInput {\n /**\n * @deprecated\n */\n base: \"fat\" | \"rect\";\n /**\n * Border style.\n */\n // @property() variant: \"fat\" | \"rect\" = \"rect\";\n @property({ type: Boolean, reflect: true }) round = false;\n /**\n * Whether this element is selected or not.\n */\n @property({ type: Boolean, reflect: true }) checked = false;\n /**\n * Whether this element is disabled or not.\n */\n @property({ type: Boolean, reflect: true }) disabled = false;\n /**\n * Parsed by JSON.parse to checked.\n */\n @property() default = \"false\";\n /**\n * Input value.\n */\n @property() value = \"on\";\n\n @query(\"input\") _input: HTMLInputElement;\n\n protected render() {\n return html`<div part=\"root\" class=\"${this.round ? \"round\" : \"rect\"}\">\n <input\n part=\"input\"\n @change=\"${this._handleChange}\"\n ?disabled=\"${this.disabled}\"\n ?checked=\"${this.checked}\"\n name=\"${this.name}\"\n id=\"${this.makeId}\"\n type=\"checkbox\"\n />\n <span>\n <i class=\"${this.checked}\"><i></i></i>\n </span>\n </div>`;\n }\n\n reset() {\n this.checked = this.default === \"true\";\n this._input.checked = this.checked;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.checked) {\n this.default = \"true\";\n }\n if (this.default === \"true\") {\n this.checked = true;\n }\n }\n\n protected _handleChange() {\n this.checked = this._input.checked;\n this.dispatchEvent(new CustomEvent(\"input\", { detail: this.checked, bubbles: true, composed: true }));\n this.dispatchEvent(new CustomEvent(\"change\", { detail: this.checked, composed: true }));\n }\n\n namevalue(): [string, boolean] {\n return [this.name, this.checked];\n }\n}\n\nexport default SwitchInput;\n"]}
|