@nysds/nys-tooltip 1.11.2 → 1.11.3
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/nys-tooltip.js +77 -534
- package/dist/nys-tooltip.js.map +1 -1
- package/package.json +4 -4
- package/dist/index.d.ts +0 -1
- package/dist/nys-tooltip.d.ts +0 -39
- package/dist/nys-tooltip.figma.d.ts +0 -1
- package/dist/nys-tooltip.styles.d.ts +0 -2
package/dist/nys-tooltip.js
CHANGED
|
@@ -1,470 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Part of the New York State Design System
|
|
9
|
-
* Repository: https://github.com/its-hcd/nysds
|
|
10
|
-
* License: MIT
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @license
|
|
14
|
-
* Copyright 2019 Google LLC
|
|
15
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
-
*/
|
|
17
|
-
const _ = globalThis, m = _.ShadowRoot && (_.ShadyCSS === void 0 || _.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, x = Symbol(), S = /* @__PURE__ */ new WeakMap();
|
|
18
|
-
let O = class {
|
|
19
|
-
constructor(t, e, o) {
|
|
20
|
-
if (this._$cssResult$ = !0, o !== x) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
21
|
-
this.cssText = t, this.t = e;
|
|
22
|
-
}
|
|
23
|
-
get styleSheet() {
|
|
24
|
-
let t = this.o;
|
|
25
|
-
const e = this.t;
|
|
26
|
-
if (m && t === void 0) {
|
|
27
|
-
const o = e !== void 0 && e.length === 1;
|
|
28
|
-
o && (t = S.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), o && S.set(e, t));
|
|
29
|
-
}
|
|
30
|
-
return t;
|
|
31
|
-
}
|
|
32
|
-
toString() {
|
|
33
|
-
return this.cssText;
|
|
34
|
-
}
|
|
1
|
+
import { LitElement as g, unsafeCSS as u, html as _ } from "lit";
|
|
2
|
+
import { property as c, state as w } from "lit/decorators.js";
|
|
3
|
+
const m = `:host{--_nys-tooltip-color: var(--nys-color-text-reverse, #ffffff);--_nys-tooltip-background-color: var(--nys-color-ink, #1b1b1b);--_nys-tooltip-border-radius: var(--nys-radius-md, 4px);--_nys-tooltip-font-family: var( --nys-font-family-ui, var( --nys-font-family-sans, "Proxima Nova", "Helvetica Neue", "Helvetica", "Arial", sans-serif ) );--_nys-tooltip-font-size: var(--nys-type-size-ui-sm, 14px);--_nys-tooltip-letter-spacing: var(--nys-font-letterspacing-ui-sm, .044px);--_nys-tooltip-line-height: var(--nys-font-lineheight-ui-sm, 24px)}.nys-tooltip__main{position:relative;width:fit-content}.nys-tooltip__wrapper{width:fit-content;display:flex;cursor:pointer}.nys-tooltip__trigger{display:flex}.nys-tooltip__content{position:absolute;display:none;max-width:400px;width:max-content;max-height:120px;padding:var(--nys-space-50, 4px) var(--nys-space-100, 8px);background-color:var(--_nys-tooltip-background-color);border-radius:var(--_nys-tooltip-border-radius);cursor:auto;z-index:1}.nys-tooltip__inner{display:block;color:var(--_nys-tooltip-color);font-family:var(--_nys-tooltip-font-family);font-size:var(--_nys-tooltip-font-size);font-weight:400;line-height:var(--_nys-tooltip-line-height);letter-spacing:var(--_nys-tooltip-letter-spacing);white-space:normal;word-break:break-word;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:4;line-clamp:4;-webkit-box-orient:vertical}.nys-tooltip__arrow{position:absolute;width:14px;height:6px;background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="15" height="6" viewBox="0 0 15 6" fill="none"><path d="M8.15079 5.44218C7.7763 5.76317 7.2237 5.76317 6.84921 5.44218L0.5 0H14.5L8.15079 5.44218Z" fill="%231B1B1B"/></svg>') no-repeat center}.nys-tooltip__content[active]{display:block}:host([position=top]) .nys-tooltip__content{bottom:100%;left:50%;transform:translate(-50%);margin-bottom:10px}:host([position=top]) .nys-tooltip__arrow{top:100%;left:var(--arrow-offset-x, 50%);transform:translate(-50%)}:host([position=bottom]) .nys-tooltip__content{top:100%;left:50%;transform:translate(-50%);margin-top:10px}:host([position=bottom]) .nys-tooltip__arrow{bottom:100%;left:var(--arrow-offset-x, 50%);transform:translate(-50%) rotate(180deg)}:host([position=left]) .nys-tooltip__content{left:auto;right:100%;top:50%;transform:translateY(-50%);margin-right:10px}:host([position=left]) .nys-tooltip__arrow{left:100%;top:50%;transform:translateY(-50%) rotate(-90deg);margin-left:-4px}:host([position=right]) .nys-tooltip__content{left:100%;top:50%;transform:translateY(-50%);margin-left:10px}:host([position=right]) .nys-tooltip__arrow{right:100%;top:50%;transform:translateY(-50%) rotate(90deg);margin-right:-4px}:host([inverted]) .nys-tooltip__content{--_nys-tooltip-color: var(--nys-color-text, #1b1b1b);--_nys-tooltip-background-color: var(--nys-color-ink-reverse, #fff)}:host([inverted]) .nys-tooltip__arrow{background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="15" height="6" viewBox="0 0 15 6" fill="none"><path d="M8.15079 5.44218C7.7763 5.76317 7.2237 5.76317 6.84921 5.44218L0.5 0H14.5L8.15079 5.44218Z" fill="white"/></svg>') no-repeat center}@media(max-width:400px){.nys-tooltip__content{max-width:calc(100vw - 2rem)}}`;
|
|
4
|
+
var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, h = (d, t, o, e) => {
|
|
5
|
+
for (var i = e > 1 ? void 0 : e ? b(t, o) : t, n = d.length - 1, s; n >= 0; n--)
|
|
6
|
+
(s = d[n]) && (i = (e ? s(t, o, i) : s(i)) || i);
|
|
7
|
+
return e && i && v(t, o, i), i;
|
|
35
8
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
else for (const e of t) {
|
|
39
|
-
const o = document.createElement("style"), i = _.litNonce;
|
|
40
|
-
i !== void 0 && o.setAttribute("nonce", i), o.textContent = e.cssText, s.appendChild(o);
|
|
41
|
-
}
|
|
42
|
-
}, E = m ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((t) => {
|
|
43
|
-
let e = "";
|
|
44
|
-
for (const o of t.cssRules) e += o.cssText;
|
|
45
|
-
return A(e);
|
|
46
|
-
})(s) : s;
|
|
47
|
-
/**
|
|
48
|
-
* @license
|
|
49
|
-
* Copyright 2017 Google LLC
|
|
50
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
51
|
-
*/
|
|
52
|
-
const { is: T, defineProperty: k, getOwnPropertyDescriptor: M, getOwnPropertyNames: z, getOwnPropertySymbols: B, getPrototypeOf: q } = Object, g = globalThis, P = g.trustedTypes, j = P ? P.emptyScript : "", I = g.reactiveElementPolyfillSupport, u = (s, t) => s, y = { toAttribute(s, t) {
|
|
53
|
-
switch (t) {
|
|
54
|
-
case Boolean:
|
|
55
|
-
s = s ? j : null;
|
|
56
|
-
break;
|
|
57
|
-
case Object:
|
|
58
|
-
case Array:
|
|
59
|
-
s = s == null ? s : JSON.stringify(s);
|
|
60
|
-
}
|
|
61
|
-
return s;
|
|
62
|
-
}, fromAttribute(s, t) {
|
|
63
|
-
let e = s;
|
|
64
|
-
switch (t) {
|
|
65
|
-
case Boolean:
|
|
66
|
-
e = s !== null;
|
|
67
|
-
break;
|
|
68
|
-
case Number:
|
|
69
|
-
e = s === null ? null : Number(s);
|
|
70
|
-
break;
|
|
71
|
-
case Object:
|
|
72
|
-
case Array:
|
|
73
|
-
try {
|
|
74
|
-
e = JSON.parse(s);
|
|
75
|
-
} catch {
|
|
76
|
-
e = null;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return e;
|
|
80
|
-
} }, w = (s, t) => !T(s, t), $ = { attribute: !0, type: String, converter: y, reflect: !1, useDefault: !1, hasChanged: w };
|
|
81
|
-
Symbol.metadata ??= Symbol("metadata"), g.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
|
|
82
|
-
class f extends HTMLElement {
|
|
83
|
-
static addInitializer(t) {
|
|
84
|
-
this._$Ei(), (this.l ??= []).push(t);
|
|
85
|
-
}
|
|
86
|
-
static get observedAttributes() {
|
|
87
|
-
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
88
|
-
}
|
|
89
|
-
static createProperty(t, e = $) {
|
|
90
|
-
if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
|
|
91
|
-
const o = Symbol(), i = this.getPropertyDescriptor(t, o, e);
|
|
92
|
-
i !== void 0 && k(this.prototype, t, i);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
static getPropertyDescriptor(t, e, o) {
|
|
96
|
-
const { get: i, set: r } = M(this.prototype, t) ?? { get() {
|
|
97
|
-
return this[e];
|
|
98
|
-
}, set(n) {
|
|
99
|
-
this[e] = n;
|
|
100
|
-
} };
|
|
101
|
-
return { get: i, set(n) {
|
|
102
|
-
const a = i?.call(this);
|
|
103
|
-
r?.call(this, n), this.requestUpdate(t, a, o);
|
|
104
|
-
}, configurable: !0, enumerable: !0 };
|
|
105
|
-
}
|
|
106
|
-
static getPropertyOptions(t) {
|
|
107
|
-
return this.elementProperties.get(t) ?? $;
|
|
108
|
-
}
|
|
109
|
-
static _$Ei() {
|
|
110
|
-
if (this.hasOwnProperty(u("elementProperties"))) return;
|
|
111
|
-
const t = q(this);
|
|
112
|
-
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
113
|
-
}
|
|
114
|
-
static finalize() {
|
|
115
|
-
if (this.hasOwnProperty(u("finalized"))) return;
|
|
116
|
-
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(u("properties"))) {
|
|
117
|
-
const e = this.properties, o = [...z(e), ...B(e)];
|
|
118
|
-
for (const i of o) this.createProperty(i, e[i]);
|
|
119
|
-
}
|
|
120
|
-
const t = this[Symbol.metadata];
|
|
121
|
-
if (t !== null) {
|
|
122
|
-
const e = litPropertyMetadata.get(t);
|
|
123
|
-
if (e !== void 0) for (const [o, i] of e) this.elementProperties.set(o, i);
|
|
124
|
-
}
|
|
125
|
-
this._$Eh = /* @__PURE__ */ new Map();
|
|
126
|
-
for (const [e, o] of this.elementProperties) {
|
|
127
|
-
const i = this._$Eu(e, o);
|
|
128
|
-
i !== void 0 && this._$Eh.set(i, e);
|
|
129
|
-
}
|
|
130
|
-
this.elementStyles = this.finalizeStyles(this.styles);
|
|
131
|
-
}
|
|
132
|
-
static finalizeStyles(t) {
|
|
133
|
-
const e = [];
|
|
134
|
-
if (Array.isArray(t)) {
|
|
135
|
-
const o = new Set(t.flat(1 / 0).reverse());
|
|
136
|
-
for (const i of o) e.unshift(E(i));
|
|
137
|
-
} else t !== void 0 && e.push(E(t));
|
|
138
|
-
return e;
|
|
139
|
-
}
|
|
140
|
-
static _$Eu(t, e) {
|
|
141
|
-
const o = e.attribute;
|
|
142
|
-
return o === !1 ? void 0 : typeof o == "string" ? o : typeof t == "string" ? t.toLowerCase() : void 0;
|
|
143
|
-
}
|
|
144
|
-
constructor() {
|
|
145
|
-
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
146
|
-
}
|
|
147
|
-
_$Ev() {
|
|
148
|
-
this._$ES = new Promise(((t) => this.enableUpdating = t)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t) => t(this)));
|
|
149
|
-
}
|
|
150
|
-
addController(t) {
|
|
151
|
-
(this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.();
|
|
152
|
-
}
|
|
153
|
-
removeController(t) {
|
|
154
|
-
this._$EO?.delete(t);
|
|
155
|
-
}
|
|
156
|
-
_$E_() {
|
|
157
|
-
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
|
|
158
|
-
for (const o of e.keys()) this.hasOwnProperty(o) && (t.set(o, this[o]), delete this[o]);
|
|
159
|
-
t.size > 0 && (this._$Ep = t);
|
|
160
|
-
}
|
|
161
|
-
createRenderRoot() {
|
|
162
|
-
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
163
|
-
return L(t, this.constructor.elementStyles), t;
|
|
164
|
-
}
|
|
165
|
-
connectedCallback() {
|
|
166
|
-
this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach(((t) => t.hostConnected?.()));
|
|
167
|
-
}
|
|
168
|
-
enableUpdating(t) {
|
|
169
|
-
}
|
|
170
|
-
disconnectedCallback() {
|
|
171
|
-
this._$EO?.forEach(((t) => t.hostDisconnected?.()));
|
|
172
|
-
}
|
|
173
|
-
attributeChangedCallback(t, e, o) {
|
|
174
|
-
this._$AK(t, o);
|
|
175
|
-
}
|
|
176
|
-
_$ET(t, e) {
|
|
177
|
-
const o = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, o);
|
|
178
|
-
if (i !== void 0 && o.reflect === !0) {
|
|
179
|
-
const r = (o.converter?.toAttribute !== void 0 ? o.converter : y).toAttribute(e, o.type);
|
|
180
|
-
this._$Em = t, r == null ? this.removeAttribute(i) : this.setAttribute(i, r), this._$Em = null;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
_$AK(t, e) {
|
|
184
|
-
const o = this.constructor, i = o._$Eh.get(t);
|
|
185
|
-
if (i !== void 0 && this._$Em !== i) {
|
|
186
|
-
const r = o.getPropertyOptions(i), n = typeof r.converter == "function" ? { fromAttribute: r.converter } : r.converter?.fromAttribute !== void 0 ? r.converter : y;
|
|
187
|
-
this._$Em = i;
|
|
188
|
-
const a = n.fromAttribute(e, r.type);
|
|
189
|
-
this[i] = a ?? this._$Ej?.get(i) ?? a, this._$Em = null;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
requestUpdate(t, e, o) {
|
|
193
|
-
if (t !== void 0) {
|
|
194
|
-
const i = this.constructor, r = this[t];
|
|
195
|
-
if (o ??= i.getPropertyOptions(t), !((o.hasChanged ?? w)(r, e) || o.useDefault && o.reflect && r === this._$Ej?.get(t) && !this.hasAttribute(i._$Eu(t, o)))) return;
|
|
196
|
-
this.C(t, e, o);
|
|
197
|
-
}
|
|
198
|
-
this.isUpdatePending === !1 && (this._$ES = this._$EP());
|
|
199
|
-
}
|
|
200
|
-
C(t, e, { useDefault: o, reflect: i, wrapped: r }, n) {
|
|
201
|
-
o && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, n ?? e ?? this[t]), r !== !0 || n !== void 0) || (this._$AL.has(t) || (this.hasUpdated || o || (e = void 0), this._$AL.set(t, e)), i === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t));
|
|
202
|
-
}
|
|
203
|
-
async _$EP() {
|
|
204
|
-
this.isUpdatePending = !0;
|
|
205
|
-
try {
|
|
206
|
-
await this._$ES;
|
|
207
|
-
} catch (e) {
|
|
208
|
-
Promise.reject(e);
|
|
209
|
-
}
|
|
210
|
-
const t = this.scheduleUpdate();
|
|
211
|
-
return t != null && await t, !this.isUpdatePending;
|
|
212
|
-
}
|
|
213
|
-
scheduleUpdate() {
|
|
214
|
-
return this.performUpdate();
|
|
215
|
-
}
|
|
216
|
-
performUpdate() {
|
|
217
|
-
if (!this.isUpdatePending) return;
|
|
218
|
-
if (!this.hasUpdated) {
|
|
219
|
-
if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
|
|
220
|
-
for (const [i, r] of this._$Ep) this[i] = r;
|
|
221
|
-
this._$Ep = void 0;
|
|
222
|
-
}
|
|
223
|
-
const o = this.constructor.elementProperties;
|
|
224
|
-
if (o.size > 0) for (const [i, r] of o) {
|
|
225
|
-
const { wrapped: n } = r, a = this[i];
|
|
226
|
-
n !== !0 || this._$AL.has(i) || a === void 0 || this.C(i, void 0, r, a);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
let t = !1;
|
|
230
|
-
const e = this._$AL;
|
|
231
|
-
try {
|
|
232
|
-
t = this.shouldUpdate(e), t ? (this.willUpdate(e), this._$EO?.forEach(((o) => o.hostUpdate?.())), this.update(e)) : this._$EM();
|
|
233
|
-
} catch (o) {
|
|
234
|
-
throw t = !1, this._$EM(), o;
|
|
235
|
-
}
|
|
236
|
-
t && this._$AE(e);
|
|
237
|
-
}
|
|
238
|
-
willUpdate(t) {
|
|
239
|
-
}
|
|
240
|
-
_$AE(t) {
|
|
241
|
-
this._$EO?.forEach(((e) => e.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
|
|
242
|
-
}
|
|
243
|
-
_$EM() {
|
|
244
|
-
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
|
|
245
|
-
}
|
|
246
|
-
get updateComplete() {
|
|
247
|
-
return this.getUpdateComplete();
|
|
248
|
-
}
|
|
249
|
-
getUpdateComplete() {
|
|
250
|
-
return this._$ES;
|
|
251
|
-
}
|
|
252
|
-
shouldUpdate(t) {
|
|
253
|
-
return !0;
|
|
254
|
-
}
|
|
255
|
-
update(t) {
|
|
256
|
-
this._$Eq &&= this._$Eq.forEach(((e) => this._$ET(e, this[e]))), this._$EM();
|
|
257
|
-
}
|
|
258
|
-
updated(t) {
|
|
259
|
-
}
|
|
260
|
-
firstUpdated(t) {
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
f.elementStyles = [], f.shadowRootOptions = { mode: "open" }, f[u("elementProperties")] = /* @__PURE__ */ new Map(), f[u("finalized")] = /* @__PURE__ */ new Map(), I?.({ ReactiveElement: f }), (g.reactiveElementVersions ??= []).push("2.1.1");
|
|
264
|
-
/**
|
|
265
|
-
* @license
|
|
266
|
-
* Copyright 2017 Google LLC
|
|
267
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
268
|
-
*/
|
|
269
|
-
const D = { attribute: !0, type: String, converter: y, reflect: !1, hasChanged: w }, N = (s = D, t, e) => {
|
|
270
|
-
const { kind: o, metadata: i } = e;
|
|
271
|
-
let r = globalThis.litPropertyMetadata.get(i);
|
|
272
|
-
if (r === void 0 && globalThis.litPropertyMetadata.set(i, r = /* @__PURE__ */ new Map()), o === "setter" && ((s = Object.create(s)).wrapped = !0), r.set(e.name, s), o === "accessor") {
|
|
273
|
-
const { name: n } = e;
|
|
274
|
-
return { set(a) {
|
|
275
|
-
const h = t.get.call(this);
|
|
276
|
-
t.set.call(this, a), this.requestUpdate(n, h, s);
|
|
277
|
-
}, init(a) {
|
|
278
|
-
return a !== void 0 && this.C(n, void 0, s, a), a;
|
|
279
|
-
} };
|
|
280
|
-
}
|
|
281
|
-
if (o === "setter") {
|
|
282
|
-
const { name: n } = e;
|
|
283
|
-
return function(a) {
|
|
284
|
-
const h = this[n];
|
|
285
|
-
t.call(this, a), this.requestUpdate(n, h, s);
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
throw Error("Unsupported decorator location: " + o);
|
|
289
|
-
};
|
|
290
|
-
function c(s) {
|
|
291
|
-
return (t, e) => typeof e == "object" ? N(s, t, e) : ((o, i, r) => {
|
|
292
|
-
const n = i.hasOwnProperty(r);
|
|
293
|
-
return i.constructor.createProperty(r, o), n ? Object.getOwnPropertyDescriptor(i, r) : void 0;
|
|
294
|
-
})(s, t, e);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* @license
|
|
298
|
-
* Copyright 2017 Google LLC
|
|
299
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
300
|
-
*/
|
|
301
|
-
function H(s) {
|
|
302
|
-
return c({ ...s, state: !0, attribute: !1 });
|
|
303
|
-
}
|
|
304
|
-
const F = U`
|
|
305
|
-
:host {
|
|
306
|
-
/* Global Tooltip Styles */
|
|
307
|
-
--_nys-tooltip-color: var(--nys-color-text-reverse, #ffffff);
|
|
308
|
-
--_nys-tooltip-background-color: var(--nys-color-ink, #1b1b1b);
|
|
309
|
-
--_nys-tooltip-border-radius: var(--nys-radius-md, 4px);
|
|
310
|
-
--_nys-tooltip-font-family: var(
|
|
311
|
-
--nys-font-family-ui,
|
|
312
|
-
var(
|
|
313
|
-
--nys-font-family-sans,
|
|
314
|
-
"Proxima Nova",
|
|
315
|
-
"Helvetica Neue",
|
|
316
|
-
"Helvetica",
|
|
317
|
-
"Arial",
|
|
318
|
-
sans-serif
|
|
319
|
-
)
|
|
320
|
-
);
|
|
321
|
-
--_nys-tooltip-font-size: var(--nys-type-size-ui-sm, 14px);
|
|
322
|
-
--_nys-tooltip-letter-spacing: var(--nys-font-letterspacing-ui-sm, 0.044px);
|
|
323
|
-
--_nys-tooltip-line-height: var(--nys-font-lineheight-ui-sm, 24px);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
.nys-tooltip__main {
|
|
327
|
-
position: relative;
|
|
328
|
-
width: fit-content;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.nys-tooltip__wrapper {
|
|
332
|
-
width: fit-content;
|
|
333
|
-
display: flex;
|
|
334
|
-
cursor: pointer;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
.nys-tooltip__trigger {
|
|
338
|
-
display: flex;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.nys-tooltip__content {
|
|
342
|
-
position: absolute;
|
|
343
|
-
display: none;
|
|
344
|
-
max-width: 400px;
|
|
345
|
-
width: max-content;
|
|
346
|
-
max-height: 120px;
|
|
347
|
-
padding: var(--nys-space-50, 4px) var(--nys-space-100, 8px);
|
|
348
|
-
background-color: var(--_nys-tooltip-background-color);
|
|
349
|
-
border-radius: var(--_nys-tooltip-border-radius);
|
|
350
|
-
cursor: auto;
|
|
351
|
-
z-index: 1;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
.nys-tooltip__inner {
|
|
355
|
-
display: block;
|
|
356
|
-
color: var(--_nys-tooltip-color);
|
|
357
|
-
font-family: var(--_nys-tooltip-font-family);
|
|
358
|
-
font-size: var(--_nys-tooltip-font-size);
|
|
359
|
-
font-weight: 400;
|
|
360
|
-
line-height: var(--_nys-tooltip-line-height);
|
|
361
|
-
letter-spacing: var(--_nys-tooltip-letter-spacing);
|
|
362
|
-
white-space: normal;
|
|
363
|
-
word-break: break-word;
|
|
364
|
-
overflow: hidden;
|
|
365
|
-
text-overflow: ellipsis;
|
|
366
|
-
display: -webkit-box;
|
|
367
|
-
-webkit-line-clamp: 4;
|
|
368
|
-
-webkit-box-orient: vertical;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/* Tooltip Arrow (default) */
|
|
372
|
-
.nys-tooltip__arrow {
|
|
373
|
-
position: absolute;
|
|
374
|
-
width: 14px;
|
|
375
|
-
height: 6px;
|
|
376
|
-
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="15" height="6" viewBox="0 0 15 6" fill="none"><path d="M8.15079 5.44218C7.7763 5.76317 7.2237 5.76317 6.84921 5.44218L0.5 0H14.5L8.15079 5.44218Z" fill="%231B1B1B"/></svg>')
|
|
377
|
-
no-repeat center;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
.nys-tooltip__content[active] {
|
|
381
|
-
display: block;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/* ===================== POSITIONING ===================== */
|
|
385
|
-
/* Top */
|
|
386
|
-
:host([position="top"]) .nys-tooltip__content {
|
|
387
|
-
bottom: 100%;
|
|
388
|
-
left: 50%;
|
|
389
|
-
transform: translateX(-50%);
|
|
390
|
-
margin-bottom: 10px;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
:host([position="top"]) .nys-tooltip__arrow {
|
|
394
|
-
top: 100%;
|
|
395
|
-
left: var(--arrow-offset-x, 50%);
|
|
396
|
-
transform: translateX(-50%);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/* Bottom */
|
|
400
|
-
:host([position="bottom"]) .nys-tooltip__content {
|
|
401
|
-
top: 100%;
|
|
402
|
-
left: 50%;
|
|
403
|
-
transform: translateX(-50%);
|
|
404
|
-
margin-top: 10px;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
:host([position="bottom"]) .nys-tooltip__arrow {
|
|
408
|
-
bottom: 100%;
|
|
409
|
-
left: var(--arrow-offset-x, 50%);
|
|
410
|
-
transform: translateX(-50%) rotate(180deg);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/* Left */
|
|
414
|
-
:host([position="left"]) .nys-tooltip__content {
|
|
415
|
-
left: auto;
|
|
416
|
-
right: 100%;
|
|
417
|
-
top: 50%;
|
|
418
|
-
transform: translateY(-50%);
|
|
419
|
-
margin-right: 10px;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
:host([position="left"]) .nys-tooltip__arrow {
|
|
423
|
-
left: 100%;
|
|
424
|
-
top: 50%;
|
|
425
|
-
transform: translateY(-50%) rotate(-90deg);
|
|
426
|
-
margin-left: -4px;
|
|
427
|
-
}
|
|
428
|
-
/* Right */
|
|
429
|
-
:host([position="right"]) .nys-tooltip__content {
|
|
430
|
-
left: 100%;
|
|
431
|
-
top: 50%;
|
|
432
|
-
transform: translateY(-50%);
|
|
433
|
-
margin-left: 10px;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
:host([position="right"]) .nys-tooltip__arrow {
|
|
437
|
-
right: 100%;
|
|
438
|
-
top: 50%;
|
|
439
|
-
transform: translateY(-50%) rotate(90deg);
|
|
440
|
-
margin-right: -4px;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
:host([inverted]) .nys-tooltip__content {
|
|
444
|
-
--_nys-tooltip-color: var(--nys-color-text, #1b1b1b);
|
|
445
|
-
--_nys-tooltip-background-color: var(--nys-color-ink-reverse, #fff);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
:host([inverted]) .nys-tooltip__arrow {
|
|
449
|
-
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="15" height="6" viewBox="0 0 15 6" fill="none"><path d="M8.15079 5.44218C7.7763 5.76317 7.2237 5.76317 6.84921 5.44218L0.5 0H14.5L8.15079 5.44218Z" fill="white"/></svg>')
|
|
450
|
-
no-repeat center;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
@media (max-width: 400px) {
|
|
454
|
-
.nys-tooltip__content {
|
|
455
|
-
max-width: calc(
|
|
456
|
-
100vw - 2rem
|
|
457
|
-
); /* 2rem = 32px = 16px margin on each side */
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
`;
|
|
461
|
-
var V = Object.defineProperty, W = Object.getOwnPropertyDescriptor, d = (s, t, e, o) => {
|
|
462
|
-
for (var i = o > 1 ? void 0 : o ? W(t, e) : t, r = s.length - 1, n; r >= 0; r--)
|
|
463
|
-
(n = s[r]) && (i = (o ? n(t, e, i) : n(i)) || i);
|
|
464
|
-
return o && i && V(t, e, i), i;
|
|
465
|
-
};
|
|
466
|
-
let K = 0;
|
|
467
|
-
const v = class v extends R {
|
|
9
|
+
let x = 0;
|
|
10
|
+
const f = class f extends g {
|
|
468
11
|
/**************** Lifecycle Methods ****************/
|
|
469
12
|
constructor() {
|
|
470
13
|
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 = () => {
|
|
@@ -494,10 +37,10 @@ const v = class v extends R {
|
|
|
494
37
|
}, this._handleEscapeKey = (t) => {
|
|
495
38
|
if (t.key === "Escape" && this._active) {
|
|
496
39
|
this._active = !1, this._removeScrollListeners();
|
|
497
|
-
const
|
|
40
|
+
const o = this.shadowRoot?.querySelector(
|
|
498
41
|
".nys-tooltip__content"
|
|
499
42
|
);
|
|
500
|
-
|
|
43
|
+
o && this._resetTooltipPositioningStyles(o);
|
|
501
44
|
}
|
|
502
45
|
};
|
|
503
46
|
}
|
|
@@ -505,11 +48,11 @@ const v = class v extends R {
|
|
|
505
48
|
return this._position;
|
|
506
49
|
}
|
|
507
50
|
set position(t) {
|
|
508
|
-
const
|
|
509
|
-
this._position = t, this.requestUpdate("position",
|
|
51
|
+
const o = this._position;
|
|
52
|
+
this._position = t, this.requestUpdate("position", o), this._internallyUpdatingPosition || (this._userHasSetPosition = t !== null, this._originalUserPosition = t);
|
|
510
53
|
}
|
|
511
54
|
connectedCallback() {
|
|
512
|
-
super.connectedCallback(), this.id || (this.id = `nys-tooltip-${Date.now()}-${
|
|
55
|
+
super.connectedCallback(), this.id || (this.id = `nys-tooltip-${Date.now()}-${x++}`), window.addEventListener("keydown", this._handleEscapeKey);
|
|
513
56
|
}
|
|
514
57
|
disconnectedCallback() {
|
|
515
58
|
super.disconnectedCallback(), window.removeEventListener("keydown", this._handleEscapeKey);
|
|
@@ -520,14 +63,14 @@ const v = class v extends R {
|
|
|
520
63
|
firstUpdated() {
|
|
521
64
|
const t = this.shadowRoot?.querySelector("slot");
|
|
522
65
|
t && t.addEventListener("slotchange", () => {
|
|
523
|
-
const
|
|
524
|
-
|
|
66
|
+
const o = this._firstAssignedEl;
|
|
67
|
+
o && this._applyFocusBehavior(o);
|
|
525
68
|
});
|
|
526
69
|
}
|
|
527
70
|
updated(t) {
|
|
528
71
|
super.updated(t);
|
|
529
|
-
const
|
|
530
|
-
|
|
72
|
+
const o = this._firstAssignedEl;
|
|
73
|
+
o && (t.has("text") && this._passAria(o), t.has("focusable") && this._applyFocusBehavior(o));
|
|
531
74
|
}
|
|
532
75
|
// Listen to window scroll so a focus tooltip can auto position even when user move across the page
|
|
533
76
|
_addScrollListeners() {
|
|
@@ -539,10 +82,10 @@ const v = class v extends R {
|
|
|
539
82
|
/******************** Functions ********************/
|
|
540
83
|
// We need to pass `ariaLabel` or `ariaDescription` to the nys-components so they can announce both their label and the tooltip's text
|
|
541
84
|
_passAria(t) {
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
85
|
+
const o = t.tagName.toLowerCase();
|
|
86
|
+
if (o.startsWith("nys-"))
|
|
87
|
+
if (o === "nys-icon") {
|
|
88
|
+
const e = t.getAttribute("ariaLabel") || "", i = e ? `${e}, ${this.text}` : this.text;
|
|
546
89
|
t.setAttribute("ariaLabel", i);
|
|
547
90
|
} else
|
|
548
91
|
t.setAttribute("ariaDescription", this.text);
|
|
@@ -552,61 +95,61 @@ const v = class v extends R {
|
|
|
552
95
|
if (!this.focusable) return;
|
|
553
96
|
if (t.tagName.toLowerCase() === "nys-icon") {
|
|
554
97
|
"updateComplete" in t && await t.updateComplete;
|
|
555
|
-
const
|
|
556
|
-
|
|
98
|
+
const e = t.shadowRoot?.querySelector("svg");
|
|
99
|
+
e && e.setAttribute("tabindex", "0");
|
|
557
100
|
} else
|
|
558
101
|
t.setAttribute("tabindex", "0");
|
|
559
102
|
}
|
|
560
103
|
// Checks if user's set position fit with current viewport (Does not account for overflow texts at this moment)
|
|
561
104
|
_doesPositionFit(t) {
|
|
562
|
-
const
|
|
563
|
-
if (!
|
|
564
|
-
const i =
|
|
565
|
-
top: i.top -
|
|
566
|
-
left: i.left -
|
|
567
|
-
bottom: window.innerHeight - i.bottom -
|
|
568
|
-
right: window.innerWidth - i.right -
|
|
105
|
+
const o = this.shadowRoot?.querySelector(".nys-tooltip__wrapper"), e = this.shadowRoot?.querySelector(".nys-tooltip__content");
|
|
106
|
+
if (!o || !e || t == null) return;
|
|
107
|
+
const i = o.getBoundingClientRect(), n = e.getBoundingClientRect(), s = 8, l = {
|
|
108
|
+
top: i.top - s,
|
|
109
|
+
left: i.left - s,
|
|
110
|
+
bottom: window.innerHeight - i.bottom - s,
|
|
111
|
+
right: window.innerWidth - i.right - s
|
|
569
112
|
};
|
|
570
113
|
return {
|
|
571
|
-
top:
|
|
572
|
-
bottom:
|
|
573
|
-
left:
|
|
574
|
-
right:
|
|
114
|
+
top: l.top >= n.height,
|
|
115
|
+
bottom: l.bottom >= n.height,
|
|
116
|
+
left: l.left >= n.width,
|
|
117
|
+
right: l.right >= n.width
|
|
575
118
|
}[t];
|
|
576
119
|
}
|
|
577
120
|
// Calculates the best placement based on available space (flips placement if it doesn't fit)
|
|
578
121
|
async autoPositionTooltip() {
|
|
579
122
|
const t = this.shadowRoot?.querySelector(
|
|
580
123
|
".nys-tooltip__wrapper"
|
|
581
|
-
),
|
|
124
|
+
), o = this.shadowRoot?.querySelector(
|
|
582
125
|
".nys-tooltip__content"
|
|
583
126
|
);
|
|
584
|
-
if (!t || !
|
|
585
|
-
const
|
|
586
|
-
top:
|
|
587
|
-
left:
|
|
588
|
-
bottom: window.innerHeight -
|
|
589
|
-
right: window.innerWidth -
|
|
127
|
+
if (!t || !o) return;
|
|
128
|
+
const e = t.getBoundingClientRect(), i = 8, n = {
|
|
129
|
+
top: e.top - i,
|
|
130
|
+
left: e.left - i,
|
|
131
|
+
bottom: window.innerHeight - e.bottom - i,
|
|
132
|
+
right: window.innerWidth - e.right - i
|
|
590
133
|
};
|
|
591
|
-
let
|
|
134
|
+
let s = [
|
|
592
135
|
"top",
|
|
593
136
|
"bottom",
|
|
594
137
|
"right",
|
|
595
138
|
"left"
|
|
596
139
|
];
|
|
597
140
|
if (this._userHasSetPosition && this._originalUserPosition) {
|
|
598
|
-
const
|
|
599
|
-
|
|
141
|
+
const r = this._originalUserPosition;
|
|
142
|
+
r === "left" ? s = ["left", "right", "top", "bottom"] : r === "right" ? s = ["right", "left", "top", "bottom"] : r === "top" ? s = ["top", "bottom", "right", "left"] : r === "bottom" && (s = ["bottom", "top", "right", "left"]);
|
|
600
143
|
}
|
|
601
|
-
for (const
|
|
602
|
-
if (this._doesPositionFit(
|
|
603
|
-
this._setInternalPosition(
|
|
144
|
+
for (const r of s)
|
|
145
|
+
if (this._doesPositionFit(r)) {
|
|
146
|
+
this._setInternalPosition(r), await this.updateComplete, this._shiftTooltipIntoViewport(o);
|
|
604
147
|
return;
|
|
605
148
|
}
|
|
606
|
-
let
|
|
607
|
-
for (const
|
|
608
|
-
r
|
|
609
|
-
this._setInternalPosition(
|
|
149
|
+
let l = "top", p = n.top;
|
|
150
|
+
for (const r of s)
|
|
151
|
+
n[r] > p && (p = n[r], l = r);
|
|
152
|
+
this._setInternalPosition(l), await this.updateComplete, this._shiftTooltipIntoViewport(o);
|
|
610
153
|
}
|
|
611
154
|
// Sets flag to distinguish to position's setter that we are updating "position" prop internally
|
|
612
155
|
_setInternalPosition(t) {
|
|
@@ -614,19 +157,19 @@ const v = class v extends R {
|
|
|
614
157
|
}
|
|
615
158
|
// Determines if text of tooltip over-extends outside of viewport edge and adjust tooltip for horizontal overflow
|
|
616
159
|
_shiftTooltipIntoViewport(t) {
|
|
617
|
-
const
|
|
160
|
+
const e = (this.shadowRoot?.querySelector(
|
|
618
161
|
".nys-tooltip__wrapper"
|
|
619
|
-
)).getBoundingClientRect(), i = t.getBoundingClientRect(),
|
|
620
|
-
this._resetTooltipPositioningStyles(t),
|
|
621
|
-
const
|
|
622
|
-
t.style.setProperty("--arrow-offset-x", `${
|
|
162
|
+
)).getBoundingClientRect(), i = t.getBoundingClientRect(), n = e.left + e.width / 2, s = i.left < 0, l = i.right > window.innerWidth;
|
|
163
|
+
this._resetTooltipPositioningStyles(t), s ? (t.style.left = "0px", t.style.transform = "none") : l && (t.style.right = "0px", t.style.left = "auto", t.style.transform = "none");
|
|
164
|
+
const p = t.getBoundingClientRect(), r = (n - p.left) / p.width, y = Math.max(0, Math.min(1, r)) * 100;
|
|
165
|
+
t.style.setProperty("--arrow-offset-x", `${y}%`);
|
|
623
166
|
}
|
|
624
167
|
// Reposition tooltip back to original set position (e.g. top, left, bottom, right) to avoid positioning issue base on last position
|
|
625
168
|
_resetTooltipPositioningStyles(t) {
|
|
626
169
|
t.style.left = "", t.style.right = "", t.style.transform = "";
|
|
627
170
|
}
|
|
628
171
|
render() {
|
|
629
|
-
return
|
|
172
|
+
return _`
|
|
630
173
|
<div class="nys-tooltip__main">
|
|
631
174
|
<div
|
|
632
175
|
class="nys-tooltip__wrapper"
|
|
@@ -639,7 +182,7 @@ const v = class v extends R {
|
|
|
639
182
|
<slot></slot>
|
|
640
183
|
</span>
|
|
641
184
|
</div>
|
|
642
|
-
${this.text?.trim() ?
|
|
185
|
+
${this.text?.trim() ? _`<div
|
|
643
186
|
id=${this.id}
|
|
644
187
|
class="nys-tooltip__content"
|
|
645
188
|
role="tooltip"
|
|
@@ -653,28 +196,28 @@ const v = class v extends R {
|
|
|
653
196
|
`;
|
|
654
197
|
}
|
|
655
198
|
};
|
|
656
|
-
|
|
657
|
-
let
|
|
658
|
-
|
|
659
|
-
c({ type: String })
|
|
660
|
-
],
|
|
661
|
-
|
|
199
|
+
f.styles = u(m);
|
|
200
|
+
let a = f;
|
|
201
|
+
h([
|
|
202
|
+
c({ type: String, reflect: !0 })
|
|
203
|
+
], a.prototype, "id", 2);
|
|
204
|
+
h([
|
|
662
205
|
c({ type: String })
|
|
663
|
-
],
|
|
664
|
-
|
|
206
|
+
], a.prototype, "text", 2);
|
|
207
|
+
h([
|
|
665
208
|
c({ type: Boolean, reflect: !0 })
|
|
666
|
-
],
|
|
667
|
-
|
|
209
|
+
], a.prototype, "inverted", 2);
|
|
210
|
+
h([
|
|
668
211
|
c({ type: Boolean, reflect: !0 })
|
|
669
|
-
],
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
],
|
|
673
|
-
|
|
212
|
+
], a.prototype, "focusable", 2);
|
|
213
|
+
h([
|
|
214
|
+
w()
|
|
215
|
+
], a.prototype, "_active", 2);
|
|
216
|
+
h([
|
|
674
217
|
c({ type: String, reflect: !0 })
|
|
675
|
-
],
|
|
676
|
-
customElements.get("nys-tooltip") || customElements.define("nys-tooltip",
|
|
218
|
+
], a.prototype, "position", 1);
|
|
219
|
+
customElements.get("nys-tooltip") || customElements.define("nys-tooltip", a);
|
|
677
220
|
export {
|
|
678
|
-
|
|
221
|
+
a as NysTooltip
|
|
679
222
|
};
|
|
680
223
|
//# sourceMappingURL=nys-tooltip.js.map
|
package/dist/nys-tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nys-tooltip.js","sources":["../../../node_modules/@lit/reactive-element/css-tag.js","../../../node_modules/@lit/reactive-element/reactive-element.js","../../../node_modules/@lit/reactive-element/decorators/property.js","../../../node_modules/@lit/reactive-element/decorators/state.js","../src/nys-tooltip.styles.ts","../src/nys-tooltip.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&\"adoptedStyleSheets\"in Document.prototype&&\"replace\"in CSSStyleSheet.prototype,s=Symbol(),o=new WeakMap;class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s)throw Error(\"CSSResult is not constructable. Use `unsafeCSS` or `css` instead.\");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(s,t))}return t}toString(){return this.cssText}}const r=t=>new n(\"string\"==typeof t?t:t+\"\",void 0,s),i=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if(\"number\"==typeof t)return t;throw Error(\"Value passed to 'css' function must be a 'css' function result: \"+t+\". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.\")})(s)+t[o+1]),t[0]);return new n(o,t,s)},S=(s,o)=>{if(e)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement(\"style\"),n=t.litNonce;void 0!==n&&o.setAttribute(\"nonce\",n),o.textContent=e.cssText,s.appendChild(o)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e=\"\";for(const s of t.cssRules)e+=s.cssText;return r(e)})(t):t;export{n as CSSResult,S as adoptStyles,i as css,c as getCompatibleStyle,e as supportsAdoptingStyleSheets,r as unsafeCSS};\n//# sourceMappingURL=css-tag.js.map\n","import{getCompatibleStyle as t,adoptStyles as s}from\"./css-tag.js\";export{CSSResult,css,supportsAdoptingStyleSheets,unsafeCSS}from\"./css-tag.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{is:i,defineProperty:e,getOwnPropertyDescriptor:h,getOwnPropertyNames:r,getOwnPropertySymbols:o,getPrototypeOf:n}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:\"\",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},f=(t,s)=>!i(t,s),b={attribute:!0,type:String,converter:u,reflect:!1,useDefault:!1,hasChanged:f};Symbol.metadata??=Symbol(\"metadata\"),a.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e(this.prototype,t,h)}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t}};return{get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d(\"elementProperties\")))return;const t=n(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(d(\"finalized\")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d(\"properties\"))){const t=this.properties,s=[...r(t),...o(t)];for(const i of s)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(t(s))}else void 0!==s&&i.push(t(s));return i}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:\"string\"==typeof i?i:\"string\"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h=\"function\"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),!0!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),!0===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];!0!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e)}}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM()}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:\"open\"},y[d(\"elementProperties\")]=new Map,y[d(\"finalized\")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push(\"2.1.1\");export{y as ReactiveElement,s as adoptStyles,u as defaultConverter,t as getCompatibleStyle,f as notEqual};\n//# sourceMappingURL=reactive-element.js.map\n","import{defaultConverter as t,notEqual as e}from\"../reactive-element.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),\"setter\"===n&&((t=Object.create(t)).wrapped=!0),s.set(r.name,t),\"accessor\"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if(\"setter\"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error(\"Unsupported decorator location: \"+n)};function n(t){return(e,o)=>\"object\"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty};\n//# sourceMappingURL=property.js.map\n","import{property as t}from\"./property.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */function r(r){return t({...r,state:!0,attribute:!1})}export{r as state};\n//# sourceMappingURL=state.js.map\n","import { css } from \"lit\";\n\nexport default css`\n :host {\n /* Global Tooltip Styles */\n --_nys-tooltip-color: var(--nys-color-text-reverse, #ffffff);\n --_nys-tooltip-background-color: var(--nys-color-ink, #1b1b1b);\n --_nys-tooltip-border-radius: var(--nys-radius-md, 4px);\n --_nys-tooltip-font-family: var(\n --nys-font-family-ui,\n var(\n --nys-font-family-sans,\n \"Proxima Nova\",\n \"Helvetica Neue\",\n \"Helvetica\",\n \"Arial\",\n sans-serif\n )\n );\n --_nys-tooltip-font-size: var(--nys-type-size-ui-sm, 14px);\n --_nys-tooltip-letter-spacing: var(--nys-font-letterspacing-ui-sm, 0.044px);\n --_nys-tooltip-line-height: var(--nys-font-lineheight-ui-sm, 24px);\n }\n\n .nys-tooltip__main {\n position: relative;\n width: fit-content;\n }\n\n .nys-tooltip__wrapper {\n width: fit-content;\n display: flex;\n cursor: pointer;\n }\n\n .nys-tooltip__trigger {\n display: flex;\n }\n\n .nys-tooltip__content {\n position: absolute;\n display: none;\n max-width: 400px;\n width: max-content;\n max-height: 120px;\n padding: var(--nys-space-50, 4px) var(--nys-space-100, 8px);\n background-color: var(--_nys-tooltip-background-color);\n border-radius: var(--_nys-tooltip-border-radius);\n cursor: auto;\n z-index: 1;\n }\n\n .nys-tooltip__inner {\n display: block;\n color: var(--_nys-tooltip-color);\n font-family: var(--_nys-tooltip-font-family);\n font-size: var(--_nys-tooltip-font-size);\n font-weight: 400;\n line-height: var(--_nys-tooltip-line-height);\n letter-spacing: var(--_nys-tooltip-letter-spacing);\n white-space: normal;\n word-break: break-word;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 4;\n -webkit-box-orient: vertical;\n }\n\n /* Tooltip Arrow (default) */\n .nys-tooltip__arrow {\n position: absolute;\n width: 14px;\n height: 6px;\n background: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"6\" viewBox=\"0 0 15 6\" fill=\"none\"><path d=\"M8.15079 5.44218C7.7763 5.76317 7.2237 5.76317 6.84921 5.44218L0.5 0H14.5L8.15079 5.44218Z\" fill=\"%231B1B1B\"/></svg>')\n no-repeat center;\n }\n\n .nys-tooltip__content[active] {\n display: block;\n }\n\n /* ===================== POSITIONING ===================== */\n /* Top */\n :host([position=\"top\"]) .nys-tooltip__content {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n margin-bottom: 10px;\n }\n\n :host([position=\"top\"]) .nys-tooltip__arrow {\n top: 100%;\n left: var(--arrow-offset-x, 50%);\n transform: translateX(-50%);\n }\n\n /* Bottom */\n :host([position=\"bottom\"]) .nys-tooltip__content {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n margin-top: 10px;\n }\n\n :host([position=\"bottom\"]) .nys-tooltip__arrow {\n bottom: 100%;\n left: var(--arrow-offset-x, 50%);\n transform: translateX(-50%) rotate(180deg);\n }\n\n /* Left */\n :host([position=\"left\"]) .nys-tooltip__content {\n left: auto;\n right: 100%;\n top: 50%;\n transform: translateY(-50%);\n margin-right: 10px;\n }\n\n :host([position=\"left\"]) .nys-tooltip__arrow {\n left: 100%;\n top: 50%;\n transform: translateY(-50%) rotate(-90deg);\n margin-left: -4px;\n }\n /* Right */\n :host([position=\"right\"]) .nys-tooltip__content {\n left: 100%;\n top: 50%;\n transform: translateY(-50%);\n margin-left: 10px;\n }\n\n :host([position=\"right\"]) .nys-tooltip__arrow {\n right: 100%;\n top: 50%;\n transform: translateY(-50%) rotate(90deg);\n margin-right: -4px;\n }\n\n :host([inverted]) .nys-tooltip__content {\n --_nys-tooltip-color: var(--nys-color-text, #1b1b1b);\n --_nys-tooltip-background-color: var(--nys-color-ink-reverse, #fff);\n }\n\n :host([inverted]) .nys-tooltip__arrow {\n background: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"6\" viewBox=\"0 0 15 6\" fill=\"none\"><path d=\"M8.15079 5.44218C7.7763 5.76317 7.2237 5.76317 6.84921 5.44218L0.5 0H14.5L8.15079 5.44218Z\" fill=\"white\"/></svg>')\n no-repeat center;\n }\n\n @media (max-width: 400px) {\n .nys-tooltip__content {\n max-width: calc(\n 100vw - 2rem\n ); /* 2rem = 32px = 16px margin on each side */\n }\n }\n`;\n","import { LitElement, html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport styles from \"./nys-tooltip.styles\";\n\nlet tooltipIdCounter = 0; // Counter for generating unique IDs\n\nexport class NysTooltip extends LitElement {\n @property({ type: String }) id = \"\";\n @property({ type: String }) text = \"\";\n @property({ type: Boolean, reflect: true }) inverted = false;\n @property({ type: Boolean, reflect: true }) focusable = false;\n\n // Track if tooltip is active (hovered or focused)\n @state()\n private _active = false;\n\n // Track if user set position is set explicitly\n private _userHasSetPosition = false;\n private _originalUserPosition: typeof this._position | null = null;\n // Internal flag to prevent dynamic positioning when not needed\n private _internallyUpdatingPosition = false;\n\n static styles = styles;\n\n /********************* Position Logic *********************/\n private _position: \"top\" | \"bottom\" | \"left\" | \"right\" | null = null;\n\n @property({ type: String, reflect: true })\n get position() {\n return this._position;\n }\n\n set position(value) {\n const oldVal = this._position;\n this._position = value;\n this.requestUpdate(\"position\", oldVal);\n\n // The \"_internallyUpdatingPosition\" flag allows user's set position to take preference\n if (!this._internallyUpdatingPosition) {\n this._userHasSetPosition = value !== null;\n this._originalUserPosition = value;\n }\n }\n\n /**************** Lifecycle Methods ****************/\n constructor() {\n super();\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Generate a unique ID if not provided\n if (!this.id) {\n this.id = `nys-tooltip-${Date.now()}-${tooltipIdCounter++}`;\n }\n\n window.addEventListener(\"keydown\", this._handleEscapeKey);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"keydown\", this._handleEscapeKey);\n }\n\n private get _firstAssignedEl(): HTMLElement | undefined {\n const slot = this.shadowRoot?.querySelector(\"slot\");\n return slot?.assignedElements({ flatten: true })[0] as\n | HTMLElement\n | undefined;\n }\n\n firstUpdated() {\n const slot = this.shadowRoot?.querySelector(\"slot\");\n if (slot) {\n slot.addEventListener(\"slotchange\", () => {\n const firstEl = this._firstAssignedEl;\n if (firstEl) {\n this._applyFocusBehavior(firstEl);\n }\n });\n }\n }\n\n updated(changedProps: Map<string, unknown>) {\n super.updated(changedProps);\n\n const firstEl = this._firstAssignedEl;\n if (!firstEl) return;\n\n // Accounts for tooltip's text change (for code editor changes & VO)\n if (changedProps.has(\"text\")) {\n this._passAria(firstEl);\n }\n if (changedProps.has(\"focusable\")) {\n this._applyFocusBehavior(firstEl);\n }\n }\n\n /******************** Event Handlers ********************/\n // When toggling tooltip, check if user has set position to give it preference it space allows. Otherwise dynamically position tooltip.\n private _handleTooltipEnter = () => {\n this._active = true;\n this._addScrollListeners();\n\n // Try to honor user's original preference first\n if (this._userHasSetPosition && this._originalUserPosition) {\n if (this._doesPositionFit(this._originalUserPosition)) {\n this.position = this._originalUserPosition;\n // Check if current tooltip position overflows to edge of screen\n this.updateComplete.then(() => {\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n if (tooltip) this._shiftTooltipIntoViewport(tooltip);\n });\n return;\n }\n }\n\n // Otherwise fall back to auto logic\n this.autoPositionTooltip();\n };\n\n private _handleBlurOrMouseLeave = () => {\n this._active = false;\n this._removeScrollListeners();\n\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n\n if (tooltip) {\n this._resetTooltipPositioningStyles(tooltip);\n }\n };\n\n // Listen to window scroll so a focus tooltip can auto position even when user move across the page\n private _addScrollListeners() {\n window.addEventListener(\"scroll\", this._handleScrollOrResize, true);\n window.addEventListener(\"resize\", this._handleScrollOrResize);\n }\n\n private _removeScrollListeners() {\n window.removeEventListener(\"scroll\", this._handleScrollOrResize, true);\n window.removeEventListener(\"resize\", this._handleScrollOrResize);\n }\n\n private _handleScrollOrResize = () => {\n if (!this._active) return;\n\n if (this._userHasSetPosition && this._originalUserPosition) {\n if (this._doesPositionFit(this._originalUserPosition)) {\n this._setInternalPosition(this._originalUserPosition);\n\n // Check if current tooltip position overflows to edge of screen\n this.updateComplete.then(() => {\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n if (tooltip) this._shiftTooltipIntoViewport(tooltip);\n });\n } else {\n this.autoPositionTooltip();\n }\n } else {\n this.autoPositionTooltip();\n }\n };\n\n private _handleEscapeKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\" && this._active) {\n this._active = false;\n this._removeScrollListeners();\n\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n if (tooltip) {\n this._resetTooltipPositioningStyles(tooltip);\n }\n }\n };\n\n /******************** Functions ********************/\n // We need to pass `ariaLabel` or `ariaDescription` to the nys-components so they can announce both their label and the tooltip's text\n private _passAria(el: HTMLElement) {\n const tagName = el.tagName.toLowerCase();\n\n if (tagName.startsWith(\"nys-\")) {\n if (tagName === \"nys-icon\") {\n // For nys-icon, use ariaLabel instead\n const existingLabel = el.getAttribute(\"ariaLabel\") || \"\";\n const mergedLabel = existingLabel\n ? `${existingLabel}, ${this.text}`\n : this.text;\n\n el.setAttribute(\"ariaLabel\", mergedLabel);\n } else {\n // For other components like nys-button, use ariaDescription\n el.setAttribute(\"ariaDescription\", this.text);\n }\n }\n }\n\n // Applies focus behavior to an otherwise non focus element (i.e. nys-icon is non focusable by default)\n private async _applyFocusBehavior(el: HTMLElement) {\n if (!this.focusable) return;\n\n const tagName = el.tagName.toLowerCase();\n if (tagName === \"nys-icon\") {\n if (\"updateComplete\" in el) {\n await (el as any).updateComplete;\n }\n const svg = el.shadowRoot?.querySelector(\"svg\");\n if (svg) {\n svg.setAttribute(\"tabindex\", \"0\");\n }\n } else {\n el.setAttribute(\"tabindex\", \"0\");\n }\n }\n\n // Checks if user's set position fit with current viewport (Does not account for overflow texts at this moment)\n private _doesPositionFit(position: typeof this._position) {\n const wrapper = this.shadowRoot?.querySelector(\".nys-tooltip__wrapper\");\n const tooltip = this.shadowRoot?.querySelector(\".nys-tooltip__content\");\n\n if (!wrapper || !tooltip || position == null) return;\n\n const triggerRect = wrapper.getBoundingClientRect();\n const tooltipRect = tooltip.getBoundingClientRect();\n\n // Define some margin buffer between tooltip and trigger (to avoid touching the edges too tightly)\n const margin = 8;\n\n // Available space on each side relative to trigger rect and viewport\n const spaceAvailable = {\n top: triggerRect.top - margin,\n left: triggerRect.left - margin,\n bottom: window.innerHeight - triggerRect.bottom - margin,\n right: window.innerWidth - triggerRect.right - margin,\n };\n\n // Check if tooltip fits on each side (compare available space vs tooltip size)\n const fits = {\n top: spaceAvailable.top >= tooltipRect.height,\n bottom: spaceAvailable.bottom >= tooltipRect.height,\n left: spaceAvailable.left >= tooltipRect.width,\n right: spaceAvailable.right >= tooltipRect.width,\n };\n\n return fits[position];\n }\n\n // Calculates the best placement based on available space (flips placement if it doesn't fit)\n private async autoPositionTooltip() {\n const wrapper = this.shadowRoot?.querySelector(\n \".nys-tooltip__wrapper\",\n ) as HTMLElement;\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n\n if (!wrapper || !tooltip) return;\n\n const triggerRect = wrapper.getBoundingClientRect();\n const margin = 8;\n\n const spaceAvailable = {\n top: triggerRect.top - margin,\n left: triggerRect.left - margin,\n bottom: window.innerHeight - triggerRect.bottom - margin,\n right: window.innerWidth - triggerRect.right - margin,\n };\n\n // Default tryOrder for auto mode\n let tryOrder: Array<keyof typeof spaceAvailable> = [\n \"top\",\n \"bottom\",\n \"right\",\n \"left\",\n ];\n\n // If user explicitly set a preferred position (even if it didn’t fit),\n // favor it first before trying others\n if (this._userHasSetPosition && this._originalUserPosition) {\n const userPosition = this._originalUserPosition;\n if (userPosition === \"left\") {\n tryOrder = [\"left\", \"right\", \"top\", \"bottom\"];\n } else if (userPosition === \"right\") {\n tryOrder = [\"right\", \"left\", \"top\", \"bottom\"];\n } else if (userPosition === \"top\") {\n tryOrder = [\"top\", \"bottom\", \"right\", \"left\"];\n } else if (userPosition === \"bottom\") {\n tryOrder = [\"bottom\", \"top\", \"right\", \"left\"];\n }\n }\n\n // 1) Try to find the first side that fits\n for (const pos of tryOrder) {\n if (this._doesPositionFit(pos)) {\n this._setInternalPosition(pos);\n await this.updateComplete;\n this._shiftTooltipIntoViewport(tooltip);\n return;\n }\n }\n\n // 2) Fallback: pick the side with the most space\n let bestPosition: keyof typeof spaceAvailable = \"top\";\n let maxSpace = spaceAvailable.top;\n\n for (const pos of tryOrder) {\n if (spaceAvailable[pos] > maxSpace) {\n maxSpace = spaceAvailable[pos];\n bestPosition = pos;\n }\n }\n this._setInternalPosition(bestPosition);\n await this.updateComplete;\n this._shiftTooltipIntoViewport(tooltip);\n }\n\n // Sets flag to distinguish to position's setter that we are updating \"position\" prop internally\n private _setInternalPosition(bestPosition: typeof this._position) {\n this._internallyUpdatingPosition = true;\n this.position = bestPosition;\n this._internallyUpdatingPosition = false;\n }\n\n // Determines if text of tooltip over-extends outside of viewport edge and adjust tooltip for horizontal overflow\n private _shiftTooltipIntoViewport(tooltip: HTMLElement) {\n const wrapper = this.shadowRoot?.querySelector(\n \".nys-tooltip__wrapper\",\n ) as HTMLElement;\n\n const wrapperRect = wrapper.getBoundingClientRect();\n const tooltipRect = tooltip.getBoundingClientRect();\n\n const wrapperCenter = wrapperRect.left + wrapperRect.width / 2;\n\n const overflowLeft = tooltipRect.left < 0;\n const overflowRight = tooltipRect.right > window.innerWidth;\n\n this._resetTooltipPositioningStyles(tooltip);\n\n // Tooltip is past the viewport edge, shift it inwards\n if (overflowLeft) {\n tooltip.style.left = \"0px\";\n tooltip.style.transform = \"none\";\n } else if (overflowRight) {\n tooltip.style.right = \"0px\";\n tooltip.style.left = \"auto\";\n tooltip.style.transform = \"none\";\n }\n\n // Recalculate tooltip rect after any shift\n const newTooltipRect = tooltip.getBoundingClientRect();\n\n // Arrow offset relative to tooltip width to maintain accuracy on zoom and out-of-bounds\n const arrowOffsetRatio =\n (wrapperCenter - newTooltipRect.left) / newTooltipRect.width;\n const arrowOffsetPercent = Math.max(0, Math.min(1, arrowOffsetRatio)) * 100;\n\n tooltip.style.setProperty(\"--arrow-offset-x\", `${arrowOffsetPercent}%`);\n }\n\n // Reposition tooltip back to original set position (e.g. top, left, bottom, right) to avoid positioning issue base on last position\n private _resetTooltipPositioningStyles(tooltip: HTMLElement) {\n tooltip.style.left = \"\";\n tooltip.style.right = \"\";\n tooltip.style.transform = \"\";\n }\n\n render() {\n return html`\n <div class=\"nys-tooltip__main\">\n <div\n class=\"nys-tooltip__wrapper\"\n @mouseenter=${this._handleTooltipEnter}\n @mouseleave=${this._handleBlurOrMouseLeave}\n @focusin=${this._handleTooltipEnter}\n @focusout=${this._handleBlurOrMouseLeave}\n >\n <span class=\"nys-tooltip__trigger\">\n <slot></slot>\n </span>\n </div>\n ${this.text?.trim()\n ? html`<div\n id=${this.id}\n class=\"nys-tooltip__content\"\n role=\"tooltip\"\n aria-hidden=${!this._active}\n ?active=${this._active}\n >\n <div class=\"nys-tooltip__inner\">${this.text}</div>\n <span class=\"nys-tooltip__arrow\"></span>\n </div>`\n : \"\"}\n </div>\n `;\n }\n}\n\nif (!customElements.get(\"nys-tooltip\")) {\n customElements.define(\"nys-tooltip\", NysTooltip);\n}\n"],"names":["t","e","s","o","n$2","r","n","S","c","i","h","a","l","p","d","u","f","b","y","styles","css","tooltipIdCounter","_NysTooltip","LitElement","tooltip","value","oldVal","slot","firstEl","changedProps","el","tagName","existingLabel","mergedLabel","svg","position","wrapper","triggerRect","tooltipRect","margin","spaceAvailable","tryOrder","userPosition","pos","bestPosition","maxSpace","wrapperRect","wrapperCenter","overflowLeft","overflowRight","newTooltipRect","arrowOffsetRatio","arrowOffsetPercent","html","NysTooltip","__decorateClass","property","state"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;A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M,GAPIH,EAQH,WAAA,WAAA,CAAA;AAcJC,EAAA;AAAA,EADHC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArB9BF,EAsBP,WAAA,YAAA,CAAA;AA0XD,eAAe,IAAI,aAAa,KACnC,eAAe,OAAO,eAAeA,CAAU;","x_google_ignoreList":[0,1,2,3]}
|
|
1
|
+
{"version":3,"file":"nys-tooltip.js","sources":["../src/nys-tooltip.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-tooltip.scss?inline\";\n\nlet tooltipIdCounter = 0; // Counter for generating unique IDs\n\nexport class NysTooltip extends LitElement {\n static styles = unsafeCSS(styles);\n\n @property({ type: String, reflect: true }) id = \"\";\n @property({ type: String }) text = \"\";\n @property({ type: Boolean, reflect: true }) inverted = false;\n @property({ type: Boolean, reflect: true }) focusable = false;\n\n // Track if tooltip is active (hovered or focused)\n @state()\n private _active = false;\n\n // Track if user set position is set explicitly\n private _userHasSetPosition = false;\n private _originalUserPosition: typeof this._position | null = null;\n // Internal flag to prevent dynamic positioning when not needed\n private _internallyUpdatingPosition = false;\n\n /********************* Position Logic *********************/\n private _position: \"top\" | \"bottom\" | \"left\" | \"right\" | null = null;\n\n @property({ type: String, reflect: true })\n get position() {\n return this._position;\n }\n\n set position(value) {\n const oldVal = this._position;\n this._position = value;\n this.requestUpdate(\"position\", oldVal);\n\n // The \"_internallyUpdatingPosition\" flag allows user's set position to take preference\n if (!this._internallyUpdatingPosition) {\n this._userHasSetPosition = value !== null;\n this._originalUserPosition = value;\n }\n }\n\n /**************** Lifecycle Methods ****************/\n constructor() {\n super();\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Generate a unique ID if not provided\n if (!this.id) {\n this.id = `nys-tooltip-${Date.now()}-${tooltipIdCounter++}`;\n }\n\n window.addEventListener(\"keydown\", this._handleEscapeKey);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"keydown\", this._handleEscapeKey);\n }\n\n private get _firstAssignedEl(): HTMLElement | undefined {\n const slot = this.shadowRoot?.querySelector(\"slot\");\n return slot?.assignedElements({ flatten: true })[0] as\n | HTMLElement\n | undefined;\n }\n\n firstUpdated() {\n const slot = this.shadowRoot?.querySelector(\"slot\");\n if (slot) {\n slot.addEventListener(\"slotchange\", () => {\n const firstEl = this._firstAssignedEl;\n if (firstEl) {\n this._applyFocusBehavior(firstEl);\n }\n });\n }\n }\n\n updated(changedProps: Map<string, unknown>) {\n super.updated(changedProps);\n\n const firstEl = this._firstAssignedEl;\n if (!firstEl) return;\n\n // Accounts for tooltip's text change (for code editor changes & VO)\n if (changedProps.has(\"text\")) {\n this._passAria(firstEl);\n }\n if (changedProps.has(\"focusable\")) {\n this._applyFocusBehavior(firstEl);\n }\n }\n\n /******************** Event Handlers ********************/\n // When toggling tooltip, check if user has set position to give it preference it space allows. Otherwise dynamically position tooltip.\n private _handleTooltipEnter = () => {\n this._active = true;\n this._addScrollListeners();\n\n // Try to honor user's original preference first\n if (this._userHasSetPosition && this._originalUserPosition) {\n if (this._doesPositionFit(this._originalUserPosition)) {\n this.position = this._originalUserPosition;\n // Check if current tooltip position overflows to edge of screen\n this.updateComplete.then(() => {\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n if (tooltip) this._shiftTooltipIntoViewport(tooltip);\n });\n return;\n }\n }\n\n // Otherwise fall back to auto logic\n this.autoPositionTooltip();\n };\n\n private _handleBlurOrMouseLeave = () => {\n this._active = false;\n this._removeScrollListeners();\n\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n\n if (tooltip) {\n this._resetTooltipPositioningStyles(tooltip);\n }\n };\n\n // Listen to window scroll so a focus tooltip can auto position even when user move across the page\n private _addScrollListeners() {\n window.addEventListener(\"scroll\", this._handleScrollOrResize, true);\n window.addEventListener(\"resize\", this._handleScrollOrResize);\n }\n\n private _removeScrollListeners() {\n window.removeEventListener(\"scroll\", this._handleScrollOrResize, true);\n window.removeEventListener(\"resize\", this._handleScrollOrResize);\n }\n\n private _handleScrollOrResize = () => {\n if (!this._active) return;\n\n if (this._userHasSetPosition && this._originalUserPosition) {\n if (this._doesPositionFit(this._originalUserPosition)) {\n this._setInternalPosition(this._originalUserPosition);\n\n // Check if current tooltip position overflows to edge of screen\n this.updateComplete.then(() => {\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n if (tooltip) this._shiftTooltipIntoViewport(tooltip);\n });\n } else {\n this.autoPositionTooltip();\n }\n } else {\n this.autoPositionTooltip();\n }\n };\n\n private _handleEscapeKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\" && this._active) {\n this._active = false;\n this._removeScrollListeners();\n\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n if (tooltip) {\n this._resetTooltipPositioningStyles(tooltip);\n }\n }\n };\n\n /******************** Functions ********************/\n // We need to pass `ariaLabel` or `ariaDescription` to the nys-components so they can announce both their label and the tooltip's text\n private _passAria(el: HTMLElement) {\n const tagName = el.tagName.toLowerCase();\n\n if (tagName.startsWith(\"nys-\")) {\n if (tagName === \"nys-icon\") {\n // For nys-icon, use ariaLabel instead\n const existingLabel = el.getAttribute(\"ariaLabel\") || \"\";\n const mergedLabel = existingLabel\n ? `${existingLabel}, ${this.text}`\n : this.text;\n\n el.setAttribute(\"ariaLabel\", mergedLabel);\n } else {\n // For other components like nys-button, use ariaDescription\n el.setAttribute(\"ariaDescription\", this.text);\n }\n }\n }\n\n // Applies focus behavior to an otherwise non focus element (i.e. nys-icon is non focusable by default)\n private async _applyFocusBehavior(el: HTMLElement) {\n if (!this.focusable) return;\n\n const tagName = el.tagName.toLowerCase();\n if (tagName === \"nys-icon\") {\n if (\"updateComplete\" in el) {\n await (el as any).updateComplete;\n }\n const svg = el.shadowRoot?.querySelector(\"svg\");\n if (svg) {\n svg.setAttribute(\"tabindex\", \"0\");\n }\n } else {\n el.setAttribute(\"tabindex\", \"0\");\n }\n }\n\n // Checks if user's set position fit with current viewport (Does not account for overflow texts at this moment)\n private _doesPositionFit(position: typeof this._position) {\n const wrapper = this.shadowRoot?.querySelector(\".nys-tooltip__wrapper\");\n const tooltip = this.shadowRoot?.querySelector(\".nys-tooltip__content\");\n\n if (!wrapper || !tooltip || position == null) return;\n\n const triggerRect = wrapper.getBoundingClientRect();\n const tooltipRect = tooltip.getBoundingClientRect();\n\n // Define some margin buffer between tooltip and trigger (to avoid touching the edges too tightly)\n const margin = 8;\n\n // Available space on each side relative to trigger rect and viewport\n const spaceAvailable = {\n top: triggerRect.top - margin,\n left: triggerRect.left - margin,\n bottom: window.innerHeight - triggerRect.bottom - margin,\n right: window.innerWidth - triggerRect.right - margin,\n };\n\n // Check if tooltip fits on each side (compare available space vs tooltip size)\n const fits = {\n top: spaceAvailable.top >= tooltipRect.height,\n bottom: spaceAvailable.bottom >= tooltipRect.height,\n left: spaceAvailable.left >= tooltipRect.width,\n right: spaceAvailable.right >= tooltipRect.width,\n };\n\n return fits[position];\n }\n\n // Calculates the best placement based on available space (flips placement if it doesn't fit)\n private async autoPositionTooltip() {\n const wrapper = this.shadowRoot?.querySelector(\n \".nys-tooltip__wrapper\",\n ) as HTMLElement;\n const tooltip = this.shadowRoot?.querySelector(\n \".nys-tooltip__content\",\n ) as HTMLElement;\n\n if (!wrapper || !tooltip) return;\n\n const triggerRect = wrapper.getBoundingClientRect();\n const margin = 8;\n\n const spaceAvailable = {\n top: triggerRect.top - margin,\n left: triggerRect.left - margin,\n bottom: window.innerHeight - triggerRect.bottom - margin,\n right: window.innerWidth - triggerRect.right - margin,\n };\n\n // Default tryOrder for auto mode\n let tryOrder: Array<keyof typeof spaceAvailable> = [\n \"top\",\n \"bottom\",\n \"right\",\n \"left\",\n ];\n\n // If user explicitly set a preferred position (even if it didn’t fit),\n // favor it first before trying others\n if (this._userHasSetPosition && this._originalUserPosition) {\n const userPosition = this._originalUserPosition;\n if (userPosition === \"left\") {\n tryOrder = [\"left\", \"right\", \"top\", \"bottom\"];\n } else if (userPosition === \"right\") {\n tryOrder = [\"right\", \"left\", \"top\", \"bottom\"];\n } else if (userPosition === \"top\") {\n tryOrder = [\"top\", \"bottom\", \"right\", \"left\"];\n } else if (userPosition === \"bottom\") {\n tryOrder = [\"bottom\", \"top\", \"right\", \"left\"];\n }\n }\n\n // 1) Try to find the first side that fits\n for (const pos of tryOrder) {\n if (this._doesPositionFit(pos)) {\n this._setInternalPosition(pos);\n await this.updateComplete;\n this._shiftTooltipIntoViewport(tooltip);\n return;\n }\n }\n\n // 2) Fallback: pick the side with the most space\n let bestPosition: keyof typeof spaceAvailable = \"top\";\n let maxSpace = spaceAvailable.top;\n\n for (const pos of tryOrder) {\n if (spaceAvailable[pos] > maxSpace) {\n maxSpace = spaceAvailable[pos];\n bestPosition = pos;\n }\n }\n this._setInternalPosition(bestPosition);\n await this.updateComplete;\n this._shiftTooltipIntoViewport(tooltip);\n }\n\n // Sets flag to distinguish to position's setter that we are updating \"position\" prop internally\n private _setInternalPosition(bestPosition: typeof this._position) {\n this._internallyUpdatingPosition = true;\n this.position = bestPosition;\n this._internallyUpdatingPosition = false;\n }\n\n // Determines if text of tooltip over-extends outside of viewport edge and adjust tooltip for horizontal overflow\n private _shiftTooltipIntoViewport(tooltip: HTMLElement) {\n const wrapper = this.shadowRoot?.querySelector(\n \".nys-tooltip__wrapper\",\n ) as HTMLElement;\n\n const wrapperRect = wrapper.getBoundingClientRect();\n const tooltipRect = tooltip.getBoundingClientRect();\n\n const wrapperCenter = wrapperRect.left + wrapperRect.width / 2;\n\n const overflowLeft = tooltipRect.left < 0;\n const overflowRight = tooltipRect.right > window.innerWidth;\n\n this._resetTooltipPositioningStyles(tooltip);\n\n // Tooltip is past the viewport edge, shift it inwards\n if (overflowLeft) {\n tooltip.style.left = \"0px\";\n tooltip.style.transform = \"none\";\n } else if (overflowRight) {\n tooltip.style.right = \"0px\";\n tooltip.style.left = \"auto\";\n tooltip.style.transform = \"none\";\n }\n\n // Recalculate tooltip rect after any shift\n const newTooltipRect = tooltip.getBoundingClientRect();\n\n // Arrow offset relative to tooltip width to maintain accuracy on zoom and out-of-bounds\n const arrowOffsetRatio =\n (wrapperCenter - newTooltipRect.left) / newTooltipRect.width;\n const arrowOffsetPercent = Math.max(0, Math.min(1, arrowOffsetRatio)) * 100;\n\n tooltip.style.setProperty(\"--arrow-offset-x\", `${arrowOffsetPercent}%`);\n }\n\n // Reposition tooltip back to original set position (e.g. top, left, bottom, right) to avoid positioning issue base on last position\n private _resetTooltipPositioningStyles(tooltip: HTMLElement) {\n tooltip.style.left = \"\";\n tooltip.style.right = \"\";\n tooltip.style.transform = \"\";\n }\n\n render() {\n return html`\n <div class=\"nys-tooltip__main\">\n <div\n class=\"nys-tooltip__wrapper\"\n @mouseenter=${this._handleTooltipEnter}\n @mouseleave=${this._handleBlurOrMouseLeave}\n @focusin=${this._handleTooltipEnter}\n @focusout=${this._handleBlurOrMouseLeave}\n >\n <span class=\"nys-tooltip__trigger\">\n <slot></slot>\n </span>\n </div>\n ${this.text?.trim()\n ? html`<div\n id=${this.id}\n class=\"nys-tooltip__content\"\n role=\"tooltip\"\n aria-hidden=${!this._active}\n ?active=${this._active}\n >\n <div class=\"nys-tooltip__inner\">${this.text}</div>\n <span class=\"nys-tooltip__arrow\"></span>\n </div>`\n : \"\"}\n </div>\n `;\n }\n}\n\nif (!customElements.get(\"nys-tooltip\")) {\n customElements.define(\"nys-tooltip\", NysTooltip);\n}\n"],"names":["tooltipIdCounter","_NysTooltip","LitElement","tooltip","e","value","oldVal","slot","firstEl","changedProps","el","tagName","existingLabel","mergedLabel","svg","position","wrapper","triggerRect","tooltipRect","margin","spaceAvailable","tryOrder","userPosition","pos","bestPosition","maxSpace","wrapperRect","wrapperCenter","overflowLeft","overflowRight","newTooltipRect","arrowOffsetRatio","arrowO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1.11.3",
|
|
4
4
|
"description": "The Tooltip component from the NYS Design System.",
|
|
5
5
|
"module": "dist/nys-tooltip.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"lit-analyze": "lit-analyzer '**/*.ts'"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"lit": "^3.
|
|
27
|
-
"typescript": "^5.
|
|
28
|
-
"vite": "^7.1.
|
|
26
|
+
"lit": "^3.3.1",
|
|
27
|
+
"typescript": "^5.9.3",
|
|
28
|
+
"vite": "^7.1.12"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
|
31
31
|
"new-york-state",
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./nys-tooltip";
|
package/dist/nys-tooltip.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
export declare class NysTooltip extends LitElement {
|
|
3
|
-
id: string;
|
|
4
|
-
text: string;
|
|
5
|
-
inverted: boolean;
|
|
6
|
-
focusable: boolean;
|
|
7
|
-
private _active;
|
|
8
|
-
private _userHasSetPosition;
|
|
9
|
-
private _originalUserPosition;
|
|
10
|
-
private _internallyUpdatingPosition;
|
|
11
|
-
static styles: import("lit").CSSResult;
|
|
12
|
-
/********************* Position Logic *********************/
|
|
13
|
-
private _position;
|
|
14
|
-
get position(): "top" | "bottom" | "left" | "right" | null;
|
|
15
|
-
set position(value: "top" | "bottom" | "left" | "right" | null);
|
|
16
|
-
/**************** Lifecycle Methods ****************/
|
|
17
|
-
constructor();
|
|
18
|
-
connectedCallback(): void;
|
|
19
|
-
disconnectedCallback(): void;
|
|
20
|
-
private get _firstAssignedEl();
|
|
21
|
-
firstUpdated(): void;
|
|
22
|
-
updated(changedProps: Map<string, unknown>): void;
|
|
23
|
-
/******************** Event Handlers ********************/
|
|
24
|
-
private _handleTooltipEnter;
|
|
25
|
-
private _handleBlurOrMouseLeave;
|
|
26
|
-
private _addScrollListeners;
|
|
27
|
-
private _removeScrollListeners;
|
|
28
|
-
private _handleScrollOrResize;
|
|
29
|
-
private _handleEscapeKey;
|
|
30
|
-
/******************** Functions ********************/
|
|
31
|
-
private _passAria;
|
|
32
|
-
private _applyFocusBehavior;
|
|
33
|
-
private _doesPositionFit;
|
|
34
|
-
private autoPositionTooltip;
|
|
35
|
-
private _setInternalPosition;
|
|
36
|
-
private _shiftTooltipIntoViewport;
|
|
37
|
-
private _resetTooltipPositioningStyles;
|
|
38
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|