loon-bulma-react 2025.0.34 → 2025.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (468) hide show
  1. package/.github/workflows/deploy-example.yml +43 -0
  2. package/.github/workflows/run-test.yml +31 -0
  3. package/.prettierignore +5 -0
  4. package/.prettierrc.json +19 -0
  5. package/dist/classes/Console.d.ts +29 -0
  6. package/dist/classes/FetchWrapper.d.ts +124 -0
  7. package/dist/components/AspectRatio/AspectRatio.d.ts +28 -0
  8. package/dist/components/Block/Block.d.ts +9 -0
  9. package/dist/components/Box/BorderBox.d.ts +29 -0
  10. package/dist/components/Box/Box.d.ts +20 -0
  11. package/dist/components/Button/Button.d.ts +84 -0
  12. package/dist/components/ButtonGroup/ButtonGroup.d.ts +26 -0
  13. package/dist/components/Calendar/CalendarItems/CalendarColoredItem.d.ts +18 -0
  14. package/dist/components/Calendar/CalendarItems/CalendarItem.d.ts +18 -0
  15. package/dist/components/Calendar/DayContainer.d.ts +25 -0
  16. package/dist/components/Calendar/EventDescriptions.d.ts +33 -0
  17. package/dist/components/Calendar/Fourweeks/FourweeksView.d.ts +23 -0
  18. package/dist/components/Calendar/Mini/MiniView.d.ts +24 -0
  19. package/dist/components/Calendar/Month/MonthView.d.ts +23 -0
  20. package/dist/components/Calendar/Planning/PlanningView.d.ts +42 -0
  21. package/dist/components/Calendar/Props.d.ts +58 -0
  22. package/dist/components/Calendar/Week/AlldayContainer.d.ts +19 -0
  23. package/dist/components/Calendar/Week/HourRow.d.ts +30 -0
  24. package/dist/components/Calendar/Week/WeekView.d.ts +24 -0
  25. package/dist/components/Calendar/calendar.functions.d.ts +10 -0
  26. package/dist/components/Calendar/index.d.ts +15 -0
  27. package/dist/components/CodeBlock/CodeBlock.d.ts +49 -0
  28. package/dist/components/Columns/Column.d.ts +207 -0
  29. package/dist/components/Columns/Columns.d.ts +35 -0
  30. package/dist/components/Container/Container.d.ts +44 -0
  31. package/dist/components/Content/Content.d.ts +22 -0
  32. package/dist/components/DataTable/DataTable.d.ts +187 -0
  33. package/dist/components/Divider/Divider.d.ts +8 -0
  34. package/dist/components/Dropdown/Dropdown.d.ts +25 -0
  35. package/dist/components/Footer/Footer.d.ts +22 -0
  36. package/dist/components/Help/Help.d.ts +19 -0
  37. package/dist/components/Hero/Hero.d.ts +104 -0
  38. package/dist/components/Icon/Icon.d.ts +82 -0
  39. package/dist/components/Image/Image.d.ts +28 -0
  40. package/dist/components/Indicator/Indicator.d.ts +25 -0
  41. package/dist/components/Kbd/Kbd.d.ts +30 -0
  42. package/dist/components/Label/Label.d.ts +11 -0
  43. package/dist/components/Link/Link.d.ts +44 -0
  44. package/dist/components/Menu/Menu.d.ts +64 -0
  45. package/dist/components/Message/Message.d.ts +49 -0
  46. package/dist/components/Modal/Modal.d.ts +74 -0
  47. package/dist/components/Notification/Notification.d.ts +38 -0
  48. package/dist/components/Pagination/Pagination.d.ts +56 -0
  49. package/dist/components/Panel/Panel.d.ts +98 -0
  50. package/dist/components/ProgressBar/ProgressBar.d.ts +28 -0
  51. package/dist/components/QuickView/QuickView.d.ts +61 -0
  52. package/dist/components/ScrollArea/ScrollArea.d.ts +76 -0
  53. package/dist/components/Section/Section.d.ts +21 -0
  54. package/dist/components/SimpleTable/SimpleTable.d.ts +121 -0
  55. package/dist/components/Steps/Steps.d.ts +61 -0
  56. package/dist/components/TabBar/TabBar.d.ts +47 -0
  57. package/dist/components/Tag/Tag.d.ts +54 -0
  58. package/dist/components/TimeLine/TimeLine.d.ts +62 -0
  59. package/dist/components/Titles/Titles.d.ts +71 -0
  60. package/dist/components/ToggleBar/ToggleBar.d.ts +80 -0
  61. package/dist/components/Tooltip/Tooltip.d.ts +49 -0
  62. package/dist/components/TreeView/TreeView.d.ts +48 -0
  63. package/dist/contexts/ActionSheet/ActionSheetContextProvider.d.ts +76 -0
  64. package/dist/contexts/AppProvider/AppProviders.d.ts +18 -0
  65. package/dist/contexts/ColorSchemeProvider/ColorSchemeProvider.d.ts +15 -0
  66. package/dist/contexts/Confirm/ConfirmContextProvider.d.ts +60 -0
  67. package/dist/contexts/DefaultsProvider/DefaultsProvider.d.ts +94 -0
  68. package/dist/contexts/DialogsProvider/DialogsProvider.d.ts +4 -0
  69. package/dist/contexts/KeysProvider/KeysProvider.d.ts +35 -0
  70. package/dist/contexts/ModalProvider/ModalProvider.d.ts +11 -0
  71. package/dist/contexts/ModeProvider/ModeProvider.d.ts +14 -0
  72. package/dist/contexts/Notifier/Notifier.d.ts +81 -0
  73. package/dist/contexts/Prompt/PromptContextProvider.d.ts +71 -0
  74. package/dist/forms/Checkbox/Checkbox.d.ts +47 -0
  75. package/dist/forms/ComboBox/ComboBox.d.ts +44 -0
  76. package/dist/forms/ComboBox/MultiComboBox.d.ts +44 -0
  77. package/dist/forms/ComboBox/useComboBoxScroll.d.ts +4 -0
  78. package/dist/forms/Currency/CurrencyInput.d.ts +47 -0
  79. package/dist/forms/Datetimes/DateInput.d.ts +37 -0
  80. package/dist/forms/Datetimes/DateTimeInput.d.ts +44 -0
  81. package/dist/forms/Datetimes/TimeInput.d.ts +42 -0
  82. package/dist/forms/File/FileInput.d.ts +71 -0
  83. package/dist/forms/Input.d.ts +223 -0
  84. package/dist/forms/MaskedInput/MaskedInput.d.ts +46 -0
  85. package/dist/forms/Numeric/NumberInput.d.ts +14 -0
  86. package/dist/forms/Numeric/RangeInput.d.ts +21 -0
  87. package/dist/forms/Others/ColorInput.d.ts +56 -0
  88. package/dist/forms/Others/HiddenInput.d.ts +29 -0
  89. package/dist/forms/Others/TelephoneInput.d.ts +14 -0
  90. package/dist/forms/Others/URLInput.d.ts +14 -0
  91. package/dist/forms/Periodes/MonthInput.d.ts +43 -0
  92. package/dist/forms/Periodes/WeekInput.d.ts +43 -0
  93. package/dist/forms/Radio/Radio.d.ts +97 -0
  94. package/dist/forms/Select/Select.d.ts +132 -0
  95. package/dist/forms/TagsInput/TagsInput.d.ts +44 -0
  96. package/dist/forms/Text/EmailInput.d.ts +14 -0
  97. package/dist/forms/Text/FormattedInput.d.ts +54 -0
  98. package/dist/forms/Text/PasswordInput.d.ts +19 -0
  99. package/dist/forms/Text/TextArea.d.ts +31 -0
  100. package/dist/forms/Text/TextEditor.d.ts +36 -0
  101. package/dist/forms/Text/TextInput.d.ts +30 -0
  102. package/dist/hooks/useCaretPosition.d.ts +8 -0
  103. package/dist/hooks/useClickOutside.d.ts +15 -0
  104. package/dist/hooks/useClipboard.d.ts +21 -0
  105. package/dist/hooks/useContextMenu.d.ts +29 -0
  106. package/dist/hooks/useCookieState.d.ts +37 -0
  107. package/dist/hooks/useDebounced.hooks.d.ts +55 -0
  108. package/dist/hooks/useFetchApi.d.ts +65 -0
  109. package/dist/hooks/useHotkeys.d.ts +44 -0
  110. package/dist/hooks/useIndexedDb.d.ts +89 -0
  111. package/dist/hooks/useLocalStoredState.d.ts +36 -0
  112. package/dist/hooks/usePagination.d.ts +25 -0
  113. package/dist/hooks/usePropState.d.ts +16 -0
  114. package/dist/hooks/useScrollIntoView.d.ts +59 -0
  115. package/dist/hooks/useSessionStoredState.d.ts +38 -0
  116. package/dist/hooks/useToggle.d.ts +16 -0
  117. package/dist/hooks/useUncontrolled.d.ts +44 -0
  118. package/dist/hooks/useValidatedState.d.ts +21 -0
  119. package/dist/index.d.ts +169 -5773
  120. package/dist/index.js +37319 -55
  121. package/dist/internal_functions/createIconsInternal.d.ts +17 -0
  122. package/dist/internal_functions/getAlignmentClass.d.ts +16 -0
  123. package/dist/internal_functions/getColorClass.d.ts +23 -0
  124. package/dist/internal_functions/getPositionClass.d.ts +2 -0
  125. package/dist/internal_functions/getSizeClass.d.ts +23 -0
  126. package/dist/internal_functions/index.d.ts +8 -0
  127. package/{styles → dist/styles}/_all.scss +3 -1
  128. package/dist/styles/tooltip.scss +32 -0
  129. package/dist/test-data.d.ts +9 -0
  130. package/dist/types/index.d.ts +111 -0
  131. package/dist/utils/JSDateTime.class.d.ts +510 -0
  132. package/dist/utils/JSDuration.class.d.ts +79 -0
  133. package/dist/utils/calculateTxtColor.function.d.ts +14 -0
  134. package/dist/utils/colors.d.ts +26 -0
  135. package/dist/utils/colorscheme.d.ts +5 -0
  136. package/dist/utils/compare.d.ts +7 -0
  137. package/dist/utils/deserialize.function.d.ts +2 -0
  138. package/dist/utils/hasBSN.function.d.ts +27 -0
  139. package/dist/utils/isIBAN.function.d.ts +24 -0
  140. package/dist/utils/math.d.ts +22 -0
  141. package/dist/utils/operators.d.ts +192 -0
  142. package/dist/utils/serialize.function.d.ts +2 -0
  143. package/dist/utils/sorting.d.ts +34 -0
  144. package/dist/utils/string.utils.d.ts +72 -0
  145. package/eslint.config.js +108 -0
  146. package/index.html +16 -0
  147. package/jest.config.ts +12 -0
  148. package/lib/classes/Console.ts +78 -0
  149. package/lib/classes/FetchWrapper.ts +392 -0
  150. package/lib/components/AspectRatio/AspectRatio.test.tsx +67 -0
  151. package/lib/components/AspectRatio/AspectRatio.tsx +40 -0
  152. package/lib/components/Block/Block.test.tsx +24 -0
  153. package/lib/components/Block/Block.tsx +13 -0
  154. package/lib/components/Box/BorderBox.test.tsx +24 -0
  155. package/lib/components/Box/BorderBox.tsx +79 -0
  156. package/lib/components/Box/Box.test.tsx +24 -0
  157. package/lib/components/Box/Box.tsx +30 -0
  158. package/lib/components/Button/Button.test.tsx +871 -0
  159. package/lib/components/Button/Button.tsx +217 -0
  160. package/lib/components/ButtonGroup/ButtonGroup.test.tsx +115 -0
  161. package/lib/components/ButtonGroup/ButtonGroup.tsx +130 -0
  162. package/lib/components/Calendar/CalendarItems/CalendarColoredItem.tsx +63 -0
  163. package/lib/components/Calendar/CalendarItems/CalendarItem.tsx +49 -0
  164. package/lib/components/Calendar/DayContainer.tsx +115 -0
  165. package/lib/components/Calendar/EventDescriptions.tsx +131 -0
  166. package/lib/components/Calendar/Fourweeks/FourweeksView.test.tsx +262 -0
  167. package/lib/components/Calendar/Fourweeks/FourweeksView.tsx +169 -0
  168. package/lib/components/Calendar/Mini/MiniView.tsx +127 -0
  169. package/lib/components/Calendar/Month/MonthView.test.tsx +266 -0
  170. package/lib/components/Calendar/Month/MonthView.tsx +178 -0
  171. package/lib/components/Calendar/Planning/PlanningView.tsx +195 -0
  172. package/lib/components/Calendar/Props.tsx +64 -0
  173. package/lib/components/Calendar/Week/AlldayContainer.tsx +38 -0
  174. package/lib/components/Calendar/Week/HourRow.tsx +159 -0
  175. package/lib/components/Calendar/Week/WeekView.test.tsx +291 -0
  176. package/lib/components/Calendar/Week/WeekView.tsx +176 -0
  177. package/lib/components/Calendar/calendar.functions.ts +32 -0
  178. package/lib/components/Calendar/index.ts +17 -0
  179. package/lib/components/CodeBlock/CodeBlock.tsx +128 -0
  180. package/lib/components/Columns/Column.test.tsx +145 -0
  181. package/lib/components/Columns/Column.tsx +316 -0
  182. package/lib/components/Columns/Columns.test.tsx +95 -0
  183. package/lib/components/Columns/Columns.tsx +62 -0
  184. package/lib/components/Container/Container.test.tsx +87 -0
  185. package/lib/components/Container/Container.tsx +140 -0
  186. package/lib/components/Content/Content.test.tsx +51 -0
  187. package/lib/components/Content/Content.tsx +31 -0
  188. package/lib/components/DataTable/DataTable.test.tsx +403 -0
  189. package/lib/components/DataTable/DataTable.tsx +726 -0
  190. package/lib/components/Divider/Divider.tsx +18 -0
  191. package/lib/components/Dropdown/Dropdown.tsx +112 -0
  192. package/lib/components/Footer/Footer.test.tsx +42 -0
  193. package/lib/components/Footer/Footer.tsx +34 -0
  194. package/lib/components/Help/Help.test.tsx +83 -0
  195. package/lib/components/Help/Help.tsx +25 -0
  196. package/lib/components/Hero/Hero.test.tsx +222 -0
  197. package/lib/components/Hero/Hero.tsx +214 -0
  198. package/lib/components/Icon/Icon.test.tsx +157 -0
  199. package/lib/components/Icon/Icon.tsx +192 -0
  200. package/lib/components/Image/Image.test.tsx +72 -0
  201. package/lib/components/Image/Image.tsx +60 -0
  202. package/lib/components/Indicator/Indicator.test.tsx +68 -0
  203. package/lib/components/Indicator/Indicator.tsx +46 -0
  204. package/lib/components/Kbd/Kbd.test.tsx +49 -0
  205. package/lib/components/Kbd/Kbd.tsx +51 -0
  206. package/lib/components/Label/Label.tsx +21 -0
  207. package/lib/components/Link/Link.test.tsx +84 -0
  208. package/lib/components/Link/Link.tsx +87 -0
  209. package/lib/components/Menu/Menu.test.tsx +154 -0
  210. package/lib/components/Menu/Menu.tsx +264 -0
  211. package/lib/components/Message/Message.test.tsx +112 -0
  212. package/lib/components/Message/Message.tsx +154 -0
  213. package/lib/components/Modal/Modal.test.tsx +188 -0
  214. package/lib/components/Modal/Modal.tsx +188 -0
  215. package/lib/components/Notification/Notification.test.tsx +175 -0
  216. package/lib/components/Notification/Notification.tsx +110 -0
  217. package/lib/components/Pagination/Pagination.tsx +143 -0
  218. package/lib/components/Panel/Panel.tsx +225 -0
  219. package/lib/components/ProgressBar/ProgressBar.test.tsx +92 -0
  220. package/lib/components/ProgressBar/ProgressBar.tsx +42 -0
  221. package/lib/components/QuickView/QuickView.test.tsx +81 -0
  222. package/lib/components/QuickView/QuickView.tsx +122 -0
  223. package/lib/components/ScrollArea/ScrollArea.test.tsx +682 -0
  224. package/lib/components/ScrollArea/ScrollArea.tsx +183 -0
  225. package/lib/components/Section/Section.test.tsx +24 -0
  226. package/lib/components/Section/Section.tsx +32 -0
  227. package/lib/components/SimpleTable/SimpleTable.test.tsx +135 -0
  228. package/lib/components/SimpleTable/SimpleTable.tsx +327 -0
  229. package/lib/components/Steps/Steps.test.tsx +356 -0
  230. package/lib/components/Steps/Steps.tsx +164 -0
  231. package/lib/components/TabBar/TabBar.test.tsx +134 -0
  232. package/lib/components/TabBar/TabBar.tsx +125 -0
  233. package/lib/components/Tag/Tag.test.tsx +184 -0
  234. package/lib/components/Tag/Tag.tsx +131 -0
  235. package/lib/components/TimeLine/TimeLine.test.tsx +149 -0
  236. package/lib/components/TimeLine/TimeLine.tsx +116 -0
  237. package/lib/components/Titles/Titles.test.tsx +53 -0
  238. package/lib/components/Titles/Titles.tsx +205 -0
  239. package/lib/components/ToggleBar/ToggleBar.test.tsx +228 -0
  240. package/lib/components/ToggleBar/ToggleBar.tsx +208 -0
  241. package/lib/components/Tooltip/Tooltip.test.tsx +61 -0
  242. package/lib/components/Tooltip/Tooltip.tsx +203 -0
  243. package/lib/components/TreeView/TreeView.tsx +233 -0
  244. package/lib/contexts/ActionSheet/ActionSheetContextProvider.test.tsx +24 -0
  245. package/lib/contexts/ActionSheet/ActionSheetContextProvider.tsx +237 -0
  246. package/lib/contexts/AppProvider/AppProviders.tsx +56 -0
  247. package/lib/contexts/ColorSchemeProvider/ColorSchemeProvider.tsx +49 -0
  248. package/lib/contexts/Confirm/ConfirmContextProvider.test.tsx +24 -0
  249. package/lib/contexts/Confirm/ConfirmContextProvider.tsx +227 -0
  250. package/lib/contexts/DefaultsProvider/DefaultsProvider.tsx +178 -0
  251. package/lib/contexts/DialogsProvider/DialogsProvider.tsx +14 -0
  252. package/lib/contexts/KeysProvider/KeysProvider.tsx +344 -0
  253. package/lib/contexts/ModalProvider/ModalProvider.tsx +59 -0
  254. package/lib/contexts/ModeProvider/ModeProvider.tsx +26 -0
  255. package/lib/contexts/Notifier/Notifier.test.tsx +342 -0
  256. package/lib/contexts/Notifier/Notifier.tsx +209 -0
  257. package/lib/contexts/Prompt/PromptContextProvider.test.tsx +24 -0
  258. package/lib/contexts/Prompt/PromptContextProvider.tsx +280 -0
  259. package/lib/forms/Checkbox/Checkbox.test.tsx +171 -0
  260. package/lib/forms/Checkbox/Checkbox.tsx +256 -0
  261. package/lib/forms/ComboBox/ComboBox.test.tsx +24 -0
  262. package/lib/forms/ComboBox/ComboBox.tsx +464 -0
  263. package/lib/forms/ComboBox/MultiComboBox.test.tsx +30 -0
  264. package/lib/forms/ComboBox/MultiComboBox.tsx +282 -0
  265. package/lib/forms/ComboBox/useComboBoxScroll.test.ts +30 -0
  266. package/lib/forms/ComboBox/useComboBoxScroll.ts +35 -0
  267. package/lib/forms/Currency/CurrencyInput.test.tsx +131 -0
  268. package/lib/forms/Currency/CurrencyInput.tsx +269 -0
  269. package/lib/forms/Datetimes/DateInput.test.tsx +198 -0
  270. package/lib/forms/Datetimes/DateInput.tsx +56 -0
  271. package/lib/forms/Datetimes/DateTimeInput.test.tsx +223 -0
  272. package/lib/forms/Datetimes/DateTimeInput.tsx +102 -0
  273. package/lib/forms/Datetimes/TimeInput.test.tsx +218 -0
  274. package/lib/forms/Datetimes/TimeInput.tsx +100 -0
  275. package/lib/forms/File/FileInput.test.tsx +175 -0
  276. package/lib/forms/File/FileInput.tsx +240 -0
  277. package/lib/forms/Input.test.tsx +158 -0
  278. package/lib/forms/Input.tsx +542 -0
  279. package/lib/forms/MaskedInput/MaskedInput.tsx +651 -0
  280. package/lib/forms/Numeric/NumberInput.test.tsx +233 -0
  281. package/lib/forms/Numeric/NumberInput.tsx +171 -0
  282. package/lib/forms/Numeric/RangeInput.test.tsx +187 -0
  283. package/lib/forms/Numeric/RangeInput.tsx +166 -0
  284. package/lib/forms/Others/ColorInput.test.tsx +181 -0
  285. package/lib/forms/Others/ColorInput.tsx +117 -0
  286. package/lib/forms/Others/HiddenInput.test.tsx +25 -0
  287. package/lib/forms/Others/HiddenInput.tsx +46 -0
  288. package/lib/forms/Others/TelephoneInput.test.tsx +153 -0
  289. package/lib/forms/Others/TelephoneInput.tsx +26 -0
  290. package/lib/forms/Others/URLInput.test.tsx +153 -0
  291. package/lib/forms/Others/URLInput.tsx +30 -0
  292. package/lib/forms/Periodes/MonthInput.test.tsx +119 -0
  293. package/lib/forms/Periodes/MonthInput.tsx +63 -0
  294. package/lib/forms/Periodes/WeekInput.test.tsx +119 -0
  295. package/lib/forms/Periodes/WeekInput.tsx +63 -0
  296. package/lib/forms/Radio/Radio.test.tsx +322 -0
  297. package/lib/forms/Radio/Radio.tsx +347 -0
  298. package/lib/forms/Select/Select.test.tsx +223 -0
  299. package/lib/forms/Select/Select.tsx +405 -0
  300. package/lib/forms/TagsInput/TagsInput.test.tsx +27 -0
  301. package/lib/forms/TagsInput/TagsInput.tsx +289 -0
  302. package/lib/forms/Text/EmailInput.test.tsx +153 -0
  303. package/lib/forms/Text/EmailInput.tsx +29 -0
  304. package/lib/forms/Text/FormattedInput.tsx +271 -0
  305. package/lib/forms/Text/PasswordInput.test.tsx +160 -0
  306. package/lib/forms/Text/PasswordInput.tsx +154 -0
  307. package/lib/forms/Text/TextArea.test.tsx +164 -0
  308. package/lib/forms/Text/TextArea.tsx +169 -0
  309. package/lib/forms/Text/TextEditor.test.tsx +12 -0
  310. package/lib/forms/Text/TextEditor.tsx +612 -0
  311. package/lib/forms/Text/TextInput.test.tsx +147 -0
  312. package/lib/forms/Text/TextInput.tsx +60 -0
  313. package/lib/hooks/useCaretPosition.test.tsx +31 -0
  314. package/lib/hooks/useCaretPosition.tsx +23 -0
  315. package/lib/hooks/useClickOutside.test.tsx +101 -0
  316. package/lib/hooks/useClickOutside.ts +44 -0
  317. package/lib/hooks/useClipboard.ts +59 -0
  318. package/lib/hooks/useContextMenu.tsx +74 -0
  319. package/lib/hooks/useCookieState.tsx +117 -0
  320. package/lib/hooks/useDebounced.hooks.test.ts +70 -0
  321. package/lib/hooks/useDebounced.hooks.ts +110 -0
  322. package/lib/hooks/useFetchApi.ts +91 -0
  323. package/lib/hooks/useHotkeys.test.tsx +111 -0
  324. package/lib/hooks/useHotkeys.ts +139 -0
  325. package/lib/hooks/useIndexedDb.tsx +337 -0
  326. package/lib/hooks/useLocalStoredState.test.tsx +98 -0
  327. package/lib/hooks/useLocalStoredState.ts +86 -0
  328. package/lib/hooks/usePagination.test.ts +113 -0
  329. package/lib/hooks/usePagination.ts +96 -0
  330. package/lib/hooks/usePropState.ts +25 -0
  331. package/lib/hooks/useScrollIntoView.ts +250 -0
  332. package/lib/hooks/useSessionStoredState.ts +87 -0
  333. package/lib/hooks/useToggle.test.tsx +52 -0
  334. package/lib/hooks/useToggle.ts +30 -0
  335. package/lib/hooks/useUncontrolled.test.ts +52 -0
  336. package/lib/hooks/useUncontrolled.ts +65 -0
  337. package/lib/hooks/useValidatedState.test.tsx +37 -0
  338. package/lib/hooks/useValidatedState.ts +37 -0
  339. package/lib/index.ts +246 -0
  340. package/lib/internal_functions/createIconsInternal.tsx +94 -0
  341. package/lib/internal_functions/getAlignmentClass.ts +37 -0
  342. package/lib/internal_functions/getColorClass.ts +73 -0
  343. package/lib/internal_functions/getPositionClass.ts +15 -0
  344. package/lib/internal_functions/getSizeClass.ts +57 -0
  345. package/lib/internal_functions/index.ts +9 -0
  346. package/lib/styles/_all.scss +457 -0
  347. package/lib/styles/bulma-box.scss +135 -0
  348. package/lib/styles/button.scss +565 -0
  349. package/lib/styles/buttons.scss +19 -0
  350. package/lib/styles/calendar.scss +148 -0
  351. package/lib/styles/checkradio.scss +662 -0
  352. package/lib/styles/datalist.scss +27 -0
  353. package/lib/styles/divider.scss +30 -0
  354. package/lib/styles/dropdown.scss +175 -0
  355. package/lib/styles/extra-inputs.scss +77 -0
  356. package/lib/styles/hero.scss +285 -0
  357. package/lib/styles/indicators.scss +142 -0
  358. package/lib/styles/keyboard.scss +15 -0
  359. package/lib/styles/linkbutton.scss +40 -0
  360. package/lib/styles/menu.scss +164 -0
  361. package/lib/styles/mini-calendar.scss +70 -0
  362. package/lib/styles/notifier-container.scss +27 -0
  363. package/lib/styles/panel.scss +222 -0
  364. package/lib/styles/quickview.scss +140 -0
  365. package/lib/styles/range-sliders.scss +298 -0
  366. package/lib/styles/select.scss +144 -0
  367. package/lib/styles/steps.scss +288 -0
  368. package/lib/styles/table.scss +330 -0
  369. package/lib/styles/tabs.scss +271 -0
  370. package/lib/styles/timeline.scss +314 -0
  371. package/lib/styles/tooltip.scss +32 -0
  372. package/lib/styles/treeview.scss +37 -0
  373. package/lib/test-data.ts +9002 -0
  374. package/lib/types/index.tsx +180 -0
  375. package/lib/types/react-app-env.d.ts +1 -0
  376. package/lib/types/typings.d.ts +373 -0
  377. package/lib/utils/JSDateTime.class.test.ts +890 -0
  378. package/lib/utils/JSDateTime.class.ts +766 -0
  379. package/lib/utils/JSDuration.class.test.ts +98 -0
  380. package/lib/utils/JSDuration.class.ts +159 -0
  381. package/lib/utils/calculateTxtColor.function.test.ts +53 -0
  382. package/lib/utils/calculateTxtColor.function.ts +56 -0
  383. package/lib/utils/colors.test.ts +78 -0
  384. package/lib/utils/colors.ts +178 -0
  385. package/lib/utils/colorscheme.ts +26 -0
  386. package/lib/utils/compare.test.ts +137 -0
  387. package/lib/utils/compare.ts +32 -0
  388. package/lib/utils/deserialize.function.test.ts +15 -0
  389. package/lib/utils/deserialize.function.ts +9 -0
  390. package/lib/utils/hasBSN.function.test.ts +27 -0
  391. package/lib/utils/hasBSN.function.ts +53 -0
  392. package/lib/utils/isIBAN.function.test.ts +25 -0
  393. package/lib/utils/isIBAN.function.ts +131 -0
  394. package/lib/utils/math.test.ts +70 -0
  395. package/lib/utils/math.ts +32 -0
  396. package/lib/utils/operators.test.ts +619 -0
  397. package/lib/utils/operators.ts +242 -0
  398. package/lib/utils/serialize.function.test.ts +13 -0
  399. package/lib/utils/serialize.function.ts +9 -0
  400. package/lib/utils/sorting.test.ts +114 -0
  401. package/lib/utils/sorting.ts +50 -0
  402. package/lib/utils/string.utils.test.ts +85 -0
  403. package/lib/utils/string.utils.ts +146 -0
  404. package/lib/vite-env.d.ts +1 -0
  405. package/package.json +55 -83
  406. package/public/vite.svg +1 -0
  407. package/src/App.tsx +77 -0
  408. package/src/AppHero.tsx +102 -0
  409. package/src/Console.ts +28 -0
  410. package/src/MOCK_DATA.ts +10014 -0
  411. package/src/Tabs/AspectRatioTab.tsx +235 -0
  412. package/src/Tabs/ButtonsAndTags.tsx +843 -0
  413. package/src/Tabs/CalendarTab.tsx +560 -0
  414. package/src/Tabs/ContextsTab.tsx +820 -0
  415. package/src/Tabs/DataTableTab.tsx +291 -0
  416. package/src/Tabs/FunctionsTab.tsx +947 -0
  417. package/src/Tabs/HooksTab.tsx +1008 -0
  418. package/src/Tabs/InputsTab.tsx +2319 -0
  419. package/src/Tabs/LayoutsTab.tsx +751 -0
  420. package/src/Tabs/Nieuw.tsx +440 -0
  421. package/src/Tabs/NotificationTab.tsx +301 -0
  422. package/src/Tabs/OverigeTab.tsx +1631 -0
  423. package/src/Tabs/ReadmeTab.tsx +260 -0
  424. package/src/Tabs/TestTab.tsx +44 -0
  425. package/src/Tabs/datatable.css +7 -0
  426. package/src/Tabs/index.ts +14 -0
  427. package/src/assets/react.svg +1 -0
  428. package/src/components/Chevrons.tsx +15 -0
  429. package/src/components/CodeVoorbeeld.tsx +41 -0
  430. package/src/components/Nieuwsblok.tsx +22 -0
  431. package/src/main.tsx +10 -0
  432. package/src/styles/example-styles.scss +8 -0
  433. package/src/styles.css +14244 -0
  434. package/src/styles.css.map +1 -0
  435. package/src/vite-env.d.ts +1 -0
  436. package/tsconfig.app.json +32 -0
  437. package/tsconfig.build.json +132 -0
  438. package/tsconfig.json +11 -0
  439. package/tsconfig.node.json +30 -0
  440. package/vite.config.ts +52 -0
  441. package/dist/index.cjs +0 -283
  442. package/dist/index.d.cts +0 -5773
  443. package/styles/tooltip.scss +0 -201
  444. /package/{styles → dist/styles}/bulma-box.scss +0 -0
  445. /package/{styles → dist/styles}/button.scss +0 -0
  446. /package/{styles → dist/styles}/buttons.scss +0 -0
  447. /package/{styles → dist/styles}/calendar.scss +0 -0
  448. /package/{styles → dist/styles}/checkradio.scss +0 -0
  449. /package/{styles → dist/styles}/datalist.scss +0 -0
  450. /package/{styles → dist/styles}/divider.scss +0 -0
  451. /package/{styles → dist/styles}/dropdown.scss +0 -0
  452. /package/{styles → dist/styles}/extra-inputs.scss +0 -0
  453. /package/{styles → dist/styles}/hero.scss +0 -0
  454. /package/{styles → dist/styles}/indicators.scss +0 -0
  455. /package/{styles → dist/styles}/keyboard.scss +0 -0
  456. /package/{styles → dist/styles}/linkbutton.scss +0 -0
  457. /package/{styles → dist/styles}/menu.scss +0 -0
  458. /package/{styles → dist/styles}/mini-calendar.scss +0 -0
  459. /package/{styles → dist/styles}/notifier-container.scss +0 -0
  460. /package/{styles → dist/styles}/panel.scss +0 -0
  461. /package/{styles → dist/styles}/quickview.scss +0 -0
  462. /package/{styles → dist/styles}/range-sliders.scss +0 -0
  463. /package/{styles → dist/styles}/select.scss +0 -0
  464. /package/{styles → dist/styles}/steps.scss +0 -0
  465. /package/{styles → dist/styles}/table.scss +0 -0
  466. /package/{styles → dist/styles}/tabs.scss +0 -0
  467. /package/{styles → dist/styles}/timeline.scss +0 -0
  468. /package/{styles → dist/styles}/treeview.scss +0 -0
@@ -0,0 +1,143 @@
1
+ import { faBackwardFast, faBackwardStep, faForwardStep, faForwardFast } from '@fortawesome/free-solid-svg-icons';
2
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
+ import { getSizeClass } from '@lib/internal_functions';
4
+ import { SizeProp } from '@lib/types';
5
+
6
+ type PaginationProps = {
7
+ /** current selected page number */ currentPage: number;
8
+ /** range to render bijvoorbeeld van de `usePagination()`-hook. Bestaat uit numbers en `'dots'` op de plekken waar puntjes moeten komen
9
+ * @example const range = [1, 'dots', 6, 7, 8, 'dots', 100] */
10
+ range: Array<number | 'dots'>;
11
+ /** grootte van de pagination buttons (default = `s`) */
12
+ size?: SizeProp;
13
+ /** verberg de `vorige-pagina`-button (default = `false)` */
14
+ hidePrev?: boolean;
15
+ /** verberg de `volgende-pagina`-button (default = `false)` */
16
+ hideNext?: boolean;
17
+ /** verberg de `eerste pagina`-button (default = `false)` */
18
+ hideFirst?: boolean;
19
+ /** verberg de `laatste-pagina`-button (default = `false)` */
20
+ hideLast?: boolean;
21
+ /** verberg de `1, 2, 3,`-buttons (default = `false)` */
22
+ hideNumbers?: boolean;
23
+
24
+ /** function om de pagina te setten */
25
+ set?: (page: number) => void;
26
+ /** function om de currentPage op de eerste pagina te setten */
27
+ first?: () => void;
28
+ /** function om de currentPage op de laatste pagina te setten */
29
+ last?: () => void;
30
+ /** function om de currentPage op vorige pagina te setten */
31
+ prev?: () => void;
32
+ /** function om de currentPage op volgende pagina te setten */
33
+ next?: () => void;
34
+ };
35
+
36
+ /**
37
+ * Pagination component voor gebruik met de `usePagination()`-hook.
38
+ * @example
39
+ * const data: Data[] = createArrayWithRandomDataOfLength(1000);
40
+ * const maxRows = 20;
41
+ * const { range, active, next, prev, first, last, setPage } = usePagination({
42
+ * total: Math.ceil(data.length / maxRows),
43
+ * });
44
+ *
45
+ * return <Pagination range={range} currentPage={currentPage} next={next} prev={prev} first={first} last={last} set={set} />
46
+ * @param range - array met de pagina-nummers die getoond moeten worden OF `'dots'` waar de puntjes moeten komen
47
+ * @param currentPage - huidige pagina
48
+ * @param size - grootte van de pagination
49
+ * @param hidePrev - verberg de vorige-pagina knop
50
+ * @param hideNext - verberg de volgende-pagina knop
51
+ * @param hideFirst - verberg de eerste-pagina knop
52
+ * @param hideLast - verberg de laatste-pagina knop
53
+ * @param hideNumbers - verberg de pagina-nummers
54
+ * @param set - functie die wordt aangeroepen als er op een pagina-nummer wordt geklikt
55
+ * @param first - functie die wordt aangeroepen als er op de eerste-pagina knop wordt geklikt
56
+ * @param last - functie die wordt aangeroepen als er op de laatste-pagina knop wordt geklikt
57
+ * @param prev - functie die wordt aangeroepen als er op de vorige-pagina knop wordt geklikt
58
+ * @param next - functie die wordt aangeroepen als er op de volgende-pagina knop wordt geklikt
59
+ */
60
+ function Pagination({
61
+ range,
62
+ currentPage,
63
+ size = 's',
64
+ hideFirst = false,
65
+ hideLast = false,
66
+ hidePrev = false,
67
+ hideNext = false,
68
+ hideNumbers = false,
69
+ set = (x: number) => {},
70
+ first = () => {},
71
+ last = () => {},
72
+ prev = () => {},
73
+ next = () => {},
74
+ }: PaginationProps) {
75
+ let className = `pagination ${getSizeClass(size, true)}`;
76
+
77
+ return (
78
+ <div className={className}>
79
+ <ul className="pagination-list">
80
+ {!hideFirst && (
81
+ <li>
82
+ <button className="pagination-link" aria-label="eerste pagina" onClick={first} disabled={currentPage === range[0]}>
83
+ <FontAwesomeIcon icon={faBackwardFast} />
84
+ </button>
85
+ </li>
86
+ )}
87
+
88
+ {!hidePrev && (
89
+ <li>
90
+ <button className="pagination-link" aria-label="vorige pagina" onClick={prev} disabled={currentPage === range[0]}>
91
+ <FontAwesomeIcon icon={faBackwardStep} />
92
+ </button>
93
+ </li>
94
+ )}
95
+
96
+ {!hideNumbers &&
97
+ range.map((r: number | 'dots', i) => {
98
+ if (r === 'dots')
99
+ return (
100
+ <li key={r + i}>
101
+ <span className="pagination-ellipsis">&hellip;</span>
102
+ </li>
103
+ );
104
+ else if (r !== currentPage)
105
+ return (
106
+ <li key={r}>
107
+ <button className="pagination-link" aria-label={`Goto page ${r}`} onClick={() => set(r)}>
108
+ {r}
109
+ </button>
110
+ </li>
111
+ );
112
+ else
113
+ return (
114
+ <li key={r}>
115
+ <button className="pagination-link is-current" aria-label={`Goto page ${r}`} onClick={() => set(r)}>
116
+ {r}
117
+ </button>
118
+ </li>
119
+ );
120
+ })}
121
+
122
+ {!hideNext && (
123
+ <li>
124
+ <button className="pagination-link" aria-label="volgende paginga" onClick={next} disabled={currentPage === range[range.length - 1]}>
125
+ <FontAwesomeIcon icon={faForwardStep} />
126
+ </button>
127
+ </li>
128
+ )}
129
+
130
+ {!hideLast && (
131
+ <li>
132
+ <button className="pagination-link" aria-label="laatste pagina" onClick={last} disabled={currentPage === range[range.length - 1]}>
133
+ <FontAwesomeIcon icon={faForwardFast} />
134
+ </button>
135
+ </li>
136
+ )}
137
+ </ul>
138
+ </div>
139
+ );
140
+ }
141
+
142
+ export { Pagination };
143
+ export type { PaginationProps };
@@ -0,0 +1,225 @@
1
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
2
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
+ import { InputValueType, InputPropsType, InputStylingPropsType, FOCUS_HELP_TIMEOUT_IN_MS, BaseInput } from '@lib/forms/Input';
4
+ import { getColorClass, createIconsINTERNAL } from '@lib/internal_functions';
5
+ import { ColorProp, PrettierType, StrictOmit } from '@lib/types';
6
+ import { OR } from '@lib/utils/operators';
7
+ import React from 'react';
8
+
9
+ type PanelProps = {
10
+ /** de kleur van het Panel (default = `i`) */
11
+ color?: ColorProp | undefined;
12
+ /** panel-children */
13
+ children?: React.ReactNode | undefined;
14
+ className?: string | undefined;
15
+ };
16
+
17
+ type PanelItemProps = {
18
+ /** Is dit panel item active? */
19
+ active?: boolean;
20
+ /** Is dit panel item disabled? */
21
+ disabled?: boolean;
22
+ /** Icon van het panel item (optioneel) */
23
+ icon?: string | IconProp;
24
+ /** content van het panelitem */
25
+ children: React.ReactNode;
26
+ /** Functie die wordt aangeroepen als er op het panel item wordt geklikt */
27
+ onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
28
+ };
29
+
30
+ type PanelTabsProps = {
31
+ /** Tabs van het panel, voor als je niet de `tabs`-prop wilt gebruikten */
32
+ children?: React.ReactNode | undefined;
33
+ /** wat is de active tab? */
34
+ activeTab?: string | undefined;
35
+ /** Functie die wordt aangeroepen als er op een tab wordt geklikt */
36
+ onTabChange?: (tab: string) => void | undefined;
37
+ /** Array van tabs, voor als je geen children wilt gebruiken */
38
+ tabs?: string[] | Array<{ label: string; value: string; disabled?: boolean }> | undefined;
39
+ };
40
+
41
+ type PanelTabItemProps = {
42
+ /** is dit tab-item active? */
43
+ active?: boolean;
44
+ /** is dit tab-item disabled? */
45
+ disabled?: boolean;
46
+ /** Functie die wordt aangeroepen als er op het tab-item wordt geklikt */
47
+ onClick?: () => void;
48
+ /** content van het tab-item */
49
+ children: React.ReactNode;
50
+ };
51
+
52
+ type PanelInputProps<T extends InputValueType> = PrettierType<
53
+ StrictOmit<InputPropsType<T>, 'optionList' | 'name'> &
54
+ StrictOmit<InputStylingPropsType, 'labelHidden' | 'direction' | 'icon'> & {
55
+ icon?: string | IconProp | undefined;
56
+ infoData?: string | React.ReactNode | ((helptag?: string | undefined) => void) | undefined;
57
+ name?: string | undefined;
58
+ }
59
+ >;
60
+
61
+ /**
62
+ * Een panel is een soort menu
63
+ * @example
64
+ * <Panel color={panelTab}>
65
+ * <Panel.Header>Panel header</Panel.Header>
66
+ * <Panel.Item>Hieronder staan tabs. Verander het kleurtje</Panel.Item>
67
+ * <Panel.Tabs tabs={panelTabs} activeTab={panelTab} onTabChange={handleChangeActivePanelTab}>
68
+ * <Panel.TabItem disabled onClick={() => console.log('Woohoo!')}>
69
+ * WOOHOO
70
+ * </Panel.TabItem>
71
+ * </Panel.Tabs>
72
+ * <Panel.Item>Dit is een Panel Item</Panel.Item>
73
+ * <Panel.Item active>Dit is een active Panel Item</Panel.Item>
74
+ * <Panel.Item disabled>Dit is een disabled Panel Item</Panel.Item>
75
+ * <Panel.Item onClick={() => console.log('clickable panel item clicked')}>
76
+ * Dit is een klikbaar Panel Item
77
+ * </Panel.Item>
78
+ *
79
+ * <Panel.Header>Panel header in het midden</Panel.Header>
80
+ * <Panel.Item icon={faBomb}>Dit is ook een Panel Item, maar met icon</Panel.Item>
81
+ * <Panel.Item icon={faBomb} active>
82
+ * Dit is ook een active Panel Item
83
+ * </Panel.Item>
84
+ * <Panel.Item onClick={() => console.log('clickable panel item clicked')} icon={faFire}>
85
+ * Dit is een klikbaar Panel Item
86
+ * </Panel.Item>
87
+ * <Panel.Item icon={faBomb} disabled>
88
+ * Dit is een disabled item
89
+ * </Panel.Item>
90
+ * <Panel.Header>Panel header an het end</Panel.Header>
91
+ * </Panel>
92
+ */
93
+ const Panel = ({ color = 'i', className: cnProp = '', children }: PanelProps) => {
94
+ let className = 'panel';
95
+ className += getColorClass(color);
96
+ if (cnProp) className += ` ${cnProp}`;
97
+
98
+ return <div className={className}>{children}</div>;
99
+ };
100
+
101
+ /** weergeven van tabs op het panel */
102
+ Panel.Tabs = ({ tabs, activeTab, onTabChange, children }: PanelTabsProps) => (
103
+ <div className="panel-tabs">
104
+ {/* Als we tabs hebben gedefinieerd, maekn we die aan */}
105
+ {tabs?.map((tab) => {
106
+ let label = typeof tab === 'string' ? tab : tab.label;
107
+ let value = typeof tab === 'string' ? tab : tab.value;
108
+ let isDisabled = typeof tab === 'string' ? false : (tab.disabled ?? false);
109
+ let className = 'panel-tab-item';
110
+ if (activeTab === value) className += ' is-active';
111
+ if (isDisabled) className += ' is-disabled';
112
+ else className += ' is-clickable';
113
+
114
+ return (
115
+ <span key={value} className={className} onClick={() => onTabChange && !isDisabled && onTabChange(value)}>
116
+ {label}
117
+ </span>
118
+ );
119
+ })}
120
+ {/* Print de children, als die er zijn */}
121
+ {children}
122
+ </div>
123
+ );
124
+
125
+ /** weergeven van een tab-item */
126
+ Panel.TabItem = ({ active = false, disabled = false, onClick, children }: PanelTabItemProps) => {
127
+ let className = 'panel-tab-item';
128
+ if (active) className += ' is-active';
129
+ if (disabled) className += ' is-disabled';
130
+ else if (onClick) className += ' is-clickable';
131
+
132
+ function handleClick() {
133
+ if (disabled) return;
134
+ onClick && onClick();
135
+ }
136
+
137
+ return (
138
+ <span className={className} onClick={handleClick}>
139
+ {children}
140
+ </span>
141
+ );
142
+ };
143
+
144
+ /** weergeven van een header van de tab. Kan ook middenin het panel gebruikt worden */
145
+ Panel.Header = ({ children }: { children: React.ReactNode }) => <div className="panel-heading">{children}</div>;
146
+
147
+ /** weergeven van een item in het panel */
148
+ Panel.Item = ({ icon, active = false, disabled = false, children, onClick }: PanelItemProps) => {
149
+ let className = 'panel-block';
150
+ if (active) className += ' is-active';
151
+ if (disabled) className += ' is-disabled';
152
+ else if (onClick) className += ' is-clickable';
153
+
154
+ function handleClick(e: React.MouseEvent<HTMLDivElement>) {
155
+ if (disabled) return;
156
+ onClick && onClick(e);
157
+ }
158
+
159
+ return (
160
+ <div className={className} onClick={handleClick}>
161
+ {icon && <span className="panel-icon">{typeof icon === 'string' ? <i className={icon}></i> : <FontAwesomeIcon icon={icon} />}</span>}
162
+ {children}
163
+ </div>
164
+ );
165
+ };
166
+
167
+ /** Een input op het panel */
168
+ Panel.Input = PanelInput;
169
+ function PanelInput({ icon, id: idProp, infoData, helpTag, name, onBlur, onFocus, ...props }: PanelInputProps<string>) {
170
+ let [hasFocus, setHasFocus] = React.useState(false);
171
+ let [isHovered, setHovered] = React.useState(false);
172
+
173
+ // input heeft altijd een icon right
174
+ let controlClass = 'control has-icons-right';
175
+ if (icon) controlClass += ' has-icons-left';
176
+
177
+ let id = idProp ?? Math.random().toString(36).substring(2);
178
+
179
+ let [, iconLeftNode, iconRightNode] = createIconsINTERNAL({
180
+ icon,
181
+ error: '',
182
+ showInfo: OR(hasFocus, isHovered),
183
+ inputId: id ?? name,
184
+ infoData: undefined,
185
+ helpTag,
186
+ hideIconRight: true,
187
+ });
188
+
189
+ /** onBlur moet ook de isTouched afhandelen */
190
+ function handleOnBlur(e: React.FocusEvent<HTMLInputElement>) {
191
+ // als we de focus verliezen door de showInfo, moet de focus behouden blijven.
192
+ // Na de click op de showInfo, setten we de focus weer op het veld. Dus als na 100ms de focus
193
+ // nog steeds niet terug is, dan zetten we hasFocus echt op `false`
194
+ if (infoData)
195
+ setTimeout(() => {
196
+ const el = document.getElementById(id);
197
+ if (document.activeElement !== el) {
198
+ setHasFocus(false);
199
+ if (onBlur) onBlur(e);
200
+ }
201
+ }, FOCUS_HELP_TIMEOUT_IN_MS);
202
+ else {
203
+ if (onBlur) onBlur(e);
204
+ setHasFocus(false);
205
+ }
206
+ }
207
+
208
+ function handleFocusChange(e: React.FocusEvent<HTMLInputElement>) {
209
+ setHasFocus(true);
210
+ if (onFocus) onFocus(e);
211
+ }
212
+
213
+ return (
214
+ <div className="panel-block" onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)}>
215
+ <div className={controlClass}>
216
+ <BaseInput name={name ?? id} id={id} onBlur={handleOnBlur} onFocus={handleFocusChange} {...props} />
217
+ {iconLeftNode}
218
+ {iconRightNode}
219
+ </div>
220
+ </div>
221
+ );
222
+ }
223
+
224
+ export { Panel };
225
+ export type { PanelProps };
@@ -0,0 +1,92 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import { ProgressBar } from './ProgressBar';
5
+ import { ColorProp } from '../../loon-react-bulma-types';
6
+
7
+ describe('Test <ProgressBar /> Component', () => {
8
+ test('Should be a function', () => expect(ProgressBar).toBeInstanceOf(Function));
9
+ test('Should render a normal-sized (default, niet opgegeven) info ProgressBar with value 50, default max 100', () => {
10
+ render(<ProgressBar value={50} suffix=" %" />);
11
+ const progress = screen.getByRole('progress');
12
+ expect(progress instanceof HTMLProgressElement).toBe(true);
13
+ expect(progress).toHaveClass('progress', 'is-info');
14
+ expect(progress).toHaveAttribute('value', '50');
15
+ expect(progress).toHaveAttribute('max', '100');
16
+ });
17
+
18
+ test('Should render a small success ProgressBar with value 25, tooltip with 25 euro, max 1000', () => {
19
+ render(<ProgressBar size="s" color="s" value={25} max={1000} prefix="$" suffix="euro" />);
20
+
21
+ const progress = screen.getByRole('progress');
22
+ expect(progress instanceof HTMLProgressElement).toBe(true);
23
+ expect(progress).toHaveClass('progress', 'is-small', 'is-success');
24
+ expect(progress).toHaveAttribute('value', '25');
25
+ expect(progress).toHaveAttribute('max', '1000');
26
+ expect(progress).toHaveAttribute('title', '$ 25 euro');
27
+ });
28
+
29
+ test('Should render a large danger ProgressBar with no value, no tooltip, max 100', () => {
30
+ render(<ProgressBar size="l" color="d" title={(v) => (typeof v === 'number' ? `${v} percent` : 'nothing')} />);
31
+ const progress = screen.getByRole('progress');
32
+ expect(progress instanceof HTMLProgressElement).toBe(true);
33
+ expect(progress).toHaveClass('progress', 'is-medium', 'is-danger');
34
+ expect(progress).not.toHaveAttribute('value');
35
+ expect(progress).toHaveAttribute('max', '100');
36
+ });
37
+
38
+ test("Should render a large danger ProgressBar with value 'indeterminate', no tooltip, max 100", () => {
39
+ render(<ProgressBar size="l" color="d" value="indeterminate" />);
40
+ const progress = screen.getByRole('progress');
41
+ expect(progress instanceof HTMLProgressElement).toBe(true);
42
+ expect(progress).toHaveClass('progress', 'is-medium', 'is-danger');
43
+ expect(progress).not.toHaveAttribute('value');
44
+ expect(progress).toHaveAttribute('max', '100');
45
+ });
46
+
47
+ test('Should render an xlarge link ProgressBar with value 75, max 100', () => {
48
+ render(<ProgressBar size="xl" color="l" value={75} title="bazinga" />);
49
+ const link = screen.getByRole('progress');
50
+ expect(link instanceof HTMLProgressElement).toBe(true);
51
+ expect(link).toHaveClass('progress', 'is-large', 'is-link');
52
+ expect(link).toHaveAttribute('value', '75');
53
+ expect(link).toHaveAttribute('max', '100');
54
+ expect(link).toHaveAttribute('title', 'bazinga');
55
+ });
56
+
57
+ test('Should render a medium-sized (default) warning ProgressBar with value 75, max 100', () => {
58
+ render(<ProgressBar color="w" size="m" value={75} />);
59
+ const link = screen.getByRole('progress');
60
+ expect(link instanceof HTMLProgressElement).toBe(true);
61
+ expect(link).toHaveClass('progress', 'is-warning', 'is-normal');
62
+ expect(link).toHaveAttribute('value', '75');
63
+ expect(link).toHaveAttribute('max', '100');
64
+ expect(link).toHaveAttribute('title', '75');
65
+ });
66
+
67
+ test('Should render a primary ProgressBar with value 75, max 100', () => {
68
+ render(<ProgressBar color="p" value={75} />);
69
+ const link = screen.getByRole('progress');
70
+ expect(link instanceof HTMLProgressElement).toBe(true);
71
+ expect(link).toHaveClass('progress', 'is-primary');
72
+ expect(link).toHaveAttribute('value', '75');
73
+ expect(link).toHaveAttribute('max', '100');
74
+ expect(link).toHaveAttribute('title', '75');
75
+ });
76
+
77
+ describe('Test colors', () => {
78
+ const colors: ColorProp[] = ['p', 'i', 'l', 'd', 's', 'w', 'light', 'dark', 'is-custom'];
79
+ const voluitColors = ['primary', 'info', 'link', 'danger', 'success', 'warning', 'light', 'dark', 'custom'];
80
+ colors.forEach((color, i) => {
81
+ test(`Should render a ${voluitColors[i]} ProgressBar with value 75, max 100`, () => {
82
+ render(<ProgressBar color={color} value={75} />);
83
+ const link = screen.getByRole('progress');
84
+ expect(link instanceof HTMLProgressElement).toBe(true);
85
+ expect(link).toHaveClass('progress', `is-${voluitColors[i]}`);
86
+ expect(link).toHaveAttribute('value', '75');
87
+ expect(link).toHaveAttribute('max', '100');
88
+ expect(link).toHaveAttribute('title', '75');
89
+ });
90
+ });
91
+ });
92
+ });
@@ -0,0 +1,42 @@
1
+ import { getSizeClass, getColorClass } from '@lib/internal_functions';
2
+ import { SizeProp, ColorProp } from '@lib/types';
3
+
4
+ type ProgressBarProps = {
5
+ /** Grootte van de progressbar */
6
+ size?: SizeProp;
7
+ /** De maximale waarde, default = 100 */
8
+ max?: number;
9
+ /** De waarde waarop de progressbar staat. Vul `undefined` of `'indeterminate'` in voor een onbepaalde, loopende progressbar */
10
+ value?: number | 'indeterminate';
11
+ /** teken of symbool **voor** de waarde (bijvoorbeeld in de title) */ prefix?: '%' | '€' | 'º' | '$' | '£' | '¢' | '¥' | (string & {});
12
+ /** teken of symbool **achter** de waarde (bijvoorbeeld in de title) */ suffix?: '%' | '€' | 'º' | '$' | '£' | '¢' | '¥' | (string & {});
13
+ /** De kleur van de progressbar (default = 'i') */
14
+ color?: ColorProp;
15
+ /** (optionele) hover-title voor de progress-bar. Als er geen title is gebruikt, wordt de `value` weergegeven (met pre- en suffix) */
16
+ title?: string | ((v?: number | 'indeterminate') => string);
17
+ };
18
+
19
+ /**
20
+ * Maak een progress-bar met de <progress> tag.
21
+ * Door de attribute `value` de waarde `undefined` of `'indeterminate'` te geven, krijg je een loopende progress bar
22
+ * @param props
23
+ * @returns een progress bar
24
+ * @example
25
+ * <ProgressBar value={50} />
26
+ * <ProgressBar value={50} extension="%" />
27
+ * <ProgressBar size='xl' />
28
+ */
29
+ function ProgressBar({ color = 'i', size = 'm', prefix = '', suffix = '', max = 100, value, title: titleProp }: ProgressBarProps) {
30
+ let className = `progress ${getSizeClass(size, true)} ${getColorClass(color, true)}`.trim();
31
+ let valueStr = value && value !== 'indeterminate' ? `${prefix} ${value} ${suffix}`.trim() : undefined;
32
+ let title = titleProp ? (typeof titleProp === 'function' ? titleProp(value) : titleProp) : valueStr;
33
+
34
+ return (
35
+ <progress className={className} value={value === 'indeterminate' ? undefined : value} max={max} title={title} role="progress">
36
+ {valueStr}
37
+ </progress>
38
+ );
39
+ }
40
+
41
+ export { ProgressBar };
42
+ export type { ProgressBarProps };
@@ -0,0 +1,81 @@
1
+ /* eslint-disable testing-library/no-node-access */
2
+ import { render, screen } from '@testing-library/react';
3
+ import { QuickView } from './QuickView';
4
+ import { ColorProp } from '../../loon-react-bulma-types';
5
+
6
+ describe('Test <QuickView> Component', () => {
7
+ test('Should be a function', () => expect(QuickView).toBeInstanceOf(Function));
8
+
9
+ test('Should render a QuickView with a <QuickView.Header>, <QuickView.Body> and <QuickView.Footer>', () => {
10
+ const mockOpened = jest.fn();
11
+ const mockDismiss = jest.fn();
12
+ render(
13
+ <QuickView onOpened={mockOpened} onDismiss={mockDismiss}>
14
+ <QuickView.Header>Header</QuickView.Header>
15
+ <QuickView.Body>Body</QuickView.Body>
16
+ <QuickView.Footer>Footer</QuickView.Footer>
17
+ </QuickView>
18
+ );
19
+ const header = screen.getByText('Header').parentElement;
20
+ expect(header).toHaveClass('quickview-header');
21
+ expect(header).toHaveTextContent('Header');
22
+
23
+ const body = screen.getByText('Body');
24
+ expect(body).toHaveClass('quickview-body');
25
+ expect(body).toHaveTextContent('Body');
26
+
27
+ const footer = screen.getByText('Footer');
28
+ expect(footer).toHaveClass('quickview-footer');
29
+ expect(footer).toHaveTextContent('Footer');
30
+
31
+ expect(mockOpened).toHaveBeenCalledTimes(1);
32
+ expect(mockDismiss).toHaveBeenCalledTimes(0);
33
+
34
+ const dismissBttn = screen.getByTitle('close');
35
+ expect(dismissBttn).toBeInTheDocument();
36
+ dismissBttn.click();
37
+ expect(mockDismiss).toHaveBeenCalledTimes(1);
38
+ });
39
+
40
+ test('It should also just render a <Quickview.Body when not defined', () => {
41
+ render(
42
+ <QuickView>
43
+ <div>Body</div>
44
+ </QuickView>
45
+ );
46
+ const body = screen.getByText('Body').parentElement;
47
+ expect(body).toHaveClass('quickview-body');
48
+ expect(body).toHaveTextContent('Body');
49
+ });
50
+
51
+ describe('Test color-prop', () => {
52
+ const colors: ColorProp[] = ['p', 'i', 'l', 'd', 's', 'w', 'light', 'dark', 'is-custom'];
53
+ const voluitColors = ['primary', 'info', 'link', 'danger', 'success', 'warning', 'light', 'dark', 'custom'];
54
+ colors.forEach((color, i) => {
55
+ test('Should color the QuickView ' + voluitColors[i], () => {
56
+ render(
57
+ <QuickView color={color}>
58
+ <QuickView.Header>Header</QuickView.Header>
59
+ <QuickView.Body>Body</QuickView.Body>
60
+ <QuickView.Footer>Footer</QuickView.Footer>
61
+ </QuickView>
62
+ );
63
+ });
64
+ });
65
+ });
66
+
67
+ describe('Test alignment-prop', () => {
68
+ const alignments: Array<'l' | 'r'> = ['l', 'r'];
69
+ alignments.forEach((alignment) => {
70
+ test('Should align the QuickView to the ' + (alignment === 'r' ? 'right' : 'left'), () => {
71
+ render(
72
+ <QuickView alignment={alignment}>
73
+ <QuickView.Header>Header</QuickView.Header>
74
+ <QuickView.Body>Body</QuickView.Body>
75
+ <QuickView.Footer>Footer</QuickView.Footer>
76
+ </QuickView>
77
+ );
78
+ });
79
+ });
80
+ });
81
+ });