@primer/view-components 0.16.0-rc.02d1611c → 0.16.0-rc.29acc449
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/action_menu/action_menu_element.js +26 -6
- package/app/components/primer/alpha/overlay.css +1 -1
- package/app/components/primer/alpha/tool_tip.js +14 -1
- package/package.json +2 -2
@@ -90,12 +90,14 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
90
90
|
return results;
|
91
91
|
}
|
92
92
|
connectedCallback() {
|
93
|
+
var _a;
|
93
94
|
const { signal } = (__classPrivateFieldSet(this, _ActionMenuElement_abortController, new AbortController(), "f"));
|
94
95
|
this.addEventListener('keydown', this, { signal });
|
95
96
|
this.addEventListener('click', this, { signal });
|
96
97
|
this.addEventListener('mouseover', this, { signal });
|
97
98
|
this.addEventListener('focusout', this, { signal });
|
98
99
|
this.addEventListener('mousedown', this, { signal });
|
100
|
+
(_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.addEventListener('toggle', this, { signal });
|
99
101
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setDynamicLabel).call(this);
|
100
102
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateInput).call(this);
|
101
103
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_softDisableItems).call(this);
|
@@ -109,9 +111,12 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
109
111
|
__classPrivateFieldGet(this, _ActionMenuElement_abortController, "f").abort();
|
110
112
|
}
|
111
113
|
handleEvent(event) {
|
112
|
-
var _a, _b;
|
114
|
+
var _a, _b, _c;
|
113
115
|
const targetIsInvoker = (_a = this.invokerElement) === null || _a === void 0 ? void 0 : _a.contains(event.target);
|
114
116
|
const eventIsActivation = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivation).call(this, event);
|
117
|
+
if (event.type === 'toggle' && event.newState === 'open') {
|
118
|
+
(_b = __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get)) === null || _b === void 0 ? void 0 : _b.focus();
|
119
|
+
}
|
115
120
|
if (targetIsInvoker && event.type === 'mousedown') {
|
116
121
|
__classPrivateFieldSet(this, _ActionMenuElement_invokerBeingClicked, true, "f");
|
117
122
|
return;
|
@@ -160,7 +165,7 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
160
165
|
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivationViaSpace).call(this, event)) {
|
161
166
|
event.preventDefault();
|
162
167
|
if (item.getAttribute('type') === 'submit') {
|
163
|
-
(
|
168
|
+
(_c = item.closest('form')) === null || _c === void 0 ? void 0 : _c.submit();
|
164
169
|
}
|
165
170
|
}
|
166
171
|
return;
|
@@ -288,7 +293,6 @@ _ActionMenuElement_isActivation = function _ActionMenuElement_isActivation(event
|
|
288
293
|
return __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isMouseActivation).call(this, event) || __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivation).call(this, event);
|
289
294
|
};
|
290
295
|
_ActionMenuElement_handleInvokerActivated = function _ActionMenuElement_handleInvokerActivated(event) {
|
291
|
-
var _a;
|
292
296
|
event.preventDefault();
|
293
297
|
event.stopPropagation();
|
294
298
|
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
@@ -296,10 +300,10 @@ _ActionMenuElement_handleInvokerActivated = function _ActionMenuElement_handleIn
|
|
296
300
|
}
|
297
301
|
else {
|
298
302
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_show).call(this);
|
299
|
-
(_a = __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get)) === null || _a === void 0 ? void 0 : _a.focus();
|
300
303
|
}
|
301
304
|
};
|
302
305
|
_ActionMenuElement_handleDialogItemActivated = function _ActionMenuElement_handleDialogItemActivated(event, dialog) {
|
306
|
+
var _a;
|
303
307
|
this.querySelector('.ActionListWrap').style.display = 'none';
|
304
308
|
const dialog_controller = new AbortController();
|
305
309
|
const { signal } = dialog_controller;
|
@@ -316,8 +320,24 @@ _ActionMenuElement_handleDialogItemActivated = function _ActionMenuElement_handl
|
|
316
320
|
setTimeout(() => { var _a; return (_a = this.invokerElement) === null || _a === void 0 ? void 0 : _a.focus(); }, 0);
|
317
321
|
}
|
318
322
|
};
|
319
|
-
//
|
320
|
-
|
323
|
+
// At this point, the dialog is about to open. When it opens, all other popovers (incuding
|
324
|
+
// this ActionMenu) will be closed. We listen to the toggle event here, which will fire when
|
325
|
+
// the menu is closed and manually re-open it. When the menu is re-opened, it gets added to
|
326
|
+
// the top of the popover stack. Only the item at the top of the stack will close when the
|
327
|
+
// escape key is pressed, so we add another beforetoggle listener. When the escape key is
|
328
|
+
// pressed, the listener is invoked, which manually closes the dialog. Closing the dialog
|
329
|
+
// causes the dialog's close event to fire, which
|
330
|
+
(_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.addEventListener('toggle', (toggleEvent) => {
|
331
|
+
var _a;
|
332
|
+
if (toggleEvent.newState === 'closed') {
|
333
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_show).call(this);
|
334
|
+
(_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.addEventListener('beforetoggle', (beforeToggleEvent) => {
|
335
|
+
if (beforeToggleEvent.newState === 'closed') {
|
336
|
+
dialog.close();
|
337
|
+
}
|
338
|
+
}, { signal });
|
339
|
+
}
|
340
|
+
}, { signal, once: true });
|
321
341
|
dialog.addEventListener('close', handleDialogClose, { signal });
|
322
342
|
dialog.addEventListener('cancel', handleDialogClose, { signal });
|
323
343
|
};
|
@@ -1 +1 @@
|
|
1
|
-
anchored-position[popover]{border-width:0;min-width:192px;overflow:visible;padding:0;position:absolute}.Overlay{border-width:0;display:flex;padding:0}anchored-position:not(.Overlay){background:none}.Overlay[popover]:not(:popover-open){display:none}anchored-position.not-anchored::backdrop,dialog::backdrop{background-color:var(--overlay-backdrop-bgColor,var(--color-neutral-muted))}
|
1
|
+
anchored-position[popover]{border-width:0;min-width:192px;overflow:visible;padding:0;position:absolute}.Overlay{border-width:0;display:flex;padding:0}anchored-position:not(.Overlay){background:none}.Overlay[popover]:not(:popover-open){display:none}anchored-position.not-anchored::backdrop,dialog::backdrop{background-color:var(--overlay-backdrop-bgColor,var(--color-neutral-muted))}@media (forced-colors:active){.Overlay{outline:1px solid #0000}}
|
@@ -202,6 +202,16 @@ class ToolTipElement extends HTMLElement {
|
|
202
202
|
margin-top: -6px;
|
203
203
|
border-right-color: var(--bgColor-emphasis, var(--color-neutral-emphasis-plus));
|
204
204
|
}
|
205
|
+
|
206
|
+
@media (forced-colors: active) {
|
207
|
+
:host {
|
208
|
+
outline: solid 1px transparent;
|
209
|
+
}
|
210
|
+
|
211
|
+
:host:before {
|
212
|
+
display: none;
|
213
|
+
}
|
214
|
+
}
|
205
215
|
`;
|
206
216
|
}
|
207
217
|
get showReason() {
|
@@ -288,7 +298,10 @@ class ToolTipElement extends HTMLElement {
|
|
288
298
|
const showing = isPopoverOpen(this);
|
289
299
|
// Ensures that tooltip stays open when hovering between tooltip and element
|
290
300
|
// WCAG Success Criterion 1.4.13 Hoverable
|
291
|
-
const shouldShow = event.type === 'mouseenter' ||
|
301
|
+
const shouldShow = event.type === 'mouseenter' ||
|
302
|
+
// Only show tooltip on focus if running in headless browser (for tests) or if focus ring
|
303
|
+
// is visible (i.e. if user is using keyboard navigation)
|
304
|
+
(event.type === 'focus' && (navigator.webdriver || this.control.matches(':focus-visible')));
|
292
305
|
const isMouseLeaveFromButton = event.type === 'mouseleave' &&
|
293
306
|
event.relatedTarget !== this.control &&
|
294
307
|
event.relatedTarget !== this;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/view-components",
|
3
|
-
"version": "0.16.0-rc.
|
3
|
+
"version": "0.16.0-rc.29acc449",
|
4
4
|
"description": "ViewComponents for the Primer Design System",
|
5
5
|
"main": "app/assets/javascripts/primer_view_components.js",
|
6
6
|
"module": "app/components/primer/primer.js",
|
@@ -73,7 +73,7 @@
|
|
73
73
|
"chokidar-cli": "^3.0.0",
|
74
74
|
"cssnano": "^6.0.1",
|
75
75
|
"eslint": "^8.23.1",
|
76
|
-
"eslint-plugin-custom-elements": "^0.0.
|
76
|
+
"eslint-plugin-custom-elements": "^0.0.8",
|
77
77
|
"eslint-plugin-github": "^4.9.2",
|
78
78
|
"eslint-plugin-prettier": "^5.0.0",
|
79
79
|
"markdownlint-cli2": "^0.11.0",
|