@wavelengthusaf/web-components 1.6.1 → 1.7.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.
- package/dist/cjs/index.cjs +313 -27
- package/dist/cjs/index.d.cts +407 -1
- package/dist/esm/index.d.ts +407 -1
- package/dist/esm/index.js +286 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -5731,6 +5731,290 @@ 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
|
+
}
|
|
5974
|
+
|
|
5975
|
+
// src/web-components/wavelength-planetrail.template.html
|
|
5976
|
+
var wavelength_planetrail_template_default = '<style>\n :host {\n display: block;\n --color: #00308F;\n }\n .flex-container {\n display: flex;\n align-items: center;\n }\n\n #inner {\n border-radius: 25px;\n height: 2px;\n flex-grow: 1;\n background-color: var(--color);\n }\n\n #path {\n fill: var(--color);\n }\n</style>\n\n<div id="outer" class="flex-container" >\n <div id="inner">\n </div>\n <div>\n <svg id="plane" width="40" height="40">\n <path\n d="M 4.1666 16.3988 L 5.7608 16.3988 L 8.1645 19.6359 L 18.2616 19.6359 L 14.1291 5.6667 L 16.2425 5.6667 L 24.5075 19.6359 L 33.985 19.6359 C 34.5022 19.6359 34.9422 19.8172 35.305 20.18 C 35.6677 20.5428 35.8491 20.9828 35.8491 21.5 C 35.8491 22.0172 35.6677 22.4572 35.305 22.82 C 34.9422 23.1828 34.5022 23.3642 33.985 23.3642 L 24.5075 23.3642 L 16.2425 37.3334 L 14.1291 37.3334 L 18.2616 23.3642 L 8.1966 23.3642 L 5.7608 26.6013 L 4.1666 26.6013 L 5.6433 21.5 L 4.1666 16.3988 Z"\n id="path"\n />\n </svg>\n </div>\n</div>\n';
|
|
5977
|
+
|
|
5978
|
+
// src/web-components/wavelength-planetrail.ts
|
|
5979
|
+
var BasePlaneTrail = class extends HTMLElement {
|
|
5980
|
+
static get observedAttributes() {
|
|
5981
|
+
return ["traildir", "color"];
|
|
5982
|
+
}
|
|
5983
|
+
constructor() {
|
|
5984
|
+
super();
|
|
5985
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
5986
|
+
this.shadow.innerHTML = wavelength_planetrail_template_default;
|
|
5987
|
+
this.plane = this.shadow.querySelector("#plane");
|
|
5988
|
+
this.outer = this.shadow.querySelector("#outer");
|
|
5989
|
+
this.inner = this.shadow.querySelector("#inner");
|
|
5990
|
+
}
|
|
5991
|
+
connectedCallback() {
|
|
5992
|
+
this.updateComponent();
|
|
5993
|
+
}
|
|
5994
|
+
attributeChangedCallback() {
|
|
5995
|
+
this.updateComponent();
|
|
5996
|
+
}
|
|
5997
|
+
updateComponent() {
|
|
5998
|
+
const trailDir = this.getAttribute("traildir") || "right";
|
|
5999
|
+
const color = this.getAttribute("color") || "#00308F";
|
|
6000
|
+
this.style.setProperty("--color", color);
|
|
6001
|
+
this.plane.style.setProperty("transform", trailDir === "right" ? "" : "matrix(-1, 0, 0, 1, 0, 0)");
|
|
6002
|
+
this.outer.style.setProperty("flex-direction", trailDir === "right" ? "row" : "row-reverse");
|
|
6003
|
+
this.outer.style.setProperty("justify-content", trailDir === "right" ? "right" : "left");
|
|
6004
|
+
if (trailDir === "right") {
|
|
6005
|
+
this.inner.style.setProperty("margin-right", "10px");
|
|
6006
|
+
this.inner.style.setProperty("margin-left", "0px");
|
|
6007
|
+
} else {
|
|
6008
|
+
this.inner.style.setProperty("margin-left", "10px");
|
|
6009
|
+
this.inner.style.setProperty("margin-right", "0px");
|
|
6010
|
+
}
|
|
6011
|
+
}
|
|
6012
|
+
};
|
|
6013
|
+
var WavelengthPlaneTrail = class extends StylingMixin(BasePlaneTrail) {
|
|
6014
|
+
};
|
|
6015
|
+
if (!customElements.get("wavelength-planetrail")) {
|
|
6016
|
+
customElements.define("wavelength-planetrail", WavelengthPlaneTrail);
|
|
6017
|
+
}
|
|
5734
6018
|
export {
|
|
5735
6019
|
BaseWavelengthInput,
|
|
5736
6020
|
BaseWavelengthMultiSelectAutocomplete,
|
|
@@ -5740,12 +6024,14 @@ export {
|
|
|
5740
6024
|
WavelengthButton,
|
|
5741
6025
|
WavelengthCheckbox,
|
|
5742
6026
|
WavelengthDatePicker,
|
|
6027
|
+
WavelengthDropdown,
|
|
5743
6028
|
WavelengthFileDropZone,
|
|
5744
6029
|
WavelengthForm,
|
|
5745
6030
|
WavelengthInput,
|
|
5746
6031
|
WavelengthMultiSelectAutocomplete,
|
|
5747
6032
|
WavelengthNavBar,
|
|
5748
6033
|
WavelengthNotificationPanel,
|
|
6034
|
+
WavelengthPlaneTrail,
|
|
5749
6035
|
WavelengthProgressBar,
|
|
5750
6036
|
WavelengthTitleBar
|
|
5751
6037
|
};
|
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.
|
|
5
|
+
"version": "1.7.0",
|
|
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",
|