@tcn/ui 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/dist/Color-ASIRERSW-B4GaVKuQ.js +990 -0
  2. package/dist/Color-ASIRERSW-B4GaVKuQ.js.map +1 -0
  3. package/dist/WithTooltip-IO6J4KBT-B1oq93K5.js +1485 -0
  4. package/dist/WithTooltip-IO6J4KBT-B1oq93K5.js.map +1 -0
  5. package/dist/actions/__docs__/components/gallery.d.ts +8 -0
  6. package/dist/actions/__docs__/components/gallery.d.ts.map +1 -0
  7. package/dist/actions/__docs__/components/gallery.js +20 -0
  8. package/dist/actions/__docs__/components/gallery.js.map +1 -0
  9. package/dist/actions/__docs__/components/showcase.d.ts +27 -0
  10. package/dist/actions/__docs__/components/showcase.d.ts.map +1 -0
  11. package/dist/actions/__docs__/components/showcase.js +15 -0
  12. package/dist/actions/__docs__/components/showcase.js.map +1 -0
  13. package/dist/actions/button/base_button/base_button.d.ts +2 -0
  14. package/dist/actions/button/base_button/base_button.d.ts.map +1 -1
  15. package/dist/actions/button/base_button/base_button.js +18 -16
  16. package/dist/actions/button/base_button/base_button.js.map +1 -1
  17. package/dist/actions/button/button/button.js +6 -6
  18. package/dist/actions/button/button_group/button_group.js +1 -1
  19. package/dist/actions/button/select_group/select_group.js +13 -13
  20. package/dist/actions/button/select_group/single_select_group.js +6 -6
  21. package/dist/actions/button/slim_button/slim_button.js +2 -2
  22. package/dist/actions/types.d.ts +2 -0
  23. package/dist/actions/types.d.ts.map +1 -0
  24. package/dist/actions/types.js +2 -0
  25. package/dist/actions/types.js.map +1 -0
  26. package/dist/divider.module-FptFV0PX.js +5 -0
  27. package/dist/divider.module-FptFV0PX.js.map +1 -0
  28. package/dist/feedback/loading/loading.js +12 -12
  29. package/dist/feedback/loading/loading.js.map +1 -1
  30. package/dist/feedback/progress/progress_bar.js +1 -1
  31. package/dist/form/field/common/field_control/field_control.js +8 -8
  32. package/dist/form/field/common/status_input/status_input.js +6 -6
  33. package/dist/form/field/field.js +6 -6
  34. package/dist/form/field/h_field/h_field.js +11 -11
  35. package/dist/form/field/v_field/v_field.js +10 -10
  36. package/dist/form/field_set/field_set.js +3 -3
  37. package/dist/formatter-QJ4M4OGQ-DaIl2Wi_.js +6 -0
  38. package/dist/formatter-QJ4M4OGQ-DaIl2Wi_.js.map +1 -0
  39. package/dist/frame.css +1 -0
  40. package/dist/gallery.css +1 -0
  41. package/dist/inputs/checkbox/checkbox.js +11 -11
  42. package/dist/inputs/color_input/color_input.js +1 -1
  43. package/dist/inputs/color_input/color_input.js.map +1 -1
  44. package/dist/inputs/color_input/color_picker.js +6 -6
  45. package/dist/inputs/combo_box/combo_box.js +17 -17
  46. package/dist/inputs/date_picker/date_picker.js +19 -19
  47. package/dist/inputs/date_picker/date_picker_body.js +2 -2
  48. package/dist/inputs/date_picker/date_picker_input.js +20 -20
  49. package/dist/inputs/date_picker/date_picker_input.js.map +1 -1
  50. package/dist/inputs/date_picker/date_picker_year_input.js +1 -1
  51. package/dist/inputs/date_picker/date_picker_year_input.js.map +1 -1
  52. package/dist/inputs/date_picker/date_picker_year_selector.js +1 -1
  53. package/dist/inputs/input/input.js +5 -5
  54. package/dist/inputs/mask_input/key_capture_input.js +8 -8
  55. package/dist/inputs/mask_input/mask_input.js +5 -5
  56. package/dist/inputs/multi_combo_box/multi_combo_box.js +17 -17
  57. package/dist/inputs/multiselect/multiselect.js +14 -14
  58. package/dist/inputs/multiselect/multiselect_row.js +8 -8
  59. package/dist/inputs/phone_number_input/phone_number_input.js +12 -12
  60. package/dist/inputs/radio/radio.js +10 -10
  61. package/dist/inputs/radio/radio_row.js +3 -3
  62. package/dist/inputs/select/select.js +15 -15
  63. package/dist/inputs/slider/slider.js +11 -11
  64. package/dist/inputs/suggestions/suggestion_list.js +2 -2
  65. package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
  66. package/dist/inputs/switch/switch.js +5 -5
  67. package/dist/inputs/textarea/textarea.js +7 -7
  68. package/dist/inputs/unit_input/unit_input.js +5 -5
  69. package/dist/layouts/body/h_body.js +7 -7
  70. package/dist/layouts/body/v_body.js +6 -6
  71. package/dist/layouts/column/column.js +17 -17
  72. package/dist/layouts/divider/divider.js +24 -23
  73. package/dist/layouts/divider/divider.js.map +1 -1
  74. package/dist/layouts/footer/footer.js +7 -7
  75. package/dist/layouts/grid/grid.js +24 -24
  76. package/dist/layouts/header/header.js +2 -2
  77. package/dist/layouts/index.d.ts +6 -5
  78. package/dist/layouts/index.d.ts.map +1 -1
  79. package/dist/layouts/index.js +28 -26
  80. package/dist/layouts/index.js.map +1 -1
  81. package/dist/layouts/list/item.js +2 -2
  82. package/dist/layouts/list/list.js +7 -7
  83. package/dist/layouts/list/section_header.js +6 -6
  84. package/dist/layouts/scaffold/scaffold.d.ts +9 -0
  85. package/dist/layouts/scaffold/scaffold.d.ts.map +1 -0
  86. package/dist/layouts/scaffold/scaffold.js +55 -0
  87. package/dist/layouts/scaffold/scaffold.js.map +1 -0
  88. package/dist/layouts/sidebar_end/sidebar_end.js +14 -14
  89. package/dist/layouts/sidebar_start/sidebar_start.js +10 -10
  90. package/dist/layouts/utility_bar/utility_bar.js +10 -10
  91. package/dist/modal.css +1 -1
  92. package/dist/overlay/frame/frame.d.ts.map +1 -1
  93. package/dist/overlay/frame/frame.js +22 -5
  94. package/dist/overlay/frame/frame.js.map +1 -1
  95. package/dist/overlay/index.d.ts +9 -2
  96. package/dist/overlay/index.d.ts.map +1 -1
  97. package/dist/overlay/index.js +22 -10
  98. package/dist/overlay/index.js.map +1 -1
  99. package/dist/overlay/menu/menu.d.ts +1 -1
  100. package/dist/overlay/menu/menu.d.ts.map +1 -1
  101. package/dist/overlay/menu/menu.js +36 -36
  102. package/dist/overlay/menu/menu.js.map +1 -1
  103. package/dist/overlay/popper/base/base_popper.d.ts +11 -0
  104. package/dist/overlay/popper/base/base_popper.d.ts.map +1 -0
  105. package/dist/overlay/popper/base/base_popper.js +27 -0
  106. package/dist/overlay/popper/base/base_popper.js.map +1 -0
  107. package/dist/overlay/popper/base/dismissal_decorator.d.ts +16 -0
  108. package/dist/overlay/popper/base/dismissal_decorator.d.ts.map +1 -0
  109. package/dist/overlay/popper/base/dismissal_decorator.js +69 -0
  110. package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -0
  111. package/dist/overlay/popper/context_popper.d.ts +11 -0
  112. package/dist/overlay/popper/context_popper.d.ts.map +1 -0
  113. package/dist/overlay/popper/context_popper.js +33 -0
  114. package/dist/overlay/popper/context_popper.js.map +1 -0
  115. package/dist/overlay/popper/element_popper.d.ts +7 -0
  116. package/dist/overlay/popper/element_popper.d.ts.map +1 -0
  117. package/dist/overlay/popper/element_popper.js +33 -0
  118. package/dist/overlay/popper/element_popper.js.map +1 -0
  119. package/dist/overlay/popper/hooks/use_context_trigger.d.ts +7 -0
  120. package/dist/overlay/popper/hooks/use_context_trigger.d.ts.map +1 -0
  121. package/dist/overlay/popper/hooks/use_context_trigger.js +31 -0
  122. package/dist/overlay/popper/hooks/use_context_trigger.js.map +1 -0
  123. package/dist/overlay/popper/hooks/use_hover_trigger.d.ts +6 -0
  124. package/dist/overlay/popper/hooks/use_hover_trigger.d.ts.map +1 -0
  125. package/dist/overlay/popper/hooks/use_hover_trigger.js +17 -0
  126. package/dist/overlay/popper/hooks/use_hover_trigger.js.map +1 -0
  127. package/dist/overlay/popper/hooks/use_restore_focus.d.ts +2 -0
  128. package/dist/overlay/popper/hooks/use_restore_focus.d.ts.map +1 -0
  129. package/dist/overlay/popper/hooks/use_restore_focus.js +18 -0
  130. package/dist/overlay/popper/hooks/use_restore_focus.js.map +1 -0
  131. package/dist/overlay/popper/legacy/popper.d.ts.map +1 -0
  132. package/dist/overlay/popper/{popper.js → legacy/popper.js} +6 -6
  133. package/dist/overlay/popper/legacy/popper.js.map +1 -0
  134. package/dist/overlay/popper/preview_popper.d.ts +7 -0
  135. package/dist/overlay/popper/preview_popper.d.ts.map +1 -0
  136. package/dist/overlay/popper/preview_popper.js +46 -0
  137. package/dist/overlay/popper/preview_popper.js.map +1 -0
  138. package/dist/overlay/portal/portal_platform_context.js +4 -4
  139. package/dist/overlay/tethered/element_tethered.d.ts +8 -0
  140. package/dist/overlay/tethered/element_tethered.d.ts.map +1 -0
  141. package/dist/overlay/tethered/element_tethered.js +33 -0
  142. package/dist/overlay/tethered/element_tethered.js.map +1 -0
  143. package/dist/overlay/tethered/hooks/calculate_position.d.ts +19 -0
  144. package/dist/overlay/tethered/hooks/calculate_position.d.ts.map +1 -0
  145. package/dist/overlay/tethered/hooks/calculate_position.js +43 -0
  146. package/dist/overlay/tethered/hooks/calculate_position.js.map +1 -0
  147. package/dist/overlay/tethered/hooks/useTether.d.ts +19 -0
  148. package/dist/overlay/tethered/hooks/useTether.d.ts.map +1 -0
  149. package/dist/overlay/tethered/hooks/useTether.js +61 -0
  150. package/dist/overlay/tethered/hooks/useTether.js.map +1 -0
  151. package/dist/overlay/tethered/tethered.d.ts +20 -0
  152. package/dist/overlay/tethered/tethered.d.ts.map +1 -0
  153. package/dist/overlay/tethered/tethered.js +59 -0
  154. package/dist/overlay/tethered/tethered.js.map +1 -0
  155. package/dist/overlay/tethered/types.d.ts +3 -0
  156. package/dist/overlay/tethered/types.d.ts.map +1 -0
  157. package/dist/overlay/tethered/types.js +2 -0
  158. package/dist/overlay/tethered/types.js.map +1 -0
  159. package/dist/popper.css +1 -1
  160. package/dist/scaffold.css +1 -0
  161. package/dist/showcase-WfP6kBEb.js +58401 -0
  162. package/dist/showcase-WfP6kBEb.js.map +1 -0
  163. package/dist/showcase.css +1 -0
  164. package/dist/stacks/box/box.js +24 -24
  165. package/dist/stacks/h_collapsible_box.js +3 -3
  166. package/dist/stacks/h_stack.js +41 -41
  167. package/dist/stacks/spacer.js +11 -11
  168. package/dist/stacks/story_components/circle.js +10 -10
  169. package/dist/stacks/story_components/picture_placeholder.js +9 -9
  170. package/dist/stacks/story_components/rect.js +7 -7
  171. package/dist/stacks/story_components/style_box.js +4 -4
  172. package/dist/stacks/utils/use_is_collapsed.js +6 -6
  173. package/dist/stacks/v_collapsible_box.js +3 -3
  174. package/dist/stacks/v_stack.js +42 -42
  175. package/dist/stacks/z_stack.js +39 -39
  176. package/dist/surfaces/alert/alert.js +4 -4
  177. package/dist/surfaces/card/card.d.ts +2 -2
  178. package/dist/surfaces/card/card.d.ts.map +1 -1
  179. package/dist/surfaces/card/card.js +7 -7
  180. package/dist/surfaces/card/card.js.map +1 -1
  181. package/dist/surfaces/confirm/confirm.js +9 -9
  182. package/dist/surfaces/drawers/drawer_start/drawer_start.js +2 -2
  183. package/dist/surfaces/drawers/drawer_top/drawer_top.js +2 -2
  184. package/dist/surfaces/index.d.ts +2 -0
  185. package/dist/surfaces/index.d.ts.map +1 -1
  186. package/dist/surfaces/index.js +22 -18
  187. package/dist/surfaces/index.js.map +1 -1
  188. package/dist/surfaces/modal/modal.d.ts +3 -3
  189. package/dist/surfaces/modal/modal.d.ts.map +1 -1
  190. package/dist/surfaces/modal/modal.js +14 -14
  191. package/dist/surfaces/modal/modal.js.map +1 -1
  192. package/dist/surfaces/page/h_page.js +7 -7
  193. package/dist/surfaces/page/v_page.js +5 -5
  194. package/dist/surfaces/panel/h_panel.js +29 -30
  195. package/dist/surfaces/panel/h_panel.js.map +1 -1
  196. package/dist/surfaces/panel/v_panel.d.ts +3 -7
  197. package/dist/surfaces/panel/v_panel.d.ts.map +1 -1
  198. package/dist/surfaces/panel/v_panel.js +12 -54
  199. package/dist/surfaces/panel/v_panel.js.map +1 -1
  200. package/dist/surfaces/pop_confirm/pop_confirm.d.ts +5 -0
  201. package/dist/surfaces/pop_confirm/pop_confirm.d.ts.map +1 -0
  202. package/dist/surfaces/pop_confirm/pop_confirm.js +37 -0
  203. package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -0
  204. package/dist/surfaces/popconfirm/pop_confirm.d.ts +5 -0
  205. package/dist/surfaces/popconfirm/pop_confirm.d.ts.map +1 -0
  206. package/dist/surfaces/popconfirm/pop_confirm.js +13 -0
  207. package/dist/surfaces/popconfirm/pop_confirm.js.map +1 -0
  208. package/dist/surfaces/popover/popover.d.ts +1 -1
  209. package/dist/surfaces/popover/popover.d.ts.map +1 -1
  210. package/dist/surfaces/popover/popover.js +1 -1
  211. package/dist/surfaces/popover/popover.js.map +1 -1
  212. package/dist/surfaces/tooltip/tooltip.d.ts +10 -0
  213. package/dist/surfaces/tooltip/tooltip.d.ts.map +1 -0
  214. package/dist/surfaces/tooltip/tooltip.js +38 -0
  215. package/dist/surfaces/tooltip/tooltip.js.map +1 -0
  216. package/dist/surfaces/window/window.d.ts +3 -3
  217. package/dist/surfaces/window/window.d.ts.map +1 -1
  218. package/dist/surfaces/window/window.js +15 -13
  219. package/dist/surfaces/window/window.js.map +1 -1
  220. package/dist/syntaxhighlighter-IQDEPFLK-BX_eF8__.js +3777 -0
  221. package/dist/syntaxhighlighter-IQDEPFLK-BX_eF8__.js.map +1 -0
  222. package/dist/tethered.css +1 -0
  223. package/dist/themes/themes/ergo/ergo_theme.js +177 -206
  224. package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
  225. package/dist/tokens/badge/badge.js +9 -9
  226. package/dist/tokens/bubble/bubble.js +8 -8
  227. package/dist/tokens/chip/chip.js +3 -3
  228. package/dist/tooltip.css +1 -1
  229. package/dist/utility_bar.css +1 -1
  230. package/dist/utils/click_away_listener.d.ts +1 -0
  231. package/dist/utils/click_away_listener.d.ts.map +1 -1
  232. package/dist/utils/click_away_listener.js +12 -11
  233. package/dist/utils/click_away_listener.js.map +1 -1
  234. package/dist/utils/dnd/draggable/draggable.js +4 -4
  235. package/dist/utils/dnd/handle.js +8 -8
  236. package/dist/utils/focus_redirect.js +5 -5
  237. package/dist/utils/hooks/make_context_hook.js +4 -4
  238. package/dist/utils/hooks/use_media_query.js +2 -2
  239. package/dist/utils/hooks/use_media_query.js.map +1 -1
  240. package/dist/utils/index.d.ts +6 -5
  241. package/dist/utils/index.d.ts.map +1 -1
  242. package/dist/utils/index.js +26 -23
  243. package/dist/utils/index.js.map +1 -1
  244. package/dist/utils/mouse_leave_region.d.ts +8 -0
  245. package/dist/utils/mouse_leave_region.d.ts.map +1 -0
  246. package/dist/utils/mouse_leave_region.js +26 -0
  247. package/dist/utils/mouse_leave_region.js.map +1 -0
  248. package/dist/utils/types/dimensions.d.ts +11 -1
  249. package/dist/utils/types/dimensions.d.ts.map +1 -1
  250. package/package.json +3 -3
  251. package/src/actions/__docs__/actions.mdx +131 -0
  252. package/src/actions/__docs__/actions.stories.tsx +309 -0
  253. package/src/actions/__docs__/components/gallery.module.css +6 -0
  254. package/src/actions/__docs__/components/gallery.tsx +28 -0
  255. package/src/actions/__docs__/components/showcase.module.css +55 -0
  256. package/src/actions/__docs__/components/showcase.tsx +121 -0
  257. package/src/actions/button/base_button/base_button.tsx +5 -1
  258. package/src/actions/types.ts +6 -0
  259. package/src/inputs/color_input/color_input.tsx +1 -1
  260. package/src/inputs/date_picker/date_picker_input.tsx +1 -1
  261. package/src/inputs/date_picker/date_picker_year_input.tsx +1 -1
  262. package/src/inputs/suggestions/suggestion_list.tsx +1 -1
  263. package/src/layouts/index.ts +7 -5
  264. package/src/layouts/scaffold/scaffold.module.css +5 -0
  265. package/src/layouts/scaffold/scaffold.tsx +60 -0
  266. package/src/layouts/utility_bar/utility_bar.module.css +0 -3
  267. package/src/overlay/frame/frame.module.css +5 -0
  268. package/src/overlay/frame/frame.stories.tsx +1 -1
  269. package/src/overlay/frame/frame.tsx +19 -3
  270. package/src/overlay/index.ts +29 -2
  271. package/src/overlay/menu/menu.tsx +1 -1
  272. package/src/overlay/popper/__stories__/base_args.ts +75 -0
  273. package/src/overlay/popper/__stories__/context_popper.stories.tsx +77 -0
  274. package/src/overlay/popper/__stories__/element_popper.stories.tsx +80 -0
  275. package/src/overlay/popper/__stories__/preview_popper.stories.tsx +73 -0
  276. package/src/overlay/popper/base/base_popper.tsx +55 -0
  277. package/src/overlay/popper/base/dismissal_decorator.tsx +80 -0
  278. package/src/overlay/popper/context_popper.tsx +43 -0
  279. package/src/overlay/popper/element_popper.tsx +42 -0
  280. package/src/overlay/popper/hooks/use_context_trigger.ts +50 -0
  281. package/src/overlay/popper/hooks/use_hover_trigger.ts +24 -0
  282. package/src/overlay/popper/hooks/use_restore_focus.ts +16 -0
  283. package/src/overlay/popper/{popper.stories.tsx → legacy/popper.stories.tsx} +11 -5
  284. package/src/overlay/popper/{popper.tsx → legacy/popper.tsx} +3 -2
  285. package/src/overlay/popper/preview_popper.tsx +54 -0
  286. package/src/overlay/tethered/__stories__/element/element_tethered.stories.tsx +57 -0
  287. package/src/overlay/tethered/__stories__/element/element_tethered_stories.module.css +14 -0
  288. package/src/overlay/tethered/__stories__/shared/base_story_config.ts +52 -0
  289. package/src/overlay/tethered/__stories__/shared/components/sb_point.module.css +20 -0
  290. package/src/overlay/tethered/__stories__/shared/components/sb_point.tsx +34 -0
  291. package/src/overlay/tethered/__stories__/shared/components/sb_reference_points.tsx +54 -0
  292. package/src/overlay/tethered/__stories__/tethered/tethered.stories.tsx +90 -0
  293. package/src/overlay/tethered/__stories__/tethered/tethered_stories.module.css +25 -0
  294. package/src/overlay/tethered/element_tethered.tsx +62 -0
  295. package/src/overlay/tethered/hooks/calculate_position.ts +110 -0
  296. package/src/overlay/tethered/hooks/useTether.ts +85 -0
  297. package/src/overlay/tethered/tethered.module.css +8 -0
  298. package/src/overlay/tethered/tethered.tsx +72 -0
  299. package/src/overlay/tethered/types.ts +2 -0
  300. package/src/stacks/h_stack.stories.tsx +2 -2
  301. package/src/stacks/v_stack.stories.tsx +2 -2
  302. package/src/surfaces/card/card.stories.tsx +64 -0
  303. package/src/surfaces/card/card.tsx +4 -4
  304. package/src/surfaces/card/card_stories.module.css +13 -0
  305. package/src/surfaces/index.ts +2 -0
  306. package/src/surfaces/modal/__stories__/modal.stories.tsx +12 -1
  307. package/src/surfaces/modal/modal.module.css +2 -2
  308. package/src/surfaces/modal/modal.tsx +14 -12
  309. package/src/surfaces/panel/__stories__/panel.stories.tsx +1 -1
  310. package/src/surfaces/panel/v_panel.tsx +8 -53
  311. package/src/surfaces/pop_confirm/pop_confirm.stories.tsx +70 -0
  312. package/src/surfaces/pop_confirm/pop_confirm.tsx +30 -0
  313. package/src/surfaces/popconfirm/pop_confirm.tsx +18 -0
  314. package/src/surfaces/popover/popover.tsx +1 -1
  315. package/src/surfaces/tooltip/tooltip.stories.tsx +54 -0
  316. package/src/surfaces/tooltip/tooltip.tsx +59 -0
  317. package/src/surfaces/window/window.stories.tsx +15 -1
  318. package/src/surfaces/window/window.tsx +16 -12
  319. package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_picker.tsx +7 -9
  320. package/src/themes/themes/ergo/__stories__/material.stories.tsx +2 -6
  321. package/src/themes/themes/ergo/__stories__/sb_materials.module.css +29 -21
  322. package/src/themes/themes/ergo/ergo_theme.css +177 -206
  323. package/src/utils/click_away_listener.tsx +1 -1
  324. package/src/utils/index.ts +7 -5
  325. package/src/utils/mouse_leave_region.tsx +38 -0
  326. package/src/utils/types/dimensions.ts +13 -1
  327. package/tsconfig.json +3 -0
  328. package/dist/overlay/popper/popper.d.ts.map +0 -1
  329. package/dist/overlay/popper/popper.js.map +0 -1
  330. package/dist/overlay/tooltip/tooltip.d.ts +0 -7
  331. package/dist/overlay/tooltip/tooltip.d.ts.map +0 -1
  332. package/dist/overlay/tooltip/tooltip.js +0 -20
  333. package/dist/overlay/tooltip/tooltip.js.map +0 -1
  334. package/dist/panel.module-DwGKncon.js +0 -5
  335. package/dist/panel.module-DwGKncon.js.map +0 -1
  336. package/src/overlay/tooltip/tooltip.stories.tsx +0 -22
  337. package/src/overlay/tooltip/tooltip.tsx +0 -24
  338. /package/dist/{panel.css → h_panel.css} +0 -0
  339. /package/dist/overlay/popper/{popper.d.ts → legacy/popper.d.ts} +0 -0
  340. /package/src/overlay/popper/{popper.module.css → legacy/popper.module.css} +0 -0
  341. /package/src/{overlay → surfaces}/tooltip/tooltip.module.css +0 -0
@@ -0,0 +1,110 @@
1
+ import type { HorizontalTether, VerticalTether } from '../types.js';
2
+ import type { Rectangle } from '../../../utils/index.js';
3
+ import type { Dimensions } from '../../../utils/index.js';
4
+
5
+ export interface CalculateTetheredPositionParams {
6
+ anchor: Rectangle;
7
+ tether: Rectangle;
8
+ direction: 'ltr' | 'rtl';
9
+ verticalAnchor: VerticalTether;
10
+ verticalOrigin: VerticalTether;
11
+ horizontalAnchor: HorizontalTether;
12
+ horizontalOrigin: HorizontalTether;
13
+ verticalOffset: number;
14
+ horizontalOffset: number;
15
+ viewport: Dimensions;
16
+ }
17
+
18
+ export const calculateTetheredPosition = ({
19
+ anchor,
20
+ tether,
21
+ direction,
22
+ verticalAnchor,
23
+ verticalOrigin,
24
+ horizontalAnchor,
25
+ horizontalOrigin,
26
+ verticalOffset,
27
+ horizontalOffset,
28
+ viewport,
29
+ }: CalculateTetheredPositionParams) => {
30
+ const isRtl = direction === 'rtl';
31
+
32
+ let top = anchor.position.y;
33
+ let left = anchor.position.x;
34
+
35
+ // Calculate vertical position
36
+ switch (verticalAnchor) {
37
+ case 'top':
38
+ top += verticalOffset;
39
+ break;
40
+ case 'center':
41
+ top += anchor.dimensions.height / 2;
42
+ break;
43
+ case 'bottom':
44
+ top += anchor.dimensions.height - verticalOffset;
45
+ break;
46
+ }
47
+
48
+ switch (verticalOrigin) {
49
+ case 'top':
50
+ break;
51
+ case 'center':
52
+ top -= tether.dimensions.height / 2;
53
+ break;
54
+ case 'bottom':
55
+ top -= tether.dimensions.height;
56
+ break;
57
+ }
58
+
59
+ // Calculate horizontal position with direction sensitivity
60
+ if (horizontalAnchor === 'start') {
61
+ left += isRtl ? anchor.dimensions.width + horizontalOffset : horizontalOffset;
62
+ } else if (horizontalAnchor === 'center') {
63
+ left += anchor.dimensions.width / 2;
64
+ } else if (horizontalAnchor === 'end') {
65
+ left += isRtl ? -horizontalOffset : anchor.dimensions.width + horizontalOffset;
66
+ }
67
+
68
+ // Adjust the origin based on RTL direction
69
+ let adjustedHorizontalOrigin = horizontalOrigin;
70
+ if (isRtl) {
71
+ if (horizontalOrigin === 'start') {
72
+ adjustedHorizontalOrigin = 'end';
73
+ } else if (horizontalOrigin === 'end') {
74
+ adjustedHorizontalOrigin = 'start';
75
+ }
76
+ }
77
+
78
+ // Apply adjusted origin to the position calculation
79
+ if (adjustedHorizontalOrigin === 'start') {
80
+ // No adjustment needed
81
+ } else if (adjustedHorizontalOrigin === 'center') {
82
+ left -= tether.dimensions.width / 2;
83
+ } else if (adjustedHorizontalOrigin === 'end') {
84
+ left -= tether.dimensions.width;
85
+ }
86
+
87
+ // Ensure the popover stays within the viewport
88
+ // Prevent overflow to the right
89
+ if (left + tether.dimensions.width > viewport.width) {
90
+ left = viewport.width - tether.dimensions.width;
91
+ }
92
+
93
+ // Prevent overflow to the left
94
+ if (left < 0) {
95
+ left = 0;
96
+ }
97
+
98
+ // Prevent overflow to the bottom
99
+ // FIXME: doesn't account for padding.
100
+ if (top + tether.dimensions.height > viewport.height) {
101
+ top = viewport.height - tether.dimensions.height;
102
+ }
103
+
104
+ // Prevent overflow to the top
105
+ if (top < 0) {
106
+ top = 0;
107
+ }
108
+
109
+ return { top, left };
110
+ };
@@ -0,0 +1,85 @@
1
+ import { useCallback, useLayoutEffect, useRef, useState } from 'react';
2
+ import type { HorizontalTether, VerticalTether } from '../types.js';
3
+ import { type Rectangle } from '../../../utils/index.js';
4
+ import { calculateTetheredPosition } from './calculate_position.js';
5
+
6
+ export interface UseTetherParams {
7
+ anchor: Rectangle | null;
8
+ verticalAnchor?: VerticalTether;
9
+ verticalOrigin?: VerticalTether;
10
+ horizontalOrigin?: HorizontalTether;
11
+ horizontalAnchor?: HorizontalTether;
12
+ verticalOffset?: number;
13
+ horizontalOffset?: number;
14
+ }
15
+
16
+ export function useTether({
17
+ anchor,
18
+ verticalAnchor = 'bottom',
19
+ verticalOrigin = 'top',
20
+ horizontalAnchor = 'start',
21
+ horizontalOrigin = 'start',
22
+ verticalOffset = 0,
23
+ horizontalOffset = 0,
24
+ }: UseTetherParams) {
25
+ const [position, setPosition] = useState({ top: 0, left: 0 });
26
+ const tetherRef = useRef<HTMLDivElement>(null);
27
+
28
+ const getPosition = useCallback(() => {
29
+ if (!anchor || !tetherRef.current) return;
30
+
31
+ const tether = tetherRef.current.getBoundingClientRect();
32
+ const computedStyle = getComputedStyle(tetherRef.current);
33
+
34
+ return calculateTetheredPosition({
35
+ anchor: anchor,
36
+ tether: {
37
+ dimensions: {
38
+ width: tether.width,
39
+ height: tether.height,
40
+ },
41
+ position: {
42
+ x: tether.left,
43
+ y: tether.top,
44
+ },
45
+ },
46
+ direction: computedStyle.direction as 'ltr' | 'rtl',
47
+ verticalAnchor: verticalAnchor,
48
+ verticalOrigin: verticalOrigin,
49
+ horizontalAnchor: horizontalAnchor,
50
+ horizontalOrigin: horizontalOrigin,
51
+ verticalOffset: verticalOffset,
52
+ horizontalOffset: horizontalOffset,
53
+ viewport: {
54
+ width: window.innerWidth,
55
+ height: window.innerHeight,
56
+ },
57
+ });
58
+ }, [
59
+ anchor,
60
+ verticalAnchor,
61
+ verticalOrigin,
62
+ horizontalAnchor,
63
+ horizontalOrigin,
64
+ verticalOffset,
65
+ horizontalOffset,
66
+ ]);
67
+
68
+ // Update the position when the window is resized
69
+ useLayoutEffect(() => {
70
+ const update = () => {
71
+ const newPosition = getPosition();
72
+ if (!newPosition) return;
73
+ if (position.top !== newPosition.top || position.left !== newPosition.left) {
74
+ setPosition(newPosition);
75
+ }
76
+ };
77
+ update();
78
+ window.addEventListener('resize', update);
79
+ return () => {
80
+ window.removeEventListener('resize', update);
81
+ };
82
+ });
83
+
84
+ return { position, tetherRef };
85
+ }
@@ -0,0 +1,8 @@
1
+ .tethered {
2
+ display: inline-block;
3
+ position: absolute;
4
+ width: auto;
5
+ height: auto;
6
+ left: var(--tethered-left, 0);
7
+ top: var(--tethered-top, 0);
8
+ }
@@ -0,0 +1,72 @@
1
+ import { forwardRef, type PropsWithChildren } from 'react';
2
+ import type { HorizontalTether, VerticalTether } from './types.js';
3
+ import { ZStack, type ZStackProps } from '../../stacks/index.js';
4
+ import { useForkRef, type Rectangle } from '../../utils/index.js';
5
+ import { useTether } from './hooks/useTether.js';
6
+ import { clsx } from 'clsx';
7
+ import { Portal } from '../portal/portal.js';
8
+
9
+ // Styles
10
+ import styles from './tethered.module.css';
11
+
12
+ export interface BaseTetheredOwnProps {
13
+ verticalAnchor?: VerticalTether;
14
+ verticalOrigin?: VerticalTether;
15
+ horizontalOrigin?: HorizontalTether;
16
+ horizontalAnchor?: HorizontalTether;
17
+ verticalOffset?: number;
18
+ horizontalOffset?: number;
19
+ }
20
+
21
+ export interface TetheredOwnProp extends BaseTetheredOwnProps {
22
+ anchor: Rectangle | null;
23
+ }
24
+ export interface TetheredProps extends TetheredOwnProp, ZStackProps {}
25
+
26
+ export const Tethered = forwardRef<HTMLElement, PropsWithChildren<TetheredProps>>(
27
+ function Tethered(
28
+ {
29
+ anchor,
30
+ verticalAnchor = 'bottom',
31
+ verticalOrigin = 'top',
32
+ horizontalAnchor = 'start',
33
+ horizontalOrigin = 'start',
34
+ verticalOffset = 0,
35
+ horizontalOffset = 0,
36
+ children,
37
+ style,
38
+ className,
39
+ ...rest
40
+ },
41
+ ref
42
+ ) {
43
+ const { position, tetherRef } = useTether({
44
+ anchor,
45
+ verticalAnchor,
46
+ verticalOrigin,
47
+ horizontalAnchor,
48
+ horizontalOrigin,
49
+ verticalOffset,
50
+ horizontalOffset,
51
+ });
52
+ const forkedRef = useForkRef(ref, tetherRef);
53
+
54
+ const cssVariables = {
55
+ '--tethered-top': `${position.top}px`,
56
+ '--tethered-left': `${position.left}px`,
57
+ };
58
+
59
+ return (
60
+ <Portal>
61
+ <ZStack
62
+ ref={forkedRef}
63
+ className={clsx(styles.tethered, className)}
64
+ style={{ position: 'absolute', ...cssVariables, ...style }}
65
+ {...rest}
66
+ >
67
+ {children}
68
+ </ZStack>
69
+ </Portal>
70
+ );
71
+ }
72
+ );
@@ -0,0 +1,2 @@
1
+ export type VerticalTether = 'top' | 'center' | 'bottom';
2
+ export type HorizontalTether = 'start' | 'center' | 'end';
@@ -80,7 +80,7 @@ const meta: Meta<HStackProps> = {
80
80
 
81
81
  export default meta;
82
82
 
83
- export function HStack(props: HStackProps) {
83
+ export function SB_HStack(props: HStackProps) {
84
84
  return (
85
85
  <StyleBox border="1px dashed #ccc" backgroundColor="white">
86
86
  <HStackComponent {...props}>
@@ -99,7 +99,7 @@ export function HStack(props: HStackProps) {
99
99
  );
100
100
  }
101
101
 
102
- HStack.storyName = 'HStack';
102
+ SB_HStack.storyName = 'HStack';
103
103
 
104
104
  export function ManyChildren(props: HStackProps) {
105
105
  return (
@@ -80,7 +80,7 @@ const meta: Meta<VStackProps> = {
80
80
 
81
81
  export default meta;
82
82
 
83
- export function VStack(props: VStackProps) {
83
+ export function SBVStack(props: VStackProps) {
84
84
  return (
85
85
  <StyleBox
86
86
  borderLeft="1px dashed #ccc"
@@ -102,7 +102,7 @@ export function VStack(props: VStackProps) {
102
102
  );
103
103
  }
104
104
 
105
- VStack.storyName = 'VStack';
105
+ SBVStack.storyName = 'VStack';
106
106
 
107
107
  export function Padding() {
108
108
  return (
@@ -0,0 +1,64 @@
1
+ import { BugIcon } from '@tcn/icons/bug_icon.js';
2
+ import { GridOneIcon } from '@tcn/icons/grid_one_icon.js';
3
+ import { Header } from '../../layouts/header/header.js';
4
+ import { VBody } from '../../layouts/body/v_body.js';
5
+ import { UtilityBar } from '../../layouts/utility_bar/utility_bar.js';
6
+ import { Box, Spacer } from '../../stacks/index.js';
7
+ import { Title } from '../../typography/title/title.js';
8
+ import { SlimButton } from '../../actions/index.js';
9
+ import { Card } from './card.js';
10
+
11
+ // Styles
12
+ import styles from './card_stories.module.css';
13
+
14
+ export default {
15
+ title: 'Surfaces/Card',
16
+ component: Card,
17
+ tags: ['autodocs'],
18
+ };
19
+
20
+ export const Default = () => {
21
+ return (
22
+ <div className={styles['stories-container']}>
23
+ <Card maxHeight="400px">
24
+ <Header>
25
+ <Title>Card Header</Title>
26
+ <Spacer />
27
+ <SlimButton hierarchy="tertiary">
28
+ <GridOneIcon />
29
+ </SlimButton>
30
+ <SlimButton hierarchy="tertiary">
31
+ <GridOneIcon />
32
+ </SlimButton>
33
+ </Header>
34
+ <UtilityBar>
35
+ <Title>Utility Bar</Title>
36
+ <Spacer />
37
+ <SlimButton hierarchy="tertiary">
38
+ <BugIcon />
39
+ </SlimButton>
40
+ <SlimButton hierarchy="tertiary">
41
+ <BugIcon />
42
+ </SlimButton>
43
+ <SlimButton size="md" hierarchy="tertiary">
44
+ <BugIcon />
45
+ </SlimButton>
46
+ <SlimButton hierarchy="tertiary">
47
+ <BugIcon />
48
+ </SlimButton>
49
+ </UtilityBar>
50
+
51
+ <VBody>
52
+ <Box className={styles['content-box']} />
53
+ </VBody>
54
+ {/* Cards typically do not have a footer */}
55
+ {/* <Footer>
56
+ <Title>Footer</Title>
57
+ <Spacer />
58
+ <Button hierarchy="secondary">Secondary</Button>
59
+ <Button hierarchy="primary">Primary</Button>
60
+ </Footer> */}
61
+ </Card>
62
+ </div>
63
+ );
64
+ };
@@ -1,8 +1,8 @@
1
- import { VStack, type VStackProps } from '../../stacks/v_stack.js';
2
1
  import { clsx } from 'clsx';
3
2
  import React from 'react';
3
+ import { Scaffold, type ScaffoldProps } from '../../layouts/scaffold/scaffold.js';
4
4
 
5
- export interface CardProps extends Omit<VStackProps, 'as' | 'children'> {
5
+ export interface CardProps extends Omit<ScaffoldProps, 'as' | 'children'> {
6
6
  children?: React.ReactNode;
7
7
  }
8
8
 
@@ -11,8 +11,8 @@ export const Card = React.forwardRef<HTMLElement, CardProps>(function Card(
11
11
  ref
12
12
  ) {
13
13
  return (
14
- <VStack ref={ref} as="section" className={clsx(className, 'tcn-card')} {...props}>
14
+ <Scaffold ref={ref} className={clsx(className, 'tcn-surface', 'tcn-card')} {...props}>
15
15
  {children}
16
- </VStack>
16
+ </Scaffold>
17
17
  );
18
18
  });
@@ -0,0 +1,13 @@
1
+ .content-box {
2
+ background: rgba(0, 128, 0, 0.5);
3
+ min-height: 200px;
4
+ width: 100%;
5
+ }
6
+
7
+ .stories-container {
8
+ width: 100%;
9
+ height: 100%;
10
+ padding: 16px;
11
+ background-color: #ccc;
12
+ overflow: auto;
13
+ }
@@ -12,3 +12,5 @@ export * from './drawers/drawer_start/drawer_start.js';
12
12
  export * from './drawers/drawer_end/drawer_end.js';
13
13
  export { Window, type WindowProps } from './window/window.js';
14
14
  export { Modal, type ModalProps } from './modal/modal.js';
15
+ export { Tooltip, type TooltipProps } from './tooltip/tooltip.js';
16
+ export { PopConfirm, type PopConfirmProps } from './pop_confirm/pop_confirm.js';
@@ -1,11 +1,12 @@
1
1
  import { useState } from 'react';
2
2
  import { Button, SlimButton } from '../../../actions/index.js';
3
- import { Footer, Header, VBody } from '../../../layouts/index.js';
3
+ import { Footer, Header, UtilityBar, VBody } from '../../../layouts/index.js';
4
4
  import { ZStack } from '../../../stacks/z_stack.js';
5
5
  import { BodyText, Title } from '../../../typography/index.js';
6
6
  import { Modal } from '../modal.js';
7
7
  import { Spacer } from '../../../stacks/index.js';
8
8
  import { CrossIcon } from '@tcn/icons/cross_icon.js';
9
+ import { BugIcon } from '@tcn/icons/bug_icon.js';
9
10
 
10
11
  export default {
11
12
  title: 'Surfaces/Modal',
@@ -32,6 +33,16 @@ export const ModalStory = () => {
32
33
  <CrossIcon />
33
34
  </SlimButton>
34
35
  </Header>
36
+ <UtilityBar>
37
+ <Title>Utility Bar</Title>
38
+ <Spacer />
39
+ <SlimButton hierarchy="tertiary">
40
+ <BugIcon />
41
+ </SlimButton>
42
+ <SlimButton hierarchy="tertiary">
43
+ <BugIcon />
44
+ </SlimButton>
45
+ </UtilityBar>
35
46
  <VBody>
36
47
  <BodyText>This is a modal</BodyText>
37
48
  </VBody>
@@ -1,4 +1,4 @@
1
1
  .modal {
2
- width: 100%;
3
- height: 100%;
2
+ width: auto;
3
+ height: auto;
4
4
  }
@@ -1,25 +1,27 @@
1
- import { VStack, type VStackProps } from '../../stacks/v_stack.js';
2
1
  import { clsx } from 'clsx';
3
2
  import React from 'react';
4
- import styles from './modal.module.css';
5
3
  import { Frame, type FrameOwnProps } from '../../overlay/frame/frame.js';
4
+ import { Scaffold, type ScaffoldProps } from '../../layouts/scaffold/scaffold.js';
5
+
6
+ // Styles
7
+ import styles from './modal.module.css';
6
8
 
7
- export type ModalProps = FrameOwnProps & Omit<VStackProps<HTMLDialogElement>, 'as'>;
9
+ export type ModalProps = FrameOwnProps & ScaffoldProps;
8
10
 
9
- export const Modal = React.forwardRef<HTMLDialogElement, ModalProps>(function Modal(
11
+ export const Modal = React.forwardRef<HTMLElement, ModalProps>(function Modal(
10
12
  { children, className, isOpen, draggable = false, veil = true, ...props }: ModalProps,
11
13
  ref
12
14
  ) {
13
15
  return (
14
- <Frame isOpen={isOpen} draggable={draggable} veil={veil}>
15
- <VStack
16
- ref={ref}
17
- className={clsx(styles['modal'], 'tcn-modal', className)}
18
- as="dialog"
19
- {...props}
20
- >
16
+ <Frame
17
+ isOpen={isOpen}
18
+ draggable={draggable}
19
+ veil={veil}
20
+ className={clsx(styles['modal'], 'tcn-surface', 'tcn-modal', className)}
21
+ >
22
+ <Scaffold ref={ref} {...props}>
21
23
  {children}
22
- </VStack>
24
+ </Scaffold>
23
25
  </Frame>
24
26
  );
25
27
  });
@@ -24,7 +24,7 @@ export const Default = () => {
24
24
  <div className={styles['stories-container']}>
25
25
  <VPanel maxHeight="600px">
26
26
  <Header>
27
- <Title>Panel Primary Header</Title>
27
+ <Title emphasis="strong">Panel Primary Header</Title>
28
28
  <Spacer />
29
29
  <SlimButton hierarchy="tertiary">
30
30
  <GridOneIcon />
@@ -1,65 +1,20 @@
1
1
  import React from 'react';
2
- import { clsx } from 'clsx';
3
- import { Box, type BoxProps } from '../../stacks/box/box.js';
4
- import type { Alignment } from '../../stacks/types/alignment.js';
5
- import { VStack } from '../../stacks/v_stack.js';
6
- // Styles
7
- import styles from './panel.module.css';
2
+ import { Scaffold, type ScaffoldProps } from '../../layouts/scaffold/scaffold.js';
3
+ import clsx from 'clsx';
8
4
 
9
- export interface VPanelProps extends Omit<BoxProps, 'as'> {
10
- vAlign?: Alignment;
11
- hAlign?: Alignment;
12
- }
5
+ export type VPanelProps = ScaffoldProps;
13
6
 
14
7
  export const VPanel = React.forwardRef<HTMLElement, VPanelProps>(function VPanel(
15
- {
16
- children,
17
- width,
18
- height = '100%',
19
- minWidth,
20
- maxWidth,
21
- minHeight,
22
- maxHeight,
23
- hAlign,
24
- vAlign = 'start',
25
- className,
26
- ...props
27
- }: VPanelProps,
8
+ { children, className, ...props }: VPanelProps,
28
9
  ref
29
10
  ) {
30
11
  return (
31
- <Box
12
+ <Scaffold
32
13
  ref={ref}
33
- width={width}
34
- height={height}
35
- minWidth={minWidth}
36
- maxWidth={maxWidth}
37
- minHeight={minHeight}
38
- maxHeight={maxHeight}
39
- data-h-alignment={hAlign}
40
- data-v-alignment={vAlign}
41
- className={clsx(className, 'panel', 'tcn-panel', 'tcn-v-panel')}
14
+ className={clsx('tcn-surface', 'tcn-panel', 'tcn-v-panel', className)}
42
15
  {...props}
43
16
  >
44
- <VStack
45
- as="section"
46
- minWidth={minWidth}
47
- maxWidth={maxWidth}
48
- minHeight={minHeight}
49
- maxHeight={maxHeight}
50
- hAlign={hAlign}
51
- vAlign={vAlign}
52
- ref={ref}
53
- className={clsx(
54
- styles['panel-stack'],
55
- className,
56
- 'panel-stack',
57
- 'tcn-panel-stack'
58
- )}
59
- zIndex={0}
60
- >
61
- {children}
62
- </VStack>
63
- </Box>
17
+ {children}
18
+ </Scaffold>
64
19
  );
65
20
  });
@@ -0,0 +1,70 @@
1
+ import { useRef, useState } from 'react';
2
+ import { Button } from '../../actions/index.js';
3
+ import { Footer, Header, VBody } from '../../layouts/index.js';
4
+ import { HStack } from '../../stacks/h_stack.js';
5
+ import { PopConfirm as PopConfirmComponent } from './pop_confirm.js';
6
+ import { BodyText, Title } from '../../typography/index.js';
7
+ import { VStack } from '../../stacks/v_stack.js';
8
+ import { Spacer } from '../../stacks/spacer.js';
9
+
10
+ export default {
11
+ title: 'Surfaces/Pop Confirm',
12
+ component: PopConfirmComponent,
13
+ tags: ['autodocs'],
14
+ parameters: {
15
+ docs: {
16
+ description: {
17
+ component: 'A tooltip component that displays a tooltip when hovered.',
18
+ },
19
+ },
20
+ },
21
+ };
22
+
23
+ export const DefaultPopConfirm = () => {
24
+ const anchorRef = useRef<HTMLButtonElement>(null);
25
+ const [open, setOpen] = useState(false);
26
+
27
+ const cancel = () => {
28
+ setOpen(false);
29
+ };
30
+
31
+ const confirm = () => {
32
+ setOpen(false);
33
+ };
34
+
35
+ const prompt = () => {
36
+ setOpen(true);
37
+ };
38
+
39
+ return (
40
+ <VStack hAlign="center" vAlign="center" height="100%" width="100%">
41
+ <HStack hAlign="center" vAlign="center">
42
+ <Button ref={anchorRef} onClick={prompt}>
43
+ Click to Confirm
44
+ </Button>
45
+ <PopConfirmComponent
46
+ height={'200px'}
47
+ open={open}
48
+ onDismissal={cancel}
49
+ anchorElement={anchorRef}
50
+ >
51
+ <Header>
52
+ <Title>Confirmation Title</Title>
53
+ </Header>
54
+ <VBody>
55
+ <BodyText>Are you sure you want to confirm this action?</BodyText>
56
+ </VBody>
57
+ <Footer>
58
+ <Spacer />
59
+ <Button hierarchy="secondary" onClick={cancel}>
60
+ Cancel
61
+ </Button>
62
+ <Button hierarchy="primary" onClick={confirm}>
63
+ Confirm
64
+ </Button>
65
+ </Footer>
66
+ </PopConfirmComponent>
67
+ </HStack>
68
+ </VStack>
69
+ );
70
+ };