@rogieking/figui3 1.6.4 → 1.6.5

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
@@ -664,10 +664,6 @@ select {
664
664
  padding-right: 1.5rem;
665
665
  }
666
666
 
667
- fig-dialog > *:not(dialog) {
668
- display: none !important;
669
- }
670
-
671
667
  /* Dropdown */
672
668
  fig-dropdown,
673
669
  .fig-dropdown {
@@ -1938,49 +1934,38 @@ dialog,
1938
1934
  }
1939
1935
  }
1940
1936
  }
1941
- fig-dialog,
1942
- .fig-dialog {
1943
- display: contents;
1937
+ dialog[is="fig-dialog"] {
1944
1938
  --offset: 1rem;
1945
1939
  --translate-x: -50%;
1946
1940
  --translate-y: -50%;
1941
+ --z-index: 999999;
1947
1942
 
1948
- dialog {
1949
- position: fixed;
1950
- top: 50%;
1951
- left: 50%;
1952
- margin: 0;
1953
- z-index: 999999;
1954
- transform: translate(var(--translate-x), var(--translate-y));
1955
- }
1943
+ position: fixed;
1944
+ top: 50%;
1945
+ left: 50%;
1946
+ margin: 0;
1947
+ z-index: var(--z-index);
1948
+ transform: translate(var(--translate-x), var(--translate-y));
1956
1949
 
1957
1950
  &[position*="bottom"] {
1958
- dialog {
1959
- bottom: var(--offset);
1960
- top: auto;
1961
- --translate-y: 0;
1962
- }
1951
+ bottom: var(--offset);
1952
+ top: auto;
1953
+ --translate-y: 0;
1963
1954
  }
1964
1955
  &[position*="top"] {
1965
- dialog {
1966
- top: var(--offset);
1967
- bottom: auto;
1968
- --translate-y: 0;
1969
- }
1956
+ top: var(--offset);
1957
+ bottom: auto;
1958
+ --translate-y: 0;
1970
1959
  }
1971
1960
  &[position*="right"] {
1972
- dialog {
1973
- right: var(--offset);
1974
- left: auto;
1975
- --translate-x: 0;
1976
- }
1961
+ right: var(--offset);
1962
+ left: auto;
1963
+ --translate-x: 0;
1977
1964
  }
1978
1965
  &[position*="left"] {
1979
- dialog {
1980
- left: var(--offset);
1981
- right: auto;
1982
- --translate-: 0;
1983
- }
1966
+ left: var(--offset);
1967
+ right: auto;
1968
+ --translate-x: 0;
1984
1969
  }
1985
1970
  }
1986
1971
 
package/example.html CHANGED
@@ -435,8 +435,9 @@
435
435
  </fig-tooltip>
436
436
  </fig-field>
437
437
 
438
- <fig-dialog open="true"
439
- position="bottom right">
438
+ <dialog open="true"
439
+ position="bottom right"
440
+ is="fig-dialog">
440
441
  <fig-header>
441
442
  <h3>Dialog</h3>
442
443
  <fig-button variant="ghost"
@@ -458,13 +459,25 @@
458
459
  </fig-header>
459
460
  <fig-content>
460
461
  <p>Some content here</p>
462
+ <fig-field direction="horizontal">
463
+ <label for="colorLevels">Color Levels</label>
464
+ <fig-slider id="colorLevels"
465
+ min="2"
466
+ max="16"
467
+ value="4"
468
+ variant="minimal"
469
+ step="1"
470
+ text="true"
471
+ style="flex: 1; max-width: 200px;">
472
+ </fig-slider>
473
+ </fig-field>
461
474
  </fig-content>
462
475
  <footer>
463
476
  <fig-button variant="secondary"
464
477
  close-dialog>Cancel</fig-button>
465
478
  <fig-button>Save</fig-button>
466
479
  </footer>
467
- </fig-dialog>
480
+ </dialog>
468
481
  <fig-header>
469
482
  <h2>Dropdown</h2>
470
483
  </fig-header>
package/fig.js CHANGED
@@ -432,20 +432,10 @@ customElements.define("fig-popover", FigPopover);
432
432
  * @attr {boolean} open - Whether the dialog is visible
433
433
  * @attr {boolean} modal - Whether the dialog should be modal
434
434
  */
435
- class FigDialog extends HTMLElement {
436
- constructor() {
437
- super();
438
- this.attachShadow({ mode: "open" });
439
- this.dialog = document.createElement("dialog");
440
- this.contentSlot = document.createElement("slot");
441
- }
442
-
435
+ class FigDialog extends HTMLDialogElement {
443
436
  connectedCallback() {
444
437
  this.modal =
445
438
  this.hasAttribute("modal") && this.getAttribute("modal") !== "false";
446
- this.appendChild(this.dialog);
447
- this.shadowRoot.appendChild(this.contentSlot);
448
- this.contentSlot.addEventListener("slotchange", this.slotChange.bind(this));
449
439
 
450
440
  requestAnimationFrame(() => {
451
441
  this.#addCloseListeners();
@@ -453,61 +443,13 @@ class FigDialog extends HTMLElement {
453
443
  }
454
444
 
455
445
  #addCloseListeners() {
456
- this.dialog
457
- .querySelectorAll("fig-button[close-dialog]")
458
- .forEach((button) => {
459
- button.removeEventListener("click", this.close);
460
- button.addEventListener("click", this.close.bind(this));
461
- });
462
- }
463
-
464
- disconnectedCallback() {
465
- this.contentSlot.removeEventListener("slotchange", this.slotChange);
466
- }
467
-
468
- slotChange() {
469
- while (this.dialog.firstChild) {
470
- this.dialog.firstChild.remove();
471
- }
472
- this.contentSlot.assignedNodes().forEach((node) => {
473
- if (node !== this.dialog) {
474
- this.dialog.appendChild(node.cloneNode(true));
475
- }
446
+ this.querySelectorAll("fig-button[close-dialog]").forEach((button) => {
447
+ button.removeEventListener("click", this.close);
448
+ button.addEventListener("click", this.close.bind(this));
476
449
  });
477
- this.#addCloseListeners();
478
- }
479
-
480
- static get observedAttributes() {
481
- return ["open", "modal"];
482
- }
483
-
484
- attributeChangedCallback(name, oldValue, newValue) {
485
- switch (name) {
486
- case "open":
487
- this.open = newValue === "true" && newValue !== "false";
488
- if (this?.show) {
489
- this[this.open ? "show" : "close"]();
490
- }
491
- break;
492
- case "modal":
493
- this.modal = newValue === "true" && newValue !== "false";
494
- break;
495
- }
496
- }
497
-
498
- /* Public methods */
499
- show() {
500
- if (this.modal) {
501
- this.dialog.showModal();
502
- } else {
503
- this.dialog.show();
504
- }
505
- }
506
- close() {
507
- this.dialog.close();
508
450
  }
509
451
  }
510
- customElements.define("fig-dialog", FigDialog);
452
+ customElements.define("fig-dialog", FigDialog, { extends: "dialog" });
511
453
 
512
454
  class FigPopover2 extends HTMLElement {
513
455
  #popover;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {