@brijbyte/agentic-ui 0.0.3 → 0.0.5

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 (289) hide show
  1. package/README.md +280 -53
  2. package/dist/accordion/accordion.d.ts +14 -0
  3. package/dist/accordion/accordion.d.ts.map +1 -1
  4. package/dist/accordion/accordion.js +5 -0
  5. package/dist/accordion/accordion.js.map +1 -1
  6. package/dist/accordion/index.d.ts +2 -2
  7. package/dist/accordion/index.js +2 -2
  8. package/dist/accordion/parts.d.ts +6 -14
  9. package/dist/accordion/parts.d.ts.map +1 -1
  10. package/dist/accordion/parts.js +7 -6
  11. package/dist/accordion/parts.js.map +1 -1
  12. package/dist/alert-dialog/alert-dialog.d.ts +11 -0
  13. package/dist/alert-dialog/alert-dialog.d.ts.map +1 -1
  14. package/dist/alert-dialog/alert-dialog.js +5 -0
  15. package/dist/alert-dialog/alert-dialog.js.map +1 -1
  16. package/dist/alert-dialog/parts.d.ts +4 -12
  17. package/dist/alert-dialog/parts.d.ts.map +1 -1
  18. package/dist/alert-dialog/parts.js +17 -19
  19. package/dist/alert-dialog/parts.js.map +1 -1
  20. package/dist/badge/badge.d.ts +6 -0
  21. package/dist/badge/badge.d.ts.map +1 -1
  22. package/dist/badge/badge.js +4 -0
  23. package/dist/badge/badge.js.map +1 -1
  24. package/dist/button/button.d.ts +12 -1
  25. package/dist/button/button.d.ts.map +1 -1
  26. package/dist/button/button.js +5 -0
  27. package/dist/button/button.js.map +1 -1
  28. package/dist/card/card.d.ts +10 -0
  29. package/dist/card/card.d.ts.map +1 -1
  30. package/dist/card/card.js +7 -0
  31. package/dist/card/card.js.map +1 -1
  32. package/dist/checkbox/checkbox.d.ts +13 -0
  33. package/dist/checkbox/checkbox.d.ts.map +1 -1
  34. package/dist/checkbox/checkbox.js +4 -0
  35. package/dist/checkbox/checkbox.js.map +1 -1
  36. package/dist/checkbox/parts.d.ts +2 -5
  37. package/dist/checkbox/parts.d.ts.map +1 -1
  38. package/dist/checkbox/parts.js +3 -2
  39. package/dist/checkbox/parts.js.map +1 -1
  40. package/dist/collapsible/collapsible.d.ts +11 -0
  41. package/dist/collapsible/collapsible.d.ts.map +1 -1
  42. package/dist/collapsible/collapsible.js +5 -0
  43. package/dist/collapsible/collapsible.js.map +1 -1
  44. package/dist/collapsible/parts.d.ts +3 -9
  45. package/dist/collapsible/parts.d.ts.map +1 -1
  46. package/dist/collapsible/parts.js +7 -6
  47. package/dist/collapsible/parts.js.map +1 -1
  48. package/dist/context-menu/context-menu.d.ts +5 -0
  49. package/dist/context-menu/context-menu.d.ts.map +1 -1
  50. package/dist/context-menu/context-menu.js +4 -0
  51. package/dist/context-menu/context-menu.js.map +1 -1
  52. package/dist/context-menu/parts.d.ts +6 -18
  53. package/dist/context-menu/parts.d.ts.map +1 -1
  54. package/dist/context-menu/parts.js +16 -16
  55. package/dist/context-menu/parts.js.map +1 -1
  56. package/dist/dialog/dialog.d.ts +13 -1
  57. package/dist/dialog/dialog.d.ts.map +1 -1
  58. package/dist/dialog/dialog.js +6 -0
  59. package/dist/dialog/dialog.js.map +1 -1
  60. package/dist/dialog/parts.d.ts +6 -18
  61. package/dist/dialog/parts.d.ts.map +1 -1
  62. package/dist/dialog/parts.js +8 -9
  63. package/dist/dialog/parts.js.map +1 -1
  64. package/dist/drawer/drawer.d.ts +11 -0
  65. package/dist/drawer/drawer.d.ts.map +1 -1
  66. package/dist/drawer/drawer.js +5 -0
  67. package/dist/drawer/drawer.js.map +1 -1
  68. package/dist/drawer/parts.d.ts +7 -19
  69. package/dist/drawer/parts.d.ts.map +1 -1
  70. package/dist/drawer/parts.js +14 -13
  71. package/dist/drawer/parts.js.map +1 -1
  72. package/dist/index.css +1580 -1150
  73. package/dist/index.d.ts +20 -11
  74. package/dist/index.js +15 -2
  75. package/dist/input/input.d.ts +8 -0
  76. package/dist/input/input.d.ts.map +1 -1
  77. package/dist/input/input.js +5 -0
  78. package/dist/input/input.js.map +1 -1
  79. package/dist/menu/menu.css +3 -8
  80. package/dist/menu/menu.d.ts +11 -4
  81. package/dist/menu/menu.d.ts.map +1 -1
  82. package/dist/menu/menu.js +10 -24
  83. package/dist/menu/menu.js.map +1 -1
  84. package/dist/menu/menu.module.js +1 -1
  85. package/dist/menu/menu.module.js.map +1 -1
  86. package/dist/menu/parts.d.ts +6 -18
  87. package/dist/menu/parts.d.ts.map +1 -1
  88. package/dist/menu/parts.js +7 -6
  89. package/dist/menu/parts.js.map +1 -1
  90. package/dist/meter/circular-meter.d.ts +48 -0
  91. package/dist/meter/circular-meter.d.ts.map +1 -0
  92. package/dist/meter/circular-meter.js +86 -0
  93. package/dist/meter/circular-meter.js.map +1 -0
  94. package/dist/meter/index.d.ts +4 -0
  95. package/dist/meter/index.js +5 -0
  96. package/dist/meter/meter.css +152 -0
  97. package/dist/meter/meter.d.ts +58 -0
  98. package/dist/meter/meter.d.ts.map +1 -0
  99. package/dist/meter/meter.js +50 -0
  100. package/dist/meter/meter.js.map +1 -0
  101. package/dist/meter/meter.module.css.d.ts +2 -0
  102. package/dist/meter/meter.module.js +27 -0
  103. package/dist/meter/meter.module.js.map +1 -0
  104. package/dist/meter/meterState.js +18 -0
  105. package/dist/meter/meterState.js.map +1 -0
  106. package/dist/meter/parts.d.ts +25 -0
  107. package/dist/meter/parts.d.ts.map +1 -0
  108. package/dist/meter/parts.js +57 -0
  109. package/dist/meter/parts.js.map +1 -0
  110. package/dist/number-field/number-field.d.ts +16 -0
  111. package/dist/number-field/number-field.d.ts.map +1 -1
  112. package/dist/number-field/number-field.js +4 -0
  113. package/dist/number-field/number-field.js.map +1 -1
  114. package/dist/number-field/parts.d.ts +6 -18
  115. package/dist/number-field/parts.d.ts.map +1 -1
  116. package/dist/number-field/parts.js +7 -6
  117. package/dist/number-field/parts.js.map +1 -1
  118. package/dist/popover/index.d.ts +3 -0
  119. package/dist/popover/index.js +4 -0
  120. package/dist/popover/parts.d.ts +29 -0
  121. package/dist/popover/parts.d.ts.map +1 -0
  122. package/dist/popover/parts.js +93 -0
  123. package/dist/popover/parts.js.map +1 -0
  124. package/dist/popover/popover.css +173 -0
  125. package/dist/popover/popover.d.ts +49 -0
  126. package/dist/popover/popover.d.ts.map +1 -0
  127. package/dist/popover/popover.js +68 -0
  128. package/dist/popover/popover.js.map +1 -0
  129. package/dist/popover/popover.module.css.d.ts +2 -0
  130. package/dist/popover/popover.module.js +16 -0
  131. package/dist/popover/popover.module.js.map +1 -0
  132. package/dist/progress/parts.d.ts +2 -4
  133. package/dist/progress/parts.d.ts.map +1 -1
  134. package/dist/progress/parts.js +3 -6
  135. package/dist/progress/parts.js.map +1 -1
  136. package/dist/progress/progress.d.ts +11 -0
  137. package/dist/progress/progress.d.ts.map +1 -1
  138. package/dist/progress/progress.js +5 -0
  139. package/dist/progress/progress.js.map +1 -1
  140. package/dist/radio/index.d.ts +3 -0
  141. package/dist/radio/index.js +4 -0
  142. package/dist/radio/parts.d.ts +14 -0
  143. package/dist/radio/parts.d.ts.map +1 -0
  144. package/dist/radio/parts.js +43 -0
  145. package/dist/radio/parts.js.map +1 -0
  146. package/dist/radio/radio.css +84 -0
  147. package/dist/radio/radio.d.ts +31 -0
  148. package/dist/radio/radio.d.ts.map +1 -0
  149. package/dist/radio/radio.js +33 -0
  150. package/dist/radio/radio.js.map +1 -0
  151. package/dist/radio/radio.module.css.d.ts +2 -0
  152. package/dist/radio/radio.module.js +11 -0
  153. package/dist/radio/radio.module.js.map +1 -0
  154. package/dist/radio-group/index.d.ts +3 -0
  155. package/dist/radio-group/index.js +4 -0
  156. package/dist/radio-group/parts.d.ts +11 -0
  157. package/dist/radio-group/parts.d.ts.map +1 -0
  158. package/dist/radio-group/parts.js +32 -0
  159. package/dist/radio-group/parts.js.map +1 -0
  160. package/dist/radio-group/radio-group.css +17 -0
  161. package/dist/radio-group/radio-group.d.ts +37 -0
  162. package/dist/radio-group/radio-group.d.ts.map +1 -0
  163. package/dist/radio-group/radio-group.js +28 -0
  164. package/dist/radio-group/radio-group.js.map +1 -0
  165. package/dist/radio-group/radio-group.module.css.d.ts +2 -0
  166. package/dist/radio-group/radio-group.module.js +9 -0
  167. package/dist/radio-group/radio-group.module.js.map +1 -0
  168. package/dist/reset-scoped.css +112 -0
  169. package/dist/select/parts.d.ts +11 -32
  170. package/dist/select/parts.d.ts.map +1 -1
  171. package/dist/select/parts.js +10 -9
  172. package/dist/select/parts.js.map +1 -1
  173. package/dist/select/select.d.ts +14 -1
  174. package/dist/select/select.d.ts.map +1 -1
  175. package/dist/select/select.js +4 -0
  176. package/dist/select/select.js.map +1 -1
  177. package/dist/separator/separator.d.ts +4 -0
  178. package/dist/separator/separator.d.ts.map +1 -1
  179. package/dist/separator/separator.js +4 -0
  180. package/dist/separator/separator.js.map +1 -1
  181. package/dist/shared/PopupArrow.js +22 -0
  182. package/dist/shared/PopupArrow.js.map +1 -0
  183. package/dist/slider/parts.d.ts +6 -18
  184. package/dist/slider/parts.d.ts.map +1 -1
  185. package/dist/slider/parts.js +7 -6
  186. package/dist/slider/parts.js.map +1 -1
  187. package/dist/slider/slider.d.ts +18 -0
  188. package/dist/slider/slider.d.ts.map +1 -1
  189. package/dist/slider/slider.js +6 -0
  190. package/dist/slider/slider.js.map +1 -1
  191. package/dist/switch/parts.d.ts +2 -6
  192. package/dist/switch/parts.d.ts.map +1 -1
  193. package/dist/switch/parts.js +3 -2
  194. package/dist/switch/parts.js.map +1 -1
  195. package/dist/switch/switch.css +11 -2
  196. package/dist/switch/switch.d.ts +12 -0
  197. package/dist/switch/switch.d.ts.map +1 -1
  198. package/dist/switch/switch.js +4 -0
  199. package/dist/switch/switch.js.map +1 -1
  200. package/dist/switch/switch.module.js.map +1 -1
  201. package/dist/tabs/parts.d.ts +3 -9
  202. package/dist/tabs/parts.d.ts.map +1 -1
  203. package/dist/tabs/parts.js +4 -3
  204. package/dist/tabs/parts.js.map +1 -1
  205. package/dist/tabs/tabs.d.ts +8 -1
  206. package/dist/tabs/tabs.d.ts.map +1 -1
  207. package/dist/tabs/tabs.js +4 -0
  208. package/dist/tabs/tabs.js.map +1 -1
  209. package/dist/toast/parts.d.ts +5 -15
  210. package/dist/toast/parts.d.ts.map +1 -1
  211. package/dist/toast/parts.js +6 -5
  212. package/dist/toast/parts.js.map +1 -1
  213. package/dist/toast/toast.d.ts +11 -0
  214. package/dist/toast/toast.d.ts.map +1 -1
  215. package/dist/toast/toast.js +8 -0
  216. package/dist/toast/toast.js.map +1 -1
  217. package/dist/tooltip/parts.d.ts +3 -9
  218. package/dist/tooltip/parts.d.ts.map +1 -1
  219. package/dist/tooltip/parts.js +4 -3
  220. package/dist/tooltip/parts.js.map +1 -1
  221. package/dist/tooltip/tooltip.d.ts +9 -0
  222. package/dist/tooltip/tooltip.d.ts.map +1 -1
  223. package/dist/tooltip/tooltip.js +4 -0
  224. package/dist/tooltip/tooltip.js.map +1 -1
  225. package/dist/utils/resolveClassName.js +25 -0
  226. package/dist/utils/resolveClassName.js.map +1 -0
  227. package/package.json +25 -4
  228. package/src/accordion/accordion.tsx +14 -0
  229. package/src/accordion/index.ts +1 -1
  230. package/src/accordion/parts.tsx +10 -17
  231. package/src/alert-dialog/alert-dialog.tsx +11 -0
  232. package/src/alert-dialog/parts.tsx +23 -31
  233. package/src/badge/badge.tsx +6 -0
  234. package/src/button/button.tsx +12 -1
  235. package/src/card/card.tsx +10 -0
  236. package/src/checkbox/checkbox.tsx +13 -0
  237. package/src/checkbox/parts.tsx +5 -7
  238. package/src/collapsible/collapsible.tsx +11 -0
  239. package/src/collapsible/parts.tsx +10 -15
  240. package/src/context-menu/context-menu.tsx +5 -0
  241. package/src/context-menu/parts.tsx +34 -34
  242. package/src/dialog/dialog.tsx +13 -1
  243. package/src/dialog/parts.tsx +14 -27
  244. package/src/drawer/drawer.tsx +11 -0
  245. package/src/drawer/parts.tsx +30 -38
  246. package/src/index.ts +4 -0
  247. package/src/input/input.tsx +8 -0
  248. package/src/menu/menu.module.css +3 -10
  249. package/src/menu/menu.tsx +13 -26
  250. package/src/menu/parts.tsx +13 -24
  251. package/src/meter/circular-meter.tsx +114 -0
  252. package/src/meter/index.ts +9 -0
  253. package/src/meter/meter.module.css +162 -0
  254. package/src/meter/meter.tsx +86 -0
  255. package/src/meter/meterState.ts +29 -0
  256. package/src/meter/parts.tsx +73 -0
  257. package/src/number-field/number-field.tsx +16 -0
  258. package/src/number-field/parts.tsx +33 -24
  259. package/src/popover/index.ts +14 -0
  260. package/src/popover/parts.tsx +105 -0
  261. package/src/popover/popover.module.css +189 -0
  262. package/src/popover/popover.tsx +80 -0
  263. package/src/progress/parts.tsx +13 -6
  264. package/src/progress/progress.tsx +11 -0
  265. package/src/radio/index.ts +6 -0
  266. package/src/radio/parts.tsx +42 -0
  267. package/src/radio/radio.module.css +96 -0
  268. package/src/radio/radio.tsx +37 -0
  269. package/src/radio-group/index.ts +5 -0
  270. package/src/radio-group/parts.tsx +31 -0
  271. package/src/radio-group/radio-group.module.css +17 -0
  272. package/src/radio-group/radio-group.tsx +63 -0
  273. package/src/select/parts.tsx +34 -41
  274. package/src/select/select.tsx +14 -1
  275. package/src/separator/separator.tsx +4 -0
  276. package/src/shared/PopupArrow.tsx +41 -0
  277. package/src/slider/parts.tsx +13 -24
  278. package/src/slider/slider.tsx +18 -0
  279. package/src/styles/reset-scoped.css +112 -0
  280. package/src/switch/parts.tsx +5 -8
  281. package/src/switch/switch.module.css +11 -2
  282. package/src/switch/switch.tsx +12 -0
  283. package/src/tabs/parts.tsx +7 -12
  284. package/src/tabs/tabs.tsx +8 -1
  285. package/src/toast/parts.tsx +11 -20
  286. package/src/toast/toast.tsx +11 -0
  287. package/src/tooltip/parts.tsx +7 -12
  288. package/src/tooltip/tooltip.tsx +9 -0
  289. package/src/utils/resolveClassName.ts +24 -0
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @brijbyte/agentic-ui — Scoped reset
3
+ *
4
+ * A class-anchored mirror of reset.css for use in sandboxed environments
5
+ * (e.g. documentation demo canvases) where you want the same baseline as
6
+ * a real app that imports reset.css — without touching html/body globally.
7
+ *
8
+ * Usage:
9
+ * @import "@brijbyte/agentic-ui/reset-scoped";
10
+ *
11
+ * <div class="agentic-reset">
12
+ * <!-- your component demo here -->
13
+ * </div>
14
+ *
15
+ * Rules are kept in exact 1-to-1 correspondence with reset.css.
16
+ * html → .agentic-reset
17
+ * body → .agentic-reset
18
+ * Keep both files in sync when either changes.
19
+ */
20
+
21
+ @layer base {
22
+ .agentic-reset,
23
+ .agentic-reset *,
24
+ .agentic-reset *::before,
25
+ .agentic-reset *::after {
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ .agentic-reset * {
30
+ margin: 0;
31
+ padding: 0;
32
+ }
33
+
34
+ /* html rules → applied to the root of the scoped subtree */
35
+ .agentic-reset {
36
+ -webkit-font-smoothing: antialiased;
37
+ -moz-osx-font-smoothing: grayscale;
38
+ text-rendering: optimizeLegibility;
39
+ tab-size: 2;
40
+ }
41
+
42
+ /* body rules → same root */
43
+ .agentic-reset {
44
+ font-family: var(--font-mono);
45
+ font-size: var(--font-size-md);
46
+ line-height: var(--line-height-normal);
47
+ color: var(--color-primary);
48
+ background-color: var(--color-canvas);
49
+ }
50
+
51
+ .agentic-reset img,
52
+ .agentic-reset picture,
53
+ .agentic-reset video,
54
+ .agentic-reset canvas,
55
+ .agentic-reset svg {
56
+ display: block;
57
+ max-width: 100%;
58
+ }
59
+
60
+ .agentic-reset input,
61
+ .agentic-reset button,
62
+ .agentic-reset textarea,
63
+ .agentic-reset select {
64
+ font: inherit;
65
+ }
66
+
67
+ .agentic-reset * {
68
+ -webkit-tap-highlight-color: transparent;
69
+ }
70
+
71
+ .agentic-reset p,
72
+ .agentic-reset h1,
73
+ .agentic-reset h2,
74
+ .agentic-reset h3,
75
+ .agentic-reset h4,
76
+ .agentic-reset h5,
77
+ .agentic-reset h6 {
78
+ overflow-wrap: break-word;
79
+ }
80
+
81
+ .agentic-reset h1,
82
+ .agentic-reset h2,
83
+ .agentic-reset h3,
84
+ .agentic-reset h4,
85
+ .agentic-reset h5,
86
+ .agentic-reset h6 {
87
+ font-family: var(--font-display);
88
+ font-weight: var(--font-weight-semibold);
89
+ line-height: var(--line-height-tight);
90
+ letter-spacing: var(--letter-spacing-tight);
91
+ color: var(--color-primary);
92
+ }
93
+
94
+ .agentic-reset * {
95
+ scrollbar-width: thin;
96
+ scrollbar-color: var(--color-thumb) var(--color-track);
97
+ }
98
+
99
+ .agentic-reset *::-webkit-scrollbar {
100
+ width: 6px;
101
+ height: 6px;
102
+ }
103
+
104
+ .agentic-reset *::-webkit-scrollbar-thumb {
105
+ background: var(--color-thumb);
106
+ border-radius: var(--radius-full);
107
+ }
108
+
109
+ .agentic-reset *::-webkit-scrollbar-track {
110
+ background: var(--color-track);
111
+ }
112
+ }
@@ -18,27 +18,24 @@ import { forwardRef } from "react";
18
18
  import type { ComponentRef, ComponentPropsWithoutRef } from "react";
19
19
  import { Switch as BaseSwitch } from "@base-ui/react/switch";
20
20
  import styles from "./switch.module.css";
21
+ import { resolveClassName, cx } from "../utils/resolveClassName";
21
22
 
22
23
  type BaseRootProps = ComponentPropsWithoutRef<typeof BaseSwitch.Root>;
23
24
  type BaseThumbProps = ComponentPropsWithoutRef<typeof BaseSwitch.Thumb>;
24
25
 
25
- export interface SwitchRootProps extends Omit<BaseRootProps, "className"> {
26
- className?: string;
27
- }
28
- export interface SwitchThumbProps extends Omit<BaseThumbProps, "className"> {
29
- className?: string;
30
- }
26
+ export interface SwitchRootProps extends BaseRootProps {}
27
+ export interface SwitchThumbProps extends BaseThumbProps {}
31
28
 
32
29
  export const SwitchRoot = forwardRef<ComponentRef<typeof BaseSwitch.Root>, SwitchRootProps>(function SwitchRoot(
33
30
  { className, ...props },
34
31
  ref,
35
32
  ) {
36
- return <BaseSwitch.Root ref={ref} className={`${styles["thumb-track"]} ${className ?? ""}`} {...props} />;
33
+ return <BaseSwitch.Root ref={ref} className={(state) => cx(styles["thumb-track"], resolveClassName(className, state))} {...props} />;
37
34
  });
38
35
 
39
36
  export const SwitchThumb = forwardRef<ComponentRef<typeof BaseSwitch.Thumb>, SwitchThumbProps>(function SwitchThumb(
40
37
  { className, ...props },
41
38
  ref,
42
39
  ) {
43
- return <BaseSwitch.Thumb ref={ref} className={`${styles.thumb} ${className ?? ""}`} {...props} />;
40
+ return <BaseSwitch.Thumb ref={ref} className={(state) => cx(styles.thumb, resolveClassName(className, state))} {...props} />;
44
41
  });
@@ -6,10 +6,14 @@
6
6
  cursor: pointer;
7
7
  user-select: none;
8
8
  }
9
- .root[data-disabled] {
10
- opacity: 0.44;
9
+ /* data-disabled lives on the inner button, not the label wrapper.
10
+ Use :has() to dim the label text, and target the track directly. */
11
+ .root:has([data-disabled]) {
11
12
  cursor: not-allowed;
12
13
  }
14
+ .root:has([data-disabled]) .label {
15
+ opacity: 0.44;
16
+ }
13
17
  .thumb-track {
14
18
  position: relative;
15
19
  width: 36px;
@@ -24,6 +28,11 @@
24
28
  outline: none;
25
29
  flex-shrink: 0;
26
30
  }
31
+ .thumb-track[data-disabled] {
32
+ opacity: 0.44;
33
+ cursor: not-allowed;
34
+ pointer-events: none;
35
+ }
27
36
  .thumb-track:focus-visible {
28
37
  box-shadow: var(--shadow-focus);
29
38
  }
@@ -4,19 +4,31 @@ import { Switch as BaseSwitch } from "@base-ui/react/switch";
4
4
  import styles from "./switch.module.css";
5
5
 
6
6
  export interface SwitchProps {
7
+ /** Controlled checked state. */
7
8
  checked?: boolean;
9
+ /** Initial checked state (uncontrolled). */
8
10
  defaultChecked?: boolean;
11
+ /** Prevent interaction. */
9
12
  disabled?: boolean;
13
+ /** Mark the field as required for form validation. */
10
14
  required?: boolean;
15
+ /** HTML name attribute for form submission. */
11
16
  name?: string;
17
+ /** HTML value attribute for form submission. */
12
18
  value?: string;
13
19
  /** Called when checked state changes. `eventDetails` is the base-ui event details object. */
14
20
  onCheckedChange?: (checked: boolean, eventDetails: unknown) => void;
21
+ /** Label content rendered next to the switch. */
15
22
  children?: ReactNode;
23
+ /** Override the auto-generated element id. */
16
24
  id?: string;
17
25
  className?: string;
18
26
  }
19
27
 
28
+ /**
29
+ * Toggle for boolean settings. Renders a track with a sliding thumb and
30
+ * an optional label. Wraps `@base-ui/react` Switch.
31
+ */
20
32
  export function Switch({ children, id, className, onCheckedChange, ...props }: SwitchProps) {
21
33
  // eslint-disable-next-line react-hooks/rules-of-hooks
22
34
  const switchId = id ?? useId();
@@ -20,29 +20,24 @@ import { forwardRef } from "react";
20
20
  import type { ComponentRef, ComponentPropsWithoutRef } from "react";
21
21
  import { Tabs as BaseTabs } from "@base-ui/react/tabs";
22
22
  import styles from "./tabs.module.css";
23
+ import { resolveClassName, cx } from "../utils/resolveClassName";
23
24
 
24
25
  type BaseListProps = ComponentPropsWithoutRef<typeof BaseTabs.List>;
25
26
  type BaseTabProps = ComponentPropsWithoutRef<typeof BaseTabs.Tab>;
26
27
  type BasePanelProps = ComponentPropsWithoutRef<typeof BaseTabs.Panel>;
27
28
 
28
- export interface TabsListProps extends Omit<BaseListProps, "className"> {
29
- className?: string;
30
- }
31
- export interface TabsTabProps extends Omit<BaseTabProps, "className"> {
32
- className?: string;
33
- }
34
- export interface TabsPanelProps extends Omit<BasePanelProps, "className"> {
35
- className?: string;
36
- }
29
+ export interface TabsListProps extends BaseListProps {}
30
+ export interface TabsTabProps extends BaseTabProps {}
31
+ export interface TabsPanelProps extends BasePanelProps {}
37
32
 
38
33
  export const TabsList = forwardRef<ComponentRef<typeof BaseTabs.List>, TabsListProps>(function TabsList({ className, ...props }, ref) {
39
- return <BaseTabs.List ref={ref} className={`${styles.list} ${className ?? ""}`} {...props} />;
34
+ return <BaseTabs.List ref={ref} className={(state) => cx(styles.list, resolveClassName(className, state))} {...props} />;
40
35
  });
41
36
 
42
37
  export const TabsTab = forwardRef<ComponentRef<typeof BaseTabs.Tab>, TabsTabProps>(function TabsTab({ className, ...props }, ref) {
43
- return <BaseTabs.Tab ref={ref} className={`${styles.tab} ${className ?? ""}`} {...props} />;
38
+ return <BaseTabs.Tab ref={ref} className={(state) => cx(styles.tab, resolveClassName(className, state))} {...props} />;
44
39
  });
45
40
 
46
41
  export const TabsPanel = forwardRef<ComponentRef<typeof BaseTabs.Panel>, TabsPanelProps>(function TabsPanel({ className, ...props }, ref) {
47
- return <BaseTabs.Panel ref={ref} className={`${styles.panel} ${className ?? ""}`} {...props} />;
42
+ return <BaseTabs.Panel ref={ref} className={(state) => cx(styles.panel, resolveClassName(className, state))} {...props} />;
48
43
  });
package/src/tabs/tabs.tsx CHANGED
@@ -11,14 +11,21 @@ export interface TabItem {
11
11
  }
12
12
 
13
13
  export interface TabsProps {
14
+ /** Array of tab definitions to render. */
14
15
  items: TabItem[];
16
+ /** Currently active tab value (controlled). */
15
17
  value?: string;
18
+ /** Initially active tab value (uncontrolled). Defaults to the first item. */
16
19
  defaultValue?: string;
17
- /** `eventDetails` is the base-ui event details object. */
20
+ /** Called when the active tab changes. `eventDetails` is the base-ui event details object. */
18
21
  onValueChange?: (value: unknown, eventDetails: unknown) => void;
19
22
  className?: string;
20
23
  }
21
24
 
25
+ /**
26
+ * Tab navigation for switching between content panels. Each tab can have
27
+ * an optional icon and can be individually disabled.
28
+ */
22
29
  export function Tabs({ items, className, ...props }: TabsProps) {
23
30
  const defaultVal = props.defaultValue ?? items[0]?.value;
24
31
 
@@ -20,6 +20,7 @@ import { forwardRef } from "react";
20
20
  import type { ComponentRef, ComponentPropsWithoutRef } from "react";
21
21
  import { Toast as BaseToast } from "@base-ui/react/toast";
22
22
  import styles from "./toast.module.css";
23
+ import { resolveClassName, cx } from "../utils/resolveClassName";
23
24
 
24
25
  type BaseRootProps = ComponentPropsWithoutRef<typeof BaseToast.Root>;
25
26
  type BaseTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;
@@ -27,50 +28,40 @@ type BaseDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Descriptio
27
28
  type BaseCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;
28
29
  type BaseViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;
29
30
 
30
- export interface ToastRootProps extends Omit<BaseRootProps, "className"> {
31
- className?: string;
32
- }
33
- export interface ToastTitleProps extends Omit<BaseTitleProps, "className"> {
34
- className?: string;
35
- }
36
- export interface ToastDescriptionProps extends Omit<BaseDescriptionProps, "className"> {
37
- className?: string;
38
- }
39
- export interface ToastCloseProps extends Omit<BaseCloseProps, "className"> {
40
- className?: string;
41
- }
42
- export interface ToastViewportPartProps extends Omit<BaseViewportProps, "className"> {
43
- className?: string;
44
- }
31
+ export interface ToastRootProps extends BaseRootProps {}
32
+ export interface ToastTitleProps extends BaseTitleProps {}
33
+ export interface ToastDescriptionProps extends BaseDescriptionProps {}
34
+ export interface ToastCloseProps extends BaseCloseProps {}
35
+ export interface ToastViewportPartProps extends BaseViewportProps {}
45
36
 
46
37
  export const ToastRoot = forwardRef<ComponentRef<typeof BaseToast.Root>, ToastRootProps>(function ToastRoot({ className, ...props }, ref) {
47
- return <BaseToast.Root ref={ref} className={`${styles.toast} ${className ?? ""}`} {...props} />;
38
+ return <BaseToast.Root ref={ref} className={(state) => cx(styles.toast, resolveClassName(className, state))} {...props} />;
48
39
  });
49
40
 
50
41
  export const ToastTitle = forwardRef<ComponentRef<typeof BaseToast.Title>, ToastTitleProps>(function ToastTitle(
51
42
  { className, ...props },
52
43
  ref,
53
44
  ) {
54
- return <BaseToast.Title ref={ref} className={`${styles.title} ${className ?? ""}`} {...props} />;
45
+ return <BaseToast.Title ref={ref} className={(state) => cx(styles.title, resolveClassName(className, state))} {...props} />;
55
46
  });
56
47
 
57
48
  export const ToastDescription = forwardRef<ComponentRef<typeof BaseToast.Description>, ToastDescriptionProps>(function ToastDescription(
58
49
  { className, ...props },
59
50
  ref,
60
51
  ) {
61
- return <BaseToast.Description ref={ref} className={`${styles.description} ${className ?? ""}`} {...props} />;
52
+ return <BaseToast.Description ref={ref} className={(state) => cx(styles.description, resolveClassName(className, state))} {...props} />;
62
53
  });
63
54
 
64
55
  export const ToastClose = forwardRef<ComponentRef<typeof BaseToast.Close>, ToastCloseProps>(function ToastClose(
65
56
  { className, ...props },
66
57
  ref,
67
58
  ) {
68
- return <BaseToast.Close ref={ref} className={`${styles.close} ${className ?? ""}`} {...props} />;
59
+ return <BaseToast.Close ref={ref} className={(state) => cx(styles.close, resolveClassName(className, state))} {...props} />;
69
60
  });
70
61
 
71
62
  export const ToastViewportPart = forwardRef<ComponentRef<typeof BaseToast.Viewport>, ToastViewportPartProps>(function ToastViewportPart(
72
63
  { className, ...props },
73
64
  ref,
74
65
  ) {
75
- return <BaseToast.Viewport ref={ref} className={`${styles.viewport} ${className ?? ""}`} {...props} />;
66
+ return <BaseToast.Viewport ref={ref} className={(state) => cx(styles.viewport, resolveClassName(className, state))} {...props} />;
76
67
  });
@@ -77,8 +77,11 @@ const DEFAULT_LIMIT: Record<NonNullable<ToastViewportProps["variant"]>, number>
77
77
 
78
78
  export interface ToastProviderProps {
79
79
  children: ReactNode;
80
+ /** Layout style for the viewport. @default "list" */
80
81
  variant?: ToastViewportProps["variant"];
82
+ /** Maximum number of toasts shown at once. */
81
83
  limit?: number;
84
+ /** Auto-dismiss delay in milliseconds. */
82
85
  timeout?: number;
83
86
  }
84
87
 
@@ -91,6 +94,10 @@ const MAX_LIMIT: Record<NonNullable<ToastViewportProps["variant"]>, number> = {
91
94
  list: 5,
92
95
  };
93
96
 
97
+ /**
98
+ * Drop-in provider that wires limit defaults to the chosen viewport variant.
99
+ * Use this instead of base-ui's `Toast.Provider` when using `ToastViewport`.
100
+ */
94
101
  export function ToastProvider({ children, variant = "list", limit, timeout }: ToastProviderProps) {
95
102
  const resolvedLimit = Math.min(limit ?? DEFAULT_LIMIT[variant], MAX_LIMIT[variant]);
96
103
  return (
@@ -100,6 +107,10 @@ export function ToastProvider({ children, variant = "list", limit, timeout }: To
100
107
  );
101
108
  }
102
109
 
110
+ /**
111
+ * Renders and manages toast notifications. Supports `"stacked"` (Sonner-style
112
+ * fanned cards) and `"list"` (vertically stacked, each fully visible) layouts.
113
+ */
103
114
  export function ToastViewport({ variant = "list", limit: _limit }: ToastViewportProps) {
104
115
  const manager = useToastManager();
105
116
  const isStacked = variant === "stacked";
@@ -25,38 +25,33 @@ import { forwardRef } from "react";
25
25
  import type { ComponentRef, ComponentPropsWithoutRef } from "react";
26
26
  import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
27
27
  import styles from "./tooltip.module.css";
28
+ import { resolveClassName, cx } from "../utils/resolveClassName";
28
29
 
29
30
  type BasePositionerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Positioner>;
30
31
  type BasePopupProps = ComponentPropsWithoutRef<typeof BaseTooltip.Popup>;
31
32
  type BaseArrowProps = ComponentPropsWithoutRef<typeof BaseTooltip.Arrow>;
32
33
 
33
- export interface TooltipPositionerProps extends Omit<BasePositionerProps, "className"> {
34
- className?: string;
35
- }
36
- export interface TooltipPopupProps extends Omit<BasePopupProps, "className"> {
37
- className?: string;
38
- }
39
- export interface TooltipArrowProps extends Omit<BaseArrowProps, "className"> {
40
- className?: string;
41
- }
34
+ export interface TooltipPositionerProps extends BasePositionerProps {}
35
+ export interface TooltipPopupProps extends BasePopupProps {}
36
+ export interface TooltipArrowProps extends BaseArrowProps {}
42
37
 
43
38
  export const TooltipPositioner = forwardRef<ComponentRef<typeof BaseTooltip.Positioner>, TooltipPositionerProps>(function TooltipPositioner(
44
39
  { className, ...props },
45
40
  ref,
46
41
  ) {
47
- return <BaseTooltip.Positioner ref={ref} className={`${styles.positioner} ${className ?? ""}`} {...props} />;
42
+ return <BaseTooltip.Positioner ref={ref} className={(state) => cx(styles.positioner, resolveClassName(className, state))} {...props} />;
48
43
  });
49
44
 
50
45
  export const TooltipPopup = forwardRef<ComponentRef<typeof BaseTooltip.Popup>, TooltipPopupProps>(function TooltipPopup(
51
46
  { className, ...props },
52
47
  ref,
53
48
  ) {
54
- return <BaseTooltip.Popup ref={ref} className={`${styles.popup} ${className ?? ""}`} {...props} />;
49
+ return <BaseTooltip.Popup ref={ref} className={(state) => cx(styles.popup, resolveClassName(className, state))} {...props} />;
55
50
  });
56
51
 
57
52
  export const TooltipArrow = forwardRef<ComponentRef<typeof BaseTooltip.Arrow>, TooltipArrowProps>(function TooltipArrow(
58
53
  { className, ...props },
59
54
  ref,
60
55
  ) {
61
- return <BaseTooltip.Arrow ref={ref} className={`${styles.arrow} ${className ?? ""}`} {...props} />;
56
+ return <BaseTooltip.Arrow ref={ref} className={(state) => cx(styles.arrow, resolveClassName(className, state))} {...props} />;
62
57
  });
@@ -3,13 +3,22 @@ import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
3
3
  import styles from "./tooltip.module.css";
4
4
 
5
5
  export interface TooltipProps {
6
+ /** Text or rich content shown inside the tooltip popup. */
6
7
  content: ReactNode;
8
+ /** The element that triggers the tooltip on hover/focus. */
7
9
  children: ReactElement;
10
+ /** Hover delay in milliseconds before the tooltip appears. @default 400 */
8
11
  delay?: number;
12
+ /** Which side of the trigger the tooltip appears on. @default "top" */
9
13
  side?: "top" | "bottom" | "left" | "right";
14
+ /** Alignment along the side axis. @default "center" */
10
15
  align?: "start" | "center" | "end";
11
16
  }
12
17
 
18
+ /**
19
+ * Accessible popup shown on hover or focus. Automatically positions itself
20
+ * with an arrow and supports configurable delay, side, and alignment.
21
+ */
13
22
  export function Tooltip({ content, children, delay = 400, side = "top", align = "center" }: TooltipProps) {
14
23
  return (
15
24
  <BaseTooltip.Provider delay={delay}>
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Resolves a base-ui className prop (string | function | undefined) into a string.
3
+ * When the className is a function, it is called with the component state.
4
+ * Used by styled parts to merge our fixed style class with the consumer's className.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * // In a styled part, prepend our class while preserving function className support:
9
+ * className={(state) => cx(styles.root, resolveClassName(className, state))}
10
+ * ```
11
+ */
12
+ export function resolveClassName<State>(
13
+ className: string | ((state: State) => string | undefined) | undefined,
14
+ state: State,
15
+ ): string | undefined {
16
+ return typeof className === "function" ? className(state) : className;
17
+ }
18
+
19
+ /**
20
+ * Joins class name strings, filtering out falsy values.
21
+ */
22
+ export function cx(...classes: (string | undefined | null | false)[]): string {
23
+ return classes.filter(Boolean).join(" ");
24
+ }