@rogieking/figui3 4.15.8 → 4.15.10

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/fig.js CHANGED
@@ -12213,6 +12213,7 @@ class FigFillPicker extends HTMLElement {
12213
12213
  this.#dialog.anchor = this.anchorElement || this.#trigger;
12214
12214
  const dialogPosition = this.getAttribute("dialog-position") || "left";
12215
12215
  this.#dialog.setAttribute("position", dialogPosition);
12216
+ this.#dialog.setAttribute("offset", this.getAttribute("dialog-offset") || "8 8");
12216
12217
 
12217
12218
  const builtinModes = ["solid", "gradient", "image", "video", "webcam"];
12218
12219
  const builtinLabels = {
@@ -12446,6 +12447,7 @@ class FigFillPicker extends HTMLElement {
12446
12447
  <fig-handle
12447
12448
  type="color"
12448
12449
  color="${this.#hsvToHex({ ...this.#color, a: 1 })}"
12450
+ data-no-color-picker
12449
12451
  drag
12450
12452
  drag-surface=".fig-fill-picker-color-area"
12451
12453
  drag-axes="x,y"
@@ -15018,6 +15020,10 @@ class FigHandle extends HTMLElement {
15018
15020
  return this.classList.contains("fig-input-gradient-ghost");
15019
15021
  }
15020
15022
 
15023
+ get #canOpenColorPicker() {
15024
+ return !this.hasAttribute("data-no-color-picker");
15025
+ }
15026
+
15021
15027
  get #dragEnabled() {
15022
15028
  const v = this.getAttribute("drag");
15023
15029
  return v !== null && v !== "false";
@@ -15246,7 +15252,12 @@ class FigHandle extends HTMLElement {
15246
15252
  select() {
15247
15253
  if (this.hasAttribute("disabled")) return;
15248
15254
  this.setAttribute("selected", "");
15249
- if (this.getAttribute("type") === "color" && !this.#isDragging && this.#usesColorTip)
15255
+ if (
15256
+ this.getAttribute("type") === "color" &&
15257
+ this.#canOpenColorPicker &&
15258
+ !this.#isDragging &&
15259
+ this.#usesColorTip
15260
+ )
15250
15261
  this.#showColorTip();
15251
15262
  }
15252
15263
 
@@ -15261,7 +15272,11 @@ class FigHandle extends HTMLElement {
15261
15272
  this.#didDrag = false;
15262
15273
  return;
15263
15274
  }
15264
- if (this.getAttribute("type") === "color" && !this.#usesColorTip) {
15275
+ if (
15276
+ this.getAttribute("type") === "color" &&
15277
+ this.#canOpenColorPicker &&
15278
+ !this.#usesColorTip
15279
+ ) {
15265
15280
  this.#openDirectColorPicker();
15266
15281
  return;
15267
15282
  }
@@ -15279,6 +15294,7 @@ class FigHandle extends HTMLElement {
15279
15294
  if (e.key !== "Enter" && e.key !== " ") return;
15280
15295
  if (!this.hasAttribute("selected")) return;
15281
15296
  if (this.getAttribute("type") !== "color") return;
15297
+ if (!this.#canOpenColorPicker) return;
15282
15298
  e.preventDefault();
15283
15299
  if (this.#usesColorTip) {
15284
15300
  if (!this.#colorTip) this.#showColorTip();
@@ -15414,6 +15430,7 @@ class FigHandle extends HTMLElement {
15414
15430
  const dx = e.clientX - startX;
15415
15431
  const dy = e.clientY - startY;
15416
15432
  if (dx * dx + dy * dy < DRAG_THRESHOLD * DRAG_THRESHOLD) return;
15433
+ this.#closeColorPickerForDrag();
15417
15434
  this.classList.add("dragging");
15418
15435
  this.style.cursor = "grabbing";
15419
15436
  if (!this.hasAttribute("selected")) this.select();
@@ -15554,6 +15571,7 @@ class FigHandle extends HTMLElement {
15554
15571
  const picker = document.createElement("fig-fill-picker");
15555
15572
  picker.setAttribute("mode", "solid");
15556
15573
  picker.setAttribute("alpha", "true");
15574
+ picker.setAttribute("dialog-offset", "8 8");
15557
15575
  picker.setAttribute("value", this.#directColorPickerValue());
15558
15576
  picker.anchorElement = this;
15559
15577
 
@@ -15589,6 +15607,12 @@ class FigHandle extends HTMLElement {
15589
15607
  this.removeAttribute("selected");
15590
15608
  }
15591
15609
 
15610
+ #closeColorPickerForDrag() {
15611
+ if (this.getAttribute("type") !== "color") return;
15612
+ this.#hideColorTip();
15613
+ this.#directColorPicker?.close();
15614
+ }
15615
+
15592
15616
  #showColorTip() {
15593
15617
  if (this.#colorTip) return;
15594
15618
  const tip = document.createElement("fig-color-tip");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "4.15.8",
3
+ "version": "4.15.10",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "MIT",