@nysds/nys-tooltip 1.19.3 → 1.19.4
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 +2 -2
- package/package.json +1 -1
- package/dist/nys-tooltip.d.ts +0 -125
package/dist/nys-tooltip.js
CHANGED
|
@@ -5,12 +5,12 @@ import { property as p, state as v } from "lit/decorators.js";
|
|
|
5
5
|
* █ █ █ █▄▄▄█ ▀▀▀▄▄ █ █ ▀▀▀▄▄
|
|
6
6
|
* █ ▀█ █ █▄▄▄█ █▄▄▀ █▄▄▄█
|
|
7
7
|
*
|
|
8
|
-
* Tooltip Component v1.19.
|
|
8
|
+
* Tooltip Component v1.19.4
|
|
9
9
|
* Part of the New York State Design System
|
|
10
10
|
* Repository: https://github.com/its-hcd/nysds
|
|
11
11
|
* License: MIT
|
|
12
12
|
*/
|
|
13
|
-
const g = `: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-
|
|
13
|
+
const g = `: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-font-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__content{position:fixed;top:0;left:0;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{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;overflow-wrap:anywhere;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}.fade-out{opacity:0;transition:opacity .2s ease-out}:host([position=top]) .nys-tooltip__arrow{top:100%;left:var(--arrow-offset-x, 50%);transform:translate(-50%)}:host([position=bottom]) .nys-tooltip__arrow{bottom:100%;left:var(--arrow-offset-x, 50%);transform:translate(-50%) rotate(180deg)}:host([position=left]) .nys-tooltip__arrow{left:100%;top:50%;transform:translateY(-50%) rotate(-90deg);margin-left:-4px}: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, #ffffff)}: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)}}`;
|
|
14
14
|
var w = Object.defineProperty, b = Object.getOwnPropertyDescriptor, c = (d, t, e, n) => {
|
|
15
15
|
for (var o = n > 1 ? void 0 : n ? b(t, e) : t, i = d.length - 1, s; i >= 0; i--)
|
|
16
16
|
(s = d[i]) && (o = (n ? s(t, e, o) : s(o)) || o);
|
package/package.json
CHANGED
package/dist/nys-tooltip.d.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
/**
|
|
3
|
-
* Shows contextual help text on hover/focus. Auto-positions to stay within viewport and supports keyboard dismiss.
|
|
4
|
-
*
|
|
5
|
-
* Link to a trigger element via `for` attribute matching the trigger's `id`. Tooltip appears on hover or focus
|
|
6
|
-
* and dismisses on blur, mouse leave, or Escape key. Use for supplementary info only—not critical content.
|
|
7
|
-
*
|
|
8
|
-
* @accessibility
|
|
9
|
-
* - Linked to trigger element via `for` attribute (must match trigger's `id`).
|
|
10
|
-
* - `role="tooltip"` with dynamic `aria-hidden` based on visibility.
|
|
11
|
-
* - Keyboard accessible: Tab to trigger, Enter/Space shows tooltip, Escape dismisses.
|
|
12
|
-
* - Screen readers announce tooltip text when visible.
|
|
13
|
-
* - Visual focus indicators on trigger elements meet WCAG 2.2 AA standards.
|
|
14
|
-
* - Auto-positioning respects viewport bounds to prevent content loss.
|
|
15
|
-
*
|
|
16
|
-
* @summary Contextual tooltip with auto-positioning, keyboard support, and screen reader integration.
|
|
17
|
-
* @element nys-tooltip
|
|
18
|
-
*
|
|
19
|
-
* @example Basic
|
|
20
|
-
* ```html
|
|
21
|
-
* <div style="display: flex; justify-content: center; gap: 5px; padding: 40px;">
|
|
22
|
-
* <nys-tooltip for="my-button" text="I am a tooltip."></nys-tooltip>
|
|
23
|
-
* <nys-button id="my-button" label="Hover Me"></nys-button>
|
|
24
|
-
* </div>
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @example Position
|
|
28
|
-
* ```html
|
|
29
|
-
* <div style="display: flex; justify-content: center; gap: 5px; padding: 40px;">
|
|
30
|
-
* <p>Hover over the icon</p>
|
|
31
|
-
* <nys-tooltip
|
|
32
|
-
* for="my-icon2"
|
|
33
|
-
* text="I am a tooltip."
|
|
34
|
-
* position="right"
|
|
35
|
-
* >
|
|
36
|
-
* </nys-tooltip>
|
|
37
|
-
* <nys-icon id="my-icon2" name="info" size="3xl"></nys-icon>
|
|
38
|
-
* </div>
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @example Inverted
|
|
42
|
-
* ```html
|
|
43
|
-
* <div style="background-color: #1b1b1b; color: #ffffff; padding: 40px; display: flex; gap: 5px">
|
|
44
|
-
* <p>Hover over the icon</p>
|
|
45
|
-
* <nys-tooltip
|
|
46
|
-
* for="my-tooltip3"
|
|
47
|
-
* text="I am a tooltip."
|
|
48
|
-
* inverted
|
|
49
|
-
* >
|
|
50
|
-
* </nys-tooltip>
|
|
51
|
-
* <nys-icon id="my-tooltip3" name="info" size="3xl"></nys-icon>
|
|
52
|
-
* </div>
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export declare class NysTooltip extends LitElement {
|
|
56
|
-
static styles: import("lit").CSSResult;
|
|
57
|
-
/** Unique identifier. Auto-generated if not provided. */
|
|
58
|
-
id: string;
|
|
59
|
-
/** Tooltip content text. Required. */
|
|
60
|
-
text: string;
|
|
61
|
-
/** Adjusts colors for dark backgrounds. */
|
|
62
|
-
inverted: boolean;
|
|
63
|
-
/** ID of the trigger element to attach this tooltip to. Required. */
|
|
64
|
-
for: string;
|
|
65
|
-
private _active;
|
|
66
|
-
private _userHasSetPosition;
|
|
67
|
-
private _originalUserPosition;
|
|
68
|
-
private _internallyUpdatingPosition;
|
|
69
|
-
private _hideTimeout;
|
|
70
|
-
private _position;
|
|
71
|
-
private _resizeObserver;
|
|
72
|
-
/**
|
|
73
|
-
* Preferred position relative to trigger. Auto-adjusts if space is insufficient.
|
|
74
|
-
* @default null (auto-positioned based on available space)
|
|
75
|
-
*/
|
|
76
|
-
get position(): "top" | "bottom" | "left" | "right" | null;
|
|
77
|
-
set position(value: "top" | "bottom" | "left" | "right" | null);
|
|
78
|
-
/**
|
|
79
|
-
* Lifecycle Methods
|
|
80
|
-
* --------------------------------------------------------------------------
|
|
81
|
-
*/
|
|
82
|
-
constructor();
|
|
83
|
-
connectedCallback(): void;
|
|
84
|
-
disconnectedCallback(): void;
|
|
85
|
-
firstUpdated(): Promise<void>;
|
|
86
|
-
updated(changedProps: Map<string, unknown>): void;
|
|
87
|
-
/**
|
|
88
|
-
* Event Handlers
|
|
89
|
-
* --------------------------------------------------------------------------
|
|
90
|
-
*/
|
|
91
|
-
private _showTooltip;
|
|
92
|
-
private _handleBlurOrMouseLeave;
|
|
93
|
-
private _triggerFadeOut;
|
|
94
|
-
private _cancelFadeOut;
|
|
95
|
-
private _addScrollListeners;
|
|
96
|
-
private _removeScrollListeners;
|
|
97
|
-
private _handleScrollOrResize;
|
|
98
|
-
private _handleEscapeKey;
|
|
99
|
-
/**
|
|
100
|
-
* Functions
|
|
101
|
-
* --------------------------------------------------------------------------
|
|
102
|
-
*/
|
|
103
|
-
private _getReferenceElement;
|
|
104
|
-
private _passAria;
|
|
105
|
-
/**
|
|
106
|
-
* In React, the reference element found is often the native HTML element within the nys-component.
|
|
107
|
-
* Therefore, this function accounts for the closest NYS component ancestor that supports a tooltip prop.
|
|
108
|
-
*/
|
|
109
|
-
private _applyTooltipPropToFormComponent;
|
|
110
|
-
private _applyFocusBehavior;
|
|
111
|
-
/**
|
|
112
|
-
* Checks if the tooltip fits inside the viewport on the given side of the trigger.
|
|
113
|
-
* Used for auto-positioning. Ignores text overflow for now.
|
|
114
|
-
*/
|
|
115
|
-
private _doesPositionFit;
|
|
116
|
-
private _userPositionTooltip;
|
|
117
|
-
private _autoPositionTooltip;
|
|
118
|
-
private _positionStartingBase;
|
|
119
|
-
private _positionTooltipElement;
|
|
120
|
-
private applyInverseTransform;
|
|
121
|
-
private _setInternalPosition;
|
|
122
|
-
private _shiftTooltipIntoViewport;
|
|
123
|
-
private _resetTooltipPositioningStyles;
|
|
124
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
125
|
-
}
|