@primer/view-components 0.1.0 → 0.1.1-rc.797d8bd8

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.
@@ -18,6 +18,7 @@ export declare class NavListElement extends HTMLElement {
18
18
  collapseItem(item: HTMLElement): void;
19
19
  itemIsExpanded(item: HTMLElement | null): boolean;
20
20
  handleItemWithSubItemClick(e: Event): void;
21
+ handleItemWithSubItemKeydown(e: KeyboardEvent): void;
21
22
  private showMore;
22
23
  private setShowMoreItemState;
23
24
  }
@@ -82,6 +82,7 @@ let NavListElement = class NavListElement extends HTMLElement {
82
82
  var _a;
83
83
  (_a = item.nextElementSibling) === null || _a === void 0 ? void 0 : _a.setAttribute('data-hidden', '');
84
84
  item.setAttribute('aria-expanded', 'false');
85
+ item.focus();
85
86
  }
86
87
  itemIsExpanded(item) {
87
88
  if ((item === null || item === void 0 ? void 0 : item.tagName) === 'A') {
@@ -105,6 +106,26 @@ let NavListElement = class NavListElement extends HTMLElement {
105
106
  }
106
107
  e.stopPropagation();
107
108
  }
109
+ // collapse item
110
+ handleItemWithSubItemKeydown(e) {
111
+ const el = e.currentTarget;
112
+ if (!(el instanceof HTMLElement))
113
+ return;
114
+ let button = el.closest('button');
115
+ if (!button) {
116
+ const button_id = el.getAttribute('aria-labelledby');
117
+ if (button_id) {
118
+ button = document.getElementById(button_id);
119
+ }
120
+ else {
121
+ return;
122
+ }
123
+ }
124
+ if (this.itemIsExpanded(button) && e.key === 'Escape') {
125
+ this.collapseItem(button);
126
+ }
127
+ e.stopPropagation();
128
+ }
108
129
  async showMore(e) {
109
130
  var _a, _b;
110
131
  e.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-rc.797d8bd8",
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",
@@ -2196,10 +2196,10 @@
2196
2196
  ]
2197
2197
  },
2198
2198
  {
2199
- "component": "NavList::Section",
2199
+ "component": "NavList::Group",
2200
2200
  "status": "alpha",
2201
- "source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/nav_list/section.rb",
2202
- "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/nav_list/section/default/",
2201
+ "source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/nav_list/group.rb",
2202
+ "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/nav_list/group/default/",
2203
2203
  "parameters": [
2204
2204
  {
2205
2205
  "name": "selected_item_id",
@@ -2291,6 +2291,12 @@
2291
2291
  "default": "N/A",
2292
2292
  "description": "Sub list title."
2293
2293
  },
2294
+ {
2295
+ "name": "heading_level",
2296
+ "type": "Integer",
2297
+ "default": "`3`",
2298
+ "description": "Heading level. Level 2 results in an `<h2>` tag, level 3 an `<h3>` tag, etc."
2299
+ },
2294
2300
  {
2295
2301
  "name": "subtitle",
2296
2302
  "type": "String",
@@ -2305,8 +2311,8 @@
2305
2311
  },
2306
2312
  {
2307
2313
  "name": "tag",
2308
- "type": "Symbol",
2309
- "default": "`:h3`",
2314
+ "type": "Integer",
2315
+ "default": "N/A",
2310
2316
  "description": "Semantic tag for the heading."
2311
2317
  },
2312
2318
  {
@@ -2374,7 +2380,7 @@
2374
2380
  {
2375
2381
  "name": "role",
2376
2382
  "type": "String",
2377
- "default": "`:listitem`",
2383
+ "default": "`nil`",
2378
2384
  "description": "ARIA role describing the function of the item."
2379
2385
  },
2380
2386
  {
@@ -28,8 +28,8 @@
28
28
  "Primer::Alpha::Menu": "",
29
29
  "Primer::Alpha::MultiInput": "",
30
30
  "Primer::Alpha::NavList": "",
31
+ "Primer::Alpha::NavList::Group": "",
31
32
  "Primer::Alpha::NavList::Item": "",
32
- "Primer::Alpha::NavList::Section": "",
33
33
  "Primer::Alpha::OcticonSymbols": "",
34
34
  "Primer::Alpha::Overlay": "",
35
35
  "Primer::Alpha::Overlay::Body": "",
@@ -27,6 +27,16 @@
27
27
  },
28
28
  "Primer::Alpha::ActionList::Heading": {
29
29
  "DEFAULT_SCHEME": "subtle",
30
+ "HEADING_LEVELS": [
31
+ 1,
32
+ 2,
33
+ 3,
34
+ 4,
35
+ 5,
36
+ 6
37
+ ],
38
+ "HEADING_MAX": 6,
39
+ "HEADING_MIN": 1,
30
40
  "SCHEME_MAPPINGS": {
31
41
  "subtle": null,
32
42
  "filled": "ActionList-sectionDivider--filled"
@@ -326,12 +336,12 @@
326
336
  "Primer::Alpha::MultiInput": {
327
337
  },
328
338
  "Primer::Alpha::NavList": {
329
- "Item": "Primer::Alpha::NavList::Item",
330
- "Section": "Primer::Alpha::NavList::Section"
339
+ "Group": "Primer::Alpha::NavList::Group",
340
+ "Item": "Primer::Alpha::NavList::Item"
331
341
  },
332
- "Primer::Alpha::NavList::Item": {
342
+ "Primer::Alpha::NavList::Group": {
333
343
  },
334
- "Primer::Alpha::NavList::Section": {
344
+ "Primer::Alpha::NavList::Item": {
335
345
  },
336
346
  "Primer::Alpha::OcticonSymbols": {
337
347
  },
@@ -28,8 +28,8 @@
28
28
  "Primer::Alpha::Menu": "alpha",
29
29
  "Primer::Alpha::MultiInput": "alpha",
30
30
  "Primer::Alpha::NavList": "alpha",
31
+ "Primer::Alpha::NavList::Group": "alpha",
31
32
  "Primer::Alpha::NavList::Item": "alpha",
32
- "Primer::Alpha::NavList::Section": "alpha",
33
33
  "Primer::Alpha::OcticonSymbols": "alpha",
34
34
  "Primer::Alpha::Overlay": "alpha",
35
35
  "Primer::Alpha::Overlay::Body": "alpha",