@mindlogic-ai/logician-ui 2.0.0-alpha.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 (432) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/USAGE.md +299 -0
  4. package/dist/Markdown-2D5K42BY.js +16 -0
  5. package/dist/Markdown-2D5K42BY.js.map +1 -0
  6. package/dist/Markdown-AZBXO5ZP.css +29 -0
  7. package/dist/Markdown-AZBXO5ZP.css.map +1 -0
  8. package/dist/Markdown-RJJEQN4R.mjs +3 -0
  9. package/dist/Markdown-RJJEQN4R.mjs.map +1 -0
  10. package/dist/analytics-GNSHP7X3.svg +1 -0
  11. package/dist/bulb-24SQINQB.svg +1 -0
  12. package/dist/chat-TLRFEUAS.svg +1 -0
  13. package/dist/chunk-5FHXD7KR.js +1735 -0
  14. package/dist/chunk-5FHXD7KR.js.map +1 -0
  15. package/dist/chunk-WSOHBA2C.mjs +1693 -0
  16. package/dist/chunk-WSOHBA2C.mjs.map +1 -0
  17. package/dist/edit-RWL72JNM.svg +1 -0
  18. package/dist/face-55KPDCH4.svg +1 -0
  19. package/dist/filled-analytics-RBC7KWND.svg +1 -0
  20. package/dist/filled-bulb-RC7E2WSM.svg +1 -0
  21. package/dist/filled-chat-A6J44Q7A.svg +1 -0
  22. package/dist/filled-edit-NKKWFSTW.svg +1 -0
  23. package/dist/filled-face-UML5C3LB.svg +1 -0
  24. package/dist/filled-layout-HBVCSDFO.svg +1 -0
  25. package/dist/index.css +51 -0
  26. package/dist/index.css.map +1 -0
  27. package/dist/index.d.mts +964 -0
  28. package/dist/index.d.ts +964 -0
  29. package/dist/index.js +5600 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/index.mjs +5401 -0
  32. package/dist/index.mjs.map +1 -0
  33. package/dist/language-VBJ24OPV.svg +1 -0
  34. package/dist/layout-NDDSWNNV.svg +1 -0
  35. package/dist/pending-NF7NSBYO.svg +1 -0
  36. package/dist/receipt-MNLQIFCO.svg +1 -0
  37. package/dist/sparkles-EOEGVL6G.svg +1 -0
  38. package/dist/store-3RQPBJWG.svg +1 -0
  39. package/dist/store_active-SAOAGVKC.svg +1 -0
  40. package/dist/studio-LYPUIEFA.svg +1 -0
  41. package/dist/studio_active-BC6O66OI.svg +1 -0
  42. package/dist/vertical-ellipsis-3G4WEOCW.svg +1 -0
  43. package/package.json +138 -0
  44. package/src/components/Accordion/Accordion.stories.tsx +41 -0
  45. package/src/components/Accordion/Accordion.tsx +14 -0
  46. package/src/components/Accordion/AccordionButton.tsx +40 -0
  47. package/src/components/Accordion/AccordionItem.tsx +17 -0
  48. package/src/components/Accordion/index.ts +4 -0
  49. package/src/components/Alert/Alert.stories.tsx +38 -0
  50. package/src/components/Alert/Alert.styles.ts +19 -0
  51. package/src/components/Alert/Alert.tsx +41 -0
  52. package/src/components/Alert/Alert.types.ts +5 -0
  53. package/src/components/Alert/index.ts +1 -0
  54. package/src/components/AutowidthInput/AutowidthInput.stories.tsx +23 -0
  55. package/src/components/AutowidthInput/AutowidthInput.tsx +47 -0
  56. package/src/components/AutowidthInput/index.ts +1 -0
  57. package/src/components/Avatar/Avatar.stories.tsx +23 -0
  58. package/src/components/Avatar/Avatar.tsx +19 -0
  59. package/src/components/Avatar/index.tsx +1 -0
  60. package/src/components/Badge/Badge.stories.tsx +23 -0
  61. package/src/components/Badge/Badge.styles.ts +11 -0
  62. package/src/components/Badge/Badge.tsx +26 -0
  63. package/src/components/Badge/index.ts +2 -0
  64. package/src/components/Banner/Banner.stories.tsx +37 -0
  65. package/src/components/Banner/Banner.styles.ts +79 -0
  66. package/src/components/Banner/Banner.tsx +68 -0
  67. package/src/components/Banner/Banner.types.ts +6 -0
  68. package/src/components/Banner/index.ts +2 -0
  69. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +14 -0
  70. package/src/components/Breadcrumb/Breadcrumb.tsx +19 -0
  71. package/src/components/Breadcrumb/Breadcrumb.types.ts +3 -0
  72. package/src/components/Breadcrumb/BreadcrumbItem/BreadcrumbItem.tsx +12 -0
  73. package/src/components/Breadcrumb/BreadcrumbItem/BreadcrumbItem.types.ts +3 -0
  74. package/src/components/Breadcrumb/BreadcrumbItem/index.ts +2 -0
  75. package/src/components/Breadcrumb/BreadcrumbLink/BreadcrumbLink.tsx +30 -0
  76. package/src/components/Breadcrumb/BreadcrumbLink/BreadcrumbLink.types.ts +3 -0
  77. package/src/components/Breadcrumb/BreadcrumbLink/index.ts +2 -0
  78. package/src/components/Breadcrumb/index.ts +3 -0
  79. package/src/components/Button/Button.stories.tsx +52 -0
  80. package/src/components/Button/Button.styles.ts +59 -0
  81. package/src/components/Button/Button.tsx +43 -0
  82. package/src/components/Button/Button.types.ts +13 -0
  83. package/src/components/Button/index.tsx +3 -0
  84. package/src/components/Card/Card.stories.tsx +24 -0
  85. package/src/components/Card/Card.styles.ts +30 -0
  86. package/src/components/Card/Card.tsx +29 -0
  87. package/src/components/Card/Card.types.ts +8 -0
  88. package/src/components/Card/index.ts +2 -0
  89. package/src/components/Carousel/Carousel.stories.tsx +159 -0
  90. package/src/components/Carousel/Carousel.tsx +160 -0
  91. package/src/components/Carousel/Carousel.types.ts +22 -0
  92. package/src/components/Carousel/index.ts +1 -0
  93. package/src/components/CarouselModal/CarouselModal.stories.tsx +53 -0
  94. package/src/components/CarouselModal/CarouselModal.tsx +106 -0
  95. package/src/components/CarouselModal/CarouselModal.types.ts +16 -0
  96. package/src/components/CarouselModal/index.ts +2 -0
  97. package/src/components/Checkbox/Checkbox.stories.tsx +16 -0
  98. package/src/components/Checkbox/Checkbox.tsx +29 -0
  99. package/src/components/Checkbox/Checkbox.types.ts +3 -0
  100. package/src/components/Checkbox/index.ts +2 -0
  101. package/src/components/Chip/Chip.stories.tsx +44 -0
  102. package/src/components/Chip/Chip.styles.ts +114 -0
  103. package/src/components/Chip/Chip.tsx +23 -0
  104. package/src/components/Chip/Chip.types.ts +14 -0
  105. package/src/components/Chip/index.ts +2 -0
  106. package/src/components/ChipButton/Chip.types.ts +4 -0
  107. package/src/components/ChipButton/ChipButton.tsx +25 -0
  108. package/src/components/ChipButton/index.ts +1 -0
  109. package/src/components/Code/Code.stories.tsx +28 -0
  110. package/src/components/Code/Code.tsx +160 -0
  111. package/src/components/Code/Code.types.ts +40 -0
  112. package/src/components/Code/_components/CopyButton.tsx +48 -0
  113. package/src/components/Code/index.ts +1 -0
  114. package/src/components/CodeTabs/CodeTabs.stories.tsx +51 -0
  115. package/src/components/CodeTabs/CodeTabs.tsx +98 -0
  116. package/src/components/CodeTabs/CodeTabs.types.ts +17 -0
  117. package/src/components/CodeTabs/index.ts +1 -0
  118. package/src/components/Container/Container.stories.tsx +28 -0
  119. package/src/components/Container/Container.tsx +21 -0
  120. package/src/components/Container/index.ts +1 -0
  121. package/src/components/Container/useContainerSize.ts +47 -0
  122. package/src/components/CopyableCode/CopyableCode.stories.tsx +26 -0
  123. package/src/components/CopyableCode/CopyableCode.tsx +58 -0
  124. package/src/components/CopyableCode/CopyableCode.types.ts +7 -0
  125. package/src/components/CopyableCode/index.ts +2 -0
  126. package/src/components/CrossPageToasts/CrossPageToasts.tsx +33 -0
  127. package/src/components/CrossPageToasts/index.ts +1 -0
  128. package/src/components/DataField/DataField.stories.tsx +61 -0
  129. package/src/components/DataField/DataField.styles.ts +33 -0
  130. package/src/components/DataField/DataField.tsx +141 -0
  131. package/src/components/DataField/DataField.types.ts +18 -0
  132. package/src/components/DataField/index.ts +1 -0
  133. package/src/components/DatePicker/RangeDatePicker.stories.tsx +45 -0
  134. package/src/components/DatePicker/RangeDatePicker.tsx +74 -0
  135. package/src/components/DatePicker/SingleDatePicker.stories.tsx +31 -0
  136. package/src/components/DatePicker/SingleDatePicker.tsx +72 -0
  137. package/src/components/DatePicker/index.ts +2 -0
  138. package/src/components/FileInput/FileInput.stories.tsx +28 -0
  139. package/src/components/FileInput/FileInput.tsx +117 -0
  140. package/src/components/FileInput/FileInput.types.ts +14 -0
  141. package/src/components/FileInput/index.ts +2 -0
  142. package/src/components/FileItem/FileItem.stories.tsx +27 -0
  143. package/src/components/FileItem/FileItem.tsx +134 -0
  144. package/src/components/FileItem/FileItem.types.ts +11 -0
  145. package/src/components/FileItem/index.ts +1 -0
  146. package/src/components/FileList/FileList.stories.tsx +65 -0
  147. package/src/components/FileList/FileList.tsx +97 -0
  148. package/src/components/FileList/FileList.types.ts +18 -0
  149. package/src/components/FileList/index.tsx +1 -0
  150. package/src/components/FormControl/FormControl.stories.tsx +16 -0
  151. package/src/components/FormControl/FormControl.tsx +12 -0
  152. package/src/components/FormControl/FormControl.types.ts +3 -0
  153. package/src/components/FormControl/index.ts +2 -0
  154. package/src/components/FormLabel/FormLabel.tsx +5 -0
  155. package/src/components/FormLabel/index.ts +1 -0
  156. package/src/components/GuideCue/GuideCue.stories.tsx +57 -0
  157. package/src/components/GuideCue/GuideCue.tsx +231 -0
  158. package/src/components/GuideCue/GuideCueContext.tsx +70 -0
  159. package/src/components/GuideCue/index.ts +2 -0
  160. package/src/components/Icon/Icon.stories.tsx +77 -0
  161. package/src/components/Icon/Icon.styles.ts +6 -0
  162. package/src/components/Icon/Icon.tsx +73 -0
  163. package/src/components/Icon/Icon.types.ts +10 -0
  164. package/src/components/Icon/IconMap.ts +290 -0
  165. package/src/components/Icon/icons/analytics.svg +1 -0
  166. package/src/components/Icon/icons/bulb.svg +1 -0
  167. package/src/components/Icon/icons/chat.svg +1 -0
  168. package/src/components/Icon/icons/edit.svg +1 -0
  169. package/src/components/Icon/icons/face.svg +1 -0
  170. package/src/components/Icon/icons/filled-analytics.svg +1 -0
  171. package/src/components/Icon/icons/filled-bulb.svg +1 -0
  172. package/src/components/Icon/icons/filled-chat.svg +1 -0
  173. package/src/components/Icon/icons/filled-edit.svg +1 -0
  174. package/src/components/Icon/icons/filled-face.svg +1 -0
  175. package/src/components/Icon/icons/filled-layout.svg +1 -0
  176. package/src/components/Icon/icons/language.svg +1 -0
  177. package/src/components/Icon/icons/layout.svg +1 -0
  178. package/src/components/Icon/icons/pending.svg +1 -0
  179. package/src/components/Icon/icons/receipt.svg +1 -0
  180. package/src/components/Icon/icons/sparkles.svg +1 -0
  181. package/src/components/Icon/icons/store.svg +1 -0
  182. package/src/components/Icon/icons/store_active.svg +1 -0
  183. package/src/components/Icon/icons/studio.svg +1 -0
  184. package/src/components/Icon/icons/studio_active.svg +1 -0
  185. package/src/components/Icon/icons/vertical-ellipsis.svg +1 -0
  186. package/src/components/Icon/index.tsx +3 -0
  187. package/src/components/IconButton/IconButton.stories.tsx +51 -0
  188. package/src/components/IconButton/IconButton.styles.ts +52 -0
  189. package/src/components/IconButton/IconButton.tsx +36 -0
  190. package/src/components/IconButton/IconButton.types.ts +12 -0
  191. package/src/components/IconButton/index.tsx +1 -0
  192. package/src/components/InfoSprinkle/InfoSprinkle.stories.tsx +25 -0
  193. package/src/components/InfoSprinkle/InfoSprinkle.tsx +48 -0
  194. package/src/components/InfoSprinkle/index.ts +1 -0
  195. package/src/components/InlineCode/InlineCode.tsx +18 -0
  196. package/src/components/InlineCode/index.ts +1 -0
  197. package/src/components/Input/Input.stories.tsx +55 -0
  198. package/src/components/Input/Input.tsx +358 -0
  199. package/src/components/Input/Input.types.ts +19 -0
  200. package/src/components/Input/index.tsx +2 -0
  201. package/src/components/LineGraph/LineGraph.stories.tsx +98 -0
  202. package/src/components/LineGraph/LineGraph.tsx +88 -0
  203. package/src/components/LineGraph/LineGraph.types.ts +41 -0
  204. package/src/components/LineGraph/index.ts +1 -0
  205. package/src/components/Link/Link.styles.ts +13 -0
  206. package/src/components/Link/Link.tsx +93 -0
  207. package/src/components/Link/index.ts +1 -0
  208. package/src/components/Loaders/PageLoader.stories.tsx +29 -0
  209. package/src/components/Loaders/PageLoader.tsx +30 -0
  210. package/src/components/Loaders/SectionLoader.stories.tsx +26 -0
  211. package/src/components/Loaders/SectionLoader.tsx +30 -0
  212. package/src/components/Loaders/index.ts +1 -0
  213. package/src/components/MDXEditor/MDXEditor.css +21 -0
  214. package/src/components/MDXEditor/MDXEditor.stories.tsx +45 -0
  215. package/src/components/MDXEditor/MDXEditor.tsx +189 -0
  216. package/src/components/MDXEditor/MDXEditor.types.ts +6 -0
  217. package/src/components/MDXEditor/index.ts +1 -0
  218. package/src/components/Markdown/Markdown.module.css +30 -0
  219. package/src/components/Markdown/Markdown.tsx +133 -0
  220. package/src/components/Markdown/Markdown.types.ts +5 -0
  221. package/src/components/Markdown/index.ts +2 -0
  222. package/src/components/Masonry/Masonry.stories.tsx +288 -0
  223. package/src/components/Masonry/Masonry.tsx +187 -0
  224. package/src/components/Masonry/Masonry.types.ts +18 -0
  225. package/src/components/Masonry/index.ts +2 -0
  226. package/src/components/MaxLengthIndicator/MaxLengthIndicator.stories.tsx +26 -0
  227. package/src/components/MaxLengthIndicator/MaxLengthIndicator.tsx +25 -0
  228. package/src/components/MaxLengthIndicator/index.tsx +1 -0
  229. package/src/components/Menu/Menu.stories.tsx +186 -0
  230. package/src/components/Menu/MenuButton.tsx +8 -0
  231. package/src/components/Menu/MenuButton.types.ts +23 -0
  232. package/src/components/Menu/MenuItem.tsx +35 -0
  233. package/src/components/Menu/MenuItem.types.ts +13 -0
  234. package/src/components/Menu/MenuList.tsx +19 -0
  235. package/src/components/Menu/index.ts +7 -0
  236. package/src/components/Modal/Modal.stories.tsx +83 -0
  237. package/src/components/Modal/Modal.styles.ts +14 -0
  238. package/src/components/Modal/Modal.tsx +14 -0
  239. package/src/components/Modal/Modal.types.ts +3 -0
  240. package/src/components/Modal/ModalBody.tsx +9 -0
  241. package/src/components/Modal/ModalCloseButton.tsx +18 -0
  242. package/src/components/Modal/ModalContent/ModalContent.tsx +8 -0
  243. package/src/components/Modal/ModalContent/ModalContent.types.ts +3 -0
  244. package/src/components/Modal/ModalContent/index.ts +1 -0
  245. package/src/components/Modal/ModalFooter/ModalFooter.module.css +3 -0
  246. package/src/components/Modal/ModalFooter/ModalFooter.tsx +20 -0
  247. package/src/components/Modal/ModalFooter/index.ts +1 -0
  248. package/src/components/Modal/ModalHeader.tsx +9 -0
  249. package/src/components/Modal/ModalOverlay.tsx +9 -0
  250. package/src/components/Modal/index.tsx +8 -0
  251. package/src/components/MonthRangePicker/MonthButton/MonthButton.tsx +105 -0
  252. package/src/components/MonthRangePicker/MonthButton/MonthButton.types.ts +42 -0
  253. package/src/components/MonthRangePicker/MonthButton/index.ts +2 -0
  254. package/src/components/MonthRangePicker/MonthRangePicker.stories.tsx +164 -0
  255. package/src/components/MonthRangePicker/MonthRangePicker.tsx +274 -0
  256. package/src/components/MonthRangePicker/MonthRangePicker.types.ts +38 -0
  257. package/src/components/MonthRangePicker/_utils/hasEnabledMonthsInYear.ts +15 -0
  258. package/src/components/MonthRangePicker/_utils/index.ts +6 -0
  259. package/src/components/MonthRangePicker/_utils/isMonthDisabled.ts +20 -0
  260. package/src/components/MonthRangePicker/_utils/isMonthInPreviewRange.ts +32 -0
  261. package/src/components/MonthRangePicker/_utils/isMonthInRange.ts +17 -0
  262. package/src/components/MonthRangePicker/_utils/isMonthSelected.ts +19 -0
  263. package/src/components/MonthRangePicker/_utils/isSelectionStart.ts +12 -0
  264. package/src/components/MonthRangePicker/constants.ts +63 -0
  265. package/src/components/MonthRangePicker/index.ts +2 -0
  266. package/src/components/Pagination/Pagination.stories.tsx +51 -0
  267. package/src/components/Pagination/Pagination.tsx +150 -0
  268. package/src/components/Pagination/Pagination.types.ts +12 -0
  269. package/src/components/Pagination/index.tsx +1 -0
  270. package/src/components/PasswordInput/PasswordInput.stories.tsx +16 -0
  271. package/src/components/PasswordInput/PasswordInput.tsx +42 -0
  272. package/src/components/PasswordInput/PasswordInput.types.ts +11 -0
  273. package/src/components/PasswordInput/index.ts +1 -0
  274. package/src/components/PinInput/PinInput.stories.tsx +26 -0
  275. package/src/components/PinInput/PinInput.tsx +53 -0
  276. package/src/components/PinInput/PinInput.types.ts +27 -0
  277. package/src/components/PinInput/index.tsx +2 -0
  278. package/src/components/ProgressBar/ProgressBar.stories.tsx +18 -0
  279. package/src/components/ProgressBar/ProgressBar.styles.ts +4 -0
  280. package/src/components/ProgressBar/ProgressBar.tsx +27 -0
  281. package/src/components/ProgressBar/ProgressBar.types.ts +4 -0
  282. package/src/components/ProgressBar/index.ts +1 -0
  283. package/src/components/RadialProgress/RadialProgress.stories.tsx +272 -0
  284. package/src/components/RadialProgress/RadialProgress.tsx +232 -0
  285. package/src/components/RadialProgress/RadialProgress.types.ts +27 -0
  286. package/src/components/RadialProgress/index.ts +2 -0
  287. package/src/components/Radio/Radio.stories.tsx +226 -0
  288. package/src/components/Radio/Radio.tsx +35 -0
  289. package/src/components/Radio/Radio.types.ts +21 -0
  290. package/src/components/Radio/RadioGroup.tsx +26 -0
  291. package/src/components/Radio/index.ts +3 -0
  292. package/src/components/SeeMoreButton/SeeMoreButton.stories.tsx +48 -0
  293. package/src/components/SeeMoreButton/SeeMoreButton.styles.ts +11 -0
  294. package/src/components/SeeMoreButton/SeeMoreButton.tsx +34 -0
  295. package/src/components/SeeMoreButton/SeeMoreButton.types.ts +6 -0
  296. package/src/components/SeeMoreButton/index.tsx +1 -0
  297. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +96 -0
  298. package/src/components/SegmentedControl/SegmentedControl.styles.ts +28 -0
  299. package/src/components/SegmentedControl/SegmentedControl.tsx +89 -0
  300. package/src/components/SegmentedControl/SegmentedControl.types.ts +15 -0
  301. package/src/components/SegmentedControl/index.ts +2 -0
  302. package/src/components/SegmentedProgressBar/ProgressSegment.tsx +18 -0
  303. package/src/components/SegmentedProgressBar/SegmentedProgressBar.stories.tsx +228 -0
  304. package/src/components/SegmentedProgressBar/SegmentedProgressBar.tsx +25 -0
  305. package/src/components/SegmentedProgressBar/SegmentedProgressBar.types.ts +11 -0
  306. package/src/components/SegmentedProgressBar/SegmentedProgressBarContext.tsx +24 -0
  307. package/src/components/SegmentedProgressBar/index.ts +3 -0
  308. package/src/components/Select/MenuList/MenuList.tsx +87 -0
  309. package/src/components/Select/MenuList/MenuList.types.ts +21 -0
  310. package/src/components/Select/MenuList/VirtualizedMenuList.tsx +140 -0
  311. package/src/components/Select/MenuList/VirtualizedMenuListContext.tsx +35 -0
  312. package/src/components/Select/MenuList/index.ts +3 -0
  313. package/src/components/Select/Select.stories.tsx +70 -0
  314. package/src/components/Select/Select.styles.ts +102 -0
  315. package/src/components/Select/Select.tsx +204 -0
  316. package/src/components/Select/Select.types.ts +18 -0
  317. package/src/components/Select/_utils/resolveStyle.ts +21 -0
  318. package/src/components/Select/index.ts +1 -0
  319. package/src/components/Slider/Slider.stories.tsx +75 -0
  320. package/src/components/Slider/Slider.tsx +12 -0
  321. package/src/components/Slider/Slider.types.ts +3 -0
  322. package/src/components/Slider/SliderFilledTrack/SliderFilledTrack.tsx +14 -0
  323. package/src/components/Slider/SliderFilledTrack/SliderFilledTrack.types.ts +3 -0
  324. package/src/components/Slider/SliderFilledTrack/index.ts +2 -0
  325. package/src/components/Slider/SliderMark/SliderMark.tsx +12 -0
  326. package/src/components/Slider/SliderMark/SliderMark.types.ts +3 -0
  327. package/src/components/Slider/SliderMark/index.ts +2 -0
  328. package/src/components/Slider/SliderThumb/SliderThumb.tsx +22 -0
  329. package/src/components/Slider/SliderThumb/SliderThumb.types.ts +3 -0
  330. package/src/components/Slider/SliderThumb/index.ts +2 -0
  331. package/src/components/Slider/SliderTrack/SliderTrack.tsx +12 -0
  332. package/src/components/Slider/SliderTrack/SliderTrack.types.ts +3 -0
  333. package/src/components/Slider/SliderTrack/index.ts +2 -0
  334. package/src/components/Slider/index.ts +5 -0
  335. package/src/components/Spinner/Spinner.stories.tsx +16 -0
  336. package/src/components/Spinner/Spinner.tsx +20 -0
  337. package/src/components/Spinner/Spinner.types.ts +3 -0
  338. package/src/components/Spinner/index.ts +2 -0
  339. package/src/components/Switch/Switch.stories.tsx +63 -0
  340. package/src/components/Switch/Switch.tsx +8 -0
  341. package/src/components/Switch/index.ts +1 -0
  342. package/src/components/Table/ExpandingTr/ExpandingTr.tsx +31 -0
  343. package/src/components/Table/ExpandingTr/ExpandingTr.types.ts +9 -0
  344. package/src/components/Table/ExpandingTr/index.ts +2 -0
  345. package/src/components/Table/Table.stories.tsx +326 -0
  346. package/src/components/Table/Table.styles.ts +48 -0
  347. package/src/components/Table/Table.tsx +9 -0
  348. package/src/components/Table/Table.types.ts +16 -0
  349. package/src/components/Table/TableContainer.tsx +55 -0
  350. package/src/components/Table/TableContext.tsx +187 -0
  351. package/src/components/Table/Tbody.tsx +12 -0
  352. package/src/components/Table/Td.tsx +138 -0
  353. package/src/components/Table/Th.tsx +154 -0
  354. package/src/components/Table/Thead.tsx +5 -0
  355. package/src/components/Table/Tr.tsx +5 -0
  356. package/src/components/Table/index.tsx +8 -0
  357. package/src/components/Tabs/Tab/Tab.styles.ts +35 -0
  358. package/src/components/Tabs/Tab/Tab.tsx +67 -0
  359. package/src/components/Tabs/Tab/index.ts +1 -0
  360. package/src/components/Tabs/TabList/TabList.styles.ts +11 -0
  361. package/src/components/Tabs/TabList/TabList.tsx +19 -0
  362. package/src/components/Tabs/TabList/index.ts +1 -0
  363. package/src/components/Tabs/TabPanel.tsx +5 -0
  364. package/src/components/Tabs/TabPanels.tsx +5 -0
  365. package/src/components/Tabs/Tabs.stories.tsx +45 -0
  366. package/src/components/Tabs/Tabs.tsx +65 -0
  367. package/src/components/Tabs/Tabs.types.ts +19 -0
  368. package/src/components/Tabs/TabsContext.tsx +162 -0
  369. package/src/components/Tabs/index.tsx +5 -0
  370. package/src/components/Tag/Tag.stories.tsx +28 -0
  371. package/src/components/Tag/Tag.styles.ts +12 -0
  372. package/src/components/Tag/Tag.tsx +23 -0
  373. package/src/components/Tag/Tag.types.ts +5 -0
  374. package/src/components/Tag/TagCloseButton/TagCloseButton.tsx +12 -0
  375. package/src/components/Tag/TagCloseButton/TagCloseButton.types.ts +3 -0
  376. package/src/components/Tag/TagCloseButton/index.ts +2 -0
  377. package/src/components/Tag/TagLabel/TagLabel.tsx +12 -0
  378. package/src/components/Tag/TagLabel/TagLabel.types.ts +3 -0
  379. package/src/components/Tag/TagLabel/index.ts +2 -0
  380. package/src/components/Tag/TagLeftIcon/TagLeftIcon.tsx +12 -0
  381. package/src/components/Tag/TagLeftIcon/TagLeftIcon.types.ts +3 -0
  382. package/src/components/Tag/TagLeftIcon/index.ts +2 -0
  383. package/src/components/Tag/TagRightIcon/TagRightIcon.tsx +12 -0
  384. package/src/components/Tag/TagRightIcon/TagRightIcon.types.ts +3 -0
  385. package/src/components/Tag/TagRightIcon/index.ts +2 -0
  386. package/src/components/Tag/index.ts +5 -0
  387. package/src/components/Textarea/Textarea.tsx +56 -0
  388. package/src/components/Textarea/adjustHeight.tsx +9 -0
  389. package/src/components/Textarea/index.ts +1 -0
  390. package/src/components/Toast/Toast.stories.tsx +49 -0
  391. package/src/components/Toast/Toast.styles.ts +19 -0
  392. package/src/components/Toast/Toast.tsx +38 -0
  393. package/src/components/Toast/Toast.types.ts +22 -0
  394. package/src/components/Toast/ToastIcon/ToastIcon.tsx +26 -0
  395. package/src/components/Toast/ToastIcon/index.ts +0 -0
  396. package/src/components/Toast/index.ts +2 -0
  397. package/src/components/Toast/useToast.tsx +65 -0
  398. package/src/components/Tooltip/Tooltip.stories.tsx +97 -0
  399. package/src/components/Tooltip/Tooltip.tsx +22 -0
  400. package/src/components/Tooltip/Tooltip.types.ts +3 -0
  401. package/src/components/Tooltip/index.ts +2 -0
  402. package/src/components/Typography/H1.tsx +17 -0
  403. package/src/components/Typography/H2.tsx +17 -0
  404. package/src/components/Typography/H3.tsx +17 -0
  405. package/src/components/Typography/H4.tsx +17 -0
  406. package/src/components/Typography/H5.tsx +17 -0
  407. package/src/components/Typography/Link.tsx +49 -0
  408. package/src/components/Typography/Subtext.tsx +17 -0
  409. package/src/components/Typography/Subtitle.tsx +18 -0
  410. package/src/components/Typography/Text.tsx +22 -0
  411. package/src/components/Typography/Typography.stories.tsx +54 -0
  412. package/src/components/Typography/Typography.types.ts +3 -0
  413. package/src/components/Typography/index.ts +26 -0
  414. package/src/components/UrlInput/UrlInput.stories.tsx +66 -0
  415. package/src/components/UrlInput/UrlInput.tsx +47 -0
  416. package/src/components/UrlInput/index.tsx +1 -0
  417. package/src/hooks/useLocale.ts +11 -0
  418. package/src/hooks/useTranslate.ts +57 -0
  419. package/src/index.ts +96 -0
  420. package/src/theme/Palette.stories.tsx +171 -0
  421. package/src/theme/colors.ts +64 -0
  422. package/src/theme/font.ts +23 -0
  423. package/src/theme/global.ts +30 -0
  424. package/src/theme/index.ts +49 -0
  425. package/src/translations/Defaults.translations.json +100 -0
  426. package/src/types/css-modules.d.ts +0 -0
  427. package/src/types/svg.d.ts +15 -0
  428. package/src/utils/findKeyByValue.ts +17 -0
  429. package/src/utils/formatDateByLocale.ts +36 -0
  430. package/src/utils/formatFileSize.ts +14 -0
  431. package/src/utils/formatNumber.ts +29 -0
  432. package/src/utils/formatTextForMarkdown.ts +3 -0
@@ -0,0 +1,114 @@
1
+ import * as CSS from 'csstype';
2
+
3
+ import theme from '@/theme/index';
4
+
5
+ import { ChipProps, ChipUseCase } from './Chip.types';
6
+
7
+ export const baseStyles = {
8
+ borderRadius: '32px', // large border radius to round it
9
+ px: 3,
10
+ py: 2, // Use direct spacing value instead of theme.spacing[2]
11
+ textTransform: 'none' as CSS.Property.TextTransform,
12
+ };
13
+
14
+ export const useCaseStyles: Record<
15
+ ChipUseCase,
16
+ Record<string, Partial<ChipProps>>
17
+ > = {
18
+ primary: {
19
+ solid: {
20
+ bgColor: theme.semanticTokens.colors.primary.main,
21
+ color: 'white',
22
+ },
23
+ outline: {
24
+ border: '1px solid',
25
+ borderColor: theme.semanticTokens.colors.primary.main,
26
+ color: theme.semanticTokens.colors.primary.main,
27
+ bgColor: 'white',
28
+ },
29
+ subtle: {
30
+ bgColor: '#EBF0FB',
31
+ color: theme.semanticTokens.colors.primary.main,
32
+ },
33
+ },
34
+ secondary: {
35
+ solid: {
36
+ bgColor: theme.colors.blue[700],
37
+ color: theme.colors.white,
38
+ },
39
+ outline: {
40
+ border: '1px solid',
41
+ borderColor: theme.colors.blue[700],
42
+ color: theme.colors.blue[700],
43
+ bgColor: 'white',
44
+ },
45
+ subtle: {
46
+ bgColor: theme.colors.blue[50],
47
+ color: theme.colors.blue[700],
48
+ },
49
+ },
50
+ success: {
51
+ solid: {
52
+ bgColor: theme.semanticTokens.colors.success.main,
53
+ color: 'white',
54
+ },
55
+ outline: {
56
+ border: '1px solid',
57
+ borderColor: theme.semanticTokens.colors.success.main,
58
+ color: theme.semanticTokens.colors.success.main,
59
+ bgColor: 'white',
60
+ },
61
+ subtle: {
62
+ bgColor: theme.colors.green[50],
63
+ color: theme.semanticTokens.colors.success.main,
64
+ },
65
+ },
66
+ danger: {
67
+ solid: {
68
+ bgColor: theme.semanticTokens.colors.danger.main,
69
+ color: 'white',
70
+ },
71
+ outline: {
72
+ border: '1px solid',
73
+ borderColor: theme.semanticTokens.colors.danger.main,
74
+ color: theme.semanticTokens.colors.danger.main,
75
+ bgColor: 'white',
76
+ },
77
+ subtle: {
78
+ bgColor: theme.semanticTokens.colors.danger.lighter,
79
+ color: theme.semanticTokens.colors.danger.main,
80
+ },
81
+ },
82
+ dark: {
83
+ solid: {
84
+ bgColor: theme.colors.gray[800],
85
+ color: 'white',
86
+ },
87
+ outline: {
88
+ border: '1px solid',
89
+ backgroundColor: 'transparent',
90
+ borderColor: theme.colors.gray[700],
91
+ color: theme.colors.gray[700],
92
+ },
93
+ subtle: {
94
+ bgColor: theme.colors.gray[100],
95
+ color: theme.colors.gray[800],
96
+ },
97
+ },
98
+ highlight: {
99
+ solid: {
100
+ bgColor: theme.colors.purple[600],
101
+ color: 'white',
102
+ },
103
+ outline: {
104
+ border: '1px solid',
105
+ backgroundColor: 'transparent',
106
+ borderColor: theme.colors.purple[600],
107
+ color: theme.colors.purple[600],
108
+ },
109
+ subtle: {
110
+ bgColor: theme.colors.purple[50],
111
+ color: theme.colors.purple[600],
112
+ },
113
+ },
114
+ };
@@ -0,0 +1,23 @@
1
+ import { Badge as ChakraBadge } from '@chakra-ui/react';
2
+
3
+ import { baseStyles, useCaseStyles } from './Chip.styles';
4
+ import { ChipProps } from './Chip.types';
5
+
6
+ /**
7
+ * A component that wraps the Chakra Badge component, but styled to look like a Chip component
8
+ */
9
+ export const Chip = ({
10
+ useCase = 'primary', // default to secondary as they are less likely to cause bigger design issues
11
+ variant = 'subtle',
12
+ ...rest
13
+ }: ChipProps) => {
14
+ return (
15
+ <ChakraBadge
16
+ {...baseStyles}
17
+ {...useCaseStyles[useCase][variant]}
18
+ {...rest}
19
+ />
20
+ );
21
+ };
22
+
23
+ Chip.displayName = 'Chip';
@@ -0,0 +1,14 @@
1
+ import { BadgeProps as ChakraBadgeProps } from '@chakra-ui/react';
2
+
3
+ export type ChipUseCase =
4
+ | 'danger'
5
+ | 'success'
6
+ | 'primary'
7
+ | 'secondary'
8
+ | 'dark'
9
+ | 'highlight';
10
+
11
+ export interface ChipProps extends ChakraBadgeProps {
12
+ useCase?: ChipUseCase;
13
+ variant?: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ export { Chip } from './Chip';
2
+ export { useCaseStyles } from './Chip.styles';
@@ -0,0 +1,4 @@
1
+ export type ChipButtonPropsTypes = {
2
+ rightIcon?: React.ReactElement;
3
+ leftIcon?: React.ReactElement;
4
+ };
@@ -0,0 +1,25 @@
1
+ import { ForwardedRef, forwardRef } from 'react';
2
+ import { Button as ChakraButton, ButtonProps } from '@chakra-ui/react';
3
+
4
+ import { ChipButtonPropsTypes } from './Chip.types';
5
+
6
+ export const ChipButton = forwardRef(
7
+ (
8
+ { rightIcon, leftIcon, ...rest }: ChipButtonPropsTypes & ButtonProps,
9
+ ref?: ForwardedRef<HTMLButtonElement>
10
+ ) => {
11
+ return (
12
+ <ChakraButton
13
+ rightIcon={rightIcon ?? undefined}
14
+ leftIcon={leftIcon ?? undefined}
15
+ iconSpacing={1}
16
+ border="1px solid"
17
+ width="fit-content"
18
+ {...rest}
19
+ ref={ref}
20
+ />
21
+ );
22
+ }
23
+ );
24
+
25
+ ChipButton.displayName = 'ChipButton';
@@ -0,0 +1 @@
1
+ export { ChipButton } from './ChipButton';
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { Meta, StoryFn } from '@storybook/react';
3
+
4
+ import { Code } from './Code';
5
+ import { CodeProps } from './Code.types';
6
+
7
+ const meta: Meta<typeof Code> = {
8
+ title: 'Components/Code',
9
+ component: Code,
10
+ args: {
11
+ children: `const t = 'test';`,
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+
17
+ const Template: StoryFn<CodeProps> = (args: CodeProps) => <Code {...args} />;
18
+
19
+ export const Basic: StoryFn<CodeProps> = Template.bind({});
20
+ Basic.args = {};
21
+
22
+ export const Copyable: StoryFn<CodeProps> = Template.bind({});
23
+ Copyable.args = {
24
+ onCopy: (str) => {
25
+ navigator.clipboard.writeText(str);
26
+ console.log(str);
27
+ },
28
+ };
@@ -0,0 +1,160 @@
1
+ import { lazy, Suspense, useState } from 'react';
2
+ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
3
+ import { a11yDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
4
+ import { Box, Flex, Spinner } from '@chakra-ui/react';
5
+
6
+ import { useTranslate } from '@/hooks/useTranslate';
7
+
8
+ import { Card } from '../Card';
9
+ import { InlineCode } from '../InlineCode';
10
+ import { SegmentedControl } from '../SegmentedControl';
11
+ import { Subtext } from '../Typography';
12
+ import { CopyButton } from './_components/CopyButton';
13
+ import { CodeProps } from './Code.types';
14
+
15
+ // Use dynamic import to break circular dependency
16
+ const Markdown = lazy(() =>
17
+ import('../Markdown').then((module) => ({ default: module.Markdown }))
18
+ );
19
+
20
+ export const Code = ({
21
+ children,
22
+ language: languageProp,
23
+ onCopy,
24
+ style = a11yDark,
25
+ customStyle,
26
+ hideHeader = false,
27
+ containerProps,
28
+ ...rest
29
+ }: CodeProps) => {
30
+ const language = languageProp === 'js' ? 'javascript' : languageProp;
31
+
32
+ const translate = useTranslate();
33
+
34
+ const [isMarkdownPreviewMode, setIsMarkdownPreviewMode] =
35
+ useState<boolean>(false);
36
+
37
+ const handleCopyClick = () => {
38
+ onCopy?.(children);
39
+ };
40
+
41
+ const handleMarkdownModeChange = (selectedValue: string) => {
42
+ setIsMarkdownPreviewMode(selectedValue === 'preview');
43
+ };
44
+
45
+ // On click (not drag), select the code content
46
+ const handleSyntaxHighlighterClick = (
47
+ e: React.MouseEvent<HTMLPreElement>
48
+ ) => {
49
+ // Skip selection on double-click or if user is already selecting text
50
+ if (e.detail > 1 || window.getSelection()?.toString() !== '') {
51
+ return;
52
+ }
53
+
54
+ try {
55
+ // Find the first child element that contains the code text
56
+ const codeElement = e.currentTarget.querySelector('code');
57
+
58
+ if (codeElement) {
59
+ const range = document.createRange();
60
+ range.selectNodeContents(codeElement);
61
+
62
+ const selection = window.getSelection();
63
+ if (selection) {
64
+ selection.removeAllRanges();
65
+ selection.addRange(range);
66
+ }
67
+ }
68
+ } catch (error) {
69
+ console.error('Error selecting code content:', error);
70
+ }
71
+ };
72
+
73
+ return (
74
+ <Card
75
+ p={0}
76
+ borderRadius="none"
77
+ {...containerProps}
78
+ className={['ml-code', containerProps?.className].join(' ')}
79
+ >
80
+ {!hideHeader && language && (
81
+ <Flex
82
+ className="ml-code-header"
83
+ justify="space-between"
84
+ align="center"
85
+ px={4}
86
+ py={2}
87
+ bgColor="white"
88
+ borderBottom="1px solid"
89
+ borderColor="primary.light"
90
+ width="100%"
91
+ zIndex={2} // show above the code block, but below the TopNav
92
+ >
93
+ <Subtext fontWeight="bold" color="gray.1200">
94
+ <pre>{language}</pre>
95
+ </Subtext>
96
+ <Flex align="center" justify="flex-end" gap={2}>
97
+ {language === 'markdown' && (
98
+ <SegmentedControl
99
+ size="sm"
100
+ options={[
101
+ {
102
+ label: translate('code_markdown_raw') as string,
103
+ value: 'raw',
104
+ },
105
+ {
106
+ label: translate('code_markdown_preview') as string,
107
+ value: 'preview',
108
+ },
109
+ ]}
110
+ onSelect={handleMarkdownModeChange}
111
+ />
112
+ )}
113
+ {onCopy && <CopyButton onClick={handleCopyClick} />}
114
+ </Flex>
115
+ </Flex>
116
+ )}
117
+ <Box overflow="hidden">
118
+ <Box position="relative" overflowY="scroll" h="fit-content" p={0}>
119
+ {isMarkdownPreviewMode ? (
120
+ <Box p={2}>
121
+ <Suspense fallback={<Spinner />}>
122
+ <Markdown
123
+ // Prevent infinite loop of markdown rendering
124
+ components={{
125
+ code: ({ className, ...rest }: any) => {
126
+ // className denotes the language of the code block and only exists for block code
127
+ if (!className) {
128
+ return <InlineCode {...rest} />;
129
+ }
130
+ },
131
+ }}
132
+ >
133
+ {children}
134
+ </Markdown>
135
+ </Suspense>
136
+ </Box>
137
+ ) : (
138
+ // @ts-expect-error - SyntaxHighlighter type issues with React 18
139
+ <SyntaxHighlighter
140
+ language={language}
141
+ style={style}
142
+ wrapLines
143
+ wrapLongLines
144
+ {...rest}
145
+ customStyle={{
146
+ maxWidth: '100%',
147
+ margin: 0,
148
+ borderRadius: 0,
149
+ ...customStyle,
150
+ }}
151
+ onClick={handleSyntaxHighlighterClick}
152
+ >
153
+ {children}
154
+ </SyntaxHighlighter>
155
+ )}
156
+ </Box>
157
+ </Box>
158
+ </Card>
159
+ );
160
+ };
@@ -0,0 +1,40 @@
1
+ import { SyntaxHighlighterProps } from 'react-syntax-highlighter';
2
+ import { BoxProps } from '@chakra-ui/react';
3
+
4
+ /**
5
+ * Code component props
6
+ */
7
+ export interface CodeProps
8
+ extends Omit<SyntaxHighlighterProps, 'style' | 'customStyle'> {
9
+ children: string;
10
+ /**
11
+ * Callback for when the copy button is clicked. No copy button is rendered if this prop is not provided.
12
+ * The user is expected to handle the copying behavior.
13
+ *
14
+ * @param str The copied text
15
+ */
16
+ onCopy?: (str: string) => void;
17
+
18
+ language?: string;
19
+
20
+ // Style object from react-syntax-highlighter
21
+ style?: { [key: string]: React.CSSProperties };
22
+
23
+ // Custom style object for the syntax highlighter
24
+ customStyle?: React.CSSProperties;
25
+
26
+ containerProps?: BoxProps;
27
+
28
+ /**
29
+ * Threshold in pixels for when the header should become sticky.
30
+ * This is typically the height of any fixed header above this component.
31
+ * @default 48
32
+ */
33
+ stickyHeaderThreshold?: number;
34
+
35
+ /**
36
+ * Whether to hide the header of the code block.
37
+ * @default false
38
+ */
39
+ hideHeader?: boolean;
40
+ }
@@ -0,0 +1,48 @@
1
+ import { MouseEventHandler, useState } from 'react';
2
+
3
+ import { Icon } from '@/components/Icon';
4
+ import { IconButton } from '@/components/IconButton';
5
+ import { IconButtonProps } from '@/components/IconButton/IconButton.types';
6
+ import { Tooltip } from '@/components/Tooltip';
7
+ import { useTranslate } from '@/hooks/useTranslate';
8
+
9
+ export const CopyButton = ({
10
+ onClick,
11
+ ...rest
12
+ }: Omit<IconButtonProps, 'aria-label'>) => {
13
+ const translate = useTranslate();
14
+ const [labelText, setLabelText] = useState<string>(
15
+ translate('copy') as string
16
+ );
17
+
18
+ // Allow both boolean and undefined to toggle back and forth between controlled and uncontrolled states fluidly
19
+ const [isTooltipOpen, setIsTooltipOpen] = useState<boolean | undefined>(
20
+ undefined
21
+ );
22
+
23
+ const handleClick: MouseEventHandler = (e) => {
24
+ // Set it to 'Copied'
25
+ setLabelText(translate('copied') as string);
26
+ // @ts-expect-error - Event type mismatch between generic and specific button events
27
+ onClick?.(e);
28
+ setIsTooltipOpen(true);
29
+ // Set it back to 'Copy' after 2s, and back to an uncontrolled tooltip
30
+ const t = setTimeout(() => {
31
+ setLabelText(translate('copy') as string);
32
+ setIsTooltipOpen(undefined);
33
+ clearTimeout(t);
34
+ }, 3000);
35
+ };
36
+
37
+ return (
38
+ <Tooltip label={labelText} isOpen={isTooltipOpen} placement="top">
39
+ <IconButton
40
+ aria-label="Copy code"
41
+ icon={<Icon icon="FaRegCopy" boxSize="sm" />}
42
+ onClick={handleClick}
43
+ p={0}
44
+ {...rest}
45
+ />
46
+ </Tooltip>
47
+ );
48
+ };
@@ -0,0 +1 @@
1
+ export { Code } from './Code';
@@ -0,0 +1,51 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { CodeTabs } from './CodeTabs';
4
+
5
+ const meta: Meta<typeof CodeTabs> = {
6
+ title: 'Components/CodeTabs',
7
+ component: CodeTabs,
8
+ tags: ['autodocs'],
9
+ parameters: {
10
+ layout: 'centered',
11
+ },
12
+ };
13
+
14
+ export default meta;
15
+ type Story = StoryObj<typeof CodeTabs>;
16
+
17
+ const CODE_SAMPLES = {
18
+ javascript: `
19
+ const response = await openai.chat.completions.create({
20
+ model: "gpt-3.5-turbo",
21
+ messages: [{ role: "user", content: "Hello, how are you?" }],
22
+ });
23
+ `,
24
+ python: `
25
+ response = openai.chat.completions.create(
26
+ model="gpt-3.5-turbo",
27
+ messages=[{"role": "user", "content": "Hello, how are you?"}]
28
+ )
29
+ `,
30
+ typescript: `
31
+ const response = await openai.chat.completions.create({
32
+ model: "gpt-3.5-turbo",
33
+ messages: [{ role: "user", content: "Hello, how are you?" }],
34
+ });
35
+ `,
36
+ };
37
+
38
+ export const Default: Story = {
39
+ args: {
40
+ code: CODE_SAMPLES,
41
+ },
42
+ };
43
+
44
+ export const WithCopyFunction: Story = {
45
+ args: {
46
+ code: CODE_SAMPLES,
47
+ onCopy: (code: string) => {
48
+ console.log('Copied code:', code);
49
+ },
50
+ },
51
+ };
@@ -0,0 +1,98 @@
1
+ import { useState } from 'react';
2
+ import { Flex } from '@chakra-ui/react';
3
+
4
+ import { Code } from '@/components/Code';
5
+ import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@/components/Tabs';
6
+ import { useTranslate } from '@/hooks/useTranslate';
7
+
8
+ import { Icon } from '../Icon';
9
+ import { IconButton } from '../IconButton';
10
+ import { useTabsContext } from '../Tabs/TabsContext';
11
+ import { Tooltip } from '../Tooltip';
12
+ import { CodeTabsProps } from './CodeTabs.types';
13
+ const CopyButton = ({
14
+ onCopy,
15
+ code,
16
+ }: Pick<CodeTabsProps, 'onCopy' | 'code'>) => {
17
+ const translate = useTranslate();
18
+ const [tooltipText, setTooltipText] = useState(translate('copy'));
19
+ const { selectedIndex } = useTabsContext();
20
+
21
+ const handleCopyClick = () => {
22
+ onCopy?.(code[Object.keys(code)[selectedIndex]]);
23
+ setTooltipText(translate('copied'));
24
+ const t = setTimeout(() => {
25
+ setTooltipText(translate('copy'));
26
+ }, 1500);
27
+ return () => clearTimeout(t);
28
+ };
29
+
30
+ return (
31
+ <Tooltip label={tooltipText} placement="top">
32
+ <IconButton
33
+ aria-label="Copy"
34
+ borderRadius="full"
35
+ icon={<Icon icon="FaRegCopy" boxSize="xs" />}
36
+ size="sm"
37
+ _hover={{
38
+ bgColor: 'whiteAlpha.500',
39
+ }}
40
+ onClick={handleCopyClick}
41
+ />
42
+ </Tooltip>
43
+ );
44
+ };
45
+
46
+ export const CodeTabs = ({ code, onCopy, ...rest }: CodeTabsProps) => {
47
+ // Extract languages from code samples
48
+ const languages = Object.keys(code);
49
+
50
+ if (languages.length === 0) {
51
+ return null;
52
+ }
53
+
54
+ return (
55
+ <Tabs bgColor="gray.1500" borderRadius="md" {...rest}>
56
+ <TabList px={2} alignItems="center">
57
+ <Flex w="100%" flex={1}>
58
+ {languages.map((language) => (
59
+ <Tab
60
+ key={`${language}-tab`}
61
+ color="gray.800"
62
+ px={3}
63
+ py={1}
64
+ m={2}
65
+ borderRadius="full"
66
+ textTransform="uppercase"
67
+ fontWeight="bold"
68
+ _selected={{ color: 'white' }}
69
+ _hover={{
70
+ bgColor: 'whiteAlpha.500',
71
+ }}
72
+ >
73
+ {language}
74
+ </Tab>
75
+ ))}
76
+ </Flex>
77
+ {onCopy && <CopyButton onCopy={onCopy} code={code} />}
78
+ </TabList>
79
+ <TabPanels>
80
+ {languages.map((language) => (
81
+ <TabPanel key={`${language}-tab-panel`}>
82
+ <Code
83
+ language={language}
84
+ hideHeader
85
+ containerProps={{
86
+ borderWidth: 0,
87
+ borderBottomRadius: 'md',
88
+ overflow: 'hidden',
89
+ }}
90
+ >
91
+ {code[language]?.trim() || ''}
92
+ </Code>
93
+ </TabPanel>
94
+ ))}
95
+ </TabPanels>
96
+ </Tabs>
97
+ );
98
+ };
@@ -0,0 +1,17 @@
1
+ import { TabsProps } from '@chakra-ui/react';
2
+
3
+ export interface CodeTabsProps extends Omit<TabsProps, 'children' | 'onCopy'> {
4
+ /**
5
+ * Code samples to display in tabs
6
+ * Each language contains code samples for different providers
7
+ */
8
+ code: {
9
+ [language: string]: string;
10
+ };
11
+
12
+ /**
13
+ * Callback for when the copy button is clicked
14
+ * The function will receive the selected code sample
15
+ */
16
+ onCopy?: (code: string) => void;
17
+ }
@@ -0,0 +1 @@
1
+ export { CodeTabs } from './CodeTabs';
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { ContainerProps } from '@chakra-ui/react';
3
+ import { Meta, StoryFn } from '@storybook/react';
4
+ import * as CSS from 'csstype';
5
+
6
+ import { Container } from './Container';
7
+
8
+ const meta: Meta<typeof Container> = {
9
+ title: 'Components/Container',
10
+ component: Container,
11
+ };
12
+
13
+ export default meta;
14
+ type Story = StoryFn<typeof Container>;
15
+
16
+ const containerStoryStyles = {
17
+ bg: 'red',
18
+ p: 32,
19
+ textAlign: 'center' as CSS.Property.TextAlign,
20
+ };
21
+
22
+ export const Basic: Story = (props: ContainerProps) => {
23
+ return (
24
+ <Container {...containerStoryStyles} {...props}>
25
+ Container
26
+ </Container>
27
+ );
28
+ };