@chayns-components/core 5.0.0-beta.41 → 5.0.0-beta.412

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 (488) 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/signature/delete.d.ts +1 -0
  6. package/lib/api/signature/delete.js +30 -0
  7. package/lib/api/signature/delete.js.map +1 -0
  8. package/lib/api/signature/get.d.ts +1 -0
  9. package/lib/api/signature/get.js +40 -0
  10. package/lib/api/signature/get.js.map +1 -0
  11. package/lib/api/signature/put.d.ts +1 -0
  12. package/lib/api/signature/put.js +34 -0
  13. package/lib/api/signature/put.js.map +1 -0
  14. package/lib/api/video/post.d.ts +16 -0
  15. package/lib/api/video/post.js +31 -0
  16. package/lib/api/video/post.js.map +1 -0
  17. package/lib/components/accordion/Accordion.d.ts +28 -3
  18. package/lib/components/accordion/Accordion.js +59 -22
  19. package/lib/components/accordion/Accordion.js.map +1 -1
  20. package/lib/components/accordion/Accordion.styles.d.ts +6 -4
  21. package/lib/components/accordion/Accordion.styles.js +42 -28
  22. package/lib/components/accordion/Accordion.styles.js.map +1 -1
  23. package/lib/components/accordion/accordion-body/AccordionBody.d.ts +21 -2
  24. package/lib/components/accordion/accordion-body/AccordionBody.js +17 -11
  25. package/lib/components/accordion/accordion-body/AccordionBody.js.map +1 -1
  26. package/lib/components/accordion/accordion-body/AccordionBody.styles.d.ts +268 -1
  27. package/lib/components/accordion/accordion-body/AccordionBody.styles.js +14 -4
  28. package/lib/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  29. package/lib/components/accordion/accordion-content/AccordionContent.d.ts +10 -2
  30. package/lib/components/accordion/accordion-content/AccordionContent.js +7 -4
  31. package/lib/components/accordion/accordion-content/AccordionContent.js.map +1 -1
  32. package/lib/components/accordion/accordion-content/AccordionContent.styles.d.ts +7 -4
  33. package/lib/components/accordion/accordion-content/AccordionContent.styles.js +14 -4
  34. package/lib/components/accordion/accordion-content/AccordionContent.styles.js.map +1 -1
  35. package/lib/components/accordion/accordion-group/AccordionGroup.d.ts +4 -3
  36. package/lib/components/accordion/accordion-group/AccordionGroup.js +6 -6
  37. package/lib/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  38. package/lib/components/accordion/accordion-head/AccordionHead.d.ts +2 -1
  39. package/lib/components/accordion/accordion-head/AccordionHead.js +7 -8
  40. package/lib/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  41. package/lib/components/accordion/accordion-head/AccordionHead.styles.d.ts +2417 -12
  42. package/lib/components/accordion/accordion-head/AccordionHead.styles.js +20 -24
  43. package/lib/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  44. package/lib/components/accordion/accordion-intro/AccordionIntro.d.ts +1 -1
  45. package/lib/components/accordion/accordion-intro/AccordionIntro.js +1 -2
  46. package/lib/components/accordion/accordion-intro/AccordionIntro.js.map +1 -1
  47. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.d.ts +2 -1
  48. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js +1 -2
  49. package/lib/components/accordion/accordion-intro/AccordionIntro.styles.js.map +1 -1
  50. package/lib/components/accordion/accordion-item/AccordionItem.d.ts +9 -0
  51. package/lib/components/accordion/accordion-item/AccordionItem.js +27 -0
  52. package/lib/components/accordion/accordion-item/AccordionItem.js.map +1 -0
  53. package/lib/components/accordion/accordion-item/AccordionItem.styles.d.ts +7 -0
  54. package/lib/components/accordion/accordion-item/AccordionItem.styles.js +33 -0
  55. package/lib/components/accordion/accordion-item/AccordionItem.styles.js.map +1 -0
  56. package/lib/components/accordion/utils.js.map +1 -1
  57. package/lib/components/amount-control/AmountControl.d.ts +22 -0
  58. package/lib/components/amount-control/AmountControl.js +185 -0
  59. package/lib/components/amount-control/AmountControl.js.map +1 -0
  60. package/lib/components/amount-control/AmountControl.styles.d.ts +288 -0
  61. package/lib/components/amount-control/AmountControl.styles.js +58 -0
  62. package/lib/components/amount-control/AmountControl.styles.js.map +1 -0
  63. package/lib/components/amount-control/utils.d.ts +7 -0
  64. package/lib/components/amount-control/utils.js +22 -0
  65. package/lib/components/amount-control/utils.js.map +1 -0
  66. package/lib/components/badge/Badge.d.ts +1 -1
  67. package/lib/components/badge/Badge.js +1 -2
  68. package/lib/components/badge/Badge.js.map +1 -1
  69. package/lib/components/badge/Badge.styles.d.ts +5 -3
  70. package/lib/components/badge/Badge.styles.js +3 -4
  71. package/lib/components/badge/Badge.styles.js.map +1 -1
  72. package/lib/components/button/Button.d.ts +6 -2
  73. package/lib/components/button/Button.js +55 -4
  74. package/lib/components/button/Button.js.map +1 -1
  75. package/lib/components/button/Button.styles.d.ts +538 -4
  76. package/lib/components/button/Button.styles.js +36 -15
  77. package/lib/components/button/Button.styles.js.map +1 -1
  78. package/lib/components/checkbox/Checkbox.d.ts +11 -3
  79. package/lib/components/checkbox/Checkbox.js +13 -8
  80. package/lib/components/checkbox/Checkbox.js.map +1 -1
  81. package/lib/components/checkbox/Checkbox.styles.d.ts +12 -5
  82. package/lib/components/checkbox/Checkbox.styles.js +51 -36
  83. package/lib/components/checkbox/Checkbox.styles.js.map +1 -1
  84. package/lib/components/code-highlighter/CodeHighlighter.d.ts +36 -0
  85. package/lib/components/code-highlighter/CodeHighlighter.js +85 -0
  86. package/lib/components/code-highlighter/CodeHighlighter.js.map +1 -0
  87. package/lib/components/code-highlighter/CodeHighlighter.styles.d.ts +16 -0
  88. package/lib/components/code-highlighter/CodeHighlighter.styles.js +88 -0
  89. package/lib/components/code-highlighter/CodeHighlighter.styles.js.map +1 -0
  90. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.d.ts +9 -0
  91. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.js +41 -0
  92. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.js.map +1 -0
  93. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.d.ts +9 -0
  94. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.js +24 -0
  95. package/lib/components/code-highlighter/copy-to-clipboard/CopyToClipboard.styles.js.map +1 -0
  96. package/lib/components/color-scheme-provider/ColorSchemeProvider.d.ts +3 -2
  97. package/lib/components/color-scheme-provider/ColorSchemeProvider.js +14 -12
  98. package/lib/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  99. package/lib/components/color-scheme-provider/font.d.ts +6 -0
  100. package/lib/components/color-scheme-provider/font.js +59 -0
  101. package/lib/components/color-scheme-provider/font.js.map +1 -0
  102. package/lib/components/combobox/ComboBox.d.ts +43 -0
  103. package/lib/components/combobox/ComboBox.js +187 -0
  104. package/lib/components/combobox/ComboBox.js.map +1 -0
  105. package/lib/components/combobox/ComboBox.styles.d.ts +289 -0
  106. package/lib/components/combobox/ComboBox.styles.js +184 -0
  107. package/lib/components/combobox/ComboBox.styles.js.map +1 -0
  108. package/lib/components/combobox/combobox-item/ComboBoxItem.d.ts +12 -0
  109. package/lib/components/combobox/combobox-item/ComboBoxItem.js +40 -0
  110. package/lib/components/combobox/combobox-item/ComboBoxItem.js.map +1 -0
  111. package/lib/components/combobox/combobox-item/ComboBoxItem.styles.d.ts +11 -0
  112. package/lib/components/combobox/combobox-item/ComboBoxItem.styles.js +62 -0
  113. package/lib/components/combobox/combobox-item/ComboBoxItem.styles.js.map +1 -0
  114. package/lib/components/content-card/ContentCard.d.ts +13 -0
  115. package/lib/components/content-card/ContentCard.js +21 -0
  116. package/lib/components/content-card/ContentCard.js.map +1 -0
  117. package/lib/components/content-card/ContentCard.styles.d.ts +2 -0
  118. package/lib/components/content-card/ContentCard.styles.js +22 -0
  119. package/lib/components/content-card/ContentCard.styles.js.map +1 -0
  120. package/lib/components/context-menu/ContextMenu.d.ts +5 -5
  121. package/lib/components/context-menu/ContextMenu.js +18 -19
  122. package/lib/components/context-menu/ContextMenu.js.map +1 -1
  123. package/lib/components/context-menu/ContextMenu.styles.d.ts +2 -1
  124. package/lib/components/context-menu/ContextMenu.styles.js +1 -2
  125. package/lib/components/context-menu/ContextMenu.styles.js.map +1 -1
  126. package/lib/components/context-menu/constants/alignment.js +3 -4
  127. package/lib/components/context-menu/constants/alignment.js.map +1 -1
  128. package/lib/components/context-menu/context-menu-content/ContextMenuContent.d.ts +1 -1
  129. package/lib/components/context-menu/context-menu-content/ContextMenuContent.js +4 -3
  130. package/lib/components/context-menu/context-menu-content/ContextMenuContent.js.map +1 -1
  131. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.d.ts +273 -8
  132. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js +14 -19
  133. package/lib/components/context-menu/context-menu-content/ContextMenuContent.styles.js.map +1 -1
  134. package/lib/components/date-info/DateInfo.d.ts +37 -0
  135. package/lib/components/date-info/DateInfo.js +111 -0
  136. package/lib/components/date-info/DateInfo.js.map +1 -0
  137. package/lib/components/date-info/constants/language.d.ts +22 -0
  138. package/lib/components/date-info/constants/language.js +629 -0
  139. package/lib/components/date-info/constants/language.js.map +1 -0
  140. package/lib/components/date-info/utils/format.d.ts +49 -0
  141. package/lib/components/date-info/utils/format.js +315 -0
  142. package/lib/components/date-info/utils/format.js.map +1 -0
  143. package/lib/components/date-info/utils/language.d.ts +7 -0
  144. package/lib/components/date-info/utils/language.js +57 -0
  145. package/lib/components/date-info/utils/language.js.map +1 -0
  146. package/lib/components/file-input/FileInput.d.ts +29 -0
  147. package/lib/components/file-input/FileInput.js +121 -0
  148. package/lib/components/file-input/FileInput.js.map +1 -0
  149. package/lib/components/file-input/FileInput.styles.d.ts +277 -0
  150. package/lib/components/file-input/FileInput.styles.js +46 -0
  151. package/lib/components/file-input/FileInput.styles.js.map +1 -0
  152. package/lib/components/file-input/file-list/FileListItem.d.ts +9 -0
  153. package/lib/components/file-input/file-list/FileListItem.js +36 -0
  154. package/lib/components/file-input/file-list/FileListItem.js.map +1 -0
  155. package/lib/components/file-input/file-list/FileListItem.styles.d.ts +2 -0
  156. package/lib/components/file-input/file-list/FileListItem.styles.js +10 -0
  157. package/lib/components/file-input/file-list/FileListItem.styles.js.map +1 -0
  158. package/lib/components/filter-buttons/FilterButtons.d.ts +22 -0
  159. package/lib/components/filter-buttons/FilterButtons.js +88 -0
  160. package/lib/components/filter-buttons/FilterButtons.js.map +1 -0
  161. package/lib/components/filter-buttons/FilterButtons.styles.d.ts +2 -0
  162. package/lib/components/filter-buttons/FilterButtons.styles.js +14 -0
  163. package/lib/components/filter-buttons/FilterButtons.styles.js.map +1 -0
  164. package/lib/components/filter-buttons/filter-button/FilterButton.d.ts +14 -0
  165. package/lib/components/filter-buttons/filter-button/FilterButton.js +47 -0
  166. package/lib/components/filter-buttons/filter-button/FilterButton.js.map +1 -0
  167. package/lib/components/filter-buttons/filter-button/FilterButton.styles.d.ts +287 -0
  168. package/lib/components/filter-buttons/filter-button/FilterButton.styles.js +106 -0
  169. package/lib/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -0
  170. package/lib/components/filter-buttons/types.d.ts +15 -0
  171. package/lib/components/filter-buttons/types.js +17 -0
  172. package/lib/components/filter-buttons/types.js.map +1 -0
  173. package/lib/components/grid-image/GridImage.d.ts +1 -1
  174. package/lib/components/grid-image/GridImage.js +3 -4
  175. package/lib/components/grid-image/GridImage.js.map +1 -1
  176. package/lib/components/grid-image/GridImage.styles.d.ts +12 -11
  177. package/lib/components/grid-image/GridImage.styles.js +4 -8
  178. package/lib/components/grid-image/GridImage.styles.js.map +1 -1
  179. package/lib/components/icon/Icon.d.ts +1 -1
  180. package/lib/components/icon/Icon.js +2 -3
  181. package/lib/components/icon/Icon.js.map +1 -1
  182. package/lib/components/icon/Icon.styles.d.ts +7 -7
  183. package/lib/components/icon/Icon.styles.js +6 -8
  184. package/lib/components/icon/Icon.styles.js.map +1 -1
  185. package/lib/components/icon/utils.js +1 -2
  186. package/lib/components/icon/utils.js.map +1 -1
  187. package/lib/components/input/Input.d.ts +39 -3
  188. package/lib/components/input/Input.js +65 -16
  189. package/lib/components/input/Input.js.map +1 -1
  190. package/lib/components/input/Input.styles.d.ts +546 -6
  191. package/lib/components/input/Input.styles.js +86 -28
  192. package/lib/components/input/Input.styles.js.map +1 -1
  193. package/lib/components/list/List.d.ts +1 -1
  194. package/lib/components/list/List.js +4 -6
  195. package/lib/components/list/List.js.map +1 -1
  196. package/lib/components/list/list-item/ListItem.d.ts +2 -2
  197. package/lib/components/list/list-item/ListItem.js +7 -6
  198. package/lib/components/list/list-item/ListItem.js.map +1 -1
  199. package/lib/components/list/list-item/ListItem.styles.d.ts +6 -4
  200. package/lib/components/list/list-item/ListItem.styles.js +14 -26
  201. package/lib/components/list/list-item/ListItem.styles.js.map +1 -1
  202. package/lib/components/list/list-item/list-item-body/ListItemBody.d.ts +6 -2
  203. package/lib/components/list/list-item/list-item-body/ListItemBody.js +28 -7
  204. package/lib/components/list/list-item/list-item-body/ListItemBody.js.map +1 -1
  205. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.d.ts +267 -1
  206. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js +1 -2
  207. package/lib/components/list/list-item/list-item-body/ListItemBody.styles.js.map +1 -1
  208. package/lib/components/list/list-item/list-item-content/ListItemContent.d.ts +8 -2
  209. package/lib/components/list/list-item/list-item-content/ListItemContent.js +1 -2
  210. package/lib/components/list/list-item/list-item-content/ListItemContent.js.map +1 -1
  211. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.d.ts +2 -1
  212. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js +1 -2
  213. package/lib/components/list/list-item/list-item-content/ListItemContent.styles.js.map +1 -1
  214. package/lib/components/list/list-item/list-item-head/ListItemHead.d.ts +1 -1
  215. package/lib/components/list/list-item/list-item-head/ListItemHead.js +4 -5
  216. package/lib/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  217. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.d.ts +544 -14
  218. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js +13 -24
  219. package/lib/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  220. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.d.ts +1 -1
  221. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js +1 -2
  222. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.js.map +1 -1
  223. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.d.ts +2 -1
  224. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js +1 -2
  225. package/lib/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.js.map +1 -1
  226. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.d.ts +1 -1
  227. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js +3 -4
  228. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -1
  229. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.d.ts +8 -7
  230. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js +2 -4
  231. package/lib/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js.map +1 -1
  232. package/lib/components/mention-finder/MentionFinder.d.ts +31 -0
  233. package/lib/components/mention-finder/MentionFinder.js +139 -0
  234. package/lib/components/mention-finder/MentionFinder.js.map +1 -0
  235. package/lib/components/mention-finder/MentionFinder.styles.d.ts +270 -0
  236. package/lib/components/mention-finder/MentionFinder.styles.js +92 -0
  237. package/lib/components/mention-finder/MentionFinder.styles.js.map +1 -0
  238. package/lib/components/mention-finder/constants/alignment.d.ts +4 -0
  239. package/lib/components/mention-finder/constants/alignment.js +12 -0
  240. package/lib/components/mention-finder/constants/alignment.js.map +1 -0
  241. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.d.ts +10 -0
  242. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.js +31 -0
  243. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.js.map +1 -0
  244. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.d.ts +10 -0
  245. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js +91 -0
  246. package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -0
  247. package/lib/components/number-input/NumberInput.d.ts +50 -0
  248. package/lib/components/number-input/NumberInput.js +130 -0
  249. package/lib/components/number-input/NumberInput.js.map +1 -0
  250. package/lib/components/number-input/constants/number.d.ts +5 -0
  251. package/lib/components/number-input/constants/number.js +12 -0
  252. package/lib/components/number-input/constants/number.js.map +1 -0
  253. package/lib/components/number-input/utils/number.d.ts +23 -0
  254. package/lib/components/number-input/utils/number.js +84 -0
  255. package/lib/components/number-input/utils/number.js.map +1 -0
  256. package/lib/components/opening-times/OpeningTimes.d.ts +19 -0
  257. package/lib/components/opening-times/OpeningTimes.js +73 -0
  258. package/lib/components/opening-times/OpeningTimes.js.map +1 -0
  259. package/lib/components/opening-times/OpeningTimes.styles.d.ts +8 -0
  260. package/lib/components/opening-times/OpeningTimes.styles.js +19 -0
  261. package/lib/components/opening-times/OpeningTimes.styles.js.map +1 -0
  262. package/lib/components/opening-times/opening-inputs/OpeningInputs.d.ts +9 -0
  263. package/lib/components/opening-times/opening-inputs/OpeningInputs.js +81 -0
  264. package/lib/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -0
  265. package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +2 -0
  266. package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.js +13 -0
  267. package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -0
  268. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.d.ts +13 -0
  269. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.js +77 -0
  270. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -0
  271. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +10 -0
  272. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +42 -0
  273. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -0
  274. package/lib/components/popup/Popup.d.ts +30 -0
  275. package/lib/components/popup/Popup.js +161 -0
  276. package/lib/components/popup/Popup.js.map +1 -0
  277. package/lib/components/popup/Popup.styles.d.ts +5 -0
  278. package/lib/components/popup/Popup.styles.js +28 -0
  279. package/lib/components/popup/Popup.styles.js.map +1 -0
  280. package/lib/components/popup/popup-content/PopupContent.d.ts +10 -0
  281. package/lib/components/popup/popup-content/PopupContent.js +69 -0
  282. package/lib/components/popup/popup-content/PopupContent.js.map +1 -0
  283. package/lib/components/popup/popup-content/PopupContent.styles.d.ts +274 -0
  284. package/lib/components/popup/popup-content/PopupContent.styles.js +92 -0
  285. package/lib/components/popup/popup-content/PopupContent.styles.js.map +1 -0
  286. package/lib/components/popup/types.d.ts +16 -0
  287. package/lib/components/popup/types.js +16 -0
  288. package/lib/components/popup/types.js.map +1 -0
  289. package/lib/components/progress-bar/ProgressBar.d.ts +13 -0
  290. package/lib/components/progress-bar/ProgressBar.js +39 -0
  291. package/lib/components/progress-bar/ProgressBar.js.map +1 -0
  292. package/lib/components/progress-bar/ProgressBar.styles.d.ts +272 -0
  293. package/lib/components/progress-bar/ProgressBar.styles.js +37 -0
  294. package/lib/components/progress-bar/ProgressBar.styles.js.map +1 -0
  295. package/lib/components/radio-button/RadioButton.d.ts +30 -0
  296. package/lib/components/radio-button/RadioButton.js +100 -0
  297. package/lib/components/radio-button/RadioButton.js.map +1 -0
  298. package/lib/components/radio-button/RadioButton.styles.d.ts +287 -0
  299. package/lib/components/radio-button/RadioButton.styles.js +105 -0
  300. package/lib/components/radio-button/RadioButton.styles.js.map +1 -0
  301. package/lib/components/radio-button/radio-button-group/RadioButtonGroup.d.ts +17 -0
  302. package/lib/components/radio-button/radio-button-group/RadioButtonGroup.js +46 -0
  303. package/lib/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -0
  304. package/lib/components/radio-button/types.d.ts +4 -0
  305. package/lib/components/radio-button/types.js +2 -0
  306. package/lib/components/radio-button/types.js.map +1 -0
  307. package/lib/components/scroll-view/ScrollView.d.ts +13 -0
  308. package/lib/components/scroll-view/ScrollView.js +22 -0
  309. package/lib/components/scroll-view/ScrollView.js.map +1 -0
  310. package/lib/components/scroll-view/ScrollView.styles.d.ts +7 -0
  311. package/lib/components/scroll-view/ScrollView.styles.js +26 -0
  312. package/lib/components/scroll-view/ScrollView.styles.js.map +1 -0
  313. package/lib/components/search-box/SearchBox.d.ts +34 -0
  314. package/lib/components/search-box/SearchBox.js +246 -0
  315. package/lib/components/search-box/SearchBox.js.map +1 -0
  316. package/lib/components/search-box/SearchBox.styles.d.ts +272 -0
  317. package/lib/components/search-box/SearchBox.styles.js +56 -0
  318. package/lib/components/search-box/SearchBox.styles.js.map +1 -0
  319. package/lib/components/search-box/search-box-item/SearchBoxItem.d.ts +9 -0
  320. package/lib/components/search-box/search-box-item/SearchBoxItem.js +30 -0
  321. package/lib/components/search-box/search-box-item/SearchBoxItem.js.map +1 -0
  322. package/lib/components/search-box/search-box-item/SearchBoxItem.styles.d.ts +7 -0
  323. package/lib/components/search-box/search-box-item/SearchBoxItem.styles.js +37 -0
  324. package/lib/components/search-box/search-box-item/SearchBoxItem.styles.js.map +1 -0
  325. package/lib/components/search-box/types.d.ts +4 -0
  326. package/lib/components/search-box/types.js +2 -0
  327. package/lib/components/search-box/types.js.map +1 -0
  328. package/lib/components/search-box/utils.d.ts +7 -0
  329. package/lib/components/search-box/utils.js +23 -0
  330. package/lib/components/search-box/utils.js.map +1 -0
  331. package/lib/components/search-input/SearchInput.d.ts +33 -0
  332. package/lib/components/search-input/SearchInput.js +102 -0
  333. package/lib/components/search-input/SearchInput.js.map +1 -0
  334. package/lib/components/search-input/SearchInput.styles.d.ts +534 -0
  335. package/lib/components/search-input/SearchInput.styles.js +26 -0
  336. package/lib/components/search-input/SearchInput.styles.js.map +1 -0
  337. package/lib/components/select-button/SelectButton.d.ts +34 -0
  338. package/lib/components/select-button/SelectButton.js +65 -0
  339. package/lib/components/select-button/SelectButton.js.map +1 -0
  340. package/lib/components/select-button/SelectButton.styles.d.ts +2 -0
  341. package/lib/components/select-button/SelectButton.styles.js +10 -0
  342. package/lib/components/select-button/SelectButton.styles.js.map +1 -0
  343. package/lib/components/select-button/types.d.ts +4 -0
  344. package/lib/components/select-button/types.js +2 -0
  345. package/lib/components/select-button/types.js.map +1 -0
  346. package/lib/components/setup-wizard/SetupWizard.d.ts +23 -0
  347. package/lib/components/setup-wizard/SetupWizard.js +79 -0
  348. package/lib/components/setup-wizard/SetupWizard.js.map +1 -0
  349. package/lib/components/setup-wizard/SetupWizard.styles.d.ts +2 -0
  350. package/lib/components/setup-wizard/SetupWizard.styles.js +10 -0
  351. package/lib/components/setup-wizard/SetupWizard.styles.js.map +1 -0
  352. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.d.ts +25 -0
  353. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +60 -0
  354. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -0
  355. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.d.ts +3 -0
  356. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.js +14 -0
  357. package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.js.map +1 -0
  358. package/lib/components/sharing-bar/SharingBar.d.ts +18 -0
  359. package/lib/components/sharing-bar/SharingBar.js +110 -0
  360. package/lib/components/sharing-bar/SharingBar.js.map +1 -0
  361. package/lib/components/sharing-bar/SharingBar.styles.d.ts +6 -0
  362. package/lib/components/sharing-bar/SharingBar.styles.js +24 -0
  363. package/lib/components/sharing-bar/SharingBar.styles.js.map +1 -0
  364. package/lib/components/signature/Signature.d.ts +33 -0
  365. package/lib/components/signature/Signature.js +111 -0
  366. package/lib/components/signature/Signature.js.map +1 -0
  367. package/lib/components/signature/Signature.styles.d.ts +5 -0
  368. package/lib/components/signature/Signature.styles.js +21 -0
  369. package/lib/components/signature/Signature.styles.js.map +1 -0
  370. package/lib/components/slider/Slider.d.ts +41 -0
  371. package/lib/components/slider/Slider.js +170 -0
  372. package/lib/components/slider/Slider.js.map +1 -0
  373. package/lib/components/slider/Slider.styles.d.ts +16 -0
  374. package/lib/components/slider/Slider.styles.js +106 -0
  375. package/lib/components/slider/Slider.styles.js.map +1 -0
  376. package/lib/components/slider-button/SliderButton.d.ts +23 -0
  377. package/lib/components/slider-button/SliderButton.js +156 -0
  378. package/lib/components/slider-button/SliderButton.js.map +1 -0
  379. package/lib/components/slider-button/SliderButton.styles.d.ts +279 -0
  380. package/lib/components/slider-button/SliderButton.styles.js +69 -0
  381. package/lib/components/slider-button/SliderButton.styles.js.map +1 -0
  382. package/lib/components/small-wait-cursor/SmallWaitCursor.d.ts +31 -0
  383. package/lib/components/small-wait-cursor/SmallWaitCursor.js +42 -0
  384. package/lib/components/small-wait-cursor/SmallWaitCursor.js.map +1 -0
  385. package/lib/components/small-wait-cursor/SmallWaitCursor.styles.d.ts +19 -0
  386. package/lib/components/small-wait-cursor/SmallWaitCursor.styles.js +101 -0
  387. package/lib/components/small-wait-cursor/SmallWaitCursor.styles.js.map +1 -0
  388. package/lib/components/text-area/TextArea.d.ts +29 -0
  389. package/lib/components/text-area/TextArea.js +72 -0
  390. package/lib/components/text-area/TextArea.js.map +1 -0
  391. package/lib/components/text-area/TextArea.styles.d.ts +13 -0
  392. package/lib/components/text-area/TextArea.styles.js +79 -0
  393. package/lib/components/text-area/TextArea.styles.js.map +1 -0
  394. package/lib/components/tooltip/Tooltip.d.ts +18 -0
  395. package/lib/components/tooltip/Tooltip.js +34 -0
  396. package/lib/components/tooltip/Tooltip.js.map +1 -0
  397. package/lib/components/tooltip/Tooltip.styles.d.ts +2 -0
  398. package/lib/components/tooltip/Tooltip.styles.js +10 -0
  399. package/lib/components/tooltip/Tooltip.styles.js.map +1 -0
  400. package/lib/components/tooltip/interface.d.ts +9 -0
  401. package/lib/components/tooltip/interface.js +2 -0
  402. package/lib/components/tooltip/interface.js.map +1 -0
  403. package/lib/components/tooltip/tooltip-item/TooltipItem.d.ts +12 -0
  404. package/lib/components/tooltip/tooltip-item/TooltipItem.js +28 -0
  405. package/lib/components/tooltip/tooltip-item/TooltipItem.js.map +1 -0
  406. package/lib/components/tooltip/tooltip-item/TooltipItem.styles.d.ts +10 -0
  407. package/lib/components/tooltip/tooltip-item/TooltipItem.styles.js +34 -0
  408. package/lib/components/tooltip/tooltip-item/TooltipItem.styles.js.map +1 -0
  409. package/lib/components/truncation/Truncation.d.ts +25 -0
  410. package/lib/components/truncation/Truncation.js +86 -0
  411. package/lib/components/truncation/Truncation.js.map +1 -0
  412. package/lib/components/truncation/Truncation.styles.d.ts +270 -0
  413. package/lib/components/truncation/Truncation.styles.js +27 -0
  414. package/lib/components/truncation/Truncation.styles.js.map +1 -0
  415. package/lib/constants/codeHighlighter.d.ts +7 -0
  416. package/lib/constants/codeHighlighter.js +13 -0
  417. package/lib/constants/codeHighlighter.js.map +1 -0
  418. package/lib/constants/serverUrls.d.ts +1 -0
  419. package/lib/constants/serverUrls.js +8 -0
  420. package/lib/constants/serverUrls.js.map +1 -0
  421. package/lib/hooks/colorMode.d.ts +2 -0
  422. package/lib/hooks/colorMode.js +22 -0
  423. package/lib/hooks/colorMode.js.map +1 -0
  424. package/lib/hooks/uuid.js.map +1 -1
  425. package/lib/index.d.ts +48 -0
  426. package/lib/index.js +265 -0
  427. package/lib/index.js.map +1 -1
  428. package/lib/types/chayns.d.ts +67 -1
  429. package/lib/types/chayns.js +3 -4
  430. package/lib/types/chayns.js.map +1 -1
  431. package/lib/types/codeHighlighter.d.ts +10 -0
  432. package/lib/types/codeHighlighter.js +12 -0
  433. package/lib/types/codeHighlighter.js.map +1 -0
  434. package/lib/types/comboBox.d.ts +4 -0
  435. package/lib/types/comboBox.js +12 -0
  436. package/lib/types/comboBox.js.map +1 -0
  437. package/lib/types/file.d.ts +42 -0
  438. package/lib/types/file.js +2 -0
  439. package/lib/types/file.js.map +1 -0
  440. package/lib/types/openingTimes.d.ts +19 -0
  441. package/lib/types/openingTimes.js +13 -0
  442. package/lib/types/openingTimes.js.map +1 -0
  443. package/lib/types/parser/prettier-parser-babel.d.js +2 -0
  444. package/lib/types/parser/prettier-parser-babel.d.js.map +1 -0
  445. package/lib/types/parser/prettier-parser-graphql.d.js +2 -0
  446. package/lib/types/parser/prettier-parser-graphql.d.js.map +1 -0
  447. package/lib/types/parser/prettier-parser-html.d.js +2 -0
  448. package/lib/types/parser/prettier-parser-html.d.js.map +1 -0
  449. package/lib/types/parser/prettier-parser-markdown.d.js +2 -0
  450. package/lib/types/parser/prettier-parser-markdown.d.js.map +1 -0
  451. package/lib/types/parser/prettier-parser-postcss.d.js +2 -0
  452. package/lib/types/parser/prettier-parser-postcss.d.js.map +1 -0
  453. package/lib/types/parser/prettier-parser-yaml.d.js +2 -0
  454. package/lib/types/parser/prettier-parser-yaml.d.js.map +1 -0
  455. package/lib/types/signature.d.ts +5 -0
  456. package/lib/types/signature.js +2 -0
  457. package/lib/types/signature.js.map +1 -0
  458. package/lib/types/slider-button.d.ts +4 -0
  459. package/lib/types/slider-button.js +2 -0
  460. package/lib/types/slider-button.js.map +1 -0
  461. package/lib/utils/calculate.d.ts +5 -0
  462. package/lib/utils/calculate.js +73 -0
  463. package/lib/utils/calculate.js.map +1 -0
  464. package/lib/utils/codeHighlighter.d.ts +4 -0
  465. package/lib/utils/codeHighlighter.js +361 -0
  466. package/lib/utils/codeHighlighter.js.map +1 -0
  467. package/lib/utils/file.d.ts +363 -0
  468. package/lib/utils/file.js +402 -0
  469. package/lib/utils/file.js.map +1 -0
  470. package/lib/utils/fileDialog.d.ts +7 -0
  471. package/lib/utils/fileDialog.js +73 -0
  472. package/lib/utils/fileDialog.js.map +1 -0
  473. package/lib/utils/isTobitEmployee.d.ts +1 -0
  474. package/lib/utils/isTobitEmployee.js +28 -0
  475. package/lib/utils/isTobitEmployee.js.map +1 -0
  476. package/lib/utils/slider.d.ts +7 -0
  477. package/lib/utils/slider.js +35 -0
  478. package/lib/utils/slider.js.map +1 -0
  479. package/lib/utils/sliderButton.d.ts +15 -0
  480. package/lib/utils/sliderButton.js +53 -0
  481. package/lib/utils/sliderButton.js.map +1 -0
  482. package/lib/utils/truncation.d.ts +1 -0
  483. package/lib/utils/truncation.js +34 -0
  484. package/lib/utils/truncation.js.map +1 -0
  485. package/lib/utils/uploadFile.d.ts +9 -0
  486. package/lib/utils/uploadFile.js +47 -0
  487. package/lib/utils/uploadFile.js.map +1 -0
  488. package/package.json +29 -21
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _Input = _interopRequireDefault(require("../input/Input"));
9
+ var _number = require("./constants/number");
10
+ var _number2 = require("./utils/number");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); }
13
+ 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; }
14
+ const NumberInput = _ref => {
15
+ let {
16
+ isDecimalInput,
17
+ isMoneyInput,
18
+ isTimeInput,
19
+ maxNumber = Infinity,
20
+ value,
21
+ placeholder,
22
+ onBlur,
23
+ isDisabled,
24
+ onChange,
25
+ minNumber = -Infinity
26
+ } = _ref;
27
+ // the plainText will be shown in the input, when it is in focus
28
+ const [plainText, setPlainText] = (0, _react.useState)('');
29
+ // the formattedValue will be shown in the input, when it is not in focus
30
+ const [formattedValue, setFormattedValue] = (0, _react.useState)('');
31
+ const [hasFocus, setHasFocus] = (0, _react.useState)(false);
32
+ const [isValueInvalid, setIsValueInvalid] = (0, _react.useState)(false);
33
+ const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);
34
+ const onLocalChange = event => {
35
+ const newValue = event.target.value;
36
+ if (newValue.replaceAll(':', '').length > 4) {
37
+ return;
38
+ }
39
+ const sanitizedValueString = newValue
40
+ // Removes everything except numbers, commas and points
41
+ .replace(_number.NUMBER_CLEAR_REGEX, '');
42
+ const valueToCheck = sanitizedValueString.replaceAll(',', '.');
43
+ if (!(0, _number2.isValidString)({
44
+ string: valueToCheck,
45
+ isMoneyInput,
46
+ isDecimalInput,
47
+ isTimeInput
48
+ })) {
49
+ return;
50
+ }
51
+ setPlainText(sanitizedValueString.replaceAll('.', ','));
52
+ if (typeof onChange === 'function') {
53
+ onChange(sanitizedValueString.replaceAll('.', ','));
54
+ }
55
+ };
56
+ const onLocalBlur = () => {
57
+ const sanitizedValue = plainText.length === 0 ? '0' : plainText;
58
+ let isInvalid = false;
59
+ const parsedNumber = (0, _number2.parseFloatWithDecimals)({
60
+ stringValue: sanitizedValue.replace(',', '.').replaceAll(':', ''),
61
+ decimals: isMoneyInput ? 2 : undefined
62
+ });
63
+ if (parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {
64
+ isInvalid = true;
65
+ }
66
+ setIsValueInvalid(isInvalid);
67
+ const newStringValue = plainText.length === 0 ? '' : (0, _number2.formateNumber)({
68
+ number: parsedNumber,
69
+ isMoneyInput,
70
+ isTimeInput
71
+ });
72
+ setFormattedValue(newStringValue);
73
+ setPlainText(newStringValue.replaceAll('.', ''));
74
+ setHasFocus(false);
75
+ if (typeof onChange === 'function') {
76
+ onChange(newStringValue.replaceAll('.', ''));
77
+ }
78
+ if (typeof onBlur === 'function') {
79
+ onBlur(parsedNumber === 0 ? null : parsedNumber, isInvalid);
80
+ }
81
+ };
82
+ const onLocalFocus = () => {
83
+ // formattedValue will be a number string with german number format (e.g. 1.000,00)
84
+ // It will remove all dots, so that the user can type in the number
85
+ setPlainText(formattedValue.replaceAll('.', ''));
86
+
87
+ // This will update the external state
88
+ if (typeof onChange === 'function') {
89
+ onChange(formattedValue.replaceAll('.', ''));
90
+ }
91
+ setIsValueInvalid(false);
92
+ setHasFocus(true);
93
+ };
94
+
95
+ // updates the formattedValue, when the value changes
96
+ (0, _react.useEffect)(() => {
97
+ const parsedNumber = (0, _number2.parseFloatWithDecimals)({
98
+ stringValue: plainText.replace(',', '.').replaceAll(':', ''),
99
+ decimals: isMoneyInput ? 2 : undefined
100
+ });
101
+
102
+ // checks, if a given number is invalid, if the input is not in focus
103
+ if (!hasFocus) {
104
+ setIsValueInvalid(parsedNumber > maxNumber || parsedNumber < minNumber);
105
+ }
106
+ setFormattedValue(plainText.length === 0 ? '' : (0, _number2.formateNumber)({
107
+ number: parsedNumber,
108
+ isMoneyInput,
109
+ isTimeInput
110
+ }));
111
+ }, [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText]);
112
+ (0, _react.useEffect)(() => {
113
+ if (typeof value === 'string') {
114
+ setPlainText(value);
115
+ }
116
+ }, [value]);
117
+ return /*#__PURE__*/_react.default.createElement(_Input.default, {
118
+ inputMode: "decimal",
119
+ onChange: onLocalChange,
120
+ value: hasFocus ? plainText : formattedValue,
121
+ placeholder: localPlaceholder,
122
+ onBlur: onLocalBlur,
123
+ onFocus: onLocalFocus,
124
+ isDisabled: isDisabled,
125
+ isInvalid: isValueInvalid
126
+ });
127
+ };
128
+ NumberInput.displayName = 'NumberInput';
129
+ var _default = exports.default = NumberInput;
130
+ //# sourceMappingURL=NumberInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberInput.js","names":["_react","_interopRequireWildcard","require","_Input","_interopRequireDefault","_number","_number2","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","NumberInput","_ref","isDecimalInput","isMoneyInput","isTimeInput","maxNumber","Infinity","value","placeholder","onBlur","isDisabled","onChange","minNumber","plainText","setPlainText","useState","formattedValue","setFormattedValue","hasFocus","setHasFocus","isValueInvalid","setIsValueInvalid","localPlaceholder","undefined","onLocalChange","event","newValue","target","replaceAll","length","sanitizedValueString","replace","NUMBER_CLEAR_REGEX","valueToCheck","isValidString","string","onLocalBlur","sanitizedValue","isInvalid","parsedNumber","parseFloatWithDecimals","stringValue","decimals","newStringValue","formateNumber","number","onLocalFocus","useEffect","createElement","inputMode","onFocus","displayName","_default","exports"],"sources":["../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import React, { ChangeEventHandler, FC, useEffect, useState } from 'react';\nimport Input from '../input/Input';\nimport { NUMBER_CLEAR_REGEX } from './constants/number';\nimport { formateNumber, isValidString, parseFloatWithDecimals } from './utils/number';\n\nexport type NumberInputProps = {\n /**\n * Applies rules for decimal input.\n * Enables the user to input one zero as number before the comma\n */\n isDecimalInput?: boolean;\n /**\n * Whether the input is disabled\n */\n isDisabled?: boolean;\n /**\n * Applies rules for money input.\n * Rules: only two decimal places, one zero before the comma\n */\n isMoneyInput?: boolean;\n /**\n * Whether the value should be formatted as a time.\n */\n isTimeInput?: boolean;\n /**\n * Limits the number to this value\n */\n maxNumber?: number;\n /**\n * Limits the number to this value\n */\n minNumber?: number;\n /**\n * Callback function that is called when the input gets out of focus\n */\n onBlur?: (newNumber: number | null, isInvalid: boolean) => void;\n /**\n * Callback function that is called when the input changes\n * It will pass the text from the input\n */\n onChange?: (newValue: string) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * The value, that should be displayed in the input, when it is in focus.\n * You can also pass a stringified number as default value.\n * NOTE: If you pass a stringified number, it will be formatted to the selected format\n */\n value?: string;\n};\n\nconst NumberInput: FC<NumberInputProps> = ({\n isDecimalInput,\n isMoneyInput,\n isTimeInput,\n maxNumber = Infinity,\n value,\n placeholder,\n onBlur,\n isDisabled,\n onChange,\n minNumber = -Infinity,\n}) => {\n // the plainText will be shown in the input, when it is in focus\n const [plainText, setPlainText] = useState<string>('');\n // the formattedValue will be shown in the input, when it is not in focus\n const [formattedValue, setFormattedValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n\n const [isValueInvalid, setIsValueInvalid] = useState(false);\n const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);\n\n const onLocalChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const newValue = event.target.value;\n\n if (newValue.replaceAll(':', '').length > 4) {\n return;\n }\n\n const sanitizedValueString = newValue\n // Removes everything except numbers, commas and points\n .replace(NUMBER_CLEAR_REGEX, '');\n\n const valueToCheck = sanitizedValueString.replaceAll(',', '.');\n\n if (!isValidString({ string: valueToCheck, isMoneyInput, isDecimalInput, isTimeInput })) {\n return;\n }\n\n setPlainText(sanitizedValueString.replaceAll('.', ','));\n\n if (typeof onChange === 'function') {\n onChange(sanitizedValueString.replaceAll('.', ','));\n }\n };\n\n const onLocalBlur = () => {\n const sanitizedValue = plainText.length === 0 ? '0' : plainText;\n let isInvalid = false;\n\n const parsedNumber = parseFloatWithDecimals({\n stringValue: sanitizedValue.replace(',', '.').replaceAll(':', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n if (parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {\n isInvalid = true;\n }\n\n setIsValueInvalid(isInvalid);\n\n const newStringValue =\n plainText.length === 0\n ? ''\n : formateNumber({\n number: parsedNumber,\n isMoneyInput,\n isTimeInput,\n });\n\n setFormattedValue(newStringValue);\n setPlainText(newStringValue.replaceAll('.', ''));\n setHasFocus(false);\n\n if (typeof onChange === 'function') {\n onChange(newStringValue.replaceAll('.', ''));\n }\n\n if (typeof onBlur === 'function') {\n onBlur(parsedNumber === 0 ? null : parsedNumber, isInvalid);\n }\n };\n\n const onLocalFocus = () => {\n // formattedValue will be a number string with german number format (e.g. 1.000,00)\n // It will remove all dots, so that the user can type in the number\n setPlainText(formattedValue.replaceAll('.', ''));\n\n // This will update the external state\n if (typeof onChange === 'function') {\n onChange(formattedValue.replaceAll('.', ''));\n }\n\n setIsValueInvalid(false);\n setHasFocus(true);\n };\n\n // updates the formattedValue, when the value changes\n useEffect(() => {\n const parsedNumber = parseFloatWithDecimals({\n stringValue: plainText.replace(',', '.').replaceAll(':', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n // checks, if a given number is invalid, if the input is not in focus\n if (!hasFocus) {\n setIsValueInvalid(parsedNumber > maxNumber || parsedNumber < minNumber);\n }\n\n setFormattedValue(\n plainText.length === 0\n ? ''\n : formateNumber({\n number: parsedNumber,\n isMoneyInput,\n isTimeInput,\n }),\n );\n }, [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText]);\n\n useEffect(() => {\n if (typeof value === 'string') {\n setPlainText(value);\n }\n }, [value]);\n\n return (\n <Input\n inputMode=\"decimal\"\n onChange={onLocalChange}\n value={hasFocus ? plainText : formattedValue}\n placeholder={localPlaceholder}\n onBlur={onLocalBlur}\n onFocus={onLocalFocus}\n isDisabled={isDisabled}\n isInvalid={isValueInvalid}\n />\n );\n};\n\nNumberInput.displayName = 'NumberInput';\n\nexport default NumberInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAsF,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC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cAAe;IAC7CR,WAAW,EAAEc,gBAAiB;IAC9Bb,MAAM,EAAE2B,WAAY;IACpBc,OAAO,EAAEJ,YAAa;IACtBpC,UAAU,EAAEA,UAAW;IACvB4B,SAAS,EAAElB;EAAe,CAC7B,CAAC;AAEV,CAAC;AAEDpB,WAAW,CAACmD,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzE,OAAA,GAEzBoB,WAAW"}
@@ -0,0 +1,5 @@
1
+ export declare const NUMBER_CLEAR_REGEX: RegExp;
2
+ export declare const INTEGER_TEST: RegExp;
3
+ export declare const DECIMAL_TEST: RegExp;
4
+ export declare const MONEY_TEST: RegExp;
5
+ export declare const TIME_TEST: RegExp;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TIME_TEST = exports.NUMBER_CLEAR_REGEX = exports.MONEY_TEST = exports.INTEGER_TEST = exports.DECIMAL_TEST = void 0;
7
+ const NUMBER_CLEAR_REGEX = exports.NUMBER_CLEAR_REGEX = /[^\d,.:]/gi;
8
+ const INTEGER_TEST = exports.INTEGER_TEST = /^[1-9][0-9]*$/;
9
+ const DECIMAL_TEST = exports.DECIMAL_TEST = /^(0|[1-9][0-9]*)?(\.[0-9]*)?$/;
10
+ const MONEY_TEST = exports.MONEY_TEST = /^(0|[1-9][0-9]*)?(\.[0-9]{0,2})?$/;
11
+ const TIME_TEST = exports.TIME_TEST = /^\d{1,2}(:\d{1,2})?$/;
12
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","names":["NUMBER_CLEAR_REGEX","exports","INTEGER_TEST","DECIMAL_TEST","MONEY_TEST","TIME_TEST"],"sources":["../../../../src/components/number-input/constants/number.ts"],"sourcesContent":["export const NUMBER_CLEAR_REGEX = /[^\\d,.:]/gi;\nexport const INTEGER_TEST = /^[1-9][0-9]*$/;\nexport const DECIMAL_TEST = /^(0|[1-9][0-9]*)?(\\.[0-9]*)?$/;\nexport const MONEY_TEST = /^(0|[1-9][0-9]*)?(\\.[0-9]{0,2})?$/;\nexport const TIME_TEST = /^\\d{1,2}(:\\d{1,2})?$/;\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,YAAY;AACvC,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG,eAAe;AACpC,MAAMC,YAAY,GAAAF,OAAA,CAAAE,YAAA,GAAG,+BAA+B;AACpD,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAG,mCAAmC;AACtD,MAAMC,SAAS,GAAAJ,OAAA,CAAAI,SAAA,GAAG,sBAAsB"}
@@ -0,0 +1,23 @@
1
+ interface ParseFloatWithDecimals {
2
+ ({ stringValue, decimals }: {
3
+ stringValue: string;
4
+ decimals?: number;
5
+ }): number;
6
+ }
7
+ export declare const parseFloatWithDecimals: ParseFloatWithDecimals;
8
+ interface FormateNumberOptions {
9
+ number: number | null;
10
+ isMoneyInput?: boolean;
11
+ isTimeInput?: boolean;
12
+ }
13
+ export declare const formateNumber: ({ number, isMoneyInput, isTimeInput }: FormateNumberOptions) => string;
14
+ interface IsValidString {
15
+ (config: {
16
+ string: string;
17
+ isDecimalInput?: boolean;
18
+ isMoneyInput?: boolean;
19
+ isTimeInput?: boolean;
20
+ }): boolean;
21
+ }
22
+ export declare const isValidString: IsValidString;
23
+ export {};
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseFloatWithDecimals = exports.isValidString = exports.formateNumber = void 0;
7
+ var _number = require("../constants/number");
8
+ const parseFloatWithDecimals = _ref => {
9
+ let {
10
+ stringValue,
11
+ decimals
12
+ } = _ref;
13
+ const parsed = parseFloat(stringValue);
14
+ if (decimals) {
15
+ return parseFloat(parsed.toFixed(decimals));
16
+ }
17
+ return parsed;
18
+ };
19
+ exports.parseFloatWithDecimals = parseFloatWithDecimals;
20
+ const formateNumber = _ref2 => {
21
+ let {
22
+ number,
23
+ isMoneyInput,
24
+ isTimeInput
25
+ } = _ref2;
26
+ if (typeof number !== 'number') {
27
+ return '';
28
+ }
29
+ if (isTimeInput) {
30
+ let hours = 0;
31
+ let minutes = 0;
32
+ const firstTwoNumbers = Number(String(number).substring(0, 2));
33
+ const lastTwoNumbers = Number(String(number).substring(2, 4));
34
+ hours = firstTwoNumbers > 23 ? 23 : firstTwoNumbers;
35
+ if (lastTwoNumbers < 7) {
36
+ minutes = lastTwoNumbers * 10;
37
+ } else {
38
+ minutes = lastTwoNumbers > 59 ? 59 : lastTwoNumbers;
39
+ }
40
+ const hoursStr = hours < 10 ? `0${hours}` : `${hours}`;
41
+ const minutesStr = minutes < 10 ? `0${minutes}` : `${minutes}`;
42
+ return `${hoursStr}:${minutesStr}`;
43
+ }
44
+ return number.toLocaleString('de-DE', {
45
+ useGrouping: true,
46
+ minimumFractionDigits: isMoneyInput ? 2 : undefined,
47
+ maximumFractionDigits: isMoneyInput ? 2 : undefined,
48
+ maximumSignificantDigits: !isMoneyInput ? 20 : undefined
49
+ });
50
+ };
51
+ exports.formateNumber = formateNumber;
52
+ const isValidString = _ref3 => {
53
+ let {
54
+ isDecimalInput,
55
+ isMoneyInput,
56
+ isTimeInput,
57
+ string
58
+ } = _ref3;
59
+ let isValid = false;
60
+
61
+ // Allows numbers, one (comma/point) and any number of decimal places
62
+ if (isDecimalInput && _number.DECIMAL_TEST.test(string)) {
63
+ isValid = true;
64
+ }
65
+
66
+ // Allows numbers but excludes numbers with leading 0
67
+ if (isMoneyInput && _number.MONEY_TEST.test(string)) {
68
+ isValid = true;
69
+ }
70
+ if (isTimeInput && _number.TIME_TEST) {
71
+ isValid = true;
72
+ }
73
+
74
+ // Allows numbers but excludes numbers with leading 0
75
+ if (!isDecimalInput && !isMoneyInput && !isTimeInput && _number.INTEGER_TEST.test(string)) {
76
+ isValid = true;
77
+ }
78
+ if (string.length === 0) {
79
+ isValid = true;
80
+ }
81
+ return isValid;
82
+ };
83
+ exports.isValidString = isValidString;
84
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","names":["_number","require","parseFloatWithDecimals","_ref","stringValue","decimals","parsed","parseFloat","toFixed","exports","formateNumber","_ref2","number","isMoneyInput","isTimeInput","hours","minutes","firstTwoNumbers","Number","String","substring","lastTwoNumbers","hoursStr","minutesStr","toLocaleString","useGrouping","minimumFractionDigits","undefined","maximumFractionDigits","maximumSignificantDigits","isValidString","_ref3","isDecimalInput","string","isValid","DECIMAL_TEST","test","MONEY_TEST","TIME_TEST","INTEGER_TEST","length"],"sources":["../../../../src/components/number-input/utils/number.ts"],"sourcesContent":["import { DECIMAL_TEST, INTEGER_TEST, MONEY_TEST, TIME_TEST } from '../constants/number';\n\ninterface ParseFloatWithDecimals {\n ({ stringValue, decimals }: { stringValue: string; decimals?: number }): number;\n}\n\nexport const parseFloatWithDecimals: ParseFloatWithDecimals = ({ stringValue, decimals }) => {\n const parsed = parseFloat(stringValue);\n\n if (decimals) {\n return parseFloat(parsed.toFixed(decimals));\n }\n\n return parsed;\n};\n\ninterface FormateNumberOptions {\n number: number | null;\n isMoneyInput?: boolean;\n isTimeInput?: boolean;\n}\n\nexport const formateNumber = ({ number, isMoneyInput, isTimeInput }: FormateNumberOptions) => {\n if (typeof number !== 'number') {\n return '';\n }\n\n if (isTimeInput) {\n let hours = 0;\n let minutes = 0;\n\n const firstTwoNumbers = Number(String(number).substring(0, 2));\n const lastTwoNumbers = Number(String(number).substring(2, 4));\n\n hours = firstTwoNumbers > 23 ? 23 : firstTwoNumbers;\n if (lastTwoNumbers < 7) {\n minutes = lastTwoNumbers * 10;\n } else {\n minutes = lastTwoNumbers > 59 ? 59 : lastTwoNumbers;\n }\n\n const hoursStr = hours < 10 ? `0${hours}` : `${hours}`;\n const minutesStr = minutes < 10 ? `0${minutes}` : `${minutes}`;\n\n return `${hoursStr}:${minutesStr}`;\n }\n\n return number.toLocaleString('de-DE', {\n useGrouping: true,\n minimumFractionDigits: isMoneyInput ? 2 : undefined,\n maximumFractionDigits: isMoneyInput ? 2 : undefined,\n maximumSignificantDigits: !isMoneyInput ? 20 : undefined,\n });\n};\n\ninterface IsValidString {\n (config: {\n string: string;\n isDecimalInput?: boolean;\n isMoneyInput?: boolean;\n isTimeInput?: boolean;\n }): boolean;\n}\n\nexport const isValidString: IsValidString = ({\n isDecimalInput,\n isMoneyInput,\n isTimeInput,\n string,\n}) => {\n let isValid = false;\n\n // Allows numbers, one (comma/point) and any number of decimal places\n if (isDecimalInput && DECIMAL_TEST.test(string)) {\n isValid = true;\n }\n\n // Allows numbers but excludes numbers with leading 0\n if (isMoneyInput && MONEY_TEST.test(string)) {\n isValid = true;\n }\n\n if (isTimeInput && TIME_TEST) {\n isValid = true;\n }\n\n // Allows numbers but excludes numbers with leading 0\n if (!isDecimalInput && !isMoneyInput && !isTimeInput && INTEGER_TEST.test(string)) {\n isValid = true;\n }\n\n if (string.length === 0) {\n isValid = true;\n }\n\n return isValid;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAMO,MAAMC,sBAA8C,GAAGC,IAAA,IAA+B;EAAA,IAA9B;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAAF,IAAA;EACpF,MAAMG,MAAM,GAAGC,UAAU,CAACH,WAAW,CAAC;EAEtC,IAAIC,QAAQ,EAAE;IACV,OAAOE,UAAU,CAACD,MAAM,CAACE,OAAO,CAACH,QAAQ,CAAC,CAAC;EAC/C;EAEA,OAAOC,MAAM;AACjB,CAAC;AAACG,OAAA,CAAAP,sBAAA,GAAAA,sBAAA;AAQK,MAAMQ,aAAa,GAAGC,KAAA,IAAiE;EAAA,IAAhE;IAAEC,MAAM;IAAEC,YAAY;IAAEC;EAAkC,CAAC,GAAAH,KAAA;EACrF,IAAI,OAAOC,MAAM,KAAK,QAAQ,EAAE;IAC5B,OAAO,EA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IG,OAAO,GAAG,KAAK;;EAEnB;EACA,IAAIF,cAAc,IAAIG,oBAAY,CAACC,IAAI,CAACH,MAAM,CAAC,EAAE;IAC7CC,OAAO,GAAG,IAAI;EAClB;;EAEA;EACA,IAAIrB,YAAY,IAAIwB,kBAAU,CAACD,IAAI,CAACH,MAAM,CAAC,EAAE;IACzCC,OAAO,GAAG,IAAI;EAClB;EAEA,IAAIpB,WAAW,IAAIwB,iBAAS,EAAE;IAC1BJ,OAAO,GAAG,IAAI;EAClB;;EAEA;EACA,IAAI,CAACF,cAAc,IAAI,CAACnB,YAAY,IAAI,CAACC,WAAW,IAAIyB,oBAAY,CAACH,IAAI,CAACH,MAAM,CAAC,EAAE;IAC/EC,OAAO,GAAG,IAAI;EAClB;EAEA,IAAID,MAAM,CAACO,MAAM,KAAK,CAAC,EAAE;IACrBN,OAAO,GAAG,IAAI;EAClB;EAEA,OAAOA,OAAO;AAClB,CAAC;AAACzB,OAAA,CAAAqB,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,19 @@
1
+ import { FC } from 'react';
2
+ import type { OpeningTime, Weekday } from '../../types/openingTimes';
3
+ export type OpeningTimesProps = {
4
+ /**
5
+ * Function to be executed when a time is changed.
6
+ * @param openingTimes
7
+ */
8
+ onChange?: (openingTimes: OpeningTime[]) => void;
9
+ /**
10
+ * The opening times corresponding to its weekday.
11
+ */
12
+ openingTimes: OpeningTime[];
13
+ /**
14
+ * The weekdays that should be displayed.
15
+ */
16
+ weekdays: Weekday[];
17
+ };
18
+ declare const OpeningTimes: FC<OpeningTimesProps>;
19
+ export default OpeningTimes;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _OpeningTimes = require("./OpeningTimes.styles");
9
+ var _Checkbox = _interopRequireDefault(require("../checkbox/Checkbox"));
10
+ var _OpeningInputs = _interopRequireDefault(require("./opening-inputs/OpeningInputs"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); }
13
+ 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; }
14
+ const OpeningTimes = _ref => {
15
+ let {
16
+ openingTimes,
17
+ weekdays,
18
+ onChange
19
+ } = _ref;
20
+ const [newOpeningTimes, setNewOpeningTimes] = (0, _react.useState)();
21
+ (0, _react.useEffect)(() => {
22
+ setNewOpeningTimes(openingTimes);
23
+ }, [openingTimes]);
24
+ (0, _react.useEffect)(() => {
25
+ if (newOpeningTimes && typeof onChange === 'function') {
26
+ onChange(newOpeningTimes);
27
+ }
28
+ }, [newOpeningTimes, onChange]);
29
+ const handleCheckBoxChange = id => {
30
+ setNewOpeningTimes(prevOpeningTimes => (prevOpeningTimes ?? []).map(openingTime => {
31
+ if (openingTime.id === id) {
32
+ return {
33
+ ...openingTime,
34
+ isDisabled: !openingTime.isDisabled
35
+ };
36
+ }
37
+ return openingTime;
38
+ }));
39
+ };
40
+ const content = (0, _react.useMemo)(() => {
41
+ const items = [];
42
+ if (!newOpeningTimes) {
43
+ return items;
44
+ }
45
+ newOpeningTimes.forEach(_ref2 => {
46
+ let {
47
+ times,
48
+ id,
49
+ weekdayId,
50
+ isDisabled
51
+ } = _ref2;
52
+ const weekday = weekdays.find(weekDay => weekDay.id === weekdayId)?.name;
53
+ if (!weekday) {
54
+ return;
55
+ }
56
+ items.push( /*#__PURE__*/_react.default.createElement(_OpeningTimes.StyledOpeningTimesWrapper, {
57
+ key: `openingTimes__${id}`
58
+ }, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
59
+ isChecked: !isDisabled,
60
+ onChange: () => handleCheckBoxChange(id)
61
+ }, weekday), /*#__PURE__*/_react.default.createElement(_OpeningInputs.default, {
62
+ times: times,
63
+ isDisabled: isDisabled,
64
+ onChange: () => {}
65
+ })));
66
+ });
67
+ return items;
68
+ }, [newOpeningTimes, weekdays]);
69
+ return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_OpeningTimes.StyledOpeningTimes, null, content), [content]);
70
+ };
71
+ OpeningTimes.displayName = 'OpeningTimes';
72
+ var _default = exports.default = OpeningTimes;
73
+ //# sourceMappingURL=OpeningTimes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpeningTimes.js","names":["_react","_interopRequireWildcard","require","_OpeningTimes","_Checkbox","_interopRequireDefault","_OpeningInputs","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","OpeningTimes","_ref","openingTimes","weekdays","onChange","newOpeningTimes","setNewOpeningTimes","useState","useEffect","handleCheckBoxChange","id","prevOpeningTimes","map","openingTime","isDisabled","content","useMemo","items","forEach","_ref2","times","weekdayId","weekday","find","weekDay","name","push","createElement","StyledOpeningTimesWrapper","key","isChecked","StyledOpeningTimes","displayName","_default","exports"],"sources":["../../../src/components/opening-times/OpeningTimes.tsx"],"sourcesContent":["import React, { FC, type ReactElement, useEffect, useMemo, useState } from 'react';\nimport { StyledOpeningTimes, StyledOpeningTimesWrapper } from './OpeningTimes.styles';\nimport type { OpeningTime, Weekday } from '../../types/openingTimes';\nimport Checkbox from '../checkbox/Checkbox';\nimport OpeningInputs from './opening-inputs/OpeningInputs';\n\nexport type OpeningTimesProps = {\n /**\n * Function to be executed when a time is changed.\n * @param openingTimes\n */\n onChange?: (openingTimes: OpeningTime[]) => void;\n /**\n * The opening times corresponding to its weekday.\n */\n openingTimes: OpeningTime[];\n /**\n * The weekdays that should be displayed.\n */\n weekdays: Weekday[];\n};\n\nconst OpeningTimes: FC<OpeningTimesProps> = ({ openingTimes, weekdays, onChange }) => {\n const [newOpeningTimes, setNewOpeningTimes] = useState<OpeningTime[]>();\n\n useEffect(() => {\n setNewOpeningTimes(openingTimes);\n }, [openingTimes]);\n\n useEffect(() => {\n if (newOpeningTimes && typeof onChange === 'function') {\n onChange(newOpeningTimes);\n }\n }, [newOpeningTimes, onChange]);\n\n const handleCheckBoxChange = (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, isDisabled: !openingTime.isDisabled };\n }\n return openingTime;\n }),\n );\n };\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!newOpeningTimes) {\n return items;\n }\n\n newOpeningTimes.forEach(({ times, id, weekdayId, isDisabled }) => {\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n if (!weekday) {\n return;\n }\n\n items.push(\n <StyledOpeningTimesWrapper key={`openingTimes__${id}`}>\n <Checkbox isChecked={!isDisabled} onChange={() => handleCheckBoxChange(id)}>\n {weekday}\n </Checkbox>\n <OpeningInputs times={times} isDisabled={isDisabled} onChange={() => {}} />\n </StyledOpeningTimesWrapper>,\n );\n });\n\n return items;\n }, [newOpeningTimes, weekdays]);\n\n return useMemo(() => <StyledOpeningTimes>{content}</StyledOpeningTimes>, [content]);\n};\n\nOpeningTimes.displayName = 'OpeningTimes';\n\nexport default OpeningTimes;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA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I;MAE1E,IAAI,CAACH,OAAO,EAAE;QACV;MACJ;MAEAL,KAAK,CAACS,IAAI,eACNvD,MAAA,CAAAS,OAAA,CAAA+C,aAAA,CAACrD,aAAA,CAAAsD,yBAAyB;QAACC,GAAG,EAAG,iBAAgBnB,EAAG;MAAE,gBAClDvC,MAAA,CAAAS,OAAA,CAAA+C,aAAA,CAACpD,SAAA,CAAAK,OAAQ;QAACkD,SAAS,EAAE,CAAChB,UAAW;QAACV,QAAQ,EAAEA,CAAA,KAAMK,oBAAoB,CAACC,EAAE;MAAE,GACtEY,OACK,CAAC,eACXnD,MAAA,CAAAS,OAAA,CAAA+C,aAAA,CAAClD,cAAA,CAAAG,OAAa;QAACwC,KAAK,EAAEA,KAAM;QAACN,UAAU,EAAEA,UAAW;QAACV,QAAQ,EAAEA,CAAA,KAAM,CAAC;MAAE,CAAE,CACnD,CAC/B,CAAC;IACL,CAAC,CAAC;IAEF,OAAOa,KAAK;EAChB,CAAC,EAAE,CAACZ,eAAe,EAAEF,QAAQ,CAAC,CAAC;EAE/B,OAAO,IAAAa,cAAO,EAAC,mBAAM7C,MAAA,CAAAS,OAAA,CAAA+C,aAAA,CAACrD,aAAA,CAAAyD,kBAAkB,QAAEhB,OAA4B,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;AACvF,CAAC;AAEDf,YAAY,CAACgC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtD,OAAA,GAE3BoB,YAAY"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
3
+ type StyledSliderButtonProps = WithTheme<{
4
+ isDisabled?: boolean;
5
+ }>;
6
+ export declare const StyledOpeningTimes: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledSliderButtonProps>>;
7
+ export declare const StyledOpeningTimesWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
8
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledOpeningTimesWrapper = exports.StyledOpeningTimes = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const StyledOpeningTimes = exports.StyledOpeningTimes = _styledComponents.default.div`
10
+ display: flex;
11
+ flex-direction: column;
12
+ gap: 8px;
13
+ `;
14
+ const StyledOpeningTimesWrapper = exports.StyledOpeningTimesWrapper = _styledComponents.default.div`
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: space-between;
18
+ `;
19
+ //# sourceMappingURL=OpeningTimes.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpeningTimes.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledOpeningTimes","exports","styled","div","StyledOpeningTimesWrapper"],"sources":["../../../src/components/opening-times/OpeningTimes.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledSliderButtonProps = WithTheme<{ isDisabled?: boolean }>;\n\nexport const StyledOpeningTimes = styled.div<StyledSliderButtonProps>`\n display: flex;\n flex-direction: column;\n gap: 8px;\n`;\n\nexport const StyledOpeningTimesWrapper = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAKhC,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,yBAAM,CAACC,GAA6B;AACtE;AACA;AACA;AACA,CAAC;AAEM,MAAMC,yBAAyB,GAAAH,OAAA,CAAAG,yBAAA,GAAGF,yBAAM,CAACC,GAAI;AACpD;AACA;AACA;AACA,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { type Time } from '../../../types/openingTimes';
3
+ export type OpeningInputsProps = {
4
+ times: Time[];
5
+ isDisabled?: boolean;
6
+ onChange: (times: Time[]) => void;
7
+ };
8
+ declare const OpeningInputs: FC<OpeningInputsProps>;
9
+ export default OpeningInputs;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _openingTimes = require("../../../types/openingTimes");
9
+ var _OpeningInputs = require("./OpeningInputs.styles");
10
+ var _OpeningInput = _interopRequireDefault(require("./opening-input/OpeningInput"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); }
13
+ 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; }
14
+ const OpeningInputs = _ref => {
15
+ let {
16
+ times,
17
+ isDisabled,
18
+ onChange
19
+ } = _ref;
20
+ const [newTimes, setNewTimes] = (0, _react.useState)();
21
+ (0, _react.useEffect)(() => {
22
+ setNewTimes(times);
23
+ }, [times]);
24
+ (0, _react.useEffect)(() => {}, []);
25
+ const handleAdd = () => {
26
+ const defaultTime = {
27
+ start: '00:00',
28
+ end: '00:00'
29
+ };
30
+ setNewTimes(prevState =>
31
+ // onChange();
32
+
33
+ prevState ? [...prevState, defaultTime] : [defaultTime]);
34
+ };
35
+ const handleRemove = indexToRemove => {
36
+ setNewTimes(prevState => (prevState ?? []).filter((_, index) => index !== indexToRemove));
37
+ };
38
+ const handleChange = (newTime, indexToUpdate) => {
39
+ setNewTimes(prevState => (prevState ?? []).map((time, index) => {
40
+ if (index === indexToUpdate) {
41
+ return newTime;
42
+ }
43
+ return time;
44
+ }));
45
+ };
46
+ const content = (0, _react.useMemo)(() => {
47
+ const items = [];
48
+ if (!newTimes) {
49
+ return items;
50
+ }
51
+ newTimes.forEach((_ref2, index) => {
52
+ let {
53
+ end,
54
+ start
55
+ } = _ref2;
56
+ if (index > 1) {
57
+ return;
58
+ }
59
+ let buttonType = _openingTimes.OpeningTimesButtonType.NONE;
60
+ if (index === 0 && times.length === 1) {
61
+ buttonType = _openingTimes.OpeningTimesButtonType.ADD;
62
+ } else if (index === 1) {
63
+ buttonType = _openingTimes.OpeningTimesButtonType.REMOVE;
64
+ }
65
+ items.push( /*#__PURE__*/_react.default.createElement(_OpeningInput.default, {
66
+ start: start,
67
+ end: end,
68
+ isDisabled: isDisabled,
69
+ buttonType: buttonType,
70
+ onAdd: handleAdd,
71
+ onChange: time => handleChange(time, index),
72
+ onRemove: () => handleRemove(index)
73
+ }));
74
+ });
75
+ return items;
76
+ }, [isDisabled, newTimes, times.length]);
77
+ return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_OpeningInputs.StyledOpeningInputs, null, content), [content]);
78
+ };
79
+ OpeningInputs.displayName = 'OpeningInputs';
80
+ var _default = exports.default = OpeningInputs;
81
+ //# sourceMappingURL=OpeningInputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpeningInputs.js","names":["_react","_interopRequireWildcard","require","_openingTimes","_OpeningInputs","_OpeningInput","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","OpeningInputs","_ref","times","isDisabled","onChange","newTimes","setNewTimes","useState","useEffect","handleAdd","defaultTime","start","end","prevState","handleRemove","indexToRemove","filter","_","index","handleChange","newTime","indexToUpdate","map","time","content","useMemo","items","forEach","_ref2","buttonType","OpeningTimesButtonType","NONE","length","ADD","REMOVE","push","createElement","onAdd","onRemove","StyledOpeningInputs","displayName","_default","exports"],"sources":["../../../../src/components/opening-times/opening-inputs/OpeningInputs.tsx"],"sourcesContent":["import React, { FC, type ReactElement, useEffect, useMemo, useState } from 'react';\nimport { OpeningTimesButtonType, type Time } from '../../../types/openingTimes';\nimport { StyledOpeningInputs } from './OpeningInputs.styles';\nimport OpeningInput from './opening-input/OpeningInput';\n\nexport type OpeningInputsProps = {\n times: Time[];\n isDisabled?: boolean;\n onChange: (times: Time[]) => void;\n};\n\nconst OpeningInputs: FC<OpeningInputsProps> = ({ times, isDisabled, onChange }) => {\n const [newTimes, setNewTimes] = useState<Time[]>();\n\n useEffect(() => {\n setNewTimes(times);\n }, [times]);\n\n useEffect(() => {}, []);\n\n const handleAdd = () => {\n const defaultTime: Time = { start: '00:00', end: '00:00' };\n\n setNewTimes((prevState) =>\n // onChange();\n\n prevState ? [...prevState, defaultTime] : [defaultTime],\n );\n };\n\n const handleRemove = (indexToRemove: number) => {\n setNewTimes((prevState) => (prevState ?? []).filter((_, index) => index !== indexToRemove));\n };\n\n const handleChange = (newTime: Time, indexToUpdate: number) => {\n setNewTimes((prevState) =>\n (prevState ?? []).map((time, index) => {\n if (index === indexToUpdate) {\n return newTime;\n }\n return time;\n }),\n );\n };\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!newTimes) {\n return items;\n }\n\n newTimes.forEach(({ end, start }, index) => {\n if (index > 1) {\n return;\n }\n\n let buttonType = OpeningTimesButtonType.NONE;\n\n if (index === 0 && times.length === 1) {\n buttonType = OpeningTimesButtonType.ADD;\n } else if (index === 1) {\n buttonType = OpeningTimesButtonType.REMOVE;\n }\n\n items.push(\n <OpeningInput\n start={start}\n end={end}\n isDisabled={isDisabled}\n buttonType={buttonType}\n onAdd={handleAdd}\n onChange={(time) => handleChange(time, index)}\n onRemove={() => handleRemove(index)}\n />,\n );\n });\n\n return items;\n }, [isDisabled, newTimes, times.length]);\n\n return useMemo(() => <StyledOpeningInputs>{content}</StyledOpeningInputs>, [content]);\n};\n\nOpeningInputs.displayName = 'OpeningInputs';\n\nexport default OpeningInputs;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAwD,SAAAI,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,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,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CAAA,OAAAM,CA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W;QACvBQ,KAAK,EAAE5B,SAAU;QACjBL,QAAQ,EAAGmB,IAAI,IAAKJ,YAAY,CAACI,IAAI,EAAEL,KAAK,CAAE;QAC9CoB,QAAQ,EAAEA,CAAA,KAAMxB,YAAY,CAACI,KAAK;MAAE,CACvC,CACL,CAAC;IACL,CAAC,CAAC;IAEF,OAAOQ,KAAK;EAChB,CAAC,EAAE,CAACvB,UAAU,EAAEE,QAAQ,EAAEH,KAAK,CAAC8B,MAAM,CAAC,CAAC;EAExC,OAAO,IAAAP,cAAO,EAAC,mBAAMtD,MAAA,CAAAS,OAAA,CAAAwD,aAAA,CAAC7D,cAAA,CAAAgE,mBAAmB,QAAEf,OAA6B,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;AACzF,CAAC;AAEDxB,aAAa,CAACwC,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA9D,OAAA,GAE7BoB,aAAa"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledOpeningInputs: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledOpeningInputs = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const StyledOpeningInputs = exports.StyledOpeningInputs = _styledComponents.default.div`
10
+ display: flex;
11
+ flex-direction: column;
12
+ `;
13
+ //# sourceMappingURL=OpeningInputs.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpeningInputs.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledOpeningInputs","exports","styled","div"],"sources":["../../../../src/components/opening-times/opening-inputs/OpeningInputs.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledOpeningInputs = styled.div`\n display: flex;\n flex-direction: column;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGE,yBAAM,CAACC,GAAI;AAC9C;AACA;AACA,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { FC } from 'react';
2
+ import { OpeningTimesButtonType, type Time } from '../../../../types/openingTimes';
3
+ export type OpeningInputProps = {
4
+ start: Time['start'];
5
+ end: Time['end'];
6
+ isDisabled?: boolean;
7
+ buttonType: OpeningTimesButtonType;
8
+ onAdd: () => void;
9
+ onRemove: () => void;
10
+ onChange: (time: Time) => void;
11
+ };
12
+ declare const OpeningInput: FC<OpeningInputProps>;
13
+ export default OpeningInput;