@fldr/ui 0.0.0-stage → 0.1.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/CHANGELOG.md +2366 -0
- package/LICENSE +21 -0
- package/README.md +488 -2
- package/ai/USAGE.md +216 -0
- package/ai/component-registry.json +8694 -0
- package/ai/component-registry.md +11933 -0
- package/ai/schemas.ts +1239 -0
- package/bin/kumo.js +36 -0
- package/dist/.build-complete +1 -0
- package/dist/ai/schemas.d.ts +3229 -0
- package/dist/ai/schemas.js +5963 -0
- package/dist/blocks-source/delete-resource/delete-resource.test.tsx +21 -0
- package/dist/blocks-source/delete-resource/delete-resource.tsx +219 -0
- package/dist/blocks-source/page-header/page-header.tsx +99 -0
- package/dist/blocks-source/resource-list/resource-list.test.tsx +28 -0
- package/dist/blocks-source/resource-list/resource-list.tsx +66 -0
- package/dist/button-DzavLWXm.d.ts +227 -0
- package/dist/catalog.d.ts +380 -0
- package/dist/catalog.js +387 -0
- package/dist/chunks/AccordionPanelDataAttributes-mmrmkky28u1010l5.js +457 -0
- package/dist/chunks/AlertDialogTrigger-l1r1gbxcky1xq889.js +24 -0
- package/dist/chunks/AlertDialogTriggerDataAttributes-go49qon601catpgn.js +56 -0
- package/dist/chunks/AutocompleteItem-36ysm5nwbsd0snr6.js +70 -0
- package/dist/chunks/AutocompleteItemDataAttributes-n5rigpf0s9ylnwi3.js +232 -0
- package/dist/chunks/AutocompleteSeparator-bnqeqh7i983d92gx.js +12 -0
- package/dist/chunks/AvatarImageDataAttributes-jw70u384c83lhqfp.js +247 -0
- package/dist/chunks/ButtonDataAttributes-nceand1fi7lvnmkb.js +35 -0
- package/dist/chunks/CSPContext-iv67i0qqhihg8mur.js +11 -0
- package/dist/chunks/CSPProvider-finau3a8hnc9o2td.js +24 -0
- package/dist/chunks/CheckboxGroup-581mfftu99wvjb3a.js +190 -0
- package/dist/chunks/CheckboxGroupContext-jf1bt3znvqlhrql6.js +10 -0
- package/dist/chunks/CheckboxGroupDataAttributes-nskqcxts64symbvf.js +10 -0
- package/dist/chunks/CheckboxIndicator-i13dmhacfgqo328c.js +414 -0
- package/dist/chunks/CheckboxIndicatorDataAttributes-3p29ju7nkczz1l2y.js +85 -0
- package/dist/chunks/CollapsiblePanel-md5suzmtnsyz1kab.js +178 -0
- package/dist/chunks/CollapsibleRootDataAttributes-bynmgxmt4jikaoha.js +36 -0
- package/dist/chunks/ComboboxClear-ioejwvtnmqanph88.js +294 -0
- package/dist/chunks/ComboboxClearDataAttributes-lo0enstdmrqpywsy.js +402 -0
- package/dist/chunks/ComboboxEmpty-gkt1y5b81a4983v7.js +1950 -0
- package/dist/chunks/ComboboxItemIndicatorDataAttributes-iku7l9ig0ve09an4.js +259 -0
- package/dist/chunks/ComboboxPopup-n8cbgys9st446j1i.js +205 -0
- package/dist/chunks/CompositeItem-kepwg8jtvgap06o6.js +20 -0
- package/dist/chunks/CompositeList-gwuaf6d14s4da0j0.js +182 -0
- package/dist/chunks/CompositeListContext-bejvmlu39hsfjzgu.js +15 -0
- package/dist/chunks/CompositeRoot-dnlkb27uw4g5aocf.js +223 -0
- package/dist/chunks/CompositeRootContext-obm54j7y6s86qwhq.js +12 -0
- package/dist/chunks/ContextMenuTriggerDataAttributes-xwozccynxv6pk5s0.js +237 -0
- package/dist/chunks/DialogBackdropDataAttributes-jwqxd6jla03xh8ke.js +28 -0
- package/dist/chunks/DialogCloseDataAttributes-12m7gwh3i6fd7d05.js +76 -0
- package/dist/chunks/DialogPopup-n6w7b389e7bs0472.js +133 -0
- package/dist/chunks/DialogRoot-hkkqj7vcjpkx8qk8.js +16 -0
- package/dist/chunks/DialogTrigger-kpugfkbfswqrus4u.js +142 -0
- package/dist/chunks/DialogTriggerDataAttributes-bp9bu13cvwuddh5b.js +18 -0
- package/dist/chunks/DialogViewportDataAttributes-mma9emv1edsc1vuy.js +78 -0
- package/dist/chunks/DirectionContext-kpby968j030psajn.js +10 -0
- package/dist/chunks/DirectionProvider-cg0pwzgdyg6r73r6.js +21 -0
- package/dist/chunks/DrawerViewport-mzqpwvqtylnad8ib.js +1532 -0
- package/dist/chunks/DrawerViewportDataAttributes-dd9593zm9fl9vcsm.js +1072 -0
- package/dist/chunks/FieldControl-hjj2tcqruozadgdi.js +122 -0
- package/dist/chunks/FieldDescription-orix2gepowrp5ni4.js +122 -0
- package/dist/chunks/FieldItemContext-ohsf45im6xhpay40.js +10 -0
- package/dist/chunks/FieldItemDataAttributes-m52srx69pispz49i.js +283 -0
- package/dist/chunks/FieldLabel-fjc7tdis7rcbq8o4.js +353 -0
- package/dist/chunks/FieldsetLegend-gl9z9eezr0xg9zr7.js +61 -0
- package/dist/chunks/FieldsetLegendDataAttributes-fn20251jxjqkpkxm.js +17 -0
- package/dist/chunks/FieldsetRootContext-fphwizvcm55ydg94.js +12 -0
- package/dist/chunks/FloatingPortalLite-j7dsy7gokbxdoe1i.js +25 -0
- package/dist/chunks/FloatingRootStore-men6ufp3a2b296fh.js +840 -0
- package/dist/chunks/FloatingTree-kiyzavvaum442o1s.js +115 -0
- package/dist/chunks/Form-oz425k7r4abea8o4.js +113 -0
- package/dist/chunks/FormContext-jv19engyccpf6xcl.js +18 -0
- package/dist/chunks/Input-ozudotydd679ly63.js +20 -0
- package/dist/chunks/InputDataAttributes-oy8t6q5y5t8ik02j.js +42 -0
- package/dist/chunks/ItemIndicator-cvf8cw5fv5l3cd8j.js +37 -0
- package/dist/chunks/LabelableContext-dz4wz3lu3lgqusu7.js +135 -0
- package/dist/chunks/ListboxSeparator-skazx18vzzj7i9zp.js +21 -0
- package/dist/chunks/MenuClearDataAttributes-fo0pekd36n56mdxu.js +1645 -0
- package/dist/chunks/MenuSubmenuTrigger-hm5xbgik6aq95x35.js +1976 -0
- package/dist/chunks/MenuSubmenuTriggerDataAttributes-gdfxdjymgmnaxdds.js +372 -0
- package/dist/chunks/MenuTrigger-dlfvicsaggss0o9m.js +265 -0
- package/dist/chunks/Menubar-ja5int05ihjj0ra4.js +116 -0
- package/dist/chunks/MenubarContext-ooz0h08i55c8oip5.js +12 -0
- package/dist/chunks/MeterLabel-cykbkvqys5263z05.js +148 -0
- package/dist/chunks/NavigationMenuIconDataAttributes-l82pkpm61d0meqxf.js +1654 -0
- package/dist/chunks/NullStore-my62xo2vfcfkerri.js +110 -0
- package/dist/chunks/NumberFieldScrubAreaCursorDataAttributes-k2lsbk35svshnwf5.js +1493 -0
- package/dist/chunks/OTPFieldInputDataAttributes-gvgtu2gg85kgjzwr.js +683 -0
- package/dist/chunks/PopoverViewport-peh28i8q4hqfjy97.js +713 -0
- package/dist/chunks/PopoverViewportDataAttributes-gplhq9d7ffp9q8u3.js +329 -0
- package/dist/chunks/PrehydrationScript-hs2je3mndbxuts7w.js +78 -0
- package/dist/chunks/PreviewCardViewportDataAttributes-bgfwmyshey7fx6nr.js +914 -0
- package/dist/chunks/ProgressLabelDataAttributes-j8mutcz11ei0ohvj.js +287 -0
- package/dist/chunks/RadioGroup-kioqngmmuo7a1lfa.js +163 -0
- package/dist/chunks/RadioGroupContext-dr6uihsj7oky0eol.js +10 -0
- package/dist/chunks/RadioGroupDataAttributes-dpdr6xe4ve204qwb.js +10 -0
- package/dist/chunks/RadioIndicator-bhxqih8wzv7hyrec.js +299 -0
- package/dist/chunks/RadioIndicatorDataAttributes-n5yupp5psifu0d4f.js +80 -0
- package/dist/chunks/ScrollAreaThumb-hxig41yn4lrurd3o.js +928 -0
- package/dist/chunks/ScrollAreaThumbDataAttributes-gup5wfxvqye6jj27.js +137 -0
- package/dist/chunks/SelectScrollUpArrowDataAttributes-fce5i1afjkb0necr.js +473 -0
- package/dist/chunks/SelectSeparator-nnak70azojox8b2b.js +1632 -0
- package/dist/chunks/Separator-fhwve0tfny3tht3a.js +24 -0
- package/dist/chunks/SeparatorDataAttributes-ch6e63bas7zflw00.js +11 -0
- package/dist/chunks/SliderIndicator-h1o3qbrvr8x0t4t2.js +1171 -0
- package/dist/chunks/SliderIndicatorDataAttributes-ff2f1cjealif5nvo.js +240 -0
- package/dist/chunks/SwitchRoot-m4t2tq5zn5wibyxk.js +244 -0
- package/dist/chunks/SwitchThumbDataAttributes-f95ld864on9y6ptk.js +90 -0
- package/dist/chunks/TabsList-n5n93rxr4sy704u8.js +664 -0
- package/dist/chunks/TabsListDataAttributes-e03a7kbubuf02z1l.js +183 -0
- package/dist/chunks/ToastArrowDataAttributes-jbnvz3kp6a35slgj.js +136 -0
- package/dist/chunks/ToggleDataAttributes-jl9ojyvwgrvefke6.js +103 -0
- package/dist/chunks/ToggleGroupContext-hg8zbkgqpscqhz83.js +10 -0
- package/dist/chunks/ToggleGroupDataAttributes-n1dwona1alvabstl.js +102 -0
- package/dist/chunks/ToolbarGroupContext-eawva8xkxb4osbxb.js +10 -0
- package/dist/chunks/ToolbarInput-kyxl1be0p3cyuayp.js +174 -0
- package/dist/chunks/ToolbarInputDataAttributes-n4a18a4km735du04.js +150 -0
- package/dist/chunks/ToolbarRootContext-difqbj720teyt8lu.js +12 -0
- package/dist/chunks/TooltipPopup-furysmeyb68uycbz.js +839 -0
- package/dist/chunks/TooltipProvider-hyans0ens4axh1y8.js +61 -0
- package/dist/chunks/TooltipViewportDataAttributes-gkwbezdq40ssuevg.js +312 -0
- package/dist/chunks/adaptiveOriginMiddleware-m9tqzw58wya9sdds.js +51 -0
- package/dist/chunks/addEventListener-ku3x23446prmd1kz.js +13 -0
- package/dist/chunks/areArraysEqual-nnpg93s9g7aqcaoh.js +15 -0
- package/dist/chunks/autocomplete-gdd9aruremdgdvx7.js +152 -0
- package/dist/chunks/badge-gca8xfu79ne55d5k.js +165 -0
- package/dist/chunks/banner-mo1xl9ww734kgsqh.js +269 -0
- package/dist/chunks/bash-jpzh6zbf5237424t.js +3 -0
- package/dist/chunks/breadcrumbs-z1jo40oxlw8e4eh4.js +159 -0
- package/dist/chunks/button-group-biv43ksvaipc3p5n.js +59 -0
- package/dist/chunks/button-hzvowfkbathmx8yg.js +274 -0
- package/dist/chunks/chart-dgh98nbzo2sux2bs.js +3985 -0
- package/dist/chunks/checkbox-eifiwbw34xwsikvf.js +211 -0
- package/dist/chunks/clamp-rcpupxvhqrn8uuyf.js +7 -0
- package/dist/chunks/clipboard-text-oukrnke1s3kebk3y.js +209 -0
- package/dist/chunks/cloudflare-logo-d8mid9xr190h78cu.js +186 -0
- package/dist/chunks/code-nj2nu6qzxhz6qnkk.js +96 -0
- package/dist/chunks/collapsible-ic6813hc4yv5s5hv.js +185 -0
- package/dist/chunks/combobox-mzvobpvalz2gnpli.js +321 -0
- package/dist/chunks/command-palette-d45ueqbuxygu87ir.js +507 -0
- package/dist/chunks/composite-c11t1ok72s3cggjc.js +90 -0
- package/dist/chunks/constants-l10cgj6pyqg27jod.js +5 -0
- package/dist/chunks/core-n0de50o00ej2ecfe.js +7177 -0
- package/dist/chunks/createBaseUIEventDetails-nvee6bghv2reeqdb.js +50 -0
- package/dist/chunks/createItems-n07tfwx89cdoar18.js +323 -0
- package/dist/chunks/createToastManager-cxjmn4jx3ejh85fs.js +1225 -0
- package/dist/chunks/css-j501gxq1am2gnikh.js +4 -0
- package/dist/chunks/date-picker-ija2bz17ai6ypnao.js +6865 -0
- package/dist/chunks/date-range-picker-oivlshld01jbel29.js +336 -0
- package/dist/chunks/dialog-g7wavhkdv2gplwq9.js +173 -0
- package/dist/chunks/diff-g2re0kj6fh27rgg5.js +4 -0
- package/dist/chunks/dropdown-m5a8nwer5hpvnkfk.js +384 -0
- package/dist/chunks/empty-e0onzpyokyl6h9bp.js +96 -0
- package/dist/chunks/engine-hzmefiqm63hu0c7i.js +10 -0
- package/dist/chunks/engine-javascript-e9xj8hhz9xfqhpnu.js +3118 -0
- package/dist/chunks/engine-oniguruma-ias56ildu01gf939.js +389 -0
- package/dist/chunks/error-lbnic2b20qr3mukp.js +6 -0
- package/dist/chunks/field-fowmq5smvp17pnqe.js +75 -0
- package/dist/chunks/flow-fak0fyldoaozd32s.js +10290 -0
- package/dist/chunks/formatNumber-b4kjdsebslm2b3t0.js +21 -0
- package/dist/chunks/getCssDimensions-gckwdrp86f73cv51.js +21 -0
- package/dist/chunks/getElementTransform-cz3jyftv0x5io95f.js +38 -0
- package/dist/chunks/getFiniteAnimations-jwd833ybtz81j5f0.js +13 -0
- package/dist/chunks/getHighlightReason-fhc53kq6qakcct9s.js +15 -0
- package/dist/chunks/getPseudoElementBounds-csuw8kwsoeyxd5tv.js +37 -0
- package/dist/chunks/github-light-hir7yctc38258pwt.js +5 -0
- package/dist/chunks/graphql-n9vlzkvcp2j19p7a.js +16 -0
- package/dist/chunks/grid-nwiczrab3r4w0zr2.js +118 -0
- package/dist/chunks/hcl-ohpfnrffs96hzyj5.js +4 -0
- package/dist/chunks/html-nimj6ljkkifnc9ni.js +12 -0
- package/dist/chunks/index.parts-db9pzsm9rrs9tp0t.js +200 -0
- package/dist/chunks/index.parts-ggacwr0yakuemead.js +24 -0
- package/dist/chunks/index.parts-pcg3pmf3yyro841t.js +13 -0
- package/dist/chunks/inertValue-n09gkjvwwa1kddov.js +9 -0
- package/dist/chunks/inline-copy-text-izxpvnrtebcqlquf.js +104 -0
- package/dist/chunks/input-group-h9fepskc84e1h11n.js +457 -0
- package/dist/chunks/input-kfi46426y22ocoo4.js +85 -0
- package/dist/chunks/input-m2tfec2viezoz9hh.js +146 -0
- package/dist/chunks/isElementDisabled-dyqutxpzdfppbohx.js +7 -0
- package/dist/chunks/itemEquality-ki3x4tzdhjlqjey6.js +56 -0
- package/dist/chunks/javascript-b6fq9bl50fdj6813.js +4 -0
- package/dist/chunks/json-h2g0z143t3cs13d7.js +4 -0
- package/dist/chunks/jsonc-jxlzvingck161eej.js +4 -0
- package/dist/chunks/jsx-jp7a33937sef92sn.js +4 -0
- package/dist/chunks/label-f18fnpbv85jddo4q.js +76 -0
- package/dist/chunks/layer-card-lsmeuqic9i1isv2b.js +74 -0
- package/dist/chunks/layer-dialog-ejtz9s7bbfhjk1md.js +414 -0
- package/dist/chunks/link-h84bkh8eem39p529.js +112 -0
- package/dist/chunks/link-provider-kbwllpbo24fvgioj.js +60 -0
- package/dist/chunks/loader-kv5nk8j8tsuesxqo.js +87 -0
- package/dist/chunks/locale-provider-j4ii538ntyok36r6.js +50 -0
- package/dist/chunks/markdown-eybeqjr58vfygtz1.js +4 -0
- package/dist/chunks/menubar-gzlyhmmc4i24prn1.js +106 -0
- package/dist/chunks/mergeCleanups-nw73c6jfwl5tyhw4.js +15 -0
- package/dist/chunks/meter-poh8jpe0qtq6mvee.js +35 -0
- package/dist/chunks/pagination-lmogkvvtu19mnr7f.js +296 -0
- package/dist/chunks/popover-nqrt3ykqv6sic8pz.js +206 -0
- package/dist/chunks/popupHandle-dk3ixgc8flr7v971.js +177 -0
- package/dist/chunks/popupStoreUtils-czfnxn051xakask5.js +868 -0
- package/dist/chunks/portal-provider-eveknxf26oudn7pp.js +63 -0
- package/dist/chunks/python-nrpnmxq4r6yp6fcd.js +4 -0
- package/dist/chunks/radio-nf717i5ypsga9zdh.js +204 -0
- package/dist/chunks/reason-parts-hssx64rmlxyn6gw5.js +40 -0
- package/dist/chunks/resolve-variant-l6x5ksfrjtu4m66l.js +35 -0
- package/dist/chunks/resolveAriaLabelledBy-knaucrjrjwnk7tvs.js +10 -0
- package/dist/chunks/resolveValueLabel-ntacnb58mhka5gg0.js +70 -0
- package/dist/chunks/rolldown-runtime-hi7ti5xiuxsegr96.js +18 -0
- package/dist/chunks/safePolygon-ep4133qogeu5vjf3.js +661 -0
- package/dist/chunks/safeReact-ek77ilng4ekk7mgz.js +18 -0
- package/dist/chunks/scrollable-k784b35i80aolmvg.js +29 -0
- package/dist/chunks/select-lnekz415wm4v6d6m.js +279 -0
- package/dist/chunks/sensitive-input-dvwlnntm7rdudwp0.js +252 -0
- package/dist/chunks/serializeValue-d1otz2i7h5tygrwf.js +13 -0
- package/dist/chunks/shellscript-i4m7lo8wi0f5bl8b.js +4 -0
- package/dist/chunks/sidebar-mhlgvpawixxoey2k.js +1466 -0
- package/dist/chunks/skeleton-line-kmhnp0lx3rxhioxa.js +74 -0
- package/dist/chunks/slider-e395gihi5cjd62ss.js +87 -0
- package/dist/chunks/sql-hqp2eekl7qhmxe92.js +4 -0
- package/dist/chunks/stringifyLocale-gbxouqj7ol627jxh.js +9 -0
- package/dist/chunks/styles-eb8bvypmayf578jf.js +35 -0
- package/dist/chunks/surface-jr8x5hy0gucjk5ig.js +30 -0
- package/dist/chunks/switch-nc8thi7ogd51m3gi.js +202 -0
- package/dist/chunks/table-ngl1b5yc8mcur662.js +238 -0
- package/dist/chunks/table-of-contents-gkjv9ck8etbz64ej.js +234 -0
- package/dist/chunks/tabs-o59bv7348nh2gppm.js +280 -0
- package/dist/chunks/tag-input-lbx9yzt33d4wu07o.js +156 -0
- package/dist/chunks/text-nqum95flcp07ac9s.js +126 -0
- package/dist/chunks/toast-ljpenshot856xqq4.js +341 -0
- package/dist/chunks/toml-oyqrgosuct25x413.js +4 -0
- package/dist/chunks/toolbar-kh6pc12ii7b6dv1x.js +141 -0
- package/dist/chunks/tooltip-bcymn9bfyz29fvji.js +92 -0
- package/dist/chunks/tsx-pem8x69upvmibv6l.js +4 -0
- package/dist/chunks/typescript-pe5y016phdwbgws7.js +4 -0
- package/dist/chunks/unwrap-lazy-element-hzbdkmujhd7iksau.js +45 -0
- package/dist/chunks/use-copy-feedback-gl55ghst0csvpv4j.js +55 -0
- package/dist/chunks/useAnchoredPopupScrollLock-msm8tzkewysnunut.js +31 -0
- package/dist/chunks/useAnimationFrame-k9lqdj9quln3sd85.js +87 -0
- package/dist/chunks/useAriaLabelledBy-j3j9jqlr9ukyk08s.js +36 -0
- package/dist/chunks/useBaseUiId-nk4k7nj9h1cy76ny.js +13 -0
- package/dist/chunks/useButton-lklvdzuhvj22bx07.js +186 -0
- package/dist/chunks/useClick-pcbkcc7r620v1smu.js +87 -0
- package/dist/chunks/useCollapsiblePanel-lrfsgx21ds36cwlp.js +415 -0
- package/dist/chunks/useCompositeItem-2juex3zh9gyrs8e9.js +31 -0
- package/dist/chunks/useCompositeListItem-ekwo2j2rjkggg7xj.js +54 -0
- package/dist/chunks/useControlled-i3srnkxy598s0au9.js +52 -0
- package/dist/chunks/useFieldValidation-oe16jiigp971yrzr.js +224 -0
- package/dist/chunks/useFloatingRootContext-k676b6m7f80bdapd.js +51 -0
- package/dist/chunks/useFocus-mn7a9t9v6fnlb4mf.js +124 -0
- package/dist/chunks/useId-82z8yqlmc1hy1c5t.js +50 -0
- package/dist/chunks/useInitialLiveRegionTextMutation-nl2hus7zx1h7ggno.js +86 -0
- package/dist/chunks/useLabel-me6zzfvkypo458pi.js +58 -0
- package/dist/chunks/useLabelableId-bjeh6q3pgrqjb7er.js +56 -0
- package/dist/chunks/useListNavigation-hpddbd0cc9pvt461.js +441 -0
- package/dist/chunks/useOnMount-gxggz1m0n869s6r0.js +12 -0
- package/dist/chunks/useOpenChangeComplete-edtabjwqmechsyv6.js +129 -0
- package/dist/chunks/usePopupHandleStore-gawjmfjf1xdgiph3.js +27 -0
- package/dist/chunks/usePopupViewport-l6w01iohvzloghy8.js +367 -0
- package/dist/chunks/usePositioner-mzvgnazldqvy44z2.js +580 -0
- package/dist/chunks/usePressAndHold-k9ynk78pgf677kpx.js +179 -0
- package/dist/chunks/usePreviousValue-o6swt5tb7xhpdu4e.js +21 -0
- package/dist/chunks/useRegisterFieldControl-m1stc9l9y4cndf0k.js +40 -0
- package/dist/chunks/useRegisteredLabelId-b7u9ygya03448zzn.js +16 -0
- package/dist/chunks/useRender-h9ktka9xt4obdv6y.js +13 -0
- package/dist/chunks/useRenderDialogRoot-bsqrqpc1ddau7xg4.js +312 -0
- package/dist/chunks/useRenderElement-nkklxbq1rp7h2kw0.js +436 -0
- package/dist/chunks/useScrollLock-le7ajwlt7oh6fzxi.js +877 -0
- package/dist/chunks/useSetFieldFocused-fbvj7gcv67dqfkp0.js +35 -0
- package/dist/chunks/useStableCallback-le5qgj6p9l04729n.js +38 -0
- package/dist/chunks/useSwipeDismiss-e8tfxzlp05p86mgb.js +697 -0
- package/dist/chunks/useTimeout-f0ayn2l2l9aop4l8.js +43 -0
- package/dist/chunks/useTransitionStatus-disysoblzgk34w14.js +74 -0
- package/dist/chunks/useTriggerFocusGuards-dyd3hb1m8en8ct50.js +40 -0
- package/dist/chunks/useTriggerSwitchTransition-hk5j36hd5dq2ok6w.js +62 -0
- package/dist/chunks/useTypeahead-kfdsw1ksl5bgvvzl.js +111 -0
- package/dist/chunks/useValueAsRef-dv0tmfr1xlpzdlru.js +27 -0
- package/dist/chunks/useValueChanged-fjssa2v6d4w8y332.js +15 -0
- package/dist/chunks/utils-o44zfmzz9z7uyj1v.js +18 -0
- package/dist/chunks/valueToPercent-djk2mqnihth2uvf6.js +7 -0
- package/dist/chunks/vendor-floating-ui-fqblx3wa0r71mjoo.js +1458 -0
- package/dist/chunks/vendor-styling-gs32v7xt5znc8kg0.js +1167 -0
- package/dist/chunks/vendor-utils-io8z5lsfxq8m2dcc.js +660 -0
- package/dist/chunks/vesper-g839e590k3dxnwh3.js +5 -0
- package/dist/chunks/visuallyHidden-kzzs9hbe93is3rci.js +25 -0
- package/dist/chunks/wasm-cpasy0o9lsjrm39j.js +8 -0
- package/dist/chunks/yaml-kzk5ddyekbyha04v.js +4 -0
- package/dist/code/server.d.ts +96 -0
- package/dist/code/server.js +151 -0
- package/dist/code.d.ts +82 -0
- package/dist/code.js +373 -0
- package/dist/command-line/cli.js +1705 -0
- package/dist/command-line/commands/add.js +282 -0
- package/dist/command-line/commands/ai.js +22 -0
- package/dist/command-line/commands/blocks.js +61 -0
- package/dist/command-line/commands/doc.js +167 -0
- package/dist/command-line/commands/init.js +95 -0
- package/dist/command-line/commands/ls.js +53 -0
- package/dist/command-line/commands/theme.js +850 -0
- package/dist/components/autocomplete.d.ts +2 -0
- package/dist/components/autocomplete.js +3 -0
- package/dist/components/badge.d.ts +2 -0
- package/dist/components/badge.js +3 -0
- package/dist/components/banner.d.ts +2 -0
- package/dist/components/banner.js +3 -0
- package/dist/components/breadcrumbs.d.ts +2 -0
- package/dist/components/breadcrumbs.js +3 -0
- package/dist/components/button-group.d.ts +2 -0
- package/dist/components/button-group.js +3 -0
- package/dist/components/button.d.ts +3 -0
- package/dist/components/button.js +3 -0
- package/dist/components/chart.d.ts +2 -0
- package/dist/components/chart.js +3 -0
- package/dist/components/checkbox.d.ts +2 -0
- package/dist/components/checkbox.js +3 -0
- package/dist/components/clipboard-text.d.ts +2 -0
- package/dist/components/clipboard-text.js +3 -0
- package/dist/components/cloudflare-logo.d.ts +2 -0
- package/dist/components/cloudflare-logo.js +3 -0
- package/dist/components/code.d.ts +2 -0
- package/dist/components/code.js +3 -0
- package/dist/components/collapsible.d.ts +2 -0
- package/dist/components/collapsible.js +3 -0
- package/dist/components/combobox.d.ts +2 -0
- package/dist/components/combobox.js +3 -0
- package/dist/components/command-palette.d.ts +2 -0
- package/dist/components/command-palette.js +3 -0
- package/dist/components/date-picker.d.ts +2 -0
- package/dist/components/date-picker.js +3 -0
- package/dist/components/date-range-picker.d.ts +2 -0
- package/dist/components/date-range-picker.js +3 -0
- package/dist/components/dialog.d.ts +2 -0
- package/dist/components/dialog.js +3 -0
- package/dist/components/dropdown.d.ts +2 -0
- package/dist/components/dropdown.js +3 -0
- package/dist/components/empty.d.ts +2 -0
- package/dist/components/empty.js +3 -0
- package/dist/components/field.d.ts +2 -0
- package/dist/components/field.js +3 -0
- package/dist/components/flow.d.ts +2 -0
- package/dist/components/flow.js +3 -0
- package/dist/components/grid.d.ts +2 -0
- package/dist/components/grid.js +3 -0
- package/dist/components/inline-copy-text.d.ts +2 -0
- package/dist/components/inline-copy-text.js +3 -0
- package/dist/components/input-group.d.ts +2 -0
- package/dist/components/input-group.js +3 -0
- package/dist/components/input.d.ts +4 -0
- package/dist/components/input.js +5 -0
- package/dist/components/label.d.ts +2 -0
- package/dist/components/label.js +3 -0
- package/dist/components/layer-card.d.ts +2 -0
- package/dist/components/layer-card.js +3 -0
- package/dist/components/layer-dialog.d.ts +2 -0
- package/dist/components/layer-dialog.js +3 -0
- package/dist/components/link.d.ts +67 -0
- package/dist/components/link.js +3 -0
- package/dist/components/loader.d.ts +2 -0
- package/dist/components/loader.js +4 -0
- package/dist/components/menubar.d.ts +2 -0
- package/dist/components/menubar.js +3 -0
- package/dist/components/meter.d.ts +2 -0
- package/dist/components/meter.js +3 -0
- package/dist/components/pagination.d.ts +2 -0
- package/dist/components/pagination.js +3 -0
- package/dist/components/popover.d.ts +2 -0
- package/dist/components/popover.js +3 -0
- package/dist/components/radio.d.ts +2 -0
- package/dist/components/radio.js +3 -0
- package/dist/components/select.d.ts +2 -0
- package/dist/components/select.js +3 -0
- package/dist/components/sensitive-input.d.ts +2 -0
- package/dist/components/sensitive-input.js +3 -0
- package/dist/components/sidebar.d.ts +2 -0
- package/dist/components/sidebar.js +3 -0
- package/dist/components/slider.d.ts +2 -0
- package/dist/components/slider.js +3 -0
- package/dist/components/surface.d.ts +2 -0
- package/dist/components/surface.js +3 -0
- package/dist/components/switch.d.ts +2 -0
- package/dist/components/switch.js +3 -0
- package/dist/components/table-of-contents.d.ts +2 -0
- package/dist/components/table-of-contents.js +3 -0
- package/dist/components/table.d.ts +2 -0
- package/dist/components/table.js +3 -0
- package/dist/components/tabs.d.ts +2 -0
- package/dist/components/tabs.js +3 -0
- package/dist/components/tag-input.d.ts +2 -0
- package/dist/components/tag-input.js +3 -0
- package/dist/components/text.d.ts +2 -0
- package/dist/components/text.js +3 -0
- package/dist/components/toast.d.ts +2 -0
- package/dist/components/toast.js +4 -0
- package/dist/components/toolbar.d.ts +2 -0
- package/dist/components/toolbar.js +3 -0
- package/dist/components/tooltip.d.ts +2 -0
- package/dist/components/tooltip.js +3 -0
- package/dist/config-BKj6nyHa.d.ts +620 -0
- package/dist/field-DIjlHM8W.d.ts +91 -0
- package/dist/index-2jvVmJ8P.d.ts +46 -0
- package/dist/index-5PpauI_2.d.ts +85 -0
- package/dist/index-AMEc1MEg.d.ts +180 -0
- package/dist/index-AUC5xRcO.d.ts +236 -0
- package/dist/index-B7epkoHc.d.ts +72 -0
- package/dist/index-B9-RdY6D.d.ts +75 -0
- package/dist/index-B9niVl3r.d.ts +140 -0
- package/dist/index-BD-gTiEv.d.ts +71 -0
- package/dist/index-BK1tZgmP.d.ts +426 -0
- package/dist/index-BVgXnR1V.d.ts +137 -0
- package/dist/index-BW1HVU7T.d.ts +119 -0
- package/dist/index-BWe6haHU.d.ts +64 -0
- package/dist/index-BkTAB4wj.d.ts +673 -0
- package/dist/index-Bwhwpw_j.d.ts +189 -0
- package/dist/index-BzE0aNpx.d.ts +143 -0
- package/dist/index-C7RoG_CH.d.ts +57 -0
- package/dist/index-CE09bLNb.d.ts +72 -0
- package/dist/index-CJRe-8P-.d.ts +174 -0
- package/dist/index-CReGk3Dc.d.ts +91 -0
- package/dist/index-CU_lnxg7.d.ts +287 -0
- package/dist/index-CYoiniZ4.d.ts +135 -0
- package/dist/index-ClS-eFxE.d.ts +104 -0
- package/dist/index-CzIWigmH.d.ts +62 -0
- package/dist/index-CzTgKPh-.d.ts +105 -0
- package/dist/index-D2Gvly0i.d.ts +96 -0
- package/dist/index-DIV3riUd.d.ts +148 -0
- package/dist/index-DL1-uSuH.d.ts +1 -0
- package/dist/index-DYYiDxZs.d.ts +243 -0
- package/dist/index-DjSGDESy.d.ts +222 -0
- package/dist/index-Dmbgjww7.d.ts +157 -0
- package/dist/index-DwNMa4LN.d.ts +166 -0
- package/dist/index-Dx7hOWUc.d.ts +93 -0
- package/dist/index-DxOyYZaJ.d.ts +251 -0
- package/dist/index-NnHba-T1.d.ts +136 -0
- package/dist/index-RP_rt8vB.d.ts +140 -0
- package/dist/index-T1sSoiWG.d.ts +184 -0
- package/dist/index-aahL-0Zw.d.ts +60 -0
- package/dist/index-bBPKMepR.d.ts +73 -0
- package/dist/index-g-eFm1Bq.d.ts +877 -0
- package/dist/index-gYC6cQVO.d.ts +105 -0
- package/dist/index-lOWfpkxK.d.ts +118 -0
- package/dist/index-pjdgauIH.d.ts +170 -0
- package/dist/index-yK3Hayg_.d.ts +40 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +207 -0
- package/dist/input-BeWEb-jD.d.ts +122 -0
- package/dist/input-group-8gEtPiKw.d.ts +100 -0
- package/dist/layer-card-BNIn9pqy.d.ts +56 -0
- package/dist/link-provider-tz-NJp9x.d.ts +67 -0
- package/dist/locale-provider-CHMCQ0-J.d.ts +40 -0
- package/dist/panda.d.ts +25 -0
- package/dist/panda.js +32 -0
- package/dist/portal-provider-BAqPpq_a.d.ts +55 -0
- package/dist/primitives/accordion.d.ts +1 -0
- package/dist/primitives/accordion.js +3 -0
- package/dist/primitives/alert-dialog.d.ts +1 -0
- package/dist/primitives/alert-dialog.js +8 -0
- package/dist/primitives/autocomplete.d.ts +1 -0
- package/dist/primitives/autocomplete.js +6 -0
- package/dist/primitives/avatar.d.ts +1 -0
- package/dist/primitives/avatar.js +3 -0
- package/dist/primitives/button.d.ts +1 -0
- package/dist/primitives/button.js +3 -0
- package/dist/primitives/checkbox-group.d.ts +1 -0
- package/dist/primitives/checkbox-group.js +4 -0
- package/dist/primitives/checkbox.d.ts +1 -0
- package/dist/primitives/checkbox.js +4 -0
- package/dist/primitives/collapsible.d.ts +1 -0
- package/dist/primitives/collapsible.js +5 -0
- package/dist/primitives/combobox.d.ts +1 -0
- package/dist/primitives/combobox.js +6 -0
- package/dist/primitives/context-menu.d.ts +1 -0
- package/dist/primitives/context-menu.js +6 -0
- package/dist/primitives/csp-provider.d.ts +1 -0
- package/dist/primitives/csp-provider.js +3 -0
- package/dist/primitives/dialog.d.ts +1 -0
- package/dist/primitives/dialog.js +9 -0
- package/dist/primitives/direction-provider.d.ts +1 -0
- package/dist/primitives/direction-provider.js +4 -0
- package/dist/primitives/drawer.d.ts +1 -0
- package/dist/primitives/drawer.js +6 -0
- package/dist/primitives/field.d.ts +1 -0
- package/dist/primitives/field.js +4 -0
- package/dist/primitives/fieldset.d.ts +1 -0
- package/dist/primitives/fieldset.js +3 -0
- package/dist/primitives/form.d.ts +1 -0
- package/dist/primitives/form.js +3 -0
- package/dist/primitives/input.d.ts +1 -0
- package/dist/primitives/input.js +4 -0
- package/dist/primitives/menu.d.ts +1 -0
- package/dist/primitives/menu.js +6 -0
- package/dist/primitives/menubar.d.ts +1 -0
- package/dist/primitives/menubar.js +3 -0
- package/dist/primitives/meter.d.ts +1 -0
- package/dist/primitives/meter.js +3 -0
- package/dist/primitives/navigation-menu.d.ts +1 -0
- package/dist/primitives/navigation-menu.js +3 -0
- package/dist/primitives/number-field.d.ts +1 -0
- package/dist/primitives/number-field.js +3 -0
- package/dist/primitives/otp-field.d.ts +3 -0
- package/dist/primitives/otp-field.js +4 -0
- package/dist/primitives/popover.d.ts +1 -0
- package/dist/primitives/popover.js +3 -0
- package/dist/primitives/preview-card.d.ts +1 -0
- package/dist/primitives/preview-card.js +3 -0
- package/dist/primitives/progress.d.ts +1 -0
- package/dist/primitives/progress.js +3 -0
- package/dist/primitives/radio-group.d.ts +1 -0
- package/dist/primitives/radio-group.js +4 -0
- package/dist/primitives/radio.d.ts +1 -0
- package/dist/primitives/radio.js +4 -0
- package/dist/primitives/scroll-area.d.ts +1 -0
- package/dist/primitives/scroll-area.js +4 -0
- package/dist/primitives/select.d.ts +1 -0
- package/dist/primitives/select.js +5 -0
- package/dist/primitives/separator.d.ts +1 -0
- package/dist/primitives/separator.js +4 -0
- package/dist/primitives/slider.d.ts +1 -0
- package/dist/primitives/slider.js +4 -0
- package/dist/primitives/switch.d.ts +1 -0
- package/dist/primitives/switch.js +4 -0
- package/dist/primitives/tabs.d.ts +1 -0
- package/dist/primitives/tabs.js +4 -0
- package/dist/primitives/toast.d.ts +1 -0
- package/dist/primitives/toast.js +5 -0
- package/dist/primitives/toggle-group.d.ts +1 -0
- package/dist/primitives/toggle-group.js +3 -0
- package/dist/primitives/toggle.d.ts +1 -0
- package/dist/primitives/toggle.js +3 -0
- package/dist/primitives/toolbar.d.ts +1 -0
- package/dist/primitives/toolbar.js +3 -0
- package/dist/primitives/tooltip.d.ts +1 -0
- package/dist/primitives/tooltip.js +4 -0
- package/dist/primitives.d.ts +42 -0
- package/dist/primitives.js +71 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +1 -0
- package/dist/scripts/theme-generator/config.d.ts +2 -0
- package/dist/scripts/theme-generator/config.js +487 -0
- package/dist/scripts/theme-generator/types.d.ts +2 -0
- package/dist/scripts/theme-generator/types.js +1 -0
- package/dist/styles/kumo-binding.css +490 -0
- package/dist/styles/kumo-standalone.css +2 -0
- package/dist/styles/kumo.css +153 -0
- package/dist/styles/theme-fedramp.css +31 -0
- package/dist/styles/theme-fldr.css +67 -0
- package/dist/styles/theme-kumo.css +464 -0
- package/dist/text-CRRU2g-u.d.ts +183 -0
- package/dist/theming.d.ts +185 -0
- package/dist/theming.js +241 -0
- package/dist/tooltip-D_vhi1PN.d.ts +105 -0
- package/dist/types-C6in2C8V.d.ts +135 -0
- package/dist/types-CdzJnnIl.d.ts +193 -0
- package/dist/types-Cl4HuOrB.d.ts +84 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +7 -0
- package/package.json +483 -3
- package/scripts/component-registry/cache.ts +123 -0
- package/scripts/component-registry/discovery.ts +560 -0
- package/scripts/component-registry/example-cleanup.ts +168 -0
- package/scripts/component-registry/index.test.ts +1075 -0
- package/scripts/component-registry/index.ts +1065 -0
- package/scripts/component-registry/markdown-generator.ts +222 -0
- package/scripts/component-registry/metadata.ts +1030 -0
- package/scripts/component-registry/props-filter.ts +312 -0
- package/scripts/component-registry/schema-generator.ts +333 -0
- package/scripts/component-registry/sub-components.ts +393 -0
- package/scripts/component-registry/types.ts +158 -0
- package/scripts/component-registry/utils.ts +280 -0
- package/scripts/component-registry/variant-parser.ts +262 -0
- package/scripts/css-build.ts +106 -0
- package/scripts/format-generated.ts +12 -0
- package/scripts/generate-globe-land-mask.mjs +80 -0
- package/scripts/generate-primitives.ts +196 -0
- package/scripts/publish-fldr.ts +78 -0
- package/scripts/theme-generator/config.ts +666 -0
- package/scripts/theme-generator/generate-css.test.ts +30 -0
- package/scripts/theme-generator/generate-css.ts +352 -0
- package/scripts/theme-generator/index.ts +165 -0
- package/scripts/theme-generator/migrate.ts +560 -0
- package/scripts/theme-generator/types.ts +92 -0
|
@@ -0,0 +1,1466 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./vendor-styling-gs32v7xt5znc8kg0.js";
|
|
3
|
+
import { t as unwrapLazyElement } from "./unwrap-lazy-element-hzbdkmujhd7iksau.js";
|
|
4
|
+
import { n as useLinkComponent } from "./link-provider-kbwllpbo24fvgioj.js";
|
|
5
|
+
import { n as TooltipProvider, t as Tooltip } from "./tooltip-bcymn9bfyz29fvji.js";
|
|
6
|
+
import { t as Button } from "./button-hzvowfkbathmx8yg.js";
|
|
7
|
+
import { t as SkeletonLine } from "./skeleton-line-kmhnp0lx3rxhioxa.js";
|
|
8
|
+
import { i as ScrollAreaViewport, n as ScrollAreaContent, r as ScrollAreaScrollbar, s as ScrollAreaRoot, t as ScrollAreaThumb } from "./ScrollAreaThumb-hxig41yn4lrurd3o.js";
|
|
9
|
+
import React, { createContext, forwardRef, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { CaretRightIcon, XIcon } from "@phosphor-icons/react";
|
|
12
|
+
//#region src/components/sidebar/sidebar.tsx
|
|
13
|
+
/** Sidebar variant definitions mapping layout, collapse, and side options. */
|
|
14
|
+
const KUMO_SIDEBAR_VARIANTS = {
|
|
15
|
+
variant: {
|
|
16
|
+
sidebar: {
|
|
17
|
+
classes: "",
|
|
18
|
+
description: "Standard sidebar with border separator"
|
|
19
|
+
},
|
|
20
|
+
floating: {
|
|
21
|
+
classes: "",
|
|
22
|
+
description: "Floating sidebar with shadow and rounded corners"
|
|
23
|
+
},
|
|
24
|
+
inset: {
|
|
25
|
+
classes: "",
|
|
26
|
+
description: "Inset sidebar within the content area"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
collapsible: {
|
|
30
|
+
icon: {
|
|
31
|
+
classes: "",
|
|
32
|
+
description: "Collapses to show icons only"
|
|
33
|
+
},
|
|
34
|
+
offcanvas: {
|
|
35
|
+
classes: "",
|
|
36
|
+
description: "Slides off screen when collapsed"
|
|
37
|
+
},
|
|
38
|
+
none: {
|
|
39
|
+
classes: "",
|
|
40
|
+
description: "Cannot be collapsed"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
side: {
|
|
44
|
+
left: {
|
|
45
|
+
classes: "",
|
|
46
|
+
description: "Left-aligned sidebar"
|
|
47
|
+
},
|
|
48
|
+
right: {
|
|
49
|
+
classes: "",
|
|
50
|
+
description: "Right-aligned sidebar"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const KUMO_SIDEBAR_DEFAULT_VARIANTS = {
|
|
55
|
+
variant: "sidebar",
|
|
56
|
+
collapsible: "icon",
|
|
57
|
+
side: "left"
|
|
58
|
+
};
|
|
59
|
+
const KUMO_SIDEBAR_STYLING = {
|
|
60
|
+
width: {
|
|
61
|
+
expanded: "16.25rem",
|
|
62
|
+
icon: "57px"
|
|
63
|
+
},
|
|
64
|
+
mobile: { breakpoint: 768 }
|
|
65
|
+
};
|
|
66
|
+
const SIDEBAR_WIDTH = "16.25rem";
|
|
67
|
+
const SIDEBAR_WIDTH_ICON = "57px";
|
|
68
|
+
const SIDEBAR_EASING = "cubic-bezier(0.77, 0, 0.175, 1)";
|
|
69
|
+
const SIDEBAR_ANIMATION_DURATION_MS = 250;
|
|
70
|
+
const TRANSITION_FALLBACK_GRACE_MS = 50;
|
|
71
|
+
const MOBILE_BREAKPOINT = 768;
|
|
72
|
+
const FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
73
|
+
function useOpenChangeComplete(open, duration, onComplete, active = true) {
|
|
74
|
+
const enabled = active && onComplete !== void 0;
|
|
75
|
+
const callbackRef = useRef(onComplete);
|
|
76
|
+
const durationRef = useRef(duration);
|
|
77
|
+
const previousOpenRef = useRef(open);
|
|
78
|
+
const previousActiveRef = useRef(active);
|
|
79
|
+
const pendingOpenRef = useRef(void 0);
|
|
80
|
+
const timeoutRef = useRef(void 0);
|
|
81
|
+
callbackRef.current = onComplete;
|
|
82
|
+
durationRef.current = duration;
|
|
83
|
+
const complete = useCallback(() => {
|
|
84
|
+
const pendingOpen = pendingOpenRef.current;
|
|
85
|
+
if (pendingOpen === void 0) return;
|
|
86
|
+
pendingOpenRef.current = void 0;
|
|
87
|
+
clearTimeout(timeoutRef.current);
|
|
88
|
+
callbackRef.current?.(pendingOpen);
|
|
89
|
+
}, []);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const openChanged = previousOpenRef.current !== open;
|
|
92
|
+
const wasActive = previousActiveRef.current;
|
|
93
|
+
previousOpenRef.current = open;
|
|
94
|
+
previousActiveRef.current = active;
|
|
95
|
+
if (!enabled) {
|
|
96
|
+
pendingOpenRef.current = void 0;
|
|
97
|
+
clearTimeout(timeoutRef.current);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!wasActive || !openChanged) return;
|
|
101
|
+
pendingOpenRef.current = open;
|
|
102
|
+
if (durationRef.current === 0 || window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
103
|
+
complete();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
timeoutRef.current = setTimeout(complete, durationRef.current + TRANSITION_FALLBACK_GRACE_MS);
|
|
107
|
+
return () => clearTimeout(timeoutRef.current);
|
|
108
|
+
}, [
|
|
109
|
+
active,
|
|
110
|
+
complete,
|
|
111
|
+
enabled,
|
|
112
|
+
open
|
|
113
|
+
]);
|
|
114
|
+
return complete;
|
|
115
|
+
}
|
|
116
|
+
function useIsMobile(breakpoint = MOBILE_BREAKPOINT) {
|
|
117
|
+
const query = `(max-width: ${breakpoint - 1}px)`;
|
|
118
|
+
const subscribe = useCallback((callback) => {
|
|
119
|
+
const mql = window.matchMedia(query);
|
|
120
|
+
mql.addEventListener("change", callback);
|
|
121
|
+
return () => mql.removeEventListener("change", callback);
|
|
122
|
+
}, [query]);
|
|
123
|
+
const getSnapshot = useCallback(() => window.matchMedia(query).matches, [query]);
|
|
124
|
+
const getServerSnapshot = useCallback(() => false, []);
|
|
125
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Vertically scrolls the sidebar viewport that contains `target`.
|
|
129
|
+
*
|
|
130
|
+
* Assigns `scrollTop` on the viewport instead of calling `scrollIntoView`,
|
|
131
|
+
* which walks the ancestor chain and scrolls every scrollable ancestor on both
|
|
132
|
+
* axes, including the `overflow-hidden` SlidingViews track and the document.
|
|
133
|
+
*/
|
|
134
|
+
function scrollWithinViewport(target, { align = "auto", behavior = "auto" } = {}) {
|
|
135
|
+
const viewport = target.closest("[data-sidebar=\"viewport\"]");
|
|
136
|
+
if (!viewport) return;
|
|
137
|
+
const targetRect = target.getBoundingClientRect();
|
|
138
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
139
|
+
const viewportScaleY = viewport.offsetHeight > 0 && viewportRect.height > 0 ? viewportRect.height / viewport.offsetHeight : 1;
|
|
140
|
+
const itemScrollOffset = (targetRect.top - viewportRect.top) / viewportScaleY + viewport.scrollTop;
|
|
141
|
+
let desired;
|
|
142
|
+
if (align === "center") desired = itemScrollOffset - (viewport.clientHeight - target.offsetHeight) / 2;
|
|
143
|
+
else if (align === "end") desired = itemScrollOffset - (viewport.clientHeight - target.offsetHeight);
|
|
144
|
+
else if (align === "auto") {
|
|
145
|
+
const itemBottom = itemScrollOffset + target.offsetHeight;
|
|
146
|
+
const viewBottom = viewport.scrollTop + viewport.clientHeight;
|
|
147
|
+
if (itemScrollOffset < viewport.scrollTop) desired = itemScrollOffset;
|
|
148
|
+
else if (itemBottom > viewBottom) desired = itemBottom - viewport.clientHeight;
|
|
149
|
+
else return;
|
|
150
|
+
} else desired = itemScrollOffset;
|
|
151
|
+
const clamped = Math.max(0, Math.min(desired, viewport.scrollHeight - viewport.clientHeight));
|
|
152
|
+
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
153
|
+
viewport.scrollTo({
|
|
154
|
+
top: clamped,
|
|
155
|
+
behavior: reducedMotion ? "auto" : behavior
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const SidebarContext = createContext(null);
|
|
159
|
+
/**
|
|
160
|
+
* Hook to access sidebar state and actions from any descendant component.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```tsx
|
|
164
|
+
* const { state, open, toggleSidebar, isMobile } = useSidebar();
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @throws Error if used outside a `Sidebar.Provider`.
|
|
168
|
+
*/
|
|
169
|
+
function useSidebar() {
|
|
170
|
+
const context = useContext(SidebarContext);
|
|
171
|
+
if (!context) throw new Error("useSidebar must be used within a Sidebar.Provider");
|
|
172
|
+
return context;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Sidebar context provider. Manages expand/collapse state and mobile detection.
|
|
176
|
+
* Renders a flex wrapper div with CSS custom properties for sidebar width.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* <Sidebar.Provider defaultOpen>
|
|
181
|
+
* <Sidebar>{...}</Sidebar>
|
|
182
|
+
* <main className="flex-1">{...}</main>
|
|
183
|
+
* </Sidebar.Provider>
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
const DEFAULT_WIDTH_PX = 256;
|
|
187
|
+
const MIN_WIDTH_PX = 200;
|
|
188
|
+
const MAX_WIDTH_PX = 480;
|
|
189
|
+
function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, onOpenChangeComplete, variant = KUMO_SIDEBAR_DEFAULT_VARIANTS.variant, side = KUMO_SIDEBAR_DEFAULT_VARIANTS.side, collapsible = KUMO_SIDEBAR_DEFAULT_VARIANTS.collapsible, resizable = false, defaultWidth = DEFAULT_WIDTH_PX, minWidth = MIN_WIDTH_PX, maxWidth = MAX_WIDTH_PX, onWidthChange, contained = false, peekable = false, animationDuration = SIDEBAR_ANIMATION_DURATION_MS, mobileBreakpoint, children, className, style }) {
|
|
190
|
+
const isMobile = useIsMobile(mobileBreakpoint);
|
|
191
|
+
const [_openMobile, _setOpenMobile] = useState(false);
|
|
192
|
+
const [width, setWidthState] = useState(defaultWidth);
|
|
193
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
194
|
+
const [isPeeking, setIsPeeking] = useState(false);
|
|
195
|
+
const openMobile = isMobile && openProp !== void 0 ? openProp : _openMobile;
|
|
196
|
+
const setOpenMobile = useCallback((next) => {
|
|
197
|
+
_setOpenMobile(next);
|
|
198
|
+
if (isMobile && openProp !== void 0) setOpenProp?.(next);
|
|
199
|
+
}, [
|
|
200
|
+
isMobile,
|
|
201
|
+
openProp,
|
|
202
|
+
setOpenProp
|
|
203
|
+
]);
|
|
204
|
+
const setWidth = useCallback((newWidth) => {
|
|
205
|
+
const clamped = Math.min(maxWidth, Math.max(minWidth, newWidth));
|
|
206
|
+
setWidthState(clamped);
|
|
207
|
+
onWidthChange?.(clamped);
|
|
208
|
+
}, [
|
|
209
|
+
minWidth,
|
|
210
|
+
maxWidth,
|
|
211
|
+
onWidthChange
|
|
212
|
+
]);
|
|
213
|
+
const [_open, _setOpen] = useState(defaultOpen);
|
|
214
|
+
const open = openProp ?? _open;
|
|
215
|
+
const setOpen = useCallback((value) => {
|
|
216
|
+
const next = typeof value === "function" ? value(open) : value;
|
|
217
|
+
setOpenProp?.(next);
|
|
218
|
+
_setOpen(next);
|
|
219
|
+
}, [setOpenProp, open]);
|
|
220
|
+
const toggleSidebar = useCallback(() => {
|
|
221
|
+
if (isMobile) setOpenMobile(!openMobile);
|
|
222
|
+
else {
|
|
223
|
+
setIsPeeking(false);
|
|
224
|
+
setOpen((prev) => !prev);
|
|
225
|
+
}
|
|
226
|
+
}, [
|
|
227
|
+
isMobile,
|
|
228
|
+
openMobile,
|
|
229
|
+
setOpenMobile,
|
|
230
|
+
setOpen
|
|
231
|
+
]);
|
|
232
|
+
const startPeek = useCallback(() => {
|
|
233
|
+
if (peekable && !open && !isMobile) setIsPeeking(true);
|
|
234
|
+
}, [
|
|
235
|
+
peekable,
|
|
236
|
+
open,
|
|
237
|
+
isMobile
|
|
238
|
+
]);
|
|
239
|
+
const stopPeek = useCallback(() => {
|
|
240
|
+
setIsPeeking(false);
|
|
241
|
+
}, []);
|
|
242
|
+
const state = isPeeking ? "peeking" : open ? "expanded" : "collapsed";
|
|
243
|
+
const sidebarWidthValue = resizable ? `${width}px` : SIDEBAR_WIDTH;
|
|
244
|
+
const itemsRef = useRef(/* @__PURE__ */ new Map());
|
|
245
|
+
const registerItem = useCallback((id, node) => {
|
|
246
|
+
const items = itemsRef.current;
|
|
247
|
+
if (node) items.set(id, node);
|
|
248
|
+
else items.delete(id);
|
|
249
|
+
}, []);
|
|
250
|
+
const scrollToItem = useCallback((id, options = {}) => {
|
|
251
|
+
const target = itemsRef.current.get(id);
|
|
252
|
+
if (!target) return;
|
|
253
|
+
scrollWithinViewport(target, options);
|
|
254
|
+
}, []);
|
|
255
|
+
const scrollItemIntoView = useCallback((id, options = {}) => {
|
|
256
|
+
const target = itemsRef.current.get(id);
|
|
257
|
+
if (!target) return;
|
|
258
|
+
const viewport = target.closest("[data-sidebar=\"viewport\"]");
|
|
259
|
+
if (!viewport) return;
|
|
260
|
+
const targetRect = target.getBoundingClientRect();
|
|
261
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
262
|
+
if (targetRect.top >= viewportRect.top && targetRect.bottom <= viewportRect.bottom) return;
|
|
263
|
+
scrollToItem(id, options);
|
|
264
|
+
}, [scrollToItem]);
|
|
265
|
+
const contextValue = useMemo(() => ({
|
|
266
|
+
state,
|
|
267
|
+
open,
|
|
268
|
+
setOpen,
|
|
269
|
+
openMobile,
|
|
270
|
+
setOpenMobile,
|
|
271
|
+
isMobile,
|
|
272
|
+
toggleSidebar,
|
|
273
|
+
variant,
|
|
274
|
+
side,
|
|
275
|
+
collapsible,
|
|
276
|
+
width,
|
|
277
|
+
resizable,
|
|
278
|
+
minWidth,
|
|
279
|
+
maxWidth,
|
|
280
|
+
isResizing,
|
|
281
|
+
setIsResizing,
|
|
282
|
+
setWidth,
|
|
283
|
+
isPeeking,
|
|
284
|
+
peekable,
|
|
285
|
+
startPeek,
|
|
286
|
+
stopPeek,
|
|
287
|
+
contained,
|
|
288
|
+
animationDuration,
|
|
289
|
+
registerItem,
|
|
290
|
+
scrollToItem,
|
|
291
|
+
scrollItemIntoView
|
|
292
|
+
}), [
|
|
293
|
+
state,
|
|
294
|
+
open,
|
|
295
|
+
openMobile,
|
|
296
|
+
isMobile,
|
|
297
|
+
width,
|
|
298
|
+
isResizing,
|
|
299
|
+
isPeeking
|
|
300
|
+
]);
|
|
301
|
+
const completeDesktopOpenChange = useOpenChangeComplete(open, animationDuration, onOpenChangeComplete, !isMobile);
|
|
302
|
+
const completeMobileOpenChange = useOpenChangeComplete(openMobile, animationDuration, onOpenChangeComplete, isMobile);
|
|
303
|
+
const completeOpenChange = isMobile ? completeMobileOpenChange : completeDesktopOpenChange;
|
|
304
|
+
const transitionProperty = isMobile ? "transform" : "width";
|
|
305
|
+
const handleOpenTransitionEnd = useCallback((event) => {
|
|
306
|
+
const target = event.target;
|
|
307
|
+
if (target.closest("[data-sidebar-wrapper]") === event.currentTarget && target.dataset.sidebar === "sidebar" && event.propertyName === transitionProperty) completeOpenChange();
|
|
308
|
+
}, [completeOpenChange, transitionProperty]);
|
|
309
|
+
return /* @__PURE__ */ jsx(SidebarContext.Provider, {
|
|
310
|
+
value: contextValue,
|
|
311
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
312
|
+
"data-sidebar-wrapper": "",
|
|
313
|
+
"data-state": state,
|
|
314
|
+
"data-side": side,
|
|
315
|
+
onTransitionEnd: handleOpenTransitionEnd,
|
|
316
|
+
style: {
|
|
317
|
+
"--sidebar-width": sidebarWidthValue,
|
|
318
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
319
|
+
"--sidebar-animation-duration": `${animationDuration}ms`,
|
|
320
|
+
"--sidebar-easing": SIDEBAR_EASING,
|
|
321
|
+
...style
|
|
322
|
+
},
|
|
323
|
+
className: cn("group/sidebar-wrapper relative isolate flex w-full [--sidebar-active-bg:var(--color-kumo-tint)] [--sidebar-bg:var(--color-kumo-base)]", !contained && !isMobile && "min-h-svh", "has-data-[variant=inset]:bg-kumo-recessed", isResizing && "select-none", className),
|
|
324
|
+
children
|
|
325
|
+
})
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
SidebarProvider.displayName = "Sidebar.Provider";
|
|
329
|
+
/**
|
|
330
|
+
* Main sidebar container. Renders as `<aside>` on desktop, modal sidebar sheet on mobile.
|
|
331
|
+
* Must be used inside `Sidebar.Provider`.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```tsx
|
|
335
|
+
* <Sidebar.Provider>
|
|
336
|
+
* <Sidebar>
|
|
337
|
+
* <Sidebar.Header>...</Sidebar.Header>
|
|
338
|
+
* <Sidebar.Content>...</Sidebar.Content>
|
|
339
|
+
* <Sidebar.Footer>...</Sidebar.Footer>
|
|
340
|
+
* </Sidebar>
|
|
341
|
+
* </Sidebar.Provider>
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
const SidebarRoot = forwardRef(({ className, contentClassName, children, fullScreenOnMobile = false, ...props }, ref) => {
|
|
345
|
+
const { state, open, isMobile, openMobile, setOpenMobile, side, variant, collapsible, isResizing, resizable, width, isPeeking, startPeek, stopPeek, contained } = useSidebar();
|
|
346
|
+
const mobileAsideRef = useCallback((node) => {
|
|
347
|
+
if (node) {
|
|
348
|
+
if (!openMobile) node.setAttribute("inert", "");
|
|
349
|
+
else node.removeAttribute("inert");
|
|
350
|
+
}
|
|
351
|
+
}, [openMobile]);
|
|
352
|
+
const mergedMobileRef = useCallback((node) => {
|
|
353
|
+
mobileAsideRef(node);
|
|
354
|
+
if (typeof ref === "function") ref(node);
|
|
355
|
+
else if (ref) ref.current = node;
|
|
356
|
+
}, [ref, mobileAsideRef]);
|
|
357
|
+
const triggerRef = useRef(null);
|
|
358
|
+
const mobileNodeRef = useRef(null);
|
|
359
|
+
const shouldRestoreFocusRef = useRef(false);
|
|
360
|
+
const isPointerInPeekZoneRef = useRef(false);
|
|
361
|
+
useEffect(() => {
|
|
362
|
+
if (!isMobile || !openMobile) return;
|
|
363
|
+
const handleKeyDown = (e) => {
|
|
364
|
+
if (e.key === "Escape") {
|
|
365
|
+
shouldRestoreFocusRef.current = true;
|
|
366
|
+
setOpenMobile(false);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
370
|
+
return () => {
|
|
371
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
372
|
+
};
|
|
373
|
+
}, [
|
|
374
|
+
isMobile,
|
|
375
|
+
openMobile,
|
|
376
|
+
setOpenMobile
|
|
377
|
+
]);
|
|
378
|
+
useEffect(() => {
|
|
379
|
+
if (!isMobile) return;
|
|
380
|
+
if (openMobile) {
|
|
381
|
+
triggerRef.current = document.activeElement;
|
|
382
|
+
shouldRestoreFocusRef.current = false;
|
|
383
|
+
requestAnimationFrame(() => {
|
|
384
|
+
(mobileNodeRef.current?.querySelector(FOCUSABLE_SELECTOR) ?? mobileNodeRef.current)?.focus();
|
|
385
|
+
});
|
|
386
|
+
} else if (shouldRestoreFocusRef.current && triggerRef.current instanceof HTMLElement) {
|
|
387
|
+
triggerRef.current.focus();
|
|
388
|
+
shouldRestoreFocusRef.current = false;
|
|
389
|
+
triggerRef.current = null;
|
|
390
|
+
}
|
|
391
|
+
}, [isMobile, openMobile]);
|
|
392
|
+
const handlePeekBlur = useCallback((e) => {
|
|
393
|
+
if (!e.currentTarget.contains(e.relatedTarget) && !isPointerInPeekZoneRef.current) stopPeek();
|
|
394
|
+
}, [stopPeek]);
|
|
395
|
+
const handlePeekMouseEnter = useCallback(() => {
|
|
396
|
+
isPointerInPeekZoneRef.current = true;
|
|
397
|
+
startPeek();
|
|
398
|
+
}, [startPeek]);
|
|
399
|
+
const handlePeekMouseLeave = useCallback(() => {
|
|
400
|
+
isPointerInPeekZoneRef.current = false;
|
|
401
|
+
stopPeek();
|
|
402
|
+
}, [stopPeek]);
|
|
403
|
+
if (collapsible === "none") return /* @__PURE__ */ jsx("aside", {
|
|
404
|
+
ref,
|
|
405
|
+
"data-state": "expanded",
|
|
406
|
+
"data-side": side,
|
|
407
|
+
"data-variant": variant,
|
|
408
|
+
"data-sidebar": "sidebar",
|
|
409
|
+
style: {
|
|
410
|
+
width: "var(--sidebar-width)",
|
|
411
|
+
minWidth: "var(--sidebar-width)",
|
|
412
|
+
maxWidth: "var(--sidebar-width)"
|
|
413
|
+
},
|
|
414
|
+
className: cn("relative flex h-full shrink-0 grow-0 flex-col overflow-hidden bg-(--sidebar-bg) text-kumo-default", variant === "sidebar" && (side === "left" ? "border-r border-kumo-line" : "border-l border-kumo-line"), variant === "floating" && "m-2 rounded-lg border border-kumo-line shadow-lg", className),
|
|
415
|
+
...props,
|
|
416
|
+
children
|
|
417
|
+
});
|
|
418
|
+
if (isMobile) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
419
|
+
"data-sidebar-backdrop": "",
|
|
420
|
+
className: cn(contained ? "absolute inset-0 z-40 bg-kumo-recessed" : "fixed inset-0 z-40 bg-kumo-recessed", "transition-opacity duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", "motion-reduce:transition-none", openMobile && !fullScreenOnMobile ? "opacity-80" : "pointer-events-none opacity-0"),
|
|
421
|
+
onClick: () => {
|
|
422
|
+
shouldRestoreFocusRef.current = true;
|
|
423
|
+
setOpenMobile(false);
|
|
424
|
+
},
|
|
425
|
+
"aria-hidden": "true"
|
|
426
|
+
}), /* @__PURE__ */ jsx("nav", {
|
|
427
|
+
ref: (node) => {
|
|
428
|
+
mergedMobileRef(node);
|
|
429
|
+
mobileNodeRef.current = node;
|
|
430
|
+
},
|
|
431
|
+
tabIndex: -1,
|
|
432
|
+
"aria-label": "Navigation",
|
|
433
|
+
"aria-hidden": !openMobile,
|
|
434
|
+
"data-state": openMobile ? "expanded" : "collapsed",
|
|
435
|
+
"data-side": side,
|
|
436
|
+
"data-variant": variant,
|
|
437
|
+
"data-collapsible": collapsible,
|
|
438
|
+
"data-sidebar": "sidebar",
|
|
439
|
+
"data-mobile": "true",
|
|
440
|
+
className: cn("group/sidebar inset-y-0 z-50 flex flex-col overflow-hidden", contained ? "absolute" : "fixed", fullScreenOnMobile ? "w-full" : "w-(--sidebar-width)", "bg-(--sidebar-bg) text-kumo-default", !fullScreenOnMobile && "border-r border-kumo-line", "transition-transform duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", "motion-reduce:transition-none", side === "left" && "left-0", side === "right" && "right-0", side === "left" && (openMobile ? "translate-x-0" : "-translate-x-full"), side === "right" && (openMobile ? "translate-x-0" : "translate-x-full"), className),
|
|
441
|
+
...props,
|
|
442
|
+
children
|
|
443
|
+
})] });
|
|
444
|
+
const collapsedWidth = collapsible === "icon" ? "var(--sidebar-width-icon)" : "0px";
|
|
445
|
+
const expandedWidth = resizable ? `${width}px` : "var(--sidebar-width)";
|
|
446
|
+
const railWidth = open ? expandedWidth : collapsedWidth;
|
|
447
|
+
const contentWidth = open || isPeeking ? expandedWidth : collapsedWidth;
|
|
448
|
+
const borderClasses = variant === "sidebar" ? side === "left" ? "border-r border-kumo-line" : "border-l border-kumo-line" : variant === "floating" ? "border border-kumo-line" : "";
|
|
449
|
+
return /* @__PURE__ */ jsx("aside", {
|
|
450
|
+
ref,
|
|
451
|
+
"data-state": state,
|
|
452
|
+
"data-side": side,
|
|
453
|
+
"data-variant": variant,
|
|
454
|
+
"data-collapsible": collapsible,
|
|
455
|
+
"data-sidebar": "sidebar",
|
|
456
|
+
style: { width: railWidth },
|
|
457
|
+
className: cn("group/sidebar relative h-full shrink-0 grow-0", "overflow-visible", "transition-[width] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", "motion-reduce:transition-none", isResizing && "transition-none!", variant === "floating" && "m-2 rounded-lg shadow-lg", className),
|
|
458
|
+
...props,
|
|
459
|
+
children: /* @__PURE__ */ jsx(TooltipProvider, { children: (() => {
|
|
460
|
+
const childArray = React.Children.toArray(children);
|
|
461
|
+
const footerChildren = childArray.filter((child) => React.isValidElement(child) && child.type?.displayName === "Sidebar.Footer");
|
|
462
|
+
const nonFooterChildren = childArray.filter((child) => !React.isValidElement(child) || child.type?.displayName !== "Sidebar.Footer");
|
|
463
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
464
|
+
"data-sidebar": "content-container",
|
|
465
|
+
style: { width: contentWidth },
|
|
466
|
+
className: cn("flex h-full flex-col", "min-w-0 overflow-hidden whitespace-nowrap", "bg-(--sidebar-bg) text-kumo-default", borderClasses, "transition-[width] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", "motion-reduce:transition-none", isResizing && "transition-none!", !open && cn(contained ? "absolute" : "fixed", "inset-y-0 z-40", side === "left" && "left-0", side === "right" && "right-0"), open && "relative", contentClassName),
|
|
467
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
468
|
+
"data-sidebar": "peek-zone",
|
|
469
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
470
|
+
onMouseEnter: handlePeekMouseEnter,
|
|
471
|
+
onMouseLeave: handlePeekMouseLeave,
|
|
472
|
+
onFocus: startPeek,
|
|
473
|
+
onBlur: handlePeekBlur,
|
|
474
|
+
children: nonFooterChildren
|
|
475
|
+
}), footerChildren]
|
|
476
|
+
});
|
|
477
|
+
})() })
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
SidebarRoot.displayName = "Sidebar";
|
|
481
|
+
/**
|
|
482
|
+
* Top section of the sidebar. Typically contains a logo, title, and action button.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```tsx
|
|
486
|
+
* <Sidebar.Header>
|
|
487
|
+
* <CloudflareLogo />
|
|
488
|
+
* <span>Design Engineering</span>
|
|
489
|
+
* <Button shape="square" icon={CaretUpDownIcon} aria-label="Switch" />
|
|
490
|
+
* </Sidebar.Header>
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
const SidebarHeader = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
494
|
+
ref,
|
|
495
|
+
"data-sidebar": "header",
|
|
496
|
+
className: cn("flex h-[58px] shrink-0 items-center gap-1 border-b border-kumo-line", "overflow-hidden px-3", className),
|
|
497
|
+
...props
|
|
498
|
+
}));
|
|
499
|
+
SidebarHeader.displayName = "Sidebar.Header";
|
|
500
|
+
/**
|
|
501
|
+
* Scrollable middle section of the sidebar. Contains nav groups and menus.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```tsx
|
|
505
|
+
* <Sidebar.Content>
|
|
506
|
+
* <Sidebar.Group>...</Sidebar.Group>
|
|
507
|
+
* </Sidebar.Content>
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
const SidebarContent = forwardRef(({ className, children, ...props }, ref) => {
|
|
511
|
+
return /* @__PURE__ */ jsxs(ScrollAreaRoot, {
|
|
512
|
+
ref,
|
|
513
|
+
"data-sidebar": "content",
|
|
514
|
+
className: cn("relative min-w-0 flex-1 overflow-hidden", className),
|
|
515
|
+
...props,
|
|
516
|
+
children: [/* @__PURE__ */ jsx(ScrollAreaViewport, {
|
|
517
|
+
tabIndex: -1,
|
|
518
|
+
"data-sidebar": "viewport",
|
|
519
|
+
className: cn("h-full px-[11px] py-3 group-not-data-[state=collapsed]/sidebar:px-3.5", "transition-[padding] duration-(--sidebar-animation-duration)", "overflow-x-hidden!", "no-scrollbar", "[mask-image:linear-gradient(to_bottom,transparent_0,black_min(24px,var(--scroll-area-overflow-y-start,24px)),black_calc(100%-min(24px,var(--scroll-area-overflow-y-end,24px))),transparent_100%)]"),
|
|
520
|
+
children: /* @__PURE__ */ jsx(ScrollAreaContent, {
|
|
521
|
+
className: "flex min-w-0! flex-col",
|
|
522
|
+
children
|
|
523
|
+
})
|
|
524
|
+
}), /* @__PURE__ */ jsx(ScrollAreaScrollbar, {
|
|
525
|
+
orientation: "vertical",
|
|
526
|
+
className: cn("flex w-1.5 touch-none p-px select-none", "opacity-0 transition-opacity duration-150", "data-[hovering]:opacity-100 data-[scrolling]:opacity-100", "group-data-[state=collapsed]/sidebar:hidden"),
|
|
527
|
+
children: /* @__PURE__ */ jsx(ScrollAreaThumb, { className: "flex-1 rounded-full bg-kumo-line" })
|
|
528
|
+
})]
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
SidebarContent.displayName = "Sidebar.Content";
|
|
532
|
+
/**
|
|
533
|
+
* Bottom-pinned section of the sidebar. Rendered outside the peek zone
|
|
534
|
+
* so hovering the footer doesn't trigger a peek. Tracks sidebar width
|
|
535
|
+
* to stay aligned with the content container.
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```tsx
|
|
539
|
+
* <Sidebar.Footer>
|
|
540
|
+
* <Sidebar.Trigger />
|
|
541
|
+
* </Sidebar.Footer>
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
const SidebarFooter = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
545
|
+
ref,
|
|
546
|
+
"data-sidebar": "footer",
|
|
547
|
+
className: cn("flex h-12 shrink-0 items-center gap-4 overflow-hidden border-t border-kumo-line whitespace-nowrap", "px-[11px] group-not-data-[state=collapsed]/sidebar:px-4", "bg-(--sidebar-bg)", "w-(--sidebar-width)", "transition-[width,padding] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", "motion-reduce:transition-none", "sticky bottom-0", "bg-clip-padding group-data-[state=collapsed]/sidebar:w-(--sidebar-width-icon)", "group-data-[state=collapsed]/sidebar:border-r group-data-[state=collapsed]/sidebar:border-kumo-line", className),
|
|
548
|
+
...props
|
|
549
|
+
}));
|
|
550
|
+
SidebarFooter.displayName = "Sidebar.Footer";
|
|
551
|
+
/**
|
|
552
|
+
* Placeholder rows for `Sidebar.Loading`, grouped like a real nav. Each string
|
|
553
|
+
* is a label-width utility; each group renders a group label above its items.
|
|
554
|
+
*/
|
|
555
|
+
const SIDEBAR_LOADING_GROUPS = [[
|
|
556
|
+
"w-28",
|
|
557
|
+
"w-40",
|
|
558
|
+
"w-24"
|
|
559
|
+
], [
|
|
560
|
+
"w-24",
|
|
561
|
+
"w-36",
|
|
562
|
+
"w-32"
|
|
563
|
+
]];
|
|
564
|
+
/**
|
|
565
|
+
* Loading state for the whole sidebar nav: nav-item-shaped placeholder rows
|
|
566
|
+
* (icon + label) grouped like the real nav, composed from `SkeletonLine` so it
|
|
567
|
+
* shares Kumo's skeleton shimmer. Drop it in place of the nav content while
|
|
568
|
+
* routes/permissions resolve. When collapsed only the icon squares remain.
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```tsx
|
|
572
|
+
* <Sidebar>
|
|
573
|
+
* {isLoading ? <Sidebar.Loading /> : <Sidebar.Content>…</Sidebar.Content>}
|
|
574
|
+
* </Sidebar>
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
const SidebarLoading = forwardRef(({ className, label = "Loading", ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
578
|
+
ref,
|
|
579
|
+
"data-sidebar": "loading",
|
|
580
|
+
role: "status",
|
|
581
|
+
"aria-label": label,
|
|
582
|
+
className: cn("flex min-h-0 w-full flex-1 flex-col gap-4 px-2 py-3", className),
|
|
583
|
+
...props,
|
|
584
|
+
children: SIDEBAR_LOADING_GROUPS.map((widths, groupIndex) => /* @__PURE__ */ jsxs("div", {
|
|
585
|
+
className: "flex flex-col gap-0.5",
|
|
586
|
+
children: [/* @__PURE__ */ jsx(SkeletonLine, { className: "mb-1 ml-2 h-2 w-16 rounded-full group-data-[state=collapsed]/sidebar:hidden" }), widths.map((width, itemIndex) => /* @__PURE__ */ jsxs("div", {
|
|
587
|
+
className: "flex min-h-8.5 items-center gap-3 rounded-lg px-3 group-data-[state=collapsed]/sidebar:justify-center group-data-[state=collapsed]/sidebar:px-0",
|
|
588
|
+
children: [/* @__PURE__ */ jsx(SkeletonLine, { className: "size-4.5 shrink-0 rounded-md" }), /* @__PURE__ */ jsx(SkeletonLine, { className: cn("h-2.5 rounded-full group-data-[state=collapsed]/sidebar:hidden", width) })]
|
|
589
|
+
}, itemIndex))]
|
|
590
|
+
}, groupIndex))
|
|
591
|
+
}));
|
|
592
|
+
SidebarLoading.displayName = "Sidebar.Loading";
|
|
593
|
+
/**
|
|
594
|
+
* Groups related menu items with an optional label.
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```tsx
|
|
598
|
+
* <Sidebar.Group>
|
|
599
|
+
* <Sidebar.GroupLabel>Build</Sidebar.GroupLabel>
|
|
600
|
+
* <Sidebar.Menu>...</Sidebar.Menu>
|
|
601
|
+
* </Sidebar.Group>
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
const SidebarGroup = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
605
|
+
ref,
|
|
606
|
+
"data-sidebar": "group",
|
|
607
|
+
className: cn("flex min-w-0 flex-col gap-y-px", className),
|
|
608
|
+
...props,
|
|
609
|
+
children
|
|
610
|
+
}));
|
|
611
|
+
SidebarGroup.displayName = "Sidebar.Group";
|
|
612
|
+
/**
|
|
613
|
+
* Section label for a sidebar group (e.g., "Build", "Protect & Connect").
|
|
614
|
+
* When the sidebar is collapsed, renders as a thin horizontal divider.
|
|
615
|
+
* When it's the first group, the divider is hidden (nothing above to separate from).
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```tsx
|
|
619
|
+
* <Sidebar.GroupLabel>Build</Sidebar.GroupLabel>
|
|
620
|
+
* ```
|
|
621
|
+
*/
|
|
622
|
+
const SidebarGroupLabel = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
623
|
+
ref,
|
|
624
|
+
"data-sidebar": "group-label",
|
|
625
|
+
className: cn("grid overflow-hidden", "transition-[grid-template-rows,margin,border-color] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", "group-data-[mobile=true]/sidebar:transition-none", "my-3 grid-rows-[0fr] border-b border-kumo-line", "[[data-sidebar=group]:first-child_&]:my-0 [[data-sidebar=group]:first-child_&]:border-transparent", "group-not-data-[state=collapsed]/sidebar:my-0 group-not-data-[state=collapsed]/sidebar:grid-rows-[1fr] group-not-data-[state=collapsed]/sidebar:border-transparent", "group-data-[mobile=true]/sidebar:my-0 group-data-[mobile=true]/sidebar:grid-rows-[1fr] group-data-[mobile=true]/sidebar:border-transparent", className),
|
|
626
|
+
...props,
|
|
627
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
628
|
+
className: "min-h-0 min-w-0",
|
|
629
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
630
|
+
className: cn("mt-4 mb-2 truncate px-3 text-sm font-medium text-kumo-subtle", "[[data-sidebar=group]:first-child_&]:mt-2"),
|
|
631
|
+
children
|
|
632
|
+
})
|
|
633
|
+
})
|
|
634
|
+
}));
|
|
635
|
+
SidebarGroupLabel.displayName = "Sidebar.GroupLabel";
|
|
636
|
+
/**
|
|
637
|
+
* When `true`, indicates the component is already wrapped in a `MenuItem` `<li>`.
|
|
638
|
+
* `MenuButton` checks this: if `false`, it auto-wraps itself in an `<li>`.
|
|
639
|
+
*/
|
|
640
|
+
const MenuItemContext = createContext(false);
|
|
641
|
+
/**
|
|
642
|
+
* When `true`, indicates the component is already wrapped in a `MenuSubItem` `<li>`.
|
|
643
|
+
* `MenuSubButton` checks this: if `false`, it auto-wraps itself in an `<li>`.
|
|
644
|
+
*/
|
|
645
|
+
const MenuSubItemContext = createContext(false);
|
|
646
|
+
/**
|
|
647
|
+
* Navigation menu list. Renders as `<ul>`.
|
|
648
|
+
*
|
|
649
|
+
* `MenuButton` auto-wraps in `<li>` so `MenuItem` is optional for simple items.
|
|
650
|
+
*
|
|
651
|
+
* @example Simple usage
|
|
652
|
+
* ```tsx
|
|
653
|
+
* <Sidebar.Menu>
|
|
654
|
+
* <Sidebar.MenuButton icon={HouseIcon} active>Account home</Sidebar.MenuButton>
|
|
655
|
+
* <Sidebar.MenuButton icon={GlobeIcon}>Domains</Sidebar.MenuButton>
|
|
656
|
+
* </Sidebar.Menu>
|
|
657
|
+
* ```
|
|
658
|
+
*
|
|
659
|
+
* @example With explicit MenuItem (needed for Collapsible wrapper)
|
|
660
|
+
* ```tsx
|
|
661
|
+
* <Sidebar.Menu>
|
|
662
|
+
* <Sidebar.MenuItem>
|
|
663
|
+
* <Sidebar.Collapsible>...</Sidebar.Collapsible>
|
|
664
|
+
* </Sidebar.MenuItem>
|
|
665
|
+
* </Sidebar.Menu>
|
|
666
|
+
* ```
|
|
667
|
+
*/
|
|
668
|
+
const SidebarMenu = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("ul", {
|
|
669
|
+
ref,
|
|
670
|
+
"data-sidebar": "menu",
|
|
671
|
+
className: cn("m-0 flex min-w-0 list-none flex-col items-stretch gap-y-px p-0", className),
|
|
672
|
+
...props
|
|
673
|
+
}));
|
|
674
|
+
SidebarMenu.displayName = "Sidebar.Menu";
|
|
675
|
+
const SidebarMenuItem = forwardRef(({ className, children, itemId, ...props }, ref) => {
|
|
676
|
+
const { registerItem } = useSidebar();
|
|
677
|
+
const setRef = useCallback((node) => {
|
|
678
|
+
if (itemId) registerItem(itemId, node);
|
|
679
|
+
if (typeof ref === "function") ref(node);
|
|
680
|
+
else if (ref) ref.current = node;
|
|
681
|
+
}, [
|
|
682
|
+
itemId,
|
|
683
|
+
ref,
|
|
684
|
+
registerItem
|
|
685
|
+
]);
|
|
686
|
+
return /* @__PURE__ */ jsx(MenuItemContext.Provider, {
|
|
687
|
+
value: true,
|
|
688
|
+
children: /* @__PURE__ */ jsx("li", {
|
|
689
|
+
ref: setRef,
|
|
690
|
+
"data-sidebar": "menu-item",
|
|
691
|
+
"data-sidebar-item-id": itemId,
|
|
692
|
+
className: cn("relative group-data-[state=collapsed]/sidebar:overflow-hidden", className),
|
|
693
|
+
...props,
|
|
694
|
+
children
|
|
695
|
+
})
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
SidebarMenuItem.displayName = "Sidebar.MenuItem";
|
|
699
|
+
/**
|
|
700
|
+
* Primary interactive element inside a menu item. Renders as a `<button>` or link.
|
|
701
|
+
* Supports icons, active state, and auto-tooltip when the sidebar is collapsed.
|
|
702
|
+
*
|
|
703
|
+
* **Auto-wraps in `<li>`** when not already inside a `Sidebar.MenuItem`.
|
|
704
|
+
* Use `MenuItem` explicitly only when wrapping a `Collapsible`.
|
|
705
|
+
*
|
|
706
|
+
* @example Simple usage (auto-wrapped in `<li>`)
|
|
707
|
+
* ```tsx
|
|
708
|
+
* <Sidebar.Menu>
|
|
709
|
+
* <Sidebar.MenuButton icon={GlobeIcon} active>Domains</Sidebar.MenuButton>
|
|
710
|
+
* <Sidebar.MenuButton icon={ClockIcon} href="/recents">Recents</Sidebar.MenuButton>
|
|
711
|
+
* </Sidebar.Menu>
|
|
712
|
+
* ```
|
|
713
|
+
*
|
|
714
|
+
* @example With Collapsible (explicit MenuItem needed)
|
|
715
|
+
* ```tsx
|
|
716
|
+
* <Sidebar.MenuItem>
|
|
717
|
+
* <Sidebar.Collapsible>
|
|
718
|
+
* <Sidebar.CollapsibleTrigger render={<Sidebar.MenuButton icon={CodeIcon}>Compute<Sidebar.MenuChevron /></Sidebar.MenuButton>} />
|
|
719
|
+
* <Sidebar.CollapsibleContent>...</Sidebar.CollapsibleContent>
|
|
720
|
+
* </Sidebar.Collapsible>
|
|
721
|
+
* </Sidebar.MenuItem>
|
|
722
|
+
* ```
|
|
723
|
+
*/
|
|
724
|
+
const SidebarMenuButton = forwardRef(({ className, icon: IconProp, active = false, size = "base", href, target, tooltip, itemId, children, ...props }, ref) => {
|
|
725
|
+
const { state, peekable, registerItem } = useSidebar();
|
|
726
|
+
const LinkComponent = useLinkComponent();
|
|
727
|
+
const isInsideMenuItem = useContext(MenuItemContext);
|
|
728
|
+
const registerAutoWrap = useCallback((node) => {
|
|
729
|
+
if (itemId && !isInsideMenuItem) registerItem(itemId, node);
|
|
730
|
+
}, [
|
|
731
|
+
itemId,
|
|
732
|
+
isInsideMenuItem,
|
|
733
|
+
registerItem
|
|
734
|
+
]);
|
|
735
|
+
const registerInteractive = useCallback((node) => {
|
|
736
|
+
if (itemId && isInsideMenuItem) registerItem(itemId, node);
|
|
737
|
+
if (typeof ref === "function") ref(node);
|
|
738
|
+
else if (ref) ref.current = node;
|
|
739
|
+
}, [
|
|
740
|
+
itemId,
|
|
741
|
+
isInsideMenuItem,
|
|
742
|
+
ref,
|
|
743
|
+
registerItem
|
|
744
|
+
]);
|
|
745
|
+
const iconNode = (() => {
|
|
746
|
+
const icon = unwrapLazyElement(IconProp);
|
|
747
|
+
if (!icon) return null;
|
|
748
|
+
if (React.isValidElement(icon)) return icon;
|
|
749
|
+
return /* @__PURE__ */ jsx(icon, { className: cn("shrink-0 opacity-40", size === "base" ? "size-4" : "size-3.5") });
|
|
750
|
+
})();
|
|
751
|
+
const content = /* @__PURE__ */ jsxs("div", {
|
|
752
|
+
className: cn("flex min-w-0 flex-1 items-center gap-3", "translate-x-[-3px] group-not-data-[state=collapsed]/sidebar:translate-x-0", "transition-transform duration-(--sidebar-animation-duration)"),
|
|
753
|
+
children: [iconNode, /* @__PURE__ */ jsx("span", {
|
|
754
|
+
className: cn("flex min-w-0 flex-1 items-center gap-2 overflow-hidden text-left"),
|
|
755
|
+
children: React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ jsx("span", {
|
|
756
|
+
className: "truncate",
|
|
757
|
+
children: child
|
|
758
|
+
}) : child)
|
|
759
|
+
})]
|
|
760
|
+
});
|
|
761
|
+
const buttonClasses = cn("group/menu-button relative flex w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-lg outline-none", "before:absolute before:inset-x-0 before:-inset-y-px", size === "base" && "min-h-8.5 px-3 py-0 text-sm font-medium", size === "sm" && "min-h-7 px-2 py-0 text-sm", "text-kumo-default", "transition-[color,box-shadow,outline] duration-(--sidebar-animation-duration)", !active && "hover:bg-(--sidebar-active-bg)", active && "bg-(--sidebar-active-bg)", "has-[[data-active]]:bg-transparent has-[[data-active]]:hover:bg-(--sidebar-active-bg)", "focus:outline-hidden focus-visible:bg-(--sidebar-active-bg) focus-visible:text-kumo-strong", className);
|
|
762
|
+
let button;
|
|
763
|
+
const itemIdOnButton = isInsideMenuItem ? itemId : void 0;
|
|
764
|
+
if (href) button = /* @__PURE__ */ jsx(LinkComponent, {
|
|
765
|
+
ref: registerInteractive,
|
|
766
|
+
...props,
|
|
767
|
+
className: cn(buttonClasses, "no-underline!"),
|
|
768
|
+
href,
|
|
769
|
+
to: href,
|
|
770
|
+
target,
|
|
771
|
+
"data-active": active || void 0,
|
|
772
|
+
"data-sidebar": "menu-button",
|
|
773
|
+
"data-sidebar-item-id": itemIdOnButton,
|
|
774
|
+
"data-kumo-component": "Sidebar",
|
|
775
|
+
"data-kumo-part": "menu-button-link",
|
|
776
|
+
"data-size": size,
|
|
777
|
+
children: content
|
|
778
|
+
});
|
|
779
|
+
else button = /* @__PURE__ */ jsx("button", {
|
|
780
|
+
ref: registerInteractive,
|
|
781
|
+
type: "button",
|
|
782
|
+
className: buttonClasses,
|
|
783
|
+
"data-active": active || void 0,
|
|
784
|
+
"data-sidebar": "menu-button",
|
|
785
|
+
"data-sidebar-item-id": itemIdOnButton,
|
|
786
|
+
"data-kumo-component": "Sidebar",
|
|
787
|
+
"data-kumo-part": "menu-button",
|
|
788
|
+
"data-size": size,
|
|
789
|
+
...props,
|
|
790
|
+
children: content
|
|
791
|
+
});
|
|
792
|
+
const showTooltip = state === "collapsed" && !peekable;
|
|
793
|
+
if (tooltip) button = /* @__PURE__ */ jsx(Tooltip, {
|
|
794
|
+
content: tooltip,
|
|
795
|
+
disabled: !showTooltip,
|
|
796
|
+
side: "right",
|
|
797
|
+
render: button
|
|
798
|
+
});
|
|
799
|
+
if (!isInsideMenuItem) return /* @__PURE__ */ jsx("li", {
|
|
800
|
+
ref: registerAutoWrap,
|
|
801
|
+
"data-sidebar": "menu-item",
|
|
802
|
+
"data-sidebar-item-id": itemId,
|
|
803
|
+
className: "relative group-data-[state=collapsed]/sidebar:overflow-hidden",
|
|
804
|
+
children: button
|
|
805
|
+
});
|
|
806
|
+
return button;
|
|
807
|
+
});
|
|
808
|
+
SidebarMenuButton.displayName = "Sidebar.MenuButton";
|
|
809
|
+
/**
|
|
810
|
+
* Badge pill displayed inside a menu button (e.g., "Beta", "New").
|
|
811
|
+
* Uses dashed border styling matching the Cloudflare design system.
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```tsx
|
|
815
|
+
* <Sidebar.MenuSubButton>
|
|
816
|
+
* Containers
|
|
817
|
+
* <Sidebar.MenuBadge>Beta</Sidebar.MenuBadge>
|
|
818
|
+
* </Sidebar.MenuSubButton>
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
const SidebarMenuBadge = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("span", {
|
|
822
|
+
ref,
|
|
823
|
+
"data-sidebar": "menu-badge",
|
|
824
|
+
className: cn("inline-flex shrink-0 items-center rounded-full border border-dashed border-kumo-line", "px-1.5 py-0.5 text-[11px]/none font-medium text-kumo-strong select-none", "group-data-[state=collapsed]/sidebar:hidden", className),
|
|
825
|
+
...props
|
|
826
|
+
}));
|
|
827
|
+
SidebarMenuBadge.displayName = "Sidebar.MenuBadge";
|
|
828
|
+
/**
|
|
829
|
+
* Indented sub-menu container for child navigation items. Renders as `<ul>` with
|
|
830
|
+
* a left border accent for visual hierarchy.
|
|
831
|
+
*
|
|
832
|
+
* `MenuSubButton` auto-wraps in `<li>` so `MenuSubItem` is optional.
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```tsx
|
|
836
|
+
* <Sidebar.MenuSub>
|
|
837
|
+
* <Sidebar.MenuSubButton active>Workers & Pages</Sidebar.MenuSubButton>
|
|
838
|
+
* <Sidebar.MenuSubButton>Durable Objects</Sidebar.MenuSubButton>
|
|
839
|
+
* </Sidebar.MenuSub>
|
|
840
|
+
* ```
|
|
841
|
+
*/
|
|
842
|
+
const SidebarMenuSub = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs("ul", {
|
|
843
|
+
ref,
|
|
844
|
+
"data-sidebar": "menu-sub",
|
|
845
|
+
className: cn("relative m-0 flex min-w-0 list-none flex-col gap-y-px overflow-hidden p-0 pr-0 pl-7", className),
|
|
846
|
+
...props,
|
|
847
|
+
children: [/* @__PURE__ */ jsx("li", {
|
|
848
|
+
"aria-hidden": "true",
|
|
849
|
+
className: "pointer-events-none absolute inset-y-px left-[19px] z-10 block w-px bg-kumo-line"
|
|
850
|
+
}), children]
|
|
851
|
+
}));
|
|
852
|
+
SidebarMenuSub.displayName = "Sidebar.MenuSub";
|
|
853
|
+
/**
|
|
854
|
+
* Individual item inside a sub-menu. Renders as `<li>`.
|
|
855
|
+
*
|
|
856
|
+
* **Optional when using `MenuSubButton` directly** — `MenuSubButton` auto-wraps
|
|
857
|
+
* itself in a `<li>` when not already inside a `MenuSubItem`.
|
|
858
|
+
*/
|
|
859
|
+
const SidebarMenuSubItem = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(MenuSubItemContext.Provider, {
|
|
860
|
+
value: true,
|
|
861
|
+
children: /* @__PURE__ */ jsx("li", {
|
|
862
|
+
ref,
|
|
863
|
+
"data-sidebar": "menu-sub-item",
|
|
864
|
+
className: cn("relative", className),
|
|
865
|
+
...props,
|
|
866
|
+
children
|
|
867
|
+
})
|
|
868
|
+
}));
|
|
869
|
+
SidebarMenuSubItem.displayName = "Sidebar.MenuSubItem";
|
|
870
|
+
/**
|
|
871
|
+
* Button inside a sub-menu item. Does not render an icon (sub-items are
|
|
872
|
+
* indented instead). Supports active state and link rendering.
|
|
873
|
+
*
|
|
874
|
+
* **Auto-wraps in `<li>`** when not already inside a `Sidebar.MenuSubItem`.
|
|
875
|
+
*
|
|
876
|
+
* @example Simple usage (auto-wrapped in `<li>`)
|
|
877
|
+
* ```tsx
|
|
878
|
+
* <Sidebar.MenuSub>
|
|
879
|
+
* <Sidebar.MenuSubButton active>Workers & Pages</Sidebar.MenuSubButton>
|
|
880
|
+
* <Sidebar.MenuSubButton href="/observability">Observability</Sidebar.MenuSubButton>
|
|
881
|
+
* </Sidebar.MenuSub>
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
const SidebarMenuSubButton = forwardRef(({ className, active = false, href, target, children, ...props }, ref) => {
|
|
885
|
+
const LinkComponent = useLinkComponent();
|
|
886
|
+
const isInsideMenuSubItem = useContext(MenuSubItemContext);
|
|
887
|
+
const buttonClasses = cn("group/menu-button relative flex min-h-8.5 w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg px-3 py-0 text-sm font-medium outline-none", "before:absolute before:inset-x-0 before:-inset-y-px", "text-kumo-default transition-[color] duration-150", !active && "hover:bg-(--sidebar-active-bg)", active && "bg-(--sidebar-active-bg)", "focus:outline-hidden focus-visible:bg-(--sidebar-active-bg) focus-visible:text-kumo-strong", className);
|
|
888
|
+
const content = /* @__PURE__ */ jsx("span", {
|
|
889
|
+
className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden text-left",
|
|
890
|
+
children: React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ jsx("span", {
|
|
891
|
+
className: "truncate",
|
|
892
|
+
children: child
|
|
893
|
+
}) : child)
|
|
894
|
+
});
|
|
895
|
+
let button;
|
|
896
|
+
if (href) button = /* @__PURE__ */ jsx(LinkComponent, {
|
|
897
|
+
ref,
|
|
898
|
+
...props,
|
|
899
|
+
className: cn(buttonClasses, "no-underline!"),
|
|
900
|
+
href,
|
|
901
|
+
to: href,
|
|
902
|
+
target,
|
|
903
|
+
"data-active": active || void 0,
|
|
904
|
+
"data-sidebar": "menu-sub-button",
|
|
905
|
+
"data-kumo-component": "Sidebar",
|
|
906
|
+
"data-kumo-part": "menu-sub-button-link",
|
|
907
|
+
children: content
|
|
908
|
+
});
|
|
909
|
+
else button = /* @__PURE__ */ jsx("button", {
|
|
910
|
+
ref,
|
|
911
|
+
type: "button",
|
|
912
|
+
className: buttonClasses,
|
|
913
|
+
"data-active": active || void 0,
|
|
914
|
+
"data-sidebar": "menu-sub-button",
|
|
915
|
+
"data-kumo-component": "Sidebar",
|
|
916
|
+
"data-kumo-part": "menu-sub-button",
|
|
917
|
+
...props,
|
|
918
|
+
children: content
|
|
919
|
+
});
|
|
920
|
+
if (!isInsideMenuSubItem) return /* @__PURE__ */ jsx("li", {
|
|
921
|
+
"data-sidebar": "menu-sub-item",
|
|
922
|
+
className: "relative",
|
|
923
|
+
children: button
|
|
924
|
+
});
|
|
925
|
+
return button;
|
|
926
|
+
});
|
|
927
|
+
SidebarMenuSubButton.displayName = "Sidebar.MenuSubButton";
|
|
928
|
+
/**
|
|
929
|
+
* Horizontal divider line between sidebar sections.
|
|
930
|
+
*/
|
|
931
|
+
const SidebarSeparator = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
932
|
+
ref,
|
|
933
|
+
"data-sidebar": "separator",
|
|
934
|
+
className: cn("my-3 px-2", className),
|
|
935
|
+
...props,
|
|
936
|
+
children: /* @__PURE__ */ jsx("div", { className: "border-b border-kumo-line" })
|
|
937
|
+
}));
|
|
938
|
+
SidebarSeparator.displayName = "Sidebar.Separator";
|
|
939
|
+
/**
|
|
940
|
+
* Animated sidebar panel icon. The vertical divider line slides based
|
|
941
|
+
* on the sidebar's open/closed state.
|
|
942
|
+
*/
|
|
943
|
+
function SidebarPanelIcon({ className }) {
|
|
944
|
+
const { open } = useSidebar();
|
|
945
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
946
|
+
width: "18",
|
|
947
|
+
height: "18",
|
|
948
|
+
viewBox: "0 0 24 24",
|
|
949
|
+
fill: "none",
|
|
950
|
+
"aria-hidden": "true",
|
|
951
|
+
focusable: "false",
|
|
952
|
+
stroke: "currentColor",
|
|
953
|
+
strokeWidth: "1.5",
|
|
954
|
+
strokeLinecap: "round",
|
|
955
|
+
className: cn("shrink-0", className),
|
|
956
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M21.25 6.72v10.56a2.97 2.97 0 0 1-2.97 2.97H5.72a2.97 2.97 0 0 1-2.97-2.97V6.72a2.97 2.97 0 0 1 2.97-2.97h12.56a2.97 2.97 0 0 1 2.97 2.97" }), /* @__PURE__ */ jsx("path", {
|
|
957
|
+
d: "M6.25 7.25v9.5",
|
|
958
|
+
className: cn("transition-transform duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", open ? "translate-x-px" : "translate-x-[10.5px]")
|
|
959
|
+
})]
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
SidebarPanelIcon.displayName = "Sidebar.PanelIcon";
|
|
963
|
+
/**
|
|
964
|
+
* Button that toggles the sidebar open/collapsed. Uses `toggleSidebar()` from context.
|
|
965
|
+
* Defaults to an animated `SidebarPanelIcon`.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```tsx
|
|
969
|
+
* <Sidebar.Trigger />
|
|
970
|
+
* ```
|
|
971
|
+
*/
|
|
972
|
+
const SidebarTrigger = forwardRef(({ className, children, onClick, ...props }, ref) => {
|
|
973
|
+
const { open, toggleSidebar } = useSidebar();
|
|
974
|
+
return /* @__PURE__ */ jsx("button", {
|
|
975
|
+
ref,
|
|
976
|
+
type: "button",
|
|
977
|
+
"data-sidebar": "trigger",
|
|
978
|
+
"data-kumo-component": "Sidebar",
|
|
979
|
+
"data-kumo-part": "trigger",
|
|
980
|
+
"aria-expanded": open,
|
|
981
|
+
"aria-label": open ? "Collapse sidebar" : "Expand sidebar",
|
|
982
|
+
className: cn("flex size-8.5 shrink-0 cursor-pointer items-center justify-center rounded-lg", "text-kumo-subtle hover:bg-(--sidebar-active-bg) hover:text-kumo-default", "focus:outline-hidden focus-visible:ring-2 focus-visible:ring-kumo-brand focus-visible:ring-inset", className),
|
|
983
|
+
onClick: (e) => {
|
|
984
|
+
onClick?.(e);
|
|
985
|
+
toggleSidebar();
|
|
986
|
+
},
|
|
987
|
+
...props,
|
|
988
|
+
children: children ?? /* @__PURE__ */ jsx(SidebarPanelIcon, {})
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
SidebarTrigger.displayName = "Sidebar.Trigger";
|
|
992
|
+
/**
|
|
993
|
+
* Close button for the mobile sidebar sheet. Most useful inside
|
|
994
|
+
* `Sidebar.Header` when `fullScreenOnMobile` is true, where the backdrop is
|
|
995
|
+
* hidden and there is no adjacent page content to click.
|
|
996
|
+
*
|
|
997
|
+
* On desktop this is a no-op (the sidebar is not a sheet), so it can be
|
|
998
|
+
* rendered unconditionally without conditional checks.
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* ```tsx
|
|
1002
|
+
* <Sidebar.Header>
|
|
1003
|
+
* <span className="flex-1">Navigation</span>
|
|
1004
|
+
* <Sidebar.Close />
|
|
1005
|
+
* </Sidebar.Header>
|
|
1006
|
+
* ```
|
|
1007
|
+
*/
|
|
1008
|
+
const SidebarClose = forwardRef(({ className, onClick, ...props }, ref) => {
|
|
1009
|
+
const { setOpenMobile } = useSidebar();
|
|
1010
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1011
|
+
ref,
|
|
1012
|
+
variant: "ghost",
|
|
1013
|
+
shape: "square",
|
|
1014
|
+
size: "sm",
|
|
1015
|
+
"data-sidebar": "close",
|
|
1016
|
+
"data-kumo-component": "Sidebar",
|
|
1017
|
+
"data-kumo-part": "close",
|
|
1018
|
+
"aria-label": "Close navigation",
|
|
1019
|
+
className: cn("shrink-0", className),
|
|
1020
|
+
onClick: (e) => {
|
|
1021
|
+
onClick?.(e);
|
|
1022
|
+
setOpenMobile(false);
|
|
1023
|
+
},
|
|
1024
|
+
...props,
|
|
1025
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: 18 })
|
|
1026
|
+
});
|
|
1027
|
+
});
|
|
1028
|
+
SidebarClose.displayName = "Sidebar.Close";
|
|
1029
|
+
/**
|
|
1030
|
+
* Invisible interaction strip at the sidebar edge for click-to-toggle.
|
|
1031
|
+
* Renders a thin hover-sensitive area between the sidebar and main content.
|
|
1032
|
+
*/
|
|
1033
|
+
const SidebarRail = forwardRef(({ className, ...props }, ref) => {
|
|
1034
|
+
const { toggleSidebar } = useSidebar();
|
|
1035
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1036
|
+
ref,
|
|
1037
|
+
type: "button",
|
|
1038
|
+
"data-sidebar": "rail",
|
|
1039
|
+
"data-kumo-component": "Sidebar",
|
|
1040
|
+
"data-kumo-part": "rail",
|
|
1041
|
+
"aria-label": "Toggle sidebar",
|
|
1042
|
+
tabIndex: -1,
|
|
1043
|
+
className: cn("absolute inset-y-0 z-1 hidden w-4 -translate-x-1/2 cursor-pointer transition-all", "after:absolute after:inset-y-0 after:left-1/2 after:w-0.5", "hover:after:bg-kumo-brand/20", "group-data-[side=left]/sidebar-wrapper:right-0", "group-data-[side=right]/sidebar-wrapper:left-0", "sm:flex", className),
|
|
1044
|
+
onClick: toggleSidebar,
|
|
1045
|
+
...props
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
SidebarRail.displayName = "Sidebar.Rail";
|
|
1049
|
+
/**
|
|
1050
|
+
* Drag handle for resizing the sidebar. Renders when `resizable` is true in
|
|
1051
|
+
* both expanded and collapsed states.
|
|
1052
|
+
*
|
|
1053
|
+
* - **Expanded → drag inward past `minWidth`**: auto-collapses to icon-only.
|
|
1054
|
+
* - **Collapsed → drag outward past `minWidth`**: auto-expands and begins
|
|
1055
|
+
* tracking width from `minWidth`.
|
|
1056
|
+
*/
|
|
1057
|
+
const SidebarResizeHandle = forwardRef(({ className, ...props }, ref) => {
|
|
1058
|
+
const { side, resizable, setIsResizing, setWidth, setOpen, open, minWidth, width: currentWidth, maxWidth } = useSidebar();
|
|
1059
|
+
const startX = useRef(0);
|
|
1060
|
+
const startWidth = useRef(0);
|
|
1061
|
+
const wasCollapsed = useRef(false);
|
|
1062
|
+
if (!resizable) return null;
|
|
1063
|
+
const KEYBOARD_STEP = 10;
|
|
1064
|
+
const handlePointerDown = (e) => {
|
|
1065
|
+
e.preventDefault();
|
|
1066
|
+
setIsResizing(true);
|
|
1067
|
+
startX.current = e.clientX;
|
|
1068
|
+
wasCollapsed.current = !open;
|
|
1069
|
+
const sidebar = e.currentTarget.closest("[data-sidebar-wrapper]")?.querySelector("[data-sidebar='sidebar']");
|
|
1070
|
+
startWidth.current = sidebar?.getBoundingClientRect().width ?? 0;
|
|
1071
|
+
const cleanup = () => {
|
|
1072
|
+
setIsResizing(false);
|
|
1073
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
1074
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
1075
|
+
};
|
|
1076
|
+
const handlePointerMove = (moveEvent) => {
|
|
1077
|
+
const delta = side === "left" ? moveEvent.clientX - startX.current : startX.current - moveEvent.clientX;
|
|
1078
|
+
const rawWidth = startWidth.current + delta;
|
|
1079
|
+
if (wasCollapsed.current) {
|
|
1080
|
+
if (rawWidth >= minWidth) {
|
|
1081
|
+
wasCollapsed.current = false;
|
|
1082
|
+
setOpen(true);
|
|
1083
|
+
setWidth(rawWidth);
|
|
1084
|
+
}
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
if (rawWidth < minWidth) {
|
|
1088
|
+
setOpen(false);
|
|
1089
|
+
wasCollapsed.current = true;
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
setWidth(rawWidth);
|
|
1093
|
+
};
|
|
1094
|
+
const handlePointerUp = () => {
|
|
1095
|
+
cleanup();
|
|
1096
|
+
};
|
|
1097
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
1098
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
1099
|
+
};
|
|
1100
|
+
const handleKeyDown = (e) => {
|
|
1101
|
+
const grow = side === "left" ? "ArrowRight" : "ArrowLeft";
|
|
1102
|
+
const shrink = side === "left" ? "ArrowLeft" : "ArrowRight";
|
|
1103
|
+
if (e.key === grow) {
|
|
1104
|
+
e.preventDefault();
|
|
1105
|
+
if (!open) {
|
|
1106
|
+
setOpen(true);
|
|
1107
|
+
setWidth(minWidth);
|
|
1108
|
+
} else setWidth(Math.min(currentWidth + KEYBOARD_STEP, maxWidth));
|
|
1109
|
+
} else if (e.key === shrink) {
|
|
1110
|
+
e.preventDefault();
|
|
1111
|
+
const next = currentWidth - KEYBOARD_STEP;
|
|
1112
|
+
if (next < minWidth) setOpen(false);
|
|
1113
|
+
else setWidth(next);
|
|
1114
|
+
} else if (e.key === "Home") {
|
|
1115
|
+
e.preventDefault();
|
|
1116
|
+
setOpen(false);
|
|
1117
|
+
} else if (e.key === "End") {
|
|
1118
|
+
e.preventDefault();
|
|
1119
|
+
setOpen(true);
|
|
1120
|
+
setWidth(maxWidth);
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1124
|
+
ref,
|
|
1125
|
+
type: "button",
|
|
1126
|
+
"aria-label": "Resize sidebar",
|
|
1127
|
+
tabIndex: 0,
|
|
1128
|
+
"data-sidebar": "resize-handle",
|
|
1129
|
+
className: cn("absolute inset-y-0 z-2 hidden w-3 cursor-col-resize sm:block", "after:absolute after:inset-y-0 after:w-0.5", "after:bg-transparent after:transition-colors", "hover:after:bg-kumo-hairline focus-visible:after:bg-kumo-hairline active:after:bg-kumo-hairline", "focus:outline-hidden", side === "left" && "right-0 after:right-0", side === "right" && "left-0 after:left-0", className),
|
|
1130
|
+
onPointerDown: handlePointerDown,
|
|
1131
|
+
onKeyDown: handleKeyDown,
|
|
1132
|
+
...props
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
SidebarResizeHandle.displayName = "Sidebar.ResizeHandle";
|
|
1136
|
+
const isCollapsibleContentShown = (isOpen, { isMobile, openMobile, state }) => isOpen && (isMobile ? openMobile : state !== "collapsed");
|
|
1137
|
+
const SidebarCollapseContext = createContext({
|
|
1138
|
+
contentId: "",
|
|
1139
|
+
isOpen: true,
|
|
1140
|
+
isCollapsible: false,
|
|
1141
|
+
autoScrollOnOpen: false,
|
|
1142
|
+
toggle: () => {},
|
|
1143
|
+
completeOpenChange: () => {}
|
|
1144
|
+
});
|
|
1145
|
+
/**
|
|
1146
|
+
* Collapsible wrapper for sidebar sub-menu expand/collapse.
|
|
1147
|
+
* Manages open/close state and provides context to Trigger and Content children.
|
|
1148
|
+
*
|
|
1149
|
+
* Keyboard behaviour: when a child receives keyboard focus (`focus-visible`)
|
|
1150
|
+
* while collapsed, the section auto-expands. It collapses again on blur
|
|
1151
|
+
* unless it was explicitly opened via click or a child has `data-active`.
|
|
1152
|
+
*
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```tsx
|
|
1155
|
+
* <Sidebar.MenuItem>
|
|
1156
|
+
* <Sidebar.Collapsible defaultOpen>
|
|
1157
|
+
* <Sidebar.CollapsibleTrigger
|
|
1158
|
+
* render={<Sidebar.MenuButton icon={CodeIcon}>Compute<Sidebar.MenuChevron /></Sidebar.MenuButton>}
|
|
1159
|
+
* />
|
|
1160
|
+
* <Sidebar.CollapsibleContent>
|
|
1161
|
+
* <Sidebar.MenuSub>...</Sidebar.MenuSub>
|
|
1162
|
+
* </Sidebar.CollapsibleContent>
|
|
1163
|
+
* </Sidebar.Collapsible>
|
|
1164
|
+
* </Sidebar.MenuItem>
|
|
1165
|
+
* ```
|
|
1166
|
+
*/
|
|
1167
|
+
const SidebarCollapsible = forwardRef(({ defaultOpen = false, open: openProp, onOpenChange, onOpenChangeComplete, autoScrollOnOpen = false, className, children, ...props }, ref) => {
|
|
1168
|
+
const sidebar = useSidebar();
|
|
1169
|
+
const { animationDuration } = sidebar;
|
|
1170
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
1171
|
+
const isOpen = openProp ?? internalOpen;
|
|
1172
|
+
const isContentShown = isCollapsibleContentShown(isOpen, sidebar);
|
|
1173
|
+
const contentId = useId();
|
|
1174
|
+
const keyboardExpandedRef = useRef(false);
|
|
1175
|
+
const toggle = useCallback(() => {
|
|
1176
|
+
const next = !isOpen;
|
|
1177
|
+
setInternalOpen(next);
|
|
1178
|
+
onOpenChange?.(next);
|
|
1179
|
+
keyboardExpandedRef.current = false;
|
|
1180
|
+
}, [isOpen, onOpenChange]);
|
|
1181
|
+
const completeOpenChange = useOpenChangeComplete(isContentShown, animationDuration, onOpenChangeComplete);
|
|
1182
|
+
const contextValue = useMemo(() => ({
|
|
1183
|
+
contentId,
|
|
1184
|
+
isOpen,
|
|
1185
|
+
isCollapsible: true,
|
|
1186
|
+
autoScrollOnOpen,
|
|
1187
|
+
toggle,
|
|
1188
|
+
completeOpenChange
|
|
1189
|
+
}), [
|
|
1190
|
+
contentId,
|
|
1191
|
+
isOpen,
|
|
1192
|
+
autoScrollOnOpen,
|
|
1193
|
+
toggle,
|
|
1194
|
+
completeOpenChange
|
|
1195
|
+
]);
|
|
1196
|
+
const handleFocusIn = useCallback((e) => {
|
|
1197
|
+
if (!isOpen && e.target.matches(":focus-visible")) {
|
|
1198
|
+
keyboardExpandedRef.current = true;
|
|
1199
|
+
setInternalOpen(true);
|
|
1200
|
+
onOpenChange?.(true);
|
|
1201
|
+
}
|
|
1202
|
+
}, [isOpen, onOpenChange]);
|
|
1203
|
+
const handleFocusOut = useCallback((e) => {
|
|
1204
|
+
if (keyboardExpandedRef.current && !e.currentTarget.contains(e.relatedTarget) && !e.currentTarget.querySelector("[data-active]")) {
|
|
1205
|
+
keyboardExpandedRef.current = false;
|
|
1206
|
+
setInternalOpen(false);
|
|
1207
|
+
onOpenChange?.(false);
|
|
1208
|
+
}
|
|
1209
|
+
}, [onOpenChange]);
|
|
1210
|
+
return /* @__PURE__ */ jsx(SidebarCollapseContext.Provider, {
|
|
1211
|
+
value: contextValue,
|
|
1212
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1213
|
+
ref,
|
|
1214
|
+
"data-open": isOpen || void 0,
|
|
1215
|
+
className: cn("min-w-0", className),
|
|
1216
|
+
onFocus: handleFocusIn,
|
|
1217
|
+
onBlur: handleFocusOut,
|
|
1218
|
+
...props,
|
|
1219
|
+
children
|
|
1220
|
+
})
|
|
1221
|
+
});
|
|
1222
|
+
});
|
|
1223
|
+
SidebarCollapsible.displayName = "Sidebar.Collapsible";
|
|
1224
|
+
/**
|
|
1225
|
+
* Trigger for a sidebar collapsible section. Uses `render` prop to compose
|
|
1226
|
+
* with `Sidebar.MenuButton` or `Sidebar.MenuSubButton`.
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
* ```tsx
|
|
1230
|
+
* <Sidebar.CollapsibleTrigger
|
|
1231
|
+
* render={
|
|
1232
|
+
* <Sidebar.MenuButton icon={CodeIcon}>
|
|
1233
|
+
* Compute
|
|
1234
|
+
* <Sidebar.MenuChevron />
|
|
1235
|
+
* </Sidebar.MenuButton>
|
|
1236
|
+
* }
|
|
1237
|
+
* />
|
|
1238
|
+
* ```
|
|
1239
|
+
*/
|
|
1240
|
+
function SidebarCollapsibleTrigger({ render }) {
|
|
1241
|
+
const { contentId, isOpen, toggle } = useContext(SidebarCollapseContext);
|
|
1242
|
+
return React.cloneElement(render, {
|
|
1243
|
+
"aria-expanded": isOpen,
|
|
1244
|
+
"aria-controls": contentId,
|
|
1245
|
+
"data-open": isOpen || void 0,
|
|
1246
|
+
onClick: (e) => {
|
|
1247
|
+
const existingOnClick = render.props.onClick;
|
|
1248
|
+
existingOnClick?.(e);
|
|
1249
|
+
toggle();
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
SidebarCollapsibleTrigger.displayName = "Sidebar.CollapsibleTrigger";
|
|
1254
|
+
/**
|
|
1255
|
+
* Animated collapsible content panel. Uses CSS grid-rows for smooth
|
|
1256
|
+
* height transitions without measuring DOM height.
|
|
1257
|
+
*
|
|
1258
|
+
* Always mounted (no unmount on close) so exit animations play.
|
|
1259
|
+
*/
|
|
1260
|
+
const SidebarCollapsibleContent = forwardRef(({ className, children, onTransitionEnd, ...props }, ref) => {
|
|
1261
|
+
const { contentId, isOpen: isCollapsibleOpen, autoScrollOnOpen, completeOpenChange } = useContext(SidebarCollapseContext);
|
|
1262
|
+
const sidebar = useSidebar();
|
|
1263
|
+
const { animationDuration } = sidebar;
|
|
1264
|
+
const contentRef = useRef(null);
|
|
1265
|
+
const isContentShown = isCollapsibleContentShown(isCollapsibleOpen, sidebar);
|
|
1266
|
+
const scrollPendingRef = useRef(false);
|
|
1267
|
+
const wasCollapsibleOpenRef = useRef(isCollapsibleOpen);
|
|
1268
|
+
useEffect(() => {
|
|
1269
|
+
if (isCollapsibleOpen && !wasCollapsibleOpenRef.current) scrollPendingRef.current = true;
|
|
1270
|
+
else if (!isCollapsibleOpen) scrollPendingRef.current = false;
|
|
1271
|
+
wasCollapsibleOpenRef.current = isCollapsibleOpen;
|
|
1272
|
+
}, [isCollapsibleOpen]);
|
|
1273
|
+
useEffect(() => {
|
|
1274
|
+
if (!isContentShown || !autoScrollOnOpen || !scrollPendingRef.current) return;
|
|
1275
|
+
const timeout = window.setTimeout(() => {
|
|
1276
|
+
scrollPendingRef.current = false;
|
|
1277
|
+
if (contentRef.current) scrollWithinViewport(contentRef.current, { behavior: "smooth" });
|
|
1278
|
+
}, animationDuration);
|
|
1279
|
+
return () => window.clearTimeout(timeout);
|
|
1280
|
+
}, [
|
|
1281
|
+
isCollapsibleOpen,
|
|
1282
|
+
isContentShown,
|
|
1283
|
+
autoScrollOnOpen,
|
|
1284
|
+
animationDuration
|
|
1285
|
+
]);
|
|
1286
|
+
const inertRef = useCallback((node) => {
|
|
1287
|
+
if (node) {
|
|
1288
|
+
if (!isContentShown) node.setAttribute("inert", "");
|
|
1289
|
+
else node.removeAttribute("inert");
|
|
1290
|
+
}
|
|
1291
|
+
}, [isContentShown]);
|
|
1292
|
+
const mergedRef = useCallback((node) => {
|
|
1293
|
+
contentRef.current = node;
|
|
1294
|
+
inertRef(node);
|
|
1295
|
+
if (typeof ref === "function") ref(node);
|
|
1296
|
+
else if (ref) ref.current = node;
|
|
1297
|
+
}, [ref, inertRef]);
|
|
1298
|
+
const handleOpenTransitionEnd = useCallback((event) => {
|
|
1299
|
+
onTransitionEnd?.(event);
|
|
1300
|
+
if (event.target === event.currentTarget && event.propertyName === "grid-template-rows") completeOpenChange();
|
|
1301
|
+
}, [completeOpenChange, onTransitionEnd]);
|
|
1302
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1303
|
+
ref: mergedRef,
|
|
1304
|
+
id: contentId,
|
|
1305
|
+
role: "region",
|
|
1306
|
+
"aria-hidden": !isContentShown,
|
|
1307
|
+
onTransitionEnd: handleOpenTransitionEnd,
|
|
1308
|
+
className: cn("grid", "transition-[grid-template-rows] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)", "motion-reduce:transition-none", isContentShown ? "grid-rows-[1fr]" : "grid-rows-[0fr]", className),
|
|
1309
|
+
...props,
|
|
1310
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1311
|
+
className: "overflow-hidden",
|
|
1312
|
+
children
|
|
1313
|
+
})
|
|
1314
|
+
});
|
|
1315
|
+
});
|
|
1316
|
+
SidebarCollapsibleContent.displayName = "Sidebar.CollapsibleContent";
|
|
1317
|
+
/**
|
|
1318
|
+
* Auto-rotating chevron for collapsible menu items. Reads open state from
|
|
1319
|
+
* the nearest `SidebarCollapseContext` and rotates accordingly.
|
|
1320
|
+
*
|
|
1321
|
+
* @example
|
|
1322
|
+
* ```tsx
|
|
1323
|
+
* <Sidebar.CollapsibleTrigger
|
|
1324
|
+
* render={<Sidebar.MenuButton icon={CodeIcon}>Compute<Sidebar.MenuChevron /></Sidebar.MenuButton>}
|
|
1325
|
+
* />
|
|
1326
|
+
* ```
|
|
1327
|
+
*/
|
|
1328
|
+
function SidebarMenuChevron({ className }) {
|
|
1329
|
+
const { isOpen, isCollapsible } = useContext(SidebarCollapseContext);
|
|
1330
|
+
return /* @__PURE__ */ jsx(CaretRightIcon, {
|
|
1331
|
+
size: 12,
|
|
1332
|
+
weight: "bold",
|
|
1333
|
+
className: cn("ml-auto shrink-0 opacity-40 transition-[transform,rotate,opacity] duration-200 group-hover/menu-button:opacity-100", isCollapsible && isOpen && "rotate-90", "group-data-[state=collapsed]/sidebar:hidden", className)
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
SidebarMenuChevron.displayName = "Sidebar.MenuChevron";
|
|
1337
|
+
const SlidingViewActiveContext = createContext("");
|
|
1338
|
+
/**
|
|
1339
|
+
* Container for animated horizontal transitions between navigation surfaces
|
|
1340
|
+
* (e.g., account ↔ zone). Inactive views are marked `aria-hidden` and `inert`.
|
|
1341
|
+
*
|
|
1342
|
+
* Animation respects `prefers-reduced-motion`.
|
|
1343
|
+
*
|
|
1344
|
+
* @example
|
|
1345
|
+
* ```tsx
|
|
1346
|
+
* <Sidebar.SlidingViews activeKey={surface} direction="left">
|
|
1347
|
+
* <Sidebar.SlidingView value="account">
|
|
1348
|
+
* <Sidebar.Content>...account nav...</Sidebar.Content>
|
|
1349
|
+
* </Sidebar.SlidingView>
|
|
1350
|
+
* <Sidebar.SlidingView value="zone">
|
|
1351
|
+
* <Sidebar.Content>...zone nav...</Sidebar.Content>
|
|
1352
|
+
* </Sidebar.SlidingView>
|
|
1353
|
+
* </Sidebar.SlidingViews>
|
|
1354
|
+
* ```
|
|
1355
|
+
*/
|
|
1356
|
+
const SidebarSlidingViews = forwardRef(({ activeKey, direction: _direction = "left", className, children, ...props }, ref) => {
|
|
1357
|
+
const activeIndex = React.Children.toArray(children).findIndex((child) => React.isValidElement(child) && child.props.value === activeKey);
|
|
1358
|
+
const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1359
|
+
const translateX = activeIndex > 0 ? `-${activeIndex * 100}%` : "0%";
|
|
1360
|
+
return /* @__PURE__ */ jsx(SlidingViewActiveContext.Provider, {
|
|
1361
|
+
value: activeKey,
|
|
1362
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1363
|
+
ref,
|
|
1364
|
+
"data-sidebar": "sliding-views",
|
|
1365
|
+
className: cn("flex min-h-0 max-w-(--sidebar-width) flex-1 overflow-hidden", className),
|
|
1366
|
+
...props,
|
|
1367
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1368
|
+
className: "flex min-h-0 w-full shrink-0",
|
|
1369
|
+
style: {
|
|
1370
|
+
transform: `translateX(${translateX})`,
|
|
1371
|
+
transition: prefersReducedMotion ? "none" : `transform var(--sidebar-animation-duration) var(--sidebar-easing)`
|
|
1372
|
+
},
|
|
1373
|
+
children
|
|
1374
|
+
})
|
|
1375
|
+
})
|
|
1376
|
+
});
|
|
1377
|
+
});
|
|
1378
|
+
SidebarSlidingViews.displayName = "Sidebar.SlidingViews";
|
|
1379
|
+
/**
|
|
1380
|
+
* Individual panel inside `SlidingViews`. Inactive views are automatically
|
|
1381
|
+
* marked `aria-hidden` and `inert` so they're unreachable by keyboard/screen readers.
|
|
1382
|
+
*/
|
|
1383
|
+
const SidebarSlidingView = forwardRef(({ value, className, children, ...props }, ref) => {
|
|
1384
|
+
const isActive = useContext(SlidingViewActiveContext) === value;
|
|
1385
|
+
const inertRef = useCallback((node) => {
|
|
1386
|
+
if (node) {
|
|
1387
|
+
if (!isActive) node.setAttribute("inert", "");
|
|
1388
|
+
else node.removeAttribute("inert");
|
|
1389
|
+
}
|
|
1390
|
+
}, [isActive]);
|
|
1391
|
+
const mergedRef = useCallback((node) => {
|
|
1392
|
+
inertRef(node);
|
|
1393
|
+
if (typeof ref === "function") ref(node);
|
|
1394
|
+
else if (ref) ref.current = node;
|
|
1395
|
+
}, [ref, inertRef]);
|
|
1396
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1397
|
+
ref: mergedRef,
|
|
1398
|
+
"data-sidebar": "sliding-view",
|
|
1399
|
+
"data-value": value,
|
|
1400
|
+
"aria-hidden": !isActive,
|
|
1401
|
+
className: cn("flex min-h-0 w-full shrink-0 flex-col", !isActive && "pointer-events-none", className),
|
|
1402
|
+
...props,
|
|
1403
|
+
children
|
|
1404
|
+
});
|
|
1405
|
+
});
|
|
1406
|
+
SidebarSlidingView.displayName = "Sidebar.SlidingView";
|
|
1407
|
+
/**
|
|
1408
|
+
* Sidebar — responsive navigation panel with expand/collapse support.
|
|
1409
|
+
*
|
|
1410
|
+
* Compound component: `Sidebar` (root `<aside>`), `.Provider`, `.Header`,
|
|
1411
|
+
* `.Content`, `.Footer`, `.Loading`, `.Group`, `.GroupLabel`,
|
|
1412
|
+
* `.Menu`, `.MenuItem`, `.MenuButton`, `.MenuBadge`,
|
|
1413
|
+
* `.MenuSub`, `.MenuSubItem`, `.MenuSubButton`, `.Separator`,
|
|
1414
|
+
* `.Trigger`, `.Close`, `.Rail`, `.ResizeHandle`, `.MenuChevron`,
|
|
1415
|
+
* `.Collapsible`, `.CollapsibleTrigger`, `.CollapsibleContent`,
|
|
1416
|
+
* `.SlidingViews`, `.SlidingView`.
|
|
1417
|
+
*
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```tsx
|
|
1420
|
+
* <Sidebar.Provider defaultOpen>
|
|
1421
|
+
* <Sidebar>
|
|
1422
|
+
* <Sidebar.Content>
|
|
1423
|
+
* <Sidebar.Group>
|
|
1424
|
+
* <Sidebar.GroupLabel>Overview</Sidebar.GroupLabel>
|
|
1425
|
+
* <Sidebar.Menu>
|
|
1426
|
+
* <Sidebar.MenuButton icon={HouseIcon} active>Home</Sidebar.MenuButton>
|
|
1427
|
+
* <Sidebar.MenuButton icon={GlobeIcon}>Domains</Sidebar.MenuButton>
|
|
1428
|
+
* </Sidebar.Menu>
|
|
1429
|
+
* </Sidebar.Group>
|
|
1430
|
+
* </Sidebar.Content>
|
|
1431
|
+
* <Sidebar.Footer>
|
|
1432
|
+
* <Sidebar.Trigger />
|
|
1433
|
+
* </Sidebar.Footer>
|
|
1434
|
+
* </Sidebar>
|
|
1435
|
+
* </Sidebar.Provider>
|
|
1436
|
+
* ```
|
|
1437
|
+
*/
|
|
1438
|
+
const Sidebar = Object.assign(SidebarRoot, {
|
|
1439
|
+
Provider: SidebarProvider,
|
|
1440
|
+
Header: SidebarHeader,
|
|
1441
|
+
Content: SidebarContent,
|
|
1442
|
+
Footer: SidebarFooter,
|
|
1443
|
+
Loading: SidebarLoading,
|
|
1444
|
+
Group: SidebarGroup,
|
|
1445
|
+
GroupLabel: SidebarGroupLabel,
|
|
1446
|
+
Menu: SidebarMenu,
|
|
1447
|
+
MenuItem: SidebarMenuItem,
|
|
1448
|
+
MenuButton: SidebarMenuButton,
|
|
1449
|
+
MenuBadge: SidebarMenuBadge,
|
|
1450
|
+
MenuSub: SidebarMenuSub,
|
|
1451
|
+
MenuSubItem: SidebarMenuSubItem,
|
|
1452
|
+
MenuSubButton: SidebarMenuSubButton,
|
|
1453
|
+
Separator: SidebarSeparator,
|
|
1454
|
+
Trigger: SidebarTrigger,
|
|
1455
|
+
Close: SidebarClose,
|
|
1456
|
+
Rail: SidebarRail,
|
|
1457
|
+
ResizeHandle: SidebarResizeHandle,
|
|
1458
|
+
MenuChevron: SidebarMenuChevron,
|
|
1459
|
+
Collapsible: SidebarCollapsible,
|
|
1460
|
+
CollapsibleTrigger: SidebarCollapsibleTrigger,
|
|
1461
|
+
CollapsibleContent: SidebarCollapsibleContent,
|
|
1462
|
+
SlidingViews: SidebarSlidingViews,
|
|
1463
|
+
SlidingView: SidebarSlidingView
|
|
1464
|
+
});
|
|
1465
|
+
//#endregion
|
|
1466
|
+
export { useSidebar as A, SidebarRail as C, SidebarSlidingView as D, SidebarSeparator as E, SidebarSlidingViews as O, SidebarProvider as S, SidebarRoot as T, SidebarMenuChevron as _, SidebarCollapsible as a, SidebarMenuSubButton as b, SidebarContent as c, SidebarGroupLabel as d, SidebarHeader as f, SidebarMenuButton as g, SidebarMenuBadge as h, Sidebar as i, SidebarTrigger as k, SidebarFooter as l, SidebarMenu as m, KUMO_SIDEBAR_STYLING as n, SidebarCollapsibleContent as o, SidebarLoading as p, KUMO_SIDEBAR_VARIANTS as r, SidebarCollapsibleTrigger as s, KUMO_SIDEBAR_DEFAULT_VARIANTS as t, SidebarGroup as u, SidebarMenuItem as v, SidebarResizeHandle as w, SidebarMenuSubItem as x, SidebarMenuSub as y };
|