@42-central/ui-react 0.20.2 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-45QRQKRC.js → chunk-3L5GLI67.js} +12 -8
- package/dist/chunk-3L5GLI67.js.map +1 -0
- package/dist/{chunk-C74TV64U.js → chunk-4FEOMQYR.js} +4 -4
- package/dist/{chunk-C74TV64U.js.map → chunk-4FEOMQYR.js.map} +1 -1
- package/dist/{chunk-LFQDB5OD.js → chunk-D3JYDAUZ.js} +3 -3
- package/dist/{chunk-LFQDB5OD.js.map → chunk-D3JYDAUZ.js.map} +1 -1
- package/dist/{chunk-UVQXRDRO.js → chunk-DHJB4UJD.js} +3 -3
- package/dist/{chunk-UVQXRDRO.js.map → chunk-DHJB4UJD.js.map} +1 -1
- package/dist/{chunk-UCCJUFOG.js → chunk-F2FSHVO5.js} +3 -3
- package/dist/{chunk-UCCJUFOG.js.map → chunk-F2FSHVO5.js.map} +1 -1
- package/dist/{chunk-Z4MBCKG5.js → chunk-FB2G4LNH.js} +4 -4
- package/dist/{chunk-Z4MBCKG5.js.map → chunk-FB2G4LNH.js.map} +1 -1
- package/dist/{chunk-FDCPMUJK.js → chunk-IRNF274I.js} +3 -3
- package/dist/chunk-IRNF274I.js.map +1 -0
- package/dist/{chunk-O5W3QWJ6.js → chunk-J44FJ7PH.js} +3 -3
- package/dist/{chunk-O5W3QWJ6.js.map → chunk-J44FJ7PH.js.map} +1 -1
- package/dist/{chunk-WXL5RP6P.js → chunk-MRAJ45IM.js} +3 -3
- package/dist/{chunk-WXL5RP6P.js.map → chunk-MRAJ45IM.js.map} +1 -1
- package/dist/{chunk-45TG7H5Q.js → chunk-OZMSXYBX.js} +3 -3
- package/dist/{chunk-45TG7H5Q.js.map → chunk-OZMSXYBX.js.map} +1 -1
- package/dist/{chunk-37VQGKD6.js → chunk-SZEOTXRZ.js} +4 -4
- package/dist/{chunk-37VQGKD6.js.map → chunk-SZEOTXRZ.js.map} +1 -1
- package/dist/{chunk-2BNIHOMT.js → chunk-YPFSRZ3T.js} +3 -3
- package/dist/{chunk-2BNIHOMT.js.map → chunk-YPFSRZ3T.js.map} +1 -1
- package/dist/{chunk-5CNVVA7I.js → chunk-YWTOW7PZ.js} +4 -4
- package/dist/{chunk-5CNVVA7I.js.map → chunk-YWTOW7PZ.js.map} +1 -1
- package/dist/components/autocomplete/index.js +2 -2
- package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts +94 -0
- package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts.map +1 -0
- package/dist/components/calendar-heatmap/calendar-heatmap.d.ts +76 -0
- package/dist/components/calendar-heatmap/calendar-heatmap.d.ts.map +1 -0
- package/dist/components/calendar-heatmap/index.d.ts +2 -0
- package/dist/components/calendar-heatmap/index.d.ts.map +1 -0
- package/dist/components/calendar-heatmap/index.js +311 -0
- package/dist/components/calendar-heatmap/index.js.map +1 -0
- package/dist/components/camera/index.js +4 -4
- package/dist/components/clipboard/index.js +1 -1
- package/dist/components/combobox/index.js +2 -2
- package/dist/components/combobox-list/index.js +4 -4
- package/dist/components/data-table/index.js +13 -13
- package/dist/components/date-picker/index.js +5 -5
- package/dist/components/geodesic/a11y.d.ts +15 -0
- package/dist/components/geodesic/a11y.d.ts.map +1 -0
- package/dist/components/geodesic/activity-badge.d.ts +5 -0
- package/dist/components/geodesic/activity-badge.d.ts.map +1 -0
- package/dist/components/geodesic/badge-frame.d.ts +60 -0
- package/dist/components/geodesic/badge-frame.d.ts.map +1 -0
- package/dist/components/geodesic/exam-badge.d.ts +5 -0
- package/dist/components/geodesic/exam-badge.d.ts.map +1 -0
- package/dist/components/geodesic/geometry.d.ts +1089 -0
- package/dist/components/geodesic/geometry.d.ts.map +1 -0
- package/dist/components/geodesic/gift-box-badge.d.ts +5 -0
- package/dist/components/geodesic/gift-box-badge.d.ts.map +1 -0
- package/dist/components/geodesic/gift-token.d.ts +23 -0
- package/dist/components/geodesic/gift-token.d.ts.map +1 -0
- package/dist/components/geodesic/glyph-slot.d.ts +8 -0
- package/dist/components/geodesic/glyph-slot.d.ts.map +1 -0
- package/dist/components/geodesic/index.d.ts +12 -0
- package/dist/components/geodesic/index.d.ts.map +1 -0
- package/dist/components/geodesic/index.js +917 -0
- package/dist/components/geodesic/index.js.map +1 -0
- package/dist/components/geodesic/module-badge.d.ts +5 -0
- package/dist/components/geodesic/module-badge.d.ts.map +1 -0
- package/dist/components/geodesic/planet.d.ts +30 -0
- package/dist/components/geodesic/planet.d.ts.map +1 -0
- package/dist/components/geodesic/project-badge.d.ts +5 -0
- package/dist/components/geodesic/project-badge.d.ts.map +1 -0
- package/dist/components/geodesic/skill-badge.d.ts +5 -0
- package/dist/components/geodesic/skill-badge.d.ts.map +1 -0
- package/dist/components/geodesic/social-badge.d.ts +8 -0
- package/dist/components/geodesic/social-badge.d.ts.map +1 -0
- package/dist/components/geodesic/status.d.ts +80 -0
- package/dist/components/geodesic/status.d.ts.map +1 -0
- package/dist/components/geodesic/styles.css +146 -0
- package/dist/components/input/index.js +1 -1
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/menu.d.ts +7 -5
- package/dist/components/menu/menu.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.js +4 -4
- package/dist/components/multi-select/index.js +3 -3
- package/dist/components/navigation-progress/index.d.ts +2 -0
- package/dist/components/navigation-progress/index.d.ts.map +1 -0
- package/dist/components/navigation-progress/index.js +133 -0
- package/dist/components/navigation-progress/index.js.map +1 -0
- package/dist/components/navigation-progress/navigation-progress.d.ts +46 -0
- package/dist/components/navigation-progress/navigation-progress.d.ts.map +1 -0
- package/dist/components/number-input/index.js +2 -2
- package/dist/components/number-input/number-input.d.ts.map +1 -1
- package/dist/components/password-input/index.js +1 -1
- package/dist/components/photo-capture/index.js +4 -4
- package/dist/components/pills-input/index.js +2 -2
- package/dist/components/pin-input/index.js +1 -1
- package/dist/components/select/index.js +3 -3
- package/dist/components/spotlight/index.js +3 -3
- package/dist/components/tags-input/index.js +2 -2
- package/dist/components/text-input/index.js +1 -1
- package/dist/components/textarea/index.js +1 -1
- package/dist/components/time-input/index.js +3 -3
- package/dist/components/tree-multi-select/index.js +3 -3
- package/dist/components/tree-select/index.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -1
- package/src/as-child.contract.test.tsx +6 -0
- package/src/components/calendar-heatmap/calendar-heatmap-grid.test.ts +186 -0
- package/src/components/calendar-heatmap/calendar-heatmap-grid.ts +192 -0
- package/src/components/calendar-heatmap/calendar-heatmap.test.tsx +180 -0
- package/src/components/calendar-heatmap/calendar-heatmap.tsx +385 -0
- package/src/components/calendar-heatmap/index.ts +11 -0
- package/src/components/geodesic/a11y.ts +10 -0
- package/src/components/geodesic/activity-badge.tsx +17 -0
- package/src/components/geodesic/badge-frame.tsx +324 -0
- package/src/components/geodesic/exam-badge.tsx +17 -0
- package/src/components/geodesic/geometry.test.ts +60 -0
- package/src/components/geodesic/geometry.ts +367 -0
- package/src/components/geodesic/gift-box-badge.tsx +17 -0
- package/src/components/geodesic/gift-token.tsx +104 -0
- package/src/components/geodesic/glyph-slot.tsx +28 -0
- package/src/components/geodesic/index.ts +13 -0
- package/src/components/geodesic/module-badge.tsx +17 -0
- package/src/components/geodesic/planet.tsx +131 -0
- package/src/components/geodesic/project-badge.tsx +17 -0
- package/src/components/geodesic/skill-badge.tsx +17 -0
- package/src/components/geodesic/social-badge.tsx +21 -0
- package/src/components/geodesic/status.test.ts +66 -0
- package/src/components/geodesic/status.ts +176 -0
- package/src/components/geodesic/styles.css +146 -0
- package/src/components/input/input.test.tsx +23 -0
- package/src/components/input/input.tsx +10 -6
- package/src/components/menu/menu.tsx +16 -9
- package/src/components/navigation-progress/index.ts +14 -0
- package/src/components/navigation-progress/navigation-progress.test.tsx +184 -0
- package/src/components/navigation-progress/navigation-progress.tsx +228 -0
- package/src/components/number-input/number-input.tsx +3 -4
- package/src/icon-stroke.test.tsx +5 -0
- package/dist/chunk-45QRQKRC.js.map +0 -1
- package/dist/chunk-FDCPMUJK.js.map +0 -1
|
@@ -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
|
|
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.
|
|
486
|
-
*
|
|
487
|
-
*
|
|
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`
|
|
495
|
-
* and
|
|
496
|
-
* `
|
|
497
|
-
*
|
|
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,
|
|
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"
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { act, render } from "@testing-library/react"
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
|
|
3
|
+
import {
|
|
4
|
+
COMPLETE_HOLD,
|
|
5
|
+
FADE_DURATION,
|
|
6
|
+
NavigationProgress,
|
|
7
|
+
type NavigationProgressProps,
|
|
8
|
+
TRICKLE_CAP,
|
|
9
|
+
TRICKLE_INTERVAL,
|
|
10
|
+
} from "./navigation-progress"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The bar is timer-driven, so every test runs on fake timers and advances
|
|
14
|
+
* them inside `act`. The fill is the root's only child; its `clip-path` reveal
|
|
15
|
+
* is the progress and its opacity class is the visibility.
|
|
16
|
+
*/
|
|
17
|
+
type Extra = Omit<NavigationProgressProps, "loading" | "testId">
|
|
18
|
+
|
|
19
|
+
/** The progress, read back from the fill's `clip-path: inset(0 <100 - value>% 0 0)`. */
|
|
20
|
+
const revealed = (el: HTMLElement) => {
|
|
21
|
+
const right = /inset\(0(?:px)? ([\d.]+)%/.exec(el.style.clipPath)?.[1]
|
|
22
|
+
return 100 - Number.parseFloat(right ?? "100")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const setup = (loading: boolean, extra: Extra = {}) => {
|
|
26
|
+
const view = render(<NavigationProgress loading={loading} testId="np" {...extra} />)
|
|
27
|
+
const root = view.getByTestId("np")
|
|
28
|
+
const fill = () => root.firstElementChild as HTMLElement
|
|
29
|
+
return {
|
|
30
|
+
root,
|
|
31
|
+
fill,
|
|
32
|
+
width: () => revealed(fill()),
|
|
33
|
+
visible: () => fill().className.includes("opacity-100"),
|
|
34
|
+
rerender: (next: boolean) =>
|
|
35
|
+
view.rerender(<NavigationProgress loading={next} testId="np" {...extra} />),
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const advance = (ms: number) => act(() => vi.advanceTimersByTime(ms))
|
|
40
|
+
|
|
41
|
+
const mockReducedMotion = (matches: boolean) => {
|
|
42
|
+
vi.spyOn(window, "matchMedia").mockImplementation(
|
|
43
|
+
(query: string) =>
|
|
44
|
+
({
|
|
45
|
+
matches: matches && query.includes("prefers-reduced-motion"),
|
|
46
|
+
media: query,
|
|
47
|
+
onchange: null,
|
|
48
|
+
addEventListener: () => {},
|
|
49
|
+
removeEventListener: () => {},
|
|
50
|
+
addListener: () => {},
|
|
51
|
+
removeListener: () => {},
|
|
52
|
+
dispatchEvent: () => false,
|
|
53
|
+
}) as MediaQueryList,
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe("NavigationProgress", () => {
|
|
58
|
+
beforeEach(() => vi.useFakeTimers())
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
vi.useRealTimers()
|
|
61
|
+
vi.restoreAllMocks()
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it("is hidden and decorative at rest", () => {
|
|
65
|
+
const bar = setup(false)
|
|
66
|
+
expect(bar.visible()).toBe(false)
|
|
67
|
+
expect(bar.root.getAttribute("aria-hidden")).toBe("true")
|
|
68
|
+
expect(bar.root.getAttribute("data-state")).toBe("idle")
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it("shows nothing for a load shorter than the delay", () => {
|
|
72
|
+
const bar = setup(true, { delay: 150 })
|
|
73
|
+
advance(100)
|
|
74
|
+
bar.rerender(false)
|
|
75
|
+
advance(2000)
|
|
76
|
+
expect(bar.visible()).toBe(false)
|
|
77
|
+
expect(bar.width()).toBe(0)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it("appears after the delay and trickles toward the cap without reaching it", () => {
|
|
81
|
+
const bar = setup(true, { delay: 150 })
|
|
82
|
+
advance(150)
|
|
83
|
+
expect(bar.visible()).toBe(true)
|
|
84
|
+
const first = bar.width()
|
|
85
|
+
|
|
86
|
+
advance(TRICKLE_INTERVAL * 5)
|
|
87
|
+
const later = bar.width()
|
|
88
|
+
expect(later).toBeGreaterThan(first)
|
|
89
|
+
|
|
90
|
+
advance(60_000)
|
|
91
|
+
expect(bar.width()).toBeLessThan(TRICKLE_CAP)
|
|
92
|
+
expect(bar.width()).toBeGreaterThan(TRICKLE_CAP - 1)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it("slows down as it fills", () => {
|
|
96
|
+
const bar = setup(true, { delay: 0 })
|
|
97
|
+
advance(0)
|
|
98
|
+
const a = bar.width()
|
|
99
|
+
advance(TRICKLE_INTERVAL)
|
|
100
|
+
const b = bar.width()
|
|
101
|
+
advance(TRICKLE_INTERVAL * 20)
|
|
102
|
+
const c = bar.width()
|
|
103
|
+
advance(TRICKLE_INTERVAL)
|
|
104
|
+
const d = bar.width()
|
|
105
|
+
expect(d - c).toBeLessThan(b - a)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it("completes to 100%, fades, then resets to 0", () => {
|
|
109
|
+
const bar = setup(true, { delay: 0 })
|
|
110
|
+
advance(TRICKLE_INTERVAL * 3)
|
|
111
|
+
bar.rerender(false)
|
|
112
|
+
expect(bar.width()).toBe(100)
|
|
113
|
+
expect(bar.visible()).toBe(true)
|
|
114
|
+
expect(bar.root.getAttribute("data-state")).toBe("complete")
|
|
115
|
+
|
|
116
|
+
advance(COMPLETE_HOLD)
|
|
117
|
+
expect(bar.visible()).toBe(false)
|
|
118
|
+
expect(bar.width()).toBe(100)
|
|
119
|
+
|
|
120
|
+
advance(FADE_DURATION)
|
|
121
|
+
expect(bar.width()).toBe(0)
|
|
122
|
+
expect(bar.root.getAttribute("data-state")).toBe("idle")
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it("keeps going from where it is when loading resumes mid-run", () => {
|
|
126
|
+
const bar = setup(true, { delay: 0 })
|
|
127
|
+
advance(TRICKLE_INTERVAL * 5)
|
|
128
|
+
const before = bar.width()
|
|
129
|
+
bar.rerender(false)
|
|
130
|
+
bar.rerender(true)
|
|
131
|
+
// Caught at 100%: restarts from the sliver, without waiting for the delay.
|
|
132
|
+
expect(bar.visible()).toBe(true)
|
|
133
|
+
expect(bar.width()).toBeLessThan(before)
|
|
134
|
+
advance(TRICKLE_INTERVAL)
|
|
135
|
+
expect(bar.width()).toBeGreaterThan(0)
|
|
136
|
+
expect(bar.width()).toBeLessThan(100)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it("under reduced motion, sits full width without trickling and hides when done", () => {
|
|
140
|
+
mockReducedMotion(true)
|
|
141
|
+
const bar = setup(true, { delay: 0 })
|
|
142
|
+
advance(0)
|
|
143
|
+
expect(bar.width()).toBe(100)
|
|
144
|
+
advance(TRICKLE_INTERVAL * 5)
|
|
145
|
+
expect(bar.width()).toBe(100)
|
|
146
|
+
|
|
147
|
+
bar.rerender(false)
|
|
148
|
+
advance(0)
|
|
149
|
+
expect(bar.visible()).toBe(false)
|
|
150
|
+
advance(FADE_DURATION)
|
|
151
|
+
expect(bar.width()).toBe(0)
|
|
152
|
+
})
|
|
153
|
+
it("paints the palette through data-color by default", () => {
|
|
154
|
+
const bar = setup(false, { color: "green" })
|
|
155
|
+
expect(bar.root.getAttribute("data-color")).toBe("green")
|
|
156
|
+
expect(bar.fill().className).toContain("bg-(--c-solid)")
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it("paints a full-width gradient from the gradient prop, ignoring color", () => {
|
|
160
|
+
const bar = setup(true, {
|
|
161
|
+
delay: 0,
|
|
162
|
+
variant: "gradient",
|
|
163
|
+
color: "green",
|
|
164
|
+
gradient: { from: "red", via: "gold", to: "blue", dir: "to-l" },
|
|
165
|
+
})
|
|
166
|
+
advance(TRICKLE_INTERVAL * 3)
|
|
167
|
+
const fill = bar.fill()
|
|
168
|
+
expect(bar.root.hasAttribute("data-color")).toBe(false)
|
|
169
|
+
expect(fill.className).toContain("bg-linear-to-l")
|
|
170
|
+
expect(fill.className).toContain("w-full")
|
|
171
|
+
expect(fill.style.getPropertyValue("--tw-gradient-from")).toBe("red")
|
|
172
|
+
expect(fill.style.getPropertyValue("--tw-gradient-via")).toBe("gold")
|
|
173
|
+
expect(fill.style.getPropertyValue("--tw-gradient-to")).toBe("blue")
|
|
174
|
+
// Progress is a reveal, not a resize, so the gradient never re-stretches.
|
|
175
|
+
expect(fill.style.width).toBe("")
|
|
176
|
+
expect(bar.width()).toBeGreaterThan(0)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it("falls back to the default stops and direction for a bare gradient", () => {
|
|
180
|
+
const bar = setup(false, { variant: "gradient" })
|
|
181
|
+
expect(bar.fill().className).toContain("from-purple-300")
|
|
182
|
+
expect(bar.fill().className).toContain("bg-linear-to-r")
|
|
183
|
+
})
|
|
184
|
+
})
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { type CSSProperties, type Ref, useEffect, useRef, useState } from "react"
|
|
4
|
+
import { cn } from "../../lib/cn"
|
|
5
|
+
import type { Color } from "../../lib/colors"
|
|
6
|
+
import {
|
|
7
|
+
buildGradientVars,
|
|
8
|
+
GRADIENT_DIR_CLASS,
|
|
9
|
+
type GradientDir,
|
|
10
|
+
type GradientProps,
|
|
11
|
+
} from "../../lib/gradient"
|
|
12
|
+
import { useReducedMotion } from "../../lib/motion/reduced-motion"
|
|
13
|
+
import { props } from "../../lib/props"
|
|
14
|
+
import type { Size } from "../../lib/sizes"
|
|
15
|
+
import type { WithTestId } from "../../lib/test-id"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* NavigationProgress — the thin bar pinned to the top of the viewport while a
|
|
19
|
+
* page loads, in the manner of nprogress / Mantine's `NavigationProgress`.
|
|
20
|
+
*
|
|
21
|
+
* It is driven by one boolean, `loading`, so it stays router-agnostic: wire it
|
|
22
|
+
* to whatever knows a navigation is in flight (TanStack Router's
|
|
23
|
+
* `useRouterState({ select: (s) => s.isLoading })`, Next's transitions, a
|
|
24
|
+
* fetch). The bar invents the progress itself, because no router knows how far
|
|
25
|
+
* along a loader is:
|
|
26
|
+
*
|
|
27
|
+
* - **delay**: nothing shows until `loading` has held for `delay` ms, so an
|
|
28
|
+
* instant navigation does not flash a bar.
|
|
29
|
+
* - **trickle**: the bar starts at a sliver and closes a fixed share of the
|
|
30
|
+
* remaining distance to `TRICKLE_CAP` on every tick. It moves quickly at
|
|
31
|
+
* first, then slows, and never reaches the end on its own.
|
|
32
|
+
* - **complete**: when `loading` drops, the bar runs to 100%, holds a beat,
|
|
33
|
+
* fades out, and only then snaps back to 0. The snap has its transition
|
|
34
|
+
* turned off, so the bar never visibly slides backwards.
|
|
35
|
+
* - **re-entry**: if `loading` comes back while the bar is still on screen,
|
|
36
|
+
* it keeps going from where it is. When it had already reached 100%, it
|
|
37
|
+
* restarts from the sliver.
|
|
38
|
+
*
|
|
39
|
+
* Under `prefers-reduced-motion` there is no trickle and no reveal transition.
|
|
40
|
+
* The bar sits at full width while loading and fades away when done.
|
|
41
|
+
*
|
|
42
|
+
* The fill is always full width and the progress is a `clip-path` revealing
|
|
43
|
+
* its left part. That is what makes `variant="gradient"` read right: the
|
|
44
|
+
* gradient spans the whole bar and stays put while the reveal grows, as in
|
|
45
|
+
* `Progress`, instead of being squeezed into, and re-stretched with, every
|
|
46
|
+
* trickle step.
|
|
47
|
+
*
|
|
48
|
+
* The bar is decorative (`aria-hidden`). It duplicates the page change itself,
|
|
49
|
+
* which is what assistive tech should announce, so it is not a
|
|
50
|
+
* `role="progressbar"` and does not wrap `Progress`. It reuses Progress's
|
|
51
|
+
* palette wiring instead: `data-color` plus the `--c-solid` slot var for
|
|
52
|
+
* `filled`, and the `--tw-gradient-*` vars for `gradient`.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/** Where a freshly shown bar starts, in percent. */
|
|
56
|
+
const START = 8
|
|
57
|
+
/** The trickle closes in on this value and never passes it. */
|
|
58
|
+
export const TRICKLE_CAP = 90
|
|
59
|
+
/** Share of the remaining distance to the cap closed on each tick. */
|
|
60
|
+
const TRICKLE_RATE = 0.1
|
|
61
|
+
/** ms between trickle ticks. The reveal transition runs this long too, so the
|
|
62
|
+
* steps read as one continuous motion. */
|
|
63
|
+
export const TRICKLE_INTERVAL = 200
|
|
64
|
+
/** ms the full bar stays visible before fading: the reveal run plus a beat. */
|
|
65
|
+
export const COMPLETE_HOLD = 400
|
|
66
|
+
/** ms of the fade-out. The reset to 0 waits for it. */
|
|
67
|
+
export const FADE_DURATION = 300
|
|
68
|
+
|
|
69
|
+
const HEIGHT: Record<Size, string> = {
|
|
70
|
+
xs: "h-0.5",
|
|
71
|
+
sm: "h-1",
|
|
72
|
+
md: "h-1.5",
|
|
73
|
+
lg: "h-2",
|
|
74
|
+
xl: "h-3",
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type NavigationProgressSize = Size
|
|
78
|
+
export type NavigationProgressVariant = "filled" | "gradient"
|
|
79
|
+
|
|
80
|
+
export type { GradientDir, GradientProps }
|
|
81
|
+
|
|
82
|
+
const FILL: Record<NavigationProgressVariant, string> = {
|
|
83
|
+
filled: "bg-(--c-solid)",
|
|
84
|
+
// from-*/to-* are the defaults; a `gradient` prop overrides the individual
|
|
85
|
+
// vars it sets. Same stops as Progress's gradient variant.
|
|
86
|
+
gradient: "from-purple-300 to-pink-400",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type BarState = {
|
|
90
|
+
value: number
|
|
91
|
+
visible: boolean
|
|
92
|
+
/** Whether the reveal animates. Off for the reset to 0 and the first
|
|
93
|
+
* paint of a new run. */
|
|
94
|
+
animate: boolean
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const HIDDEN: BarState = { value: 0, visible: false, animate: false }
|
|
98
|
+
|
|
99
|
+
export type NavigationProgressProps = WithTestId & {
|
|
100
|
+
/** Whether a navigation is in flight. */
|
|
101
|
+
loading: boolean
|
|
102
|
+
/** ms `loading` must hold before the bar appears. @default 150 */
|
|
103
|
+
delay?: number
|
|
104
|
+
/** `filled` paints the `color` palette; `gradient` paints `gradient`'s
|
|
105
|
+
* stops across the whole bar. @default "filled" */
|
|
106
|
+
variant?: NavigationProgressVariant
|
|
107
|
+
/** Accent palette. Unset, the bar takes the kit's default solid. Ignored
|
|
108
|
+
* when `variant="gradient"`. */
|
|
109
|
+
color?: Color
|
|
110
|
+
/** Gradient stops and direction; only applied when `variant="gradient"`.
|
|
111
|
+
* Same shape as Badge's and Progress's. Unset fields fall back to
|
|
112
|
+
* purple-300 → pink-400, `to-r`. */
|
|
113
|
+
gradient?: GradientProps
|
|
114
|
+
/** Bar thickness. @default "xs" */
|
|
115
|
+
size?: NavigationProgressSize
|
|
116
|
+
ref?: Ref<HTMLDivElement>
|
|
117
|
+
/** On the fixed root. Override the positioning here to embed the bar
|
|
118
|
+
* somewhere other than the top of the viewport (`absolute`, …). */
|
|
119
|
+
className?: string
|
|
120
|
+
classNames?: { root?: string; bar?: string }
|
|
121
|
+
style?: CSSProperties
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export const NavigationProgress = ({
|
|
125
|
+
loading,
|
|
126
|
+
delay = 150,
|
|
127
|
+
variant = "filled",
|
|
128
|
+
color,
|
|
129
|
+
gradient,
|
|
130
|
+
size = "xs",
|
|
131
|
+
ref,
|
|
132
|
+
className,
|
|
133
|
+
classNames,
|
|
134
|
+
style,
|
|
135
|
+
testId,
|
|
136
|
+
}: NavigationProgressProps) => {
|
|
137
|
+
const isGradient = variant === "gradient"
|
|
138
|
+
const reduced = useReducedMotion()
|
|
139
|
+
const [bar, setBar] = useState<BarState>(HIDDEN)
|
|
140
|
+
// Read inside the effect without re-running it on every trickle tick.
|
|
141
|
+
const barRef = useRef(bar)
|
|
142
|
+
barRef.current = bar
|
|
143
|
+
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
const timers: ReturnType<typeof setTimeout>[] = []
|
|
146
|
+
const later = (fn: () => void, ms: number) => timers.push(setTimeout(fn, ms))
|
|
147
|
+
let interval: ReturnType<typeof setInterval> | undefined
|
|
148
|
+
|
|
149
|
+
if (loading) {
|
|
150
|
+
const run = () => {
|
|
151
|
+
if (reduced) {
|
|
152
|
+
setBar({ value: 100, visible: true, animate: false })
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
interval = setInterval(() => {
|
|
156
|
+
setBar((b) => ({
|
|
157
|
+
...b,
|
|
158
|
+
value: b.value + (TRICKLE_CAP - b.value) * TRICKLE_RATE,
|
|
159
|
+
animate: true,
|
|
160
|
+
}))
|
|
161
|
+
}, TRICKLE_INTERVAL)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const current = barRef.current
|
|
165
|
+
if (current.visible && current.value < 100) {
|
|
166
|
+
// Still trickling (or a re-render mid-run): keep going from here.
|
|
167
|
+
run()
|
|
168
|
+
} else if (current.visible) {
|
|
169
|
+
// Caught mid-completion: restart from the sliver.
|
|
170
|
+
setBar({ value: START, visible: true, animate: false })
|
|
171
|
+
run()
|
|
172
|
+
} else {
|
|
173
|
+
later(() => {
|
|
174
|
+
setBar({ value: START, visible: true, animate: false })
|
|
175
|
+
run()
|
|
176
|
+
}, delay)
|
|
177
|
+
}
|
|
178
|
+
} else if (barRef.current.visible) {
|
|
179
|
+
setBar({ value: 100, visible: true, animate: !reduced })
|
|
180
|
+
later(
|
|
181
|
+
() => {
|
|
182
|
+
setBar((b) => ({ ...b, visible: false }))
|
|
183
|
+
later(() => setBar(HIDDEN), FADE_DURATION)
|
|
184
|
+
},
|
|
185
|
+
reduced ? 0 : COMPLETE_HOLD,
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return () => {
|
|
190
|
+
for (const t of timers) clearTimeout(t)
|
|
191
|
+
clearInterval(interval)
|
|
192
|
+
}
|
|
193
|
+
}, [loading, delay, reduced])
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<div
|
|
197
|
+
ref={ref}
|
|
198
|
+
aria-hidden
|
|
199
|
+
data-color={isGradient ? undefined : color}
|
|
200
|
+
data-variant={variant}
|
|
201
|
+
data-state={bar.visible ? (loading ? "loading" : "complete") : "idle"}
|
|
202
|
+
className={cn(
|
|
203
|
+
"pointer-events-none fixed inset-x-0 top-0 z-(--navigation-progress-z,1000) overflow-hidden",
|
|
204
|
+
HEIGHT[size],
|
|
205
|
+
className,
|
|
206
|
+
classNames?.root,
|
|
207
|
+
)}
|
|
208
|
+
style={style}
|
|
209
|
+
{...props({ "data-testid": testId })}
|
|
210
|
+
>
|
|
211
|
+
<div
|
|
212
|
+
className={cn(
|
|
213
|
+
"h-full w-full transition-opacity ease-out",
|
|
214
|
+
FILL[variant],
|
|
215
|
+
isGradient && GRADIENT_DIR_CLASS[gradient?.dir ?? "to-r"],
|
|
216
|
+
bar.animate && "transition-[clip-path,opacity] motion-reduce:transition-opacity",
|
|
217
|
+
bar.visible ? "opacity-100" : "opacity-0",
|
|
218
|
+
classNames?.bar,
|
|
219
|
+
)}
|
|
220
|
+
style={{
|
|
221
|
+
...(isGradient && gradient ? buildGradientVars(gradient) : null),
|
|
222
|
+
clipPath: `inset(0 ${100 - bar.value}% 0 0)`,
|
|
223
|
+
transitionDuration: `${bar.visible ? TRICKLE_INTERVAL : FADE_DURATION}ms`,
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
</div>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
@@ -379,10 +379,9 @@ export const NumberInput = ({
|
|
|
379
379
|
readOnly={readOnly}
|
|
380
380
|
startSlot={startSlot}
|
|
381
381
|
// The steppers (and the clear button) are interactive — they must
|
|
382
|
-
// not sit inside the `aria-hidden
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
// `endSlot`.
|
|
382
|
+
// not sit inside the `aria-hidden` end-slot span. Render them as
|
|
383
|
+
// direct children instead, and flag the shell's end padding
|
|
384
|
+
// manually so the layout matches an `endSlot`.
|
|
386
385
|
classNames={{ root: classNames?.root }}
|
|
387
386
|
className="pe-0! overflow-clip"
|
|
388
387
|
{...props({ "data-with-end-slot": !hideControls || canClear || suffix != null })}
|
package/src/icon-stroke.test.tsx
CHANGED
|
@@ -29,6 +29,11 @@ const sources = readdirSync(componentsDir, { recursive: true, encoding: "utf8" }
|
|
|
29
29
|
const NOT_ICONS: Record<string, string> = {
|
|
30
30
|
"avatar/avatar.tsx": "the group's notch mask, never painted",
|
|
31
31
|
"circular-progress/circular-progress.tsx": "a progress ring, its width is the `thickness` prop",
|
|
32
|
+
"geodesic/badge-frame.tsx":
|
|
33
|
+
"an illustration: wires drawn in viewBox units, scaling with the badge",
|
|
34
|
+
"geodesic/gift-token.tsx":
|
|
35
|
+
"an illustration: the orbit is drawn in viewBox units, scaling with the token",
|
|
36
|
+
"geodesic/planet.tsx": "an illustration: its own wire weights, fixed with non-scaling-stroke",
|
|
32
37
|
"spinner/spinner.tsx": "a loading ring, weighted to read while it spins",
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/input/input.tsx"],"names":[],"mappings":";;;;;;;;;AAwCO,IAAM,mBAAA,GAAsB,EAAA;AAAA,EACjC,uEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,6BAAA;AAAA,EACA,iCAAA;AAAA,EACA,0DAAA;AAAA,EACA;AACF;AAQO,IAAM,WAAA,GAAc;AAAA,EACzB,wDAAA;AAAA,EACA,kBAAA,CAAmB,OAAA;AAAA,EACnB,4CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mLAAA;AAAA;AAAA;AAAA,EAGA,8KAAA;AAAA;AAAA,EAEA,2DAAA;AAAA,EACA,0BAAA;AAAA,EACA,6BAAA;AAAA,EACA;AACF;AAGO,IAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,OAAA,EAAS,CAAC,YAAA,EAAc,0CAA0C,CAAA;AAAA;AAAA;AAAA,EAGlE,QAAA,EAAU;AAAA,IACR,mCAAA;AAAA,IACA;AAAA;AAEJ;AAQO,IAAM,QAAA,GAAW;AAAA,EACtB,EAAA,EAAI,SAAA;AAAA,EACJ,EAAA,EAAI,SAAA;AAAA,EACJ,EAAA,EAAI,OAAA;AAAA,EACJ,EAAA,EAAI,SAAA;AAAA,EACJ,EAAA,EAAI;AACN;AAGO,IAAM,aAAa,GAAA,CAAI,CAAC,GAAG,WAAA,EAAa,oCAAoC,CAAA,EAAG;AAAA,EACpF,QAAA,EAAU;AAAA,IACR,OAAA,EAAS,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOT,IAAA,EAAM;AAAA,MACJ,EAAA,EAAI;AAAA,QACF,eAA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SAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA;AAAA,MACA,UAAA,EAAY;AAAA,QACV,MAAM,UAAA,EAAY,IAAA;AAAA,QAClB,WAAW,UAAA,EAAY,SAAA;AAAA,QACvB,SAAS,UAAA,EAAY;AAAA,OACvB;AAAA,MACC,GAAG,KAAA,CAAM;AAAA,QACR,QAAA,EAAU,YAAY,KAAA,EAAO,QAAA;AAAA,QAC7B,OAAA,EAAS,WAAW,KAAA,EAAO,OAAA;AAAA,QAC3B,QAAA,EAAU,YAAY,KAAA,EAAO;AAAA,OAC9B,CAAA;AAAA,MAED,QAAA,kBAAA,GAAA;AAAA,QAAC,GAAA,CAAI,KAAA;AAAA,QAAJ;AAAA,UACE,GAAG,eAAA;AAAA,UACH,GAAG,eAAe,KAAK,CAAA;AAAA,UACvB,GAAG,KAAA,CAAM;AAAA,YACR,QAAA,EAAU,YAAY,KAAA,EAAO,QAAA;AAAA,YAC7B,cAAA,EAAgB,WAAW,KAAA,EAAO,OAAA;AAAA,YAClC,QAAA,EAAU,YAAY,KAAA,EAAO,QAAA;AAAA,YAC7B,aAAA,EAAe;AAAA,WAChB,CAAA;AAAA,UACD,SAAA,EAAW,EAAA,CAAG,mBAAA,EAAqB,UAAA,EAAY,KAAK,CAAA;AAAA,UACnD,GAAG;AAAA;AAAA;AACN;AAAA,GACF;AAEJ","file":"chunk-45QRQKRC.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { ReactNode, Ref } from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport { fieldA11yProps } from \"../field/field\"\n\n/**\n * Input / InputBase — the styled input *shell* the whole form family renders\n * into (Select trigger, Combobox/Autocomplete search field, PillsInput, and\n * `TextInput`). It is deliberately the lowest layer: label / description /\n * error live in `Field`, not here — reach for `TextInput` when you want them\n * built in, which is the common case, and for `Input` when you're composing\n * the shell yourself or the control needs no accessible name of its own.\n *\n * - `InputBase` is the polymorphic shell. It draws the bordered box, the\n * focus-visible ring, the disabled / invalid states, and lays out\n * an optional `startSlot` / `endSlot` around a single control child. The\n * child can be anything — an `<input>`, a `<button>` (Select trigger), or a\n * `<div>` of pills (PillsInput). Style your control with the exported\n * `inputControlClasses` so it sits flush inside the shell.\n * - `Input` is `InputBase` wrapping a real `<input>`. Native\n * input props (`value`, `onChange`, `placeholder`, `name`, `type`, `ref`, …)\n * are forwarded straight to the element; `className` styles the shell root\n * (matching the kit's other components), and `classNames` overrides parts.\n *\n * The shell is palette-independent, so there is no `color` prop: the focus halo\n * and border are a fixed `brand-500` per the 42 UI Kit Figma (see `shellChrome`),\n * and `de33dee` removed both `color` and the `filled` variant. `invalid` swaps\n * the border / ring to red.\n */\n\n/** Inner-control reset — apply to whatever element you nest inside `InputBase`\n * (input, button, …) so it inherits the shell's font and fills the row. */\nexport const inputControlClasses = cn(\n \"w-full flex-1 min-w-0 appearance-none border-0 bg-transparent p-0 m-0\",\n // `font: inherit` is the canonical form-control reset — without it the UA\n // forces its own font-size and the shell's `size` text scale is ignored.\n // No `text-trim`: a native `<input>`'s text renders inside the UA's own\n // form-control internals, not a normal CSS line box, so `text-box-trim`\n // computes an inconsistent (content-dependent) box height there — Chrome\n // was scrolling the text vertically once its computed box stopped matching\n // the element's actual rendered height.\n \"font-[inherit] text-inherit\",\n \"outline-none focus:outline-none\",\n \"placeholder:text-black/50 dark:placeholder:text-white/50\",\n \"disabled:cursor-not-allowed\",\n)\n\n/**\n * Shared shell chrome — surface, border, focus ring, and state styling. The\n * single-line `Input` shell and the multi-line `PillsInput` shell both build on\n * these; only the layout (row vs wrap) and the sizing differ, so the visual\n * treatment (incl. the invalid red halo) lives in exactly one place.\n */\nexport const shellChrome = [\n \"group/input relative rounded-input border outline-none\",\n TEXT_COLOR_CLASSES.primary,\n \"transition-[color,box-shadow,border-color]\",\n // Fixed brand-500 focus halo + border, per the 42 UI Kit Figma — independent\n // of the instance's own `color`. The combined selector matches either shape\n // in the family: a shell wrapping a real focusable descendant (Input,\n // Select, Combobox, MultiSelect, ComboboxList, MultiComboboxList, PinInput's\n // per-cell shell) or a shell that IS the tabbable element itself (TreeSelect,\n // TreeMultiSelect). `:has()` alone only matches the former.\n \"[&:is(:focus-visible,:has(:focus-visible))]:border-brand-500 [&:is(:focus-visible,:has(:focus-visible))]:ring-[3px] [&:is(:focus-visible,:has(:focus-visible))]:ring-brand-500/15\",\n // Invalid wins over the palette: red border + red halo. Same combined\n // selector as the rule above so the two can't drift out of sync.\n \"data-invalid:border-red-500 data-invalid:[&:is(:focus-visible,:has(:focus-visible))]:border-red-500 data-invalid:[&:is(:focus-visible,:has(:focus-visible))]:ring-red-500/15\",\n // Disabled affordances on the shell.\n \"data-disabled:cursor-not-allowed data-disabled:opacity-60\",\n \"data-disabled:bg-white/8\",\n \"data-pointer:cursor-pointer\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0\",\n]\n\n/** Surface treatment per `variant`, shared across the input shells. */\nexport const shellVariants = {\n // Translucent border to go with the translucent fill: at `bg-white/4` the\n // shell has no ground of its own, so a fixed opaque hairline can vanish (on\n // a light-gray card) or over-assert (on a mid-tone host page). Same hue\n // language as Card's `default` (navy-tinted light / white-tinted dark), one\n // alpha step tighter — these render within a shade of the opaque colors\n // they replace, so the hairline keeps its weight and only gains\n // background-adaptivity.\n default: [\"bg-white/4\", \"border-brand-900/20 dark:border-white/15\"],\n // Escape hatch: strip the chrome but keep the layout (height / slots). Same\n // combined selector as `shellChrome`'s \"on\" rule so the cancel can't drift.\n unstyled: [\n \"border-transparent bg-transparent\",\n \"rounded-none [&:is(:focus-visible,:has(:focus-visible))]:ring-0\",\n ],\n}\n\n/**\n * Inline gap between the shell's slots and control, per `size`. The single\n * source for this spacing: `inputShell` applies it to the shell row, and any\n * control that lays out its *own* slots inside a nested flex (e.g. the Select\n * trigger) reuses it so adornments sit identically across the family.\n */\nexport const shellGap = {\n xs: \"gap-1.5\",\n sm: \"gap-1.5\",\n md: \"gap-2\",\n lg: \"gap-2.5\",\n xl: \"gap-3\",\n} as const\n\n/** Single-line input shell. Reused by the family's button / input controls. */\nexport const inputShell = cva([...shellChrome, \"flex w-full items-center gap-y-0.5\"], {\n variants: {\n variant: shellVariants,\n // Padding is slot-aware: the base is the tight, no-adornment inset, and each\n // side gains a step of inline padding only when `InputBase` flags an\n // adornment there (`data-with-start-slot` / `data-with-end-slot`). These are\n // self-referential `data-*` variants — the attributes live on this same\n // shell element, so a `group-*` variant (which targets descendants) wouldn't\n // match.\n size: {\n xs: [\n \"ps-1.5 pe-1.5\",\n \"data-with-start-slot:ps-2 data-with-end-slot:pe-2\",\n `min-h-7 ${shellGap.xs} text-xs [&_svg]:size-3`,\n ],\n sm: [\n \"ps-2 pe-2\",\n \"data-with-start-slot:ps-2.5 data-with-end-slot:pe-2.5\",\n `min-h-8 ${shellGap.sm} text-sm [&_svg]:size-3.5`,\n ],\n md: [\n \"ps-2 pe-2\",\n \"data-with-start-slot:ps-2.5 data-with-end-slot:pe-2.5\",\n `min-h-9 ${shellGap.md} text-md [&_svg]:size-4`,\n ],\n lg: [\n \"ps-3 pe-3\",\n \"data-with-start-slot:ps-3.5 data-with-end-slot:pe-3.5\",\n `min-h-10 ${shellGap.lg} text-lg [&_svg]:size-5`,\n ],\n xl: [\n \"ps-3.5 pe-3.5\",\n \"data-with-start-slot:ps-4 data-with-end-slot:pe-4\",\n `min-h-12 ${shellGap.xl} text-xl [&_svg]:size-6`,\n ],\n },\n },\n defaultVariants: { variant: \"default\", size: \"md\" },\n})\n\n/** Start/end adornment slot — the shared visual contract for the inline-start /\n * inline-end content the whole form family lays out (icon, chevron, clear).\n * Exported so Select / Combobox / the pills controls slot their adornments\n * identically to `InputBase` instead of re-deriving the layout. */\nexport const inputSlot = cn(\n \"inline-flex shrink-0 items-center justify-center\",\n TEXT_COLOR_CLASSES.muted,\n)\n\n/** Muted color for a component's own custom-rendered placeholder / empty-state text — a\n * `<span>` standing in for a native `::placeholder` wherever the value display isn't a real\n * `<input>` (Select's trigger, MultiSelect's non-searchable mode, TreeSelect / TreeMultiSelect's\n * trigger, DatePicker's range-mode trigger). Same color pairing as `inputControlClasses`'s native\n * `::placeholder` rule above. Kept as its own export, not folded into `inputSlot` — `inputSlot`'s\n * `inline-flex items-center justify-center shrink-0` are icon-slot layout rules; forced onto a\n * run of text they'd center it and block it from shrinking, silently breaking truncation on the\n * call sites where this color sits on the same span as `flex-1`/`truncate`. */\nexport const placeholderColor = TEXT_COLOR_CLASSES.muted\n\nexport type InputVariant = NonNullable<VariantProps<typeof inputShell>[\"variant\"]>\nexport type InputSize = NonNullable<VariantProps<typeof inputShell>[\"size\"]>\n\ntype ShellClassNames = {\n /** The shell `<div>` (also targeted by `className`). */\n root?: string\n startSlot?: string\n endSlot?: string\n}\n\n/** Props shared by the shell and the convenience `Input`. */\ntype ShellOwnProps = VariantProps<typeof inputShell> & {\n /** Red border + ring; also wires `aria-invalid` on `Input`. */\n invalid?: boolean\n /** Dims the shell and (on `Input`) disables the element. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits (on `Input`). */\n readOnly?: boolean\n /** `cursor: pointer` — for button-like triggers (Select). */\n pointer?: boolean\n /** Decorative or interactive content at the inline-start of the control. */\n startSlot?: ReactNode\n /** Content at the inline-end — chevron, clear button, spinner. */\n endSlot?: ReactNode\n}\n\nexport type InputBaseProps = NoAsChild<Omit<HTMLArkProps<\"div\">, \"color\">> &\n ShellOwnProps &\n WithTestId & {\n classNames?: ShellClassNames\n }\n\nexport const InputBase = ({\n variant,\n size,\n invalid,\n disabled,\n readOnly,\n pointer,\n startSlot,\n endSlot,\n children,\n className,\n classNames,\n testId,\n asChild: _asChild,\n ...rest\n}: InputBaseProps) => (\n <ark.div\n {...props({\n \"data-invalid\": invalid,\n \"data-disabled\": disabled,\n \"data-readonly\": readOnly,\n \"data-pointer\": pointer,\n // Drive the slot-aware padding in `inputShell`: each side gains a step of\n // inline padding when an adornment sits there (`data-with-*-slot:`).\n \"data-with-start-slot\": startSlot != null,\n \"data-with-end-slot\": endSlot != null,\n // Only meaningful when `InputBase` is used bare (no `Input`-style inner\n // control routing its own `testId`) — a `testId` given to a control that\n // wraps `InputBase` itself (Input, NumberInput, Select, …) always lands\n // on that control's real interactive element instead, never here.\n \"data-testid\": testId,\n })}\n className={cn(className, classNames?.root, inputShell({ variant, size }))}\n {...rest}\n >\n {startSlot != null && (\n <span className={cn(inputSlot, classNames?.startSlot)} aria-hidden>\n {startSlot}\n </span>\n )}\n {children}\n {endSlot != null && (\n <span className={cn(inputSlot, classNames?.endSlot)} aria-hidden>\n {endSlot}\n </span>\n )}\n </ark.div>\n)\n\nexport type InputProps = Omit<HTMLArkProps<\"input\">, \"size\" | \"color\"> &\n ShellOwnProps &\n WithTestId & {\n /** Lands on the underlying `<input>` for focus-on-error. Declared\n * explicitly because `HTMLArkProps` is `ComponentPropsWithoutRef`, so the\n * native prop types alone don't carry it — same as `Textarea`,\n * `PasswordInput`, and `NumberInput`. */\n ref?: Ref<HTMLInputElement>\n classNames?: ShellClassNames & {\n /** The inner `<input>` element. */\n input?: string\n }\n }\n\nexport const Input = ({\n variant,\n size,\n invalid,\n disabled,\n readOnly,\n pointer,\n startSlot,\n endSlot,\n className,\n classNames,\n testId,\n ...rest\n}: InputProps) => {\n // When nested in a `Field`, inherit its id / aria-describedby / state so the\n // label, description, and error wire up — exactly how Ark's own `Field.Input`\n // behaves. `useFieldContext` is null outside a Field, so this is a no-op then.\n const field = useFieldContext()\n const fieldInputProps = field?.getInputProps()\n\n return (\n <InputBase\n variant={variant}\n size={size}\n pointer={pointer}\n startSlot={startSlot}\n endSlot={endSlot}\n className={className}\n classNames={{\n root: classNames?.root,\n startSlot: classNames?.startSlot,\n endSlot: classNames?.endSlot,\n }}\n {...props({\n disabled: disabled || field?.disabled,\n invalid: invalid || field?.invalid,\n readOnly: readOnly || field?.readOnly,\n })}\n >\n <ark.input\n {...fieldInputProps}\n {...fieldA11yProps(field)}\n {...props({\n disabled: disabled || field?.disabled,\n \"aria-invalid\": invalid || field?.invalid,\n readOnly: readOnly || field?.readOnly,\n \"data-testid\": testId,\n })}\n className={cn(inputControlClasses, classNames?.input)}\n {...rest}\n />\n </InputBase>\n )\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/menu/menu.tsx"],"names":["ArkMenu"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgEA,IAAM,WAAA,GAAc,EAAA;AAAA,EAClB,aAAA;AAAA,EACA,kCAAA;AAAA,EACA;AACF,CAAA;AAQA,IAAM,QAAA,GAAW,GAAA;AAAA,EACf;AAAA,IACE,kFAAA;AAAA,IACA,0BAAA;AAAA,IACA,kCAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA,QAIP,KAAA,EAAO;AAAA,UACL,kBAAA,CAAmB,OAAA;AAAA,UACnB;AAAA,SACF;AAAA;AAAA,QAEA,IAAA,EAAM,CAAC,iBAAA,EAAmB,gCAAgC;AAAA;AAC5D,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,KAAA;AAAM;AAEtC,CAAA;AAMA,IAAM,WAAA,GAAc,2DAAA;AAiBb,IAAM,aAAA,GAAiD;AAAA,EAC5D,KAAA,sBAAQ,SAAA,EAAA,EAAU,CAAA;AAAA,EAClB,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,OAAA,EAAQ,WAAA,EAAY,MAAK,cAAA,EAAe,aAAA,EAAY,MAAA,EACvD,QAAA,kBAAA,GAAA,CAAC,YAAO,EAAA,EAAG,IAAA,EAAK,IAAG,IAAA,EAAK,CAAA,EAAE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AA,MAAM,OAAO,cAAA,EAAe;AAC5B,EAAA,MAAM,WAAW,kBAAA,EAAmB;AACpC,EAAA,MAAM,EAAE,aAAA,EAAe,mBAAA,EAAqB,GAAG,OAAA,KAAY,IAAA,CAAK,eAAA,CAAgB,EAAE,KAAA,EAAO,CAAA;AACzF,EAAA,uBACE,GAAA;AAAA,IAAC,GAAA,CAAI,MAAA;AAAA,IAAJ;AAAA,MACE,GAAG,UAAA;AAAA,QACF;AAAA,UACE,GAAG,OAAA;AAAA,UACH,eAAA,EAAiB,QAAA,CAAS,SAAA,GAAY,MAAA,GAAY,QAAQ,eAAe,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAKzE,WAAA,EAAa,CAAC,KAAA,KAAqB,KAAA,CAAM,cAAA;AAAe,SAC1D;AAAA;AAAA;AAAA;AAAA;AAAA,QAKA,EAAE,GAAG,KAAA,CAAM,EAAE,eAAe,MAAA,EAAQ,CAAA,EAAG,GAAG,IAAA,EAAM,SAAA,EAAW,EAAA,CAAG,aAAA,EAAe,SAAS,CAAA;AAAE,OAC1F;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;AAGO,IAAM,iBAAiBA,IAAA,CAAQ;AAC/B,IAAM,YAAYA,IAAA,CAAQ;AAC1B,IAAM,UAAUA,IAAA,CAAQ;AAExB,IAAM,SAAA,GAAY;AAElB,IAAM,UAAA,GAAa","file":"chunk-FDCPMUJK.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react/factory\"\nimport { useLocaleContext } from \"@ark-ui/react/locale\"\nimport { Menu as ArkMenu, useMenuContext } from \"@ark-ui/react/menu\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { usePresenceContext } from \"@ark-ui/react/presence\"\nimport { mergeProps } from \"@ark-ui/react/utils\"\nimport { cva } from \"class-variance-authority\"\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type DragEvent,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n} from \"react\"\nimport { composeChildren } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { warnRenamedProp } from \"../../lib/dev-warn\"\nimport { type IconMap, mergeIcons } from \"../../lib/icons\"\nimport { useOverlayContainer } from \"../../lib/overlay-container\"\nimport { useNestedLayer } from \"../../lib/overlay-layer\"\nimport { type LogicalPosition, resolveLogicalPlacement } from \"../../lib/placement\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport { CheckIcon, ChevronRightIcon } from \"../popover/icons\"\nimport {\n popoverChevron,\n popoverChrome,\n popoverGroupLabel,\n popoverIndicator,\n} from \"../popover/popover\"\n\n/**\n * Menu — the kit's dropdown of actions, a styled layer over Ark UI's Menu.\n * It's the click-triggered sibling of `Popover` (a free-form panel): Ark's Menu\n * machine wires roving focus, type-ahead, `role=\"menu\"` / `menuitem`,\n * `aria-haspopup` / `aria-expanded`, submenus, and checkbox / radio selection.\n *\n * Two ways to use it — the compound parts (this file) give full control; the\n * data-driven `<Menu data={…}>` convenience (see `menu-data.tsx`) covers the\n * common action-menu case and is built on these very parts.\n *\n * <Menu.Root>\n * <Menu.Trigger asChild><Button>Open</Button></Menu.Trigger>\n * <Menu.Content>\n * <Menu.Item startSection={<User />} onClick={openProfile}>Profile</Menu.Item>\n * <Menu.Divider />\n * <Menu.Item color=\"red\" startSection={<Trash />} onClick={remove}>Delete</Menu.Item>\n * </Menu.Content>\n * </Menu.Root>\n *\n * Portaled by default (escapes `overflow:hidden` ancestors), sized to content,\n * and animated via the kit's shared `popover-in/out` tokens.\n */\n\n/** Menu surface — the shared floating chrome, sized to content and scrollable\n * when tall. Unlike the form pickers' `popoverContent` (an `overflow-hidden`\n * clip around a nested scroller) a Menu scrolls natively, so Ark needs no\n * `scrollToIndexFn` workaround. */\nconst menuContent = cn(\n popoverChrome,\n \"flex w-max min-w-40 flex-col p-1\",\n \"max-h-[min(24rem,var(--available-height,24rem))] overflow-y-auto overscroll-contain\",\n)\n\n/** A single menu row — shared by `Item`, `CheckboxItem`, `RadioItem`, and\n * `SubTrigger` so every row is visually identical. Mirrors `popoverOption`'s\n * neutral look, but the `colored` variant swaps the text + highlight tints to\n * the palette slot vars (`--c-text` / `--c-soft`) resolved from `data-color` —\n * e.g. a red \"Delete\". Highlight is `data-highlighted`, selection is\n * `data-[state=checked]`, disabled is `data-disabled`, all owned by Ark. */\nconst menuItem = cva(\n [\n \"relative flex cursor-pointer items-center gap-2 rounded-xs px-2.5 py-1.5 text-md\",\n \"select-none outline-none\",\n \"data-[state=checked]:font-medium\",\n \"data-disabled:pointer-events-none data-disabled:opacity-50\",\n ],\n {\n variants: {\n colored: {\n // Neutral highlight is transparent — a low-opacity black/white wash,\n // not an opaque gray — matching the surface's own background-dependent\n // tint (no Figma reference for this state yet).\n false: [\n TEXT_COLOR_CLASSES.primary,\n \"data-highlighted:bg-black/5 dark:data-highlighted:bg-white/8\",\n ],\n // Slot vars already shift by theme (colors.css), so no `dark:` needed.\n true: [\"text-(--c-text)\", \"data-highlighted:bg-(--c-soft)\"],\n },\n },\n defaultVariants: { colored: false },\n },\n)\n\n/** Hairline between groups of items. Same shade as Popover's own\n * Header/Footer/Body slotEdge dividers (brand-900/20 / white/15) — both are\n * separator lines on the identical popoverChrome panel, so they shouldn't\n * drift to different weights. */\nconst menuDivider = \"-mx-1 my-1 h-px border-0 bg-brand-900/20 dark:bg-white/15\"\n\ntype MenuPlacement = NonNullable<NonNullable<ArkMenu.RootProps[\"positioning\"]>[\"placement\"]>\n\n/** `position` accepts Ark's physical placements plus the logical, RTL-aware\n * horizontal sides `start` / `end` (resolved to `left` / `right` by direction). */\nexport type MenuPosition = LogicalPosition<MenuPlacement>\n\nexport type MenuIconSlot = \"check\" | \"radio\" | \"submenu\"\nexport type MenuIcons = IconMap<MenuIconSlot>\n\n/**\n * The default icons: the checkbox item's check, the radio item's dot, and the\n * submenu trigger's chevron. The chevron points to where the submenu opens, the\n * inline end, so it mirrors under RTL; a consumer's icon is drawn as given.\n * The dot is a filled glyph, so it takes no `iconStroke`.\n */\nexport const DEFAULT_ICONS: Record<MenuIconSlot, ReactNode> = {\n check: <CheckIcon />,\n radio: (\n <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n <circle cx=\"12\" cy=\"12\" r=\"5\" />\n </svg>\n ),\n submenu: <ChevronRightIcon className=\"rtl:-scale-x-100\" />,\n}\n\ntype MenuContextValue = {\n withinPortal: boolean\n container?: HTMLElement | null\n icons: Record<MenuIconSlot, ReactNode>\n}\nconst MenuContext = createContext<MenuContextValue>({ withinPortal: true, icons: DEFAULT_ICONS })\n\nexport type MenuRootProps = Omit<ArkMenu.RootProps, \"positioning\" | \"onOpenChange\"> & {\n /** Dropdown placement relative to the trigger. Prefer the logical `start` / `end`\n * sides (RTL-aware), or use any Ark placement (`bottom-start`, `top`, …).\n * Defaults to `\"bottom\"`. */\n position?: MenuPosition\n /** Gap in px between the trigger and the dropdown. */\n offset?: number\n /** Render the dropdown in a Portal so it escapes clipping ancestors. Default `true`. */\n withinPortal?: boolean\n /** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is\n * one (so the panel stays above it), else `document.body`. */\n container?: HTMLElement | null\n /** Called when the menu opens or closes (flattened from Ark's detail object). */\n onOpenChange?: (open: boolean) => void\n /** Fires on close (any source) — Escape, outside interaction, item selection, or a controlled `onOpenChange`. */\n onClose?: () => void\n /** Replaces the default icons: `check`, `radio`, `submenu`. Reaches every item and submenu\n * inside, drawn as given (never restroked or mirrored). */\n icons?: MenuIcons\n}\n\n/**\n * Selects a link item (`<Menu.Item asChild><Link/></Menu.Item>`) from the\n * keyboard. zag's default `navigate` dispatches `new MouseEvent(\"click\")`,\n * which doesn't bubble, so React's delegated `onClick` never sees it and a\n * router `Link` falls back to a full page load. `node.click()` dispatches a\n * bubbling click instead, which reaches the router. Deferred like zag's own,\n * so the menu settles before the navigation starts. A `navigate` prop still\n * overrides it.\n */\nconst clickLink: NonNullable<ArkMenu.RootProps[\"navigate\"]> = ({ node }) => {\n queueMicrotask(() => node.click())\n}\n\nconst Root = ({\n position = \"bottom\",\n offset,\n withinPortal = true,\n container,\n onOpenChange,\n onClose,\n icons,\n children,\n ...rest\n}: MenuRootProps) => {\n const { dir } = useLocaleContext()\n return (\n <MenuContext.Provider\n value={{ withinPortal, container, icons: mergeIcons(DEFAULT_ICONS, icons) }}\n >\n <ArkMenu.Root\n positioning={{ placement: resolveLogicalPlacement(position, dir), gutter: offset }}\n navigate={clickLink}\n onOpenChange={({ open }) => {\n onOpenChange?.(open)\n if (!open) onClose?.()\n }}\n {...rest}\n >\n {children}\n </ArkMenu.Root>\n </MenuContext.Provider>\n )\n}\n\nexport type MenuContentProps = ArkMenu.ContentProps & WithTestId\n\nconst Content = ({ className, children, testId, ...rest }: MenuContentProps) => {\n const { withinPortal, container } = useContext(MenuContext)\n const portalContainer = useOverlayContainer(container)\n // Holds an enclosing Modal/Drawer/Popover open while the menu is; see `lib/overlay-layer.tsx`.\n useNestedLayer(useMenuContext().open)\n const panel = (\n <ArkMenu.Positioner>\n <ArkMenu.Content\n className={cn(menuContent, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {children}\n </ArkMenu.Content>\n </ArkMenu.Positioner>\n )\n if (!withinPortal) return panel\n return <Portal container={portalContainer}>{panel}</Portal>\n}\n\n/** Shared inline-start wrapper for a `startSlot`. Sizes a bare icon to 16px\n * (`size-4`, like Button `md` / Input / Accordion) so every row's label starts\n * on the same column whatever icon it carries. Scoped to this slot — not the\n * whole row — so SVGs in `children` / `endSlot` and the row's own indicator\n * or chevron keep their sizes. `:where()` drops the rule to zero class\n * specificity, so a size class on the icon itself (`className=\"size-5\"`) still\n * wins; Lucide's `size` prop is only an HTML attribute and does not. */\nconst StartSlot = ({ children }: { children: ReactNode }) => (\n <span className=\"inline-flex shrink-0 items-center [:where(&)_svg]:size-4\">{children}</span>\n)\n\n/** Shared inline-end wrapper for an `endSlot` (pushes it to the far edge). */\nconst EndSlot = ({ children }: { children: ReactNode }) => (\n <span className={cn(\"ms-auto inline-flex shrink-0 items-center gap-2\", TEXT_COLOR_CLASSES.muted)}>\n {children}\n </span>\n)\n\n/** A row's leading slot, plus its former `startSection` spelling. */\nexport type MenuStartSlotProps = {\n /** Content before the label (usually an icon — a bare SVG is sized to 16px;\n * a size class on the icon overrides it). */\n startSlot?: ReactNode\n /** @deprecated Renamed `startSlot`, like the rest of the kit's leading slots.\n * Removed in the next minor. `startSlot` wins when both are set. */\n startSection?: ReactNode\n}\n\n/** A row's trailing slot, plus its former `endSection` spelling. */\nexport type MenuEndSlotProps = {\n /** Content after the label, pushed to the inline-end. */\n endSlot?: ReactNode\n /** @deprecated Renamed `endSlot`, like the rest of the kit's trailing slots.\n * Removed in the next minor. `endSlot` wins when both are set. */\n endSection?: ReactNode\n}\n\n/** Warns once when a part is still given a deprecated `*Section` slot. */\nconst warnSections = (part: string, start: ReactNode, end?: ReactNode) => {\n if (start !== undefined) warnRenamedProp(`Menu.${part}`, \"startSection\", \"startSlot\")\n if (end !== undefined) warnRenamedProp(`Menu.${part}`, \"endSection\", \"endSlot\")\n}\n\nexport type MenuItemProps = Omit<ArkMenu.ItemProps, \"value\" | \"onClick\" | \"onSelect\"> &\n WithTestId &\n MenuStartSlotProps &\n MenuEndSlotProps & {\n /** Unique value — used for type-ahead + the selection detail. Auto-generated\n * when omitted (Mantine-style items need no explicit value). */\n value?: string\n /** Palette for the row — colors the label + highlight tint (e.g. `\"red\"` for a\n * destructive action). Resolved from `data-color` via the slot vars. */\n color?: Color\n /** Fires when the item is selected — on click *and* keyboard activation\n * (Enter / Space), not just a pointer click. Wraps Ark's `onSelect`. */\n onClick?: () => void\n }\n\nconst Item = ({\n value,\n startSection,\n endSection,\n startSlot = startSection,\n endSlot = endSection,\n color,\n onClick,\n className,\n children,\n testId,\n asChild,\n ...rest\n}: MenuItemProps) => {\n const autoId = useId()\n warnSections(\"Item\", startSection, endSection)\n return (\n <ArkMenu.Item\n asChild={asChild}\n value={value ?? autoId}\n onSelect={onClick}\n data-color={color}\n className={cn(menuItem({ colored: color != null }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {startSlot != null && <StartSlot>{startSlot}</StartSlot>}\n {own}\n {endSlot != null && <EndSlot>{endSlot}</EndSlot>}\n </>\n ))}\n </ArkMenu.Item>\n )\n}\n\n/** Optional decorative leader for a section heading — the code-themed `// ` from\n * `Text`'s `prefix`. Hidden from screen readers and the clipboard\n * (`aria-hidden` + `select-none`); renders nothing when unset (off by default). */\nconst HeadingPrefix = ({ prefix }: { prefix: ReactNode }) =>\n prefix === undefined ? null : (\n <span aria-hidden=\"true\" className=\"select-none\">\n {prefix}\n </span>\n )\n\nexport type MenuLabelProps = Omit<ComponentPropsWithoutRef<\"div\">, \"prefix\"> &\n WithTestId & {\n /** Decorative leader before the label (e.g. `\"// \"`). Off by default; hidden\n * from screen readers and the clipboard. */\n prefix?: ReactNode\n }\n\n/** Standalone section heading (Mantine parity). For grouped items with proper\n * ARIA wiring, prefer `Menu.ItemGroup` + `Menu.ItemGroupLabel`. */\nconst Label = ({ className, prefix, children, testId, ...rest }: MenuLabelProps) => (\n <div className={cn(popoverGroupLabel, className)} {...props({ \"data-testid\": testId })} {...rest}>\n <HeadingPrefix prefix={prefix} />\n {children}\n </div>\n)\n\nexport type MenuItemGroupLabelProps = Omit<ArkMenu.ItemGroupLabelProps, \"prefix\"> &\n WithTestId & {\n /** Decorative leader before the label (e.g. `\"// \"`). Off by default; hidden\n * from screen readers and the clipboard. */\n prefix?: ReactNode\n }\n\nconst ItemGroupLabel = ({\n className,\n prefix,\n children,\n testId,\n asChild,\n ...rest\n}: MenuItemGroupLabelProps) => (\n <ArkMenu.ItemGroupLabel\n asChild={asChild}\n className={cn(popoverGroupLabel, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n <HeadingPrefix prefix={prefix} />\n {own}\n </>\n ))}\n </ArkMenu.ItemGroupLabel>\n)\n\nconst Divider = ({ className, testId, ...rest }: ArkMenu.SeparatorProps & WithTestId) => (\n <ArkMenu.Separator\n className={cn(menuDivider, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type MenuCheckboxItemProps = ArkMenu.CheckboxItemProps &\n WithTestId &\n MenuStartSlotProps & {\n color?: Color\n }\n\nconst CheckboxItem = ({\n startSection,\n startSlot = startSection,\n color,\n className,\n children,\n testId,\n asChild,\n ...rest\n}: MenuCheckboxItemProps) => {\n const { icons } = useContext(MenuContext)\n warnSections(\"CheckboxItem\", startSection)\n return (\n <ArkMenu.CheckboxItem\n asChild={asChild}\n data-color={color}\n className={cn(menuItem({ colored: color != null }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {startSlot != null && <StartSlot>{startSlot}</StartSlot>}\n {own}\n <ArkMenu.ItemIndicator className={popoverIndicator}>{icons.check}</ArkMenu.ItemIndicator>\n </>\n ))}\n </ArkMenu.CheckboxItem>\n )\n}\n\nexport type MenuRadioGroupProps = Omit<\n ArkMenu.RadioItemGroupProps,\n \"onValueChange\" | \"onChange\"\n> & {\n /** Called with the newly selected value (flattened from Ark's detail object). */\n onChange?: (value: string) => void\n}\n\nconst RadioGroup = ({ onChange, ...rest }: MenuRadioGroupProps) => (\n <ArkMenu.RadioItemGroup\n onValueChange={onChange ? ({ value }) => onChange(value) : undefined}\n {...rest}\n />\n)\n\nexport type MenuRadioItemProps = ArkMenu.RadioItemProps &\n WithTestId &\n MenuStartSlotProps & {\n color?: Color\n }\n\nconst RadioItem = ({\n startSection,\n startSlot = startSection,\n color,\n className,\n children,\n testId,\n asChild,\n ...rest\n}: MenuRadioItemProps) => {\n const { icons } = useContext(MenuContext)\n warnSections(\"RadioItem\", startSection)\n return (\n <ArkMenu.RadioItem\n asChild={asChild}\n data-color={color}\n className={cn(menuItem({ colored: color != null }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {startSlot != null && <StartSlot>{startSlot}</StartSlot>}\n {own}\n <ArkMenu.ItemIndicator className={popoverIndicator}>{icons.radio}</ArkMenu.ItemIndicator>\n </>\n ))}\n </ArkMenu.RadioItem>\n )\n}\n\nexport type MenuSubProps = Omit<ArkMenu.RootProps, \"positioning\"> & {\n /** Gap in px between the trigger row and the submenu. Ark manages submenu\n * *placement* itself (RTL-aware `right-start` / `left-start`, flush to the\n * parent), so only this main-axis gap is adjustable. Defaults to `10`. */\n offset?: number\n}\n\n/** A submenu opens flush to its trigger row, so its first item lands one surface\n * inset *below* the trigger — the `menuContent` top border (1px) + top padding\n * (`p-1` = 4px). Nudging the submenu up by that inset lines the first sub-item\n * up with the trigger row. Cross-axis is the vertical axis for the (Ark-forced)\n * `right-start` / `left-start` placements, and Floating UI maps a negative value\n * to \"up\" in both directions — so one constant covers LTR and RTL. */\nconst SUBMENU_ALIGN_OFFSET = -5\n\n/** Submenu root — a nested Ark Menu whose triggering row is `Menu.SubTrigger`.\n * Inherits the parent's portal settings via context (see `Menu.SubContent`).\n *\n * Ark's menu machine hard-overrides a submenu's placement and `gutter` (to `0`),\n * so a `gutter`-based offset is silently dropped. It leaves `offset` untouched,\n * and Floating UI resolves the axes as `offset.mainAxis ?? gutter` (the gap) and\n * `offset.crossAxis` (the top alignment) — so the whole `offset` object is the\n * one path that survives the override. */\nconst Sub = ({ offset = 10, children, ...rest }: MenuSubProps) => (\n <ArkMenu.Root\n positioning={{ offset: { mainAxis: offset, crossAxis: SUBMENU_ALIGN_OFFSET } }}\n navigate={clickLink}\n {...rest}\n >\n {children}\n </ArkMenu.Root>\n)\n\nexport type MenuSubTriggerProps = ArkMenu.TriggerItemProps &\n WithTestId &\n MenuStartSlotProps & {\n color?: Color\n }\n\nconst SubTrigger = ({\n startSection,\n startSlot = startSection,\n color,\n className,\n children,\n testId,\n asChild,\n ...rest\n}: MenuSubTriggerProps) => {\n const { icons } = useContext(MenuContext)\n warnSections(\"SubTrigger\", startSection)\n return (\n <ArkMenu.TriggerItem\n asChild={asChild}\n data-color={color}\n className={cn(menuItem({ colored: color != null }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {startSlot != null && <StartSlot>{startSlot}</StartSlot>}\n {own}\n <span className={cn(popoverChevron, \"ms-auto -me-1 [&_svg]:size-4\")}>\n {icons.submenu}\n </span>\n </>\n ))}\n </ArkMenu.TriggerItem>\n )\n}\n\nexport {\n CheckboxItem,\n Content,\n Divider,\n Item,\n ItemGroupLabel,\n Label,\n RadioGroup,\n RadioItem,\n Root,\n Sub,\n SubTrigger,\n}\n\nexport type MenuTriggerProps = ArkMenu.TriggerProps & WithTestId & { ref?: Ref<HTMLButtonElement> }\n\n/** Ark's `Menu.Trigger` minus one handler. Zag's trigger calls `preventDefault()`\n * on `pointerdown`, which cancels the browser's own mouse-down focus of the\n * button. With no pointer-initiated focus on record, Chromium treats every\n * later *programmatic* focus as keyboard-like: Zag's `focus()` on the content\n * when the menu opens, and its `focus()` back on the trigger when it closes,\n * both match `:focus-visible`, so a mouse user gets the keyboard ring on the\n * trigger after every menu interaction (#227).\n *\n * Leaving `pointerdown` alone restores the platform behaviour — the click\n * focuses the button without a ring, and the programmatic focuses that follow\n * inherit that. Keyboard users keep the ring, since a Tab/Enter/Escape still\n * marks the focus as keyboard-driven. It's also how Zag's own Popover trigger\n * behaves (it never cancels `pointerdown`). */\nexport const Trigger = ({ ref, value, className, testId, ...rest }: MenuTriggerProps) => {\n const menu = useMenuContext()\n const presence = usePresenceContext()\n const { onPointerDown: _cancelsNativeFocus, ...trigger } = menu.getTriggerProps({ value })\n return (\n <ark.button\n {...mergeProps(\n {\n ...trigger,\n \"aria-controls\": presence.unmounted ? undefined : trigger[\"aria-controls\"],\n // The canceled `pointerdown` also blocked a native drag as a side\n // effect: an `asChild` `<a href>`, or the `<img>` of an avatar\n // trigger, would otherwise lift a drag ghost off the trigger.\n // Canceling `dragstart` instead leaves the press, and its focus, alone.\n onDragStart: (event: DragEvent) => event.preventDefault(),\n },\n // Same side effect for text: a double-click or drag on a non-button\n // trigger (`asChild` + `<span role=\"button\">`) would select its label.\n // CSS restores that. It lands on the `asChild` child too, and the\n // consumer's `className` comes last so it can override it.\n { ...props({ \"data-testid\": testId }), ...rest, className: cn(\"select-none\", className) },\n )}\n ref={ref}\n />\n )\n}\n\n/** Ark parts re-exported unchanged (no styling needed). */\nexport const ContextTrigger = ArkMenu.ContextTrigger\nexport const ItemGroup = ArkMenu.ItemGroup\nexport const Context = ArkMenu.Context\n/** Alias for `Divider` (Ark's name for the same part). */\nexport const Separator = Divider\n/** Submenu dropdown — identical surface + portalling to `Menu.Content`. */\nexport const SubContent = Content\n"]}
|