@primer/view-components 0.36.6-rc.f22d48ee → 0.37.0-rc.0bf6cc7a

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.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A companion Catalyst element for the Details view component. This element
3
+ * ensures the <details> and <summary> elements markup is properly accessible by
4
+ * updating the aria-label and aria-expanded attributes on click.
5
+ *
6
+ * aria-label values default to "Expand" and "Collapse". To override those
7
+ * values, use the `data-aria-label-open` and `data-aria-label-closed`
8
+ * attributes on the summary target.
9
+ *
10
+ * @example
11
+ * ```html
12
+ * <details-toggle>
13
+ * <details open=true data-target="details-toggle.detailsTarget">
14
+ * <summary
15
+ * aria-expanded="true"
16
+ * aria-label="Collapse me"
17
+ * data-target="details-toggle.summaryTarget"
18
+ * data-action="click:details-toggle#toggle"
19
+ * data-aria-label-closed="Expand me"
20
+ * data-aria-label-open="Collapse me"
21
+ * >
22
+ * Click me
23
+ * </summary>
24
+ * <div>Contents</div>
25
+ * </details>
26
+ * </details-toggle>
27
+ * ```
28
+ */
29
+ declare class DetailsToggleElement extends HTMLElement {
30
+ detailsTarget: HTMLDetailsElement;
31
+ summaryTarget: HTMLElement;
32
+ toggle(): void;
33
+ }
34
+ declare global {
35
+ interface Window {
36
+ DetailsToggleElement: typeof DetailsToggleElement;
37
+ }
38
+ }
39
+ export {};
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { controller, target } from '@github/catalyst';
8
+ /**
9
+ * A companion Catalyst element for the Details view component. This element
10
+ * ensures the <details> and <summary> elements markup is properly accessible by
11
+ * updating the aria-label and aria-expanded attributes on click.
12
+ *
13
+ * aria-label values default to "Expand" and "Collapse". To override those
14
+ * values, use the `data-aria-label-open` and `data-aria-label-closed`
15
+ * attributes on the summary target.
16
+ *
17
+ * @example
18
+ * ```html
19
+ * <details-toggle>
20
+ * <details open=true data-target="details-toggle.detailsTarget">
21
+ * <summary
22
+ * aria-expanded="true"
23
+ * aria-label="Collapse me"
24
+ * data-target="details-toggle.summaryTarget"
25
+ * data-action="click:details-toggle#toggle"
26
+ * data-aria-label-closed="Expand me"
27
+ * data-aria-label-open="Collapse me"
28
+ * >
29
+ * Click me
30
+ * </summary>
31
+ * <div>Contents</div>
32
+ * </details>
33
+ * </details-toggle>
34
+ * ```
35
+ */
36
+ let DetailsToggleElement = class DetailsToggleElement extends HTMLElement {
37
+ toggle() {
38
+ const detailsIsOpen = this.detailsTarget.hasAttribute('open');
39
+ if (detailsIsOpen) {
40
+ const ariaLabelClosed = this.summaryTarget.getAttribute('data-aria-label-closed') || 'Expand';
41
+ this.summaryTarget.setAttribute('aria-label', ariaLabelClosed);
42
+ this.summaryTarget.setAttribute('aria-expanded', 'false');
43
+ }
44
+ else {
45
+ const ariaLabelOpen = this.summaryTarget.getAttribute('data-aria-label-open') || 'Collapse';
46
+ this.summaryTarget.setAttribute('aria-label', ariaLabelOpen);
47
+ this.summaryTarget.setAttribute('aria-expanded', 'true');
48
+ }
49
+ }
50
+ };
51
+ __decorate([
52
+ target
53
+ ], DetailsToggleElement.prototype, "detailsTarget", void 0);
54
+ __decorate([
55
+ target
56
+ ], DetailsToggleElement.prototype, "summaryTarget", void 0);
57
+ DetailsToggleElement = __decorate([
58
+ controller
59
+ ], DetailsToggleElement);
60
+ window.DetailsToggleElement = DetailsToggleElement;
@@ -25,3 +25,4 @@ import '../../lib/primer/forms/primer_text_field';
25
25
  import '../../lib/primer/forms/toggle_switch_input';
26
26
  import './alpha/action_menu/action_menu_element';
27
27
  import './alpha/select_panel_element';
28
+ import './beta/details_toggle_element';
@@ -25,3 +25,4 @@ import '../../lib/primer/forms/primer_text_field';
25
25
  import '../../lib/primer/forms/toggle_switch_input';
26
26
  import './alpha/action_menu/action_menu_element';
27
27
  import './alpha/select_panel_element';
28
+ import './beta/details_toggle_element';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.36.6-rc.f22d48ee",
3
+ "version": "0.37.0-rc.0bf6cc7a",
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",
@@ -3843,7 +3843,18 @@
3843
3843
  "name": "button",
3844
3844
  "description": "Required trigger for the dropdown. Has the same arguments as {{#link_to_component}}Primer::ButtonComponent{{/link_to_component}},\nbut it is locked as a `summary` tag.",
3845
3845
  "parameters": [
3846
-
3846
+ {
3847
+ "name": "aria_label_open",
3848
+ "type": "String",
3849
+ "default": "N/A",
3850
+ "description": "Defaults to \"Close\". Value to announce when menu is open."
3851
+ },
3852
+ {
3853
+ "name": "aria_label_closed",
3854
+ "type": "String",
3855
+ "default": "N/A",
3856
+ "description": "Defaults to \"Open\". Value to announce when menu is closed."
3857
+ }
3847
3858
  ]
3848
3859
  },
3849
3860
  {
@@ -13358,9 +13369,26 @@
13358
13369
  "slots": [
13359
13370
  {
13360
13371
  "name": "summary",
13361
- "description": null,
13372
+ "description": "Use the Summary slot as the target for toggling the Details content open/closed.",
13362
13373
  "parameters": [
13363
-
13374
+ {
13375
+ "name": "button",
13376
+ "type": "Boolean",
13377
+ "default": "N/A",
13378
+ "description": "Whether or not to render the summary element as a button."
13379
+ },
13380
+ {
13381
+ "name": "aria_label_open",
13382
+ "type": "String",
13383
+ "default": "N/A",
13384
+ "description": "Defaults to \"Collapse\". Value to announce when details element is open."
13385
+ },
13386
+ {
13387
+ "name": "aria_label_closed",
13388
+ "type": "String",
13389
+ "default": "N/A",
13390
+ "description": "Defaults to \"Expand\". Value to announce when details element is closed."
13391
+ }
13364
13392
  ]
13365
13393
  },
13366
13394
  {
@@ -13401,6 +13429,26 @@
13401
13429
  ],
13402
13430
  "return_types": [
13403
13431
 
13432
+ ]
13433
+ },
13434
+ {
13435
+ "name": "open",
13436
+ "description": "Returns the value of attribute open.",
13437
+ "parameters": [
13438
+
13439
+ ],
13440
+ "return_types": [
13441
+
13442
+ ]
13443
+ },
13444
+ {
13445
+ "name": "open?",
13446
+ "description": "Returns the value of attribute open.",
13447
+ "parameters": [
13448
+
13449
+ ],
13450
+ "return_types": [
13451
+
13404
13452
  ]
13405
13453
  }
13406
13454
  ],
@@ -13456,6 +13504,19 @@
13456
13504
  "color-contrast"
13457
13505
  ]
13458
13506
  }
13507
+ },
13508
+ {
13509
+ "preview_path": "primer/beta/details/open",
13510
+ "name": "open",
13511
+ "snapshot": "false",
13512
+ "skip_rules": {
13513
+ "wont_fix": [
13514
+ "region"
13515
+ ],
13516
+ "will_fix": [
13517
+ "color-contrast"
13518
+ ]
13519
+ }
13459
13520
  }
13460
13521
  ],
13461
13522
  "subcomponents": [
@@ -3118,6 +3118,19 @@
3118
3118
  "color-contrast"
3119
3119
  ]
3120
3120
  }
3121
+ },
3122
+ {
3123
+ "preview_path": "primer/beta/details/open",
3124
+ "name": "open",
3125
+ "snapshot": "false",
3126
+ "skip_rules": {
3127
+ "wont_fix": [
3128
+ "region"
3129
+ ],
3130
+ "will_fix": [
3131
+ "color-contrast"
3132
+ ]
3133
+ }
3121
3134
  }
3122
3135
  ]
3123
3136
  },