godown 2.7.5 → 2.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -45
- package/{.deps.d.ts → _deps.d.ts} +1 -2
- package/{.deps.d.ts.map → _deps.d.ts.map} +1 -1
- package/{.deps.js → _deps.js} +1 -2
- package/_deps.js.map +1 -0
- package/alert.d.ts +8 -1
- package/alert.d.ts.map +1 -1
- package/alert.js +4 -1
- package/alert.js.map +1 -1
- package/avatar-group.d.ts +8 -1
- package/avatar-group.d.ts.map +1 -1
- package/avatar-group.js +4 -1
- package/avatar-group.js.map +1 -1
- package/avatar.d.ts +8 -1
- package/avatar.d.ts.map +1 -1
- package/avatar.js +4 -1
- package/avatar.js.map +1 -1
- package/button.d.ts +8 -1
- package/button.d.ts.map +1 -1
- package/button.js +4 -1
- package/button.js.map +1 -1
- package/card.d.ts +8 -1
- package/card.d.ts.map +1 -1
- package/card.js +4 -1
- package/card.js.map +1 -1
- package/carousel.d.ts +8 -1
- package/carousel.d.ts.map +1 -1
- package/carousel.js +4 -1
- package/carousel.js.map +1 -1
- package/components.json +194 -0
- package/conf.d.ts +6 -75
- package/conf.d.ts.map +1 -1
- package/conf.js +8 -34
- package/conf.js.map +1 -1
- package/decorators/godown.d.ts +4 -0
- package/decorators/godown.d.ts.map +1 -0
- package/decorators/godown.js +9 -0
- package/decorators/godown.js.map +1 -0
- package/decorators/part.d.ts +7 -0
- package/decorators/part.d.ts.map +1 -0
- package/decorators/part.js +8 -0
- package/decorators/part.js.map +1 -0
- package/decorators/styles.d.ts +3 -0
- package/decorators/styles.d.ts.map +1 -0
- package/decorators/styles.js +8 -0
- package/decorators/styles.js.map +1 -0
- package/details.d.ts +8 -1
- package/details.d.ts.map +1 -1
- package/details.js +4 -1
- package/details.js.map +1 -1
- package/dialog.d.ts +8 -1
- package/dialog.d.ts.map +1 -1
- package/dialog.js +4 -1
- package/dialog.js.map +1 -1
- package/divider.d.ts +8 -1
- package/divider.d.ts.map +1 -1
- package/divider.js +4 -1
- package/divider.js.map +1 -1
- package/dragbox.d.ts +8 -1
- package/dragbox.d.ts.map +1 -1
- package/dragbox.js +4 -1
- package/dragbox.js.map +1 -1
- package/flex-flow.d.ts +8 -1
- package/flex-flow.d.ts.map +1 -1
- package/flex-flow.js +4 -1
- package/flex-flow.js.map +1 -1
- package/form.d.ts +8 -1
- package/form.d.ts.map +1 -1
- package/form.js +4 -1
- package/form.js.map +1 -1
- package/grid-flow.d.ts +9 -0
- package/grid-flow.d.ts.map +1 -0
- package/grid-flow.js +5 -0
- package/grid-flow.js.map +1 -0
- package/index.d.ts +32 -3
- package/index.d.ts.map +1 -1
- package/index.js +32 -3
- package/index.js.map +1 -1
- package/input.d.ts +8 -1
- package/input.d.ts.map +1 -1
- package/input.js +4 -1
- package/input.js.map +1 -1
- package/label-input.d.ts +8 -1
- package/label-input.d.ts.map +1 -1
- package/label-input.js +4 -1
- package/label-input.js.map +1 -1
- package/layout.d.ts +9 -0
- package/layout.d.ts.map +1 -0
- package/layout.js +5 -0
- package/layout.js.map +1 -0
- package/lib/css.d.ts +13 -0
- package/lib/css.d.ts.map +1 -0
- package/lib/css.js +29 -0
- package/lib/css.js.map +1 -0
- package/lib/directives.d.ts +16 -20
- package/lib/directives.d.ts.map +1 -1
- package/lib/directives.js +33 -31
- package/lib/directives.js.map +1 -1
- package/lib/event-coll.d.ts +13 -0
- package/lib/event-coll.d.ts.map +1 -0
- package/lib/event-coll.js +45 -0
- package/lib/event-coll.js.map +1 -0
- package/lib/{templates.d.ts → icons.d.ts} +1 -17
- package/lib/icons.d.ts.map +1 -0
- package/lib/icons.js +73 -0
- package/lib/icons.js.map +1 -0
- package/lib/jsx.d.ts +4 -0
- package/lib/jsx.d.ts.map +1 -0
- package/lib/jsx.js +52 -0
- package/lib/jsx.js.map +1 -0
- package/lib/route-tree.d.ts +5 -5
- package/lib/route-tree.js +5 -5
- package/lib/route-tree.js.map +1 -1
- package/lib/utils.d.ts +6 -46
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +25 -110
- package/lib/utils.js.map +1 -1
- package/link.d.ts +9 -0
- package/link.d.ts.map +1 -0
- package/link.js +5 -0
- package/link.js.map +1 -0
- package/overbreath.d.ts +8 -1
- package/overbreath.d.ts.map +1 -1
- package/overbreath.js +4 -1
- package/overbreath.js.map +1 -1
- package/package.json +18 -23
- package/progress.d.ts +8 -1
- package/progress.d.ts.map +1 -1
- package/progress.js +4 -1
- package/progress.js.map +1 -1
- package/proto/godown-config.d.ts +41 -0
- package/proto/godown-config.d.ts.map +1 -0
- package/proto/godown-config.js +27 -0
- package/proto/godown-config.js.map +1 -0
- package/{godown-element.d.ts → proto/godown-element.d.ts} +48 -16
- package/proto/godown-element.d.ts.map +1 -0
- package/{godown-element.js → proto/godown-element.js} +82 -26
- package/proto/godown-element.js.map +1 -0
- package/proto/super-a.d.ts +30 -0
- package/proto/super-a.d.ts.map +1 -0
- package/proto/super-a.js +141 -0
- package/proto/super-a.js.map +1 -0
- package/proto/super-input.d.ts +44 -0
- package/proto/super-input.d.ts.map +1 -0
- package/proto/super-input.js +119 -0
- package/proto/super-input.js.map +1 -0
- package/proto/super-openable.d.ts +23 -0
- package/proto/super-openable.d.ts.map +1 -0
- package/proto/super-openable.js +43 -0
- package/proto/super-openable.js.map +1 -0
- package/range-input.d.ts +9 -0
- package/range-input.d.ts.map +1 -0
- package/range-input.js +5 -0
- package/range-input.js.map +1 -0
- package/react/create.d.ts.map +1 -1
- package/react/create.js +4 -1
- package/react/create.js.map +1 -1
- package/react/index.d.ts +64 -34
- package/react/index.d.ts.map +1 -1
- package/react/index.js +78 -51
- package/react/index.js.map +1 -1
- package/rotate.d.ts +9 -0
- package/rotate.d.ts.map +1 -0
- package/rotate.js +5 -0
- package/rotate.js.map +1 -0
- package/router-link.d.ts +9 -0
- package/router-link.d.ts.map +1 -0
- package/router-link.js +5 -0
- package/router-link.js.map +1 -0
- package/router.d.ts +8 -1
- package/router.d.ts.map +1 -1
- package/router.js +4 -1
- package/router.js.map +1 -1
- package/search-input.d.ts +8 -1
- package/search-input.d.ts.map +1 -1
- package/search-input.js +4 -1
- package/search-input.js.map +1 -1
- package/select-input.d.ts +8 -1
- package/select-input.d.ts.map +1 -1
- package/select-input.js +4 -1
- package/select-input.js.map +1 -1
- package/skeleton.d.ts +8 -1
- package/skeleton.d.ts.map +1 -1
- package/skeleton.js +4 -1
- package/skeleton.js.map +1 -1
- package/split-input.d.ts +8 -1
- package/split-input.d.ts.map +1 -1
- package/split-input.js +4 -1
- package/split-input.js.map +1 -1
- package/styles/colors/presets.d.ts +13 -0
- package/styles/colors/presets.d.ts.map +1 -0
- package/styles/colors/presets.js +6 -0
- package/styles/colors/presets.js.map +1 -0
- package/styles/colors/presetsRGB.d.ts +16 -0
- package/styles/colors/presetsRGB.d.ts.map +1 -0
- package/styles/colors/presetsRGB.js +134 -0
- package/styles/colors/presetsRGB.js.map +1 -0
- package/styles/global.d.ts +18 -0
- package/styles/global.d.ts.map +1 -0
- package/styles/global.js +78 -0
- package/styles/global.js.map +1 -0
- package/styles/inputStyle.d.ts +3 -0
- package/styles/inputStyle.d.ts.map +1 -0
- package/styles/inputStyle.js +59 -0
- package/styles/inputStyle.js.map +1 -0
- package/switch-input.d.ts +8 -1
- package/switch-input.d.ts.map +1 -1
- package/switch-input.js +4 -1
- package/switch-input.js.map +1 -1
- package/text.d.ts +8 -1
- package/text.d.ts.map +1 -1
- package/text.js +4 -1
- package/text.js.map +1 -1
- package/time.d.ts +8 -1
- package/time.d.ts.map +1 -1
- package/time.js +4 -1
- package/time.js.map +1 -1
- package/tooltip.d.ts +8 -1
- package/tooltip.d.ts.map +1 -1
- package/tooltip.js +4 -1
- package/tooltip.js.map +1 -1
- package/typewriter.d.ts +8 -1
- package/typewriter.d.ts.map +1 -1
- package/typewriter.js +4 -1
- package/typewriter.js.map +1 -1
- package/web-components/alert/alert.d.ts +2 -10
- package/web-components/alert/alert.d.ts.map +1 -1
- package/web-components/alert/alert.js +93 -91
- package/web-components/alert/alert.js.map +1 -1
- package/web-components/avatar/avatar-group.d.ts +21 -0
- package/web-components/avatar/avatar-group.d.ts.map +1 -0
- package/web-components/avatar/avatar-group.js +86 -0
- package/web-components/avatar/avatar-group.js.map +1 -0
- package/web-components/avatar/avatar.d.ts +5 -18
- package/web-components/avatar/avatar.d.ts.map +1 -1
- package/web-components/avatar/avatar.js +70 -85
- package/web-components/avatar/avatar.js.map +1 -1
- package/web-components/button/button.d.ts +10 -43
- package/web-components/button/button.d.ts.map +1 -1
- package/web-components/button/button.js +183 -226
- package/web-components/button/button.js.map +1 -1
- package/web-components/card/card.d.ts +2 -27
- package/web-components/card/card.d.ts.map +1 -1
- package/web-components/card/card.js +57 -132
- package/web-components/card/card.js.map +1 -1
- package/web-components/carousel/carousel.d.ts +5 -16
- package/web-components/carousel/carousel.d.ts.map +1 -1
- package/web-components/carousel/carousel.js +102 -106
- package/web-components/carousel/carousel.js.map +1 -1
- package/web-components/details/details.d.ts +4 -15
- package/web-components/details/details.d.ts.map +1 -1
- package/web-components/details/details.js +91 -97
- package/web-components/details/details.js.map +1 -1
- package/web-components/dialog/dialog.d.ts +6 -17
- package/web-components/dialog/dialog.d.ts.map +1 -1
- package/web-components/dialog/dialog.js +87 -137
- package/web-components/dialog/dialog.js.map +1 -1
- package/web-components/divider/divider.d.ts +13 -0
- package/web-components/divider/divider.d.ts.map +1 -0
- package/web-components/divider/divider.js +95 -0
- package/web-components/divider/divider.js.map +1 -0
- package/web-components/form/form.d.ts +15 -22
- package/web-components/form/form.d.ts.map +1 -1
- package/web-components/form/form.js +47 -117
- package/web-components/form/form.js.map +1 -1
- package/web-components/input/input.d.ts +5 -18
- package/web-components/input/input.d.ts.map +1 -1
- package/web-components/input/input.js +74 -169
- package/web-components/input/input.js.map +1 -1
- package/web-components/input/label-input.d.ts +5 -19
- package/web-components/input/label-input.d.ts.map +1 -1
- package/web-components/input/label-input.js +74 -141
- package/web-components/input/label-input.js.map +1 -1
- package/web-components/input/range-input.d.ts +53 -0
- package/web-components/input/range-input.d.ts.map +1 -0
- package/web-components/input/range-input.js +316 -0
- package/web-components/input/range-input.js.map +1 -0
- package/web-components/input/search-input.d.ts +4 -12
- package/web-components/input/search-input.d.ts.map +1 -1
- package/web-components/input/search-input.js +118 -113
- package/web-components/input/search-input.js.map +1 -1
- package/web-components/input/select-input.d.ts +17 -32
- package/web-components/input/select-input.d.ts.map +1 -1
- package/web-components/input/select-input.js +154 -286
- package/web-components/input/select-input.js.map +1 -1
- package/web-components/input/split-input.d.ts +8 -15
- package/web-components/input/split-input.d.ts.map +1 -1
- package/web-components/input/split-input.js +82 -72
- package/web-components/input/split-input.js.map +1 -1
- package/web-components/input/switch-input.d.ts +8 -17
- package/web-components/input/switch-input.d.ts.map +1 -1
- package/web-components/input/switch-input.js +122 -158
- package/web-components/input/switch-input.js.map +1 -1
- package/web-components/layout/flex-flow.d.ts +11 -19
- package/web-components/layout/flex-flow.d.ts.map +1 -1
- package/web-components/layout/flex-flow.js +57 -35
- package/web-components/layout/flex-flow.js.map +1 -1
- package/web-components/layout/grid-flow.d.ts +14 -0
- package/web-components/layout/grid-flow.d.ts.map +1 -0
- package/web-components/layout/grid-flow.js +56 -0
- package/web-components/layout/grid-flow.js.map +1 -0
- package/web-components/layout/layout.d.ts +18 -0
- package/web-components/layout/layout.d.ts.map +1 -0
- package/web-components/layout/layout.js +76 -0
- package/web-components/layout/layout.js.map +1 -0
- package/web-components/link/link.d.ts +10 -0
- package/web-components/link/link.d.ts.map +1 -0
- package/web-components/link/link.js +17 -0
- package/web-components/link/link.js.map +1 -0
- package/web-components/link/router-link.d.ts +19 -0
- package/web-components/link/router-link.d.ts.map +1 -0
- package/web-components/link/router-link.js +60 -0
- package/web-components/link/router-link.js.map +1 -0
- package/web-components/progress/progress.d.ts +2 -12
- package/web-components/progress/progress.d.ts.map +1 -1
- package/web-components/progress/progress.js +52 -48
- package/web-components/progress/progress.js.map +1 -1
- package/web-components/router/router.d.ts +15 -21
- package/web-components/router/router.d.ts.map +1 -1
- package/web-components/router/router.js +35 -37
- package/web-components/router/router.js.map +1 -1
- package/web-components/skeleton/skeleton.d.ts +5 -12
- package/web-components/skeleton/skeleton.d.ts.map +1 -1
- package/web-components/skeleton/skeleton.js +90 -98
- package/web-components/skeleton/skeleton.js.map +1 -1
- package/web-components/text/overbreath.d.ts +15 -20
- package/web-components/text/overbreath.d.ts.map +1 -1
- package/web-components/text/overbreath.js +108 -202
- package/web-components/text/overbreath.js.map +1 -1
- package/web-components/text/text.d.ts +5 -18
- package/web-components/text/text.d.ts.map +1 -1
- package/web-components/text/text.js +70 -80
- package/web-components/text/text.js.map +1 -1
- package/web-components/text/time.d.ts +5 -14
- package/web-components/text/time.d.ts.map +1 -1
- package/web-components/text/time.js +32 -31
- package/web-components/text/time.js.map +1 -1
- package/web-components/text/typewriter.d.ts +3 -11
- package/web-components/text/typewriter.d.ts.map +1 -1
- package/web-components/text/typewriter.js +42 -40
- package/web-components/text/typewriter.js.map +1 -1
- package/web-components/tooltip/tooltip.d.ts +21 -17
- package/web-components/tooltip/tooltip.d.ts.map +1 -1
- package/web-components/tooltip/tooltip.js +98 -60
- package/web-components/tooltip/tooltip.js.map +1 -1
- package/web-components/wrapper/dragbox.d.ts +5 -10
- package/web-components/wrapper/dragbox.d.ts.map +1 -1
- package/web-components/wrapper/dragbox.js +40 -31
- package/web-components/wrapper/dragbox.js.map +1 -1
- package/web-components/wrapper/rotate.d.ts +30 -0
- package/web-components/wrapper/rotate.d.ts.map +1 -0
- package/web-components/wrapper/rotate.js +92 -0
- package/web-components/wrapper/rotate.js.map +1 -0
- package/.deps.js.map +0 -1
- package/a.d.ts +0 -2
- package/a.d.ts.map +0 -1
- package/a.js +0 -2
- package/a.js.map +0 -1
- package/clip.d.ts +0 -2
- package/clip.d.ts.map +0 -1
- package/clip.js +0 -2
- package/clip.js.map +0 -1
- package/decorators/define.d.ts +0 -7
- package/decorators/define.d.ts.map +0 -1
- package/decorators/define.js +0 -11
- package/decorators/define.js.map +0 -1
- package/details-group.d.ts +0 -2
- package/details-group.d.ts.map +0 -1
- package/details-group.js +0 -2
- package/details-group.js.map +0 -1
- package/godown-element.d.ts.map +0 -1
- package/godown-element.js.map +0 -1
- package/lib/event-collection.d.ts +0 -14
- package/lib/event-collection.d.ts.map +0 -1
- package/lib/event-collection.js +0 -71
- package/lib/event-collection.js.map +0 -1
- package/lib/templates.d.ts.map +0 -1
- package/lib/templates.js +0 -76
- package/lib/templates.js.map +0 -1
- package/naming.d.ts +0 -91
- package/naming.d.ts.map +0 -1
- package/naming.js +0 -67
- package/naming.js.map +0 -1
- package/nav-layout.d.ts +0 -2
- package/nav-layout.d.ts.map +0 -1
- package/nav-layout.js +0 -2
- package/nav-layout.js.map +0 -1
- package/open-offset.d.ts +0 -2
- package/open-offset.d.ts.map +0 -1
- package/open-offset.js +0 -2
- package/open-offset.js.map +0 -1
- package/router-a.d.ts +0 -2
- package/router-a.d.ts.map +0 -1
- package/router-a.js +0 -2
- package/router-a.js.map +0 -1
- package/supers/anchor.d.ts +0 -26
- package/supers/anchor.d.ts.map +0 -1
- package/supers/anchor.js +0 -124
- package/supers/anchor.js.map +0 -1
- package/supers/input.d.ts +0 -28
- package/supers/input.d.ts.map +0 -1
- package/supers/input.js +0 -117
- package/supers/input.js.map +0 -1
- package/supers/openable.d.ts +0 -38
- package/supers/openable.d.ts.map +0 -1
- package/supers/openable.js +0 -77
- package/supers/openable.js.map +0 -1
- package/supers/root.d.ts +0 -18
- package/supers/root.d.ts.map +0 -1
- package/supers/root.js +0 -76
- package/supers/root.js.map +0 -1
- package/tabs.d.ts +0 -2
- package/tabs.d.ts.map +0 -1
- package/tabs.js +0 -2
- package/tabs.js.map +0 -1
- package/web-components/a/a.d.ts +0 -16
- package/web-components/a/a.d.ts.map +0 -1
- package/web-components/a/a.js +0 -17
- package/web-components/a/a.js.map +0 -1
- package/web-components/group/avatar-group.d.ts +0 -29
- package/web-components/group/avatar-group.d.ts.map +0 -1
- package/web-components/group/avatar-group.js +0 -88
- package/web-components/group/avatar-group.js.map +0 -1
- package/web-components/group/details-group.d.ts +0 -28
- package/web-components/group/details-group.d.ts.map +0 -1
- package/web-components/group/details-group.js +0 -59
- package/web-components/group/details-group.js.map +0 -1
- package/web-components/index.d.ts +0 -35
- package/web-components/index.d.ts.map +0 -1
- package/web-components/index.js +0 -35
- package/web-components/index.js.map +0 -1
- package/web-components/layout/divider.d.ts +0 -22
- package/web-components/layout/divider.d.ts.map +0 -1
- package/web-components/layout/divider.js +0 -85
- package/web-components/layout/divider.js.map +0 -1
- package/web-components/layout/nav-layout.d.ts +0 -38
- package/web-components/layout/nav-layout.d.ts.map +0 -1
- package/web-components/layout/nav-layout.js +0 -69
- package/web-components/layout/nav-layout.js.map +0 -1
- package/web-components/offset/open-offset.d.ts +0 -27
- package/web-components/offset/open-offset.d.ts.map +0 -1
- package/web-components/offset/open-offset.js +0 -130
- package/web-components/offset/open-offset.js.map +0 -1
- package/web-components/router/router-a.d.ts +0 -25
- package/web-components/router/router-a.d.ts.map +0 -1
- package/web-components/router/router-a.js +0 -70
- package/web-components/router/router-a.js.map +0 -1
- package/web-components/tabs/tabs.d.ts +0 -52
- package/web-components/tabs/tabs.d.ts.map +0 -1
- package/web-components/tabs/tabs.js +0 -165
- package/web-components/tabs/tabs.js.map +0 -1
- package/web-components/text/clip.d.ts +0 -22
- package/web-components/text/clip.d.ts.map +0 -1
- package/web-components/text/clip.js +0 -45
- package/web-components/text/clip.js.map +0 -1
- package/web-components/wrapper/wrapper.d.ts +0 -27
- package/web-components/wrapper/wrapper.d.ts.map +0 -1
- package/web-components/wrapper/wrapper.js +0 -95
- package/web-components/wrapper/wrapper.js.map +0 -1
- package/wrapper.d.ts +0 -2
- package/wrapper.d.ts.map +0 -1
- package/wrapper.js +0 -2
- package/wrapper.js.map +0 -1
@@ -1,8 +1,10 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
|
-
import { css, html, property } from "
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
|
2
|
+
import { css, html, property } from "../../_deps.js";
|
3
|
+
import { godown } from "../../decorators/godown.js";
|
4
|
+
import { styles } from "../../decorators/styles.js";
|
5
|
+
import { GodownElement } from "../../proto/godown-element.js";
|
6
|
+
import { cssGlobalVars } from "../../styles/global.js";
|
7
|
+
const protoName = "progress";
|
6
8
|
/**
|
7
9
|
* {@linkcode Progress} similar to progress.
|
8
10
|
*/
|
@@ -27,10 +29,10 @@ let Progress = class Progress extends GodownElement {
|
|
27
29
|
let className;
|
28
30
|
if (this.value !== null) {
|
29
31
|
width = this.parsePercent(this.value);
|
30
|
-
className = "
|
32
|
+
className = "static";
|
31
33
|
}
|
32
|
-
return html `<div class="${className}">
|
33
|
-
<i style="width:${width}%;"></i>
|
34
|
+
return html `<div part="root" class="${className}">
|
35
|
+
<i part="value" style="width:${width}%;"></i>
|
34
36
|
</div>`;
|
35
37
|
}
|
36
38
|
/**
|
@@ -46,46 +48,6 @@ let Progress = class Progress extends GodownElement {
|
|
46
48
|
return (parseFloat(String(s)) / (this.max - this.min)) * 100;
|
47
49
|
}
|
48
50
|
};
|
49
|
-
Progress.styles = [
|
50
|
-
GodownElement.styles,
|
51
|
-
css `
|
52
|
-
:host,
|
53
|
-
div {
|
54
|
-
display: inline-flex;
|
55
|
-
position: relative;
|
56
|
-
width: 10em;
|
57
|
-
height: 0.5em;
|
58
|
-
border-radius: 0.25em;
|
59
|
-
background: var(${cssvarValues.input}--false);
|
60
|
-
z-index: 1;
|
61
|
-
}
|
62
|
-
|
63
|
-
div i {
|
64
|
-
position: absolute;
|
65
|
-
border-radius: inherit;
|
66
|
-
top: 0;
|
67
|
-
left: 0;
|
68
|
-
height: 100%;
|
69
|
-
background: var(${cssvarValues.cssvar}--accept);
|
70
|
-
z-index: 2;
|
71
|
-
transition: all 0.3s;
|
72
|
-
animation: progress 1.5s ease-in-out infinite alternate;
|
73
|
-
}
|
74
|
-
|
75
|
-
@keyframes progress {
|
76
|
-
from {
|
77
|
-
left: 0;
|
78
|
-
}
|
79
|
-
to {
|
80
|
-
left: 80%;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
div.v i {
|
85
|
-
animation: none;
|
86
|
-
}
|
87
|
-
`,
|
88
|
-
];
|
89
51
|
__decorate([
|
90
52
|
property({ type: Number })
|
91
53
|
], Progress.prototype, "max", void 0);
|
@@ -96,7 +58,49 @@ __decorate([
|
|
96
58
|
property({ type: Number, reflect: true })
|
97
59
|
], Progress.prototype, "value", void 0);
|
98
60
|
Progress = __decorate([
|
99
|
-
|
61
|
+
godown(protoName),
|
62
|
+
styles(css `
|
63
|
+
:host {
|
64
|
+
width: 100%;
|
65
|
+
height: 0.5em;
|
66
|
+
display: inline-block;
|
67
|
+
border-radius: 0.25em;
|
68
|
+
background: var(--${cssGlobalVars.passive});
|
69
|
+
color: var(--${cssGlobalVars.active});
|
70
|
+
}
|
71
|
+
|
72
|
+
[part="root"] {
|
73
|
+
height: inherit;
|
74
|
+
z-index: 1;
|
75
|
+
position: relative;
|
76
|
+
border-radius: inherit;
|
77
|
+
}
|
78
|
+
|
79
|
+
[part="value"] {
|
80
|
+
position: absolute;
|
81
|
+
z-index: 2;
|
82
|
+
top: 0;
|
83
|
+
left: 0;
|
84
|
+
height: 100%;
|
85
|
+
border-radius: inherit;
|
86
|
+
transition: all 0.3s;
|
87
|
+
animation: progress 1.5s ease-in-out infinite alternate;
|
88
|
+
background: currentColor;
|
89
|
+
}
|
90
|
+
|
91
|
+
@keyframes progress {
|
92
|
+
from {
|
93
|
+
left: 0;
|
94
|
+
}
|
95
|
+
to {
|
96
|
+
left: 80%;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
.static [part="value"] {
|
101
|
+
animation: none;
|
102
|
+
}
|
103
|
+
`)
|
100
104
|
], Progress);
|
101
105
|
export { Progress };
|
102
106
|
export default Progress;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"progress.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/progress/progress.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/progress/progress.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,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B;;GAEG;AA4CI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,aAAa;IAApC;;QACL;;WAEG;QACyB,QAAG,GAAG,CAAC,CAAC;QACpC;;WAEG;QACyB,QAAG,GAAG,CAAC,CAAC;QACpC;;WAEG;QACwC,UAAK,GAAG,IAAI,CAAC;IA0B1D,CAAC;IAxBW,MAAM;QACd,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,SAAiB,CAAC;QACtB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACxB,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtC,SAAS,GAAG,QAAQ,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAA,2BAA2B,SAAS;qCACd,KAAK;WAC/B,CAAC;IACV,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,IAAqB,GAAG;QACnC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAC/D,CAAC;CACF,CAAA;AAlC6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qCAAS;AAIR;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qCAAS;AAIO;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAAc;AAZ7C,QAAQ;IA3CpB,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CAAC,GAAG,CAAA;;;;;;wBAMa,aAAa,CAAC,OAAO;mBAC1B,aAAa,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCtC,CAAC;GACW,QAAQ,CAsCpB;;AAED,eAAe,QAAQ,CAAC","sourcesContent":["import { css, html, property } from \"../../_deps.js\";\nimport { godown } from \"../../decorators/godown.js\";\nimport { styles } from \"../../decorators/styles.js\";\nimport { GodownElement } from \"../../proto/godown-element.js\";\nimport { cssGlobalVars } from \"../../styles/global.js\";\n\nconst protoName = \"progress\";\n\n/**\n * {@linkcode Progress} similar to progress.\n */\n@godown(protoName)\n@styles(css`\n :host {\n width: 100%;\n height: 0.5em;\n display: inline-block;\n border-radius: 0.25em;\n background: var(--${cssGlobalVars.passive});\n color: var(--${cssGlobalVars.active});\n }\n\n [part=\"root\"] {\n height: inherit;\n z-index: 1;\n position: relative;\n border-radius: inherit;\n }\n\n [part=\"value\"] {\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: inherit;\n transition: all 0.3s;\n animation: progress 1.5s ease-in-out infinite alternate;\n background: currentColor;\n }\n\n @keyframes progress {\n from {\n left: 0;\n }\n to {\n left: 80%;\n }\n }\n\n .static [part=\"value\"] {\n animation: none;\n }\n`)\nexport class Progress extends GodownElement {\n /**\n * Maximum.\n */\n @property({ type: Number }) max = 1;\n /**\n * Minimum.\n */\n @property({ type: Number }) min = 0;\n /**\n * Input value.\n */\n @property({ type: Number, reflect: true }) value = null;\n\n protected render() {\n let width = 20;\n let className: string;\n if (this.value !== null) {\n width = this.parsePercent(this.value);\n className = \"static\";\n }\n return html`<div part=\"root\" class=\"${className}\">\n <i part=\"value\" style=\"width:${width}%;\"></i>\n </div>`;\n }\n\n /**\n * Convert s to a percentage without a percent sign.\n *\n * @param s String or number to convert.\n * @returns Percentage without a percent sign.\n */\n parsePercent(s: string | number = \"0\"): number {\n if (String(s).includes(\"%\")) {\n return parseFloat(String(s));\n }\n return (parseFloat(String(s)) / (this.max - this.min)) * 100;\n }\n}\n\nexport default Progress;\n"]}
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import { type PropertyValueMap } from "
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import { GodownElement } from "../../supers/root.js";
|
1
|
+
import { type PropertyValueMap } from "../../_deps.js";
|
2
|
+
import { type HTMLTemplate } from "../../lib/directives.js";
|
3
|
+
import { GodownElement } from "../../proto/godown-element.js";
|
5
4
|
/**
|
6
5
|
* {@linkcode Router} has basic routing control.
|
6
|
+
*
|
7
|
+
* To switch routes, use history api or router-link.
|
7
8
|
*/
|
8
9
|
export declare class Router<T = unknown> extends GodownElement {
|
9
10
|
private _routes;
|
@@ -31,11 +32,11 @@ export declare class Router<T = unknown> extends GodownElement {
|
|
31
32
|
/**
|
32
33
|
* Rendered content when there is no match.
|
33
34
|
*/
|
34
|
-
|
35
|
+
default: HTMLTemplate;
|
35
36
|
/**
|
36
37
|
* The type of routing query.
|
37
38
|
*/
|
38
|
-
type: "united" | "
|
39
|
+
type: "united" | "slotted" | "field";
|
39
40
|
/**
|
40
41
|
* Rewrite history.
|
41
42
|
*/
|
@@ -48,10 +49,10 @@ export declare class Router<T = unknown> extends GodownElement {
|
|
48
49
|
* Cache record.
|
49
50
|
*/
|
50
51
|
record: Map<string, {
|
51
|
-
pathname: string;
|
52
|
-
params: Record<string, string>;
|
53
52
|
path: string;
|
54
|
-
component:
|
53
|
+
component: HTMLTemplate | T;
|
54
|
+
params: Record<string, string>;
|
55
|
+
pathname: string;
|
55
56
|
}>;
|
56
57
|
set routes(v: (Record<string, any> & Record<"path", string> & {
|
57
58
|
component?: T;
|
@@ -59,14 +60,13 @@ export declare class Router<T = unknown> extends GodownElement {
|
|
59
60
|
get routes(): (Record<string, any> & Record<"path", string> & {
|
60
61
|
component?: T;
|
61
62
|
})[];
|
62
|
-
static styles: import("lit").CSSResult[];
|
63
63
|
reset(): void;
|
64
64
|
protected render(): T | HTMLTemplate;
|
65
65
|
useRouter(): {
|
66
|
-
pathname: string;
|
67
|
-
params: Record<string, string>;
|
68
66
|
path: string;
|
69
|
-
component:
|
67
|
+
component: HTMLTemplate | T;
|
68
|
+
params: Record<string, string>;
|
69
|
+
pathname: string;
|
70
70
|
};
|
71
71
|
connectedCallback(): void;
|
72
72
|
/**
|
@@ -78,15 +78,9 @@ export declare class Router<T = unknown> extends GodownElement {
|
|
78
78
|
protected updated(changedProperties: PropertyValueMap<this>): void;
|
79
79
|
fieldComponent(usedRouteTemplate?: string): null | T;
|
80
80
|
slottedComponent(usedRouteTemplate?: string): null | HTMLTemplate;
|
81
|
-
useWhichRoute(path: string
|
82
|
-
parseRouterParams(routeTemplate: string,
|
81
|
+
useWhichRoute(path: string): string | null;
|
82
|
+
parseRouterParams(routeTemplate: string, path: string): Record<string, string>;
|
83
83
|
static updateAll(): void;
|
84
84
|
}
|
85
85
|
export default Router;
|
86
|
-
declare global {
|
87
|
-
interface HTMLElementTagNameMap {
|
88
|
-
"route-view": Router;
|
89
|
-
"g-router": Router;
|
90
|
-
}
|
91
|
-
}
|
92
86
|
//# sourceMappingURL=router.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/router/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAS,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/router/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAS,MAAM,gBAAgB,CAAC;AAI7E,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAM9D;;;;GAIG;AACH,qBAMa,MAAM,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,aAAa;IACpD,OAAO,CAAC,OAAO,CAAkD;IACjE,OAAO,CAAC,UAAU,CAA8B;IAEhD;;OAEG;IACM,SAAS,EAAE,CAAC,GAAG,YAAY,CAAQ;IAC5C;;OAEG;IACM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAC7C;;OAEG;IACM,IAAI,EAAE,MAAM,CAAQ;IAC7B;;OAEG;IACS,QAAQ,SAAM;IAC1B;;OAEG;IACS,OAAO,SAAM;IACzB;;OAEG;IACM,OAAO,EAAE,YAAY,CAAc;IAC5C;;OAEG;IACS,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAY;IAC5D;;OAEG;IACM,QAAQ,UAAQ;IACzB;;OAEG;IAC0B,KAAK,UAAS;IAE3C;;OAEG;IACH,MAAM;cA2Ce,MAAM;mBAAa,YAAY,GAAG,CAAC;gBAAU,OAAO,MAAM,EAAE,MAAM,CAAC;kBAAY,MAAM;OA3C5C;IAE9D,IAAI,MAAM,CAAC,CAAC;;QAAA,EAOX;IAED,IAAI,MAAM;;SAET;IAED,KAAK;IAKL,SAAS,CAAC,MAAM,IAAI,CAAC,GAAG,YAAY;IAuBpC,SAAS,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,YAAY,GAAG,CAAC,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAS5G,iBAAiB;IA2BjB;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAQ;IAE5F,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAa3D,cAAc,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,CAAC;IAgBpD,gBAAgB,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY;IA6BjE,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAI1C,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI9E,MAAM,CAAC,SAAS;CAQjB;AAED,eAAe,MAAM,CAAC"}
|
@@ -1,16 +1,20 @@
|
|
1
|
+
var Router_1;
|
1
2
|
import { __decorate } from "tslib";
|
2
|
-
import { css, property, state } from "
|
3
|
-
import
|
4
|
-
import {
|
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";
|
5
8
|
import RouteTree from "../../lib/route-tree.js";
|
6
|
-
import { htmlSlot } from "../../lib/templates.js";
|
7
9
|
import { deepQuerySelectorAll } from "../../lib/utils.js";
|
8
|
-
import { GodownElement } from "../../
|
9
|
-
const
|
10
|
+
import { GodownElement } from "../../proto/godown-element.js";
|
11
|
+
const protoName = "router";
|
10
12
|
/**
|
11
13
|
* {@linkcode Router} has basic routing control.
|
14
|
+
*
|
15
|
+
* To switch routes, use history api or router-link.
|
12
16
|
*/
|
13
|
-
let Router = class Router extends GodownElement {
|
17
|
+
let Router = Router_1 = class Router extends GodownElement {
|
14
18
|
constructor() {
|
15
19
|
super(...arguments);
|
16
20
|
this._routes = [];
|
@@ -38,7 +42,7 @@ let Router = class Router extends GodownElement {
|
|
38
42
|
/**
|
39
43
|
* Rendered content when there is no match.
|
40
44
|
*/
|
41
|
-
this.
|
45
|
+
this.default = htmlSlot();
|
42
46
|
/**
|
43
47
|
* The type of routing query.
|
44
48
|
*/
|
@@ -63,9 +67,6 @@ let Router = class Router extends GodownElement {
|
|
63
67
|
this.routeChangeCallback = null;
|
64
68
|
}
|
65
69
|
set routes(v) {
|
66
|
-
if (Object.prototype.toString.call(v) !== "[object Array]") {
|
67
|
-
return;
|
68
|
-
}
|
69
70
|
this._routes = v;
|
70
71
|
this.reset();
|
71
72
|
for (const route of v) {
|
@@ -81,6 +82,7 @@ let Router = class Router extends GodownElement {
|
|
81
82
|
this.record.clear();
|
82
83
|
}
|
83
84
|
render() {
|
85
|
+
this.params = {};
|
84
86
|
if (this.cache) {
|
85
87
|
const cached = this.record.get(this.pathname);
|
86
88
|
if (cached) {
|
@@ -88,12 +90,10 @@ let Router = class Router extends GodownElement {
|
|
88
90
|
return this.component;
|
89
91
|
}
|
90
92
|
}
|
91
|
-
this.params = {};
|
92
93
|
switch (this.type) {
|
93
94
|
case "field":
|
94
95
|
this.component = this.fieldComponent();
|
95
96
|
break;
|
96
|
-
case "child":
|
97
97
|
case "slotted":
|
98
98
|
this.component = this.slottedComponent();
|
99
99
|
break;
|
@@ -101,7 +101,7 @@ let Router = class Router extends GodownElement {
|
|
101
101
|
this.component = this.fieldComponent() ?? this.slottedComponent();
|
102
102
|
break;
|
103
103
|
}
|
104
|
-
return this.component ?? this.
|
104
|
+
return this.component ?? this.default;
|
105
105
|
}
|
106
106
|
useRouter() {
|
107
107
|
return {
|
@@ -122,6 +122,10 @@ let Router = class Router extends GodownElement {
|
|
122
122
|
});
|
123
123
|
const self = this;
|
124
124
|
const pushHistory = history.pushState;
|
125
|
+
const { override } = conf;
|
126
|
+
if (!override.pushState) {
|
127
|
+
override.pushState = pushHistory;
|
128
|
+
}
|
125
129
|
history.pushState = function () {
|
126
130
|
pushHistory.apply(this, arguments);
|
127
131
|
self.pathname = window.location.pathname;
|
@@ -160,14 +164,14 @@ let Router = class Router extends GodownElement {
|
|
160
164
|
return route.component;
|
161
165
|
}
|
162
166
|
slottedComponent(usedRouteTemplate) {
|
163
|
-
const childNodes = this.
|
167
|
+
const childNodes = this.slottedChildren;
|
164
168
|
if (!childNodes.length) {
|
165
169
|
return null;
|
166
170
|
}
|
167
171
|
const slottedPaths = Array.from(childNodes).map((node) => {
|
168
|
-
const
|
172
|
+
const slotName = node.getAttribute("slot");
|
169
173
|
return {
|
170
|
-
path:
|
174
|
+
path: slotName,
|
171
175
|
};
|
172
176
|
});
|
173
177
|
const tempRouteTree = new RouteTree();
|
@@ -175,7 +179,7 @@ let Router = class Router extends GodownElement {
|
|
175
179
|
tempRouteTree.insert(withPath.path);
|
176
180
|
}
|
177
181
|
if (!usedRouteTemplate) {
|
178
|
-
usedRouteTemplate =
|
182
|
+
usedRouteTemplate = tempRouteTree.useWhich(this.pathname);
|
179
183
|
if (!usedRouteTemplate) {
|
180
184
|
return null;
|
181
185
|
}
|
@@ -187,18 +191,14 @@ let Router = class Router extends GodownElement {
|
|
187
191
|
this.params = this.parseRouterParams(usedRouteTemplate, this.pathname);
|
188
192
|
return htmlSlot(slotElement.path);
|
189
193
|
}
|
190
|
-
useWhichRoute(path
|
191
|
-
return
|
194
|
+
useWhichRoute(path) {
|
195
|
+
return this._routeTree.useWhich(this.baseURL + path);
|
192
196
|
}
|
193
|
-
parseRouterParams(routeTemplate,
|
194
|
-
return
|
197
|
+
parseRouterParams(routeTemplate, path) {
|
198
|
+
return this._routeTree.parseParams(path, routeTemplate);
|
195
199
|
}
|
196
200
|
static updateAll() {
|
197
|
-
const
|
198
|
-
if (!routeViewTagName) {
|
199
|
-
return;
|
200
|
-
}
|
201
|
-
const routeViewArray = deepQuerySelectorAll(routeViewTagName, document.body);
|
201
|
+
const routeViewArray = deepQuerySelectorAll(Router_1.elementTagName, document.body);
|
202
202
|
routeViewArray.forEach((ArrayItem) => {
|
203
203
|
if (!ArrayItem.override) {
|
204
204
|
ArrayItem.pathname = window.location.pathname;
|
@@ -206,13 +206,6 @@ let Router = class Router extends GodownElement {
|
|
206
206
|
});
|
207
207
|
}
|
208
208
|
};
|
209
|
-
Router.styles = [
|
210
|
-
css `
|
211
|
-
:host {
|
212
|
-
display: contents;
|
213
|
-
}
|
214
|
-
`,
|
215
|
-
];
|
216
209
|
__decorate([
|
217
210
|
state()
|
218
211
|
], Router.prototype, "component", void 0);
|
@@ -230,7 +223,7 @@ __decorate([
|
|
230
223
|
], Router.prototype, "baseURL", void 0);
|
231
224
|
__decorate([
|
232
225
|
state()
|
233
|
-
], Router.prototype, "
|
226
|
+
], Router.prototype, "default", void 0);
|
234
227
|
__decorate([
|
235
228
|
property()
|
236
229
|
], Router.prototype, "type", void 0);
|
@@ -240,8 +233,13 @@ __decorate([
|
|
240
233
|
__decorate([
|
241
234
|
property({ type: Boolean })
|
242
235
|
], Router.prototype, "cache", void 0);
|
243
|
-
Router = __decorate([
|
244
|
-
|
236
|
+
Router = Router_1 = __decorate([
|
237
|
+
godown(protoName),
|
238
|
+
styles(css `
|
239
|
+
:host {
|
240
|
+
display: contents;
|
241
|
+
}
|
242
|
+
`)
|
245
243
|
], Router);
|
246
244
|
export { Router };
|
247
245
|
export default Router;
|
@@ -1 +1 @@
|
|
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,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I,CAAC,WAAW,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,SAAS;QACd,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,MAAM,cAAc,GAAG,oBAAoB,CAAS,gBAAgB,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrF,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACnC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACxB,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAChD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;AAxJM,aAAM,GAAG;IACd,GAAG,CAAA;;;;KAIF;CACF,AANY,CAMX;AA7DO;IAAR,KAAK,EAAE;yCAAoC;AAInC;IAAR,KAAK,EAAE;sCAAqC;AAIpC;IAAR,KAAK,EAAE;oCAAqB;AAIjB;IAAX,QAAQ,EAAE;wCAAe;AAId;IAAX,QAAQ,EAAE;uCAAc;AAIhB;IAAR,KAAK,EAAE;mCAAkB;AAId;IAAX,QAAQ,EAAE;oCAA2D;AAI7D;IAAR,KAAK,EAAE;wCAAiB;AAII;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qCAAe;AAvChC,MAAM;IADlB,MAAM,CAAC,UAAU,CAAC;GACN,MAAM,CAuNlB;;AAED,eAAe,MAAM,CAAC","sourcesContent":["import { css, property, type PropertyValueMap, state } from \"../../.deps.js\";\nimport { conf } from \"../../conf.js\";\nimport { define } from \"../../decorators/define.js\";\nimport RouteTree from \"../../lib/route-tree.js\";\nimport { htmlSlot, type HTMLTemplate } from \"../../lib/templates.js\";\nimport { deepQuerySelectorAll } from \"../../lib/utils.js\";\nimport { GodownElement } from \"../../supers/root.js\";\n\ntype WithRecord<T extends string> = Record<string, any> & Record<T, string>;\n\nconst defineName = \"router\";\n\n/**\n * {@linkcode Router} has basic routing control.\n */\n@define(defineName)\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() def = htmlSlot();\n /**\n * The type of routing query.\n */\n @property() type: \"united\" | \"child\" | \"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 if (Object.prototype.toString.call(v) !== \"[object Array]\") {\n return;\n }\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 static styles = [\n css`\n :host {\n display: contents;\n }\n `,\n ];\n\n reset() {\n this._routeTree = new RouteTree();\n this.record.clear();\n }\n\n protected render(): T | HTMLTemplate {\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 this.params = {};\n switch (this.type) {\n case \"field\":\n this.component = this.fieldComponent();\n break;\n case \"child\":\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.def;\n }\n\n useRouter() {\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 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.querySelectorAll(\":scope > *[slot]\");\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 = this.useWhichRoute(this.pathname, undefined, tempRouteTree);\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, baseURL = this.baseURL, appl: RouteTree = this._routeTree): string | null {\n return appl.useWhich(baseURL + path);\n }\n\n parseRouterParams(routeTemplate: string, originpath: string, appl: RouteTree = this._routeTree): Record<string, string> {\n return appl.parseParams(originpath, routeTemplate);\n }\n\n static updateAll() {\n const routeViewTagName = conf.nameMap.get(\"route-view\");\n if (!routeViewTagName) {\n return;\n }\n const routeViewArray = deepQuerySelectorAll<Router>(routeViewTagName, 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\ndeclare global {\n interface HTMLElementTagNameMap {\n \"route-view\": Router;\n \"g-router\": Router;\n }\n}\n"]}
|
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,cAAZ,MAAM,MAAoB,SAAQ,aAAa;IAA/C;;QACG,YAAO,GAA+C,EAAE,CAAC;QACzD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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,10 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import { type HTMLTemplate } from "../../lib/templates.js";
|
3
|
-
import { GodownElement } from "../../supers/root.js";
|
1
|
+
import { GodownElement } from "../../proto/godown-element.js";
|
4
2
|
/**
|
5
3
|
* {@linkcode Skeleton} renders a skeleton screen.
|
6
4
|
*
|
7
5
|
* Inspired by Ant-design.
|
6
|
+
*
|
7
|
+
* @slot loading - The content if loading is true.
|
8
|
+
* @slot - The content if loading is false.
|
8
9
|
*/
|
9
10
|
export declare class Skeleton extends GodownElement {
|
10
11
|
/**
|
@@ -19,15 +20,7 @@ export declare class Skeleton extends GodownElement {
|
|
19
20
|
* If false, hidden.
|
20
21
|
*/
|
21
22
|
loading: boolean;
|
22
|
-
|
23
|
-
protected render(): HTMLTemplate;
|
24
|
-
private renderIcon;
|
23
|
+
protected render(): import("lit").TemplateResult<1>;
|
25
24
|
}
|
26
25
|
export default Skeleton;
|
27
|
-
declare global {
|
28
|
-
interface HTMLElementTagNameMap {
|
29
|
-
"skeleton-screen": Skeleton;
|
30
|
-
"g-skeleton": Skeleton;
|
31
|
-
}
|
32
|
-
}
|
33
26
|
//# sourceMappingURL=skeleton.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"skeleton.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/skeleton/skeleton.ts"],"names":[],"mappings":"
|
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"}
|