@primer/view-components 0.1.6-rc.277c7eae → 0.1.6-rc.396599d3

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.
@@ -10,6 +10,7 @@ export declare class ActionMenuElement extends HTMLElement {
10
10
  set dynamicLabel(value: boolean);
11
11
  get popoverElement(): HTMLElement | null;
12
12
  get invokerElement(): HTMLElement | null;
13
+ get invokerLabel(): HTMLElement | null;
13
14
  connectedCallback(): void;
14
15
  disconnectedCallback(): void;
15
16
  handleEvent(event: Event): void;
@@ -68,6 +68,11 @@ export class ActionMenuElement extends HTMLElement {
68
68
  }
69
69
  return null;
70
70
  }
71
+ get invokerLabel() {
72
+ if (!this.invokerElement)
73
+ return null;
74
+ return this.invokerElement.querySelector('.Button-label');
75
+ }
71
76
  connectedCallback() {
72
77
  const { signal } = (__classPrivateFieldSet(this, _ActionMenuElement_abortController, new AbortController(), "f"));
73
78
  this.addEventListener('keydown', this, { signal });
@@ -130,21 +135,21 @@ export class ActionMenuElement extends HTMLElement {
130
135
  _ActionMenuElement_abortController = new WeakMap(), _ActionMenuElement_originalLabel = new WeakMap(), _ActionMenuElement_instances = new WeakSet(), _ActionMenuElement_setDynamicLabel = function _ActionMenuElement_setDynamicLabel() {
131
136
  if (!this.dynamicLabel)
132
137
  return;
133
- const invoker = this.invokerElement;
134
- if (!invoker)
138
+ const invokerLabel = this.invokerLabel;
139
+ if (!invokerLabel)
135
140
  return;
136
- const item = this.querySelector('[aria-checked=true]');
137
- if (item && this.dynamicLabel) {
138
- __classPrivateFieldSet(this, _ActionMenuElement_originalLabel, __classPrivateFieldGet(this, _ActionMenuElement_originalLabel, "f") || (invoker.textContent || ''), "f");
141
+ const itemLabel = this.querySelector('[aria-checked=true] .ActionListItem-label');
142
+ if (itemLabel && this.dynamicLabel) {
143
+ __classPrivateFieldSet(this, _ActionMenuElement_originalLabel, __classPrivateFieldGet(this, _ActionMenuElement_originalLabel, "f") || (invokerLabel.textContent || ''), "f");
139
144
  const prefixSpan = document.createElement('span');
140
145
  prefixSpan.classList.add('color-fg-muted');
141
146
  const contentSpan = document.createElement('span');
142
147
  prefixSpan.textContent = this.dynamicLabelPrefix;
143
- contentSpan.textContent = item.textContent || '';
144
- invoker.replaceChildren(prefixSpan, contentSpan);
148
+ contentSpan.textContent = itemLabel.textContent || '';
149
+ invokerLabel.replaceChildren(prefixSpan, contentSpan);
145
150
  }
146
151
  else {
147
- invoker.textContent = __classPrivateFieldGet(this, _ActionMenuElement_originalLabel, "f");
152
+ invokerLabel.textContent = __classPrivateFieldGet(this, _ActionMenuElement_originalLabel, "f");
148
153
  }
149
154
  }, _ActionMenuElement_isEnterKeydown = function _ActionMenuElement_isEnterKeydown(event) {
150
155
  return (event instanceof KeyboardEvent &&
@@ -20,13 +20,7 @@ function focusIfNeeded(elem) {
20
20
  const overlayStack = [];
21
21
  function clickHandler(event) {
22
22
  const target = event.target;
23
- let button = null;
24
- if (target instanceof HTMLButtonElement) {
25
- button = target;
26
- }
27
- else {
28
- button = target === null || target === void 0 ? void 0 : target.querySelector('button');
29
- }
23
+ const button = target === null || target === void 0 ? void 0 : target.closest('button');
30
24
  if (!button)
31
25
  return;
32
26
  // If the user is clicking a valid dialog trigger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.1.6-rc.277c7eae",
3
+ "version": "0.1.6-rc.396599d3",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",
@@ -647,13 +647,13 @@
647
647
  },
648
648
  {
649
649
  "name": "with_show_button",
650
- "description": "Button to activate the menu. This may be a {{#link_to_component}}Primer::ButtonComponent{{/link_to_component}} or {{#link_to_component}}Primer::IconButton{{/link_to_component}}.",
650
+ "description": "Button to activate the menu.",
651
651
  "parameters": [
652
652
  {
653
- "name": "icon",
654
- "type": "Symbol",
653
+ "name": "system_arguments",
654
+ "type": "Hash",
655
655
  "default": "N/A",
656
- "description": "Set this to an [Octicon name](https://primer.style/octicons/) when you want to render an `IconButton`. Otherwise, this renders as a {{#link_to_component}}Primer::ButtonComponent{{/link_to_component}}."
656
+ "description": "The arguments accepted by {{#link_to_component}}Primer::Alpha::Overlay{{/link_to_component}}'s `show_button` slot."
657
657
  }
658
658
  ]
659
659
  },
@@ -695,6 +695,11 @@
695
695
  "preview_path": "/lookbook/preview/primer/alpha/action_menu/playground",
696
696
  "name": "playground"
697
697
  },
698
+ {
699
+ "inspect_path": "/lookbook/inspect/primer/alpha/action_menu/content_labels",
700
+ "preview_path": "/lookbook/preview/primer/alpha/action_menu/content_labels",
701
+ "name": "content_labels"
702
+ },
698
703
  {
699
704
  "inspect_path": "/lookbook/inspect/primer/alpha/action_menu/default",
700
705
  "preview_path": "/lookbook/preview/primer/alpha/action_menu/default",
@@ -3347,10 +3352,22 @@
3347
3352
  "description": "Optional button to open the Overlay.",
3348
3353
  "parameters": [
3349
3354
  {
3350
- "name": "system_arguments",
3355
+ "name": "icon",
3356
+ "type": "String",
3357
+ "default": "N/A",
3358
+ "description": "Name of {{link_to_octicons}} to use instead of text. If provided, a {{#link_to_component}}Primer::Beta::IconButton{{/link_to_component}} will be rendered. Otherwise a {{#link_to_component}}Primer::Beta::Button{{/link_to_component}} will be rendered."
3359
+ },
3360
+ {
3361
+ "name": "controls",
3362
+ "type": "String",
3363
+ "default": "N/A",
3364
+ "description": "The ID of the menu this button controls. Used internally."
3365
+ },
3366
+ {
3367
+ "name": "button_arguments",
3351
3368
  "type": "Hash",
3352
3369
  "default": "N/A",
3353
- "description": "The same arguments as {{#link_to_component}}Primer::ButtonComponent{{/link_to_component}}."
3370
+ "description": "The arguments accepted by {{#link_to_component}}Primer::Beta::Button{{/link_to_component}} or {{#link_to_component}}Primer::Beta::IconButton{{/link_to_component}} depending on the presence of the `icon:` argument."
3354
3371
  }
3355
3372
  ]
3356
3373
  },
@@ -3364,6 +3381,12 @@
3364
3381
  "default": "N/A",
3365
3382
  "description": "Show a divider between the header and body."
3366
3383
  },
3384
+ {
3385
+ "name": "size",
3386
+ "type": "Symbol",
3387
+ "default": "N/A",
3388
+ "description": "One of One of `:auto`, `:large`, `:medium`, `:medium_portrait`, `:small`, or `:xlarge`.."
3389
+ },
3367
3390
  {
3368
3391
  "name": "visually_hide_title",
3369
3392
  "type": "Boolean",
@@ -123,6 +123,11 @@
123
123
  "preview_path": "/lookbook/preview/primer/alpha/action_menu/playground",
124
124
  "name": "playground"
125
125
  },
126
+ {
127
+ "inspect_path": "/lookbook/inspect/primer/alpha/action_menu/content_labels",
128
+ "preview_path": "/lookbook/preview/primer/alpha/action_menu/content_labels",
129
+ "name": "content_labels"
130
+ },
126
131
  {
127
132
  "inspect_path": "/lookbook/inspect/primer/alpha/action_menu/default",
128
133
  "preview_path": "/lookbook/preview/primer/alpha/action_menu/default",