nsw-design-system 3.26.1 → 3.26.2

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.
@@ -35,6 +35,7 @@ declare class Navigation {
35
35
  mobileToggleMainNav(e: any): void;
36
36
  buttonClickDesktop(event: any): void;
37
37
  buttonKeydownDesktop(event: any): void;
38
+ ensureSingleDesktopSubNav(currentTarget: any): void;
38
39
  escapeClose(e: any): void;
39
40
  saveElements(e: any): void;
40
41
  showSubNav({ propertyName }: {
package/dist/js/main.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! NSW Design System v3.26.1 | MIT License */
1
+ /*! NSW Design System v3.26.2 | MIT License */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define('NSW', ['exports'], factory) :
@@ -3500,6 +3500,7 @@
3500
3500
  buttonClickDesktop(event) {
3501
3501
  const isDesktop = this.breakpoint.matches;
3502
3502
  if (!isDesktop || !event.target.closest('.nsw-main-nav__sub-nav')) {
3503
+ this.ensureSingleDesktopSubNav(event.currentTarget);
3503
3504
  this.saveElements(event);
3504
3505
  this.toggleSubNavDesktop();
3505
3506
  event.preventDefault();
@@ -3507,11 +3508,28 @@
3507
3508
  }
3508
3509
  buttonKeydownDesktop(event) {
3509
3510
  if (event.key === ' ' || event.key === 'Enter' || event.key === 'Spacebar') {
3511
+ this.ensureSingleDesktopSubNav(event.currentTarget);
3510
3512
  this.saveElements(event);
3511
3513
  this.toggleSubNavDesktop();
3512
3514
  event.preventDefault();
3513
3515
  }
3514
3516
  }
3517
+ ensureSingleDesktopSubNav(currentTarget) {
3518
+ if (!this.breakpoint.matches) return;
3519
+ while (this.openSubNavElements.length > 0) {
3520
+ const {
3521
+ link
3522
+ } = this.whichSubNavLatest();
3523
+ const isExpanded = link.getAttribute('aria-expanded') === 'true';
3524
+ if (!isExpanded) {
3525
+ this.openSubNavElements.pop();
3526
+ } else if (link === currentTarget) {
3527
+ return;
3528
+ } else {
3529
+ this.closeSubNav();
3530
+ }
3531
+ }
3532
+ }
3515
3533
  escapeClose(e) {
3516
3534
  if (e.key === 'Escape') {
3517
3535
  // removes handleOutsideClick functionality from docs site
@@ -3536,6 +3554,11 @@
3536
3554
  link: currentTarget,
3537
3555
  linkParent: currentTarget.parentNode
3538
3556
  };
3557
+ if (this.breakpoint.matches) {
3558
+ this.openSubNavElements = this.openSubNavElements.filter(({
3559
+ link
3560
+ }) => link !== currentTarget);
3561
+ }
3539
3562
  this.openSubNavElements.push(temp);
3540
3563
  }
3541
3564
  showSubNav({
@@ -7571,4 +7594,4 @@
7571
7594
 
7572
7595
  }));
7573
7596
 
7574
- ;(function(g){try{g.NSW=g.NSW||{};g.NSW.VERSION="3.26.1";}catch(e){} }(typeof globalThis!=='undefined'?globalThis:(typeof window!=='undefined'?window:self)));
7597
+ ;(function(g){try{g.NSW=g.NSW||{};g.NSW.VERSION="3.26.2";}catch(e){} }(typeof globalThis!=='undefined'?globalThis:(typeof window!=='undefined'?window:self)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsw-design-system",
3
- "version": "3.26.1",
3
+ "version": "3.26.2",
4
4
  "description": "Design system for Digital NSW",
5
5
  "main": "dist/js/main.js",
6
6
  "types": "dist/js/main.d.ts",
@@ -164,7 +164,9 @@
164
164
  margin: nsw.rem(12px) 0;
165
165
 
166
166
  @include nsw.breakpoint('md') {
167
+ flex: 0 0 auto;
167
168
  text-align: right;
169
+ white-space: nowrap;
168
170
  }
169
171
  }
170
172
 
@@ -96,7 +96,7 @@
96
96
  .nsw-material-icons {
97
97
  transform: rotate(90deg);
98
98
  margin-left: nsw.rem(6px);
99
- transition: transform nsw.$nsw-transition-duration, color nsw.$nsw-transition-duration;
99
+ transition: transform nsw.$nsw-transition-duration-smooth, color nsw.$nsw-transition-duration-smooth;
100
100
  }
101
101
 
102
102
  &.active {
@@ -111,6 +111,12 @@
111
111
  }
112
112
  }
113
113
 
114
+ @include nsw.prefers-reduced-motion() {
115
+ &__list > li > a .nsw-material-icons {
116
+ transition: none;
117
+ }
118
+ }
119
+
114
120
  &__sub-list {
115
121
  list-style: none;
116
122
  padding: 0;
@@ -160,6 +160,7 @@ class Navigation {
160
160
  buttonClickDesktop(event) {
161
161
  const isDesktop = this.breakpoint.matches
162
162
  if (!isDesktop || !event.target.closest('.nsw-main-nav__sub-nav')) {
163
+ this.ensureSingleDesktopSubNav(event.currentTarget)
163
164
  this.saveElements(event)
164
165
  this.toggleSubNavDesktop()
165
166
  event.preventDefault()
@@ -168,12 +169,30 @@ class Navigation {
168
169
 
169
170
  buttonKeydownDesktop(event) {
170
171
  if (event.key === ' ' || event.key === 'Enter' || event.key === 'Spacebar') {
172
+ this.ensureSingleDesktopSubNav(event.currentTarget)
171
173
  this.saveElements(event)
172
174
  this.toggleSubNavDesktop()
173
175
  event.preventDefault()
174
176
  }
175
177
  }
176
178
 
179
+ ensureSingleDesktopSubNav(currentTarget) {
180
+ if (!this.breakpoint.matches) return
181
+
182
+ while (this.openSubNavElements.length > 0) {
183
+ const { link } = this.whichSubNavLatest()
184
+ const isExpanded = link.getAttribute('aria-expanded') === 'true'
185
+
186
+ if (!isExpanded) {
187
+ this.openSubNavElements.pop()
188
+ } else if (link === currentTarget) {
189
+ return
190
+ } else {
191
+ this.closeSubNav()
192
+ }
193
+ }
194
+ }
195
+
177
196
  escapeClose(e) {
178
197
  if (e.key === 'Escape') {
179
198
  // removes handleOutsideClick functionality from docs site
@@ -197,6 +216,10 @@ class Navigation {
197
216
  linkParent: currentTarget.parentNode,
198
217
  }
199
218
 
219
+ if (this.breakpoint.matches) {
220
+ this.openSubNavElements = this.openSubNavElements.filter(({ link }) => link !== currentTarget)
221
+ }
222
+
200
223
  this.openSubNavElements.push(temp)
201
224
  }
202
225
 
@@ -236,6 +236,8 @@ h6,
236
236
  margin: nsw.rem(16px) 0 0 0;
237
237
 
238
238
  @include nsw.font-size('md');
239
+
240
+ line-height: var(--nsw-line-height);
239
241
  }
240
242
 
241
243