@central-ui/react 0.1.2 → 0.3.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 (287) hide show
  1. package/LICENSE +49 -0
  2. package/dist/components/accordion/index.d.ts +4 -3
  3. package/dist/components/accordion/index.js +7 -4
  4. package/dist/components/autocomplete/index.d.ts +23 -30
  5. package/dist/components/autocomplete/index.js +81 -56
  6. package/dist/components/avatar/index.d.ts +1 -2
  7. package/dist/components/avatar/index.js +0 -1
  8. package/dist/components/badge/index.d.ts +0 -1
  9. package/dist/components/badge/index.js +2 -2
  10. package/dist/components/banner/index.d.ts +1 -1
  11. package/dist/components/banner/index.js +23 -25
  12. package/dist/components/barchart/index.d.ts +106 -0
  13. package/dist/components/barchart/index.js +122 -0
  14. package/dist/components/breadcrumb/index.d.ts +0 -1
  15. package/dist/components/breadcrumb/index.js +6 -7
  16. package/dist/components/button/index.d.ts +2 -3
  17. package/dist/components/button/index.js +11 -12
  18. package/dist/components/card/index.d.ts +0 -1
  19. package/dist/components/card/index.js +0 -1
  20. package/dist/components/carousel/index.d.ts +169 -0
  21. package/dist/components/carousel/index.js +299 -0
  22. package/dist/components/checkbox/index.d.ts +13 -11
  23. package/dist/components/checkbox/index.js +51 -31
  24. package/dist/components/chip/index.d.ts +1 -1
  25. package/dist/components/chip/index.js +2 -3
  26. package/dist/components/combobox/index.d.ts +33 -49
  27. package/dist/components/combobox/index.js +102 -70
  28. package/dist/components/datepicker/index.d.ts +18 -31
  29. package/dist/components/datepicker/index.js +81 -99
  30. package/dist/components/dialog/index.d.ts +14 -27
  31. package/dist/components/dialog/index.js +17 -18
  32. package/dist/components/divider/index.d.ts +0 -1
  33. package/dist/components/divider/index.js +0 -1
  34. package/dist/components/donutchart/index.d.ts +100 -0
  35. package/dist/components/donutchart/index.js +178 -0
  36. package/dist/components/drawer/index.d.ts +12 -21
  37. package/dist/components/drawer/index.js +34 -36
  38. package/dist/components/empty/index.d.ts +3 -3
  39. package/dist/components/empty/index.js +4 -5
  40. package/dist/components/exception/index.d.ts +86 -0
  41. package/dist/components/exception/index.js +116 -0
  42. package/dist/components/fileupload/index.d.ts +4 -9
  43. package/dist/components/fileupload/index.js +26 -38
  44. package/dist/components/form/index.d.ts +0 -1
  45. package/dist/components/form/index.js +0 -1
  46. package/dist/components/horizontalbarchart/index.d.ts +120 -0
  47. package/dist/components/horizontalbarchart/index.js +193 -0
  48. package/dist/components/input/index.d.ts +22 -22
  49. package/dist/components/input/index.js +76 -105
  50. package/dist/components/linechart/index.d.ts +114 -0
  51. package/dist/components/linechart/index.js +139 -0
  52. package/dist/components/menu/index.d.ts +9 -11
  53. package/dist/components/menu/index.js +42 -39
  54. package/dist/components/metric/index.d.ts +0 -1
  55. package/dist/components/metric/index.js +0 -1
  56. package/dist/components/numberinput/index.d.ts +14 -21
  57. package/dist/components/numberinput/index.js +40 -53
  58. package/dist/components/otpinput/index.d.ts +14 -9
  59. package/dist/components/otpinput/index.js +25 -18
  60. package/dist/components/page/index.d.ts +0 -1
  61. package/dist/components/page/index.js +1 -3
  62. package/dist/components/passwordinput/index.d.ts +14 -11
  63. package/dist/components/passwordinput/index.js +36 -45
  64. package/dist/components/popover/index.d.ts +21 -19
  65. package/dist/components/popover/index.js +34 -15
  66. package/dist/components/radio/index.d.ts +13 -9
  67. package/dist/components/radio/index.js +69 -60
  68. package/dist/components/ratinginput/index.d.ts +13 -8
  69. package/dist/components/ratinginput/index.js +37 -17
  70. package/dist/components/select/index.d.ts +30 -30
  71. package/dist/components/select/index.js +80 -41
  72. package/dist/components/skeleton/index.d.ts +0 -1
  73. package/dist/components/skeleton/index.js +0 -1
  74. package/dist/components/slider/index.d.ts +14 -9
  75. package/dist/components/slider/index.js +64 -63
  76. package/dist/components/spinner/index.d.ts +1 -2
  77. package/dist/components/spinner/index.js +2 -3
  78. package/dist/components/splitter/index.d.ts +1 -2
  79. package/dist/components/splitter/index.js +5 -6
  80. package/dist/components/stepper/index.d.ts +8 -20
  81. package/dist/components/stepper/index.js +15 -16
  82. package/dist/components/switch/index.d.ts +12 -10
  83. package/dist/components/switch/index.js +46 -30
  84. package/dist/components/table/index.d.ts +3 -3
  85. package/dist/components/table/index.js +14 -13
  86. package/dist/components/tabs/index.d.ts +0 -1
  87. package/dist/components/tabs/index.js +1 -2
  88. package/dist/components/textarea/index.d.ts +14 -11
  89. package/dist/components/textarea/index.js +37 -46
  90. package/dist/components/textlink/index.d.ts +3 -1
  91. package/dist/components/textlink/index.js +4 -1
  92. package/dist/components/toast/index.d.ts +8 -14
  93. package/dist/components/toast/index.js +48 -48
  94. package/dist/components/toggle/index.d.ts +0 -1
  95. package/dist/components/toggle/index.js +17 -24
  96. package/dist/components/tooltip/index.d.ts +11 -13
  97. package/dist/components/tooltip/index.js +12 -9
  98. package/dist/components/tour/index.d.ts +154 -0
  99. package/dist/components/tour/index.js +280 -0
  100. package/dist/index.d.ts +7 -2
  101. package/dist/index.js +7 -1
  102. package/dist/types/Icon.d.ts +0 -1
  103. package/dist/types/Icon.js +0 -1
  104. package/dist/types/Style.d.ts +0 -1
  105. package/dist/types/Style.js +0 -1
  106. package/dist/types/Validation.d.ts +12 -0
  107. package/dist/types/Validation.js +1 -0
  108. package/dist/utils/ArkStateToDataAttributes.d.ts +0 -1
  109. package/dist/utils/ArkStateToDataAttributes.js +0 -1
  110. package/dist/utils/Validation.d.ts +14 -0
  111. package/dist/utils/Validation.js +23 -0
  112. package/dist/utils/asChild.d.ts +41 -0
  113. package/dist/utils/asChild.js +15 -0
  114. package/dist/utils/icons.d.ts +24 -0
  115. package/dist/utils/icons.js +160 -0
  116. package/dist/utils/useForwardClickToInput.d.ts +0 -1
  117. package/dist/utils/useForwardClickToInput.js +0 -1
  118. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts +0 -1
  119. package/dist/utils/virtualization/useVirtualizedAutocomplete.js +0 -1
  120. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts +0 -1
  121. package/dist/utils/virtualization/useVirtualizedCombobox.js +0 -1
  122. package/dist/utils/virtualization/useVirtualizedTable.d.ts +0 -1
  123. package/dist/utils/virtualization/useVirtualizedTable.js +0 -1
  124. package/package.json +14 -11
  125. package/src/presets/shopify-polaris/shopify-polaris-autocomplete.css +2 -2
  126. package/src/presets/shopify-polaris/shopify-polaris-barchart.css +64 -0
  127. package/src/presets/shopify-polaris/shopify-polaris-carousel.css +62 -0
  128. package/src/presets/shopify-polaris/shopify-polaris-checkbox.css +2 -2
  129. package/src/presets/shopify-polaris/shopify-polaris-combobox.css +2 -2
  130. package/src/presets/shopify-polaris/shopify-polaris-datepicker.css +4 -4
  131. package/src/presets/shopify-polaris/shopify-polaris-dialog.css +16 -0
  132. package/src/presets/shopify-polaris/shopify-polaris-donutchart.css +172 -0
  133. package/src/presets/shopify-polaris/shopify-polaris-drawer.css +16 -0
  134. package/src/presets/shopify-polaris/shopify-polaris-exception.css +40 -0
  135. package/src/presets/shopify-polaris/shopify-polaris-fileupload.css +1 -1
  136. package/src/presets/shopify-polaris/shopify-polaris-horizontalbarchart.css +60 -0
  137. package/src/presets/shopify-polaris/shopify-polaris-input.css +2 -2
  138. package/src/presets/shopify-polaris/shopify-polaris-linechart.css +68 -0
  139. package/src/presets/shopify-polaris/shopify-polaris-menu.css +16 -0
  140. package/src/presets/shopify-polaris/shopify-polaris-numberinput.css +2 -2
  141. package/src/presets/shopify-polaris/shopify-polaris-otpinput.css +2 -2
  142. package/src/presets/shopify-polaris/shopify-polaris-passwordinput.css +2 -2
  143. package/src/presets/shopify-polaris/shopify-polaris-popover.css +29 -0
  144. package/src/presets/shopify-polaris/shopify-polaris-radio.css +2 -2
  145. package/src/presets/shopify-polaris/shopify-polaris-ratinginput.css +2 -2
  146. package/src/presets/shopify-polaris/shopify-polaris-select.css +2 -2
  147. package/src/presets/shopify-polaris/shopify-polaris-slider.css +2 -2
  148. package/src/presets/shopify-polaris/shopify-polaris-stepper.css +16 -0
  149. package/src/presets/shopify-polaris/shopify-polaris-switch.css +2 -2
  150. package/src/presets/shopify-polaris/shopify-polaris-textarea.css +2 -2
  151. package/src/presets/shopify-polaris/shopify-polaris-tooltip.css +16 -0
  152. package/src/presets/shopify-polaris/shopify-polaris.css +6 -0
  153. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-autocomplete.css +2 -2
  154. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-barchart.css +64 -0
  155. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-carousel.css +55 -0
  156. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-checkbox.css +2 -2
  157. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-combobox.css +2 -2
  158. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-datepicker.css +2 -2
  159. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-dialog.css +9 -0
  160. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-donutchart.css +172 -0
  161. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-drawer.css +9 -0
  162. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-exception.css +40 -0
  163. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-fileupload.css +1 -1
  164. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-horizontalbarchart.css +60 -0
  165. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-input.css +2 -2
  166. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-linechart.css +68 -0
  167. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-menu.css +9 -0
  168. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-numberinput.css +2 -2
  169. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-otpinput.css +2 -2
  170. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-passwordinput.css +2 -2
  171. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-popover.css +22 -0
  172. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-radio.css +2 -2
  173. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-ratinginput.css +2 -2
  174. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-slider.css +2 -2
  175. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +9 -0
  176. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-switch.css +2 -2
  177. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-textarea.css +2 -2
  178. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-tooltip.css +9 -0
  179. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +6 -0
  180. package/dist/components/accordion/index.d.ts.map +0 -1
  181. package/dist/components/accordion/index.js.map +0 -1
  182. package/dist/components/autocomplete/index.d.ts.map +0 -1
  183. package/dist/components/autocomplete/index.js.map +0 -1
  184. package/dist/components/avatar/index.d.ts.map +0 -1
  185. package/dist/components/avatar/index.js.map +0 -1
  186. package/dist/components/badge/index.d.ts.map +0 -1
  187. package/dist/components/badge/index.js.map +0 -1
  188. package/dist/components/banner/index.d.ts.map +0 -1
  189. package/dist/components/banner/index.js.map +0 -1
  190. package/dist/components/breadcrumb/index.d.ts.map +0 -1
  191. package/dist/components/breadcrumb/index.js.map +0 -1
  192. package/dist/components/button/index.d.ts.map +0 -1
  193. package/dist/components/button/index.js.map +0 -1
  194. package/dist/components/card/index.d.ts.map +0 -1
  195. package/dist/components/card/index.js.map +0 -1
  196. package/dist/components/checkbox/index.d.ts.map +0 -1
  197. package/dist/components/checkbox/index.js.map +0 -1
  198. package/dist/components/chip/index.d.ts.map +0 -1
  199. package/dist/components/chip/index.js.map +0 -1
  200. package/dist/components/combobox/index.d.ts.map +0 -1
  201. package/dist/components/combobox/index.js.map +0 -1
  202. package/dist/components/datepicker/index.d.ts.map +0 -1
  203. package/dist/components/datepicker/index.js.map +0 -1
  204. package/dist/components/dialog/index.d.ts.map +0 -1
  205. package/dist/components/dialog/index.js.map +0 -1
  206. package/dist/components/divider/index.d.ts.map +0 -1
  207. package/dist/components/divider/index.js.map +0 -1
  208. package/dist/components/drawer/index.d.ts.map +0 -1
  209. package/dist/components/drawer/index.js.map +0 -1
  210. package/dist/components/empty/index.d.ts.map +0 -1
  211. package/dist/components/empty/index.js.map +0 -1
  212. package/dist/components/fileupload/index.d.ts.map +0 -1
  213. package/dist/components/fileupload/index.js.map +0 -1
  214. package/dist/components/form/index.d.ts.map +0 -1
  215. package/dist/components/form/index.js.map +0 -1
  216. package/dist/components/input/index.d.ts.map +0 -1
  217. package/dist/components/input/index.js.map +0 -1
  218. package/dist/components/menu/index.d.ts.map +0 -1
  219. package/dist/components/menu/index.js.map +0 -1
  220. package/dist/components/metric/index.d.ts.map +0 -1
  221. package/dist/components/metric/index.js.map +0 -1
  222. package/dist/components/numberinput/index.d.ts.map +0 -1
  223. package/dist/components/numberinput/index.js.map +0 -1
  224. package/dist/components/otpinput/index.d.ts.map +0 -1
  225. package/dist/components/otpinput/index.js.map +0 -1
  226. package/dist/components/page/index.d.ts.map +0 -1
  227. package/dist/components/page/index.js.map +0 -1
  228. package/dist/components/passwordinput/index.d.ts.map +0 -1
  229. package/dist/components/passwordinput/index.js.map +0 -1
  230. package/dist/components/popover/index.d.ts.map +0 -1
  231. package/dist/components/popover/index.js.map +0 -1
  232. package/dist/components/radio/index.d.ts.map +0 -1
  233. package/dist/components/radio/index.js.map +0 -1
  234. package/dist/components/ratinginput/index.d.ts.map +0 -1
  235. package/dist/components/ratinginput/index.js.map +0 -1
  236. package/dist/components/select/index.d.ts.map +0 -1
  237. package/dist/components/select/index.js.map +0 -1
  238. package/dist/components/skeleton/index.d.ts.map +0 -1
  239. package/dist/components/skeleton/index.js.map +0 -1
  240. package/dist/components/slider/index.d.ts.map +0 -1
  241. package/dist/components/slider/index.js.map +0 -1
  242. package/dist/components/spinner/index.d.ts.map +0 -1
  243. package/dist/components/spinner/index.js.map +0 -1
  244. package/dist/components/splitter/index.d.ts.map +0 -1
  245. package/dist/components/splitter/index.js.map +0 -1
  246. package/dist/components/stepper/index.d.ts.map +0 -1
  247. package/dist/components/stepper/index.js.map +0 -1
  248. package/dist/components/switch/index.d.ts.map +0 -1
  249. package/dist/components/switch/index.js.map +0 -1
  250. package/dist/components/table/index.d.ts.map +0 -1
  251. package/dist/components/table/index.js.map +0 -1
  252. package/dist/components/tabs/index.d.ts.map +0 -1
  253. package/dist/components/tabs/index.js.map +0 -1
  254. package/dist/components/textarea/index.d.ts.map +0 -1
  255. package/dist/components/textarea/index.js.map +0 -1
  256. package/dist/components/textlink/index.d.ts.map +0 -1
  257. package/dist/components/textlink/index.js.map +0 -1
  258. package/dist/components/toast/index.d.ts.map +0 -1
  259. package/dist/components/toast/index.js.map +0 -1
  260. package/dist/components/toggle/index.d.ts.map +0 -1
  261. package/dist/components/toggle/index.js.map +0 -1
  262. package/dist/components/tooltip/index.d.ts.map +0 -1
  263. package/dist/components/tooltip/index.js.map +0 -1
  264. package/dist/index.d.ts.map +0 -1
  265. package/dist/index.js.map +0 -1
  266. package/dist/types/Icon.d.ts.map +0 -1
  267. package/dist/types/Icon.js.map +0 -1
  268. package/dist/types/Style.d.ts.map +0 -1
  269. package/dist/types/Style.js.map +0 -1
  270. package/dist/types/Tone.d.ts +0 -4
  271. package/dist/types/Tone.d.ts.map +0 -1
  272. package/dist/types/Tone.js +0 -2
  273. package/dist/types/Tone.js.map +0 -1
  274. package/dist/utils/ArkStateToDataAttributes.d.ts.map +0 -1
  275. package/dist/utils/ArkStateToDataAttributes.js.map +0 -1
  276. package/dist/utils/Tone.d.ts +0 -3
  277. package/dist/utils/Tone.d.ts.map +0 -1
  278. package/dist/utils/Tone.js +0 -7
  279. package/dist/utils/Tone.js.map +0 -1
  280. package/dist/utils/useForwardClickToInput.d.ts.map +0 -1
  281. package/dist/utils/useForwardClickToInput.js.map +0 -1
  282. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts.map +0 -1
  283. package/dist/utils/virtualization/useVirtualizedAutocomplete.js.map +0 -1
  284. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts.map +0 -1
  285. package/dist/utils/virtualization/useVirtualizedCombobox.js.map +0 -1
  286. package/dist/utils/virtualization/useVirtualizedTable.d.ts.map +0 -1
  287. package/dist/utils/virtualization/useVirtualizedTable.js.map +0 -1
@@ -2,6 +2,9 @@ import { cloneElement } from 'react';
2
2
  import { twMerge } from 'tailwind-merge';
3
3
  /**
4
4
  * Adds preset styling to one link child without rendering a wrapper or handling navigation.
5
+ * Use it for a link presented as text, like "Read the guide" or "Create account" inside a
6
+ * sentence. To make a whole item clickable (a card, a list row), use your router's bare Link
7
+ * directly instead, without TextLink.
5
8
  * Pass a native anchor or your router's Link; put the destination and navigation props
6
9
  * on that child. Custom link components must forward className, style, and data-*
7
10
  * attributes to their anchor. Supply one element, not text, a fragment, or a list.
@@ -31,6 +34,7 @@ import { twMerge } from 'tailwind-merge';
31
34
  export default function TextLink({ disableStyle, children, className, style, ...props }) {
32
35
  return cloneElement(children, {
33
36
  ...props,
37
+ // Spread from an object so the data-* keys pass the element props' excess property check
34
38
  ...{
35
39
  'data-component': 'textlink-textlink',
36
40
  'data-style-disabled': disableStyle ? '' : undefined,
@@ -39,4 +43,3 @@ export default function TextLink({ disableStyle, children, className, style, ...
39
43
  style: { ...children.props.style, ...style },
40
44
  });
41
45
  }
42
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
1
  import type { StyleProps } from '../../types/Style.ts';
2
+ import type { AsChildProps } from '../../utils/asChild.ts';
2
3
  import { Toast as BaseToast } from '@base-ui/react/toast';
3
4
  import type { ComponentProps, ReactElement, ReactNode } from 'react';
4
5
  export type ProviderProps = Omit<BaseToast.Provider.Props, 'toastManager'> & Pick<BaseToast.Viewport.Props, 'style'> & {
@@ -66,9 +67,7 @@ export declare function Root({ tone, children, }: {
66
67
  export type ToastProps = Omit<BaseToast.Root.Props, 'toast' | 'className'> & {
67
68
  className?: string;
68
69
  } & StyleProps;
69
- export declare const Toast: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastRootProps, "className" | "toast"> & {
70
- className?: string;
71
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
70
+ export declare const Toast: import("react").ForwardRefExoticComponent<Omit<ToastProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
72
71
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
73
72
  export declare function Icon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
74
73
  /** Omit for the supplied default icon; pass a child only to replace it. */
@@ -82,18 +81,14 @@ export declare const Title: import("react").ForwardRefExoticComponent<Omit<Omit<
82
81
  export declare const Description: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastDescriptionProps, "className"> & {
83
82
  className?: string;
84
83
  } & StyleProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
85
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
86
- export declare const CloseHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastCloseProps, "children" | "className" | "render"> & {
87
- className?: string;
88
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
89
- children: ReactElement;
90
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
91
- export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastCloseProps, "className"> & {
84
+ /** Icon-only: put just a CloseButtonIcon inside, never text like "Close". It is already named "Dismiss notification" for screen readers. Pass asChild to give dismissing behavior to your own button instead, like a "Dismiss" Button, which then names itself. */
85
+ export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastCloseProps, "className" | "render"> & {
92
86
  className?: string;
93
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
94
- export declare const ActionButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastActionProps, "className"> & {
87
+ } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
88
+ /** Runs the toast's action. Pass asChild to give this behavior to your own button instead; it keeps the state data attributes but none of this part's styling. */
89
+ export declare const ActionButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastActionProps, "className" | "render"> & {
95
90
  className?: string;
96
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
91
+ } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
97
92
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
98
93
  export declare function CloseButtonIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
99
94
  /** Omit for the supplied default icon; pass a child only to replace it. */
@@ -108,4 +103,3 @@ type NotificationData = {
108
103
  [key: string]: unknown;
109
104
  };
110
105
  export {};
111
- //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { asChildRendering } from "../../utils/asChild.js";
2
3
  import { Toast as BaseToast } from '@base-ui/react/toast';
3
- import { CircleCheck, Info, TriangleAlert, X } from 'lucide-react';
4
+ import { CircleCheck, Info, TriangleAlert, X } from "../../utils/icons.js";
4
5
  import { cloneElement, createContext, forwardRef, useContext, useEffect, useState, } from 'react';
5
6
  import { twMerge } from 'tailwind-merge';
6
7
  /**
@@ -77,36 +78,28 @@ export const Toast = /* @__PURE__ */ forwardRef(function Toast({ disableStyle, c
77
78
  const notification = useNotificationContext();
78
79
  const tone = useContext(ToneContext);
79
80
  return (_jsx(BaseToast.Root, { ...props, ref: ref, toast: notification, "data-tone": tone, "data-component": "toast-toast", "data-style-disabled": disableStyle ? '' : undefined, className: className, style: (state) => {
80
- // Base UI measures heights and provides offsets; the legacy stack adds a 16px gap.
81
- const offsetY = state.expanded
82
- ? 'calc(-1 * (var(--toast-offset-y, 0px) + var(--toast-index) * 16px))'
83
- : 'calc(var(--toast-index) * -16px)';
84
81
  const starting = state.transitionStatus === 'starting';
85
82
  const ending = state.transitionStatus === 'ending';
86
- const horizontalExit = ending &&
87
- (state.swipeDirection === 'left' || state.swipeDirection === 'right');
88
- const x = horizontalExit
89
- ? 'calc(var(--toast-swipe-movement-x, 0px) + ' +
90
- (state.swipeDirection === 'left' ? '-150%' : '150%') +
91
- ')'
92
- : 'var(--toast-swipe-movement-x, 0px)';
93
- const y = starting
94
- ? '150%'
95
- : ending && !horizontalExit
96
- ? 'calc(var(--toast-swipe-movement-y, 0px) + ' +
97
- (state.swipeDirection === 'up' ? '-150%' : '150%') +
98
- ')'
99
- : 'calc(' + offsetY + ' + var(--toast-swipe-movement-y, 0px))';
83
+ const horizontalExit = ending && (state.swipeDirection === 'left' || state.swipeDirection === 'right');
84
+ // Following the finger horizontally, and leaving off-screen on the swiped side
85
+ const x = (() => {
86
+ if (!horizontalExit)
87
+ return 'var(--toast-swipe-movement-x, 0px)';
88
+ return `calc(var(--toast-swipe-movement-x, 0px) + ${state.swipeDirection === 'left' ? '-150%' : '150%'})`;
89
+ })();
90
+ // Entering from below, leaving off-screen vertically, or else stacking: Base UI measures heights and provides offsets, and the legacy stack adds a 16px gap
91
+ const y = (() => {
92
+ if (starting)
93
+ return '150%';
94
+ if (ending && !horizontalExit)
95
+ return `calc(var(--toast-swipe-movement-y, 0px) + ${state.swipeDirection === 'up' ? '-150%' : '150%'})`;
96
+ const offsetY = state.expanded ? 'calc(-1 * (var(--toast-offset-y, 0px) + var(--toast-index) * 16px))' : 'calc(var(--toast-index) * -16px)';
97
+ return `calc(${offsetY} + var(--toast-swipe-movement-y, 0px))`;
98
+ })();
99
+ // Collapsed toasts behind the front one shrink a little each
100
+ const scale = state.expanded ? '1' : 'max(0, calc(1 - var(--toast-index) * 0.05))';
100
101
  return {
101
- transform: 'translateX(' +
102
- x +
103
- ') translateY(' +
104
- y +
105
- ') scale(' +
106
- (state.expanded
107
- ? '1'
108
- : 'max(0, calc(1 - var(--toast-index) * 0.05))') +
109
- ')',
102
+ transform: `translateX(${x}) translateY(${y}) scale(${scale})`,
110
103
  transformOrigin: 'bottom center',
111
104
  zIndex: 'calc(1000 - var(--toast-index))',
112
105
  height: state.expanded
@@ -126,10 +119,17 @@ export const Toast = /* @__PURE__ */ forwardRef(function Toast({ disableStyle, c
126
119
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
127
120
  export function Icon({ disableStyle, children, className, ...props }) {
128
121
  const tone = useContext(ToneContext);
129
- const icon = children ??
130
- (tone === 'success' ? (_jsx(CircleCheck, {})) : tone === 'error' ? (_jsx(TriangleAlert, {})) : (_jsx(Info, {})));
122
+ // Choosing the tone's default icon, unless one is supplied
123
+ const icon = (() => {
124
+ if (children)
125
+ return children;
126
+ if (tone === 'success')
127
+ return _jsx(CircleCheck, {});
128
+ if (tone === 'error')
129
+ return _jsx(TriangleAlert, {});
130
+ return _jsx(Info, {});
131
+ })();
131
132
  return cloneElement(icon, {
132
- ...icon.props,
133
133
  ...props,
134
134
  'aria-hidden': true,
135
135
  'data-tone': tone,
@@ -147,21 +147,22 @@ export const Title = /* @__PURE__ */ forwardRef(function Title({ disableStyle, c
147
147
  export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, ...props }, ref) {
148
148
  return (_jsx(BaseToast.Description, { ...props, ref: ref, "data-component": "toast-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
149
149
  });
150
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
151
- export const CloseHandler = /* @__PURE__ */ forwardRef(function CloseHandler({ children, ...props }, ref) {
152
- return (_jsx(BaseToast.Close, { ...props, ref: ref, render: children, className: props.className }));
150
+ /** Icon-only: put just a CloseButtonIcon inside, never text like "Close". It is already named "Dismiss notification" for screen readers. Pass asChild to give dismissing behavior to your own button instead, like a "Dismiss" Button, which then names itself. */
151
+ export const CloseButton = /* @__PURE__ */ forwardRef(function CloseButton({ asChild, disableStyle, children, ...props }, ref) {
152
+ // Naming the icon-only button for screen readers, while the consumer's own button names itself
153
+ const ariaLabel = asChild ? undefined : 'Dismiss notification';
154
+ const rendering = asChildRendering({ asChild, children, component: 'toast-closebutton', disableStyle });
155
+ return _jsx(BaseToast.Close, { "aria-label": ariaLabel, ...props, ref: ref, ...rendering });
153
156
  });
154
- export const CloseButton = /* @__PURE__ */ forwardRef(function CloseButton({ disableStyle, className, ...props }, ref) {
155
- return (_jsx(BaseToast.Close, { "aria-label": "Dismiss notification", ...props, ref: ref, "data-component": "toast-closebutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
156
- });
157
- export const ActionButton = /* @__PURE__ */ forwardRef(function ActionButton({ disableStyle, className, ...props }, ref) {
158
- return (_jsx(BaseToast.Action, { ...props, ref: ref, "data-component": "toast-actionbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
157
+ /** Runs the toast's action. Pass asChild to give this behavior to your own button instead; it keeps the state data attributes but none of this part's styling. */
158
+ export const ActionButton = /* @__PURE__ */ forwardRef(function ActionButton({ asChild, disableStyle, children, ...props }, ref) {
159
+ const rendering = asChildRendering({ asChild, children, component: 'toast-actionbutton', disableStyle });
160
+ return _jsx(BaseToast.Action, { ...props, ref: ref, ...rendering });
159
161
  });
160
162
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
161
163
  export function CloseButtonIcon({ disableStyle, children = _jsx(X, {}), className, ...props }) {
162
164
  const tone = useContext(ToneContext);
163
165
  return cloneElement(children, {
164
- ...children.props,
165
166
  ...props,
166
167
  'aria-hidden': true,
167
168
  'data-tone': tone,
@@ -175,8 +176,10 @@ export function CloseButtonIcon({ disableStyle, children = _jsx(X, {}), classNam
175
176
  }
176
177
  // Private: every callback-rendered composition receives the native object required by Toast.Root.
177
178
  function Notifications({ className, style, }) {
178
- const { toasts } = BaseToast.useToastManager();
179
- const visible = toasts.filter((notification) => !notification.limited && notification.transitionStatus !== 'ending');
179
+ const toastManager = BaseToast.useToastManager();
180
+ const visible = toastManager.toasts.filter((notification) => !notification.limited && notification.transitionStatus !== 'ending');
181
+ // The stack's 16px gaps between the visible toasts
182
+ const gaps = Math.max(0, visible.length - 1) * 16;
180
183
  return (_jsx(BaseToast.Portal, { children: _jsx(BaseToast.Viewport, { className: className, style: (state) => ({
181
184
  position: 'fixed',
182
185
  bottom: 24,
@@ -184,13 +187,11 @@ function Notifications({ className, style, }) {
184
187
  transform: 'translateX(-50%)',
185
188
  width: 'min(400px, calc(100vw - 48px))',
186
189
  zIndex: 1000,
187
- height: state.expanded
188
- ? visible.reduce((total, notification) => total + (notification.height ?? 0), 0) +
189
- Math.max(0, visible.length - 1) * 16
190
- : (visible[0]?.height ?? 0) + Math.max(0, visible.length - 1) * 16,
190
+ // Expanded, the viewport fits every visible toast, otherwise only the front one
191
+ height: (state.expanded ? visible.reduce((total, notification) => total + (notification.height ?? 0), 0) : (visible[0]?.height ?? 0)) + gaps,
191
192
  pointerEvents: visible.length ? 'auto' : 'none',
192
193
  ...(typeof style === 'function' ? style(state) : style),
193
- }), children: toasts.map((notification) => (_jsx(NotificationContext.Provider, { value: notification, children: notification.data.render() }, notification.id))) }) }));
194
+ }), children: toastManager.toasts.map((notification) => (_jsx(NotificationContext.Provider, { value: notification, children: notification.data.render() }, notification.id))) }) }));
194
195
  }
195
196
  let activeManager;
196
197
  const NotificationContext =
@@ -202,4 +203,3 @@ function useNotificationContext() {
202
203
  throw new Error('Toast.Toast must be rendered by Toast.Show');
203
204
  return notification;
204
205
  }
205
- //# sourceMappingURL=index.js.map
@@ -38,4 +38,3 @@ export declare const InactiveIcon: import("react").ForwardRefExoticComponent<Omi
38
38
  /** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
39
39
  children: ReactElement<SVGIconProps>;
40
40
  } & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
41
- //# sourceMappingURL=index.d.ts.map
@@ -31,38 +31,32 @@ export const Root = /* @__PURE__ */ forwardRef(function Root({ children, classNa
31
31
  }, className: className, children: _jsx(ToggleContext.Provider, { value: { pressed: pressed ?? pressedInternalState, disabled, size }, children: children }) }));
32
32
  });
33
33
  /** Render beside InactiveIcon inside Root. It automatically appears only while pressed; supply the decorative icon without another visibility condition. */
34
- export const ActiveIcon = /* @__PURE__ */ forwardRef(function ActiveIcon({ disableStyle, children, className, ...props }, ref) {
35
- const { pressed, disabled, size } = useToggleContext();
36
- if (!pressed)
34
+ export const ActiveIcon = /* @__PURE__ */ forwardRef(function ActiveIcon(props, ref) {
35
+ const context = useToggleContext();
36
+ if (!context.pressed)
37
37
  return null;
38
- return cloneElement(children, {
39
- ...props,
40
- ref,
41
- 'aria-hidden': true,
42
- 'data-size': size,
43
- 'data-pressed': pressed ? '' : undefined,
44
- 'data-disabled': disabled ? '' : undefined,
45
- ...{
46
- 'data-component': 'toggle-activeicon',
47
- 'data-style-disabled': disableStyle ? '' : undefined,
48
- },
49
- className: twMerge(children.props.className, className),
50
- });
38
+ return _jsx(StateIcon, { ...props, ref: ref, component: "toggle-activeicon" });
51
39
  });
52
40
  /** Render beside ActiveIcon inside Root. It automatically appears only while unpressed; supply the decorative icon without another visibility condition. */
53
- export const InactiveIcon = /* @__PURE__ */ forwardRef(function InactiveIcon({ disableStyle, children, className, ...props }, ref) {
54
- const { pressed, disabled, size } = useToggleContext();
55
- if (pressed)
41
+ export const InactiveIcon = /* @__PURE__ */ forwardRef(function InactiveIcon(props, ref) {
42
+ const context = useToggleContext();
43
+ if (context.pressed)
56
44
  return null;
45
+ return _jsx(StateIcon, { ...props, ref: ref, component: "toggle-inactiveicon" });
46
+ });
47
+ // The shared body of ActiveIcon and InactiveIcon: decorates the supplied icon with the toggle's state
48
+ const StateIcon = /* @__PURE__ */ forwardRef(function StateIcon({ disableStyle, children, className, component, ...props }, ref) {
49
+ const context = useToggleContext();
57
50
  return cloneElement(children, {
58
51
  ...props,
59
52
  ref,
60
53
  'aria-hidden': true,
61
- 'data-size': size,
62
- 'data-pressed': pressed ? '' : undefined,
63
- 'data-disabled': disabled ? '' : undefined,
54
+ 'data-size': context.size,
55
+ 'data-pressed': context.pressed ? '' : undefined,
56
+ 'data-disabled': context.disabled ? '' : undefined,
57
+ // Spread from an object so the data-* keys pass the element props' excess property check
64
58
  ...{
65
- 'data-component': 'toggle-inactiveicon',
59
+ 'data-component': component,
66
60
  'data-style-disabled': disableStyle ? '' : undefined,
67
61
  },
68
62
  className: twMerge(children.props.className, className),
@@ -75,4 +69,3 @@ function useToggleContext() {
75
69
  throw new Error('Toggle icons must be inside Toggle.Root');
76
70
  return context;
77
71
  }
78
- //# sourceMappingURL=index.js.map
@@ -1,8 +1,9 @@
1
1
  import type { StyleProps } from '../../types/Style.ts';
2
+ import type { AsChildProps } from '../../utils/asChild.ts';
2
3
  import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';
3
- import type { ComponentPropsWithRef, ReactElement } from 'react';
4
+ import type { ComponentPropsWithRef } from 'react';
4
5
  /**
5
- * Wrap the target element with OpenHandler and keep Popup in the same Root. Popup already includes its portal and positioner. PopupText supplies the help text; Arrow is optional.
6
+ * OpenButton renders its own trigger button; pass asChild to make your own target element the trigger instead. Keep Popup in the same Root. Popup already includes its portal and positioner. PopupText supplies the help text; Arrow is optional.
6
7
  *
7
8
  * @example Complete composition
8
9
  * import { Button, Tooltip } from '@central-ui/react'
@@ -10,9 +11,9 @@ import type { ComponentPropsWithRef, ReactElement } from 'react';
10
11
  * function Example() {
11
12
  * return (
12
13
  * <Tooltip.Root>
13
- * <Tooltip.OpenHandler>
14
+ * <Tooltip.OpenButton asChild>
14
15
  * <Button.default variant="secondary">Delivery information</Button.default>
15
- * </Tooltip.OpenHandler>
16
+ * </Tooltip.OpenButton>
16
17
  * <Tooltip.Popup>
17
18
  * <Tooltip.PopupText>Usually arrives within three days.</Tooltip.PopupText>
18
19
  * <Tooltip.Arrow />
@@ -22,23 +23,20 @@ import type { ComponentPropsWithRef, ReactElement } from 'react';
22
23
  * }
23
24
  *
24
25
  * @example Place help below its target
25
- * // Keep the same OpenHandler and Root.
26
+ * // Keep the same OpenButton and Root.
26
27
  * ;<Tooltip.Popup side="bottom">
27
28
  * <Tooltip.PopupText>Delivery details</Tooltip.PopupText>
28
29
  * </Tooltip.Popup>
29
30
  */
30
- export declare const Root: <Payload>(props: BaseTooltip.Root.Props<Payload>) => React.JSX.Element;
31
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
32
- export declare const OpenHandler: import("react").ForwardRefExoticComponent<Omit<Omit<BaseTooltip.Trigger.Props<unknown>, "children" | "className" | "render"> & {
31
+ export declare function Root<Payload = unknown>(props: BaseTooltip.Root.Props<Payload>): import("react").JSX.Element;
32
+ /** Opens the tooltip on hover or focus. Pass asChild to give this behavior to your own element, like your app's Button. */
33
+ export declare const OpenButton: import("react").ForwardRefExoticComponent<Omit<Omit<BaseTooltip.Trigger.Props<unknown>, "className" | "render"> & {
33
34
  className?: string;
34
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
35
- children: ReactElement;
36
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
35
+ } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
37
36
  export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseTooltip.Popup>, 'className'> & {
38
37
  className?: string;
39
38
  } & Pick<BaseTooltip.Portal.Props, 'container' | 'keepMounted'> & Pick<BaseTooltip.Positioner.Props, 'anchor' | 'positionMethod' | 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'collisionBoundary' | 'collisionPadding' | 'sticky' | 'arrowPadding' | 'disableAnchorTracking' | 'collisionAvoidance'> & StyleProps;
40
39
  /** Already includes the portal and positioner. Keep it in the matching Root and let the native open state control visibility. */
41
- export declare function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }: PopupProps & StyleProps): import("react").JSX.Element;
40
+ export declare function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }: PopupProps): import("react").JSX.Element;
42
41
  export declare const PopupText: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
43
42
  export declare const Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").SVGProps<SVGSVGElement>, "children" | "dangerouslySetInnerHTML"> & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
44
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { asChildRendering } from "../../utils/asChild.js";
2
3
  import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';
3
4
  import { forwardRef } from 'react';
4
5
  /**
5
- * Wrap the target element with OpenHandler and keep Popup in the same Root. Popup already includes its portal and positioner. PopupText supplies the help text; Arrow is optional.
6
+ * OpenButton renders its own trigger button; pass asChild to make your own target element the trigger instead. Keep Popup in the same Root. Popup already includes its portal and positioner. PopupText supplies the help text; Arrow is optional.
6
7
  *
7
8
  * @example Complete composition
8
9
  * import { Button, Tooltip } from '@central-ui/react'
@@ -10,9 +11,9 @@ import { forwardRef } from 'react';
10
11
  * function Example() {
11
12
  * return (
12
13
  * <Tooltip.Root>
13
- * <Tooltip.OpenHandler>
14
+ * <Tooltip.OpenButton asChild>
14
15
  * <Button.default variant="secondary">Delivery information</Button.default>
15
- * </Tooltip.OpenHandler>
16
+ * </Tooltip.OpenButton>
16
17
  * <Tooltip.Popup>
17
18
  * <Tooltip.PopupText>Usually arrives within three days.</Tooltip.PopupText>
18
19
  * <Tooltip.Arrow />
@@ -22,15 +23,18 @@ import { forwardRef } from 'react';
22
23
  * }
23
24
  *
24
25
  * @example Place help below its target
25
- * // Keep the same OpenHandler and Root.
26
+ * // Keep the same OpenButton and Root.
26
27
  * ;<Tooltip.Popup side="bottom">
27
28
  * <Tooltip.PopupText>Delivery details</Tooltip.PopupText>
28
29
  * </Tooltip.Popup>
29
30
  */
30
- export const Root = BaseTooltip.Root;
31
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
32
- export const OpenHandler = /* @__PURE__ */ forwardRef(function OpenHandler({ children, ...props }, ref) {
33
- return _jsx(BaseTooltip.Trigger, { ...props, ref: ref, render: children });
31
+ export function Root(props) {
32
+ return _jsx(BaseTooltip.Root, { ...props });
33
+ }
34
+ /** Opens the tooltip on hover or focus. Pass asChild to give this behavior to your own element, like your app's Button. */
35
+ export const OpenButton = /* @__PURE__ */ forwardRef(function OpenButton({ asChild, disableStyle, children, ...props }, ref) {
36
+ const rendering = asChildRendering({ asChild, children, component: 'tooltip-openbutton', disableStyle });
37
+ return _jsx(BaseTooltip.Trigger, { ...props, ref: ref, ...rendering });
34
38
  });
35
39
  /** Already includes the portal and positioner. Keep it in the matching Root and let the native open state control visibility. */
36
40
  export function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side = 'top', sideOffset = 8, align = 'start', alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }) {
@@ -48,4 +52,3 @@ export const PopupText = /* @__PURE__ */ forwardRef(function PopupText({ disable
48
52
  export const Arrow = /* @__PURE__ */ forwardRef(function Arrow({ disableStyle, className, style, ...props }, ref) {
49
53
  return (_jsxs(BaseTooltip.Arrow, { style: style, render: _jsx("svg", { ...props, ref: ref, "aria-hidden": true, width: "20", height: "10", viewBox: "0 0 20 10" }), "data-component": "tooltip-arrow", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx("path", { d: "M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z", "data-component": "tooltip-arrow-1" }), _jsx("path", { d: "M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z", "data-component": "tooltip-arrow-2" }), _jsx("path", { d: "M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z", "data-component": "tooltip-arrow-3" })] }));
50
54
  });
51
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,154 @@
1
+ import type { StyleProps } from '../../types/Style.ts';
2
+ import type { AsChildProps } from '../../utils/asChild.ts';
3
+ import type { Step as JoyrideStep } from 'react-joyride';
4
+ import type { ComponentProps, ReactElement, ReactNode, SVGProps } from 'react';
5
+ /**
6
+ * A guided tour that highlights elements one by one, each with a popup next to it.
7
+ * Root holds the steps (which element, in which order); Popup holds what every popup shows.
8
+ * Write the popup's frame and buttons once, and put what differs per step in a Content
9
+ * with the step's `value`, like Tabs.Content. Back/Next/Done/Skip/Close are styled buttons that show only when they can act.
10
+ *
11
+ * @example Complete composition, opened from a button
12
+ * import { Button, Tour } from '@central-ui/react'
13
+ *
14
+ * function Example() {
15
+ * const [open, setOpen] = useState(false)
16
+ *
17
+ * return (
18
+ * <>
19
+ * <Button.default onClick={() => setOpen(true)}>Take the tour</Button.default>
20
+ * <div id="search">…</div>
21
+ * <div id="filters">…</div>
22
+ *
23
+ * <Tour.Root
24
+ * steps={[
25
+ * { value: 'search', target: '#search' },
26
+ * { value: 'filters', target: '#filters' },
27
+ * ]}
28
+ * open={open}
29
+ * onOpenChange={setOpen}
30
+ * >
31
+ * <Tour.Popup>
32
+ * <Tour.Content value="search">
33
+ * <Tour.Title>Search</Tour.Title>
34
+ * <Tour.Description>Find any order fast.</Tour.Description>
35
+ * </Tour.Content>
36
+ * <Tour.Content value="filters">
37
+ * <Tour.Title>Filters</Tour.Title>
38
+ * <Tour.Description>Narrow the results.</Tour.Description>
39
+ * </Tour.Content>
40
+ * <Tour.Progress />
41
+ * <Tour.BackButton>Back</Tour.BackButton>
42
+ * <Tour.NextButton>Next</Tour.NextButton>
43
+ * <Tour.DoneButton>Done</Tour.DoneButton>
44
+ * </Tour.Popup>
45
+ * </Tour.Root>
46
+ * </>
47
+ * )
48
+ * }
49
+ *
50
+ * @example Start on its own as soon as the page mounts, with no trigger button
51
+ * // Uncontrolled: defaultOpen starts the tour when Root mounts, and Root closes it itself.
52
+ * // Mount Root conditionally (e.g. only for users who haven't seen it) to show it once.
53
+ * ;<Tour.Root steps={steps} defaultOpen onOpenChange={(open) => { if (!open) markTourSeen() }}>
54
+ * <Tour.Popup>…</Tour.Popup>
55
+ * </Tour.Root>
56
+ *
57
+ * @example Content only one step has, like a video
58
+ * // Anything inside a Content shows only on its step; anything outside shows on every step.
59
+ * ;<Tour.Content value="filters">
60
+ * <Tour.Title>Filters</Tour.Title>
61
+ * <video src="/filters.mp4" autoPlay muted />
62
+ * </Tour.Content>
63
+ *
64
+ * @example Let users click the highlighted element during a step
65
+ * ;<Tour.Root steps={[{ value: 'upload', target: '#upload', interactive: true }]}>
66
+ */
67
+ export declare function Root(props: {
68
+ /**
69
+ * The tour's stops, in order. Each `value` pairs with the Content of the same value,
70
+ * and `target` is the element to highlight, as a CSS selector or an element.
71
+ * Set `interactive` to let users click the highlighted element during that step,
72
+ * e.g. a "try it now" step; otherwise clicks on it are blocked so a click can't navigate away mid-tour.
73
+ */
74
+ steps: readonly ({
75
+ value: string;
76
+ interactive?: boolean;
77
+ } & Pick<JoyrideStep, 'target'>)[];
78
+ /** Whether the tour is showing. Use with onOpenChange to start it from your own button. */
79
+ open?: boolean;
80
+ /**
81
+ * Whether the tour starts as soon as Root mounts, when `open` isn't controlled.
82
+ * Use it for tours that start on their own, like a first visit.
83
+ * @default false
84
+ */
85
+ defaultOpen?: boolean;
86
+ /** Called when the tour starts or ends, including when it ends by Close, Skip, Done, or the Escape key. */
87
+ onOpenChange?: (open: boolean) => void;
88
+ /** The `value` of the step showing. Use with onStepChange to control the step yourself. */
89
+ step?: string;
90
+ /**
91
+ * The `value` of the step the tour starts on, when `step` isn't controlled.
92
+ * @default the first step's value
93
+ */
94
+ defaultStep?: string;
95
+ /** Called with the next step's `value` whenever the tour moves to another step. */
96
+ onStepChange?: (step: string) => void;
97
+ /** The Popup. */
98
+ children: ReactNode;
99
+ }): import("react").JSX.Element;
100
+ type PopupPlacement = {
101
+ side: 'top' | 'bottom' | 'left' | 'right';
102
+ align: 'start' | 'center' | 'end';
103
+ };
104
+ /**
105
+ * The box next to the highlighted element, shown on every step. Write the shared frame and buttons here once.
106
+ * `side` and `align` are where it prefers to sit; Joyride flips it when that side has no room, so it never leaves the screen.
107
+ */
108
+ export declare function Popup({ disableStyle, className, side, align, ...props }: ComponentProps<'div'> & StyleProps & {
109
+ /**
110
+ * The side of the highlighted element the popup prefers.
111
+ * @default 'bottom'
112
+ */
113
+ side?: PopupPlacement['side'];
114
+ /**
115
+ * How the popup lines up along that side.
116
+ * @default 'center'
117
+ */
118
+ align?: PopupPlacement['align'];
119
+ }): import("react").JSX.Element;
120
+ /** Shows its children only while its step is showing, like Tabs.Content. Put anything specific to one step here. */
121
+ export declare function Content({ disableStyle, className, value, ...props }: ComponentProps<'div'> & StyleProps & {
122
+ /** The `value` of the step this content belongs to, matching one of Root's steps. */
123
+ value: string;
124
+ }): import("react").JSX.Element | null;
125
+ export declare function Title({ disableStyle, className, ...props }: ComponentProps<'h2'> & StyleProps): import("react").JSX.Element;
126
+ export declare function Description({ disableStyle, className, ...props }: ComponentProps<'p'> & StyleProps): import("react").JSX.Element;
127
+ /** Shows the position in the tour, like "2 of 5". Pass a function as children to word it differently, e.g. for another language. */
128
+ export declare function Progress({ disableStyle, className, children, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps & {
129
+ children?: (progress: {
130
+ step: number;
131
+ total: number;
132
+ }) => ReactNode;
133
+ }): import("react").JSX.Element;
134
+ type ButtonProps = ComponentProps<'button'> & AsChildProps & StyleProps;
135
+ /** Goes back one step, styled like a secondary Button. Not rendered on the first step, where there's nothing to go back to. Pass asChild to give this behavior to your own button instead. */
136
+ export declare function BackButton(props: ButtonProps): import("react").JSX.Element | null;
137
+ /** Goes to the next step, styled like a primary Button. Not rendered on the last step; DoneButton takes its place there. Pass asChild to give this behavior to your own button instead. */
138
+ export declare function NextButton(props: ButtonProps): import("react").JSX.Element | null;
139
+ /** Finishes the tour, styled like a primary Button. Rendered only on the last step, in NextButton's place. Pass asChild to give this behavior to your own button instead. */
140
+ export declare function DoneButton(props: ButtonProps): import("react").JSX.Element | null;
141
+ /** Ends the tour early, styled like a tertiary Button. Not rendered on the last step, where Done already ends it. Pass asChild to give this behavior to your own button instead. */
142
+ export declare function SkipButton(props: ButtonProps): import("react").JSX.Element | null;
143
+ /**
144
+ * Ends the tour from any step: the round ✕ in the popup's top-right corner, like Dialog's.
145
+ * Icon-only: put just a CloseButtonIcon inside, never text like "Close". It is already named for screen readers by Joyride.
146
+ * Pass asChild to give this behavior to your own button instead.
147
+ */
148
+ export declare function CloseButton(props: ButtonProps): import("react").JSX.Element;
149
+ /** A default ✕ icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
150
+ export declare function CloseButtonIcon({ disableStyle, children, className, ...props }: SVGProps<SVGSVGElement> & StyleProps & {
151
+ /** Omit for the supplied default icon; pass a child only to replace it. */
152
+ children?: ReactElement<SVGProps<SVGSVGElement>>;
153
+ }): import("react").FunctionComponentElement<any>;
154
+ export {};