@doist/reactist 25.0.0-beta.2 → 25.0.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 (345) hide show
  1. package/README.md +35 -16
  2. package/dist/reactist.cjs.development.js +448 -422
  3. package/dist/reactist.cjs.development.js.map +1 -1
  4. package/dist/reactist.cjs.production.min.js +1 -1
  5. package/dist/reactist.cjs.production.min.js.map +1 -1
  6. package/es/alert/alert.js +13 -13
  7. package/es/alert/alert.js.map +1 -1
  8. package/es/alert/alert.module.css.js +1 -1
  9. package/es/avatar/avatar.js +6 -6
  10. package/es/avatar/avatar.js.map +1 -1
  11. package/es/avatar/avatar.module.css.js +1 -1
  12. package/es/avatar/utils.js.map +1 -1
  13. package/es/badge/badge.js +4 -4
  14. package/es/badge/badge.js.map +1 -1
  15. package/es/badge/badge.module.css.js +1 -1
  16. package/es/banner/banner.js +16 -16
  17. package/es/banner/banner.js.map +1 -1
  18. package/es/banner/banner.module.css.js +1 -1
  19. package/es/base-field/base-field.js +25 -25
  20. package/es/base-field/base-field.js.map +1 -1
  21. package/es/base-field/base-field.module.css.js +1 -1
  22. package/es/box/box.js +12 -12
  23. package/es/box/box.js.map +1 -1
  24. package/es/box/box.module.css.js +1 -1
  25. package/es/box/gap.module.css.js +1 -1
  26. package/es/box/margin.module.css.js +1 -1
  27. package/es/box/padding.module.css.js +1 -1
  28. package/es/box/width.module.css.js +1 -1
  29. package/es/button/button.js +19 -19
  30. package/es/button/button.js.map +1 -1
  31. package/es/button/button.module.css.js +1 -1
  32. package/es/checkbox-field/checkbox-field.js +16 -16
  33. package/es/checkbox-field/checkbox-field.js.map +1 -1
  34. package/es/checkbox-field/checkbox-field.module.css.js +1 -1
  35. package/es/checkbox-field/checkbox-icon.js +3 -3
  36. package/es/checkbox-field/checkbox-icon.js.map +1 -1
  37. package/es/checkbox-field/use-fork-ref.js.map +1 -1
  38. package/es/columns/columns.js +6 -6
  39. package/es/columns/columns.js.map +1 -1
  40. package/es/columns/columns.module.css.js +1 -1
  41. package/es/components/color-picker/color-picker.js +11 -11
  42. package/es/components/color-picker/color-picker.js.map +1 -1
  43. package/es/components/color-picker/index.js +1 -5
  44. package/es/components/color-picker/index.js.map +1 -1
  45. package/es/components/deprecated-button/deprecated-button.js +4 -4
  46. package/es/components/deprecated-button/deprecated-button.js.map +1 -1
  47. package/es/components/deprecated-button/index.js +1 -4
  48. package/es/components/deprecated-button/index.js.map +1 -1
  49. package/es/components/deprecated-dropdown/dropdown.js +11 -11
  50. package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
  51. package/es/components/deprecated-dropdown/index.js +1 -4
  52. package/es/components/deprecated-dropdown/index.js.map +1 -1
  53. package/es/components/deprecated-input/index.js +1 -4
  54. package/es/components/deprecated-input/index.js.map +1 -1
  55. package/es/components/deprecated-input/input.js +3 -3
  56. package/es/components/deprecated-input/input.js.map +1 -1
  57. package/es/components/deprecated-select/index.js +1 -4
  58. package/es/components/deprecated-select/index.js.map +1 -1
  59. package/es/components/deprecated-select/select.js +3 -3
  60. package/es/components/deprecated-select/select.js.map +1 -1
  61. package/es/components/key-capturer/index.js +1 -5
  62. package/es/components/key-capturer/index.js.map +1 -1
  63. package/es/components/key-capturer/key-capturer.js +3 -3
  64. package/es/components/key-capturer/key-capturer.js.map +1 -1
  65. package/es/components/keyboard-shortcut/index.js +1 -4
  66. package/es/components/keyboard-shortcut/index.js.map +1 -1
  67. package/es/components/keyboard-shortcut/keyboard-shortcut.js +4 -4
  68. package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  69. package/es/components/progress-bar/index.js +1 -4
  70. package/es/components/progress-bar/index.js.map +1 -1
  71. package/es/components/progress-bar/progress-bar.js +5 -5
  72. package/es/components/progress-bar/progress-bar.js.map +1 -1
  73. package/es/components/time/index.js +1 -4
  74. package/es/components/time/index.js.map +1 -1
  75. package/es/components/time/time-utils.js.map +1 -1
  76. package/es/components/time/time.js +5 -5
  77. package/es/components/time/time.js.map +1 -1
  78. package/es/divider/divider.js +4 -4
  79. package/es/divider/divider.js.map +1 -1
  80. package/es/divider/divider.module.css.js +1 -1
  81. package/es/heading/heading.js +5 -5
  82. package/es/heading/heading.js.map +1 -1
  83. package/es/heading/heading.module.css.js +1 -1
  84. package/es/hidden/hidden.js +5 -5
  85. package/es/hidden/hidden.js.map +1 -1
  86. package/es/hidden/hidden.module.css.js +1 -1
  87. package/es/hidden-visually/hidden-visually.js +4 -4
  88. package/es/hidden-visually/hidden-visually.js.map +1 -1
  89. package/es/hidden-visually/hidden-visually.module.css.js +1 -1
  90. package/es/icons/alert-icon.js +10 -10
  91. package/es/icons/alert-icon.js.map +1 -1
  92. package/es/icons/close-icon.js +3 -3
  93. package/es/icons/close-icon.js.map +1 -1
  94. package/es/icons/password-hidden-icon.js +6 -6
  95. package/es/icons/password-hidden-icon.js.map +1 -1
  96. package/es/icons/password-visible-icon.js +5 -5
  97. package/es/icons/password-visible-icon.js.map +1 -1
  98. package/es/index.js +13 -15
  99. package/es/index.js.map +1 -1
  100. package/es/inline/inline.js +2 -2
  101. package/es/inline/inline.js.map +1 -1
  102. package/es/loading/loading.js +3 -3
  103. package/es/loading/loading.js.map +1 -1
  104. package/es/menu/menu.js +32 -32
  105. package/es/menu/menu.js.map +1 -1
  106. package/es/modal/modal.js +45 -45
  107. package/es/modal/modal.js.map +1 -1
  108. package/es/modal/modal.module.css.js +1 -1
  109. package/es/notice/notice.js +8 -8
  110. package/es/notice/notice.js.map +1 -1
  111. package/es/notice/notice.module.css.js +1 -1
  112. package/es/password-field/password-field.js +7 -7
  113. package/es/password-field/password-field.js.map +1 -1
  114. package/es/prose/prose.js +4 -4
  115. package/es/prose/prose.js.map +1 -1
  116. package/es/prose/prose.module.css.js +1 -1
  117. package/es/select-field/select-field.js +11 -11
  118. package/es/select-field/select-field.js.map +1 -1
  119. package/es/select-field/select-field.module.css.js +1 -1
  120. package/es/spinner/spinner.js +9 -9
  121. package/es/spinner/spinner.js.map +1 -1
  122. package/es/spinner/spinner.module.css.js +1 -1
  123. package/es/stack/stack.js +4 -4
  124. package/es/stack/stack.js.map +1 -1
  125. package/es/switch-field/switch-field.js +18 -18
  126. package/es/switch-field/switch-field.js.map +1 -1
  127. package/es/switch-field/switch-field.module.css.js +1 -1
  128. package/es/tabs/tabs.js +23 -23
  129. package/es/tabs/tabs.js.map +1 -1
  130. package/es/tabs/tabs.module.css.js +1 -1
  131. package/es/text/text.js +5 -5
  132. package/es/text/text.js.map +1 -1
  133. package/es/text/text.module.css.js +1 -1
  134. package/es/text-area/text-area.js +14 -14
  135. package/es/text-area/text-area.js.map +1 -1
  136. package/es/text-area/text-area.module.css.js +1 -1
  137. package/es/text-field/text-field.js +13 -13
  138. package/es/text-field/text-field.js.map +1 -1
  139. package/es/text-field/text-field.module.css.js +1 -1
  140. package/es/text-link/text-link.js +5 -5
  141. package/es/text-link/text-link.js.map +1 -1
  142. package/es/text-link/text-link.module.css.js +1 -1
  143. package/es/toast/static-toast.js +5 -5
  144. package/es/toast/static-toast.js.map +1 -1
  145. package/es/toast/toast-animation.js.map +1 -1
  146. package/es/toast/toast.module.css.js +1 -1
  147. package/es/toast/use-toasts.js +4 -4
  148. package/es/toast/use-toasts.js.map +1 -1
  149. package/es/tooltip/tooltip.js +9 -9
  150. package/es/tooltip/tooltip.js.map +1 -1
  151. package/es/tooltip/tooltip.module.css.js +1 -1
  152. package/es/utils/common-helpers.js +2 -2
  153. package/es/utils/common-helpers.js.map +1 -1
  154. package/es/utils/polymorphism.js +2 -2
  155. package/es/utils/polymorphism.js.map +1 -1
  156. package/es/utils/responsive-props.js.map +1 -1
  157. package/lib/alert/alert.d.ts +3 -3
  158. package/lib/alert/alert.js +1 -1
  159. package/lib/alert/alert.js.map +1 -1
  160. package/lib/avatar/avatar.d.ts +2 -2
  161. package/lib/avatar/avatar.js +1 -1
  162. package/lib/avatar/avatar.js.map +1 -1
  163. package/lib/avatar/utils.js.map +1 -1
  164. package/lib/badge/badge.d.ts +2 -2
  165. package/lib/badge/badge.js +1 -1
  166. package/lib/badge/badge.js.map +1 -1
  167. package/lib/banner/banner.d.ts +2 -2
  168. package/lib/banner/banner.js +1 -1
  169. package/lib/banner/banner.js.map +1 -1
  170. package/lib/base-field/base-field.d.ts +9 -9
  171. package/lib/base-field/base-field.js +1 -1
  172. package/lib/base-field/base-field.js.map +1 -1
  173. package/lib/box/box.d.ts +15 -15
  174. package/lib/box/box.js +1 -1
  175. package/lib/box/box.js.map +1 -1
  176. package/lib/button/button.d.ts +4 -4
  177. package/lib/button/button.js +1 -1
  178. package/lib/button/button.js.map +1 -1
  179. package/lib/checkbox-field/checkbox-field.js +1 -1
  180. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  181. package/lib/checkbox-field/checkbox-icon.d.ts +1 -1
  182. package/lib/checkbox-field/checkbox-icon.js +1 -1
  183. package/lib/checkbox-field/checkbox-icon.js.map +1 -1
  184. package/lib/checkbox-field/use-fork-ref.js.map +1 -1
  185. package/lib/columns/columns.d.ts +4 -4
  186. package/lib/columns/columns.js +1 -1
  187. package/lib/columns/columns.js.map +1 -1
  188. package/lib/components/color-picker/color-picker.d.ts +3 -3
  189. package/lib/components/color-picker/color-picker.js +1 -1
  190. package/lib/components/color-picker/color-picker.js.map +1 -1
  191. package/lib/components/deprecated-button/deprecated-button.d.ts +4 -4
  192. package/lib/components/deprecated-button/deprecated-button.js +1 -1
  193. package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
  194. package/lib/components/deprecated-dropdown/dropdown.d.ts +5 -5
  195. package/lib/components/deprecated-dropdown/dropdown.js +1 -1
  196. package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
  197. package/lib/components/deprecated-input/input.js +1 -1
  198. package/lib/components/deprecated-input/input.js.map +1 -1
  199. package/lib/components/deprecated-select/select.d.ts +2 -2
  200. package/lib/components/deprecated-select/select.js +1 -1
  201. package/lib/components/deprecated-select/select.js.map +1 -1
  202. package/lib/components/key-capturer/key-capturer.d.ts +5 -5
  203. package/lib/components/key-capturer/key-capturer.js +1 -1
  204. package/lib/components/key-capturer/key-capturer.js.map +1 -1
  205. package/lib/components/keyboard-shortcut/keyboard-shortcut.d.ts +3 -3
  206. package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
  207. package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  208. package/lib/components/progress-bar/progress-bar.d.ts +1 -1
  209. package/lib/components/progress-bar/progress-bar.js +1 -1
  210. package/lib/components/progress-bar/progress-bar.js.map +1 -1
  211. package/lib/components/time/time-utils.d.ts +1 -1
  212. package/lib/components/time/time-utils.js +1 -1
  213. package/lib/components/time/time-utils.js.map +1 -1
  214. package/lib/components/time/time.d.ts +2 -2
  215. package/lib/components/time/time.js +1 -1
  216. package/lib/components/time/time.js.map +1 -1
  217. package/lib/divider/divider.js +1 -1
  218. package/lib/divider/divider.js.map +1 -1
  219. package/lib/heading/heading.d.ts +2 -2
  220. package/lib/heading/heading.js +1 -1
  221. package/lib/heading/heading.js.map +1 -1
  222. package/lib/hidden/hidden.d.ts +4 -4
  223. package/lib/hidden/hidden.js +1 -1
  224. package/lib/hidden/hidden.js.map +1 -1
  225. package/lib/hidden-visually/hidden-visually.d.ts +1 -1
  226. package/lib/hidden-visually/hidden-visually.js +1 -1
  227. package/lib/hidden-visually/hidden-visually.js.map +1 -1
  228. package/lib/icons/alert-icon.js +1 -1
  229. package/lib/icons/alert-icon.js.map +1 -1
  230. package/lib/icons/close-icon.js +1 -1
  231. package/lib/icons/close-icon.js.map +1 -1
  232. package/lib/icons/password-hidden-icon.js +1 -1
  233. package/lib/icons/password-hidden-icon.js.map +1 -1
  234. package/lib/icons/password-visible-icon.js +1 -1
  235. package/lib/icons/password-visible-icon.js.map +1 -1
  236. package/lib/index.js +1 -1
  237. package/lib/inline/inline.d.ts +1 -1
  238. package/lib/inline/inline.js +1 -1
  239. package/lib/inline/inline.js.map +1 -1
  240. package/lib/loading/loading.d.ts +3 -3
  241. package/lib/loading/loading.js +1 -1
  242. package/lib/loading/loading.js.map +1 -1
  243. package/lib/menu/menu.d.ts +1 -1
  244. package/lib/menu/menu.js +1 -1
  245. package/lib/menu/menu.js.map +1 -1
  246. package/lib/modal/modal-stories-components.d.ts +2 -2
  247. package/lib/modal/modal.d.ts +4 -4
  248. package/lib/modal/modal.js +1 -1
  249. package/lib/modal/modal.js.map +1 -1
  250. package/lib/notice/notice.d.ts +1 -1
  251. package/lib/notice/notice.js +1 -1
  252. package/lib/notice/notice.js.map +1 -1
  253. package/lib/password-field/password-field.js +1 -1
  254. package/lib/password-field/password-field.js.map +1 -1
  255. package/lib/prose/prose.js +1 -1
  256. package/lib/prose/prose.js.map +1 -1
  257. package/lib/select-field/select-field.js +1 -1
  258. package/lib/select-field/select-field.js.map +1 -1
  259. package/lib/spinner/spinner.js +1 -1
  260. package/lib/spinner/spinner.js.map +1 -1
  261. package/lib/stack/stack.d.ts +1 -1
  262. package/lib/stack/stack.js +1 -1
  263. package/lib/stack/stack.js.map +1 -1
  264. package/lib/switch-field/switch-field.js +1 -1
  265. package/lib/switch-field/switch-field.js.map +1 -1
  266. package/lib/tabs/tabs.d.ts +5 -6
  267. package/lib/tabs/tabs.js +1 -1
  268. package/lib/tabs/tabs.js.map +1 -1
  269. package/lib/text/text.d.ts +1 -1
  270. package/lib/text/text.js +1 -1
  271. package/lib/text/text.js.map +1 -1
  272. package/lib/text-area/text-area.js +1 -1
  273. package/lib/text-area/text-area.js.map +1 -1
  274. package/lib/text-field/text-field.d.ts +1 -1
  275. package/lib/text-field/text-field.js +1 -1
  276. package/lib/text-field/text-field.js.map +1 -1
  277. package/lib/text-link/text-link.d.ts +1 -1
  278. package/lib/text-link/text-link.js +1 -1
  279. package/lib/text-link/text-link.js.map +1 -1
  280. package/lib/toast/static-toast.d.ts +2 -2
  281. package/lib/toast/static-toast.js +1 -1
  282. package/lib/toast/static-toast.js.map +1 -1
  283. package/lib/toast/toast-animation.d.ts +1 -1
  284. package/lib/toast/toast-animation.js.map +1 -1
  285. package/lib/toast/use-toasts.d.ts +3 -3
  286. package/lib/toast/use-toasts.js +1 -1
  287. package/lib/toast/use-toasts.js.map +1 -1
  288. package/lib/tooltip/tooltip.js +1 -1
  289. package/lib/tooltip/tooltip.js.map +1 -1
  290. package/lib/utils/common-helpers.js +1 -1
  291. package/lib/utils/common-helpers.js.map +1 -1
  292. package/lib/utils/common-types.d.ts +8 -8
  293. package/lib/utils/polymorphism.d.ts +9 -9
  294. package/lib/utils/polymorphism.js +1 -1
  295. package/lib/utils/polymorphism.js.map +1 -1
  296. package/lib/utils/responsive-props.d.ts +3 -3
  297. package/lib/utils/responsive-props.js.map +1 -1
  298. package/lib/utils/test-helpers.d.ts +1 -1
  299. package/package.json +13 -7
  300. package/lib/alert/alert.test.d.ts +0 -1
  301. package/lib/avatar/avatar.test.d.ts +0 -1
  302. package/lib/avatar/utils.test.d.ts +0 -1
  303. package/lib/badge/badge.test.d.ts +0 -1
  304. package/lib/banner/banner.test.d.ts +0 -1
  305. package/lib/box/box.test.d.ts +0 -1
  306. package/lib/button/button.test.d.ts +0 -1
  307. package/lib/checkbox-field/checkbox-field.test.d.ts +0 -1
  308. package/lib/columns/columns.test.d.ts +0 -1
  309. package/lib/components/color-picker/color-picker.test.d.ts +0 -1
  310. package/lib/components/deprecated-button/deprecated-button.test.d.ts +0 -1
  311. package/lib/components/deprecated-dropdown/dropdown.test.d.ts +0 -1
  312. package/lib/components/deprecated-input/input.test.d.ts +0 -1
  313. package/lib/components/deprecated-select/select.test.d.ts +0 -1
  314. package/lib/components/key-capturer/key-capturer.test.d.ts +0 -1
  315. package/lib/components/keyboard-shortcut/keyboard-shortcut.test.d.ts +0 -1
  316. package/lib/components/progress-bar/progress-bar.test.d.ts +0 -1
  317. package/lib/components/time/time-utils.test.d.ts +0 -1
  318. package/lib/components/time/time.test.d.ts +0 -1
  319. package/lib/heading/heading.test.d.ts +0 -1
  320. package/lib/hidden/hidden.test.d.ts +0 -1
  321. package/lib/hidden-visually/hidden-visually.test.d.ts +0 -1
  322. package/lib/inline/inline.test.d.ts +0 -1
  323. package/lib/loading/loading.test.d.ts +0 -1
  324. package/lib/menu/menu.test.d.ts +0 -1
  325. package/lib/modal/modal.test.d.ts +0 -1
  326. package/lib/notice/notice.test.d.ts +0 -1
  327. package/lib/password-field/password-field.test.d.ts +0 -1
  328. package/lib/prose/prose.test.d.ts +0 -1
  329. package/lib/select-field/select-field.test.d.ts +0 -1
  330. package/lib/stack/stack.test.d.ts +0 -1
  331. package/lib/switch-field/switch-field.test.d.ts +0 -1
  332. package/lib/tabs/tabs.test.d.ts +0 -1
  333. package/lib/text/text.test.d.ts +0 -1
  334. package/lib/text-area/text-area.test.d.ts +0 -1
  335. package/lib/text-field/text-field.test.d.ts +0 -1
  336. package/lib/toast/toast.test.d.ts +0 -1
  337. package/lib/tooltip/tooltip.test.d.ts +0 -1
  338. package/styles/color-picker.css +0 -9
  339. package/styles/deprecated-button.css +0 -7
  340. package/styles/dropdown.css +0 -8
  341. package/styles/progress-bar.css +0 -7
  342. package/styles/select.css +0 -1
  343. package/styles/time.css +0 -7
  344. /package/styles/{input.css → index.css} +0 -0
  345. /package/styles/{spinner.module.css.css → spinner.css} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"text-area.js","sources":["../../src/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMergeRefs } from 'use-callback-ref'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ninterface TextAreaProps extends FieldComponentProps<HTMLTextAreaElement>, BaseFieldVariantProps {\n /**\n * The number of visible text lines for the text area.\n *\n * If it is specified, it must be a positive integer. If it is not specified, the default\n * value is 2 (set by the browser).\n *\n * When `autoExpand` is true, this value serves the purpose of specifying the minimum number\n * of rows that the textarea will shrink to when the content is not large enough to make it\n * expand.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows\n */\n rows?: number\n\n /**\n * If `true`, the textarea will auto-expand or shrink vertically to fit the content.\n */\n autoExpand?: boolean\n}\n\nconst TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n rows,\n autoExpand = false,\n ...props\n },\n ref,\n) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const internalRef = React.useRef<HTMLTextAreaElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n React.useEffect(\n function setupAutoExpand() {\n const containerElement = containerRef.current\n\n function handleAutoExpand(value: string) {\n if (containerElement) {\n containerElement.dataset.replicatedValue = value\n }\n }\n\n function handleInput(event: Event) {\n handleAutoExpand((event.currentTarget as HTMLTextAreaElement).value)\n }\n\n const textAreaElement = internalRef.current\n if (!textAreaElement || !autoExpand) {\n return undefined\n }\n\n // Apply change initially, in case the text area has a non-empty initial value\n handleAutoExpand(textAreaElement.value)\n\n textAreaElement.addEventListener('input', handleInput)\n return () => textAreaElement.removeEventListener('input', handleInput)\n },\n [autoExpand],\n )\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n className={[\n styles.textAreaContainer,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box\n width=\"full\"\n display=\"flex\"\n className={styles.innerContainer}\n ref={containerRef}\n >\n <textarea\n {...props}\n {...extraProps}\n ref={combinedRef}\n rows={rows}\n className={autoExpand ? styles.autoExpand : undefined}\n />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","React","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","hidden","ariaDescribedBy","rows","autoExpand","props","containerRef","internalRef","combinedRef","useMergeRefs","setupAutoExpand","containerElement","current","handleAutoExpand","value","dataset","replicatedValue","handleInput","event","currentTarget","textAreaElement","undefined","addEventListener","removeEventListener","BaseField","className","styles","textAreaContainer","error","bordered","extraProps","Box","width","display","innerContainer"],"mappings":";;;;;;;;MA2BMA,QAAQ,gBAAGC,UAAA,CAAqD,SAASD,QAAT,OAiBlEE,GAjBkE;MAClE;IACIC,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;IASIC,QATJ;IAUIC,MAVJ;IAWI,oBAAoBC,eAXxB;IAYIC,IAZJ;IAaIC,UAAU,GAAG;;MACVC;;EAIP,MAAMC,YAAY,GAAGhB,MAAA,CAA6B,IAA7B,CAArB;EACA,MAAMiB,WAAW,GAAGjB,MAAA,CAAkC,IAAlC,CAApB;EACA,MAAMkB,WAAW,GAAGC,YAAY,CAAC,CAAClB,GAAD,EAAMgB,WAAN,CAAD,CAAhC;EAEAjB,SAAA,CACI,SAASoB,eAAT;IACI,MAAMC,gBAAgB,GAAGL,YAAY,CAACM,OAAtC;;IAEA,SAASC,gBAAT,CAA0BC,KAA1B;MACI,IAAIH,gBAAJ,EAAsB;QAClBA,gBAAgB,CAACI,OAAjB,CAAyBC,eAAzB,GAA2CF,KAA3C;;;;IAIR,SAASG,WAAT,CAAqBC,KAArB;MACIL,gBAAgB,CAAEK,KAAK,CAACC,aAAN,CAA4CL,KAA9C,CAAhB;;;IAGJ,MAAMM,eAAe,GAAGb,WAAW,CAACK,OAApC;;IACA,IAAI,CAACQ,eAAD,IAAoB,CAAChB,UAAzB,EAAqC;MACjC,OAAOiB,SAAP;;;;IAIJR,gBAAgB,CAACO,eAAe,CAACN,KAAjB,CAAhB;IAEAM,eAAe,CAACE,gBAAhB,CAAiC,OAAjC,EAA0CL,WAA1C;IACA,OAAO,MAAMG,eAAe,CAACG,mBAAhB,CAAoC,OAApC,EAA6CN,WAA7C,CAAb;GAvBR,EAyBI,CAACb,UAAD,CAzBJ;EA4BA,oBACId,aAAA,CAACkC,SAAD;IACIhC,OAAO,EAAEA;IACTC,EAAE,EAAEA;IACJC,KAAK,EAAEA;IACPC,cAAc,EAAEA;IAChBC,cAAc,EAAEA;IAChBC,IAAI,EAAEA;IACNC,OAAO,EAAEA;IACTC,IAAI,EAAEA;IACNE,MAAM,EAAEA;wBACUC;IAClBuB,SAAS,EAAE,CACPC,MAAM,CAACC,iBADA,EAEP5B,IAAI,KAAK,OAAT,GAAmB2B,MAAM,CAACE,KAA1B,GAAkC,IAF3B,EAGPpC,OAAO,KAAK,UAAZ,GAAyBkC,MAAM,CAACG,QAAhC,GAA2C,IAHpC;IAKX7B,QAAQ,EAAEA;GAhBd,EAkBM8B,UAAD,iBACGxC,aAAA,CAACyC,GAAD;IACIC,KAAK,EAAC;IACNC,OAAO,EAAC;IACRR,SAAS,EAAEC,MAAM,CAACQ;IAClB3C,GAAG,EAAEe;GAJT,eAMIhB,aAAA,WAAA,mDACQe,KADR,GAEQyB,UAFR;IAGIvC,GAAG,EAAEiB,WAHT;IAIIL,IAAI,EAAEA,IAJV;IAKIsB,SAAS,EAAErB,UAAU,GAAGsB,MAAM,CAACtB,UAAV,GAAuBiB;KAXpD,CAnBR,CADJ;AAqCH,CAxFgB;;;;"}
1
+ {"version":3,"file":"text-area.js","sources":["../../src/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMergeRefs } from 'use-callback-ref'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ninterface TextAreaProps extends FieldComponentProps<HTMLTextAreaElement>, BaseFieldVariantProps {\n /**\n * The number of visible text lines for the text area.\n *\n * If it is specified, it must be a positive integer. If it is not specified, the default\n * value is 2 (set by the browser).\n *\n * When `autoExpand` is true, this value serves the purpose of specifying the minimum number\n * of rows that the textarea will shrink to when the content is not large enough to make it\n * expand.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows\n */\n rows?: number\n\n /**\n * If `true`, the textarea will auto-expand or shrink vertically to fit the content.\n */\n autoExpand?: boolean\n}\n\nconst TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n rows,\n autoExpand = false,\n ...props\n },\n ref,\n) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const internalRef = React.useRef<HTMLTextAreaElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n React.useEffect(\n function setupAutoExpand() {\n const containerElement = containerRef.current\n\n function handleAutoExpand(value: string) {\n if (containerElement) {\n containerElement.dataset.replicatedValue = value\n }\n }\n\n function handleInput(event: Event) {\n handleAutoExpand((event.currentTarget as HTMLTextAreaElement).value)\n }\n\n const textAreaElement = internalRef.current\n if (!textAreaElement || !autoExpand) {\n return undefined\n }\n\n // Apply change initially, in case the text area has a non-empty initial value\n handleAutoExpand(textAreaElement.value)\n\n textAreaElement.addEventListener('input', handleInput)\n return () => textAreaElement.removeEventListener('input', handleInput)\n },\n [autoExpand],\n )\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n className={[\n styles.textAreaContainer,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box\n width=\"full\"\n display=\"flex\"\n className={styles.innerContainer}\n ref={containerRef}\n >\n <textarea\n {...props}\n {...extraProps}\n ref={combinedRef}\n rows={rows}\n className={autoExpand ? styles.autoExpand : undefined}\n />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","React","forwardRef","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","hidden","ariaDescribedBy","rows","autoExpand","props","containerRef","useRef","internalRef","combinedRef","useMergeRefs","useEffect","setupAutoExpand","containerElement","current","handleAutoExpand","value","dataset","replicatedValue","handleInput","event","currentTarget","textAreaElement","undefined","addEventListener","removeEventListener","createElement","BaseField","className","styles","textAreaContainer","error","bordered","extraProps","Box","width","display","innerContainer","_objectSpread"],"mappings":";;;;;;;;AA2BMA,MAAAA,QAAQ,gBAAGC,KAAK,CAACC,UAAN,CAAqD,SAASF,QAAT,CAiBlEG,IAAAA,EAAAA,GAjBkE,EAiB/D;EAAA,IAhBH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;IASIC,QATJ;IAUIC,MAVJ;AAWI,IAAA,kBAAA,EAAoBC,eAXxB;IAYIC,IAZJ;AAaIC,IAAAA,UAAU,GAAG,KAAA;GAGd,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,YAAY,GAAGjB,KAAK,CAACkB,MAAN,CAA6B,IAA7B,CAArB,CAAA;AACA,EAAA,MAAMC,WAAW,GAAGnB,KAAK,CAACkB,MAAN,CAAkC,IAAlC,CAApB,CAAA;EACA,MAAME,WAAW,GAAGC,YAAY,CAAC,CAACnB,GAAD,EAAMiB,WAAN,CAAD,CAAhC,CAAA;AAEAnB,EAAAA,KAAK,CAACsB,SAAN,CACI,SAASC,eAAT,GAAwB;AACpB,IAAA,MAAMC,gBAAgB,GAAGP,YAAY,CAACQ,OAAtC,CAAA;;IAEA,SAASC,gBAA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AEA,QAAAA;GAhBd,EAkBMiC,UAAD,iBACG5C,KAAC,CAAAqC,aAAD,CAACQ,GAAD,EACI;AAAAC,IAAAA,KAAK,EAAC,MAAN;AACAC,IAAAA,OAAO,EAAC,MADR;IAEAR,SAAS,EAAEC,gBAAM,CAACQ,cAFlB;AAGA9C,IAAAA,GAAG,EAAEe,YAAAA;GAJT,eAMIjB,KAAA,CAAAqC,aAAA,CAAA,UAAA,EAAAY,cAAA,CAAAA,cAAA,CAAAA,cAAA,CAAA,EAAA,EACQjC,KADR,CAAA,EAEQ4B,UAFR,CAAA,EAAA,EAAA,EAAA;AAGI1C,IAAAA,GAAG,EAAEkB,WAHT;AAIIN,IAAAA,IAAI,EAAEA,IAJV;AAKIyB,IAAAA,SAAS,EAAExB,UAAU,GAAGyB,gBAAM,CAACzB,UAAV,GAAuBmB,SAAAA;AALhD,GAAA,CAAA,CANJ,CAnBR,CADJ,CAAA;AAqCH,CAxFgB;;;;"}
@@ -1,4 +1,4 @@
1
1
  var modules_2728c236 = {"textAreaContainer":"_55ccf266","innerContainer":"_89bb7098","bordered":"_02a47358","error":"_704ff540","autoExpand":"_145ca8f0"};
2
2
 
3
- export default modules_2728c236;
3
+ export { modules_2728c236 as default };
4
4
  //# sourceMappingURL=text-area.module.css.js.map
@@ -1,12 +1,12 @@
1
1
  import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { forwardRef, useRef, createElement } from 'react';
3
- import { Box } from '../box/box.js';
2
+ import * as React from 'react';
4
3
  import { BaseField } from '../base-field/base-field.js';
5
- import styles from './text-field.module.css.js';
4
+ import { Box } from '../box/box.js';
5
+ import modules_aaf25250 from './text-field.module.css.js';
6
6
  import { useMergeRefs } from 'use-callback-ref';
7
7
 
8
8
  const _excluded = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "type", "maxWidth", "hidden", "aria-describedby", "startSlot", "endSlot"];
9
- const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
9
+ const TextField = /*#__PURE__*/React.forwardRef(function TextField(_ref, ref) {
10
10
  let {
11
11
  variant = 'default',
12
12
  id,
@@ -25,7 +25,7 @@ const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
25
25
  } = _ref,
26
26
  props = _objectWithoutProperties(_ref, _excluded);
27
27
 
28
- const internalRef = useRef(null);
28
+ const internalRef = React.useRef(null);
29
29
  const combinedRef = useMergeRefs([ref, internalRef]);
30
30
 
31
31
  function handleClick(event) {
@@ -35,7 +35,7 @@ const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
35
35
  (_internalRef$current = internalRef.current) == null ? void 0 : _internalRef$current.focus();
36
36
  }
37
37
 
38
- return /*#__PURE__*/createElement(BaseField, {
38
+ return /*#__PURE__*/React.createElement(BaseField, {
39
39
  variant: variant,
40
40
  id: id,
41
41
  label: label,
@@ -47,21 +47,21 @@ const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
47
47
  maxWidth: maxWidth,
48
48
  hidden: hidden,
49
49
  "aria-describedby": ariaDescribedBy
50
- }, extraProps => /*#__PURE__*/createElement(Box, {
50
+ }, extraProps => /*#__PURE__*/React.createElement(Box, {
51
51
  display: "flex",
52
52
  alignItems: "center",
53
- className: [styles.inputWrapper, tone === 'error' ? styles.error : null, variant === 'bordered' ? styles.bordered : null],
53
+ className: [modules_aaf25250.inputWrapper, tone === 'error' ? modules_aaf25250.error : null, variant === 'bordered' ? modules_aaf25250.bordered : null],
54
54
  onClick: handleClick
55
- }, startSlot ? /*#__PURE__*/createElement(Box, {
56
- className: styles.slot,
55
+ }, startSlot ? /*#__PURE__*/React.createElement(Box, {
56
+ className: modules_aaf25250.slot,
57
57
  display: "flex",
58
58
  marginRight: variant === 'bordered' ? 'xsmall' : '-xsmall',
59
59
  marginLeft: variant === 'bordered' ? '-xsmall' : 'xsmall'
60
- }, startSlot) : null, /*#__PURE__*/createElement("input", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
60
+ }, startSlot) : null, /*#__PURE__*/React.createElement("input", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
61
61
  type: type,
62
62
  ref: combinedRef
63
- })), endSlot ? /*#__PURE__*/createElement(Box, {
64
- className: styles.slot,
63
+ })), endSlot ? /*#__PURE__*/React.createElement(Box, {
64
+ className: modules_aaf25250.slot,
65
65
  display: "flex",
66
66
  marginRight: variant === 'bordered' ? '-xsmall' : 'xsmall',
67
67
  marginLeft: variant === 'bordered' ? 'xsmall' : '-xsmall'
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.js","sources":["../../src/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\nimport { useMergeRefs } from 'use-callback-ref'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ninterface TextFieldProps\n extends Omit<FieldComponentProps<HTMLInputElement>, 'type'>,\n BaseFieldVariantProps {\n type?: TextFieldType\n startSlot?: React.ReactElement | string | number\n endSlot?: React.ReactElement | string | number\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n startSlot,\n endSlot,\n ...props\n },\n ref,\n) {\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n function handleClick(event: React.MouseEvent) {\n if (event.currentTarget === combinedRef.current) return\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.inputWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n onClick={handleClick}\n >\n {startSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n marginLeft={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n >\n {startSlot}\n </Box>\n ) : null}\n <input {...props} {...extraProps} type={type} ref={combinedRef} />\n {endSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n marginLeft={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n >\n {endSlot}\n </Box>\n ) : null}\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","type","maxWidth","hidden","ariaDescribedBy","startSlot","endSlot","props","internalRef","combinedRef","useMergeRefs","handleClick","event","currentTarget","current","focus","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","error","bordered","onClick","slot","marginRight","marginLeft"],"mappings":";;;;;;;;MAiBMA,SAAS,gBAAGC,UAAA,CAAmD,SAASD,SAAT,OAkBjEE,GAlBiE;MACjE;IACIC,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;IASIC,IAAI,GAAG,MATX;IAUIC,QAVJ;IAWIC,MAXJ;IAYI,oBAAoBC,eAZxB;IAaIC,SAbJ;IAcIC;;MACGC;;EAIP,MAAMC,WAAW,GAAGjB,MAAA,CAA+B,IAA/B,CAApB;EACA,MAAMkB,WAAW,GAAGC,YAAY,CAAC,CAAClB,GAAD,EAAMgB,WAAN,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AEpC,OAAO,KAAK,UAAZ,GAAyB,QAAzB,GAAoC;GAJpD,EAMKa,OANL,CADI,GASJ,IA9BR,CAdR,CADJ;AAkDH,CA9EiB;;;;"}
1
+ {"version":3,"file":"text-field.js","sources":["../../src/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\nimport { useMergeRefs } from 'use-callback-ref'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ninterface TextFieldProps\n extends Omit<FieldComponentProps<HTMLInputElement>, 'type'>,\n BaseFieldVariantProps {\n type?: TextFieldType\n startSlot?: React.ReactElement | string | number\n endSlot?: React.ReactElement | string | number\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n startSlot,\n endSlot,\n ...props\n },\n ref,\n) {\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n function handleClick(event: React.MouseEvent) {\n if (event.currentTarget === combinedRef.current) return\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.inputWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n onClick={handleClick}\n >\n {startSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n marginLeft={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n >\n {startSlot}\n </Box>\n ) : null}\n <input {...props} {...extraProps} type={type} ref={combinedRef} />\n {endSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n marginLeft={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n >\n {endSlot}\n </Box>\n ) : null}\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","forwardRef","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","type","maxWidth","hidden","ariaDescribedBy","startSlot","endSlot","props","internalRef","useRef","combinedRef","useMergeRefs","handleClick","event","currentTarget","current","focus","createElement","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","error","bordered","onClick","slot","marginRight","marginLeft"],"mappings":";;;;;;;;AAiBMA,MAAAA,SAAS,gBAAGC,KAAK,CAACC,UAAN,CAAmD,SAASF,SAAT,CAkBjEG,IAAAA,EAAAA,GAlBiE,EAkB9D;EAAA,IAjBH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;AASIC,IAAAA,IAAI,GAAG,MATX;IAUIC,QAVJ;IAWIC,MAXJ;AAYI,IAAA,kBAAA,EAAoBC,eAZxB;IAaIC,SAbJ;AAcIC,IAAAA,OAAAA;GAGD,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,WAAW,GAAGlB,KAAK,CAACmB,MAAN,CAA+B,IAA/B,CAApB,CAAA;EACA,MAAMC,WAAW,GAAGC,YAAY,CAAC,CAACnB,GAAD,EAAMgB,WAAN,CAAD,CAAhC,CAAA;;EAEA,SAASI,WAAT,CAAqBC,KAArB,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C,IAAAA,UAAU,EAAEtC,OAAO,KAAK,UAAZ,GAAyB,SAAzB,GAAqC,QAAA;AAJjD,GAAJ,EAMKY,SANL,CADM,GASN,IAnBR,eAoBIf,KAAW,CAAA2B,aAAX,CAAW,OAAX,EAAWV,cAAAA,CAAAA,cAAAA,CAAAA,cAAAA,CAAAA,EAAAA,EAAAA,KAAX,GAAsBY,UAAtB,CAAA,EAAA,EAAA,EAAA;AAAkClB,IAAAA,IAAI,EAAEA,IAAxC;AAA8CT,IAAAA,GAAG,EAAEkB,WAAAA;GApBvD,CAAA,CAAA,EAqBKJ,OAAO,gBACJhB,KAAA,CAAA2B,aAAA,CAACG,GAAD,EAAI;IACAG,SAAS,EAAEC,gBAAM,CAACK,IADlB;AAEAR,IAAAA,OAAO,EAAC,MAFR;AAGAS,IAAAA,WAAW,EAAErC,OAAO,KAAK,UAAZ,GAAyB,SAAzB,GAAqC,QAHlD;AAIAsC,IAAAA,UAAU,EAAEtC,OAAO,KAAK,UAAZ,GAAyB,QAAzB,GAAoC,SAAA;AAJhD,GAAJ,EAMKa,OANL,CADI,GASJ,IA9BR,CAdR,CADJ,CAAA;AAkDH,CA9EiB;;;;"}
@@ -1,4 +1,4 @@
1
1
  var modules_aaf25250 = {"inputWrapper":"dea25485","bordered":"_80b6b376","error":"_1a32867a","slot":"dbbd207e"};
2
2
 
3
- export default modules_aaf25250;
3
+ export { modules_aaf25250 as default };
4
4
  //# sourceMappingURL=text-field.module.css.js.map
@@ -1,8 +1,8 @@
1
1
  import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { createElement } from 'react';
3
- import { polymorphicComponent } from '../utils/polymorphism.js';
2
+ import * as React from 'react';
4
3
  import { Box } from '../box/box.js';
5
- import styles from './text-link.module.css.js';
4
+ import { polymorphicComponent } from '../utils/polymorphism.js';
5
+ import modules_3d05deee from './text-link.module.css.js';
6
6
 
7
7
  const _excluded = ["as", "openInNewTab", "exceptionallySetClassName"];
8
8
  const TextLink = /*#__PURE__*/polymorphicComponent(function TextLink(_ref, ref) {
@@ -13,10 +13,10 @@ const TextLink = /*#__PURE__*/polymorphicComponent(function TextLink(_ref, ref)
13
13
  } = _ref,
14
14
  props = _objectWithoutProperties(_ref, _excluded);
15
15
 
16
- return /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
16
+ return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
17
17
  as: as,
18
18
  display: "inline",
19
- className: [exceptionallySetClassName, styles.container],
19
+ className: [exceptionallySetClassName, modules_3d05deee.container],
20
20
  ref: ref,
21
21
  target: openInNewTab ? '_blank' : undefined,
22
22
  rel: openInNewTab ? 'noopener noreferrer' : undefined
@@ -1 +1 @@
1
- {"version":3,"file":"text-link.js","sources":["../../src/text-link/text-link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../utils/polymorphism'\nimport styles from './text-link.module.css'\nimport type { OpenInNewTab } from '../utils/common-types'\n\ntype TextLinkProps = OpenInNewTab\n\nconst TextLink = polymorphicComponent<'a', TextLinkProps>(function TextLink(\n { as = 'a', openInNewTab = false, exceptionallySetClassName, ...props },\n ref,\n) {\n return (\n <Box\n {...props}\n as={as}\n display=\"inline\"\n className={[exceptionallySetClassName, styles.container]}\n ref={ref}\n target={openInNewTab ? '_blank' : undefined}\n rel={openInNewTab ? 'noopener noreferrer' : undefined}\n />\n )\n})\n\nexport { TextLink }\nexport type { TextLinkProps }\n"],"names":["TextLink","polymorphicComponent","ref","as","openInNewTab","exceptionallySetClassName","props","React","Box","display","className","styles","container","target","undefined","rel"],"mappings":";;;;;;;MAQMA,QAAQ,gBAAGC,oBAAoB,CAAqB,SAASD,QAAT,OAEtDE,GAFsD;MACtD;IAAEC,EAAE,GAAG,GAAP;IAAYC,YAAY,GAAG,KAA3B;IAAkCC;;MAA8BC;;EAGhE,oBACIC,aAAA,CAACC,GAAD,oCACQF,KADR;IAEIH,EAAE,EAAEA,EAFR;IAGIM,OAAO,EAAC,QAHZ;IAIIC,SAAS,EAAE,CAACL,yBAAD,EAA4BM,MAAM,CAACC,SAAnC,CAJf;IAKIV,GAAG,EAAEA,GALT;IAMIW,MAAM,EAAET,YAAY,GAAG,QAAH,GAAcU,SANtC;IAOIC,GAAG,EAAEX,YAAY,GAAG,qBAAH,GAA2BU;KARpD;AAWH,CAfoC;;;;"}
1
+ {"version":3,"file":"text-link.js","sources":["../../src/text-link/text-link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../utils/polymorphism'\nimport styles from './text-link.module.css'\nimport type { OpenInNewTab } from '../utils/common-types'\n\ntype TextLinkProps = OpenInNewTab\n\nconst TextLink = polymorphicComponent<'a', TextLinkProps>(function TextLink(\n { as = 'a', openInNewTab = false, exceptionallySetClassName, ...props },\n ref,\n) {\n return (\n <Box\n {...props}\n as={as}\n display=\"inline\"\n className={[exceptionallySetClassName, styles.container]}\n ref={ref}\n target={openInNewTab ? '_blank' : undefined}\n rel={openInNewTab ? 'noopener noreferrer' : undefined}\n />\n )\n})\n\nexport { TextLink }\nexport type { TextLinkProps }\n"],"names":["TextLink","polymorphicComponent","ref","as","openInNewTab","exceptionallySetClassName","props","React","createElement","Box","display","className","styles","container","target","undefined","rel"],"mappings":";;;;;;;AAQMA,MAAAA,QAAQ,gBAAGC,oBAAoB,CAAqB,SAASD,QAAT,CAAA,IAAA,EAEtDE,GAFsD,EAEnD;EAAA,IADH;AAAEC,IAAAA,EAAE,GAAG,GAAP;AAAYC,IAAAA,YAAY,GAAG,KAA3B;AAAkCC,IAAAA,yBAAAA;GAC/B,GAAA,IAAA;AAAA,MAD6DC,KAC7D,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,oBACIC,KAAC,CAAAC,aAAD,CAACC,GAAD,oCACQH,KADR,CAAA,EAAA,EAAA,EAAA;AAEIH,IAAAA,EAAE,EAAEA,EAFR;AAGIO,IAAAA,OAAO,EAAC,QAHZ;AAIIC,IAAAA,SAAS,EAAE,CAACN,yBAAD,EAA4BO,gBAAM,CAACC,SAAnC,CAJf;AAKIX,IAAAA,GAAG,EAAEA,GALT;AAMIY,IAAAA,MAAM,EAAEV,YAAY,GAAG,QAAH,GAAcW,SANtC;AAOIC,IAAAA,GAAG,EAAEZ,YAAY,GAAG,qBAAH,GAA2BW,SAAAA;GARpD,CAAA,CAAA,CAAA;AAWH,CAfoC;;;;"}
@@ -1,4 +1,4 @@
1
1
  var modules_3d05deee = {"container":"fdc181b3"};
2
2
 
3
- export default modules_3d05deee;
3
+ export { modules_3d05deee as default };
4
4
  //# sourceMappingURL=text-link.module.css.js.map
@@ -1,11 +1,11 @@
1
1
  import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import React__default from 'react';
3
+ import { CloseIcon } from '../icons/close-icon.js';
3
4
  import { Box } from '../box/box.js';
4
- import { Stack } from '../stack/stack.js';
5
5
  import { Button, IconButton } from '../button/button.js';
6
- import { CloseIcon } from '../icons/close-icon.js';
6
+ import { Stack } from '../stack/stack.js';
7
7
  import { Text } from '../text/text.js';
8
- import styles from './toast.module.css.js';
8
+ import modules_d11e18f0 from './toast.module.css.js';
9
9
 
10
10
  const _excluded = ["message", "description", "icon", "action", "onDismiss", "dismissLabel"];
11
11
  /**
@@ -44,7 +44,7 @@ const StaticToast = /*#__PURE__*/React__default.forwardRef(function Toast(_ref,
44
44
  display: "flex",
45
45
  padding: "large",
46
46
  alignItems: "center",
47
- className: styles.toastContainer
47
+ className: modules_d11e18f0.toastContainer
48
48
  }, props), icon ? /*#__PURE__*/React__default.createElement(ToastContentSlot, null, icon) : null, /*#__PURE__*/React__default.createElement(Box, {
49
49
  flexGrow: 1,
50
50
  maxWidth: "small"
@@ -78,7 +78,7 @@ function ToastContentSlot({
78
78
  justifyContent: "center",
79
79
  marginX: "-xsmall",
80
80
  marginY: "-medium",
81
- className: styles.slot
81
+ className: modules_d11e18f0.slot
82
82
  }, children);
83
83
  }
84
84
 
@@ -1 +1 @@
1
- {"version":3,"file":"static-toast.js","sources":["../../src/toast/static-toast.tsx"],"sourcesContent":["import React from 'react'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Box } from '../box'\nimport { IconButton, Button } from '../button'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\n\nimport styles from './toast.module.css'\n\ntype ToastActionObject = {\n label: string\n onClick: () => void\n}\n\ntype StaticToastProps = {\n /**\n * The message shown in the toast.\n */\n message: NonNullable<React.ReactNode>\n\n /**\n * An optional extra description that complements the main message shown in the toast.\n */\n description?: React.ReactNode\n\n /**\n * An icon to be shown in front of the message.\n */\n icon?: React.ReactNode\n\n /**\n * The action to call when the user clicks on the dismiss button. If omitted, the dismiss button\n * does not appear.\n */\n onDismiss?: () => void\n\n /**\n * The label for the button that dismisses the toast.\n */\n dismissLabel?: string\n\n /**\n * What to render in the action slot. Usually a button or link.\n *\n * You can also pass an object that containst the action label, and a function that performs the\n * action. This is used by the toast component to render a button for you.\n *\n * In general, you should prefer the action object most of the time. But it is possible to pass\n * a React element instead, if you need more control over what to render. For instance, you may\n * want to render a link instead of a button.\n *\n * Keep in mind, though, that the default button rendered uses `variant=\"tertiary\"` and\n * `size=\"small\"`. In most cases you should stick to the variants `tertiary` or `primary`, which\n * are the ones that look better in the toast's dark background. And in all cases you should use\n * size `small`.\n */\n action?: React.ReactElement | ToastActionObject\n}\n\n/**\n * A toast that shows a message, and an optional action associated with it.\n *\n * This component is generally not meant to be used directly. Most of the time you'll want to use\n * toasts generated via `useToasts` instead. However, this component is available in case you need\n * to take control of rendering a toast under different circumstances than that of notification-like\n * floating toasts.\n *\n * This component makes no assumptions outwardly about how it is positioned on the screen. That is,\n * it will not be shown floating or fixed to the viewport edges, as toasts normally show up. It only\n * provides the toast look and feel, but you are responsible for positioning it as you want.\n *\n * @see useToasts\n */\nconst StaticToast = React.forwardRef<HTMLDivElement, StaticToastProps>(function Toast(\n { message, description, icon, action, onDismiss, dismissLabel = 'Close', ...props },\n ref,\n) {\n return (\n <Box\n ref={ref}\n role=\"alert\"\n aria-live=\"polite\"\n borderRadius=\"full\"\n width=\"fitContent\"\n background=\"toast\"\n display=\"flex\"\n padding=\"large\"\n alignItems=\"center\"\n className={styles.toastContainer}\n {...props}\n >\n {icon ? <ToastContentSlot>{icon}</ToastContentSlot> : null}\n\n <Box flexGrow={1} maxWidth=\"small\">\n {description ? (\n <Stack space=\"small\">\n <Text weight=\"bold\">{message} </Text>\n <Text>{description}</Text>\n </Stack>\n ) : (\n <Text>{message}</Text>\n )}\n </Box>\n\n {action ? (\n <ToastContentSlot>\n {isActionObject(action) ? (\n <Button variant=\"tertiary\" size=\"small\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : (\n action\n )}\n </ToastContentSlot>\n ) : null}\n\n {onDismiss ? (\n <ToastContentSlot>\n <IconButton\n variant=\"quaternary\"\n size=\"small\"\n onClick={onDismiss}\n aria-label={dismissLabel}\n icon={<CloseIcon />}\n />\n </ToastContentSlot>\n ) : null}\n </Box>\n )\n})\n\nfunction isActionObject(action: StaticToastProps['action']): action is ToastActionObject {\n return (\n action != null &&\n typeof action === 'object' &&\n 'label' in action &&\n 'onClick' in action &&\n typeof action.label === 'string' &&\n typeof action.onClick === 'function'\n )\n}\n\nfunction ToastContentSlot({ children }: { children: React.ReactNode }) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n marginX=\"-xsmall\"\n marginY=\"-medium\"\n className={styles.slot}\n >\n {children}\n </Box>\n )\n}\n\nexport { StaticToast, isActionObject }\nexport type { StaticToastProps }\n"],"names":["StaticToast","React","forwardRef","Toast","ref","message","description","icon","action","onDismiss","dismissLabel","props","Box","role","borderRadius","width","background","display","padding","alignItems","className","styles","toastContainer","ToastContentSlot","flexGrow","maxWidth","Stack","space","Text","weight","isActionObject","Button","variant","size","onClick","label","IconButton","CloseIcon","children","justifyContent","marginX","marginY","slot"],"mappings":";;;;;;;;;;AA4DA;;;;;;;;;;;;;;;MAcMA,WAAW,gBAAGC,cAAK,CAACC,UAAN,CAAmD,SAASC,KAAT,OAEnEC,GAFmE;MACnE;IAAEC,OAAF;IAAWC,WAAX;IAAwBC,IAAxB;IAA8BC,MAA9B;IAAsCC,SAAtC;IAAiDC,YAAY,GAAG;;MAAYC;;EAG5E,oBACIV,4BAAA,CAACW,GAAD;IACIR,GAAG,EAAEA,GADT;IAEIS,IAAI,EAAC,OAFT;iBAGc,QAHd;IAIIC,YAAY,EAAC,MAJjB;IAKIC,KAAK,EAAC,YALV;IAMIC,UAAU,EAAC,OANf;IAOIC,OAAO,EAAC,MAPZ;IAQIC,OAAO,EAAC,OARZ;IASIC,UAAU,EAAC,QATf;IAUIC,SAAS,EAAEC,MAAM,CAACC;KACdX,KAXR,GAaKJ,IAAI,gBAAGN,4BAAA,CAACsB,gBAAD,MAAA,EAAmBhB,IAAnB,CAAH,GAAiD,IAb1D,eAeIN,4BAAA,CAACW,GAAD;IAAKY,QAAQ,EAAE;IAAGC,QAAQ,EAAC;GAA3B,EACKnB,WAAW,gBACRL,4BAAA,CAACyB,KAAD;IAAOC,KAAK,EAAC;GAAb,eACI1B,4BAAA,CAAC2B,IAAD;IAAMC,MAAM,EAAC;GAAb,EAAqBxB,OAArB,KAAA,CADJ,eAEIJ,4BAAA,CAAC2B,IAAD,MAAA,EAAOtB,WAAP,CAFJ,CADQ,gBAMRL,4BAAA,CAAC2B,IAAD,MAAA,EAAOvB,OAAP,CAPR,CAfJ,EA0BKG,MAAM,gBACHP,4BAAA,CAACsB,gBAAD,MAAA,EACKO,cAAc,CAACtB,MAAD,CAAd,gBACGP,4BAAA,CAAC8B,MAAD;IAAQC,OAAO,EAAC;IAAWC,IAAI,EAAC;IAAQC,OAAO,EAAE1B,MAAM,CAAC0B;GAAxD,EACK1B,MAAM,CAAC2B,KADZ,CADH,GAKG3B,MANR,CADG,GAUH,IApCR,EAsCKC,SAAS,gBACNR,4BAAA,CAACsB,gBAAD,MAAA,eACItB,4BAAA,CAACmC,UAAD;IACIJ,OAAO,EAAC;IACRC,IAAI,EAAC;IACLC,OAAO,EAAEzB;kBACGC;IACZH,IAAI,eAAEN,4BAAA,CAACoC,SAAD,MAAA;GALV,CADJ,CADM,GAUN,IAhDR,CADJ;AAoDH,CAxDmB;;AA0DpB,SAASP,cAAT,CAAwBtB,MAAxB;EACI,OACIA,MAAM,IAAI,IAAV,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEA,WAAWA,MAFX,IAGA,aAAaA,MAHb,IAIA,OAAOA,MAAM,CAAC2B,KAAd,KAAwB,QAJxB,IAKA,OAAO3B,MAAM,CAAC0B,OAAd,KAA0B,UAN9B;AAQH;;AAED,SAASX,gBAAT,CAA0B;EAAEe;AAAF,CAA1B;EACI,oBACIrC,4BAAA,CAACW,GAAD;IACIK,OAAO,EAAC;IACRE,UAAU,EAAC;IACXoB,cAAc,EAAC;IACfC,OAAO,EAAC;IACRC,OAAO,EAAC;IACRrB,SAAS,EAAEC,MAAM,CAACqB;GANtB,EAQKJ,QARL,CADJ;AAYH;;;;"}
1
+ {"version":3,"file":"static-toast.js","sources":["../../src/toast/static-toast.tsx"],"sourcesContent":["import React from 'react'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Box } from '../box'\nimport { IconButton, Button } from '../button'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\n\nimport styles from './toast.module.css'\n\ntype ToastActionObject = {\n label: string\n onClick: () => void\n}\n\ntype StaticToastProps = {\n /**\n * The message shown in the toast.\n */\n message: NonNullable<React.ReactNode>\n\n /**\n * An optional extra description that complements the main message shown in the toast.\n */\n description?: React.ReactNode\n\n /**\n * An icon to be shown in front of the message.\n */\n icon?: React.ReactNode\n\n /**\n * The action to call when the user clicks on the dismiss button. If omitted, the dismiss button\n * does not appear.\n */\n onDismiss?: () => void\n\n /**\n * The label for the button that dismisses the toast.\n */\n dismissLabel?: string\n\n /**\n * What to render in the action slot. Usually a button or link.\n *\n * You can also pass an object that containst the action label, and a function that performs the\n * action. This is used by the toast component to render a button for you.\n *\n * In general, you should prefer the action object most of the time. But it is possible to pass\n * a React element instead, if you need more control over what to render. For instance, you may\n * want to render a link instead of a button.\n *\n * Keep in mind, though, that the default button rendered uses `variant=\"tertiary\"` and\n * `size=\"small\"`. In most cases you should stick to the variants `tertiary` or `primary`, which\n * are the ones that look better in the toast's dark background. And in all cases you should use\n * size `small`.\n */\n action?: React.ReactElement | ToastActionObject\n}\n\n/**\n * A toast that shows a message, and an optional action associated with it.\n *\n * This component is generally not meant to be used directly. Most of the time you'll want to use\n * toasts generated via `useToasts` instead. However, this component is available in case you need\n * to take control of rendering a toast under different circumstances than that of notification-like\n * floating toasts.\n *\n * This component makes no assumptions outwardly about how it is positioned on the screen. That is,\n * it will not be shown floating or fixed to the viewport edges, as toasts normally show up. It only\n * provides the toast look and feel, but you are responsible for positioning it as you want.\n *\n * @see useToasts\n */\nconst StaticToast = React.forwardRef<HTMLDivElement, StaticToastProps>(function Toast(\n { message, description, icon, action, onDismiss, dismissLabel = 'Close', ...props },\n ref,\n) {\n return (\n <Box\n ref={ref}\n role=\"alert\"\n aria-live=\"polite\"\n borderRadius=\"full\"\n width=\"fitContent\"\n background=\"toast\"\n display=\"flex\"\n padding=\"large\"\n alignItems=\"center\"\n className={styles.toastContainer}\n {...props}\n >\n {icon ? <ToastContentSlot>{icon}</ToastContentSlot> : null}\n\n <Box flexGrow={1} maxWidth=\"small\">\n {description ? (\n <Stack space=\"small\">\n <Text weight=\"bold\">{message} </Text>\n <Text>{description}</Text>\n </Stack>\n ) : (\n <Text>{message}</Text>\n )}\n </Box>\n\n {action ? (\n <ToastContentSlot>\n {isActionObject(action) ? (\n <Button variant=\"tertiary\" size=\"small\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : (\n action\n )}\n </ToastContentSlot>\n ) : null}\n\n {onDismiss ? (\n <ToastContentSlot>\n <IconButton\n variant=\"quaternary\"\n size=\"small\"\n onClick={onDismiss}\n aria-label={dismissLabel}\n icon={<CloseIcon />}\n />\n </ToastContentSlot>\n ) : null}\n </Box>\n )\n})\n\nfunction isActionObject(action: StaticToastProps['action']): action is ToastActionObject {\n return (\n action != null &&\n typeof action === 'object' &&\n 'label' in action &&\n 'onClick' in action &&\n typeof action.label === 'string' &&\n typeof action.onClick === 'function'\n )\n}\n\nfunction ToastContentSlot({ children }: { children: React.ReactNode }) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n marginX=\"-xsmall\"\n marginY=\"-medium\"\n className={styles.slot}\n >\n {children}\n </Box>\n )\n}\n\nexport { StaticToast, isActionObject }\nexport type { StaticToastProps }\n"],"names":["StaticToast","React","forwardRef","Toast","ref","message","description","icon","action","onDismiss","dismissLabel","props","Box","_objectSpread","role","borderRadius","width","background","display","padding","alignItems","className","styles","toastContainer","createElement","ToastContentSlot","flexGrow","maxWidth","Stack","space","Text","weight","isActionObject","Button","variant","size","onClick","label","IconButton","CloseIcon","children","justifyContent","marginX","marginY","slot"],"mappings":";;;;;;;;;;AA4DA;;;;;;;;;;;;;AAaG;;AACGA,MAAAA,WAAW,gBAAGC,cAAK,CAACC,UAAN,CAAmD,SAASC,KAAT,CAEnEC,IAAAA,EAAAA,GAFmE,EAEhE;EAAA,IADH;IAAEC,OAAF;IAAWC,WAAX;IAAwBC,IAAxB;IAA8BC,MAA9B;IAAsCC,SAAtC;AAAiDC,IAAAA,YAAY,GAAG,OAAA;GAC7D,GAAA,IAAA;AAAA,MADyEC,KACzE,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,oBACIV,4BAAA,CAACW,GAAD,EAAAC,cAAA,CAAA;AACIT,IAAAA,GAAG,EAAEA,GADT;AAEIU,IAAAA,IAAI,EAAC,OAFT;AAGc,IAAA,WAAA,EAAA,QAHd;AAIIC,IA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AACPJ,IAAAA,OAAO,EAAC,YADD;AAEPC,IAAAA,IAAI,EAAC,OAFE;AAGPC,IAAAA,OAAO,EAAE3B,SAHF;AAIK,IAAA,YAAA,EAAAC,YAJL;AAKPH,IAAAA,IAAI,eAAEN,cAAA,CAAAuB,aAAA,CAACe,SAAD,EAAU,IAAV,CAAA;AALC,GAAX,CADJ,CADM,GAUN,IAhDR,CADJ,CAAA;AAoDH,CAxDmB,EAApB;;AA0DA,SAASP,cAAT,CAAwBxB,MAAxB,EAA0D;EACtD,OACIA,MAAM,IAAI,IAAV,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEA,OAAWA,IAAAA,MAFX,IAGA,SAAA,IAAaA,MAHb,IAIA,OAAOA,MAAM,CAAC6B,KAAd,KAAwB,QAJxB,IAKA,OAAO7B,MAAM,CAAC4B,OAAd,KAA0B,UAN9B,CAAA;AAQH,CAAA;;AAED,SAASX,gBAAT,CAA0B;AAAEe,EAAAA,QAAAA;AAAF,CAA1B,EAAqE;AACjE,EAAA,oBACIvC,cAAA,CAAAuB,aAAA,CAACZ,GAAD,EAAI;AACAM,IAAAA,OAAO,EAAC,MADR;AAEAE,IAAAA,UAAU,EAAC,QAFX;AAGAqB,IAAAA,cAAc,EAAC,QAHf;AAIAC,IAAAA,OAAO,EAAC,SAJR;AAKAC,IAAAA,OAAO,EAAC,SALR;IAMAtB,SAAS,EAAEC,gBAAM,CAACsB,IAAAA;GANtB,EAQKJ,QARL,CADJ,CAAA;AAYH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"toast-animation.js","sources":["../../src/toast/toast-animation.ts"],"sourcesContent":["/**\n * Adapted with minor changes from https://github.com/seek-oss/braid-design-system/blob/7a5ebccb/packages/braid-design-system/lib/components/useToast/useFlipList.ts\n *\n * MIT License\n *\n * Copyright (c) 2018 SEEK\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { useMemo, useCallback, useLayoutEffect } from 'react'\n\nconst ANIMATION_TIMEOUT = 400\nconst ENTRANCE_TRANSITION = 'transform 0.3s ease, opacity 0.3s ease'\nconst EXIT_TRANSITION = 'opacity 0.2s ease'\n\ntype Transform = {\n property: 'opacity' | 'transform' | 'scale'\n from?: string\n to?: string\n}\n\n/**\n * Applies the \"from\" value of given CSS properties, and also sets a transition CSS property. Then\n * it waits an animation frame before setting the same CSS properties to the target \"to\" value. This\n * triggers the browser to perform the CSS transition on them.\n *\n * At the end of the animation, it cleans up, unsetting all the CSS properties (including the\n * transition), and calls the \"done\" callback, if given.\n */\nfunction animate({\n element,\n transforms,\n transition,\n done,\n}: {\n element: HTMLElement\n transforms: Transform[]\n transition: string\n done?: () => void\n}) {\n const fallbackTimeout = setTimeout(() => {\n done?.()\n }, ANIMATION_TIMEOUT)\n\n transforms.forEach(({ property, from = '' }) => {\n element.style.setProperty(property, from)\n })\n element.style.setProperty('transition', '')\n\n function transitionEndHandler(event: TransitionEvent) {\n if (event.target !== element) {\n return\n }\n element.style.setProperty('transition', '')\n done?.()\n element.removeEventListener('transitionend', transitionEndHandler)\n clearTimeout(fallbackTimeout)\n }\n\n element.addEventListener('transitionend', transitionEndHandler)\n\n // Call requestAnimationFrame twice to make sure we have a full animation frame at our disposal\n window.requestAnimationFrame(() => {\n window.requestAnimationFrame(() => {\n element.style.setProperty('transition', transition)\n transforms.forEach(({ property, to = '' }) => {\n element.style.setProperty(property, to)\n })\n })\n })\n}\n\ntype ToastsAnimationToolkit = {\n /**\n * Used for gathering all the active stacked toast elements. Should be used by passing\n * `ref={mappedRef(toastId)}` to the stacked toasts.\n */\n mappedRef: (toastId: string) => (ref: HTMLElement | null) => void\n\n /**\n * The stacked toasts view should use this callback when it needs to remove a toast, instead of\n * removing it right away. The actual removal from the state (and consequently, from the DOM)\n * should happen in the `onAnimationDone` instead.\n */\n animateRemove: (toastId: string, onAnimationDone: () => void) => void\n}\n\n/**\n * Provides the functionality of animating the stacked toasts when they appear and before they\n * disappear.\n *\n * It works by keeping a mapping from toast IDs to the toast elements, and keeping a mapping from\n * toast IDs to their top position. Then, on every single re-render, it compares the new DOM\n * situation with the previously stored one in these mappings. With this information, it applies\n * animations that smoothly transitions between both states.\n */\nfunction useToastsAnimation(): ToastsAnimationToolkit {\n const refs = useMemo(() => new Map<string, HTMLElement | null>(), [])\n const positions = useMemo(() => new Map<string, number>(), [])\n\n useLayoutEffect(() => {\n const animations: Array<{\n element: HTMLElement\n transforms: Transform[]\n transition: string\n }> = []\n\n Array.from(refs.entries()).forEach(([id, element]) => {\n if (!element) {\n refs.delete(id)\n return\n }\n\n const prevTop = positions.get(id)\n const { top, height } = element.getBoundingClientRect()\n\n if (typeof prevTop === 'number' && prevTop !== top) {\n // Move animation\n animations.push({\n element,\n transition: ENTRANCE_TRANSITION,\n transforms: [{ property: 'transform', from: `translateY(${prevTop - top}px)` }],\n })\n } else if (typeof prevTop !== 'number') {\n // Enter animation\n animations.push({\n element,\n transition: ENTRANCE_TRANSITION,\n transforms: [\n { property: 'transform', from: `translateY(${height}px)` },\n { property: 'opacity', from: '0' },\n ],\n })\n }\n\n positions.set(id, element.getBoundingClientRect().top)\n })\n\n animations.forEach(({ element, transforms, transition }) => {\n animate({ element, transforms, transition })\n })\n })\n\n const animateRemove = useCallback(\n function animateRemove(id: string, onAnimationDone: () => void) {\n const element = refs.get(id)\n if (element) {\n // Removal animation\n animate({\n element,\n transforms: [{ property: 'opacity', to: '0' }],\n transition: EXIT_TRANSITION,\n done: onAnimationDone,\n })\n }\n },\n [refs],\n )\n\n const mappedRef = useCallback(\n (id: string) => (ref: HTMLElement | null) => {\n refs.set(id, ref)\n },\n [refs],\n )\n\n return { mappedRef, animateRemove }\n}\n\nexport { ANIMATION_TIMEOUT, useToastsAnimation }\n"],"names":["ANIMATION_TIMEOUT","ENTRANCE_TRANSITION","EXIT_TRANSITION","animate","element","transforms","transition","done","fallbackTimeout","setTimeout","forEach","property","from","style","setProperty","transitionEndHandler","event","target","removeEventListener","clearTimeout","addEventListener","window","requestAnimationFrame","to","useToastsAnimation","refs","useMemo","Map","positions","useLayoutEffect","animations","Array","entries","id","delete","prevTop","get","top","height","getBoundingClientRect","push","set","animateRemove","useCallback","onAnimationDone","mappedRef","ref"],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;MA4BMA,iBAAiB,GAAG;AAC1B,MAAMC,mBAAmB,GAAG,wCAA5B;AACA,MAAMC,eAAe,GAAG,mBAAxB;AAQA;;;;;;;;;AAQA,SAASC,OAAT,CAAiB;EACbC,OADa;EAEbC,UAFa;EAGbC,UAHa;EAIbC;AAJa,CAAjB;EAWI,MAAMC,eAAe,GAAGC,UAAU,CAAC;IAC/BF,IAAI,QAAJ,YAAAA,IAAI;GAD0B,EAE/BP,iBAF+B,CAAlC;EAIAK,UAAU,CAACK,OAAX,CAAmB,CAAC;IAAEC,QAAF;IAAYC,IAAI,GAAG;GAApB;IACfR,OAAO,CAACS,KAAR,CAAcC,WAAd,CAA0BH,QAA1B,EAAoCC,IAApC;GADJ;EAGAR,OAAO,CAACS,KAAR,CAAcC,W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EAa7B,CAACnB,IAAD,CAb6B,CAAjC;EAgBA,MAAMoB,SAAS,GAAGF,WAAW,CACxBV,EAAD,IAAiBa,GAAD;IACZrB,IAAI,CAACgB,GAAL,CAASR,EAAT,EAAaa,GAAb;GAFqB,EAIzB,CAACrB,IAAD,CAJyB,CAA7B;EAOA,OAAO;IAAEoB,SAAF;IAAaH;GAApB;AACH;;;;"}
1
+ {"version":3,"file":"toast-animation.js","sources":["../../src/toast/toast-animation.ts"],"sourcesContent":["/**\n * Adapted with minor changes from https://github.com/seek-oss/braid-design-system/blob/7a5ebccb/packages/braid-design-system/lib/components/useToast/useFlipList.ts\n *\n * MIT License\n *\n * Copyright (c) 2018 SEEK\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { useMemo, useCallback, useLayoutEffect } from 'react'\n\nconst ANIMATION_TIMEOUT = 400\nconst ENTRANCE_TRANSITION = 'transform 0.3s ease, opacity 0.3s ease'\nconst EXIT_TRANSITION = 'opacity 0.2s ease'\n\ntype Transform = {\n property: 'opacity' | 'transform' | 'scale'\n from?: string\n to?: string\n}\n\n/**\n * Applies the \"from\" value of given CSS properties, and also sets a transition CSS property. Then\n * it waits an animation frame before setting the same CSS properties to the target \"to\" value. This\n * triggers the browser to perform the CSS transition on them.\n *\n * At the end of the animation, it cleans up, unsetting all the CSS properties (including the\n * transition), and calls the \"done\" callback, if given.\n */\nfunction animate({\n element,\n transforms,\n transition,\n done,\n}: {\n element: HTMLElement\n transforms: Transform[]\n transition: string\n done?: () => void\n}) {\n const fallbackTimeout = setTimeout(() => {\n done?.()\n }, ANIMATION_TIMEOUT)\n\n transforms.forEach(({ property, from = '' }) => {\n element.style.setProperty(property, from)\n })\n element.style.setProperty('transition', '')\n\n function transitionEndHandler(event: TransitionEvent) {\n if (event.target !== element) {\n return\n }\n element.style.setProperty('transition', '')\n done?.()\n element.removeEventListener('transitionend', transitionEndHandler)\n clearTimeout(fallbackTimeout)\n }\n\n element.addEventListener('transitionend', transitionEndHandler)\n\n // Call requestAnimationFrame twice to make sure we have a full animation frame at our disposal\n window.requestAnimationFrame(() => {\n window.requestAnimationFrame(() => {\n element.style.setProperty('transition', transition)\n transforms.forEach(({ property, to = '' }) => {\n element.style.setProperty(property, to)\n })\n })\n })\n}\n\ntype ToastsAnimationToolkit = {\n /**\n * Used for gathering all the active stacked toast elements. Should be used by passing\n * `ref={mappedRef(toastId)}` to the stacked toasts.\n */\n mappedRef: (toastId: string) => (ref: HTMLElement | null) => void\n\n /**\n * The stacked toasts view should use this callback when it needs to remove a toast, instead of\n * removing it right away. The actual removal from the state (and consequently, from the DOM)\n * should happen in the `onAnimationDone` instead.\n */\n animateRemove: (toastId: string, onAnimationDone: () => void) => void\n}\n\n/**\n * Provides the functionality of animating the stacked toasts when they appear and before they\n * disappear.\n *\n * It works by keeping a mapping from toast IDs to the toast elements, and keeping a mapping from\n * toast IDs to their top position. Then, on every single re-render, it compares the new DOM\n * situation with the previously stored one in these mappings. With this information, it applies\n * animations that smoothly transitions between both states.\n */\nfunction useToastsAnimation(): ToastsAnimationToolkit {\n const refs = useMemo(() => new Map<string, HTMLElement | null>(), [])\n const positions = useMemo(() => new Map<string, number>(), [])\n\n useLayoutEffect(() => {\n const animations: Array<{\n element: HTMLElement\n transforms: Transform[]\n transition: string\n }> = []\n\n Array.from(refs.entries()).forEach(([id, element]) => {\n if (!element) {\n refs.delete(id)\n return\n }\n\n const prevTop = positions.get(id)\n const { top, height } = element.getBoundingClientRect()\n\n if (typeof prevTop === 'number' && prevTop !== top) {\n // Move animation\n animations.push({\n element,\n transition: ENTRANCE_TRANSITION,\n transforms: [{ property: 'transform', from: `translateY(${prevTop - top}px)` }],\n })\n } else if (typeof prevTop !== 'number') {\n // Enter animation\n animations.push({\n element,\n transition: ENTRANCE_TRANSITION,\n transforms: [\n { property: 'transform', from: `translateY(${height}px)` },\n { property: 'opacity', from: '0' },\n ],\n })\n }\n\n positions.set(id, element.getBoundingClientRect().top)\n })\n\n animations.forEach(({ element, transforms, transition }) => {\n animate({ element, transforms, transition })\n })\n })\n\n const animateRemove = useCallback(\n function animateRemove(id: string, onAnimationDone: () => void) {\n const element = refs.get(id)\n if (element) {\n // Removal animation\n animate({\n element,\n transforms: [{ property: 'opacity', to: '0' }],\n transition: EXIT_TRANSITION,\n done: onAnimationDone,\n })\n }\n },\n [refs],\n )\n\n const mappedRef = useCallback(\n (id: string) => (ref: HTMLElement | null) => {\n refs.set(id, ref)\n },\n [refs],\n )\n\n return { mappedRef, animateRemove }\n}\n\nexport { ANIMATION_TIMEOUT, useToastsAnimation }\n"],"names":["ANIMATION_TIMEOUT","ENTRANCE_TRANSITION","EXIT_TRANSITION","animate","element","transforms","transition","done","fallbackTimeout","setTimeout","forEach","property","from","style","setProperty","transitionEndHandler","event","target","removeEventListener","clearTimeout","addEventListener","window","requestAnimationFrame","to","useToastsAnimation","refs","useMemo","Map","positions","useLayoutEffect","animations","Array","entries","id","delete","prevTop","get","top","height","getBoundingClientRect","push","set","animateRemove","useCallback","onAnimationDone","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,OAAO,CAAC;QACJC,OADI;AAEJC,QAAAA,UAAU,EAAE,CAAC;AAAEM,UAAAA,QAAQ,EAAE,SAAZ;AAAuBY,UAAAA,EAAE,EAAE,GAAA;AAA3B,SAAD,CAFR;AAGJjB,QAAAA,UAAU,EAAEJ,eAHR;AAIJK,QAAAA,IAAI,EAAEqC,eAAAA;AAJF,OAAD,CAAP,CAAA;AAMH,KAAA;AACJ,GAZ4B,EAa7B,CAACnB,IAAD,CAb6B,CAAjC,CAAA;AAgBA,EAAA,MAAMoB,SAAS,GAAGF,WAAW,CACxBV,EAAD,IAAiBa,GAAD,IAA4B;AACxCrB,IAAAA,IAAI,CAACgB,GAAL,CAASR,EAAT,EAAaa,GAAb,CAAA,CAAA;AACH,GAHwB,EAIzB,CAACrB,IAAD,CAJyB,CAA7B,CAAA;EAOA,OAAO;IAAEoB,SAAF;AAAaH,IAAAA,aAAAA;GAApB,CAAA;AACH;;;;"}
@@ -1,4 +1,4 @@
1
1
  var modules_d11e18f0 = {"stackedToastsView":"_616cc3f3","toastContainer":"_1b5f8e86","slot":"ce2e3476"};
2
2
 
3
- export default modules_d11e18f0;
3
+ export { modules_d11e18f0 as default };
4
4
  //# sourceMappingURL=toast.module.css.js.map
@@ -1,11 +1,11 @@
1
1
  import { objectSpread2 as _objectSpread2, objectWithoutProperties as _objectWithoutProperties } from '../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import React__default from 'react';
3
- import { Box } from '../box/box.js';
4
- import { Stack } from '../stack/stack.js';
5
3
  import { Portal } from '@ariakit/react';
6
4
  import { generateElementId } from '../utils/common-helpers.js';
7
- import styles from './toast.module.css.js';
5
+ import { Box } from '../box/box.js';
6
+ import { Stack } from '../stack/stack.js';
8
7
  import { isActionObject, StaticToast } from './static-toast.js';
8
+ import modules_d11e18f0 from './toast.module.css.js';
9
9
  import { useToastsAnimation } from './toast-animation.js';
10
10
 
11
11
  const _excluded = ["toastId"];
@@ -127,7 +127,7 @@ function ToastsProvider({
127
127
  return /*#__PURE__*/React__default.createElement(ToastsContext.Provider, {
128
128
  value: showToast
129
129
  }, children, /*#__PURE__*/React__default.createElement(Portal, null, toasts.length === 0 ? null : /*#__PURE__*/React__default.createElement(Box, {
130
- className: [styles.stackedToastsView, containerClassName],
130
+ className: [modules_d11e18f0.stackedToastsView, containerClassName],
131
131
  position: "fixed",
132
132
  width: "full",
133
133
  paddingX: padding,
@@ -1 +1 @@
1
- {"version":3,"file":"use-toasts.js","sources":["../../src/toast/use-toasts.tsx"],"sourcesContent":["import React from 'react'\nimport { Portal } from '@ariakit/react'\n\nimport { generateElementId } from '../utils/common-helpers'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { isActionObject, StaticToast, StaticToastProps } from './static-toast'\n\nimport styles from './toast.module.css'\n\nimport type { Space } from '../utils/common-types'\nimport { useToastsAnimation } from './toast-animation'\n\n/**\n * The props needed to fire up a new notification toast.\n */\ntype ToastProps = StaticToastProps & {\n /**\n * The number of seconds the toast is expected to be shown before it is dismissed automatically,\n * or false to disable auto-dismiss.\n *\n * It defaults to whatever is the autoDismissDelay set in the ToastsProvider.\n */\n autoDismissDelay?: number | false\n\n /**\n * The label for the button that dismisses the toast.\n *\n * It defaults to the value set in the ToastsProvider, but individual toasts can have a\n * different value if needed.\n */\n dismissLabel?: string\n\n /**\n * Whether to show the dismiss button or not.\n *\n * Use this value with care. If combined with disabling `autoDismissDelay`, it may leave you\n * with toasts that the user won't be able to dismiss at will. It then is your responsibility to\n * dismiss the toast by calling the function returned by `showToast`.\n */\n showDismissButton?: boolean\n}\n\n//\n// InternalToast component and its props\n//\n\ntype InternalToastProps = Omit<ToastProps, 'autoDismissDelay' | 'dismissLabel'> &\n Required<Pick<ToastProps, 'autoDismissDelay' | 'dismissLabel'>> & {\n toastId: string\n onRemoveToast: (toastId: string) => void\n }\n\n/** @private */\nconst InternalToast = React.forwardRef<HTMLDivElement, InternalToastProps>(function InternalToast(\n {\n message,\n description,\n icon,\n action,\n autoDismissDelay,\n dismissLabel,\n showDismissButton = true,\n toastId,\n onDismiss,\n onRemoveToast,\n },\n ref,\n) {\n const [timeoutRunning, setTimeoutRunning] = React.useState(Boolean(autoDismissDelay))\n const timeoutRef = React.useRef<number | undefined>()\n\n const startTimeout = React.useCallback(function startTimeout() {\n setTimeoutRunning(true)\n }, [])\n\n const stopTimeout = React.useCallback(function stopTimeout() {\n setTimeoutRunning(false)\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }, [])\n\n const removeToast = React.useCallback(\n function removeToast() {\n onRemoveToast(toastId)\n onDismiss?.()\n },\n [onDismiss, onRemoveToast, toastId],\n )\n\n React.useEffect(\n function setupAutoDismiss() {\n if (!timeoutRunning || !autoDismissDelay) return\n timeoutRef.current = window.setTimeout(removeToast, autoDismissDelay * 1000)\n return stopTimeout\n },\n [autoDismissDelay, removeToast, stopTimeout, timeoutRunning],\n )\n\n /**\n * If the action is toast action object and not a custom element,\n * the `onClick` property is wrapped in another handler responsible\n * for removing the toast when the action is triggered.\n */\n const actionWithCustomActionHandler = React.useMemo(() => {\n if (!isActionObject(action)) {\n return action\n }\n\n return {\n ...action,\n onClick: function handleActionClick() {\n if (!action) {\n return\n }\n\n action.onClick()\n removeToast()\n },\n }\n }, [action, removeToast])\n\n return (\n <StaticToast\n ref={ref}\n message={message}\n description={description}\n icon={icon}\n action={actionWithCustomActionHandler}\n onDismiss={showDismissButton ? removeToast : undefined}\n dismissLabel={dismissLabel}\n // @ts-expect-error\n onMouseEnter={stopTimeout}\n onMouseLeave={startTimeout}\n />\n )\n})\n\n//\n// Internal state and context\n//\n\ntype InternalToastEntry = Omit<InternalToastProps, 'onRemoveToast'>\ntype ToastsList = readonly InternalToastEntry[]\n\ntype ShowToastAction = (props: ToastProps) => () => void\nconst ToastsContext = React.createContext<ShowToastAction>(() => () => undefined)\n\n/**\n * The props needed by the ToastsProvider component.\n *\n * @see ToastsProvider\n */\ntype ToastsProviderProps = {\n /**\n * The default label to apply to toast dismiss buttons.\n *\n * This is useful in environments that need locatization, so you do not need to pass the same\n * translated label every time you trigger a toast.\n *\n * However, you can still apply a different label to a specific toast, by passing a different\n * value when calling showToast.\n *\n * @default 'Close'\n */\n defaultDismissLabel?: string\n\n /**\n * The default number of seconds after which the toast will be dismissed automatically.\n *\n * You can pass a different value to a specific toast when calling `showToast`. You can even\n * pass `false` if you want a certain toast to never be dismissed automatically.\n *\n * @default 10 (seconds)\n */\n defaultAutoDismissDelay?: number\n\n /**\n * The padding used to separate the toasts from the viewport borders.\n *\n * @default 'large'\n */\n padding?: Space\n\n /**\n * The app wrapped by the provider.\n */\n children: NonNullable<React.ReactNode>\n\n /**\n * Custom classname for the toasts container, if you need to fine-tune the position or other styles\n */\n containerClassName?: string\n}\n\n/**\n * Provides the state management and rendering of the toasts currently active.\n *\n * You need to render this near the top of your app components tree, in order to `useToasts`.\n *\n * @see useToasts\n */\nfunction ToastsProvider({\n children,\n padding = 'large',\n defaultAutoDismissDelay = 10 /* seconds */,\n defaultDismissLabel = 'Close',\n containerClassName,\n}: ToastsProviderProps) {\n const [toasts, setToasts] = React.useState<ToastsList>([])\n const { mappedRef, animateRemove } = useToastsAnimation()\n\n const removeToast = React.useCallback(\n function onRemoveToast(toastId: string) {\n animateRemove(toastId, () => {\n setToasts((list) => {\n const index = list.findIndex((n) => n.toastId === toastId)\n if (index < 0) return list\n const copy = [...list]\n copy.splice(index, 1)\n return copy\n })\n })\n },\n [animateRemove],\n )\n\n const showToast = React.useCallback(\n function showToast(props: ToastProps) {\n const toastId = generateElementId('toast')\n const newToast: InternalToastEntry = {\n autoDismissDelay: defaultAutoDismissDelay,\n dismissLabel: defaultDismissLabel,\n ...props,\n toastId,\n }\n setToasts((list) => [...list, newToast])\n return () => removeToast(toastId)\n },\n [defaultAutoDismissDelay, defaultDismissLabel, removeToast],\n )\n\n return (\n <ToastsContext.Provider value={showToast}>\n {children}\n <Portal>\n {toasts.length === 0 ? null : (\n <Box\n className={[styles.stackedToastsView, containerClassName]}\n position=\"fixed\"\n width=\"full\"\n paddingX={padding}\n paddingBottom={padding}\n data-testid=\"toasts-container\"\n >\n <Stack space=\"medium\">\n {toasts.map(({ toastId, ...props }) => (\n <InternalToast\n key={toastId}\n ref={mappedRef(toastId)}\n toastId={toastId}\n onRemoveToast={removeToast}\n {...props}\n />\n ))}\n </Stack>\n </Box>\n )}\n </Portal>\n </ToastsContext.Provider>\n )\n}\n\n/**\n * Provides a function `showToast` that shows a new toast every time you call it.\n *\n * ```jsx\n * const showToast = useToasts()\n *\n * <button onClick={() => showToast({ message: 'Hello' })}>\n * Say hello\n * </button>\n * ```\n *\n * All toasts fired via this function are rendered in a global fixed location, and stacked one on\n * top of the other.\n *\n * When called, `showToast` returns a function that dismisses the toast when called.\n *\n * @see ToastsProvider\n */\nfunction useToasts() {\n return React.useContext(ToastsContext)\n}\n\n/**\n * Adds a toast to be rendered, stacked alongside any other currently active toasts.\n *\n * For most situations, you should prefer to use the `showToast` function obtained from `useToasts`.\n * This component is provided for convenience to render toasts in the markup, but it has some\n * peculiarities, which are discussed below.\n *\n * Internally, this calls `showToast`. It is provided for two reasons:\n *\n * 1. Convenience, when you want to fire a toast in markup/jsx code. Keep in mind, though, that\n * toasts rendered in this way will be removed from view when the context where it is rendered\n * is unmounted. Unlike toasts fired with `showToast`, which will normally be dismissed, either\n * by the user or after a delay. They'll still be animated on their way out, though.\n * 2. When combined with disabling dismissing it (e.g. `showDismissButton={false}` and\n * `autoDismissDelay={false}` it provides a way to show \"permanent\" toasts that only go away when\n * the component ceases to be rendered).\n *\n * This is useful for cases when the consumer wants to control when a toast is visible, and to keep\n * it visible based on an app-specific condition.\n *\n * Something important to note about this component is that it triggers the toast based on the props\n * passed when first rendered, and it does not update the toast if these props change on subsequent\n * renders. In this sense, this is an imperative component, more than a descriptive one. This is\n * done to simplify the internals, and to keep it in line with how `showToast` works: you fire up a\n * toast imperatively, and you loose control over it. It remains rendered according to the props you\n * first passed.\n *\n * @see useToasts\n */\nfunction Toast(props: ToastProps) {\n const showToast = useToasts()\n const propsRef = React.useRef<ToastProps>(props)\n React.useEffect(() => {\n const dismissToast = showToast(propsRef.current)\n return dismissToast\n }, [showToast])\n return null\n}\n\nexport { Toast, ToastsProvider, useToasts }\nexport type { ToastProps, ToastsProviderProps }\n"],"names":["InternalToast","React","forwardRef","message","description","icon","action","autoDismissDelay","dismissLabel","showDismissButton","toastId","onDismiss","onRemoveToast","ref","timeoutRunning","setTimeoutRunning","useState","Boolean","timeoutRef","useRef","startTimeout","useCallback","stopTimeout","clearTimeout","current","undefined","removeToast","useEffect","setupAutoDismiss","window","setTimeout","actionWithCustomActionHandler","useMemo","isActionObject","onClick","handleActionClick","StaticToast","onMouseEnter","onMouseLeave","ToastsContext","createContext","ToastsProvider","children","padding","defaultAutoDismissDelay","defaultDismissLabel","containerClassName","toasts","setToasts","mappedRef","animateRemove","useToastsAnimation","list","index","findIndex","n","copy","splice","showToast","props","generateElementId","newToast","Provider","value","Portal","length","Box","className","styles","stackedToastsView","position","width","paddingX","paddingBottom","Stack","space","map","key","useToasts","useContext","Toast","propsRef","dismissToast"],"mappings":";;;;;;;;;;;AAqDA;;AACA,MAAMA,aAAa,gBAAGC,cAAK,CAACC,UAAN,CAAqD,SAASF,aAAT,CACvE;EACIG,OADJ;EAEIC,WAFJ;EAGIC,IAHJ;EAIIC,MAJJ;EAKIC,gBALJ;EAMIC,YANJ;EAOIC,iBAAiB,GAAG,IAPxB;EAQIC,OARJ;EASIC,SATJ;EAUIC;AAVJ,CADuE,EAavEC,GAbuE;EAevE,MAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsCd,cAAK,CAACe,QAAN,CAAeC,OAAO,CAACV,gBAAD,CAAtB,CAA5C;EACA,MAAMW,UAAU,GAAGjB,cAAK,CAACkB,MAAN,EAAnB;EAEA,MAAMC,YAAY,GAAGnB,cAAK,CAACoB,WAAN,CAAkB,SAASD,YAAT;IACnCL,iBAAiB,CAAC,IAAD,CAAjB;GADiB,EAElB,EAFkB,CAArB;EAIA,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AS,CAACuB,QAAQ,CAACzD,OAAV,CAA9B;IACA,OAAO0D,YAAP;GAFJ,EAGG,CAACxB,SAAD,CAHH;EAIA,OAAO,IAAP;AACH;;;;"}
1
+ {"version":3,"file":"use-toasts.js","sources":["../../src/toast/use-toasts.tsx"],"sourcesContent":["import React from 'react'\nimport { Portal } from '@ariakit/react'\n\nimport { generateElementId } from '../utils/common-helpers'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { isActionObject, StaticToast, StaticToastProps } from './static-toast'\n\nimport styles from './toast.module.css'\n\nimport type { Space } from '../utils/common-types'\nimport { useToastsAnimation } from './toast-animation'\n\n/**\n * The props needed to fire up a new notification toast.\n */\ntype ToastProps = StaticToastProps & {\n /**\n * The number of seconds the toast is expected to be shown before it is dismissed automatically,\n * or false to disable auto-dismiss.\n *\n * It defaults to whatever is the autoDismissDelay set in the ToastsProvider.\n */\n autoDismissDelay?: number | false\n\n /**\n * The label for the button that dismisses the toast.\n *\n * It defaults to the value set in the ToastsProvider, but individual toasts can have a\n * different value if needed.\n */\n dismissLabel?: string\n\n /**\n * Whether to show the dismiss button or not.\n *\n * Use this value with care. If combined with disabling `autoDismissDelay`, it may leave you\n * with toasts that the user won't be able to dismiss at will. It then is your responsibility to\n * dismiss the toast by calling the function returned by `showToast`.\n */\n showDismissButton?: boolean\n}\n\n//\n// InternalToast component and its props\n//\n\ntype InternalToastProps = Omit<ToastProps, 'autoDismissDelay' | 'dismissLabel'> &\n Required<Pick<ToastProps, 'autoDismissDelay' | 'dismissLabel'>> & {\n toastId: string\n onRemoveToast: (toastId: string) => void\n }\n\n/** @private */\nconst InternalToast = React.forwardRef<HTMLDivElement, InternalToastProps>(function InternalToast(\n {\n message,\n description,\n icon,\n action,\n autoDismissDelay,\n dismissLabel,\n showDismissButton = true,\n toastId,\n onDismiss,\n onRemoveToast,\n },\n ref,\n) {\n const [timeoutRunning, setTimeoutRunning] = React.useState(Boolean(autoDismissDelay))\n const timeoutRef = React.useRef<number | undefined>()\n\n const startTimeout = React.useCallback(function startTimeout() {\n setTimeoutRunning(true)\n }, [])\n\n const stopTimeout = React.useCallback(function stopTimeout() {\n setTimeoutRunning(false)\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }, [])\n\n const removeToast = React.useCallback(\n function removeToast() {\n onRemoveToast(toastId)\n onDismiss?.()\n },\n [onDismiss, onRemoveToast, toastId],\n )\n\n React.useEffect(\n function setupAutoDismiss() {\n if (!timeoutRunning || !autoDismissDelay) return\n timeoutRef.current = window.setTimeout(removeToast, autoDismissDelay * 1000)\n return stopTimeout\n },\n [autoDismissDelay, removeToast, stopTimeout, timeoutRunning],\n )\n\n /**\n * If the action is toast action object and not a custom element,\n * the `onClick` property is wrapped in another handler responsible\n * for removing the toast when the action is triggered.\n */\n const actionWithCustomActionHandler = React.useMemo(() => {\n if (!isActionObject(action)) {\n return action\n }\n\n return {\n ...action,\n onClick: function handleActionClick() {\n if (!action) {\n return\n }\n\n action.onClick()\n removeToast()\n },\n }\n }, [action, removeToast])\n\n return (\n <StaticToast\n ref={ref}\n message={message}\n description={description}\n icon={icon}\n action={actionWithCustomActionHandler}\n onDismiss={showDismissButton ? removeToast : undefined}\n dismissLabel={dismissLabel}\n // @ts-expect-error\n onMouseEnter={stopTimeout}\n onMouseLeave={startTimeout}\n />\n )\n})\n\n//\n// Internal state and context\n//\n\ntype InternalToastEntry = Omit<InternalToastProps, 'onRemoveToast'>\ntype ToastsList = readonly InternalToastEntry[]\n\ntype ShowToastAction = (props: ToastProps) => () => void\nconst ToastsContext = React.createContext<ShowToastAction>(() => () => undefined)\n\n/**\n * The props needed by the ToastsProvider component.\n *\n * @see ToastsProvider\n */\ntype ToastsProviderProps = {\n /**\n * The default label to apply to toast dismiss buttons.\n *\n * This is useful in environments that need locatization, so you do not need to pass the same\n * translated label every time you trigger a toast.\n *\n * However, you can still apply a different label to a specific toast, by passing a different\n * value when calling showToast.\n *\n * @default 'Close'\n */\n defaultDismissLabel?: string\n\n /**\n * The default number of seconds after which the toast will be dismissed automatically.\n *\n * You can pass a different value to a specific toast when calling `showToast`. You can even\n * pass `false` if you want a certain toast to never be dismissed automatically.\n *\n * @default 10 (seconds)\n */\n defaultAutoDismissDelay?: number\n\n /**\n * The padding used to separate the toasts from the viewport borders.\n *\n * @default 'large'\n */\n padding?: Space\n\n /**\n * The app wrapped by the provider.\n */\n children: NonNullable<React.ReactNode>\n\n /**\n * Custom classname for the toasts container, if you need to fine-tune the position or other styles\n */\n containerClassName?: string\n}\n\n/**\n * Provides the state management and rendering of the toasts currently active.\n *\n * You need to render this near the top of your app components tree, in order to `useToasts`.\n *\n * @see useToasts\n */\nfunction ToastsProvider({\n children,\n padding = 'large',\n defaultAutoDismissDelay = 10 /* seconds */,\n defaultDismissLabel = 'Close',\n containerClassName,\n}: ToastsProviderProps) {\n const [toasts, setToasts] = React.useState<ToastsList>([])\n const { mappedRef, animateRemove } = useToastsAnimation()\n\n const removeToast = React.useCallback(\n function onRemoveToast(toastId: string) {\n animateRemove(toastId, () => {\n setToasts((list) => {\n const index = list.findIndex((n) => n.toastId === toastId)\n if (index < 0) return list\n const copy = [...list]\n copy.splice(index, 1)\n return copy\n })\n })\n },\n [animateRemove],\n )\n\n const showToast = React.useCallback(\n function showToast(props: ToastProps) {\n const toastId = generateElementId('toast')\n const newToast: InternalToastEntry = {\n autoDismissDelay: defaultAutoDismissDelay,\n dismissLabel: defaultDismissLabel,\n ...props,\n toastId,\n }\n setToasts((list) => [...list, newToast])\n return () => removeToast(toastId)\n },\n [defaultAutoDismissDelay, defaultDismissLabel, removeToast],\n )\n\n return (\n <ToastsContext.Provider value={showToast}>\n {children}\n <Portal>\n {toasts.length === 0 ? null : (\n <Box\n className={[styles.stackedToastsView, containerClassName]}\n position=\"fixed\"\n width=\"full\"\n paddingX={padding}\n paddingBottom={padding}\n data-testid=\"toasts-container\"\n >\n <Stack space=\"medium\">\n {toasts.map(({ toastId, ...props }) => (\n <InternalToast\n key={toastId}\n ref={mappedRef(toastId)}\n toastId={toastId}\n onRemoveToast={removeToast}\n {...props}\n />\n ))}\n </Stack>\n </Box>\n )}\n </Portal>\n </ToastsContext.Provider>\n )\n}\n\n/**\n * Provides a function `showToast` that shows a new toast every time you call it.\n *\n * ```jsx\n * const showToast = useToasts()\n *\n * <button onClick={() => showToast({ message: 'Hello' })}>\n * Say hello\n * </button>\n * ```\n *\n * All toasts fired via this function are rendered in a global fixed location, and stacked one on\n * top of the other.\n *\n * When called, `showToast` returns a function that dismisses the toast when called.\n *\n * @see ToastsProvider\n */\nfunction useToasts() {\n return React.useContext(ToastsContext)\n}\n\n/**\n * Adds a toast to be rendered, stacked alongside any other currently active toasts.\n *\n * For most situations, you should prefer to use the `showToast` function obtained from `useToasts`.\n * This component is provided for convenience to render toasts in the markup, but it has some\n * peculiarities, which are discussed below.\n *\n * Internally, this calls `showToast`. It is provided for two reasons:\n *\n * 1. Convenience, when you want to fire a toast in markup/jsx code. Keep in mind, though, that\n * toasts rendered in this way will be removed from view when the context where it is rendered\n * is unmounted. Unlike toasts fired with `showToast`, which will normally be dismissed, either\n * by the user or after a delay. They'll still be animated on their way out, though.\n * 2. When combined with disabling dismissing it (e.g. `showDismissButton={false}` and\n * `autoDismissDelay={false}` it provides a way to show \"permanent\" toasts that only go away when\n * the component ceases to be rendered).\n *\n * This is useful for cases when the consumer wants to control when a toast is visible, and to keep\n * it visible based on an app-specific condition.\n *\n * Something important to note about this component is that it triggers the toast based on the props\n * passed when first rendered, and it does not update the toast if these props change on subsequent\n * renders. In this sense, this is an imperative component, more than a descriptive one. This is\n * done to simplify the internals, and to keep it in line with how `showToast` works: you fire up a\n * toast imperatively, and you loose control over it. It remains rendered according to the props you\n * first passed.\n *\n * @see useToasts\n */\nfunction Toast(props: ToastProps) {\n const showToast = useToasts()\n const propsRef = React.useRef<ToastProps>(props)\n React.useEffect(() => {\n const dismissToast = showToast(propsRef.current)\n return dismissToast\n }, [showToast])\n return null\n}\n\nexport { Toast, ToastsProvider, useToasts }\nexport type { ToastProps, ToastsProviderProps }\n"],"names":["InternalToast","React","forwardRef","message","description","icon","action","autoDismissDelay","dismissLabel","showDismissButton","toastId","onDismiss","onRemoveToast","ref","timeoutRunning","setTimeoutRunning","useState","Boolean","timeoutRef","useRef","startTimeout","useCallback","stopTimeout","clearTimeout","current","undefined","removeToast","useEffect","setupAutoDismiss","window","setTimeout","actionWithCustomActionHandler","useMemo","isActionObject","_objectSpread","onClick","handleActionClick","createElement","StaticToast","onMouseEnter","onMouseLeave","ToastsContext","createContext","ToastsProvider","children","padding","defaultAutoDismissDelay","defaultDismissLabel","containerClassName","toasts","setToasts","mappedRef","animateRemove","useToastsAnimation","list","index","findIndex","n","copy","splice","showToast","props","generateElementId","newToast","Provider","value","Portal","length","Box","className","styles","stackedToastsView","position","width","paddingX","paddingBottom","Stack","space","map","key","useToasts","useContext","Toast","propsRef","dismissToast"],"mappings":";;;;;;;;;;;AAqDA;;AACA,MAAMA,aAAa,gBAAGC,cAAK,CAACC,UAAN,CAAqD,SAASF,aAAT,CACvE;EACIG,OADJ;EAEIC,WAFJ;EAGIC,IAHJ;EAIIC,MAJJ;EAKIC,gBALJ;EAMIC,YANJ;AAOIC,EAAAA,iBAAiB,GAAG,IAPxB;EAQIC,OARJ;EASIC,SATJ;AAUIC,EAAAA,aAAAA;AAVJ,CADuE,EAavEC,GAbuE,EAapE;AAEH,EAAA,MAAM,CAACC,cAAD,EAAiBC,iBAAjB,CAAsCd,GAAAA,cAAK,CAACe,QAAN,CAAeC,OAAO,CAACV,gBAAD,CAAtB,CAA5C,CAAA;AACA,EAAA,MAAMW,UAAU,GAAGjB,cAAK,CAACkB,MAAN,EAAnB,CAAA;EAEA,MAAMC,YAAY,GAAGnB,cAAK,CAACoB,WAAN,CAAkB,SAASD,YAAT,GAAqB;IACxDL,iBAAiB,CAAC,IAAD,CAAjB,CAAA;GADiB,EAElB,EAFkB,CAArB,CAAA;EAIA,MAAMO,WAAW,GAAGrB,cAAK,CAACoB,WAAN,CAAk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AQ,GAAGlF,cAAK,CAACkB,MAAN,CAAyB0C,KAAzB,CAAjB,CAAA;EACA5D,cAAK,CAAC0B,SAAN,CAAgB,MAAK;AACjB,IAAA,MAAMyD,YAAY,GAAGxB,SAAS,CAACuB,QAAQ,CAAC3D,OAAV,CAA9B,CAAA;AACA,IAAA,OAAO4D,YAAP,CAAA;GAFJ,EAGG,CAACxB,SAAD,CAHH,CAAA,CAAA;AAIA,EAAA,OAAO,IAAP,CAAA;AACH;;;;"}
@@ -1,7 +1,7 @@
1
- import { Children, createElement, Fragment } from 'react';
2
- import { Box } from '../box/box.js';
1
+ import * as React from 'react';
3
2
  import { useTooltipStore, TooltipAnchor, Tooltip as Tooltip$1, TooltipArrow } from '@ariakit/react';
4
- import styles from './tooltip.module.css.js';
3
+ import { Box } from '../box/box.js';
4
+ import modules_95f1407a from './tooltip.module.css.js';
5
5
 
6
6
  function Tooltip({
7
7
  children,
@@ -17,7 +17,7 @@ function Tooltip({
17
17
  hideTimeout: 100
18
18
  });
19
19
  const isOpen = tooltip.useState('open');
20
- const child = Children.only(children);
20
+ const child = React.Children.only(children);
21
21
 
22
22
  if (!child) {
23
23
  return child;
@@ -27,15 +27,15 @@ function Tooltip({
27
27
  throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded');
28
28
  }
29
29
 
30
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(TooltipAnchor, {
30
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TooltipAnchor, {
31
31
  render: child,
32
32
  store: tooltip,
33
33
  ref: child.ref
34
- }), isOpen && content ? /*#__PURE__*/createElement(Tooltip$1, {
34
+ }), isOpen && content ? /*#__PURE__*/React.createElement(Tooltip$1, {
35
35
  store: tooltip,
36
36
  gutter: gapSize,
37
- render: /*#__PURE__*/createElement(Box, {
38
- className: [styles.tooltip, exceptionallySetClassName],
37
+ render: /*#__PURE__*/React.createElement(Box, {
38
+ className: [modules_95f1407a.tooltip, exceptionallySetClassName],
39
39
  background: "toast",
40
40
  borderRadius: "standard",
41
41
  paddingX: "small",
@@ -45,7 +45,7 @@ function Tooltip({
45
45
  overflow: "hidden",
46
46
  textAlign: "center"
47
47
  })
48
- }, withArrow ? /*#__PURE__*/createElement(TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
48
+ }, withArrow ? /*#__PURE__*/React.createElement(TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
49
49
  }
50
50
 
51
51
  export { Tooltip };
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n useTooltipStore,\n Tooltip as AriakitTooltip,\n TooltipAnchor,\n TooltipArrow,\n} from '@ariakit/react'\nimport { Box } from '../box'\n\nimport type { TooltipStoreState } from '@ariakit/react'\n\nimport styles from './tooltip.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ninterface TooltipProps extends ObfuscatedClassName {\n /**\n * The element that triggers the tooltip. Generally a button or link.\n *\n * It should be an interactive element accessible both via mouse and keyboard interactions.\n */\n children: React.ReactNode\n\n /**\n * The content to show in the tooltip.\n *\n * It can be rich content provided via React elements, or string content. It should not include\n * interactive elements inside it. This includes links or buttons.\n *\n * You can provide a function instead of the content itself. In this case, the function should\n * return the desired content. This is useful if the content is expensive to generate. It can\n * also be useful if the content dynamically changes often, so every time you trigger the\n * tooltip the content may have changed (e.g. if you show a ticking time clock in the tooltip).\n *\n * The trigger element will be associated to this content via `aria-describedby`. This means\n * that the tooltip content will be read by assistive technologies such as screen readers. It\n * will likely read this content right after reading the trigger element label.\n */\n content: React.ReactNode | (() => React.ReactNode)\n\n /**\n * How to place the tooltip relative to its trigger element.\n *\n * The possible values are \"top\", \"bottom\", \"left\", \"right\". Additionally, any of these values\n * can be combined with `-start` or `-end` for even more control. For instance `top-start` will\n * place the tooltip at the top, but with the start (e.g. left) side of the toolip and the\n * trigger aligned. If neither `-start` or `-end` are provided, the tooltip is centered along\n * the vertical or horizontal axis with the trigger.\n *\n * The position is enforced whenever possible, but tooltips can appear in different positions\n * if the specified one would make the tooltip intersect with the viewport edges.\n *\n * @default 'top'\n */\n position?: TooltipStoreState['placement']\n\n /**\n * The separation (in pixels) between the trigger element and the tooltip.\n * @default 3\n */\n gapSize?: number\n\n /**\n * Whether to show an arrow-like element attached to the tooltip, and pointing towards the\n * trigger element.\n * @default false\n */\n withArrow?: boolean\n}\n\nfunction Tooltip({\n children,\n content,\n position = 'top',\n gapSize = 3,\n withArrow = false,\n exceptionallySetClassName,\n}: TooltipProps) {\n const tooltip = useTooltipStore({ placement: position, showTimeout: 500, hideTimeout: 100 })\n const isOpen = tooltip.useState('open')\n\n const child = React.Children.only(\n children as React.FunctionComponentElement<JSX.IntrinsicElements['div']> | null,\n )\n\n if (!child) {\n return child\n }\n\n if (typeof child.ref === 'string') {\n throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded')\n }\n\n return (\n <>\n <TooltipAnchor render={child} store={tooltip} ref={child.ref} />\n {isOpen && content ? (\n <AriakitTooltip\n store={tooltip}\n gutter={gapSize}\n render={\n <Box\n className={[styles.tooltip, exceptionallySetClassName]}\n background=\"toast\"\n borderRadius=\"standard\"\n paddingX=\"small\"\n paddingY=\"xsmall\"\n maxWidth=\"medium\"\n width=\"fitContent\"\n overflow=\"hidden\"\n textAlign=\"center\"\n />\n }\n >\n {withArrow ? <TooltipArrow /> : null}\n {typeof content === 'function' ? content() : content}\n </AriakitTooltip>\n ) : null}\n </>\n )\n}\n\nexport type { TooltipProps }\nexport { Tooltip }\n"],"names":["Tooltip","children","content","position","gapSize","withArrow","exceptionallySetClassName","tooltip","useTooltipStore","placement","showTimeout","hideTimeout","isOpen","useState","child","React","only","ref","Error","TooltipAnchor","render","store","AriakitTooltip","gutter","Box","className","styles","background","borderRadius","paddingX","paddingY","maxWidth","width","overflow","textAlign","TooltipArrow"],"mappings":";;;;;AAsEA,SAASA,OAAT,CAAiB;EACbC,QAD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../../src/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n useTooltipStore,\n Tooltip as AriakitTooltip,\n TooltipAnchor,\n TooltipArrow,\n} from '@ariakit/react'\nimport { Box } from '../box'\n\nimport type { TooltipStoreState } from '@ariakit/react'\n\nimport styles from './tooltip.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ninterface TooltipProps extends ObfuscatedClassName {\n /**\n * The element that triggers the tooltip. Generally a button or link.\n *\n * It should be an interactive element accessible both via mouse and keyboard interactions.\n */\n children: React.ReactNode\n\n /**\n * The content to show in the tooltip.\n *\n * It can be rich content provided via React elements, or string content. It should not include\n * interactive elements inside it. This includes links or buttons.\n *\n * You can provide a function instead of the content itself. In this case, the function should\n * return the desired content. This is useful if the content is expensive to generate. It can\n * also be useful if the content dynamically changes often, so every time you trigger the\n * tooltip the content may have changed (e.g. if you show a ticking time clock in the tooltip).\n *\n * The trigger element will be associated to this content via `aria-describedby`. This means\n * that the tooltip content will be read by assistive technologies such as screen readers. It\n * will likely read this content right after reading the trigger element label.\n */\n content: React.ReactNode | (() => React.ReactNode)\n\n /**\n * How to place the tooltip relative to its trigger element.\n *\n * The possible values are \"top\", \"bottom\", \"left\", \"right\". Additionally, any of these values\n * can be combined with `-start` or `-end` for even more control. For instance `top-start` will\n * place the tooltip at the top, but with the start (e.g. left) side of the toolip and the\n * trigger aligned. If neither `-start` or `-end` are provided, the tooltip is centered along\n * the vertical or horizontal axis with the trigger.\n *\n * The position is enforced whenever possible, but tooltips can appear in different positions\n * if the specified one would make the tooltip intersect with the viewport edges.\n *\n * @default 'top'\n */\n position?: TooltipStoreState['placement']\n\n /**\n * The separation (in pixels) between the trigger element and the tooltip.\n * @default 3\n */\n gapSize?: number\n\n /**\n * Whether to show an arrow-like element attached to the tooltip, and pointing towards the\n * trigger element.\n * @default false\n */\n withArrow?: boolean\n}\n\nfunction Tooltip({\n children,\n content,\n position = 'top',\n gapSize = 3,\n withArrow = false,\n exceptionallySetClassName,\n}: TooltipProps) {\n const tooltip = useTooltipStore({ placement: position, showTimeout: 500, hideTimeout: 100 })\n const isOpen = tooltip.useState('open')\n\n const child = React.Children.only(\n children as React.FunctionComponentElement<JSX.IntrinsicElements['div']> | null,\n )\n\n if (!child) {\n return child\n }\n\n if (typeof child.ref === 'string') {\n throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded')\n }\n\n return (\n <>\n <TooltipAnchor render={child} store={tooltip} ref={child.ref} />\n {isOpen && content ? (\n <AriakitTooltip\n store={tooltip}\n gutter={gapSize}\n render={\n <Box\n className={[styles.tooltip, exceptionallySetClassName]}\n background=\"toast\"\n borderRadius=\"standard\"\n paddingX=\"small\"\n paddingY=\"xsmall\"\n maxWidth=\"medium\"\n width=\"fitContent\"\n overflow=\"hidden\"\n textAlign=\"center\"\n />\n }\n >\n {withArrow ? <TooltipArrow /> : null}\n {typeof content === 'function' ? content() : content}\n </AriakitTooltip>\n ) : null}\n </>\n )\n}\n\nexport type { TooltipProps }\nexport { Tooltip }\n"],"names":["Tooltip","children","content","position","gapSize","withArrow","exceptionallySetClassName","tooltip","useTooltipStore","placement","showTimeout","hideTimeout","isOpen","useState","child","React","Children","only","ref","Error","createElement","Fragment","TooltipAnchor","render","store","AriakitTooltip","gutter","Box","className","styles","background","borderRadius","paddingX","paddingY","maxWidth","width","overflow","textAlign","TooltipArrow"],"mappings":";;;;;AAsEA,SAASA,OAAT,CAAiB;EACbC,QADa;EAEbC,OAFa;AAGbC,EAAAA,QAAQ,GAAG,KAHE;AAIbC,EAAAA,OAAO,GAAG,CAJG;AAKbC,EAAAA,SAAS,GAAG,KALC;AAMbC,EAAAA,yBAAAA;AANa,CAAjB,EAOe;EACX,MAAMC,OAAO,GAAGC,eAAe,CAAC;AAAEC,IAAAA,SAAS,EAAEN,QAAb;AAAuBO,IAAAA,WAAW,EAAE,GAApC;AAAyCC,IAAAA,WAAW,EAAE,GAAA;AAAtD,GAAD,CAA/B,CAAA;AACA,EAAA,MAAMC,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jBpC,EAkBK,OAAOpC,OAAP,KAAmB,UAAnB,GAAgCA,OAAO,EAAvC,GAA4CA,OAlBjD,CADH,GAqBG,IAvBR,CADJ,CAAA;AA2BH;;;;"}
@@ -1,4 +1,4 @@
1
1
  var modules_95f1407a = {"tooltip":"_487c82cd"};
2
2
 
3
- export default modules_95f1407a;
3
+ export { modules_95f1407a as default };
4
4
  //# sourceMappingURL=tooltip.module.css.js.map
@@ -1,4 +1,4 @@
1
- import { useRef } from 'react';
1
+ import * as React from 'react';
2
2
 
3
3
  let uid = 0;
4
4
 
@@ -11,7 +11,7 @@ function generateElementId(prefix) {
11
11
  return prefix + "-" + num;
12
12
  }
13
13
  function useId(providedId) {
14
- const ref = useRef(providedId != null ? providedId : null);
14
+ const ref = React.useRef(providedId != null ? providedId : null);
15
15
 
16
16
  if (!ref.current) {
17
17
  ref.current = generateElementId('element');
@@ -1 +1 @@
1
- {"version":3,"file":"common-helpers.js","sources":["../../src/utils/common-helpers.ts"],"sourcesContent":["import * as React from 'react'\n\nlet uid = 0\nfunction uniqueId() {\n return uid++\n}\n\nexport function generateElementId(prefix: string): string {\n const num = uniqueId()\n return `${prefix}-${num}`\n}\n\nexport function useId(providedId?: string): string {\n const ref = React.useRef<string | null>(providedId ?? null)\n if (!ref.current) {\n ref.current = generateElementId('element')\n }\n return ref.current\n}\n"],"names":["uid","uniqueId","generateElementId","prefix","num","useId","providedId","ref","React","current"],"mappings":";;AAEA,IAAIA,GAAG,GAAG,CAAV;;AACA,SAASC,QAAT;EACI,OAAOD,GAAG,EAAV;AACH;;SAEeE,kBAAkBC;EAC9B,MAAMC,GAAG,GAAGH,QAAQ,EAApB;EACA,OAAUE,MAAV,SAAoBC,GAApB;AACH;SAEeC,MAAMC;EAClB,MAAMC,GAAG,GAAGC,MAAA,CAA4BF,UAA5B,WAA4BA,UAA5B,GAA0C,IAA1C,CAAZ;;EACA,IAAI,CAACC,GAAG,CAACE,OAAT,EAAkB;IACdF,GAAG,CAACE,OAAJ,GAAcP,iBAAiB,CAAC,SAAD,CAA/B;;;EAEJ,OAAOK,GAAG,CAACE,OAAX;AACH;;;;"}
1
+ {"version":3,"file":"common-helpers.js","sources":["../../src/utils/common-helpers.ts"],"sourcesContent":["import * as React from 'react'\n\nlet uid = 0\nfunction uniqueId() {\n return uid++\n}\n\nexport function generateElementId(prefix: string): string {\n const num = uniqueId()\n return `${prefix}-${num}`\n}\n\nexport function useId(providedId?: string): string {\n const ref = React.useRef<string | null>(providedId ?? null)\n if (!ref.current) {\n ref.current = generateElementId('element')\n }\n return ref.current\n}\n"],"names":["uid","uniqueId","generateElementId","prefix","num","useId","providedId","ref","React","useRef","current"],"mappings":";;AAEA,IAAIA,GAAG,GAAG,CAAV,CAAA;;AACA,SAASC,QAAT,GAAiB;AACb,EAAA,OAAOD,GAAG,EAAV,CAAA;AACH,CAAA;;AAEK,SAAUE,iBAAV,CAA4BC,MAA5B,EAA0C;EAC5C,MAAMC,GAAG,GAAGH,QAAQ,EAApB,CAAA;EACA,OAAUE,MAAV,SAAoBC,GAApB,CAAA;AACH,CAAA;AAEK,SAAUC,KAAV,CAAgBC,UAAhB,EAAmC;EACrC,MAAMC,GAAG,GAAGC,KAAK,CAACC,MAAN,CAA4BH,UAA5B,IAA4BA,IAAAA,GAAAA,UAA5B,GAA0C,IAA1C,CAAZ,CAAA;;AACA,EAAA,IAAI,CAACC,GAAG,CAACG,OAAT,EAAkB;AACdH,IAAAA,GAAG,CAACG,OAAJ,GAAcR,iBAAiB,CAAC,SAAD,CAA/B,CAAA;AACH,GAAA;;EACD,OAAOK,GAAG,CAACG,OAAX,CAAA;AACH;;;;"}