@roadtrip/components 3.32.5 → 3.33.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 (233) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/road-badge_14.cjs.entry.js +9 -4
  3. package/dist/cjs/road-badge_14.cjs.entry.js.map +1 -1
  4. package/dist/cjs/road-dropdown.cjs.entry.js +1 -1
  5. package/dist/cjs/road-dropdown.cjs.entry.js.map +1 -1
  6. package/dist/cjs/road-phone-number-input.cjs.entry.js +26 -61
  7. package/dist/cjs/road-phone-number-input.cjs.entry.js.map +1 -1
  8. package/dist/cjs/road-plate-number.cjs.entry.js +2 -2
  9. package/dist/cjs/road-profil-dropdown.cjs.entry.js +1 -1
  10. package/dist/cjs/road-progress-indicator-horizontal.cjs.entry.js +1 -1
  11. package/dist/cjs/road-progress-indicator-vertical-item.cjs.entry.js +1 -1
  12. package/dist/cjs/road-progress-indicator-vertical.cjs.entry.js +1 -1
  13. package/dist/cjs/road-progress-tracker-item.cjs.entry.js +1 -1
  14. package/dist/cjs/road-progress-tracker.cjs.entry.js +1 -1
  15. package/dist/cjs/road-progress.cjs.entry.js +1 -1
  16. package/dist/cjs/road-radio-group.cjs.entry.js +1 -1
  17. package/dist/cjs/road-radio.cjs.entry.js +1 -1
  18. package/dist/cjs/road-range.cjs.entry.js +2 -2
  19. package/dist/cjs/road-rating.cjs.entry.js +1 -1
  20. package/dist/cjs/road-segmented-button-bar.cjs.entry.js +1 -1
  21. package/dist/cjs/road-segmented-button.cjs.entry.js +2 -2
  22. package/dist/cjs/road-segmented-buttons.cjs.entry.js +1 -1
  23. package/dist/cjs/road-select-filter.cjs.entry.js +2 -2
  24. package/dist/cjs/road-select.cjs.entry.js +1 -1
  25. package/dist/cjs/road-skeleton.cjs.entry.js +1 -1
  26. package/dist/cjs/road-spinner.cjs.entry.js +1 -1
  27. package/dist/cjs/road-switch.cjs.entry.js +2 -2
  28. package/dist/cjs/road-tab-bar.cjs.entry.js +2 -2
  29. package/dist/cjs/road-tab-button.cjs.entry.js +2 -2
  30. package/dist/cjs/road-tab.cjs.entry.js +2 -2
  31. package/dist/cjs/road-table.cjs.entry.js +1 -1
  32. package/dist/cjs/road-tabs.cjs.entry.js +1 -1
  33. package/dist/cjs/road-tag.cjs.entry.js +1 -1
  34. package/dist/cjs/road-text.cjs.entry.js +1 -1
  35. package/dist/cjs/road-textarea.cjs.entry.js +1 -1
  36. package/dist/cjs/road-toast.cjs.entry.js +1 -1
  37. package/dist/cjs/road-toggle.cjs.entry.js +2 -2
  38. package/dist/cjs/road-toolbar-title-page.cjs.entry.js +1 -1
  39. package/dist/cjs/road-toolbar-title.cjs.entry.js +1 -1
  40. package/dist/cjs/road-toolbar-v2.cjs.entry.js +1 -1
  41. package/dist/cjs/road-tooltip.cjs.entry.js +3 -3
  42. package/dist/cjs/roadtrip.cjs.js +1 -1
  43. package/dist/collection/components/drawer/drawer.css +9 -0
  44. package/dist/collection/components/drawer/drawer.js +26 -1
  45. package/dist/collection/components/drawer/drawer.js.map +1 -1
  46. package/dist/collection/components/drawer/drawer.stories.js +7 -1
  47. package/dist/collection/components/dropdown/dropdown.css +1 -1
  48. package/dist/collection/components/phone-number-input/constants.js +3 -0
  49. package/dist/collection/components/phone-number-input/constants.js.map +1 -0
  50. package/dist/collection/components/phone-number-input/phone-number-input.css +198 -129
  51. package/dist/collection/components/phone-number-input/phone-number-input.js +23 -63
  52. package/dist/collection/components/phone-number-input/phone-number-input.js.map +1 -1
  53. package/dist/collection/components/plate-number/plate-number.js +2 -2
  54. package/dist/collection/components/profil-dropdown/profil-dropdown.js +1 -1
  55. package/dist/collection/components/progress/progress.js +1 -1
  56. package/dist/collection/components/progress-indicator-horizontal/progress-indicator-horizontal.js +1 -1
  57. package/dist/collection/components/progress-indicator-vertical/progress-indicator-vertical.js +1 -1
  58. package/dist/collection/components/progress-indicator-vertical-item/progress-indicator-vertical-item.js +1 -1
  59. package/dist/collection/components/progress-tracker/progress-tracker.js +1 -1
  60. package/dist/collection/components/progress-tracker-item/progress-tracker-item.js +1 -1
  61. package/dist/collection/components/radio/radio.js +1 -1
  62. package/dist/collection/components/radio-group/radio-group.js +1 -1
  63. package/dist/collection/components/range/range.js +2 -2
  64. package/dist/collection/components/rating/rating.js +1 -1
  65. package/dist/collection/components/row/row.js +1 -1
  66. package/dist/collection/components/segmented-button/segmented-button.js +2 -2
  67. package/dist/collection/components/segmented-button-bar/segmented-button-bar.js +1 -1
  68. package/dist/collection/components/segmented-buttons/segmented-buttons.js +1 -1
  69. package/dist/collection/components/select/select.js +1 -1
  70. package/dist/collection/components/select-filter/select-filter.js +2 -2
  71. package/dist/collection/components/skeleton/skeleton.js +1 -1
  72. package/dist/collection/components/spinner/spinner.js +1 -1
  73. package/dist/collection/components/switch/switch.js +2 -2
  74. package/dist/collection/components/tab/tab.js +2 -2
  75. package/dist/collection/components/tab-bar/tab-bar.js +2 -2
  76. package/dist/collection/components/tab-button/tab-button.js +2 -2
  77. package/dist/collection/components/table/table.js +1 -1
  78. package/dist/collection/components/tabs/tabs.js +1 -1
  79. package/dist/collection/components/tag/tag.js +1 -1
  80. package/dist/collection/components/text/text.js +1 -1
  81. package/dist/collection/components/textarea/textarea.js +1 -1
  82. package/dist/collection/components/toast/toast.js +1 -1
  83. package/dist/collection/components/toggle/toggle.js +2 -2
  84. package/dist/collection/components/toolbar/toolbar.js +1 -1
  85. package/dist/collection/components/toolbar-title/toolbar-title.js +1 -1
  86. package/dist/collection/components/toolbar-title-page/toolbar-title-page.js +1 -1
  87. package/dist/collection/components/toolbar-v2/toolbar-v2.js +1 -1
  88. package/dist/collection/components/tooltip/tooltip.js +3 -3
  89. package/dist/collection/components/utilities/text.stories.js +2 -0
  90. package/dist/collection/fonts/Muli-Black.woff +0 -0
  91. package/dist/collection/fonts/Muli-Black.woff2 +0 -0
  92. package/dist/collection/fonts/Muli-SemiBold.woff +0 -0
  93. package/dist/collection/fonts/Muli-SemiBold.woff2 +0 -0
  94. package/dist/esm/loader.js +1 -1
  95. package/dist/esm/road-badge_14.entry.js +9 -4
  96. package/dist/esm/road-badge_14.entry.js.map +1 -1
  97. package/dist/esm/road-dropdown.entry.js +1 -1
  98. package/dist/esm/road-dropdown.entry.js.map +1 -1
  99. package/dist/esm/road-phone-number-input.entry.js +26 -61
  100. package/dist/esm/road-phone-number-input.entry.js.map +1 -1
  101. package/dist/esm/road-plate-number.entry.js +2 -2
  102. package/dist/esm/road-profil-dropdown.entry.js +1 -1
  103. package/dist/esm/road-progress-indicator-horizontal.entry.js +1 -1
  104. package/dist/esm/road-progress-indicator-vertical-item.entry.js +1 -1
  105. package/dist/esm/road-progress-indicator-vertical.entry.js +1 -1
  106. package/dist/esm/road-progress-tracker-item.entry.js +1 -1
  107. package/dist/esm/road-progress-tracker.entry.js +1 -1
  108. package/dist/esm/road-progress.entry.js +1 -1
  109. package/dist/esm/road-radio-group.entry.js +1 -1
  110. package/dist/esm/road-radio.entry.js +1 -1
  111. package/dist/esm/road-range.entry.js +2 -2
  112. package/dist/esm/road-rating.entry.js +1 -1
  113. package/dist/esm/road-segmented-button-bar.entry.js +1 -1
  114. package/dist/esm/road-segmented-button.entry.js +2 -2
  115. package/dist/esm/road-segmented-buttons.entry.js +1 -1
  116. package/dist/esm/road-select-filter.entry.js +2 -2
  117. package/dist/esm/road-select.entry.js +1 -1
  118. package/dist/esm/road-skeleton.entry.js +1 -1
  119. package/dist/esm/road-spinner.entry.js +1 -1
  120. package/dist/esm/road-switch.entry.js +2 -2
  121. package/dist/esm/road-tab-bar.entry.js +2 -2
  122. package/dist/esm/road-tab-button.entry.js +2 -2
  123. package/dist/esm/road-tab.entry.js +2 -2
  124. package/dist/esm/road-table.entry.js +1 -1
  125. package/dist/esm/road-tabs.entry.js +1 -1
  126. package/dist/esm/road-tag.entry.js +1 -1
  127. package/dist/esm/road-text.entry.js +1 -1
  128. package/dist/esm/road-textarea.entry.js +1 -1
  129. package/dist/esm/road-toast.entry.js +1 -1
  130. package/dist/esm/road-toggle.entry.js +2 -2
  131. package/dist/esm/road-toolbar-title-page.entry.js +1 -1
  132. package/dist/esm/road-toolbar-title.entry.js +1 -1
  133. package/dist/esm/road-toolbar-v2.entry.js +1 -1
  134. package/dist/esm/road-tooltip.entry.js +3 -3
  135. package/dist/esm/roadtrip.js +1 -1
  136. package/dist/html.html-data.json +4 -0
  137. package/dist/roadtrip/fonts/Muli-Black.woff +0 -0
  138. package/dist/roadtrip/fonts/Muli-Black.woff2 +0 -0
  139. package/dist/roadtrip/fonts/Muli-SemiBold.woff +0 -0
  140. package/dist/roadtrip/fonts/Muli-SemiBold.woff2 +0 -0
  141. package/dist/roadtrip/{p-c1e2aa67.entry.js → p-04913d58.entry.js} +2 -2
  142. package/dist/roadtrip/{p-494aab48.entry.js → p-06fbd2ea.entry.js} +2 -2
  143. package/dist/roadtrip/{p-2a4a0928.entry.js → p-167cd2fc.entry.js} +2 -2
  144. package/dist/roadtrip/p-215afdbd.entry.js +2 -0
  145. package/dist/roadtrip/{p-8f7375bc.entry.js → p-2e049c8e.entry.js} +2 -2
  146. package/dist/roadtrip/{p-8ca23318.entry.js → p-37430583.entry.js} +2 -2
  147. package/dist/roadtrip/{p-9fce16aa.entry.js → p-3dcaa947.entry.js} +2 -2
  148. package/dist/roadtrip/{p-1e61ca1f.entry.js → p-3f5dff96.entry.js} +2 -2
  149. package/dist/roadtrip/{p-f8817c0e.entry.js → p-449affa6.entry.js} +2 -2
  150. package/dist/roadtrip/p-4675ea6d.entry.js +2 -0
  151. package/dist/roadtrip/{p-4a47999a.entry.js → p-5fea6a74.entry.js} +2 -2
  152. package/dist/roadtrip/{p-f9754547.entry.js → p-60bd73ad.entry.js} +2 -2
  153. package/dist/roadtrip/p-65f9bd9c.entry.js +2 -0
  154. package/dist/roadtrip/{p-c68fc795.entry.js → p-6c617506.entry.js} +2 -2
  155. package/dist/roadtrip/{p-4e779fd6.entry.js → p-6ff3b37c.entry.js} +2 -2
  156. package/dist/roadtrip/p-85b1e505.entry.js +2 -0
  157. package/dist/roadtrip/{p-a990a8b6.entry.js → p-862c1831.entry.js} +2 -2
  158. package/dist/roadtrip/{p-a990a8b6.entry.js.map → p-862c1831.entry.js.map} +1 -1
  159. package/dist/roadtrip/p-8b04fc62.entry.js +2 -0
  160. package/dist/roadtrip/{p-b5c4455e.entry.js → p-913b72de.entry.js} +3 -3
  161. package/dist/roadtrip/p-913b72de.entry.js.map +1 -0
  162. package/dist/roadtrip/{p-87c1ff76.entry.js → p-99a6faae.entry.js} +2 -2
  163. package/dist/roadtrip/{p-bba18327.entry.js → p-b5fa8c5a.entry.js} +2 -2
  164. package/dist/roadtrip/{p-db243855.entry.js → p-b8c5d292.entry.js} +2 -2
  165. package/dist/roadtrip/{p-d68e64a8.entry.js → p-c28e7add.entry.js} +2 -2
  166. package/dist/roadtrip/{p-10e65612.entry.js → p-c47ccbf2.entry.js} +2 -2
  167. package/dist/roadtrip/{p-c3ef32ef.entry.js → p-c6824205.entry.js} +2 -2
  168. package/dist/roadtrip/{p-833c1e78.entry.js → p-cfd2919e.entry.js} +2 -2
  169. package/dist/roadtrip/{p-a0a95c0a.entry.js → p-d80e7563.entry.js} +2 -2
  170. package/dist/roadtrip/p-db77c354.entry.js +2 -0
  171. package/dist/roadtrip/{p-5fab1bc3.entry.js.map → p-db77c354.entry.js.map} +1 -1
  172. package/dist/roadtrip/{p-0cacf829.entry.js → p-ddfe088f.entry.js} +2 -2
  173. package/dist/roadtrip/p-ddfe088f.entry.js.map +1 -0
  174. package/dist/roadtrip/{p-4bbc889b.entry.js → p-e6c4c576.entry.js} +2 -2
  175. package/dist/roadtrip/{p-01be5517.entry.js → p-e6e9882b.entry.js} +2 -2
  176. package/dist/roadtrip/{p-5a6fbd7f.entry.js → p-e75ec60f.entry.js} +2 -2
  177. package/dist/roadtrip/{p-edbbe884.entry.js → p-ea1a175d.entry.js} +2 -2
  178. package/dist/roadtrip/{p-2903bdc0.entry.js → p-eac313e4.entry.js} +2 -2
  179. package/dist/roadtrip/{p-fb26ed7e.entry.js → p-f1b53143.entry.js} +2 -2
  180. package/dist/roadtrip/{p-b18cda16.entry.js → p-fd3c58b6.entry.js} +2 -2
  181. package/dist/roadtrip/{p-32845e72.entry.js → p-fe40ab3d.entry.js} +2 -2
  182. package/dist/roadtrip/roadtrip.css +1 -1
  183. package/dist/roadtrip/roadtrip.esm.js +1 -1
  184. package/dist/roadtrip/roadtrip.esm.js.map +1 -1
  185. package/dist/types/components/drawer/drawer.d.ts +4 -0
  186. package/dist/types/components/phone-number-input/constants.d.ts +1 -0
  187. package/dist/types/components/phone-number-input/phone-number-input.d.ts +3 -9
  188. package/dist/types/components-react.d.ts +4 -4
  189. package/dist/types/components.d.ts +16 -0
  190. package/hydrate/index.js +85 -114
  191. package/hydrate/index.mjs +85 -114
  192. package/package.json +1 -1
  193. package/dist/roadtrip/p-0cacf829.entry.js.map +0 -1
  194. package/dist/roadtrip/p-427bd935.entry.js +0 -2
  195. package/dist/roadtrip/p-5fab1bc3.entry.js +0 -2
  196. package/dist/roadtrip/p-78b51033.entry.js +0 -2
  197. package/dist/roadtrip/p-9737182c.entry.js +0 -2
  198. package/dist/roadtrip/p-a925ff64.entry.js +0 -2
  199. package/dist/roadtrip/p-b5c4455e.entry.js.map +0 -1
  200. package/dist/roadtrip/p-ee92b78d.entry.js +0 -2
  201. /package/dist/roadtrip/{p-c1e2aa67.entry.js.map → p-04913d58.entry.js.map} +0 -0
  202. /package/dist/roadtrip/{p-494aab48.entry.js.map → p-06fbd2ea.entry.js.map} +0 -0
  203. /package/dist/roadtrip/{p-2a4a0928.entry.js.map → p-167cd2fc.entry.js.map} +0 -0
  204. /package/dist/roadtrip/{p-427bd935.entry.js.map → p-215afdbd.entry.js.map} +0 -0
  205. /package/dist/roadtrip/{p-8f7375bc.entry.js.map → p-2e049c8e.entry.js.map} +0 -0
  206. /package/dist/roadtrip/{p-8ca23318.entry.js.map → p-37430583.entry.js.map} +0 -0
  207. /package/dist/roadtrip/{p-9fce16aa.entry.js.map → p-3dcaa947.entry.js.map} +0 -0
  208. /package/dist/roadtrip/{p-1e61ca1f.entry.js.map → p-3f5dff96.entry.js.map} +0 -0
  209. /package/dist/roadtrip/{p-f8817c0e.entry.js.map → p-449affa6.entry.js.map} +0 -0
  210. /package/dist/roadtrip/{p-ee92b78d.entry.js.map → p-4675ea6d.entry.js.map} +0 -0
  211. /package/dist/roadtrip/{p-4a47999a.entry.js.map → p-5fea6a74.entry.js.map} +0 -0
  212. /package/dist/roadtrip/{p-f9754547.entry.js.map → p-60bd73ad.entry.js.map} +0 -0
  213. /package/dist/roadtrip/{p-a925ff64.entry.js.map → p-65f9bd9c.entry.js.map} +0 -0
  214. /package/dist/roadtrip/{p-c68fc795.entry.js.map → p-6c617506.entry.js.map} +0 -0
  215. /package/dist/roadtrip/{p-4e779fd6.entry.js.map → p-6ff3b37c.entry.js.map} +0 -0
  216. /package/dist/roadtrip/{p-9737182c.entry.js.map → p-85b1e505.entry.js.map} +0 -0
  217. /package/dist/roadtrip/{p-78b51033.entry.js.map → p-8b04fc62.entry.js.map} +0 -0
  218. /package/dist/roadtrip/{p-87c1ff76.entry.js.map → p-99a6faae.entry.js.map} +0 -0
  219. /package/dist/roadtrip/{p-bba18327.entry.js.map → p-b5fa8c5a.entry.js.map} +0 -0
  220. /package/dist/roadtrip/{p-db243855.entry.js.map → p-b8c5d292.entry.js.map} +0 -0
  221. /package/dist/roadtrip/{p-d68e64a8.entry.js.map → p-c28e7add.entry.js.map} +0 -0
  222. /package/dist/roadtrip/{p-10e65612.entry.js.map → p-c47ccbf2.entry.js.map} +0 -0
  223. /package/dist/roadtrip/{p-c3ef32ef.entry.js.map → p-c6824205.entry.js.map} +0 -0
  224. /package/dist/roadtrip/{p-833c1e78.entry.js.map → p-cfd2919e.entry.js.map} +0 -0
  225. /package/dist/roadtrip/{p-a0a95c0a.entry.js.map → p-d80e7563.entry.js.map} +0 -0
  226. /package/dist/roadtrip/{p-4bbc889b.entry.js.map → p-e6c4c576.entry.js.map} +0 -0
  227. /package/dist/roadtrip/{p-01be5517.entry.js.map → p-e6e9882b.entry.js.map} +0 -0
  228. /package/dist/roadtrip/{p-5a6fbd7f.entry.js.map → p-e75ec60f.entry.js.map} +0 -0
  229. /package/dist/roadtrip/{p-edbbe884.entry.js.map → p-ea1a175d.entry.js.map} +0 -0
  230. /package/dist/roadtrip/{p-2903bdc0.entry.js.map → p-eac313e4.entry.js.map} +0 -0
  231. /package/dist/roadtrip/{p-fb26ed7e.entry.js.map → p-f1b53143.entry.js.map} +0 -0
  232. /package/dist/roadtrip/{p-b18cda16.entry.js.map → p-fd3c58b6.entry.js.map} +0 -0
  233. /package/dist/roadtrip/{p-32845e72.entry.js.map → p-fe40ab3d.entry.js.map} +0 -0
@@ -1,15 +1,10 @@
1
- :host() #phone-number .invalid-feedback.sc-road-input{
2
- margin-left: -4.5rem;
3
- }
4
-
5
- .is-invalid .form-control.sc-road-input{
1
+ .is-invalid .phone-number-input-field.sc-road-input{
6
2
  border-color: var(--road-danger-outline);
7
3
  }
8
4
 
9
5
  .road-phone-input-select {
10
6
  position: relative;
11
7
  display: block;
12
- margin-bottom: 1rem;
13
8
  font-family: var(--road-font, sans-serif);
14
9
  color: var(--road-on-surface);
15
10
  background-color: var(--road-surface);
@@ -53,154 +48,228 @@
53
48
  cursor: pointer;
54
49
  }
55
50
 
56
- .form-select-area:-moz-focusring {
57
- color: transparent;
58
- text-shadow: 0 0 0 #000000;
59
- }
51
+ .form-select-area:-moz-focusring {
52
+ color: transparent;
53
+ text-shadow: 0 0 0 #000000;
54
+ }
60
55
 
61
- .form-select-area::-ms-expand { /* IE fix remove native arrow */
62
- display: none;
63
- }
56
+ .form-select-area::-ms-expand { /* IE fix remove native arrow */
57
+ display: none;
58
+ }
64
59
 
65
- /**
66
- * Placeholder
67
- */
60
+ /**
61
+ * Placeholder
62
+ */
68
63
 
69
- .form-select-area::placeholder {
70
- color: var(--road-on-surface-extra-weak);
71
- }
64
+ .form-select-area::placeholder {
65
+ color: var(--road-on-surface-extra-weak);
66
+ }
72
67
 
73
- /**
74
- * Hover state
75
- */
68
+ /**
69
+ * Hover state
70
+ */
76
71
 
77
- @media (hover: hover) {
72
+ @media (hover: hover) {
78
73
 
79
- .form-select-area:not(:disabled):hover {
80
- border-color: var(--road-input-outline-variant);
81
- }
74
+ .form-select-area:not(:disabled):hover {
75
+ border-color: var(--road-input-outline-variant);
82
76
  }
77
+ }
83
78
 
84
- /**
85
- * Focus state
86
- */
79
+ /**
80
+ * Focus state
81
+ */
87
82
 
88
- .form-select-area:focus ~ .form-select-area-label,
89
- .form-select-area[required]:valid ~ .form-select-area-label,
90
- .form-select-area.has-value ~ .form-select-area-label {
91
- transform: scale(0.625) translateY(-0.625rem);
92
- }
83
+ .form-select-area:focus ~ .form-select-area-label,
84
+ .form-select-area[required]:valid ~ .form-select-area-label,
85
+ .form-select-area.has-value ~ .form-select-area-label {
86
+ transform: scale(0.625) translateY(-0.625rem);
87
+ }
93
88
 
94
- .form-select-area:not(:disabled):focus {
95
- border-color: var(--road-input-outline-variant);
96
- }
89
+ .form-select-area:not(:disabled):focus {
90
+ border-color: var(--road-input-outline-variant);
91
+ }
97
92
 
98
- /**
99
- * Disabled state
100
- */
93
+ /**
94
+ * Disabled state
95
+ */
101
96
 
102
- .form-select-area:disabled,
103
- .form-select-area[readonly] {
104
- color: transparent;
105
- cursor: not-allowed;
106
- background: var(--road-surface-disabled);
107
- opacity: 1;
108
- }
97
+ .form-select-area:disabled,
98
+ .form-select-area[readonly] {
99
+ color: transparent;
100
+ cursor: not-allowed;
101
+ background: var(--road-surface-disabled);
102
+ opacity: 1;
103
+ }
109
104
 
110
- /* LABEL
111
- -------------------- */
112
-
113
- .form-select-area-label {
114
- position: absolute;
115
- top: 0.9rem;
116
- left: 1rem;
117
- display: block;
118
- font-size: var(--road-font-size-18);
119
- line-height: 1.5;
120
- color: var(--road-on-surface-extra-weak);
121
- pointer-events: none;
122
- transition: transform 200ms cubic-bezier(0, 0, 0.2, 1) 0ms;
123
- transform-origin: 0 0;
124
- }
105
+ /* LABEL
106
+ -------------------- */
125
107
 
126
- .form-select-area:required ~ .form-select-area-label::after{
127
- color: var(--road-on-danger-surface);
128
- content: " *";
129
- }
108
+ .form-select-area-label {
109
+ position: absolute;
110
+ top: 0.9rem;
111
+ left: 1rem;
112
+ display: block;
113
+ font-size: var(--road-font-size-18);
114
+ line-height: 1.5;
115
+ color: var(--road-on-surface-extra-weak);
116
+ pointer-events: none;
117
+ transition: transform 200ms cubic-bezier(0, 0, 0.2, 1) 0ms;
118
+ transform-origin: 0 0;
119
+ }
130
120
 
131
- /* Value
132
- -------------------- */
133
-
134
- .form-select-area-value {
135
- position: absolute;
136
- top: 1.4rem;
137
- left: 1rem;
138
- display: block;
139
- font-size: var(--road-label-medium);
140
- line-height: 1.5;
141
- color: var(--road-on-surface);
142
- pointer-events: none;
143
- transition: transform 200ms cubic-bezier(0, 0, 0.2, 1) 0ms;
144
- transform-origin: 0 0;
145
- }
121
+ .form-select-area:required ~ .form-select-area-label::after{
122
+ color: var(--road-on-danger-surface);
123
+ content: " *";
124
+ }
146
125
 
126
+ /* Value
127
+ -------------------- */
147
128
 
148
- /* SIZES
149
- -------------------- */
129
+ .form-select-area-value {
130
+ position: absolute;
131
+ top: 1.4rem;
132
+ left: 1rem;
133
+ display: block;
134
+ font-size: var(--road-label-medium);
135
+ line-height: 1.5;
136
+ color: var(--road-on-surface);
137
+ pointer-events: none;
138
+ transition: transform 200ms cubic-bezier(0, 0, 0.2, 1) 0ms;
139
+ transform-origin: 0 0;
140
+ }
150
141
 
151
- :host(.select-xl) .form-select-area {
152
- height: 3.5rem;
153
- padding: 0.75rem 0 0 1rem;
154
- }
155
142
 
156
- :host(.select-xl) .form-select-area-label {
157
- top: 1rem;
158
- }
143
+ /* SIZES
144
+ -------------------- */
159
145
 
160
- :host(.select-xl) .form-select-area:focus ~ .form-select-area-label,
161
- :host(.select-xl) .form-select-area[required]:valid ~ .form-select-area-label,
162
- :host(.select-xl) .form-select-area.has-value ~ .form-select-area-label,
163
- :host(.select-xl) .form-select-area[type="date"] ~ .form-select-area-label,
164
- :host(.select-xl) .form-select-area[type="time"] ~ .form-select-area-label {
165
- transform: scale(0.75) translateY(-0.625rem);
166
- }
146
+ :host(.select-xl) .form-select-area {
147
+ height: 3.5rem;
148
+ padding: 0.75rem 0 0 1rem;
149
+ }
167
150
 
168
- :host(.select-xl) .form-select-area:placeholder-shown ~ .form-select-area-label {
169
- transform: scale(0.75) translateY(-0.625rem);
170
- }
151
+ .input-xl {
152
+ height: 3.5rem;
153
+ padding: 0.75rem 0 0 1rem;
154
+ }
171
155
 
172
- /* ERROR
173
- -------------------- */
156
+ :host(.select-xl) .form-select-area-label {
157
+ top: 1rem;
158
+ }
174
159
 
175
- .invalid-feedback {
176
- display: none;
177
- width: 100%;
178
- margin-top: 0.5rem;
179
- font-size: var(--road-body-small);
180
- color: var(--road-on-danger-surface);
181
- }
160
+ :host(.select-xl) .form-select-area:focus ~ .form-select-area-label,
161
+ :host(.select-xl) .form-select-area[required]:valid ~ .form-select-area-label,
162
+ :host(.select-xl) .form-select-area.has-value ~ .form-select-area-label,
163
+ :host(.select-xl) .form-select-area[type="date"] ~ .form-select-area-label,
164
+ :host(.select-xl) .form-select-area[type="time"] ~ .form-select-area-label {
165
+ transform: scale(0.75) translateY(-0.625rem);
166
+ }
182
167
 
183
- .form-select-area.is-invalid,
184
- .was-validated .form-select-area:invalid {
185
- border-color: var(--road-on-danger-surface);
186
- }
168
+ :host(.select-xl) .form-select-area:placeholder-shown ~ .form-select-area-label {
169
+ transform: scale(0.75) translateY(-0.625rem);
170
+ }
187
171
 
188
- .form-select-area.is-invalid ~ .invalid-feedback,
189
- .was-validated .form-select-area:invalid ~ .invalid-feedback {
190
- display: block;
191
- }
172
+ /* ERROR
173
+ -------------------- */
192
174
 
175
+ .invalid-feedback {
176
+ gap: .25rem;
177
+ display: flex;
178
+ width: 100%;
179
+ margin: 0.5rem 0;
180
+ font-size: var(--road-body-small);
181
+ color: var(--road-on-danger-surface);
182
+ }
193
183
 
194
- .form-select-area option:checked::after {
195
- position: absolute;
196
- top: 0;
197
- left: 0;
198
- content: attr(data-content);
199
- }
184
+ .form-select-area.is-invalid,
185
+ .was-validated .form-select-area:invalid {
186
+ border-color: var(--road-on-danger-surface);
187
+ }
200
188
 
201
- .form-select-area::after {
202
- position: absolute;
203
- top: 0;
204
- left: 0;
205
- content: var(--selected-content, '');
206
- }
189
+ .form-select-area.is-invalid ~ .invalid-feedback,
190
+ .was-validated .form-select-area:invalid ~ .invalid-feedback {
191
+ display: block;
192
+ }
193
+
194
+
195
+ .form-select-area option:checked::after {
196
+ position: absolute;
197
+ top: 0;
198
+ left: 0;
199
+ content: attr(data-content);
200
+ }
201
+
202
+ .form-select-area::after {
203
+ position: absolute;
204
+ top: 0;
205
+ left: 0;
206
+ content: var(--selected-content, '');
207
+ }
208
+
209
+ /* -------------
210
+ INPUT FORM LABEL
211
+ --------------- */
212
+
213
+ .phone-number-input-label {
214
+ position: absolute;
215
+ top: 1rem;
216
+ left: 6rem;
217
+ display: block;
218
+ font-size: var(--road-body-medium);
219
+ line-height: 1.5;
220
+ color: var(--road-on-surface-weak);
221
+ pointer-events: none;
222
+ transition: transform 200ms cubic-bezier(0, 0, 0.2, 1) 0ms;
223
+ transform-origin: 0 0;
224
+ }
225
+
226
+ .phone-number-input-field:required ~ .phone-number-input-label::after{
227
+ color: var(--road-danger-default);
228
+ content: " *";
229
+ }
230
+
231
+ /**
232
+ * Focus state
233
+ */
234
+
235
+ .phone-number-input-field:focus ~ .phone-number-input-label,
236
+ .phone-number-input-field[required]:valid ~ .phone-number-input-label,
237
+ .phone-number-input-field.has-value ~ .phone-number-input-label {
238
+ transform: scale(0.625) translateY(-0.625rem);
239
+ }
240
+
241
+ .phone-number-input-field:placeholder-shown ~ .phone-number-input-label {
242
+ transform: scale(0.625) translateY(-0.625rem);
243
+ }
244
+
245
+ /* IE FIX */
246
+
247
+ .phone-number-input-field:-ms-input-placeholder ~ .phone-number-input-label {
248
+ transform: scale(0.625) translateY(-0.625rem);
249
+ }
250
+
251
+ .phone-number-inputs-container {
252
+ position: relative;
253
+ display: flex;
254
+ }
255
+
256
+ .road-phone-input-select {
257
+ margin-bottom: 1rem;
258
+ }
259
+
260
+ .is-error {
261
+ margin-bottom: 0;
262
+ }
263
+
264
+ /* -------------
265
+ FORM INPUT FIELD
266
+ ------------- */
267
+
268
+ .phone-number-input-field {
269
+ flex-grow: 1;
270
+ border: 1px solid var(--road-input-outline);
271
+ border-left: 0;
272
+ border-radius: 0.25rem;
273
+ border-bottom-left-radius: 0;
274
+ border-top-left-radius: 0;
275
+ }
@@ -1,5 +1,6 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { PhoneNumberFormat, PhoneNumberType, PhoneNumberUtil } from "google-libphonenumber";
3
+ import { forbiddenChars } from "./constants";
3
4
  let selectIds = 0;
4
5
  export class RoadPhoneNumberInput {
5
6
  constructor() {
@@ -26,12 +27,8 @@ export class RoadPhoneNumberInput {
26
27
  phone: this.resetPhoneUtilData(),
27
28
  };
28
29
  }
29
- updateMessagePosition() {
30
- this.placeErrorMessage();
31
- }
32
30
  // On component load
33
31
  componentWillLoad() {
34
- this.placeErrorMessage();
35
32
  let fromSelect = false;
36
33
  if (this.phoneValue) {
37
34
  this.phoneNumber = this.phoneValue;
@@ -48,35 +45,17 @@ export class RoadPhoneNumberInput {
48
45
  }
49
46
  // On user input
50
47
  handleInput(event) {
51
- this.phoneNumber = event.detail.value;
48
+ const input = event.target;
49
+ this.phoneNumber = input.value;
52
50
  this.createAndDispatchPhoneData();
53
51
  }
54
52
  // On user key down
55
53
  handleKeyDown(event) {
56
- // Liste des caractères interdits
57
- const caracteresInterdits = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '=', '[', ']', '{', '}', '|', ';', ':', "'", '"', ',', '.', '<', '>', '/', '?'];
58
- // Vérifier si la touche pressée est dans la liste des caractères interdits
59
- if (caracteresInterdits.includes(event.key)) {
54
+ // checks if the forbidden characters's list contains the pressed key
55
+ if (forbiddenChars.includes(event.key)) {
60
56
  event.preventDefault();
61
57
  }
62
58
  }
63
- // On user key up
64
- handleKeyUp(event) {
65
- // Récupérer la valeur saisie
66
- const inputValue = event.target.value || '';
67
- // Vérifier si la valeur contient uniquement des chiffres ou le symbole "+"
68
- const containsOnlyNumbersAndPlus = /^[0-9+]*$/.test(inputValue);
69
- // Si la valeur ne contient pas uniquement des chiffres ou le symbole "+", réinitialiser le champ de saisie à son état précédent
70
- if (!containsOnlyNumbersAndPlus) {
71
- // Réinitialiser la valeur du champ de saisie à son état précédent
72
- event.target.value = this.phoneNumber;
73
- }
74
- else {
75
- // Si la valeur contient uniquement des chiffres ou le symbole "+", mettre à jour la valeur du numéro de téléphone
76
- this.phoneNumber = inputValue;
77
- this.createAndDispatchPhoneData();
78
- }
79
- }
80
59
  // On user select
81
60
  handleSelect(event) {
82
61
  const select = event.target;
@@ -88,6 +67,7 @@ export class RoadPhoneNumberInput {
88
67
  this.updateCountryOptions();
89
68
  }
90
69
  createAndDispatchPhoneData(fromSelect) {
70
+ var _a;
91
71
  // Init phone util
92
72
  const phoneUtil = PhoneNumberUtil.getInstance();
93
73
  const PNF = PhoneNumberFormat;
@@ -95,7 +75,7 @@ export class RoadPhoneNumberInput {
95
75
  this.returnObject.phone = this.resetPhoneUtilData();
96
76
  const tmpCountry = this.selectedCountry.length ? this.selectedCountry : this.countryData[0].countryCode;
97
77
  try {
98
- const parsedPhoneNumber = phoneUtil.parse(this.phoneNumber, tmpCountry);
78
+ const parsedPhoneNumber = phoneUtil.parse((_a = this.phoneNumber) !== null && _a !== void 0 ? _a : '', tmpCountry);
99
79
  this.returnObject.isError = !phoneUtil.isValidNumber(parsedPhoneNumber) && !this.isEmptyPhoneNumber();
100
80
  this.returnObject.phone.nationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.NATIONAL);
101
81
  this.returnObject.phone.internationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.INTERNATIONAL);
@@ -117,7 +97,7 @@ export class RoadPhoneNumberInput {
117
97
  const phoneType = Object.entries(PhoneNumberType).find(entry => entry[1] === phoneUtil.getNumberType(parsedPhoneNumber));
118
98
  this.returnObject.phone.numberType = phoneType[0];
119
99
  }
120
- catch (_a) { }
100
+ catch (_b) { }
121
101
  finally {
122
102
  this.roadPhoneNumberInput.emit(this.returnObject);
123
103
  }
@@ -130,16 +110,18 @@ export class RoadPhoneNumberInput {
130
110
  this.selectedCountry = value;
131
111
  }
132
112
  resetPhoneUtilData() {
113
+ var _a, _b;
133
114
  return {
134
115
  numberType: 'UNKNOWN',
135
116
  countryCode: this.selectedCountry,
136
117
  code: this.selectedCountryCode,
137
- nationalNumber: this.phoneNumber,
138
- internationalNumber: this.phoneNumber,
118
+ nationalNumber: (_a = this.phoneNumber) !== null && _a !== void 0 ? _a : '',
119
+ internationalNumber: (_b = this.phoneNumber) !== null && _b !== void 0 ? _b : '',
139
120
  };
140
121
  }
141
122
  isEmptyPhoneNumber() {
142
- return !this.phoneNumber.length;
123
+ var _a;
124
+ return !((_a = this.phoneNumber) === null || _a === void 0 ? void 0 : _a.length);
143
125
  }
144
126
  getPhoneCodeFromCountryCode(countryCode) {
145
127
  var _a;
@@ -164,38 +146,22 @@ export class RoadPhoneNumberInput {
164
146
  },
165
147
  ];
166
148
  }
167
- placeErrorMessage() {
168
- this.waitForElementToExist('.invalid-feedback').then((messError) => {
169
- messError.style.display = "flex";
170
- messError.style.marginTop = "-0.5rem";
171
- const phoneNumberInput = this.el;
172
- phoneNumberInput.appendChild(messError);
173
- });
174
- }
175
- waitForElementToExist(selector) {
176
- return new Promise(resolve => {
177
- if (document.querySelector(selector)) {
178
- return resolve(document.querySelector(selector));
179
- }
180
- const observer = new MutationObserver(() => {
181
- if (document.querySelector(selector)) {
182
- resolve(document.querySelector(selector));
183
- observer.disconnect();
184
- }
185
- });
186
- observer.observe(document.body, {
187
- subtree: true,
188
- childList: true,
189
- });
190
- });
149
+ hasValue() {
150
+ return this.phoneNumber !== '' && this.phoneNumber !== null;
191
151
  }
192
152
  render() {
193
- const selectId = `road-select-${selectIds++}`;
153
+ const id = selectIds++;
154
+ const selectId = `road-phone-number-select-${id}`;
155
+ const inputId = `road-phone-number-input-${id}`;
194
156
  const labelId = selectId + '-label';
195
157
  const valueId = selectId + '-value';
196
158
  const isInvalidClass = this.errorMessage.length ? 'is-invalid' : '';
197
159
  const isErrorClass = this.errorMessage.length ? 'is-error' : '';
198
- return (h(Host, { key: 'eda1808cf7138f507656e3b3a9fa367fca5d598a' }, h("road-input-group", { key: '2c110dd86bd69aa2619fd54697992dfa54cafe7f' }, h("div", { key: 'cca235435d4edefaf271e75df90236a327805a98', class: `road-phone-input-select ${isErrorClass}`, slot: "prepend" }, h("select", { key: 'f734b4ac6b7bb88ae209689fdf85ce8d3d631302', id: 'phone-number-input', class: `form-select-area has-value ${isInvalidClass}`, "aria-disabled": this.disabled ? 'true' : null, disabled: this.disabled, onChange: (event) => this.handleSelect(event), "aria-label": this.codeLabel, tabIndex: this.disabled ? -1 : 0 }, this.countryOptions && this.countryOptions.map(option => (h("option", { value: option.value, disabled: option.disabled, selected: option.selected }, option.label)))), h("label", { key: '89255560eed68abaf4d2125e62e96695cec49fcf', class: "form-select-area-label", id: labelId, htmlFor: selectId }, this.codeLabel), h("label", { key: '402c5307460ffdbd82281ccce5174687743c01ed', class: "form-select-area-value", id: valueId, htmlFor: selectId }, "+", this.selectedCountryCode)), h("road-input", { key: '4d151be9354c9225bafc8cc05b6ebfcfc075e92c', type: "tel", id: "phone-number", sizes: "xl", label: this.phoneLabel, value: this.phoneValue, onRoadChange: (event) => this.handleInput(event), required: this.required, error: this.errorMessage, onKeyDown: (event) => this.handleKeyDown(event), tabIndex: 0 }))));
160
+ const hasValueClass = this.hasValue() ? 'has-value' : '';
161
+ const sizes = 'xl';
162
+ return (h(Host, { key: '9f90460c652db496fc88dd4b8e611bdf348e3f5a' }, h("div", { key: '03fceb8966c9622782a0341a2f0a01511cfe7006', class: 'phone-number-inputs-container' }, h("div", { key: '4a889f1e223cf354a262fd68d948c05dc265a14b', class: `road-phone-input-select ${isErrorClass} ${isInvalidClass}`, slot: "prepend" }, h("select", { key: 'cc520dea43d2b64645f9cbf67c768efce7790079', id: selectId, class: `form-select-area has-value`, "aria-disabled": this.disabled ? 'true' : null, disabled: this.disabled, onChange: (event) => this.handleSelect(event), "aria-label": this.codeLabel, tabIndex: this.disabled ? -1 : 0 }, this.countryOptions && this.countryOptions.map(option => (h("option", { value: option.value, disabled: option.disabled, selected: option.selected }, option.label)))), h("label", { key: '6769d2bda09b72449a566ece542ebf7edc5a0e40', class: "form-select-area-label", id: labelId, htmlFor: selectId }, this.codeLabel), h("label", { key: '513bfd2c0eab6609d74eb7b9ebc14a212be4cc9d', class: "form-select-area-value", id: valueId, htmlFor: selectId }, "+", this.selectedCountryCode)), h("input", { key: 'db609e065a32f7014c6d32dec4aae86b2b607e77', type: 'tel', id: inputId, class: `input-${sizes} phone-number-input-field ${hasValueClass} ${isErrorClass}`, value: this.phoneValue, required: this.required, tabIndex: 0, onInput: (event) => this.handleInput(event), onKeyDown: (event) => this.handleKeyDown(event) }), h("label", { key: 'cac7f2ae8afa700db8871bc4d2b35f49822ca179', class: "phone-number-input-label", id: labelId, htmlFor: inputId }, this.phoneLabel)), this.errorMessage
163
+ && this.errorMessage !== ''
164
+ && h("p", { key: 'cb521ea80ae33ce0743a64270d47234cc0bdf114', class: "invalid-feedback" }, h("road-icon", { key: '1dcf2587dabc46402d1c16bbf75604aedfc4d54d', slot: "start", color: 'danger', name: "alert-error-solid", "aria-hidden": "true", size: "sm" }), this.errorMessage)));
199
165
  }
200
166
  static get is() { return "road-phone-number-input"; }
201
167
  static get encapsulation() { return "scoped"; }
@@ -423,11 +389,5 @@ export class RoadPhoneNumberInput {
423
389
  }];
424
390
  }
425
391
  static get elementRef() { return "el"; }
426
- static get watchers() {
427
- return [{
428
- "propName": "errorMessage",
429
- "methodName": "updateMessagePosition"
430
- }];
431
- }
432
392
  }
433
393
  //# sourceMappingURL=phone-number-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phone-number-input.js","sourceRoot":"","sources":["../../../src/components/phone-number-input/phone-number-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI5F,IAAI,SAAS,GAAG,CAAC,CAAC;AAOlB,MAAM,OAAO,oBAAoB;IALjC;QAqBE,0BAA0B;QAClB,aAAQ,GAAY,KAAK,CAAC;QAElC,iJAAiJ;QACzI,gBAAW,GAAkB,EAAE,CAAC;QAExC,wDAAwD;QAChD,aAAQ,GAAW,IAAI,CAAC;QAEhC,oCAAoC;QAC5B,cAAS,GAAW,EAAE,CAAC;QAE/B,8BAA8B;QACtB,eAAU,GAAW,EAAE,CAAC;QAQhC,0DAA0D;QAClD,iBAAY,GAAW,EAAE,CAAC;QAElC,oCAAoC;QAC5B,aAAQ,GAAG,KAAK,CAAC;QAEhB,oBAAe,GAAW,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QAC1D,wBAAmB,GAAW,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5D,gBAAW,GAAW,EA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, Prop, Element, Host, State, h, Event, EventEmitter, Watch } from '@stencil/core';\nimport { PhoneNumberFormat, PhoneNumberType, PhoneNumberUtil } from 'google-libphonenumber';\nimport { CountryOption, CountryType, PhoneReturnType, ReturnObject } from './interfaces';\nimport { RoadInputCustomEvent } from '../../components';\n\nlet selectIds = 0;\n\n@Component({\n tag: 'road-phone-number-input',\n styleUrl: 'phone-number-input.css',\n scoped: true,\n})\nexport class RoadPhoneNumberInput {\n\n /** Computed phone data */\n @Event() roadPhoneNumberInput!: EventEmitter<{\n isError: boolean;\n phone: {\n numberType: string;\n countryCode: string;\n nationalNumber: string;\n code: string;\n internationalNumber: string;\n };\n }>;\n\n @Element() el!: HTMLRoadPhoneNumberInputElement;\n\n /** Disable both fields */\n @Prop() disabled: boolean = false;\n\n /** List of countries displayed in the country selection. Countries will be automatically sorted by alphabetical order (see format in example) */\n @Prop() countryData: CountryType[] = [];\n\n /** Used to display countries with the right language */\n @Prop() language: string = 'fr';\n\n /** Country selection placeHolder */\n @Prop() codeLabel: string = '';\n\n /** Phone input placeHolder */\n @Prop() phoneLabel: string = '';\n\n /** Value displayed in the phone input */\n @Prop() phoneValue?: string;\n\n /** Selected country code */\n @Prop() countryCode?: string;\n\n /** Error message (displayed only if ther is a message) */\n @Prop() errorMessage: string = '';\n\n /** Add a star in the phone input */\n @Prop() required = false;\n\n @State() selectedCountry: string = this.countryData[0].countryCode;\n @State() selectedCountryCode: string = this.countryData[0].phoneCode;\n @State() phoneNumber: string = '';\n @State() countryOptions: CountryOption[] = [];\n @State() returnObject: ReturnObject = {\n isError: false,\n phone: this.resetPhoneUtilData(),\n };\n\n @Watch('errorMessage')\n updateMessagePosition() {\n this.placeErrorMessage();\n }\n\n // On component load\n componentWillLoad() {\n this.placeErrorMessage();\n let fromSelect = false;\n\n if (this.phoneValue) {\n this.phoneNumber = this.phoneValue;\n }\n\n if (this.countryCode) {\n this.selectedCountry = this.countryCode;\n if (this.getPhoneCodeFromCountryCode(this.countryCode)) {\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.countryCode)!);\n fromSelect = true;\n }\n }\n\n this.updateCountryOptions();\n this.createAndDispatchPhoneData(fromSelect);\n }\n\n // On user input\n handleInput(event: RoadInputCustomEvent<{\n value: string | null | undefined;\n }>) {\n this.phoneNumber = event.detail.value!;\n this.createAndDispatchPhoneData();\n }\n \n\n // On user key down\n handleKeyDown(event: KeyboardEvent) {\n // Liste des caractères interdits\n const caracteresInterdits = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '=', '[', ']', '{', '}', '|', ';', ':', \"'\", '\"', ',', '.', '<', '>', '/', '?'];\n \n // Vérifier si la touche pressée est dans la liste des caractères interdits\n if (caracteresInterdits.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n // On user key up\n handleKeyUp(event: KeyboardEvent) {\n // Récupérer la valeur saisie\n const inputValue = (event.target as HTMLInputElement).value || '';\n\n // Vérifier si la valeur contient uniquement des chiffres ou le symbole \"+\"\n const containsOnlyNumbersAndPlus = /^[0-9+]*$/.test(inputValue);\n\n // Si la valeur ne contient pas uniquement des chiffres ou le symbole \"+\", réinitialiser le champ de saisie à son état précédent\n if (!containsOnlyNumbersAndPlus) {\n // Réinitialiser la valeur du champ de saisie à son état précédent\n (event.target as HTMLInputElement).value = this.phoneNumber;\n } else {\n // Si la valeur contient uniquement des chiffres ou le symbole \"+\", mettre à jour la valeur du numéro de téléphone\n this.phoneNumber = inputValue;\n this.createAndDispatchPhoneData();\n }\n }\n\n // On user select\n handleSelect(event: Event) {\n const select = event.target as HTMLSelectElement | null;\n if (select) {\n this.updateSelectedCountry(select.value);\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.selectedCountry)!);\n }\n this.createAndDispatchPhoneData(true);\n this.updateCountryOptions();\n }\n\n createAndDispatchPhoneData(fromSelect?: boolean) {\n // Init phone util\n const phoneUtil = PhoneNumberUtil.getInstance();\n const PNF = PhoneNumberFormat;\n\n // Reset the return object data\n this.returnObject.phone = this.resetPhoneUtilData();\n\n const tmpCountry = this.selectedCountry.length ? this.selectedCountry : this.countryData[0].countryCode;\n\n try {\n const parsedPhoneNumber = phoneUtil.parse(this.phoneNumber, tmpCountry);\n this.returnObject.isError = !phoneUtil.isValidNumber(parsedPhoneNumber) && !this.isEmptyPhoneNumber();\n this.returnObject.phone.nationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.NATIONAL);\n this.returnObject.phone.internationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.INTERNATIONAL);\n\n // Set the country code values depending on the event origin\n if (phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)) {\n if (fromSelect) {\n this.returnObject.isError = !(\n phoneUtil.isValidNumber(parsedPhoneNumber) &&\n phoneUtil.isValidNumberForRegion(parsedPhoneNumber, this.selectedCountry) &&\n !this.isEmptyPhoneNumber()\n );\n } else {\n this.updateSelectedCountryCode(parsedPhoneNumber.getCountryCode()!.toString());\n this.updateSelectedCountry(phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)!);\n\n this.returnObject.phone.countryCode = this.selectedCountry;\n this.returnObject.phone.code = this.selectedCountryCode;\n }\n this.updateCountryOptions();\n }\n\n const phoneType = Object.entries(PhoneNumberType).find(entry => entry[1] === phoneUtil.getNumberType(parsedPhoneNumber))!;\n this.returnObject.phone.numberType = phoneType[0];\n } catch {} finally {\n this.roadPhoneNumberInput.emit(this.returnObject);\n }\n }\n\n // utils\n\n updateSelectedCountryCode(countryCode: string) {\n this.selectedCountryCode = countryCode;\n }\n\n updateSelectedCountry(value: string) {\n this.selectedCountry = value;\n }\n\n resetPhoneUtilData(): PhoneReturnType {\n return {\n numberType: 'UNKNOWN',\n countryCode: this.selectedCountry,\n code: this.selectedCountryCode,\n nationalNumber: this.phoneNumber,\n internationalNumber: this.phoneNumber,\n };\n }\n\n isEmptyPhoneNumber(): boolean {\n return !this.phoneNumber.length;\n }\n\n getPhoneCodeFromCountryCode(countryCode: string): string | undefined {\n return this.countryData.find(country => country.countryCode === countryCode)?.phoneCode;\n }\n\n updateCountryOptions() {\n const validLanguage = this.countryData[0].translations[this.language] ? this.language : 'fr';\n this.countryOptions = [\n ...this.countryData\n .sort((a, b) => a.translations[validLanguage].localeCompare(b.translations[validLanguage]))\n .map(country => ({\n value: country.countryCode,\n label: `${country.translations[validLanguage]} (+${country.phoneCode})`,\n selected: country.countryCode === this.selectedCountry,\n disabled: false,\n })\n ),\n {\n value: '',\n label: '--',\n selected: this.countryData.every((country) => country.countryCode !== this.selectedCountry),\n disabled: true,\n },\n ];\n }\n\n placeErrorMessage() {\n this.waitForElementToExist('.invalid-feedback').then((messError: HTMLElement) => {\n messError.style.display = \"flex\";\n messError.style.marginTop = \"-0.5rem\";\n const phoneNumberInput = (this.el as HTMLRoadPhoneNumberInputElement);\n phoneNumberInput.appendChild(messError);\n });\n }\n\n waitForElementToExist(selector: string): Promise<HTMLElement> {\n return new Promise(resolve => {\n if (document.querySelector(selector)) {\n return resolve(document.querySelector(selector) as HTMLElement);\n }\n\n const observer = new MutationObserver(() => {\n if (document.querySelector(selector)) {\n resolve(document.querySelector(selector) as HTMLElement);\n observer.disconnect();\n }\n });\n\n observer.observe(document.body, {\n subtree: true,\n childList: true,\n });\n });\n }\n\n render() {\n const selectId = `road-select-${selectIds++}`;\n const labelId = selectId + '-label';\n const valueId = selectId + '-value';\n const isInvalidClass = this.errorMessage.length ? 'is-invalid' : '';\n const isErrorClass = this.errorMessage.length ? 'is-error' : '';\n\n return (\n <Host>\n <road-input-group>\n <div class={`road-phone-input-select ${isErrorClass}`} slot=\"prepend\">\n <select\n id='phone-number-input'\n class={`form-select-area has-value ${isInvalidClass}`}\n aria-disabled={this.disabled ? 'true' : null}\n disabled={this.disabled}\n onChange={(event) => this.handleSelect(event)}\n aria-label={this.codeLabel}\n tabIndex={this.disabled ? -1 : 0}\n >\n {this.countryOptions && this.countryOptions.map(option => (\n <option value={option.value} disabled={option.disabled} selected={option.selected}>{option.label}</option>\n ))}\n </select>\n <label class=\"form-select-area-label\" id={labelId} htmlFor={selectId}>{this.codeLabel}</label>\n <label class=\"form-select-area-value\" id={valueId} htmlFor={selectId}>+{this.selectedCountryCode}</label>\n </div>\n <road-input\n type=\"tel\"\n id=\"phone-number\"\n sizes=\"xl\"\n label={this.phoneLabel}\n value={this.phoneValue}\n onRoadChange={(event) => this.handleInput(event)}\n required={this.required}\n error={this.errorMessage}\n onKeyDown={(event) => this.handleKeyDown(event)} // Lier la fonction handleKeyDown à l'événement onKeyDown\n tabIndex={0}\n >\n </road-input>\n </road-input-group>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"phone-number-input.js","sourceRoot":"","sources":["../../../src/components/phone-number-input/phone-number-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,IAAI,SAAS,GAAG,CAAC,CAAC;AAOlB,MAAM,OAAO,oBAAoB;IALjC;QAqBE,0BAA0B;QAClB,aAAQ,GAAY,KAAK,CAAC;QAElC,iJAAiJ;QACzI,gBAAW,GAAkB,EAAE,CAAC;QAExC,wDAAwD;QAChD,aAAQ,GAAW,IAAI,CAAC;QAEhC,oCAAoC;QAC5B,cAAS,GAAW,EAAE,CAAC;QAE/B,8BAA8B;QACtB,eAAU,G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EAAE,EACjF,KAAK,EAAE,IAAI,CAAC,UAAU,EACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,CAAC,KAAiB,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EACvD,SAAS,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,GAC9D;gBACF,8DACE,KAAK,EAAC,0BAA0B,EAChC,EAAE,EAAE,OAAO,EACX,OAAO,EAAE,OAAO,IAEf,IAAI,CAAC,UAAU,CACV,CACJ;YAEJ,IAAI,CAAC,YAAY;mBACd,IAAI,CAAC,YAAY,KAAK,EAAE;mBACxB,0DAAG,KAAK,EAAC,kBAAkB;oBAC5B,kEACE,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,QAAQ,EACd,IAAI,EAAC,mBAAmB,iBACZ,MAAM,EAClB,IAAI,EAAC,IAAI,GACT;oBACD,IAAI,CAAC,YAAY,CAChB,CAED,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Element, Host, State, h, Event, EventEmitter } from '@stencil/core';\nimport { PhoneNumberFormat, PhoneNumberType, PhoneNumberUtil } from 'google-libphonenumber';\nimport { CountryOption, CountryType, PhoneReturnType, ReturnObject } from './interfaces';\nimport { forbiddenChars } from './constants';\n\nlet selectIds = 0;\n\n@Component({\n tag: 'road-phone-number-input',\n styleUrl: 'phone-number-input.css',\n scoped: true,\n})\nexport class RoadPhoneNumberInput {\n\n /** Computed phone data */\n @Event() roadPhoneNumberInput!: EventEmitter<{\n isError: boolean;\n phone: {\n numberType: string;\n countryCode: string;\n nationalNumber: string;\n code: string;\n internationalNumber: string;\n };\n }>;\n\n @Element() el!: HTMLRoadPhoneNumberInputElement;\n\n /** Disable both fields */\n @Prop() disabled: boolean = false;\n\n /** List of countries displayed in the country selection. Countries will be automatically sorted by alphabetical order (see format in example) */\n @Prop() countryData: CountryType[] = [];\n\n /** Used to display countries with the right language */\n @Prop() language: string = 'fr';\n\n /** Country selection placeHolder */\n @Prop() codeLabel: string = '';\n\n /** Phone input placeHolder */\n @Prop() phoneLabel: string = '';\n\n /** Value displayed in the phone input */\n @Prop() phoneValue?: string;\n\n /** Selected country code */\n @Prop() countryCode?: string;\n\n /** Error message (displayed only if ther is a message) */\n @Prop() errorMessage: string = '';\n\n /** Add a star in the phone input */\n @Prop() required = false;\n\n @State() selectedCountry: string = this.countryData[0].countryCode;\n @State() selectedCountryCode: string = this.countryData[0].phoneCode;\n @State() phoneNumber: string | null = '';\n @State() countryOptions: CountryOption[] = [];\n @State() returnObject: ReturnObject = {\n isError: false,\n phone: this.resetPhoneUtilData(),\n };\n\n // On component load\n componentWillLoad() {\n let fromSelect = false;\n\n if (this.phoneValue) {\n this.phoneNumber = this.phoneValue;\n }\n\n if (this.countryCode) {\n this.selectedCountry = this.countryCode;\n if (this.getPhoneCodeFromCountryCode(this.countryCode)) {\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.countryCode)!);\n fromSelect = true;\n }\n }\n\n this.updateCountryOptions();\n this.createAndDispatchPhoneData(fromSelect);\n }\n\n // On user input\n handleInput(event: Event) {\n const input = event.target as HTMLInputElement;\n this.phoneNumber = input.value;\n this.createAndDispatchPhoneData();\n }\n\n\n // On user key down\n handleKeyDown(event: KeyboardEvent) {\n // checks if the forbidden characters's list contains the pressed key\n if (forbiddenChars.includes(event.key)) {\n event.preventDefault();\n }\n }\n\n // On user select\n handleSelect(event: Event) {\n const select = event.target as HTMLSelectElement | null;\n if (select) {\n this.updateSelectedCountry(select.value);\n this.updateSelectedCountryCode(this.getPhoneCodeFromCountryCode(this.selectedCountry)!);\n }\n this.createAndDispatchPhoneData(true);\n this.updateCountryOptions();\n }\n\n createAndDispatchPhoneData(fromSelect?: boolean) {\n // Init phone util\n const phoneUtil = PhoneNumberUtil.getInstance();\n const PNF = PhoneNumberFormat;\n\n // Reset the return object data\n this.returnObject.phone = this.resetPhoneUtilData();\n\n const tmpCountry = this.selectedCountry.length ? this.selectedCountry : this.countryData[0].countryCode;\n\n try {\n const parsedPhoneNumber = phoneUtil.parse(this.phoneNumber ?? '', tmpCountry);\n this.returnObject.isError = !phoneUtil.isValidNumber(parsedPhoneNumber) && !this.isEmptyPhoneNumber();\n this.returnObject.phone.nationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.NATIONAL);\n this.returnObject.phone.internationalNumber = phoneUtil.format(parsedPhoneNumber, PNF.INTERNATIONAL);\n\n // Set the country code values depending on the event origin\n if (phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)) {\n if (fromSelect) {\n this.returnObject.isError = !(\n phoneUtil.isValidNumber(parsedPhoneNumber) &&\n phoneUtil.isValidNumberForRegion(parsedPhoneNumber, this.selectedCountry) &&\n !this.isEmptyPhoneNumber()\n );\n } else {\n this.updateSelectedCountryCode(parsedPhoneNumber.getCountryCode()!.toString());\n this.updateSelectedCountry(phoneUtil.getRegionCodeForNumber(parsedPhoneNumber)!);\n\n this.returnObject.phone.countryCode = this.selectedCountry;\n this.returnObject.phone.code = this.selectedCountryCode;\n }\n this.updateCountryOptions();\n }\n\n const phoneType = Object.entries(PhoneNumberType).find(entry => entry[1] === phoneUtil.getNumberType(parsedPhoneNumber))!;\n this.returnObject.phone.numberType = phoneType[0];\n } catch {} finally {\n this.roadPhoneNumberInput.emit(this.returnObject);\n }\n }\n\n // utils\n\n updateSelectedCountryCode(countryCode: string) {\n this.selectedCountryCode = countryCode;\n }\n\n updateSelectedCountry(value: string) {\n this.selectedCountry = value;\n }\n\n resetPhoneUtilData(): PhoneReturnType {\n return {\n numberType: 'UNKNOWN',\n countryCode: this.selectedCountry,\n code: this.selectedCountryCode,\n nationalNumber: this.phoneNumber ?? '',\n internationalNumber: this.phoneNumber ?? '',\n };\n }\n\n isEmptyPhoneNumber(): boolean {\n return !this.phoneNumber?.length;\n }\n\n getPhoneCodeFromCountryCode(countryCode: string): string | undefined {\n return this.countryData.find(country => country.countryCode === countryCode)?.phoneCode;\n }\n\n updateCountryOptions() {\n const validLanguage = this.countryData[0].translations[this.language] ? this.language : 'fr';\n this.countryOptions = [\n ...this.countryData\n .sort((a, b) => a.translations[validLanguage].localeCompare(b.translations[validLanguage]))\n .map(country => ({\n value: country.countryCode,\n label: `${country.translations[validLanguage]} (+${country.phoneCode})`,\n selected: country.countryCode === this.selectedCountry,\n disabled: false,\n })\n ),\n {\n value: '',\n label: '--',\n selected: this.countryData.every((country) => country.countryCode !== this.selectedCountry),\n disabled: true,\n },\n ];\n }\n\n private hasValue(): boolean {\n return this.phoneNumber !== '' && this.phoneNumber !== null;\n }\n\n render() {\n const id = selectIds++;\n const selectId = `road-phone-number-select-${id}`;\n const inputId = `road-phone-number-input-${id}`;\n const labelId = selectId + '-label';\n const valueId = selectId + '-value';\n const isInvalidClass = this.errorMessage.length ? 'is-invalid' : '';\n const isErrorClass = this.errorMessage.length ? 'is-error' : '';\n const hasValueClass = this.hasValue() ? 'has-value' : '';\n const sizes = 'xl';\n\n return (\n <Host>\n <div class='phone-number-inputs-container'>\n <div class={`road-phone-input-select ${isErrorClass} ${isInvalidClass}`} slot=\"prepend\">\n <select\n id={selectId}\n class={`form-select-area has-value`}\n aria-disabled={this.disabled ? 'true' : null}\n disabled={this.disabled}\n onChange={(event) => this.handleSelect(event)}\n aria-label={this.codeLabel}\n tabIndex={this.disabled ? -1 : 0}\n >\n {this.countryOptions && this.countryOptions.map(option => (\n <option value={option.value} disabled={option.disabled} selected={option.selected}>{option.label}</option>\n ))}\n </select>\n <label class=\"form-select-area-label\" id={labelId} htmlFor={selectId}>{this.codeLabel}</label>\n <label class=\"form-select-area-value\" id={valueId} htmlFor={selectId}>+{this.selectedCountryCode}</label>\n </div>\n <input\n type='tel'\n id={inputId}\n class={`input-${sizes} phone-number-input-field ${hasValueClass} ${isErrorClass}`}\n value={this.phoneValue}\n required={this.required}\n tabIndex={0}\n onInput={(event: InputEvent) => this.handleInput(event)}\n onKeyDown={(event: KeyboardEvent) => this.handleKeyDown(event)}\n />\n <label\n class=\"phone-number-input-label\"\n id={labelId}\n htmlFor={inputId}\n >\n {this.phoneLabel}\n </label>\n </div>\n {\n this.errorMessage\n && this.errorMessage !== ''\n && <p class=\"invalid-feedback\">\n <road-icon\n slot=\"start\"\n color='danger'\n name=\"alert-error-solid\"\n aria-hidden=\"true\"\n size=\"sm\"\n />\n {this.errorMessage}\n </p>\n }\n </Host>\n );\n }\n}\n"]}
@@ -92,10 +92,10 @@ export class PlateNumber {
92
92
  render() {
93
93
  const value = this.getValue();
94
94
  const motorbikeClass = this.motorbike ? 'motorbike-plate' : '';
95
- return (h("road-input-group", { key: '7980cc259f449b537eb2a03fc4e291f1d1969bfb', class: `plate-number plate-number-${this.country.toLowerCase()} ${motorbikeClass}` }, h("label", { key: '3149ae01f12aadde00cb72903b09c73a45816732', slot: "prepend", class: "input-group-prepend" }, h("div", { key: '21220cb22eccab0efab05f44a1127bcb6cbd204f', class: "plate-number-start" }, h("road-icon", { key: '2b1e4f33543c17399f1d19088f3d71c1d15c0248', class: "plate-number-icon", icon: licensePlateStarEu }), h("div", { key: 'ab3f376b26c1bc8b8dcc0741a8d651bf5ef2ab66', class: "plate-number-location", "aria-label": this.country, role: "img" }, this.countries
95
+ return (h("road-input-group", { key: 'd99ec720113a121c58794385a2a697459cc4e0eb', class: `plate-number plate-number-${this.country.toLowerCase()} ${motorbikeClass}` }, h("label", { key: '559c8428a6403ee087bc219b6027b12a48c658d8', slot: "prepend", class: "input-group-prepend" }, h("div", { key: '8483940a622fb54e8bc29dfeaf3ade7aaeeb0e8c', class: "plate-number-start" }, h("road-icon", { key: 'ba60f444919f5b6221fe4d910ced4bec521e4101', class: "plate-number-icon", icon: licensePlateStarEu }), h("div", { key: '095d70b607191a292c5857559566954122c5081c', class: "plate-number-location", "aria-label": this.country, role: "img" }, this.countries
96
96
  .filter(item => item.country === this.country)[0].letter))), this.motorbike
97
97
  ? (h("textarea", { class: "form-control plate-number-input mb-0", disabled: this.disabled, placeholder: this.placeholder != null ? this.placeholder : this.countries.filter(item => item.country === this.country)[0].placeholder, readOnly: this.readonly, maxlength: "9", rows: 2, onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus }))
98
- : (h("input", { class: "plate-number-input mb-0", disabled: this.disabled, placeholder: this.placeholder != null ? this.placeholder : this.countries.filter(item => item.country === this.country)[0].placeholder, readOnly: this.readonly, value: value, onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus })), h("label", { key: '247d5b0a7be0f8d5012f5954d569c674e5f294a2', slot: "append", class: "input-group-append" }, h("div", { key: '7ddc6a2c9e8bc5a41677cda5f3b48ae000952d08', class: "plate-number-end" }))));
98
+ : (h("input", { class: "plate-number-input mb-0", disabled: this.disabled, placeholder: this.placeholder != null ? this.placeholder : this.countries.filter(item => item.country === this.country)[0].placeholder, readOnly: this.readonly, value: value, onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus })), h("label", { key: '28ce8da1e17d33750056cbbb7b62686f492b4f6d', slot: "append", class: "input-group-append" }, h("div", { key: 'a7fd028f9e8457e1b865abbe79539223d64c7087', class: "plate-number-end" }))));
99
99
  }
100
100
  static get is() { return "road-plate-number"; }
101
101
  static get encapsulation() { return "scoped"; }