@tcn/ui 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/README.md +38 -3
  2. package/dist/divider.module-FptFV0PX.js +5 -0
  3. package/dist/divider.module-FptFV0PX.js.map +1 -0
  4. package/dist/draggable.css +1 -0
  5. package/dist/feedback/progress/progress_bar.js +1 -1
  6. package/dist/form/field/common/field_description.js +1 -1
  7. package/dist/form/field/common/field_error.js +1 -1
  8. package/dist/form/field/common/field_label.js +1 -1
  9. package/dist/form/field/field.js +1 -1
  10. package/dist/frame.css +1 -0
  11. package/dist/inputs/color_input/color_input.js +1 -1
  12. package/dist/inputs/color_input/color_input.js.map +1 -1
  13. package/dist/inputs/color_input/color_picker.js +1 -1
  14. package/dist/inputs/combo_box/combo_box.js +1 -1
  15. package/dist/inputs/date_picker/date_picker.js +1 -1
  16. package/dist/inputs/date_picker/date_picker_date.js +1 -1
  17. package/dist/inputs/date_picker/date_picker_day.js +1 -1
  18. package/dist/inputs/date_picker/date_picker_input.js +2 -2
  19. package/dist/inputs/date_picker/date_picker_input.js.map +1 -1
  20. package/dist/inputs/date_picker/date_picker_time_selector.js +1 -1
  21. package/dist/inputs/date_picker/date_picker_year_input.js +1 -1
  22. package/dist/inputs/date_picker/date_picker_year_input.js.map +1 -1
  23. package/dist/inputs/date_picker/date_picker_year_selector.js +2 -2
  24. package/dist/inputs/mask_input/key_capture_input.js +1 -1
  25. package/dist/inputs/mask_input/mask_input.js +1 -1
  26. package/dist/inputs/multiselect/multiselect.js +1 -1
  27. package/dist/inputs/phone_number_input/phone_number_input.d.ts +2 -0
  28. package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
  29. package/dist/inputs/phone_number_input/phone_number_input.js +160 -154
  30. package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
  31. package/dist/inputs/select/select.js +1 -1
  32. package/dist/inputs/slider/slider.js +1 -1
  33. package/dist/inputs/suggestions/suggestion_list.js +3 -3
  34. package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
  35. package/dist/inputs/switch/switch.js +1 -1
  36. package/dist/inputs/textarea/textarea.d.ts +2 -2
  37. package/dist/inputs/textarea/textarea.d.ts.map +1 -1
  38. package/dist/inputs/textarea/textarea.js.map +1 -1
  39. package/dist/inputs/unit_input/unit_input.js +1 -1
  40. package/dist/layouts/divider/divider.js +24 -23
  41. package/dist/layouts/divider/divider.js.map +1 -1
  42. package/dist/layouts/header/header.d.ts.map +1 -1
  43. package/dist/layouts/header/header.js.map +1 -1
  44. package/dist/layouts/index.d.ts +6 -5
  45. package/dist/layouts/index.d.ts.map +1 -1
  46. package/dist/layouts/index.js +28 -26
  47. package/dist/layouts/index.js.map +1 -1
  48. package/dist/layouts/scaffold/scaffold.d.ts +9 -0
  49. package/dist/layouts/scaffold/scaffold.d.ts.map +1 -0
  50. package/dist/layouts/scaffold/scaffold.js +55 -0
  51. package/dist/layouts/scaffold/scaffold.js.map +1 -0
  52. package/dist/modal.css +1 -1
  53. package/dist/overlay/frame/frame.d.ts +11 -0
  54. package/dist/overlay/frame/frame.d.ts.map +1 -0
  55. package/dist/overlay/frame/frame.js +35 -0
  56. package/dist/overlay/frame/frame.js.map +1 -0
  57. package/dist/overlay/index.d.ts +10 -2
  58. package/dist/overlay/index.d.ts.map +1 -1
  59. package/dist/overlay/index.js +22 -8
  60. package/dist/overlay/index.js.map +1 -1
  61. package/dist/overlay/menu/menu.d.ts +1 -1
  62. package/dist/overlay/menu/menu.d.ts.map +1 -1
  63. package/dist/overlay/menu/menu.js +2 -2
  64. package/dist/overlay/menu/menu.js.map +1 -1
  65. package/dist/overlay/popper/base/base_popper.d.ts +11 -0
  66. package/dist/overlay/popper/base/base_popper.d.ts.map +1 -0
  67. package/dist/overlay/popper/base/base_popper.js +27 -0
  68. package/dist/overlay/popper/base/base_popper.js.map +1 -0
  69. package/dist/overlay/popper/base/dismissal_decorator.d.ts +16 -0
  70. package/dist/overlay/popper/base/dismissal_decorator.d.ts.map +1 -0
  71. package/dist/overlay/popper/base/dismissal_decorator.js +69 -0
  72. package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -0
  73. package/dist/overlay/popper/context_popper.d.ts +11 -0
  74. package/dist/overlay/popper/context_popper.d.ts.map +1 -0
  75. package/dist/overlay/popper/context_popper.js +33 -0
  76. package/dist/overlay/popper/context_popper.js.map +1 -0
  77. package/dist/overlay/popper/element_popper.d.ts +7 -0
  78. package/dist/overlay/popper/element_popper.d.ts.map +1 -0
  79. package/dist/overlay/popper/element_popper.js +33 -0
  80. package/dist/overlay/popper/element_popper.js.map +1 -0
  81. package/dist/overlay/popper/hooks/use_context_trigger.d.ts +7 -0
  82. package/dist/overlay/popper/hooks/use_context_trigger.d.ts.map +1 -0
  83. package/dist/overlay/popper/hooks/use_context_trigger.js +31 -0
  84. package/dist/overlay/popper/hooks/use_context_trigger.js.map +1 -0
  85. package/dist/overlay/popper/hooks/use_hover_trigger.d.ts +6 -0
  86. package/dist/overlay/popper/hooks/use_hover_trigger.d.ts.map +1 -0
  87. package/dist/overlay/popper/hooks/use_hover_trigger.js +17 -0
  88. package/dist/overlay/popper/hooks/use_hover_trigger.js.map +1 -0
  89. package/dist/overlay/popper/hooks/use_restore_focus.d.ts +2 -0
  90. package/dist/overlay/popper/hooks/use_restore_focus.d.ts.map +1 -0
  91. package/dist/overlay/popper/hooks/use_restore_focus.js +18 -0
  92. package/dist/overlay/popper/hooks/use_restore_focus.js.map +1 -0
  93. package/dist/overlay/popper/legacy/popper.d.ts.map +1 -0
  94. package/dist/overlay/popper/{popper.js → legacy/popper.js} +6 -6
  95. package/dist/overlay/popper/legacy/popper.js.map +1 -0
  96. package/dist/overlay/popper/preview_popper.d.ts +7 -0
  97. package/dist/overlay/popper/preview_popper.d.ts.map +1 -0
  98. package/dist/overlay/popper/preview_popper.js +46 -0
  99. package/dist/overlay/popper/preview_popper.js.map +1 -0
  100. package/dist/overlay/tethered/element_tethered.d.ts +8 -0
  101. package/dist/overlay/tethered/element_tethered.d.ts.map +1 -0
  102. package/dist/overlay/tethered/element_tethered.js +33 -0
  103. package/dist/overlay/tethered/element_tethered.js.map +1 -0
  104. package/dist/overlay/tethered/hooks/calculate_position.d.ts +19 -0
  105. package/dist/overlay/tethered/hooks/calculate_position.d.ts.map +1 -0
  106. package/dist/overlay/tethered/hooks/calculate_position.js +43 -0
  107. package/dist/overlay/tethered/hooks/calculate_position.js.map +1 -0
  108. package/dist/overlay/tethered/hooks/useTether.d.ts +19 -0
  109. package/dist/overlay/tethered/hooks/useTether.d.ts.map +1 -0
  110. package/dist/overlay/tethered/hooks/useTether.js +61 -0
  111. package/dist/overlay/tethered/hooks/useTether.js.map +1 -0
  112. package/dist/overlay/tethered/tethered.d.ts +20 -0
  113. package/dist/overlay/tethered/tethered.d.ts.map +1 -0
  114. package/dist/overlay/tethered/tethered.js +59 -0
  115. package/dist/overlay/tethered/tethered.js.map +1 -0
  116. package/dist/overlay/tethered/types.d.ts +3 -0
  117. package/dist/overlay/tethered/types.d.ts.map +1 -0
  118. package/dist/overlay/tethered/types.js +2 -0
  119. package/dist/overlay/tethered/types.js.map +1 -0
  120. package/dist/popper.css +1 -1
  121. package/dist/scaffold.css +1 -0
  122. package/dist/stacks/box/box.d.ts +1 -1
  123. package/dist/stacks/box/box.d.ts.map +1 -1
  124. package/dist/stacks/box/box.js +1 -1
  125. package/dist/stacks/box/box.js.map +1 -1
  126. package/dist/stacks/h_collapsible_box.js +1 -1
  127. package/dist/stacks/v_collapsible_box.js +1 -1
  128. package/dist/surfaces/card/card.d.ts +2 -2
  129. package/dist/surfaces/card/card.d.ts.map +1 -1
  130. package/dist/surfaces/card/card.js +7 -7
  131. package/dist/surfaces/card/card.js.map +1 -1
  132. package/dist/surfaces/index.d.ts +4 -2
  133. package/dist/surfaces/index.d.ts.map +1 -1
  134. package/dist/surfaces/index.js +26 -22
  135. package/dist/surfaces/index.js.map +1 -1
  136. package/dist/surfaces/modal/modal.d.ts +4 -3
  137. package/dist/surfaces/modal/modal.d.ts.map +1 -1
  138. package/dist/surfaces/modal/modal.js +12 -11
  139. package/dist/surfaces/modal/modal.js.map +1 -1
  140. package/dist/surfaces/panel/h_panel.js +23 -24
  141. package/dist/surfaces/panel/h_panel.js.map +1 -1
  142. package/dist/surfaces/panel/v_panel.d.ts +3 -7
  143. package/dist/surfaces/panel/v_panel.d.ts.map +1 -1
  144. package/dist/surfaces/panel/v_panel.js +12 -54
  145. package/dist/surfaces/panel/v_panel.js.map +1 -1
  146. package/dist/surfaces/pop_confirm/pop_confirm.d.ts +5 -0
  147. package/dist/surfaces/pop_confirm/pop_confirm.d.ts.map +1 -0
  148. package/dist/surfaces/pop_confirm/pop_confirm.js +37 -0
  149. package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -0
  150. package/dist/surfaces/popconfirm/pop_confirm.d.ts +5 -0
  151. package/dist/surfaces/popconfirm/pop_confirm.d.ts.map +1 -0
  152. package/dist/surfaces/popconfirm/pop_confirm.js +13 -0
  153. package/dist/surfaces/popconfirm/pop_confirm.js.map +1 -0
  154. package/dist/surfaces/popover/popover.d.ts +1 -1
  155. package/dist/surfaces/popover/popover.d.ts.map +1 -1
  156. package/dist/surfaces/popover/popover.js +1 -1
  157. package/dist/surfaces/popover/popover.js.map +1 -1
  158. package/dist/surfaces/tooltip/tooltip.d.ts +10 -0
  159. package/dist/surfaces/tooltip/tooltip.d.ts.map +1 -0
  160. package/dist/surfaces/tooltip/tooltip.js +38 -0
  161. package/dist/surfaces/tooltip/tooltip.js.map +1 -0
  162. package/dist/surfaces/window/window.d.ts +4 -3
  163. package/dist/surfaces/window/window.d.ts.map +1 -1
  164. package/dist/surfaces/window/window.js +18 -6
  165. package/dist/surfaces/window/window.js.map +1 -1
  166. package/dist/tethered.css +1 -0
  167. package/dist/themes/themes/ergo/ergo_theme.js +166 -158
  168. package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
  169. package/dist/tooltip.css +1 -1
  170. package/dist/typography/title/title.d.ts +2 -1
  171. package/dist/typography/title/title.d.ts.map +1 -1
  172. package/dist/typography/title/title.js +23 -22
  173. package/dist/typography/title/title.js.map +1 -1
  174. package/dist/utility_bar.css +1 -1
  175. package/dist/utils/click_away_listener.d.ts +1 -0
  176. package/dist/utils/click_away_listener.d.ts.map +1 -1
  177. package/dist/utils/click_away_listener.js +2 -1
  178. package/dist/utils/click_away_listener.js.map +1 -1
  179. package/dist/utils/dnd/context.d.ts +4 -0
  180. package/dist/utils/dnd/context.d.ts.map +1 -0
  181. package/dist/utils/dnd/context.js +20 -0
  182. package/dist/utils/dnd/context.js.map +1 -0
  183. package/dist/utils/dnd/draggable/draggable.d.ts +7 -0
  184. package/dist/utils/dnd/draggable/draggable.d.ts.map +1 -0
  185. package/dist/utils/dnd/draggable/draggable.js +27 -0
  186. package/dist/utils/dnd/draggable/draggable.js.map +1 -0
  187. package/dist/utils/dnd/handle.d.ts +6 -0
  188. package/dist/utils/dnd/handle.d.ts.map +1 -0
  189. package/dist/utils/dnd/handle.js +22 -0
  190. package/dist/utils/dnd/handle.js.map +1 -0
  191. package/dist/utils/dnd/hooks/use_drag_container.d.ts +7 -0
  192. package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -0
  193. package/dist/utils/dnd/hooks/use_drag_container.js +30 -0
  194. package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -0
  195. package/dist/utils/{hooks → dnd/hooks}/use_draggable.d.ts +3 -3
  196. package/dist/utils/dnd/hooks/use_draggable.d.ts.map +1 -0
  197. package/dist/utils/dnd/hooks/use_draggable.js +41 -0
  198. package/dist/utils/dnd/hooks/use_draggable.js.map +1 -0
  199. package/dist/utils/dnd/types.d.ts +10 -0
  200. package/dist/utils/dnd/types.d.ts.map +1 -0
  201. package/dist/utils/dnd/types.js +2 -0
  202. package/dist/utils/dnd/types.js.map +1 -0
  203. package/dist/utils/index.d.ts +6 -5
  204. package/dist/utils/index.d.ts.map +1 -1
  205. package/dist/utils/index.js +26 -23
  206. package/dist/utils/index.js.map +1 -1
  207. package/dist/utils/mouse_leave_region.d.ts +8 -0
  208. package/dist/utils/mouse_leave_region.d.ts.map +1 -0
  209. package/dist/utils/mouse_leave_region.js +26 -0
  210. package/dist/utils/mouse_leave_region.js.map +1 -0
  211. package/dist/utils/types/dimensions.d.ts +11 -1
  212. package/dist/utils/types/dimensions.d.ts.map +1 -1
  213. package/package.json +9 -3
  214. package/src/inputs/color_input/color_input.tsx +1 -1
  215. package/src/inputs/date_picker/date_picker_input.tsx +1 -1
  216. package/src/inputs/date_picker/date_picker_year_input.tsx +1 -1
  217. package/src/inputs/phone_number_input/phone_number_input.tsx +8 -0
  218. package/src/inputs/suggestions/suggestion_list.tsx +1 -1
  219. package/src/inputs/textarea/textarea.tsx +2 -2
  220. package/src/layouts/header/header.tsx +0 -1
  221. package/src/layouts/index.ts +7 -5
  222. package/src/layouts/scaffold/scaffold.module.css +5 -0
  223. package/src/layouts/scaffold/scaffold.tsx +60 -0
  224. package/src/layouts/utility_bar/utility_bar.module.css +0 -3
  225. package/src/overlay/frame/frame.module.css +5 -0
  226. package/src/overlay/frame/frame.stories.tsx +40 -0
  227. package/src/overlay/frame/frame.tsx +50 -0
  228. package/src/overlay/frame/frame_stories.module.css +14 -0
  229. package/src/overlay/index.ts +30 -2
  230. package/src/overlay/menu/menu.tsx +1 -1
  231. package/src/overlay/popper/__stories__/base_args.ts +75 -0
  232. package/src/overlay/popper/__stories__/context_popper.stories.tsx +77 -0
  233. package/src/overlay/popper/__stories__/element_popper.stories.tsx +80 -0
  234. package/src/overlay/popper/__stories__/preview_popper.stories.tsx +73 -0
  235. package/src/overlay/popper/base/base_popper.tsx +55 -0
  236. package/src/overlay/popper/base/dismissal_decorator.tsx +80 -0
  237. package/src/overlay/popper/context_popper.tsx +43 -0
  238. package/src/overlay/popper/element_popper.tsx +42 -0
  239. package/src/overlay/popper/hooks/use_context_trigger.ts +50 -0
  240. package/src/overlay/popper/hooks/use_hover_trigger.ts +24 -0
  241. package/src/overlay/popper/hooks/use_restore_focus.ts +16 -0
  242. package/src/overlay/popper/{popper.stories.tsx → legacy/popper.stories.tsx} +11 -5
  243. package/src/overlay/popper/{popper.tsx → legacy/popper.tsx} +3 -2
  244. package/src/overlay/popper/preview_popper.tsx +54 -0
  245. package/src/overlay/tethered/__stories__/element/element_tethered.stories.tsx +57 -0
  246. package/src/overlay/tethered/__stories__/element/element_tethered_stories.module.css +14 -0
  247. package/src/overlay/tethered/__stories__/shared/base_story_config.ts +52 -0
  248. package/src/overlay/tethered/__stories__/shared/components/sb_point.module.css +20 -0
  249. package/src/overlay/tethered/__stories__/shared/components/sb_point.tsx +34 -0
  250. package/src/overlay/tethered/__stories__/shared/components/sb_reference_points.tsx +54 -0
  251. package/src/overlay/tethered/__stories__/tethered/tethered.stories.tsx +90 -0
  252. package/src/overlay/tethered/__stories__/tethered/tethered_stories.module.css +25 -0
  253. package/src/overlay/tethered/element_tethered.tsx +62 -0
  254. package/src/overlay/tethered/hooks/calculate_position.ts +110 -0
  255. package/src/overlay/tethered/hooks/useTether.ts +85 -0
  256. package/src/overlay/tethered/tethered.module.css +8 -0
  257. package/src/overlay/tethered/tethered.tsx +72 -0
  258. package/src/overlay/tethered/types.ts +2 -0
  259. package/src/stacks/box/box.tsx +8 -2
  260. package/src/stacks/h_stack.stories.tsx +2 -2
  261. package/src/stacks/v_stack.stories.tsx +2 -2
  262. package/src/surfaces/card/card.stories.tsx +64 -0
  263. package/src/surfaces/card/card.tsx +4 -4
  264. package/src/surfaces/card/card_stories.module.css +13 -0
  265. package/src/surfaces/index.ts +4 -2
  266. package/src/surfaces/modal/__stories__/modal.stories.tsx +31 -28
  267. package/src/surfaces/modal/modal.module.css +2 -2
  268. package/src/surfaces/modal/modal.tsx +16 -11
  269. package/src/surfaces/panel/__stories__/panel.stories.tsx +1 -1
  270. package/src/surfaces/panel/v_panel.tsx +8 -53
  271. package/src/surfaces/pop_confirm/pop_confirm.stories.tsx +70 -0
  272. package/src/surfaces/pop_confirm/pop_confirm.tsx +30 -0
  273. package/src/surfaces/popconfirm/pop_confirm.tsx +18 -0
  274. package/src/surfaces/popover/popover.tsx +1 -1
  275. package/src/surfaces/tooltip/tooltip.stories.tsx +54 -0
  276. package/src/surfaces/tooltip/tooltip.tsx +59 -0
  277. package/src/surfaces/window/window.stories.tsx +51 -4
  278. package/src/surfaces/window/window.tsx +19 -7
  279. package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_picker.tsx +7 -9
  280. package/src/themes/themes/ergo/__stories__/material.stories.tsx +2 -6
  281. package/src/themes/themes/ergo/__stories__/sb_materials.module.css +29 -21
  282. package/src/themes/themes/ergo/ergo_theme.css +166 -158
  283. package/src/typography/title/title.tsx +22 -18
  284. package/src/utils/click_away_listener.tsx +1 -1
  285. package/src/utils/dnd/__stories__/draggable.stories.tsx +48 -0
  286. package/src/utils/dnd/__stories__/draggable_stories.module.css +21 -0
  287. package/src/utils/{__stories__ → dnd/__stories__}/use_draggable.stories.tsx +15 -10
  288. package/src/utils/dnd/context.ts +24 -0
  289. package/src/utils/dnd/draggable/draggable.module.css +8 -0
  290. package/src/utils/dnd/draggable/draggable.tsx +42 -0
  291. package/src/utils/dnd/handle.tsx +32 -0
  292. package/src/utils/dnd/hooks/use_drag_container.ts +42 -0
  293. package/src/utils/{hooks → dnd/hooks}/use_draggable.ts +23 -17
  294. package/src/utils/dnd/types.ts +6 -0
  295. package/src/utils/index.ts +7 -5
  296. package/src/utils/mouse_leave_region.tsx +38 -0
  297. package/src/utils/types/dimensions.ts +13 -1
  298. package/tsconfig.json +3 -0
  299. package/dist/overlay/popper/popper.d.ts.map +0 -1
  300. package/dist/overlay/popper/popper.js.map +0 -1
  301. package/dist/overlay/tooltip/tooltip.d.ts +0 -7
  302. package/dist/overlay/tooltip/tooltip.d.ts.map +0 -1
  303. package/dist/overlay/tooltip/tooltip.js +0 -20
  304. package/dist/overlay/tooltip/tooltip.js.map +0 -1
  305. package/dist/panel.module-DwGKncon.js +0 -5
  306. package/dist/panel.module-DwGKncon.js.map +0 -1
  307. package/dist/title.module-B16de2jd.js +0 -5
  308. package/dist/title.module-B16de2jd.js.map +0 -1
  309. package/dist/utils/hooks/use_draggable.d.ts.map +0 -1
  310. package/dist/utils/hooks/use_draggable.js +0 -30
  311. package/dist/utils/hooks/use_draggable.js.map +0 -1
  312. package/src/overlay/tooltip/tooltip.stories.tsx +0 -22
  313. package/src/overlay/tooltip/tooltip.tsx +0 -24
  314. /package/dist/{panel.css → h_panel.css} +0 -0
  315. /package/dist/overlay/popper/{popper.d.ts → legacy/popper.d.ts} +0 -0
  316. /package/src/overlay/popper/{popper.module.css → legacy/popper.module.css} +0 -0
  317. /package/src/{overlay → surfaces}/tooltip/tooltip.module.css +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"click_away_listener.js","sources":["../../src/utils/click_away_listener.tsx"],"sourcesContent":["import React, { useEffect, useCallback, useRef } from 'react';\nimport { useForkRef } from './hooks/use_fork_ref.js';\nexport interface ClickAwayListenerProps {\n children: React.ReactElement;\n onClickAway: (event: React.MouseEvent | React.TouchEvent) => void;\n mouseEvent?: 'onMouseUp' | 'onMouseDown' | 'onClick';\n touchEvent?: 'onTouchStart' | 'onTouchEnd';\n isException?: (target: HTMLElement) => boolean;\n // An array of refs that wont trigger the click away listener\n refs?: React.RefObject<Element>[];\n}\nconst eventMap = {\n onClick: 'click',\n onMouseDown: 'mousedown',\n onMouseUp: 'mouseup',\n};\nconst touchMap = {\n onTouchStart: 'touchstart',\n onTouchEnd: 'touchend',\n};\n\nfunction isEventWithinElement(\n event: MouseEvent | TouchEvent,\n node: HTMLElement | null,\n activated: boolean,\n refs: (Element | null)[]\n) {\n if (!activated) {\n return true;\n }\n\n let isWithinElement: boolean;\n\n if (event.composedPath) {\n isWithinElement =\n [node, ...refs].find((ref: any) => {\n return event.composedPath().indexOf(ref) > -1;\n }) !== undefined;\n } else {\n isWithinElement =\n !document.documentElement.contains(event.target as any) ||\n [node, ...refs].find((ref: any) => {\n return ref?.contains(event.target);\n }) !== undefined;\n }\n\n return isWithinElement;\n}\n\nexport const ClickAwayListener = React.forwardRef<HTMLElement, ClickAwayListenerProps>(\n function ClickAwayListener(\n { children, mouseEvent, touchEvent, onClickAway, refs = [], isException },\n ref\n ) {\n const nodeRef = useRef<HTMLElement | null>(null);\n const startedActionWithinElementRef = useRef<boolean>(true);\n const DOMMouseEvent = eventMap[mouseEvent || 'onClick'];\n const DOMTouchEvent = touchMap[touchEvent || 'onTouchEnd'];\n const newRef = useForkRef(ref, nodeRef, (children as any).ref);\n const activatedRef = React.useRef(false);\n\n React.useEffect(() => {\n // Ensure that this component is not \"activated\" synchronously.\n // https://github.com/facebook/react/issues/20074\n window.setTimeout(() => {\n activatedRef.current = true;\n }, 0);\n return () => {\n activatedRef.current = false;\n };\n }, []);\n\n const trackAction = useCallback(\n (event: any) => {\n startedActionWithinElementRef.current = isEventWithinElement(\n event,\n nodeRef.current,\n activatedRef.current,\n refs.map(r => r.current)\n );\n },\n [refs]\n );\n\n const eventHandler = useCallback(\n (event: any) => {\n const startedFromWithinElement = startedActionWithinElementRef.current;\n const isWithinElement = isEventWithinElement(\n event,\n nodeRef.current,\n activatedRef.current,\n refs.map(r => r.current)\n );\n\n if (\n !isWithinElement &&\n !startedFromWithinElement &&\n (!isException || !isException(event.target))\n ) {\n onClickAway(event);\n }\n },\n [onClickAway, refs, isException]\n );\n\n useEffect(() => {\n document.addEventListener('mousedown', trackAction);\n document.addEventListener('touchstart', trackAction);\n document.addEventListener(DOMMouseEvent, eventHandler);\n document.addEventListener(DOMTouchEvent, eventHandler);\n return () => {\n document.removeEventListener('mousedown', trackAction);\n document.removeEventListener('touchstart', trackAction);\n document.removeEventListener(DOMMouseEvent, eventHandler);\n document.removeEventListener(DOMTouchEvent, eventHandler);\n };\n }, [DOMTouchEvent, DOMMouseEvent, eventHandler, trackAction]);\n\n return React.cloneElement(children, {\n ...children.props,\n ref: newRef,\n });\n }\n);\n"],"names":["eventMap","touchMap","isEventWithinElement","event","node","activated","refs","isWithinElement","ref","ClickAwayListener","React","children","mouseEvent","touchEvent","onClickAway","isException","nodeRef","useRef","startedActionWithinElementRef","DOMMouseEvent","DOMTouchEvent","newRef","useForkRef","activatedRef","trackAction","useCallback","r","eventHandler","startedFromWithinElement","useEffect"],"mappings":";;AAWA,MAAMA,IAAW;AAAA,EACf,SAAS;AAAA,EACT,aAAa;AAAA,EACb,WAAW;AACb,GACMC,IAAW;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AACd;AAEA,SAASC,EACPC,GACAC,GACAC,GACAC,GACA;AACA,MAAI,CAACD;AACH,WAAO;AAGT,MAAIE;AAEJ,SAAIJ,EAAM,eACRI,IACE,CAACH,GAAM,GAAGE,CAAI,EAAE,KAAK,CAACE,MACbL,EAAM,aAAA,EAAe,QAAQK,CAAG,IAAI,EAC5C,MAAM,SAETD,IACE,CAAC,SAAS,gBAAgB,SAASJ,EAAM,MAAa,KACtD,CAACC,GAAM,GAAGE,CAAI,EAAE,KAAK,CAACE,MACbA,GAAK,SAASL,EAAM,MAAM,CAClC,MAAM,QAGJI;AACT;AAEO,MAAME,IAAoBC,EAAM;AAAA,EACrC,SACE,EAAE,UAAAC,GAAU,YAAAC,GAAY,YAAAC,GAAY,aAAAC,GAAa,MAAAR,IAAO,CAAA,GAAI,aAAAS,EAAA,GAC5DP,GACA;AACA,UAAMQ,IAAUC,EAA2B,IAAI,GACzCC,IAAgCD,EAAgB,EAAI,GACpDE,IAAgBnB,EAASY,KAAc,SAAS,GAChDQ,IAAgBnB,EAASY,KAAc,YAAY,GACnDQ,IAASC,EAAWd,GAAKQ,GAAUL,EAAiB,GAAG,GACvDY,IAAeb,EAAM,OAAO,EAAK;AAEvC,IAAAA,EAAM,UAAU,OAGd,OAAO,WAAW,MAAM;AACtB,MAAAa,EAAa,UAAU;AAAA,IACzB,GAAG,CAAC,GACG,MAAM;AACX,MAAAA,EAAa,UAAU;AAAA,IACzB,IACC,CAAA,CAAE;AAEL,UAAMC,IAAcC;AAAA,MAClB,CAACtB,MAAe;AACd,QAAAe,EAA8B,UAAUhB;AAAA,UACtCC;AAAA,UACAa,EAAQ;AAAA,UACRO,EAAa;AAAA,UACbjB,EAAK,IAAI,CAAAoB,MAAKA,EAAE,OAAO;AAAA,QAAA;AAAA,MAE3B;AAAA,MACA,CAACpB,CAAI;AAAA,IAAA,GAGDqB,IAAeF;AAAA,MACnB,CAACtB,MAAe;AACd,cAAMyB,IAA2BV,EAA8B;AAQ/D,QACE,CARsBhB;AAAA,UACtBC;AAAA,UACAa,EAAQ;AAAA,UACRO,EAAa;AAAA,UACbjB,EAAK,IAAI,CAAAoB,MAAKA,EAAE,OAAO;AAAA,QAAA,KAKvB,CAACE,MACA,CAACb,KAAe,CAACA,EAAYZ,EAAM,MAAM,MAE1CW,EAAYX,CAAK;AAAA,MAErB;AAAA,MACA,CAACW,GAAaR,GAAMS,CAAW;AAAA,IAAA;AAGjC,WAAAc,EAAU,OACR,SAAS,iBAAiB,aAAaL,CAAW,GAClD,SAAS,iBAAiB,cAAcA,CAAW,GACnD,SAAS,iBAAiBL,GAAeQ,CAAY,GACrD,SAAS,iBAAiBP,GAAeO,CAAY,GAC9C,MAAM;AACX,eAAS,oBAAoB,aAAaH,CAAW,GACrD,SAAS,oBAAoB,cAAcA,CAAW,GACtD,SAAS,oBAAoBL,GAAeQ,CAAY,GACxD,SAAS,oBAAoBP,GAAeO,CAAY;AAAA,IAC1D,IACC,CAACP,GAAeD,GAAeQ,GAAcH,CAAW,CAAC,GAErDd,EAAM,aAAaC,GAAU;AAAA,MAClC,GAAGA,EAAS;AAAA,MACZ,KAAKU;AAAA,IAAA,CACN;AAAA,EACH;AACF;"}
1
+ {"version":3,"file":"click_away_listener.js","sources":["../../src/utils/click_away_listener.tsx"],"sourcesContent":["import React, { useEffect, useCallback, useRef } from 'react';\nimport { useForkRef } from './hooks/use_fork_ref.js';\nexport interface ClickAwayListenerProps {\n children: React.ReactElement;\n onClickAway: (event: React.MouseEvent | React.TouchEvent) => void;\n mouseEvent?: 'onMouseUp' | 'onMouseDown' | 'onClick';\n touchEvent?: 'onTouchStart' | 'onTouchEnd';\n isException?: (target: HTMLElement) => boolean;\n // An array of refs that wont trigger the click away listener\n refs?: React.RefObject<Element>[];\n}\nconst eventMap = {\n onClick: 'click',\n onMouseDown: 'mousedown',\n onMouseUp: 'mouseup',\n};\nconst touchMap = {\n onTouchStart: 'touchstart',\n onTouchEnd: 'touchend',\n};\n\nexport function isEventWithinElement(\n event: MouseEvent | TouchEvent,\n node: HTMLElement | null,\n activated: boolean,\n refs: (Element | null)[]\n) {\n if (!activated) {\n return true;\n }\n\n let isWithinElement: boolean;\n\n if (event.composedPath) {\n isWithinElement =\n [node, ...refs].find((ref: any) => {\n return event.composedPath().indexOf(ref) > -1;\n }) !== undefined;\n } else {\n isWithinElement =\n !document.documentElement.contains(event.target as any) ||\n [node, ...refs].find((ref: any) => {\n return ref?.contains(event.target);\n }) !== undefined;\n }\n\n return isWithinElement;\n}\n\nexport const ClickAwayListener = React.forwardRef<HTMLElement, ClickAwayListenerProps>(\n function ClickAwayListener(\n { children, mouseEvent, touchEvent, onClickAway, refs = [], isException },\n ref\n ) {\n const nodeRef = useRef<HTMLElement | null>(null);\n const startedActionWithinElementRef = useRef<boolean>(true);\n const DOMMouseEvent = eventMap[mouseEvent || 'onClick'];\n const DOMTouchEvent = touchMap[touchEvent || 'onTouchEnd'];\n const newRef = useForkRef(ref, nodeRef, (children as any).ref);\n const activatedRef = React.useRef(false);\n\n React.useEffect(() => {\n // Ensure that this component is not \"activated\" synchronously.\n // https://github.com/facebook/react/issues/20074\n window.setTimeout(() => {\n activatedRef.current = true;\n }, 0);\n return () => {\n activatedRef.current = false;\n };\n }, []);\n\n const trackAction = useCallback(\n (event: any) => {\n startedActionWithinElementRef.current = isEventWithinElement(\n event,\n nodeRef.current,\n activatedRef.current,\n refs.map(r => r.current)\n );\n },\n [refs]\n );\n\n const eventHandler = useCallback(\n (event: any) => {\n const startedFromWithinElement = startedActionWithinElementRef.current;\n const isWithinElement = isEventWithinElement(\n event,\n nodeRef.current,\n activatedRef.current,\n refs.map(r => r.current)\n );\n\n if (\n !isWithinElement &&\n !startedFromWithinElement &&\n (!isException || !isException(event.target))\n ) {\n onClickAway(event);\n }\n },\n [onClickAway, refs, isException]\n );\n\n useEffect(() => {\n document.addEventListener('mousedown', trackAction);\n document.addEventListener('touchstart', trackAction);\n document.addEventListener(DOMMouseEvent, eventHandler);\n document.addEventListener(DOMTouchEvent, eventHandler);\n return () => {\n document.removeEventListener('mousedown', trackAction);\n document.removeEventListener('touchstart', trackAction);\n document.removeEventListener(DOMMouseEvent, eventHandler);\n document.removeEventListener(DOMTouchEvent, eventHandler);\n };\n }, [DOMTouchEvent, DOMMouseEvent, eventHandler, trackAction]);\n\n return React.cloneElement(children, {\n ...children.props,\n ref: newRef,\n });\n }\n);\n"],"names":["eventMap","touchMap","isEventWithinElement","event","node","activated","refs","isWithinElement","ref","ClickAwayListener","React","children","mouseEvent","touchEvent","onClickAway","isException","nodeRef","useRef","startedActionWithinElementRef","DOMMouseEvent","DOMTouchEvent","newRef","useForkRef","activatedRef","trackAction","useCallback","r","eventHandler","startedFromWithinElement","useEffect"],"mappings":";;AAWA,MAAMA,IAAW;AAAA,EACf,SAAS;AAAA,EACT,aAAa;AAAA,EACb,WAAW;AACb,GACMC,IAAW;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AACd;AAEO,SAASC,EACdC,GACAC,GACAC,GACAC,GACA;AACA,MAAI,CAACD;AACH,WAAO;AAGT,MAAIE;AAEJ,SAAIJ,EAAM,eACRI,IACE,CAACH,GAAM,GAAGE,CAAI,EAAE,KAAK,CAACE,MACbL,EAAM,aAAA,EAAe,QAAQK,CAAG,IAAI,EAC5C,MAAM,SAETD,IACE,CAAC,SAAS,gBAAgB,SAASJ,EAAM,MAAa,KACtD,CAACC,GAAM,GAAGE,CAAI,EAAE,KAAK,CAACE,MACbA,GAAK,SAASL,EAAM,MAAM,CAClC,MAAM,QAGJI;AACT;AAEO,MAAME,IAAoBC,EAAM;AAAA,EACrC,SACE,EAAE,UAAAC,GAAU,YAAAC,GAAY,YAAAC,GAAY,aAAAC,GAAa,MAAAR,IAAO,CAAA,GAAI,aAAAS,EAAA,GAC5DP,GACA;AACA,UAAMQ,IAAUC,EAA2B,IAAI,GACzCC,IAAgCD,EAAgB,EAAI,GACpDE,IAAgBnB,EAASY,KAAc,SAAS,GAChDQ,IAAgBnB,EAASY,KAAc,YAAY,GACnDQ,IAASC,EAAWd,GAAKQ,GAAUL,EAAiB,GAAG,GACvDY,IAAeb,EAAM,OAAO,EAAK;AAEvC,IAAAA,EAAM,UAAU,OAGd,OAAO,WAAW,MAAM;AACtB,MAAAa,EAAa,UAAU;AAAA,IACzB,GAAG,CAAC,GACG,MAAM;AACX,MAAAA,EAAa,UAAU;AAAA,IACzB,IACC,CAAA,CAAE;AAEL,UAAMC,IAAcC;AAAA,MAClB,CAACtB,MAAe;AACd,QAAAe,EAA8B,UAAUhB;AAAA,UACtCC;AAAA,UACAa,EAAQ;AAAA,UACRO,EAAa;AAAA,UACbjB,EAAK,IAAI,CAAAoB,MAAKA,EAAE,OAAO;AAAA,QAAA;AAAA,MAE3B;AAAA,MACA,CAACpB,CAAI;AAAA,IAAA,GAGDqB,IAAeF;AAAA,MACnB,CAACtB,MAAe;AACd,cAAMyB,IAA2BV,EAA8B;AAQ/D,QACE,CARsBhB;AAAA,UACtBC;AAAA,UACAa,EAAQ;AAAA,UACRO,EAAa;AAAA,UACbjB,EAAK,IAAI,CAAAoB,MAAKA,EAAE,OAAO;AAAA,QAAA,KAKvB,CAACE,MACA,CAACb,KAAe,CAACA,EAAYZ,EAAM,MAAM,MAE1CW,EAAYX,CAAK;AAAA,MAErB;AAAA,MACA,CAACW,GAAaR,GAAMS,CAAW;AAAA,IAAA;AAGjC,WAAAc,EAAU,OACR,SAAS,iBAAiB,aAAaL,CAAW,GAClD,SAAS,iBAAiB,cAAcA,CAAW,GACnD,SAAS,iBAAiBL,GAAeQ,CAAY,GACrD,SAAS,iBAAiBP,GAAeO,CAAY,GAC9C,MAAM;AACX,eAAS,oBAAoB,aAAaH,CAAW,GACrD,SAAS,oBAAoB,cAAcA,CAAW,GACtD,SAAS,oBAAoBL,GAAeQ,CAAY,GACxD,SAAS,oBAAoBP,GAAeO,CAAY;AAAA,IAC1D,IACC,CAACP,GAAeD,GAAeQ,GAAcH,CAAW,CAAC,GAErDd,EAAM,aAAaC,GAAU;AAAA,MAClC,GAAGA,EAAS;AAAA,MACZ,KAAKU;AAAA,IAAA,CACN;AAAA,EACH;AACF;"}
@@ -0,0 +1,4 @@
1
+ import { DragContainer } from './types.js';
2
+ export declare const DragContainerContext: import('react').Context<DragContainer>;
3
+ export declare function useDragContainer(): DragContainer;
4
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/utils/dnd/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAShD,eAAO,MAAM,oBAAoB,wCAA6C,CAAC;AAE/E,wBAAgB,gBAAgB,IAAI,aAAa,CAWhD"}
@@ -0,0 +1,20 @@
1
+ import { createContext as t, useContext as r } from "react";
2
+ const n = {
3
+ registerHandle: () => {
4
+ },
5
+ unregisterHandle: () => {
6
+ },
7
+ isDragging: !1,
8
+ position: { x: 0, y: 0 }
9
+ }, o = t(n);
10
+ function i() {
11
+ const e = r(o);
12
+ return e === n && console.warn(
13
+ "useDragContainer: No DragContainerContext found. Handles may will not register or trigger drag events."
14
+ ), e;
15
+ }
16
+ export {
17
+ o as DragContainerContext,
18
+ i as useDragContainer
19
+ };
20
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../../src/utils/dnd/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { DragContainer } from './types.js';\n\nconst defaultValue: DragContainer = {\n registerHandle: () => {},\n unregisterHandle: () => {},\n isDragging: false,\n position: { x: 0, y: 0 },\n};\n\nexport const DragContainerContext = createContext<DragContainer>(defaultValue);\n\nexport function useDragContainer(): DragContainer {\n const context = useContext(DragContainerContext);\n\n if (context === defaultValue) {\n // biome-ignore lint/suspicious/noConsole: Let devs know if they're not using the context correctly\n console.warn(\n 'useDragContainer: No DragContainerContext found. Handles may will not register or trigger drag events.'\n );\n }\n\n return context;\n}\n"],"names":["defaultValue","DragContainerContext","createContext","useDragContainer","context","useContext"],"mappings":";AAGA,MAAMA,IAA8B;AAAA,EAClC,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,YAAY;AAAA,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,EAAA;AACvB,GAEaC,IAAuBC,EAA6BF,CAAY;AAEtE,SAASG,IAAkC;AAChD,QAAMC,IAAUC,EAAWJ,CAAoB;AAE/C,SAAIG,MAAYJ,KAEd,QAAQ;AAAA,IACN;AAAA,EAAA,GAIGI;AACT;"}
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export interface DraggableProps {
3
+ children: React.ReactElement;
4
+ draggable?: boolean;
5
+ }
6
+ export declare const Draggable: React.FC<DraggableProps>;
7
+ //# sourceMappingURL=draggable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable.d.ts","sourceRoot":"","sources":["../../../../src/utils/dnd/draggable/draggable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAQ3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA4B9C,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import i, { useMemo as n } from "react";
3
+ import { DragContainerContext as g } from "../context.js";
4
+ import l from "clsx";
5
+ import { useMakeDragContainer as p } from "../hooks/use_drag_container.js";
6
+ import '../../../draggable.css';const c = "_draggable_db40376", m = { draggable: c }, y = ({
7
+ children: a,
8
+ draggable: t = !0
9
+ }) => {
10
+ const o = p({}), r = n(
11
+ () => ({
12
+ "--position-x": `${o.position.x}px`,
13
+ "--position-y": `${o.position.y}px`
14
+ }),
15
+ [o.position]
16
+ ), e = i.cloneElement(a, {
17
+ className: l("tcn-draggable", m.draggable, a.props.className),
18
+ style: { ...r, ...a.props.style },
19
+ "data-is-dragging": o.isDragging,
20
+ "data-is-draggable": t
21
+ });
22
+ return /* @__PURE__ */ s(g.Provider, { value: o, children: e });
23
+ };
24
+ export {
25
+ y as Draggable
26
+ };
27
+ //# sourceMappingURL=draggable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable.js","sources":["../../../../src/utils/dnd/draggable/draggable.tsx"],"sourcesContent":["import React, { useMemo, type CSSProperties } from 'react';\n\nimport { DragContainerContext } from '../context.js';\nimport clsx from 'clsx';\nimport { useMakeDragContainer } from '../hooks/use_drag_container.js';\n\nimport styles from './draggable.module.css';\n\nexport interface DraggableProps {\n children: React.ReactElement;\n draggable?: boolean;\n}\n\nexport const Draggable: React.FC<DraggableProps> = ({\n children,\n draggable: isDraggable = true,\n}) => {\n const context = useMakeDragContainer({});\n\n const cssVariables = useMemo(\n () =>\n ({\n '--position-x': `${context.position.x}px`,\n '--position-y': `${context.position.y}px`,\n }) as CSSProperties,\n\n [context.position]\n );\n\n const clonedChildren = React.cloneElement(children, {\n className: clsx('tcn-draggable', styles.draggable, children.props.className),\n style: { ...cssVariables, ...children.props.style },\n 'data-is-dragging': context.isDragging,\n 'data-is-draggable': isDraggable,\n });\n\n return (\n <DragContainerContext.Provider value={context}>\n {clonedChildren}\n </DragContainerContext.Provider>\n );\n};\n"],"names":["Draggable","children","isDraggable","context","useMakeDragContainer","cssVariables","useMemo","clonedChildren","React","clsx","styles","DragContainerContext"],"mappings":";;;;;sDAaaA,IAAsC,CAAC;AAAA,EAClD,UAAAC;AAAA,EACA,WAAWC,IAAc;AAC3B,MAAM;AACJ,QAAMC,IAAUC,EAAqB,EAAE,GAEjCC,IAAeC;AAAA,IACnB,OACG;AAAA,MACC,gBAAgB,GAAGH,EAAQ,SAAS,CAAC;AAAA,MACrC,gBAAgB,GAAGA,EAAQ,SAAS,CAAC;AAAA,IAAA;AAAA,IAGzC,CAACA,EAAQ,QAAQ;AAAA,EAAA,GAGbI,IAAiBC,EAAM,aAAaP,GAAU;AAAA,IAClD,WAAWQ,EAAK,iBAAiBC,EAAO,WAAWT,EAAS,MAAM,SAAS;AAAA,IAC3E,OAAO,EAAE,GAAGI,GAAc,GAAGJ,EAAS,MAAM,MAAA;AAAA,IAC5C,oBAAoBE,EAAQ;AAAA,IAC5B,qBAAqBD;AAAA,EAAA,CACtB;AAED,2BACGS,EAAqB,UAArB,EAA8B,OAAOR,GACnC,UAAAI,GACH;AAEJ;"}
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ export interface DragHandleProps {
3
+ children: React.ReactElement;
4
+ }
5
+ export declare const DragHandle: React.FC<DragHandleProps>;
6
+ //# sourceMappingURL=handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../../src/utils/dnd/handle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAKjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;CAC9B;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAsBhD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import s, { useRef as f, useEffect as u } from "react";
2
+ import a from "clsx";
3
+ import { useDragContainer as l } from "./context.js";
4
+ import { useForkRef as m } from "../hooks/use_fork_ref.js";
5
+ const d = ({ children: e }) => {
6
+ const { registerHandle: t, unregisterHandle: n } = l(), r = f(null);
7
+ u(() => {
8
+ if (r.current != null)
9
+ return t(r), () => {
10
+ r.current != null && n(r);
11
+ };
12
+ }, [t, n]);
13
+ const o = m(r, e.props.ref);
14
+ return s.cloneElement(e, {
15
+ className: a("tcn-drag-handle", e.props.className),
16
+ ref: o
17
+ });
18
+ };
19
+ export {
20
+ d as DragHandle
21
+ };
22
+ //# sourceMappingURL=handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle.js","sources":["../../../src/utils/dnd/handle.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport { useDragContainer } from './context.js';\nimport { useForkRef } from '../hooks/use_fork_ref.js';\n\nexport interface DragHandleProps {\n children: React.ReactElement;\n}\n\nexport const DragHandle: React.FC<DragHandleProps> = ({ children }) => {\n const { registerHandle, unregisterHandle } = useDragContainer();\n const ref = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (ref.current == null) {\n return;\n }\n registerHandle(ref);\n return () => {\n if (ref.current == null) {\n return;\n }\n unregisterHandle(ref);\n };\n }, [registerHandle, unregisterHandle]);\n\n const mergedRef = useForkRef(ref, children.props.ref);\n return React.cloneElement(children, {\n className: clsx('tcn-drag-handle', children.props.className),\n ref: mergedRef,\n });\n};\n"],"names":["DragHandle","children","registerHandle","unregisterHandle","useDragContainer","ref","useRef","useEffect","mergedRef","useForkRef","React","clsx"],"mappings":";;;;AASO,MAAMA,IAAwC,CAAC,EAAE,UAAAC,QAAe;AACrE,QAAM,EAAE,gBAAAC,GAAgB,kBAAAC,EAAA,IAAqBC,EAAA,GACvCC,IAAMC,EAA2B,IAAI;AAE3C,EAAAC,EAAU,MAAM;AACd,QAAIF,EAAI,WAAW;AAGnB,aAAAH,EAAeG,CAAG,GACX,MAAM;AACX,QAAIA,EAAI,WAAW,QAGnBF,EAAiBE,CAAG;AAAA,MACtB;AAAA,EACF,GAAG,CAACH,GAAgBC,CAAgB,CAAC;AAErC,QAAMK,IAAYC,EAAWJ,GAAKJ,EAAS,MAAM,GAAG;AACpD,SAAOS,EAAM,aAAaT,GAAU;AAAA,IAClC,WAAWU,EAAK,mBAAmBV,EAAS,MAAM,SAAS;AAAA,IAC3D,KAAKO;AAAA,EAAA,CACN;AACH;"}
@@ -0,0 +1,7 @@
1
+ import { Position } from '../../index.js';
2
+ import { DragContainer } from '../types.js';
3
+ export interface UseDragContainerOptions {
4
+ initialPosition?: Position;
5
+ }
6
+ export declare function useMakeDragContainer(options: UseDragContainerOptions): DragContainer;
7
+ //# sourceMappingURL=use_drag_container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_drag_container.d.ts","sourceRoot":"","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa,CAgCpF"}
@@ -0,0 +1,30 @@
1
+ import { useState as n, useRef as b, useCallback as o } from "react";
2
+ import { useDraggable as k } from "./use_draggable.js";
3
+ function m(l) {
4
+ const [c, a] = n([]), r = b(l.initialPosition ?? { x: 0, y: 0 }), [s, g] = n(r.current), [u, i] = n(!1);
5
+ k({
6
+ handles: c,
7
+ startDragCallback: () => {
8
+ i(!0);
9
+ },
10
+ dragCallback: (e, t) => {
11
+ g({
12
+ x: r.current.x + e,
13
+ y: r.current.y + t
14
+ });
15
+ },
16
+ endDragCallback: () => {
17
+ i(!1), r.current = s;
18
+ }
19
+ });
20
+ const f = o((e) => {
21
+ a((t) => [...t, e]);
22
+ }, []), d = o((e) => {
23
+ a((t) => t.filter((D) => D !== e));
24
+ }, []);
25
+ return { registerHandle: f, unregisterHandle: d, position: s, isDragging: u };
26
+ }
27
+ export {
28
+ m as useMakeDragContainer
29
+ };
30
+ //# sourceMappingURL=use_drag_container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_drag_container.js","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { useDraggable } from './use_draggable.js';\nimport type { Position } from '../../index.js';\nimport type { DragContainer } from '../types.js';\n\nexport interface UseDragContainerOptions {\n initialPosition?: Position;\n}\n\nexport function useMakeDragContainer(options: UseDragContainerOptions): DragContainer {\n const [handles, setHandles] = useState<React.RefObject<HTMLElement>[]>([]);\n const positionRef = useRef<Position>(options.initialPosition ?? { x: 0, y: 0 });\n const [position, setPosition] = useState(positionRef.current);\n const [isDragging, setIsDragging] = useState(false);\n\n useDraggable({\n handles: handles,\n startDragCallback: () => {\n setIsDragging(true);\n },\n dragCallback: (deltaX, deltaY) => {\n setPosition({\n x: positionRef.current.x + deltaX,\n y: positionRef.current.y + deltaY,\n });\n },\n endDragCallback: () => {\n setIsDragging(false);\n positionRef.current = position;\n },\n });\n\n const registerHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => [...prev, handle]);\n }, []);\n\n const unregisterHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => prev.filter(h => h !== handle));\n }, []);\n\n return { registerHandle, unregisterHandle, position, isDragging };\n}\n"],"names":["useMakeDragContainer","options","handles","setHandles","useState","positionRef","useRef","position","setPosition","isDragging","setIsDragging","useDraggable","deltaX","deltaY","registerHandle","useCallback","handle","prev","unregisterHandle","h"],"mappings":";;AASO,SAASA,EAAqBC,GAAiD;AACpF,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAyC,CAAA,CAAE,GACnEC,IAAcC,EAAiBL,EAAQ,mBAAmB,EAAE,GAAG,GAAG,GAAG,GAAG,GACxE,CAACM,GAAUC,CAAW,IAAIJ,EAASC,EAAY,OAAO,GACtD,CAACI,GAAYC,CAAa,IAAIN,EAAS,EAAK;AAElD,EAAAO,EAAa;AAAA,IACX,SAAAT;AAAA,IACA,mBAAmB,MAAM;AACvB,MAAAQ,EAAc,EAAI;AAAA,IACpB;AAAA,IACA,cAAc,CAACE,GAAQC,MAAW;AAChC,MAAAL,EAAY;AAAA,QACV,GAAGH,EAAY,QAAQ,IAAIO;AAAA,QAC3B,GAAGP,EAAY,QAAQ,IAAIQ;AAAA,MAAA,CAC5B;AAAA,IACH;AAAA,IACA,iBAAiB,MAAM;AACrB,MAAAH,EAAc,EAAK,GACnBL,EAAY,UAAUE;AAAA,IACxB;AAAA,EAAA,CACD;AAED,QAAMO,IAAiBC,EAAY,CAACC,MAAyC;AAC3E,IAAAb,EAAW,CAAAc,MAAQ,CAAC,GAAGA,GAAMD,CAAM,CAAC;AAAA,EACtC,GAAG,CAAA,CAAE,GAECE,IAAmBH,EAAY,CAACC,MAAyC;AAC7E,IAAAb,EAAW,OAAQc,EAAK,OAAO,CAAAE,MAAKA,MAAMH,CAAM,CAAC;AAAA,EACnD,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,gBAAAF,GAAgB,kBAAAI,GAAkB,UAAAX,GAAU,YAAAE,EAAA;AACvD;"}
@@ -1,8 +1,8 @@
1
- interface DraggableOptions {
1
+ export interface UseDraggableOptions {
2
2
  startDragCallback: (startX: number, startY: number) => void;
3
3
  dragCallback: (deltaX: number, deltaY: number, startX: number, startY: number) => void;
4
4
  endDragCallback: (deltaX: number, deltaY: number, startX: number, startY: number) => void;
5
+ handles?: React.RefObject<HTMLElement>[] | React.RefObject<HTMLElement>;
5
6
  }
6
- export declare function useDraggable(options: DraggableOptions): import('react').MutableRefObject<HTMLElement | null>;
7
- export {};
7
+ export declare function useDraggable(options: UseDraggableOptions): void;
8
8
  //# sourceMappingURL=use_draggable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_draggable.d.ts","sourceRoot":"","sources":["../../../../src/utils/dnd/hooks/use_draggable.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvF,eAAe,EAAE,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,KACX,IAAI,CAAC;IACV,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;CACzE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,QAiExD"}
@@ -0,0 +1,41 @@
1
+ import { useRef as s, useEffect as f } from "react";
2
+ function g(t) {
3
+ const m = s(t.startDragCallback);
4
+ m.current = t.startDragCallback;
5
+ const i = s(t.dragCallback);
6
+ i.current = t.dragCallback;
7
+ const v = s(t.endDragCallback);
8
+ v.current = t.endDragCallback, f(() => {
9
+ const r = t.handles;
10
+ if (r === void 0) return;
11
+ let n = 0, a = 0;
12
+ function d(e) {
13
+ const l = e.clientX - n, u = e.clientY - a;
14
+ i.current(l, u, n, a);
15
+ }
16
+ function o(e) {
17
+ const l = e.clientX !== void 0 ? e.clientX - n : 0, u = e.clientY !== void 0 ? e.clientY - a : 0;
18
+ v.current(l, u, n, a), document.body.removeEventListener("mousemove", d), document.body.removeEventListener("mouseup", o), document.body.removeEventListener("mouseleave", o);
19
+ }
20
+ function c(e) {
21
+ n = e.clientX, a = e.clientY, m.current(n, a), document.body.addEventListener("mousemove", d), document.body.addEventListener("mouseup", o), document.body.addEventListener("mouseleave", o);
22
+ }
23
+ if (Array.isArray(r))
24
+ for (const e of r)
25
+ e?.current?.addEventListener("mousedown", c);
26
+ else
27
+ r?.current?.addEventListener("mousedown", c);
28
+ return () => {
29
+ if (Array.isArray(r))
30
+ for (const e of r)
31
+ e?.current?.removeEventListener("mousedown", c);
32
+ else
33
+ r?.current?.removeEventListener("mousedown", c);
34
+ document.body.removeEventListener("mousemove", d), document.body.removeEventListener("mouseup", o), document.body.removeEventListener("mouseleave", o);
35
+ };
36
+ }, [t.handles]);
37
+ }
38
+ export {
39
+ g as useDraggable
40
+ };
41
+ //# sourceMappingURL=use_draggable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_draggable.js","sources":["../../../../src/utils/dnd/hooks/use_draggable.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nexport interface UseDraggableOptions {\n startDragCallback: (startX: number, startY: number) => void;\n dragCallback: (deltaX: number, deltaY: number, startX: number, startY: number) => void;\n endDragCallback: (\n deltaX: number,\n deltaY: number,\n startX: number,\n startY: number\n ) => void;\n handles?: React.RefObject<HTMLElement>[] | React.RefObject<HTMLElement>;\n}\n\nexport function useDraggable(options: UseDraggableOptions) {\n const startDragCallbackRef = useRef(options.startDragCallback);\n startDragCallbackRef.current = options.startDragCallback;\n const dragCallbackRef = useRef(options.dragCallback);\n dragCallbackRef.current = options.dragCallback;\n const endDragCallbackRef = useRef(options.endDragCallback);\n endDragCallbackRef.current = options.endDragCallback;\n\n useEffect(() => {\n const handles = options.handles;\n if (handles === undefined) return;\n let startX = 0;\n let startY = 0;\n\n function drag(event: MouseEvent) {\n const deltaX = event.clientX - startX;\n const deltaY = event.clientY - startY;\n\n dragCallbackRef.current(deltaX, deltaY, startX, startY);\n }\n\n function endDrag(event: MouseEvent) {\n const deltaX = event.clientX !== undefined ? event.clientX - startX : 0;\n const deltaY = event.clientY !== undefined ? event.clientY - startY : 0;\n endDragCallbackRef.current(deltaX, deltaY, startX, startY);\n document.body.removeEventListener('mousemove', drag);\n document.body.removeEventListener('mouseup', endDrag);\n document.body.removeEventListener('mouseleave', endDrag);\n }\n\n function startDrag(event: MouseEvent) {\n startX = event.clientX;\n startY = event.clientY;\n\n startDragCallbackRef.current(startX, startY);\n\n document.body.addEventListener('mousemove', drag);\n document.body.addEventListener('mouseup', endDrag);\n document.body.addEventListener('mouseleave', endDrag);\n }\n\n if (Array.isArray(handles)) {\n for (const element of handles) {\n if (element != null) {\n element.current?.addEventListener('mousedown', startDrag);\n }\n }\n } else {\n handles?.current?.addEventListener('mousedown', startDrag);\n }\n return () => {\n if (Array.isArray(handles)) {\n for (const element of handles) {\n if (element != null) {\n element.current?.removeEventListener('mousedown', startDrag);\n }\n }\n } else {\n handles?.current?.removeEventListener('mousedown', startDrag);\n }\n document.body.removeEventListener('mousemove', drag);\n document.body.removeEventListener('mouseup', endDrag);\n document.body.removeEventListener('mouseleave', endDrag);\n };\n }, [options.handles]);\n}\n"],"names":["useDraggable","options","startDragCallbackRef","useRef","dragCallbackRef","endDragCallbackRef","useEffect","handles","startX","startY","drag","event","deltaX","deltaY","endDrag","startDrag","element"],"mappings":";AAcO,SAASA,EAAaC,GAA8B;AACzD,QAAMC,IAAuBC,EAAOF,EAAQ,iBAAiB;AAC7D,EAAAC,EAAqB,UAAUD,EAAQ;AACvC,QAAMG,IAAkBD,EAAOF,EAAQ,YAAY;AACnD,EAAAG,EAAgB,UAAUH,EAAQ;AAClC,QAAMI,IAAqBF,EAAOF,EAAQ,eAAe;AACzD,EAAAI,EAAmB,UAAUJ,EAAQ,iBAErCK,EAAU,MAAM;AACd,UAAMC,IAAUN,EAAQ;AACxB,QAAIM,MAAY,OAAW;AAC3B,QAAIC,IAAS,GACTC,IAAS;AAEb,aAASC,EAAKC,GAAmB;AAC/B,YAAMC,IAASD,EAAM,UAAUH,GACzBK,IAASF,EAAM,UAAUF;AAE/B,MAAAL,EAAgB,QAAQQ,GAAQC,GAAQL,GAAQC,CAAM;AAAA,IACxD;AAEA,aAASK,EAAQH,GAAmB;AAClC,YAAMC,IAASD,EAAM,YAAY,SAAYA,EAAM,UAAUH,IAAS,GAChEK,IAASF,EAAM,YAAY,SAAYA,EAAM,UAAUF,IAAS;AACtE,MAAAJ,EAAmB,QAAQO,GAAQC,GAAQL,GAAQC,CAAM,GACzD,SAAS,KAAK,oBAAoB,aAAaC,CAAI,GACnD,SAAS,KAAK,oBAAoB,WAAWI,CAAO,GACpD,SAAS,KAAK,oBAAoB,cAAcA,CAAO;AAAA,IACzD;AAEA,aAASC,EAAUJ,GAAmB;AACpC,MAAAH,IAASG,EAAM,SACfF,IAASE,EAAM,SAEfT,EAAqB,QAAQM,GAAQC,CAAM,GAE3C,SAAS,KAAK,iBAAiB,aAAaC,CAAI,GAChD,SAAS,KAAK,iBAAiB,WAAWI,CAAO,GACjD,SAAS,KAAK,iBAAiB,cAAcA,CAAO;AAAA,IACtD;AAEA,QAAI,MAAM,QAAQP,CAAO;AACvB,iBAAWS,KAAWT;AACpB,QACES,GAAQ,SAAS,iBAAiB,aAAaD,CAAS;AAAA;AAI5D,MAAAR,GAAS,SAAS,iBAAiB,aAAaQ,CAAS;AAE3D,WAAO,MAAM;AACX,UAAI,MAAM,QAAQR,CAAO;AACvB,mBAAWS,KAAWT;AACpB,UACES,GAAQ,SAAS,oBAAoB,aAAaD,CAAS;AAAA;AAI/D,QAAAR,GAAS,SAAS,oBAAoB,aAAaQ,CAAS;AAE9D,eAAS,KAAK,oBAAoB,aAAaL,CAAI,GACnD,SAAS,KAAK,oBAAoB,WAAWI,CAAO,GACpD,SAAS,KAAK,oBAAoB,cAAcA,CAAO;AAAA,IACzD;AAAA,EACF,GAAG,CAACb,EAAQ,OAAO,CAAC;AACtB;"}
@@ -0,0 +1,10 @@
1
+ export interface DragContainer {
2
+ registerHandle: (handle: React.RefObject<HTMLElement>) => void;
3
+ unregisterHandle: (handle: React.RefObject<HTMLElement>) => void;
4
+ isDragging: boolean;
5
+ position: {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/dnd/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC/D,gBAAgB,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACjE,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACpC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,17 +1,18 @@
1
- export * from './focus_redirect.js';
2
1
  export * from './click_away_listener.js';
2
+ export * from './focus_redirect.js';
3
3
  export * from './scroll_away_listener.js';
4
+ export * from './dnd/hooks/use_draggable.js';
4
5
  export * from './hooks/make_context_hook.js';
5
- export * from './hooks/use_draggable.js';
6
6
  export * from './hooks/use_fork_ref.js';
7
7
  export * from './hooks/use_media_query.js';
8
8
  export * from './hooks/use_resize_observer.js';
9
9
  export * from './default_value.js';
10
10
  export * from './calendar/calendar_date.js';
11
11
  export * from './calendar/calendar_dates_generator.js';
12
- export * from './calendar/month.js';
13
- export * from './calendar/get_months_of_year.js';
14
12
  export * from './calendar/get_days_of_week.js';
15
- export * from './types/variations.js';
13
+ export * from './calendar/get_months_of_year.js';
14
+ export * from './calendar/month.js';
16
15
  export * from './types/dimensions.js';
16
+ export * from './types/variations.js';
17
+ export * from './responsive/responsive_renderer.js';
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAE/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AAEpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,qCAAqC,CAAC"}
@@ -1,30 +1,33 @@
1
- import { FocusRedirect as o } from "./focus_redirect.js";
2
- import { ClickAwayListener as f } from "./click_away_listener.js";
3
- import { ScrollAwayListener as m } from "./scroll_away_listener.js";
4
- import { makeContextHook as p } from "./hooks/make_context_hook.js";
5
- import { useDraggable as i } from "./hooks/use_draggable.js";
1
+ import { ClickAwayListener as o, isEventWithinElement as t } from "./click_away_listener.js";
2
+ import { FocusRedirect as m } from "./focus_redirect.js";
3
+ import { ScrollAwayListener as s } from "./scroll_away_listener.js";
4
+ import { useDraggable as a } from "./dnd/hooks/use_draggable.js";
5
+ import { makeContextHook as i } from "./hooks/make_context_hook.js";
6
6
  import { useForkRef as u } from "./hooks/use_fork_ref.js";
7
- import { useMediaQuery as l } from "./hooks/use_media_query.js";
8
- import { TriggerConfig as c, useResizeObserver as d } from "./hooks/use_resize_observer.js";
7
+ import { useMediaQuery as d } from "./hooks/use_media_query.js";
8
+ import { TriggerConfig as R, useResizeObserver as c } from "./hooks/use_resize_observer.js";
9
9
  import { defaultValue as C } from "./default_value.js";
10
- import { CalendarDatesGenerator as M } from "./calendar/calendar_dates_generator.js";
11
- import { Month as R } from "./calendar/month.js";
12
- import { getMonthsOfYear as h } from "./calendar/get_months_of_year.js";
13
- import { getDaysOfWeek as A } from "./calendar/get_days_of_week.js";
10
+ import { CalendarDatesGenerator as v } from "./calendar/calendar_dates_generator.js";
11
+ import { getDaysOfWeek as M } from "./calendar/get_days_of_week.js";
12
+ import { getMonthsOfYear as b } from "./calendar/get_months_of_year.js";
13
+ import { Month as A } from "./calendar/month.js";
14
+ import { ResponsiveRenderer as F } from "./responsive/responsive_renderer.js";
14
15
  export {
15
- M as CalendarDatesGenerator,
16
- f as ClickAwayListener,
17
- o as FocusRedirect,
18
- R as Month,
19
- m as ScrollAwayListener,
20
- c as TriggerConfig,
16
+ v as CalendarDatesGenerator,
17
+ o as ClickAwayListener,
18
+ m as FocusRedirect,
19
+ A as Month,
20
+ F as ResponsiveRenderer,
21
+ s as ScrollAwayListener,
22
+ R as TriggerConfig,
21
23
  C as defaultValue,
22
- A as getDaysOfWeek,
23
- h as getMonthsOfYear,
24
- p as makeContextHook,
25
- i as useDraggable,
24
+ M as getDaysOfWeek,
25
+ b as getMonthsOfYear,
26
+ t as isEventWithinElement,
27
+ i as makeContextHook,
28
+ a as useDraggable,
26
29
  u as useForkRef,
27
- l as useMediaQuery,
28
- d as useResizeObserver
30
+ d as useMediaQuery,
31
+ c as useResizeObserver
29
32
  };
30
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ export interface MouseLeaveRegionProps {
3
+ elementsRefs: (React.RefObject<Element> | React.MutableRefObject<Element>)[];
4
+ onMouseLeave: () => void;
5
+ buffer?: number;
6
+ }
7
+ export declare function MouseLeaveRegion({ onMouseLeave, elementsRefs: elementRefs, buffer, }: MouseLeaveRegionProps): null;
8
+ //# sourceMappingURL=mouse_leave_region.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mouse_leave_region.d.ts","sourceRoot":"","sources":["../../src/utils/mouse_leave_region.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IAC7E,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,EACZ,YAAY,EAAE,WAAW,EACzB,MAAU,GACX,EAAE,qBAAqB,QAyBvB"}
@@ -0,0 +1,26 @@
1
+ import { useEffect as u } from "react";
2
+ function v({
3
+ onMouseLeave: o,
4
+ elementsRefs: i,
5
+ buffer: t = 8
6
+ }) {
7
+ return u(() => {
8
+ const r = (e) => {
9
+ i.some((c) => {
10
+ const s = c.current;
11
+ if (s != null) {
12
+ const n = s.getBoundingClientRect(), l = Math.max(e.clientX - t, n.left), m = Math.min(e.clientX + t, n.right), a = Math.max(e.clientY - t, n.top), p = Math.min(e.clientY + t, n.bottom);
13
+ return l <= m && a <= p;
14
+ }
15
+ return !1;
16
+ }) || o();
17
+ };
18
+ return window.addEventListener("mousemove", r), () => {
19
+ window.removeEventListener("mousemove", r);
20
+ };
21
+ }, [o, i, t]), null;
22
+ }
23
+ export {
24
+ v as MouseLeaveRegion
25
+ };
26
+ //# sourceMappingURL=mouse_leave_region.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mouse_leave_region.js","sources":["../../src/utils/mouse_leave_region.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nexport interface MouseLeaveRegionProps {\n elementsRefs: (React.RefObject<Element> | React.MutableRefObject<Element>)[];\n onMouseLeave: () => void;\n buffer?: number;\n}\n\nexport function MouseLeaveRegion({\n onMouseLeave,\n elementsRefs: elementRefs,\n buffer = 8,\n}: MouseLeaveRegionProps) {\n useEffect(() => {\n const update = (event: MouseEvent) => {\n const intersects = elementRefs.some(ref => {\n const element = ref.current;\n if (element != null) {\n const rect = element.getBoundingClientRect();\n const overlapLeft = Math.max(event.clientX - buffer, rect.left);\n const overlapRight = Math.min(event.clientX + buffer, rect.right);\n const overlapTop = Math.max(event.clientY - buffer, rect.top);\n const overlapBottom = Math.min(event.clientY + buffer, rect.bottom);\n return overlapLeft <= overlapRight && overlapTop <= overlapBottom;\n }\n return false;\n });\n if (!intersects) {\n onMouseLeave();\n }\n };\n window.addEventListener('mousemove', update);\n return () => {\n window.removeEventListener('mousemove', update);\n };\n }, [onMouseLeave, elementRefs, buffer]);\n return null;\n}\n"],"names":["MouseLeaveRegion","onMouseLeave","elementRefs","buffer","useEffect","update","event","ref","element","rect","overlapLeft","overlapRight","overlapTop","overlapBottom"],"mappings":";AAQO,SAASA,EAAiB;AAAA,EAC/B,cAAAC;AAAA,EACA,cAAcC;AAAA,EACd,QAAAC,IAAS;AACX,GAA0B;AACxB,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAS,CAACC,MAAsB;AAapC,MAZmBJ,EAAY,KAAK,CAAAK,MAAO;AACzC,cAAMC,IAAUD,EAAI;AACpB,YAAIC,KAAW,MAAM;AACnB,gBAAMC,IAAOD,EAAQ,sBAAA,GACfE,IAAc,KAAK,IAAIJ,EAAM,UAAUH,GAAQM,EAAK,IAAI,GACxDE,IAAe,KAAK,IAAIL,EAAM,UAAUH,GAAQM,EAAK,KAAK,GAC1DG,IAAa,KAAK,IAAIN,EAAM,UAAUH,GAAQM,EAAK,GAAG,GACtDI,IAAgB,KAAK,IAAIP,EAAM,UAAUH,GAAQM,EAAK,MAAM;AAClE,iBAAOC,KAAeC,KAAgBC,KAAcC;AAAA,QACtD;AACA,eAAO;AAAA,MACT,CAAC,KAECZ,EAAA;AAAA,IAEJ;AACA,kBAAO,iBAAiB,aAAaI,CAAM,GACpC,MAAM;AACX,aAAO,oBAAoB,aAAaA,CAAM;AAAA,IAChD;AAAA,EACF,GAAG,CAACJ,GAAcC,GAAaC,CAAM,CAAC,GAC/B;AACT;"}
@@ -6,7 +6,17 @@ export interface Dimensions {
6
6
  width: number;
7
7
  height: number;
8
8
  }
9
- export interface Rect {
9
+ export interface Rectangle {
10
+ dimensions: Dimensions;
11
+ position: Position;
12
+ }
13
+ export interface RectCorners {
14
+ topLeft: Position;
15
+ topRight: Position;
16
+ bottomLeft: Position;
17
+ bottomRight: Position;
18
+ }
19
+ export interface RectEdges {
10
20
  top: number;
11
21
  right: number;
12
22
  bottom: number;
@@ -1 +1 @@
1
- {"version":3,"file":"dimensions.d.ts","sourceRoot":"","sources":["../../../src/utils/types/dimensions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd"}
1
+ {"version":3,"file":"dimensions.d.ts","sourceRoot":"","sources":["../../../src/utils/types/dimensions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,QAAQ,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,QAAQ,CAAC;IACrB,WAAW,EAAE,QAAQ,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tcn/ui",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "author": "TCN",
@@ -41,6 +41,12 @@
41
41
  "import": "./dist/actions/index.js",
42
42
  "default": "./dist/actions/index.js"
43
43
  },
44
+ "./dnd": {
45
+ "@bc-monorepo/source": "./src/dnd/index.ts",
46
+ "types": "./dist/dnd/index.d.ts",
47
+ "import": "./dist/dnd/index.js",
48
+ "default": "./dist/dnd/index.js"
49
+ },
44
50
  "./feedback": {
45
51
  "@bc-monorepo/source": "./src/feedback/index.ts",
46
52
  "types": "./dist/feedback/index.d.ts",
@@ -128,8 +134,8 @@
128
134
  "dependencies": {
129
135
  "clsx": "^2.1.1",
130
136
  "react-color": "^2.19.3",
131
- "@tcn/icons": "2.1.1",
132
- "@tcn/state": "1.0.1"
137
+ "@tcn/icons": "2.2.0",
138
+ "@tcn/state": "1.1.0"
133
139
  },
134
140
  "scripts": {
135
141
  "build": "vite build",
@@ -11,7 +11,7 @@ import { ColorPicker } from './color_picker.js';
11
11
  import { Input } from '../input/input.js';
12
12
  import styles from './color_input.module.css';
13
13
 
14
- import { Popper } from '../../overlay/popper/popper.js';
14
+ import { Popper } from '../../overlay/popper/legacy/popper.js';
15
15
 
16
16
  export interface ColorInputProps
17
17
  extends Omit<HTMLAttributes<HTMLButtonElement>, 'onChange' | 'onError'> {
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Hierarchy } from '../../utils/index.js';
3
3
  import { ZStack } from '../../stacks/z_stack.js';
4
- import { Popper } from '../../overlay/popper/popper.js';
4
+ import { Popper } from '../../overlay/popper/legacy/popper.js';
5
5
  import { clsx } from 'clsx';
6
6
  import { HTMLAttributes } from 'react';
7
7
  import { Button } from '../../actions/index.js';
@@ -2,7 +2,7 @@ import { Button } from '../../actions/index.js';
2
2
  import { clsx } from 'clsx';
3
3
  import styles from './date_picker_year_input.module.css';
4
4
  import { useState } from 'react';
5
- import { Popper } from '../../overlay/popper/popper.js';
5
+ import { Popper } from '../../overlay/popper/legacy/popper.js';
6
6
  import { DatePickerPresenter } from './date_picker_presenter.js';
7
7
  import { DatePickerYearSelector } from './date_picker_year_selector.js';
8
8
  import { useSignalValue } from '@tcn/state';
@@ -118,6 +118,8 @@ function getCountryCodeFromValue(
118
118
  export interface PhoneNumberInputProps
119
119
  extends Omit<HStackProps, 'onChange' | 'children'> {
120
120
  value?: string;
121
+ name?: string;
122
+ autoComplete?: string;
121
123
  defaultCountry?: string;
122
124
  /**
123
125
  * Callback fired when the phone number value changes.
@@ -135,6 +137,8 @@ export interface PhoneNumberInputProps
135
137
  export const PhoneNumberInput = React.forwardRef(function PhoneNumberInput(
136
138
  {
137
139
  value = '',
140
+ name,
141
+ autoComplete,
138
142
  defaultCountry = 'US',
139
143
  onChange,
140
144
  countrySelectRef: countryRef,
@@ -345,6 +349,8 @@ export const PhoneNumberInput = React.forwardRef(function PhoneNumberInput(
345
349
  {obfuscateValue ? (
346
350
  <MaskInput
347
351
  key="obfuscated"
352
+ name={name}
353
+ autoComplete={autoComplete}
348
354
  ref={forkedInputRef}
349
355
  value=""
350
356
  mask={createObfuscatedMasks(currentMasks)}
@@ -365,6 +371,8 @@ export const PhoneNumberInput = React.forwardRef(function PhoneNumberInput(
365
371
  ) : (
366
372
  <MaskInput
367
373
  key="normal"
374
+ name={name}
375
+ autoComplete={autoComplete}
368
376
  ref={forkedInputRef}
369
377
  value={phoneNumber}
370
378
  mask={currentMasks}
@@ -10,7 +10,7 @@ import { OptionProps, Option } from '../options/option.js';
10
10
  import styles from './suggestion_list.module.css';
11
11
 
12
12
  import { Button } from '../../actions/index.js';
13
- import { Popper } from '../../overlay/popper/popper.js';
13
+ import { Popper } from '../../overlay/popper/legacy/popper.js';
14
14
 
15
15
  const MAX_RESULTS = 50;
16
16
  const BATCH_SIZE = 50;
@@ -1,10 +1,10 @@
1
1
  import { clsx } from 'clsx';
2
2
  import React from 'react';
3
- import { HTMLAttributes } from 'react';
3
+ import { TextareaHTMLAttributes } from 'react';
4
4
  import styles from './textarea.module.css';
5
5
 
6
6
  export interface TextareaProps
7
- extends Omit<HTMLAttributes<HTMLTextAreaElement>, 'onChange'> {
7
+ extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'> {
8
8
  value?: string;
9
9
  width?: string;
10
10
  height?: string;
@@ -4,7 +4,6 @@ import { HStack, type HStackProps } from '../../stacks/h_stack.js';
4
4
  import type { Hierarchy, Size } from '../../utils/index.js';
5
5
  import styles from './header.module.css';
6
6
 
7
- // UtilityBar
8
7
  export interface HeaderProps extends Omit<HStackProps, 'as'> {
9
8
  hierarchy?: Hierarchy;
10
9
  size?: Size;