godown 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/godown+lit.iife.js +4 -4
- package/build/godown+lit.iife.js.map +1 -1
- package/build/godown+lit.js +4 -4
- package/build/godown+lit.js.map +1 -1
- package/build/godown+lit.umd.js +4 -4
- package/build/godown+lit.umd.js.map +1 -1
- package/build/godown.iife.js +4 -4
- package/build/godown.js +4 -4
- package/build/godown.js.map +1 -1
- package/build/godown.umd.js +4 -4
- package/build/godown.umd.js.map +1 -1
- package/components/alert.js +1 -1
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts +5 -4
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +1 -1
- package/components/avatar.js.map +1 -1
- package/components/badge.d.ts +10 -2
- package/components/badge.d.ts.map +1 -1
- package/components/badge.js.map +1 -1
- package/components/breath.d.ts +2 -3
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +1 -1
- package/components/breath.js.map +1 -1
- package/components/button.d.ts +7 -2
- package/components/button.d.ts.map +1 -1
- package/components/button.js +1 -1
- package/components/button.js.map +1 -1
- package/components/card.d.ts +6 -0
- package/components/card.d.ts.map +1 -1
- package/components/card.js +1 -1
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts +2 -2
- package/components/details.d.ts +3 -3
- package/components/details.d.ts.map +1 -1
- package/components/dialog.d.ts +9 -6
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +1 -1
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts +1 -1
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +1 -1
- package/components/divider.js.map +1 -1
- package/components/heading.d.ts +2 -0
- package/components/heading.d.ts.map +1 -1
- package/components/heading.js.map +1 -1
- package/components/input.d.ts +2 -2
- package/components/input.d.ts.map +1 -1
- package/components/input.js +1 -1
- package/components/input.js.map +1 -1
- package/components/link.d.ts +1 -1
- package/components/link.d.ts.map +1 -1
- package/components/link.js +1 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts +0 -7
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +1 -1
- package/components/progress.js.map +1 -1
- package/components/range.d.ts +50 -15
- package/components/range.d.ts.map +1 -1
- package/components/range.js +1 -1
- package/components/range.js.map +1 -1
- package/components/rotate.d.ts +6 -4
- package/components/rotate.d.ts.map +1 -1
- package/components/rotate.js.map +1 -1
- package/components/select.d.ts +4 -2
- package/components/select.d.ts.map +1 -1
- package/components/select.js +1 -1
- package/components/select.js.map +1 -1
- package/components/split.d.ts +2 -1
- package/components/split.d.ts.map +1 -1
- package/components/split.js +1 -1
- package/components/split.js.map +1 -1
- package/components/switch.d.ts +10 -20
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +1 -1
- package/components/switch.js.map +1 -1
- package/components/time.d.ts +2 -2
- package/components/time.d.ts.map +1 -1
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +3 -2
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +1 -1
- package/components/tooltip.js.map +1 -1
- package/core/direction.d.ts +27 -0
- package/core/direction.d.ts.map +1 -0
- package/core/direction.js +2 -0
- package/core/direction.js.map +1 -0
- package/core/global-style.d.ts +0 -2
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +1 -1
- package/core/global-style.js.map +1 -1
- package/core/outline.d.ts +20 -0
- package/core/outline.d.ts.map +1 -0
- package/core/outline.js +2 -0
- package/core/outline.js.map +1 -0
- package/core/super-anchor.d.ts +2 -2
- package/core/super-anchor.d.ts.map +1 -1
- package/core/super-anchor.js +1 -1
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +4 -2
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +1 -1
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts +0 -4
- package/core/super-openable.d.ts.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.js +1 -1
- package/dev/components/avatar.d.ts +5 -4
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +7 -5
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/badge.d.ts +10 -2
- package/dev/components/badge.d.ts.map +1 -1
- package/dev/components/badge.js +8 -0
- package/dev/components/badge.js.map +1 -1
- package/dev/components/breath.d.ts +2 -3
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +3 -14
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +7 -2
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +19 -5
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +6 -0
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +15 -11
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +2 -2
- package/dev/components/carousel.js +2 -2
- package/dev/components/details.d.ts +3 -3
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +3 -3
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +9 -6
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +58 -62
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts +1 -1
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +3 -2
- package/dev/components/divider.js.map +1 -1
- package/dev/components/heading.d.ts +2 -0
- package/dev/components/heading.d.ts.map +1 -1
- package/dev/components/heading.js +2 -0
- package/dev/components/heading.js.map +1 -1
- package/dev/components/input.d.ts +2 -2
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +29 -8
- package/dev/components/input.js.map +1 -1
- package/dev/components/link.d.ts +1 -1
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +2 -2
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +0 -7
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +4 -25
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +50 -15
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +50 -14
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +6 -4
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +6 -4
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/select.d.ts +4 -2
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +27 -24
- package/dev/components/select.js.map +1 -1
- package/dev/components/split.d.ts +2 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +12 -7
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +10 -20
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +57 -98
- package/dev/components/switch.js.map +1 -1
- package/dev/components/time.d.ts +2 -2
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +3 -2
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +7 -19
- package/dev/components/tooltip.js.map +1 -1
- package/dev/core/direction.d.ts +27 -0
- package/dev/core/direction.d.ts.map +1 -0
- package/dev/core/direction.js +56 -0
- package/dev/core/direction.js.map +1 -0
- package/dev/core/global-style.d.ts +0 -2
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +3 -7
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/outline.d.ts +20 -0
- package/dev/core/outline.d.ts.map +1 -0
- package/dev/core/outline.js +44 -0
- package/dev/core/outline.js.map +1 -0
- package/dev/core/super-anchor.d.ts +2 -2
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +0 -1
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +4 -2
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +25 -30
- package/dev/core/super-input.js.map +1 -1
- package/dev/core/super-openable.d.ts +0 -4
- package/dev/core/super-openable.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/alert.ts +1 -1
- package/src/components/avatar.ts +9 -6
- package/src/components/badge.ts +10 -3
- package/src/components/breath.ts +5 -17
- package/src/components/button.ts +18 -5
- package/src/components/card.ts +15 -11
- package/src/components/carousel.ts +2 -2
- package/src/components/details.ts +3 -3
- package/src/components/dialog.ts +66 -65
- package/src/components/divider.ts +3 -2
- package/src/components/heading.ts +2 -0
- package/src/components/input.ts +29 -8
- package/src/components/link.ts +2 -2
- package/src/components/progress.ts +4 -25
- package/src/components/range.ts +64 -26
- package/src/components/rotate.ts +6 -4
- package/src/components/select.ts +33 -26
- package/src/components/split.ts +13 -7
- package/src/components/switch.ts +62 -94
- package/src/components/time.ts +2 -2
- package/src/components/tooltip.ts +8 -20
- package/src/core/direction.ts +65 -0
- package/src/core/global-style.ts +3 -9
- package/src/core/outline.ts +54 -0
- package/src/core/super-anchor.ts +3 -2
- package/src/core/super-input.ts +31 -33
- package/src/core/super-openable.ts +0 -8
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/src/components/select.ts
CHANGED
@@ -4,6 +4,8 @@ import { type TemplateResult, css, html, nothing } from "lit";
|
|
4
4
|
import { property, state } from "lit/decorators.js";
|
5
5
|
|
6
6
|
import Input from "./input.js";
|
7
|
+
import { cssGlobalVars } from "../core/global-style.js";
|
8
|
+
import { type DirectionCardinalY, directionOutsetPlace } from "../core/direction.js";
|
7
9
|
|
8
10
|
function contain(a: string, b: string): boolean {
|
9
11
|
return a && b && a.toLowerCase().includes(b.toLowerCase());
|
@@ -46,29 +48,29 @@ const protoName = "select";
|
|
46
48
|
* @category input
|
47
49
|
*/
|
48
50
|
@godown(protoName)
|
49
|
-
@styles(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
width: 100%;
|
57
|
-
visibility: hidden;
|
58
|
-
}
|
51
|
+
@styles(
|
52
|
+
directionOutsetPlace,
|
53
|
+
css`
|
54
|
+
:host(:focus-within),
|
55
|
+
.outline {
|
56
|
+
${cssGlobalVars.input}-outline-color: var(${cssGlobalVars.active});
|
57
|
+
}
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
[part="input"] {
|
60
|
+
text-overflow: ellipsis;
|
61
|
+
}
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
[part="content"] {
|
64
|
+
position: absolute;
|
65
|
+
width: 100%;
|
66
|
+
visibility: hidden;
|
67
|
+
}
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
[visible] [part="content"] {
|
70
|
+
visibility: visible;
|
71
|
+
}
|
72
|
+
`,
|
73
|
+
)
|
72
74
|
class Select extends Input {
|
73
75
|
// @ts-ignore
|
74
76
|
value: string | string[];
|
@@ -83,7 +85,7 @@ class Select extends Input {
|
|
83
85
|
protected _content: HTMLElement;
|
84
86
|
|
85
87
|
@property()
|
86
|
-
direction:
|
88
|
+
direction: DirectionCardinalY;
|
87
89
|
|
88
90
|
@property({ type: Boolean })
|
89
91
|
multiple = false;
|
@@ -92,21 +94,25 @@ class Select extends Input {
|
|
92
94
|
visible = false;
|
93
95
|
|
94
96
|
@state()
|
95
|
-
protected autoDirection:
|
97
|
+
protected autoDirection: DirectionCardinalY = "bottom";
|
96
98
|
|
97
99
|
protected lastChecked: HTMLElement;
|
98
100
|
protected defaultText: string;
|
99
101
|
protected defaultChecked: HTMLElement[];
|
100
102
|
private __store: { value: string; text: string }[] = [];
|
101
103
|
|
104
|
+
get observedRecord(): Record<string, any> {
|
105
|
+
return {
|
106
|
+
...super.observedRecord,
|
107
|
+
direction: this.direction || this.autoDirection,
|
108
|
+
};
|
109
|
+
}
|
110
|
+
|
102
111
|
protected render(): TemplateResult<1> {
|
103
112
|
return html`
|
104
113
|
<div
|
105
114
|
part="root"
|
106
|
-
${attr(
|
107
|
-
...this.observedRecord,
|
108
|
-
direction: this.direction || this.autoDirection,
|
109
|
-
})}
|
115
|
+
${attr(this.observedRecord)}
|
110
116
|
class="input-field"
|
111
117
|
>
|
112
118
|
${[
|
@@ -138,6 +144,7 @@ class Select extends Input {
|
|
138
144
|
<label
|
139
145
|
for="${this.makeId}"
|
140
146
|
part="content"
|
147
|
+
direction-outset-place
|
141
148
|
>
|
142
149
|
${htmlSlot()}
|
143
150
|
</label>
|
package/src/components/split.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { type HandlerEvent, attr, tokenList, godown, styles, loop } from "@godown/element";
|
1
|
+
import { type HandlerEvent, attr, tokenList, godown, styles, loop, omit } from "@godown/element";
|
2
2
|
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property, state } from "lit/decorators.js";
|
4
4
|
|
5
5
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
6
|
-
import SuperInput from "../core/super-input.js";
|
6
|
+
import { SuperInput } from "../core/super-input.js";
|
7
7
|
|
8
8
|
const protoName = "split";
|
9
9
|
const cssScope = scopePrefix(protoName);
|
@@ -24,7 +24,6 @@ const cssScope = scopePrefix(protoName);
|
|
24
24
|
@godown(protoName)
|
25
25
|
@styles(css`
|
26
26
|
:host {
|
27
|
-
color: var(${cssGlobalVars.foreground});
|
28
27
|
display: block;
|
29
28
|
border-radius: 1px;
|
30
29
|
width: fit-content;
|
@@ -50,9 +49,10 @@ const cssScope = scopePrefix(protoName);
|
|
50
49
|
width: var(${cssScope}--size);
|
51
50
|
height: var(${cssScope}--size);
|
52
51
|
vertical-align: top;
|
53
|
-
text-align: center;
|
54
|
-
background-color: var(${cssGlobalVars.input}-background);
|
55
52
|
border-radius: inherit;
|
53
|
+
display: inline-flex;
|
54
|
+
align-items: center;
|
55
|
+
justify-content: center;
|
56
56
|
}
|
57
57
|
|
58
58
|
[part="input"] {
|
@@ -64,8 +64,9 @@ const cssScope = scopePrefix(protoName);
|
|
64
64
|
z-index: -1;
|
65
65
|
}
|
66
66
|
|
67
|
-
.focus
|
68
|
-
|
67
|
+
.focus,
|
68
|
+
[part="input-box"]:active {
|
69
|
+
${cssGlobalVars.input}-outline-color: var(${cssGlobalVars.active});
|
69
70
|
}
|
70
71
|
`)
|
71
72
|
class Split extends SuperInput {
|
@@ -87,6 +88,10 @@ class Split extends SuperInput {
|
|
87
88
|
@state()
|
88
89
|
currentValue: (string | void)[] = [];
|
89
90
|
|
91
|
+
get observedRecord(): Record<string, any> {
|
92
|
+
return omit(super.observedRecord, "outline-type");
|
93
|
+
}
|
94
|
+
|
90
95
|
protected render(): TemplateResult<1> {
|
91
96
|
return html`
|
92
97
|
<div
|
@@ -98,6 +103,7 @@ class Split extends SuperInput {
|
|
98
103
|
(index: number) => html`
|
99
104
|
<span
|
100
105
|
part="input-box"
|
106
|
+
outline-type="${this.outlineType}"
|
101
107
|
class="${tokenList({ focus: this.current === index })}"
|
102
108
|
@click="${this.disabled ? null : () => this.focusAt(index)}"
|
103
109
|
>
|
package/src/components/switch.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { attr, godown, styles } from "@godown/element";
|
1
|
+
import { attr, godown, omit, styles } from "@godown/element";
|
2
2
|
import { type TemplateResult, css, html } from "lit";
|
3
|
-
import { property
|
3
|
+
import { property } from "lit/decorators.js";
|
4
4
|
|
5
5
|
import { cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
6
|
-
import SuperInput from "../core/super-input.js";
|
6
|
+
import { SuperInput } from "../core/super-input.js";
|
7
7
|
|
8
8
|
const protoName = "switch";
|
9
9
|
const cssScope = scopePrefix(protoName);
|
@@ -11,9 +11,6 @@ const cssScope = scopePrefix(protoName);
|
|
11
11
|
/**
|
12
12
|
* {@linkcode Switch} renders a switch.
|
13
13
|
*
|
14
|
-
* The switch is rectangular by default,
|
15
|
-
* set the round property to rounded switch.
|
16
|
-
*
|
17
14
|
* @fires change - Fires when the switch is switched.
|
18
15
|
* @category input
|
19
16
|
*/
|
@@ -30,153 +27,124 @@ const cssScope = scopePrefix(protoName);
|
|
30
27
|
${cssScope}-width: 3em;
|
31
28
|
${cssScope}-height: calc(var(${cssScope}-width) / 2);
|
32
29
|
${cssScope}-handle-size: 1.25em;
|
33
|
-
${cssScope}-handle-space:
|
30
|
+
${cssScope}-handle-space: calc(var(${cssScope}-width) / 4 - var(${cssScope}-handle-size) / 2);
|
34
31
|
${cssScope}-transition: .2s ease-in-out;
|
35
|
-
|
32
|
+
border-radius: calc(var(${cssScope}-height) / 2);
|
33
|
+
background: var(${cssGlobalVars.passive});
|
36
34
|
vertical-align: bottom;
|
37
|
-
|
35
|
+
transition: 0.2s ease-in-out;
|
36
|
+
transition-property: background, left;
|
38
37
|
}
|
39
38
|
|
40
|
-
[
|
41
|
-
|
42
|
-
transition: var(${cssScope}-transition);
|
39
|
+
:host([checked]) {
|
40
|
+
background: var(${cssGlobalVars.active});
|
43
41
|
}
|
44
42
|
|
45
43
|
[part="root"] {
|
46
|
-
border-radius: inherit;
|
47
|
-
position: relative;
|
48
44
|
height: inherit;
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
width: 100%;
|
54
|
-
height: 100%;
|
55
|
-
appearance: none;
|
45
|
+
display: flex;
|
46
|
+
align-items: center;
|
47
|
+
position: relative;
|
48
|
+
transition: inherit;
|
56
49
|
}
|
57
50
|
|
58
51
|
[part="handle"] {
|
59
|
-
|
60
|
-
display: inline-flex;
|
52
|
+
display: flex;
|
61
53
|
align-items: center;
|
62
54
|
justify-content: center;
|
63
55
|
position: absolute;
|
56
|
+
transition: inherit;
|
64
57
|
left: 0;
|
65
|
-
|
58
|
+
top: 50%;
|
66
59
|
pointer-events: none;
|
67
|
-
border-radius:
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
border-radius: 100%;
|
61
|
+
background: currentColor;
|
62
|
+
--size: var(${cssScope}-handle-size);
|
63
|
+
width: var(--size);
|
64
|
+
height: var(--size);
|
65
|
+
transform: translateY(-50%) translateX(var(${cssScope}-handle-space));
|
73
66
|
}
|
74
67
|
|
75
68
|
:host([checked]) [part="handle"] {
|
76
69
|
left: 50%;
|
77
70
|
}
|
78
71
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
.rect .false {
|
84
|
-
background: var(${cssGlobalVars.passive});
|
85
|
-
}
|
86
|
-
|
87
|
-
.round [part="handle"] {
|
88
|
-
--size: var(${cssScope}-handle-size);
|
89
|
-
border-radius: 100%;
|
90
|
-
background: var(--godown--input-control);
|
91
|
-
width: var(--size);
|
92
|
-
height: var(--size);
|
93
|
-
margin: var(${cssScope}-handle-space);
|
94
|
-
}
|
95
|
-
|
96
|
-
:host([checked]) .round {
|
97
|
-
background: var(${cssGlobalVars.active});
|
72
|
+
[part="input"] {
|
73
|
+
opacity: 0;
|
74
|
+
width: 100%;
|
75
|
+
height: 100%;
|
98
76
|
}
|
99
77
|
`)
|
100
|
-
class Switch extends SuperInput {
|
78
|
+
class Switch extends SuperInput<boolean> {
|
101
79
|
/**
|
102
|
-
*
|
80
|
+
* @deprecated
|
103
81
|
*/
|
104
|
-
|
105
|
-
round = false;
|
82
|
+
round: boolean;
|
106
83
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
@property({ type: Boolean, reflect: true })
|
111
|
-
checked = false;
|
84
|
+
set checked(v: boolean) {
|
85
|
+
this.value = v;
|
86
|
+
}
|
112
87
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
@property({ type: Boolean, reflect: true })
|
117
|
-
disabled = false;
|
88
|
+
get checked(): boolean {
|
89
|
+
return this.value;
|
90
|
+
}
|
118
91
|
|
119
92
|
/**
|
120
93
|
* Default checked state.
|
121
94
|
*/
|
122
|
-
@property()
|
123
|
-
default =
|
95
|
+
@property({ type: Boolean })
|
96
|
+
default = false;
|
124
97
|
|
125
98
|
/**
|
126
|
-
*
|
99
|
+
* The current value of the switch component. Reflects the "checked" attribute.
|
127
100
|
*/
|
128
|
-
@property()
|
129
|
-
value =
|
101
|
+
@property({ type: Boolean, attribute: "checked", reflect: true })
|
102
|
+
value = false;
|
130
103
|
|
131
|
-
|
132
|
-
|
104
|
+
get observedRecord(): Record<string, any> {
|
105
|
+
return omit(super.observedRecord, "outline-type");
|
106
|
+
}
|
133
107
|
|
134
108
|
protected render(): TemplateResult<1> {
|
135
109
|
return html`
|
136
110
|
<div
|
137
111
|
part="root"
|
138
112
|
${attr(this.observedRecord)}
|
139
|
-
class="
|
113
|
+
class="round"
|
140
114
|
>
|
141
115
|
<input
|
142
116
|
part="input"
|
143
117
|
type="checkbox"
|
144
118
|
?disabled="${this.disabled}"
|
145
|
-
?checked="${this.
|
146
|
-
name="${this.name}"
|
119
|
+
?checked="${this.value}"
|
147
120
|
id="${this.makeId}"
|
148
121
|
@change="${this._handleChange}"
|
149
122
|
/>
|
150
|
-
<span
|
151
|
-
part="handle"
|
152
|
-
class="${this.checked}"
|
153
|
-
></span>
|
123
|
+
<span part="handle"></span>
|
154
124
|
</div>
|
155
125
|
`;
|
156
126
|
}
|
157
127
|
|
158
128
|
reset(): void {
|
159
|
-
this.
|
160
|
-
this._input.checked = this.
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
129
|
+
this.value = this.default;
|
130
|
+
this._input.checked = this.value;
|
131
|
+
}
|
132
|
+
|
133
|
+
protected _connectedInit(): void {
|
134
|
+
if (this.default) {
|
135
|
+
this.value = true;
|
136
|
+
} else {
|
137
|
+
if (this.value) {
|
138
|
+
this.value = true;
|
139
|
+
this.default = true;
|
140
|
+
}
|
170
141
|
}
|
171
142
|
}
|
172
143
|
|
173
144
|
protected _handleChange(): void {
|
174
|
-
|
175
|
-
this.
|
176
|
-
|
177
|
-
|
178
|
-
namevalue(): [string, boolean] {
|
179
|
-
return [this.name, this.checked];
|
145
|
+
const { checked } = this._input;
|
146
|
+
this.value = checked;
|
147
|
+
this.dispatchCustomEvent("change", this.value);
|
180
148
|
}
|
181
149
|
}
|
182
150
|
|
package/src/components/time.ts
CHANGED
@@ -42,13 +42,13 @@ class Time extends GlobalStyle {
|
|
42
42
|
* If there is a value, update every gap or timeout.
|
43
43
|
*/
|
44
44
|
@property({ type: Number })
|
45
|
-
timeout:
|
45
|
+
timeout: number;
|
46
46
|
|
47
47
|
/**
|
48
48
|
* The number of milliseconds that change with each update.
|
49
49
|
*/
|
50
50
|
@property({ type: Number })
|
51
|
-
gap:
|
51
|
+
gap: number;
|
52
52
|
|
53
53
|
protected timeoutId: number;
|
54
54
|
|
@@ -3,7 +3,8 @@ import { type TemplateResult, css, html } from "lit";
|
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
5
|
import { scopePrefix } from "../core/global-style.js";
|
6
|
-
import
|
6
|
+
import { SuperOpenable } from "../core/super-openable.js";
|
7
|
+
import { type DirectionCardinal, type DirectionCorner, directionOutsetPlace } from "../core/direction.js";
|
7
8
|
|
8
9
|
const protoName = "tooltip";
|
9
10
|
const cssScope = scopePrefix(protoName);
|
@@ -19,6 +20,7 @@ const cssScope = scopePrefix(protoName);
|
|
19
20
|
*/
|
20
21
|
@godown(protoName)
|
21
22
|
@styles(
|
23
|
+
directionOutsetPlace,
|
22
24
|
css`
|
23
25
|
:host {
|
24
26
|
${cssScope}--tip-background: inherit;
|
@@ -57,23 +59,6 @@ const cssScope = scopePrefix(protoName);
|
|
57
59
|
pointer-events: none;
|
58
60
|
}
|
59
61
|
`,
|
60
|
-
css`
|
61
|
-
[direction^="top"] [part="tip"] {
|
62
|
-
bottom: 100%;
|
63
|
-
}
|
64
|
-
|
65
|
-
[direction^="bottom"] [part="tip"] {
|
66
|
-
top: 100%;
|
67
|
-
}
|
68
|
-
|
69
|
-
[direction$="right"] [part="tip"] {
|
70
|
-
left: 100%;
|
71
|
-
}
|
72
|
-
|
73
|
-
[direction$="left"] [part="tip"] {
|
74
|
-
right: 100%;
|
75
|
-
}
|
76
|
-
`,
|
77
62
|
)
|
78
63
|
class Tooltip extends SuperOpenable {
|
79
64
|
/**
|
@@ -86,7 +71,7 @@ class Tooltip extends SuperOpenable {
|
|
86
71
|
* Direction of opening the tip.
|
87
72
|
*/
|
88
73
|
@property()
|
89
|
-
direction:
|
74
|
+
direction: DirectionCardinal | DirectionCorner = "top";
|
90
75
|
|
91
76
|
/**
|
92
77
|
* Content alignment.
|
@@ -135,7 +120,10 @@ class Tooltip extends SuperOpenable {
|
|
135
120
|
style="justify-content:${align};align-items:${align}"
|
136
121
|
>
|
137
122
|
${htmlSlot()}
|
138
|
-
<div
|
123
|
+
<div
|
124
|
+
part="tip"
|
125
|
+
direction-outset-place
|
126
|
+
>
|
139
127
|
${this.tip
|
140
128
|
? html`
|
141
129
|
<span class="passive">${this.tip}</span>
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { css, unsafeCSS, type CSSResult } from "lit";
|
2
|
+
|
3
|
+
const insetAlignSelector = unsafeCSS(`[direction-inset-align]`);
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Controls the inset alignment of the element relative to the direction.
|
7
|
+
*
|
8
|
+
* ```html
|
9
|
+
* <div direction="${direction}">
|
10
|
+
* <div direction-inset-align></div>
|
11
|
+
* </div>
|
12
|
+
* ```
|
13
|
+
*/
|
14
|
+
export const directionInsetAlign: CSSResult = css`
|
15
|
+
[direction^="top"] ${insetAlignSelector} {
|
16
|
+
top: 0;
|
17
|
+
}
|
18
|
+
|
19
|
+
[direction^="bottom"] ${insetAlignSelector} {
|
20
|
+
bottom: 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
[direction$="right"] ${insetAlignSelector} {
|
24
|
+
right: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
[direction$="left"] ${insetAlignSelector} {
|
28
|
+
left: 0;
|
29
|
+
}
|
30
|
+
`;
|
31
|
+
|
32
|
+
const outsetPlaceSelector = unsafeCSS(`[direction-outset-place]`);
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Controls the outset placement of the element relative to the direction.
|
36
|
+
*
|
37
|
+
* ```html
|
38
|
+
* <div direction="${direction}">
|
39
|
+
* <div direction-outset-place></div>
|
40
|
+
* </div>
|
41
|
+
* ```
|
42
|
+
*/
|
43
|
+
export const directionOutsetPlace: CSSResult = css`
|
44
|
+
[direction^="top"] ${outsetPlaceSelector} {
|
45
|
+
bottom: 100%;
|
46
|
+
}
|
47
|
+
|
48
|
+
[direction^="bottom"] ${outsetPlaceSelector} {
|
49
|
+
top: 100%;
|
50
|
+
}
|
51
|
+
|
52
|
+
[direction$="right"] ${outsetPlaceSelector} {
|
53
|
+
left: 100%;
|
54
|
+
}
|
55
|
+
|
56
|
+
[direction$="left"] ${outsetPlaceSelector} {
|
57
|
+
right: 100%;
|
58
|
+
}
|
59
|
+
`;
|
60
|
+
|
61
|
+
export type DirectionCardinalX = "left" | "right";
|
62
|
+
export type DirectionCardinalY = "top" | "bottom";
|
63
|
+
export type DirectionCardinal = DirectionCardinalX | DirectionCardinalY;
|
64
|
+
export type DirectionCorner = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
65
|
+
export type DirectionCenter = "center";
|
package/src/core/global-style.ts
CHANGED
@@ -17,8 +17,6 @@ export function variablePrefix(variable: string): CSSResult {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
export const cssGlobalVars: {
|
20
|
-
foreground: CSSResult;
|
21
|
-
background: CSSResult;
|
22
20
|
clipBackground: CSSResult;
|
23
21
|
active: CSSResult;
|
24
22
|
passive: CSSResult;
|
@@ -28,8 +26,6 @@ export const cssGlobalVars: {
|
|
28
26
|
black: CSSResult;
|
29
27
|
color: CSSResult;
|
30
28
|
} = {
|
31
|
-
foreground: scopePrefix("foreground", 2),
|
32
|
-
background: scopePrefix("background", 2),
|
33
29
|
clipBackground: scopePrefix("clip-background", 2),
|
34
30
|
active: scopePrefix("active", 2),
|
35
31
|
passive: scopePrefix("passive", 2),
|
@@ -54,13 +50,11 @@ GlobalStyle.styles = [
|
|
54
50
|
return `${colorKey}:rgb(${rgb});`;
|
55
51
|
}, presetsRGB).join("") +
|
56
52
|
joinProperties([
|
57
|
-
[cssGlobalVars.
|
58
|
-
[cssGlobalVars.
|
59
|
-
[cssGlobalVars.active, `var(${cssGlobalVars._colors.blue[6]})`],
|
60
|
-
[cssGlobalVars.passive, `var(${cssGlobalVars._colors.darkgray[6]})`],
|
53
|
+
[cssGlobalVars.active, `var(${cssGlobalVars._colors.blue[5]})`],
|
54
|
+
[cssGlobalVars.passive, `var(${cssGlobalVars._colors.darkgray[5]})`],
|
61
55
|
[
|
62
56
|
cssGlobalVars.clipBackground,
|
63
|
-
`linear-gradient(to bottom, var(${cssGlobalVars.
|
57
|
+
`linear-gradient(to bottom, var(${cssGlobalVars._colors.lightgray[0]}), var(${cssGlobalVars._colors.darkgray[5]}))`,
|
64
58
|
],
|
65
59
|
]) +
|
66
60
|
"}",
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { css, unsafeCSS, type CSSResult } from "lit";
|
2
|
+
|
3
|
+
type OutlineVars = {
|
4
|
+
width: string | CSSResult;
|
5
|
+
color: string | CSSResult;
|
6
|
+
};
|
7
|
+
|
8
|
+
/**
|
9
|
+
* The `OutlineBuilder` class is responsible for generating CSS styles for various types of outlines.
|
10
|
+
*/
|
11
|
+
export class OutlineBuilder {
|
12
|
+
css: CSSResult;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @param vars.width The width variable of the outline.
|
16
|
+
* @param vars.color The color variable of the outline.
|
17
|
+
*/
|
18
|
+
constructor(vars: OutlineVars) {
|
19
|
+
const width = unsafeCSS(vars.width);
|
20
|
+
const color = unsafeCSS(vars.color);
|
21
|
+
this.css = css`
|
22
|
+
[outline-type="outline"],
|
23
|
+
[outline-type="outline-inset"] {
|
24
|
+
outline-width: var(${width});
|
25
|
+
outline-color: var(${color});
|
26
|
+
outline-style: solid;
|
27
|
+
}
|
28
|
+
|
29
|
+
[outline-type="outline-inset"] {
|
30
|
+
outline-offset: calc(-1 * var(${width}));
|
31
|
+
}
|
32
|
+
|
33
|
+
[outline-type="box-shadow"] {
|
34
|
+
box-shadow: 0 0 0 var(${width}) var(${color});
|
35
|
+
}
|
36
|
+
|
37
|
+
[outline-type="box-shadow-inset"] {
|
38
|
+
box-shadow: inset 0 0 0 var(${width}) var(${color});
|
39
|
+
}
|
40
|
+
|
41
|
+
[outline-type="border"] {
|
42
|
+
border-width: var(${width});
|
43
|
+
border-color: var(${color});
|
44
|
+
border-style: solid;
|
45
|
+
}
|
46
|
+
`;
|
47
|
+
}
|
48
|
+
|
49
|
+
get styleSheet(): CSSStyleSheet {
|
50
|
+
return this.css.styleSheet;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
export type OutlineType = "outline" | "outline-inset" | "box-shadow" | "box-shadow-inset" | "border";
|
package/src/core/super-anchor.ts
CHANGED
@@ -23,12 +23,13 @@ import { GlobalStyle } from "./global-style.js";
|
|
23
23
|
text-decoration: inherit;
|
24
24
|
}
|
25
25
|
`)
|
26
|
-
class SuperAnchor extends GlobalStyle {
|
26
|
+
abstract class SuperAnchor extends GlobalStyle {
|
27
27
|
/**
|
28
28
|
* A element href.
|
29
29
|
*/
|
30
30
|
@property()
|
31
31
|
href: string;
|
32
|
+
|
32
33
|
/**
|
33
34
|
* A element target.
|
34
35
|
*/
|
@@ -53,7 +54,7 @@ class SuperAnchor extends GlobalStyle {
|
|
53
54
|
`;
|
54
55
|
}
|
55
56
|
|
56
|
-
protected _handleClick(_: MouseEvent): void
|
57
|
+
protected abstract _handleClick(_: MouseEvent): void;
|
57
58
|
}
|
58
59
|
|
59
60
|
export default SuperAnchor;
|