@42-central/ui-react 0.20.2 → 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 (85) 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-C74TV64U.js → chunk-4FEOMQYR.js} +4 -4
  4. package/dist/{chunk-C74TV64U.js.map → chunk-4FEOMQYR.js.map} +1 -1
  5. package/dist/{chunk-LFQDB5OD.js → chunk-D3JYDAUZ.js} +3 -3
  6. package/dist/{chunk-LFQDB5OD.js.map → chunk-D3JYDAUZ.js.map} +1 -1
  7. package/dist/{chunk-UVQXRDRO.js → chunk-DHJB4UJD.js} +3 -3
  8. package/dist/{chunk-UVQXRDRO.js.map → chunk-DHJB4UJD.js.map} +1 -1
  9. package/dist/{chunk-UCCJUFOG.js → chunk-DJAXXLN6.js} +3 -3
  10. package/dist/{chunk-UCCJUFOG.js.map → chunk-DJAXXLN6.js.map} +1 -1
  11. package/dist/{chunk-Z4MBCKG5.js → chunk-FB2G4LNH.js} +4 -4
  12. package/dist/{chunk-Z4MBCKG5.js.map → chunk-FB2G4LNH.js.map} +1 -1
  13. package/dist/{chunk-FDCPMUJK.js → chunk-IRNF274I.js} +3 -3
  14. package/dist/chunk-IRNF274I.js.map +1 -0
  15. package/dist/{chunk-O5W3QWJ6.js → chunk-J44FJ7PH.js} +3 -3
  16. package/dist/{chunk-O5W3QWJ6.js.map → chunk-J44FJ7PH.js.map} +1 -1
  17. package/dist/{chunk-WXL5RP6P.js → chunk-MRAJ45IM.js} +3 -3
  18. package/dist/{chunk-WXL5RP6P.js.map → chunk-MRAJ45IM.js.map} +1 -1
  19. package/dist/{chunk-45TG7H5Q.js → chunk-OZMSXYBX.js} +3 -3
  20. package/dist/{chunk-45TG7H5Q.js.map → chunk-OZMSXYBX.js.map} +1 -1
  21. package/dist/{chunk-37VQGKD6.js → chunk-SZEOTXRZ.js} +4 -4
  22. package/dist/{chunk-37VQGKD6.js.map → chunk-SZEOTXRZ.js.map} +1 -1
  23. package/dist/{chunk-2BNIHOMT.js → chunk-YPFSRZ3T.js} +3 -3
  24. package/dist/{chunk-2BNIHOMT.js.map → chunk-YPFSRZ3T.js.map} +1 -1
  25. package/dist/{chunk-5CNVVA7I.js → chunk-YWTOW7PZ.js} +4 -4
  26. package/dist/{chunk-5CNVVA7I.js.map → chunk-YWTOW7PZ.js.map} +1 -1
  27. package/dist/components/autocomplete/index.js +2 -2
  28. package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts +94 -0
  29. package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts.map +1 -0
  30. package/dist/components/calendar-heatmap/calendar-heatmap.d.ts +76 -0
  31. package/dist/components/calendar-heatmap/calendar-heatmap.d.ts.map +1 -0
  32. package/dist/components/calendar-heatmap/index.d.ts +2 -0
  33. package/dist/components/calendar-heatmap/index.d.ts.map +1 -0
  34. package/dist/components/calendar-heatmap/index.js +311 -0
  35. package/dist/components/calendar-heatmap/index.js.map +1 -0
  36. package/dist/components/camera/index.js +4 -4
  37. package/dist/components/clipboard/index.js +1 -1
  38. package/dist/components/combobox/index.js +2 -2
  39. package/dist/components/combobox-list/index.js +4 -4
  40. package/dist/components/data-table/index.js +13 -13
  41. package/dist/components/date-picker/index.js +5 -5
  42. package/dist/components/input/index.js +1 -1
  43. package/dist/components/input/input.d.ts.map +1 -1
  44. package/dist/components/menu/index.js +1 -1
  45. package/dist/components/menu/menu.d.ts +7 -5
  46. package/dist/components/menu/menu.d.ts.map +1 -1
  47. package/dist/components/multi-combobox-list/index.js +4 -4
  48. package/dist/components/multi-select/index.js +3 -3
  49. package/dist/components/navigation-progress/index.d.ts +2 -0
  50. package/dist/components/navigation-progress/index.d.ts.map +1 -0
  51. package/dist/components/navigation-progress/index.js +133 -0
  52. package/dist/components/navigation-progress/index.js.map +1 -0
  53. package/dist/components/navigation-progress/navigation-progress.d.ts +46 -0
  54. package/dist/components/navigation-progress/navigation-progress.d.ts.map +1 -0
  55. package/dist/components/number-input/index.js +2 -2
  56. package/dist/components/number-input/number-input.d.ts.map +1 -1
  57. package/dist/components/password-input/index.js +1 -1
  58. package/dist/components/photo-capture/index.js +4 -4
  59. package/dist/components/pills-input/index.js +2 -2
  60. package/dist/components/pin-input/index.js +1 -1
  61. package/dist/components/select/index.js +3 -3
  62. package/dist/components/spotlight/index.js +3 -3
  63. package/dist/components/tags-input/index.js +2 -2
  64. package/dist/components/text-input/index.js +1 -1
  65. package/dist/components/textarea/index.js +1 -1
  66. package/dist/components/time-input/index.js +3 -3
  67. package/dist/components/tree-multi-select/index.js +3 -3
  68. package/dist/components/tree-select/index.js +2 -2
  69. package/dist/index.js +2 -2
  70. package/package.json +1 -1
  71. package/src/as-child.contract.test.tsx +4 -0
  72. package/src/components/calendar-heatmap/calendar-heatmap-grid.test.ts +186 -0
  73. package/src/components/calendar-heatmap/calendar-heatmap-grid.ts +192 -0
  74. package/src/components/calendar-heatmap/calendar-heatmap.test.tsx +180 -0
  75. package/src/components/calendar-heatmap/calendar-heatmap.tsx +385 -0
  76. package/src/components/calendar-heatmap/index.ts +11 -0
  77. package/src/components/input/input.test.tsx +23 -0
  78. package/src/components/input/input.tsx +10 -6
  79. package/src/components/menu/menu.tsx +16 -9
  80. package/src/components/navigation-progress/index.ts +14 -0
  81. package/src/components/navigation-progress/navigation-progress.test.tsx +184 -0
  82. package/src/components/navigation-progress/navigation-progress.tsx +228 -0
  83. package/src/components/number-input/number-input.tsx +3 -4
  84. package/dist/chunk-45QRQKRC.js.map +0 -1
  85. package/dist/chunk-FDCPMUJK.js.map +0 -1
@@ -0,0 +1,385 @@
1
+ "use client"
2
+
3
+ import { ark, type HTMLArkProps } from "@ark-ui/react"
4
+ import { useLocaleContext } from "@ark-ui/react/locale"
5
+ import { useTooltipContext } from "@ark-ui/react/tooltip"
6
+ import { parseDate } from "@internationalized/date"
7
+ import { type CSSProperties, type KeyboardEvent, useMemo, useRef, useState } from "react"
8
+ import type { NoAsChild } from "../../lib/as-child"
9
+ import { cn } from "../../lib/cn"
10
+ import type { Color } from "../../lib/colors"
11
+ import { focusStyles } from "../../lib/focus-styles"
12
+ import { useLocale, useTimeZone } from "../../lib/intl"
13
+ import { props } from "../../lib/props"
14
+ import type { WithTestId } from "../../lib/test-id"
15
+ import { TEXT_COLOR_CLASSES } from "../../lib/typography-size"
16
+ import { useIsomorphicLayoutEffect } from "../../lib/use-isomorphic-layout-effect"
17
+ import { isNowPending, useNow } from "../../lib/use-now"
18
+ import type { FirstDayOfWeek } from "../schedule/schedule-types"
19
+ import { Tooltip } from "../tooltip"
20
+ import {
21
+ buildHeatmap,
22
+ type CalendarHeatmapDatum,
23
+ type CalendarHeatmapThresholds,
24
+ defaultRange,
25
+ type HeatmapDay,
26
+ intensity,
27
+ legendLevels,
28
+ nextHeatmapDay,
29
+ } from "./calendar-heatmap-grid"
30
+
31
+ export type { CalendarHeatmapDatum, CalendarHeatmapThresholds }
32
+
33
+ /**
34
+ * Everything the heatmap says that `Intl` can't: the grid's name, the legend's
35
+ * ends, and the sentence that names a day. Dates, weekdays, months and numbers
36
+ * are never here, they come from the resolved locale.
37
+ */
38
+ export type CalendarHeatmapTranslations = {
39
+ /** The grid's accessible name. */
40
+ label: string
41
+ /** A day's tooltip and accessible name. One sentence, so word order is the
42
+ * translation's own: "3 activités le lundi 26 octobre 2026". */
43
+ day: (details: { value: number; formattedValue: string; formattedDate: string }) => string
44
+ less: string
45
+ more: string
46
+ }
47
+
48
+ export const CALENDAR_HEATMAP_DEFAULT_TRANSLATIONS: CalendarHeatmapTranslations = {
49
+ label: "Activity",
50
+ day: ({ value, formattedValue, formattedDate }) =>
51
+ value === 0
52
+ ? `No activity on ${formattedDate}`
53
+ : `${formattedValue} ${value === 1 ? "activity" : "activities"} on ${formattedDate}`,
54
+ less: "Less",
55
+ more: "More",
56
+ }
57
+
58
+ export type CalendarHeatmapClassNames = {
59
+ grid?: string
60
+ cell?: string
61
+ legend?: string
62
+ tooltip?: string
63
+ }
64
+
65
+ export type CalendarHeatmapProps = Omit<NoAsChild<HTMLArkProps<"div">>, "color" | "children"> &
66
+ WithTestId & {
67
+ /** One entry per day, or per event: entries on the same day add up. */
68
+ data: readonly CalendarHeatmapDatum[]
69
+ /** The first and last day shown, both included. Defaults to the year ending today. */
70
+ range?: { start: Date; end: Date }
71
+ /** The ramp's palette. Inherits the nearest `data-color` when omitted. */
72
+ color?: Color
73
+ /**
74
+ * Lower bounds of levels 1 to 4, ascending: `[1, 5, 10, 20]` paints 1–4
75
+ * at level 1 and 20 or more at level 4. One to four of them, never more:
76
+ * past four steps a reader can't rank the shades. Defaults to the busiest
77
+ * day split into quarters.
78
+ */
79
+ thresholds?: CalendarHeatmapThresholds
80
+ /** The day each column starts on. Defaults to the locale's. */
81
+ startOfWeek?: FirstDayOfWeek
82
+ /** BCP-47 tag, or `"auto"`. Inherits `IntlProvider`'s when omitted. */
83
+ locale?: "auto" | (string & {})
84
+ /** IANA zone the data's instants are bucketed in, or `"auto"`. Inherits `IntlProvider`'s. */
85
+ timeZone?: "auto" | (string & {})
86
+ /** Makes days activatable, by click, Enter or Space. */
87
+ onDayClick?: (date: Date, value: number) => void
88
+ translations?: Partial<CalendarHeatmapTranslations>
89
+ classNames?: CalendarHeatmapClassNames
90
+ }
91
+
92
+ /**
93
+ * The four-step ramp, as whole class literals so Tailwind sees every one.
94
+ * Each step is the palette's solid at a growing strength, so any `color`,
95
+ * custom palettes included, makes its own ramp; step 0 is the kit's neutral
96
+ * no-data ground.
97
+ *
98
+ * Forced colors drop every background, so there intensity becomes size: a
99
+ * `Highlight` square that grows with the step inside a `CanvasText` frame.
100
+ */
101
+ const RAMP = [
102
+ "bg-brand-900/6 dark:bg-white/8",
103
+ "bg-(--c-solid)/30 before:inset-[35%]",
104
+ "bg-(--c-solid)/55 before:inset-[24%]",
105
+ "bg-(--c-solid)/80 before:inset-[12%]",
106
+ "bg-(--c-solid) before:inset-0",
107
+ ]
108
+
109
+ const swatch = cn(
110
+ "relative block aspect-square rounded-xxs",
111
+ "forced-colors:border forced-colors:border-[CanvasText] forced-colors:bg-[Canvas]",
112
+ "before:absolute before:hidden before:bg-[Highlight] forced-colors:before:block",
113
+ "forced-colors:forced-color-adjust-none",
114
+ )
115
+
116
+ /** `NumberFormat#formatRange` is ES2023, and the kit's `lib` stops at ES2022. */
117
+ type RangeNumberFormat = Intl.NumberFormat & { formatRange(start: number, end: number): string }
118
+
119
+ const caption = cn("text-xs leading-none", TEXT_COLOR_CLASSES.muted)
120
+
121
+ /**
122
+ * Figma's cell and gap, as custom properties so a consumer can resize the
123
+ * whole heatmap from `className`: `className="[--cell:10px] [--gap:3px]"`.
124
+ * The squares never stretch or shrink with the container; a range longer
125
+ * than it has room for scrolls instead, whatever its length.
126
+ */
127
+ const SIZE = "[--cell:0.75rem] [--gap:0.25rem]"
128
+
129
+ /** The month row, then seven day rows: shared by the grid and the weekday labels beside it, which is what lines them up. */
130
+ const TRACKS = "grid grid-rows-[auto_repeat(7,var(--cell))] gap-(--gap)"
131
+
132
+ /**
133
+ * A GitHub-style activity grid: one square per day, a column per week, the
134
+ * shade saying how much happened.
135
+ *
136
+ * <CalendarHeatmap data={commits} color="green" />
137
+ *
138
+ * It is a real ARIA grid: one tab stop, arrows move a day (↑↓) or a week
139
+ * (←→, mirrored in RTL), Home/End go along the row, Ctrl+Home/End to the
140
+ * ends, PageUp/PageDown a month. Every day is named in full ("3 activities on
141
+ * Monday, October 26, 2026"), and one shared tooltip follows hover and focus.
142
+ *
143
+ * The squares keep their size: a range wider than the container scrolls, the
144
+ * latest week in view and the weekday labels pinned beside it.
145
+ */
146
+ export const CalendarHeatmap = ({
147
+ data,
148
+ range,
149
+ color,
150
+ thresholds,
151
+ startOfWeek,
152
+ locale: localeProp,
153
+ timeZone: timeZoneProp,
154
+ onDayClick,
155
+ translations,
156
+ className,
157
+ classNames,
158
+ style,
159
+ testId,
160
+ ...rest
161
+ }: CalendarHeatmapProps) => {
162
+ const locale = useLocale(localeProp)
163
+ const timeZone = useTimeZone(timeZoneProp)
164
+ const { dir } = useLocaleContext()
165
+ const t = { ...CALENDAR_HEATMAP_DEFAULT_TRANSLATIONS, ...translations }
166
+
167
+ // The default range ends today, which the server can't know: until the
168
+ // client clock arrives the grid renders empty, so the markup still matches.
169
+ const now = useNow()
170
+ const pending = !range && isNowPending(now)
171
+ const { start, end } = range ?? defaultRange(now, timeZone)
172
+ // Compared by instant, so an inline `range={{ start, end }}` or the default
173
+ // range's minute tick doesn't rebuild an unchanged grid.
174
+ const startTime = start.getTime()
175
+ const endTime = end.getTime()
176
+
177
+ const layout = useMemo(
178
+ () =>
179
+ buildHeatmap({
180
+ data,
181
+ start: new Date(startTime),
182
+ end: new Date(endTime),
183
+ timeZone,
184
+ locale,
185
+ startOfWeek,
186
+ thresholds,
187
+ }),
188
+ [data, startTime, endTime, timeZone, locale, startOfWeek, thresholds],
189
+ )
190
+ const { weeks, months, weekdays, first, last } = layout
191
+ const levels = layout.thresholds.length
192
+
193
+ const format = useMemo(
194
+ () => ({
195
+ number: new Intl.NumberFormat(locale) as RangeNumberFormat,
196
+ date: new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone }),
197
+ month: new Intl.DateTimeFormat(locale, { month: "short", timeZone }),
198
+ weekday: new Intl.DateTimeFormat(locale, { weekday: "short", timeZone }),
199
+ weekdayLong: new Intl.DateTimeFormat(locale, { weekday: "long", timeZone }),
200
+ }),
201
+ [locale, timeZone],
202
+ )
203
+ const describe = (day: HeatmapDay) =>
204
+ t.day({
205
+ value: day.value,
206
+ formattedValue: format.number.format(day.value),
207
+ formattedDate: format.date.format(day.date),
208
+ })
209
+
210
+ // Roving tab stop: the last focused day, else the latest one.
211
+ const [focused, setFocused] = useState<string | null>(null)
212
+ const stop =
213
+ focused && focused >= first.toString() && focused <= last.toString() ? focused : last.toString()
214
+
215
+ const gridRef = useRef<HTMLDivElement>(null)
216
+ const scrollerRef = useRef<HTMLDivElement>(null)
217
+
218
+ // Open on the latest week when the grid is wider than its container. By
219
+ // delta, not to an absolute position, so RTL's negative scroll works too.
220
+ useIsomorphicLayoutEffect(() => {
221
+ const scroller = scrollerRef.current
222
+ if (!scroller) return
223
+ scroller.scrollLeft += dir === "rtl" ? -scroller.scrollWidth : scroller.scrollWidth
224
+ }, [dir, weeks.length, pending])
225
+
226
+ const onKeyDown = (event: KeyboardEvent<HTMLElement>, day: HeatmapDay, column: number) => {
227
+ if (onDayClick && (event.key === "Enter" || event.key === " ")) {
228
+ event.preventDefault()
229
+ onDayClick(day.date, day.value)
230
+ return
231
+ }
232
+ const target = nextHeatmapDay(event.key, parseDate(day.key), {
233
+ dir,
234
+ ctrlKey: event.ctrlKey || event.metaKey,
235
+ column,
236
+ columns: weeks.length,
237
+ first,
238
+ last,
239
+ })
240
+ if (!target) return
241
+ // The scroller would scroll on an unhandled arrow.
242
+ event.preventDefault()
243
+ const key = target.toString()
244
+ setFocused(key)
245
+ gridRef.current?.querySelector<HTMLElement>(`[data-date="${key}"]`)?.focus()
246
+ }
247
+
248
+ return (
249
+ <ark.div
250
+ data-color={color}
251
+ // As wide as the weeks need and no wider, so the legend ends where they
252
+ // do; capped at the container, past which the weeks scroll.
253
+ className={cn("flex w-fit max-w-full min-w-0 flex-col gap-3", SIZE, className)}
254
+ style={{ "--weeks": weeks.length, ...style } as CSSProperties}
255
+ {...props({ "data-testid": testId })}
256
+ {...rest}
257
+ >
258
+ <div className="flex">
259
+ {/* The weekday labels sit outside the scroller, so they stay in view
260
+ however far back the weeks are scrolled. Fixed tracks line them up
261
+ with the rows; the screen-reader row headers live in the grid. */}
262
+ <div aria-hidden className={cn(caption, TRACKS, "shrink-0 grid-cols-[auto] py-1 pe-2")}>
263
+ <span>&nbsp;</span>
264
+ {weekdays.map((weekday, row) => (
265
+ <span key={weekday.getTime()} className="flex items-center">
266
+ {/* Every other row, like a paper calendar: seven labels crowd. */}
267
+ {row % 2 === 1 && format.weekday.format(weekday)}
268
+ </span>
269
+ ))}
270
+ </div>
271
+
272
+ <Tooltip.Root openDelay={150} closeDelay={0}>
273
+ {/* Padded so the focus ring isn't clipped by the scroll edge. */}
274
+ <div ref={scrollerRef} className="min-w-0 overflow-x-auto p-1">
275
+ {/* biome-ignore lint/a11y/useSemanticElements: ARIA grid on divs, not a <table>: the cells are laid out on CSS grid tracks (rows are subgrids), and table elements lose their implicit semantics in some engines once their display changes. */}
276
+ <div
277
+ ref={gridRef}
278
+ role="grid"
279
+ aria-label={t.label}
280
+ aria-busy={pending || undefined}
281
+ className={cn(
282
+ TRACKS,
283
+ "w-max grid-cols-[repeat(var(--weeks),var(--cell))]",
284
+ classNames?.grid,
285
+ )}
286
+ >
287
+ {/* Each day's own name carries its date, so the month row is visual only. */}
288
+ <div aria-hidden className={cn(caption, "col-span-full grid grid-cols-subgrid")}>
289
+ <span>&nbsp;</span>
290
+ {!pending &&
291
+ months.map(({ column, date }) => (
292
+ <span
293
+ key={column}
294
+ className="row-start-1 whitespace-nowrap"
295
+ style={{ gridColumnStart: column + 1 }}
296
+ >
297
+ {format.month.format(date)}
298
+ </span>
299
+ ))}
300
+ </div>
301
+ {weekdays.map((weekday, row) => (
302
+ // biome-ignore lint/a11y/useSemanticElements lint/a11y/useFocusableInteractive: ARIA grid on divs, not a <table>: the cells are laid out on CSS grid tracks (rows are subgrids), and table elements lose their implicit semantics in some engines once their display changes; only cells take focus in the grid pattern.
303
+ <div
304
+ key={weekday.getTime()}
305
+ role="row"
306
+ className="col-span-full grid grid-cols-subgrid"
307
+ >
308
+ {/* biome-ignore lint/a11y/useSemanticElements lint/a11y/useFocusableInteractive: ARIA grid on divs, not a <table>: the cells are laid out on CSS grid tracks (rows are subgrids), and table elements lose their implicit semantics in some engines once their display changes; a header is read, not focused. */}
309
+ <div role="rowheader" className="sr-only">
310
+ {format.weekdayLong.format(weekday)}
311
+ </div>
312
+ {weeks.map((week, column) => {
313
+ const day = week[row]
314
+ // biome-ignore lint/suspicious/noArrayIndexKey lint/a11y/useSemanticElements lint/a11y/useFocusableInteractive: a padding slot has no date, so its column is its identity, and nothing to focus; ARIA grid on divs, not a <table>: the cells are laid out on CSS grid tracks (rows are subgrids), and table elements lose their implicit semantics in some engines once their display changes.
315
+ if (!day || pending) return <div key={column} role="gridcell" />
316
+ return (
317
+ <Tooltip.Trigger key={day.key} asChild value={day.key}>
318
+ {/* biome-ignore lint/a11y/useSemanticElements: ARIA grid on divs, not a <table>: the cells are laid out on CSS grid tracks (rows are subgrids), and table elements lose their implicit semantics in some engines once their display changes. */}
319
+ <div
320
+ role="gridcell"
321
+ tabIndex={day.key === stop ? 0 : -1}
322
+ // The tooltip repeats the day's own name, so it mustn't describe it too.
323
+ aria-describedby={undefined}
324
+ data-date={day.key}
325
+ data-level={day.level}
326
+ className={cn(
327
+ swatch,
328
+ RAMP[intensity(day.level, levels)],
329
+ focusStyles(),
330
+ // Focus scrolls a cell into view: leave room for its ring.
331
+ "scroll-m-1",
332
+ onDayClick && "cursor-pointer",
333
+ classNames?.cell,
334
+ )}
335
+ onFocus={() => setFocused(day.key)}
336
+ onKeyDown={(event) => onKeyDown(event, day, column)}
337
+ onClick={onDayClick && (() => onDayClick(day.date, day.value))}
338
+ >
339
+ <span className="sr-only">{describe(day)}</span>
340
+ </div>
341
+ </Tooltip.Trigger>
342
+ )
343
+ })}
344
+ </div>
345
+ ))}
346
+ </div>
347
+ </div>
348
+ <Tooltip.Content aria-hidden className={classNames?.tooltip}>
349
+ <DayTooltip weeks={weeks} describe={describe} />
350
+ </Tooltip.Content>
351
+ </Tooltip.Root>
352
+ </div>
353
+
354
+ <div className={cn(caption, "flex items-center justify-end gap-1", classNames?.legend)}>
355
+ <span className="me-1">{t.less}</span>
356
+ {legendLevels(layout.thresholds).map(({ level, min, max }) => (
357
+ <span key={level} className={cn(swatch, "size-(--cell)", RAMP[intensity(level, levels)])}>
358
+ <span className="sr-only">
359
+ {max === null
360
+ ? `${format.number.format(min)}+`
361
+ : max - min <= 1
362
+ ? format.number.format(min)
363
+ : // NFKC: server and browser ICU disagree on the dash's spacing.
364
+ format.number.formatRange(min, max - 1).normalize("NFKC")}
365
+ </span>
366
+ </span>
367
+ ))}
368
+ <span className="ms-1">{t.more}</span>
369
+ </div>
370
+ </ark.div>
371
+ )
372
+ }
373
+
374
+ /** The shared tooltip's text: whichever day's trigger it is showing for. */
375
+ const DayTooltip = ({
376
+ weeks,
377
+ describe,
378
+ }: {
379
+ weeks: (HeatmapDay | null)[][]
380
+ describe: (day: HeatmapDay) => string
381
+ }) => {
382
+ const { triggerValue } = useTooltipContext()
383
+ const day = weeks.flat().find((candidate) => candidate?.key === triggerValue)
384
+ return day ? describe(day) : null
385
+ }
@@ -0,0 +1,11 @@
1
+ "use client"
2
+
3
+ export {
4
+ CALENDAR_HEATMAP_DEFAULT_TRANSLATIONS,
5
+ CalendarHeatmap,
6
+ type CalendarHeatmapClassNames,
7
+ type CalendarHeatmapDatum,
8
+ type CalendarHeatmapProps,
9
+ type CalendarHeatmapThresholds,
10
+ type CalendarHeatmapTranslations,
11
+ } from "./calendar-heatmap"
@@ -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"