@chayns-components/core 5.0.0-beta.39 → 5.0.0-beta.392

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 (419) hide show
  1. package/README.md +3 -9
  2. package/lib/api/image/post.d.ts +16 -0
  3. package/lib/api/image/post.js +34 -0
  4. package/lib/api/image/post.js.map +1 -0
  5. package/lib/api/video/post.d.ts +16 -0
  6. package/lib/api/video/post.js +31 -0
  7. package/lib/api/video/post.js.map +1 -0
  8. package/lib/components/accordion/Accordion.d.ts +24 -3
  9. package/lib/components/accordion/Accordion.js +46 -17
  10. package/lib/components/accordion/Accordion.js.map +1 -1
  11. package/lib/components/accordion/Accordion.styles.d.ts +6 -4
  12. package/lib/components/accordion/Accordion.styles.js +42 -28
  13. package/lib/components/accordion/Accordion.styles.js.map +1 -1
  14. package/lib/components/accordion/accordion-body/AccordionBody.d.ts +21 -2
  15. package/lib/components/accordion/accordion-body/AccordionBody.js +17 -11
  16. package/lib/components/accordion/accordion-body/AccordionBody.js.map +1 -1
  17. package/lib/components/accordion/accordion-body/AccordionBody.styles.d.ts +268 -1
  18. package/lib/components/accordion/accordion-body/AccordionBody.styles.js +14 -4
  19. package/lib/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  20. package/lib/components/accordion/accordion-content/AccordionContent.d.ts +10 -2
  21. package/lib/components/accordion/accordion-content/AccordionContent.js +7 -4
  22. package/lib/components/accordion/accordion-content/AccordionContent.js.map +1 -1
  23. package/lib/components/accordion/accordion-content/AccordionContent.styles.d.ts +7 -4
  24. package/lib/components/accordion/accordion-content/AccordionContent.styles.js +14 -4
  25. package/lib/components/accordion/accordion-content/AccordionContent.styles.js.map +1 -1
  26. package/lib/components/accordion/accordion-group/AccordionGroup.d.ts +4 -3
  27. package/lib/components/accordion/accordion-group/AccordionGroup.js +6 -6
  28. package/lib/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  29. package/lib/components/accordion/accordion-head/AccordionHead.d.ts +1 -1
  30. package/lib/components/accordion/accordion-head/AccordionHead.js +5 -7
  31. package/lib/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  32. package/lib/components/accordion/accordion-head/AccordionHead.styles.d.ts +2417 -12
  33. package/lib/components/accordion/accordion-head/AccordionHead.styles.js +20 -24
  34. package/lib/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  35. package/lib/components/accordion/accordion-intro/AccordionIntro.d.ts +1 -1
  36. package/lib/components/accordion/accordion-intro/AccordionIntro.js +1 -2
  37. package/lib/components/accordion/accordion-intro/AccordionIntro.js.map +1 -1
  38. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.d.ts +2 -1
  39. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js +1 -2
  40. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js.map +1 -1
  41. package/lib/components/accordion/accordion-item/AccordionItem.d.ts +9 -0
  42. package/lib/components/accordion/accordion-item/AccordionItem.js +27 -0
  43. package/lib/components/accordion/accordion-item/AccordionItem.js.map +1 -0
  44. package/lib/components/accordion/accordion-item/AccordionItem.styles.d.ts +7 -0
  45. package/lib/components/accordion/accordion-item/AccordionItem.styles.js +33 -0
  46. package/lib/components/accordion/accordion-item/AccordionItem.styles.js.map +1 -0
  47. package/lib/components/accordion/utils.js.map +1 -1
  48. package/lib/components/amount-control/AmountControl.d.ts +22 -0
  49. package/lib/components/amount-control/AmountControl.js +185 -0
  50. package/lib/components/amount-control/AmountControl.js.map +1 -0
  51. package/lib/components/amount-control/AmountControl.styles.d.ts +288 -0
  52. package/lib/components/amount-control/AmountControl.styles.js +58 -0
  53. package/lib/components/amount-control/AmountControl.styles.js.map +1 -0
  54. package/lib/components/amount-control/utils.d.ts +7 -0
  55. package/lib/components/amount-control/utils.js +22 -0
  56. package/lib/components/amount-control/utils.js.map +1 -0
  57. package/lib/components/badge/Badge.d.ts +1 -1
  58. package/lib/components/badge/Badge.js +1 -2
  59. package/lib/components/badge/Badge.js.map +1 -1
  60. package/lib/components/badge/Badge.styles.d.ts +5 -3
  61. package/lib/components/badge/Badge.styles.js +3 -4
  62. package/lib/components/badge/Badge.styles.js.map +1 -1
  63. package/lib/components/button/Button.d.ts +6 -2
  64. package/lib/components/button/Button.js +55 -4
  65. package/lib/components/button/Button.js.map +1 -1
  66. package/lib/components/button/Button.styles.d.ts +538 -4
  67. package/lib/components/button/Button.styles.js +36 -15
  68. package/lib/components/button/Button.styles.js.map +1 -1
  69. package/lib/components/checkbox/Checkbox.d.ts +11 -3
  70. package/lib/components/checkbox/Checkbox.js +13 -8
  71. package/lib/components/checkbox/Checkbox.js.map +1 -1
  72. package/lib/components/checkbox/Checkbox.styles.d.ts +12 -5
  73. package/lib/components/checkbox/Checkbox.styles.js +51 -36
  74. package/lib/components/checkbox/Checkbox.styles.js.map +1 -1
  75. package/lib/components/code-highlighter/CodeHighlighter.d.ts +36 -0
  76. package/lib/components/code-highlighter/CodeHighlighter.js +85 -0
  77. package/lib/components/code-highlighter/CodeHighlighter.js.map +1 -0
  78. package/lib/components/code-highlighter/CodeHighlighter.styles.d.ts +16 -0
  79. package/lib/components/code-highlighter/CodeHighlighter.styles.js +88 -0
  80. package/lib/components/code-highlighter/CodeHighlighter.styles.js.map +1 -0
  81. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.d.ts +9 -0
  82. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.js +41 -0
  83. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.js.map +1 -0
  84. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.d.ts +9 -0
  85. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.js +24 -0
  86. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.js.map +1 -0
  87. package/lib/components/color-scheme-provider/ColorSchemeProvider.d.ts +3 -2
  88. package/lib/components/color-scheme-provider/ColorSchemeProvider.js +14 -12
  89. package/lib/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  90. package/lib/components/color-scheme-provider/font.d.ts +6 -0
  91. package/lib/components/color-scheme-provider/font.js +59 -0
  92. package/lib/components/color-scheme-provider/font.js.map +1 -0
  93. package/lib/components/combobox/ComboBox.d.ts +39 -0
  94. package/lib/components/combobox/ComboBox.js +183 -0
  95. package/lib/components/combobox/ComboBox.js.map +1 -0
  96. package/lib/components/combobox/ComboBox.styles.d.ts +288 -0
  97. package/lib/components/combobox/ComboBox.styles.js +177 -0
  98. package/lib/components/combobox/ComboBox.styles.js.map +1 -0
  99. package/lib/components/combobox/combobox-item/ComboBoxItem.d.ts +12 -0
  100. package/lib/components/combobox/combobox-item/ComboBoxItem.js +40 -0
  101. package/lib/components/combobox/combobox-item/ComboBoxItem.js.map +1 -0
  102. package/lib/components/combobox/combobox-item/ComboBoxItem.styles.d.ts +11 -0
  103. package/lib/components/combobox/combobox-item/ComboBoxItem.styles.js +61 -0
  104. package/lib/components/combobox/combobox-item/ComboBoxItem.styles.js.map +1 -0
  105. package/lib/components/content-card/ContentCard.d.ts +13 -0
  106. package/lib/components/content-card/ContentCard.js +21 -0
  107. package/lib/components/content-card/ContentCard.js.map +1 -0
  108. package/lib/components/content-card/ContentCard.styles.d.ts +2 -0
  109. package/lib/components/content-card/ContentCard.styles.js +22 -0
  110. package/lib/components/content-card/ContentCard.styles.js.map +1 -0
  111. package/lib/components/context-menu/ContextMenu.d.ts +5 -5
  112. package/lib/components/context-menu/ContextMenu.js +18 -19
  113. package/lib/components/context-menu/ContextMenu.js.map +1 -1
  114. package/lib/components/context-menu/ContextMenu.styles.d.ts +2 -1
  115. package/lib/components/context-menu/ContextMenu.styles.js +1 -2
  116. package/lib/components/context-menu/ContextMenu.styles.js.map +1 -1
  117. package/lib/components/context-menu/constants/alignment.js +3 -4
  118. package/lib/components/context-menu/constants/alignment.js.map +1 -1
  119. package/lib/components/context-menu/context-menu-content/ContextMenuContent.d.ts +1 -1
  120. package/lib/components/context-menu/context-menu-content/ContextMenuContent.js +4 -3
  121. package/lib/components/context-menu/context-menu-content/ContextMenuContent.js.map +1 -1
  122. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.d.ts +273 -8
  123. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js +14 -19
  124. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js.map +1 -1
  125. package/lib/components/date-info/DateInfo.d.ts +40 -0
  126. package/lib/components/date-info/DateInfo.js +108 -0
  127. package/lib/components/date-info/DateInfo.js.map +1 -0
  128. package/lib/components/date-info/utils/format.d.ts +43 -0
  129. package/lib/components/date-info/utils/format.js +287 -0
  130. package/lib/components/date-info/utils/format.js.map +1 -0
  131. package/lib/components/date-info/utils/language.d.ts +1 -0
  132. package/lib/components/date-info/utils/language.js +35 -0
  133. package/lib/components/date-info/utils/language.js.map +1 -0
  134. package/lib/components/file-input/FileInput.d.ts +21 -0
  135. package/lib/components/file-input/FileInput.js +104 -0
  136. package/lib/components/file-input/FileInput.js.map +1 -0
  137. package/lib/components/file-input/FileInput.styles.d.ts +274 -0
  138. package/lib/components/file-input/FileInput.styles.js +35 -0
  139. package/lib/components/file-input/FileInput.styles.js.map +1 -0
  140. package/lib/components/file-input/file-list/FileListItem.d.ts +9 -0
  141. package/lib/components/file-input/file-list/FileListItem.js +36 -0
  142. package/lib/components/file-input/file-list/FileListItem.js.map +1 -0
  143. package/lib/components/file-input/file-list/FileListItem.styles.d.ts +2 -0
  144. package/lib/components/file-input/file-list/FileListItem.styles.js +10 -0
  145. package/lib/components/file-input/file-list/FileListItem.styles.js.map +1 -0
  146. package/lib/components/filter-buttons/FilterButtons.d.ts +22 -0
  147. package/lib/components/filter-buttons/FilterButtons.js +88 -0
  148. package/lib/components/filter-buttons/FilterButtons.js.map +1 -0
  149. package/lib/components/filter-buttons/FilterButtons.styles.d.ts +2 -0
  150. package/lib/components/filter-buttons/FilterButtons.styles.js +14 -0
  151. package/lib/components/filter-buttons/FilterButtons.styles.js.map +1 -0
  152. package/lib/components/filter-buttons/filter-button/FilterButton.d.ts +14 -0
  153. package/lib/components/filter-buttons/filter-button/FilterButton.js +47 -0
  154. package/lib/components/filter-buttons/filter-button/FilterButton.js.map +1 -0
  155. package/lib/components/filter-buttons/filter-button/FilterButton.styles.d.ts +287 -0
  156. package/lib/components/filter-buttons/filter-button/FilterButton.styles.js +104 -0
  157. package/lib/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -0
  158. package/lib/components/filter-buttons/types.d.ts +15 -0
  159. package/lib/components/filter-buttons/types.js +17 -0
  160. package/lib/components/filter-buttons/types.js.map +1 -0
  161. package/lib/components/grid-image/GridImage.d.ts +1 -1
  162. package/lib/components/grid-image/GridImage.js +3 -4
  163. package/lib/components/grid-image/GridImage.js.map +1 -1
  164. package/lib/components/grid-image/GridImage.styles.d.ts +12 -11
  165. package/lib/components/grid-image/GridImage.styles.js +4 -8
  166. package/lib/components/grid-image/GridImage.styles.js.map +1 -1
  167. package/lib/components/icon/Icon.d.ts +1 -1
  168. package/lib/components/icon/Icon.js +2 -3
  169. package/lib/components/icon/Icon.js.map +1 -1
  170. package/lib/components/icon/Icon.styles.d.ts +7 -7
  171. package/lib/components/icon/Icon.styles.js +6 -8
  172. package/lib/components/icon/Icon.styles.js.map +1 -1
  173. package/lib/components/icon/utils.js +1 -2
  174. package/lib/components/icon/utils.js.map +1 -1
  175. package/lib/components/input/Input.d.ts +35 -3
  176. package/lib/components/input/Input.js +62 -16
  177. package/lib/components/input/Input.js.map +1 -1
  178. package/lib/components/input/Input.styles.d.ts +541 -6
  179. package/lib/components/input/Input.styles.js +59 -18
  180. package/lib/components/input/Input.styles.js.map +1 -1
  181. package/lib/components/list/List.d.ts +1 -1
  182. package/lib/components/list/List.js +4 -6
  183. package/lib/components/list/List.js.map +1 -1
  184. package/lib/components/list/list-item/ListItem.d.ts +2 -2
  185. package/lib/components/list/list-item/ListItem.js +7 -6
  186. package/lib/components/list/list-item/ListItem.js.map +1 -1
  187. package/lib/components/list/list-item/ListItem.styles.d.ts +6 -4
  188. package/lib/components/list/list-item/ListItem.styles.js +14 -26
  189. package/lib/components/list/list-item/ListItem.styles.js.map +1 -1
  190. package/lib/components/list/list-item/list-item-body/ListItemBody.d.ts +6 -2
  191. package/lib/components/list/list-item/list-item-body/ListItemBody.js +28 -7
  192. package/lib/components/list/list-item/list-item-body/ListItemBody.js.map +1 -1
  193. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.d.ts +267 -1
  194. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js +1 -2
  195. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js.map +1 -1
  196. package/lib/components/list/list-item/list-item-content/ListItemContent.d.ts +8 -2
  197. package/lib/components/list/list-item/list-item-content/ListItemContent.js +1 -2
  198. package/lib/components/list/list-item/list-item-content/ListItemContent.js.map +1 -1
  199. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.d.ts +2 -1
  200. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js +1 -2
  201. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js.map +1 -1
  202. package/lib/components/list/list-item/list-item-head/ListItemHead.d.ts +1 -1
  203. package/lib/components/list/list-item/list-item-head/ListItemHead.js +4 -5
  204. package/lib/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  205. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.d.ts +544 -14
  206. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js +13 -24
  207. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  208. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.d.ts +1 -1
  209. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js +1 -2
  210. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js.map +1 -1
  211. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.d.ts +2 -1
  212. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js +1 -2
  213. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js.map +1 -1
  214. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.d.ts +1 -1
  215. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js +3 -4
  216. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -1
  217. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.d.ts +8 -7
  218. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js +2 -4
  219. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js.map +1 -1
  220. package/lib/components/mention-finder/MentionFinder.d.ts +31 -0
  221. package/lib/components/mention-finder/MentionFinder.js +139 -0
  222. package/lib/components/mention-finder/MentionFinder.js.map +1 -0
  223. package/lib/components/mention-finder/MentionFinder.styles.d.ts +270 -0
  224. package/lib/components/mention-finder/MentionFinder.styles.js +92 -0
  225. package/lib/components/mention-finder/MentionFinder.styles.js.map +1 -0
  226. package/lib/components/mention-finder/constants/alignment.d.ts +4 -0
  227. package/lib/components/mention-finder/constants/alignment.js +12 -0
  228. package/lib/components/mention-finder/constants/alignment.js.map +1 -0
  229. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.d.ts +10 -0
  230. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.js +31 -0
  231. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.js.map +1 -0
  232. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.d.ts +10 -0
  233. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js +91 -0
  234. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -0
  235. package/lib/components/number-input/NumberInput.d.ts +46 -0
  236. package/lib/components/number-input/NumberInput.js +123 -0
  237. package/lib/components/number-input/NumberInput.js.map +1 -0
  238. package/lib/components/number-input/constants/number.d.ts +4 -0
  239. package/lib/components/number-input/constants/number.js +11 -0
  240. package/lib/components/number-input/constants/number.js.map +1 -0
  241. package/lib/components/number-input/utils/number.d.ts +21 -0
  242. package/lib/components/number-input/utils/number.js +64 -0
  243. package/lib/components/number-input/utils/number.js.map +1 -0
  244. package/lib/components/popup/Popup.d.ts +30 -0
  245. package/lib/components/popup/Popup.js +154 -0
  246. package/lib/components/popup/Popup.js.map +1 -0
  247. package/lib/components/popup/Popup.styles.d.ts +5 -0
  248. package/lib/components/popup/Popup.styles.js +26 -0
  249. package/lib/components/popup/Popup.styles.js.map +1 -0
  250. package/lib/components/popup/popup-content/PopupContent.d.ts +9 -0
  251. package/lib/components/popup/popup-content/PopupContent.js +66 -0
  252. package/lib/components/popup/popup-content/PopupContent.js.map +1 -0
  253. package/lib/components/popup/popup-content/PopupContent.styles.d.ts +274 -0
  254. package/lib/components/popup/popup-content/PopupContent.styles.js +92 -0
  255. package/lib/components/popup/popup-content/PopupContent.styles.js.map +1 -0
  256. package/lib/components/popup/types.d.ts +16 -0
  257. package/lib/components/popup/types.js +16 -0
  258. package/lib/components/popup/types.js.map +1 -0
  259. package/lib/components/progress-bar/ProgressBar.d.ts +9 -0
  260. package/lib/components/progress-bar/ProgressBar.js +38 -0
  261. package/lib/components/progress-bar/ProgressBar.js.map +1 -0
  262. package/lib/components/progress-bar/ProgressBar.styles.d.ts +271 -0
  263. package/lib/components/progress-bar/ProgressBar.styles.js +36 -0
  264. package/lib/components/progress-bar/ProgressBar.styles.js.map +1 -0
  265. package/lib/components/radio-button/RadioButton.d.ts +26 -0
  266. package/lib/components/radio-button/RadioButton.js +85 -0
  267. package/lib/components/radio-button/RadioButton.js.map +1 -0
  268. package/lib/components/radio-button/RadioButton.styles.d.ts +22 -0
  269. package/lib/components/radio-button/RadioButton.styles.js +95 -0
  270. package/lib/components/radio-button/RadioButton.styles.js.map +1 -0
  271. package/lib/components/radio-button/radio-button-group/RadioButtonGroup.d.ts +17 -0
  272. package/lib/components/radio-button/radio-button-group/RadioButtonGroup.js +46 -0
  273. package/lib/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -0
  274. package/lib/components/radio-button/types.d.ts +4 -0
  275. package/lib/components/radio-button/types.js +2 -0
  276. package/lib/components/radio-button/types.js.map +1 -0
  277. package/lib/components/scroll-view/ScrollView.d.ts +13 -0
  278. package/lib/components/scroll-view/ScrollView.js +22 -0
  279. package/lib/components/scroll-view/ScrollView.js.map +1 -0
  280. package/lib/components/scroll-view/ScrollView.styles.d.ts +7 -0
  281. package/lib/components/scroll-view/ScrollView.styles.js +26 -0
  282. package/lib/components/scroll-view/ScrollView.styles.js.map +1 -0
  283. package/lib/components/search-box/SearchBox.d.ts +30 -0
  284. package/lib/components/search-box/SearchBox.js +179 -0
  285. package/lib/components/search-box/SearchBox.js.map +1 -0
  286. package/lib/components/search-box/SearchBox.styles.d.ts +272 -0
  287. package/lib/components/search-box/SearchBox.styles.js +56 -0
  288. package/lib/components/search-box/SearchBox.styles.js.map +1 -0
  289. package/lib/components/search-box/search-box-item/SearchBoxItem.d.ts +9 -0
  290. package/lib/components/search-box/search-box-item/SearchBoxItem.js +29 -0
  291. package/lib/components/search-box/search-box-item/SearchBoxItem.js.map +1 -0
  292. package/lib/components/search-box/search-box-item/SearchBoxItem.styles.d.ts +7 -0
  293. package/lib/components/search-box/search-box-item/SearchBoxItem.styles.js +28 -0
  294. package/lib/components/search-box/search-box-item/SearchBoxItem.styles.js.map +1 -0
  295. package/lib/components/search-box/types.d.ts +4 -0
  296. package/lib/components/search-box/types.js +2 -0
  297. package/lib/components/search-box/types.js.map +1 -0
  298. package/lib/components/search-box/utils.d.ts +7 -0
  299. package/lib/components/search-box/utils.js +23 -0
  300. package/lib/components/search-box/utils.js.map +1 -0
  301. package/lib/components/search-input/SearchInput.d.ts +33 -0
  302. package/lib/components/search-input/SearchInput.js +102 -0
  303. package/lib/components/search-input/SearchInput.js.map +1 -0
  304. package/lib/components/search-input/SearchInput.styles.d.ts +534 -0
  305. package/lib/components/search-input/SearchInput.styles.js +26 -0
  306. package/lib/components/search-input/SearchInput.styles.js.map +1 -0
  307. package/lib/components/setup-wizard/SetupWizard.d.ts +23 -0
  308. package/lib/components/setup-wizard/SetupWizard.js +79 -0
  309. package/lib/components/setup-wizard/SetupWizard.js.map +1 -0
  310. package/lib/components/setup-wizard/SetupWizard.styles.d.ts +2 -0
  311. package/lib/components/setup-wizard/SetupWizard.styles.js +10 -0
  312. package/lib/components/setup-wizard/SetupWizard.styles.js.map +1 -0
  313. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.d.ts +25 -0
  314. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +60 -0
  315. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -0
  316. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.d.ts +3 -0
  317. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.js +14 -0
  318. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.js.map +1 -0
  319. package/lib/components/sharing-bar/SharingBar.d.ts +18 -0
  320. package/lib/components/sharing-bar/SharingBar.js +110 -0
  321. package/lib/components/sharing-bar/SharingBar.js.map +1 -0
  322. package/lib/components/sharing-bar/SharingBar.styles.d.ts +6 -0
  323. package/lib/components/sharing-bar/SharingBar.styles.js +24 -0
  324. package/lib/components/sharing-bar/SharingBar.styles.js.map +1 -0
  325. package/lib/components/slider/Slider.d.ts +21 -0
  326. package/lib/components/slider/Slider.js +51 -0
  327. package/lib/components/slider/Slider.js.map +1 -0
  328. package/lib/components/slider/Slider.styles.d.ts +10 -0
  329. package/lib/components/slider/Slider.styles.js +74 -0
  330. package/lib/components/slider/Slider.styles.js.map +1 -0
  331. package/lib/components/small-wait-cursor/SmallWaitCursor.d.ts +31 -0
  332. package/lib/components/small-wait-cursor/SmallWaitCursor.js +42 -0
  333. package/lib/components/small-wait-cursor/SmallWaitCursor.js.map +1 -0
  334. package/lib/components/small-wait-cursor/SmallWaitCursor.styles.d.ts +19 -0
  335. package/lib/components/small-wait-cursor/SmallWaitCursor.styles.js +101 -0
  336. package/lib/components/small-wait-cursor/SmallWaitCursor.styles.js.map +1 -0
  337. package/lib/components/text-area/TextArea.d.ts +29 -0
  338. package/lib/components/text-area/TextArea.js +72 -0
  339. package/lib/components/text-area/TextArea.js.map +1 -0
  340. package/lib/components/text-area/TextArea.styles.d.ts +13 -0
  341. package/lib/components/text-area/TextArea.styles.js +79 -0
  342. package/lib/components/text-area/TextArea.styles.js.map +1 -0
  343. package/lib/components/tooltip/Tooltip.d.ts +18 -0
  344. package/lib/components/tooltip/Tooltip.js +32 -0
  345. package/lib/components/tooltip/Tooltip.js.map +1 -0
  346. package/lib/components/tooltip/Tooltip.styles.d.ts +2 -0
  347. package/lib/components/tooltip/Tooltip.styles.js +10 -0
  348. package/lib/components/tooltip/Tooltip.styles.js.map +1 -0
  349. package/lib/components/tooltip/interface.d.ts +4 -0
  350. package/lib/components/tooltip/interface.js +2 -0
  351. package/lib/components/tooltip/interface.js.map +1 -0
  352. package/lib/components/tooltip/tooltip-item/TooltipItem.d.ts +7 -0
  353. package/lib/components/tooltip/tooltip-item/TooltipItem.js +20 -0
  354. package/lib/components/tooltip/tooltip-item/TooltipItem.js.map +1 -0
  355. package/lib/components/tooltip/tooltip-item/TooltipItem.styles.d.ts +8 -0
  356. package/lib/components/tooltip/tooltip-item/TooltipItem.styles.js +29 -0
  357. package/lib/components/tooltip/tooltip-item/TooltipItem.styles.js.map +1 -0
  358. package/lib/components/truncation/Truncation.d.ts +25 -0
  359. package/lib/components/truncation/Truncation.js +86 -0
  360. package/lib/components/truncation/Truncation.js.map +1 -0
  361. package/lib/components/truncation/Truncation.styles.d.ts +270 -0
  362. package/lib/components/truncation/Truncation.styles.js +27 -0
  363. package/lib/components/truncation/Truncation.styles.js.map +1 -0
  364. package/lib/constants/codeHighlighter.d.ts +7 -0
  365. package/lib/constants/codeHighlighter.js +13 -0
  366. package/lib/constants/codeHighlighter.js.map +1 -0
  367. package/lib/hooks/colorMode.d.ts +2 -0
  368. package/lib/hooks/colorMode.js +22 -0
  369. package/lib/hooks/colorMode.js.map +1 -0
  370. package/lib/hooks/uuid.js.map +1 -1
  371. package/lib/index.d.ts +40 -0
  372. package/lib/index.js +237 -0
  373. package/lib/index.js.map +1 -1
  374. package/lib/types/chayns.d.ts +59 -0
  375. package/lib/types/chayns.js +3 -4
  376. package/lib/types/chayns.js.map +1 -1
  377. package/lib/types/codeHighlighter.d.ts +10 -0
  378. package/lib/types/codeHighlighter.js +12 -0
  379. package/lib/types/codeHighlighter.js.map +1 -0
  380. package/lib/types/comboBox.d.ts +4 -0
  381. package/lib/types/comboBox.js +12 -0
  382. package/lib/types/comboBox.js.map +1 -0
  383. package/lib/types/file.d.ts +42 -0
  384. package/lib/types/file.js +2 -0
  385. package/lib/types/file.js.map +1 -0
  386. package/lib/types/parser/prettier-parser-babel.d.js +2 -0
  387. package/lib/types/parser/prettier-parser-babel.d.js.map +1 -0
  388. package/lib/types/parser/prettier-parser-graphql.d.js +2 -0
  389. package/lib/types/parser/prettier-parser-graphql.d.js.map +1 -0
  390. package/lib/types/parser/prettier-parser-html.d.js +2 -0
  391. package/lib/types/parser/prettier-parser-html.d.js.map +1 -0
  392. package/lib/types/parser/prettier-parser-markdown.d.js +2 -0
  393. package/lib/types/parser/prettier-parser-markdown.d.js.map +1 -0
  394. package/lib/types/parser/prettier-parser-postcss.d.js +2 -0
  395. package/lib/types/parser/prettier-parser-postcss.d.js.map +1 -0
  396. package/lib/types/parser/prettier-parser-yaml.d.js +2 -0
  397. package/lib/types/parser/prettier-parser-yaml.d.js.map +1 -0
  398. package/lib/utils/calculate.d.ts +3 -0
  399. package/lib/utils/calculate.js +49 -0
  400. package/lib/utils/calculate.js.map +1 -0
  401. package/lib/utils/codeHighlighter.d.ts +4 -0
  402. package/lib/utils/codeHighlighter.js +361 -0
  403. package/lib/utils/codeHighlighter.js.map +1 -0
  404. package/lib/utils/file.d.ts +363 -0
  405. package/lib/utils/file.js +402 -0
  406. package/lib/utils/file.js.map +1 -0
  407. package/lib/utils/fileDialog.d.ts +7 -0
  408. package/lib/utils/fileDialog.js +73 -0
  409. package/lib/utils/fileDialog.js.map +1 -0
  410. package/lib/utils/isTobitEmployee.d.ts +1 -0
  411. package/lib/utils/isTobitEmployee.js +28 -0
  412. package/lib/utils/isTobitEmployee.js.map +1 -0
  413. package/lib/utils/truncation.d.ts +1 -0
  414. package/lib/utils/truncation.js +34 -0
  415. package/lib/utils/truncation.js.map +1 -0
  416. package/lib/utils/uploadFile.d.ts +9 -0
  417. package/lib/utils/uploadFile.js +47 -0
  418. package/lib/utils/uploadFile.js.map +1 -0
  419. package/package.json +29 -21
@@ -1 +1 @@
1
- {"version":3,"file":"Button.styles.js","names":["StyledButton","styled","button","isSecondary","theme","text","disabled","hasIcon","StyledIconWrapper","span"],"sources":["../../../src/components/button/Button.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport type { ButtonProps } from './Button';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledButtonProps = ButtonProps &\n WithTheme<{\n hasIcon: boolean;\n }>;\n\nexport const StyledButton = styled.button<StyledButtonProps>`\n background-color: ${({ isSecondary, theme }: StyledButtonProps) =>\n isSecondary ? theme['202'] : theme['408']};\n border-radius: 3px;\n box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);\n border: none;\n color: ${({ isSecondary, theme }: StyledButtonProps) => (isSecondary ? theme.text : 'white')};\n cursor: pointer;\n display: inline-block;\n line-height: 1.15;\n min-height: 30px;\n opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};\n padding: ${({ hasIcon }) => `7px 12px 7px ${hasIcon ? '42px' : '12px'}`};\n position: relative;\n user-select: none;\n transition: opacity 0.3s ease;\n`;\n\nexport const StyledIconWrapper = styled.span`\n align-items: center;\n background-color: rgba(255, 255, 255, 0.2);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: absolute;\n top: 0;\n width: 30px;\n`;\n"],"mappings":";;;;;;AAAA;AAAuC;AAShC,MAAMA,YAAY,GAAGC,yBAAM,CAACC,MAA0B;AAC7D,wBAAwB;EAAA,IAAC;IAAEC,WAAW;IAAEC;EAAyB,CAAC;EAAA,OAC1DD,WAAW,GAAGC,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAClD;AACA;AACA;AACA,aAAa;EAAA,IAAC;IAAED,WAAW;IAAEC;EAAyB,CAAC;EAAA,OAAMD,WAAW,GAAGC,KAAK,CAACC,IAAI,GAAG,OAAO;AAAA,CAAE;AACjG;AACA;AACA;AACA;AACA,eAAe;EAAA,IAAC;IAAEC;EAAS,CAAC;EAAA,OAAMA,QAAQ,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AACtD,eAAe;EAAA,IAAC;IAAEC;EAAQ,CAAC;EAAA,OAAM,gBAAeA,OAAO,GAAG,MAAM,GAAG,MAAO,EAAC;AAAA,CAAC;AAC5E;AACA;AACA;AACA,CAAC;AAAC;AAEK,MAAMC,iBAAiB,GAAGP,yBAAM,CAACQ,IAAK;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAAC"}
1
+ {"version":3,"file":"Button.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","StyledButton","exports","styled","button","_ref","isSecondary","theme","_ref2","text","_ref3","disabled","_ref4","hasIcon","hasChildren","css","StyledIconWrapper","span","StyledMotionChildrenWrapper","motion","div","StyledMotionWaitCursorWrapper"],"sources":["../../../src/components/button/Button.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { ButtonProps } from './Button';\n\ntype StyledButtonProps = ButtonProps &\n WithTheme<{\n hasIcon: boolean;\n hasChildren: boolean;\n }>;\n\nexport const StyledButton = styled.button<StyledButtonProps>`\n align-items: center;\n background-color: ${({ isSecondary, theme }: StyledButtonProps) =>\n isSecondary ? theme['202'] : theme['408']};\n border-radius: 3px;\n box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);\n border: none;\n color: ${({ isSecondary, theme }: StyledButtonProps) => (isSecondary ? theme.text : 'white')};\n cursor: pointer;\n display: inline-flex;\n line-height: 1.15;\n min-height: 32px;\n opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};\n position: relative;\n user-select: none;\n transition: opacity 0.3s ease;\n\n ${({ hasIcon, hasChildren }) => {\n if (hasIcon) {\n if (hasChildren) {\n return css`\n padding: 7px 12px 7px 42px;\n `;\n }\n return css`\n padding: 7px 12px 7px 18px;\n `;\n }\n return css`\n padding: 7px 12px 7px 12px;\n `;\n }}\n`;\n\nexport const StyledIconWrapper = styled.span`\n align-items: center;\n background-color: rgba(255, 255, 255, 0.2);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: absolute;\n top: 0;\n width: 30px;\n`;\n\nexport const StyledMotionChildrenWrapper = styled(motion.div)<FramerMotionBugFix>``;\n\nexport const StyledMotionWaitCursorWrapper = styled(motion.div)<FramerMotionBugFix>`\n align-items: center;\n display: flex;\n justify-content: center;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAA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;EAAA,IAAC;IAAEC;EAAS,CAAC,GAAAD,KAAA;EAAA,OAAMC,QAAQ,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AACtD;AACA;AACA;AACA;AACA,MAAMC,KAAA,IAA8B;EAAA,IAA7B;IAAEC,OAAO;IAAEC;EAAY,CAAC,GAAAF,KAAA;EACvB,IAAIC,OAAO,EAAE;IACT,IAAIC,WAAW,EAAE;MACb,OAAO,IAAAC,qBAAG,CAAC;AAC3B;AACA,iBAAiB;IACL;IACA,OAAO,IAAAA,qBAAG,CAAC;AACvB;AACA,aAAa;EACL;EACA,OAAO,IAAAA,qBAAG,CAAC;AACnB;AACA,SAAS;AACL,CAAE;AACN,CAAC;AAEM,MAAMC,iBAAiB,GAAAd,OAAA,CAAAc,iBAAA,GAAGb,yBAAM,CAACc,IAAK;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,2BAA2B,GAAAhB,OAAA,CAAAgB,2BAAA,GAAG,IAAAf,yBAAM,EAACgB,oBAAM,CAACC,GAAG,CAAsB,EAAC;AAE5E,MAAMC,6BAA6B,GAAAnB,OAAA,CAAAmB,6BAAA,GAAG,IAAAlB,yBAAM,EAACgB,oBAAM,CAACC,GAAG,CAAsB;AACpF;AACA;AACA;AACA,CAAC"}
@@ -1,9 +1,9 @@
1
- import { ChangeEventHandler, FC, ReactNode } from 'react';
2
- export declare type CheckboxProps = {
1
+ import { ChangeEventHandler, FC, ReactElement } from 'react';
2
+ export type CheckboxProps = {
3
3
  /**
4
4
  * Text for checkbox or switch
5
5
  */
6
- children?: ReactNode;
6
+ children?: ReactElement;
7
7
  /**
8
8
  * Indicates whether the checkbox or switch is selected
9
9
  */
@@ -12,6 +12,10 @@ export declare type CheckboxProps = {
12
12
  * Disables the checkbox or switch so it cannot be toggled
13
13
  */
14
14
  isDisabled?: boolean;
15
+ /**
16
+ * Classname for the label
17
+ */
18
+ labelClassName?: string;
15
19
  /**
16
20
  * Function to be executed if the checked value changes
17
21
  */
@@ -20,6 +24,10 @@ export declare type CheckboxProps = {
20
24
  * Changes the design to use switch instead of checkbox
21
25
  */
22
26
  shouldShowAsSwitch?: boolean;
27
+ /**
28
+ * Whether the Checkbox should be displayed centered to the label or at the top
29
+ */
30
+ shouldShowCentered?: boolean;
23
31
  };
24
32
  declare const Checkbox: FC<CheckboxProps>;
25
33
  export default Checkbox;
@@ -6,18 +6,21 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _uuid = require("../../hooks/uuid");
9
+ var _calculate = require("../../utils/calculate");
9
10
  var _Checkbox = require("./Checkbox.styles");
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
13
  const Checkbox = _ref => {
13
14
  let {
14
15
  children,
15
16
  isChecked,
16
17
  isDisabled,
18
+ labelClassName,
17
19
  onChange,
18
- shouldShowAsSwitch
20
+ shouldShowAsSwitch,
21
+ shouldShowCentered = false
19
22
  } = _ref;
20
- const [isActive, setIsActive] = (0, _react.useState)(isChecked !== null && isChecked !== void 0 ? isChecked : false);
23
+ const [isActive, setIsActive] = (0, _react.useState)(isChecked ?? false);
21
24
  const handleChange = (0, _react.useCallback)(event => {
22
25
  setIsActive(event.target.checked);
23
26
  if (typeof onChange === 'function') {
@@ -25,6 +28,7 @@ const Checkbox = _ref => {
25
28
  }
26
29
  }, [onChange]);
27
30
  const uuid = (0, _uuid.useUuid)();
31
+ const lineHeight = (0, _react.useMemo)(() => shouldShowCentered ? undefined : (0, _calculate.getHeightOfSingleTextLine)(), [shouldShowCentered]);
28
32
  return /*#__PURE__*/_react.default.createElement(_Checkbox.StyledCheckbox, null, /*#__PURE__*/_react.default.createElement(_Checkbox.StyledCheckboxInput, {
29
33
  checked: isChecked,
30
34
  disabled: isDisabled,
@@ -32,13 +36,14 @@ const Checkbox = _ref => {
32
36
  onChange: handleChange,
33
37
  type: "checkbox"
34
38
  }), /*#__PURE__*/_react.default.createElement(_Checkbox.StyledCheckboxLabel, {
39
+ className: labelClassName,
35
40
  htmlFor: uuid,
36
- isChecked: isChecked !== null && isChecked !== void 0 ? isChecked : isActive,
41
+ isChecked: isChecked ?? isActive,
37
42
  isDisabled: isDisabled,
38
- shouldShowAsSwitch: shouldShowAsSwitch
43
+ shouldShowAsSwitch: shouldShowAsSwitch,
44
+ lineHeight: lineHeight
39
45
  }, children));
40
46
  };
41
47
  Checkbox.displayName = 'Checkbox';
42
- var _default = Checkbox;
43
- exports.default = _default;
48
+ var _default = exports.default = Checkbox;
44
49
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","names":["Checkbox","children","isChecked","isDisabled","onChange","shouldShowAsSwitch","isActive","setIsActive","useState","handleChange","useCallback","event","target","checked","uuid","useUuid","displayName"],"sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n ReactNode,\n useCallback,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport { StyledCheckbox, StyledCheckboxInput, StyledCheckboxLabel } from './Checkbox.styles';\n\nexport type CheckboxProps = {\n /**\n * Text for checkbox or switch\n */\n children?: ReactNode;\n /**\n * Indicates whether the checkbox or switch is selected\n */\n isChecked?: boolean;\n /**\n * Disables the checkbox or switch so it cannot be toggled\n */\n isDisabled?: boolean;\n /**\n * Function to be executed if the checked value changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Changes the design to use switch instead of checkbox\n */\n shouldShowAsSwitch?: boolean;\n};\n\nconst Checkbox: FC<CheckboxProps> = ({\n children,\n isChecked,\n isDisabled,\n onChange,\n shouldShowAsSwitch,\n}) => {\n const [isActive, setIsActive] = useState(isChecked ?? false);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setIsActive(event.target.checked);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange]\n );\n\n const uuid = useUuid();\n\n return (\n <StyledCheckbox>\n <StyledCheckboxInput\n checked={isChecked}\n disabled={isDisabled}\n id={uuid}\n onChange={handleChange}\n type=\"checkbox\"\n />\n <StyledCheckboxLabel\n htmlFor={uuid}\n isChecked={isChecked ?? isActive}\n isDisabled={isDisabled}\n shouldShowAsSwitch={shouldShowAsSwitch}\n >\n {children}\n </StyledCheckboxLabel>\n </StyledCheckbox>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"mappings":";;;;;;AAAA;AAQA;AACA;AAA6F;AAAA;AAyB7F,MAAMA,QAA2B,GAAG,QAM9B;EAAA,IAN+B;IACjCC,QAAQ;IACRC,SAAS;IACTC,UAAU;IACVC,QAAQ;IACRC;EACJ,CAAC;EACG,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAG,IAAAC,eAAQ,EAACN,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,KAAK,CAAC;EAE5D,MAAMO,YAAY,GAAG,IAAAC,kBAAW,EAC3BC,KAAoC,IAAK;IACtCJ,WAAW,CAACI,KAAK,CAACC,MAAM,CAACC,OAAO,CAAC;IAEjC,IAAI,OAAOT,QAAQ,KAAK,UAAU,EAAE;MAChCA,QAAQ,CAACO,KAAK,CAAC;IACnB;EACJ,CAAC,EACD,CAACP,QAAQ,CAAC,CACb;EAED,MAAMU,IAAI,GAAG,IAAAC,aAAO,GAAE;EAEtB,oBACI,6BAAC,wBAAc,qBACX,6BAAC,6BAAmB;IAChB,OAAO,EAAEb,SAAU;IACnB,QAAQ,EAAEC,UAAW;IACrB,EAAE,EAAEW,IAAK;IACT,QAAQ,EAAEL,YAAa;IACvB,IAAI,EAAC;EAAU,EACjB,eACF,6BAAC,6BAAmB;IAChB,OAAO,EAAEK,IAAK;IACd,SAAS,EAAEZ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAII,QAAS;IACjC,UAAU,EAAEH,UAAW;IACvB,kBAAkB,EAAEE;EAAmB,GAEtCJ,QAAQ,CACS,CACT;AAEzB,CAAC;AAEDD,QAAQ,CAACgB,WAAW,GAAG,UAAU;AAAC,eAEnBhB,QAAQ;AAAA"}
1
+ {"version":3,"file":"Checkbox.js","names":["_react","_interopRequireWildcard","require","_uuid","_calculate","_Checkbox","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Checkbox","_ref","children","isChecked","isDisabled","labelClassName","onChange","shouldShowAsSwitch","shouldShowCentered","isActive","setIsActive","useState","handleChange","useCallback","event","target","checked","uuid","useUuid","lineHeight","useMemo","undefined","getHeightOfSingleTextLine","createElement","StyledCheckbox","StyledCheckboxInput","disabled","id","type","StyledCheckboxLabel","className","htmlFor","displayName","_default","exports"],"sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n ReactElement,\n useCallback,\n useMemo,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport { getHeightOfSingleTextLine } from '../../utils/calculate';\nimport { StyledCheckbox, StyledCheckboxInput, StyledCheckboxLabel } from './Checkbox.styles';\n\nexport type CheckboxProps = {\n /**\n * Text for checkbox or switch\n */\n children?: ReactElement;\n /**\n * Indicates whether the checkbox or switch is selected\n */\n isChecked?: boolean;\n /**\n * Disables the checkbox or switch so it cannot be toggled\n */\n isDisabled?: boolean;\n /**\n * Classname for the label\n */\n labelClassName?: string;\n /**\n * Function to be executed if the checked value changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Changes the design to use switch instead of checkbox\n */\n shouldShowAsSwitch?: boolean;\n /**\n * Whether the Checkbox should be displayed centered to the label or at the top\n */\n shouldShowCentered?: boolean;\n};\n\nconst Checkbox: FC<CheckboxProps> = ({\n children,\n isChecked,\n isDisabled,\n labelClassName,\n onChange,\n shouldShowAsSwitch,\n shouldShowCentered = false,\n}) => {\n const [isActive, setIsActive] = useState(isChecked ?? false);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setIsActive(event.target.checked);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange],\n );\n\n const uuid = useUuid();\n\n const lineHeight = useMemo(\n () => (shouldShowCentered ? undefined : getHeightOfSingleTextLine()),\n [shouldShowCentered],\n );\n\n return (\n <StyledCheckbox>\n <StyledCheckboxInput\n checked={isChecked}\n disabled={isDisabled}\n id={uuid}\n onChange={handleChange}\n type=\"checkbox\"\n />\n <StyledCheckboxLabel\n className={labelClassName}\n htmlFor={uuid}\n isChecked={isChecked ?? isActive}\n isDisabled={isDisabled}\n shouldShowAsSwitch={shouldShowAsSwitch}\n lineHeight={lineHeight}\n >\n {children}\n </StyledCheckboxLabel>\n </StyledCheckbox>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAA6F,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR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;IAChBT,OAAO,EAAEb,SAAU;IACnBuB,QAAQ,EAAEtB,UAAW;IACrBuB,EAAE,EAAEV,IAAK;IACTX,QAAQ,EAAEM,YAAa;IACvBgB,IAAI,EAAC;EAAU,CAClB,CAAC,eACFvD,MAAA,CAAAY,OAAA,CAAAsC,aAAA,CAAC7C,SAAA,CAAAmD,mBAAmB;IAChBC,SAAS,EAAEzB,cAAe;IAC1B0B,OAAO,EAAEd,IAAK;IACdd,SAAS,EAAEA,SAAS,IAAIM,QAAS;IACjCL,UAAU,EAAEA,UAAW;IACvBG,kBAAkB,EAAEA,kBAAmB;IACvCY,UAAU,EAAEA;EAAW,GAEtBjB,QACgB,CACT,CAAC;AAEzB,CAAC;AAEDF,QAAQ,CAACgC,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjD,OAAA,GAEnBe,QAAQ"}
@@ -1,6 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
1
3
  import type { CheckboxProps } from './Checkbox';
2
- export declare const StyledCheckbox: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export declare const StyledCheckboxInput: import("styled-components").StyledComponent<"input", any, {}, never>;
4
- export declare const StyledCheckboxLabel: import("styled-components").StyledComponent<"label", any, Omit<CheckboxProps, "children" | "onChange"> & {
5
- theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
6
- }, never>;
4
+ export declare const StyledCheckbox: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
5
+ export declare const StyledCheckboxInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>>;
6
+ type StyledCheckboxLabelProps = WithTheme<{
7
+ shouldShowAsSwitch?: CheckboxProps['shouldShowAsSwitch'];
8
+ isDisabled?: CheckboxProps['isDisabled'];
9
+ isChecked?: CheckboxProps['isChecked'];
10
+ lineHeight?: number;
11
+ }>;
12
+ export declare const StyledCheckboxLabel: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, StyledCheckboxLabelProps>>;
13
+ export {};
@@ -5,62 +5,69 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.StyledCheckboxLabel = exports.StyledCheckboxInput = exports.StyledCheckbox = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
- const StyledCheckbox = _styledComponents.default.div`
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ const StyledCheckbox = exports.StyledCheckbox = _styledComponents.default.div`
11
11
  align-items: center;
12
12
  display: flex;
13
13
  position: relative;
14
14
  `;
15
- exports.StyledCheckbox = StyledCheckbox;
16
- const StyledCheckboxInput = _styledComponents.default.input`
15
+ const StyledCheckboxInput = exports.StyledCheckboxInput = _styledComponents.default.input`
17
16
  display: none;
18
17
  `;
19
- exports.StyledCheckboxInput = StyledCheckboxInput;
20
- const StyledCheckboxLabel = _styledComponents.default.label`
21
- cursor: ${_ref => {
18
+ const StyledCheckboxLabel = exports.StyledCheckboxLabel = _styledComponents.default.label`
19
+ color: ${_ref => {
22
20
  let {
23
- isDisabled
21
+ theme
24
22
  } = _ref;
25
- return isDisabled ? 'default' : 'pointer';
23
+ return theme.text;
26
24
  }};
27
- opacity: ${_ref2 => {
25
+ cursor: ${_ref2 => {
28
26
  let {
29
27
  isDisabled
30
28
  } = _ref2;
29
+ return isDisabled ? 'default' : 'pointer';
30
+ }};
31
+ opacity: ${_ref3 => {
32
+ let {
33
+ isDisabled
34
+ } = _ref3;
31
35
  return isDisabled ? 0.5 : 1;
32
36
  }};
33
- padding-left: ${_ref3 => {
37
+ padding-left: ${_ref4 => {
34
38
  let {
35
39
  shouldShowAsSwitch
36
- } = _ref3;
40
+ } = _ref4;
37
41
  return shouldShowAsSwitch ? '48px' : '20px';
38
42
  }};
39
43
  transition: opacity 0.2s ease;
40
44
  user-select: none;
41
45
 
42
46
  &:after {
43
- ${_ref4 => {
47
+ ${_ref5 => {
44
48
  let {
45
49
  isChecked,
46
- shouldShowAsSwitch
47
- } = _ref4;
50
+ shouldShowAsSwitch,
51
+ lineHeight
52
+ } = _ref5;
48
53
  return shouldShowAsSwitch ? (0, _styledComponents.css)`
49
54
  background-color: white;
50
55
  border-radius: 50%;
51
56
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
52
57
  height: 16px;
53
58
  left: 7px;
54
- transform: translateY(-50%) translateX(${isChecked ? '18px' : 0});
59
+ top: ${lineHeight ? `${lineHeight / 1.5}px` : '50%'};
60
+ transform: translateX(${isChecked ? '18px' : 0}) translateY(-50%);
55
61
  transition: transform 0.2s ease;
56
62
  width: 16px;
57
63
  ` : (0, _styledComponents.css)`
58
64
  border-right: 2px solid #fff;
59
65
  border-bottom: 2px solid #fff;
60
66
  height: 10px;
61
- left: 1px;
67
+ left: 2px;
62
68
  opacity: ${isChecked ? 1 : 0};
63
- transform: translateY(-50%) rotateZ(37deg);
69
+ top: ${lineHeight ? `calc(${lineHeight / 1.5}px - 2px)` : 'calc(50% - 2px)'};
70
+ transform: rotateZ(37deg) translateY(-50%);
64
71
  transition: opacity 0.2s ease;
65
72
  width: 5.5px;
66
73
  `;
@@ -68,58 +75,66 @@ const StyledCheckboxLabel = _styledComponents.default.label`
68
75
 
69
76
  content: ' ';
70
77
  position: absolute;
71
- top: 50%;
72
- transform-origin: 100% 100%;
73
78
  }
74
79
 
75
80
  &:before {
76
- background-color: ${_ref5 => {
81
+ background-color: ${_ref6 => {
77
82
  let {
78
83
  isChecked,
79
84
  shouldShowAsSwitch,
80
85
  theme
81
- } = _ref5;
86
+ } = _ref6;
82
87
  if (shouldShowAsSwitch) {
83
88
  return isChecked ? theme.green : theme.red;
84
89
  }
85
90
  return isChecked ? theme['408'] : theme['403'];
86
91
  }};
87
- border: 1px solid rgba(${_ref6 => {
92
+ border: 1px solid rgba(${_ref7 => {
88
93
  let {
89
94
  theme
90
- } = _ref6;
95
+ } = _ref7;
91
96
  return theme['409-rgb'];
92
97
  }}, 0.5);
93
- border-radius: ${_ref7 => {
98
+ border-radius: ${_ref8 => {
94
99
  let {
95
100
  shouldShowAsSwitch
96
- } = _ref7;
101
+ } = _ref8;
97
102
  return shouldShowAsSwitch ? '100px' : 0;
98
103
  }};
99
104
  content: ' ';
100
- height: ${_ref8 => {
105
+ height: ${_ref9 => {
101
106
  let {
102
107
  shouldShowAsSwitch
103
- } = _ref8;
108
+ } = _ref9;
104
109
  return shouldShowAsSwitch ? '13px' : '15px';
105
110
  }};
106
- left: ${_ref9 => {
111
+ left: ${_ref10 => {
107
112
  let {
108
113
  shouldShowAsSwitch
109
- } = _ref9;
114
+ } = _ref10;
110
115
  return shouldShowAsSwitch ? '10px' : 0;
111
116
  }};
112
117
  position: absolute;
113
- top: 50%;
114
- transform: translateY(-50%);
115
118
  transition: background-color 0.2s ease;
116
- width: ${_ref10 => {
119
+ width: ${_ref11 => {
117
120
  let {
118
121
  shouldShowAsSwitch
119
- } = _ref10;
122
+ } = _ref11;
120
123
  return shouldShowAsSwitch ? '28px' : '15px';
121
124
  }};
125
+ ${_ref12 => {
126
+ let {
127
+ lineHeight
128
+ } = _ref12;
129
+ return lineHeight ? (0, _styledComponents.css)`
130
+ top: ${lineHeight / 1.5}px;
131
+ transform: translateY(-50%);
132
+ ` : (0, _styledComponents.css)`
133
+ top: 50%;
134
+ transform: translateY(-50%);
135
+ `;
136
+ }}
137
+ }
122
138
  }
123
139
  `;
124
- exports.StyledCheckboxLabel = StyledCheckboxLabel;
125
140
  //# sourceMappingURL=Checkbox.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.styles.js","names":["StyledCheckbox","styled","div","StyledCheckboxInput","input","StyledCheckboxLabel","label","isDisabled","shouldShowAsSwitch","isChecked","css","theme","green","red"],"sources":["../../../src/components/checkbox/Checkbox.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { CheckboxProps } from './Checkbox';\n\nexport const StyledCheckbox = styled.div`\n align-items: center;\n display: flex;\n position: relative;\n`;\n\nexport const StyledCheckboxInput = styled.input`\n display: none;\n`;\n\ntype StyledCheckboxLabelProps = WithTheme<Omit<CheckboxProps, 'children' | 'onChange'>>;\n\nexport const StyledCheckboxLabel = styled.label<StyledCheckboxLabelProps>`\n cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n padding-left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '48px' : '20px')};\n transition: opacity 0.2s ease;\n user-select: none;\n\n &:after {\n ${({ isChecked, shouldShowAsSwitch }) =>\n shouldShowAsSwitch\n ? css`\n background-color: white;\n border-radius: 50%;\n box-shadow: 0 1px 4px rgb(0 0 0 / 35%);\n height: 16px;\n left: 7px;\n transform: translateY(-50%) translateX(${isChecked ? '18px' : 0});\n transition: transform 0.2s ease;\n width: 16px;\n `\n : css`\n border-right: 2px solid #fff;\n border-bottom: 2px solid #fff;\n height: 10px;\n left: 1px;\n opacity: ${isChecked ? 1 : 0};\n transform: translateY(-50%) rotateZ(37deg);\n transition: opacity 0.2s ease;\n width: 5.5px;\n `}\n\n content: ' ';\n position: absolute;\n top: 50%;\n transform-origin: 100% 100%;\n }\n\n &:before {\n background-color: ${({\n isChecked,\n shouldShowAsSwitch,\n theme,\n }: StyledCheckboxLabelProps) => {\n if (shouldShowAsSwitch) {\n return isChecked ? theme.green : theme.red;\n }\n\n return isChecked ? theme['408'] : theme['403'];\n }};\n border: 1px solid rgba(${({ theme }: StyledCheckboxLabelProps) => theme['409-rgb']}, 0.5);\n border-radius: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '100px' : 0)};\n content: ' ';\n height: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '13px' : '15px')};\n left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '10px' : 0)};\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n transition: background-color 0.2s ease;\n width: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch 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ACV,iCAAiC;EAAA,IAAC;IAAEA;EAAgC,CAAC;EAAA,OAAKA,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC3F,yBAAyB;EAAA,IAAC;IAAEH;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,OAAO,GAAG,CAAC;AAAA,CAAE;AACxF;AACA,kBAAkB;EAAA,IAAC;IAAEA;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,MAAM,GAAG,MAAM;AAAA,CAAE;AACrF,gBAAgB;EAAA,IAAC;IAAEA;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,MAAM,GAAG,CAAC;AAAA,CAAE;AAC9E;AACA;AACA;AACA;AACA,iBAAiB;EAAA,IAAC;IAAEA;EAAmB,CAAC;EAAA,OAAMA,kBAAkB,GAAG,MAAM,GAAG,MAAM;AAAA,CAAE;AACpF;AACA,CAAC;AAAC"}
1
+ {"version":3,"file":"Checkbox.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","StyledCheckbox","exports","styled","div","StyledCheckboxInput","input","StyledCheckboxLabel","label","_ref","theme","text","_ref2","isDisabled","_ref3","_ref4","shouldShowAsSwitch","_ref5","isChecked","lineHeight","css","_ref6","green","red","_ref7","_ref8","_ref9","_ref10","_ref11","_ref12"],"sources":["../../../src/components/checkbox/Checkbox.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { CheckboxProps } from './Checkbox';\n\nexport const StyledCheckbox = styled.div`\n align-items: center;\n display: flex;\n position: relative;\n`;\n\nexport const StyledCheckboxInput = styled.input`\n display: none;\n`;\n\ntype StyledCheckboxLabelProps = WithTheme<{\n shouldShowAsSwitch?: CheckboxProps['shouldShowAsSwitch'];\n isDisabled?: CheckboxProps['isDisabled'];\n isChecked?: CheckboxProps['isChecked'];\n lineHeight?: number;\n}>;\n\nexport const StyledCheckboxLabel = styled.label<StyledCheckboxLabelProps>`\n color: ${({ theme }: StyledCheckboxLabelProps) => theme.text};\n cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n padding-left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '48px' : '20px')};\n transition: opacity 0.2s ease;\n user-select: none;\n\n &:after {\n ${({ isChecked, shouldShowAsSwitch, lineHeight }) =>\n shouldShowAsSwitch\n ? css`\n background-color: white;\n border-radius: 50%;\n box-shadow: 0 1px 4px rgb(0 0 0 / 35%);\n height: 16px;\n left: 7px;\n top: ${lineHeight ? `${lineHeight / 1.5}px` : '50%'};\n transform: translateX(${isChecked ? '18px' : 0}) translateY(-50%);\n transition: transform 0.2s ease;\n width: 16px;\n `\n : css`\n border-right: 2px solid #fff;\n border-bottom: 2px solid #fff;\n height: 10px;\n left: 2px;\n opacity: ${isChecked ? 1 : 0};\n top: ${lineHeight ? `calc(${lineHeight / 1.5}px - 2px)` : 'calc(50% - 2px)'};\n transform: rotateZ(37deg) translateY(-50%);\n transition: opacity 0.2s ease;\n width: 5.5px;\n `}\n\n content: ' ';\n position: absolute;\n }\n\n &:before {\n background-color: ${({\n isChecked,\n shouldShowAsSwitch,\n theme,\n }: StyledCheckboxLabelProps) => {\n if (shouldShowAsSwitch) {\n return isChecked ? theme.green : theme.red;\n }\n\n return isChecked ? theme['408'] : theme['403'];\n }};\n border: 1px solid rgba(${({ theme }: StyledCheckboxLabelProps) => theme['409-rgb']}, 0.5);\n border-radius: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '100px' : 0)};\n content: ' ';\n height: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '13px' : '15px')};\n left: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '10px' : 0)};\n position: absolute;\n transition: background-color 0.2s ease;\n width: ${({ shouldShowAsSwitch }) => (shouldShowAsSwitch ? '28px' : '15px')};\n ${({ lineHeight }) =>\n lineHeight\n ? css`\n top: ${lineHeight / 1.5}px;\n transform: translateY(-50%);\n `\n : css`\n top: 50%;\n transform: translateY(-50%);\n `}\n }\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,Y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C;AACtB,6BAA6BD,UAAU,GAAG,GAAI;AAC9C;AACA,mBAAmB,GACD,IAAAC,qBAAG,CAAC;AACtB;AACA;AACA,mBAAmB;AAAA,CAAC;AACpB;AACA;AACA,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { FC } from 'react';
2
+ import { CodeHighlighterLanguage, CodeHighlighterTheme, HighlightedLines } from '../../types/codeHighlighter';
3
+ export type CodeHighlighterProps = {
4
+ /**
5
+ * The code that should be displayed.
6
+ */
7
+ code: string;
8
+ /**
9
+ * The text that should be displayed after the copy button.
10
+ * If not set, just the button is displayed without text.
11
+ */
12
+ copyButtonText?: string;
13
+ /**
14
+ * The lines of code that should be highlighted.
15
+ * Following lines can be highlighted: added, removed and just marked.
16
+ */
17
+ highlightedLines?: HighlightedLines;
18
+ /**
19
+ * The language of the displayed code.
20
+ */
21
+ language: CodeHighlighterLanguage;
22
+ /**
23
+ * Whether the code should be formatted with prettier.
24
+ */
25
+ shouldFormatCode?: boolean;
26
+ /**
27
+ * Whether the line numbers should be displayed.
28
+ */
29
+ shouldShowLineNumbers?: boolean;
30
+ /**
31
+ * The theme of the code block. Decide between dark and light.
32
+ */
33
+ theme?: CodeHighlighterTheme;
34
+ };
35
+ declare const CodeHighlighter: FC<CodeHighlighterProps>;
36
+ export default CodeHighlighter;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _standalone = require("prettier/standalone");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactSyntaxHighlighter = require("react-syntax-highlighter");
10
+ var _prism = require("react-syntax-highlighter/dist/esm/styles/prism");
11
+ var _codeHighlighter = require("../../types/codeHighlighter");
12
+ var _codeHighlighter2 = require("../../utils/codeHighlighter");
13
+ var _CodeHighlighter = require("./CodeHighlighter.styles");
14
+ var _CopyToClipboard = _interopRequireDefault(require("./copy-to-clipboard/CopyToClipboard"));
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ const CodeHighlighter = _ref => {
19
+ let {
20
+ theme = _codeHighlighter.CodeHighlighterTheme.Dark,
21
+ code,
22
+ copyButtonText,
23
+ language,
24
+ highlightedLines,
25
+ shouldFormatCode = false,
26
+ shouldShowLineNumbers = false
27
+ } = _ref;
28
+ // function to style highlighted code
29
+ const lineWrapper = (0, _react.useCallback)(lineNumber => {
30
+ let style = {
31
+ backgroundColor: 'none',
32
+ display: 'block',
33
+ borderRadius: '2px'
34
+ };
35
+ if (highlightedLines?.added && highlightedLines.added.includes(lineNumber)) {
36
+ style = {
37
+ ...style,
38
+ backgroundColor: '#2EF29930'
39
+ };
40
+ } else if (highlightedLines?.removed && highlightedLines.removed.includes(lineNumber)) {
41
+ style = {
42
+ ...style,
43
+ backgroundColor: '#F22E5B30'
44
+ };
45
+ } else if (highlightedLines?.marked && highlightedLines.marked.includes(lineNumber)) {
46
+ style = {
47
+ ...style,
48
+ backgroundColor: '#cccccc40'
49
+ };
50
+ }
51
+ return {
52
+ style
53
+ };
54
+ }, [highlightedLines]);
55
+ const formattedCode = (0, _react.useMemo)(() => {
56
+ if (language) {
57
+ const config = (0, _codeHighlighter2.getParserForLanguage)(language);
58
+ if (shouldFormatCode && config) {
59
+ return (0, _standalone.format)(code, config);
60
+ }
61
+ return code;
62
+ }
63
+ return code;
64
+ }, [code, language, shouldFormatCode]);
65
+ return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_CodeHighlighter.StyledCodeHighlighter, {
66
+ codeTheme: theme
67
+ }, /*#__PURE__*/_react.default.createElement(_CodeHighlighter.StyledCodeHighlighterHeader, {
68
+ codeTheme: theme
69
+ }, /*#__PURE__*/_react.default.createElement(_CodeHighlighter.StyledCodeHighlighterFileName, {
70
+ codeTheme: theme
71
+ }, (0, _codeHighlighter2.formatLanguage)(language)), /*#__PURE__*/_react.default.createElement(_CopyToClipboard.default, {
72
+ text: code,
73
+ theme: theme,
74
+ copyButtonText: copyButtonText
75
+ })), /*#__PURE__*/_react.default.createElement(_reactSyntaxHighlighter.PrismAsyncLight, {
76
+ language: language ?? '',
77
+ showLineNumbers: shouldShowLineNumbers,
78
+ style: theme === _codeHighlighter.CodeHighlighterTheme.Dark ? _prism.oneDark : _prism.oneLight,
79
+ wrapLines: true,
80
+ lineProps: lineWrapper
81
+ }, formattedCode)), [theme, language, code, copyButtonText, shouldShowLineNumbers, lineWrapper, formattedCode]);
82
+ };
83
+ CodeHighlighter.displayName = 'CodeHighlighter';
84
+ var _default = exports.default = CodeHighlighter;
85
+ //# sourceMappingURL=CodeHighlighter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeHighlighter.js","names":["_standalone","require","_react","_interopRequireWildcard","_reactSyntaxHighlighter","_prism","_codeHighlighter","_codeHighlighter2","_CodeHighlighter","_CopyToClipboard","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","CodeHighlighter","_ref","theme","CodeHighlighterTheme","Dark","code","copyButtonText","language","highlightedLines","shouldFormatCode","shouldShowLineNumbers","lineWrapper","useCallback","lineNumber","style","backgroundColor","display","borderRadius","added","includes","removed","marked","formattedCode","useMemo","config","getParserForLanguage","format","createElement","StyledCodeHighlighter","codeTheme","StyledCodeHighlighterHeader","StyledCodeHighlighterFileName","formatLanguage","text","PrismAsyncLight","showLineNumbers","oneDark","oneLight","wrapLines","lineProps","displayName","_default","exports"],"sources":["../../../src/components/code-highlighter/CodeHighlighter.tsx"],"sourcesContent":["import { format } from 'prettier/standalone';\nimport React, { FC, useCallback, useMemo } from 'react';\nimport { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { oneDark, oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';\nimport {\n CodeHighlighterLanguage,\n CodeHighlighterTheme,\n HighlightedLines,\n} from '../../types/codeHighlighter';\nimport { formatLanguage, getParserForLanguage } from '../../utils/codeHighlighter';\nimport {\n StyledCodeHighlighter,\n StyledCodeHighlighterFileName,\n StyledCodeHighlighterHeader,\n} from './CodeHighlighter.styles';\nimport CopyToClipboard from './copy-to-clipboard/CopyToClipboard';\n\nexport type CodeHighlighterProps = {\n /**\n * The code that should be displayed.\n */\n code: string;\n /**\n * The text that should be displayed after the copy button.\n * If not set, just the button is displayed without text.\n */\n copyButtonText?: string;\n /**\n * The lines of code that should be highlighted.\n * Following lines can be highlighted: added, removed and just marked.\n */\n highlightedLines?: HighlightedLines;\n /**\n * The language of the displayed code.\n */\n language: CodeHighlighterLanguage;\n /**\n * Whether the code should be formatted with prettier.\n */\n shouldFormatCode?: boolean;\n /**\n * Whether the line numbers should be displayed.\n */\n shouldShowLineNumbers?: boolean;\n /**\n * The theme of the code block. Decide between dark and light.\n */\n theme?: CodeHighlighterTheme;\n};\n\nconst CodeHighlighter: FC<CodeHighlighterProps> = ({\n theme = CodeHighlighterTheme.Dark,\n code,\n copyButtonText,\n language,\n highlightedLines,\n shouldFormatCode = false,\n shouldShowLineNumbers = false,\n}) => {\n // function to style highlighted code\n const lineWrapper = useCallback(\n (lineNumber: number) => {\n let style = {\n backgroundColor: 'none',\n display: 'block',\n borderRadius: '2px',\n };\n\n if (highlightedLines?.added && highlightedLines.added.includes(lineNumber)) {\n style = { ...style, backgroundColor: '#2EF29930' };\n } else if (highlightedLines?.removed && highlightedLines.removed.includes(lineNumber)) {\n style = { ...style, backgroundColor: '#F22E5B30' };\n } else if (highlightedLines?.marked && highlightedLines.marked.includes(lineNumber)) {\n style = { ...style, backgroundColor: '#cccccc40' };\n }\n\n return { style };\n },\n [highlightedLines],\n );\n\n const formattedCode = useMemo(() => {\n if (language) {\n const config = getParserForLanguage(language);\n\n if (shouldFormatCode && config) {\n return format(code, config) as unknown as string;\n }\n\n return code;\n }\n\n return code;\n }, [code, language, shouldFormatCode]);\n\n return useMemo(\n () => (\n <StyledCodeHighlighter codeTheme={theme}>\n <StyledCodeHighlighterHeader codeTheme={theme}>\n <StyledCodeHighlighterFileName codeTheme={theme}>\n {formatLanguage(language)}\n </StyledCodeHighlighterFileName>\n <CopyToClipboard text={code} theme={theme} copyButtonText={copyButtonText} />\n </StyledCodeHighlighterHeader>\n <SyntaxHighlighter\n language={language ?? ''}\n showLineNumbers={shouldShowLineNumbers}\n style={theme === CodeHighlighterTheme.Dark ? oneDark : oneLight}\n wrapLines\n lineProps={lineWrapper}\n >\n {formattedCode}\n </SyntaxHighlighter>\n </StyledCodeHighlighter>\n ),\n [theme, language, code, copyButtonText, shouldShowLineNumbers, lineWrapper, formattedCode],\n );\n};\n\nCodeHighlighter.displayName = 'CodeHighlighter';\n\nexport default CodeHighlighter;\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AAKA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AAKA,IAAAQ,gBAAA,GAAAC,sBAAA,CAAAT,OAAA;AAAkE,SAAAS,uBAAAC,GA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types/codeHighlighter';
3
+ import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
4
+ type StyledCodeHighlighterProps = WithTheme<{
5
+ codeTheme: CodeHighlighterTheme;
6
+ }>;
7
+ export declare const StyledCodeHighlighter: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledCodeHighlighterProps>>;
8
+ type StyledCodeHighlighterHeaderProps = WithTheme<{
9
+ codeTheme: CodeHighlighterTheme;
10
+ }>;
11
+ export declare const StyledCodeHighlighterHeader: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledCodeHighlighterHeaderProps>>;
12
+ type StyledCodeHighlighterFileNameProps = WithTheme<{
13
+ codeTheme: CodeHighlighterTheme;
14
+ }>;
15
+ export declare const StyledCodeHighlighterFileName: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, StyledCodeHighlighterFileNameProps>>;
16
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledCodeHighlighterHeader = exports.StyledCodeHighlighterFileName = exports.StyledCodeHighlighter = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _codeHighlighter = require("../../types/codeHighlighter");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const StyledCodeHighlighter = exports.StyledCodeHighlighter = _styledComponents.default.div`
11
+ margin: 4px 0;
12
+ background-color: ${_ref => {
13
+ let {
14
+ codeTheme
15
+ } = _ref;
16
+ return codeTheme === _codeHighlighter.CodeHighlighterTheme.Dark ? '#282c34' : '#fafafa';
17
+ }};
18
+ border-radius: 8px;
19
+ padding-bottom: 6px;
20
+
21
+ pre {
22
+ margin: 0 !important;
23
+ overflow: auto;
24
+ padding: 1em;
25
+ line-height: 1.5;
26
+
27
+ // Styles for custom scrollbar
28
+ &::-webkit-scrollbar {
29
+ height: 5px;
30
+ }
31
+
32
+ &::-webkit-scrollbar-track {
33
+ background-color: transparent;
34
+ }
35
+
36
+ &::-webkit-scrollbar-button {
37
+ background-color: transparent;
38
+ height: 2px;
39
+ }
40
+
41
+ &::-webkit-scrollbar-thumb {
42
+
43
+ background-color: rgba(${_ref2 => {
44
+ let {
45
+ codeTheme
46
+ } = _ref2;
47
+ return codeTheme === _codeHighlighter.CodeHighlighterTheme.Dark ? '229, 229, 229' : '153, 153, 153';
48
+ }},
49
+ 1);
50
+ border-radius: 20px;
51
+ }
52
+
53
+ // Scrollbar styles for Firefox. The above styles are not supported in Firefox, these styles are
54
+ // only supported in Firefox:
55
+ * {
56
+ scrollbar-color: rgba(${_ref3 => {
57
+ let {
58
+ codeTheme
59
+ } = _ref3;
60
+ return codeTheme === _codeHighlighter.CodeHighlighterTheme.Dark ? '229, 229, 229' : '153, 153, 153';
61
+ }},
62
+ 1);)transparent;
63
+ scrollbar-width: thin;
64
+ }
65
+ }
66
+ `;
67
+ const StyledCodeHighlighterHeader = exports.StyledCodeHighlighterHeader = _styledComponents.default.div`
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: space-between;
71
+ border-bottom: 1px solid
72
+ ${_ref4 => {
73
+ let {
74
+ codeTheme
75
+ } = _ref4;
76
+ return codeTheme === _codeHighlighter.CodeHighlighterTheme.Dark ? '#e5e5e5' : '#999999';
77
+ }};
78
+ padding: 4px 12px;
79
+ `;
80
+ const StyledCodeHighlighterFileName = exports.StyledCodeHighlighterFileName = _styledComponents.default.span`
81
+ color: ${_ref5 => {
82
+ let {
83
+ codeTheme
84
+ } = _ref5;
85
+ return codeTheme === _codeHighlighter.CodeHighlighterTheme.Dark ? '#e5e5e5' : '#999999';
86
+ }};
87
+ `;
88
+ //# sourceMappingURL=CodeHighlighter.styles.js.map