@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
@@ -0,0 +1,111 @@
1
+ import { jsxs as h, Fragment as v, jsx as e } from "react/jsx-runtime";
2
+ import g, { useLayoutEffect as F } from "react";
3
+ import { NotebookIcon as L } from "@tcn/icons/notebook_icon.js";
4
+ import { Input as R } from "../input/input.js";
5
+ import "../../actions/button/base_button/base_button.js";
6
+ import "../../actions/button/button_group/button_group.js";
7
+ import "../../actions/button/slim_button/slim_button.js";
8
+ import { Button as j } from "../../actions/button/button/button.js";
9
+ import "../../actions/button/select_group/select_group.js";
10
+ import "../../actions/button/select_group/single_select_group.js";
11
+ import "../../actions/toggle/toggle.js";
12
+ import { InputGroup as y } from "../input_group/input_group.js";
13
+ import z from "clsx";
14
+ import { usePhoneContext as V } from "./phone_number_context.js";
15
+ import { PhoneNumberCountrySelectAdapter as _ } from "./phone_number_country_select_adapter.js";
16
+ import { SuggestionList as q } from "../suggestions/suggestion_list.js";
17
+ function eo({
18
+ disabled: n,
19
+ countries: k,
20
+ name: B,
21
+ "aria-label": S,
22
+ autoFocus: P,
23
+ placeholder: b
24
+ }) {
25
+ const u = g.useRef(null), [i, t] = g.useState(null), l = i != null, {
26
+ phoneBook: s,
27
+ setValue: r,
28
+ setCountry: d,
29
+ ariaPhoneBookButtonLabel: I,
30
+ sipAddress: p,
31
+ setSipAddress: m,
32
+ focusNumberInput: c,
33
+ setFocusNumberInput: a
34
+ } = V(), C = s.length > 0;
35
+ function N(o) {
36
+ t(l ? null : o.currentTarget);
37
+ }
38
+ function f() {
39
+ t(null);
40
+ }
41
+ function x(o) {
42
+ f(), a(!0), r(o);
43
+ }
44
+ const A = k?.map((o) => ({
45
+ value: o,
46
+ label: o
47
+ })) || [];
48
+ function E(o) {
49
+ o !== "SIP" && (m(p), a(!0), r(""), d(o || "US"));
50
+ }
51
+ function O(o) {
52
+ m(o), r(`sip:${o}`);
53
+ }
54
+ return F(() => {
55
+ const o = u.current;
56
+ o == null || !c || requestAnimationFrame(() => {
57
+ o.value.length > 0 ? o.select() : o.focus();
58
+ });
59
+ }, [c]), /* @__PURE__ */ h(v, { children: [
60
+ /* @__PURE__ */ h(y, { children: [
61
+ /* @__PURE__ */ e(
62
+ _,
63
+ {
64
+ value: "SIP",
65
+ onChange: E,
66
+ options: A,
67
+ disabled: n
68
+ }
69
+ ),
70
+ /* @__PURE__ */ e(
71
+ R,
72
+ {
73
+ ref: u,
74
+ value: p,
75
+ disabled: n,
76
+ onChange: O,
77
+ name: B,
78
+ "aria-label": S,
79
+ autoFocus: P,
80
+ placeholder: b
81
+ }
82
+ ),
83
+ C && /* @__PURE__ */ e(
84
+ j,
85
+ {
86
+ disabled: n,
87
+ className: z("tcn-input-group-slot", "tcn-phone-number-phone-book"),
88
+ "aria-label": I,
89
+ onClick: N,
90
+ size: "md",
91
+ children: /* @__PURE__ */ e(L, { size: "md" })
92
+ }
93
+ )
94
+ ] }),
95
+ /* @__PURE__ */ e(
96
+ q,
97
+ {
98
+ open: l,
99
+ anchorElement: i,
100
+ onOptionSelect: x,
101
+ onClose: f,
102
+ noSuggestionMessage: "No phone numbers found",
103
+ children: s
104
+ }
105
+ )
106
+ ] });
107
+ }
108
+ export {
109
+ eo as SipInput
110
+ };
111
+ //# sourceMappingURL=sip_input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sip_input.js","sources":["../../../src/inputs/phone_number_input/sip_input.tsx"],"sourcesContent":["import React, { useLayoutEffect } from 'react';\nimport { NotebookIcon } from '@tcn/icons/notebook_icon.js';\nimport { Input } from '../input/input.js';\nimport { Button } from '../../actions/index.js';\nimport { InputGroup } from '../input_group/input_group.js';\nimport clsx from 'clsx';\nimport { usePhoneContext } from './phone_number_context.js';\nimport type { CountryCode } from 'libphonenumber-js';\nimport {\n PhoneNumberCountrySelectAdapter,\n type CountryOption,\n} from './phone_number_country_select_adapter.js';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\n\nexport interface SipInputProps {\n onChange: (value: string) => void;\n countries?: CountryCode[];\n disabled?: boolean;\n name?: string;\n 'aria-label'?: string;\n autoFocus?: boolean;\n placeholder?: string;\n}\n\nexport function SipInput({\n disabled,\n countries,\n name,\n 'aria-label': ariaLabel,\n autoFocus,\n placeholder,\n}: SipInputProps) {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [phoneBookElement, setPhoneBookElement] =\n React.useState<HTMLButtonElement | null>(null);\n const isPhoneBookOpen = phoneBookElement != null;\n\n const {\n phoneBook: phoneBookOptions,\n setValue,\n setCountry,\n ariaPhoneBookButtonLabel,\n sipAddress,\n setSipAddress,\n focusNumberInput,\n setFocusNumberInput,\n } = usePhoneContext();\n\n const showPhoneBook = phoneBookOptions.length > 0;\n\n function togglePhoneBook(e: React.MouseEvent<HTMLButtonElement>) {\n if (isPhoneBookOpen) {\n setPhoneBookElement(null);\n } else {\n setPhoneBookElement(e.currentTarget);\n }\n }\n\n function closePhoneBook() {\n setPhoneBookElement(null);\n }\n\n function handlePhoneBookOptionSelect(value: string) {\n closePhoneBook();\n setFocusNumberInput(true);\n setValue(value);\n }\n\n const options: CountryOption[] =\n countries?.map(country => ({\n value: country,\n label: country,\n })) || [];\n\n function selectCountry(countryCode?: string) {\n if (countryCode !== 'SIP') {\n setSipAddress(sipAddress);\n setFocusNumberInput(true);\n setValue('');\n setCountry((countryCode as CountryCode) || 'US');\n }\n }\n\n function updateSipValue(value: string) {\n setSipAddress(value);\n setValue(`sip:${value}`);\n }\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n\n if (input == null || !focusNumberInput) {\n return;\n }\n\n requestAnimationFrame(() => {\n if (input.value.length > 0) {\n input.select();\n } else {\n input.focus();\n }\n });\n }, [focusNumberInput]);\n\n return (\n <>\n <InputGroup>\n <PhoneNumberCountrySelectAdapter\n value=\"SIP\"\n onChange={selectCountry}\n options={options}\n disabled={disabled}\n />\n <Input\n ref={inputRef}\n value={sipAddress}\n disabled={disabled}\n onChange={updateSipValue}\n name={name}\n aria-label={ariaLabel}\n autoFocus={autoFocus}\n placeholder={placeholder}\n />\n {showPhoneBook && (\n <Button\n disabled={disabled}\n className={clsx('tcn-input-group-slot', 'tcn-phone-number-phone-book')}\n aria-label={ariaPhoneBookButtonLabel}\n onClick={togglePhoneBook}\n size=\"md\"\n >\n <NotebookIcon size=\"md\" />\n </Button>\n )}\n </InputGroup>\n <SuggestionList\n open={isPhoneBookOpen}\n anchorElement={phoneBookElement}\n onOptionSelect={handlePhoneBookOptionSelect}\n onClose={closePhoneBook}\n noSuggestionMessage=\"No phone numbers found\"\n >\n {phoneBookOptions}\n </SuggestionList>\n </>\n );\n}\n"],"names":["SipInput","disabled","countries","name","ariaLabel","autoFocus","placeholder","inputRef","React","phoneBookElement","setPhoneBookElement","isPhoneBookOpen","phoneBookOptions","setValue","setCountry","ariaPhoneBookButtonLabel","sipAddress","setSipAddress","focusNumberInput","setFocusNumberInput","usePhoneContext","showPhoneBook","togglePhoneBook","e","closePhoneBook","handlePhoneBookOptionSelect","value","options","country","selectCountry","countryCode","updateSipValue","useLayoutEffect","input","jsxs","Fragment","InputGroup","jsx","PhoneNumberCountrySelectAdapter","Input","Button","clsx","NotebookIcon","SuggestionList"],"mappings":";;;;;;;;;;;;;;;;AAwBO,SAASA,GAAS;AAAA,EACvB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAcC;AAAA,EACd,WAAAC;AAAA,EACA,aAAAC;AACF,GAAkB;AAChB,QAAMC,IAAWC,EAAM,OAAyB,IAAI,GAC9C,CAACC,GAAkBC,CAAmB,IAC1CF,EAAM,SAAmC,IAAI,GACzCG,IAAkBF,KAAoB,MAEtC;AAAA,IACJ,WAAWG;AAAA,IACX,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,YAAAC;AAAA,IACA,eAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,qBAAAC;AAAA,EAAA,IACEC,EAAA,GAEEC,IAAgBT,EAAiB,SAAS;AAEhD,WAASU,EAAgBC,GAAwC;AAC/D,IACEb,EADEC,IACkB,OAEAY,EAAE,aAFE;AAAA,EAI5B;AAEA,WAASC,IAAiB;AACxB,IAAAd,EAAoB,IAAI;AAAA,EAC1B;AAEA,WAASe,EAA4BC,GAAe;AAClD,IAAAF,EAAA,GACAL,EAAoB,EAAI,GACxBN,EAASa,CAAK;AAAA,EAChB;AAEA,QAAMC,IACJzB,GAAW,IAAI,CAAA0B,OAAY;AAAA,IACzB,OAAOA;AAAA,IACP,OAAOA;AAAA,EAAA,EACP,KAAK,CAAA;AAET,WAASC,EAAcC,GAAsB;AAC3C,IAAIA,MAAgB,UAClBb,EAAcD,CAAU,GACxBG,EAAoB,EAAI,GACxBN,EAAS,EAAE,GACXC,EAAYgB,KAA+B,IAAI;AAAA,EAEnD;AAEA,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AA,EACH,GACF;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/inputs/select/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAOlE,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;IAC5D,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAC/E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,oGA2IjB,CAAC"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/inputs/select/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAOlE,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;IAC5D,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAC/E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,oGA0IjB,CAAC"}
@@ -77,7 +77,7 @@ const he = F.forwardRef(function({
77
77
  W,
78
78
  {
79
79
  ref: B,
80
- className: L(T, "tcn-select", O.select),
80
+ className: L(T, "tcn-select", "tcn-control", O.select),
81
81
  width: "100%",
82
82
  ...D,
83
83
  hAlign: "start",
@@ -89,9 +89,10 @@ const he = F.forwardRef(function({
89
89
  children: /* @__PURE__ */ u("span", { className: L(O.selectedLabel, "tcn-select-selected-label"), children: k })
90
90
  }
91
91
  ),
92
- y && /* @__PURE__ */ u(
92
+ /* @__PURE__ */ u(
93
93
  Q,
94
94
  {
95
+ open: y,
95
96
  anchorElement: q,
96
97
  onClose: N,
97
98
  value: "",
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sources":["../../../src/inputs/select/select.tsx"],"sourcesContent":["import { useForkRef } from '../../utils/index.js';\nimport { clsx } from 'clsx';\nimport React, { useRef, useState } from 'react';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\nimport { OptionProps } from '../options/option.js';\nimport { Button, type ButtonProps } from '../../actions/index.js';\nimport styles from './select.module.css';\n\nfunction findOptionFromValue(options: React.ReactElement<OptionProps>[], value: string) {\n return options.find(option => option.props.value === value);\n}\n\nexport interface SelectProps\n extends Omit<ButtonProps, 'children' | 'onChange' | 'value'> {\n children?: React.ReactElement<OptionProps>[] | React.ReactElement<OptionProps>;\n onChange?: (value: string) => void;\n value?: string | null;\n placeholder?: string;\n noOptionMatchedMessage?: React.ReactNode;\n trimCustomInput?: boolean;\n}\n\nexport const Select = React.forwardRef(function Select(\n {\n children = [],\n onKeyDown,\n onKeyUp,\n value,\n placeholder = '-- Select --',\n noOptionMatchedMessage,\n trimCustomInput = false,\n className,\n onMouseDown,\n onMouseUp,\n onChange,\n ...props\n }: SelectProps,\n ref: React.Ref<HTMLButtonElement>\n) {\n const safeChildren = React.Children.toArray(\n children\n ) as React.ReactElement<OptionProps>[];\n const keyPressedDownRef = useRef('');\n const isAlreadyFocusedRef = useRef(false);\n const isClosingRef = useRef(false);\n const [anchorElement, setAnchorElement] = useState<HTMLButtonElement | null>(null);\n const internalButtonRef = useRef<HTMLButtonElement | null>(null);\n const [isSuggestionsOpen, setIsSuggestionsOpen] = useState(false);\n const forkedRef = useForkRef(ref, internalButtonRef);\n const selectedOption = findOptionFromValue(safeChildren, value || '');\n const selectedLabel =\n selectedOption == null ? placeholder || '' : selectedOption.props.label;\n\n function openSuggestions() {\n setIsSuggestionsOpen(true);\n }\n\n function closeSuggestions() {\n setIsSuggestionsOpen(false);\n }\n\n function handleClose() {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleSelection(value: string, _: string | undefined, isSuggestion: boolean) {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n if (isSuggestion) {\n onChange && onChange(value);\n }\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLButtonElement>) {\n const key = event.key;\n keyPressedDownRef.current = key;\n onKeyDown && onKeyDown(event);\n }\n\n function handleKeyUp(event: React.KeyboardEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n const isSameKey = (keyPressedDownRef.current = event.key);\n\n keyPressedDownRef.current = '';\n const key = event.key;\n\n if (isSameKey && (key === 'Enter' || key === ' ')) {\n if (isSuggestionsOpen) {\n closeSuggestions();\n } else {\n openSuggestions();\n }\n }\n\n onKeyUp && onKeyUp(event);\n }\n\n function handlMouseDown(event: React.MouseEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n isAlreadyFocusedRef.current = document.activeElement === event.currentTarget;\n onMouseDown && onMouseDown(event);\n }\n\n function handleMouseUp(event: React.MouseEvent<HTMLButtonElement>) {\n if (isClosingRef.current) {\n isClosingRef.current = false;\n closeSuggestions();\n }\n\n openSuggestions();\n onMouseUp && onMouseUp(event);\n }\n\n return (\n <>\n <Button\n ref={forkedRef}\n className={clsx(className, 'tcn-select', styles.select)}\n width=\"100%\"\n {...props}\n hAlign=\"start\"\n value={selectedLabel}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onMouseDown={handlMouseDown}\n onMouseUp={handleMouseUp}\n >\n <span className={clsx(styles.selectedLabel, 'tcn-select-selected-label')}>\n {selectedLabel}\n </span>\n </Button>\n {isSuggestionsOpen && (\n <SuggestionList\n anchorElement={anchorElement}\n onClose={handleClose}\n value={''}\n scrollToValue={value || ''}\n trimCustomInput={trimCustomInput}\n onOptionSelect={handleSelection}\n noSuggestionMessage={noOptionMatchedMessage}\n >\n {children}\n </SuggestionList>\n )}\n </>\n );\n});\n"],"names":["findOptionFromValue","options","value","option","Select","React","children","onKeyDown","onKeyUp","placeholder","noOptionMatchedMessage","trimCustomInput","className","onMouseDown","onMouseUp","onChange","props","ref","safeChildren","keyPressedDownRef","useRef","isAlreadyFocusedRef","isClosingRef","anchorElement","setAnchorElement","useState","internalButtonRef","isSuggestionsOpen","setIsSuggestionsOpen","forkedRef","useForkRef","selectedOption","selectedLabel","openSuggestions","closeSuggestions","handleClose","button","handleSelection","_","isSuggestion","handleKeyDown","event","key","handleKeyUp","isSameKey","handlMouseDown","handleMouseUp","jsxs","Fragment","jsx","Button","clsx","styles","SuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;AAQA,SAASA,EAAoBC,GAA4CC,GAAe;AACtF,SAAOD,EAAQ,KAAK,CAAAE,MAAUA,EAAO,MAAM,UAAUD,CAAK;AAC5D;AAYO,MAAME,KAASC,EAAM,WAAW,SACrC;AAAA,EACE,UAAAC,IAAW,CAAA;AAAA,EACX,WAA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A,IAAA;AAAA,EACH,GAEJ;AAEJ,CAAC;"}
1
+ {"version":3,"file":"select.js","sources":["../../../src/inputs/select/select.tsx"],"sourcesContent":["import { useForkRef } from '../../utils/index.js';\nimport { clsx } from 'clsx';\nimport React, { useRef, useState } from 'react';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\nimport { OptionProps } from '../options/option.js';\nimport { Button, type ButtonProps } from '../../actions/index.js';\nimport styles from './select.module.css';\n\nfunction findOptionFromValue(options: React.ReactElement<OptionProps>[], value: string) {\n return options.find(option => option.props.value === value);\n}\n\nexport interface SelectProps\n extends Omit<ButtonProps, 'children' | 'onChange' | 'value'> {\n children?: React.ReactElement<OptionProps>[] | React.ReactElement<OptionProps>;\n onChange?: (value: string) => void;\n value?: string | null;\n placeholder?: string;\n noOptionMatchedMessage?: React.ReactNode;\n trimCustomInput?: boolean;\n}\n\nexport const Select = React.forwardRef(function Select(\n {\n children = [],\n onKeyDown,\n onKeyUp,\n value,\n placeholder = '-- Select --',\n noOptionMatchedMessage,\n trimCustomInput = false,\n className,\n onMouseDown,\n onMouseUp,\n onChange,\n ...props\n }: SelectProps,\n ref: React.Ref<HTMLButtonElement>\n) {\n const safeChildren = React.Children.toArray(\n children\n ) as React.ReactElement<OptionProps>[];\n const keyPressedDownRef = useRef('');\n const isAlreadyFocusedRef = useRef(false);\n const isClosingRef = useRef(false);\n const [anchorElement, setAnchorElement] = useState<HTMLButtonElement | null>(null);\n const internalButtonRef = useRef<HTMLButtonElement | null>(null);\n const [isSuggestionsOpen, setIsSuggestionsOpen] = useState(false);\n const forkedRef = useForkRef(ref, internalButtonRef);\n const selectedOption = findOptionFromValue(safeChildren, value || '');\n const selectedLabel =\n selectedOption == null ? placeholder || '' : selectedOption.props.label;\n\n function openSuggestions() {\n setIsSuggestionsOpen(true);\n }\n\n function closeSuggestions() {\n setIsSuggestionsOpen(false);\n }\n\n function handleClose() {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleSelection(value: string, _: string | undefined, isSuggestion: boolean) {\n const button = internalButtonRef.current;\n\n if (button != null) {\n requestAnimationFrame(() => {\n if (isSuggestion) {\n onChange && onChange(value);\n }\n button.focus();\n });\n }\n\n closeSuggestions();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLButtonElement>) {\n const key = event.key;\n keyPressedDownRef.current = key;\n onKeyDown && onKeyDown(event);\n }\n\n function handleKeyUp(event: React.KeyboardEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n const isSameKey = (keyPressedDownRef.current = event.key);\n\n keyPressedDownRef.current = '';\n const key = event.key;\n\n if (isSameKey && (key === 'Enter' || key === ' ')) {\n if (isSuggestionsOpen) {\n closeSuggestions();\n } else {\n openSuggestions();\n }\n }\n\n onKeyUp && onKeyUp(event);\n }\n\n function handlMouseDown(event: React.MouseEvent<HTMLButtonElement>) {\n setAnchorElement(event.currentTarget);\n isAlreadyFocusedRef.current = document.activeElement === event.currentTarget;\n onMouseDown && onMouseDown(event);\n }\n\n function handleMouseUp(event: React.MouseEvent<HTMLButtonElement>) {\n if (isClosingRef.current) {\n isClosingRef.current = false;\n closeSuggestions();\n }\n\n openSuggestions();\n onMouseUp && onMouseUp(event);\n }\n\n return (\n <>\n <Button\n ref={forkedRef}\n className={clsx(className, 'tcn-select', 'tcn-control', styles.select)}\n width=\"100%\"\n {...props}\n hAlign=\"start\"\n value={selectedLabel}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onMouseDown={handlMouseDown}\n onMouseUp={handleMouseUp}\n >\n <span className={clsx(styles.selectedLabel, 'tcn-select-selected-label')}>\n {selectedLabel}\n </span>\n </Button>\n <SuggestionList\n open={isSuggestionsOpen}\n anchorElement={anchorElement}\n onClose={handleClose}\n value={''}\n scrollToValue={value || ''}\n trimCustomInput={trimCustomInput}\n onOptionSelect={handleSelection}\n noSuggestionMessage={noOptionMatchedMessage}\n >\n {children}\n </SuggestionList>\n </>\n );\n});\n"],"names":["findOptionFromValue","options","value","option","Select","React","children","onKeyDown","onKeyUp","placeholder","noOptionMatchedMessage","trimCustomInput","className","onMouseDown","onMouseUp","onChange","props","ref","safeChildren","keyPressedDownRef","useRef","isAlreadyFocusedRef","isClosingRef","anchorElement","setAnchorElement","useState","internalButtonRef","isSuggestionsOpen","setIsSuggestionsOpen","forkedRef","useForkRef","selectedOption","selectedLabel","openSuggestions","closeSuggestions","handleClose","button","handleSelection","_","isSuggestion","handleKeyDown","event","key","handleKeyUp","isSameKey","handlMouseDown","handleMouseUp","jsxs","Fragment","jsx","Button","clsx","styles","SuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;AAQA,SAASA,EAAoBC,GAA4CC,GAAe;AACtF,SAAOD,EAAQ,KAAK,CAAAE,MAAUA,EAAO,MAAM,UAAUD,CAAK;AAC5D;AAYO,MAAME,KAASC,EAAM,WAAW,SACrC;AAAA,EACE,UAAAC,IAAW,CAAA;AAAA,EACX,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAN;AAAA,EACA,aAAAO,IAAc;AAAA,EACd,wBAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAeb,EAAM,SAAS;AAAA,IAClCC;AAAA,EAAA,GAEIa,IAAoBC,EAAO,EAAE,GAC7BC,IAAsBD,EAAO,EAAK,GAClCE,IAAeF,EAAO,EAAK,GAC3B,CAACG,GAAeC,CAAgB,IAAIC,EAAmC,IAAI,GAC3EC,IAAoBN,EAAiC,IAAI,GACzD,CAACO,GAAmBC,CAAoB,IAAIH,EAAS,EAAK,GAC1DI,IAAYC,EAAWb,GAAKS,CAAiB,GAC7CK,IAAiB/B,EAAoBkB,GAAchB,KAAS,EAAE,GAC9D8B,IACJD,KAAkB,OAAOtB,KAAe,KAAKsB,E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A;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAKrB;AAAA,QACL,WAAWsB,EAAKvC,GAAW,cAAc,eAAewC,EAAO,MAAM;AAAA,QACrE,OAAM;AAAA,QACL,GAAGpC;AAAA,QACJ,QAAO;AAAA,QACP,OAAOgB;AAAA,QACP,WAAWQ;AAAA,QACX,SAASG;AAAA,QACT,aAAaE;AAAA,QACb,WAAWC;AAAA,QAEX,UAAA,gBAAAG,EAAC,UAAK,WAAWE,EAAKC,EAAO,eAAe,2BAA2B,GACpE,UAAApB,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF,gBAAAiB;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,MAAM1B;AAAA,QACN,eAAAJ;AAAA,QACA,SAASY;AAAA,QACT,OAAO;AAAA,QACP,eAAejC,KAAS;AAAA,QACxB,iBAAAS;AAAA,QACA,gBAAgB0B;AAAA,QAChB,qBAAqB3B;AAAA,QAEpB,UAAAJ;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ,CAAC;"}
@@ -1,15 +1,18 @@
1
1
  import { default as React } from 'react';
2
2
  export interface SuggestionListProps extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange'> {
3
3
  value?: string;
4
+ initialSearchValue?: string;
4
5
  scrollToValue?: string;
5
6
  anchorElement: HTMLElement | null;
7
+ open?: boolean;
6
8
  children?: React.ReactNode;
7
9
  onChange?: (value: string) => void;
8
10
  onOptionSelect?: (value: string, label: string | undefined, isSuggestion: boolean, obfuscate: boolean) => void;
9
11
  noSuggestionMessage?: React.ReactNode;
10
12
  trimCustomInput?: boolean;
11
13
  haveValueAsOption?: boolean;
14
+ restoreFocus?: boolean;
12
15
  onClose?: (inputValue: string, cursorStartPosition: number | null, cursorEndPosition: number | null) => void;
13
16
  }
14
- export declare function SuggestionList({ value, scrollToValue, anchorElement, children, onOptionSelect, noSuggestionMessage, onClose, onChange, onKeyUp, onKeyDown, trimCustomInput, haveValueAsOption, ...props }: SuggestionListProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function SuggestionList({ value, initialSearchValue: searchValue, scrollToValue, anchorElement, open, children, onOptionSelect, noSuggestionMessage, onClose, onChange, onKeyUp, onKeyDown, trimCustomInput, haveValueAsOption, restoreFocus, ...props }: SuggestionListProps): import("react/jsx-runtime").JSX.Element;
15
18
  //# sourceMappingURL=suggestion_list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"suggestion_list.d.ts","sourceRoot":"","sources":["../../../src/inputs/suggestions/suggestion_list.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAazE,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,EACrB,SAAS,EAAE,OAAO,KACf,IAAI,CAAC;IACV,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,CACR,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,iBAAiB,EAAE,MAAM,GAAG,IAAI,KAC7B,IAAI,CAAC;CACX;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAU,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,cAAc,EACd,mBAAwC,EACxC,OAAO,EACP,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAuB,EACvB,iBAAyB,EACzB,GAAG,KAAK,EACT,EAAE,mBAAmB,2CA0XrB"}
1
+ {"version":3,"file":"suggestion_list.d.ts","sourceRoot":"","sources":["../../../src/inputs/suggestions/suggestion_list.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAazE,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,EACrB,SAAS,EAAE,OAAO,KACf,IAAI,CAAC;IACV,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,CACR,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,iBAAiB,EAAE,MAAM,GAAG,IAAI,KAC7B,IAAI,CAAC;CACX;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAU,EACV,kBAAkB,EAAE,WAAW,EAC/B,aAAa,EACb,aAAa,EACb,IAAY,EACZ,QAAQ,EACR,cAAc,EACd,mBAAwC,EACxC,OAAO,EACP,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAuB,EACvB,iBAAyB,EACzB,YAAmB,EACnB,GAAG,KAAK,EACT,EAAE,mBAAmB,2CAyYrB"}
@@ -1,82 +1,88 @@
1
- import { jsx as r, jsxs as N, Fragment as ce } from "react/jsx-runtime";
2
- import { BodyText as ae } from "../../typography/body_text/body_text.js";
1
+ import { jsx as r, jsxs as P, Fragment as fe } from "react/jsx-runtime";
2
+ import { BodyText as de } from "../../typography/body_text/body_text.js";
3
3
  import "../../typography/callout/callout.js";
4
4
  import "../../typography/caption/caption.js";
5
5
  import "../../typography/footnote/footnote.js";
6
6
  import "../../typography/headline/headline.js";
7
7
  import "../../typography/subheadline/subheadline.js";
8
8
  import "../../typography/title/title.js";
9
- import { VStack as O } from "../../stacks/v_stack.js";
10
- import { ZStack as ue } from "../../stacks/z_stack.js";
11
- import { clsx as R } from "clsx";
12
- import { Children as pe, isValidElement as de, useState as a, useRef as T, useLayoutEffect as S } from "react";
9
+ import { VStack as W } from "../../stacks/v_stack.js";
10
+ import { ZStack as ge } from "../../stacks/z_stack.js";
11
+ import { clsx as D } from "clsx";
12
+ import { Children as he, isValidElement as me, useState as a, useRef as F, useLayoutEffect as b } from "react";
13
13
  import "../../utils/click_away_listener.js";
14
- import { FocusRedirect as fe } from "../../utils/focus_redirect.js";
14
+ import { FocusRedirect as we } from "../../utils/focus_redirect.js";
15
15
  import "../../utils/scroll_away_listener.js";
16
16
  import "../../utils/hooks/use_resize_observer.js";
17
17
  import "../../utils/dnd/context.js";
18
18
  import "../../draggable.module-BgelQsuJ.js";
19
- import { SuggestionItem as ge } from "./suggestion_item.js";
20
- import { Option as U } from "../options/option.js";
19
+ import { SuggestionItem as be } from "./suggestion_item.js";
20
+ import { Option as $ } from "../options/option.js";
21
21
  import "../../actions/button/base_button/base_button.js";
22
22
  import "../../actions/button/button_group/button_group.js";
23
23
  import "../../actions/button/slim_button/slim_button.js";
24
- import { Button as he } from "../../actions/button/button/button.js";
24
+ import { Button as xe } from "../../actions/button/button/button.js";
25
25
  import "../../actions/button/select_group/select_group.js";
26
26
  import "../../actions/button/select_group/single_select_group.js";
27
27
  import "../../actions/toggle/toggle.js";
28
- import { Popper as me } from "../../overlay/popper/legacy/popper.js";
29
- import '../../suggestion_list.css';const we = "_suggestion-list_711fb17", be = "_input_a0df060", A = { "suggestion-list": we, input: be }, I = 50, xe = 50;
30
- function Xe({
31
- value: D = "",
28
+ import { Popper as Le } from "../../overlay/popper/legacy/popper.js";
29
+ import '../../suggestion_list.css';const ke = "_suggestion-list_711fb17", ye = "_input_a0df060", H = { "suggestion-list": ke, input: ye }, I = 50, Se = 50;
30
+ function Qe({
31
+ value: _ = "",
32
+ initialSearchValue: B,
32
33
  scrollToValue: g,
33
34
  anchorElement: l,
34
- children: V,
35
+ open: M = !1,
36
+ children: j,
35
37
  onOptionSelect: h,
36
- noSuggestionMessage: P = "-- No Matches --",
37
- onClose: b,
38
- onChange: F,
39
- onKeyUp: H,
40
- onKeyDown: _,
41
- trimCustomInput: W = !1,
42
- haveValueAsOption: $ = !1,
43
- ...j
38
+ noSuggestionMessage: q = "-- No Matches --",
39
+ onClose: x,
40
+ onChange: K,
41
+ onKeyUp: E,
42
+ onKeyDown: N,
43
+ trimCustomInput: Z = !1,
44
+ haveValueAsOption: X = !1,
45
+ restoreFocus: z = !0,
46
+ ...G
44
47
  }) {
45
- const x = pe.toArray(V).filter(
46
- (e) => de(e) && e.type === U
47
- ), [L, q] = a(() => {
48
+ const L = he.toArray(j).filter(
49
+ (e) => me(e) && e.type === $
50
+ ), [k, J] = a(() => {
48
51
  if (g != null) {
49
- const e = x.findIndex((o) => o.props.value === g);
52
+ const e = L.findIndex((i) => i.props.value === g);
50
53
  if (e !== -1)
51
54
  return e;
52
55
  }
53
56
  return -1;
54
- }), M = T(""), [Z, B] = a(I), [f, k] = a(L), [m, X] = a(D), c = T(null), [z, G] = a(x.length), [n, E] = a(
55
- () => C(D, I)
56
- ), [J, Q] = a(), [Y, ee] = a();
57
- function te(e) {
58
- const o = e.key, t = e.currentTarget, s = M.current = o;
59
- if (M.current = "", s)
60
- switch (o) {
57
+ }), C = F(""), v = F(!1), [Q, O] = a(I), [d, y] = a(k), [m, T] = a(_), c = F(null), [Y, ee] = a(L.length), [n, U] = a(
58
+ () => R(_, I)
59
+ ), [te, se] = a(), [ne, ie] = a();
60
+ function oe(e) {
61
+ if (!v.current)
62
+ return;
63
+ v.current = !1;
64
+ const i = e.key, t = e.currentTarget, s = C.current = i;
65
+ if (C.current = "", s)
66
+ switch (i) {
61
67
  case "Enter": {
62
- if (n[f] == null) {
63
- const p = W ? t.value.trim() : t.value;
68
+ if (n[d] == null) {
69
+ const p = Z ? t.value.trim() : t.value;
64
70
  if (p === "")
65
71
  return;
66
- const y = p.toLocaleLowerCase(), i = x.find(
67
- (v) => v.props.value.toLocaleLowerCase() === y || v.props.label != null && v.props.label.toLocaleLowerCase() === y
68
- ), K = i != null, d = i?.props.label || p, le = i?.props.value || p;
72
+ const S = p.toLocaleLowerCase(), o = L.find(
73
+ (A) => A.props.value.toLocaleLowerCase() === S || A.props.label != null && A.props.label.toLocaleLowerCase() === S
74
+ ), V = o != null, f = o?.props.label || p, pe = o?.props.value || p;
69
75
  requestAnimationFrame(() => {
70
76
  h && h(
71
- le,
72
- d,
73
- K,
74
- i?.props.obfuscate ?? !1
77
+ pe,
78
+ f,
79
+ V,
80
+ o?.props.obfuscate ?? !1
75
81
  );
76
82
  });
77
83
  break;
78
84
  }
79
- const u = n[f].props;
85
+ const u = n[d].props;
80
86
  if (u.disabled)
81
87
  break;
82
88
  requestAnimationFrame(() => {
@@ -90,17 +96,17 @@ function Xe({
90
96
  break;
91
97
  }
92
98
  case "Escape": {
93
- b && b(t.value, t.selectionStart, t.selectionEnd);
99
+ x && x(t.value, t.selectionStart, t.selectionEnd);
94
100
  break;
95
101
  }
96
102
  }
97
- H && H(e);
103
+ E && E(e);
98
104
  }
99
- function se(e) {
100
- const o = e.key;
101
- switch (M.current = o, o) {
105
+ function re(e) {
106
+ const i = e.key;
107
+ switch (C.current = i, v.current = !0, i) {
102
108
  case "ArrowDown": {
103
- let t = f + 1;
109
+ let t = d + 1;
104
110
  for (; t < n.length && n[t]?.props.disabled; )
105
111
  t++;
106
112
  if (t === n.length) {
@@ -108,13 +114,13 @@ function Xe({
108
114
  t++;
109
115
  t === n.length && (t = -1);
110
116
  }
111
- k(t), e.preventDefault();
117
+ y(t), e.preventDefault();
112
118
  break;
113
119
  }
114
120
  case "Tab": {
115
121
  let t = 1;
116
122
  e.shiftKey && (t = -1);
117
- let s = f + t;
123
+ let s = d + t;
118
124
  if (t > 0)
119
125
  for (; s < n.length && n[s]?.props.disabled; )
120
126
  s++;
@@ -130,11 +136,11 @@ function Xe({
130
136
  s--;
131
137
  s === -1 && (s = -1);
132
138
  }
133
- k(s), e.preventDefault();
139
+ y(s), e.preventDefault();
134
140
  break;
135
141
  }
136
142
  case "ArrowUp": {
137
- let t = f - 1;
143
+ let t = d - 1;
138
144
  for (; t >= 0 && n[t]?.props.disabled; )
139
145
  t--;
140
146
  if (t === -1) {
@@ -142,112 +148,115 @@ function Xe({
142
148
  t--;
143
149
  t === -1 && (t = -1);
144
150
  }
145
- k(t), e.preventDefault();
151
+ y(t), e.preventDefault();
146
152
  break;
147
153
  }
148
154
  }
149
- _ && _(e);
155
+ N && N(e);
150
156
  }
151
- function C(e, o) {
152
- const t = x.filter((s) => {
153
- const w = s.props, u = String(w.label).toLocaleLowerCase(), p = w.keywords?.map((d) => d.toLocaleLowerCase()) || [], y = String(w.value).toLocaleLowerCase(), i = e.toLocaleLowerCase();
154
- return w.obfuscate ?? !1 ? u.includes(i) || p.some((d) => d.includes(i)) : u.includes(i) || p.some((d) => d.includes(i)) || y.includes(i);
157
+ function R(e, i) {
158
+ const t = L.filter((s) => {
159
+ const w = s.props, u = String(w.label).toLocaleLowerCase(), p = w.keywords?.map((f) => f.toLocaleLowerCase()) || [], S = String(w.value).toLocaleLowerCase(), o = e.toLocaleLowerCase();
160
+ return w.obfuscate ?? !1 ? u.includes(o) || p.some((f) => f.includes(o)) : u.includes(o) || p.some((f) => f.includes(o)) || S.includes(o);
155
161
  });
156
- return $ && e.trim().length > 0 && !t.some((s) => s.props.value === e) && t.unshift(
157
- /* @__PURE__ */ r(U, { value: e, label: e, keywords: [e], children: e }, "value")
158
- ), G(t.length), t.slice(0, o);
162
+ return X && e.trim().length > 0 && !t.some((s) => s.props.value === e) && t.unshift(
163
+ /* @__PURE__ */ r($, { value: e, label: e, keywords: [e], children: e }, "value")
164
+ ), ee(t.length), t.slice(0, i);
159
165
  }
160
- function ne() {
166
+ function le() {
161
167
  const e = c.current;
162
168
  e?.focus();
163
169
  }
164
- function oe() {
170
+ function ce() {
165
171
  const e = c.current;
166
- e != null && b && b(e.value, e.selectionStart, e.selectionEnd);
172
+ e != null && x && x(e.value, e.selectionStart, e.selectionEnd);
167
173
  }
168
- function ie(e) {
169
- const o = e.currentTarget;
170
- B(I), X(e.target.value);
171
- const t = C(o.value, I);
172
- E(t), F && F(e.target.value);
174
+ function ae(e) {
175
+ const i = e.currentTarget;
176
+ O(I), T(e.target.value);
177
+ const t = R(i.value, I);
178
+ U(t), K && K(e.target.value);
173
179
  }
174
- function re() {
175
- const e = Z + xe;
176
- B(e);
177
- const o = C(m, e);
178
- E(o);
180
+ function ue() {
181
+ const e = Q + Se;
182
+ O(e);
183
+ const i = R(m, e);
184
+ U(i);
179
185
  }
180
- return S(() => {
186
+ return b(() => {
181
187
  const e = c.current;
182
- e != null && e.value.length > 0 ? e.select() : e?.focus();
183
- }, []), S(() => {
188
+ M && (e != null && e.value.length > 0 ? e.select() : e?.focus());
189
+ }, [M]), b(() => {
184
190
  if (l != null) {
185
191
  const e = l.getBoundingClientRect();
186
- Q(`${e.width}px`), ee(`${e.height}px`), c.current != null && l instanceof HTMLInputElement && (c.current.value = l.value, c.current.selectionStart = l.selectionStart, c.current.selectionEnd = l.selectionEnd);
192
+ se(`${e.width}px`), ie(`${e.height}px`), c.current != null && l instanceof HTMLInputElement && (c.current.value = l.value, c.current.selectionStart = l.selectionStart, c.current.selectionEnd = l.selectionEnd);
187
193
  }
188
- }, [l]), S(() => {
194
+ }, [l]), b(() => {
189
195
  if (g != null) {
190
196
  const e = n.findIndex(
191
- (o) => o.props.value === g
197
+ (i) => i.props.value === g
192
198
  );
193
- q(e);
199
+ J(e);
194
200
  }
195
- }, [n, g]), S(() => {
196
- k(m === "" ? L : -1);
197
- }, [m, L]), /* @__PURE__ */ r(
198
- me,
201
+ }, [n, g]), b(() => {
202
+ y(m === "" ? k : -1);
203
+ }, [m, k]), b(() => {
204
+ T(B ?? "");
205
+ }, [B]), /* @__PURE__ */ r(
206
+ Le,
199
207
  {
200
- open: !0,
208
+ open: M,
201
209
  anchorElement: l,
202
- onClose: oe,
210
+ onClose: ce,
203
211
  verticalAnchor: "top",
204
212
  verticalOrigin: "top",
205
213
  verticalOffset: -4,
206
- children: /* @__PURE__ */ N(
207
- O,
214
+ restoreFocus: z,
215
+ children: /* @__PURE__ */ P(
216
+ W,
208
217
  {
209
- minHeight: `calc(${Y}, 8px)`,
218
+ minHeight: `calc(${ne}, 8px)`,
210
219
  maxHeight: "300px",
211
- minWidth: J,
220
+ minWidth: te,
212
221
  width: "auto",
213
222
  hAlign: "start",
214
- className: R(A["suggestion-list"], "tcn-suggestion-list"),
223
+ className: D(H["suggestion-list"], "tcn-suggestion-list"),
215
224
  children: [
216
225
  /* @__PURE__ */ r(
217
226
  "input",
218
227
  {
219
228
  ref: c,
220
229
  value: m,
221
- onKeyUp: te,
222
- onKeyDown: se,
223
- onChange: ie,
224
- className: R(A.input, "tcn-suggestion-list-search-input"),
225
- ...j
230
+ onKeyUp: oe,
231
+ onKeyDown: re,
232
+ onChange: ae,
233
+ className: D(H.input, "tcn-suggestion-list-search-input"),
234
+ ...G
226
235
  },
227
236
  -1
228
237
  ),
229
- /* @__PURE__ */ N(O, { children: [
230
- n.map((e, o) => /* @__PURE__ */ r(
231
- ge,
238
+ /* @__PURE__ */ P(W, { children: [
239
+ n.map((e, i) => /* @__PURE__ */ r(
240
+ be,
232
241
  {
233
242
  option: e,
234
- isSelected: o === L && m !== "",
235
- isFocused: o === f,
243
+ isSelected: i === k && m !== "",
244
+ isFocused: i === d,
236
245
  onClick: h
237
246
  },
238
- o
247
+ i
239
248
  )),
240
- z > n.length && /* @__PURE__ */ r(ce, { children: /* @__PURE__ */ r(he, { marginBlock: "8px", hierarchy: "tertiary", onClick: re, children: "Show More" }) })
249
+ Y > n.length && /* @__PURE__ */ r(fe, { children: /* @__PURE__ */ r(xe, { marginBlock: "8px", hierarchy: "tertiary", onClick: ue, children: "Show More" }) })
241
250
  ] }),
242
251
  n.length === 0 && /* @__PURE__ */ r(
243
- ue,
252
+ ge,
244
253
  {
245
254
  padding: "8px",
246
- className: R(A["no-results"], "tcn-suggestion-list-no-results"),
247
- children: /* @__PURE__ */ r(ae, { children: P })
255
+ className: D(H["no-results"], "tcn-suggestion-list-no-results"),
256
+ children: /* @__PURE__ */ r(de, { children: q })
248
257
  }
249
258
  ),
250
- /* @__PURE__ */ r(fe, { onRedirect: ne }, n.length + 1)
259
+ /* @__PURE__ */ r(we, { onRedirect: le }, n.length + 1)
251
260
  ]
252
261
  }
253
262
  )
@@ -255,6 +264,6 @@ function Xe({
255
264
  );
256
265
  }
257
266
  export {
258
- Xe as SuggestionList
267
+ Qe as SuggestionList
259
268
  };
260
269
  //# sourceMappingURL=suggestion_list.js.map