godown 3.0.0-canary.10 → 3.0.0-canary.11
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 +1 -1
- package/components/alert.d.ts +2 -1
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +5 -7
- 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 +7 -4
- 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 +4 -3
- 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 +3 -2
- 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 +4 -3
- 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 +15 -9
- 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 +2 -1
- 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 +3 -2
- 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 +2 -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 +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 +2 -1
- 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 +5 -5
- package/components/layout.js.map +1 -1
- package/components/link.d.ts.map +1 -1
- package/components/progress.d.ts +2 -1
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +3 -2
- 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 +3 -6
- 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.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 +8 -4
- 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 +3 -2
- 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 +3 -2
- 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 +3 -2
- 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 +3 -4
- 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 +3 -2
- 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 +3 -4
- 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 +3 -2
- 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.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/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 +6 -1
- 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 +26 -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 +11 -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 +8 -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.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 +9 -12
- 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 +14 -10
- 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 +13 -9
- 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 +4 -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 +1 -1
- 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/package.json +5 -4
- 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 +16 -10
- package/src/components/card.ts +9 -6
- package/src/components/carousel.ts +35 -21
- package/src/components/details.ts +10 -5
- package/src/components/dialog.ts +18 -17
- package/src/components/divider.ts +19 -7
- package/src/components/dragbox.ts +15 -8
- 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 +1 -1
- package/src/components/progress.ts +9 -4
- package/src/components/range.ts +29 -34
- package/src/components/rotate.ts +9 -6
- package/src/components/router.ts +27 -19
- package/src/components/select.ts +31 -18
- package/src/components/skeleton.ts +6 -5
- package/src/components/split.ts +22 -18
- package/src/components/switch.ts +18 -14
- package/src/components/text.ts +6 -8
- 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 +14 -14
- package/src/core/super-openable.ts +5 -5
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
@@ -1,5 +1,6 @@
|
|
1
1
|
import { godown, styles } from "@godown/element/decorators/index.js";
|
2
|
-
import {
|
2
|
+
import { attr } from "@godown/element/directives/attr.js";
|
3
|
+
import { css, html, type TemplateResult } from "lit";
|
3
4
|
import { property } from "lit/decorators.js";
|
4
5
|
|
5
6
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -9,25 +10,36 @@ const protoName = "divider";
|
|
9
10
|
/**
|
10
11
|
* {@linkcode Divider} similar to `<hr>`.
|
11
12
|
*
|
12
|
-
* This component does not render content.
|
13
|
-
*
|
14
13
|
* @category layout
|
15
14
|
*/
|
16
15
|
@godown(protoName)
|
17
16
|
@styles(
|
18
17
|
css`
|
19
|
-
:host{
|
18
|
+
:host {
|
20
19
|
width: 100%;
|
21
20
|
height: .05em;
|
22
21
|
margin: auto;
|
23
22
|
display: block;
|
24
23
|
background: currentColor;
|
25
24
|
}
|
25
|
+
|
26
26
|
:host([vertical]) {
|
27
27
|
width: .05em;
|
28
28
|
height: max(1em, 100%);
|
29
29
|
}
|
30
|
-
|
30
|
+
|
31
|
+
:host([contents]) [part=root] {
|
32
|
+
width: 100%;
|
33
|
+
height: .05em;
|
34
|
+
margin: auto;
|
35
|
+
display: block;
|
36
|
+
background: currentColor;
|
37
|
+
}
|
38
|
+
|
39
|
+
[part=root] {
|
40
|
+
display: contents;
|
41
|
+
}
|
42
|
+
`,
|
31
43
|
)
|
32
44
|
class Divider extends GlobalStyle {
|
33
45
|
/**
|
@@ -36,8 +48,8 @@ class Divider extends GlobalStyle {
|
|
36
48
|
@property({ type: Boolean, reflect: true })
|
37
49
|
vertical = false;
|
38
50
|
|
39
|
-
|
40
|
-
this.
|
51
|
+
protected render(): TemplateResult<1> {
|
52
|
+
return html`<div part="root" ${attr(this.observedRecord)}></div>`;
|
41
53
|
}
|
42
54
|
}
|
43
55
|
|
@@ -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 { EventListenerFunc } from "@godown/element/tools/events.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 { GlobalStyle } from "../core/global-style.js";
|
@@ -61,15 +62,21 @@ class Dragbox extends GlobalStyle {
|
|
61
62
|
@property()
|
62
63
|
y = "auto";
|
63
64
|
|
64
|
-
protected render() {
|
65
|
-
return html`<div
|
65
|
+
protected render(): TemplateResult<1> {
|
66
|
+
return html`<div
|
67
|
+
part="root"
|
68
|
+
${attr(this.observedRecord)}
|
69
|
+
@mousedown="${this._handleDragStart}"
|
70
|
+
@mouseup="${this._handleDragEnd}">
|
71
|
+
${htmlSlot()}
|
72
|
+
</div>`;
|
66
73
|
}
|
67
74
|
|
68
|
-
protected firstUpdated() {
|
75
|
+
protected firstUpdated(): void {
|
69
76
|
this.reset();
|
70
77
|
}
|
71
78
|
|
72
|
-
protected _handleDragStart(e: MouseEvent) {
|
79
|
+
protected _handleDragStart(e: MouseEvent): void {
|
73
80
|
this.cx = e.clientX;
|
74
81
|
this.cy = e.clientY;
|
75
82
|
this.t = this.offsetTop;
|
@@ -82,13 +89,13 @@ class Dragbox extends GlobalStyle {
|
|
82
89
|
protected _handleMouseMove: EventListenerFunc;
|
83
90
|
protected _handleMouseLeave: EventListenerFunc;
|
84
91
|
|
85
|
-
protected _handleDragEnd() {
|
92
|
+
protected _handleDragEnd(): void {
|
86
93
|
this.drag = false;
|
87
94
|
this.events.remove(document, "mousemove", this._handleMouseMove);
|
88
95
|
this.events.remove(document, "mouseleave", this._handleMouseLeave);
|
89
96
|
}
|
90
97
|
|
91
|
-
protected _handleDrag(e: MouseEvent) {
|
98
|
+
protected _handleDrag(e: MouseEvent): void {
|
92
99
|
if (!this.drag) {
|
93
100
|
return;
|
94
101
|
}
|
@@ -111,7 +118,7 @@ class Dragbox extends GlobalStyle {
|
|
111
118
|
}
|
112
119
|
}
|
113
120
|
|
114
|
-
reset() {
|
121
|
+
reset(): void {
|
115
122
|
const { x, y, style, offsetsWidth, offsetsHeight, offsetWidth, offsetHeight, offsetLeft, offsetTop } = this;
|
116
123
|
style.left = x || "0";
|
117
124
|
style.top = y || "0";
|
package/src/components/flex.ts
CHANGED
@@ -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 { htmlSlot } from "@godown/element/directives/html-slot.js";
|
4
5
|
import { htmlStyle } from "@godown/element/directives/html-style.js";
|
5
6
|
import { joinRules } from "@godown/element/tools/css.js";
|
6
|
-
import { css } from "lit";
|
7
|
+
import { css, html, type TemplateResult } from "lit";
|
7
8
|
import { property } from "lit/decorators.js";
|
8
9
|
|
9
10
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -17,7 +18,16 @@ const protoName = "flex";
|
|
17
18
|
* @category layout
|
18
19
|
*/
|
19
20
|
@godown(protoName)
|
20
|
-
@styles(css
|
21
|
+
@styles(css`
|
22
|
+
:host,
|
23
|
+
:host([contents]) [part=root] {
|
24
|
+
display: flex;
|
25
|
+
}
|
26
|
+
|
27
|
+
[part=root] {
|
28
|
+
display: contents;
|
29
|
+
}
|
30
|
+
`)
|
21
31
|
class Flex extends GlobalStyle {
|
22
32
|
/**
|
23
33
|
* CSS property `flex-flow` (`flex-direction flex-wrap`).
|
@@ -49,8 +59,9 @@ class Flex extends GlobalStyle {
|
|
49
59
|
@property({ type: Boolean })
|
50
60
|
vertical = false;
|
51
61
|
|
52
|
-
protected render() {
|
53
|
-
return
|
62
|
+
protected render(): TemplateResult<1> {
|
63
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
64
|
+
${[
|
54
65
|
htmlSlot(),
|
55
66
|
htmlStyle(
|
56
67
|
joinRules({
|
@@ -63,7 +74,8 @@ class Flex extends GlobalStyle {
|
|
63
74
|
},
|
64
75
|
}),
|
65
76
|
),
|
66
|
-
]
|
77
|
+
]}
|
78
|
+
</div>`;
|
67
79
|
}
|
68
80
|
}
|
69
81
|
|
package/src/components/form.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
3
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
4
|
-
import { css } from "lit";
|
4
|
+
import { css, type TemplateResult } from "lit";
|
5
5
|
import { property } from "lit/decorators.js";
|
6
6
|
|
7
7
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -30,13 +30,13 @@ class Form<T = object> extends GlobalStyle {
|
|
30
30
|
return Form.buildValue(this._slot.assignedElements()) as T;
|
31
31
|
}
|
32
32
|
|
33
|
-
nameValue = this.namevalue;
|
33
|
+
nameValue: () => [string, T] = this.namevalue;
|
34
34
|
|
35
|
-
protected render() {
|
35
|
+
protected render(): TemplateResult<1> {
|
36
36
|
return htmlSlot();
|
37
37
|
}
|
38
38
|
|
39
|
-
reset() {
|
39
|
+
reset(): void {
|
40
40
|
this.deepQuerySelectorAll<HTMLElement & { reset?: () => void; }>("*").forEach((el) => {
|
41
41
|
if (el.tagName === this.tagName) {
|
42
42
|
return;
|
package/src/components/grid.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
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 { htmlStyle } from "@godown/element/directives/html-style.js";
|
5
6
|
import { joinRules } from "@godown/element/tools/css.js";
|
6
7
|
import { isNumerical } from "@godown/element/tools/lib.js";
|
7
|
-
import { css } from "lit";
|
8
|
+
import { css, html, type TemplateResult } from "lit";
|
8
9
|
import { property } from "lit/decorators.js";
|
9
10
|
|
10
11
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -18,7 +19,16 @@ const protoName = "grid";
|
|
18
19
|
* @category layout
|
19
20
|
*/
|
20
21
|
@godown(protoName)
|
21
|
-
@styles(css
|
22
|
+
@styles(css`
|
23
|
+
:host,
|
24
|
+
:host([contents]) [part=root] {
|
25
|
+
display: grid;
|
26
|
+
}
|
27
|
+
|
28
|
+
[part=root] {
|
29
|
+
display: contents;
|
30
|
+
}
|
31
|
+
`)
|
22
32
|
class Grid extends GlobalStyle {
|
23
33
|
/**
|
24
34
|
* CSS property `gap`.
|
@@ -54,8 +64,9 @@ class Grid extends GlobalStyle {
|
|
54
64
|
@property()
|
55
65
|
items: string;
|
56
66
|
|
57
|
-
protected render() {
|
58
|
-
return
|
67
|
+
protected render(): TemplateResult<1> {
|
68
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
69
|
+
${[
|
59
70
|
htmlSlot(),
|
60
71
|
htmlStyle(
|
61
72
|
joinRules({
|
@@ -68,7 +79,8 @@ class Grid extends GlobalStyle {
|
|
68
79
|
},
|
69
80
|
}),
|
70
81
|
),
|
71
|
-
]
|
82
|
+
]}
|
83
|
+
</div>`;
|
72
84
|
}
|
73
85
|
}
|
74
86
|
|
package/src/components/input.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { part } from "@godown/element/decorators/part.js";
|
3
3
|
import { styles } from "@godown/element/decorators/styles.js";
|
4
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
5
|
import { classList } from "@godown/element/directives/class-list.js";
|
5
|
-
import { css, html, nothing } from "lit";
|
6
|
+
import { css, html, nothing, type TemplateResult } from "lit";
|
6
7
|
import { property } from "lit/decorators.js";
|
7
8
|
|
8
9
|
import { cssGlobalVars } from "../core/global-style.js";
|
@@ -42,8 +43,8 @@ class Input extends SuperInput {
|
|
42
43
|
@part("input")
|
43
44
|
protected _input: HTMLInputElement;
|
44
45
|
|
45
|
-
protected render() {
|
46
|
-
return html`<div part="root" class="${classList("input-field", this.variant)}">
|
46
|
+
protected render(): TemplateResult<1> {
|
47
|
+
return html`<div part="root" ${attr(this.observedRecord)} class="${classList("input-field", this.variant)}">
|
47
48
|
${[
|
48
49
|
this._renderPrefix(),
|
49
50
|
html`<input
|
@@ -63,7 +64,7 @@ class Input extends SuperInput {
|
|
63
64
|
</div>`;
|
64
65
|
}
|
65
66
|
|
66
|
-
reset() {
|
67
|
+
reset(): void {
|
67
68
|
this._input.value = this.default;
|
68
69
|
this.value = this.default;
|
69
70
|
}
|
package/src/components/layout.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
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
4
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
-
import { css, html } from "lit";
|
5
|
+
import { css, html, type TemplateResult } from "lit";
|
6
6
|
import { property } from "lit/decorators.js";
|
7
7
|
|
8
8
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -20,13 +20,18 @@ const protoName = "layout";
|
|
20
20
|
@godown(protoName)
|
21
21
|
@styles(
|
22
22
|
css`
|
23
|
-
:host
|
23
|
+
:host,
|
24
|
+
:host([contents]) [part=root] {
|
24
25
|
min-height: 100%;
|
25
26
|
display: flex;
|
26
27
|
flex-direction: column;
|
27
28
|
}
|
28
29
|
|
29
|
-
|
30
|
+
[part=root] {
|
31
|
+
display: contents;
|
32
|
+
}
|
33
|
+
|
34
|
+
[sticky] header {
|
30
35
|
position: sticky;
|
31
36
|
top: 0;
|
32
37
|
z-index: 1;
|
@@ -64,10 +69,11 @@ class NavLayout extends GlobalStyle {
|
|
64
69
|
@property({ type: Boolean })
|
65
70
|
sticky = false;
|
66
71
|
|
67
|
-
protected render() {
|
68
|
-
return html
|
72
|
+
protected render(): TemplateResult<1> {
|
73
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
74
|
+
${
|
69
75
|
!this.noHeader
|
70
|
-
? html`<header part="header"
|
76
|
+
? html`<header part="header">${htmlSlot("header")}</header>`
|
71
77
|
: ""
|
72
78
|
}
|
73
79
|
<main part="main">${htmlSlot()}</main>
|
@@ -75,7 +81,8 @@ class NavLayout extends GlobalStyle {
|
|
75
81
|
!this.noFooter
|
76
82
|
? html`<footer part="footer">${htmlSlot("footer")}</footer>`
|
77
83
|
: ""
|
78
|
-
}
|
84
|
+
}
|
85
|
+
</div>`;
|
79
86
|
}
|
80
87
|
}
|
81
88
|
|
package/src/components/link.ts
CHANGED
@@ -26,7 +26,7 @@ class Link extends SuperAnchor {
|
|
26
26
|
@property()
|
27
27
|
type: "push" | "replace" | "normal" = "normal";
|
28
28
|
|
29
|
-
protected _handleClick(e: MouseEvent) {
|
29
|
+
protected _handleClick(e: MouseEvent): void {
|
30
30
|
if (this.type === "push" || this.type === "replace") {
|
31
31
|
e.preventDefault();
|
32
32
|
(history[`${this.type}State`])(null, "", this.href);
|
@@ -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 { isNil } from "@godown/element/tools/lib.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 { cssGlobalVars, GlobalStyle } from "../core/global-style.js";
|
@@ -18,12 +19,16 @@ const protoName = "progress";
|
|
18
19
|
:host {
|
19
20
|
width: 100%;
|
20
21
|
height: 0.5em;
|
21
|
-
display: inline-block;
|
22
22
|
border-radius: 0.25em;
|
23
23
|
background: var(${cssGlobalVars.passive});
|
24
24
|
color: var(${cssGlobalVars.active});
|
25
25
|
}
|
26
26
|
|
27
|
+
:host,
|
28
|
+
[part=root] {
|
29
|
+
display: block;
|
30
|
+
}
|
31
|
+
|
27
32
|
[part=root] {
|
28
33
|
height: inherit;
|
29
34
|
z-index: 1;
|
@@ -66,14 +71,14 @@ class Progress extends GlobalStyle {
|
|
66
71
|
@property({ type: Number })
|
67
72
|
value: number;
|
68
73
|
|
69
|
-
protected render() {
|
74
|
+
protected render(): TemplateResult<1> {
|
70
75
|
let width = 20;
|
71
76
|
let className: string;
|
72
77
|
if (!isNil(this.value)) {
|
73
78
|
width = this.parsePercent(this.value);
|
74
79
|
className = "static";
|
75
80
|
}
|
76
|
-
return html`<div part="root" class="${className}">
|
81
|
+
return html`<div part="root" ${attr(this.observedRecord)} class="${className}">
|
77
82
|
<i part="value" style="width:${width}%;"></i>
|
78
83
|
</div>`;
|
79
84
|
}
|
package/src/components/range.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { part } from "@godown/element/decorators/part.js";
|
3
3
|
import { styles } from "@godown/element/decorators/styles.js";
|
4
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
5
|
import { classList } from "@godown/element/directives/class-list.js";
|
5
6
|
import { joinProperties } from "@godown/element/tools/css.js";
|
6
7
|
import { isNil } from "@godown/element/tools/lib.js";
|
7
|
-
import { css, html } from "lit";
|
8
|
+
import { css, html, type TemplateResult } from "lit";
|
8
9
|
import { property, queryAll, state } from "lit/decorators.js";
|
9
10
|
|
10
11
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
@@ -30,7 +31,7 @@ const cssScope = scopePrefix(protoName);
|
|
30
31
|
${cssScope}-track-width: .5em;
|
31
32
|
background: var(${cssGlobalVars.input}-background);
|
32
33
|
width: var(${cssGlobalVars.input}-width);
|
33
|
-
display:
|
34
|
+
display: block;
|
34
35
|
margin: 0.25em 0;
|
35
36
|
}
|
36
37
|
|
@@ -46,7 +47,7 @@ const cssScope = scopePrefix(protoName);
|
|
46
47
|
}
|
47
48
|
|
48
49
|
[part=root] {
|
49
|
-
min-height:inherit;
|
50
|
+
min-height: inherit;
|
50
51
|
position: relative;
|
51
52
|
border-radius: inherit;
|
52
53
|
width: 100%;
|
@@ -85,16 +86,16 @@ const cssScope = scopePrefix(protoName);
|
|
85
86
|
}
|
86
87
|
`,
|
87
88
|
css`
|
88
|
-
|
89
|
-
height:
|
89
|
+
[vertical] {
|
90
|
+
height: inherit;
|
90
91
|
width: var(${cssScope}-track-width);
|
91
92
|
}
|
92
93
|
|
93
|
-
|
94
|
+
[vertical] i {
|
94
95
|
transform: translate(-25%, -50%);
|
95
96
|
}
|
96
97
|
|
97
|
-
|
98
|
+
[vertical] [part=track] {
|
98
99
|
width: 100%;
|
99
100
|
height: max(calc(var(--to) - var(--from)), calc(var(--from) - var(--to)));
|
100
101
|
top: min(var(--from), var(--to));
|
@@ -107,7 +108,7 @@ const cssScope = scopePrefix(protoName);
|
|
107
108
|
top: 0;
|
108
109
|
}
|
109
110
|
|
110
|
-
|
111
|
+
[vertical] [part=handle] {
|
111
112
|
top: var(--handle);
|
112
113
|
left: 0;
|
113
114
|
}
|
@@ -164,7 +165,7 @@ class Range extends SuperInput {
|
|
164
165
|
/**
|
165
166
|
* Returns true when the second number is greater than the first number.
|
166
167
|
*/
|
167
|
-
get reverse() {
|
168
|
+
get reverse(): boolean {
|
168
169
|
return this.range ? this.value[0] > this.value[1] : false;
|
169
170
|
}
|
170
171
|
|
@@ -196,7 +197,7 @@ class Range extends SuperInput {
|
|
196
197
|
return rangeValue;
|
197
198
|
}
|
198
199
|
|
199
|
-
protected render() {
|
200
|
+
protected render(): TemplateResult<1> {
|
200
201
|
const rangeValue = this.padValue(2);
|
201
202
|
const from = Math.min(...rangeValue);
|
202
203
|
const to = Math.max(...rangeValue);
|
@@ -204,13 +205,7 @@ class Range extends SuperInput {
|
|
204
205
|
|
205
206
|
return html`<div
|
206
207
|
part="root"
|
207
|
-
|
208
|
-
classList({
|
209
|
-
vertical: this.vertical,
|
210
|
-
range: this.range,
|
211
|
-
reverse: this.reverse,
|
212
|
-
})
|
213
|
-
}"
|
208
|
+
${attr(this.observedRecord)}
|
214
209
|
@mousedown="${this.disabled ? null : this._handleMousedownRoot}"
|
215
210
|
style="${
|
216
211
|
joinProperties({
|
@@ -234,7 +229,7 @@ class Range extends SuperInput {
|
|
234
229
|
</div>`;
|
235
230
|
}
|
236
231
|
|
237
|
-
protected renderHandle(index: number) {
|
232
|
+
protected renderHandle(index: number): TemplateResult<1> {
|
238
233
|
const { range } = this;
|
239
234
|
const end = !range || index === (this.value as number[]).length - 1;
|
240
235
|
return html`<i
|
@@ -253,7 +248,7 @@ class Range extends SuperInput {
|
|
253
248
|
|
254
249
|
private _keydownEvent: EventListenerOrEventListenerObject;
|
255
250
|
|
256
|
-
focusHandle(index: number) {
|
251
|
+
focusHandle(index: number): void {
|
257
252
|
this.lastFocus = index;
|
258
253
|
const handleItem = this._handles.item(index);
|
259
254
|
handleItem?.focus();
|
@@ -262,7 +257,7 @@ class Range extends SuperInput {
|
|
262
257
|
}
|
263
258
|
}
|
264
259
|
|
265
|
-
blurHandle() {
|
260
|
+
blurHandle(): void {
|
266
261
|
this.lastFocus = undefined;
|
267
262
|
this._keydownEvent = this.events.remove(document, "keydown", this._keydownEvent);
|
268
263
|
}
|
@@ -271,7 +266,7 @@ class Range extends SuperInput {
|
|
271
266
|
if (!this.range) {
|
272
267
|
index = 0;
|
273
268
|
}
|
274
|
-
return (e: KeyboardEvent) => {
|
269
|
+
return (e: KeyboardEvent): void => {
|
275
270
|
if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
|
276
271
|
e.preventDefault();
|
277
272
|
this.createSetValue(index)(old => old - this.step);
|
@@ -283,20 +278,20 @@ class Range extends SuperInput {
|
|
283
278
|
}
|
284
279
|
|
285
280
|
createMouseDown(index: number) {
|
286
|
-
return (e: MouseEvent) => {
|
281
|
+
return (e: MouseEvent): void => {
|
287
282
|
this.focusHandle(index);
|
288
283
|
this.createMousedownListener(this.createSetValue(index))(e);
|
289
284
|
};
|
290
285
|
}
|
291
286
|
|
292
|
-
protected _handleMousedownEnd(e: MouseEvent) {
|
287
|
+
protected _handleMousedownEnd(e: MouseEvent): void {
|
293
288
|
this.lastFocus = 0;
|
294
289
|
this.createMousedownListener(this.setEnd)(e);
|
295
290
|
this.focusHandle(0);
|
296
291
|
}
|
297
292
|
|
298
293
|
createSetValue(index: number) {
|
299
|
-
return (numberOrModifier: number | ((value: number) => number)) => {
|
294
|
+
return (numberOrModifier: number | ((value: number) => number)): void => {
|
300
295
|
const number = typeof numberOrModifier === "number"
|
301
296
|
? this.normalizeValue(numberOrModifier)
|
302
297
|
: numberOrModifier(this.rangeValue[index]);
|
@@ -309,14 +304,14 @@ class Range extends SuperInput {
|
|
309
304
|
};
|
310
305
|
}
|
311
306
|
|
312
|
-
setEnd(value: number) {
|
307
|
+
setEnd(value: number): void {
|
313
308
|
this.createSetValue((this.value as any)?.length - 1 || 0)(value);
|
314
309
|
}
|
315
310
|
|
316
311
|
/**
|
317
312
|
* Compute value from event.
|
318
313
|
*/
|
319
|
-
protected _computeValue(e: MouseEvent) {
|
314
|
+
protected _computeValue(e: MouseEvent): number {
|
320
315
|
const rect = this._root.getBoundingClientRect();
|
321
316
|
const div = this.vertical ? (e.clientY - rect.top) / rect.height : (e.clientX - rect.left) / rect.width;
|
322
317
|
const value = Math.round((div * (this.max - this.min)) / this.step) * this.step;
|
@@ -326,13 +321,13 @@ class Range extends SuperInput {
|
|
326
321
|
/**
|
327
322
|
* Ensure that the values do not exceed the range of max and min.
|
328
323
|
*/
|
329
|
-
protected normalizeValue(value: number) {
|
324
|
+
protected normalizeValue(value: number): number {
|
330
325
|
if (value > this.max) { value -= this.step; }
|
331
326
|
else if (value < this.min) { value += this.step; }
|
332
327
|
return value;
|
333
328
|
}
|
334
329
|
|
335
|
-
protected _handleMousedownRoot(e: MouseEvent) {
|
330
|
+
protected _handleMousedownRoot(e: MouseEvent): void {
|
336
331
|
const value = this._computeValue(e);
|
337
332
|
const index = this.range
|
338
333
|
? this.rangeValue.reduce((acc, item, index) => {
|
@@ -349,7 +344,7 @@ class Range extends SuperInput {
|
|
349
344
|
}
|
350
345
|
|
351
346
|
protected createMousedownListener(mouseMoveCallback: (arg0: number) => void) {
|
352
|
-
return (e: MouseEvent) => {
|
347
|
+
return (e: MouseEvent): void => {
|
353
348
|
e.preventDefault();
|
354
349
|
e.stopPropagation();
|
355
350
|
const move = this.createMousemoveListener(mouseMoveCallback);
|
@@ -363,7 +358,7 @@ class Range extends SuperInput {
|
|
363
358
|
}
|
364
359
|
|
365
360
|
protected createMousemoveListener(callback: (arg0: number) => void) {
|
366
|
-
return (e: MouseEvent) => {
|
361
|
+
return (e: MouseEvent): void => {
|
367
362
|
const value = this._computeValue(e);
|
368
363
|
if (value > this.max || value < this.min) {
|
369
364
|
return;
|
@@ -372,7 +367,7 @@ class Range extends SuperInput {
|
|
372
367
|
};
|
373
368
|
}
|
374
369
|
|
375
|
-
protected _connectedInit() {
|
370
|
+
protected _connectedInit(): void {
|
376
371
|
const gap = this.max - this.min;
|
377
372
|
this.step ||= gap / 100;
|
378
373
|
if (isNil(this.value)) {
|
@@ -385,15 +380,15 @@ class Range extends SuperInput {
|
|
385
380
|
this.default ??= this.value;
|
386
381
|
}
|
387
382
|
|
388
|
-
reset() {
|
383
|
+
reset(): void {
|
389
384
|
this.value = this.default;
|
390
385
|
}
|
391
386
|
|
392
|
-
sort() {
|
387
|
+
sort(): number | number[] {
|
393
388
|
return this.value = this.toSorted();
|
394
389
|
}
|
395
390
|
|
396
|
-
toSorted() {
|
391
|
+
toSorted(): number | number[] {
|
397
392
|
if (this.range) {
|
398
393
|
return [...this.value as number[]].sort((a, b) => a - b);
|
399
394
|
}
|
package/src/components/rotate.ts
CHANGED
@@ -2,7 +2,7 @@ import { godown } from "@godown/element/decorators/godown.js";
|
|
2
2
|
import { part } from "@godown/element/decorators/part.js";
|
3
3
|
import { styles } from "@godown/element/decorators/styles.js";
|
4
4
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
-
import { css, html } from "lit";
|
5
|
+
import { css, html, type TemplateResult } from "lit";
|
6
6
|
|
7
7
|
import { GlobalStyle, scopePrefix } from "../core/global-style.js";
|
8
8
|
|
@@ -42,7 +42,7 @@ const cssScope = scopePrefix(protoName);
|
|
42
42
|
margin: calc(-1 * var(${cssScope}--offset));
|
43
43
|
}
|
44
44
|
|
45
|
-
[part=slot]{
|
45
|
+
[part=slot] {
|
46
46
|
z-index: 2;
|
47
47
|
}
|
48
48
|
`,
|
@@ -51,19 +51,19 @@ class Rotate extends GlobalStyle {
|
|
51
51
|
@part("root")
|
52
52
|
protected _root: HTMLElement;
|
53
53
|
|
54
|
-
protected render() {
|
54
|
+
protected render(): TemplateResult<1> {
|
55
55
|
return html`<div part="root">
|
56
56
|
<div part="slot" @mousemove="${this._handleRotate}">${htmlSlot()}</div>
|
57
57
|
<i @mouseleave="${this.reset}"></i>
|
58
58
|
</div>`;
|
59
59
|
}
|
60
60
|
|
61
|
-
reset() {
|
61
|
+
reset(): void {
|
62
62
|
this._root.style.removeProperty("transform");
|
63
63
|
this._root.style.removeProperty("transition");
|
64
64
|
}
|
65
65
|
|
66
|
-
protected _handleRotate(e: MouseEvent) {
|
66
|
+
protected _handleRotate(e: MouseEvent): void {
|
67
67
|
const { rotateX, rotateY } = this._computeOffset(e);
|
68
68
|
this._root.style.setProperty("transform", `rotateX(${rotateX}rad) rotateY(${rotateY}rad)`);
|
69
69
|
this._root.style.setProperty("transition", "0s");
|
@@ -77,7 +77,10 @@ class Rotate extends GlobalStyle {
|
|
77
77
|
* @param e Mouse move event.
|
78
78
|
* @returns rotateX, rotateY
|
79
79
|
*/
|
80
|
-
_computeOffset(e: MouseEvent) {
|
80
|
+
_computeOffset(e: MouseEvent): {
|
81
|
+
rotateX: number;
|
82
|
+
rotateY: number;
|
83
|
+
} {
|
81
84
|
const { left, top, width, height } = this._root.getBoundingClientRect();
|
82
85
|
const { clientX, clientY } = e;
|
83
86
|
const offsetX = clientX - left;
|