@42-central/ui-react 0.24.0 → 0.26.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/dist/{chunk-YWTOW7PZ.js → chunk-276RL7FX.js} +10 -10
- package/dist/{chunk-YWTOW7PZ.js.map → chunk-276RL7FX.js.map} +1 -1
- package/dist/{chunk-FUNTJZX7.js → chunk-2CL3FKEY.js} +3 -3
- package/dist/{chunk-FUNTJZX7.js.map → chunk-2CL3FKEY.js.map} +1 -1
- package/dist/{chunk-YPFSRZ3T.js → chunk-2NTCQIRP.js} +5 -5
- package/dist/{chunk-YPFSRZ3T.js.map → chunk-2NTCQIRP.js.map} +1 -1
- package/dist/{chunk-D3JYDAUZ.js → chunk-2TZU4LSX.js} +4 -4
- package/dist/{chunk-D3JYDAUZ.js.map → chunk-2TZU4LSX.js.map} +1 -1
- package/dist/{chunk-DJLNGWMM.js → chunk-6IRMKF5T.js} +3 -3
- package/dist/{chunk-DJLNGWMM.js.map → chunk-6IRMKF5T.js.map} +1 -1
- package/dist/{chunk-DT6LKNZF.js → chunk-7247WBTV.js} +5 -4
- package/dist/chunk-7247WBTV.js.map +1 -0
- package/dist/{chunk-F2FSHVO5.js → chunk-7B44J3CF.js} +7 -7
- package/dist/{chunk-F2FSHVO5.js.map → chunk-7B44J3CF.js.map} +1 -1
- package/dist/{chunk-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
- package/dist/chunk-7E7JNWOC.js.map +1 -0
- package/dist/{chunk-7AQ4MN4M.js → chunk-7OGZT7U2.js} +14 -6
- package/dist/chunk-7OGZT7U2.js.map +1 -0
- package/dist/{chunk-UAYENYS2.js → chunk-AKXALCUN.js} +3 -3
- package/dist/{chunk-UAYENYS2.js.map → chunk-AKXALCUN.js.map} +1 -1
- package/dist/{chunk-BE2LWUHY.js → chunk-BMEJBY6H.js} +5 -3
- package/dist/chunk-BMEJBY6H.js.map +1 -0
- package/dist/{chunk-DHJB4UJD.js → chunk-DMI4KS32.js} +5 -5
- package/dist/{chunk-DHJB4UJD.js.map → chunk-DMI4KS32.js.map} +1 -1
- package/dist/{chunk-FB2G4LNH.js → chunk-DSZF2TW6.js} +7 -7
- package/dist/{chunk-FB2G4LNH.js.map → chunk-DSZF2TW6.js.map} +1 -1
- package/dist/{chunk-N66NC6QK.js → chunk-E3XLWMEB.js} +3 -3
- package/dist/{chunk-N66NC6QK.js.map → chunk-E3XLWMEB.js.map} +1 -1
- package/dist/{chunk-MXAACRWE.js → chunk-E52Z2FKU.js} +5 -5
- package/dist/{chunk-MXAACRWE.js.map → chunk-E52Z2FKU.js.map} +1 -1
- package/dist/chunk-F374BNL4.js +129 -0
- package/dist/chunk-F374BNL4.js.map +1 -0
- package/dist/{chunk-3L5GLI67.js → chunk-I4B3N3UX.js} +3 -3
- package/dist/{chunk-3L5GLI67.js.map → chunk-I4B3N3UX.js.map} +1 -1
- package/dist/{chunk-IPYHTCFL.js → chunk-IUK7OJXZ.js} +3 -3
- package/dist/{chunk-IPYHTCFL.js.map → chunk-IUK7OJXZ.js.map} +1 -1
- package/dist/{chunk-HRNWWL3Y.js → chunk-J2NW7JID.js} +61 -29
- package/dist/chunk-J2NW7JID.js.map +1 -0
- package/dist/{chunk-MRAJ45IM.js → chunk-JDPVD2YE.js} +5 -5
- package/dist/{chunk-MRAJ45IM.js.map → chunk-JDPVD2YE.js.map} +1 -1
- package/dist/{chunk-SZEOTXRZ.js → chunk-JFB6O7IY.js} +5 -5
- package/dist/{chunk-SZEOTXRZ.js.map → chunk-JFB6O7IY.js.map} +1 -1
- package/dist/{chunk-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
- package/dist/chunk-KKLCHLCZ.js.map +1 -0
- package/dist/{chunk-6N6J2DOE.js → chunk-LIZWCWED.js} +3 -3
- package/dist/{chunk-6N6J2DOE.js.map → chunk-LIZWCWED.js.map} +1 -1
- package/dist/chunk-LJVIZNPE.js +9 -0
- package/dist/chunk-LJVIZNPE.js.map +1 -0
- package/dist/{chunk-HQPU73WV.js → chunk-LYGOFMXJ.js} +3 -3
- package/dist/{chunk-HQPU73WV.js.map → chunk-LYGOFMXJ.js.map} +1 -1
- package/dist/{chunk-JVG5ISPT.js → chunk-N42EFOML.js} +4 -4
- package/dist/{chunk-JVG5ISPT.js.map → chunk-N42EFOML.js.map} +1 -1
- package/dist/{chunk-C4NFRSOR.js → chunk-NF2PBGD3.js} +38 -25
- package/dist/chunk-NF2PBGD3.js.map +1 -0
- package/dist/{chunk-DA4QII2N.js → chunk-NLSJ6T7V.js} +4 -4
- package/dist/{chunk-DA4QII2N.js.map → chunk-NLSJ6T7V.js.map} +1 -1
- package/dist/{chunk-UT3TOV2Q.js → chunk-OVT2KZHY.js} +3 -3
- package/dist/{chunk-UT3TOV2Q.js.map → chunk-OVT2KZHY.js.map} +1 -1
- package/dist/{chunk-MW42XVPD.js → chunk-PBSVX5DB.js} +15 -5
- package/dist/chunk-PBSVX5DB.js.map +1 -0
- package/dist/{chunk-SVKN5ZHX.js → chunk-PEHFWGTT.js} +16 -13
- package/dist/chunk-PEHFWGTT.js.map +1 -0
- package/dist/{chunk-J44FJ7PH.js → chunk-PFZMB3US.js} +4 -4
- package/dist/{chunk-J44FJ7PH.js.map → chunk-PFZMB3US.js.map} +1 -1
- package/dist/{chunk-IRNF274I.js → chunk-PT22KEVD.js} +5 -5
- package/dist/{chunk-IRNF274I.js.map → chunk-PT22KEVD.js.map} +1 -1
- package/dist/{chunk-OZMSXYBX.js → chunk-QEAF57ZQ.js} +4 -4
- package/dist/{chunk-OZMSXYBX.js.map → chunk-QEAF57ZQ.js.map} +1 -1
- package/dist/{chunk-SWVUXEBT.js → chunk-SCXXJDKQ.js} +3 -3
- package/dist/{chunk-SWVUXEBT.js.map → chunk-SCXXJDKQ.js.map} +1 -1
- package/dist/{chunk-E5H3YWZV.js → chunk-SOUDKESO.js} +15 -8
- package/dist/chunk-SOUDKESO.js.map +1 -0
- package/dist/{chunk-4FEOMQYR.js → chunk-THGJLR5S.js} +6 -6
- package/dist/{chunk-4FEOMQYR.js.map → chunk-THGJLR5S.js.map} +1 -1
- package/dist/{chunk-TCFB23JT.js → chunk-WERJ44ZN.js} +3 -3
- package/dist/{chunk-TCFB23JT.js.map → chunk-WERJ44ZN.js.map} +1 -1
- package/dist/{chunk-QNKD2SQM.js → chunk-X3YIHN2U.js} +5 -5
- package/dist/{chunk-QNKD2SQM.js.map → chunk-X3YIHN2U.js.map} +1 -1
- package/dist/{chunk-VD6PB3VA.js → chunk-X6DESK37.js} +12 -3
- package/dist/chunk-X6DESK37.js.map +1 -0
- package/dist/{chunk-47LEAR6G.js → chunk-Y2G47ARQ.js} +6 -6
- package/dist/{chunk-47LEAR6G.js.map → chunk-Y2G47ARQ.js.map} +1 -1
- package/dist/{chunk-O7LS6OZR.js → chunk-YMVUQ2L7.js} +4 -4
- package/dist/{chunk-O7LS6OZR.js.map → chunk-YMVUQ2L7.js.map} +1 -1
- package/dist/{chunk-F342ZT7O.js → chunk-ZVECQBGG.js} +13 -7
- package/dist/chunk-ZVECQBGG.js.map +1 -0
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +1 -1
- package/dist/components/alert/index.js +1 -1
- package/dist/components/ambient-background/index.js +14 -26
- package/dist/components/ambient-background/index.js.map +1 -1
- package/dist/components/ambient-background/starfield.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +55 -10
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +1 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +300 -39
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/index.js +5 -5
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/index.js +12 -3
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/button-group.d.ts +10 -2
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/button-multi-select/index.js +4 -4
- package/dist/components/button-select/button-select-control.d.ts +4 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +4 -1
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +4 -4
- package/dist/components/calendar/index.js +4 -4
- package/dist/components/calendar-heatmap/index.js +2 -2
- package/dist/components/camera/index.js +12 -12
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/index.js +1 -1
- package/dist/components/carousel/index.js +2 -2
- package/dist/components/checkbox/checkbox.d.ts +3 -2
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/choice-card-group/index.js +2 -2
- package/dist/components/choice-card-group/index.js.map +1 -1
- package/dist/components/clipboard/index.js +3 -3
- package/dist/components/code-block/chrome.js +3 -3
- package/dist/components/code-block/code-block.d.ts +6 -3
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/highlighter.d.ts +16 -15
- package/dist/components/code-block/highlighter.d.ts.map +1 -1
- package/dist/components/code-block/index.d.ts +2 -1
- package/dist/components/code-block/index.d.ts.map +1 -1
- package/dist/components/code-block/index.js +85 -14
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/code-block/languages.d.ts +61 -0
- package/dist/components/code-block/languages.d.ts.map +1 -0
- package/dist/components/code-block/static.d.ts +2 -1
- package/dist/components/code-block/static.d.ts.map +1 -1
- package/dist/components/code-block/static.js +99 -10
- package/dist/components/code-block/static.js.map +1 -1
- package/dist/components/combobox/index.js +5 -5
- package/dist/components/combobox-list/index.js +7 -7
- package/dist/components/compare/index.js +2 -2
- package/dist/components/data-table/index.js +32 -32
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/index.js +14 -14
- package/dist/components/download-button/index.js +2 -2
- package/dist/components/drawer/index.js +5 -5
- package/dist/components/field/field.d.ts +3 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/file-item/index.js +5 -5
- package/dist/components/file-preview/index.js +5 -5
- package/dist/components/file-trigger/index.js +2 -2
- package/dist/components/file-upload/index.js +6 -6
- package/dist/components/gallery/index.js +2 -2
- package/dist/components/geodesic/badge-frame.d.ts +13 -1
- package/dist/components/geodesic/badge-frame.d.ts.map +1 -1
- package/dist/components/geodesic/exam-badge.d.ts +4 -1
- package/dist/components/geodesic/exam-badge.d.ts.map +1 -1
- package/dist/components/geodesic/geometry.d.ts +14 -9
- package/dist/components/geodesic/geometry.d.ts.map +1 -1
- package/dist/components/geodesic/index.js +62 -23
- package/dist/components/geodesic/index.js.map +1 -1
- package/dist/components/geodesic/status.d.ts +8 -6
- package/dist/components/geodesic/status.d.ts.map +1 -1
- package/dist/components/geodesic/styles.css +15 -2
- package/dist/components/hover-card/index.js +2 -2
- package/dist/components/image-cropper/index.js +7 -7
- package/dist/components/indicator/index.js +24 -9
- package/dist/components/indicator/index.js.map +1 -1
- package/dist/components/indicator/indicator.d.ts +15 -6
- package/dist/components/indicator/indicator.d.ts.map +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.js +8 -8
- package/dist/components/menu/index.js +4 -4
- package/dist/components/modal/index.js +5 -5
- package/dist/components/multi-combobox-list/index.js +7 -7
- package/dist/components/multi-select/index.js +8 -8
- package/dist/components/nav-link/index.js +5 -1
- package/dist/components/nav-link/nav-link.d.ts.map +1 -1
- package/dist/components/nav-link/tanstack.js +5 -1
- package/dist/components/nav-link/tanstack.js.map +1 -1
- package/dist/components/number-input/index.js +5 -5
- package/dist/components/overlays/index.js +7 -7
- package/dist/components/password-input/index.js +3 -3
- package/dist/components/photo-capture/index.js +16 -16
- package/dist/components/pills-input/index.js +5 -5
- package/dist/components/pin-input/index.js +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/index.js +1 -1
- package/dist/components/schedule/index.js +7 -7
- package/dist/components/segment-group/index.js +4 -4
- package/dist/components/segment-group/segment-group.d.ts +6 -1
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +6 -6
- package/dist/components/slider/index.js +2 -2
- package/dist/components/spotlight/index.js +11 -11
- package/dist/components/switch/index.js +14 -19
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts +1 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/tabs/index.js +3 -3
- package/dist/components/tabs/tabs-data.d.ts +4 -1
- package/dist/components/tabs/tabs-data.d.ts.map +1 -1
- package/dist/components/tabs/tabs.d.ts +4 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +7 -7
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/theme-icon/index.js +1 -1
- package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
- package/dist/components/time-input/index.js +9 -9
- package/dist/components/tree-multi-select/index.js +8 -8
- package/dist/components/tree-select/index.js +5 -5
- package/dist/index.js +4 -4
- package/dist/lib/sidebar-rail.d.ts +21 -0
- package/dist/lib/sidebar-rail.d.ts.map +1 -0
- package/dist/theme.css +35 -35
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +6 -0
- package/src/components/action-icon/action-icon.tsx +3 -1
- package/src/components/ambient-background/starfield.tsx +18 -43
- package/src/components/app-shell/app-shell.test.tsx +430 -5
- package/src/components/app-shell/app-shell.tsx +484 -24
- package/src/components/app-shell/index.ts +2 -0
- package/src/components/avatar/avatar.test.tsx +12 -0
- package/src/components/avatar/avatar.tsx +9 -0
- package/src/components/badge/badge.tsx +11 -6
- package/src/components/button/button.tsx +1 -1
- package/src/components/button-group/button-group.test.tsx +24 -0
- package/src/components/button-group/button-group.tsx +21 -4
- package/src/components/button-multi-select/button-multi-select.test.tsx +15 -0
- package/src/components/button-select/button-select-control.tsx +5 -0
- package/src/components/button-select/button-select.test.tsx +25 -0
- package/src/components/button-select/button-select.tsx +13 -2
- package/src/components/card/card.tsx +10 -9
- package/src/components/checkbox/checkbox.test.tsx +17 -9
- package/src/components/checkbox/checkbox.tsx +26 -27
- package/src/components/choice-card-group/choice-card-group.tsx +3 -3
- package/src/components/code-block/code-block.tsx +7 -4
- package/src/components/code-block/highlighter.test.ts +79 -1
- package/src/components/code-block/highlighter.ts +76 -30
- package/src/components/code-block/index.ts +2 -0
- package/src/components/code-block/languages.ts +63 -0
- package/src/components/code-block/static.tsx +2 -1
- package/src/components/data-table/data-table-pagination.tsx +5 -5
- package/src/components/data-table/data-table-stack.tsx +2 -2
- package/src/components/field/field.tsx +14 -0
- package/src/components/geodesic/badge-frame.tsx +67 -13
- package/src/components/geodesic/exam-badge.tsx +8 -4
- package/src/components/geodesic/geometry.ts +8 -6
- package/src/components/geodesic/status.test.ts +11 -2
- package/src/components/geodesic/status.ts +11 -7
- package/src/components/geodesic/styles.css +15 -2
- package/src/components/indicator/indicator.test.tsx +45 -0
- package/src/components/indicator/indicator.tsx +40 -13
- package/src/components/kbd/kbd.tsx +2 -1
- package/src/components/nav-link/nav-link.test.tsx +121 -1
- package/src/components/nav-link/nav-link.tsx +78 -29
- package/src/components/segment-group/segment-group.test.tsx +22 -0
- package/src/components/segment-group/segment-group.tsx +35 -19
- package/src/components/switch/switch.test.tsx +15 -0
- package/src/components/switch/switch.tsx +27 -27
- package/src/components/table/table.test.tsx +1 -1
- package/src/components/table/table.tsx +14 -11
- package/src/components/tabs/tabs-data.tsx +5 -1
- package/src/components/tabs/tabs.test.tsx +28 -0
- package/src/components/tabs/tabs.tsx +14 -4
- package/src/components/theme-icon/theme-icon.tsx +46 -12
- package/src/lib/sidebar-rail.ts +24 -0
- package/src/theme.css +35 -35
- package/src/theme.test.ts +0 -1
- package/dist/chunk-2MXWEIMD.js.map +0 -1
- package/dist/chunk-6VYGK3Q3.js.map +0 -1
- package/dist/chunk-7AQ4MN4M.js.map +0 -1
- package/dist/chunk-7CNDZZZ6.js +0 -95
- package/dist/chunk-7CNDZZZ6.js.map +0 -1
- package/dist/chunk-BE2LWUHY.js.map +0 -1
- package/dist/chunk-C4NFRSOR.js.map +0 -1
- package/dist/chunk-DT6LKNZF.js.map +0 -1
- package/dist/chunk-E5H3YWZV.js.map +0 -1
- package/dist/chunk-F342ZT7O.js.map +0 -1
- package/dist/chunk-HRNWWL3Y.js.map +0 -1
- package/dist/chunk-MW42XVPD.js.map +0 -1
- package/dist/chunk-SVKN5ZHX.js.map +0 -1
- package/dist/chunk-VD6PB3VA.js.map +0 -1
|
@@ -3,6 +3,7 @@ import { type ComponentPropsWithoutRef, type Dispatch, type Ref, type SetStateAc
|
|
|
3
3
|
import type { NoAsChild } from "../../lib/as-child";
|
|
4
4
|
import type { Size } from "../../lib/sizes";
|
|
5
5
|
import type { WithTestId } from "../../lib/test-id";
|
|
6
|
+
import { type Updater } from "../../lib/use-uncontrolled";
|
|
6
7
|
/**
|
|
7
8
|
* AppShell — header / sidebar / main / aside app frame, laid out with CSS
|
|
8
9
|
* Grid named areas. Sidebar spans the full height on the left; Header
|
|
@@ -11,10 +12,14 @@ import type { WithTestId } from "../../lib/test-id";
|
|
|
11
12
|
* Aside sits below Header, full height only within the remaining row,
|
|
12
13
|
* beside Main. No Footer — add one only once a real consumer needs it.
|
|
13
14
|
*
|
|
14
|
-
* Sidebar is
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* On desktop, Sidebar is a grid column that can be collapsed — opt in by
|
|
16
|
+
* rendering an `AppShell.SidebarCollapseTrigger` (or driving `collapsed`):
|
|
17
|
+
* the column animates to zero and the sidebar slides off the start edge,
|
|
18
|
+
* coming back as a floating card while the pointer rests on that edge
|
|
19
|
+
* (fumadocs' docs sidebar behaves the same way). Below `breakpoint`, it
|
|
20
|
+
* becomes an overlay `Drawer` instead, toggled by `AppShell.SidebarTrigger`
|
|
21
|
+
* (which renders nothing on desktop — `SidebarCollapseTrigger` is its
|
|
22
|
+
* desktop counterpart, and renders nothing on mobile). Aside works
|
|
18
23
|
* differently: it's always mounted (no JS/container-query gating at all,
|
|
19
24
|
* unlike Sidebar) and purely CSS-driven — hidden below a `@xl` container
|
|
20
25
|
* breakpoint, visible above it — mirroring how fumadocs' own docs layout
|
|
@@ -50,7 +55,14 @@ export type AppShellState = {
|
|
|
50
55
|
setMobileOpen: Dispatch<SetStateAction<boolean>>;
|
|
51
56
|
/** Whether `AppShell` is narrower than its `breakpoint`, so Sidebar is a drawer. */
|
|
52
57
|
isMobile: boolean;
|
|
53
|
-
/**
|
|
58
|
+
/** Whether the desktop sidebar is collapsed. Has no effect below
|
|
59
|
+
* `breakpoint`, where the sidebar is a drawer either way. */
|
|
60
|
+
collapsed: boolean;
|
|
61
|
+
/** Collapses or expands the desktop sidebar — e.g. from a keyboard
|
|
62
|
+
* shortcut. Goes through `onCollapsedChange` when `collapsed` is controlled. */
|
|
63
|
+
setCollapsed: (updater: Updater<boolean>) => void;
|
|
64
|
+
/** Id of the sidebar — the drawer's content on mobile, the docked column on
|
|
65
|
+
* desktop — which both triggers' `aria-controls` point at. */
|
|
54
66
|
sidebarId: string;
|
|
55
67
|
};
|
|
56
68
|
/**
|
|
@@ -67,14 +79,28 @@ export type AppShellProps = HTMLArkProps<"div"> & WithTestId & {
|
|
|
67
79
|
* overlay `Drawer` instead of a grid column — measured against the
|
|
68
80
|
* container itself via `ResizeObserver`, not the viewport. @default 768 */
|
|
69
81
|
breakpoint?: number;
|
|
82
|
+
/** Whether the desktop sidebar is collapsed (controlled). Ignored below
|
|
83
|
+
* `breakpoint`. */
|
|
84
|
+
collapsed?: boolean;
|
|
85
|
+
/** Initial collapsed state (uncontrolled). @default false */
|
|
86
|
+
defaultCollapsed?: boolean;
|
|
87
|
+
/** Called when a `SidebarCollapseTrigger` (or `useAppShell().setCollapsed`)
|
|
88
|
+
* collapses or expands the desktop sidebar. */
|
|
89
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
70
90
|
/** Lands on the grid root; also used internally to measure `breakpoint`
|
|
71
91
|
* against the container's own width. */
|
|
72
92
|
ref?: Ref<HTMLDivElement>;
|
|
73
93
|
};
|
|
74
|
-
declare const AppShellRoot: ({ breakpoint, className, style, children, ref, testId, onClick, ...rest }: AppShellProps) => import("react").JSX.Element;
|
|
94
|
+
declare const AppShellRoot: ({ breakpoint, collapsed: collapsedProp, defaultCollapsed, onCollapsedChange, className, style, children, ref, testId, onClick, ...rest }: AppShellProps) => import("react").JSX.Element;
|
|
95
|
+
export type AppShellSidebarCollapse = "hide" | "icons";
|
|
75
96
|
export type AppShellSidebarProps = NoAsChild<HTMLArkProps<"aside">> & WithTestId & {
|
|
76
97
|
/** Width when expanded, from the kit's Size scale. @default "md" */
|
|
77
98
|
size?: Size;
|
|
99
|
+
/** What collapsing does on desktop. `"hide"` slides the sidebar off the
|
|
100
|
+
* edge, peeking back as a card on hover at the edge. `"icons"` shrinks it
|
|
101
|
+
* to a 68px icon rail: labels turn into tooltips, and resting on the rail
|
|
102
|
+
* peeks the full sidebar over the page. @default "hide" */
|
|
103
|
+
collapse?: AppShellSidebarCollapse;
|
|
78
104
|
};
|
|
79
105
|
/**
|
|
80
106
|
* Below `breakpoint`, renders through the kit's own `Drawer` instead of the
|
|
@@ -106,12 +132,13 @@ export type AppShellSidebarProps = NoAsChild<HTMLArkProps<"aside">> & WithTestId
|
|
|
106
132
|
* no `title`, so without one of those it is a dialog with no name (and
|
|
107
133
|
* `Drawer` warns in development).
|
|
108
134
|
*/
|
|
109
|
-
declare const AppShellSidebar: ({ size, className, children, testId, asChild: _asChild, ...rest }: AppShellSidebarProps) => import("react").JSX.Element;
|
|
135
|
+
declare const AppShellSidebar: ({ size, collapse, className, children, testId, asChild: _asChild, ...rest }: AppShellSidebarProps) => import("react").JSX.Element;
|
|
110
136
|
export type AppShellSidebarHeaderProps = ComponentPropsWithoutRef<"div"> & WithTestId;
|
|
111
137
|
declare const AppShellSidebarHeader: ({ className, testId, ...rest }: AppShellSidebarHeaderProps) => import("react").JSX.Element;
|
|
112
138
|
export type AppShellSidebarBodyProps = ComponentPropsWithoutRef<"div"> & WithTestId;
|
|
113
139
|
/**
|
|
114
|
-
* The scroll region — the only part of Sidebar that scrolls.
|
|
140
|
+
* The scroll region — the only part of Sidebar that scrolls. On an icon rail
|
|
141
|
+
* its scrollbar is hidden (no room for one). The mask fades
|
|
115
142
|
* content at the top/bottom edges instead of clipping it on a hard line
|
|
116
143
|
* (fumadocs' own docs sidebar uses the same static mask on its nav
|
|
117
144
|
* viewport); `overscroll-contain` stops scrolling the list from chaining
|
|
@@ -226,18 +253,36 @@ export type AppShellAsideProps = HTMLArkProps<"aside"> & WithTestId & {
|
|
|
226
253
|
declare const AppShellAside: ({ size, className, testId, ...rest }: AppShellAsideProps) => import("react").JSX.Element;
|
|
227
254
|
export type AppShellSidebarTriggerProps = HTMLArkProps<"button"> & WithTestId;
|
|
228
255
|
/**
|
|
229
|
-
* Opens/closes the mobile `Drawer`. Renders nothing above `breakpoint
|
|
230
|
-
*
|
|
256
|
+
* Opens/closes the mobile `Drawer`. Renders nothing above `breakpoint`,
|
|
257
|
+
* where the sidebar is a grid column — `SidebarCollapseTrigger` is the
|
|
258
|
+
* desktop counterpart that collapses it.
|
|
231
259
|
* `asChild`-able, like every other kit trigger. Carries `aria-expanded` and
|
|
232
260
|
* `aria-controls` (the drawer's content), like any disclosure button.
|
|
233
261
|
*/
|
|
234
262
|
declare const AppShellSidebarTrigger: ({ onClick, testId, ...rest }: AppShellSidebarTriggerProps) => import("react").JSX.Element | null;
|
|
263
|
+
export type AppShellSidebarCollapseTriggerProps = HTMLArkProps<"button"> & WithTestId;
|
|
264
|
+
/**
|
|
265
|
+
* Collapses/expands the desktop sidebar — `SidebarTrigger`'s desktop
|
|
266
|
+
* counterpart, and its mirror image: renders nothing below `breakpoint`,
|
|
267
|
+
* where the sidebar is a drawer and there's nothing to collapse. Rendering one
|
|
268
|
+
* is what opts a shell into collapsing. `asChild`-able; carries
|
|
269
|
+
* `aria-expanded`, `aria-controls` and `data-collapsed`.
|
|
270
|
+
*
|
|
271
|
+
* Usually rendered twice: in `SidebarHeader` to collapse, and in `Header` to
|
|
272
|
+
* expand again (the one in the sidebar slides away with it) — the Header one
|
|
273
|
+
* often only while `useAppShell().collapsed`. Collapsing from the one inside
|
|
274
|
+
* the sidebar hands focus to a collapse trigger outside it, including one
|
|
275
|
+
* that only just rendered, since the collapsed sidebar is `inert` and would
|
|
276
|
+
* otherwise drop focus on the floor.
|
|
277
|
+
*/
|
|
278
|
+
declare const AppShellSidebarCollapseTrigger: ({ onClick, testId, ...rest }: AppShellSidebarCollapseTriggerProps) => import("react").JSX.Element | null;
|
|
235
279
|
export declare const AppShell: typeof AppShellRoot & {
|
|
236
280
|
Sidebar: typeof AppShellSidebar;
|
|
237
281
|
SidebarHeader: typeof AppShellSidebarHeader;
|
|
238
282
|
SidebarBody: typeof AppShellSidebarBody;
|
|
239
283
|
SidebarFooter: typeof AppShellSidebarFooter;
|
|
240
284
|
SidebarTrigger: typeof AppShellSidebarTrigger;
|
|
285
|
+
SidebarCollapseTrigger: typeof AppShellSidebarCollapseTrigger;
|
|
241
286
|
Header: typeof AppShellHeader;
|
|
242
287
|
Main: typeof AppShellMain;
|
|
243
288
|
Full: typeof AppShellFull;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-shell.d.ts","sourceRoot":"","sources":["../../../src/components/app-shell/app-shell.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EACL,KAAK,wBAAwB,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@
|
|
|
1
|
-
export { AppShell, type AppShellAsideProps, type AppShellContentProps, type AppShellFullProps, type AppShellHeaderProps, type AppShellMainProps, type AppShellMainSize, type AppShellProps, type AppShellSidebarBodyProps, type AppShellSidebarFooterProps, type AppShellSidebarHeaderProps, type AppShellSidebarProps, type AppShellSidebarTriggerProps, type AppShellState, useAppShell, } from "./app-shell";
|
|
1
|
+
export { AppShell, type AppShellAsideProps, type AppShellContentProps, type AppShellFullProps, type AppShellHeaderProps, type AppShellMainProps, type AppShellMainSize, type AppShellProps, type AppShellSidebarBodyProps, type AppShellSidebarCollapse, type AppShellSidebarCollapseTriggerProps, type AppShellSidebarFooterProps, type AppShellSidebarHeaderProps, type AppShellSidebarProps, type AppShellSidebarTriggerProps, type AppShellState, useAppShell, } from "./app-shell";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/app-shell/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,aAAa,EAClB,WAAW,GACZ,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/app-shell/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,mCAAmC,EACxC,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,aAAa,EAClB,WAAW,GACZ,MAAM,aAAa,CAAA"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Drawer } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
2
|
+
import { Drawer } from '../../chunk-YMVUQ2L7.js';
|
|
3
|
+
import '../../chunk-NLSJ6T7V.js';
|
|
4
4
|
import { useContainerQuery } from '../../chunk-4G3N7UMJ.js';
|
|
5
5
|
import '../../chunk-2LI3VPDP.js';
|
|
6
6
|
import { useMergedRefs } from '../../chunk-HBWV5EPU.js';
|
|
7
|
-
import '../../chunk-
|
|
7
|
+
import { SidebarRailContext } from '../../chunk-LJVIZNPE.js';
|
|
8
8
|
import '../../chunk-H7WOMZXO.js';
|
|
9
|
-
import '../../chunk-
|
|
10
|
-
import '../../chunk-
|
|
11
|
-
import '../../chunk-
|
|
9
|
+
import '../../chunk-7P32XCEU.js';
|
|
10
|
+
import '../../chunk-BMEJBY6H.js';
|
|
11
|
+
import '../../chunk-LIZWCWED.js';
|
|
12
|
+
import { useUncontrolled } from '../../chunk-PMUCGFY5.js';
|
|
13
|
+
import { useIsomorphicLayoutEffect } from '../../chunk-BUIHQJGE.js';
|
|
12
14
|
import '../../chunk-XXOR34T4.js';
|
|
13
15
|
import '../../chunk-D2QIPQ74.js';
|
|
14
16
|
import '../../chunk-R5LYFTHA.js';
|
|
@@ -17,8 +19,9 @@ import '../../chunk-C6NVU4F7.js';
|
|
|
17
19
|
import { TEXT_COLOR_CLASSES } from '../../chunk-GIPQUKCN.js';
|
|
18
20
|
import { cn } from '../../chunk-4ASNIDV7.js';
|
|
19
21
|
import { ark } from '@ark-ui/react';
|
|
20
|
-
import { createContext, useRef, useState, useId, useContext } from 'react';
|
|
21
|
-
import {
|
|
22
|
+
import { createContext, useRef, useState, useId, useContext, useEffect } from 'react';
|
|
23
|
+
import { flushSync } from 'react-dom';
|
|
24
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
22
25
|
|
|
23
26
|
var AppShellContext = createContext(null);
|
|
24
27
|
function useAppShell() {
|
|
@@ -35,6 +38,9 @@ var followsLink = (event, drawer) => {
|
|
|
35
38
|
};
|
|
36
39
|
var AppShellRoot = ({
|
|
37
40
|
breakpoint = 768,
|
|
41
|
+
collapsed: collapsedProp,
|
|
42
|
+
defaultCollapsed,
|
|
43
|
+
onCollapsedChange,
|
|
38
44
|
className,
|
|
39
45
|
style,
|
|
40
46
|
children,
|
|
@@ -45,29 +51,44 @@ var AppShellRoot = ({
|
|
|
45
51
|
}) => {
|
|
46
52
|
const rootRef = useRef(null);
|
|
47
53
|
const [mobileOpen, setMobileOpen] = useState(false);
|
|
54
|
+
const [collapsed, setCollapsed] = useUncontrolled({
|
|
55
|
+
value: collapsedProp,
|
|
56
|
+
defaultValue: defaultCollapsed,
|
|
57
|
+
finalValue: false,
|
|
58
|
+
onChange: onCollapsedChange
|
|
59
|
+
});
|
|
48
60
|
const isMobile = useContainerQuery(rootRef, breakpoint);
|
|
49
61
|
const sidebarId = `app-shell-sidebar-${useId()}`;
|
|
50
62
|
const mergedRef = useMergedRefs(ref, rootRef);
|
|
51
|
-
return /* @__PURE__ */ jsx(
|
|
52
|
-
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
AppShellContext.Provider,
|
|
53
65
|
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
value: { mobileOpen, setMobileOpen, isMobile, collapsed, setCollapsed, sidebarId },
|
|
67
|
+
children: /* @__PURE__ */ jsx(
|
|
68
|
+
ark.div,
|
|
69
|
+
{
|
|
70
|
+
...props({
|
|
71
|
+
"data-testid": testId,
|
|
72
|
+
"data-sidebar-collapsed": collapsed && !isMobile
|
|
73
|
+
}),
|
|
74
|
+
...rest,
|
|
75
|
+
ref: mergedRef,
|
|
76
|
+
onClick: (event) => {
|
|
77
|
+
onClick?.(event);
|
|
78
|
+
if (mobileOpen && followsLink(event, document.getElementById(sidebarId))) {
|
|
79
|
+
setMobileOpen(false);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
style: { gridTemplateAreas: `"sidebar header header" "sidebar main aside"`, ...style },
|
|
83
|
+
className: cn(
|
|
84
|
+
"@container grid h-dvh grid-cols-[auto_1fr_auto] grid-rows-[auto_1fr] overflow-hidden",
|
|
85
|
+
className
|
|
86
|
+
),
|
|
87
|
+
children
|
|
61
88
|
}
|
|
62
|
-
|
|
63
|
-
style: { gridTemplateAreas: `"sidebar header header" "sidebar main aside"`, ...style },
|
|
64
|
-
className: cn(
|
|
65
|
-
"@container grid h-dvh grid-cols-[auto_1fr_auto] grid-rows-[auto_1fr] overflow-hidden",
|
|
66
|
-
className
|
|
67
|
-
),
|
|
68
|
-
children
|
|
89
|
+
)
|
|
69
90
|
}
|
|
70
|
-
)
|
|
91
|
+
);
|
|
71
92
|
};
|
|
72
93
|
var SIDEBAR_WIDTH = {
|
|
73
94
|
xs: "w-56",
|
|
@@ -76,15 +97,25 @@ var SIDEBAR_WIDTH = {
|
|
|
76
97
|
lg: "w-80",
|
|
77
98
|
xl: "w-96"
|
|
78
99
|
};
|
|
100
|
+
var RAIL_WIDTH = "w-[calc(--spacing(17)+1px)]";
|
|
101
|
+
var RAIL_PEEK_DELAY = 1200;
|
|
102
|
+
var RAIL_REST_TOLERANCE = 4;
|
|
79
103
|
var AppShellSidebar = ({
|
|
80
104
|
size = "md",
|
|
105
|
+
collapse = "hide",
|
|
81
106
|
className,
|
|
82
107
|
children,
|
|
83
108
|
testId,
|
|
84
109
|
asChild: _asChild,
|
|
85
110
|
...rest
|
|
86
111
|
}) => {
|
|
87
|
-
const { isMobile, mobileOpen, setMobileOpen, sidebarId } = useAppShell();
|
|
112
|
+
const { isMobile, mobileOpen, setMobileOpen, collapsed, sidebarId } = useAppShell();
|
|
113
|
+
const columnRef = useRef(null);
|
|
114
|
+
const asideRef = useRef(null);
|
|
115
|
+
const icons = collapse === "icons";
|
|
116
|
+
const { peeking, restPoint, onPointerEnter, onPointerMove, onPointerLeave, onScrollActivity } = useSidebarPeek(collapsed, columnRef, asideRef, icons ? RAIL_PEEK_DELAY : 0);
|
|
117
|
+
const rail = icons && collapsed && !peeking;
|
|
118
|
+
useRailAnchor(icons && collapsed && !isMobile, peeking, asideRef, restPoint);
|
|
88
119
|
if (isMobile) {
|
|
89
120
|
return /* @__PURE__ */ jsx(
|
|
90
121
|
Drawer,
|
|
@@ -103,25 +134,217 @@ var AppShellSidebar = ({
|
|
|
103
134
|
}
|
|
104
135
|
);
|
|
105
136
|
}
|
|
106
|
-
return /* @__PURE__ */
|
|
107
|
-
|
|
137
|
+
return /* @__PURE__ */ jsxs(
|
|
138
|
+
"div",
|
|
108
139
|
{
|
|
109
|
-
|
|
110
|
-
|
|
140
|
+
ref: columnRef,
|
|
141
|
+
id: sidebarId,
|
|
111
142
|
className: cn(
|
|
112
|
-
"[grid-area:sidebar]
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// own chrome (border-brand-900/20 dark:border-white/15, bg-brand-50/90
|
|
116
|
-
// dark:bg-brand-950/85) rather than a neutral gray.
|
|
117
|
-
"border-e border-brand-900/20 bg-brand-50/90 dark:border-white/15 dark:bg-brand-950/85",
|
|
118
|
-
SIDEBAR_WIDTH[size],
|
|
119
|
-
className
|
|
143
|
+
"[grid-area:sidebar] relative z-10",
|
|
144
|
+
"transition-[width] duration-250 ease-out motion-reduce:transition-none",
|
|
145
|
+
collapsed ? icons ? RAIL_WIDTH : "w-0" : SIDEBAR_WIDTH[size]
|
|
120
146
|
),
|
|
121
|
-
children
|
|
147
|
+
children: [
|
|
148
|
+
collapsed && !icons && // The hot strip along the start edge that brings the card back. Before
|
|
149
|
+
// the aside in the DOM so a peeking card paints over it.
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
"aria-hidden": true,
|
|
154
|
+
"data-sidebar-edge": "",
|
|
155
|
+
className: "absolute inset-y-0 inset-s-0 w-4",
|
|
156
|
+
onPointerEnter,
|
|
157
|
+
onPointerLeave
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx(
|
|
161
|
+
ark.aside,
|
|
162
|
+
{
|
|
163
|
+
...props({
|
|
164
|
+
"data-testid": testId,
|
|
165
|
+
"data-collapsed": collapsed,
|
|
166
|
+
"data-peeking": peeking,
|
|
167
|
+
"data-sidebar-rail": rail
|
|
168
|
+
}),
|
|
169
|
+
...rest,
|
|
170
|
+
ref: asideRef,
|
|
171
|
+
inert: collapsed && !icons && !peeking,
|
|
172
|
+
onPointerEnter: (event) => {
|
|
173
|
+
rest.onPointerEnter?.(event);
|
|
174
|
+
onPointerEnter(event);
|
|
175
|
+
},
|
|
176
|
+
onWheelCapture: (event) => {
|
|
177
|
+
rest.onWheelCapture?.(event);
|
|
178
|
+
onScrollActivity();
|
|
179
|
+
},
|
|
180
|
+
onScrollCapture: (event) => {
|
|
181
|
+
rest.onScrollCapture?.(event);
|
|
182
|
+
onScrollActivity();
|
|
183
|
+
},
|
|
184
|
+
onPointerMove: (event) => {
|
|
185
|
+
rest.onPointerMove?.(event);
|
|
186
|
+
onPointerMove(event);
|
|
187
|
+
},
|
|
188
|
+
onPointerLeave: (event) => {
|
|
189
|
+
rest.onPointerLeave?.(event);
|
|
190
|
+
onPointerLeave(event);
|
|
191
|
+
},
|
|
192
|
+
className: cn(
|
|
193
|
+
"absolute inset-y-0 inset-s-0 flex flex-col overflow-hidden",
|
|
194
|
+
TEXT_COLOR_CLASSES.primary,
|
|
195
|
+
// Brand-derived border/fill, matching InputBase/Popover/Modal/Drawer/Table's
|
|
196
|
+
// own chrome (border-brand-900/20 dark:border-white/15, bg-brand-50/90
|
|
197
|
+
// dark:bg-brand-950/85) rather than a neutral gray.
|
|
198
|
+
"border-e border-brand-900/20 bg-brand-50/90 dark:border-white/15 dark:bg-brand-950/85",
|
|
199
|
+
"transition-[width,translate,inset-block,border-radius,box-shadow] duration-250 ease-out motion-reduce:transition-none",
|
|
200
|
+
rail ? RAIL_WIDTH : SIDEBAR_WIDTH[size],
|
|
201
|
+
// A peeking rail widens in place, over the page.
|
|
202
|
+
icons && peeking && "shadow-lg backdrop-blur-sm",
|
|
203
|
+
collapsed && !icons && [
|
|
204
|
+
// Collapsed, it's a floating panel over scrolling content — so it
|
|
205
|
+
// takes Popover's blur, which the docked column doesn't need.
|
|
206
|
+
"inset-y-2 rounded-xl border backdrop-blur-sm",
|
|
207
|
+
peeking ? "translate-x-2 shadow-lg rtl:-translate-x-2" : "-translate-x-full rtl:translate-x-full"
|
|
208
|
+
],
|
|
209
|
+
className
|
|
210
|
+
),
|
|
211
|
+
children: /* @__PURE__ */ jsx(SidebarRailContext.Provider, { value: icons ? { active: rail } : null, children })
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
]
|
|
122
215
|
}
|
|
123
216
|
);
|
|
124
217
|
};
|
|
218
|
+
var PEEK_LEAVE_DELAY = 500;
|
|
219
|
+
var PEEK_EDGE_DISTANCE = 100;
|
|
220
|
+
function useSidebarPeek(collapsed, columnRef, asideRef, enterDelay) {
|
|
221
|
+
const [hovered, setHovered] = useState(false);
|
|
222
|
+
const [wasCollapsed, setWasCollapsed] = useState(collapsed);
|
|
223
|
+
const timer = useRef(void 0);
|
|
224
|
+
const restOrigin = useRef(null);
|
|
225
|
+
const restPoint = useRef(null);
|
|
226
|
+
if (wasCollapsed !== collapsed) {
|
|
227
|
+
setWasCollapsed(collapsed);
|
|
228
|
+
setHovered(false);
|
|
229
|
+
}
|
|
230
|
+
useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
231
|
+
const ignored = (event) => !collapsed || event.pointerType === "touch" || (asideRef.current?.getAnimations?.().length ?? 0) > 0;
|
|
232
|
+
const armRest = (event) => {
|
|
233
|
+
restOrigin.current = { x: event.clientX, y: event.clientY };
|
|
234
|
+
restartRest();
|
|
235
|
+
};
|
|
236
|
+
const restartRest = () => {
|
|
237
|
+
window.clearTimeout(timer.current);
|
|
238
|
+
timer.current = window.setTimeout(() => {
|
|
239
|
+
restPoint.current = restOrigin.current;
|
|
240
|
+
restOrigin.current = null;
|
|
241
|
+
setHovered(true);
|
|
242
|
+
}, enterDelay);
|
|
243
|
+
};
|
|
244
|
+
const onPointerEnter = (event) => {
|
|
245
|
+
if (ignored(event)) return;
|
|
246
|
+
if (enterDelay > 0) return armRest(event);
|
|
247
|
+
window.clearTimeout(timer.current);
|
|
248
|
+
setHovered(true);
|
|
249
|
+
};
|
|
250
|
+
const onPointerMove = (event) => {
|
|
251
|
+
if (enterDelay === 0 || hovered || ignored(event)) return;
|
|
252
|
+
const origin = restOrigin.current;
|
|
253
|
+
if (!origin || Math.hypot(event.clientX - origin.x, event.clientY - origin.y) > RAIL_REST_TOLERANCE) {
|
|
254
|
+
armRest(event);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const onScrollActivity = () => {
|
|
258
|
+
if (enterDelay === 0 || hovered || !restOrigin.current) return;
|
|
259
|
+
restartRest();
|
|
260
|
+
};
|
|
261
|
+
const onPointerLeave = (event) => {
|
|
262
|
+
if (!collapsed || event.pointerType === "touch") return;
|
|
263
|
+
restOrigin.current = null;
|
|
264
|
+
window.clearTimeout(timer.current);
|
|
265
|
+
const shell = columnRef.current?.parentElement ?? document.documentElement;
|
|
266
|
+
const { left, right } = shell.getBoundingClientRect();
|
|
267
|
+
const fromEdge = Math.min(event.clientX - left, right - event.clientX);
|
|
268
|
+
timer.current = window.setTimeout(
|
|
269
|
+
() => setHovered(false),
|
|
270
|
+
fromEdge > PEEK_EDGE_DISTANCE ? 0 : PEEK_LEAVE_DELAY
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
return {
|
|
274
|
+
peeking: collapsed && hovered,
|
|
275
|
+
restPoint,
|
|
276
|
+
onPointerEnter,
|
|
277
|
+
onPointerMove,
|
|
278
|
+
onPointerLeave,
|
|
279
|
+
onScrollActivity
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function scrollerOf(node, within) {
|
|
283
|
+
for (let el = node.parentElement; el && el !== within; el = el.parentElement) {
|
|
284
|
+
const { overflowY } = getComputedStyle(el);
|
|
285
|
+
if (overflowY === "auto" || overflowY === "scroll") return el;
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
var WHEEL_STREAM_GAP = 150;
|
|
290
|
+
var ANCHOR_MAX_DURATION = 1e3;
|
|
291
|
+
function useRailAnchor(enabled, peeking, asideRef, restPoint) {
|
|
292
|
+
const anchor = useRef(null);
|
|
293
|
+
useIsomorphicLayoutEffect(() => {
|
|
294
|
+
const aside = asideRef.current;
|
|
295
|
+
if (!enabled || !aside) return;
|
|
296
|
+
if (peeking) {
|
|
297
|
+
const point = restPoint.current;
|
|
298
|
+
const hit = point ? document.elementFromPoint?.(point.x, point.y) : null;
|
|
299
|
+
anchor.current = hit && aside.contains(hit) ? hit : null;
|
|
300
|
+
}
|
|
301
|
+
const target = anchor.current;
|
|
302
|
+
if (!peeking) anchor.current = null;
|
|
303
|
+
if (!target?.isConnected) return;
|
|
304
|
+
const scroller = scrollerOf(target, aside);
|
|
305
|
+
if (!scroller) return;
|
|
306
|
+
const top = target.getBoundingClientRect().top;
|
|
307
|
+
const correct = () => {
|
|
308
|
+
const drift = target.getBoundingClientRect().top - top;
|
|
309
|
+
if (drift !== 0) scroller.scrollTop += drift;
|
|
310
|
+
};
|
|
311
|
+
const observer = new ResizeObserver(correct);
|
|
312
|
+
observer.observe(scroller);
|
|
313
|
+
for (const child of scroller.children) observer.observe(child);
|
|
314
|
+
const overflowAnchor = scroller.style.overflowAnchor;
|
|
315
|
+
scroller.style.overflowAnchor = "none";
|
|
316
|
+
let stopped = false;
|
|
317
|
+
let lastWheel = Number.NEGATIVE_INFINITY;
|
|
318
|
+
const holdWheel = (event) => {
|
|
319
|
+
const continuing = event.timeStamp - lastWheel < WHEEL_STREAM_GAP;
|
|
320
|
+
lastWheel = event.timeStamp;
|
|
321
|
+
if (!stopped || continuing) event.preventDefault();
|
|
322
|
+
else releaseWheel();
|
|
323
|
+
};
|
|
324
|
+
const releaseWheel = () => scroller.removeEventListener("wheel", holdWheel);
|
|
325
|
+
const stop = () => {
|
|
326
|
+
if (stopped) return;
|
|
327
|
+
stopped = true;
|
|
328
|
+
observer.disconnect();
|
|
329
|
+
scroller.style.overflowAnchor = overflowAnchor;
|
|
330
|
+
};
|
|
331
|
+
scroller.addEventListener("wheel", holdWheel, { passive: false });
|
|
332
|
+
let settle = 0;
|
|
333
|
+
if (aside.getAnimations) {
|
|
334
|
+
const running = aside.getAnimations({ subtree: true });
|
|
335
|
+
Promise.allSettled(running.map((animation) => animation.finished)).then(() => {
|
|
336
|
+
settle = requestAnimationFrame(stop);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
const timeout = window.setTimeout(stop, ANCHOR_MAX_DURATION);
|
|
340
|
+
return () => {
|
|
341
|
+
stop();
|
|
342
|
+
releaseWheel();
|
|
343
|
+
window.clearTimeout(timeout);
|
|
344
|
+
cancelAnimationFrame(settle);
|
|
345
|
+
};
|
|
346
|
+
}, [enabled, peeking]);
|
|
347
|
+
}
|
|
125
348
|
var HEADER_HEIGHT_CLASS = "h-14";
|
|
126
349
|
var AppShellSidebarHeader = ({ className, testId, ...rest }) => /* @__PURE__ */ jsx(
|
|
127
350
|
"div",
|
|
@@ -136,6 +359,10 @@ var AppShellSidebarBody = ({ className, testId, ...rest }) => /* @__PURE__ */ js
|
|
|
136
359
|
{
|
|
137
360
|
className: cn(
|
|
138
361
|
"min-h-0 flex-1 overflow-y-auto overscroll-contain p-4",
|
|
362
|
+
// A classic (non-overlay) scrollbar would take ~15px of a 68px rail and
|
|
363
|
+
// push the icons off-centre. The rail still scrolls by wheel, touch and
|
|
364
|
+
// focus, and the edge mask below still shows there's more.
|
|
365
|
+
"sidebar-rail:[scrollbar-width:none]",
|
|
139
366
|
"[mask-image:linear-gradient(to_bottom,transparent,black_12px,black_calc(100%-12px),transparent)]",
|
|
140
367
|
className
|
|
141
368
|
),
|
|
@@ -255,12 +482,46 @@ var AppShellSidebarTrigger = ({ onClick, testId, ...rest }) => {
|
|
|
255
482
|
}
|
|
256
483
|
);
|
|
257
484
|
};
|
|
485
|
+
var AppShellSidebarCollapseTrigger = ({
|
|
486
|
+
onClick,
|
|
487
|
+
testId,
|
|
488
|
+
...rest
|
|
489
|
+
}) => {
|
|
490
|
+
const { isMobile, collapsed, setCollapsed, sidebarId } = useAppShell();
|
|
491
|
+
if (isMobile) return null;
|
|
492
|
+
return /* @__PURE__ */ jsx(
|
|
493
|
+
ark.button,
|
|
494
|
+
{
|
|
495
|
+
type: "button",
|
|
496
|
+
"aria-expanded": !collapsed,
|
|
497
|
+
"aria-controls": sidebarId,
|
|
498
|
+
"data-app-shell-collapse-trigger": "",
|
|
499
|
+
...props({ "data-testid": testId, "data-collapsed": collapsed }),
|
|
500
|
+
...rest,
|
|
501
|
+
onClick: (event) => {
|
|
502
|
+
onClick?.(event);
|
|
503
|
+
const button = event.currentTarget;
|
|
504
|
+
flushSync(() => setCollapsed((value) => !value));
|
|
505
|
+
const sidebar = document.getElementById(sidebarId);
|
|
506
|
+
if (sidebar && button.closest("[inert]")) {
|
|
507
|
+
const outside = [
|
|
508
|
+
...sidebar.parentElement?.querySelectorAll(
|
|
509
|
+
"[data-app-shell-collapse-trigger]"
|
|
510
|
+
) ?? []
|
|
511
|
+
].find((trigger) => !sidebar.contains(trigger));
|
|
512
|
+
outside?.focus();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
};
|
|
258
518
|
var AppShell = Object.assign(AppShellRoot, {
|
|
259
519
|
Sidebar: AppShellSidebar,
|
|
260
520
|
SidebarHeader: AppShellSidebarHeader,
|
|
261
521
|
SidebarBody: AppShellSidebarBody,
|
|
262
522
|
SidebarFooter: AppShellSidebarFooter,
|
|
263
523
|
SidebarTrigger: AppShellSidebarTrigger,
|
|
524
|
+
SidebarCollapseTrigger: AppShellSidebarCollapseTrigger,
|
|
264
525
|
Header: AppShellHeader,
|
|
265
526
|
Main: AppShellMain,
|
|
266
527
|
Full: AppShellFull,
|