@handijitcom/ui 3.1.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 (56) hide show
  1. package/README.md +74 -0
  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/Drawer/index.cjs +1 -1
  26. package/build/components/Drawer/index.cjs.map +1 -1
  27. package/build/components/Drawer/index.js +33 -33
  28. package/build/components/Drawer/index.js.map +1 -1
  29. package/build/components/Menu/index.cjs +1 -1
  30. package/build/components/Menu/index.cjs.map +1 -1
  31. package/build/components/Menu/index.js +48 -48
  32. package/build/components/Menu/index.js.map +1 -1
  33. package/build/components/UserMenu/index.cjs +2 -0
  34. package/build/components/UserMenu/index.cjs.map +1 -0
  35. package/build/components/UserMenu/index.d.cts +21 -0
  36. package/build/components/UserMenu/index.d.ts +21 -0
  37. package/build/components/UserMenu/index.js +36 -0
  38. package/build/components/UserMenu/index.js.map +1 -0
  39. package/build/components/UserMenu/style.css +1 -0
  40. package/build/helpers/app-shell.helper.cjs +2 -0
  41. package/build/helpers/app-shell.helper.cjs.map +1 -0
  42. package/build/helpers/app-shell.helper.d.cts +12 -0
  43. package/build/helpers/app-shell.helper.d.ts +12 -0
  44. package/build/helpers/app-shell.helper.js +18 -0
  45. package/build/helpers/app-shell.helper.js.map +1 -0
  46. package/build/index.cjs +1 -1
  47. package/build/index.d.cts +2 -0
  48. package/build/index.d.ts +2 -0
  49. package/build/index.js +91 -83
  50. package/build/index.js.map +1 -1
  51. package/build/styles.css +6 -0
  52. package/build/types/theme.type.d.cts +17 -0
  53. package/build/types/theme.type.d.ts +17 -0
  54. package/build/types/types/theme.type.d.cts +17 -0
  55. package/build/types/types/theme.type.d.ts +17 -0
  56. package/package.json +21 -1
package/README.md CHANGED
@@ -308,6 +308,15 @@ either. Labels are given **once**, on the provider:
308
308
  today: 'Bugün',
309
309
  yesterday: 'Dün',
310
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
+ },
311
320
  bulkPaste: {
312
321
  summary: count => `${count} satır okundu`,
313
322
  invalidSummary: count => `${count} satır okunamadı`,
@@ -418,6 +427,7 @@ and changes when an announcement strip appears.
418
427
  | Surface | `Card` (+ `CardMedia`, `CardOverlay`, `CardBody`, `CardFooter`) · `SummaryCard` · `Panel` (+ `PanelForm`, `PanelRow`) · `PageHeader` · `SectionHeader` · `Tile` · `Directory` (+ `DirectoryGroup`, `DirectoryRow`, `DirectoryJump`) · `Carousel` · `Gallery` · `ScrollArea` · `Disclosure` · `Accordion` · `Tabs` |
419
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` |
420
429
  | Brand surface (3.0) | `BrandSurface` (+ `BrandBlueprint`) · `Eyebrow` · `StatStrip` |
430
+ | Shell (3.2) | `AppShell` (+ `AppShellNav`, `AppShellNavGroup`, `AppShellNavItem`) · `UserMenu` |
421
431
  | Modal | `Modal` · `Drawer` · `BottomSheet` · `ConfirmDialog` · `PromptDialog` · `CommandPalette` |
422
432
  | Data | `Table` (+ `TableScroller`) · `DataTable` (+ `DataTableRow`, `DataTableColumnMenu`) · `FilterBar` (+ `FilterBarField`) · `Pagination` · `Timeline` |
423
433
  | Theme and hooks | `UiProvider` · `UiThemeScript` · `useUi` · `useUiTheme` · `useUiTokens` · `useAnnounce` · `useStickToBottom` · `usePositioning` · `useVirtualList` · `useListboxNavigation` · `hasOpenSurface` |
@@ -702,6 +712,70 @@ code per line. Quantities follow the data contract's grammar ("1.250" is
702
712
  1250, "2,00" is 2, "1,5" is refused). The parser is a plain function: on the
703
713
  server import it from `@handijitcom/ui`, not from the client subpath.
704
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
+
705
779
  ### TypeScript resolution
706
780
 
707
781
  The declarations resolve under every `moduleResolution`: `bundler`, `node16`
@@ -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,EAAY,GAEZC,EAAa,CAAC,CAAE,MAAAC,KAA+B,CACnD,MAAMC,EAASC,EAAAA,kBAAA,E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@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.js","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":";;;;;;;;;;;AA0CA,MAAMA,IAAY,IAEZC,IAAa,CAAC,EAAE,OAAAC,QAA+B;AACnD,QAAMC,IAASC,EAAA;AAEf,SACE,gBAAAC,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAC,EAAC,QAAA,EAAK,eAAW,IAAC,WAAWC,EAAO,YACjC,UAAAN,IAAQF,IAAY,GAAGA,CAAS,MAAME,GACzC;AAAA,IACA,gBAAAG,EAAC,QAAA,EAAK,WAAWG,EAAO,QACrB,UAAA;AAAA,MAAA;AAAA,MACAC,EAAiB,yBAAyBN,EAAO,OAAOD,CAAK;AAAA,IAAA,EAAA,CAChE;AAAA,EAAA,GACF;AAEJ,GAiBMQ,IAAsB,CAAC;AAAA,EAC3B,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,YAAAC,IAAa;AAAA,EACb,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC;AACF,MAA4B;AAC1B,QAAM,EAAE,aAAAC,GAAa,YAAAC,EAAA,IAAeC,EAAA,GAE9BC,IACJ,gBAAAlB,EAAAC,GAAA,EACG,UAAA;AAAA,IAAAO,uBACE,QAAA,EAAK,eAAW,IAAC,WAAWL,EAAO,WACjC,UAAAK,EAAA,CACH;AAAA,IAEF,gBAAAN,EAAC,QAAA,EAAK,WAAWC,EAAO,YAAa,UAAAG,GAAM;AAAA,IAC1CG,MAAU,UAAaA,IAAQ,KAAK,gBAAAP,EAACN,GAAA,EAAW,OAAOa,EAAA,CAAO;AAAA,EAAA,GACjE,GAIIU,IAAQJ,IAAcT,IAAQ;AAEpC,MAAIC,MAAS,UAAaI;AACxB,WACE,gBAAAT,EAAC,MAAA,EAAG,WAAAW,GAAsB,eAAaC,GACrC,UAAA,gBAAAZ;AAAA,MAAC;AAAA,MAAA;A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E,WAAWsB,EAAGjB,EAAO,KAAKU,CAAS;AAAA,MACnC,eAAaC;AAAA,MAEZ,UAAA;AAAA,QAAA+B,EAAS,IAAI,CAAAM,MAAW;AACvB,gBAAMK,IAAY,GAAGT,CAAM,IAAII,EAAQ,EAAE;AAEzC,iBACE,gBAAAnD;AAAA,YAAC;AAAA,YAAA;AAAA,cAEC,WAAWG,EAAO;AAAA,cAClB,MAAMgD,EAAQ,QAAQ,UAAU;AAAA,cAChC,mBAAiBA,EAAQ,QAAQK,IAAY;AAAA,cAE5C,UAAA;AAAA,gBAAAL,EAAQ,SACP,gBAAAjD,EAAC,KAAA,EAAE,IAAIsD,GAAW,WAAWrD,EAAO,oBAAoB,GACrD,UAAAgD,EAAQ,MAAA,CACX;AAAA,gBAEF,gBAAAjD,EAAC,QAAG,WAAWC,EAAO,WAAY,UAAAgD,EAAQ,MAAM,IAAIG,CAAU,EAAA,CAAE;AAAA,cAAA;AAAA,YAAA;AAAA,YAV3DH,EAAQ;AAAA,UAAA;AAAA,QAanB,CAAC;AAAA,QACArB,KAAY,gBAAA5B,EAAC,MAAA,EAAG,WAAWC,EAAO,WAAY,UAAA2B,EAAA,CAAS;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG9D,GAEa2B,IAA4B,gBAAA/B;AAAA,EACzB,gBAAAC,EAAMiB,GAAiB,aAAa;AACpD;"}
@@ -0,0 +1,2 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react"),o=require("../../theme/context.cjs"),t=l.createContext({isCollapsed:!1}),s=()=>l.useContext(t),n=()=>{const{labels:e}=o.useUi(),{labels:u}=s();return{...e==null?void 0:e.appShell,...u}};exports.default=t;exports.useAppShell=s;exports.useAppShellLabels=n;
2
+ //# sourceMappingURL=context.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.cjs","sources":["../../../src/components/AppShell/context.ts"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\n\nexport type AppShellLabels = {\n skipToContent: string;\n navigation: string;\n openNavigation: string;\n collapse: string;\n expand: string;\n badge: Formatter<[count: number]>;\n userMenu: string;\n};\n\n/**\n * What `AppShell` hands its navigation (3.2). The parts also work outside a shell (a settings\n * page's own list): then nothing is collapsed and a click only follows the link.\n */\nexport type AppShellContextValue = {\n /** The sidebar shows icons only. Always `false` inside the narrow-window drawer. */\n isCollapsed: boolean;\n /** A link was followed: the drawer closes. */\n onNavigate?: () => void;\n /** A group was opened from the icon rail: the sidebar expands to show its links. */\n onExpandSidebar?: () => void;\n /** The shell's `labels` prop, over the provider's. */\n labels?: Partial<AppShellLabels>;\n};\n\nconst AppShellContext = createContext<AppShellContextValue>({ isCollapsed: false });\n\nexport const useAppShell = (): AppShellContextValue => useContext(AppShellContext);\n\n/** The shell's labels: its `labels` prop first, then `UiProvider`'s `appShell`. */\nexport const useAppShellLabels = (): Partial<AppShellLabels> => {\n const { labels: config } = useUi();\n const { labels } = useAppShell();\n\n return { ...config?.appShell, ...labels };\n};\n\nexport default AppShellContext;\n"],"names":["AppShellContext","createContext","useAppShell","useContext","useAppShellLabels","config","useUi","labels"],"mappings":"uLA+BMA,EAAkBC,EAAAA,cAAoC,CAAE,YAAa,GAAO,EAErEC,EAAc,IAA4BC,EAAAA,WAAWH,CAAe,EAGpEI,EAAoB,IAA+B,CAC9D,KAAM,CAAE,OAAQC,CAAA,EAAWC,QAAA,EACrB,CAAE,OAAAC,CAAA,EAAWL,EAAA,EAEnB,MAAO,CAAE,GAAGG,GAAA,YAAAA,EAAQ,SAAU,GAAGE,CAAA,CACnC"}
@@ -0,0 +1,29 @@
1
+ import { Formatter } from '../../types/theme.type.cjs';
2
+ export type AppShellLabels = {
3
+ skipToContent: string;
4
+ navigation: string;
5
+ openNavigation: string;
6
+ collapse: string;
7
+ expand: string;
8
+ badge: Formatter<[count: number]>;
9
+ userMenu: string;
10
+ };
11
+ /**
12
+ * What `AppShell` hands its navigation (3.2). The parts also work outside a shell (a settings
13
+ * page's own list): then nothing is collapsed and a click only follows the link.
14
+ */
15
+ export type AppShellContextValue = {
16
+ /** The sidebar shows icons only. Always `false` inside the narrow-window drawer. */
17
+ isCollapsed: boolean;
18
+ /** A link was followed: the drawer closes. */
19
+ onNavigate?: () => void;
20
+ /** A group was opened from the icon rail: the sidebar expands to show its links. */
21
+ onExpandSidebar?: () => void;
22
+ /** The shell's `labels` prop, over the provider's. */
23
+ labels?: Partial<AppShellLabels>;
24
+ };
25
+ declare const AppShellContext: import('react').Context<AppShellContextValue>;
26
+ export declare const useAppShell: () => AppShellContextValue;
27
+ /** The shell's labels: its `labels` prop first, then `UiProvider`'s `appShell`. */
28
+ export declare const useAppShellLabels: () => Partial<AppShellLabels>;
29
+ export default AppShellContext;
@@ -0,0 +1,29 @@
1
+ import { Formatter } from '../../types/theme.type.js';
2
+ export type AppShellLabels = {
3
+ skipToContent: string;
4
+ navigation: string;
5
+ openNavigation: string;
6
+ collapse: string;
7
+ expand: string;
8
+ badge: Formatter<[count: number]>;
9
+ userMenu: string;
10
+ };
11
+ /**
12
+ * What `AppShell` hands its navigation (3.2). The parts also work outside a shell (a settings
13
+ * page's own list): then nothing is collapsed and a click only follows the link.
14
+ */
15
+ export type AppShellContextValue = {
16
+ /** The sidebar shows icons only. Always `false` inside the narrow-window drawer. */
17
+ isCollapsed: boolean;
18
+ /** A link was followed: the drawer closes. */
19
+ onNavigate?: () => void;
20
+ /** A group was opened from the icon rail: the sidebar expands to show its links. */
21
+ onExpandSidebar?: () => void;
22
+ /** The shell's `labels` prop, over the provider's. */
23
+ labels?: Partial<AppShellLabels>;
24
+ };
25
+ declare const AppShellContext: import('react').Context<AppShellContextValue>;
26
+ export declare const useAppShell: () => AppShellContextValue;
27
+ /** The shell's labels: its `labels` prop first, then `UiProvider`'s `appShell`. */
28
+ export declare const useAppShellLabels: () => Partial<AppShellLabels>;
29
+ export default AppShellContext;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { createContext as t, useContext as s } from "react";
3
+ import { useUi as o } from "../../theme/context.js";
4
+ const p = t({ isCollapsed: !1 }), a = () => s(p), u = () => {
5
+ const { labels: e } = o(), { labels: l } = a();
6
+ return { ...e == null ? void 0 : e.appShell, ...l };
7
+ };
8
+ export {
9
+ p as default,
10
+ a as useAppShell,
11
+ u as useAppShellLabels
12
+ };
13
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../../src/components/AppShell/context.ts"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\n\nexport type AppShellLabels = {\n skipToContent: string;\n navigation: string;\n openNavigation: string;\n collapse: string;\n expand: string;\n badge: Formatter<[count: number]>;\n userMenu: string;\n};\n\n/**\n * What `AppShell` hands its navigation (3.2). The parts also work outside a shell (a settings\n * page's own list): then nothing is collapsed and a click only follows the link.\n */\nexport type AppShellContextValue = {\n /** The sidebar shows icons only. Always `false` inside the narrow-window drawer. */\n isCollapsed: boolean;\n /** A link was followed: the drawer closes. */\n onNavigate?: () => void;\n /** A group was opened from the icon rail: the sidebar expands to show its links. */\n onExpandSidebar?: () => void;\n /** The shell's `labels` prop, over the provider's. */\n labels?: Partial<AppShellLabels>;\n};\n\nconst AppShellContext = createContext<AppShellContextValue>({ isCollapsed: false });\n\nexport const useAppShell = (): AppShellContextValue => useContext(AppShellContext);\n\n/** The shell's labels: its `labels` prop first, then `UiProvider`'s `appShell`. */\nexport const useAppShellLabels = (): Partial<AppShellLabels> => {\n const { labels: config } = useUi();\n const { labels } = useAppShell();\n\n return { ...config?.appShell, ...labels };\n};\n\nexport default AppShellContext;\n"],"names":["AppShellContext","createContext","useAppShell","useContext","useAppShellLabels","config","useUi","labels"],"mappings":";;;AA+BA,MAAMA,IAAkBC,EAAoC,EAAE,aAAa,IAAO,GAErEC,IAAc,MAA4BC,EAAWH,CAAe,GAGpEI,IAAoB,MAA+B;AAC9D,QAAM,EAAE,QAAQC,EAAA,IAAWC,EAAA,GACrB,EAAE,QAAAC,EAAA,IAAWL,EAAA;AAEnB,SAAO,EAAE,GAAGG,KAAA,gBAAAA,EAAQ,UAAU,GAAGE,EAAA;AACnC;"}
@@ -0,0 +1,2 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),l=require("react"),k=require("react-bootstrap-icons"),P=require("../../constants/breakpoint.constants.cjs"),Q=require("../../helpers/class-name.helper.cjs"),V=require("../../helpers/component.helper.cjs"),o=require("../../helpers/label.helper.cjs"),Y=require("../../theme/context.cjs"),F=require("../Drawer/index.cjs"),A=require("../IconButton/index.cjs"),E=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"}},G=({brand:d,navigation:x,sidebarFooter:w,title:b,search:j,actions:N,children:R,isCollapsed:p,isDefaultCollapsed:y=!1,onCollapsedChange:u,labels:n,className:O,testId:C})=>{const{labels:m}=Y.useUi(),r={...m==null?void 0:m.appShell,...n},S=l.useId(),g=l.useRef(null),q=l.useRef(null),[D,I]=l.useState(y),c=p??D,[i,h]=l.useState(!1),_=l.useCallback(t=>{p===void 0&&I(t),u==null||u(t)},[p,u]),v=l.useCallback(()=>h(!1),[]),L=l.useCallback(()=>_(!1),[_]);l.useEffect(()=>{if(!i)return;const t=window.matchMedia(P.ABOVE_TABLET_MEDIA_QUERY);if(t.matches){h(!1);return}const a=f=>{f.matches&&h(!1)};return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[i]),l.useEffect(()=>{const t=q.current;if(!t||typeof ResizeObserver>"u")return;const a=document.documentElement,f=new ResizeObserver(([U])=>a.style.setProperty("--ui-header-height",`${U.contentRect.height}px`));return f.observe(t),()=>{f.disconnect(),a.style.removeProperty("--ui-header-height")}},[]);const M=t=>{var a;t.preventDefault(),(a=g.current)==null||a.focus()},T=l.useMemo(()=>({isCollapsed:c,onExpandSidebar:L,labels:n}),[c,L,n]),$=l.useMemo(()=>({isCollapsed:!1,onNavigate:v,labels:n}),[v,n]),z=o.resolveLabel("AppShell.labels.navigation",r.navigation),B=c?o.resolveLabel("AppShell.labels.expand",r.expand):o.resolveLabel("AppShell.labels.collapse",r.collapse);return e.jsxs("div",{className:Q.cx(s.default.shell,c&&s.default["shell--collapsed"],O),"data-testid":C,children:[e.jsx("a",{href:`#${S}`,className:s.default.shell__skip,onClick:M,children:o.resolveLabel("AppShell.labels.skipToContent",r.skipToContent)}),e.jsxs("aside",{className:s.default.shell__sidebar,children:[d&&e.jsx("div",{className:s.default.shell__brand,children:d}),e.jsx(E.default.Provider,{value:T,children:e.jsx("div",{className:s.default.shell__navigation,children:x})}),e.jsxs("div",{className:s.default.shell__footer,children:[w,e.jsx(A.default,{icon:e.jsx(k.ChevronDoubleLeft,{"aria-hidden":!0,className:s.default.shell__toggle}),label:B,size:"sm",className:s.default["shell__toggle-button"],onClick:()=>_(!c)})]})]}),e.jsxs("div",{className:s.default.shell__frame,children:[e.jsxs("header",{ref:q,className:s.default.shell__topbar,children:[e.jsx(A.default,{icon:e.jsx(k.List,{"aria-hidden":!0}),label:o.resolveLabel("AppShell.labels.openNavigation",r.openNavigation),className:s.default["shell__menu-button"],"aria-expanded":i,onClick:()=>h(!0)}),b&&e.jsx("div",{className:s.default.shell__title,children:b}),j&&e.jsx("div",{className:s.default.shell__search,children:j}),N&&e.jsx("div",{className:s.default.shell__actions,children:N})]}),e.jsx("main",{ref:g,id:S,tabIndex:-1,className:s.default.shell__content,children:R})]}),e.jsx(F.default,{isOpen:i,onClose:v,title:z,side:"start",size:"sm",className:s.default.shell__drawer,children:i&&e.jsxs(E.default.Provider,{value:$,children:[d&&e.jsx("div",{className:s.default["shell__drawer-brand"],children:d}),x]})})]})},H=l.memo(V.named(G,"AppShell"));exports.default=H;
2
+ //# sourceMappingURL=index.cjs.map