godown 3.0.0-canary.7 → 3.0.0-canary.8
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/components/alert.d.ts.map +1 -1
- package/components/alert.js +3 -2
- package/components/alert.js.map +1 -1
- package/components/breath.js +2 -2
- package/components/breath.js.map +1 -1
- package/components/card.d.ts +1 -1
- package/components/card.d.ts.map +1 -1
- package/components/card.js +3 -4
- package/components/card.js.map +1 -1
- package/components/carousel.js +1 -1
- package/components/carousel.js.map +1 -1
- package/components/input.d.ts +0 -1
- package/components/input.d.ts.map +1 -1
- package/components/input.js +0 -3
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +1 -1
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +5 -6
- package/components/layout.js.map +1 -1
- package/components/router.js +1 -1
- package/components/router.js.map +1 -1
- package/components/select.d.ts +0 -4
- package/components/select.d.ts.map +1 -1
- package/components/select.js +0 -7
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +1 -2
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +1 -1
- package/components/split.d.ts.map +1 -1
- package/components/split.js +8 -2
- package/components/split.js.map +1 -1
- package/components/text.js +1 -1
- package/components/text.js.map +1 -1
- package/core/super-input.d.ts +0 -1
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +0 -3
- package/core/super-input.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +3 -2
- package/dev/components/alert.js.map +1 -1
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +2 -1
- package/dev/components/breath.js.map +1 -1
- package/dev/components/card.d.ts +1 -1
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +3 -4
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +1 -0
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/input.d.ts +0 -1
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +0 -3
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +1 -1
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +7 -6
- package/dev/components/layout.js.map +1 -1
- package/dev/components/router.js +1 -1
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +0 -4
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +0 -7
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +1 -2
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +1 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +9 -3
- package/dev/components/split.js.map +1 -1
- package/dev/components/text.js +3 -3
- package/dev/core/super-input.d.ts +0 -1
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +0 -3
- package/dev/core/super-input.js.map +1 -1
- package/package.json +7 -6
- 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 +93 -0
- package/src/components/breath.ts +151 -0
- package/src/components/button.ts +276 -0
- package/src/components/card.ts +85 -0
- package/src/components/carousel.ts +166 -0
- package/src/components/details.ts +112 -0
- package/src/components/dialog.ts +160 -0
- package/src/components/divider.ts +44 -0
- package/src/components/dragbox.ts +126 -0
- package/src/components/flex.ts +65 -0
- package/src/components/form.ts +83 -0
- package/src/components/grid.ts +66 -0
- package/src/components/input.ts +71 -0
- package/src/components/layout.ts +84 -0
- package/src/components/link.ts +36 -0
- package/src/components/progress.ts +101 -0
- package/src/components/range.ts +409 -0
- package/src/components/rotate.ts +92 -0
- package/src/components/router.ts +264 -0
- package/src/components/select.ts +268 -0
- package/src/components/skeleton.ts +116 -0
- package/src/components/split.ts +190 -0
- package/src/components/switch.ts +176 -0
- package/src/components/text.ts +95 -0
- package/src/components/time.ts +77 -0
- package/src/components/tooltip.ts +118 -0
- package/src/components/typewriter.ts +147 -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,147 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { classList } from "@godown/element/directives/class-list.js";
|
4
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
+
import { random } from "@godown/element/tools/lib.js";
|
6
|
+
import { css, html, type PropertyValueMap } from "lit";
|
7
|
+
import { property, query, state } from "lit/decorators.js";
|
8
|
+
|
9
|
+
import { GlobalStyle, scopePrefix } from "../core/global-style.js";
|
10
|
+
|
11
|
+
const protoName = "typewriter";
|
12
|
+
const cssScope = scopePrefix(protoName);
|
13
|
+
|
14
|
+
/**
|
15
|
+
* {@linkcode Typewriter} renders a typewriter effect to text.
|
16
|
+
*
|
17
|
+
* @category effect
|
18
|
+
*/
|
19
|
+
@godown(protoName)
|
20
|
+
@styles(css`
|
21
|
+
:host {
|
22
|
+
${cssScope}--cursor-width: .05em;
|
23
|
+
font-family: monospace;
|
24
|
+
white-space: nowrap;
|
25
|
+
}
|
26
|
+
|
27
|
+
i {
|
28
|
+
border-right: var(${cssScope}--cursor-width) solid;
|
29
|
+
margin-left: 0.02em;
|
30
|
+
animation: s 1.5s steps(1) infinite;
|
31
|
+
}
|
32
|
+
|
33
|
+
@keyframes s {
|
34
|
+
0% {
|
35
|
+
border-color: currentColor;
|
36
|
+
}
|
37
|
+
50% {
|
38
|
+
border-color: transparent;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
slot {
|
43
|
+
display: none;
|
44
|
+
}
|
45
|
+
|
46
|
+
.hidden {
|
47
|
+
visibility: hidden;
|
48
|
+
}
|
49
|
+
`)
|
50
|
+
class Typewriter extends GlobalStyle {
|
51
|
+
/**
|
52
|
+
* Raw text.
|
53
|
+
*/
|
54
|
+
@property()
|
55
|
+
text = "";
|
56
|
+
/**
|
57
|
+
* Start immediately after {@linkcode Typewriter.firstUpdated}.
|
58
|
+
*/
|
59
|
+
@property({ type: Boolean })
|
60
|
+
stopped = false;
|
61
|
+
/**
|
62
|
+
* If true, hide the cursor
|
63
|
+
*/
|
64
|
+
@property({ type: Boolean })
|
65
|
+
ended = false;
|
66
|
+
/**
|
67
|
+
* Maximum random time.
|
68
|
+
*/
|
69
|
+
@property({ type: Number })
|
70
|
+
max = 100;
|
71
|
+
/**
|
72
|
+
* Minimum random time.
|
73
|
+
*/
|
74
|
+
@property({ type: Number })
|
75
|
+
min = 50;
|
76
|
+
/**
|
77
|
+
* Fixed time.
|
78
|
+
*/
|
79
|
+
@property({ type: Number })
|
80
|
+
delay = 0;
|
81
|
+
/**
|
82
|
+
* The index at the beginning.
|
83
|
+
*/
|
84
|
+
@property({ type: Number })
|
85
|
+
index = 0;
|
86
|
+
/**
|
87
|
+
* Internal text.
|
88
|
+
*/
|
89
|
+
@state()
|
90
|
+
content = "";
|
91
|
+
|
92
|
+
timeoutID: number;
|
93
|
+
@query("i")
|
94
|
+
_i: HTMLElement;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* {@linkcode Typewriter.text} length.
|
98
|
+
*/
|
99
|
+
get len() {
|
100
|
+
return this.text.length;
|
101
|
+
}
|
102
|
+
|
103
|
+
protected render() {
|
104
|
+
return html`${htmlSlot()}${this.content}<i part="cursor" class="${
|
105
|
+
classList({
|
106
|
+
hidden: this.ended,
|
107
|
+
})
|
108
|
+
}"></i>`;
|
109
|
+
}
|
110
|
+
|
111
|
+
protected firstUpdated() {
|
112
|
+
if (!this.text) {
|
113
|
+
this.text = this._slot?.assignedNodes()[0]?.textContent.trim() || "";
|
114
|
+
}
|
115
|
+
if (!this.stopped && this.len) {
|
116
|
+
this.write();
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
protected updated(changedProperties: PropertyValueMap<this>) {
|
121
|
+
if (changedProperties.has("index")) {
|
122
|
+
this.dispatchEvent(new CustomEvent(this.index === this.len ? "done" : "write", { detail: this.content }));
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
write(at = this.index) {
|
127
|
+
this.content = this.text.slice(0, at + 1);
|
128
|
+
const timeout = this.delay || random(this.max, this.min);
|
129
|
+
this.timeoutID = window.setTimeout(() => {
|
130
|
+
const nx = at + 1;
|
131
|
+
if (nx <= this.len) {
|
132
|
+
this.index = nx;
|
133
|
+
this.write();
|
134
|
+
}
|
135
|
+
}, timeout);
|
136
|
+
}
|
137
|
+
|
138
|
+
stop() {
|
139
|
+
clearTimeout(this.timeoutID);
|
140
|
+
}
|
141
|
+
|
142
|
+
end() {
|
143
|
+
this.ended = true;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
export default Typewriter;
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import { type Gradients, presetsRGB } from "@godown/colors/presets-rgb.js";
|
2
|
+
import { travel } from "@godown/colors/travel.js";
|
3
|
+
import GodownElement from "@godown/element";
|
4
|
+
import GodownConfig from "@godown/element/config.js";
|
5
|
+
import { trim } from "@godown/element/tools/lib.js";
|
6
|
+
import { css, CSSResult, unsafeCSS } from "lit";
|
7
|
+
|
8
|
+
GodownElement.godownConfig ||= new GodownConfig();
|
9
|
+
|
10
|
+
export class GlobalStyle extends GodownElement {
|
11
|
+
}
|
12
|
+
|
13
|
+
const cssvar = trim(GlobalStyle.godownConfig.prefix, "-");
|
14
|
+
|
15
|
+
export function scopePrefix(scope: string, len = 1) {
|
16
|
+
return variablePrefix(cssvar + "-".repeat(len) + scope);
|
17
|
+
}
|
18
|
+
|
19
|
+
export function variablePrefix(variable: string) {
|
20
|
+
return unsafeCSS("--" + variable);
|
21
|
+
}
|
22
|
+
|
23
|
+
export const cssGlobalVars = {
|
24
|
+
foreground: scopePrefix("foreground", 2),
|
25
|
+
background: scopePrefix("background", 2),
|
26
|
+
clipBackground: scopePrefix("clip-background", 2),
|
27
|
+
active: scopePrefix("active", 2),
|
28
|
+
passive: scopePrefix("passive", 2),
|
29
|
+
_colors: {} as PresetsGradientsCSSResult,
|
30
|
+
input: scopePrefix("input", 2),
|
31
|
+
white: scopePrefix("color-white", 2),
|
32
|
+
black: scopePrefix("color-black", 2),
|
33
|
+
};
|
34
|
+
|
35
|
+
type PresetsGradientsCSSResult = Record<keyof typeof presetsRGB, Gradients<CSSResult>>;
|
36
|
+
GlobalStyle.styles = [
|
37
|
+
unsafeCSS(
|
38
|
+
":host{"
|
39
|
+
+ `${cssGlobalVars.black}:rgb(0 0 0);`
|
40
|
+
+ `${cssGlobalVars.white}:rgb(255 255 255);`
|
41
|
+
+ travel((key, gradient, rgb) => {
|
42
|
+
cssGlobalVars._colors[key] ||= [] as any;
|
43
|
+
cssGlobalVars._colors[key].push(unsafeCSS(scopePrefix("color", 2) + "-" + key + "-" + gradient));
|
44
|
+
const endKey = `-${key}-${gradient}`;
|
45
|
+
const colorKey = scopePrefix("color", 2) + endKey;
|
46
|
+
return `${colorKey}:rgb(${rgb});`;
|
47
|
+
}, presetsRGB).join("")
|
48
|
+
+ "}",
|
49
|
+
),
|
50
|
+
css`
|
51
|
+
:host {
|
52
|
+
${cssGlobalVars.background}: var(${cssGlobalVars._colors.darkgray[9]});
|
53
|
+
${cssGlobalVars.foreground}: var(${cssGlobalVars._colors.lightgray[0]});
|
54
|
+
${cssGlobalVars.active}: var(${cssGlobalVars._colors.blue[6]});
|
55
|
+
${cssGlobalVars.passive}: var(${cssGlobalVars._colors.darkgray[6]});
|
56
|
+
${cssGlobalVars.clipBackground}: linear-gradient(180deg, var(${cssGlobalVars.foreground}), var(${cssGlobalVars.passive}));
|
57
|
+
}
|
58
|
+
`,
|
59
|
+
css`
|
60
|
+
* {
|
61
|
+
border: 0;
|
62
|
+
outline: 0;
|
63
|
+
margin: 0;
|
64
|
+
padding: 0;
|
65
|
+
font-size: 100%;
|
66
|
+
font-style: normal;
|
67
|
+
box-sizing: border-box;
|
68
|
+
}
|
69
|
+
|
70
|
+
:host {
|
71
|
+
box-sizing: border-box;
|
72
|
+
}
|
73
|
+
|
74
|
+
a {
|
75
|
+
text-decoration: none;
|
76
|
+
}
|
77
|
+
|
78
|
+
span {
|
79
|
+
white-space: nowrap;
|
80
|
+
}
|
81
|
+
|
82
|
+
svg {
|
83
|
+
user-select: none;
|
84
|
+
}
|
85
|
+
`,
|
86
|
+
];
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { styles } from "@godown/element/decorators/index.js";
|
2
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
3
|
+
import { css, html } from "lit";
|
4
|
+
import { property } from "lit/decorators.js";
|
5
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
6
|
+
|
7
|
+
import { GlobalStyle } from "./global-style.js";
|
8
|
+
|
9
|
+
@styles(css`
|
10
|
+
:host {
|
11
|
+
display: inline-block;
|
12
|
+
color: currentColor;
|
13
|
+
text-decoration: none;
|
14
|
+
cursor: default;
|
15
|
+
}
|
16
|
+
|
17
|
+
:host([href]) {
|
18
|
+
cursor: pointer;
|
19
|
+
}
|
20
|
+
|
21
|
+
a {
|
22
|
+
width: 100%;
|
23
|
+
display: flex;
|
24
|
+
color: inherit;
|
25
|
+
text-decoration: inherit;
|
26
|
+
justify-content: space-between;
|
27
|
+
align-items: center;
|
28
|
+
}
|
29
|
+
`)
|
30
|
+
class SuperAnchor extends GlobalStyle {
|
31
|
+
/**
|
32
|
+
* A element href.
|
33
|
+
*/
|
34
|
+
@property()
|
35
|
+
href: string = undefined;
|
36
|
+
/**
|
37
|
+
* A element target.
|
38
|
+
*/
|
39
|
+
@property()
|
40
|
+
target: "_blank" | "_self" | "_parent" | "_top" = "_self";
|
41
|
+
|
42
|
+
protected render() {
|
43
|
+
return html`<a part="root" href="${ifDefined(this.href)}" target="${this.target}" @click=${this._handleClick}>
|
44
|
+
${htmlSlot()}
|
45
|
+
</a>`;
|
46
|
+
}
|
47
|
+
|
48
|
+
// eslint-disable-next-line
|
49
|
+
protected _handleClick(_: MouseEvent) {}
|
50
|
+
}
|
51
|
+
|
52
|
+
export default SuperAnchor;
|
@@ -0,0 +1,230 @@
|
|
1
|
+
import { part } from "@godown/element/decorators/part.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { htmlSlot } from "@godown/element/directives/index.js";
|
4
|
+
import { type HandlerEvent } from "@godown/element/element.js";
|
5
|
+
import iconEyeSlashFill from "@godown/f7-icon/icons/eye-slash-fill.js";
|
6
|
+
import { css, html } from "lit";
|
7
|
+
import { property } from "lit/decorators.js";
|
8
|
+
|
9
|
+
import { cssGlobalVars, GlobalStyle } from "./global-style.js";
|
10
|
+
|
11
|
+
const fieldStyle = css`
|
12
|
+
.input-field {
|
13
|
+
display: flex;
|
14
|
+
position: relative;
|
15
|
+
align-items: center;
|
16
|
+
border-radius: inherit;
|
17
|
+
height: inherit;
|
18
|
+
}
|
19
|
+
|
20
|
+
.input-field [part="input"] {
|
21
|
+
background: transparent;
|
22
|
+
height: 100%;
|
23
|
+
width: 100%;
|
24
|
+
color: inherit;
|
25
|
+
}
|
26
|
+
|
27
|
+
.input-field:focus-within,
|
28
|
+
.input-field.outline {
|
29
|
+
box-shadow: var(${cssGlobalVars.input}-box-shadow);
|
30
|
+
}
|
31
|
+
|
32
|
+
.input-field [part="icon"] {
|
33
|
+
display: flex;
|
34
|
+
align-items: center;
|
35
|
+
justify-content: center;
|
36
|
+
}
|
37
|
+
|
38
|
+
.input-field [part="prefix"],
|
39
|
+
.input-field [part="suffix"] {
|
40
|
+
height: 100%;
|
41
|
+
display: flex;
|
42
|
+
}
|
43
|
+
|
44
|
+
.input-field [part="space"]{
|
45
|
+
width: var(${cssGlobalVars.input}-space);
|
46
|
+
}
|
47
|
+
`;
|
48
|
+
|
49
|
+
const inputStyle = css`
|
50
|
+
:host {
|
51
|
+
${cssGlobalVars.input}-width: 10em;
|
52
|
+
${cssGlobalVars.input}-height: 1.6em;
|
53
|
+
${cssGlobalVars.input}-space: 0.2em;
|
54
|
+
${cssGlobalVars.input}-background: var(${cssGlobalVars.background});
|
55
|
+
${cssGlobalVars.input}-control: var(${cssGlobalVars.foreground});
|
56
|
+
${cssGlobalVars.input}-control-edge: var(${cssGlobalVars.active});
|
57
|
+
${cssGlobalVars.input}-radius: 0.2em;
|
58
|
+
${cssGlobalVars.input}-box-shadow: 0px 0px 0px .1em var(${cssGlobalVars.active});
|
59
|
+
border-radius: var(${cssGlobalVars.input}-radius);
|
60
|
+
}
|
61
|
+
|
62
|
+
:host([disabled]) {
|
63
|
+
cursor: not-allowed;
|
64
|
+
filter: brightness(0.85);
|
65
|
+
}
|
66
|
+
|
67
|
+
input:disabled {
|
68
|
+
cursor: inherit;
|
69
|
+
}
|
70
|
+
|
71
|
+
input::-ms-reveal,
|
72
|
+
input::-ms-clear {
|
73
|
+
display: none;
|
74
|
+
}
|
75
|
+
`;
|
76
|
+
|
77
|
+
@styles(fieldStyle, inputStyle)
|
78
|
+
class SuperInput extends GlobalStyle {
|
79
|
+
autofocus: boolean;
|
80
|
+
@property()
|
81
|
+
autocomplete: string | boolean;
|
82
|
+
|
83
|
+
@property({ type: Boolean, reflect: true })
|
84
|
+
disabled: boolean;
|
85
|
+
|
86
|
+
@property({ reflect: true })
|
87
|
+
type: InputType;
|
88
|
+
|
89
|
+
@property({ reflect: true })
|
90
|
+
placeholder: string;
|
91
|
+
|
92
|
+
@property({ reflect: true })
|
93
|
+
name: string;
|
94
|
+
|
95
|
+
@property()
|
96
|
+
value: any;
|
97
|
+
|
98
|
+
/**
|
99
|
+
* default property records the default or initial value and is used to reset the input.
|
100
|
+
*/
|
101
|
+
@property()
|
102
|
+
default: any;
|
103
|
+
|
104
|
+
@part("input")
|
105
|
+
_input: HTMLInputElement;
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Returns true when the input is compositing.
|
109
|
+
*/
|
110
|
+
compositing: boolean;
|
111
|
+
|
112
|
+
set defaultValue(value: typeof this.default) {
|
113
|
+
this.default = value;
|
114
|
+
}
|
115
|
+
|
116
|
+
get defaultValue() {
|
117
|
+
return this.default;
|
118
|
+
}
|
119
|
+
|
120
|
+
makeId = Math.random().toString(36).slice(1);
|
121
|
+
|
122
|
+
namevalue(): [string, any] {
|
123
|
+
return [this.name, this.value];
|
124
|
+
}
|
125
|
+
|
126
|
+
nameValue = this.namevalue;
|
127
|
+
|
128
|
+
reset() {
|
129
|
+
this.value = this.default;
|
130
|
+
this._input.value = this.default;
|
131
|
+
}
|
132
|
+
|
133
|
+
protected _handleInput(e: HandlerEvent<HTMLInputElement>) {
|
134
|
+
e.stopPropagation();
|
135
|
+
if (this.compositing) {
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
this.value = e.target.value?.trim();
|
139
|
+
this.dispatchEvent(
|
140
|
+
new CustomEvent("input", {
|
141
|
+
detail: this.value,
|
142
|
+
bubbles: true,
|
143
|
+
composed: true,
|
144
|
+
}),
|
145
|
+
);
|
146
|
+
this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
|
147
|
+
}
|
148
|
+
|
149
|
+
connectedCallback() {
|
150
|
+
super.connectedCallback();
|
151
|
+
this._connectedInit();
|
152
|
+
}
|
153
|
+
|
154
|
+
protected _connectedInit() {
|
155
|
+
this.default ??= this.value || "";
|
156
|
+
this.value ??= this.default;
|
157
|
+
}
|
158
|
+
|
159
|
+
protected _compositionInit() {
|
160
|
+
if (this._input) {
|
161
|
+
this.events.add(this._input, "compositionstart", () => this.compositing = true);
|
162
|
+
this.events.add(this._input, "compositionend", (e: HandlerEvent<HTMLInputElement>) => {
|
163
|
+
this.compositing = false;
|
164
|
+
this._handleInput(e);
|
165
|
+
});
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
protected _changeInputType(t: typeof this.type) {
|
170
|
+
if (this._input) {
|
171
|
+
this._input.type = t;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
focus(options?: FocusOptions) {
|
176
|
+
this._input?.focus(options);
|
177
|
+
}
|
178
|
+
|
179
|
+
protected firstUpdated() {
|
180
|
+
this._compositionInit();
|
181
|
+
}
|
182
|
+
|
183
|
+
protected _renderPrefix() {
|
184
|
+
return html`<label for=${this.makeId} part="prefix">
|
185
|
+
<i part="space"></i>
|
186
|
+
${htmlSlot("prefix")}</label>`;
|
187
|
+
}
|
188
|
+
|
189
|
+
protected _renderSuffix() {
|
190
|
+
const PASSWORD = "password";
|
191
|
+
return html`<label for=${this.makeId} part="suffix">${
|
192
|
+
this.type === "password"
|
193
|
+
? html`
|
194
|
+
<i part="space"></i>
|
195
|
+
<i
|
196
|
+
part="icon"
|
197
|
+
@mousedown="${() => this._changeInputType("text")}"
|
198
|
+
@mouseup="${() => this._changeInputType(PASSWORD)}"
|
199
|
+
@mouseleave="${() => this._changeInputType(PASSWORD)}"
|
200
|
+
>${iconEyeSlashFill()}</i>`
|
201
|
+
: htmlSlot("suffix")
|
202
|
+
}
|
203
|
+
<i part="space"></i>
|
204
|
+
</label>`;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
export default SuperInput;
|
209
|
+
|
210
|
+
type InputType =
|
211
|
+
| "hidden"
|
212
|
+
| "text"
|
213
|
+
| "search"
|
214
|
+
| "tel"
|
215
|
+
| "url"
|
216
|
+
| "email"
|
217
|
+
| "password"
|
218
|
+
| "datetime"
|
219
|
+
| "date"
|
220
|
+
| "month"
|
221
|
+
| "week"
|
222
|
+
| "time"
|
223
|
+
| "datetime-local"
|
224
|
+
| "number"
|
225
|
+
| "range"
|
226
|
+
| "color"
|
227
|
+
| "checkbox"
|
228
|
+
| "radio"
|
229
|
+
| "file"
|
230
|
+
| "image";
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { type PropertyValueMap } from "lit";
|
2
|
+
import { property } from "lit/decorators.js";
|
3
|
+
|
4
|
+
import { GlobalStyle } from "./global-style.js";
|
5
|
+
|
6
|
+
class SuperOpenable extends GlobalStyle {
|
7
|
+
/**
|
8
|
+
* Open the content.
|
9
|
+
*/
|
10
|
+
@property({ type: Boolean, reflect: true })
|
11
|
+
open = false;
|
12
|
+
|
13
|
+
toggle(to = !this.open) {
|
14
|
+
this.open = to;
|
15
|
+
}
|
16
|
+
|
17
|
+
close() {
|
18
|
+
this.open = false;
|
19
|
+
}
|
20
|
+
|
21
|
+
show() {
|
22
|
+
this.open = true;
|
23
|
+
}
|
24
|
+
|
25
|
+
protected updated(changedProperties: PropertyValueMap<this>) {
|
26
|
+
const open = changedProperties.get("open");
|
27
|
+
if (open !== undefined) {
|
28
|
+
this.dispatchEvent(new CustomEvent("change", { detail: this.open }));
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
// eslint-disable-next-line
|
33
|
+
protected _handelClick(_: MouseEvent) {
|
34
|
+
this.toggle();
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
export default SuperOpenable;
|
39
|
+
|
40
|
+
export type Direction4 = "left" | "right" | "top" | "bottom";
|
41
|
+
|
42
|
+
export type Direction5 = Direction4 | "center";
|
43
|
+
|
44
|
+
export type Direction8 =
|
45
|
+
| Direction4
|
46
|
+
| "top-left"
|
47
|
+
| "top-right"
|
48
|
+
| "bottom-left"
|
49
|
+
| "bottom-right";
|
50
|
+
|
51
|
+
export type Direction9 = Direction8 | Direction5;
|
package/src/details.ts
ADDED
package/src/dialog.ts
ADDED
package/src/divider.ts
ADDED
package/src/dragbox.ts
ADDED
package/src/flex.ts
ADDED
package/src/form.ts
ADDED
package/src/grid.ts
ADDED
package/src/index.ts
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
export { default as Alert } from "./alert.js";
|
2
|
+
export { default as Avatar } from "./avatar.js";
|
3
|
+
export { default as Breath } from "./breath.js";
|
4
|
+
export { default as Button } from "./button.js";
|
5
|
+
export { default as Card } from "./card.js";
|
6
|
+
export { default as Carousel } from "./carousel.js";
|
7
|
+
export { default as Details } from "./details.js";
|
8
|
+
export { default as Dialog } from "./dialog.js";
|
9
|
+
export { default as Divider } from "./divider.js";
|
10
|
+
export { default as Dragbox } from "./dragbox.js";
|
11
|
+
export { default as Flex } from "./flex.js";
|
12
|
+
export { default as Form } from "./form.js";
|
13
|
+
export { default as Grid } from "./grid.js";
|
14
|
+
export { default as Input } from "./input.js";
|
15
|
+
export { default as Layout } from "./layout.js";
|
16
|
+
export { default as Link } from "./link.js";
|
17
|
+
export { default as Progress } from "./progress.js";
|
18
|
+
export { default as Range } from "./range.js";
|
19
|
+
export { default as Rotate } from "./rotate.js";
|
20
|
+
export { default as Router } from "./router.js";
|
21
|
+
export { default as Select } from "./select.js";
|
22
|
+
export { default as Skeleton } from "./skeleton.js";
|
23
|
+
export { default as Split } from "./split.js";
|
24
|
+
export { default as Switch } from "./switch.js";
|
25
|
+
export { default as Text } from "./text.js";
|
26
|
+
export { default as Time } from "./time.js";
|
27
|
+
export { default as Tooltip } from "./tooltip.js";
|
28
|
+
export { default as Typewriter } from "./typewriter.js";
|