@webjsdev/ui 0.3.3 → 0.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webjsdev/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "An AI-first component library - class-helper functions for visuals, custom elements only where state matters. Source-copied into your repo, you own it. Works with any Tailwind v4 project.",
|
|
6
6
|
"bin": {
|
|
@@ -55,8 +55,14 @@ export const hoverCardContentClass = (): string =>
|
|
|
55
55
|
export class UiHoverCard extends WebComponent {
|
|
56
56
|
static properties = {
|
|
57
57
|
open: { type: Boolean, reflect: true },
|
|
58
|
+
openDelay: { type: Number },
|
|
59
|
+
closeDelay: { type: Number },
|
|
58
60
|
};
|
|
59
61
|
declare open: boolean;
|
|
62
|
+
// `openDelay` / `closeDelay` ride the `open-delay` / `close-delay`
|
|
63
|
+
// attributes (shadcn parity), read as typed props.
|
|
64
|
+
declare openDelay: number;
|
|
65
|
+
declare closeDelay: number;
|
|
60
66
|
|
|
61
67
|
_showTimer: number | undefined;
|
|
62
68
|
_hideTimer: number | undefined;
|
|
@@ -64,6 +70,8 @@ export class UiHoverCard extends WebComponent {
|
|
|
64
70
|
constructor() {
|
|
65
71
|
super();
|
|
66
72
|
this.open = false;
|
|
73
|
+
this.openDelay = 700;
|
|
74
|
+
this.closeDelay = 300;
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
// Back-compat getter.
|
|
@@ -71,14 +79,12 @@ export class UiHoverCard extends WebComponent {
|
|
|
71
79
|
|
|
72
80
|
show(): void {
|
|
73
81
|
clearTimeout(this._hideTimer);
|
|
74
|
-
|
|
75
|
-
this._showTimer = window.setTimeout(() => { this.open = true; }, delay);
|
|
82
|
+
this._showTimer = window.setTimeout(() => { this.open = true; }, this.openDelay);
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
hide(): void {
|
|
79
86
|
clearTimeout(this._showTimer);
|
|
80
|
-
|
|
81
|
-
this._hideTimer = window.setTimeout(() => { this.open = false; }, delay);
|
|
87
|
+
this._hideTimer = window.setTimeout(() => { this.open = false; }, this.closeDelay);
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
render() {
|
|
@@ -64,8 +64,14 @@ let lastTooltipHideAt = 0;
|
|
|
64
64
|
export class UiTooltip extends WebComponent {
|
|
65
65
|
static properties = {
|
|
66
66
|
open: { type: Boolean, reflect: true },
|
|
67
|
+
delayDuration: { type: Number },
|
|
68
|
+
skipDelayDuration: { type: Number },
|
|
67
69
|
};
|
|
68
70
|
declare open: boolean;
|
|
71
|
+
// `delayDuration` / `skipDelayDuration` ride the `delay-duration` /
|
|
72
|
+
// `skip-delay-duration` attributes (shadcn parity), read as typed props.
|
|
73
|
+
declare delayDuration: number;
|
|
74
|
+
declare skipDelayDuration: number;
|
|
69
75
|
|
|
70
76
|
_showTimer: number | undefined;
|
|
71
77
|
_hideTimer: number | undefined;
|
|
@@ -73,6 +79,8 @@ export class UiTooltip extends WebComponent {
|
|
|
73
79
|
constructor() {
|
|
74
80
|
super();
|
|
75
81
|
this.open = false;
|
|
82
|
+
this.delayDuration = 700;
|
|
83
|
+
this.skipDelayDuration = 300;
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
// Back-compat getter for tests + external code that read `el.isOpen`
|
|
@@ -82,8 +90,8 @@ export class UiTooltip extends WebComponent {
|
|
|
82
90
|
show(): void {
|
|
83
91
|
clearTimeout(this._showTimer);
|
|
84
92
|
clearTimeout(this._hideTimer);
|
|
85
|
-
const delay =
|
|
86
|
-
const skipDelay =
|
|
93
|
+
const delay = this.delayDuration;
|
|
94
|
+
const skipDelay = this.skipDelayDuration;
|
|
87
95
|
const sinceLastHide = Date.now() - lastTooltipHideAt;
|
|
88
96
|
if (lastTooltipHideAt > 0 && sinceLastHide < skipDelay) {
|
|
89
97
|
this.open = true;
|