openproject-primer_view_components 0.94.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/app/assets/javascripts/primer_view_components.js +11 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_bar.css +1 -1
- data/app/components/primer/alpha/action_bar.css.map +1 -1
- data/app/components/primer/alpha/action_list/item.rb +5 -1
- data/app/components/primer/alpha/action_list.css +1 -1
- data/app/components/primer/alpha/action_list.css.json +13 -11
- data/app/components/primer/alpha/action_list.css.map +1 -1
- data/app/components/primer/alpha/action_list.pcss +12 -0
- data/app/components/primer/alpha/action_menu/action_menu_element.d.ts +6 -0
- data/app/components/primer/alpha/action_menu/action_menu_element.js +389 -84
- data/app/components/primer/alpha/action_menu/action_menu_element.ts +439 -78
- data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.d.ts +4 -1
- data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.js +37 -13
- data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.ts +41 -12
- data/app/components/primer/alpha/action_menu/menu.html.erb +27 -19
- data/app/components/primer/alpha/action_menu/menu.rb +7 -0
- data/app/components/primer/alpha/action_menu/primary_menu.rb +15 -0
- data/app/components/primer/alpha/action_menu.rb +55 -0
- data/app/components/primer/alpha/auto_complete.css +1 -1
- data/app/components/primer/alpha/auto_complete.css.map +1 -1
- data/app/components/primer/alpha/banner.css +1 -1
- data/app/components/primer/alpha/banner.css.map +1 -1
- data/app/components/primer/alpha/button_marketing.css +1 -1
- data/app/components/primer/alpha/button_marketing.css.map +1 -1
- data/app/components/primer/alpha/dialog.css +1 -1
- data/app/components/primer/alpha/dialog.css.map +1 -1
- data/app/components/primer/alpha/dropdown/menu.rb +1 -1
- data/app/components/primer/alpha/dropdown.css +1 -1
- data/app/components/primer/alpha/dropdown.css.json +1 -1
- data/app/components/primer/alpha/dropdown.css.map +1 -1
- data/app/components/primer/alpha/layout.css +1 -1
- data/app/components/primer/alpha/layout.css.json +3 -3
- data/app/components/primer/alpha/layout.css.map +1 -1
- data/app/components/primer/alpha/menu.css +1 -1
- data/app/components/primer/alpha/menu.css.json +3 -3
- data/app/components/primer/alpha/menu.css.map +1 -1
- data/app/components/primer/alpha/overlay.css +1 -1
- data/app/components/primer/alpha/overlay.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.json +1 -1
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/select_panel.css +1 -1
- data/app/components/primer/alpha/select_panel.css.map +1 -1
- data/app/components/primer/alpha/skeleton_box.css +1 -1
- data/app/components/primer/alpha/skeleton_box.css.map +1 -1
- data/app/components/primer/alpha/stack.css +1 -1
- data/app/components/primer/alpha/stack.css.map +1 -1
- data/app/components/primer/alpha/stack_item.css +1 -1
- data/app/components/primer/alpha/stack_item.css.map +1 -1
- data/app/components/primer/alpha/tab_nav.css +1 -1
- data/app/components/primer/alpha/tab_nav.css.map +1 -1
- data/app/components/primer/alpha/text_field.css +1 -1
- data/app/components/primer/alpha/text_field.css.map +1 -1
- data/app/components/primer/alpha/toggle_switch.css +1 -1
- data/app/components/primer/alpha/toggle_switch.css.map +1 -1
- data/app/components/primer/alpha/tree_view.css +1 -1
- data/app/components/primer/alpha/tree_view.css.json +3 -3
- data/app/components/primer/alpha/tree_view.css.map +1 -1
- data/app/components/primer/alpha/underline_nav.css +1 -1
- data/app/components/primer/alpha/underline_nav.css.map +1 -1
- data/app/components/primer/beta/border_box.css +1 -1
- data/app/components/primer/beta/border_box.css.json +5 -5
- data/app/components/primer/beta/border_box.css.map +1 -1
- data/app/components/primer/beta/button.css +1 -1
- data/app/components/primer/beta/button.css.map +1 -1
- data/app/components/primer/beta/button.pcss +97 -0
- data/app/components/primer/beta/button.rb +15 -3
- data/app/components/primer/beta/counter.css +1 -1
- data/app/components/primer/beta/counter.css.map +1 -1
- data/app/components/primer/beta/flash.css +1 -1
- data/app/components/primer/beta/flash.css.map +1 -1
- data/app/components/primer/beta/link.css +1 -1
- data/app/components/primer/beta/link.css.json +1 -1
- data/app/components/primer/beta/link.css.map +1 -1
- data/app/components/primer/beta/popover.css +1 -1
- data/app/components/primer/beta/popover.css.map +1 -1
- data/app/components/primer/beta/progress_bar.css +1 -1
- data/app/components/primer/beta/progress_bar.css.map +1 -1
- data/app/components/primer/beta/relative_time.rb +7 -1
- data/app/components/primer/beta/state.css +1 -1
- data/app/components/primer/beta/state.css.json +2 -2
- data/app/components/primer/beta/state.css.map +1 -1
- data/app/components/primer/beta/timeline_item.css +1 -1
- data/app/components/primer/beta/timeline_item.css.map +1 -1
- data/app/components/primer/open_project/border_grid.css +1 -1
- data/app/components/primer/open_project/border_grid.css.map +1 -1
- data/app/components/primer/open_project/color_field.css +1 -1
- data/app/components/primer/open_project/color_field.css.map +1 -1
- data/app/components/primer/open_project/color_swatch.css +1 -0
- data/app/components/primer/open_project/color_swatch.css.json +6 -0
- data/app/components/primer/open_project/color_swatch.css.map +1 -0
- data/app/components/primer/open_project/color_swatch.pcss +8 -0
- data/app/components/primer/open_project/color_swatch.rb +57 -0
- data/app/components/primer/open_project/inline_message.css +1 -1
- data/app/components/primer/open_project/inline_message.css.map +1 -1
- data/app/components/primer/open_project/input_group.css +1 -1
- data/app/components/primer/open_project/input_group.css.map +1 -1
- data/app/components/primer/open_project/inset_box.css +1 -0
- data/app/components/primer/open_project/inset_box.css.json +9 -0
- data/app/components/primer/open_project/inset_box.css.map +1 -0
- data/app/components/primer/open_project/inset_box.html.erb +46 -0
- data/app/components/primer/open_project/inset_box.pcss +24 -0
- data/app/components/primer/open_project/inset_box.rb +63 -0
- data/app/components/primer/open_project/keybinding_hint/chords.d.ts +5 -0
- data/app/components/primer/open_project/keybinding_hint/chords.js +29 -0
- data/app/components/primer/open_project/keybinding_hint/chords.ts +38 -0
- data/app/components/primer/open_project/keybinding_hint/key_names.d.ts +16 -0
- data/app/components/primer/open_project/keybinding_hint/key_names.js +107 -0
- data/app/components/primer/open_project/keybinding_hint/key_names.ts +116 -0
- data/app/components/primer/open_project/keybinding_hint/localized_names.d.ts +22 -0
- data/app/components/primer/open_project/keybinding_hint/localized_names.js +47 -0
- data/app/components/primer/open_project/keybinding_hint/localized_names.ts +71 -0
- data/app/components/primer/open_project/keybinding_hint/names.rb +92 -0
- data/app/components/primer/open_project/keybinding_hint/names_from_scope.d.ts +21 -0
- data/app/components/primer/open_project/keybinding_hint/names_from_scope.js +81 -0
- data/app/components/primer/open_project/keybinding_hint/names_from_scope.ts +96 -0
- data/app/components/primer/open_project/keybinding_hint/platform.d.ts +10 -0
- data/app/components/primer/open_project/keybinding_hint/platform.js +24 -0
- data/app/components/primer/open_project/keybinding_hint/platform.ts +34 -0
- data/app/components/primer/open_project/keybinding_hint/platform_override.d.ts +2 -0
- data/app/components/primer/open_project/keybinding_hint/platform_override.js +4 -0
- data/app/components/primer/open_project/keybinding_hint/platform_override.ts +7 -0
- data/app/components/primer/open_project/keybinding_hint.css +1 -0
- data/app/components/primer/open_project/keybinding_hint.css.json +10 -0
- data/app/components/primer/open_project/keybinding_hint.css.map +1 -0
- data/app/components/primer/open_project/keybinding_hint.html.erb +4 -0
- data/app/components/primer/open_project/keybinding_hint.pcss +65 -0
- data/app/components/primer/open_project/keybinding_hint.rb +112 -0
- data/app/components/primer/open_project/keybinding_hint_element.d.ts +31 -0
- data/app/components/primer/open_project/keybinding_hint_element.js +183 -0
- data/app/components/primer/open_project/keybinding_hint_element.ts +152 -0
- data/app/components/primer/open_project/page_header.css +1 -1
- data/app/components/primer/open_project/page_header.css.json +2 -2
- data/app/components/primer/open_project/page_header.css.map +1 -1
- data/app/components/primer/open_project/pagination.css +1 -1
- data/app/components/primer/open_project/pagination.css.json +1 -1
- data/app/components/primer/open_project/pagination.css.map +1 -1
- data/app/components/primer/open_project/sub_header.css +1 -1
- data/app/components/primer/open_project/sub_header.css.map +1 -1
- data/app/components/primer/primer.d.ts +1 -0
- data/app/components/primer/primer.js +1 -0
- data/app/components/primer/primer.pcss +3 -0
- data/app/components/primer/primer.ts +1 -0
- data/app/components/primer/truncate.css +1 -1
- data/app/components/primer/truncate.css.json +3 -4
- data/app/components/primer/truncate.css.map +1 -1
- data/app/controllers/primer/view_components/action_menu_controller.rb +35 -0
- data/app/views/primer/view_components/action_menu/deferred.html.erb +25 -11
- data/app/views/primer/view_components/action_menu/deferred_form.html.erb +10 -0
- data/app/views/primer/view_components/action_menu/deferred_preload.html.erb +7 -1
- data/config/locales/en.yml +179 -0
- data/config/routes.rb +1 -0
- data/lib/primer/accessibility.rb +1 -2
- data/lib/primer/classify.rb +1 -2
- data/lib/primer/view_components/version.rb +1 -1
- data/previews/primer/alpha/action_menu_preview/deferred_refresh.html.erb +34 -0
- data/previews/primer/alpha/action_menu_preview/deferred_refresh_form.html.erb +9 -0
- data/previews/primer/alpha/action_menu_preview.rb +14 -0
- data/previews/primer/open_project/color_swatch_preview.rb +27 -0
- data/previews/primer/open_project/inset_box_preview.rb +85 -0
- data/previews/primer/open_project/keybinding_hint_preview/full_format.html.erb +3 -0
- data/previews/primer/open_project/keybinding_hint_preview/in_action_list.html.erb +12 -0
- data/previews/primer/open_project/keybinding_hint_preview/in_button.html.erb +24 -0
- data/previews/primer/open_project/keybinding_hint_preview/platforms.html.erb +8 -0
- data/previews/primer/open_project/keybinding_hint_preview/playground.html.erb +4 -0
- data/previews/primer/open_project/keybinding_hint_preview/prose.html.erb +3 -0
- data/previews/primer/open_project/keybinding_hint_preview/schemes.html.erb +6 -0
- data/previews/primer/open_project/keybinding_hint_preview/sequence.html.erb +1 -0
- data/previews/primer/open_project/keybinding_hint_preview/sizes.html.erb +4 -0
- data/previews/primer/open_project/keybinding_hint_preview.rb +71 -0
- data/static/arguments.json +109 -1
- data/static/audited_at.json +3 -0
- data/static/classes.json +27 -0
- data/static/classnames.cjs +9 -0
- data/static/classnames.js +9 -0
- data/static/constants.json +63 -0
- data/static/info_arch.json +523 -8
- data/static/previews.json +310 -0
- data/static/statuses.json +3 -0
- metadata +55 -5
- data/app/components/primer/alpha/text_field.css.json +0 -134
- data/app/components/primer/alpha/toggle_switch.css.json +0 -40
- data/app/components/primer/alpha/underline_nav.css.json +0 -26
- data/app/components/primer/beta/button.css.json +0 -86
|
@@ -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_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;
|
|
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,61 +147,41 @@ 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('toggle', this, { signal, capture: true });
|
|
150
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_bindHostListeners).call(this);
|
|
107
151
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setDynamicLabel).call(this);
|
|
108
152
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateInput).call(this);
|
|
109
153
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_softDisableItems).call(this);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
// The code below updates the menu (i.e. overlay) position whenever the invoker button
|
|
116
|
-
// changes position within its scroll container.
|
|
117
|
-
//
|
|
118
|
-
// See: https://github.com/primer/view_components/issues/3175
|
|
119
|
-
const scrollUpdater = () => {
|
|
120
|
-
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isOpen).call(this)) {
|
|
121
|
-
this.overlay?.update();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
__classPrivateFieldSet(this, _ActionMenuElement_intersectionObserver, new IntersectionObserver(entries => {
|
|
125
|
-
for (const entry of entries) {
|
|
126
|
-
const elem = entry.target;
|
|
127
|
-
if (elem === this.invokerElement) {
|
|
128
|
-
if (entry.isIntersecting) {
|
|
129
|
-
// eslint-disable-next-line github/prefer-observers
|
|
130
|
-
window.addEventListener('scroll', scrollUpdater, { capture: true });
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
window.removeEventListener('scroll', scrollUpdater, { capture: true });
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}), "f");
|
|
138
|
-
observeMutationsUntilConditionMet(this, () => Boolean(this.invokerElement), () => __classPrivateFieldGet(this, _ActionMenuElement_intersectionObserver, "f").observe(this.invokerElement));
|
|
139
|
-
// If there's no include fragment, then no async fetching will occur and we can
|
|
140
|
-
// mark the component as ready.
|
|
141
|
-
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)) {
|
|
142
158
|
this.setAttribute('data-ready', 'true');
|
|
143
159
|
}
|
|
144
|
-
const levelObserver = new MutationObserver(() => __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateLevels).call(this));
|
|
145
|
-
levelObserver.observe(this, { childList: true, subtree: true });
|
|
146
160
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateLevels).call(this);
|
|
147
|
-
__classPrivateFieldSet(this, _ActionMenuElement_focusZoneStack, new ActionMenuFocusZoneStack(), "f");
|
|
148
161
|
}
|
|
149
162
|
disconnectedCallback() {
|
|
150
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);
|
|
151
177
|
}
|
|
152
178
|
handleEvent(event) {
|
|
153
179
|
const targetIsInvoker = this.invokerElement?.contains(event.target);
|
|
154
180
|
const eventIsActivation = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivation).call(this, event);
|
|
181
|
+
if (event.type === 'beforetoggle' && event instanceof ToggleEvent) {
|
|
182
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleBeforeToggleEvent).call(this, event);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
155
185
|
if (event.type === 'toggle' && event instanceof ToggleEvent) {
|
|
156
186
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleToggleEvent).call(this, event);
|
|
157
187
|
return;
|
|
@@ -211,7 +241,34 @@ let ActionMenuElement = ActionMenuElement_1 = _a = class ActionMenuElement exten
|
|
|
211
241
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleItemActivated).call(this, item);
|
|
212
242
|
return;
|
|
213
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
|
+
}
|
|
214
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;
|
|
215
272
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleIncludeFragmentReplaced).call(this);
|
|
216
273
|
return;
|
|
217
274
|
}
|
|
@@ -296,14 +353,198 @@ _ActionMenuElement_inputName = new WeakMap();
|
|
|
296
353
|
_ActionMenuElement_invokerBeingClicked = new WeakMap();
|
|
297
354
|
_ActionMenuElement_intersectionObserver = new WeakMap();
|
|
298
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();
|
|
299
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
|
+
};
|
|
300
381
|
_ActionMenuElement_updateLevels = function _ActionMenuElement_updateLevels() {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
menu.setAttribute('data-level', idx.toString());
|
|
304
|
-
idx++;
|
|
382
|
+
for (const [index, menu] of this.querySelectorAll('[role=menu]').entries()) {
|
|
383
|
+
menu.setAttribute('data-level', String(index + 1));
|
|
305
384
|
}
|
|
306
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
|
+
};
|
|
307
548
|
_ActionMenuElement_softDisableItems = function _ActionMenuElement_softDisableItems() {
|
|
308
549
|
const { signal } = __classPrivateFieldGet(this, _ActionMenuElement_abortController, "f");
|
|
309
550
|
for (const item of this.querySelectorAll(ActionMenuElement_1.validSelectors.join(','))) {
|
|
@@ -356,39 +597,65 @@ _ActionMenuElement_handleItemKeyboardEvent = function _ActionMenuElement_handleI
|
|
|
356
597
|
subMenu?.showPopover();
|
|
357
598
|
break;
|
|
358
599
|
}
|
|
359
|
-
case 'ArrowLeft':
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
overlay
|
|
600
|
+
case 'ArrowLeft': {
|
|
601
|
+
const overlay = item.closest('anchored-position');
|
|
602
|
+
if (overlay && overlay !== this.overlay) {
|
|
603
|
+
overlay.hidePopover();
|
|
363
604
|
}
|
|
364
605
|
break;
|
|
606
|
+
}
|
|
365
607
|
}
|
|
366
608
|
};
|
|
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
|
+
}
|
|
616
|
+
if (event.newState !== 'closed')
|
|
617
|
+
return;
|
|
618
|
+
const menu = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_toggledMenu).call(this, event);
|
|
619
|
+
if (!menu)
|
|
620
|
+
return;
|
|
621
|
+
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").pop(menu);
|
|
622
|
+
// The primary menu's popover hands focus back to the invoker itself
|
|
623
|
+
if (menu === this.overlay)
|
|
624
|
+
return;
|
|
625
|
+
// A nested popover does not hand focus back when it closes, so a sub-menu closed
|
|
626
|
+
// with ArrowLeft or Escape would leave focus on the body and the focusout handler
|
|
627
|
+
// would then close the whole menu. Move focus to the sub-menu's item before the
|
|
628
|
+
// sub-menu hides, while focus is still inside it. Doing this synchronously, rather
|
|
629
|
+
// than in the async toggle event, keeps focus from ever reaching the body.
|
|
630
|
+
if (!menu.contains(document.activeElement))
|
|
631
|
+
return;
|
|
632
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_itemForSubMenu).call(this, menu)?.focus();
|
|
633
|
+
};
|
|
367
634
|
_ActionMenuElement_handleToggleEvent = function _ActionMenuElement_handleToggleEvent(event) {
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
if (!(event.target instanceof AnchoredPositionElement))
|
|
635
|
+
const menu = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_toggledMenu).call(this, event);
|
|
636
|
+
if (!menu)
|
|
371
637
|
return;
|
|
372
638
|
if (event.newState === 'open') {
|
|
373
639
|
// allow tabbing away from primary menu, but trap focus in sub-menus
|
|
374
|
-
const isPrimaryMenu =
|
|
375
|
-
__classPrivateFieldGet(this, _ActionMenuElement_focusZoneStack, "f").push(
|
|
640
|
+
const isPrimaryMenu = menu === this.overlay;
|
|
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);
|
|
376
645
|
window.requestAnimationFrame(() => {
|
|
377
|
-
const firstItem =
|
|
646
|
+
const firstItem = menu.querySelector(ActionMenuElement_1.menuItemSelectors.join(','));
|
|
378
647
|
firstItem?.focus();
|
|
379
648
|
});
|
|
380
649
|
}
|
|
381
|
-
else {
|
|
382
|
-
//
|
|
383
|
-
//
|
|
384
|
-
|
|
385
|
-
const item = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_itemForSubMenu).call(this, subMenu);
|
|
386
|
-
const openPopover = document.querySelector(':popover-open');
|
|
387
|
-
if (item && !openPopover) {
|
|
388
|
-
item.focus();
|
|
389
|
-
}
|
|
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();
|
|
390
654
|
}
|
|
391
655
|
};
|
|
656
|
+
_ActionMenuElement_toggledMenu = function _ActionMenuElement_toggledMenu(event) {
|
|
657
|
+
return event.target instanceof AnchoredPositionElement ? event.target : null;
|
|
658
|
+
};
|
|
392
659
|
_ActionMenuElement_handleInvokerActivated = function _ActionMenuElement_handleInvokerActivated(event) {
|
|
393
660
|
event.preventDefault();
|
|
394
661
|
/* eslint-disable-next-line no-restricted-syntax */
|
|
@@ -478,11 +745,32 @@ _ActionMenuElement_handleItemActivated = function _ActionMenuElement_handleItemA
|
|
|
478
745
|
}));
|
|
479
746
|
};
|
|
480
747
|
_ActionMenuElement_handleIncludeFragmentReplaced = function _ActionMenuElement_handleIncludeFragmentReplaced() {
|
|
481
|
-
|
|
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);
|
|
482
766
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_softDisableItems).call(this);
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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
|
+
}
|
|
486
774
|
};
|
|
487
775
|
_ActionMenuElement_handleFocusOut = function _ActionMenuElement_handleFocusOut() {
|
|
488
776
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_hide).call(this);
|
|
@@ -497,7 +785,7 @@ _ActionMenuElement_hide = function _ActionMenuElement_hide() {
|
|
|
497
785
|
}
|
|
498
786
|
};
|
|
499
787
|
_ActionMenuElement_isOpen = function _ActionMenuElement_isOpen() {
|
|
500
|
-
return this.
|
|
788
|
+
return this.overlay?.matches(':popover-open') ?? false;
|
|
501
789
|
};
|
|
502
790
|
_ActionMenuElement_setDynamicLabel = function _ActionMenuElement_setDynamicLabel() {
|
|
503
791
|
if (!this.dynamicLabel)
|
|
@@ -505,7 +793,12 @@ _ActionMenuElement_setDynamicLabel = function _ActionMenuElement_setDynamicLabel
|
|
|
505
793
|
const invokerLabel = this.invokerLabel;
|
|
506
794
|
if (!invokerLabel)
|
|
507
795
|
return;
|
|
508
|
-
|
|
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
|
+
}
|
|
509
802
|
let itemLabel;
|
|
510
803
|
if (this.selectVariant === 'single') {
|
|
511
804
|
itemLabel = this.querySelector('[aria-checked=true] .ActionListItem-label')?.textContent?.trim();
|
|
@@ -552,6 +845,11 @@ _ActionMenuElement_updateInput = function _ActionMenuElement_updateInput() {
|
|
|
552
845
|
if (inputs.length > 0) {
|
|
553
846
|
__classPrivateFieldSet(this, _ActionMenuElement_inputName, __classPrivateFieldGet(this, _ActionMenuElement_inputName, "f") || inputs[0].name, "f");
|
|
554
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"));
|
|
555
853
|
for (const selectedItem of this.selectedItems) {
|
|
556
854
|
const newInput = document.createElement('input');
|
|
557
855
|
newInput.setAttribute('data-list-input', 'true');
|
|
@@ -583,6 +881,7 @@ _ActionMenuElement_itemForSubMenu = function _ActionMenuElement_itemForSubMenu(s
|
|
|
583
881
|
}
|
|
584
882
|
return null;
|
|
585
883
|
};
|
|
884
|
+
ActionMenuElement.observedAttributes = ['src'];
|
|
586
885
|
ActionMenuElement.validItemRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];
|
|
587
886
|
ActionMenuElement.validSelectors = ActionMenuElement_1.validItemRoles.map(role => `[role="${role}"]`);
|
|
588
887
|
ActionMenuElement.menuItemSelectors = ActionMenuElement_1.validSelectors.map(selector => `:not([hidden]) > ${selector}`);
|
|
@@ -595,6 +894,12 @@ __decorate([
|
|
|
595
894
|
__decorate([
|
|
596
895
|
target
|
|
597
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);
|
|
598
903
|
ActionMenuElement = ActionMenuElement_1 = __decorate([
|
|
599
904
|
controller('action-menu')
|
|
600
905
|
], ActionMenuElement);
|