@design.estate/dees-wcctools 3.6.0 → 3.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design.estate/dees-wcctools",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
4
4
  "private": false,
5
5
  "description": "A set of web component tools for creating element catalogues, enabling the structured development and documentation of custom elements and pages.",
6
6
  "exports": {
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-wcctools',
6
- version: '3.6.0',
6
+ version: '3.6.2',
7
7
  description: 'A set of web component tools for creating element catalogues, enabling the structured development and documentation of custom elements and pages.'
8
8
  }
@@ -12,6 +12,7 @@ import './wcc-properties.js';
12
12
  import { type TTheme } from './wcc-properties.js';
13
13
  import { breakpoints } from '@design.estate/dees-domtools';
14
14
  import { WccFrame } from './wcc-frame.js';
15
+ import { WccSidebar } from './wcc-sidebar.js';
15
16
 
16
17
  /**
17
18
  * Get filtered and sorted items from a section
@@ -491,10 +492,10 @@ export class WccDashboard extends DeesElement {
491
492
  if (this.scrollListenersAttached) {
492
493
  return;
493
494
  }
494
-
495
+
495
496
  const wccFrame = await this.wccFrame;
496
- const wccSidebar = this.shadowRoot.querySelector('wcc-sidebar');
497
-
497
+ const wccSidebar = this.shadowRoot.querySelector('wcc-sidebar') as WccSidebar | null;
498
+
498
499
  if (wccFrame) {
499
500
  // The frame element itself is the scrollable container
500
501
  wccFrame.addEventListener('scroll', () => {
@@ -505,11 +506,14 @@ export class WccDashboard extends DeesElement {
505
506
  }
506
507
 
507
508
  if (wccSidebar) {
508
- // The sidebar element itself is the scrollable container
509
- wccSidebar.addEventListener('scroll', () => {
510
- this.sidebarScrollY = wccSidebar.scrollTop;
511
- this.debouncedScrollUpdate();
512
- });
509
+ // Use the sidebar's scrollable container (.menu element)
510
+ const scrollContainer = wccSidebar.scrollableContainer;
511
+ if (scrollContainer) {
512
+ scrollContainer.addEventListener('scroll', () => {
513
+ this.sidebarScrollY = scrollContainer.scrollTop;
514
+ this.debouncedScrollUpdate();
515
+ });
516
+ }
513
517
  }
514
518
  }
515
519
 
@@ -555,18 +559,21 @@ export class WccDashboard extends DeesElement {
555
559
  if (this.scrollPositionsApplied) {
556
560
  return;
557
561
  }
558
-
562
+
559
563
  const wccFrame = await this.wccFrame;
560
- const wccSidebar = this.shadowRoot.querySelector('wcc-sidebar');
561
-
564
+ const wccSidebar = this.shadowRoot.querySelector('wcc-sidebar') as WccSidebar | null;
565
+
562
566
  if (wccFrame && this.frameScrollY > 0) {
563
567
  // The frame element itself is the scrollable container
564
568
  wccFrame.scrollTop = this.frameScrollY;
565
569
  }
566
570
 
567
571
  if (wccSidebar && this.sidebarScrollY > 0) {
568
- // The sidebar element itself is the scrollable container
569
- wccSidebar.scrollTop = this.sidebarScrollY;
572
+ // Use the sidebar's scrollable container (.menu element)
573
+ const scrollContainer = wccSidebar.scrollableContainer;
574
+ if (scrollContainer) {
575
+ scrollContainer.scrollTop = this.sidebarScrollY;
576
+ }
570
577
  }
571
578
 
572
579
  this.scrollPositionsApplied = true;
@@ -50,6 +50,13 @@ export class WccSidebar extends DeesElement {
50
50
 
51
51
  private sectionsInitialized = false;
52
52
 
53
+ /**
54
+ * Returns the scrollable container element (.menu) for external scroll management
55
+ */
56
+ public get scrollableContainer(): HTMLElement | null {
57
+ return this.shadowRoot?.querySelector('.menu') as HTMLElement | null;
58
+ }
59
+
53
60
  public render(): TemplateResult {
54
61
  return html`
55
62
  <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet" />
@@ -647,27 +654,43 @@ export class WccSidebar extends DeesElement {
647
654
  groupedItems.get(group)!.push(entry);
648
655
  }
649
656
 
650
- const result: TemplateResult[] = [];
657
+ // Build a unified list of render items (ungrouped elements and groups)
658
+ // Each item has a sortKey (element name or first element name of group)
659
+ type RenderItem =
660
+ | { type: 'element'; entry: [string, any]; sortKey: string }
661
+ | { type: 'group'; groupName: string; items: Array<[string, any]>; sortKey: string };
651
662
 
652
- // Render ungrouped items first
663
+ const renderItems: RenderItem[] = [];
664
+
665
+ // Add ungrouped items
653
666
  const ungrouped = groupedItems.get(null) || [];
654
667
  for (const entry of ungrouped) {
655
- result.push(this.renderElementItem(entry, section));
668
+ renderItems.push({ type: 'element', entry, sortKey: entry[0].toLowerCase() });
656
669
  }
657
670
 
658
- // Render grouped items
671
+ // Add groups (sorted by their first element's name)
659
672
  for (const [groupName, items] of groupedItems) {
660
673
  if (groupName === null) continue;
661
-
662
- result.push(html`
663
- <div class="item-group">
664
- <span class="item-group-legend">${groupName}</span>
665
- ${items.map((entry) => this.renderElementItem(entry, section))}
666
- </div>
667
- `);
674
+ const firstElementName = items[0]?.[0] || '';
675
+ renderItems.push({ type: 'group', groupName, items, sortKey: firstElementName.toLowerCase() });
668
676
  }
669
677
 
670
- return result;
678
+ // Sort all items alphabetically by sortKey
679
+ renderItems.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
680
+
681
+ // Render in sorted order
682
+ return renderItems.map((item) => {
683
+ if (item.type === 'element') {
684
+ return this.renderElementItem(item.entry, section);
685
+ } else {
686
+ return html`
687
+ <div class="item-group">
688
+ <span class="item-group-legend">${item.groupName}</span>
689
+ ${item.items.map((entry) => this.renderElementItem(entry, section))}
690
+ </div>
691
+ `;
692
+ }
693
+ });
671
694
  }
672
695
  }
673
696