@waggylabs/yumekit 0.2.4 → 0.2.5

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/README.md CHANGED
@@ -42,10 +42,6 @@ npm install @waggylabs/yumekit
42
42
  The IIFE bundle includes all components and icons. Drop it into any HTML page:
43
43
 
44
44
  ```html
45
- <link
46
- rel="stylesheet"
47
- href="https://cdn.jsdelivr.net/npm/@waggylabs/yumekit/dist/styles/blue-light.css"
48
- />
49
45
  <script src="https://cdn.jsdelivr.net/npm/@waggylabs/yumekit/dist/yumekit.min.js"></script>
50
46
 
51
47
  <y-button color="primary">Click me</y-button>
@@ -221,6 +221,7 @@ class YumeButton extends HTMLElement {
221
221
  .button {
222
222
  box-sizing: border-box;
223
223
  display: inline-flex;
224
+ width: 100%;
224
225
  min-height: var(--button-min-height, var(--sizing-medium, 40px));
225
226
  min-width: var(--button-min-width, var(--sizing-medium, 40px));
226
227
  padding: var(--button-padding, var(--component-button-padding-medium));
@@ -836,6 +837,31 @@ if (!customElements.get("y-icon")) {
836
837
  customElements.define("y-icon", YumeIcon);
837
838
  }
838
839
 
840
+ /* ================================================================== */
841
+ /* Centralized SVG icon strings for the YumeKit component library. */
842
+ /* */
843
+ /* Each static icon also lives in its own .svg file in this directory */
844
+ /* so it can be used standalone (e.g. <img src="…">, CSS background, */
845
+ /* design tools, etc.). The strings below mirror those files — keep */
846
+ /* them in sync when editing an icon. */
847
+ /* ================================================================== */
848
+
849
+ /* ── Chevrons ─────────────────────────────────────────────────────── */
850
+
851
+ const chevronRight = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`;
852
+
853
+ const chevronDown = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>`;
854
+
855
+ /* ── Double chevrons (collapse / expand) ──────────────────────────── */
856
+
857
+ const collapseLeft = `<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="11 17 6 12 11 7"/><polyline points="18 17 13 12 18 7"/></svg>`;
858
+
859
+ 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>`;
860
+
861
+ /* ── Menu (hamburger) ────────────────────────────────────────────── */
862
+
863
+ 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>`;
864
+
839
865
  class YumeMenu extends HTMLElement {
840
866
  static get observedAttributes() {
841
867
  return ["items", "anchor", "visible", "direction", "size"];
@@ -972,10 +998,16 @@ class YumeMenu extends HTMLElement {
972
998
  });
973
999
  }
974
1000
 
1001
+ if (!item.children?.length) {
1002
+ li.addEventListener("click", () => {
1003
+ this.visible = false;
1004
+ });
1005
+ }
1006
+
975
1007
  if (item.children?.length) {
976
1008
  const indicator = document.createElement("span");
977
1009
  indicator.className = "submenu-indicator";
978
- indicator.textContent = "▶";
1010
+ indicator.innerHTML = chevronRight;
979
1011
  li.appendChild(indicator);
980
1012
 
981
1013
  const submenu = this._createMenuList(item.children);
@@ -1129,8 +1161,6 @@ class YumeMenu extends HTMLElement {
1129
1161
  border-radius: var(--component-menu-border-radius, 4px);
1130
1162
  box-shadow: var(--component-menu-shadow, 0 2px 8px rgba(0, 0, 0, 0.15));
1131
1163
  min-width: 150px;
1132
- max-height: 300px;
1133
- overflow-y: auto;
1134
1164
  }
1135
1165
 
1136
1166
  li.menuitem {
@@ -1142,6 +1172,7 @@ class YumeMenu extends HTMLElement {
1142
1172
  white-space: nowrap;
1143
1173
  color: var(--component-menu-color, #f7f7fa);
1144
1174
  font-size: var(--font-size-button, 1em);
1175
+ position: relative;
1145
1176
  }
1146
1177
 
1147
1178
  li.menuitem:hover {
@@ -1161,7 +1192,8 @@ class YumeMenu extends HTMLElement {
1161
1192
  }
1162
1193
 
1163
1194
  .submenu-indicator {
1164
- font-size: 0.75em;
1195
+ display: inline-flex;
1196
+ align-items: center;
1165
1197
  margin-left: 0.5rem;
1166
1198
  opacity: 0.6;
1167
1199
  }
@@ -1186,31 +1218,6 @@ if (!customElements.get("y-menu")) {
1186
1218
  customElements.define("y-menu", YumeMenu);
1187
1219
  }
1188
1220
 
1189
- /* ================================================================== */
1190
- /* Centralized SVG icon strings for the YumeKit component library. */
1191
- /* */
1192
- /* Each static icon also lives in its own .svg file in this directory */
1193
- /* so it can be used standalone (e.g. <img src="…">, CSS background, */
1194
- /* design tools, etc.). The strings below mirror those files — keep */
1195
- /* them in sync when editing an icon. */
1196
- /* ================================================================== */
1197
-
1198
- /* ── Chevrons ─────────────────────────────────────────────────────── */
1199
-
1200
- const chevronRight = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`;
1201
-
1202
- const chevronDown = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>`;
1203
-
1204
- /* ── Double chevrons (collapse / expand) ──────────────────────────── */
1205
-
1206
- const collapseLeft = `<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="11 17 6 12 11 7"/><polyline points="18 17 13 12 18 7"/></svg>`;
1207
-
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>`;
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
-
1214
1221
  class YumeAppbar extends HTMLElement {
1215
1222
  static get observedAttributes() {
1216
1223
  return [
@@ -219,6 +219,7 @@ class YumeButton extends HTMLElement {
219
219
  .button {
220
220
  box-sizing: border-box;
221
221
  display: inline-flex;
222
+ width: 100%;
222
223
  min-height: var(--button-min-height, var(--sizing-medium, 40px));
223
224
  min-width: var(--button-min-width, var(--sizing-medium, 40px));
224
225
  padding: var(--button-padding, var(--component-button-padding-medium));
@@ -1,27 +1 @@
1
- declare class YumeMenu extends HTMLElement {
2
- static get observedAttributes(): string[];
3
- static _closeAll(except: any): void;
4
- _onAnchorClick(e: any): void;
5
- _onDocumentClick(e: any): void;
6
- _onScrollOrResize(): void;
7
- connectedCallback(): void;
8
- set items(val: any);
9
- get items(): any;
10
- disconnectedCallback(): void;
11
- attributeChangedCallback(name: any, oldVal: any, newVal: any): void;
12
- set anchor(val: string);
13
- get anchor(): string;
14
- set visible(val: boolean);
15
- get visible(): boolean;
16
- set direction(val: string);
17
- get direction(): string;
18
- set size(val: string);
19
- get size(): string;
20
- _createMenuList(items: any): HTMLUListElement;
21
- _findTemplate(name: any): Element;
22
- _setupAnchor(): void;
23
- _anchorEl: any;
24
- _teardownAnchor(): void;
25
- _updatePosition(): void;
26
- render(): void;
27
- }
1
+ export {};
@@ -1,3 +1,16 @@
1
+ /* ================================================================== */
2
+ /* Centralized SVG icon strings for the YumeKit component library. */
3
+ /* */
4
+ /* Each static icon also lives in its own .svg file in this directory */
5
+ /* so it can be used standalone (e.g. <img src="…">, CSS background, */
6
+ /* design tools, etc.). The strings below mirror those files — keep */
7
+ /* them in sync when editing an icon. */
8
+ /* ================================================================== */
9
+
10
+ /* ── Chevrons ─────────────────────────────────────────────────────── */
11
+
12
+ const chevronRight = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`;
13
+
1
14
  class YumeMenu extends HTMLElement {
2
15
  static get observedAttributes() {
3
16
  return ["items", "anchor", "visible", "direction", "size"];
@@ -134,10 +147,16 @@ class YumeMenu extends HTMLElement {
134
147
  });
135
148
  }
136
149
 
150
+ if (!item.children?.length) {
151
+ li.addEventListener("click", () => {
152
+ this.visible = false;
153
+ });
154
+ }
155
+
137
156
  if (item.children?.length) {
138
157
  const indicator = document.createElement("span");
139
158
  indicator.className = "submenu-indicator";
140
- indicator.textContent = "▶";
159
+ indicator.innerHTML = chevronRight;
141
160
  li.appendChild(indicator);
142
161
 
143
162
  const submenu = this._createMenuList(item.children);
@@ -291,8 +310,6 @@ class YumeMenu extends HTMLElement {
291
310
  border-radius: var(--component-menu-border-radius, 4px);
292
311
  box-shadow: var(--component-menu-shadow, 0 2px 8px rgba(0, 0, 0, 0.15));
293
312
  min-width: 150px;
294
- max-height: 300px;
295
- overflow-y: auto;
296
313
  }
297
314
 
298
315
  li.menuitem {
@@ -304,6 +321,7 @@ class YumeMenu extends HTMLElement {
304
321
  white-space: nowrap;
305
322
  color: var(--component-menu-color, #f7f7fa);
306
323
  font-size: var(--font-size-button, 1em);
324
+ position: relative;
307
325
  }
308
326
 
309
327
  li.menuitem:hover {
@@ -323,7 +341,8 @@ class YumeMenu extends HTMLElement {
323
341
  }
324
342
 
325
343
  .submenu-indicator {
326
- font-size: 0.75em;
344
+ display: inline-flex;
345
+ align-items: center;
327
346
  margin-left: 0.5rem;
328
347
  opacity: 0.6;
329
348
  }
@@ -191,17 +191,13 @@ class YumePanel extends HTMLElement {
191
191
  return;
192
192
  }
193
193
 
194
- if (this.hasChildren()) {
195
- this.toggle();
196
- } else {
197
- this.dispatchEvent(
198
- new CustomEvent("select", {
199
- detail: { selected: true },
200
- bubbles: true,
201
- composed: true,
202
- }),
203
- );
204
- }
194
+ this.dispatchEvent(
195
+ new CustomEvent("select", {
196
+ detail: { selected: true },
197
+ bubbles: true,
198
+ composed: true,
199
+ }),
200
+ );
205
201
  });
206
202
 
207
203
  header.addEventListener("keydown", (e) => {
@@ -211,6 +207,21 @@ class YumePanel extends HTMLElement {
211
207
  }
212
208
  });
213
209
 
210
+ const arrow = this.shadowRoot.querySelector(".arrow");
211
+ if (arrow) {
212
+ arrow.addEventListener("click", (e) => {
213
+ e.stopPropagation();
214
+ this.toggle();
215
+ });
216
+
217
+ arrow.addEventListener("keydown", (e) => {
218
+ if (e.key === " " || e.key === "Enter") {
219
+ e.preventDefault();
220
+ this.toggle();
221
+ }
222
+ });
223
+ }
224
+
214
225
  const childrenSlot = this.shadowRoot.querySelector(
215
226
  'slot[name="children"]',
216
227
  );
@@ -254,13 +265,13 @@ class YumePanel extends HTMLElement {
254
265
 
255
266
  updateExpandedState() {
256
267
  const hasChildren = this.hasChildren();
257
- const header = this.shadowRoot.querySelector(".header");
268
+ const arrow = this.shadowRoot.querySelector(".arrow");
258
269
  const isExpanded = this.expanded && hasChildren;
259
270
 
260
271
  this._expanded = isExpanded;
261
272
 
262
- if (header) {
263
- header.setAttribute("aria-expanded", String(isExpanded));
273
+ if (arrow) {
274
+ arrow.setAttribute("aria-expanded", String(isExpanded));
264
275
  }
265
276
  }
266
277
 
@@ -315,10 +326,6 @@ class YumePanel extends HTMLElement {
315
326
  background: var(--component-panel-hover-background);
316
327
  }
317
328
 
318
- :host([data-has-children="false"]) .header {
319
- cursor: default;
320
- }
321
-
322
329
  .header ::slotted([slot="icon"]) {
323
330
  margin-right: 6px;
324
331
  }
@@ -335,6 +342,17 @@ class YumePanel extends HTMLElement {
335
342
  align-items: center;
336
343
  justify-content: center;
337
344
  transition: transform 0.2s ease;
345
+ background: none;
346
+ border: none;
347
+ padding: 0;
348
+ cursor: pointer;
349
+ color: inherit;
350
+ flex-shrink: 0;
351
+ }
352
+
353
+ .arrow:focus-visible {
354
+ outline: 2px solid var(--component-panel-accent, currentColor);
355
+ border-radius: 2px;
338
356
  }
339
357
 
340
358
  .arrow svg {
@@ -369,12 +387,12 @@ class YumePanel extends HTMLElement {
369
387
 
370
388
  this.shadowRoot.adoptedStyleSheets = [sheet];
371
389
  this.shadowRoot.innerHTML = `
372
- <div class="header" part="header" role="button" tabindex="0" aria-expanded="false">
390
+ <div class="header" part="header" role="button" tabindex="0">
373
391
  <slot name="icon"></slot>
374
392
  <slot name="label"><slot></slot></slot>
375
- <span class="arrow" id="arrow" part="arrow">
393
+ <button class="arrow" id="arrow" part="arrow" tabindex="0" aria-expanded="false" aria-label="Toggle children">
376
394
  ${chevronDown}
377
- </span>
395
+ </button>
378
396
  </div>
379
397
  <div class="children" id="childrenContainer" part="children">
380
398
  <slot name="children"></slot>
package/dist/icons/all.js CHANGED
@@ -18,7 +18,7 @@ var bolt = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill
18
18
 
19
19
  var calendar = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"/>\n <line x1=\"16\" y1=\"2\" x2=\"16\" y2=\"6\"/>\n <line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"6\"/>\n <line x1=\"3\" y1=\"10\" x2=\"21\" y2=\"10\"/>\n <rect x=\"7\" y=\"14\" width=\"3\" height=\"3\" rx=\"0.5\"/>\n <rect x=\"14\" y=\"14\" width=\"3\" height=\"3\" rx=\"0.5\"/>\n</svg>\n";
20
20
 
21
- var campfire = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M12 3c0 4-4 6-4 10a4 4 0 0 0 8 0c0-4-4-6-4-10z\"/>\n <path d=\"M12 17a1.5 1.5 0 0 1-1.5-1.5c0-1.5 1.5-2.5 1.5-4 0 1.5 1.5 2.5 1.5 4A1.5 1.5 0 0 1 12 17z\"/>\n <line x1=\"5\" y1=\"21\" x2=\"19\" y2=\"21\"/>\n <line x1=\"3\" y1=\"21\" x2=\"10\" y2=\"17\"/>\n <line x1=\"21\" y1=\"21\" x2=\"14\" y2=\"17\"/>\n</svg>\n";
21
+ var campfire = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M3 21L15 18\" stroke=\"black\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M21 21L9 18\" stroke=\"black\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12.4787 16.9985C12.4787 16.9985 9.64692 16.9985 8.02964 15.1923C6.41236 13.386 6.8164 10.225 8.43406 7.51565C10.0517 4.80626 12.8819 3 12.8819 3C12.8819 3 12.0729 5.25782 11.6686 7.06408C11.2643 8.87034 12.0742 9.32191 12.0742 9.32191C12.0742 9.32191 12.8825 9.77347 14.0955 8.41878C15.3085 7.06408 15.3085 6.16095 15.3085 6.16095C15.3085 6.16095 18.0166 13.2656 16.5796 15.1923C15.1427 17.1189 12.4787 16.9985 12.4787 16.9985Z\" stroke=\"black\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M11.6436 16.9995C11.6436 16.9995 10.7941 16.9995 10.3089 16.3544C9.82371 15.7093 9.94492 14.5804 10.4302 13.6127C10.9155 12.6451 11.7646 12 11.7646 12C11.7646 12 11.5219 12.8064 11.4006 13.4515C11.2793 14.0966 11.5223 14.2578 11.5223 14.2578C11.5223 14.2578 11.7648 14.4191 12.1287 13.9353C12.4926 13.4515 12.4926 13.1289 12.4926 13.1289C12.4926 13.1289 13.305 15.6663 12.8739 16.3544C12.4428 17.0425 11.6436 16.9995 11.6436 16.9995Z\" stroke=\"black\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n";
22
22
 
23
23
  var chart = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"22 12 18 12 15 21 9 3 6 12 2 12\"/>\n</svg>\n";
24
24
 
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./components/y-checkbox.js";
7
7
  export * from "./components/y-drawer.js";
8
8
  export * from "./components/y-icon.js";
9
9
  export * from "./components/y-input.js";
10
+ export * from "./components/y-menu.js";
10
11
  export * from "./components/y-panel.js";
11
12
  export * from "./components/y-panelbar.js";
12
13
  export * from "./components/y-progress.js";