@openproject/primer-view-components 0.96.0-rc.6be00b612 → 0.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/assets/javascripts/primer_view_components.js +5 -5
- 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_bar.css +1 -1
- package/app/components/primer/alpha/action_list.css +1 -1
- package/app/components/primer/alpha/action_list.css.json +11 -11
- package/app/components/primer/alpha/action_menu/action_menu_element.d.ts +6 -0
- package/app/components/primer/alpha/action_menu/action_menu_element.js +354 -66
- package/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.d.ts +3 -0
- package/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.js +33 -8
- package/app/components/primer/alpha/auto_complete.css +1 -1
- package/app/components/primer/alpha/banner.css +1 -1
- package/app/components/primer/alpha/button_marketing.css +1 -1
- package/app/components/primer/alpha/dialog.css +1 -1
- package/app/components/primer/alpha/dropdown.css +1 -1
- package/app/components/primer/alpha/dropdown.css.json +1 -1
- package/app/components/primer/alpha/layout.css +1 -1
- package/app/components/primer/alpha/layout.css.json +3 -3
- package/app/components/primer/alpha/menu.css +1 -1
- package/app/components/primer/alpha/menu.css.json +3 -3
- package/app/components/primer/alpha/overlay.css +1 -1
- package/app/components/primer/alpha/segmented_control.css +1 -1
- package/app/components/primer/alpha/segmented_control.css.json +1 -1
- package/app/components/primer/alpha/select_panel.css +1 -1
- package/app/components/primer/alpha/skeleton_box.css +1 -1
- package/app/components/primer/alpha/stack.css +1 -1
- package/app/components/primer/alpha/stack_item.css +1 -1
- package/app/components/primer/alpha/tab_nav.css +1 -1
- package/app/components/primer/alpha/text_field.css +1 -1
- package/app/components/primer/alpha/toggle_switch.css +1 -1
- package/app/components/primer/alpha/tree_view.css +1 -1
- package/app/components/primer/alpha/tree_view.css.json +3 -3
- package/app/components/primer/alpha/underline_nav.css +1 -1
- package/app/components/primer/beta/border_box.css +1 -1
- package/app/components/primer/beta/border_box.css.json +5 -5
- package/app/components/primer/beta/button.css +1 -1
- package/app/components/primer/beta/counter.css +1 -1
- package/app/components/primer/beta/flash.css +1 -1
- package/app/components/primer/beta/link.css +1 -1
- package/app/components/primer/beta/link.css.json +1 -1
- package/app/components/primer/beta/popover.css +1 -1
- package/app/components/primer/beta/progress_bar.css +1 -1
- package/app/components/primer/beta/state.css +1 -1
- package/app/components/primer/beta/state.css.json +2 -2
- package/app/components/primer/beta/timeline_item.css +1 -1
- package/app/components/primer/open_project/border_grid.css +1 -1
- package/app/components/primer/open_project/color_field.css +1 -1
- package/app/components/primer/open_project/inline_message.css +1 -1
- package/app/components/primer/open_project/input_group.css +1 -1
- package/app/components/primer/open_project/page_header.css +1 -1
- package/app/components/primer/open_project/page_header.css.json +2 -2
- package/app/components/primer/open_project/pagination.css +1 -1
- package/app/components/primer/open_project/pagination.css.json +1 -1
- package/app/components/primer/open_project/sub_header.css +1 -1
- package/app/components/primer/truncate.css +1 -1
- package/app/components/primer/truncate.css.json +3 -4
- package/package.json +4 -3
- package/static/arguments.json +13 -1
- package/static/constants.json +8 -0
- package/static/info_arch.json +40 -2
- package/static/previews.json +26 -0
- package/app/components/primer/alpha/text_field.css.json +0 -134
- package/app/components/primer/alpha/toggle_switch.css.json +0 -40
- package/app/components/primer/alpha/underline_nav.css.json +0 -26
- package/app/components/primer/beta/button.css.json +0 -101
|
@@ -4,18 +4,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
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
|
+
};
|
|
7
12
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
13
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
14
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
15
|
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");
|
|
11
16
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
17
|
};
|
|
13
|
-
var
|
|
14
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
17
|
-
};
|
|
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_handleBeforeToggleEvent, _ActionMenuElement_handleToggleEvent, _ActionMenuElement_toggledMenu, _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;
|
|
18
|
+
var _ActionMenuElement_instances, _a, _ActionMenuElement_abortController, _ActionMenuElement_originalLabel, _ActionMenuElement_inputName, _ActionMenuElement_invokerBeingClicked, _ActionMenuElement_intersectionObserver, _ActionMenuElement_focusZoneStack, _ActionMenuElement_request, _ActionMenuElement_ownedLoaders, _ActionMenuElement_emptyLoaders, _ActionMenuElement_scrollUpdater, _ActionMenuElement_bindHostListeners, _ActionMenuElement_setupSubMenuLoading, _ActionMenuElement_observeInvokerPosition, _ActionMenuElement_updateLevels, _ActionMenuElement_deferred_get, _ActionMenuElement_preload_get, _ActionMenuElement_body_get, _ActionMenuElement_sync, _ActionMenuElement_invalidate, _ActionMenuElement_load, _ActionMenuElement_keepInputs, _ActionMenuElement_dropKeptInputs, _ActionMenuElement_listen, _ActionMenuElement_noLoadPending, _ActionMenuElement_updateReady, _ActionMenuElement_onBodyMutation, _ActionMenuElement_adopt, _ActionMenuElement_keepOpenWhileLoading, _ActionMenuElement_pruneFocusZones, _ActionMenuElement_softDisableItems, _ActionMenuElement_potentiallyDisallowActivation, _ActionMenuElement_isAnchorActivationViaSpace, _ActionMenuElement_isClipboardActivationViaKeyboard, _ActionMenuElement_isActivation, _ActionMenuElement_handleItemKeyboardEvent, _ActionMenuElement_handleBeforeToggleEvent, _ActionMenuElement_handleToggleEvent, _ActionMenuElement_toggledMenu, _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
19
|
var ActionMenuElement_1;
|
|
20
20
|
import { controller, target } from '@github/catalyst';
|
|
21
21
|
import '@oddbird/popover-polyfill';
|
|
@@ -25,7 +25,7 @@ import { ActionMenuFocusZoneStack } from './action_menu_focus_zone_stack';
|
|
|
25
25
|
import { ClipboardCopyElement } from '@github/clipboard-copy-element';
|
|
26
26
|
let ActionMenuElement = ActionMenuElement_1 = _a = class ActionMenuElement extends HTMLElement {
|
|
27
27
|
constructor() {
|
|
28
|
-
super(
|
|
28
|
+
super();
|
|
29
29
|
_ActionMenuElement_instances.add(this);
|
|
30
30
|
_ActionMenuElement_abortController.set(this, void 0);
|
|
31
31
|
_ActionMenuElement_originalLabel.set(this, '');
|
|
@@ -33,6 +33,57 @@ let ActionMenuElement = ActionMenuElement_1 = _a = class ActionMenuElement exten
|
|
|
33
33
|
_ActionMenuElement_invokerBeingClicked.set(this, false);
|
|
34
34
|
_ActionMenuElement_intersectionObserver.set(this, void 0);
|
|
35
35
|
_ActionMenuElement_focusZoneStack.set(this, void 0);
|
|
36
|
+
// The current request of a deferred primary menu: the loader it was made
|
|
37
|
+
// with and the src it was made for. Never updated; a new request replaces it.
|
|
38
|
+
// The src is recorded because the loader's attribute is configuration a
|
|
39
|
+
// morph may rewrite while the request is in flight; the record is what was
|
|
40
|
+
// requested, so a rewritten loader cannot pass an old response off as new.
|
|
41
|
+
_ActionMenuElement_request.set(this, null
|
|
42
|
+
// Every primary loader this element created or adopted, so completions of
|
|
43
|
+
// superseded ones can be told apart from sub-menu fragments.
|
|
44
|
+
);
|
|
45
|
+
// Every primary loader this element created or adopted, so completions of
|
|
46
|
+
// superseded ones can be told apart from sub-menu fragments.
|
|
47
|
+
_ActionMenuElement_ownedLoaders.set(this, new WeakSet()
|
|
48
|
+
// Loaders whose response had no menu items, with the body they left
|
|
49
|
+
// empty. That body staying empty is not a reason to load again before the
|
|
50
|
+
// next open; a body other code puts in its place is.
|
|
51
|
+
);
|
|
52
|
+
// Loaders whose response had no menu items, with the body they left
|
|
53
|
+
// empty. That body staying empty is not a reason to load again before the
|
|
54
|
+
// next open; a body other code puts in its place is.
|
|
55
|
+
_ActionMenuElement_emptyLoaders.set(this, new WeakMap());
|
|
56
|
+
_ActionMenuElement_scrollUpdater.set(this, () => {
|
|
57
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
|
58
|
+
this.overlay?.update();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Never disconnected: it observes the element's own subtree, so it keeps
|
|
62
|
+
// working while the element is detached. A local, not a field: the
|
|
63
|
+
// registration keeps it alive as long as the element is.
|
|
64
|
+
const observer = new MutationObserver(records => {
|
|
65
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_onBodyMutation).call(this, records);
|
|
66
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateLevels).call(this);
|
|
67
|
+
});
|
|
68
|
+
observer.observe(this, { childList: true, subtree: true });
|
|
69
|
+
__classPrivateFieldSet(this, _ActionMenuElement_focusZoneStack, new ActionMenuFocusZoneStack(), "f");
|
|
70
|
+
// The code below updates the menu (i.e. overlay) position whenever the invoker button
|
|
71
|
+
// changes position within its scroll container.
|
|
72
|
+
//
|
|
73
|
+
// See: https://github.com/primer/view_components/issues/3175
|
|
74
|
+
__classPrivateFieldSet(this, _ActionMenuElement_intersectionObserver, new IntersectionObserver(entries => {
|
|
75
|
+
for (const entry of entries) {
|
|
76
|
+
if (entry.target !== this.invokerElement)
|
|
77
|
+
continue;
|
|
78
|
+
if (entry.isIntersecting) {
|
|
79
|
+
// eslint-disable-next-line github/prefer-observers
|
|
80
|
+
window.addEventListener('scroll', __classPrivateFieldGet(this, _ActionMenuElement_scrollUpdater, "f"), { capture: true });
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
window.removeEventListener('scroll', __classPrivateFieldGet(this, _ActionMenuElement_scrollUpdater, "f"), { capture: true });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}), "f");
|
|
36
87
|
}
|
|
37
88
|
get selectVariant() {
|
|
38
89
|
return this.getAttribute('data-select-variant');
|
|
@@ -69,14 +120,13 @@ let ActionMenuElement = ActionMenuElement_1 = _a = class ActionMenuElement exten
|
|
|
69
120
|
}
|
|
70
121
|
get invokerElement() {
|
|
71
122
|
const id = this.querySelector('[role=menu]')?.id;
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (el.getAttribute('aria-controls') === id) {
|
|
123
|
+
if (id) {
|
|
124
|
+
const el = this.querySelector(`[aria-controls="${CSS.escape(id)}"]`);
|
|
125
|
+
if (el)
|
|
76
126
|
return el;
|
|
77
|
-
}
|
|
78
127
|
}
|
|
79
|
-
|
|
128
|
+
const overlayId = this.overlay?.id;
|
|
129
|
+
return overlayId ? this.querySelector(`[popovertarget="${CSS.escape(overlayId)}"]`) : null;
|
|
80
130
|
}
|
|
81
131
|
get invokerLabel() {
|
|
82
132
|
if (!this.invokerElement)
|
|
@@ -97,58 +147,33 @@ let ActionMenuElement = ActionMenuElement_1 = _a = class ActionMenuElement exten
|
|
|
97
147
|
return results;
|
|
98
148
|
}
|
|
99
149
|
connectedCallback() {
|
|
100
|
-
|
|
101
|
-
this.addEventListener('keydown', this, { signal });
|
|
102
|
-
this.addEventListener('click', this, { signal });
|
|
103
|
-
this.addEventListener('mouseover', this, { signal });
|
|
104
|
-
this.addEventListener('focusout', this, { signal });
|
|
105
|
-
this.addEventListener('mousedown', this, { signal });
|
|
106
|
-
this.addEventListener('beforetoggle', this, { signal, capture: true });
|
|
107
|
-
this.addEventListener('toggle', this, { signal, capture: true });
|
|
150
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_bindHostListeners).call(this);
|
|
108
151
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setDynamicLabel).call(this);
|
|
109
152
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateInput).call(this);
|
|
110
153
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_softDisableItems).call(this);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
// The code below updates the menu (i.e. overlay) position whenever the invoker button
|
|
117
|
-
// changes position within its scroll container.
|
|
118
|
-
//
|
|
119
|
-
// See: https://github.com/primer/view_components/issues/3175
|
|
120
|
-
const scrollUpdater = () => {
|
|
121
|
-
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
|
122
|
-
this.overlay?.update();
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
__classPrivateFieldSet(this, _ActionMenuElement_intersectionObserver, new IntersectionObserver(entries => {
|
|
126
|
-
for (const entry of entries) {
|
|
127
|
-
const elem = entry.target;
|
|
128
|
-
if (elem === this.invokerElement) {
|
|
129
|
-
if (entry.isIntersecting) {
|
|
130
|
-
// eslint-disable-next-line github/prefer-observers
|
|
131
|
-
window.addEventListener('scroll', scrollUpdater, { capture: true });
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
window.removeEventListener('scroll', scrollUpdater, { capture: true });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}), "f");
|
|
139
|
-
observeMutationsUntilConditionMet(this, () => Boolean(this.invokerElement), () => __classPrivateFieldGet(this, _ActionMenuElement_intersectionObserver, "f").observe(this.invokerElement));
|
|
140
|
-
// If there's no include fragment, then no async fetching will occur and we can
|
|
141
|
-
// mark the component as ready.
|
|
142
|
-
if (!this.includeFragment) {
|
|
154
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setupSubMenuLoading).call(this);
|
|
155
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_sync).call(this);
|
|
156
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_observeInvokerPosition).call(this);
|
|
157
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_noLoadPending).call(this)) {
|
|
143
158
|
this.setAttribute('data-ready', 'true');
|
|
144
159
|
}
|
|
145
|
-
const levelObserver = new MutationObserver(() => __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateLevels).call(this));
|
|
146
|
-
levelObserver.observe(this, { childList: true, subtree: true });
|
|
147
160
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateLevels).call(this);
|
|
148
|
-
__classPrivateFieldSet(this, _ActionMenuElement_focusZoneStack, new ActionMenuFocusZoneStack(), "f");
|
|
149
161
|
}
|
|
150
162
|
disconnectedCallback() {
|
|
151
163
|
__classPrivateFieldGet(this, _ActionMenuElement_abortController, "f").abort();
|
|
164
|
+
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").clear();
|
|
165
|
+
__classPrivateFieldGet(this, _ActionMenuElement_intersectionObserver, "f").disconnect();
|
|
166
|
+
window.removeEventListener('scroll', __classPrivateFieldGet(this, _ActionMenuElement_scrollUpdater, "f"), { capture: true });
|
|
167
|
+
}
|
|
168
|
+
attributeChangedCallback(name) {
|
|
169
|
+
if (name === 'src')
|
|
170
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_sync).call(this);
|
|
171
|
+
}
|
|
172
|
+
// Forgets the current request so the menu loads again at the current src:
|
|
173
|
+
// at once when open or preloaded, otherwise when it next opens.
|
|
174
|
+
refresh() {
|
|
175
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_invalidate).call(this);
|
|
176
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_sync).call(this);
|
|
152
177
|
}
|
|
153
178
|
handleEvent(event) {
|
|
154
179
|
const targetIsInvoker = this.invokerElement?.contains(event.target);
|
|
@@ -216,7 +241,34 @@ let ActionMenuElement = ActionMenuElement_1 = _a = class ActionMenuElement exten
|
|
|
216
241
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleItemActivated).call(this, item);
|
|
217
242
|
return;
|
|
218
243
|
}
|
|
244
|
+
if (event.type === 'include-fragment-replace') {
|
|
245
|
+
const loader = event.target;
|
|
246
|
+
if (loader !== __classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader)
|
|
247
|
+
return;
|
|
248
|
+
// Other code removed the current loader before it completed, eg. by
|
|
249
|
+
// emptying the body, or rewrote its src, eg. by a morph: its response is
|
|
250
|
+
// not the one requested and must not render or mark the menu ready
|
|
251
|
+
const body = __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_body_get);
|
|
252
|
+
if (!body || loader.parentElement !== body || (loader.getAttribute('src') ?? '').trim() !== __classPrivateFieldGet(this, _ActionMenuElement_request, "f").src) {
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// A response without menu items is discarded, so the body stays empty
|
|
257
|
+
// and the menu loads again when it next opens
|
|
258
|
+
const fragment = event instanceof CustomEvent ? event.detail?.fragment : null;
|
|
259
|
+
if (!(fragment instanceof DocumentFragment))
|
|
260
|
+
return;
|
|
261
|
+
if (!fragment.querySelector(ActionMenuElement_1.menuItemSelectors.join(','))) {
|
|
262
|
+
fragment.replaceChildren();
|
|
263
|
+
__classPrivateFieldGet(this, _ActionMenuElement_emptyLoaders, "f").set(loader, body);
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
219
267
|
if (event.type === 'include-fragment-replaced') {
|
|
268
|
+
// A superseded primary loader that completed late
|
|
269
|
+
const loader = event.target;
|
|
270
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_ownedLoaders, "f").has(loader) && loader !== __classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader)
|
|
271
|
+
return;
|
|
220
272
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleIncludeFragmentReplaced).call(this);
|
|
221
273
|
return;
|
|
222
274
|
}
|
|
@@ -301,14 +353,198 @@ _ActionMenuElement_inputName = new WeakMap();
|
|
|
301
353
|
_ActionMenuElement_invokerBeingClicked = new WeakMap();
|
|
302
354
|
_ActionMenuElement_intersectionObserver = new WeakMap();
|
|
303
355
|
_ActionMenuElement_focusZoneStack = new WeakMap();
|
|
356
|
+
_ActionMenuElement_request = new WeakMap();
|
|
357
|
+
_ActionMenuElement_ownedLoaders = new WeakMap();
|
|
358
|
+
_ActionMenuElement_emptyLoaders = new WeakMap();
|
|
359
|
+
_ActionMenuElement_scrollUpdater = new WeakMap();
|
|
304
360
|
_ActionMenuElement_instances = new WeakSet();
|
|
361
|
+
_ActionMenuElement_bindHostListeners = function _ActionMenuElement_bindHostListeners() {
|
|
362
|
+
const { signal } = (__classPrivateFieldSet(this, _ActionMenuElement_abortController, new AbortController(), "f"));
|
|
363
|
+
this.addEventListener('keydown', this, { signal });
|
|
364
|
+
this.addEventListener('click', this, { signal });
|
|
365
|
+
this.addEventListener('mouseover', this, { signal });
|
|
366
|
+
this.addEventListener('focusout', this, { signal });
|
|
367
|
+
this.addEventListener('mousedown', this, { signal });
|
|
368
|
+
this.addEventListener('beforetoggle', this, { signal, capture: true });
|
|
369
|
+
this.addEventListener('toggle', this, { signal, capture: true });
|
|
370
|
+
};
|
|
371
|
+
_ActionMenuElement_setupSubMenuLoading = function _ActionMenuElement_setupSubMenuLoading() {
|
|
372
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_deferred_get) || !this.includeFragment)
|
|
373
|
+
return;
|
|
374
|
+
this.includeFragment.addEventListener('include-fragment-replaced', this, {
|
|
375
|
+
signal: __classPrivateFieldGet(this, _ActionMenuElement_abortController, "f").signal,
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
_ActionMenuElement_observeInvokerPosition = function _ActionMenuElement_observeInvokerPosition() {
|
|
379
|
+
observeMutationsUntilConditionMet(this, () => Boolean(this.invokerElement), () => __classPrivateFieldGet(this, _ActionMenuElement_intersectionObserver, "f").observe(this.invokerElement));
|
|
380
|
+
};
|
|
305
381
|
_ActionMenuElement_updateLevels = function _ActionMenuElement_updateLevels() {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
menu.setAttribute('data-level', idx.toString());
|
|
309
|
-
idx++;
|
|
382
|
+
for (const [index, menu] of this.querySelectorAll('[role=menu]').entries()) {
|
|
383
|
+
menu.setAttribute('data-level', String(index + 1));
|
|
310
384
|
}
|
|
311
385
|
};
|
|
386
|
+
_ActionMenuElement_deferred_get = function _ActionMenuElement_deferred_get() {
|
|
387
|
+
return Boolean(this.loaderTemplate);
|
|
388
|
+
};
|
|
389
|
+
_ActionMenuElement_preload_get = function _ActionMenuElement_preload_get() {
|
|
390
|
+
return this.loaderTemplate?.content.firstElementChild?.getAttribute('loading') === 'eager';
|
|
391
|
+
};
|
|
392
|
+
_ActionMenuElement_body_get = function _ActionMenuElement_body_get() {
|
|
393
|
+
return this.overlayBody ?? null;
|
|
394
|
+
};
|
|
395
|
+
_ActionMenuElement_sync = function _ActionMenuElement_sync(opening = false) {
|
|
396
|
+
const src = (this.getAttribute('src') ?? '').trim();
|
|
397
|
+
if (!__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_deferred_get) || !src)
|
|
398
|
+
return;
|
|
399
|
+
if (!(opening || __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this) || __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_preload_get))) {
|
|
400
|
+
// A pending or failed loader for another src must not render meanwhile;
|
|
401
|
+
// a completed one is kept, so setting its src again does not reload
|
|
402
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_request, "f") && src !== __classPrivateFieldGet(this, _ActionMenuElement_request, "f").src && __classPrivateFieldGet(this, _ActionMenuElement_request, "f").loader.parentElement === __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_body_get)) {
|
|
403
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_invalidate).call(this);
|
|
404
|
+
}
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const loader = __classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader;
|
|
408
|
+
if (!__classPrivateFieldGet(this, _ActionMenuElement_request, "f") || src !== __classPrivateFieldGet(this, _ActionMenuElement_request, "f").src || !__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_body_get)?.firstElementChild) {
|
|
409
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_load).call(this, src, opening);
|
|
410
|
+
}
|
|
411
|
+
else if (loader?.isConnected) {
|
|
412
|
+
// A retry fetches the loader's own src, which a morph may have rewritten
|
|
413
|
+
if ((loader.getAttribute('src') ?? '').trim() === __classPrivateFieldGet(this, _ActionMenuElement_request, "f").src) {
|
|
414
|
+
loader.classList.remove('is-error');
|
|
415
|
+
loader.refetch();
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_load).call(this, src, opening);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
_ActionMenuElement_invalidate = function _ActionMenuElement_invalidate() {
|
|
423
|
+
__classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader.remove();
|
|
424
|
+
__classPrivateFieldSet(this, _ActionMenuElement_request, null, "f");
|
|
425
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateReady).call(this);
|
|
426
|
+
};
|
|
427
|
+
_ActionMenuElement_load = function _ActionMenuElement_load(src, opening = false) {
|
|
428
|
+
const body = __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_body_get);
|
|
429
|
+
const template = this.loaderTemplate?.content.firstElementChild;
|
|
430
|
+
if (!body || !template)
|
|
431
|
+
return;
|
|
432
|
+
// Imported, not cloned, so the loader is upgraded before it connects
|
|
433
|
+
const loader = this.ownerDocument.importNode(template, true);
|
|
434
|
+
loader.setAttribute('src', src);
|
|
435
|
+
loader.setAttribute('loading', 'eager');
|
|
436
|
+
__classPrivateFieldSet(this, _ActionMenuElement_request, { loader, src }, "f");
|
|
437
|
+
__classPrivateFieldGet(this, _ActionMenuElement_ownedLoaders, "f").add(loader);
|
|
438
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_listen).call(this, loader);
|
|
439
|
+
// The response decides the form field name
|
|
440
|
+
__classPrivateFieldSet(this, _ActionMenuElement_inputName, '', "f");
|
|
441
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_keepInputs).call(this, body);
|
|
442
|
+
body.prepend(loader);
|
|
443
|
+
if (opening || __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
|
444
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_keepOpenWhileLoading).call(this, loader);
|
|
445
|
+
// A focus handler may have started a newer load meanwhile
|
|
446
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader !== loader)
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
for (const child of Array.from(body.childNodes)) {
|
|
450
|
+
if (child !== loader)
|
|
451
|
+
child.remove();
|
|
452
|
+
}
|
|
453
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateReady).call(this);
|
|
454
|
+
};
|
|
455
|
+
_ActionMenuElement_keepInputs = function _ActionMenuElement_keepInputs(body) {
|
|
456
|
+
const inputs = body.querySelector('[data-list-inputs]');
|
|
457
|
+
if (!inputs)
|
|
458
|
+
return;
|
|
459
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_dropKeptInputs).call(this);
|
|
460
|
+
this.append(inputs);
|
|
461
|
+
};
|
|
462
|
+
_ActionMenuElement_dropKeptInputs = function _ActionMenuElement_dropKeptInputs() {
|
|
463
|
+
for (const inputs of this.querySelectorAll(':scope > [data-list-inputs]'))
|
|
464
|
+
inputs.remove();
|
|
465
|
+
};
|
|
466
|
+
_ActionMenuElement_listen = function _ActionMenuElement_listen(fragment) {
|
|
467
|
+
fragment.addEventListener('include-fragment-replace', this);
|
|
468
|
+
fragment.addEventListener('include-fragment-replaced', this);
|
|
469
|
+
};
|
|
470
|
+
_ActionMenuElement_noLoadPending = function _ActionMenuElement_noLoadPending() {
|
|
471
|
+
if (!__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_deferred_get) && this.includeFragment?.isConnected)
|
|
472
|
+
return false;
|
|
473
|
+
const loader = __classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader;
|
|
474
|
+
return !loader || loader.parentElement !== __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_body_get);
|
|
475
|
+
};
|
|
476
|
+
_ActionMenuElement_updateReady = function _ActionMenuElement_updateReady() {
|
|
477
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_noLoadPending).call(this)) {
|
|
478
|
+
this.setAttribute('data-ready', 'true');
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
this.removeAttribute('data-ready');
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
_ActionMenuElement_onBodyMutation = function _ActionMenuElement_onBodyMutation(records) {
|
|
485
|
+
// A replaced overlay may have taken open sub-menus with it
|
|
486
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_pruneFocusZones).call(this);
|
|
487
|
+
if (!__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_deferred_get))
|
|
488
|
+
return;
|
|
489
|
+
const body = __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_body_get);
|
|
490
|
+
if (!body)
|
|
491
|
+
return;
|
|
492
|
+
if (records.some(record => record.addedNodes.length > 0)) {
|
|
493
|
+
const fragments = Array.from(body.querySelectorAll(':scope > include-fragment')).filter(fragment => !__classPrivateFieldGet(this, _ActionMenuElement_ownedLoaders, "f").has(fragment));
|
|
494
|
+
const fragment = fragments.at(-1);
|
|
495
|
+
if (fragment)
|
|
496
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_adopt).call(this, fragment);
|
|
497
|
+
}
|
|
498
|
+
// An empty body was emptied or replaced by other code, unless it is the
|
|
499
|
+
// one the current loader left empty; loading again there would loop on a
|
|
500
|
+
// preloaded menu, so that one waits for the next open
|
|
501
|
+
const loader = __classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader;
|
|
502
|
+
if (!body.firstElementChild && !(loader && __classPrivateFieldGet(this, _ActionMenuElement_emptyLoaders, "f").get(loader) === body))
|
|
503
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_sync).call(this);
|
|
504
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateReady).call(this);
|
|
505
|
+
};
|
|
506
|
+
_ActionMenuElement_adopt = function _ActionMenuElement_adopt(fragment) {
|
|
507
|
+
const body = __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_body_get);
|
|
508
|
+
if (!body)
|
|
509
|
+
return;
|
|
510
|
+
const src = (fragment.getAttribute('src') ?? '').trim();
|
|
511
|
+
__classPrivateFieldSet(this, _ActionMenuElement_request, { loader: fragment, src }, "f");
|
|
512
|
+
__classPrivateFieldGet(this, _ActionMenuElement_ownedLoaders, "f").add(fragment);
|
|
513
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_listen).call(this, fragment);
|
|
514
|
+
// The response decides the form field name
|
|
515
|
+
__classPrivateFieldSet(this, _ActionMenuElement_inputName, '', "f");
|
|
516
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_keepInputs).call(this, body);
|
|
517
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
|
518
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_keepOpenWhileLoading).call(this, fragment);
|
|
519
|
+
// A focus handler may have started a newer load meanwhile
|
|
520
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_request, "f")?.loader !== fragment)
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
for (const child of Array.from(body.childNodes)) {
|
|
524
|
+
if (child !== fragment)
|
|
525
|
+
child.remove();
|
|
526
|
+
}
|
|
527
|
+
if (src && src !== this.getAttribute('src')) {
|
|
528
|
+
this.setAttribute('src', src);
|
|
529
|
+
}
|
|
530
|
+
else if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this) || __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_preload_get)) {
|
|
531
|
+
// An unchanged src does not run the rule, and a lazy loader inserted
|
|
532
|
+
// before its attributes never starts on its own
|
|
533
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_sync).call(this);
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
_ActionMenuElement_keepOpenWhileLoading = function _ActionMenuElement_keepOpenWhileLoading(fragment) {
|
|
537
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_pruneFocusZones).call(this);
|
|
538
|
+
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").popAbove(this.overlay);
|
|
539
|
+
for (const child of this.childPopoverElements) {
|
|
540
|
+
if (child.matches(':popover-open'))
|
|
541
|
+
child.hidePopover();
|
|
542
|
+
}
|
|
543
|
+
fragment.querySelector('[role=menuitem]')?.focus();
|
|
544
|
+
};
|
|
545
|
+
_ActionMenuElement_pruneFocusZones = function _ActionMenuElement_pruneFocusZones() {
|
|
546
|
+
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").prune(element => element.isConnected && this.contains(element));
|
|
547
|
+
};
|
|
312
548
|
_ActionMenuElement_softDisableItems = function _ActionMenuElement_softDisableItems() {
|
|
313
549
|
const { signal } = __classPrivateFieldGet(this, _ActionMenuElement_abortController, "f");
|
|
314
550
|
for (const item of this.querySelectorAll(ActionMenuElement_1.validSelectors.join(','))) {
|
|
@@ -371,6 +607,12 @@ _ActionMenuElement_handleItemKeyboardEvent = function _ActionMenuElement_handleI
|
|
|
371
607
|
}
|
|
372
608
|
};
|
|
373
609
|
_ActionMenuElement_handleBeforeToggleEvent = function _ActionMenuElement_handleBeforeToggleEvent(event) {
|
|
610
|
+
if (event.newState === 'open') {
|
|
611
|
+
// A closed lazy menu catches up, and a failed load retries, as it opens
|
|
612
|
+
if (event.target === this.overlay)
|
|
613
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_sync).call(this, true);
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
374
616
|
if (event.newState !== 'closed')
|
|
375
617
|
return;
|
|
376
618
|
const menu = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_toggledMenu).call(this, event);
|
|
@@ -397,11 +639,19 @@ _ActionMenuElement_handleToggleEvent = function _ActionMenuElement_handleToggleE
|
|
|
397
639
|
// allow tabbing away from primary menu, but trap focus in sub-menus
|
|
398
640
|
const isPrimaryMenu = menu === this.overlay;
|
|
399
641
|
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").push(menu, { trapFocus: !isPrimaryMenu });
|
|
642
|
+
// Picks up a src set by a beforetoggle listener that ran after ours
|
|
643
|
+
if (isPrimaryMenu)
|
|
644
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_sync).call(this, true);
|
|
400
645
|
window.requestAnimationFrame(() => {
|
|
401
646
|
const firstItem = menu.querySelector(ActionMenuElement_1.menuItemSelectors.join(','));
|
|
402
647
|
firstItem?.focus();
|
|
403
648
|
});
|
|
404
649
|
}
|
|
650
|
+
else if (menu === this.overlay && !document.querySelector(':popover-open')) {
|
|
651
|
+
// A light-dismissed menu (e.g. a click outside it) leaves focus on the body;
|
|
652
|
+
// hand it back to the invoker so the menu stays reachable from the keyboard.
|
|
653
|
+
this.invokerElement?.focus();
|
|
654
|
+
}
|
|
405
655
|
};
|
|
406
656
|
_ActionMenuElement_toggledMenu = function _ActionMenuElement_toggledMenu(event) {
|
|
407
657
|
return event.target instanceof AnchoredPositionElement ? event.target : null;
|
|
@@ -495,11 +745,32 @@ _ActionMenuElement_handleItemActivated = function _ActionMenuElement_handleItemA
|
|
|
495
745
|
}));
|
|
496
746
|
};
|
|
497
747
|
_ActionMenuElement_handleIncludeFragmentReplaced = function _ActionMenuElement_handleIncludeFragmentReplaced() {
|
|
498
|
-
|
|
748
|
+
// Content can finish loading while the menu is detached
|
|
749
|
+
if (this.isConnected) {
|
|
750
|
+
const firstItem = __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get);
|
|
751
|
+
if (firstItem) {
|
|
752
|
+
firstItem.focus();
|
|
753
|
+
}
|
|
754
|
+
else if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
|
755
|
+
// Nothing to focus in an empty response: close and return to the
|
|
756
|
+
// button.
|
|
757
|
+
this.overlay.hidePopover();
|
|
758
|
+
this.invokerElement?.focus();
|
|
759
|
+
}
|
|
760
|
+
this.overlay?.update();
|
|
761
|
+
}
|
|
762
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_deferred_get))
|
|
763
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_dropKeptInputs).call(this);
|
|
764
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setDynamicLabel).call(this);
|
|
765
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateInput).call(this);
|
|
499
766
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_softDisableItems).call(this);
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
767
|
+
// Ready unless the focus moves above started another load
|
|
768
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_deferred_get)) {
|
|
769
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateReady).call(this);
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
this.setAttribute('data-ready', 'true');
|
|
773
|
+
}
|
|
503
774
|
};
|
|
504
775
|
_ActionMenuElement_handleFocusOut = function _ActionMenuElement_handleFocusOut() {
|
|
505
776
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_hide).call(this);
|
|
@@ -514,7 +785,7 @@ _ActionMenuElement_hide = function _ActionMenuElement_hide() {
|
|
|
514
785
|
}
|
|
515
786
|
};
|
|
516
787
|
_ActionMenuElement_isOpen = function _ActionMenuElement_isOpen() {
|
|
517
|
-
return this.
|
|
788
|
+
return this.overlay?.matches(':popover-open') ?? false;
|
|
518
789
|
};
|
|
519
790
|
_ActionMenuElement_setDynamicLabel = function _ActionMenuElement_setDynamicLabel() {
|
|
520
791
|
if (!this.dynamicLabel)
|
|
@@ -522,7 +793,12 @@ _ActionMenuElement_setDynamicLabel = function _ActionMenuElement_setDynamicLabel
|
|
|
522
793
|
const invokerLabel = this.invokerLabel;
|
|
523
794
|
if (!invokerLabel)
|
|
524
795
|
return;
|
|
525
|
-
|
|
796
|
+
// Kept on the host, since the button of a cloned or restored menu
|
|
797
|
+
// already shows a selection
|
|
798
|
+
if (!__classPrivateFieldGet(this, _ActionMenuElement_originalLabel, "f")) {
|
|
799
|
+
__classPrivateFieldSet(this, _ActionMenuElement_originalLabel, this.getAttribute('data-original-label') ?? (invokerLabel.textContent || ''), "f");
|
|
800
|
+
this.setAttribute('data-original-label', __classPrivateFieldGet(this, _ActionMenuElement_originalLabel, "f"));
|
|
801
|
+
}
|
|
526
802
|
let itemLabel;
|
|
527
803
|
if (this.selectVariant === 'single') {
|
|
528
804
|
itemLabel = this.querySelector('[aria-checked=true] .ActionListItem-label')?.textContent?.trim();
|
|
@@ -569,6 +845,11 @@ _ActionMenuElement_updateInput = function _ActionMenuElement_updateInput() {
|
|
|
569
845
|
if (inputs.length > 0) {
|
|
570
846
|
__classPrivateFieldSet(this, _ActionMenuElement_inputName, __classPrivateFieldGet(this, _ActionMenuElement_inputName, "f") || inputs[0].name, "f");
|
|
571
847
|
}
|
|
848
|
+
// Kept on the container too, so a cloned or restored menu with nothing
|
|
849
|
+
// selected still names the inputs it creates
|
|
850
|
+
__classPrivateFieldSet(this, _ActionMenuElement_inputName, __classPrivateFieldGet(this, _ActionMenuElement_inputName, "f") || (inputList.getAttribute('data-input-name') ?? ''), "f");
|
|
851
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_inputName, "f"))
|
|
852
|
+
inputList.setAttribute('data-input-name', __classPrivateFieldGet(this, _ActionMenuElement_inputName, "f"));
|
|
572
853
|
for (const selectedItem of this.selectedItems) {
|
|
573
854
|
const newInput = document.createElement('input');
|
|
574
855
|
newInput.setAttribute('data-list-input', 'true');
|
|
@@ -600,6 +881,7 @@ _ActionMenuElement_itemForSubMenu = function _ActionMenuElement_itemForSubMenu(s
|
|
|
600
881
|
}
|
|
601
882
|
return null;
|
|
602
883
|
};
|
|
884
|
+
ActionMenuElement.observedAttributes = ['src'];
|
|
603
885
|
ActionMenuElement.validItemRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];
|
|
604
886
|
ActionMenuElement.validSelectors = ActionMenuElement_1.validItemRoles.map(role => `[role="${role}"]`);
|
|
605
887
|
ActionMenuElement.menuItemSelectors = ActionMenuElement_1.validSelectors.map(selector => `:not([hidden]) > ${selector}`);
|
|
@@ -612,6 +894,12 @@ __decorate([
|
|
|
612
894
|
__decorate([
|
|
613
895
|
target
|
|
614
896
|
], ActionMenuElement.prototype, "list", void 0);
|
|
897
|
+
__decorate([
|
|
898
|
+
target
|
|
899
|
+
], ActionMenuElement.prototype, "overlayBody", void 0);
|
|
900
|
+
__decorate([
|
|
901
|
+
target
|
|
902
|
+
], ActionMenuElement.prototype, "loaderTemplate", void 0);
|
|
615
903
|
ActionMenuElement = ActionMenuElement_1 = __decorate([
|
|
616
904
|
controller('action-menu')
|
|
617
905
|
], ActionMenuElement);
|
|
@@ -11,6 +11,9 @@ export declare class ActionMenuFocusZoneStack {
|
|
|
11
11
|
trapFocus: boolean;
|
|
12
12
|
}): void;
|
|
13
13
|
pop(target?: AnchoredPositionElement): void;
|
|
14
|
+
popAbove(element: AnchoredPositionElement): void;
|
|
15
|
+
prune(isLive: (element: AnchoredPositionElement) => boolean): void;
|
|
16
|
+
clear(): void;
|
|
14
17
|
elementIsMenuItem(element: HTMLElement): boolean;
|
|
15
18
|
get isEmpty(): boolean;
|
|
16
19
|
}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
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
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _ActionMenuFocusZoneStack_instances, _ActionMenuFocusZoneStack_stack, _ActionMenuFocusZoneStack_setupFocusZone, _ActionMenuFocusZoneStack_validItemRoles_get;
|
|
12
|
+
var _ActionMenuFocusZoneStack_instances, _ActionMenuFocusZoneStack_stack, _ActionMenuFocusZoneStack_popTop, _ActionMenuFocusZoneStack_includes, _ActionMenuFocusZoneStack_setupFocusZone, _ActionMenuFocusZoneStack_validItemRoles_get;
|
|
13
13
|
import { FocusKeys, focusTrap, focusZone } from '@primer/behaviors';
|
|
14
14
|
import { ActionMenuElement } from './action_menu_element';
|
|
15
15
|
export class ActionMenuFocusZoneStack {
|
|
@@ -25,15 +25,36 @@ export class ActionMenuFocusZoneStack {
|
|
|
25
25
|
const { trapFocus } = options;
|
|
26
26
|
__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").push({ element: next, abortController: __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "m", _ActionMenuFocusZoneStack_setupFocusZone).call(this, next, trapFocus) });
|
|
27
27
|
}
|
|
28
|
+
// Pops and aborts the top entry, or the given element and every entry above it.
|
|
28
29
|
pop(target) {
|
|
29
30
|
if (target) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
if (!__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "m", _ActionMenuFocusZoneStack_includes).call(this, target))
|
|
32
|
+
return;
|
|
33
|
+
this.popAbove(target);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "m", _ActionMenuFocusZoneStack_popTop).call(this);
|
|
36
|
+
}
|
|
37
|
+
// Pops and aborts every entry above (not including) the given element.
|
|
38
|
+
popAbove(element) {
|
|
39
|
+
if (!__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "m", _ActionMenuFocusZoneStack_includes).call(this, element))
|
|
40
|
+
return;
|
|
41
|
+
while (this.current && this.current.element !== element)
|
|
42
|
+
__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "m", _ActionMenuFocusZoneStack_popTop).call(this);
|
|
43
|
+
}
|
|
44
|
+
// Drops and aborts every entry whose element is no longer live, for example
|
|
45
|
+
// an overlay that other code removed while it was open. Its toggle event
|
|
46
|
+
// never reaches the menu, so nothing else pops it.
|
|
47
|
+
prune(isLive) {
|
|
48
|
+
__classPrivateFieldSet(this, _ActionMenuFocusZoneStack_stack, __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").filter(entry => {
|
|
49
|
+
if (isLive(entry.element))
|
|
50
|
+
return true;
|
|
51
|
+
entry.abortController.abort();
|
|
52
|
+
return false;
|
|
53
|
+
}), "f");
|
|
54
|
+
}
|
|
55
|
+
clear() {
|
|
56
|
+
while (this.current)
|
|
57
|
+
__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "m", _ActionMenuFocusZoneStack_popTop).call(this);
|
|
37
58
|
}
|
|
38
59
|
elementIsMenuItem(element) {
|
|
39
60
|
return __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_instances, "a", _ActionMenuFocusZoneStack_validItemRoles_get).includes(element.getAttribute('role') || '');
|
|
@@ -42,7 +63,11 @@ export class ActionMenuFocusZoneStack {
|
|
|
42
63
|
return __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").length === 0;
|
|
43
64
|
}
|
|
44
65
|
}
|
|
45
|
-
_ActionMenuFocusZoneStack_stack = new WeakMap(), _ActionMenuFocusZoneStack_instances = new WeakSet(),
|
|
66
|
+
_ActionMenuFocusZoneStack_stack = new WeakMap(), _ActionMenuFocusZoneStack_instances = new WeakSet(), _ActionMenuFocusZoneStack_popTop = function _ActionMenuFocusZoneStack_popTop() {
|
|
67
|
+
__classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").pop()?.abortController.abort();
|
|
68
|
+
}, _ActionMenuFocusZoneStack_includes = function _ActionMenuFocusZoneStack_includes(element) {
|
|
69
|
+
return __classPrivateFieldGet(this, _ActionMenuFocusZoneStack_stack, "f").some(entry => entry.element === element);
|
|
70
|
+
}, _ActionMenuFocusZoneStack_setupFocusZone = function _ActionMenuFocusZoneStack_setupFocusZone(containerEl, trapFocus) {
|
|
46
71
|
const focusZoneAbortController = focusZone(containerEl, {
|
|
47
72
|
bindKeys: FocusKeys.ArrowVertical | FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd | FocusKeys.Backspace,
|
|
48
73
|
focusOutBehavior: 'wrap',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.autocomplete-label-stacked{display:block;margin-bottom:var(--base-size-6)}.autocomplete-label-inline{display:inline;margin-right:var(--base-size-6)}@media
|
|
1
|
+
.autocomplete-label-stacked{display:block;margin-bottom:var(--base-size-6)}.autocomplete-label-inline{display:inline;margin-right:var(--base-size-6)}@media(max-width:543.98px){.autocomplete-label-inline{display:block;margin-bottom:var(--base-size-6)}}.autocomplete-body{position:relative;display:inline}.autocomplete-embedded-icon-wrap{display:inline-flex;padding:var(--base-size-4) var(--base-size-8);align-items:center}.autocomplete-embedded-icon-wrap:focus-within{border-color:var(--borderColor-accent-emphasis);border-color:var(--focus-outlineColor);outline:none;box-shadow:inset 0 0 0 1px var(--focus-outlineColor)}.autocomplete-embedded-icon-wrap .form-control{padding:0;margin-left:var(--base-size-8);border:none;box-shadow:none}:is(.autocomplete-embedded-icon-wrap .form-control):focus,:is(.autocomplete-embedded-icon-wrap .form-control):focus-visible{box-shadow:none}.autocomplete-results{position:absolute;left:0;z-index:99;width:max-content;min-width:100%;max-height:20em;overflow-y:auto;font-size:var(--text-codeBlock-size);list-style:none;background:var(--overlay-bgColor);border:var(--borderWidth-thin) solid var(--borderColor-default);border-radius:var(--borderRadius-medium);box-shadow:var(--shadow-resting-medium)}.autocomplete-item{display:block;width:100%;padding:var(--base-size-4) var(--base-size-8);overflow:hidden;font-weight:var(--base-text-weight-semibold);color:var(--fgColor-default);text-align:left;-webkit-text-decoration:none;text-decoration:none;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;background-color:var(--overlay-bgColor);border:0}.autocomplete-item.navigation-focus,.autocomplete-item.selected,.autocomplete-item:hover,.autocomplete-item[aria-selected=true]{color:var(--fgColor-onEmphasis);-webkit-text-decoration:none;text-decoration:none;background-color:var(--bgColor-accent-emphasis)}
|