@42-central/ui-react 0.27.0 → 0.28.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 (106) hide show
  1. package/dist/{chunk-OVT2KZHY.js → chunk-3KARNPW4.js} +3 -3
  2. package/dist/{chunk-OVT2KZHY.js.map → chunk-3KARNPW4.js.map} +1 -1
  3. package/dist/chunk-6B2GNPJP.js +43 -0
  4. package/dist/chunk-6B2GNPJP.js.map +1 -0
  5. package/dist/{chunk-E52Z2FKU.js → chunk-7BY5I2RB.js} +3 -3
  6. package/dist/{chunk-E52Z2FKU.js.map → chunk-7BY5I2RB.js.map} +1 -1
  7. package/dist/{chunk-X3YIHN2U.js → chunk-ASKQ6N5V.js} +3 -3
  8. package/dist/{chunk-X3YIHN2U.js.map → chunk-ASKQ6N5V.js.map} +1 -1
  9. package/dist/{chunk-6IRMKF5T.js → chunk-B4GNSSHU.js} +4 -4
  10. package/dist/{chunk-6IRMKF5T.js.map → chunk-B4GNSSHU.js.map} +1 -1
  11. package/dist/{chunk-BMEJBY6H.js → chunk-B5YHYI7E.js} +22 -27
  12. package/dist/chunk-B5YHYI7E.js.map +1 -0
  13. package/dist/{chunk-7OGZT7U2.js → chunk-G3AD3NJG.js} +3 -3
  14. package/dist/{chunk-7OGZT7U2.js.map → chunk-G3AD3NJG.js.map} +1 -1
  15. package/dist/{chunk-MNYY7UU2.js → chunk-GJFCIG34.js} +4 -4
  16. package/dist/{chunk-MNYY7UU2.js.map → chunk-GJFCIG34.js.map} +1 -1
  17. package/dist/{chunk-5H5YOPCF.js → chunk-I53TMAV2.js} +5 -5
  18. package/dist/{chunk-5H5YOPCF.js.map → chunk-I53TMAV2.js.map} +1 -1
  19. package/dist/{chunk-MCRTAUSZ.js → chunk-K3FZHYJL.js} +3 -3
  20. package/dist/{chunk-MCRTAUSZ.js.map → chunk-K3FZHYJL.js.map} +1 -1
  21. package/dist/{chunk-ZVECQBGG.js → chunk-KNGSO7A3.js} +41 -13
  22. package/dist/chunk-KNGSO7A3.js.map +1 -0
  23. package/dist/{chunk-4D2V4JE4.js → chunk-KYVXPSNW.js} +3 -3
  24. package/dist/{chunk-4D2V4JE4.js.map → chunk-KYVXPSNW.js.map} +1 -1
  25. package/dist/{chunk-L24N5EON.js → chunk-P7SH3XWY.js} +3 -3
  26. package/dist/{chunk-L24N5EON.js.map → chunk-P7SH3XWY.js.map} +1 -1
  27. package/dist/{chunk-LKFHUDEW.js → chunk-QVOBLRCM.js} +3 -3
  28. package/dist/{chunk-LKFHUDEW.js.map → chunk-QVOBLRCM.js.map} +1 -1
  29. package/dist/{chunk-SCXXJDKQ.js → chunk-SP6LCCTZ.js} +21 -28
  30. package/dist/chunk-SP6LCCTZ.js.map +1 -0
  31. package/dist/{chunk-Y2G47ARQ.js → chunk-TGGNSSOJ.js} +3 -3
  32. package/dist/{chunk-Y2G47ARQ.js.map → chunk-TGGNSSOJ.js.map} +1 -1
  33. package/dist/{chunk-D2QIPQ74.js → chunk-W3XX7BYT.js} +2 -2
  34. package/dist/chunk-W3XX7BYT.js.map +1 -0
  35. package/dist/{chunk-F374BNL4.js → chunk-YVTM2KRR.js} +12 -8
  36. package/dist/chunk-YVTM2KRR.js.map +1 -0
  37. package/dist/colors.css +328 -0
  38. package/dist/components/action-icon/action-icon.d.ts +6 -5
  39. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  40. package/dist/components/action-icon/index.js +3 -2
  41. package/dist/components/alert/index.js +2 -2
  42. package/dist/components/app-shell/index.js +5 -4
  43. package/dist/components/app-shell/index.js.map +1 -1
  44. package/dist/components/badge/badge.d.ts +1 -1
  45. package/dist/components/badge/badge.d.ts.map +1 -1
  46. package/dist/components/badge/index.js +2 -1
  47. package/dist/components/button/button.d.ts +11 -9
  48. package/dist/components/button/button.d.ts.map +1 -1
  49. package/dist/components/button/index.js +3 -2
  50. package/dist/components/button-multi-select/index.js +4 -3
  51. package/dist/components/button-multi-select/index.js.map +1 -1
  52. package/dist/components/button-select/index.js +4 -3
  53. package/dist/components/button-select/index.js.map +1 -1
  54. package/dist/components/calendar/index.js +4 -3
  55. package/dist/components/camera/index.js +6 -5
  56. package/dist/components/clipboard/index.js +3 -2
  57. package/dist/components/clipboard/index.js.map +1 -1
  58. package/dist/components/data-table/index.js +10 -9
  59. package/dist/components/data-table/index.js.map +1 -1
  60. package/dist/components/date-picker/index.js +7 -6
  61. package/dist/components/date-picker/index.js.map +1 -1
  62. package/dist/components/download-button/index.js +4 -3
  63. package/dist/components/drawer/index.js +5 -4
  64. package/dist/components/file-item/index.js +4 -3
  65. package/dist/components/file-preview/index.js +4 -3
  66. package/dist/components/file-preview/index.js.map +1 -1
  67. package/dist/components/file-trigger/index.js +4 -3
  68. package/dist/components/file-upload/index.js +4 -3
  69. package/dist/components/file-upload/index.js.map +1 -1
  70. package/dist/components/image-cropper/index.js +4 -3
  71. package/dist/components/lightbox/index.js +7 -6
  72. package/dist/components/lightbox/index.js.map +1 -1
  73. package/dist/components/modal/index.js +5 -4
  74. package/dist/components/notification/index.js +3 -3
  75. package/dist/components/overlays/index.js +7 -6
  76. package/dist/components/overlays/index.js.map +1 -1
  77. package/dist/components/photo-capture/index.js +8 -7
  78. package/dist/components/photo-capture/index.js.map +1 -1
  79. package/dist/components/schedule/index.js +4 -3
  80. package/dist/components/schedule/index.js.map +1 -1
  81. package/dist/components/spinner/index.js +1 -1
  82. package/dist/components/spinner/spinner.d.ts +1 -1
  83. package/dist/components/spinner/spinner.d.ts.map +1 -1
  84. package/dist/components/spotlight/index.js +5 -4
  85. package/dist/components/spotlight/index.js.map +1 -1
  86. package/dist/components/theme-icon/index.js +1 -1
  87. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  88. package/dist/lib/button-colors.d.ts +25 -0
  89. package/dist/lib/button-colors.d.ts.map +1 -0
  90. package/package.json +1 -1
  91. package/src/colors.css +328 -0
  92. package/src/components/action-icon/action-icon.test.tsx +22 -0
  93. package/src/components/action-icon/action-icon.tsx +24 -28
  94. package/src/components/badge/badge.test.tsx +53 -10
  95. package/src/components/badge/badge.tsx +64 -11
  96. package/src/components/button/button.test.tsx +41 -5
  97. package/src/components/button/button.tsx +28 -33
  98. package/src/components/spinner/spinner.tsx +3 -3
  99. package/src/components/theme-icon/theme-icon.test.tsx +7 -0
  100. package/src/components/theme-icon/theme-icon.tsx +10 -6
  101. package/src/lib/button-colors.ts +55 -0
  102. package/dist/chunk-BMEJBY6H.js.map +0 -1
  103. package/dist/chunk-D2QIPQ74.js.map +0 -1
  104. package/dist/chunk-F374BNL4.js.map +0 -1
  105. package/dist/chunk-SCXXJDKQ.js.map +0 -1
  106. package/dist/chunk-ZVECQBGG.js.map +0 -1
@@ -4,8 +4,8 @@ import { Badge } from "./badge"
4
4
 
5
5
  describe("Badge", () => {
6
6
  it("renders a non-focusable span by default", () => {
7
- render(<Badge>12</Badge>)
8
- const badge = screen.getByText("12")
7
+ render(<Badge testId="badge">12</Badge>)
8
+ const badge = screen.getByTestId("badge")
9
9
  expect(badge.tagName).toBe("SPAN")
10
10
  expect(badge.getAttribute("tabindex")).toBeNull()
11
11
  })
@@ -14,8 +14,8 @@ describe("Badge", () => {
14
14
  // :focus-visible never matches a plain span — so that they're already in
15
15
  // place when asChild turns the badge into a real control.
16
16
  it("carries the kit's focus ring even as a plain span", () => {
17
- render(<Badge>12</Badge>)
18
- expect(screen.getByText("12").className).toContain("focus-visible:ring-brand-500")
17
+ render(<Badge testId="badge">12</Badge>)
18
+ expect(screen.getByTestId("badge").className).toContain("focus-visible:ring-brand-500")
19
19
  })
20
20
 
21
21
  it("collapses onto an asChild button that is focusable and keeps the ring", () => {
@@ -26,15 +26,21 @@ describe("Badge", () => {
26
26
  )
27
27
 
28
28
  const trigger = screen.getByRole("button", { name: "12 campuses" })
29
- // One node, not a button wrapping a span: the badge *is* the trigger.
30
- expect(trigger.querySelector("span")).toBeNull()
29
+ // One node, not a button wrapping the badge: the badge *is* the trigger,
30
+ // and its text is trimmed inside it like on a plain badge.
31
+ expect(trigger.children).toHaveLength(1)
32
+ expect(trigger.firstElementChild?.className).toBe("text-trim")
31
33
  expect(trigger.className).toContain("focus-visible:ring-brand-500")
32
34
  expect(trigger.className).toContain("focus-visible:ring-offset-2")
33
35
  })
34
36
 
35
37
  it("writes data-color so the palette resolves, but leaves the ring alone", () => {
36
- render(<Badge color="green">Validated</Badge>)
37
- const badge = screen.getByText("Validated")
38
+ render(
39
+ <Badge color="green" testId="badge">
40
+ Validated
41
+ </Badge>,
42
+ )
43
+ const badge = screen.getByTestId("badge")
38
44
  expect(badge.getAttribute("data-color")).toBe("green")
39
45
  // Focus stays brand-500 regardless of palette — see focusStyles.
40
46
  expect(badge.className).toContain("focus-visible:ring-brand-500")
@@ -42,10 +48,47 @@ describe("Badge", () => {
42
48
 
43
49
  it("omits data-color on the gradient variant", () => {
44
50
  render(
45
- <Badge variant="gradient" color="green">
51
+ <Badge variant="gradient" color="green" testId="badge">
46
52
  Pro
47
53
  </Badge>,
48
54
  )
49
- expect(screen.getByText("Pro").getAttribute("data-color")).toBeNull()
55
+ expect(screen.getByTestId("badge").getAttribute("data-color")).toBeNull()
56
+ })
57
+
58
+ // The trimmed span hugs cap height → baseline, so `items-center` centres
59
+ // the caps rather than Lato's lopsided ascent/descent box.
60
+ describe("text trimming", () => {
61
+ it("wraps a run of text in one text-trim span, keeping its spaces", () => {
62
+ const count = 3
63
+ render(<Badge testId="badge">{count} items</Badge>)
64
+ const badge = screen.getByTestId("badge")
65
+ expect(badge.children).toHaveLength(1)
66
+ expect(badge.firstElementChild?.className).toBe("text-trim")
67
+ expect(badge.firstElementChild?.textContent).toBe("3 items")
68
+ })
69
+
70
+ it("leaves icons and other elements as flex siblings of the text", () => {
71
+ render(
72
+ <Badge testId="badge">
73
+ <svg data-testid="icon" />
74
+ Live
75
+ <strong>!</strong>
76
+ </Badge>,
77
+ )
78
+ const kids = [...screen.getByTestId("badge").children]
79
+ expect(kids.map((kid) => kid.tagName)).toEqual(["svg", "SPAN", "STRONG"])
80
+ expect(kids[1]?.className).toBe("text-trim")
81
+ })
82
+
83
+ it("renders no empty span for empty or missing children", () => {
84
+ render(
85
+ <Badge testId="badge">
86
+ {""}
87
+ {null}
88
+ {false}
89
+ </Badge>,
90
+ )
91
+ expect(screen.getByTestId("badge").children).toHaveLength(0)
92
+ })
50
93
  })
51
94
  })
@@ -1,5 +1,7 @@
1
1
  import { ark, type HTMLArkProps } from "@ark-ui/react"
2
2
  import { cva, type VariantProps } from "class-variance-authority"
3
+ import { Children, type ReactNode } from "react"
4
+ import { composeChildren } from "../../lib/as-child"
3
5
  import { cn } from "../../lib/cn"
4
6
  import type { Color } from "../../lib/colors"
5
7
  import { focusStyles } from "../../lib/focus-styles"
@@ -41,6 +43,14 @@ const badgeVariants = cva(
41
43
  "inline-flex items-center",
42
44
  "whitespace-nowrap select-none",
43
45
  "font-sans font-medium",
46
+ // Optically equal padding on all four sides. Each size sets only its
47
+ // height (`--badge-h`); the inline padding is derived from it so the gap
48
+ // beside the text matches the gap above and below the caps:
49
+ // (height − cap height) / 2 − side bearing
50
+ // `1cap` is the cap height of the badge's own font, so this holds for
51
+ // every size and survives a font swap. The 0.08em is Lato's average
52
+ // glyph side bearing, already part of the visible gap at either end.
53
+ "min-h-(--badge-h) px-[calc((var(--badge-h)_-_1cap)/2_-_0.08em)]",
44
54
  // Figma strokes every badge at 0.5px, inside the box. A CSS border cannot
45
55
  // draw that: Chrome rounds any border-width under 1px up to 1px. An inset
46
56
  // ring (box-shadow) is not rounded — one device pixel on a 2x screen, a
@@ -86,19 +96,20 @@ const badgeVariants = cva(
86
96
  },
87
97
  // Figma (node 14950-143827) defines sm/md/lg; xs/xl extrapolate one
88
98
  // step past either end. Radius follows Figma on every step
89
- // (`rounded-badge`, 4px), as do md's height and padding. The rest of
99
+ // (`rounded-badge`, 4px), as does md's height. The rest of
90
100
  // the scale departs from Figma on purpose (3b408c4c), so there the
91
101
  // design catches up to the kit, not the reverse: sm is 12px text, 3px gap, 22px tall
92
- // (Figma 10/4/20); md has a 6px gap (4); lg is 16px text, 8px gap,
93
- // 8px padding (14/4/10). Icon size ([&_svg]:size-*) isn't in the
94
- // Figma spec — scaled by eye to each step, same convention as
95
- // Button's own size variant.
102
+ // (Figma 10/4/20); md has a 6px gap (4); lg is 16px text and an 8px
103
+ // gap (14/4). Padding is not a per-size value: the base classes derive
104
+ // it from `--badge-h`, which lands md on Figma's ~6px. Icon size
105
+ // ([&_svg]:size-*) isn't in the Figma spec — scaled by eye to each
106
+ // step, same convention as Button's own size variant.
96
107
  size: {
97
- xs: "min-h-5 px-0.5 text-[10px] leading-2.5 gap-0.5 rounded-badge [&_svg]:size-2.5",
98
- sm: "min-h-5.5 px-1 text-xs gap-0.75 rounded-badge [&_svg]:size-3",
99
- md: "min-h-6 px-1.5 text-sm gap-1.5 rounded-badge [&_svg]:size-3",
100
- lg: "min-h-7 px-2 text-md gap-2 rounded-badge [&_svg]:size-3.5",
101
- xl: "min-h-8 px-2.5 text-lg gap-3.5 rounded-badge [&_svg]:size-4",
108
+ xs: "[--badge-h:--spacing(5)] text-[10px] leading-2.5 gap-0.5 rounded-badge [&_svg]:size-2.5",
109
+ sm: "[--badge-h:--spacing(5.5)] text-xs gap-0.75 rounded-badge [&_svg]:size-3",
110
+ md: "[--badge-h:--spacing(6)] text-sm gap-1.5 rounded-badge [&_svg]:size-3",
111
+ lg: "[--badge-h:--spacing(7)] text-md gap-2 rounded-badge [&_svg]:size-3.5",
112
+ xl: "[--badge-h:--spacing(8)] text-lg gap-3.5 rounded-badge [&_svg]:size-4",
102
113
  },
103
114
  },
104
115
  defaultVariants: {
@@ -127,6 +138,43 @@ export type BadgeProps = Omit<HTMLArkProps<"span">, "color"> &
127
138
  gradient?: GradientProps
128
139
  }
129
140
 
141
+ type TextNode = string | number
142
+ const isText = (node: ReactNode): node is TextNode =>
143
+ typeof node === "string" || typeof node === "number"
144
+
145
+ /**
146
+ * Wraps each run of bare text in a `text-trim` span, leaving icons and other
147
+ * elements as they are.
148
+ *
149
+ * Untrimmed, the text's line box carries the font's ascent and descent, which
150
+ * Lato does not split evenly around its caps — so `items-center` centred the
151
+ * line box and left the caps ~1px high at sm/md. Trimmed to cap height →
152
+ * baseline, the span *is* the caps, so `items-center` centres them, and an icon
153
+ * beside them centres on the caps too. It has to be a wrapper: `text-box-trim`
154
+ * applies to block containers and inline boxes, and bare text in a flex
155
+ * container lives in an anonymous flex item that no class can reach.
156
+ *
157
+ * A run is grouped, not each node wrapped: `{count} items` arrives as two
158
+ * children, and splitting them would put the flex `gap` where the space was.
159
+ * The trimmed box ends at the baseline but nothing clips it, so descenders
160
+ * still paint below it.
161
+ */
162
+ const trimTextRuns = (own: ReactNode): ReactNode => {
163
+ const nodes = Children.toArray(own).filter((node) => node !== "")
164
+ return nodes.flatMap<ReactNode>((node, i) => {
165
+ if (!isText(node)) return [node]
166
+ // Only the first node of a run renders it; the rest are already inside.
167
+ if (i > 0 && isText(nodes[i - 1])) return []
168
+ const end = nodes.findIndex((next, j) => j > i && !isText(next))
169
+ return [
170
+ // biome-ignore lint/suspicious/noArrayIndexKey: a text run has no identity but its position
171
+ <span key={`text-${i}`} className="text-trim">
172
+ {nodes.slice(i, end === -1 ? undefined : end)}
173
+ </span>,
174
+ ]
175
+ })
176
+ }
177
+
130
178
  export const Badge = ({
131
179
  className,
132
180
  variant,
@@ -135,6 +183,8 @@ export const Badge = ({
135
183
  gradient,
136
184
  style,
137
185
  testId,
186
+ asChild,
187
+ children,
138
188
  ...rest
139
189
  }: BadgeProps) => {
140
190
  const isGradient = variant === "gradient"
@@ -149,7 +199,10 @@ export const Badge = ({
149
199
  className,
150
200
  )}
151
201
  {...props({ "data-testid": testId })}
202
+ asChild={asChild}
152
203
  {...rest}
153
- />
204
+ >
205
+ {composeChildren(asChild, children, trimTextRuns)}
206
+ </ark.span>
154
207
  )
155
208
  }
@@ -135,12 +135,48 @@ describe("Button", () => {
135
135
  expect(onLinkClick).not.toHaveBeenCalled()
136
136
  })
137
137
 
138
- it("keeps full contrast while loading, scoping the :disabled dim to a plain disabled", () => {
138
+ it("keeps full contrast while loading, scoping the :disabled tints to a plain disabled", () => {
139
139
  render(<Button loading>Saving</Button>)
140
140
  const loading = screen.getByRole("button", { name: "Saving" })
141
- // Class tokens, not substrings: `disabled:not-data-loading:opacity-50`
142
- // contains `data-loading:opacity-50`.
143
- expect([...loading.classList]).not.toContain("data-loading:opacity-50")
144
- expect([...loading.classList]).toContain("disabled:not-data-loading:opacity-50")
141
+ const classes = [...loading.classList]
142
+ expect(classes.some((c) => c.includes("opacity-50"))).toBe(false)
143
+ // Every :disabled colour is gated off while loading, which also sets native disabled.
144
+ const disabledColours = classes.filter(
145
+ (c) => c.startsWith("disabled:") && c.includes("(--btn-"),
146
+ )
147
+ expect(disabledColours.length).toBeGreaterThan(0)
148
+ expect(disabledColours.every((c) => c.startsWith("disabled:not-data-loading:"))).toBe(true)
149
+ })
150
+
151
+ it("keys the disabled tints off data-disabled too, for an asChild element", () => {
152
+ render(<Button disabled>Off</Button>)
153
+ expect([...screen.getByRole("button", { name: "Off" }).classList]).toContain(
154
+ "data-disabled:bg-(--btn-disabled-bg)",
155
+ )
156
+ })
157
+
158
+ it("renders the link variant as bare underlined text, without the size box", () => {
159
+ render(
160
+ <Button variant="link" size="lg" startSlot={<span data-testid="icon" />}>
161
+ Read more
162
+ </Button>,
163
+ )
164
+ const link = screen.getByRole("button", { name: "Read more" })
165
+ const classes = [...link.classList]
166
+ expect(link.getAttribute("data-variant")).toBe("link")
167
+ expect(classes).toEqual(
168
+ expect.arrayContaining(["h-auto", "px-0", "underline", "text-(--btn-link-text)"]),
169
+ )
170
+ expect(classes).not.toContain("h-10")
171
+ expect(classes).not.toContain("no-underline")
172
+ // The slot's negative margin would pull the icon outside the unpadded box.
173
+ expect(screen.getByTestId("icon").parentElement?.className).toContain("ms-0")
174
+ })
175
+
176
+ it("sizes its icons through a zero-specificity rule, so a class on the icon wins", () => {
177
+ render(<Button size="lg">Go</Button>)
178
+ const classes = [...screen.getByRole("button", { name: "Go" }).classList]
179
+ expect(classes).toContain("[:where(&)_svg]:size-5")
180
+ expect(classes.some((c) => c.startsWith("[&_svg]"))).toBe(false)
145
181
  })
146
182
  })
@@ -4,6 +4,7 @@ import { ark, type HTMLArkProps } from "@ark-ui/react"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
5
5
  import type { MouseEvent, ReactNode } from "react"
6
6
  import { withAsChildContent } from "../../lib/as-child"
7
+ import { buttonColorVariants } from "../../lib/button-colors"
7
8
  import { cn } from "../../lib/cn"
8
9
  import type { Color } from "../../lib/colors"
9
10
  import { focusStyles } from "../../lib/focus-styles"
@@ -15,13 +16,15 @@ import { Spinner } from "../spinner/spinner"
15
16
  * Button — interactive but stateless primitive.
16
17
  *
17
18
  * The new (variant × color) model splits visual treatment from accent palette:
18
- * - `variant` picks the shape (filled / light / outline / subtle)
19
- * - `color` picks the palette (brand / gray / neutral / red / orange / …)
19
+ * - `variant` picks the shape (filled / light / outline / subtle / link)
20
+ * - `color` picks the palette (brand / neutral / red / orange / …)
20
21
  *
21
22
  * Color is delivered through CSS variables: the component writes a
22
23
  * `data-color="…"` attribute and the global rules in `colors.css` resolve
23
- * `--c-solid`, `--c-soft`, `--c-text` etc. for both light and dark mode. So
24
- * the cva matrix only enumerates variants, not (variant × color) pairs.
24
+ * the button-only `--btn-*` slots (copied from the Figma Button set) for
25
+ * both light and dark mode. So the cva matrix only enumerates variants, not
26
+ * (variant × color) pairs; the per-variant classes live in
27
+ * `lib/button-colors.ts`, shared with ActionIcon.
25
28
  * When `color` is omitted, no `data-color` attribute is rendered and the
26
29
  * slot vars cascade from `:root` — which mirrors `neutral` — so the
27
30
  * zero-config `<Button>` renders `filled` · `neutral`. Consumers retheme the
@@ -53,10 +56,10 @@ import { Spinner } from "../spinner/spinner"
53
56
  * spinner at all. Under `motion-reduce` the swap is instant; the spinner
54
57
  * itself still turns.
55
58
  *
56
- * A loading button keeps full contrast — dimming it would read as
57
- * `disabled`. `disabled` alone still dims (`not-data-loading:` scopes the
58
- * `:disabled` dim off, since `resolvedDisabled` sets native `disabled` for
59
- * `loading` too).
59
+ * A loading button keeps full contrast — muting it would read as
60
+ * `disabled`. `disabled` alone switches to the palette's disabled tints
61
+ * (`not-data-loading:` scopes the `:disabled` colours off, since
62
+ * `resolvedDisabled` sets native `disabled` for `loading` too).
60
63
  *
61
64
  * `loading` doesn't use `pointer-events-none` to block interaction — that
62
65
  * also blocks `:hover`, which would make `cursor-progress` unreachable by a
@@ -77,37 +80,29 @@ const buttonVariants = cva(
77
80
  "rounded-button border border-transparent",
78
81
  "transition-colors-radius",
79
82
  focusStyles(),
80
- "disabled:not-data-loading:pointer-events-none disabled:not-data-loading:opacity-50",
81
- "data-disabled:pointer-events-none data-disabled:opacity-50",
83
+ "disabled:not-data-loading:pointer-events-none data-disabled:pointer-events-none",
82
84
  "not-data-loading:hover:cursor-pointer",
83
85
  "data-loading:cursor-progress",
84
- "[&_svg]:shrink-0 [&_svg]:pointer-events-none",
86
+ // Every svg rule is `[:where(&)_svg]`: zero class specificity, so a size
87
+ // class on the icon itself (`<Star className="size-5" />`) or a nested
88
+ // component's own svg rule wins whatever the CSS order. Lucide's `size`
89
+ // prop is only an HTML attribute and still loses. Same fix as Input (#427).
90
+ "[:where(&)_svg]:shrink-0 [:where(&)_svg]:pointer-events-none",
85
91
  ],
86
92
  {
87
93
  variants: {
88
- variant: {
89
- filled: [
90
- "bg-(--c-solid) text-(--c-on-solid)",
91
- "not-data-loading:hover:bg-(--c-solid-hover)",
92
- ],
93
- light: [
94
- "bg-(--c-soft) text-(--c-text) border-(--c-soft-hover)",
95
- "not-data-loading:hover:bg-(--c-soft-hover) not-data-loading:hover:border-(--c-solid)",
96
- ],
97
- outline: [
98
- "bg-transparent text-(--c-text) border-(--c-solid)/35",
99
- "not-data-loading:hover:bg-(--c-soft)",
100
- ],
101
- subtle: ["bg-transparent text-(--c-text)", "not-data-loading:hover:bg-(--c-soft)"],
102
- },
94
+ variant: buttonColorVariants,
103
95
  size: {
104
- xs: "h-7 px-2 text-xs [&_svg]:size-3 gap-1",
105
- sm: "h-8 px-3 text-sm [&_svg]:size-3.5 gap-1.5",
106
- md: "h-9 px-4 text-md [&_svg]:size-4 gap-2",
107
- lg: "h-10 px-4 text-lg [&_svg]:size-5 gap-3",
108
- xl: "h-12 px-5 text-xl [&_svg]:size-6 gap-3",
96
+ xs: "h-7 px-2 text-xs [:where(&)_svg]:size-3 gap-1",
97
+ sm: "h-8 px-3 text-sm [:where(&)_svg]:size-3.5 gap-1.5",
98
+ md: "h-9 px-4 text-md [:where(&)_svg]:size-4 gap-2",
99
+ lg: "h-10 px-4 text-lg [:where(&)_svg]:size-5 gap-3",
100
+ xl: "h-12 px-5 text-xl [:where(&)_svg]:size-6 gap-3",
109
101
  },
110
102
  },
103
+ // Figma's link is bare text: no box, no padding, no fixed height. A
104
+ // compound variant so it lands after (and wins over) the size classes.
105
+ compoundVariants: [{ variant: "link", class: "h-auto px-0 rounded-none border-0" }],
111
106
  defaultVariants: {
112
107
  variant: "filled",
113
108
  size: "md",
@@ -271,13 +266,13 @@ export const Button = ({
271
266
  const content = (own: ReactNode) => (
272
267
  <>
273
268
  {startSlot && (
274
- <HiddenSlot className={startSlotVariants({ size })}>
269
+ <HiddenSlot className={cn(startSlotVariants({ size }), variant === "link" && "ms-0")}>
275
270
  {morph === "start" ? <LoadingSlot loading={loading}>{startSlot}</LoadingSlot> : startSlot}
276
271
  </HiddenSlot>
277
272
  )}
278
273
  {morph === "label" ? <LoadingLabel loading={loading}>{own}</LoadingLabel> : own}
279
274
  {endSlot && (
280
- <HiddenSlot className={endSlotVariants({ size })}>
275
+ <HiddenSlot className={cn(endSlotVariants({ size }), variant === "link" && "me-0")}>
281
276
  {morph === "end" ? <LoadingSlot loading={loading}>{endSlot}</LoadingSlot> : endSlot}
282
277
  </HiddenSlot>
283
278
  )}
@@ -24,7 +24,7 @@ import { TEXT_COLOR_CLASSES } from "../../lib/typography-size"
24
24
  * paints the primitives behind Figma's `Text/text-primary` (`brand-950` / `white`).
25
25
  *
26
26
  * Sizing follows the same logic: omit `size` to inherit from a parent's
27
- * `[&_svg]:size-*` rule (Button does this), or set it explicitly for
27
+ * svg size rule (Button's `[:where(&)_svg]:size-*`), or set it explicitly for
28
28
  * standalone use.
29
29
  *
30
30
  * Accessibility: a standalone spinner is a `role="status"` live region holding
@@ -59,7 +59,7 @@ export type SpinnerColor = Color | "currentColor" | "default"
59
59
 
60
60
  export type SpinnerProps = Omit<ComponentPropsWithoutRef<"span">, "color" | "children"> &
61
61
  WithTestId & {
62
- /** Explicit size; omit to inherit from a parent's `[&_svg]:size-*` rule. */
62
+ /** Explicit size; omit to inherit from a parent's svg size rule. */
63
63
  size?: SpinnerSize
64
64
  /**
65
65
  * Stroke color. Omit (or pass `"currentColor"`) to inherit the surrounding
@@ -122,7 +122,7 @@ export const Spinner = ({
122
122
  strokeLinejoin="round"
123
123
  aria-hidden
124
124
  // Sized: fill the root. Unsized: keep the 24px intrinsic size, or a parent's
125
- // `[&_svg]:size-*` rule (Button's), which the root then hugs.
125
+ // svg size rule (Button's), which the root then hugs.
126
126
  className={cn("block", size && "size-full")}
127
127
  >
128
128
  {withTrack && <circle cx="12" cy="12" r="10" strokeWidth={1} className="opacity-20" />}
@@ -17,4 +17,11 @@ describe("ThemeIcon", () => {
17
17
  const link = screen.getByRole("link", { name: "settings" })
18
18
  expect(link.className).toContain("focus-visible:ring-brand-500")
19
19
  })
20
+
21
+ it("sizes its icon through a zero-specificity rule, so a class on the icon wins", () => {
22
+ render(<ThemeIcon testId="icon" size="md" />)
23
+ const classes = [...screen.getByTestId("icon").classList]
24
+ expect(classes).toContain("[:where(&)_svg]:size-4")
25
+ expect(classes.some((c) => c.startsWith("[&_svg]"))).toBe(false)
26
+ })
20
27
  })
@@ -26,7 +26,11 @@ const themeIconVariants = cva(
26
26
  "inline-flex items-center justify-center",
27
27
  "aspect-square shrink-0 select-none",
28
28
  "rounded-lg border",
29
- "[&_svg]:shrink-0 [&_svg]:pointer-events-none",
29
+ // Every svg rule is `[:where(&)_svg]`: zero class specificity, so a size
30
+ // class on the icon itself (`<Star className="size-5" />`) or a nested
31
+ // component's own svg rule wins whatever the CSS order. Lucide's `size`
32
+ // prop is only an HTML attribute and still loses. Same fix as Input (#427).
33
+ "[:where(&)_svg]:shrink-0 [:where(&)_svg]:pointer-events-none",
30
34
  // Inert on the default non-focusable <div>; applies once `asChild`
31
35
  // renders ThemeIcon onto a real <a>/<button>. See `focusStyles`.
32
36
  focusStyles(),
@@ -98,11 +102,11 @@ const themeIconVariants = cva(
98
102
  // a 28/32/36/40/48px tile — under half the tile, so the tile reads as a
99
103
  // frame around the icon, not as the icon's own padding.
100
104
  size: {
101
- xs: "h-7 [&_svg]:size-3",
102
- sm: "h-8 [&_svg]:size-3.5",
103
- md: "h-9 [&_svg]:size-4",
104
- lg: "h-10 [&_svg]:size-4.5",
105
- xl: "h-12 [&_svg]:size-5.5",
105
+ xs: "h-7 [:where(&)_svg]:size-3",
106
+ sm: "h-8 [:where(&)_svg]:size-3.5",
107
+ md: "h-9 [:where(&)_svg]:size-4",
108
+ lg: "h-10 [:where(&)_svg]:size-4.5",
109
+ xl: "h-12 [:where(&)_svg]:size-5.5",
106
110
  },
107
111
  radius: {
108
112
  xs: "rounded-xs",
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Colour classes shared by Button and ActionIcon, one entry per variant.
3
+ *
4
+ * Every value comes from the `--btn-*` slots in `colors.css`, which copy the
5
+ * 42 UI Kit V3 Figma `Buttons/Button` set (Figma's ActionIcon is an instance
6
+ * of it). Shape, size and layout stay in each component's own `cva`.
7
+ *
8
+ * Hovers are gated on `not-data-loading:` so a loading control keeps its
9
+ * resting colours. Disabled colours are keyed twice: `:disabled` for a real
10
+ * `<button>` (scoped off while loading, which also sets native `disabled`)
11
+ * and `data-disabled` for an `asChild` element, where `:disabled` never
12
+ * matches.
13
+ *
14
+ * Every class is written out in full: Tailwind only generates CSS for class
15
+ * names it finds literally in the source, so composing the prefixes with a
16
+ * template string would silently drop every hover and disabled rule.
17
+ */
18
+ export const buttonColorVariants = {
19
+ filled: [
20
+ "bg-(--btn-solid) text-(--btn-on-solid)",
21
+ "not-data-loading:hover:bg-(--btn-solid-hover)",
22
+ "disabled:not-data-loading:bg-(--btn-disabled-bg) data-disabled:bg-(--btn-disabled-bg)",
23
+ "disabled:not-data-loading:border-(--btn-disabled-border) data-disabled:border-(--btn-disabled-border)",
24
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
25
+ ],
26
+ light: [
27
+ "bg-(--btn-light-bg) border-(--btn-light-border) text-(--btn-light-text)",
28
+ "not-data-loading:hover:bg-(--btn-light-hover-bg)",
29
+ "not-data-loading:hover:border-(--btn-light-hover-border)",
30
+ "not-data-loading:hover:text-(--btn-light-hover-text)",
31
+ "disabled:not-data-loading:bg-(--btn-light-disabled-bg) data-disabled:bg-(--btn-light-disabled-bg)",
32
+ "disabled:not-data-loading:border-(--btn-light-disabled-border) data-disabled:border-(--btn-light-disabled-border)",
33
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
34
+ ],
35
+ outline: [
36
+ "bg-transparent border-(--btn-outline-border) text-(--btn-outline-text)",
37
+ "not-data-loading:hover:bg-(--btn-outline-hover-bg)",
38
+ "not-data-loading:hover:border-(--btn-outline-hover-border)",
39
+ "not-data-loading:hover:text-(--btn-outline-hover-text)",
40
+ "disabled:not-data-loading:bg-(--btn-disabled-bg) data-disabled:bg-(--btn-disabled-bg)",
41
+ "disabled:not-data-loading:border-(--btn-disabled-border) data-disabled:border-(--btn-disabled-border)",
42
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
43
+ ],
44
+ subtle: [
45
+ "bg-transparent text-(--btn-subtle-text)",
46
+ "not-data-loading:hover:bg-(--btn-subtle-hover-bg)",
47
+ "not-data-loading:hover:text-(--btn-subtle-hover-text)",
48
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
49
+ ],
50
+ link: [
51
+ "bg-transparent text-(--btn-link-text) underline underline-offset-2",
52
+ "not-data-loading:hover:text-(--btn-link-hover)",
53
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
54
+ ],
55
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/action-icon/action-icon.tsx"],"names":[],"mappings":";;;;;;;;;AAuCA,IAAM,kBAAA,GAAqB,GAAA;AAAA,EACzB;AAAA,IACE,yCAAA;AAAA,IACA,oCAAA;AAAA,IACA,qCAAA;AAAA,IACA,cAAA;AAAA,IACA,+CAAA;AAAA,IACA,0BAAA;AAAA,IACA,WAAA,EAAY;AAAA,IACZ,mEAAA;AAAA,IACA,4DAAA;AAAA,IACA,uCAAA;AAAA,IACA,sDAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,MAAA,EAAQ;AAAA,UACN,oCAAA;AAAA,UACA;AAAA,SACF;AAAA,QACA,KAAA,EAAO;AAAA,UACL,uDAAA;AAAA,UACA;AAAA,SACF;AAAA;AAAA;AAAA,QAGA,OAAA,EAAS;AAAA,UACP,sDAAA;AAAA,UACA;AAAA,SACF;AAAA,QACA,MAAA,EAAQ,CAAC,gCAAA,EAAkC,sCAAsC,CAAA;AAAA,QACjF,OAAA,EAAS;AAAA,UACP,8EAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,4BAAA;AAAA,QACJ,EAAA,EAAI,8BAAA;AAAA,QACJ,EAAA,EAAI,4BAAA;AAAA,QACJ,EAAA,EAAI,6BAAA;AAAA,QACJ,EAAA,EAAI;AAAA,OACN;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAA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,cAAA,EAAgB,OAAA;AAAA,QAChB,aAAA,EAAe;AAAA,OAChB,CAAA;AAAA,MACA,GAAG,IAAA;AAAA,MAEH,QAAA,EAAA,OAAA,IAAW,UACV,kBAAA,CAAmB,QAAA,EAAU,sBAAM,GAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAO,IAAA,EAAM,CAAA,EAAI;AAAA,QAC3D,OAAA,EAAS;AAAA,OACV,CAAA,GACC,OAAA,uBACD,OAAA,EAAA,EAAQ,KAAA,EAAO,MAAM,CAAA,GAEtB;AAAA;AAAA,GAEJ;AAEJ","file":"chunk-BMEJBY6H.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { MouseEvent } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * ActionIcon — square, icon-only sibling of `Button`.\n *\n * Same (variant × color) model as `Button`:\n * - `variant` picks the shape (filled / light / outline / subtle / default)\n * - `color` picks the palette (brand / gray / red / …)\n * - Color is delivered via `data-color` + the slot vars in `colors.css`,\n * so dark mode shade-shifts happen at the CSS layer.\n *\n * What's specific to ActionIcon:\n * - Forced 1:1 aspect ratio.\n * - Own `radius` scale (incl. `full` for circular FABs / like-buttons).\n * - Wider size scale (xs..xl) than Button — toolbar density matters here.\n *\n * The accessible name MUST come from `aria-label` (or `aria-labelledby`); the\n * icon children are decoration.\n *\n * `asChild` renders the single child with ActionIcon's styling. Ark's\n * factory clones exactly one element, so `loading`'s spinner replaces\n * *that* element's own children (`withAsChildContent`, `lib/as-child.ts`)\n * rather than the element itself. The `onClick` guard (`preventWhileLoading`)\n * goes on the same clone, since `disabled` doesn't do anything on an\n * arbitrary `asChild` element (e.g. an `<a>`) — same reason the `opacity-50`\n * dimming and `pointer-events-none` blocking are keyed off `data-loading`\n * rather than `:disabled` (see `Button`'s note on this).\n */\nconst actionIconVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"aspect-square shrink-0 select-none\",\n \"font-medium uppercase tracking-wide\",\n \"no-underline\",\n \"rounded-action-icon border border-transparent\",\n \"transition-colors-radius\",\n focusStyles(),\n \"disabled:not-data-loading:pointer-events-none disabled:opacity-50\",\n \"data-disabled:pointer-events-none data-disabled:opacity-50\",\n \"not-data-loading:hover:cursor-pointer\",\n \"data-loading:cursor-progress data-loading:opacity-50\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n ],\n {\n variants: {\n variant: {\n filled: [\n \"bg-(--c-solid) text-(--c-on-solid)\",\n \"not-data-loading:hover:bg-(--c-solid-hover)\",\n ],\n light: [\n \"bg-(--c-soft) text-(--c-text) border-(--c-soft-hover)\",\n \"not-data-loading:hover:bg-(--c-soft-hover) not-data-loading:hover:border-(--c-solid)\",\n ],\n // Button's outline edge (the colour at 35%), so the two read as one\n // stroke weight side by side in a toolbar.\n outline: [\n \"bg-transparent text-(--c-text) border-(--c-solid)/35\",\n \"not-data-loading:hover:bg-(--c-soft)\",\n ],\n subtle: [\"bg-transparent text-(--c-text)\", \"not-data-loading:hover:bg-(--c-soft)\"],\n default: [\n \"bg-brand-950 text-white border-brand-800 not-data-loading:hover:bg-brand-800\",\n \"dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80\",\n ],\n },\n size: {\n xs: \"h-7 text-xs [&_svg]:size-5\",\n sm: \"h-8 text-sm [&_svg]:size-5.5\",\n md: \"h-9 text-md [&_svg]:size-6\",\n lg: \"h-10 text-lg [&_svg]:size-7\",\n xl: \"h-12 text-xl [&_svg]:size-8\",\n },\n radius: {\n xs: \"rounded-xs\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-lg\",\n xl: \"rounded-xl\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n)\n\nexport type ActionIconVariant = NonNullable<VariantProps<typeof actionIconVariants>[\"variant\"]>\nexport type ActionIconSize = NonNullable<VariantProps<typeof actionIconVariants>[\"size\"]>\nexport type ActionIconRadius = NonNullable<VariantProps<typeof actionIconVariants>[\"radius\"]>\n\nexport type ActionIconProps = Omit<HTMLArkProps<\"button\">, \"color\"> &\n VariantProps<typeof actionIconVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n /**\n * Replace the icon with a spinner, mark the element as busy, and suppress\n * pointer interactions. Mirrors `Button`'s `loading`.\n */\n loading?: boolean\n }\n\n/** Mirrors `Button`'s `preventWhileLoading` — see the note there. */\nconst preventWhileLoading = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n}\n\nexport const ActionIcon = ({\n className,\n variant,\n size,\n radius,\n color,\n loading = false,\n children,\n disabled,\n type,\n asChild,\n testId,\n onClick,\n ...rest\n}: ActionIconProps) => {\n const resolvedDisabled = disabled || loading\n const resolvedOnClick = loading ? preventWhileLoading : onClick\n\n return (\n <ark.button\n asChild={asChild}\n type={asChild ? type : (type ?? \"button\")}\n disabled={resolvedDisabled}\n data-color={color}\n data-variant={variant ?? \"default\"}\n className={cn(actionIconVariants({ variant, size, radius }), className)}\n onClick={resolvedOnClick}\n {...props({\n \"aria-busy\": loading,\n \"aria-disabled\": resolvedDisabled,\n \"data-loading\": loading,\n \"data-testid\": testId,\n })}\n {...rest}\n >\n {asChild && loading ? (\n withAsChildContent(children, () => <Spinner label={null} />, {\n onClick: preventWhileLoading,\n })\n ) : loading ? (\n <Spinner label={null} />\n ) : (\n children\n )}\n </ark.button>\n )\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/spinner/spinner.tsx"],"names":[],"mappings":";;;;;AA0CA,IAAM,YAAA,GAAqC;AAAA,EACzC,EA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,EAAO,cAAA;AAAA,YACP,aAAA,EAAc,OAAA;AAAA,YACd,cAAA,EAAe,OAAA;AAAA,YACf,aAAA,EAAW,IAAA;AAAA,YAGX,SAAA,EAAW,EAAA,CAAG,OAAA,EAAS,IAAA,IAAQ,WAAW,CAAA;AAAA,YAEzC,QAAA,EAAA;AAAA,cAAA,SAAA,oBAAa,GAAA,CAAC,QAAA,EAAA,EAAO,EAAA,EAAG,IAAA,EAAK,EAAA,EAAG,IAAA,EAAK,CAAA,EAAE,IAAA,EAAK,WAAA,EAAa,CAAA,EAAG,SAAA,EAAU,YAAA,EAAa,CAAA;AAAA,8BACpF,GAAA;AAAA,gBAAC,QAAA;AAAA,gBAAA;AAAA,kBACC,EAAA,EAAG,IAAA;AAAA,kBACH,EAAA,EAAG,IAAA;AAAA,kBACH,CAAA,EAAE,IAAA;AAAA,kBACF,WAAA,EAAa,CAAA;AAAA,kBACb,eAAA,EAAgB,OAAA;AAAA,kBAChB,aAAA,EAAc,OAAA;AAAA,kBACd,SAAA,EAAU;AAAA;AAAA;AACZ;AAAA;AAAA,SACF;AAAA,QACC,CAAC,UAAA,oBAAc,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,WAAW,QAAA,EAAA,KAAA,EAAM;AAAA;AAAA;AAAA,GACnD;AAEJ","file":"chunk-D2QIPQ74.js","sourcesContent":["import type { ComponentPropsWithoutRef } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\n\n/**\n * Spinner — inline activity indicator.\n *\n * Pure React Server Component. The SVG strokes use `currentColor`, so when\n * `color` is omitted the spinner inherits its parent's text color — that's\n * how Button/ActionIcon embed it without extra plumbing. Pass a palette\n * `color` to route through the `data-color` + slot-var system and emit a\n * palette stroke regardless of the surrounding text color.\n *\n * Two non-palette `color` values round out the prop:\n * - `\"currentColor\"` — the explicit, named form of the omit-color behavior\n * (inherit the surrounding text color); handy when a call site wants to\n * state the intent rather than rely on the absence of a prop.\n * - `\"default\"` — the neutral high-contrast stroke that matches Button's\n * `default` variant. Like that variant, it sidesteps the slot vars and\n * paints the primitives behind Figma's `Text/text-primary` (`brand-950` / `white`).\n *\n * Sizing follows the same logic: omit `size` to inherit from a parent's\n * `[&_svg]:size-*` rule (Button does this), or set it explicitly for\n * standalone use.\n *\n * Accessibility: a standalone spinner is a `role=\"status\"` live region holding\n * visually hidden \"Loading\" text (the `label`), so it is announced as a status\n * rather than read as a picture. Inside containers that already broadcast a\n * busy state (`aria-busy=\"true\"` on Button/ActionIcon), pass `label={null}` to\n * make it decorative (`aria-hidden`) and avoid double announcements.\n *\n * The rotation lives on the root, so `className` (e.g. Button's\n * `[animation-play-state:paused]`) reaches the animated element. Under\n * `prefers-reduced-motion` it stops and the arc rests in place, the same rule\n * the kit applies to `Progress`/`CircularProgress`'s indeterminate loops.\n */\n\n/** One size scale for the root; the ring fills it. */\nconst SPINNER_SIZE: Record<Size, string> = {\n xs: \"size-3\",\n sm: \"size-4\",\n md: \"size-5\",\n lg: \"size-6\",\n xl: \"size-8\",\n}\n\nexport type SpinnerSize = Size\n\n/**\n * The spinner's `color` accepts the shared palette plus two non-palette\n * tokens: `\"currentColor\"` (explicit inherit) and `\"default\"` (neutral\n * high-contrast stroke matching Button's `default` variant).\n */\nexport type SpinnerColor = Color | \"currentColor\" | \"default\"\n\nexport type SpinnerProps = Omit<ComponentPropsWithoutRef<\"span\">, \"color\" | \"children\"> &\n WithTestId & {\n /** Explicit size; omit to inherit from a parent's `[&_svg]:size-*` rule. */\n size?: SpinnerSize\n /**\n * Stroke color. Omit (or pass `\"currentColor\"`) to inherit the surrounding\n * text color; pass a palette name to route through the slot vars; pass\n * `\"default\"` for the neutral high-contrast stroke that matches Button's\n * `default` variant.\n */\n color?: SpinnerColor\n /**\n * Status text announced by assistive tech. Defaults to `\"Loading\"`. Set to\n * `null` for a purely decorative spinner (e.g. inside a button that already\n * has `aria-busy`).\n */\n label?: string | null\n /** Draws a faint full ring under the spinning arc, so the arc reads as moving around a track. */\n withTrack?: boolean\n }\n\nexport const Spinner = ({\n className,\n size,\n color,\n label = \"Loading\",\n withTrack = false,\n testId,\n ...rest\n}: SpinnerProps) => {\n const decorative = label === null\n // Only real palette names drive the slot-var system. `\"currentColor\"` and\n // `\"default\"` are handled with literal classes below, so they neither emit a\n // `data-color` nor reach for `--c-solid`.\n const isPalette = color !== undefined && color !== \"currentColor\" && color !== \"default\"\n return (\n <span\n // A status, not a picture: the label is live text, read when the spinner\n // appears. Decorative spinners leave the tree entirely.\n {...(decorative ? { \"aria-hidden\": true } : { role: \"status\", \"aria-label\": label })}\n data-color={isPalette ? color : undefined}\n className={cn(\n // `relative` contains the sr-only label, so it can't escape a scroller.\n // `w-fit`: the root is what spins, so it must hug the ring, never a whole row.\n \"relative flex w-fit shrink-0 items-center justify-center aspect-square origin-center\",\n \"animate-spin motion-reduce:animate-none text-current\",\n size && SPINNER_SIZE[size],\n isPalette && \"text-(--c-solid)\",\n color === \"default\" && TEXT_COLOR_CLASSES.primary,\n className,\n )}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden\n // Sized: fill the root. Unsized: keep the 24px intrinsic size, or a parent's\n // `[&_svg]:size-*` rule (Button's), which the root then hugs.\n className={cn(\"block\", size && \"size-full\")}\n >\n {withTrack && <circle cx=\"12\" cy=\"12\" r=\"10\" strokeWidth={1} className=\"opacity-20\" />}\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n strokeWidth={2}\n strokeDasharray=\"42 20\"\n strokeLinecap=\"round\"\n className=\"opacity-90\"\n />\n </svg>\n {!decorative && <span className=\"sr-only\">{label}</span>}\n </span>\n )\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/theme-icon/theme-icon.tsx"],"names":[],"mappings":";;;;;;;AAuBA,IAAM,iBAAA,GAAoB,GAAA;AAAA,EACxB;AAAA,IACE,yCAAA;AAAA,IACA,oCAAA;AAAA,IACA,mBAAA;AAAA,IACA,8CAAA;AAAA;AAAA;AAAA,IAGA,WAAA;AAAY,GACd;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAYP,MAAA,EACE,6FAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAiBF,KAAA,EAAO;AAAA,UACL,qEAAA;AAAA,UACA,oJAAA;AAAA,UACA,6JAAA;AAAA,UACA;AAAA,SACF;AAAA;AAAA;AAAA;AAAA;AAAA,QAKA,OAAA,EAAS;AAAA,UACP,gGAAA;AAAA,UACA;AAAA,SACF;AAAA,QACA,MAAA,EAAQ;AAAA,UACN,gGAAA;AAAA,UACA;AAAA,SACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASA,OAAA,EAAS;AAAA,UACP,kDAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA;AAAA;AAAA;AAAA,MAIA,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA,QACJ,EAAA,EAAI,sBAAA;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA,QACJ,EAAA,EAAI,uBAAA;AAAA,QACJ,EAAA,EAAI;AAAA,OACN;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS,SAAA;AAAA,MACT,IAAA,EAAM,IAAA;AAAA,MACN,MAAA,EAAQ;AAAA;AACV;AAEJ,CAAA;AAaO,IAAM,YAAY,CAAC;AAAA,EACxB,SAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA;AAAA,EAAC,GAAA,CAAI,GAAA;AAAA,EAAJ;AAAA,IACC,OAAA;AAAA,IACA,YAAA,EAAY,KAAA;AAAA,IACZ,gBAAc,OAAA,IAAW,SAAA;AAAA,IACzB,SAAA,EAAW,GAAG,iBAAA,CAAkB,EAAE,SAAS,IAAA,EAAM,MAAA,EAAQ,CAAA,EAAG,SAAS,CAAA;AAAA,IACpE,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG;AAAA;AACN","file":"chunk-F374BNL4.js","sourcesContent":["import { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * ThemeIcon — square, non-interactive icon-display box. Visually related to\n * `ActionIcon` (same size/radius scales) but deliberately **not** its\n * (variant × color) look: every variant here is a muted, low-saturation\n * surface — just enough contrast to read as \"raised above the page,\" never\n * a vivid CTA-style fill. There's no hover state and no cursor affordance,\n * because this is a display, not a control.\n *\n * `asChild` renders the single child as the root, so it composes on top of\n * an interactive element (e.g. wrap a `Link`) when the icon itself needs to\n * be clickable. The kit's focus ring (`focusStyles`) rides along for that\n * case and stays inert on the default `<div>` — but reach for `ActionIcon`\n * when an interactive icon is the common case, since it also supplies the\n * `aria-label`, disabled and loading handling a real trigger needs.\n */\nconst themeIconVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"aspect-square shrink-0 select-none\",\n \"rounded-lg border\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n // Inert on the default non-focusable <div>; applies once `asChild`\n // renders ThemeIcon onto a real <a>/<button>. See `focusStyles`.\n focusStyles(),\n ],\n {\n variants: {\n variant: {\n // A translucent wash of `--c-solid` (not the opaque token) so the\n // fill blends with whatever surface it sits on instead of reading\n // as a painted CTA block. The border mixes in black on top of that\n // same var — a fixed darkening, not another opacity step of it —\n // so it reads as a recessed edge in both themes; some colors (neutral\n // in particular) have a dark-mode `--c-solid` that's lighter than\n // its own soft/text steps, which would flip a same-var-opacity\n // border the wrong way. This is the ThemeIcon-specific reading of\n // \"filled\": raised, not loud. Button/Badge/ActionIcon's `filled`\n // (opaque bg-(--c-solid)) would look like a button here —\n // intentionally not reused.\n filled:\n \"bg-(--c-solid)/15 text-(--c-text) border-[color-mix(in_oklab,var(--c-solid)_35%,black_65%)]\",\n // `light`, `outline` and `subtle` paint through two local properties,\n // `--theme-icon-fill` and `--theme-icon-glyph`, and only the\n // properties change per theme and palette. The `bg-*`/`text-*` stay\n // plain utilities, so a caller's `className` colour replaces them\n // through `cn`: a `dark:` or `data-color` text class would outrank it.\n //\n // Figma tints a hued tile with its solid shade at 30%\n // (`bg-<hue>-secondary`), as Badge's `light` does: `--c-soft` is the\n // -50/-950 end of the scale and fades into the page in both themes.\n // The dark glyph is that solid shade (`fg-<hue>-primary`); the light\n // theme draws it in the palette's text step instead, as Badge does,\n // since a -500 glyph on its own tint over white falls under 3:1 for\n // yellow, orange and green. Neutral (also the no-`color` default,\n // which resolves to the neutral mirror on :root) fills with the\n // black/white-16 overlay its own `--c-soft` already is, and draws its\n // glyph in the solid black/white.\n light: [\n \"bg-(--theme-icon-fill) text-(--theme-icon-glyph) border-transparent\",\n \"[--theme-icon-fill:color-mix(in_oklab,var(--c-solid)_30%,transparent)] [--theme-icon-glyph:var(--c-text)] dark:[--theme-icon-glyph:var(--c-solid)]\",\n \"not-data-color:[--theme-icon-fill:var(--c-soft)] data-[color=neutral]:[--theme-icon-fill:var(--c-soft)] data-[color=gray]:[--theme-icon-fill:var(--c-soft)]\",\n \"not-data-color:[--theme-icon-glyph:var(--c-solid)] data-[color=neutral]:[--theme-icon-glyph:var(--c-solid)] data-[color=gray]:[--theme-icon-glyph:var(--c-solid)]\",\n ],\n // A hued glyph takes the palette's text step (Figma `fg-<hue>-secondary`,\n // the -300). Neutral's text step is the 80% secondary white, but Figma\n // draws its glyph in `fg-primary` — full white, which is neutral's\n // solid shade (black in the light theme).\n outline: [\n \"bg-transparent text-(--theme-icon-glyph) border-(--c-solid) [--theme-icon-glyph:var(--c-text)]\",\n \"not-data-color:[--theme-icon-glyph:var(--c-solid)] data-[color=neutral]:[--theme-icon-glyph:var(--c-solid)] data-[color=gray]:[--theme-icon-glyph:var(--c-solid)]\",\n ],\n subtle: [\n \"bg-transparent text-(--theme-icon-glyph) border-transparent [--theme-icon-glyph:var(--c-text)]\",\n \"not-data-color:[--theme-icon-glyph:var(--c-solid)] data-[color=neutral]:[--theme-icon-glyph:var(--c-solid)] data-[color=gray]:[--theme-icon-glyph:var(--c-solid)]\",\n ],\n // Palette-independent neutral surface. Unlike ActionIcon's\n // high-contrast inverted `default` (a black/white button look),\n // this stays a muted card in both themes. It sits on the kit's\n // translucent surface (the quiet `bg-black/3 dark:bg-white/4` fill\n // `Kbd` and `Card` share, edged with Figma's `border-secondary`,\n // `dark:border-white/16`) rather than an opaque gray step, so the tile\n // reads on whatever surface hosts it. Light mode darkens because a\n // bare `bg-white/4` vanishes on a near-white page.\n default: [\n \"bg-black/3 text-brand-900/70 border-brand-900/20\",\n \"dark:bg-white/4 dark:text-white/80 dark:border-white/16\",\n ],\n },\n // Figma (ThemeIcon, node 17583-16687): the glyph is 12/14/16/18/22px in\n // a 28/32/36/40/48px tile — under half the tile, so the tile reads as a\n // frame around the icon, not as the icon's own padding.\n size: {\n xs: \"h-7 [&_svg]:size-3\",\n sm: \"h-8 [&_svg]:size-3.5\",\n md: \"h-9 [&_svg]:size-4\",\n lg: \"h-10 [&_svg]:size-4.5\",\n xl: \"h-12 [&_svg]:size-5.5\",\n },\n radius: {\n xs: \"rounded-xs\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-lg\",\n xl: \"rounded-xl\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n radius: \"md\",\n },\n },\n)\n\nexport type ThemeIconVariant = NonNullable<VariantProps<typeof themeIconVariants>[\"variant\"]>\nexport type ThemeIconSize = NonNullable<VariantProps<typeof themeIconVariants>[\"size\"]>\nexport type ThemeIconRadius = NonNullable<VariantProps<typeof themeIconVariants>[\"radius\"]>\n\nexport type ThemeIconProps = HTMLArkProps<\"div\"> &\n VariantProps<typeof themeIconVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n }\n\nexport const ThemeIcon = ({\n className,\n variant,\n size,\n radius,\n color,\n asChild,\n testId,\n ...rest\n}: ThemeIconProps) => (\n <ark.div\n asChild={asChild}\n data-color={color}\n data-variant={variant ?? \"default\"}\n className={cn(themeIconVariants({ variant, size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/button/button.tsx"],"names":[],"mappings":";;;;;;;;;AAsEA,IAAM,cAAA,GAAiB,GAAA;AAAA,EACrB;AAAA,IACE,yCAAA;AAAA,IACA,+BAAA;AAAA,IACA,qCAAA;AAAA,IACA,cAAA;AAAA,IACA,0CAAA;AAAA,IACA,0BAAA;AAAA,IACA,WAAA,EAAY;AAAA,IACZ,oFAAA;AAAA,IACA,4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ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { MouseEvent, ReactNode } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * Button — interactive but stateless primitive.\n *\n * The new (variant × color) model splits visual treatment from accent palette:\n * - `variant` picks the shape (filled / light / outline / subtle)\n * - `color` picks the palette (brand / gray / neutral / red / orange / …)\n *\n * Color is delivered through CSS variables: the component writes a\n * `data-color=\"…\"` attribute and the global rules in `colors.css` resolve\n * `--c-solid`, `--c-soft`, `--c-text` etc. for both light and dark mode. So\n * the cva matrix only enumerates variants, not (variant × color) pairs.\n * When `color` is omitted, no `data-color` attribute is rendered and the\n * slot vars cascade from `:root` — which mirrors `neutral` — so the\n * zero-config `<Button>` renders `filled` · `neutral`. Consumers retheme the\n * default for the whole app by overriding the slot vars at `:root`, no JS\n * required.\n *\n * `asChild` (inherited from `HTMLArkProps`) renders the single child element\n * with Button's styling merged in. Ark's factory clones exactly one element,\n * so only one element can survive the swap — `startSlot`/`endSlot` and the\n * `loading` spinner are folded into *that* element's own children\n * (`withAsChildContent`, `lib/as-child.ts`) rather than rendered as siblings,\n * so they keep showing up even when the child is a link. Common case:\n * `<Button asChild startSlot={<Icon />}><a ...>Go</a></Button>`.\n *\n * `loading` never changes the button's size or moves its label. Nothing\n * leaves the layout; the spinner morphs into a place that is already there:\n * - with a `startSlot`, the spinner is stacked on the icon in the same grid\n * cell and the two crossfade (`LoadingSlot`); the label and any `endSlot`\n * stay put;\n * - with only an `endSlot`, the same morph happens in the end slot;\n * - with no slot, the label stays laid out (so it still sizes the button)\n * while it fades and lifts away, and the spinner fades up into an\n * overlay centred over it (`LoadingLabel`).\n * The cell and the label keep their idle size, so the button is sized by its\n * idle content — CSS only, nothing measured. The spinner is mounted whenever\n * the `loading` prop is *passed* (true or false), so the fade has a state to\n * start from, and its rotation is paused while idle so a page of idle buttons\n * runs no animations; a button that never passes `loading` renders no\n * spinner at all. Under `motion-reduce` the swap is instant; the spinner\n * itself still turns.\n *\n * A loading button keeps full contrast — dimming it would read as\n * `disabled`. `disabled` alone still dims (`not-data-loading:` scopes the\n * `:disabled` dim off, since `resolvedDisabled` sets native `disabled` for\n * `loading` too).\n *\n * `loading` doesn't use `pointer-events-none` to block interaction — that\n * also blocks `:hover`, which would make `cursor-progress` unreachable by a\n * real mouse. Instead native `disabled` handles a real `<button>` (the\n * `disabled:pointer-events-none` rule is scoped off while loading via\n * `not-data-loading:` for the same reason as the dim), and an explicit\n * `onClick` guard (`preventWhileLoading`) handles an arbitrary `asChild`\n * element, which `disabled` doesn't affect. `cursor-progress` and the hover\n * suppression are keyed off `data-loading` rather than `:disabled`, which\n * never matches a non-form element like an `<a>`.\n */\nconst buttonVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"whitespace-nowrap select-none\",\n \"font-medium uppercase tracking-wide\",\n \"no-underline\",\n \"rounded-button border border-transparent\",\n \"transition-colors-radius\",\n focusStyles(),\n \"disabled:not-data-loading:pointer-events-none disabled:not-data-loading:opacity-50\",\n \"data-disabled:pointer-events-none data-disabled:opacity-50\",\n \"not-data-loading:hover:cursor-pointer\",\n \"data-loading:cursor-progress\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n ],\n {\n variants: {\n variant: {\n filled: [\n \"bg-(--c-solid) text-(--c-on-solid)\",\n \"not-data-loading:hover:bg-(--c-solid-hover)\",\n ],\n light: [\n \"bg-(--c-soft) text-(--c-text) border-(--c-soft-hover)\",\n \"not-data-loading:hover:bg-(--c-soft-hover) not-data-loading:hover:border-(--c-solid)\",\n ],\n outline: [\n \"bg-transparent text-(--c-text) border-(--c-solid)/35\",\n \"not-data-loading:hover:bg-(--c-soft)\",\n ],\n subtle: [\"bg-transparent text-(--c-text)\", \"not-data-loading:hover:bg-(--c-soft)\"],\n },\n size: {\n xs: \"h-7 px-2 text-xs [&_svg]:size-3 gap-1\",\n sm: \"h-8 px-3 text-sm [&_svg]:size-3.5 gap-1.5\",\n md: \"h-9 px-4 text-md [&_svg]:size-4 gap-2\",\n lg: \"h-10 px-4 text-lg [&_svg]:size-5 gap-3\",\n xl: \"h-12 px-5 text-xl [&_svg]:size-6 gap-3\",\n },\n },\n defaultVariants: {\n variant: \"filled\",\n size: \"md\",\n },\n },\n)\n\nconst startSlotVariants = cva(\"inline-flex shrink-0 items-center\", {\n variants: {\n size: {\n xs: \"-ms-0.5\",\n sm: \"-ms-1\",\n md: \"-ms-2\",\n lg: \"-ms-2.5\",\n xl: \"-ms-3\",\n },\n },\n})\nconst endSlotVariants = cva(\"inline-flex shrink-0 items-center\", {\n variants: {\n size: {\n xs: \"-me-0.5\",\n sm: \"-me-1\",\n md: \"-me-2\",\n lg: \"-me-2.5\",\n xl: \"-me-3\",\n },\n },\n})\n\nexport type ButtonVariant = NonNullable<VariantProps<typeof buttonVariants>[\"variant\"]>\nexport type ButtonSize = NonNullable<VariantProps<typeof buttonVariants>[\"size\"]>\n\nexport type ButtonProps = Omit<HTMLArkProps<\"button\">, \"color\"> &\n VariantProps<typeof buttonVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n /**\n * Show a spinner and mark the button as busy + non-interactive, without\n * changing its size: the spinner crossfades in place of `startSlot` (or\n * `endSlot` when there is no `startSlot`), or over the label when there\n * is no slot. Use for async submit handlers.\n */\n loading?: boolean\n /**\n * Optional element rendered at the inline-start of the children (e.g. an\n * icon) — left in LTR, right in RTL. Hidden from assistive tech via\n * `aria-hidden`.\n */\n startSlot?: ReactNode\n /**\n * Optional element rendered at the inline-end of the children — right in\n * LTR, left in RTL. `aria-hidden`.\n */\n endSlot?: ReactNode\n }\n\nconst HiddenSlot = ({ children, className }: { children: ReactNode; className?: string }) => (\n <span\n aria-hidden=\"true\"\n className={cn(\"inline-flex shrink-0 items-center justify-center\", className)}\n >\n {children}\n </span>\n)\n\n/** Both layers of a loading morph share one grid cell, so the cell is as big\n * as the larger of the two and swapping them can't move anything. */\nconst morphLayer = \"col-start-1 row-start-1 transition-morph motion-reduce:transition-none\"\n\n/** The spinner's own rotation runs only while it is showing; paused (not\n * removed) so it fades out from where it was rather than snapping back. */\nconst LoadingSpinner = ({ loading }: { loading: boolean }) => (\n <Spinner label={null} className={loading ? undefined : \"[animation-play-state:paused]\"} />\n)\n\n/**\n * A slot's icon and the spinner stacked in place: the icon shrinks and fades\n * out as the spinner grows and fades in, inside a cell that keeps its size.\n */\nconst LoadingSlot = ({ loading, children }: { loading: boolean; children: ReactNode }) => (\n <span className=\"inline-grid place-items-center\">\n <span className={cn(morphLayer, \"inline-flex\", loading && \"scale-50 opacity-0\")}>\n {children}\n </span>\n <span className={cn(morphLayer, \"inline-flex\", !loading && \"scale-50 opacity-0\")}>\n <LoadingSpinner loading={loading} />\n </span>\n </span>\n)\n\n/**\n * No slot to morph in: the label stays laid out (it still sizes the button)\n * while it fades and lifts away, and the spinner rises into an overlay over\n * the whole button — the root is `relative` for it. The label wrapper\n * inherits the root's `gap`, so children with several nodes keep their\n * spacing.\n */\nconst LoadingLabel = ({ loading, children }: { loading: boolean; children: ReactNode }) => (\n <>\n <span\n className={cn(\n morphLayer,\n \"inline-flex items-center justify-center gap-[inherit]\",\n loading && \"-translate-y-1 opacity-0\",\n )}\n >\n {children}\n </span>\n <span\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none absolute inset-0 grid place-items-center\",\n \"transition-morph motion-reduce:transition-none\",\n !loading && \"translate-y-1 opacity-0\",\n )}\n >\n <LoadingSpinner loading={loading} />\n </span>\n </>\n)\n\n/**\n * Swallows the click while `loading`. Native `disabled` already blocks\n * interaction on a real `<button>` with or without this, but it's a no-op\n * on an arbitrary `asChild` element (e.g. an `<a>`) — that's the one case\n * this actually needs to do something. A stable module-level reference so\n * it never causes the clone below to look \"changed\" across renders.\n */\nconst preventWhileLoading = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n}\n\nexport const Button = ({\n className,\n variant,\n size,\n color,\n loading: loadingProp,\n startSlot,\n endSlot,\n children,\n disabled,\n type,\n asChild,\n testId,\n onClick,\n ...rest\n}: ButtonProps) => {\n const loading = loadingProp ?? false\n // Passing `loading` at all (even `false`) opts into the spinner layers, so\n // the first switch to `true` already has a from-state to fade from.\n const loadable = loadingProp !== undefined\n // Where the spinner morphs: the start slot, else the end slot, else over\n // the label.\n const morph = !loadable ? null : startSlot ? \"start\" : endSlot ? \"end\" : \"label\"\n const resolvedDisabled = disabled || loading\n const resolvedOnClick = loading ? preventWhileLoading : onClick\n const content = (own: ReactNode) => (\n <>\n {startSlot && (\n <HiddenSlot className={startSlotVariants({ size })}>\n {morph === \"start\" ? <LoadingSlot loading={loading}>{startSlot}</LoadingSlot> : startSlot}\n </HiddenSlot>\n )}\n {morph === \"label\" ? <LoadingLabel loading={loading}>{own}</LoadingLabel> : own}\n {endSlot && (\n <HiddenSlot className={endSlotVariants({ size })}>\n {morph === \"end\" ? <LoadingSlot loading={loading}>{endSlot}</LoadingSlot> : endSlot}\n </HiddenSlot>\n )}\n </>\n )\n\n return (\n <ark.button\n asChild={asChild}\n type={asChild ? type : (type ?? \"button\")}\n disabled={resolvedDisabled}\n data-color={color}\n data-variant={variant ?? \"filled\"}\n data-size={size ?? \"md\"}\n className={cn(buttonVariants({ variant, size }), morph === \"label\" && \"relative\", className)}\n onClick={resolvedOnClick}\n {...props({\n \"aria-busy\": loading,\n \"aria-disabled\": resolvedDisabled,\n \"data-loading\": loading,\n \"data-testid\": testId,\n })}\n {...rest}\n >\n {asChild\n ? withAsChildContent(\n children,\n content,\n loading ? { onClick: preventWhileLoading } : undefined,\n )\n : content(children)}\n </ark.button>\n )\n}\n"]}