@tecsinapse/react-core 1.20.0 → 1.21.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 (573) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/components/atoms/Avatar/Avatar.d.ts +1 -1
  3. package/dist/components/atoms/Avatar/Avatar.js +30 -42
  4. package/dist/components/atoms/Avatar/Avatar.js.map +1 -1
  5. package/dist/components/atoms/Avatar/Avatar.stories.d.ts +9 -0
  6. package/dist/components/atoms/Avatar/helpers.js +6 -11
  7. package/dist/components/atoms/Avatar/helpers.js.map +1 -1
  8. package/dist/components/atoms/Avatar/styled.js +41 -54
  9. package/dist/components/atoms/Avatar/styled.js.map +1 -1
  10. package/dist/components/atoms/Badge/Badge.js +17 -23
  11. package/dist/components/atoms/Badge/Badge.js.map +1 -1
  12. package/dist/components/atoms/Badge/styled.js +44 -31
  13. package/dist/components/atoms/Badge/styled.js.map +1 -1
  14. package/dist/components/atoms/BoxContent/BoxContent.js +38 -18
  15. package/dist/components/atoms/BoxContent/BoxContent.js.map +1 -1
  16. package/dist/components/atoms/BoxContent/BoxContent.stories.d.ts +9 -0
  17. package/dist/components/atoms/BoxContent/styled.d.ts +1 -1
  18. package/dist/components/atoms/BoxContent/styled.js +53 -73
  19. package/dist/components/atoms/BoxContent/styled.js.map +1 -1
  20. package/dist/components/atoms/Button/Button.js +77 -51
  21. package/dist/components/atoms/Button/Button.js.map +1 -1
  22. package/dist/components/atoms/Button/States/BaseState.d.ts +1 -1
  23. package/dist/components/atoms/Button/States/BaseState.js +27 -36
  24. package/dist/components/atoms/Button/States/BaseState.js.map +1 -1
  25. package/dist/components/atoms/Button/States/Error.d.ts +1 -1
  26. package/dist/components/atoms/Button/States/Error.js +28 -17
  27. package/dist/components/atoms/Button/States/Error.js.map +1 -1
  28. package/dist/components/atoms/Button/States/Loading.d.ts +1 -1
  29. package/dist/components/atoms/Button/States/Loading.js +26 -35
  30. package/dist/components/atoms/Button/States/Loading.js.map +1 -1
  31. package/dist/components/atoms/Button/States/Success.d.ts +1 -1
  32. package/dist/components/atoms/Button/States/Success.js +28 -17
  33. package/dist/components/atoms/Button/States/Success.js.map +1 -1
  34. package/dist/components/atoms/Button/States/styled.js +17 -39
  35. package/dist/components/atoms/Button/States/styled.js.map +1 -1
  36. package/dist/components/atoms/Button/styled.js +52 -50
  37. package/dist/components/atoms/Button/styled.js.map +1 -1
  38. package/dist/components/atoms/Card/Card.js +52 -28
  39. package/dist/components/atoms/Card/Card.js.map +1 -1
  40. package/dist/components/atoms/Card/Card.stories.d.ts +9 -0
  41. package/dist/components/atoms/Card/Footer/Footer.js +10 -21
  42. package/dist/components/atoms/Card/Footer/Footer.js.map +1 -1
  43. package/dist/components/atoms/Card/Header/Header.js +10 -21
  44. package/dist/components/atoms/Card/Header/Header.js.map +1 -1
  45. package/dist/components/atoms/Card/styled.js +14 -17
  46. package/dist/components/atoms/Card/styled.js.map +1 -1
  47. package/dist/components/atoms/Checkbox/Checkbox.js +66 -39
  48. package/dist/components/atoms/Checkbox/Checkbox.js.map +1 -1
  49. package/dist/components/atoms/Checkbox/Checkbox.stories.d.ts +9 -0
  50. package/dist/components/atoms/Checkbox/styled.js +39 -68
  51. package/dist/components/atoms/Checkbox/styled.js.map +1 -1
  52. package/dist/components/atoms/Divider/Divider.js +38 -18
  53. package/dist/components/atoms/Divider/Divider.js.map +1 -1
  54. package/dist/components/atoms/Divider/Divider.stories.d.ts +9 -0
  55. package/dist/components/atoms/Divider/styled.js +30 -43
  56. package/dist/components/atoms/Divider/styled.js.map +1 -1
  57. package/dist/components/atoms/GroupButton/GroupButton.js +68 -47
  58. package/dist/components/atoms/GroupButton/GroupButton.js.map +1 -1
  59. package/dist/components/atoms/GroupButton/GroupButton.stories.d.ts +8 -0
  60. package/dist/components/atoms/GroupButton/GroupButtonOption.js +16 -23
  61. package/dist/components/atoms/GroupButton/GroupButtonOption.js.map +1 -1
  62. package/dist/components/atoms/GroupButton/styled.js +113 -124
  63. package/dist/components/atoms/GroupButton/styled.js.map +1 -1
  64. package/dist/components/atoms/Icon/Icon.js +64 -31
  65. package/dist/components/atoms/Icon/Icon.js.map +1 -1
  66. package/dist/components/atoms/Icon/Icon.stories.d.ts +9 -0
  67. package/dist/components/atoms/Icon/helpers.d.ts +2 -2
  68. package/dist/components/atoms/Icon/helpers.js +110 -77
  69. package/dist/components/atoms/Icon/helpers.js.map +1 -1
  70. package/dist/components/atoms/Input/Hint.js +19 -34
  71. package/dist/components/atoms/Input/Hint.js.map +1 -1
  72. package/dist/components/atoms/Input/InputContainer/InputContainer.js +81 -44
  73. package/dist/components/atoms/Input/InputContainer/InputContainer.js.map +1 -1
  74. package/dist/components/atoms/Input/InputElement/InputElement.js +68 -40
  75. package/dist/components/atoms/Input/InputElement/InputElement.js.map +1 -1
  76. package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.js +109 -83
  77. package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.js.map +1 -1
  78. package/dist/components/atoms/Input/PressableInputContainer/PressableInputContainer.js +67 -31
  79. package/dist/components/atoms/Input/PressableInputContainer/PressableInputContainer.js.map +1 -1
  80. package/dist/components/atoms/Input/PressableInputContainer/styled.js +9 -12
  81. package/dist/components/atoms/Input/PressableInputContainer/styled.js.map +1 -1
  82. package/dist/components/atoms/Input/hooks/useInputFocus.d.ts +1 -1
  83. package/dist/components/atoms/Input/hooks/useInputFocus.js +8 -12
  84. package/dist/components/atoms/Input/hooks/useInputFocus.js.map +1 -1
  85. package/dist/components/atoms/Input/hooks/useNumberMask.d.ts +2 -2
  86. package/dist/components/atoms/Input/hooks/useNumberMask.js +67 -66
  87. package/dist/components/atoms/Input/hooks/useNumberMask.js.map +1 -1
  88. package/dist/components/atoms/Input/hooks/useStringMask.d.ts +1 -1
  89. package/dist/components/atoms/Input/hooks/useStringMask.js +49 -60
  90. package/dist/components/atoms/Input/hooks/useStringMask.js.map +1 -1
  91. package/dist/components/atoms/Input/styled.js +106 -144
  92. package/dist/components/atoms/Input/styled.js.map +1 -1
  93. package/dist/components/atoms/Paper/Paper.js +47 -21
  94. package/dist/components/atoms/Paper/Paper.js.map +1 -1
  95. package/dist/components/atoms/Paper/Paper.stories.d.ts +9 -0
  96. package/dist/components/atoms/Paper/styled.js +14 -17
  97. package/dist/components/atoms/Paper/styled.js.map +1 -1
  98. package/dist/components/atoms/PressableSurface/PressableSurface.js +78 -68
  99. package/dist/components/atoms/PressableSurface/PressableSurface.js.map +1 -1
  100. package/dist/components/atoms/ProgressBar/ProgressBar.js +88 -44
  101. package/dist/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
  102. package/dist/components/atoms/ProgressBar/ProgressBar.stories.d.ts +9 -0
  103. package/dist/components/atoms/ProgressBar/styled.js +39 -51
  104. package/dist/components/atoms/ProgressBar/styled.js.map +1 -1
  105. package/dist/components/atoms/RadioButton/RadioButton.js +60 -33
  106. package/dist/components/atoms/RadioButton/RadioButton.js.map +1 -1
  107. package/dist/components/atoms/RadioButton/RadioButton.stories.d.ts +9 -0
  108. package/dist/components/atoms/RadioButton/styled.js +28 -44
  109. package/dist/components/atoms/RadioButton/styled.js.map +1 -1
  110. package/dist/components/atoms/Switch/Switch.js +94 -73
  111. package/dist/components/atoms/Switch/Switch.js.map +1 -1
  112. package/dist/components/atoms/Switch/Switch.stories.d.ts +9 -0
  113. package/dist/components/atoms/Switch/animation.js +12 -20
  114. package/dist/components/atoms/Switch/animation.js.map +1 -1
  115. package/dist/components/atoms/Switch/styled.js +36 -44
  116. package/dist/components/atoms/Switch/styled.js.map +1 -1
  117. package/dist/components/atoms/Tag/Tag.js +65 -45
  118. package/dist/components/atoms/Tag/Tag.js.map +1 -1
  119. package/dist/components/atoms/Tag/styled.js +43 -63
  120. package/dist/components/atoms/Tag/styled.js.map +1 -1
  121. package/dist/components/atoms/Text/Text.js +71 -37
  122. package/dist/components/atoms/Text/Text.js.map +1 -1
  123. package/dist/components/atoms/Text/Text.stories.d.ts +9 -0
  124. package/dist/components/atoms/Text/functions.js +5 -10
  125. package/dist/components/atoms/Text/functions.js.map +1 -1
  126. package/dist/components/atoms/Text/styled.js +29 -67
  127. package/dist/components/atoms/Text/styled.js.map +1 -1
  128. package/dist/components/atoms/shared/PaperAndCard.d.ts +1 -1
  129. package/dist/components/atoms/shared/PaperAndCard.js +17 -32
  130. package/dist/components/atoms/shared/PaperAndCard.js.map +1 -1
  131. package/dist/components/molecules/Calendar/Calendar.js +148 -98
  132. package/dist/components/molecules/Calendar/Calendar.js.map +1 -1
  133. package/dist/components/molecules/Calendar/Calendar.stories.d.ts +8 -0
  134. package/dist/components/molecules/Calendar/components/MonthWeek.js +92 -125
  135. package/dist/components/molecules/Calendar/components/MonthWeek.js.map +1 -1
  136. package/dist/components/molecules/Calendar/components/Weekdays.js +16 -29
  137. package/dist/components/molecules/Calendar/components/Weekdays.js.map +1 -1
  138. package/dist/components/molecules/Calendar/styled.js +88 -91
  139. package/dist/components/molecules/Calendar/styled.js.map +1 -1
  140. package/dist/components/molecules/DatePicker/DatePicker.js +133 -86
  141. package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
  142. package/dist/components/molecules/DatePicker/styled.js +34 -40
  143. package/dist/components/molecules/DatePicker/styled.js.map +1 -1
  144. package/dist/components/molecules/DateTimePicker/DateTimePicker.js +150 -85
  145. package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
  146. package/dist/components/molecules/DateTimePicker/styled.js +10 -18
  147. package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
  148. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js +174 -146
  149. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
  150. package/dist/components/molecules/DateTimeSelector/Selector.js +101 -69
  151. package/dist/components/molecules/DateTimeSelector/Selector.js.map +1 -1
  152. package/dist/components/molecules/DateTimeSelector/styled.js +67 -105
  153. package/dist/components/molecules/DateTimeSelector/styled.js.map +1 -1
  154. package/dist/components/molecules/Grid/functions.d.ts +1 -1
  155. package/dist/components/molecules/Grid/functions.js +22 -16
  156. package/dist/components/molecules/Grid/functions.js.map +1 -1
  157. package/dist/components/molecules/HintInputContainer/HintInputContainer.js +84 -36
  158. package/dist/components/molecules/HintInputContainer/HintInputContainer.js.map +1 -1
  159. package/dist/components/molecules/IconTextButton/IconComponent.js +38 -31
  160. package/dist/components/molecules/IconTextButton/IconComponent.js.map +1 -1
  161. package/dist/components/molecules/InputPassword/InputPasswordIcon.js +53 -28
  162. package/dist/components/molecules/InputPassword/InputPasswordIcon.js.map +1 -1
  163. package/dist/components/molecules/InputPassword/styled.js +15 -18
  164. package/dist/components/molecules/InputPassword/styled.js.map +1 -1
  165. package/dist/components/molecules/Snackbar/Snackbar.d.ts +1 -1
  166. package/dist/components/molecules/Snackbar/Snackbar.js +64 -71
  167. package/dist/components/molecules/Snackbar/Snackbar.js.map +1 -1
  168. package/dist/components/molecules/Snackbar/styled.js +92 -73
  169. package/dist/components/molecules/Snackbar/styled.js.map +1 -1
  170. package/dist/components/molecules/TextArea/TextArea.js +63 -72
  171. package/dist/components/molecules/TextArea/TextArea.js.map +1 -1
  172. package/dist/components/molecules/TextArea/styled.js +33 -27
  173. package/dist/components/molecules/TextArea/styled.js.map +1 -1
  174. package/dist/hooks/useDebouncedState.js +14 -14
  175. package/dist/hooks/useDebouncedState.js.map +1 -1
  176. package/dist/hooks/useTheme.js +5 -8
  177. package/dist/hooks/useTheme.js.map +1 -1
  178. package/dist/index.js +141 -455
  179. package/dist/index.js.map +1 -1
  180. package/dist/styles/ThemeProvider.js +13 -19
  181. package/dist/styles/ThemeProvider.js.map +1 -1
  182. package/dist/styles/definitions.js +107 -104
  183. package/dist/styles/definitions.js.map +1 -1
  184. package/dist/styles/light.js +47 -36
  185. package/dist/styles/light.js.map +1 -1
  186. package/dist/utils/IPhoneXHelper.js +13 -19
  187. package/dist/utils/IPhoneXHelper.js.map +1 -1
  188. package/dist/utils/ResponsiveFontSize.d.ts +1 -1
  189. package/dist/utils/ResponsiveFontSize.js +22 -42
  190. package/dist/utils/ResponsiveFontSize.js.map +1 -1
  191. package/dist/utils/extractNumbersFromString.js +6 -11
  192. package/dist/utils/extractNumbersFromString.js.map +1 -1
  193. package/dist/utils/formatWithMask.js +23 -20
  194. package/dist/utils/formatWithMask.js.map +1 -1
  195. package/dist/utils/lightenDarkenColor.js +19 -15
  196. package/dist/utils/lightenDarkenColor.js.map +1 -1
  197. package/dist/utils/masks.js +16 -18
  198. package/dist/utils/masks.js.map +1 -1
  199. package/dist/utils/variantComplement.js +24 -25
  200. package/dist/utils/variantComplement.js.map +1 -1
  201. package/esm/components/atoms/Avatar/Avatar.d.ts +1 -1
  202. package/esm/components/atoms/Avatar/Avatar.js +25 -43
  203. package/esm/components/atoms/Avatar/Avatar.js.map +1 -1
  204. package/esm/components/atoms/Avatar/helpers.js +6 -8
  205. package/esm/components/atoms/Avatar/helpers.js.map +1 -1
  206. package/esm/components/atoms/Avatar/styled.js +32 -30
  207. package/esm/components/atoms/Avatar/styled.js.map +1 -1
  208. package/esm/components/atoms/Badge/Badge.js +15 -16
  209. package/esm/components/atoms/Badge/Badge.js.map +1 -1
  210. package/esm/components/atoms/Badge/styled.js +34 -15
  211. package/esm/components/atoms/Badge/styled.js.map +1 -1
  212. package/esm/components/atoms/BoxContent/BoxContent.js +35 -15
  213. package/esm/components/atoms/BoxContent/BoxContent.js.map +1 -1
  214. package/esm/components/atoms/BoxContent/styled.d.ts +3 -16
  215. package/esm/components/atoms/BoxContent/styled.js +48 -49
  216. package/esm/components/atoms/BoxContent/styled.js.map +1 -1
  217. package/esm/components/atoms/Button/Button.js +79 -56
  218. package/esm/components/atoms/Button/Button.js.map +1 -1
  219. package/esm/components/atoms/Button/States/BaseState.d.ts +1 -1
  220. package/esm/components/atoms/Button/States/BaseState.js +22 -22
  221. package/esm/components/atoms/Button/States/BaseState.js.map +1 -1
  222. package/esm/components/atoms/Button/States/Error.d.ts +1 -1
  223. package/esm/components/atoms/Button/States/Error.js +26 -7
  224. package/esm/components/atoms/Button/States/Error.js.map +1 -1
  225. package/esm/components/atoms/Button/States/Loading.d.ts +1 -1
  226. package/esm/components/atoms/Button/States/Loading.js +20 -20
  227. package/esm/components/atoms/Button/States/Loading.js.map +1 -1
  228. package/esm/components/atoms/Button/States/Success.d.ts +1 -1
  229. package/esm/components/atoms/Button/States/Success.js +26 -7
  230. package/esm/components/atoms/Button/States/Success.js.map +1 -1
  231. package/esm/components/atoms/Button/States/styled.d.ts +2 -11
  232. package/esm/components/atoms/Button/States/styled.js +13 -22
  233. package/esm/components/atoms/Button/States/styled.js.map +1 -1
  234. package/esm/components/atoms/Button/styled.js +43 -35
  235. package/esm/components/atoms/Button/styled.js.map +1 -1
  236. package/esm/components/atoms/Card/Card.js +52 -27
  237. package/esm/components/atoms/Card/Card.js.map +1 -1
  238. package/esm/components/atoms/Card/Footer/Footer.js +6 -10
  239. package/esm/components/atoms/Card/Footer/Footer.js.map +1 -1
  240. package/esm/components/atoms/Card/Header/Header.js +6 -10
  241. package/esm/components/atoms/Card/Header/Header.js.map +1 -1
  242. package/esm/components/atoms/Card/styled.d.ts +1 -8
  243. package/esm/components/atoms/Card/styled.js +11 -9
  244. package/esm/components/atoms/Card/styled.js.map +1 -1
  245. package/esm/components/atoms/Checkbox/Checkbox.js +66 -40
  246. package/esm/components/atoms/Checkbox/Checkbox.js.map +1 -1
  247. package/esm/components/atoms/Checkbox/styled.d.ts +3 -7
  248. package/esm/components/atoms/Checkbox/styled.js +35 -48
  249. package/esm/components/atoms/Checkbox/styled.js.map +1 -1
  250. package/esm/components/atoms/Divider/Divider.js +35 -15
  251. package/esm/components/atoms/Divider/Divider.js.map +1 -1
  252. package/esm/components/atoms/Divider/styled.d.ts +1 -13
  253. package/esm/components/atoms/Divider/styled.js +21 -25
  254. package/esm/components/atoms/Divider/styled.js.map +1 -1
  255. package/esm/components/atoms/GroupButton/GroupButton.js +83 -62
  256. package/esm/components/atoms/GroupButton/GroupButton.js.map +1 -1
  257. package/esm/components/atoms/GroupButton/GroupButtonOption.js +13 -13
  258. package/esm/components/atoms/GroupButton/GroupButtonOption.js.map +1 -1
  259. package/esm/components/atoms/GroupButton/styled.js +101 -84
  260. package/esm/components/atoms/GroupButton/styled.js.map +1 -1
  261. package/esm/components/atoms/Icon/Icon.js +64 -33
  262. package/esm/components/atoms/Icon/Icon.js.map +1 -1
  263. package/esm/components/atoms/Icon/helpers.d.ts +1 -1
  264. package/esm/components/atoms/Icon/helpers.js +88 -64
  265. package/esm/components/atoms/Icon/helpers.js.map +1 -1
  266. package/esm/components/atoms/Input/Hint.js +18 -26
  267. package/esm/components/atoms/Input/Hint.js.map +1 -1
  268. package/esm/components/atoms/Input/InputContainer/InputContainer.js +88 -55
  269. package/esm/components/atoms/Input/InputContainer/InputContainer.js.map +1 -1
  270. package/esm/components/atoms/Input/InputElement/InputElement.js +64 -34
  271. package/esm/components/atoms/Input/InputElement/InputElement.js.map +1 -1
  272. package/esm/components/atoms/Input/InputMaskElement/InputMaskElement.js +102 -87
  273. package/esm/components/atoms/Input/InputMaskElement/InputMaskElement.js.map +1 -1
  274. package/esm/components/atoms/Input/PressableInputContainer/PressableInputContainer.js +50 -25
  275. package/esm/components/atoms/Input/PressableInputContainer/PressableInputContainer.js.map +1 -1
  276. package/esm/components/atoms/Input/PressableInputContainer/styled.js +6 -5
  277. package/esm/components/atoms/Input/PressableInputContainer/styled.js.map +1 -1
  278. package/esm/components/atoms/Input/hooks/useInputFocus.d.ts +1 -1
  279. package/esm/components/atoms/Input/hooks/useInputFocus.js +11 -26
  280. package/esm/components/atoms/Input/hooks/useInputFocus.js.map +1 -1
  281. package/esm/components/atoms/Input/hooks/useNumberMask.d.ts +2 -2
  282. package/esm/components/atoms/Input/hooks/useNumberMask.js +67 -84
  283. package/esm/components/atoms/Input/hooks/useNumberMask.js.map +1 -1
  284. package/esm/components/atoms/Input/hooks/useStringMask.d.ts +1 -1
  285. package/esm/components/atoms/Input/hooks/useStringMask.js +58 -79
  286. package/esm/components/atoms/Input/hooks/useStringMask.js.map +1 -1
  287. package/esm/components/atoms/Input/styled.js +91 -89
  288. package/esm/components/atoms/Input/styled.js.map +1 -1
  289. package/esm/components/atoms/Paper/Paper.js +45 -20
  290. package/esm/components/atoms/Paper/Paper.js.map +1 -1
  291. package/esm/components/atoms/Paper/styled.d.ts +1 -9
  292. package/esm/components/atoms/Paper/styled.js +11 -9
  293. package/esm/components/atoms/Paper/styled.js.map +1 -1
  294. package/esm/components/atoms/PressableSurface/PressableSurface.js +83 -66
  295. package/esm/components/atoms/PressableSurface/PressableSurface.js.map +1 -1
  296. package/esm/components/atoms/ProgressBar/ProgressBar.js +79 -64
  297. package/esm/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
  298. package/esm/components/atoms/ProgressBar/styled.js +30 -24
  299. package/esm/components/atoms/ProgressBar/styled.js.map +1 -1
  300. package/esm/components/atoms/RadioButton/RadioButton.js +61 -35
  301. package/esm/components/atoms/RadioButton/RadioButton.js.map +1 -1
  302. package/esm/components/atoms/RadioButton/styled.js +24 -28
  303. package/esm/components/atoms/RadioButton/styled.js.map +1 -1
  304. package/esm/components/atoms/Switch/Switch.js +88 -62
  305. package/esm/components/atoms/Switch/Switch.js.map +1 -1
  306. package/esm/components/atoms/Switch/animation.js +7 -5
  307. package/esm/components/atoms/Switch/animation.js.map +1 -1
  308. package/esm/components/atoms/Switch/styled.d.ts +2 -14
  309. package/esm/components/atoms/Switch/styled.js +27 -22
  310. package/esm/components/atoms/Switch/styled.js.map +1 -1
  311. package/esm/components/atoms/Tag/Tag.js +69 -63
  312. package/esm/components/atoms/Tag/Tag.js.map +1 -1
  313. package/esm/components/atoms/Tag/styled.js +31 -35
  314. package/esm/components/atoms/Tag/styled.js.map +1 -1
  315. package/esm/components/atoms/Text/Text.js +72 -43
  316. package/esm/components/atoms/Text/Text.js.map +1 -1
  317. package/esm/components/atoms/Text/functions.js +5 -7
  318. package/esm/components/atoms/Text/functions.js.map +1 -1
  319. package/esm/components/atoms/Text/styled.d.ts +2 -16
  320. package/esm/components/atoms/Text/styled.js +19 -43
  321. package/esm/components/atoms/Text/styled.js.map +1 -1
  322. package/esm/components/atoms/shared/PaperAndCard.d.ts +1 -3
  323. package/esm/components/atoms/shared/PaperAndCard.js +16 -20
  324. package/esm/components/atoms/shared/PaperAndCard.js.map +1 -1
  325. package/esm/components/molecules/Calendar/Calendar.js +130 -124
  326. package/esm/components/molecules/Calendar/Calendar.js.map +1 -1
  327. package/esm/components/molecules/Calendar/components/MonthWeek.js +80 -98
  328. package/esm/components/molecules/Calendar/components/MonthWeek.js.map +1 -1
  329. package/esm/components/molecules/Calendar/components/Weekdays.js +19 -25
  330. package/esm/components/molecules/Calendar/components/Weekdays.js.map +1 -1
  331. package/esm/components/molecules/Calendar/styled.js +79 -52
  332. package/esm/components/molecules/Calendar/styled.js.map +1 -1
  333. package/esm/components/molecules/DatePicker/DatePicker.js +131 -95
  334. package/esm/components/molecules/DatePicker/DatePicker.js.map +1 -1
  335. package/esm/components/molecules/DatePicker/styled.js +25 -19
  336. package/esm/components/molecules/DatePicker/styled.js.map +1 -1
  337. package/esm/components/molecules/DateTimePicker/DateTimePicker.js +155 -102
  338. package/esm/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
  339. package/esm/components/molecules/DateTimePicker/styled.js +8 -10
  340. package/esm/components/molecules/DateTimePicker/styled.js.map +1 -1
  341. package/esm/components/molecules/DateTimeSelector/DateTimeSelector.js +175 -179
  342. package/esm/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
  343. package/esm/components/molecules/DateTimeSelector/Selector.js +93 -82
  344. package/esm/components/molecules/DateTimeSelector/Selector.js.map +1 -1
  345. package/esm/components/molecules/DateTimeSelector/styled.js +54 -52
  346. package/esm/components/molecules/DateTimeSelector/styled.js.map +1 -1
  347. package/esm/components/molecules/Grid/functions.d.ts +1 -1
  348. package/esm/components/molecules/Grid/functions.js +23 -13
  349. package/esm/components/molecules/Grid/functions.js.map +1 -1
  350. package/esm/components/molecules/HintInputContainer/HintInputContainer.js +71 -36
  351. package/esm/components/molecules/HintInputContainer/HintInputContainer.js.map +1 -1
  352. package/esm/components/molecules/IconTextButton/IconComponent.js +31 -17
  353. package/esm/components/molecules/IconTextButton/IconComponent.js.map +1 -1
  354. package/esm/components/molecules/InputPassword/InputPasswordIcon.js +48 -24
  355. package/esm/components/molecules/InputPassword/InputPasswordIcon.js.map +1 -1
  356. package/esm/components/molecules/InputPassword/styled.js +12 -9
  357. package/esm/components/molecules/InputPassword/styled.js.map +1 -1
  358. package/esm/components/molecules/Snackbar/Snackbar.d.ts +1 -1
  359. package/esm/components/molecules/Snackbar/Snackbar.js +64 -65
  360. package/esm/components/molecules/Snackbar/Snackbar.js.map +1 -1
  361. package/esm/components/molecules/Snackbar/styled.js +84 -48
  362. package/esm/components/molecules/Snackbar/styled.js.map +1 -1
  363. package/esm/components/molecules/TextArea/TextArea.js +66 -67
  364. package/esm/components/molecules/TextArea/TextArea.js.map +1 -1
  365. package/esm/components/molecules/TextArea/styled.d.ts +2 -12
  366. package/esm/components/molecules/TextArea/styled.js +25 -12
  367. package/esm/components/molecules/TextArea/styled.js.map +1 -1
  368. package/esm/hooks/useDebouncedState.js +13 -28
  369. package/esm/hooks/useDebouncedState.js.map +1 -1
  370. package/esm/hooks/useTheme.js +6 -5
  371. package/esm/hooks/useTheme.js.map +1 -1
  372. package/esm/index.js +55 -36
  373. package/esm/index.js.map +1 -1
  374. package/esm/styles/ThemeProvider.js +10 -9
  375. package/esm/styles/ThemeProvider.js.map +1 -1
  376. package/esm/styles/definitions.js +107 -117
  377. package/esm/styles/definitions.js.map +1 -1
  378. package/esm/styles/light.js +44 -31
  379. package/esm/styles/light.js.map +1 -1
  380. package/esm/utils/IPhoneXHelper.js +11 -9
  381. package/esm/utils/IPhoneXHelper.js.map +1 -1
  382. package/esm/utils/ResponsiveFontSize.d.ts +1 -1
  383. package/esm/utils/ResponsiveFontSize.js +26 -31
  384. package/esm/utils/ResponsiveFontSize.js.map +1 -1
  385. package/esm/utils/extractNumbersFromString.js +5 -7
  386. package/esm/utils/extractNumbersFromString.js.map +1 -1
  387. package/esm/utils/formatWithMask.js +20 -13
  388. package/esm/utils/formatWithMask.js.map +1 -1
  389. package/esm/utils/lightenDarkenColor.js +23 -14
  390. package/esm/utils/lightenDarkenColor.js.map +1 -1
  391. package/esm/utils/masks.js +18 -17
  392. package/esm/utils/masks.js.map +1 -1
  393. package/esm/utils/variantComplement.js +23 -21
  394. package/esm/utils/variantComplement.js.map +1 -1
  395. package/package.json +4 -7
  396. package/rollup.config.js +36 -0
  397. package/src/components/atoms/Avatar/Avatar.stories.tsx +2 -3
  398. package/src/components/atoms/Avatar/Avatar.tsx +1 -1
  399. package/src/components/atoms/Button/States/BaseState.tsx +1 -1
  400. package/src/components/atoms/Button/States/Error.tsx +2 -2
  401. package/src/components/atoms/Button/States/Loading.tsx +1 -1
  402. package/src/components/atoms/Button/States/Success.tsx +2 -2
  403. package/src/components/atoms/Icon/Icon.tsx +6 -2
  404. package/src/components/atoms/Icon/helpers.ts +18 -16
  405. package/src/components/molecules/Grid/functions.ts +2 -6
  406. package/src/components/molecules/IconTextButton/IconComponent.tsx +2 -6
  407. package/src/components/molecules/IconTextButton/{IconTextButton.tsx → IconTextButton.ts} +0 -0
  408. package/src/components/molecules/Snackbar/Snackbar.tsx +1 -1
  409. package/tsconfig.build.json +2 -1
  410. package/babel.config.esm.js +0 -34
  411. package/dist/components/atoms/Avatar/index.js +0 -16
  412. package/dist/components/atoms/Avatar/index.js.map +0 -1
  413. package/dist/components/atoms/Badge/index.js +0 -16
  414. package/dist/components/atoms/Badge/index.js.map +0 -1
  415. package/dist/components/atoms/BoxContent/index.js +0 -16
  416. package/dist/components/atoms/BoxContent/index.js.map +0 -1
  417. package/dist/components/atoms/Button/States/index.js +0 -32
  418. package/dist/components/atoms/Button/States/index.js.map +0 -1
  419. package/dist/components/atoms/Button/index.js +0 -36
  420. package/dist/components/atoms/Button/index.js.map +0 -1
  421. package/dist/components/atoms/Card/Footer/index.js +0 -16
  422. package/dist/components/atoms/Card/Footer/index.js.map +0 -1
  423. package/dist/components/atoms/Card/Header/index.js +0 -16
  424. package/dist/components/atoms/Card/Header/index.js.map +0 -1
  425. package/dist/components/atoms/Card/index.js +0 -16
  426. package/dist/components/atoms/Card/index.js.map +0 -1
  427. package/dist/components/atoms/Checkbox/index.js +0 -16
  428. package/dist/components/atoms/Checkbox/index.js.map +0 -1
  429. package/dist/components/atoms/Divider/index.js +0 -16
  430. package/dist/components/atoms/Divider/index.js.map +0 -1
  431. package/dist/components/atoms/GroupButton/index.js +0 -24
  432. package/dist/components/atoms/GroupButton/index.js.map +0 -1
  433. package/dist/components/atoms/Icon/index.js +0 -16
  434. package/dist/components/atoms/Icon/index.js.map +0 -1
  435. package/dist/components/atoms/Input/PressableInputContainer/index.js +0 -16
  436. package/dist/components/atoms/Input/PressableInputContainer/index.js.map +0 -1
  437. package/dist/components/atoms/Input/index.js +0 -113
  438. package/dist/components/atoms/Input/index.js.map +0 -1
  439. package/dist/components/atoms/Paper/index.js +0 -16
  440. package/dist/components/atoms/Paper/index.js.map +0 -1
  441. package/dist/components/atoms/PressableSurface/index.js +0 -16
  442. package/dist/components/atoms/PressableSurface/index.js.map +0 -1
  443. package/dist/components/atoms/ProgressBar/index.js +0 -16
  444. package/dist/components/atoms/ProgressBar/index.js.map +0 -1
  445. package/dist/components/atoms/RadioButton/index.js +0 -16
  446. package/dist/components/atoms/RadioButton/index.js.map +0 -1
  447. package/dist/components/atoms/Switch/index.js +0 -16
  448. package/dist/components/atoms/Switch/index.js.map +0 -1
  449. package/dist/components/atoms/Tag/index.js +0 -16
  450. package/dist/components/atoms/Tag/index.js.map +0 -1
  451. package/dist/components/atoms/Text/index.js +0 -16
  452. package/dist/components/atoms/Text/index.js.map +0 -1
  453. package/dist/components/molecules/Calendar/components/index.js +0 -24
  454. package/dist/components/molecules/Calendar/components/index.js.map +0 -1
  455. package/dist/components/molecules/Calendar/index.js +0 -16
  456. package/dist/components/molecules/Calendar/index.js.map +0 -1
  457. package/dist/components/molecules/DatePicker/index.js +0 -16
  458. package/dist/components/molecules/DatePicker/index.js.map +0 -1
  459. package/dist/components/molecules/DateTimePicker/index.js +0 -16
  460. package/dist/components/molecules/DateTimePicker/index.js.map +0 -1
  461. package/dist/components/molecules/DateTimeSelector/index.js +0 -16
  462. package/dist/components/molecules/DateTimeSelector/index.js.map +0 -1
  463. package/dist/components/molecules/Grid/index.js +0 -20
  464. package/dist/components/molecules/Grid/index.js.map +0 -1
  465. package/dist/components/molecules/HintInputContainer/index.js +0 -16
  466. package/dist/components/molecules/HintInputContainer/index.js.map +0 -1
  467. package/dist/components/molecules/HintInputContainer/styled.js +0 -2
  468. package/dist/components/molecules/HintInputContainer/styled.js.map +0 -1
  469. package/dist/components/molecules/IconTextButton/IconTextButton.js +0 -6
  470. package/dist/components/molecules/IconTextButton/IconTextButton.js.map +0 -1
  471. package/dist/components/molecules/IconTextButton/index.js +0 -16
  472. package/dist/components/molecules/IconTextButton/index.js.map +0 -1
  473. package/dist/components/molecules/IconTextButton/styled.d.ts +0 -4
  474. package/dist/components/molecules/IconTextButton/styled.js +0 -29
  475. package/dist/components/molecules/IconTextButton/styled.js.map +0 -1
  476. package/dist/components/molecules/InputPassword/index.js +0 -16
  477. package/dist/components/molecules/InputPassword/index.js.map +0 -1
  478. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js +0 -6
  479. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js.map +0 -1
  480. package/dist/components/molecules/LabeledSwitch/index.js +0 -6
  481. package/dist/components/molecules/LabeledSwitch/index.js.map +0 -1
  482. package/dist/components/molecules/Snackbar/index.js +0 -16
  483. package/dist/components/molecules/Snackbar/index.js.map +0 -1
  484. package/dist/components/molecules/TextArea/index.js +0 -24
  485. package/dist/components/molecules/TextArea/index.js.map +0 -1
  486. package/dist/hooks/index.js +0 -22
  487. package/dist/hooks/index.js.map +0 -1
  488. package/dist/types/defaults.js +0 -6
  489. package/dist/types/defaults.js.map +0 -1
  490. package/dist/utils/index.js +0 -103
  491. package/dist/utils/index.js.map +0 -1
  492. package/esm/components/atoms/Avatar/index.js +0 -2
  493. package/esm/components/atoms/Avatar/index.js.map +0 -1
  494. package/esm/components/atoms/Badge/index.js +0 -2
  495. package/esm/components/atoms/Badge/index.js.map +0 -1
  496. package/esm/components/atoms/BoxContent/index.js +0 -2
  497. package/esm/components/atoms/BoxContent/index.js.map +0 -1
  498. package/esm/components/atoms/Button/States/index.js +0 -4
  499. package/esm/components/atoms/Button/States/index.js.map +0 -1
  500. package/esm/components/atoms/Button/index.js +0 -3
  501. package/esm/components/atoms/Button/index.js.map +0 -1
  502. package/esm/components/atoms/Card/Footer/index.js +0 -2
  503. package/esm/components/atoms/Card/Footer/index.js.map +0 -1
  504. package/esm/components/atoms/Card/Header/index.js +0 -2
  505. package/esm/components/atoms/Card/Header/index.js.map +0 -1
  506. package/esm/components/atoms/Card/index.js +0 -2
  507. package/esm/components/atoms/Card/index.js.map +0 -1
  508. package/esm/components/atoms/Checkbox/index.js +0 -2
  509. package/esm/components/atoms/Checkbox/index.js.map +0 -1
  510. package/esm/components/atoms/Divider/index.js +0 -2
  511. package/esm/components/atoms/Divider/index.js.map +0 -1
  512. package/esm/components/atoms/GroupButton/index.js +0 -3
  513. package/esm/components/atoms/GroupButton/index.js.map +0 -1
  514. package/esm/components/atoms/Icon/index.js +0 -2
  515. package/esm/components/atoms/Icon/index.js.map +0 -1
  516. package/esm/components/atoms/Input/PressableInputContainer/index.js +0 -2
  517. package/esm/components/atoms/Input/PressableInputContainer/index.js.map +0 -1
  518. package/esm/components/atoms/Input/index.js +0 -10
  519. package/esm/components/atoms/Input/index.js.map +0 -1
  520. package/esm/components/atoms/Paper/index.js +0 -2
  521. package/esm/components/atoms/Paper/index.js.map +0 -1
  522. package/esm/components/atoms/PressableSurface/index.js +0 -2
  523. package/esm/components/atoms/PressableSurface/index.js.map +0 -1
  524. package/esm/components/atoms/ProgressBar/index.js +0 -2
  525. package/esm/components/atoms/ProgressBar/index.js.map +0 -1
  526. package/esm/components/atoms/RadioButton/index.js +0 -2
  527. package/esm/components/atoms/RadioButton/index.js.map +0 -1
  528. package/esm/components/atoms/Switch/index.js +0 -2
  529. package/esm/components/atoms/Switch/index.js.map +0 -1
  530. package/esm/components/atoms/Tag/index.js +0 -2
  531. package/esm/components/atoms/Tag/index.js.map +0 -1
  532. package/esm/components/atoms/Text/index.js +0 -2
  533. package/esm/components/atoms/Text/index.js.map +0 -1
  534. package/esm/components/molecules/Calendar/components/index.js +0 -3
  535. package/esm/components/molecules/Calendar/components/index.js.map +0 -1
  536. package/esm/components/molecules/Calendar/index.js +0 -2
  537. package/esm/components/molecules/Calendar/index.js.map +0 -1
  538. package/esm/components/molecules/DatePicker/index.js +0 -2
  539. package/esm/components/molecules/DatePicker/index.js.map +0 -1
  540. package/esm/components/molecules/DateTimePicker/index.js +0 -2
  541. package/esm/components/molecules/DateTimePicker/index.js.map +0 -1
  542. package/esm/components/molecules/DateTimeSelector/index.js +0 -2
  543. package/esm/components/molecules/DateTimeSelector/index.js.map +0 -1
  544. package/esm/components/molecules/Grid/index.js +0 -2
  545. package/esm/components/molecules/Grid/index.js.map +0 -1
  546. package/esm/components/molecules/HintInputContainer/index.js +0 -2
  547. package/esm/components/molecules/HintInputContainer/index.js.map +0 -1
  548. package/esm/components/molecules/HintInputContainer/styled.js +0 -2
  549. package/esm/components/molecules/HintInputContainer/styled.js.map +0 -1
  550. package/esm/components/molecules/IconTextButton/IconTextButton.js +0 -2
  551. package/esm/components/molecules/IconTextButton/IconTextButton.js.map +0 -1
  552. package/esm/components/molecules/IconTextButton/index.js +0 -2
  553. package/esm/components/molecules/IconTextButton/index.js.map +0 -1
  554. package/esm/components/molecules/IconTextButton/styled.d.ts +0 -11
  555. package/esm/components/molecules/IconTextButton/styled.js +0 -14
  556. package/esm/components/molecules/IconTextButton/styled.js.map +0 -1
  557. package/esm/components/molecules/InputPassword/index.js +0 -2
  558. package/esm/components/molecules/InputPassword/index.js.map +0 -1
  559. package/esm/components/molecules/LabeledSwitch/LabeledSwitch.js +0 -2
  560. package/esm/components/molecules/LabeledSwitch/LabeledSwitch.js.map +0 -1
  561. package/esm/components/molecules/LabeledSwitch/index.js +0 -2
  562. package/esm/components/molecules/LabeledSwitch/index.js.map +0 -1
  563. package/esm/components/molecules/Snackbar/index.js +0 -2
  564. package/esm/components/molecules/Snackbar/index.js.map +0 -1
  565. package/esm/components/molecules/TextArea/index.js +0 -3
  566. package/esm/components/molecules/TextArea/index.js.map +0 -1
  567. package/esm/hooks/index.js +0 -3
  568. package/esm/hooks/index.js.map +0 -1
  569. package/esm/types/defaults.js +0 -2
  570. package/esm/types/defaults.js.map +0 -1
  571. package/esm/utils/index.js +0 -8
  572. package/esm/utils/index.js.map +0 -1
  573. package/src/components/molecules/IconTextButton/styled.ts +0 -20
@@ -1,99 +1,100 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useNumberMask = exports.getInternalNumberAndMask = void 0;
7
-
8
- var _currency = _interopRequireDefault(require("currency.js"));
9
-
10
- var _react = require("react");
11
-
12
- var _extractNumbersFromString = require("../../../../utils/extractNumbersFromString");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var currency = require('currency.js');
6
+ var React = require('react');
7
+ var extractNumbersFromString = require('../../../../utils/extractNumbersFromString.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var currency__default = /*#__PURE__*/_interopDefaultLegacy(currency);
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
+ var __spreadValues = (a, b) => {
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ if (__getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(b)) {
24
+ if (__propIsEnum.call(b, prop))
25
+ __defNormalProp(a, prop, b[prop]);
26
+ }
27
+ return a;
28
+ };
16
29
  const DEFAULT_OPTIONS = {
17
- symbol: 'R$ ',
18
- separator: '.',
19
- decimal: ',',
30
+ symbol: "R$ ",
31
+ separator: ".",
32
+ decimal: ",",
20
33
  precision: 2
21
34
  };
22
-
23
- const getRegex = precision => new RegExp("\\B(?=(\\d{".concat(precision, "})(?!\\d))"), 'g');
24
-
35
+ const getRegex = (precision) => new RegExp(`\\B(?=(\\d{${precision}})(?!\\d))`, "g");
25
36
  const getInternalNumberAndMask = (value, options) => {
26
- const mergedOptions = { ...DEFAULT_OPTIONS,
27
- ...options
28
- };
29
- const {
30
- precision = -1
31
- } = mergedOptions;
37
+ const mergedOptions = __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options);
38
+ const { precision = -1 } = mergedOptions;
32
39
  let internalNumber;
33
-
34
- if (typeof value === 'number') {
40
+ if (typeof value === "number") {
35
41
  if (precision) {
36
42
  let stringValue = String(value);
37
- const decimalIndex = stringValue.indexOf('.');
43
+ const decimalIndex = stringValue.indexOf(".");
38
44
  const currentPrecision = decimalIndex + precision;
39
-
40
45
  if (decimalIndex !== -1 && currentPrecision <= stringValue.length) {
41
46
  const zeros = stringValue.length + 1 - currentPrecision;
42
-
43
- for (let i = 0; i < zeros; i++) stringValue = stringValue + "0";
47
+ for (let i = 0; i < zeros; i++)
48
+ stringValue = stringValue + `0`;
44
49
  }
45
-
46
50
  internalNumber = Number(stringValue);
47
51
  } else {
48
52
  internalNumber = value;
49
53
  }
50
54
  } else {
51
- const onlyNumbers = String((0, _extractNumbersFromString.extractNumbersFromString)(value));
52
- const padZeros = String(onlyNumbers).padStart(precision + 1, '0');
53
- internalNumber = Number(padZeros.replace(getRegex(precision), '.'));
55
+ const onlyNumbers = String(extractNumbersFromString.extractNumbersFromString(value));
56
+ const padZeros = String(onlyNumbers).padStart(precision + 1, "0");
57
+ internalNumber = Number(padZeros.replace(getRegex(precision), "."));
54
58
  }
55
-
56
59
  if (internalNumber > Number.MAX_SAFE_INTEGER) {
57
60
  internalNumber = Number.MAX_SAFE_INTEGER;
58
61
  }
59
-
60
62
  if (internalNumber < Number.MIN_SAFE_INTEGER) {
61
63
  internalNumber = Number.MIN_SAFE_INTEGER;
62
64
  }
63
-
64
65
  return {
65
66
  internalNumber,
66
67
  mergedOptions
67
68
  };
68
69
  };
69
-
70
- exports.getInternalNumberAndMask = getInternalNumberAndMask;
71
-
72
70
  const useNumberMask = (options, defaultValue) => {
73
- const applyMask = (0, _react.useCallback)(function () {
74
- let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
75
- const {
76
- internalNumber,
77
- mergedOptions
78
- } = getInternalNumberAndMask(value, options);
79
- return {
80
- raw: internalNumber,
81
- formatted: (0, _currency.default)(internalNumber).format(mergedOptions)
82
- };
83
- }, [options, getRegex]);
84
- const [value, setValue] = (0, _react.useState)(applyMask(defaultValue));
85
- const handleChangeValue = (0, _react.useCallback)(formattedValue => {
86
- const {
87
- raw,
88
- formatted
89
- } = applyMask(formattedValue);
90
- setValue({
91
- raw,
92
- formatted
93
- });
94
- }, [applyMask, setValue]);
71
+ const applyMask = React.useCallback(
72
+ (value2 = 0) => {
73
+ const { internalNumber, mergedOptions } = getInternalNumberAndMask(
74
+ value2,
75
+ options
76
+ );
77
+ return {
78
+ raw: internalNumber,
79
+ formatted: currency__default["default"](internalNumber).format(mergedOptions)
80
+ };
81
+ },
82
+ [options, getRegex]
83
+ );
84
+ const [value, setValue] = React.useState(applyMask(defaultValue));
85
+ const handleChangeValue = React.useCallback(
86
+ (formattedValue) => {
87
+ const { raw, formatted } = applyMask(formattedValue);
88
+ setValue({
89
+ raw,
90
+ formatted
91
+ });
92
+ },
93
+ [applyMask, setValue]
94
+ );
95
95
  return [value, handleChangeValue];
96
96
  };
97
97
 
98
+ exports.getInternalNumberAndMask = getInternalNumberAndMask;
98
99
  exports.useNumberMask = useNumberMask;
99
- //# sourceMappingURL=useNumberMask.js.map
100
+ //# sourceMappingURL=useNumberMask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNumberMask.js","names":["DEFAULT_OPTIONS","symbol","separator","decimal","precision","getRegex","RegExp","getInternalNumberAndMask","value","options","mergedOptions","internalNumber","stringValue","String","decimalIndex","indexOf","currentPrecision","length","zeros","i","Number","onlyNumbers","extractNumbersFromString","padZeros","padStart","replace","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","useNumberMask","defaultValue","applyMask","useCallback","raw","formatted","currency","format","setValue","useState","handleChangeValue","formattedValue"],"sources":["../../../../../src/components/atoms/Input/hooks/useNumberMask.ts"],"sourcesContent":["import currency from 'currency.js';\nimport { useCallback, useState } from 'react';\nimport { extractNumbersFromString } from '../../../../utils/extractNumbersFromString';\nimport { MaskValue } from './useStringMask';\n\nexport type CurrencyOptions = currency.Options;\n\nconst DEFAULT_OPTIONS: CurrencyOptions = {\n symbol: 'R$ ',\n separator: '.',\n decimal: ',',\n precision: 2,\n};\n\nconst getRegex = (precision: number) =>\n new RegExp(`\\\\B(?=(\\\\d{${precision}})(?!\\\\d))`, 'g');\n\nexport const getInternalNumberAndMask = (\n value: string | number,\n options?: CurrencyOptions\n): { internalNumber: number; mergedOptions: CurrencyOptions } => {\n const mergedOptions = { ...DEFAULT_OPTIONS, ...options };\n const { precision = -1 } = mergedOptions;\n\n let internalNumber;\n\n if (typeof value === 'number') {\n if (precision) {\n let stringValue = String(value);\n const decimalIndex = stringValue.indexOf('.');\n const currentPrecision = decimalIndex + precision;\n if (decimalIndex !== -1 && currentPrecision <= stringValue.length) {\n const zeros = stringValue.length + 1 - currentPrecision;\n for (let i = 0; i < zeros; i++) stringValue = stringValue + `0`;\n }\n internalNumber = Number(stringValue);\n } else {\n internalNumber = value;\n }\n } else {\n const onlyNumbers = String(extractNumbersFromString(value));\n const padZeros = String(onlyNumbers).padStart(precision + 1, '0');\n internalNumber = Number(padZeros.replace(getRegex(precision), '.'));\n }\n\n if (internalNumber > Number.MAX_SAFE_INTEGER) {\n internalNumber = Number.MAX_SAFE_INTEGER;\n }\n\n if (internalNumber < Number.MIN_SAFE_INTEGER) {\n internalNumber = Number.MIN_SAFE_INTEGER;\n }\n\n return {\n internalNumber,\n mergedOptions,\n };\n};\n\n/**\n * TODO:\n * @param options\n * @param defaultValue\n * @returns\n */\nexport const useNumberMask = (\n options?: CurrencyOptions,\n defaultValue?: string | number\n): [MaskValue, (value: string | number) => void] => {\n const applyMask = useCallback(\n (value: string | number = 0): MaskValue => {\n const { internalNumber, mergedOptions } = getInternalNumberAndMask(\n value,\n options\n );\n\n return {\n raw: internalNumber,\n formatted: currency(internalNumber).format(mergedOptions),\n };\n },\n [options, getRegex]\n );\n\n const [value, setValue] = useState<MaskValue>(applyMask(defaultValue));\n\n const handleChangeValue = useCallback(\n (formattedValue: string | number) => {\n const { raw, formatted } = applyMask(formattedValue);\n setValue({\n raw,\n formatted,\n });\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAKA,MAAMA,eAAgC,GAAG;EACvCC,MAAM,EAAE,KAD+B;EAEvCC,SAAS,EAAE,GAF4B;EAGvCC,OAAO,EAAE,GAH8B;EAIvCC,SAAS,EAAE;AAJ4B,CAAzC;;AAOA,MAAMC,QAAQ,GAAID,SAAD,IACf,IAAIE,MAAJ,sBAAyBF,SAAzB,iBAAgD,GAAhD,CADF;;AAGO,MAAMG,wBAAwB,GAAG,CACtCC,KADsC,EAEtCC,OAFsC,KAGyB;EAC/D,MAAMC,aA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O,gBAA5B,EAA8C;IAC5ChB,cAAc,GAAGS,MAAM,CAACO,gBAAxB;EACD;;EAED,OAAO;IACLhB,cADK;IAELD;EAFK,CAAP;AAID,CAxCM;;;;AAgDA,MAAMkB,aAAa,GAAG,CAC3BnB,OAD2B,EAE3BoB,YAF2B,KAGuB;EAClD,MAAMC,SAAS,GAAG,IAAAC,kBAAA,EAChB,YAA2C;IAAA,IAA1CvB,KAA0C,uEAAjB,CAAiB;IACzC,MAAM;MAAEG,cAAF;MAAkBD;IAAlB,IAAoCH,wBAAwB,CAChEC,KADgE,EAEhEC,OAFgE,CAAlE;IAKA,OAAO;MACLuB,GAAG,EAAErB,cADA;MAELsB,SAAS,EAAE,IAAAC,iBAAA,EAASvB,cAAT,EAAyBwB,MAAzB,CAAgCzB,aAAhC;IAFN,CAAP;EAID,CAXe,EAYhB,CAACD,OAAD,EAAUJ,QAAV,CAZgB,CAAlB;EAeA,MAAM,CAACG,KAAD,EAAQ4B,QAAR,IAAoB,IAAAC,eAAA,EAAoBP,SAAS,CAACD,YAAD,CAA7B,CAA1B;EAEA,MAAMS,iBAAiB,GAAG,IAAAP,kBAAA,EACvBQ,cAAD,IAAqC;IACnC,MAAM;MAAEP,GAAF;MAAOC;IAAP,IAAqBH,SAAS,CAACS,cAAD,CAApC;IACAH,QAAQ,CAAC;MACPJ,GADO;MAEPC;IAFO,CAAD,CAAR;EAID,CAPuB,EAQxB,CAACH,SAAD,EAAYM,QAAZ,CARwB,CAA1B;EAWA,OAAO,CAAC5B,KAAD,EAAQ8B,iBAAR,CAAP;AACD,CAjCM"}
1
+ {"version":3,"file":"useNumberMask.js","sources":["../../../../../src/components/atoms/Input/hooks/useNumberMask.ts"],"sourcesContent":["import currency from 'currency.js';\nimport { useCallback, useState } from 'react';\nimport { extractNumbersFromString } from '../../../../utils/extractNumbersFromString';\nimport { MaskValue } from './useStringMask';\n\nexport type CurrencyOptions = currency.Options;\n\nconst DEFAULT_OPTIONS: CurrencyOptions = {\n symbol: 'R$ ',\n separator: '.',\n decimal: ',',\n precision: 2,\n};\n\nconst getRegex = (precision: number) =>\n new RegExp(`\\\\B(?=(\\\\d{${precision}})(?!\\\\d))`, 'g');\n\nexport const getInternalNumberAndMask = (\n value: string | number,\n options?: CurrencyOptions\n): { internalNumber: number; mergedOptions: CurrencyOptions } => {\n const mergedOptions = { ...DEFAULT_OPTIONS, ...options };\n const { precision = -1 } = mergedOptions;\n\n let internalNumber;\n\n if (typeof value === 'number') {\n if (precision) {\n let stringValue = String(value);\n const decimalIndex = stringValue.indexOf('.');\n const currentPrecision = decimalIndex + precision;\n if (decimalIndex !== -1 && currentPrecision <= stringValue.length) {\n const zeros = stringValue.length + 1 - currentPrecision;\n for (let i = 0; i < zeros; i++) stringValue = stringValue + `0`;\n }\n internalNumber = Number(stringValue);\n } else {\n internalNumber = value;\n }\n } else {\n const onlyNumbers = String(extractNumbersFromString(value));\n const padZeros = String(onlyNumbers).padStart(precision + 1, '0');\n internalNumber = Number(padZeros.replace(getRegex(precision), '.'));\n }\n\n if (internalNumber > Number.MAX_SAFE_INTEGER) {\n internalNumber = Number.MAX_SAFE_INTEGER;\n }\n\n if (internalNumber < Number.MIN_SAFE_INTEGER) {\n internalNumber = Number.MIN_SAFE_INTEGER;\n }\n\n return {\n internalNumber,\n mergedOptions,\n };\n};\n\n/**\n * TODO:\n * @param options\n * @param defaultValue\n * @returns\n */\nexport const useNumberMask = (\n options?: CurrencyOptions,\n defaultValue?: string | number\n): [MaskValue, (value: string | number) => void] => {\n const applyMask = useCallback(\n (value: string | number = 0): MaskValue => {\n const { internalNumber, mergedOptions } = getInternalNumberAndMask(\n value,\n options\n );\n\n return {\n raw: internalNumber,\n formatted: currency(internalNumber).format(mergedOptions),\n };\n },\n [options, getRegex]\n );\n\n const [value, setValue] = useState<MaskValue>(applyMask(defaultValue));\n\n const handleChangeValue = useCallback(\n (formattedValue: string | number) => {\n const { raw, formatted } = applyMask(formattedValue);\n setValue({\n raw,\n formatted,\n });\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"names":["extractNumbersFromString","useCallback","value","currency","useState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,eAAmC,GAAA;AAAA,EACvC,MAAQ,EAAA,KAAA;AAAA,EACR,SAAW,EAAA,GAAA;AAAA,EACX,OAAS,EAAA,GAAA;AAAA,EACT,SAAW,EAAA,CAAA;AACb,CAAA,CAAA;AAEA,MAAM,WAAW,CAAC,SAAA,KAChB,IAAI,MAAO,CAAA,CAAA,WAAA,EAAc,uBAAuB,GAAG,CAAA,CAAA;AAExC,MAAA,wBAAA,GAA2B,CACtC,KAAA,EACA,OAC+D,KAAA;AAC/D,EAAM,MAAA,aAAA,GAAgB,kCAAK,eAAoB,CAAA,EAAA,OAAA,CAAA,CAAA;AAC/C,EAAM,MAAA,EAAE,SAAY,GAAA,CAAA,CAAA,EAAO,GAAA,aAAA,CAAA;AAE3B,EAAI,IAAA,cAAA,CAAA;AAEJ,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,IAAA,IAAI,SAAW,EAAA;AACb,MAAI,IAAA,WAAA,GAAc,OAAO,KAAK,CAAA,CAAA;AAC9B,MAAM,MAAA,YAAA,GAAe,WAAY,CAAA,OAAA,CAAQ,GAAG,CAAA,CAAA;AAC5C,MAAA,MAAM,mBAAmB,YAAe,GAAA,SAAA,CAAA;AACxC,MAAA,IAAI,YAAiB,KAAA,CAAA,CAAA,IAAM,gBAAoB,IAAA,WAAA,CAAY,MAAQ,EAAA;AACjE,QAAM,MAAA,KAAA,GAAQ,WAAY,CAAA,MAAA,GAAS,CAAI,GAAA,gBAAA,CAAA;AACvC,QAAS,KAAA,IAAA,CAAA,GAAI,CAAG,EAAA,CAAA,GAAI,KAAO,EAAA,CAAA,EAAA;AAAK,UAAA,WAAA,GAAc,WAAc,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,OAC9D;AACA,MAAA,cAAA,GAAiB,OAAO,WAAW,C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,YAAY,CAAC,CAAA,CAAA;AAErE,EAAA,MAAM,iBAAoB,GAAAH,iBAAA;AAAA,IACxB,CAAC,cAAoC,KAAA;AACnC,MAAA,MAAM,EAAE,GAAA,EAAK,SAAU,EAAA,GAAI,UAAU,cAAc,CAAA,CAAA;AACnD,MAAS,QAAA,CAAA;AAAA,QACP,GAAA;AAAA,QACA,SAAA;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,IACA,CAAC,WAAW,QAAQ,CAAA;AAAA,GACtB,CAAA;AAEA,EAAO,OAAA,CAAC,OAAO,iBAAiB,CAAA,CAAA;AAClC;;;;;"}
@@ -5,4 +5,4 @@ export interface MaskValue {
5
5
  export declare type MaskType = string | RegExp | Array<RegExp>;
6
6
  export declare const mergeMask: (value: string | undefined, mask: MaskType[]) => MaskValue;
7
7
  export declare const getMask: (mask: MaskType[] | ((value: string) => MaskType[]), newValue: string) => MaskType[];
8
- export declare const useStringMask: (mask: MaskType[] | ((value: string) => MaskType[]), defaultValue?: string | number | undefined) => [MaskValue, (text: string | number) => void];
8
+ export declare const useStringMask: (mask: MaskType[] | ((value: string) => MaskType[]), defaultValue?: string | number) => [MaskValue, (text: string | number) => void];
@@ -1,38 +1,28 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useStringMask = exports.mergeMask = exports.getMask = void 0;
3
+ Object.defineProperty(exports, '__esModule', { value: true });
7
4
 
8
- var _react = require("react");
5
+ var React = require('react');
9
6
 
10
- const mergeMask = function () {
11
- let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
12
- let mask = arguments.length > 1 ? arguments[1] : undefined;
13
- let formatted = '';
14
- let raw = '';
7
+ const mergeMask = (value = "", mask) => {
8
+ let formatted = "";
9
+ let raw = "";
15
10
  let iMask = 0;
16
11
  let iChars = 0;
17
-
18
12
  while (!(iMask === mask.length || iChars === value.length)) {
19
13
  const maskChar = mask[iMask];
20
14
  const valueChar = value[iChars];
21
-
22
15
  if (maskChar === valueChar) {
23
16
  formatted += maskChar;
24
17
  iChars++;
25
18
  iMask++;
26
19
  continue;
27
20
  }
28
-
29
21
  const rawValueChar = value[iChars];
30
-
31
- if (typeof maskChar === 'object') {
22
+ if (typeof maskChar === "object") {
32
23
  iChars++;
33
24
  const maskCharRegex = Array.isArray(maskChar) ? maskChar[0] : maskChar;
34
25
  const matchRegex = RegExp(maskCharRegex).test(valueChar);
35
-
36
26
  if (matchRegex) {
37
27
  formatted += valueChar;
38
28
  raw += rawValueChar;
@@ -43,70 +33,69 @@ const mergeMask = function () {
43
33
  iMask++;
44
34
  }
45
35
  }
46
-
47
- return {
48
- raw,
49
- formatted
50
- };
36
+ return { raw, formatted };
51
37
  };
52
-
53
- exports.mergeMask = mergeMask;
54
-
55
38
  const getMask = (mask, newValue) => {
56
39
  let maskArray;
57
40
  const regexArray = [];
58
-
59
- if (typeof mask === 'function') {
41
+ if (typeof mask === "function") {
60
42
  maskArray = mask(newValue);
61
43
  } else {
62
44
  maskArray = mask;
63
45
  }
64
-
65
- maskArray.forEach(exp => {
66
- if (typeof exp !== 'string') {
67
- if (Array.isArray(exp)) regexArray.push(exp);else regexArray.push(exp);
46
+ maskArray.forEach((exp) => {
47
+ if (typeof exp !== "string") {
48
+ if (Array.isArray(exp))
49
+ regexArray.push(exp);
50
+ else
51
+ regexArray.push(exp);
68
52
  } else {
69
53
  for (let i = 0; i < exp.length; i++) {
70
- if (exp[i] === '\\') {
54
+ if (exp[i] === "\\") {
71
55
  regexArray.push(exp[i + 1]);
72
56
  i++;
73
57
  } else {
74
- if (exp[i] === '9') regexArray.push(/\d/);else if (exp[i] === 'a') regexArray.push(/[a-zA-Z]/);else regexArray.push(exp[i]);
58
+ if (exp[i] === "9")
59
+ regexArray.push(/\d/);
60
+ else if (exp[i] === "a")
61
+ regexArray.push(/[a-zA-Z]/);
62
+ else
63
+ regexArray.push(exp[i]);
75
64
  }
76
65
  }
77
66
  }
78
67
  });
79
68
  return regexArray;
80
69
  };
81
-
82
- exports.getMask = getMask;
83
-
84
70
  const useStringMask = (mask, defaultValue) => {
85
- const applyMask = (0, _react.useCallback)(function () {
86
- let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
87
- const selectedMask = getMask(mask, value);
88
- const {
89
- formatted,
90
- raw
91
- } = mergeMask(value, selectedMask);
92
- return {
93
- raw,
94
- formatted
95
- };
96
- }, [mask]);
97
- const [value, setValue] = (0, _react.useState)(applyMask(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()));
98
- const handleChangeValue = (0, _react.useCallback)(formattedValue => {
99
- const {
100
- raw,
101
- formatted
102
- } = applyMask(formattedValue === null || formattedValue === void 0 ? void 0 : formattedValue.toString());
103
- setValue({
104
- raw,
105
- formatted
106
- });
107
- }, [applyMask, setValue]);
71
+ const applyMask = React.useCallback(
72
+ (value2 = "") => {
73
+ const selectedMask = getMask(mask, value2);
74
+ const { formatted, raw } = mergeMask(value2, selectedMask);
75
+ return {
76
+ raw,
77
+ formatted
78
+ };
79
+ },
80
+ [mask]
81
+ );
82
+ const [value, setValue] = React.useState(
83
+ applyMask(defaultValue == null ? void 0 : defaultValue.toString())
84
+ );
85
+ const handleChangeValue = React.useCallback(
86
+ (formattedValue) => {
87
+ const { raw, formatted } = applyMask(formattedValue == null ? void 0 : formattedValue.toString());
88
+ setValue({
89
+ raw,
90
+ formatted
91
+ });
92
+ },
93
+ [applyMask, setValue]
94
+ );
108
95
  return [value, handleChangeValue];
109
96
  };
110
97
 
98
+ exports.getMask = getMask;
99
+ exports.mergeMask = mergeMask;
111
100
  exports.useStringMask = useStringMask;
112
- //# sourceMappingURL=useStringMask.js.map
101
+ //# sourceMappingURL=useStringMask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStringMask.js","names":["mergeMask","value","mask","formatted","raw","iMask","iChars","length","maskChar","valueChar","rawValueChar","maskCharRegex","Array","isArray","matchRegex","RegExp","test","getMask","newValue","maskArray","regexArray","forEach","exp","push","i","useStringMask","defaultValue","applyMask","useCallback","selectedMask","setValue","useState","toString","handleChangeValue","formattedValue"],"sources":["../../../../../src/components/atoms/Input/hooks/useStringMask.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\n\nexport interface MaskValue {\n formatted?: string;\n raw?: string | number;\n}\n\nexport type MaskType = string | RegExp | Array<RegExp>;\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nexport const mergeMask = (value = '', mask: MaskType[]): MaskValue => {\n let formatted = '';\n let raw = '';\n let iMask = 0;\n let iChars = 0;\n\n while (!(iMask === mask.length || iChars === value.length)) {\n const maskChar = mask[iMask];\n const valueChar = value[iChars];\n\n if (maskChar === valueChar) {\n formatted += maskChar;\n iChars++;\n iMask++;\n continue;\n }\n\n const rawValueChar = value[iChars];\n\n if (typeof maskChar === 'object') {\n iChars++;\n\n const maskCharRegex = Array.isArray(maskChar) ? maskChar[0] : maskChar;\n const matchRegex = RegExp(maskCharRegex).test(valueChar);\n\n if (matchRegex) {\n formatted += valueChar;\n raw += rawValueChar;\n iMask++;\n }\n } else {\n formatted += maskChar;\n iMask++;\n }\n }\n\n return { raw, formatted };\n};\n\nexport const getMask = (\n mask: MaskType[] | ((value: string) => MaskType[]),\n newValue: string\n): MaskType[] => {\n let maskArray: MaskType[];\n const regexArray: MaskType[] = [];\n\n if (typeof mask === 'function') {\n maskArray = mask(newValue);\n } else {\n maskArray = mask;\n }\n\n maskArray.forEach(exp => {\n if (typeof exp !== 'string') {\n if (Array.isArray(exp)) regexArray.push(exp);\n else regexArray.push(exp);\n } else {\n for (let i = 0; i < exp.length; i++) {\n if (exp[i] === '\\\\') {\n regexArray.push(exp[i + 1]);\n i++;\n } else {\n if (exp[i] === '9') regexArray.push(/\\d/);\n else if (exp[i] === 'a') regexArray.push(/[a-zA-Z]/);\n else regexArray.push(exp[i]);\n }\n }\n }\n });\n\n return regexArray;\n};\n\n/**\n * TODO:\n * @param mask\n * @param defaultValue\n * @returns\n */\nexport const useStringMask = (\n mask: MaskType[] | ((value: string) => MaskType[]),\n defaultValue?: string | number\n): [MaskValue, (text: string | number) => void] => {\n const applyMask = useCallback(\n (value = ''): MaskValue => {\n const selectedMask = getMask(mask, value);\n const { formatted, raw } = mergeMask(value, selectedMask);\n\n return {\n raw,\n formatted,\n };\n },\n [mask]\n );\n\n const [value, setValue] = useState<MaskValue>(\n applyMask(defaultValue?.toString())\n );\n\n const handleChangeValue = useCallback(\n (formattedValue: string | number) => {\n const { raw, formatted } = applyMask(formattedValue?.toString());\n setValue({\n raw,\n formatted,\n });\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"mappings":";;;;;;;AAAA;;AAeO,MAAMA,SAAS,GAAG,YAA6C;EAAA,IAA5CC,KAA4C,uEAApC,EAAoC;EAAA,IAAhCC,IAAgC;EACpE,IAAIC,SAAS,GAAG,EAAhB;EACA,IAAIC,GAAG,GAAG,EAAV;EACA,IAAIC,KAAK,GAAG,CAAZ;EACA,IAAIC,MAAM,GAAG,CAAb;;EAEA,OAAO,EAAED,KAAK,KAAKH,IAAI,CAACK,MAAf,IAAyBD,MAAM,KAAKL,KAAK,CAACM,MAA5C,CAAP,EAA4D;IAC1D,MAAMC,QAAQ,GAAGN,IAAI,CAACG,KAAD,CAArB;IACA,MAAMI,SAAS,GAAGR,KAAK,CAACK,MAAD,CAAvB;;IAEA,IAAIE,QAAQ,KAAKC,SAAjB,EAA4B;MAC1BN,SAAS,IAAIK,QAAb;MACAF,MAAM;MACND,KAAK;MACL;IACD;;IAED,MAAMK,YAAY,GAAGT,KAAK,CAACK,MAAD,CAA1B;;IAEA,IAAI,OAAOE,QAAP,KAAoB,QAAxB,EAAkC;MAChCF,MAAM;MAEN,MAAMK,aAAa,GAAGC,KAAK,CAACC,OAAN,CAAcL,QAAd,IAA0BA,QAAQ,CAAC,CAAD,CAAlC,GAAwCA,QAA9D;MACA,MAAMM,UAAU,GAAGC,MAAM,CAACJ,aAAD,CAAN,CAAsBK,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ACG,IAAX,CAAgBD,GAAG,CAACE,CAAD,CAAnB;QACN;MACF;IACF;EACF,CAhBD;EAkBA,OAAOJ,UAAP;AACD,CAhCM;;;;AAwCA,MAAMK,aAAa,GAAG,CAC3BvB,IAD2B,EAE3BwB,YAF2B,KAGsB;EACjD,MAAMC,SAAS,GAAG,IAAAC,kBAAA,EAChB,YAA2B;IAAA,IAA1B3B,KAA0B,uEAAlB,EAAkB;IACzB,MAAM4B,YAAY,GAAGZ,OAAO,CAACf,IAAD,EAAOD,KAAP,CAA5B;IACA,MAAM;MAAEE,SAAF;MAAaC;IAAb,IAAqBJ,SAAS,CAACC,KAAD,EAAQ4B,YAAR,CAApC;IAEA,OAAO;MACLzB,GADK;MAELD;IAFK,CAAP;EAID,CATe,EAUhB,CAACD,IAAD,CAVgB,CAAlB;EAaA,MAAM,CAACD,KAAD,EAAQ6B,QAAR,IAAoB,IAAAC,eAAA,EACxBJ,SAAS,CAACD,YAAD,aAACA,YAAD,uBAACA,YAAY,CAAEM,QAAd,EAAD,CADe,CAA1B;EAIA,MAAMC,iBAAiB,GAAG,IAAAL,kBAAA,EACvBM,cAAD,IAAqC;IACnC,MAAM;MAAE9B,GAAF;MAAOD;IAAP,IAAqBwB,SAAS,CAACO,cAAD,aAACA,cAAD,uBAACA,cAAc,CAAEF,QAAhB,EAAD,CAApC;IACAF,QAAQ,CAAC;MACP1B,GADO;MAEPD;IAFO,CAAD,CAAR;EAID,CAPuB,EAQxB,CAACwB,SAAD,EAAYG,QAAZ,CARwB,CAA1B;EAWA,OAAO,CAAC7B,KAAD,EAAQgC,iBAAR,CAAP;AACD,CAjCM"}
1
+ {"version":3,"file":"useStringMask.js","sources":["../../../../../src/components/atoms/Input/hooks/useStringMask.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\n\nexport interface MaskValue {\n formatted?: string;\n raw?: string | number;\n}\n\nexport type MaskType = string | RegExp | Array<RegExp>;\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nexport const mergeMask = (value = '', mask: MaskType[]): MaskValue => {\n let formatted = '';\n let raw = '';\n let iMask = 0;\n let iChars = 0;\n\n while (!(iMask === mask.length || iChars === value.length)) {\n const maskChar = mask[iMask];\n const valueChar = value[iChars];\n\n if (maskChar === valueChar) {\n formatted += maskChar;\n iChars++;\n iMask++;\n continue;\n }\n\n const rawValueChar = value[iChars];\n\n if (typeof maskChar === 'object') {\n iChars++;\n\n const maskCharRegex = Array.isArray(maskChar) ? maskChar[0] : maskChar;\n const matchRegex = RegExp(maskCharRegex).test(valueChar);\n\n if (matchRegex) {\n formatted += valueChar;\n raw += rawValueChar;\n iMask++;\n }\n } else {\n formatted += maskChar;\n iMask++;\n }\n }\n\n return { raw, formatted };\n};\n\nexport const getMask = (\n mask: MaskType[] | ((value: string) => MaskType[]),\n newValue: string\n): MaskType[] => {\n let maskArray: MaskType[];\n const regexArray: MaskType[] = [];\n\n if (typeof mask === 'function') {\n maskArray = mask(newValue);\n } else {\n maskArray = mask;\n }\n\n maskArray.forEach(exp => {\n if (typeof exp !== 'string') {\n if (Array.isArray(exp)) regexArray.push(exp);\n else regexArray.push(exp);\n } else {\n for (let i = 0; i < exp.length; i++) {\n if (exp[i] === '\\\\') {\n regexArray.push(exp[i + 1]);\n i++;\n } else {\n if (exp[i] === '9') regexArray.push(/\\d/);\n else if (exp[i] === 'a') regexArray.push(/[a-zA-Z]/);\n else regexArray.push(exp[i]);\n }\n }\n }\n });\n\n return regexArray;\n};\n\n/**\n * TODO:\n * @param mask\n * @param defaultValue\n * @returns\n */\nexport const useStringMask = (\n mask: MaskType[] | ((value: string) => MaskType[]),\n defaultValue?: string | number\n): [MaskValue, (text: string | number) => void] => {\n const applyMask = useCallback(\n (value = ''): MaskValue => {\n const selectedMask = getMask(mask, value);\n const { formatted, raw } = mergeMask(value, selectedMask);\n\n return {\n raw,\n formatted,\n };\n },\n [mask]\n );\n\n const [value, setValue] = useState<MaskValue>(\n applyMask(defaultValue?.toString())\n );\n\n const handleChangeValue = useCallback(\n (formattedValue: string | number) => {\n const { raw, formatted } = applyMask(formattedValue?.toString());\n setValue({\n raw,\n formatted,\n });\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"names":["useCallback","value","useState"],"mappings":";;;;;;AAeO,MAAM,SAAY,GAAA,CAAC,KAAQ,GAAA,EAAA,EAAI,IAAgC,KAAA;AACpE,EAAA,IAAI,SAAY,GAAA,EAAA,CAAA;AAChB,EAAA,IAAI,GAAM,GAAA,EAAA,CAAA;AACV,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAA,IAAI,MAAS,GAAA,CAAA,CAAA;AAEb,EAAA,OAAO,EAAE,KAAU,KAAA,IAAA,CAAK,MAAU,IAAA,MAAA,KAAW,MAAM,MAAS,CAAA,EAAA;AAC1D,IAAA,MAAM,WAAW,IAAK,CAAA,KAAA,CAAA,CAAA;AACtB,IAAA,MAAM,YAAY,KAAM,CAAA,MAAA,CAAA,CAAA;AAExB,IAAA,IAAI,aAAa,SAAW,EAAA;AAC1B,MAAa,SAAA,IAAA,QAAA,CAAA;AACb,MAAA,MAAA,EAAA,CAAA;AACA,MAAA,KAAA,EAAA,CAAA;AACA,MAAA,SAAA;AAAA,KACF;AAEA,IAAA,MAAM,eAAe,KAAM,CAAA,MAAA,CAAA,CAAA;AAE3B,IAAI,IAAA,OAAO,aAAa,QAAU,EAAA;AAChC,MAAA,MAAA,EAAA,CAAA;AAEA,MAAA,MAAM,gBAAgB,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAA,GAAI,SAAS,CAAK,CAAA,GAAA,QAAA,CAAA;AAC9D,MAAA,MAAM,UAAa,GAAA,MAAA,CAAO,aAAa,CAAA,CAAE,KAAK,SAAS,CAAA,CAAA;AAEvD,MAAA,IAAI,UAAY,EAAA;AACd,QAAa,SAAA,IAAA,SAAA,CAAA;AACb,QAAO,GAAA,IAAA,YAAA,CAAA;AACP,QAAA,KAAA,EAAA,CAAA;AAAA,OACF;AAAA,KAC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