godown 2.7.6 → 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,246 +0,0 @@
|
|
1
|
-
var Router_1;
|
2
|
-
import { __decorate } from "tslib";
|
3
|
-
import { css, property, state } from "../../_deps.js";
|
4
|
-
import conf from "../../conf.js";
|
5
|
-
import { godown } from "../../decorators/godown.js";
|
6
|
-
import { styles } from "../../decorators/styles.js";
|
7
|
-
import { htmlSlot } from "../../lib/directives.js";
|
8
|
-
import RouteTree from "../../lib/route-tree.js";
|
9
|
-
import { deepQuerySelectorAll } from "../../lib/utils.js";
|
10
|
-
import { GodownElement } from "../../proto/godown-element.js";
|
11
|
-
const protoName = "router";
|
12
|
-
/**
|
13
|
-
* {@linkcode Router} has basic routing control.
|
14
|
-
*
|
15
|
-
* To switch routes, use history api or router-link.
|
16
|
-
*/
|
17
|
-
let Router = Router_1 = class Router extends GodownElement {
|
18
|
-
constructor() {
|
19
|
-
super(...arguments);
|
20
|
-
this._routes = [];
|
21
|
-
this._routeTree = new RouteTree();
|
22
|
-
/**
|
23
|
-
* Component will render.
|
24
|
-
*/
|
25
|
-
this.component = null;
|
26
|
-
/**
|
27
|
-
* Dynamic parameters record.
|
28
|
-
*/
|
29
|
-
this.params = {};
|
30
|
-
/**
|
31
|
-
* Value of matched path in routes, or null.
|
32
|
-
*/
|
33
|
-
this.path = null;
|
34
|
-
/**
|
35
|
-
* Current pathname (location.pathname).
|
36
|
-
*/
|
37
|
-
this.pathname = "";
|
38
|
-
/**
|
39
|
-
* Path prefix.
|
40
|
-
*/
|
41
|
-
this.baseURL = "";
|
42
|
-
/**
|
43
|
-
* Rendered content when there is no match.
|
44
|
-
*/
|
45
|
-
this.default = htmlSlot();
|
46
|
-
/**
|
47
|
-
* The type of routing query.
|
48
|
-
*/
|
49
|
-
this.type = "united";
|
50
|
-
/**
|
51
|
-
* Rewrite history.
|
52
|
-
*/
|
53
|
-
this.override = true;
|
54
|
-
/**
|
55
|
-
* Cache accessed.
|
56
|
-
*/
|
57
|
-
this.cache = false;
|
58
|
-
/**
|
59
|
-
* Cache record.
|
60
|
-
*/
|
61
|
-
this.record = new Map();
|
62
|
-
/**
|
63
|
-
*
|
64
|
-
* @param ur value of useRouter()
|
65
|
-
* @param first whether this path is loaded for the first time
|
66
|
-
*/
|
67
|
-
this.routeChangeCallback = null;
|
68
|
-
}
|
69
|
-
set routes(v) {
|
70
|
-
this._routes = v;
|
71
|
-
this.reset();
|
72
|
-
for (const route of v) {
|
73
|
-
this._routeTree.insert(route.path);
|
74
|
-
}
|
75
|
-
this.requestUpdate();
|
76
|
-
}
|
77
|
-
get routes() {
|
78
|
-
return this._routes;
|
79
|
-
}
|
80
|
-
reset() {
|
81
|
-
this._routeTree = new RouteTree();
|
82
|
-
this.record.clear();
|
83
|
-
}
|
84
|
-
render() {
|
85
|
-
this.params = {};
|
86
|
-
if (this.cache) {
|
87
|
-
const cached = this.record.get(this.pathname);
|
88
|
-
if (cached) {
|
89
|
-
Object.assign(this, cached);
|
90
|
-
return this.component;
|
91
|
-
}
|
92
|
-
}
|
93
|
-
switch (this.type) {
|
94
|
-
case "field":
|
95
|
-
this.component = this.fieldComponent();
|
96
|
-
break;
|
97
|
-
case "slotted":
|
98
|
-
this.component = this.slottedComponent();
|
99
|
-
break;
|
100
|
-
case "united":
|
101
|
-
this.component = this.fieldComponent() ?? this.slottedComponent();
|
102
|
-
break;
|
103
|
-
}
|
104
|
-
return this.component ?? this.default;
|
105
|
-
}
|
106
|
-
useRouter() {
|
107
|
-
return {
|
108
|
-
pathname: this.pathname,
|
109
|
-
params: this.params,
|
110
|
-
path: this.path,
|
111
|
-
component: this.component,
|
112
|
-
};
|
113
|
-
}
|
114
|
-
connectedCallback() {
|
115
|
-
super.connectedCallback();
|
116
|
-
this.pathname = window.location.pathname;
|
117
|
-
if (!this.override) {
|
118
|
-
return;
|
119
|
-
}
|
120
|
-
this.addEvent(window, "popstate", () => {
|
121
|
-
this.pathname = window.location.pathname;
|
122
|
-
});
|
123
|
-
const self = this;
|
124
|
-
const pushHistory = history.pushState;
|
125
|
-
const { override } = conf;
|
126
|
-
if (!override.pushState) {
|
127
|
-
override.pushState = pushHistory;
|
128
|
-
}
|
129
|
-
history.pushState = function () {
|
130
|
-
pushHistory.apply(this, arguments);
|
131
|
-
self.pathname = window.location.pathname;
|
132
|
-
};
|
133
|
-
const replaceHistory = history.replaceState;
|
134
|
-
history.replaceState = function () {
|
135
|
-
replaceHistory.apply(this, arguments);
|
136
|
-
self.pathname = window.location.pathname;
|
137
|
-
};
|
138
|
-
}
|
139
|
-
updated(changedProperties) {
|
140
|
-
const shouldDispatch = changedProperties.has("pathname") || changedProperties.has("path");
|
141
|
-
if (shouldDispatch) {
|
142
|
-
const ur = this.useRouter();
|
143
|
-
const noRecord = !this.record.has(this.pathname);
|
144
|
-
if (noRecord) {
|
145
|
-
this.record.set(this.pathname, ur);
|
146
|
-
}
|
147
|
-
this.routeChangeCallback?.(ur, noRecord);
|
148
|
-
this.dispatchEvent(new CustomEvent("change", { detail: ur }));
|
149
|
-
}
|
150
|
-
}
|
151
|
-
fieldComponent(usedRouteTemplate) {
|
152
|
-
if (!usedRouteTemplate) {
|
153
|
-
usedRouteTemplate = this.useWhichRoute(this.pathname);
|
154
|
-
}
|
155
|
-
this.path = usedRouteTemplate;
|
156
|
-
if (!usedRouteTemplate) {
|
157
|
-
return null;
|
158
|
-
}
|
159
|
-
this.params = this.parseRouterParams(this.path, this.pathname);
|
160
|
-
const route = this.routes.find((r) => r.path === usedRouteTemplate);
|
161
|
-
if (!route) {
|
162
|
-
return null;
|
163
|
-
}
|
164
|
-
return route.component;
|
165
|
-
}
|
166
|
-
slottedComponent(usedRouteTemplate) {
|
167
|
-
const childNodes = this.slottedChildren;
|
168
|
-
if (!childNodes.length) {
|
169
|
-
return null;
|
170
|
-
}
|
171
|
-
const slottedPaths = Array.from(childNodes).map((node) => {
|
172
|
-
const slotName = node.getAttribute("slot");
|
173
|
-
return {
|
174
|
-
path: slotName,
|
175
|
-
};
|
176
|
-
});
|
177
|
-
const tempRouteTree = new RouteTree();
|
178
|
-
for (const withPath of slottedPaths) {
|
179
|
-
tempRouteTree.insert(withPath.path);
|
180
|
-
}
|
181
|
-
if (!usedRouteTemplate) {
|
182
|
-
usedRouteTemplate = tempRouteTree.useWhich(this.pathname);
|
183
|
-
if (!usedRouteTemplate) {
|
184
|
-
return null;
|
185
|
-
}
|
186
|
-
}
|
187
|
-
const slotElement = slottedPaths.find((s) => s.path === usedRouteTemplate);
|
188
|
-
if (!slotElement) {
|
189
|
-
return null;
|
190
|
-
}
|
191
|
-
this.params = this.parseRouterParams(usedRouteTemplate, this.pathname);
|
192
|
-
return htmlSlot(slotElement.path);
|
193
|
-
}
|
194
|
-
useWhichRoute(path) {
|
195
|
-
return this._routeTree.useWhich(this.baseURL + path);
|
196
|
-
}
|
197
|
-
parseRouterParams(routeTemplate, path) {
|
198
|
-
return this._routeTree.parseParams(path, routeTemplate);
|
199
|
-
}
|
200
|
-
static updateAll() {
|
201
|
-
const routeViewArray = deepQuerySelectorAll(Router_1.elementTagName, document.body);
|
202
|
-
routeViewArray.forEach((ArrayItem) => {
|
203
|
-
if (!ArrayItem.override) {
|
204
|
-
ArrayItem.pathname = window.location.pathname;
|
205
|
-
}
|
206
|
-
});
|
207
|
-
}
|
208
|
-
};
|
209
|
-
__decorate([
|
210
|
-
state()
|
211
|
-
], Router.prototype, "component", void 0);
|
212
|
-
__decorate([
|
213
|
-
state()
|
214
|
-
], Router.prototype, "params", void 0);
|
215
|
-
__decorate([
|
216
|
-
state()
|
217
|
-
], Router.prototype, "path", void 0);
|
218
|
-
__decorate([
|
219
|
-
property()
|
220
|
-
], Router.prototype, "pathname", void 0);
|
221
|
-
__decorate([
|
222
|
-
property()
|
223
|
-
], Router.prototype, "baseURL", void 0);
|
224
|
-
__decorate([
|
225
|
-
state()
|
226
|
-
], Router.prototype, "default", void 0);
|
227
|
-
__decorate([
|
228
|
-
property()
|
229
|
-
], Router.prototype, "type", void 0);
|
230
|
-
__decorate([
|
231
|
-
state()
|
232
|
-
], Router.prototype, "override", void 0);
|
233
|
-
__decorate([
|
234
|
-
property({ type: Boolean })
|
235
|
-
], Router.prototype, "cache", void 0);
|
236
|
-
Router = Router_1 = __decorate([
|
237
|
-
godown(protoName),
|
238
|
-
styles(css `
|
239
|
-
:host {
|
240
|
-
display: contents;
|
241
|
-
}
|
242
|
-
`)
|
243
|
-
], Router);
|
244
|
-
export { Router };
|
245
|
-
export default Router;
|
246
|
-
//# sourceMappingURL=router.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/router/router.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAqB,MAAM,yBAAyB,CAAC;AACtE,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9D,MAAM,SAAS,GAAG,QAAQ,CAAC;AAE3B;;;;GAIG;AAOI,IAAM,MAAM,cAA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AAE;sCAAqC;AAIpC;IAAR,KAAK,EAAE;oCAAqB;AAIjB;IAAX,QAAQ,EAAE;wCAAe;AAId;IAAX,QAAQ,EAAE;uCAAc;AAIhB;IAAR,KAAK,EAAE;uCAAoC;AAIhC;IAAX,QAAQ,EAAE;oCAAiD;AAInD;IAAR,KAAK,EAAE;wCAAiB;AAII;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qCAAe;AAvChC,MAAM;IANlB,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CAAC,GAAG,CAAA;;;;CAIV,CAAC;GACW,MAAM,CA4MlB;;AAED,eAAe,MAAM,CAAC","sourcesContent":["import { css, property, type PropertyValueMap, state } from \"../../_deps.js\";\nimport conf from \"../../conf.js\";\nimport { godown } from \"../../decorators/godown.js\";\nimport { styles } from \"../../decorators/styles.js\";\nimport { htmlSlot, type HTMLTemplate } from \"../../lib/directives.js\";\nimport RouteTree from \"../../lib/route-tree.js\";\nimport { deepQuerySelectorAll } from \"../../lib/utils.js\";\nimport { GodownElement } from \"../../proto/godown-element.js\";\n\ntype WithRecord<T extends string> = Record<string, any> & Record<T, string>;\n\nconst protoName = \"router\";\n\n/**\n * {@linkcode Router} has basic routing control.\n *\n * To switch routes, use history api or router-link.\n */\n@godown(protoName)\n@styles(css`\n :host {\n display: contents;\n }\n`)\nexport class Router<T = unknown> extends GodownElement {\n private _routes: (WithRecord<\"path\"> & { component?: T })[] = [];\n private _routeTree: RouteTree = new RouteTree();\n\n /**\n * Component will render.\n */\n @state() component: T | HTMLTemplate = null;\n /**\n * Dynamic parameters record.\n */\n @state() params: Record<string, string> = {};\n /**\n * Value of matched path in routes, or null.\n */\n @state() path: string = null;\n /**\n * Current pathname (location.pathname).\n */\n @property() pathname = \"\";\n /**\n * Path prefix.\n */\n @property() baseURL = \"\";\n /**\n * Rendered content when there is no match.\n */\n @state() default: HTMLTemplate = htmlSlot();\n /**\n * The type of routing query.\n */\n @property() type: \"united\" | \"slotted\" | \"field\" = \"united\";\n /**\n * Rewrite history.\n */\n @state() override = true;\n /**\n * Cache accessed.\n */\n @property({ type: Boolean }) cache = false;\n\n /**\n * Cache record.\n */\n record = new Map<string, ReturnType<typeof this.useRouter>>();\n\n set routes(v) {\n this._routes = v;\n this.reset();\n for (const route of v) {\n this._routeTree.insert(route.path);\n }\n this.requestUpdate();\n }\n\n get routes() {\n return this._routes;\n }\n\n reset() {\n this._routeTree = new RouteTree();\n this.record.clear();\n }\n\n protected render(): T | HTMLTemplate {\n this.params = {};\n if (this.cache) {\n const cached = this.record.get(this.pathname);\n if (cached) {\n Object.assign(this, cached);\n return this.component;\n }\n }\n switch (this.type) {\n case \"field\":\n this.component = this.fieldComponent();\n break;\n case \"slotted\":\n this.component = this.slottedComponent();\n break;\n case \"united\":\n this.component = this.fieldComponent() ?? this.slottedComponent();\n break;\n }\n return this.component ?? this.default;\n }\n\n useRouter(): { path: string; component: HTMLTemplate | T; params: Record<string, string>; pathname: string } {\n return {\n pathname: this.pathname,\n params: this.params,\n path: this.path,\n component: this.component,\n };\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.pathname = window.location.pathname;\n if (!this.override) {\n return;\n }\n this.addEvent(window, \"popstate\", () => {\n this.pathname = window.location.pathname;\n });\n const self = this;\n const pushHistory = history.pushState;\n\n const { override } = conf;\n if (!override.pushState) {\n override.pushState = pushHistory;\n }\n history.pushState = function () {\n pushHistory.apply(this, arguments);\n self.pathname = window.location.pathname;\n };\n const replaceHistory = history.replaceState;\n history.replaceState = function () {\n replaceHistory.apply(this, arguments);\n self.pathname = window.location.pathname;\n };\n }\n\n /**\n *\n * @param ur value of useRouter()\n * @param first whether this path is loaded for the first time\n */\n routeChangeCallback: (ur: ReturnType<typeof this.useRouter>, first: boolean) => void = null;\n\n protected updated(changedProperties: PropertyValueMap<this>) {\n const shouldDispatch = changedProperties.has(\"pathname\") || changedProperties.has(\"path\");\n if (shouldDispatch) {\n const ur = this.useRouter();\n const noRecord = !this.record.has(this.pathname);\n if (noRecord) {\n this.record.set(this.pathname, ur);\n }\n this.routeChangeCallback?.(ur, noRecord);\n this.dispatchEvent(new CustomEvent(\"change\", { detail: ur }));\n }\n }\n\n fieldComponent(usedRouteTemplate?: string): null | T {\n if (!usedRouteTemplate) {\n usedRouteTemplate = this.useWhichRoute(this.pathname);\n }\n this.path = usedRouteTemplate;\n if (!usedRouteTemplate) {\n return null;\n }\n this.params = this.parseRouterParams(this.path, this.pathname);\n const route = this.routes.find((r) => r.path === usedRouteTemplate);\n if (!route) {\n return null;\n }\n return route.component;\n }\n\n slottedComponent(usedRouteTemplate?: string): null | HTMLTemplate {\n const childNodes = this.slottedChildren;\n if (!childNodes.length) {\n return null;\n }\n const slottedPaths = Array.from(childNodes).map((node) => {\n const slotName = node.getAttribute(\"slot\");\n return {\n path: slotName,\n };\n });\n const tempRouteTree = new RouteTree();\n for (const withPath of slottedPaths) {\n tempRouteTree.insert(withPath.path);\n }\n if (!usedRouteTemplate) {\n usedRouteTemplate = tempRouteTree.useWhich(this.pathname);\n if (!usedRouteTemplate) {\n return null;\n }\n }\n const slotElement = slottedPaths.find((s) => s.path === usedRouteTemplate);\n if (!slotElement) {\n return null;\n }\n this.params = this.parseRouterParams(usedRouteTemplate, this.pathname);\n return htmlSlot(slotElement.path);\n }\n\n useWhichRoute(path: string): string | null {\n return this._routeTree.useWhich(this.baseURL + path);\n }\n\n parseRouterParams(routeTemplate: string, path: string): Record<string, string> {\n return this._routeTree.parseParams(path, routeTemplate);\n }\n\n static updateAll() {\n const routeViewArray = deepQuerySelectorAll<Router>(Router.elementTagName, document.body);\n routeViewArray.forEach((ArrayItem) => {\n if (!ArrayItem.override) {\n ArrayItem.pathname = window.location.pathname;\n }\n });\n }\n}\n\nexport default Router;\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"skeleton.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/skeleton/skeleton.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAM9D;;;;;;;GAOG;AACH,qBAwEa,QAAS,SAAQ,aAAa;IACzC;;OAEG;IACS,IAAI,EAAE,MAAM,GAAG,OAAO,CAAU;IAC5C;;OAEG;IACS,SAAS,EAAE,UAAU,GAAG,SAAS,CAAc;IAC3D;;OAEG;IACM,OAAO,UAAQ;IAExB,SAAS,CAAC,MAAM;CAQjB;AAED,eAAe,QAAQ,CAAC"}
|
@@ -1,130 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import { css, html, property, state } from "../../_deps.js";
|
3
|
-
import { godown } from "../../decorators/godown.js";
|
4
|
-
import { styles } from "../../decorators/styles.js";
|
5
|
-
import { ifValue } from "../../lib/directives.js";
|
6
|
-
import { htmlSlot } from "../../lib/directives.js";
|
7
|
-
import { svgImage } from "../../lib/icons.js";
|
8
|
-
import { GodownElement } from "../../proto/godown-element.js";
|
9
|
-
import { createScope, cssGlobalVars } from "../../styles/global.js";
|
10
|
-
const protoName = "skeleton";
|
11
|
-
const cssScope = createScope(protoName);
|
12
|
-
/**
|
13
|
-
* {@linkcode Skeleton} renders a skeleton screen.
|
14
|
-
*
|
15
|
-
* Inspired by Ant-design.
|
16
|
-
*
|
17
|
-
* @slot loading - The content if loading is true.
|
18
|
-
* @slot - The content if loading is false.
|
19
|
-
*/
|
20
|
-
let Skeleton = class Skeleton extends GodownElement {
|
21
|
-
constructor() {
|
22
|
-
super(...arguments);
|
23
|
-
/**
|
24
|
-
* Skeleton type.
|
25
|
-
*/
|
26
|
-
this.type = "text";
|
27
|
-
/**
|
28
|
-
* Animation type.
|
29
|
-
*/
|
30
|
-
this.animation = "position";
|
31
|
-
/**
|
32
|
-
* If false, hidden.
|
33
|
-
*/
|
34
|
-
this.loading = true;
|
35
|
-
}
|
36
|
-
render() {
|
37
|
-
if (!this.loading) {
|
38
|
-
return htmlSlot();
|
39
|
-
}
|
40
|
-
return html `<div part="root" class="${this.animation}">
|
41
|
-
${ifValue(this.type === "image", svgImage(), htmlSlot("loading"))}
|
42
|
-
</div>`;
|
43
|
-
}
|
44
|
-
};
|
45
|
-
__decorate([
|
46
|
-
property()
|
47
|
-
], Skeleton.prototype, "type", void 0);
|
48
|
-
__decorate([
|
49
|
-
property()
|
50
|
-
], Skeleton.prototype, "animation", void 0);
|
51
|
-
__decorate([
|
52
|
-
state()
|
53
|
-
], Skeleton.prototype, "loading", void 0);
|
54
|
-
Skeleton = __decorate([
|
55
|
-
godown(protoName),
|
56
|
-
styles([
|
57
|
-
css `
|
58
|
-
:host {
|
59
|
-
--${cssScope}--from: rgb(var(--${cssGlobalVars.foregroundRGB}) / 7.5%);
|
60
|
-
--${cssScope}--to: rgb(var(--${cssGlobalVars.foregroundRGB}) / 22%);
|
61
|
-
--${cssScope}--deg: 94deg;
|
62
|
-
--${cssScope}--color: rgb(var(--${cssGlobalVars.foregroundRGB}) / 50%);
|
63
|
-
--${cssScope}--background: var(--${cssGlobalVars.background});
|
64
|
-
--${cssScope}--duration: 1.5s;
|
65
|
-
--${cssScope}--icon-width: 5em;
|
66
|
-
--${cssScope}--icon-height: 5em;
|
67
|
-
--${cssScope}--icon-margin: .75em;
|
68
|
-
color: var(--${cssScope}--color);
|
69
|
-
background: var(--${cssScope}--background);
|
70
|
-
min-height: 1.5em;
|
71
|
-
width: 100%;
|
72
|
-
flex-shrink: 0;
|
73
|
-
display: block;
|
74
|
-
overflow: hidden;
|
75
|
-
}
|
76
|
-
|
77
|
-
[part="root"] {
|
78
|
-
height: 100%;
|
79
|
-
min-height: inherit;
|
80
|
-
text-align: center;
|
81
|
-
animation: var(--${cssScope}--duration) ease-in-out 0s infinite none running;
|
82
|
-
}
|
83
|
-
|
84
|
-
svg {
|
85
|
-
width: var(--${cssScope}--icon-width);
|
86
|
-
height: var(--${cssScope}--icon-height);
|
87
|
-
margin: var(--${cssScope}--icon-margin);
|
88
|
-
}
|
89
|
-
|
90
|
-
.position {
|
91
|
-
background-image: linear-gradient(
|
92
|
-
var(--${cssScope}--deg),
|
93
|
-
var(--${cssScope}--from) 36%,
|
94
|
-
var(--${cssScope}--to) 50%,
|
95
|
-
var(--${cssScope}--from) 64%
|
96
|
-
);
|
97
|
-
background-color: transparent;
|
98
|
-
background-size: 200% 100%;
|
99
|
-
animation-name: po;
|
100
|
-
}
|
101
|
-
|
102
|
-
@keyframes po {
|
103
|
-
from {
|
104
|
-
background-position: 150% center;
|
105
|
-
}
|
106
|
-
to {
|
107
|
-
background-position: -50% center;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
.opacity {
|
112
|
-
background: var(--${cssScope}--from);
|
113
|
-
animation-name: op;
|
114
|
-
animation-direction: alternate;
|
115
|
-
}
|
116
|
-
|
117
|
-
@keyframes op {
|
118
|
-
50% {
|
119
|
-
opacity: 0.2;
|
120
|
-
}
|
121
|
-
to {
|
122
|
-
opacity: 1;
|
123
|
-
}
|
124
|
-
}
|
125
|
-
`,
|
126
|
-
])
|
127
|
-
], Skeleton);
|
128
|
-
export { Skeleton };
|
129
|
-
export default Skeleton;
|
130
|
-
//# sourceMappingURL=skeleton.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"skeleton.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/skeleton/skeleton.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,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;A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;;;;;;;;;;;;;;;;0BAiBE,QAAQ;;;;;;;;;;;;;GAa/B;KACF,CAAC;GACW,QAAQ,CAsBpB;;AAED,eAAe,QAAQ,CAAC","sourcesContent":["import { css, html, property, state } from \"../../_deps.js\";\nimport { godown } from \"../../decorators/godown.js\";\nimport { styles } from \"../../decorators/styles.js\";\nimport { ifValue } from \"../../lib/directives.js\";\nimport { htmlSlot } from \"../../lib/directives.js\";\nimport { svgImage } from \"../../lib/icons.js\";\nimport { GodownElement } from \"../../proto/godown-element.js\";\nimport { createScope, cssGlobalVars } from \"../../styles/global.js\";\n\nconst protoName = \"skeleton\";\nconst cssScope = createScope(protoName);\n\n/**\n * {@linkcode Skeleton} renders a skeleton screen.\n *\n * Inspired by Ant-design.\n *\n * @slot loading - The content if loading is true.\n * @slot - The content if loading is false.\n */\n@godown(protoName)\n@styles([\n css`\n :host {\n --${cssScope}--from: rgb(var(--${cssGlobalVars.foregroundRGB}) / 7.5%);\n --${cssScope}--to: rgb(var(--${cssGlobalVars.foregroundRGB}) / 22%);\n --${cssScope}--deg: 94deg;\n --${cssScope}--color: rgb(var(--${cssGlobalVars.foregroundRGB}) / 50%);\n --${cssScope}--background: var(--${cssGlobalVars.background});\n --${cssScope}--duration: 1.5s;\n --${cssScope}--icon-width: 5em;\n --${cssScope}--icon-height: 5em;\n --${cssScope}--icon-margin: .75em;\n color: var(--${cssScope}--color);\n background: var(--${cssScope}--background);\n min-height: 1.5em;\n width: 100%;\n flex-shrink: 0;\n display: block;\n overflow: hidden;\n }\n\n [part=\"root\"] {\n height: 100%;\n min-height: inherit;\n text-align: center;\n animation: var(--${cssScope}--duration) ease-in-out 0s infinite none running;\n }\n\n svg {\n width: var(--${cssScope}--icon-width);\n height: var(--${cssScope}--icon-height);\n margin: var(--${cssScope}--icon-margin);\n }\n\n .position {\n background-image: linear-gradient(\n var(--${cssScope}--deg),\n var(--${cssScope}--from) 36%,\n var(--${cssScope}--to) 50%,\n var(--${cssScope}--from) 64%\n );\n background-color: transparent;\n background-size: 200% 100%;\n animation-name: po;\n }\n\n @keyframes po {\n from {\n background-position: 150% center;\n }\n to {\n background-position: -50% center;\n }\n }\n\n .opacity {\n background: var(--${cssScope}--from);\n animation-name: op;\n animation-direction: alternate;\n }\n\n @keyframes op {\n 50% {\n opacity: 0.2;\n }\n to {\n opacity: 1;\n }\n }\n `,\n])\nexport class Skeleton extends GodownElement {\n /**\n * Skeleton type.\n */\n @property() type: \"text\" | \"image\" = \"text\";\n /**\n * Animation type.\n */\n @property() animation: \"position\" | \"opacity\" = \"position\";\n /**\n * If false, hidden.\n */\n @state() loading = true;\n\n protected render() {\n if (!this.loading) {\n return htmlSlot();\n }\n return html`<div part=\"root\" class=\"${this.animation}\">\n ${ifValue(this.type === \"image\", svgImage(), htmlSlot(\"loading\"))}\n </div>`;\n }\n}\n\nexport default Skeleton;\n"]}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { GodownElement } from "../../proto/godown-element.js";
|
2
|
-
/**
|
3
|
-
* {@linkcode Overbreath} render the text with a breathing effect.
|
4
|
-
*
|
5
|
-
* Dynamically generate a breathing effect based on the length of the split text.
|
6
|
-
*
|
7
|
-
* If there is not enough CSS variable `--${CSSprefix}--${number}`, the initial value will be repeated.
|
8
|
-
*
|
9
|
-
* Inspired by Vercel home page (2023).
|
10
|
-
*
|
11
|
-
*/
|
12
|
-
export declare class Overbreath extends GodownElement {
|
13
|
-
text: string | string[];
|
14
|
-
duration: string;
|
15
|
-
speedup: string;
|
16
|
-
protected render(): import("lit").TemplateResult<1>;
|
17
|
-
protected renderText(text: string): import("lit").TemplateResult<1>;
|
18
|
-
protected getTexts(): string[];
|
19
|
-
protected parseDuration(): number;
|
20
|
-
}
|
21
|
-
export default Overbreath;
|
22
|
-
//# sourceMappingURL=overbreath.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"overbreath.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/text/overbreath.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAM9D;;;;;;;;;GASG;AACH,qBA2Da,UAAW,SAAQ,aAAa;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAE5B,SAAS,CAAC,MAAM;IAsBhB,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM;IAMjC,SAAS,CAAC,QAAQ,IAAI,MAAM,EAAE;IAI9B,SAAS,CAAC,aAAa;CAUxB;AAED,eAAe,UAAU,CAAC"}
|
@@ -1,132 +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 { htmlStyle } from "../../lib/directives.js";
|
6
|
-
import { GodownElement } from "../../proto/godown-element.js";
|
7
|
-
import { colorValues, createScope, cssGlobalVars } from "../../styles/global.js";
|
8
|
-
const defineName = "overbreath";
|
9
|
-
const cssScope = createScope(defineName);
|
10
|
-
/**
|
11
|
-
* {@linkcode Overbreath} render the text with a breathing effect.
|
12
|
-
*
|
13
|
-
* Dynamically generate a breathing effect based on the length of the split text.
|
14
|
-
*
|
15
|
-
* If there is not enough CSS variable `--${CSSprefix}--${number}`, the initial value will be repeated.
|
16
|
-
*
|
17
|
-
* Inspired by Vercel home page (2023).
|
18
|
-
*
|
19
|
-
*/
|
20
|
-
let Overbreath = class Overbreath extends GodownElement {
|
21
|
-
render() {
|
22
|
-
const texts = this.getTexts();
|
23
|
-
const len = texts.length;
|
24
|
-
const gap = 100 / 2 / len;
|
25
|
-
const duration = this.parseDuration() || len * 2 + 2;
|
26
|
-
const t = duration / len;
|
27
|
-
return html `${texts.map(this.renderText)}
|
28
|
-
${htmlStyle(`.colorful{animation-duration:${duration}s;}` +
|
29
|
-
`@keyframes colorfulN{0%,${gap * 3}%{opacity:0;}${gap}%,${gap * 2}%{opacity: 1;}}` +
|
30
|
-
texts
|
31
|
-
.map((_, index) => {
|
32
|
-
const number = index + 1;
|
33
|
-
const delay = -1 * t * (len - (number - 2));
|
34
|
-
const defaultNumber = ((number - 1) % 3) + 1;
|
35
|
-
return `.rel:nth-child(${number}) .colorful{animation-delay:${delay}s;background:var(--${cssScope}--${number},var(--${cssScope}--${defaultNumber}));}`;
|
36
|
-
})
|
37
|
-
.join(""))}`;
|
38
|
-
}
|
39
|
-
renderText(text) {
|
40
|
-
return html `<span class="rel">
|
41
|
-
<span class="nocolor">${text}</span>
|
42
|
-
<span class="colorful">${text}</span>
|
43
|
-
</span>`;
|
44
|
-
}
|
45
|
-
getTexts() {
|
46
|
-
return Array.isArray(this.text) ? this.text : (this.text || this.textContent).split(/\s+/).filter((x) => x);
|
47
|
-
}
|
48
|
-
parseDuration() {
|
49
|
-
const { duration } = this;
|
50
|
-
if (duration) {
|
51
|
-
if (duration.endsWith("s")) {
|
52
|
-
return parseFloat(duration.slice(0, -1));
|
53
|
-
}
|
54
|
-
else if (duration.endsWith("ms")) {
|
55
|
-
return parseFloat(duration.slice(0, -2)) / 1000;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
59
|
-
};
|
60
|
-
__decorate([
|
61
|
-
property()
|
62
|
-
], Overbreath.prototype, "text", void 0);
|
63
|
-
__decorate([
|
64
|
-
property()
|
65
|
-
], Overbreath.prototype, "duration", void 0);
|
66
|
-
__decorate([
|
67
|
-
property()
|
68
|
-
], Overbreath.prototype, "speedup", void 0);
|
69
|
-
Overbreath = __decorate([
|
70
|
-
godown(defineName),
|
71
|
-
styles([
|
72
|
-
css `
|
73
|
-
:host {
|
74
|
-
--${cssScope}--deg: 60deg;
|
75
|
-
--${cssScope}--1-1: ${colorValues.red[5]};
|
76
|
-
--${cssScope}--1-2: ${colorValues.yellow[5]};
|
77
|
-
--${cssScope}--2-1: ${colorValues.green[5]};
|
78
|
-
--${cssScope}--2-2: ${colorValues.purple[5]};
|
79
|
-
--${cssScope}--3-1: ${colorValues.blue[5]};
|
80
|
-
--${cssScope}--3-2: ${colorValues.pink[5]};
|
81
|
-
--${cssScope}--1: linear-gradient(var(--${cssScope}--deg), var(--${cssScope}--1-1), var(--${cssScope}--1-2));
|
82
|
-
--${cssScope}--2: linear-gradient(var(--${cssScope}--deg), var(--${cssScope}--2-1), var(--${cssScope}--2-2));
|
83
|
-
--${cssScope}--3: linear-gradient(var(--${cssScope}--deg), var(--${cssScope}--3-1), var(--${cssScope}--3-2));
|
84
|
-
}
|
85
|
-
`,
|
86
|
-
css `
|
87
|
-
:host {
|
88
|
-
display: flex;
|
89
|
-
margin: auto;
|
90
|
-
width: -moz-fit-content;
|
91
|
-
width: fit-content;
|
92
|
-
font-size: 2em;
|
93
|
-
align-items: center;
|
94
|
-
}
|
95
|
-
|
96
|
-
::selection {
|
97
|
-
background: none;
|
98
|
-
}
|
99
|
-
|
100
|
-
.rel {
|
101
|
-
position: relative;
|
102
|
-
font-weight: 800;
|
103
|
-
font-size: inherit;
|
104
|
-
letter-spacing: -0.05em;
|
105
|
-
}
|
106
|
-
`,
|
107
|
-
css `
|
108
|
-
.nocolor,
|
109
|
-
.colorful {
|
110
|
-
padding: 0 0.05em;
|
111
|
-
box-sizing: border-box;
|
112
|
-
display: inline-block;
|
113
|
-
animation-iteration-count: infinite;
|
114
|
-
-webkit-text-fill-color: transparent;
|
115
|
-
-webkit-background-clip: text !important;
|
116
|
-
background-clip: text !important;
|
117
|
-
}
|
118
|
-
.colorful {
|
119
|
-
opacity: 0;
|
120
|
-
animation-name: colorfulN;
|
121
|
-
}
|
122
|
-
.nocolor {
|
123
|
-
position: absolute;
|
124
|
-
top: 0;
|
125
|
-
background: var(--${cssGlobalVars.clipBackground});
|
126
|
-
}
|
127
|
-
`,
|
128
|
-
])
|
129
|
-
], Overbreath);
|
130
|
-
export { Overbreath };
|
131
|
-
export default Overbreath;
|
132
|
-
//# sourceMappingURL=overbreath.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"overbreath.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/text/overbreath.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEjF,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;AAEzC;;;;;;;;;GASG;AA4DI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,aAAa;IAKjC,MAAM;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;QACzB,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,QAAQ,GAAG,GAAG,CAAC;QAEzB,OAAO,IAAI,CAAA,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;MACtC,SAAS,CACT,gCAAgC,QAAQ,KAAK;YAC3C,2BAA2B,GAAG,GAAG,CAAC,gBAAgB,GAAG,KAAK,GAAG,GAAG,CAAC,iBAAiB;YAClF,KAAK;iBACF,GAAG,CAAC,CAAC,CAAC,EAA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AC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA9Ca;IAAX,QAAQ,EAAE;wCAAyB;AACxB;IAAX,QAAQ,EAAE;4CAAkB;AACjB;IAAX,QAAQ,EAAE;2CAAiB;AAHjB,UAAU;IA3DtB,MAAM,CAAC,UAAU,CAAC;IAClB,MAAM,CAAC;QACN,GAAG,CAAA;;UAEK,QAAQ;UACR,QAAQ,UAAU,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;UACpC,QAAQ,UAAU,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;UACvC,QAAQ,UAAU,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;UACtC,QAAQ,UAAU,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;UACvC,QAAQ,UAAU,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;UACrC,QAAQ,UAAU,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;UACrC,QAAQ,8BAA8B,QAAQ,iBAAiB,QAAQ,iBAAiB,QAAQ;UAChG,QAAQ,8BAA8B,QAAQ,iBAAiB,QAAQ,iBAAiB,QAAQ;UAChG,QAAQ,8BAA8B,QAAQ,iBAAiB,QAAQ,iBAAiB,QAAQ;;GAEvG;QACD,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;GAoBF;QACD,GAAG,CAAA;;;;;;;;;;;;;;;;;;0BAkBqB,aAAa,CAAC,cAAc;;GAEnD;KACF,CAAC;GACW,UAAU,CA+CtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, html, property } from \"../../_deps.js\";\nimport { godown } from \"../../decorators/godown.js\";\nimport { styles } from \"../../decorators/styles.js\";\nimport { htmlStyle } from \"../../lib/directives.js\";\nimport { GodownElement } from \"../../proto/godown-element.js\";\nimport { colorValues, createScope, cssGlobalVars } from \"../../styles/global.js\";\n\nconst defineName = \"overbreath\";\nconst cssScope = createScope(defineName);\n\n/**\n * {@linkcode Overbreath} render the text with a breathing effect.\n *\n * Dynamically generate a breathing effect based on the length of the split text.\n *\n * If there is not enough CSS variable `--${CSSprefix}--${number}`, the initial value will be repeated.\n *\n * Inspired by Vercel home page (2023).\n *\n */\n@godown(defineName)\n@styles([\n css`\n :host {\n --${cssScope}--deg: 60deg;\n --${cssScope}--1-1: ${colorValues.red[5]};\n --${cssScope}--1-2: ${colorValues.yellow[5]};\n --${cssScope}--2-1: ${colorValues.green[5]};\n --${cssScope}--2-2: ${colorValues.purple[5]};\n --${cssScope}--3-1: ${colorValues.blue[5]};\n --${cssScope}--3-2: ${colorValues.pink[5]};\n --${cssScope}--1: linear-gradient(var(--${cssScope}--deg), var(--${cssScope}--1-1), var(--${cssScope}--1-2));\n --${cssScope}--2: linear-gradient(var(--${cssScope}--deg), var(--${cssScope}--2-1), var(--${cssScope}--2-2));\n --${cssScope}--3: linear-gradient(var(--${cssScope}--deg), var(--${cssScope}--3-1), var(--${cssScope}--3-2));\n }\n `,\n css`\n :host {\n display: flex;\n margin: auto;\n width: -moz-fit-content;\n width: fit-content;\n font-size: 2em;\n align-items: center;\n }\n\n ::selection {\n background: none;\n }\n\n .rel {\n position: relative;\n font-weight: 800;\n font-size: inherit;\n letter-spacing: -0.05em;\n }\n `,\n css`\n .nocolor,\n .colorful {\n padding: 0 0.05em;\n box-sizing: border-box;\n display: inline-block;\n animation-iteration-count: infinite;\n -webkit-text-fill-color: transparent;\n -webkit-background-clip: text !important;\n background-clip: text !important;\n }\n .colorful {\n opacity: 0;\n animation-name: colorfulN;\n }\n .nocolor {\n position: absolute;\n top: 0;\n background: var(--${cssGlobalVars.clipBackground});\n }\n `,\n])\nexport class Overbreath extends GodownElement {\n @property() text: string | string[];\n @property() duration: string;\n @property() speedup: string;\n\n protected render() {\n const texts = this.getTexts();\n const len = texts.length;\n const gap = 100 / 2 / len;\n const duration = this.parseDuration() || len * 2 + 2;\n const t = duration / len;\n\n return html`${texts.map(this.renderText)}\n ${htmlStyle(\n `.colorful{animation-duration:${duration}s;}` +\n `@keyframes colorfulN{0%,${gap * 3}%{opacity:0;}${gap}%,${gap * 2}%{opacity: 1;}}` +\n texts\n .map((_, index) => {\n const number = index + 1;\n const delay = -1 * t * (len - (number - 2));\n const defaultNumber = ((number - 1) % 3) + 1;\n return `.rel:nth-child(${number}) .colorful{animation-delay:${delay}s;background:var(--${cssScope}--${number},var(--${cssScope}--${defaultNumber}));}`;\n })\n .join(\"\"),\n )}`;\n }\n\n protected renderText(text: string) {\n return html`<span class=\"rel\">\n <span class=\"nocolor\">${text}</span>\n <span class=\"colorful\">${text}</span>\n </span>`;\n }\n protected getTexts(): string[] {\n return Array.isArray(this.text) ? this.text : (this.text || this.textContent).split(/\\s+/).filter((x) => x);\n }\n\n protected parseDuration() {\n const { duration } = this;\n if (duration) {\n if (duration.endsWith(\"s\")) {\n return parseFloat(duration.slice(0, -1));\n } else if (duration.endsWith(\"ms\")) {\n return parseFloat(duration.slice(0, -2)) / 1000;\n }\n }\n }\n}\n\nexport default Overbreath;\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/text/text.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAO9D;;GAEG;AACH,qBAmDa,IAAK,SAAQ,aAAa;IACrC;;OAEG;IACS,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAU;IAEvE;;OAEG;IAC0B,IAAI,EAAE,OAAO,CAAC;IAE3C,SAAS,CAAC,MAAM;CAWjB;AAED,eAAe,IAAI,CAAC"}
|