@rogieking/figui3 2.35.0 → 2.36.0

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.
Files changed (3) hide show
  1. package/components.css +5 -0
  2. package/fig.js +31 -1
  3. package/package.json +1 -1
package/components.css CHANGED
@@ -1517,6 +1517,11 @@ fig-3d-rotate {
1517
1517
  var(--gradient-start-color),
1518
1518
  var(--gradient-end-color)
1519
1519
  );
1520
+ &.selected {
1521
+ background: var(--figma-color-border-strong) !important;
1522
+ inset: -1px;
1523
+ border-radius: var(--radius-medium);
1524
+ }
1520
1525
 
1521
1526
  &.front {
1522
1527
  background: var(--front-face-bg);
package/fig.js CHANGED
@@ -6462,7 +6462,7 @@ class Fig3DRotate extends HTMLElement {
6462
6462
  #fieldInputs = {};
6463
6463
 
6464
6464
  static get observedAttributes() {
6465
- return ["value", "precision", "aspect-ratio", "fields", "perspective", "perspective-origin", "transform-origin"];
6465
+ return ["value", "precision", "aspect-ratio", "fields", "perspective", "perspective-origin", "transform-origin", "selected", "drag"];
6466
6466
  }
6467
6467
 
6468
6468
  connectedCallback() {
@@ -6475,6 +6475,8 @@ class Fig3DRotate extends HTMLElement {
6475
6475
  const val = this.getAttribute("value");
6476
6476
  if (val) this.#parseValue(val);
6477
6477
  this.#render();
6478
+ this.#syncSelected(this.getAttribute("selected"));
6479
+ this.#syncDragState();
6478
6480
  }
6479
6481
 
6480
6482
  disconnectedCallback() {
@@ -6522,6 +6524,20 @@ class Fig3DRotate extends HTMLElement {
6522
6524
  }
6523
6525
  }
6524
6526
 
6527
+ #syncDragState() {
6528
+ if (!this.#container) return;
6529
+ this.#container.style.cursor = this.#dragEnabled ? "" : "default";
6530
+ }
6531
+
6532
+ #syncSelected(value) {
6533
+ if (!this.#cube) return;
6534
+ const faces = this.#cube.querySelectorAll(".fig-3d-rotate-face");
6535
+ const name = value ? value.trim().toLowerCase() : "";
6536
+ for (const face of faces) {
6537
+ face.classList.toggle("selected", name !== "" && face.classList.contains(name));
6538
+ }
6539
+ }
6540
+
6525
6541
  #parseFields(str) {
6526
6542
  if (!str || !str.trim()) {
6527
6543
  this.#fields = [];
@@ -6551,6 +6567,14 @@ class Fig3DRotate extends HTMLElement {
6551
6567
  this.#syncTransformOrigin(newValue);
6552
6568
  return;
6553
6569
  }
6570
+ if (name === "selected") {
6571
+ this.#syncSelected(newValue);
6572
+ return;
6573
+ }
6574
+ if (name === "drag") {
6575
+ this.#syncDragState();
6576
+ return;
6577
+ }
6554
6578
  if (name === "fields") {
6555
6579
  this.#parseFields(newValue);
6556
6580
  if (this.#cube) this.#render();
@@ -6695,7 +6719,13 @@ class Fig3DRotate extends HTMLElement {
6695
6719
  window.addEventListener("keyup", this.#boundKeyUp);
6696
6720
  }
6697
6721
 
6722
+ get #dragEnabled() {
6723
+ const attr = this.getAttribute("drag");
6724
+ return attr === null || attr.toLowerCase() !== "false";
6725
+ }
6726
+
6698
6727
  #startDrag(e) {
6728
+ if (!this.#dragEnabled) return;
6699
6729
  e.preventDefault();
6700
6730
  this.#isDragging = true;
6701
6731
  this.#container.classList.add("dragging");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "2.35.0",
3
+ "version": "2.36.0",
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",