@primer/view-components 0.18.2-rc.fe99b203 → 0.19.0-rc.1ce8b774
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/components/primer/alpha/action_bar_element.js +16 -10
- package/app/components/primer/alpha/action_menu/action_menu_element.js +16 -19
- package/app/components/primer/alpha/modal_dialog.js +11 -10
- package/app/components/primer/alpha/segmented_control.js +2 -3
- package/app/components/primer/alpha/toggle_switch.js +2 -2
- package/app/components/primer/alpha/tool_tip.js +6 -7
- package/app/components/primer/beta/nav_list.js +8 -10
- package/app/components/primer/beta/nav_list_group_element.js +2 -3
- package/app/components/primer/dialog_helper.js +6 -7
- package/app/components/primer/focus_group.js +9 -12
- package/lib/primer/forms/primer_multi_input.js +2 -3
- package/lib/primer/forms/primer_text_field.js +2 -4
- package/package.json +4 -4
- package/static/arguments.json +22 -0
- package/static/audited_at.json +1 -0
- package/static/constants.json +3 -0
- package/static/info_arch.json +66 -2
- package/static/previews.json +13 -0
- package/static/statuses.json +1 -0
@@ -50,12 +50,11 @@ let ActionBarElement = class ActionBarElement extends HTMLElement {
|
|
50
50
|
_ActionBarElement_focusZoneAbortController.set(this, null);
|
51
51
|
}
|
52
52
|
connectedCallback() {
|
53
|
-
var _a, _b;
|
54
53
|
// Calculate the width of all the items before hiding anything
|
55
54
|
for (const item of this.items) {
|
56
55
|
const width = item.getBoundingClientRect().width;
|
57
|
-
const marginLeft = parseInt(
|
58
|
-
const marginRight = parseInt(
|
56
|
+
const marginLeft = parseInt(window.getComputedStyle(item)?.marginLeft, 10);
|
57
|
+
const marginRight = parseInt(window.getComputedStyle(item)?.marginRight, 10);
|
59
58
|
item.setAttribute('data-offset-width', `${width + marginLeft + marginRight}`);
|
60
59
|
}
|
61
60
|
resizeObserver.observe(this);
|
@@ -73,11 +72,10 @@ let ActionBarElement = class ActionBarElement extends HTMLElement {
|
|
73
72
|
instersectionObserver.unobserve(this);
|
74
73
|
}
|
75
74
|
menuItemClick(event) {
|
76
|
-
var _a;
|
77
75
|
const currentTarget = event.currentTarget;
|
78
|
-
const id = currentTarget
|
76
|
+
const id = currentTarget?.getAttribute('data-for');
|
79
77
|
if (id) {
|
80
|
-
|
78
|
+
document.getElementById(id)?.click();
|
81
79
|
}
|
82
80
|
}
|
83
81
|
update() {
|
@@ -140,12 +138,20 @@ _ActionBarElement_firstItem_get = function _ActionBarElement_firstItem_get() {
|
|
140
138
|
return foundItem;
|
141
139
|
};
|
142
140
|
_ActionBarElement_showItem = function _ActionBarElement_showItem(index) {
|
143
|
-
this.items[index]
|
144
|
-
__classPrivateFieldGet(this, _ActionBarElement_instances, "a", _ActionBarElement_menuItems_get)[index]
|
141
|
+
const item = this.items[index];
|
142
|
+
const menuItem = __classPrivateFieldGet(this, _ActionBarElement_instances, "a", _ActionBarElement_menuItems_get)[index];
|
143
|
+
if (!item || !menuItem)
|
144
|
+
return;
|
145
|
+
item.style.setProperty('visibility', 'visible');
|
146
|
+
menuItem.hidden = true;
|
145
147
|
};
|
146
148
|
_ActionBarElement_hideItem = function _ActionBarElement_hideItem(index) {
|
147
|
-
this.items[index]
|
148
|
-
__classPrivateFieldGet(this, _ActionBarElement_instances, "a", _ActionBarElement_menuItems_get)[index]
|
149
|
+
const item = this.items[index];
|
150
|
+
const menuItem = __classPrivateFieldGet(this, _ActionBarElement_instances, "a", _ActionBarElement_menuItems_get)[index];
|
151
|
+
if (!item || !menuItem)
|
152
|
+
return;
|
153
|
+
item.style.setProperty('visibility', 'hidden');
|
154
|
+
menuItem.hidden = false;
|
149
155
|
};
|
150
156
|
_ActionBarElement_menuItems_get = function _ActionBarElement_menuItems_get() {
|
151
157
|
return this.moreMenu.querySelectorAll('[role="menu"] > li');
|
@@ -56,12 +56,10 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
56
56
|
this.toggleAttribute('data-dynamic-label', value);
|
57
57
|
}
|
58
58
|
get popoverElement() {
|
59
|
-
|
60
|
-
return ((_a = this.invokerElement) === null || _a === void 0 ? void 0 : _a.popoverTargetElement) || null;
|
59
|
+
return this.invokerElement?.popoverTargetElement || null;
|
61
60
|
}
|
62
61
|
get invokerElement() {
|
63
|
-
|
64
|
-
const id = (_a = this.querySelector('[role=menu]')) === null || _a === void 0 ? void 0 : _a.id;
|
62
|
+
const id = this.querySelector('[role=menu]')?.id;
|
65
63
|
if (!id)
|
66
64
|
return null;
|
67
65
|
for (const el of this.querySelectorAll(`[aria-controls]`)) {
|
@@ -82,22 +80,21 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
82
80
|
for (const selectedItem of selectedItems) {
|
83
81
|
const labelEl = selectedItem.querySelector('.ActionListItem-label');
|
84
82
|
results.push({
|
85
|
-
label: labelEl
|
86
|
-
value: selectedItem
|
83
|
+
label: labelEl?.textContent,
|
84
|
+
value: selectedItem?.getAttribute('data-value'),
|
87
85
|
element: selectedItem,
|
88
86
|
});
|
89
87
|
}
|
90
88
|
return results;
|
91
89
|
}
|
92
90
|
connectedCallback() {
|
93
|
-
var _a;
|
94
91
|
const { signal } = (__classPrivateFieldSet(this, _ActionMenuElement_abortController, new AbortController(), "f"));
|
95
92
|
this.addEventListener('keydown', this, { signal });
|
96
93
|
this.addEventListener('click', this, { signal });
|
97
94
|
this.addEventListener('mouseover', this, { signal });
|
98
95
|
this.addEventListener('focusout', this, { signal });
|
99
96
|
this.addEventListener('mousedown', this, { signal });
|
100
|
-
|
97
|
+
this.popoverElement?.addEventListener('toggle', this, { signal });
|
101
98
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setDynamicLabel).call(this);
|
102
99
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateInput).call(this);
|
103
100
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_softDisableItems).call(this);
|
@@ -111,11 +108,10 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
111
108
|
__classPrivateFieldGet(this, _ActionMenuElement_abortController, "f").abort();
|
112
109
|
}
|
113
110
|
handleEvent(event) {
|
114
|
-
|
115
|
-
const targetIsInvoker = (_a = this.invokerElement) === null || _a === void 0 ? void 0 : _a.contains(event.target);
|
111
|
+
const targetIsInvoker = this.invokerElement?.contains(event.target);
|
116
112
|
const eventIsActivation = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivation).call(this, event);
|
117
113
|
if (event.type === 'toggle' && event.newState === 'open') {
|
118
|
-
|
114
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get)?.focus();
|
119
115
|
}
|
120
116
|
if (targetIsInvoker && event.type === 'mousedown') {
|
121
117
|
__classPrivateFieldSet(this, _ActionMenuElement_invokerBeingClicked, true, "f");
|
@@ -165,7 +161,7 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
165
161
|
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivationViaSpace).call(this, event)) {
|
166
162
|
event.preventDefault();
|
167
163
|
if (item.getAttribute('type') === 'submit') {
|
168
|
-
|
164
|
+
item.closest('form')?.submit();
|
169
165
|
}
|
170
166
|
}
|
171
167
|
return;
|
@@ -265,7 +261,9 @@ _ActionMenuElement_potentiallyDisallowActivation = function _ActionMenuElement_p
|
|
265
261
|
return false;
|
266
262
|
if (item.getAttribute('aria-disabled')) {
|
267
263
|
event.preventDefault();
|
264
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
268
265
|
event.stopPropagation();
|
266
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
269
267
|
event.stopImmediatePropagation();
|
270
268
|
return true;
|
271
269
|
}
|
@@ -294,6 +292,7 @@ _ActionMenuElement_isActivation = function _ActionMenuElement_isActivation(event
|
|
294
292
|
};
|
295
293
|
_ActionMenuElement_handleInvokerActivated = function _ActionMenuElement_handleInvokerActivated(event) {
|
296
294
|
event.preventDefault();
|
295
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
297
296
|
event.stopPropagation();
|
298
297
|
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
299
298
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_hide).call(this);
|
@@ -316,7 +315,7 @@ _ActionMenuElement_handleDialogItemActivated = function _ActionMenuElement_handl
|
|
316
315
|
const lostFocus = this.ownerDocument.activeElement === this.ownerDocument.body;
|
317
316
|
const focusInClosedMenu = this.contains(activeElement);
|
318
317
|
if (lostFocus || focusInClosedMenu) {
|
319
|
-
setTimeout(() =>
|
318
|
+
setTimeout(() => this.invokerElement?.focus(), 0);
|
320
319
|
}
|
321
320
|
};
|
322
321
|
// a modal <dialog> element will close all popovers
|
@@ -376,6 +375,7 @@ _ActionMenuElement_activateItem = function _ActionMenuElement_activateItem(event
|
|
376
375
|
return;
|
377
376
|
// otherwise, event will not result in activation by default, so we stop it and
|
378
377
|
// simulate a click
|
378
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
379
379
|
event.stopPropagation();
|
380
380
|
const elem = item;
|
381
381
|
elem.click();
|
@@ -389,16 +389,13 @@ _ActionMenuElement_handleFocusOut = function _ActionMenuElement_handleFocusOut()
|
|
389
389
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_hide).call(this);
|
390
390
|
};
|
391
391
|
_ActionMenuElement_show = function _ActionMenuElement_show() {
|
392
|
-
|
393
|
-
(_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.showPopover();
|
392
|
+
this.popoverElement?.showPopover();
|
394
393
|
};
|
395
394
|
_ActionMenuElement_hide = function _ActionMenuElement_hide() {
|
396
|
-
|
397
|
-
(_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.hidePopover();
|
395
|
+
this.popoverElement?.hidePopover();
|
398
396
|
};
|
399
397
|
_ActionMenuElement_isOpen = function _ActionMenuElement_isOpen() {
|
400
|
-
|
401
|
-
return (_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.matches(':popover-open');
|
398
|
+
return this.popoverElement?.matches(':popover-open');
|
402
399
|
};
|
403
400
|
_ActionMenuElement_setDynamicLabel = function _ActionMenuElement_setDynamicLabel() {
|
404
401
|
if (!this.dynamicLabel)
|
@@ -14,18 +14,19 @@ import { focusTrap } from '@primer/behaviors';
|
|
14
14
|
import { getFocusableChild } from '@primer/behaviors/utils';
|
15
15
|
function focusIfNeeded(elem) {
|
16
16
|
if (document.activeElement !== elem) {
|
17
|
-
elem
|
17
|
+
elem?.focus();
|
18
18
|
}
|
19
19
|
}
|
20
20
|
const overlayStack = [];
|
21
21
|
function clickHandler(event) {
|
22
22
|
const target = event.target;
|
23
|
-
const button = target
|
23
|
+
const button = target?.closest('button');
|
24
24
|
if (!button || button.hasAttribute('disabled') || button.getAttribute('aria-disabled') === 'true')
|
25
25
|
return;
|
26
26
|
// If the user is clicking a valid dialog trigger
|
27
|
-
let dialogId = button
|
27
|
+
let dialogId = button?.getAttribute('data-show-dialog-id');
|
28
28
|
if (dialogId) {
|
29
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
29
30
|
event.stopPropagation();
|
30
31
|
const dialog = document.getElementById(dialogId);
|
31
32
|
if (dialog instanceof ModalDialogElement) {
|
@@ -63,7 +64,7 @@ function keydownHandler(event) {
|
|
63
64
|
}
|
64
65
|
function mousedownHandler(event) {
|
65
66
|
const target = event.target;
|
66
|
-
if (target
|
67
|
+
if (target?.closest('button'))
|
67
68
|
return;
|
68
69
|
// Find the top level dialog that is open.
|
69
70
|
const topLevelDialog = overlayStack[overlayStack.length - 1];
|
@@ -92,7 +93,6 @@ export class ModalDialogElement extends HTMLElement {
|
|
92
93
|
return this.hasAttribute('open');
|
93
94
|
}
|
94
95
|
set open(value) {
|
95
|
-
var _a, _b, _c, _d;
|
96
96
|
if (value) {
|
97
97
|
if (this.open)
|
98
98
|
return;
|
@@ -100,7 +100,7 @@ export class ModalDialogElement extends HTMLElement {
|
|
100
100
|
this.setAttribute('aria-disabled', 'false');
|
101
101
|
document.body.style.paddingRight = `${window.innerWidth - document.body.clientWidth}px`;
|
102
102
|
document.body.style.overflow = 'hidden';
|
103
|
-
|
103
|
+
__classPrivateFieldGet(this, _ModalDialogElement_instances, "a", _ModalDialogElement_overlayBackdrop_get)?.classList.remove('Overlay--hidden');
|
104
104
|
if (__classPrivateFieldGet(this, _ModalDialogElement_focusAbortController, "f").signal.aborted) {
|
105
105
|
__classPrivateFieldSet(this, _ModalDialogElement_focusAbortController, new AbortController(), "f");
|
106
106
|
}
|
@@ -112,13 +112,13 @@ export class ModalDialogElement extends HTMLElement {
|
|
112
112
|
return;
|
113
113
|
this.removeAttribute('open');
|
114
114
|
this.setAttribute('aria-disabled', 'true');
|
115
|
-
|
115
|
+
__classPrivateFieldGet(this, _ModalDialogElement_instances, "a", _ModalDialogElement_overlayBackdrop_get)?.classList.add('Overlay--hidden');
|
116
116
|
document.body.style.paddingRight = '0';
|
117
117
|
document.body.style.overflow = 'initial';
|
118
118
|
__classPrivateFieldGet(this, _ModalDialogElement_focusAbortController, "f").abort();
|
119
119
|
// if #openButton is a child of a menu, we need to focus a suitable child of the menu
|
120
120
|
// element since it is expected for the menu to close on click
|
121
|
-
const menu =
|
121
|
+
const menu = this.openButton?.closest('details') || this.openButton?.closest('action-menu');
|
122
122
|
if (menu) {
|
123
123
|
focusIfNeeded(getFocusableChild(menu));
|
124
124
|
}
|
@@ -153,8 +153,7 @@ export class ModalDialogElement extends HTMLElement {
|
|
153
153
|
}
|
154
154
|
}
|
155
155
|
_ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_instances = new WeakSet(), _ModalDialogElement_overlayBackdrop_get = function _ModalDialogElement_overlayBackdrop_get() {
|
156
|
-
|
157
|
-
if ((_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-modal-dialog-overlay')) {
|
156
|
+
if (this.parentElement?.hasAttribute('data-modal-dialog-overlay')) {
|
158
157
|
return this.parentElement;
|
159
158
|
}
|
160
159
|
return null;
|
@@ -169,11 +168,13 @@ _ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_in
|
|
169
168
|
case 'Escape':
|
170
169
|
this.close();
|
171
170
|
event.preventDefault();
|
171
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
172
172
|
event.stopPropagation();
|
173
173
|
break;
|
174
174
|
case 'Enter': {
|
175
175
|
const target = event.target;
|
176
176
|
if (target.getAttribute('data-close-dialog-id') === this.id) {
|
177
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
177
178
|
event.stopPropagation();
|
178
179
|
}
|
179
180
|
break;
|
@@ -20,13 +20,12 @@ let SegmentedControlElement = class SegmentedControlElement extends HTMLElement
|
|
20
20
|
__classPrivateFieldGet(this, _SegmentedControlElement_instances, "m", _SegmentedControlElement_updateButtonLabels).call(this);
|
21
21
|
}
|
22
22
|
select(event) {
|
23
|
-
var _a, _b;
|
24
23
|
const button = event.currentTarget;
|
25
24
|
for (const item of this.items) {
|
26
25
|
item.classList.remove('SegmentedControl-item--selected');
|
27
|
-
|
26
|
+
item.querySelector('[aria-current]')?.setAttribute('aria-current', 'false');
|
28
27
|
}
|
29
|
-
|
28
|
+
button.closest('li.SegmentedControl-item')?.classList.add('SegmentedControl-item--selected');
|
30
29
|
button.setAttribute('aria-current', 'true');
|
31
30
|
}
|
32
31
|
};
|
@@ -134,9 +134,9 @@ let ToggleSwitchElement = class ToggleSwitchElement extends HTMLElement {
|
|
134
134
|
credentials: 'same-origin',
|
135
135
|
method: 'POST',
|
136
136
|
headers: {
|
137
|
-
'Requested-With': 'XMLHttpRequest'
|
137
|
+
'Requested-With': 'XMLHttpRequest',
|
138
138
|
},
|
139
|
-
body
|
139
|
+
body,
|
140
140
|
});
|
141
141
|
}
|
142
142
|
catch (error) {
|
@@ -19,12 +19,12 @@ const isPopoverOpen = (() => {
|
|
19
19
|
selector = ':popover-open';
|
20
20
|
return el.matches(selector);
|
21
21
|
}
|
22
|
-
catch
|
22
|
+
catch {
|
23
23
|
try {
|
24
24
|
selector = ':open';
|
25
25
|
return el.matches(':open');
|
26
26
|
}
|
27
|
-
catch
|
27
|
+
catch {
|
28
28
|
selector = '.\\:popover-open';
|
29
29
|
return el.matches('.\\:popover-open');
|
30
30
|
}
|
@@ -253,7 +253,6 @@ class ToolTipElement extends HTMLElement {
|
|
253
253
|
return !isPopoverOpen(this);
|
254
254
|
}
|
255
255
|
connectedCallback() {
|
256
|
-
var _a, _b;
|
257
256
|
tooltips.add(this);
|
258
257
|
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updateControlReference).call(this);
|
259
258
|
__classPrivateFieldGet(this, _ToolTipElement_instances, "m", _ToolTipElement_updateDirection).call(this);
|
@@ -268,7 +267,7 @@ class ToolTipElement extends HTMLElement {
|
|
268
267
|
if (!this.control)
|
269
268
|
return;
|
270
269
|
this.setAttribute('role', 'tooltip');
|
271
|
-
|
270
|
+
__classPrivateFieldGet(this, _ToolTipElement_abortController, "f")?.abort();
|
272
271
|
__classPrivateFieldSet(this, _ToolTipElement_abortController, new AbortController(), "f");
|
273
272
|
const { signal } = __classPrivateFieldGet(this, _ToolTipElement_abortController, "f");
|
274
273
|
this.addEventListener('mouseleave', this, { signal });
|
@@ -279,7 +278,7 @@ class ToolTipElement extends HTMLElement {
|
|
279
278
|
this.control.addEventListener('mousedown', this, { signal });
|
280
279
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
281
280
|
// @ts-ignore popoverTargetElement is not in the type definition
|
282
|
-
|
281
|
+
this.control.popoverTargetElement?.addEventListener('beforetoggle', this, {
|
283
282
|
signal,
|
284
283
|
});
|
285
284
|
this.ownerDocument.addEventListener('focusout', focusOutListener);
|
@@ -287,10 +286,9 @@ class ToolTipElement extends HTMLElement {
|
|
287
286
|
this.ownerDocument.addEventListener('keydown', this, { signal, capture: true });
|
288
287
|
}
|
289
288
|
disconnectedCallback() {
|
290
|
-
var _a;
|
291
289
|
tooltips.delete(this);
|
292
290
|
openTooltips.delete(this);
|
293
|
-
|
291
|
+
__classPrivateFieldGet(this, _ToolTipElement_abortController, "f")?.abort();
|
294
292
|
}
|
295
293
|
async handleEvent(event) {
|
296
294
|
if (!this.control)
|
@@ -310,6 +308,7 @@ class ToolTipElement extends HTMLElement {
|
|
310
308
|
const isOpeningOtherPopover = event.type === 'beforetoggle' && event.currentTarget !== this;
|
311
309
|
const shouldHide = isMouseLeaveFromButton || isEscapeKeydown || isMouseDownOnButton || isOpeningOtherPopover;
|
312
310
|
if (showing && isEscapeKeydown) {
|
311
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
313
312
|
event.stopImmediatePropagation();
|
314
313
|
event.preventDefault();
|
315
314
|
}
|
@@ -47,21 +47,19 @@ let NavListElement = class NavListElement extends HTMLElement {
|
|
47
47
|
}
|
48
48
|
// expand collapsible item onClick
|
49
49
|
expandItem(item) {
|
50
|
-
|
51
|
-
(_a = item.nextElementSibling) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-hidden');
|
50
|
+
item.nextElementSibling?.removeAttribute('data-hidden');
|
52
51
|
item.setAttribute('aria-expanded', 'true');
|
53
52
|
}
|
54
53
|
collapseItem(item) {
|
55
|
-
|
56
|
-
(_a = item.nextElementSibling) === null || _a === void 0 ? void 0 : _a.setAttribute('data-hidden', '');
|
54
|
+
item.nextElementSibling?.setAttribute('data-hidden', '');
|
57
55
|
item.setAttribute('aria-expanded', 'false');
|
58
56
|
item.focus();
|
59
57
|
}
|
60
58
|
itemIsExpanded(item) {
|
61
|
-
if (
|
59
|
+
if (item?.tagName === 'A') {
|
62
60
|
return true;
|
63
61
|
}
|
64
|
-
return
|
62
|
+
return item?.getAttribute('aria-expanded') === 'true';
|
65
63
|
}
|
66
64
|
// expand/collapse item
|
67
65
|
handleItemWithSubItemClick(e) {
|
@@ -77,6 +75,7 @@ let NavListElement = class NavListElement extends HTMLElement {
|
|
77
75
|
else {
|
78
76
|
this.expandItem(button);
|
79
77
|
}
|
78
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
80
79
|
e.stopPropagation();
|
81
80
|
}
|
82
81
|
// collapse item
|
@@ -97,18 +96,18 @@ let NavListElement = class NavListElement extends HTMLElement {
|
|
97
96
|
if (this.itemIsExpanded(button) && e.key === 'Escape') {
|
98
97
|
this.collapseItem(button);
|
99
98
|
}
|
99
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
100
100
|
e.stopPropagation();
|
101
101
|
}
|
102
102
|
};
|
103
103
|
_NavListElement_instances = new WeakSet();
|
104
104
|
_NavListElement_findSelectedNavItemById = function _NavListElement_findSelectedNavItemById(itemId) {
|
105
|
-
var _a;
|
106
105
|
// First we compare the selected link to data-item-id for each nav item
|
107
106
|
for (const navItem of this.items) {
|
108
107
|
if (navItem.classList.contains('ActionListItem--hasSubItem')) {
|
109
108
|
continue;
|
110
109
|
}
|
111
|
-
const keys =
|
110
|
+
const keys = navItem.getAttribute('data-item-id')?.split(' ') || [];
|
112
111
|
if (keys.includes(itemId)) {
|
113
112
|
return navItem;
|
114
113
|
}
|
@@ -152,10 +151,9 @@ _NavListElement_deselect = function _NavListElement_deselect(navItem) {
|
|
152
151
|
}
|
153
152
|
};
|
154
153
|
_NavListElement_findParentMenu = function _NavListElement_findParentMenu(navItem) {
|
155
|
-
var _a;
|
156
154
|
if (!navItem.classList.contains('ActionListItem--subItem'))
|
157
155
|
return null;
|
158
|
-
const parent =
|
156
|
+
const parent = navItem.closest('li.ActionListItem--hasSubItem')?.querySelector('button.ActionListContent');
|
159
157
|
if (parent) {
|
160
158
|
return parent;
|
161
159
|
}
|
@@ -44,7 +44,6 @@ let NavListGroupElement = class NavListGroupElement extends HTMLElement {
|
|
44
44
|
return this.showMoreItem.getAttribute('src') || '';
|
45
45
|
}
|
46
46
|
async showMore(e) {
|
47
|
-
var _a, _b;
|
48
47
|
e.preventDefault();
|
49
48
|
if (this.showMoreDisabled)
|
50
49
|
return;
|
@@ -69,11 +68,11 @@ let NavListGroupElement = class NavListGroupElement extends HTMLElement {
|
|
69
68
|
return;
|
70
69
|
}
|
71
70
|
const fragment = __classPrivateFieldGet(this, _NavListGroupElement_instances, "m", _NavListGroupElement_parseHTML).call(this, document, html);
|
72
|
-
|
71
|
+
fragment?.querySelector('li > a')?.setAttribute('data-targets', 'nav-list-group.focusMarkers');
|
73
72
|
const listId = e.target.closest('button').getAttribute('data-list-id');
|
74
73
|
const list = document.getElementById(listId);
|
75
74
|
list.append(fragment);
|
76
|
-
|
75
|
+
this.focusMarkers.pop()?.focus();
|
77
76
|
this.showMoreDisabled = false;
|
78
77
|
}
|
79
78
|
setShowMoreItemState() {
|
@@ -11,13 +11,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
11
11
|
};
|
12
12
|
var _DialogHelperElement_abortController;
|
13
13
|
function dialogInvokerButtonHandler(event) {
|
14
|
-
var _a;
|
15
14
|
const target = event.target;
|
16
|
-
const button = target
|
15
|
+
const button = target?.closest('button');
|
17
16
|
if (!button || button.hasAttribute('disabled') || button.getAttribute('aria-disabled') === 'true')
|
18
17
|
return;
|
19
18
|
// If the user is clicking a valid dialog trigger
|
20
|
-
let dialogId = button
|
19
|
+
let dialogId = button?.getAttribute('data-show-dialog-id');
|
21
20
|
if (dialogId) {
|
22
21
|
const dialog = document.getElementById(dialogId);
|
23
22
|
if (dialog instanceof HTMLDialogElement) {
|
@@ -36,7 +35,7 @@ function dialogInvokerButtonHandler(event) {
|
|
36
35
|
let node = button;
|
37
36
|
let fixed = false;
|
38
37
|
while (node) {
|
39
|
-
node =
|
38
|
+
node = node.parentElement?.closest('[popover]:not(:popover-open)');
|
40
39
|
if (node && node.popover === 'auto') {
|
41
40
|
node.classList.add('dialog-inside-popover-fix');
|
42
41
|
node.popover = 'manual';
|
@@ -47,6 +46,7 @@ function dialogInvokerButtonHandler(event) {
|
|
47
46
|
if (fixed) {
|
48
47
|
// We need to re-open the dialog as modal, and also ensure no close event listeners
|
49
48
|
// are trying to act on the close
|
49
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
50
50
|
dialog.addEventListener('close', e => e.stopImmediatePropagation(), { once: true });
|
51
51
|
dialog.close();
|
52
52
|
dialog.showModal();
|
@@ -92,14 +92,13 @@ export class DialogHelperElement extends HTMLElement {
|
|
92
92
|
}).observe(this, { subtree: true, attributeFilter: ['open'] });
|
93
93
|
}
|
94
94
|
disconnectedCallback() {
|
95
|
-
|
96
|
-
(_a = __classPrivateFieldGet(this, _DialogHelperElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
95
|
+
__classPrivateFieldGet(this, _DialogHelperElement_abortController, "f")?.abort();
|
97
96
|
}
|
98
97
|
handleEvent(event) {
|
99
98
|
const target = event.target;
|
100
99
|
const dialog = this.dialog;
|
101
100
|
// The click target _must_ be the dialog element itself, and not elements underneath or inside.
|
102
|
-
if (target !== dialog || !
|
101
|
+
if (target !== dialog || !dialog?.open)
|
103
102
|
return;
|
104
103
|
const rect = dialog.getBoundingClientRect();
|
105
104
|
const clickWasInsideDialog = rect.top <= event.clientY &&
|
@@ -13,7 +13,7 @@ var _FocusGroupElement_instances, _FocusGroupElement_retainSignal, _FocusGroupEl
|
|
13
13
|
import '@oddbird/popover-polyfill';
|
14
14
|
const validSelectors = ['[role="menuitem"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]'];
|
15
15
|
const menuItemSelector = validSelectors.map(selector => `:not([hidden]) > ${selector}`).join(', ');
|
16
|
-
const getMnemonicFor = (item) =>
|
16
|
+
const getMnemonicFor = (item) => item.textContent?.trim()[0].toLowerCase();
|
17
17
|
const printable = /^\S$/;
|
18
18
|
class FocusGroupElement extends HTMLElement {
|
19
19
|
constructor() {
|
@@ -54,26 +54,23 @@ class FocusGroupElement extends HTMLElement {
|
|
54
54
|
this.addEventListener('focusin', this, { signal });
|
55
55
|
}
|
56
56
|
disconnectedCallback() {
|
57
|
-
|
58
|
-
(_a = __classPrivateFieldGet(this, _FocusGroupElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
57
|
+
__classPrivateFieldGet(this, _FocusGroupElement_abortController, "f")?.abort();
|
59
58
|
}
|
60
59
|
handleEvent(event) {
|
61
|
-
var _a;
|
62
60
|
const { direction, nowrap } = this;
|
63
61
|
if (event.type === 'focusin') {
|
64
62
|
if (this.retain && event.target instanceof Element && event.target.matches(menuItemSelector)) {
|
65
|
-
|
63
|
+
__classPrivateFieldGet(this, _FocusGroupElement_retainSignal, "f")?.abort();
|
66
64
|
const { signal } = (__classPrivateFieldSet(this, _FocusGroupElement_retainSignal, new AbortController(), "f"));
|
67
65
|
for (const item of __classPrivateFieldGet(this, _FocusGroupElement_instances, "a", _FocusGroupElement_items_get)) {
|
68
66
|
item.setAttribute('tabindex', item === event.target ? '0' : '-1');
|
69
67
|
const popover = event.target.closest('[popover]');
|
70
|
-
if (item === event.target &&
|
68
|
+
if (item === event.target && popover?.popover === 'auto' && popover.closest('focus-group') === this) {
|
71
69
|
popover.addEventListener('toggle', (toggleEvent) => {
|
72
|
-
var _a, _b;
|
73
70
|
if (!(toggleEvent.target instanceof Element))
|
74
71
|
return;
|
75
72
|
if (toggleEvent.newState === 'closed') {
|
76
|
-
|
73
|
+
__classPrivateFieldGet(this, _FocusGroupElement_retainSignal, "f")?.abort();
|
77
74
|
item.setAttribute('tabindex', '-1');
|
78
75
|
if (popover.id) {
|
79
76
|
const invoker = this.querySelector(`[popovertarget="${popover.id}"]`);
|
@@ -81,7 +78,7 @@ class FocusGroupElement extends HTMLElement {
|
|
81
78
|
invoker.setAttribute('tabindex', '0');
|
82
79
|
}
|
83
80
|
else {
|
84
|
-
|
81
|
+
__classPrivateFieldGet(this, _FocusGroupElement_instances, "a", _FocusGroupElement_items_get)[0]?.setAttribute('tabindex', '0');
|
85
82
|
}
|
86
83
|
}
|
87
84
|
}
|
@@ -146,13 +143,13 @@ class FocusGroupElement extends HTMLElement {
|
|
146
143
|
let el = focusEl;
|
147
144
|
do {
|
148
145
|
el = el.closest(`[popover]:not(:popover-open)`);
|
149
|
-
if (
|
146
|
+
if (el?.popover === 'auto' && !['ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
150
147
|
el.showPopover();
|
151
148
|
}
|
152
|
-
el =
|
149
|
+
el = el?.parentElement || null;
|
153
150
|
} while (el);
|
154
151
|
}
|
155
|
-
focusEl
|
152
|
+
focusEl?.focus();
|
156
153
|
}
|
157
154
|
}
|
158
155
|
}
|
@@ -8,7 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
8
8
|
import { controller, targets } from '@github/catalyst';
|
9
9
|
let PrimerMultiInputElement = class PrimerMultiInputElement extends HTMLElement {
|
10
10
|
activateField(name) {
|
11
|
-
var _a, _b;
|
12
11
|
const fieldWithName = this.findField(name);
|
13
12
|
if (!fieldWithName)
|
14
13
|
return;
|
@@ -17,11 +16,11 @@ let PrimerMultiInputElement = class PrimerMultiInputElement extends HTMLElement
|
|
17
16
|
continue;
|
18
17
|
field.setAttribute('disabled', 'disabled');
|
19
18
|
field.setAttribute('hidden', 'hidden');
|
20
|
-
|
19
|
+
field.parentElement?.setAttribute('hidden', 'hidden');
|
21
20
|
}
|
22
21
|
fieldWithName.removeAttribute('disabled');
|
23
22
|
fieldWithName.removeAttribute('hidden');
|
24
|
-
|
23
|
+
fieldWithName.parentElement?.removeAttribute('hidden');
|
25
24
|
}
|
26
25
|
findField(name) {
|
27
26
|
for (const field of this.fields) {
|
@@ -27,8 +27,7 @@ class PrimerTextFieldElement extends HTMLElement {
|
|
27
27
|
_PrimerTextFieldElement_abortController.set(this, void 0);
|
28
28
|
}
|
29
29
|
connectedCallback() {
|
30
|
-
|
31
|
-
(_a = __classPrivateFieldGet(this, _PrimerTextFieldElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
30
|
+
__classPrivateFieldGet(this, _PrimerTextFieldElement_abortController, "f")?.abort();
|
32
31
|
const { signal } = (__classPrivateFieldSet(this, _PrimerTextFieldElement_abortController, new AbortController(), "f"));
|
33
32
|
this.inputElement.addEventListener('auto-check-success', async (event) => {
|
34
33
|
const message = await event.detail.response.text();
|
@@ -45,8 +44,7 @@ class PrimerTextFieldElement extends HTMLElement {
|
|
45
44
|
}, { signal });
|
46
45
|
}
|
47
46
|
disconnectedCallback() {
|
48
|
-
|
49
|
-
(_a = __classPrivateFieldGet(this, _PrimerTextFieldElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
47
|
+
__classPrivateFieldGet(this, _PrimerTextFieldElement_abortController, "f")?.abort();
|
50
48
|
}
|
51
49
|
clearContents() {
|
52
50
|
this.inputElement.value = '';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/view-components",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.19.0-rc.1ce8b774",
|
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",
|
@@ -51,7 +51,7 @@
|
|
51
51
|
"@github/include-fragment-element": "^6.1.1",
|
52
52
|
"@github/relative-time-element": "^4.0.0",
|
53
53
|
"@github/tab-container-element": "^3.1.2",
|
54
|
-
"@oddbird/popover-polyfill": "^0.
|
54
|
+
"@oddbird/popover-polyfill": "^0.4.0",
|
55
55
|
"@primer/behaviors": "^1.3.4"
|
56
56
|
},
|
57
57
|
"devDependencies": {
|
@@ -80,12 +80,12 @@
|
|
80
80
|
"mocha": "^10.0.0",
|
81
81
|
"playwright": "^1.35.1",
|
82
82
|
"postcss": "^8.4.16",
|
83
|
-
"postcss-cli": "^
|
83
|
+
"postcss-cli": "^11.0.0",
|
84
84
|
"postcss-custom-properties-fallback": "^1.0.2",
|
85
85
|
"postcss-import": "^16.0.0",
|
86
86
|
"postcss-mixins": "^9.0.3",
|
87
87
|
"postcss-preset-env": "^9.3.0",
|
88
|
-
"prettier": "3.2.
|
88
|
+
"prettier": "3.2.5",
|
89
89
|
"rollup": "^2.79.1",
|
90
90
|
"rollup-plugin-terser": "^7.0.2",
|
91
91
|
"stylelint": "^16.1.0",
|