@nysds/components 1.4.4 → 1.4.6
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/dist/nysds.es.js +155 -139
- package/dist/nysds.es.js.map +1 -1
- package/dist/nysds.js +12 -2
- package/dist/nysds.js.map +1 -1
- package/dist/packages/nys-tooltip/src/nys-tooltip.d.ts +1 -1
- package/package.json +1 -1
package/dist/nysds.js
CHANGED
|
@@ -3885,7 +3885,17 @@ ${this.value}</textarea
|
|
|
3885
3885
|
--_nys-tooltip-color: var(--nys-color-text-reverse, #ffffff);
|
|
3886
3886
|
--_nys-tooltip-background: var(--nys-color-ink, #1b1b1b);
|
|
3887
3887
|
--_nys-tooltip-border-radius: var(--nys-radius-md, 4px);
|
|
3888
|
-
--_nys-tooltip-font-family: var(
|
|
3888
|
+
--_nys-tooltip-font-family: var(
|
|
3889
|
+
--nys-font-family-ui,
|
|
3890
|
+
var(
|
|
3891
|
+
--nys-font-family-sans,
|
|
3892
|
+
"Proxima Nova",
|
|
3893
|
+
"Helvetica Neue",
|
|
3894
|
+
"Helvetica",
|
|
3895
|
+
"Arial",
|
|
3896
|
+
sans-serif
|
|
3897
|
+
)
|
|
3898
|
+
);
|
|
3889
3899
|
--_nys-tooltip-font-size: var(--nys-type-size-ui-sm, 14px);
|
|
3890
3900
|
--_nys-tooltip-letterspacing: var(--nys-font-letterspacing-ui-sm, 0.044px);
|
|
3891
3901
|
--_nys-tooltip-lineheight: var(--nys-font-lineheight-ui-sm, 24px);
|
|
@@ -4025,7 +4035,7 @@ ${this.value}</textarea
|
|
|
4025
4035
|
); /* 2rem = 32px = 16px margin on each side */
|
|
4026
4036
|
}
|
|
4027
4037
|
}
|
|
4028
|
-
`;var f2=Object.defineProperty,g2=Object.getOwnPropertyDescriptor,S1=(a,e,t,o)=>{for(var s=o>1?void 0:o?g2(e,t):e,r=a.length-1,i;r>=0;r--)(i=a[r])&&(s=(o?i(e,t,s):i(s))||s);return o&&s&&f2(e,t,s),s};let v2=0;const ne=class ne extends g{constructor(){super(),this.id="",this.text="",this.inverted=!1,this.focusable=!1,this._active=!1,this._userHasSetPosition=!1,this._originalUserPosition=null,this._internallyUpdatingPosition=!1,this._position=null,this._handleTooltipEnter=()=>{if(this._active=!0,this._addScrollListeners(),this._userHasSetPosition&&this._originalUserPosition&&this._doesPositionFit(this._originalUserPosition)){this.position=this._originalUserPosition,this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");e&&this._shiftTooltipIntoViewport(e)});return}this.autoPositionTooltip()},this._handleBlurOrMouseLeave=()=>{var t;this._active=!1,this._removeScrollListeners();const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");e&&this._resetTooltipPositioningStyles(e)},this._handleScrollOrResize=()=>{this._active&&(this._userHasSetPosition&&this._originalUserPosition?this._doesPositionFit(this._originalUserPosition)?(this._setInternalPosition(this._originalUserPosition),this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");e&&this._shiftTooltipIntoViewport(e)})):this.autoPositionTooltip():this.autoPositionTooltip())},this._handleEscapeKey=e=>{var t;if(e.key==="Escape"&&this._active){this._active=!1,this._removeScrollListeners();const o=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");o&&this._resetTooltipPositioningStyles(o)}}}get position(){return this._position}set position(e){const t=this._position;this._position=e,this.requestUpdate("position",t),this._internallyUpdatingPosition||(this._userHasSetPosition=e!==null,this._originalUserPosition=e)}connectedCallback(){super.connectedCallback(),this.id||(this.id=`nys-tooltip-${Date.now()}-${v2++}`),window.addEventListener("keydown",this._handleEscapeKey)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this._handleEscapeKey)}get _firstAssignedEl(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");return e==null?void 0:e.assignedElements({flatten:!0})[0]}firstUpdated(){const e=this._firstAssignedEl;e&&this._applyFocusBehavior(e)}updated(e){super.updated(e);const t=this._firstAssignedEl;t&&e.has("text")&&this.
|
|
4038
|
+
`;var f2=Object.defineProperty,g2=Object.getOwnPropertyDescriptor,S1=(a,e,t,o)=>{for(var s=o>1?void 0:o?g2(e,t):e,r=a.length-1,i;r>=0;r--)(i=a[r])&&(s=(o?i(e,t,s):i(s))||s);return o&&s&&f2(e,t,s),s};let v2=0;const ne=class ne extends g{constructor(){super(),this.id="",this.text="",this.inverted=!1,this.focusable=!1,this._active=!1,this._userHasSetPosition=!1,this._originalUserPosition=null,this._internallyUpdatingPosition=!1,this._position=null,this._handleTooltipEnter=()=>{if(this._active=!0,this._addScrollListeners(),this._userHasSetPosition&&this._originalUserPosition&&this._doesPositionFit(this._originalUserPosition)){this.position=this._originalUserPosition,this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");e&&this._shiftTooltipIntoViewport(e)});return}this.autoPositionTooltip()},this._handleBlurOrMouseLeave=()=>{var t;this._active=!1,this._removeScrollListeners();const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");e&&this._resetTooltipPositioningStyles(e)},this._handleScrollOrResize=()=>{this._active&&(this._userHasSetPosition&&this._originalUserPosition?this._doesPositionFit(this._originalUserPosition)?(this._setInternalPosition(this._originalUserPosition),this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");e&&this._shiftTooltipIntoViewport(e)})):this.autoPositionTooltip():this.autoPositionTooltip())},this._handleEscapeKey=e=>{var t;if(e.key==="Escape"&&this._active){this._active=!1,this._removeScrollListeners();const o=(t=this.shadowRoot)==null?void 0:t.querySelector(".nys-tooltip__content");o&&this._resetTooltipPositioningStyles(o)}}}get position(){return this._position}set position(e){const t=this._position;this._position=e,this.requestUpdate("position",t),this._internallyUpdatingPosition||(this._userHasSetPosition=e!==null,this._originalUserPosition=e)}connectedCallback(){super.connectedCallback(),this.id||(this.id=`nys-tooltip-${Date.now()}-${v2++}`),window.addEventListener("keydown",this._handleEscapeKey)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this._handleEscapeKey)}get _firstAssignedEl(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");return e==null?void 0:e.assignedElements({flatten:!0})[0]}firstUpdated(){const e=this._firstAssignedEl;e&&this._applyFocusBehavior(e)}updated(e){super.updated(e);const t=this._firstAssignedEl;t&&e.has("text")&&this._passAria(t)}_addScrollListeners(){window.addEventListener("scroll",this._handleScrollOrResize,!0),window.addEventListener("resize",this._handleScrollOrResize)}_removeScrollListeners(){window.removeEventListener("scroll",this._handleScrollOrResize,!0),window.removeEventListener("resize",this._handleScrollOrResize)}_passAria(e){const t=e.tagName.toLowerCase();if(t.startsWith("nys-"))if(t==="nys-icon"){const o=e.getAttribute("ariaLabel")||"",s=o?`${o}, ${this.text}`:this.text;e.setAttribute("ariaLabel",s)}else e.setAttribute("ariaDescription",this.text)}async _applyFocusBehavior(e){var o;if(!this.focusable)return;if(e.tagName.toLowerCase()==="nys-icon"){"updateComplete"in e&&await e.updateComplete;const s=(o=e.shadowRoot)==null?void 0:o.querySelector("svg");s&&s.setAttribute("tabindex","0")}else e.setAttribute("tabindex","0")}_doesPositionFit(e){var u,p;const t=(u=this.shadowRoot)==null?void 0:u.querySelector(".nys-tooltip__wrapper"),o=(p=this.shadowRoot)==null?void 0:p.querySelector(".nys-tooltip__content");if(!t||!o||e==null)return;const s=t.getBoundingClientRect(),r=o.getBoundingClientRect(),i=8,c={top:s.top-i,left:s.left-i,bottom:window.innerHeight-s.bottom-i,right:window.innerWidth-s.right-i};return{top:c.top>=r.height,bottom:c.bottom>=r.height,left:c.left>=r.width,right:c.right>=r.width}[e]}async autoPositionTooltip(){var u,p;const e=(u=this.shadowRoot)==null?void 0:u.querySelector(".nys-tooltip__wrapper"),t=(p=this.shadowRoot)==null?void 0:p.querySelector(".nys-tooltip__content");if(!e||!t)return;const o=e.getBoundingClientRect(),s=8,r={top:o.top-s,left:o.left-s,bottom:window.innerHeight-o.bottom-s,right:window.innerWidth-o.right-s};let i=["top","bottom","right","left"];if(this._userHasSetPosition&&this._originalUserPosition){const d=this._originalUserPosition;d==="left"?i=["left","right","top","bottom"]:d==="right"?i=["right","left","top","bottom"]:d==="top"?i=["top","bottom","right","left"]:d==="bottom"&&(i=["bottom","top","right","left"])}for(const d of i)if(this._doesPositionFit(d)){this._setInternalPosition(d),await this.updateComplete,this._shiftTooltipIntoViewport(t);return}let c="top",h=r.top;for(const d of i)r[d]>h&&(h=r[d],c=d);this._setInternalPosition(c),await this.updateComplete,this._shiftTooltipIntoViewport(t)}_setInternalPosition(e){this._internallyUpdatingPosition=!0,this.position=e,this._internallyUpdatingPosition=!1}_shiftTooltipIntoViewport(e){var d;const o=((d=this.shadowRoot)==null?void 0:d.querySelector(".nys-tooltip__wrapper")).getBoundingClientRect(),s=e.getBoundingClientRect(),r=o.left+o.width/2,i=s.left<0,c=s.right>window.innerWidth;this._resetTooltipPositioningStyles(e),i?(e.style.left="0px",e.style.transform="none"):c&&(e.style.right="0px",e.style.left="auto",e.style.transform="none");const h=e.getBoundingClientRect(),u=(r-h.left)/h.width,p=Math.max(0,Math.min(1,u))*100;e.style.setProperty("--arrow-offset-x",`${p}%`)}_resetTooltipPositioningStyles(e){e.style.left="",e.style.right="",e.style.transform=""}render(){var e;return l`
|
|
4029
4039
|
<div class="nys-tooltip__main">
|
|
4030
4040
|
<div
|
|
4031
4041
|
class="nys-tooltip__wrapper"
|