@handijitcom/ui 3.0.0 → 3.2.0

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.
Files changed (118) hide show
  1. package/README.md +209 -9
  2. package/build/components/AppShell/Nav.cjs +2 -0
  3. package/build/components/AppShell/Nav.cjs.map +1 -0
  4. package/build/components/AppShell/Nav.d.cts +75 -0
  5. package/build/components/AppShell/Nav.d.ts +75 -0
  6. package/build/components/AppShell/Nav.js +189 -0
  7. package/build/components/AppShell/Nav.js.map +1 -0
  8. package/build/components/AppShell/context.cjs +2 -0
  9. package/build/components/AppShell/context.cjs.map +1 -0
  10. package/build/components/AppShell/context.d.cts +29 -0
  11. package/build/components/AppShell/context.d.ts +29 -0
  12. package/build/components/AppShell/context.js +13 -0
  13. package/build/components/AppShell/context.js.map +1 -0
  14. package/build/components/AppShell/index.cjs +2 -0
  15. package/build/components/AppShell/index.cjs.map +1 -0
  16. package/build/components/AppShell/index.d.cts +39 -0
  17. package/build/components/AppShell/index.d.ts +39 -0
  18. package/build/components/AppShell/index.js +130 -0
  19. package/build/components/AppShell/index.js.map +1 -0
  20. package/build/components/AppShell/style.css +1 -0
  21. package/build/components/Avatar/index.cjs +1 -1
  22. package/build/components/Avatar/index.cjs.map +1 -1
  23. package/build/components/Avatar/index.js +18 -18
  24. package/build/components/Avatar/index.js.map +1 -1
  25. package/build/components/BulkPasteInput/index.cjs +2 -0
  26. package/build/components/BulkPasteInput/index.cjs.map +1 -0
  27. package/build/components/BulkPasteInput/index.d.cts +26 -0
  28. package/build/components/BulkPasteInput/index.d.ts +26 -0
  29. package/build/components/BulkPasteInput/index.js +80 -0
  30. package/build/components/BulkPasteInput/index.js.map +1 -0
  31. package/build/components/BulkPasteInput/style.css +1 -0
  32. package/build/components/Checkbox/index.cjs +1 -1
  33. package/build/components/Checkbox/index.cjs.map +1 -1
  34. package/build/components/Checkbox/index.js +6 -6
  35. package/build/components/Checkbox/index.js.map +1 -1
  36. package/build/components/DataTable/context.cjs +2 -0
  37. package/build/components/DataTable/context.cjs.map +1 -0
  38. package/build/components/DataTable/context.d.cts +17 -0
  39. package/build/components/DataTable/context.d.ts +17 -0
  40. package/build/components/DataTable/context.js +7 -0
  41. package/build/components/DataTable/context.js.map +1 -0
  42. package/build/components/DataTable/index.cjs +1 -1
  43. package/build/components/DataTable/index.cjs.map +1 -1
  44. package/build/components/DataTable/index.d.cts +46 -5
  45. package/build/components/DataTable/index.d.ts +46 -5
  46. package/build/components/DataTable/index.js +236 -93
  47. package/build/components/DataTable/index.js.map +1 -1
  48. package/build/components/DataTable/style.css +1 -1
  49. package/build/components/DataTableColumnMenu/index.cjs +2 -0
  50. package/build/components/DataTableColumnMenu/index.cjs.map +1 -0
  51. package/build/components/DataTableColumnMenu/index.d.cts +13 -0
  52. package/build/components/DataTableColumnMenu/index.d.ts +13 -0
  53. package/build/components/DataTableColumnMenu/index.js +69 -0
  54. package/build/components/DataTableColumnMenu/index.js.map +1 -0
  55. package/build/components/DataTableColumnMenu/style.css +1 -0
  56. package/build/components/Drawer/index.cjs +1 -1
  57. package/build/components/Drawer/index.cjs.map +1 -1
  58. package/build/components/Drawer/index.js +33 -33
  59. package/build/components/Drawer/index.js.map +1 -1
  60. package/build/components/Gallery/index.cjs +2 -0
  61. package/build/components/Gallery/index.cjs.map +1 -0
  62. package/build/components/Gallery/index.d.cts +56 -0
  63. package/build/components/Gallery/index.d.ts +56 -0
  64. package/build/components/Gallery/index.js +253 -0
  65. package/build/components/Gallery/index.js.map +1 -0
  66. package/build/components/Gallery/style.css +1 -0
  67. package/build/components/Menu/index.cjs +1 -1
  68. package/build/components/Menu/index.cjs.map +1 -1
  69. package/build/components/Menu/index.js +48 -48
  70. package/build/components/Menu/index.js.map +1 -1
  71. package/build/components/NotificationCenter/index.cjs +2 -0
  72. package/build/components/NotificationCenter/index.cjs.map +1 -0
  73. package/build/components/NotificationCenter/index.d.cts +45 -0
  74. package/build/components/NotificationCenter/index.d.ts +45 -0
  75. package/build/components/NotificationCenter/index.js +124 -0
  76. package/build/components/NotificationCenter/index.js.map +1 -0
  77. package/build/components/NotificationCenter/style.css +1 -0
  78. package/build/components/Popover/index.cjs +1 -1
  79. package/build/components/Popover/index.cjs.map +1 -1
  80. package/build/components/Popover/index.js +16 -16
  81. package/build/components/Popover/index.js.map +1 -1
  82. package/build/components/TreeSelect/index.cjs +2 -0
  83. package/build/components/TreeSelect/index.cjs.map +1 -0
  84. package/build/components/TreeSelect/index.d.cts +40 -0
  85. package/build/components/TreeSelect/index.d.ts +40 -0
  86. package/build/components/TreeSelect/index.js +175 -0
  87. package/build/components/TreeSelect/index.js.map +1 -0
  88. package/build/components/TreeSelect/style.css +1 -0
  89. package/build/components/UserMenu/index.cjs +2 -0
  90. package/build/components/UserMenu/index.cjs.map +1 -0
  91. package/build/components/UserMenu/index.d.cts +21 -0
  92. package/build/components/UserMenu/index.d.ts +21 -0
  93. package/build/components/UserMenu/index.js +36 -0
  94. package/build/components/UserMenu/index.js.map +1 -0
  95. package/build/components/UserMenu/style.css +1 -0
  96. package/build/helpers/app-shell.helper.cjs +2 -0
  97. package/build/helpers/app-shell.helper.cjs.map +1 -0
  98. package/build/helpers/app-shell.helper.d.cts +12 -0
  99. package/build/helpers/app-shell.helper.d.ts +12 -0
  100. package/build/helpers/app-shell.helper.js +18 -0
  101. package/build/helpers/app-shell.helper.js.map +1 -0
  102. package/build/helpers/bulk-paste.helper.cjs +2 -0
  103. package/build/helpers/bulk-paste.helper.cjs.map +1 -0
  104. package/build/helpers/bulk-paste.helper.d.cts +38 -0
  105. package/build/helpers/bulk-paste.helper.d.ts +38 -0
  106. package/build/helpers/bulk-paste.helper.js +37 -0
  107. package/build/helpers/bulk-paste.helper.js.map +1 -0
  108. package/build/index.cjs +1 -1
  109. package/build/index.d.cts +9 -1
  110. package/build/index.d.ts +9 -1
  111. package/build/index.js +138 -118
  112. package/build/index.js.map +1 -1
  113. package/build/styles.css +17 -1
  114. package/build/types/theme.type.d.cts +71 -0
  115. package/build/types/theme.type.d.ts +71 -0
  116. package/build/types/types/theme.type.d.cts +71 -0
  117. package/build/types/types/theme.type.d.ts +71 -0
  118. package/package.json +71 -1
package/README.md CHANGED
@@ -281,7 +281,49 @@ either. Labels are given **once**, on the provider:
281
281
  pagination: { label: 'Sayfalar', previous: 'Önceki sayfa', next: 'Sonraki sayfa' },
282
282
  quantity: { label: 'Adet', decrease: 'Adeti azalt', increase: 'Adeti artır' },
283
283
  range: { min: 'En az', max: 'En çok' },
284
- dataTable: { empty: 'Kayıt bulunamadı.', loading: 'Yükleniyor…' },
284
+ dataTable: {
285
+ empty: 'Kayıt bulunamadı.',
286
+ loading: 'Yükleniyor…',
287
+ columns: 'Sütunlar',
288
+ moveUp: column => `${column} sütununu öne al`,
289
+ moveDown: column => `${column} sütununu geri al`,
290
+ },
291
+ gallery: {
292
+ thumbnails: 'Görseller',
293
+ thumbnail: (index, total) => `Görsel ${index} / ${total}`,
294
+ previous: 'Önceki görsel',
295
+ next: 'Sonraki görsel',
296
+ fullscreen: 'Tam ekran',
297
+ zoomIn: 'Yakınlaştır',
298
+ zoomOut: 'Uzaklaştır',
299
+ },
300
+ treeSelect: { search: 'Kategori ara', empty: 'Eşleşen kategori yok' },
301
+ notificationCenter: {
302
+ trigger: unread => (unread ? `Bildirimler, ${unread} okunmamış` : 'Bildirimler'),
303
+ title: 'Bildirimler',
304
+ markAllRead: 'Tümünü okundu işaretle',
305
+ markRead: 'Okundu işaretle',
306
+ empty: 'Bildirim yok',
307
+ unread: 'Okunmamış',
308
+ today: 'Bugün',
309
+ yesterday: 'Dün',
310
+ },
311
+ appShell: {
312
+ skipToContent: 'İçeriğe atla',
313
+ navigation: 'Ana menü',
314
+ openNavigation: 'Menüyü aç',
315
+ collapse: 'Kenar çubuğunu daralt',
316
+ expand: 'Kenar çubuğunu genişlet',
317
+ badge: count => `${count} yeni`,
318
+ userMenu: 'Hesap',
319
+ },
320
+ bulkPaste: {
321
+ summary: count => `${count} satır okundu`,
322
+ invalidSummary: count => `${count} satır okunamadı`,
323
+ line: line => `Satır ${line}`,
324
+ missingCode: 'Kod yok',
325
+ invalidQuantity: 'Adet okunamadı',
326
+ },
285
327
  copyField: {
286
328
  copy: value => `${value} kopyala`,
287
329
  copied: value => `${value} kopyalandı`,
@@ -380,13 +422,14 @@ and changes when an announcement strip appears.
380
422
  | Group | Components |
381
423
  | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
382
424
  | Action | `Button` · `IconButton` · `TextLink` · `Tooltip` · `Menu` · `ContextMenu` · `Popover` |
383
- | Choice | `Chip` · `ChipGroup` · `SegmentedControl` · `Select` · `Combobox` · `Checkbox` · `Switch` · `Radio` · `RadioCard` · `RangeSlider` · `RatingInput` · `QuantityStepper` · `TableCheckbox` |
384
- | Input | `Input` · `PasswordInput` · `Textarea` · `TagInput` · `DateField` (+ `DateRange`) · `FileUpload` · `Field` · `ScaledInput` · `MoneyInput` · `QuantityInput` · `RateInput` · `PercentInput` |
385
- | Surface | `Card` (+ `CardMedia`, `CardOverlay`, `CardBody`, `CardFooter`) · `SummaryCard` · `Panel` (+ `PanelForm`, `PanelRow`) · `PageHeader` · `SectionHeader` · `Tile` · `Directory` (+ `DirectoryGroup`, `DirectoryRow`, `DirectoryJump`) · `Carousel` · `ScrollArea` · `Disclosure` · `Accordion` · `Tabs` |
386
- | Feedback | `Alert` · `Badge` · `StatusDot` · `CodeBadge` · `Kbd` · `EmptyState` · `Skeleton` (+ `SkeletonCard`, `SkeletonRows`, `SkeletonTable`) · `Spinner` · `Progress` · `Steps` · `Divider` · `Avatar` · `Rating` · `Price` · `Stat` · `CopyField` · `Breadcrumb` · `ToastHub` (+ `ToastPortal`) |
425
+ | Choice | `Chip` · `ChipGroup` · `SegmentedControl` · `Select` · `Combobox` · `TreeSelect` · `Checkbox` · `Switch` · `Radio` · `RadioCard` · `RangeSlider` · `RatingInput` · `QuantityStepper` · `TableCheckbox` |
426
+ | Input | `Input` · `PasswordInput` · `Textarea` · `TagInput` · `DateField` (+ `DateRange`) · `FileUpload` · `Field` · `ScaledInput` · `MoneyInput` · `QuantityInput` · `RateInput` · `PercentInput` · `BulkPasteInput` |
427
+ | Surface | `Card` (+ `CardMedia`, `CardOverlay`, `CardBody`, `CardFooter`) · `SummaryCard` · `Panel` (+ `PanelForm`, `PanelRow`) · `PageHeader` · `SectionHeader` · `Tile` · `Directory` (+ `DirectoryGroup`, `DirectoryRow`, `DirectoryJump`) · `Carousel` · `Gallery` · `ScrollArea` · `Disclosure` · `Accordion` · `Tabs` |
428
+ | Feedback | `Alert` · `Badge` · `StatusDot` · `CodeBadge` · `Kbd` · `EmptyState` · `Skeleton` (+ `SkeletonCard`, `SkeletonRows`, `SkeletonTable`) · `Spinner` · `Progress` · `Steps` · `Divider` · `Avatar` · `Rating` · `Price` · `Stat` · `CopyField` · `Breadcrumb` · `ToastHub` (+ `ToastPortal`) · `NotificationCenter` |
387
429
  | Brand surface (3.0) | `BrandSurface` (+ `BrandBlueprint`) · `Eyebrow` · `StatStrip` |
430
+ | Shell (3.2) | `AppShell` (+ `AppShellNav`, `AppShellNavGroup`, `AppShellNavItem`) · `UserMenu` |
388
431
  | Modal | `Modal` · `Drawer` · `BottomSheet` · `ConfirmDialog` · `PromptDialog` · `CommandPalette` |
389
- | Data | `Table` (+ `TableScroller`) · `DataTable` (+ `DataTableRow`) · `FilterBar` (+ `FilterBarField`) · `Pagination` · `Timeline` |
432
+ | Data | `Table` (+ `TableScroller`) · `DataTable` (+ `DataTableRow`, `DataTableColumnMenu`) · `FilterBar` (+ `FilterBarField`) · `Pagination` · `Timeline` |
390
433
  | Theme and hooks | `UiProvider` · `UiThemeScript` · `useUi` · `useUiTheme` · `useUiTokens` · `useAnnounce` · `useStickToBottom` · `usePositioning` · `useVirtualList` · `useListboxNavigation` · `hasOpenSurface` |
391
434
  | Chat, `/chat` | `ChatThread` · `ChatMessage` · `PromptInput` · `PromptSuggestions` · `Prose` · `CodeBlock` · `ReasoningBlock` (+ `ReasoningText`) · `ToolCall` (+ `ToolCallSection`) · `TerminalOutput` · `SourceList` · `Citation` · `MessageActions` · `AppBar` · `ActionList` (+ `ActionListItem`) · `SegmentBar` · `Legend` · `DescriptionList` |
392
435
  | Charts, `/charts` | `LineChart` · `AreaChart` · `BarChart` · `ComposedChart` · `PieChart` · `ScatterPlot` · `Heatmap` · `BoxPlot` · `Histogram` · `RadarChart` |
@@ -577,6 +620,162 @@ data contract. `123450` with two decimal places is "1.234,50".
577
620
  formatters' (`formatMoney`, `formatQuantity` …); `Price` stays a
578
621
  display of an already formatted text.
579
622
 
623
+ ### Parts portal components (3.1)
624
+
625
+ Dense data and ordering screens: every one is its own subpath
626
+ (`@handijitcom/ui/gallery`, `/tree-select`, `/notification-center`,
627
+ `/bulk-paste-input`, `/data-table-column-menu`) and works the same in Next and
628
+ Electron.
629
+
630
+ **`DataTable` data mode.** Pass `rows` and a `render` per column instead of
631
+ children; then, all opt-in:
632
+
633
+ ```tsx
634
+ <DataTable
635
+ label="Parçalar"
636
+ columns={[
637
+ { key: 'code', label: 'Kod', isAlwaysVisible: true, render: part => part.code },
638
+ { key: 'name', label: 'Ad', render: part => part.name },
639
+ ]}
640
+ rows={parts}
641
+ getRowKey={part => part.code}
642
+ columnState={columns} // { order: string[]; hidden: string[] }, or uncontrolled
643
+ onColumnStateChange={setColumns} // persist it per user
644
+ columnMenu={<DataTableColumnMenu />} // visibility checkboxes + move up / down
645
+ density="compact" // or 'comfortable' (default)
646
+ onRowActivate={openPart} // ↑ ↓ Home End move, Enter (or a click) activates
647
+ isVirtualized // only the rows in view; fixed `rowHeight` (36 / 48 px)
648
+ hasViewportCap
649
+ />
650
+ ```
651
+
652
+ A virtualized table scrolls in its own box (`hasViewportCap`, or
653
+ `--ui-data-table-max-height`, 480px by default) with a sticky header; its rows
654
+ are `rowHeight` tall and its cells do not wrap. Children mode is unchanged and
655
+ ignores these props.
656
+
657
+ **`DataTableColumnMenu`** (`@handijitcom/ui/data-table-column-menu`) is the
658
+ column menu, a component of its own so that a table without one does not bundle
659
+ `Popover`, `Checkbox` and `IconButton` (`DataTable` alone 2.85 kB gzip, with the
660
+ menu 6.66 kB). Pass it as `columnMenu`; it is drawn in a toolbar above the
661
+ table and edits that table's `columnState`, controlled or not. Its texts come
662
+ from `UiLabels.dataTable` (`columns`, `moveUp`, `moveDown`) or its `labels`
663
+ prop. Outside a data-mode `DataTable` it draws nothing.
664
+
665
+ ```tsx
666
+ import DataTable from '@handijitcom/ui/data-table';
667
+ import DataTableColumnMenu from '@handijitcom/ui/data-table-column-menu';
668
+
669
+ <DataTable
670
+ columns={columns}
671
+ rows={parts}
672
+ columnMenu={<DataTableColumnMenu labels={{ columns: 'Görünüm' }} />}
673
+ />;
674
+ ```
675
+
676
+ **`Gallery`** — main image, thumbnails, a hover zoom under a mouse, a
677
+ full-screen view (← → Home End, Escape, swipe, click to zoom).
678
+ `renderImage` is the platform adapter; pass its `className` through:
679
+
680
+ ```tsx
681
+ <Gallery
682
+ label="Ürün görselleri"
683
+ images={[{ src, alt: 'Fren balatası, ön', thumbnailSrc, width: 800, height: 800 }]}
684
+ renderImage={({ src, alt, className, variant, width, height }) => (
685
+ <Image
686
+ src={src}
687
+ alt={alt}
688
+ className={className}
689
+ width={width}
690
+ height={height}
691
+ sizes={variant === 'thumbnail' ? '64px' : '(max-width: 768px) 100vw, 50vw'}
692
+ />
693
+ )}
694
+ />
695
+ ```
696
+
697
+ **`TreeSelect`** — an inline ARIA tree (put it in a `Popover` or a
698
+ `Drawer` for a dropdown): `isMultiple`, `value` / `onChange`, `expanded` /
699
+ `onExpandedChange` (optional), `hasSearch` (matches stay with their ancestors,
700
+ which open). Each node is selected on its own; what a parent's selection
701
+ means is the caller's.
702
+
703
+ **`NotificationCenter`** — bell with an unread badge and a panel grouped by
704
+ day (today, yesterday, then the date in `labels.locale`). Presentational:
705
+ `items`, `onItemSelect`, `onMarkRead`, `onMarkAllRead`, optional `isOpen` /
706
+ `onOpenChange`, `formatDay` / `formatTime`.
707
+
708
+ **`BulkPasteInput`** and **`parseBulkPaste(text, { defaultQuantity, isMergingDuplicates })`**
709
+ — rows `{ code, quantity, line }` and invalid lines `{ line, text, reason }`
710
+ from a spreadsheet copy (tabs), `;`, `,` or space separated lines, or one
711
+ code per line. Quantities follow the data contract's grammar ("1.250" is
712
+ 1250, "2,00" is 2, "1,5" is refused). The parser is a plain function: on the
713
+ server import it from `@handijitcom/ui`, not from the client subpath.
714
+
715
+ ### Application shell (3.2)
716
+
717
+ `AppShell` (`@handijitcom/ui/app-shell`) is the frame of a signed-in panel or
718
+ desktop program: a 232px sidebar that collapses to a 56px icon rail, a sticky
719
+ 52px top bar and the content. Below the tablet width the sidebar becomes a
720
+ `Drawer` opened by a menu button. It is presentational and router-agnostic:
721
+ links go through `UiProvider`'s `linkComponent` (Next's `Link`, an Electron
722
+ router link), the current page comes from `currentPath`.
723
+
724
+ ```tsx
725
+ <AppShell
726
+ brand={<Logo />}
727
+ navigation={
728
+ <AppShellNav
729
+ currentPath={pathname} // the longest matching href is the current page
730
+ sections={[
731
+ { id: 'main', items: [{ id: 'orders', label: 'Siparişler', href: '/orders', icon: <Cart />, badge: 3 }] },
732
+ {
733
+ id: 'stock',
734
+ label: 'Stok',
735
+ items: [
736
+ {
737
+ id: 'depot',
738
+ label: 'Depo',
739
+ icon: <Box />,
740
+ items: [{ id: 'transfers', label: 'Transferler', href: '/stock/transfers' }],
741
+ },
742
+ ],
743
+ },
744
+ ]}
745
+ />
746
+ }
747
+ title={<Breadcrumb items={crumbs} />}
748
+ search={<Input type="search" aria-label="Ara" />}
749
+ actions={
750
+ <>
751
+ <NotificationCenter items={notices} />
752
+ <UserMenu name={user.name} meta={user.role} items={accountItems} />
753
+ </>
754
+ }
755
+ isCollapsed={isCollapsed} // or uncontrolled with isDefaultCollapsed
756
+ onCollapsedChange={setCollapsed} // persist it yourself
757
+ >
758
+ {children}
759
+ </AppShell>
760
+ ```
761
+
762
+ - **Accessibility.** A skip link (it focuses `<main>` without touching the
763
+ address, so a hash router is safe), the `header`, `nav` and `main`
764
+ landmarks, `aria-current="page"` on the current link, groups as
765
+ `aria-expanded` buttons. On the icon rail the labels stay for screen
766
+ readers; a group clicked there expands the sidebar. Counts are read through
767
+ `labels.appShell.badge`.
768
+ - **Parts.** `AppShellNavItem` and `AppShellNavGroup` also compose by hand
769
+ (`<AppShellNav><AppShellNavItem … isActive /></AppShellNav>`); outside the
770
+ shell nothing is collapsed. A link in the drawer closes it.
771
+ - **Lengths on `<html>`.** `--app-sidebar-width` (232px, 56px collapsed, 0
772
+ below the tablet width; plain CSS) for the notices:
773
+ `<ToastPortal inset={{ inlineStart: 'var(--app-sidebar-width)' }} />`; and
774
+ `--ui-header-height`, the top bar's measured height, so sticky components
775
+ stop below it.
776
+ - Labels: `appShell.skipToContent`, `navigation`, `openNavigation`,
777
+ `collapse`, `expand`, `badge`, `userMenu` (provider or the `labels` prop).
778
+
580
779
  ### TypeScript resolution
581
780
 
582
781
  The declarations resolve under every `moduleResolution`: `bundler`, `node16`
@@ -1021,9 +1220,10 @@ npm run playground # component gallery → http://localhost:5273
1021
1220
  dropped name is **breaking** and surfaces as a build error at the consumer's
1022
1221
  next install. For a deliberate change: `npm run build`, then
1023
1222
  `node scripts/check-api.mjs --update`, and a line in the CHANGELOG.
1024
- - **Bundle size**: budgets in `.size-limit.js` (main entry 46 kB, `styles.css`
1025
- 25 kB gzip). When `size-limit` turns red, measure what was added before
1026
- raising a limit.
1223
+ - **Bundle size**: budgets in `.size-limit.js` (whole main entry 53.5 kB,
1224
+ `styles.css` 26 kB gzip; per import, e.g. `DataTable` alone 3 kB, with
1225
+ `DataTableColumnMenu` 7 kB). When `size-limit` turns red, measure what was
1226
+ added before raising a limit.
1027
1227
  - **Sub-entry boundary**: `chat` and `charts` import the main entry by PACKAGE
1028
1228
  NAME only (`subentry-boundary.test.ts`); a relative path would bundle a
1029
1229
  second copy of the provider context and the modal stack.
@@ -0,0 +1,2 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),v=require("react"),B=require("react-bootstrap-icons"),y=require("../../helpers/app-shell.helper.cjs"),f=require("../../helpers/class-name.helper.cjs"),b=require("../../helpers/component.helper.cjs"),A=require("../../helpers/label.helper.cjs"),G=require("../Link/index.cjs"),x=require("./context.cjs"),s={default:{"shell":"ui-shell-DdJz9","shell--collapsed":"ui-shell--collapsed-mBfej","srOnly":"ui-srOnly--wftu","shell__skip":"ui-shell__skip-hqzkw","shell__sidebar":"ui-shell__sidebar-59ryl","shell__brand":"ui-shell__brand-Mph-k","shell__navigation":"ui-shell__navigation-quAVK","shell__footer":"ui-shell__footer-gGr9S","shell__toggle":"ui-shell__toggle--vukn","shell__frame":"ui-shell__frame-4Cwe2","shell__topbar":"ui-shell__topbar-HH2s0","shell__menu-button":"ui-shell__menu-button-8CeT4","shell__title":"ui-shell__title--Z5jA","shell__search":"ui-shell__search-4Tij9","shell__actions":"ui-shell__actions-RU34x","shell__content":"ui-shell__content-nbbhQ","shell__drawer-brand":"ui-shell__drawer-brand-3MgNr","nav":"ui-nav-3I7Ws","nav__section-label":"ui-nav__section-label-0CMnM","nav__list":"ui-nav__list-Wotlu","nav__sublist":"ui-nav__sublist-8ut6O","nav__item":"ui-nav__item-RvDle","nav__item--active":"ui-nav__item--active-Lg028","nav__item--disabled":"ui-nav__item--disabled-CcOTO","nav__icon":"ui-nav__icon-NVN6X","nav__label":"ui-nav__label-nlEMg","nav__badge":"ui-nav__badge-aR8RE","nav__chevron":"ui-nav__chevron-ZrqW9","nav__chevron--open":"ui-nav__chevron--open-56sZo","nav__section":"ui-nav__section-hkG3J"}},j=99,S=({count:l})=>{const t=x.useAppShellLabels();return a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,className:s.default.nav__badge,children:l>j?`${j}+`:l}),a.jsxs("span",{className:s.default.srOnly,children:[", ",A.resolveFormatter("AppShell.labels.badge",t.badge,l)]})]})},M=({label:l,href:t,icon:u,badge:d,isActive:m=!1,isDisabled:_=!1,linkProps:n,className:r,testId:p})=>{const{isCollapsed:h,onNavigate:c}=x.useAppShell(),i=a.jsxs(a.Fragment,{children:[u&&a.jsx("span",{"aria-hidden":!0,className:s.default.nav__icon,children:u}),a.jsx("span",{className:s.default.nav__label,children:l}),d!==void 0&&d>0&&a.jsx(S,{count:d})]}),e=h?l:void 0;if(t===void 0||_)return a.jsx("li",{className:r,"data-testid":p,children:a.jsx("span",{className:f.cx(s.default.nav__item,s.default["nav__item--disabled"]),"aria-disabled":"true",title:e,children:i})});const o=I=>{var N;(N=n==null?void 0:n.onClick)==null||N.call(n,I),c==null||c()};return a.jsx("li",{className:r,"data-testid":p,children:a.jsx(G.default,{...n,href:t,className:f.cx(s.default.nav__item,m&&s.default["nav__item--active"]),"aria-current":m?"page":void 0,title:e,onClick:o,children:i})})},g=v.memo(b.named(M,"AppShellNavItem")),D=({label:l,icon:t,badge:u,hasActiveItem:d=!1,children:m,className:_,testId:n})=>{const{isCollapsed:r,onExpandSidebar:p}=x.useAppShell(),h=v.useId(),[c,i]=v.useState(d);v.useEffect(()=>{d&&i(!0)},[d]);const e=c&&!r,o=()=>{if(r){i(!0),p==null||p();return}i(!c)};return a.jsxs("li",{className:_,"data-testid":n,children:[a.jsxs("button",{type:"button",className:f.cx(s.default.nav__item,s.default["nav__item--group"],d&&r&&s.default["nav__item--active"]),"aria-expanded":e,"aria-controls":h,title:r?l:void 0,onClick:o,children:[t&&a.jsx("span",{"aria-hidden":!0,className:s.default.nav__icon,children:t}),a.jsx("span",{className:s.default.nav__label,children:l}),u!==void 0&&u>0&&a.jsx(S,{count:u}),a.jsx(B.ChevronDown,{"aria-hidden":!0,className:f.cx(s.default.nav__chevron,e&&s.default["nav__chevron--open"])})]}),a.jsx("ul",{id:h,className:s.default.nav__sublist,hidden:!e,children:m})]})},q=v.memo(b.named(D,"AppShellNavGroup")),C=l=>l.flatMap(t=>[...t.href!==void 0&&t.isActive===void 0?[t.href]:[],...C(t.items??[])]),L=({sections:l=[],currentPath:t,label:u,children:d,className:m,testId:_})=>{const n=x.useAppShellLabels(),r=v.useId(),p=v.useMemo(()=>y.findActiveHref(C(l.flatMap(e=>e.items)),t),[l,t]),h=e=>e.isActive??(e.href!==void 0&&e.href===p),c=e=>(e.items??[]).some(o=>h(o)||c(o)),i=e=>e.items&&e.items.length>0?a.jsx(q,{label:e.label,icon:e.icon,badge:e.badge,hasActiveItem:c(e),children:e.items.map(i)},e.id):a.jsx(g,{label:e.label,href:e.href,icon:e.icon,badge:e.badge,isActive:h(e),isDisabled:e.isDisabled,linkProps:e.linkProps},e.id);return a.jsxs("nav",{"aria-label":A.resolveLabel("AppShellNav.label",u,n.navigation),className:f.cx(s.default.nav,m),"data-testid":_,children:[l.map(e=>{const o=`${r}-${e.id}`;return a.jsxs("div",{className:s.default.nav__section,role:e.label?"group":void 0,"aria-labelledby":e.label?o:void 0,children:[e.label&&a.jsx("p",{id:o,className:s.default["nav__section-label"],children:e.label}),a.jsx("ul",{className:s.default.nav__list,children:e.items.map(i)})]},e.id)}),d&&a.jsx("ul",{className:s.default.nav__list,children:d})]})},E=v.memo(b.named(L,"AppShellNav"));exports.AppShellNav=E;exports.AppShellNavGroup=q;exports.AppShellNavItem=g;
2
+ //# sourceMappingURL=Nav.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.cjs","sources":["../../../src/components/AppShell/Nav.tsx"],"sourcesContent":["'use client';\n\nimport { type MouseEvent, type ReactNode, memo, useEffect, useId, useMemo, useState } from 'react';\n\nimport { ChevronDown } from 'react-bootstrap-icons';\n\nimport { findActiveHref } from '../../helpers/app-shell.helper';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport type { UiLinkExtraProps } from '../../types/link.type';\nimport UiLink from '../Link';\nimport { useAppShell, useAppShellLabels } from './context';\n\nimport styles from './index.module.scss';\n\n/** One entry of `AppShellNav`'s data: a link, or a collapsible group when it has `items`. */\nexport type AppShellNavLink = {\n id: string;\n label: string;\n /** Without it the entry is a passive row (a screen that is not there yet). */\n href?: string;\n icon?: ReactNode;\n /** A count drawn at the end of the row (and at the icon's corner on the icon rail). */\n badge?: number;\n /** Overrides the `currentPath` match for this entry. */\n isActive?: boolean;\n isDisabled?: boolean;\n /** Nested links: the entry becomes a group that opens and closes. */\n items?: AppShellNavLink[];\n /** Extra props for the router's link component. */\n linkProps?: UiLinkExtraProps;\n};\n\n/** A titled block of entries (\"Satış\", \"Raporlar\"). */\nexport type AppShellNavSection = {\n id: string;\n /** Shown above the entries; read as the group's name. */\n label?: string;\n items: AppShellNavLink[];\n};\n\n/* Above this the badge reads \"99+\": a wider badge pushes the label out. */\nconst BADGE_MAX = 99;\n\nconst CountBadge = ({ count }: { count: number }) => {\n const labels = useAppShellLabels();\n\n return (\n <>\n <span aria-hidden className={styles.nav__badge}>\n {count > BADGE_MAX ? `${BADGE_MAX}+` : count}\n </span>\n <span className={styles.srOnly}>\n {', '}\n {resolveFormatter('AppShell.labels.badge', labels.badge, count)}\n </span>\n </>\n );\n};\n\nexport type AppShellNavItemProps = {\n label: string;\n /** Without it (or with `isDisabled`) the row is passive. */\n href?: string;\n icon?: ReactNode;\n badge?: number;\n /** The current page: drawn as selected and read as `aria-current=\"page\"`. */\n isActive?: boolean;\n isDisabled?: boolean;\n linkProps?: UiLinkExtraProps;\n className?: string;\n testId?: string;\n};\n\n/** One navigation row: icon, label, count. Rendered through the provider's link component. */\nconst AppShellNavItemBase = ({\n label,\n href,\n icon,\n badge,\n isActive = false,\n isDisabled = false,\n linkProps,\n className,\n testId,\n}: AppShellNavItemProps) => {\n const { isCollapsed, onNavigate } = useAppShell();\n\n const content = (\n <>\n {icon && (\n <span aria-hidden className={styles.nav__icon}>\n {icon}\n </span>\n )}\n <span className={styles.nav__label}>{label}</span>\n {badge !== undefined && badge > 0 && <CountBadge count={badge} />}\n </>\n );\n\n /* On the icon rail the label is hidden: the native tooltip names the icon for the pointer. */\n const title = isCollapsed ? label : undefined;\n\n if (href === undefined || isDisabled)\n return (\n <li className={className} data-testid={testId}>\n <span\n className={cx(styles.nav__item, styles['nav__item--disabled'])}\n aria-disabled=\"true\"\n title={title}\n >\n {content}\n </span>\n </li>\n );\n\n const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {\n (linkProps?.onClick as ((event: MouseEvent<HTMLAnchorElement>) => void) | undefined)?.(event);\n onNavigate?.();\n };\n\n return (\n <li className={className} data-testid={testId}>\n <UiLink\n {...linkProps}\n href={href}\n className={cx(styles.nav__item, isActive && styles['nav__item--active'])}\n aria-current={isActive ? 'page' : undefined}\n title={title}\n onClick={handleClick}\n >\n {content}\n </UiLink>\n </li>\n );\n};\n\nexport const AppShellNavItem = /*#__PURE__*/ memo(\n /*#__PURE__*/ named(AppShellNavItemBase, 'AppShellNavItem'),\n) as typeof AppShellNavItemBase;\n\nexport type AppShellNavGroupProps = {\n label: string;\n icon?: ReactNode;\n badge?: number;\n /**\n * The current page is one of its links: the group opens (at first, and whenever this turns true)\n * and its row is marked on the icon rail.\n */\n hasActiveItem?: boolean;\n /** `AppShellNavItem`s (or nested groups). */\n children: ReactNode;\n className?: string;\n testId?: string;\n};\n\n/** A row that opens and closes a nested list of links. */\nconst AppShellNavGroupBase = ({\n label,\n icon,\n badge,\n hasActiveItem = false,\n children,\n className,\n testId,\n}: AppShellNavGroupProps) => {\n const { isCollapsed, onExpandSidebar } = useAppShell();\n const listId = useId();\n const [isExpanded, setIsExpanded] = useState(hasActiveItem);\n\n /* The page moved into the group (a link elsewhere, the browser's back button): show it. */\n useEffect(() => {\n if (hasActiveItem) setIsExpanded(true);\n }, [hasActiveItem]);\n\n /* The icon rail has no room for nested links: the list is closed there whatever the state. */\n const isOpen = isExpanded && !isCollapsed;\n\n const handleClick = () => {\n if (isCollapsed) {\n setIsExpanded(true);\n onExpandSidebar?.();\n return;\n }\n setIsExpanded(!isExpanded);\n };\n\n return (\n <li className={className} data-testid={testId}>\n <button\n type=\"button\"\n className={cx(\n styles.nav__item,\n styles['nav__item--group'],\n hasActiveItem && isCollapsed && styles['nav__item--active'],\n )}\n aria-expanded={isOpen}\n aria-controls={listId}\n title={isCollapsed ? label : undefined}\n onClick={handleClick}\n >\n {icon && (\n <span aria-hidden className={styles.nav__icon}>\n {icon}\n </span>\n )}\n <span className={styles.nav__label}>{label}</span>\n {badge !== undefined && badge > 0 && <CountBadge count={badge} />}\n <ChevronDown\n aria-hidden\n className={cx(styles.nav__chevron, isOpen && styles['nav__chevron--open'])}\n />\n </button>\n <ul id={listId} className={styles.nav__sublist} hidden={!isOpen}>\n {children}\n </ul>\n </li>\n );\n};\n\nexport const AppShellNavGroup = /*#__PURE__*/ memo(\n /*#__PURE__*/ named(AppShellNavGroupBase, 'AppShellNavGroup'),\n) as typeof AppShellNavGroupBase;\n\nconst linkHrefs = (links: readonly AppShellNavLink[]): string[] =>\n links.flatMap(link => [\n ...(link.href !== undefined && link.isActive === undefined ? [link.href] : []),\n ...linkHrefs(link.items ?? []),\n ]);\n\nexport type AppShellNavProps = {\n /** Titled blocks of links. */\n sections?: AppShellNavSection[];\n /** The router's current path: the longest matching `href` is the current page. */\n currentPath?: string;\n /** The landmark's name; `labels.appShell.navigation` by default. */\n label?: string;\n /** Your own `AppShellNavItem` / `AppShellNavGroup` rows, after the sections. */\n children?: ReactNode;\n className?: string;\n testId?: string;\n};\n\n/** The sidebar's `<nav>`: sections of links with icons, counts and nested groups. */\nconst AppShellNavBase = ({\n sections = [],\n currentPath,\n label,\n children,\n className,\n testId,\n}: AppShellNavProps) => {\n const labels = useAppShellLabels();\n const baseId = useId();\n\n const activeHref = useMemo(\n () => findActiveHref(linkHrefs(sections.flatMap(section => section.items)), currentPath),\n [sections, currentPath],\n );\n\n const isActive = (link: AppShellNavLink): boolean =>\n link.isActive ?? (link.href !== undefined && link.href === activeHref);\n\n const containsActive = (link: AppShellNavLink): boolean =>\n (link.items ?? []).some(child => isActive(child) || containsActive(child));\n\n const renderLink = (link: AppShellNavLink): ReactNode =>\n link.items && link.items.length > 0 ? (\n <AppShellNavGroup\n key={link.id}\n label={link.label}\n icon={link.icon}\n badge={link.badge}\n hasActiveItem={containsActive(link)}\n >\n {link.items.map(renderLink)}\n </AppShellNavGroup>\n ) : (\n <AppShellNavItem\n key={link.id}\n label={link.label}\n href={link.href}\n icon={link.icon}\n badge={link.badge}\n isActive={isActive(link)}\n isDisabled={link.isDisabled}\n linkProps={link.linkProps}\n />\n );\n\n return (\n <nav\n aria-label={resolveLabel('AppShellNav.label', label, labels.navigation)}\n className={cx(styles.nav, className)}\n data-testid={testId}\n >\n {sections.map(section => {\n const headingId = `${baseId}-${section.id}`;\n\n return (\n <div\n key={section.id}\n className={styles.nav__section}\n role={section.label ? 'group' : undefined}\n aria-labelledby={section.label ? headingId : undefined}\n >\n {section.label && (\n <p id={headingId} className={styles['nav__section-label']}>\n {section.label}\n </p>\n )}\n <ul className={styles.nav__list}>{section.items.map(renderLink)}</ul>\n </div>\n );\n })}\n {children && <ul className={styles.nav__list}>{children}</ul>}\n </nav>\n );\n};\n\nexport const AppShellNav = /*#__PURE__*/ memo(\n /*#__PURE__*/ named(AppShellNavBase, 'AppShellNav'),\n) as typeof AppShellNavBase;\n"],"names":["BADGE_MAX","CountBadge","count","labels","useAppShellLabels","jsxs","Fragment","jsx","styles","resolveFormatter","AppShellNavItemBase","label","href","icon","badge","isActive","isDisabled","linkProps","className","testId","isCollapsed","onNavigate","useAppShell","content","title","cx","handleClick","event","_a","UiLink","AppShellNavItem","memo","named","AppShellNavGroupBase","hasActiveItem","children","onExpandSidebar","listId","useId","isExpanded","setIsExpanded","useState","useEffect","isOpen","ChevronDown","AppShellNavGroup","linkHrefs","links","link","AppShellNavBase","sections","currentPath","baseId","activeHref","useMemo","findActiveHref","section","containsActive","child","renderLink","resolveLabel","headingId","AppShellNav"],"mappings":"odA0CMA,EA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,CAG9D,EAEa2B,EAA4B/B,EAAAA,KACzBC,EAAAA,MAAMiB,EAAiB,aAAa,CACpD"}
@@ -0,0 +1,75 @@
1
+ import { ReactNode } from 'react';
2
+ import { UiLinkExtraProps } from '../../types/link.type.cjs';
3
+ /** One entry of `AppShellNav`'s data: a link, or a collapsible group when it has `items`. */
4
+ export type AppShellNavLink = {
5
+ id: string;
6
+ label: string;
7
+ /** Without it the entry is a passive row (a screen that is not there yet). */
8
+ href?: string;
9
+ icon?: ReactNode;
10
+ /** A count drawn at the end of the row (and at the icon's corner on the icon rail). */
11
+ badge?: number;
12
+ /** Overrides the `currentPath` match for this entry. */
13
+ isActive?: boolean;
14
+ isDisabled?: boolean;
15
+ /** Nested links: the entry becomes a group that opens and closes. */
16
+ items?: AppShellNavLink[];
17
+ /** Extra props for the router's link component. */
18
+ linkProps?: UiLinkExtraProps;
19
+ };
20
+ /** A titled block of entries ("Satış", "Raporlar"). */
21
+ export type AppShellNavSection = {
22
+ id: string;
23
+ /** Shown above the entries; read as the group's name. */
24
+ label?: string;
25
+ items: AppShellNavLink[];
26
+ };
27
+ export type AppShellNavItemProps = {
28
+ label: string;
29
+ /** Without it (or with `isDisabled`) the row is passive. */
30
+ href?: string;
31
+ icon?: ReactNode;
32
+ badge?: number;
33
+ /** The current page: drawn as selected and read as `aria-current="page"`. */
34
+ isActive?: boolean;
35
+ isDisabled?: boolean;
36
+ linkProps?: UiLinkExtraProps;
37
+ className?: string;
38
+ testId?: string;
39
+ };
40
+ /** One navigation row: icon, label, count. Rendered through the provider's link component. */
41
+ declare const AppShellNavItemBase: ({ label, href, icon, badge, isActive, isDisabled, linkProps, className, testId, }: AppShellNavItemProps) => import("react").JSX.Element;
42
+ export declare const AppShellNavItem: typeof AppShellNavItemBase;
43
+ export type AppShellNavGroupProps = {
44
+ label: string;
45
+ icon?: ReactNode;
46
+ badge?: number;
47
+ /**
48
+ * The current page is one of its links: the group opens (at first, and whenever this turns true)
49
+ * and its row is marked on the icon rail.
50
+ */
51
+ hasActiveItem?: boolean;
52
+ /** `AppShellNavItem`s (or nested groups). */
53
+ children: ReactNode;
54
+ className?: string;
55
+ testId?: string;
56
+ };
57
+ /** A row that opens and closes a nested list of links. */
58
+ declare const AppShellNavGroupBase: ({ label, icon, badge, hasActiveItem, children, className, testId, }: AppShellNavGroupProps) => import("react").JSX.Element;
59
+ export declare const AppShellNavGroup: typeof AppShellNavGroupBase;
60
+ export type AppShellNavProps = {
61
+ /** Titled blocks of links. */
62
+ sections?: AppShellNavSection[];
63
+ /** The router's current path: the longest matching `href` is the current page. */
64
+ currentPath?: string;
65
+ /** The landmark's name; `labels.appShell.navigation` by default. */
66
+ label?: string;
67
+ /** Your own `AppShellNavItem` / `AppShellNavGroup` rows, after the sections. */
68
+ children?: ReactNode;
69
+ className?: string;
70
+ testId?: string;
71
+ };
72
+ /** The sidebar's `<nav>`: sections of links with icons, counts and nested groups. */
73
+ declare const AppShellNavBase: ({ sections, currentPath, label, children, className, testId, }: AppShellNavProps) => import("react").JSX.Element;
74
+ export declare const AppShellNav: typeof AppShellNavBase;
75
+ export {};
@@ -0,0 +1,75 @@
1
+ import { ReactNode } from 'react';
2
+ import { UiLinkExtraProps } from '../../types/link.type.js';
3
+ /** One entry of `AppShellNav`'s data: a link, or a collapsible group when it has `items`. */
4
+ export type AppShellNavLink = {
5
+ id: string;
6
+ label: string;
7
+ /** Without it the entry is a passive row (a screen that is not there yet). */
8
+ href?: string;
9
+ icon?: ReactNode;
10
+ /** A count drawn at the end of the row (and at the icon's corner on the icon rail). */
11
+ badge?: number;
12
+ /** Overrides the `currentPath` match for this entry. */
13
+ isActive?: boolean;
14
+ isDisabled?: boolean;
15
+ /** Nested links: the entry becomes a group that opens and closes. */
16
+ items?: AppShellNavLink[];
17
+ /** Extra props for the router's link component. */
18
+ linkProps?: UiLinkExtraProps;
19
+ };
20
+ /** A titled block of entries ("Satış", "Raporlar"). */
21
+ export type AppShellNavSection = {
22
+ id: string;
23
+ /** Shown above the entries; read as the group's name. */
24
+ label?: string;
25
+ items: AppShellNavLink[];
26
+ };
27
+ export type AppShellNavItemProps = {
28
+ label: string;
29
+ /** Without it (or with `isDisabled`) the row is passive. */
30
+ href?: string;
31
+ icon?: ReactNode;
32
+ badge?: number;
33
+ /** The current page: drawn as selected and read as `aria-current="page"`. */
34
+ isActive?: boolean;
35
+ isDisabled?: boolean;
36
+ linkProps?: UiLinkExtraProps;
37
+ className?: string;
38
+ testId?: string;
39
+ };
40
+ /** One navigation row: icon, label, count. Rendered through the provider's link component. */
41
+ declare const AppShellNavItemBase: ({ label, href, icon, badge, isActive, isDisabled, linkProps, className, testId, }: AppShellNavItemProps) => import("react").JSX.Element;
42
+ export declare const AppShellNavItem: typeof AppShellNavItemBase;
43
+ export type AppShellNavGroupProps = {
44
+ label: string;
45
+ icon?: ReactNode;
46
+ badge?: number;
47
+ /**
48
+ * The current page is one of its links: the group opens (at first, and whenever this turns true)
49
+ * and its row is marked on the icon rail.
50
+ */
51
+ hasActiveItem?: boolean;
52
+ /** `AppShellNavItem`s (or nested groups). */
53
+ children: ReactNode;
54
+ className?: string;
55
+ testId?: string;
56
+ };
57
+ /** A row that opens and closes a nested list of links. */
58
+ declare const AppShellNavGroupBase: ({ label, icon, badge, hasActiveItem, children, className, testId, }: AppShellNavGroupProps) => import("react").JSX.Element;
59
+ export declare const AppShellNavGroup: typeof AppShellNavGroupBase;
60
+ export type AppShellNavProps = {
61
+ /** Titled blocks of links. */
62
+ sections?: AppShellNavSection[];
63
+ /** The router's current path: the longest matching `href` is the current page. */
64
+ currentPath?: string;
65
+ /** The landmark's name; `labels.appShell.navigation` by default. */
66
+ label?: string;
67
+ /** Your own `AppShellNavItem` / `AppShellNavGroup` rows, after the sections. */
68
+ children?: ReactNode;
69
+ className?: string;
70
+ testId?: string;
71
+ };
72
+ /** The sidebar's `<nav>`: sections of links with icons, counts and nested groups. */
73
+ declare const AppShellNavBase: ({ sections, currentPath, label, children, className, testId, }: AppShellNavProps) => import("react").JSX.Element;
74
+ export declare const AppShellNav: typeof AppShellNavBase;
75
+ export {};
@@ -0,0 +1,189 @@
1
+ "use client";
2
+ import { jsxs as h, jsx as s, Fragment as g } from "react/jsx-runtime";
3
+ import { memo as b, useId as C, useMemo as G, useState as L, useEffect as M } from "react";
4
+ import { ChevronDown as E } from "react-bootstrap-icons";
5
+ import { findActiveHref as H } from "../../helpers/app-shell.helper.js";
6
+ import { cx as f } from "../../helpers/class-name.helper.js";
7
+ import { named as N } from "../../helpers/component.helper.js";
8
+ import { resolveLabel as $, resolveFormatter as j } from "../../helpers/label.helper.js";
9
+ import F from "../Link/index.js";
10
+ import { useAppShellLabels as x, useAppShell as B } from "./context.js";
11
+ const a = {"shell":"ui-shell-DdJz9","shell--collapsed":"ui-shell--collapsed-mBfej","srOnly":"ui-srOnly--wftu","shell__skip":"ui-shell__skip-hqzkw","shell__sidebar":"ui-shell__sidebar-59ryl","shell__brand":"ui-shell__brand-Mph-k","shell__navigation":"ui-shell__navigation-quAVK","shell__footer":"ui-shell__footer-gGr9S","shell__toggle":"ui-shell__toggle--vukn","shell__frame":"ui-shell__frame-4Cwe2","shell__topbar":"ui-shell__topbar-HH2s0","shell__menu-button":"ui-shell__menu-button-8CeT4","shell__title":"ui-shell__title--Z5jA","shell__search":"ui-shell__search-4Tij9","shell__actions":"ui-shell__actions-RU34x","shell__content":"ui-shell__content-nbbhQ","shell__drawer-brand":"ui-shell__drawer-brand-3MgNr","nav":"ui-nav-3I7Ws","nav__section-label":"ui-nav__section-label-0CMnM","nav__list":"ui-nav__list-Wotlu","nav__sublist":"ui-nav__sublist-8ut6O","nav__item":"ui-nav__item-RvDle","nav__item--active":"ui-nav__item--active-Lg028","nav__item--disabled":"ui-nav__item--disabled-CcOTO","nav__icon":"ui-nav__icon-NVN6X","nav__label":"ui-nav__label-nlEMg","nav__badge":"ui-nav__badge-aR8RE","nav__chevron":"ui-nav__chevron-ZrqW9","nav__chevron--open":"ui-nav__chevron--open-56sZo","nav__section":"ui-nav__section-hkG3J"};
12
+ const S = 99, I = ({ count: l }) => {
13
+ const t = x();
14
+ return /* @__PURE__ */ h(g, { children: [
15
+ /* @__PURE__ */ s("span", { "aria-hidden": !0, className: a.nav__badge, children: l > S ? `${S}+` : l }),
16
+ /* @__PURE__ */ h("span", { className: a.srOnly, children: [
17
+ ", ",
18
+ j("AppShell.labels.badge", t.badge, l)
19
+ ] })
20
+ ] });
21
+ }, O = ({
22
+ label: l,
23
+ href: t,
24
+ icon: m,
25
+ badge: i,
26
+ isActive: _ = !1,
27
+ isDisabled: u = !1,
28
+ linkProps: r,
29
+ className: n,
30
+ testId: p
31
+ }) => {
32
+ const { isCollapsed: v, onNavigate: d } = B(), o = /* @__PURE__ */ h(g, { children: [
33
+ m && /* @__PURE__ */ s("span", { "aria-hidden": !0, className: a.nav__icon, children: m }),
34
+ /* @__PURE__ */ s("span", { className: a.nav__label, children: l }),
35
+ i !== void 0 && i > 0 && /* @__PURE__ */ s(I, { count: i })
36
+ ] }), e = v ? l : void 0;
37
+ if (t === void 0 || u)
38
+ return /* @__PURE__ */ s("li", { className: n, "data-testid": p, children: /* @__PURE__ */ s(
39
+ "span",
40
+ {
41
+ className: f(a.nav__item, a["nav__item--disabled"]),
42
+ "aria-disabled": "true",
43
+ title: e,
44
+ children: o
45
+ }
46
+ ) });
47
+ const c = (D) => {
48
+ var A;
49
+ (A = r == null ? void 0 : r.onClick) == null || A.call(r, D), d == null || d();
50
+ };
51
+ return /* @__PURE__ */ s("li", { className: n, "data-testid": p, children: /* @__PURE__ */ s(
52
+ F,
53
+ {
54
+ ...r,
55
+ href: t,
56
+ className: f(a.nav__item, _ && a["nav__item--active"]),
57
+ "aria-current": _ ? "page" : void 0,
58
+ title: e,
59
+ onClick: c,
60
+ children: o
61
+ }
62
+ ) });
63
+ }, w = /* @__PURE__ */ b(
64
+ /* @__PURE__ */ N(O, "AppShellNavItem")
65
+ ), U = ({
66
+ label: l,
67
+ icon: t,
68
+ badge: m,
69
+ hasActiveItem: i = !1,
70
+ children: _,
71
+ className: u,
72
+ testId: r
73
+ }) => {
74
+ const { isCollapsed: n, onExpandSidebar: p } = B(), v = C(), [d, o] = L(i);
75
+ M(() => {
76
+ i && o(!0);
77
+ }, [i]);
78
+ const e = d && !n, c = () => {
79
+ if (n) {
80
+ o(!0), p == null || p();
81
+ return;
82
+ }
83
+ o(!d);
84
+ };
85
+ return /* @__PURE__ */ h("li", { className: u, "data-testid": r, children: [
86
+ /* @__PURE__ */ h(
87
+ "button",
88
+ {
89
+ type: "button",
90
+ className: f(
91
+ a.nav__item,
92
+ a["nav__item--group"],
93
+ i && n && a["nav__item--active"]
94
+ ),
95
+ "aria-expanded": e,
96
+ "aria-controls": v,
97
+ title: n ? l : void 0,
98
+ onClick: c,
99
+ children: [
100
+ t && /* @__PURE__ */ s("span", { "aria-hidden": !0, className: a.nav__icon, children: t }),
101
+ /* @__PURE__ */ s("span", { className: a.nav__label, children: l }),
102
+ m !== void 0 && m > 0 && /* @__PURE__ */ s(I, { count: m }),
103
+ /* @__PURE__ */ s(
104
+ E,
105
+ {
106
+ "aria-hidden": !0,
107
+ className: f(a.nav__chevron, e && a["nav__chevron--open"])
108
+ }
109
+ )
110
+ ]
111
+ }
112
+ ),
113
+ /* @__PURE__ */ s("ul", { id: v, className: a.nav__sublist, hidden: !e, children: _ })
114
+ ] });
115
+ }, X = /* @__PURE__ */ b(
116
+ /* @__PURE__ */ N(U, "AppShellNavGroup")
117
+ ), y = (l) => l.flatMap((t) => [
118
+ ...t.href !== void 0 && t.isActive === void 0 ? [t.href] : [],
119
+ ...y(t.items ?? [])
120
+ ]), q = ({
121
+ sections: l = [],
122
+ currentPath: t,
123
+ label: m,
124
+ children: i,
125
+ className: _,
126
+ testId: u
127
+ }) => {
128
+ const r = x(), n = C(), p = G(
129
+ () => H(y(l.flatMap((e) => e.items)), t),
130
+ [l, t]
131
+ ), v = (e) => e.isActive ?? (e.href !== void 0 && e.href === p), d = (e) => (e.items ?? []).some((c) => v(c) || d(c)), o = (e) => e.items && e.items.length > 0 ? /* @__PURE__ */ s(
132
+ X,
133
+ {
134
+ label: e.label,
135
+ icon: e.icon,
136
+ badge: e.badge,
137
+ hasActiveItem: d(e),
138
+ children: e.items.map(o)
139
+ },
140
+ e.id
141
+ ) : /* @__PURE__ */ s(
142
+ w,
143
+ {
144
+ label: e.label,
145
+ href: e.href,
146
+ icon: e.icon,
147
+ badge: e.badge,
148
+ isActive: v(e),
149
+ isDisabled: e.isDisabled,
150
+ linkProps: e.linkProps
151
+ },
152
+ e.id
153
+ );
154
+ return /* @__PURE__ */ h(
155
+ "nav",
156
+ {
157
+ "aria-label": $("AppShellNav.label", m, r.navigation),
158
+ className: f(a.nav, _),
159
+ "data-testid": u,
160
+ children: [
161
+ l.map((e) => {
162
+ const c = `${n}-${e.id}`;
163
+ return /* @__PURE__ */ h(
164
+ "div",
165
+ {
166
+ className: a.nav__section,
167
+ role: e.label ? "group" : void 0,
168
+ "aria-labelledby": e.label ? c : void 0,
169
+ children: [
170
+ e.label && /* @__PURE__ */ s("p", { id: c, className: a["nav__section-label"], children: e.label }),
171
+ /* @__PURE__ */ s("ul", { className: a.nav__list, children: e.items.map(o) })
172
+ ]
173
+ },
174
+ e.id
175
+ );
176
+ }),
177
+ i && /* @__PURE__ */ s("ul", { className: a.nav__list, children: i })
178
+ ]
179
+ }
180
+ );
181
+ }, P = /* @__PURE__ */ b(
182
+ /* @__PURE__ */ N(q, "AppShellNav")
183
+ );
184
+ export {
185
+ P as AppShellNav,
186
+ X as AppShellNavGroup,
187
+ w as AppShellNavItem
188
+ };
189
+ //# sourceMappingURL=Nav.js.map