@webjsdev/ui 0.3.2 → 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.2",
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": {
@@ -343,22 +343,24 @@ UiDropdownMenuContent.register('ui-dropdown-menu-content');
343
343
  export class UiDropdownMenuItem extends WebComponent {
344
344
  static properties = {
345
345
  variant: { type: String, reflect: true },
346
+ inset: { type: Boolean },
346
347
  };
347
348
  declare variant: 'default' | 'destructive';
349
+ declare inset: boolean;
348
350
 
349
351
  constructor() {
350
352
  super();
351
353
  this.variant = 'default';
354
+ this.inset = false;
352
355
  }
353
356
 
354
357
  render() {
355
- const inset = this.hasAttribute('inset');
356
358
  return html`<div
357
359
  data-slot="dropdown-menu-item"
358
360
  role="menuitem"
359
361
  tabindex="-1"
360
362
  data-variant=${this.variant}
361
- ?data-inset=${inset}
363
+ ?data-inset=${this.inset}
362
364
  class=${dropdownMenuItemClass()}
363
365
  @click=${this._onClick}
364
366
  @pointerenter=${this._onPointerEnter}
@@ -394,11 +396,18 @@ UiDropdownMenuItem.register('ui-dropdown-menu-item');
394
396
  // --------------------------------------------------------------------------
395
397
 
396
398
  export class UiDropdownMenuLabel extends WebComponent {
399
+ static properties = { inset: { type: Boolean } };
400
+ declare inset: boolean;
401
+
402
+ constructor() {
403
+ super();
404
+ this.inset = false;
405
+ }
406
+
397
407
  render() {
398
- const inset = this.hasAttribute('inset');
399
408
  return html`<div
400
409
  data-slot="dropdown-menu-label"
401
- ?data-inset=${inset}
410
+ ?data-inset=${this.inset}
402
411
  class=${dropdownMenuLabelClass()}
403
412
  ><slot></slot></div>`;
404
413
  }
@@ -540,6 +549,14 @@ export class UiDropdownMenuSub extends WebComponent {
540
549
  UiDropdownMenuSub.register('ui-dropdown-menu-sub');
541
550
 
542
551
  export class UiDropdownMenuSubTrigger extends WebComponent {
552
+ static properties = { inset: { type: Boolean } };
553
+ declare inset: boolean;
554
+
555
+ constructor() {
556
+ super();
557
+ this.inset = false;
558
+ }
559
+
543
560
  // SSR-safe: linkedom doesn't implement closest() on custom elements.
544
561
  _sub(): UiDropdownMenuSub | null {
545
562
  if (typeof this.closest !== 'function') return null;
@@ -547,7 +564,6 @@ export class UiDropdownMenuSubTrigger extends WebComponent {
547
564
  }
548
565
 
549
566
  render() {
550
- const inset = this.hasAttribute('inset');
551
567
  const open = !!this._sub()?.open;
552
568
  return html`<div
553
569
  data-slot="dropdown-menu-sub-trigger"
@@ -556,7 +572,7 @@ export class UiDropdownMenuSubTrigger extends WebComponent {
556
572
  aria-haspopup="menu"
557
573
  aria-expanded=${String(open)}
558
574
  data-state=${open ? 'open' : 'closed'}
559
- ?data-inset=${inset}
575
+ ?data-inset=${this.inset}
560
576
  class=${dropdownMenuSubTriggerClass()}
561
577
  @click=${this._onClick}
562
578
  @pointerenter=${this._onPointerEnter}
@@ -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
- const delay = Number(this.getAttribute('open-delay') ?? 700);
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
- const delay = Number(this.getAttribute('close-delay') ?? 300);
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() {
@@ -33,7 +33,7 @@
33
33
  * Events:
34
34
  * `ui-pressed-change` on <ui-toggle>: `{ detail: { pressed } }` after a click.
35
35
  *
36
- * Keyboard: native button Enter / Space activates (via the inner <button>).
36
+ * Keyboard: native button. Enter / Space activates (via the inner <button>).
37
37
  *
38
38
  * Design tokens used: --muted, --muted-foreground, --accent, --accent-foreground,
39
39
  * --input, --background, --ring, --destructive.
@@ -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 = Number(this.getAttribute('delay-duration') ?? 700);
86
- const skipDelay = Number(this.getAttribute('skip-delay-duration') ?? 300);
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;