@stacksjs/defaults 0.70.82 → 0.70.83

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
- "version": "0.70.82",
4
+ "version": "0.70.83",
5
5
  "description": "Default Stacks scaffold resources (views, layouts, components, preloader) — shipped so apps consuming the framework from node_modules get the same fallback resources a vendored checkout provides. Source of truth: storage/framework/defaults.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -308,6 +308,20 @@ export function buildSidebarNavHtml(
308
308
  discoveredModels: DiscoveredModel[] = [],
309
309
  toggles: DashboardSectionToggles = DEFAULT_TOGGLES,
310
310
  ): string {
311
+ return buildNavSections(discoveredModels, toggles)
312
+ .map(([key, label, items]) => renderSection(key, label, items))
313
+ .join('')
314
+ }
315
+
316
+ /**
317
+ * The sidebar's navigation tree as data: `[sectionKey, sectionLabel, items]`
318
+ * per section, with all toggle/model logic applied. Shared by the legacy
319
+ * HTML renderer above and the macOS web sidebar below.
320
+ */
321
+ export function buildNavSections(
322
+ discoveredModels: DiscoveredModel[] = [],
323
+ toggles: DashboardSectionToggles = DEFAULT_TOGGLES,
324
+ ): Array<[string, string, NavItem[]]> {
311
325
  const sections: Array<[string, string, NavItem[]]> = []
312
326
 
313
327
  // Library section: views live at the project root (e.g. `/functions`,
@@ -515,7 +529,131 @@ export function buildSidebarNavHtml(
515
529
  ]])
516
530
  }
517
531
 
518
- return sections.map(([key, label, items]) => renderSection(key, label, items)).join('')
532
+ return sections
533
+ }
534
+
535
+ // ============================================================================
536
+ // macOS web sidebar (@stacksjs/components' <Sidebar theme="macos">)
537
+ // ============================================================================
538
+
539
+ /**
540
+ * The legacy icon keys above, as SF-Symbol-style iconify classes (f7 icons
541
+ * mirror SF Symbols) for the macOS web sidebar.
542
+ */
543
+ const NAV_ICON_CLASSES: Record<string, string> = {
544
+ 'home': 'i-f7-house',
545
+ 'function': 'i-f7-function',
546
+ 'list-number': 'i-f7-list-number',
547
+ 'package': 'i-f7-cube-box',
548
+ 'dashboard': 'i-f7-square-grid-2x2',
549
+ 'files': 'i-f7-folder',
550
+ 'file': 'i-f7-doc',
551
+ 'post': 'i-f7-doc-text',
552
+ 'tags': 'i-f7-tag',
553
+ 'tag': 'i-f7-tag',
554
+ 'comment': 'i-f7-chat-bubble',
555
+ 'user-edit': 'i-f7-person',
556
+ 'seo': 'i-f7-search',
557
+ 'rocket': 'i-f7-rocket',
558
+ 'api': 'i-f7-globe',
559
+ 'link': 'i-f7-link',
560
+ 'bolt': 'i-f7-bolt',
561
+ 'terminal': 'i-f7-chevron-left-slash-chevron-right',
562
+ 'queue': 'i-f7-list-bullet',
563
+ 'briefcase': 'i-f7-briefcase',
564
+ 'clock': 'i-f7-clock',
565
+ 'search': 'i-f7-search',
566
+ 'log': 'i-f7-doc-plaintext',
567
+ 'bell': 'i-f7-bell',
568
+ 'mail': 'i-f7-envelope',
569
+ 'mailbox': 'i-f7-tray',
570
+ 'activity': 'i-f7-waveform',
571
+ 'settings': 'i-f7-gear-alt',
572
+ 'users': 'i-f7-person-2',
573
+ 'user': 'i-f7-person',
574
+ 'group': 'i-f7-person-3',
575
+ 'table': 'i-f7-table',
576
+ 'cart': 'i-f7-cart',
577
+ 'check-circle': 'i-f7-checkmark-circle',
578
+ 'cloud': 'i-f7-cloud',
579
+ 'coupon': 'i-f7-ticket',
580
+ 'document': 'i-f7-doc-text',
581
+ 'gift': 'i-f7-gift',
582
+ 'globe': 'i-f7-globe',
583
+ 'globe-search': 'i-f7-globe',
584
+ 'invoice': 'i-f7-money-dollar-circle',
585
+ 'lock': 'i-f7-lock',
586
+ 'list-settings': 'i-f7-list-bullet-below-rectangle',
587
+ 'megaphone': 'i-f7-speaker-2',
588
+ 'orders': 'i-f7-bag',
589
+ 'percent': 'i-f7-percent',
590
+ 'puzzle': 'i-f7-square-on-square',
591
+ 'sale-tag': 'i-f7-tag',
592
+ 'server': 'i-f7-rectangle-stack',
593
+ 'star': 'i-f7-star',
594
+ 'truck': 'i-f7-car-fill',
595
+ 'zap': 'i-f7-bolt',
596
+ }
597
+
598
+ /** One row for `@stacksjs/components`' <Sidebar :sections>. */
599
+ export interface WebSidebarItem {
600
+ id: string
601
+ label: string
602
+ icon: string
603
+ /** macOS system color name or CSS color for the icon tint. */
604
+ iconColor: string
605
+ href: string
606
+ roles?: string[]
607
+ }
608
+
609
+ export interface WebSidebarSection {
610
+ id: string
611
+ label: string
612
+ items: WebSidebarItem[]
613
+ }
614
+
615
+ /** Stable row id derived from the route (e.g. `/content/posts` → `content-posts`). */
616
+ function navItemId(to: string): string {
617
+ return to.replace(/^\//, '').replace(/\//g, '-') || 'home'
618
+ }
619
+
620
+ function titleCase(label: string): string {
621
+ return label.charAt(0).toUpperCase() + label.slice(1)
622
+ }
623
+
624
+ /**
625
+ * The dashboard navigation shaped for the macOS web sidebar. Reads the
626
+ * discovered-models manifest synchronously (stx server-script friendly)
627
+ * and reuses the exact section/toggle logic of the legacy HTML builder.
628
+ */
629
+ export function buildWebSidebarSections(): WebSidebarSection[] {
630
+ const manifest = loadDiscoveredManifest()
631
+ const sections = buildNavSections(manifest.models, manifest.sections)
632
+
633
+ return [
634
+ {
635
+ id: 'top',
636
+ label: '',
637
+ items: [{ id: 'home', label: 'Home', icon: NAV_ICON_CLASSES.home, iconColor: 'blue', href: '/' }],
638
+ },
639
+ ...sections.map(([key, label, items]) => ({
640
+ id: key,
641
+ label: titleCase(label),
642
+ items: items.map(item => ({
643
+ id: navItemId(item.to),
644
+ label: item.text,
645
+ icon: NAV_ICON_CLASSES[item.icon] ?? NAV_ICON_CLASSES.file,
646
+ iconColor: 'blue',
647
+ href: item.to,
648
+ ...(item.roles && item.roles.length > 0 ? { roles: item.roles } : {}),
649
+ })),
650
+ })),
651
+ {
652
+ id: 'system',
653
+ label: '',
654
+ items: [{ id: 'settings', label: 'Settings', icon: NAV_ICON_CLASSES.settings, iconColor: 'blue', href: '/settings/billing' }],
655
+ },
656
+ ]
519
657
  }
520
658
 
521
659
  /**
@@ -1,23 +0,0 @@
1
- <!--
2
- Stacks Dashboard sidebar.
3
-
4
- The actual sidebar is rendered inline by the dashboard layout
5
- (`storage/framework/defaults/views/dashboard/layouts/default.stx`)
6
- using the helper at `resources/functions/dashboard/sidebar.ts`. We
7
- bypass the component-boundary path because in the STX version this
8
- framework ships with, prop bindings on component invocations
9
- (`<Sidebar :nav-html="…" />`) silently arrive as undefined regardless
10
- of how the expression is shaped — so the layout builds the chunk of
11
- HTML server-side and drops it in via raw triple-brace interpolation.
12
-
13
- This file is kept (empty) rather than deleted because the components
14
- directory is auto-scanned and a referenced-but-missing component
15
- would surface as a runtime error in any view that still does
16
- `<Sidebar />` (e.g. the older `DashboardLayout.stx`). An empty
17
- template is a no-op render: safe, unobtrusive, and doesn't drag any
18
- stale markup into pages that DO use the layout's inline sidebar.
19
-
20
- See the helper module for the SVG icons + section structure + the
21
- user-model discovery that wires `Booking`, `Car`, `Roadtrip`, etc.
22
- into the Data section automatically.
23
- -->