wj-elements 0.1.48 → 0.1.49
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/custom-elements.json +14058 -0
- package/dist/dark.css +1 -0
- package/dist/light.css +1 -0
- package/dist/localize.js +45 -0
- package/dist/popup.element-CWsSOxs2.js +1072 -0
- package/dist/router-links-FtZbFUto.js +146 -0
- package/dist/styles.css +1 -0
- package/dist/web-types.json +3122 -0
- package/dist/wje-accordion-item.js +88 -0
- package/dist/wje-accordion.js +79 -0
- package/dist/wje-animation.js +121 -0
- package/dist/wje-aside.js +55 -0
- package/dist/wje-avatar.js +77 -0
- package/dist/wje-badge.js +50 -0
- package/dist/wje-breadcrumb.js +148 -0
- package/dist/wje-breadcrumbs.js +67 -0
- package/dist/wje-button-group.js +78 -0
- package/dist/wje-button.js +207 -0
- package/dist/wje-card-content.js +48 -0
- package/dist/wje-card-controls.js +48 -0
- package/dist/wje-card-header.js +47 -0
- package/dist/wje-card-subtitle.js +55 -0
- package/dist/wje-card-title.js +55 -0
- package/dist/wje-card.js +50 -0
- package/dist/wje-carousel-item.js +33 -0
- package/dist/wje-carousel.js +177 -0
- package/dist/wje-checkbox.js +96 -0
- package/dist/wje-chip.js +32 -0
- package/dist/wje-col.js +27 -0
- package/dist/wje-color-picker.js +953 -0
- package/dist/wje-container.js +57 -0
- package/dist/wje-copy-button.js +170 -0
- package/dist/wje-dialog.js +86 -0
- package/dist/wje-divider.js +53 -0
- package/dist/wje-dropdown.js +114 -0
- package/dist/wje-element.js +453 -0
- package/dist/wje-fetchAndParseCSS.js +40 -0
- package/dist/wje-file-upload-item.js +115 -0
- package/dist/wje-file-upload.js +297 -0
- package/dist/wje-footer.js +56 -0
- package/dist/wje-form.js +28 -0
- package/dist/wje-format-digital.js +85 -0
- package/dist/wje-grid.js +28 -0
- package/dist/wje-header.js +58 -0
- package/dist/wje-icon-picker.js +221 -0
- package/dist/wje-icon.js +119 -0
- package/dist/wje-img-comparer.js +111 -0
- package/dist/wje-img.js +58 -0
- package/dist/wje-infinite-scroll.js +201 -0
- package/dist/wje-inline-edit.js +145 -0
- package/dist/wje-input-file.js +85 -0
- package/dist/wje-input.js +334 -0
- package/dist/wje-item.js +45 -0
- package/dist/wje-label.js +67 -0
- package/dist/wje-list.js +53 -0
- package/dist/wje-main.js +56 -0
- package/dist/wje-masonry.js +218 -0
- package/dist/wje-master.js +423 -0
- package/dist/wje-menu-button.js +65 -0
- package/dist/wje-menu-item.js +230 -0
- package/dist/wje-menu-label.js +57 -0
- package/dist/wje-menu.js +74 -0
- package/dist/wje-option.js +99 -0
- package/dist/wje-options.js +63 -0
- package/dist/wje-popup.js +5 -0
- package/dist/wje-progress-bar.js +161 -0
- package/dist/wje-qr-code.js +2332 -0
- package/dist/wje-radio-group.js +101 -0
- package/dist/wje-radio.js +46 -0
- package/dist/wje-rate.js +260 -0
- package/dist/wje-relative-time.js +85 -0
- package/dist/wje-reorder-dropzone.js +27 -0
- package/dist/wje-reorder-handle.js +115 -0
- package/dist/wje-reorder-item.js +32 -0
- package/dist/wje-reorder.js +138 -0
- package/dist/wje-route.js +46 -0
- package/dist/wje-router-link.js +64 -0
- package/dist/wje-router-outlet.js +127 -0
- package/dist/wje-routerx.js +1088 -0
- package/dist/wje-row.js +58 -0
- package/dist/wje-select.js +242 -0
- package/dist/wje-slider.js +177 -0
- package/dist/wje-sliding-container.js +277 -0
- package/dist/wje-split-view.js +112 -0
- package/dist/wje-status.js +54 -0
- package/dist/wje-store.js +192 -0
- package/dist/wje-tab-group.js +107 -0
- package/dist/wje-tab-panel.js +52 -0
- package/dist/wje-tab.js +59 -0
- package/dist/wje-textarea.js +116 -0
- package/dist/wje-thumbnail.js +64 -0
- package/dist/wje-toast.js +76 -0
- package/dist/wje-toggle.js +94 -0
- package/dist/wje-toolbar-action.js +63 -0
- package/dist/wje-toolbar.js +61 -0
- package/dist/wje-tooltip.js +116 -0
- package/dist/wje-visually-hidden.js +56 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var i = (n, t, e) => t in n ? l(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var o = (n, t, e) => (i(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import u, { event as c } from "./wje-element.js";
|
|
5
|
+
const d = ":host{display:inline-flex}@media (min-width: 768px){:host{display:none}}";
|
|
6
|
+
class r extends u {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of MenuButton.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
o(this, "className", "MenuButton");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the CSS styles for the component.
|
|
18
|
+
*
|
|
19
|
+
* @static
|
|
20
|
+
* @returns {CSSStyleSheet}
|
|
21
|
+
*/
|
|
22
|
+
static get cssStyleSheet() {
|
|
23
|
+
return d;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the list of attributes to observe for changes.
|
|
27
|
+
*
|
|
28
|
+
* @static
|
|
29
|
+
* @returns {Array<string>}
|
|
30
|
+
*/
|
|
31
|
+
static get observedAttributes() {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets up the attributes for the component.
|
|
36
|
+
*/
|
|
37
|
+
setupAttributes() {
|
|
38
|
+
this.isShadowRoot = "open";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Draws the component.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} context - The context for drawing.
|
|
44
|
+
* @param {Object} store - The store for drawing.
|
|
45
|
+
* @param {Object} params - The parameters for drawing.
|
|
46
|
+
* @returns {DocumentFragment}
|
|
47
|
+
*/
|
|
48
|
+
draw(e, m, p) {
|
|
49
|
+
let s = document.createDocumentFragment(), a = document.createElement("slot");
|
|
50
|
+
return s.appendChild(a), s;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Refreshes the component after drawing.
|
|
54
|
+
* Adds a click event listener that toggles the "open" class on the content element.
|
|
55
|
+
*/
|
|
56
|
+
afterDraw() {
|
|
57
|
+
c.addListener(this, "click", null, (e) => {
|
|
58
|
+
document.querySelector(`#${this.contentId}`).classList.toggle("open");
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
r.define("wje-menu-button", r);
|
|
63
|
+
export {
|
|
64
|
+
r as default
|
|
65
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var A = (o, r, e) => r in o ? y(o, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[r] = e;
|
|
3
|
+
var c = (o, r, e) => (A(o, typeof r != "symbol" ? r + "" : r, e), e);
|
|
4
|
+
import E, { WjElementUtils as k, event as l } from "./wje-element.js";
|
|
5
|
+
import { b as S } from "./router-links-FtZbFUto.js";
|
|
6
|
+
const L = ':host{--wje-menu-item-safe-triangle-cursor-x: 0;--wje-menu-item-safe-triangle-cursor-y: 0;--wje-menu-item-safe-triangle-submenu-start-x: 0;--wje-menu-item-safe-triangle-submenu-start-y: 0;--wje-menu-item-safe-triangle-submenu-end-x: 0;--wje-menu-item-safe-triangle-submenu-end-y: 0;display:block}:host .native-menu-item{background:var(--wje-menu-item-background);position:relative;display:flex;flex-wrap:nowrap;align-items:center;justify-content:center;color:var(--wje-menu-item-color);padding-top:var(--wje-menu-item-padding-top);padding-bottom:var(--wje-menu-item-padding-bottom);transition:var(--wje-transition-fast) fill;-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer;width:100%}:host .native-menu-item:hover{color:var(--wje-menu-item-color-hover);background:var(--wje-menu-item-background-hover)}:host .native-menu-item:focus{color:var(--wje-menu-item-color-focus);background:var(--wje-menu-item-background-focus)}:host .native-menu-item:active{color:var(--wje-menu-item-color-active);background:var(--wje-menu-item-background-active)}:host .native-menu-item .label{flex:1 1 auto;display:inline-block;text-overflow:ellipsis;overflow:hidden;line-height:normal}:host .native-menu-item .check-icon{flex:0 0 auto;display:var(--wje-menu-item-check-icon-display, flex);align-items:center;justify-content:center;width:var(--wje-menu-item-check-icon-width, 1.5rem);visibility:hidden}:host .native-menu-item .check-icon.checked{visibility:visible}:host .native-menu-item.expanded-submenu{color:var(--wje-menu-item-color-active);background:var(--wje-menu-item-background-active)}:host .native-menu-item.expanded-submenu:hover{color:var(--wje-menu-item-color-hover);background:var(--wje-menu-item-background-hover)}:host .native-menu-item.expanded-submenu:after{content:"";position:fixed;z-index:1;top:0;right:0;bottom:0;left:0;clip-path:polygon(var(--wje-menu-item-safe-triangle-cursor-x) var(--wje-menu-item-safe-triangle-cursor-y),var(--wje-menu-item-safe-triangle-submenu-start-x) var(--wje-menu-item-safe-triangle-submenu-start-y),var(--wje-menu-item-safe-triangle-submenu-end-x) var(--wje-menu-item-safe-triangle-submenu-end-y))}:host(.collapse) ::slotted([slot="start"]){margin:0}:host(.collapse) ::slotted([slot="end"]){display:none}:host(.collapse) .label,:host(.collapse) .check-icon,:host(.collapse) .submenu-icon{display:none}.submenu-icon{--wje-icon-size: 14px !important;flex:0 0 auto;display:flex;align-items:center;justify-content:center;width:1.5rem;visibility:var(--wje-menu-item-icon-visibility)}.has-submenu .submenu-icon{--wje-menu-item-icon-visibility: visible}.submenu-icon.collapse{flex:none;position:relative}:host(:focus-visible){outline:none}::slotted([slot="start"]){flex:0 0 auto;display:flex;align-items:center;margin-inline-end:.5rem}::slotted([slot="end"]){flex:0 0 auto;display:flex;align-items:center;margin-inline-start:.5rem}:host(.wje-menu-variant-nav) ::slotted([slot="submenu"]){--wje-menu-border-width: 0 !important;--wje-menu-margin-inline: 2rem 0 !important}:host(.wje-menu-variant-context){display:block}:host(.active){color:var(--wje-menu-item-color-active);background:var(--wje-menu-item-background-active)}:host(.open){color:var(--wje-menu-item-color-active);background:var(--wje-menu-item-background-active)}';
|
|
7
|
+
class j extends E {
|
|
8
|
+
/**
|
|
9
|
+
* Constructor for MenuItem class.
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
c(this, "className", "MenuItem");
|
|
15
|
+
/**
|
|
16
|
+
* Checks if the submenu should be hidden based on the event.
|
|
17
|
+
*
|
|
18
|
+
* @param {Event} e - The event object.
|
|
19
|
+
*/
|
|
20
|
+
c(this, "shouldHideSubmenu", (e) => {
|
|
21
|
+
if (this.collapse || this.variant === "CONTEXT" && this.hasSubmenu) {
|
|
22
|
+
if (e.relatedTarget && this.contains(e.relatedTarget) || this.variant === "NAV" && !this.collapse)
|
|
23
|
+
return;
|
|
24
|
+
this.deactivateSubmenu(), this.hideSubmenu();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Dispatches a mousemove event.
|
|
29
|
+
*/
|
|
30
|
+
c(this, "dispatchMove", (e) => {
|
|
31
|
+
this.style.setProperty("--wje-menu-item-safe-triangle-cursor-x", `${e.clientX}px`), this.style.setProperty("--wje-menu-item-safe-triangle-cursor-y", `${e.clientY}px`);
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Dispatches a reposition event.
|
|
35
|
+
*/
|
|
36
|
+
c(this, "dispatchReposition", (e) => {
|
|
37
|
+
if (this.submenu.assignedNodes().length === 0)
|
|
38
|
+
return;
|
|
39
|
+
let s = this.submenu.assignedNodes()[0];
|
|
40
|
+
const { left: n, top: t, width: i, height: u } = s.getBoundingClientRect();
|
|
41
|
+
this.style.setProperty("--wje-menu-item-safe-triangle-submenu-start-x", `${n}px`), this.style.setProperty("--wje-menu-item-safe-triangle-submenu-start-y", `${t}px`), this.style.setProperty("--wje-menu-item-safe-triangle-submenu-end-x", `${n}px`), this.style.setProperty("--wje-menu-item-safe-triangle-submenu-end-y", `${t + u}px`);
|
|
42
|
+
});
|
|
43
|
+
S(this, { selector: !1 }), this._collapsible = !1;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Getter for placement attribute.
|
|
47
|
+
* @returns {string} The placement attribute of the menu or "right-start" if it doesn't exist.
|
|
48
|
+
*/
|
|
49
|
+
get placement() {
|
|
50
|
+
let e = this.querySelector("wje-menu");
|
|
51
|
+
return e != null && e.hasAttribute("placement") ? e.getAttribute("placement") : "right-start";
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Getter for offset attribute.
|
|
55
|
+
* @returns {string} The offset attribute of the menu or "0" if it doesn't exist.
|
|
56
|
+
*/
|
|
57
|
+
get offset() {
|
|
58
|
+
let e = this.querySelector("wje-menu");
|
|
59
|
+
return e != null && e.hasAttribute("offset") ? e.getAttribute("offset") : "0";
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Getter for variant attribute.
|
|
63
|
+
* @returns {string} The variant attribute of the menu or "CONTEXT" if it doesn't exist.
|
|
64
|
+
*/
|
|
65
|
+
get variant() {
|
|
66
|
+
let e = this.querySelector("wje-menu");
|
|
67
|
+
return e != null && e.hasAttribute("variant") && !this.collapse ? e.getAttribute("variant").toUpperCase() : "CONTEXT";
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Getter for collapse attribute.
|
|
71
|
+
* @returns {boolean} True if the closest parent has the collapse attribute, false otherwise.
|
|
72
|
+
*/
|
|
73
|
+
get collapse() {
|
|
74
|
+
return !!this.closest("[collapse]");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Getter for cssStyleSheet.
|
|
78
|
+
* @returns {string} The styles imported from styles.css.
|
|
79
|
+
*/
|
|
80
|
+
static get cssStyleSheet() {
|
|
81
|
+
return L;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Getter for observedAttributes.
|
|
85
|
+
* @returns {Array} An empty array as no attributes are being observed.
|
|
86
|
+
*/
|
|
87
|
+
static get observedAttributes() {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sets up the attributes for the MenuItem element.
|
|
92
|
+
*/
|
|
93
|
+
setupAttributes() {
|
|
94
|
+
super.setupAttributes(), this.isShadowRoot = "open", this.setAttribute("active-class", "open");
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Removes the active attribute from the menu before drawing the MenuItem.
|
|
98
|
+
*/
|
|
99
|
+
beforeDraw(e, s, n) {
|
|
100
|
+
var t;
|
|
101
|
+
(t = this.querySelector("wje-menu")) == null || t.removeAttribute("active");
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Draws the MenuItem element.
|
|
105
|
+
*
|
|
106
|
+
* @param {Object} context - The context for drawing.
|
|
107
|
+
* @param {Object} store - The store for drawing.
|
|
108
|
+
* @param {Object} params - The parameters for drawing.
|
|
109
|
+
* @returns {DocumentFragment} The fragment to be appended to the MenuItem.
|
|
110
|
+
*/
|
|
111
|
+
draw(e, s, n) {
|
|
112
|
+
var f, w, g;
|
|
113
|
+
this.hasSubmenu = k.hasSlot(this, "submenu");
|
|
114
|
+
let t = document.createDocumentFragment();
|
|
115
|
+
this.setAttribute("tabindex", "0"), this.classList.forEach((a) => {
|
|
116
|
+
a.startsWith("wje-menu-variant-") && this.classList.remove(a);
|
|
117
|
+
}), this.classList.remove("collapse"), this.classList.add("wje-menu-variant-" + this.variant.toLowerCase()), this.collapse ? (w = this.parentElement) != null && w.hasAttribute("collapse") && this.classList.add("collapse") : (f = this.querySelector("wje-menu")) == null || f.setAttribute("variant", this.variant.toLowerCase());
|
|
118
|
+
let i = document.createElement("div");
|
|
119
|
+
i.setAttribute("part", "native"), i.setAttribute("id", "anchor"), i.classList.add("native-menu-item");
|
|
120
|
+
let u = document.createElement("span");
|
|
121
|
+
u.setAttribute("part", "check"), u.classList.add("check-icon"), u.innerHTML = '<wje-icon name="check"></wje-icon>', this.hasAttribute("checked") ? u.classList.add("checked") : u.classList.remove("checked");
|
|
122
|
+
let p = document.createElement("slot");
|
|
123
|
+
p.name = "start";
|
|
124
|
+
let b = document.createElement("slot");
|
|
125
|
+
b.classList.add("label");
|
|
126
|
+
let d = document.createElement("slot");
|
|
127
|
+
d.setAttribute("part", "end"), d.name = "end";
|
|
128
|
+
let m = document.createElement("slot");
|
|
129
|
+
m.setAttribute("part", "submenu"), m.name = "submenu";
|
|
130
|
+
let x = this.collapse ? "collapse" : "expand", h = document.createElement("span");
|
|
131
|
+
h.setAttribute("part", "submenu-icon"), h.classList.add("submenu-icon", x), h.innerHTML = this.collapse ? '<wje-icon name="chevron-down"></wje-icon>' : '<wje-icon name="chevron-right"></wje-icon>', this.hasSubmenu ? i.classList.add("has-submenu") : i.classList.remove("has-submenu"), i.appendChild(u), i.appendChild(p), i.appendChild(b), i.appendChild(d), i.appendChild(h);
|
|
132
|
+
let v = !1;
|
|
133
|
+
if (
|
|
134
|
+
/*(this.collapse && this.variant === "NAV" && this.hasSubmenu) || */
|
|
135
|
+
this.variant === "CONTEXT" && this.hasSubmenu
|
|
136
|
+
) {
|
|
137
|
+
i.setAttribute("slot", "anchor");
|
|
138
|
+
let a = document.createElement("wje-popup");
|
|
139
|
+
a.setAttribute("anchor", "anchor"), a.setAttribute("placement", this.placement), a.setAttribute("offset", this.offset), a.appendChild(i), a.appendChild(m), this.popup = a, t.appendChild(a), v = !0;
|
|
140
|
+
}
|
|
141
|
+
return (g = this.parentElement) != null && g.hasAttribute("collapse") && !this.hasSubmenu ? t.appendChild(this.collapseItem(i)) : v || t.appendChild(i), (!this.collapse && this.variant === "NAV" || this.variant === "MEGAMENU" && this.hasSubmenu) && t.appendChild(m), this.native = i, this.submenu = m, t;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Adds event listeners after drawing the MenuItem.
|
|
145
|
+
*/
|
|
146
|
+
afterDraw() {
|
|
147
|
+
this.addEventListener("mousemove", this.dispatchMove), this.addEventListener("wje-popup:reposition", this.dispatchReposition), l.addListener(this, "mouseenter", null, (e) => {
|
|
148
|
+
if (this.collapse || this.variant === "CONTEXT" && this.hasSubmenu) {
|
|
149
|
+
if (this.hasAttribute("manual") || this.variant === "NAV" && this.collapse)
|
|
150
|
+
return;
|
|
151
|
+
this.activateSubmenu(e), e.stopPropagation(), this.showSubmenu();
|
|
152
|
+
}
|
|
153
|
+
}), l.addListener(this, "mouseleave", null, this.shouldHideSubmenu), l.addListener(this, "focusout", null, this.shouldHideSubmenu), l.addListener(this, "click", null, (e) => {
|
|
154
|
+
!this.collapse && this.variant === "NAV" && this.hasSubmenu ? (this.submenuToggle(e), this.hideSubmenu(), e.stopPropagation()) : (l.dispatchCustomEvent(this, "wje-menu-item:click"), l.dispatchCustomEvent(this, this.dialog, {
|
|
155
|
+
bubbles: !0
|
|
156
|
+
}));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Creates a tooltip for the MenuItem when it is collapsed.
|
|
161
|
+
* @param {HTMLElement} native - The native MenuItem element.
|
|
162
|
+
* @returns {HTMLElement} The tooltip element.
|
|
163
|
+
*/
|
|
164
|
+
collapseItem(e) {
|
|
165
|
+
let s = document.createElement("slot");
|
|
166
|
+
s.setAttribute("slot", "start"), s.setAttribute("name", "tooltip-start");
|
|
167
|
+
let n = document.createElement("slot");
|
|
168
|
+
n.setAttribute("slot", "end"), n.setAttribute("name", "tooltip-end");
|
|
169
|
+
let t = document.createElement("wje-tooltip");
|
|
170
|
+
return t.setAttribute("content", this.getTextFromElement(this)), t.setAttribute("placement", "right"), t.setAttribute("offset", this.offset || "0"), t.appendChild(s), t.appendChild(n), t.appendChild(e), t;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Shows the submenu of the MenuItem.
|
|
174
|
+
*/
|
|
175
|
+
showSubmenu() {
|
|
176
|
+
this.tabIndex = -1, this.hasSubmenu && (this.popup.setAttribute("active", ""), this.classList.add("expanded-submenu"), this.native.classList.add("expanded-submenu"));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Hides the submenu of the MenuItem.
|
|
180
|
+
*/
|
|
181
|
+
hideSubmenu() {
|
|
182
|
+
this.tabIndex = 0, this.hasSubmenu && (this.popup.removeAttribute("active"), this.classList.remove("expanded-submenu"), this.native.classList.remove("expanded-submenu"));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Toggles the active state of the submenu element.
|
|
186
|
+
* If the submenu is not active, it sets the "active" attribute.
|
|
187
|
+
* If the submenu is already active, it removes the "active" attribute.
|
|
188
|
+
* @param {Event} e - The event object.
|
|
189
|
+
*/
|
|
190
|
+
submenuToggle(e) {
|
|
191
|
+
if (this.hasSubmenu) {
|
|
192
|
+
let s = this.submenu.assignedElements({ flatten: !0 })[0];
|
|
193
|
+
s.hasAttribute("active") ? this === e.target && s.removeAttribute("active") : s.setAttribute("active", "");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Deactivates the submenu by removing the "active" attribute.
|
|
198
|
+
*/
|
|
199
|
+
deactivateSubmenu() {
|
|
200
|
+
if (this.hasSubmenu) {
|
|
201
|
+
let e = this.submenu.assignedElements({ flatten: !0 })[0];
|
|
202
|
+
e.hasAttribute("active") && e.removeAttribute("active");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Activates the submenu of the menu item.
|
|
207
|
+
*/
|
|
208
|
+
activateSubmenu() {
|
|
209
|
+
if (this.hasSubmenu) {
|
|
210
|
+
let e = this.submenu.assignedElements({ flatten: !0 })[0];
|
|
211
|
+
e.hasAttribute("active") || e.setAttribute("active", "");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Clears the innerHTML of the context before disconnecting the MenuItem.
|
|
216
|
+
*/
|
|
217
|
+
beforeDisconnect() {
|
|
218
|
+
this.context.innerHTML = "";
|
|
219
|
+
}
|
|
220
|
+
getTextFromElement(e) {
|
|
221
|
+
let s = "";
|
|
222
|
+
for (let n of e.childNodes)
|
|
223
|
+
n.nodeType === Node.TEXT_NODE && (s += n.textContent);
|
|
224
|
+
return s.trim();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
j.define("wje-menu-item", j);
|
|
228
|
+
export {
|
|
229
|
+
j as default
|
|
230
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var o = Object.defineProperty;
|
|
2
|
+
var i = (t, e, a) => e in t ? o(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
|
|
3
|
+
var s = (t, e, a) => (i(t, typeof e != "symbol" ? e + "" : e, a), a);
|
|
4
|
+
import d, { WjElementUtils as m } from "./wje-element.js";
|
|
5
|
+
const u = ":host{--wje-letter-spacing: .025rem;--wje-menu-label-color: var(--wje-color-contrast-6);--wje-padding-top: 0;--wje-padding-bottom: 0;--wje-padding-start: 1.5rem;--wje-padding-end: 1.5rem}.native-menu-label{font-size:var(--wje-menu-label-font-size);display:inline-block;font-weight:var(--wje-menu-label-weight);letter-spacing:var(--wje-letter-spacing);color:var(--wje-menu-label-color);padding:var(--wje-padding-top) var(--wje-padding-start) var(--wje-padding-bottom) var(--wje-padding-end)}";
|
|
6
|
+
class l extends d {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of MenuLabel.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
s(this, "className", "MenuLabel");
|
|
15
|
+
this.hasSubmenu = m.hasSlot(this, "submenu");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the CSS styles for the component.
|
|
19
|
+
*
|
|
20
|
+
* @static
|
|
21
|
+
* @returns {CSSStyleSheet}
|
|
22
|
+
*/
|
|
23
|
+
static get cssStyleSheet() {
|
|
24
|
+
return u;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the list of attributes to observe for changes.
|
|
28
|
+
*
|
|
29
|
+
* @static
|
|
30
|
+
* @returns {Array<string>}
|
|
31
|
+
*/
|
|
32
|
+
static get observedAttributes() {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets up the attributes for the component.
|
|
37
|
+
*/
|
|
38
|
+
setupAttributes() {
|
|
39
|
+
this.isShadowRoot = "open";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Draws the component.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} context - The context for drawing.
|
|
45
|
+
* @param {Object} store - The store for drawing.
|
|
46
|
+
* @param {Object} params - The parameters for drawing.
|
|
47
|
+
* @returns {DocumentFragment}
|
|
48
|
+
*/
|
|
49
|
+
draw(a, c, p) {
|
|
50
|
+
let r = document.createDocumentFragment(), n = document.createElement("slot");
|
|
51
|
+
return n.setAttribute("part", "native"), n.classList.add("native-menu-label"), r.appendChild(n), r;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
l.define("wje-menu-label", l);
|
|
55
|
+
export {
|
|
56
|
+
l as default
|
|
57
|
+
};
|
package/dist/wje-menu.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var m = (n, t, e) => t in n ? d(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var o = (n, t, e) => (m(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import l from "./wje-element.js";
|
|
5
|
+
const u = ":host{display:none;background:var(--wje-menu-background);position:relative;border-width:var(--wje-menu-border-width);border-style:var(--wje-menu-border-style);border-color:var(--wje-menu-border-color);z-index:var(--wje-menu-z-index, 8);box-shadow:var(--wje-menu-shadow);border-radius:var(--wje-menu-border-radius);padding-top:var(--wje-menu-padding-top);padding-bottom:var(--wje-menu-padding-bottom);padding-inline:var(--wje-menu-padding-inline);margin-top:var(--wje-menu-margin-top);margin-bottom:var(--wje-menu-margin-bottom);margin-inline:var(--wje-menu-margin-inline);overflow:auto;overscroll-behavior:none}:host .native-menu{display:flex;flex-direction:column;width:100%}:host .native-menu ::slotted(wje-button){margin:0}:host(.wje-menu-collapse){width:var(--wje-menu-collapse-width)}:host([collapse]){box-shadow:none}:host([variant=context]){display:block!important;margin-left:var(--wje-menu-submenu-offset)}:host([variant=megamenu]) .native-menu{flex-direction:row;align-items:end;flex-wrap:nowrap}:host([variant=megamenu]) .native-menu .check-icon{display:none}:host([active]){display:flex!important}";
|
|
6
|
+
class i extends l {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of Menu.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
o(this, "className", "Menu");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the CSS styles for the component.
|
|
18
|
+
*
|
|
19
|
+
* @static
|
|
20
|
+
* @returns {CSSStyleSheet}
|
|
21
|
+
*/
|
|
22
|
+
static get cssStyleSheet() {
|
|
23
|
+
return u;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the list of attributes to observe for changes.
|
|
27
|
+
*
|
|
28
|
+
* @static
|
|
29
|
+
* @returns {Array<string>}
|
|
30
|
+
*/
|
|
31
|
+
static get observedAttributes() {
|
|
32
|
+
return ["active", "collapse"];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets up the attributes for the component.
|
|
36
|
+
*/
|
|
37
|
+
setupAttributes() {
|
|
38
|
+
this.isShadowRoot = "open";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Draws the component.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} context - The context for drawing.
|
|
44
|
+
* @param {Object} store - The store for drawing.
|
|
45
|
+
* @param {Object} params - The parameters for drawing.
|
|
46
|
+
* @returns {DocumentFragment}
|
|
47
|
+
*/
|
|
48
|
+
draw(e, c, p) {
|
|
49
|
+
let r = document.createDocumentFragment();
|
|
50
|
+
this.classList.remove("wje-menu-collapse"), this.hasAttribute("collapse") && this.classList.add("wje-menu-collapse");
|
|
51
|
+
let a = document.createElement("div");
|
|
52
|
+
a.setAttribute("part", "native"), a.classList.add("native-menu");
|
|
53
|
+
let s = document.createElement("slot");
|
|
54
|
+
return a.appendChild(s), r.appendChild(a), r;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Refreshes the component after drawing.
|
|
58
|
+
*/
|
|
59
|
+
afterDraw() {
|
|
60
|
+
Array.from(this.children).forEach((e) => {
|
|
61
|
+
e.tagName.includes("-") && e.refresh();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Cleans up the component before disconnecting.
|
|
66
|
+
*/
|
|
67
|
+
beforeDisconnect() {
|
|
68
|
+
this.context.innerHTML = "";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
i.define("wje-menu", i);
|
|
72
|
+
export {
|
|
73
|
+
i as default
|
|
74
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var m = (n, t, e) => t in n ? p(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var o = (n, t, e) => (m(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import u, { event as h } from "./wje-element.js";
|
|
5
|
+
import g from "./wje-icon.js";
|
|
6
|
+
const b = ':host{display:block}:host wje-icon{visibility:hidden;margin-inline:.5rem}:host([selected]) wje-icon{visibility:visible}.native-option{display:flex;align-items:center;padding-top:var(--wje-option-padding-top);padding-bottom:var(--wje-option-padding-bottom)}.native-option:hover{background-color:var(--wje-option-highlighted)}::slotted([slot="start"]){flex:0 0 auto;display:flex;align-items:center;margin-inline-end:.5rem}::slotted([slot="end"]){flex:0 0 auto;display:flex;align-items:center;margin-inline:auto .5rem}';
|
|
7
|
+
class d extends u {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of Option.
|
|
10
|
+
*
|
|
11
|
+
* @constructor
|
|
12
|
+
*/
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
/**
|
|
16
|
+
* Dependencies of the Option component.
|
|
17
|
+
*/
|
|
18
|
+
o(this, "depandencies", {
|
|
19
|
+
"wje-icon": g
|
|
20
|
+
});
|
|
21
|
+
o(this, "className", "Option");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Sets the selected attribute of the option.
|
|
25
|
+
*
|
|
26
|
+
* @param {boolean} value - The value to set.
|
|
27
|
+
*/
|
|
28
|
+
set selected(e) {
|
|
29
|
+
return e ? this.setAttribute("selected", "") : this.removeAttribute("selected");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Sets the value attribute of the option.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} value - The value to set.
|
|
35
|
+
*/
|
|
36
|
+
set value(e) {
|
|
37
|
+
this.setAttribute("value", e);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Sets the text content of the option.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} value - The text to set.
|
|
43
|
+
*/
|
|
44
|
+
set text(e) {
|
|
45
|
+
this.innerText = e;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the CSS styles for the component.
|
|
49
|
+
*
|
|
50
|
+
* @static
|
|
51
|
+
* @returns {CSSStyleSheet}
|
|
52
|
+
*/
|
|
53
|
+
static get cssStyleSheet() {
|
|
54
|
+
return b;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns the list of attributes to observe for changes.
|
|
58
|
+
*
|
|
59
|
+
* @static
|
|
60
|
+
* @returns {Array<string>}
|
|
61
|
+
*/
|
|
62
|
+
static get observedAttributes() {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sets up the attributes for the component.
|
|
67
|
+
*/
|
|
68
|
+
setupAttributes() {
|
|
69
|
+
this.isShadowRoot = "open";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Draws the component.
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} context - The context for drawing.
|
|
75
|
+
* @param {Object} store - The store for drawing.
|
|
76
|
+
* @param {Object} params - The parameters for drawing.
|
|
77
|
+
* @returns {DocumentFragment}
|
|
78
|
+
*/
|
|
79
|
+
draw(e, v, w) {
|
|
80
|
+
let s = document.createDocumentFragment(), i = document.createElement("div");
|
|
81
|
+
i.classList.add("native-option"), i.setAttribute("part", "native");
|
|
82
|
+
let a = document.createElement("wje-icon");
|
|
83
|
+
a.setAttribute("name", "check");
|
|
84
|
+
let r = document.createElement("slot");
|
|
85
|
+
r.setAttribute("name", "start");
|
|
86
|
+
let c = document.createElement("slot"), l = document.createElement("slot");
|
|
87
|
+
return l.setAttribute("name", "end"), i.appendChild(a), i.appendChild(r), i.appendChild(c), i.appendChild(l), s.appendChild(i), s;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Adds event listeners after the component is drawn.
|
|
91
|
+
*/
|
|
92
|
+
afterDraw() {
|
|
93
|
+
h.addListener(this, "click", "wje:option-change");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
d.define("wje-option", d);
|
|
97
|
+
export {
|
|
98
|
+
d as default
|
|
99
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var c = (o, e, t) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var a = (o, e, t) => (c(o, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import d, { event as u } from "./wje-element.js";
|
|
5
|
+
import h from "./wje-option.js";
|
|
6
|
+
class r extends d {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of Options.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
a(this, "depandencies", {
|
|
15
|
+
"wje-option": h
|
|
16
|
+
});
|
|
17
|
+
a(this, "className", "Options");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the list of attributes to observe for changes.
|
|
21
|
+
*
|
|
22
|
+
* @static
|
|
23
|
+
* @returns {Array<string>}
|
|
24
|
+
*/
|
|
25
|
+
static get observedAttributes() {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sets up the attributes for the component.
|
|
30
|
+
*/
|
|
31
|
+
setupAttributes() {
|
|
32
|
+
this.isShadowRoot = "open";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Prepares the component before drawing.
|
|
36
|
+
* Fetches the pages and creates the options elements.
|
|
37
|
+
*/
|
|
38
|
+
async beforeDraw() {
|
|
39
|
+
this.response = await this.getPages();
|
|
40
|
+
let t = document.createDocumentFragment();
|
|
41
|
+
this.response.forEach((s, i) => {
|
|
42
|
+
let n = document.createElement("wje-option");
|
|
43
|
+
n.setAttribute("value", s[this.itemValue] || s.value), n.innerText = s[this.itemText] || s.text, t.appendChild(n);
|
|
44
|
+
}), this.parentElement.appendChild(t), u.dispatchCustomEvent(this, "wje-options:load", {});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fetches the pages from the provided URL.
|
|
48
|
+
*
|
|
49
|
+
* @param {number} page - The page number to fetch.
|
|
50
|
+
* @returns {Promise<Object>} The fetched data.
|
|
51
|
+
* @throws Will throw an error if the response is not ok.
|
|
52
|
+
*/
|
|
53
|
+
async getPages(t) {
|
|
54
|
+
const s = await fetch(this.url);
|
|
55
|
+
if (!s.ok)
|
|
56
|
+
throw new Error(`An error occurred: ${s.status}`);
|
|
57
|
+
return await s.json();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
r.define("wje-options", r);
|
|
61
|
+
export {
|
|
62
|
+
r as default
|
|
63
|
+
};
|