@rogieking/figui3 1.6.6 → 1.6.8

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/components.css CHANGED
@@ -1867,6 +1867,7 @@ dialog,
1867
1867
  padding: 0;
1868
1868
  outline: 0;
1869
1869
  border: 0;
1870
+ inset: auto;
1870
1871
  color: var(--figma-color-text);
1871
1872
  border-radius: var(--radius-large, 0.8125rem);
1872
1873
  background: var(--figma-color-bg);
@@ -1981,7 +1982,8 @@ dialog[is="fig-dialog"] {
1981
1982
  }
1982
1983
 
1983
1984
  /* Tooltip */
1984
- fig-tooltip {
1985
+ fig-tooltip,
1986
+ fig-popover {
1985
1987
  display: contents;
1986
1988
  }
1987
1989
  .fig-tooltip {
package/example.html CHANGED
@@ -25,6 +25,46 @@
25
25
 
26
26
  <h2><label>Effects/</label>UI3 Components</h2>
27
27
  </fig-header>
28
+
29
+ <fig-popover action="manual"
30
+ open="true"
31
+ size="large">
32
+ <fig-button>
33
+ Hover me
34
+ </fig-button>
35
+ <div popover>
36
+ <fig-header>
37
+ <h2>Slider</h2>
38
+ </fig-header>
39
+ <fig-dropdown>
40
+ <option>One</option>
41
+ <option>Two</option>
42
+ </fig-dropdown>
43
+ <fig-field direction="horizontal">
44
+ <label>Slider</label>
45
+ <fig-slider min="1"
46
+ max="100"
47
+ value="50"
48
+ step="1"
49
+ units="%"
50
+ transform="100">
51
+ </fig-slider>
52
+ </fig-field>
53
+ <br />
54
+ <fig-field direction="horizontal">
55
+ <label>Slider</label>
56
+ <fig-slider min="1"
57
+ max="100"
58
+ value="50"
59
+ step="1"
60
+ units="%"
61
+ transform="100">
62
+ </fig-slider>
63
+
64
+ </fig-field>
65
+ </div>
66
+ </fig-popover>
67
+
28
68
  <fig-content>
29
69
 
30
70
  <br /><br /><br /><br /><br /><br /><br /><br /><br />
package/fig.js CHANGED
@@ -225,7 +225,6 @@ class FigTooltip extends HTMLElement {
225
225
  this.action = this.getAttribute("action") || "hover";
226
226
  let delay = parseInt(this.getAttribute("delay"));
227
227
  this.delay = !isNaN(delay) ? delay : 500;
228
- this.isOpen = false;
229
228
 
230
229
  // Bind methods that will be used as event listeners
231
230
  this.#boundHideOnChromeOpen = this.#hideOnChromeOpen.bind(this);
@@ -366,7 +365,13 @@ class FigTooltip extends HTMLElement {
366
365
  }
367
366
  }
368
367
  static get observedAttributes() {
369
- return ["action", "delay"];
368
+ return ["action", "delay", "open"];
369
+ }
370
+ get open() {
371
+ return this.hasAttribute("open") && this.getAttribute("open") === "true";
372
+ }
373
+ set open(value) {
374
+ this.setAttribute("open", value);
370
375
  }
371
376
  attributeChangedCallback(name, oldValue, newValue) {
372
377
  if (name === "action") {
@@ -376,6 +381,17 @@ class FigTooltip extends HTMLElement {
376
381
  let delay = parseInt(newValue);
377
382
  this.delay = !isNaN(delay) ? delay : 500;
378
383
  }
384
+ if (name === "open") {
385
+ if (newValue === "true") {
386
+ requestAnimationFrame(() => {
387
+ this.showDelayedPopup();
388
+ });
389
+ } else {
390
+ requestAnimationFrame(() => {
391
+ this.hidePopup();
392
+ });
393
+ }
394
+ }
379
395
  }
380
396
 
381
397
  #hideOnChromeOpen(e) {
@@ -383,11 +399,16 @@ class FigTooltip extends HTMLElement {
383
399
 
384
400
  // Check if the clicked element is a select or opens a dialog
385
401
  const target = e.target;
402
+
403
+ // If the target is a child of this.popup, return early
404
+ if (this.popup && this.popup.contains(target)) {
405
+ return;
406
+ }
407
+
386
408
  if (
387
409
  target.tagName === "SELECT" ||
388
410
  target.hasAttribute("popover") ||
389
- target.closest("dialog") ||
390
- target.onclick?.toString().includes("alert")
411
+ target.closest("dialog")
391
412
  ) {
392
413
  this.hidePopup();
393
414
  }
@@ -403,26 +424,19 @@ customElements.define("fig-tooltip", FigTooltip);
403
424
  * @attr {string} size - The size of the popover
404
425
  */
405
426
  class FigPopover extends FigTooltip {
406
- static observedAttributes = ["action", "size"];
407
-
408
427
  constructor() {
409
428
  super();
410
429
  this.action = this.getAttribute("action") || "click";
411
430
  this.delay = parseInt(this.getAttribute("delay")) || 0;
412
431
  }
413
432
  render() {
414
- //this.destroy()
415
- //if (!this.popup) {
416
433
  this.popup = this.popup || this.querySelector("[popover]");
417
434
  this.popup.setAttribute("class", "fig-popover");
418
435
  this.popup.style.position = "fixed";
419
- this.popup.style.display = "block";
420
- this.popup.style.pointerEvents = "none";
436
+ this.popup.style.visibility = "hidden";
437
+ this.popup.style.display = "inline-flex";
421
438
  document.body.append(this.popup);
422
- //}
423
439
  }
424
-
425
- destroy() {}
426
440
  }
427
441
  customElements.define("fig-popover", FigPopover);
428
442
 
@@ -671,6 +685,7 @@ class FigSlider extends HTMLElement {
671
685
 
672
686
  constructor() {
673
687
  super();
688
+ this.initialInnerHTML = this.innerHTML;
674
689
 
675
690
  // Bind the event handlers
676
691
  this.#boundHandleInput = (e) => {
@@ -800,7 +815,6 @@ class FigSlider extends HTMLElement {
800
815
  }
801
816
 
802
817
  connectedCallback() {
803
- this.initialInnerHTML = this.innerHTML;
804
818
  this.#regenerateInnerHTML();
805
819
  }
806
820
 
package/glitch.html ADDED
@@ -0,0 +1,70 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport"
7
+ content="width=device-width, initial-scale=1.0">
8
+ <title>Figma UI3 Web Components</title>
9
+ <link rel="stylesheet"
10
+ type="text/css"
11
+ href="fig.css">
12
+ <script src="fig.js"></script>
13
+ <style>
14
+ body {
15
+ width: 480px;
16
+ margin: 0 auto;
17
+ }
18
+ </style>
19
+ </head>
20
+
21
+ <body>
22
+
23
+
24
+ <fig-header>
25
+
26
+ <h2><label>Effects/</label>UI3 Components</h2>
27
+ </fig-header>
28
+
29
+ <fig-popover action="manual"
30
+ open="true"
31
+ size="large">
32
+ <fig-button>
33
+ Hover me
34
+ </fig-button>
35
+ <div popover>
36
+ <fig-header>
37
+ <h2>Slider</h2>
38
+ </fig-header>
39
+ <fig-dropdown>
40
+ <option>One</option>
41
+ <option>Two</option>
42
+ </fig-dropdown>
43
+ <fig-field direction="horizontal">
44
+ <label>Slider</label>
45
+ <fig-slider min="1"
46
+ max="100"
47
+ value="50"
48
+ step="1"
49
+ units="%"
50
+ transform="100">
51
+ </fig-slider>
52
+ </fig-field>
53
+ <br />
54
+ <fig-field direction="horizontal">
55
+ <label>Slider</label>
56
+ <fig-slider min="1"
57
+ max="100"
58
+ value="50"
59
+ step="1"
60
+ units="%"
61
+ transform="100">
62
+ </fig-slider>
63
+
64
+ </fig-field>
65
+ </div>
66
+ </fig-popover>
67
+
68
+ </body>
69
+
70
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {