@rogieking/figui3 1.2.5 → 1.2.7

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/example.html CHANGED
@@ -526,7 +526,7 @@
526
526
  value="25"
527
527
  default="50"
528
528
  step="25">
529
- <datalist id="markers">
529
+ <datalist>
530
530
  <option value="0"></option>
531
531
  <option value="25"></option>
532
532
  <option value="50"></option>
@@ -535,6 +535,17 @@
535
535
  </datalist>
536
536
  </fig-slider>
537
537
  </fig-field>
538
+ <fig-field direction="horizontal">
539
+ <label>Stepper slider (auto)</label>
540
+ <fig-slider type="stepper"
541
+ value="0"
542
+ default="5"
543
+ min="0"
544
+ max="10"
545
+ step="1"
546
+ text="true">
547
+ </fig-slider>
548
+ </fig-field>
538
549
 
539
550
  <fig-field>
540
551
  <label>Delta slider</label>
package/fig.css CHANGED
@@ -1704,7 +1704,7 @@ fig-slider {
1704
1704
  datalist {
1705
1705
  position: absolute;
1706
1706
  inset: 0;
1707
- top: calc((var(--slider-field-height) - var(--slider-height)) / 2);
1707
+ top: 0;
1708
1708
  display: flex;
1709
1709
  transition: var(--slider-transition);
1710
1710
  background: transparent;
package/fig.js CHANGED
@@ -1,7 +1,7 @@
1
- function uniqueId() {
1
+ function figUniqueId() {
2
2
  return Date.now().toString(36) + Math.random().toString(36).substring(2);
3
3
  }
4
- function supportsPopover() {
4
+ function figSupportsPopover() {
5
5
  return HTMLElement.prototype.hasOwnProperty("popover");
6
6
  }
7
7
 
@@ -502,7 +502,7 @@ class FigPopover2 extends HTMLElement {
502
502
  this.#trigger = this;
503
503
  this.#delay = Number(this.getAttribute("delay")) || 0;
504
504
  this.#action = this.getAttribute("trigger-action") || "click";
505
- this.#id = `tooltip-${uniqueId()}`;
505
+ this.#id = `tooltip-${figUniqueId()}`;
506
506
  if (this.#popover) {
507
507
  this.#popover.setAttribute("id", this.#id);
508
508
  this.#popover.setAttribute("role", "tooltip");
@@ -726,6 +726,7 @@ class FigSlider extends HTMLElement {
726
726
  //child nodes hack
727
727
  requestAnimationFrame(() => {
728
728
  this.input = this.querySelector("[type=range]");
729
+ this.inputContainer = this.querySelector(".fig-slider-input-container");
729
730
  this.input.removeEventListener("input", this.handleInput);
730
731
  this.input.addEventListener("input", this.handleInput.bind(this));
731
732
 
@@ -739,11 +740,23 @@ class FigSlider extends HTMLElement {
739
740
  this.datalist = this.querySelector("datalist");
740
741
  this.figInputText = this.querySelector("fig-input-text");
741
742
  if (this.datalist) {
743
+ this.inputContainer.append(this.datalist);
742
744
  this.datalist.setAttribute(
743
745
  "id",
744
- this.datalist.getAttribute("id") || uniqueId()
746
+ this.datalist.getAttribute("id") || figUniqueId()
745
747
  );
746
748
  this.input.setAttribute("list", this.datalist.getAttribute("id"));
749
+ } else if (this.type === "stepper") {
750
+ this.datalist = document.createElement("datalist");
751
+ this.datalist.setAttribute("id", figUniqueId());
752
+ let steps = (this.max - this.min) / this.step + 1;
753
+ for (let i = 0; i < steps; i++) {
754
+ let option = document.createElement("option");
755
+ option.setAttribute("value", this.min + i * this.step);
756
+ this.datalist.append(option);
757
+ }
758
+ this.inputContainer.append(this.datalist);
759
+ this.input.setAttribute("list", this.datalist.getAttribute("id"));
747
760
  }
748
761
  if (this.figInputText) {
749
762
  this.figInputText.removeEventListener("input", this.handleTextInput);
@@ -1129,7 +1142,7 @@ class FigField extends HTMLElement {
1129
1142
  );
1130
1143
  if (this.input && this.label) {
1131
1144
  this.label.addEventListener("click", this.focus.bind(this));
1132
- let inputId = this.input.getAttribute("id") || uniqueId();
1145
+ let inputId = this.input.getAttribute("id") || figUniqueId();
1133
1146
  this.input.setAttribute("id", inputId);
1134
1147
  this.label.setAttribute("for", inputId);
1135
1148
  }
@@ -1396,7 +1409,7 @@ class FigCheckbox extends HTMLElement {
1396
1409
  this.input = document.createElement("input");
1397
1410
  this.name = this.getAttribute("name") || "checkbox";
1398
1411
  this.value = this.getAttribute("value") || "";
1399
- this.input.setAttribute("id", uniqueId());
1412
+ this.input.setAttribute("id", figUniqueId());
1400
1413
  this.input.setAttribute("name", this.name);
1401
1414
  this.input.setAttribute("type", "checkbox");
1402
1415
  this.labelElement = document.createElement("label");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {