@korsolutions/ui 0.0.52 → 0.0.53

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 (254) hide show
  1. package/AGENTS.md +3 -3
  2. package/dist/module/components/alert/components/alert-description.js.map +1 -1
  3. package/dist/module/components/index.js +1 -0
  4. package/dist/module/components/index.js.map +1 -1
  5. package/dist/module/components/input/numeric-input.js +1 -1
  6. package/dist/module/components/input/numeric-input.js.map +1 -1
  7. package/dist/module/components/input/variants/default.js +9 -2
  8. package/dist/module/components/input/variants/default.js.map +1 -1
  9. package/dist/module/components/input/variants/secondary.js +9 -2
  10. package/dist/module/components/input/variants/secondary.js.map +1 -1
  11. package/dist/module/components/link/variants/default.js.map +1 -1
  12. package/dist/module/components/menu/components/menu-trigger.js +1 -1
  13. package/dist/module/components/menu/components/menu-trigger.js.map +1 -1
  14. package/dist/module/components/phone-input/index.js +4 -0
  15. package/dist/module/components/phone-input/index.js.map +1 -0
  16. package/dist/module/components/phone-input/phone-input.js +165 -0
  17. package/dist/module/components/phone-input/phone-input.js.map +1 -0
  18. package/dist/module/components/phone-input/types.js +4 -0
  19. package/dist/module/components/phone-input/types.js.map +1 -0
  20. package/dist/module/components/phone-input/variants/default.js +128 -0
  21. package/dist/module/components/phone-input/variants/default.js.map +1 -0
  22. package/dist/module/components/phone-input/variants/index.js +7 -0
  23. package/dist/module/components/phone-input/variants/index.js.map +1 -0
  24. package/dist/module/components/select/components/select-trigger.js +2 -2
  25. package/dist/module/components/select/components/select-trigger.js.map +1 -1
  26. package/dist/module/components/tabs/variants/default.js.map +1 -1
  27. package/dist/module/components/toast/components/toast-icon.js.map +1 -1
  28. package/dist/module/components/toast/manager.js +2 -2
  29. package/dist/module/components/toast/manager.js.map +1 -1
  30. package/dist/module/components/typography/variants/body-lg.js.map +1 -1
  31. package/dist/module/components/typography/variants/body-md.js.map +1 -1
  32. package/dist/module/components/typography/variants/body-sm.js.map +1 -1
  33. package/dist/module/components/typography/variants/heading-lg.js.map +1 -1
  34. package/dist/module/components/typography/variants/heading-md.js.map +1 -1
  35. package/dist/module/components/typography/variants/heading-sm.js.map +1 -1
  36. package/dist/module/data/countries.js +476 -0
  37. package/dist/module/data/countries.js.map +1 -0
  38. package/dist/module/hooks/index.js +1 -0
  39. package/dist/module/hooks/index.js.map +1 -1
  40. package/dist/module/hooks/use-phone-mask.js +121 -0
  41. package/dist/module/hooks/use-phone-mask.js.map +1 -0
  42. package/dist/module/hooks/use-relative-position.js.map +1 -1
  43. package/dist/module/index.js +2 -2
  44. package/dist/module/index.js.map +1 -1
  45. package/dist/module/themes/provider.js.map +1 -1
  46. package/dist/module/themes/utils.js.map +1 -1
  47. package/dist/module/utils/input-utils.js.map +1 -1
  48. package/dist/module/utils/normalize-layout.js.map +1 -1
  49. package/dist/module/utils/use-themed-styles.js.map +1 -1
  50. package/dist/typescript/src/components/alert/components/alert-body.d.ts.map +1 -1
  51. package/dist/typescript/src/components/alert/components/alert-description.d.ts +2 -2
  52. package/dist/typescript/src/components/alert/components/alert-description.d.ts.map +1 -1
  53. package/dist/typescript/src/components/alert/components/alert-icon.d.ts.map +1 -1
  54. package/dist/typescript/src/components/alert/components/alert-root.d.ts.map +1 -1
  55. package/dist/typescript/src/components/alert/components/alert-title.d.ts.map +1 -1
  56. package/dist/typescript/src/components/alert/variants/default.d.ts +1 -1
  57. package/dist/typescript/src/components/alert/variants/default.d.ts.map +1 -1
  58. package/dist/typescript/src/components/alert/variants/destructive.d.ts +1 -1
  59. package/dist/typescript/src/components/alert/variants/destructive.d.ts.map +1 -1
  60. package/dist/typescript/src/components/alert-dialog/components/alert-dialog-trigger.d.ts.map +1 -1
  61. package/dist/typescript/src/components/alert-dialog/variants/default.d.ts +1 -1
  62. package/dist/typescript/src/components/alert-dialog/variants/default.d.ts.map +1 -1
  63. package/dist/typescript/src/components/avatar/variants/default.d.ts +1 -1
  64. package/dist/typescript/src/components/avatar/variants/default.d.ts.map +1 -1
  65. package/dist/typescript/src/components/badge/components/badge-root.d.ts.map +1 -1
  66. package/dist/typescript/src/components/badge/variants/default.d.ts +1 -1
  67. package/dist/typescript/src/components/badge/variants/default.d.ts.map +1 -1
  68. package/dist/typescript/src/components/badge/variants/secondary.d.ts +1 -1
  69. package/dist/typescript/src/components/badge/variants/secondary.d.ts.map +1 -1
  70. package/dist/typescript/src/components/button/components/button-label.d.ts.map +1 -1
  71. package/dist/typescript/src/components/button/variants/default.d.ts +1 -1
  72. package/dist/typescript/src/components/button/variants/default.d.ts.map +1 -1
  73. package/dist/typescript/src/components/button/variants/secondary.d.ts +1 -1
  74. package/dist/typescript/src/components/button/variants/secondary.d.ts.map +1 -1
  75. package/dist/typescript/src/components/calendar/variants/default.d.ts +1 -1
  76. package/dist/typescript/src/components/calendar/variants/default.d.ts.map +1 -1
  77. package/dist/typescript/src/components/card/card-body.d.ts.map +1 -1
  78. package/dist/typescript/src/components/card/card-footer.d.ts.map +1 -1
  79. package/dist/typescript/src/components/card/card-header.d.ts.map +1 -1
  80. package/dist/typescript/src/components/card/card-root.d.ts.map +1 -1
  81. package/dist/typescript/src/components/card/card-title.d.ts.map +1 -1
  82. package/dist/typescript/src/components/card/variants/default.d.ts +1 -1
  83. package/dist/typescript/src/components/card/variants/default.d.ts.map +1 -1
  84. package/dist/typescript/src/components/checkbox/variants/default.d.ts +1 -1
  85. package/dist/typescript/src/components/checkbox/variants/default.d.ts.map +1 -1
  86. package/dist/typescript/src/components/checkbox/variants/outlined.d.ts +1 -1
  87. package/dist/typescript/src/components/checkbox/variants/outlined.d.ts.map +1 -1
  88. package/dist/typescript/src/components/empty/variants/default.d.ts +1 -1
  89. package/dist/typescript/src/components/empty/variants/default.d.ts.map +1 -1
  90. package/dist/typescript/src/components/field/variants/default.d.ts +1 -1
  91. package/dist/typescript/src/components/field/variants/default.d.ts.map +1 -1
  92. package/dist/typescript/src/components/icon/icon.d.ts.map +1 -1
  93. package/dist/typescript/src/components/index.d.ts +1 -0
  94. package/dist/typescript/src/components/index.d.ts.map +1 -1
  95. package/dist/typescript/src/components/input/input.d.ts.map +1 -1
  96. package/dist/typescript/src/components/input/numeric-input.d.ts +1 -1
  97. package/dist/typescript/src/components/input/numeric-input.d.ts.map +1 -1
  98. package/dist/typescript/src/components/input/variants/default.d.ts +1 -1
  99. package/dist/typescript/src/components/input/variants/default.d.ts.map +1 -1
  100. package/dist/typescript/src/components/input/variants/secondary.d.ts +1 -1
  101. package/dist/typescript/src/components/input/variants/secondary.d.ts.map +1 -1
  102. package/dist/typescript/src/components/link/variants/default.d.ts.map +1 -1
  103. package/dist/typescript/src/components/menu/components/menu-trigger.d.ts +1 -1
  104. package/dist/typescript/src/components/menu/components/menu-trigger.d.ts.map +1 -1
  105. package/dist/typescript/src/components/menu/context.d.ts.map +1 -1
  106. package/dist/typescript/src/components/menu/variants/default.d.ts +1 -1
  107. package/dist/typescript/src/components/menu/variants/default.d.ts.map +1 -1
  108. package/dist/typescript/src/components/phone-input/index.d.ts +3 -0
  109. package/dist/typescript/src/components/phone-input/index.d.ts.map +1 -0
  110. package/dist/typescript/src/components/phone-input/phone-input.d.ts +16 -0
  111. package/dist/typescript/src/components/phone-input/phone-input.d.ts.map +1 -0
  112. package/dist/typescript/src/components/phone-input/types.d.ts +15 -0
  113. package/dist/typescript/src/components/phone-input/types.d.ts.map +1 -0
  114. package/dist/typescript/src/components/phone-input/variants/default.d.ts +3 -0
  115. package/dist/typescript/src/components/phone-input/variants/default.d.ts.map +1 -0
  116. package/dist/typescript/src/components/phone-input/variants/index.d.ts +5 -0
  117. package/dist/typescript/src/components/phone-input/variants/index.d.ts.map +1 -0
  118. package/dist/typescript/src/components/popover/components/popover-trigger.d.ts.map +1 -1
  119. package/dist/typescript/src/components/popover/context.d.ts.map +1 -1
  120. package/dist/typescript/src/components/popover/variants/default.d.ts +1 -1
  121. package/dist/typescript/src/components/popover/variants/default.d.ts.map +1 -1
  122. package/dist/typescript/src/components/popover/variants/unstyled.d.ts +1 -1
  123. package/dist/typescript/src/components/popover/variants/unstyled.d.ts.map +1 -1
  124. package/dist/typescript/src/components/progress/variants/default.d.ts +1 -1
  125. package/dist/typescript/src/components/progress/variants/default.d.ts.map +1 -1
  126. package/dist/typescript/src/components/select/components/select-trigger.d.ts.map +1 -1
  127. package/dist/typescript/src/components/select/context.d.ts.map +1 -1
  128. package/dist/typescript/src/components/select/variants/default.d.ts +1 -1
  129. package/dist/typescript/src/components/select/variants/default.d.ts.map +1 -1
  130. package/dist/typescript/src/components/tabs/variants/default.d.ts +1 -1
  131. package/dist/typescript/src/components/tabs/variants/default.d.ts.map +1 -1
  132. package/dist/typescript/src/components/tabs/variants/line.d.ts +1 -1
  133. package/dist/typescript/src/components/tabs/variants/line.d.ts.map +1 -1
  134. package/dist/typescript/src/components/textarea/variants/default.d.ts +1 -1
  135. package/dist/typescript/src/components/textarea/variants/default.d.ts.map +1 -1
  136. package/dist/typescript/src/components/toast/components/toast-icon.d.ts +1 -1
  137. package/dist/typescript/src/components/toast/components/toast-icon.d.ts.map +1 -1
  138. package/dist/typescript/src/components/toast/manager.d.ts.map +1 -1
  139. package/dist/typescript/src/components/typography/variants/body-lg.d.ts.map +1 -1
  140. package/dist/typescript/src/components/typography/variants/body-md.d.ts.map +1 -1
  141. package/dist/typescript/src/components/typography/variants/body-sm.d.ts.map +1 -1
  142. package/dist/typescript/src/components/typography/variants/heading-lg.d.ts.map +1 -1
  143. package/dist/typescript/src/components/typography/variants/heading-md.d.ts.map +1 -1
  144. package/dist/typescript/src/components/typography/variants/heading-sm.d.ts.map +1 -1
  145. package/dist/typescript/src/data/countries.d.ts +17 -0
  146. package/dist/typescript/src/data/countries.d.ts.map +1 -0
  147. package/dist/typescript/src/hooks/index.d.ts +1 -0
  148. package/dist/typescript/src/hooks/index.d.ts.map +1 -1
  149. package/dist/typescript/src/hooks/use-phone-mask.d.ts +20 -0
  150. package/dist/typescript/src/hooks/use-phone-mask.d.ts.map +1 -0
  151. package/dist/typescript/src/hooks/use-relative-position.d.ts +1 -1
  152. package/dist/typescript/src/hooks/use-relative-position.d.ts.map +1 -1
  153. package/dist/typescript/src/index.d.ts +2 -2
  154. package/dist/typescript/src/index.d.ts.map +1 -1
  155. package/dist/typescript/src/themes/provider.d.ts +1 -1
  156. package/dist/typescript/src/themes/provider.d.ts.map +1 -1
  157. package/dist/typescript/src/themes/utils.d.ts.map +1 -1
  158. package/dist/typescript/src/utils/input-utils.d.ts.map +1 -1
  159. package/dist/typescript/src/utils/normalize-layout.d.ts +1 -1
  160. package/dist/typescript/src/utils/normalize-layout.d.ts.map +1 -1
  161. package/dist/typescript/src/utils/use-themed-styles.d.ts.map +1 -1
  162. package/package.json +1 -1
  163. package/src/components/alert/components/alert-body.tsx +1 -1
  164. package/src/components/alert/components/alert-description.tsx +5 -3
  165. package/src/components/alert/components/alert-icon.tsx +1 -1
  166. package/src/components/alert/components/alert-root.tsx +1 -1
  167. package/src/components/alert/components/alert-title.tsx +2 -2
  168. package/src/components/alert/variants/default.tsx +2 -2
  169. package/src/components/alert/variants/destructive.tsx +2 -2
  170. package/src/components/alert-dialog/components/alert-dialog-trigger.tsx +1 -1
  171. package/src/components/alert-dialog/variants/default.tsx +2 -2
  172. package/src/components/avatar/variants/default.tsx +2 -2
  173. package/src/components/badge/components/badge-label.tsx +1 -1
  174. package/src/components/badge/components/badge-root.tsx +2 -2
  175. package/src/components/badge/variants/default.tsx +2 -2
  176. package/src/components/badge/variants/secondary.tsx +2 -2
  177. package/src/components/button/components/button-label.tsx +2 -2
  178. package/src/components/button/variants/default.tsx +3 -3
  179. package/src/components/button/variants/secondary.tsx +3 -3
  180. package/src/components/calendar/components/calendar-day.tsx +1 -1
  181. package/src/components/calendar/components/calendar-nav-button.tsx +1 -1
  182. package/src/components/calendar/components/calendar-title.tsx +1 -1
  183. package/src/components/calendar/components/calendar-weeks.tsx +1 -1
  184. package/src/components/calendar/variants/default.tsx +2 -2
  185. package/src/components/card/card-body.tsx +2 -2
  186. package/src/components/card/card-footer.tsx +2 -2
  187. package/src/components/card/card-header.tsx +2 -2
  188. package/src/components/card/card-root.tsx +2 -2
  189. package/src/components/card/card-title.tsx +3 -3
  190. package/src/components/card/variants/default.tsx +2 -2
  191. package/src/components/checkbox/variants/default.tsx +2 -2
  192. package/src/components/checkbox/variants/outlined.tsx +2 -2
  193. package/src/components/empty/variants/default.tsx +2 -2
  194. package/src/components/field/variants/default.tsx +2 -2
  195. package/src/components/icon/icon.tsx +1 -1
  196. package/src/components/icon/variants/default.tsx +1 -1
  197. package/src/components/index.ts +1 -0
  198. package/src/components/input/input.tsx +1 -1
  199. package/src/components/input/numeric-input.tsx +8 -2
  200. package/src/components/input/variants/default.tsx +10 -3
  201. package/src/components/input/variants/secondary.tsx +10 -3
  202. package/src/components/link/variants/default.tsx +2 -2
  203. package/src/components/menu/components/menu-content.tsx +1 -1
  204. package/src/components/menu/components/menu-root.tsx +1 -1
  205. package/src/components/menu/components/menu-trigger.tsx +40 -38
  206. package/src/components/menu/context.ts +1 -1
  207. package/src/components/menu/variants/default.tsx +2 -2
  208. package/src/components/phone-input/index.ts +2 -0
  209. package/src/components/phone-input/phone-input.tsx +220 -0
  210. package/src/components/phone-input/types.ts +20 -0
  211. package/src/components/phone-input/variants/default.tsx +124 -0
  212. package/src/components/phone-input/variants/index.ts +5 -0
  213. package/src/components/popover/components/popover-content.tsx +2 -2
  214. package/src/components/popover/components/popover-root.tsx +1 -1
  215. package/src/components/popover/components/popover-trigger.tsx +2 -2
  216. package/src/components/popover/context.ts +1 -1
  217. package/src/components/popover/variants/default.tsx +2 -2
  218. package/src/components/popover/variants/unstyled.tsx +2 -2
  219. package/src/components/progress/components/progress-indicator.tsx +1 -1
  220. package/src/components/progress/components/progress-root.tsx +1 -1
  221. package/src/components/progress/variants/default.tsx +2 -2
  222. package/src/components/scroll-bar/scroll-bar.tsx +1 -1
  223. package/src/components/select/components/select-content.tsx +2 -2
  224. package/src/components/select/components/select-option.tsx +1 -1
  225. package/src/components/select/components/select-overlay.tsx +1 -1
  226. package/src/components/select/components/select-root.tsx +2 -2
  227. package/src/components/select/components/select-trigger.tsx +35 -9
  228. package/src/components/select/context.ts +1 -1
  229. package/src/components/select/variants/default.tsx +2 -2
  230. package/src/components/tabs/variants/default.tsx +2 -2
  231. package/src/components/tabs/variants/line.tsx +2 -2
  232. package/src/components/textarea/variants/default.tsx +2 -2
  233. package/src/components/toast/components/toast-icon.tsx +8 -2
  234. package/src/components/toast/manager.tsx +11 -4
  235. package/src/components/toast/variants/danger.tsx +1 -1
  236. package/src/components/toast/variants/default.tsx +1 -1
  237. package/src/components/toast/variants/success.tsx +1 -1
  238. package/src/components/typography/variants/body-lg.tsx +1 -1
  239. package/src/components/typography/variants/body-md.tsx +1 -1
  240. package/src/components/typography/variants/body-sm.tsx +1 -1
  241. package/src/components/typography/variants/heading-lg.tsx +1 -1
  242. package/src/components/typography/variants/heading-md.tsx +1 -1
  243. package/src/components/typography/variants/heading-sm.tsx +1 -1
  244. package/src/data/countries.ts +88 -0
  245. package/src/hooks/index.ts +1 -0
  246. package/src/hooks/use-phone-mask.ts +183 -0
  247. package/src/hooks/use-relative-position.ts +94 -18
  248. package/src/index.tsx +8 -3
  249. package/src/themes/provider.tsx +23 -5
  250. package/src/themes/utils.ts +5 -2
  251. package/src/utils/input-utils.ts +5 -2
  252. package/src/utils/normalize-layout.ts +5 -2
  253. package/src/utils/use-themed-styles.ts +11 -3
  254. package/tsconfig.json +14 -7
@@ -1,5 +1,5 @@
1
- import { useRelativePosition } from "@/hooks/use-relative-position";
2
- import { useSafeAreaInsets } from "@/safe-area";
1
+ import { useRelativePosition } from "../../../hooks/use-relative-position";
2
+ import { useSafeAreaInsets } from "../../../safe-area";
3
3
  import React from "react";
4
4
  import { type StyleProp, View, type ViewStyle } from "react-native";
5
5
  import { usePopover } from "../context";
@@ -1,4 +1,4 @@
1
- import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "@/hooks/use-relative-position";
1
+ import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "../../../hooks/use-relative-position";
2
2
  import React, { useState } from "react";
3
3
  import { type LayoutRectangle } from "react-native";
4
4
  import { PopoverContext } from "../context";
@@ -1,5 +1,5 @@
1
- import type { ViewRef } from "@/types/element.types";
2
- import { measureLayoutPosition } from "@/utils/normalize-layout";
1
+ import type { ViewRef } from "../../../types/element.types";
2
+ import { measureLayoutPosition } from "../../../utils/normalize-layout";
3
3
  import React, { forwardRef, useImperativeHandle, useRef } from "react";
4
4
  import { type PressableProps } from "react-native";
5
5
  import { usePopover } from "../context";
@@ -1,4 +1,4 @@
1
- import type { LayoutPosition } from "@/hooks/use-relative-position";
1
+ import type { LayoutPosition } from "../../hooks/use-relative-position";
2
2
  import { createContext, type Dispatch, useContext } from "react";
3
3
  import type { LayoutRectangle } from "react-native";
4
4
  import type { PopoverStyles } from "./types";
@@ -1,5 +1,5 @@
1
- import { type PopoverStyles } from "@/components/popover/types";
2
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { type PopoverStyles } from "../types";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export const usePopoverVariantDefault = (): PopoverStyles => {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { type PopoverStyles } from "@/components/popover/types";
2
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { type PopoverStyles } from "../types";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export const usePopoverVariantUnstyled = (): PopoverStyles => {
5
5
  return useThemedStyles(
@@ -1,4 +1,4 @@
1
- import { calculateComposedStyles } from "@/utils/calculate-styles";
1
+ import { calculateComposedStyles } from "../../../utils/calculate-styles";
2
2
  import React from "react";
3
3
  import { type StyleProp, View, type ViewStyle } from "react-native";
4
4
  import { useProgress } from "../context";
@@ -1,4 +1,4 @@
1
- import { calculateComposedStyles } from "@/utils/calculate-styles";
1
+ import { calculateComposedStyles } from "../../../utils/calculate-styles";
2
2
  import React from "react";
3
3
  import { type StyleProp, View, type ViewStyle } from "react-native";
4
4
  import { ProgressContext } from "../context";
@@ -1,5 +1,5 @@
1
- import { type ProgressStyles } from "@/components";
2
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { type ProgressStyles } from "../..";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export const useProgressVariantDefault = (): ProgressStyles => {
5
5
  return useThemedStyles(
@@ -1,4 +1,4 @@
1
- import { useTheme } from "@/themes";
1
+ import { useTheme } from "../../themes";
2
2
  import React, { useEffect } from "react";
3
3
  import { Platform } from "react-native";
4
4
 
@@ -1,5 +1,5 @@
1
- import { useRelativePosition } from "@/hooks/use-relative-position";
2
- import { calculateComposedStyles } from "@/utils/calculate-styles";
1
+ import { useRelativePosition } from "../../../hooks/use-relative-position";
2
+ import { calculateComposedStyles } from "../../../utils/calculate-styles";
3
3
  import React from "react";
4
4
  import { type StyleProp, View, type ViewStyle } from "react-native";
5
5
  import { useSelect } from "../context";
@@ -1,4 +1,4 @@
1
- import { calculateComposedStyles } from "@/utils/calculate-styles";
1
+ import { calculateComposedStyles } from "../../../utils/calculate-styles";
2
2
  import React, { useEffect, useState } from "react";
3
3
  import { Pressable, Text } from "react-native";
4
4
  import { useSelect } from "../context";
@@ -1,4 +1,4 @@
1
- import { calculateComposedStyles } from "@/utils/calculate-styles";
1
+ import { calculateComposedStyles } from "../../../utils/calculate-styles";
2
2
  import React from "react";
3
3
  import { Pressable, type StyleProp, StyleSheet, type ViewStyle } from "react-native";
4
4
  import { useSelect } from "../context";
@@ -1,5 +1,5 @@
1
- import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "@/hooks";
2
- import { calculateComposedStyles } from "@/utils/calculate-styles";
1
+ import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "../../../hooks";
2
+ import { calculateComposedStyles } from "../../../utils/calculate-styles";
3
3
  import React, { useState } from "react";
4
4
  import { type LayoutRectangle, type StyleProp, View, type ViewStyle } from "react-native";
5
5
  import { SelectContext } from "../context";
@@ -1,8 +1,14 @@
1
- import type { ViewRef } from "@/types/element.types";
2
- import { calculateComposedStyles } from "@/utils/calculate-styles";
3
- import { measureLayoutPosition } from "@/utils/normalize-layout";
4
1
  import React, { useRef } from "react";
5
- import { Pressable, Text, type StyleProp, type TextStyle, type ViewStyle } from "react-native";
2
+ import {
3
+ Pressable,
4
+ Text,
5
+ type StyleProp,
6
+ type TextStyle,
7
+ type ViewStyle,
8
+ } from "react-native";
9
+ import type { ViewRef } from "../../../types/element.types";
10
+ import { calculateComposedStyles } from "../../../utils/calculate-styles";
11
+ import { measureLayoutPosition } from "../../../utils/normalize-layout";
6
12
  import { useSelect } from "../context";
7
13
 
8
14
  export interface SelectTriggerProps {
@@ -14,7 +20,12 @@ export function SelectTrigger(props: SelectTriggerProps) {
14
20
  const select = useSelect();
15
21
  const triggerRef = useRef<ViewRef>(null);
16
22
 
17
- const composedStyles = calculateComposedStyles(select.styles, select.state, "trigger", props.style);
23
+ const composedStyles = calculateComposedStyles(
24
+ select.styles,
25
+ select.state,
26
+ "trigger",
27
+ props.style,
28
+ );
18
29
 
19
30
  const onTriggerPress = () => {
20
31
  if (!select.isOpen) {
@@ -28,7 +39,12 @@ export function SelectTrigger(props: SelectTriggerProps) {
28
39
  };
29
40
 
30
41
  return (
31
- <Pressable ref={triggerRef} onPress={onTriggerPress} disabled={select.isDisabled} style={composedStyles}>
42
+ <Pressable
43
+ ref={triggerRef}
44
+ onPress={onTriggerPress}
45
+ disabled={select.isDisabled}
46
+ style={composedStyles}
47
+ >
32
48
  <SelectValue placeholder={props.placeholder} />
33
49
  </Pressable>
34
50
  );
@@ -42,12 +58,22 @@ export interface SelectValueProps {
42
58
  export function SelectValue(props: SelectValueProps) {
43
59
  const select = useSelect();
44
60
 
45
- const selectedOption = select.options.find((option) => option.value === select.value);
61
+ const selectedOption = select.options.find(
62
+ (option) => option.value === select.value,
63
+ );
46
64
  const selectedOptionLabel = selectedOption?.label;
47
65
 
48
- const composedStyles = calculateComposedStyles(select.styles, select.state, selectedOptionLabel ? "value" : "placeholder");
66
+ const composedStyles = calculateComposedStyles(
67
+ select.styles,
68
+ select.state,
69
+ selectedOptionLabel ? "value" : "placeholder",
70
+ );
49
71
  if (typeof selectedOptionLabel !== "string") {
50
72
  return <>{selectedOptionLabel}</>;
51
73
  }
52
- return <Text style={composedStyles}>{selectedOptionLabel ?? props.placeholder}</Text>;
74
+ return (
75
+ <Text style={composedStyles}>
76
+ {selectedOptionLabel ?? props.placeholder}
77
+ </Text>
78
+ );
53
79
  }
@@ -1,4 +1,4 @@
1
- import type { LayoutPosition } from "@/hooks";
1
+ import type { LayoutPosition } from "../../hooks";
2
2
  import { createContext, type Dispatch, useContext } from "react";
3
3
  import type { LayoutRectangle } from "react-native";
4
4
  import type { SelectOption, SelectState, SelectStyles } from "./types";
@@ -1,5 +1,5 @@
1
- import { type SelectStyles } from "@/components";
2
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { type SelectStyles } from "../..";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useSelectVariantDefault(): SelectStyles {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { type TabsStyles } from "@/components";
2
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
2
+ import { type TabsStyles } from "../types";
3
3
 
4
4
  export const useTabsVariantDefault = (): TabsStyles => {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { type TabsStyles } from "@/components";
2
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { type TabsStyles } from "../..";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export const useTabsVariantLine = (): TabsStyles => {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { type TextareaStyles } from "@/components";
2
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { type TextareaStyles } from "../..";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useTextareaVariantDefault(): TextareaStyles {
5
5
  return useThemedStyles(
@@ -1,10 +1,16 @@
1
- import type { PropsWithRequiredRender, SvgProps } from "@/types/props.types";
2
1
  import React from "react";
2
+ import type {
3
+ PropsWithRequiredRender,
4
+ SvgProps,
5
+ } from "../../../types/props.types";
3
6
  import { useToast } from "../context";
4
7
 
5
8
  export type ToastIconProps = SvgProps;
6
9
 
7
- export function ToastIcon({ render: Component, ...props }: PropsWithRequiredRender<ToastIconProps>) {
10
+ export function ToastIcon({
11
+ render: Component,
12
+ ...props
13
+ }: PropsWithRequiredRender<ToastIconProps>) {
8
14
  const toast = useToast();
9
15
 
10
16
  const composedProps = {
@@ -1,7 +1,7 @@
1
- import { Portal } from "@/components/portal";
2
- import { useSafeAreaInsets } from "@/safe-area";
3
1
  import React, { useSyncExternalStore } from "react";
4
2
  import { StyleSheet, View } from "react-native";
3
+ import { useSafeAreaInsets } from "../../safe-area";
4
+ import { Portal } from "../portal";
5
5
  import { ToastDescription } from "./components/toast-description";
6
6
  import { ToastRoot } from "./components/toast-root";
7
7
  import { ToastTitle } from "./components/toast-title";
@@ -87,7 +87,12 @@ export function ToastContainer() {
87
87
  <Portal name={TOAST_PORTAL_NAME}>
88
88
  <View style={[s.wrapper, { top: insets.top + 24 }]}>
89
89
  {toasts.map((toast) => (
90
- <ToastComponent key={toast.id} title={toast.title} description={toast.description} variant={toast.variant} />
90
+ <ToastComponent
91
+ key={toast.id}
92
+ title={toast.title}
93
+ description={toast.description}
94
+ variant={toast.variant}
95
+ />
91
96
  ))}
92
97
  </View>
93
98
  </Portal>
@@ -105,7 +110,9 @@ export function ToastComponent(props: ToastProps) {
105
110
  return (
106
111
  <ToastRoot variant={props.variant}>
107
112
  <ToastTitle>{props.title}</ToastTitle>
108
- {!!props.description && <ToastDescription>{props.description}</ToastDescription>}
113
+ {!!props.description && (
114
+ <ToastDescription>{props.description}</ToastDescription>
115
+ )}
109
116
  </ToastRoot>
110
117
  );
111
118
  }
@@ -1,4 +1,4 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
2
2
  import { type ToastStyles } from "../types";
3
3
 
4
4
  export const useToastVariantDanger = (): ToastStyles => {
@@ -1,4 +1,4 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
2
2
  import { type ToastStyles } from "../types";
3
3
 
4
4
  export const useToastVariantDefault = (): ToastStyles => {
@@ -1,4 +1,4 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
1
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
2
2
  import { type ToastStyles } from "../types";
3
3
 
4
4
  export const useToastVariantSuccess = (): ToastStyles => {
@@ -1,5 +1,5 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
2
1
  import { type TextStyle } from "react-native";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useTextVariantBodyLg(): TextStyle {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
2
1
  import { type TextStyle } from "react-native";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useTextVariantBodyMd(): TextStyle {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
2
1
  import { type TextStyle } from "react-native";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useTextVariantBodySm(): TextStyle {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
2
1
  import { type TextStyle } from "react-native";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useTextVariantHeadingLg(): TextStyle {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
2
1
  import { type TextStyle } from "react-native";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useTextVariantHeadingMd(): TextStyle {
5
5
  return useThemedStyles(
@@ -1,5 +1,5 @@
1
- import { useThemedStyles } from "@/utils/use-themed-styles";
2
1
  import { type TextStyle } from "react-native";
2
+ import { useThemedStyles } from "../../../utils/use-themed-styles";
3
3
 
4
4
  export function useTextVariantHeadingSm(): TextStyle {
5
5
  return useThemedStyles(
@@ -0,0 +1,88 @@
1
+ export interface CountryData {
2
+ /** ISO 3166-1 alpha-2 code */
3
+ code: string;
4
+ /** Display name */
5
+ name: string;
6
+ /** Dial code without plus sign */
7
+ dialCode: string;
8
+ /** Flag emoji */
9
+ flag: string;
10
+ /** Format pattern using # for digits */
11
+ format: string;
12
+ /** Priority for sorting countries with same dial code (lower = higher) */
13
+ priority: number;
14
+ }
15
+
16
+ export const COUNTRIES: CountryData[] = [
17
+ { code: "AF", name: "Afghanistan", dialCode: "93", flag: "🇦🇫", format: "## ### ####", priority: 0 },
18
+ { code: "AL", name: "Albania", dialCode: "355", flag: "🇦🇱", format: "## ### ####", priority: 0 },
19
+ { code: "DZ", name: "Algeria", dialCode: "213", flag: "🇩🇿", format: "### ## ## ##", priority: 0 },
20
+ { code: "AR", name: "Argentina", dialCode: "54", flag: "🇦🇷", format: "## ####-####", priority: 0 },
21
+ { code: "AU", name: "Australia", dialCode: "61", flag: "🇦🇺", format: "#### ### ###", priority: 0 },
22
+ { code: "AT", name: "Austria", dialCode: "43", flag: "🇦🇹", format: "### #######", priority: 0 },
23
+ { code: "BD", name: "Bangladesh", dialCode: "880", flag: "🇧🇩", format: "#### ######", priority: 0 },
24
+ { code: "BE", name: "Belgium", dialCode: "32", flag: "🇧🇪", format: "### ## ## ##", priority: 0 },
25
+ { code: "BR", name: "Brazil", dialCode: "55", flag: "🇧🇷", format: "(##) #####-####", priority: 0 },
26
+ { code: "CA", name: "Canada", dialCode: "1", flag: "🇨🇦", format: "(###) ###-####", priority: 1 },
27
+ { code: "CL", name: "Chile", dialCode: "56", flag: "🇨🇱", format: "# #### ####", priority: 0 },
28
+ { code: "CN", name: "China", dialCode: "86", flag: "🇨🇳", format: "### #### ####", priority: 0 },
29
+ { code: "CO", name: "Colombia", dialCode: "57", flag: "🇨🇴", format: "### ### ####", priority: 0 },
30
+ { code: "CR", name: "Costa Rica", dialCode: "506", flag: "🇨🇷", format: "#### ####", priority: 0 },
31
+ { code: "CZ", name: "Czech Republic", dialCode: "420", flag: "🇨🇿", format: "### ### ###", priority: 0 },
32
+ { code: "DK", name: "Denmark", dialCode: "45", flag: "🇩🇰", format: "## ## ## ##", priority: 0 },
33
+ { code: "DO", name: "Dominican Republic", dialCode: "1", flag: "🇩🇴", format: "(###) ###-####", priority: 2 },
34
+ { code: "EC", name: "Ecuador", dialCode: "593", flag: "🇪🇨", format: "## ### ####", priority: 0 },
35
+ { code: "EG", name: "Egypt", dialCode: "20", flag: "🇪🇬", format: "### ### ####", priority: 0 },
36
+ { code: "FI", name: "Finland", dialCode: "358", flag: "🇫🇮", format: "## ### ## ##", priority: 0 },
37
+ { code: "FR", name: "France", dialCode: "33", flag: "🇫🇷", format: "# ## ## ## ##", priority: 0 },
38
+ { code: "DE", name: "Germany", dialCode: "49", flag: "🇩🇪", format: "#### #######", priority: 0 },
39
+ { code: "GH", name: "Ghana", dialCode: "233", flag: "🇬🇭", format: "## ### ####", priority: 0 },
40
+ { code: "GR", name: "Greece", dialCode: "30", flag: "🇬🇷", format: "### ### ####", priority: 0 },
41
+ { code: "GT", name: "Guatemala", dialCode: "502", flag: "🇬🇹", format: "#### ####", priority: 0 },
42
+ { code: "HK", name: "Hong Kong", dialCode: "852", flag: "🇭🇰", format: "#### ####", priority: 0 },
43
+ { code: "HU", name: "Hungary", dialCode: "36", flag: "🇭🇺", format: "## ### ####", priority: 0 },
44
+ { code: "IN", name: "India", dialCode: "91", flag: "🇮🇳", format: "#####-#####", priority: 0 },
45
+ { code: "ID", name: "Indonesia", dialCode: "62", flag: "🇮🇩", format: "### #### ####", priority: 0 },
46
+ { code: "IE", name: "Ireland", dialCode: "353", flag: "🇮🇪", format: "## ### ####", priority: 0 },
47
+ { code: "IL", name: "Israel", dialCode: "972", flag: "🇮🇱", format: "##-###-####", priority: 0 },
48
+ { code: "IT", name: "Italy", dialCode: "39", flag: "🇮🇹", format: "### ### ####", priority: 0 },
49
+ { code: "JM", name: "Jamaica", dialCode: "1", flag: "🇯🇲", format: "(###) ###-####", priority: 3 },
50
+ { code: "JP", name: "Japan", dialCode: "81", flag: "🇯🇵", format: "##-####-####", priority: 0 },
51
+ { code: "KE", name: "Kenya", dialCode: "254", flag: "🇰🇪", format: "### ######", priority: 0 },
52
+ { code: "KR", name: "South Korea", dialCode: "82", flag: "🇰🇷", format: "##-####-####", priority: 0 },
53
+ { code: "MY", name: "Malaysia", dialCode: "60", flag: "🇲🇾", format: "##-### ####", priority: 0 },
54
+ { code: "MX", name: "Mexico", dialCode: "52", flag: "🇲🇽", format: "## #### ####", priority: 0 },
55
+ { code: "MA", name: "Morocco", dialCode: "212", flag: "🇲🇦", format: "##-### ####", priority: 0 },
56
+ { code: "NL", name: "Netherlands", dialCode: "31", flag: "🇳🇱", format: "# ## ## ## ##", priority: 0 },
57
+ { code: "NZ", name: "New Zealand", dialCode: "64", flag: "🇳🇿", format: "## ### ####", priority: 0 },
58
+ { code: "NG", name: "Nigeria", dialCode: "234", flag: "🇳🇬", format: "### ### ####", priority: 0 },
59
+ { code: "NO", name: "Norway", dialCode: "47", flag: "🇳🇴", format: "### ## ###", priority: 0 },
60
+ { code: "PK", name: "Pakistan", dialCode: "92", flag: "🇵🇰", format: "### #######", priority: 0 },
61
+ { code: "PA", name: "Panama", dialCode: "507", flag: "🇵🇦", format: "####-####", priority: 0 },
62
+ { code: "PE", name: "Peru", dialCode: "51", flag: "🇵🇪", format: "### ### ###", priority: 0 },
63
+ { code: "PH", name: "Philippines", dialCode: "63", flag: "🇵🇭", format: "### ### ####", priority: 0 },
64
+ { code: "PL", name: "Poland", dialCode: "48", flag: "🇵🇱", format: "### ### ###", priority: 0 },
65
+ { code: "PT", name: "Portugal", dialCode: "351", flag: "🇵🇹", format: "### ### ###", priority: 0 },
66
+ { code: "PR", name: "Puerto Rico", dialCode: "1", flag: "🇵🇷", format: "(###) ###-####", priority: 4 },
67
+ { code: "RO", name: "Romania", dialCode: "40", flag: "🇷🇴", format: "### ### ###", priority: 0 },
68
+ { code: "RU", name: "Russia", dialCode: "7", flag: "🇷🇺", format: "### ###-##-##", priority: 0 },
69
+ { code: "SA", name: "Saudi Arabia", dialCode: "966", flag: "🇸🇦", format: "## ### ####", priority: 0 },
70
+ { code: "SG", name: "Singapore", dialCode: "65", flag: "🇸🇬", format: "#### ####", priority: 0 },
71
+ { code: "ZA", name: "South Africa", dialCode: "27", flag: "🇿🇦", format: "## ### ####", priority: 0 },
72
+ { code: "ES", name: "Spain", dialCode: "34", flag: "🇪🇸", format: "### ## ## ##", priority: 0 },
73
+ { code: "SE", name: "Sweden", dialCode: "46", flag: "🇸🇪", format: "##-### ## ##", priority: 0 },
74
+ { code: "CH", name: "Switzerland", dialCode: "41", flag: "🇨🇭", format: "## ### ## ##", priority: 0 },
75
+ { code: "TW", name: "Taiwan", dialCode: "886", flag: "🇹🇼", format: "### ### ###", priority: 0 },
76
+ { code: "TH", name: "Thailand", dialCode: "66", flag: "🇹🇭", format: "## ### ####", priority: 0 },
77
+ { code: "TR", name: "Turkey", dialCode: "90", flag: "🇹🇷", format: "### ### ## ##", priority: 0 },
78
+ { code: "UA", name: "Ukraine", dialCode: "380", flag: "🇺🇦", format: "## ### ## ##", priority: 0 },
79
+ { code: "AE", name: "United Arab Emirates", dialCode: "971", flag: "🇦🇪", format: "## ### ####", priority: 0 },
80
+ { code: "GB", name: "United Kingdom", dialCode: "44", flag: "🇬🇧", format: "#### ######", priority: 0 },
81
+ { code: "US", name: "United States", dialCode: "1", flag: "🇺🇸", format: "(###) ###-####", priority: 0 },
82
+ { code: "VE", name: "Venezuela", dialCode: "58", flag: "🇻🇪", format: "###-###-####", priority: 0 },
83
+ { code: "VN", name: "Vietnam", dialCode: "84", flag: "🇻🇳", format: "## ### ## ##", priority: 0 },
84
+ ];
85
+
86
+ export function getCountryByCode(code: string): CountryData | undefined {
87
+ return COUNTRIES.find((c) => c.code === code);
88
+ }
@@ -1,4 +1,5 @@
1
1
  export * from "./use-screen-size";
2
2
  export * from "./use-currency-mask";
3
3
  export * from "./use-numeric-mask";
4
+ export * from "./use-phone-mask";
4
5
  export * from "./use-relative-position";
@@ -0,0 +1,183 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ import {
3
+ type CountryData,
4
+ COUNTRIES,
5
+ getCountryByCode,
6
+ } from "../data/countries";
7
+
8
+ export interface UsePhoneMaskOptions {
9
+ value?: string;
10
+ defaultCountry?: string;
11
+ onChange?: (e164Value: string) => void;
12
+ onCountryChange?: (country: CountryData) => void;
13
+ countries?: CountryData[];
14
+ }
15
+
16
+ export interface UsePhoneMaskReturn {
17
+ displayValue: string;
18
+ e164Value: string;
19
+ country: CountryData;
20
+ countries: CountryData[];
21
+ onChangeText: (text: string) => void;
22
+ setCountry: (countryCode: string) => void;
23
+ setValue: (e164: string) => void;
24
+ keyboardType: "phone-pad";
25
+ }
26
+
27
+ function stripToDigits(text: string): string {
28
+ return text.replace(/\D/g, "");
29
+ }
30
+
31
+ function formatNational(digits: string, format: string): string {
32
+ let result = "";
33
+ let digitIndex = 0;
34
+ for (let i = 0; i < format.length && digitIndex < digits.length; i++) {
35
+ if (format[i] === "#") {
36
+ result += digits[digitIndex];
37
+ digitIndex++;
38
+ } else {
39
+ result += format[i];
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+
45
+ function toE164(dialCode: string, nationalDigits: string): string {
46
+ return `+${dialCode}${nationalDigits}`;
47
+ }
48
+
49
+ function getMaxDigits(format: string): number {
50
+ return format.split("").filter((c) => c === "#").length;
51
+ }
52
+
53
+ function parseE164(
54
+ e164: string,
55
+ countries: CountryData[],
56
+ ): { country: CountryData; nationalDigits: string } | null {
57
+ if (!e164.startsWith("+")) return null;
58
+ const digits = e164.slice(1);
59
+
60
+ const sorted = [...countries].sort(
61
+ (a, b) => b.dialCode.length - a.dialCode.length,
62
+ );
63
+
64
+ for (const country of sorted) {
65
+ if (digits.startsWith(country.dialCode)) {
66
+ return {
67
+ country,
68
+ nationalDigits: digits.slice(country.dialCode.length),
69
+ };
70
+ }
71
+ }
72
+ return null;
73
+ }
74
+
75
+ export function usePhoneMask({
76
+ value: controlledValue,
77
+ defaultCountry = "US",
78
+ onChange,
79
+ onCountryChange,
80
+ countries: customCountries,
81
+ }: UsePhoneMaskOptions = {}): UsePhoneMaskReturn {
82
+ const availableCountries = customCountries ?? COUNTRIES;
83
+ const isInternalChange = useRef(false);
84
+
85
+ const [country, setCountryState] = useState<CountryData>(
86
+ () => getCountryByCode(defaultCountry) ?? availableCountries[0]!,
87
+ );
88
+ const [nationalDigits, setNationalDigits] = useState<string>("");
89
+ const [displayValue, setDisplayValue] = useState<string>("");
90
+
91
+ useEffect(() => {
92
+ if (isInternalChange.current) {
93
+ isInternalChange.current = false;
94
+ return;
95
+ }
96
+
97
+ if (controlledValue) {
98
+ const parsed = parseE164(controlledValue, availableCountries);
99
+ if (parsed) {
100
+ setCountryState(parsed.country);
101
+ setNationalDigits(parsed.nationalDigits);
102
+ setDisplayValue(
103
+ formatNational(parsed.nationalDigits, parsed.country.format),
104
+ );
105
+ }
106
+ } else {
107
+ setNationalDigits("");
108
+ setDisplayValue("");
109
+ }
110
+ }, [controlledValue]);
111
+
112
+ const onChangeText = useCallback(
113
+ (text: string) => {
114
+ const digits = stripToDigits(text);
115
+ const maxDigits = getMaxDigits(country.format);
116
+ const trimmed = digits.slice(0, maxDigits);
117
+
118
+ setNationalDigits(trimmed);
119
+ setDisplayValue(formatNational(trimmed, country.format));
120
+
121
+ const e164 = trimmed.length > 0 ? toE164(country.dialCode, trimmed) : "";
122
+ isInternalChange.current = true;
123
+ onChange?.(e164);
124
+ },
125
+ [country, onChange],
126
+ );
127
+
128
+ const handleSetCountry = useCallback(
129
+ (countryCode: string) => {
130
+ const newCountry = availableCountries.find((c) => c.code === countryCode);
131
+ if (!newCountry) return;
132
+
133
+ setCountryState(newCountry);
134
+ onCountryChange?.(newCountry);
135
+
136
+ const maxDigits = getMaxDigits(newCountry.format);
137
+ const trimmed = nationalDigits.slice(0, maxDigits);
138
+ setNationalDigits(trimmed);
139
+ setDisplayValue(formatNational(trimmed, newCountry.format));
140
+
141
+ const e164 =
142
+ trimmed.length > 0 ? toE164(newCountry.dialCode, trimmed) : "";
143
+ isInternalChange.current = true;
144
+ onChange?.(e164);
145
+ },
146
+ [nationalDigits, availableCountries, onChange, onCountryChange],
147
+ );
148
+
149
+ const setValue = useCallback(
150
+ (e164: string) => {
151
+ if (!e164) {
152
+ setNationalDigits("");
153
+ setDisplayValue("");
154
+ isInternalChange.current = true;
155
+ onChange?.("");
156
+ return;
157
+ }
158
+ const parsed = parseE164(e164, availableCountries);
159
+ if (parsed) {
160
+ setCountryState(parsed.country);
161
+ setNationalDigits(parsed.nationalDigits);
162
+ setDisplayValue(
163
+ formatNational(parsed.nationalDigits, parsed.country.format),
164
+ );
165
+ isInternalChange.current = true;
166
+ onChange?.(e164);
167
+ }
168
+ },
169
+ [availableCountries, onChange],
170
+ );
171
+
172
+ return {
173
+ displayValue,
174
+ e164Value:
175
+ nationalDigits.length > 0 ? toE164(country.dialCode, nationalDigits) : "",
176
+ country,
177
+ countries: availableCountries,
178
+ onChangeText,
179
+ setCountry: handleSetCountry,
180
+ setValue,
181
+ keyboardType: "phone-pad",
182
+ };
183
+ }