@codeleap/web 6.8.0 → 7.0.1

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 (357) hide show
  1. package/dist/components/ActivityIndicator/index.js +28 -0
  2. package/dist/components/ActivityIndicator/index.js.map +1 -0
  3. package/dist/components/ActivityIndicator/styles.js +2 -0
  4. package/dist/components/ActivityIndicator/styles.js.map +1 -0
  5. package/dist/components/ActivityIndicator/types.js +2 -0
  6. package/dist/components/ActivityIndicator/types.js.map +1 -0
  7. package/dist/components/Badge/index.js +68 -0
  8. package/dist/components/Badge/index.js.map +1 -0
  9. package/dist/components/Badge/styles.js +2 -0
  10. package/dist/components/Badge/styles.js.map +1 -0
  11. package/dist/components/Badge/types.js +2 -0
  12. package/dist/components/Badge/types.js.map +1 -0
  13. package/dist/components/Button/index.js +52 -0
  14. package/dist/components/Button/index.js.map +1 -0
  15. package/dist/components/Button/styles.js +2 -0
  16. package/dist/components/Button/styles.js.map +1 -0
  17. package/dist/components/Button/types.js +2 -0
  18. package/dist/components/Button/types.js.map +1 -0
  19. package/dist/components/Calendar/index.js +50 -0
  20. package/dist/components/Calendar/index.js.map +1 -0
  21. package/dist/components/Calendar/styles.js +2 -0
  22. package/dist/components/Calendar/styles.js.map +1 -0
  23. package/dist/components/Calendar/types.js +2 -0
  24. package/dist/components/Calendar/types.js.map +1 -0
  25. package/dist/components/Carousel/index.js +129 -0
  26. package/dist/components/Carousel/index.js.map +1 -0
  27. package/dist/components/Carousel/styles.js +2 -0
  28. package/dist/components/Carousel/styles.js.map +1 -0
  29. package/dist/components/Carousel/types.js +2 -0
  30. package/dist/components/Carousel/types.js.map +1 -0
  31. package/dist/components/Checkbox/index.js +44 -0
  32. package/dist/components/Checkbox/index.js.map +1 -0
  33. package/dist/components/Checkbox/styles.js +2 -0
  34. package/dist/components/Checkbox/styles.js.map +1 -0
  35. package/dist/components/Checkbox/types.js +2 -0
  36. package/dist/components/Checkbox/types.js.map +1 -0
  37. package/dist/components/Collapse/index.js +27 -0
  38. package/dist/components/Collapse/index.js.map +1 -0
  39. package/dist/components/Collapse/styles.js +2 -0
  40. package/dist/components/Collapse/styles.js.map +1 -0
  41. package/dist/components/Collapse/types.js +2 -0
  42. package/dist/components/Collapse/types.js.map +1 -0
  43. package/dist/components/ColorPicker/index.js +65 -0
  44. package/dist/components/ColorPicker/index.js.map +1 -0
  45. package/dist/components/ColorPicker/styles.js +2 -0
  46. package/dist/components/ColorPicker/styles.js.map +1 -0
  47. package/dist/components/ColorPicker/types.js +2 -0
  48. package/dist/components/ColorPicker/types.js.map +1 -0
  49. package/dist/components/CropPicker/hooks.js +130 -0
  50. package/dist/components/CropPicker/hooks.js.map +1 -0
  51. package/dist/components/CropPicker/index.js +38 -0
  52. package/dist/components/CropPicker/index.js.map +1 -0
  53. package/dist/components/CropPicker/styles.js +2 -0
  54. package/dist/components/CropPicker/styles.js.map +1 -0
  55. package/dist/components/CropPicker/types.js +2 -0
  56. package/dist/components/CropPicker/types.js.map +1 -0
  57. package/dist/components/CropPicker/utils.js +70 -0
  58. package/dist/components/CropPicker/utils.js.map +1 -0
  59. package/dist/components/DatePicker/index.js +70 -0
  60. package/dist/components/DatePicker/index.js.map +1 -0
  61. package/dist/components/DatePicker/styles.js +2 -0
  62. package/dist/components/DatePicker/styles.js.map +1 -0
  63. package/dist/components/DatePicker/types.js +2 -0
  64. package/dist/components/DatePicker/types.js.map +1 -0
  65. package/dist/components/Drawer/index.js +50 -0
  66. package/dist/components/Drawer/index.js.map +1 -0
  67. package/dist/components/Drawer/styles.js +2 -0
  68. package/dist/components/Drawer/styles.js.map +1 -0
  69. package/dist/components/Drawer/types.js +2 -0
  70. package/dist/components/Drawer/types.js.map +1 -0
  71. package/dist/components/Dropzone/context.js +39 -0
  72. package/dist/components/Dropzone/context.js.map +1 -0
  73. package/dist/components/Dropzone/elements.js +51 -0
  74. package/dist/components/Dropzone/elements.js.map +1 -0
  75. package/dist/components/Dropzone/index.js +71 -0
  76. package/dist/components/Dropzone/index.js.map +1 -0
  77. package/dist/components/Dropzone/styles.js +2 -0
  78. package/dist/components/Dropzone/styles.js.map +1 -0
  79. package/dist/components/Dropzone/types.js +2 -0
  80. package/dist/components/Dropzone/types.js.map +1 -0
  81. package/dist/components/Dropzone/useDropzone.js +17 -0
  82. package/dist/components/Dropzone/useDropzone.js.map +1 -0
  83. package/dist/components/EmptyPlaceholder/index.js +65 -0
  84. package/dist/components/EmptyPlaceholder/index.js.map +1 -0
  85. package/dist/components/EmptyPlaceholder/styles.js +2 -0
  86. package/dist/components/EmptyPlaceholder/styles.js.map +1 -0
  87. package/dist/components/EmptyPlaceholder/types.js +2 -0
  88. package/dist/components/EmptyPlaceholder/types.js.map +1 -0
  89. package/dist/components/Field/context.js +52 -0
  90. package/dist/components/Field/context.js.map +1 -0
  91. package/dist/components/Field/elements.js +84 -0
  92. package/dist/components/Field/elements.js.map +1 -0
  93. package/dist/components/Field/index.js +37 -0
  94. package/dist/components/Field/index.js.map +1 -0
  95. package/dist/components/Field/styles.js +2 -0
  96. package/dist/components/Field/styles.js.map +1 -0
  97. package/dist/components/Field/types.js +2 -0
  98. package/dist/components/Field/types.js.map +1 -0
  99. package/dist/components/Field/useFieldInput.js +47 -0
  100. package/dist/components/Field/useFieldInput.js.map +1 -0
  101. package/dist/components/FileInput/index.js +55 -0
  102. package/dist/components/FileInput/index.js.map +1 -0
  103. package/dist/components/FileInput/types.js +2 -0
  104. package/dist/components/FileInput/types.js.map +1 -0
  105. package/dist/components/Icon/index.js +51 -0
  106. package/dist/components/Icon/index.js.map +1 -0
  107. package/dist/components/Icon/styles.js +2 -0
  108. package/dist/components/Icon/styles.js.map +1 -0
  109. package/dist/components/Icon/types.js +2 -0
  110. package/dist/components/Icon/types.js.map +1 -0
  111. package/dist/components/List/context.js +76 -0
  112. package/dist/components/List/context.js.map +1 -0
  113. package/dist/components/List/elements.js +123 -0
  114. package/dist/components/List/elements.js.map +1 -0
  115. package/dist/components/List/index.js +35 -0
  116. package/dist/components/List/index.js.map +1 -0
  117. package/dist/components/List/scroll.js +75 -0
  118. package/dist/components/List/scroll.js.map +1 -0
  119. package/dist/components/List/styles.js +2 -0
  120. package/dist/components/List/styles.js.map +1 -0
  121. package/dist/components/List/types.js +2 -0
  122. package/dist/components/List/types.js.map +1 -0
  123. package/dist/components/LoadingOverlay/index.js +32 -0
  124. package/dist/components/LoadingOverlay/index.js.map +1 -0
  125. package/dist/components/LoadingOverlay/styles.js +2 -0
  126. package/dist/components/LoadingOverlay/styles.js.map +1 -0
  127. package/dist/components/LoadingOverlay/types.js +2 -0
  128. package/dist/components/LoadingOverlay/types.js.map +1 -0
  129. package/dist/components/MaskedTextInput/index.js +34 -0
  130. package/dist/components/MaskedTextInput/index.js.map +1 -0
  131. package/dist/components/MaskedTextInput/mask.js +34 -0
  132. package/dist/components/MaskedTextInput/mask.js.map +1 -0
  133. package/dist/components/MaskedTextInput/types.js +2 -0
  134. package/dist/components/MaskedTextInput/types.js.map +1 -0
  135. package/dist/components/Modal/context.js +36 -0
  136. package/dist/components/Modal/context.js.map +1 -0
  137. package/dist/components/Modal/elements.js +66 -0
  138. package/dist/components/Modal/elements.js.map +1 -0
  139. package/dist/components/Modal/index.js +34 -0
  140. package/dist/components/Modal/index.js.map +1 -0
  141. package/dist/components/Modal/styles.js +2 -0
  142. package/dist/components/Modal/styles.js.map +1 -0
  143. package/dist/components/Modal/types.js +2 -0
  144. package/dist/components/Modal/types.js.map +1 -0
  145. package/dist/components/NumberIncrement/index.js +65 -0
  146. package/dist/components/NumberIncrement/index.js.map +1 -0
  147. package/dist/components/NumberIncrement/styles.js +2 -0
  148. package/dist/components/NumberIncrement/styles.js.map +1 -0
  149. package/dist/components/NumberIncrement/types.js +2 -0
  150. package/dist/components/NumberIncrement/types.js.map +1 -0
  151. package/dist/components/NumberIncrement/useNumberIncrement.js +113 -0
  152. package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -0
  153. package/dist/components/Overlay/index.js +44 -0
  154. package/dist/components/Overlay/index.js.map +1 -0
  155. package/dist/components/Overlay/styles.js +2 -0
  156. package/dist/components/Overlay/styles.js.map +1 -0
  157. package/dist/components/Overlay/types.js +2 -0
  158. package/dist/components/Overlay/types.js.map +1 -0
  159. package/dist/components/PaginationButtons/index.js +100 -0
  160. package/dist/components/PaginationButtons/index.js.map +1 -0
  161. package/dist/components/PaginationButtons/styles.js +2 -0
  162. package/dist/components/PaginationButtons/styles.js.map +1 -0
  163. package/dist/components/PaginationButtons/types.js +2 -0
  164. package/dist/components/PaginationButtons/types.js.map +1 -0
  165. package/dist/components/PaginationIndicator/index.js +41 -0
  166. package/dist/components/PaginationIndicator/index.js.map +1 -0
  167. package/dist/components/PaginationIndicator/styles.js +2 -0
  168. package/dist/components/PaginationIndicator/styles.js.map +1 -0
  169. package/dist/components/PaginationIndicator/types.js +2 -0
  170. package/dist/components/PaginationIndicator/types.js.map +1 -0
  171. package/dist/components/Progress/Bar/Segmented.js +37 -0
  172. package/dist/components/Progress/Bar/Segmented.js.map +1 -0
  173. package/dist/components/Progress/Bar/index.js +44 -0
  174. package/dist/components/Progress/Bar/index.js.map +1 -0
  175. package/dist/components/Progress/Bar/styles.js +2 -0
  176. package/dist/components/Progress/Bar/styles.js.map +1 -0
  177. package/dist/components/Progress/Bar/types.js +2 -0
  178. package/dist/components/Progress/Bar/types.js.map +1 -0
  179. package/dist/components/Progress/Circle/Segmented.js +60 -0
  180. package/dist/components/Progress/Circle/Segmented.js.map +1 -0
  181. package/dist/components/Progress/Circle/index.js +65 -0
  182. package/dist/components/Progress/Circle/index.js.map +1 -0
  183. package/dist/components/Progress/Circle/styles.js +2 -0
  184. package/dist/components/Progress/Circle/styles.js.map +1 -0
  185. package/dist/components/Progress/Circle/types.js +2 -0
  186. package/dist/components/Progress/Circle/types.js.map +1 -0
  187. package/dist/components/Progress/index.js +3 -0
  188. package/dist/components/Progress/index.js.map +1 -0
  189. package/dist/components/Progress/utils.js +4 -0
  190. package/dist/components/Progress/utils.js.map +1 -0
  191. package/dist/components/RadioInput/index.js +47 -0
  192. package/dist/components/RadioInput/index.js.map +1 -0
  193. package/dist/components/RadioInput/styles.js +2 -0
  194. package/dist/components/RadioInput/styles.js.map +1 -0
  195. package/dist/components/RadioInput/types.js +2 -0
  196. package/dist/components/RadioInput/types.js.map +1 -0
  197. package/dist/components/SearchInput/index.js +61 -0
  198. package/dist/components/SearchInput/index.js.map +1 -0
  199. package/dist/components/SectionFilters/index.js +148 -0
  200. package/dist/components/SectionFilters/index.js.map +1 -0
  201. package/dist/components/SectionFilters/styles.js +2 -0
  202. package/dist/components/SectionFilters/styles.js.map +1 -0
  203. package/dist/components/SectionFilters/types.js +2 -0
  204. package/dist/components/SectionFilters/types.js.map +1 -0
  205. package/dist/components/Select/context.js +156 -0
  206. package/dist/components/Select/context.js.map +1 -0
  207. package/dist/components/Select/elements.js +47 -0
  208. package/dist/components/Select/elements.js.map +1 -0
  209. package/dist/components/Select/index.js +53 -0
  210. package/dist/components/Select/index.js.map +1 -0
  211. package/dist/components/Select/styles.js +2 -0
  212. package/dist/components/Select/styles.js.map +1 -0
  213. package/dist/components/Select/types.js +2 -0
  214. package/dist/components/Select/types.js.map +1 -0
  215. package/dist/components/Select/useTriggerWidth.js +27 -0
  216. package/dist/components/Select/useTriggerWidth.js.map +1 -0
  217. package/dist/components/Slider/index.js +139 -0
  218. package/dist/components/Slider/index.js.map +1 -0
  219. package/dist/components/Slider/styles.js +2 -0
  220. package/dist/components/Slider/styles.js.map +1 -0
  221. package/dist/components/Slider/types.js +2 -0
  222. package/dist/components/Slider/types.js.map +1 -0
  223. package/dist/components/Switch/index.js +48 -0
  224. package/dist/components/Switch/index.js.map +1 -0
  225. package/dist/components/Switch/styles.js +2 -0
  226. package/dist/components/Switch/styles.js.map +1 -0
  227. package/dist/components/Switch/types.js +2 -0
  228. package/dist/components/Switch/types.js.map +1 -0
  229. package/dist/components/Tag/index.js +53 -0
  230. package/dist/components/Tag/index.js.map +1 -0
  231. package/dist/components/Tag/styles.js +2 -0
  232. package/dist/components/Tag/styles.js.map +1 -0
  233. package/dist/components/Tag/types.js +2 -0
  234. package/dist/components/Tag/types.js.map +1 -0
  235. package/dist/components/Text/index.js +94 -0
  236. package/dist/components/Text/index.js.map +1 -0
  237. package/dist/components/Text/styles.js +2 -0
  238. package/dist/components/Text/styles.js.map +1 -0
  239. package/dist/components/Text/types.js +2 -0
  240. package/dist/components/Text/types.js.map +1 -0
  241. package/dist/components/TextEditor/index.js +90 -0
  242. package/dist/components/TextEditor/index.js.map +1 -0
  243. package/dist/components/TextEditor/styles.js +2 -0
  244. package/dist/components/TextEditor/styles.js.map +1 -0
  245. package/dist/components/TextEditor/types.js +2 -0
  246. package/dist/components/TextEditor/types.js.map +1 -0
  247. package/dist/components/TextInput/index.js +65 -0
  248. package/dist/components/TextInput/index.js.map +1 -0
  249. package/dist/components/TextInput/styles.js +2 -0
  250. package/dist/components/TextInput/styles.js.map +1 -0
  251. package/dist/components/TextInput/types.js +2 -0
  252. package/dist/components/TextInput/types.js.map +1 -0
  253. package/dist/components/TextInput/useTextInput.js +64 -0
  254. package/dist/components/TextInput/useTextInput.js.map +1 -0
  255. package/dist/components/Tooltip/index.js +94 -0
  256. package/dist/components/Tooltip/index.js.map +1 -0
  257. package/dist/components/Tooltip/styles.js +2 -0
  258. package/dist/components/Tooltip/styles.js.map +1 -0
  259. package/dist/components/Tooltip/types.js +2 -0
  260. package/dist/components/Tooltip/types.js.map +1 -0
  261. package/dist/components/Touchable/index.js +80 -0
  262. package/dist/components/Touchable/index.js.map +1 -0
  263. package/dist/components/Touchable/styles.js +2 -0
  264. package/dist/components/Touchable/styles.js.map +1 -0
  265. package/dist/components/Touchable/types.js +2 -0
  266. package/dist/components/Touchable/types.js.map +1 -0
  267. package/dist/components/View/index.js +39 -0
  268. package/dist/components/View/index.js.map +1 -0
  269. package/dist/components/View/styles.js +2 -0
  270. package/dist/components/View/styles.js.map +1 -0
  271. package/dist/components/View/types.js +2 -0
  272. package/dist/components/View/types.js.map +1 -0
  273. package/dist/components/components.js +42 -0
  274. package/dist/components/components.js.map +1 -0
  275. package/dist/index.js +5 -0
  276. package/dist/index.js.map +1 -0
  277. package/dist/lib/ListMasonry.js +86 -0
  278. package/dist/lib/ListMasonry.js.map +1 -0
  279. package/dist/lib/ThemeVariables.js +22 -0
  280. package/dist/lib/ThemeVariables.js.map +1 -0
  281. package/dist/lib/WebStyleRegistry.js +69 -0
  282. package/dist/lib/WebStyleRegistry.js.map +1 -0
  283. package/dist/lib/hooks/index.js +23 -0
  284. package/dist/lib/hooks/index.js.map +1 -0
  285. package/dist/lib/hooks/useAnimatedStyle.js +23 -0
  286. package/dist/lib/hooks/useAnimatedStyle.js.map +1 -0
  287. package/dist/lib/hooks/useAnimatedVariantStyles.js +20 -0
  288. package/dist/lib/hooks/useAnimatedVariantStyles.js.map +1 -0
  289. package/dist/lib/hooks/useAsyncSelect.js +57 -0
  290. package/dist/lib/hooks/useAsyncSelect.js.map +1 -0
  291. package/dist/lib/hooks/useBreakpointMatch.js +108 -0
  292. package/dist/lib/hooks/useBreakpointMatch.js.map +1 -0
  293. package/dist/lib/hooks/useClick.js +38 -0
  294. package/dist/lib/hooks/useClick.js.map +1 -0
  295. package/dist/lib/hooks/useClickOutside.js +31 -0
  296. package/dist/lib/hooks/useClickOutside.js.map +1 -0
  297. package/dist/lib/hooks/useFileInput.js +17 -0
  298. package/dist/lib/hooks/useFileInput.js.map +1 -0
  299. package/dist/lib/hooks/useIsomorphicEffect.js +7 -0
  300. package/dist/lib/hooks/useIsomorphicEffect.js.map +1 -0
  301. package/dist/lib/hooks/useKeydown.js +39 -0
  302. package/dist/lib/hooks/useKeydown.js.map +1 -0
  303. package/dist/lib/hooks/useListFocus.js +46 -0
  304. package/dist/lib/hooks/useListFocus.js.map +1 -0
  305. package/dist/lib/hooks/useMediaQuery.js +25 -0
  306. package/dist/lib/hooks/useMediaQuery.js.map +1 -0
  307. package/dist/lib/hooks/usePageExitBlocker.js +44 -0
  308. package/dist/lib/hooks/usePageExitBlocker.js.map +1 -0
  309. package/dist/lib/hooks/usePagination.js +90 -0
  310. package/dist/lib/hooks/usePagination.js.map +1 -0
  311. package/dist/lib/hooks/usePopState.js +31 -0
  312. package/dist/lib/hooks/usePopState.js.map +1 -0
  313. package/dist/lib/hooks/usePopoverDismiss.js +32 -0
  314. package/dist/lib/hooks/usePopoverDismiss.js.map +1 -0
  315. package/dist/lib/hooks/useRefresh.js +67 -0
  316. package/dist/lib/hooks/useRefresh.js.map +1 -0
  317. package/dist/lib/hooks/useScrollEffect.js +19 -0
  318. package/dist/lib/hooks/useScrollEffect.js.map +1 -0
  319. package/dist/lib/hooks/useSearchParams.js +48 -0
  320. package/dist/lib/hooks/useSearchParams.js.map +1 -0
  321. package/dist/lib/hooks/useStaticAnimationStyles.js +16 -0
  322. package/dist/lib/hooks/useStaticAnimationStyles.js.map +1 -0
  323. package/dist/lib/hooks/useStylesFor.js +36 -0
  324. package/dist/lib/hooks/useStylesFor.js.map +1 -0
  325. package/dist/lib/hooks/useTouchableEvents.js +34 -0
  326. package/dist/lib/hooks/useTouchableEvents.js.map +1 -0
  327. package/dist/lib/hooks/useWindowFocus.js +30 -0
  328. package/dist/lib/hooks/useWindowFocus.js.map +1 -0
  329. package/dist/lib/hooks/useWindowSize.js +29 -0
  330. package/dist/lib/hooks/useWindowSize.js.map +1 -0
  331. package/dist/lib/index.js +7 -0
  332. package/dist/lib/index.js.map +1 -0
  333. package/dist/lib/tools/index.js +4 -0
  334. package/dist/lib/tools/index.js.map +1 -0
  335. package/dist/lib/tools/localStorage.js +155 -0
  336. package/dist/lib/tools/localStorage.js.map +1 -0
  337. package/dist/lib/tools/mediaQuery.js +33 -0
  338. package/dist/lib/tools/mediaQuery.js.map +1 -0
  339. package/dist/lib/tools/modal.js +55 -0
  340. package/dist/lib/tools/modal.js.map +1 -0
  341. package/dist/lib/utils/attributes.js +23 -0
  342. package/dist/lib/utils/attributes.js.map +1 -0
  343. package/dist/lib/utils/cache.js +10 -0
  344. package/dist/lib/utils/cache.js.map +1 -0
  345. package/dist/lib/utils/index.js +6 -0
  346. package/dist/lib/utils/index.js.map +1 -0
  347. package/dist/lib/utils/pollyfils/scroll.js +66 -0
  348. package/dist/lib/utils/pollyfils/scroll.js.map +1 -0
  349. package/dist/lib/utils/stopPropagation.js +19 -0
  350. package/dist/lib/utils/stopPropagation.js.map +1 -0
  351. package/dist/lib/utils/test.js +14 -0
  352. package/dist/lib/utils/test.js.map +1 -0
  353. package/dist/types/index.js +2 -0
  354. package/dist/types/index.js.map +1 -0
  355. package/dist/types/utility.js +2 -0
  356. package/dist/types/utility.js.map +1 -0
  357. package/package.json +18 -18
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useRef, useState } from 'react';
3
+ import { useDebounceCallback } from '@codeleap/hooks';
4
+ import { deepEqual } from '@codeleap/utils';
5
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
6
+ import { useIsomorphicEffect } from '../../lib/hooks/useIsomorphicEffect';
7
+ import { useElementScroll, useWindowScroll } from './scroll';
8
+ const LIST_STYLE_REGISTRY_NAME = 'List';
9
+ function resolvePadding(props, stylePositioner) {
10
+ const get = (key) => props[key] ?? stylePositioner?.[key];
11
+ const p = get('padding') ?? 0;
12
+ const ph = get('paddingHorizontal') ?? p;
13
+ const pv = get('paddingVertical') ?? p;
14
+ return {
15
+ paddingTop: get('paddingTop') ?? pv,
16
+ paddingBottom: get('paddingBottom') ?? pv,
17
+ paddingLeft: get('paddingLeft') ?? ph,
18
+ paddingRight: get('paddingRight') ?? ph,
19
+ };
20
+ }
21
+ function useListProvider(props) {
22
+ const wrapperRef = useRef(null);
23
+ const [wrapperLayout, setWrapperLayout] = useState(null);
24
+ const styles = useStylesFor(LIST_STYLE_REGISTRY_NAME, props.style);
25
+ const stylePositioner = styles?.positioner ?? {};
26
+ const update = useCallback((target) => {
27
+ const rect = target.getBoundingClientRect();
28
+ const next = { width: rect.width, offsetHeight: target.offsetHeight };
29
+ setWrapperLayout(current => deepEqual(next, current) ? current : next);
30
+ }, []);
31
+ const { debounce: updateDebounced } = useDebounceCallback(update, 200);
32
+ useIsomorphicEffect(() => {
33
+ if (typeof window === 'undefined')
34
+ return;
35
+ const el = wrapperRef.current;
36
+ if (!el)
37
+ return;
38
+ update(el);
39
+ const observer = new ResizeObserver(([entry]) => {
40
+ updateDebounced(entry.target);
41
+ });
42
+ observer.observe(el);
43
+ return () => observer.disconnect();
44
+ }, [wrapperRef.current, update, updateDebounced]);
45
+ const scrollHook = props.scrollHook ?? (props.windowScroll ? useWindowScroll : useElementScroll);
46
+ const ready = !!wrapperLayout;
47
+ return {
48
+ wrapperRef,
49
+ wrapperLayout,
50
+ styles: styles,
51
+ props,
52
+ scrollHook,
53
+ ready,
54
+ padding: resolvePadding(props, stylePositioner),
55
+ };
56
+ }
57
+ export const ListContext = createContext(null);
58
+ /**
59
+ * Returns the nearest `List.Provider` context value.
60
+ * Throws when `required` is `true` (default) and no provider is found; pass `false` to allow optional usage.
61
+ */
62
+ export const useListContext = (required = true) => {
63
+ const ctx = useContext(ListContext);
64
+ if (!ctx && required)
65
+ throw new Error('useListContext must be used inside List.Provider');
66
+ return ctx;
67
+ };
68
+ /**
69
+ * Provides layout measurements, resolved styles, scroll state, and positioner config to all List sub-components.
70
+ * Must wrap `List.Wrapper` / `List.Items`; `List` renders this automatically when used as the top-level component.
71
+ */
72
+ export const ListProvider = (props) => {
73
+ const value = useListProvider(props);
74
+ return (_jsx(ListContext, { value: value, children: props.children }));
75
+ };
76
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/List/context.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAa,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClG,OAAO,EAAE,m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AE7B,OAAO;QACL,UAAU;QACV,aAAa;QACb,MAAM,EAAE,MAAsC;QAC9C,KAAK;QACL,UAAU;QACV,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,eAAe,CAAC;KAChD,CAAA;AACH,CAAC;AAID,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAA;AAEvE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAQ,GAAC,IAAI,EAAoB,EAAE;IAChE,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACnC,IAAI,CAAC,GAAG,IAAI,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACzF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;IACvD,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IACpC,OAAO,CACL,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,YACtB,KAAK,CAAC,QAAQ,GACH,CACf,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,123 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import React, { useCallback, useImperativeHandle, useMemo } from 'react';
3
+ import { useMasonry, usePositioner, useResizeObserver, useInfiniteLoader, useScrollToIndex, } from 'masonic';
4
+ import { TypeGuards } from '@codeleap/types';
5
+ import { View } from '../View';
6
+ import { useListContext } from './context';
7
+ /**
8
+ * Outer `View` that measures its own dimensions for the Masonic positioner via a `ResizeObserver`.
9
+ * Must be rendered inside `List.Provider`; forwards extra `ViewProps` to the underlying `View`.
10
+ */
11
+ export const ListWrapper = ({ children, ...viewProps }) => {
12
+ const { wrapperRef, styles, padding } = useListContext();
13
+ return (_jsx(View, { ...viewProps, css: [styles.wrapper, padding, viewProps.css], ref: wrapperRef, children: children }));
14
+ };
15
+ function _ListItemsContent({ data, renderItem: providedRenderItem, fetchNextPage: itemsFetchNextPage, hasNextPage: itemsHasNextPage, ref, }) {
16
+ const { wrapperRef, wrapperLayout, scrollHook, styles, props, padding } = useListContext();
17
+ const fetchNextPage = itemsFetchNextPage ?? props.fetchNextPage;
18
+ const hasNextPage = itemsHasNextPage ?? props.hasNextPage;
19
+ const { scrollTop, isScrolling, height, width, scrollElement } = scrollHook(wrapperRef, wrapperLayout);
20
+ const innerWidth = width - padding.paddingLeft - padding.paddingRight;
21
+ const stylePositioner = styles.positioner ?? {};
22
+ const positionerConfig = {
23
+ columnCount: props.columnCount ?? stylePositioner.columnCount ?? 1,
24
+ columnGutter: props.columnGutter ?? stylePositioner.columnGutter,
25
+ columnWidth: props.columnWidth ?? stylePositioner.columnWidth,
26
+ maxColumnCount: props.maxColumnCount ?? stylePositioner.maxColumnCount,
27
+ maxColumnWidth: props.maxColumnWidth ?? stylePositioner.maxColumnWidth,
28
+ rowGutter: props.rowGutter ?? stylePositioner.rowGutter,
29
+ };
30
+ const positioner = usePositioner({ width: Math.max(0, innerWidth), ...positionerConfig }, [data]);
31
+ const resizeObserver = useResizeObserver(positioner);
32
+ const scrollToIndexFn = useScrollToIndex(positioner, {
33
+ element: scrollElement,
34
+ height,
35
+ });
36
+ useImperativeHandle(ref, () => ({
37
+ scrollToIndex: (index, options) => {
38
+ scrollToIndexFn(index);
39
+ },
40
+ }), [scrollToIndexFn]);
41
+ const maybeLoadMore = useInfiniteLoader(async () => {
42
+ if (hasNextPage)
43
+ fetchNextPage?.();
44
+ }, {
45
+ isItemLoaded: (index, items) => !!items?.[index],
46
+ ...props.infiniteLoaderProps,
47
+ });
48
+ const separator = useMemo(() => {
49
+ if (!props.separators)
50
+ return null;
51
+ return props.ItemSeparatorComponent ?? null;
52
+ }, [props.separators, props.ItemSeparatorComponent]);
53
+ const dataLength = data?.length ?? 0;
54
+ const wrappedRenderItem = useCallback((masonryProps) => {
55
+ if (!providedRenderItem)
56
+ return null;
57
+ const { index, data: item } = masonryProps;
58
+ const isFirst = index === 0;
59
+ const isLast = index === dataLength - 1;
60
+ const isOnly = dataLength === 1;
61
+ return _jsxs(_Fragment, { children: [isFirst ? null : separator, providedRenderItem({
62
+ ...masonryProps,
63
+ item,
64
+ isFirst,
65
+ isLast,
66
+ isOnly,
67
+ })] });
68
+ }, [providedRenderItem, separator, dataLength]);
69
+ return useMasonry({
70
+ positioner,
71
+ resizeObserver,
72
+ height: Math.max(1, height),
73
+ scrollTop,
74
+ isScrolling,
75
+ items: data ?? [],
76
+ render: wrappedRenderItem,
77
+ onRender: maybeLoadMore,
78
+ });
79
+ }
80
+ /**
81
+ * Renders the virtualized Masonic grid once the `List.Wrapper` layout is ready; returns `null` until then.
82
+ * Handles infinite loading via Masonic's `useInfiniteLoader`, item separators, and exposes a `scrollToIndex` imperative handle via `ref`.
83
+ * Must be rendered inside `List.Provider`.
84
+ */
85
+ export function ListItems(props) {
86
+ const { ready } = useListContext();
87
+ if (!ready)
88
+ return null;
89
+ return _jsx(_ListItemsContent, { ...props });
90
+ }
91
+ /**
92
+ * Styled slot rendered above `List.Items`; applies the `header` composition style from the list's style sheet.
93
+ * Must be rendered inside `List.Provider`.
94
+ */
95
+ export const ListHeader = ({ children, ...viewProps }) => {
96
+ const { styles } = useListContext();
97
+ return (_jsx(View, { ...viewProps, css: [styles.header, viewProps.css], children: children }));
98
+ };
99
+ /**
100
+ * Styled slot rendered below `List.Items`; falls back to `ListProviderProps.ListFooterComponent` when no `children` are given.
101
+ * Renders nothing when both sources are empty. Must be rendered inside `List.Provider`.
102
+ */
103
+ export const ListFooter = ({ children, ...viewProps }) => {
104
+ const { styles, props } = useListContext();
105
+ const footer = children ?? (TypeGuards.isFunction(props.ListFooterComponent)
106
+ ? props.ListFooterComponent()
107
+ : props.ListFooterComponent);
108
+ if (!footer)
109
+ return null;
110
+ return (_jsx(View, { ...viewProps, css: [styles.footer, viewProps.css], children: footer }));
111
+ };
112
+ /**
113
+ * Renders `ListProviderProps.placeholder` when it is a valid React element; otherwise renders nothing.
114
+ * Typically used to show an `EmptyPlaceholder` when the list has no data. Must be rendered inside `List.Provider`.
115
+ */
116
+ export const ListPlaceholder = () => {
117
+ const { props } = useListContext();
118
+ const { placeholder } = props;
119
+ if (React.isValidElement(placeholder))
120
+ return _jsx(_Fragment, { children: placeholder });
121
+ return null;
122
+ };
123
+ //# sourceMappingURL=elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../../src/components/List/elements.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACxE,OAAO,EACL,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GAEjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAa,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAG1C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAa,EAAE,EAAE;IACnE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAA;IACxD,OAAO,CACL,KAAC,IAAI,OAAK,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAG,SAAiB,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,UAA6C,YAC5H,QAAQ,GACJ,CACR,CAAA;AACH,CAAC,CAAA;AAED,SAAS,iBAAiB,CAAqB,EAC7C,IAAI,EACJ,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,kBAAkB,EACjC,WAAW,EAAE,gBAAgB,EAC7B,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AK,CAAC,mBAAmB,CAAC;QAC9C,CAAC,CAAC,KAAK,CAAC,mBAAmB,EAAE;QAC7B,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAC9B,CAAA;IACD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,OAAO,CACL,KAAC,IAAI,OAAK,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAG,SAAiB,CAAC,GAAG,CAAC,YAC9D,MAAM,GACF,CACR,CAAA;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,cAAc,EAAE,CAAA;IAClC,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;IAC7B,IAAI,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;QAAE,OAAO,4BAAG,WAAW,GAAI,CAAA;IAChE,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
3
+ import { ListProvider } from './context';
4
+ import { ListWrapper, ListItems, ListHeader, ListFooter, ListPlaceholder } from './elements';
5
+ export * from './styles';
6
+ export * from './types';
7
+ export * from './context';
8
+ export * from './elements';
9
+ export * from './scroll';
10
+ /**
11
+ * Virtualized, optionally multi-column list with built-in infinite scroll, item separators, and a programmable scroll handle.
12
+ * Rendering is powered by Masonic; the list measures its container via `ResizeObserver` and will not render items until layout is ready.
13
+ * Uses: `List.Provider`, `List.Wrapper`, `List.Items`, `List.Footer`, `List.Placeholder`
14
+ */
15
+ export function List(props) {
16
+ const { data, renderItem, fetchNextPage, hasNextPage, ...providerProps } = { ...List.defaultProps, ...props };
17
+ return (_jsx(ListProvider, { ...providerProps, children: _jsxs(ListWrapper, { children: [_jsx(ListPlaceholder, {}), _jsx(ListItems, { data: data, renderItem: renderItem, fetchNextPage: fetchNextPage, hasNextPage: hasNextPage }), _jsx(ListFooter, {})] }) }));
18
+ }
19
+ List.Provider = ListProvider;
20
+ List.Wrapper = ListWrapper;
21
+ List.Items = ListItems;
22
+ List.Header = ListHeader;
23
+ List.Footer = ListFooter;
24
+ List.Placeholder = ListPlaceholder;
25
+ List.styleRegistryName = 'List';
26
+ List.elements = ['wrapper', 'list', 'header', 'footer', 'separator', 'placeholder', 'positioner'];
27
+ List.rootElement = 'wrapper';
28
+ List.withVariantTypes = (styles) => {
29
+ return List;
30
+ };
31
+ List.defaultProps = {
32
+ separators: true,
33
+ };
34
+ WebStyleRegistry.registerComponent(List);
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/List/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAG5F,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AAExB;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAqB,KAAmB;IAC1D,MAAM,EACJ,IAAI,EACJ,UAAU,EACV,aAAa,EACb,WAAW,EACX,GAAG,aAAa,EACjB,GAAG,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,KAAK,EAAkB,CAAA;IAEtD,OAAO,CACL,KAAC,YAAY,OAAK,aAAa,YAC7B,MAAC,WAAW,eACV,KAAC,eAAe,KAAG,EACnB,KAAC,SAAS,IACR,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,GACxB,EACF,KAAC,UAAU,KAAG,IACF,GACD,CAChB,CAAA;AACH,CAAC;AAED,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAA;AAC5B,IAAI,CAAC,OAAO,GAAG,WAAW,CAAA;AAC1B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;AACtB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAA;AACxB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAA;AACxB,IAAI,CAAC,WAAW,GAAG,eAAe,CAAA;AAElC,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAA;AAC/B,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,CAAA;AACjG,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;AAE5B,IAAI,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACzD,OAAO,IAA8F,CAAA;AACvG,CAAC,CAAA;AAED,IAAI,CAAC,YAAY,GAAG;IAClB,UAAU,EAAE,IAAI;CACe,CAAA;AAEjC,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,75 @@
1
+ import { useState } from 'react';
2
+ import { useContainerPosition, useScroller as useMasonicScroller, } from 'masonic';
3
+ import { useIsomorphicEffect } from '../../lib/hooks/useIsomorphicEffect';
4
+ import { useWindowSize } from '../../lib/hooks/useWindowSize';
5
+ function useElementScroller(ref) {
6
+ const [isScrolling, setIsScrolling] = useState(false);
7
+ const [scrollTop, setScrollTop] = useState(0);
8
+ useIsomorphicEffect(() => {
9
+ if (typeof window === 'undefined')
10
+ return;
11
+ const { current } = ref;
12
+ let tick;
13
+ if (current) {
14
+ const handleScroll = () => {
15
+ if (tick)
16
+ return;
17
+ tick = window.requestAnimationFrame(() => {
18
+ setScrollTop(current.scrollTop);
19
+ tick = void 0;
20
+ });
21
+ };
22
+ current.addEventListener('scroll', handleScroll);
23
+ return () => {
24
+ current.removeEventListener('scroll', handleScroll);
25
+ if (tick)
26
+ window.cancelAnimationFrame(tick);
27
+ };
28
+ }
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ }, [ref.current]);
31
+ useIsomorphicEffect(() => {
32
+ if (typeof window === 'undefined')
33
+ return;
34
+ setIsScrolling(true);
35
+ const to = window.setTimeout(() => {
36
+ setIsScrolling(false);
37
+ }, 1000 / 6);
38
+ return () => window.clearTimeout(to);
39
+ }, [scrollTop]);
40
+ return { scrollTop, isScrolling };
41
+ }
42
+ /**
43
+ * `UseListScrollHook` implementation that tracks scroll position on a specific container element.
44
+ * Use when the list's `List.Wrapper` is itself the scrolling surface (i.e. `overflow: auto/scroll`).
45
+ * This is the default scroll hook; override via `ListProviderProps.scrollHook` or set `windowScroll` to switch to `useWindowScroll`.
46
+ */
47
+ export const useElementScroll = (wrapperRef, layout) => {
48
+ const { scrollTop, isScrolling } = useElementScroller(wrapperRef);
49
+ return {
50
+ scrollTop,
51
+ isScrolling,
52
+ height: layout?.offsetHeight ?? 0,
53
+ width: layout?.width ?? 0,
54
+ scrollElement: wrapperRef,
55
+ };
56
+ };
57
+ /**
58
+ * `UseListScrollHook` implementation that tracks the browser window scroll position.
59
+ * Use when the page itself is the scrolling surface (e.g. no overflow container around the list).
60
+ * Enable via `ListProviderProps.windowScroll` or by passing this directly to `ListProviderProps.scrollHook`.
61
+ */
62
+ export const useWindowScroll = (wrapperRef, layout) => {
63
+ const windowSize = useWindowSize();
64
+ const windowHeight = windowSize[1];
65
+ const { offset } = useContainerPosition(wrapperRef, windowSize);
66
+ const { scrollTop, isScrolling } = useMasonicScroller(offset);
67
+ return {
68
+ scrollTop,
69
+ isScrolling,
70
+ height: windowHeight,
71
+ width: layout?.width ?? 0,
72
+ scrollElement: typeof window !== 'undefined' ? window : null,
73
+ };
74
+ };
75
+ //# sourceMappingURL=scroll.js.map
@@ -0,0 +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EAAE,YAAY;QACpB,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;QACzB,aAAa,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;KAC7D,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/List/styles.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/List/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { View } from '../View';
3
+ import { ActivityIndicator } from '../ActivityIndicator';
4
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
5
+ import { useNestedStylesByKey } from '@codeleap/styles';
6
+ import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
7
+ export * from './styles';
8
+ export * from './types';
9
+ /**
10
+ * `View` wrapper that renders an `ActivityIndicator` alongside its children;
11
+ * use `visible` to toggle the `wrapper:visible` style variant to show or hide
12
+ * the spinner layer.
13
+ * Uses: `View`, `ActivityIndicator`, `useStylesFor`, `WebStyleRegistry`
14
+ */
15
+ export const LoadingOverlay = (props) => {
16
+ const { visible, children, style, indicatorProps, debugName, ...rest } = {
17
+ ...LoadingOverlay.defaultProps,
18
+ ...props,
19
+ };
20
+ const styles = useStylesFor(LoadingOverlay.styleRegistryName, style);
21
+ const indicatorStyles = useNestedStylesByKey('indicator', styles);
22
+ return (_jsxs(View, { ...rest, style: [styles.wrapper, visible && styles['wrapper:visible']], children: [_jsx(ActivityIndicator, { debugName: debugName, ...indicatorProps, style: indicatorStyles }), children] }));
23
+ };
24
+ LoadingOverlay.styleRegistryName = 'LoadingOverlay';
25
+ LoadingOverlay.elements = ['wrapper', 'indicator'];
26
+ LoadingOverlay.rootElement = 'wrapper';
27
+ LoadingOverlay.withVariantTypes = (styles) => {
28
+ return LoadingOverlay;
29
+ };
30
+ LoadingOverlay.defaultProps = {};
31
+ WebStyleRegistry.registerComponent(LoadingOverlay);
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/LoadingOverlay/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAyC,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAE7D,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAE,EAAE;IAC3D,MAAM,EACJ,OAAO,EACP,QAAQ,EACR,KAAK,EACL,cAAc,EACd,SAAS,EACT,GAAG,IAAI,EACR,GAAG;QACF,GAAG,cAAc,CAAC,YAAY;QAC9B,GAAG,KAAK;KACT,CAAA;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAEpE,MAAM,eAAe,GAAG,oBAAoB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;IAEjE,OAAO,CACL,MAAC,IAAI,OAAK,IAAI,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC,aAC3E,KAAC,iBAAiB,IAAC,SAAS,EAAE,SAAS,KAAM,cAAc,EAAE,KAAK,EAAE,eAAe,GAAI,EACtF,QAAQ,IACJ,CACR,CAAA;AACH,CAAC,CAAA;AAED,cAAc,CAAC,iBAAiB,GAAG,gBAAgB,CAAA;AACnD,cAAc,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAClD,cAAc,CAAC,WAAW,GAAG,SAAS,CAAA;AAEtC,cAAc,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACnE,OAAO,cAA2F,CAAA;AACpG,CAAC,CAAA;AAED,cAAc,CAAC,YAAY,GAAG,EAAkC,CAAA;AAEhE,gBAAgB,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/LoadingOverlay/styles.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/LoadingOverlay/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { useIMask } from 'react-imask';
3
+ import { TextInput } from '../TextInput';
4
+ import { maskPresets } from './mask';
5
+ import { useMemo, useCallback } from 'react';
6
+ import { TypeGuards } from '@codeleap/types';
7
+ export * from './types';
8
+ /**
9
+ * `TextInput` variant that applies a `react-imask` pattern mask via a set of named presets or a custom `react-imask` configuration.
10
+ * The `placeholder` defaults to the mask pattern string when none is provided.
11
+ * Uses: `TextInput`
12
+ */
13
+ export const MaskedTextInput = (props) => {
14
+ const { maskType, maskOptions: customMaskOptions, onAccept, onComplete, unmask = false, onValueChange, value, ...textInputProps } = props;
15
+ const maskOptions = useMemo(() => {
16
+ const preset = maskType ? maskPresets[maskType] : {};
17
+ return {
18
+ ...preset,
19
+ ...customMaskOptions,
20
+ unmask,
21
+ };
22
+ }, [maskType, customMaskOptions, unmask]);
23
+ const handleAccept = useCallback((value, maskRef, e) => {
24
+ onAccept?.(value, maskRef, e);
25
+ onValueChange?.(value);
26
+ }, [onAccept, onValueChange]);
27
+ const { ref: maskRef } = useIMask(maskOptions, {
28
+ onAccept: handleAccept,
29
+ onComplete,
30
+ });
31
+ const placeholder = textInputProps?.placeholder ?? (TypeGuards.isString(maskOptions?.mask) ? maskOptions?.mask : undefined);
32
+ return (_jsx(TextInput, { ...textInputProps, placeholder: placeholder, ref: maskRef, value: value, onValueChange: onValueChange }));
33
+ };
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MaskedTextInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,cAAc,SAAS,CAAA;AAEvB;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,EACJ,QAAQ,EACR,WAAW,EAAE,iBAAiB,EAC9B,QAAQ,EACR,UAAU,EACV,MAAM,GAAG,KAAK,EACd,aAAa,EACb,KAAK,EACL,GAAG,cAAc,EAClB,GAAG,KAAK,CAAA;IAET,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;QAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QAEpD,OAAO;YACL,GAAG,MAAM;YACT,GAAG,iBAAiB;YACpB,MAAM;SACP,CAAA;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAA;IAEzC,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,OAAY,EAAE,CAAc,EAAE,EAAE;QAC/E,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;QAC7B,aAAa,EAAE,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAA;IAE7B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,WAAkB,EAAE;QACpD,QAAQ,EAAE,YAAY;QACtB,UAAU;KACX,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,cAAc,EAAE,WAAW,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAE3H,OAAO,CACL,KAAC,SAAS,OACJ,cAAc,EAClB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,OAAc,EACnB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,GAC5B,CACH,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,34 @@
1
+ export const maskPresets = {
2
+ 'credit-card': {
3
+ mask: '0000 0000 0000 0000',
4
+ lazy: false,
5
+ placeholderChar: '0',
6
+ },
7
+ 'cpf': {
8
+ mask: '000.000.000-00',
9
+ lazy: false,
10
+ placeholderChar: '0',
11
+ },
12
+ 'cnpj': {
13
+ mask: '00.000.000/0000-00',
14
+ lazy: false,
15
+ placeholderChar: '0',
16
+ },
17
+ 'zip-code': {
18
+ mask: '00000-000',
19
+ lazy: false,
20
+ placeholderChar: '0',
21
+ },
22
+ 'cel-phone': {
23
+ mask: '+000 000 000 000',
24
+ lazy: false,
25
+ placeholderChar: '0',
26
+ },
27
+ 'cel-phone-brl': {
28
+ mask: '(00) 00000-0000',
29
+ lazy: false,
30
+ placeholderChar: '0',
31
+ },
32
+ 'custom': {},
33
+ };
34
+ //# sourceMappingURL=mask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mask.js","sourceRoot":"","sources":["../../../src/components/MaskedTextInput/mask.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,WAAW,GAAkE;IACxF,aAAa,EAAE;QACb,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,KAAK;QACX,eAAe,EAAE,GAAG;KACrB;IACD,KAAK,EAAE;QACL,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,KAAK;QACX,eAAe,EAAE,GAAG;KACrB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,KAAK;QACX,eAAe,EAAE,GAAG;KACrB;IACD,UAAU,EAAE;QACV,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,KAAK;QACX,eAAe,EAAE,GAAG;KACrB;IACD,WAAW,EAAE;QACX,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,KAAK;QACX,eAAe,EAAE,GAAG;KACrB;IACD,eAAe,EAAE;QACf,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,KAAK;QACX,eAAe,EAAE,GAAG;KACrB;IACD,QAAQ,EAAE,EAAE;CACb,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/MaskedTextInput/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
4
+ function useModalProvider({ children: _children, ...props }) {
5
+ const styles = useStylesFor('Modal', props.style);
6
+ const close = () => {
7
+ props.toggle?.();
8
+ props.onClose?.();
9
+ };
10
+ return {
11
+ props,
12
+ styles: styles,
13
+ close,
14
+ };
15
+ }
16
+ export const ModalContext = createContext(null);
17
+ /**
18
+ * Reads the nearest `Modal.Provider` context value.
19
+ * Throws if called outside a `Modal.Provider` tree.
20
+ */
21
+ export const useModalContext = () => {
22
+ const ctx = useContext(ModalContext);
23
+ if (!ctx)
24
+ throw new Error('useModalContext must be used inside Modal.Provider');
25
+ return ctx;
26
+ };
27
+ /**
28
+ * Shares resolved styles and the `close` callback with all sub-components in a custom `Modal` layout.
29
+ * Required by `Modal.Backdrop`, `Modal.Box`, `Modal.Header`, `Modal.Body`, and `Modal.Footer` when composed manually.
30
+ * Uses: `useStylesFor`
31
+ */
32
+ export const ModalProvider = (props) => {
33
+ const value = useModalProvider(props);
34
+ return (_jsx(ModalContext.Provider, { value: value, children: props.children }));
35
+ };
36
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/Modal/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAIjD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAE3D,SAAS,gBAAgB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAc;IACrE,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAEjD,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,KAAK,CAAC,MAAM,EAAE,EAAE,CAAA;QAChB,KAAK,CAAC,OAAO,EAAE,EAAE,CAAA;IACnB,CAAC,CAAA;IAED,OAAO;QACL,KAAK;QACL,MAAM,EAAE,MAAuC;QAC/C,KAAK;KACN,CAAA;AACH,CAAC;AAID,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAA;AAEzE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAsB,EAAE;IACrD,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,CAAA;IACpC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;IAC/E,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAiB,EAAE,EAAE;IACjD,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,CACL,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAChC,KAAK,CAAC,QAAQ,GACO,CACzB,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
+ import { ModalOverlay, Modal as RACModal, Dialog, Heading, } from 'react-aria-components';
3
+ import { TypeGuards } from '@codeleap/types';
4
+ import { View } from '../View';
5
+ import { Text } from '../Text';
6
+ import { useModalContext } from './context';
7
+ /**
8
+ * Full-screen overlay that controls open/close state and dismiss gestures for the modal.
9
+ * Backdrop click dismissal and Escape-key dismissal are each gated by `closable` + their respective props.
10
+ * Must be rendered inside `Modal.Provider`.
11
+ */
12
+ export const ModalBackdrop = ({ children }) => {
13
+ const { styles, close, props } = useModalContext();
14
+ return (_jsx(ModalOverlay, { isOpen: !!props.visible, onOpenChange: (open) => { if (!open)
15
+ close(); }, isDismissable: !!(props.closable && props.dismissOnBackdrop), isKeyboardDismissDisabled: !props.closeOnEscape, css: styles.backdrop, children: children }));
16
+ };
17
+ /**
18
+ * Scoped dialog container that wraps children in a react-aria `Modal` + `Dialog` pair.
19
+ * Falls back to `debugName` or `"Dialog"` as the accessible label when no `title` is provided.
20
+ * Must be rendered inside `Modal.Backdrop`.
21
+ */
22
+ export const ModalBox = ({ children, 'aria-label': ariaLabel }) => {
23
+ const { styles, props } = useModalContext();
24
+ const resolvedAriaLabel = ariaLabel ?? (!props.title ? (props.debugName ?? 'Dialog') : undefined);
25
+ return (_jsx(RACModal, { css: styles.box, children: _jsx(Dialog, { "aria-label": resolvedAriaLabel, children: children }) }));
26
+ };
27
+ /**
28
+ * Renders the modal title, description, and optional close button; returns `null` when none of those are present.
29
+ * Props passed directly override values inherited from `Modal.Provider` context.
30
+ * Uses: `Text`, `View`
31
+ */
32
+ export const ModalHeader = ({ title, description, showClose, renderClose } = {}) => {
33
+ const { styles, close, props: ctxProps } = useModalContext();
34
+ const resolvedTitle = title ?? ctxProps.title;
35
+ const resolvedDescription = description ?? ctxProps.description;
36
+ const resolvedShowClose = showClose ?? ctxProps.showClose;
37
+ const resolvedRenderClose = renderClose ?? ctxProps.renderClose;
38
+ const showCloseButton = resolvedShowClose !== false && TypeGuards.isFunction(resolvedRenderClose);
39
+ const hasHeader = !!resolvedTitle || !!resolvedDescription || showCloseButton;
40
+ if (!hasHeader)
41
+ return null;
42
+ const titleElement = TypeGuards.isString(resolvedTitle) ? (_jsx(Text, { component: Heading, text: resolvedTitle, slot: 'title', css: styles.title })) : (resolvedTitle ?? null);
43
+ return (_jsxs(_Fragment, { children: [_jsxs(View, { component: 'header', style: styles.header, children: [titleElement, resolvedRenderClose?.({ close }) ?? null] }), resolvedDescription && (TypeGuards.isString(resolvedDescription) ? (_jsx(Text, { text: resolvedDescription, style: styles.description })) : resolvedDescription)] }));
44
+ };
45
+ /**
46
+ * Scrollable content area of the modal.
47
+ * Must be rendered inside `Modal.Provider`.
48
+ * Uses: `View`
49
+ */
50
+ export const ModalBody = ({ children }) => {
51
+ const { styles } = useModalContext();
52
+ return _jsx(View, { style: styles.body, children: children });
53
+ };
54
+ /**
55
+ * Sticky action area rendered below `Modal.Body`; falls back to the `footer` prop from context when no `children` are supplied.
56
+ * Returns `null` when no content is available.
57
+ * Uses: `View`
58
+ */
59
+ export const ModalFooter = ({ children }) => {
60
+ const { styles, props } = useModalContext();
61
+ const content = children ?? props.footer;
62
+ if (!content)
63
+ return null;
64
+ return _jsx(View, { component: 'footer', style: styles.footer, children: content });
65
+ };
66
+ //# sourceMappingURL=elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../../../src/components/Modal/elements.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,YAAY,EACZ,KAAK,IAAI,QAAQ,EACjB,MAAM,EACN,OAAO,GACR,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAG3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE;IACrE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,eAAe,EAAE,CAAA;IAElD,OAAO,CACL,KAAC,YAAY,IACX,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,EACvB,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;YAAE,KAAK,EAAE,CAAA,CAAC,CAAC,EAC9C,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,iBAAiB,CAAC,EAC5D,yBAAyB,EAAE,CAAC,KAAK,CAAC,aAAa,EAC/C,GAAG,EAAG,MAAc,CAAC,QAAQ,YAE5B,QAAQ,GACI,CAChB,CAAA;AACH,CAAC,CAAA;AAMD;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAY,EAAE,EAAE;IAC1E,MAAM,EAAE,MA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