@wavelengthusaf/web-components 1.8.0 → 1.10.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 +192 -1
- package/dist/cjs/index.d.cts +32 -1
- package/dist/esm/index.d.ts +32 -1
- package/dist/esm/index.js +192 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -6156,6 +6156,197 @@ if (!customElements.get("wavelength-manyplanes")) {
|
|
|
6156
6156
|
customElements.define("wavelength-manyplanes", WavelengthManyPlanes);
|
|
6157
6157
|
}
|
|
6158
6158
|
|
|
6159
|
+
// src/web-components/wavelength-tooltip.template.html
|
|
6160
|
+
var wavelength_tooltip_template_default = '<style>\n :host {\n display: inline-block;\n --color: #898989ff;\n --text-color: white;\n --text-content: "Tooltip Text";\n --font-family: "Arial";\n font-family: var(--font-family);\n font-size: 10px;\n }\n\n .textbox {\n background-color: var(--color);\n width: fit-content;\n height: fit-content;\n border-radius: 5px;\n padding: 5px;\n }\n\n p {\n margin: 0px;\n }\n\n .tooltip-text {\n color: var(--text-color);\n white-space: pre-wrap;\n }\n\n .flex-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .arrow {\n width: 0;\n height: 0;\n border: 6px solid transparent;\n }\n\n .tooltip {\n display: flex;\n align-items: center;\n width: fit-content;\n height: fit-content;\n }\n\n .tooltip[data-direction="up"] .arrow {\n border-bottom-color: var(--color);\n border-top-width: 0;\n }\n .tooltip[data-direction="down"] .arrow {\n border-top-color: var(--color);\n border-bottom-width: 0;\n }\n .tooltip[data-direction="left"] .arrow {\n border-right-color: var(--color);\n border-left-width: 0;\n }\n .tooltip[data-direction="right"] .arrow {\n border-left-color: var(--color);\n border-right-width: 0;\n }\n</style>\n<div class="tooltip flex-container">\n <div class="textbox">\n <p class="tooltip-text"></p>\n </div>\n <div class="arrow"></div>\n</div>\n\n\n';
|
|
6161
|
+
|
|
6162
|
+
// src/web-components/wavelength-tooltip.ts
|
|
6163
|
+
var WavelengthToolTip = class extends HTMLElement {
|
|
6164
|
+
static get observedAttributes() {
|
|
6165
|
+
return ["color", "font", "direction", "text-color", "text-content"];
|
|
6166
|
+
}
|
|
6167
|
+
constructor() {
|
|
6168
|
+
super();
|
|
6169
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
6170
|
+
this.shadow.innerHTML = wavelength_tooltip_template_default;
|
|
6171
|
+
}
|
|
6172
|
+
connectedCallback() {
|
|
6173
|
+
this.updateComponent();
|
|
6174
|
+
}
|
|
6175
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6176
|
+
if (oldValue === newValue) {
|
|
6177
|
+
return;
|
|
6178
|
+
}
|
|
6179
|
+
this.updateComponent();
|
|
6180
|
+
}
|
|
6181
|
+
updateDirection(direction) {
|
|
6182
|
+
const tooltip = this.shadow.querySelector(".tooltip");
|
|
6183
|
+
if (tooltip === null) {
|
|
6184
|
+
return;
|
|
6185
|
+
}
|
|
6186
|
+
tooltip.setAttribute("data-direction", direction);
|
|
6187
|
+
switch (direction) {
|
|
6188
|
+
case "up":
|
|
6189
|
+
tooltip.style.flexDirection = "column-reverse";
|
|
6190
|
+
break;
|
|
6191
|
+
case "down":
|
|
6192
|
+
tooltip.style.flexDirection = "column";
|
|
6193
|
+
break;
|
|
6194
|
+
case "left":
|
|
6195
|
+
tooltip.style.flexDirection = "row-reverse";
|
|
6196
|
+
break;
|
|
6197
|
+
case "right":
|
|
6198
|
+
tooltip.style.flexDirection = "row";
|
|
6199
|
+
break;
|
|
6200
|
+
default:
|
|
6201
|
+
tooltip.style.flexDirection = "column";
|
|
6202
|
+
break;
|
|
6203
|
+
}
|
|
6204
|
+
}
|
|
6205
|
+
updateComponent() {
|
|
6206
|
+
const colorAttr = this.getAttribute("color") || "#898989ff";
|
|
6207
|
+
const textColorAttr = this.getAttribute("text-color") || "white";
|
|
6208
|
+
const font = this.getAttribute("font") || "Arial";
|
|
6209
|
+
const direction = this.getAttribute("direction") || "none";
|
|
6210
|
+
const textContent = this.getAttribute("text-content") || "Tooltip Text";
|
|
6211
|
+
const color = CSS.supports("color", colorAttr) ? colorAttr : "#898989ff";
|
|
6212
|
+
const textColor = CSS.supports("color", textColorAttr) ? textColorAttr : "white";
|
|
6213
|
+
const textbox = this.shadow.querySelector(".textbox");
|
|
6214
|
+
const tooltipText = this.shadow.querySelector(".tooltip-text");
|
|
6215
|
+
if (textbox === null || tooltipText === null) {
|
|
6216
|
+
return;
|
|
6217
|
+
}
|
|
6218
|
+
this.style.setProperty("--font-family", font);
|
|
6219
|
+
this.style.setProperty("--color", color);
|
|
6220
|
+
this.style.setProperty("--text-color", textColor);
|
|
6221
|
+
this.style.setProperty("--text-content", textContent);
|
|
6222
|
+
tooltipText.textContent = textContent;
|
|
6223
|
+
this.updateDirection(direction);
|
|
6224
|
+
}
|
|
6225
|
+
};
|
|
6226
|
+
if (!customElements.get("wavelength-tooltip")) {
|
|
6227
|
+
customElements.define("wavelength-tooltip", WavelengthToolTip);
|
|
6228
|
+
}
|
|
6229
|
+
|
|
6230
|
+
// src/web-components/wavelength-menu.template.html
|
|
6231
|
+
var wavelength_menu_template_default = '<style>\n :host {\n display: block;\n --background-color: white;\n --text-color: black;\n --font: Arial, Helvetica, sans-serif;\n --font-size: 12px;\n --border: 0px solid #ccc;\n --padding: 5px;\n --border-radius: 3px;\n --selected-color: #5799ea;\n --disabled-color: #d1d1d1;\n }\n .flex-container {\n overflow-y: scroll;\n height: 125px;\n width: 175px;\n flex-direction: column;\n background-color: var(--background-color);\n border: var(--border);\n border-radius: var(--border-radius);\n padding: var(--padding);\n margin: 5px;\n box-shadow: 4px 5px 7px 4px rgba(0, 0, 0, 0.1);\n }\n .menu-item {\n display: block;\n padding: var(--padding);\n margin: 5px;\n font-size: var(--font-size);\n font-family: var(--font);\n color: var(--text-color);\n background-color: var(--background-color);\n cursor: pointer;\n transition: background-color 0.1s ease;\n border-radius: var(--border-radius);\n }\n .menu-item:hover {\n background-color: #f0f0f0;\n }\n .menu-item.selected {\n background-color: var(--selected-color) !important;\n color: white !important;\n }\n .menu-item:focus {\n background-color: #d1d1d1;\n }\n .menu-item:active {\n background-color: #d1d1d1;\n }\n .menu-item.disabled {\n color: var(--disabled-color);\n background-color: var(--background-color);\n cursor: not-allowed;\n pointer-events: none;\n opacity: 0.6;\n }\n</style>\n<div class="flex-container"></div>\n';
|
|
6232
|
+
|
|
6233
|
+
// src/web-components/wavelength-menu.ts
|
|
6234
|
+
var WavelengthMenu = class extends HTMLElement {
|
|
6235
|
+
constructor() {
|
|
6236
|
+
super();
|
|
6237
|
+
this._items = [];
|
|
6238
|
+
this._selectedIndex = -1;
|
|
6239
|
+
this._selectedId = null;
|
|
6240
|
+
this._onItemClick = (e) => {
|
|
6241
|
+
const menuItem = e.target.closest(".menu-item");
|
|
6242
|
+
if (!menuItem || menuItem.classList.contains("disabled")) return;
|
|
6243
|
+
const index = parseInt(menuItem.getAttribute("data-index") || "-1");
|
|
6244
|
+
const isAlreadySelected = menuItem.classList.contains("selected");
|
|
6245
|
+
const menuItems = this._shadow.querySelectorAll(".menu-item");
|
|
6246
|
+
menuItems.forEach((item) => item.classList.remove("selected"));
|
|
6247
|
+
if (!isAlreadySelected) {
|
|
6248
|
+
menuItem.classList.add("selected");
|
|
6249
|
+
this._selectedIndex = index;
|
|
6250
|
+
this._selectedId = menuItem.getAttribute("data-id");
|
|
6251
|
+
} else {
|
|
6252
|
+
this._selectedIndex = -1;
|
|
6253
|
+
this._selectedId = null;
|
|
6254
|
+
}
|
|
6255
|
+
this._dispatchSelectEvent();
|
|
6256
|
+
};
|
|
6257
|
+
this._shadow = this.attachShadow({ mode: "open" });
|
|
6258
|
+
this._shadow.innerHTML = wavelength_menu_template_default;
|
|
6259
|
+
this._flexContainer = this._shadow.querySelector(".flex-container");
|
|
6260
|
+
try {
|
|
6261
|
+
this._items = JSON.parse(this.getAttribute("items") || "[]");
|
|
6262
|
+
} catch (e) {
|
|
6263
|
+
this._items = [];
|
|
6264
|
+
}
|
|
6265
|
+
}
|
|
6266
|
+
static get observedAttributes() {
|
|
6267
|
+
return ["background-color", "text-color", "font", "font-size", "border", "padding", "border-radius", "selected-color", "items", "disabled-color"];
|
|
6268
|
+
}
|
|
6269
|
+
// Getter for items array.
|
|
6270
|
+
get items() {
|
|
6271
|
+
return this._items;
|
|
6272
|
+
}
|
|
6273
|
+
set items(value) {
|
|
6274
|
+
this._items = Array.isArray(value) ? value : [];
|
|
6275
|
+
this.render();
|
|
6276
|
+
}
|
|
6277
|
+
get value() {
|
|
6278
|
+
return _nullishCoalesce(this._items[this._selectedIndex], () => ( null));
|
|
6279
|
+
}
|
|
6280
|
+
connectedCallback() {
|
|
6281
|
+
this.render();
|
|
6282
|
+
this._flexContainer.addEventListener("click", this._onItemClick);
|
|
6283
|
+
}
|
|
6284
|
+
disconnectedCallback() {
|
|
6285
|
+
this._flexContainer.removeEventListener("click", this._onItemClick);
|
|
6286
|
+
}
|
|
6287
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6288
|
+
if (oldValue === newValue) return;
|
|
6289
|
+
if (name === "items") {
|
|
6290
|
+
try {
|
|
6291
|
+
this._items = JSON.parse(newValue || "[]");
|
|
6292
|
+
} catch (e) {
|
|
6293
|
+
this._items = [];
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
this.render();
|
|
6297
|
+
}
|
|
6298
|
+
render() {
|
|
6299
|
+
this._syncStyles();
|
|
6300
|
+
this._renderItems();
|
|
6301
|
+
}
|
|
6302
|
+
_syncStyles() {
|
|
6303
|
+
const styleAttributes = ["background-color", "text-color", "font", "font-size", "border", "padding", "border-radius", "selected-color", "disabled-color"];
|
|
6304
|
+
styleAttributes.forEach((attr) => {
|
|
6305
|
+
const value = this.getAttribute(attr);
|
|
6306
|
+
if (value) {
|
|
6307
|
+
this.style.setProperty(`--${attr}`, value);
|
|
6308
|
+
}
|
|
6309
|
+
});
|
|
6310
|
+
}
|
|
6311
|
+
_renderItems() {
|
|
6312
|
+
if (!this._flexContainer) return;
|
|
6313
|
+
this._flexContainer.innerHTML = "";
|
|
6314
|
+
this._items.forEach((item, index) => {
|
|
6315
|
+
const itemEl = document.createElement("div");
|
|
6316
|
+
itemEl.classList.add("menu-item");
|
|
6317
|
+
itemEl.textContent = item.label || item.toString();
|
|
6318
|
+
const isSelected = this._selectedId ? item.id === this._selectedId : this._selectedIndex === index;
|
|
6319
|
+
if (isSelected) {
|
|
6320
|
+
itemEl.classList.add("selected");
|
|
6321
|
+
}
|
|
6322
|
+
if (item.disabled) {
|
|
6323
|
+
itemEl.classList.add("disabled");
|
|
6324
|
+
itemEl.setAttribute("disabled", "");
|
|
6325
|
+
}
|
|
6326
|
+
if (item.id) {
|
|
6327
|
+
itemEl.id = item.id;
|
|
6328
|
+
itemEl.setAttribute("data-id", item.id);
|
|
6329
|
+
}
|
|
6330
|
+
itemEl.setAttribute("data-index", index.toString());
|
|
6331
|
+
this._flexContainer.appendChild(itemEl);
|
|
6332
|
+
});
|
|
6333
|
+
}
|
|
6334
|
+
_dispatchSelectEvent() {
|
|
6335
|
+
this.dispatchEvent(
|
|
6336
|
+
new CustomEvent("wavelength-menu-select", {
|
|
6337
|
+
detail: this.value,
|
|
6338
|
+
bubbles: true,
|
|
6339
|
+
composed: true
|
|
6340
|
+
})
|
|
6341
|
+
);
|
|
6342
|
+
}
|
|
6343
|
+
};
|
|
6344
|
+
if (!customElements.get("wavelength-menu")) {
|
|
6345
|
+
customElements.define("wavelength-menu", WavelengthMenu);
|
|
6346
|
+
}
|
|
6347
|
+
|
|
6348
|
+
|
|
6349
|
+
|
|
6159
6350
|
|
|
6160
6351
|
|
|
6161
6352
|
|
|
@@ -6176,7 +6367,7 @@ if (!customElements.get("wavelength-manyplanes")) {
|
|
|
6176
6367
|
|
|
6177
6368
|
|
|
6178
6369
|
|
|
6179
|
-
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.WavelengthManyPlanes = WavelengthManyPlanes; exports.WavelengthMultiSelectAutocomplete = WavelengthMultiSelectAutocomplete; exports.WavelengthNavBar = WavelengthNavBar; exports.WavelengthNotificationPanel = WavelengthNotificationPanel; exports.WavelengthPlaneTrail = WavelengthPlaneTrail; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthSnackbar = WavelengthSnackbar; exports.WavelengthTitleBar = WavelengthTitleBar;
|
|
6370
|
+
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.WavelengthManyPlanes = WavelengthManyPlanes; exports.WavelengthMenu = WavelengthMenu; exports.WavelengthMultiSelectAutocomplete = WavelengthMultiSelectAutocomplete; exports.WavelengthNavBar = WavelengthNavBar; exports.WavelengthNotificationPanel = WavelengthNotificationPanel; exports.WavelengthPlaneTrail = WavelengthPlaneTrail; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthSnackbar = WavelengthSnackbar; exports.WavelengthTitleBar = WavelengthTitleBar; exports.WavelengthToolTip = WavelengthToolTip;
|
|
6180
6371
|
/*! Bundled license information:
|
|
6181
6372
|
|
|
6182
6373
|
react/cjs/react.production.min.js:
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -2255,4 +2255,35 @@ declare class WavelengthManyPlanes extends HTMLElement {
|
|
|
2255
2255
|
createPlane(opacity: string, color: string, flipped: boolean): SVGSVGElement;
|
|
2256
2256
|
}
|
|
2257
2257
|
|
|
2258
|
-
|
|
2258
|
+
declare class WavelengthToolTip extends HTMLElement {
|
|
2259
|
+
static get observedAttributes(): string[];
|
|
2260
|
+
private shadow;
|
|
2261
|
+
constructor();
|
|
2262
|
+
connectedCallback(): void;
|
|
2263
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
2264
|
+
updateDirection(direction: string): void;
|
|
2265
|
+
updateComponent(): void;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
declare class WavelengthMenu extends HTMLElement {
|
|
2269
|
+
static get observedAttributes(): string[];
|
|
2270
|
+
private _items;
|
|
2271
|
+
private _selectedIndex;
|
|
2272
|
+
private _selectedId;
|
|
2273
|
+
private _flexContainer;
|
|
2274
|
+
private _shadow;
|
|
2275
|
+
constructor();
|
|
2276
|
+
get items(): any[];
|
|
2277
|
+
set items(value: any[]);
|
|
2278
|
+
get value(): any;
|
|
2279
|
+
connectedCallback(): void;
|
|
2280
|
+
disconnectedCallback(): void;
|
|
2281
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
2282
|
+
render(): void;
|
|
2283
|
+
private _syncStyles;
|
|
2284
|
+
private _renderItems;
|
|
2285
|
+
private _onItemClick;
|
|
2286
|
+
private _dispatchSelectEvent;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthDropdown, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthManyPlanes, WavelengthMenu, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthPlaneTrail, WavelengthProgressBar, WavelengthSnackbar, WavelengthTitleBar, WavelengthToolTip };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2255,4 +2255,35 @@ declare class WavelengthManyPlanes extends HTMLElement {
|
|
|
2255
2255
|
createPlane(opacity: string, color: string, flipped: boolean): SVGSVGElement;
|
|
2256
2256
|
}
|
|
2257
2257
|
|
|
2258
|
-
|
|
2258
|
+
declare class WavelengthToolTip extends HTMLElement {
|
|
2259
|
+
static get observedAttributes(): string[];
|
|
2260
|
+
private shadow;
|
|
2261
|
+
constructor();
|
|
2262
|
+
connectedCallback(): void;
|
|
2263
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
2264
|
+
updateDirection(direction: string): void;
|
|
2265
|
+
updateComponent(): void;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
declare class WavelengthMenu extends HTMLElement {
|
|
2269
|
+
static get observedAttributes(): string[];
|
|
2270
|
+
private _items;
|
|
2271
|
+
private _selectedIndex;
|
|
2272
|
+
private _selectedId;
|
|
2273
|
+
private _flexContainer;
|
|
2274
|
+
private _shadow;
|
|
2275
|
+
constructor();
|
|
2276
|
+
get items(): any[];
|
|
2277
|
+
set items(value: any[]);
|
|
2278
|
+
get value(): any;
|
|
2279
|
+
connectedCallback(): void;
|
|
2280
|
+
disconnectedCallback(): void;
|
|
2281
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
2282
|
+
render(): void;
|
|
2283
|
+
private _syncStyles;
|
|
2284
|
+
private _renderItems;
|
|
2285
|
+
private _onItemClick;
|
|
2286
|
+
private _dispatchSelectEvent;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthDropdown, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthManyPlanes, WavelengthMenu, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthPlaneTrail, WavelengthProgressBar, WavelengthSnackbar, WavelengthTitleBar, WavelengthToolTip };
|
package/dist/esm/index.js
CHANGED
|
@@ -6155,6 +6155,195 @@ var WavelengthManyPlanes = class extends HTMLElement {
|
|
|
6155
6155
|
if (!customElements.get("wavelength-manyplanes")) {
|
|
6156
6156
|
customElements.define("wavelength-manyplanes", WavelengthManyPlanes);
|
|
6157
6157
|
}
|
|
6158
|
+
|
|
6159
|
+
// src/web-components/wavelength-tooltip.template.html
|
|
6160
|
+
var wavelength_tooltip_template_default = '<style>\n :host {\n display: inline-block;\n --color: #898989ff;\n --text-color: white;\n --text-content: "Tooltip Text";\n --font-family: "Arial";\n font-family: var(--font-family);\n font-size: 10px;\n }\n\n .textbox {\n background-color: var(--color);\n width: fit-content;\n height: fit-content;\n border-radius: 5px;\n padding: 5px;\n }\n\n p {\n margin: 0px;\n }\n\n .tooltip-text {\n color: var(--text-color);\n white-space: pre-wrap;\n }\n\n .flex-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .arrow {\n width: 0;\n height: 0;\n border: 6px solid transparent;\n }\n\n .tooltip {\n display: flex;\n align-items: center;\n width: fit-content;\n height: fit-content;\n }\n\n .tooltip[data-direction="up"] .arrow {\n border-bottom-color: var(--color);\n border-top-width: 0;\n }\n .tooltip[data-direction="down"] .arrow {\n border-top-color: var(--color);\n border-bottom-width: 0;\n }\n .tooltip[data-direction="left"] .arrow {\n border-right-color: var(--color);\n border-left-width: 0;\n }\n .tooltip[data-direction="right"] .arrow {\n border-left-color: var(--color);\n border-right-width: 0;\n }\n</style>\n<div class="tooltip flex-container">\n <div class="textbox">\n <p class="tooltip-text"></p>\n </div>\n <div class="arrow"></div>\n</div>\n\n\n';
|
|
6161
|
+
|
|
6162
|
+
// src/web-components/wavelength-tooltip.ts
|
|
6163
|
+
var WavelengthToolTip = class extends HTMLElement {
|
|
6164
|
+
static get observedAttributes() {
|
|
6165
|
+
return ["color", "font", "direction", "text-color", "text-content"];
|
|
6166
|
+
}
|
|
6167
|
+
constructor() {
|
|
6168
|
+
super();
|
|
6169
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
6170
|
+
this.shadow.innerHTML = wavelength_tooltip_template_default;
|
|
6171
|
+
}
|
|
6172
|
+
connectedCallback() {
|
|
6173
|
+
this.updateComponent();
|
|
6174
|
+
}
|
|
6175
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6176
|
+
if (oldValue === newValue) {
|
|
6177
|
+
return;
|
|
6178
|
+
}
|
|
6179
|
+
this.updateComponent();
|
|
6180
|
+
}
|
|
6181
|
+
updateDirection(direction) {
|
|
6182
|
+
const tooltip = this.shadow.querySelector(".tooltip");
|
|
6183
|
+
if (tooltip === null) {
|
|
6184
|
+
return;
|
|
6185
|
+
}
|
|
6186
|
+
tooltip.setAttribute("data-direction", direction);
|
|
6187
|
+
switch (direction) {
|
|
6188
|
+
case "up":
|
|
6189
|
+
tooltip.style.flexDirection = "column-reverse";
|
|
6190
|
+
break;
|
|
6191
|
+
case "down":
|
|
6192
|
+
tooltip.style.flexDirection = "column";
|
|
6193
|
+
break;
|
|
6194
|
+
case "left":
|
|
6195
|
+
tooltip.style.flexDirection = "row-reverse";
|
|
6196
|
+
break;
|
|
6197
|
+
case "right":
|
|
6198
|
+
tooltip.style.flexDirection = "row";
|
|
6199
|
+
break;
|
|
6200
|
+
default:
|
|
6201
|
+
tooltip.style.flexDirection = "column";
|
|
6202
|
+
break;
|
|
6203
|
+
}
|
|
6204
|
+
}
|
|
6205
|
+
updateComponent() {
|
|
6206
|
+
const colorAttr = this.getAttribute("color") || "#898989ff";
|
|
6207
|
+
const textColorAttr = this.getAttribute("text-color") || "white";
|
|
6208
|
+
const font = this.getAttribute("font") || "Arial";
|
|
6209
|
+
const direction = this.getAttribute("direction") || "none";
|
|
6210
|
+
const textContent = this.getAttribute("text-content") || "Tooltip Text";
|
|
6211
|
+
const color = CSS.supports("color", colorAttr) ? colorAttr : "#898989ff";
|
|
6212
|
+
const textColor = CSS.supports("color", textColorAttr) ? textColorAttr : "white";
|
|
6213
|
+
const textbox = this.shadow.querySelector(".textbox");
|
|
6214
|
+
const tooltipText = this.shadow.querySelector(".tooltip-text");
|
|
6215
|
+
if (textbox === null || tooltipText === null) {
|
|
6216
|
+
return;
|
|
6217
|
+
}
|
|
6218
|
+
this.style.setProperty("--font-family", font);
|
|
6219
|
+
this.style.setProperty("--color", color);
|
|
6220
|
+
this.style.setProperty("--text-color", textColor);
|
|
6221
|
+
this.style.setProperty("--text-content", textContent);
|
|
6222
|
+
tooltipText.textContent = textContent;
|
|
6223
|
+
this.updateDirection(direction);
|
|
6224
|
+
}
|
|
6225
|
+
};
|
|
6226
|
+
if (!customElements.get("wavelength-tooltip")) {
|
|
6227
|
+
customElements.define("wavelength-tooltip", WavelengthToolTip);
|
|
6228
|
+
}
|
|
6229
|
+
|
|
6230
|
+
// src/web-components/wavelength-menu.template.html
|
|
6231
|
+
var wavelength_menu_template_default = '<style>\n :host {\n display: block;\n --background-color: white;\n --text-color: black;\n --font: Arial, Helvetica, sans-serif;\n --font-size: 12px;\n --border: 0px solid #ccc;\n --padding: 5px;\n --border-radius: 3px;\n --selected-color: #5799ea;\n --disabled-color: #d1d1d1;\n }\n .flex-container {\n overflow-y: scroll;\n height: 125px;\n width: 175px;\n flex-direction: column;\n background-color: var(--background-color);\n border: var(--border);\n border-radius: var(--border-radius);\n padding: var(--padding);\n margin: 5px;\n box-shadow: 4px 5px 7px 4px rgba(0, 0, 0, 0.1);\n }\n .menu-item {\n display: block;\n padding: var(--padding);\n margin: 5px;\n font-size: var(--font-size);\n font-family: var(--font);\n color: var(--text-color);\n background-color: var(--background-color);\n cursor: pointer;\n transition: background-color 0.1s ease;\n border-radius: var(--border-radius);\n }\n .menu-item:hover {\n background-color: #f0f0f0;\n }\n .menu-item.selected {\n background-color: var(--selected-color) !important;\n color: white !important;\n }\n .menu-item:focus {\n background-color: #d1d1d1;\n }\n .menu-item:active {\n background-color: #d1d1d1;\n }\n .menu-item.disabled {\n color: var(--disabled-color);\n background-color: var(--background-color);\n cursor: not-allowed;\n pointer-events: none;\n opacity: 0.6;\n }\n</style>\n<div class="flex-container"></div>\n';
|
|
6232
|
+
|
|
6233
|
+
// src/web-components/wavelength-menu.ts
|
|
6234
|
+
var WavelengthMenu = class extends HTMLElement {
|
|
6235
|
+
constructor() {
|
|
6236
|
+
super();
|
|
6237
|
+
this._items = [];
|
|
6238
|
+
this._selectedIndex = -1;
|
|
6239
|
+
this._selectedId = null;
|
|
6240
|
+
this._onItemClick = (e) => {
|
|
6241
|
+
const menuItem = e.target.closest(".menu-item");
|
|
6242
|
+
if (!menuItem || menuItem.classList.contains("disabled")) return;
|
|
6243
|
+
const index = parseInt(menuItem.getAttribute("data-index") || "-1");
|
|
6244
|
+
const isAlreadySelected = menuItem.classList.contains("selected");
|
|
6245
|
+
const menuItems = this._shadow.querySelectorAll(".menu-item");
|
|
6246
|
+
menuItems.forEach((item) => item.classList.remove("selected"));
|
|
6247
|
+
if (!isAlreadySelected) {
|
|
6248
|
+
menuItem.classList.add("selected");
|
|
6249
|
+
this._selectedIndex = index;
|
|
6250
|
+
this._selectedId = menuItem.getAttribute("data-id");
|
|
6251
|
+
} else {
|
|
6252
|
+
this._selectedIndex = -1;
|
|
6253
|
+
this._selectedId = null;
|
|
6254
|
+
}
|
|
6255
|
+
this._dispatchSelectEvent();
|
|
6256
|
+
};
|
|
6257
|
+
this._shadow = this.attachShadow({ mode: "open" });
|
|
6258
|
+
this._shadow.innerHTML = wavelength_menu_template_default;
|
|
6259
|
+
this._flexContainer = this._shadow.querySelector(".flex-container");
|
|
6260
|
+
try {
|
|
6261
|
+
this._items = JSON.parse(this.getAttribute("items") || "[]");
|
|
6262
|
+
} catch (e) {
|
|
6263
|
+
this._items = [];
|
|
6264
|
+
}
|
|
6265
|
+
}
|
|
6266
|
+
static get observedAttributes() {
|
|
6267
|
+
return ["background-color", "text-color", "font", "font-size", "border", "padding", "border-radius", "selected-color", "items", "disabled-color"];
|
|
6268
|
+
}
|
|
6269
|
+
// Getter for items array.
|
|
6270
|
+
get items() {
|
|
6271
|
+
return this._items;
|
|
6272
|
+
}
|
|
6273
|
+
set items(value) {
|
|
6274
|
+
this._items = Array.isArray(value) ? value : [];
|
|
6275
|
+
this.render();
|
|
6276
|
+
}
|
|
6277
|
+
get value() {
|
|
6278
|
+
return this._items[this._selectedIndex] ?? null;
|
|
6279
|
+
}
|
|
6280
|
+
connectedCallback() {
|
|
6281
|
+
this.render();
|
|
6282
|
+
this._flexContainer.addEventListener("click", this._onItemClick);
|
|
6283
|
+
}
|
|
6284
|
+
disconnectedCallback() {
|
|
6285
|
+
this._flexContainer.removeEventListener("click", this._onItemClick);
|
|
6286
|
+
}
|
|
6287
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6288
|
+
if (oldValue === newValue) return;
|
|
6289
|
+
if (name === "items") {
|
|
6290
|
+
try {
|
|
6291
|
+
this._items = JSON.parse(newValue || "[]");
|
|
6292
|
+
} catch (e) {
|
|
6293
|
+
this._items = [];
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
this.render();
|
|
6297
|
+
}
|
|
6298
|
+
render() {
|
|
6299
|
+
this._syncStyles();
|
|
6300
|
+
this._renderItems();
|
|
6301
|
+
}
|
|
6302
|
+
_syncStyles() {
|
|
6303
|
+
const styleAttributes = ["background-color", "text-color", "font", "font-size", "border", "padding", "border-radius", "selected-color", "disabled-color"];
|
|
6304
|
+
styleAttributes.forEach((attr) => {
|
|
6305
|
+
const value = this.getAttribute(attr);
|
|
6306
|
+
if (value) {
|
|
6307
|
+
this.style.setProperty(`--${attr}`, value);
|
|
6308
|
+
}
|
|
6309
|
+
});
|
|
6310
|
+
}
|
|
6311
|
+
_renderItems() {
|
|
6312
|
+
if (!this._flexContainer) return;
|
|
6313
|
+
this._flexContainer.innerHTML = "";
|
|
6314
|
+
this._items.forEach((item, index) => {
|
|
6315
|
+
const itemEl = document.createElement("div");
|
|
6316
|
+
itemEl.classList.add("menu-item");
|
|
6317
|
+
itemEl.textContent = item.label || item.toString();
|
|
6318
|
+
const isSelected = this._selectedId ? item.id === this._selectedId : this._selectedIndex === index;
|
|
6319
|
+
if (isSelected) {
|
|
6320
|
+
itemEl.classList.add("selected");
|
|
6321
|
+
}
|
|
6322
|
+
if (item.disabled) {
|
|
6323
|
+
itemEl.classList.add("disabled");
|
|
6324
|
+
itemEl.setAttribute("disabled", "");
|
|
6325
|
+
}
|
|
6326
|
+
if (item.id) {
|
|
6327
|
+
itemEl.id = item.id;
|
|
6328
|
+
itemEl.setAttribute("data-id", item.id);
|
|
6329
|
+
}
|
|
6330
|
+
itemEl.setAttribute("data-index", index.toString());
|
|
6331
|
+
this._flexContainer.appendChild(itemEl);
|
|
6332
|
+
});
|
|
6333
|
+
}
|
|
6334
|
+
_dispatchSelectEvent() {
|
|
6335
|
+
this.dispatchEvent(
|
|
6336
|
+
new CustomEvent("wavelength-menu-select", {
|
|
6337
|
+
detail: this.value,
|
|
6338
|
+
bubbles: true,
|
|
6339
|
+
composed: true
|
|
6340
|
+
})
|
|
6341
|
+
);
|
|
6342
|
+
}
|
|
6343
|
+
};
|
|
6344
|
+
if (!customElements.get("wavelength-menu")) {
|
|
6345
|
+
customElements.define("wavelength-menu", WavelengthMenu);
|
|
6346
|
+
}
|
|
6158
6347
|
export {
|
|
6159
6348
|
BaseWavelengthInput,
|
|
6160
6349
|
BaseWavelengthMultiSelectAutocomplete,
|
|
@@ -6169,13 +6358,15 @@ export {
|
|
|
6169
6358
|
WavelengthForm,
|
|
6170
6359
|
WavelengthInput,
|
|
6171
6360
|
WavelengthManyPlanes,
|
|
6361
|
+
WavelengthMenu,
|
|
6172
6362
|
WavelengthMultiSelectAutocomplete,
|
|
6173
6363
|
WavelengthNavBar,
|
|
6174
6364
|
WavelengthNotificationPanel,
|
|
6175
6365
|
WavelengthPlaneTrail,
|
|
6176
6366
|
WavelengthProgressBar,
|
|
6177
6367
|
WavelengthSnackbar,
|
|
6178
|
-
WavelengthTitleBar
|
|
6368
|
+
WavelengthTitleBar,
|
|
6369
|
+
WavelengthToolTip
|
|
6179
6370
|
};
|
|
6180
6371
|
/*! Bundled license information:
|
|
6181
6372
|
|
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.10.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",
|