@trellixio/roaster-react 1.1.0 → 2.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 (815) hide show
  1. package/README.md +31 -17
  2. package/cjs/components/ActionCard/ActionCard.js +20 -4
  3. package/cjs/components/ActionCard/ActionCard.js.map +1 -1
  4. package/cjs/components/ActionCard/ActionCardGroup.js +42 -0
  5. package/cjs/components/ActionCard/ActionCardGroup.js.map +1 -0
  6. package/cjs/components/ActionList/ActionList.context.js.map +1 -1
  7. package/cjs/components/ActionList/ActionList.js +20 -23
  8. package/cjs/components/ActionList/ActionList.js.map +1 -1
  9. package/cjs/components/ActionList/components/ActionListDivider.js +6 -3
  10. package/cjs/components/ActionList/components/ActionListDivider.js.map +1 -1
  11. package/cjs/components/ActionList/components/ActionListDropdown.js +30 -15
  12. package/cjs/components/ActionList/components/ActionListDropdown.js.map +1 -1
  13. package/cjs/components/ActionList/components/ActionListGroup.js +25 -4
  14. package/cjs/components/ActionList/components/ActionListGroup.js.map +1 -1
  15. package/cjs/components/ActionList/components/ActionListItem.js +54 -4
  16. package/cjs/components/ActionList/components/ActionListItem.js.map +1 -1
  17. package/cjs/components/ActionList/components/ActionListSearch.js +67 -0
  18. package/cjs/components/ActionList/components/ActionListSearch.js.map +1 -0
  19. package/cjs/components/ActionList/components/ActionListSubmenu.js +125 -0
  20. package/cjs/components/ActionList/components/ActionListSubmenu.js.map +1 -0
  21. package/cjs/components/ActionList/components/ActionListSwitchItem.js +64 -0
  22. package/cjs/components/ActionList/components/ActionListSwitchItem.js.map +1 -0
  23. package/cjs/components/ActionList/components/ActionListTrigger.js +2 -36
  24. package/cjs/components/ActionList/components/ActionListTrigger.js.map +1 -1
  25. package/cjs/components/Alert/Alert.js +19 -2
  26. package/cjs/components/Alert/Alert.js.map +1 -1
  27. package/cjs/components/AppFrame/AppFrame.js +56 -0
  28. package/cjs/components/AppFrame/AppFrame.js.map +1 -0
  29. package/cjs/components/Avatar/Avatar.js +31 -8
  30. package/cjs/components/Avatar/Avatar.js.map +1 -1
  31. package/cjs/components/BlockCard/BlockCard.js +98 -4
  32. package/cjs/components/BlockCard/BlockCard.js.map +1 -1
  33. package/cjs/components/Button/Button.js +36 -15
  34. package/cjs/components/Button/Button.js.map +1 -1
  35. package/cjs/components/ButtonIcon/ButtonIcon.js +8 -9
  36. package/cjs/components/ButtonIcon/ButtonIcon.js.map +1 -1
  37. package/cjs/components/Chart/Chart.js +185 -0
  38. package/cjs/components/Chart/Chart.js.map +1 -0
  39. package/cjs/components/Checkbox/Checkbox.js +65 -38
  40. package/cjs/components/Checkbox/Checkbox.js.map +1 -1
  41. package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.context.js.map +1 -1
  42. package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.js +45 -11
  43. package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -1
  44. package/cjs/components/Checkbox/ChoiceText.js +49 -0
  45. package/cjs/components/Checkbox/ChoiceText.js.map +1 -0
  46. package/cjs/components/ColorField/ColorField.js +69 -18
  47. package/cjs/components/ColorField/ColorField.js.map +1 -1
  48. package/cjs/components/DatePicker/DatePicker.js +86 -48
  49. package/cjs/components/DatePicker/DatePicker.js.map +1 -1
  50. package/cjs/components/DatePicker/components/Calendar/Calendar.js +65 -35
  51. package/cjs/components/DatePicker/components/Calendar/Calendar.js.map +1 -1
  52. package/cjs/components/DatePicker/components/Day/Day.js +16 -31
  53. package/cjs/components/DatePicker/components/Day/Day.js.map +1 -1
  54. package/cjs/components/DatePicker/components/Month/Month.js +92 -29
  55. package/cjs/components/DatePicker/components/Month/Month.js.map +1 -1
  56. package/cjs/components/DatePicker/components/MonthGrid/MonthGrid.js +97 -0
  57. package/cjs/components/DatePicker/components/MonthGrid/MonthGrid.js.map +1 -0
  58. package/cjs/components/DatePicker/components/Weekday/Weekday.js +3 -15
  59. package/cjs/components/DatePicker/components/Weekday/Weekday.js.map +1 -1
  60. package/cjs/components/DatePicker/utils/index.js +43 -25
  61. package/cjs/components/DatePicker/utils/index.js.map +1 -1
  62. package/cjs/components/DescriptiveList/DescriptiveList.js +14 -5
  63. package/cjs/components/DescriptiveList/DescriptiveList.js.map +1 -1
  64. package/cjs/components/DescriptiveList/DescriptiveListItem.js +15 -3
  65. package/cjs/components/DescriptiveList/DescriptiveListItem.js.map +1 -1
  66. package/cjs/components/DropdownCard/DropdownCard.context.js.map +1 -1
  67. package/cjs/components/DropdownCard/DropdownCard.js +17 -22
  68. package/cjs/components/DropdownCard/DropdownCard.js.map +1 -1
  69. package/cjs/components/DropdownCard/components/DropdownCardActions.js +5 -3
  70. package/cjs/components/DropdownCard/components/DropdownCardActions.js.map +1 -1
  71. package/cjs/components/DropdownCard/components/DropdownCardContent.js +5 -3
  72. package/cjs/components/DropdownCard/components/DropdownCardContent.js.map +1 -1
  73. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js +18 -13
  74. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  75. package/cjs/components/DropdownCard/components/DropdownCardTabs.js +136 -0
  76. package/cjs/components/DropdownCard/components/DropdownCardTabs.js.map +1 -0
  77. package/cjs/components/DropdownCard/components/DropdownCardTrigger.js +2 -34
  78. package/cjs/components/DropdownCard/components/DropdownCardTrigger.js.map +1 -1
  79. package/cjs/components/Field/Field.js +27 -0
  80. package/cjs/components/Field/Field.js.map +1 -0
  81. package/cjs/components/FileField/FileField.js +64 -24
  82. package/cjs/components/FileField/FileField.js.map +1 -1
  83. package/cjs/components/FormActions/FormActions.js +27 -0
  84. package/cjs/components/FormActions/FormActions.js.map +1 -0
  85. package/cjs/components/HyperlinkCard/HyperlinkCard.js +22 -6
  86. package/cjs/components/HyperlinkCard/HyperlinkCard.js.map +1 -1
  87. package/cjs/components/Icon/Icon.js +10 -12
  88. package/cjs/components/Icon/Icon.js.map +1 -1
  89. package/cjs/components/IconBadge/IconBadge.js +40 -0
  90. package/cjs/components/IconBadge/IconBadge.js.map +1 -0
  91. package/cjs/components/Loader/Loader.js +35 -2
  92. package/cjs/components/Loader/Loader.js.map +1 -1
  93. package/cjs/components/Modal/Modal.js +91 -4
  94. package/cjs/components/Modal/Modal.js.map +1 -1
  95. package/cjs/components/Modal/ModalProvider/ModalProviderFooter.js +7 -4
  96. package/cjs/components/Modal/ModalProvider/ModalProviderFooter.js.map +1 -1
  97. package/cjs/components/Modal/ModalProvider/index.js +16 -17
  98. package/cjs/components/Modal/ModalProvider/index.js.map +1 -1
  99. package/cjs/components/Modal/utils/reducer.js +4 -1
  100. package/cjs/components/Modal/utils/reducer.js.map +1 -1
  101. package/cjs/components/Modal/utils/useModal.js +1 -1
  102. package/cjs/components/Modal/utils/useModal.js.map +1 -1
  103. package/cjs/components/Page/Breadcrumbs.js +43 -0
  104. package/cjs/components/Page/Breadcrumbs.js.map +1 -0
  105. package/cjs/components/Page/Page.js +73 -8
  106. package/cjs/components/Page/Page.js.map +1 -1
  107. package/cjs/components/Pagination/Pagination.js +23 -12
  108. package/cjs/components/Pagination/Pagination.js.map +1 -1
  109. package/cjs/components/Progress/Progress.js +48 -3
  110. package/cjs/components/Progress/Progress.js.map +1 -1
  111. package/cjs/components/Radio/Radio.js +35 -25
  112. package/cjs/components/Radio/Radio.js.map +1 -1
  113. package/cjs/components/Radio/RadioGroup/RadioGroup.context.js.map +1 -1
  114. package/cjs/components/Radio/RadioGroup/RadioGroup.js +37 -24
  115. package/cjs/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
  116. package/cjs/components/RangeField/RangeField.js +31 -27
  117. package/cjs/components/RangeField/RangeField.js.map +1 -1
  118. package/cjs/components/Select/Select.js +75 -31
  119. package/cjs/components/Select/Select.js.map +1 -1
  120. package/cjs/components/Sidebar/Sidebar.js +122 -110
  121. package/cjs/components/Sidebar/Sidebar.js.map +1 -1
  122. package/cjs/components/Sidebar/components/Back.js +38 -0
  123. package/cjs/components/Sidebar/components/Back.js.map +1 -0
  124. package/cjs/components/Sidebar/components/Menu.js +17 -6
  125. package/cjs/components/Sidebar/components/Menu.js.map +1 -1
  126. package/cjs/components/Sidebar/components/MenuItem.js +37 -6
  127. package/cjs/components/Sidebar/components/MenuItem.js.map +1 -1
  128. package/cjs/components/Sidebar/components/Section.js +15 -3
  129. package/cjs/components/Sidebar/components/Section.js.map +1 -1
  130. package/cjs/components/Sidebar/components/SubMenu.js +15 -2
  131. package/cjs/components/Sidebar/components/SubMenu.js.map +1 -1
  132. package/cjs/components/Spinner/Spinner.js +20 -2
  133. package/cjs/components/Spinner/Spinner.js.map +1 -1
  134. package/cjs/components/StatCard/StatCard.js +47 -10
  135. package/cjs/components/StatCard/StatCard.js.map +1 -1
  136. package/cjs/components/Switch/Switch.js +42 -20
  137. package/cjs/components/Switch/Switch.js.map +1 -1
  138. package/cjs/components/Table/Table.js +95 -31
  139. package/cjs/components/Table/Table.js.map +1 -1
  140. package/cjs/components/Table/components/Checkbox/index.js +8 -8
  141. package/cjs/components/Table/components/Checkbox/index.js.map +1 -1
  142. package/cjs/components/Table/components/TableBody.js +3 -3
  143. package/cjs/components/Table/components/TableBody.js.map +1 -1
  144. package/cjs/components/Table/components/TableCell.js +3 -4
  145. package/cjs/components/Table/components/TableCell.js.map +1 -1
  146. package/cjs/components/Table/components/TableGroup.js +30 -0
  147. package/cjs/components/Table/components/TableGroup.js.map +1 -0
  148. package/cjs/components/Table/components/TableHead.js +19 -16
  149. package/cjs/components/Table/components/TableHead.js.map +1 -1
  150. package/cjs/components/Table/components/TableHeadCell.js +23 -5
  151. package/cjs/components/Table/components/TableHeadCell.js.map +1 -1
  152. package/cjs/components/Table/components/TablePagination.js +6 -16
  153. package/cjs/components/Table/components/TablePagination.js.map +1 -1
  154. package/cjs/components/Table/components/TableProvider/TableProvider.js +4 -4
  155. package/cjs/components/Table/components/TableProvider/TableProvider.js.map +1 -1
  156. package/cjs/components/Table/components/TableRow.js +12 -9
  157. package/cjs/components/Table/components/TableRow.js.map +1 -1
  158. package/cjs/components/Table/labels.js +34 -0
  159. package/cjs/components/Table/labels.js.map +1 -0
  160. package/cjs/components/Table/utils/rows/context.js.map +1 -1
  161. package/cjs/components/Table/utils/table/context.js.map +1 -1
  162. package/cjs/components/Table/utils/table/hooks.js +3 -3
  163. package/cjs/components/Table/utils/table/hooks.js.map +1 -1
  164. package/cjs/components/Table/utils/table/types.js +0 -7
  165. package/cjs/components/Table/utils/table/types.js.map +1 -1
  166. package/cjs/components/Table/utils/useSelectableResourceState/index.js +4 -5
  167. package/cjs/components/Table/utils/useSelectableResourceState/index.js.map +1 -1
  168. package/cjs/components/Tag/Tag.js +36 -5
  169. package/cjs/components/Tag/Tag.js.map +1 -1
  170. package/cjs/components/Tag/TagGroup.js +3 -2
  171. package/cjs/components/Tag/TagGroup.js.map +1 -1
  172. package/cjs/components/TextField/TextField.js +41 -38
  173. package/cjs/components/TextField/TextField.js.map +1 -1
  174. package/cjs/components/Textarea/Textarea.js +10 -26
  175. package/cjs/components/Textarea/Textarea.js.map +1 -1
  176. package/cjs/components/Thumbnail/Thumbnail.js +22 -8
  177. package/cjs/components/Thumbnail/Thumbnail.js.map +1 -1
  178. package/cjs/components/Timeline/Timeline.js +40 -0
  179. package/cjs/components/Timeline/Timeline.js.map +1 -0
  180. package/cjs/components/Timeline/TimelineGroup.js +42 -0
  181. package/cjs/components/Timeline/TimelineGroup.js.map +1 -0
  182. package/cjs/components/Timeline/TimelineItem.js +38 -0
  183. package/cjs/components/Timeline/TimelineItem.js.map +1 -0
  184. package/cjs/components/Toast/Toast.js +18 -2
  185. package/cjs/components/Toast/Toast.js.map +1 -1
  186. package/cjs/components/Toast/Toasts.context.js +31 -3
  187. package/cjs/components/Toast/Toasts.context.js.map +1 -1
  188. package/cjs/components/Toast/ToastsContainer/index.js +43 -19
  189. package/cjs/components/Toast/ToastsContainer/index.js.map +1 -1
  190. package/cjs/components/Toast/ToastsProvider/index.js +11 -15
  191. package/cjs/components/Toast/ToastsProvider/index.js.map +1 -1
  192. package/cjs/components/Toast/store.js +49 -0
  193. package/cjs/components/Toast/store.js.map +1 -0
  194. package/cjs/components/Tooltip/Tooltip.js +34 -53
  195. package/cjs/components/Tooltip/Tooltip.js.map +1 -1
  196. package/cjs/components/Tooltip/TooltipCallout.js +60 -0
  197. package/cjs/components/Tooltip/TooltipCallout.js.map +1 -0
  198. package/cjs/components/Tooltip/useTooltip.js +11 -45
  199. package/cjs/components/Tooltip/useTooltip.js.map +1 -1
  200. package/cjs/components/Visualizer/Visualizer.js +70 -10
  201. package/cjs/components/Visualizer/Visualizer.js.map +1 -1
  202. package/cjs/index.js +68 -66
  203. package/cjs/index.js.map +1 -1
  204. package/cjs/tokens/tokens.js +1532 -0
  205. package/cjs/tokens/tokens.js.map +1 -0
  206. package/cjs/utils/Slot/index.js +52 -0
  207. package/cjs/utils/Slot/index.js.map +1 -0
  208. package/cjs/utils/classNames/index.js +3 -3
  209. package/cjs/utils/classNames/index.js.map +1 -1
  210. package/cjs/utils/getElementRef/index.js +16 -0
  211. package/cjs/utils/getElementRef/index.js.map +1 -0
  212. package/cjs/utils/guid/index.js.map +1 -1
  213. package/cjs/utils/toPercent/index.js +9 -0
  214. package/cjs/utils/toPercent/index.js.map +1 -0
  215. package/cjs/utils/useControllableState/index.js +39 -0
  216. package/cjs/utils/useControllableState/index.js.map +1 -0
  217. package/cjs/utils/useDropdown/DropdownTrigger.js +33 -0
  218. package/cjs/utils/useDropdown/DropdownTrigger.js.map +1 -0
  219. package/cjs/utils/useDropdown/index.js +54 -23
  220. package/cjs/utils/useDropdown/index.js.map +1 -1
  221. package/cjs/utils/useImageFallback/index.js +26 -0
  222. package/cjs/utils/useImageFallback/index.js.map +1 -0
  223. package/cjs/utils/useUid/index.js.map +1 -1
  224. package/esm/components/ActionCard/ActionCard.js +20 -4
  225. package/esm/components/ActionCard/ActionCard.js.map +1 -1
  226. package/esm/components/ActionCard/ActionCardGroup.js +26 -0
  227. package/esm/components/ActionCard/ActionCardGroup.js.map +1 -0
  228. package/esm/components/ActionList/ActionList.context.js.map +1 -1
  229. package/esm/components/ActionList/ActionList.js +21 -11
  230. package/esm/components/ActionList/ActionList.js.map +1 -1
  231. package/esm/components/ActionList/components/ActionListDivider.js +6 -3
  232. package/esm/components/ActionList/components/ActionListDivider.js.map +1 -1
  233. package/esm/components/ActionList/components/ActionListDropdown.js +31 -16
  234. package/esm/components/ActionList/components/ActionListDropdown.js.map +1 -1
  235. package/esm/components/ActionList/components/ActionListGroup.js +24 -3
  236. package/esm/components/ActionList/components/ActionListGroup.js.map +1 -1
  237. package/esm/components/ActionList/components/ActionListItem.js +53 -3
  238. package/esm/components/ActionList/components/ActionListItem.js.map +1 -1
  239. package/esm/components/ActionList/components/ActionListSearch.js +52 -0
  240. package/esm/components/ActionList/components/ActionListSearch.js.map +1 -0
  241. package/esm/components/ActionList/components/ActionListSubmenu.js +110 -0
  242. package/esm/components/ActionList/components/ActionListSubmenu.js.map +1 -0
  243. package/esm/components/ActionList/components/ActionListSwitchItem.js +49 -0
  244. package/esm/components/ActionList/components/ActionListSwitchItem.js.map +1 -0
  245. package/esm/components/ActionList/components/ActionListTrigger.js +2 -23
  246. package/esm/components/ActionList/components/ActionListTrigger.js.map +1 -1
  247. package/esm/components/Alert/Alert.js +19 -2
  248. package/esm/components/Alert/Alert.js.map +1 -1
  249. package/esm/components/AppFrame/AppFrame.js +37 -0
  250. package/esm/components/AppFrame/AppFrame.js.map +1 -0
  251. package/esm/components/Avatar/Avatar.js +31 -8
  252. package/esm/components/Avatar/Avatar.js.map +1 -1
  253. package/esm/components/BlockCard/BlockCard.js +98 -4
  254. package/esm/components/BlockCard/BlockCard.js.map +1 -1
  255. package/esm/components/Button/Button.js +36 -15
  256. package/esm/components/Button/Button.js.map +1 -1
  257. package/esm/components/ButtonIcon/ButtonIcon.js +8 -9
  258. package/esm/components/ButtonIcon/ButtonIcon.js.map +1 -1
  259. package/esm/components/Chart/Chart.js +170 -0
  260. package/esm/components/Chart/Chart.js.map +1 -0
  261. package/esm/components/Checkbox/Checkbox.js +64 -37
  262. package/esm/components/Checkbox/Checkbox.js.map +1 -1
  263. package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.context.js.map +1 -1
  264. package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.js +45 -11
  265. package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -1
  266. package/esm/components/Checkbox/ChoiceText.js +33 -0
  267. package/esm/components/Checkbox/ChoiceText.js.map +1 -0
  268. package/esm/components/ColorField/ColorField.js +69 -18
  269. package/esm/components/ColorField/ColorField.js.map +1 -1
  270. package/esm/components/DatePicker/DatePicker.js +86 -48
  271. package/esm/components/DatePicker/DatePicker.js.map +1 -1
  272. package/esm/components/DatePicker/components/Calendar/Calendar.js +60 -18
  273. package/esm/components/DatePicker/components/Calendar/Calendar.js.map +1 -1
  274. package/esm/components/DatePicker/components/Day/Day.js +18 -20
  275. package/esm/components/DatePicker/components/Day/Day.js.map +1 -1
  276. package/esm/components/DatePicker/components/Month/Month.js +93 -30
  277. package/esm/components/DatePicker/components/Month/Month.js.map +1 -1
  278. package/esm/components/DatePicker/components/MonthGrid/MonthGrid.js +82 -0
  279. package/esm/components/DatePicker/components/MonthGrid/MonthGrid.js.map +1 -0
  280. package/esm/components/DatePicker/components/Weekday/Weekday.js +4 -3
  281. package/esm/components/DatePicker/components/Weekday/Weekday.js.map +1 -1
  282. package/esm/components/DatePicker/utils/index.js +37 -25
  283. package/esm/components/DatePicker/utils/index.js.map +1 -1
  284. package/esm/components/DescriptiveList/DescriptiveList.js +14 -5
  285. package/esm/components/DescriptiveList/DescriptiveList.js.map +1 -1
  286. package/esm/components/DescriptiveList/DescriptiveListItem.js +15 -3
  287. package/esm/components/DescriptiveList/DescriptiveListItem.js.map +1 -1
  288. package/esm/components/DropdownCard/DropdownCard.context.js.map +1 -1
  289. package/esm/components/DropdownCard/DropdownCard.js +18 -10
  290. package/esm/components/DropdownCard/DropdownCard.js.map +1 -1
  291. package/esm/components/DropdownCard/components/DropdownCardActions.js +5 -3
  292. package/esm/components/DropdownCard/components/DropdownCardActions.js.map +1 -1
  293. package/esm/components/DropdownCard/components/DropdownCardContent.js +5 -3
  294. package/esm/components/DropdownCard/components/DropdownCardContent.js.map +1 -1
  295. package/esm/components/DropdownCard/components/DropdownCardDropdown.js +19 -14
  296. package/esm/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  297. package/esm/components/DropdownCard/components/DropdownCardTabs.js +118 -0
  298. package/esm/components/DropdownCard/components/DropdownCardTabs.js.map +1 -0
  299. package/esm/components/DropdownCard/components/DropdownCardTrigger.js +2 -21
  300. package/esm/components/DropdownCard/components/DropdownCardTrigger.js.map +1 -1
  301. package/esm/components/Field/Field.js +24 -0
  302. package/esm/components/Field/Field.js.map +1 -0
  303. package/esm/components/FileField/FileField.js +64 -24
  304. package/esm/components/FileField/FileField.js.map +1 -1
  305. package/esm/components/FormActions/FormActions.js +12 -0
  306. package/esm/components/FormActions/FormActions.js.map +1 -0
  307. package/esm/components/HyperlinkCard/HyperlinkCard.js +10 -7
  308. package/esm/components/HyperlinkCard/HyperlinkCard.js.map +1 -1
  309. package/esm/components/Icon/Icon.js +10 -12
  310. package/esm/components/Icon/Icon.js.map +1 -1
  311. package/esm/components/IconBadge/IconBadge.js +25 -0
  312. package/esm/components/IconBadge/IconBadge.js.map +1 -0
  313. package/esm/components/Loader/Loader.js +24 -4
  314. package/esm/components/Loader/Loader.js.map +1 -1
  315. package/esm/components/Modal/Modal.js +90 -3
  316. package/esm/components/Modal/Modal.js.map +1 -1
  317. package/esm/components/Modal/ModalProvider/ModalProviderFooter.js +7 -4
  318. package/esm/components/Modal/ModalProvider/ModalProviderFooter.js.map +1 -1
  319. package/esm/components/Modal/ModalProvider/index.js +16 -17
  320. package/esm/components/Modal/ModalProvider/index.js.map +1 -1
  321. package/esm/components/Modal/utils/reducer.js +4 -1
  322. package/esm/components/Modal/utils/reducer.js.map +1 -1
  323. package/esm/components/Modal/utils/useModal.js +1 -1
  324. package/esm/components/Modal/utils/useModal.js.map +1 -1
  325. package/esm/components/Page/Breadcrumbs.js +28 -0
  326. package/esm/components/Page/Breadcrumbs.js.map +1 -0
  327. package/esm/components/Page/Page.js +73 -9
  328. package/esm/components/Page/Page.js.map +1 -1
  329. package/esm/components/Pagination/Pagination.js +23 -12
  330. package/esm/components/Pagination/Pagination.js.map +1 -1
  331. package/esm/components/Progress/Progress.js +35 -3
  332. package/esm/components/Progress/Progress.js.map +1 -1
  333. package/esm/components/Radio/Radio.js +35 -25
  334. package/esm/components/Radio/Radio.js.map +1 -1
  335. package/esm/components/Radio/RadioGroup/RadioGroup.context.js.map +1 -1
  336. package/esm/components/Radio/RadioGroup/RadioGroup.js +37 -24
  337. package/esm/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
  338. package/esm/components/RangeField/RangeField.js +31 -27
  339. package/esm/components/RangeField/RangeField.js.map +1 -1
  340. package/esm/components/Select/Select.js +75 -31
  341. package/esm/components/Select/Select.js.map +1 -1
  342. package/esm/components/Sidebar/Sidebar.js +121 -109
  343. package/esm/components/Sidebar/Sidebar.js.map +1 -1
  344. package/esm/components/Sidebar/components/Back.js +23 -0
  345. package/esm/components/Sidebar/components/Back.js.map +1 -0
  346. package/esm/components/Sidebar/components/Menu.js +5 -7
  347. package/esm/components/Sidebar/components/Menu.js.map +1 -1
  348. package/esm/components/Sidebar/components/MenuItem.js +25 -7
  349. package/esm/components/Sidebar/components/MenuItem.js.map +1 -1
  350. package/esm/components/Sidebar/components/Section.js +4 -5
  351. package/esm/components/Sidebar/components/Section.js.map +1 -1
  352. package/esm/components/Sidebar/components/SubMenu.js +4 -4
  353. package/esm/components/Sidebar/components/SubMenu.js.map +1 -1
  354. package/esm/components/Spinner/Spinner.js +9 -4
  355. package/esm/components/Spinner/Spinner.js.map +1 -1
  356. package/esm/components/StatCard/StatCard.js +46 -10
  357. package/esm/components/StatCard/StatCard.js.map +1 -1
  358. package/esm/components/Switch/Switch.js +42 -20
  359. package/esm/components/Switch/Switch.js.map +1 -1
  360. package/esm/components/Table/Table.js +95 -31
  361. package/esm/components/Table/Table.js.map +1 -1
  362. package/esm/components/Table/components/Checkbox/index.js +8 -8
  363. package/esm/components/Table/components/Checkbox/index.js.map +1 -1
  364. package/esm/components/Table/components/TableBody.js +3 -3
  365. package/esm/components/Table/components/TableBody.js.map +1 -1
  366. package/esm/components/Table/components/TableCell.js +3 -4
  367. package/esm/components/Table/components/TableCell.js.map +1 -1
  368. package/esm/components/Table/components/TableGroup.js +15 -0
  369. package/esm/components/Table/components/TableGroup.js.map +1 -0
  370. package/esm/components/Table/components/TableHead.js +19 -16
  371. package/esm/components/Table/components/TableHead.js.map +1 -1
  372. package/esm/components/Table/components/TableHeadCell.js +23 -6
  373. package/esm/components/Table/components/TableHeadCell.js.map +1 -1
  374. package/esm/components/Table/components/TablePagination.js +6 -3
  375. package/esm/components/Table/components/TablePagination.js.map +1 -1
  376. package/esm/components/Table/components/TableProvider/TableProvider.js +5 -5
  377. package/esm/components/Table/components/TableProvider/TableProvider.js.map +1 -1
  378. package/esm/components/Table/components/TableRow.js +11 -8
  379. package/esm/components/Table/components/TableRow.js.map +1 -1
  380. package/esm/components/Table/labels.js +18 -0
  381. package/esm/components/Table/labels.js.map +1 -0
  382. package/esm/components/Table/utils/rows/context.js.map +1 -1
  383. package/esm/components/Table/utils/table/context.js.map +1 -1
  384. package/esm/components/Table/utils/table/hooks.js +4 -4
  385. package/esm/components/Table/utils/table/hooks.js.map +1 -1
  386. package/esm/components/Table/utils/table/types.js +1 -7
  387. package/esm/components/Table/utils/table/types.js.map +1 -1
  388. package/esm/components/Table/utils/useSelectableResourceState/index.js +4 -5
  389. package/esm/components/Table/utils/useSelectableResourceState/index.js.map +1 -1
  390. package/esm/components/Tag/Tag.js +36 -5
  391. package/esm/components/Tag/Tag.js.map +1 -1
  392. package/esm/components/Tag/TagGroup.js +3 -2
  393. package/esm/components/Tag/TagGroup.js.map +1 -1
  394. package/esm/components/TextField/TextField.js +41 -38
  395. package/esm/components/TextField/TextField.js.map +1 -1
  396. package/esm/components/Textarea/Textarea.js +10 -26
  397. package/esm/components/Textarea/Textarea.js.map +1 -1
  398. package/esm/components/Thumbnail/Thumbnail.js +22 -8
  399. package/esm/components/Thumbnail/Thumbnail.js.map +1 -1
  400. package/esm/components/Timeline/Timeline.js +25 -0
  401. package/esm/components/Timeline/Timeline.js.map +1 -0
  402. package/esm/components/Timeline/TimelineGroup.js +27 -0
  403. package/esm/components/Timeline/TimelineGroup.js.map +1 -0
  404. package/esm/components/Timeline/TimelineItem.js +23 -0
  405. package/esm/components/Timeline/TimelineItem.js.map +1 -0
  406. package/esm/components/Toast/Toast.js +18 -2
  407. package/esm/components/Toast/Toast.js.map +1 -1
  408. package/esm/components/Toast/Toasts.context.js +17 -4
  409. package/esm/components/Toast/Toasts.context.js.map +1 -1
  410. package/esm/components/Toast/ToastsContainer/index.js +44 -20
  411. package/esm/components/Toast/ToastsContainer/index.js.map +1 -1
  412. package/esm/components/Toast/ToastsProvider/index.js +10 -14
  413. package/esm/components/Toast/ToastsProvider/index.js.map +1 -1
  414. package/esm/components/Toast/store.js +47 -0
  415. package/esm/components/Toast/store.js.map +1 -0
  416. package/esm/components/Tooltip/Tooltip.js +34 -53
  417. package/esm/components/Tooltip/Tooltip.js.map +1 -1
  418. package/esm/components/Tooltip/TooltipCallout.js +45 -0
  419. package/esm/components/Tooltip/TooltipCallout.js.map +1 -0
  420. package/esm/components/Tooltip/useTooltip.js +12 -33
  421. package/esm/components/Tooltip/useTooltip.js.map +1 -1
  422. package/esm/components/Visualizer/Visualizer.js +69 -9
  423. package/esm/components/Visualizer/Visualizer.js.map +1 -1
  424. package/esm/index.js +31 -27
  425. package/esm/index.js.map +1 -1
  426. package/esm/tokens/tokens.js +1530 -0
  427. package/esm/tokens/tokens.js.map +1 -0
  428. package/esm/utils/Slot/index.js +37 -0
  429. package/esm/utils/Slot/index.js.map +1 -0
  430. package/esm/utils/classNames/index.js +3 -3
  431. package/esm/utils/classNames/index.js.map +1 -1
  432. package/esm/utils/getElementRef/index.js +14 -0
  433. package/esm/utils/getElementRef/index.js.map +1 -0
  434. package/esm/utils/guid/index.js.map +1 -1
  435. package/esm/utils/toPercent/index.js +7 -0
  436. package/esm/utils/toPercent/index.js.map +1 -0
  437. package/esm/utils/useControllableState/index.js +24 -0
  438. package/esm/utils/useControllableState/index.js.map +1 -0
  439. package/esm/utils/useDropdown/DropdownTrigger.js +18 -0
  440. package/esm/utils/useDropdown/DropdownTrigger.js.map +1 -0
  441. package/esm/utils/useDropdown/index.js +55 -25
  442. package/esm/utils/useDropdown/index.js.map +1 -1
  443. package/esm/utils/useImageFallback/index.js +11 -0
  444. package/esm/utils/useImageFallback/index.js.map +1 -0
  445. package/esm/utils/useUid/index.js.map +1 -1
  446. package/fonts/dm-sans/LICENSE +93 -0
  447. package/fonts/dm-sans/dm-sans-latin-400-italic.woff2 +0 -0
  448. package/fonts/dm-sans/dm-sans-latin-400-normal.woff2 +0 -0
  449. package/fonts/dm-sans/dm-sans-latin-700-italic.woff2 +0 -0
  450. package/fonts/dm-sans/dm-sans-latin-700-normal.woff2 +0 -0
  451. package/fonts/inter/LICENSE +93 -0
  452. package/fonts/inter/inter-latin-opsz-italic.woff2 +0 -0
  453. package/fonts/inter/inter-latin-opsz-normal.woff2 +0 -0
  454. package/fonts/roboto-mono/LICENSE +93 -0
  455. package/fonts/roboto-mono/roboto-mono-latin-wght-normal.woff2 +0 -0
  456. package/lib/components/ActionCard/ActionCard.d.ts +14 -13
  457. package/lib/components/ActionCard/ActionCard.d.ts.map +1 -1
  458. package/lib/components/ActionCard/ActionCardGroup.d.ts +22 -0
  459. package/lib/components/ActionCard/ActionCardGroup.d.ts.map +1 -0
  460. package/lib/components/ActionCard/index.d.ts +1 -0
  461. package/lib/components/ActionCard/index.d.ts.map +1 -1
  462. package/lib/components/ActionList/ActionList.context.d.ts +6 -3
  463. package/lib/components/ActionList/ActionList.context.d.ts.map +1 -1
  464. package/lib/components/ActionList/ActionList.d.ts +18 -18
  465. package/lib/components/ActionList/ActionList.d.ts.map +1 -1
  466. package/lib/components/ActionList/components/ActionListDivider.d.ts +4 -5
  467. package/lib/components/ActionList/components/ActionListDivider.d.ts.map +1 -1
  468. package/lib/components/ActionList/components/ActionListDropdown.d.ts +4 -1
  469. package/lib/components/ActionList/components/ActionListDropdown.d.ts.map +1 -1
  470. package/lib/components/ActionList/components/ActionListGroup.d.ts +7 -5
  471. package/lib/components/ActionList/components/ActionListGroup.d.ts.map +1 -1
  472. package/lib/components/ActionList/components/ActionListItem.d.ts +32 -7
  473. package/lib/components/ActionList/components/ActionListItem.d.ts.map +1 -1
  474. package/lib/components/ActionList/components/ActionListSearch.d.ts +21 -0
  475. package/lib/components/ActionList/components/ActionListSearch.d.ts.map +1 -0
  476. package/lib/components/ActionList/components/ActionListSubmenu.d.ts +22 -0
  477. package/lib/components/ActionList/components/ActionListSubmenu.d.ts.map +1 -0
  478. package/lib/components/ActionList/components/ActionListSwitchItem.d.ts +17 -0
  479. package/lib/components/ActionList/components/ActionListSwitchItem.d.ts.map +1 -0
  480. package/lib/components/ActionList/components/ActionListTrigger.d.ts +4 -6
  481. package/lib/components/ActionList/components/ActionListTrigger.d.ts.map +1 -1
  482. package/lib/components/Alert/Alert.d.ts +25 -11
  483. package/lib/components/Alert/Alert.d.ts.map +1 -1
  484. package/lib/components/AppFrame/AppFrame.d.ts +48 -0
  485. package/lib/components/AppFrame/AppFrame.d.ts.map +1 -0
  486. package/lib/components/AppFrame/index.d.ts +3 -0
  487. package/lib/components/AppFrame/index.d.ts.map +1 -0
  488. package/lib/components/Avatar/Avatar.d.ts +20 -8
  489. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  490. package/lib/components/BlockCard/BlockCard.d.ts +77 -11
  491. package/lib/components/BlockCard/BlockCard.d.ts.map +1 -1
  492. package/lib/components/BlockCard/index.d.ts +1 -1
  493. package/lib/components/BlockCard/index.d.ts.map +1 -1
  494. package/lib/components/Button/Button.d.ts +45 -26
  495. package/lib/components/Button/Button.d.ts.map +1 -1
  496. package/lib/components/ButtonIcon/ButtonIcon.d.ts +18 -17
  497. package/lib/components/ButtonIcon/ButtonIcon.d.ts.map +1 -1
  498. package/lib/components/Chart/Chart.d.ts +142 -0
  499. package/lib/components/Chart/Chart.d.ts.map +1 -0
  500. package/lib/components/Chart/index.d.ts +3 -0
  501. package/lib/components/Chart/index.d.ts.map +1 -0
  502. package/lib/components/Checkbox/Checkbox.d.ts +25 -33
  503. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  504. package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.context.d.ts +2 -0
  505. package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.context.d.ts.map +1 -1
  506. package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.d.ts +23 -5
  507. package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.d.ts.map +1 -1
  508. package/lib/components/Checkbox/ChoiceText.d.ts +17 -0
  509. package/lib/components/Checkbox/ChoiceText.d.ts.map +1 -0
  510. package/lib/components/Checkbox/index.d.ts +0 -1
  511. package/lib/components/Checkbox/index.d.ts.map +1 -1
  512. package/lib/components/ColorField/ColorField.d.ts +15 -13
  513. package/lib/components/ColorField/ColorField.d.ts.map +1 -1
  514. package/lib/components/ColorField/index.d.ts +1 -1
  515. package/lib/components/ColorField/index.d.ts.map +1 -1
  516. package/lib/components/DatePicker/DatePicker.d.ts +13 -5
  517. package/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
  518. package/lib/components/DatePicker/components/Calendar/Calendar.d.ts +24 -3
  519. package/lib/components/DatePicker/components/Calendar/Calendar.d.ts.map +1 -1
  520. package/lib/components/DatePicker/components/Day/Day.d.ts +11 -10
  521. package/lib/components/DatePicker/components/Day/Day.d.ts.map +1 -1
  522. package/lib/components/DatePicker/components/Month/Month.d.ts +21 -17
  523. package/lib/components/DatePicker/components/Month/Month.d.ts.map +1 -1
  524. package/lib/components/DatePicker/components/MonthGrid/MonthGrid.d.ts +32 -0
  525. package/lib/components/DatePicker/components/MonthGrid/MonthGrid.d.ts.map +1 -0
  526. package/lib/components/DatePicker/components/MonthGrid/index.d.ts +3 -0
  527. package/lib/components/DatePicker/components/MonthGrid/index.d.ts.map +1 -0
  528. package/lib/components/DatePicker/components/Weekday/Weekday.d.ts +4 -3
  529. package/lib/components/DatePicker/components/Weekday/Weekday.d.ts.map +1 -1
  530. package/lib/components/DatePicker/components/index.d.ts +1 -0
  531. package/lib/components/DatePicker/components/index.d.ts.map +1 -1
  532. package/lib/components/DatePicker/utils/index.d.ts +339 -17
  533. package/lib/components/DatePicker/utils/index.d.ts.map +1 -1
  534. package/lib/components/DatePicker/utils/types.d.ts +4 -2
  535. package/lib/components/DatePicker/utils/types.d.ts.map +1 -1
  536. package/lib/components/DescriptiveList/DescriptiveList.d.ts +10 -11
  537. package/lib/components/DescriptiveList/DescriptiveList.d.ts.map +1 -1
  538. package/lib/components/DescriptiveList/DescriptiveListItem.d.ts +10 -4
  539. package/lib/components/DescriptiveList/DescriptiveListItem.d.ts.map +1 -1
  540. package/lib/components/DropdownCard/DropdownCard.context.d.ts +5 -2
  541. package/lib/components/DropdownCard/DropdownCard.context.d.ts.map +1 -1
  542. package/lib/components/DropdownCard/DropdownCard.d.ts +15 -13
  543. package/lib/components/DropdownCard/DropdownCard.d.ts.map +1 -1
  544. package/lib/components/DropdownCard/components/DropdownCardActions.d.ts +4 -3
  545. package/lib/components/DropdownCard/components/DropdownCardActions.d.ts.map +1 -1
  546. package/lib/components/DropdownCard/components/DropdownCardContent.d.ts +4 -3
  547. package/lib/components/DropdownCard/components/DropdownCardContent.d.ts.map +1 -1
  548. package/lib/components/DropdownCard/components/DropdownCardDropdown.d.ts +12 -3
  549. package/lib/components/DropdownCard/components/DropdownCardDropdown.d.ts.map +1 -1
  550. package/lib/components/DropdownCard/components/DropdownCardTabs.d.ts +44 -0
  551. package/lib/components/DropdownCard/components/DropdownCardTabs.d.ts.map +1 -0
  552. package/lib/components/DropdownCard/components/DropdownCardTrigger.d.ts +4 -6
  553. package/lib/components/DropdownCard/components/DropdownCardTrigger.d.ts.map +1 -1
  554. package/lib/components/DropdownCard/components/index.d.ts +1 -0
  555. package/lib/components/DropdownCard/components/index.d.ts.map +1 -1
  556. package/lib/components/Field/Field.d.ts +47 -0
  557. package/lib/components/Field/Field.d.ts.map +1 -0
  558. package/lib/components/Field/index.d.ts +3 -0
  559. package/lib/components/Field/index.d.ts.map +1 -0
  560. package/lib/components/FileField/FileField.d.ts +20 -11
  561. package/lib/components/FileField/FileField.d.ts.map +1 -1
  562. package/lib/components/FileField/index.d.ts +1 -1
  563. package/lib/components/FileField/index.d.ts.map +1 -1
  564. package/lib/components/FormActions/FormActions.d.ts +9 -0
  565. package/lib/components/FormActions/FormActions.d.ts.map +1 -0
  566. package/lib/components/FormActions/index.d.ts +3 -0
  567. package/lib/components/FormActions/index.d.ts.map +1 -0
  568. package/lib/components/HyperlinkCard/HyperlinkCard.d.ts +11 -8
  569. package/lib/components/HyperlinkCard/HyperlinkCard.d.ts.map +1 -1
  570. package/lib/components/Icon/Icon.d.ts +14 -13
  571. package/lib/components/Icon/Icon.d.ts.map +1 -1
  572. package/lib/components/IconBadge/IconBadge.d.ts +24 -0
  573. package/lib/components/IconBadge/IconBadge.d.ts.map +1 -0
  574. package/lib/components/IconBadge/index.d.ts +3 -0
  575. package/lib/components/IconBadge/index.d.ts.map +1 -0
  576. package/lib/components/Loader/Loader.d.ts +17 -6
  577. package/lib/components/Loader/Loader.d.ts.map +1 -1
  578. package/lib/components/Loader/index.d.ts +1 -1
  579. package/lib/components/Loader/index.d.ts.map +1 -1
  580. package/lib/components/Modal/Modal.d.ts +4 -6
  581. package/lib/components/Modal/Modal.d.ts.map +1 -1
  582. package/lib/components/Modal/ModalProvider/ModalProviderFooter.d.ts.map +1 -1
  583. package/lib/components/Modal/ModalProvider/index.d.ts.map +1 -1
  584. package/lib/components/Modal/index.d.ts +1 -1
  585. package/lib/components/Modal/index.d.ts.map +1 -1
  586. package/lib/components/Modal/types/index.d.ts +36 -15
  587. package/lib/components/Modal/types/index.d.ts.map +1 -1
  588. package/lib/components/Modal/utils/index.d.ts +0 -1
  589. package/lib/components/Modal/utils/index.d.ts.map +1 -1
  590. package/lib/components/Modal/utils/reducer.d.ts +286 -6
  591. package/lib/components/Modal/utils/reducer.d.ts.map +1 -1
  592. package/lib/components/Modal/utils/useModal.d.ts +3 -2
  593. package/lib/components/Modal/utils/useModal.d.ts.map +1 -1
  594. package/lib/components/Page/Breadcrumbs.d.ts +20 -0
  595. package/lib/components/Page/Breadcrumbs.d.ts.map +1 -0
  596. package/lib/components/Page/Page.d.ts +61 -27
  597. package/lib/components/Page/Page.d.ts.map +1 -1
  598. package/lib/components/Page/index.d.ts +3 -1
  599. package/lib/components/Page/index.d.ts.map +1 -1
  600. package/lib/components/Pagination/Pagination.d.ts +22 -20
  601. package/lib/components/Pagination/Pagination.d.ts.map +1 -1
  602. package/lib/components/Pagination/index.d.ts +1 -1
  603. package/lib/components/Pagination/index.d.ts.map +1 -1
  604. package/lib/components/Progress/Progress.d.ts +29 -6
  605. package/lib/components/Progress/Progress.d.ts.map +1 -1
  606. package/lib/components/Progress/index.d.ts +1 -1
  607. package/lib/components/Progress/index.d.ts.map +1 -1
  608. package/lib/components/Radio/Radio.d.ts +19 -33
  609. package/lib/components/Radio/Radio.d.ts.map +1 -1
  610. package/lib/components/Radio/RadioGroup/RadioGroup.context.d.ts +2 -0
  611. package/lib/components/Radio/RadioGroup/RadioGroup.context.d.ts.map +1 -1
  612. package/lib/components/Radio/RadioGroup/RadioGroup.d.ts +22 -18
  613. package/lib/components/Radio/RadioGroup/RadioGroup.d.ts.map +1 -1
  614. package/lib/components/RangeField/RangeField.d.ts +8 -15
  615. package/lib/components/RangeField/RangeField.d.ts.map +1 -1
  616. package/lib/components/Select/Select.d.ts +45 -43
  617. package/lib/components/Select/Select.d.ts.map +1 -1
  618. package/lib/components/Sidebar/Sidebar.d.ts +48 -25
  619. package/lib/components/Sidebar/Sidebar.d.ts.map +1 -1
  620. package/lib/components/Sidebar/components/Back.d.ts +14 -0
  621. package/lib/components/Sidebar/components/Back.d.ts.map +1 -0
  622. package/lib/components/Sidebar/components/Menu.d.ts +9 -14
  623. package/lib/components/Sidebar/components/Menu.d.ts.map +1 -1
  624. package/lib/components/Sidebar/components/MenuItem.d.ts +18 -15
  625. package/lib/components/Sidebar/components/MenuItem.d.ts.map +1 -1
  626. package/lib/components/Sidebar/components/Section.d.ts +6 -6
  627. package/lib/components/Sidebar/components/Section.d.ts.map +1 -1
  628. package/lib/components/Sidebar/components/SubMenu.d.ts +6 -8
  629. package/lib/components/Sidebar/components/SubMenu.d.ts.map +1 -1
  630. package/lib/components/Sidebar/index.d.ts +1 -1
  631. package/lib/components/Sidebar/index.d.ts.map +1 -1
  632. package/lib/components/Spinner/Spinner.d.ts +12 -5
  633. package/lib/components/Spinner/Spinner.d.ts.map +1 -1
  634. package/lib/components/Spinner/index.d.ts +1 -1
  635. package/lib/components/Spinner/index.d.ts.map +1 -1
  636. package/lib/components/StatCard/StatCard.d.ts +31 -11
  637. package/lib/components/StatCard/StatCard.d.ts.map +1 -1
  638. package/lib/components/StatCard/index.d.ts +1 -1
  639. package/lib/components/StatCard/index.d.ts.map +1 -1
  640. package/lib/components/Switch/Switch.d.ts +14 -15
  641. package/lib/components/Switch/Switch.d.ts.map +1 -1
  642. package/lib/components/Table/Table.d.ts +54 -25
  643. package/lib/components/Table/Table.d.ts.map +1 -1
  644. package/lib/components/Table/Table.types.d.ts +1 -1
  645. package/lib/components/Table/Table.types.d.ts.map +1 -1
  646. package/lib/components/Table/components/Checkbox/index.d.ts +7 -3
  647. package/lib/components/Table/components/Checkbox/index.d.ts.map +1 -1
  648. package/lib/components/Table/components/TableBody.d.ts +2 -2
  649. package/lib/components/Table/components/TableBody.d.ts.map +1 -1
  650. package/lib/components/Table/components/TableCell.d.ts +7 -3
  651. package/lib/components/Table/components/TableCell.d.ts.map +1 -1
  652. package/lib/components/Table/components/TableGroup.d.ts +16 -0
  653. package/lib/components/Table/components/TableGroup.d.ts.map +1 -0
  654. package/lib/components/Table/components/TableHead.d.ts +8 -2
  655. package/lib/components/Table/components/TableHead.d.ts.map +1 -1
  656. package/lib/components/Table/components/TableHeadCell.d.ts +24 -5
  657. package/lib/components/Table/components/TableHeadCell.d.ts.map +1 -1
  658. package/lib/components/Table/components/TablePagination.d.ts +3 -1
  659. package/lib/components/Table/components/TablePagination.d.ts.map +1 -1
  660. package/lib/components/Table/components/TableProvider/TableProvider.d.ts +1 -2
  661. package/lib/components/Table/components/TableProvider/TableProvider.d.ts.map +1 -1
  662. package/lib/components/Table/components/TableRow.d.ts +8 -2
  663. package/lib/components/Table/components/TableRow.d.ts.map +1 -1
  664. package/lib/components/Table/index.d.ts +3 -3
  665. package/lib/components/Table/index.d.ts.map +1 -1
  666. package/lib/components/Table/labels.d.ts +23 -0
  667. package/lib/components/Table/labels.d.ts.map +1 -0
  668. package/lib/components/Table/utils/table/types.d.ts +6 -11
  669. package/lib/components/Table/utils/table/types.d.ts.map +1 -1
  670. package/lib/components/Table/utils/useSelectableResourceState/index.d.ts +1 -2
  671. package/lib/components/Table/utils/useSelectableResourceState/index.d.ts.map +1 -1
  672. package/lib/components/Tag/Tag.d.ts +42 -15
  673. package/lib/components/Tag/Tag.d.ts.map +1 -1
  674. package/lib/components/Tag/TagGroup.d.ts +3 -3
  675. package/lib/components/Tag/TagGroup.d.ts.map +1 -1
  676. package/lib/components/Tag/index.d.ts +1 -1
  677. package/lib/components/Tag/index.d.ts.map +1 -1
  678. package/lib/components/TextField/TextField.d.ts +11 -27
  679. package/lib/components/TextField/TextField.d.ts.map +1 -1
  680. package/lib/components/Textarea/Textarea.d.ts +10 -26
  681. package/lib/components/Textarea/Textarea.d.ts.map +1 -1
  682. package/lib/components/Thumbnail/Thumbnail.d.ts +11 -7
  683. package/lib/components/Thumbnail/Thumbnail.d.ts.map +1 -1
  684. package/lib/components/Timeline/Timeline.d.ts +26 -0
  685. package/lib/components/Timeline/Timeline.d.ts.map +1 -0
  686. package/lib/components/Timeline/TimelineGroup.d.ts +15 -0
  687. package/lib/components/Timeline/TimelineGroup.d.ts.map +1 -0
  688. package/lib/components/Timeline/TimelineItem.d.ts +19 -0
  689. package/lib/components/Timeline/TimelineItem.d.ts.map +1 -0
  690. package/lib/components/Timeline/index.d.ts +5 -0
  691. package/lib/components/Timeline/index.d.ts.map +1 -0
  692. package/lib/components/Toast/Toast.d.ts +20 -10
  693. package/lib/components/Toast/Toast.d.ts.map +1 -1
  694. package/lib/components/Toast/Toasts.context.d.ts +15 -2
  695. package/lib/components/Toast/Toasts.context.d.ts.map +1 -1
  696. package/lib/components/Toast/ToastsContainer/index.d.ts.map +1 -1
  697. package/lib/components/Toast/ToastsProvider/index.d.ts +1 -3
  698. package/lib/components/Toast/ToastsProvider/index.d.ts.map +1 -1
  699. package/lib/components/Toast/index.d.ts +3 -5
  700. package/lib/components/Toast/index.d.ts.map +1 -1
  701. package/lib/components/Toast/store.d.ts +30 -0
  702. package/lib/components/Toast/store.d.ts.map +1 -0
  703. package/lib/components/Toast/types.d.ts +8 -5
  704. package/lib/components/Toast/types.d.ts.map +1 -1
  705. package/lib/components/Tooltip/Tooltip.d.ts +29 -23
  706. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  707. package/lib/components/Tooltip/TooltipCallout.d.ts +31 -0
  708. package/lib/components/Tooltip/TooltipCallout.d.ts.map +1 -0
  709. package/lib/components/Tooltip/useTooltip.d.ts +16 -27
  710. package/lib/components/Tooltip/useTooltip.d.ts.map +1 -1
  711. package/lib/components/Visualizer/Visualizer.d.ts +19 -8
  712. package/lib/components/Visualizer/Visualizer.d.ts.map +1 -1
  713. package/lib/components/Visualizer/index.d.ts +1 -1
  714. package/lib/components/Visualizer/index.d.ts.map +1 -1
  715. package/lib/index.d.ts +134 -1
  716. package/lib/index.d.ts.map +1 -1
  717. package/lib/showcase/chartData.d.ts +29 -0
  718. package/lib/showcase/chartData.d.ts.map +1 -0
  719. package/lib/tokens/tokens.d.ts +1528 -0
  720. package/lib/tokens/tokens.d.ts.map +1 -0
  721. package/lib/types.d.ts +4 -29
  722. package/lib/types.d.ts.map +1 -1
  723. package/lib/utils/Slot/index.d.ts +11 -0
  724. package/lib/utils/Slot/index.d.ts.map +1 -0
  725. package/lib/utils/classNames/index.d.ts +3 -1
  726. package/lib/utils/classNames/index.d.ts.map +1 -1
  727. package/lib/utils/getElementRef/index.d.ts +9 -0
  728. package/lib/utils/getElementRef/index.d.ts.map +1 -0
  729. package/lib/utils/index.d.ts +4 -7
  730. package/lib/utils/index.d.ts.map +1 -1
  731. package/lib/utils/toPercent/index.d.ts +3 -0
  732. package/lib/utils/toPercent/index.d.ts.map +1 -0
  733. package/lib/utils/useControllableState/index.d.ts +19 -0
  734. package/lib/utils/useControllableState/index.d.ts.map +1 -0
  735. package/lib/utils/useDropdown/DropdownTrigger.d.ts +12 -0
  736. package/lib/utils/useDropdown/DropdownTrigger.d.ts.map +1 -0
  737. package/lib/utils/useDropdown/index.d.ts +30 -6
  738. package/lib/utils/useDropdown/index.d.ts.map +1 -1
  739. package/lib/utils/useImageFallback/index.d.ts +15 -0
  740. package/lib/utils/useImageFallback/index.d.ts.map +1 -0
  741. package/package.json +19 -11
  742. package/theme.css +1 -1
  743. package/theme.css.d.ts +2 -0
  744. package/cjs/components/ActionList/useDropdown.js +0 -47
  745. package/cjs/components/ActionList/useDropdown.js.map +0 -1
  746. package/cjs/components/Modal/utils/events.js +0 -19
  747. package/cjs/components/Modal/utils/events.js.map +0 -1
  748. package/cjs/components/Toast/ToastsProvider/useToastsState/useToastsState.js +0 -55
  749. package/cjs/components/Toast/ToastsProvider/useToastsState/useToastsState.js.map +0 -1
  750. package/cjs/components/Toast/events.js +0 -20
  751. package/cjs/components/Toast/events.js.map +0 -1
  752. package/cjs/components/Visualizer/Visualizer.context.js +0 -12
  753. package/cjs/components/Visualizer/Visualizer.context.js.map +0 -1
  754. package/cjs/components/Visualizer/VisualizerMobileOpener.js +0 -28
  755. package/cjs/components/Visualizer/VisualizerMobileOpener.js.map +0 -1
  756. package/cjs/utils/createUseExternalEvents/index.js +0 -32
  757. package/cjs/utils/createUseExternalEvents/index.js.map +0 -1
  758. package/cjs/utils/useIsomorphicEffect/index.js +0 -22
  759. package/cjs/utils/useIsomorphicEffect/index.js.map +0 -1
  760. package/cjs/utils/useQueue/index.js +0 -36
  761. package/cjs/utils/useQueue/index.js.map +0 -1
  762. package/cjs/utils/useUncontrolled/index.js +0 -25
  763. package/cjs/utils/useUncontrolled/index.js.map +0 -1
  764. package/esm/components/ActionList/useDropdown.js +0 -45
  765. package/esm/components/ActionList/useDropdown.js.map +0 -1
  766. package/esm/components/Modal/utils/events.js +0 -13
  767. package/esm/components/Modal/utils/events.js.map +0 -1
  768. package/esm/components/Toast/ToastsProvider/useToastsState/useToastsState.js +0 -51
  769. package/esm/components/Toast/ToastsProvider/useToastsState/useToastsState.js.map +0 -1
  770. package/esm/components/Toast/events.js +0 -12
  771. package/esm/components/Toast/events.js.map +0 -1
  772. package/esm/components/Visualizer/Visualizer.context.js +0 -9
  773. package/esm/components/Visualizer/Visualizer.context.js.map +0 -1
  774. package/esm/components/Visualizer/VisualizerMobileOpener.js +0 -13
  775. package/esm/components/Visualizer/VisualizerMobileOpener.js.map +0 -1
  776. package/esm/utils/createUseExternalEvents/index.js +0 -30
  777. package/esm/utils/createUseExternalEvents/index.js.map +0 -1
  778. package/esm/utils/useIsomorphicEffect/index.js +0 -7
  779. package/esm/utils/useIsomorphicEffect/index.js.map +0 -1
  780. package/esm/utils/useQueue/index.js +0 -34
  781. package/esm/utils/useQueue/index.js.map +0 -1
  782. package/esm/utils/useUncontrolled/index.js +0 -23
  783. package/esm/utils/useUncontrolled/index.js.map +0 -1
  784. package/lib/components/ActionList/useDropdown.d.ts +0 -57
  785. package/lib/components/ActionList/useDropdown.d.ts.map +0 -1
  786. package/lib/components/CodeBlock/CodeBlock.d.ts +0 -16
  787. package/lib/components/CodeBlock/CodeBlock.d.ts.map +0 -1
  788. package/lib/components/CodeBlock/index.d.ts +0 -2
  789. package/lib/components/CodeBlock/index.d.ts.map +0 -1
  790. package/lib/components/Modal/utils/events.d.ts +0 -9
  791. package/lib/components/Modal/utils/events.d.ts.map +0 -1
  792. package/lib/components/Toast/ToastsProvider/useToastsState/useToastsState.d.ts +0 -13
  793. package/lib/components/Toast/ToastsProvider/useToastsState/useToastsState.d.ts.map +0 -1
  794. package/lib/components/Toast/events.d.ts +0 -37
  795. package/lib/components/Toast/events.d.ts.map +0 -1
  796. package/lib/components/Visualizer/Visualizer.context.d.ts +0 -14
  797. package/lib/components/Visualizer/Visualizer.context.d.ts.map +0 -1
  798. package/lib/components/Visualizer/VisualizerMobileOpener.d.ts +0 -7
  799. package/lib/components/Visualizer/VisualizerMobileOpener.d.ts.map +0 -1
  800. package/lib/components/index.d.ts +0 -36
  801. package/lib/components/index.d.ts.map +0 -1
  802. package/lib/utils/createUseExternalEvents/index.d.ts +0 -14
  803. package/lib/utils/createUseExternalEvents/index.d.ts.map +0 -1
  804. package/lib/utils/useDidUpdate/index.d.ts +0 -30
  805. package/lib/utils/useDidUpdate/index.d.ts.map +0 -1
  806. package/lib/utils/useEventListener/index.d.ts +0 -7
  807. package/lib/utils/useEventListener/index.d.ts.map +0 -1
  808. package/lib/utils/useForceUpdate/index.d.ts +0 -28
  809. package/lib/utils/useForceUpdate/index.d.ts.map +0 -1
  810. package/lib/utils/useIsomorphicEffect/index.d.ts +0 -21
  811. package/lib/utils/useIsomorphicEffect/index.d.ts.map +0 -1
  812. package/lib/utils/useQueue/index.d.ts +0 -65
  813. package/lib/utils/useQueue/index.d.ts.map +0 -1
  814. package/lib/utils/useUncontrolled/index.d.ts +0 -38
  815. package/lib/utils/useUncontrolled/index.d.ts.map +0 -1
@@ -1,16 +1,31 @@
1
1
  'use client';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
3
  import * as React from 'react';
3
4
  import { CheckboxGroupProvider } from './CheckboxGroup.context.js';
4
- import { useUncontrolled } from '../../../utils/useUncontrolled/index.js';
5
+ import { leafValues } from '../ChoiceText.js';
6
+ import { useControllableState } from '../../../utils/useControllableState/index.js';
5
7
  import { classNames } from '../../../utils/classNames/index.js';
6
8
 
9
+ const defaultLabels = { selectAll: "Select all" };
7
10
  const CheckboxGroup = React.forwardRef((props, ref) => {
8
- const { title, children, className, value, defaultValue, onChange, orientation = "vertical" } = props;
9
- const [internalValue, setInternalValue] = useUncontrolled({
11
+ const {
12
+ label,
13
+ children,
14
+ className,
10
15
  value,
11
16
  defaultValue,
12
- finalValue: [],
13
- onChange
17
+ onValueChange,
18
+ orientation = "vertical",
19
+ variant = "default",
20
+ selectAll = false,
21
+ labels,
22
+ ...others
23
+ } = props;
24
+ const text = { ...defaultLabels, ...labels };
25
+ const [internalValue, setInternalValue] = useControllableState({
26
+ value,
27
+ defaultValue: defaultValue ?? [],
28
+ onChange: onValueChange
14
29
  });
15
30
  const handleChange = (event) => {
16
31
  const itemValue = event.currentTarget.value;
@@ -18,14 +33,33 @@ const CheckboxGroup = React.forwardRef((props, ref) => {
18
33
  internalValue.includes(itemValue) ? internalValue.filter((item) => item !== itemValue) : [...internalValue, itemValue]
19
34
  );
20
35
  };
21
- return /* @__PURE__ */ React.createElement(CheckboxGroupProvider, { value: { value: internalValue, onChange: handleChange } }, /* @__PURE__ */ React.createElement("p", null, title), /* @__PURE__ */ React.createElement(
22
- "div",
36
+ const toggleAll = () => {
37
+ const all = leafValues(children);
38
+ const allChecked = all.every((item) => internalValue.includes(item));
39
+ setInternalValue(
40
+ allChecked ? internalValue.filter((item) => !all.includes(item)) : [.../* @__PURE__ */ new Set([...internalValue, ...all])]
41
+ );
42
+ };
43
+ return /* @__PURE__ */ jsx(CheckboxGroupProvider, { value: { value: internalValue, onChange: handleChange, setValue: setInternalValue }, children: /* @__PURE__ */ jsxs(
44
+ "fieldset",
23
45
  {
46
+ ...others,
24
47
  ref,
25
- className: classNames("option-list checkbox", { "items-group": orientation === "horizontal" }, className)
26
- },
27
- children
28
- ));
48
+ className: classNames(
49
+ "roaster-choice-group",
50
+ {
51
+ "roaster-choice-group--row": orientation === "horizontal",
52
+ "roaster-choice-group--list": variant === "list"
53
+ },
54
+ className
55
+ ),
56
+ children: [
57
+ label != null && label !== "" && /* @__PURE__ */ jsx("legend", { className: "roaster-choice-group__legend", children: label }),
58
+ selectAll && /* @__PURE__ */ jsx("button", { className: "roaster-choice-group__action", type: "button", onClick: toggleAll, children: text.selectAll }),
59
+ children
60
+ ]
61
+ }
62
+ ) });
29
63
  });
30
64
  CheckboxGroup.displayName = "CheckboxGroup";
31
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxGroup.js","sources":["../../../../../src/components/Checkbox/CheckboxGroup/CheckboxGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useUncontrolled } from '@/utils';\nimport { CheckboxGroupProvider } from './CheckboxGroup.context';\n\nexport interface CheckboxGroupProps {\n title?: string;\n children: React.ReactNode;\n value?: string[];\n defaultValue?: string[];\n className?: string;\n onChange?(value: string[]): void;\n orientation?: 'horizontal' | 'vertical';\n}\n\nexport const CheckboxGroup = React.forwardRef<HTMLDivElement, CheckboxGroupProps>((props: CheckboxGroupProps, ref) => {\n const { title, children, className, value, defaultValue, onChange, orientation = 'vertical' } = props;\n\n const [internalValue, setInternalValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: [],\n onChange,\n });\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const itemValue = event.currentTarget.value;\n setInternalValue(\n internalValue.includes(itemValue)\n ? internalValue.filter((item) => item !== itemValue)\n : [...internalValue, itemValue]\n );\n };\n\n return (\n <CheckboxGroupProvider value={{ value: internalValue, onChange: handleChange }}>\n <p>{title}</p>\n <div\n ref={ref}\n className={classNames('option-list checkbox', { 'items-group': orientation === 'horizontal' }, className)}\n >\n {children}\n </div>\n </CheckboxGroupProvider>\n );\n});\n\nCheck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":3,"file":"CheckboxGroup.js","sources":["../../../../../src/components/Checkbox/CheckboxGroup/CheckboxGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useControllableState } from '@/utils';\nimport { CheckboxGroupProvider } from './CheckboxGroup.context';\nimport { leafValues } from '../ChoiceText';\n\n/** The text of a checkbox group, for other languages. */\nexport interface CheckboxGroupLabels {\n /** The button that checks every checkbox of the group, or unchecks them once they all are. */\n selectAll: string;\n}\n\nconst defaultLabels: CheckboxGroupLabels = { selectAll: 'Select all' };\n\n/** Every native `<fieldset>` prop (`name`, `disabled`, `aria-*`, ...) is accepted and forwarded to it. */\nexport interface CheckboxGroupProps extends Omit<React.ComponentPropsWithoutRef<'fieldset'>, 'defaultValue'> {\n /** The question the checkboxes answer, as the group's legend. */\n label?: React.ReactNode;\n /** The checkboxes. */\n children: React.ReactNode;\n /** The checked values, for a controlled group. */\n value?: string[];\n /** The values checked at first, for an uncontrolled group. */\n defaultValue?: string[];\n /** Called with the checked values when the user toggles one. */\n onValueChange?(value: string[]): void;\n /** `horizontal` lays the checkboxes out in a row. */\n orientation?: 'horizontal' | 'vertical';\n /** `list`: a long list, such as a filter's, its legend ruled off. */\n variant?: 'default' | 'list';\n /** A button beside the legend that checks every checkbox, or unchecks them once they all are. */\n selectAll?: boolean;\n /** The text of the group, in English by default. */\n labels?: Partial<CheckboxGroupLabels>;\n}\n\n/** A set of checkboxes that hold one list of values, in a fieldset with a legend. */\nexport const CheckboxGroup = React.forwardRef<HTMLFieldSetElement, CheckboxGroupProps>((props, ref) => {\n const {\n label,\n children,\n className,\n value,\n defaultValue,\n onValueChange,\n orientation = 'vertical',\n variant = 'default',\n selectAll = false,\n labels,\n ...others\n } = props;\n const text = { ...defaultLabels, ...labels };\n\n const [internalValue, setInternalValue] = useControllableState({\n value,\n defaultValue: defaultValue ?? [],\n onChange: onValueChange,\n });\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const itemValue = event.currentTarget.value;\n setInternalValue(\n internalValue.includes(itemValue)\n ? internalValue.filter((item) => item !== itemValue)\n : [...internalValue, itemValue]\n );\n };\n\n const toggleAll = () => {\n const all = leafValues(children);\n const allChecked = all.every((item) => internalValue.includes(item));\n setInternalValue(\n allChecked ? internalValue.filter((item) => !all.includes(item)) : [...new Set([...internalValue, ...all])]\n );\n };\n\n return (\n <CheckboxGroupProvider value={{ value: internalValue, onChange: handleChange, setValue: setInternalValue }}>\n <fieldset\n {...others}\n ref={ref}\n className={classNames(\n 'roaster-choice-group',\n {\n 'roaster-choice-group--row': orientation === 'horizontal',\n 'roaster-choice-group--list': variant === 'list',\n },\n className\n )}\n >\n {label != null && label !== '' && <legend className=\"roaster-choice-group__legend\">{label}</legend>}\n {selectAll && (\n <button className=\"roaster-choice-group__action\" type=\"button\" onClick={toggleAll}>\n {text.selectAll}\n </button>\n )}\n {children}\n </fieldset>\n </CheckboxGroupProvider>\n );\n});\n\nCheckboxGroup.displayName = 'CheckboxGroup';\n"],"names":[],"mappings":";;;;;;;;AAMA,MAAM,aAAa,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE;AACrC,MAAC,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC9D,EAAE,MAAM;AACR,IAAI,KAAK;AACT,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,aAAa;AACjB,IAAI,WAAW,GAAG,UAAU;AAC5B,IAAI,OAAO,GAAG,SAAS;AACvB,IAAI,SAAS,GAAG,KAAK;AACrB,IAAI,MAAM;AACV,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,IAAI,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAAE;AAC9C,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,oBAAoB,CAAC;AACjE,IAAI,KAAK;AACT,IAAI,YAAY,EAAE,YAAY,IAAI,EAAE;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;AACR,OAAO;AACP,MAAM,QAAQ,EAAE;AAChB,QAAQ,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,oBAAoB,GAAG,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,8BAA8B,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACtI,QAAQ,SAAS,oBAAoB,GAAG,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,8BAA8B,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;AAC/J,QAAQ;AACR;AACA;AACA,GAAG,EAAE,CAAC;AACN,CAAC;AACD,aAAa,CAAC,WAAW,GAAG,eAAe;;"}
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import * as React from 'react';
4
+
5
+ const shown = (node) => node != null && node !== false && node !== "";
6
+ function ChoiceText({
7
+ label,
8
+ description,
9
+ detail,
10
+ labelId
11
+ }) {
12
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
13
+ shown(label) && /* @__PURE__ */ jsxs("span", { className: "roaster-choice__label", id: labelId, children: [
14
+ label,
15
+ shown(description) && /* @__PURE__ */ jsx("span", { className: "roaster-choice__description", children: description })
16
+ ] }),
17
+ shown(detail) && /* @__PURE__ */ jsx("span", { className: "roaster-choice__detail", children: detail })
18
+ ] });
19
+ }
20
+ function leafValues(children) {
21
+ const values = [];
22
+ React.Children.forEach(children, (child) => {
23
+ if (!React.isValidElement(child)) return;
24
+ const { value, children: inner } = child.props;
25
+ const nested = inner != null ? leafValues(inner) : [];
26
+ if (nested.length) values.push(...nested);
27
+ else if (typeof value === "string") values.push(value);
28
+ });
29
+ return values;
30
+ }
31
+
32
+ export { ChoiceText, leafValues };
33
+ //# sourceMappingURL=ChoiceText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChoiceText.js","sources":["../../../../src/components/Checkbox/ChoiceText.tsx"],"sourcesContent":["import * as React from 'react';\n\nconst shown = (node: React.ReactNode) => node != null && node !== false && node !== '';\n\n/**\n * The text of a checkbox or radio button, inside its label: the label, a description under it and a detail at the\n * row's end. `labelId` names the label's text, for a group of choices under it.\n */\nexport function ChoiceText({\n label,\n description,\n detail,\n labelId,\n}: {\n label?: React.ReactNode;\n description?: React.ReactNode;\n detail?: React.ReactNode;\n labelId?: string;\n}) {\n return (\n <>\n {shown(label) && (\n <span className=\"roaster-choice__label\" id={labelId}>\n {label}\n {shown(description) && <span className=\"roaster-choice__description\">{description}</span>}\n </span>\n )}\n {shown(detail) && <span className=\"roaster-choice__detail\">{detail}</span>}\n </>\n );\n}\n\n/**\n * The values of the checkboxes in `children`, at any depth: an element with a `value` stands for its own, unless it\n * has checkboxes under it, which stand for it.\n */\nexport function leafValues(children: React.ReactNode): string[] {\n const values: string[] = [];\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement<{ value?: unknown; children?: React.ReactNode }>(child)) return;\n const { value, children: inner } = child.props;\n const nested = inner != null ? leafValues(inner) : [];\n if (nested.length) values.push(...nested);\n else if (typeof value === 'string') values.push(value);\n });\n return values;\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,EAAE;AAC9D,SAAS,UAAU,CAAC;AAC3B,EAAE,KAAK;AACP,EAAE,WAAW;AACb,EAAE,MAAM;AACR,EAAE;AACF,CAAC,EAAE;AACH,EAAE,uBAAuB,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE;AACpD,IAAI,KAAK,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;AAC9G,MAAM,KAAK;AACX,MAAM,KAAK,CAAC,WAAW,CAAC,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,6BAA6B,EAAE,QAAQ,EAAE,WAAW,EAAE;AAC3H,KAAK,EAAE,CAAC;AACR,IAAI,KAAK,CAAC,MAAM,CAAC,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1G,GAAG,EAAE,CAAC;AACN;AACO,SAAS,UAAU,CAAC,QAAQ,EAAE;AACrC,EAAE,MAAM,MAAM,GAAG,EAAE;AACnB,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAK;AAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;AACtC,IAAI,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK;AAClD,IAAI,MAAM,MAAM,GAAG,KAAK,IAAI,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE;AACzD,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC7C,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;AAC1D,EAAE,CAAC,CAAC;AACJ,EAAE,OAAO,MAAM;AACf;;"}
@@ -1,33 +1,84 @@
1
1
  'use client';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
3
  import * as React from 'react';
3
- import { useUncontrolled } from '../../utils/useUncontrolled/index.js';
4
+ import { Field, fieldControlProps } from '../Field/Field.js';
5
+ import { useControllableState } from '../../utils/useControllableState/index.js';
4
6
  import { useUid } from '../../utils/useUid/index.js';
5
7
 
8
+ function toFullHex(text) {
9
+ if (!/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(text)) return null;
10
+ return (text.length === 4 ? text.replace(/[0-9a-f]/gi, (digit) => digit + digit) : text).toLowerCase();
11
+ }
12
+ const defaultColorFieldLabels = { hex: "Hex color code" };
6
13
  const ColorField = React.forwardRef((props, ref) => {
7
- const { id, label, name, disabled, helpText, labelClassName, onChange, value, defaultValue, ...others } = props;
8
- const [internalValue, setInternalValue] = useUncontrolled({
14
+ const {
15
+ id,
16
+ label,
17
+ name,
18
+ disabled,
19
+ description,
20
+ error,
21
+ className,
22
+ style,
23
+ onChange,
24
+ onValueChange,
9
25
  value,
10
26
  defaultValue,
11
- finalValue: "",
12
- onChange
27
+ labels,
28
+ ...others
29
+ } = props;
30
+ const text = { ...defaultColorFieldLabels, ...labels };
31
+ const [internalValue, setInternalValue] = useControllableState({
32
+ value,
33
+ defaultValue: defaultValue ?? "",
34
+ onChange: onValueChange
13
35
  });
14
36
  const uid = useUid(id);
37
+ const [hexText, setHexText] = React.useState(internalValue);
38
+ React.useEffect(() => {
39
+ setHexText((typed) => toFullHex(typed) === internalValue.toLowerCase() ? typed : internalValue);
40
+ }, [internalValue]);
41
+ const typedColor = toFullHex(hexText);
42
+ const shownHex = typedColor && typedColor !== internalValue.toLowerCase() ? internalValue : hexText;
15
43
  const handleChange = (event) => {
44
+ onChange?.(event);
16
45
  setInternalValue(event.currentTarget.value);
17
46
  };
18
- return /* @__PURE__ */ React.createElement("label", { htmlFor: uid }, /* @__PURE__ */ React.createElement("p", { className: labelClassName }, label), /* @__PURE__ */ React.createElement("div", { className: "merged-inputs" }, /* @__PURE__ */ React.createElement("div", { className: "color-picker merge-right" }, /* @__PURE__ */ React.createElement("span", { className: "color-preview", style: { backgroundColor: internalValue } }), /* @__PURE__ */ React.createElement(
19
- "input",
20
- {
21
- ...others,
22
- id: uid,
23
- ref,
24
- type: "color",
25
- name,
26
- disabled,
27
- onChange: handleChange,
28
- value: internalValue
29
- }
30
- )), /* @__PURE__ */ React.createElement("input", { type: "text", className: "merge-left", value: internalValue, onChange: handleChange })), /* @__PURE__ */ React.createElement("small", null, helpText));
47
+ const handleHexChange = (event) => {
48
+ const typed = event.currentTarget.value;
49
+ setHexText(typed);
50
+ const color = toFullHex(typed);
51
+ if (color) setInternalValue(color);
52
+ };
53
+ return /* @__PURE__ */ jsx(Field, { controlId: uid, label, description, error, className, style, children: /* @__PURE__ */ jsxs("div", { className: "roaster-merged-inputs", children: [
54
+ /* @__PURE__ */ jsxs("span", { className: "roaster-color-swatch roaster-merged-inputs__start", children: [
55
+ /* @__PURE__ */ jsx("span", { className: "roaster-color-swatch__preview", style: { backgroundColor: internalValue } }),
56
+ /* @__PURE__ */ jsx(
57
+ "input",
58
+ {
59
+ ...others,
60
+ ...fieldControlProps(uid, { description, error }, others),
61
+ ref,
62
+ type: "color",
63
+ className: "roaster-color-swatch__input",
64
+ name,
65
+ disabled,
66
+ onChange: handleChange,
67
+ value: internalValue
68
+ }
69
+ )
70
+ ] }),
71
+ /* @__PURE__ */ jsx(
72
+ "input",
73
+ {
74
+ type: "text",
75
+ className: "roaster-input roaster-merged-inputs__end",
76
+ "aria-label": text.hex,
77
+ value: shownHex,
78
+ onChange: handleHexChange
79
+ }
80
+ )
81
+ ] }) });
31
82
  });
32
83
  ColorField.displayName = "ColorField";
33
84
 
@@ -1 +1 @@
1
- {"version":3,"file":"ColorField.js","sources":["../../../../src/components/ColorField/ColorField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useUid, useUncontrolled } from '@/utils';\n\n/** Every native `<input>` prop (`aria-*`, `data-*`, ...) is accepted and forwarded to the color input. */\nexport interface ColorFieldProps extends Omit<React.ComponentPropsWithoutRef<'input'>, 'onChange' | 'type'> {\n /** The HTML ID attribute to be applied to the color field input element (optional). */\n id?: string;\n /** The name attribute to be applied to the color field input element (optional). */\n name?: string;\n /** Whether the color field input should be disabled (optional). */\n disabled?: boolean;\n /** The current value of the color field input (optional). */\n value?: string;\n /** The default value of the color field input (optional). */\n defaultValue?: string;\n /**\n * A function to be called when the value of the color field input changes (optional).\n * The function receives the new color of the input as a string.\n */\n onChange?(value: string): void;\n /** The label to be displayed above the color field input (optional). */\n label?: React.ReactNode;\n /** Help text to be displayed below the color field input (optional). */\n helpText?: React.ReactNode;\n /** CSS class names to be applied to the label element (optional). */\n labelClassName?: string;\n}\n\n/** A color picker with a text field that shows and edits the hex value. */\nexport const ColorField = React.forwardRef<HTMLInputElement, ColorFieldProps>((props, ref) => {\n const { id, label, name, disabled, helpText, labelClassName, onChange, value, defaultValue, ...others } = props;\n const [internalValue, setInternalValue] = useUncontrolled({\n value,\n defaultValue,\n finalValue: '',\n onChange,\n });\n const uid = useUid(id);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n setInternalValue(event.currentTarget.value);\n };\n\n return (\n <label htmlFor={uid}>\n <p className={labelClassName}>{label}</p>\n <div className=\"merged-inputs\">\n <div className=\"color-picker merge-right\">\n <span className=\"color-preview\" style={{ backgroundColor: internalValue }} />\n <input\n {...others}\n id={uid}\n ref={ref}\n type=\"color\"\n name={name}\n disabled={disabled}\n onChange={handleChange}\n value={internalValue}\n />\n </div>\n <input type=\"text\" className=\"merge-left\" value={internalValue} onChange={handleChange} />\n </div>\n <small>{helpText}</small>\n </label>\n );\n});\n\nColorField.displayName = 'ColorField';\n"],"names":[],"mappings":";;;;;AAEY,MAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC3D,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK;AACjH,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,eAAe,CAAC;AAC5D,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,UAAU,EAAE,EAAE;AAClB,IAAI;AACJ,GAAG,CAAC;AACJ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;AACxB,EAAE,MAAM,YAAY,GAAG,CAAC,KAAK,KAAK;AAClC,IAAI,gBAAgB,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC;AAC/C,EAAE,CAAC;AACH,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,KAAK,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,0BAA0B,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,EAAE,CAAC,kBAAkB,KAAK,CAAC,aAAa;AACpd,IAAI,OAAO;AACX,IAAI;AACJ,MAAM,GAAG,MAAM;AACf,MAAM,EAAE,EAAE,GAAG;AACb,MAAM,GAAG;AACT,MAAM,IAAI,EAAE,OAAO;AACnB,MAAM,IAAI;AACV,MAAM,QAAQ;AACd,MAAM,QAAQ,EAAE,YAAY;AAC5B,MAAM,KAAK,EAAE;AACb;AACA,GAAG,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC3M,CAAC;AACD,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
1
+ {"version":3,"file":"ColorField.js","sources":["../../../../src/components/ColorField/ColorField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useUid, useControllableState } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps } from '../Field';\n\n/** `#abc` or `#aabbcc` as `#aabbcc`; anything else as `null`. */\nfunction toFullHex(text: string) {\n if (!/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(text)) return null;\n return (text.length === 4 ? text.replace(/[0-9a-f]/gi, (digit) => digit + digit) : text).toLowerCase();\n}\n\n/** The text of the color field, for other languages. */\nexport interface ColorFieldLabels {\n /** The name of the text input that holds the hex code, read by screen readers. */\n hex: string;\n}\n\nconst defaultColorFieldLabels: ColorFieldLabels = { hex: 'Hex color code' };\n\n/**\n * Every native `<input>` prop (`name`, `required`, `aria-*`, ...) is accepted and forwarded to the color input, with the\n * ref. `className` and `style` go to the field's wrapper.\n */\nexport interface ColorFieldProps\n extends FieldBaseProps, Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'className' | 'style'> {\n /** The HTML ID attribute to be applied to the color field input element (optional). */\n id?: string;\n /** The name attribute to be applied to the color field input element (optional). */\n name?: string;\n /** Whether the color field input should be disabled (optional). */\n disabled?: boolean;\n /** The current value of the color field input (optional). */\n value?: string;\n /** The default value of the color field input (optional). */\n defaultValue?: string;\n /** Called with the new color when the user picks or types one. The native `onChange` gets the event. */\n onValueChange?(value: string): void;\n /** The text of the field, in English by default. */\n labels?: Partial<ColorFieldLabels>;\n}\n\n/** A color picker with a text field that shows and edits the hex value. */\nexport const ColorField = React.forwardRef<HTMLInputElement, ColorFieldProps>((props, ref) => {\n const {\n id,\n label,\n name,\n disabled,\n description,\n error,\n className,\n style,\n onChange,\n onValueChange,\n value,\n defaultValue,\n labels,\n ...others\n } = props;\n const text = { ...defaultColorFieldLabels, ...labels };\n const [internalValue, setInternalValue] = useControllableState({\n value,\n defaultValue: defaultValue ?? '',\n onChange: onValueChange,\n });\n const uid = useUid(id);\n\n // The hex text as typed: the color only follows once it is a whole code (#RGB or #RRGGBB).\n const [hexText, setHexText] = React.useState(internalValue);\n React.useEffect(() => {\n setHexText((typed) => (toFullHex(typed) === internalValue.toLowerCase() ? typed : internalValue));\n }, [internalValue]);\n\n // A whole code the value doesn't hold (a controlled field the parent didn't update) gives way to the value.\n const typedColor = toFullHex(hexText);\n const shownHex = typedColor && typedColor !== internalValue.toLowerCase() ? internalValue : hexText;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n setInternalValue(event.currentTarget.value);\n };\n const handleHexChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const typed = event.currentTarget.value;\n setHexText(typed);\n const color = toFullHex(typed);\n if (color) setInternalValue(color);\n };\n\n return (\n <Field controlId={uid} label={label} description={description} error={error} className={className} style={style}>\n <div className=\"roaster-merged-inputs\">\n <span className=\"roaster-color-swatch roaster-merged-inputs__start\">\n <span className=\"roaster-color-swatch__preview\" style={{ backgroundColor: internalValue }} />\n <input\n {...others}\n {...fieldControlProps(uid, { label, description, error }, others)}\n ref={ref}\n type=\"color\"\n className=\"roaster-color-swatch__input\"\n name={name}\n disabled={disabled}\n onChange={handleChange}\n value={internalValue}\n />\n </span>\n <input\n type=\"text\"\n className=\"roaster-input roaster-merged-inputs__end\"\n aria-label={text.hex}\n value={shownHex}\n onChange={handleHexChange}\n />\n </div>\n </Field>\n );\n});\n\nColorField.displayName = 'ColorField';\n"],"names":[],"mappings":";;;;;;;AAKA,SAAS,SAAS,CAAC,IAAI,EAAE;AACzB,EAAE,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,IAAI;AAC9D,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,KAAK,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE;AACxG;AACA,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,gBAAgB,EAAE;AAC7C,MAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GA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C9B,QAAQ,KAAK,EAAE,QAAQ;AACvB,QAAQ,QAAQ,EAAE;AAClB;AACA;AACA,GAAG,EAAE,CAAC,EAAE,CAAC;AACT,CAAC;AACD,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
@@ -1,18 +1,20 @@
1
1
  'use client';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
3
  import * as React from 'react';
3
4
  import { pickCalendarProps, formatDate, dateStringParser, isDateValid, getSeparatorIndex } from './utils/index.js';
4
- import './components/Day/Day.js';
5
- import './components/Weekday/Weekday.js';
6
5
  import { Calendar } from './components/Calendar/Calendar.js';
6
+ import { MonthGrid } from './components/MonthGrid/MonthGrid.js';
7
7
  import { TextField } from '../TextField/TextField.js';
8
- import { useUncontrolled } from '../../utils/useUncontrolled/index.js';
8
+ import { useMergeRefs } from '@floating-ui/react';
9
+ import { useControllableState } from '../../utils/useControllableState/index.js';
9
10
 
10
- function DatePicker(props) {
11
+ const DatePickerBase = React.forwardRef(function DatePicker2(props, ref) {
11
12
  const { calendarProps, others } = pickCalendarProps(props);
13
+ const { labels, ...inputProps } = others;
12
14
  const {
13
15
  month,
14
16
  year,
15
- onChange,
17
+ onValueChange,
16
18
  onInputError,
17
19
  value: passedValue,
18
20
  disableSpecificDates,
@@ -21,16 +23,17 @@ function DatePicker(props) {
21
23
  minDate,
22
24
  maxDate,
23
25
  defaultValue,
24
- onMonthChange
26
+ onMonthChange,
27
+ locale,
28
+ weekStartsOn
25
29
  } = calendarProps;
26
- const textFieldRef = React.useRef(null);
27
30
  const calendarRef = React.useRef(null);
28
31
  const [isTextFieldFocused, setIsTextFieldFocused] = React.useState(false);
29
32
  const [inputError, setInputError] = React.useState(false);
30
33
  const [currentKey, setCurrentKey] = React.useState("");
31
34
  const [{ currentDisplayedMonth, currentDisplayedYear }, setCalendarDate] = React.useState({
32
- currentDisplayedMonth: month,
33
- currentDisplayedYear: year
35
+ currentDisplayedMonth: defaultValue ? defaultValue.getMonth() : month,
36
+ currentDisplayedYear: defaultValue ? defaultValue.getFullYear() : year
34
37
  });
35
38
  const separatorIndex = getSeparatorIndex(dateFormat);
36
39
  const handleMonthChange = React.useCallback(
@@ -40,17 +43,29 @@ function DatePicker(props) {
40
43
  },
41
44
  [onMonthChange]
42
45
  );
43
- const [date, setDate] = useUncontrolled({
46
+ const [date, setDate] = useControllableState({
44
47
  value: passedValue,
45
- defaultValue,
46
- finalValue: null,
47
- onChange
48
+ defaultValue: defaultValue ?? null,
49
+ onChange: onValueChange
48
50
  });
49
51
  const [inputValue, setInputValue] = React.useState(
50
52
  date instanceof Date ? formatDate(date, separator, dateFormat) : ""
51
53
  );
52
- const onFocus = () => setIsTextFieldFocused(true);
54
+ const inputRef = React.useRef(null);
55
+ const mergedRef = useMergeRefs([inputRef, ref]);
56
+ const returningFocus = React.useRef(false);
57
+ const onFocus = () => {
58
+ if (returningFocus.current) returningFocus.current = false;
59
+ else setIsTextFieldFocused(true);
60
+ };
53
61
  const onBlur = () => setIsTextFieldFocused(false);
62
+ const closeToInput = React.useCallback(() => {
63
+ setIsTextFieldFocused(false);
64
+ if (inputRef.current && document.activeElement !== inputRef.current) {
65
+ returningFocus.current = true;
66
+ inputRef.current.focus();
67
+ }
68
+ }, []);
54
69
  const handleDateSelection = React.useCallback(
55
70
  (selectedDate) => {
56
71
  setInputValue(formatDate(selectedDate, separator, dateFormat));
@@ -60,9 +75,9 @@ function DatePicker(props) {
60
75
  currentDisplayedYear: selectedDate.getFullYear()
61
76
  });
62
77
  setInputError("");
63
- window.setTimeout(onBlur, 10);
78
+ window.setTimeout(closeToInput, 10);
64
79
  },
65
- [setDate, separator, dateFormat]
80
+ [setDate, separator, dateFormat, closeToInput]
66
81
  );
67
82
  const controlledTime = passedValue === void 0 ? void 0 : passedValue?.getTime() ?? null;
68
83
  React.useEffect(() => {
@@ -89,41 +104,64 @@ function DatePicker(props) {
89
104
  }
90
105
  return setInputError(onInputError?.("OUT_OF_RANGE") ?? true);
91
106
  }
92
- if (valueLength < 10 && valueLength > 0) {
93
- return setInputError(onInputError?.("INVALID_DATE") ?? true);
94
- }
107
+ setInputError("");
95
108
  }
96
- React.useEffect(() => {
97
- if (defaultValue) handleDateSelection(defaultValue);
98
- }, []);
99
- return /* @__PURE__ */ React.createElement("div", { className: "date-picker", ref: calendarRef }, /* @__PURE__ */ React.createElement(
100
- TextField,
101
- {
102
- ...others,
103
- value: inputValue,
104
- ref: textFieldRef,
105
- onFocus,
106
- maxLength: 10,
107
- onChange: (value) => handleInputChange(value),
108
- onKeyDown: (event) => setCurrentKey(event.key),
109
- error: inputError
110
- }
111
- ), /* @__PURE__ */ React.createElement(
112
- Calendar,
109
+ const handleInputBlur = (event) => {
110
+ others.onBlur?.(event);
111
+ if (inputValue.length > 0 && inputValue.length < 10) setInputError(onInputError?.("INVALID_DATE") ?? true);
112
+ };
113
+ return /* @__PURE__ */ jsxs(
114
+ "div",
113
115
  {
114
- selected: date ?? void 0,
115
- onClose: onBlur,
116
- minDate,
117
- maxDate,
118
- isOpen: isTextFieldFocused,
119
- year: currentDisplayedYear,
120
- month: currentDisplayedMonth,
121
- onMonthChange: handleMonthChange,
122
- handleDateSelection,
123
- disableSpecificDates
116
+ className: "roaster-date-picker",
117
+ ref: calendarRef,
118
+ onBlur: (event) => {
119
+ if (!event.currentTarget.contains(event.relatedTarget)) onBlur();
120
+ },
121
+ children: [
122
+ /* @__PURE__ */ jsx(
123
+ TextField,
124
+ {
125
+ ...inputProps,
126
+ value: inputValue,
127
+ ref: mergedRef,
128
+ onFocus,
129
+ onBlur: handleInputBlur,
130
+ maxLength: 10,
131
+ role: "combobox",
132
+ "aria-haspopup": "dialog",
133
+ "aria-expanded": isTextFieldFocused,
134
+ onValueChange: (value) => handleInputChange(value),
135
+ onKeyDown: (event) => {
136
+ setCurrentKey(event.key);
137
+ if (event.key === "Escape") onBlur();
138
+ },
139
+ error: inputError || others.error
140
+ }
141
+ ),
142
+ /* @__PURE__ */ jsx(
143
+ Calendar,
144
+ {
145
+ selected: date ?? void 0,
146
+ onClose: closeToInput,
147
+ minDate,
148
+ maxDate,
149
+ isOpen: isTextFieldFocused,
150
+ year: currentDisplayedYear,
151
+ month: currentDisplayedMonth,
152
+ onMonthChange: handleMonthChange,
153
+ handleDateSelection,
154
+ disableSpecificDates,
155
+ locale,
156
+ weekStartsOn,
157
+ labels
158
+ }
159
+ )
160
+ ]
124
161
  }
125
- ));
126
- }
162
+ );
163
+ });
164
+ const DatePicker = Object.assign(DatePickerBase, { MonthGrid });
127
165
 
128
166
  export { DatePicker };
129
167
  //# sourceMappingURL=DatePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sources":["../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dateStringParser, formatDate, getSeparatorIndex, isDateValid, pickCalendarProps } from './utils';\n\nimport { Calendar, CalendarProps } from './components';\nimport { TextField, TextFieldProps } from '../TextField';\nimport { useUncontrolled } from '@/utils';\nimport { DateSeparator, DateFormat, DatePickerInputError } from './utils/types';\n\nexport interface DatePickerProps\n extends\n Omit<CalendarProps, 'handleDateSelection' | 'year' | 'month' | 'selected' | 'isOpen' | 'onClose'>,\n Omit<TextFieldProps, 'onChange' | 'defaultValue' | 'value' | 'onAbort' | 'ref'> {\n /** The separator used for the date input fields. Defaults to '-' */\n separator?: DateSeparator;\n /** The format used as input mask. Defaults to 'YYYY MM DD' */\n dateFormat?: DateFormat;\n /** Callback function that will be called when an error occurs when parsing the date */\n onInputError?(type: DatePickerInputError): string;\n /** Callback function that will be called when the date is changed */\n onChange?(date: Date): void;\n /** Default value for uncontrolled input */\n defaultValue?: Date | null;\n /** Selected date, required with controlled input */\n value?: Date | null;\n /** The month to show, from 0 to 11. 0 is January, 1 is February ... 11 is December */\n month?: number;\n /** The year to show */\n year?: number;\n}\n\n/** A text field with a calendar, to type or pick a date, with optional minimum and maximum dates. */\nexport function DatePicker(props: DatePickerProps) {\n const { calendarProps, others } = pickCalendarProps<DatePickerProps>(props);\n\n const {\n month,\n year,\n onChange,\n onInputError,\n value: passedValue,\n disableSpecificDates,\n dateFormat,\n separator,\n minDate,\n maxDate,\n defaultValue,\n onMonthChange,\n } = calendarProps;\n\n const textFieldRef = React.useRef<HTMLInputElement>(null);\n const calendarRef = React.useRef<HTMLDivElement>(null);\n const [isTextFieldFocused, setIsTextFieldFocused] = React.useState(false);\n const [inputError, setInputError] = React.useState<string | boolean>(false);\n const [currentKey, setCurrentKey] = React.useState('');\n const [{ currentDisplayedMonth, currentDisplayedYear }, setCalendarDate] = React.useState({\n currentDisplayedMonth: month,\n currentDisplayedYear: year,\n });\n\n const separatorIndex = getSeparatorIndex(dateFormat);\n\n const handleMonthChange = React.useCallback(\n (targetMonth: number, targetYear: number) => {\n setCalendarDate({ currentDisplayedMonth: targetMonth, currentDisplayedYear: targetYear });\n onMonthChange?.(targetMonth, targetYear);\n },\n [onMonthChange]\n );\n\n const [date, setDate] = useUncontrolled<Date | null>({\n value: passedValue,\n defaultValue,\n finalValue: null,\n onChange,\n });\n\n const [inputValue, setInputValue] = React.useState(\n date instanceof Date ? formatDate(date, separator, dateFormat) : ''\n );\n\n const onFocus = () => setIsTextFieldFocused(true);\n const onBlur = () => setIsTextFieldFocused(false);\n\n const handleDateSelection = React.useCallback(\n (selectedDate: Date) => {\n setInputValue(formatDate(selectedDate, separator, dateFormat));\n setDate(selectedDate);\n setCalendarDate({\n currentDisplayedMonth: selectedDate.getMonth(),\n currentDisplayedYear: selectedDate.getFullYear(),\n });\n setInputError('');\n window.setTimeout(onBlur, 10);\n },\n [setDate, separator, dateFormat]\n );\n\n // A controlled date picker shows the new value whenever the parent changes it. Compared by time, since the parent\n // may pass a new Date object for the same day on every render.\n const controlledTime = passedValue === undefined ? undefined : (passedValue?.getTime() ?? null);\n React.useEffect(() => {\n if (controlledTime === undefined) return;\n setInputValue(controlledTime === null ? '' : formatDate(new Date(controlledTime), separator, dateFormat));\n }, [controlledTime, separator, dateFormat]);\n\n function handleInputChange(value: string) {\n const valueLength = value.length;\n\n if (currentKey !== 'Backspace' && (valueLength === separatorIndex.first || valueLength === separatorIndex.second)) {\n return setInputValue(value + separator);\n }\n\n if (valueLength === 0) {\n setDate(null);\n }\n\n setInputValue(value);\n\n if (valueLength === 10) {\n const dateValue = dateStringParser(value, dateFormat, separator);\n if (!dateValue) {\n return setInputError(onInputError?.('INVALID_DATE') ?? true);\n }\n setInputError('');\n\n if (isDateValid({ date: dateValue, minDate, maxDate })) {\n return handleDateSelection(dateValue);\n }\n return setInputError(onInputError?.('OUT_OF_RANGE') ?? true);\n }\n if (valueLength < 10 && valueLength > 0) {\n return setInputError(onInputError?.('INVALID_DATE') ?? true);\n }\n }\n\n React.useEffect(() => {\n if (defaultValue) handleDateSelection(defaultValue);\n }, []);\n\n return (\n <div className=\"date-picker\" ref={calendarRef}>\n <TextField\n {...others}\n value={inputValue}\n ref={textFieldRef}\n onFocus={onFocus}\n maxLength={10}\n onChange={(value) => handleInputChange(value)}\n onKeyDown={(event) => setCurrentKey(event.key)}\n error={inputError as string}\n />\n <Calendar\n selected={date ?? undefined}\n onClose={onBlur}\n minDate={minDate}\n maxDate={maxDate}\n isOpen={isTextFieldFocused}\n year={currentDisplayedYear}\n month={currentDisplayedMonth}\n onMonthChange={handleMonthChange}\n handleDateSelection={handleDateSelection}\n disableSpecificDates={disableSpecificDates}\n />\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAKO,SAAS,UAAU,CAAC,KAAK,EAAE;AAClC,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC,KAAK,CAAC;AAC5D,EAAE,MAAM;AACR,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,YAAY;AAChB,IAAI,KAAK,EAAE,WAAW;AACtB,IAAI,oBAAoB;AACxB,IAAI,UAAU;AACd,IAAI,SAAS;AACb,IAAI,OAAO;AACX,IAAI,OAAO;AACX,IAAI,YAAY;AAChB,IAAI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AAK,CAAC,aAAa;AACvI,IAAI,SAAS;AACb,IAAI;AACJ,MAAM,GAAG,MAAM;AACf,MAAM,KAAK,EAAE,UAAU;AACvB,MAAM,GAAG,EAAE,YAAY;AACvB,MAAM,OAAO;AACb,MAAM,SAAS,EAAE,EAAE;AACnB,MAAM,QAAQ,EAAE,CAAC,KAAK,KAAK,iBAAiB,CAAC,KAAK,CAAC;AACnD,MAAM,SAAS,EAAE,CAAC,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC;AACpD,MAAM,KAAK,EAAE;AACb;AACA,GAAG,kBAAkB,KAAK,CAAC,aAAa;AACxC,IAAI,QAAQ;AACZ,IAAI;AACJ,MAAM,QAAQ,EAAE,IAAI,IAAI,MAAM;AAC9B,MAAM,OAAO,EAAE,MAAM;AACrB,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,MAAM,EAAE,kBAAkB;AAChC,MAAM,IAAI,EAAE,oBAAoB;AAChC,MAAM,KAAK,EAAE,qBAAqB;AAClC,MAAM,aAAa,EAAE,iBAAiB;AACtC,MAAM,mBAAmB;AACzB,MAAM;AACN;AACA,GAAG,CAAC;AACJ;;"}
1
+ {"version":3,"file":"DatePicker.js","sources":["../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dateStringParser, formatDate, getSeparatorIndex, isDateValid, pickCalendarProps } from './utils';\n\nimport { Calendar, CalendarProps } from './components';\nimport type { CalendarLabels } from './components/Calendar/Calendar';\nimport { TextField, TextFieldProps } from '../TextField';\nimport { useMergeRefs } from '@floating-ui/react';\nimport { useControllableState } from '@/utils';\nimport { MonthGrid } from './components/MonthGrid';\nimport { DateSeparator, DateFormat, DatePickerInputError } from './utils/types';\n\nexport interface DatePickerProps\n extends\n Omit<CalendarProps, 'handleDateSelection' | 'year' | 'month' | 'selected' | 'isOpen' | 'onClose'>,\n Omit<TextFieldProps, 'onChange' | 'onValueChange' | 'defaultValue' | 'value' | 'onAbort' | 'ref'> {\n /** The separator used for the date input fields. Defaults to '-' */\n separator?: DateSeparator;\n /** The format used as input mask. Defaults to 'YYYY MM DD' */\n dateFormat?: DateFormat;\n /** Callback function that will be called when an error occurs when parsing the date */\n onInputError?(type: DatePickerInputError): string;\n /** Called with the new date, or `null` when the field is cleared. */\n onValueChange?(date: Date | null): void;\n /** Default value for uncontrolled input */\n defaultValue?: Date | null;\n /** Selected date, required with controlled input */\n value?: Date | null;\n /** The month to show, from 0 to 11. 0 is January, 1 is February ... 11 is December */\n month?: number;\n /** The year to show */\n year?: number;\n /** The text of the calendar, in English by default. */\n labels?: Partial<CalendarLabels>;\n}\n\nconst DatePickerBase = React.forwardRef<HTMLInputElement, DatePickerProps>(function DatePicker(props, ref) {\n const { calendarProps, others } = pickCalendarProps(props);\n const { labels, ...inputProps } = others as typeof others & { labels?: Partial<CalendarLabels> };\n\n const {\n month,\n year,\n onValueChange,\n onInputError,\n value: passedValue,\n disableSpecificDates,\n dateFormat,\n separator,\n minDate,\n maxDate,\n defaultValue,\n onMonthChange,\n locale,\n weekStartsOn,\n } = calendarProps;\n\n const calendarRef = React.useRef<HTMLDivElement>(null);\n const [isTextFieldFocused, setIsTextFieldFocused] = React.useState(false);\n const [inputError, setInputError] = React.useState<string | boolean>(false);\n const [currentKey, setCurrentKey] = React.useState('');\n // The calendar opens on the default date's month, if there is one.\n const [{ currentDisplayedMonth, currentDisplayedYear }, setCalendarDate] = React.useState({\n currentDisplayedMonth: defaultValue ? defaultValue.getMonth() : month,\n currentDisplayedYear: defaultValue ? defaultValue.getFullYear() : year,\n });\n\n const separatorIndex = getSeparatorIndex(dateFormat);\n\n const handleMonthChange = React.useCallback(\n (targetMonth: number, targetYear: number) => {\n setCalendarDate({ currentDisplayedMonth: targetMonth, currentDisplayedYear: targetYear });\n onMonthChange?.(targetMonth, targetYear);\n },\n [onMonthChange]\n );\n\n const [date, setDate] = useControllableState<Date | null>({\n value: passedValue,\n defaultValue: defaultValue ?? null,\n onChange: onValueChange,\n });\n\n const [inputValue, setInputValue] = React.useState(\n date instanceof Date ? formatDate(date, separator, dateFormat) : ''\n );\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = useMergeRefs([inputRef, ref]);\n // Set while the focus goes back to the input after closing, so that focus doesn't open the calendar again.\n const returningFocus = React.useRef(false);\n const onFocus = () => {\n if (returningFocus.current) returningFocus.current = false;\n else setIsTextFieldFocused(true);\n };\n const onBlur = () => setIsTextFieldFocused(false);\n // Escape closes the calendar, and the focus goes back to the input.\n const closeToInput = React.useCallback(() => {\n setIsTextFieldFocused(false);\n // Only when the focus really moves: focusing the focused input fires no focus event to clear the flag.\n if (inputRef.current && document.activeElement !== inputRef.current) {\n returningFocus.current = true;\n inputRef.current.focus();\n }\n }, []);\n\n const handleDateSelection = React.useCallback(\n (selectedDate: Date) => {\n setInputValue(formatDate(selectedDate, separator, dateFormat));\n setDate(selectedDate);\n setCalendarDate({\n currentDisplayedMonth: selectedDate.getMonth(),\n currentDisplayedYear: selectedDate.getFullYear(),\n });\n setInputError('');\n // Chosen: the calendar closes and the focus goes back to the input.\n window.setTimeout(closeToInput, 10);\n },\n [setDate, separator, dateFormat, closeToInput]\n );\n\n // A controlled date picker shows the new value whenever the parent changes it. Compared by time, since the parent\n // may pass a new Date object for the same day on every render.\n const controlledTime = passedValue === undefined ? undefined : (passedValue?.getTime() ?? null);\n React.useEffect(() => {\n if (controlledTime === undefined) return;\n setInputValue(controlledTime === null ? '' : formatDate(new Date(controlledTime), separator, dateFormat));\n }, [controlledTime, separator, dateFormat]);\n\n function handleInputChange(value: string) {\n const valueLength = value.length;\n\n if (currentKey !== 'Backspace' && (valueLength === separatorIndex.first || valueLength === separatorIndex.second)) {\n return setInputValue(value + separator);\n }\n\n if (valueLength === 0) {\n setDate(null);\n }\n\n setInputValue(value);\n\n if (valueLength === 10) {\n const dateValue = dateStringParser(value, dateFormat, separator);\n if (!dateValue) {\n return setInputError(onInputError?.('INVALID_DATE') ?? true);\n }\n setInputError('');\n\n if (isDateValid({ date: dateValue, minDate, maxDate })) {\n return handleDateSelection(dateValue);\n }\n return setInputError(onInputError?.('OUT_OF_RANGE') ?? true);\n }\n // Still typing: the error, if any, waits for the field to lose the focus.\n setInputError('');\n }\n\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n others.onBlur?.(event);\n if (inputValue.length > 0 && inputValue.length < 10) setInputError(onInputError?.('INVALID_DATE') ?? true);\n };\n\n return (\n <div\n className=\"roaster-date-picker\"\n ref={calendarRef}\n // Close when the focus leaves the date picker (Tab past the calendar, or a click elsewhere).\n onBlur={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) onBlur();\n }}\n >\n <TextField\n {...inputProps}\n value={inputValue}\n ref={mergedRef}\n onFocus={onFocus}\n onBlur={handleInputBlur}\n maxLength={10}\n // The WAI-ARIA date picker combobox: a text input that opens a calendar dialog.\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-expanded={isTextFieldFocused}\n onValueChange={(value) => handleInputChange(value)}\n onKeyDown={(event) => {\n setCurrentKey(event.key);\n if (event.key === 'Escape') onBlur();\n }}\n // A typing error wins over the one the parent passes.\n error={inputError || others.error}\n />\n <Calendar\n selected={date ?? undefined}\n onClose={closeToInput}\n minDate={minDate}\n maxDate={maxDate}\n isOpen={isTextFieldFocused}\n year={currentDisplayedYear}\n month={currentDisplayedMonth}\n onMonthChange={handleMonthChange}\n handleDateSelection={handleDateSelection}\n disableSpecificDates={disableSpecificDates}\n locale={locale}\n weekStartsOn={weekStartsOn}\n labels={labels}\n />\n </div>\n );\n});\n\n/**\n * A text field with a calendar, to type or pick a date, with optional minimum and maximum dates. DatePicker.MonthGrid\n * chooses a range of whole months instead.\n */\nexport const DatePicker = Object.assign(DatePickerBase, { MonthGrid });\n"],"names":[],"mappings":";;;;;;;;;;AASA,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE;AACzE,EAAE,MA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'react';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { Button } from '../../../Button/Button.js';
4
- import { monthName, noop, getPreviousDisplayMonth, getPreviousDisplayYear, getNextDisplayMonth, getNextDisplayYear } from '../../utils/index.js';
4
+ import { monthTitle, noop, getPreviousDisplayMonth, getPreviousDisplayYear, getNextDisplayMonth, getNextDisplayYear } from '../../utils/index.js';
5
5
  import { Month } from '../Month/Month.js';
6
- import { classNames } from '../../../../utils/classNames/index.js';
6
+ import { Icon } from '../../../Icon/Icon.js';
7
7
 
8
+ const defaultCalendarLabels = {
9
+ calendar: "Choose a date",
10
+ previousMonth: "Previous month",
11
+ nextMonth: "Next month"
12
+ };
8
13
  function Calendar({
9
- ref,
10
14
  selected,
11
15
  month,
12
16
  year,
@@ -16,26 +20,64 @@ function Calendar({
16
20
  onMonthChange,
17
21
  handleDateSelection = noop,
18
22
  isOpen = false,
19
- onClose
23
+ onClose,
24
+ locale,
25
+ weekStartsOn,
26
+ labels
20
27
  }) {
28
+ const text = { ...defaultCalendarLabels, ...labels };
21
29
  const showNextYear = getNextDisplayYear(month, year);
22
30
  const showNextMonth = getNextDisplayMonth(month);
23
31
  const showPreviousYear = getPreviousDisplayYear(month, year);
24
32
  const showPreviousMonth = getPreviousDisplayMonth(month);
25
33
  if (!isOpen) return null;
26
- return /* @__PURE__ */ React.createElement("div", { className: classNames("calendar", { visible: isOpen }), ref }, /* @__PURE__ */ React.createElement("div", { className: "background-overlay", onClick: onClose }), /* @__PURE__ */ React.createElement("div", { className: "calendar-nav" }, /* @__PURE__ */ React.createElement(Button, { variant: "secondary", onClick: () => onMonthChange?.(showPreviousMonth, showPreviousYear) }, /* @__PURE__ */ React.createElement("i", { className: "fa-regular fa-arrow-left" })), /* @__PURE__ */ React.createElement("span", { className: "month" }, monthName(month), " ", year), /* @__PURE__ */ React.createElement(Button, { variant: "secondary", onClick: () => onMonthChange?.(showNextMonth, showNextYear) }, /* @__PURE__ */ React.createElement("i", { className: "fa-regular fa-arrow-right" }))), /* @__PURE__ */ React.createElement(
27
- Month,
28
- {
29
- month,
30
- year,
31
- selected,
32
- onChange: handleDateSelection,
33
- minDate,
34
- maxDate,
35
- disableSpecificDates
36
- }
37
- ));
34
+ return (
35
+ // A click in the calendar leaves the focus where it is: Safari doesn't focus a clicked button, so the click would
36
+ // otherwise blur the input and close the calendar. Not an interaction of its own: the buttons inside are.
37
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
38
+ /* @__PURE__ */ jsx("div", { className: "roaster-date-picker__popup", onMouseDown: (event) => event.preventDefault(), children: /* @__PURE__ */ jsxs("div", { className: "roaster-date-picker__calendar", role: "dialog", "aria-label": text.calendar, children: [
39
+ /* @__PURE__ */ jsxs("div", { className: "roaster-date-picker__nav", children: [
40
+ /* @__PURE__ */ jsx(
41
+ Button,
42
+ {
43
+ variant: "secondary",
44
+ iconOnly: true,
45
+ "aria-label": text.previousMonth,
46
+ onClick: () => onMonthChange?.(showPreviousMonth, showPreviousYear),
47
+ children: /* @__PURE__ */ jsx(Icon, { name: "arrow-left" })
48
+ }
49
+ ),
50
+ /* @__PURE__ */ jsx("span", { className: "roaster-date-picker__month", "aria-live": "polite", children: monthTitle(month, year, locale) }),
51
+ /* @__PURE__ */ jsx(
52
+ Button,
53
+ {
54
+ variant: "secondary",
55
+ iconOnly: true,
56
+ "aria-label": text.nextMonth,
57
+ onClick: () => onMonthChange?.(showNextMonth, showNextYear),
58
+ children: /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
59
+ }
60
+ )
61
+ ] }),
62
+ /* @__PURE__ */ jsx(
63
+ Month,
64
+ {
65
+ month,
66
+ year,
67
+ selected,
68
+ onChange: handleDateSelection,
69
+ onMonthChange,
70
+ onEscape: onClose,
71
+ minDate,
72
+ maxDate,
73
+ disableSpecificDates,
74
+ locale,
75
+ weekStartsOn
76
+ }
77
+ )
78
+ ] }) })
79
+ );
38
80
  }
39
81
 
40
- export { Calendar };
82
+ export { Calendar, defaultCalendarLabels };
41
83
  //# sourceMappingURL=Calendar.js.map