godown 3.0.0-canary.8 → 3.0.0-canary.9
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.js +1 -1
- package/components/avatar.d.ts +1 -0
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +3 -2
- package/components/avatar.js.map +1 -1
- package/components/breath.d.ts +1 -0
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +3 -2
- package/components/breath.js.map +1 -1
- package/components/button.d.ts +12 -6
- package/components/button.d.ts.map +1 -1
- package/components/button.js +14 -11
- package/components/button.js.map +1 -1
- package/components/card.d.ts +1 -2
- package/components/card.d.ts.map +1 -1
- package/components/card.js +5 -10
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts +5 -4
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +2 -1
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts +4 -1
- package/components/details.d.ts.map +1 -1
- package/components/details.js +4 -1
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +4 -1
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +5 -2
- package/components/dialog.js.map +1 -1
- package/components/dragbox.d.ts +7 -7
- package/components/dragbox.d.ts.map +1 -1
- package/components/dragbox.js +1 -1
- package/components/dragbox.js.map +1 -1
- package/components/flex.d.ts +1 -0
- package/components/flex.d.ts.map +1 -1
- package/components/flex.js +8 -0
- package/components/flex.js.map +1 -1
- package/components/form.d.ts +0 -2
- package/components/form.d.ts.map +1 -1
- package/components/form.js +0 -2
- package/components/form.js.map +1 -1
- package/components/grid.d.ts +7 -2
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js +1 -0
- package/components/grid.js.map +1 -1
- package/components/input.d.ts +2 -2
- package/components/input.d.ts.map +1 -1
- package/components/input.js +2 -2
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +2 -5
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +16 -4
- 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 +1 -10
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +5 -14
- package/components/progress.js.map +1 -1
- package/components/range.d.ts +12 -11
- package/components/range.d.ts.map +1 -1
- package/components/range.js +4 -11
- package/components/range.js.map +1 -1
- package/components/rotate.d.ts +1 -1
- package/components/rotate.d.ts.map +1 -1
- package/components/rotate.js +1 -1
- package/components/rotate.js.map +1 -1
- package/components/router.d.ts +6 -8
- package/components/router.d.ts.map +1 -1
- package/components/router.js +9 -9
- package/components/router.js.map +1 -1
- package/components/select.d.ts +1 -2
- package/components/select.d.ts.map +1 -1
- package/components/select.js +1 -2
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +2 -2
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +17 -0
- package/components/split.d.ts.map +1 -1
- package/components/split.js +42 -17
- package/components/split.js.map +1 -1
- package/components/switch.d.ts +3 -3
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +5 -5
- package/components/switch.js.map +1 -1
- package/components/text.js +2 -2
- package/components/time.d.ts +4 -4
- package/components/time.d.ts.map +1 -1
- package/components/time.js +1 -9
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +11 -1
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +19 -5
- package/components/tooltip.js.map +1 -1
- package/components/typewriter.d.ts +2 -2
- package/components/typewriter.d.ts.map +1 -1
- package/components/typewriter.js +2 -2
- package/components/typewriter.js.map +1 -1
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +8 -1
- package/core/global-style.js.map +1 -1
- package/core/super-anchor.js +1 -1
- package/core/super-input.d.ts +2 -2
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/avatar.d.ts +1 -0
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +1 -3
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/breath.d.ts +1 -0
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +1 -0
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +12 -6
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +18 -13
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +1 -2
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +21 -28
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +5 -4
- 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/details.d.ts +4 -1
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +3 -0
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +4 -1
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +4 -1
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/dragbox.d.ts +7 -7
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts +1 -0
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +8 -0
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts +0 -2
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +0 -2
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts +7 -2
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +1 -0
- package/dev/components/grid.js.map +1 -1
- package/dev/components/input.d.ts +2 -2
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +1 -1
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +2 -5
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +15 -3
- 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 +1 -10
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +3 -12
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +12 -11
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +3 -10
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +1 -1
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +6 -8
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +9 -9
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +1 -2
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +0 -1
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +17 -0
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +41 -16
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +3 -3
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +7 -7
- package/dev/components/switch.js.map +1 -1
- package/dev/components/time.d.ts +4 -4
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +1 -9
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +11 -1
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +28 -8
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts +2 -2
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +0 -1
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +8 -9
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-input.d.ts +2 -2
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js.map +1 -1
- package/index.js +13 -13
- package/package.json +1 -1
- package/src/components/avatar.ts +2 -3
- package/src/components/breath.ts +2 -0
- package/src/components/button.ts +26 -16
- package/src/components/card.ts +22 -27
- package/src/components/carousel.ts +7 -4
- package/src/components/details.ts +5 -1
- package/src/components/dialog.ts +6 -1
- package/src/components/dragbox.ts +8 -7
- package/src/components/flex.ts +6 -1
- package/src/components/form.ts +1 -2
- package/src/components/grid.ts +11 -2
- package/src/components/input.ts +3 -2
- package/src/components/layout.ts +6 -8
- package/src/components/link.ts +3 -1
- package/src/components/progress.ts +6 -12
- package/src/components/range.ts +15 -20
- package/src/components/rotate.ts +1 -1
- package/src/components/router.ts +18 -9
- package/src/components/select.ts +2 -2
- package/src/components/skeleton.ts +2 -0
- package/src/components/split.ts +48 -17
- package/src/components/switch.ts +12 -8
- package/src/components/time.ts +8 -4
- package/src/components/tooltip.ts +29 -8
- package/src/components/typewriter.ts +10 -3
- package/src/core/global-style.ts +9 -9
- package/src/core/super-input.ts +2 -2
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/src/components/layout.ts
CHANGED
@@ -13,11 +13,8 @@ const protoName = "layout";
|
|
13
13
|
* {@linkcode NavLayout} renders slot and optional top header, bottom footer.
|
14
14
|
*
|
15
15
|
* @slot - The main content of the layout.
|
16
|
-
*
|
17
16
|
* @slot header - The header of the layout.
|
18
|
-
*
|
19
17
|
* @slot footer - The footer of the layout.
|
20
|
-
*
|
21
18
|
* @category layout
|
22
19
|
*/
|
23
20
|
@godown(protoName)
|
@@ -50,21 +47,22 @@ const protoName = "layout";
|
|
50
47
|
)
|
51
48
|
class NavLayout extends GlobalStyle {
|
52
49
|
/**
|
53
|
-
* If true,
|
50
|
+
* If true, remove the header slot.
|
54
51
|
*/
|
55
52
|
@property({ type: Boolean })
|
56
|
-
noHeader
|
53
|
+
noHeader = false;
|
54
|
+
|
57
55
|
/**
|
58
|
-
* If true,
|
56
|
+
* If true, remove the footer slot.
|
59
57
|
*/
|
60
58
|
@property({ type: Boolean })
|
61
|
-
noFooter
|
59
|
+
noFooter = false;
|
62
60
|
|
63
61
|
/**
|
64
62
|
* If true, header will sticky.
|
65
63
|
*/
|
66
64
|
@property({ type: Boolean })
|
67
|
-
sticky
|
65
|
+
sticky = false;
|
68
66
|
|
69
67
|
protected render() {
|
70
68
|
return html`${
|
package/src/components/link.ts
CHANGED
@@ -19,7 +19,9 @@ class Link extends SuperAnchor {
|
|
19
19
|
/**
|
20
20
|
* If "push", call `history.pushState`.
|
21
21
|
*
|
22
|
-
* If "replace", call `history.replaceState
|
22
|
+
* If "replace", call `history.replaceState`.
|
23
|
+
*
|
24
|
+
* If "normal", behave like a normal anchor.
|
23
25
|
*/
|
24
26
|
@property()
|
25
27
|
type: "push" | "replace" | "normal" = "normal";
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { godown } from "@godown/element/decorators/godown.js";
|
2
2
|
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { isNil } from "@godown/element/tools/lib.js";
|
3
4
|
import { css, html } from "lit";
|
4
5
|
import { property } from "lit/decorators.js";
|
5
6
|
|
@@ -56,26 +57,19 @@ const protoName = "progress";
|
|
56
57
|
}
|
57
58
|
`)
|
58
59
|
class Progress extends GlobalStyle {
|
59
|
-
/**
|
60
|
-
* Maximum.
|
61
|
-
*/
|
62
60
|
@property({ type: Number })
|
63
61
|
max = 1;
|
64
|
-
|
65
|
-
* Minimum.
|
66
|
-
*/
|
62
|
+
|
67
63
|
@property({ type: Number })
|
68
64
|
min = 0;
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
@property({ type: Number, reflect: true })
|
73
|
-
value = null;
|
65
|
+
|
66
|
+
@property({ type: Number })
|
67
|
+
value: number;
|
74
68
|
|
75
69
|
protected render() {
|
76
70
|
let width = 20;
|
77
71
|
let className: string;
|
78
|
-
if (this.value
|
72
|
+
if (!isNil(this.value)) {
|
79
73
|
width = this.parsePercent(this.value);
|
80
74
|
className = "static";
|
81
75
|
}
|
package/src/components/range.ts
CHANGED
@@ -133,33 +133,36 @@ class Range extends SuperInput {
|
|
133
133
|
step: number;
|
134
134
|
|
135
135
|
/**
|
136
|
-
* Display vertically
|
136
|
+
* Display vertically.
|
137
137
|
*/
|
138
138
|
@property({ type: Boolean, reflect: true })
|
139
139
|
vertical: boolean;
|
140
140
|
|
141
141
|
/**
|
142
|
-
*
|
142
|
+
* Value, or each of values, will render a handle.
|
143
|
+
*
|
144
|
+
* Accepts number or array of numbers.
|
143
145
|
*/
|
144
146
|
@property({ type: Array })
|
145
147
|
value: number | number[];
|
148
|
+
|
146
149
|
/**
|
147
|
-
* The default of `this.value`.
|
150
|
+
* The default of `{@linkcode this.value}`.
|
148
151
|
*/
|
149
152
|
@property({ type: Array })
|
150
153
|
default: typeof this.value;
|
151
154
|
|
152
155
|
@part("root")
|
153
|
-
_root: HTMLElement;
|
156
|
+
protected _root: HTMLElement;
|
154
157
|
|
155
158
|
@queryAll("[part=handle]")
|
156
|
-
_handles: NodeListOf<HTMLElement>;
|
159
|
+
protected _handles: NodeListOf<HTMLElement>;
|
157
160
|
|
158
161
|
@state()
|
159
162
|
lastFocus?: number;
|
160
163
|
|
161
164
|
/**
|
162
|
-
* Returns true when the second number is greater than the first number
|
165
|
+
* Returns true when the second number is greater than the first number.
|
163
166
|
*/
|
164
167
|
get reverse() {
|
165
168
|
return this.range ? this.value[0] > this.value[1] : false;
|
@@ -279,8 +282,8 @@ class Range extends SuperInput {
|
|
279
282
|
};
|
280
283
|
}
|
281
284
|
|
282
|
-
createMouseDown(index) {
|
283
|
-
return (e) => {
|
285
|
+
createMouseDown(index: number) {
|
286
|
+
return (e: MouseEvent) => {
|
284
287
|
this.focusHandle(index);
|
285
288
|
this.createMousedownListener(this.createSetValue(index))(e);
|
286
289
|
};
|
@@ -292,7 +295,7 @@ class Range extends SuperInput {
|
|
292
295
|
this.focusHandle(0);
|
293
296
|
}
|
294
297
|
|
295
|
-
createSetValue(index
|
298
|
+
createSetValue(index: number) {
|
296
299
|
return (numberOrModifier: number | ((value: number) => number)) => {
|
297
300
|
const number = typeof numberOrModifier === "number"
|
298
301
|
? this.normalizeValue(numberOrModifier)
|
@@ -386,21 +389,13 @@ class Range extends SuperInput {
|
|
386
389
|
this.value = this.default;
|
387
390
|
}
|
388
391
|
|
389
|
-
swap() {
|
390
|
-
if (this.range) {
|
391
|
-
const [a, b] = this.value as [number, number];
|
392
|
-
this.value = [b, a];
|
393
|
-
}
|
394
|
-
}
|
395
|
-
|
396
392
|
sort() {
|
397
|
-
this.value = this.toSorted();
|
393
|
+
return this.value = this.toSorted();
|
398
394
|
}
|
399
395
|
|
400
|
-
toSorted()
|
396
|
+
toSorted() {
|
401
397
|
if (this.range) {
|
402
|
-
|
403
|
-
return a > b ? [b, a] : [a, b];
|
398
|
+
return [...this.value as number[]].sort((a, b) => a - b);
|
404
399
|
}
|
405
400
|
return this.value;
|
406
401
|
}
|
package/src/components/rotate.ts
CHANGED
package/src/components/router.ts
CHANGED
@@ -27,6 +27,8 @@ const protoName = "router";
|
|
27
27
|
*
|
28
28
|
* If no routes are matched, the default value (no named slot) will be rendered.
|
29
29
|
*
|
30
|
+
* @slot - Display slot when there is no match.
|
31
|
+
* @slot * - Matching slot will be displayed.
|
30
32
|
* @category navigation
|
31
33
|
*/
|
32
34
|
@godown(protoName)
|
@@ -50,31 +52,37 @@ class Router<C = unknown> extends GlobalStyle {
|
|
50
52
|
*/
|
51
53
|
@state()
|
52
54
|
component: C | TemplateResult = null;
|
55
|
+
|
53
56
|
/**
|
54
57
|
* Dynamic parameters record.
|
55
58
|
*/
|
56
59
|
@state()
|
57
60
|
params: Record<string, string> = {};
|
61
|
+
|
58
62
|
/**
|
59
63
|
* Value of matched path in routes.
|
60
64
|
*/
|
61
65
|
@state()
|
62
66
|
path: string;
|
67
|
+
|
63
68
|
/**
|
64
69
|
* Current pathname (equals to location.pathname).
|
65
70
|
*/
|
66
71
|
@property()
|
67
72
|
pathname = "";
|
73
|
+
|
68
74
|
/**
|
69
75
|
* Path prefix.
|
70
76
|
*/
|
71
77
|
@property()
|
72
78
|
baseURL = "";
|
79
|
+
|
73
80
|
/**
|
74
81
|
* Rendered content when there is no match.
|
75
82
|
*/
|
76
83
|
@state()
|
77
84
|
default: TemplateResult = htmlSlot();
|
85
|
+
|
78
86
|
/**
|
79
87
|
* The type of routing sources.
|
80
88
|
*
|
@@ -84,6 +92,7 @@ class Router<C = unknown> extends GlobalStyle {
|
|
84
92
|
*/
|
85
93
|
@property()
|
86
94
|
type: "united" | "slotted" | "field" = "united";
|
95
|
+
|
87
96
|
/**
|
88
97
|
* Cache accessed records.
|
89
98
|
*
|
@@ -97,6 +106,7 @@ class Router<C = unknown> extends GlobalStyle {
|
|
97
106
|
this.__routes = value;
|
98
107
|
this.collectFieldRoutes(value);
|
99
108
|
}
|
109
|
+
|
100
110
|
get routes() {
|
101
111
|
return this.__routes;
|
102
112
|
}
|
@@ -158,8 +168,7 @@ class Router<C = unknown> extends GlobalStyle {
|
|
158
168
|
}
|
159
169
|
|
160
170
|
/**
|
161
|
-
*
|
162
|
-
* @param first whether this path is loaded for the first time.
|
171
|
+
* Callback function when the route changes.
|
163
172
|
*/
|
164
173
|
routeChangeCallback: (params: {
|
165
174
|
pathname: string;
|
@@ -182,9 +191,7 @@ class Router<C = unknown> extends GlobalStyle {
|
|
182
191
|
}
|
183
192
|
|
184
193
|
/**
|
185
|
-
*
|
186
|
-
* @param query Query string.
|
187
|
-
* @returns Components or null.
|
194
|
+
* Get component from {@linkcode routes} by query.
|
188
195
|
*/
|
189
196
|
fieldComponent(query?: string) {
|
190
197
|
query ||= this.useWhich(this.pathname);
|
@@ -203,9 +210,7 @@ class Router<C = unknown> extends GlobalStyle {
|
|
203
210
|
}
|
204
211
|
|
205
212
|
/**
|
206
|
-
*
|
207
|
-
* @param query Query string.
|
208
|
-
* @returns Named slot element template result or null.
|
213
|
+
* Get component from slotted elements by query.
|
209
214
|
*/
|
210
215
|
slottedComponent(usedRouteTemplate?: string) {
|
211
216
|
const slottedPaths = this._slottedNames;
|
@@ -256,9 +261,13 @@ class Router<C = unknown> extends GlobalStyle {
|
|
256
261
|
|
257
262
|
static updateAll() {
|
258
263
|
this.routerInstances.forEach((i) => {
|
259
|
-
i.
|
264
|
+
i.handlePopstate();
|
260
265
|
});
|
261
266
|
}
|
267
|
+
|
268
|
+
handlePopstate = this.events.add(window, "popstate", () => {
|
269
|
+
this.pathname = location.pathname;
|
270
|
+
}) as () => void;
|
262
271
|
}
|
263
272
|
|
264
273
|
export default Router;
|
package/src/components/select.ts
CHANGED
@@ -69,7 +69,6 @@ const protoName = "select";
|
|
69
69
|
`,
|
70
70
|
)
|
71
71
|
class Select extends Input {
|
72
|
-
_cache = new WeakMap<HTMLElement, boolean>();
|
73
72
|
// @ts-ignore
|
74
73
|
value: string | string[];
|
75
74
|
|
@@ -80,7 +79,7 @@ class Select extends Input {
|
|
80
79
|
text: string;
|
81
80
|
|
82
81
|
@part("content")
|
83
|
-
_content: HTMLElement;
|
82
|
+
protected _content: HTMLElement;
|
84
83
|
|
85
84
|
@property()
|
86
85
|
direction: "top" | "bottom" | undefined;
|
@@ -93,6 +92,7 @@ class Select extends Input {
|
|
93
92
|
|
94
93
|
@state()
|
95
94
|
protected autoDirection: "top" | "bottom" = "bottom";
|
95
|
+
|
96
96
|
protected lastChecked: HTMLElement;
|
97
97
|
protected defaultText: string;
|
98
98
|
protected defaultChecked: HTMLElement[];
|
@@ -91,12 +91,14 @@ class Skeleton extends GlobalStyle {
|
|
91
91
|
*/
|
92
92
|
@property()
|
93
93
|
type: "text" | "image";
|
94
|
+
|
94
95
|
/**
|
95
96
|
* Animation type.
|
96
97
|
* opacity animation only effect on slotted element and image icon.
|
97
98
|
*/
|
98
99
|
@property()
|
99
100
|
animation: "position" | "opacity" = "position";
|
101
|
+
|
100
102
|
/**
|
101
103
|
* If false, render slot only.
|
102
104
|
*/
|
package/src/components/split.ts
CHANGED
@@ -79,6 +79,7 @@ class Split extends SuperInput {
|
|
79
79
|
*/
|
80
80
|
@property({ type: Number })
|
81
81
|
len = 6;
|
82
|
+
|
82
83
|
/**
|
83
84
|
* Focus index.
|
84
85
|
*/
|
@@ -87,6 +88,7 @@ class Split extends SuperInput {
|
|
87
88
|
|
88
89
|
@state()
|
89
90
|
current = -1;
|
91
|
+
|
90
92
|
@state()
|
91
93
|
currentValue: (string | void)[] = [];
|
92
94
|
|
@@ -123,7 +125,32 @@ class Split extends SuperInput {
|
|
123
125
|
if (this.compositing) {
|
124
126
|
return;
|
125
127
|
}
|
126
|
-
|
128
|
+
|
129
|
+
this.fillInput(e.data);
|
130
|
+
this.value = this.currentValue.join("");
|
131
|
+
|
132
|
+
this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true, composed: true }));
|
133
|
+
this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Fill input with data.
|
138
|
+
*
|
139
|
+
* If data is null
|
140
|
+
* - If current value is null, move to before.
|
141
|
+
* - If current value is not null, delete it.
|
142
|
+
*
|
143
|
+
* If data is not null
|
144
|
+
* - If current value is null, input data.
|
145
|
+
* - If current value is not null, input data and move to after.
|
146
|
+
*
|
147
|
+
* If data is multiple characters,
|
148
|
+
* Fill input with data[0] and call fillInput with data.slice(1).
|
149
|
+
*
|
150
|
+
* @param data Input event data.
|
151
|
+
*/
|
152
|
+
protected fillInput(data: string | null) {
|
153
|
+
if (data === null) {
|
127
154
|
// delete
|
128
155
|
|
129
156
|
if (this.currentValue[this.current] !== null) {
|
@@ -137,28 +164,32 @@ class Split extends SuperInput {
|
|
137
164
|
const lastNotNull = this.currentValue.findLastIndex(a => a !== null);
|
138
165
|
this.current = this.current - 1 < 0 ? lastNotNull < 0 ? 0 : lastNotNull : this.current - 1;
|
139
166
|
}
|
140
|
-
|
141
|
-
|
167
|
+
return;
|
168
|
+
}
|
142
169
|
|
143
|
-
|
144
|
-
if (this.current + 1 >= this.len) {
|
145
|
-
// index overflow
|
170
|
+
const multiple = data.length > 1;
|
146
171
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
} else {
|
152
|
-
// go to after
|
172
|
+
// input
|
173
|
+
this.currentValue[this.current] = data[0];
|
174
|
+
if (this.current + 1 >= this.len) {
|
175
|
+
// index overflow
|
153
176
|
|
154
|
-
|
177
|
+
this.current = this.currentValue.indexOf(null);
|
178
|
+
if (this.current === -1) {
|
179
|
+
this.blur();
|
155
180
|
}
|
156
|
-
}
|
181
|
+
} else {
|
182
|
+
// go to after
|
157
183
|
|
158
|
-
|
184
|
+
this.current += 1;
|
185
|
+
}
|
159
186
|
|
160
|
-
|
161
|
-
|
187
|
+
if (multiple) {
|
188
|
+
const after = data.slice(1);
|
189
|
+
if (after) {
|
190
|
+
this.fillInput(after);
|
191
|
+
}
|
192
|
+
}
|
162
193
|
}
|
163
194
|
|
164
195
|
focus() {
|
package/src/components/switch.ts
CHANGED
@@ -24,6 +24,7 @@ const cssScope = scopePrefix(protoName);
|
|
24
24
|
${cssScope}-width: 3em;
|
25
25
|
${cssScope}-height: calc(var(${cssScope}-width) / 2);
|
26
26
|
${cssScope}-handle-size: 1.25em;
|
27
|
+
${cssScope}-handle-space: .125em;
|
27
28
|
${cssScope}-transition: .2s ease-in-out;
|
28
29
|
background: var(${cssGlobalVars.input}-background);
|
29
30
|
width: var(${cssScope}-width);
|
@@ -72,7 +73,7 @@ const cssScope = scopePrefix(protoName);
|
|
72
73
|
}
|
73
74
|
|
74
75
|
:host([checked]) span {
|
75
|
-
|
76
|
+
left: 50%;
|
76
77
|
}
|
77
78
|
|
78
79
|
.rect .true {
|
@@ -83,13 +84,13 @@ const cssScope = scopePrefix(protoName);
|
|
83
84
|
background: var(${cssGlobalVars.passive});
|
84
85
|
}
|
85
86
|
|
86
|
-
.round span
|
87
|
+
.round span{
|
87
88
|
--size: var(${cssScope}-handle-size);
|
88
|
-
content:"";
|
89
89
|
border-radius: 100%;
|
90
90
|
background: var(--godown--input-control);
|
91
91
|
width: var(--size);
|
92
92
|
height: var(--size);
|
93
|
+
margin: var(${cssScope}-handle-space);
|
93
94
|
}
|
94
95
|
|
95
96
|
.round {
|
@@ -107,21 +108,25 @@ class Switch extends SuperInput {
|
|
107
108
|
*/
|
108
109
|
@property({ type: Boolean, reflect: true })
|
109
110
|
round = false;
|
111
|
+
|
110
112
|
/**
|
111
113
|
* Whether this element is selected or not.
|
112
114
|
*/
|
113
115
|
@property({ type: Boolean, reflect: true })
|
114
116
|
checked = false;
|
117
|
+
|
115
118
|
/**
|
116
|
-
*
|
119
|
+
* Disable this element.
|
117
120
|
*/
|
118
121
|
@property({ type: Boolean, reflect: true })
|
119
122
|
disabled = false;
|
123
|
+
|
120
124
|
/**
|
121
|
-
*
|
125
|
+
* Default checked state.
|
122
126
|
*/
|
123
127
|
@property()
|
124
128
|
default = "false";
|
129
|
+
|
125
130
|
/**
|
126
131
|
* Input value.
|
127
132
|
*/
|
@@ -129,7 +134,7 @@ class Switch extends SuperInput {
|
|
129
134
|
value = "on";
|
130
135
|
|
131
136
|
@query("input")
|
132
|
-
_input: HTMLInputElement;
|
137
|
+
protected _input: HTMLInputElement;
|
133
138
|
|
134
139
|
protected render() {
|
135
140
|
return html`<div part="root" class="${this.round ? "round" : "rect"}">
|
@@ -142,8 +147,7 @@ class Switch extends SuperInput {
|
|
142
147
|
id="${this.makeId}"
|
143
148
|
type="checkbox"
|
144
149
|
>
|
145
|
-
<span class="${this.checked}">
|
146
|
-
</span>
|
150
|
+
<span part="handle" class="${this.checked}"></span>
|
147
151
|
</div>`;
|
148
152
|
}
|
149
153
|
|
package/src/components/time.ts
CHANGED
@@ -17,32 +17,36 @@ const protoName = "time";
|
|
17
17
|
@styles(css`:host{text-align: center;}`)
|
18
18
|
class Time extends GlobalStyle {
|
19
19
|
/**
|
20
|
-
*
|
20
|
+
* Escape symbol.
|
21
21
|
*/
|
22
22
|
@property()
|
23
23
|
escape = "%";
|
24
|
+
|
24
25
|
/**
|
25
26
|
* Format strings.
|
26
27
|
*/
|
27
28
|
@property()
|
28
29
|
format = "YYYY-MM-DD hh:mm:ss UTFZ";
|
30
|
+
|
29
31
|
/**
|
30
32
|
* Time.
|
31
33
|
*/
|
32
34
|
@property({ type: Object })
|
33
35
|
time = new Date();
|
36
|
+
|
34
37
|
/**
|
35
38
|
* If there is a value, update every gap or timeout.
|
36
39
|
*/
|
37
40
|
@property({ type: Number })
|
38
|
-
timeout
|
41
|
+
timeout;
|
42
|
+
|
39
43
|
/**
|
40
44
|
* The number of milliseconds that change with each update.
|
41
45
|
*/
|
42
46
|
@property({ type: Number })
|
43
|
-
gap
|
47
|
+
gap;
|
44
48
|
|
45
|
-
timeoutId: number;
|
49
|
+
protected timeoutId: number;
|
46
50
|
|
47
51
|
protected render(): string {
|
48
52
|
return fmtime(this.format, this.time, this.escape);
|
@@ -4,7 +4,7 @@ import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
|
4
4
|
import { css, html } from "lit";
|
5
5
|
import { property } from "lit/decorators.js";
|
6
6
|
|
7
|
-
import {
|
7
|
+
import { scopePrefix } from "../core/global-style.js";
|
8
8
|
import SuperOpenable, { type Direction8 } from "../core/super-openable.js";
|
9
9
|
|
10
10
|
const protoName = "tooltip";
|
@@ -15,7 +15,7 @@ const cssScope = scopePrefix(protoName);
|
|
15
15
|
*
|
16
16
|
* If it has the tip property, ignore the slot tip.
|
17
17
|
*
|
18
|
-
* @slot tip - Tip element.
|
18
|
+
* @slot tip - Tip element if no `tim` provided.
|
19
19
|
* @slot - Content.
|
20
20
|
* @category feedback
|
21
21
|
*/
|
@@ -23,7 +23,7 @@ const cssScope = scopePrefix(protoName);
|
|
23
23
|
@styles(
|
24
24
|
css`
|
25
25
|
:host {
|
26
|
-
${cssScope}--tip-background:
|
26
|
+
${cssScope}--tip-background: inherit;
|
27
27
|
display: inline-block;
|
28
28
|
width: fit-content;
|
29
29
|
}
|
@@ -44,9 +44,7 @@ const cssScope = scopePrefix(protoName);
|
|
44
44
|
user-select: none;
|
45
45
|
}
|
46
46
|
|
47
|
-
:host([open]) [part="tip"]
|
48
|
-
:host(:hover) [part="tip"],
|
49
|
-
[part="tip"]:hover {
|
47
|
+
:host([open]) [part="tip"] {
|
50
48
|
visibility: visible;
|
51
49
|
}
|
52
50
|
|
@@ -76,11 +74,13 @@ class Tooltip extends SuperOpenable {
|
|
76
74
|
*/
|
77
75
|
@property()
|
78
76
|
tip: string;
|
77
|
+
|
79
78
|
/**
|
80
79
|
* Direction of opening the tip.
|
81
80
|
*/
|
82
81
|
@property()
|
83
82
|
direction: Direction8 = "top";
|
83
|
+
|
84
84
|
/**
|
85
85
|
* Content alignment.
|
86
86
|
*/
|
@@ -93,6 +93,18 @@ class Tooltip extends SuperOpenable {
|
|
93
93
|
@property({ type: Boolean })
|
94
94
|
propagation: boolean;
|
95
95
|
|
96
|
+
/**
|
97
|
+
* How can tips be triggered.
|
98
|
+
*
|
99
|
+
* If `focus`, element will be focusable, open tip when focused.
|
100
|
+
*
|
101
|
+
* If `hover`, element will open tip when hovered.
|
102
|
+
*
|
103
|
+
* @default "hover"
|
104
|
+
*/
|
105
|
+
@property()
|
106
|
+
type: "hover" | "focus" = "hover";
|
107
|
+
|
96
108
|
static aligns = {
|
97
109
|
start: "flex-start",
|
98
110
|
end: "flex-end",
|
@@ -103,9 +115,18 @@ class Tooltip extends SuperOpenable {
|
|
103
115
|
|
104
116
|
protected render() {
|
105
117
|
const align = Tooltip.aligns[this.align] || "inherit";
|
106
|
-
|
118
|
+
const isFocusable = this.type === "focus";
|
119
|
+
return html`<div part="root"
|
120
|
+
tabindex="${isFocusable ? 0 : -1}"
|
121
|
+
@focus="${isFocusable ? () => this.open = true : null}"
|
122
|
+
@blur="${isFocusable ? () => this.open = false : null}"
|
123
|
+
@mouseenter="${isFocusable ? null : () => this.open = true}"
|
124
|
+
@mouseleave="${isFocusable ? null : () => this.open = false}"
|
125
|
+
style="justify-content:${align};align-items:${align}">
|
107
126
|
${htmlSlot()}
|
108
|
-
<div part="tip"
|
127
|
+
<div part="tip"
|
128
|
+
direction="${this.direction}"
|
129
|
+
style="pointer-events:${this.propagation ? "none" : "all"}">
|
109
130
|
${
|
110
131
|
this.tip
|
111
132
|
? html`<span class="passive">${this.tip}</span>`
|