godown 3.0.0-canary.1 → 3.0.0-canary.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -9
- package/components/alert.d.ts +6 -3
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +22 -14
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts +7 -2
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +13 -6
- package/components/avatar.js.map +1 -1
- package/components/breath.d.ts +4 -2
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +8 -6
- package/components/breath.js.map +1 -1
- package/components/button.d.ts +20 -11
- package/components/button.d.ts.map +1 -1
- package/components/button.js +23 -20
- package/components/button.js.map +1 -1
- package/components/card.d.ts +2 -2
- package/components/card.d.ts.map +1 -1
- package/components/card.js +8 -13
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts +8 -5
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +18 -11
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts +7 -3
- package/components/details.d.ts.map +1 -1
- package/components/details.js +7 -3
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +9 -5
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +20 -14
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts +3 -4
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +6 -7
- package/components/divider.js.map +1 -1
- package/components/dragbox.d.ts +9 -8
- package/components/dragbox.d.ts.map +1 -1
- package/components/dragbox.js +3 -2
- package/components/dragbox.js.map +1 -1
- package/components/flex.d.ts +3 -1
- package/components/flex.d.ts.map +1 -1
- package/components/flex.js +13 -4
- package/components/flex.js.map +1 -1
- package/components/form.d.ts +2 -3
- package/components/form.d.ts.map +1 -1
- package/components/form.js +0 -2
- package/components/form.js.map +1 -1
- package/components/grid.d.ts +9 -3
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js +6 -4
- package/components/grid.js.map +1 -1
- package/components/input.d.ts +4 -4
- package/components/input.d.ts.map +1 -1
- package/components/input.js +5 -7
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +4 -6
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +23 -12
- package/components/layout.js.map +1 -1
- package/components/link.d.ts +3 -1
- package/components/link.d.ts.map +1 -1
- package/components/link.js +3 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts +4 -12
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +9 -17
- package/components/progress.js.map +1 -1
- package/components/range.d.ts +45 -18
- package/components/range.d.ts.map +1 -1
- package/components/range.js +133 -62
- package/components/range.js.map +1 -1
- package/components/rotate.d.ts +3 -2
- package/components/rotate.d.ts.map +1 -1
- package/components/rotate.js +1 -1
- package/components/rotate.js.map +1 -1
- package/components/router.d.ts +15 -17
- package/components/router.d.ts.map +1 -1
- package/components/router.js +10 -10
- package/components/router.js.map +1 -1
- package/components/select.d.ts +6 -9
- package/components/select.d.ts.map +1 -1
- package/components/select.js +48 -43
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts +2 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +5 -5
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +20 -2
- package/components/split.d.ts.map +1 -1
- package/components/split.js +54 -20
- package/components/split.js.map +1 -1
- package/components/switch.d.ts +6 -5
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +7 -6
- package/components/switch.js.map +1 -1
- package/components/text.d.ts +2 -1
- package/components/text.d.ts.map +1 -1
- package/components/text.js +5 -6
- package/components/text.js.map +1 -1
- package/components/time.d.ts +6 -22
- package/components/time.d.ts.map +1 -1
- package/components/time.js +7 -67
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +13 -2
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +24 -5
- package/components/tooltip.js.map +1 -1
- package/components/typewriter.d.ts +4 -4
- package/components/typewriter.d.ts.map +1 -1
- package/components/typewriter.js +4 -5
- package/components/typewriter.js.map +1 -1
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +9 -2
- package/core/global-style.js.map +1 -1
- package/core/super-anchor.d.ts +2 -1
- package/core/super-anchor.d.ts.map +1 -1
- package/core/super-anchor.js +4 -3
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +5 -5
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +3 -6
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts.map +1 -1
- package/core/super-openable.js +1 -1
- package/core/super-openable.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts +6 -3
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +38 -25
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts +7 -2
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +28 -13
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/breath.d.ts +4 -2
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +20 -6
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +20 -11
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +34 -25
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +2 -2
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +25 -30
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +8 -5
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +35 -20
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +7 -3
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +12 -4
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +9 -5
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +30 -24
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts +3 -4
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +20 -8
- package/dev/components/divider.js.map +1 -1
- package/dev/components/dragbox.d.ts +9 -8
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js +8 -1
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts +3 -1
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +24 -4
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts +2 -3
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +0 -2
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts +9 -3
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +17 -4
- package/dev/components/grid.js.map +1 -1
- package/dev/components/input.d.ts +4 -4
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +3 -21
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +4 -6
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +33 -13
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.d.ts +3 -1
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +3 -1
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +4 -12
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +14 -18
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +45 -18
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +164 -109
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +3 -2
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +1 -1
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +15 -17
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +10 -10
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +6 -9
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +58 -45
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts +2 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +6 -6
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +20 -2
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +69 -32
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +6 -5
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +23 -20
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.d.ts +2 -1
- package/dev/components/text.d.ts.map +1 -1
- package/dev/components/text.js +7 -7
- package/dev/components/text.js.map +1 -1
- package/dev/components/time.d.ts +6 -22
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +9 -67
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +13 -2
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +55 -20
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts +4 -4
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +11 -5
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +18 -10
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-anchor.d.ts +2 -1
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +8 -5
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +5 -5
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +21 -20
- package/dev/core/super-input.js.map +1 -1
- package/dev/core/super-openable.d.ts.map +1 -1
- package/dev/core/super-openable.js +1 -1
- package/dev/core/super-openable.js.map +1 -1
- package/dev/range.d.ts +1 -1
- package/dev/range.d.ts.map +1 -1
- package/index.js +13 -13
- package/package.json +11 -8
- package/range.d.ts +1 -1
- package/range.d.ts.map +1 -1
- package/src/alert.ts +11 -0
- package/src/avatar.ts +11 -0
- package/src/breath.ts +13 -0
- package/src/button.ts +11 -0
- package/src/card.ts +11 -0
- package/src/carousel.ts +11 -0
- package/src/components/alert.ts +284 -0
- package/src/components/avatar.ts +109 -0
- package/src/components/breath.ts +165 -0
- package/src/components/button.ts +292 -0
- package/src/components/card.ts +83 -0
- package/src/components/carousel.ts +183 -0
- package/src/components/details.ts +121 -0
- package/src/components/dialog.ts +166 -0
- package/src/components/divider.ts +56 -0
- package/src/components/dragbox.ts +134 -0
- package/src/components/flex.ts +82 -0
- package/src/components/form.ts +82 -0
- package/src/components/grid.ts +87 -0
- package/src/components/input.ts +73 -0
- package/src/components/layout.ts +89 -0
- package/src/components/link.ts +38 -0
- package/src/components/progress.ts +100 -0
- package/src/components/range.ts +399 -0
- package/src/components/rotate.ts +95 -0
- package/src/components/router.ts +281 -0
- package/src/components/select.ts +281 -0
- package/src/components/skeleton.ts +119 -0
- package/src/components/split.ts +225 -0
- package/src/components/switch.ts +184 -0
- package/src/components/text.ts +93 -0
- package/src/components/time.ts +84 -0
- package/src/components/tooltip.ts +150 -0
- package/src/components/typewriter.ts +159 -0
- package/src/core/global-style.ts +105 -0
- package/src/core/super-anchor.ts +55 -0
- package/src/core/super-input.ts +230 -0
- package/src/core/super-openable.ts +51 -0
- package/src/details.ts +11 -0
- package/src/dialog.ts +11 -0
- package/src/divider.ts +11 -0
- package/src/dragbox.ts +11 -0
- package/src/flex.ts +11 -0
- package/src/form.ts +11 -0
- package/src/grid.ts +11 -0
- package/src/index.ts +28 -0
- package/src/input.ts +13 -0
- package/src/layout.ts +12 -0
- package/src/link.ts +13 -0
- package/src/progress.ts +12 -0
- package/src/range.ts +13 -0
- package/src/rotate.ts +13 -0
- package/src/router.ts +12 -0
- package/src/select.ts +13 -0
- package/src/skeleton.ts +13 -0
- package/src/split.ts +13 -0
- package/src/switch.ts +13 -0
- package/src/text.ts +13 -0
- package/src/time.ts +13 -0
- package/src/tooltip.ts +13 -0
- package/src/typewriter.ts +11 -0
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/dev/components/split.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
2
|
import { godown } from "@godown/element/decorators/godown.js";
|
3
3
|
import { styles } from "@godown/element/decorators/styles.js";
|
4
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
5
|
import { classList } from "@godown/element/directives/class-list.js";
|
5
6
|
import { css, html, nothing } from "lit";
|
6
7
|
import { property, state } from "lit/decorators.js";
|
@@ -8,6 +9,13 @@ import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
|
8
9
|
import SuperInput from "../core/super-input.js";
|
9
10
|
const protoName = "split";
|
10
11
|
const cssScope = scopePrefix(protoName);
|
12
|
+
const loop = (len, fn) => {
|
13
|
+
const result = new Array(len);
|
14
|
+
for (let index = 0; index < len; index++) {
|
15
|
+
result[index] = fn(index);
|
16
|
+
}
|
17
|
+
return result;
|
18
|
+
};
|
11
19
|
/**
|
12
20
|
* {@linkcode Split} renders multiple input boxes.
|
13
21
|
*
|
@@ -32,23 +40,21 @@ let Split = class Split extends SuperInput {
|
|
32
40
|
this.currentValue = [];
|
33
41
|
}
|
34
42
|
render() {
|
35
|
-
return html
|
36
|
-
|
37
|
-
${this.currentValue
|
38
|
-
.map((value, index) => html `<span part="input-box"
|
43
|
+
return html `<div part="root" ${attr(this.observedRecord)}>
|
44
|
+
${loop(this.len, (index) => html `<span part="input-box"
|
39
45
|
@click="${this.disabled ? null : () => this.focusAt(index)}"
|
40
46
|
class="${classList({ focus: this.current === index }) || nothing}"
|
41
|
-
>${
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
>${this.currentValue[index]}</span>`)}
|
48
|
+
<input
|
49
|
+
part="input"
|
50
|
+
id="${this.makeId}"
|
51
|
+
@blur=${this.blur}
|
52
|
+
@input="${this._handleInput}"
|
53
|
+
.value="${
|
48
54
|
/* Ensure that input always has a value of length this.len */
|
49
55
|
this.value.padStart(this.len, " ")}"
|
50
|
-
|
51
|
-
|
56
|
+
>
|
57
|
+
</div>
|
52
58
|
`;
|
53
59
|
}
|
54
60
|
connectedCallback() {
|
@@ -60,7 +66,29 @@ let Split = class Split extends SuperInput {
|
|
60
66
|
if (this.compositing) {
|
61
67
|
return;
|
62
68
|
}
|
63
|
-
|
69
|
+
this.fillInput(e.data);
|
70
|
+
this.value = this.currentValue.join("");
|
71
|
+
this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true, composed: true }));
|
72
|
+
this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
|
73
|
+
}
|
74
|
+
/**
|
75
|
+
* Fill input with data.
|
76
|
+
*
|
77
|
+
* If data is null
|
78
|
+
* - If current value is null, move to before.
|
79
|
+
* - If current value is not null, delete it.
|
80
|
+
*
|
81
|
+
* If data is not null
|
82
|
+
* - If current value is null, input data.
|
83
|
+
* - If current value is not null, input data and move to after.
|
84
|
+
*
|
85
|
+
* If data is multiple characters,
|
86
|
+
* Fill input with data[0] and call fillInput with data.slice(1).
|
87
|
+
*
|
88
|
+
* @param data Input event data.
|
89
|
+
*/
|
90
|
+
fillInput(data) {
|
91
|
+
if (data === null) {
|
64
92
|
// delete
|
65
93
|
if (this.currentValue[this.current] !== null) {
|
66
94
|
// delete exist value
|
@@ -72,28 +100,32 @@ let Split = class Split extends SuperInput {
|
|
72
100
|
const lastNotNull = this.currentValue.findLastIndex(a => a !== null);
|
73
101
|
this.current = this.current - 1 < 0 ? lastNotNull < 0 ? 0 : lastNotNull : this.current - 1;
|
74
102
|
}
|
103
|
+
return;
|
75
104
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
}
|
105
|
+
const multiple = data.length > 1;
|
106
|
+
// input
|
107
|
+
this.currentValue[this.current] = data[0];
|
108
|
+
if (this.current + 1 >= this.len) {
|
109
|
+
// index overflow
|
110
|
+
this.current = this.currentValue.indexOf(null);
|
111
|
+
if (this.current === -1) {
|
112
|
+
this.blur();
|
85
113
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
114
|
+
}
|
115
|
+
else {
|
116
|
+
// go to after
|
117
|
+
this.current += 1;
|
118
|
+
}
|
119
|
+
if (multiple) {
|
120
|
+
const after = data.slice(1);
|
121
|
+
if (after) {
|
122
|
+
this.fillInput(after);
|
89
123
|
}
|
90
124
|
}
|
91
|
-
this.value = this.currentValue.join("");
|
92
|
-
this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true, composed: true }));
|
93
|
-
this.dispatchEvent(new CustomEvent("change", { detail: this.value, composed: true }));
|
94
125
|
}
|
95
126
|
focus() {
|
96
127
|
this.focusAt(this.current);
|
128
|
+
super.focus();
|
97
129
|
}
|
98
130
|
focusAt(i) {
|
99
131
|
this.current = i;
|
@@ -102,6 +134,7 @@ let Split = class Split extends SuperInput {
|
|
102
134
|
blur() {
|
103
135
|
this._input.blur();
|
104
136
|
this.current = -1;
|
137
|
+
super.blur();
|
105
138
|
}
|
106
139
|
reset() {
|
107
140
|
this.current = -1;
|
@@ -136,7 +169,11 @@ Split = __decorate([
|
|
136
169
|
${cssScope}--gap: .25em;
|
137
170
|
}
|
138
171
|
|
139
|
-
[part=
|
172
|
+
:host([contents]) [part=root] {
|
173
|
+
width: fit-content;
|
174
|
+
}
|
175
|
+
|
176
|
+
[part=root] {
|
140
177
|
gap: var(${cssScope}--gap);
|
141
178
|
width: 100%;
|
142
179
|
position: relative;
|
@@ -146,7 +183,7 @@ Split = __decorate([
|
|
146
183
|
border-radius: inherit;
|
147
184
|
}
|
148
185
|
|
149
|
-
[part=
|
186
|
+
[part=input-box] {
|
150
187
|
width: var(${cssScope}--size);
|
151
188
|
height: var(${cssScope}--size);
|
152
189
|
vertical-align: top;
|
@@ -155,7 +192,7 @@ Split = __decorate([
|
|
155
192
|
border-radius: inherit;
|
156
193
|
}
|
157
194
|
|
158
|
-
[part=
|
195
|
+
[part=input] {
|
159
196
|
width: 100%;
|
160
197
|
height: 100%;
|
161
198
|
opacity: 0;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../src/components/split.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,
|
1
|
+
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../src/components/split.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,MAAM,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAExC,MAAM,IAAI,GAAG,CAAI,GAAW,EAAE,EAAyB,EAAE,EAAE;IACzD,MAAM,MAAM,GAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CA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AC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChG,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,CAAC;IACH,CAAC;CACF,CAAA;AAzIC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kCACnB;AAMR;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAChB;AAGX;IADC,KAAK,EAAE;sCACK;AAGb;IADC,KAAK,EAAE;2CAC6B;AAjBjC,KAAK;IAjDV,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CACL,GAAG,CAAA;;mBAEc,aAAa,CAAC,UAAU;;;;QAInC,QAAQ;QACR,QAAQ;;;;;;;;iBAQC,QAAQ;;;;;;;;;;mBAUN,QAAQ;oBACP,QAAQ;;;8BAGE,aAAa,CAAC,KAAK;;;;;;;;;;;;;;wBAczB,aAAa,CAAC,KAAK;;GAExC,CACF;GACK,KAAK,CA8IV;AAED,eAAe,KAAK,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type TemplateResult } from "lit";
|
1
2
|
import SuperInput from "../core/super-input.js";
|
2
3
|
/**
|
3
4
|
* {@linkcode Switch} renders a switch.
|
@@ -9,7 +10,7 @@ import SuperInput from "../core/super-input.js";
|
|
9
10
|
*/
|
10
11
|
declare class Switch extends SuperInput {
|
11
12
|
/**
|
12
|
-
*
|
13
|
+
* Display rounded.
|
13
14
|
*/
|
14
15
|
round: boolean;
|
15
16
|
/**
|
@@ -17,19 +18,19 @@ declare class Switch extends SuperInput {
|
|
17
18
|
*/
|
18
19
|
checked: boolean;
|
19
20
|
/**
|
20
|
-
*
|
21
|
+
* Disable this element.
|
21
22
|
*/
|
22
23
|
disabled: boolean;
|
23
24
|
/**
|
24
|
-
*
|
25
|
+
* Default checked state.
|
25
26
|
*/
|
26
27
|
default: string;
|
27
28
|
/**
|
28
29
|
* Input value.
|
29
30
|
*/
|
30
31
|
value: string;
|
31
|
-
_input: HTMLInputElement;
|
32
|
-
protected render():
|
32
|
+
protected _input: HTMLInputElement;
|
33
|
+
protected render(): TemplateResult<1>;
|
33
34
|
reset(): void;
|
34
35
|
connectedCallback(): void;
|
35
36
|
protected _handleChange(): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/components/switch.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/components/switch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAIrD,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAKhD;;;;;;;GAOG;AACH,cAqFM,MAAO,SAAQ,UAAU;IAC7B;;OAEG;IAEH,KAAK,UAAS;IAEd;;OAEG;IAEH,OAAO,UAAS;IAEhB;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;OAEG;IAEH,OAAO,SAAW;IAElB;;OAEG;IAEH,KAAK,SAAQ;IAGb,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAEnC,SAAS,CAAC,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;IAkBrC,KAAK,IAAI,IAAI;IAKb,iBAAiB,IAAI,IAAI;IAUzB,SAAS,CAAC,aAAa,IAAI,IAAI;IAM/B,SAAS,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;CAG/B;AAED,eAAe,MAAM,CAAC"}
|
package/dev/components/switch.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
2
|
import { godown } from "@godown/element/decorators/godown.js";
|
3
3
|
import { styles } from "@godown/element/decorators/styles.js";
|
4
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
5
|
import { css, html } from "lit";
|
5
6
|
import { property, query } from "lit/decorators.js";
|
6
7
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
@@ -19,7 +20,7 @@ let Switch = class Switch extends SuperInput {
|
|
19
20
|
constructor() {
|
20
21
|
super(...arguments);
|
21
22
|
/**
|
22
|
-
*
|
23
|
+
* Display rounded.
|
23
24
|
*/
|
24
25
|
this.round = false;
|
25
26
|
/**
|
@@ -27,11 +28,11 @@ let Switch = class Switch extends SuperInput {
|
|
27
28
|
*/
|
28
29
|
this.checked = false;
|
29
30
|
/**
|
30
|
-
*
|
31
|
+
* Disable this element.
|
31
32
|
*/
|
32
33
|
this.disabled = false;
|
33
34
|
/**
|
34
|
-
*
|
35
|
+
* Default checked state.
|
35
36
|
*/
|
36
37
|
this.default = "false";
|
37
38
|
/**
|
@@ -40,7 +41,10 @@ let Switch = class Switch extends SuperInput {
|
|
40
41
|
this.value = "on";
|
41
42
|
}
|
42
43
|
render() {
|
43
|
-
return html `<div part="root"
|
44
|
+
return html `<div part="root"
|
45
|
+
${attr(this.observedRecord)}
|
46
|
+
class="${this.round ? "round" : "rect"}"
|
47
|
+
>
|
44
48
|
<input
|
45
49
|
part="input"
|
46
50
|
@change="${this._handleChange}"
|
@@ -50,8 +54,7 @@ let Switch = class Switch extends SuperInput {
|
|
50
54
|
id="${this.makeId}"
|
51
55
|
type="checkbox"
|
52
56
|
>
|
53
|
-
<span class="${this.checked}">
|
54
|
-
</span>
|
57
|
+
<span part="handle" class="${this.checked}"></span>
|
55
58
|
</div>`;
|
56
59
|
}
|
57
60
|
reset() {
|
@@ -97,39 +100,39 @@ __decorate([
|
|
97
100
|
Switch = __decorate([
|
98
101
|
godown(protoName),
|
99
102
|
styles(css `
|
103
|
+
:host,
|
104
|
+
:host([contents]) [part=root] {
|
105
|
+
width: var(${cssScope}-width);
|
106
|
+
height: var(${cssScope}-height);
|
107
|
+
}
|
108
|
+
|
100
109
|
:host {
|
101
110
|
${cssScope}-width: 3em;
|
102
111
|
${cssScope}-height: calc(var(${cssScope}-width) / 2);
|
103
112
|
${cssScope}-handle-size: 1.25em;
|
113
|
+
${cssScope}-handle-space: .125em;
|
104
114
|
${cssScope}-transition: .2s ease-in-out;
|
105
115
|
background: var(${cssGlobalVars.input}-background);
|
106
|
-
width: var(${cssScope}-width);
|
107
|
-
height: var(${cssScope}-height);
|
108
116
|
display: inline-block;
|
109
117
|
vertical-align: bottom;
|
110
118
|
border-radius: 0;
|
111
119
|
}
|
112
120
|
|
113
|
-
[part=
|
121
|
+
[part=root],
|
114
122
|
span {
|
115
123
|
transition: var(${cssScope}-transition);
|
116
124
|
}
|
117
125
|
|
118
|
-
[part=
|
126
|
+
[part=root] {
|
119
127
|
border-radius: inherit;
|
120
128
|
position: relative;
|
121
129
|
height: inherit;
|
122
130
|
}
|
123
|
-
|
124
|
-
[part="root"],
|
131
|
+
|
125
132
|
input {
|
133
|
+
opacity: 0;
|
126
134
|
width: 100%;
|
127
|
-
}
|
128
|
-
|
129
|
-
input {
|
130
|
-
margin: 0;
|
131
135
|
height: 100%;
|
132
|
-
outline: none;
|
133
136
|
appearance: none;
|
134
137
|
}
|
135
138
|
|
@@ -150,7 +153,7 @@ Switch = __decorate([
|
|
150
153
|
}
|
151
154
|
|
152
155
|
:host([checked]) span {
|
153
|
-
|
156
|
+
left: 50%;
|
154
157
|
}
|
155
158
|
|
156
159
|
.rect .true {
|
@@ -161,13 +164,13 @@ Switch = __decorate([
|
|
161
164
|
background: var(${cssGlobalVars.passive});
|
162
165
|
}
|
163
166
|
|
164
|
-
.round span
|
167
|
+
.round span{
|
165
168
|
--size: var(${cssScope}-handle-size);
|
166
|
-
content:"";
|
167
169
|
border-radius: 100%;
|
168
170
|
background: var(--godown--input-control);
|
169
171
|
width: var(--size);
|
170
172
|
height: var(--size);
|
173
|
+
margin: var(${cssScope}-handle-space);
|
171
174
|
}
|
172
175
|
|
173
176
|
.round {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/components/switch.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,IAAI,
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/components/switch.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAExC;;;;;;;GAOG;AAsFH,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;IAA/B;;QACE;;WAEG;QAEH,UAAK,GAAG,KAAK,CAAC;QAEd;;WAEG;QAEH,YAAO,GAAG,KAAK,CAAC;QAEhB;;WAEG;QAEH,aAAQ,GAAG,KAAK,CAAC;QAEjB;;WAEG;QAEH,YAAO,GAAG,OAAO,CAAC;QAElB;;WAEG;QAEH,UAAK,GAAG,IAAI,CAAC;IA+Cf,CAAC;IA1CW,MAAM;QACd,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;eAClB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAA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CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAC3B;AAMhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAC1B;AAMjB;IADC,QAAQ,EAAE;uCACO;AAMlB;IADC,QAAQ,EAAE;qCACE;AAGH;IADT,KAAK,CAAC,OAAO,CAAC;sCACoB;AAhC/B,MAAM;IArFX,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CACL,GAAG,CAAA;;;mBAGc,QAAQ;oBACP,QAAQ;;;;QAIpB,QAAQ;QACR,QAAQ,qBAAqB,QAAQ;QACrC,QAAQ;QACR,QAAQ;QACR,QAAQ;wBACQ,aAAa,CAAC,KAAK;;;;;;;;wBAQnB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA6BA,QAAQ;;;;;;;;wBAQhB,aAAa,CAAC,MAAM;;;;wBAIpB,aAAa,CAAC,OAAO;;;;oBAIzB,QAAQ;;;;;oBAKR,QAAQ;;;;wBAIJ,aAAa,CAAC,OAAO;;;;wBAIrB,aAAa,CAAC,MAAM;;GAEzC,CACF;GACK,MAAM,CA4EX;AAED,eAAe,MAAM,CAAC"}
|
package/dev/components/text.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type TemplateResult } from "lit";
|
1
2
|
import { GlobalStyle } from "../core/global-style.js";
|
2
3
|
/**
|
3
4
|
* {@linkcode Text} renders nowrap text.
|
@@ -13,7 +14,7 @@ declare class Text extends GlobalStyle {
|
|
13
14
|
* Set background-clip to text.
|
14
15
|
*/
|
15
16
|
clip: boolean;
|
16
|
-
protected render():
|
17
|
+
protected render(): TemplateResult<1>;
|
17
18
|
}
|
18
19
|
export default Text;
|
19
20
|
//# sourceMappingURL=text.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrD,OAAO,EAAiB,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAMlF;;;;GAIG;AACH,cAiDM,IAAK,SAAQ,WAAW;IAC5B;;OAEG;IAEH,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAU;IAE3D;;OAEG;IAEH,IAAI,EAAE,OAAO,CAAC;IAEd,SAAS,CAAC,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CAStC;AAED,eAAe,IAAI,CAAC"}
|
package/dev/components/text.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
2
|
import { godown } from "@godown/element/decorators/godown.js";
|
3
3
|
import { styles } from "@godown/element/decorators/styles.js";
|
4
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
5
|
import { classList } from "@godown/element/directives/class-list.js";
|
5
6
|
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
6
7
|
import { css, html } from "lit";
|
@@ -24,9 +25,8 @@ let Text = class Text extends GlobalStyle {
|
|
24
25
|
render() {
|
25
26
|
return html `<span
|
26
27
|
part="root"
|
27
|
-
|
28
|
-
|
29
|
-
})}"
|
28
|
+
${attr(this.observedRecord)}
|
29
|
+
class="${classList(this.underline)}"
|
30
30
|
>
|
31
31
|
${htmlSlot()}
|
32
32
|
</span>`;
|
@@ -50,7 +50,7 @@ Text = __decorate([
|
|
50
50
|
overflow-wrap: break-word;
|
51
51
|
}
|
52
52
|
|
53
|
-
|
53
|
+
[part=root] {
|
54
54
|
white-space: nowrap;
|
55
55
|
width: 100%;
|
56
56
|
vertical-align: bottom;
|
@@ -61,11 +61,11 @@ Text = __decorate([
|
|
61
61
|
color: var(${cssScope}--color);
|
62
62
|
}
|
63
63
|
|
64
|
-
|
64
|
+
[part=root]:hover {
|
65
65
|
color: var(${cssScope}--color-hover, var(${cssScope}--color));
|
66
66
|
}
|
67
67
|
|
68
|
-
|
68
|
+
[part=root]:active {
|
69
69
|
color: var(${cssScope}--color-active, var(${cssScope}--color));
|
70
70
|
}
|
71
71
|
|
@@ -79,7 +79,7 @@ Text = __decorate([
|
|
79
79
|
text-decoration: none;
|
80
80
|
}
|
81
81
|
|
82
|
-
|
82
|
+
[clip] {
|
83
83
|
background: var(${cssGlobalVars.clipBackground});
|
84
84
|
display: inline-block;
|
85
85
|
color: transparent;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,IAAI,
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAElF,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAExC;;;;GAIG;AAkDH,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,WAAW;IAA9B;;QACE;;WAEG;QAEH,cAAS,GAA2C,MAAM,CAAC;IAiB7D,CAAC;IATW,MAAM;QACd,OAAO,IAAI,CAAA;;QAEP,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;eAClB,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;;QAEhC,QAAQ,EAAE;YACN,CAAC;IACX,CAAC;CACF,CAAA;AAjBC;IADC,QAAQ,EAAE;uCACgD;AAM3D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kCACd;AAXV,IAAI;IAjDT,MAAM,CAAC,SAAS,CAAC;IACjB,MAAM,CAAC,GAAG,CAAA;;QAEH,QAAQ;QACR,QAAQ;QACR,QAAQ;;;;;;;;;;;;;;mBAcG,QAAQ;;;;mBAIR,QAAQ,sBAAsB,QAAQ;;;;mBAItC,QAAQ,uBAAuB,QAAQ;;;;;;;;;;;;;;wBAclC,aAAa,CAAC,cAAc;;;;;;;CAOnD,CAAC;GACI,IAAI,CAsBT;AAED,eAAe,IAAI,CAAC"}
|
package/dev/components/time.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type PropertyValues } from "lit";
|
1
|
+
import { type PropertyValues, TemplateResult } from "lit";
|
2
2
|
import { GlobalStyle } from "../core/global-style.js";
|
3
3
|
/**
|
4
4
|
* {@linkcode Time} renders a formatting time.
|
@@ -7,12 +7,11 @@ import { GlobalStyle } from "../core/global-style.js";
|
|
7
7
|
*/
|
8
8
|
declare class Time extends GlobalStyle {
|
9
9
|
/**
|
10
|
-
*
|
10
|
+
* Escape symbol.
|
11
11
|
*/
|
12
12
|
escape: string;
|
13
13
|
/**
|
14
14
|
* Format strings.
|
15
|
-
* {@linkcode Time.fmt}
|
16
15
|
*/
|
17
16
|
format: string;
|
18
17
|
/**
|
@@ -22,32 +21,17 @@ declare class Time extends GlobalStyle {
|
|
22
21
|
/**
|
23
22
|
* If there is a value, update every gap or timeout.
|
24
23
|
*/
|
25
|
-
timeout:
|
24
|
+
timeout: any;
|
26
25
|
/**
|
27
26
|
* The number of milliseconds that change with each update.
|
28
27
|
*/
|
29
|
-
gap:
|
30
|
-
timeoutId: number;
|
31
|
-
protected render():
|
28
|
+
gap: any;
|
29
|
+
protected timeoutId: number;
|
30
|
+
protected render(): TemplateResult<1>;
|
32
31
|
protected firstUpdated(): void;
|
33
32
|
protected updated(changedProperties: PropertyValues): void;
|
34
33
|
disconnectedCallback(): void;
|
35
34
|
startTimeout(): number;
|
36
|
-
/**
|
37
|
-
* Y for year\
|
38
|
-
* M for month\
|
39
|
-
* D for day\
|
40
|
-
* h for hour\
|
41
|
-
* m for minute\
|
42
|
-
* s for second\
|
43
|
-
* S for milli second\
|
44
|
-
* Z for time zone.
|
45
|
-
*
|
46
|
-
* @param fm Format string.
|
47
|
-
* @param tm Time.
|
48
|
-
* @returns Format result
|
49
|
-
*/
|
50
|
-
static fmt(fm: string, tm: Date, em: string): string;
|
51
35
|
}
|
52
36
|
export default Time;
|
53
37
|
//# sourceMappingURL=time.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/components/time.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/components/time.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD;;;;GAIG;AACH,cAEM,IAAK,SAAQ,WAAW;IAC5B;;OAEG;IAEH,MAAM,SAAO;IAEb;;OAEG;IAEH,MAAM,SAA8B;IAEpC;;OAEG;IAEH,IAAI,EAAE,IAAI,CAAc;IAExB;;OAEG;IAEH,OAAO,EAAE,GAAG,CAAC;IAEb;;OAEG;IAEH,GAAG,EAAE,GAAG,CAAC;IAET,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAE5B,SAAS,CAAC,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;IAMrC,SAAS,CAAC,YAAY,IAAI,IAAI;IAM9B,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IAS1D,oBAAoB,IAAI,IAAI;IAI5B,YAAY,IAAI,MAAM;CAKvB;AAED,eAAe,IAAI,CAAC"}
|
package/dev/components/time.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
var Time_1;
|
2
1
|
import { __decorate } from "tslib";
|
3
2
|
import { godown } from "@godown/element/decorators/godown.js";
|
4
3
|
import { styles } from "@godown/element/decorators/styles.js";
|
5
|
-
import {
|
4
|
+
import { attr } from "@godown/element/directives/attr.js";
|
5
|
+
import fmtime from "fmtime";
|
6
|
+
import { css, html } from "lit";
|
6
7
|
import { property } from "lit/decorators.js";
|
7
8
|
import { GlobalStyle } from "../core/global-style.js";
|
8
9
|
const protoName = "time";
|
@@ -11,33 +12,26 @@ const protoName = "time";
|
|
11
12
|
*
|
12
13
|
* @category display
|
13
14
|
*/
|
14
|
-
let Time =
|
15
|
+
let Time = class Time extends GlobalStyle {
|
15
16
|
constructor() {
|
16
17
|
super(...arguments);
|
17
18
|
/**
|
18
|
-
*
|
19
|
+
* Escape symbol.
|
19
20
|
*/
|
20
21
|
this.escape = "%";
|
21
22
|
/**
|
22
23
|
* Format strings.
|
23
|
-
* {@linkcode Time.fmt}
|
24
24
|
*/
|
25
25
|
this.format = "YYYY-MM-DD hh:mm:ss UTFZ";
|
26
26
|
/**
|
27
27
|
* Time.
|
28
28
|
*/
|
29
29
|
this.time = new Date();
|
30
|
-
/**
|
31
|
-
* If there is a value, update every gap or timeout.
|
32
|
-
*/
|
33
|
-
this.timeout = 0;
|
34
|
-
/**
|
35
|
-
* The number of milliseconds that change with each update.
|
36
|
-
*/
|
37
|
-
this.gap = 0;
|
38
30
|
}
|
39
31
|
render() {
|
40
|
-
return
|
32
|
+
return html `<span part="root" ${attr(this.observedRecord)}>
|
33
|
+
${fmtime(this.format, this.time, this.escape)}
|
34
|
+
</span>`;
|
41
35
|
}
|
42
36
|
firstUpdated() {
|
43
37
|
if (this.timeout) {
|
@@ -60,58 +54,6 @@ let Time = Time_1 = class Time extends GlobalStyle {
|
|
60
54
|
this.time = new Date(this.time.getTime() + (this.gap || this.timeout));
|
61
55
|
}, Math.abs(this.timeout));
|
62
56
|
}
|
63
|
-
/**
|
64
|
-
* Y for year\
|
65
|
-
* M for month\
|
66
|
-
* D for day\
|
67
|
-
* h for hour\
|
68
|
-
* m for minute\
|
69
|
-
* s for second\
|
70
|
-
* S for milli second\
|
71
|
-
* Z for time zone.
|
72
|
-
*
|
73
|
-
* @param fm Format string.
|
74
|
-
* @param tm Time.
|
75
|
-
* @returns Format result
|
76
|
-
*/
|
77
|
-
static fmt(fm, tm, em) {
|
78
|
-
if (!fm) {
|
79
|
-
return fm;
|
80
|
-
}
|
81
|
-
tm = typeof tm === "string" ? new Date(tm) : tm;
|
82
|
-
if (isNaN(tm.getTime())) {
|
83
|
-
return fm;
|
84
|
-
}
|
85
|
-
const rest = [];
|
86
|
-
const replaced = `${em}${em}`;
|
87
|
-
fm = fm.replace(new RegExp(`${em}([ZYMDhmsS${em}])`, "g"), (_, p1) => {
|
88
|
-
rest.push(p1);
|
89
|
-
return replaced;
|
90
|
-
});
|
91
|
-
function formatNumber(n, max = 2) {
|
92
|
-
return n.toString().padStart(max, "0").split("");
|
93
|
-
}
|
94
|
-
const z = tm.getTimezoneOffset() / -60;
|
95
|
-
const switcher = {
|
96
|
-
Z: [z >= 0 ? "+" + z.toString() : z.toString()],
|
97
|
-
Y: tm.getFullYear().toString().split(""),
|
98
|
-
M: formatNumber(tm.getMonth() + 1),
|
99
|
-
D: formatNumber(tm.getDate()),
|
100
|
-
h: formatNumber(tm.getHours()),
|
101
|
-
m: formatNumber(tm.getMinutes()),
|
102
|
-
s: formatNumber(tm.getSeconds()),
|
103
|
-
S: formatNumber(tm.getMilliseconds(), 3),
|
104
|
-
};
|
105
|
-
const result = [];
|
106
|
-
for (const f of fm.split("").reverse()) {
|
107
|
-
const s = switcher[f]?.pop();
|
108
|
-
result.push(s ? s : f);
|
109
|
-
}
|
110
|
-
return result
|
111
|
-
.reverse()
|
112
|
-
.join("")
|
113
|
-
.replace(new RegExp(replaced, "g"), () => rest.shift());
|
114
|
-
}
|
115
57
|
};
|
116
58
|
__decorate([
|
117
59
|
property()
|
@@ -128,7 +70,7 @@ __decorate([
|
|
128
70
|
__decorate([
|
129
71
|
property({ type: Number })
|
130
72
|
], Time.prototype, "gap", void 0);
|
131
|
-
Time =
|
73
|
+
Time = __decorate([
|
132
74
|
godown(protoName),
|
133
75
|
styles(css `:host{text-align: center;}`)
|
134
76
|
], Time);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/components/time.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/components/time.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAuC,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB;;;;GAIG;AAGH,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,WAAW;IAA9B;;QACE;;WAEG;QAEH,WAAM,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