@helpwave/hightide 0.1.25 → 0.1.27

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 (664) hide show
  1. package/README.md +1 -1
  2. package/dist/components/branding/HelpwaveBadge.d.mts +4 -5
  3. package/dist/components/branding/HelpwaveBadge.d.ts +4 -5
  4. package/dist/components/branding/HelpwaveBadge.js +46 -87
  5. package/dist/components/branding/HelpwaveBadge.js.map +1 -1
  6. package/dist/components/branding/HelpwaveBadge.mjs +46 -89
  7. package/dist/components/branding/HelpwaveBadge.mjs.map +1 -1
  8. package/dist/components/date/DatePicker.d.mts +1 -1
  9. package/dist/components/date/DatePicker.d.ts +1 -1
  10. package/dist/components/date/DatePicker.js +65 -14
  11. package/dist/components/date/DatePicker.js.map +1 -1
  12. package/dist/components/date/DatePicker.mjs +66 -15
  13. package/dist/components/date/DatePicker.mjs.map +1 -1
  14. package/dist/components/date/DayPicker.d.mts +1 -1
  15. package/dist/components/date/DayPicker.d.ts +1 -1
  16. package/dist/components/date/DayPicker.js +3 -3
  17. package/dist/components/date/DayPicker.js.map +1 -1
  18. package/dist/components/date/DayPicker.mjs +3 -3
  19. package/dist/components/date/DayPicker.mjs.map +1 -1
  20. package/dist/components/date/TimeDisplay.js.map +1 -1
  21. package/dist/components/date/TimeDisplay.mjs.map +1 -1
  22. package/dist/components/date/TimePicker.js +2 -2
  23. package/dist/components/date/TimePicker.js.map +1 -1
  24. package/dist/components/date/TimePicker.mjs +2 -2
  25. package/dist/components/date/TimePicker.mjs.map +1 -1
  26. package/dist/components/date/YearMonthPicker.js +59 -8
  27. package/dist/components/date/YearMonthPicker.js.map +1 -1
  28. package/dist/components/date/YearMonthPicker.mjs +60 -9
  29. package/dist/components/date/YearMonthPicker.mjs.map +1 -1
  30. package/dist/components/{dialogs → dialog}/ConfirmDialog.d.mts +9 -8
  31. package/dist/components/{dialogs → dialog}/ConfirmDialog.d.ts +9 -8
  32. package/dist/components/dialog/ConfirmDialog.js +938 -0
  33. package/dist/components/dialog/ConfirmDialog.js.map +1 -0
  34. package/dist/components/dialog/ConfirmDialog.mjs +902 -0
  35. package/dist/components/dialog/ConfirmDialog.mjs.map +1 -0
  36. package/dist/components/dialog/Dialog.d.mts +27 -0
  37. package/dist/components/dialog/Dialog.d.ts +27 -0
  38. package/dist/components/dialog/Dialog.js +879 -0
  39. package/dist/components/dialog/Dialog.js.map +1 -0
  40. package/dist/components/dialog/Dialog.mjs +845 -0
  41. package/dist/components/dialog/Dialog.mjs.map +1 -0
  42. package/dist/components/dialog/DiscardChangesDialog.d.mts +24 -0
  43. package/dist/components/dialog/DiscardChangesDialog.d.ts +24 -0
  44. package/dist/components/dialog/DiscardChangesDialog.js +966 -0
  45. package/dist/components/dialog/DiscardChangesDialog.js.map +1 -0
  46. package/dist/components/dialog/DiscardChangesDialog.mjs +930 -0
  47. package/dist/components/dialog/DiscardChangesDialog.mjs.map +1 -0
  48. package/dist/components/dialog/InputDialog.d.mts +22 -0
  49. package/dist/components/dialog/InputDialog.d.ts +22 -0
  50. package/dist/components/dialog/InputDialog.js +1139 -0
  51. package/dist/components/dialog/InputDialog.js.map +1 -0
  52. package/dist/components/dialog/InputDialog.mjs +1103 -0
  53. package/dist/components/dialog/InputDialog.mjs.map +1 -0
  54. package/dist/components/dialog/LanguageDialog.d.mts +25 -0
  55. package/dist/components/dialog/LanguageDialog.d.ts +25 -0
  56. package/dist/components/dialog/LanguageDialog.js +1697 -0
  57. package/dist/components/dialog/LanguageDialog.js.map +1 -0
  58. package/dist/components/dialog/LanguageDialog.mjs +1671 -0
  59. package/dist/components/dialog/LanguageDialog.mjs.map +1 -0
  60. package/dist/components/dialog/ThemeDialog.d.mts +26 -0
  61. package/dist/components/dialog/ThemeDialog.d.ts +26 -0
  62. package/dist/components/dialog/ThemeDialog.js +1751 -0
  63. package/dist/components/dialog/ThemeDialog.js.map +1 -0
  64. package/dist/components/dialog/ThemeDialog.mjs +1725 -0
  65. package/dist/components/dialog/ThemeDialog.mjs.map +1 -0
  66. package/dist/components/dialog/index.d.mts +17 -0
  67. package/dist/components/dialog/index.d.ts +17 -0
  68. package/dist/components/dialog/index.js +2098 -0
  69. package/dist/components/dialog/index.js.map +1 -0
  70. package/dist/components/dialog/index.mjs +2067 -0
  71. package/dist/components/dialog/index.mjs.map +1 -0
  72. package/dist/components/form/FormElementWrapper.d.mts +29 -0
  73. package/dist/components/form/FormElementWrapper.d.ts +29 -0
  74. package/dist/components/form/FormElementWrapper.js +98 -0
  75. package/dist/components/form/FormElementWrapper.js.map +1 -0
  76. package/dist/components/form/FormElementWrapper.mjs +64 -0
  77. package/dist/components/form/FormElementWrapper.mjs.map +1 -0
  78. package/dist/components/icons-and-geometry/Avatar.js +498 -2886
  79. package/dist/components/icons-and-geometry/Avatar.js.map +1 -1
  80. package/dist/components/icons-and-geometry/Avatar.mjs +490 -2878
  81. package/dist/components/icons-and-geometry/Avatar.mjs.map +1 -1
  82. package/dist/components/icons-and-geometry/{Helpwave.d.mts → HelpwaveLogo.d.mts} +3 -3
  83. package/dist/components/icons-and-geometry/{Helpwave.d.ts → HelpwaveLogo.d.ts} +3 -3
  84. package/dist/components/icons-and-geometry/{Helpwave.js → HelpwaveLogo.js} +21 -22
  85. package/dist/components/icons-and-geometry/HelpwaveLogo.js.map +1 -0
  86. package/dist/components/icons-and-geometry/{Helpwave.mjs → HelpwaveLogo.mjs} +17 -18
  87. package/dist/components/icons-and-geometry/HelpwaveLogo.mjs.map +1 -0
  88. package/dist/components/icons-and-geometry/Ring.js +1 -1
  89. package/dist/components/icons-and-geometry/Ring.js.map +1 -1
  90. package/dist/components/icons-and-geometry/Ring.mjs +1 -1
  91. package/dist/components/icons-and-geometry/Ring.mjs.map +1 -1
  92. package/dist/components/icons-and-geometry/Tag.js +8 -20
  93. package/dist/components/icons-and-geometry/Tag.js.map +1 -1
  94. package/dist/components/icons-and-geometry/Tag.mjs +8 -20
  95. package/dist/components/icons-and-geometry/Tag.mjs.map +1 -1
  96. package/dist/components/layout/Carousel.d.mts +33 -0
  97. package/dist/components/layout/Carousel.d.ts +33 -0
  98. package/dist/components/layout/Carousel.js +684 -0
  99. package/dist/components/layout/Carousel.js.map +1 -0
  100. package/dist/components/layout/Carousel.mjs +659 -0
  101. package/dist/components/layout/Carousel.mjs.map +1 -0
  102. package/dist/components/{layout-and-navigation → layout}/Chip.d.mts +8 -5
  103. package/dist/components/{layout-and-navigation → layout}/Chip.d.ts +8 -5
  104. package/dist/components/{layout-and-navigation → layout}/Chip.js +18 -5
  105. package/dist/components/layout/Chip.js.map +1 -0
  106. package/dist/components/{layout-and-navigation → layout}/Chip.mjs +18 -5
  107. package/dist/components/layout/Chip.mjs.map +1 -0
  108. package/dist/components/{layout-and-navigation → layout}/DividerInserter.js +1 -1
  109. package/dist/components/layout/DividerInserter.js.map +1 -0
  110. package/dist/components/{layout-and-navigation → layout}/DividerInserter.mjs +1 -1
  111. package/dist/components/layout/DividerInserter.mjs.map +1 -0
  112. package/dist/components/{layout-and-navigation → layout}/Expandable.d.mts +13 -10
  113. package/dist/components/{layout-and-navigation → layout}/Expandable.d.ts +13 -10
  114. package/dist/components/{layout-and-navigation → layout}/Expandable.js +20 -7
  115. package/dist/components/layout/Expandable.js.map +1 -0
  116. package/dist/components/{layout-and-navigation → layout}/Expandable.mjs +21 -8
  117. package/dist/components/layout/Expandable.mjs.map +1 -0
  118. package/dist/components/{layout-and-navigation → layout}/FAQSection.js +26 -13
  119. package/dist/components/layout/FAQSection.js.map +1 -0
  120. package/dist/components/{layout-and-navigation → layout}/FAQSection.mjs +27 -14
  121. package/dist/components/layout/FAQSection.mjs.map +1 -0
  122. package/dist/components/layout/FloatingContainer.d.mts +38 -0
  123. package/dist/components/layout/FloatingContainer.d.ts +38 -0
  124. package/dist/components/layout/FloatingContainer.js +219 -0
  125. package/dist/components/layout/FloatingContainer.js.map +1 -0
  126. package/dist/components/layout/FloatingContainer.mjs +195 -0
  127. package/dist/components/layout/FloatingContainer.mjs.map +1 -0
  128. package/dist/components/layout/ListBox.d.mts +44 -0
  129. package/dist/components/layout/ListBox.d.ts +44 -0
  130. package/dist/components/layout/ListBox.js +329 -0
  131. package/dist/components/layout/ListBox.js.map +1 -0
  132. package/dist/components/layout/ListBox.mjs +290 -0
  133. package/dist/components/layout/ListBox.mjs.map +1 -0
  134. package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.js +1 -1
  135. package/dist/components/layout/MarkdownInterpreter.js.map +1 -0
  136. package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.mjs +1 -1
  137. package/dist/components/layout/MarkdownInterpreter.mjs.map +1 -0
  138. package/dist/components/layout/ScrollArea.d.mts +15 -0
  139. package/dist/components/layout/ScrollArea.d.ts +15 -0
  140. package/dist/components/layout/ScrollArea.js +1252 -0
  141. package/dist/components/layout/ScrollArea.js.map +1 -0
  142. package/dist/components/layout/ScrollArea.mjs +1216 -0
  143. package/dist/components/layout/ScrollArea.mjs.map +1 -0
  144. package/dist/components/{layout-and-navigation → layout}/TextImage.js +6 -4
  145. package/dist/components/layout/TextImage.js.map +1 -0
  146. package/dist/components/{layout-and-navigation → layout}/TextImage.mjs +5 -3
  147. package/dist/components/layout/TextImage.mjs.map +1 -0
  148. package/dist/components/{layout-and-navigation → layout}/VerticalDivider.js +1 -1
  149. package/dist/components/layout/VerticalDivider.js.map +1 -0
  150. package/dist/components/{layout-and-navigation → layout}/VerticalDivider.mjs +1 -1
  151. package/dist/components/layout/VerticalDivider.mjs.map +1 -0
  152. package/dist/components/loading-states/ErrorComponent.js.map +1 -1
  153. package/dist/components/loading-states/ErrorComponent.mjs.map +1 -1
  154. package/dist/components/loading-states/LoadingAndErrorComponent.d.mts +1 -1
  155. package/dist/components/loading-states/LoadingAndErrorComponent.d.ts +1 -1
  156. package/dist/components/loading-states/LoadingAnimation.js +18 -17
  157. package/dist/components/loading-states/LoadingAnimation.js.map +1 -1
  158. package/dist/components/loading-states/LoadingAnimation.mjs +18 -17
  159. package/dist/components/loading-states/LoadingAnimation.mjs.map +1 -1
  160. package/dist/components/loading-states/LoadingButton.js +55 -18
  161. package/dist/components/loading-states/LoadingButton.js.map +1 -1
  162. package/dist/components/loading-states/LoadingButton.mjs +55 -18
  163. package/dist/components/loading-states/LoadingButton.mjs.map +1 -1
  164. package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.js +668 -23
  165. package/dist/components/navigation/BreadCrumb.js.map +1 -0
  166. package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.mjs +668 -23
  167. package/dist/components/navigation/BreadCrumb.mjs.map +1 -0
  168. package/dist/components/navigation/Navigation.d.mts +21 -0
  169. package/dist/components/navigation/Navigation.d.ts +21 -0
  170. package/dist/components/navigation/Navigation.js +4018 -0
  171. package/dist/components/navigation/Navigation.js.map +1 -0
  172. package/dist/components/navigation/Navigation.mjs +4012 -0
  173. package/dist/components/navigation/Navigation.mjs.map +1 -0
  174. package/dist/components/{layout-and-navigation → navigation}/Pagination.js +107 -192
  175. package/dist/components/navigation/Pagination.js.map +1 -0
  176. package/dist/components/{layout-and-navigation → navigation}/Pagination.mjs +102 -187
  177. package/dist/components/navigation/Pagination.mjs.map +1 -0
  178. package/dist/components/{layout-and-navigation → navigation}/StepperBar.js +44 -4
  179. package/dist/components/navigation/StepperBar.js.map +1 -0
  180. package/dist/components/{layout-and-navigation → navigation}/StepperBar.mjs +44 -4
  181. package/dist/components/navigation/StepperBar.mjs.map +1 -0
  182. package/dist/components/properties/CheckboxProperty.js +890 -135
  183. package/dist/components/properties/CheckboxProperty.js.map +1 -1
  184. package/dist/components/properties/CheckboxProperty.mjs +897 -142
  185. package/dist/components/properties/CheckboxProperty.mjs.map +1 -1
  186. package/dist/components/properties/DateProperty.js +153 -198
  187. package/dist/components/properties/DateProperty.js.map +1 -1
  188. package/dist/components/properties/DateProperty.mjs +146 -191
  189. package/dist/components/properties/DateProperty.mjs.map +1 -1
  190. package/dist/components/properties/MultiSelectProperty.d.mts +5 -10
  191. package/dist/components/properties/MultiSelectProperty.d.ts +5 -10
  192. package/dist/components/properties/MultiSelectProperty.js +1156 -1160
  193. package/dist/components/properties/MultiSelectProperty.js.map +1 -1
  194. package/dist/components/properties/MultiSelectProperty.mjs +1169 -1163
  195. package/dist/components/properties/MultiSelectProperty.mjs.map +1 -1
  196. package/dist/components/properties/NumberProperty.js +155 -201
  197. package/dist/components/properties/NumberProperty.js.map +1 -1
  198. package/dist/components/properties/NumberProperty.mjs +148 -194
  199. package/dist/components/properties/NumberProperty.mjs.map +1 -1
  200. package/dist/components/properties/PropertyBase.js +49 -9
  201. package/dist/components/properties/PropertyBase.js.map +1 -1
  202. package/dist/components/properties/PropertyBase.mjs +49 -9
  203. package/dist/components/properties/PropertyBase.mjs.map +1 -1
  204. package/dist/components/properties/SelectProperty.d.mts +5 -8
  205. package/dist/components/properties/SelectProperty.d.ts +5 -8
  206. package/dist/components/properties/SelectProperty.js +1062 -836
  207. package/dist/components/properties/SelectProperty.js.map +1 -1
  208. package/dist/components/properties/SelectProperty.mjs +1077 -841
  209. package/dist/components/properties/SelectProperty.mjs.map +1 -1
  210. package/dist/components/properties/TextProperty.js +97 -100
  211. package/dist/components/properties/TextProperty.js.map +1 -1
  212. package/dist/components/properties/TextProperty.mjs +100 -103
  213. package/dist/components/properties/TextProperty.mjs.map +1 -1
  214. package/dist/components/table/Table.js +1619 -994
  215. package/dist/components/table/Table.js.map +1 -1
  216. package/dist/components/table/Table.mjs +1626 -1001
  217. package/dist/components/table/Table.mjs.map +1 -1
  218. package/dist/components/table/TableFilterButton.js +116 -201
  219. package/dist/components/table/TableFilterButton.js.map +1 -1
  220. package/dist/components/table/TableFilterButton.mjs +105 -190
  221. package/dist/components/table/TableFilterButton.mjs.map +1 -1
  222. package/dist/components/table/TableSortButton.js +4 -3
  223. package/dist/components/table/TableSortButton.js.map +1 -1
  224. package/dist/components/table/TableSortButton.mjs +4 -3
  225. package/dist/components/table/TableSortButton.mjs.map +1 -1
  226. package/dist/components/user-action/Button.d.mts +15 -11
  227. package/dist/components/user-action/Button.d.ts +15 -11
  228. package/dist/components/user-action/Button.js +10 -9
  229. package/dist/components/user-action/Button.js.map +1 -1
  230. package/dist/components/user-action/Button.mjs +10 -9
  231. package/dist/components/user-action/Button.mjs.map +1 -1
  232. package/dist/components/user-action/Checkbox.d.mts +9 -25
  233. package/dist/components/user-action/Checkbox.d.ts +9 -25
  234. package/dist/components/user-action/Checkbox.js +793 -103
  235. package/dist/components/user-action/Checkbox.js.map +1 -1
  236. package/dist/components/user-action/Checkbox.mjs +794 -104
  237. package/dist/components/user-action/Checkbox.mjs.map +1 -1
  238. package/dist/components/user-action/CopyToClipboardWrapper.js +3 -1
  239. package/dist/components/user-action/CopyToClipboardWrapper.js.map +1 -1
  240. package/dist/components/user-action/CopyToClipboardWrapper.mjs +3 -1
  241. package/dist/components/user-action/CopyToClipboardWrapper.mjs.map +1 -1
  242. package/dist/components/user-action/DateAndTimePicker.d.mts +1 -1
  243. package/dist/components/user-action/DateAndTimePicker.d.ts +1 -1
  244. package/dist/components/user-action/DateAndTimePicker.js +67 -14
  245. package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
  246. package/dist/components/user-action/DateAndTimePicker.mjs +68 -15
  247. package/dist/components/user-action/DateAndTimePicker.mjs.map +1 -1
  248. package/dist/components/user-action/Label.d.mts +6 -8
  249. package/dist/components/user-action/Label.d.ts +6 -8
  250. package/dist/components/user-action/Label.js +4 -6
  251. package/dist/components/user-action/Label.js.map +1 -1
  252. package/dist/components/user-action/Label.mjs +4 -6
  253. package/dist/components/user-action/Label.mjs.map +1 -1
  254. package/dist/components/user-action/Menu.d.mts +2 -2
  255. package/dist/components/user-action/Menu.d.ts +2 -2
  256. package/dist/components/user-action/Menu.js +1 -1
  257. package/dist/components/user-action/Menu.js.map +1 -1
  258. package/dist/components/user-action/Menu.mjs +1 -1
  259. package/dist/components/user-action/Menu.mjs.map +1 -1
  260. package/dist/components/user-action/ScrollPicker.js +8 -6
  261. package/dist/components/user-action/ScrollPicker.js.map +1 -1
  262. package/dist/components/user-action/ScrollPicker.mjs +8 -6
  263. package/dist/components/user-action/ScrollPicker.mjs.map +1 -1
  264. package/dist/components/user-action/SearchBar.d.mts +1 -2
  265. package/dist/components/user-action/SearchBar.d.ts +1 -2
  266. package/dist/components/user-action/SearchBar.js +93 -178
  267. package/dist/components/user-action/SearchBar.js.map +1 -1
  268. package/dist/components/user-action/SearchBar.mjs +86 -171
  269. package/dist/components/user-action/SearchBar.mjs.map +1 -1
  270. package/dist/components/user-action/Textarea.d.mts +22 -11
  271. package/dist/components/user-action/Textarea.d.ts +22 -11
  272. package/dist/components/user-action/Textarea.js +101 -92
  273. package/dist/components/user-action/Textarea.js.map +1 -1
  274. package/dist/components/user-action/Textarea.mjs +100 -92
  275. package/dist/components/user-action/Textarea.mjs.map +1 -1
  276. package/dist/components/user-action/input/Input.d.mts +37 -0
  277. package/dist/components/user-action/input/Input.d.ts +37 -0
  278. package/dist/components/user-action/input/Input.js +244 -0
  279. package/dist/components/user-action/input/Input.js.map +1 -0
  280. package/dist/components/user-action/input/Input.mjs +209 -0
  281. package/dist/components/user-action/input/Input.mjs.map +1 -0
  282. package/dist/components/user-action/input/InsideLabelInput.d.mts +20 -0
  283. package/dist/components/user-action/input/InsideLabelInput.d.ts +20 -0
  284. package/dist/components/user-action/input/InsideLabelInput.js +295 -0
  285. package/dist/components/user-action/input/InsideLabelInput.js.map +1 -0
  286. package/dist/components/user-action/input/InsideLabelInput.mjs +260 -0
  287. package/dist/components/user-action/input/InsideLabelInput.mjs.map +1 -0
  288. package/dist/components/user-action/input/ToggleableInput.d.mts +22 -0
  289. package/dist/components/user-action/input/ToggleableInput.d.ts +22 -0
  290. package/dist/components/user-action/{Input.js → input/ToggleableInput.js} +136 -171
  291. package/dist/components/user-action/input/ToggleableInput.js.map +1 -0
  292. package/dist/components/user-action/input/ToggleableInput.mjs +264 -0
  293. package/dist/components/user-action/input/ToggleableInput.mjs.map +1 -0
  294. package/dist/components/user-action/select/Select.d.mts +102 -0
  295. package/dist/components/user-action/select/Select.d.ts +102 -0
  296. package/dist/components/user-action/select/Select.js +1367 -0
  297. package/dist/components/user-action/select/Select.js.map +1 -0
  298. package/dist/components/user-action/select/Select.mjs +1333 -0
  299. package/dist/components/user-action/select/Select.mjs.map +1 -0
  300. package/dist/components/utils/FocusTrap.d.mts +28 -0
  301. package/dist/components/utils/FocusTrap.d.ts +28 -0
  302. package/dist/components/utils/FocusTrap.js +252 -0
  303. package/dist/components/utils/FocusTrap.js.map +1 -0
  304. package/dist/components/utils/FocusTrap.mjs +229 -0
  305. package/dist/components/utils/FocusTrap.mjs.map +1 -0
  306. package/dist/components/utils/Transition.d.mts +26 -0
  307. package/dist/components/utils/Transition.d.ts +26 -0
  308. package/dist/components/utils/Transition.js +74 -0
  309. package/dist/components/utils/Transition.js.map +1 -0
  310. package/dist/components/utils/Transition.mjs +50 -0
  311. package/dist/components/utils/Transition.mjs.map +1 -0
  312. package/dist/hooks/focus/useFocusGuards.d.mts +3 -0
  313. package/dist/hooks/focus/useFocusGuards.d.ts +3 -0
  314. package/dist/hooks/focus/useFocusGuards.js +74 -0
  315. package/dist/hooks/focus/useFocusGuards.js.map +1 -0
  316. package/dist/hooks/focus/useFocusGuards.mjs +50 -0
  317. package/dist/hooks/focus/useFocusGuards.mjs.map +1 -0
  318. package/dist/hooks/{useFocusManagement.js → focus/useFocusManagement.js} +1 -1
  319. package/dist/hooks/focus/useFocusManagement.js.map +1 -0
  320. package/dist/hooks/{useFocusManagement.mjs → focus/useFocusManagement.mjs} +1 -1
  321. package/dist/hooks/focus/useFocusManagement.mjs.map +1 -0
  322. package/dist/hooks/{useFocusOnceVisible.js → focus/useFocusOnceVisible.js} +1 -1
  323. package/dist/hooks/focus/useFocusOnceVisible.js.map +1 -0
  324. package/dist/hooks/{useFocusOnceVisible.mjs → focus/useFocusOnceVisible.mjs} +1 -1
  325. package/dist/hooks/focus/useFocusOnceVisible.mjs.map +1 -0
  326. package/dist/hooks/focus/useFocusTrap.d.mts +16 -0
  327. package/dist/hooks/focus/useFocusTrap.d.ts +16 -0
  328. package/dist/hooks/focus/useFocusTrap.js +233 -0
  329. package/dist/hooks/focus/useFocusTrap.js.map +1 -0
  330. package/dist/hooks/focus/useFocusTrap.mjs +210 -0
  331. package/dist/hooks/focus/useFocusTrap.mjs.map +1 -0
  332. package/dist/hooks/focus/useIsMounted.d.mts +3 -0
  333. package/dist/hooks/focus/useIsMounted.d.ts +3 -0
  334. package/dist/hooks/focus/useIsMounted.js +43 -0
  335. package/dist/hooks/focus/useIsMounted.js.map +1 -0
  336. package/dist/hooks/focus/useIsMounted.mjs +20 -0
  337. package/dist/hooks/focus/useIsMounted.mjs.map +1 -0
  338. package/dist/hooks/useFloatingElement.d.mts +22 -0
  339. package/dist/hooks/useFloatingElement.d.ts +22 -0
  340. package/dist/hooks/useFloatingElement.js +162 -0
  341. package/dist/hooks/useFloatingElement.js.map +1 -0
  342. package/dist/hooks/useFloatingElement.mjs +139 -0
  343. package/dist/hooks/useFloatingElement.mjs.map +1 -0
  344. package/dist/hooks/useLocalStorage.js +2 -2
  345. package/dist/hooks/useLocalStorage.js.map +1 -1
  346. package/dist/hooks/useLocalStorage.mjs +2 -2
  347. package/dist/hooks/useLocalStorage.mjs.map +1 -1
  348. package/dist/hooks/useLogOnce.d.mts +3 -4
  349. package/dist/hooks/useLogOnce.d.ts +3 -4
  350. package/dist/hooks/useLogOnce.js +5 -5
  351. package/dist/hooks/useLogOnce.js.map +1 -1
  352. package/dist/hooks/useLogOnce.mjs +5 -5
  353. package/dist/hooks/useLogOnce.mjs.map +1 -1
  354. package/dist/hooks/useRerender.d.mts +2 -2
  355. package/dist/hooks/useRerender.d.ts +2 -2
  356. package/dist/hooks/useSearch.d.mts +2 -2
  357. package/dist/hooks/useSearch.d.ts +2 -2
  358. package/dist/hooks/useSearch.js +1 -1
  359. package/dist/hooks/useSearch.js.map +1 -1
  360. package/dist/hooks/useSearch.mjs +1 -1
  361. package/dist/hooks/useSearch.mjs.map +1 -1
  362. package/dist/localization/LanguageProvider.d.mts +2 -2
  363. package/dist/localization/LanguageProvider.d.ts +2 -2
  364. package/dist/localization/LanguageProvider.js +2 -2
  365. package/dist/localization/LanguageProvider.js.map +1 -1
  366. package/dist/localization/LanguageProvider.mjs +2 -2
  367. package/dist/localization/LanguageProvider.mjs.map +1 -1
  368. package/dist/localization/defaults/form.d.mts +1 -0
  369. package/dist/localization/defaults/form.d.ts +1 -0
  370. package/dist/localization/defaults/form.js +2 -0
  371. package/dist/localization/defaults/form.js.map +1 -1
  372. package/dist/localization/defaults/form.mjs +2 -0
  373. package/dist/localization/defaults/form.mjs.map +1 -1
  374. package/dist/localization/useTranslation.js.map +1 -1
  375. package/dist/localization/useTranslation.mjs.map +1 -1
  376. package/dist/storybook/helper.d.mts +17 -0
  377. package/dist/storybook/helper.d.ts +17 -0
  378. package/dist/storybook/helper.js +61 -0
  379. package/dist/storybook/helper.js.map +1 -0
  380. package/dist/storybook/helper.mjs +37 -0
  381. package/dist/storybook/helper.mjs.map +1 -0
  382. package/dist/{css → style}/globals.css +836 -378
  383. package/dist/{css → style}/uncompiled/globals.css +80 -17
  384. package/dist/{css → style}/uncompiled/theme/colors-component.css +18 -4
  385. package/dist/{css → style}/uncompiled/theme/colors-semantic.css +2 -9
  386. package/dist/style/uncompiled/typography.css +171 -0
  387. package/dist/{css → style}/uncompiled/utitlity/animation.css +54 -42
  388. package/dist/{css → style}/uncompiled/utitlity/index.css +2 -1
  389. package/dist/{css → style}/uncompiled/utitlity/shadow.css +9 -1
  390. package/dist/style/uncompiled/utitlity/sizing.css +29 -0
  391. package/dist/theming/useTheme.d.mts +5 -3
  392. package/dist/theming/useTheme.d.ts +5 -3
  393. package/dist/theming/useTheme.js +42 -19
  394. package/dist/theming/useTheme.js.map +1 -1
  395. package/dist/theming/useTheme.mjs +40 -17
  396. package/dist/theming/useTheme.mjs.map +1 -1
  397. package/dist/{util → utils}/array.d.mts +1 -0
  398. package/dist/{util → utils}/array.d.ts +1 -0
  399. package/dist/{util → utils}/array.js +15 -2
  400. package/dist/utils/array.js.map +1 -0
  401. package/dist/{util → utils}/array.mjs +15 -2
  402. package/dist/utils/array.mjs.map +1 -0
  403. package/dist/utils/bagFunctions.d.mts +15 -0
  404. package/dist/utils/bagFunctions.d.ts +15 -0
  405. package/dist/{util/PropsWithFunctionChildren.js → utils/bagFunctions.js} +5 -5
  406. package/dist/utils/bagFunctions.js.map +1 -0
  407. package/dist/{util/PropsWithFunctionChildren.mjs → utils/bagFunctions.mjs} +2 -2
  408. package/dist/utils/bagFunctions.mjs.map +1 -0
  409. package/dist/{util → utils}/builder.js +1 -1
  410. package/dist/utils/builder.js.map +1 -0
  411. package/dist/{util → utils}/builder.mjs +1 -1
  412. package/dist/utils/builder.mjs.map +1 -0
  413. package/dist/{util → utils}/date.js +3 -3
  414. package/dist/utils/date.js.map +1 -0
  415. package/dist/{util → utils}/date.mjs +2 -2
  416. package/dist/utils/date.mjs.map +1 -0
  417. package/dist/{util → utils}/easeFunctions.js +5 -4
  418. package/dist/utils/easeFunctions.js.map +1 -0
  419. package/dist/{util → utils}/easeFunctions.mjs +4 -3
  420. package/dist/utils/easeFunctions.mjs.map +1 -0
  421. package/dist/{util → utils}/emailValidation.js +1 -1
  422. package/dist/utils/emailValidation.js.map +1 -0
  423. package/dist/{util → utils}/emailValidation.mjs +1 -1
  424. package/dist/utils/emailValidation.mjs.map +1 -0
  425. package/dist/{util → utils}/loopingArray.js +1 -1
  426. package/dist/utils/loopingArray.js.map +1 -0
  427. package/dist/{util → utils}/loopingArray.mjs +1 -1
  428. package/dist/utils/loopingArray.mjs.map +1 -0
  429. package/dist/utils/match.d.mts +3 -0
  430. package/dist/utils/match.d.ts +3 -0
  431. package/dist/utils/match.js +32 -0
  432. package/dist/utils/match.js.map +1 -0
  433. package/dist/utils/match.mjs +8 -0
  434. package/dist/utils/match.mjs.map +1 -0
  435. package/dist/utils/math.d.mts +3 -0
  436. package/dist/utils/math.d.ts +3 -0
  437. package/dist/{util → utils}/math.js +3 -2
  438. package/dist/utils/math.js.map +1 -0
  439. package/dist/utils/math.mjs +9 -0
  440. package/dist/utils/math.mjs.map +1 -0
  441. package/dist/{util → utils}/noop.js +1 -1
  442. package/dist/utils/noop.js.map +1 -0
  443. package/dist/utils/noop.mjs +6 -0
  444. package/dist/utils/noop.mjs.map +1 -0
  445. package/dist/{util → utils}/resolveSetState.js +1 -1
  446. package/dist/utils/resolveSetState.js.map +1 -0
  447. package/dist/{util → utils}/resolveSetState.mjs +1 -1
  448. package/dist/utils/resolveSetState.mjs.map +1 -0
  449. package/dist/{util → utils}/simpleSearch.js +1 -1
  450. package/dist/utils/simpleSearch.js.map +1 -0
  451. package/dist/{util → utils}/simpleSearch.mjs +1 -1
  452. package/dist/utils/simpleSearch.mjs.map +1 -0
  453. package/dist/{util → utils}/storage.js +1 -1
  454. package/dist/utils/storage.js.map +1 -0
  455. package/dist/{util → utils}/storage.mjs +1 -1
  456. package/dist/utils/storage.mjs.map +1 -0
  457. package/dist/{util → utils}/writeToClipboard.js +2 -1
  458. package/dist/utils/writeToClipboard.js.map +1 -0
  459. package/dist/{util → utils}/writeToClipboard.mjs +3 -1
  460. package/dist/utils/writeToClipboard.mjs.map +1 -0
  461. package/package.json +8 -8
  462. package/dist/components/dialogs/ConfirmDialog.js +0 -674
  463. package/dist/components/dialogs/ConfirmDialog.js.map +0 -1
  464. package/dist/components/dialogs/ConfirmDialog.mjs +0 -638
  465. package/dist/components/dialogs/ConfirmDialog.mjs.map +0 -1
  466. package/dist/components/icons-and-geometry/Helpwave.js.map +0 -1
  467. package/dist/components/icons-and-geometry/Helpwave.mjs.map +0 -1
  468. package/dist/components/layout-and-navigation/BreadCrumb.js.map +0 -1
  469. package/dist/components/layout-and-navigation/BreadCrumb.mjs.map +0 -1
  470. package/dist/components/layout-and-navigation/Carousel.d.mts +0 -25
  471. package/dist/components/layout-and-navigation/Carousel.d.ts +0 -25
  472. package/dist/components/layout-and-navigation/Carousel.js +0 -641
  473. package/dist/components/layout-and-navigation/Carousel.js.map +0 -1
  474. package/dist/components/layout-and-navigation/Carousel.mjs +0 -607
  475. package/dist/components/layout-and-navigation/Carousel.mjs.map +0 -1
  476. package/dist/components/layout-and-navigation/Chip.js.map +0 -1
  477. package/dist/components/layout-and-navigation/Chip.mjs.map +0 -1
  478. package/dist/components/layout-and-navigation/DividerInserter.js.map +0 -1
  479. package/dist/components/layout-and-navigation/DividerInserter.mjs.map +0 -1
  480. package/dist/components/layout-and-navigation/Expandable.js.map +0 -1
  481. package/dist/components/layout-and-navigation/Expandable.mjs.map +0 -1
  482. package/dist/components/layout-and-navigation/FAQSection.js.map +0 -1
  483. package/dist/components/layout-and-navigation/FAQSection.mjs.map +0 -1
  484. package/dist/components/layout-and-navigation/MarkdownInterpreter.js.map +0 -1
  485. package/dist/components/layout-and-navigation/MarkdownInterpreter.mjs.map +0 -1
  486. package/dist/components/layout-and-navigation/Overlay.d.mts +0 -67
  487. package/dist/components/layout-and-navigation/Overlay.d.ts +0 -67
  488. package/dist/components/layout-and-navigation/Overlay.js +0 -702
  489. package/dist/components/layout-and-navigation/Overlay.js.map +0 -1
  490. package/dist/components/layout-and-navigation/Overlay.mjs +0 -665
  491. package/dist/components/layout-and-navigation/Overlay.mjs.map +0 -1
  492. package/dist/components/layout-and-navigation/Pagination.js.map +0 -1
  493. package/dist/components/layout-and-navigation/Pagination.mjs.map +0 -1
  494. package/dist/components/layout-and-navigation/SearchableList.d.mts +0 -24
  495. package/dist/components/layout-and-navigation/SearchableList.d.ts +0 -24
  496. package/dist/components/layout-and-navigation/SearchableList.js +0 -758
  497. package/dist/components/layout-and-navigation/SearchableList.js.map +0 -1
  498. package/dist/components/layout-and-navigation/SearchableList.mjs +0 -724
  499. package/dist/components/layout-and-navigation/SearchableList.mjs.map +0 -1
  500. package/dist/components/layout-and-navigation/StepperBar.js.map +0 -1
  501. package/dist/components/layout-and-navigation/StepperBar.mjs.map +0 -1
  502. package/dist/components/layout-and-navigation/TextImage.js.map +0 -1
  503. package/dist/components/layout-and-navigation/TextImage.mjs.map +0 -1
  504. package/dist/components/layout-and-navigation/Tile.d.mts +0 -27
  505. package/dist/components/layout-and-navigation/Tile.d.ts +0 -27
  506. package/dist/components/layout-and-navigation/Tile.js +0 -96
  507. package/dist/components/layout-and-navigation/Tile.js.map +0 -1
  508. package/dist/components/layout-and-navigation/Tile.mjs +0 -61
  509. package/dist/components/layout-and-navigation/Tile.mjs.map +0 -1
  510. package/dist/components/layout-and-navigation/VerticalDivider.js.map +0 -1
  511. package/dist/components/layout-and-navigation/VerticalDivider.mjs.map +0 -1
  512. package/dist/components/modals/ConfirmModal.d.mts +0 -33
  513. package/dist/components/modals/ConfirmModal.d.ts +0 -33
  514. package/dist/components/modals/ConfirmModal.js +0 -687
  515. package/dist/components/modals/ConfirmModal.js.map +0 -1
  516. package/dist/components/modals/ConfirmModal.mjs +0 -651
  517. package/dist/components/modals/ConfirmModal.mjs.map +0 -1
  518. package/dist/components/modals/DiscardChangesModal.d.mts +0 -20
  519. package/dist/components/modals/DiscardChangesModal.d.ts +0 -20
  520. package/dist/components/modals/DiscardChangesModal.js +0 -717
  521. package/dist/components/modals/DiscardChangesModal.js.map +0 -1
  522. package/dist/components/modals/DiscardChangesModal.mjs +0 -681
  523. package/dist/components/modals/DiscardChangesModal.mjs.map +0 -1
  524. package/dist/components/modals/InputModal.d.mts +0 -21
  525. package/dist/components/modals/InputModal.d.ts +0 -21
  526. package/dist/components/modals/InputModal.js +0 -976
  527. package/dist/components/modals/InputModal.js.map +0 -1
  528. package/dist/components/modals/InputModal.mjs +0 -940
  529. package/dist/components/modals/InputModal.mjs.map +0 -1
  530. package/dist/components/modals/LanguageModal.d.mts +0 -21
  531. package/dist/components/modals/LanguageModal.d.ts +0 -21
  532. package/dist/components/modals/LanguageModal.js +0 -1468
  533. package/dist/components/modals/LanguageModal.js.map +0 -1
  534. package/dist/components/modals/LanguageModal.mjs +0 -1432
  535. package/dist/components/modals/LanguageModal.mjs.map +0 -1
  536. package/dist/components/modals/ThemeModal.d.mts +0 -21
  537. package/dist/components/modals/ThemeModal.d.ts +0 -21
  538. package/dist/components/modals/ThemeModal.js +0 -1497
  539. package/dist/components/modals/ThemeModal.js.map +0 -1
  540. package/dist/components/modals/ThemeModal.mjs +0 -1461
  541. package/dist/components/modals/ThemeModal.mjs.map +0 -1
  542. package/dist/components/user-action/Input.d.mts +0 -77
  543. package/dist/components/user-action/Input.d.ts +0 -77
  544. package/dist/components/user-action/Input.js.map +0 -1
  545. package/dist/components/user-action/Input.mjs +0 -298
  546. package/dist/components/user-action/Input.mjs.map +0 -1
  547. package/dist/components/user-action/MultiSelect.d.mts +0 -42
  548. package/dist/components/user-action/MultiSelect.d.ts +0 -42
  549. package/dist/components/user-action/MultiSelect.js +0 -1468
  550. package/dist/components/user-action/MultiSelect.js.map +0 -1
  551. package/dist/components/user-action/MultiSelect.mjs +0 -1433
  552. package/dist/components/user-action/MultiSelect.mjs.map +0 -1
  553. package/dist/components/user-action/Select.d.mts +0 -41
  554. package/dist/components/user-action/Select.d.ts +0 -41
  555. package/dist/components/user-action/Select.js +0 -1236
  556. package/dist/components/user-action/Select.js.map +0 -1
  557. package/dist/components/user-action/Select.mjs +0 -1201
  558. package/dist/components/user-action/Select.mjs.map +0 -1
  559. package/dist/components/user-action/ToggleableInput.d.mts +0 -37
  560. package/dist/components/user-action/ToggleableInput.d.ts +0 -37
  561. package/dist/components/user-action/ToggleableInput.js +0 -192
  562. package/dist/components/user-action/ToggleableInput.js.map +0 -1
  563. package/dist/components/user-action/ToggleableInput.mjs +0 -157
  564. package/dist/components/user-action/ToggleableInput.mjs.map +0 -1
  565. package/dist/css/uncompiled/textstyles.css +0 -69
  566. package/dist/hooks/useFocusManagement.js.map +0 -1
  567. package/dist/hooks/useFocusManagement.mjs.map +0 -1
  568. package/dist/hooks/useFocusOnceVisible.js.map +0 -1
  569. package/dist/hooks/useFocusOnceVisible.mjs.map +0 -1
  570. package/dist/index.d.mts +0 -103
  571. package/dist/index.d.ts +0 -103
  572. package/dist/index.js +0 -12610
  573. package/dist/index.js.map +0 -1
  574. package/dist/index.mjs +0 -12447
  575. package/dist/index.mjs.map +0 -1
  576. package/dist/util/PropsWithFunctionChildren.d.mts +0 -14
  577. package/dist/util/PropsWithFunctionChildren.d.ts +0 -14
  578. package/dist/util/PropsWithFunctionChildren.js.map +0 -1
  579. package/dist/util/PropsWithFunctionChildren.mjs.map +0 -1
  580. package/dist/util/array.js.map +0 -1
  581. package/dist/util/array.mjs.map +0 -1
  582. package/dist/util/builder.js.map +0 -1
  583. package/dist/util/builder.mjs.map +0 -1
  584. package/dist/util/date.js.map +0 -1
  585. package/dist/util/date.mjs.map +0 -1
  586. package/dist/util/easeFunctions.js.map +0 -1
  587. package/dist/util/easeFunctions.mjs.map +0 -1
  588. package/dist/util/emailValidation.js.map +0 -1
  589. package/dist/util/emailValidation.mjs.map +0 -1
  590. package/dist/util/loopingArray.js.map +0 -1
  591. package/dist/util/loopingArray.mjs.map +0 -1
  592. package/dist/util/math.d.mts +0 -3
  593. package/dist/util/math.d.ts +0 -3
  594. package/dist/util/math.js.map +0 -1
  595. package/dist/util/math.mjs +0 -8
  596. package/dist/util/math.mjs.map +0 -1
  597. package/dist/util/news.d.mts +0 -101
  598. package/dist/util/news.d.ts +0 -101
  599. package/dist/util/news.js +0 -76
  600. package/dist/util/news.js.map +0 -1
  601. package/dist/util/news.mjs +0 -49
  602. package/dist/util/news.mjs.map +0 -1
  603. package/dist/util/noop.js.map +0 -1
  604. package/dist/util/noop.mjs +0 -6
  605. package/dist/util/noop.mjs.map +0 -1
  606. package/dist/util/resolveSetState.js.map +0 -1
  607. package/dist/util/resolveSetState.mjs.map +0 -1
  608. package/dist/util/simpleSearch.js.map +0 -1
  609. package/dist/util/simpleSearch.mjs.map +0 -1
  610. package/dist/util/storage.js.map +0 -1
  611. package/dist/util/storage.mjs.map +0 -1
  612. package/dist/util/types.d.mts +0 -3
  613. package/dist/util/types.d.ts +0 -3
  614. package/dist/util/types.js +0 -18
  615. package/dist/util/types.js.map +0 -1
  616. package/dist/util/types.mjs +0 -1
  617. package/dist/util/types.mjs.map +0 -1
  618. package/dist/util/writeToClipboard.js.map +0 -1
  619. package/dist/util/writeToClipboard.mjs.map +0 -1
  620. /package/dist/components/{layout-and-navigation → layout}/DividerInserter.d.mts +0 -0
  621. /package/dist/components/{layout-and-navigation → layout}/DividerInserter.d.ts +0 -0
  622. /package/dist/components/{layout-and-navigation → layout}/FAQSection.d.mts +0 -0
  623. /package/dist/components/{layout-and-navigation → layout}/FAQSection.d.ts +0 -0
  624. /package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.d.mts +0 -0
  625. /package/dist/components/{layout-and-navigation → layout}/MarkdownInterpreter.d.ts +0 -0
  626. /package/dist/components/{layout-and-navigation → layout}/TextImage.d.mts +0 -0
  627. /package/dist/components/{layout-and-navigation → layout}/TextImage.d.ts +0 -0
  628. /package/dist/components/{layout-and-navigation → layout}/VerticalDivider.d.mts +0 -0
  629. /package/dist/components/{layout-and-navigation → layout}/VerticalDivider.d.ts +0 -0
  630. /package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.d.mts +0 -0
  631. /package/dist/components/{layout-and-navigation → navigation}/BreadCrumb.d.ts +0 -0
  632. /package/dist/components/{layout-and-navigation → navigation}/Pagination.d.mts +0 -0
  633. /package/dist/components/{layout-and-navigation → navigation}/Pagination.d.ts +0 -0
  634. /package/dist/components/{layout-and-navigation → navigation}/StepperBar.d.mts +0 -0
  635. /package/dist/components/{layout-and-navigation → navigation}/StepperBar.d.ts +0 -0
  636. /package/dist/hooks/{useFocusManagement.d.mts → focus/useFocusManagement.d.mts} +0 -0
  637. /package/dist/hooks/{useFocusManagement.d.ts → focus/useFocusManagement.d.ts} +0 -0
  638. /package/dist/hooks/{useFocusOnceVisible.d.mts → focus/useFocusOnceVisible.d.mts} +0 -0
  639. /package/dist/hooks/{useFocusOnceVisible.d.ts → focus/useFocusOnceVisible.d.ts} +0 -0
  640. /package/dist/{css → style}/uncompiled/theme/colors-basic.css +0 -0
  641. /package/dist/{css → style}/uncompiled/theme/index.css +0 -0
  642. /package/dist/{css → style}/uncompiled/theme/variants.css +0 -0
  643. /package/dist/{css → style}/uncompiled/utitlity/borderradius.css +0 -0
  644. /package/dist/{css → style}/uncompiled/utitlity/general.css +0 -0
  645. /package/dist/{util → utils}/builder.d.mts +0 -0
  646. /package/dist/{util → utils}/builder.d.ts +0 -0
  647. /package/dist/{util → utils}/date.d.mts +0 -0
  648. /package/dist/{util → utils}/date.d.ts +0 -0
  649. /package/dist/{util → utils}/easeFunctions.d.mts +0 -0
  650. /package/dist/{util → utils}/easeFunctions.d.ts +0 -0
  651. /package/dist/{util → utils}/emailValidation.d.mts +0 -0
  652. /package/dist/{util → utils}/emailValidation.d.ts +0 -0
  653. /package/dist/{util → utils}/loopingArray.d.mts +0 -0
  654. /package/dist/{util → utils}/loopingArray.d.ts +0 -0
  655. /package/dist/{util → utils}/noop.d.mts +0 -0
  656. /package/dist/{util → utils}/noop.d.ts +0 -0
  657. /package/dist/{util → utils}/resolveSetState.d.mts +0 -0
  658. /package/dist/{util → utils}/resolveSetState.d.ts +0 -0
  659. /package/dist/{util → utils}/simpleSearch.d.mts +0 -0
  660. /package/dist/{util → utils}/simpleSearch.d.ts +0 -0
  661. /package/dist/{util → utils}/storage.d.mts +0 -0
  662. /package/dist/{util → utils}/storage.d.ts +0 -0
  663. /package/dist/{util → utils}/writeToClipboard.d.mts +0 -0
  664. /package/dist/{util → utils}/writeToClipboard.d.ts +0 -0
@@ -27,14 +27,12 @@ __export(useTheme_exports, {
27
27
  module.exports = __toCommonJS(useTheme_exports);
28
28
  var import_react2 = require("react");
29
29
  var import_react3 = require("react");
30
-
31
- // src/util/noop.ts
32
- var noop = () => void 0;
30
+ var import_react4 = require("react");
33
31
 
34
32
  // src/hooks/useLocalStorage.ts
35
33
  var import_react = require("react");
36
34
 
37
- // src/util/storage.ts
35
+ // src/utils/storage.ts
38
36
  var StorageService = class {
39
37
  // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript
40
38
  constructor(storage) {
@@ -63,7 +61,7 @@ var LocalStorageService = class extends StorageService {
63
61
  }
64
62
  };
65
63
 
66
- // src/util/resolveSetState.ts
64
+ // src/utils/resolveSetState.ts
67
65
  function resolveSetState(action, prev) {
68
66
  return typeof action === "function" ? action(prev) : action;
69
67
  }
@@ -115,30 +113,55 @@ var ThemeUtil = {
115
113
  themes,
116
114
  translation: defaultThemeTypeTranslation
117
115
  };
118
- var ThemeContext = (0, import_react3.createContext)({
119
- theme: "light",
120
- setTheme: noop
121
- });
116
+ var ThemeContext = (0, import_react4.createContext)(null);
122
117
  var ThemeProvider = ({ children, initialTheme }) => {
123
118
  const [storedTheme, setStoredTheme] = useLocalStorage("theme", initialTheme ?? "system");
124
- const [userTheme, setUserTheme] = (0, import_react3.useState)();
125
- (0, import_react3.useEffect)(() => {
119
+ const [themePreference, setThemePreference] = (0, import_react4.useState)("system");
120
+ const resolvedTheme = (0, import_react3.useMemo)(() => {
121
+ if (storedTheme && storedTheme !== "system") {
122
+ return storedTheme;
123
+ }
124
+ return themePreference === "dark" ? "dark" : "light";
125
+ }, [storedTheme, themePreference]);
126
+ (0, import_react4.useEffect)(() => {
126
127
  if (!!initialTheme && storedTheme !== initialTheme) {
127
128
  console.warn("ThemeProvider initial state changed: Prefer using useTheme's setTheme instead");
128
129
  setStoredTheme(initialTheme);
129
130
  }
130
131
  }, [initialTheme]);
131
- const usedTheme = (0, import_react2.useMemo)(() => storedTheme !== "system" ? storedTheme : userTheme, [storedTheme, userTheme]);
132
- (0, import_react3.useEffect)(() => {
133
- document.documentElement.setAttribute("data-theme", usedTheme);
134
- }, [usedTheme]);
135
- (0, import_react3.useEffect)(() => {
132
+ (0, import_react4.useEffect)(() => {
133
+ document.documentElement.setAttribute("data-theme", resolvedTheme);
134
+ }, [resolvedTheme]);
135
+ const getPreference = (0, import_react2.useCallback)(() => {
136
136
  const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
137
- setUserTheme(prefersDark ? "dark" : "light");
137
+ const prefersLight = window.matchMedia("(prefers-color-scheme: light)").matches;
138
+ setThemePreference(prefersDark ? "dark" : prefersLight ? "light" : "system");
138
139
  }, []);
139
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: { theme: storedTheme, setTheme: setStoredTheme }, children });
140
+ (0, import_react4.useEffect)(() => {
141
+ getPreference();
142
+ }, [getPreference]);
143
+ (0, import_react4.useEffect)(() => {
144
+ const darkQuery = window.matchMedia("(prefers-color-scheme: dark)");
145
+ const lightQuery = window.matchMedia("(prefers-color-scheme: light)");
146
+ const noPrefQuery = window.matchMedia("(prefers-color-scheme: no-preference)");
147
+ darkQuery.addEventListener("change", getPreference);
148
+ lightQuery.addEventListener("change", getPreference);
149
+ noPrefQuery.addEventListener("change", getPreference);
150
+ return () => {
151
+ darkQuery.removeEventListener("change", getPreference);
152
+ lightQuery.removeEventListener("change", getPreference);
153
+ noPrefQuery.removeEventListener("change", getPreference);
154
+ };
155
+ }, [getPreference]);
156
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: { theme: storedTheme, resolvedTheme, setTheme: setStoredTheme }, children });
157
+ };
158
+ var useTheme = () => {
159
+ const context = (0, import_react4.useContext)(ThemeContext);
160
+ if (!context) {
161
+ throw new Error("useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.");
162
+ }
163
+ return context;
140
164
  };
141
- var useTheme = () => (0, import_react3.useContext)(ThemeContext);
142
165
  // Annotate the CommonJS export names for ESM import in node:
143
166
  0 && (module.exports = {
144
167
  ThemeContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/util/noop.ts","../../src/hooks/useLocalStorage.ts","../../src/util/storage.ts","../../src/util/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { useMemo } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { noop } from '../util/noop'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType>({\n theme: 'light',\n setTheme: noop\n})\n\ntype ThemeProviderProps = {\n initialTheme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, initialTheme }: PropsWithChildren<ThemeProviderProps>) => {\n const [storedTheme, setStoredTheme] = useLocalStorage<ThemeType>('theme', initialTheme ?? 'system')\n const [userTheme, setUserTheme] = useState<ThemeType>()\n\n useEffect(() => {\n if (!!initialTheme && storedTheme !== initialTheme) {\n console.warn('ThemeProvider initial state changed: Prefer using useTheme\\'s setTheme instead')\n setStoredTheme(initialTheme)\n }\n }, [initialTheme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const usedTheme = useMemo(() => storedTheme !== 'system' ? storedTheme : userTheme, [storedTheme, userTheme])\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', usedTheme)\n }, [usedTheme])\n\n useEffect(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n setUserTheme(prefersDark ? 'dark' : 'light')\n }, [])\n\n return (\n <ThemeContext.Provider value={{ theme: storedTheme, setTheme: setStoredTheme }}>\n {children}\n </ThemeContext.Provider>\n )\n}\n\n\nexport const useTheme = () => useContext(ThemeContext)\n","export const noop = () => undefined\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '../util/storage'\nimport { resolveSetState } from '../util/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n return [storedValue, setValue]\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAAwB;AACxB,IAAAA,gBAA+D;;;ACFxD,IAAM,OAA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O,IAAM,WAAW,UAAM,0BAAW,YAAY;","names":["import_react"]}
1
+ {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { useCallback } from 'react'\nimport { useMemo } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n initialTheme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, initialTheme }: PropsWithChildren<ThemeProviderProps>) => {\n const [storedTheme, setStoredTheme] = useLocalStorage<ThemeType>('theme', initialTheme ?? 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo(() => {\n if(storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n return themePreference === 'dark' ? 'dark' : 'light'\n }, [storedTheme, themePreference])\n\n useEffect(() => {\n if (!!initialTheme && storedTheme !== initialTheme) {\n console.warn('ThemeProvider initial state changed: Prefer using useTheme\\'s setTheme instead')\n setStoredTheme(initialTheme)\n }\n }, [initialTheme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider value={{ theme: storedTheme, resolvedTheme, setTheme: setStoredTheme }}>\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if(!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n return [storedValue, setValue]\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAA4B;AAC5B,IAAAA,gBAAwB;AACxB,IAAAA,gBAA+D;;;ACA/D,mBAAsC;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EA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a;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,OAAO,aAAa,eAAe,UAAU,eAAe,GACzF,UACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,cAAU,0BAAW,YAAY;AACvC,MAAG,CAAC,SAAS;AACX,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["import_react"]}
@@ -1,14 +1,12 @@
1
1
  // src/theming/useTheme.tsx
2
+ import { useCallback as useCallback2 } from "react";
2
3
  import { useMemo } from "react";
3
4
  import { createContext, useContext, useEffect, useState as useState2 } from "react";
4
5
 
5
- // src/util/noop.ts
6
- var noop = () => void 0;
7
-
8
6
  // src/hooks/useLocalStorage.ts
9
7
  import { useCallback, useState } from "react";
10
8
 
11
- // src/util/storage.ts
9
+ // src/utils/storage.ts
12
10
  var StorageService = class {
13
11
  // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript
14
12
  constructor(storage) {
@@ -37,7 +35,7 @@ var LocalStorageService = class extends StorageService {
37
35
  }
38
36
  };
39
37
 
40
- // src/util/resolveSetState.ts
38
+ // src/utils/resolveSetState.ts
41
39
  function resolveSetState(action, prev) {
42
40
  return typeof action === "function" ? action(prev) : action;
43
41
  }
@@ -89,30 +87,55 @@ var ThemeUtil = {
89
87
  themes,
90
88
  translation: defaultThemeTypeTranslation
91
89
  };
92
- var ThemeContext = createContext({
93
- theme: "light",
94
- setTheme: noop
95
- });
90
+ var ThemeContext = createContext(null);
96
91
  var ThemeProvider = ({ children, initialTheme }) => {
97
92
  const [storedTheme, setStoredTheme] = useLocalStorage("theme", initialTheme ?? "system");
98
- const [userTheme, setUserTheme] = useState2();
93
+ const [themePreference, setThemePreference] = useState2("system");
94
+ const resolvedTheme = useMemo(() => {
95
+ if (storedTheme && storedTheme !== "system") {
96
+ return storedTheme;
97
+ }
98
+ return themePreference === "dark" ? "dark" : "light";
99
+ }, [storedTheme, themePreference]);
99
100
  useEffect(() => {
100
101
  if (!!initialTheme && storedTheme !== initialTheme) {
101
102
  console.warn("ThemeProvider initial state changed: Prefer using useTheme's setTheme instead");
102
103
  setStoredTheme(initialTheme);
103
104
  }
104
105
  }, [initialTheme]);
105
- const usedTheme = useMemo(() => storedTheme !== "system" ? storedTheme : userTheme, [storedTheme, userTheme]);
106
- useEffect(() => {
107
- document.documentElement.setAttribute("data-theme", usedTheme);
108
- }, [usedTheme]);
109
106
  useEffect(() => {
107
+ document.documentElement.setAttribute("data-theme", resolvedTheme);
108
+ }, [resolvedTheme]);
109
+ const getPreference = useCallback2(() => {
110
110
  const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
111
- setUserTheme(prefersDark ? "dark" : "light");
111
+ const prefersLight = window.matchMedia("(prefers-color-scheme: light)").matches;
112
+ setThemePreference(prefersDark ? "dark" : prefersLight ? "light" : "system");
112
113
  }, []);
113
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { theme: storedTheme, setTheme: setStoredTheme }, children });
114
+ useEffect(() => {
115
+ getPreference();
116
+ }, [getPreference]);
117
+ useEffect(() => {
118
+ const darkQuery = window.matchMedia("(prefers-color-scheme: dark)");
119
+ const lightQuery = window.matchMedia("(prefers-color-scheme: light)");
120
+ const noPrefQuery = window.matchMedia("(prefers-color-scheme: no-preference)");
121
+ darkQuery.addEventListener("change", getPreference);
122
+ lightQuery.addEventListener("change", getPreference);
123
+ noPrefQuery.addEventListener("change", getPreference);
124
+ return () => {
125
+ darkQuery.removeEventListener("change", getPreference);
126
+ lightQuery.removeEventListener("change", getPreference);
127
+ noPrefQuery.removeEventListener("change", getPreference);
128
+ };
129
+ }, [getPreference]);
130
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { theme: storedTheme, resolvedTheme, setTheme: setStoredTheme }, children });
131
+ };
132
+ var useTheme = () => {
133
+ const context = useContext(ThemeContext);
134
+ if (!context) {
135
+ throw new Error("useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.");
136
+ }
137
+ return context;
114
138
  };
115
- var useTheme = () => useContext(ThemeContext);
116
139
  export {
117
140
  ThemeContext,
118
141
  ThemeProvider,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/util/noop.ts","../../src/hooks/useLocalStorage.ts","../../src/util/storage.ts","../../src/util/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { useMemo } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { noop } from '../util/noop'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType>({\n theme: 'light',\n setTheme: noop\n})\n\ntype ThemeProviderProps = {\n initialTheme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, initialTheme }: PropsWithChildren<ThemeProviderProps>) => {\n const [storedTheme, setStoredTheme] = useLocalStorage<ThemeType>('theme', initialTheme ?? 'system')\n const [userTheme, setUserTheme] = useState<ThemeType>()\n\n useEffect(() => {\n if (!!initialTheme && storedTheme !== initialTheme) {\n console.warn('ThemeProvider initial state changed: Prefer using useTheme\\'s setTheme instead')\n setStoredTheme(initialTheme)\n }\n }, [initialTheme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const usedTheme = useMemo(() => storedTheme !== 'system' ? storedTheme : userTheme, [storedTheme, userTheme])\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', usedTheme)\n }, [usedTheme])\n\n useEffect(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n setUserTheme(prefersDark ? 'dark' : 'light')\n }, [])\n\n return (\n <ThemeContext.Provider value={{ theme: storedTheme, setTheme: setStoredTheme }}>\n {children}\n </ThemeContext.Provider>\n )\n}\n\n\nexport const useTheme = () => useContext(ThemeContext)\n","export const noop = () => undefined\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '../util/storage'\nimport { resolveSetState } from '../util/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n return [storedValue, setValue]\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,eAAe,YAAY,WAAW,YAAAA,iBAAgB;;;ACFxD,IAAM,OAAO,MAAM;;;ACG1B,SAAS,aAAa,gBAAgB;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EAEO,YAAY;AACjB,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;AAEO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,cAAc;AACZ,UAAM,OAAO,YAAY;AAAA,EAC3B;AACF;;;AC7BO,SAAS,gBAAmB,QAA2B,MAAY;AACxE,SAAO,OAAO,WAAW,aAAc,OAA0B,IAAI,IAAI;AAC3E;;;AFIO,IAAM,kBAAkB,CAAI,KAAa,cAAmC;AACjF,QAAM,MAAM,YAAY,MAAS;AAC/B,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AACA,UAAM,iBAAiB,IAAI,oBAAoB;AAC/C,UAAM,QAAQ,eAAe,IAAO,GAAG;AACvC,WAAO,SAAS;AAAA,EAClB,GAAG,CAAC,WAAW,GAAG,CAAC;AAEnB,QAAM,CAAC,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S;AAAA,EAC/D,GAAG,CAAC,SAAS,CAAC;AAEd,YAAU,MAAM;AACd,UAAM,cAAc,OAAO,WAAW,8BAA8B,EAAE;AACtE,iBAAa,cAAc,SAAS,OAAO;AAAA,EAC7C,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,OAAO,aAAa,UAAU,eAAe,GAC1E,UACH;AAEJ;AAGO,IAAM,WAAW,MAAM,WAAW,YAAY;","names":["useState","useState"]}
1
+ {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { useCallback } from 'react'\nimport { useMemo } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n initialTheme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, initialTheme }: PropsWithChildren<ThemeProviderProps>) => {\n const [storedTheme, setStoredTheme] = useLocalStorage<ThemeType>('theme', initialTheme ?? 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo(() => {\n if(storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n return themePreference === 'dark' ? 'dark' : 'light'\n }, [storedTheme, themePreference])\n\n useEffect(() => {\n if (!!initialTheme && storedTheme !== initialTheme) {\n console.warn('ThemeProvider initial state changed: Prefer using useTheme\\'s setTheme instead')\n setStoredTheme(initialTheme)\n }\n }, [initialTheme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider value={{ theme: storedTheme, resolvedTheme, setTheme: setStoredTheme }}>\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if(!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n return [storedValue, setValue]\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";AACA,SAAS,eAAAA,oBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,eAAe,YAAY,WAAW,YAAAC,iBAAgB;;;ACA/D,SAAS,aAAa,gBAAgB;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAA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C;AAC7E,cAAU,iBAAiB,UAAU,aAAa;AAClD,eAAW,iBAAiB,UAAU,aAAa;AACnD,gBAAY,iBAAiB,UAAU,aAAa;AACpD,WAAO,MAAM;AACX,gBAAU,oBAAoB,UAAU,aAAa;AACrD,iBAAW,oBAAoB,UAAU,aAAa;AACtD,kBAAY,oBAAoB,UAAU,aAAa;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,OAAO,aAAa,eAAe,UAAU,eAAe,GACzF,UACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,UAAU,WAAW,YAAY;AACvC,MAAG,CAAC,SAAS;AACX,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["useCallback","useState","useState","useCallback"]}
@@ -26,6 +26,7 @@ declare const createLoopingList: <T>(list: T[], startIndex?: number, length?: nu
26
26
  declare const ArrayUtil: {
27
27
  unique: <T>(list: T[]) => T[];
28
28
  difference: <T>(list: T[], removeList: T[]) => T[];
29
+ moveItems: <T>(list: T[], move?: number) => any[];
29
30
  };
30
31
 
31
32
  export { ArrayUtil, type RangeOptions, closestMatch, createLoopingList, createLoopingListWithIndex, equalSizeGroups, getNeighbours, range };
@@ -26,6 +26,7 @@ declare const createLoopingList: <T>(list: T[], startIndex?: number, length?: nu
26
26
  declare const ArrayUtil: {
27
27
  unique: <T>(list: T[]) => T[];
28
28
  difference: <T>(list: T[], removeList: T[]) => T[];
29
+ moveItems: <T>(list: T[], move?: number) => any[];
29
30
  };
30
31
 
31
32
  export { ArrayUtil, type RangeOptions, closestMatch, createLoopingList, createLoopingListWithIndex, equalSizeGroups, getNeighbours, range };
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/util/array.ts
19
+ // src/utils/array.ts
20
20
  var array_exports = {};
21
21
  __export(array_exports, {
22
22
  ArrayUtil: () => ArrayUtil,
@@ -121,6 +121,18 @@ var createLoopingListWithIndex = (list, startIndex = 0, length = 0, forwards = t
121
121
  var createLoopingList = (list, startIndex = 0, length = 0, forwards = true) => {
122
122
  return createLoopingListWithIndex(list, startIndex, length, forwards).map(([_, item]) => item);
123
123
  };
124
+ var moveItems = (list, move = 0) => {
125
+ const result = [];
126
+ let start = move;
127
+ if (start < 0) {
128
+ start = list.length - move;
129
+ }
130
+ start = start % list.length;
131
+ for (let i = 0; i < list.length; i++) {
132
+ result[i] = list[(i + start) % list.length];
133
+ }
134
+ return result;
135
+ };
124
136
  var ArrayUtil = {
125
137
  unique: (list) => {
126
138
  const seen = /* @__PURE__ */ new Set();
@@ -135,7 +147,8 @@ var ArrayUtil = {
135
147
  difference: (list, removeList) => {
136
148
  const remove = new Set(removeList);
137
149
  return list.filter((item) => !remove.has(item));
138
- }
150
+ },
151
+ moveItems
139
152
  };
140
153
  // Annotate the CommonJS export names for ESM import in node:
141
154
  0 && (module.exports = {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/array.ts"],"sourcesContent":["export const equalSizeGroups = <T>(array: T[], groupSize: number): T[][] => {\n if (groupSize <= 0) {\n console.warn(`group size should be greater than 0: groupSize = ${groupSize}`)\n return [[...array]]\n }\n\n const groups = []\n for (let i = 0; i < array.length; i += groupSize) {\n groups.push(array.slice(i, Math.min(i + groupSize, array.length)))\n }\n return groups\n}\n\nexport type RangeOptions = {\n /** Whether the range can be defined empty via end < start without a warning */\n allowEmptyRange: boolean,\n stepSize: number,\n exclusiveStart: boolean,\n exclusiveEnd: boolean,\n}\n\nconst defaultRangeOptions: RangeOptions = {\n allowEmptyRange: false,\n stepSize: 1,\n exclusiveStart: false,\n exclusiveEnd: true,\n}\n\n/**\n * @param endOrRange The end value or a range [start, end], end is exclusive\n * @param options the options for defining the range\n */\nexport const range = (endOrRange: number | [number, number], options?: Partial<RangeOptions>): number[] => {\n const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options }\n let start = 0\n let end: number\n if (typeof endOrRange === 'number') {\n end = endOrRange\n } else {\n start = endOrRange[0]\n end = endOrRange[1]\n }\n if (!exclusiveEnd) {\n end -= 1\n }\n if (exclusiveStart) {\n start += 1\n }\n\n if (end - 1 < start) {\n if (!allowEmptyRange) {\n console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`)\n }\n return []\n }\n return Array.from({ length: end - start }, (_, index) => index * stepSize + start)\n}\n\n/** Finds the closest match\n * @param list The list of all possible matches\n * @param firstCloser Return whether item1 is closer than item2\n */\nexport const closestMatch = <T>(list: T[], firstCloser: (item1: T, item2: T) => boolean) => {\n return list.reduce((item1, item2) => {\n return firstCloser(item1, item2) ? item1 : item2\n })\n}\n\n/**\n * returns the item in middle of a list and its neighbours before and after\n * e.g. [1,2,3,4,5,6] for item = 1 would return [5,6,1,2,3]\n */\nexport const getNeighbours = <T>(list: T[], item: T, neighbourDistance: number = 2) => {\n const index = list.indexOf(item)\n const totalItems = neighbourDistance * 2 + 1\n if (list.length < totalItems) {\n console.warn('List is to short')\n return list\n }\n\n if (index === -1) {\n console.error('item not found in list')\n return list.splice(0, totalItems)\n }\n\n let start = index - neighbourDistance\n if (start < 0) {\n start += list.length\n }\n const end = (index + neighbourDistance + 1) % list.length\n\n const result: T[] = []\n let ignoreOnce = list.length === totalItems\n for (let i = start; i !== end || ignoreOnce; i = (i + 1) % list.length) {\n result.push(list[i]!)\n if (end === i && ignoreOnce) {\n ignoreOnce = false\n }\n }\n return result\n}\n\nexport const createLoopingListWithIndex = <T>(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n if (length < 0) {\n console.warn(`createLoopingList: length must be >= 0, given ${length}`)\n } else if (length === 0) {\n length = list.length\n }\n\n const returnList: [number, T][] = []\n\n if (forwards) {\n for (let i = startIndex; returnList.length < length; i = (i + 1) % list.length) {\n returnList.push([i, list[i]!])\n }\n } else {\n for (let i = startIndex; returnList.length < length; i = i === 0 ? i = list.length - 1 : i - 1) {\n returnList.push([i, list[i]!])\n }\n }\n\n return returnList\n}\n\nexport const createLoopingList = <T>(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n return createLoopingListWithIndex(list, startIndex, length, forwards).map(([_, item]) => item)\n}\n\n/**\n * @param list The list to be changed\n * @param move The shifting applied to the array (can be negative)\n */\nconst moveItems = <T>(list: T[], move: number = 0) => {\n const result = []\n let start = move\n if (start < 0) {\n start = list.length - move\n }\n start = start % list.length\n for (let i = 0; i < list.length; i++) {\n result[i] = list[(i + start) % list.length]\n }\n return result\n}\n\nexport const ArrayUtil = {\n unique: <T>(list: T[]): T[] => {\n const seen = new Set<T>()\n return list.filter((item) => {\n if (seen.has(item)) {\n return false\n }\n seen.add(item)\n return true\n })\n },\n difference: <T>(list: T[], removeList: T[]): T[] => {\n const remove = new Set<T>(removeList)\n return list.filter((item) => !remove.has(item))\n },\n moveItems,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,kBAAkB,CAAI,OAAY,cAA6B;AAC1E,MAAI,aAAa,GAAG;AAClB,YAAQ,KAAK,oDAAoD,SAAS,EAAE;AAC5E,WAAO,CAAC,CAAC,GAAG,KAAK,CAAC;AAAA,EACpB;AAEA,QAAM,SAAS,CAAC;AAChB,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,WAAW;AAChD,WAAO,KAAK,MAAM,MAAM,GAAG,KAAK,IAAI,IAAI,WAAW,MAAM,MAAM,CAAC,CAAC;AAAA,EACnE;AACA,SAAO;AACT;AAUA,IAAM,sBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,cAAc;AAChB;AAMO,IAAM,QAAQ,CAAC,YAAuC,YAA8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A,SAAO;AACT;AAEO,IAAM,YAAY;AAAA,EACvB,QAAQ,CAAI,SAAmB;AAC7B,UAAM,OAAO,oBAAI,IAAO;AACxB,WAAO,KAAK,OAAO,CAAC,SAAS;AAC3B,UAAI,KAAK,IAAI,IAAI,GAAG;AAClB,eAAO;AAAA,MACT;AACA,WAAK,IAAI,IAAI;AACb,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EACA,YAAY,CAAI,MAAW,eAAyB;AAClD,UAAM,SAAS,IAAI,IAAO,UAAU;AACpC,WAAO,KAAK,OAAO,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC;AAAA,EAChD;AAAA,EACA;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- // src/util/array.ts
1
+ // src/utils/array.ts
2
2
  var equalSizeGroups = (array, groupSize) => {
3
3
  if (groupSize <= 0) {
4
4
  console.warn(`group size should be greater than 0: groupSize = ${groupSize}`);
@@ -92,6 +92,18 @@ var createLoopingListWithIndex = (list, startIndex = 0, length = 0, forwards = t
92
92
  var createLoopingList = (list, startIndex = 0, length = 0, forwards = true) => {
93
93
  return createLoopingListWithIndex(list, startIndex, length, forwards).map(([_, item]) => item);
94
94
  };
95
+ var moveItems = (list, move = 0) => {
96
+ const result = [];
97
+ let start = move;
98
+ if (start < 0) {
99
+ start = list.length - move;
100
+ }
101
+ start = start % list.length;
102
+ for (let i = 0; i < list.length; i++) {
103
+ result[i] = list[(i + start) % list.length];
104
+ }
105
+ return result;
106
+ };
95
107
  var ArrayUtil = {
96
108
  unique: (list) => {
97
109
  const seen = /* @__PURE__ */ new Set();
@@ -106,7 +118,8 @@ var ArrayUtil = {
106
118
  difference: (list, removeList) => {
107
119
  const remove = new Set(removeList);
108
120
  return list.filter((item) => !remove.has(item));
109
- }
121
+ },
122
+ moveItems
110
123
  };
111
124
  export {
112
125
  ArrayUtil,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/array.ts"],"sourcesContent":["export const equalSizeGroups = <T>(array: T[], groupSize: number): T[][] => {\n if (groupSize <= 0) {\n console.warn(`group size should be greater than 0: groupSize = ${groupSize}`)\n return [[...array]]\n }\n\n const groups = []\n for (let i = 0; i < array.length; i += groupSize) {\n groups.push(array.slice(i, Math.min(i + groupSize, array.length)))\n }\n return groups\n}\n\nexport type RangeOptions = {\n /** Whether the range can be defined empty via end < start without a warning */\n allowEmptyRange: boolean,\n stepSize: number,\n exclusiveStart: boolean,\n exclusiveEnd: boolean,\n}\n\nconst defaultRangeOptions: RangeOptions = {\n allowEmptyRange: false,\n stepSize: 1,\n exclusiveStart: false,\n exclusiveEnd: true,\n}\n\n/**\n * @param endOrRange The end value or a range [start, end], end is exclusive\n * @param options the options for defining the range\n */\nexport const range = (endOrRange: number | [number, number], options?: Partial<RangeOptions>): number[] => {\n const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options }\n let start = 0\n let end: number\n if (typeof endOrRange === 'number') {\n end = endOrRange\n } else {\n start = endOrRange[0]\n end = endOrRange[1]\n }\n if (!exclusiveEnd) {\n end -= 1\n }\n if (exclusiveStart) {\n start += 1\n }\n\n if (end - 1 < start) {\n if (!allowEmptyRange) {\n console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`)\n }\n return []\n }\n return Array.from({ length: end - start }, (_, index) => index * stepSize + start)\n}\n\n/** Finds the closest match\n * @param list The list of all possible matches\n * @param firstCloser Return whether item1 is closer than item2\n */\nexport const closestMatch = <T>(list: T[], firstCloser: (item1: T, item2: T) => boolean) => {\n return list.reduce((item1, item2) => {\n return firstCloser(item1, item2) ? item1 : item2\n })\n}\n\n/**\n * returns the item in middle of a list and its neighbours before and after\n * e.g. [1,2,3,4,5,6] for item = 1 would return [5,6,1,2,3]\n */\nexport const getNeighbours = <T>(list: T[], item: T, neighbourDistance: number = 2) => {\n const index = list.indexOf(item)\n const totalItems = neighbourDistance * 2 + 1\n if (list.length < totalItems) {\n console.warn('List is to short')\n return list\n }\n\n if (index === -1) {\n console.error('item not found in list')\n return list.splice(0, totalItems)\n }\n\n let start = index - neighbourDistance\n if (start < 0) {\n start += list.length\n }\n const end = (index + neighbourDistance + 1) % list.length\n\n const result: T[] = []\n let ignoreOnce = list.length === totalItems\n for (let i = start; i !== end || ignoreOnce; i = (i + 1) % list.length) {\n result.push(list[i]!)\n if (end === i && ignoreOnce) {\n ignoreOnce = false\n }\n }\n return result\n}\n\nexport const createLoopingListWithIndex = <T>(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n if (length < 0) {\n console.warn(`createLoopingList: length must be >= 0, given ${length}`)\n } else if (length === 0) {\n length = list.length\n }\n\n const returnList: [number, T][] = []\n\n if (forwards) {\n for (let i = startIndex; returnList.length < length; i = (i + 1) % list.length) {\n returnList.push([i, list[i]!])\n }\n } else {\n for (let i = startIndex; returnList.length < length; i = i === 0 ? i = list.length - 1 : i - 1) {\n returnList.push([i, list[i]!])\n }\n }\n\n return returnList\n}\n\nexport const createLoopingList = <T>(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n return createLoopingListWithIndex(list, startIndex, length, forwards).map(([_, item]) => item)\n}\n\n/**\n * @param list The list to be changed\n * @param move The shifting applied to the array (can be negative)\n */\nconst moveItems = <T>(list: T[], move: number = 0) => {\n const result = []\n let start = move\n if (start < 0) {\n start = list.length - move\n }\n start = start % list.length\n for (let i = 0; i < list.length; i++) {\n result[i] = list[(i + start) % list.length]\n }\n return result\n}\n\nexport const ArrayUtil = {\n unique: <T>(list: T[]): T[] => {\n const seen = new Set<T>()\n return list.filter((item) => {\n if (seen.has(item)) {\n return false\n }\n seen.add(item)\n return true\n })\n },\n difference: <T>(list: T[], removeList: T[]): T[] => {\n const remove = new Set<T>(removeList)\n return list.filter((item) => !remove.has(item))\n },\n moveItems,\n}\n"],"mappings":";AAAO,IAAM,kBAAkB,CAAI,OAAY,cAA6B;AAC1E,MAAI,aAAa,GAAG;AAClB,YAAQ,KAAK,oDAA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B,SAAS;AACvH,SAAO,2BAA2B,MAAM,YAAY,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,IAAI;AAC/F;AAMA,IAAM,YAAY,CAAI,MAAW,OAAe,MAAM;AACpD,QAAM,SAAS,CAAC;AAChB,MAAI,QAAQ;AACZ,MAAI,QAAQ,GAAG;AACb,YAAQ,KAAK,SAAS;AAAA,EACxB;AACA,UAAQ,QAAQ,KAAK;AACrB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,WAAO,CAAC,IAAI,MAAM,IAAI,SAAS,KAAK,MAAM;AAAA,EAC5C;AACA,SAAO;AACT;AAEO,IAAM,YAAY;AAAA,EACvB,QAAQ,CAAI,SAAmB;AAC7B,UAAM,OAAO,oBAAI,IAAO;AACxB,WAAO,KAAK,OAAO,CAAC,SAAS;AAC3B,UAAI,KAAK,IAAI,IAAI,GAAG;AAClB,eAAO;AAAA,MACT;AACA,WAAK,IAAI,IAAI;AACb,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EACA,YAAY,CAAI,MAAW,eAAyB;AAClD,UAAM,SAAS,IAAI,IAAO,UAAU;AACpC,WAAO,KAAK,OAAO,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC;AAAA,EAChD;AAAA,EACA;AACF;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type BagFunction<T> = (bag: T) => ReactNode;
4
+ type BagFunctionOrNode<T> = BagFunction<T> | ReactNode;
5
+ type PropsWithBagFunction<T, P = unknown> = P & {
6
+ children?: BagFunction<T>;
7
+ };
8
+ type PropsWithBagFunctionOrChildren<T, P = unknown> = P & {
9
+ children?: BagFunctionOrNode<T>;
10
+ };
11
+ declare const BagFunctionUtil: {
12
+ resolve: <T>(children: BagFunctionOrNode<T>, bag: T) => ReactNode;
13
+ };
14
+
15
+ export { type BagFunction, type BagFunctionOrNode, BagFunctionUtil, type PropsWithBagFunction, type PropsWithBagFunctionOrChildren };
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type BagFunction<T> = (bag: T) => ReactNode;
4
+ type BagFunctionOrNode<T> = BagFunction<T> | ReactNode;
5
+ type PropsWithBagFunction<T, P = unknown> = P & {
6
+ children?: BagFunction<T>;
7
+ };
8
+ type PropsWithBagFunctionOrChildren<T, P = unknown> = P & {
9
+ children?: BagFunctionOrNode<T>;
10
+ };
11
+ declare const BagFunctionUtil: {
12
+ resolve: <T>(children: BagFunctionOrNode<T>, bag: T) => ReactNode;
13
+ };
14
+
15
+ export { type BagFunction, type BagFunctionOrNode, BagFunctionUtil, type PropsWithBagFunction, type PropsWithBagFunctionOrChildren };
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/util/PropsWithFunctionChildren.ts
20
- var PropsWithFunctionChildren_exports = {};
21
- __export(PropsWithFunctionChildren_exports, {
19
+ // src/utils/bagFunctions.ts
20
+ var bagFunctions_exports = {};
21
+ __export(bagFunctions_exports, {
22
22
  BagFunctionUtil: () => BagFunctionUtil
23
23
  });
24
- module.exports = __toCommonJS(PropsWithFunctionChildren_exports);
24
+ module.exports = __toCommonJS(bagFunctions_exports);
25
25
  var resolve = (children, bag) => {
26
26
  if (typeof children === "function") {
27
27
  return children(bag);
@@ -35,4 +35,4 @@ var BagFunctionUtil = {
35
35
  0 && (module.exports = {
36
36
  BagFunctionUtil
37
37
  });
38
- //# sourceMappingURL=PropsWithFunctionChildren.js.map
38
+ //# sourceMappingURL=bagFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/bagFunctions.ts"],"sourcesContent":["import type { ReactNode } from 'react'\n\nexport type BagFunction<T> = (bag: T) => ReactNode\n\nexport type BagFunctionOrNode<T> = BagFunction<T> | ReactNode\n\nexport type PropsWithBagFunction<T, P = unknown> = P & { children?: BagFunction<T> }\n\nexport type PropsWithBagFunctionOrChildren<T, P = unknown> = P & { children?: BagFunctionOrNode<T> }\n\nconst resolve = <T>(children: BagFunctionOrNode<T>, bag: T): ReactNode => {\n if (typeof children === 'function') {\n return (children as BagFunction<T>)(bag)\n }\n\n return children ?? undefined\n}\n\nexport const BagFunctionUtil = {\n resolve\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,IAAM,UAAU,CAAI,UAAiC,QAAsB;AACzE,MAAI,OAAO,aAAa,YAAY;AAClC,WAAQ,SAA4B,GAAG;AAAA,EACzC;AAEA,SAAO,YAAY;AACrB;AAEO,IAAM,kBAAkB;AAAA,EAC7B;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- // src/util/PropsWithFunctionChildren.ts
1
+ // src/utils/bagFunctions.ts
2
2
  var resolve = (children, bag) => {
3
3
  if (typeof children === "function") {
4
4
  return children(bag);
@@ -11,4 +11,4 @@ var BagFunctionUtil = {
11
11
  export {
12
12
  BagFunctionUtil
13
13
  };
14
- //# sourceMappingURL=PropsWithFunctionChildren.mjs.map
14
+ //# sourceMappingURL=bagFunctions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/bagFunctions.ts"],"sourcesContent":["import type { ReactNode } from 'react'\n\nexport type BagFunction<T> = (bag: T) => ReactNode\n\nexport type BagFunctionOrNode<T> = BagFunction<T> | ReactNode\n\nexport type PropsWithBagFunction<T, P = unknown> = P & { children?: BagFunction<T> }\n\nexport type PropsWithBagFunctionOrChildren<T, P = unknown> = P & { children?: BagFunctionOrNode<T> }\n\nconst resolve = <T>(children: BagFunctionOrNode<T>, bag: T): ReactNode => {\n if (typeof children === 'function') {\n return (children as BagFunction<T>)(bag)\n }\n\n return children ?? undefined\n}\n\nexport const BagFunctionUtil = {\n resolve\n}"],"mappings":";AAUA,IAAM,UAAU,CAAI,UAAiC,QAAsB;AACzE,MAAI,OAAO,aAAa,YAAY;AAClC,WAAQ,SAA4B,GAAG;AAAA,EACzC;AAEA,SAAO,YAAY;AACrB;AAEO,IAAM,kBAAkB;AAAA,EAC7B;AACF;","names":[]}
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/util/builder.ts
19
+ // src/utils/builder.ts
20
20
  var builder_exports = {};
21
21
  __export(builder_exports, {
22
22
  builder: () => builder
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/builder.ts"],"sourcesContent":["/**\n * A simple function that implements the builder pattern\n * @param value The value to update which gets return with the same reference\n * @param update The updates to apply on the object\n */\nexport const builder = <T>(value: T, update: (value: T) => void): T => {\n update(value)\n return value\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,IAAM,UAAU,CAAI,OAAU,WAAkC;AACrE,SAAO,KAAK;AACZ,SAAO;AACT;","names":[]}
@@ -1,4 +1,4 @@
1
- // src/util/builder.ts
1
+ // src/utils/builder.ts
2
2
  var builder = (value, update) => {
3
3
  update(value);
4
4
  return value;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/builder.ts"],"sourcesContent":["/**\n * A simple function that implements the builder pattern\n * @param value The value to update which gets return with the same reference\n * @param update The updates to apply on the object\n */\nexport const builder = <T>(value: T, update: (value: T) => void): T => {\n update(value)\n return value\n}\n"],"mappings":";AAKO,IAAM,UAAU,CAAI,OAAU,WAAkC;AACrE,SAAO,KAAK;AACZ,SAAO;AACT;","names":[]}
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/util/date.ts
19
+ // src/utils/date.ts
20
20
  var date_exports = {};
21
21
  __export(date_exports, {
22
22
  addDuration: () => addDuration,
@@ -34,7 +34,7 @@ __export(date_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(date_exports);
36
36
 
37
- // src/util/array.ts
37
+ // src/utils/array.ts
38
38
  var equalSizeGroups = (array, groupSize) => {
39
39
  if (groupSize <= 0) {
40
40
  console.warn(`group size should be greater than 0: groupSize = ${groupSize}`);
@@ -47,7 +47,7 @@ var equalSizeGroups = (array, groupSize) => {
47
47
  return groups;
48
48
  };
49
49
 
50
- // src/util/date.ts
50
+ // src/utils/date.ts
51
51
  var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
52
52
  var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
53
53
  var formatDate = (date) => {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/date.ts","../../src/utils/array.ts"],"sourcesContent":["import { equalSizeGroups } from './array'\n\nexport const monthsList = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as const\nexport type Month = typeof monthsList[number]\n\nexport const weekDayList = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] as const\nexport type WeekDay = typeof weekDayList[number]\n\nexport const formatDate = (date: Date) => {\n const year = date.getFullYear().toString().padStart(4, '0')\n const month = (date.getMonth() + 1).toString().padStart(2, '0')\n const day = (date.getDate()).toString().padStart(2, '0')\n return `${year}-${month}-${day}`\n}\n\nexport const formatDateTime = (date: Date) => {\n const dateString = formatDate(date)\n const hours = date.getHours().toString().padStart(2, '0')\n const minutes = date.getMinutes().toString().padStart(2, '0')\n return `${dateString}T${hours}:${minutes}`\n}\n\nexport const getDaysInMonth = (year: number, month: number): number => {\n const lastDayOfMonth = new Date(year, month + 1, 0)\n return lastDayOfMonth.getDate()\n}\n\nexport type Duration = {\n years?: number,\n months?: number,\n days?: number,\n hours?: number,\n minutes?: number,\n seconds?: number,\n milliseconds?: number,\n}\n\nexport const changeDuration = (date: Date, duration: Duration, isAdding?: boolean): Date => {\n const {\n years = 0,\n months = 0,\n days = 0,\n hours = 0,\n minutes = 0,\n seconds = 0,\n milliseconds = 0,\n } = duration\n\n // Check ranges\n if (years < 0) {\n console.error(`Range error years must be greater than 0: received ${years}`)\n return new Date(date)\n }\n if (months < 0 || months > 11) {\n console.error(`Range error month must be 0 <= month <= 11: received ${months}`)\n return new Date(date)\n }\n if (days < 0) {\n console.error(`Range error days must be greater than 0: received ${days}`)\n return new Date(date)\n }\n if (hours < 0 || hours > 23) {\n console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`)\n return new Date(date)\n }\n if (minutes < 0 || minutes > 59) {\n console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`)\n return new Date(date)\n }\n if (seconds < 0 || seconds > 59) {\n console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`)\n return new Date(date)\n }\n if (milliseconds < 0) {\n console.error(`Range error seconds must be greater than 0: received ${milliseconds}`)\n return new Date(date)\n }\n\n const multiplier = isAdding ? 1 : -1\n\n const newDate = new Date(date)\n\n newDate.setFullYear(newDate.getFullYear() + multiplier * years)\n\n newDate.setMonth(newDate.getMonth() + multiplier * months)\n\n newDate.setDate(newDate.getDate() + multiplier * days)\n\n newDate.setHours(newDate.getHours() + multiplier * hours)\n\n newDate.setMinutes(newDate.getMinutes() + multiplier * minutes)\n\n newDate.setSeconds(newDate.getSeconds() + multiplier * seconds)\n\n newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds)\n\n return newDate\n}\n\nexport const addDuration = (date: Date, duration: Duration): Date => {\n return changeDuration(date, duration, true)\n}\n\nexport const subtractDuration = (date: Date, duration: Duration): Date => {\n return changeDuration(date, duration, false)\n}\n\nexport const getBetweenDuration = (startDate: Date, endDate: Date): Duration => {\n const durationInMilliseconds = endDate.getTime() - startDate.getTime()\n\n const millisecondsInSecond = 1000\n const millisecondsInMinute = 60 * millisecondsInSecond\n const millisecondsInHour = 60 * millisecondsInMinute\n const millisecondsInDay = 24 * millisecondsInHour\n const millisecondsInMonth = 30 * millisecondsInDay // Rough estimation, can be adjusted\n\n const years = Math.floor(durationInMilliseconds / (365.25 * millisecondsInDay))\n const months = Math.floor(durationInMilliseconds / millisecondsInMonth)\n const days = Math.floor(durationInMilliseconds / millisecondsInDay)\n const hours = Math.floor((durationInMilliseconds % millisecondsInDay) / millisecondsInHour)\n const seconds = Math.floor((durationInMilliseconds % millisecondsInHour) / millisecondsInSecond)\n const milliseconds = durationInMilliseconds % millisecondsInSecond\n\n return {\n years,\n months,\n days,\n hours,\n seconds,\n milliseconds,\n }\n}\n\n/** Checks if a given date is in the range of two dates\n *\n * An undefined value for startDate or endDate means no bound for the start or end respectively\n */\nexport const isInTimeSpan = (value: Date, startDate?: Date, endDate?: Date): boolean => {\n if (startDate && endDate) {\n console.assert(startDate <= endDate)\n return startDate <= value && value <= endDate\n } else if (startDate) {\n return startDate <= value\n } else if (endDate) {\n return endDate >= value\n } else {\n return true\n }\n}\n\n/** Compare two dates on the year, month, day */\nexport const equalDate = (date1: Date, date2: Date) => {\n return date1.getFullYear() === date2.getFullYear()\n && date1.getMonth() === date2.getMonth()\n && date1.getDate() === date2.getDate()\n}\n\nexport const getWeeksForCalenderMonth = (date: Date, weekStart: WeekDay, weeks: number = 6) => {\n const month = date.getMonth()\n const year = date.getFullYear()\n\n const dayList: Date[] = []\n let currentDate = new Date(year, month, 1) // Start of month\n const weekStartIndex = weekDayList.indexOf(weekStart)\n\n // Move the current day to the week before\n while (currentDate.getDay() !== weekStartIndex) {\n currentDate = subtractDuration(currentDate, { days: 1 })\n }\n\n while (dayList.length < 7 * weeks) {\n const date = new Date(currentDate)\n date.setHours(date.getHours(), date.getMinutes()) // To make sure we are not overwriting the time\n dayList.push(date)\n currentDate = addDuration(currentDate, { days: 1 })\n }\n\n // weeks\n return equalSizeGroups(dayList, 7)\n}\n","export const equalSizeGroups = <T>(array: T[], groupSize: number): T[][] => {\n if (groupSize <= 0) {\n console.warn(`group size should be greater than 0: groupSize = ${groupSize}`)\n return [[...array]]\n }\n\n const groups = []\n for (let i = 0; i < array.length; i += groupSize) {\n groups.push(array.slice(i, Math.min(i + groupSize, array.length)))\n }\n return groups\n}\n\nexport type RangeOptions = {\n /** Whether the range can be defined empty via end < start without a warning */\n allowEmptyRange: boolean,\n stepSize: number,\n exclusiveStart: boolean,\n exclusiveEnd: boolean,\n}\n\nconst defaultRangeOptions: RangeOptions = {\n allowEmptyRange: false,\n stepSize: 1,\n exclusiveStart: false,\n exclusiveEnd: true,\n}\n\n/**\n * @param endOrRange The end value or a range [start, end], end is exclusive\n * @param options the options for defining the range\n */\nexport const range = (endOrRange: number | [number, number], options?: Partial<RangeOptions>): number[] => {\n const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options }\n let start = 0\n let end: number\n if (typeof endOrRange === 'number') {\n end = endOrRange\n } else {\n start = endOrRange[0]\n end = endOrRange[1]\n }\n if (!exclusiveEnd) {\n end -= 1\n }\n if (exclusiveStart) {\n start += 1\n }\n\n if (end - 1 < start) {\n if (!allowEmptyRange) {\n console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`)\n }\n return []\n }\n return Array.from({ length: end - start }, (_, index) => index * stepSize + start)\n}\n\n/** Finds the closest match\n * @param list The list of all possible matches\n * @param firstCloser Return whether item1 is closer than item2\n */\nexport const closestMatch = <T>(list: T[], firstCloser: (item1: T, item2: T) => boolean) => {\n return list.reduce((item1, item2) => {\n return firstCloser(item1, item2) ? item1 : item2\n })\n}\n\n/**\n * returns the item in middle of a list and its neighbours before and after\n * e.g. [1,2,3,4,5,6] for item = 1 would return [5,6,1,2,3]\n */\nexport const getNeighbours = <T>(list: T[], item: T, neighbourDistance: number = 2) => {\n const index = list.indexOf(item)\n const totalItems = neighbourDistance * 2 + 1\n if (list.length < totalItems) {\n console.warn('List is to short')\n return list\n }\n\n if (index === -1) {\n console.error('item not found in list')\n return list.splice(0, totalItems)\n }\n\n let start = index - neighbourDistance\n if (start < 0) {\n start += list.length\n }\n const end = (index + neighbourDistance + 1) % list.length\n\n const result: T[] = []\n let ignoreOnce = list.length === totalItems\n for (let i = start; i !== end || ignoreOnce; i = (i + 1) % list.length) {\n result.push(list[i]!)\n if (end === i && ignoreOnce) {\n ignoreOnce = false\n }\n }\n return result\n}\n\nexport const createLoopingListWithIndex = <T>(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n if (length < 0) {\n console.warn(`createLoopingList: length must be >= 0, given ${length}`)\n } else if (length === 0) {\n length = list.length\n }\n\n const returnList: [number, T][] = []\n\n if (forwards) {\n for (let i = startIndex; returnList.length < length; i = (i + 1) % list.length) {\n returnList.push([i, list[i]!])\n }\n } else {\n for (let i = startIndex; returnList.length < length; i = i === 0 ? i = list.length - 1 : i - 1) {\n returnList.push([i, list[i]!])\n }\n }\n\n return returnList\n}\n\nexport const createLoopingList = <T>(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n return createLoopingListWithIndex(list, startIndex, length, forwards).map(([_, item]) => item)\n}\n\n/**\n * @param list The list to be changed\n * @param move The shifting applied to the array (can be negative)\n */\nconst moveItems = <T>(list: T[], move: number = 0) => {\n const result = []\n let start = move\n if (start < 0) {\n start = list.length - move\n }\n start = start % list.length\n for (let i = 0; i < list.length; i++) {\n result[i] = list[(i + start) % list.length]\n }\n return result\n}\n\nexport const ArrayUtil = {\n unique: <T>(list: T[]): T[] => {\n const seen = new Set<T>()\n return list.filter((item) => {\n if (seen.has(item)) {\n return false\n }\n seen.add(item)\n return true\n })\n },\n difference: <T>(list: T[], removeList: T[]): T[] => {\n const remove = new Set<T>(removeList)\n return list.filter((item) => !remove.has(item))\n },\n moveItems,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAkB,CAAI,OAAY,cAA6B;AAC1E,MAA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YAAY,KAC5C,MAAM,SAAS,MAAM,MAAM,SAAS,KACpC,MAAM,QAAQ,MAAM,MAAM,QAAQ;AACzC;AAEO,IAAM,2BAA2B,CAAC,MAAY,WAAoB,QAAgB,MAAM;AAC7F,QAAM,QAAQ,KAAK,SAAS;AAC5B,QAAM,OAAO,KAAK,YAAY;AAE9B,QAAM,UAAkB,CAAC;AACzB,MAAI,cAAc,IAAI,KAAK,MAAM,OAAO,CAAC;AACzC,QAAM,iBAAiB,YAAY,QAAQ,SAAS;AAGpD,SAAO,YAAY,OAAO,MAAM,gBAAgB;AAC9C,kBAAc,iBAAiB,aAAa,EAAE,MAAM,EAAE,CAAC;AAAA,EACzD;AAEA,SAAO,QAAQ,SAAS,IAAI,OAAO;AACjC,UAAMA,QAAO,IAAI,KAAK,WAAW;AACjC,IAAAA,MAAK,SAASA,MAAK,SAAS,GAAGA,MAAK,WAAW,CAAC;AAChD,YAAQ,KAAKA,KAAI;AACjB,kBAAc,YAAY,aAAa,EAAE,MAAM,EAAE,CAAC;AAAA,EACpD;AAGA,SAAO,gBAAgB,SAAS,CAAC;AACnC;","names":["date"]}
@@ -1,4 +1,4 @@
1
- // src/util/array.ts
1
+ // src/utils/array.ts
2
2
  var equalSizeGroups = (array, groupSize) => {
3
3
  if (groupSize <= 0) {
4
4
  console.warn(`group size should be greater than 0: groupSize = ${groupSize}`);
@@ -11,7 +11,7 @@ var equalSizeGroups = (array, groupSize) => {
11
11
  return groups;
12
12
  };
13
13
 
14
- // src/util/date.ts
14
+ // src/utils/date.ts
15
15
  var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
16
16
  var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
17
17
  var formatDate = (date) => {