godown 3.0.0-canary.10 → 3.0.0-canary.12
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 +3 -3
- package/alert.d.ts +1 -0
- package/alert.d.ts.map +1 -1
- package/avatar.d.ts +1 -0
- package/avatar.d.ts.map +1 -1
- package/button.d.ts +1 -0
- package/button.d.ts.map +1 -1
- package/card.d.ts +1 -0
- package/card.d.ts.map +1 -1
- package/carousel.d.ts +1 -0
- package/carousel.d.ts.map +1 -1
- package/components/alert.d.ts +2 -1
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +6 -8
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts +2 -1
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +8 -5
- package/components/avatar.js.map +1 -1
- package/components/breath.d.ts +3 -2
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +6 -5
- package/components/breath.js.map +1 -1
- package/components/button.d.ts +5 -3
- package/components/button.d.ts.map +1 -1
- package/components/button.js +20 -3
- package/components/button.js.map +1 -1
- package/components/card.d.ts +2 -1
- package/components/card.d.ts.map +1 -1
- package/components/card.js +5 -4
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts +3 -1
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +17 -11
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts +2 -1
- package/components/details.d.ts.map +1 -1
- package/components/details.js +3 -2
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +2 -2
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +5 -3
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts +2 -3
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +5 -6
- package/components/divider.js.map +1 -1
- package/components/dragbox.d.ts +2 -1
- package/components/dragbox.d.ts.map +1 -1
- package/components/dragbox.js +4 -2
- 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 +5 -4
- package/components/flex.js.map +1 -1
- package/components/form.d.ts +2 -1
- package/components/form.d.ts.map +1 -1
- package/components/form.js.map +1 -1
- package/components/grid.d.ts +2 -1
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js +5 -4
- package/components/grid.js.map +1 -1
- package/components/input.d.ts +2 -1
- package/components/input.d.ts.map +1 -1
- package/components/input.js +3 -2
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +2 -1
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +6 -6
- package/components/layout.js.map +1 -1
- package/components/link.d.ts +4 -0
- package/components/link.d.ts.map +1 -1
- package/components/link.js +10 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts +2 -1
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +5 -4
- package/components/progress.js.map +1 -1
- package/components/range.d.ts +3 -2
- package/components/range.d.ts.map +1 -1
- package/components/range.js +8 -7
- package/components/range.js.map +1 -1
- package/components/rotate.d.ts +2 -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 +9 -9
- package/components/router.d.ts.map +1 -1
- package/components/router.js.map +1 -1
- package/components/select.d.ts +2 -1
- package/components/select.d.ts.map +1 -1
- package/components/select.js +11 -5
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts +2 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +5 -4
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +2 -1
- package/components/split.d.ts.map +1 -1
- package/components/split.js +4 -3
- package/components/split.js.map +1 -1
- package/components/switch.d.ts +2 -1
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +4 -3
- package/components/switch.js.map +1 -1
- package/components/text.d.ts +2 -1
- package/components/text.d.ts.map +1 -1
- package/components/text.js +9 -6
- package/components/text.js.map +1 -1
- package/components/time.d.ts +2 -2
- package/components/time.d.ts.map +1 -1
- package/components/time.js +3 -2
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +2 -1
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +4 -3
- 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 +4 -5
- package/components/typewriter.js.map +1 -1
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +1 -1
- package/core/global-style.js.map +1 -1
- package/core/super-anchor.d.ts +2 -1
- package/core/super-anchor.d.ts.map +1 -1
- package/core/super-anchor.js +4 -3
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +3 -2
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +10 -4
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts.map +1 -1
- package/core/super-openable.js +1 -1
- package/core/super-openable.js.map +1 -1
- package/custom-elements.json +1 -1
- package/details.d.ts +1 -0
- package/details.d.ts.map +1 -1
- package/dev/alert.d.ts +1 -0
- package/dev/alert.d.ts.map +1 -1
- package/dev/alert.js +1 -0
- package/dev/alert.js.map +1 -1
- package/dev/avatar.d.ts +1 -0
- package/dev/avatar.d.ts.map +1 -1
- package/dev/avatar.js +1 -0
- package/dev/avatar.js.map +1 -1
- package/dev/button.d.ts +1 -0
- package/dev/button.d.ts.map +1 -1
- package/dev/button.js +1 -0
- package/dev/button.js.map +1 -1
- package/dev/card.d.ts +1 -0
- package/dev/card.d.ts.map +1 -1
- package/dev/card.js +1 -0
- package/dev/card.js.map +1 -1
- package/dev/carousel.d.ts +1 -0
- package/dev/carousel.d.ts.map +1 -1
- package/dev/carousel.js +1 -0
- package/dev/carousel.js.map +1 -1
- package/dev/components/alert.d.ts +2 -1
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +12 -10
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts +2 -1
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +21 -7
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/breath.d.ts +3 -2
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +17 -5
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +5 -3
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +23 -2
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +2 -1
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +8 -5
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +3 -1
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +27 -13
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +2 -1
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +8 -3
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +2 -2
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +12 -10
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts +2 -3
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +19 -7
- package/dev/components/divider.js.map +1 -1
- package/dev/components/dragbox.d.ts +2 -1
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js +9 -1
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts +2 -1
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +16 -4
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts +2 -1
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts +2 -1
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +16 -4
- package/dev/components/grid.js.map +1 -1
- package/dev/components/input.d.ts +2 -1
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +2 -1
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +2 -1
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +13 -6
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.d.ts +4 -0
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +10 -1
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +2 -1
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +7 -2
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +3 -2
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +27 -22
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +2 -1
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +1 -1
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +9 -9
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +2 -1
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +18 -7
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts +2 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +4 -3
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +2 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +15 -11
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +2 -1
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +15 -14
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.d.ts +2 -1
- package/dev/components/text.d.ts.map +1 -1
- package/dev/components/text.js +8 -4
- package/dev/components/text.js.map +1 -1
- package/dev/components/time.d.ts +2 -2
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +5 -2
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +2 -1
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +24 -12
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts +2 -2
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +11 -4
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +10 -1
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-anchor.d.ts +2 -1
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +8 -5
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +3 -2
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +13 -5
- package/dev/core/super-input.js.map +1 -1
- package/dev/core/super-openable.d.ts.map +1 -1
- package/dev/core/super-openable.js +1 -1
- package/dev/core/super-openable.js.map +1 -1
- package/dev/details.d.ts +1 -0
- package/dev/details.d.ts.map +1 -1
- package/dev/details.js +1 -0
- package/dev/details.js.map +1 -1
- package/dev/dialog.d.ts +1 -0
- package/dev/dialog.d.ts.map +1 -1
- package/dev/dialog.js +1 -0
- package/dev/dialog.js.map +1 -1
- package/dev/divider.d.ts +1 -0
- package/dev/divider.d.ts.map +1 -1
- package/dev/divider.js +1 -0
- package/dev/divider.js.map +1 -1
- package/dev/dragbox.d.ts +1 -0
- package/dev/dragbox.d.ts.map +1 -1
- package/dev/dragbox.js +1 -0
- package/dev/dragbox.js.map +1 -1
- package/dev/flex.d.ts +1 -0
- package/dev/flex.d.ts.map +1 -1
- package/dev/flex.js +1 -0
- package/dev/flex.js.map +1 -1
- package/dev/form.d.ts +1 -0
- package/dev/form.d.ts.map +1 -1
- package/dev/form.js +1 -0
- package/dev/form.js.map +1 -1
- package/dev/grid.d.ts +1 -0
- package/dev/grid.d.ts.map +1 -1
- package/dev/grid.js +1 -0
- package/dev/grid.js.map +1 -1
- package/dev/layout.d.ts.map +1 -1
- package/dev/progress.d.ts.map +1 -1
- package/dev/router.d.ts.map +1 -1
- package/dev/split.d.ts +1 -1
- package/dev/split.d.ts.map +1 -1
- package/dev/typewriter.d.ts +1 -0
- package/dev/typewriter.d.ts.map +1 -1
- package/dev/typewriter.js +1 -0
- package/dev/typewriter.js.map +1 -1
- package/dialog.d.ts +1 -0
- package/dialog.d.ts.map +1 -1
- package/divider.d.ts +1 -0
- package/divider.d.ts.map +1 -1
- package/dragbox.d.ts +1 -0
- package/dragbox.d.ts.map +1 -1
- package/flex.d.ts +1 -0
- package/flex.d.ts.map +1 -1
- package/form.d.ts +1 -0
- package/form.d.ts.map +1 -1
- package/grid.d.ts +1 -0
- package/grid.d.ts.map +1 -1
- package/layout.d.ts.map +1 -1
- package/package.json +9 -5
- package/progress.d.ts.map +1 -1
- package/router.d.ts.map +1 -1
- package/split.d.ts +1 -1
- package/split.d.ts.map +1 -1
- package/src/alert.ts +2 -0
- package/src/avatar.ts +2 -0
- package/src/button.ts +2 -0
- package/src/card.ts +2 -0
- package/src/carousel.ts +2 -0
- package/src/components/alert.ts +18 -16
- package/src/components/avatar.ts +25 -11
- package/src/components/breath.ts +22 -10
- package/src/components/button.ts +21 -15
- package/src/components/card.ts +9 -6
- package/src/components/carousel.ts +36 -21
- package/src/components/details.ts +10 -5
- package/src/components/dialog.ts +19 -18
- package/src/components/divider.ts +19 -7
- package/src/components/dragbox.ts +16 -9
- package/src/components/flex.ts +17 -5
- package/src/components/form.ts +4 -4
- package/src/components/grid.ts +17 -5
- package/src/components/input.ts +5 -4
- package/src/components/layout.ts +15 -8
- package/src/components/link.ts +10 -2
- package/src/components/progress.ts +9 -4
- package/src/components/range.ts +44 -45
- package/src/components/rotate.ts +9 -6
- package/src/components/router.ts +27 -19
- package/src/components/select.ts +31 -20
- package/src/components/skeleton.ts +6 -5
- package/src/components/split.ts +23 -19
- package/src/components/switch.ts +20 -19
- package/src/components/text.ts +7 -9
- package/src/components/time.ts +12 -9
- package/src/components/tooltip.ts +26 -14
- package/src/components/typewriter.ts +19 -14
- package/src/core/global-style.ts +23 -4
- package/src/core/super-anchor.ts +11 -8
- package/src/core/super-input.ts +23 -21
- package/src/core/super-openable.ts +5 -5
- package/src/details.ts +2 -0
- package/src/dialog.ts +2 -0
- package/src/divider.ts +2 -0
- package/src/dragbox.ts +2 -0
- package/src/flex.ts +2 -0
- package/src/form.ts +2 -0
- package/src/grid.ts +2 -0
- package/src/layout.ts +1 -0
- package/src/progress.ts +1 -0
- package/src/router.ts +1 -0
- package/src/split.ts +1 -1
- package/src/typewriter.ts +2 -0
- package/typewriter.d.ts +1 -0
- package/typewriter.d.ts.map +1 -1
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
@@ -1,8 +1,9 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
3
4
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
4
5
|
import iconPhoto from "@godown/f7-icon/icons/photo.js";
|
5
|
-
import { css, html } from "lit";
|
6
|
+
import { css, html, type TemplateResult } from "lit";
|
6
7
|
import { property, state } from "lit/decorators.js";
|
7
8
|
|
8
9
|
import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
|
@@ -49,7 +50,7 @@ const cssScope = scopePrefix(protoName);
|
|
49
50
|
margin: calc(var(--size) * 0.05);
|
50
51
|
}
|
51
52
|
|
52
|
-
|
53
|
+
[animation=position] {
|
53
54
|
background-image: linear-gradient(
|
54
55
|
var(${cssScope}--deg),
|
55
56
|
var(${cssScope}--from) 36%,
|
@@ -70,7 +71,7 @@ const cssScope = scopePrefix(protoName);
|
|
70
71
|
}
|
71
72
|
}
|
72
73
|
|
73
|
-
|
74
|
+
[animation=opacity] {
|
74
75
|
animation-name: op;
|
75
76
|
animation-direction: alternate;
|
76
77
|
}
|
@@ -105,11 +106,11 @@ class Skeleton extends GlobalStyle {
|
|
105
106
|
@state()
|
106
107
|
loading = true;
|
107
108
|
|
108
|
-
protected render() {
|
109
|
+
protected render(): TemplateResult<1> {
|
109
110
|
if (!this.loading) {
|
110
111
|
return htmlSlot();
|
111
112
|
}
|
112
|
-
return html`<div part="root"
|
113
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
113
114
|
${this.type === "image" ? iconPhoto() : ""}
|
114
115
|
${htmlSlot("loading")}</div>`;
|
115
116
|
}
|
package/src/components/split.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
3
4
|
import { classList } from "@godown/element/directives/class-list.js";
|
4
5
|
import { type HandlerEvent } from "@godown/element/element.js";
|
5
|
-
import { css, html, nothing } from "lit";
|
6
|
+
import { css, html, nothing, type TemplateResult } from "lit";
|
6
7
|
import { property, state } from "lit/decorators.js";
|
7
8
|
|
8
9
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
@@ -40,12 +41,16 @@ const loop = <T>(len: number, fn: (index?: number) => T) => {
|
|
40
41
|
${cssScope}--gap: .25em;
|
41
42
|
}
|
42
43
|
|
44
|
+
:host([contents]) [part=root] {
|
45
|
+
width: fit-content;
|
46
|
+
}
|
47
|
+
|
43
48
|
[part=root] {
|
44
49
|
gap: var(${cssScope}--gap);
|
45
50
|
width: 100%;
|
46
51
|
position: relative;
|
47
52
|
vertical-align: top;
|
48
|
-
display:
|
53
|
+
display: flex;
|
49
54
|
justify-content: space-between;
|
50
55
|
border-radius: inherit;
|
51
56
|
}
|
@@ -92,9 +97,8 @@ class Split extends SuperInput {
|
|
92
97
|
@state()
|
93
98
|
currentValue: (string | void)[] = [];
|
94
99
|
|
95
|
-
protected render() {
|
96
|
-
return html
|
97
|
-
<div part="root">
|
100
|
+
protected render(): TemplateResult<1> {
|
101
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
98
102
|
${
|
99
103
|
loop(this.len, (index: number) =>
|
100
104
|
html`<span part="input-box"
|
@@ -102,16 +106,16 @@ class Split extends SuperInput {
|
|
102
106
|
class="${classList({ focus: this.current === index }) || nothing}"
|
103
107
|
>${this.currentValue[index]}</span>`)
|
104
108
|
}
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
<input
|
110
|
+
part="input"
|
111
|
+
id="${this.makeId}"
|
112
|
+
@blur=${this.blur}
|
113
|
+
@input="${this._handleInput}"
|
114
|
+
.value="${
|
111
115
|
/* Ensure that input always has a value of length this.len */
|
112
116
|
this.value.padStart(this.len, " ")}"
|
113
|
-
|
114
|
-
|
117
|
+
>
|
118
|
+
</div>
|
115
119
|
`;
|
116
120
|
}
|
117
121
|
|
@@ -120,7 +124,7 @@ class Split extends SuperInput {
|
|
120
124
|
this.reset();
|
121
125
|
}
|
122
126
|
|
123
|
-
protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>) {
|
127
|
+
protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>): void {
|
124
128
|
e.stopPropagation();
|
125
129
|
if (this.compositing) {
|
126
130
|
return;
|
@@ -149,7 +153,7 @@ class Split extends SuperInput {
|
|
149
153
|
*
|
150
154
|
* @param data Input event data.
|
151
155
|
*/
|
152
|
-
protected fillInput(data: string | null) {
|
156
|
+
protected fillInput(data: string | null): void {
|
153
157
|
if (data === null) {
|
154
158
|
// delete
|
155
159
|
|
@@ -192,23 +196,23 @@ class Split extends SuperInput {
|
|
192
196
|
}
|
193
197
|
}
|
194
198
|
|
195
|
-
focus() {
|
199
|
+
focus(): void {
|
196
200
|
this.focusAt(this.current);
|
197
201
|
super.focus();
|
198
202
|
}
|
199
203
|
|
200
|
-
focusAt(i: number) {
|
204
|
+
focusAt(i: number): void {
|
201
205
|
this.current = i;
|
202
206
|
this._input.focus();
|
203
207
|
}
|
204
208
|
|
205
|
-
blur() {
|
209
|
+
blur(): void {
|
206
210
|
this._input.blur();
|
207
211
|
this.current = -1;
|
208
212
|
super.blur();
|
209
213
|
}
|
210
214
|
|
211
|
-
reset() {
|
215
|
+
reset(): void {
|
212
216
|
this.current = -1;
|
213
217
|
this.value = this.default;
|
214
218
|
this.currentValue = this.value.split("").concat(Array(this.len - this.value.length).fill(null));
|
package/src/components/switch.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
-
import {
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
|
+
import { css, html, type TemplateResult } from "lit";
|
4
5
|
import { property, query } from "lit/decorators.js";
|
5
6
|
|
6
7
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
@@ -20,6 +21,13 @@ const cssScope = scopePrefix(protoName);
|
|
20
21
|
@godown(protoName)
|
21
22
|
@styles(
|
22
23
|
css`
|
24
|
+
:host,
|
25
|
+
:host([contents]) [part=root] {
|
26
|
+
width: var(${cssScope}-width);
|
27
|
+
height: var(${cssScope}-height);
|
28
|
+
display: inline-block;
|
29
|
+
}
|
30
|
+
|
23
31
|
:host {
|
24
32
|
${cssScope}-width: 3em;
|
25
33
|
${cssScope}-height: calc(var(${cssScope}-width) / 2);
|
@@ -27,9 +35,6 @@ const cssScope = scopePrefix(protoName);
|
|
27
35
|
${cssScope}-handle-space: .125em;
|
28
36
|
${cssScope}-transition: .2s ease-in-out;
|
29
37
|
background: var(${cssGlobalVars.input}-background);
|
30
|
-
width: var(${cssScope}-width);
|
31
|
-
height: var(${cssScope}-height);
|
32
|
-
display: inline-block;
|
33
38
|
vertical-align: bottom;
|
34
39
|
border-radius: 0;
|
35
40
|
}
|
@@ -44,14 +49,10 @@ const cssScope = scopePrefix(protoName);
|
|
44
49
|
position: relative;
|
45
50
|
height: inherit;
|
46
51
|
}
|
47
|
-
|
48
|
-
[part=root],
|
49
|
-
input {
|
50
|
-
width: 100%;
|
51
|
-
}
|
52
|
-
|
52
|
+
|
53
53
|
input {
|
54
54
|
opacity: 0;
|
55
|
+
width: 100%;
|
55
56
|
height: 100%;
|
56
57
|
appearance: none;
|
57
58
|
}
|
@@ -70,6 +71,7 @@ const cssScope = scopePrefix(protoName);
|
|
70
71
|
|
71
72
|
:host([round]) {
|
72
73
|
border-radius: calc(var(${cssScope}-height) / 2);
|
74
|
+
background: var(${cssGlobalVars.passive});
|
73
75
|
}
|
74
76
|
|
75
77
|
:host([checked]) span {
|
@@ -93,10 +95,6 @@ const cssScope = scopePrefix(protoName);
|
|
93
95
|
margin: var(${cssScope}-handle-space);
|
94
96
|
}
|
95
97
|
|
96
|
-
.round {
|
97
|
-
background: var(${cssGlobalVars.passive});
|
98
|
-
}
|
99
|
-
|
100
98
|
:host([checked]) .round {
|
101
99
|
background: var(${cssGlobalVars.active});
|
102
100
|
}
|
@@ -136,8 +134,11 @@ class Switch extends SuperInput {
|
|
136
134
|
@query("input")
|
137
135
|
protected _input: HTMLInputElement;
|
138
136
|
|
139
|
-
protected render() {
|
140
|
-
return html`<div part="root"
|
137
|
+
protected render(): TemplateResult<1> {
|
138
|
+
return html`<div part="root"
|
139
|
+
${attr(this.observedRecord)}
|
140
|
+
class="${this.round ? "round" : "rect"}"
|
141
|
+
>
|
141
142
|
<input
|
142
143
|
part="input"
|
143
144
|
@change="${this._handleChange}"
|
@@ -151,12 +152,12 @@ class Switch extends SuperInput {
|
|
151
152
|
</div>`;
|
152
153
|
}
|
153
154
|
|
154
|
-
reset() {
|
155
|
+
reset(): void {
|
155
156
|
this.checked = this.default === "true";
|
156
157
|
this._input.checked = this.checked;
|
157
158
|
}
|
158
159
|
|
159
|
-
connectedCallback() {
|
160
|
+
connectedCallback(): void {
|
160
161
|
super.connectedCallback();
|
161
162
|
if (this.checked) {
|
162
163
|
this.default = "true";
|
@@ -166,7 +167,7 @@ class Switch extends SuperInput {
|
|
166
167
|
}
|
167
168
|
}
|
168
169
|
|
169
|
-
protected _handleChange() {
|
170
|
+
protected _handleChange(): void {
|
170
171
|
this.checked = this._input.checked;
|
171
172
|
this.dispatchEvent(new CustomEvent("input", { detail: this.checked, bubbles: true, composed: true }));
|
172
173
|
this.dispatchEvent(new CustomEvent("change", { detail: this.checked, composed: true }));
|
package/src/components/text.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
3
4
|
import { classList } from "@godown/element/directives/class-list.js";
|
4
5
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
-
import { css, html } from "lit";
|
6
|
+
import { css, html, type TemplateResult } from "lit";
|
6
7
|
import { property } from "lit/decorators.js";
|
7
8
|
|
8
9
|
import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
|
@@ -56,7 +57,7 @@ const cssScope = scopePrefix(protoName);
|
|
56
57
|
text-decoration: none;
|
57
58
|
}
|
58
59
|
|
59
|
-
|
60
|
+
[clip] {
|
60
61
|
background: var(${cssGlobalVars.clipBackground});
|
61
62
|
display: inline-block;
|
62
63
|
color: transparent;
|
@@ -76,16 +77,13 @@ class Text extends GlobalStyle {
|
|
76
77
|
* Set background-clip to text.
|
77
78
|
*/
|
78
79
|
@property({ type: Boolean })
|
79
|
-
clip
|
80
|
+
clip = false;
|
80
81
|
|
81
|
-
protected render() {
|
82
|
+
protected render(): TemplateResult<1> {
|
82
83
|
return html`<span
|
83
84
|
part="root"
|
84
|
-
|
85
|
-
classList(this.underline
|
86
|
-
clip: this.clip,
|
87
|
-
})
|
88
|
-
}"
|
85
|
+
${attr(this.observedRecord)}
|
86
|
+
class="${classList(this.underline)}"
|
89
87
|
>
|
90
88
|
${htmlSlot()}
|
91
89
|
</span>`;
|
package/src/components/time.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
3
4
|
import fmtime from "fmtime";
|
4
|
-
import { css, type PropertyValues } from "lit";
|
5
|
+
import { css, html, type PropertyValues, TemplateResult } from "lit";
|
5
6
|
import { property } from "lit/decorators.js";
|
6
7
|
|
7
8
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -32,27 +33,29 @@ class Time extends GlobalStyle {
|
|
32
33
|
* Time.
|
33
34
|
*/
|
34
35
|
@property({ type: Object })
|
35
|
-
time = new Date();
|
36
|
+
time: Date = new Date();
|
36
37
|
|
37
38
|
/**
|
38
39
|
* If there is a value, update every gap or timeout.
|
39
40
|
*/
|
40
41
|
@property({ type: Number })
|
41
|
-
timeout;
|
42
|
+
timeout: any;
|
42
43
|
|
43
44
|
/**
|
44
45
|
* The number of milliseconds that change with each update.
|
45
46
|
*/
|
46
47
|
@property({ type: Number })
|
47
|
-
gap;
|
48
|
+
gap: any;
|
48
49
|
|
49
50
|
protected timeoutId: number;
|
50
51
|
|
51
|
-
protected render():
|
52
|
-
return
|
52
|
+
protected render(): TemplateResult<1> {
|
53
|
+
return html`<span part="root" ${attr(this.observedRecord)}>
|
54
|
+
${fmtime(this.format, this.time, this.escape)}
|
55
|
+
</span>`;
|
53
56
|
}
|
54
57
|
|
55
|
-
protected firstUpdated() {
|
58
|
+
protected firstUpdated(): void {
|
56
59
|
if (this.timeout) {
|
57
60
|
this.timeoutId = this.startTimeout();
|
58
61
|
}
|
@@ -67,11 +70,11 @@ class Time extends GlobalStyle {
|
|
67
70
|
}
|
68
71
|
}
|
69
72
|
|
70
|
-
disconnectedCallback() {
|
73
|
+
disconnectedCallback(): void {
|
71
74
|
clearInterval(this.timeoutId);
|
72
75
|
}
|
73
76
|
|
74
|
-
startTimeout() {
|
77
|
+
startTimeout(): number {
|
75
78
|
return window.setInterval(() => {
|
76
79
|
this.time = new Date(this.time.getTime() + (this.gap || this.timeout));
|
77
80
|
}, Math.abs(this.timeout));
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
3
4
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
4
|
-
import { css, html } from "lit";
|
5
|
+
import { css, html, type TemplateResult } from "lit";
|
5
6
|
import { property } from "lit/decorators.js";
|
6
7
|
|
7
8
|
import { scopePrefix } from "../core/global-style.js";
|
@@ -24,12 +25,15 @@ const cssScope = scopePrefix(protoName);
|
|
24
25
|
css`
|
25
26
|
:host {
|
26
27
|
${cssScope}--tip-background: inherit;
|
27
|
-
display: inline-block;
|
28
28
|
width: fit-content;
|
29
29
|
}
|
30
|
+
|
31
|
+
:host,
|
32
|
+
[part=root] {
|
33
|
+
display: inline-flex;
|
34
|
+
}
|
30
35
|
|
31
36
|
[part=root] {
|
32
|
-
display: flex;
|
33
37
|
position: relative;
|
34
38
|
transition: inherit;
|
35
39
|
border-radius: inherit;
|
@@ -51,18 +55,25 @@ const cssScope = scopePrefix(protoName);
|
|
51
55
|
.passive {
|
52
56
|
background: var(${cssScope}--tip-background);
|
53
57
|
}
|
58
|
+
|
59
|
+
[propagation] [part=tip] {
|
60
|
+
pointer-events: none;
|
61
|
+
}
|
54
62
|
`,
|
55
63
|
css`
|
56
|
-
[direction^=top] {
|
64
|
+
[direction^=top] [part=tip] {
|
57
65
|
bottom: 100%;
|
58
66
|
}
|
59
|
-
|
67
|
+
|
68
|
+
[direction^=bottom] [part=tip] {
|
60
69
|
top: 100%;
|
61
70
|
}
|
62
|
-
|
71
|
+
|
72
|
+
[direction$=right] [part=tip] {
|
63
73
|
left: 100%;
|
64
74
|
}
|
65
|
-
|
75
|
+
|
76
|
+
[direction$=left] [part=tip] {
|
66
77
|
right: 100%;
|
67
78
|
}
|
68
79
|
`,
|
@@ -112,10 +123,12 @@ class Tooltip extends SuperOpenable {
|
|
112
123
|
"flex-end": "flex-end",
|
113
124
|
};
|
114
125
|
|
115
|
-
protected render() {
|
126
|
+
protected render(): TemplateResult<1> {
|
116
127
|
const align = Tooltip.aligns[this.align] || "inherit";
|
117
128
|
const isFocusable = this.type === "focus";
|
118
|
-
return html`<div
|
129
|
+
return html`<div
|
130
|
+
part="root"
|
131
|
+
${attr(this.observedRecord)}
|
119
132
|
tabindex="${isFocusable ? 0 : -1}"
|
120
133
|
@focus="${isFocusable ? () => this.open = true : null}"
|
121
134
|
@blur="${isFocusable ? () => this.open = false : null}"
|
@@ -123,14 +136,13 @@ class Tooltip extends SuperOpenable {
|
|
123
136
|
@mouseleave="${isFocusable ? null : () => this.open = false}"
|
124
137
|
style="justify-content:${align};align-items:${align}">
|
125
138
|
${htmlSlot()}
|
126
|
-
<div part="tip"
|
127
|
-
|
128
|
-
style="pointer-events:${this.propagation ? "none" : "all"}">
|
129
|
-
${
|
139
|
+
<div part="tip">
|
140
|
+
${
|
130
141
|
this.tip
|
131
142
|
? html`<span class="passive">${this.tip}</span>`
|
132
143
|
: htmlSlot("tip")
|
133
|
-
}
|
144
|
+
}
|
145
|
+
</div>
|
134
146
|
</div>`;
|
135
147
|
}
|
136
148
|
}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
3
4
|
import { classList } from "@godown/element/directives/class-list.js";
|
4
5
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
6
|
import { random } from "@godown/element/tools/lib.js";
|
6
|
-
import { css, html, type PropertyValueMap } from "lit";
|
7
|
+
import { css, html, type PropertyValueMap, TemplateResult } from "lit";
|
7
8
|
import { property, query, state } from "lit/decorators.js";
|
8
9
|
|
9
10
|
import { GlobalStyle, scopePrefix } from "../core/global-style.js";
|
@@ -20,7 +21,11 @@ const cssScope = scopePrefix(protoName);
|
|
20
21
|
@styles(css`
|
21
22
|
:host {
|
22
23
|
${cssScope}--cursor-width: .05em;
|
23
|
-
|
24
|
+
}
|
25
|
+
|
26
|
+
:host,
|
27
|
+
:host([contents]) [part=root] {
|
28
|
+
display: inline-block;
|
24
29
|
}
|
25
30
|
|
26
31
|
i {
|
@@ -103,19 +108,19 @@ class Typewriter extends GlobalStyle {
|
|
103
108
|
/**
|
104
109
|
* {@linkcode Typewriter.text} length.
|
105
110
|
*/
|
106
|
-
get len() {
|
111
|
+
get len(): number {
|
107
112
|
return this.text.length;
|
108
113
|
}
|
109
114
|
|
110
|
-
protected render() {
|
111
|
-
return html
|
112
|
-
|
113
|
-
|
114
|
-
})
|
115
|
-
|
115
|
+
protected render(): TemplateResult<1> {
|
116
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
117
|
+
${htmlSlot()}
|
118
|
+
${this.content}
|
119
|
+
<i part="cursor" class="${classList({ hidden: this.ended })}"></i>
|
120
|
+
</div>`;
|
116
121
|
}
|
117
122
|
|
118
|
-
protected firstUpdated() {
|
123
|
+
protected firstUpdated(): void {
|
119
124
|
if (!this.text) {
|
120
125
|
this.text = this._slot?.assignedNodes()[0]?.textContent.trim() || "";
|
121
126
|
}
|
@@ -124,13 +129,13 @@ class Typewriter extends GlobalStyle {
|
|
124
129
|
}
|
125
130
|
}
|
126
131
|
|
127
|
-
protected updated(changedProperties: PropertyValueMap<this>) {
|
132
|
+
protected updated(changedProperties: PropertyValueMap<this>): void {
|
128
133
|
if (changedProperties.has("index")) {
|
129
134
|
this.dispatchEvent(new CustomEvent(this.index === this.len ? "done" : "write", { detail: this.content }));
|
130
135
|
}
|
131
136
|
}
|
132
137
|
|
133
|
-
write(at = this.index) {
|
138
|
+
write(at: number = this.index): void {
|
134
139
|
this.content = this.text.slice(0, at + 1);
|
135
140
|
const timeout = this.delay || random(this.max, this.min);
|
136
141
|
this.timeoutID = window.setTimeout(() => {
|
@@ -142,11 +147,11 @@ class Typewriter extends GlobalStyle {
|
|
142
147
|
}, timeout);
|
143
148
|
}
|
144
149
|
|
145
|
-
stop() {
|
150
|
+
stop(): void {
|
146
151
|
clearTimeout(this.timeoutID);
|
147
152
|
}
|
148
153
|
|
149
|
-
end() {
|
154
|
+
end(): void {
|
150
155
|
this.ended = true;
|
151
156
|
}
|
152
157
|
}
|
package/src/core/global-style.ts
CHANGED
@@ -13,15 +13,25 @@ export class GlobalStyle extends GodownElement {
|
|
13
13
|
|
14
14
|
const cssvar = trim(GlobalStyle.godownConfig.prefix, "-");
|
15
15
|
|
16
|
-
export function scopePrefix(scope: string, len = 1) {
|
16
|
+
export function scopePrefix(scope: string, len = 1): CSSResult {
|
17
17
|
return variablePrefix(cssvar + "-".repeat(len) + scope);
|
18
18
|
}
|
19
19
|
|
20
|
-
export function variablePrefix(variable: string) {
|
20
|
+
export function variablePrefix(variable: string): CSSResult {
|
21
21
|
return unsafeCSS("--" + variable);
|
22
22
|
}
|
23
23
|
|
24
|
-
export const cssGlobalVars
|
24
|
+
export const cssGlobalVars: {
|
25
|
+
foreground: CSSResult;
|
26
|
+
background: CSSResult;
|
27
|
+
clipBackground: CSSResult;
|
28
|
+
active: CSSResult;
|
29
|
+
passive: CSSResult;
|
30
|
+
_colors: PresetsGradientsCSSResult;
|
31
|
+
input: CSSResult;
|
32
|
+
white: CSSResult;
|
33
|
+
black: CSSResult;
|
34
|
+
} = {
|
25
35
|
foreground: scopePrefix("foreground", 2),
|
26
36
|
background: scopePrefix("background", 2),
|
27
37
|
clipBackground: scopePrefix("clip-background", 2),
|
@@ -82,5 +92,14 @@ GlobalStyle.styles = [
|
|
82
92
|
svg {
|
83
93
|
user-select: none;
|
84
94
|
}
|
85
|
-
|
95
|
+
|
96
|
+
:host([contents]) {
|
97
|
+
display: contents;
|
98
|
+
}
|
99
|
+
|
100
|
+
:where(:host([contents]) [part=root]) {
|
101
|
+
all: inherit;
|
102
|
+
display: revert;
|
103
|
+
}
|
104
|
+
`,
|
86
105
|
];
|
package/src/core/super-anchor.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { styles } from "@godown/element/decorators/index.js";
|
2
|
+
import { attr } from "@godown/element/directives/attr.js";
|
2
3
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
3
|
-
import { css, html } from "lit";
|
4
|
+
import { css, html, type TemplateResult } from "lit";
|
4
5
|
import { property } from "lit/decorators.js";
|
5
6
|
import { ifDefined } from "lit/directives/if-defined.js";
|
6
7
|
|
@@ -18,13 +19,11 @@ import { GlobalStyle } from "./global-style.js";
|
|
18
19
|
cursor: pointer;
|
19
20
|
}
|
20
21
|
|
21
|
-
|
22
|
+
[part=root] {
|
22
23
|
width: 100%;
|
23
|
-
display: flex;
|
24
24
|
color: inherit;
|
25
|
+
display: inline-block;
|
25
26
|
text-decoration: inherit;
|
26
|
-
justify-content: space-between;
|
27
|
-
align-items: center;
|
28
27
|
}
|
29
28
|
`)
|
30
29
|
class SuperAnchor extends GlobalStyle {
|
@@ -39,14 +38,18 @@ class SuperAnchor extends GlobalStyle {
|
|
39
38
|
@property()
|
40
39
|
target: "_blank" | "_self" | "_parent" | "_top" = "_self";
|
41
40
|
|
42
|
-
protected render() {
|
43
|
-
return html`<a part="root"
|
41
|
+
protected render(): TemplateResult<1> {
|
42
|
+
return html`<a part="root"
|
43
|
+
${attr(this.observedRecord)}
|
44
|
+
href="${ifDefined(this.href)}"
|
45
|
+
target="${this.target}"
|
46
|
+
@click=${this._handleClick}>
|
44
47
|
${htmlSlot()}
|
45
48
|
</a>`;
|
46
49
|
}
|
47
50
|
|
48
51
|
// eslint-disable-next-line
|
49
|
-
protected _handleClick(_: MouseEvent) {}
|
52
|
+
protected _handleClick(_: MouseEvent): void {}
|
50
53
|
}
|
51
54
|
|
52
55
|
export default SuperAnchor;
|