@wavelengthusaf/web-components 1.6.1 → 1.6.2

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.
@@ -2317,7 +2317,7 @@ var WavelengthBanner = class extends HTMLElement {
2317
2317
  this.updateAttributes();
2318
2318
  }
2319
2319
  updateAttributes() {
2320
- const classificationRaw = _optionalChain([this, 'access', _ => _.getAttribute, 'call', _2 => _2("classification"), 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]) || "";
2320
+ const classificationRaw = _optionalChain([this, 'access', _2 => _2.getAttribute, 'call', _3 => _3("classification"), 'optionalAccess', _4 => _4.toLowerCase, 'call', _5 => _5()]) || "";
2321
2321
  const controlRaw = this.getAttribute("control") || "";
2322
2322
  const controlList = controlRaw.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
2323
2323
  let bannerText = this.getAttribute("banner-text");
@@ -2569,9 +2569,9 @@ function unwrap(t) {
2569
2569
  }
2570
2570
  function isZodType(core, type) {
2571
2571
  const anyCore = core;
2572
- const typeName = _optionalChain([anyCore, 'optionalAccess', _5 => _5._def, 'optionalAccess', _6 => _6.typeName]);
2572
+ const typeName = _optionalChain([anyCore, 'optionalAccess', _6 => _6._def, 'optionalAccess', _7 => _7.typeName]);
2573
2573
  if (typeof typeName === "string" && typeName === type) return true;
2574
- const ctorName = _optionalChain([anyCore, 'optionalAccess', _7 => _7.constructor, 'optionalAccess', _8 => _8.name]);
2574
+ const ctorName = _optionalChain([anyCore, 'optionalAccess', _8 => _8.constructor, 'optionalAccess', _9 => _9.name]);
2575
2575
  return ctorName === type;
2576
2576
  }
2577
2577
  function zodToFields(schema) {
@@ -2591,14 +2591,14 @@ function zodToFields(schema) {
2591
2591
  type,
2592
2592
  required: typeof anyZt.isOptional === "function" ? !anyZt.isOptional() : true
2593
2593
  };
2594
- const placeholder = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce((typeof anyZt.meta === "function" ? _optionalChain([anyZt, 'access', _9 => _9.meta, 'call', _10 => _10(), 'optionalAccess', _11 => _11.placeholder]) : void 0), () => ( _optionalChain([anyZt, 'optionalAccess', _12 => _12.description]))), () => ( _optionalChain([anyZt, 'optionalAccess', _13 => _13._def, 'optionalAccess', _14 => _14.description]))), () => ( (typeof core.meta === "function" ? _optionalChain([core, 'access', _15 => _15.meta, 'call', _16 => _16(), 'optionalAccess', _17 => _17.placeholder]) : void 0))), () => ( _optionalChain([core, 'optionalAccess', _18 => _18.description]))), () => ( _optionalChain([core, 'optionalAccess', _19 => _19._def, 'optionalAccess', _20 => _20.description]))), () => ( field.label));
2594
+ const placeholder = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce((typeof anyZt.meta === "function" ? _optionalChain([anyZt, 'access', _10 => _10.meta, 'call', _11 => _11(), 'optionalAccess', _12 => _12.placeholder]) : void 0), () => ( _optionalChain([anyZt, 'optionalAccess', _13 => _13.description]))), () => ( _optionalChain([anyZt, 'optionalAccess', _14 => _14._def, 'optionalAccess', _15 => _15.description]))), () => ( (typeof core.meta === "function" ? _optionalChain([core, 'access', _16 => _16.meta, 'call', _17 => _17(), 'optionalAccess', _18 => _18.placeholder]) : void 0))), () => ( _optionalChain([core, 'optionalAccess', _19 => _19.description]))), () => ( _optionalChain([core, 'optionalAccess', _20 => _20._def, 'optionalAccess', _21 => _21.description]))), () => ( field.label));
2595
2595
  field.placeholder = placeholder;
2596
2596
  if (type === "text") {
2597
- const checks = _nullishCoalesce(_optionalChain([core, 'optionalAccess', _21 => _21._def, 'optionalAccess', _22 => _22.checks]), () => ( []));
2597
+ const checks = _nullishCoalesce(_optionalChain([core, 'optionalAccess', _22 => _22._def, 'optionalAccess', _23 => _23.checks]), () => ( []));
2598
2598
  for (const chk of checks) {
2599
- const kind = chk.kind || _optionalChain([chk, 'access', _23 => _23._zod, 'optionalAccess', _24 => _24.def, 'optionalAccess', _25 => _25.check]);
2600
- const min = _nullishCoalesce(chk.value, () => ( _optionalChain([chk, 'access', _26 => _26._zod, 'optionalAccess', _27 => _27.def, 'optionalAccess', _28 => _28.minimum])));
2601
- const max = _nullishCoalesce(chk.value, () => ( _optionalChain([chk, 'access', _29 => _29._zod, 'optionalAccess', _30 => _30.def, 'optionalAccess', _31 => _31.maximum])));
2599
+ const kind = chk.kind || _optionalChain([chk, 'access', _24 => _24._zod, 'optionalAccess', _25 => _25.def, 'optionalAccess', _26 => _26.check]);
2600
+ const min = _nullishCoalesce(chk.value, () => ( _optionalChain([chk, 'access', _27 => _27._zod, 'optionalAccess', _28 => _28.def, 'optionalAccess', _29 => _29.minimum])));
2601
+ const max = _nullishCoalesce(chk.value, () => ( _optionalChain([chk, 'access', _30 => _30._zod, 'optionalAccess', _31 => _31.def, 'optionalAccess', _32 => _32.maximum])));
2602
2602
  if ((kind === "min" || kind === "min_length") && typeof min === "number") {
2603
2603
  field.minLength = min;
2604
2604
  }
@@ -2670,7 +2670,7 @@ var WavelengthForm = class extends HTMLElement {
2670
2670
  // --- Event handlers ---
2671
2671
  this.onInputChange = (name, rawValue) => {
2672
2672
  this._value = { ...this._value, [name]: rawValue };
2673
- const res = _optionalChain([this, 'access', _32 => _32._validator, 'optionalAccess', _33 => _33.validate, 'call', _34 => _34(this._value)]);
2673
+ const res = _optionalChain([this, 'access', _33 => _33._validator, 'optionalAccess', _34 => _34.validate, 'call', _35 => _35(this._value)]);
2674
2674
  const issues = res && !res.isValid ? _nullishCoalesce(res.issues, () => ( [])) : [];
2675
2675
  this.dispatchEvent(
2676
2676
  new CustomEvent("form-change", {
@@ -2899,7 +2899,7 @@ var WavelengthForm = class extends HTMLElement {
2899
2899
  if (res.isValid) {
2900
2900
  this.setFieldError(name, void 0);
2901
2901
  } else {
2902
- const issues = _nullishCoalesce(_optionalChain([res, 'access', _35 => _35.issues, 'optionalAccess', _36 => _36.filter, 'call', _37 => _37((i) => _optionalChain([i, 'access', _38 => _38.path, 'optionalAccess', _39 => _39[0]]) === name)]), () => ( []));
2902
+ const issues = _nullishCoalesce(_optionalChain([res, 'access', _36 => _36.issues, 'optionalAccess', _37 => _37.filter, 'call', _38 => _38((i) => _optionalChain([i, 'access', _39 => _39.path, 'optionalAccess', _40 => _40[0]]) === name)]), () => ( []));
2903
2903
  const messages = issues.map((i) => i.message).join("\n");
2904
2904
  this.setFieldError(name, issues.length > 0 ? messages : "Invalid value");
2905
2905
  }
@@ -2915,7 +2915,7 @@ var WavelengthForm = class extends HTMLElement {
2915
2915
  return { isValid: true, value: res.value, issues: [] };
2916
2916
  }
2917
2917
  for (const f of this._fields) {
2918
- const issues = _nullishCoalesce(_optionalChain([res, 'access', _40 => _40.issues, 'optionalAccess', _41 => _41.filter, 'call', _42 => _42((i) => _optionalChain([i, 'access', _43 => _43.path, 'optionalAccess', _44 => _44[0]]) === f.name)]), () => ( []));
2918
+ const issues = _nullishCoalesce(_optionalChain([res, 'access', _41 => _41.issues, 'optionalAccess', _42 => _42.filter, 'call', _43 => _43((i) => _optionalChain([i, 'access', _44 => _44.path, 'optionalAccess', _45 => _45[0]]) === f.name)]), () => ( []));
2919
2919
  if (issues.length > 0) {
2920
2920
  const messages = issues.map((i) => i.message).join("\n");
2921
2921
  this.setFieldError(f.name, messages);
@@ -3045,7 +3045,7 @@ var WavelengthForm = class extends HTMLElement {
3045
3045
  rightSlot.className = "right";
3046
3046
  const buildButton = (cfg, defaultEvent) => {
3047
3047
  const btn = document.createElement("wavelength-button");
3048
- const requestedType = _nullishCoalesce(_optionalChain([cfg, 'access', _45 => _45.buttonProps, 'optionalAccess', _46 => _46.type]), () => ( ""));
3048
+ const requestedType = _nullishCoalesce(_optionalChain([cfg, 'access', _46 => _46.buttonProps, 'optionalAccess', _47 => _47.type]), () => ( ""));
3049
3049
  const type = requestedType === "submit" ? "submit" : "button";
3050
3050
  if (cfg.buttonProps) {
3051
3051
  for (const [key, value] of Object.entries(cfg.buttonProps)) {
@@ -3313,7 +3313,7 @@ var BaseWavelengthInput = class extends HTMLElement {
3313
3313
  this._applyAttributes();
3314
3314
  this._setupDebouncedValidation();
3315
3315
  const maxLengthAttr = this.getAttribute("max-length");
3316
- const value = _optionalChain([this, 'access', _47 => _47.inputEl, 'optionalAccess', _48 => _48.value, 'optionalAccess', _49 => _49.trim, 'optionalCall', _50 => _50()]) || "";
3316
+ const value = _optionalChain([this, 'access', _48 => _48.inputEl, 'optionalAccess', _49 => _49.value, 'optionalAccess', _50 => _50.trim, 'optionalCall', _51 => _51()]) || "";
3317
3317
  this.inputEl.addEventListener("input", this._onInput);
3318
3318
  this.inputEl.addEventListener("blur", this._onBlur);
3319
3319
  this.inputEl.addEventListener("focus", this._onFocus);
@@ -3794,8 +3794,8 @@ var WavelengthTitleBar = class extends HTMLElement {
3794
3794
  }
3795
3795
  attributeChangedCallback(name, oldValue, newValue) {
3796
3796
  if (oldValue === newValue) return;
3797
- const titleElement = _optionalChain([this, 'access', _51 => _51.shadowRoot, 'optionalAccess', _52 => _52.querySelector, 'call', _53 => _53(".title")]);
3798
- const subtitleElement = _optionalChain([this, 'access', _54 => _54.shadowRoot, 'optionalAccess', _55 => _55.querySelector, 'call', _56 => _56(".subtitle")]);
3797
+ const titleElement = _optionalChain([this, 'access', _52 => _52.shadowRoot, 'optionalAccess', _53 => _53.querySelector, 'call', _54 => _54(".title")]);
3798
+ const subtitleElement = _optionalChain([this, 'access', _55 => _55.shadowRoot, 'optionalAccess', _56 => _56.querySelector, 'call', _57 => _57(".subtitle")]);
3799
3799
  switch (name) {
3800
3800
  case "title-text":
3801
3801
  if (titleElement) titleElement.textContent = newValue;
@@ -4541,7 +4541,7 @@ var BaseWavelengthMultiSelectAutocomplete = class extends HTMLElement {
4541
4541
  </svg>
4542
4542
  </span>
4543
4543
  `;
4544
- _optionalChain([chip, 'access', _57 => _57.querySelector, 'call', _58 => _58(".multi-select-remove-button"), 'optionalAccess', _59 => _59.addEventListener, 'call', _60 => _60("click", (e) => {
4544
+ _optionalChain([chip, 'access', _58 => _58.querySelector, 'call', _59 => _59(".multi-select-remove-button"), 'optionalAccess', _60 => _60.addEventListener, 'call', _61 => _61("click", (e) => {
4545
4545
  e.stopPropagation();
4546
4546
  this.handleRemoveChip(opt);
4547
4547
  })]);
@@ -4739,7 +4739,7 @@ var WavelengthNavBar = class extends HTMLElement {
4739
4739
  super();
4740
4740
  const shadow = this.attachShadow({ mode: "open" });
4741
4741
  shadow.appendChild(template4.content.cloneNode(true));
4742
- _optionalChain([shadow, 'access', _61 => _61.querySelector, 'call', _62 => _62("#logo"), 'optionalAccess', _63 => _63.addEventListener, 'call', _64 => _64("click", () => {
4742
+ _optionalChain([shadow, 'access', _62 => _62.querySelector, 'call', _63 => _63("#logo"), 'optionalAccess', _64 => _64.addEventListener, 'call', _65 => _65("click", () => {
4743
4743
  this.dispatchEvent(new CustomEvent("home-click"));
4744
4744
  })]);
4745
4745
  }
@@ -4759,7 +4759,7 @@ var WavelengthNavBar = class extends HTMLElement {
4759
4759
  this.style.setProperty("--border", this.getAttribute("border") || "1px solid #ddd");
4760
4760
  }
4761
4761
  renderTabs() {
4762
- const container = _optionalChain([this, 'access', _65 => _65.shadowRoot, 'optionalAccess', _66 => _66.querySelector, 'call', _67 => _67(".middle-tab-group")]);
4762
+ const container = _optionalChain([this, 'access', _66 => _66.shadowRoot, 'optionalAccess', _67 => _67.querySelector, 'call', _68 => _68(".middle-tab-group")]);
4763
4763
  if (!container) return;
4764
4764
  container.innerHTML = "";
4765
4765
  const itemsAttr = this.getAttribute("items");
@@ -5662,26 +5662,26 @@ var WavelengthFileDropZone = class extends HTMLElement {
5662
5662
  if (!this.dropZone || !this.fileInput) return;
5663
5663
  this.dropZone.addEventListener("dragover", (e) => {
5664
5664
  e.preventDefault();
5665
- _optionalChain([this, 'access', _68 => _68.dropZone, 'optionalAccess', _69 => _69.classList, 'access', _70 => _70.add, 'call', _71 => _71("dragover")]);
5665
+ _optionalChain([this, 'access', _69 => _69.dropZone, 'optionalAccess', _70 => _70.classList, 'access', _71 => _71.add, 'call', _72 => _72("dragover")]);
5666
5666
  });
5667
5667
  this.dropZone.addEventListener("dragleave", (e) => {
5668
5668
  e.preventDefault();
5669
- _optionalChain([this, 'access', _72 => _72.dropZone, 'optionalAccess', _73 => _73.classList, 'access', _74 => _74.remove, 'call', _75 => _75("dragover")]);
5669
+ _optionalChain([this, 'access', _73 => _73.dropZone, 'optionalAccess', _74 => _74.classList, 'access', _75 => _75.remove, 'call', _76 => _76("dragover")]);
5670
5670
  });
5671
5671
  this.dropZone.addEventListener("drop", (e) => {
5672
5672
  e.preventDefault();
5673
- _optionalChain([this, 'access', _76 => _76.dropZone, 'optionalAccess', _77 => _77.classList, 'access', _78 => _78.remove, 'call', _79 => _79("dragover")]);
5674
- const files = _optionalChain([e, 'access', _80 => _80.dataTransfer, 'optionalAccess', _81 => _81.files]);
5675
- if (_optionalChain([files, 'optionalAccess', _82 => _82.length])) {
5673
+ _optionalChain([this, 'access', _77 => _77.dropZone, 'optionalAccess', _78 => _78.classList, 'access', _79 => _79.remove, 'call', _80 => _80("dragover")]);
5674
+ const files = _optionalChain([e, 'access', _81 => _81.dataTransfer, 'optionalAccess', _82 => _82.files]);
5675
+ if (_optionalChain([files, 'optionalAccess', _83 => _83.length])) {
5676
5676
  this.validateAndProcessFiles(files);
5677
5677
  }
5678
5678
  });
5679
5679
  this.dropZone.addEventListener("click", () => {
5680
- _optionalChain([this, 'access', _83 => _83.fileInput, 'optionalAccess', _84 => _84.click, 'call', _85 => _85()]);
5680
+ _optionalChain([this, 'access', _84 => _84.fileInput, 'optionalAccess', _85 => _85.click, 'call', _86 => _86()]);
5681
5681
  });
5682
5682
  this.fileInput.addEventListener("change", (event) => {
5683
5683
  const input = event.target;
5684
- if (_optionalChain([input, 'access', _86 => _86.files, 'optionalAccess', _87 => _87.length])) {
5684
+ if (_optionalChain([input, 'access', _87 => _87.files, 'optionalAccess', _88 => _88.length])) {
5685
5685
  this.validateAndProcessFiles(input.files);
5686
5686
  }
5687
5687
  });
@@ -5689,7 +5689,7 @@ var WavelengthFileDropZone = class extends HTMLElement {
5689
5689
  validateAndProcessFiles(files) {
5690
5690
  const fileList = Array.from(files);
5691
5691
  let errorMessage = "";
5692
- const acceptedTypes = _optionalChain([this, 'access', _88 => _88.getAttribute, 'call', _89 => _89("accepted-types"), 'optionalAccess', _90 => _90.split, 'call', _91 => _91(",")]) || [];
5692
+ const acceptedTypes = _optionalChain([this, 'access', _89 => _89.getAttribute, 'call', _90 => _90("accepted-types"), 'optionalAccess', _91 => _91.split, 'call', _92 => _92(",")]) || [];
5693
5693
  if (acceptedTypes.length) {
5694
5694
  const invalidFiles = fileList.filter((file) => !acceptedTypes.some((type) => file.name.toLowerCase().endsWith(type.toLowerCase().replace("*", ""))));
5695
5695
  if (invalidFiles.length) {
@@ -5732,6 +5732,247 @@ var WavelengthFileDropZone = class extends HTMLElement {
5732
5732
  };
5733
5733
  customElements.define("wavelength-file-drop-zone", WavelengthFileDropZone);
5734
5734
 
5735
+ // src/web-components/wavelength-dropdown.ts
5736
+ var template6 = document.createElement("template");
5737
+ template6.innerHTML = `
5738
+ <style>
5739
+ :host {
5740
+ display: inline-block;
5741
+ position: relative;
5742
+ font-family: inherit;
5743
+ font-size: inherit;
5744
+ }
5745
+
5746
+ .dropdown-box{
5747
+ width: 100%;
5748
+ height: 100%;
5749
+ }
5750
+
5751
+ .dropdown-field {
5752
+ user-select: none;
5753
+ height: inherit;
5754
+ display: flex;
5755
+ align-items: center;
5756
+ justify-content: space-between;
5757
+ cursor: pointer;
5758
+ border: 1px solid black;
5759
+ gap: 4px;
5760
+ padding: 0 8px;
5761
+ }
5762
+
5763
+ .selected {
5764
+ display: flex;
5765
+ height: inherit;
5766
+ width: inherit;
5767
+ overflow: hidden;
5768
+ white-space: nowrap;
5769
+ align-items: center;
5770
+ }
5771
+
5772
+ .arrow {
5773
+ width: 10px;
5774
+ height: 1px;
5775
+ background: black;
5776
+ margin: 8px;
5777
+ clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
5778
+ transform: rotate(180deg);
5779
+ }
5780
+
5781
+ .arrow.active {
5782
+ transform: rotate(0deg);
5783
+ }
5784
+
5785
+ .options-list {
5786
+ position: relative;
5787
+ left: 0;
5788
+ right: 0;
5789
+ margin: 0;
5790
+ padding: 0;
5791
+ list-style: none;
5792
+ overflow-y: auto;
5793
+ display: none;
5794
+ z-index: 10;
5795
+ box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
5796
+ }
5797
+
5798
+ .options-list.show {
5799
+ display: inline-block;
5800
+ }
5801
+ </style>
5802
+
5803
+ <div class="dropdown-box" tabindex="0">
5804
+ <div class="dropdown-field">
5805
+ <span class="selected"></span>
5806
+ <i class="arrow"></i>
5807
+ </div>
5808
+ <ul class="options-list"></ul>
5809
+ </div>
5810
+ `;
5811
+ var WavelengthDropdown = class extends HTMLElement {
5812
+ constructor() {
5813
+ super();
5814
+ this._options = [];
5815
+ const shadow = this.attachShadow({ mode: "open" });
5816
+ shadow.appendChild(template6.content.cloneNode(true));
5817
+ this.dropdownField = shadow.querySelector(".dropdown-field");
5818
+ this.dropdownBox = shadow.querySelector(".dropdown-box");
5819
+ this.selectedSpan = shadow.querySelector(".selected");
5820
+ this.arrow = shadow.querySelector(".arrow");
5821
+ this.optionsList = shadow.querySelector(".options-list");
5822
+ this._selectedValue = this.getAttribute("default-value");
5823
+ }
5824
+ static get observedAttributes() {
5825
+ return ["options", "default-value", "color", "font-size", "font-family", "border-radius", "width", "height", "arrow-size", "popup-radius", "popup-align", "popup-selected-color"];
5826
+ }
5827
+ connectedCallback() {
5828
+ this.parseOptionsAttribute();
5829
+ this.applyStyles();
5830
+ this.dropdownField.addEventListener("click", () => {
5831
+ this.optionsList.classList.toggle("show");
5832
+ this.arrow.classList.toggle("active");
5833
+ });
5834
+ document.addEventListener("click", (e) => {
5835
+ if (!this.contains(e.target)) {
5836
+ this.optionsList.classList.remove("show");
5837
+ this.arrow.classList.remove("active");
5838
+ }
5839
+ });
5840
+ }
5841
+ attributeChangedCallback() {
5842
+ this.parseOptionsAttribute();
5843
+ this.setDefaultValue();
5844
+ this.applyStyles();
5845
+ }
5846
+ parseOptionsAttribute() {
5847
+ const attr = this.getAttribute("options");
5848
+ if (!attr) return;
5849
+ this._options = JSON.parse(attr);
5850
+ this.renderOptions();
5851
+ }
5852
+ setDefaultValue() {
5853
+ const defaultValue = this.getAttribute("default-value");
5854
+ if (defaultValue) {
5855
+ const match = this._options.find((o) => o.value === defaultValue);
5856
+ this.setSelected(match || this._options[0]);
5857
+ } else {
5858
+ this.setSelected(this._options[0]);
5859
+ }
5860
+ }
5861
+ renderOptions() {
5862
+ this.optionsList.innerHTML = "";
5863
+ this._options.forEach((opt) => {
5864
+ const li = document.createElement("li");
5865
+ li.textContent = opt.value;
5866
+ li.style.padding = "8px";
5867
+ li.style.whiteSpace = "nowrap";
5868
+ li.style.overflow = "visible";
5869
+ li.style.textOverflow = "clip";
5870
+ li.style.fontSize = this.getAttribute("font-size") || this.style.fontSize || "inherit";
5871
+ li.style.fontFamily = this.getAttribute("font-family") || this.style.fontFamily || "inherit";
5872
+ li.style.color = "#000";
5873
+ const originalBg = li.style.backgroundColor;
5874
+ li.addEventListener("mouseenter", () => {
5875
+ li.style.backgroundColor = "#eee";
5876
+ });
5877
+ li.addEventListener("mouseleave", () => {
5878
+ if (this._selectedValue === opt.value) {
5879
+ li.style.backgroundColor = this.getAttribute("popup-selected-color") || "";
5880
+ } else {
5881
+ li.style.backgroundColor = originalBg;
5882
+ }
5883
+ });
5884
+ li.addEventListener("click", () => {
5885
+ this.setSelected(opt);
5886
+ this.optionsList.classList.remove("show");
5887
+ this.arrow.classList.remove("active");
5888
+ const event = new CustomEvent("change", {
5889
+ detail: { value: opt.value },
5890
+ bubbles: true,
5891
+ composed: true
5892
+ });
5893
+ this.dispatchEvent(event);
5894
+ });
5895
+ this.optionsList.appendChild(li);
5896
+ });
5897
+ }
5898
+ setSelected(opt) {
5899
+ if (!opt) return;
5900
+ if (opt.label) {
5901
+ this.selectedSpan.textContent = opt.label;
5902
+ } else {
5903
+ this.selectedSpan.textContent = opt.value;
5904
+ }
5905
+ this.dropdownField.style.backgroundColor = opt.color || "";
5906
+ const children = Array.from(this.optionsList.childNodes.entries(), ([_, child]) => child);
5907
+ children.map((child) => {
5908
+ if (child.textContent === opt.value) {
5909
+ child.style.backgroundColor = this.getAttribute("popup-selected-color") || "";
5910
+ } else {
5911
+ child.style.backgroundColor = this.optionsList.style.backgroundColor;
5912
+ }
5913
+ });
5914
+ }
5915
+ applyStyles() {
5916
+ const style = this.style;
5917
+ Object.assign(this.dropdownBox.style, {
5918
+ width: this.getAttribute("width") || style.width,
5919
+ height: this.getAttribute("height") || style.height
5920
+ });
5921
+ Object.assign(this.dropdownField.style, {
5922
+ borderRadius: this.getAttribute("border-radius") || style.borderRadius,
5923
+ fontSize: this.getAttribute("font-size") || style.fontSize,
5924
+ fontFamily: this.getAttribute("font-family") || style.fontFamily,
5925
+ color: this.getAttribute("color") || "#000"
5926
+ });
5927
+ this.dropdownBox.style.minWidth = this.getAttribute("width") || "auto";
5928
+ const arrow = this.dropdownField.querySelector(".arrow");
5929
+ arrow.style.padding = this.getAttribute("arrow-size") || "2px";
5930
+ this.optionsList.style.minWidth = "auto";
5931
+ const popupAlign = this.getAttribute("popup-align") || "left";
5932
+ switch (popupAlign) {
5933
+ case "center":
5934
+ this.optionsList.style.left = "50%";
5935
+ this.optionsList.style.transform = "translateX(-50%)";
5936
+ this.optionsList.style.right = "auto";
5937
+ break;
5938
+ case "right":
5939
+ this.optionsList.style.left = "auto";
5940
+ this.optionsList.style.right = "0";
5941
+ this.optionsList.style.transform = "none";
5942
+ break;
5943
+ case "left":
5944
+ default:
5945
+ this.optionsList.style.left = "0";
5946
+ this.optionsList.style.right = "auto";
5947
+ this.optionsList.style.transform = "none";
5948
+ break;
5949
+ }
5950
+ this.optionsList.style.backgroundColor = "white";
5951
+ this.optionsList.style.borderRadius = this.getAttribute("popup-radius") || this.getAttribute("border-radius") || "4px";
5952
+ }
5953
+ get value() {
5954
+ return this._selectedValue;
5955
+ }
5956
+ set value(val) {
5957
+ const opt = this._options.find((o) => o.value === val);
5958
+ if (opt) {
5959
+ this._selectedValue = opt.value;
5960
+ this.setSelected(opt);
5961
+ }
5962
+ }
5963
+ get color() {
5964
+ return this.selectedSpan.style.backgroundColor || "";
5965
+ }
5966
+ set color(col) {
5967
+ const opt = this._options.find((o) => o.color === col);
5968
+ if (opt) this.setSelected(opt);
5969
+ }
5970
+ };
5971
+ if (!customElements.get("wavelength-dropdown")) {
5972
+ customElements.define("wavelength-dropdown", WavelengthDropdown);
5973
+ }
5974
+
5975
+
5735
5976
 
5736
5977
 
5737
5978
 
@@ -5748,7 +5989,7 @@ customElements.define("wavelength-file-drop-zone", WavelengthFileDropZone);
5748
5989
 
5749
5990
 
5750
5991
 
5751
- exports.BaseWavelengthInput = BaseWavelengthInput; exports.BaseWavelengthMultiSelectAutocomplete = BaseWavelengthMultiSelectAutocomplete; exports.ChildDataTable = ChildDataTable; exports.SampleComponent = SampleComponent; exports.WavelengthBanner = WavelengthBanner; exports.WavelengthButton = WavelengthButton; exports.WavelengthCheckbox = WavelengthCheckbox; exports.WavelengthDatePicker = WavelengthDatePicker; exports.WavelengthFileDropZone = WavelengthFileDropZone; exports.WavelengthForm = WavelengthForm; exports.WavelengthInput = WavelengthInput; exports.WavelengthMultiSelectAutocomplete = WavelengthMultiSelectAutocomplete; exports.WavelengthNavBar = WavelengthNavBar; exports.WavelengthNotificationPanel = WavelengthNotificationPanel; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthTitleBar = WavelengthTitleBar;
5992
+ exports.BaseWavelengthInput = BaseWavelengthInput; exports.BaseWavelengthMultiSelectAutocomplete = BaseWavelengthMultiSelectAutocomplete; exports.ChildDataTable = ChildDataTable; exports.SampleComponent = SampleComponent; exports.WavelengthBanner = WavelengthBanner; exports.WavelengthButton = WavelengthButton; exports.WavelengthCheckbox = WavelengthCheckbox; exports.WavelengthDatePicker = WavelengthDatePicker; exports.WavelengthDropdown = WavelengthDropdown; exports.WavelengthFileDropZone = WavelengthFileDropZone; exports.WavelengthForm = WavelengthForm; exports.WavelengthInput = WavelengthInput; exports.WavelengthMultiSelectAutocomplete = WavelengthMultiSelectAutocomplete; exports.WavelengthNavBar = WavelengthNavBar; exports.WavelengthNotificationPanel = WavelengthNotificationPanel; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthTitleBar = WavelengthTitleBar;
5752
5993
  /*! Bundled license information:
5753
5994
 
5754
5995
  react/cjs/react.production.min.js:
@@ -1829,4 +1829,27 @@ declare class WavelengthFileDropZone extends HTMLElement {
1829
1829
  private formatFileSize;
1830
1830
  }
1831
1831
 
1832
- export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthProgressBar, WavelengthTitleBar };
1832
+ declare class WavelengthDropdown extends HTMLElement {
1833
+ private dropdownBox;
1834
+ private dropdownField;
1835
+ private selectedSpan;
1836
+ private arrow;
1837
+ private optionsList;
1838
+ private _options;
1839
+ private _selectedValue;
1840
+ constructor();
1841
+ static get observedAttributes(): string[];
1842
+ connectedCallback(): void;
1843
+ attributeChangedCallback(): void;
1844
+ private parseOptionsAttribute;
1845
+ private setDefaultValue;
1846
+ private renderOptions;
1847
+ private setSelected;
1848
+ private applyStyles;
1849
+ get value(): string | null;
1850
+ set value(val: string);
1851
+ get color(): string;
1852
+ set color(col: string);
1853
+ }
1854
+
1855
+ export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthDropdown, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthProgressBar, WavelengthTitleBar };
@@ -1829,4 +1829,27 @@ declare class WavelengthFileDropZone extends HTMLElement {
1829
1829
  private formatFileSize;
1830
1830
  }
1831
1831
 
1832
- export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthProgressBar, WavelengthTitleBar };
1832
+ declare class WavelengthDropdown extends HTMLElement {
1833
+ private dropdownBox;
1834
+ private dropdownField;
1835
+ private selectedSpan;
1836
+ private arrow;
1837
+ private optionsList;
1838
+ private _options;
1839
+ private _selectedValue;
1840
+ constructor();
1841
+ static get observedAttributes(): string[];
1842
+ connectedCallback(): void;
1843
+ attributeChangedCallback(): void;
1844
+ private parseOptionsAttribute;
1845
+ private setDefaultValue;
1846
+ private renderOptions;
1847
+ private setSelected;
1848
+ private applyStyles;
1849
+ get value(): string | null;
1850
+ set value(val: string);
1851
+ get color(): string;
1852
+ set color(col: string);
1853
+ }
1854
+
1855
+ export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthDropdown, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthProgressBar, WavelengthTitleBar };
package/dist/esm/index.js CHANGED
@@ -5731,6 +5731,246 @@ var WavelengthFileDropZone = class extends HTMLElement {
5731
5731
  }
5732
5732
  };
5733
5733
  customElements.define("wavelength-file-drop-zone", WavelengthFileDropZone);
5734
+
5735
+ // src/web-components/wavelength-dropdown.ts
5736
+ var template6 = document.createElement("template");
5737
+ template6.innerHTML = `
5738
+ <style>
5739
+ :host {
5740
+ display: inline-block;
5741
+ position: relative;
5742
+ font-family: inherit;
5743
+ font-size: inherit;
5744
+ }
5745
+
5746
+ .dropdown-box{
5747
+ width: 100%;
5748
+ height: 100%;
5749
+ }
5750
+
5751
+ .dropdown-field {
5752
+ user-select: none;
5753
+ height: inherit;
5754
+ display: flex;
5755
+ align-items: center;
5756
+ justify-content: space-between;
5757
+ cursor: pointer;
5758
+ border: 1px solid black;
5759
+ gap: 4px;
5760
+ padding: 0 8px;
5761
+ }
5762
+
5763
+ .selected {
5764
+ display: flex;
5765
+ height: inherit;
5766
+ width: inherit;
5767
+ overflow: hidden;
5768
+ white-space: nowrap;
5769
+ align-items: center;
5770
+ }
5771
+
5772
+ .arrow {
5773
+ width: 10px;
5774
+ height: 1px;
5775
+ background: black;
5776
+ margin: 8px;
5777
+ clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
5778
+ transform: rotate(180deg);
5779
+ }
5780
+
5781
+ .arrow.active {
5782
+ transform: rotate(0deg);
5783
+ }
5784
+
5785
+ .options-list {
5786
+ position: relative;
5787
+ left: 0;
5788
+ right: 0;
5789
+ margin: 0;
5790
+ padding: 0;
5791
+ list-style: none;
5792
+ overflow-y: auto;
5793
+ display: none;
5794
+ z-index: 10;
5795
+ box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
5796
+ }
5797
+
5798
+ .options-list.show {
5799
+ display: inline-block;
5800
+ }
5801
+ </style>
5802
+
5803
+ <div class="dropdown-box" tabindex="0">
5804
+ <div class="dropdown-field">
5805
+ <span class="selected"></span>
5806
+ <i class="arrow"></i>
5807
+ </div>
5808
+ <ul class="options-list"></ul>
5809
+ </div>
5810
+ `;
5811
+ var WavelengthDropdown = class extends HTMLElement {
5812
+ constructor() {
5813
+ super();
5814
+ this._options = [];
5815
+ const shadow = this.attachShadow({ mode: "open" });
5816
+ shadow.appendChild(template6.content.cloneNode(true));
5817
+ this.dropdownField = shadow.querySelector(".dropdown-field");
5818
+ this.dropdownBox = shadow.querySelector(".dropdown-box");
5819
+ this.selectedSpan = shadow.querySelector(".selected");
5820
+ this.arrow = shadow.querySelector(".arrow");
5821
+ this.optionsList = shadow.querySelector(".options-list");
5822
+ this._selectedValue = this.getAttribute("default-value");
5823
+ }
5824
+ static get observedAttributes() {
5825
+ return ["options", "default-value", "color", "font-size", "font-family", "border-radius", "width", "height", "arrow-size", "popup-radius", "popup-align", "popup-selected-color"];
5826
+ }
5827
+ connectedCallback() {
5828
+ this.parseOptionsAttribute();
5829
+ this.applyStyles();
5830
+ this.dropdownField.addEventListener("click", () => {
5831
+ this.optionsList.classList.toggle("show");
5832
+ this.arrow.classList.toggle("active");
5833
+ });
5834
+ document.addEventListener("click", (e) => {
5835
+ if (!this.contains(e.target)) {
5836
+ this.optionsList.classList.remove("show");
5837
+ this.arrow.classList.remove("active");
5838
+ }
5839
+ });
5840
+ }
5841
+ attributeChangedCallback() {
5842
+ this.parseOptionsAttribute();
5843
+ this.setDefaultValue();
5844
+ this.applyStyles();
5845
+ }
5846
+ parseOptionsAttribute() {
5847
+ const attr = this.getAttribute("options");
5848
+ if (!attr) return;
5849
+ this._options = JSON.parse(attr);
5850
+ this.renderOptions();
5851
+ }
5852
+ setDefaultValue() {
5853
+ const defaultValue = this.getAttribute("default-value");
5854
+ if (defaultValue) {
5855
+ const match = this._options.find((o) => o.value === defaultValue);
5856
+ this.setSelected(match || this._options[0]);
5857
+ } else {
5858
+ this.setSelected(this._options[0]);
5859
+ }
5860
+ }
5861
+ renderOptions() {
5862
+ this.optionsList.innerHTML = "";
5863
+ this._options.forEach((opt) => {
5864
+ const li = document.createElement("li");
5865
+ li.textContent = opt.value;
5866
+ li.style.padding = "8px";
5867
+ li.style.whiteSpace = "nowrap";
5868
+ li.style.overflow = "visible";
5869
+ li.style.textOverflow = "clip";
5870
+ li.style.fontSize = this.getAttribute("font-size") || this.style.fontSize || "inherit";
5871
+ li.style.fontFamily = this.getAttribute("font-family") || this.style.fontFamily || "inherit";
5872
+ li.style.color = "#000";
5873
+ const originalBg = li.style.backgroundColor;
5874
+ li.addEventListener("mouseenter", () => {
5875
+ li.style.backgroundColor = "#eee";
5876
+ });
5877
+ li.addEventListener("mouseleave", () => {
5878
+ if (this._selectedValue === opt.value) {
5879
+ li.style.backgroundColor = this.getAttribute("popup-selected-color") || "";
5880
+ } else {
5881
+ li.style.backgroundColor = originalBg;
5882
+ }
5883
+ });
5884
+ li.addEventListener("click", () => {
5885
+ this.setSelected(opt);
5886
+ this.optionsList.classList.remove("show");
5887
+ this.arrow.classList.remove("active");
5888
+ const event = new CustomEvent("change", {
5889
+ detail: { value: opt.value },
5890
+ bubbles: true,
5891
+ composed: true
5892
+ });
5893
+ this.dispatchEvent(event);
5894
+ });
5895
+ this.optionsList.appendChild(li);
5896
+ });
5897
+ }
5898
+ setSelected(opt) {
5899
+ if (!opt) return;
5900
+ if (opt.label) {
5901
+ this.selectedSpan.textContent = opt.label;
5902
+ } else {
5903
+ this.selectedSpan.textContent = opt.value;
5904
+ }
5905
+ this.dropdownField.style.backgroundColor = opt.color || "";
5906
+ const children = Array.from(this.optionsList.childNodes.entries(), ([_, child]) => child);
5907
+ children.map((child) => {
5908
+ if (child.textContent === opt.value) {
5909
+ child.style.backgroundColor = this.getAttribute("popup-selected-color") || "";
5910
+ } else {
5911
+ child.style.backgroundColor = this.optionsList.style.backgroundColor;
5912
+ }
5913
+ });
5914
+ }
5915
+ applyStyles() {
5916
+ const style = this.style;
5917
+ Object.assign(this.dropdownBox.style, {
5918
+ width: this.getAttribute("width") || style.width,
5919
+ height: this.getAttribute("height") || style.height
5920
+ });
5921
+ Object.assign(this.dropdownField.style, {
5922
+ borderRadius: this.getAttribute("border-radius") || style.borderRadius,
5923
+ fontSize: this.getAttribute("font-size") || style.fontSize,
5924
+ fontFamily: this.getAttribute("font-family") || style.fontFamily,
5925
+ color: this.getAttribute("color") || "#000"
5926
+ });
5927
+ this.dropdownBox.style.minWidth = this.getAttribute("width") || "auto";
5928
+ const arrow = this.dropdownField.querySelector(".arrow");
5929
+ arrow.style.padding = this.getAttribute("arrow-size") || "2px";
5930
+ this.optionsList.style.minWidth = "auto";
5931
+ const popupAlign = this.getAttribute("popup-align") || "left";
5932
+ switch (popupAlign) {
5933
+ case "center":
5934
+ this.optionsList.style.left = "50%";
5935
+ this.optionsList.style.transform = "translateX(-50%)";
5936
+ this.optionsList.style.right = "auto";
5937
+ break;
5938
+ case "right":
5939
+ this.optionsList.style.left = "auto";
5940
+ this.optionsList.style.right = "0";
5941
+ this.optionsList.style.transform = "none";
5942
+ break;
5943
+ case "left":
5944
+ default:
5945
+ this.optionsList.style.left = "0";
5946
+ this.optionsList.style.right = "auto";
5947
+ this.optionsList.style.transform = "none";
5948
+ break;
5949
+ }
5950
+ this.optionsList.style.backgroundColor = "white";
5951
+ this.optionsList.style.borderRadius = this.getAttribute("popup-radius") || this.getAttribute("border-radius") || "4px";
5952
+ }
5953
+ get value() {
5954
+ return this._selectedValue;
5955
+ }
5956
+ set value(val) {
5957
+ const opt = this._options.find((o) => o.value === val);
5958
+ if (opt) {
5959
+ this._selectedValue = opt.value;
5960
+ this.setSelected(opt);
5961
+ }
5962
+ }
5963
+ get color() {
5964
+ return this.selectedSpan.style.backgroundColor || "";
5965
+ }
5966
+ set color(col) {
5967
+ const opt = this._options.find((o) => o.color === col);
5968
+ if (opt) this.setSelected(opt);
5969
+ }
5970
+ };
5971
+ if (!customElements.get("wavelength-dropdown")) {
5972
+ customElements.define("wavelength-dropdown", WavelengthDropdown);
5973
+ }
5734
5974
  export {
5735
5975
  BaseWavelengthInput,
5736
5976
  BaseWavelengthMultiSelectAutocomplete,
@@ -5740,6 +5980,7 @@ export {
5740
5980
  WavelengthButton,
5741
5981
  WavelengthCheckbox,
5742
5982
  WavelengthDatePicker,
5983
+ WavelengthDropdown,
5743
5984
  WavelengthFileDropZone,
5744
5985
  WavelengthForm,
5745
5986
  WavelengthInput,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wavelengthusaf/web-components",
3
3
  "author": "563 EWS - Wavelength",
4
4
  "license": "MIT",
5
- "version": "1.6.1",
5
+ "version": "1.6.2",
6
6
  "description": "Common component library used by Wavelength developers (NATIVE WEB COMPONENTS)",
7
7
  "main": "/dist/cjs/index.cjs",
8
8
  "module": "/dist/esm/index.js",