@codeleap/web 7.0.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,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { Button } from '../Button';
4
+ import { Collapse } from '../Collapse';
5
+ import { View } from '../View';
6
+ import { HexColorPicker } from 'react-colorful';
7
+ import { TypeGuards } from '@codeleap/types';
8
+ import { useConditionalState, useState } from '@codeleap/hooks';
9
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
10
+ import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
11
+ export * from './styles';
12
+ export * from './types';
13
+ const DefaultFooter = (props) => {
14
+ const { styles, clearIcon, handleClear, confirmIcon, handleConfirmation } = props;
15
+ return (_jsxs(View, { style: styles.footerWrapper, children: [_jsx(Button, { debugName: 'ColorPicker footer trash', name: clearIcon, onPress: handleClear, style: styles.clearIcon }), _jsx(Button, { debugName: 'ColorPicker footer check', name: confirmIcon, onPress: handleConfirmation, style: styles.confirmIcon })] }));
16
+ };
17
+ /**
18
+ * Color selection control that wraps any `react-colorful` picker in either an inline (`isPlain`) or collapsible-dropdown layout with optional confirm/clear footer actions.
19
+ * Internal color state is initialised from `initialColor`; `onConfirm` fires only when the user explicitly confirms (not on every picker drag).
20
+ * Uses: `Button`, `Collapse`, `View`
21
+ */
22
+ export const ColorPicker = (props) => {
23
+ const { isPlain, initialColor, showFooter, icon, style, clearIcon, confirmIcon, onConfirm, onClear, closeOnConfirm, pickerComponent: PickerComponent, openPickerComponent: OpenPickerComponent, footerComponent: FooterComponent, openPickerProps, } = {
24
+ ...ColorPicker.defaultProps,
25
+ ...props,
26
+ };
27
+ const styles = useStylesFor(ColorPicker.styleRegistryName, style);
28
+ const [visible, toggle] = useConditionalState(props?.visible, props?.toggle, { initialValue: false });
29
+ const [color, setColor] = useState(initialColor);
30
+ const handleConfirmation = useCallback((color) => {
31
+ onConfirm?.(color);
32
+ if (closeOnConfirm)
33
+ toggle(false);
34
+ }, []);
35
+ const handleClear = useCallback((initialColor) => {
36
+ setColor(initialColor);
37
+ if (TypeGuards.isFunction(onClear))
38
+ onClear?.();
39
+ }, []);
40
+ // Dragging to change the color in any other way does not seem to work for some reason.
41
+ const picker = _jsx(View, { style: styles.picker, children: _jsx(PickerComponent, { color: color, onChange: setColor }) });
42
+ const openColorPickerBtn = !!OpenPickerComponent ? (_jsx(OpenPickerComponent, { color: color, visible: visible, toggle: () => toggle(!visible) })) : (_jsx(Button, { onPress: () => toggle(!visible), icon: icon, ...openPickerProps }));
43
+ return (_jsx(View, { style: styles.wrapper, children: isPlain ? picker : (_jsxs(_Fragment, { children: [openColorPickerBtn, _jsx(Collapse, { open: visible, style: [
44
+ styles.dropdown,
45
+ visible && styles['dropdown:open'],
46
+ ], children: _jsxs(View, { style: styles.dropdownInnerWrapper, children: [picker, showFooter ? (_jsx(FooterComponent, { color: color, handleConfirmation: () => handleConfirmation(color), handleClear: () => handleClear(initialColor), styles: styles, clearIcon: clearIcon, confirmIcon: confirmIcon })) : null] }) })] })) }));
47
+ };
48
+ ColorPicker.styleRegistryName = 'ColorPicker';
49
+ ColorPicker.elements = ['wrapper', 'picker', 'dropdown', 'dropdownInnerWrapper', 'footerWrapper', 'clearIcon', 'confirmIcon'];
50
+ ColorPicker.rootElement = 'wrapper';
51
+ ColorPicker.withVariantTypes = (styles) => {
52
+ return ColorPicker;
53
+ };
54
+ ColorPicker.defaultProps = {
55
+ pickerComponent: (props) => _jsx(HexColorPicker, { ...props }),
56
+ footerComponent: DefaultFooter,
57
+ icon: 'edit',
58
+ clearIcon: 'trash',
59
+ confirmIcon: 'check',
60
+ showFooter: true,
61
+ isPlain: false,
62
+ closeOnConfirm: true,
63
+ };
64
+ WebStyleRegistry.registerComponent(ColorPicker);
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAG7D,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,aAAa,GAAG,CAAC,KAA6B,EAAE,EAAE;IACtD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAA;IAEjF,OAAO,CACL,MAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,aAAa,aAC/B,KAAC,MAAM,IACL,SAAS,EAAC,0BAA0B,EACpC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,WAAW,EACpB,KAA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I,IACH,GACE,IACV,CACJ,GACI,CACR,CAAA;AACH,CAAC,CAAA;AAED,WAAW,CAAC,iBAAiB,GAAG,aAAa,CAAA;AAC7C,WAAW,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;AAC7H,WAAW,CAAC,WAAW,GAAG,SAAS,CAAA;AAEnC,WAAW,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAChE,OAAO,WAAqF,CAAA;AAC9F,CAAC,CAAA;AAED,WAAW,CAAC,YAAY,GAAG;IACzB,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,cAAc,OAAK,KAAK,GAAI;IACzD,eAAe,EAAE,aAAa;IAC9B,IAAI,EAAE,MAAiB;IACvB,SAAS,EAAE,OAAkB;IAC7B,WAAW,EAAE,OAAkB;IAC/B,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,IAAI;CACQ,CAAA;AAE9B,gBAAgB,CAAC,iBAAiB,CAAC,WAAW,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/ColorPicker/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/ColorPicker/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,130 @@
1
+ import { useMemo } from 'react';
2
+ import { useCallback, useEffect, useState } from 'react';
3
+ import { calculateProportionalDimensions, cropImage, readImage } from './utils';
4
+ /**
5
+ * Manages crop state for a `CropPicker`, including image loading, crop selection with minimum-size enforcement, confirm/cancel handlers, and display-size calculation.
6
+ * Pass the return value to `CropPicker` via the `handle` prop.
7
+ */
8
+ export function useCropPicker({ aspect, minWidth: minW, minHeight: minH, file, onCrop, }) {
9
+ const [image, setImage] = useState(null);
10
+ const [crop, setCrop] = useState();
11
+ const [relativeCrop, setRelativeCrop] = useState();
12
+ const [imageDimensions, setImageDimensions] = useState(null);
13
+ const cleanup = () => {
14
+ setRelativeCrop(null);
15
+ setCrop(undefined);
16
+ setImageDimensions(null);
17
+ setTimeout(() => setImage(null), 500);
18
+ };
19
+ const handleConfirmCrop = async () => {
20
+ const [preview, croppedBlob] = await cropImage(image, relativeCrop);
21
+ const newImage = {
22
+ file: new File([croppedBlob], 'cropped.jpg', {
23
+ type: 'image/jpeg',
24
+ lastModified: Date.now(),
25
+ }),
26
+ preview,
27
+ };
28
+ onCrop(newImage);
29
+ setTimeout(() => cleanup());
30
+ };
31
+ const handleCancelCrop = () => {
32
+ onCrop(null);
33
+ setTimeout(() => cleanup());
34
+ };
35
+ const loadFile = useCallback(async (toReadFile) => {
36
+ const imageData = await readImage(toReadFile);
37
+ const { naturalWidth, naturalHeight } = imageData;
38
+ const dimensions = calculateProportionalDimensions(naturalWidth, naturalHeight);
39
+ setImageDimensions(dimensions);
40
+ const targetAspect = aspect || dimensions.aspectRatio;
41
+ const imageAspect = dimensions.aspectRatio;
42
+ let initialCrop;
43
+ if (aspect) {
44
+ const v = imageAspect >= targetAspect
45
+ ? {
46
+ width: ((naturalHeight * targetAspect) / naturalWidth) * 100,
47
+ height: 100,
48
+ }
49
+ : {
50
+ width: 100,
51
+ height: (naturalWidth / targetAspect / naturalHeight) * 100,
52
+ };
53
+ initialCrop = {
54
+ ...v,
55
+ x: (100 - v.width) / 2,
56
+ y: (100 - v.height) / 2,
57
+ unit: '%',
58
+ };
59
+ }
60
+ else {
61
+ initialCrop = {
62
+ width: 100,
63
+ height: 100,
64
+ x: 0,
65
+ y: 0,
66
+ unit: '%',
67
+ };
68
+ }
69
+ setCrop(initialCrop);
70
+ setRelativeCrop(initialCrop);
71
+ setImage(imageData);
72
+ }, []);
73
+ const getMinDimensions = useCallback(() => {
74
+ if (!imageDimensions)
75
+ return { minWidth: minW ?? 100, minHeight: minH ?? 100 };
76
+ const targetAspect = aspect || imageDimensions.aspectRatio;
77
+ const calculatedMinWidth = (minW ?? 100) * targetAspect;
78
+ const calculatedMinHeight = minH ?? 100;
79
+ return {
80
+ minWidth: Math.max(calculatedMinWidth, 50),
81
+ minHeight: Math.max(calculatedMinHeight, 50),
82
+ };
83
+ }, [aspect, imageDimensions, minW, minH]);
84
+ const handleCropChange = useCallback((newCrop) => {
85
+ if (!imageDimensions) {
86
+ setCrop(newCrop);
87
+ return;
88
+ }
89
+ const { minWidth, minHeight } = getMinDimensions();
90
+ setCrop({
91
+ ...newCrop,
92
+ width: newCrop.width < minWidth ? minWidth : newCrop.width,
93
+ height: newCrop.height < minHeight ? minHeight : newCrop.height,
94
+ });
95
+ }, [imageDimensions, getMinDimensions]);
96
+ const containerStyles = useMemo(() => {
97
+ if (!imageDimensions)
98
+ return {};
99
+ return {
100
+ width: imageDimensions.displayWidth,
101
+ height: imageDimensions.displayHeight,
102
+ maxWidth: '90vw',
103
+ maxHeight: '70vh',
104
+ margin: '0 auto',
105
+ };
106
+ }, [imageDimensions]);
107
+ const imageStyles = useMemo(() => {
108
+ if (!imageDimensions)
109
+ return {};
110
+ return {
111
+ width: imageDimensions.displayWidth,
112
+ height: imageDimensions.displayHeight,
113
+ objectFit: 'contain',
114
+ };
115
+ }, [imageDimensions]);
116
+ useEffect(() => {
117
+ loadFile(file);
118
+ }, []);
119
+ return {
120
+ containerStyles,
121
+ imageStyles,
122
+ handleCropChange,
123
+ handleConfirmCrop,
124
+ handleCancelCrop,
125
+ setRelativeCrop,
126
+ crop,
127
+ image,
128
+ };
129
+ }
130
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/components/CropPicker/hooks.ts"],"names":[],"mappings":"AAAA,OAA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AE,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK;YAC1D,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM;SAChE,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAA;IAEvC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE;QACnC,IAAI,CAAC,eAAe;YAAE,OAAO,EAAE,CAAA;QAE/B,OAAO;YACL,KAAK,EAAE,eAAe,CAAC,YAAY;YACnC,MAAM,EAAE,eAAe,CAAC,aAAa;YACrC,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,MAAM;YACjB,MAAM,EAAE,QAAQ;SACjB,CAAA;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAA;IAErB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;QAC/B,IAAI,CAAC,eAAe;YAAE,OAAO,EAAE,CAAA;QAE/B,OAAO;YACL,KAAK,EAAE,eAAe,CAAC,YAAY;YACnC,MAAM,EAAE,eAAe,CAAC,aAAa;YACrC,SAAS,EAAE,SAAkB;SAC9B,CAAA;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAA;IAErB,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACL,eAAe;QACf,WAAW;QACX,gBAAgB;QAChB,iBAAiB;QACjB,gBAAgB;QAChB,eAAe;QACf,IAAI;QACJ,KAAK;KACN,CAAA;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { useCompositionStyles } from '@codeleap/styles';
3
+ import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
4
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
5
+ import { View } from '../View';
6
+ import { ActivityIndicator } from '../ActivityIndicator';
7
+ import 'react-image-crop/dist/ReactCrop.css';
8
+ const ReactCrop = require('react-image-crop').Component;
9
+ export * from './styles';
10
+ export * from './types';
11
+ export * from './hooks';
12
+ /**
13
+ * Image crop editor that wraps react-image-crop and delegates all crop state to a `useCropPicker` handle.
14
+ * Renders a loading spinner while the image is being decoded; renders nothing when `handle` is not provided.
15
+ */
16
+ export const CropPicker = (props) => {
17
+ const { style, handle, reactCrop, aspect, children, } = {
18
+ ...CropPicker.defaultProps,
19
+ ...props,
20
+ };
21
+ const styles = useStylesFor(CropPicker.styleRegistryName, style);
22
+ const compositionStyles = useCompositionStyles(['indicator'], styles);
23
+ if (!handle)
24
+ return null;
25
+ const { image, crop, setRelativeCrop, handleCropChange, } = handle;
26
+ return (_jsxs(View, { style: styles.wrapper, children: [!image?.src ? (_jsx(ActivityIndicator, { style: compositionStyles.indicator, debugName: 'CropPickerLoading' })) : (_jsx(ReactCrop, { ...reactCrop, crop: crop, onChange: handleCropChange, onComplete: (_, relCrop) => setRelativeCrop(relCrop), style: styles.crop, aspect: aspect ?? reactCrop?.aspect, children: _jsx("img", { src: image.src,
27
+ // @ts-ignore
28
+ css: [styles?.image] }) })), children] }));
29
+ };
30
+ CropPicker.styleRegistryName = 'CropPicker';
31
+ CropPicker.elements = ['crop', 'image', 'wrapper', 'indicator'];
32
+ CropPicker.rootElement = 'crop';
33
+ CropPicker.withVariantTypes = (styles) => {
34
+ return CropPicker;
35
+ };
36
+ CropPicker.defaultProps = {};
37
+ WebStyleRegistry.registerComponent(CropPicker);
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CropPicker/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAyC,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,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EAAE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,EACpD,KAAK,EAAE,MAAM,CAAC,IAAI,EAClB,MAAM,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,YAEnC,cACE,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,aAAa;oBACb,GAAG,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,GACpB,GACQ,CACb,EACA,QAAQ,IACJ,CACR,CAAA;AACH,CAAC,CAAA;AAED,UAAU,CAAC,iBAAiB,GAAG,YAAY,CAAA;AAC3C,UAAU,CAAC,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/D,UAAU,CAAC,WAAW,GAAG,MAAM,CAAA;AAC/B,UAAU,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC/D,OAAO,UAAmF,CAAA;AAC5F,CAAC,CAAA;AAED,UAAU,CAAC,YAAY,GAAG,EAA8B,CAAA;AAExD,gBAAgB,CAAC,iBAAiB,CAAC,UAAU,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/CropPicker/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/CropPicker/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ /** Reads a `File` or `Blob` as a data-URL and resolves with a loaded `HTMLImageElement`. */
2
+ export function readImage(file) {
3
+ return new Promise((resolve, reject) => {
4
+ const reader = new FileReader();
5
+ reader.onload = () => {
6
+ const image = new Image();
7
+ image.onload = () => resolve(image);
8
+ image.onerror = () => reject(new Error('Failed to load image'));
9
+ image.src = reader.result;
10
+ };
11
+ reader.onerror = () => reject(new Error('Failed to read file'));
12
+ reader.readAsDataURL(file);
13
+ });
14
+ }
15
+ /**
16
+ * Renders the specified percentage-unit `crop` region of `image` onto an off-screen canvas and returns a `[dataURL, Blob]` tuple.
17
+ * The output blob is always `image/png` at quality 1.
18
+ */
19
+ export async function cropImage(image, crop) {
20
+ if (!crop.width || !crop.height) {
21
+ throw new Error('Invalid crop dimensions');
22
+ }
23
+ const canvas = document.createElement('canvas');
24
+ const ctx = canvas.getContext('2d', { willReadFrequently: true });
25
+ if (!ctx) {
26
+ throw new Error('Could not get canvas 2d context');
27
+ }
28
+ const scaleX = image.naturalWidth / 100;
29
+ const scaleY = image.naturalHeight / 100;
30
+ canvas.width = crop.width * scaleX;
31
+ canvas.height = crop.height * scaleY;
32
+ ctx.drawImage(image, crop.x * scaleX, crop.y * scaleY, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height);
33
+ try {
34
+ const blob = await new Promise((resolve, reject) => {
35
+ canvas.toBlob(blob => blob ? resolve(blob) : reject(new Error('Canvas is empty')), 'image/png', 1);
36
+ });
37
+ const croppedImage = await readImage(blob);
38
+ return [croppedImage.src, blob];
39
+ }
40
+ catch (error) {
41
+ throw new Error(`Failed to crop image: ${error instanceof Error ? error.message : String(error)}`);
42
+ }
43
+ }
44
+ /**
45
+ * Scales natural image dimensions down to fit within a 600×400 display budget while preserving aspect ratio.
46
+ * Returns both the original natural dimensions and the calculated display dimensions.
47
+ */
48
+ export const calculateProportionalDimensions = (naturalWidth, naturalHeight) => {
49
+ const aspectRatio = naturalWidth / naturalHeight;
50
+ const maxWidth = 600;
51
+ const maxHeight = 400;
52
+ let displayWidth = naturalWidth;
53
+ let displayHeight = naturalHeight;
54
+ if (displayHeight > maxHeight) {
55
+ displayHeight = maxHeight;
56
+ displayWidth = displayHeight * aspectRatio;
57
+ }
58
+ if (displayWidth > maxWidth) {
59
+ displayWidth = maxWidth;
60
+ displayHeight = displayWidth / aspectRatio;
61
+ }
62
+ return {
63
+ naturalWidth,
64
+ naturalHeight,
65
+ displayWidth: Math.round(displayWidth),
66
+ displayHeight: Math.round(displayHeight),
67
+ aspectRatio,
68
+ };
69
+ };
70
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/CropPicker/utils.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,MAAM,UAAU,SAAS,CAAC,IAAiB;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAA;QAE/B,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACnB,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAA;YACzB,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YACnC,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAA;YAC/D,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAgB,CAAA;QACrC,CAAC,CAAA;QAED,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAA;QAC/D,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAuB,EACvB,IAAU;IAEV,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,GAAG,GAAG,MAAM,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OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACpG,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,YAAoB,EAAE,aAAqB,EAAE,EAAE;IAC7F,MAAM,WAAW,GAAG,YAAY,GAAG,aAAa,CAAA;IAEhD,MAAM,QAAQ,GAAG,GAAG,CAAA;IACpB,MAAM,SAAS,GAAG,GAAG,CAAA;IAErB,IAAI,YAAY,GAAG,YAAY,CAAA;IAC/B,IAAI,aAAa,GAAG,aAAa,CAAA;IAEjC,IAAI,aAAa,GAAG,SAAS,EAAE,CAAC;QAC9B,aAAa,GAAG,SAAS,CAAA;QACzB,YAAY,GAAG,aAAa,GAAG,WAAW,CAAA;IAC5C,CAAC;IAED,IAAI,YAAY,GAAG,QAAQ,EAAE,CAAC;QAC5B,YAAY,GAAG,QAAQ,CAAA;QACvB,aAAa,GAAG,YAAY,GAAG,WAAW,CAAA;IAC5C,CAAC;IAED,OAAO;QACL,YAAY;QACZ,aAAa;QACb,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;QACtC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;QACxC,WAAW;KACZ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import { Popover } from 'react-aria-components';
4
+ import { CalendarDate, getLocalTimeZone } from '@internationalized/date';
5
+ import { useConditionalState } from '@codeleap/hooks';
6
+ import { fields } from '@codeleap/form';
7
+ import { View } from '../View';
8
+ import { Calendar } from '../Calendar';
9
+ import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
10
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
11
+ import { useFieldInput } from '../Field';
12
+ export * from './styles';
13
+ export * from './types';
14
+ function dateToCalendarDate(date) {
15
+ if (!date)
16
+ return null;
17
+ return new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
18
+ }
19
+ function calendarDateToDate(cal) {
20
+ return cal.toDate(getLocalTimeZone());
21
+ }
22
+ function defaultFormatDate(date) {
23
+ return date.toLocaleDateString(undefined, { day: '2-digit', month: '2-digit', year: 'numeric' });
24
+ }
25
+ /**
26
+ * Date selection control that pairs a fully custom trigger element with a `react-aria-components` `Popover` containing a `Calendar`.
27
+ * Converts native `Date` values to/from `@internationalized/date` `CalendarDate` for the calendar; closes the popover after a date is selected.
28
+ * Uses: `View`, `Calendar`
29
+ */
30
+ export function DatePicker(props) {
31
+ const { value, onValueChange, field, style, defaultValue, renderTrigger, calendarProps, minDate, maxDate, disabled, visible: providedVisible, toggle: providedToggle, formatDate, label, helper, placeholder, forceError, } = { ...DatePicker.defaultProps, ...props };
32
+ const styles = useStylesFor(DatePicker.styleRegistryName, style);
33
+ const triggerRef = useRef(null);
34
+ const [isOpen, setIsOpen] = useConditionalState(providedVisible, providedToggle, { initialValue: false });
35
+ const { inputValue, onInputValueChange, validation } = useFieldInput(field, fields.date, { value, onValueChange });
36
+ const hasError = validation?.showError || !!forceError;
37
+ const errorMessage = validation?.message || forceError;
38
+ const formattedValue = inputValue ? (formatDate ?? defaultFormatDate)(inputValue) : '';
39
+ const handleCalendarChange = (date) => {
40
+ onInputValueChange(calendarDateToDate(date));
41
+ setIsOpen(false);
42
+ };
43
+ return (_jsxs(View, { style: styles.wrapper, children: [renderTrigger?.({
44
+ ref: triggerRef,
45
+ value: inputValue ?? null,
46
+ formattedValue,
47
+ isOpen,
48
+ onPress: () => setIsOpen(!isOpen),
49
+ disabled: !!disabled,
50
+ style: styles.trigger,
51
+ label,
52
+ placeholder,
53
+ helper,
54
+ error: hasError ? errorMessage : undefined,
55
+ hasValue: !!inputValue,
56
+ }), _jsx(Popover, { triggerRef: triggerRef, isOpen: isOpen, onOpenChange: setIsOpen, css: styles.popover, children: _jsx(Calendar, { value: dateToCalendarDate(inputValue) ?? undefined, onChange: handleCalendarChange, minValue: dateToCalendarDate(minDate) ?? undefined, maxValue: dateToCalendarDate(maxDate) ?? undefined, defaultValue: dateToCalendarDate(defaultValue) ?? undefined, ...calendarProps }) })] }));
57
+ }
58
+ DatePicker.styleRegistryName = 'DatePicker';
59
+ DatePicker.elements = ['wrapper', 'popover', 'trigger'];
60
+ DatePicker.rootElement = 'wrapper';
61
+ DatePicker.withVariantTypes = (styles) => {
62
+ return DatePicker;
63
+ };
64
+ DatePicker.defaultProps = {
65
+ minDate: new Date(1910, 0, 1),
66
+ maxDate: new Date(),
67
+ disabled: false,
68
+ };
69
+ WebStyleRegistry.registerComponent(DatePicker);
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DatePicker/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,SAAS,kBAAkB,CAAC,IAA6B;IACvD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,OAAO,IAAI,YAAY,CAAC,IAA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,YAAY,CAAC,IAAI,SAAS,KACvD,aAAa,GACjB,GACM,IACL,CACR,CAAA;AACH,CAAC;AAED,UAAU,CAAC,iBAAiB,GAAG,YAAY,CAAA;AAC3C,UAAU,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AACvD,UAAU,CAAC,WAAW,GAAG,SAAS,CAAA;AAClC,UAAU,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC/D,OAAO,UAAmF,CAAA;AAC5F,CAAC,CAAA;AACD,UAAU,CAAC,YAAY,GAAG;IACxB,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7B,OAAO,EAAE,IAAI,IAAI,EAAE;IACnB,QAAQ,EAAE,KAAK;CACY,CAAA;AAE7B,gBAAgB,CAAC,iBAAiB,CAAC,UAAU,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/DatePicker/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/DatePicker/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { Modal as RACModal, Dialog } from 'react-aria-components';
3
+ import { ModalContext, useModalContext } from '../Modal/context';
4
+ import { ModalBackdrop, ModalBody, ModalFooter, ModalHeader } from '../Modal/elements';
5
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
6
+ import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
7
+ export * from './styles';
8
+ export * from './types';
9
+ const DrawerProvider = ({ children, position: _position, ...props }) => {
10
+ const styles = useStylesFor(Drawer.styleRegistryName, props.style);
11
+ const close = () => {
12
+ props.toggle?.();
13
+ props.onClose?.();
14
+ };
15
+ const value = {
16
+ props,
17
+ styles: styles,
18
+ close,
19
+ };
20
+ return (_jsx(ModalContext.Provider, { value: value, children: children }));
21
+ };
22
+ const DrawerBox = ({ children, position }) => {
23
+ const { styles, props } = useModalContext();
24
+ const resolvedAriaLabel = !props.title ? (props.debugName ?? 'Dialog') : undefined;
25
+ return (_jsx(RACModal, { css: styles.box, "data-position": position, children: _jsx(Dialog, { "aria-label": resolvedAriaLabel, children: children }) }));
26
+ };
27
+ /**
28
+ * Side-panel overlay that slides in from a configurable edge of the viewport.
29
+ * Shares the same dismiss mechanics as `Modal` (backdrop click, Escape key), controlled by `closable` et al.
30
+ * Uses: `ModalBackdrop`, `ModalBody`, `ModalFooter`, `ModalHeader`
31
+ */
32
+ export const Drawer = (props) => {
33
+ const { children, position, ...rest } = { ...Drawer.defaultProps, ...props };
34
+ return (_jsx(DrawerProvider, { ...rest, position: position, children: _jsx(ModalBackdrop, { children: _jsxs(DrawerBox, { position: position, children: [_jsx(ModalHeader, {}), _jsx(ModalBody, { children: children }), _jsx(ModalFooter, {})] }) }) }));
35
+ };
36
+ Drawer.styleRegistryName = 'Drawer';
37
+ Drawer.elements = ['backdrop', 'box', 'header', 'body', 'footer', 'title', 'description'];
38
+ Drawer.rootElement = 'backdrop';
39
+ Drawer.withVariantTypes = (styles) => {
40
+ return Drawer;
41
+ };
42
+ Drawer.defaultProps = {
43
+ position: 'left',
44
+ closable: true,
45
+ showClose: false,
46
+ dismissOnBackdrop: true,
47
+ closeOnEscape: true,
48
+ };
49
+ WebStyleRegistry.registerComponent(Drawer);
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Drawer/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAA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BAAiB,YAClC,QAAQ,GACF,GACA,CACZ,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC3C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,YAAY,EAAE,GAAG,KAAK,EAAE,CAAA;IAC5E,OAAO,CACL,KAAC,cAAc,OAAK,IAAI,EAAE,QAAQ,EAAE,QAAQ,YAC1C,KAAC,aAAa,cACZ,MAAC,SAAS,IAAC,QAAQ,EAAE,QAAQ,aAC3B,KAAC,WAAW,KAAG,EACf,KAAC,SAAS,cAAE,QAAQ,GAAa,EACjC,KAAC,WAAW,KAAG,IACL,GACE,GACD,CAClB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,iBAAiB,GAAG,QAAQ,CAAA;AACnC,MAAM,CAAC,QAAQ,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA;AACzF,MAAM,CAAC,WAAW,GAAG,UAAU,CAAA;AAE/B,MAAM,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC3D,OAAO,MAA2E,CAAA;AACpF,CAAC,CAAA;AAED,MAAM,CAAC,YAAY,GAAG;IACpB,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,KAAK;IAChB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,IAAI;CACI,CAAA;AAEzB,gBAAgB,CAAC,iBAAiB,CAAC,MAAM,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/Drawer/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/Drawer/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ import { useStylesFor } from '../../lib/hooks/useStylesFor';
4
+ import { useDropzone } from './useDropzone';
5
+ function useDropzoneProvider(props) {
6
+ const { handle: externalHandle, style, children: _children, extensionProps = {}, ...dropzoneOptions } = props;
7
+ // Always call the hook — satisfies Rules of Hooks.
8
+ // When an external handle is provided its result is discarded.
9
+ const internalHandle = useDropzone(dropzoneOptions);
10
+ const handle = externalHandle ?? internalHandle;
11
+ const styles = useStylesFor('Dropzone', style);
12
+ return {
13
+ handle,
14
+ styles: styles,
15
+ extensionProps,
16
+ };
17
+ }
18
+ export const DropzoneContext = createContext(null);
19
+ /**
20
+ * Reads the nearest `Dropzone.Provider` context value.
21
+ * Throws if called outside a `Dropzone.Provider` tree.
22
+ */
23
+ export const useDropzoneContext = () => {
24
+ const ctx = useContext(DropzoneContext);
25
+ if (!ctx)
26
+ throw new Error('useDropzoneContext must be used inside Dropzone.Provider');
27
+ return ctx;
28
+ };
29
+ /**
30
+ * Wires a `DropzoneHandle` and resolved styles into React context for all
31
+ * Dropzone sub-components. Accepts either a pre-built `handle` prop (external
32
+ * control) or raw `UseDropzoneOptions` to have the Provider create a handle
33
+ * internally.
34
+ */
35
+ export const DropzoneProvider = (props) => {
36
+ const value = useDropzoneProvider(props);
37
+ return (_jsx(DropzoneContext.Provider, { value: value, children: props.children }));
38
+ };
39
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/Dropzone/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAIjD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,SAAS,mBAAmB,CAAC,KAA4B;IACvD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,GAAG,EAA+B,EAAE,GAAG,eAAe,EAAE,GAAG,KAAK,CAAA;IAE1I,mDAAmD;IACnD,+DAA+D;IAC/D,MAAM,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC,CAAA;IACnD,MAAM,MAAM,GAAG,cAAc,IAAI,cAAc,CAAA;IAE/C,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAE9C,OAAO;QACL,MAAM;QACN,MAAM,EAAE,MAA0C;QAClD,cAAc;KACf,CAAA;AACH,CAAC;AAID,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAA8B,IAAI,CAAC,CAAA;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAyB,EAAE;IAC3D,MAAM,GAAG,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IACvC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAA;IACrF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAA4B,EAAE,EAAE;IAC/D,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAA;IACxC,OAAO,CACL,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACnC,KAAK,CAAC,QAAQ,GACU,CAC5B,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createPortal } from 'react-dom';
3
+ import { View } from '../View';
4
+ import { useDropzoneContext } from './context';
5
+ /**
6
+ * Droppable zone element. Applies `getRootProps` and `getInputProps` from the
7
+ * nearest `Dropzone.Provider` handle to a root `View` and a hidden `<input>`.
8
+ *
9
+ * Must be rendered inside `Dropzone.Provider`.
10
+ */
11
+ export const DropzoneWrapper = ({ children }) => {
12
+ const { handle, styles } = useDropzoneContext();
13
+ return (_jsxs(View, { ...handle.dropzone.getRootProps(), style: styles.dropzone, children: [children, _jsx("input", { ...handle.dropzone.getInputProps() })] }));
14
+ };
15
+ /**
16
+ * Overlay rendered on top of `Dropzone.Wrapper` while a file is being dragged
17
+ * over this specific zone (`isDragActive`). Place it as a child of
18
+ * `Dropzone.Wrapper` so it inherits the wrapper's positioning context.
19
+ *
20
+ * For a page-wide overlay that activates when dragging anywhere on the
21
+ * document, use `Dropzone.FullscreenOverlay` instead.
22
+ *
23
+ * Must be rendered inside `Dropzone.Provider`.
24
+ */
25
+ export const DropzoneOverlay = ({ children }) => {
26
+ const { handle, styles } = useDropzoneContext();
27
+ if (!handle.dropzone.isDragActive)
28
+ return null;
29
+ return (_jsx(View, { style: styles.overlay, children: _jsx(View, { style: styles.overlayInner, children: children }) }));
30
+ };
31
+ /**
32
+ * Full-page overlay rendered via a React portal into `document.body` while
33
+ * a file is being dragged anywhere on the document (`isDragGlobal`).
34
+ *
35
+ * Unlike `Dropzone.Overlay`, this component is not scoped to the wrapper zone —
36
+ * it activates the moment a drag enters the browser window. Position it with
37
+ * `position: fixed; inset: 0` in the `overlay` style key.
38
+ *
39
+ * Must be rendered inside `Dropzone.Provider`.
40
+ */
41
+ export const DropzoneFullscreenOverlay = ({ children }) => {
42
+ const { handle, styles } = useDropzoneContext();
43
+ if (!handle.dropzone.isDragGlobal)
44
+ return null;
45
+ if (typeof document === 'undefined')
46
+ return null;
47
+ // Spread getRootProps (minus ref) so drops on the fullscreen overlay are captured by this dropzone.
48
+ const { ref: _ref, ...rootProps } = handle.dropzone.getRootProps();
49
+ return createPortal(_jsx(View, { ...rootProps, style: styles.fullscreenOverlay, children: _jsx(View, { style: styles.fullscreenOverlayInner, children: children }) }), document.body);
50
+ };
51
+ //# sourceMappingURL=elements.js.map