godown 3.11.2 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/godown+lit.iife.js +12 -13
- package/build/godown+lit.iife.js.map +1 -1
- package/build/godown+lit.js +11 -12
- package/build/godown+lit.js.map +1 -1
- package/build/godown+lit.umd.js +12 -13
- package/build/godown+lit.umd.js.map +1 -1
- package/build/godown.iife.js +9 -8
- package/build/godown.iife.js.map +1 -0
- package/build/godown.js +7 -7
- package/build/godown.js.map +1 -1
- package/build/godown.umd.js +8 -8
- package/build/godown.umd.js.map +1 -1
- package/custom-elements.json +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/internal/global-style.d.ts.map +1 -1
- package/internal/global-style.js +1 -1
- package/internal/global-style.js.map +1 -1
- package/internal/popover.d.ts +3 -0
- package/internal/popover.d.ts.map +1 -0
- package/internal/popover.js +2 -0
- package/internal/popover.js.map +1 -0
- package/internal/reset-style.d.ts +3 -0
- package/internal/reset-style.d.ts.map +1 -0
- package/internal/reset-style.js +2 -0
- package/internal/reset-style.js.map +1 -0
- package/internal/ring.d.ts +1 -0
- package/internal/ring.d.ts.map +1 -1
- package/internal/ring.js +1 -1
- package/internal/ring.js.map +1 -1
- package/internal/super-input.d.ts +1 -4
- package/internal/super-input.d.ts.map +1 -1
- package/internal/super-input.js +1 -1
- package/internal/super-input.js.map +1 -1
- package/internal/utils.d.ts +2 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +2 -0
- package/internal/utils.js.map +1 -0
- package/package.json +3 -4
- package/popover.d.ts +2 -0
- package/popover.d.ts.map +1 -0
- package/popover.js +2 -0
- package/popover.js.map +1 -0
- package/src/index.ts +1 -0
- package/src/internal/global-style.ts +6 -34
- package/src/internal/popover.ts +64 -0
- package/src/internal/reset-style.ts +63 -0
- package/src/internal/ring.ts +3 -2
- package/src/internal/super-input.ts +2 -33
- package/src/internal/utils.ts +10 -0
- package/src/popover.ts +1 -0
- package/src/web-components/alert/component.ts +5 -4
- package/src/web-components/avatar/component.ts +1 -0
- package/src/web-components/button/component.ts +22 -18
- package/src/web-components/card/component.ts +3 -2
- package/src/web-components/chip/component.ts +1 -3
- package/src/web-components/details/component.ts +28 -17
- package/src/web-components/dialog/component.ts +51 -67
- package/src/web-components/heading/component.ts +0 -1
- package/src/web-components/input/component.ts +38 -30
- package/src/web-components/layout/component.ts +1 -0
- package/src/web-components/link/component.ts +0 -2
- package/src/web-components/popover/component.ts +172 -0
- package/src/web-components/popover/definition.ts +11 -0
- package/src/web-components/range/component.ts +2 -1
- package/src/web-components/rotate/component.ts +0 -1
- package/src/web-components/select/component.ts +109 -173
- package/src/web-components/split/component.ts +2 -2
- package/src/web-components/switch/component.ts +2 -1
- package/src/web-components/tabs/component.ts +99 -100
- package/src/web-components/text/component.ts +47 -52
- package/src/web-components/time/component.ts +5 -15
- package/src/web-components/tooltip/component.ts +44 -111
- package/vscode.css-custom-data.json +1 -1
- package/vscode.html-custom-data.json +1 -1
- package/web-components/alert/component.d.ts.map +1 -1
- package/web-components/alert/component.js +1 -1
- package/web-components/alert/component.js.map +1 -1
- package/web-components/avatar/component.d.ts.map +1 -1
- package/web-components/avatar/component.js +1 -1
- package/web-components/avatar/component.js.map +1 -1
- package/web-components/button/component.d.ts.map +1 -1
- package/web-components/button/component.js +1 -1
- package/web-components/button/component.js.map +1 -1
- package/web-components/card/component.d.ts.map +1 -1
- package/web-components/card/component.js +1 -1
- package/web-components/card/component.js.map +1 -1
- package/web-components/chip/component.d.ts +1 -3
- package/web-components/chip/component.d.ts.map +1 -1
- package/web-components/chip/component.js.map +1 -1
- package/web-components/details/component.d.ts +9 -13
- package/web-components/details/component.d.ts.map +1 -1
- package/web-components/details/component.js +1 -1
- package/web-components/details/component.js.map +1 -1
- package/web-components/dialog/component.d.ts +12 -14
- package/web-components/dialog/component.d.ts.map +1 -1
- package/web-components/dialog/component.js +1 -1
- package/web-components/dialog/component.js.map +1 -1
- package/web-components/heading/component.d.ts.map +1 -1
- package/web-components/heading/component.js +1 -1
- package/web-components/heading/component.js.map +1 -1
- package/web-components/input/component.d.ts +3 -1
- package/web-components/input/component.d.ts.map +1 -1
- package/web-components/input/component.js +1 -1
- package/web-components/input/component.js.map +1 -1
- package/web-components/layout/component.d.ts.map +1 -1
- package/web-components/layout/component.js +1 -1
- package/web-components/layout/component.js.map +1 -1
- package/web-components/link/component.d.ts.map +1 -1
- package/web-components/link/component.js +1 -1
- package/web-components/link/component.js.map +1 -1
- package/web-components/popover/component.d.ts +35 -0
- package/web-components/popover/component.d.ts.map +1 -0
- package/web-components/popover/component.js +2 -0
- package/web-components/popover/component.js.map +1 -0
- package/web-components/popover/definition.d.ts +8 -0
- package/web-components/popover/definition.d.ts.map +1 -0
- package/web-components/popover/definition.js +2 -0
- package/web-components/popover/definition.js.map +1 -0
- package/web-components/range/component.d.ts.map +1 -1
- package/web-components/range/component.js +1 -1
- package/web-components/range/component.js.map +1 -1
- package/web-components/rotate/component.d.ts.map +1 -1
- package/web-components/rotate/component.js.map +1 -1
- package/web-components/select/component.d.ts +11 -27
- package/web-components/select/component.d.ts.map +1 -1
- package/web-components/select/component.js +1 -1
- package/web-components/select/component.js.map +1 -1
- package/web-components/split/component.js +1 -1
- package/web-components/split/component.js.map +1 -1
- package/web-components/switch/component.d.ts.map +1 -1
- package/web-components/switch/component.js +1 -1
- package/web-components/switch/component.js.map +1 -1
- package/web-components/tabs/component.d.ts +18 -25
- package/web-components/tabs/component.d.ts.map +1 -1
- package/web-components/tabs/component.js +1 -1
- package/web-components/tabs/component.js.map +1 -1
- package/web-components/text/component.d.ts +4 -7
- package/web-components/text/component.d.ts.map +1 -1
- package/web-components/text/component.js +1 -1
- package/web-components/text/component.js.map +1 -1
- package/web-components/time/component.d.ts +2 -2
- package/web-components/time/component.d.ts.map +1 -1
- package/web-components/time/component.js +1 -1
- package/web-components/time/component.js.map +1 -1
- package/web-components/tooltip/component.d.ts +15 -39
- package/web-components/tooltip/component.d.ts.map +1 -1
- package/web-components/tooltip/component.js +1 -1
- package/web-components/tooltip/component.js.map +1 -1
- package/web-types.json +1 -1
- package/internal/direction.d.ts +0 -27
- package/internal/direction.d.ts.map +0 -1
- package/internal/direction.js +0 -2
- package/internal/direction.js.map +0 -1
- package/internal/super-openable.d.ts +0 -15
- package/internal/super-openable.d.ts.map +0 -1
- package/internal/super-openable.js +0 -2
- package/internal/super-openable.js.map +0 -1
- package/src/internal/direction.ts +0 -65
- package/src/internal/super-openable.ts +0 -34
@@ -2,52 +2,32 @@ import { attr, godown, htmlSlot, StyleController, styles, tokenList } from "@god
|
|
2
2
|
import { cssGlobalVars, GlobalStyle, scopePrefix } from "../../internal/global-style.js";
|
3
3
|
import { css, html, type TemplateResult } from "lit";
|
4
4
|
import { property, queryAll } from "lit/decorators.js";
|
5
|
-
import { RingBuilder, type RingType } from "../../internal/ring.js";
|
5
|
+
import { RingBuilder, ringTypeAttribute, type RingType } from "../../internal/ring.js";
|
6
6
|
|
7
7
|
const protoName = "tabs";
|
8
8
|
const cssScope = scopePrefix(protoName);
|
9
9
|
|
10
|
-
const
|
10
|
+
const hoverToken = "hover";
|
11
11
|
|
12
12
|
/**
|
13
13
|
* {@linkcode Tabs} used to render a set of tabs.
|
14
14
|
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
* When "useSlot" is enabled, each item in "tabs" becomes a named slot with the same name as itself,
|
18
|
-
* while for non-slot tabs, the content is rendered as a horizontally padded string.
|
19
|
-
*
|
20
|
-
* When "mouseenter" and "mouseleave" are triggered on an individual tab, the indicator will move.
|
21
|
-
*
|
22
|
-
* The moving indicator will start from the position of the item that was last entered.
|
23
|
-
*
|
24
|
-
* If the pointer moves out of the root element or the element is connected to the document,
|
25
|
-
* the starting position of the indicator will be regarded as the current selection.
|
26
|
-
*
|
27
|
-
* Apply "flex-direction: column" to the tabs to arrange them vertically.
|
28
|
-
*
|
29
|
-
* @csspart root - The root element.
|
30
|
-
* @csspart item - The tab items.
|
31
|
-
* @csspart indicator - The indicator.
|
32
|
-
* @csspart selected - The selected tab item.
|
33
|
-
* @csspart hover - The hovered tab item.
|
34
|
-
* @fires select - Fires when the tab is selected.
|
15
|
+
* @fires select - Fires when the tab index is changed.
|
35
16
|
* @category display
|
36
17
|
*/
|
37
18
|
@godown(protoName)
|
38
19
|
@styles(css`
|
39
20
|
:host {
|
40
21
|
${cssScope}--indicator-background: var(${cssGlobalVars.passive});
|
41
|
-
${cssScope}--
|
42
|
-
|
43
|
-
transition: 0.3s ease-in-out;
|
44
|
-
width: fit-content;
|
22
|
+
${cssScope}--selected-background: var(${cssGlobalVars.passive});
|
23
|
+
transition: 0.2s ease-in-out;
|
45
24
|
display: flex;
|
46
25
|
cursor: default;
|
47
26
|
}
|
48
27
|
|
49
28
|
[part="root"] {
|
50
|
-
|
29
|
+
gap: 0.25em;
|
30
|
+
padding: 0.25em;
|
51
31
|
position: relative;
|
52
32
|
z-index: 1;
|
53
33
|
display: flex;
|
@@ -56,14 +36,10 @@ const mouseEnterAddedToken = "hover";
|
|
56
36
|
border-radius: inherit;
|
57
37
|
transition: inherit;
|
58
38
|
transition-property: width, transform, opacity;
|
59
|
-
gap: var(${cssScope}--space);
|
60
|
-
}
|
61
|
-
|
62
|
-
[useslot] [part~="item"] {
|
63
|
-
padding: 0;
|
64
39
|
}
|
65
40
|
|
66
41
|
[part~="item"] {
|
42
|
+
position: relative;
|
67
43
|
width: 100%;
|
68
44
|
display: block;
|
69
45
|
padding: 0 0.25em;
|
@@ -74,12 +50,11 @@ const mouseEnterAddedToken = "hover";
|
|
74
50
|
transition-property: inherit;
|
75
51
|
}
|
76
52
|
|
77
|
-
[part="indicator"]
|
53
|
+
[part="indicator"],
|
54
|
+
[part~="item"]::after {
|
78
55
|
width: 100%;
|
79
56
|
height: 100%;
|
80
57
|
inset: 0;
|
81
|
-
opacity: 0;
|
82
|
-
z-index: -1;
|
83
58
|
position: absolute;
|
84
59
|
transition: inherit;
|
85
60
|
border-radius: inherit;
|
@@ -87,27 +62,58 @@ const mouseEnterAddedToken = "hover";
|
|
87
62
|
background: var(${cssScope}--indicator-background);
|
88
63
|
}
|
89
64
|
|
90
|
-
[part
|
91
|
-
|
65
|
+
[part="indicator"] {
|
66
|
+
opacity: 0;
|
67
|
+
z-index: -1;
|
68
|
+
}
|
69
|
+
|
70
|
+
[part~="item"]::after {
|
71
|
+
z-index: -2;
|
72
|
+
}
|
73
|
+
|
74
|
+
[indicator="underline"] [part="indicator"],
|
75
|
+
[indicator="underline"] [part~="item"]::after {
|
76
|
+
top: 100%;
|
77
|
+
height: 0.15em;
|
78
|
+
border-radius: 0.075em;
|
79
|
+
margin-top: 0.15em;
|
80
|
+
}
|
81
|
+
|
82
|
+
[part~="selected"]::after {
|
83
|
+
content: "";
|
84
|
+
background: var(${cssScope}--selected-background);
|
92
85
|
}
|
93
86
|
|
94
|
-
[part~="selected"] [part="indicator"],
|
95
87
|
[part~="hover"] [part="indicator"] {
|
96
88
|
opacity: 1;
|
97
89
|
}
|
98
90
|
`)
|
99
91
|
class Tabs extends GlobalStyle {
|
100
|
-
@property({ attribute:
|
92
|
+
@property({ attribute: ringTypeAttribute })
|
101
93
|
ringType: RingType = "border";
|
102
94
|
|
103
95
|
/**
|
104
|
-
*
|
96
|
+
* If it is "select", the indicator moves from the selected content to the hover position.
|
97
|
+
*
|
98
|
+
* If it is "previous", the indicator moves from the last moved position to the hover position.
|
99
|
+
*
|
100
|
+
* If "none", the indicator will not move.
|
101
|
+
*/
|
102
|
+
@property()
|
103
|
+
beginning: "selected" | "previous" | "none" = "selected";
|
104
|
+
|
105
|
+
/**
|
106
|
+
* The behavior of the indicator:
|
107
|
+
*
|
108
|
+
* If "background", its size will be consistent with that of a single tab.
|
109
|
+
*
|
110
|
+
* If "underline", an underline will be displayed at the bottom of the tab.
|
105
111
|
*/
|
106
|
-
@property(
|
107
|
-
|
112
|
+
@property()
|
113
|
+
indicator: "background" | "underline" = "background";
|
108
114
|
|
109
115
|
/**
|
110
|
-
*
|
116
|
+
* Tab list or slot list.
|
111
117
|
*/
|
112
118
|
@property({ type: Array })
|
113
119
|
tabs: string[];
|
@@ -118,7 +124,7 @@ class Tabs extends GlobalStyle {
|
|
118
124
|
@property({ type: Number })
|
119
125
|
index = 0;
|
120
126
|
|
121
|
-
protected
|
127
|
+
protected previousIndex: number;
|
122
128
|
|
123
129
|
@queryAll("[part~=item]")
|
124
130
|
protected _items: HTMLCollectionOf<HTMLLIElement>;
|
@@ -138,24 +144,20 @@ class Tabs extends GlobalStyle {
|
|
138
144
|
${attr(this.observedRecord)}
|
139
145
|
@mouseleave="${this._handleMouseLeave}"
|
140
146
|
>
|
141
|
-
${this.tabs?.map(
|
142
|
-
tab
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
<div part="indicator"></div>
|
156
|
-
</li>
|
157
|
-
`
|
158
|
-
: "",
|
147
|
+
${this.tabs?.map(
|
148
|
+
(tab, index) => html`
|
149
|
+
<li
|
150
|
+
part="${tokenList("item", this.index === index && "selected")}"
|
151
|
+
@mouseenter=${() => {
|
152
|
+
this.move(this.previousIndex, index);
|
153
|
+
this.previousIndex = index;
|
154
|
+
}}
|
155
|
+
@click=${() => this.select(index)}
|
156
|
+
>
|
157
|
+
${htmlSlot(tab, tab)}
|
158
|
+
<div part="indicator"></div>
|
159
|
+
</li>
|
160
|
+
`,
|
159
161
|
)}
|
160
162
|
</ul>
|
161
163
|
`;
|
@@ -163,65 +165,62 @@ class Tabs extends GlobalStyle {
|
|
163
165
|
|
164
166
|
connectedCallback(): void {
|
165
167
|
super.connectedCallback();
|
166
|
-
this.
|
168
|
+
this.previousIndex = this.beginning === "selected" ? this.index : -1;
|
167
169
|
}
|
168
170
|
|
169
171
|
protected _handleMouseLeave(): void {
|
170
|
-
const lastItem = this._items[this.
|
172
|
+
const lastItem = this._items[this.previousIndex];
|
171
173
|
if (lastItem) {
|
172
|
-
lastItem.part.remove(
|
174
|
+
lastItem.part.remove(hoverToken);
|
173
175
|
}
|
174
|
-
this.
|
176
|
+
this.previousIndex = this.beginning === "selected" ? this.index : -1;
|
175
177
|
}
|
176
178
|
|
177
|
-
move(
|
178
|
-
if (
|
179
|
+
move(sourceIndex: number, targetIndex: number): void {
|
180
|
+
if (sourceIndex === targetIndex) {
|
179
181
|
return;
|
180
182
|
}
|
181
183
|
const { _items, _indicators } = this;
|
182
|
-
const
|
183
|
-
if (!
|
184
|
+
const targetElement = _items[targetIndex];
|
185
|
+
if (!targetElement) {
|
184
186
|
return;
|
185
187
|
}
|
186
|
-
|
187
|
-
const fromItem = _items[
|
188
|
+
targetElement.part.add(hoverToken);
|
189
|
+
const fromItem = _items[sourceIndex];
|
188
190
|
if (!fromItem) {
|
189
191
|
return;
|
190
192
|
}
|
191
|
-
fromItem.part.remove(
|
192
|
-
|
193
|
-
const fromIndicator = _indicators[from];
|
194
|
-
if (!toIndicator || !fromIndicator) {
|
193
|
+
fromItem.part.remove(hoverToken);
|
194
|
+
if (this.beginning === "none") {
|
195
195
|
return;
|
196
196
|
}
|
197
|
-
const
|
198
|
-
const
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
const {
|
204
|
-
const
|
205
|
-
|
206
|
-
|
207
|
-
style
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
197
|
+
const targetIndicator = _indicators[targetIndex];
|
198
|
+
const sourceIndicator = _indicators[sourceIndex];
|
199
|
+
if (!targetIndicator || !sourceIndicator) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
const { x: sourceX, y: sourceY, width: sourceWidth } = sourceIndicator.getBoundingClientRect();
|
203
|
+
const { x, y } = targetIndicator.getBoundingClientRect();
|
204
|
+
const transformX = sourceX - x;
|
205
|
+
const transformY = sourceY - y;
|
206
|
+
|
207
|
+
const { style: targetStyle } = targetIndicator;
|
208
|
+
const { style: sourceStyle } = sourceIndicator;
|
209
|
+
|
210
|
+
targetStyle.transform = `translate3d(${transformX}px,${transformY}px,0)`;
|
211
|
+
targetStyle.width = `${sourceWidth}px`;
|
212
|
+
targetStyle.transition = sourceStyle.transition = "none";
|
213
|
+
targetIndicator.getBoundingClientRect();
|
214
|
+
targetStyle.width = targetStyle.transform = targetStyle.transition = sourceStyle.transition = "";
|
213
215
|
}
|
214
216
|
|
215
217
|
select(selected: number): void {
|
216
|
-
const { index,
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
this.dispatchCustomEvent("select", selected);
|
221
|
-
this.move(_lastIndex, selected);
|
222
|
-
this._lastIndex = selected;
|
223
|
-
if (index in tabs && (tabs[index] || useSlot)) {
|
218
|
+
const { index, previousIndex } = this;
|
219
|
+
this.move(previousIndex, selected);
|
220
|
+
if (selected !== index) {
|
221
|
+
this.previousIndex = selected;
|
224
222
|
this.index = selected;
|
223
|
+
this.dispatchCustomEvent("select", selected);
|
225
224
|
}
|
226
225
|
}
|
227
226
|
}
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import { godown, htmlSlot, styles } from "@godown/element";
|
2
2
|
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
|
-
import { GlobalStyle, cssGlobalVars
|
5
|
+
import { GlobalStyle, cssGlobalVars } from "../../internal/global-style.js";
|
6
6
|
|
7
7
|
const protoName = "text";
|
8
8
|
|
9
|
-
const cssScope = scopePrefix(protoName);
|
10
|
-
|
11
9
|
/**
|
12
10
|
* {@linkcode Text} renders text.
|
13
11
|
*
|
@@ -15,74 +13,71 @@ const cssScope = scopePrefix(protoName);
|
|
15
13
|
*/
|
16
14
|
@godown(protoName)
|
17
15
|
@styles(css`
|
18
|
-
:host {
|
19
|
-
${
|
20
|
-
${cssScope}--color-hover: currentColor;
|
21
|
-
${cssScope}--color-active: currentColor;
|
16
|
+
:host([clip]) {
|
17
|
+
background: var(${cssGlobalVars.backgroundClip});
|
22
18
|
display: inline-block;
|
23
|
-
|
24
|
-
|
19
|
+
color: transparent;
|
20
|
+
-webkit-text-fill-color: transparent;
|
21
|
+
background-clip: text;
|
22
|
+
-webkit-background-clip: text;
|
25
23
|
}
|
26
24
|
|
27
|
-
[
|
25
|
+
:host([nowrap]) {
|
28
26
|
white-space: nowrap;
|
29
|
-
vertical-align: bottom;
|
30
|
-
display: inline-block;
|
31
|
-
text-overflow: inherit;
|
32
|
-
overflow-wrap: inherit;
|
33
|
-
overflow: hidden;
|
34
|
-
color: var(${cssScope}--color);
|
35
27
|
}
|
36
28
|
|
37
|
-
[
|
38
|
-
|
29
|
+
:host([italic]) {
|
30
|
+
font-style: italic;
|
39
31
|
}
|
40
32
|
|
41
|
-
[
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
.active:active,
|
47
|
-
.always {
|
48
|
-
text-decoration: underline;
|
33
|
+
:host([truncate]),
|
34
|
+
:host([truncate]) ::slotted(*) {
|
35
|
+
max-width: 100%;
|
36
|
+
overflow: hidden;
|
37
|
+
text-overflow: ellipsis;
|
49
38
|
}
|
50
39
|
|
51
|
-
|
52
|
-
text-decoration:
|
40
|
+
:host([strikethrough]) {
|
41
|
+
text-decoration: line-through;
|
53
42
|
}
|
54
43
|
|
55
|
-
[
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
-webkit-background-clip: text;
|
44
|
+
:host([underline=""]),
|
45
|
+
:host([underline="always"]),
|
46
|
+
:host(:hover[underline="hover"]),
|
47
|
+
:host(:active[underline="active"]),
|
48
|
+
:host(:focus[underline="focus"]) {
|
49
|
+
text-decoration: underline;
|
62
50
|
}
|
63
51
|
`)
|
64
52
|
class Text extends GlobalStyle {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
53
|
+
@property({
|
54
|
+
converter: {
|
55
|
+
fromAttribute(value) {
|
56
|
+
return value === "" ? true : value;
|
57
|
+
},
|
58
|
+
toAttribute(value) {
|
59
|
+
return value === false ? null : value === true ? "" : value;
|
60
|
+
},
|
61
|
+
},
|
62
|
+
reflect: true,
|
63
|
+
})
|
64
|
+
underline: "none" | "hover" | "active" | "always" | boolean = "none";
|
65
|
+
|
66
|
+
@property({ type: Boolean, reflect: true })
|
67
|
+
nowrap = false;
|
68
|
+
|
69
|
+
@property({ type: Boolean, reflect: true })
|
70
|
+
italic = false;
|
71
|
+
|
72
|
+
@property({ type: Boolean, reflect: true })
|
73
|
+
truncate = false;
|
70
74
|
|
71
|
-
|
72
|
-
* Set background-clip to text.
|
73
|
-
*/
|
74
|
-
@property({ type: Boolean })
|
75
|
+
@property({ type: Boolean, reflect: true })
|
75
76
|
clip = false;
|
76
77
|
|
77
78
|
protected render(): TemplateResult<1> {
|
78
79
|
return html`
|
79
|
-
<
|
80
|
-
part="root"
|
81
|
-
${attr(this.observedRecord)}
|
82
|
-
class="${tokenList(this.underline)}"
|
83
|
-
>
|
84
|
-
${htmlSlot()}
|
85
|
-
</span>
|
80
|
+
<p part="root">${htmlSlot()}</p>
|
86
81
|
`;
|
87
82
|
}
|
88
83
|
}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { attr, godown
|
1
|
+
import { attr, godown } from "@godown/element";
|
2
2
|
import fmtime from "fmtime";
|
3
|
-
import { type PropertyValues, type TemplateResult,
|
3
|
+
import { type PropertyValues, type TemplateResult, html } from "lit";
|
4
4
|
import { property } from "lit/decorators.js";
|
5
5
|
|
6
|
-
import
|
6
|
+
import Text from "../text/component.js";
|
7
7
|
|
8
8
|
const protoName = "time";
|
9
9
|
|
@@ -14,12 +14,7 @@ const protoName = "time";
|
|
14
14
|
* @category display
|
15
15
|
*/
|
16
16
|
@godown(protoName)
|
17
|
-
|
18
|
-
:host {
|
19
|
-
text-align: center;
|
20
|
-
}
|
21
|
-
`)
|
22
|
-
class Time extends GlobalStyle {
|
17
|
+
class Time extends Text {
|
23
18
|
/**
|
24
19
|
* Escape symbol.
|
25
20
|
*/
|
@@ -54,12 +49,7 @@ class Time extends GlobalStyle {
|
|
54
49
|
|
55
50
|
protected render(): TemplateResult<1> {
|
56
51
|
return html`
|
57
|
-
<
|
58
|
-
part="root"
|
59
|
-
${attr(this.observedRecord)}
|
60
|
-
>
|
61
|
-
${fmtime(this.format, this.time, this.escape)}
|
62
|
-
</span>
|
52
|
+
<p part="root">${fmtime(this.format, this.time, this.escape)}</p>
|
63
53
|
`;
|
64
54
|
}
|
65
55
|
|
@@ -1,138 +1,71 @@
|
|
1
|
-
import {
|
2
|
-
import { type TemplateResult,
|
1
|
+
import { godown, htmlSlot } from "@godown/element";
|
2
|
+
import { type TemplateResult, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
|
-
import
|
6
|
-
import { SuperOpenable } from "../../internal/super-openable.js";
|
7
|
-
import { type DirectionCardinal, type DirectionCorner, directionOutsetPlace } from "../../internal/direction.js";
|
5
|
+
import Popover from "../popover/component.js";
|
8
6
|
|
9
7
|
const protoName = "tooltip";
|
10
|
-
const cssScope = scopePrefix(protoName);
|
11
8
|
|
12
9
|
/**
|
13
|
-
* {@linkcode Tooltip}
|
10
|
+
* {@linkcode Tooltip} is similar to {@linkcode Popover}.
|
14
11
|
*
|
15
|
-
*
|
12
|
+
* It listens for the mouseenter event and displays the tip or popover after a specified delay.
|
16
13
|
*
|
17
|
-
*
|
18
|
-
*
|
14
|
+
* When it is clicked or the mouseleave event occurs followed by another delay, closes the tip.
|
15
|
+
*
|
16
|
+
* @fires toggle - Fired when the popover is toggled.
|
17
|
+
* @slot tip - Tip content.
|
18
|
+
* @slot - Tip trigger.
|
19
19
|
* @category feedback
|
20
20
|
*/
|
21
21
|
@godown(protoName)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
:host {
|
26
|
-
${cssScope}--tip-background: inherit;
|
27
|
-
width: fit-content;
|
28
|
-
}
|
29
|
-
|
30
|
-
:host,
|
31
|
-
[part="root"] {
|
32
|
-
display: inline-flex;
|
33
|
-
}
|
34
|
-
|
35
|
-
[part="root"] {
|
36
|
-
position: relative;
|
37
|
-
transition: inherit;
|
38
|
-
border-radius: inherit;
|
39
|
-
}
|
40
|
-
|
41
|
-
[part="tip"] {
|
42
|
-
width: fit-content;
|
43
|
-
height: fit-content;
|
44
|
-
position: absolute;
|
45
|
-
visibility: hidden;
|
46
|
-
transition: inherit;
|
47
|
-
user-select: none;
|
48
|
-
}
|
49
|
-
|
50
|
-
:host([open]) [part="tip"] {
|
51
|
-
visibility: visible;
|
52
|
-
}
|
22
|
+
class Tooltip extends Popover {
|
23
|
+
action: "hide";
|
24
|
+
span: "span" | "isolated";
|
53
25
|
|
54
|
-
.passive {
|
55
|
-
background: var(${cssScope}--tip-background);
|
56
|
-
}
|
57
|
-
|
58
|
-
[propagation] [part="tip"] {
|
59
|
-
pointer-events: none;
|
60
|
-
}
|
61
|
-
`,
|
62
|
-
)
|
63
|
-
class Tooltip extends SuperOpenable {
|
64
|
-
/**
|
65
|
-
* Tip text, if there is a value, the slot will be ignored.
|
66
|
-
*/
|
67
26
|
@property()
|
68
27
|
tip: string;
|
69
28
|
|
70
|
-
|
71
|
-
|
72
|
-
*/
|
73
|
-
@property()
|
74
|
-
direction: DirectionCardinal | DirectionCorner = "top";
|
75
|
-
|
76
|
-
/**
|
77
|
-
* Content alignment.
|
78
|
-
*/
|
79
|
-
@property()
|
80
|
-
align: "center" | "flex-start" | "flex-end" | "start" | "end" = "center";
|
81
|
-
|
82
|
-
/**
|
83
|
-
* If true, allow penetration of the tip.
|
84
|
-
*/
|
85
|
-
@property({ type: Boolean })
|
86
|
-
propagation = false;
|
87
|
-
|
88
|
-
/**
|
89
|
-
* How can tips be triggered.
|
90
|
-
*
|
91
|
-
* If `focus`, element will be focusable, open tip when focused.
|
92
|
-
*
|
93
|
-
* If `hover`, element will open tip when hovered.
|
94
|
-
*
|
95
|
-
* @default "hover"
|
96
|
-
*/
|
97
|
-
@property()
|
98
|
-
type: "hover" | "focus" = "hover";
|
99
|
-
|
100
|
-
static aligns = {
|
101
|
-
start: "flex-start",
|
102
|
-
end: "flex-end",
|
103
|
-
center: "center",
|
104
|
-
"flex-start": "flex-start",
|
105
|
-
"flex-end": "flex-end",
|
106
|
-
};
|
29
|
+
@property({ type: Number })
|
30
|
+
delay = 300;
|
107
31
|
|
108
32
|
protected render(): TemplateResult<1> {
|
109
|
-
const align = Tooltip.aligns[this.align] || "inherit";
|
110
|
-
const isFocusable = this.type === "focus";
|
111
33
|
return html`
|
112
|
-
<div
|
113
|
-
part="root"
|
114
|
-
${attr(this.observedRecord)}
|
115
|
-
tabindex="${isFocusable ? 0 : -1}"
|
116
|
-
@focus="${isFocusable ? () => (this.open = true) : null}"
|
117
|
-
@blur="${isFocusable ? () => (this.open = false) : null}"
|
118
|
-
@mouseenter="${isFocusable ? null : () => (this.open = true)}"
|
119
|
-
@mouseleave="${isFocusable ? null : () => (this.open = false)}"
|
120
|
-
style="justify-content:${align};align-items:${align}"
|
121
|
-
>
|
122
|
-
${htmlSlot()}
|
34
|
+
<div part="root">
|
123
35
|
<div
|
124
|
-
part="
|
125
|
-
|
36
|
+
part="trigger"
|
37
|
+
@click=${this.hide}
|
126
38
|
>
|
127
|
-
${
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
39
|
+
${htmlSlot()}
|
40
|
+
</div>
|
41
|
+
<div
|
42
|
+
part="popover"
|
43
|
+
popover="manual"
|
44
|
+
>
|
45
|
+
${htmlSlot("tip", this.tip)}
|
132
46
|
</div>
|
133
47
|
</div>
|
134
48
|
`;
|
135
49
|
}
|
50
|
+
|
51
|
+
_hoverTimeout: number;
|
52
|
+
_leaveTimeout: number;
|
53
|
+
|
54
|
+
connectedCallback(): void {
|
55
|
+
super.connectedCallback();
|
56
|
+
this.events.add(this, "mouseenter", () => {
|
57
|
+
clearTimeout(this._leaveTimeout);
|
58
|
+
this._hoverTimeout = setTimeout(() => {
|
59
|
+
this.show();
|
60
|
+
}, this.delay);
|
61
|
+
});
|
62
|
+
this.events.add(this, "mouseleave", () => {
|
63
|
+
clearTimeout(this._hoverTimeout);
|
64
|
+
this._leaveTimeout = setTimeout(() => {
|
65
|
+
this.hide();
|
66
|
+
}, this.delay);
|
67
|
+
});
|
68
|
+
}
|
136
69
|
}
|
137
70
|
|
138
71
|
export default Tooltip;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":1.1,"properties":[],"pseudoElements":[
|
1
|
+
{"version":1.1,"properties":[],"pseudoElements":[]}
|