godown 3.2.0 → 3.4.0
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 +10 -10
- package/build/godown.js +10 -10
- package/build/godown.js.map +1 -1
- package/build/godown.umd.js +10 -10
- package/build/godown.umd.js.map +1 -1
- package/components/alert.d.ts +1 -3
- 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 +5 -4
- 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 +10 -2
- package/components/badge.d.ts.map +1 -1
- package/components/badge.js.map +1 -1
- package/components/breath.d.ts +2 -3
- 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 +8 -3
- 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 +6 -0
- 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 +7 -13
- 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 +3 -3
- package/components/details.d.ts.map +1 -1
- package/components/dialog.d.ts +9 -6
- 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 +1 -1
- package/components/heading.d.ts +2 -0
- package/components/heading.d.ts.map +1 -1
- package/components/heading.js.map +1 -1
- package/components/input.d.ts +2 -2
- package/components/input.d.ts.map +1 -1
- package/components/input.js +1 -1
- package/components/input.js.map +1 -1
- package/components/link.d.ts +1 -1
- package/components/link.d.ts.map +1 -1
- package/components/link.js +1 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts +0 -7
- 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 +48 -19
- 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 +6 -4
- package/components/rotate.d.ts.map +1 -1
- package/components/rotate.js.map +1 -1
- 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 +4 -2
- package/components/select.d.ts.map +1 -1
- package/components/select.js +1 -1
- package/components/select.js.map +1 -1
- package/components/split.d.ts +2 -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 +5 -7
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +1 -1
- package/components/switch.js.map +1 -1
- package/components/text.js +1 -1
- package/components/text.js.map +1 -1
- package/components/time.d.ts +2 -5
- package/components/time.d.ts.map +1 -1
- package/components/time.js +1 -1
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +3 -2
- 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/direction.d.ts +27 -0
- package/core/direction.d.ts.map +1 -0
- package/core/direction.js +2 -0
- package/core/direction.js.map +1 -0
- package/core/global-style.d.ts +1 -2
- 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/outline.d.ts +20 -0
- package/core/outline.d.ts.map +1 -0
- package/core/outline.js +2 -0
- package/core/outline.js.map +1 -0
- package/core/super-anchor.d.ts +2 -2
- 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 +2 -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 +0 -4
- package/core/super-openable.d.ts.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts +1 -3
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +33 -57
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts +5 -4
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +5 -4
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/badge.d.ts +10 -2
- package/dev/components/badge.d.ts.map +1 -1
- package/dev/components/badge.js +8 -0
- package/dev/components/badge.js.map +1 -1
- package/dev/components/breath.d.ts +2 -3
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +3 -14
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +8 -3
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +19 -5
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +6 -0
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +11 -11
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +7 -13
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +40 -39
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +3 -3
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +3 -3
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +9 -6
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +58 -62
- 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/heading.d.ts +2 -0
- package/dev/components/heading.d.ts.map +1 -1
- package/dev/components/heading.js +2 -0
- package/dev/components/heading.js.map +1 -1
- package/dev/components/input.d.ts +2 -2
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +30 -9
- package/dev/components/input.js.map +1 -1
- package/dev/components/link.d.ts +1 -1
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +2 -2
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +0 -7
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +4 -25
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +48 -19
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +83 -61
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +6 -4
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +6 -4
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +2 -3
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +4 -2
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +27 -24
- package/dev/components/select.js.map +1 -1
- package/dev/components/split.d.ts +2 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +11 -7
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +5 -7
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +23 -45
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.js +2 -2
- package/dev/components/time.d.ts +2 -5
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +6 -20
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +3 -2
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +7 -19
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +2 -2
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/direction.d.ts +27 -0
- package/dev/core/direction.d.ts.map +1 -0
- package/dev/core/direction.js +56 -0
- package/dev/core/direction.js.map +1 -0
- package/dev/core/global-style.d.ts +1 -2
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +11 -11
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/outline.d.ts +20 -0
- package/dev/core/outline.d.ts.map +1 -0
- package/dev/core/outline.js +44 -0
- package/dev/core/outline.js.map +1 -0
- package/dev/core/super-anchor.d.ts +2 -2
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +0 -1
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +2 -0
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +19 -30
- package/dev/core/super-input.js.map +1 -1
- package/dev/core/super-openable.d.ts +0 -4
- package/dev/core/super-openable.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/alert.ts +34 -65
- package/src/components/avatar.ts +7 -5
- package/src/components/badge.ts +10 -3
- package/src/components/breath.ts +5 -17
- package/src/components/button.ts +19 -6
- package/src/components/card.ts +11 -11
- package/src/components/carousel.ts +45 -44
- package/src/components/details.ts +3 -3
- package/src/components/dialog.ts +66 -65
- package/src/components/divider.ts +1 -1
- package/src/components/heading.ts +2 -0
- package/src/components/input.ts +30 -9
- package/src/components/link.ts +2 -2
- package/src/components/progress.ts +4 -25
- package/src/components/range.ts +92 -70
- package/src/components/rotate.ts +6 -4
- package/src/components/router.ts +2 -3
- package/src/components/select.ts +33 -26
- package/src/components/split.ts +12 -7
- package/src/components/switch.ts +26 -41
- package/src/components/text.ts +2 -2
- package/src/components/time.ts +10 -25
- package/src/components/tooltip.ts +8 -20
- package/src/components/typewriter.ts +9 -7
- package/src/core/direction.ts +65 -0
- package/src/core/global-style.ts +12 -14
- package/src/core/outline.ts +54 -0
- package/src/core/super-anchor.ts +3 -2
- package/src/core/super-input.ts +22 -30
- package/src/core/super-openable.ts +0 -8
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/src/components/card.ts
CHANGED
@@ -22,19 +22,13 @@ const cssScope = scopePrefix(protoName);
|
|
22
22
|
@godown(protoName)
|
23
23
|
@styles(css`
|
24
24
|
:host {
|
25
|
-
${cssScope}--
|
26
|
-
${cssScope}--border-
|
27
|
-
${cssScope}--
|
28
|
-
${cssScope}--border-background: var(${cssGlobalVars.passive});
|
29
|
-
${cssScope}--padding: .75em;
|
30
|
-
color: var(${cssGlobalVars.foreground});
|
31
|
-
background: var(${cssScope}--background);
|
25
|
+
${cssScope}--border-width: .075em;
|
26
|
+
${cssScope}--border-color: var(${cssGlobalVars.passive});
|
27
|
+
${cssScope}--padding: .5em;
|
32
28
|
border-width: var(${cssScope}--border-width);
|
33
29
|
display: block;
|
34
30
|
flex-shrink: 0;
|
35
|
-
|
36
|
-
overflow: hidden;
|
37
|
-
box-sizing: border-box;
|
31
|
+
border-radius: 0.2em;
|
38
32
|
}
|
39
33
|
|
40
34
|
slot {
|
@@ -44,7 +38,7 @@ const cssScope = scopePrefix(protoName);
|
|
44
38
|
|
45
39
|
:host,
|
46
40
|
slot {
|
47
|
-
border-color: var(${cssScope}--border-
|
41
|
+
border-color: var(${cssScope}--border-color);
|
48
42
|
border-style: solid;
|
49
43
|
}
|
50
44
|
|
@@ -57,9 +51,15 @@ const cssScope = scopePrefix(protoName);
|
|
57
51
|
}
|
58
52
|
`)
|
59
53
|
class Card extends GlobalStyle {
|
54
|
+
/**
|
55
|
+
* Whether to display the header.
|
56
|
+
*/
|
60
57
|
@property({ type: Boolean })
|
61
58
|
footer = false;
|
62
59
|
|
60
|
+
/**
|
61
|
+
* Whether to display the footer.
|
62
|
+
*/
|
63
63
|
@property({ type: Boolean })
|
64
64
|
header = false;
|
65
65
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { attr, godown, htmlSlot,
|
1
|
+
import { attr, godown, htmlSlot, part, styles } from "@godown/element";
|
2
2
|
import iconChevronLeft from "@godown/f7-icon/icons/chevron-left.js";
|
3
3
|
import iconChevronRight from "@godown/f7-icon/icons/chevron-right.js";
|
4
4
|
import { type TemplateResult, css, html } from "lit";
|
@@ -8,16 +8,16 @@ import { GlobalStyle } from "../core/global-style.js";
|
|
8
8
|
|
9
9
|
const protoName = "carousel";
|
10
10
|
|
11
|
+
function getWidth(e) {
|
12
|
+
return e.getBoundingClientRect().width;
|
13
|
+
}
|
14
|
+
|
11
15
|
/**
|
12
16
|
* {@linkcode Carousel} make the content display as a carousel.
|
13
17
|
*
|
14
18
|
* When this component is `firstUpdated`,
|
15
19
|
* clone the first and last element and make the matching element visible when switching index.
|
16
20
|
*
|
17
|
-
* Child elements should maintain the same size.
|
18
|
-
*
|
19
|
-
* If no width, it will be the width of the first element.
|
20
|
-
*
|
21
21
|
* @slot - Carousel items, should maintain the same size.
|
22
22
|
* @fires change - Fires when the index changes.
|
23
23
|
* @category display
|
@@ -69,23 +69,17 @@ const protoName = "carousel";
|
|
69
69
|
`)
|
70
70
|
class Carousel extends GlobalStyle {
|
71
71
|
/**
|
72
|
-
* The index of the
|
72
|
+
* The index of the current item.
|
73
73
|
*/
|
74
74
|
@property({ type: Number })
|
75
75
|
index = 0;
|
76
76
|
|
77
77
|
/**
|
78
|
-
*
|
78
|
+
* The duration of the transition.
|
79
79
|
*/
|
80
80
|
@property({ type: Number })
|
81
81
|
autoChange = 0;
|
82
82
|
|
83
|
-
/**
|
84
|
-
* Element width.
|
85
|
-
*/
|
86
|
-
@property()
|
87
|
-
width: string;
|
88
|
-
|
89
83
|
@part("move-root")
|
90
84
|
protected _moveRoot: HTMLElement;
|
91
85
|
|
@@ -95,6 +89,8 @@ class Carousel extends GlobalStyle {
|
|
95
89
|
|
96
90
|
private __cloneLast: HTMLElement | undefined;
|
97
91
|
|
92
|
+
protected _offset: number;
|
93
|
+
|
98
94
|
protected render(): TemplateResult<1> {
|
99
95
|
return html`
|
100
96
|
<div
|
@@ -107,47 +103,59 @@ class Carousel extends GlobalStyle {
|
|
107
103
|
>
|
108
104
|
${iconChevronLeft()}
|
109
105
|
</i>
|
110
|
-
<div
|
111
|
-
part="move-root"
|
112
|
-
style="transform:${`translateX(-${this.index + 1}00%)`}"
|
113
|
-
>
|
114
|
-
${htmlSlot()}
|
115
|
-
</div>
|
106
|
+
<div part="move-root">${htmlSlot()}</div>
|
116
107
|
<i
|
117
108
|
part="next"
|
118
109
|
@click="${this.next}"
|
119
110
|
>
|
120
111
|
${iconChevronRight()}
|
121
112
|
</i>
|
122
|
-
${htmlStyle(`:host,:host([contents]) [part=root]{width:${this.width};}`)}
|
123
113
|
</div>
|
124
114
|
`;
|
125
115
|
}
|
126
116
|
|
127
|
-
|
128
|
-
|
129
|
-
|
117
|
+
connectedCallback(): void {
|
118
|
+
super.connectedCallback();
|
130
119
|
if (this.children.length) {
|
131
|
-
this.width ||= `${(this.firstElementChild as HTMLElement).offsetWidth}px`;
|
132
|
-
|
133
120
|
this.__cloneFirst?.remove();
|
134
121
|
this.__cloneLast?.remove();
|
135
122
|
this.__cloneLast = this.firstElementChild.cloneNode(true) as HTMLElement;
|
136
123
|
this.__cloneFirst = this.lastElementChild.cloneNode(true) as HTMLElement;
|
137
124
|
this.appendChild(this.__cloneLast);
|
138
125
|
this.insertBefore(this.__cloneFirst, this.firstElementChild);
|
139
|
-
this.show(this.index);
|
140
126
|
}
|
141
|
-
this.checkInterval();
|
142
127
|
}
|
143
128
|
|
144
|
-
|
145
|
-
|
129
|
+
protected async firstUpdated(): Promise<void> {
|
130
|
+
await this.updateComplete;
|
131
|
+
this.show(this.index, true);
|
146
132
|
}
|
147
133
|
|
148
|
-
|
134
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
135
|
+
super.attributeChangedCallback(name, _old, value);
|
136
|
+
if (name === "index" && this.isConnected) {
|
137
|
+
this.show(this.index);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
show(i: number, n?: boolean): void {
|
142
|
+
i = this.normalizeIndex(i);
|
149
143
|
this.index = i;
|
144
|
+
this._offset = 0;
|
145
|
+
for (let childIndex = 0; childIndex <= i; childIndex++) {
|
146
|
+
this._offset -= getWidth(this.children[childIndex]);
|
147
|
+
}
|
148
|
+
this._offset += (getWidth(this) - getWidth(this.children[i + 1])) / 2;
|
150
149
|
this.dispatchEvent(new CustomEvent("change", { detail: i, composed: true }));
|
150
|
+
this._doTranslateX(`${this._offset}px`, n);
|
151
|
+
this.timeouts.remove(this.intervalID);
|
152
|
+
if (this.autoChange > 0) {
|
153
|
+
this.intervalID = this.timeouts.add(
|
154
|
+
setInterval(() => {
|
155
|
+
this.next();
|
156
|
+
}, this.autoChange),
|
157
|
+
);
|
158
|
+
}
|
151
159
|
}
|
152
160
|
|
153
161
|
next(): void {
|
@@ -157,7 +165,6 @@ class Carousel extends GlobalStyle {
|
|
157
165
|
} else {
|
158
166
|
this.show(this.index + 1);
|
159
167
|
}
|
160
|
-
this.checkInterval();
|
161
168
|
}
|
162
169
|
|
163
170
|
prev(): void {
|
@@ -167,26 +174,20 @@ class Carousel extends GlobalStyle {
|
|
167
174
|
} else {
|
168
175
|
this.show(this.index - 1);
|
169
176
|
}
|
170
|
-
this.checkInterval();
|
171
177
|
}
|
172
178
|
|
173
179
|
protected _doTranslateX(xValue: string, noTransition?: boolean): void {
|
174
180
|
this._moveRoot.style.transform = `translateX(${xValue})`;
|
175
|
-
|
176
|
-
this._moveRoot.style.transition = "none";
|
177
|
-
}
|
178
|
-
this._moveRoot.getBoundingClientRect();
|
181
|
+
this._moveRoot.style.transition = noTransition ? "none" : "";
|
179
182
|
}
|
180
183
|
|
181
|
-
|
182
|
-
if (
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
this.intervalID = setInterval(() => {
|
187
|
-
this.next();
|
188
|
-
}, this.autoChange);
|
184
|
+
normalizeIndex(i: number): number {
|
185
|
+
if (i < 0) {
|
186
|
+
return 0;
|
187
|
+
} else if (i > this.children.length - 3) {
|
188
|
+
return this.children.length - 3;
|
189
189
|
}
|
190
|
+
return i;
|
190
191
|
}
|
191
192
|
}
|
192
193
|
|
@@ -4,7 +4,7 @@ import { type TemplateResult, css, html } from "lit";
|
|
4
4
|
import { property } from "lit/decorators.js";
|
5
5
|
|
6
6
|
import { scopePrefix } from "../core/global-style.js";
|
7
|
-
import SuperOpenable from "../core/super-openable.js";
|
7
|
+
import { SuperOpenable } from "../core/super-openable.js";
|
8
8
|
|
9
9
|
const protoName = "details";
|
10
10
|
|
@@ -79,13 +79,13 @@ const cssScope = scopePrefix(protoName);
|
|
79
79
|
`)
|
80
80
|
class Details extends SuperOpenable {
|
81
81
|
/**
|
82
|
-
*
|
82
|
+
* Determines whether the details component should fill the available space.
|
83
83
|
*/
|
84
84
|
@property({ type: Boolean })
|
85
85
|
fill = false;
|
86
86
|
|
87
87
|
/**
|
88
|
-
*
|
88
|
+
* The summary text to display in the details component.
|
89
89
|
*/
|
90
90
|
@property()
|
91
91
|
summary = "";
|
package/src/components/dialog.ts
CHANGED
@@ -2,8 +2,14 @@ import { type HandlerEvent, attr, godown, htmlSlot, styles } from "@godown/eleme
|
|
2
2
|
import { type PropertyValues, type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
|
-
import {
|
6
|
-
import SuperOpenable from "../core/super-openable.js";
|
5
|
+
import { scopePrefix } from "../core/global-style.js";
|
6
|
+
import { SuperOpenable } from "../core/super-openable.js";
|
7
|
+
import {
|
8
|
+
type DirectionCardinal,
|
9
|
+
type DirectionCenter,
|
10
|
+
type DirectionCorner,
|
11
|
+
directionInsetAlign,
|
12
|
+
} from "../core/direction.js";
|
7
13
|
|
8
14
|
const protoName = "dialog";
|
9
15
|
const cssScope = scopePrefix(protoName);
|
@@ -19,87 +25,77 @@ const cssScope = scopePrefix(protoName);
|
|
19
25
|
* @category feedback
|
20
26
|
*/
|
21
27
|
@godown(protoName)
|
22
|
-
@styles(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
visibility: visible;
|
37
|
-
}
|
38
|
-
|
39
|
-
:host([open][modal]) [part="modal"] {
|
40
|
-
pointer-events: all;
|
41
|
-
visibility: visible;
|
42
|
-
opacity: var(${cssScope}--opacity-modal);
|
43
|
-
}
|
44
|
-
|
45
|
-
[part="modal"] {
|
46
|
-
visibility: hidden;
|
47
|
-
opacity: 0;
|
48
|
-
width: 100%;
|
49
|
-
height: 100%;
|
50
|
-
position: absolute;
|
51
|
-
background: var(${cssScope}--background-modal);
|
52
|
-
}
|
53
|
-
|
54
|
-
[part="root"] {
|
55
|
-
width: 100%;
|
56
|
-
height: 100%;
|
57
|
-
display: flex;
|
58
|
-
position: relative;
|
59
|
-
align-items: center;
|
60
|
-
justify-content: center;
|
61
|
-
}
|
28
|
+
@styles(
|
29
|
+
directionInsetAlign,
|
30
|
+
css`
|
31
|
+
:host {
|
32
|
+
${cssScope}--background: none;
|
33
|
+
${cssScope}--background-modal: black;
|
34
|
+
${cssScope}--opacity-modal: 0.2;
|
35
|
+
background: var(${cssScope}--background);
|
36
|
+
pointer-events: none;
|
37
|
+
visibility: hidden;
|
38
|
+
position: fixed;
|
39
|
+
z-index: 1;
|
40
|
+
inset: 0;
|
41
|
+
}
|
62
42
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
}
|
43
|
+
:host([open]) {
|
44
|
+
visibility: visible;
|
45
|
+
}
|
67
46
|
|
68
|
-
|
69
|
-
|
70
|
-
|
47
|
+
:host([open][modal]) [part="modal"] {
|
48
|
+
pointer-events: all;
|
49
|
+
visibility: visible;
|
50
|
+
opacity: var(${cssScope}--opacity-modal);
|
51
|
+
}
|
71
52
|
|
72
|
-
|
73
|
-
|
74
|
-
|
53
|
+
[part="modal"] {
|
54
|
+
visibility: hidden;
|
55
|
+
opacity: 0;
|
56
|
+
width: 100%;
|
57
|
+
height: 100%;
|
58
|
+
position: absolute;
|
59
|
+
background: var(${cssScope}--background-modal);
|
60
|
+
}
|
75
61
|
|
76
|
-
|
77
|
-
|
78
|
-
|
62
|
+
[part="root"] {
|
63
|
+
width: 100%;
|
64
|
+
height: 100%;
|
65
|
+
display: flex;
|
66
|
+
position: relative;
|
67
|
+
align-items: center;
|
68
|
+
justify-content: center;
|
69
|
+
}
|
79
70
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
71
|
+
[part="container"] {
|
72
|
+
pointer-events: all;
|
73
|
+
position: absolute;
|
74
|
+
}
|
75
|
+
`,
|
76
|
+
)
|
84
77
|
class Dialog extends SuperOpenable {
|
85
78
|
/**
|
86
|
-
*
|
87
|
-
* @deprecated
|
79
|
+
* The direction of the dialog container.
|
88
80
|
*/
|
89
|
-
|
81
|
+
@property()
|
82
|
+
direction: DirectionCardinal | DirectionCorner | DirectionCenter;
|
90
83
|
|
91
84
|
/**
|
92
|
-
*
|
85
|
+
* Indicates whether the dialog should be displayed as a modal.
|
93
86
|
*/
|
94
87
|
@property({ type: Boolean, reflect: true })
|
95
88
|
modal = false;
|
96
89
|
|
97
90
|
/**
|
98
|
-
*
|
91
|
+
* The keys will close the dialog when pressed.
|
99
92
|
*/
|
100
93
|
@property()
|
101
94
|
key = "Escape";
|
102
95
|
|
96
|
+
/**
|
97
|
+
* Indicates whether the modal has been invoked.
|
98
|
+
*/
|
103
99
|
private __modalInvoke = false;
|
104
100
|
|
105
101
|
protected render(): TemplateResult<1> {
|
@@ -109,7 +105,12 @@ class Dialog extends SuperOpenable {
|
|
109
105
|
${attr(this.observedRecord)}
|
110
106
|
>
|
111
107
|
<div part="modal"></div>
|
112
|
-
<div
|
108
|
+
<div
|
109
|
+
part="container"
|
110
|
+
direction-inset-align
|
111
|
+
>
|
112
|
+
${htmlSlot()}
|
113
|
+
</div>
|
113
114
|
</div>
|
114
115
|
`;
|
115
116
|
}
|
package/src/components/input.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
import { attr,
|
1
|
+
import { attr, tokenList, godown, part, styles, htmlSlot } from "@godown/element";
|
2
|
+
import iconEyeSlashFill from "@godown/f7-icon/icons/eye-slash-fill.js";
|
2
3
|
import { type TemplateResult, css, html, nothing } from "lit";
|
3
4
|
import { property } from "lit/decorators.js";
|
4
5
|
|
5
6
|
import { cssGlobalVars } from "../core/global-style.js";
|
6
|
-
import SuperInput from "../core/super-input.js";
|
7
|
+
import { SuperInput } from "../core/super-input.js";
|
7
8
|
|
8
9
|
const protoName = "input";
|
9
10
|
|
@@ -19,11 +20,13 @@ const protoName = "input";
|
|
19
20
|
:host {
|
20
21
|
width: var(${cssGlobalVars.input}-width);
|
21
22
|
height: var(${cssGlobalVars.input}-height);
|
22
|
-
color: var(${cssGlobalVars.foreground});
|
23
|
-
background: var(${cssGlobalVars.input}-background);
|
24
|
-
border-radius: var(${cssGlobalVars.input}-radius);
|
25
23
|
display: block;
|
26
24
|
}
|
25
|
+
|
26
|
+
:host(:focus-within),
|
27
|
+
.outline {
|
28
|
+
${cssGlobalVars.input}-outline-color: var(${cssGlobalVars.active});
|
29
|
+
}
|
27
30
|
`)
|
28
31
|
class Input extends SuperInput {
|
29
32
|
type: "text" | "search" | "tel" | "url" | "email" | "password" = "text";
|
@@ -44,7 +47,7 @@ class Input extends SuperInput {
|
|
44
47
|
<div
|
45
48
|
part="root"
|
46
49
|
${attr(this.observedRecord)}
|
47
|
-
class="${
|
50
|
+
class="${tokenList("input-field", this.variant)}"
|
48
51
|
>
|
49
52
|
${[
|
50
53
|
this._renderPrefix(),
|
@@ -68,9 +71,27 @@ class Input extends SuperInput {
|
|
68
71
|
`;
|
69
72
|
}
|
70
73
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
+
protected _renderSuffix(): TemplateResult<1> {
|
75
|
+
const PASSWORD = "password";
|
76
|
+
return html`
|
77
|
+
<label
|
78
|
+
for=${this.makeId}
|
79
|
+
part="suffix"
|
80
|
+
>
|
81
|
+
${this.type === PASSWORD
|
82
|
+
? html`
|
83
|
+
<i
|
84
|
+
part="icon"
|
85
|
+
@mousedown="${() => this._changeInputType("text")}"
|
86
|
+
@mouseup="${() => this._changeInputType(PASSWORD)}"
|
87
|
+
@mouseleave="${() => this._changeInputType(PASSWORD)}"
|
88
|
+
>
|
89
|
+
${iconEyeSlashFill()}
|
90
|
+
</i>
|
91
|
+
`
|
92
|
+
: htmlSlot("suffix")}
|
93
|
+
</label>
|
94
|
+
`;
|
74
95
|
}
|
75
96
|
}
|
76
97
|
|
package/src/components/link.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { godown } from "@godown/element";
|
2
2
|
import { property } from "lit/decorators.js";
|
3
3
|
|
4
|
-
import SuperAnchor from "../core/super-anchor.js";
|
4
|
+
import { SuperAnchor } from "../core/super-anchor.js";
|
5
5
|
import Router from "./router.js";
|
6
6
|
|
7
7
|
const protoName = "link";
|
@@ -92,13 +92,13 @@ class Link extends SuperAnchor {
|
|
92
92
|
handleState: () => void = () => {
|
93
93
|
switch (this.type) {
|
94
94
|
case linkTypes.auto:
|
95
|
-
// biome-ignore lint: if replace is true, fallthrough to replace case
|
96
95
|
case linkTypes.push:
|
97
96
|
if (!this.replace) {
|
98
97
|
// type is auto or push and replace is false
|
99
98
|
history.pushState(this.state, "", this.href);
|
100
99
|
break;
|
101
100
|
}
|
101
|
+
// fallthrough to replace
|
102
102
|
case linkTypes.replace:
|
103
103
|
history.replaceState(this.state, "", this.href);
|
104
104
|
break;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { attr, godown, isNil, styles } from "@godown/element";
|
1
|
+
import { attr, godown, isNil, Ranger, styles } from "@godown/element";
|
2
2
|
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
@@ -31,6 +31,7 @@ const protoName = "progress";
|
|
31
31
|
z-index: 1;
|
32
32
|
position: relative;
|
33
33
|
border-radius: inherit;
|
34
|
+
overflow: hidden;
|
34
35
|
}
|
35
36
|
|
36
37
|
[part="value"] {
|
@@ -72,12 +73,8 @@ class Progress extends GlobalStyle {
|
|
72
73
|
let width = 20;
|
73
74
|
let className: string;
|
74
75
|
if (!isNil(this.value)) {
|
75
|
-
|
76
|
-
|
77
|
-
width = 100;
|
78
|
-
} else if (width < 0) {
|
79
|
-
width = 0;
|
80
|
-
}
|
76
|
+
const ranger = new Ranger(this.min, this.max);
|
77
|
+
width = ranger.restrict(this.value / ranger.diff) * 100;
|
81
78
|
className = "static";
|
82
79
|
}
|
83
80
|
return html`
|
@@ -93,24 +90,6 @@ class Progress extends GlobalStyle {
|
|
93
90
|
</div>
|
94
91
|
`;
|
95
92
|
}
|
96
|
-
|
97
|
-
/**
|
98
|
-
* Convert s to a percentage without a percent sign.
|
99
|
-
*
|
100
|
-
* @param s String or number to convert.
|
101
|
-
* @returns Percentage without a percent sign.
|
102
|
-
*/
|
103
|
-
parsePercent(s: string | number = "0"): number {
|
104
|
-
s = String(s);
|
105
|
-
if (s.includes("%")) {
|
106
|
-
return parseFloat(s);
|
107
|
-
}
|
108
|
-
const diff = this.max - this.min;
|
109
|
-
if (diff === 0) {
|
110
|
-
return 100;
|
111
|
-
}
|
112
|
-
return (parseFloat(s) / diff) * 100;
|
113
|
-
}
|
114
93
|
}
|
115
94
|
|
116
95
|
export default Progress;
|