@rxdrag/website-lib-core 0.0.63 → 0.0.65

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.
@@ -0,0 +1,243 @@
1
+ export type CountryDial = {
2
+ code: string; // ISO 3166-1 alpha-2
3
+ name: string; // English name
4
+ region?: string; // Continent/region label
5
+ dialCode: string; // +NN
6
+ };
7
+
8
+ // Note: Names follow common English naming used in international forms.
9
+ // Region is a coarse grouping for search hints.
10
+ export const countries: CountryDial[] = [
11
+ { code: "AF", name: "Afghanistan", region: "Asia", dialCode: "+93" },
12
+ { code: "AL", name: "Albania", region: "Europe", dialCode: "+355" },
13
+ { code: "DZ", name: "Algeria", region: "Africa", dialCode: "+213" },
14
+ { code: "AS", name: "American Samoa", region: "Oceania", dialCode: "+1" },
15
+ { code: "AD", name: "Andorra", region: "Europe", dialCode: "+376" },
16
+ { code: "AO", name: "Angola", region: "Africa", dialCode: "+244" },
17
+ { code: "AI", name: "Anguilla", region: "North America", dialCode: "+1" },
18
+ { code: "AG", name: "Antigua and Barbuda", region: "North America", dialCode: "+1" },
19
+ { code: "AR", name: "Argentina", region: "South America", dialCode: "+54" },
20
+ { code: "AM", name: "Armenia", region: "Asia", dialCode: "+374" },
21
+ { code: "AW", name: "Aruba", region: "North America", dialCode: "+297" },
22
+ { code: "AU", name: "Australia", region: "Oceania", dialCode: "+61" },
23
+ { code: "AT", name: "Austria", region: "Europe", dialCode: "+43" },
24
+ { code: "AZ", name: "Azerbaijan", region: "Asia", dialCode: "+994" },
25
+ { code: "BS", name: "Bahamas", region: "North America", dialCode: "+1" },
26
+ { code: "BH", name: "Bahrain", region: "Asia", dialCode: "+973" },
27
+ { code: "BD", name: "Bangladesh", region: "Asia", dialCode: "+880" },
28
+ { code: "BB", name: "Barbados", region: "North America", dialCode: "+1" },
29
+ { code: "BY", name: "Belarus", region: "Europe", dialCode: "+375" },
30
+ { code: "BE", name: "Belgium", region: "Europe", dialCode: "+32" },
31
+ { code: "BZ", name: "Belize", region: "North America", dialCode: "+501" },
32
+ { code: "BJ", name: "Benin", region: "Africa", dialCode: "+229" },
33
+ { code: "BM", name: "Bermuda", region: "North America", dialCode: "+1" },
34
+ { code: "BT", name: "Bhutan", region: "Asia", dialCode: "+975" },
35
+ { code: "BO", name: "Bolivia", region: "South America", dialCode: "+591" },
36
+ { code: "BA", name: "Bosnia and Herzegovina", region: "Europe", dialCode: "+387" },
37
+ { code: "BW", name: "Botswana", region: "Africa", dialCode: "+267" },
38
+ { code: "BR", name: "Brazil", region: "South America", dialCode: "+55" },
39
+ { code: "VG", name: "British Virgin Islands", region: "North America", dialCode: "+1" },
40
+ { code: "BN", name: "Brunei", region: "Asia", dialCode: "+673" },
41
+ { code: "BG", name: "Bulgaria", region: "Europe", dialCode: "+359" },
42
+ { code: "BF", name: "Burkina Faso", region: "Africa", dialCode: "+226" },
43
+ { code: "BI", name: "Burundi", region: "Africa", dialCode: "+257" },
44
+ { code: "KH", name: "Cambodia", region: "Asia", dialCode: "+855" },
45
+ { code: "CM", name: "Cameroon", region: "Africa", dialCode: "+237" },
46
+ { code: "CA", name: "Canada", region: "North America", dialCode: "+1" },
47
+ { code: "CV", name: "Cape Verde", region: "Africa", dialCode: "+238" },
48
+ { code: "KY", name: "Cayman Islands", region: "North America", dialCode: "+1" },
49
+ { code: "CF", name: "Central African Republic", region: "Africa", dialCode: "+236" },
50
+ { code: "TD", name: "Chad", region: "Africa", dialCode: "+235" },
51
+ { code: "CL", name: "Chile", region: "South America", dialCode: "+56" },
52
+ { code: "CN", name: "China", region: "Asia", dialCode: "+86" },
53
+ { code: "HK", name: "Hong Kong, China", region: "Asia", dialCode: "+852" },
54
+ { code: "MO", name: "Macao, China", region: "Asia", dialCode: "+853" },
55
+ { code: "TW", name: "Taiwan, China", region: "Asia", dialCode: "+886" },
56
+ { code: "CO", name: "Colombia", region: "South America", dialCode: "+57" },
57
+ { code: "KM", name: "Comoros", region: "Africa", dialCode: "+269" },
58
+ { code: "CG", name: "Congo", region: "Africa", dialCode: "+242" },
59
+ { code: "CD", name: "Congo (DRC)", region: "Africa", dialCode: "+243" },
60
+ { code: "CR", name: "Costa Rica", region: "North America", dialCode: "+506" },
61
+ { code: "CI", name: "Côte d’Ivoire", region: "Africa", dialCode: "+225" },
62
+ { code: "HR", name: "Croatia", region: "Europe", dialCode: "+385" },
63
+ { code: "CU", name: "Cuba", region: "North America", dialCode: "+53" },
64
+ { code: "CY", name: "Cyprus", region: "Europe", dialCode: "+357" },
65
+ { code: "CZ", name: "Czechia", region: "Europe", dialCode: "+420" },
66
+ { code: "DK", name: "Denmark", region: "Europe", dialCode: "+45" },
67
+ { code: "DJ", name: "Djibouti", region: "Africa", dialCode: "+253" },
68
+ { code: "DM", name: "Dominica", region: "North America", dialCode: "+1" },
69
+ { code: "DO", name: "Dominican Republic", region: "North America", dialCode: "+1" },
70
+ { code: "EC", name: "Ecuador", region: "South America", dialCode: "+593" },
71
+ { code: "EG", name: "Egypt", region: "Africa", dialCode: "+20" },
72
+ { code: "SV", name: "El Salvador", region: "North America", dialCode: "+503" },
73
+ { code: "GQ", name: "Equatorial Guinea", region: "Africa", dialCode: "+240" },
74
+ { code: "ER", name: "Eritrea", region: "Africa", dialCode: "+291" },
75
+ { code: "EE", name: "Estonia", region: "Europe", dialCode: "+372" },
76
+ { code: "SZ", name: "Eswatini", region: "Africa", dialCode: "+268" },
77
+ { code: "ET", name: "Ethiopia", region: "Africa", dialCode: "+251" },
78
+ { code: "FO", name: "Faroe Islands", region: "Europe", dialCode: "+298" },
79
+ { code: "FJ", name: "Fiji", region: "Oceania", dialCode: "+679" },
80
+ { code: "FI", name: "Finland", region: "Europe", dialCode: "+358" },
81
+ { code: "FR", name: "France", region: "Europe", dialCode: "+33" },
82
+ { code: "GF", name: "French Guiana", region: "South America", dialCode: "+594" },
83
+ { code: "PF", name: "French Polynesia", region: "Oceania", dialCode: "+689" },
84
+ { code: "GA", name: "Gabon", region: "Africa", dialCode: "+241" },
85
+ { code: "GM", name: "Gambia", region: "Africa", dialCode: "+220" },
86
+ { code: "GE", name: "Georgia", region: "Asia", dialCode: "+995" },
87
+ { code: "DE", name: "Germany", region: "Europe", dialCode: "+49" },
88
+ { code: "GH", name: "Ghana", region: "Africa", dialCode: "+233" },
89
+ { code: "GI", name: "Gibraltar", region: "Europe", dialCode: "+350" },
90
+ { code: "GR", name: "Greece", region: "Europe", dialCode: "+30" },
91
+ { code: "GL", name: "Greenland", region: "North America", dialCode: "+299" },
92
+ { code: "GD", name: "Grenada", region: "North America", dialCode: "+1" },
93
+ { code: "GP", name: "Guadeloupe", region: "North America", dialCode: "+590" },
94
+ { code: "GU", name: "Guam", region: "Oceania", dialCode: "+1" },
95
+ { code: "GT", name: "Guatemala", region: "North America", dialCode: "+502" },
96
+ { code: "GG", name: "Guernsey", region: "Europe", dialCode: "+44" },
97
+ { code: "GN", name: "Guinea", region: "Africa", dialCode: "+224" },
98
+ { code: "GW", name: "Guinea-Bissau", region: "Africa", dialCode: "+245" },
99
+ { code: "GY", name: "Guyana", region: "South America", dialCode: "+592" },
100
+ { code: "HT", name: "Haiti", region: "North America", dialCode: "+509" },
101
+ { code: "HN", name: "Honduras", region: "North America", dialCode: "+504" },
102
+ { code: "HU", name: "Hungary", region: "Europe", dialCode: "+36" },
103
+ { code: "IS", name: "Iceland", region: "Europe", dialCode: "+354" },
104
+ { code: "IN", name: "India", region: "Asia", dialCode: "+91" },
105
+ { code: "ID", name: "Indonesia", region: "Asia", dialCode: "+62" },
106
+ { code: "IR", name: "Iran", region: "Asia", dialCode: "+98" },
107
+ { code: "IQ", name: "Iraq", region: "Asia", dialCode: "+964" },
108
+ { code: "IE", name: "Ireland", region: "Europe", dialCode: "+353" },
109
+ { code: "IM", name: "Isle of Man", region: "Europe", dialCode: "+44" },
110
+ { code: "IL", name: "Israel", region: "Asia", dialCode: "+972" },
111
+ { code: "IT", name: "Italy", region: "Europe", dialCode: "+39" },
112
+ { code: "JM", name: "Jamaica", region: "North America", dialCode: "+1" },
113
+ { code: "JP", name: "Japan", region: "Asia", dialCode: "+81" },
114
+ { code: "JE", name: "Jersey", region: "Europe", dialCode: "+44" },
115
+ { code: "JO", name: "Jordan", region: "Asia", dialCode: "+962" },
116
+ { code: "KZ", name: "Kazakhstan", region: "Asia", dialCode: "+7" },
117
+ { code: "KE", name: "Kenya", region: "Africa", dialCode: "+254" },
118
+ { code: "KI", name: "Kiribati", region: "Oceania", dialCode: "+686" },
119
+ { code: "XK", name: "Kosovo", region: "Europe", dialCode: "+383" },
120
+ { code: "KW", name: "Kuwait", region: "Asia", dialCode: "+965" },
121
+ { code: "KG", name: "Kyrgyzstan", region: "Asia", dialCode: "+996" },
122
+ { code: "LA", name: "Laos", region: "Asia", dialCode: "+856" },
123
+ { code: "LV", name: "Latvia", region: "Europe", dialCode: "+371" },
124
+ { code: "LB", name: "Lebanon", region: "Asia", dialCode: "+961" },
125
+ { code: "LS", name: "Lesotho", region: "Africa", dialCode: "+266" },
126
+ { code: "LR", name: "Liberia", region: "Africa", dialCode: "+231" },
127
+ { code: "LY", name: "Libya", region: "Africa", dialCode: "+218" },
128
+ { code: "LI", name: "Liechtenstein", region: "Europe", dialCode: "+423" },
129
+ { code: "LT", name: "Lithuania", region: "Europe", dialCode: "+370" },
130
+ { code: "LU", name: "Luxembourg", region: "Europe", dialCode: "+352" },
131
+ { code: "MG", name: "Madagascar", region: "Africa", dialCode: "+261" },
132
+ { code: "MW", name: "Malawi", region: "Africa", dialCode: "+265" },
133
+ { code: "MY", name: "Malaysia", region: "Asia", dialCode: "+60" },
134
+ { code: "MV", name: "Maldives", region: "Asia", dialCode: "+960" },
135
+ { code: "ML", name: "Mali", region: "Africa", dialCode: "+223" },
136
+ { code: "MT", name: "Malta", region: "Europe", dialCode: "+356" },
137
+ { code: "MH", name: "Marshall Islands", region: "Oceania", dialCode: "+692" },
138
+ { code: "MQ", name: "Martinique", region: "North America", dialCode: "+596" },
139
+ { code: "MR", name: "Mauritania", region: "Africa", dialCode: "+222" },
140
+ { code: "MU", name: "Mauritius", region: "Africa", dialCode: "+230" },
141
+ { code: "YT", name: "Mayotte", region: "Africa", dialCode: "+262" },
142
+ { code: "MX", name: "Mexico", region: "North America", dialCode: "+52" },
143
+ { code: "FM", name: "Micronesia", region: "Oceania", dialCode: "+691" },
144
+ { code: "MD", name: "Moldova", region: "Europe", dialCode: "+373" },
145
+ { code: "MC", name: "Monaco", region: "Europe", dialCode: "+377" },
146
+ { code: "MN", name: "Mongolia", region: "Asia", dialCode: "+976" },
147
+ { code: "ME", name: "Montenegro", region: "Europe", dialCode: "+382" },
148
+ { code: "MS", name: "Montserrat", region: "North America", dialCode: "+1" },
149
+ { code: "MA", name: "Morocco", region: "Africa", dialCode: "+212" },
150
+ { code: "MZ", name: "Mozambique", region: "Africa", dialCode: "+258" },
151
+ { code: "MM", name: "Myanmar", region: "Asia", dialCode: "+95" },
152
+ { code: "NA", name: "Namibia", region: "Africa", dialCode: "+264" },
153
+ { code: "NR", name: "Nauru", region: "Oceania", dialCode: "+674" },
154
+ { code: "NP", name: "Nepal", region: "Asia", dialCode: "+977" },
155
+ { code: "NL", name: "Netherlands", region: "Europe", dialCode: "+31" },
156
+ { code: "NC", name: "New Caledonia", region: "Oceania", dialCode: "+687" },
157
+ { code: "NZ", name: "New Zealand", region: "Oceania", dialCode: "+64" },
158
+ { code: "NI", name: "Nicaragua", region: "North America", dialCode: "+505" },
159
+ { code: "NE", name: "Niger", region: "Africa", dialCode: "+227" },
160
+ { code: "NG", name: "Nigeria", region: "Africa", dialCode: "+234" },
161
+ { code: "NU", name: "Niue", region: "Oceania", dialCode: "+683" },
162
+ { code: "NF", name: "Norfolk Island", region: "Oceania", dialCode: "+672" },
163
+ { code: "KP", name: "North Korea", region: "Asia", dialCode: "+850" },
164
+ { code: "MK", name: "North Macedonia", region: "Europe", dialCode: "+389" },
165
+ { code: "MP", name: "Northern Mariana Islands", region: "Oceania", dialCode: "+1" },
166
+ { code: "NO", name: "Norway", region: "Europe", dialCode: "+47" },
167
+ { code: "OM", name: "Oman", region: "Asia", dialCode: "+968" },
168
+ { code: "PK", name: "Pakistan", region: "Asia", dialCode: "+92" },
169
+ { code: "PW", name: "Palau", region: "Oceania", dialCode: "+680" },
170
+ { code: "PS", name: "Palestine", region: "Asia", dialCode: "+970" },
171
+ { code: "PA", name: "Panama", region: "North America", dialCode: "+507" },
172
+ { code: "PG", name: "Papua New Guinea", region: "Oceania", dialCode: "+675" },
173
+ { code: "PY", name: "Paraguay", region: "South America", dialCode: "+595" },
174
+ { code: "PE", name: "Peru", region: "South America", dialCode: "+51" },
175
+ { code: "PH", name: "Philippines", region: "Asia", dialCode: "+63" },
176
+ { code: "PL", name: "Poland", region: "Europe", dialCode: "+48" },
177
+ { code: "PT", name: "Portugal", region: "Europe", dialCode: "+351" },
178
+ { code: "PR", name: "Puerto Rico", region: "North America", dialCode: "+1" },
179
+ { code: "QA", name: "Qatar", region: "Asia", dialCode: "+974" },
180
+ { code: "RE", name: "Réunion", region: "Africa", dialCode: "+262" },
181
+ { code: "RO", name: "Romania", region: "Europe", dialCode: "+40" },
182
+ { code: "RU", name: "Russia", region: "Europe", dialCode: "+7" },
183
+ { code: "RW", name: "Rwanda", region: "Africa", dialCode: "+250" },
184
+ { code: "BL", name: "Saint Barthélemy", region: "North America", dialCode: "+590" },
185
+ { code: "KN", name: "Saint Kitts and Nevis", region: "North America", dialCode: "+1" },
186
+ { code: "LC", name: "Saint Lucia", region: "North America", dialCode: "+1" },
187
+ { code: "MF", name: "Saint Martin", region: "North America", dialCode: "+590" },
188
+ { code: "PM", name: "Saint Pierre and Miquelon", region: "North America", dialCode: "+508" },
189
+ { code: "VC", name: "Saint Vincent and the Grenadines", region: "North America", dialCode: "+1" },
190
+ { code: "WS", name: "Samoa", region: "Oceania", dialCode: "+685" },
191
+ { code: "SM", name: "San Marino", region: "Europe", dialCode: "+378" },
192
+ { code: "ST", name: "São Tomé and Príncipe", region: "Africa", dialCode: "+239" },
193
+ { code: "SA", name: "Saudi Arabia", region: "Asia", dialCode: "+966" },
194
+ { code: "SN", name: "Senegal", region: "Africa", dialCode: "+221" },
195
+ { code: "RS", name: "Serbia", region: "Europe", dialCode: "+381" },
196
+ { code: "SC", name: "Seychelles", region: "Africa", dialCode: "+248" },
197
+ { code: "SL", name: "Sierra Leone", region: "Africa", dialCode: "+232" },
198
+ { code: "SG", name: "Singapore", region: "Asia", dialCode: "+65" },
199
+ { code: "SX", name: "Sint Maarten", region: "North America", dialCode: "+1" },
200
+ { code: "SK", name: "Slovakia", region: "Europe", dialCode: "+421" },
201
+ { code: "SI", name: "Slovenia", region: "Europe", dialCode: "+386" },
202
+ { code: "SB", name: "Solomon Islands", region: "Oceania", dialCode: "+677" },
203
+ { code: "SO", name: "Somalia", region: "Africa", dialCode: "+252" },
204
+ { code: "ZA", name: "South Africa", region: "Africa", dialCode: "+27" },
205
+ { code: "KR", name: "South Korea", region: "Asia", dialCode: "+82" },
206
+ { code: "SS", name: "South Sudan", region: "Africa", dialCode: "+211" },
207
+ { code: "ES", name: "Spain", region: "Europe", dialCode: "+34" },
208
+ { code: "LK", name: "Sri Lanka", region: "Asia", dialCode: "+94" },
209
+ { code: "SD", name: "Sudan", region: "Africa", dialCode: "+249" },
210
+ { code: "SR", name: "Suriname", region: "South America", dialCode: "+597" },
211
+ { code: "SE", name: "Sweden", region: "Europe", dialCode: "+46" },
212
+ { code: "CH", name: "Switzerland", region: "Europe", dialCode: "+41" },
213
+ { code: "SY", name: "Syria", region: "Asia", dialCode: "+963" },
214
+ { code: "TJ", name: "Tajikistan", region: "Asia", dialCode: "+992" },
215
+ { code: "TZ", name: "Tanzania", region: "Africa", dialCode: "+255" },
216
+ { code: "TH", name: "Thailand", region: "Asia", dialCode: "+66" },
217
+ { code: "TG", name: "Togo", region: "Africa", dialCode: "+228" },
218
+ { code: "TK", name: "Tokelau", region: "Oceania", dialCode: "+690" },
219
+ { code: "TO", name: "Tonga", region: "Oceania", dialCode: "+676" },
220
+ { code: "TT", name: "Trinidad and Tobago", region: "North America", dialCode: "+1" },
221
+ { code: "TN", name: "Tunisia", region: "Africa", dialCode: "+216" },
222
+ { code: "TR", name: "Türkiye", region: "Europe", dialCode: "+90" },
223
+ { code: "TM", name: "Turkmenistan", region: "Asia", dialCode: "+993" },
224
+ { code: "TC", name: "Turks and Caicos Islands", region: "North America", dialCode: "+1" },
225
+ { code: "TV", name: "Tuvalu", region: "Oceania", dialCode: "+688" },
226
+ { code: "UG", name: "Uganda", region: "Africa", dialCode: "+256" },
227
+ { code: "UA", name: "Ukraine", region: "Europe", dialCode: "+380" },
228
+ { code: "AE", name: "United Arab Emirates", region: "Asia", dialCode: "+971" },
229
+ { code: "GB", name: "United Kingdom", region: "Europe", dialCode: "+44" },
230
+ { code: "US", name: "United States", region: "North America", dialCode: "+1" },
231
+ { code: "UY", name: "Uruguay", region: "South America", dialCode: "+598" },
232
+ { code: "UZ", name: "Uzbekistan", region: "Asia", dialCode: "+998" },
233
+ { code: "VU", name: "Vanuatu", region: "Oceania", dialCode: "+678" },
234
+ { code: "VA", name: "Vatican City", region: "Europe", dialCode: "+39" },
235
+ { code: "VE", name: "Venezuela", region: "South America", dialCode: "+58" },
236
+ { code: "VN", name: "Vietnam", region: "Asia", dialCode: "+84" },
237
+ { code: "VI", name: "U.S. Virgin Islands", region: "North America", dialCode: "+1" },
238
+ { code: "WF", name: "Wallis and Futuna", region: "Oceania", dialCode: "+681" },
239
+ { code: "EH", name: "Western Sahara", region: "Africa", dialCode: "+212" },
240
+ { code: "YE", name: "Yemen", region: "Asia", dialCode: "+967" },
241
+ { code: "ZM", name: "Zambia", region: "Africa", dialCode: "+260" },
242
+ { code: "ZW", name: "Zimbabwe", region: "Africa", dialCode: "+263" },
243
+ ];
@@ -1,49 +1,60 @@
1
- import { FileUpload, FileUploadProps } from "./FileUpload";
2
- import { Input } from "./Input";
3
- import { Input2 } from "./Input2";
4
- import { Textarea } from "./Textarea";
5
- import { Textarea2 } from "./Textarea2";
6
- import { FieldStyle } from "./types";
7
-
8
- export const getControl = (controlName?: string, fieldStyle?: FieldStyle) => {
9
- switch (controlName) {
10
- case "Input":
11
- return getInput(fieldStyle);
12
- case "Textarea":
13
- return getTextarea(fieldStyle);
14
- default:
15
- return getInput(fieldStyle);
16
- }
17
- };
18
-
19
- export const getInput = (fieldStyle?: FieldStyle) => {
20
- if (fieldStyle === "default") {
21
- return Input;
22
- } else if (fieldStyle === "label-inline") {
23
- return Input2;
24
- } else {
25
- return Input;
26
- }
27
- };
28
-
29
- export const getTextarea = (fieldStyle?: FieldStyle) => {
30
- if (fieldStyle === "default") {
31
- return Textarea;
32
- } else if (fieldStyle === "label-inline") {
33
- return Textarea2;
34
- } else {
35
- return Textarea;
36
- }
37
- };
38
-
39
- export const getFileUpload = (
40
- fieldStyle?: FieldStyle
41
- ): React.FC<FileUploadProps> => {
42
- if (fieldStyle === "default") {
43
- return FileUpload;
44
- } else if (fieldStyle === "label-inline") {
45
- return FileUpload;
46
- } else {
47
- return FileUpload;
48
- }
49
- };
1
+ import { FileUpload2, FileUploadProps } from "./FileUpload2";
2
+ import { Input } from "./Input";
3
+ import { Input2 } from "./Input2";
4
+ import { Textarea } from "./Textarea";
5
+ import { Textarea2 } from "./Textarea2";
6
+ import TelInput from "./TelInput";
7
+ import TelInput2 from "./TelInput2";
8
+ import { FieldStyle } from "./types";
9
+
10
+ export const getControl = (controlName?: string, fieldStyle?: FieldStyle) => {
11
+ switch (controlName) {
12
+ case "Input":
13
+ return getInput(fieldStyle);
14
+ case "Textarea":
15
+ return getTextarea(fieldStyle);
16
+ case "TelInput":
17
+ return getTelInput(fieldStyle);
18
+ default:
19
+ return getInput(fieldStyle);
20
+ }
21
+ };
22
+
23
+ export const getInput = (fieldStyle?: FieldStyle) => {
24
+ if (fieldStyle === "default") {
25
+ return Input;
26
+ } else if (fieldStyle === "label-inline") {
27
+ return Input2;
28
+ } else {
29
+ return Input;
30
+ }
31
+ };
32
+
33
+ export const getTextarea = (fieldStyle?: FieldStyle) => {
34
+ if (fieldStyle === "default") {
35
+ return Textarea;
36
+ } else if (fieldStyle === "label-inline") {
37
+ return Textarea2;
38
+ } else {
39
+ return Textarea;
40
+ }
41
+ };
42
+
43
+ export const getTelInput = (fieldStyle?: FieldStyle) => {
44
+ if (fieldStyle === "label-inline") {
45
+ return TelInput2;
46
+ }
47
+ return TelInput;
48
+ };
49
+
50
+ export const getFileUpload = (
51
+ fieldStyle?: FieldStyle
52
+ ): React.FC<FileUploadProps> => {
53
+ if (fieldStyle === "default") {
54
+ return FileUpload2;
55
+ } else if (fieldStyle === "label-inline") {
56
+ return FileUpload2;
57
+ } else {
58
+ return FileUpload2;
59
+ }
60
+ };
@@ -0,0 +1,20 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+
3
+ /**
4
+ * 计算内联标签布局所需的 paddingLeft(= label 宽度 + 额外间距)
5
+ * - 返回 labelRef 供 <label ref={labelRef} /> 绑定
6
+ * - 返回 paddingLeft 用于内层输入/容器 style
7
+ */
8
+ export function useInlineLabelPadding(extraSpace: number = 16) {
9
+ const labelRef = useRef<HTMLLabelElement>(null);
10
+ const [paddingLeft, setPaddingLeft] = useState<string>("3.5rem");
11
+
12
+ useEffect(() => {
13
+ if (labelRef.current) {
14
+ const width = labelRef.current.getBoundingClientRect().width;
15
+ setPaddingLeft(`${width + extraSpace}px`);
16
+ }
17
+ }, [extraSpace]);
18
+
19
+ return { labelRef, paddingLeft } as const;
20
+ }
@@ -0,0 +1,81 @@
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import type { CountryDial } from "../countryDialCodes";
3
+ import { countries as defaultCountries } from "../countryDialCodes";
4
+
5
+ export interface UseTelControlOptions {
6
+ countries?: CountryDial[];
7
+ name: string;
8
+ value?: string | number | readonly string[] | undefined;
9
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
10
+ }
11
+
12
+ export function useTelControl({ countries, name, value, onChange }: UseTelControlOptions) {
13
+ const allCountries = useMemo<CountryDial[]>(() => countries || defaultCountries, [countries]);
14
+
15
+ const [selected, setSelected] = useState<CountryDial | null>(null);
16
+ const [localNumber, setLocalNumber] = useState<string>("");
17
+
18
+ const toStringValue = (val?: string | number | readonly string[]) => {
19
+ if (typeof val === "string") return val;
20
+ if (typeof val === "number") return String(val);
21
+ if (Array.isArray(val)) return val[0] ?? "";
22
+ return "";
23
+ };
24
+
25
+ useEffect(() => {
26
+ const s = toStringValue(value).trim();
27
+ const m = s.match(/^\+\d{1,4}/);
28
+ const dial = m ? m[0] : "";
29
+ const number = s.slice(dial.length).trimStart();
30
+ setLocalNumber(number || "");
31
+ if (dial) {
32
+ const found = allCountries.find((c) => c.dialCode === dial) || null;
33
+ setSelected(found);
34
+ } else {
35
+ setSelected(null);
36
+ }
37
+ }, [value, allCountries]);
38
+
39
+ const emitChange = (combined: string) => {
40
+ if (!onChange) return;
41
+ const evt = {
42
+ target: { value: combined, name } as unknown,
43
+ currentTarget: { value: combined, name } as unknown,
44
+ } as unknown as React.ChangeEvent<HTMLInputElement>;
45
+ onChange(evt);
46
+ };
47
+
48
+ const filtered = (query: string) => {
49
+ if (!query) return allCountries;
50
+ const q = query.toLowerCase();
51
+ return allCountries.filter(
52
+ (c) =>
53
+ c.name.toLowerCase().includes(q) ||
54
+ (c.region && c.region.toLowerCase().includes(q)) ||
55
+ c.dialCode.replace("+", "").includes(q.replace("+", ""))
56
+ );
57
+ };
58
+
59
+ const onSelectCountry = (c: CountryDial) => {
60
+ setSelected(c);
61
+ const combined = `${c.dialCode} ${localNumber}`.trim();
62
+ emitChange(combined);
63
+ };
64
+
65
+ const onChangeLocal = (next: string) => {
66
+ setLocalNumber(next);
67
+ const combined = `${selected?.dialCode || ""} ${next}`.trim();
68
+ emitChange(combined);
69
+ };
70
+
71
+ return {
72
+ allCountries,
73
+ selected,
74
+ setSelected,
75
+ localNumber,
76
+ setLocalNumber,
77
+ filtered,
78
+ onSelectCountry,
79
+ onChangeLocal,
80
+ } as const;
81
+ }
@@ -1,5 +1,5 @@
1
1
  export * from "./ContactForm";
2
- export * from "./FileUpload";
2
+ export * from "./FileUpload2";
3
3
  export * from "./Input";
4
4
  export * from "./Submit";
5
5
  export * from "./Textarea";
@@ -0,0 +1,44 @@
1
+ import { useRef } from "react";
2
+ import {
3
+ DATA_POPUP_CTA,
4
+ DATA_OPENABLE_ROLE,
5
+ OpenAble,
6
+ DATA_OPENABLE,
7
+ popover,
8
+ } from "../../controller";
9
+
10
+ export function ReactModalTrigger(props: {
11
+ className?: string;
12
+ openableKey?: string;
13
+ callToAction?: string;
14
+ children?: React.ReactNode;
15
+ }) {
16
+ const {
17
+ className,
18
+ callToAction,
19
+ openableKey = "enquiry-modal",
20
+ children,
21
+ } = props;
22
+ const ref = useRef<HTMLButtonElement>(null);
23
+ const roleProps = {
24
+ [DATA_POPUP_CTA]: callToAction,
25
+ [DATA_OPENABLE_ROLE]: OpenAble.ModalTrigger,
26
+ [DATA_OPENABLE]: openableKey,
27
+ };
28
+
29
+ const handleClick = () => {
30
+ if (ref.current) {
31
+ popover.open(openableKey, ref.current);
32
+ }
33
+ };
34
+ return (
35
+ <button
36
+ ref={ref}
37
+ {...roleProps}
38
+ className={className}
39
+ onClick={handleClick}
40
+ >
41
+ {children || "Get a quote"}
42
+ </button>
43
+ );
44
+ }