@tcn/ui 0.9.0 → 0.11.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 (298) hide show
  1. package/dist/bar.css +1 -0
  2. package/dist/body.css +1 -1
  3. package/dist/body.module-BbFZ7KNP.js +5 -0
  4. package/dist/body.module-BbFZ7KNP.js.map +1 -0
  5. package/dist/divider.css +1 -1
  6. package/dist/footer.css +1 -1
  7. package/dist/form/field/h_field/h_field.d.ts.map +1 -1
  8. package/dist/form/field/h_field/h_field.js +33 -35
  9. package/dist/form/field/h_field/h_field.js.map +1 -1
  10. package/dist/form/field/v_field/v_field.d.ts.map +1 -1
  11. package/dist/form/field/v_field/v_field.js +34 -36
  12. package/dist/form/field/v_field/v_field.js.map +1 -1
  13. package/dist/frame.css +1 -1
  14. package/dist/inputs/color_input/color_input.d.ts.map +1 -1
  15. package/dist/inputs/color_input/color_input.js +47 -46
  16. package/dist/inputs/color_input/color_input.js.map +1 -1
  17. package/dist/inputs/combo_box/combo_box.d.ts.map +1 -1
  18. package/dist/inputs/combo_box/combo_box.js +61 -58
  19. package/dist/inputs/combo_box/combo_box.js.map +1 -1
  20. package/dist/inputs/index.d.ts +1 -0
  21. package/dist/inputs/index.d.ts.map +1 -1
  22. package/dist/inputs/index.js +34 -31
  23. package/dist/inputs/index.js.map +1 -1
  24. package/dist/inputs/input/input.js +9 -9
  25. package/dist/inputs/input/input.js.map +1 -1
  26. package/dist/inputs/input_group/input_group.d.ts +5 -0
  27. package/dist/inputs/input_group/input_group.d.ts.map +1 -0
  28. package/dist/inputs/input_group/input_group.js +20 -0
  29. package/dist/inputs/input_group/input_group.js.map +1 -0
  30. package/dist/inputs/phone_number_input/countries_phone_information.d.ts +2 -2
  31. package/dist/inputs/phone_number_input/countries_phone_information.d.ts.map +1 -1
  32. package/dist/inputs/phone_number_input/countries_phone_information.js +5 -353
  33. package/dist/inputs/phone_number_input/countries_phone_information.js.map +1 -1
  34. package/dist/inputs/phone_number_input/phone_number_context.d.ts +24 -0
  35. package/dist/inputs/phone_number_input/phone_number_context.d.ts.map +1 -0
  36. package/dist/inputs/phone_number_input/phone_number_context.js +23 -0
  37. package/dist/inputs/phone_number_input/phone_number_context.js.map +1 -0
  38. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts +19 -0
  39. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts.map +1 -0
  40. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js +77 -0
  41. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js.map +1 -0
  42. package/dist/inputs/phone_number_input/phone_number_input.d.ts +16 -14
  43. package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
  44. package/dist/inputs/phone_number_input/phone_number_input.js +104 -274
  45. package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
  46. package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts +6 -0
  47. package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts.map +1 -0
  48. package/dist/inputs/phone_number_input/phone_number_input_adapter.js +95 -0
  49. package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -0
  50. package/dist/inputs/phone_number_input/sip_input.d.ts +12 -0
  51. package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -0
  52. package/dist/inputs/phone_number_input/sip_input.js +111 -0
  53. package/dist/inputs/phone_number_input/sip_input.js.map +1 -0
  54. package/dist/inputs/select/select.d.ts.map +1 -1
  55. package/dist/inputs/select/select.js +3 -2
  56. package/dist/inputs/select/select.js.map +1 -1
  57. package/dist/inputs/suggestions/suggestion_list.d.ts +4 -1
  58. package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
  59. package/dist/inputs/suggestions/suggestion_list.js +120 -111
  60. package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
  61. package/dist/inputs/textarea/textarea.js +8 -8
  62. package/dist/inputs/textarea/textarea.js.map +1 -1
  63. package/dist/inputs/unit_input/unit_input.d.ts.map +1 -1
  64. package/dist/inputs/unit_input/unit_input.js +39 -39
  65. package/dist/inputs/unit_input/unit_input.js.map +1 -1
  66. package/dist/layouts/bar/bar.d.ts +5 -0
  67. package/dist/layouts/bar/bar.d.ts.map +1 -0
  68. package/dist/layouts/bar/bar.js +20 -0
  69. package/dist/layouts/bar/bar.js.map +1 -0
  70. package/dist/layouts/body/body.d.ts +2 -2
  71. package/dist/layouts/body/body.d.ts.map +1 -1
  72. package/dist/layouts/body/body.js +12 -12
  73. package/dist/layouts/body/body.js.map +1 -1
  74. package/dist/layouts/body/h_body.d.ts.map +1 -1
  75. package/dist/layouts/body/h_body.js +18 -12
  76. package/dist/layouts/body/h_body.js.map +1 -1
  77. package/dist/layouts/body/v_body.d.ts.map +1 -1
  78. package/dist/layouts/body/v_body.js +16 -10
  79. package/dist/layouts/body/v_body.js.map +1 -1
  80. package/dist/layouts/footer/footer.d.ts +2 -3
  81. package/dist/layouts/footer/footer.d.ts.map +1 -1
  82. package/dist/layouts/footer/footer.js +7 -7
  83. package/dist/layouts/footer/footer.js.map +1 -1
  84. package/dist/layouts/header/header.d.ts +2 -2
  85. package/dist/layouts/header/header.d.ts.map +1 -1
  86. package/dist/layouts/header/header.js +13 -21
  87. package/dist/layouts/header/header.js.map +1 -1
  88. package/dist/layouts/index.d.ts +0 -1
  89. package/dist/layouts/index.d.ts.map +1 -1
  90. package/dist/layouts/index.js +17 -19
  91. package/dist/layouts/index.js.map +1 -1
  92. package/dist/layouts/rail/rail.js +41 -41
  93. package/dist/layouts/rail/rail.js.map +1 -1
  94. package/dist/layouts/rail/side/side.d.ts.map +1 -1
  95. package/dist/layouts/rail/side/side.js +1 -1
  96. package/dist/layouts/rail/side/side.js.map +1 -1
  97. package/dist/layouts/rail/utility_strip/utility_strip.d.ts.map +1 -1
  98. package/dist/layouts/rail/utility_strip/utility_strip.js +21 -17
  99. package/dist/layouts/rail/utility_strip/utility_strip.js.map +1 -1
  100. package/dist/layouts/scaffold/scaffold.js +32 -32
  101. package/dist/layouts/scaffold/scaffold.js.map +1 -1
  102. package/dist/layouts/utility_bar/utility_bar.d.ts +2 -2
  103. package/dist/layouts/utility_bar/utility_bar.d.ts.map +1 -1
  104. package/dist/layouts/utility_bar/utility_bar.js +17 -19
  105. package/dist/layouts/utility_bar/utility_bar.js.map +1 -1
  106. package/dist/overlay/frame/frame.d.ts +8 -4
  107. package/dist/overlay/frame/frame.d.ts.map +1 -1
  108. package/dist/overlay/frame/frame.js +87 -23
  109. package/dist/overlay/frame/frame.js.map +1 -1
  110. package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -1
  111. package/dist/overlay/popper/legacy/popper.d.ts.map +1 -1
  112. package/dist/overlay/popper/legacy/popper.js +52 -50
  113. package/dist/overlay/popper/legacy/popper.js.map +1 -1
  114. package/dist/panel.css +1 -0
  115. package/dist/phone_number_input.css +1 -1
  116. package/dist/rail.css +1 -1
  117. package/dist/scaffold.css +1 -1
  118. package/dist/side.css +1 -1
  119. package/dist/stacks/box/bottom_resize_handle.d.ts +2 -2
  120. package/dist/stacks/box/bottom_resize_handle.d.ts.map +1 -1
  121. package/dist/stacks/box/bottom_resize_handle.js +12 -10
  122. package/dist/stacks/box/bottom_resize_handle.js.map +1 -1
  123. package/dist/stacks/box/box.d.ts +4 -4
  124. package/dist/stacks/box/box.d.ts.map +1 -1
  125. package/dist/stacks/box/box.js +26 -26
  126. package/dist/stacks/box/box.js.map +1 -1
  127. package/dist/stacks/box/end_resize_handle.d.ts +2 -2
  128. package/dist/stacks/box/end_resize_handle.d.ts.map +1 -1
  129. package/dist/stacks/box/end_resize_handle.js +6 -5
  130. package/dist/stacks/box/end_resize_handle.js.map +1 -1
  131. package/dist/stacks/box/left_resize_handle.d.ts +2 -2
  132. package/dist/stacks/box/left_resize_handle.d.ts.map +1 -1
  133. package/dist/stacks/box/left_resize_handle.js +10 -9
  134. package/dist/stacks/box/left_resize_handle.js.map +1 -1
  135. package/dist/stacks/box/resize_handlers.d.ts +2 -2
  136. package/dist/stacks/box/resize_handlers.d.ts.map +1 -1
  137. package/dist/stacks/box/resize_handlers.js +32 -32
  138. package/dist/stacks/box/resize_handlers.js.map +1 -1
  139. package/dist/stacks/box/right_resize_handle.d.ts +2 -2
  140. package/dist/stacks/box/right_resize_handle.d.ts.map +1 -1
  141. package/dist/stacks/box/right_resize_handle.js +6 -5
  142. package/dist/stacks/box/right_resize_handle.js.map +1 -1
  143. package/dist/stacks/box/start_resize_handle.d.ts +2 -2
  144. package/dist/stacks/box/start_resize_handle.d.ts.map +1 -1
  145. package/dist/stacks/box/start_resize_handle.js +6 -6
  146. package/dist/stacks/box/start_resize_handle.js.map +1 -1
  147. package/dist/stacks/box/top_resize_handle.d.ts +2 -2
  148. package/dist/stacks/box/top_resize_handle.d.ts.map +1 -1
  149. package/dist/stacks/box/top_resize_handle.js +6 -5
  150. package/dist/stacks/box/top_resize_handle.js.map +1 -1
  151. package/dist/stacks/h_collapsible_box.d.ts.map +1 -1
  152. package/dist/stacks/h_collapsible_box.js +25 -25
  153. package/dist/stacks/h_collapsible_box.js.map +1 -1
  154. package/dist/stacks/v_collapsible_box.js +25 -25
  155. package/dist/stacks/v_collapsible_box.js.map +1 -1
  156. package/dist/suggestion_list.css +1 -1
  157. package/dist/surfaces/index.d.ts +1 -2
  158. package/dist/surfaces/index.d.ts.map +1 -1
  159. package/dist/surfaces/index.js +18 -20
  160. package/dist/surfaces/index.js.map +1 -1
  161. package/dist/surfaces/panel/panel.d.ts +5 -0
  162. package/dist/surfaces/panel/panel.d.ts.map +1 -0
  163. package/dist/surfaces/panel/panel.js +19 -0
  164. package/dist/surfaces/panel/panel.js.map +1 -0
  165. package/dist/surfaces/pop_confirm/pop_confirm.js +2 -3
  166. package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
  167. package/dist/surfaces/window/window.d.ts +1 -1
  168. package/dist/surfaces/window/window.d.ts.map +1 -1
  169. package/dist/surfaces/window/window.js +20 -10
  170. package/dist/surfaces/window/window.js.map +1 -1
  171. package/dist/themes/stylesheets/reset.css +1 -1
  172. package/dist/themes/stylesheets/reset.js +8 -1
  173. package/dist/themes/stylesheets/reset.js.map +1 -1
  174. package/dist/themes/theme.d.ts +2 -1
  175. package/dist/themes/theme.d.ts.map +1 -1
  176. package/dist/themes/theme.js +16 -9
  177. package/dist/themes/theme.js.map +1 -1
  178. package/dist/themes/themes/ergo/ergo_theme.css +1 -1
  179. package/dist/themes/themes/ergo/ergo_theme.js +210 -18
  180. package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
  181. package/dist/typography/body_text/body_text.d.ts.map +1 -1
  182. package/dist/typography/body_text/body_text.js +12 -10
  183. package/dist/typography/body_text/body_text.js.map +1 -1
  184. package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
  185. package/dist/utils/dnd/hooks/use_drag_container.js +22 -19
  186. package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
  187. package/package.json +4 -2
  188. package/src/form/field/h_field/h_field.tsx +0 -4
  189. package/src/form/field/v_field/v_field.stories.tsx +8 -0
  190. package/src/form/field/v_field/v_field.tsx +1 -4
  191. package/src/form/field_set/field_set.stories.tsx +2 -1
  192. package/src/inputs/__docs__/inputs.mdx +81 -0
  193. package/src/inputs/__docs__/inputs.stories.tsx +268 -0
  194. package/src/inputs/color_input/color_input.tsx +17 -17
  195. package/src/inputs/combo_box/combo_box.tsx +17 -13
  196. package/src/inputs/index.ts +2 -0
  197. package/src/inputs/input/input.tsx +1 -1
  198. package/src/inputs/input_group/input_group.tsx +26 -0
  199. package/src/inputs/phone_number_input/countries_phone_information.ts +6 -353
  200. package/src/inputs/phone_number_input/phone_number_context.tsx +32 -0
  201. package/src/inputs/phone_number_input/phone_number_country_select_adapter.tsx +126 -0
  202. package/src/inputs/phone_number_input/phone_number_input.module.css +5 -63
  203. package/src/inputs/phone_number_input/phone_number_input.stories.tsx +180 -150
  204. package/src/inputs/phone_number_input/phone_number_input.tsx +133 -400
  205. package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +123 -0
  206. package/src/inputs/phone_number_input/sip_input.tsx +147 -0
  207. package/src/inputs/select/select.tsx +13 -14
  208. package/src/inputs/suggestions/suggestion_list.module.css +1 -0
  209. package/src/inputs/suggestions/suggestion_list.stories.tsx +12 -8
  210. package/src/inputs/suggestions/suggestion_list.tsx +24 -3
  211. package/src/inputs/textarea/textarea.tsx +1 -1
  212. package/src/inputs/unit_input/unit_input.tsx +17 -17
  213. package/src/layouts/__stories__/composed.stories.tsx +0 -55
  214. package/src/layouts/__stories__/rail.stories.tsx +78 -0
  215. package/src/layouts/__stories__/scaffold.stories.tsx +90 -0
  216. package/src/layouts/__stories__/utils/content.tsx +27 -0
  217. package/src/layouts/__stories__/utils/layout_theme.css +88 -0
  218. package/src/layouts/__stories__/utils/layout_theme_provider.tsx +11 -0
  219. package/src/layouts/__stories__/utils.tsx +6 -6
  220. package/src/layouts/{utility_bar/utility_bar.module.css → bar/bar.module.css} +2 -1
  221. package/src/layouts/bar/bar.tsx +23 -0
  222. package/src/layouts/body/body.module.css +9 -4
  223. package/src/layouts/body/body.tsx +7 -6
  224. package/src/layouts/body/h_body.module.css +1 -2
  225. package/src/layouts/body/h_body.tsx +9 -4
  226. package/src/layouts/body/v_body.tsx +9 -4
  227. package/src/layouts/divider/divider.module.css +1 -1
  228. package/src/layouts/footer/footer.module.css +0 -3
  229. package/src/layouts/footer/footer.tsx +5 -6
  230. package/src/layouts/header/header.tsx +6 -15
  231. package/src/layouts/index.ts +0 -1
  232. package/src/layouts/rail/rail.module.css +9 -5
  233. package/src/layouts/rail/rail.tsx +1 -1
  234. package/src/layouts/rail/side/side.module.css +0 -1
  235. package/src/layouts/rail/side/side.tsx +1 -2
  236. package/src/layouts/rail/utility_strip/utility_strip.module.css +5 -0
  237. package/src/layouts/rail/utility_strip/utility_strip.tsx +4 -1
  238. package/src/layouts/scaffold/scaffold.module.css +10 -7
  239. package/src/layouts/scaffold/scaffold.tsx +1 -1
  240. package/src/layouts/utility_bar/utility_bar.tsx +6 -9
  241. package/src/overlay/frame/frame.module.css +2 -4
  242. package/src/overlay/frame/frame.stories.tsx +13 -10
  243. package/src/overlay/frame/frame.tsx +124 -16
  244. package/src/overlay/popper/base/dismissal_decorator.tsx +1 -1
  245. package/src/overlay/popper/legacy/popper.tsx +5 -1
  246. package/src/stacks/box/bottom_resize_handle.tsx +12 -5
  247. package/src/stacks/box/box.tsx +18 -14
  248. package/src/stacks/box/end_resize_handle.tsx +11 -6
  249. package/src/stacks/box/left_resize_handle.tsx +9 -3
  250. package/src/stacks/box/resize_handlers.ts +27 -13
  251. package/src/stacks/box/right_resize_handle.tsx +9 -3
  252. package/src/stacks/box/start_resize_handle.tsx +9 -4
  253. package/src/stacks/box/top_resize_handle.tsx +10 -4
  254. package/src/stacks/collapsible_box.stories.tsx +11 -11
  255. package/src/stacks/h_collapsible_box.tsx +5 -5
  256. package/src/stacks/v_collapsible_box.tsx +4 -4
  257. package/src/surfaces/index.ts +1 -2
  258. package/src/surfaces/panel/__stories__/panel.stories.tsx +12 -12
  259. package/src/surfaces/panel/__stories__/panel_stories.module.css +3 -3
  260. package/src/surfaces/panel/panel.module.css +1 -6
  261. package/src/surfaces/panel/panel.tsx +22 -0
  262. package/src/surfaces/window/window.tsx +14 -4
  263. package/src/themes/stories/controls_fieldset.tsx +1 -1
  264. package/src/themes/stylesheets/reset.css +8 -1
  265. package/src/themes/theme.tsx +6 -2
  266. package/src/themes/themes/ergo/__stories__/material.stories.tsx +15 -16
  267. package/src/themes/themes/ergo/ergo_theme.css +210 -18
  268. package/src/typography/body_text/body_text.tsx +2 -0
  269. package/src/utils/dnd/__stories__/draggable.stories.tsx +14 -8
  270. package/src/utils/dnd/hooks/use_drag_container.ts +13 -3
  271. package/dist/h_body.css +0 -1
  272. package/dist/h_panel.css +0 -1
  273. package/dist/header.css +0 -1
  274. package/dist/layouts/rail/main/main.d.ts +0 -6
  275. package/dist/layouts/rail/main/main.d.ts.map +0 -1
  276. package/dist/layouts/rail/main/main.js +0 -21
  277. package/dist/layouts/rail/main/main.js.map +0 -1
  278. package/dist/main.css +0 -1
  279. package/dist/surfaces/panel/h_panel.d.ts +0 -9
  280. package/dist/surfaces/panel/h_panel.d.ts.map +0 -1
  281. package/dist/surfaces/panel/h_panel.js +0 -60
  282. package/dist/surfaces/panel/h_panel.js.map +0 -1
  283. package/dist/surfaces/panel/v_panel.d.ts +0 -5
  284. package/dist/surfaces/panel/v_panel.d.ts.map +0 -1
  285. package/dist/surfaces/panel/v_panel.js +0 -19
  286. package/dist/surfaces/panel/v_panel.js.map +0 -1
  287. package/dist/utility_bar.css +0 -1
  288. package/dist/v_body.css +0 -1
  289. package/src/inputs/phone_number_input/__tests__/utils.test.ts +0 -52
  290. package/src/layouts/header/header.module.css +0 -8
  291. package/src/layouts/rail/__stories__/rail.stories.tsx +0 -64
  292. package/src/layouts/rail/__stories__/rail_stories.module.css +0 -25
  293. package/src/layouts/rail/main/main.module.css +0 -7
  294. package/src/layouts/rail/main/main.tsx +0 -26
  295. package/src/layouts/scaffold/__stories__/scaffold.stories.tsx +0 -53
  296. package/src/layouts/scaffold/__stories__/scaffold_stories.module.css +0 -31
  297. package/src/surfaces/panel/h_panel.tsx +0 -65
  298. package/src/surfaces/panel/v_panel.tsx +0 -20
@@ -1,50 +1,158 @@
1
- import React from 'react';
2
- import { ZStack, type ZStackProps } from '../../stacks/index.js';
3
- import { Portal } from '../portal/portal.js';
1
+ import { clsx } from 'clsx';
2
+ import React, { useCallback } from 'react';
3
+ import { flushSync } from 'react-dom';
4
+ import { Box, ZStack, type BoxProps } from '../../stacks/index.js';
5
+ import { useDragContainer } from '../../utils/dnd/context.js';
4
6
  import { Draggable } from '../../utils/dnd/draggable/draggable.js';
7
+ import { Portal } from '../portal/portal.js';
5
8
 
6
9
  // Styles
7
10
  import styles from './frame.module.css';
8
- import { clsx } from 'clsx';
9
-
10
11
  export interface FrameOwnProps {
11
12
  isOpen?: boolean;
12
- children?: React.ReactNode;
13
13
  draggable?: boolean;
14
14
  veil?: boolean;
15
+ resizable?: boolean;
15
16
  }
16
17
 
17
- export type FrameProps = ZStackProps & FrameOwnProps;
18
+ export type FrameProps = Omit<
19
+ BoxProps,
20
+ | 'enableResizeOnLeft'
21
+ | 'enableResizeOnRight'
22
+ | 'enableResizeOnTop'
23
+ | 'enableResizeOnBottom'
24
+ > &
25
+ FrameOwnProps;
18
26
 
19
- export const Frame = React.forwardRef<HTMLDialogElement, FrameProps>(function Frame(
27
+ export const Frame = React.forwardRef<HTMLElement, FrameProps>(function Frame(
20
28
  {
21
29
  children,
22
30
  isOpen = false,
23
31
  draggable = true,
24
32
  veil = false,
33
+ resizable = true,
25
34
  className,
26
35
  ...rest
27
36
  }: FrameProps,
28
37
  ref
29
38
  ) {
30
- if (!isOpen) {
31
- return null;
32
- }
33
-
39
+ if (!isOpen) return null;
34
40
  return (
35
41
  <Portal>
36
42
  <ZStack width="100%" height="100%" data-is-veil={veil} className="tcn-frame-veil">
37
43
  <Draggable draggable={draggable}>
38
- <ZStack
39
- as="dialog"
44
+ <FrameDialog
45
+ className={className}
40
46
  ref={ref}
41
- className={clsx(styles['frame'], 'tcn-frame', className)}
47
+ enableResizeOnLeft={resizable}
48
+ enableResizeOnRight={resizable}
49
+ enableResizeOnTop={resizable}
50
+ enableResizeOnBottom={resizable}
51
+ draggable={draggable}
42
52
  {...rest}
43
53
  >
44
54
  {children}
45
- </ZStack>
55
+ </FrameDialog>
46
56
  </Draggable>
47
57
  </ZStack>
48
58
  </Portal>
49
59
  );
50
60
  });
61
+ interface FrameDialogProps extends BoxProps {}
62
+
63
+ export const FrameDialog = React.forwardRef<HTMLElement, FrameDialogProps>(
64
+ function FrameDialog(
65
+ {
66
+ as = 'div',
67
+ role = 'dialog',
68
+ children,
69
+ className,
70
+ draggable,
71
+ onWidthResize,
72
+ onHeightResize,
73
+ ...rest
74
+ }: FrameDialogProps,
75
+ ref: React.Ref<HTMLElement>
76
+ ) {
77
+ const drag = useDragContainer();
78
+
79
+ const handleWidthResize = React.useCallback(
80
+ (
81
+ width: number,
82
+ origin: 'left' | 'right',
83
+ totalDelta: number,
84
+ currentDelta: number
85
+ ) => {
86
+ if (!draggable) {
87
+ return;
88
+ }
89
+ // TODO: add clamp logic
90
+ if (origin === 'right') {
91
+ flushSync(() => {
92
+ drag.setPosition(prev => ({
93
+ x: prev.x + currentDelta / 2,
94
+ y: prev.y,
95
+ }));
96
+ });
97
+ }
98
+ if (origin === 'left') {
99
+ flushSync(() => {
100
+ drag.setPosition(prev => ({
101
+ x: prev.x - currentDelta / 2,
102
+ y: prev.y,
103
+ }));
104
+ });
105
+ }
106
+
107
+ onWidthResize?.(width, origin, totalDelta, currentDelta);
108
+ },
109
+ [onWidthResize, drag, draggable]
110
+ );
111
+
112
+ const handleHeightResize = useCallback(
113
+ (
114
+ height: number,
115
+ origin: 'top' | 'bottom',
116
+ totalDelta: number,
117
+ currentDelta: number
118
+ ) => {
119
+ if (!draggable) {
120
+ return;
121
+ }
122
+ // TODO: add clamp logic
123
+ if (origin === 'bottom') {
124
+ flushSync(() => {
125
+ drag.setPosition(prev => ({
126
+ x: prev.x,
127
+ y: prev.y + currentDelta / 2,
128
+ }));
129
+ });
130
+ }
131
+ if (origin === 'top') {
132
+ flushSync(() => {
133
+ drag.setPosition(prev => ({
134
+ x: prev.x,
135
+ y: prev.y - currentDelta / 2,
136
+ }));
137
+ });
138
+ }
139
+ onHeightResize?.(height, origin, totalDelta, currentDelta);
140
+ },
141
+ [onHeightResize, drag, draggable]
142
+ );
143
+
144
+ return (
145
+ <Box
146
+ className={clsx(styles['frame-dialog'], 'tcn-frame-dialog', className)}
147
+ ref={ref}
148
+ onWidthResize={handleWidthResize}
149
+ onHeightResize={handleHeightResize}
150
+ as={as}
151
+ role={role}
152
+ {...rest}
153
+ >
154
+ {children}
155
+ </Box>
156
+ );
157
+ }
158
+ );
@@ -36,7 +36,7 @@ export const PopperDismissalDecorator = forwardRef<
36
36
 
37
37
  function buildExceptionHandler(dismissal: PopperDismissal) {
38
38
  if (dismissal in dismissals) {
39
- return target => isException?.(dismissal, target) ?? false;
39
+ return (target: HTMLElement) => isException?.(dismissal, target) ?? false;
40
40
  }
41
41
  return () => false;
42
42
  }
@@ -152,13 +152,17 @@ export function Popper({
152
152
  };
153
153
 
154
154
  useLayoutEffect(() => {
155
- updatePosition();
156
155
  window.addEventListener('resize', updatePosition);
157
156
  return () => {
158
157
  window.removeEventListener('resize', updatePosition);
159
158
  };
160
159
  });
161
160
 
161
+ // biome-ignore lint/correctness/useExhaustiveDependencies: updatePosition depends on open and anchorElement
162
+ useLayoutEffect(() => {
163
+ updatePosition();
164
+ }, [open, anchorElement]);
165
+
162
166
  useLayoutEffect(() => {
163
167
  if (open) {
164
168
  activeElementRef.current = window.document.activeElement as HTMLElement;
@@ -1,14 +1,19 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import styles from './bottom_resize_handle.module.css';
3
- import { createVerticalResizeHandler } from './resize_handlers.js';
4
- import { clsx } from 'clsx';
5
4
  import type { HandleProps } from './handle_props.js';
5
+ import { createVerticalResizeHandler } from './resize_handlers.js';
6
6
 
7
7
  export interface BottomResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onHeightResize?: (value: number) => void;
11
- onHeightResizeEnd?: (value: number) => void;
10
+ onHeightResize?: (
11
+ height: number,
12
+ origin: 'top' | 'bottom',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
16
+ onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
12
17
  }
13
18
 
14
19
  export function BottomResizeHandle({
@@ -20,7 +25,9 @@ export function BottomResizeHandle({
20
25
  const resizeHandler = createVerticalResizeHandler(
21
26
  targetRef,
22
27
  onHeightResize,
23
- onHeightResizeEnd
28
+ onHeightResizeEnd,
29
+ false,
30
+ 'bottom'
24
31
  );
25
32
  const offset = handleProps?.offset ? handleProps.offset : -8;
26
33
 
@@ -1,16 +1,16 @@
1
- import { useForkRef } from '../../utils/index.js';
1
+ import { clsx } from 'clsx';
2
2
  import React, { CSSProperties, HTMLAttributes, useRef } from 'react';
3
- import { LeftResizeHandle } from './left_resize_handle.js';
4
- import { RightResizeHandle } from './right_resize_handle.js';
3
+ import { useForkRef } from '../../utils/index.js';
4
+ import styles from '../stack.module.css';
5
+ import { isCustomSizeProp } from '../utils/isCustomSizeProp.js';
6
+ import { removeUndefinedProperties } from '../utils/remove_undefined_properties.js';
5
7
  import { BottomResizeHandle } from './bottom_resize_handle.js';
6
8
  import { EndResizeHandle } from './end_resize_handle.js';
9
+ import { HandleProps } from './handle_props.js';
10
+ import { LeftResizeHandle } from './left_resize_handle.js';
11
+ import { RightResizeHandle } from './right_resize_handle.js';
7
12
  import { StartResizeHandle } from './start_resize_handle.js';
8
13
  import { TopResizeHandle } from './top_resize_handle.js';
9
- import { clsx } from 'clsx';
10
- import { isCustomSizeProp } from '../utils/isCustomSizeProp.js';
11
- import { removeUndefinedProperties } from '../utils/remove_undefined_properties.js';
12
- import styles from '../stack.module.css';
13
- import { HandleProps } from './handle_props.js';
14
14
 
15
15
  export interface BoxProps<T extends HTMLElement = HTMLElement> extends HTMLAttributes<T> {
16
16
  as?: string;
@@ -46,15 +46,19 @@ export interface BoxProps<T extends HTMLElement = HTMLElement> extends HTMLAttri
46
46
  horizontalHandleProps?: HandleProps;
47
47
  verticalHandleProps?: HandleProps;
48
48
  onWidthResize?: (
49
- width: number
50
- // origin: 'left' | 'right'
49
+ width: number,
50
+ origin: 'left' | 'right',
51
+ totalDelta: number,
52
+ currentDelta: number
51
53
  ) => void;
52
54
  onHeightResize?: (
53
- height: number
54
- // origin: 'top' | 'bottom'
55
+ height: number,
56
+ origin: 'top' | 'bottom',
57
+ totalDelta: number,
58
+ currentDelta: number
55
59
  ) => void;
56
- onWidthResizeEnd?: (width: number) => void;
57
- onHeightResizeEnd?: (width: number) => void;
60
+ onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
61
+ onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
58
62
  }
59
63
 
60
64
  export const Box = React.forwardRef<HTMLElement, BoxProps>(function Box(
@@ -1,16 +1,20 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import styles from './end_resize_handle.module.css';
4
+ import { HandleProps } from './handle_props.js';
3
5
  import { createHorizontalResizeHandler } from './resize_handlers.js';
4
- import { clsx } from 'clsx';
5
- import type { HandleProps } from './handle_props.js';
6
6
 
7
7
  export interface EndResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (value: number) => void;
11
- onWidthResizeEnd?: (value: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
16
+ onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
-
14
18
  export function EndResizeHandle({
15
19
  targetRef,
16
20
  handleProps,
@@ -20,7 +24,8 @@ export function EndResizeHandle({
20
24
  const resizeHandler = createHorizontalResizeHandler(
21
25
  targetRef,
22
26
  onWidthResize,
23
- onWidthResizeEnd
27
+ onWidthResizeEnd,
28
+ 'right'
24
29
  );
25
30
  const offset = handleProps?.offset ? handleProps.offset : -8;
26
31
 
@@ -1,14 +1,19 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import { HandleProps } from './handle_props.js';
3
4
  import styles from './left_resize_handle.module.css';
4
5
  import { createHorizontalResizeHandler } from './resize_handlers.js';
5
- import { clsx } from 'clsx';
6
6
 
7
7
  export interface LeftResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (value: number) => void;
11
- onWidthResizeEnd?: (value: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
16
+ onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
18
  export function LeftResizeHandle({
14
19
  targetRef,
@@ -20,6 +25,7 @@ export function LeftResizeHandle({
20
25
  targetRef,
21
26
  onWidthResize,
22
27
  onWidthResizeEnd,
28
+ 'left',
23
29
  true,
24
30
  true
25
31
  );
@@ -9,8 +9,14 @@ function createVeil() {
9
9
 
10
10
  export function createHorizontalResizeHandler(
11
11
  targetRef: React.MutableRefObject<HTMLElement | null>,
12
- onWidthResize?: (value: number) => void,
13
- onWidthResizeEnd?: (value: number) => void,
12
+ onWidthResize?: (
13
+ width: number,
14
+ origin: 'left' | 'right',
15
+ totalDelta: number,
16
+ currentDelta: number
17
+ ) => void,
18
+ onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void,
19
+ origin: 'left' | 'right' = 'right',
14
20
  invert = false,
15
21
  disableDirection = false
16
22
  ) {
@@ -34,13 +40,14 @@ export function createHorizontalResizeHandler(
34
40
  let width = startRect.width;
35
41
 
36
42
  const drag = (event: MouseEvent) => {
37
- const deltaX = direction * (event.clientX - startX);
38
- const newWidth = startRect.width + deltaX;
43
+ const totalDelta = direction * (event.clientX - startX);
44
+ const newWidth = startRect.width + totalDelta;
45
+ const currentDelta = newWidth - width;
39
46
 
40
47
  width = newWidth;
41
48
 
42
49
  box.style.width = `${newWidth}px`;
43
- onWidthResize && onWidthResize(newWidth);
50
+ onWidthResize?.(newWidth, origin, totalDelta, currentDelta);
44
51
  event.stopPropagation();
45
52
  event.preventDefault();
46
53
  };
@@ -60,7 +67,7 @@ export function createHorizontalResizeHandler(
60
67
  event.stopPropagation();
61
68
  event.preventDefault();
62
69
 
63
- onWidthResizeEnd && onWidthResizeEnd(width);
70
+ onWidthResizeEnd?.(width, origin);
64
71
  };
65
72
 
66
73
  document.body.addEventListener('mousemove', drag);
@@ -73,9 +80,15 @@ export function createHorizontalResizeHandler(
73
80
 
74
81
  export function createVerticalResizeHandler(
75
82
  targetRef: React.MutableRefObject<HTMLElement | null>,
76
- onHeightResize?: (value: number) => void,
77
- onHeightResizeEnd?: (value: number) => void,
78
- invert = false
83
+ onHeightResize?: (
84
+ height: number,
85
+ origin: 'top' | 'bottom',
86
+ totalDelta: number,
87
+ currentDelta: number
88
+ ) => void,
89
+ onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void,
90
+ invert = false,
91
+ origin: 'top' | 'bottom' = 'bottom'
79
92
  ) {
80
93
  const direction = invert ? -1 : 1;
81
94
  return function startVerticalResize(event: React.MouseEvent) {
@@ -93,11 +106,12 @@ export function createVerticalResizeHandler(
93
106
  let height = startRect.height;
94
107
 
95
108
  const drag = (event: MouseEvent) => {
96
- const deltaY = direction * (event.clientY - startY);
97
- const newHeight = startRect.height + deltaY;
109
+ const totalDelta = direction * (event.clientY - startY);
110
+ const newHeight = startRect.height + totalDelta;
111
+ const currentDelta = newHeight - height;
98
112
  height = newHeight;
99
113
  box.style.height = `${newHeight}px`;
100
- onHeightResize && onHeightResize(newHeight);
114
+ onHeightResize?.(newHeight, origin, totalDelta, currentDelta);
101
115
  event.stopPropagation();
102
116
  event.preventDefault();
103
117
  };
@@ -117,7 +131,7 @@ export function createVerticalResizeHandler(
117
131
  event.stopPropagation();
118
132
  event.preventDefault();
119
133
 
120
- onHeightResizeEnd && onHeightResizeEnd(height);
134
+ onHeightResizeEnd?.(height, origin);
121
135
  };
122
136
 
123
137
  document.body.addEventListener('mousemove', drag);
@@ -1,14 +1,19 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import { HandleProps } from './handle_props.js';
3
4
  import { createHorizontalResizeHandler } from './resize_handlers.js';
4
5
  import styles from './right_resize_handle.module.css';
5
- import { clsx } from 'clsx';
6
6
 
7
7
  export interface RightResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (value: number) => void;
11
- onWidthResizeEnd?: (value: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
16
+ onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
18
  export function RightResizeHandle({
14
19
  targetRef,
@@ -20,6 +25,7 @@ export function RightResizeHandle({
20
25
  targetRef,
21
26
  onWidthResize,
22
27
  onWidthResizeEnd,
28
+ 'right',
23
29
  false,
24
30
  true
25
31
  );
@@ -1,14 +1,19 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import { HandleProps } from './handle_props.js';
3
4
  import { createHorizontalResizeHandler } from './resize_handlers.js';
4
5
  import styles from './start_resize_handle.module.css';
5
- import { clsx } from 'clsx';
6
6
 
7
7
  export interface StartResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (value: number) => void;
11
- onWidthResizeEnd?: (value: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
16
+ onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
18
  export function StartResizeHandle({
14
19
  targetRef,
@@ -20,7 +25,7 @@ export function StartResizeHandle({
20
25
  targetRef,
21
26
  onWidthResize,
22
27
  onWidthResizeEnd,
23
- true
28
+ 'left'
24
29
  );
25
30
  const offset = handleProps?.offset ? handleProps.offset : -8;
26
31
 
@@ -1,14 +1,19 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import { HandleProps } from './handle_props.js';
3
4
  import { createVerticalResizeHandler } from './resize_handlers.js';
4
5
  import styles from './top_resize_handle.module.css';
5
- import { clsx } from 'clsx';
6
6
 
7
7
  export interface TopResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onHeightResize?: (value: number) => void;
11
- onHeightResizeEnd?: (value: number) => void;
10
+ onHeightResize?: (
11
+ height: number,
12
+ origin: 'top' | 'bottom',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
16
+ onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
12
17
  }
13
18
  export function TopResizeHandle({
14
19
  targetRef,
@@ -20,7 +25,8 @@ export function TopResizeHandle({
20
25
  targetRef,
21
26
  onHeightResize,
22
27
  onHeightResizeEnd,
23
- true
28
+ true,
29
+ 'top'
24
30
  );
25
31
  const offset = handleProps?.offset ? handleProps.offset : -8;
26
32
 
@@ -1,13 +1,13 @@
1
+ import { ChevronLeftIcon as ChevronLeft } from '@tcn/icons/chevron_left_icon.js';
2
+ import { PlusIcon as Plus } from '@tcn/icons/plus_icon.js';
1
3
  import React from 'react';
2
4
  import { Button, SlimButton } from '../actions/index.js';
3
- import { HCollapsibleBox as HComponent } from './h_collapsible_box.js';
4
- import { VCollapsibleBox as VComponent } from './v_collapsible_box.js';
5
5
  import { Title } from '../typography/index.js';
6
- import { Spacer } from './spacer.js';
6
+ import { HCollapsibleBox } from './h_collapsible_box.js';
7
7
  import { HStack } from './h_stack.js';
8
+ import { Spacer } from './spacer.js';
9
+ import { VCollapsibleBox } from './v_collapsible_box.js';
8
10
  import { VStack } from './v_stack.js';
9
- import { ChevronLeftIcon as ChevronLeft } from '@tcn/icons/chevron_left_icon.js';
10
- import { PlusIcon as Plus } from '@tcn/icons/plus_icon.js';
11
11
 
12
12
  export default {
13
13
  title: 'Stacks/Collapsible Box',
@@ -49,13 +49,13 @@ export function CollapsibleBox() {
49
49
  <Button onClick={() => setVHopen(c => !c)}>toggle vertical collapse</Button>
50
50
  <Button onClick={() => setHOpen(c => !c)}>toggle horizontal collapse</Button>
51
51
  </VStack>
52
- <VComponent open={vOpen} enableResizeOnTop>
52
+ <VCollapsibleBox open={vOpen} enableResizeOnTop>
53
53
  <MyPanel />
54
- </VComponent>
54
+ </VCollapsibleBox>
55
55
  </VStack>
56
- <HComponent open={hOpen} enableResizeOnStart>
56
+ <HCollapsibleBox open={hOpen} enableResizeOnStart>
57
57
  <MyPanel />
58
- </HComponent>
58
+ </HCollapsibleBox>
59
59
  </HStack>
60
60
  );
61
61
  }
@@ -67,9 +67,9 @@ export function VerticalCollapsibleBox() {
67
67
  <HStack height="flex" hAlign="end" gap="16px">
68
68
  <Button onClick={() => setOpen(c => !c)}>toggle collapse</Button>
69
69
  </HStack>
70
- <VComponent open={open} enableResizeOnTop defaultHeight="300px">
70
+ <VCollapsibleBox open={open} enableResizeOnTop defaultHeight="300px">
71
71
  <MyPanel />
72
- </VComponent>
72
+ </VCollapsibleBox>
73
73
  </VStack>
74
74
  );
75
75
  }
@@ -1,6 +1,6 @@
1
+ import { clsx } from 'clsx';
1
2
  import React, { useLayoutEffect } from 'react';
2
3
  import { useForkRef } from '../utils/index.js';
3
- import { clsx } from 'clsx';
4
4
  import { Box, BoxProps } from './box/box.js';
5
5
  import styles from './collapsible_box.module.css';
6
6
  import { useIsCollapsed } from './utils/use_is_collapsed.js';
@@ -32,13 +32,13 @@ export const HCollapsibleBox = React.forwardRef(function CollapsibleBox(
32
32
  data-is-collapsed={!open}
33
33
  data-collapse-orientation="horizontal"
34
34
  data-is-resizing={resizing}
35
- onWidthResize={width => {
35
+ onWidthResize={(width, origin, totalDelta, currentDelta) => {
36
36
  setIsResizing(true);
37
- props.onWidthResize?.(width);
37
+ props.onWidthResize?.(width, origin, totalDelta, currentDelta);
38
38
  }}
39
- onWidthResizeEnd={width => {
39
+ onWidthResizeEnd={(width, origin) => {
40
40
  setIsResizing(false);
41
- props.onWidthResizeEnd?.(width);
41
+ props.onWidthResizeEnd?.(width, origin);
42
42
  collapsibleRef.current?.style.setProperty('--collapsible-size', `${width}px`);
43
43
  }}
44
44
  className={clsx(
@@ -32,14 +32,14 @@ export const VCollapsibleBox = React.forwardRef(function CollapsibleBox(
32
32
  data-is-collapsed={!open}
33
33
  data-collapse-orientation="vertical"
34
34
  data-is-resizing={resizing}
35
- onHeightResize={height => {
35
+ onHeightResize={(height, origin, totalDelta, currentDelta) => {
36
36
  setIsResizing(true);
37
- props.onHeightResize?.(height);
37
+ props.onHeightResize?.(height, origin, totalDelta, currentDelta);
38
38
  }}
39
- onHeightResizeEnd={height => {
39
+ onHeightResizeEnd={(height, origin) => {
40
40
  setIsResizing(false);
41
41
  collapsibleRef.current?.style.setProperty('--collapsible-size', `${height}px`);
42
- props.onHeightResizeEnd?.(height);
42
+ props.onHeightResizeEnd?.(height, origin);
43
43
  }}
44
44
  className={clsx(
45
45
  props.className,
@@ -3,8 +3,7 @@ export * from './card/card.js';
3
3
  export * from './confirm/confirm.js';
4
4
  export * from './page/h_page.js';
5
5
  export * from './page/v_page.js';
6
- export * from './panel/h_panel.js';
7
- export * from './panel/v_panel.js';
6
+ export * from './panel/panel.js';
8
7
  export * from './popover/popover.js';
9
8
  export * from './drawers/drawer_bottom/drawer_bottom.js';
10
9
  export * from './drawers/drawer_top/drawer_top.js';