@waggylabs/yumekit 0.2.1 → 0.2.3
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/components/y-appbar.d.ts +21 -0
- package/dist/components/y-appbar.js +310 -22
- package/dist/components/y-badge.d.ts +5 -0
- package/dist/components/y-badge.js +5 -0
- package/dist/components/y-button.d.ts +6 -1
- package/dist/components/y-button.js +5 -0
- package/dist/components/y-checkbox.d.ts +7 -1
- package/dist/components/y-checkbox.js +6 -0
- package/dist/components/y-dialog.d.ts +7 -0
- package/dist/components/y-dialog.js +14 -24
- package/dist/components/y-drawer.js +1 -2
- package/dist/components/y-icon.d.ts +5 -0
- package/dist/components/y-icon.js +16 -8
- package/dist/components/y-input.d.ts +5 -0
- package/dist/components/y-input.js +6 -0
- package/dist/components/y-menu.d.ts +1 -0
- package/dist/components/y-menu.js +28 -1
- package/dist/components/y-panel.d.ts +10 -1
- package/dist/components/y-panel.js +21 -0
- package/dist/components/y-progress.d.ts +11 -0
- package/dist/components/y-progress.js +14 -0
- package/dist/components/y-radio.d.ts +11 -2
- package/dist/components/y-radio.js +3 -0
- package/dist/components/y-select.d.ts +19 -5
- package/dist/components/y-select.js +19 -0
- package/dist/components/y-slider.d.ts +11 -2
- package/dist/components/y-slider.js +10 -0
- package/dist/components/y-switch.d.ts +3 -0
- package/dist/components/y-switch.js +8 -2
- package/dist/components/y-table.d.ts +3 -0
- package/dist/components/y-table.js +4 -1
- package/dist/components/y-tabs.d.ts +14 -7
- package/dist/components/y-tabs.js +9 -0
- package/dist/components/y-theme.d.ts +6 -1
- package/dist/components/y-theme.js +10 -3
- package/dist/components/y-toast.d.ts +4 -0
- package/dist/components/y-toast.js +7 -0
- package/dist/components/y-tooltip.d.ts +6 -0
- package/dist/components/y-tooltip.js +8 -0
- package/dist/icons/all.js +3 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/index.js +458 -54
- package/dist/styles/variables.css +7 -4
- package/dist/yumekit.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export class YumeAppbar extends HTMLElement {
|
|
2
2
|
static get observedAttributes(): string[];
|
|
3
3
|
_onCollapseClick(): void;
|
|
4
|
+
_onMediaChange(e: any): void;
|
|
4
5
|
_idCounter: number;
|
|
6
|
+
_mql: MediaQueryList;
|
|
7
|
+
_isMobile: boolean;
|
|
5
8
|
connectedCallback(): void;
|
|
6
9
|
disconnectedCallback(): void;
|
|
7
10
|
attributeChangedCallback(name: any, oldVal: any, newVal: any): void;
|
|
@@ -21,8 +24,26 @@ export class YumeAppbar extends HTMLElement {
|
|
|
21
24
|
get menuDirection(): string;
|
|
22
25
|
set sticky(val: string | false);
|
|
23
26
|
get sticky(): string | false;
|
|
27
|
+
set mobileBreakpoint(val: string);
|
|
28
|
+
/**
|
|
29
|
+
* Override the mobile breakpoint (in pixels) for this instance.
|
|
30
|
+
* Falls back to the CSS variable --component-appbar-mobile-breakpoint (default 768).
|
|
31
|
+
*/
|
|
32
|
+
get mobileBreakpoint(): string;
|
|
33
|
+
/** Whether the appbar is currently rendering in mobile mode. */
|
|
34
|
+
get mobile(): boolean;
|
|
24
35
|
toggle(): void;
|
|
25
36
|
_uid(prefix: any): string;
|
|
26
37
|
_isItemActive(item: any): boolean;
|
|
38
|
+
_getBreakpointPx(): number;
|
|
39
|
+
_setupMediaQuery(): void;
|
|
40
|
+
_teardownMediaQuery(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Convert appbar nav items to y-menu item format.
|
|
43
|
+
* Maps `href` → `url` and recursively converts children.
|
|
44
|
+
*/
|
|
45
|
+
_toMenuItems(items: any): any;
|
|
27
46
|
render(): void;
|
|
47
|
+
_renderMobile(): void;
|
|
48
|
+
_renderDesktop(): void;
|
|
28
49
|
}
|
|
@@ -57,6 +57,7 @@ class YumeButton extends HTMLElement {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/** The current selected value(s), comma-separated when 'multiple' is set. */
|
|
60
61
|
get value() {
|
|
61
62
|
if (this.hasAttribute("multiple")) {
|
|
62
63
|
return Array.from(this.selectedValues).join(",");
|
|
@@ -87,6 +88,10 @@ class YumeButton extends HTMLElement {
|
|
|
87
88
|
this.setAttribute("value", newVal);
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Sets the button options from an array of objects.
|
|
93
|
+
* @param {Array<Object>} options
|
|
94
|
+
*/
|
|
90
95
|
setOptions(options) {
|
|
91
96
|
this.setAttribute("options", JSON.stringify(options));
|
|
92
97
|
}
|
|
@@ -664,7 +669,6 @@ function sanitizeSvg(raw) {
|
|
|
664
669
|
}
|
|
665
670
|
};
|
|
666
671
|
|
|
667
|
-
// Sanitize the <svg> element's own attributes
|
|
668
672
|
for (const attr of [...svg.attributes]) {
|
|
669
673
|
if (!ALLOWED_ATTRS.has(attr.name.toLowerCase())) {
|
|
670
674
|
svg.removeAttribute(attr.name);
|
|
@@ -706,6 +710,7 @@ class YumeIcon extends HTMLElement {
|
|
|
706
710
|
this.render();
|
|
707
711
|
}
|
|
708
712
|
|
|
713
|
+
/** The registered icon name to display. */
|
|
709
714
|
get name() {
|
|
710
715
|
return this.getAttribute("name") || "";
|
|
711
716
|
}
|
|
@@ -713,6 +718,7 @@ class YumeIcon extends HTMLElement {
|
|
|
713
718
|
this.setAttribute("name", val);
|
|
714
719
|
}
|
|
715
720
|
|
|
721
|
+
/** Icon size: "small" | "medium" | "large" (default "medium"). */
|
|
716
722
|
get size() {
|
|
717
723
|
return this.getAttribute("size") || "medium";
|
|
718
724
|
}
|
|
@@ -720,6 +726,7 @@ class YumeIcon extends HTMLElement {
|
|
|
720
726
|
this.setAttribute("size", val);
|
|
721
727
|
}
|
|
722
728
|
|
|
729
|
+
/** Color theme: "base" | "primary" | "secondary" | "success" | "warning" | "error" | "help". */
|
|
723
730
|
get color() {
|
|
724
731
|
return this.getAttribute("color") || "";
|
|
725
732
|
}
|
|
@@ -728,6 +735,7 @@ class YumeIcon extends HTMLElement {
|
|
|
728
735
|
else this.removeAttribute("color");
|
|
729
736
|
}
|
|
730
737
|
|
|
738
|
+
/** Accessible label for the icon. When set, the icon gets role="img". */
|
|
731
739
|
get label() {
|
|
732
740
|
return this.getAttribute("label") || "";
|
|
733
741
|
}
|
|
@@ -736,8 +744,9 @@ class YumeIcon extends HTMLElement {
|
|
|
736
744
|
else this.removeAttribute("label");
|
|
737
745
|
}
|
|
738
746
|
|
|
747
|
+
/** Stroke weight: "thin" | "regular" | "thick". */
|
|
739
748
|
get weight() {
|
|
740
|
-
return this.getAttribute("weight") || "";
|
|
749
|
+
return this.getAttribute("weight") || "regular";
|
|
741
750
|
}
|
|
742
751
|
set weight(val) {
|
|
743
752
|
if (val) this.setAttribute("weight", val);
|
|
@@ -759,18 +768,22 @@ class YumeIcon extends HTMLElement {
|
|
|
759
768
|
|
|
760
769
|
_getSize(size) {
|
|
761
770
|
const map = {
|
|
762
|
-
small: "var(--component-icon-size-small,
|
|
763
|
-
|
|
764
|
-
|
|
771
|
+
"x-small": "var(--component-icon-size-x-small, 10px)",
|
|
772
|
+
small: "var(--component-icon-size-small, 14px)",
|
|
773
|
+
medium: "var(--component-icon-size-medium, 18px)",
|
|
774
|
+
large: "var(--component-icon-size-large, 22px)",
|
|
775
|
+
"x-large": "var(--component-icon-size-x-large, 28px)",
|
|
765
776
|
};
|
|
766
777
|
return map[size] || map.medium;
|
|
767
778
|
}
|
|
768
779
|
|
|
769
780
|
_getWeight(weight) {
|
|
770
781
|
const map = {
|
|
771
|
-
thin: "1",
|
|
772
|
-
|
|
773
|
-
|
|
782
|
+
"x-thin": "1",
|
|
783
|
+
thin: "1.5",
|
|
784
|
+
regular: "2",
|
|
785
|
+
thick: "2.5",
|
|
786
|
+
"x-thick": "3",
|
|
774
787
|
};
|
|
775
788
|
return map[weight] || "";
|
|
776
789
|
}
|
|
@@ -838,11 +851,14 @@ class YumeMenu extends HTMLElement {
|
|
|
838
851
|
|
|
839
852
|
connectedCallback() {
|
|
840
853
|
if (!this.hasAttribute("items")) this.items = [];
|
|
854
|
+
|
|
841
855
|
this._setupAnchor();
|
|
842
856
|
this.render();
|
|
857
|
+
|
|
843
858
|
document.addEventListener("click", this._onDocumentClick);
|
|
844
859
|
window.addEventListener("scroll", this._onScrollOrResize, true);
|
|
845
860
|
window.addEventListener("resize", this._onScrollOrResize);
|
|
861
|
+
|
|
846
862
|
this.style.position = "fixed";
|
|
847
863
|
this.style.zIndex = "1000";
|
|
848
864
|
this.style.display = "none";
|
|
@@ -850,6 +866,7 @@ class YumeMenu extends HTMLElement {
|
|
|
850
866
|
|
|
851
867
|
disconnectedCallback() {
|
|
852
868
|
this._teardownAnchor();
|
|
869
|
+
|
|
853
870
|
document.removeEventListener("click", this._onDocumentClick);
|
|
854
871
|
window.removeEventListener("scroll", this._onScrollOrResize, true);
|
|
855
872
|
window.removeEventListener("resize", this._onScrollOrResize);
|
|
@@ -857,14 +874,18 @@ class YumeMenu extends HTMLElement {
|
|
|
857
874
|
|
|
858
875
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
859
876
|
if (oldVal === newVal) return;
|
|
877
|
+
|
|
860
878
|
if (name === "items" || name === "size") this.render();
|
|
879
|
+
|
|
861
880
|
if (name === "anchor") {
|
|
862
881
|
this._teardownAnchor();
|
|
863
882
|
this._setupAnchor();
|
|
864
883
|
}
|
|
884
|
+
|
|
865
885
|
if (name === "visible") {
|
|
866
886
|
this._updatePosition();
|
|
867
887
|
}
|
|
888
|
+
|
|
868
889
|
if (name === "direction") {
|
|
869
890
|
this._updatePosition();
|
|
870
891
|
}
|
|
@@ -975,9 +996,20 @@ class YumeMenu extends HTMLElement {
|
|
|
975
996
|
|
|
976
997
|
_onAnchorClick(e) {
|
|
977
998
|
e.stopPropagation();
|
|
999
|
+
if (!this.visible) {
|
|
1000
|
+
YumeMenu._closeAll(this);
|
|
1001
|
+
}
|
|
978
1002
|
this.visible = !this.visible;
|
|
979
1003
|
}
|
|
980
1004
|
|
|
1005
|
+
static _closeAll(except) {
|
|
1006
|
+
document.querySelectorAll("y-menu").forEach((menu) => {
|
|
1007
|
+
if (menu !== except && menu.visible) {
|
|
1008
|
+
menu.visible = false;
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
|
|
981
1013
|
_onDocumentClick(e) {
|
|
982
1014
|
const path = e.composedPath();
|
|
983
1015
|
if (this._anchorEl && path.includes(this._anchorEl)) return;
|
|
@@ -1017,7 +1049,13 @@ class YumeMenu extends HTMLElement {
|
|
|
1017
1049
|
}
|
|
1018
1050
|
|
|
1019
1051
|
const anchorRect = this._anchorEl.getBoundingClientRect();
|
|
1052
|
+
|
|
1053
|
+
// Temporarily show off-screen to measure actual dimensions
|
|
1054
|
+
this.style.visibility = "hidden";
|
|
1055
|
+
this.style.display = "block";
|
|
1020
1056
|
const menuRect = this.getBoundingClientRect();
|
|
1057
|
+
this.style.visibility = "";
|
|
1058
|
+
|
|
1021
1059
|
const vw = window.innerWidth;
|
|
1022
1060
|
const vh = window.innerHeight;
|
|
1023
1061
|
|
|
@@ -1078,8 +1116,8 @@ class YumeMenu extends HTMLElement {
|
|
|
1078
1116
|
this.shadowRoot.innerHTML = "";
|
|
1079
1117
|
|
|
1080
1118
|
const paddingVar = `var(--component-button-padding-${this.size}, 0.5rem)`;
|
|
1081
|
-
|
|
1082
1119
|
const style = document.createElement("style");
|
|
1120
|
+
|
|
1083
1121
|
style.textContent = `
|
|
1084
1122
|
ul.menu,
|
|
1085
1123
|
ul.submenu {
|
|
@@ -1132,12 +1170,14 @@ class YumeMenu extends HTMLElement {
|
|
|
1132
1170
|
flex: 1;
|
|
1133
1171
|
}
|
|
1134
1172
|
`;
|
|
1173
|
+
|
|
1135
1174
|
this.shadowRoot.appendChild(style);
|
|
1136
1175
|
|
|
1137
1176
|
const rootUl = this._createMenuList(this.items);
|
|
1138
1177
|
rootUl.classList.add("menu");
|
|
1139
1178
|
rootUl.setAttribute("role", "menu");
|
|
1140
1179
|
rootUl.setAttribute("part", "menu");
|
|
1180
|
+
|
|
1141
1181
|
this.shadowRoot.appendChild(rootUl);
|
|
1142
1182
|
}
|
|
1143
1183
|
}
|
|
@@ -1167,6 +1207,10 @@ const collapseLeft = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height=
|
|
|
1167
1207
|
|
|
1168
1208
|
const expandRight = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="13 17 18 12 13 7"/><polyline points="6 17 11 12 6 7"/></svg>`;
|
|
1169
1209
|
|
|
1210
|
+
/* ── Menu (hamburger) ────────────────────────────────────────────── */
|
|
1211
|
+
|
|
1212
|
+
const menu = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>`;
|
|
1213
|
+
|
|
1170
1214
|
class YumeAppbar extends HTMLElement {
|
|
1171
1215
|
static get observedAttributes() {
|
|
1172
1216
|
return [
|
|
@@ -1176,6 +1220,7 @@ class YumeAppbar extends HTMLElement {
|
|
|
1176
1220
|
"size",
|
|
1177
1221
|
"menu-direction",
|
|
1178
1222
|
"sticky",
|
|
1223
|
+
"mobile-breakpoint",
|
|
1179
1224
|
];
|
|
1180
1225
|
}
|
|
1181
1226
|
|
|
@@ -1183,17 +1228,26 @@ class YumeAppbar extends HTMLElement {
|
|
|
1183
1228
|
super();
|
|
1184
1229
|
this.attachShadow({ mode: "open" });
|
|
1185
1230
|
this._onCollapseClick = this._onCollapseClick.bind(this);
|
|
1231
|
+
this._onMediaChange = this._onMediaChange.bind(this);
|
|
1186
1232
|
this._idCounter = 0;
|
|
1233
|
+
this._mql = null;
|
|
1234
|
+
this._isMobile = false;
|
|
1187
1235
|
}
|
|
1188
1236
|
|
|
1189
1237
|
connectedCallback() {
|
|
1238
|
+
this._setupMediaQuery();
|
|
1190
1239
|
this.render();
|
|
1191
1240
|
}
|
|
1192
1241
|
|
|
1193
|
-
disconnectedCallback() {
|
|
1242
|
+
disconnectedCallback() {
|
|
1243
|
+
this._teardownMediaQuery();
|
|
1244
|
+
}
|
|
1194
1245
|
|
|
1195
1246
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
1196
1247
|
if (oldVal === newVal) return;
|
|
1248
|
+
if (name === "mobile-breakpoint" || name === "orientation") {
|
|
1249
|
+
this._setupMediaQuery();
|
|
1250
|
+
}
|
|
1197
1251
|
this.render();
|
|
1198
1252
|
}
|
|
1199
1253
|
|
|
@@ -1251,6 +1305,23 @@ class YumeAppbar extends HTMLElement {
|
|
|
1251
1305
|
else this.removeAttribute("sticky");
|
|
1252
1306
|
}
|
|
1253
1307
|
|
|
1308
|
+
/**
|
|
1309
|
+
* Override the mobile breakpoint (in pixels) for this instance.
|
|
1310
|
+
* Falls back to the CSS variable --component-appbar-mobile-breakpoint (default 768).
|
|
1311
|
+
*/
|
|
1312
|
+
get mobileBreakpoint() {
|
|
1313
|
+
return this.getAttribute("mobile-breakpoint") || "";
|
|
1314
|
+
}
|
|
1315
|
+
set mobileBreakpoint(val) {
|
|
1316
|
+
if (val) this.setAttribute("mobile-breakpoint", val);
|
|
1317
|
+
else this.removeAttribute("mobile-breakpoint");
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
/** Whether the appbar is currently rendering in mobile mode. */
|
|
1321
|
+
get mobile() {
|
|
1322
|
+
return this._isMobile;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1254
1325
|
toggle() {
|
|
1255
1326
|
this.collapsed = !this.collapsed;
|
|
1256
1327
|
}
|
|
@@ -1273,7 +1344,228 @@ class YumeAppbar extends HTMLElement {
|
|
|
1273
1344
|
return false;
|
|
1274
1345
|
}
|
|
1275
1346
|
|
|
1347
|
+
_getBreakpointPx() {
|
|
1348
|
+
const attr = this.mobileBreakpoint;
|
|
1349
|
+
if (attr) {
|
|
1350
|
+
const px = parseInt(attr, 10);
|
|
1351
|
+
if (!isNaN(px) && px > 0) return px;
|
|
1352
|
+
}
|
|
1353
|
+
const cssVal = getComputedStyle(document.documentElement)
|
|
1354
|
+
.getPropertyValue("--component-appbar-mobile-breakpoint")
|
|
1355
|
+
.trim();
|
|
1356
|
+
if (cssVal) {
|
|
1357
|
+
const px = parseInt(cssVal, 10);
|
|
1358
|
+
if (!isNaN(px) && px > 0) return px;
|
|
1359
|
+
}
|
|
1360
|
+
return 768;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
_setupMediaQuery() {
|
|
1364
|
+
this._teardownMediaQuery();
|
|
1365
|
+
if (this.orientation !== "horizontal") {
|
|
1366
|
+
this._isMobile = false;
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
const bp = this._getBreakpointPx();
|
|
1370
|
+
this._mql = window.matchMedia(`(max-width: ${bp}px)`);
|
|
1371
|
+
this._isMobile = this._mql.matches;
|
|
1372
|
+
this._mql.addEventListener("change", this._onMediaChange);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
_teardownMediaQuery() {
|
|
1376
|
+
if (this._mql) {
|
|
1377
|
+
this._mql.removeEventListener("change", this._onMediaChange);
|
|
1378
|
+
this._mql = null;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
_onMediaChange(e) {
|
|
1383
|
+
this._isMobile = e.matches;
|
|
1384
|
+
this.render();
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Convert appbar nav items to y-menu item format.
|
|
1389
|
+
* Maps `href` → `url` and recursively converts children.
|
|
1390
|
+
*/
|
|
1391
|
+
_toMenuItems(items) {
|
|
1392
|
+
return items.map((item) => {
|
|
1393
|
+
const mi = { text: item.text || "" };
|
|
1394
|
+
if (item.href) mi.url = item.href;
|
|
1395
|
+
if (item.icon) mi.icon = item.icon;
|
|
1396
|
+
if (item.children?.length) {
|
|
1397
|
+
mi.children = this._toMenuItems(item.children);
|
|
1398
|
+
}
|
|
1399
|
+
return mi;
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1276
1403
|
render() {
|
|
1404
|
+
if (this._isMobile) {
|
|
1405
|
+
this._renderMobile();
|
|
1406
|
+
} else {
|
|
1407
|
+
this._renderDesktop();
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
_renderMobile() {
|
|
1412
|
+
const size = this.size;
|
|
1413
|
+
|
|
1414
|
+
const sizeConfig = {
|
|
1415
|
+
small: {
|
|
1416
|
+
padding: "var(--spacing-x-small, 4px)",
|
|
1417
|
+
buttonSize: "small",
|
|
1418
|
+
iconSize: "small",
|
|
1419
|
+
},
|
|
1420
|
+
medium: {
|
|
1421
|
+
padding: "var(--spacing-small, 6px)",
|
|
1422
|
+
buttonSize: "medium",
|
|
1423
|
+
iconSize: "medium",
|
|
1424
|
+
},
|
|
1425
|
+
large: {
|
|
1426
|
+
padding: "var(--spacing-medium, 8px)",
|
|
1427
|
+
buttonSize: "large",
|
|
1428
|
+
iconSize: "large",
|
|
1429
|
+
},
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
this.shadowRoot.innerHTML = "";
|
|
1433
|
+
this._idCounter = 0;
|
|
1434
|
+
|
|
1435
|
+
const cfg = sizeConfig[size] || sizeConfig.medium;
|
|
1436
|
+
const style = document.createElement("style");
|
|
1437
|
+
|
|
1438
|
+
style.textContent = `
|
|
1439
|
+
:host {
|
|
1440
|
+
display: block;
|
|
1441
|
+
font-family: var(--font-family-body, sans-serif);
|
|
1442
|
+
color: var(--component-appbar-color, #f7f7fa);
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
:host([sticky]),
|
|
1446
|
+
:host([sticky="start"]),
|
|
1447
|
+
:host([sticky="end"]) {
|
|
1448
|
+
position: sticky;
|
|
1449
|
+
top: 0;
|
|
1450
|
+
left: 0;
|
|
1451
|
+
width: 100%;
|
|
1452
|
+
z-index: var(--component-appbar-z-index, 100);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
:host([sticky]) .appbar {
|
|
1456
|
+
border-radius: 0;
|
|
1457
|
+
border: none;
|
|
1458
|
+
border-bottom: var(--component-appbar-border-width, var(--component-sidebar-border-width, 2px)) solid var(--component-appbar-border-color, #37383a);
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
.appbar {
|
|
1462
|
+
display: flex;
|
|
1463
|
+
flex-direction: row;
|
|
1464
|
+
align-items: center;
|
|
1465
|
+
background: var(--component-appbar-background, #0c0c0d);
|
|
1466
|
+
border: var(--component-appbar-border-width, var(--component-sidebar-border-width, 2px)) solid var(--component-appbar-border-color, #37383a);
|
|
1467
|
+
border-radius: var(--component-appbar-border-radius, var(--component-sidebar-border-radius, 4px));
|
|
1468
|
+
overflow: visible;
|
|
1469
|
+
padding: var(--_appbar-padding);
|
|
1470
|
+
box-sizing: border-box;
|
|
1471
|
+
width: 100%;
|
|
1472
|
+
height: auto;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
.mobile-start {
|
|
1476
|
+
display: flex;
|
|
1477
|
+
align-items: center;
|
|
1478
|
+
flex-shrink: 0;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
.mobile-center {
|
|
1482
|
+
flex: 1;
|
|
1483
|
+
display: flex;
|
|
1484
|
+
justify-content: center;
|
|
1485
|
+
align-items: center;
|
|
1486
|
+
overflow: hidden;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
.mobile-end {
|
|
1490
|
+
display: flex;
|
|
1491
|
+
align-items: center;
|
|
1492
|
+
flex-shrink: 0;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
.mobile-end ::slotted(*) {
|
|
1496
|
+
display: block;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
::slotted(*) {
|
|
1500
|
+
display: block;
|
|
1501
|
+
}
|
|
1502
|
+
`;
|
|
1503
|
+
this.shadowRoot.appendChild(style);
|
|
1504
|
+
|
|
1505
|
+
const bar = document.createElement("div");
|
|
1506
|
+
bar.className = "appbar";
|
|
1507
|
+
bar.setAttribute("role", "navigation");
|
|
1508
|
+
bar.style.setProperty("--_appbar-padding", cfg.padding);
|
|
1509
|
+
|
|
1510
|
+
/* ── Left: hamburger button ── */
|
|
1511
|
+
const startSection = document.createElement("div");
|
|
1512
|
+
startSection.className = "mobile-start";
|
|
1513
|
+
|
|
1514
|
+
const menuBtn = document.createElement("y-button");
|
|
1515
|
+
const menuBtnId = this._uid("appbar-mobile-menu");
|
|
1516
|
+
menuBtn.id = menuBtnId;
|
|
1517
|
+
menuBtn.setAttribute("color", "base");
|
|
1518
|
+
menuBtn.setAttribute("style-type", "flat");
|
|
1519
|
+
menuBtn.setAttribute("size", cfg.buttonSize);
|
|
1520
|
+
menuBtn.setAttribute("aria-label", "Open menu");
|
|
1521
|
+
|
|
1522
|
+
const menuIcon = document.createElement("span");
|
|
1523
|
+
menuIcon.slot = "left-icon";
|
|
1524
|
+
menuIcon.innerHTML = menu;
|
|
1525
|
+
menuBtn.appendChild(menuIcon);
|
|
1526
|
+
|
|
1527
|
+
startSection.appendChild(menuBtn);
|
|
1528
|
+
|
|
1529
|
+
const navItems = this.items;
|
|
1530
|
+
if (navItems.length > 0) {
|
|
1531
|
+
const mobileMenu = document.createElement("y-menu");
|
|
1532
|
+
mobileMenu.setAttribute("anchor", menuBtnId);
|
|
1533
|
+
mobileMenu.setAttribute("direction", "down");
|
|
1534
|
+
mobileMenu.setAttribute("size", cfg.buttonSize);
|
|
1535
|
+
mobileMenu.items = this._toMenuItems(navItems);
|
|
1536
|
+
startSection.appendChild(mobileMenu);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
bar.appendChild(startSection);
|
|
1540
|
+
|
|
1541
|
+
/* ── Center: logo + title ── */
|
|
1542
|
+
const centerSection = document.createElement("div");
|
|
1543
|
+
centerSection.className = "mobile-center";
|
|
1544
|
+
|
|
1545
|
+
const logoSlot = document.createElement("slot");
|
|
1546
|
+
logoSlot.name = "logo";
|
|
1547
|
+
centerSection.appendChild(logoSlot);
|
|
1548
|
+
|
|
1549
|
+
const titleSlot = document.createElement("slot");
|
|
1550
|
+
titleSlot.name = "title";
|
|
1551
|
+
centerSection.appendChild(titleSlot);
|
|
1552
|
+
|
|
1553
|
+
bar.appendChild(centerSection);
|
|
1554
|
+
|
|
1555
|
+
/* ── Right: footer slot ── */
|
|
1556
|
+
const endSection = document.createElement("div");
|
|
1557
|
+
endSection.className = "mobile-end";
|
|
1558
|
+
endSection.setAttribute("part", "footer");
|
|
1559
|
+
|
|
1560
|
+
const footerSlot = document.createElement("slot");
|
|
1561
|
+
footerSlot.name = "footer";
|
|
1562
|
+
endSection.appendChild(footerSlot);
|
|
1563
|
+
|
|
1564
|
+
bar.appendChild(endSection);
|
|
1565
|
+
this.shadowRoot.appendChild(bar);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
_renderDesktop() {
|
|
1277
1569
|
const isVertical = this.orientation === "vertical";
|
|
1278
1570
|
const isCollapsed = this.collapsed && isVertical;
|
|
1279
1571
|
const size = this.size;
|
|
@@ -1302,12 +1594,13 @@ class YumeAppbar extends HTMLElement {
|
|
|
1302
1594
|
iconSize: "large",
|
|
1303
1595
|
},
|
|
1304
1596
|
};
|
|
1305
|
-
const cfg = sizeConfig[size] || sizeConfig.medium;
|
|
1306
1597
|
|
|
1307
1598
|
this.shadowRoot.innerHTML = "";
|
|
1308
1599
|
this._idCounter = 0;
|
|
1309
1600
|
|
|
1601
|
+
const cfg = sizeConfig[size] || sizeConfig.medium;
|
|
1310
1602
|
const style = document.createElement("style");
|
|
1603
|
+
|
|
1311
1604
|
style.textContent = `
|
|
1312
1605
|
:host {
|
|
1313
1606
|
display: block;
|
|
@@ -1536,15 +1829,11 @@ class YumeAppbar extends HTMLElement {
|
|
|
1536
1829
|
`;
|
|
1537
1830
|
this.shadowRoot.appendChild(style);
|
|
1538
1831
|
|
|
1539
|
-
// Clone document stylesheets so CSS-class-based icons (e.g. Font Awesome) render in shadow DOM
|
|
1540
|
-
document.querySelectorAll('link[rel="stylesheet"]').forEach((link) => {
|
|
1541
|
-
this.shadowRoot.appendChild(link.cloneNode(true));
|
|
1542
|
-
});
|
|
1543
|
-
|
|
1544
1832
|
const bar = document.createElement("div");
|
|
1545
1833
|
bar.className = `appbar ${isVertical ? "vertical" : "horizontal"}`;
|
|
1546
1834
|
|
|
1547
1835
|
if (isCollapsed) bar.classList.add("collapsed");
|
|
1836
|
+
|
|
1548
1837
|
bar.setAttribute("role", "navigation");
|
|
1549
1838
|
bar.style.setProperty("--_appbar-padding", cfg.padding);
|
|
1550
1839
|
bar.style.setProperty("--_appbar-collapsed-width", cfg.collapsedWidth);
|
|
@@ -1554,7 +1843,6 @@ class YumeAppbar extends HTMLElement {
|
|
|
1554
1843
|
`calc(${cfg.collapsedWidth} - 2 * var(--_appbar-padding) - 2 * var(--component-appbar-border-width, var(--component-sidebar-border-width, 2px)))`,
|
|
1555
1844
|
);
|
|
1556
1845
|
|
|
1557
|
-
/* --- Header: logo + title --- */
|
|
1558
1846
|
const header = document.createElement("div");
|
|
1559
1847
|
header.className = "appbar-header";
|
|
1560
1848
|
header.setAttribute("part", "header");
|
|
@@ -1584,21 +1872,22 @@ class YumeAppbar extends HTMLElement {
|
|
|
1584
1872
|
header.appendChild(headerSlot);
|
|
1585
1873
|
bar.appendChild(header);
|
|
1586
1874
|
|
|
1587
|
-
/* --- Body: y-button nav items --- */
|
|
1588
1875
|
const body = document.createElement("div");
|
|
1589
1876
|
body.className = "appbar-body";
|
|
1590
1877
|
body.setAttribute("part", "body");
|
|
1591
1878
|
|
|
1592
1879
|
const navItems = this.items;
|
|
1880
|
+
|
|
1593
1881
|
navItems.forEach((item) => {
|
|
1594
1882
|
const hasChildren = item.children?.length > 0;
|
|
1595
1883
|
const wrapper = document.createElement("div");
|
|
1596
|
-
wrapper.className = "nav-item";
|
|
1597
|
-
|
|
1598
1884
|
const btn = document.createElement("y-button");
|
|
1599
1885
|
const btnId = this._uid("appbar-btn");
|
|
1600
|
-
btn.id = btnId;
|
|
1601
1886
|
const isActive = this._isItemActive(item);
|
|
1887
|
+
|
|
1888
|
+
wrapper.className = "nav-item";
|
|
1889
|
+
btn.id = btnId;
|
|
1890
|
+
|
|
1602
1891
|
btn.setAttribute("color", isActive ? "primary" : "base");
|
|
1603
1892
|
btn.setAttribute("style-type", "flat");
|
|
1604
1893
|
btn.setAttribute("size", cfg.buttonSize);
|
|
@@ -1661,7 +1950,6 @@ class YumeAppbar extends HTMLElement {
|
|
|
1661
1950
|
|
|
1662
1951
|
bar.appendChild(body);
|
|
1663
1952
|
|
|
1664
|
-
/* --- Footer: slot + collapse toggle (vertical only) --- */
|
|
1665
1953
|
const footer = document.createElement("div");
|
|
1666
1954
|
footer.className = "appbar-footer";
|
|
1667
1955
|
footer.setAttribute("part", "footer");
|
|
@@ -2,10 +2,15 @@ export class YumeBadge extends HTMLElement {
|
|
|
2
2
|
static get observedAttributes(): string[];
|
|
3
3
|
connectedCallback(): void;
|
|
4
4
|
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
5
|
+
/** Horizontal alignment of the badge: "left" | "right" (default "right"). */
|
|
5
6
|
get alignment(): string;
|
|
7
|
+
/** Color theme: "primary" | "secondary" | "base" | "success" | "warning" | "error" | "help". */
|
|
6
8
|
get color(): string;
|
|
9
|
+
/** Vertical position of the badge: "top" | "bottom" (default "top"). */
|
|
7
10
|
get position(): string;
|
|
11
|
+
/** Badge size: "small" | "medium" | "large" (default "small"). */
|
|
8
12
|
get size(): string;
|
|
13
|
+
/** The text content displayed inside the badge. */
|
|
9
14
|
get value(): string;
|
|
10
15
|
getBadgeColors(color: any): any;
|
|
11
16
|
getBadgePosition(position: any, alignment: any): string;
|
|
@@ -19,22 +19,27 @@ class YumeBadge extends HTMLElement {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/** Horizontal alignment of the badge: "left" | "right" (default "right"). */
|
|
22
23
|
get alignment() {
|
|
23
24
|
return this.getAttribute("alignment") || "right";
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/** Color theme: "primary" | "secondary" | "base" | "success" | "warning" | "error" | "help". */
|
|
26
28
|
get color() {
|
|
27
29
|
return this.getAttribute("color") || "primary";
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
/** Vertical position of the badge: "top" | "bottom" (default "top"). */
|
|
30
33
|
get position() {
|
|
31
34
|
return this.getAttribute("position") || "top";
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
/** Badge size: "small" | "medium" | "large" (default "small"). */
|
|
34
38
|
get size() {
|
|
35
39
|
return this.getAttribute("size") || "small";
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
/** The text content displayed inside the badge. */
|
|
38
43
|
get value() {
|
|
39
44
|
return this.getAttribute("value") || "";
|
|
40
45
|
}
|
|
@@ -3,9 +3,14 @@ export class YumeButton extends HTMLElement {
|
|
|
3
3
|
connectedCallback(): void;
|
|
4
4
|
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
5
5
|
set value(newVal: any);
|
|
6
|
+
/** The current selected value(s), comma-separated when 'multiple' is set. */
|
|
6
7
|
get value(): any;
|
|
7
8
|
selectedValues: any;
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Sets the button options from an array of objects.
|
|
11
|
+
* @param {Array<Object>} options
|
|
12
|
+
*/
|
|
13
|
+
setOptions(options: Array<any>): void;
|
|
9
14
|
handleClick(): void;
|
|
10
15
|
init(): void;
|
|
11
16
|
proxyNativeOnClick(): void;
|
|
@@ -55,6 +55,7 @@ class YumeButton extends HTMLElement {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/** The current selected value(s), comma-separated when 'multiple' is set. */
|
|
58
59
|
get value() {
|
|
59
60
|
if (this.hasAttribute("multiple")) {
|
|
60
61
|
return Array.from(this.selectedValues).join(",");
|
|
@@ -85,6 +86,10 @@ class YumeButton extends HTMLElement {
|
|
|
85
86
|
this.setAttribute("value", newVal);
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Sets the button options from an array of objects.
|
|
91
|
+
* @param {Array<Object>} options
|
|
92
|
+
*/
|
|
88
93
|
setOptions(options) {
|
|
89
94
|
this.setAttribute("options", JSON.stringify(options));
|
|
90
95
|
}
|