@primer/view-components 0.44.0-rc.b6346e6e → 0.44.0-rc.b69ecd26
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/components/primer/alpha/action_menu/action_menu_element.d.ts +5 -0
- package/app/assets/javascripts/components/primer/alpha/action_menu/action_menu_focus_zone_stack.d.ts +17 -0
- 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.d.ts +5 -0
- package/app/components/primer/alpha/action_menu/action_menu_element.js +113 -16
- package/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.d.ts +17 -0
- package/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.js +62 -0
- package/app/components/primer/beta/progress_bar.css +1 -1
- package/package.json +2 -2
- package/static/arguments.json +167 -68
- package/static/audited_at.json +4 -0
- package/static/constants.json +27 -7
- package/static/info_arch.json +711 -221
- package/static/previews.json +13 -0
- package/static/statuses.json +4 -0
@@ -11,6 +11,10 @@ export declare class ActionMenuElement extends HTMLElement {
|
|
11
11
|
#private;
|
12
12
|
includeFragment: IncludeFragmentElement;
|
13
13
|
overlay: AnchoredPositionElement;
|
14
|
+
list: HTMLElement;
|
15
|
+
static validItemRoles: string[];
|
16
|
+
static validSelectors: string[];
|
17
|
+
static menuItemSelectors: string[];
|
14
18
|
get selectVariant(): SelectVariant;
|
15
19
|
set selectVariant(variant: SelectVariant);
|
16
20
|
get dynamicLabelPrefix(): string;
|
@@ -18,6 +22,7 @@ export declare class ActionMenuElement extends HTMLElement {
|
|
18
22
|
get dynamicLabel(): boolean;
|
19
23
|
set dynamicLabel(value: boolean);
|
20
24
|
get popoverElement(): HTMLElement | null;
|
25
|
+
get childPopoverElements(): HTMLElement[];
|
21
26
|
get invokerElement(): HTMLButtonElement | null;
|
22
27
|
get invokerLabel(): HTMLElement | null;
|
23
28
|
get selectedItems(): SelectedItem[];
|
@@ -15,13 +15,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
15
15
|
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");
|
16
16
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
17
17
|
};
|
18
|
-
var _ActionMenuElement_instances, _ActionMenuElement_abortController, _ActionMenuElement_originalLabel, _ActionMenuElement_inputName, _ActionMenuElement_invokerBeingClicked, _ActionMenuElement_intersectionObserver, _ActionMenuElement_softDisableItems, _ActionMenuElement_potentiallyDisallowActivation, _ActionMenuElement_isAnchorActivationViaSpace, _ActionMenuElement_isActivation, _ActionMenuElement_handleInvokerActivated, _ActionMenuElement_handleDialogItemActivated, _ActionMenuElement_handleItemActivated, _ActionMenuElement_handleIncludeFragmentReplaced, _ActionMenuElement_handleFocusOut, _ActionMenuElement_show, _ActionMenuElement_hide, _ActionMenuElement_isOpen, _ActionMenuElement_setDynamicLabel, _ActionMenuElement_updateInput, _ActionMenuElement_firstItem_get;
|
18
|
+
var _ActionMenuElement_instances, _a, _ActionMenuElement_abortController, _ActionMenuElement_originalLabel, _ActionMenuElement_inputName, _ActionMenuElement_invokerBeingClicked, _ActionMenuElement_intersectionObserver, _ActionMenuElement_focusZoneStack, _ActionMenuElement_updateLevels, _ActionMenuElement_softDisableItems, _ActionMenuElement_potentiallyDisallowActivation, _ActionMenuElement_isAnchorActivationViaSpace, _ActionMenuElement_isClipboardActivationViaKeyboard, _ActionMenuElement_isActivation, _ActionMenuElement_handleItemKeyboardEvent, _ActionMenuElement_handleToggleEvent, _ActionMenuElement_handleInvokerActivated, _ActionMenuElement_handleDialogItemActivated, _ActionMenuElement_handleItemActivated, _ActionMenuElement_handleIncludeFragmentReplaced, _ActionMenuElement_handleFocusOut, _ActionMenuElement_show, _ActionMenuElement_hide, _ActionMenuElement_isOpen, _ActionMenuElement_setDynamicLabel, _ActionMenuElement_updateInput, _ActionMenuElement_firstItem_get, _ActionMenuElement_subMenuForItem, _ActionMenuElement_itemForSubMenu;
|
19
|
+
var ActionMenuElement_1;
|
19
20
|
import { controller, target } from '@github/catalyst';
|
20
21
|
import '@oddbird/popover-polyfill';
|
21
22
|
import { observeMutationsUntilConditionMet } from '../../utils';
|
22
|
-
|
23
|
-
|
24
|
-
let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
23
|
+
import { ActionMenuFocusZoneStack } from './action_menu_focus_zone_stack';
|
24
|
+
import { ClipboardCopyElement } from '@github/clipboard-copy-element';
|
25
|
+
let ActionMenuElement = ActionMenuElement_1 = _a = class ActionMenuElement extends HTMLElement {
|
25
26
|
constructor() {
|
26
27
|
super(...arguments);
|
27
28
|
_ActionMenuElement_instances.add(this);
|
@@ -30,6 +31,7 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
30
31
|
_ActionMenuElement_inputName.set(this, '');
|
31
32
|
_ActionMenuElement_invokerBeingClicked.set(this, false);
|
32
33
|
_ActionMenuElement_intersectionObserver.set(this, void 0);
|
34
|
+
_ActionMenuElement_focusZoneStack.set(this, void 0);
|
33
35
|
}
|
34
36
|
get selectVariant() {
|
35
37
|
return this.getAttribute('data-select-variant');
|
@@ -60,6 +62,10 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
60
62
|
get popoverElement() {
|
61
63
|
return this.invokerElement?.popoverTargetElement || null;
|
62
64
|
}
|
65
|
+
// i.e. sub-menus
|
66
|
+
get childPopoverElements() {
|
67
|
+
return Array.from(this.overlay.querySelectorAll('anchored-position'));
|
68
|
+
}
|
63
69
|
get invokerElement() {
|
64
70
|
const id = this.querySelector('[role=menu]')?.id;
|
65
71
|
if (!id)
|
@@ -96,7 +102,7 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
96
102
|
this.addEventListener('mouseover', this, { signal });
|
97
103
|
this.addEventListener('focusout', this, { signal });
|
98
104
|
this.addEventListener('mousedown', this, { signal });
|
99
|
-
this.
|
105
|
+
this.addEventListener('toggle', this, { signal, capture: true });
|
100
106
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setDynamicLabel).call(this);
|
101
107
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateInput).call(this);
|
102
108
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_softDisableItems).call(this);
|
@@ -134,6 +140,10 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
134
140
|
if (!this.includeFragment) {
|
135
141
|
this.setAttribute('data-ready', 'true');
|
136
142
|
}
|
143
|
+
const levelObserver = new MutationObserver(() => __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateLevels).call(this));
|
144
|
+
levelObserver.observe(this, { childList: true, subtree: true });
|
145
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateLevels).call(this);
|
146
|
+
__classPrivateFieldSet(this, _ActionMenuElement_focusZoneStack, new ActionMenuFocusZoneStack(), "f");
|
137
147
|
}
|
138
148
|
disconnectedCallback() {
|
139
149
|
__classPrivateFieldGet(this, _ActionMenuElement_abortController, "f").abort();
|
@@ -141,10 +151,9 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
141
151
|
handleEvent(event) {
|
142
152
|
const targetIsInvoker = this.invokerElement?.contains(event.target);
|
143
153
|
const eventIsActivation = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivation).call(this, event);
|
144
|
-
if (event.type === 'toggle' && event
|
145
|
-
|
146
|
-
|
147
|
-
});
|
154
|
+
if (event.type === 'toggle' && event instanceof ToggleEvent) {
|
155
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleToggleEvent).call(this, event);
|
156
|
+
return;
|
148
157
|
}
|
149
158
|
if (targetIsInvoker && event.type === 'mousedown') {
|
150
159
|
__classPrivateFieldSet(this, _ActionMenuElement_invokerBeingClicked, true, "f");
|
@@ -172,7 +181,7 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
172
181
|
});
|
173
182
|
return;
|
174
183
|
}
|
175
|
-
const item = event.target.closest(menuItemSelectors.join(','));
|
184
|
+
const item = event.target.closest(ActionMenuElement_1.menuItemSelectors.join(','));
|
176
185
|
const targetIsItem = item !== null;
|
177
186
|
if (targetIsItem && eventIsActivation) {
|
178
187
|
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_potentiallyDisallowActivation).call(this, event))
|
@@ -191,15 +200,26 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
191
200
|
event.preventDefault();
|
192
201
|
item.click();
|
193
202
|
}
|
203
|
+
const subMenu = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_subMenuForItem).call(this, item);
|
204
|
+
if (subMenu) {
|
205
|
+
// Prevent submitting a form when clicking on sub-menu items
|
206
|
+
event.preventDefault();
|
207
|
+
subMenu.showPopover();
|
208
|
+
return;
|
209
|
+
}
|
194
210
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleItemActivated).call(this, item);
|
195
211
|
return;
|
196
212
|
}
|
197
213
|
if (event.type === 'include-fragment-replaced') {
|
198
214
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleIncludeFragmentReplaced).call(this);
|
215
|
+
return;
|
216
|
+
}
|
217
|
+
if (targetIsItem && event instanceof KeyboardEvent) {
|
218
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleItemKeyboardEvent).call(this, event, item);
|
199
219
|
}
|
200
220
|
}
|
201
221
|
get items() {
|
202
|
-
return Array.from(this.querySelectorAll(menuItemSelectors.join(',')));
|
222
|
+
return Array.from(this.querySelectorAll(ActionMenuElement_1.menuItemSelectors.join(',')));
|
203
223
|
}
|
204
224
|
getItemById(itemId) {
|
205
225
|
return this.querySelector(`li[data-item-id="${itemId}"`);
|
@@ -274,10 +294,18 @@ _ActionMenuElement_originalLabel = new WeakMap();
|
|
274
294
|
_ActionMenuElement_inputName = new WeakMap();
|
275
295
|
_ActionMenuElement_invokerBeingClicked = new WeakMap();
|
276
296
|
_ActionMenuElement_intersectionObserver = new WeakMap();
|
297
|
+
_ActionMenuElement_focusZoneStack = new WeakMap();
|
277
298
|
_ActionMenuElement_instances = new WeakSet();
|
299
|
+
_ActionMenuElement_updateLevels = function _ActionMenuElement_updateLevels() {
|
300
|
+
let idx = 1;
|
301
|
+
for (const menu of this.querySelectorAll('[role=menu]')) {
|
302
|
+
menu.setAttribute('data-level', idx.toString());
|
303
|
+
idx++;
|
304
|
+
}
|
305
|
+
};
|
278
306
|
_ActionMenuElement_softDisableItems = function _ActionMenuElement_softDisableItems() {
|
279
307
|
const { signal } = __classPrivateFieldGet(this, _ActionMenuElement_abortController, "f");
|
280
|
-
for (const item of this.querySelectorAll(validSelectors.join(','))) {
|
308
|
+
for (const item of this.querySelectorAll(ActionMenuElement_1.validSelectors.join(','))) {
|
281
309
|
item.addEventListener('click', __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_potentiallyDisallowActivation).bind(this), { signal });
|
282
310
|
item.addEventListener('keydown', __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_potentiallyDisallowActivation).bind(this), { signal });
|
283
311
|
}
|
@@ -285,7 +313,7 @@ _ActionMenuElement_softDisableItems = function _ActionMenuElement_softDisableIte
|
|
285
313
|
_ActionMenuElement_potentiallyDisallowActivation = function _ActionMenuElement_potentiallyDisallowActivation(event) {
|
286
314
|
if (!__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivation).call(this, event))
|
287
315
|
return false;
|
288
|
-
const item = event.target.closest(menuItemSelectors.join(','));
|
316
|
+
const item = event.target.closest(ActionMenuElement_1.menuItemSelectors.join(','));
|
289
317
|
if (!item)
|
290
318
|
return false;
|
291
319
|
if (item.getAttribute('aria-disabled')) {
|
@@ -305,11 +333,57 @@ _ActionMenuElement_isAnchorActivationViaSpace = function _ActionMenuElement_isAn
|
|
305
333
|
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
306
334
|
event.key === ' ');
|
307
335
|
};
|
336
|
+
_ActionMenuElement_isClipboardActivationViaKeyboard = function _ActionMenuElement_isClipboardActivationViaKeyboard(event) {
|
337
|
+
return (event.target instanceof ClipboardCopyElement &&
|
338
|
+
event instanceof KeyboardEvent &&
|
339
|
+
event.type === 'keydown' &&
|
340
|
+
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
341
|
+
(event.key === ' ' || event.key === 'Enter'));
|
342
|
+
};
|
308
343
|
_ActionMenuElement_isActivation = function _ActionMenuElement_isActivation(event) {
|
309
344
|
// Some browsers fire MouseEvents (Firefox) and others fire PointerEvents (Chrome). Activating an item via
|
310
345
|
// enter or space counterintuitively fires one of these rather than a KeyboardEvent. Since PointerEvent
|
311
346
|
// inherits from MouseEvent, it is enough to check for MouseEvent here.
|
312
|
-
return (event instanceof MouseEvent && event.type === 'click') ||
|
347
|
+
return ((event instanceof MouseEvent && event.type === 'click') ||
|
348
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isAnchorActivationViaSpace).call(this, event) ||
|
349
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isClipboardActivationViaKeyboard).call(this, event));
|
350
|
+
};
|
351
|
+
_ActionMenuElement_handleItemKeyboardEvent = function _ActionMenuElement_handleItemKeyboardEvent(event, item) {
|
352
|
+
switch (event.key) {
|
353
|
+
case 'ArrowRight': {
|
354
|
+
const subMenu = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_subMenuForItem).call(this, item);
|
355
|
+
subMenu?.showPopover();
|
356
|
+
break;
|
357
|
+
}
|
358
|
+
case 'ArrowLeft':
|
359
|
+
if (item.closest('role[menu]') !== this.list) {
|
360
|
+
const overlay = item.closest('anchored-position');
|
361
|
+
overlay?.hidePopover();
|
362
|
+
}
|
363
|
+
break;
|
364
|
+
}
|
365
|
+
};
|
366
|
+
_ActionMenuElement_handleToggleEvent = function _ActionMenuElement_handleToggleEvent(event) {
|
367
|
+
const subMenu = event.target;
|
368
|
+
if (event.newState === 'open') {
|
369
|
+
// allow tabbing away from primary menu, but trap focus in sub-menus
|
370
|
+
const isPrimaryMenu = subMenu === this.overlay;
|
371
|
+
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").push(subMenu, { trapFocus: !isPrimaryMenu });
|
372
|
+
window.requestAnimationFrame(() => {
|
373
|
+
const firstItem = subMenu.querySelector(ActionMenuElement_1.menuItemSelectors.join(','));
|
374
|
+
firstItem?.focus();
|
375
|
+
});
|
376
|
+
}
|
377
|
+
else {
|
378
|
+
// Note that this will also cause focus to return to the invoker button, which is
|
379
|
+
// desirable
|
380
|
+
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").pop(subMenu);
|
381
|
+
const item = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_itemForSubMenu).call(this, subMenu);
|
382
|
+
const openPopover = document.querySelector(':popover-open');
|
383
|
+
if (item && !openPopover) {
|
384
|
+
item.focus();
|
385
|
+
}
|
386
|
+
}
|
313
387
|
};
|
314
388
|
_ActionMenuElement_handleInvokerActivated = function _ActionMenuElement_handleInvokerActivated(event) {
|
315
389
|
event.preventDefault();
|
@@ -412,6 +486,9 @@ _ActionMenuElement_show = function _ActionMenuElement_show() {
|
|
412
486
|
};
|
413
487
|
_ActionMenuElement_hide = function _ActionMenuElement_hide() {
|
414
488
|
this.popoverElement?.hidePopover();
|
489
|
+
for (const child of this.childPopoverElements) {
|
490
|
+
child.hidePopover();
|
491
|
+
}
|
415
492
|
};
|
416
493
|
_ActionMenuElement_isOpen = function _ActionMenuElement_isOpen() {
|
417
494
|
return this.popoverElement?.matches(':popover-open');
|
@@ -476,15 +553,35 @@ _ActionMenuElement_updateInput = function _ActionMenuElement_updateInput() {
|
|
476
553
|
}
|
477
554
|
};
|
478
555
|
_ActionMenuElement_firstItem_get = function _ActionMenuElement_firstItem_get() {
|
479
|
-
return this.querySelector(menuItemSelectors.join(','));
|
556
|
+
return this.querySelector(ActionMenuElement_1.menuItemSelectors.join(','));
|
557
|
+
};
|
558
|
+
_ActionMenuElement_subMenuForItem = function _ActionMenuElement_subMenuForItem(item) {
|
559
|
+
const popoverId = item.getAttribute('popovertarget');
|
560
|
+
if (popoverId) {
|
561
|
+
return this.querySelector(`[id="${popoverId}"]`);
|
562
|
+
}
|
563
|
+
return null;
|
480
564
|
};
|
565
|
+
_ActionMenuElement_itemForSubMenu = function _ActionMenuElement_itemForSubMenu(subMenu) {
|
566
|
+
const anchorId = subMenu.getAttribute('anchor');
|
567
|
+
if (anchorId) {
|
568
|
+
return this.querySelector(`[id="${anchorId}"]`);
|
569
|
+
}
|
570
|
+
return null;
|
571
|
+
};
|
572
|
+
ActionMenuElement.validItemRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];
|
573
|
+
ActionMenuElement.validSelectors = ActionMenuElement_1.validItemRoles.map(role => `[role="${role}"]`);
|
574
|
+
ActionMenuElement.menuItemSelectors = ActionMenuElement_1.validSelectors.map(selector => `:not([hidden]) > ${selector}`);
|
481
575
|
__decorate([
|
482
576
|
target
|
483
577
|
], ActionMenuElement.prototype, "includeFragment", void 0);
|
484
578
|
__decorate([
|
485
579
|
target
|
486
580
|
], ActionMenuElement.prototype, "overlay", void 0);
|
487
|
-
|
581
|
+
__decorate([
|
582
|
+
target
|
583
|
+
], ActionMenuElement.prototype, "list", void 0);
|
584
|
+
ActionMenuElement = ActionMenuElement_1 = __decorate([
|
488
585
|
controller
|
489
586
|
], ActionMenuElement);
|
490
587
|
export { ActionMenuElement };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import AnchoredPositionElement from '../../anchored_position';
|
2
|
+
type StackEntry = {
|
3
|
+
element: AnchoredPositionElement;
|
4
|
+
abortController?: AbortController;
|
5
|
+
};
|
6
|
+
export declare class ActionMenuFocusZoneStack {
|
7
|
+
#private;
|
8
|
+
constructor();
|
9
|
+
get current(): StackEntry | undefined;
|
10
|
+
push(next: AnchoredPositionElement, options?: {
|
11
|
+
trapFocus: boolean;
|
12
|
+
}): void;
|
13
|
+
pop(target?: AnchoredPositionElement): void;
|
14
|
+
elementIsMenuItem(element: HTMLElement): boolean;
|
15
|
+
get isEmpty(): boolean;
|
16
|
+
}
|
17
|
+
export {};
|
@@ -0,0 +1,62 @@
|
|
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 _ActionMenuFocusZoneStack_instances, _ActionMenuFocusZoneStack_stack, _ActionMenuFocusZoneStack_setupFocusZone, _ActionMenuFocusZoneStack_validItemRoles_get;
|
13
|
+
import { FocusKeys, focusTrap, focusZone } from '@primer/behaviors';
|
14
|
+
import { ActionMenuElement } from './action_menu_element';
|
15
|
+
export class ActionMenuFocusZoneStack {
|
16
|
+
constructor() {
|
17
|
+
_ActionMenuFocusZoneStack_instances.add(this);
|
18
|
+
_ActionMenuFocusZoneStack_stack.set(this, void 0);
|
19
|
+
__classPrivateFieldSet(this, _ActionMenuFocusZoneStack_stack, [], "f");
|
20
|
+
}
|
21
|
+
get current() {
|
22
|
+
return __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f")[__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").length - 1];
|
23
|
+
}
|
24
|
+
push(next, options = { trapFocus: true }) {
|
25
|
+
const { trapFocus } = options;
|
26
|
+
__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").push({ element: next, abortController: __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "m", _ActionMenuFocusZoneStack_setupFocusZone).call(this, next, trapFocus) });
|
27
|
+
}
|
28
|
+
pop(target) {
|
29
|
+
if (target) {
|
30
|
+
while (__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").length > 0 && this.current?.element !== target) {
|
31
|
+
const entry = __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").pop();
|
32
|
+
entry?.abortController?.abort();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
const entry = __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").pop();
|
36
|
+
entry?.abortController?.abort();
|
37
|
+
}
|
38
|
+
elementIsMenuItem(element) {
|
39
|
+
return __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "a", _ActionMenuFocusZoneStack_validItemRoles_get).includes(element.getAttribute('role') || '');
|
40
|
+
}
|
41
|
+
get isEmpty() {
|
42
|
+
return __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").length === 0;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
_ActionMenuFocusZoneStack_stack = new WeakMap(), _ActionMenuFocusZoneStack_instances = new WeakSet(), _ActionMenuFocusZoneStack_setupFocusZone = function _ActionMenuFocusZoneStack_setupFocusZone(containerEl, trapFocus) {
|
46
|
+
const focusZoneAbortController = focusZone(containerEl, {
|
47
|
+
bindKeys: FocusKeys.ArrowVertical | FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd | FocusKeys.Backspace,
|
48
|
+
focusOutBehavior: 'wrap',
|
49
|
+
focusableElementFilter: (element) => {
|
50
|
+
return this.elementIsMenuItem(element) && element.closest('anchored-position') === containerEl;
|
51
|
+
},
|
52
|
+
});
|
53
|
+
if (trapFocus) {
|
54
|
+
const { signal: focusZoneSignal } = focusZoneAbortController;
|
55
|
+
return focusTrap(containerEl, undefined, focusZoneSignal);
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
return focusZoneAbortController;
|
59
|
+
}
|
60
|
+
}, _ActionMenuFocusZoneStack_validItemRoles_get = function _ActionMenuFocusZoneStack_validItemRoles_get() {
|
61
|
+
return ActionMenuElement.validItemRoles;
|
62
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
.Progress{background-color:var(--
|
1
|
+
.Progress{background-color:var(--progressBar-track-bgColor);border-radius:var(--borderRadius-medium);display:flex;height:8px;outline:solid 1px var(--progressBar-track-borderColor);outline-offset:-1px;overflow:hidden}.Progress--large{height:10px}.Progress--small{height:5px}.Progress-item{outline:2px solid #0000}.Progress-item+.Progress-item{margin-left:var(--base-size-2)}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/view-components",
|
3
|
-
"version": "0.44.0-rc.
|
3
|
+
"version": "0.44.0-rc.b69ecd26",
|
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",
|
@@ -68,7 +68,7 @@
|
|
68
68
|
"@github/markdownlint-github": "^0.8.0",
|
69
69
|
"@github/prettier-config": "0.0.6",
|
70
70
|
"@playwright/test": "^1.49.1",
|
71
|
-
"@primer/css": "22.0.
|
71
|
+
"@primer/css": "22.0.2",
|
72
72
|
"@primer/stylelint-config": "^13.1.1",
|
73
73
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
74
74
|
"@rollup/plugin-typescript": "^8.3.3",
|
package/static/arguments.json
CHANGED
@@ -325,77 +325,11 @@
|
|
325
325
|
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/action_menu.rb",
|
326
326
|
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/action_menu/default/",
|
327
327
|
"parameters": [
|
328
|
-
{
|
329
|
-
"name": "menu_id",
|
330
|
-
"type": "String",
|
331
|
-
"default": "`self.class.generate_id`",
|
332
|
-
"description": "Id of the menu."
|
333
|
-
},
|
334
|
-
{
|
335
|
-
"name": "anchor_align",
|
336
|
-
"type": "Symbol",
|
337
|
-
"default": "`:start`",
|
338
|
-
"description": "One of `:center`, `:end`, or `:start`.."
|
339
|
-
},
|
340
|
-
{
|
341
|
-
"name": "anchor_side",
|
342
|
-
"type": "Symbol",
|
343
|
-
"default": "`:outside_bottom`",
|
344
|
-
"description": "One of `:inside_bottom`, `:inside_center`, `:inside_left`, `:inside_right`, `:inside_top`, `:outside_bottom`, `:outside_left`, `:outside_right`, or `:outside_top`.."
|
345
|
-
},
|
346
|
-
{
|
347
|
-
"name": "size",
|
348
|
-
"type": "Symbol",
|
349
|
-
"default": "`:auto`",
|
350
|
-
"description": "One of `:auto`, `:large`, `:medium`, `:medium_portrait`, `:small`, or `:xlarge`.."
|
351
|
-
},
|
352
|
-
{
|
353
|
-
"name": "src",
|
354
|
-
"type": "String",
|
355
|
-
"default": "`nil`",
|
356
|
-
"description": "Used with an `include-fragment` element to load menu content from the given source URL."
|
357
|
-
},
|
358
|
-
{
|
359
|
-
"name": "preload",
|
360
|
-
"type": "Boolean",
|
361
|
-
"default": "`false`",
|
362
|
-
"description": "When true, and src is present, loads the `include-fragment` on trigger hover."
|
363
|
-
},
|
364
|
-
{
|
365
|
-
"name": "dynamic_label",
|
366
|
-
"type": "Boolean",
|
367
|
-
"default": "`false`",
|
368
|
-
"description": "Whether or not to display the text of the currently selected item in the show button."
|
369
|
-
},
|
370
|
-
{
|
371
|
-
"name": "dynamic_label_prefix",
|
372
|
-
"type": "String",
|
373
|
-
"default": "`nil`",
|
374
|
-
"description": "If provided, the prefix is prepended to the dynamic label and displayed in the show button."
|
375
|
-
},
|
376
|
-
{
|
377
|
-
"name": "select_variant",
|
378
|
-
"type": "Symbol",
|
379
|
-
"default": "`:none`",
|
380
|
-
"description": "One of `:multiple`, `:none`, or `:single`."
|
381
|
-
},
|
382
|
-
{
|
383
|
-
"name": "form_arguments",
|
384
|
-
"type": "Hash",
|
385
|
-
"default": "`{}`",
|
386
|
-
"description": "Allows an `ActionMenu` to act as a select list in multi- and single-select modes. Pass the `builder:` and `name:` options to this hash. `builder:` should be an instance of `ActionView::Helpers::FormBuilder`, which are created by the standard Rails `#form_with` and `#form_for` helpers. The `name:` option is the desired name of the field that will be included in the params sent to the server on form submission."
|
387
|
-
},
|
388
|
-
{
|
389
|
-
"name": "overlay_arguments",
|
390
|
-
"type": "Hash",
|
391
|
-
"default": "`{}`",
|
392
|
-
"description": "Arguments to pass to the underlying [Overlay](/components/alpha/overlay)"
|
393
|
-
},
|
394
328
|
{
|
395
329
|
"name": "system_arguments",
|
396
330
|
"type": "Hash",
|
397
331
|
"default": "N/A",
|
398
|
-
"description": "
|
332
|
+
"description": "The arguments accepted by [ActionMenu::PrimaryMenu](/components/alpha/actionmenuprimarymenu)."
|
399
333
|
}
|
400
334
|
]
|
401
335
|
},
|
@@ -484,7 +418,7 @@
|
|
484
418
|
"name": "system_arguments",
|
485
419
|
"type": "Hash",
|
486
420
|
"default": "N/A",
|
487
|
-
"description": "The arguments accepted by [
|
421
|
+
"description": "The arguments accepted by [ActionMenu::ListWrapper](/components/alpha/actionmenulistwrapper)"
|
488
422
|
}
|
489
423
|
]
|
490
424
|
},
|
@@ -510,6 +444,171 @@
|
|
510
444
|
}
|
511
445
|
]
|
512
446
|
},
|
447
|
+
{
|
448
|
+
"component": "ActionMenu::Menu",
|
449
|
+
"status": "alpha",
|
450
|
+
"a11y_reviewed": false,
|
451
|
+
"short_name": "ActionMenuMenu",
|
452
|
+
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/action_menu/menu.rb",
|
453
|
+
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/action_menu/menu/default/",
|
454
|
+
"parameters": [
|
455
|
+
{
|
456
|
+
"name": "anchor_align",
|
457
|
+
"type": "Symbol",
|
458
|
+
"default": "N/A",
|
459
|
+
"description": "One of `:center`, `:end`, or `:start`."
|
460
|
+
},
|
461
|
+
{
|
462
|
+
"name": "anchor_side",
|
463
|
+
"type": "Symbol",
|
464
|
+
"default": "N/A",
|
465
|
+
"description": "One of `:inside_bottom`, `:inside_center`, `:inside_left`, `:inside_right`, `:inside_top`, `:outside_bottom`, `:outside_left`, `:outside_right`, or `:outside_top`."
|
466
|
+
},
|
467
|
+
{
|
468
|
+
"name": "menu_id",
|
469
|
+
"type": "String",
|
470
|
+
"default": "`self.class.generate_id`",
|
471
|
+
"description": "Id of the menu."
|
472
|
+
},
|
473
|
+
{
|
474
|
+
"name": "size",
|
475
|
+
"type": "Symbol",
|
476
|
+
"default": "`:auto`",
|
477
|
+
"description": "One of `:auto`, `:large`, `:medium`, `:medium_portrait`, `:small`, or `:xlarge`."
|
478
|
+
},
|
479
|
+
{
|
480
|
+
"name": "src",
|
481
|
+
"type": "String",
|
482
|
+
"default": "`nil`",
|
483
|
+
"description": "Used with an `include-fragment` element to load menu content from the given source URL."
|
484
|
+
},
|
485
|
+
{
|
486
|
+
"name": "preload",
|
487
|
+
"type": "Boolean",
|
488
|
+
"default": "`false`",
|
489
|
+
"description": "When true, and src is present, loads the `include-fragment` on trigger hover."
|
490
|
+
},
|
491
|
+
{
|
492
|
+
"name": "select_variant",
|
493
|
+
"type": "Symbol",
|
494
|
+
"default": "`:none`",
|
495
|
+
"description": "One of `:multiple`, `:none`, or `:single`."
|
496
|
+
},
|
497
|
+
{
|
498
|
+
"name": "form_arguments",
|
499
|
+
"type": "Hash",
|
500
|
+
"default": "`{}`",
|
501
|
+
"description": "Allows an `ActionMenu` to act as a select list in multi- and single-select modes. Pass the `builder:` and `name:` options to this hash. `builder:` should be an instance of `ActionView::Helpers::FormBuilder`, which are created by the standard Rails `#form_with` and `#form_for` helpers. The `name:` option is the desired name of the field that will be included in the params sent to the server on form submission."
|
502
|
+
},
|
503
|
+
{
|
504
|
+
"name": "overlay_arguments",
|
505
|
+
"type": "Hash",
|
506
|
+
"default": "`{}`",
|
507
|
+
"description": "Arguments to pass to the underlying [Overlay](/components/alpha/overlay)"
|
508
|
+
},
|
509
|
+
{
|
510
|
+
"name": "list_arguments",
|
511
|
+
"type": "Hash",
|
512
|
+
"default": "`{}`",
|
513
|
+
"description": "Arguments to pass to the underlying [ActionMenu::List](/components/alpha/actionmenulist)"
|
514
|
+
},
|
515
|
+
{
|
516
|
+
"name": "system_arguments",
|
517
|
+
"type": "Hash",
|
518
|
+
"default": "N/A",
|
519
|
+
"description": "[System arguments](/system-arguments)."
|
520
|
+
}
|
521
|
+
]
|
522
|
+
},
|
523
|
+
{
|
524
|
+
"component": "ActionMenu::PrimaryMenu",
|
525
|
+
"status": "alpha",
|
526
|
+
"a11y_reviewed": false,
|
527
|
+
"short_name": "ActionMenuPrimaryMenu",
|
528
|
+
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/action_menu/primary_menu.rb",
|
529
|
+
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/action_menu/primary_menu/default/",
|
530
|
+
"parameters": [
|
531
|
+
{
|
532
|
+
"name": "anchor_align",
|
533
|
+
"type": "Symbol",
|
534
|
+
"default": "`:start`",
|
535
|
+
"description": "One of `:center`, `:end`, or `:start`."
|
536
|
+
},
|
537
|
+
{
|
538
|
+
"name": "anchor_side",
|
539
|
+
"type": "Symbol",
|
540
|
+
"default": "`:outside_bottom`",
|
541
|
+
"description": "One of `:inside_bottom`, `:inside_center`, `:inside_left`, `:inside_right`, `:inside_top`, `:outside_bottom`, `:outside_left`, `:outside_right`, or `:outside_top`."
|
542
|
+
},
|
543
|
+
{
|
544
|
+
"name": "dynamic_label",
|
545
|
+
"type": "Boolean",
|
546
|
+
"default": "`false`",
|
547
|
+
"description": "Whether or not to display the text of the currently selected item in the show button."
|
548
|
+
},
|
549
|
+
{
|
550
|
+
"name": "dynamic_label_prefix",
|
551
|
+
"type": "String",
|
552
|
+
"default": "`nil`",
|
553
|
+
"description": "If provided, the prefix is prepended to the dynamic label and displayed in the show button."
|
554
|
+
},
|
555
|
+
{
|
556
|
+
"name": "system_arguments",
|
557
|
+
"type": "Hash",
|
558
|
+
"default": "N/A",
|
559
|
+
"description": "[System arguments](/system-arguments)."
|
560
|
+
}
|
561
|
+
]
|
562
|
+
},
|
563
|
+
{
|
564
|
+
"component": "ActionMenu::SubMenu",
|
565
|
+
"status": "alpha",
|
566
|
+
"a11y_reviewed": false,
|
567
|
+
"short_name": "ActionMenuSubMenu",
|
568
|
+
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/action_menu/sub_menu.rb",
|
569
|
+
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/action_menu/sub_menu/default/",
|
570
|
+
"parameters": [
|
571
|
+
{
|
572
|
+
"name": "menu_id",
|
573
|
+
"type": "String",
|
574
|
+
"default": "`self.class.generate_id`",
|
575
|
+
"description": "Id of the menu."
|
576
|
+
},
|
577
|
+
{
|
578
|
+
"name": "anchor_align",
|
579
|
+
"type": "Symbol",
|
580
|
+
"default": "`:start`",
|
581
|
+
"description": "One of `:center`, `:end`, or `:start`."
|
582
|
+
},
|
583
|
+
{
|
584
|
+
"name": "anchor_side",
|
585
|
+
"type": "Symbol",
|
586
|
+
"default": "`:outside_right`",
|
587
|
+
"description": "One of `:inside_bottom`, `:inside_center`, `:inside_left`, `:inside_right`, `:inside_top`, `:outside_bottom`, `:outside_left`, `:outside_right`, or `:outside_top`."
|
588
|
+
},
|
589
|
+
{
|
590
|
+
"name": "overlay_arguments",
|
591
|
+
"type": "Hash",
|
592
|
+
"default": "`{}`",
|
593
|
+
"description": "Arguments to pass to the underlying [Overlay](/components/alpha/overlay)"
|
594
|
+
},
|
595
|
+
{
|
596
|
+
"name": "system_arguments",
|
597
|
+
"type": "Hash",
|
598
|
+
"default": "N/A",
|
599
|
+
"description": "[System arguments](/system-arguments)."
|
600
|
+
}
|
601
|
+
]
|
602
|
+
},
|
603
|
+
{
|
604
|
+
"component": "ActionMenu::SubMenuItem",
|
605
|
+
"status": "alpha",
|
606
|
+
"a11y_reviewed": false,
|
607
|
+
"short_name": "ActionMenuSubMenuItem",
|
608
|
+
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/action_menu/sub_menu_item.rb",
|
609
|
+
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/action_menu/sub_menu_item/default/",
|
610
|
+
"parameters": []
|
611
|
+
},
|
513
612
|
{
|
514
613
|
"component": "AutoComplete",
|
515
614
|
"status": "deprecated",
|
package/static/audited_at.json
CHANGED
@@ -12,6 +12,10 @@
|
|
12
12
|
"Primer::Alpha::ActionMenu::Heading": "",
|
13
13
|
"Primer::Alpha::ActionMenu::List": "",
|
14
14
|
"Primer::Alpha::ActionMenu::ListWrapper": "2023-07-10",
|
15
|
+
"Primer::Alpha::ActionMenu::Menu": "",
|
16
|
+
"Primer::Alpha::ActionMenu::PrimaryMenu": "",
|
17
|
+
"Primer::Alpha::ActionMenu::SubMenu": "",
|
18
|
+
"Primer::Alpha::ActionMenu::SubMenuItem": "",
|
15
19
|
"Primer::Alpha::AutoComplete": "",
|
16
20
|
"Primer::Alpha::AutoComplete::Item": "",
|
17
21
|
"Primer::Alpha::Banner": "",
|