@m3e/nav-rail 1.0.0-rc.2 → 1.0.0-rc.4

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/README.md CHANGED
@@ -27,7 +27,7 @@ Alternately, you can explicitly reference the `html-custom-data.json` and `css-c
27
27
  }
28
28
  ```
29
29
 
30
- ## 🚀 Browser Usage
30
+ ## 🚀 Native Module Support
31
31
 
32
32
  This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#module_specifiers). To use it directly in a browser without a bundler, use a module script similar to the following.
33
33
 
@@ -35,12 +35,6 @@ This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/
35
35
  <script type="module" src="/node_modules/@m3e/nav-rail/dist/index.js"></script>
36
36
  ```
37
37
 
38
- You also need a module script for `@m3e/nav-bar` due to it being a dependency.
39
-
40
- ```html
41
- <script type="module" src="/node_modules/@m3e/nav-bar/dist/index.js"></script>
42
- ```
43
-
44
38
  In addition, you must use an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) to include dependencies.
45
39
 
46
40
  ```html
@@ -46,6 +46,36 @@
46
46
  "name": "--m3e-nav-rail-expanded-icon-button-inset",
47
47
  "description": "Inset for icon buttons in expanded mode.",
48
48
  "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-nav-bar-height",
52
+ "description": "Height of the navigation bar.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-nav-bar-container-color",
57
+ "description": "Background color of the navigation bar container.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-nav-bar-vertical-item-width",
62
+ "description": "Minimum width of vertical nav items.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-nav-bar-height",
67
+ "description": "Height of the navigation bar.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-nav-bar-container-color",
72
+ "description": "Background color of the navigation bar container.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-nav-bar-vertical-item-width",
77
+ "description": "Minimum width of vertical nav items.",
78
+ "values": []
49
79
  }
50
80
  ],
51
81
  "pseudoElements": []
@@ -69,6 +69,30 @@
69
69
  {
70
70
  "description": "Inset for icon buttons in expanded mode.",
71
71
  "name": "--m3e-nav-rail-expanded-icon-button-inset"
72
+ },
73
+ {
74
+ "description": "Height of the navigation bar.",
75
+ "name": "--m3e-nav-bar-height",
76
+ "inheritedFrom": {
77
+ "name": "M3eNavBarElement",
78
+ "module": "../nav-bar/src/NavBarElement.ts"
79
+ }
80
+ },
81
+ {
82
+ "description": "Background color of the navigation bar container.",
83
+ "name": "--m3e-nav-bar-container-color",
84
+ "inheritedFrom": {
85
+ "name": "M3eNavBarElement",
86
+ "module": "../nav-bar/src/NavBarElement.ts"
87
+ }
88
+ },
89
+ {
90
+ "description": "Minimum width of vertical nav items.",
91
+ "name": "--m3e-nav-bar-vertical-item-width",
92
+ "inheritedFrom": {
93
+ "name": "M3eNavBarElement",
94
+ "module": "../nav-bar/src/NavBarElement.ts"
95
+ }
72
96
  }
73
97
  ],
74
98
  "members": [
@@ -100,18 +124,123 @@
100
124
  }
101
125
  }
102
126
  ]
127
+ },
128
+ {
129
+ "kind": "field",
130
+ "name": "mode",
131
+ "type": {
132
+ "text": "NavBarMode"
133
+ },
134
+ "default": "\"compact\"",
135
+ "description": "The mode in which items in the bar are presented.",
136
+ "attribute": "mode",
137
+ "reflects": true,
138
+ "inheritedFrom": {
139
+ "name": "M3eNavBarElement",
140
+ "module": "../nav-bar/src/NavBarElement.ts"
141
+ }
142
+ },
143
+ {
144
+ "kind": "field",
145
+ "name": "items",
146
+ "type": {
147
+ "text": "readonly M3eNavItemElement[]"
148
+ },
149
+ "description": "The items of the bar.",
150
+ "readonly": true,
151
+ "inheritedFrom": {
152
+ "name": "M3eNavBarElement",
153
+ "module": "../nav-bar/src/NavBarElement.ts"
154
+ }
155
+ },
156
+ {
157
+ "kind": "field",
158
+ "name": "selected",
159
+ "type": {
160
+ "text": "M3eNavItemElement | null"
161
+ },
162
+ "description": "The selected item.",
163
+ "readonly": true,
164
+ "inheritedFrom": {
165
+ "name": "M3eNavBarElement",
166
+ "module": "../nav-bar/src/NavBarElement.ts"
167
+ }
168
+ },
169
+ {
170
+ "kind": "field",
171
+ "name": "currentMode",
172
+ "type": {
173
+ "text": "Exclude<NavBarMode, \"auto\">"
174
+ },
175
+ "description": "The current mode applied to the bar.",
176
+ "inheritedFrom": {
177
+ "name": "M3eNavBarElement",
178
+ "module": "../nav-bar/src/NavBarElement.ts"
179
+ }
180
+ },
181
+ {
182
+ "kind": "method",
183
+ "name": "#handleSlotChange",
184
+ "privacy": "private",
185
+ "return": {
186
+ "type": {
187
+ "text": "void"
188
+ }
189
+ },
190
+ "inheritedFrom": {
191
+ "name": "M3eNavBarElement",
192
+ "module": "../nav-bar/src/NavBarElement.ts"
193
+ }
194
+ },
195
+ {
196
+ "kind": "method",
197
+ "name": "#handleChange",
198
+ "privacy": "private",
199
+ "return": {
200
+ "type": {
201
+ "text": "void"
202
+ }
203
+ },
204
+ "parameters": [
205
+ {
206
+ "name": "e",
207
+ "type": {
208
+ "text": "Event"
209
+ }
210
+ }
211
+ ],
212
+ "inheritedFrom": {
213
+ "name": "M3eNavBarElement",
214
+ "module": "../nav-bar/src/NavBarElement.ts"
215
+ }
103
216
  }
104
217
  ],
105
218
  "events": [
106
219
  {
220
+ "name": "change",
221
+ "type": {
222
+ "text": "Event"
223
+ },
107
224
  "description": "Emitted when the selected state of an item changes.",
108
- "name": "change"
225
+ "inheritedFrom": {
226
+ "name": "M3eNavBarElement",
227
+ "module": "../nav-bar/src/NavBarElement.ts"
228
+ }
109
229
  }
110
230
  ],
111
231
  "attributes": [
112
232
  {
113
233
  "description": "The mode in which items in the rail are presented.",
114
- "name": "mode"
234
+ "name": "mode",
235
+ "type": {
236
+ "text": "NavBarMode"
237
+ },
238
+ "default": "\"compact\"",
239
+ "fieldName": "mode",
240
+ "inheritedFrom": {
241
+ "name": "M3eNavBarElement",
242
+ "module": "../nav-bar/src/NavBarElement.ts"
243
+ }
115
244
  }
116
245
  ],
117
246
  "superclass": {
@@ -119,7 +248,17 @@
119
248
  "package": "@m3e/nav-bar"
120
249
  },
121
250
  "tagName": "m3e-nav-rail",
122
- "customElement": true
251
+ "customElement": true,
252
+ "slots": [
253
+ {
254
+ "description": "Renders the items of the bar.",
255
+ "name": "",
256
+ "inheritedFrom": {
257
+ "name": "M3eNavBarElement",
258
+ "module": "../nav-bar/src/NavBarElement.ts"
259
+ }
260
+ }
261
+ ]
123
262
  }
124
263
  ],
125
264
  "exports": [
@@ -223,7 +362,7 @@
223
362
  "privacy": "private",
224
363
  "return": {
225
364
  "type": {
226
- "text": "void"
365
+ "text": "Promise<void>"
227
366
  }
228
367
  }
229
368
  },
@@ -326,6 +465,154 @@
326
465
  }
327
466
  ]
328
467
  },
468
+ {
469
+ "kind": "javascript-module",
470
+ "path": "../nav-bar/src/NavBarElement.ts",
471
+ "declarations": [
472
+ {
473
+ "kind": "class",
474
+ "description": "A horizontal bar, typically used on smaller devices, that allows a user to switch between 3-5 views.",
475
+ "name": "M3eNavBarElement",
476
+ "cssProperties": [
477
+ {
478
+ "description": "Height of the navigation bar.",
479
+ "name": "--m3e-nav-bar-height"
480
+ },
481
+ {
482
+ "description": "Background color of the navigation bar container.",
483
+ "name": "--m3e-nav-bar-container-color"
484
+ },
485
+ {
486
+ "description": "Minimum width of vertical nav items.",
487
+ "name": "--m3e-nav-bar-vertical-item-width"
488
+ }
489
+ ],
490
+ "slots": [
491
+ {
492
+ "description": "Renders the items of the bar.",
493
+ "name": ""
494
+ }
495
+ ],
496
+ "members": [
497
+ {
498
+ "kind": "field",
499
+ "name": "mode",
500
+ "type": {
501
+ "text": "NavBarMode"
502
+ },
503
+ "default": "\"compact\"",
504
+ "description": "The mode in which items in the bar are presented.",
505
+ "attribute": "mode",
506
+ "reflects": true
507
+ },
508
+ {
509
+ "kind": "field",
510
+ "name": "items",
511
+ "type": {
512
+ "text": "readonly M3eNavItemElement[]"
513
+ },
514
+ "description": "The items of the bar.",
515
+ "readonly": true
516
+ },
517
+ {
518
+ "kind": "field",
519
+ "name": "selected",
520
+ "type": {
521
+ "text": "M3eNavItemElement | null"
522
+ },
523
+ "description": "The selected item.",
524
+ "readonly": true
525
+ },
526
+ {
527
+ "kind": "field",
528
+ "name": "currentMode",
529
+ "type": {
530
+ "text": "Exclude<NavBarMode, \"auto\">"
531
+ },
532
+ "description": "The current mode applied to the bar."
533
+ },
534
+ {
535
+ "kind": "method",
536
+ "name": "#handleSlotChange",
537
+ "privacy": "private",
538
+ "return": {
539
+ "type": {
540
+ "text": "void"
541
+ }
542
+ }
543
+ },
544
+ {
545
+ "kind": "method",
546
+ "name": "#handleChange",
547
+ "privacy": "private",
548
+ "return": {
549
+ "type": {
550
+ "text": "void"
551
+ }
552
+ },
553
+ "parameters": [
554
+ {
555
+ "name": "e",
556
+ "type": {
557
+ "text": "Event"
558
+ }
559
+ }
560
+ ]
561
+ }
562
+ ],
563
+ "events": [
564
+ {
565
+ "name": "change",
566
+ "type": {
567
+ "text": "Event"
568
+ },
569
+ "description": "Emitted when the selected state of an item changes."
570
+ }
571
+ ],
572
+ "attributes": [
573
+ {
574
+ "description": "The mode in which items in the bar are presented.",
575
+ "name": "mode",
576
+ "type": {
577
+ "text": "NavBarMode"
578
+ },
579
+ "default": "\"compact\"",
580
+ "fieldName": "mode"
581
+ }
582
+ ],
583
+ "mixins": [
584
+ {
585
+ "name": "Role",
586
+ "package": "@m3e/core"
587
+ }
588
+ ],
589
+ "superclass": {
590
+ "name": "LitElement",
591
+ "package": "lit"
592
+ },
593
+ "tagName": "m3e-nav-bar",
594
+ "customElement": true
595
+ }
596
+ ],
597
+ "exports": [
598
+ {
599
+ "kind": "js",
600
+ "name": "M3eNavBarElement",
601
+ "declaration": {
602
+ "name": "M3eNavBarElement",
603
+ "module": "../nav-bar/src/NavBarElement.ts"
604
+ }
605
+ },
606
+ {
607
+ "kind": "custom-element-definition",
608
+ "name": "m3e-nav-bar",
609
+ "declaration": {
610
+ "name": "M3eNavBarElement",
611
+ "module": "../nav-bar/src/NavBarElement.ts"
612
+ }
613
+ }
614
+ ]
615
+ },
329
616
  {
330
617
  "kind": "javascript-module",
331
618
  "path": "../core/src/shared/mixins/AttachInternals.ts",
@@ -1180,25 +1467,6 @@
1180
1467
  "kind": "mixin",
1181
1468
  "description": "Mixin that adds support for custom event attributes.",
1182
1469
  "name": "EventAttribute",
1183
- "members": [
1184
- {
1185
- "kind": "method",
1186
- "name": "dispatchEvent",
1187
- "return": {
1188
- "type": {
1189
- "text": "boolean"
1190
- }
1191
- },
1192
- "parameters": [
1193
- {
1194
- "name": "event",
1195
- "type": {
1196
- "text": "Event"
1197
- }
1198
- }
1199
- ]
1200
- }
1201
- ],
1202
1470
  "parameters": [
1203
1471
  {
1204
1472
  "name": "base",
@@ -1496,6 +1764,17 @@
1496
1764
  "description": "Mixin to augment an element with behavior used to submit a form.",
1497
1765
  "name": "FormSubmitter",
1498
1766
  "members": [
1767
+ {
1768
+ "kind": "field",
1769
+ "name": "formAssociated",
1770
+ "type": {
1771
+ "text": "boolean"
1772
+ },
1773
+ "static": true,
1774
+ "readonly": true,
1775
+ "default": "true",
1776
+ "description": "Indicates that this custom element participates in form submission, validation, and form state restoration."
1777
+ },
1499
1778
  {
1500
1779
  "kind": "field",
1501
1780
  "name": "name",
@@ -2032,6 +2311,11 @@
2032
2311
  "kind": "javascript-module",
2033
2312
  "path": "../core/src/shared/mixins/Labelled.ts",
2034
2313
  "declarations": [
2314
+ {
2315
+ "kind": "variable",
2316
+ "name": "updateLabels",
2317
+ "description": "A symbol through which to update labels to reflect a control's current state."
2318
+ },
2035
2319
  {
2036
2320
  "kind": "function",
2037
2321
  "name": "isLabelledMixin",
@@ -2081,16 +2365,6 @@
2081
2365
  },
2082
2366
  "description": "The label elements that the element is associated with.",
2083
2367
  "readonly": true
2084
- },
2085
- {
2086
- "kind": "method",
2087
- "name": "[_updateLabels]",
2088
- "privacy": "private",
2089
- "return": {
2090
- "type": {
2091
- "text": "void"
2092
- }
2093
- }
2094
2368
  }
2095
2369
  ],
2096
2370
  "parameters": [
@@ -2105,6 +2379,14 @@
2105
2379
  }
2106
2380
  ],
2107
2381
  "exports": [
2382
+ {
2383
+ "kind": "js",
2384
+ "name": "updateLabels",
2385
+ "declaration": {
2386
+ "name": "updateLabels",
2387
+ "module": "../core/src/shared/mixins/Labelled.ts"
2388
+ }
2389
+ },
2108
2390
  {
2109
2391
  "kind": "js",
2110
2392
  "name": "isLabelledMixin",
@@ -4,12 +4,12 @@
4
4
  "tags": [
5
5
  {
6
6
  "name": "m3e-nav-rail",
7
- "description": "A vertical bar, typically used on larger devices, that allows a user to switch between views.\n---\n\n\n### **Events:**\n - **change** - Emitted when the selected state of an item changes.\n\n### **CSS Properties:**\n - **--m3e-nav-rail-top-space** - Top block padding for the nav rail. _(default: undefined)_\n- **--m3e-nav-rail-bottom-space** - Bottom block padding for the nav rail. _(default: undefined)_\n- **--m3e-nav-rail-compact-width** - Width of the nav rail in compact mode. _(default: undefined)_\n- **--m3e-nav-rail-expanded-inline-padding** - Inline padding for expanded nav rail. _(default: undefined)_\n- **--m3e-nav-rail-expanded-min-width** - Minimum width of the nav rail in expanded mode. _(default: undefined)_\n- **--m3e-nav-rail-expanded-max-width** - Maximum width of the nav rail in expanded mode. _(default: undefined)_\n- **--m3e-nav-rail-expanded-item-height** - Height of nav items in expanded mode. _(default: undefined)_\n- **--m3e-nav-rail-button-item-space** - Space below icon buttons and FABs. _(default: undefined)_\n- **--m3e-nav-rail-expanded-icon-button-inset** - Inset for icon buttons in expanded mode. _(default: undefined)_",
7
+ "description": "A vertical bar, typically used on larger devices, that allows a user to switch between views.\n---\n\n\n### **Events:**\n - **change** - Emitted when the selected state of an item changes.\n\n### **Slots:**\n - _default_ - Renders the items of the bar.\n\n### **CSS Properties:**\n - **--m3e-nav-rail-top-space** - Top block padding for the nav rail. _(default: undefined)_\n- **--m3e-nav-rail-bottom-space** - Bottom block padding for the nav rail. _(default: undefined)_\n- **--m3e-nav-rail-compact-width** - Width of the nav rail in compact mode. _(default: undefined)_\n- **--m3e-nav-rail-expanded-inline-padding** - Inline padding for expanded nav rail. _(default: undefined)_\n- **--m3e-nav-rail-expanded-min-width** - Minimum width of the nav rail in expanded mode. _(default: undefined)_\n- **--m3e-nav-rail-expanded-max-width** - Maximum width of the nav rail in expanded mode. _(default: undefined)_\n- **--m3e-nav-rail-expanded-item-height** - Height of nav items in expanded mode. _(default: undefined)_\n- **--m3e-nav-rail-button-item-space** - Space below icon buttons and FABs. _(default: undefined)_\n- **--m3e-nav-rail-expanded-icon-button-inset** - Inset for icon buttons in expanded mode. _(default: undefined)_\n- **--m3e-nav-bar-height** - Height of the navigation bar. _(default: undefined)_\n- **--m3e-nav-bar-container-color** - Background color of the navigation bar container. _(default: undefined)_\n- **--m3e-nav-bar-vertical-item-width** - Minimum width of vertical nav items. _(default: undefined)_",
8
8
  "attributes": [
9
9
  {
10
10
  "name": "mode",
11
11
  "description": "The mode in which items in the rail are presented.",
12
- "values": []
12
+ "values": [{ "name": "NavBarMode" }]
13
13
  }
14
14
  ],
15
15
  "references": []
@@ -25,6 +25,18 @@
25
25
  }
26
26
  ],
27
27
  "references": []
28
+ },
29
+ {
30
+ "name": "m3e-nav-bar",
31
+ "description": "A horizontal bar, typically used on smaller devices, that allows a user to switch between 3-5 views.\n---\n\n\n### **Events:**\n - **change** - Emitted when the selected state of an item changes.\n\n### **Slots:**\n - _default_ - Renders the items of the bar.\n\n### **CSS Properties:**\n - **--m3e-nav-bar-height** - Height of the navigation bar. _(default: undefined)_\n- **--m3e-nav-bar-container-color** - Background color of the navigation bar container. _(default: undefined)_\n- **--m3e-nav-bar-vertical-item-width** - Minimum width of vertical nav items. _(default: undefined)_",
32
+ "attributes": [
33
+ {
34
+ "name": "mode",
35
+ "description": "The mode in which items in the bar are presented.",
36
+ "values": [{ "name": "NavBarMode" }]
37
+ }
38
+ ],
39
+ "references": []
28
40
  }
29
41
  ]
30
42
  }
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { css, LitElement, html } from 'lit';
7
7
  import { DesignToken, HtmlFor, MutationController } from '@m3e/core';
8
- import { RovingTabIndexManager, selectionManager, M3eInteractivityChecker } from '@m3e/core/a11y';
8
+ import { RovingTabIndexManager, selectionManager, M3eInteractivityChecker, addAriaReferencedId, removeAriaReferencedId } from '@m3e/core/a11y';
9
9
  import { M3eNavBarElement } from '@m3e/nav-bar';
10
10
 
11
11
  /******************************************************************************
@@ -255,6 +255,9 @@ let M3eNavRailToggleElement = class M3eNavRailToggleElement extends HtmlFor(LitE
255
255
  if (control instanceof M3eNavRailElement) {
256
256
  __classPrivateFieldGet(this, _M3eNavRailToggleElement_mutationController, "f").observe(control);
257
257
  }
258
+ if (this.htmlFor && this.parentElement) {
259
+ addAriaReferencedId(this.parentElement, "aria-controls", this.htmlFor);
260
+ }
258
261
  super.attach(control);
259
262
  __classPrivateFieldGet(this, _M3eNavRailToggleElement_instances, "m", _M3eNavRailToggleElement_updateToggle).call(this);
260
263
  }
@@ -263,7 +266,12 @@ let M3eNavRailToggleElement = class M3eNavRailToggleElement extends HtmlFor(LitE
263
266
  for (const target of __classPrivateFieldGet(this, _M3eNavRailToggleElement_mutationController, "f").targets) {
264
267
  __classPrivateFieldGet(this, _M3eNavRailToggleElement_mutationController, "f").unobserve(target);
265
268
  }
266
- __classPrivateFieldGet(this, _M3eNavRailToggleElement_instances, "m", _M3eNavRailToggleElement_updateToggle).call(this);
269
+ if (this.parentElement) {
270
+ if (this.htmlFor) {
271
+ removeAriaReferencedId(this.parentElement, "aria-controls", this.htmlFor);
272
+ }
273
+ this.parentElement.ariaExpanded = null;
274
+ }
267
275
  super.detach();
268
276
  }
269
277
  /** @inheritdoc */
@@ -279,9 +287,20 @@ _M3eNavRailToggleElement_handleClick = function _M3eNavRailToggleElement_handleC
279
287
  this.control.currentMode = this.control.currentMode === "compact" ? "expanded" : "compact";
280
288
  }
281
289
  };
282
- _M3eNavRailToggleElement_updateToggle = function _M3eNavRailToggleElement_updateToggle() {
283
- if (this.parentElement?.hasAttribute("toggle")) {
284
- this.parentElement.toggleAttribute("selected", this.control instanceof M3eNavRailElement && this.control.currentMode === "expanded");
290
+ _M3eNavRailToggleElement_updateToggle =
291
+ /** @private */
292
+ async function _M3eNavRailToggleElement_updateToggle() {
293
+ if (!this.parentElement)
294
+ return;
295
+ const selected = this.control instanceof M3eNavRailElement && this.control.currentMode === "expanded";
296
+ this.parentElement.ariaExpanded = `${selected}`;
297
+ if (this.parentElement.hasAttribute("toggle")) {
298
+ this.parentElement.toggleAttribute("selected", selected);
299
+ }
300
+ if (this.parentElement instanceof LitElement) {
301
+ // Wait for update and remove aria-pressed due to use of aria-expanded.
302
+ await this.parentElement.updateComplete;
303
+ this.parentElement.ariaPressed = null;
285
304
  }
286
305
  };
287
306
  /** The styles of the element. */