@42-central/ui-react 0.20.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/{chunk-45QRQKRC.js → chunk-3L5GLI67.js} +12 -8
  2. package/dist/chunk-3L5GLI67.js.map +1 -0
  3. package/dist/{chunk-BNWQ7IAZ.js → chunk-4FEOMQYR.js} +5 -5
  4. package/dist/{chunk-BNWQ7IAZ.js.map → chunk-4FEOMQYR.js.map} +1 -1
  5. package/dist/{chunk-POKLPMSB.js → chunk-D3JYDAUZ.js} +3 -3
  6. package/dist/{chunk-POKLPMSB.js.map → chunk-D3JYDAUZ.js.map} +1 -1
  7. package/dist/{chunk-KMZENCEP.js → chunk-DHJB4UJD.js} +4 -4
  8. package/dist/{chunk-KMZENCEP.js.map → chunk-DHJB4UJD.js.map} +1 -1
  9. package/dist/{chunk-IOYZC7SA.js → chunk-DJAXXLN6.js} +3 -3
  10. package/dist/{chunk-IOYZC7SA.js.map → chunk-DJAXXLN6.js.map} +1 -1
  11. package/dist/{chunk-3BXKTWWD.js → chunk-FB2G4LNH.js} +5 -5
  12. package/dist/{chunk-3BXKTWWD.js.map → chunk-FB2G4LNH.js.map} +1 -1
  13. package/dist/{chunk-E63VD25L.js → chunk-HQPU73WV.js} +4 -4
  14. package/dist/{chunk-E63VD25L.js.map → chunk-HQPU73WV.js.map} +1 -1
  15. package/dist/{chunk-RCF7HTG5.js → chunk-IRNF274I.js} +5 -5
  16. package/dist/chunk-IRNF274I.js.map +1 -0
  17. package/dist/{chunk-O5W3QWJ6.js → chunk-J44FJ7PH.js} +3 -3
  18. package/dist/{chunk-O5W3QWJ6.js.map → chunk-J44FJ7PH.js.map} +1 -1
  19. package/dist/{chunk-TWLJQE75.js → chunk-MRAJ45IM.js} +4 -4
  20. package/dist/{chunk-TWLJQE75.js.map → chunk-MRAJ45IM.js.map} +1 -1
  21. package/dist/{chunk-5HUEBSIS.js → chunk-N66NC6QK.js} +120 -24
  22. package/dist/chunk-N66NC6QK.js.map +1 -0
  23. package/dist/{chunk-SXNAUSEB.js → chunk-OZMSXYBX.js} +4 -4
  24. package/dist/{chunk-SXNAUSEB.js.map → chunk-OZMSXYBX.js.map} +1 -1
  25. package/dist/{chunk-LBAE6FP6.js → chunk-SZEOTXRZ.js} +4 -4
  26. package/dist/{chunk-LBAE6FP6.js.map → chunk-SZEOTXRZ.js.map} +1 -1
  27. package/dist/chunk-V6PY7C6S.js +18 -0
  28. package/dist/chunk-V6PY7C6S.js.map +1 -0
  29. package/dist/{chunk-MKKQE3TM.js → chunk-YPFSRZ3T.js} +4 -4
  30. package/dist/{chunk-MKKQE3TM.js.map → chunk-YPFSRZ3T.js.map} +1 -1
  31. package/dist/{chunk-NJPHZBLI.js → chunk-YWTOW7PZ.js} +5 -5
  32. package/dist/{chunk-NJPHZBLI.js.map → chunk-YWTOW7PZ.js.map} +1 -1
  33. package/dist/{chunk-VTDBWU6H.js → chunk-YZJUPYPO.js} +3 -3
  34. package/dist/{chunk-VTDBWU6H.js.map → chunk-YZJUPYPO.js.map} +1 -1
  35. package/dist/components/autocomplete/index.js +4 -3
  36. package/dist/components/autocomplete/index.js.map +1 -1
  37. package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts +94 -0
  38. package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts.map +1 -0
  39. package/dist/components/calendar-heatmap/calendar-heatmap.d.ts +76 -0
  40. package/dist/components/calendar-heatmap/calendar-heatmap.d.ts.map +1 -0
  41. package/dist/components/calendar-heatmap/index.d.ts +2 -0
  42. package/dist/components/calendar-heatmap/index.d.ts.map +1 -0
  43. package/dist/components/calendar-heatmap/index.js +311 -0
  44. package/dist/components/calendar-heatmap/index.js.map +1 -0
  45. package/dist/components/camera/index.js +6 -5
  46. package/dist/components/clipboard/index.js +1 -1
  47. package/dist/components/code-block/chrome.js +4 -4
  48. package/dist/components/code-block/index.js +5 -5
  49. package/dist/components/combobox/index.js +4 -3
  50. package/dist/components/combobox-list/index.js +6 -5
  51. package/dist/components/data-table/index.js +16 -16
  52. package/dist/components/date-picker/index.js +7 -6
  53. package/dist/components/date-picker/index.js.map +1 -1
  54. package/dist/components/hover-card/hover-card.d.ts +44 -26
  55. package/dist/components/hover-card/hover-card.d.ts.map +1 -1
  56. package/dist/components/hover-card/index.js +35 -53
  57. package/dist/components/hover-card/index.js.map +1 -1
  58. package/dist/components/input/index.js +1 -1
  59. package/dist/components/input/input.d.ts.map +1 -1
  60. package/dist/components/menu/index.js +3 -3
  61. package/dist/components/menu/menu.d.ts +7 -5
  62. package/dist/components/menu/menu.d.ts.map +1 -1
  63. package/dist/components/multi-combobox-list/index.js +6 -5
  64. package/dist/components/multi-select/index.js +5 -4
  65. package/dist/components/multi-select/index.js.map +1 -1
  66. package/dist/components/navigation-progress/index.d.ts +2 -0
  67. package/dist/components/navigation-progress/index.d.ts.map +1 -0
  68. package/dist/components/navigation-progress/index.js +133 -0
  69. package/dist/components/navigation-progress/index.js.map +1 -0
  70. package/dist/components/navigation-progress/navigation-progress.d.ts +46 -0
  71. package/dist/components/navigation-progress/navigation-progress.d.ts.map +1 -0
  72. package/dist/components/number-input/index.js +4 -3
  73. package/dist/components/number-input/number-input.d.ts.map +1 -1
  74. package/dist/components/password-input/index.js +1 -1
  75. package/dist/components/photo-capture/index.js +6 -5
  76. package/dist/components/photo-capture/index.js.map +1 -1
  77. package/dist/components/pills-input/index.js +2 -2
  78. package/dist/components/pin-input/index.js +1 -1
  79. package/dist/components/popover/index.d.ts +1 -1
  80. package/dist/components/popover/index.d.ts.map +1 -1
  81. package/dist/components/popover/index.js +2 -1
  82. package/dist/components/popover/popover.d.ts +44 -29
  83. package/dist/components/popover/popover.d.ts.map +1 -1
  84. package/dist/components/schedule/index.js +2 -2
  85. package/dist/components/select/index.js +5 -4
  86. package/dist/components/spotlight/index.js +5 -4
  87. package/dist/components/spotlight/index.js.map +1 -1
  88. package/dist/components/tags-input/index.js +4 -3
  89. package/dist/components/tags-input/index.js.map +1 -1
  90. package/dist/components/text-input/index.js +1 -1
  91. package/dist/components/textarea/index.js +1 -1
  92. package/dist/components/time-input/index.js +5 -4
  93. package/dist/components/time-input/index.js.map +1 -1
  94. package/dist/components/tooltip/index.js +2 -2
  95. package/dist/components/tree-multi-select/index.js +5 -4
  96. package/dist/components/tree-multi-select/index.js.map +1 -1
  97. package/dist/components/tree-select/index.js +4 -3
  98. package/dist/components/tree-select/index.js.map +1 -1
  99. package/dist/index.js +2 -2
  100. package/dist/lib/placement.d.ts +42 -1
  101. package/dist/lib/placement.d.ts.map +1 -1
  102. package/dist/lib/slide-on-switch.d.ts +69 -0
  103. package/dist/lib/slide-on-switch.d.ts.map +1 -0
  104. package/package.json +1 -1
  105. package/src/as-child.contract.test.tsx +4 -0
  106. package/src/components/calendar-heatmap/calendar-heatmap-grid.test.ts +186 -0
  107. package/src/components/calendar-heatmap/calendar-heatmap-grid.ts +192 -0
  108. package/src/components/calendar-heatmap/calendar-heatmap.test.tsx +180 -0
  109. package/src/components/calendar-heatmap/calendar-heatmap.tsx +385 -0
  110. package/src/components/calendar-heatmap/index.ts +11 -0
  111. package/src/components/hover-card/hover-card.tsx +89 -167
  112. package/src/components/input/input.test.tsx +23 -0
  113. package/src/components/input/input.tsx +10 -6
  114. package/src/components/menu/menu.tsx +16 -9
  115. package/src/components/navigation-progress/index.ts +14 -0
  116. package/src/components/navigation-progress/navigation-progress.test.tsx +184 -0
  117. package/src/components/navigation-progress/navigation-progress.tsx +228 -0
  118. package/src/components/number-input/number-input.tsx +3 -4
  119. package/src/components/popover/index.ts +2 -0
  120. package/src/components/popover/popover.test.tsx +131 -0
  121. package/src/components/popover/popover.tsx +191 -53
  122. package/src/lib/placement.test.ts +37 -0
  123. package/src/lib/placement.ts +60 -1
  124. package/src/lib/slide-on-switch.ts +99 -0
  125. package/dist/chunk-45QRQKRC.js.map +0 -1
  126. package/dist/chunk-5HUEBSIS.js.map +0 -1
  127. package/dist/chunk-G52U24GR.js +0 -10
  128. package/dist/chunk-G52U24GR.js.map +0 -1
  129. package/dist/chunk-RCF7HTG5.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 { type LogicalPosition, resolveLogicalPlacement } from "../../lib/placement"
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<HoverCardPlacement>
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
- * has already completed its first open — `Group` flips this true one
98
- * frame after opening, once the panel has a real, computed position to
99
- * slide *from*. Gates the slide transition (see `hoverCardSlideStyle`) so
100
- * only a later switch between targets animates, never the initial reveal. */
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
- /** Match the trigger's width (`"target"`), or size to content (`"auto"`,
111
- * default — a hover card's content is usually much larger than its
112
- * trigger, unlike a dropdown). */
113
- width?: "target" | "auto"
114
- /** Panel placement relative to the trigger. Defaults to Ark's `"bottom"`. */
115
- position?: HoverCardPosition
116
- /** Gap in px between the trigger and the panel. */
117
- gutter?: number
118
- /** Positioner offset. */
119
- offset?:
120
- | {
121
- mainAxis?: number | undefined
122
- crossAxis?: number | undefined
123
- }
124
- | undefined
125
- /** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */
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 = "bottom",
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
- sameWidth: width === "target",
160
- placement: resolveLogicalPlacement(position, dir),
161
- gutter,
162
- offset,
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 ? hoverCardSlideStyle : undefined}>
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
- const isGroupContent = (node: ReactNode): node is ReactElement<HoverCardContentProps> =>
211
- isValidElement(node) && node.type === Content
212
-
213
- export type HoverCardGroupProps = Omit<
214
- Ark.RootProps,
215
- "positioning" | "onOpenChange" | "children"
216
- > & {
217
- /** Match every trigger's width (`"target"`), or size to content (`"auto"`,
218
- * default). */
219
- width?: "target" | "auto"
220
- /** Panel placement relative to the active trigger. Defaults to Ark's `"bottom"`. */
221
- position?: HoverCardPosition
222
- /** Gap in px between the active trigger and the panel. */
223
- gutter?: number
224
- /** Positioner offset. */
225
- offset?:
226
- | {
227
- mainAxis?: number | undefined
228
- crossAxis?: number | undefined
229
- }
230
- | undefined
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` (`hoverCardSlideStyle`, applied by `Content`
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 = "bottom",
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 items = Children.toArray(children)
305
- const contents = items.filter(isGroupContent)
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
- sameWidth: width === "target",
328
- placement: resolveLogicalPlacement(position, dir),
329
- gutter,
330
- offset,
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
- if (open) {
335
- slidingRafRef.current = requestAnimationFrame(() => {
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
  )
@@ -2,6 +2,7 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react"
2
2
  import { createRef } from "react"
3
3
  import { describe, expect, it, vi } from "vitest"
4
4
  import { Field } from "../field/field"
5
+ import { Kbd } from "../kbd/kbd"
5
6
  import { Input, InputBase } from "./input"
6
7
 
7
8
  describe("Input", () => {
@@ -109,3 +110,25 @@ describe("InputBase", () => {
109
110
  expect(screen.getByTestId("shell").tagName).toBe("DIV")
110
111
  })
111
112
  })
113
+
114
+ /**
115
+ * Shell icon sizing (#422) — the shell sizes svgs through `:where()`, at zero
116
+ * class specificity, so a component in a slot that sizes its own icons keeps
117
+ * them. The classes are asserted, not the computed size: jsdom runs no Tailwind.
118
+ */
119
+ describe("InputBase (icon sizing)", () => {
120
+ it("sizes svgs at zero specificity, never with a bare descendant rule", () => {
121
+ render(<InputBase testId="shell" startSlot={<svg aria-hidden="true" />} />)
122
+ const cls = screen.getByTestId("shell").className
123
+ expect(cls).toContain("[:where(&)_svg]:size-4")
124
+ expect(cls).toContain("[:where(&)_svg]:shrink-0")
125
+ expect(cls).not.toMatch(/\[&_svg\]/)
126
+ })
127
+
128
+ it("keeps a slotted Kbd's own icon sizing", () => {
129
+ render(<Input placeholder="Search" endSlot={<Kbd hotkey="mod+k" size="sm" />} />)
130
+ const caps = document.querySelectorAll("kbd kbd")
131
+ expect(caps.length).toBe(2)
132
+ for (const cap of caps) expect(cap.className).toContain("[&_svg]:size-3")
133
+ })
134
+ })
@@ -77,7 +77,11 @@ export const shellChrome = [
77
77
  "data-disabled:cursor-not-allowed data-disabled:opacity-60",
78
78
  "data-disabled:bg-white/8",
79
79
  "data-pointer:cursor-pointer",
80
- "[&_svg]:pointer-events-none [&_svg]:shrink-0",
80
+ // `:where()` drops every shell svg rule to zero class specificity, so it
81
+ // sizes bare icons (the slot's own, the family's chevron / clear) while a
82
+ // component in a slot that styles its own icons (Kbd, Badge, Spinner…), or
83
+ // a size class on the icon itself, wins whatever the CSS order (#422).
84
+ "[:where(&)_svg]:pointer-events-none [:where(&)_svg]:shrink-0",
81
85
  ]
82
86
 
83
87
  /** Surface treatment per `variant`, shared across the input shells. */
@@ -126,27 +130,27 @@ export const inputShell = cva([...shellChrome, "flex w-full items-center gap-y-0
126
130
  xs: [
127
131
  "ps-1.5 pe-1.5",
128
132
  "data-with-start-slot:ps-2 data-with-end-slot:pe-2",
129
- `min-h-7 ${shellGap.xs} text-xs [&_svg]:size-3`,
133
+ `min-h-7 ${shellGap.xs} text-xs [:where(&)_svg]:size-3`,
130
134
  ],
131
135
  sm: [
132
136
  "ps-2 pe-2",
133
137
  "data-with-start-slot:ps-2.5 data-with-end-slot:pe-2.5",
134
- `min-h-8 ${shellGap.sm} text-sm [&_svg]:size-3.5`,
138
+ `min-h-8 ${shellGap.sm} text-sm [:where(&)_svg]:size-3.5`,
135
139
  ],
136
140
  md: [
137
141
  "ps-2 pe-2",
138
142
  "data-with-start-slot:ps-2.5 data-with-end-slot:pe-2.5",
139
- `min-h-9 ${shellGap.md} text-md [&_svg]:size-4`,
143
+ `min-h-9 ${shellGap.md} text-md [:where(&)_svg]:size-4`,
140
144
  ],
141
145
  lg: [
142
146
  "ps-3 pe-3",
143
147
  "data-with-start-slot:ps-3.5 data-with-end-slot:pe-3.5",
144
- `min-h-10 ${shellGap.lg} text-lg [&_svg]:size-5`,
148
+ `min-h-10 ${shellGap.lg} text-lg [:where(&)_svg]:size-5`,
145
149
  ],
146
150
  xl: [
147
151
  "ps-3.5 pe-3.5",
148
152
  "data-with-start-slot:ps-4 data-with-end-slot:pe-4",
149
- `min-h-12 ${shellGap.xl} text-xl [&_svg]:size-6`,
153
+ `min-h-12 ${shellGap.xl} text-xl [:where(&)_svg]:size-6`,
150
154
  ],
151
155
  },
152
156
  },
@@ -475,29 +475,36 @@ const RadioItem = ({
475
475
  export type MenuSubProps = Omit<ArkMenu.RootProps, "positioning"> & {
476
476
  /** Gap in px between the trigger row and the submenu. Ark manages submenu
477
477
  * *placement* itself (RTL-aware `right-start` / `left-start`, flush to the
478
- * parent), so only this main-axis gap is adjustable. Defaults to `10`. */
478
+ * parent, flipping to `-end` when it doesn't fit below the row), so only this
479
+ * main-axis gap is adjustable. Defaults to `10`. */
479
480
  offset?: number
480
481
  }
481
482
 
482
483
  /** A submenu opens flush to its trigger row, so its first item lands one surface
483
484
  * inset *below* the trigger — the `menuContent` top border (1px) + top padding
484
485
  * (`p-1` = 4px). Nudging the submenu up by that inset lines the first sub-item
485
- * up with the trigger row. Cross-axis is the vertical axis for the (Ark-forced)
486
- * `right-start` / `left-start` placements, and Floating UI maps a negative value
487
- * to "up" in both directions — so one constant covers LTR and RTL. */
486
+ * up with the trigger row.
487
+ *
488
+ * It goes on the *alignment* axis (zag's `shift`), not the cross axis: Floating
489
+ * UI negates it for `-end` alignments. When the submenu doesn't fit below its
490
+ * row, `flip` moves it to `right-end` / `left-end` (bottom edges flush), and
491
+ * the same nudge then pushes it *down* by the inset, lining the last sub-item
492
+ * up with the row. A cross-axis offset keeps its sign and leaves the end-aligned
493
+ * submenu twice the inset too high. One constant covers LTR and RTL. */
488
494
  const SUBMENU_ALIGN_OFFSET = -5
489
495
 
490
496
  /** Submenu root — a nested Ark Menu whose triggering row is `Menu.SubTrigger`.
491
497
  * Inherits the parent's portal settings via context (see `Menu.SubContent`).
492
498
  *
493
499
  * Ark's menu machine hard-overrides a submenu's placement and `gutter` (to `0`),
494
- * so a `gutter`-based offset is silently dropped. It leaves `offset` untouched,
495
- * and Floating UI resolves the axes as `offset.mainAxis ?? gutter` (the gap) and
496
- * `offset.crossAxis` (the top alignment) — so the whole `offset` object is the
497
- * one path that survives the override. */
500
+ * so a `gutter`-based offset is silently dropped. It leaves `offset`, `shift`
501
+ * and `flip` untouched: zag resolves the gap as `offset.mainAxis ?? gutter` and
502
+ * passes `shift` as Floating UI's `alignmentAxis` (see `SUBMENU_ALIGN_OFFSET`).
503
+ * The default `flip` already falls back to the end-aligned placement, then the
504
+ * other side. */
498
505
  const Sub = ({ offset = 10, children, ...rest }: MenuSubProps) => (
499
506
  <ArkMenu.Root
500
- positioning={{ offset: { mainAxis: offset, crossAxis: SUBMENU_ALIGN_OFFSET } }}
507
+ positioning={{ offset: { mainAxis: offset }, shift: SUBMENU_ALIGN_OFFSET }}
501
508
  navigate={clickLink}
502
509
  {...rest}
503
510
  >
@@ -0,0 +1,14 @@
1
+ "use client"
2
+
3
+ // `"use client"` must be the first line: tsup classifies entries by what
4
+ // consumers import (this barrel), and the bar runs timers in effects, so it
5
+ // can't render in a Server Component tree. Same as `progress/index.ts`.
6
+
7
+ export {
8
+ type GradientDir,
9
+ type GradientProps,
10
+ NavigationProgress,
11
+ type NavigationProgressProps,
12
+ type NavigationProgressSize,
13
+ type NavigationProgressVariant,
14
+ } from "./navigation-progress"