@sbb-esta/lyne-elements-dev 5.13.3-dev.1795422812 → 5.13.3-dev.1795428541
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/custom-elements.json
CHANGED
|
@@ -121515,19 +121515,19 @@
|
|
|
121515
121515
|
"privacy": "public",
|
|
121516
121516
|
"description": "The positions of the tooltip, relative to the trigger.\nProvide either a comma-separated list or an array of positions.\nThe first entry is the primary position (`--sbb-overlay-position-area`),\nthe following ones are the fallback positions (`--sbb-overlay-position-try-fallbacks`).\nIf not set, the default positions of the trigger (`tooltipPositions`) or the CSS variables are used.",
|
|
121517
121517
|
"type": {
|
|
121518
|
-
"text": "string[]
|
|
121518
|
+
"text": "string[]"
|
|
121519
121519
|
},
|
|
121520
121520
|
"attribute": "positions",
|
|
121521
|
-
"default": "
|
|
121521
|
+
"default": "[]"
|
|
121522
121522
|
},
|
|
121523
121523
|
{
|
|
121524
121524
|
"kind": "field",
|
|
121525
121525
|
"name": "_positions",
|
|
121526
121526
|
"type": {
|
|
121527
|
-
"text": "string[]
|
|
121527
|
+
"text": "string[]"
|
|
121528
121528
|
},
|
|
121529
121529
|
"privacy": "private",
|
|
121530
|
-
"default": "
|
|
121530
|
+
"default": "[]"
|
|
121531
121531
|
},
|
|
121532
121532
|
{
|
|
121533
121533
|
"kind": "field",
|
|
@@ -122344,7 +122344,7 @@
|
|
|
122344
122344
|
"name": "positions",
|
|
122345
122345
|
"description": "The positions of the tooltip, relative to the trigger.\nProvide either a comma-separated list or an array of positions.\nThe first entry is the primary position (`--sbb-overlay-position-area`),\nthe following ones are the fallback positions (`--sbb-overlay-position-try-fallbacks`).\nIf not set, the default positions of the trigger (`tooltipPositions`) or the CSS variables are used.",
|
|
122346
122346
|
"type": {
|
|
122347
|
-
"text": "string[]
|
|
122347
|
+
"text": "string[]"
|
|
122348
122348
|
},
|
|
122349
122349
|
"fieldName": "positions"
|
|
122350
122350
|
},
|
|
@@ -64,7 +64,7 @@ export declare class SbbTooltipElement extends SbbTooltipElement_base {
|
|
|
64
64
|
* If not set, the default positions of the trigger (`tooltipPositions`) or the CSS variables are used.
|
|
65
65
|
*/
|
|
66
66
|
set positions(value: string | string[] | null);
|
|
67
|
-
get positions(): string[]
|
|
67
|
+
get positions(): string[];
|
|
68
68
|
private _positions;
|
|
69
69
|
private _triggerElement;
|
|
70
70
|
private _triggerAbortController?;
|
|
@@ -193,8 +193,8 @@ let SbbTooltipElement = (() => {
|
|
|
193
193
|
* If not set, the default positions of the trigger (`tooltipPositions`) or the CSS variables are used.
|
|
194
194
|
*/
|
|
195
195
|
set positions(value) {
|
|
196
|
-
if (typeof value === "string") this._positions = value?.split(",").map((p) => p.trim()).filter(Boolean) ??
|
|
197
|
-
else this._positions = value;
|
|
196
|
+
if (typeof value === "string") this._positions = value?.split(",").map((p) => p.trim()).filter(Boolean) ?? [];
|
|
197
|
+
else this._positions = value ?? [];
|
|
198
198
|
}
|
|
199
199
|
get positions() {
|
|
200
200
|
return this._positions;
|
|
@@ -204,7 +204,7 @@ let SbbTooltipElement = (() => {
|
|
|
204
204
|
this.#trigger_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _trigger_initializers, null));
|
|
205
205
|
this._openDelay = (__runInitializers(this, _trigger_extraInitializers), null);
|
|
206
206
|
this._closeDelay = null;
|
|
207
|
-
this._positions =
|
|
207
|
+
this._positions = [];
|
|
208
208
|
this._triggerElement = null;
|
|
209
209
|
this._escapableOverlayController = new SbbEscapableOverlayController(this);
|
|
210
210
|
this._overlayController = new SbbOverlayPositionController(this);
|
|
@@ -231,6 +231,7 @@ let SbbTooltipElement = (() => {
|
|
|
231
231
|
"sbb-tooltip-open-delay",
|
|
232
232
|
"sbb-tooltip-close-delay",
|
|
233
233
|
"sbb-tooltip-position",
|
|
234
|
+
"sbb-tooltip-positions",
|
|
234
235
|
"sbb-tooltip-disabled"
|
|
235
236
|
],
|
|
236
237
|
childList: true,
|
|
@@ -255,7 +256,8 @@ let SbbTooltipElement = (() => {
|
|
|
255
256
|
tooltip.openDelay = triggerElement.hasAttribute("sbb-tooltip-open-delay") ? +triggerElement.getAttribute("sbb-tooltip-open-delay") : null;
|
|
256
257
|
tooltip.closeDelay = triggerElement.hasAttribute("sbb-tooltip-close-delay") ? +triggerElement.getAttribute("sbb-tooltip-close-delay") : null;
|
|
257
258
|
tooltip.disabled = triggerElement.hasAttribute("sbb-tooltip-disabled");
|
|
258
|
-
tooltip.positions = triggerElement.getAttribute("sbb-tooltip-position");
|
|
259
|
+
tooltip.positions = triggerElement.getAttribute("sbb-tooltip-positions") ?? triggerElement.getAttribute("sbb-tooltip-position");
|
|
260
|
+
if (triggerElement.hasAttribute("sbb-tooltip-position")) console.warn("The `sbb-tooltip-position` attribute is deprecated. Use `sbb-tooltip-positions` instead.");
|
|
259
261
|
} else if (tooltip) {
|
|
260
262
|
tooltipTriggers.delete(triggerElement);
|
|
261
263
|
tooltip._destroy?.();
|
|
@@ -284,7 +286,7 @@ let SbbTooltipElement = (() => {
|
|
|
284
286
|
updated(changedProperties) {
|
|
285
287
|
super.updated(changedProperties);
|
|
286
288
|
if (changedProperties.has("positions") || changedProperties.has("trigger")) {
|
|
287
|
-
const positions = this._positions
|
|
289
|
+
const positions = this._positions.length ? this._positions : this.trigger?.tooltipPositions;
|
|
288
290
|
if (positions?.length) {
|
|
289
291
|
const positionTryFallbacks = positions.slice(1).join(", ");
|
|
290
292
|
this.dynamicStyleSheet?.replaceSync(`:host {--sbb-overlay-position-area: ${positions[0]};${positionTryFallbacks.length ? ` --sbb-overlay-position-try-fallbacks: ${positionTryFallbacks}};` : ""}`);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbb-esta/lyne-elements-dev",
|
|
3
|
-
"version": "5.13.3-dev.
|
|
3
|
+
"version": "5.13.3-dev.1795428541",
|
|
4
4
|
"description": "Lyne Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design system",
|
|
7
7
|
"web components",
|
|
8
8
|
"lit",
|
|
9
|
-
"https://github.com/sbb-design-systems/lyne-components/commit/
|
|
9
|
+
"https://github.com/sbb-design-systems/lyne-components/commit/5fef59a2e14e33b62f43b0095d1d16021044f171"
|
|
10
10
|
],
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
package/tooltip.pure.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isServer as r,unsafeCSS as i}from"lit";import{property as a}from"lit/decorators.js";import{SbbDisabledMixin as o,SbbDynamicStylesheetMixin as s,SbbEscapableOverlayController as c,SbbOpenCloseBaseElement as l,SbbOverlayPositionController as u,appendAriaElements as d,idReference as f,isAndroid as p,isIOS as m,isZeroAnimationDuration as h,popoverResetStyles as g,queueDomContentLoaded as _,readConfig as v,removeAriaElements as y,sbbInputModalityDetector as b,sbbOverlayOutsidePointerEventListener as x}from"./core.js";var S=`:host{--sbb-tooltip-max-width:min(25rem, calc(100vw - var(--sbb-spacing-fixed-2x)));--sbb-tooltip-animation-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-4x));position-area:var(--sbb-overlay-position-area);position-try-fallbacks:var(--sbb-overlay-position-try-fallbacks);pointer-events:var(--sbb-tooltip-pointer-events,all);z-index:var(--sbb-tooltip-z-index,var(--sbb-overlay-default-z-index));animation-name:var(--sbb-tooltip-animation-name);animation-duration:var(--sbb-tooltip-animation-duration);animation-timing-function:var(--sbb-tooltip-animation-easing);font-size:var(--sbb-tooltip-font-size);letter-spacing:var(--sbb-letter-spacing-text);line-height:var(--sbb-typo-line-height-text);display:none;position:fixed}:host(:is(:is(:state(state-opening),[state--state-opening]),:is(:state(state-opened),[state--state-opened]),:is(:state(state-closing),[state--state-closing]))){--sbb-tooltip-animation-name:open;display:block}:host(:is(:state(state-closing),[state--state-closing])){--sbb-tooltip-animation-name:close;--sbb-tooltip-pointer-events:none}:host(:is([data-position~=block-end],[data-position~=bottom],[data-position^=end])){padding-block-start:var(--sbb-tooltip-gap)}:host(:is([data-position~=block-start],[data-position~=top],[data-position^=start])){padding-block-end:var(--sbb-tooltip-gap)}:host(:is([data-position~=inline-start],[data-position~=inline-end],[data-position~=left],[data-position~=right],[data-position$=\\ start],[data-position$=\\ end])){padding-inline:var(--sbb-tooltip-gap)}.sbb-tooltip{box-shadow:var(--sbb-box-shadow-level-5-soft);border:var(--sbb-border-width-1x) solid var(--sbb-tooltip-border-color);border-radius:var(--sbb-tooltip-border-radius);padding:var(--sbb-tooltip-padding);color:var(--sbb-tooltip-color);background-color:var(--sbb-tooltip-background-color);min-width:var(--sbb-tooltip-min-width);max-width:var(--sbb-tooltip-max-width)}@keyframes open{0%{opacity:0;translate:var(--sbb-tooltip-animation-translate)}to{opacity:1;translate:0}}@keyframes close{0%{opacity:1;translate:0}to{opacity:0;translate:var(--sbb-tooltip-animation-translate)}}
|
|
2
|
-
`;const C=p||m,w=/* @__PURE__ */ new WeakMap;let T=(()=>{let p=s(o(l)),m=[],T,E=[],D=[],O,k,A,j;return class extends p{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(p[Symbol.metadata]??null):void 0;T=[f(),a()],O=[a({attribute:`open-delay`,type:Number})],k=[a({attribute:`close-delay`,type:Number})],A=[a({attribute:`long-press-close-delay`,type:Number})],j=[a()],e(this,null,T,{kind:`accessor`,name:`trigger`,static:!1,private:!1,access:{has:e=>`trigger`in e,get:e=>e.trigger,set:(e,t)=>{e.trigger=t}},metadata:t},E,D),e(this,null,O,{kind:`setter`,name:`openDelay`,static:!1,private:!1,access:{has:e=>`openDelay`in e,set:(e,t)=>{e.openDelay=t}},metadata:t},null,m),e(this,null,k,{kind:`setter`,name:`closeDelay`,static:!1,private:!1,access:{has:e=>`closeDelay`in e,set:(e,t)=>{e.closeDelay=t}},metadata:t},null,m),e(this,null,A,{kind:`setter`,name:`longPressCloseDelay`,static:!1,private:!1,access:{has:e=>`longPressCloseDelay`in e,set:(e,t)=>{e.longPressCloseDelay=t}},metadata:t},null,m),e(this,null,j,{kind:`setter`,name:`positions`,static:!1,private:!1,access:{has:e=>`positions`in e,set:(e,t)=>{e.positions=t}},metadata:t},null,m),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-tooltip`}static{this.role=`tooltip`}static{this.styles=[g,i(S)]}static{r||_(()=>this._initializeTooltipOutlet())}#e;get trigger(){return this.#e}set trigger(e){this.#e=e}set openDelay(e){this._openDelay=e}get openDelay(){return this._openDelay??v().tooltip?.openDelay??0}set closeDelay(e){this._closeDelay=e}get closeDelay(){return this._closeDelay??v().tooltip?.closeDelay??0}set longPressCloseDelay(e){this._longPressCloseDelay=+e}get longPressCloseDelay(){return this._longPressCloseDelay??v().tooltip?.longPressCloseDelay??1500}set positions(e){this._positions=typeof e==`string`?e?.split(`,`).map(e=>e.trim()).filter(Boolean)??
|
|
2
|
+
`;const C=p||m,w=/* @__PURE__ */ new WeakMap;let T=(()=>{let p=s(o(l)),m=[],T,E=[],D=[],O,k,A,j;return class extends p{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(p[Symbol.metadata]??null):void 0;T=[f(),a()],O=[a({attribute:`open-delay`,type:Number})],k=[a({attribute:`close-delay`,type:Number})],A=[a({attribute:`long-press-close-delay`,type:Number})],j=[a()],e(this,null,T,{kind:`accessor`,name:`trigger`,static:!1,private:!1,access:{has:e=>`trigger`in e,get:e=>e.trigger,set:(e,t)=>{e.trigger=t}},metadata:t},E,D),e(this,null,O,{kind:`setter`,name:`openDelay`,static:!1,private:!1,access:{has:e=>`openDelay`in e,set:(e,t)=>{e.openDelay=t}},metadata:t},null,m),e(this,null,k,{kind:`setter`,name:`closeDelay`,static:!1,private:!1,access:{has:e=>`closeDelay`in e,set:(e,t)=>{e.closeDelay=t}},metadata:t},null,m),e(this,null,A,{kind:`setter`,name:`longPressCloseDelay`,static:!1,private:!1,access:{has:e=>`longPressCloseDelay`in e,set:(e,t)=>{e.longPressCloseDelay=t}},metadata:t},null,m),e(this,null,j,{kind:`setter`,name:`positions`,static:!1,private:!1,access:{has:e=>`positions`in e,set:(e,t)=>{e.positions=t}},metadata:t},null,m),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-tooltip`}static{this.role=`tooltip`}static{this.styles=[g,i(S)]}static{r||_(()=>this._initializeTooltipOutlet())}#e;get trigger(){return this.#e}set trigger(e){this.#e=e}set openDelay(e){this._openDelay=e}get openDelay(){return this._openDelay??v().tooltip?.openDelay??0}set closeDelay(e){this._closeDelay=e}get closeDelay(){return this._closeDelay??v().tooltip?.closeDelay??0}set longPressCloseDelay(e){this._longPressCloseDelay=+e}get longPressCloseDelay(){return this._longPressCloseDelay??v().tooltip?.longPressCloseDelay??1500}set positions(e){this._positions=typeof e==`string`?e?.split(`,`).map(e=>e.trim()).filter(Boolean)??[]:e??[]}get positions(){return this._positions}constructor(){super(),this.#e=(t(this,m),t(this,E,null)),this._openDelay=(t(this,D),null),this._closeDelay=null,this._positions=[],this._triggerElement=null,this._escapableOverlayController=new c(this),this._overlayController=new u(this),this._isOutsidePointerListenerConnected=!1,this.addEventListener(`mouseleave`,e=>{this.state!==`opened`&&this.state!==`opening`||e.relatedTarget&&this._triggerElement?.contains(e.relatedTarget)||this._delayedClose()},{passive:!0}),this.addEventListener(`overlayOutsidePointer`,()=>this.close(),{passive:!0}),this.addEventListener(`animationend`,e=>this._onTooltipAnimationEnd(e),{passive:!0})}static _initializeTooltipOutlet(){this._tooltipOutlet=document.createElement(`div`),this._tooltipOutlet.classList.add(`sbb-overlay-outlet`),document.body.appendChild(this._tooltipOutlet),new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`)this._handleTooltipTrigger(t.target);else if(t.type===`childList`)for(let e of[...t.addedNodes,...t.removedNodes].filter(e=>e.nodeType===e.ELEMENT_NODE))this._handleTooltipTrigger(e),this._findAndHandleTooltipTriggers(e)}).observe(document.documentElement,{attributeFilter:[`sbb-tooltip`,`sbb-tooltip-open-delay`,`sbb-tooltip-close-delay`,`sbb-tooltip-position`,`sbb-tooltip-positions`,`sbb-tooltip-disabled`],childList:!0,subtree:!0}),this._findAndHandleTooltipTriggers(document.body)}static _findAndHandleTooltipTriggers(e){e.querySelectorAll(`[sbb-tooltip]`).forEach(e=>this._handleTooltipTrigger(e))}static _handleTooltipTrigger(e){let t=e.getAttribute(`sbb-tooltip`),n=w.get(e);t&&e.isConnected?(n||(n=document.createElement(`sbb-tooltip`),w.set(e,n),this._tooltipOutlet.appendChild(n),n.trigger=e),n.textContent=t,n.openDelay=e.hasAttribute(`sbb-tooltip-open-delay`)?+e.getAttribute(`sbb-tooltip-open-delay`):null,n.closeDelay=e.hasAttribute(`sbb-tooltip-close-delay`)?+e.getAttribute(`sbb-tooltip-close-delay`):null,n.disabled=e.hasAttribute(`sbb-tooltip-disabled`),n.positions=e.getAttribute(`sbb-tooltip-positions`)??e.getAttribute(`sbb-tooltip-position`)):n&&(w.delete(e),n._destroy?.())}connectedCallback(){super.connectedCallback(),this.popover=`manual`,this.state=`closed`,this.hasUpdated&&this.trigger&&this._attach(this.trigger)}disconnectedCallback(){super.disconnectedCallback(),this._detach(),this._isOutsidePointerListenerConnected&&=(x.disconnect(this),!1)}requestUpdate(e,t,n){super.requestUpdate(e,t,n),r||((!e||e===`trigger`)&&this.hasUpdated?this._attach(this.trigger):e===`disabled`&&this._updateTriggerDescription())}updated(e){if(super.updated(e),e.has(`positions`)||e.has(`trigger`)){let e=this._positions.length?this._positions:this.trigger?.tooltipPositions;if(e?.length){let t=e.slice(1).join(`, `);this.dynamicStyleSheet?.replaceSync(`:host {--sbb-overlay-position-area: ${e[0]};${t.length?` --sbb-overlay-position-try-fallbacks: ${t}};`:``}`)}else this.dynamicStyleSheet?.replaceSync(``)}}firstUpdated(e){super.firstUpdated(e),this._attach(this.trigger)}open(){this._resetOpenCloseTimeout(),this.state!==`closed`&&this.state!==`closing`||this.disabled||!this.trigger||!this.dispatchBeforeOpenEvent()||(this.showPopover?.(),this.state=`opening`,this._updateOutsidePointerListener(),this._overlayController.connect(this.trigger),this._isZeroAnimationDuration()&&this._handleOpening())}close(){this._resetOpenCloseTimeout(),(this.state===`opened`||this.state===`opening`)&&(this.dispatchBeforeCloseEvent(),this.state=`closing`,this._isZeroAnimationDuration()&&this._handleClosing())}_delayedOpen(){this._resetOpenCloseTimeout(),this._openTimeout=setTimeout(()=>this.open(),this.openDelay),this._updateOutsidePointerListener()}_handleOpening(){this.state=`opened`,this._escapableOverlayController.connect(),this.dispatchOpenEvent()}_delayedClose(){this._resetOpenCloseTimeout(),this._closeTimeout=setTimeout(()=>this.close(),this.closeDelay)}_handleClosing(){this.state=`closed`,this._updateOutsidePointerListener(),this.hidePopover?.(),this._overlayController.disconnect(),this._escapableOverlayController.disconnect(),this.dispatchCloseEvent(),this._openStateController?.abort()}_onTooltipAnimationEnd(e){e.animationName===`open`&&this.state===`opening`?this._handleOpening():e.animationName===`close`&&this.state===`closing`&&this._handleClosing()}_attach(e){this._triggerElement&&this._detach(),this._triggerElement=e,this._triggerElement&&(this._updateTriggerDescription(),this._addTriggerEventHandlers())}_updateTriggerDescription(){if(!this._triggerElement)return;let e=y(this._triggerElement.ariaDescribedByElements,this);this._triggerElement.ariaDescribedByElements=this.disabled?e:d(e,this)}_detach(){this._triggerAbortController?.abort(),this._openStateController?.abort(),this._resetOpenCloseTimeout(),clearTimeout(this._longPressCloseTimeout),this._triggerElement&&=(this._triggerElement.ariaDescribedByElements=y(this._triggerElement.ariaDescribedByElements,this),null)}_destroy(){this._detach(),this.remove()}_addTriggerEventHandlers(){let e=this._triggerElement;if(!e)return;this._triggerAbortController?.abort(),this._triggerAbortController=new AbortController;let t={signal:this._triggerAbortController.signal,passive:!0};C||(e.addEventListener(`mouseenter`,()=>this._delayedOpen(),t),e.addEventListener(`mouseleave`,e=>{let t=e.relatedTarget;t&&t===this||this._delayedClose()},t),e.addEventListener(`blur`,()=>this.close(),t),e.addEventListener(`focus`,()=>{b.mostRecentModality===`keyboard`&&this._delayedOpen()},t)),e.addEventListener(`touchstart`,()=>{clearTimeout(this._longPressOpenTimeout),clearTimeout(this._longPressCloseTimeout),this._longPressOpenTimeout=setTimeout(()=>this.open(),500),this._updateOutsidePointerListener()},t),e.addEventListener(`touchend`,()=>{clearTimeout(this._longPressOpenTimeout),this._longPressOpenTimeout=void 0,this._longPressCloseTimeout=setTimeout(()=>this.close(),this.longPressCloseDelay),this._updateOutsidePointerListener()},t),e.addEventListener(`touchcancel`,()=>{clearTimeout(this._longPressOpenTimeout),this._longPressOpenTimeout=void 0,this._updateOutsidePointerListener()},t)}_isZeroAnimationDuration(){return h(this,`--sbb-tooltip-animation-duration`)}_resetOpenCloseTimeout(){clearTimeout(this._openTimeout),clearTimeout(this._closeTimeout),clearTimeout(this._longPressOpenTimeout),this._openTimeout=void 0,this._closeTimeout=void 0,this._longPressOpenTimeout=void 0,this._updateOutsidePointerListener()}_updateOutsidePointerListener(){let e=this.isConnected&&(this.state!==`closed`||this._openTimeout!==void 0||this._longPressOpenTimeout!==void 0);e!==this._isOutsidePointerListenerConnected&&(this._isOutsidePointerListenerConnected=e,e?x.connect(this):x.disconnect(this))}render(){return n`
|
|
3
3
|
<div class="sbb-tooltip">
|
|
4
4
|
<slot></slot>
|
|
5
5
|
</div>
|