@handijitcom/ui 3.2.0 → 3.3.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.
- package/README.md +111 -4
- package/build/components/Accordion/index.cjs +1 -1
- package/build/components/AppShell/Nav.cjs +1 -1
- package/build/components/AppShell/Nav.js +1 -1
- package/build/components/AppShell/context.js +2 -2
- package/build/components/AppShell/index.cjs +1 -1
- package/build/components/AppShell/index.cjs.map +1 -1
- package/build/components/AppShell/index.js +62 -55
- package/build/components/AppShell/index.js.map +1 -1
- package/build/components/AppShell/style.css +1 -1
- package/build/components/BottomSheet/index.cjs +1 -1
- package/build/components/BottomSheet/style.css +1 -1
- package/build/components/Breadcrumb/index.cjs +1 -1
- package/build/components/Breadcrumb/index.cjs.map +1 -1
- package/build/components/Breadcrumb/index.d.cts +11 -1
- package/build/components/Breadcrumb/index.d.ts +11 -1
- package/build/components/Breadcrumb/index.js +70 -22
- package/build/components/Breadcrumb/index.js.map +1 -1
- package/build/components/Breadcrumb/style.css +1 -1
- package/build/components/BulkPasteInput/index.cjs +1 -1
- package/build/components/Button/index.cjs +1 -1
- package/build/components/Carousel/index.cjs +1 -1
- package/build/components/ChipGroup/index.cjs +1 -1
- package/build/components/Combobox/index.cjs +1 -1
- package/build/components/CommandPalette/index.cjs +1 -1
- package/build/components/ConfirmDialog/index.cjs +1 -1
- package/build/components/DataTable/index.cjs +1 -1
- package/build/components/DataTable/index.cjs.map +1 -1
- package/build/components/DataTable/index.js +68 -67
- package/build/components/DataTable/index.js.map +1 -1
- package/build/components/DataTable/style.css +1 -1
- package/build/components/DataTableColumnMenu/index.cjs +1 -1
- package/build/components/DateField/index.js +1 -1
- package/build/components/Directory/index.js +1 -1
- package/build/components/Drawer/index.cjs +1 -1
- package/build/components/Drawer/style.css +1 -1
- package/build/components/Eyebrow/index.cjs +1 -1
- package/build/components/Eyebrow/index.cjs.map +1 -1
- package/build/components/Eyebrow/index.d.cts +6 -1
- package/build/components/Eyebrow/index.d.ts +6 -1
- package/build/components/Eyebrow/index.js +25 -6
- package/build/components/Eyebrow/index.js.map +1 -1
- package/build/components/Eyebrow/style.css +1 -1
- package/build/components/FileUpload/index.cjs +1 -1
- package/build/components/FilterBar/index.js +1 -1
- package/build/components/Gallery/index.cjs +1 -1
- package/build/components/Gallery/index.cjs.map +1 -1
- package/build/components/Gallery/index.js +28 -28
- package/build/components/Gallery/index.js.map +1 -1
- package/build/components/Gallery/style.css +1 -1
- package/build/components/Modal/index.cjs +1 -1
- package/build/components/Modal/style.css +1 -1
- package/build/components/MoneyInput/index.cjs +1 -1
- package/build/components/NotificationCenter/index.cjs +1 -1
- package/build/components/PageHeader/index.cjs +1 -1
- package/build/components/PageHeader/index.cjs.map +1 -1
- package/build/components/PageHeader/index.d.cts +5 -0
- package/build/components/PageHeader/index.d.ts +5 -0
- package/build/components/PageHeader/index.js +38 -28
- package/build/components/PageHeader/index.js.map +1 -1
- package/build/components/PageHeader/style.css +1 -1
- package/build/components/Pagination/index.cjs +1 -1
- package/build/components/Panel/index.js +1 -1
- package/build/components/PasswordInput/index.cjs +1 -1
- package/build/components/PercentInput/index.cjs +1 -1
- package/build/components/Popover/style.css +1 -1
- package/build/components/Price/index.cjs +1 -1
- package/build/components/Price/index.cjs.map +1 -1
- package/build/components/Price/index.d.cts +8 -0
- package/build/components/Price/index.d.ts +8 -0
- package/build/components/Price/index.js +44 -35
- package/build/components/Price/index.js.map +1 -1
- package/build/components/Price/style.css +1 -1
- package/build/components/PromptDialog/index.cjs +1 -1
- package/build/components/QuantityInput/index.cjs +1 -1
- package/build/components/RateInput/index.cjs +1 -1
- package/build/components/ScaledInput/index.cjs +1 -1
- package/build/components/SectionHeader/index.cjs +1 -1
- package/build/components/SectionHeader/index.cjs.map +1 -1
- package/build/components/SectionHeader/index.d.cts +2 -0
- package/build/components/SectionHeader/index.d.ts +2 -0
- package/build/components/SectionHeader/index.js +25 -15
- package/build/components/SectionHeader/index.js.map +1 -1
- package/build/components/SectionHeader/style.css +1 -1
- package/build/components/Select/index.cjs +1 -1
- package/build/components/Switch/index.js +4 -4
- package/build/components/Table/style.css +1 -1
- package/build/components/Tabs/index.cjs +1 -1
- package/build/components/Tabs/index.cjs.map +1 -1
- package/build/components/Tabs/index.js +120 -80
- package/build/components/Tabs/index.js.map +1 -1
- package/build/components/Tabs/style.css +1 -1
- package/build/components/Toast/index.cjs +1 -1
- package/build/components/Toast/style.css +1 -1
- package/build/components/ToastPortal/index.cjs +1 -1
- package/build/components/TotalsList/index.cjs +2 -0
- package/build/components/TotalsList/index.cjs.map +1 -0
- package/build/components/TotalsList/index.d.cts +26 -0
- package/build/components/TotalsList/index.d.ts +26 -0
- package/build/components/TotalsList/index.js +22 -0
- package/build/components/TotalsList/index.js.map +1 -0
- package/build/components/TotalsList/style.css +1 -0
- package/build/components/TreeSelect/index.cjs +1 -1
- package/build/components/UserMenu/index.cjs +1 -1
- package/build/constants/breakpoint.constants.cjs +1 -1
- package/build/constants/breakpoint.constants.cjs.map +1 -1
- package/build/constants/breakpoint.constants.d.cts +2 -0
- package/build/constants/breakpoint.constants.d.ts +2 -0
- package/build/constants/breakpoint.constants.js +5 -4
- package/build/constants/breakpoint.constants.js.map +1 -1
- package/build/helpers/scroll.helper.cjs +1 -1
- package/build/helpers/scroll.helper.cjs.map +1 -1
- package/build/helpers/scroll.helper.d.cts +6 -0
- package/build/helpers/scroll.helper.d.ts +6 -0
- package/build/helpers/scroll.helper.js +10 -5
- package/build/helpers/scroll.helper.js.map +1 -1
- package/build/hooks/usePrinting.cjs +2 -0
- package/build/hooks/usePrinting.cjs.map +1 -0
- package/build/hooks/usePrinting.d.cts +8 -0
- package/build/hooks/usePrinting.d.ts +8 -0
- package/build/hooks/usePrinting.js +18 -0
- package/build/hooks/usePrinting.js.map +1 -0
- package/build/index.cjs +1 -1
- package/build/index.d.cts +2 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +88 -86
- package/build/index.js.map +1 -1
- package/build/scss/_mixins.scss +8 -0
- package/build/styles.css +18 -16
- package/build/theme/context.js +2 -2
- package/build/types/theme.type.d.cts +5 -0
- package/build/types/theme.type.d.ts +5 -0
- package/build/types/types/theme.type.d.cts +5 -0
- package/build/types/types/theme.type.d.ts +5 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -82,7 +82,19 @@ render-blocking files hurt LCP more than the bytes did.
|
|
|
82
82
|
|
|
83
83
|
Every component also has a subpath (`@handijitcom/ui/button`, `/chip-group`,
|
|
84
84
|
`/combobox`, …). The main entry is a pure re-export, so a bundler reaches the
|
|
85
|
-
same file either way.
|
|
85
|
+
same file either way. **A subpath's default export is its component; its parts
|
|
86
|
+
and types are named exports**, exactly as on the main entry:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import AppShell, { AppShellNav } from '@handijitcom/ui/app-shell';
|
|
90
|
+
import { AppShell, AppShellNav } from '@handijitcom/ui'; // the same modules
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This holds for `import` and `require` alike, in Node, Vitest and bundlers.
|
|
94
|
+
3.2.0's `app-shell` subpath exported only `default` at run time (its
|
|
95
|
+
`AppShellNav`, `AppShellNavGroup` and `AppShellNavItem` were `undefined`);
|
|
96
|
+
since 3.2.1 every subpath is a build entry and `npm run build` imports each one
|
|
97
|
+
in both formats and fails on a missing name.
|
|
86
98
|
|
|
87
99
|
The sub-entries have their own stylesheets, imported **after** `styles.css`:
|
|
88
100
|
`@handijitcom/ui/chat.css`, `@handijitcom/ui/charts.css`, `@handijitcom/ui/calendar.css`.
|
|
@@ -424,7 +436,7 @@ and changes when an announcement strip appears.
|
|
|
424
436
|
| Action | `Button` · `IconButton` · `TextLink` · `Tooltip` · `Menu` · `ContextMenu` · `Popover` |
|
|
425
437
|
| Choice | `Chip` · `ChipGroup` · `SegmentedControl` · `Select` · `Combobox` · `TreeSelect` · `Checkbox` · `Switch` · `Radio` · `RadioCard` · `RangeSlider` · `RatingInput` · `QuantityStepper` · `TableCheckbox` |
|
|
426
438
|
| 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`
|
|
439
|
+
| Surface | `Card` (+ `CardMedia`, `CardOverlay`, `CardBody`, `CardFooter`) · `SummaryCard` · `Panel` (+ `PanelForm`, `PanelRow`) · `TotalsList` · `PageHeader` · `SectionHeader` · `Tile` · `Directory` (+ `DirectoryGroup`, `DirectoryRow`, `DirectoryJump`) · `Carousel` · `Gallery` · `ScrollArea` · `Disclosure` · `Accordion` · `Tabs` |
|
|
428
440
|
| Feedback | `Alert` · `Badge` · `StatusDot` · `CodeBadge` · `Kbd` · `EmptyState` · `Skeleton` (+ `SkeletonCard`, `SkeletonRows`, `SkeletonTable`) · `Spinner` · `Progress` · `Steps` · `Divider` · `Avatar` · `Rating` · `Price` · `Stat` · `CopyField` · `Breadcrumb` · `ToastHub` (+ `ToastPortal`) · `NotificationCenter` |
|
|
429
441
|
| Brand surface (3.0) | `BrandSurface` (+ `BrandBlueprint`) · `Eyebrow` · `StatStrip` |
|
|
430
442
|
| Shell (3.2) | `AppShell` (+ `AppShellNav`, `AppShellNavGroup`, `AppShellNavItem`) · `UserMenu` |
|
|
@@ -435,6 +447,18 @@ and changes when an announcement strip appears.
|
|
|
435
447
|
| Charts, `/charts` | `LineChart` · `AreaChart` · `BarChart` · `ComposedChart` · `PieChart` · `ScatterPlot` · `Heatmap` · `BoxPlot` · `Histogram` · `RadarChart` |
|
|
436
448
|
| Calendar, `/calendar` | `Calendar` |
|
|
437
449
|
|
|
450
|
+
**Overflow on a narrow screen (3.2.1).** `Tabs` that do not fit fade out at
|
|
451
|
+
the edge they continue past, with a round scroll button there under a mouse
|
|
452
|
+
(touch swipes; the buttons stay out of the tab order and away from screen
|
|
453
|
+
readers), and the selected tab is scrolled into view, on the first paint too,
|
|
454
|
+
by moving the strip only, never the page. A `Breadcrumb` of more than three
|
|
455
|
+
crumbs stays on one line at tablet-portrait width and below: the middle crumbs
|
|
456
|
+
fold into a "…" button that unfolds the whole trail (`expandLabel` or
|
|
457
|
+
`labels.breadcrumbExpand`; without one it is named by the crumbs it hides) and
|
|
458
|
+
the current page is cut with an ellipsis, its full text in `title`. `Gallery`'s
|
|
459
|
+
arrows are round `IconButton`s centred on the image's edges, shown on hover or
|
|
460
|
+
focus under a mouse and always on touch.
|
|
461
|
+
|
|
438
462
|
### Variants and sizes
|
|
439
463
|
|
|
440
464
|
| `UIVariant` | Use |
|
|
@@ -619,6 +643,11 @@ data contract. `123450` with two decimal places is "1.234,50".
|
|
|
619
643
|
`unitDigits` from the unit. Display elsewhere is the application's
|
|
620
644
|
formatters' (`formatMoney`, `formatQuantity` …); `Price` stays a
|
|
621
645
|
display of an already formatted text.
|
|
646
|
+
- **`Price` writes the lira sign first** (3.2.1), as `@handijitcom/tr`
|
|
647
|
+
`formatLira` does: `<Price value="2.649,57" currency="₺" />` reads
|
|
648
|
+
"₺2.649,57", a negative "-₺0,05", no space. Any other symbol or code stays
|
|
649
|
+
after the amount ("2.649,57 TL" style). `currencyPosition="prefix" | "suffix"`
|
|
650
|
+
overrides the default either way.
|
|
622
651
|
|
|
623
652
|
### Parts portal components (3.1)
|
|
624
653
|
|
|
@@ -728,7 +757,10 @@ router link), the current page comes from `currentPath`.
|
|
|
728
757
|
<AppShellNav
|
|
729
758
|
currentPath={pathname} // the longest matching href is the current page
|
|
730
759
|
sections={[
|
|
731
|
-
{
|
|
760
|
+
{
|
|
761
|
+
id: 'main',
|
|
762
|
+
items: [{ id: 'orders', label: 'Siparişler', href: '/orders', icon: <Cart />, badge: 3 }],
|
|
763
|
+
},
|
|
732
764
|
{
|
|
733
765
|
id: 'stock',
|
|
734
766
|
label: 'Stok',
|
|
@@ -767,7 +799,12 @@ router link), the current page comes from `currentPath`.
|
|
|
767
799
|
`labels.appShell.badge`.
|
|
768
800
|
- **Parts.** `AppShellNavItem` and `AppShellNavGroup` also compose by hand
|
|
769
801
|
(`<AppShellNav><AppShellNavItem … isActive /></AppShellNav>`); outside the
|
|
770
|
-
shell nothing is collapsed. A link in the drawer closes it
|
|
802
|
+
shell nothing is collapsed. A link in the drawer closes it, the brand link
|
|
803
|
+
too (3.2.1).
|
|
804
|
+
- **Sidebar.** The column runs the page's full height; inside it the brand,
|
|
805
|
+
the links and the toggle are a sticky, viewport-tall box (`100dvh`) whose
|
|
806
|
+
links scroll on their own (3.2.1). A brand link of an icon and a name
|
|
807
|
+
(`<TextLink href="/"><Icon />Name</TextLink>`) gets a gap between the two.
|
|
771
808
|
- **Lengths on `<html>`.** `--app-sidebar-width` (232px, 56px collapsed, 0
|
|
772
809
|
below the tablet width; plain CSS) for the notices:
|
|
773
810
|
`<ToastPortal inset={{ inlineStart: 'var(--app-sidebar-width)' }} />`; and
|
|
@@ -776,6 +813,70 @@ router link), the current page comes from `currentPath`.
|
|
|
776
813
|
- Labels: `appShell.skipToContent`, `navigation`, `openNavigation`,
|
|
777
814
|
`collapse`, `expand`, `badge`, `userMenu` (provider or the `labels` prop).
|
|
778
815
|
|
|
816
|
+
### Totals (3.3.0)
|
|
817
|
+
|
|
818
|
+
`TotalsList` (`@handijitcom/ui/totals-list`) is the "label → amount" list of a
|
|
819
|
+
cart, an order or an invoice. `SummaryCard` is a link card and the chat
|
|
820
|
+
entry's `DescriptionList` puts each value right after its label, so neither
|
|
821
|
+
lines amounts up. `TotalsList` is a native `<dl>`: labels at the start,
|
|
822
|
+
amounts at the end in tabular figures (the digits of every row sit under each
|
|
823
|
+
other), and an `isTotal` row emphasized below a divider. Its items have
|
|
824
|
+
`DescriptionList`'s shape (`term`, `description`), so a switch is the import
|
|
825
|
+
and one flag.
|
|
826
|
+
|
|
827
|
+
```tsx
|
|
828
|
+
<Panel title="Sipariş özeti" footer={<Button>Siparişi ver</Button>}>
|
|
829
|
+
<TotalsList
|
|
830
|
+
items={[
|
|
831
|
+
{ term: 'Liste toplamı', description: <Price value="12.480,00" size="sm" /> },
|
|
832
|
+
{ term: 'İskonto', description: <Price value="-1.248,00" size="sm" /> },
|
|
833
|
+
{
|
|
834
|
+
term: 'Kargo',
|
|
835
|
+
description: (
|
|
836
|
+
<Badge tone="info" variant="soft">
|
|
837
|
+
Ücretsiz
|
|
838
|
+
</Badge>
|
|
839
|
+
),
|
|
840
|
+
},
|
|
841
|
+
{ term: 'KDV (%20)', description: <Price value="2.246,40" size="sm" /> },
|
|
842
|
+
{ term: 'Genel toplam', description: <Price value="13.478,40" size="lg" />, isTotal: true },
|
|
843
|
+
]}
|
|
844
|
+
/>
|
|
845
|
+
</Panel>
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
- **Amounts.** Any node: a `Price` (a negative value keeps its minus in front
|
|
849
|
+
of the sign, "-₺1.248,00"), plain text, or an inline `Badge`. Amounts do not
|
|
850
|
+
wrap; a long label wraps at the start.
|
|
851
|
+
- **Grand total.** `isTotal` sets the row in body size and semibold below a
|
|
852
|
+
rule. Give its `Price` a larger `size` for more weight; usually one row has it.
|
|
853
|
+
- A row never breaks across two printed pages.
|
|
854
|
+
|
|
855
|
+
### Printing (3.3.0)
|
|
856
|
+
|
|
857
|
+
The paper holds the page, not the screen's controls. Nothing to call: the
|
|
858
|
+
rules are in each component's stylesheet under `@media print`.
|
|
859
|
+
|
|
860
|
+
| Component | On paper |
|
|
861
|
+
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
862
|
+
| `AppShell` | the sidebar, the top bar and the skip link are hidden; the content takes the full width without the frame's padding |
|
|
863
|
+
| `Drawer` · `Modal` · `BottomSheet` · `Popover` · `ToastHub` | never printed, open or not (so the dialogs built on `Modal` too) |
|
|
864
|
+
| `DataTable` | every row; no scroll box, cap or sticky header/column; the header repeats on each page; rows never break across pages; no column menu or bulk bar |
|
|
865
|
+
| `Table` | no scroll box or sticky head; the header repeats; rows never break across pages |
|
|
866
|
+
| `TotalsList` | rows never break across pages |
|
|
867
|
+
|
|
868
|
+
**A virtualized `DataTable` renders all of its rows while printing.** On
|
|
869
|
+
`beforeprint` (or when the `print` media query starts to match) it turns its
|
|
870
|
+
row window off and renders synchronously, so the pages are laid out with
|
|
871
|
+
every row; `afterprint` brings the window back. The alternative, a "only the
|
|
872
|
+
rows in view are printed" note, would have left the printout incomplete. Two
|
|
873
|
+
limits: a very long list makes a long render before the print dialog (it is
|
|
874
|
+
what the paper needs), and a headless PDF renderer that switches to print
|
|
875
|
+
media without firing `beforeprint` (e.g. `page.pdf()` in some setups) prints
|
|
876
|
+
the window only, without the blank spacers. Dispatch the event first:
|
|
877
|
+
`await page.evaluate(() => window.dispatchEvent(new Event('beforeprint')))`,
|
|
878
|
+
or render that table without `isVirtualized`.
|
|
879
|
+
|
|
779
880
|
### TypeScript resolution
|
|
780
881
|
|
|
781
882
|
The declarations resolve under every `moduleResolution`: `bundler`, `node16`
|
|
@@ -847,6 +948,12 @@ import { logos } from '@handijitcom/ui/design';
|
|
|
847
948
|
- `StatStrip` (`page` or `brand`) is a list of value and label facts with thin
|
|
848
949
|
dividers; `Eyebrow` is the mono capital label with its rules (`start` or
|
|
849
950
|
`center`). The text is set in capitals by CSS, so give the page a `lang`.
|
|
951
|
+
- **A brand or a proper name is never capitalised by CSS** (3.2.1). Under
|
|
952
|
+
`lang="tr"` the browser writes "Mann-Filter" as "MANN-FİLTER". Capitals stay
|
|
953
|
+
the default (3.x is compatible); for a name pass `isUppercase={false}` to
|
|
954
|
+
`Eyebrow`, `isEyebrowUppercase={false}` to `PageHeader`,
|
|
955
|
+
`isOverlineUppercase={false}` to `SectionHeader`; in your own SCSS include
|
|
956
|
+
the mixin `ui.overline-as-written` after `ui.overline`.
|
|
850
957
|
|
|
851
958
|
**One `PRIMARY` per screen.** `UIVariant` is a hierarchy of emphasis: two
|
|
852
959
|
filled buttons side by side and neither stands out.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),r=require("react"),v=require("../../helpers/class-name.helper.cjs"),j=require("../../helpers/component.helper.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),r=require("react"),v=require("../../helpers/class-name.helper.cjs"),j=require("../../helpers/component.helper.cjs"),D=require("../Disclosure/index.cjs"),u={default:{"accordion":"ui-accordion-h9jLC","accordion__item":"ui-accordion__item--YvzK"}},I=({items:m,isSingle:l,defaultOpenIds:p,openIds:i,onChange:s,className:_,testId:f})=>{const[x,q]=r.useState(p??[]),c=i!==void 0,t=c?i:x,b=r.useCallback((e,o)=>{const d=o?l?[e]:[...t.filter(n=>n!==e),e]:t.filter(n=>n!==e);c||q(d),s==null||s(d)},[c,l,s,t]);return a.jsx("div",{className:v.cx(u.default.accordion,_),"data-testid":f,children:m.map(e=>a.jsx(D.default,{variant:"plain",className:u.default.accordion__item,summary:e.title,meta:e.meta,isDisabled:e.isDisabled,isOpen:t.includes(e.id),onOpenChange:o=>b(e.id,o),children:e.content},e.id))})},N=r.memo(j.named(I,"Accordion"));exports.default=N;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +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;
|
|
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__sidebar-inner":"ui-shell__sidebar-inner-iIXhF","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
2
|
//# sourceMappingURL=Nav.cjs.map
|
|
@@ -8,7 +8,7 @@ import { named as N } from "../../helpers/component.helper.js";
|
|
|
8
8
|
import { resolveLabel as $, resolveFormatter as j } from "../../helpers/label.helper.js";
|
|
9
9
|
import F from "../Link/index.js";
|
|
10
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"};
|
|
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__sidebar-inner":"ui-shell__sidebar-inner-iIXhF","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
12
|
const S = 99, I = ({ count: l }) => {
|
|
13
13
|
const t = x();
|
|
14
14
|
return /* @__PURE__ */ h(g, { children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { useContext as t, createContext as s } from "react";
|
|
3
3
|
import { useUi as o } from "../../theme/context.js";
|
|
4
|
-
const p =
|
|
4
|
+
const p = s({ isCollapsed: !1 }), a = () => t(p), u = () => {
|
|
5
5
|
const { labels: e } = o(), { labels: l } = a();
|
|
6
6
|
return { ...e == null ? void 0 : e.appShell, ...l };
|
|
7
7
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),t=require("react"),L=require("react-bootstrap-icons"),Q=require("../../constants/breakpoint.constants.cjs"),V=require("../../helpers/class-name.helper.cjs"),Y=require("../../helpers/component.helper.cjs"),i=require("../../helpers/label.helper.cjs"),F=require("../../theme/context.cjs"),H=require("../Drawer/index.cjs"),w=require("../IconButton/index.cjs"),E=require("./context.cjs"),l={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__sidebar-inner":"ui-shell__sidebar-inner-iIXhF","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"}},x=require("./Nav.cjs"),J=({brand:d,navigation:b,sidebarFooter:I,title:N,search:j,actions:S,children:R,isCollapsed:_,isDefaultCollapsed:C=!1,onCollapsedChange:u,labels:n,className:D,testId:y})=>{const{labels:m}=F.useUi(),r={...m==null?void 0:m.appShell,...n},A=t.useId(),g=t.useRef(null),q=t.useRef(null),[O,M]=t.useState(C),c=_??O,[o,h]=t.useState(!1),v=t.useCallback(s=>{_===void 0&&M(s),u==null||u(s)},[_,u]),p=t.useCallback(()=>h(!1),[]),k=t.useCallback(()=>v(!1),[v]);t.useEffect(()=>{if(!o)return;const s=window.matchMedia(Q.ABOVE_TABLET_MEDIA_QUERY);if(s.matches){h(!1);return}const a=f=>{f.matches&&h(!1)};return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[o]),t.useEffect(()=>{const s=q.current;if(!s||typeof ResizeObserver>"u")return;const a=document.documentElement,f=new ResizeObserver(([P])=>a.style.setProperty("--ui-header-height",`${P.contentRect.height}px`));return f.observe(s),()=>{f.disconnect(),a.style.removeProperty("--ui-header-height")}},[]);const B=s=>{var a;s.preventDefault(),(a=g.current)==null||a.focus()},T=s=>{s.target.closest("a")&&p()},z=t.useMemo(()=>({isCollapsed:c,onExpandSidebar:k,labels:n}),[c,k,n]),U=t.useMemo(()=>({isCollapsed:!1,onNavigate:p,labels:n}),[p,n]),$=i.resolveLabel("AppShell.labels.navigation",r.navigation),G=c?i.resolveLabel("AppShell.labels.expand",r.expand):i.resolveLabel("AppShell.labels.collapse",r.collapse);return e.jsxs("div",{className:V.cx(l.default.shell,c&&l.default["shell--collapsed"],D),"data-testid":y,children:[e.jsx("a",{href:`#${A}`,className:l.default.shell__skip,onClick:B,children:i.resolveLabel("AppShell.labels.skipToContent",r.skipToContent)}),e.jsx("aside",{className:l.default.shell__sidebar,children:e.jsxs("div",{className:l.default["shell__sidebar-inner"],children:[d&&e.jsx("div",{className:l.default.shell__brand,children:d}),e.jsx(E.default.Provider,{value:z,children:e.jsx("div",{className:l.default.shell__navigation,children:b})}),e.jsxs("div",{className:l.default.shell__footer,children:[I,e.jsx(w.default,{icon:e.jsx(L.ChevronDoubleLeft,{"aria-hidden":!0,className:l.default.shell__toggle}),label:G,size:"sm",className:l.default["shell__toggle-button"],onClick:()=>v(!c)})]})]})}),e.jsxs("div",{className:l.default.shell__frame,children:[e.jsxs("header",{ref:q,className:l.default.shell__topbar,children:[e.jsx(w.default,{icon:e.jsx(L.List,{"aria-hidden":!0}),label:i.resolveLabel("AppShell.labels.openNavigation",r.openNavigation),className:l.default["shell__menu-button"],"aria-expanded":o,onClick:()=>h(!0)}),N&&e.jsx("div",{className:l.default.shell__title,children:N}),j&&e.jsx("div",{className:l.default.shell__search,children:j}),S&&e.jsx("div",{className:l.default.shell__actions,children:S})]}),e.jsx("main",{ref:g,id:A,tabIndex:-1,className:l.default.shell__content,children:R})]}),e.jsx(H.default,{isOpen:o,onClose:p,title:$,side:"start",size:"sm",className:l.default.shell__drawer,children:o&&e.jsxs(E.default.Provider,{value:U,children:[d&&e.jsx("div",{className:l.default["shell__drawer-brand"],onClick:T,children:d}),b]})})]})},K=t.memo(Y.named(J,"AppShell"));exports.AppShellNav=x.AppShellNav;exports.AppShellNavGroup=x.AppShellNavGroup;exports.AppShellNavItem=x.AppShellNavItem;exports.default=K;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/AppShell/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type MouseEvent,\n type ReactNode,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { ChevronDoubleLeft, List } from 'react-bootstrap-icons';\n\nimport { ABOVE_TABLET_MEDIA_QUERY } from '../../constants/breakpoint.constants';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport Drawer from '../Drawer';\nimport IconButton from '../IconButton';\nimport AppShellContext, { type AppShellContextValue, type AppShellLabels } from './context';\n\nimport styles from './index.module.scss';\n\nexport {\n AppShellNav,\n AppShellNavGroup,\n AppShellNavItem,\n type AppShellNavGroupProps,\n type AppShellNavItemProps,\n type AppShellNavLink,\n type AppShellNavProps,\n type AppShellNavSection,\n} from './Nav';\nexport type { AppShellLabels } from './context';\n\ntype Props = {\n /** The top of the sidebar: the logo or the product's name (usually a link home). */\n brand?: ReactNode;\n /** The sidebar's navigation, usually `<AppShellNav>`; drawn again in the narrow-window drawer. */\n navigation: ReactNode;\n /** Above the collapse toggle: help, version, a theme switch. */\n sidebarFooter?: ReactNode;\n /** The top bar's start: the page title or a `Breadcrumb`. */\n title?: ReactNode;\n /** The top bar's middle: a search field or a command palette trigger. */\n search?: ReactNode;\n /** The top bar's end: `NotificationCenter`, `UserMenu`… */\n actions?: ReactNode;\n /** The page. */\n children: ReactNode;\n /** The sidebar shows icons only. Controlled; uncontrolled when omitted. Persist it yourself. */\n isCollapsed?: boolean;\n /** The first state of an uncontrolled sidebar. */\n isDefaultCollapsed?: boolean;\n onCollapsedChange?: (isCollapsed: boolean) => void;\n labels?: Partial<AppShellLabels>;\n className?: string;\n testId?: string;\n};\n\n/**\n * The frame of a signed-in panel (3.2): a sidebar that collapses to icons (a drawer below the\n * tablet width), a sticky top bar and the content. Presentational and router-agnostic: links go\n * through `UiProvider`'s `linkComponent`, the current path comes from `AppShellNav.currentPath`.\n *\n * It publishes two lengths on `<html>`: `--app-sidebar-width` (CSS, for `ToastPortal`'s `inset`)\n * and `--ui-header-height` (the top bar's height, read by the sticky components).\n */\nconst AppShell = ({\n brand,\n navigation,\n sidebarFooter,\n title,\n search,\n actions,\n children,\n isCollapsed,\n isDefaultCollapsed = false,\n onCollapsedChange,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const text = { ...config?.appShell, ...labelProps };\n const mainId = useId();\n const mainRef = useRef<HTMLElement>(null);\n const topbarRef = useRef<HTMLElement>(null);\n\n const [uncontrolledCollapsed, setUncontrolledCollapsed] = useState(isDefaultCollapsed);\n const collapsed = isCollapsed ?? uncontrolledCollapsed;\n const [isDrawerOpen, setIsDrawerOpen] = useState(false);\n\n const setCollapsed = useCallback(\n (next: boolean) => {\n if (isCollapsed === undefined) setUncontrolledCollapsed(next);\n onCollapsedChange?.(next);\n },\n [isCollapsed, onCollapsedChange],\n );\n\n const closeDrawer = useCallback(() => setIsDrawerOpen(false), []);\n const expandSidebar = useCallback(() => setCollapsed(false), [setCollapsed]);\n\n /* The window grew past the tablet width with the drawer open: the sidebar is back, close it. */\n useEffect(() => {\n if (!isDrawerOpen) return;\n const query = window.matchMedia(ABOVE_TABLET_MEDIA_QUERY);\n if (query.matches) {\n setIsDrawerOpen(false);\n return;\n }\n\n const handleChange = (event: MediaQueryListEvent) => {\n if (event.matches) setIsDrawerOpen(false);\n };\n query.addEventListener('change', handleChange);\n return () => query.removeEventListener('change', handleChange);\n }, [isDrawerOpen]);\n\n /* Sticky components (`DataTable` captions, `DirectoryGroup`) stop below the sticky top bar. */\n useEffect(() => {\n const topbar = topbarRef.current;\n if (!topbar || typeof ResizeObserver === 'undefined') return;\n\n const root = document.documentElement;\n const observer = new ResizeObserver(([entry]) =>\n root.style.setProperty('--ui-header-height', `${entry.contentRect.height}px`),\n );\n observer.observe(topbar);\n\n return () => {\n observer.disconnect();\n root.style.removeProperty('--ui-header-height');\n };\n }, []);\n\n /* A hash link would be read as a route by a hash router (Electron): focus the content instead. */\n const handleSkip = (event: MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n mainRef.current?.focus();\n };\n\n const sidebarContext = useMemo<AppShellContextValue>(\n () => ({ isCollapsed: collapsed, onExpandSidebar: expandSidebar, labels: labelProps }),\n [collapsed, expandSidebar, labelProps],\n );\n const drawerContext = useMemo<AppShellContextValue>(\n () => ({ isCollapsed: false, onNavigate: closeDrawer, labels: labelProps }),\n [closeDrawer, labelProps],\n );\n\n const navigationLabel = resolveLabel('AppShell.labels.navigation', text.navigation);\n const toggleLabel = collapsed\n ? resolveLabel('AppShell.labels.expand', text.expand)\n : resolveLabel('AppShell.labels.collapse', text.collapse);\n\n return (\n <div\n className={cx(styles.shell, collapsed && styles['shell--collapsed'], className)}\n data-testid={testId}\n >\n <a href={`#${mainId}`} className={styles.shell__skip} onClick={handleSkip}>\n {resolveLabel('AppShell.labels.skipToContent', text.skipToContent)}\n </a>\n\n <aside className={styles.shell__sidebar}>\n {brand && <div className={styles.shell__brand}>{brand}</div>}\n <AppShellContext.Provider value={sidebarContext}>\n <div className={styles.shell__navigation}>{navigation}</div>\n </AppShellContext.Provider>\n <div className={styles.shell__footer}>\n {sidebarFooter}\n <IconButton\n icon={<ChevronDoubleLeft aria-hidden className={styles.shell__toggle} />}\n label={toggleLabel}\n size=\"sm\"\n className={styles['shell__toggle-button']}\n onClick={() => setCollapsed(!collapsed)}\n />\n </div>\n </aside>\n\n <div className={styles.shell__frame}>\n <header ref={topbarRef} className={styles.shell__topbar}>\n <IconButton\n icon={<List aria-hidden />}\n label={resolveLabel('AppShell.labels.openNavigation', text.openNavigation)}\n className={styles['shell__menu-button']}\n aria-expanded={isDrawerOpen}\n onClick={() => setIsDrawerOpen(true)}\n />\n {title && <div className={styles.shell__title}>{title}</div>}\n {search && <div className={styles.shell__search}>{search}</div>}\n {actions && <div className={styles.shell__actions}>{actions}</div>}\n </header>\n\n <main ref={mainRef} id={mainId} tabIndex={-1} className={styles.shell__content}>\n {children}\n </main>\n </div>\n\n <Drawer\n isOpen={isDrawerOpen}\n onClose={closeDrawer}\n title={navigationLabel}\n side=\"start\"\n size=\"sm\"\n className={styles.shell__drawer}\n >\n {/* Drawn only while open: a closed dialog must not hold a second navigation landmark. */}\n {isDrawerOpen && (\n <AppShellContext.Provider value={drawerContext}>\n {brand && <div className={styles['shell__drawer-brand']}>{brand}</div>}\n {navigation}\n </AppShellContext.Provider>\n )}\n </Drawer>\n </div>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(AppShell, 'AppShell')) as typeof AppShell;\n"],"names":["AppShell","brand","navigation","sidebarFooter","title","search","actions","children","isCollapsed","isDefaultCollapsed","onCollapsedChange","labelProps","className","testId","config","useUi","text","mainId","useId","mainRef","useRef","topbarRef","uncontrolledCollapsed","setUncontrolledCollapsed","useState","collapsed","isDrawerOpen","setIsDrawerOpen","setCollapsed","useCallback","next","closeDrawer","expandSidebar","useEffect","query","ABOVE_TABLET_MEDIA_QUERY","handleChange","event","topbar","root","observer","entry","handleSkip","_a","sidebarContext","useMemo","drawerContext","navigationLabel","resolveLabel","toggleLabel","jsxs","cx","styles","jsx","AppShellContext","IconButton","ChevronDoubleLeft","List","Drawer","index","memo","named"],"mappings":"kkBAuEMA,EAAW,CAAC,CAChB,MAAAC,EACA,WAAAC,EACA,cAAAC,EACA,MAAAC,EACA,OAAAC,EACA,QAAAC,EACA,SAAAC,EACA,YAAAC,EACA,mBAAAC,EAAqB,GACrB,kBAAAC,EACA,OAAQC,EACR,UAAAC,EACA,OAAAC,CACF,IAAa,CACX,KAAM,CAAE,OAAQC,CAAA,EAAWC,QAAA,EACrBC,EAAO,CAAE,GAAGF,GAAA,YAAAA,EAAQ,SAAU,GAAGH,CAAA,EACjCM,EAASC,EAAAA,MAAA,EACTC,EAAUC,EAAAA,OAAoB,IAAI,EAClCC,EAAYD,EAAAA,OAAoB,IAAI,EAEpC,CAACE,EAAuBC,CAAwB,EAAIC,EAAAA,SAASf,CAAkB,EAC/EgB,EAAYjB,GAAec,EAC3B,CAACI,EAAcC,CAAe,EAAIH,EAAAA,SAAS,EAAK,EAEhDI,EAAeC,EAAAA,YAClBC,GAAkB,CACbtB,IAAgB,QAAWe,EAAyBO,CAAI,EAC5DpB,GAAA,MAAAA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A,CACC,KAAMF,EAAAA,IAACI,EAAAA,KAAA,CAAK,cAAW,EAAA,CAAC,EACxB,MAAOT,EAAAA,aAAa,iCAAkChC,EAAK,cAAc,EACzE,UAAWoC,EAAAA,QAAO,oBAAoB,EACtC,gBAAe1B,EACf,QAAS,IAAMC,EAAgB,EAAI,CAAA,CAAA,EAEpCvB,GAASiD,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAAA,QAAO,aAAe,SAAAhD,EAAM,EACrDC,GAAUgD,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAAA,QAAO,cAAgB,SAAA/C,EAAO,EACxDC,GAAW+C,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAAA,QAAO,eAAiB,SAAA9C,CAAA,CAAQ,CAAA,EAC9D,EAEA+C,EAAAA,IAAC,OAAA,CAAK,IAAKlC,EAAS,GAAIF,EAAQ,SAAU,GAAI,UAAWmC,UAAO,eAC7D,SAAA7C,CAAA,CACH,CAAA,EACF,EAEA8C,EAAAA,IAACK,EAAAA,QAAA,CACC,OAAQhC,EACR,QAASK,EACT,MAAOgB,EACP,KAAK,QACL,KAAK,KACL,UAAWK,EAAAA,QAAO,cAGjB,YACCF,EAAAA,KAACI,EAAAA,QAAgB,SAAhB,CAAyB,MAAOR,EAC9B,SAAA,CAAA7C,SAAU,MAAA,CAAI,UAAWmD,EAAAA,QAAO,qBAAqB,EAAI,SAAAnD,EAAM,EAC/DC,CAAA,CAAA,CACH,CAAA,CAAA,CAEJ,CAAA,CAAA,CAGN,EAEAyD,EAA6BC,OAAmBC,EAAAA,MAAM7D,EAAU,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/AppShell/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type MouseEvent,\n type ReactNode,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { ChevronDoubleLeft, List } from 'react-bootstrap-icons';\n\nimport { ABOVE_TABLET_MEDIA_QUERY } from '../../constants/breakpoint.constants';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport Drawer from '../Drawer';\nimport IconButton from '../IconButton';\nimport AppShellContext, { type AppShellContextValue, type AppShellLabels } from './context';\n\nimport styles from './index.module.scss';\n\nexport {\n AppShellNav,\n AppShellNavGroup,\n AppShellNavItem,\n type AppShellNavGroupProps,\n type AppShellNavItemProps,\n type AppShellNavLink,\n type AppShellNavProps,\n type AppShellNavSection,\n} from './Nav';\nexport type { AppShellLabels } from './context';\n\ntype Props = {\n /** The top of the sidebar: the logo or the product's name (usually a link home). */\n brand?: ReactNode;\n /** The sidebar's navigation, usually `<AppShellNav>`; drawn again in the narrow-window drawer. */\n navigation: ReactNode;\n /** Above the collapse toggle: help, version, a theme switch. */\n sidebarFooter?: ReactNode;\n /** The top bar's start: the page title or a `Breadcrumb`. */\n title?: ReactNode;\n /** The top bar's middle: a search field or a command palette trigger. */\n search?: ReactNode;\n /** The top bar's end: `NotificationCenter`, `UserMenu`… */\n actions?: ReactNode;\n /** The page. */\n children: ReactNode;\n /** The sidebar shows icons only. Controlled; uncontrolled when omitted. Persist it yourself. */\n isCollapsed?: boolean;\n /** The first state of an uncontrolled sidebar. */\n isDefaultCollapsed?: boolean;\n onCollapsedChange?: (isCollapsed: boolean) => void;\n labels?: Partial<AppShellLabels>;\n className?: string;\n testId?: string;\n};\n\n/**\n * The frame of a signed-in panel (3.2): a sidebar that collapses to icons (a drawer below the\n * tablet width), a sticky top bar and the content. Presentational and router-agnostic: links go\n * through `UiProvider`'s `linkComponent`, the current path comes from `AppShellNav.currentPath`.\n *\n * It publishes two lengths on `<html>`: `--app-sidebar-width` (CSS, for `ToastPortal`'s `inset`)\n * and `--ui-header-height` (the top bar's height, read by the sticky components).\n */\nconst AppShell = ({\n brand,\n navigation,\n sidebarFooter,\n title,\n search,\n actions,\n children,\n isCollapsed,\n isDefaultCollapsed = false,\n onCollapsedChange,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const text = { ...config?.appShell, ...labelProps };\n const mainId = useId();\n const mainRef = useRef<HTMLElement>(null);\n const topbarRef = useRef<HTMLElement>(null);\n\n const [uncontrolledCollapsed, setUncontrolledCollapsed] = useState(isDefaultCollapsed);\n const collapsed = isCollapsed ?? uncontrolledCollapsed;\n const [isDrawerOpen, setIsDrawerOpen] = useState(false);\n\n const setCollapsed = useCallback(\n (next: boolean) => {\n if (isCollapsed === undefined) setUncontrolledCollapsed(next);\n onCollapsedChange?.(next);\n },\n [isCollapsed, onCollapsedChange],\n );\n\n const closeDrawer = useCallback(() => setIsDrawerOpen(false), []);\n const expandSidebar = useCallback(() => setCollapsed(false), [setCollapsed]);\n\n /* The window grew past the tablet width with the drawer open: the sidebar is back, close it. */\n useEffect(() => {\n if (!isDrawerOpen) return;\n const query = window.matchMedia(ABOVE_TABLET_MEDIA_QUERY);\n if (query.matches) {\n setIsDrawerOpen(false);\n return;\n }\n\n const handleChange = (event: MediaQueryListEvent) => {\n if (event.matches) setIsDrawerOpen(false);\n };\n query.addEventListener('change', handleChange);\n return () => query.removeEventListener('change', handleChange);\n }, [isDrawerOpen]);\n\n /* Sticky components (`DataTable` captions, `DirectoryGroup`) stop below the sticky top bar. */\n useEffect(() => {\n const topbar = topbarRef.current;\n if (!topbar || typeof ResizeObserver === 'undefined') return;\n\n const root = document.documentElement;\n const observer = new ResizeObserver(([entry]) =>\n root.style.setProperty('--ui-header-height', `${entry.contentRect.height}px`),\n );\n observer.observe(topbar);\n\n return () => {\n observer.disconnect();\n root.style.removeProperty('--ui-header-height');\n };\n }, []);\n\n /* A hash link would be read as a route by a hash router (Electron): focus the content instead. */\n const handleSkip = (event: MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n mainRef.current?.focus();\n };\n\n const handleDrawerBrandClick = (event: MouseEvent<HTMLDivElement>) => {\n if ((event.target as Element).closest('a')) closeDrawer();\n };\n\n const sidebarContext = useMemo<AppShellContextValue>(\n () => ({ isCollapsed: collapsed, onExpandSidebar: expandSidebar, labels: labelProps }),\n [collapsed, expandSidebar, labelProps],\n );\n const drawerContext = useMemo<AppShellContextValue>(\n () => ({ isCollapsed: false, onNavigate: closeDrawer, labels: labelProps }),\n [closeDrawer, labelProps],\n );\n\n const navigationLabel = resolveLabel('AppShell.labels.navigation', text.navigation);\n const toggleLabel = collapsed\n ? resolveLabel('AppShell.labels.expand', text.expand)\n : resolveLabel('AppShell.labels.collapse', text.collapse);\n\n return (\n <div\n className={cx(styles.shell, collapsed && styles['shell--collapsed'], className)}\n data-testid={testId}\n >\n <a href={`#${mainId}`} className={styles.shell__skip} onClick={handleSkip}>\n {resolveLabel('AppShell.labels.skipToContent', text.skipToContent)}\n </a>\n\n {/*\n The column paints the background and the rule down the whole page; the inner box is the\n sticky, viewport-tall part that holds the brand, the scrolling links and the toggle (3.2.1).\n */}\n <aside className={styles.shell__sidebar}>\n <div className={styles['shell__sidebar-inner']}>\n {brand && <div className={styles.shell__brand}>{brand}</div>}\n <AppShellContext.Provider value={sidebarContext}>\n <div className={styles.shell__navigation}>{navigation}</div>\n </AppShellContext.Provider>\n <div className={styles.shell__footer}>\n {sidebarFooter}\n <IconButton\n icon={<ChevronDoubleLeft aria-hidden className={styles.shell__toggle} />}\n label={toggleLabel}\n size=\"sm\"\n className={styles['shell__toggle-button']}\n onClick={() => setCollapsed(!collapsed)}\n />\n </div>\n </div>\n </aside>\n\n <div className={styles.shell__frame}>\n <header ref={topbarRef} className={styles.shell__topbar}>\n <IconButton\n icon={<List aria-hidden />}\n label={resolveLabel('AppShell.labels.openNavigation', text.openNavigation)}\n className={styles['shell__menu-button']}\n aria-expanded={isDrawerOpen}\n onClick={() => setIsDrawerOpen(true)}\n />\n {title && <div className={styles.shell__title}>{title}</div>}\n {search && <div className={styles.shell__search}>{search}</div>}\n {actions && <div className={styles.shell__actions}>{actions}</div>}\n </header>\n\n <main ref={mainRef} id={mainId} tabIndex={-1} className={styles.shell__content}>\n {children}\n </main>\n </div>\n\n <Drawer\n isOpen={isDrawerOpen}\n onClose={closeDrawer}\n title={navigationLabel}\n side=\"start\"\n size=\"sm\"\n className={styles.shell__drawer}\n >\n {/* Drawn only while open: a closed dialog must not hold a second navigation landmark. */}\n {isDrawerOpen && (\n <AppShellContext.Provider value={drawerContext}>\n {brand && (\n /* The brand is usually a link home: following it closes the drawer like a nav link. */\n <div className={styles['shell__drawer-brand']} onClick={handleDrawerBrandClick}>\n {brand}\n </div>\n )}\n {navigation}\n </AppShellContext.Provider>\n )}\n </Drawer>\n </div>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(AppShell, 'AppShell')) as typeof AppShell;\n"],"names":["AppShell","brand","navigation","sidebarFooter","title","search","actions","children","isCollapsed","isDefaultCollapsed","onCollapsedChange","labelProps","className","testId","config","useUi","text","mainId","useId","mainRef","useRef","topbarRef","uncontrolledCollapsed","setUncontrolledCollapsed","useState","collapsed","isDrawerOpen","setIsDrawerOpen","setCollapsed","useCallback","next","closeDrawer","expandSidebar","useEffect","query","ABOVE_TABLET_MEDIA_QUERY","handleChange","event","topbar","root","observer","entry","handleSkip","_a","handleDrawerBrandClick","sidebarContext","useMemo","drawerContext","navigationLabel","resolveLabel","toggleLabel","jsxs","cx","styles","jsx","AppShellContext","IconButton","ChevronDoubleLeft","List","Drawer","index","memo","named"],"mappings":"ylBAuEMA,EAAW,CAAC,CAChB,MAAAC,EACA,WAAAC,EACA,cAAAC,EACA,MAAAC,EACA,OAAAC,EACA,QAAAC,EACA,SAAAC,EACA,YAAAC,EACA,mBAAAC,EAAqB,GACrB,kBAAAC,EACA,OAAQC,EACR,UAAAC,EACA,OAAAC,CACF,IAAa,CACX,KAAM,CAAE,OAAQC,CAAA,EAAWC,QAAA,EACrBC,EAAO,CAAE,GAAGF,GAAA,YAAAA,EAAQ,SAAU,GAAGH,CAAA,EACjCM,EAASC,EAAAA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MAAOR,EAC9B,SAAA,CAAA9C,GAECqD,EAAAA,IAAC,OAAI,UAAWD,UAAO,qBAAqB,EAAG,QAAST,EACrD,SAAA3C,EACH,EAEDC,CAAA,CAAA,CACH,CAAA,CAAA,CAEJ,CAAA,CAAA,CAGN,EAEA0D,EAA6BC,OAAmBC,EAAAA,MAAM9D,EAAU,UAAU,CAAC"}
|
|
@@ -1,121 +1,125 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as a, jsx as l } from "react/jsx-runtime";
|
|
3
|
-
import { memo as
|
|
4
|
-
import { ChevronDoubleLeft as
|
|
5
|
-
import { ABOVE_TABLET_MEDIA_QUERY as
|
|
6
|
-
import { cx as
|
|
7
|
-
import { named as
|
|
3
|
+
import { memo as H, useId as J, useRef as D, useState as L, useCallback as b, useEffect as y, useMemo as C } from "react";
|
|
4
|
+
import { ChevronDoubleLeft as K, List as P } from "react-bootstrap-icons";
|
|
5
|
+
import { ABOVE_TABLET_MEDIA_QUERY as W } from "../../constants/breakpoint.constants.js";
|
|
6
|
+
import { cx as X } from "../../helpers/class-name.helper.js";
|
|
7
|
+
import { named as Z } from "../../helpers/component.helper.js";
|
|
8
8
|
import { resolveLabel as c } from "../../helpers/label.helper.js";
|
|
9
|
-
import { useUi as
|
|
10
|
-
import
|
|
9
|
+
import { useUi as ee } from "../../theme/context.js";
|
|
10
|
+
import le from "../Drawer/index.js";
|
|
11
11
|
import I from "../IconButton/index.js";
|
|
12
|
-
import
|
|
13
|
-
const e = {"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"};
|
|
14
|
-
|
|
12
|
+
import R from "./context.js";
|
|
13
|
+
const e = {"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__sidebar-inner":"ui-shell__sidebar-inner-iIXhF","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"};
|
|
14
|
+
import { AppShellNav as be, AppShellNavGroup as Ne, AppShellNavItem as xe } from "./Nav.js";
|
|
15
|
+
const se = ({
|
|
15
16
|
brand: d,
|
|
16
17
|
navigation: N,
|
|
17
|
-
sidebarFooter:
|
|
18
|
+
sidebarFooter: O,
|
|
18
19
|
title: x,
|
|
19
20
|
search: S,
|
|
20
|
-
actions:
|
|
21
|
+
actions: A,
|
|
21
22
|
children: z,
|
|
22
|
-
isCollapsed:
|
|
23
|
-
isDefaultCollapsed:
|
|
24
|
-
onCollapsedChange:
|
|
23
|
+
isCollapsed: u,
|
|
24
|
+
isDefaultCollapsed: B = !1,
|
|
25
|
+
onCollapsedChange: h,
|
|
25
26
|
labels: r,
|
|
26
|
-
className:
|
|
27
|
+
className: T,
|
|
27
28
|
testId: M
|
|
28
29
|
}) => {
|
|
29
|
-
const { labels:
|
|
30
|
+
const { labels: _ } = ee(), n = { ..._ == null ? void 0 : _.appShell, ...r }, g = J(), w = D(null), k = D(null), [U, j] = L(B), o = u ?? U, [i, m] = L(!1), v = b(
|
|
30
31
|
(s) => {
|
|
31
|
-
|
|
32
|
+
u === void 0 && j(s), h == null || h(s);
|
|
32
33
|
},
|
|
33
|
-
[
|
|
34
|
-
),
|
|
35
|
-
|
|
34
|
+
[u, h]
|
|
35
|
+
), p = b(() => m(!1), []), E = b(() => v(!1), [v]);
|
|
36
|
+
y(() => {
|
|
36
37
|
if (!i) return;
|
|
37
|
-
const s = window.matchMedia(
|
|
38
|
+
const s = window.matchMedia(W);
|
|
38
39
|
if (s.matches) {
|
|
39
|
-
|
|
40
|
+
m(!1);
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
const t = (
|
|
43
|
-
|
|
43
|
+
const t = (f) => {
|
|
44
|
+
f.matches && m(!1);
|
|
44
45
|
};
|
|
45
46
|
return s.addEventListener("change", t), () => s.removeEventListener("change", t);
|
|
46
|
-
}, [i]),
|
|
47
|
-
const s =
|
|
47
|
+
}, [i]), y(() => {
|
|
48
|
+
const s = k.current;
|
|
48
49
|
if (!s || typeof ResizeObserver > "u") return;
|
|
49
|
-
const t = document.documentElement,
|
|
50
|
+
const t = document.documentElement, f = new ResizeObserver(
|
|
50
51
|
([F]) => t.style.setProperty("--ui-header-height", `${F.contentRect.height}px`)
|
|
51
52
|
);
|
|
52
|
-
return
|
|
53
|
-
|
|
53
|
+
return f.observe(s), () => {
|
|
54
|
+
f.disconnect(), t.style.removeProperty("--ui-header-height");
|
|
54
55
|
};
|
|
55
56
|
}, []);
|
|
56
57
|
const $ = (s) => {
|
|
57
58
|
var t;
|
|
58
59
|
s.preventDefault(), (t = w.current) == null || t.focus();
|
|
59
|
-
}, q =
|
|
60
|
-
()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
}, q = (s) => {
|
|
61
|
+
s.target.closest("a") && p();
|
|
62
|
+
}, G = C(
|
|
63
|
+
() => ({ isCollapsed: o, onExpandSidebar: E, labels: r }),
|
|
64
|
+
[o, E, r]
|
|
65
|
+
), Q = C(
|
|
66
|
+
() => ({ isCollapsed: !1, onNavigate: p, labels: r }),
|
|
67
|
+
[p, r]
|
|
65
68
|
), V = c("AppShell.labels.navigation", n.navigation), Y = o ? c("AppShell.labels.expand", n.expand) : c("AppShell.labels.collapse", n.collapse);
|
|
66
69
|
return /* @__PURE__ */ a(
|
|
67
70
|
"div",
|
|
68
71
|
{
|
|
69
|
-
className:
|
|
72
|
+
className: X(e.shell, o && e["shell--collapsed"], T),
|
|
70
73
|
"data-testid": M,
|
|
71
74
|
children: [
|
|
72
|
-
/* @__PURE__ */ l("a", { href: `#${
|
|
73
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ l("a", { href: `#${g}`, className: e.shell__skip, onClick: $, children: c("AppShell.labels.skipToContent", n.skipToContent) }),
|
|
76
|
+
/* @__PURE__ */ l("aside", { className: e.shell__sidebar, children: /* @__PURE__ */ a("div", { className: e["shell__sidebar-inner"], children: [
|
|
74
77
|
d && /* @__PURE__ */ l("div", { className: e.shell__brand, children: d }),
|
|
75
|
-
/* @__PURE__ */ l(
|
|
78
|
+
/* @__PURE__ */ l(R.Provider, { value: G, children: /* @__PURE__ */ l("div", { className: e.shell__navigation, children: N }) }),
|
|
76
79
|
/* @__PURE__ */ a("div", { className: e.shell__footer, children: [
|
|
77
|
-
|
|
80
|
+
O,
|
|
78
81
|
/* @__PURE__ */ l(
|
|
79
82
|
I,
|
|
80
83
|
{
|
|
81
|
-
icon: /* @__PURE__ */ l(
|
|
84
|
+
icon: /* @__PURE__ */ l(K, { "aria-hidden": !0, className: e.shell__toggle }),
|
|
82
85
|
label: Y,
|
|
83
86
|
size: "sm",
|
|
84
87
|
className: e["shell__toggle-button"],
|
|
85
|
-
onClick: () =>
|
|
88
|
+
onClick: () => v(!o)
|
|
86
89
|
}
|
|
87
90
|
)
|
|
88
91
|
] })
|
|
89
|
-
] }),
|
|
92
|
+
] }) }),
|
|
90
93
|
/* @__PURE__ */ a("div", { className: e.shell__frame, children: [
|
|
91
|
-
/* @__PURE__ */ a("header", { ref:
|
|
94
|
+
/* @__PURE__ */ a("header", { ref: k, className: e.shell__topbar, children: [
|
|
92
95
|
/* @__PURE__ */ l(
|
|
93
96
|
I,
|
|
94
97
|
{
|
|
95
|
-
icon: /* @__PURE__ */ l(
|
|
98
|
+
icon: /* @__PURE__ */ l(P, { "aria-hidden": !0 }),
|
|
96
99
|
label: c("AppShell.labels.openNavigation", n.openNavigation),
|
|
97
100
|
className: e["shell__menu-button"],
|
|
98
101
|
"aria-expanded": i,
|
|
99
|
-
onClick: () =>
|
|
102
|
+
onClick: () => m(!0)
|
|
100
103
|
}
|
|
101
104
|
),
|
|
102
105
|
x && /* @__PURE__ */ l("div", { className: e.shell__title, children: x }),
|
|
103
106
|
S && /* @__PURE__ */ l("div", { className: e.shell__search, children: S }),
|
|
104
|
-
|
|
107
|
+
A && /* @__PURE__ */ l("div", { className: e.shell__actions, children: A })
|
|
105
108
|
] }),
|
|
106
|
-
/* @__PURE__ */ l("main", { ref: w, id:
|
|
109
|
+
/* @__PURE__ */ l("main", { ref: w, id: g, tabIndex: -1, className: e.shell__content, children: z })
|
|
107
110
|
] }),
|
|
108
111
|
/* @__PURE__ */ l(
|
|
109
|
-
|
|
112
|
+
le,
|
|
110
113
|
{
|
|
111
114
|
isOpen: i,
|
|
112
|
-
onClose:
|
|
115
|
+
onClose: p,
|
|
113
116
|
title: V,
|
|
114
117
|
side: "start",
|
|
115
118
|
size: "sm",
|
|
116
119
|
className: e.shell__drawer,
|
|
117
|
-
children: i && /* @__PURE__ */ a(
|
|
118
|
-
d && /*
|
|
120
|
+
children: i && /* @__PURE__ */ a(R.Provider, { value: Q, children: [
|
|
121
|
+
d && /* The brand is usually a link home: following it closes the drawer like a nav link. */
|
|
122
|
+
/* @__PURE__ */ l("div", { className: e["shell__drawer-brand"], onClick: q, children: d }),
|
|
119
123
|
N
|
|
120
124
|
] })
|
|
121
125
|
}
|
|
@@ -123,8 +127,11 @@ const le = ({
|
|
|
123
127
|
]
|
|
124
128
|
}
|
|
125
129
|
);
|
|
126
|
-
},
|
|
130
|
+
}, ue = /* @__PURE__ */ H(/* @__PURE__ */ Z(se, "AppShell"));
|
|
127
131
|
export {
|
|
128
|
-
|
|
132
|
+
be as AppShellNav,
|
|
133
|
+
Ne as AppShellNavGroup,
|
|
134
|
+
xe as AppShellNavItem,
|
|
135
|
+
ue as default
|
|
129
136
|
};
|
|
130
137
|
//# sourceMappingURL=index.js.map
|