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