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/range.js
CHANGED
@@ -2,23 +2,22 @@ import { __decorate } from "tslib";
|
|
2
2
|
import { godown } from "@godown/element/decorators/godown.js";
|
3
3
|
import { part } from "@godown/element/decorators/part.js";
|
4
4
|
import { styles } from "@godown/element/decorators/styles.js";
|
5
|
+
import { attr } from "@godown/element/directives/attr.js";
|
5
6
|
import { classList } from "@godown/element/directives/class-list.js";
|
6
|
-
import { conditionIf } from "@godown/element/directives/condition-if.js";
|
7
|
-
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
8
7
|
import { joinProperties } from "@godown/element/tools/css.js";
|
9
8
|
import { isNil } from "@godown/element/tools/lib.js";
|
10
9
|
import { css, html } from "lit";
|
11
|
-
import { property, state } from "lit/decorators.js";
|
10
|
+
import { property, queryAll, state } from "lit/decorators.js";
|
12
11
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
13
12
|
import SuperInput from "../core/super-input.js";
|
14
13
|
const protoName = "range";
|
15
14
|
const cssScope = scopePrefix(protoName);
|
16
15
|
/**
|
17
|
-
* {@linkcode Range} is similar to
|
16
|
+
* {@linkcode Range} is similar to `<input type="range">`.
|
18
17
|
*
|
19
|
-
* Value accepts
|
18
|
+
* Value accepts number, or array.
|
20
19
|
*
|
21
|
-
* Number
|
20
|
+
* Number has 1 handle, the array has the number of its elements and the minimum is 2.
|
22
21
|
*
|
23
22
|
* @category input
|
24
23
|
*/
|
@@ -33,73 +32,145 @@ let Range = class Range extends SuperInput {
|
|
33
32
|
* Maximum value.
|
34
33
|
*/
|
35
34
|
this.max = 100;
|
36
|
-
/**
|
37
|
-
* Sliding step length.
|
38
|
-
*/
|
39
|
-
this.step = 1;
|
40
35
|
}
|
41
36
|
/**
|
42
|
-
* Returns true when the second number is greater than the first number
|
37
|
+
* Returns true when the second number is greater than the first number.
|
43
38
|
*/
|
44
39
|
get reverse() {
|
45
40
|
return this.range ? this.value[0] > this.value[1] : false;
|
46
41
|
}
|
47
42
|
/**
|
48
|
-
*
|
43
|
+
* If value is array.
|
49
44
|
*/
|
50
45
|
get range() {
|
51
46
|
return Array.isArray(this.value);
|
52
47
|
}
|
48
|
+
/**
|
49
|
+
* Return values in the form of an array.
|
50
|
+
*/
|
53
51
|
get rangeValue() {
|
54
|
-
return (this.range ? this.value : [
|
52
|
+
return (this.range ? this.value : [this.value]);
|
53
|
+
}
|
54
|
+
/**
|
55
|
+
* @param len Minimum result length.
|
56
|
+
* @param value Fill value.
|
57
|
+
* @returns Array with length of len.
|
58
|
+
*/
|
59
|
+
padValue(len, value = 0) {
|
60
|
+
const { rangeValue } = this;
|
61
|
+
const miss = len - rangeValue.length;
|
62
|
+
if (miss > 0) {
|
63
|
+
return new Array(miss).fill(value).concat(rangeValue);
|
64
|
+
}
|
65
|
+
return rangeValue;
|
55
66
|
}
|
56
67
|
render() {
|
57
|
-
const
|
68
|
+
const rangeValue = this.padValue(2);
|
69
|
+
const from = Math.min(...rangeValue);
|
70
|
+
const to = Math.max(...rangeValue);
|
58
71
|
const gap = this.max - this.min;
|
59
72
|
return html `<div
|
60
73
|
part="root"
|
61
|
-
|
62
|
-
vertical: this.vertical,
|
63
|
-
range: this.range,
|
64
|
-
reverse: this.reverse,
|
65
|
-
})}"
|
74
|
+
${attr(this.observedRecord)}
|
66
75
|
@mousedown="${this.disabled ? null : this._handleMousedownRoot}"
|
67
|
-
style="${joinProperties({
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
part="
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
</i>
|
76
|
+
style="${joinProperties({
|
77
|
+
"--from": `${((from - this.min) / gap) * 100}%`,
|
78
|
+
"--to": `${((to - this.min) / gap) * 100}%`,
|
79
|
+
...(this.range
|
80
|
+
? Object.fromEntries(rangeValue.map((value, index) => [
|
81
|
+
`--handle-${index}`,
|
82
|
+
`${((value - this.min) / gap) * 100}%`,
|
83
|
+
]))
|
84
|
+
: {}),
|
85
|
+
})}"><div part="track"></div>
|
86
|
+
${this.range
|
87
|
+
? this.value.map((_, index) => this.renderHandle(index))
|
88
|
+
: this.renderHandle(0)}
|
81
89
|
</div>`;
|
82
90
|
}
|
83
|
-
|
84
|
-
|
85
|
-
this.
|
91
|
+
renderHandle(index) {
|
92
|
+
const { range } = this;
|
93
|
+
const end = !range || index === this.value.length - 1;
|
94
|
+
return html `<i
|
95
|
+
tabindex="0"
|
96
|
+
part="handle"
|
97
|
+
class="${classList({ "last-focus": this.lastFocus === index })}"
|
98
|
+
@mousedown="${this.disabled ? null : this.createMouseDown(index)}"
|
99
|
+
@focus="${this.disabled ? null : () => this.focusHandle(index)}"
|
100
|
+
@blur="${this.disabled ? null : this.blurHandle}"
|
101
|
+
style="--handle:var(--${
|
102
|
+
/* In single-handle mod or end, it is max value */
|
103
|
+
(!range && end) ? `to` : `handle-${index}`})"
|
104
|
+
></i>
|
105
|
+
`;
|
106
|
+
}
|
107
|
+
focusHandle(index) {
|
108
|
+
this.lastFocus = index;
|
109
|
+
const handleItem = this._handles.item(index);
|
110
|
+
handleItem?.focus();
|
111
|
+
if (!this._keydownEvent) {
|
112
|
+
this._keydownEvent = this.events.add(document, "keydown", this.createKeydownEvent(index));
|
113
|
+
}
|
114
|
+
}
|
115
|
+
blurHandle() {
|
116
|
+
this.lastFocus = undefined;
|
117
|
+
this._keydownEvent = this.events.remove(document, "keydown", this._keydownEvent);
|
118
|
+
}
|
119
|
+
createKeydownEvent(index) {
|
120
|
+
if (!this.range) {
|
121
|
+
index = 0;
|
122
|
+
}
|
123
|
+
return (e) => {
|
124
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
|
125
|
+
e.preventDefault();
|
126
|
+
this.createSetValue(index)(old => old - this.step);
|
127
|
+
}
|
128
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") {
|
129
|
+
e.preventDefault();
|
130
|
+
this.createSetValue(index)(old => old + this.step);
|
131
|
+
}
|
132
|
+
};
|
133
|
+
}
|
134
|
+
createMouseDown(index) {
|
135
|
+
return (e) => {
|
136
|
+
this.focusHandle(index);
|
137
|
+
this.createMousedownListener(this.createSetValue(index))(e);
|
138
|
+
};
|
86
139
|
}
|
87
140
|
_handleMousedownEnd(e) {
|
88
|
-
this.lastFocus =
|
141
|
+
this.lastFocus = 0;
|
89
142
|
this.createMousedownListener(this.setEnd)(e);
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
143
|
+
this.focusHandle(0);
|
144
|
+
}
|
145
|
+
createSetValue(index) {
|
146
|
+
return (numberOrModifier) => {
|
147
|
+
const number = typeof numberOrModifier === "number"
|
148
|
+
? this.normalizeValue(numberOrModifier)
|
149
|
+
: numberOrModifier(this.rangeValue[index]);
|
150
|
+
let newValue = number;
|
151
|
+
if (this.range) {
|
152
|
+
newValue = [...this.rangeValue];
|
153
|
+
newValue[index] = number;
|
154
|
+
}
|
155
|
+
this.value = newValue;
|
156
|
+
};
|
94
157
|
}
|
95
158
|
setEnd(value) {
|
96
|
-
|
97
|
-
this.value = this.range ? [i, value] : value;
|
159
|
+
this.createSetValue(this.value?.length - 1 || 0)(value);
|
98
160
|
}
|
161
|
+
/**
|
162
|
+
* Compute value from event.
|
163
|
+
*/
|
99
164
|
_computeValue(e) {
|
100
165
|
const rect = this._root.getBoundingClientRect();
|
101
166
|
const div = this.vertical ? (e.clientY - rect.top) / rect.height : (e.clientX - rect.left) / rect.width;
|
102
|
-
|
167
|
+
const value = Math.round((div * (this.max - this.min)) / this.step) * this.step;
|
168
|
+
return this.normalizeValue(value);
|
169
|
+
}
|
170
|
+
/**
|
171
|
+
* Ensure that the values do not exceed the range of max and min.
|
172
|
+
*/
|
173
|
+
normalizeValue(value) {
|
103
174
|
if (value > this.max) {
|
104
175
|
value -= this.step;
|
105
176
|
}
|
@@ -110,26 +181,29 @@ let Range = class Range extends SuperInput {
|
|
110
181
|
}
|
111
182
|
_handleMousedownRoot(e) {
|
112
183
|
const value = this._computeValue(e);
|
113
|
-
|
114
|
-
this.
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
184
|
+
const index = this.range
|
185
|
+
? this.rangeValue.reduce((acc, item, index) => {
|
186
|
+
const diff = Math.abs(value - item);
|
187
|
+
const prevDiff = Math.abs(value - this.rangeValue[acc]);
|
188
|
+
return diff < prevDiff ? index : acc;
|
189
|
+
}, 0)
|
190
|
+
: 0;
|
191
|
+
const set = this.createSetValue(index);
|
192
|
+
set(value);
|
193
|
+
this.createMousedownListener(set)(e);
|
194
|
+
this.focusHandle(index);
|
121
195
|
}
|
122
196
|
createMousedownListener(mouseMoveCallback) {
|
123
197
|
return (e) => {
|
124
198
|
e.preventDefault();
|
125
199
|
e.stopPropagation();
|
126
200
|
const move = this.createMousemoveListener(mouseMoveCallback);
|
127
|
-
|
201
|
+
this.events.add(document, "mousemove", move);
|
128
202
|
const stop = () => {
|
129
|
-
|
130
|
-
|
203
|
+
this.events.remove(document, "mousemove", move);
|
204
|
+
this.events.remove(document, "mouseup", stop);
|
131
205
|
};
|
132
|
-
|
206
|
+
this.events.add(document, "mouseup", stop);
|
133
207
|
};
|
134
208
|
}
|
135
209
|
createMousemoveListener(callback) {
|
@@ -144,34 +218,25 @@ let Range = class Range extends SuperInput {
|
|
144
218
|
_connectedInit() {
|
145
219
|
const gap = this.max - this.min;
|
146
220
|
this.step ||= gap / 100;
|
147
|
-
if (
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
const mid = Math.round(gap / 2 / this.step) * this.step;
|
155
|
-
this.default = this.range ? [0, mid] : mid;
|
156
|
-
this.value = this.default;
|
221
|
+
if (isNil(this.value)) {
|
222
|
+
if (!isNil(this.default)) {
|
223
|
+
this.value = this.default;
|
224
|
+
}
|
225
|
+
else {
|
226
|
+
this.value = Math.round(gap / 2 / this.step) * this.step;
|
227
|
+
}
|
157
228
|
}
|
229
|
+
this.default ??= this.value;
|
158
230
|
}
|
159
231
|
reset() {
|
160
232
|
this.value = this.default;
|
161
233
|
}
|
162
|
-
swap() {
|
163
|
-
if (this.range) {
|
164
|
-
const [a, b] = this.value;
|
165
|
-
this.value = [b, a];
|
166
|
-
}
|
167
|
-
}
|
168
234
|
sort() {
|
169
|
-
this.value = this.toSorted();
|
235
|
+
return this.value = this.toSorted();
|
170
236
|
}
|
171
237
|
toSorted() {
|
172
238
|
if (this.range) {
|
173
|
-
|
174
|
-
return a > b ? [b, a] : [a, b];
|
239
|
+
return [...this.value].sort((a, b) => a - b);
|
175
240
|
}
|
176
241
|
return this.value;
|
177
242
|
}
|
@@ -197,6 +262,9 @@ __decorate([
|
|
197
262
|
__decorate([
|
198
263
|
part("root")
|
199
264
|
], Range.prototype, "_root", void 0);
|
265
|
+
__decorate([
|
266
|
+
queryAll("[part=handle]")
|
267
|
+
], Range.prototype, "_handles", void 0);
|
200
268
|
__decorate([
|
201
269
|
state()
|
202
270
|
], Range.prototype, "lastFocus", void 0);
|
@@ -208,7 +276,7 @@ Range = __decorate([
|
|
208
276
|
${cssScope}-track-width: .5em;
|
209
277
|
background: var(${cssGlobalVars.input}-background);
|
210
278
|
width: var(${cssGlobalVars.input}-width);
|
211
|
-
display:
|
279
|
+
display: block;
|
212
280
|
margin: 0.25em 0;
|
213
281
|
}
|
214
282
|
|
@@ -217,26 +285,23 @@ Range = __decorate([
|
|
217
285
|
width: fit-content;
|
218
286
|
}
|
219
287
|
|
220
|
-
|
288
|
+
:host(:not([disabled])) .last-focus {
|
289
|
+
z-index: 1;
|
221
290
|
${cssScope}-handle-scale:1.05;
|
222
291
|
background: var(${cssScope}-handle-active);
|
223
292
|
}
|
224
293
|
|
225
|
-
|
226
|
-
|
227
|
-
}
|
228
|
-
|
229
|
-
[part="root"] {
|
230
|
-
min-height:inherit;
|
294
|
+
[part=root] {
|
295
|
+
min-height: inherit;
|
231
296
|
position: relative;
|
232
297
|
border-radius: inherit;
|
233
298
|
width: 100%;
|
234
|
-
--
|
235
|
-
--
|
299
|
+
--from: 0%;
|
300
|
+
--to: 50%;
|
236
301
|
height: var(${cssScope}-track-width);
|
237
302
|
}
|
238
303
|
|
239
|
-
[part=
|
304
|
+
[part=track] {
|
240
305
|
height: 100%;
|
241
306
|
min-height:inherit;
|
242
307
|
display: flex;
|
@@ -244,12 +309,12 @@ Range = __decorate([
|
|
244
309
|
pointer-events: none;
|
245
310
|
border-radius: inherit;
|
246
311
|
justify-content: space-between;
|
247
|
-
left: min(var(--
|
312
|
+
left: min(var(--from), var(--to));
|
248
313
|
background: var(${cssGlobalVars.active});
|
249
|
-
width: max(calc(var(--
|
314
|
+
width: max(calc(var(--to) - var(--from)), calc(var(--from) - var(--to)));
|
250
315
|
}
|
251
316
|
|
252
|
-
[part=
|
317
|
+
[part=handle] {
|
253
318
|
width: 1em;
|
254
319
|
height: 1em;
|
255
320
|
display: flex;
|
@@ -265,39 +330,29 @@ Range = __decorate([
|
|
265
330
|
border-color: var(${cssGlobalVars.input}-control);
|
266
331
|
}
|
267
332
|
`, css `
|
268
|
-
|
269
|
-
height:
|
333
|
+
[vertical] {
|
334
|
+
height: inherit;
|
270
335
|
width: var(${cssScope}-track-width);
|
271
336
|
}
|
272
337
|
|
273
|
-
|
338
|
+
[vertical] i {
|
274
339
|
transform: translate(-25%, -50%);
|
275
340
|
}
|
276
341
|
|
277
|
-
|
342
|
+
[vertical] [part=track] {
|
278
343
|
width: 100%;
|
279
|
-
height: max(calc(var(--
|
280
|
-
top: min(var(--
|
344
|
+
height: max(calc(var(--to) - var(--from)), calc(var(--from) - var(--to)));
|
345
|
+
top: min(var(--from), var(--to));
|
281
346
|
left: 0;
|
282
347
|
}
|
283
348
|
`, css `
|
284
|
-
|
285
|
-
left: var(--
|
349
|
+
[part=handle] {
|
350
|
+
left: var(--handle);
|
286
351
|
top: 0;
|
287
352
|
}
|
288
353
|
|
289
|
-
|
290
|
-
|
291
|
-
top: 0;
|
292
|
-
}
|
293
|
-
|
294
|
-
.vertical .start {
|
295
|
-
top: var(--start);
|
296
|
-
left: 0;
|
297
|
-
}
|
298
|
-
|
299
|
-
.vertical .end {
|
300
|
-
top: var(--end);
|
354
|
+
[vertical] [part=handle] {
|
355
|
+
top: var(--handle);
|
301
356
|
left: 0;
|
302
357
|
}
|
303
358
|
`)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../src/components/range.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../src/components/range.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,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,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE9D,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;;;;;;;;GAQG;AA4FH,IAAM,KAAK,GAAX,MAAM,KAAM,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AQ;;;;;;;;;;oBAUZ,QAAQ;;;;;;;;;;;;wBAYJ,aAAa,CAAC,MAAM;;;;;;;;;;;;;;;6BAef,QAAQ;wBACb,aAAa,CAAC,MAAM;0BAClB,aAAa,CAAC,KAAK;;GAE1C,EACD,GAAG,CAAA;;;mBAGc,QAAQ;;;;;;;;;;;;;GAaxB,EACD,GAAG,CAAA;;;;;;;;;;GAUF,CACF;GACK,KAAK,CAwRV;AAED,eAAe,KAAK,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type TemplateResult } from "lit";
|
1
2
|
import { GlobalStyle } from "../core/global-style.js";
|
2
3
|
/**
|
3
4
|
* {@linkcode Rotate} Make child elements rotate.
|
@@ -5,8 +6,8 @@ import { GlobalStyle } from "../core/global-style.js";
|
|
5
6
|
* @category wrapper
|
6
7
|
*/
|
7
8
|
declare class Rotate extends GlobalStyle {
|
8
|
-
_root: HTMLElement;
|
9
|
-
protected render():
|
9
|
+
protected _root: HTMLElement;
|
10
|
+
protected render(): TemplateResult<1>;
|
10
11
|
reset(): void;
|
11
12
|
protected _handleRotate(e: MouseEvent): void;
|
12
13
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/components/rotate.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/components/rotate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAErD,OAAO,EAAE,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAKnE;;;;GAIG;AACH,cAiCM,MAAO,SAAQ,WAAW;IAE9B,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC;IAE7B,SAAS,CAAC,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;IAOrC,KAAK,IAAI,IAAI;IAKb,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAM5C;;;;;;;OAOG;IACH,cAAc,CAAC,CAAC,EAAE,UAAU,GAAG;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB;CAUF;AAED,eAAe,MAAM,CAAC"}
|
package/dev/components/rotate.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rotate.js","sourceRoot":"","sources":["../../src/components/rotate.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,IAAI,
|
1
|
+
{"version":3,"file":"rotate.js","sourceRoot":"","sources":["../../src/components/rotate.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAExC;;;;GAIG;AAkCH,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,WAAW;IAIpB,MAAM;QACd,OAAO,IAAI,CAAA;qCACsB,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE;wBAC9C,IAAI,CAAC,KAAK;WACvB,CAAC;IACV,CAAC;IAED,KAAK;QACH,IAAI,CA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;4BACC,QAAQ;;;;;;CAMnC,CACA;GACK,MAAM,CA2CX;AAED,eAAe,MAAM,CAAC"}
|
@@ -18,10 +18,12 @@ import { GlobalStyle } from "../core/global-style.js";
|
|
18
18
|
*
|
19
19
|
* If no routes are matched, the default value (no named slot) will be rendered.
|
20
20
|
*
|
21
|
+
* @slot - Display slot when there is no match.
|
22
|
+
* @slot * - Matching slot will be displayed.
|
21
23
|
* @category navigation
|
22
24
|
*/
|
23
|
-
declare class Router
|
24
|
-
static routerInstances: Set<Router
|
25
|
+
declare class Router extends GlobalStyle {
|
26
|
+
static routerInstances: Set<Router>;
|
25
27
|
private __fieldRouteTree;
|
26
28
|
private __slottedRouteTree;
|
27
29
|
private __cacheRecord;
|
@@ -29,7 +31,7 @@ declare class Router<C = unknown> extends GlobalStyle {
|
|
29
31
|
/**
|
30
32
|
* Render result.
|
31
33
|
*/
|
32
|
-
component:
|
34
|
+
component: unknown | TemplateResult;
|
33
35
|
/**
|
34
36
|
* Dynamic parameters record.
|
35
37
|
*/
|
@@ -66,43 +68,38 @@ declare class Router<C = unknown> extends GlobalStyle {
|
|
66
68
|
cache: boolean;
|
67
69
|
set routes(value: (Record<string, any> & {
|
68
70
|
path: string;
|
69
|
-
component?:
|
71
|
+
component?: unknown;
|
70
72
|
})[]);
|
71
73
|
get routes(): (Record<string, any> & {
|
72
74
|
path: string;
|
73
|
-
component?:
|
75
|
+
component?: unknown;
|
74
76
|
})[];
|
75
77
|
clear(): void;
|
76
|
-
protected render():
|
78
|
+
protected render(): unknown;
|
77
79
|
connectedCallback(): void;
|
78
80
|
disconnectedCallback(): void;
|
79
81
|
useRouter(): {
|
80
82
|
pathname: string;
|
81
83
|
params: Record<string, string>;
|
82
84
|
path: string;
|
83
|
-
component:
|
85
|
+
component: unknown;
|
84
86
|
};
|
85
87
|
/**
|
86
|
-
*
|
87
|
-
* @param first whether this path is loaded for the first time.
|
88
|
+
* Callback function when the route changes.
|
88
89
|
*/
|
89
90
|
routeChangeCallback: (params: {
|
90
91
|
pathname: string;
|
91
92
|
params: Record<string, string>;
|
92
93
|
path: string;
|
93
|
-
component:
|
94
|
+
component: unknown | TemplateResult;
|
94
95
|
}, first: boolean) => void;
|
95
96
|
protected updated(changedProperties: PropertyValueMap<this>): void;
|
96
97
|
/**
|
97
|
-
*
|
98
|
-
* @param query Query string.
|
99
|
-
* @returns Components or null.
|
98
|
+
* Get component from {@linkcode routes} by query.
|
100
99
|
*/
|
101
|
-
fieldComponent(query?: string):
|
100
|
+
fieldComponent(query?: string): unknown;
|
102
101
|
/**
|
103
|
-
*
|
104
|
-
* @param query Query string.
|
105
|
-
* @returns Named slot element template result or null.
|
102
|
+
* Get component from slotted elements by query.
|
106
103
|
*/
|
107
104
|
slottedComponent(usedRouteTemplate?: string): TemplateResult<1>;
|
108
105
|
/**
|
@@ -116,6 +113,7 @@ declare class Router<C = unknown> extends GlobalStyle {
|
|
116
113
|
useWhich(path: string): string;
|
117
114
|
parseParams(routeTemplate: string, path: string): Record<string, string>;
|
118
115
|
static updateAll(): void;
|
116
|
+
handlePopstate: () => void;
|
119
117
|
}
|
120
118
|
export default Router;
|
121
119
|
//# sourceMappingURL=router.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/components/router.ts"],"names":[],"mappings":"AAIA,OAAO,EAAO,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/components/router.ts"],"names":[],"mappings":"AAIA,OAAO,EAAO,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,cAEM,MAAO,SAAQ,WAAW;IAC9B,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