@primer/view-components 0.0.102 → 0.0.103
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/app/assets/javascripts/primer_view_components.js +1 -1
- package/app/assets/javascripts/primer_view_components.js.map +1 -1
- package/app/assets/styles/primer_view_components.css +1 -1
- package/app/assets/styles/primer_view_components.css.map +1 -1
- package/app/components/primer/alpha/modal_dialog.d.ts +1 -1
- package/app/components/primer/alpha/modal_dialog.js +48 -40
- package/app/components/primer/alpha/nav_list.js +3 -3
- package/package.json +5 -3
- package/static/audited_at.json +0 -4
- package/static/constants.json +0 -8
- package/static/statuses.json +0 -4
- package/app/components/primer/alpha/tool-tip-element.d.ts +0 -23
- package/app/components/primer/alpha/tool-tip-element.js +0 -352
- package/app/components/primer/clipboard_copy_component.d.ts +0 -1
- package/app/components/primer/clipboard_copy_component.js +0 -43
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _ToolTipElement_instances, _ToolTipElement_abortController, _ToolTipElement_align, _ToolTipElement_side, _ToolTipElement_allowUpdatePosition, _ToolTipElement_update, _ToolTipElement_updatePosition;
|
|
13
|
-
import { getAnchoredPosition } from '@primer/behaviors';
|
|
14
|
-
const TOOLTIP_OPEN_CLASS = 'tooltip-open';
|
|
15
|
-
const TOOLTIP_ARROW_EDGE_OFFSET = 6;
|
|
16
|
-
const DIRECTION_CLASSES = [
|
|
17
|
-
'tooltip-n',
|
|
18
|
-
'tooltip-s',
|
|
19
|
-
'tooltip-e',
|
|
20
|
-
'tooltip-w',
|
|
21
|
-
'tooltip-ne',
|
|
22
|
-
'tooltip-se',
|
|
23
|
-
'tooltip-nw',
|
|
24
|
-
'tooltip-sw'
|
|
25
|
-
];
|
|
26
|
-
class ToolTipElement extends HTMLElement {
|
|
27
|
-
constructor() {
|
|
28
|
-
super(...arguments);
|
|
29
|
-
_ToolTipElement_instances.add(this);
|
|
30
|
-
_ToolTipElement_abortController.set(this, void 0);
|
|
31
|
-
_ToolTipElement_align.set(this, 'center');
|
|
32
|
-
_ToolTipElement_side.set(this, 'outside-bottom');
|
|
33
|
-
_ToolTipElement_allowUpdatePosition.set(this, false);
|
|
34
|
-
}
|
|
35
|
-
styles() {
|
|
36
|
-
return `
|
|
37
|
-
:host {
|
|
38
|
-
position: absolute;
|
|
39
|
-
z-index: 1000000;
|
|
40
|
-
padding: .5em .75em;
|
|
41
|
-
font: normal normal 11px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
|
42
|
-
-webkit-font-smoothing: subpixel-antialiased;
|
|
43
|
-
color: var(--color-fg-on-emphasis);
|
|
44
|
-
text-align: center;
|
|
45
|
-
text-decoration: none;
|
|
46
|
-
text-shadow: none;
|
|
47
|
-
text-transform: none;
|
|
48
|
-
letter-spacing: normal;
|
|
49
|
-
word-wrap: break-word;
|
|
50
|
-
white-space: pre;
|
|
51
|
-
background: var(--color-neutral-emphasis-plus);
|
|
52
|
-
border-radius: 6px;
|
|
53
|
-
opacity: 0;
|
|
54
|
-
max-width: 250px;
|
|
55
|
-
word-wrap: break-word;
|
|
56
|
-
white-space: normal;
|
|
57
|
-
width: max-content;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
:host:before{
|
|
61
|
-
position: absolute;
|
|
62
|
-
z-index: 1000001;
|
|
63
|
-
color: var(--color-neutral-emphasis-plus);
|
|
64
|
-
content: "";
|
|
65
|
-
border: 6px solid transparent;
|
|
66
|
-
opacity: 0
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@keyframes tooltip-appear {
|
|
70
|
-
from {
|
|
71
|
-
opacity: 0
|
|
72
|
-
}
|
|
73
|
-
to {
|
|
74
|
-
opacity: 1
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
:host:after{
|
|
79
|
-
position: absolute;
|
|
80
|
-
display: block;
|
|
81
|
-
right: 0;
|
|
82
|
-
left: 0;
|
|
83
|
-
height: 12px;
|
|
84
|
-
content: ""
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
:host(.${TOOLTIP_OPEN_CLASS}),
|
|
88
|
-
:host(.${TOOLTIP_OPEN_CLASS}):before {
|
|
89
|
-
animation-name: tooltip-appear;
|
|
90
|
-
animation-duration: .1s;
|
|
91
|
-
animation-fill-mode: forwards;
|
|
92
|
-
animation-timing-function: ease-in;
|
|
93
|
-
animation-delay: .4s
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
:host(.tooltip-s):before,
|
|
97
|
-
:host(.tooltip-n):before {
|
|
98
|
-
right: 50%;
|
|
99
|
-
margin-right: -${TOOLTIP_ARROW_EDGE_OFFSET}px;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
:host(.tooltip-s):before,
|
|
103
|
-
:host(.tooltip-se):before,
|
|
104
|
-
:host(.tooltip-sw):before {
|
|
105
|
-
bottom: 100%;
|
|
106
|
-
border-bottom-color: var(--color-neutral-emphasis-plus)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
:host(.tooltip-s):after,
|
|
110
|
-
:host(.tooltip-se):after,
|
|
111
|
-
:host(.tooltip-sw):after {
|
|
112
|
-
bottom: 100%
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
:host(.tooltip-n):before,
|
|
116
|
-
:host(.tooltip-ne):before,
|
|
117
|
-
:host(.tooltip-nw):before {
|
|
118
|
-
top: 100%;
|
|
119
|
-
border-top-color: var(--color-neutral-emphasis-plus)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
:host(.tooltip-n):after,
|
|
123
|
-
:host(.tooltip-ne):after,
|
|
124
|
-
:host(.tooltip-nw):after {
|
|
125
|
-
top: 100%
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
:host(.tooltip-se):before,
|
|
129
|
-
:host(.tooltip-ne):before {
|
|
130
|
-
left: 0;
|
|
131
|
-
margin-left: ${TOOLTIP_ARROW_EDGE_OFFSET}px;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
:host(.tooltip-sw):before,
|
|
135
|
-
:host(.tooltip-nw):before {
|
|
136
|
-
right: 0;
|
|
137
|
-
margin-right: ${TOOLTIP_ARROW_EDGE_OFFSET}px;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
:host(.tooltip-w):before {
|
|
141
|
-
top: 50%;
|
|
142
|
-
bottom: 50%;
|
|
143
|
-
left: 100%;
|
|
144
|
-
margin-top: -6px;
|
|
145
|
-
border-left-color: var(--color-neutral-emphasis-plus)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
:host(.tooltip-e):before {
|
|
149
|
-
top: 50%;
|
|
150
|
-
right: 100%;
|
|
151
|
-
bottom: 50%;
|
|
152
|
-
margin-top: -6px;
|
|
153
|
-
border-right-color: var(--color-neutral-emphasis-plus)
|
|
154
|
-
}
|
|
155
|
-
`;
|
|
156
|
-
}
|
|
157
|
-
get htmlFor() {
|
|
158
|
-
return this.getAttribute('for') || '';
|
|
159
|
-
}
|
|
160
|
-
set htmlFor(value) {
|
|
161
|
-
this.setAttribute('for', value);
|
|
162
|
-
}
|
|
163
|
-
get type() {
|
|
164
|
-
const type = this.getAttribute('data-type');
|
|
165
|
-
return type === 'label' ? 'label' : 'description';
|
|
166
|
-
}
|
|
167
|
-
set type(value) {
|
|
168
|
-
this.setAttribute('data-type', value);
|
|
169
|
-
}
|
|
170
|
-
get direction() {
|
|
171
|
-
return (this.getAttribute('data-direction') || 's');
|
|
172
|
-
}
|
|
173
|
-
set direction(value) {
|
|
174
|
-
this.setAttribute('data-direction', value);
|
|
175
|
-
}
|
|
176
|
-
get control() {
|
|
177
|
-
return this.ownerDocument.getElementById(this.htmlFor);
|
|
178
|
-
}
|
|
179
|
-
connectedCallback() {
|
|
180
|
-
var _a;
|
|
181
|
-
if (!this.shadowRoot) {
|
|
182
|
-
const shadow = this.attachShadow({ mode: 'open' });
|
|
183
|
-
// eslint-disable-next-line github/no-inner-html
|
|
184
|
-
shadow.innerHTML = `
|
|
185
|
-
<style>
|
|
186
|
-
${this.styles()}
|
|
187
|
-
</style>
|
|
188
|
-
<slot></slot>
|
|
189
|
-
`;
|
|
190
|
-
}
|
|
191
|
-
this.hidden = true;
|
|
192
|
-
__classPrivateFieldSet(this, _ToolTipElement_allowUpdatePosition, true, "f");
|
|
193
|
-
if (!this.id) {
|
|
194
|
-
this.id = `tooltip-${Date.now()}-${(Math.random() * 10000).toFixed(0)}`;
|
|
195
|
-
}
|
|
196
|
-
if (!this.control)
|
|
197
|
-
return;
|
|
198
|
-
this.setAttribute('role', 'tooltip');
|
|
199
|
-
(_a = __classPrivateFieldGet(this, _ToolTipElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
|
200
|
-
__classPrivateFieldSet(this, _ToolTipElement_abortController, new AbortController(), "f");
|
|
201
|
-
const { signal } = __classPrivateFieldGet(this, _ToolTipElement_abortController, "f");
|
|
202
|
-
this.addEventListener('mouseleave', this, { signal });
|
|
203
|
-
this.control.addEventListener('mouseenter', this, { signal });
|
|
204
|
-
this.control.addEventListener('mouseleave', this, { signal });
|
|
205
|
-
this.control.addEventListener('focus', this, { signal });
|
|
206
|
-
this.control.addEventListener('blur', this, { signal });
|
|
207
|
-
this.ownerDocument.addEventListener('keydown', this, { signal });
|
|
208
|
-
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_update).call(this);
|
|
209
|
-
}
|
|
210
|
-
disconnectedCallback() {
|
|
211
|
-
var _a;
|
|
212
|
-
(_a = __classPrivateFieldGet(this, _ToolTipElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
|
213
|
-
}
|
|
214
|
-
handleEvent(event) {
|
|
215
|
-
if (!this.control)
|
|
216
|
-
return;
|
|
217
|
-
// Ensures that tooltip stays open when hovering between tooltip and element
|
|
218
|
-
// WCAG Success Criterion 1.4.13 Hoverable
|
|
219
|
-
if ((event.type === 'mouseenter' || event.type === 'focus') && this.hidden) {
|
|
220
|
-
this.hidden = false;
|
|
221
|
-
}
|
|
222
|
-
else if (event.type === 'blur') {
|
|
223
|
-
this.hidden = true;
|
|
224
|
-
}
|
|
225
|
-
else if (event.type === 'mouseleave' &&
|
|
226
|
-
event.relatedTarget !== this.control &&
|
|
227
|
-
event.relatedTarget !== this) {
|
|
228
|
-
this.hidden = true;
|
|
229
|
-
}
|
|
230
|
-
else if (event.type === 'keydown' && event.key === 'Escape' && !this.hidden) {
|
|
231
|
-
this.hidden = true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
attributeChangedCallback(name) {
|
|
235
|
-
if (name === 'id' || name === 'data-type') {
|
|
236
|
-
if (!this.id || !this.control)
|
|
237
|
-
return;
|
|
238
|
-
if (this.type === 'label') {
|
|
239
|
-
this.control.setAttribute('aria-labelledby', this.id);
|
|
240
|
-
this.setAttribute('aria-hidden', 'true');
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
let describedBy = this.control.getAttribute('aria-describedby');
|
|
244
|
-
describedBy ? (describedBy = `${describedBy} ${this.id}`) : (describedBy = this.id);
|
|
245
|
-
this.control.setAttribute('aria-describedby', describedBy);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else if (this.isConnected && name === 'hidden') {
|
|
249
|
-
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_update).call(this);
|
|
250
|
-
}
|
|
251
|
-
else if (name === 'data-direction') {
|
|
252
|
-
this.classList.remove(...DIRECTION_CLASSES);
|
|
253
|
-
const direction = this.direction;
|
|
254
|
-
if (direction === 'n') {
|
|
255
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
|
256
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
|
|
257
|
-
}
|
|
258
|
-
else if (direction === 'ne') {
|
|
259
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
|
|
260
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
|
|
261
|
-
}
|
|
262
|
-
else if (direction === 'e') {
|
|
263
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
|
264
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-right', "f");
|
|
265
|
-
}
|
|
266
|
-
else if (direction === 'se') {
|
|
267
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'start', "f");
|
|
268
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
|
|
269
|
-
}
|
|
270
|
-
else if (direction === 's') {
|
|
271
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
|
272
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
|
|
273
|
-
}
|
|
274
|
-
else if (direction === 'sw') {
|
|
275
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
|
|
276
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-bottom', "f");
|
|
277
|
-
}
|
|
278
|
-
else if (direction === 'w') {
|
|
279
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'center', "f");
|
|
280
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-left', "f");
|
|
281
|
-
}
|
|
282
|
-
else if (direction === 'nw') {
|
|
283
|
-
__classPrivateFieldSet(this, _ToolTipElement_align, 'end', "f");
|
|
284
|
-
__classPrivateFieldSet(this, _ToolTipElement_side, 'outside-top', "f");
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
_ToolTipElement_abortController = new WeakMap(), _ToolTipElement_align = new WeakMap(), _ToolTipElement_side = new WeakMap(), _ToolTipElement_allowUpdatePosition = new WeakMap(), _ToolTipElement_instances = new WeakSet(), _ToolTipElement_update = function _ToolTipElement_update() {
|
|
290
|
-
if (this.hidden) {
|
|
291
|
-
this.classList.remove(TOOLTIP_OPEN_CLASS, ...DIRECTION_CLASSES);
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
this.classList.add(TOOLTIP_OPEN_CLASS);
|
|
295
|
-
for (const tooltip of this.ownerDocument.querySelectorAll(this.tagName)) {
|
|
296
|
-
if (tooltip !== this)
|
|
297
|
-
tooltip.hidden = true;
|
|
298
|
-
}
|
|
299
|
-
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updatePosition).call(this);
|
|
300
|
-
}
|
|
301
|
-
}, _ToolTipElement_updatePosition = function _ToolTipElement_updatePosition() {
|
|
302
|
-
if (!this.control)
|
|
303
|
-
return;
|
|
304
|
-
if (!__classPrivateFieldGet(this, _ToolTipElement_allowUpdatePosition, "f") || this.hidden)
|
|
305
|
-
return;
|
|
306
|
-
const TOOLTIP_OFFSET = 10;
|
|
307
|
-
this.style.left = `0px`; // Ensures we have reliable tooltip width in `getAnchoredPosition`
|
|
308
|
-
const position = getAnchoredPosition(this, this.control, {
|
|
309
|
-
side: __classPrivateFieldGet(this, _ToolTipElement_side, "f"),
|
|
310
|
-
align: __classPrivateFieldGet(this, _ToolTipElement_align, "f"),
|
|
311
|
-
anchorOffset: TOOLTIP_OFFSET
|
|
312
|
-
});
|
|
313
|
-
const anchorSide = position.anchorSide;
|
|
314
|
-
const align = position.anchorAlign;
|
|
315
|
-
this.style.top = `${position.top}px`;
|
|
316
|
-
this.style.left = `${position.left}px`;
|
|
317
|
-
let direction = 's';
|
|
318
|
-
if (anchorSide === 'outside-left') {
|
|
319
|
-
direction = 'w';
|
|
320
|
-
}
|
|
321
|
-
else if (anchorSide === 'outside-right') {
|
|
322
|
-
direction = 'e';
|
|
323
|
-
}
|
|
324
|
-
else if (anchorSide === 'outside-top') {
|
|
325
|
-
if (align === 'center') {
|
|
326
|
-
direction = 'n';
|
|
327
|
-
}
|
|
328
|
-
else if (align === 'start') {
|
|
329
|
-
direction = 'ne';
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
direction = 'nw';
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
if (align === 'center') {
|
|
337
|
-
direction = 's';
|
|
338
|
-
}
|
|
339
|
-
else if (align === 'start') {
|
|
340
|
-
direction = 'se';
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
direction = 'sw';
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
this.classList.add(`tooltip-${direction}`);
|
|
347
|
-
};
|
|
348
|
-
ToolTipElement.observedAttributes = ['data-type', 'data-direction', 'id', 'hidden'];
|
|
349
|
-
if (!window.customElements.get('tool-tip')) {
|
|
350
|
-
window.ToolTipElement = ToolTipElement;
|
|
351
|
-
window.customElements.define('tool-tip', ToolTipElement);
|
|
352
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@github/clipboard-copy-element';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import '@github/clipboard-copy-element';
|
|
2
|
-
const CLIPBOARD_COPY_TIMER_DURATION = 2000;
|
|
3
|
-
function showSVG(svg) {
|
|
4
|
-
svg.style.display = 'inline-block';
|
|
5
|
-
}
|
|
6
|
-
function hideSVG(svg) {
|
|
7
|
-
svg.style.display = 'none';
|
|
8
|
-
}
|
|
9
|
-
// Toggle a copy button.
|
|
10
|
-
function showCopy(button) {
|
|
11
|
-
const [copyIcon, checkIcon] = button.querySelectorAll('.octicon');
|
|
12
|
-
if (!copyIcon || !checkIcon)
|
|
13
|
-
return;
|
|
14
|
-
showSVG(copyIcon);
|
|
15
|
-
hideSVG(checkIcon);
|
|
16
|
-
}
|
|
17
|
-
// Toggle a copy button.
|
|
18
|
-
function showCheck(button) {
|
|
19
|
-
const [copyIcon, checkIcon] = button.querySelectorAll('.octicon');
|
|
20
|
-
if (!copyIcon || !checkIcon)
|
|
21
|
-
return;
|
|
22
|
-
hideSVG(copyIcon);
|
|
23
|
-
showSVG(checkIcon);
|
|
24
|
-
}
|
|
25
|
-
const clipboardCopyElementTimers = new WeakMap();
|
|
26
|
-
document.addEventListener('clipboard-copy', function ({ target }) {
|
|
27
|
-
if (!(target instanceof HTMLElement))
|
|
28
|
-
return;
|
|
29
|
-
if (!target.hasAttribute('data-view-component'))
|
|
30
|
-
return;
|
|
31
|
-
const currentTimeout = clipboardCopyElementTimers.get(target);
|
|
32
|
-
if (currentTimeout) {
|
|
33
|
-
clearTimeout(currentTimeout);
|
|
34
|
-
clipboardCopyElementTimers.delete(target);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
showCheck(target);
|
|
38
|
-
}
|
|
39
|
-
clipboardCopyElementTimers.set(target, setTimeout(() => {
|
|
40
|
-
showCopy(target);
|
|
41
|
-
clipboardCopyElementTimers.delete(target);
|
|
42
|
-
}, CLIPBOARD_COPY_TIMER_DURATION));
|
|
43
|
-
});
|