@42-central/ui-react 0.20.0 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-P276SCCV.js → chunk-2BNIHOMT.js} +6 -6
- package/dist/{chunk-P276SCCV.js.map → chunk-2BNIHOMT.js.map} +1 -1
- package/dist/{chunk-PAFS7TED.js → chunk-2HIX6DKN.js} +3 -3
- package/dist/{chunk-PAFS7TED.js.map → chunk-2HIX6DKN.js.map} +1 -1
- package/dist/{chunk-Z5WYYDG2.js → chunk-2MXWEIMD.js} +7 -4
- package/dist/chunk-2MXWEIMD.js.map +1 -0
- package/dist/{chunk-VVM7JMZS.js → chunk-37VQGKD6.js} +8 -8
- package/dist/{chunk-VVM7JMZS.js.map → chunk-37VQGKD6.js.map} +1 -1
- package/dist/{chunk-7R4CDHBK.js → chunk-45QRQKRC.js} +4 -4
- package/dist/{chunk-7R4CDHBK.js.map → chunk-45QRQKRC.js.map} +1 -1
- package/dist/{chunk-FZNPJAGJ.js → chunk-45TG7H5Q.js} +5 -5
- package/dist/{chunk-FZNPJAGJ.js.map → chunk-45TG7H5Q.js.map} +1 -1
- package/dist/{chunk-MKJKCBRE.js → chunk-47LEAR6G.js} +6 -6
- package/dist/{chunk-MKJKCBRE.js.map → chunk-47LEAR6G.js.map} +1 -1
- package/dist/chunk-4ASNIDV7.js +17 -0
- package/dist/chunk-4ASNIDV7.js.map +1 -0
- package/dist/{chunk-WFHY6NRQ.js → chunk-5CNVVA7I.js} +11 -11
- package/dist/{chunk-WFHY6NRQ.js.map → chunk-5CNVVA7I.js.map} +1 -1
- package/dist/{chunk-2TM7UVM2.js → chunk-6M6YZ3PQ.js} +4 -4
- package/dist/{chunk-2TM7UVM2.js.map → chunk-6M6YZ3PQ.js.map} +1 -1
- package/dist/{chunk-4BGU2UQB.js → chunk-6VYGK3Q3.js} +6 -6
- package/dist/{chunk-4BGU2UQB.js.map → chunk-6VYGK3Q3.js.map} +1 -1
- package/dist/{chunk-ZFUTGBJC.js → chunk-6YNLRQ25.js} +3 -3
- package/dist/{chunk-ZFUTGBJC.js.map → chunk-6YNLRQ25.js.map} +1 -1
- package/dist/{chunk-6OV6EJQ2.js → chunk-7AQ4MN4M.js} +6 -6
- package/dist/{chunk-6OV6EJQ2.js.map → chunk-7AQ4MN4M.js.map} +1 -1
- package/dist/{chunk-5337N3FE.js → chunk-7BOSX65U.js} +3 -3
- package/dist/{chunk-5337N3FE.js.map → chunk-7BOSX65U.js.map} +1 -1
- package/dist/{chunk-THLMW5IU.js → chunk-7CNDZZZ6.js} +4 -4
- package/dist/{chunk-THLMW5IU.js.map → chunk-7CNDZZZ6.js.map} +1 -1
- package/dist/{chunk-LJ3GHC4V.js → chunk-BE2LWUHY.js} +5 -5
- package/dist/{chunk-LJ3GHC4V.js.map → chunk-BE2LWUHY.js.map} +1 -1
- package/dist/{chunk-2KN3MI7I.js → chunk-C4NFRSOR.js} +4 -4
- package/dist/{chunk-2KN3MI7I.js.map → chunk-C4NFRSOR.js.map} +1 -1
- package/dist/{chunk-3REFDGOM.js → chunk-C6NVU4F7.js} +3 -3
- package/dist/{chunk-3REFDGOM.js.map → chunk-C6NVU4F7.js.map} +1 -1
- package/dist/{chunk-LSIX2PVU.js → chunk-C74TV64U.js} +7 -7
- package/dist/{chunk-LSIX2PVU.js.map → chunk-C74TV64U.js.map} +1 -1
- package/dist/{chunk-HVOEVB4E.js → chunk-D2QIPQ74.js} +3 -3
- package/dist/{chunk-HVOEVB4E.js.map → chunk-D2QIPQ74.js.map} +1 -1
- package/dist/{chunk-4EU6FGGB.js → chunk-DA4QII2N.js} +4 -4
- package/dist/{chunk-4EU6FGGB.js.map → chunk-DA4QII2N.js.map} +1 -1
- package/dist/{chunk-LZWA7V62.js → chunk-DJLNGWMM.js} +5 -5
- package/dist/{chunk-LZWA7V62.js.map → chunk-DJLNGWMM.js.map} +1 -1
- package/dist/{chunk-HEQ2H6VO.js → chunk-DT6LKNZF.js} +4 -4
- package/dist/{chunk-HEQ2H6VO.js.map → chunk-DT6LKNZF.js.map} +1 -1
- package/dist/{chunk-BUFALAEK.js → chunk-E5H3YWZV.js} +4 -4
- package/dist/{chunk-BUFALAEK.js.map → chunk-E5H3YWZV.js.map} +1 -1
- package/dist/{chunk-H7INUXZD.js → chunk-F342ZT7O.js} +4 -4
- package/dist/{chunk-H7INUXZD.js.map → chunk-F342ZT7O.js.map} +1 -1
- package/dist/{chunk-KOT4PWGE.js → chunk-FDCPMUJK.js} +6 -6
- package/dist/{chunk-KOT4PWGE.js.map → chunk-FDCPMUJK.js.map} +1 -1
- package/dist/{chunk-VALQ2XVA.js → chunk-H3PYSAWN.js} +3 -3
- package/dist/{chunk-VALQ2XVA.js.map → chunk-H3PYSAWN.js.map} +1 -1
- package/dist/{chunk-WR444JRU.js → chunk-HQPU73WV.js} +7 -7
- package/dist/{chunk-WR444JRU.js.map → chunk-HQPU73WV.js.map} +1 -1
- package/dist/{chunk-Q5ZO2O25.js → chunk-HRNWWL3Y.js} +6 -6
- package/dist/{chunk-Q5ZO2O25.js.map → chunk-HRNWWL3Y.js.map} +1 -1
- package/dist/{chunk-HBFN5W7Q.js → chunk-JVG5ISPT.js} +4 -4
- package/dist/{chunk-HBFN5W7Q.js.map → chunk-JVG5ISPT.js.map} +1 -1
- package/dist/{chunk-JL4QMM46.js → chunk-LFQDB5OD.js} +5 -5
- package/dist/{chunk-JL4QMM46.js.map → chunk-LFQDB5OD.js.map} +1 -1
- package/dist/{chunk-U2PNMMDB.js → chunk-LKFHUDEW.js} +7 -7
- package/dist/{chunk-U2PNMMDB.js.map → chunk-LKFHUDEW.js.map} +1 -1
- package/dist/{chunk-2SVX3MQQ.js → chunk-MW42XVPD.js} +3 -3
- package/dist/{chunk-2SVX3MQQ.js.map → chunk-MW42XVPD.js.map} +1 -1
- package/dist/{chunk-S4TRYMCU.js → chunk-MXAACRWE.js} +6 -6
- package/dist/{chunk-S4TRYMCU.js.map → chunk-MXAACRWE.js.map} +1 -1
- package/dist/{chunk-ZN3WYGIQ.js → chunk-N66NC6QK.js} +121 -25
- package/dist/chunk-N66NC6QK.js.map +1 -0
- package/dist/{chunk-DUPE2CRU.js → chunk-NKOTA5TM.js} +3 -3
- package/dist/{chunk-DUPE2CRU.js.map → chunk-NKOTA5TM.js.map} +1 -1
- package/dist/{chunk-RGLNH7A5.js → chunk-NLOBBJAA.js} +3 -3
- package/dist/{chunk-RGLNH7A5.js.map → chunk-NLOBBJAA.js.map} +1 -1
- package/dist/{chunk-FXDLS23K.js → chunk-NS6RGPWR.js} +3 -3
- package/dist/{chunk-FXDLS23K.js.map → chunk-NS6RGPWR.js.map} +1 -1
- package/dist/{chunk-ZWOZL4XX.js → chunk-O5W3QWJ6.js} +5 -5
- package/dist/{chunk-ZWOZL4XX.js.map → chunk-O5W3QWJ6.js.map} +1 -1
- package/dist/{chunk-PD4FX34E.js → chunk-O7LS6OZR.js} +4 -4
- package/dist/{chunk-PD4FX34E.js.map → chunk-O7LS6OZR.js.map} +1 -1
- package/dist/{chunk-K6BHDFX3.js → chunk-QKSLDQM2.js} +3 -3
- package/dist/{chunk-K6BHDFX3.js.map → chunk-QKSLDQM2.js.map} +1 -1
- package/dist/{chunk-CDHIF2NV.js → chunk-QNKD2SQM.js} +8 -8
- package/dist/{chunk-CDHIF2NV.js.map → chunk-QNKD2SQM.js.map} +1 -1
- package/dist/{chunk-SE3CGQRO.js → chunk-RLOWPCGG.js} +3 -3
- package/dist/{chunk-SE3CGQRO.js.map → chunk-RLOWPCGG.js.map} +1 -1
- package/dist/{chunk-R57QP43T.js → chunk-SVKN5ZHX.js} +4 -4
- package/dist/{chunk-R57QP43T.js.map → chunk-SVKN5ZHX.js.map} +1 -1
- package/dist/{chunk-NJ4RO3CT.js → chunk-SWVUXEBT.js} +5 -5
- package/dist/{chunk-NJ4RO3CT.js.map → chunk-SWVUXEBT.js.map} +1 -1
- package/dist/{chunk-GGT4GJD6.js → chunk-TWNIAF7K.js} +3 -3
- package/dist/{chunk-GGT4GJD6.js.map → chunk-TWNIAF7K.js.map} +1 -1
- package/dist/{chunk-4TCTMRR5.js → chunk-UAYENYS2.js} +5 -5
- package/dist/{chunk-4TCTMRR5.js.map → chunk-UAYENYS2.js.map} +1 -1
- package/dist/{chunk-DHTSVJ4G.js → chunk-UCCJUFOG.js} +9 -9
- package/dist/{chunk-DHTSVJ4G.js.map → chunk-UCCJUFOG.js.map} +1 -1
- package/dist/{chunk-HDRC6ITF.js → chunk-UT3TOV2Q.js} +3 -3
- package/dist/{chunk-HDRC6ITF.js.map → chunk-UT3TOV2Q.js.map} +1 -1
- package/dist/{chunk-6KER77RS.js → chunk-UVQXRDRO.js} +7 -7
- package/dist/{chunk-6KER77RS.js.map → chunk-UVQXRDRO.js.map} +1 -1
- package/dist/{chunk-R52P43LZ.js → chunk-UXPINIDN.js} +3 -3
- package/dist/{chunk-R52P43LZ.js.map → chunk-UXPINIDN.js.map} +1 -1
- package/dist/chunk-V6PY7C6S.js +18 -0
- package/dist/chunk-V6PY7C6S.js.map +1 -0
- package/dist/{chunk-45DFYIK5.js → chunk-VD6PB3VA.js} +3 -3
- package/dist/{chunk-45DFYIK5.js.map → chunk-VD6PB3VA.js.map} +1 -1
- package/dist/{chunk-7AWOMWCQ.js → chunk-WXL5RP6P.js} +7 -7
- package/dist/{chunk-7AWOMWCQ.js.map → chunk-WXL5RP6P.js.map} +1 -1
- package/dist/{chunk-IMP5VHEN.js → chunk-XKDL4QS6.js} +3 -3
- package/dist/{chunk-IMP5VHEN.js.map → chunk-XKDL4QS6.js.map} +1 -1
- package/dist/{chunk-H26K66EU.js → chunk-Y57NW6G7.js} +3 -3
- package/dist/{chunk-H26K66EU.js.map → chunk-Y57NW6G7.js.map} +1 -1
- package/dist/{chunk-2OQP7UY4.js → chunk-YZJUPYPO.js} +5 -5
- package/dist/{chunk-2OQP7UY4.js.map → chunk-YZJUPYPO.js.map} +1 -1
- package/dist/{chunk-JYK6JVR3.js → chunk-Z4MBCKG5.js} +8 -8
- package/dist/{chunk-JYK6JVR3.js.map → chunk-Z4MBCKG5.js.map} +1 -1
- package/dist/components/accordion/index.js +5 -5
- package/dist/components/action-icon/index.js +4 -4
- package/dist/components/alert/index.js +6 -6
- package/dist/components/ambient-background/index.js +1 -1
- package/dist/components/app-shell/index.js +6 -6
- package/dist/components/aspect-ratio/index.js +1 -1
- package/dist/components/autocomplete/index.js +7 -6
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/badge/index.js +3 -3
- package/dist/components/breadcrumb/index.js +1 -1
- package/dist/components/button/index.js +4 -4
- package/dist/components/button-group/index.js +2 -2
- package/dist/components/button-multi-select/index.js +7 -7
- package/dist/components/button-select/index.js +7 -7
- package/dist/components/calendar/index.js +6 -6
- package/dist/components/camera/index.js +15 -14
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/index.js +2 -2
- package/dist/components/carousel/index.js +3 -3
- package/dist/components/chart/index.js +1 -1
- package/dist/components/checkbox/index.js +6 -6
- package/dist/components/choice-card-group/index.js +5 -5
- package/dist/components/circular-progress/index.js +1 -1
- package/dist/components/clipboard/index.js +6 -6
- package/dist/components/code/index.js +2 -2
- package/dist/components/code-block/chrome.js +7 -7
- package/dist/components/code-block/index.js +8 -8
- package/dist/components/code-block/static.js +4 -1
- package/dist/components/code-block/static.js.map +1 -1
- package/dist/components/collapse/index.js +2 -2
- package/dist/components/combobox/index.js +7 -6
- package/dist/components/combobox-list/index.js +9 -8
- package/dist/components/compare/index.js +2 -2
- package/dist/components/container/index.js +1 -1
- package/dist/components/data-table/index.js +33 -33
- package/dist/components/date-picker/index.js +16 -15
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/divider/index.js +2 -2
- package/dist/components/download-button/index.js +5 -5
- package/dist/components/drawer/index.js +6 -6
- package/dist/components/field/index.js +2 -2
- package/dist/components/figure/index.js +2 -2
- package/dist/components/file-item/index.js +8 -8
- package/dist/components/file-preview/index.js +6 -6
- package/dist/components/file-queue-summary/index.js +2 -2
- package/dist/components/file-trigger/index.js +5 -5
- package/dist/components/file-upload/index.js +10 -10
- package/dist/components/flex/index.js +2 -2
- package/dist/components/gallery/index.js +4 -4
- package/dist/components/grid/index.js +1 -1
- package/dist/components/hover-card/hover-card.d.ts +44 -26
- package/dist/components/hover-card/hover-card.d.ts.map +1 -1
- package/dist/components/hover-card/index.js +36 -54
- package/dist/components/hover-card/index.js.map +1 -1
- package/dist/components/image/index.js +2 -2
- package/dist/components/image-cropper/index.js +7 -7
- package/dist/components/indicator/index.js +1 -1
- package/dist/components/input/index.js +3 -3
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/lightbox/index.js +9 -9
- package/dist/components/mark/index.js +2 -2
- package/dist/components/menu/index.js +5 -5
- package/dist/components/modal/index.js +6 -6
- package/dist/components/multi-combobox-list/index.js +11 -10
- package/dist/components/multi-select/index.js +10 -9
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/nav-link/index.js +5 -5
- package/dist/components/nav-link/tanstack.js +5 -5
- package/dist/components/notification/index.js +7 -7
- package/dist/components/number-input/index.js +7 -6
- package/dist/components/overlays/index.js +8 -8
- package/dist/components/password-input/index.js +4 -4
- package/dist/components/photo-capture/index.js +18 -17
- package/dist/components/photo-capture/index.js.map +1 -1
- package/dist/components/pill/index.js +3 -3
- package/dist/components/pills-input/index.js +6 -6
- package/dist/components/pin-input/index.js +3 -3
- package/dist/components/popover/index.d.ts +1 -1
- package/dist/components/popover/index.d.ts.map +1 -1
- package/dist/components/popover/index.js +3 -2
- package/dist/components/popover/popover.d.ts +44 -29
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/progress/index.js +2 -2
- package/dist/components/radio-group/index.js +4 -4
- package/dist/components/rating/index.js +3 -3
- package/dist/components/schedule/index.js +10 -10
- package/dist/components/segment-group/index.js +3 -3
- package/dist/components/select/index.js +8 -7
- package/dist/components/skeleton/index.js +2 -2
- package/dist/components/slider/index.js +4 -4
- package/dist/components/spinner/index.js +2 -2
- package/dist/components/spotlight/index.js +16 -15
- package/dist/components/spotlight/index.js.map +1 -1
- package/dist/components/switch/index.js +3 -3
- package/dist/components/table/index.js +3 -3
- package/dist/components/tabs/index.js +3 -3
- package/dist/components/tags-input/index.js +9 -8
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/text/index.js +2 -2
- package/dist/components/text-input/index.js +3 -3
- package/dist/components/textarea/index.js +3 -3
- package/dist/components/theme-icon/index.js +3 -3
- package/dist/components/time-input/index.js +9 -8
- package/dist/components/time-input/index.js.map +1 -1
- package/dist/components/timeline/index.js +1 -1
- package/dist/components/title/index.js +2 -2
- package/dist/components/tooltip/index.js +4 -4
- package/dist/components/tree-multi-select/index.js +11 -10
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-select/index.js +8 -7
- package/dist/components/tree-select/index.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/cn.d.ts.map +1 -1
- package/dist/lib/cn.js +1 -1
- package/dist/lib/placement.d.ts +42 -1
- package/dist/lib/placement.d.ts.map +1 -1
- package/dist/lib/slide-on-switch.d.ts +69 -0
- package/dist/lib/slide-on-switch.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/card/card.test.tsx +10 -0
- package/src/components/card/card.tsx +4 -1
- package/src/components/hover-card/hover-card.tsx +89 -167
- package/src/components/popover/index.ts +2 -0
- package/src/components/popover/popover.test.tsx +131 -0
- package/src/components/popover/popover.tsx +191 -53
- package/src/lib/cn.test.ts +9 -0
- package/src/lib/cn.ts +9 -1
- package/src/lib/placement.test.ts +37 -0
- package/src/lib/placement.ts +60 -1
- package/src/lib/slide-on-switch.ts +99 -0
- package/dist/chunk-G52U24GR.js +0 -10
- package/dist/chunk-G52U24GR.js.map +0 -1
- package/dist/chunk-QP4I37PA.js +0 -14
- package/dist/chunk-QP4I37PA.js.map +0 -1
- package/dist/chunk-Z5WYYDG2.js.map +0 -1
- package/dist/chunk-ZN3WYGIQ.js.map +0 -1
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
import { HoverCard as Ark } from "@ark-ui/react/hover-card"
|
|
4
4
|
import { useLocaleContext } from "@ark-ui/react/locale"
|
|
5
5
|
import { Portal } from "@ark-ui/react/portal"
|
|
6
|
-
import {
|
|
7
|
-
Children,
|
|
8
|
-
cloneElement,
|
|
9
|
-
createContext,
|
|
10
|
-
isValidElement,
|
|
11
|
-
type ReactElement,
|
|
12
|
-
type ReactNode,
|
|
13
|
-
useContext,
|
|
14
|
-
useEffect,
|
|
15
|
-
useRef,
|
|
16
|
-
useState,
|
|
17
|
-
} from "react"
|
|
6
|
+
import { createContext, type ReactNode, useContext } from "react"
|
|
18
7
|
import { cn } from "../../lib/cn"
|
|
19
8
|
import { useOverlayContainer } from "../../lib/overlay-container"
|
|
20
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
type LogicalPosition,
|
|
11
|
+
type Placement,
|
|
12
|
+
type PlacementProps,
|
|
13
|
+
toPositioning,
|
|
14
|
+
} from "../../lib/placement"
|
|
21
15
|
import { props } from "../../lib/props"
|
|
16
|
+
import {
|
|
17
|
+
activeGroupContent,
|
|
18
|
+
slideStyle,
|
|
19
|
+
splitGroupChildren,
|
|
20
|
+
useSlideAfterPlaced,
|
|
21
|
+
} from "../../lib/slide-on-switch"
|
|
22
22
|
import type { WithTestId } from "../../lib/test-id"
|
|
23
23
|
import { popoverChrome } from "../popover/popover"
|
|
24
24
|
|
|
@@ -60,44 +60,19 @@ import { popoverChrome } from "../popover/popover"
|
|
|
60
60
|
* click, tap or Enter pins it as a focusable, dismissable popover.
|
|
61
61
|
*/
|
|
62
62
|
|
|
63
|
-
/** Slide transition for `HoverCard.Group`'s shared positioner — Ark sets the
|
|
64
|
-
* positioner's `transform: translate3d(var(--x), var(--y), 0)` inline
|
|
65
|
-
* (`@zag-js/popper`); animating `transform` itself makes the browser
|
|
66
|
-
* interpolate that translate smoothly between two trigger anchors when the
|
|
67
|
-
* group's active trigger changes. Passed as `style` (not a class) so it
|
|
68
|
-
* merges with — rather than replaces — Ark's own inline `transform`/
|
|
69
|
-
* `position` (Ark's `mergeProps` shallow-merges style objects); same
|
|
70
|
-
* override-the-real-style technique `Tabs.Indicator` / `SegmentGroup` use
|
|
71
|
-
* for their sliding pill. Only applied inside `Group`, and only once
|
|
72
|
-
* `HoverCardContextValue.sliding` is true (see `Group`) — never on the very
|
|
73
|
-
* first open, where the positioner's `--x`/`--y` haven't been computed yet
|
|
74
|
-
* (the panel briefly sits at its unset `transform: none` origin, the
|
|
75
|
-
* viewport's top-left, before floating-ui places it); animating *that*
|
|
76
|
-
* jump would read as the panel sliding in from the top of the screen
|
|
77
|
-
* instead of just appearing. A standalone `Root` never gets this at all: it
|
|
78
|
-
* also repositions on scroll/resize (`autoUpdate`), where an animated
|
|
79
|
-
* `transform` would look laggy rather than responsive. */
|
|
80
|
-
const hoverCardSlideStyle = {
|
|
81
|
-
transitionProperty: "transform",
|
|
82
|
-
transitionDuration: "200ms",
|
|
83
|
-
transitionTimingFunction: "cubic-bezier(0.32, 0.72, 0, 1)",
|
|
84
|
-
} as const
|
|
85
|
-
|
|
86
|
-
type HoverCardPlacement = NonNullable<NonNullable<Ark.RootProps["positioning"]>["placement"]>
|
|
87
|
-
|
|
88
63
|
/** `position` accepts Ark's physical placements plus the logical, RTL-aware
|
|
89
64
|
* horizontal sides `start` / `end` (resolved to `left` / `right` by direction). */
|
|
90
|
-
export type HoverCardPosition = LogicalPosition<
|
|
65
|
+
export type HoverCardPosition = LogicalPosition<Placement>
|
|
91
66
|
|
|
92
67
|
type HoverCardContextValue = {
|
|
93
68
|
width: "target" | "auto"
|
|
94
69
|
withinPortal: boolean
|
|
95
70
|
container?: HTMLElement | null
|
|
96
71
|
/** Whether this `Content` is `HoverCard.Group`'s single shared panel *and*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* only a later switch between targets animates, never the
|
|
72
|
+
* its open has been placed once — `Group` flips this true after the first
|
|
73
|
+
* placement lands, once the panel has a real position to slide *from*
|
|
74
|
+
* (see `useSlideAfterPlaced`). Gates the slide transition (`slideStyle`)
|
|
75
|
+
* so only a later switch between targets animates, never the reveal. */
|
|
101
76
|
sliding: boolean
|
|
102
77
|
}
|
|
103
78
|
const HoverCardContext = createContext<HoverCardContextValue>({
|
|
@@ -106,39 +81,31 @@ const HoverCardContext = createContext<HoverCardContextValue>({
|
|
|
106
81
|
sliding: false,
|
|
107
82
|
})
|
|
108
83
|
|
|
109
|
-
export type HoverCardRootProps = Omit<Ark.RootProps, "positioning" | "onOpenChange"> &
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
withinPortal?: boolean
|
|
127
|
-
/** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is
|
|
128
|
-
* one (so the panel stays above it), else `document.body`. */
|
|
129
|
-
container?: HTMLElement | null
|
|
130
|
-
/** Fires when the card opens or closes (flattened from Ark's detail object). */
|
|
131
|
-
onOpenChange?: (open: boolean) => void
|
|
132
|
-
/** Fires on close (any source) — pointer/focus leaving, Escape, outside
|
|
133
|
-
* interaction, or a controlled `onOpenChange`. */
|
|
134
|
-
onClose?: () => void
|
|
135
|
-
}
|
|
84
|
+
export type HoverCardRootProps = Omit<Ark.RootProps, "positioning" | "onOpenChange"> &
|
|
85
|
+
PlacementProps & {
|
|
86
|
+
/** Match the trigger's width (`"target"`), or size to content (`"auto"`,
|
|
87
|
+
* default — a hover card's content is usually much larger than its
|
|
88
|
+
* trigger, unlike a dropdown). */
|
|
89
|
+
width?: "target" | "auto"
|
|
90
|
+
/** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */
|
|
91
|
+
withinPortal?: boolean
|
|
92
|
+
/** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is
|
|
93
|
+
* one (so the panel stays above it), else `document.body`. */
|
|
94
|
+
container?: HTMLElement | null
|
|
95
|
+
/** Fires when the card opens or closes (flattened from Ark's detail object). */
|
|
96
|
+
onOpenChange?: (open: boolean) => void
|
|
97
|
+
/** Fires on close (any source) — pointer/focus leaving, Escape, outside
|
|
98
|
+
* interaction, or a controlled `onOpenChange`. */
|
|
99
|
+
onClose?: () => void
|
|
100
|
+
}
|
|
136
101
|
|
|
137
102
|
const Root = ({
|
|
138
103
|
width = "auto",
|
|
139
|
-
position
|
|
104
|
+
position,
|
|
140
105
|
gutter,
|
|
141
106
|
offset,
|
|
107
|
+
hideWhenDetached,
|
|
108
|
+
positioning,
|
|
142
109
|
withinPortal = true,
|
|
143
110
|
container,
|
|
144
111
|
openDelay,
|
|
@@ -155,12 +122,11 @@ const Root = ({
|
|
|
155
122
|
lazyMount
|
|
156
123
|
unmountOnExit
|
|
157
124
|
openDelay={openDelay}
|
|
158
|
-
positioning={
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}}
|
|
125
|
+
positioning={toPositioning(
|
|
126
|
+
{ position, gutter, offset, hideWhenDetached, positioning },
|
|
127
|
+
dir,
|
|
128
|
+
width,
|
|
129
|
+
)}
|
|
164
130
|
onOpenChange={({ open }) => {
|
|
165
131
|
onOpenChange?.(open)
|
|
166
132
|
if (!open) onClose?.()
|
|
@@ -192,7 +158,7 @@ const Content = ({
|
|
|
192
158
|
const { width, withinPortal, container, sliding } = useContext(HoverCardContext)
|
|
193
159
|
const portalContainer = useOverlayContainer(container)
|
|
194
160
|
const panel = (
|
|
195
|
-
<Ark.Positioner style={sliding ?
|
|
161
|
+
<Ark.Positioner style={sliding ? slideStyle : undefined}>
|
|
196
162
|
<Ark.Content
|
|
197
163
|
tabIndex={-1}
|
|
198
164
|
className={cn(popoverChrome, width === "target" ? "w-full" : "w-max", className)}
|
|
@@ -207,43 +173,27 @@ const Content = ({
|
|
|
207
173
|
return <Portal container={portalContainer}>{panel}</Portal>
|
|
208
174
|
}
|
|
209
175
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
/** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */
|
|
232
|
-
withinPortal?: boolean
|
|
233
|
-
/** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is
|
|
234
|
-
* one (so the panel stays above it), else `document.body`. */
|
|
235
|
-
container?: HTMLElement | null
|
|
236
|
-
/** Fires when the card opens or closes (flattened from Ark's detail object). */
|
|
237
|
-
onOpenChange?: (open: boolean) => void
|
|
238
|
-
/** Fires on close (any source) — pointer/focus leaving the whole group,
|
|
239
|
-
* Escape, outside interaction, or a controlled `onOpenChange`. */
|
|
240
|
-
onClose?: () => void
|
|
241
|
-
/** `HoverCard.Trigger` (one per hover target, each with its own `value`)
|
|
242
|
-
* and `HoverCard.Content` (one per target's content, `value`-matched to
|
|
243
|
-
* its trigger) — the same parts `HoverCard.Root` uses, just several of
|
|
244
|
-
* each instead of one. */
|
|
245
|
-
children?: ReactNode
|
|
246
|
-
}
|
|
176
|
+
export type HoverCardGroupProps = Omit<Ark.RootProps, "positioning" | "onOpenChange" | "children"> &
|
|
177
|
+
PlacementProps & {
|
|
178
|
+
/** Match every trigger's width (`"target"`), or size to content (`"auto"`,
|
|
179
|
+
* default). */
|
|
180
|
+
width?: "target" | "auto"
|
|
181
|
+
/** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */
|
|
182
|
+
withinPortal?: boolean
|
|
183
|
+
/** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is
|
|
184
|
+
* one (so the panel stays above it), else `document.body`. */
|
|
185
|
+
container?: HTMLElement | null
|
|
186
|
+
/** Fires when the card opens or closes (flattened from Ark's detail object). */
|
|
187
|
+
onOpenChange?: (open: boolean) => void
|
|
188
|
+
/** Fires on close (any source) — pointer/focus leaving the whole group,
|
|
189
|
+
* Escape, outside interaction, or a controlled `onOpenChange`. */
|
|
190
|
+
onClose?: () => void
|
|
191
|
+
/** `HoverCard.Trigger` (one per hover target, each with its own `value`)
|
|
192
|
+
* and `HoverCard.Content` (one per target's content, `value`-matched to
|
|
193
|
+
* its trigger) — the same parts `HoverCard.Root` uses, just several of
|
|
194
|
+
* each instead of one. */
|
|
195
|
+
children?: ReactNode
|
|
196
|
+
}
|
|
247
197
|
|
|
248
198
|
/**
|
|
249
199
|
* One shared card across several hover targets (e.g. a row of avatars) — the
|
|
@@ -275,7 +225,7 @@ export type HoverCardGroupProps = Omit<
|
|
|
275
225
|
* as a props update on the *same* `Content`/`Positioner`/`Content` element
|
|
276
226
|
* tree, not an unmount-and-remount of a different one, which is what keeps
|
|
277
227
|
* it one real, continuous DOM node to slide. Paired with a CSS transition on
|
|
278
|
-
* the positioner's `transform` (`
|
|
228
|
+
* the positioner's `transform` (`slideStyle`, applied by `Content`
|
|
279
229
|
* whenever `sliding` is set), that reposition visibly slides the panel from
|
|
280
230
|
* one target to the next.
|
|
281
231
|
*
|
|
@@ -289,9 +239,11 @@ export type HoverCardGroupProps = Omit<
|
|
|
289
239
|
*/
|
|
290
240
|
const Group = ({
|
|
291
241
|
width = "auto",
|
|
292
|
-
position
|
|
242
|
+
position,
|
|
293
243
|
gutter,
|
|
294
244
|
offset,
|
|
245
|
+
hideWhenDetached,
|
|
246
|
+
positioning,
|
|
295
247
|
withinPortal = true,
|
|
296
248
|
container,
|
|
297
249
|
openDelay,
|
|
@@ -301,68 +253,38 @@ const Group = ({
|
|
|
301
253
|
...rest
|
|
302
254
|
}: HoverCardGroupProps) => {
|
|
303
255
|
const { dir } = useLocaleContext()
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
const triggers = items.filter((item) => !isGroupContent(item))
|
|
307
|
-
|
|
308
|
-
// False until one frame after opening, once the panel has a real computed
|
|
309
|
-
// position to slide *from* — see `hoverCardSlideStyle`'s doc comment.
|
|
310
|
-
// Reset on every close so the *next* pioneer open doesn't animate either.
|
|
311
|
-
const [sliding, setSliding] = useState(false)
|
|
312
|
-
const slidingRafRef = useRef<number | null>(null)
|
|
313
|
-
useEffect(
|
|
314
|
-
() => () => {
|
|
315
|
-
if (slidingRafRef.current != null) cancelAnimationFrame(slidingRafRef.current)
|
|
316
|
-
},
|
|
317
|
-
[],
|
|
318
|
-
)
|
|
256
|
+
const { contents, triggers } = splitGroupChildren(children, Content)
|
|
257
|
+
const slide = useSlideAfterPlaced()
|
|
319
258
|
|
|
320
259
|
return (
|
|
321
|
-
<HoverCardContext.Provider value={{ width, withinPortal, container, sliding }}>
|
|
260
|
+
<HoverCardContext.Provider value={{ width, withinPortal, container, sliding: slide.sliding }}>
|
|
322
261
|
<Ark.Root
|
|
323
262
|
lazyMount
|
|
324
263
|
unmountOnExit
|
|
325
264
|
openDelay={openDelay}
|
|
326
|
-
positioning={
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
265
|
+
positioning={toPositioning(
|
|
266
|
+
{
|
|
267
|
+
position,
|
|
268
|
+
gutter,
|
|
269
|
+
offset,
|
|
270
|
+
hideWhenDetached,
|
|
271
|
+
positioning: {
|
|
272
|
+
...positioning,
|
|
273
|
+
updatePosition: slide.updatePosition(positioning?.updatePosition),
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
dir,
|
|
277
|
+
width,
|
|
278
|
+
)}
|
|
332
279
|
onOpenChange={({ open }) => {
|
|
333
280
|
onOpenChange?.(open)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
slidingRafRef.current = null
|
|
337
|
-
setSliding(true)
|
|
338
|
-
})
|
|
339
|
-
} else {
|
|
340
|
-
if (slidingRafRef.current != null) {
|
|
341
|
-
cancelAnimationFrame(slidingRafRef.current)
|
|
342
|
-
slidingRafRef.current = null
|
|
343
|
-
}
|
|
344
|
-
setSliding(false)
|
|
345
|
-
onClose?.()
|
|
346
|
-
}
|
|
281
|
+
slide.onOpenChange(open)
|
|
282
|
+
if (!open) onClose?.()
|
|
347
283
|
}}
|
|
348
284
|
{...rest}
|
|
349
285
|
>
|
|
350
286
|
{triggers}
|
|
351
|
-
<Ark.Context>
|
|
352
|
-
{(api) => {
|
|
353
|
-
const active = contents.find((c) => c.props.value === api.triggerValue)
|
|
354
|
-
// Force a stable `key`, overriding whatever each `Content` was
|
|
355
|
-
// authored with (e.g. `key={person.handle}` in a `.map()`) — this
|
|
356
|
-
// slot only ever renders one at a time, but a *different* key
|
|
357
|
-
// switching in here reads to React as a different component,
|
|
358
|
-
// unmounting the real Positioner/Content DOM tree and mounting a
|
|
359
|
-
// fresh one instead of updating it in place. That fresh mount is
|
|
360
|
-
// exactly what breaks the "one shared, sliding panel" contract:
|
|
361
|
-
// its position starts unset again, so every switch would look
|
|
362
|
-
// like the panel jumping in from the top instead of sliding.
|
|
363
|
-
return active ? cloneElement(active, { key: "hover-card-group-content" }) : null
|
|
364
|
-
}}
|
|
365
|
-
</Ark.Context>
|
|
287
|
+
<Ark.Context>{(api) => activeGroupContent(contents, api.triggerValue)}</Ark.Context>
|
|
366
288
|
</Ark.Root>
|
|
367
289
|
</HoverCardContext.Provider>
|
|
368
290
|
)
|
|
@@ -213,6 +213,137 @@ describe('Popover mode="hover"', () => {
|
|
|
213
213
|
})
|
|
214
214
|
})
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* `Popover.Group` — several triggers, one shared panel. A switch has to keep
|
|
218
|
+
* the *same* content node (a remount would restart the slide from the
|
|
219
|
+
* viewport's corner), so it's compared by reference, like `HoverCard.Group`.
|
|
220
|
+
*/
|
|
221
|
+
describe("Popover.Group", () => {
|
|
222
|
+
const person = (name: string) => screen.getByRole("button", { name })
|
|
223
|
+
const contents = () => document.querySelectorAll('[data-scope="popover"][data-part="content"]')
|
|
224
|
+
|
|
225
|
+
const Row = (props: Partial<PopoverProps>) => (
|
|
226
|
+
<Popover.Group
|
|
227
|
+
mode="hover"
|
|
228
|
+
openDelay={100}
|
|
229
|
+
closeDelay={100}
|
|
230
|
+
withinPortal={false}
|
|
231
|
+
{...(props as object)}
|
|
232
|
+
>
|
|
233
|
+
<Popover.Trigger value="ada" asChild>
|
|
234
|
+
<button type="button">Ada</button>
|
|
235
|
+
</Popover.Trigger>
|
|
236
|
+
<Popover.Trigger value="grace" asChild>
|
|
237
|
+
<button type="button">Grace</button>
|
|
238
|
+
</Popover.Trigger>
|
|
239
|
+
<Popover.Content value="ada">
|
|
240
|
+
<span>Ada's card</span>
|
|
241
|
+
<a href="/ada">Ada's profile</a>
|
|
242
|
+
</Popover.Content>
|
|
243
|
+
<Popover.Content value="grace">
|
|
244
|
+
<span>Grace's card</span>
|
|
245
|
+
<a href="/grace">Grace's profile</a>
|
|
246
|
+
</Popover.Content>
|
|
247
|
+
</Popover.Group>
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
it("moves an open preview to the next trigger, without closing or replaying the delay", async () => {
|
|
251
|
+
const onOpenChange = vi.fn()
|
|
252
|
+
const onTriggerValueChange = vi.fn()
|
|
253
|
+
render(<Row onOpenChange={onOpenChange} onTriggerValueChange={onTriggerValueChange} />)
|
|
254
|
+
hover(person("Ada"))
|
|
255
|
+
await tick(100)
|
|
256
|
+
expect(screen.queryByText("Ada's card")).not.toBeNull()
|
|
257
|
+
const node = panel()
|
|
258
|
+
|
|
259
|
+
unhover(person("Ada"))
|
|
260
|
+
hover(person("Grace"))
|
|
261
|
+
await tick(0)
|
|
262
|
+
expect(screen.queryByText("Grace's card")).not.toBeNull()
|
|
263
|
+
expect(screen.queryByText("Ada's card")).toBeNull()
|
|
264
|
+
expect(contents()).toHaveLength(1)
|
|
265
|
+
expect(panel()).toBe(node)
|
|
266
|
+
expect(onOpenChange).toHaveBeenCalledTimes(1)
|
|
267
|
+
expect(onTriggerValueChange).toHaveBeenLastCalledWith({
|
|
268
|
+
value: "grace",
|
|
269
|
+
triggerElement: person("Grace"),
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
// The pending close from leaving Ada was cancelled by reaching Grace.
|
|
273
|
+
await tick(1000)
|
|
274
|
+
expect(state()).toBe("open")
|
|
275
|
+
expect(person("Grace").getAttribute("aria-expanded")).toBe("true")
|
|
276
|
+
expect(person("Ada").getAttribute("aria-expanded")).toBe("false")
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
it("pins the clicked trigger's card when another one is previewing", async () => {
|
|
280
|
+
render(<Row />)
|
|
281
|
+
hover(person("Ada"))
|
|
282
|
+
await tick(100)
|
|
283
|
+
await tick(16)
|
|
284
|
+
|
|
285
|
+
fireEvent.click(person("Grace"))
|
|
286
|
+
await tick(16)
|
|
287
|
+
expect(state()).toBe("open")
|
|
288
|
+
expect(screen.queryByText("Grace's card")).not.toBeNull()
|
|
289
|
+
expect(document.activeElement).toBe(screen.getByRole("link", { name: "Grace's profile" }))
|
|
290
|
+
|
|
291
|
+
// Pinned: hover and pointer-leave no longer move or close it.
|
|
292
|
+
unhover(person("Grace"))
|
|
293
|
+
hover(person("Ada"))
|
|
294
|
+
await tick(1000)
|
|
295
|
+
expect(state()).toBe("open")
|
|
296
|
+
expect(screen.queryByText("Grace's card")).not.toBeNull()
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
it("pins when the click lands on a face the preview already moved to", async () => {
|
|
300
|
+
// A real pointer hovers a face before clicking it, so by click time the
|
|
301
|
+
// preview has switched there and zag answers with a close, not a switch.
|
|
302
|
+
const onOpenChange = vi.fn()
|
|
303
|
+
render(<Row onOpenChange={onOpenChange} />)
|
|
304
|
+
hover(person("Ada"))
|
|
305
|
+
await tick(100)
|
|
306
|
+
await tick(16)
|
|
307
|
+
unhover(person("Ada"))
|
|
308
|
+
hover(person("Grace"))
|
|
309
|
+
await tick(0)
|
|
310
|
+
fireEvent.click(person("Grace"))
|
|
311
|
+
await tick(16)
|
|
312
|
+
expect(state()).toBe("open")
|
|
313
|
+
expect(onOpenChange).toHaveBeenCalledTimes(1)
|
|
314
|
+
expect(document.activeElement).toBe(screen.getByRole("link", { name: "Grace's profile" }))
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
it("closes once the pointer leaves the whole group", async () => {
|
|
318
|
+
const onOpenChange = vi.fn()
|
|
319
|
+
render(<Row onOpenChange={onOpenChange} />)
|
|
320
|
+
hover(person("Ada"))
|
|
321
|
+
await tick(100)
|
|
322
|
+
unhover(person("Ada"))
|
|
323
|
+
await tick(100)
|
|
324
|
+
expect(state()).toBe("closed")
|
|
325
|
+
expect(onOpenChange).toHaveBeenLastCalledWith({ open: false })
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
it('switches triggers on click in mode="click"', async () => {
|
|
329
|
+
const onOpenChange = vi.fn()
|
|
330
|
+
render(
|
|
331
|
+
<Row mode="click" openDelay={undefined} closeDelay={undefined} onOpenChange={onOpenChange} />,
|
|
332
|
+
)
|
|
333
|
+
fireEvent.click(person("Ada"))
|
|
334
|
+
await tick(16)
|
|
335
|
+
expect(screen.queryByText("Ada's card")).not.toBeNull()
|
|
336
|
+
const node = panel()
|
|
337
|
+
|
|
338
|
+
fireEvent.click(person("Grace"))
|
|
339
|
+
await tick(16)
|
|
340
|
+
expect(screen.queryByText("Grace's card")).not.toBeNull()
|
|
341
|
+
expect(panel()).toBe(node)
|
|
342
|
+
expect(state()).toBe("open")
|
|
343
|
+
expect(onOpenChange).toHaveBeenCalledTimes(1)
|
|
344
|
+
})
|
|
345
|
+
})
|
|
346
|
+
|
|
216
347
|
describe("Popover testId", () => {
|
|
217
348
|
it("lands on the trigger", () => {
|
|
218
349
|
render(
|