scb-wc 0.1.252 → 0.1.254

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.
@@ -1,22 +1,33 @@
1
- import{f as v,h as y,m as f,p as l,v as _,y as w}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as a}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import{closeManualPopover as x,openManualPopover as S}from"../shared/manual-popover.js";import{ScbTourStepElement as k}from"./scb-tour-step.js";(function(){try{var u=typeof globalThis<"u"?globalThis:window;if(!u.__scb_ce_guard_installed__){u.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,o,s){try{customElements.get(e)||t(e,o,s)}catch(i){var n=String(i||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();var p,g={fromAttribute:u=>u!==null&&u!=="false",toAttribute:u=>u?"":null},r=(p=class extends y{constructor(...t){super(...t),this.variant="standard",this.open=!1,this.autoStart=!1,this.storageKey="",this.step=0,this.closeLabel="Stäng guiden",this.previousLabel="Föregående",this.nextLabel="Nästa",this.doneLabel="Klart",this.stepLabel="{current} av {total}",this._steps=[],this._stepObserver=new MutationObserver(()=>this._readSteps()),this._autoStartAttempted=!1,this._startRequest=0,this._shownStorageKey="",this._operation=0,this._frame=0,this._scrollRoots=[],this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._startOnLoad=async()=>{if(!this.isConnected||document.readyState!=="complete"||!this.autoStart||this.open||this._autoStartAttempted)return;this._autoStartAttempted=!0;const e=this._startRequest,o=this.storageKey;try{if(o&&localStorage.getItem(o)==="seen")return}catch{}await this.updateComplete;const s=this._findTarget(this._steps[0]?.target);s?.localName.includes("-")&&(await customElements.whenDefined(s.localName),await s.updateComplete),this.isConnected&&this.autoStart&&!this.open&&e===this._startRequest&&o===this.storageKey&&this.start()},this._schedulePosition=()=>{cancelAnimationFrame(this._frame),this._frame=requestAnimationFrame(()=>this._position())},this._onResize=()=>{this._target?.scrollIntoView({block:"center",inline:"nearest",behavior:"instant"}),this._schedulePosition()},this._next=()=>{this.step>=this._steps.length-1?this._close("complete"):this.step++},this._onKeydown=e=>{e.key!=="Escape"||!this.open||(e.preventDefault(),e.stopPropagation(),this.close())}}connectedCallback(){super.connectedCallback(),this._readSteps(),this._stepObserver.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["target","heading"]}),document.readyState!=="complete"&&window.addEventListener("load",this._startOnLoad,{once:!0})}disconnectedCallback(){this._startRequest++,this._stepObserver.disconnect(),window.removeEventListener("load",this._startOnLoad),this._hide(),super.disconnectedCallback()}updated(t){this.open&&t.has("open")&&(this._autoStartAttempted=!0,this._startRequest++),this.open?(t.has("open")||t.has("step")||t.has("_steps"))&&this._showStep():this._hide(),this._startOnLoad()}_readSteps(){this._steps=Array.from(this.children).filter(t=>t instanceof k).map(t=>({target:t.target,heading:t.heading,content:(t.textContent??"").replace(/\s+/g," ").trim()}))}_findTarget(t){if(!t)return null;try{const e=this.querySelector(t)??this.getRootNode().querySelector(t);return e instanceof HTMLElement?e:null}catch{return null}}start(){this._autoStartAttempted=!0,this._startRequest++,this.step=0,this.open=!0}close(){this._autoStartAttempted=!0,this._startRequest++,this._close("dismiss")}_close(t){if(this.open){if(this._shownStorageKey&&t!=="target-unavailable")try{localStorage.setItem(this._shownStorageKey,"seen")}catch{}this.open=!1,this._hide(),this.dispatchEvent(new CustomEvent("close",{detail:{reason:t,step:this.step},bubbles:!0,composed:!0}))}}_hide(){this._operation++,cancelAnimationFrame(this._frame),this._resizeObserver.disconnect(),window.removeEventListener("resize",this._onResize),window.removeEventListener("scroll",this._schedulePosition,!0),this._scrollRoots.forEach(o=>o.removeEventListener("scroll",this._schedulePosition,!0)),this._scrollRoots=[];const t=this.shadowRoot?.querySelector(".surface"),e=t?.contains(this.shadowRoot?.activeElement??null);x(t),e&&this._returnFocus?.isConnected&&this._returnFocus.focus({preventScroll:!0}),this._returnFocus=void 0,this._target=void 0,this._shownStorageKey=""}async _showStep(){const t=++this._operation;if(await this.updateComplete,!this.open||t!==this._operation)return;const e=Math.max(0,Math.min(this._steps.length-1,Math.trunc(this.step)||0));if(this.step!==e){this.step=e;return}const o=this._steps[e],s=this._findTarget(o?.target);if(!s||!this._isVisible(s)){this._close("target-unavailable");return}const n=this.shadowRoot.querySelector(".surface");if(!n.matches(":popover-open")){this._shownStorageKey=this.storageKey;let c=document.activeElement;for(;c?.shadowRoot?.activeElement;)c=c.shadowRoot.activeElement;c instanceof HTMLElement&&(this._returnFocus=c)}this._target=s;const i=s.getBoundingClientRect();if((i.top<0||i.bottom>innerHeight||i.left<0||i.right>innerWidth)&&s.scrollIntoView({block:"center",inline:"nearest",behavior:"instant"}),!S(n,s)){this._close("target-unavailable");return}this._resizeObserver.disconnect(),this._resizeObserver.observe(s),this._resizeObserver.observe(n),window.addEventListener("resize",this._onResize),window.addEventListener("scroll",this._schedulePosition,!0),this._scrollRoots.forEach(c=>c.removeEventListener("scroll",this._schedulePosition,!0)),this._scrollRoots=[];let d=s.getRootNode();for(;d instanceof ShadowRoot;)d.addEventListener("scroll",this._schedulePosition,!0),this._scrollRoots.push(d),d=d.host.getRootNode();this._position(),n.focus({preventScroll:!0}),this.dispatchEvent(new CustomEvent("stepchange",{detail:{step:e,total:this._steps.length},bubbles:!0,composed:!0}))}_isVisible(t){const e=getComputedStyle(t),o=t.getBoundingClientRect();return t.isConnected&&e.visibility!=="hidden"&&o.width>0&&o.height>0}_position(){const t=this._target,e=this.shadowRoot?.querySelector(".surface");if(!this.open||!e||!t)return;if(!this._isVisible(t)){this._close("target-unavailable");return}const o=getComputedStyle(this),s=Number.parseFloat(o.getPropertyValue("--spacing-4"))||12,n=Number.parseFloat(o.getPropertyValue("--scb-tour-design-anchor-gap-medium"))||12,i=t.getBoundingClientRect(),d=e.getBoundingClientRect(),c=innerHeight-i.bottom-n,b=i.top-n,h=c>=d.height+s||c>=b?"bottom":"top";e.style.setProperty("--available-height",`calc(${Math.max(0,(h==="bottom"?innerHeight-i.bottom:i.top)-s)}px - var(--scb-tour-design-anchor-gap-medium))`);const m=Math.max(s,Math.min(i.left+i.width/2-d.width/2,innerWidth-d.width-s));e.style.left=`${m}px`,e.style.top=h==="bottom"?`calc(${i.bottom}px + var(--scb-tour-design-anchor-gap-medium))`:`calc(${i.top}px - var(--scb-tour-design-anchor-gap-medium))`,e.dataset.side=h,e.style.setProperty("--anchor-x",`${i.left+i.width/2-m}px`)}render(){const t=this._steps[this.step],e=this.stepLabel.replace("{current}",String(this.step+1)).replace("{total}",String(this._steps.length));return _`
1
+ import{f,h as _,m as w,p as n,v as x,y as k}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as a}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import{closeManualPopover as S,openManualPopover as z}from"../shared/manual-popover.js";import{ScbTourStepElement as R}from"./scb-tour-step.js";(function(){try{var l=typeof globalThis<"u"?globalThis:window;if(!l.__scb_ce_guard_installed__){l.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,o,s){try{customElements.get(e)||t(e,o,s)}catch(i){var d=String(i||"");if(d.indexOf("already been used")===-1&&d.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();var m,b,v={fromAttribute:l=>l!==null&&l!=="false",toAttribute:l=>l?"":null},r=(m=class extends _{constructor(...t){super(...t),this.variant="standard",this.spotlight=!1,this.open=!1,this.autoStart=!1,this.storageKey="",this.step=0,this.closeLabel="Stäng guiden",this.previousLabel="Föregående",this.nextLabel="Nästa",this.doneLabel="Klart",this.stepLabel="{current} av {total}",this._steps=[],this._stepObserver=new MutationObserver(()=>this._readSteps()),this._autoStartAttempted=!1,this._startRequest=0,this._shownStorageKey="",this._spotlightId=`scb-tour-spotlight-${b._nextId++}`,this._operation=0,this._frame=0,this._scrollRoots=[],this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._startOnLoad=async()=>{if(!this.isConnected||document.readyState!=="complete"||!this.autoStart||this.open||this._autoStartAttempted)return;this._autoStartAttempted=!0;const e=this._startRequest,o=this.storageKey;try{if(o&&localStorage.getItem(o)==="seen")return}catch{}await this.updateComplete;const s=this._findTarget(this._steps[0]?.target);s?.localName.includes("-")&&(await customElements.whenDefined(s.localName),await s.updateComplete),this.isConnected&&this.autoStart&&!this.open&&e===this._startRequest&&o===this.storageKey&&this.start()},this._schedulePosition=e=>{e&&this.shadowRoot?.querySelector(".layer")?.removeAttribute("data-moving"),cancelAnimationFrame(this._frame),this._frame=requestAnimationFrame(()=>this._position())},this._onResize=e=>{this._target?.scrollIntoView({block:"center",inline:"nearest",behavior:"instant"}),this._schedulePosition(e)},this._next=()=>{this.step>=this._steps.length-1?this._close("complete"):this.step++},this._onKeydown=e=>{e.key!=="Escape"||!this.open||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),this.close())}}connectedCallback(){super.connectedCallback(),this._readSteps(),this._stepObserver.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["target","heading"]}),document.readyState!=="complete"&&window.addEventListener("load",this._startOnLoad,{once:!0})}disconnectedCallback(){this._startRequest++,this._stepObserver.disconnect(),window.removeEventListener("load",this._startOnLoad),this._hide(),super.disconnectedCallback()}updated(t){this.open&&t.has("open")&&(this._autoStartAttempted=!0,this._startRequest++),this.open?t.has("open")||t.has("step")||t.has("_steps")?this._showStep():t.has("spotlight")&&this._position():this._hide(),this._startOnLoad()}_readSteps(){this._steps=Array.from(this.children).filter(t=>t instanceof R).map(t=>({target:t.target,heading:t.heading,content:(t.textContent??"").replace(/\s+/g," ").trim()}))}_findTarget(t){if(!t)return null;try{const e=this.querySelector(t)??this.getRootNode().querySelector(t);return e instanceof HTMLElement?e:null}catch{return null}}start(){this._autoStartAttempted=!0,this._startRequest++,this.step=0,this.open=!0}close(){this._autoStartAttempted=!0,this._startRequest++,this._close("dismiss")}_close(t){if(this.open){if(this._shownStorageKey&&t!=="target-unavailable")try{localStorage.setItem(this._shownStorageKey,"seen")}catch{}this.open=!1,this._hide(),this.dispatchEvent(new CustomEvent("close",{detail:{reason:t,step:this.step},bubbles:!0,composed:!0}))}}_hide(){this._operation++,cancelAnimationFrame(this._frame),this._resizeObserver.disconnect(),window.removeEventListener("resize",this._onResize),window.removeEventListener("keydown",this._onKeydown),window.removeEventListener("scroll",this._schedulePosition,!0),this._scrollRoots.forEach(o=>o.removeEventListener("scroll",this._schedulePosition,!0)),this._scrollRoots=[];const t=this.shadowRoot?.querySelector(".surface")?.contains(this.shadowRoot?.activeElement??null),e=this.shadowRoot?.querySelector(".layer");S(e),e?.removeAttribute("data-moving"),t&&this._returnFocus?.isConnected&&this._returnFocus.focus({preventScroll:!0}),this._returnFocus=void 0,this._target=void 0,this._spotlightTarget=void 0,this._shownStorageKey=""}async _showStep(){const t=++this._operation;if(await this.updateComplete,!this.open||t!==this._operation)return;const e=Math.max(0,Math.min(this._steps.length-1,Math.trunc(this.step)||0));if(this.step!==e){this.step=e;return}const o=this._steps[e],s=this._findTarget(o?.target);if(!s||!this._isVisible(s)){this._close("target-unavailable");return}const d=this.shadowRoot.querySelector(".surface"),i=this.shadowRoot.querySelector(".layer");if(!i.matches(":popover-open")){this._shownStorageKey=this.storageKey;let c=document.activeElement;for(;c?.shadowRoot?.activeElement;)c=c.shadowRoot.activeElement;c instanceof HTMLElement&&(this._returnFocus=c)}this._target=s;const h=s.getBoundingClientRect();if((h.top<0||h.bottom>innerHeight||h.left<0||h.right>innerWidth)&&s.scrollIntoView({block:"center",inline:"nearest",behavior:"instant"}),!z(i,s)){this._close("target-unavailable");return}this._resizeObserver.disconnect(),this._resizeObserver.observe(s),this._resizeObserver.observe(d),window.addEventListener("resize",this._onResize),window.addEventListener("scroll",this._schedulePosition,!0),this._scrollRoots.forEach(c=>c.removeEventListener("scroll",this._schedulePosition,!0)),this._scrollRoots=[];let p=s.getRootNode();for(;p instanceof ShadowRoot;)p.addEventListener("scroll",this._schedulePosition,!0),this._scrollRoots.push(p),p=p.host.getRootNode();this._position(),d.focus({preventScroll:!0}),this.dispatchEvent(new CustomEvent("stepchange",{detail:{step:e,total:this._steps.length},bubbles:!0,composed:!0}))}_isVisible(t){const e=getComputedStyle(t),o=t.getBoundingClientRect();return t.isConnected&&e.visibility!=="hidden"&&o.width>0&&o.height>0}_position(){const t=this._target,e=this.shadowRoot?.querySelector(".surface");if(!this.open||!e||!t)return;if(!this._isVisible(t)){this._close("target-unavailable");return}const o=getComputedStyle(this),s=Number.parseFloat(o.getPropertyValue("--spacing-4"))||12,d=Number.parseFloat(o.getPropertyValue("--scb-tour-design-anchor-gap-medium"))||12,i=t.getBoundingClientRect();if(this.spotlight){window.addEventListener("keydown",this._onKeydown);const u=this.shadowRoot.querySelector(".layer");this._spotlightTarget!==t&&(u.toggleAttribute("data-moving",!!this._spotlightTarget),this._spotlightTarget=t),u.style.setProperty("--_spotlight-left",`${i.left}px`),u.style.setProperty("--_spotlight-top",`${i.top}px`),u.style.setProperty("--_spotlight-width",`${i.width}px`),u.style.setProperty("--_spotlight-height",`${i.height}px`)}else window.removeEventListener("keydown",this._onKeydown),this._spotlightTarget=void 0;const h=e.getBoundingClientRect(),p=innerHeight-i.bottom-d,c=i.top-d,g=p>=h.height+s||p>=c?"bottom":"top";e.style.setProperty("--available-height",`calc(${Math.max(0,(g==="bottom"?innerHeight-i.bottom:i.top)-s)}px - var(--scb-tour-design-anchor-gap-medium))`);const y=Math.max(s,Math.min(i.left+i.width/2-h.width/2,innerWidth-h.width-s));e.style.left=`${y}px`,e.style.top=g==="bottom"?`calc(${i.bottom}px + var(--scb-tour-design-anchor-gap-medium))`:`calc(${i.top}px - var(--scb-tour-design-anchor-gap-medium))`,e.dataset.side=g,e.style.setProperty("--anchor-x",`${i.left+i.width/2-y}px`)}render(){const t=this._steps[this.step],e=this.stepLabel.replace("{current}",String(this.step+1)).replace("{total}",String(this._steps.length));return x`
2
2
  <slot name="trigger" @click=${o=>{o.defaultPrevented||this.start()}}></slot>
3
3
  <slot></slot>
4
- <section class="surface" part="surface" popover="manual" role="dialog" tabindex="-1"
5
- aria-labelledby="heading" aria-describedby="content counter" @keydown=${this._onKeydown}>
6
- <span class="arrow" part="arrow" aria-hidden="true"></span>
7
- <div class="body">
8
- <div class="header">
9
- <h2 id="heading">${t?.heading}</h2>
10
- <scb-icon-button size="small" icon="close" aria-label=${this.closeLabel} @click=${this.close}></scb-icon-button>
11
- </div>
12
- <p id="content">${t?.content}</p>
13
- <div class="footer">
14
- <span id="counter" class="counter">${e}</span>
15
- <div class="actions">
16
- <scb-button variant="text" size="small" .label=${this.previousLabel} ?disabled=${this.step<=0} @click=${()=>this.step--}></scb-button>
17
- <scb-button size="small" .label=${this.step===this._steps.length-1?this.doneLabel:this.nextLabel} @click=${this._next}></scb-button>
4
+ <div class="layer" popover="manual">
5
+ <svg class="spotlight" aria-hidden="true" focusable="false">
6
+ <defs>
7
+ <mask id=${this._spotlightId} maskUnits="userSpaceOnUse" x="0" y="0" width="100%" height="100%">
8
+ <rect width="100%" height="100%" fill="white"></rect>
9
+ <rect class="spotlight-hole" fill="black"></rect>
10
+ </mask>
11
+ </defs>
12
+ <rect class="spotlight-scrim" width="100%" height="100%" mask=${`url(#${this._spotlightId})`}></rect>
13
+ </svg>
14
+ <section class="surface" part="surface" role="dialog" tabindex="-1"
15
+ aria-labelledby="heading" aria-describedby="content counter" @keydown=${this._onKeydown}>
16
+ <span class="arrow" part="arrow" aria-hidden="true"></span>
17
+ <div class="body">
18
+ <div class="header">
19
+ <h2 id="heading">${t?.heading}</h2>
20
+ <scb-icon-button size="small" icon="close" aria-label=${this.closeLabel} @click=${this.close}></scb-icon-button>
21
+ </div>
22
+ <p id="content">${t?.content}</p>
23
+ <div class="footer">
24
+ <span id="counter" class="counter">${e}</span>
25
+ <div class="actions">
26
+ <scb-button variant="text" size="small" .label=${this.previousLabel} ?disabled=${this.step<=0} @click=${()=>this.step--}></scb-button>
27
+ <scb-button size="small" .label=${this.step===this._steps.length-1?this.doneLabel:this.nextLabel} @click=${this._next}></scb-button>
28
+ </div>
18
29
  </div>
19
30
  </div>
20
- </div>
21
- </section>
22
- `}},p.styles=w`:host{display:block}.surface{display:none;position:fixed;box-sizing:border-box;margin:0;inset:auto;border:0;inline-size:min(360px,calc(100vw - 2*var(--spacing-4, 12px)));max-block-size:min(var(--available-height, 100vh),calc(100vh - 2*var(--spacing-4, 12px)));padding:var(--scb-tour-design-padding-medium);border-radius:var(--scb-tour-design-radius-medium);background:var(--scb-tour-surface-color, var(--md-sys-color-surface-container));color:var(--scb-tour-content-color, var(--md-sys-color-on-surface));box-shadow:var(--scb-tour-design-shadow-medium);overflow:visible;outline:0;font-family:var(--scb-tour-design-supporting-medium-font);font-size:var(--scb-tour-design-supporting-medium-size);line-height:var(--scb-tour-design-supporting-medium-line-height);font-weight:var(--scb-tour-design-supporting-medium-weight);letter-spacing:var(--scb-tour-design-supporting-medium-tracking)}.surface:popover-open{display:block}:host([variant='inverse']) .surface{background:var(--scb-tour-surface-color, var(--md-sys-color-on-info-container));color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--scb-button-low-emphasis-content-color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--scb-button-filled-container-color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--scb-button-filled-content-color:var(--scb-tour-surface-color, var(--md-sys-color-on-info-container));--scb-button-disabled-content-color:color-mix(in srgb, var(--scb-tour-content-color, var(--md-sys-color-info-container)) calc(100% * var(--md-sys-state-disabled-state-layer-opacity, 0.38)), transparent);--md-icon-button-icon-color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--md-focus-ring-color:var(--scb-tour-content-color, var(--md-sys-color-info-container))}.body,.footer,.header{gap:var(--scb-tour-design-gap-medium)}.body{display:grid;max-block-size:calc(min(var(--available-height, 100vh),100vh - 2*var(--spacing-4, 12px)) - 2*var(--scb-tour-design-padding-medium));overflow:auto;overflow-wrap:anywhere}.footer,.header{display:flex;align-items:start}h2{flex:1;font-family:var(--scb-tour-design-title-medium-font);font-size:var(--scb-tour-design-title-medium-size);line-height:var(--scb-tour-design-title-medium-line-height);font-weight:var(--scb-tour-design-title-medium-weight);letter-spacing:var(--scb-tour-design-title-medium-tracking)}h2,p{margin:0}.footer{align-items:center;flex-wrap:wrap}.counter{margin-inline-end:auto}.actions{display:flex;flex-wrap:wrap;gap:var(--scb-tour-design-gap-medium)}.arrow{position:absolute;left:clamp(var(--scb-tour-design-arrow-size-medium),calc(var(--anchor-x) - var(--scb-tour-design-arrow-size-medium)),calc(100% - 3*var(--scb-tour-design-arrow-size-medium)));top:calc(-1*var(--scb-tour-design-arrow-size-medium));inline-size:calc(2*var(--scb-tour-design-arrow-size-medium));block-size:var(--scb-tour-design-arrow-size-medium);background:inherit;clip-path:polygon(50%0,100% 100%,0 100%);pointer-events:none}.surface[data-side=top]{translate:0-100%}.surface[data-side=top] .arrow{top:100%;transform:rotate(180deg)}:host{--scb-tour-design-padding-medium:var(--spacing-5, 16px);--scb-tour-design-gap-medium:var(--spacing-4, 12px);--scb-tour-design-radius-medium:var(--radius-medium, 12px);--scb-tour-design-anchor-gap-medium:var(--spacing-4, 12px);--scb-tour-design-arrow-size-medium:var(--spacing-3, 8px);--scb-tour-design-title-medium-font:var(--scb-typography-title-medium-font, var(--md-sys-typescale-title-medium-font, var(--brand)));--scb-tour-design-title-medium-size:var(--scb-typography-title-medium-size, var(--md-sys-typescale-title-medium-size, 18px));--scb-tour-design-title-medium-line-height:var(--scb-typography-title-medium-line-height, var(--md-sys-typescale-title-medium-line-height, 26px));--scb-tour-design-title-medium-tracking:var(--scb-typography-title-medium-tracking, var(--md-sys-typescale-title-medium-tracking, var(--tracking-05, -0.3px)));--scb-tour-design-title-medium-weight:var(--scb-typography-title-medium-weight, var(--md-sys-typescale-title-medium-weight, var(--weight-semibold, 600)));--scb-tour-design-title-medium-letter-spacing:var(--scb-typography-title-medium-letter-spacing, var(--scb-typography-title-medium-tracking, var(--md-sys-typescale-title-medium-tracking, var(--tracking-05, -0.3px))));--scb-tour-design-title-medium-font-weight:var(--scb-typography-title-medium-font-weight, var(--scb-typography-title-medium-weight, var(--md-sys-typescale-title-medium-weight, var(--weight-semibold, 600))));--scb-tour-design-supporting-medium-font:var(--scb-typography-body-medium-font, var(--md-sys-typescale-body-medium-font, var(--brand)));--scb-tour-design-supporting-medium-size:var(--scb-typography-body-medium-size, var(--md-sys-typescale-body-medium-size, 16px));--scb-tour-design-supporting-medium-line-height:var(--scb-typography-body-medium-line-height, var(--md-sys-typescale-body-medium-line-height, 24px));--scb-tour-design-supporting-medium-tracking:var(--scb-typography-body-medium-tracking, var(--md-sys-typescale-body-medium-tracking, var(--tracking-03, -0.15px)));--scb-tour-design-supporting-medium-weight:var(--scb-typography-body-medium-weight, var(--md-sys-typescale-body-medium-weight, var(--weight-regular, 400)));--scb-tour-design-supporting-medium-letter-spacing:var(--scb-typography-body-medium-letter-spacing, var(--scb-typography-body-medium-tracking, var(--md-sys-typescale-body-medium-tracking, var(--tracking-03, -0.15px))));--scb-tour-design-supporting-medium-font-weight:var(--scb-typography-body-medium-font-weight, var(--scb-typography-body-medium-weight, var(--md-sys-typescale-body-medium-weight, var(--weight-regular, 400))))}`,p);a([l({type:String,reflect:!0})],r.prototype,"variant",void 0);a([l({type:Boolean,reflect:!0,converter:g})],r.prototype,"open",void 0);a([l({type:Boolean,attribute:"auto-start",converter:g})],r.prototype,"autoStart",void 0);a([l({type:String,attribute:"storage-key"})],r.prototype,"storageKey",void 0);a([l({type:Number,reflect:!0})],r.prototype,"step",void 0);a([l({attribute:"close-label"})],r.prototype,"closeLabel",void 0);a([l({attribute:"previous-label"})],r.prototype,"previousLabel",void 0);a([l({attribute:"next-label"})],r.prototype,"nextLabel",void 0);a([l({attribute:"done-label"})],r.prototype,"doneLabel",void 0);a([l({attribute:"step-label"})],r.prototype,"stepLabel",void 0);a([v()],r.prototype,"_steps",void 0);r=a([f("scb-tour")],r);
31
+ </section>
32
+ </div>
33
+ `}},b=m,m._nextId=0,m.styles=k`@keyframes scb-kf-fade-in{0%{opacity:0}to{opacity:1}}:host{display:block}.layer{display:none;position:fixed;inset:0;margin:0;padding:0;border:0;inline-size:100%;block-size:100%;max-inline-size:none;max-block-size:none;overflow:visible;background:0 0;pointer-events:none}.layer:popover-open{display:block}.layer::backdrop{background:0 0;pointer-events:none}:host([spotlight]) .layer:popover-open{animation:scb-kf-fade-in var(--scb-motion-duration-short, 200ms) var(--scb-motion-easing-standard, ease)}.spotlight{display:none;position:fixed;inset:0;inline-size:100%;block-size:100%}:host([spotlight]) .spotlight{display:block}.spotlight-hole{x:calc(var(--_spotlight-left) - var(--spacing-3, 8px));y:calc(var(--_spotlight-top) - var(--spacing-3, 8px));width:calc(var(--_spotlight-width) + 2*var(--spacing-3, 8px));height:calc(var(--_spotlight-height) + 2*var(--spacing-3, 8px));rx:var(--radius-medium, 12px)}.layer[data-moving] .spotlight-hole{transition-property:x,y,width,height;transition-duration:var(--scb-motion-duration-short, 200ms);transition-timing-function:var(--scb-motion-easing-standard, ease)}.spotlight-scrim{fill:var(--scb-tour-spotlight-color, color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent))}@media (prefers-reduced-motion:reduce){:host([spotlight]) .layer:popover-open{animation:none}.layer[data-moving] .spotlight-hole{transition:none}}.surface{position:fixed;pointer-events:auto;box-sizing:border-box;margin:0;inset:auto;border:0;inline-size:min(360px,calc(100vw - 2*var(--spacing-4, 12px)));max-block-size:min(var(--available-height, 100vh),calc(100vh - 2*var(--spacing-4, 12px)));padding:var(--scb-tour-design-padding-medium);border-radius:var(--scb-tour-design-radius-medium);background:var(--scb-tour-surface-color, var(--md-sys-color-surface-container));color:var(--scb-tour-content-color, var(--md-sys-color-on-surface));box-shadow:var(--scb-tour-design-shadow-medium);overflow:visible;outline:0;font-family:var(--scb-tour-design-supporting-medium-font);font-size:var(--scb-tour-design-supporting-medium-size);line-height:var(--scb-tour-design-supporting-medium-line-height);font-weight:var(--scb-tour-design-supporting-medium-weight);letter-spacing:var(--scb-tour-design-supporting-medium-tracking)}:host([variant='inverse']) .surface{background:var(--scb-tour-surface-color, var(--md-sys-color-on-info-container));color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--scb-button-low-emphasis-content-color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--scb-button-filled-container-color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--scb-button-filled-content-color:var(--scb-tour-surface-color, var(--md-sys-color-on-info-container));--scb-button-disabled-content-color:color-mix(in srgb, var(--scb-tour-content-color, var(--md-sys-color-info-container)) calc(100% * var(--md-sys-state-disabled-state-layer-opacity, 0.38)), transparent);--md-icon-button-icon-color:var(--scb-tour-content-color, var(--md-sys-color-info-container));--md-focus-ring-color:var(--scb-tour-content-color, var(--md-sys-color-info-container))}.body,.footer,.header{gap:var(--scb-tour-design-gap-medium)}.body{display:grid;max-block-size:calc(min(var(--available-height, 100vh),100vh - 2*var(--spacing-4, 12px)) - 2*var(--scb-tour-design-padding-medium));overflow:auto;overflow-wrap:anywhere}.footer,.header{display:flex;align-items:start}h2{flex:1;font-family:var(--scb-tour-design-title-medium-font);font-size:var(--scb-tour-design-title-medium-size);line-height:var(--scb-tour-design-title-medium-line-height);font-weight:var(--scb-tour-design-title-medium-weight);letter-spacing:var(--scb-tour-design-title-medium-tracking)}h2,p{margin:0}.footer{align-items:center;flex-wrap:wrap}.counter{margin-inline-end:auto}.actions{display:flex;flex-wrap:wrap;gap:var(--scb-tour-design-gap-medium)}.arrow{position:absolute;left:clamp(var(--scb-tour-design-arrow-size-medium),calc(var(--anchor-x) - var(--scb-tour-design-arrow-size-medium)),calc(100% - 3*var(--scb-tour-design-arrow-size-medium)));top:calc(-1*var(--scb-tour-design-arrow-size-medium));inline-size:calc(2*var(--scb-tour-design-arrow-size-medium));block-size:var(--scb-tour-design-arrow-size-medium);background:inherit;clip-path:polygon(50%0,100% 100%,0 100%);pointer-events:none}.surface[data-side=top]{translate:0-100%}.surface[data-side=top] .arrow{top:100%;transform:rotate(180deg)}:host{--scb-tour-design-padding-medium:var(--spacing-5, 16px);--scb-tour-design-gap-medium:var(--spacing-4, 12px);--scb-tour-design-radius-medium:var(--radius-medium, 12px);--scb-tour-design-anchor-gap-medium:var(--spacing-4, 12px);--scb-tour-design-arrow-size-medium:var(--spacing-3, 8px);--scb-tour-design-title-medium-font:var(--scb-typography-title-medium-font, var(--md-sys-typescale-title-medium-font, var(--brand)));--scb-tour-design-title-medium-size:var(--scb-typography-title-medium-size, var(--md-sys-typescale-title-medium-size, 18px));--scb-tour-design-title-medium-line-height:var(--scb-typography-title-medium-line-height, var(--md-sys-typescale-title-medium-line-height, 26px));--scb-tour-design-title-medium-tracking:var(--scb-typography-title-medium-tracking, var(--md-sys-typescale-title-medium-tracking, var(--tracking-05, -0.3px)));--scb-tour-design-title-medium-weight:var(--scb-typography-title-medium-weight, var(--md-sys-typescale-title-medium-weight, var(--weight-semibold, 600)));--scb-tour-design-title-medium-letter-spacing:var(--scb-typography-title-medium-letter-spacing, var(--scb-typography-title-medium-tracking, var(--md-sys-typescale-title-medium-tracking, var(--tracking-05, -0.3px))));--scb-tour-design-title-medium-font-weight:var(--scb-typography-title-medium-font-weight, var(--scb-typography-title-medium-weight, var(--md-sys-typescale-title-medium-weight, var(--weight-semibold, 600))));--scb-tour-design-supporting-medium-font:var(--scb-typography-body-medium-font, var(--md-sys-typescale-body-medium-font, var(--brand)));--scb-tour-design-supporting-medium-size:var(--scb-typography-body-medium-size, var(--md-sys-typescale-body-medium-size, 16px));--scb-tour-design-supporting-medium-line-height:var(--scb-typography-body-medium-line-height, var(--md-sys-typescale-body-medium-line-height, 24px));--scb-tour-design-supporting-medium-tracking:var(--scb-typography-body-medium-tracking, var(--md-sys-typescale-body-medium-tracking, var(--tracking-03, -0.15px)));--scb-tour-design-supporting-medium-weight:var(--scb-typography-body-medium-weight, var(--md-sys-typescale-body-medium-weight, var(--weight-regular, 400)));--scb-tour-design-supporting-medium-letter-spacing:var(--scb-typography-body-medium-letter-spacing, var(--scb-typography-body-medium-tracking, var(--md-sys-typescale-body-medium-tracking, var(--tracking-03, -0.15px))));--scb-tour-design-supporting-medium-font-weight:var(--scb-typography-body-medium-font-weight, var(--scb-typography-body-medium-weight, var(--md-sys-typescale-body-medium-weight, var(--weight-regular, 400))))}`,m);a([n({type:String,reflect:!0})],r.prototype,"variant",void 0);a([n({type:Boolean,reflect:!0,converter:v})],r.prototype,"spotlight",void 0);a([n({type:Boolean,reflect:!0,converter:v})],r.prototype,"open",void 0);a([n({type:Boolean,attribute:"auto-start",converter:v})],r.prototype,"autoStart",void 0);a([n({type:String,attribute:"storage-key"})],r.prototype,"storageKey",void 0);a([n({type:Number,reflect:!0})],r.prototype,"step",void 0);a([n({attribute:"close-label"})],r.prototype,"closeLabel",void 0);a([n({attribute:"previous-label"})],r.prototype,"previousLabel",void 0);a([n({attribute:"next-label"})],r.prototype,"nextLabel",void 0);a([n({attribute:"done-label"})],r.prototype,"doneLabel",void 0);a([n({attribute:"step-label"})],r.prototype,"stepLabel",void 0);a([f()],r.prototype,"_steps",void 0);r=b=a([w("scb-tour")],r);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scb-wc",
3
- "version": "0.1.252",
3
+ "version": "0.1.254",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -569,5 +569,5 @@
569
569
  "./scb-viz/*": null,
570
570
  "./mvc/*": "./mvc/*"
571
571
  },
572
- "buildHash": "3F1B5A0493BF340029BFEB318C261C11E708F1A78026A5E8CEB494B08DECC6E3"
572
+ "buildHash": "CCFFFFFD261CC57A7C52DA42E83D29257B75F65A20152E686F46102C594EBC72"
573
573
  }
@@ -3,7 +3,9 @@ import '../scb-button/scb-button.js';
3
3
  import '../scb-icon-button/scb-icon-button.js';
4
4
  export type ScbTourCloseReason = 'dismiss' | 'complete' | 'target-unavailable';
5
5
  export declare class ScbTour extends LitElement {
6
+ private static _nextId;
6
7
  variant: 'standard' | 'inverse';
8
+ spotlight: boolean;
7
9
  open: boolean;
8
10
  autoStart: boolean;
9
11
  storageKey: string;
@@ -19,6 +21,8 @@ export declare class ScbTour extends LitElement {
19
21
  private _startRequest;
20
22
  private _shownStorageKey;
21
23
  private _target?;
24
+ private _spotlightTarget?;
25
+ private readonly _spotlightId;
22
26
  private _returnFocus?;
23
27
  private _operation;
24
28
  private _frame;
@@ -6,12 +6,15 @@ import { ScbTourStepElement as r } from "./scb-tour-step.js";
6
6
  import { LitElement as i, css as a, html as o } from "lit";
7
7
  import { customElement as s, property as c, state as l } from "lit/decorators.js";
8
8
  //#region src/scb-components/scb-tour/scb-tour.ts
9
- var u = {
9
+ var u, d = {
10
10
  fromAttribute: (e) => e !== null && e !== "false",
11
11
  toAttribute: (e) => e ? "" : null
12
- }, d = class extends i {
12
+ }, f = class extends i {
13
+ static {
14
+ u = this;
15
+ }
13
16
  constructor(...e) {
14
- super(...e), this.variant = "standard", this.open = !1, this.autoStart = !1, this.storageKey = "", this.step = 0, this.closeLabel = "Stäng guiden", this.previousLabel = "Föregående", this.nextLabel = "Nästa", this.doneLabel = "Klart", this.stepLabel = "{current} av {total}", this._steps = [], this._stepObserver = new MutationObserver(() => this._readSteps()), this._autoStartAttempted = !1, this._startRequest = 0, this._shownStorageKey = "", this._operation = 0, this._frame = 0, this._scrollRoots = [], this._resizeObserver = new ResizeObserver(() => this._schedulePosition()), this._startOnLoad = async () => {
17
+ super(...e), this.variant = "standard", this.spotlight = !1, this.open = !1, this.autoStart = !1, this.storageKey = "", this.step = 0, this.closeLabel = "Stäng guiden", this.previousLabel = "Föregående", this.nextLabel = "Nästa", this.doneLabel = "Klart", this.stepLabel = "{current} av {total}", this._steps = [], this._stepObserver = new MutationObserver(() => this._readSteps()), this._autoStartAttempted = !1, this._startRequest = 0, this._shownStorageKey = "", this._spotlightId = `scb-tour-spotlight-${u._nextId++}`, this._operation = 0, this._frame = 0, this._scrollRoots = [], this._resizeObserver = new ResizeObserver(() => this._schedulePosition()), this._startOnLoad = async () => {
15
18
  if (!this.isConnected || document.readyState !== "complete" || !this.autoStart || this.open || this._autoStartAttempted) return;
16
19
  this._autoStartAttempted = !0;
17
20
  let e = this._startRequest, t = this.storageKey;
@@ -21,26 +24,74 @@ var u = {
21
24
  await this.updateComplete;
22
25
  let n = this._findTarget(this._steps[0]?.target);
23
26
  n?.localName.includes("-") && (await customElements.whenDefined(n.localName), await n.updateComplete), this.isConnected && this.autoStart && !this.open && e === this._startRequest && t === this.storageKey && this.start();
24
- }, this._schedulePosition = () => {
25
- cancelAnimationFrame(this._frame), this._frame = requestAnimationFrame(() => this._position());
26
- }, this._onResize = () => {
27
+ }, this._schedulePosition = (e) => {
28
+ e && this.shadowRoot?.querySelector(".layer")?.removeAttribute("data-moving"), cancelAnimationFrame(this._frame), this._frame = requestAnimationFrame(() => this._position());
29
+ }, this._onResize = (e) => {
27
30
  this._target?.scrollIntoView({
28
31
  block: "center",
29
32
  inline: "nearest",
30
33
  behavior: "instant"
31
- }), this._schedulePosition();
34
+ }), this._schedulePosition(e);
32
35
  }, this._next = () => {
33
36
  this.step >= this._steps.length - 1 ? this._close("complete") : this.step++;
34
37
  }, this._onKeydown = (e) => {
35
- e.key !== "Escape" || !this.open || (e.preventDefault(), e.stopPropagation(), this.close());
38
+ e.key !== "Escape" || !this.open || e.defaultPrevented || (e.preventDefault(), e.stopPropagation(), this.close());
36
39
  };
37
40
  }
41
+ static {
42
+ this._nextId = 0;
43
+ }
38
44
  static {
39
45
  this.styles = a`
40
46
  :host { display: block; }
41
- .surface {
47
+ .layer {
42
48
  display: none;
43
49
  position: fixed;
50
+ inset: 0;
51
+ margin: 0;
52
+ padding: 0;
53
+ border: 0;
54
+ inline-size: 100%;
55
+ block-size: 100%;
56
+ max-inline-size: none;
57
+ max-block-size: none;
58
+ overflow: visible;
59
+ background: transparent;
60
+ pointer-events: none;
61
+ }
62
+ .layer:popover-open { display: block; }
63
+ .layer::backdrop { background: transparent; pointer-events: none; }
64
+ :host([spotlight]) .layer:popover-open {
65
+ animation: scb-kf-fade-in var(--scb-motion-duration-short, 200ms) var(--scb-motion-easing-standard, ease);
66
+ }
67
+ @keyframes scb-kf-fade-in {
68
+ from { opacity: 0; }
69
+ to { opacity: 1; }
70
+ }
71
+ .spotlight { display: none; position: fixed; inset: 0; inline-size: 100%; block-size: 100%; }
72
+ :host([spotlight]) .spotlight { display: block; }
73
+ .spotlight-hole {
74
+ x: calc(var(--_spotlight-left) - var(--spacing-3, 8px));
75
+ y: calc(var(--_spotlight-top) - var(--spacing-3, 8px));
76
+ width: calc(var(--_spotlight-width) + 2 * var(--spacing-3, 8px));
77
+ height: calc(var(--_spotlight-height) + 2 * var(--spacing-3, 8px));
78
+ rx: var(--radius-medium, 12px);
79
+ }
80
+ .layer[data-moving] .spotlight-hole {
81
+ transition-property: x, y, width, height;
82
+ transition-duration: var(--scb-motion-duration-short, 200ms);
83
+ transition-timing-function: var(--scb-motion-easing-standard, ease);
84
+ }
85
+ .spotlight-scrim {
86
+ fill: var(--scb-tour-spotlight-color, color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent));
87
+ }
88
+ @media (prefers-reduced-motion: reduce) {
89
+ :host([spotlight]) .layer:popover-open { animation: none; }
90
+ .layer[data-moving] .spotlight-hole { transition: none; }
91
+ }
92
+ .surface {
93
+ position: fixed;
94
+ pointer-events: auto;
44
95
  box-sizing: border-box;
45
96
  margin: 0;
46
97
  inset: auto;
@@ -60,7 +111,6 @@ var u = {
60
111
  font-weight: var(--scb-tour-design-supporting-medium-weight);
61
112
  letter-spacing: var(--scb-tour-design-supporting-medium-tracking);
62
113
  }
63
- .surface:popover-open { display: block; }
64
114
  :host([variant='inverse']) .surface {
65
115
  background: var(--scb-tour-surface-color, var(--md-sys-color-on-info-container));
66
116
  color: var(--scb-tour-content-color, var(--md-sys-color-info-container));
@@ -145,7 +195,7 @@ var u = {
145
195
  this._startRequest++, this._stepObserver.disconnect(), window.removeEventListener("load", this._startOnLoad), this._hide(), super.disconnectedCallback();
146
196
  }
147
197
  updated(e) {
148
- this.open && e.has("open") && (this._autoStartAttempted = !0, this._startRequest++), this.open ? (e.has("open") || e.has("step") || e.has("_steps")) && this._showStep() : this._hide(), this._startOnLoad();
198
+ this.open && e.has("open") && (this._autoStartAttempted = !0, this._startRequest++), this.open ? e.has("open") || e.has("step") || e.has("_steps") ? this._showStep() : e.has("spotlight") && this._position() : this._hide(), this._startOnLoad();
149
199
  }
150
200
  _readSteps() {
151
201
  this._steps = Array.from(this.children).filter((e) => e instanceof r).map((e) => ({
@@ -185,9 +235,9 @@ var u = {
185
235
  }
186
236
  }
187
237
  _hide() {
188
- this._operation++, cancelAnimationFrame(this._frame), this._resizeObserver.disconnect(), window.removeEventListener("resize", this._onResize), window.removeEventListener("scroll", this._schedulePosition, !0), this._scrollRoots.forEach((e) => e.removeEventListener("scroll", this._schedulePosition, !0)), this._scrollRoots = [];
189
- let e = this.shadowRoot?.querySelector(".surface"), n = e?.contains(this.shadowRoot?.activeElement ?? null);
190
- t(e), n && this._returnFocus?.isConnected && this._returnFocus.focus({ preventScroll: !0 }), this._returnFocus = void 0, this._target = void 0, this._shownStorageKey = "";
238
+ this._operation++, cancelAnimationFrame(this._frame), this._resizeObserver.disconnect(), window.removeEventListener("resize", this._onResize), window.removeEventListener("keydown", this._onKeydown), window.removeEventListener("scroll", this._schedulePosition, !0), this._scrollRoots.forEach((e) => e.removeEventListener("scroll", this._schedulePosition, !0)), this._scrollRoots = [];
239
+ let e = (this.shadowRoot?.querySelector(".surface"))?.contains(this.shadowRoot?.activeElement ?? null), n = this.shadowRoot?.querySelector(".layer");
240
+ t(n), n?.removeAttribute("data-moving"), e && this._returnFocus?.isConnected && this._returnFocus.focus({ preventScroll: !0 }), this._returnFocus = void 0, this._target = void 0, this._spotlightTarget = void 0, this._shownStorageKey = "";
191
241
  }
192
242
  async _showStep() {
193
243
  let e = ++this._operation;
@@ -202,26 +252,26 @@ var u = {
202
252
  this._close("target-unavailable");
203
253
  return;
204
254
  }
205
- let a = this.shadowRoot.querySelector(".surface");
206
- if (!a.matches(":popover-open")) {
255
+ let a = this.shadowRoot.querySelector(".surface"), o = this.shadowRoot.querySelector(".layer");
256
+ if (!o.matches(":popover-open")) {
207
257
  this._shownStorageKey = this.storageKey;
208
258
  let e = document.activeElement;
209
259
  for (; e?.shadowRoot?.activeElement;) e = e.shadowRoot.activeElement;
210
260
  e instanceof HTMLElement && (this._returnFocus = e);
211
261
  }
212
262
  this._target = i;
213
- let o = i.getBoundingClientRect();
214
- if ((o.top < 0 || o.bottom > innerHeight || o.left < 0 || o.right > innerWidth) && i.scrollIntoView({
263
+ let s = i.getBoundingClientRect();
264
+ if ((s.top < 0 || s.bottom > innerHeight || s.left < 0 || s.right > innerWidth) && i.scrollIntoView({
215
265
  block: "center",
216
266
  inline: "nearest",
217
267
  behavior: "instant"
218
- }), !n(a, i)) {
268
+ }), !n(o, i)) {
219
269
  this._close("target-unavailable");
220
270
  return;
221
271
  }
222
272
  this._resizeObserver.disconnect(), this._resizeObserver.observe(i), this._resizeObserver.observe(a), window.addEventListener("resize", this._onResize), window.addEventListener("scroll", this._schedulePosition, !0), this._scrollRoots.forEach((e) => e.removeEventListener("scroll", this._schedulePosition, !0)), this._scrollRoots = [];
223
- let s = i.getRootNode();
224
- for (; s instanceof ShadowRoot;) s.addEventListener("scroll", this._schedulePosition, !0), this._scrollRoots.push(s), s = s.host.getRootNode();
273
+ let c = i.getRootNode();
274
+ for (; c instanceof ShadowRoot;) c.addEventListener("scroll", this._schedulePosition, !0), this._scrollRoots.push(c), c = c.host.getRootNode();
225
275
  this._position(), a.focus({ preventScroll: !0 }), this.dispatchEvent(new CustomEvent("stepchange", {
226
276
  detail: {
227
277
  step: t,
@@ -242,7 +292,13 @@ var u = {
242
292
  this._close("target-unavailable");
243
293
  return;
244
294
  }
245
- let n = getComputedStyle(this), r = Number.parseFloat(n.getPropertyValue("--spacing-4")) || 12, i = Number.parseFloat(n.getPropertyValue("--scb-tour-design-anchor-gap-medium")) || 12, a = e.getBoundingClientRect(), o = t.getBoundingClientRect(), s = innerHeight - a.bottom - i, c = a.top - i, l = s >= o.height + r || s >= c ? "bottom" : "top";
295
+ let n = getComputedStyle(this), r = Number.parseFloat(n.getPropertyValue("--spacing-4")) || 12, i = Number.parseFloat(n.getPropertyValue("--scb-tour-design-anchor-gap-medium")) || 12, a = e.getBoundingClientRect();
296
+ if (this.spotlight) {
297
+ window.addEventListener("keydown", this._onKeydown);
298
+ let t = this.shadowRoot.querySelector(".layer");
299
+ this._spotlightTarget !== e && (t.toggleAttribute("data-moving", !!this._spotlightTarget), this._spotlightTarget = e), t.style.setProperty("--_spotlight-left", `${a.left}px`), t.style.setProperty("--_spotlight-top", `${a.top}px`), t.style.setProperty("--_spotlight-width", `${a.width}px`), t.style.setProperty("--_spotlight-height", `${a.height}px`);
300
+ } else window.removeEventListener("keydown", this._onKeydown), this._spotlightTarget = void 0;
301
+ let o = t.getBoundingClientRect(), s = innerHeight - a.bottom - i, c = a.top - i, l = s >= o.height + r || s >= c ? "bottom" : "top";
246
302
  t.style.setProperty("--available-height", `calc(${Math.max(0, (l === "bottom" ? innerHeight - a.bottom : a.top) - r)}px - var(--scb-tour-design-anchor-gap-medium))`);
247
303
  let u = Math.max(r, Math.min(a.left + a.width / 2 - o.width / 2, innerWidth - o.width - r));
248
304
  t.style.left = `${u}px`, t.style.top = l === "bottom" ? `calc(${a.bottom}px + var(--scb-tour-design-anchor-gap-medium))` : `calc(${a.top}px - var(--scb-tour-design-anchor-gap-medium))`, t.dataset.side = l, t.style.setProperty("--anchor-x", `${a.left + a.width / 2 - u}px`);
@@ -254,44 +310,59 @@ var u = {
254
310
  e.defaultPrevented || this.start();
255
311
  }}></slot>
256
312
  <slot></slot>
257
- <section class="surface" part="surface" popover="manual" role="dialog" tabindex="-1"
258
- aria-labelledby="heading" aria-describedby="content counter" @keydown=${this._onKeydown}>
259
- <span class="arrow" part="arrow" aria-hidden="true"></span>
260
- <div class="body">
261
- <div class="header">
262
- <h2 id="heading">${e?.heading}</h2>
263
- <scb-icon-button size="small" icon="close" aria-label=${this.closeLabel} @click=${this.close}></scb-icon-button>
264
- </div>
265
- <p id="content">${e?.content}</p>
266
- <div class="footer">
267
- <span id="counter" class="counter">${t}</span>
268
- <div class="actions">
269
- <scb-button variant="text" size="small" .label=${this.previousLabel} ?disabled=${this.step <= 0} @click=${() => this.step--}></scb-button>
270
- <scb-button size="small" .label=${this.step === this._steps.length - 1 ? this.doneLabel : this.nextLabel} @click=${this._next}></scb-button>
313
+ <div class="layer" popover="manual">
314
+ <svg class="spotlight" aria-hidden="true" focusable="false">
315
+ <defs>
316
+ <mask id=${this._spotlightId} maskUnits="userSpaceOnUse" x="0" y="0" width="100%" height="100%">
317
+ <rect width="100%" height="100%" fill="white"></rect>
318
+ <rect class="spotlight-hole" fill="black"></rect>
319
+ </mask>
320
+ </defs>
321
+ <rect class="spotlight-scrim" width="100%" height="100%" mask=${`url(#${this._spotlightId})`}></rect>
322
+ </svg>
323
+ <section class="surface" part="surface" role="dialog" tabindex="-1"
324
+ aria-labelledby="heading" aria-describedby="content counter" @keydown=${this._onKeydown}>
325
+ <span class="arrow" part="arrow" aria-hidden="true"></span>
326
+ <div class="body">
327
+ <div class="header">
328
+ <h2 id="heading">${e?.heading}</h2>
329
+ <scb-icon-button size="small" icon="close" aria-label=${this.closeLabel} @click=${this.close}></scb-icon-button>
330
+ </div>
331
+ <p id="content">${e?.content}</p>
332
+ <div class="footer">
333
+ <span id="counter" class="counter">${t}</span>
334
+ <div class="actions">
335
+ <scb-button variant="text" size="small" .label=${this.previousLabel} ?disabled=${this.step <= 0} @click=${() => this.step--}></scb-button>
336
+ <scb-button size="small" .label=${this.step === this._steps.length - 1 ? this.doneLabel : this.nextLabel} @click=${this._next}></scb-button>
337
+ </div>
271
338
  </div>
272
339
  </div>
273
- </div>
274
- </section>
340
+ </section>
341
+ </div>
275
342
  `;
276
343
  }
277
344
  };
278
345
  e([c({
279
346
  type: String,
280
347
  reflect: !0
281
- })], d.prototype, "variant", void 0), e([c({
348
+ })], f.prototype, "variant", void 0), e([c({
349
+ type: Boolean,
350
+ reflect: !0,
351
+ converter: d
352
+ })], f.prototype, "spotlight", void 0), e([c({
282
353
  type: Boolean,
283
354
  reflect: !0,
284
- converter: u
285
- })], d.prototype, "open", void 0), e([c({
355
+ converter: d
356
+ })], f.prototype, "open", void 0), e([c({
286
357
  type: Boolean,
287
358
  attribute: "auto-start",
288
- converter: u
289
- })], d.prototype, "autoStart", void 0), e([c({
359
+ converter: d
360
+ })], f.prototype, "autoStart", void 0), e([c({
290
361
  type: String,
291
362
  attribute: "storage-key"
292
- })], d.prototype, "storageKey", void 0), e([c({
363
+ })], f.prototype, "storageKey", void 0), e([c({
293
364
  type: Number,
294
365
  reflect: !0
295
- })], d.prototype, "step", void 0), e([c({ attribute: "close-label" })], d.prototype, "closeLabel", void 0), e([c({ attribute: "previous-label" })], d.prototype, "previousLabel", void 0), e([c({ attribute: "next-label" })], d.prototype, "nextLabel", void 0), e([c({ attribute: "done-label" })], d.prototype, "doneLabel", void 0), e([c({ attribute: "step-label" })], d.prototype, "stepLabel", void 0), e([l()], d.prototype, "_steps", void 0), d = e([s("scb-tour")], d);
366
+ })], f.prototype, "step", void 0), e([c({ attribute: "close-label" })], f.prototype, "closeLabel", void 0), e([c({ attribute: "previous-label" })], f.prototype, "previousLabel", void 0), e([c({ attribute: "next-label" })], f.prototype, "nextLabel", void 0), e([c({ attribute: "done-label" })], f.prototype, "doneLabel", void 0), e([c({ attribute: "step-label" })], f.prototype, "stepLabel", void 0), e([l()], f.prototype, "_steps", void 0), f = u = e([s("scb-tour")], f);
296
367
  //#endregion
297
- export { d as ScbTour };
368
+ export { f as ScbTour };
package/scb-wc.bundle.js CHANGED
@@ -21990,11 +21990,56 @@
21990
21990
  <td headers=${[...o,i].join(` `)}>${this._content(n.values[c])}</td></tr>`)}),a=s}),t}render(){let e=this._model;return x`<div class="scroll" tabindex="0" ?hidden=${!!e}><slot @slotchange=${this._queueRead}></slot></div>
21991
21991
  ${e?x`<table class="mobile" aria-label=${R(e.label||void 0)}>
21992
21992
  <tbody>${this._mobileRows(e)}</tbody>
21993
- </table>`:S}`}};N([v()],Hm.prototype,`_model`,void 0),N([v()],Hm.prototype,`_mobile`,void 0),Hm=N([a(`scb-table-next`)],Hm),w(),b(),P();var Um=class extends C{constructor(...e){super(...e),this.target=``,this.heading=``}static{this.styles=p`:host { display: none !important; }`}connectedCallback(){super.connectedCallback(),this.setAttribute(`hidden`,``),this.setAttribute(`aria-hidden`,`true`)}render(){return x`<slot></slot>`}};N([_({type:String,reflect:!0})],Um.prototype,`target`,void 0),N([_({type:String,reflect:!0})],Um.prototype,`heading`,void 0),Um=N([a(`scb-tour-step`)],Um),w(),b(),Ol(),Mc(),dl(),P();var Wm={fromAttribute:e=>e!==null&&e!==`false`,toAttribute:e=>e?``:null},Gm=class extends C{constructor(...e){super(...e),this.variant=`standard`,this.open=!1,this.autoStart=!1,this.storageKey=``,this.step=0,this.closeLabel=`Stäng guiden`,this.previousLabel=`Föregående`,this.nextLabel=`Nästa`,this.doneLabel=`Klart`,this.stepLabel=`{current} av {total}`,this._steps=[],this._stepObserver=new MutationObserver(()=>this._readSteps()),this._autoStartAttempted=!1,this._startRequest=0,this._shownStorageKey=``,this._operation=0,this._frame=0,this._scrollRoots=[],this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._startOnLoad=async()=>{if(!this.isConnected||document.readyState!==`complete`||!this.autoStart||this.open||this._autoStartAttempted)return;this._autoStartAttempted=!0;let e=this._startRequest,t=this.storageKey;try{if(t&&localStorage.getItem(t)===`seen`)return}catch{}await this.updateComplete;let n=this._findTarget(this._steps[0]?.target);n?.localName.includes(`-`)&&(await customElements.whenDefined(n.localName),await n.updateComplete),this.isConnected&&this.autoStart&&!this.open&&e===this._startRequest&&t===this.storageKey&&this.start()},this._schedulePosition=()=>{cancelAnimationFrame(this._frame),this._frame=requestAnimationFrame(()=>this._position())},this._onResize=()=>{this._target?.scrollIntoView({block:`center`,inline:`nearest`,behavior:`instant`}),this._schedulePosition()},this._next=()=>{this.step>=this._steps.length-1?this._close(`complete`):this.step++},this._onKeydown=e=>{e.key!==`Escape`||!this.open||(e.preventDefault(),e.stopPropagation(),this.close())}}static{this.styles=p`
21993
+ </table>`:S}`}};N([v()],Hm.prototype,`_model`,void 0),N([v()],Hm.prototype,`_mobile`,void 0),Hm=N([a(`scb-table-next`)],Hm),w(),b(),P();var Um=class extends C{constructor(...e){super(...e),this.target=``,this.heading=``}static{this.styles=p`:host { display: none !important; }`}connectedCallback(){super.connectedCallback(),this.setAttribute(`hidden`,``),this.setAttribute(`aria-hidden`,`true`)}render(){return x`<slot></slot>`}};N([_({type:String,reflect:!0})],Um.prototype,`target`,void 0),N([_({type:String,reflect:!0})],Um.prototype,`heading`,void 0),Um=N([a(`scb-tour-step`)],Um),w(),b(),Ol(),Mc(),dl(),P();var Wm,Gm={fromAttribute:e=>e!==null&&e!==`false`,toAttribute:e=>e?``:null},Km=class extends C{static{Wm=this}constructor(...e){super(...e),this.variant=`standard`,this.spotlight=!1,this.open=!1,this.autoStart=!1,this.storageKey=``,this.step=0,this.closeLabel=`Stäng guiden`,this.previousLabel=`Föregående`,this.nextLabel=`Nästa`,this.doneLabel=`Klart`,this.stepLabel=`{current} av {total}`,this._steps=[],this._stepObserver=new MutationObserver(()=>this._readSteps()),this._autoStartAttempted=!1,this._startRequest=0,this._shownStorageKey=``,this._spotlightId=`scb-tour-spotlight-${Wm._nextId++}`,this._operation=0,this._frame=0,this._scrollRoots=[],this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._startOnLoad=async()=>{if(!this.isConnected||document.readyState!==`complete`||!this.autoStart||this.open||this._autoStartAttempted)return;this._autoStartAttempted=!0;let e=this._startRequest,t=this.storageKey;try{if(t&&localStorage.getItem(t)===`seen`)return}catch{}await this.updateComplete;let n=this._findTarget(this._steps[0]?.target);n?.localName.includes(`-`)&&(await customElements.whenDefined(n.localName),await n.updateComplete),this.isConnected&&this.autoStart&&!this.open&&e===this._startRequest&&t===this.storageKey&&this.start()},this._schedulePosition=e=>{e&&this.shadowRoot?.querySelector(`.layer`)?.removeAttribute(`data-moving`),cancelAnimationFrame(this._frame),this._frame=requestAnimationFrame(()=>this._position())},this._onResize=e=>{this._target?.scrollIntoView({block:`center`,inline:`nearest`,behavior:`instant`}),this._schedulePosition(e)},this._next=()=>{this.step>=this._steps.length-1?this._close(`complete`):this.step++},this._onKeydown=e=>{e.key!==`Escape`||!this.open||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),this.close())}}static{this._nextId=0}static{this.styles=p`
21994
21994
  :host { display: block; }
21995
- .surface {
21995
+ .layer {
21996
21996
  display: none;
21997
21997
  position: fixed;
21998
+ inset: 0;
21999
+ margin: 0;
22000
+ padding: 0;
22001
+ border: 0;
22002
+ inline-size: 100%;
22003
+ block-size: 100%;
22004
+ max-inline-size: none;
22005
+ max-block-size: none;
22006
+ overflow: visible;
22007
+ background: transparent;
22008
+ pointer-events: none;
22009
+ }
22010
+ .layer:popover-open { display: block; }
22011
+ .layer::backdrop { background: transparent; pointer-events: none; }
22012
+ :host([spotlight]) .layer:popover-open {
22013
+ animation: scb-kf-fade-in var(--scb-motion-duration-short, 200ms) var(--scb-motion-easing-standard, ease);
22014
+ }
22015
+ @keyframes scb-kf-fade-in {
22016
+ from { opacity: 0; }
22017
+ to { opacity: 1; }
22018
+ }
22019
+ .spotlight { display: none; position: fixed; inset: 0; inline-size: 100%; block-size: 100%; }
22020
+ :host([spotlight]) .spotlight { display: block; }
22021
+ .spotlight-hole {
22022
+ x: calc(var(--_spotlight-left) - var(--spacing-3, 8px));
22023
+ y: calc(var(--_spotlight-top) - var(--spacing-3, 8px));
22024
+ width: calc(var(--_spotlight-width) + 2 * var(--spacing-3, 8px));
22025
+ height: calc(var(--_spotlight-height) + 2 * var(--spacing-3, 8px));
22026
+ rx: var(--radius-medium, 12px);
22027
+ }
22028
+ .layer[data-moving] .spotlight-hole {
22029
+ transition-property: x, y, width, height;
22030
+ transition-duration: var(--scb-motion-duration-short, 200ms);
22031
+ transition-timing-function: var(--scb-motion-easing-standard, ease);
22032
+ }
22033
+ .spotlight-scrim {
22034
+ fill: var(--scb-tour-spotlight-color, color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent));
22035
+ }
22036
+ @media (prefers-reduced-motion: reduce) {
22037
+ :host([spotlight]) .layer:popover-open { animation: none; }
22038
+ .layer[data-moving] .spotlight-hole { transition: none; }
22039
+ }
22040
+ .surface {
22041
+ position: fixed;
22042
+ pointer-events: auto;
21998
22043
  box-sizing: border-box;
21999
22044
  margin: 0;
22000
22045
  inset: auto;
@@ -22014,7 +22059,6 @@
22014
22059
  font-weight: var(--scb-tour-design-supporting-medium-weight);
22015
22060
  letter-spacing: var(--scb-tour-design-supporting-medium-tracking);
22016
22061
  }
22017
- .surface:popover-open { display: block; }
22018
22062
  :host([variant='inverse']) .surface {
22019
22063
  background: var(--scb-tour-surface-color, var(--md-sys-color-on-info-container));
22020
22064
  color: var(--scb-tour-content-color, var(--md-sys-color-info-container));
@@ -22084,25 +22128,36 @@
22084
22128
  }
22085
22129
 
22086
22130
  /* design:bindings:scb-tour:end */
22087
- `}connectedCallback(){super.connectedCallback(),this._readSteps(),this._stepObserver.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`target`,`heading`]}),document.readyState!==`complete`&&window.addEventListener(`load`,this._startOnLoad,{once:!0})}disconnectedCallback(){this._startRequest++,this._stepObserver.disconnect(),window.removeEventListener(`load`,this._startOnLoad),this._hide(),super.disconnectedCallback()}updated(e){this.open&&e.has(`open`)&&(this._autoStartAttempted=!0,this._startRequest++),this.open?(e.has(`open`)||e.has(`step`)||e.has(`_steps`))&&this._showStep():this._hide(),this._startOnLoad()}_readSteps(){this._steps=Array.from(this.children).filter(e=>e instanceof Um).map(e=>({target:e.target,heading:e.heading,content:(e.textContent??``).replace(/\s+/g,` `).trim()}))}_findTarget(e){if(!e)return null;try{let t=this.querySelector(e)??this.getRootNode().querySelector(e);return t instanceof HTMLElement?t:null}catch{return null}}start(){this._autoStartAttempted=!0,this._startRequest++,this.step=0,this.open=!0}close(){this._autoStartAttempted=!0,this._startRequest++,this._close(`dismiss`)}_close(e){if(this.open){if(this._shownStorageKey&&e!==`target-unavailable`)try{localStorage.setItem(this._shownStorageKey,`seen`)}catch{}this.open=!1,this._hide(),this.dispatchEvent(new CustomEvent(`close`,{detail:{reason:e,step:this.step},bubbles:!0,composed:!0}))}}_hide(){this._operation++,cancelAnimationFrame(this._frame),this._resizeObserver.disconnect(),window.removeEventListener(`resize`,this._onResize),window.removeEventListener(`scroll`,this._schedulePosition,!0),this._scrollRoots.forEach(e=>e.removeEventListener(`scroll`,this._schedulePosition,!0)),this._scrollRoots=[];let e=this.shadowRoot?.querySelector(`.surface`),t=e?.contains(this.shadowRoot?.activeElement??null);z(e),t&&this._returnFocus?.isConnected&&this._returnFocus.focus({preventScroll:!0}),this._returnFocus=void 0,this._target=void 0,this._shownStorageKey=``}async _showStep(){let e=++this._operation;if(await this.updateComplete,!this.open||e!==this._operation)return;let t=Math.max(0,Math.min(this._steps.length-1,Math.trunc(this.step)||0));if(this.step!==t){this.step=t;return}let n=this._steps[t],r=this._findTarget(n?.target);if(!r||!this._isVisible(r)){this._close(`target-unavailable`);return}let i=this.shadowRoot.querySelector(`.surface`);if(!i.matches(`:popover-open`)){this._shownStorageKey=this.storageKey;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;e instanceof HTMLElement&&(this._returnFocus=e)}this._target=r;let a=r.getBoundingClientRect();if((a.top<0||a.bottom>innerHeight||a.left<0||a.right>innerWidth)&&r.scrollIntoView({block:`center`,inline:`nearest`,behavior:`instant`}),!Sl(i,r)){this._close(`target-unavailable`);return}this._resizeObserver.disconnect(),this._resizeObserver.observe(r),this._resizeObserver.observe(i),window.addEventListener(`resize`,this._onResize),window.addEventListener(`scroll`,this._schedulePosition,!0),this._scrollRoots.forEach(e=>e.removeEventListener(`scroll`,this._schedulePosition,!0)),this._scrollRoots=[];let o=r.getRootNode();for(;o instanceof ShadowRoot;)o.addEventListener(`scroll`,this._schedulePosition,!0),this._scrollRoots.push(o),o=o.host.getRootNode();this._position(),i.focus({preventScroll:!0}),this.dispatchEvent(new CustomEvent(`stepchange`,{detail:{step:t,total:this._steps.length},bubbles:!0,composed:!0}))}_isVisible(e){let t=getComputedStyle(e),n=e.getBoundingClientRect();return e.isConnected&&t.visibility!==`hidden`&&n.width>0&&n.height>0}_position(){let e=this._target,t=this.shadowRoot?.querySelector(`.surface`);if(!this.open||!t||!e)return;if(!this._isVisible(e)){this._close(`target-unavailable`);return}let n=getComputedStyle(this),r=Number.parseFloat(n.getPropertyValue(`--spacing-4`))||12,i=Number.parseFloat(n.getPropertyValue(`--scb-tour-design-anchor-gap-medium`))||12,a=e.getBoundingClientRect(),o=t.getBoundingClientRect(),s=innerHeight-a.bottom-i,c=a.top-i,l=s>=o.height+r||s>=c?`bottom`:`top`;t.style.setProperty(`--available-height`,`calc(${Math.max(0,(l===`bottom`?innerHeight-a.bottom:a.top)-r)}px - var(--scb-tour-design-anchor-gap-medium))`);let u=Math.max(r,Math.min(a.left+a.width/2-o.width/2,innerWidth-o.width-r));t.style.left=`${u}px`,t.style.top=l===`bottom`?`calc(${a.bottom}px + var(--scb-tour-design-anchor-gap-medium))`:`calc(${a.top}px - var(--scb-tour-design-anchor-gap-medium))`,t.dataset.side=l,t.style.setProperty(`--anchor-x`,`${a.left+a.width/2-u}px`)}render(){let e=this._steps[this.step],t=this.stepLabel.replace(`{current}`,String(this.step+1)).replace(`{total}`,String(this._steps.length));return x`
22131
+ `}connectedCallback(){super.connectedCallback(),this._readSteps(),this._stepObserver.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`target`,`heading`]}),document.readyState!==`complete`&&window.addEventListener(`load`,this._startOnLoad,{once:!0})}disconnectedCallback(){this._startRequest++,this._stepObserver.disconnect(),window.removeEventListener(`load`,this._startOnLoad),this._hide(),super.disconnectedCallback()}updated(e){this.open&&e.has(`open`)&&(this._autoStartAttempted=!0,this._startRequest++),this.open?e.has(`open`)||e.has(`step`)||e.has(`_steps`)?this._showStep():e.has(`spotlight`)&&this._position():this._hide(),this._startOnLoad()}_readSteps(){this._steps=Array.from(this.children).filter(e=>e instanceof Um).map(e=>({target:e.target,heading:e.heading,content:(e.textContent??``).replace(/\s+/g,` `).trim()}))}_findTarget(e){if(!e)return null;try{let t=this.querySelector(e)??this.getRootNode().querySelector(e);return t instanceof HTMLElement?t:null}catch{return null}}start(){this._autoStartAttempted=!0,this._startRequest++,this.step=0,this.open=!0}close(){this._autoStartAttempted=!0,this._startRequest++,this._close(`dismiss`)}_close(e){if(this.open){if(this._shownStorageKey&&e!==`target-unavailable`)try{localStorage.setItem(this._shownStorageKey,`seen`)}catch{}this.open=!1,this._hide(),this.dispatchEvent(new CustomEvent(`close`,{detail:{reason:e,step:this.step},bubbles:!0,composed:!0}))}}_hide(){this._operation++,cancelAnimationFrame(this._frame),this._resizeObserver.disconnect(),window.removeEventListener(`resize`,this._onResize),window.removeEventListener(`keydown`,this._onKeydown),window.removeEventListener(`scroll`,this._schedulePosition,!0),this._scrollRoots.forEach(e=>e.removeEventListener(`scroll`,this._schedulePosition,!0)),this._scrollRoots=[];let e=(this.shadowRoot?.querySelector(`.surface`))?.contains(this.shadowRoot?.activeElement??null),t=this.shadowRoot?.querySelector(`.layer`);z(t),t?.removeAttribute(`data-moving`),e&&this._returnFocus?.isConnected&&this._returnFocus.focus({preventScroll:!0}),this._returnFocus=void 0,this._target=void 0,this._spotlightTarget=void 0,this._shownStorageKey=``}async _showStep(){let e=++this._operation;if(await this.updateComplete,!this.open||e!==this._operation)return;let t=Math.max(0,Math.min(this._steps.length-1,Math.trunc(this.step)||0));if(this.step!==t){this.step=t;return}let n=this._steps[t],r=this._findTarget(n?.target);if(!r||!this._isVisible(r)){this._close(`target-unavailable`);return}let i=this.shadowRoot.querySelector(`.surface`),a=this.shadowRoot.querySelector(`.layer`);if(!a.matches(`:popover-open`)){this._shownStorageKey=this.storageKey;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;e instanceof HTMLElement&&(this._returnFocus=e)}this._target=r;let o=r.getBoundingClientRect();if((o.top<0||o.bottom>innerHeight||o.left<0||o.right>innerWidth)&&r.scrollIntoView({block:`center`,inline:`nearest`,behavior:`instant`}),!Sl(a,r)){this._close(`target-unavailable`);return}this._resizeObserver.disconnect(),this._resizeObserver.observe(r),this._resizeObserver.observe(i),window.addEventListener(`resize`,this._onResize),window.addEventListener(`scroll`,this._schedulePosition,!0),this._scrollRoots.forEach(e=>e.removeEventListener(`scroll`,this._schedulePosition,!0)),this._scrollRoots=[];let s=r.getRootNode();for(;s instanceof ShadowRoot;)s.addEventListener(`scroll`,this._schedulePosition,!0),this._scrollRoots.push(s),s=s.host.getRootNode();this._position(),i.focus({preventScroll:!0}),this.dispatchEvent(new CustomEvent(`stepchange`,{detail:{step:t,total:this._steps.length},bubbles:!0,composed:!0}))}_isVisible(e){let t=getComputedStyle(e),n=e.getBoundingClientRect();return e.isConnected&&t.visibility!==`hidden`&&n.width>0&&n.height>0}_position(){let e=this._target,t=this.shadowRoot?.querySelector(`.surface`);if(!this.open||!t||!e)return;if(!this._isVisible(e)){this._close(`target-unavailable`);return}let n=getComputedStyle(this),r=Number.parseFloat(n.getPropertyValue(`--spacing-4`))||12,i=Number.parseFloat(n.getPropertyValue(`--scb-tour-design-anchor-gap-medium`))||12,a=e.getBoundingClientRect();if(this.spotlight){window.addEventListener(`keydown`,this._onKeydown);let t=this.shadowRoot.querySelector(`.layer`);this._spotlightTarget!==e&&(t.toggleAttribute(`data-moving`,!!this._spotlightTarget),this._spotlightTarget=e),t.style.setProperty(`--_spotlight-left`,`${a.left}px`),t.style.setProperty(`--_spotlight-top`,`${a.top}px`),t.style.setProperty(`--_spotlight-width`,`${a.width}px`),t.style.setProperty(`--_spotlight-height`,`${a.height}px`)}else window.removeEventListener(`keydown`,this._onKeydown),this._spotlightTarget=void 0;let o=t.getBoundingClientRect(),s=innerHeight-a.bottom-i,c=a.top-i,l=s>=o.height+r||s>=c?`bottom`:`top`;t.style.setProperty(`--available-height`,`calc(${Math.max(0,(l===`bottom`?innerHeight-a.bottom:a.top)-r)}px - var(--scb-tour-design-anchor-gap-medium))`);let u=Math.max(r,Math.min(a.left+a.width/2-o.width/2,innerWidth-o.width-r));t.style.left=`${u}px`,t.style.top=l===`bottom`?`calc(${a.bottom}px + var(--scb-tour-design-anchor-gap-medium))`:`calc(${a.top}px - var(--scb-tour-design-anchor-gap-medium))`,t.dataset.side=l,t.style.setProperty(`--anchor-x`,`${a.left+a.width/2-u}px`)}render(){let e=this._steps[this.step],t=this.stepLabel.replace(`{current}`,String(this.step+1)).replace(`{total}`,String(this._steps.length));return x`
22088
22132
  <slot name="trigger" @click=${e=>{e.defaultPrevented||this.start()}}></slot>
22089
22133
  <slot></slot>
22090
- <section class="surface" part="surface" popover="manual" role="dialog" tabindex="-1"
22091
- aria-labelledby="heading" aria-describedby="content counter" @keydown=${this._onKeydown}>
22092
- <span class="arrow" part="arrow" aria-hidden="true"></span>
22093
- <div class="body">
22094
- <div class="header">
22095
- <h2 id="heading">${e?.heading}</h2>
22096
- <scb-icon-button size="small" icon="close" aria-label=${this.closeLabel} @click=${this.close}></scb-icon-button>
22097
- </div>
22098
- <p id="content">${e?.content}</p>
22099
- <div class="footer">
22100
- <span id="counter" class="counter">${t}</span>
22101
- <div class="actions">
22102
- <scb-button variant="text" size="small" .label=${this.previousLabel} ?disabled=${this.step<=0} @click=${()=>this.step--}></scb-button>
22103
- <scb-button size="small" .label=${this.step===this._steps.length-1?this.doneLabel:this.nextLabel} @click=${this._next}></scb-button>
22134
+ <div class="layer" popover="manual">
22135
+ <svg class="spotlight" aria-hidden="true" focusable="false">
22136
+ <defs>
22137
+ <mask id=${this._spotlightId} maskUnits="userSpaceOnUse" x="0" y="0" width="100%" height="100%">
22138
+ <rect width="100%" height="100%" fill="white"></rect>
22139
+ <rect class="spotlight-hole" fill="black"></rect>
22140
+ </mask>
22141
+ </defs>
22142
+ <rect class="spotlight-scrim" width="100%" height="100%" mask=${`url(#${this._spotlightId})`}></rect>
22143
+ </svg>
22144
+ <section class="surface" part="surface" role="dialog" tabindex="-1"
22145
+ aria-labelledby="heading" aria-describedby="content counter" @keydown=${this._onKeydown}>
22146
+ <span class="arrow" part="arrow" aria-hidden="true"></span>
22147
+ <div class="body">
22148
+ <div class="header">
22149
+ <h2 id="heading">${e?.heading}</h2>
22150
+ <scb-icon-button size="small" icon="close" aria-label=${this.closeLabel} @click=${this.close}></scb-icon-button>
22151
+ </div>
22152
+ <p id="content">${e?.content}</p>
22153
+ <div class="footer">
22154
+ <span id="counter" class="counter">${t}</span>
22155
+ <div class="actions">
22156
+ <scb-button variant="text" size="small" .label=${this.previousLabel} ?disabled=${this.step<=0} @click=${()=>this.step--}></scb-button>
22157
+ <scb-button size="small" .label=${this.step===this._steps.length-1?this.doneLabel:this.nextLabel} @click=${this._next}></scb-button>
22158
+ </div>
22104
22159
  </div>
22105
22160
  </div>
22106
- </div>
22107
- </section>
22108
- `}};N([_({type:String,reflect:!0})],Gm.prototype,`variant`,void 0),N([_({type:Boolean,reflect:!0,converter:Wm})],Gm.prototype,`open`,void 0),N([_({type:Boolean,attribute:`auto-start`,converter:Wm})],Gm.prototype,`autoStart`,void 0),N([_({type:String,attribute:`storage-key`})],Gm.prototype,`storageKey`,void 0),N([_({type:Number,reflect:!0})],Gm.prototype,`step`,void 0),N([_({attribute:`close-label`})],Gm.prototype,`closeLabel`,void 0),N([_({attribute:`previous-label`})],Gm.prototype,`previousLabel`,void 0),N([_({attribute:`next-label`})],Gm.prototype,`nextLabel`,void 0),N([_({attribute:`done-label`})],Gm.prototype,`doneLabel`,void 0),N([_({attribute:`step-label`})],Gm.prototype,`stepLabel`,void 0),N([v()],Gm.prototype,`_steps`,void 0),Gm=N([a(`scb-tour`)],Gm),_c(),Mc(),Fc(),Wc(),yc(),yl(),Ru(),gd(),wd(),Nd(),zd(),Id(),dl(),gl(),Qc(),rl(),cf(),uf(),hf(),ff(),vd(),Sd(),bd(),Tu(),Cf(),Kc(),Nl(),j(),Ec(),Ol(),_c(),Mc(),Fc(),Wc(),yc(),yl(),Ru(),gd(),wd(),Nd(),zd(),Id(),dl(),gl(),Qc(),rl(),cf(),uf(),hf(),ff(),vd(),Sd(),bd(),Tu(),Cf(),Kc(),Nl(),cc(),j(),Ec(),Ol()})();
22161
+ </section>
22162
+ </div>
22163
+ `}};N([_({type:String,reflect:!0})],Km.prototype,`variant`,void 0),N([_({type:Boolean,reflect:!0,converter:Gm})],Km.prototype,`spotlight`,void 0),N([_({type:Boolean,reflect:!0,converter:Gm})],Km.prototype,`open`,void 0),N([_({type:Boolean,attribute:`auto-start`,converter:Gm})],Km.prototype,`autoStart`,void 0),N([_({type:String,attribute:`storage-key`})],Km.prototype,`storageKey`,void 0),N([_({type:Number,reflect:!0})],Km.prototype,`step`,void 0),N([_({attribute:`close-label`})],Km.prototype,`closeLabel`,void 0),N([_({attribute:`previous-label`})],Km.prototype,`previousLabel`,void 0),N([_({attribute:`next-label`})],Km.prototype,`nextLabel`,void 0),N([_({attribute:`done-label`})],Km.prototype,`doneLabel`,void 0),N([_({attribute:`step-label`})],Km.prototype,`stepLabel`,void 0),N([v()],Km.prototype,`_steps`,void 0),Km=Wm=N([a(`scb-tour`)],Km),_c(),Mc(),Fc(),Wc(),yc(),yl(),Ru(),gd(),wd(),Nd(),zd(),Id(),dl(),gl(),Qc(),rl(),cf(),uf(),hf(),ff(),vd(),Sd(),bd(),Tu(),Cf(),Kc(),Nl(),j(),Ec(),Ol(),_c(),Mc(),Fc(),Wc(),yc(),yl(),Ru(),gd(),wd(),Nd(),zd(),Id(),dl(),gl(),Qc(),rl(),cf(),uf(),hf(),ff(),vd(),Sd(),bd(),Tu(),Cf(),Kc(),Nl(),cc(),j(),Ec(),Ol()})();