godown 3.0.0 → 3.0.2
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/build/godown+lit.iife.js +12 -12
- package/build/godown+lit.iife.js.map +1 -1
- package/build/godown+lit.js +12 -12
- package/build/godown+lit.js.map +1 -1
- package/build/godown+lit.umd.js +12 -12
- package/build/godown+lit.umd.js.map +1 -1
- package/build/godown.iife.js +11 -11
- package/build/godown.js +11 -11
- package/build/godown.js.map +1 -1
- package/build/godown.umd.js +11 -11
- package/build/godown.umd.js.map +1 -1
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +1 -1
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +1 -1
- package/components/avatar.js.map +1 -1
- package/components/badge.d.ts.map +1 -1
- package/components/badge.js +1 -1
- package/components/badge.js.map +1 -1
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +1 -1
- package/components/breath.js.map +1 -1
- package/components/button.d.ts.map +1 -1
- package/components/button.js +1 -1
- package/components/button.js.map +1 -1
- package/components/card.d.ts.map +1 -1
- package/components/card.js +1 -1
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +1 -1
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts.map +1 -1
- package/components/details.js +1 -1
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +3 -2
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +1 -1
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +1 -1
- package/components/divider.js.map +1 -1
- 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.map +1 -1
- package/components/flex.js.map +1 -1
- package/components/form.d.ts.map +1 -1
- package/components/form.js.map +1 -1
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js.map +1 -1
- package/components/heading.d.ts.map +1 -1
- package/components/heading.js +1 -1
- package/components/heading.js.map +1 -1
- package/components/input.d.ts.map +1 -1
- package/components/input.js +1 -1
- package/components/input.js.map +1 -1
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +1 -1
- package/components/layout.js.map +1 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +1 -1
- package/components/progress.js.map +1 -1
- package/components/range.d.ts.map +1 -1
- package/components/range.js +1 -1
- package/components/range.js.map +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 +21 -26
- package/components/router.d.ts.map +1 -1
- package/components/router.js +1 -1
- package/components/router.js.map +1 -1
- package/components/select.d.ts.map +1 -1
- package/components/select.js +1 -1
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +1 -1
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts.map +1 -1
- package/components/split.js +1 -1
- package/components/split.js.map +1 -1
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +1 -1
- package/components/switch.js.map +1 -1
- package/components/text.d.ts.map +1 -1
- package/components/text.js +1 -1
- package/components/text.js.map +1 -1
- package/components/time.d.ts.map +1 -1
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +1 -1
- package/components/tooltip.js.map +1 -1
- package/components/typewriter.d.ts.map +1 -1
- package/components/typewriter.js +1 -1
- 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.map +1 -1
- package/core/super-anchor.js +1 -1
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +1 -0
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +1 -1
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts.map +1 -1
- package/core/super-openable.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +82 -69
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +52 -36
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/badge.d.ts.map +1 -1
- package/dev/components/badge.js +57 -50
- package/dev/components/badge.js.map +1 -1
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +20 -14
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +13 -13
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +40 -35
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +63 -43
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +72 -61
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +3 -2
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +63 -65
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +28 -23
- package/dev/components/divider.js.map +1 -1
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js +19 -17
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +16 -11
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +4 -4
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +16 -11
- package/dev/components/grid.js.map +1 -1
- package/dev/components/heading.d.ts.map +1 -1
- package/dev/components/heading.js +62 -40
- package/dev/components/heading.js.map +1 -1
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +32 -24
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +43 -30
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.js +1 -1
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +51 -42
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +33 -30
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +12 -5
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +21 -26
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +22 -18
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +65 -57
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +65 -61
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +66 -58
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +88 -79
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.d.ts.map +1 -1
- package/dev/components/text.js +51 -45
- package/dev/components/text.js.map +1 -1
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +13 -2
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +31 -23
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +35 -27
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +9 -9
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +27 -26
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +1 -0
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +87 -69
- 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 -2
- package/dev/core/super-openable.js.map +1 -1
- package/package.json +3 -3
- package/src/components/alert.ts +84 -75
- package/src/components/avatar.ts +54 -40
- package/src/components/badge.ts +68 -65
- package/src/components/breath.ts +23 -19
- package/src/components/button.ts +14 -14
- package/src/components/card.ts +42 -40
- package/src/components/carousel.ts +65 -47
- package/src/components/details.ts +74 -65
- package/src/components/dialog.ts +69 -66
- package/src/components/divider.ts +33 -30
- package/src/components/dragbox.ts +22 -22
- package/src/components/flex.ts +31 -28
- package/src/components/form.ts +7 -9
- package/src/components/grid.ts +31 -28
- package/src/components/heading.ts +67 -49
- package/src/components/input.ts +37 -31
- package/src/components/layout.ts +45 -34
- package/src/components/link.ts +1 -1
- package/src/components/progress.ts +53 -46
- package/src/components/range.ts +58 -52
- package/src/components/rotate.ts +15 -10
- package/src/components/router.ts +46 -46
- package/src/components/select.ts +74 -70
- package/src/components/skeleton.ts +67 -65
- package/src/components/split.ts +73 -69
- package/src/components/switch.ts +90 -83
- package/src/components/text.ts +53 -49
- package/src/components/time.ts +14 -3
- package/src/components/tooltip.ts +32 -24
- package/src/components/typewriter.ts +37 -31
- package/src/core/global-style.ts +11 -12
- package/src/core/super-anchor.ts +29 -30
- package/src/core/super-input.ts +91 -74
- package/src/core/super-openable.ts +2 -8
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/src/components/time.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { attr, godown, styles } from "@godown/element";
|
2
2
|
import fmtime from "fmtime";
|
3
|
-
import {
|
3
|
+
import { type PropertyValues, type TemplateResult, css, html } from "lit";
|
4
4
|
import { property } from "lit/decorators.js";
|
5
5
|
|
6
6
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -14,7 +14,11 @@ const protoName = "time";
|
|
14
14
|
* @category display
|
15
15
|
*/
|
16
16
|
@godown(protoName)
|
17
|
-
@styles(css
|
17
|
+
@styles(css`
|
18
|
+
:host {
|
19
|
+
text-align: center;
|
20
|
+
}
|
21
|
+
`)
|
18
22
|
class Time extends GlobalStyle {
|
19
23
|
/**
|
20
24
|
* Escape symbol.
|
@@ -49,7 +53,14 @@ class Time extends GlobalStyle {
|
|
49
53
|
protected timeoutId: number;
|
50
54
|
|
51
55
|
protected render(): TemplateResult<1> {
|
52
|
-
return html
|
56
|
+
return html`
|
57
|
+
<span
|
58
|
+
part="root"
|
59
|
+
${attr(this.observedRecord)}
|
60
|
+
>
|
61
|
+
${fmtime(this.format, this.time, this.escape)}
|
62
|
+
</span>
|
63
|
+
`;
|
53
64
|
}
|
54
65
|
|
55
66
|
protected firstUpdated(): void {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { attr, godown, htmlSlot, styles } from "@godown/element";
|
2
|
-
import { css, html
|
2
|
+
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
5
|
import { scopePrefix } from "../core/global-style.js";
|
@@ -24,19 +24,19 @@ const cssScope = scopePrefix(protoName);
|
|
24
24
|
${cssScope}--tip-background: inherit;
|
25
25
|
width: fit-content;
|
26
26
|
}
|
27
|
-
|
27
|
+
|
28
28
|
:host,
|
29
|
-
[part=root] {
|
29
|
+
[part="root"] {
|
30
30
|
display: inline-flex;
|
31
31
|
}
|
32
32
|
|
33
|
-
[part=root] {
|
33
|
+
[part="root"] {
|
34
34
|
position: relative;
|
35
35
|
transition: inherit;
|
36
36
|
border-radius: inherit;
|
37
37
|
}
|
38
38
|
|
39
|
-
[part=tip] {
|
39
|
+
[part="tip"] {
|
40
40
|
width: fit-content;
|
41
41
|
height: fit-content;
|
42
42
|
position: absolute;
|
@@ -45,7 +45,7 @@ const cssScope = scopePrefix(protoName);
|
|
45
45
|
user-select: none;
|
46
46
|
}
|
47
47
|
|
48
|
-
:host([open]) [part=tip] {
|
48
|
+
:host([open]) [part="tip"] {
|
49
49
|
visibility: visible;
|
50
50
|
}
|
51
51
|
|
@@ -53,24 +53,24 @@ const cssScope = scopePrefix(protoName);
|
|
53
53
|
background: var(${cssScope}--tip-background);
|
54
54
|
}
|
55
55
|
|
56
|
-
[propagation] [part=tip] {
|
56
|
+
[propagation] [part="tip"] {
|
57
57
|
pointer-events: none;
|
58
58
|
}
|
59
59
|
`,
|
60
60
|
css`
|
61
|
-
[direction^=top] [part=tip] {
|
61
|
+
[direction^="top"] [part="tip"] {
|
62
62
|
bottom: 100%;
|
63
63
|
}
|
64
64
|
|
65
|
-
[direction^=bottom] [part=tip] {
|
65
|
+
[direction^="bottom"] [part="tip"] {
|
66
66
|
top: 100%;
|
67
67
|
}
|
68
68
|
|
69
|
-
[direction$=right] [part=tip] {
|
69
|
+
[direction$="right"] [part="tip"] {
|
70
70
|
left: 100%;
|
71
71
|
}
|
72
72
|
|
73
|
-
[direction$=left] [part=tip] {
|
73
|
+
[direction$="left"] [part="tip"] {
|
74
74
|
right: 100%;
|
75
75
|
}
|
76
76
|
`,
|
@@ -123,19 +123,27 @@ class Tooltip extends SuperOpenable {
|
|
123
123
|
protected render(): TemplateResult<1> {
|
124
124
|
const align = Tooltip.aligns[this.align] || "inherit";
|
125
125
|
const isFocusable = this.type === "focus";
|
126
|
-
return html
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
126
|
+
return html`
|
127
|
+
<div
|
128
|
+
part="root"
|
129
|
+
${attr(this.observedRecord)}
|
130
|
+
tabindex="${isFocusable ? 0 : -1}"
|
131
|
+
@focus="${isFocusable ? () => (this.open = true) : null}"
|
132
|
+
@blur="${isFocusable ? () => (this.open = false) : null}"
|
133
|
+
@mouseenter="${isFocusable ? null : () => (this.open = true)}"
|
134
|
+
@mouseleave="${isFocusable ? null : () => (this.open = false)}"
|
135
|
+
style="justify-content:${align};align-items:${align}"
|
136
|
+
>
|
137
|
+
${htmlSlot()}
|
138
|
+
<div part="tip">
|
139
|
+
${this.tip
|
140
|
+
? html`
|
141
|
+
<span class="passive">${this.tip}</span>
|
142
|
+
`
|
143
|
+
: htmlSlot("tip")}
|
144
|
+
</div>
|
145
|
+
</div>
|
146
|
+
`;
|
139
147
|
}
|
140
148
|
}
|
141
149
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { attr, godown, htmlSlot, random, styles } from "@godown/element";
|
2
|
-
import {
|
2
|
+
import { type PropertyValueMap, type TemplateResult, css, html } from "lit";
|
3
3
|
import { property, query, state } from "lit/decorators.js";
|
4
4
|
|
5
5
|
import { GlobalStyle, scopePrefix } from "../core/global-style.js";
|
@@ -13,37 +13,35 @@ const cssScope = scopePrefix(protoName);
|
|
13
13
|
* @category effect
|
14
14
|
*/
|
15
15
|
@godown(protoName)
|
16
|
-
@styles(
|
17
|
-
|
18
|
-
:
|
19
|
-
|
20
|
-
}
|
16
|
+
@styles(css`
|
17
|
+
:host {
|
18
|
+
${cssScope}--cursor-width: .05em;
|
19
|
+
}
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
:host,
|
22
|
+
:host([contents]) [part="root"] {
|
23
|
+
display: inline-block;
|
24
|
+
}
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
i {
|
27
|
+
border-right: var(${cssScope}--cursor-width) solid;
|
28
|
+
margin-left: 0.02em;
|
29
|
+
animation: s 1.5s steps(1) infinite;
|
30
|
+
}
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
50% {
|
38
|
-
border-color: transparent;
|
39
|
-
}
|
32
|
+
@keyframes s {
|
33
|
+
0% {
|
34
|
+
border-color: currentColor;
|
40
35
|
}
|
41
|
-
|
42
|
-
|
43
|
-
display: none;
|
36
|
+
50% {
|
37
|
+
border-color: transparent;
|
44
38
|
}
|
45
|
-
|
46
|
-
|
39
|
+
}
|
40
|
+
|
41
|
+
slot {
|
42
|
+
display: none;
|
43
|
+
}
|
44
|
+
`)
|
47
45
|
class Typewriter extends GlobalStyle {
|
48
46
|
/**
|
49
47
|
* Raw text.
|
@@ -97,10 +95,18 @@ class Typewriter extends GlobalStyle {
|
|
97
95
|
}
|
98
96
|
|
99
97
|
protected render(): TemplateResult<1> {
|
100
|
-
return html
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
return html`
|
99
|
+
<div
|
100
|
+
part="root"
|
101
|
+
${attr(this.observedRecord)}
|
102
|
+
>
|
103
|
+
${htmlSlot()} ${this.contentInternal}
|
104
|
+
<i
|
105
|
+
part="cursor"
|
106
|
+
?hidden="${this.ended}"
|
107
|
+
></i>
|
108
|
+
</div>
|
109
|
+
`;
|
104
110
|
}
|
105
111
|
|
106
112
|
protected firstUpdated(): void {
|
package/src/core/global-style.ts
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
import { type Gradients, presetsRGB } from "@godown/colors/presets-rgb.js";
|
2
2
|
import { travel } from "@godown/colors/travel.js";
|
3
3
|
import { GodownElement, joinProperties, trim } from "@godown/element";
|
4
|
-
import {
|
4
|
+
import { type CSSResult, css, unsafeCSS } from "lit";
|
5
5
|
|
6
|
-
export class GlobalStyle extends GodownElement {
|
7
|
-
}
|
6
|
+
export class GlobalStyle extends GodownElement {}
|
8
7
|
|
9
8
|
const cssvar = trim(GlobalStyle.godownConfig.prefix, "-");
|
10
9
|
|
@@ -41,25 +40,25 @@ export const cssGlobalVars: {
|
|
41
40
|
type PresetsGradientsCSSResult = Record<keyof typeof presetsRGB, Gradients<CSSResult>>;
|
42
41
|
GlobalStyle.styles = [
|
43
42
|
unsafeCSS(
|
44
|
-
":host{"
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
":host{" +
|
44
|
+
`${cssGlobalVars.black}:rgb(0 0 0);` +
|
45
|
+
`${cssGlobalVars.white}:rgb(255 255 255);` +
|
46
|
+
travel((key, gradient, rgb) => {
|
48
47
|
cssGlobalVars._colors[key] ||= [] as any;
|
49
48
|
cssGlobalVars._colors[key].push(unsafeCSS(scopePrefix("color", 2) + "-" + key + "-" + gradient));
|
50
49
|
const endKey = `-${key}-${gradient}`;
|
51
50
|
const colorKey = scopePrefix("color", 2) + endKey;
|
52
51
|
return `${colorKey}:rgb(${rgb});`;
|
53
|
-
}, presetsRGB).join("")
|
54
|
-
|
52
|
+
}, presetsRGB).join("") +
|
53
|
+
joinProperties({
|
55
54
|
[cssGlobalVars.background + ""]: `var(${cssGlobalVars._colors.darkgray[9]})`,
|
56
55
|
[cssGlobalVars.foreground + ""]: `var(${cssGlobalVars._colors.lightgray[0]})`,
|
57
56
|
[cssGlobalVars.active + ""]: `var(${cssGlobalVars._colors.blue[6]})`,
|
58
57
|
[cssGlobalVars.passive + ""]: `var(${cssGlobalVars._colors.darkgray[6]})`,
|
59
58
|
[cssGlobalVars.clipBackground + ""]:
|
60
59
|
`linear-gradient(to bottom, var(${cssGlobalVars.foreground}), var(${cssGlobalVars.passive}))`,
|
61
|
-
})
|
62
|
-
|
60
|
+
}) +
|
61
|
+
"}",
|
63
62
|
),
|
64
63
|
css`
|
65
64
|
* {
|
@@ -92,7 +91,7 @@ GlobalStyle.styles = [
|
|
92
91
|
display: contents;
|
93
92
|
}
|
94
93
|
|
95
|
-
:where(:host([contents]) [part=root]) {
|
94
|
+
:where(:host([contents]) [part="root"]) {
|
96
95
|
all: inherit;
|
97
96
|
display: revert;
|
98
97
|
}
|
package/src/core/super-anchor.ts
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
import { attr, htmlSlot, styles } from "@godown/element";
|
2
|
-
import { css, html, nothing
|
2
|
+
import { type TemplateResult, css, html, nothing } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
5
|
import { GlobalStyle } from "./global-style.js";
|
6
6
|
|
7
|
-
@styles(
|
8
|
-
|
9
|
-
:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
7
|
+
@styles(css`
|
8
|
+
:host {
|
9
|
+
display: inline-block;
|
10
|
+
color: currentColor;
|
11
|
+
text-decoration: none;
|
12
|
+
cursor: default;
|
13
|
+
}
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
:host([href]) {
|
16
|
+
cursor: pointer;
|
17
|
+
}
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
)
|
19
|
+
[part="root"] {
|
20
|
+
width: 100%;
|
21
|
+
color: inherit;
|
22
|
+
display: inline-block;
|
23
|
+
text-decoration: inherit;
|
24
|
+
}
|
25
|
+
`)
|
28
26
|
class SuperAnchor extends GlobalStyle {
|
29
27
|
/**
|
30
28
|
* A element href.
|
@@ -38,18 +36,19 @@ class SuperAnchor extends GlobalStyle {
|
|
38
36
|
target: "_blank" | "_self" | "_parent" | "_top" = "_self";
|
39
37
|
|
40
38
|
protected render(): TemplateResult<1> {
|
41
|
-
return html
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
return html`
|
40
|
+
<a
|
41
|
+
part="root"
|
42
|
+
${attr(this.observedRecord)}
|
43
|
+
href="${this.href || nothing}"
|
44
|
+
target="${this.target}"
|
45
|
+
@click=${this._handleClick}
|
46
|
+
>
|
47
|
+
${htmlSlot()}
|
48
|
+
</a>
|
49
|
+
`;
|
50
50
|
}
|
51
51
|
|
52
|
-
// eslint-disable-next-line
|
53
52
|
protected _handleClick(_: MouseEvent): void {}
|
54
53
|
}
|
55
54
|
|
package/src/core/super-input.ts
CHANGED
@@ -1,79 +1,79 @@
|
|
1
|
-
import { type HandlerEvent, htmlSlot, part, styles } from "@godown/element";
|
1
|
+
import { type HandlerEvent, htmlSlot, omit, part, styles } from "@godown/element";
|
2
2
|
import iconEyeSlashFill from "@godown/f7-icon/icons/eye-slash-fill.js";
|
3
|
-
import { css, html
|
3
|
+
import { type TemplateResult, css, html } from "lit";
|
4
4
|
import { property } from "lit/decorators.js";
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { GlobalStyle, cssGlobalVars } from "./global-style.js";
|
7
7
|
|
8
8
|
const fieldStyle = css`
|
9
|
-
.input-field {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
}
|
9
|
+
.input-field {
|
10
|
+
display: flex;
|
11
|
+
position: relative;
|
12
|
+
align-items: center;
|
13
|
+
border-radius: inherit;
|
14
|
+
height: inherit;
|
15
|
+
}
|
16
16
|
|
17
|
-
.input-field [part=input] {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
17
|
+
.input-field [part="input"] {
|
18
|
+
background: transparent;
|
19
|
+
height: 100%;
|
20
|
+
width: 100%;
|
21
|
+
color: inherit;
|
22
|
+
padding: 0 var(${cssGlobalVars.input}-space);
|
23
|
+
}
|
24
24
|
|
25
|
-
.input-field:focus-within,
|
26
|
-
.input-field.outline {
|
27
|
-
|
28
|
-
}
|
25
|
+
.input-field:focus-within,
|
26
|
+
.input-field.outline {
|
27
|
+
box-shadow: var(${cssGlobalVars.input}-box-shadow);
|
28
|
+
}
|
29
29
|
|
30
|
-
.input-field [part=icon] {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
30
|
+
.input-field [part="icon"] {
|
31
|
+
display: flex;
|
32
|
+
align-items: center;
|
33
|
+
justify-content: center;
|
34
|
+
}
|
35
35
|
|
36
|
-
.input-field [part=prefix],
|
37
|
-
.input-field [part=suffix] {
|
38
|
-
|
39
|
-
|
40
|
-
}
|
36
|
+
.input-field [part="prefix"],
|
37
|
+
.input-field [part="suffix"] {
|
38
|
+
height: 100%;
|
39
|
+
display: flex;
|
40
|
+
}
|
41
41
|
|
42
|
-
.input-field [part=suffix] [part=icon] {
|
43
|
-
|
44
|
-
}
|
42
|
+
.input-field [part="suffix"] [part="icon"] {
|
43
|
+
padding-inline-end: var(${cssGlobalVars.input}-space);
|
44
|
+
}
|
45
45
|
|
46
|
-
.input-field [part=prefix] [part=icon] {
|
47
|
-
|
48
|
-
}
|
46
|
+
.input-field [part="prefix"] [part="icon"] {
|
47
|
+
padding-inline-start: var(${cssGlobalVars.input}-space);
|
48
|
+
}
|
49
49
|
`;
|
50
50
|
|
51
51
|
const inputStyle = css`
|
52
|
-
:host {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
}
|
52
|
+
:host {
|
53
|
+
${cssGlobalVars.input}-width: 10em;
|
54
|
+
${cssGlobalVars.input}-height: 1.6em;
|
55
|
+
${cssGlobalVars.input}-space: 0.2em;
|
56
|
+
${cssGlobalVars.input}-background: var(${cssGlobalVars.background});
|
57
|
+
${cssGlobalVars.input}-control: var(${cssGlobalVars.foreground});
|
58
|
+
${cssGlobalVars.input}-control-edge: var(${cssGlobalVars.active});
|
59
|
+
${cssGlobalVars.input}-radius: 0.2em;
|
60
|
+
${cssGlobalVars.input}-box-shadow: 0px 0px 0px .1em var(${cssGlobalVars.active});
|
61
|
+
border-radius: var(${cssGlobalVars.input}-radius);
|
62
|
+
}
|
63
63
|
|
64
|
-
:host([disabled]) {
|
65
|
-
|
66
|
-
|
67
|
-
}
|
64
|
+
:host([disabled]) {
|
65
|
+
cursor: not-allowed;
|
66
|
+
filter: brightness(0.85);
|
67
|
+
}
|
68
68
|
|
69
|
-
input:disabled {
|
70
|
-
|
71
|
-
}
|
69
|
+
input:disabled {
|
70
|
+
cursor: inherit;
|
71
|
+
}
|
72
72
|
|
73
|
-
input::-ms-reveal,
|
74
|
-
input::-ms-clear {
|
75
|
-
|
76
|
-
}
|
73
|
+
input::-ms-reveal,
|
74
|
+
input::-ms-clear {
|
75
|
+
display: none;
|
76
|
+
}
|
77
77
|
`;
|
78
78
|
|
79
79
|
@styles(fieldStyle, inputStyle)
|
@@ -97,6 +97,10 @@ class SuperInput extends GlobalStyle {
|
|
97
97
|
@property()
|
98
98
|
value: any;
|
99
99
|
|
100
|
+
get observedRecord(): Record<string, any> {
|
101
|
+
return omit(super.observedRecord, "default", "value");
|
102
|
+
}
|
103
|
+
|
100
104
|
/**
|
101
105
|
* default property records the default or initial value and is used to reset the input.
|
102
106
|
*/
|
@@ -161,7 +165,7 @@ class SuperInput extends GlobalStyle {
|
|
161
165
|
|
162
166
|
protected _compositionInit(): void {
|
163
167
|
if (this._input) {
|
164
|
-
this.events.add(this._input, "compositionstart", () => this.compositing = true);
|
168
|
+
this.events.add(this._input, "compositionstart", () => (this.compositing = true));
|
165
169
|
this.events.add(this._input, "compositionend", (e: HandlerEvent<HTMLInputElement>) => {
|
166
170
|
this.compositing = false;
|
167
171
|
this._handleInput(e);
|
@@ -184,24 +188,37 @@ class SuperInput extends GlobalStyle {
|
|
184
188
|
}
|
185
189
|
|
186
190
|
protected _renderPrefix(): TemplateResult<1> {
|
187
|
-
return html
|
188
|
-
|
191
|
+
return html`
|
192
|
+
<label
|
193
|
+
for=${this.makeId}
|
194
|
+
part="prefix"
|
195
|
+
>
|
196
|
+
${htmlSlot("prefix")}
|
197
|
+
</label>
|
198
|
+
`;
|
189
199
|
}
|
190
200
|
|
191
201
|
protected _renderSuffix(): TemplateResult<1> {
|
192
202
|
const PASSWORD = "password";
|
193
|
-
return html
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
203
|
+
return html`
|
204
|
+
<label
|
205
|
+
for=${this.makeId}
|
206
|
+
part="suffix"
|
207
|
+
>
|
208
|
+
${this.type === "password"
|
209
|
+
? html`
|
210
|
+
<i
|
211
|
+
part="icon"
|
212
|
+
@mousedown="${() => this._changeInputType("text")}"
|
213
|
+
@mouseup="${() => this._changeInputType(PASSWORD)}"
|
214
|
+
@mouseleave="${() => this._changeInputType(PASSWORD)}"
|
215
|
+
>
|
216
|
+
${iconEyeSlashFill()}
|
217
|
+
</i>
|
218
|
+
`
|
219
|
+
: htmlSlot("suffix")}
|
220
|
+
</label>
|
221
|
+
`;
|
205
222
|
}
|
206
223
|
}
|
207
224
|
|
@@ -10,7 +10,7 @@ class SuperOpenable extends GlobalStyle {
|
|
10
10
|
@property({ type: Boolean, reflect: true })
|
11
11
|
open = false;
|
12
12
|
|
13
|
-
toggle(to: boolean =
|
13
|
+
toggle(to: boolean = !this.open satisfies boolean): void {
|
14
14
|
this.open = to;
|
15
15
|
}
|
16
16
|
|
@@ -29,7 +29,6 @@ class SuperOpenable extends GlobalStyle {
|
|
29
29
|
}
|
30
30
|
}
|
31
31
|
|
32
|
-
// eslint-disable-next-line
|
33
32
|
protected _handelClick(_: MouseEvent): void {
|
34
33
|
this.toggle();
|
35
34
|
}
|
@@ -41,11 +40,6 @@ export type Direction4 = "left" | "right" | "top" | "bottom";
|
|
41
40
|
|
42
41
|
export type Direction5 = Direction4 | "center";
|
43
42
|
|
44
|
-
export type Direction8 =
|
45
|
-
| Direction4
|
46
|
-
| "top-left"
|
47
|
-
| "top-right"
|
48
|
-
| "bottom-left"
|
49
|
-
| "bottom-right";
|
43
|
+
export type Direction8 = Direction4 | "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
50
44
|
|
51
45
|
export type Direction9 = Direction8 | Direction5;
|