godown 3.0.0-canary.1 → 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/components/alert.d.ts +5 -3
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +35 -24
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts +5 -1
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +7 -6
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/breath.d.ts +2 -1
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +3 -1
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +16 -9
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +29 -25
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +1 -2
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +21 -29
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +6 -5
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +9 -7
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +5 -2
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +4 -1
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +8 -4
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +23 -18
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts +1 -1
- package/dev/components/divider.js +1 -1
- package/dev/components/dragbox.d.ts +7 -7
- package/dev/components/dragbox.d.ts.map +1 -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 +8 -0
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts +0 -2
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +0 -2
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts +8 -3
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +1 -0
- package/dev/components/grid.js.map +1 -1
- package/dev/components/input.d.ts +2 -3
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +1 -20
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +3 -6
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +23 -10
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.d.ts +3 -1
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +3 -1
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +2 -11
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +7 -16
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +43 -17
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +157 -99
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +1 -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 +6 -8
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +10 -10
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +4 -8
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +46 -44
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +2 -3
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +18 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +55 -22
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +4 -4
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +12 -13
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.js +3 -3
- package/dev/components/time.d.ts +4 -20
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +5 -66
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +11 -1
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +39 -16
- 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 +0 -1
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +8 -9
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-input.d.ts +2 -3
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +21 -20
- package/dev/core/super-input.js.map +1 -1
- package/dev/range.d.ts +1 -1
- package/dev/range.d.ts.map +1 -1
- package/index.js +13 -13
- package/package.json +9 -7
- 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,116 @@
|
|
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 svgCaretDown from "@godown/f7-icon/icons/chevron-down.js";
|
5
|
+
import { css, html } from "lit";
|
6
|
+
import { property, query } from "lit/decorators.js";
|
7
|
+
|
8
|
+
import { scopePrefix } from "../core/global-style.js";
|
9
|
+
import SuperOpenable from "../core/super-openable.js";
|
10
|
+
|
11
|
+
const protoName = "details";
|
12
|
+
|
13
|
+
const cssScope = scopePrefix(protoName);
|
14
|
+
|
15
|
+
/**
|
16
|
+
* {@linkcode Details} similar to `<details>`.
|
17
|
+
*
|
18
|
+
* @slot summary - Details summary if no `summary` is provided.
|
19
|
+
* @slot - Details content.
|
20
|
+
* @fires change - Fired when the details is toggled.
|
21
|
+
* @category display
|
22
|
+
*/
|
23
|
+
@godown(protoName)
|
24
|
+
@styles(
|
25
|
+
css`
|
26
|
+
:host {
|
27
|
+
${cssScope}--icon-deg-open: 0deg;
|
28
|
+
${cssScope}--icon-deg-close: 90deg;
|
29
|
+
${cssScope}--icon-deg: 0deg;
|
30
|
+
${cssScope}--icon-space: 0.3em;
|
31
|
+
${cssScope}--summary-direction: row;
|
32
|
+
${cssScope}--transition: .3s;
|
33
|
+
height: fit-content;
|
34
|
+
display: block;
|
35
|
+
transition: var(${cssScope}--transition);
|
36
|
+
}
|
37
|
+
|
38
|
+
dl {
|
39
|
+
height: 100%;
|
40
|
+
position: relative;
|
41
|
+
overflow: hidden;
|
42
|
+
}
|
43
|
+
|
44
|
+
dt {
|
45
|
+
height: 100%;
|
46
|
+
display: flex;
|
47
|
+
flex-wrap: nowrap;
|
48
|
+
justify-content: space-between;
|
49
|
+
background: inherit;
|
50
|
+
align-items: center;
|
51
|
+
flex-direction: var(${cssScope}--summary-direction);
|
52
|
+
}
|
53
|
+
|
54
|
+
dd {
|
55
|
+
display: grid;
|
56
|
+
overflow: hidden;
|
57
|
+
grid-template-rows: 0fr;
|
58
|
+
transition: var(${cssScope}--transition);
|
59
|
+
transition-property: grid-template-rows;
|
60
|
+
}
|
61
|
+
|
62
|
+
i {
|
63
|
+
display: flex;
|
64
|
+
backface-visibility: hidden;
|
65
|
+
padding: var(${cssScope}--icon-space);
|
66
|
+
transition: var(${cssScope}--transition);
|
67
|
+
transform: rotate(var(${cssScope}--icon-deg));
|
68
|
+
}
|
69
|
+
|
70
|
+
:host([open]) dd {
|
71
|
+
grid-template-rows: 1fr;
|
72
|
+
}
|
73
|
+
|
74
|
+
:host([float]) dd {
|
75
|
+
top: 100%;
|
76
|
+
position: absolute;
|
77
|
+
}
|
78
|
+
|
79
|
+
i {
|
80
|
+
transform: rotate(var(${cssScope}--icon-deg-close));
|
81
|
+
}
|
82
|
+
:host([open]) i {
|
83
|
+
transform: rotate(var(${cssScope}--icon-deg-open));
|
84
|
+
}
|
85
|
+
`,
|
86
|
+
)
|
87
|
+
class Details extends SuperOpenable {
|
88
|
+
/**
|
89
|
+
* If it is true, the summary event scope will fill the element.
|
90
|
+
*/
|
91
|
+
@property({ type: Boolean })
|
92
|
+
fill = false;
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Summary text.
|
96
|
+
*/
|
97
|
+
@property()
|
98
|
+
summary = "";
|
99
|
+
|
100
|
+
@query("dd")
|
101
|
+
protected _dd: HTMLDataListElement;
|
102
|
+
|
103
|
+
protected render() {
|
104
|
+
return html`<dl part="root">
|
105
|
+
<dt part="title" @click="${this._handelClick}">
|
106
|
+
<span part="summary">${this.summary || htmlSlot("summary")} </span>
|
107
|
+
<span><i part="icon">${svgCaretDown()}</i></span>
|
108
|
+
</dt>
|
109
|
+
<dd part="details" @click=${this.fill ? () => this.toggle() : null}>
|
110
|
+
<div style="min-height: 0;">${htmlSlot()}</div>
|
111
|
+
</dd>
|
112
|
+
</dl>`;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
export default Details;
|
@@ -0,0 +1,165 @@
|
|
1
|
+
import { type HandlerEvent } from "@godown/element";
|
2
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
3
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
4
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
+
import { css, html, type PropertyValues } from "lit";
|
6
|
+
import { property } from "lit/decorators.js";
|
7
|
+
|
8
|
+
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
9
|
+
import SuperOpenable, { type Direction9 } from "../core/super-openable.js";
|
10
|
+
|
11
|
+
const protoName = "dialog";
|
12
|
+
const cssScope = scopePrefix(protoName);
|
13
|
+
|
14
|
+
/**
|
15
|
+
* {@linkcode Dialog} similar to `<dialog>`.
|
16
|
+
*
|
17
|
+
* Like dialog, it listens for submit events and closes itself when the target method is "dialog".
|
18
|
+
*
|
19
|
+
* It listens for the keydown event and also closes itself when the {@linkcode key} contained in the key is pressed.
|
20
|
+
*
|
21
|
+
* @category feedback
|
22
|
+
*/
|
23
|
+
@godown(protoName)
|
24
|
+
@styles(
|
25
|
+
css`
|
26
|
+
:host {
|
27
|
+
${cssScope}--background: none;
|
28
|
+
${cssScope}--background-modal: var(${cssGlobalVars.background});
|
29
|
+
${cssScope}--opacity-modal: 0.2;
|
30
|
+
background: var(${cssScope}--background);
|
31
|
+
pointer-events: none;
|
32
|
+
visibility: hidden;
|
33
|
+
position: fixed;
|
34
|
+
z-index: 1;
|
35
|
+
inset:0;
|
36
|
+
}
|
37
|
+
|
38
|
+
:host([open]) {
|
39
|
+
visibility: visible;
|
40
|
+
}
|
41
|
+
|
42
|
+
:host([open][modal]) [part=modal] {
|
43
|
+
pointer-events: all;
|
44
|
+
visibility: visible;
|
45
|
+
opacity: var(${cssScope}--opacity-modal);
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
[part=modal] {
|
50
|
+
visibility: hidden;
|
51
|
+
opacity: 0;
|
52
|
+
width: 100%;
|
53
|
+
height: 100%;
|
54
|
+
position: absolute;
|
55
|
+
background: var(${cssScope}--background-modal);
|
56
|
+
}
|
57
|
+
|
58
|
+
[part=root] {
|
59
|
+
width: 100%;
|
60
|
+
height: 100%;
|
61
|
+
display: flex;
|
62
|
+
position: relative;
|
63
|
+
align-items: center;
|
64
|
+
justify-content: center;
|
65
|
+
}
|
66
|
+
|
67
|
+
[direction] {
|
68
|
+
pointer-events: all;
|
69
|
+
position: absolute;
|
70
|
+
}
|
71
|
+
|
72
|
+
[direction^=top] {
|
73
|
+
top: 0;
|
74
|
+
}
|
75
|
+
|
76
|
+
[direction^=bottom] {
|
77
|
+
bottom: 0;
|
78
|
+
}
|
79
|
+
|
80
|
+
[direction$=right] {
|
81
|
+
right: 0%;
|
82
|
+
}
|
83
|
+
|
84
|
+
[direction$=left] {
|
85
|
+
left: 0%;
|
86
|
+
}
|
87
|
+
`,
|
88
|
+
)
|
89
|
+
class Dialog extends SuperOpenable {
|
90
|
+
/**
|
91
|
+
* Direction of the opening animation.
|
92
|
+
*/
|
93
|
+
@property()
|
94
|
+
direction: Direction9 = "center";
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Enable modal, blocking event penetration.
|
98
|
+
*/
|
99
|
+
@property({ type: Boolean, reflect: true })
|
100
|
+
modal = false;
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Close key.
|
104
|
+
*/
|
105
|
+
@property()
|
106
|
+
key = "Escape";
|
107
|
+
|
108
|
+
private _modalInvoke: boolean;
|
109
|
+
|
110
|
+
protected render() {
|
111
|
+
return html`<div part="root">
|
112
|
+
<div part="modal"></div>
|
113
|
+
<div part="container" direction="${this.direction}">${htmlSlot()}</div>
|
114
|
+
</div>`;
|
115
|
+
}
|
116
|
+
|
117
|
+
showModal() {
|
118
|
+
if (!this.modal) {
|
119
|
+
this.modal = true;
|
120
|
+
this._modalInvoke = true;
|
121
|
+
}
|
122
|
+
this.show();
|
123
|
+
}
|
124
|
+
|
125
|
+
private _submitEvent: EventListenerOrEventListenerObject;
|
126
|
+
private _keydownEvent: EventListenerOrEventListenerObject;
|
127
|
+
|
128
|
+
protected updated(changedProperties: PropertyValues) {
|
129
|
+
if (changedProperties.has("open")) {
|
130
|
+
if (this.open) {
|
131
|
+
this._submitEvent = this.events.add(this, "submit", this._handelSubmit);
|
132
|
+
if (this.key) {
|
133
|
+
this._keydownEvent = this.events.add(document, "keydown", this._handleKeydown.bind(this));
|
134
|
+
}
|
135
|
+
} else {
|
136
|
+
this.events.remove(this, "submit", this._submitEvent);
|
137
|
+
this.events.remove(document, "keydown", this._keydownEvent);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
protected _handleKeydown(e: KeyboardEvent) {
|
143
|
+
e.preventDefault();
|
144
|
+
const keys = this.key.split(/[\s,]/);
|
145
|
+
if (keys.includes(e.key) || keys.includes(e.code)) {
|
146
|
+
this.close();
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
protected _handelSubmit(e: HandlerEvent<HTMLFormElement>) {
|
151
|
+
if (e.target.method === "dialog") {
|
152
|
+
this.close();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
close() {
|
157
|
+
if (this._modalInvoke) {
|
158
|
+
this.modal = false;
|
159
|
+
this._modalInvoke = false;
|
160
|
+
}
|
161
|
+
this.open = false;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
export default Dialog;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { godown, styles } from "@godown/element/decorators/index.js";
|
2
|
+
import { css } from "lit";
|
3
|
+
import { property } from "lit/decorators.js";
|
4
|
+
|
5
|
+
import { GlobalStyle } from "../core/global-style.js";
|
6
|
+
|
7
|
+
const protoName = "divider";
|
8
|
+
|
9
|
+
/**
|
10
|
+
* {@linkcode Divider} similar to `<hr>`.
|
11
|
+
*
|
12
|
+
* This component does not render content.
|
13
|
+
*
|
14
|
+
* @category layout
|
15
|
+
*/
|
16
|
+
@godown(protoName)
|
17
|
+
@styles(
|
18
|
+
css`
|
19
|
+
:host{
|
20
|
+
width: 100%;
|
21
|
+
height: .05em;
|
22
|
+
margin: auto;
|
23
|
+
display: block;
|
24
|
+
background: currentColor;
|
25
|
+
}
|
26
|
+
:host([vertical]) {
|
27
|
+
width: .05em;
|
28
|
+
height: max(1em, 100%);
|
29
|
+
}
|
30
|
+
`,
|
31
|
+
)
|
32
|
+
class Divider extends GlobalStyle {
|
33
|
+
/**
|
34
|
+
* Vertical display.
|
35
|
+
*/
|
36
|
+
@property({ type: Boolean, reflect: true })
|
37
|
+
vertical = false;
|
38
|
+
|
39
|
+
connectedCallback() {
|
40
|
+
this.createRenderRoot();
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
export default Divider;
|
@@ -0,0 +1,127 @@
|
|
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 { EventListenerFunc } from "@godown/element/tools/events.js";
|
5
|
+
import { css, html } from "lit";
|
6
|
+
import { property } from "lit/decorators.js";
|
7
|
+
|
8
|
+
import { GlobalStyle } from "../core/global-style.js";
|
9
|
+
|
10
|
+
const protoName = "dragbox";
|
11
|
+
|
12
|
+
/**
|
13
|
+
* {@linkcode Dragbox} does not extend beyond the range of {@linkcode Dragbox.offsetsWidth} and {@linkcode Dragbox.offsetsHeight}.
|
14
|
+
*
|
15
|
+
* @category wrapper
|
16
|
+
*/
|
17
|
+
@godown(protoName)
|
18
|
+
@styles(
|
19
|
+
css`
|
20
|
+
:host {
|
21
|
+
position: absolute;
|
22
|
+
display: block;
|
23
|
+
}
|
24
|
+
|
25
|
+
:host(:active) {
|
26
|
+
-webkit-user-select: none;
|
27
|
+
user-select: none;
|
28
|
+
}
|
29
|
+
`,
|
30
|
+
)
|
31
|
+
class Dragbox extends GlobalStyle {
|
32
|
+
/**
|
33
|
+
* Width of (`this.offsetParent` or `document.body`).
|
34
|
+
*/
|
35
|
+
get offsetsWidth(): number {
|
36
|
+
return this.offsetParent?.clientWidth ?? document.body.offsetWidth;
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Height of (`this.offsetParent` or `document.body`).
|
41
|
+
*/
|
42
|
+
get offsetsHeight(): number {
|
43
|
+
return this.offsetParent?.clientHeight ?? document.body.offsetHeight;
|
44
|
+
}
|
45
|
+
|
46
|
+
private drag: boolean;
|
47
|
+
private t: number;
|
48
|
+
private l: number;
|
49
|
+
private cx: number;
|
50
|
+
private cy: number;
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Position x.
|
54
|
+
*/
|
55
|
+
@property()
|
56
|
+
x = "auto";
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Position y.
|
60
|
+
*/
|
61
|
+
@property()
|
62
|
+
y = "auto";
|
63
|
+
|
64
|
+
protected render() {
|
65
|
+
return html`<div @mousedown="${this._handleDragStart}" @mouseup="${this._handleDragEnd}">${htmlSlot()}</div>`;
|
66
|
+
}
|
67
|
+
|
68
|
+
protected firstUpdated() {
|
69
|
+
this.reset();
|
70
|
+
}
|
71
|
+
|
72
|
+
protected _handleDragStart(e: MouseEvent) {
|
73
|
+
this.cx = e.clientX;
|
74
|
+
this.cy = e.clientY;
|
75
|
+
this.t = this.offsetTop;
|
76
|
+
this.l = this.offsetLeft;
|
77
|
+
this.drag = true;
|
78
|
+
this._handleMouseMove = this.events.add(document, "mousemove", this._handleDrag.bind(this));
|
79
|
+
this._handleMouseLeave = this.events.add(document, "mouseleave", this._handleDragEnd.bind(this));
|
80
|
+
}
|
81
|
+
|
82
|
+
protected _handleMouseMove: EventListenerFunc;
|
83
|
+
protected _handleMouseLeave: EventListenerFunc;
|
84
|
+
|
85
|
+
protected _handleDragEnd() {
|
86
|
+
this.drag = false;
|
87
|
+
this.events.remove(document, "mousemove", this._handleMouseMove);
|
88
|
+
this.events.remove(document, "mouseleave", this._handleMouseLeave);
|
89
|
+
}
|
90
|
+
|
91
|
+
protected _handleDrag(e: MouseEvent) {
|
92
|
+
if (!this.drag) {
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
const nl = e.clientX - (this.cx - this.l);
|
96
|
+
const nt = e.clientY - (this.cy - this.t);
|
97
|
+
const { style, offsetsWidth, offsetsHeight, offsetWidth, offsetHeight } = this;
|
98
|
+
if (nl < 0) {
|
99
|
+
style.left = "0";
|
100
|
+
} else if (nl < offsetsWidth - offsetWidth) {
|
101
|
+
style.left = `${nl}px`;
|
102
|
+
} else {
|
103
|
+
style.left = `${offsetsWidth - offsetWidth}"px"`;
|
104
|
+
}
|
105
|
+
if (nt < 0) {
|
106
|
+
style.top = "0";
|
107
|
+
} else if (nt < offsetsHeight - offsetHeight) {
|
108
|
+
style.top = `${nt}px`;
|
109
|
+
} else {
|
110
|
+
style.top = `${offsetsHeight - offsetHeight}px`;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
reset() {
|
115
|
+
const { x, y, style, offsetsWidth, offsetsHeight, offsetWidth, offsetHeight, offsetLeft, offsetTop } = this;
|
116
|
+
style.left = x || "0";
|
117
|
+
style.top = y || "0";
|
118
|
+
if (offsetLeft > offsetsWidth - offsetWidth) {
|
119
|
+
style.left = `${offsetsWidth - offsetWidth}px`;
|
120
|
+
}
|
121
|
+
if (offsetTop > offsetsHeight - offsetHeight) {
|
122
|
+
style.top = `${offsetsHeight - offsetHeight}px`;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
export default Dragbox;
|
@@ -0,0 +1,70 @@
|
|
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 { htmlStyle } from "@godown/element/directives/html-style.js";
|
5
|
+
import { joinRules } from "@godown/element/tools/css.js";
|
6
|
+
import { css } from "lit";
|
7
|
+
import { property } from "lit/decorators.js";
|
8
|
+
|
9
|
+
import { GlobalStyle } from "../core/global-style.js";
|
10
|
+
|
11
|
+
const protoName = "flex";
|
12
|
+
|
13
|
+
/**
|
14
|
+
* {@linkcode Flex} provides flex layout.
|
15
|
+
*
|
16
|
+
* @slot - Flex items.
|
17
|
+
* @category layout
|
18
|
+
*/
|
19
|
+
@godown(protoName)
|
20
|
+
@styles(css`:host {display:flex;}`)
|
21
|
+
class Flex extends GlobalStyle {
|
22
|
+
/**
|
23
|
+
* CSS property `flex-flow` (`flex-direction flex-wrap`).
|
24
|
+
*/
|
25
|
+
@property({ attribute: "flex-flow" })
|
26
|
+
flexFlow: string;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* CSS property `gap`.
|
30
|
+
*/
|
31
|
+
@property()
|
32
|
+
gap: string;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* CSS property `justify-content`.
|
36
|
+
*/
|
37
|
+
@property()
|
38
|
+
content: string;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* CSS property `align-items`.
|
42
|
+
*/
|
43
|
+
@property()
|
44
|
+
items: string;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* If true, set flex-direction to "column".
|
48
|
+
*/
|
49
|
+
@property({ type: Boolean })
|
50
|
+
vertical = false;
|
51
|
+
|
52
|
+
protected render() {
|
53
|
+
return [
|
54
|
+
htmlSlot(),
|
55
|
+
htmlStyle(
|
56
|
+
joinRules({
|
57
|
+
":host": {
|
58
|
+
gap: this.gap,
|
59
|
+
"flex-flow": this.flexFlow,
|
60
|
+
"flex-direction": this.vertical && "column",
|
61
|
+
"align-items": this.items,
|
62
|
+
"justify-content": this.content,
|
63
|
+
},
|
64
|
+
}),
|
65
|
+
),
|
66
|
+
];
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
export default Flex;
|
@@ -0,0 +1,82 @@
|
|
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 { css } from "lit";
|
5
|
+
import { property } from "lit/decorators.js";
|
6
|
+
|
7
|
+
import { GlobalStyle } from "../core/global-style.js";
|
8
|
+
|
9
|
+
const protoName = "form";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* {@linkcode Form} Gets child element key-value object,
|
13
|
+
* which will be nested if the child element is the same as this element.
|
14
|
+
*
|
15
|
+
* @category form
|
16
|
+
*/
|
17
|
+
@godown(protoName)
|
18
|
+
@styles(
|
19
|
+
css`
|
20
|
+
:host {
|
21
|
+
display: block;
|
22
|
+
}
|
23
|
+
`,
|
24
|
+
)
|
25
|
+
class Form<T = object> extends GlobalStyle {
|
26
|
+
@property()
|
27
|
+
name = "";
|
28
|
+
|
29
|
+
get value(): T {
|
30
|
+
return Form.buildValue(this._slot.assignedElements()) as T;
|
31
|
+
}
|
32
|
+
|
33
|
+
nameValue = this.namevalue;
|
34
|
+
|
35
|
+
protected render() {
|
36
|
+
return htmlSlot();
|
37
|
+
}
|
38
|
+
|
39
|
+
reset() {
|
40
|
+
this.deepQuerySelectorAll<HTMLElement & { reset?: () => void; }>("*").forEach((el) => {
|
41
|
+
if (el.tagName === this.tagName) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
if (el.reset) {
|
45
|
+
el.reset();
|
46
|
+
}
|
47
|
+
});
|
48
|
+
}
|
49
|
+
|
50
|
+
namevalue(): [string, T] {
|
51
|
+
return [this.name, this.value];
|
52
|
+
}
|
53
|
+
|
54
|
+
static buildValue(
|
55
|
+
elements: (Element & {
|
56
|
+
name?: string;
|
57
|
+
value?: unknown;
|
58
|
+
namevalue?: () => [string, unknown];
|
59
|
+
})[],
|
60
|
+
): Record<string, any> {
|
61
|
+
const result = {};
|
62
|
+
for (const el of elements) {
|
63
|
+
if (el.tagName === "FORM") {
|
64
|
+
Object.assign(result, Object.fromEntries(new FormData(el as HTMLFormElement).entries()));
|
65
|
+
} else if (el.namevalue) {
|
66
|
+
const [name, value] = el.namevalue();
|
67
|
+
if (name) {
|
68
|
+
result[name] = value;
|
69
|
+
}
|
70
|
+
} else if (el.name && el.value !== undefined) {
|
71
|
+
result[el.name] = el.value;
|
72
|
+
} else if (el.shadowRoot) {
|
73
|
+
for (const slot of el.shadowRoot.querySelectorAll("slot")) {
|
74
|
+
Object.assign(result, this.buildValue(slot.assignedElements()));
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
return result;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
export default Form;
|
@@ -0,0 +1,75 @@
|
|
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 { htmlStyle } from "@godown/element/directives/html-style.js";
|
5
|
+
import { joinRules } from "@godown/element/tools/css.js";
|
6
|
+
import { isNumerical } from "@godown/element/tools/lib.js";
|
7
|
+
import { css } from "lit";
|
8
|
+
import { property } from "lit/decorators.js";
|
9
|
+
|
10
|
+
import { GlobalStyle } from "../core/global-style.js";
|
11
|
+
|
12
|
+
const protoName = "grid";
|
13
|
+
|
14
|
+
/**
|
15
|
+
* {@linkcode Grid} provides gird layout.
|
16
|
+
*
|
17
|
+
* @slot - Grid items.
|
18
|
+
* @category layout
|
19
|
+
*/
|
20
|
+
@godown(protoName)
|
21
|
+
@styles(css`:host{display:grid;}`)
|
22
|
+
class Grid extends GlobalStyle {
|
23
|
+
/**
|
24
|
+
* CSS property `gap`.
|
25
|
+
*/
|
26
|
+
@property()
|
27
|
+
gap: string;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* CSS property `grid-template-columns`.
|
31
|
+
*
|
32
|
+
* If columns is numerical, divide columns equally.
|
33
|
+
*/
|
34
|
+
@property()
|
35
|
+
columns: string | number;
|
36
|
+
|
37
|
+
/**
|
38
|
+
* CSS property `grid-template-rows`.
|
39
|
+
*
|
40
|
+
* If rows is numerical, divide rows equally.
|
41
|
+
*/
|
42
|
+
@property()
|
43
|
+
rows: string | number;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* CSS property `place-content` (`align-content justify-content`).
|
47
|
+
*/
|
48
|
+
@property()
|
49
|
+
content: string;
|
50
|
+
|
51
|
+
/**
|
52
|
+
* CSS property `place-items` (`align-items justify-items`).
|
53
|
+
*/
|
54
|
+
@property()
|
55
|
+
items: string;
|
56
|
+
|
57
|
+
protected render() {
|
58
|
+
return [
|
59
|
+
htmlSlot(),
|
60
|
+
htmlStyle(
|
61
|
+
joinRules({
|
62
|
+
":host": {
|
63
|
+
gap: this.gap,
|
64
|
+
"grid-template-columns": isNumerical(this.columns) ? `repeat(${this.columns},1fr)` : this.columns,
|
65
|
+
"grid-template-rows": isNumerical(this.rows) ? `repeat(${this.rows},1fr)` : this.rows,
|
66
|
+
"place-content": this.content,
|
67
|
+
"place-items": this.items,
|
68
|
+
},
|
69
|
+
}),
|
70
|
+
),
|
71
|
+
];
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
export default Grid;
|