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