@govtechsg/sgds-web-component 3.1.1-rc.1 → 3.1.1-rc.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.
@@ -4557,6 +4557,7 @@
4557
4557
  }
4558
4558
 
4559
4559
  const LG_BREAKPOINT = 1024;
4560
+ const MD_BREAKPOINT = 768;
4560
4561
 
4561
4562
  var Archive = html `
4562
4563
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
@@ -7040,10 +7041,11 @@
7040
7041
  property({ type: String, reflect: true })
7041
7042
  ], SgdsIcon.prototype, "size", void 0);
7042
7043
 
7043
- var css_248z$2 = css`:host{display:block;position:sticky;top:0;z-index:1000}nav{background-color:var(--sgds-surface-default);border-bottom:var(--sgds-border-width-1) solid var(--sgds-border-color-muted);width:100%}.subnav{align-items:flex-start;display:flex;flex-direction:column;flex-wrap:nowrap}.header-container{display:flex;gap:var(--sgds-gap-md);padding:var(--sgds-padding-md) var(--sgds-padding-lg);width:100%}slot[name=header]::slotted(*){--sgds-margin-3-xs:var(--sgds-margin-none);flex:1 1 auto;margin-bottom:var(--sgds-margin-3-xs,--sgds-margin-none);padding-top:var(--sgds-padding-none)}.subnav-toggler{cursor:pointer;transition:transform .2s ease-in-out}.subnav:not(.collapsed) .subnav-toggler{transform:rotate(-180deg)}.subnav-nav-group{display:flex;flex:1 1 0}.subnav-nav,.subnav-nav-group{align-items:flex-start;flex-direction:column;width:100%}.subnav-nav{display:none;overflow-y:auto;transition:transform .2s ease-in-out}.subnav-nav ::slotted(*){width:100%}.subnav-actions{bottom:0;display:flex;flex-direction:column;gap:var(--sgds-gap-md);padding:var(--sgds-padding-md) var(--sgds-padding-lg);position:sticky;width:100%}slot[name=actions]::slotted(*){width:100%}@media screen and (max-width:1023px){.subnav.sgds-container{max-width:inherit}}@media screen and (min-width:1024px){nav{position:inherit}.subnav{flex-direction:row;flex-wrap:wrap;gap:var(--sgds-gap-xl);row-gap:var(--sgds-gap-none)}.header-container{flex:1;padding:var(--sgds-padding-none);width:auto}slot[name=header]::slotted(*){padding-top:var(--sgds-padding-lg);white-space:nowrap}.subnav-nav-group{align-items:center;flex:1;flex-direction:row;gap:var(--sgds-gap-xl);justify-content:space-between}.subnav-nav{align-items:center;display:flex;flex-direction:row;gap:var(--sgds-gap-lg);overflow-y:inherit;transition:none}.subnav-nav ::slotted(*){width:inherit}.subnav-toggler{display:none}.subnav-actions{align-items:center;flex:0;flex-direction:row;padding:var(--sgds-padding-none);position:inherit}slot[name=actions]::slotted(*){width:inherit}}`;
7044
+ var css_248z$2 = css`:host{display:block;position:sticky;top:0;z-index:1000}nav{background-color:var(--sgds-surface-default);border-bottom:var(--sgds-border-width-1) solid var(--sgds-border-color-muted);width:100%}.subnav{align-items:flex-start;display:flex;flex-direction:column;flex-wrap:nowrap}.header-container{display:flex;gap:var(--sgds-gap-md);padding:var(--sgds-padding-md) var(--sgds-padding-lg);width:100%}slot[name=header]::slotted(*){--sgds-margin-3-xs:var(--sgds-margin-none);flex:1 1 auto;margin-bottom:var(--sgds-margin-3-xs,--sgds-margin-none);padding-top:var(--sgds-padding-none)}.subnav-toggler{cursor:pointer;transition:transform .2s ease-in-out}.subnav-toggler:focus,.subnav-toggler:focus-visible{box-shadow:var(--sgds-box-shadow-focus);outline:0}.subnav:not(.collapsed) .subnav-toggler{transform:rotate(-180deg)}.subnav-nav-group{display:flex;flex:1 1 0}.subnav-nav,.subnav-nav-group{align-items:flex-start;flex-direction:column;width:100%}.subnav-nav{display:none;overflow-y:auto;transition:transform .2s ease-in-out}.subnav-nav ::slotted(*){width:100%}.subnav-actions{bottom:0;display:flex;flex-direction:column;gap:var(--sgds-gap-md);padding:var(--sgds-padding-md) var(--sgds-padding-lg);position:sticky;width:100%}slot[name=actions]::slotted(*){width:100%}@media screen and (max-width:1023px){.subnav.sgds-container{max-width:inherit}}@media screen and (min-width:512px){.subnav-actions{flex-direction:row}}@media screen and (min-width:768px){nav{border-bottom:var(--sgds-border-width-0)}.subnav{align-items:center;flex-direction:row}.subnav.collapsed{border-bottom:var(--sgds-border-width-1) solid var(--sgds-border-color-muted)}.header-container{padding:var(--sgds-padding-lg) var(--sgds-padding-2-xl)}.subnav-nav{background-color:var(--sgds-surface-default);border-bottom:var(--sgds-border-width-1) solid var(--sgds-border-color-muted);left:0;position:absolute;top:100%}.subnav-actions{align-items:center;flex-direction:row;padding:var(--sgds-padding-sm) var(--sgds-padding-2-xl) var(--sgds-padding-sm) var(--sgds-padding-none);position:inherit}}@media screen and (min-width:1024px){nav{border-bottom:var(--sgds-border-width-1) solid var(--sgds-border-color-muted);position:inherit}.subnav{align-items:flex-start;flex-wrap:wrap;gap:var(--sgds-gap-xl);row-gap:var(--sgds-gap-none)}.subnav.collapsed{border-bottom:var(--sgds-border-width-0)}.header-container{flex:1;padding:var(--sgds-padding-none);width:auto}slot[name=header]::slotted(*){padding-top:var(--sgds-padding-lg);white-space:nowrap}.subnav-nav-group{align-items:center;flex:1;flex-direction:row;gap:var(--sgds-gap-xl);justify-content:space-between}.subnav-nav{align-items:center;background-color:inherit;border-bottom:var(--sgds-border-width-0);display:flex;flex-direction:row;gap:var(--sgds-gap-lg);overflow-y:inherit;position:inherit;transition:none}.subnav-nav ::slotted(*){width:inherit}.subnav-toggler{display:none}.subnav-actions{padding:var(--sgds-padding-sm) var(--sgds-padding-none)}slot[name=actions]::slotted(*){width:inherit}}`;
7044
7045
 
7045
7046
  var css_248z$1 = css`.sgds-container{margin-left:auto;margin-right:auto;max-width:calc(100% - 40px);width:100%}.sgds-grid{display:grid;gap:var(--sgds-gap-md);grid-template-columns:repeat(4,1fr)}.sgds-col-1{grid-column:span 1}.sgds-col-2{grid-column:span 2}.sgds-col-3{grid-column:span 3}.sgds-col-4{grid-column:span 4}.sgds-col-center-2{grid-column:2/span 2}.sgds-col-none{display:none}@media (min-width:512px){.sgds-grid{grid-template-columns:repeat(8,1fr)}.sgds-container{max-width:calc(100% - 48px)}.sgds-col-sm-1{grid-column:span 1}.sgds-col-sm-2{grid-column:span 2}.sgds-col-sm-3{grid-column:span 3}.sgds-col-sm-4{grid-column:span 4}.sgds-col-sm-5{grid-column:span 5}.sgds-col-sm-6{grid-column:span 6}.sgds-col-sm-7{grid-column:span 7}.sgds-col-sm-8{grid-column:span 8}.sgds-col-sm-center-2{grid-column:4/span 2}.sgds-col-sm-center-4{grid-column:3/span 4}.sgds-col-sm-center-6{grid-column:2/span 6}.sgds-col-none{display:revert}.sgds-col-sm-none{display:none}}@media (min-width:768px){.sgds-container{max-width:calc(100% - 64px)}.sgds-col-md-1{grid-column:span 1}.sgds-col-md-2{grid-column:span 2}.sgds-col-md-3{grid-column:span 3}.sgds-col-md-4{grid-column:span 4}.sgds-col-md-5{grid-column:span 5}.sgds-col-md-6{grid-column:span 6}.sgds-col-md-7{grid-column:span 7}.sgds-col-md-8{grid-column:span 8}.sgds-col-md-center-2{grid-column:4/span 2}.sgds-col-md-center-4{grid-column:3/span 4}.sgds-col-md-center-6{grid-column:2/span 6}.sgds-col-sm-none{display:revert}.sgds-col-md-none{display:none}}@media (min-width:1024px){.sgds-grid{grid-template-columns:repeat(12,1fr)}.sgds-container{max-width:896px}.sgds-col-lg-1{grid-column:span 1}.sgds-col-lg-2{grid-column:span 2}.sgds-col-lg-3{grid-column:span 3}.sgds-col-lg-4{grid-column:span 4}.sgds-col-lg-5{grid-column:span 5}.sgds-col-lg-6{grid-column:span 6}.sgds-col-lg-7{grid-column:span 7}.sgds-col-lg-8{grid-column:span 8}.sgds-col-lg-9{grid-column:span 9}.sgds-col-lg-10{grid-column:span 10}.sgds-col-lg-11{grid-column:span 11}.sgds-col-lg-12{grid-column:span 12}.sgds-col-lg-center-2{grid-column:6/span 2}.sgds-col-lg-center-4{grid-column:5/span 4}.sgds-col-lg-center-6{grid-column:4/span 6}.sgds-col-lg-center-8{grid-column:3/span 8}.sgds-col-lg-center-10{grid-column:2/span 10}.sgds-col-md-none{display:revert}.sgds-col-lg-none{display:none}}@media (min-width:1280px){.sgds-grid{gap:var(--sgds-gap-xl)}.sgds-container{max-width:1176px}.sgds-col-xl-1{grid-column:span 1}.sgds-col-xl-2{grid-column:span 2}.sgds-col-xl-3{grid-column:span 3}.sgds-col-xl-4{grid-column:span 4}.sgds-col-xl-5{grid-column:span 5}.sgds-col-xl-6{grid-column:span 6}.sgds-col-xl-7{grid-column:span 7}.sgds-col-xl-8{grid-column:span 8}.sgds-col-xl-9{grid-column:span 9}.sgds-col-xl-10{grid-column:span 10}.sgds-col-xl-11{grid-column:span 11}.sgds-col-xl-12{grid-column:span 12}.sgds-col-xl-center-2{grid-column:6/span 2}.sgds-col-xl-center-4{grid-column:5/span 4}.sgds-col-xl-center-6{grid-column:4/span 6}.sgds-col-xl-center-8{grid-column:3/span 8}.sgds-col-xl-center-10{grid-column:2/span 10}.sgds-col-lg-none{display:revert}.sgds-col-xl-none{display:none}}@media (min-width:1440px){.sgds-container{max-width:1320px}.sgds-col-2-xl-1{grid-column:span 1}.sgds-col-2-xl-2{grid-column:span 2}.sgds-col-2-xl-3{grid-column:span 3}.sgds-col-2-xl-4{grid-column:span 4}.sgds-col-2-xl-5{grid-column:span 5}.sgds-col-2-xl-6{grid-column:span 6}.sgds-col-2-xl-7{grid-column:span 7}.sgds-col-2-xl-8{grid-column:span 8}.sgds-col-2-xl-9{grid-column:span 9}.sgds-col-2-xl-10{grid-column:span 10}.sgds-col-2-xl-11{grid-column:span 11}.sgds-col-2-xl-12{grid-column:span 12}.sgds-col-2-xl-center-2{grid-column:6/span 2}.sgds-col-2-xl-center-4{grid-column:5/span 4}.sgds-col-2-xl-center-6{grid-column:4/span 6}.sgds-col-2-xl-center-8{grid-column:3/span 8}.sgds-col-2-xl-center-10{grid-column:2/span 10}.sgds-col-xl-none{display:revert}.sgds-col-2-xl-none{display:none}}`;
7046
7047
 
7048
+ const VALID_KEYS = ["Enter", " "];
7047
7049
  /**
7048
7050
  * @summary This component provides secondary navigation within a specific section or page. It typically appears below the main navigation and offers context-specific links or actions to help users explore related content.
7049
7051
  *
@@ -7067,10 +7069,6 @@
7067
7069
  await this.updateComplete;
7068
7070
  if (!this.isCollapsed) {
7069
7071
  this.isMenuOpen = false;
7070
- this.mobileNav.style.display = "flex";
7071
- }
7072
- else {
7073
- this.mobileNav.style.display = "none";
7074
7072
  }
7075
7073
  this._updateMobileLayout();
7076
7074
  };
@@ -7081,10 +7079,11 @@
7081
7079
  const { top: subnavTop } = this.nav.getBoundingClientRect();
7082
7080
  const headerHeight = this.headerContainer.clientHeight;
7083
7081
  const actionsButtonHeight = this.mobileActions.clientHeight;
7084
- const offset = subnavTop + headerHeight + actionsButtonHeight;
7085
- const subnavHeight = this.headerContainer.clientHeight + actionsButtonHeight;
7082
+ const offset = window.innerWidth >= MD_BREAKPOINT && window.innerWidth < LG_BREAKPOINT
7083
+ ? subnavTop + headerHeight
7084
+ : subnavTop + headerHeight + actionsButtonHeight;
7086
7085
  this.mobileNav.style.maxHeight = `calc(100dvh - ${offset}px)`;
7087
- this.style.minHeight = `${subnavHeight}px`;
7086
+ this.style.minHeight = `${this.nav.clientHeight}px`;
7088
7087
  this.nav.style.position = "absolute";
7089
7088
  }
7090
7089
  else {
@@ -7124,6 +7123,12 @@
7124
7123
  this.hide();
7125
7124
  }
7126
7125
  }
7126
+ async _onKeyboardToggle(event) {
7127
+ if (!VALID_KEYS.includes(event.key))
7128
+ return;
7129
+ event.preventDefault();
7130
+ this._toggleMenu();
7131
+ }
7127
7132
  /** Shows the menu. For when subnav is in the collapsed form */
7128
7133
  async show() {
7129
7134
  if (this.isMenuOpen) {
@@ -7148,7 +7153,9 @@
7148
7153
  return;
7149
7154
  }
7150
7155
  await stopAnimations(this.mobileNav);
7151
- this.mobileNav.style.display = "flex";
7156
+ if (this.isCollapsed) {
7157
+ this.mobileNav.style.display = "flex";
7158
+ }
7152
7159
  const { keyframes, options } = getAnimation(this, "subnav.show");
7153
7160
  await animateTo(this.mobileNav, shimKeyframesHeightAuto(keyframes, this.mobileNav.scrollHeight), options);
7154
7161
  this.emit("sgds-after-show");
@@ -7162,7 +7169,9 @@
7162
7169
  await stopAnimations(this.mobileNav);
7163
7170
  const { keyframes, options } = getAnimation(this, "subnav.hide");
7164
7171
  await animateTo(this.mobileNav, shimKeyframesHeightAuto(keyframes, this.mobileNav.scrollHeight), options);
7165
- this.mobileNav.style.display = "none";
7172
+ if (this.isCollapsed) {
7173
+ this.mobileNav.style.display = "none";
7174
+ }
7166
7175
  this.emit("sgds-after-hide");
7167
7176
  }
7168
7177
  async handleOpenChange() {
@@ -7175,12 +7184,16 @@
7175
7184
  this._animateToHide();
7176
7185
  }
7177
7186
  }
7187
+ async handleCollapsedChange() {
7188
+ await this.updateComplete;
7189
+ this.mobileNav.style.display = this.isCollapsed ? "none" : "flex";
7190
+ }
7178
7191
  render() {
7179
7192
  return html `
7180
7193
  <nav aria-label="Sub navigation">
7181
7194
  <div
7182
7195
  class=${classMap({
7183
- "sgds-container": !this.isCollapsed,
7196
+ "sgds-container": true,
7184
7197
  subnav: true,
7185
7198
  collapsed: !this.isMenuOpen
7186
7199
  })}
@@ -7190,8 +7203,11 @@
7190
7203
  <sgds-icon
7191
7204
  class="subnav-toggler"
7192
7205
  name="chevron-down"
7206
+ tabindex="0"
7193
7207
  @click=${this._toggleMenu}
7208
+ @keydown=${this._onKeyboardToggle}
7194
7209
  aria-label="Toggle sub navigation"
7210
+ aria-expanded=${this.isMenuOpen}
7195
7211
  ></sgds-icon>
7196
7212
  </div>
7197
7213
  <div class="subnav-nav-group">
@@ -7239,6 +7255,9 @@
7239
7255
  __decorate([
7240
7256
  watch("isMenuOpen", { waitUntilFirstUpdate: true })
7241
7257
  ], SgdsSubnav.prototype, "handleOpenChange", null);
7258
+ __decorate([
7259
+ watch("isCollapsed", { waitUntilFirstUpdate: true })
7260
+ ], SgdsSubnav.prototype, "handleCollapsedChange", null);
7242
7261
  setDefaultAnimation("subnav.show", {
7243
7262
  keyframes: [
7244
7263
  { height: "0", opacity: "0" },