@nightshadeui/components 3.1.0 → 3.2.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/README.md +21 -0
- package/css.d.ts +2 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +7 -0
- package/dist/_virtual/_rolldown/runtime.js +10 -0
- package/dist/components/BaseMenu.css +1 -0
- package/dist/components/BaseMenu.js +108 -0
- package/dist/components/BaseMenu.vue.d.ts +21 -8
- package/dist/components/BaseMenu.vue.d.ts.map +1 -1
- package/dist/components/Btn.css +1 -0
- package/dist/components/Btn.js +186 -0
- package/dist/components/Btn.vue.d.ts +38 -2
- package/dist/components/Btn.vue.d.ts.map +1 -1
- package/dist/components/Bubble.css +1 -0
- package/dist/components/Bubble.js +37 -0
- package/dist/components/Bubble.vue.d.ts +12 -2
- package/dist/components/Bubble.vue.d.ts.map +1 -1
- package/dist/components/Checkbox.css +1 -0
- package/dist/components/Checkbox.js +116 -0
- package/dist/components/Checkbox.vue.d.ts +15 -3
- package/dist/components/Checkbox.vue.d.ts.map +1 -1
- package/dist/components/Chip.css +1 -0
- package/dist/components/Chip.js +91 -0
- package/dist/components/Chip.vue.d.ts +16 -2
- package/dist/components/Chip.vue.d.ts.map +1 -1
- package/dist/components/ContextMenu.js +56 -0
- package/dist/components/ContextMenu.vue.d.ts +28 -8
- package/dist/components/ContextMenu.vue.d.ts.map +1 -1
- package/dist/components/ContextPopup.js +166 -0
- package/dist/components/ContextPopup.vue.d.ts +23 -2
- package/dist/components/ContextPopup.vue.d.ts.map +1 -1
- package/dist/components/Filler.css +1 -0
- package/dist/components/Filler.js +18 -0
- package/dist/components/Filler.vue.d.ts +6 -2
- package/dist/components/Filler.vue.d.ts.map +1 -1
- package/dist/components/HGroup.css +1 -0
- package/dist/components/HGroup.js +44 -0
- package/dist/components/HGroup.vue.d.ts +21 -8
- package/dist/components/HGroup.vue.d.ts.map +1 -1
- package/dist/components/InputBase.css +1 -0
- package/dist/components/InputBase.js +115 -0
- package/dist/components/InputBase.vue.d.ts +16 -2
- package/dist/components/InputBase.vue.d.ts.map +1 -1
- package/dist/components/InputGroup.css +1 -0
- package/dist/components/InputGroup.js +21 -0
- package/dist/components/InputGroup.vue.d.ts +12 -2
- package/dist/components/InputGroup.vue.d.ts.map +1 -1
- package/dist/components/InputSelect.css +1 -0
- package/dist/components/InputSelect.js +110 -0
- package/dist/components/InputSelect.vue.d.ts +18 -2
- package/dist/components/InputSelect.vue.d.ts.map +1 -1
- package/dist/components/InputText.css +1 -0
- package/dist/components/InputText.js +77 -0
- package/dist/components/InputText.vue.d.ts +18 -2
- package/dist/components/InputText.vue.d.ts.map +1 -1
- package/dist/components/InputTextarea.css +1 -0
- package/dist/components/InputTextarea.js +80 -0
- package/dist/components/InputTextarea.vue.d.ts +18 -2
- package/dist/components/InputTextarea.vue.d.ts.map +1 -1
- package/dist/components/ModalOverlay.css +1 -0
- package/dist/components/ModalOverlay.js +45 -0
- package/dist/components/ModalOverlay.vue.d.ts +12 -2
- package/dist/components/ModalOverlay.vue.d.ts.map +1 -1
- package/dist/components/RouterBtn.js +39 -0
- package/dist/components/RouterBtn.vue.d.ts +10 -2
- package/dist/components/RouterBtn.vue.d.ts.map +1 -1
- package/dist/components/Slider.css +1 -0
- package/dist/components/Slider.js +326 -0
- package/dist/components/Slider.vue.d.ts +10 -2
- package/dist/components/Slider.vue.d.ts.map +1 -1
- package/dist/components/Tab.css +1 -0
- package/dist/components/Tab.js +56 -0
- package/dist/components/Tab.vue.d.ts +12 -2
- package/dist/components/Tab.vue.d.ts.map +1 -1
- package/dist/components/TabCap.css +1 -0
- package/dist/components/TabCap.js +28 -0
- package/dist/components/TabCap.vue.d.ts +6 -2
- package/dist/components/TabCap.vue.d.ts.map +1 -1
- package/dist/components/Toggle.css +1 -0
- package/dist/components/Toggle.js +102 -0
- package/dist/components/Toggle.vue.d.ts +6 -2
- package/dist/components/Toggle.vue.d.ts.map +1 -1
- package/dist/components/ToolPanel.css +1 -0
- package/dist/components/ToolPanel.js +33 -0
- package/dist/components/ToolPanel.vue.d.ts +12 -2
- package/dist/components/ToolPanel.vue.d.ts.map +1 -1
- package/dist/components/Tooltip.css +1 -0
- package/dist/components/Tooltip.js +97 -0
- package/dist/components/Tooltip.vue.d.ts +225 -0
- package/dist/components/Tooltip.vue.d.ts.map +1 -0
- package/dist/components/VGroup.css +1 -0
- package/dist/components/VGroup.js +36 -0
- package/dist/components/VGroup.vue.d.ts +21 -8
- package/dist/components/VGroup.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +51 -0
- package/dist/components.css +39 -1
- package/dist/directives/index.d.ts +2 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/directives/tooltip.d.ts +14 -0
- package/dist/directives/tooltip.d.ts.map +1 -0
- package/dist/directives/tooltip.js +23 -0
- package/dist/glyphs/GlyphCheck.js +17 -0
- package/dist/glyphs/GlyphCheck.vue.d.ts +2 -1
- package/dist/glyphs/GlyphCheck.vue.d.ts.map +1 -1
- package/dist/glyphs/GlyphXmark.js +17 -0
- package/dist/glyphs/GlyphXmark.vue.d.ts +2 -1
- package/dist/glyphs/GlyphXmark.vue.d.ts.map +1 -1
- package/dist/helpers/props.js +28 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -0
- package/package.json +14 -8
- package/src/components/BaseMenu.vue +36 -29
- package/src/components/Btn.vue +197 -191
- package/src/components/Bubble.vue +110 -103
- package/src/components/Checkbox.vue +93 -86
- package/src/components/Chip.vue +109 -102
- package/src/components/ContextPopup.vue +9 -1
- package/src/components/Filler.vue +21 -14
- package/src/components/HGroup.vue +47 -41
- package/src/components/InputBase.vue +137 -130
- package/src/components/InputGroup.vue +26 -16
- package/src/components/InputSelect.vue +28 -21
- package/src/components/InputText.vue +24 -17
- package/src/components/InputTextarea.vue +31 -24
- package/src/components/ModalOverlay.vue +21 -14
- package/src/components/Slider.vue +258 -249
- package/src/components/Tab.vue +73 -66
- package/src/components/TabCap.vue +20 -13
- package/src/components/Toggle.vue +102 -95
- package/src/components/ToolPanel.vue +36 -35
- package/src/components/Tooltip.vue +184 -0
- package/src/components/VGroup.vue +43 -37
- package/src/components/index.ts +2 -0
- package/src/directives/index.ts +1 -0
- package/src/directives/tooltip.ts +50 -0
- package/src/index.ts +1 -0
- package/dist/components.mjs +0 -1719
|
@@ -116,123 +116,130 @@ export default {
|
|
|
116
116
|
</script>
|
|
117
117
|
|
|
118
118
|
<style scoped>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
--Toggle-width: calc(1.618 * var(--Toggle-size));
|
|
122
|
-
--Toggle-knob-offset: var(--input-minor-padding);
|
|
123
|
-
--Toggle-knob-size: calc(var(--Toggle-size) - 2 * var(--Toggle-knob-offset));
|
|
124
|
-
--Toggle-knob-radius: calc(var(--Toggle-radius) - 0.5 * var(--Toggle-knob-offset));
|
|
119
|
+
/* The order, stated wherever these styles load first: the styles, then the components */
|
|
120
|
+
@layer nightshade, nightshade-components;
|
|
125
121
|
|
|
126
|
-
|
|
122
|
+
@layer nightshade-components {
|
|
127
123
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
.Toggle {
|
|
125
|
+
--Toggle-size: var(--input-minor-height);
|
|
126
|
+
--Toggle-width: calc(1.618 * var(--Toggle-size));
|
|
127
|
+
--Toggle-knob-offset: var(--input-minor-padding);
|
|
128
|
+
--Toggle-knob-size: calc(var(--Toggle-size) - 2 * var(--Toggle-knob-offset));
|
|
129
|
+
--Toggle-knob-radius: calc(var(--Toggle-radius) - 0.5 * var(--Toggle-knob-offset));
|
|
131
130
|
|
|
132
|
-
|
|
133
|
-
--Toggle-border: transparent;
|
|
134
|
-
--Toggle-radius: var(--radius-m);
|
|
131
|
+
--Toggle-outline: transparent;
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
--Toggle-background: var(--surface-deep);
|
|
134
|
+
--Toggle-knob-background: var(--surface-knob);
|
|
135
|
+
--Toggle-knob-transparency: 0%;
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
height: var(--Toggle-size);
|
|
137
|
+
--Toggle-border-size: 0px;
|
|
138
|
+
--Toggle-border: transparent;
|
|
139
|
+
--Toggle-radius: var(--radius-m);
|
|
143
140
|
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
--Toggle-box-shadow: 0 1px 3px var(--Toggle-shadow) inset, 0 0 5px -1px var(--Toggle-shadow) inset;
|
|
142
|
+
--Toggle-shadow: var(--shadow-light);
|
|
146
143
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
box-shadow: var(--Toggle-box-shadow);
|
|
144
|
+
display: block;
|
|
145
|
+
position: relative;
|
|
146
|
+
width: var(--Toggle-width);
|
|
147
|
+
height: var(--Toggle-size);
|
|
152
148
|
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
border: var(--Toggle-border-size) solid var(--Toggle-border);
|
|
150
|
+
border-radius: var(--Toggle-radius);
|
|
155
151
|
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
background: var(--Toggle-background);
|
|
153
|
+
outline: var(--input-outline-size) solid var(--Toggle-outline);
|
|
154
|
+
outline-offset: var(--input-outline-offset);
|
|
155
|
+
background-clip: border-box;
|
|
156
|
+
box-shadow: var(--Toggle-box-shadow);
|
|
158
157
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
user-select: none;
|
|
162
160
|
|
|
163
|
-
.
|
|
164
|
-
|
|
165
|
-
position: absolute;
|
|
166
|
-
top: 50%;
|
|
167
|
-
left: 0;
|
|
168
|
-
width: var(--Toggle-knob-size);
|
|
169
|
-
height: var(--Toggle-knob-size);
|
|
170
|
-
border-radius: var(--Toggle-knob-radius);
|
|
171
|
-
background: color-mix(in srgb, var(--Toggle-knob-background), transparent var(--Toggle-knob-transparency));
|
|
172
|
-
box-shadow: 0 1px 3px var(--Toggle-shadow), 0 1px 5px var(--Toggle-shadow);
|
|
173
|
-
|
|
174
|
-
transform: translate(calc(var(--Toggle-knob-offset) - var(--Toggle-border-size)), -50%);
|
|
175
|
-
transition: transform .3s, border-radius .3s;
|
|
176
|
-
}
|
|
161
|
+
transition: background-color .3s, border-radius .3s;
|
|
162
|
+
}
|
|
177
163
|
|
|
178
|
-
|
|
164
|
+
.Toggle input {
|
|
165
|
+
display: none;
|
|
166
|
+
}
|
|
179
167
|
|
|
180
|
-
.Toggle
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
168
|
+
.Toggle::before {
|
|
169
|
+
content: '';
|
|
170
|
+
position: absolute;
|
|
171
|
+
top: 50%;
|
|
172
|
+
left: 0;
|
|
173
|
+
width: var(--Toggle-knob-size);
|
|
174
|
+
height: var(--Toggle-knob-size);
|
|
175
|
+
border-radius: var(--Toggle-knob-radius);
|
|
176
|
+
background: color-mix(in srgb, var(--Toggle-knob-background), transparent var(--Toggle-knob-transparency));
|
|
177
|
+
box-shadow: 0 1px 3px var(--Toggle-shadow), 0 1px 5px var(--Toggle-shadow);
|
|
178
|
+
|
|
179
|
+
transform: translate(calc(var(--Toggle-knob-offset) - var(--Toggle-border-size)), -50%);
|
|
180
|
+
transition: transform .3s, border-radius .3s;
|
|
181
|
+
}
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
filter: var(--input-hover-filter);
|
|
188
|
-
}
|
|
183
|
+
/* States */
|
|
189
184
|
|
|
190
|
-
.Toggle
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
185
|
+
.Toggle-disabled {
|
|
186
|
+
cursor: not-allowed;
|
|
187
|
+
opacity: var(--input-disabled-opacity);
|
|
188
|
+
filter: var(--input-disabled-filter);
|
|
189
|
+
}
|
|
195
190
|
|
|
196
|
-
.Toggle-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
191
|
+
.Toggle:not(.Toggle-disabled):hover, .Toggle.Toggle-forceHover {
|
|
192
|
+
filter: var(--input-hover-filter);
|
|
193
|
+
}
|
|
200
194
|
|
|
201
|
-
.Toggle-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
var(--Toggle-knob-offset) -
|
|
207
|
-
var(--Toggle-border-size)
|
|
208
|
-
), -50%);
|
|
209
|
-
}
|
|
195
|
+
.Toggle:not(.Toggle-disabled):focus-visible, .Toggle.Toggle-forceFocus {
|
|
196
|
+
z-index: 10;
|
|
197
|
+
--Toggle-outline: var(--tone-focus-outline);
|
|
198
|
+
--Toggle-border: var(--tone-focus-border);
|
|
199
|
+
}
|
|
210
200
|
|
|
211
|
-
|
|
201
|
+
.Toggle-active {
|
|
202
|
+
--Toggle-background: var(--tone-fill);
|
|
203
|
+
--Toggle-knob-background: var(--tone-fill-text);
|
|
204
|
+
}
|
|
212
205
|
|
|
213
|
-
.Toggle-
|
|
214
|
-
|
|
215
|
-
|
|
206
|
+
.Toggle-active::before {
|
|
207
|
+
transform: translate(
|
|
208
|
+
calc(
|
|
209
|
+
var(--Toggle-width) -
|
|
210
|
+
var(--Toggle-knob-size) -
|
|
211
|
+
var(--Toggle-knob-offset) -
|
|
212
|
+
var(--Toggle-border-size)
|
|
213
|
+
), -50%);
|
|
214
|
+
}
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
--Toggle-border: var(--tone-border);
|
|
219
|
-
--Toggle-border-size: var(--input-border-size);
|
|
220
|
-
}
|
|
216
|
+
/* Styles */
|
|
221
217
|
|
|
222
|
-
.Toggle-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
218
|
+
.Toggle-round {
|
|
219
|
+
--Toggle-radius: calc(.5 * var(--Toggle-size));
|
|
220
|
+
}
|
|
226
221
|
|
|
227
|
-
.Toggle-
|
|
228
|
-
|
|
229
|
-
|
|
222
|
+
.Toggle-outline {
|
|
223
|
+
--Toggle-border: var(--tone-border);
|
|
224
|
+
--Toggle-border-size: var(--input-border-size);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.Toggle-flat {
|
|
228
|
+
--Toggle-shadow: transparent;
|
|
229
|
+
--Toggle-box-shadow: none;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.Toggle-translucent {
|
|
233
|
+
--Toggle-knob-transparency: var(--translucency-mix-medium);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.Toggle-translucent::before {
|
|
237
|
+
box-shadow:
|
|
238
|
+
0 0 2px var(--shadow-medium),
|
|
239
|
+
0 1px 5px var(--Toggle-shadow),
|
|
240
|
+
0 0 3px var(--translucency-highlight) inset;
|
|
241
|
+
backdrop-filter: blur(var(--translucency-blur));
|
|
242
|
+
}
|
|
230
243
|
|
|
231
|
-
.Toggle-translucent::before {
|
|
232
|
-
box-shadow:
|
|
233
|
-
0 0 2px var(--shadow-medium),
|
|
234
|
-
0 1px 5px var(--Toggle-shadow),
|
|
235
|
-
0 0 3px var(--translucency-highlight) inset;
|
|
236
|
-
backdrop-filter: blur(var(--translucency-blur));
|
|
237
244
|
}
|
|
238
245
|
</style>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
<div
|
|
3
3
|
class="ToolPanel"
|
|
4
4
|
:class="[
|
|
5
|
-
resolvedProps.size && `ToolPanel-size-${resolvedProps.size}`,
|
|
6
5
|
resolvedProps.size && `input-size-${resolvedProps.size}`,
|
|
7
6
|
{
|
|
8
7
|
'ToolPanel-flat': resolvedProps.flat,
|
|
@@ -34,50 +33,52 @@ export default {
|
|
|
34
33
|
</script>
|
|
35
34
|
|
|
36
35
|
<style scoped>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
--ToolPanel-padding: var(--input-minor-padding);
|
|
40
|
-
--ToolPanel-gap: var(--input-gap);
|
|
36
|
+
/* The order, stated wherever these styles load first: the styles, then the components */
|
|
37
|
+
@layer nightshade, nightshade-components;
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
@layer nightshade-components {
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
.ToolPanel {
|
|
42
|
+
--ToolPanel-size: var(--input-major-height);
|
|
43
|
+
--ToolPanel-padding: var(--input-minor-padding);
|
|
44
|
+
--ToolPanel-gap: var(--input-gap);
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
--ToolPanel-box-shadow: 0 1px 1px var(--ToolPanel-shadow) inset, 0 0 5px var(--ToolPanel-shadow) inset;
|
|
46
|
+
--ToolPanel-background: var(--surface-deep);
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
padding: calc(var(--ToolPanel-padding) - var(--ToolPanel-border-size));
|
|
55
|
-
height: var(--ToolPanel-size);
|
|
56
|
-
min-height: 0;
|
|
48
|
+
--ToolPanel-border-size: 0px;
|
|
49
|
+
--ToolPanel-border: var(--border-deep);
|
|
50
|
+
--ToolPanel-radius: var(--radius-m);
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
box-shadow: var(--ToolPanel-box-shadow);
|
|
61
|
-
background: var(--ToolPanel-background);
|
|
52
|
+
--ToolPanel-shadow: var(--shadow-light);
|
|
53
|
+
--ToolPanel-box-shadow: 0 1px 1px var(--ToolPanel-shadow) inset, 0 0 5px var(--ToolPanel-shadow) inset;
|
|
62
54
|
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: var(--ToolPanel-gap);
|
|
58
|
+
padding: calc(var(--ToolPanel-padding) - var(--ToolPanel-border-size));
|
|
59
|
+
min-height: var(--ToolPanel-size);
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
border: var(--ToolPanel-border-size) solid var(--ToolPanel-border);
|
|
62
|
+
border-radius: var(--ToolPanel-radius);
|
|
63
|
+
box-shadow: var(--ToolPanel-box-shadow);
|
|
64
|
+
background: var(--ToolPanel-background);
|
|
69
65
|
|
|
70
|
-
|
|
66
|
+
transition: color .3s, background-color .3s, border-radius .3s, filter .3s;
|
|
67
|
+
}
|
|
71
68
|
|
|
72
|
-
|
|
73
|
-
--ToolPanel-radius: calc(.5 * var(--ToolPanel-size));
|
|
74
|
-
}
|
|
69
|
+
/* Styles */
|
|
75
70
|
|
|
76
|
-
.ToolPanel-
|
|
77
|
-
|
|
78
|
-
}
|
|
71
|
+
.ToolPanel-round {
|
|
72
|
+
--ToolPanel-radius: calc(.5 * var(--ToolPanel-size));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.ToolPanel-outline {
|
|
76
|
+
--ToolPanel-border-size: var(--input-border-size);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.ToolPanel-flat {
|
|
80
|
+
--ToolPanel-box-shadow: none;
|
|
81
|
+
}
|
|
79
82
|
|
|
80
|
-
.ToolPanel-flat {
|
|
81
|
-
--ToolPanel-box-shadow: none;
|
|
82
83
|
}
|
|
83
84
|
</style>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ContextPopup
|
|
3
|
+
v-if="shown"
|
|
4
|
+
:dir="resolvedProps.dir"
|
|
5
|
+
:align="resolvedProps.align"
|
|
6
|
+
:anchorEl="anchor"
|
|
7
|
+
anchorDir="auto"
|
|
8
|
+
:overlayEnabled="false"
|
|
9
|
+
:overlayShown="false"
|
|
10
|
+
@hide="hide">
|
|
11
|
+
<div
|
|
12
|
+
:id="tooltipId"
|
|
13
|
+
class="Tooltip"
|
|
14
|
+
role="tooltip">
|
|
15
|
+
<slot>
|
|
16
|
+
<div
|
|
17
|
+
v-if="resolvedProps.title"
|
|
18
|
+
class="Title">
|
|
19
|
+
{{ resolvedProps.title }}
|
|
20
|
+
</div>
|
|
21
|
+
<div
|
|
22
|
+
v-if="resolvedProps.text"
|
|
23
|
+
class="Text">
|
|
24
|
+
{{ resolvedProps.text }}
|
|
25
|
+
</div>
|
|
26
|
+
</slot>
|
|
27
|
+
</div>
|
|
28
|
+
</ContextPopup>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
import { nightshadeMixin } from '../helpers/props.js';
|
|
33
|
+
import ContextPopup from './ContextPopup.vue';
|
|
34
|
+
|
|
35
|
+
const SHOW_DELAY = 300;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Shows a bubble while its anchor is hovered or focused from the keyboard.
|
|
39
|
+
* The anchor is the parent element, or `anchorEl` (which `v-tooltip` passes).
|
|
40
|
+
*/
|
|
41
|
+
export default {
|
|
42
|
+
|
|
43
|
+
components: {
|
|
44
|
+
ContextPopup,
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
mixins: [nightshadeMixin],
|
|
48
|
+
|
|
49
|
+
props: {
|
|
50
|
+
title: { type: String },
|
|
51
|
+
text: { type: String },
|
|
52
|
+
dir: { type: String, default: 'top' },
|
|
53
|
+
align: { type: String, default: 'center' },
|
|
54
|
+
anchorEl: { default: null },
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
data() {
|
|
58
|
+
return {
|
|
59
|
+
shown: false,
|
|
60
|
+
anchor: null,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
computed: {
|
|
65
|
+
|
|
66
|
+
tooltipId() {
|
|
67
|
+
return `Tooltip-${this.$.uid}`;
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
hasContent() {
|
|
71
|
+
return Boolean(this.$slots.default || this.resolvedProps.title || this.resolvedProps.text);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
created() {
|
|
77
|
+
this.showTimer = null;
|
|
78
|
+
this.anchorTitle = null;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
mounted() {
|
|
82
|
+
this.anchor = this.resolvedProps.anchorEl ?? this.$el.parentElement;
|
|
83
|
+
this.anchor.addEventListener('pointerenter', this.onPointerEnter);
|
|
84
|
+
this.anchor.addEventListener('pointerleave', this.hide);
|
|
85
|
+
this.anchor.addEventListener('pointerdown', this.hide);
|
|
86
|
+
this.anchor.addEventListener('focusin', this.onFocusIn);
|
|
87
|
+
this.anchor.addEventListener('focusout', this.hide);
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
beforeUnmount() {
|
|
91
|
+
this.hide();
|
|
92
|
+
this.anchor.removeEventListener('pointerenter', this.onPointerEnter);
|
|
93
|
+
this.anchor.removeEventListener('pointerleave', this.hide);
|
|
94
|
+
this.anchor.removeEventListener('pointerdown', this.hide);
|
|
95
|
+
this.anchor.removeEventListener('focusin', this.onFocusIn);
|
|
96
|
+
this.anchor.removeEventListener('focusout', this.hide);
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
methods: {
|
|
100
|
+
|
|
101
|
+
show() {
|
|
102
|
+
clearTimeout(this.showTimer);
|
|
103
|
+
if (this.shown || !this.hasContent) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// The native title would show a second tooltip
|
|
107
|
+
this.anchorTitle = this.anchor.getAttribute('title');
|
|
108
|
+
this.anchor.removeAttribute('title');
|
|
109
|
+
this.anchor.setAttribute('aria-describedby', this.tooltipId);
|
|
110
|
+
window.addEventListener('scroll', this.hide, { capture: true, passive: true });
|
|
111
|
+
this.shown = true;
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
hide() {
|
|
115
|
+
clearTimeout(this.showTimer);
|
|
116
|
+
if (!this.shown) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (this.anchorTitle != null) {
|
|
120
|
+
this.anchor.setAttribute('title', this.anchorTitle);
|
|
121
|
+
}
|
|
122
|
+
this.anchor.removeAttribute('aria-describedby');
|
|
123
|
+
window.removeEventListener('scroll', this.hide, { capture: true });
|
|
124
|
+
this.shown = false;
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
onPointerEnter(ev) {
|
|
128
|
+
if (ev.pointerType !== 'mouse') {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
clearTimeout(this.showTimer);
|
|
132
|
+
this.showTimer = setTimeout(() => this.show(), SHOW_DELAY);
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
onFocusIn(ev) {
|
|
136
|
+
if (ev.target.matches(':focus-visible')) {
|
|
137
|
+
this.show();
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
};
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<style scoped>
|
|
147
|
+
/* The order, stated wherever these styles load first: the styles, then the components */
|
|
148
|
+
@layer nightshade, nightshade-components;
|
|
149
|
+
|
|
150
|
+
@layer nightshade-components {
|
|
151
|
+
|
|
152
|
+
.Tooltip {
|
|
153
|
+
--Tooltip-padding: var(--sp1) var(--sp1-5);
|
|
154
|
+
--Tooltip-gap: var(--sp0-5);
|
|
155
|
+
--Tooltip-width: var(--sp40);
|
|
156
|
+
--Tooltip-title: var(--text-base);
|
|
157
|
+
--Tooltip-text: var(--text-subtle);
|
|
158
|
+
|
|
159
|
+
display: flex;
|
|
160
|
+
flex-flow: column;
|
|
161
|
+
gap: var(--Tooltip-gap);
|
|
162
|
+
width: max-content;
|
|
163
|
+
max-width: var(--Tooltip-width);
|
|
164
|
+
padding: var(--Tooltip-padding);
|
|
165
|
+
|
|
166
|
+
font-size: var(--font-size-s);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.Title {
|
|
170
|
+
font-weight: var(--font-weight-bold);
|
|
171
|
+
color: var(--Tooltip-title);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.Text {
|
|
175
|
+
color: var(--Tooltip-text);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* A lone text is the whole message */
|
|
179
|
+
.Text:first-child {
|
|
180
|
+
color: var(--Tooltip-title);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
</style>
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
<component
|
|
3
3
|
:is="resolvedProps.tagName"
|
|
4
4
|
class="VGroup"
|
|
5
|
+
:style="gapStyle"
|
|
5
6
|
:class="[
|
|
6
7
|
`VGroup-align-${resolvedProps.align}`,
|
|
7
|
-
`VGroup-justify-${resolvedProps.justify}`,
|
|
8
|
-
`VGroup-gap-${resolvedProps.gap}`,
|
|
8
|
+
resolvedProps.justify && `VGroup-justify-${resolvedProps.justify}`,
|
|
9
9
|
]">
|
|
10
10
|
<slot />
|
|
11
11
|
</component>
|
|
@@ -22,47 +22,53 @@ export default {
|
|
|
22
22
|
tagName: { type: String, default: 'div' },
|
|
23
23
|
align: { type: String, default: 'stretch' },
|
|
24
24
|
justify: { type: String },
|
|
25
|
-
gap: { type: String,
|
|
26
|
-
}
|
|
25
|
+
gap: { type: [String, Number] },
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
computed: {
|
|
29
|
+
|
|
30
|
+
// `gap` names a step of the spacing scale: `1` is `--sp1`, `0-5` is `--sp0-5`.
|
|
31
|
+
gapStyle() {
|
|
32
|
+
const { gap } = this.resolvedProps;
|
|
33
|
+
if (gap == null) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
'--VGroup-gap': String(gap) === '0' ? '0px' : `var(--sp${gap})`,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
},
|
|
27
42
|
|
|
28
43
|
};
|
|
29
44
|
</script>
|
|
30
45
|
|
|
31
46
|
<style scoped>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
flex-flow: column nowrap;
|
|
35
|
-
}
|
|
47
|
+
/* The order, stated wherever these styles load first: the styles, then the components */
|
|
48
|
+
@layer nightshade, nightshade-components;
|
|
36
49
|
|
|
37
|
-
|
|
38
|
-
.VGroup-align-baseline { align-items: baseline; }
|
|
39
|
-
.VGroup-align-center { align-items: center; }
|
|
40
|
-
.VGroup-align-start { align-items: flex-start; }
|
|
41
|
-
.VGroup-align-end { align-items: flex-end; }
|
|
50
|
+
@layer nightshade-components {
|
|
42
51
|
|
|
43
|
-
.VGroup
|
|
44
|
-
|
|
45
|
-
.VGroup-justify-end { justify-content: flex-end; }
|
|
46
|
-
.VGroup-justify-space-around { justify-content: space-around; }
|
|
47
|
-
.VGroup-justify-space-between { justify-content: space-between; }
|
|
52
|
+
.VGroup {
|
|
53
|
+
--VGroup-gap: var(--sp2);
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.VGroup-
|
|
55
|
-
.VGroup-
|
|
56
|
-
.VGroup-
|
|
57
|
-
.VGroup-
|
|
58
|
-
.VGroup-
|
|
59
|
-
|
|
60
|
-
.VGroup-
|
|
61
|
-
.VGroup-
|
|
62
|
-
.VGroup-
|
|
63
|
-
.VGroup-
|
|
64
|
-
.VGroup-
|
|
65
|
-
.VGroup-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
display: flex;
|
|
56
|
+
gap: var(--VGroup-gap);
|
|
57
|
+
flex-flow: column nowrap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.VGroup-align-stretch { align-items: stretch; }
|
|
61
|
+
.VGroup-align-baseline { align-items: baseline; }
|
|
62
|
+
.VGroup-align-center { align-items: center; }
|
|
63
|
+
.VGroup-align-start { align-items: flex-start; }
|
|
64
|
+
.VGroup-align-end { align-items: flex-end; }
|
|
65
|
+
|
|
66
|
+
.VGroup-justify-center { justify-content: center; }
|
|
67
|
+
.VGroup-justify-start { justify-content: flex-start; }
|
|
68
|
+
.VGroup-justify-end { justify-content: flex-end; }
|
|
69
|
+
.VGroup-justify-space-around { justify-content: space-around; }
|
|
70
|
+
.VGroup-justify-space-between { justify-content: space-between; }
|
|
71
|
+
.VGroup-justify-space-evenly { justify-content: space-evenly; }
|
|
72
|
+
|
|
73
|
+
}
|
|
68
74
|
</style>
|
package/src/components/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import Tab from './Tab.vue';
|
|
|
19
19
|
import TabCap from './TabCap.vue';
|
|
20
20
|
import Toggle from './Toggle.vue';
|
|
21
21
|
import ToolPanel from './ToolPanel.vue';
|
|
22
|
+
import Tooltip from './Tooltip.vue';
|
|
22
23
|
import VGroup from './VGroup.vue';
|
|
23
24
|
|
|
24
25
|
export {
|
|
@@ -43,5 +44,6 @@ export {
|
|
|
43
44
|
TabCap,
|
|
44
45
|
Toggle,
|
|
45
46
|
ToolPanel,
|
|
47
|
+
Tooltip,
|
|
46
48
|
VGroup,
|
|
47
49
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tooltip.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createVNode, Directive, DirectiveBinding, render } from 'vue';
|
|
2
|
+
|
|
3
|
+
import Tooltip from '../components/Tooltip.vue';
|
|
4
|
+
|
|
5
|
+
export interface TooltipOptions {
|
|
6
|
+
title?: string;
|
|
7
|
+
text?: string;
|
|
8
|
+
dir?: string;
|
|
9
|
+
align?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type TooltipValue = string | TooltipOptions | null | undefined;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Each element's tooltip renders into a detached container: the bubble itself teleports to `#overlays`.
|
|
16
|
+
*/
|
|
17
|
+
const containers = new WeakMap<HTMLElement, HTMLElement>();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `v-tooltip="'Saves the draft'"` or `v-tooltip="{ title: 'Save', text: 'Saves the draft' }"`.
|
|
21
|
+
* The directive renders a `Tooltip` anchored to its element; use `Tooltip` directly for rich content.
|
|
22
|
+
*/
|
|
23
|
+
export const vTooltip: Directive<HTMLElement, TooltipValue> = {
|
|
24
|
+
|
|
25
|
+
mounted(el, binding) {
|
|
26
|
+
const container = document.createElement('div');
|
|
27
|
+
containers.set(el, container);
|
|
28
|
+
renderTooltip(el, binding);
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
updated(el, binding) {
|
|
32
|
+
renderTooltip(el, binding);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
beforeUnmount(el) {
|
|
36
|
+
render(null, containers.get(el)!);
|
|
37
|
+
containers.delete(el);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function renderTooltip(el: HTMLElement, binding: DirectiveBinding<TooltipValue>) {
|
|
43
|
+
const options = typeof binding.value === 'string' ? { text: binding.value } : binding.value ?? {};
|
|
44
|
+
const vnode = createVNode(Tooltip, {
|
|
45
|
+
...options,
|
|
46
|
+
anchorEl: el,
|
|
47
|
+
});
|
|
48
|
+
vnode.appContext = binding.instance?.$.appContext ?? null;
|
|
49
|
+
render(vnode, containers.get(el)!);
|
|
50
|
+
}
|