scb-wc 0.1.247 → 0.1.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +2 -0
- package/all.js +2 -0
- package/index.js +10 -8
- package/mvc/components/all.js +2 -0
- package/mvc/components/scb-tour/scb-tour-step.js +1 -0
- package/mvc/components/scb-tour/scb-tour.js +22 -0
- package/mvc/components/shared/manual-popover.js +1 -1
- package/package.json +12 -2
- package/scb-components/index.d.ts +2 -0
- package/scb-components/scb-tour/scb-tour-step.d.ts +13 -0
- package/scb-components/scb-tour/scb-tour.d.ts +52 -0
- package/scb-tour/scb-tour-step.js +27 -0
- package/scb-tour/scb-tour.js +284 -0
- package/scb-wc.bundle.js +242 -137
- package/scb-wc.d.ts +4 -0
- package/shared/manual-popover.js +2 -1
package/all.d.ts
CHANGED
|
@@ -95,6 +95,8 @@ import './scb-components/scb-textfield/scb-textfield.js';
|
|
|
95
95
|
import './scb-components/scb-toc/scb-toc-item.js';
|
|
96
96
|
import './scb-components/scb-toc/scb-toc.js';
|
|
97
97
|
import './scb-components/scb-tooltip/scb-tooltip.js';
|
|
98
|
+
import './scb-components/scb-tour/scb-tour-step.js';
|
|
99
|
+
import './scb-components/scb-tour/scb-tour.js';
|
|
98
100
|
import './scb-components/scb-viz/scb-viz-actions-runtime.js';
|
|
99
101
|
import './scb-components/scb-viz/scb-viz-print-runtime.js';
|
|
100
102
|
import './scb-components/scb-viz/scb-viz-series-differentiation-registry.js';
|
package/all.js
CHANGED
|
@@ -95,6 +95,8 @@ import './scb-textfield/scb-textfield.js';
|
|
|
95
95
|
import './scb-toc/scb-toc-item.js';
|
|
96
96
|
import './scb-toc/scb-toc.js';
|
|
97
97
|
import './scb-tooltip/scb-tooltip.js';
|
|
98
|
+
import './scb-tour/scb-tour-step.js';
|
|
99
|
+
import './scb-tour/scb-tour.js';
|
|
98
100
|
import './scb-viz/scb-viz-actions-runtime.js';
|
|
99
101
|
import './scb-viz/scb-viz-print-runtime.js';
|
|
100
102
|
import './scb-viz/scb-viz-series-differentiation-registry.js';
|
package/index.js
CHANGED
|
@@ -99,11 +99,13 @@ import { ScbSecondaryTab as Ke } from "./scb-tabs/scb-secondary-tab.js";
|
|
|
99
99
|
import { ScbTabs as qe } from "./scb-tabs/scb-tabs.js";
|
|
100
100
|
import { ScbTocItem as Je } from "./scb-toc/scb-toc-item.js";
|
|
101
101
|
import { ScbToc as Ye } from "./scb-toc/scb-toc.js";
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
104
|
-
import {
|
|
105
|
-
import {
|
|
106
|
-
import {
|
|
107
|
-
import {
|
|
108
|
-
import {
|
|
109
|
-
|
|
102
|
+
import { ScbTourStepElement as Xe } from "./scb-tour/scb-tour-step.js";
|
|
103
|
+
import { ScbTour as Ze } from "./scb-tour/scb-tour.js";
|
|
104
|
+
import { buildScbVizExportFileName as Qe, createScbVizCsvBlob as $e, createScbVizRasterBlobFromElement as et, createScbVizRasterDataUrlFromElement as tt, downloadScbVizBlob as nt, getScbVizCurrentFullscreenElement as rt, getScbVizExportBaseFileName as it, getScbVizFullscreenDocument as at, isScbVizFullscreenSupported as ot, openScbVizPrintFrame as st, runWithScbVizForcedPrintLightMode as ct, toggleScbVizFullscreen as lt } from "./scb-viz/scb-viz-actions-runtime.js";
|
|
105
|
+
import { buildScbVizPrintDocumentHtml as ut, buildScbVizPrintableFooterHtml as dt, buildScbVizPrintableTableHtml as ft } from "./scb-viz/scb-viz-print-runtime.js";
|
|
106
|
+
import { appendScbVizSeriesDifferentiationPatternMarks as pt, getScbVizSeriesDifferentiationPatternDefinition as mt, getScbVizSeriesDifferentiationPatternKinds as ht, getScbVizSeriesDifferentiationRegistry as gt, getScbVizSeriesDifferentiationVariant as _t, scbVizSeriesDifferentiationRegistry as vt } from "./scb-viz/scb-viz-series-differentiation-registry.js";
|
|
107
|
+
import { clearScbVizSeriesDifferentiationColorClass as yt, clearScbVizSeriesDifferentiationMetadata as bt, ensureScbVizGroupedSeriesDifferentiationStore as xt, ensureScbVizStyledModeSeriesPattern as St, getScbVizGroupedSeriesDifferentiationKey as Ct, getScbVizGroupedSeriesDifferentiationVariant as wt, getScbVizGroupedSeriesDifferentiationVariantIndex as Tt, getScbVizHighchartsColorClassName as Et, getScbVizHighchartsSvgElement as Dt, getScbVizHighchartsSvgRoot as Ot, getScbVizLegendSeriesDifferentiationTargets as kt, getScbVizSeriesDifferentiationColorIndex as At, getScbVizSeriesDifferentiationVariantByIndex as jt, isScbVizGroupedSeriesDifferentiationChart as Mt, isScbVizHighchartsStyledMode as Nt, setScbVizSeriesDifferentiationColorClass as Pt, setScbVizSeriesDifferentiationMetadata as Ft, shouldShowScbVizSeriesDifferentiationAction as It, usesScbVizGroupedPointDifferentiation as Lt } from "./scb-viz/scb-viz-series-differentiation-runtime.js";
|
|
108
|
+
import { buildScbVizResolvedTableView as Rt, createScbVizCsvRows as zt, inferScbVizTableAlignments as Bt, normalizeScbVizRenderableCell as Vt, readScbVizTableDataFromSlot as Ht } from "./scb-viz/scb-viz-table-runtime.js";
|
|
109
|
+
import { ScbViz as Ut } from "./scb-viz/scb-viz.js";
|
|
110
|
+
import { ensureRippleReady as Wt, syncRippleToControl as Gt } from "./shared/lazy-ripple.js";
|
|
111
|
+
export { D as SCBBreadcrumb, E as SCBBreadcrumbItem, l as ScbAccordion, s as ScbAccordionItem, u as ScbActionCard, C as ScbAppBar, a as ScbAvatar, w as ScbBadge, c as ScbButton, H as ScbCalendar, U as ScbCalendarCard, O as ScbCalendarEvent, d as ScbCard, P as ScbCheckbox, N as ScbCheckboxGroup, o as ScbChevron, R as ScbChip, W as ScbCollapse, f as ScbContainerCard, G as ScbCookiesConsent, A as ScbDatepicker, z as ScbDialog, k as ScbDivider, K as ScbDrawer, q as ScbDropZone, Z as ScbDropdown, $ as ScbFactCard, Q as ScbFactCardContent, ie as ScbFooter, ee as ScbFooterSection, se as ScbFormErrorSummary, fe as ScbGalleryGrid, re as ScbGrid, te as ScbGridItem, _e as ScbHeader, pe as ScbHeaderMenuGroup, me as ScbHeaderMenuItem, he as ScbHeaderTab, ge as ScbHeaderUtility, ue as ScbHorizontalScroller, ae as ScbIcon, g as ScbIconButton, ve as ScbKeyFigureCard, T as ScbLink, ye as ScbLinkButton, p as ScbLinkCard, V as ScbList, m as ScbListCard, B as ScbListItem, Ce as ScbMenu, be as ScbMenuItem, Te as ScbNav, we as ScbNavItem, oe as ScbNotificationCard, X as ScbOptionsMenu, J as ScbOptionsMenuItem, Y as ScbOptionsSubMenu, de as ScbOverlay, Ee as ScbPagination, Ge as ScbPrimaryTab, De as ScbProgressIndicator, Oe as ScbProgressStep, ke as ScbProgressStepper, I as ScbRadioButton, F as ScbRadioGroup, Ae as ScbScrollspy, S as ScbSearch, Ke as ScbSecondaryTab, Me as ScbSegmentedButton, je as ScbSegmentedItem, Pe as ScbSelect, Ne as ScbSelectOption, Fe as ScbSkeleton, Ie as ScbSlider, Le as ScbSnackbar, h as ScbSocialCard, ne as ScbStack, Re as ScbStatusPill, ze as ScbStep, Be as ScbStepper, Se as ScbSubmenu, L as ScbSwitch, Ve as ScbTable, He as ScbTableAdvanced, We as ScbTableNext, qe as ScbTabs, M as ScbTextField, Ye as ScbToc, Je as ScbTocItem, j as ScbTooltip, Ze as ScbTour, Xe as ScbTourStepElement, Ut as ScbViz, xe as ScbmenuSection, e as addLazyFocusRingListeners, pt as appendScbVizSeriesDifferentiationPatternMarks, Qe as buildScbVizExportFileName, ut as buildScbVizPrintDocumentHtml, dt as buildScbVizPrintableFooterHtml, ft as buildScbVizPrintableTableHtml, Rt as buildScbVizResolvedTableView, yt as clearScbVizSeriesDifferentiationColorClass, bt as clearScbVizSeriesDifferentiationMetadata, _ as closeManualPopover, v as closeManualPopoverAfterAnimations, y as closeNestedPopupSurfaces, i as componentSizeToken, $e as createScbVizCsvBlob, zt as createScbVizCsvRows, et as createScbVizRasterBlobFromElement, tt as createScbVizRasterDataUrlFromElement, nt as downloadScbVizBlob, t as ensureFocusRingOnFocusVisible, n as ensureFocusRingOnTab, r as ensureFocusRingReady, Wt as ensureRippleReady, xt as ensureScbVizGroupedSeriesDifferentiationStore, St as ensureScbVizStyledModeSeriesPattern, rt as getScbVizCurrentFullscreenElement, it as getScbVizExportBaseFileName, at as getScbVizFullscreenDocument, Ct as getScbVizGroupedSeriesDifferentiationKey, wt as getScbVizGroupedSeriesDifferentiationVariant, Tt as getScbVizGroupedSeriesDifferentiationVariantIndex, Et as getScbVizHighchartsColorClassName, Dt as getScbVizHighchartsSvgElement, Ot as getScbVizHighchartsSvgRoot, kt as getScbVizLegendSeriesDifferentiationTargets, At as getScbVizSeriesDifferentiationColorIndex, mt as getScbVizSeriesDifferentiationPatternDefinition, ht as getScbVizSeriesDifferentiationPatternKinds, gt as getScbVizSeriesDifferentiationRegistry, _t as getScbVizSeriesDifferentiationVariant, jt as getScbVizSeriesDifferentiationVariantByIndex, ce as hasScbSvgIcon, Bt as inferScbVizTableAlignments, b as isManualPopoverOpen, ot as isScbVizFullscreenSupported, Mt as isScbVizGroupedSeriesDifferentiationChart, Nt as isScbVizHighchartsStyledMode, Vt as normalizeScbVizRenderableCell, x as openManualPopover, st as openScbVizPrintFrame, Ht as readScbVizTableDataFromSlot, Ue as readTable, le as renderScbIcon, ct as runWithScbVizForcedPrintLightMode, vt as scbVizSeriesDifferentiationRegistry, Pt as setScbVizSeriesDifferentiationColorClass, Ft as setScbVizSeriesDifferentiationMetadata, It as shouldShowScbVizSeriesDifferentiationAction, Gt as syncRippleToControl, lt as toggleScbVizFullscreen, Lt as usesScbVizGroupedPointDifferentiation };
|
package/mvc/components/all.js
CHANGED
|
@@ -95,6 +95,8 @@ import './scb-textfield/scb-textfield.js';
|
|
|
95
95
|
import './scb-toc/scb-toc.js';
|
|
96
96
|
import './scb-toc/scb-toc-item.js';
|
|
97
97
|
import './scb-tooltip/scb-tooltip.js';
|
|
98
|
+
import './scb-tour/scb-tour.js';
|
|
99
|
+
import './scb-tour/scb-tour-step.js';
|
|
98
100
|
import './scb-viz/scb-viz.js';
|
|
99
101
|
import './scb-viz/scb-viz-actions-runtime.js';
|
|
100
102
|
import './scb-viz/scb-viz-print-runtime.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as u,m as p,p as c,v as _,y as m}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as s}from"../../vendor/decorate.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var r=customElements.define.bind(customElements);customElements.define=function(n,d,l){try{customElements.get(n)||r(n,d,l)}catch(a){var i=String(a||"");if(i.indexOf("already been used")===-1&&i.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var o,t=(o=class extends u{constructor(...r){super(...r),this.target="",this.heading=""}connectedCallback(){super.connectedCallback(),this.setAttribute("hidden",""),this.setAttribute("aria-hidden","true")}render(){return _`<slot></slot>`}},o.styles=m`:host{display:none!important}`,o);s([c({type:String,reflect:!0})],t.prototype,"target",void 0);s([c({type:String,reflect:!0})],t.prototype,"heading",void 0);t=s([p("scb-tour-step")],t);export{t as ScbTourStepElement};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{f as v,h as y,m as f,p as d,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,r,s){try{customElements.get(e)||t(e,r,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},o=(p=class extends y{constructor(...t){super(...t),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,r=this.storageKey;try{if(r&&localStorage.getItem(r)==="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&&r===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(r=>r.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 r=this._steps[e],s=this._findTarget(r?.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 l=s.getRootNode();for(;l instanceof ShadowRoot;)l.addEventListener("scroll",this._schedulePosition,!0),this._scrollRoots.push(l),l=l.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),r=t.getBoundingClientRect();return t.isConnected&&e.visibility!=="hidden"&&r.width>0&&r.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 r=getComputedStyle(this),s=Number.parseFloat(r.getPropertyValue("--spacing-4"))||12,n=Number.parseFloat(r.getPropertyValue("--scb-tour-design-anchor-gap-medium"))||12,i=t.getBoundingClientRect(),l=e.getBoundingClientRect(),c=innerHeight-i.bottom-n,b=i.top-n,h=c>=l.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-l.width/2,innerWidth-l.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 _`
|
|
2
|
+
<slot name="trigger" @click=${r=>{r.defaultPrevented||this.start()}}></slot>
|
|
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>
|
|
18
|
+
</div>
|
|
19
|
+
</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}.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([d({type:Boolean,reflect:!0,converter:g})],o.prototype,"open",void 0);a([d({type:Boolean,attribute:"auto-start",converter:g})],o.prototype,"autoStart",void 0);a([d({type:String,attribute:"storage-key"})],o.prototype,"storageKey",void 0);a([d({type:Number,reflect:!0})],o.prototype,"step",void 0);a([d({attribute:"close-label"})],o.prototype,"closeLabel",void 0);a([d({attribute:"previous-label"})],o.prototype,"previousLabel",void 0);a([d({attribute:"next-label"})],o.prototype,"nextLabel",void 0);a([d({attribute:"done-label"})],o.prototype,"doneLabel",void 0);a([d({attribute:"step-label"})],o.prototype,"stepLabel",void 0);a([v()],o.prototype,"_steps",void 0);o=a([f("scb-tour")],o);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){try{var o=typeof globalThis<"u"?globalThis:window;if(!o.__scb_ce_guard_installed__){o.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(r,e,s){try{customElements.get(r)||t(r,e,s)}catch(i){var n=String(i||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();var c=new WeakMap;function p(o){const t=(c.get(o)??0)+1;return c.set(o,t),t}function d(o){const t=getComputedStyle(o),r=n=>n.endsWith("ms")?Number.parseFloat(n):Number.parseFloat(n)*1e3,e=t.transitionDuration.split(",").map(n=>r(n.trim())),s=t.transitionDelay.split(",").map(n=>r(n.trim()));return e.reduce((n,i,a)=>{const f=s[a%s.length]??0;return Math.max(n,i+f)},0)}var l=["scb-datepicker","scb-dialog","scb-drawer","scb-dropdown","scb-options-menu","scb-options-sub-menu","scb-overlay","scb-search","scb-select","scb-tooltip"].join(",");function v(o,t,r="manual"){if(!o)return!1;p(o);const e=o;if(typeof e.showPopover!="function")return!1;if(o.setAttribute("popover",r),!o.matches(":popover-open"))try{e.showPopover(t?{source:t}:void 0)}catch{return!1}return o.matches(":popover-open")}function u(o){if(!o)return;p(o);const t=o;if(typeof t.hidePopover=="function"&&o.matches(":popover-open"))try{t.hidePopover()}catch{}o.removeAttribute("popover")}function m(o,t,r){if(!o)return;const e=p(o);requestAnimationFrame(async()=>{const s=r??o,n=d(s),i=s.getAnimations().filter(a=>a.playState!=="finished");i.length>0?await Promise.allSettled(i.map(a=>a.finished)):n>0&&await new Promise(a=>setTimeout(a,n)),c.get(o)===e&&(u(o),t?.())})}function h(o){return!!o?.matches(":popover-open")}function b(o){const t=r=>{for(const e of r.querySelectorAll("*"))e.shadowRoot&&t(e.shadowRoot),e.matches("[popover]")&&h(e)&&u(e),e.matches(l)&&"open"in e&&e.open&&(e.open=!1)};t(o)}export{u as closeManualPopover,m as closeManualPopoverAfterAnimations,b as closeNestedPopupSurfaces,h as isManualPopoverOpen,v as openManualPopover};
|
|
1
|
+
(function(){try{var o=typeof globalThis<"u"?globalThis:window;if(!o.__scb_ce_guard_installed__){o.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(r,e,s){try{customElements.get(r)||t(r,e,s)}catch(i){var n=String(i||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();var c=new WeakMap;function p(o){const t=(c.get(o)??0)+1;return c.set(o,t),t}function d(o){const t=getComputedStyle(o),r=n=>n.endsWith("ms")?Number.parseFloat(n):Number.parseFloat(n)*1e3,e=t.transitionDuration.split(",").map(n=>r(n.trim())),s=t.transitionDelay.split(",").map(n=>r(n.trim()));return e.reduce((n,i,a)=>{const f=s[a%s.length]??0;return Math.max(n,i+f)},0)}var l=["scb-datepicker","scb-dialog","scb-drawer","scb-dropdown","scb-options-menu","scb-options-sub-menu","scb-overlay","scb-search","scb-select","scb-tooltip","scb-tour"].join(",");function v(o,t,r="manual"){if(!o)return!1;p(o);const e=o;if(typeof e.showPopover!="function")return!1;if(o.setAttribute("popover",r),!o.matches(":popover-open"))try{e.showPopover(t?{source:t}:void 0)}catch{return!1}return o.matches(":popover-open")}function u(o){if(!o)return;p(o);const t=o;if(typeof t.hidePopover=="function"&&o.matches(":popover-open"))try{t.hidePopover()}catch{}o.removeAttribute("popover")}function m(o,t,r){if(!o)return;const e=p(o);requestAnimationFrame(async()=>{const s=r??o,n=d(s),i=s.getAnimations().filter(a=>a.playState!=="finished");i.length>0?await Promise.allSettled(i.map(a=>a.finished)):n>0&&await new Promise(a=>setTimeout(a,n)),c.get(o)===e&&(u(o),t?.())})}function h(o){return!!o?.matches(":popover-open")}function b(o){const t=r=>{for(const e of r.querySelectorAll("*"))e.shadowRoot&&t(e.shadowRoot),e.matches("[popover]")&&h(e)&&u(e),e.matches(l)&&"open"in e&&e.open&&(e.open=!1)};t(o)}export{u as closeManualPopover,m as closeManualPopoverAfterAnimations,b as closeNestedPopupSurfaces,h as isManualPopoverOpen,v as openManualPopover};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.249",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -551,6 +551,16 @@
|
|
|
551
551
|
"import": "./scb-tooltip/scb-tooltip.js",
|
|
552
552
|
"require": "./scb-tooltip/scb-tooltip.js"
|
|
553
553
|
},
|
|
554
|
+
"./scb-tour": {
|
|
555
|
+
"types": "./scb-components/scb-tour/scb-tour.d.ts",
|
|
556
|
+
"import": "./scb-tour/scb-tour.js",
|
|
557
|
+
"require": "./scb-tour/scb-tour.js"
|
|
558
|
+
},
|
|
559
|
+
"./scb-tour/scb-tour-step": {
|
|
560
|
+
"types": "./scb-components/scb-tour/scb-tour-step.d.ts",
|
|
561
|
+
"import": "./scb-tour/scb-tour-step.js",
|
|
562
|
+
"require": "./scb-tour/scb-tour-step.js"
|
|
563
|
+
},
|
|
554
564
|
"./scb-viz": {
|
|
555
565
|
"types": "./scb-components/scb-viz/scb-viz.d.ts",
|
|
556
566
|
"import": "./scb-viz/scb-viz.js",
|
|
@@ -559,5 +569,5 @@
|
|
|
559
569
|
"./scb-viz/*": null,
|
|
560
570
|
"./mvc/*": "./mvc/*"
|
|
561
571
|
},
|
|
562
|
-
"buildHash": "
|
|
572
|
+
"buildHash": "5D8608FA841C895BA23E8A60C0A84998CB24A8798048BAD58F9BC26987A1D100"
|
|
563
573
|
}
|
|
@@ -95,6 +95,8 @@ export * from './scb-textfield/scb-textfield';
|
|
|
95
95
|
export * from './scb-toc/scb-toc-item';
|
|
96
96
|
export * from './scb-toc/scb-toc';
|
|
97
97
|
export * from './scb-tooltip/scb-tooltip';
|
|
98
|
+
export * from './scb-tour/scb-tour-step';
|
|
99
|
+
export * from './scb-tour/scb-tour';
|
|
98
100
|
export * from './scb-viz/scb-viz-actions-runtime';
|
|
99
101
|
export * from './scb-viz/scb-viz-print-runtime';
|
|
100
102
|
export * from './scb-viz/scb-viz-series-differentiation-registry';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class ScbTourStepElement extends LitElement {
|
|
3
|
+
target: string;
|
|
4
|
+
heading: string;
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
8
|
+
}
|
|
9
|
+
declare global {
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'scb-tour-step': ScbTourStepElement;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import '../scb-button/scb-button.js';
|
|
3
|
+
import '../scb-icon-button/scb-icon-button.js';
|
|
4
|
+
export type ScbTourCloseReason = 'dismiss' | 'complete' | 'target-unavailable';
|
|
5
|
+
export declare class ScbTour extends LitElement {
|
|
6
|
+
open: boolean;
|
|
7
|
+
autoStart: boolean;
|
|
8
|
+
storageKey: string;
|
|
9
|
+
step: number;
|
|
10
|
+
closeLabel: string;
|
|
11
|
+
previousLabel: string;
|
|
12
|
+
nextLabel: string;
|
|
13
|
+
doneLabel: string;
|
|
14
|
+
stepLabel: string;
|
|
15
|
+
private _steps;
|
|
16
|
+
private _stepObserver;
|
|
17
|
+
private _autoStartAttempted;
|
|
18
|
+
private _startRequest;
|
|
19
|
+
private _shownStorageKey;
|
|
20
|
+
private _target?;
|
|
21
|
+
private _returnFocus?;
|
|
22
|
+
private _operation;
|
|
23
|
+
private _frame;
|
|
24
|
+
private _scrollRoots;
|
|
25
|
+
private _resizeObserver;
|
|
26
|
+
static styles: import("lit").CSSResult;
|
|
27
|
+
connectedCallback(): void;
|
|
28
|
+
disconnectedCallback(): void;
|
|
29
|
+
protected updated(changed: PropertyValues): void;
|
|
30
|
+
private _readSteps;
|
|
31
|
+
private _findTarget;
|
|
32
|
+
private _startOnLoad;
|
|
33
|
+
/** Startar guiden från första steget. */
|
|
34
|
+
start(): void;
|
|
35
|
+
/** Stänger guiden utan att markera den som slutförd. */
|
|
36
|
+
close(): void;
|
|
37
|
+
private _close;
|
|
38
|
+
private _hide;
|
|
39
|
+
private _showStep;
|
|
40
|
+
private _isVisible;
|
|
41
|
+
private _schedulePosition;
|
|
42
|
+
private _onResize;
|
|
43
|
+
private _position;
|
|
44
|
+
private _next;
|
|
45
|
+
private _onKeydown;
|
|
46
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
47
|
+
}
|
|
48
|
+
declare global {
|
|
49
|
+
interface HTMLElementTagNameMap {
|
|
50
|
+
'scb-tour': ScbTour;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import e from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/decorate.js";
|
|
2
|
+
import { LitElement as t, css as n, html as r } from "lit";
|
|
3
|
+
import { customElement as i, property as a } from "lit/decorators.js";
|
|
4
|
+
//#region src/scb-components/scb-tour/scb-tour-step.ts
|
|
5
|
+
var o = class extends t {
|
|
6
|
+
constructor(...e) {
|
|
7
|
+
super(...e), this.target = "", this.heading = "";
|
|
8
|
+
}
|
|
9
|
+
static {
|
|
10
|
+
this.styles = n`:host { display: none !important; }`;
|
|
11
|
+
}
|
|
12
|
+
connectedCallback() {
|
|
13
|
+
super.connectedCallback(), this.setAttribute("hidden", ""), this.setAttribute("aria-hidden", "true");
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
return r`<slot></slot>`;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
e([a({
|
|
20
|
+
type: String,
|
|
21
|
+
reflect: !0
|
|
22
|
+
})], o.prototype, "target", void 0), e([a({
|
|
23
|
+
type: String,
|
|
24
|
+
reflect: !0
|
|
25
|
+
})], o.prototype, "heading", void 0), o = e([i("scb-tour-step")], o);
|
|
26
|
+
//#endregion
|
|
27
|
+
export { o as ScbTourStepElement };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import e from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/decorate.js";
|
|
2
|
+
import "../scb-button/scb-button.js";
|
|
3
|
+
import "../scb-icon-button/scb-icon-button.js";
|
|
4
|
+
import { closeManualPopover as t, openManualPopover as n } from "../shared/manual-popover.js";
|
|
5
|
+
import { ScbTourStepElement as r } from "./scb-tour-step.js";
|
|
6
|
+
import { LitElement as i, css as a, html as o } from "lit";
|
|
7
|
+
import { customElement as s, property as c, state as l } from "lit/decorators.js";
|
|
8
|
+
//#region src/scb-components/scb-tour/scb-tour.ts
|
|
9
|
+
var u = {
|
|
10
|
+
fromAttribute: (e) => e !== null && e !== "false",
|
|
11
|
+
toAttribute: (e) => e ? "" : null
|
|
12
|
+
}, d = class extends i {
|
|
13
|
+
constructor(...e) {
|
|
14
|
+
super(...e), 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 () => {
|
|
15
|
+
if (!this.isConnected || document.readyState !== "complete" || !this.autoStart || this.open || this._autoStartAttempted) return;
|
|
16
|
+
this._autoStartAttempted = !0;
|
|
17
|
+
let e = this._startRequest, t = this.storageKey;
|
|
18
|
+
try {
|
|
19
|
+
if (t && localStorage.getItem(t) === "seen") return;
|
|
20
|
+
} catch {}
|
|
21
|
+
await this.updateComplete;
|
|
22
|
+
let n = this._findTarget(this._steps[0]?.target);
|
|
23
|
+
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._target?.scrollIntoView({
|
|
28
|
+
block: "center",
|
|
29
|
+
inline: "nearest",
|
|
30
|
+
behavior: "instant"
|
|
31
|
+
}), this._schedulePosition();
|
|
32
|
+
}, this._next = () => {
|
|
33
|
+
this.step >= this._steps.length - 1 ? this._close("complete") : this.step++;
|
|
34
|
+
}, this._onKeydown = (e) => {
|
|
35
|
+
e.key !== "Escape" || !this.open || (e.preventDefault(), e.stopPropagation(), this.close());
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
static {
|
|
39
|
+
this.styles = a`
|
|
40
|
+
:host { display: block; }
|
|
41
|
+
.surface {
|
|
42
|
+
display: none;
|
|
43
|
+
position: fixed;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
margin: 0;
|
|
46
|
+
inset: auto;
|
|
47
|
+
border: 0;
|
|
48
|
+
inline-size: min(360px, calc(100vw - 2 * var(--spacing-4, 12px)));
|
|
49
|
+
max-block-size: min(var(--available-height, 100vh), calc(100vh - 2 * var(--spacing-4, 12px)));
|
|
50
|
+
padding: var(--scb-tour-design-padding-medium);
|
|
51
|
+
border-radius: var(--scb-tour-design-radius-medium);
|
|
52
|
+
background: var(--scb-tour-surface-color, var(--md-sys-color-surface-container));
|
|
53
|
+
color: var(--scb-tour-content-color, var(--md-sys-color-on-surface));
|
|
54
|
+
box-shadow: var(--scb-tour-design-shadow-medium);
|
|
55
|
+
overflow: visible;
|
|
56
|
+
outline: none;
|
|
57
|
+
font-family: var(--scb-tour-design-supporting-medium-font);
|
|
58
|
+
font-size: var(--scb-tour-design-supporting-medium-size);
|
|
59
|
+
line-height: var(--scb-tour-design-supporting-medium-line-height);
|
|
60
|
+
font-weight: var(--scb-tour-design-supporting-medium-weight);
|
|
61
|
+
letter-spacing: var(--scb-tour-design-supporting-medium-tracking);
|
|
62
|
+
}
|
|
63
|
+
.surface:popover-open { display: block; }
|
|
64
|
+
.body {
|
|
65
|
+
display: grid;
|
|
66
|
+
gap: var(--scb-tour-design-gap-medium);
|
|
67
|
+
max-block-size: calc(min(var(--available-height, 100vh), 100vh - 2 * var(--spacing-4, 12px)) - 2 * var(--scb-tour-design-padding-medium));
|
|
68
|
+
overflow: auto;
|
|
69
|
+
overflow-wrap: anywhere;
|
|
70
|
+
}
|
|
71
|
+
.header { display: flex; align-items: start; gap: var(--scb-tour-design-gap-medium); }
|
|
72
|
+
h2 {
|
|
73
|
+
flex: 1;
|
|
74
|
+
margin: 0;
|
|
75
|
+
font-family: var(--scb-tour-design-title-medium-font);
|
|
76
|
+
font-size: var(--scb-tour-design-title-medium-size);
|
|
77
|
+
line-height: var(--scb-tour-design-title-medium-line-height);
|
|
78
|
+
font-weight: var(--scb-tour-design-title-medium-weight);
|
|
79
|
+
letter-spacing: var(--scb-tour-design-title-medium-tracking);
|
|
80
|
+
}
|
|
81
|
+
p { margin: 0; }
|
|
82
|
+
.footer { display: flex; align-items: center; flex-wrap: wrap; gap: var(--scb-tour-design-gap-medium); }
|
|
83
|
+
.counter { margin-inline-end: auto; }
|
|
84
|
+
.actions { display: flex; flex-wrap: wrap; gap: var(--scb-tour-design-gap-medium); }
|
|
85
|
+
.arrow {
|
|
86
|
+
position: absolute;
|
|
87
|
+
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)));
|
|
88
|
+
top: calc(-1 * var(--scb-tour-design-arrow-size-medium));
|
|
89
|
+
inline-size: calc(2 * var(--scb-tour-design-arrow-size-medium));
|
|
90
|
+
block-size: var(--scb-tour-design-arrow-size-medium);
|
|
91
|
+
background: inherit;
|
|
92
|
+
clip-path: polygon(50% 0, 100% 100%, 0 100%);
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
}
|
|
95
|
+
.surface[data-side='top'] { translate: 0 -100%; }
|
|
96
|
+
.surface[data-side='top'] .arrow { top: 100%; transform: rotate(180deg); }
|
|
97
|
+
|
|
98
|
+
/* design:bindings:scb-tour:start */
|
|
99
|
+
/* Genererat från src/scb-components/scb-tour/component.json. Kör component:finish efter ändring. */
|
|
100
|
+
:host {
|
|
101
|
+
--scb-tour-design-padding-medium: var(--spacing-5, 16px);
|
|
102
|
+
--scb-tour-design-gap-medium: var(--spacing-4, 12px);
|
|
103
|
+
--scb-tour-design-radius-medium: var(--radius-medium, 12px);
|
|
104
|
+
--scb-tour-design-anchor-gap-medium: var(--spacing-4, 12px);
|
|
105
|
+
--scb-tour-design-arrow-size-medium: var(--spacing-3, 8px);
|
|
106
|
+
--scb-tour-design-title-medium-font: var(--scb-typography-title-medium-font, var(--md-sys-typescale-title-medium-font, var(--brand)));
|
|
107
|
+
--scb-tour-design-title-medium-size: var(--scb-typography-title-medium-size, var(--md-sys-typescale-title-medium-size, 18px));
|
|
108
|
+
--scb-tour-design-title-medium-line-height: var(--scb-typography-title-medium-line-height, var(--md-sys-typescale-title-medium-line-height, 26px));
|
|
109
|
+
--scb-tour-design-title-medium-tracking: var(--scb-typography-title-medium-tracking, var(--md-sys-typescale-title-medium-tracking, var(--tracking-05, -0.3px)));
|
|
110
|
+
--scb-tour-design-title-medium-weight: var(--scb-typography-title-medium-weight, var(--md-sys-typescale-title-medium-weight, var(--weight-semibold, 600)));
|
|
111
|
+
--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))));
|
|
112
|
+
--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))));
|
|
113
|
+
--scb-tour-design-supporting-medium-font: var(--scb-typography-body-medium-font, var(--md-sys-typescale-body-medium-font, var(--brand)));
|
|
114
|
+
--scb-tour-design-supporting-medium-size: var(--scb-typography-body-medium-size, var(--md-sys-typescale-body-medium-size, 16px));
|
|
115
|
+
--scb-tour-design-supporting-medium-line-height: var(--scb-typography-body-medium-line-height, var(--md-sys-typescale-body-medium-line-height, 24px));
|
|
116
|
+
--scb-tour-design-supporting-medium-tracking: var(--scb-typography-body-medium-tracking, var(--md-sys-typescale-body-medium-tracking, var(--tracking-03, -0.15px)));
|
|
117
|
+
--scb-tour-design-supporting-medium-weight: var(--scb-typography-body-medium-weight, var(--md-sys-typescale-body-medium-weight, var(--weight-regular, 400)));
|
|
118
|
+
--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))));
|
|
119
|
+
--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))));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* design:bindings:scb-tour:end */
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
connectedCallback() {
|
|
126
|
+
super.connectedCallback(), this._readSteps(), this._stepObserver.observe(this, {
|
|
127
|
+
childList: !0,
|
|
128
|
+
subtree: !0,
|
|
129
|
+
characterData: !0,
|
|
130
|
+
attributes: !0,
|
|
131
|
+
attributeFilter: ["target", "heading"]
|
|
132
|
+
}), document.readyState !== "complete" && window.addEventListener("load", this._startOnLoad, { once: !0 });
|
|
133
|
+
}
|
|
134
|
+
disconnectedCallback() {
|
|
135
|
+
this._startRequest++, this._stepObserver.disconnect(), window.removeEventListener("load", this._startOnLoad), this._hide(), super.disconnectedCallback();
|
|
136
|
+
}
|
|
137
|
+
updated(e) {
|
|
138
|
+
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();
|
|
139
|
+
}
|
|
140
|
+
_readSteps() {
|
|
141
|
+
this._steps = Array.from(this.children).filter((e) => e instanceof r).map((e) => ({
|
|
142
|
+
target: e.target,
|
|
143
|
+
heading: e.heading,
|
|
144
|
+
content: (e.textContent ?? "").replace(/\s+/g, " ").trim()
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
_findTarget(e) {
|
|
148
|
+
if (!e) return null;
|
|
149
|
+
try {
|
|
150
|
+
let t = this.querySelector(e) ?? this.getRootNode().querySelector(e);
|
|
151
|
+
return t instanceof HTMLElement ? t : null;
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
start() {
|
|
157
|
+
this._autoStartAttempted = !0, this._startRequest++, this.step = 0, this.open = !0;
|
|
158
|
+
}
|
|
159
|
+
close() {
|
|
160
|
+
this._autoStartAttempted = !0, this._startRequest++, this._close("dismiss");
|
|
161
|
+
}
|
|
162
|
+
_close(e) {
|
|
163
|
+
if (this.open) {
|
|
164
|
+
if (this._shownStorageKey && e !== "target-unavailable") try {
|
|
165
|
+
localStorage.setItem(this._shownStorageKey, "seen");
|
|
166
|
+
} catch {}
|
|
167
|
+
this.open = !1, this._hide(), this.dispatchEvent(new CustomEvent("close", {
|
|
168
|
+
detail: {
|
|
169
|
+
reason: e,
|
|
170
|
+
step: this.step
|
|
171
|
+
},
|
|
172
|
+
bubbles: !0,
|
|
173
|
+
composed: !0
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
_hide() {
|
|
178
|
+
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 = [];
|
|
179
|
+
let e = this.shadowRoot?.querySelector(".surface"), n = e?.contains(this.shadowRoot?.activeElement ?? null);
|
|
180
|
+
t(e), n && this._returnFocus?.isConnected && this._returnFocus.focus({ preventScroll: !0 }), this._returnFocus = void 0, this._target = void 0, this._shownStorageKey = "";
|
|
181
|
+
}
|
|
182
|
+
async _showStep() {
|
|
183
|
+
let e = ++this._operation;
|
|
184
|
+
if (await this.updateComplete, !this.open || e !== this._operation) return;
|
|
185
|
+
let t = Math.max(0, Math.min(this._steps.length - 1, Math.trunc(this.step) || 0));
|
|
186
|
+
if (this.step !== t) {
|
|
187
|
+
this.step = t;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
let r = this._steps[t], i = this._findTarget(r?.target);
|
|
191
|
+
if (!i || !this._isVisible(i)) {
|
|
192
|
+
this._close("target-unavailable");
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
let a = this.shadowRoot.querySelector(".surface");
|
|
196
|
+
if (!a.matches(":popover-open")) {
|
|
197
|
+
this._shownStorageKey = this.storageKey;
|
|
198
|
+
let e = document.activeElement;
|
|
199
|
+
for (; e?.shadowRoot?.activeElement;) e = e.shadowRoot.activeElement;
|
|
200
|
+
e instanceof HTMLElement && (this._returnFocus = e);
|
|
201
|
+
}
|
|
202
|
+
this._target = i;
|
|
203
|
+
let o = i.getBoundingClientRect();
|
|
204
|
+
if ((o.top < 0 || o.bottom > innerHeight || o.left < 0 || o.right > innerWidth) && i.scrollIntoView({
|
|
205
|
+
block: "center",
|
|
206
|
+
inline: "nearest",
|
|
207
|
+
behavior: "instant"
|
|
208
|
+
}), !n(a, i)) {
|
|
209
|
+
this._close("target-unavailable");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
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 = [];
|
|
213
|
+
let s = i.getRootNode();
|
|
214
|
+
for (; s instanceof ShadowRoot;) s.addEventListener("scroll", this._schedulePosition, !0), this._scrollRoots.push(s), s = s.host.getRootNode();
|
|
215
|
+
this._position(), a.focus({ preventScroll: !0 }), this.dispatchEvent(new CustomEvent("stepchange", {
|
|
216
|
+
detail: {
|
|
217
|
+
step: t,
|
|
218
|
+
total: this._steps.length
|
|
219
|
+
},
|
|
220
|
+
bubbles: !0,
|
|
221
|
+
composed: !0
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
_isVisible(e) {
|
|
225
|
+
let t = getComputedStyle(e), n = e.getBoundingClientRect();
|
|
226
|
+
return e.isConnected && t.visibility !== "hidden" && n.width > 0 && n.height > 0;
|
|
227
|
+
}
|
|
228
|
+
_position() {
|
|
229
|
+
let e = this._target, t = this.shadowRoot?.querySelector(".surface");
|
|
230
|
+
if (!this.open || !t || !e) return;
|
|
231
|
+
if (!this._isVisible(e)) {
|
|
232
|
+
this._close("target-unavailable");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
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";
|
|
236
|
+
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))`);
|
|
237
|
+
let u = Math.max(r, Math.min(a.left + a.width / 2 - o.width / 2, innerWidth - o.width - r));
|
|
238
|
+
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`);
|
|
239
|
+
}
|
|
240
|
+
render() {
|
|
241
|
+
let e = this._steps[this.step], t = this.stepLabel.replace("{current}", String(this.step + 1)).replace("{total}", String(this._steps.length));
|
|
242
|
+
return o`
|
|
243
|
+
<slot name="trigger" @click=${(e) => {
|
|
244
|
+
e.defaultPrevented || this.start();
|
|
245
|
+
}}></slot>
|
|
246
|
+
<slot></slot>
|
|
247
|
+
<section class="surface" part="surface" popover="manual" role="dialog" tabindex="-1"
|
|
248
|
+
aria-labelledby="heading" aria-describedby="content counter" @keydown=${this._onKeydown}>
|
|
249
|
+
<span class="arrow" part="arrow" aria-hidden="true"></span>
|
|
250
|
+
<div class="body">
|
|
251
|
+
<div class="header">
|
|
252
|
+
<h2 id="heading">${e?.heading}</h2>
|
|
253
|
+
<scb-icon-button size="small" icon="close" aria-label=${this.closeLabel} @click=${this.close}></scb-icon-button>
|
|
254
|
+
</div>
|
|
255
|
+
<p id="content">${e?.content}</p>
|
|
256
|
+
<div class="footer">
|
|
257
|
+
<span id="counter" class="counter">${t}</span>
|
|
258
|
+
<div class="actions">
|
|
259
|
+
<scb-button variant="text" size="small" .label=${this.previousLabel} ?disabled=${this.step <= 0} @click=${() => this.step--}></scb-button>
|
|
260
|
+
<scb-button size="small" .label=${this.step === this._steps.length - 1 ? this.doneLabel : this.nextLabel} @click=${this._next}></scb-button>
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
</section>
|
|
265
|
+
`;
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
e([c({
|
|
269
|
+
type: Boolean,
|
|
270
|
+
reflect: !0,
|
|
271
|
+
converter: u
|
|
272
|
+
})], d.prototype, "open", void 0), e([c({
|
|
273
|
+
type: Boolean,
|
|
274
|
+
attribute: "auto-start",
|
|
275
|
+
converter: u
|
|
276
|
+
})], d.prototype, "autoStart", void 0), e([c({
|
|
277
|
+
type: String,
|
|
278
|
+
attribute: "storage-key"
|
|
279
|
+
})], d.prototype, "storageKey", void 0), e([c({
|
|
280
|
+
type: Number,
|
|
281
|
+
reflect: !0
|
|
282
|
+
})], 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);
|
|
283
|
+
//#endregion
|
|
284
|
+
export { d as ScbTour };
|