@smallpearl/ngx-helper 0.29.23

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 (117) hide show
  1. package/README.md +230 -0
  2. package/core/index.d.ts +2 -0
  3. package/core/src/ngx-helper.d.ts +7 -0
  4. package/core/src/version.d.ts +1 -0
  5. package/entity-field/index.d.ts +2 -0
  6. package/entity-field/src/entity-field-spec.d.ts +69 -0
  7. package/entity-field/src/provider.d.ts +27 -0
  8. package/fesm2022/smallpearl-ngx-helper-core.mjs +23 -0
  9. package/fesm2022/smallpearl-ngx-helper-core.mjs.map +1 -0
  10. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs +112 -0
  11. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs.map +1 -0
  12. package/fesm2022/smallpearl-ngx-helper-forms.mjs +112 -0
  13. package/fesm2022/smallpearl-ngx-helper-forms.mjs.map +1 -0
  14. package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs +108 -0
  15. package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs.map +1 -0
  16. package/fesm2022/smallpearl-ngx-helper-locale.mjs +296 -0
  17. package/fesm2022/smallpearl-ngx-helper-locale.mjs.map +1 -0
  18. package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs +504 -0
  19. package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs.map +1 -0
  20. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs +184 -0
  21. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs.map +1 -0
  22. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs +1486 -0
  23. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs.map +1 -0
  24. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs +800 -0
  25. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs.map +1 -0
  26. package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs +328 -0
  27. package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs.map +1 -0
  28. package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs +468 -0
  29. package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs.map +1 -0
  30. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs +854 -0
  31. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs.map +1 -0
  32. package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs +930 -0
  33. package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs.map +1 -0
  34. package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs +926 -0
  35. package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs.map +1 -0
  36. package/fesm2022/smallpearl-ngx-helper-sideload.mjs +111 -0
  37. package/fesm2022/smallpearl-ngx-helper-sideload.mjs.map +1 -0
  38. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs +384 -0
  39. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs.map +1 -0
  40. package/fesm2022/smallpearl-ngx-helper.mjs +13 -0
  41. package/fesm2022/smallpearl-ngx-helper.mjs.map +1 -0
  42. package/forms/index.d.ts +1 -0
  43. package/forms/src/validation-error-handler.d.ts +52 -0
  44. package/hover-dropdown/index.d.ts +1 -0
  45. package/hover-dropdown/src/hover-dropdown.directive.d.ts +41 -0
  46. package/index.d.ts +5 -0
  47. package/locale/index.d.ts +5 -0
  48. package/locale/src/currency.pipe.d.ts +14 -0
  49. package/locale/src/date.pipe.d.ts +14 -0
  50. package/locale/src/format-currency.d.ts +1 -0
  51. package/locale/src/format-date.d.ts +2 -0
  52. package/locale/src/is-empty.d.ts +1 -0
  53. package/locale/src/providers.d.ts +20 -0
  54. package/mat-busy-wheel/index.d.ts +4 -0
  55. package/mat-busy-wheel/src/busy-wheel-op.d.ts +65 -0
  56. package/mat-busy-wheel/src/busy-wheel.component.d.ts +12 -0
  57. package/mat-busy-wheel/src/busy-wheel.service.d.ts +42 -0
  58. package/mat-busy-wheel/src/host-busy-wheel.directive.d.ts +35 -0
  59. package/mat-context-menu/index.d.ts +1 -0
  60. package/mat-context-menu/src/mat-context-menu.component.d.ts +54 -0
  61. package/mat-entity-crud/index.d.ts +5 -0
  62. package/mat-entity-crud/src/default-config.d.ts +9 -0
  63. package/mat-entity-crud/src/form-view-host.component.d.ts +34 -0
  64. package/mat-entity-crud/src/mat-entity-crud-form-base.d.ts +95 -0
  65. package/mat-entity-crud/src/mat-entity-crud-internal-types.d.ts +66 -0
  66. package/mat-entity-crud/src/mat-entity-crud-types.d.ts +141 -0
  67. package/mat-entity-crud/src/mat-entity-crud.component.d.ts +267 -0
  68. package/mat-entity-crud/src/preview-host.component.d.ts +19 -0
  69. package/mat-entity-crud/src/preview-pane.component.d.ts +27 -0
  70. package/mat-entity-crud/src/providers.d.ts +3 -0
  71. package/mat-entity-list/index.d.ts +3 -0
  72. package/mat-entity-list/src/config.d.ts +6 -0
  73. package/mat-entity-list/src/mat-entity-list-types.d.ts +53 -0
  74. package/mat-entity-list/src/mat-entity-list.component.d.ts +209 -0
  75. package/mat-entity-list/src/providers.d.ts +3 -0
  76. package/mat-file-input/README.md +63 -0
  77. package/mat-file-input/index.d.ts +1 -0
  78. package/mat-file-input/src/mat-file-input.component.d.ts +58 -0
  79. package/mat-form-error/README.md +306 -0
  80. package/mat-form-error/index.d.ts +6 -0
  81. package/mat-form-error/src/locales/en.d.ts +4 -0
  82. package/mat-form-error/src/locales/hu.d.ts +4 -0
  83. package/mat-form-error/src/locales/index.d.ts +3 -0
  84. package/mat-form-error/src/locales/pt-br.d.ts +4 -0
  85. package/mat-form-error/src/ngx-error-list.component.d.ts +9 -0
  86. package/mat-form-error/src/ngx-mat-error-control.d.ts +17 -0
  87. package/mat-form-error/src/ngx-mat-error-def.directive.d.ts +30 -0
  88. package/mat-form-error/src/ngx-mat-errors-for-date-range-picker.directive.d.ts +8 -0
  89. package/mat-form-error/src/ngx-mat-errors.component.d.ts +23 -0
  90. package/mat-form-error/src/types.d.ts +68 -0
  91. package/mat-form-error/src/utils/coerce-to-observable.d.ts +3 -0
  92. package/mat-form-error/src/utils/distinct-until-error-changed.d.ts +2 -0
  93. package/mat-form-error/src/utils/find-error-for-control.d.ts +9 -0
  94. package/mat-form-error/src/utils/get-abstract-controls.d.ts +3 -0
  95. package/mat-form-error/src/utils/get-control-with-error.d.ts +3 -0
  96. package/mat-select-entity/index.d.ts +2 -0
  97. package/mat-select-entity/src/mat-select-entity.component.d.ts +207 -0
  98. package/mat-select-entity/src/providers.d.ts +9 -0
  99. package/mat-side-menu-layout/index.d.ts +6 -0
  100. package/mat-side-menu-layout/src/layout.service.d.ts +23 -0
  101. package/mat-side-menu-layout/src/mat-menu-layout.component.d.ts +39 -0
  102. package/mat-side-menu-layout/src/mat-menu-layout.module.d.ts +18 -0
  103. package/mat-side-menu-layout/src/mat-menu-list-item.component.d.ts +36 -0
  104. package/mat-side-menu-layout/src/mat-menu-pane.component.d.ts +66 -0
  105. package/mat-side-menu-layout/src/nav-item.d.ts +10 -0
  106. package/mat-tel-input/README.md +18 -0
  107. package/mat-tel-input/index.d.ts +2 -0
  108. package/mat-tel-input/src/country-codes.d.ts +5 -0
  109. package/mat-tel-input/src/mat-telephone.component.d.ts +129 -0
  110. package/mat-tel-input/src/providers.d.ts +38 -0
  111. package/ngx-helper.d.ts +2 -0
  112. package/package.json +114 -0
  113. package/public-api.d.ts +1 -0
  114. package/sideload/index.d.ts +1 -0
  115. package/sideload/src/sideload.d.ts +17 -0
  116. package/stationary-with-line-items/index.d.ts +1 -0
  117. package/stationary-with-line-items/src/stationary-with-line-items.component.d.ts +74 -0
@@ -0,0 +1,926 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Component, ChangeDetectionStrategy, Optional, Inject, Self, ViewChild, Input } from '@angular/core';
3
+ import * as i2 from '@angular/cdk/a11y';
4
+ import { coerceBooleanProperty } from '@angular/cdk/coercion';
5
+ import * as i4 from '@angular/common';
6
+ import { CommonModule } from '@angular/common';
7
+ import * as i1 from '@angular/common/http';
8
+ import * as i3 from '@angular/forms';
9
+ import { FormGroup, FormControl, Validators, NgControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
10
+ import * as i8 from '@angular/material/form-field';
11
+ import { MAT_FORM_FIELD, MatFormFieldControl } from '@angular/material/form-field';
12
+ import { PhoneNumberUtil, PhoneNumberType } from 'google-libphonenumber';
13
+ import { BehaviorSubject, ReplaySubject, Subject, NEVER } from 'rxjs';
14
+ import { map, takeUntil, take, tap, catchError } from 'rxjs/operators';
15
+ import * as i7 from 'ngx-mat-select-search';
16
+ import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
17
+ import * as i5 from '@angular/material/select';
18
+ import { MatSelectModule } from '@angular/material/select';
19
+ import * as i6 from '@angular/material/core';
20
+
21
+ const QQMAT_TELEPHONE_INPUT_CONFIG_PROVIDER = new InjectionToken('QQMatTelephoneInputConfigProvider');
22
+
23
+ // Array of country objects for the flag dropdown.
24
+ // Here is the criteria for the plugin to support a given country/territory
25
+ // - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
26
+ // - It has it's own country calling code (it is not a sub-region of another country): https://en.wikipedia.org/wiki/List_of_country_calling_codes
27
+ // - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png
28
+ // - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml
29
+ // Each country array has the following information:
30
+ // [
31
+ // Country name,
32
+ // iso2 code,
33
+ // International dial code,
34
+ // ]
35
+ const COUNTRY_CODES = [
36
+ { name: "Afghanistan (‫افغانستان‬‎)", code: "AF", callingCode: 93 },
37
+ { name: "Albania (Shqipëri)", code: "AL", callingCode: 355 },
38
+ { name: "Algeria (‫الجزائر‬‎)", code: "DZ", callingCode: 213 },
39
+ { name: "American Samoa", code: "AS", callingCode: 1 },
40
+ { name: "Andorra", code: "AD", callingCode: 376 },
41
+ { name: "Angola", code: "AO", callingCode: 244 },
42
+ { name: "Anguilla", code: "AI", callingCode: 1 },
43
+ { name: "Antigua and Barbuda", code: "AG", callingCode: 1 },
44
+ { name: "Argentina", code: "AR", callingCode: 54 },
45
+ { name: "Armenia (Հայաստան)", code: "AM", callingCode: 374 },
46
+ { name: "Aruba", code: "AW", callingCode: 297 },
47
+ { name: "Ascension Island", code: "AC", callingCode: 247 },
48
+ { name: "Australia", code: "AU", callingCode: 61 },
49
+ { name: "Austria (Österreich)", code: "AT", callingCode: 43 },
50
+ { name: "Azerbaijan (Azərbaycan)", code: "AZ", callingCode: 994 },
51
+ { name: "Bahamas", code: "BS", callingCode: 1 },
52
+ { name: "Bahrain (‫البحرين‬‎)", code: "BH", callingCode: 973 },
53
+ { name: "Bangladesh (বাংলাদেশ)", code: "BD", callingCode: 880 },
54
+ { name: "Barbados", code: "BB", callingCode: 1 },
55
+ { name: "Belarus (Беларусь)", code: "BY", callingCode: 375 },
56
+ { name: "Belgium (België)", code: "BE", callingCode: 32 },
57
+ { name: "Belize", code: "BZ", callingCode: 501 },
58
+ { name: "Benin (Bénin)", code: "BJ", callingCode: 229 },
59
+ { name: "Bermuda", code: "BM", callingCode: 1 },
60
+ { name: "Bhutan (འབྲུག)", code: "BT", callingCode: 975 },
61
+ { name: "Bolivia", code: "BO", callingCode: 591 },
62
+ { name: "Bosnia and Herzegovina (Босна и Херцеговина)", code: "BA", callingCode: 387 },
63
+ { name: "Botswana", code: "BW", callingCode: 267 },
64
+ { name: "Brazil (Brasil)", code: "BR", callingCode: 55 },
65
+ { name: "British Indian Ocean Territory", code: "IO", callingCode: 246 },
66
+ { name: "British Virgin Islands", code: "VG", callingCode: 1 },
67
+ { name: "Brunei", code: "BN", callingCode: 673 },
68
+ { name: "Bulgaria (България)", code: "BG", callingCode: 359 },
69
+ { name: "Burkina Faso", code: "BF", callingCode: 226 },
70
+ { name: "Burundi (Uburundi)", code: "BI", callingCode: 257 },
71
+ { name: "Cambodia (កម្ពុជា)", code: "KH", callingCode: 855 },
72
+ { name: "Cameroon (Cameroun)", code: "CM", callingCode: 237 },
73
+ { name: "Canada", code: "CA", callingCode: 1 },
74
+ { name: "Cape Verde (Kabu Verdi)", code: "CV", callingCode: 238 },
75
+ { name: "Caribbean Netherlands", code: "BQ", callingCode: 599 },
76
+ { name: "Cayman Islands", code: "KY", callingCode: 1 },
77
+ { name: "Central African Republic (République centrafricaine)", code: "CF", callingCode: 236 },
78
+ { name: "Chad (Tchad)", code: "TD", callingCode: 235 },
79
+ { name: "Chile", code: "CL", callingCode: 56 },
80
+ { name: "China (中国)", code: "CN", callingCode: 86 },
81
+ { name: "Christmas Island", code: "CX", callingCode: 61 },
82
+ { name: "Cocos (Keeling) Islands", code: "CC", callingCode: 61 },
83
+ { name: "Colombia", code: "CO", callingCode: 57 },
84
+ { name: "Comoros (‫جزر القمر‬‎)", code: "KM", callingCode: 269 },
85
+ { name: "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", code: "CD", callingCode: 243 },
86
+ { name: "Congo (Republic) (Congo-Brazzaville)", code: "CG", callingCode: 242 },
87
+ { name: "Cook Islands", code: "CK", callingCode: 682 },
88
+ { name: "Costa Rica", code: "CR", callingCode: 506 },
89
+ { name: "Côte d’Ivoire", code: "CI", callingCode: 225 },
90
+ { name: "Croatia (Hrvatska)", code: "HR", callingCode: 385 },
91
+ { name: "Cuba", code: "CU", callingCode: 53 },
92
+ { name: "Curaçao", code: "CW", callingCode: 599 },
93
+ { name: "Cyprus (Κύπρος)", code: "CY", callingCode: 357 },
94
+ { name: "Czech Republic (Česká republika)", code: "CZ", callingCode: 420 },
95
+ { name: "Denmark (Danmark)", code: "DK", callingCode: 45 },
96
+ { name: "Djibouti", code: "DJ", callingCode: 253 },
97
+ { name: "Dominica", code: "DM", callingCode: 1 },
98
+ { name: "Dominican Republic (República Dominicana)", code: "DO", callingCode: 1 },
99
+ { name: "Ecuador", code: "EC", callingCode: 593 },
100
+ { name: "Egypt (‫مصر‬‎)", code: "EG", callingCode: 20 },
101
+ { name: "El Salvador", code: "SV", callingCode: 503 },
102
+ { name: "Equatorial Guinea (Guinea Ecuatorial)", code: "GQ", callingCode: 240 },
103
+ { name: "Eritrea", code: "ER", callingCode: 291 },
104
+ { name: "Estonia (Eesti)", code: "EE", callingCode: 372 },
105
+ { name: "Eswatini", code: "SZ", callingCode: 268 },
106
+ { name: "Ethiopia", code: "ET", callingCode: 251 },
107
+ { name: "Falkland Islands (Islas Malvinas)", code: "FK", callingCode: 500 },
108
+ { name: "Faroe Islands (Føroyar)", code: "FO", callingCode: 298 },
109
+ { name: "Fiji", code: "FJ", callingCode: 679 },
110
+ { name: "Finland (Suomi)", code: "FI", callingCode: 358 },
111
+ { name: "France", code: "FR", callingCode: 33 },
112
+ { name: "French Guiana (Guyane française)", code: "GF", callingCode: 594 },
113
+ { name: "French Polynesia (Polynésie française)", code: "PF", callingCode: 689 },
114
+ { name: "Gabon", code: "GA", callingCode: 241 },
115
+ { name: "Gambia", code: "GM", callingCode: 220 },
116
+ { name: "Georgia (საქართველო)", code: "GE", callingCode: 995 },
117
+ { name: "Germany (Deutschland)", code: "DE", callingCode: 49 },
118
+ { name: "Ghana (Gaana)", code: "GH", callingCode: 233 },
119
+ { name: "Gibraltar", code: "GI", callingCode: 350 },
120
+ { name: "Greece (Ελλάδα)", code: "GR", callingCode: 30 },
121
+ { name: "Greenland (Kalaallit Nunaat)", code: "GL", callingCode: 299 },
122
+ { name: "Grenada", code: "GD", callingCode: 1 },
123
+ { name: "Guadeloupe", code: "GP", callingCode: 590 },
124
+ { name: "Guam", code: "GU", callingCode: 1 },
125
+ { name: "Guatemala", code: "GT", callingCode: 502 },
126
+ { name: "Guernsey", code: "GG", callingCode: 44 },
127
+ { name: "Guinea (Guinée)", code: "GN", callingCode: 224 },
128
+ { name: "Guinea-Bissau (Guiné Bissau)", code: "GW", callingCode: 245 },
129
+ { name: "Guyana", code: "GY", callingCode: 592 },
130
+ { name: "Haiti", code: "HT", callingCode: 509 },
131
+ { name: "Honduras", code: "HN", callingCode: 504 },
132
+ { name: "Hong Kong (香港)", code: "HK", callingCode: 852 },
133
+ { name: "Hungary (Magyarország)", code: "HU", callingCode: 36 },
134
+ { name: "Iceland (Ísland)", code: "IS", callingCode: 354 },
135
+ { name: "India (भारत)", code: "IN", callingCode: 91 },
136
+ { name: "Indonesia", code: "ID", callingCode: 62 },
137
+ { name: "Iran (‫ایران‬‎)", code: "IR", callingCode: 98 },
138
+ { name: "Iraq (‫العراق‬‎)", code: "IQ", callingCode: 964 },
139
+ { name: "Ireland", code: "IE", callingCode: 353 },
140
+ { name: "Isle of Man", code: "IM", callingCode: 44 },
141
+ { name: "Israel (‫ישראל‬‎)", code: "IL", callingCode: 972 },
142
+ { name: "Italy (Italia)", code: "IT", callingCode: 39 },
143
+ { name: "Jamaica", code: "JM", callingCode: 1 },
144
+ { name: "Japan (日本)", code: "JP", callingCode: 81 },
145
+ { name: "Jersey", code: "JE", callingCode: 44 },
146
+ { name: "Jordan (‫الأردن‬‎)", code: "JO", callingCode: 962 },
147
+ { name: "Kazakhstan (Казахстан)", code: "KZ", callingCode: 7 },
148
+ { name: "Kenya", code: "KE", callingCode: 254 },
149
+ { name: "Kiribati", code: "KI", callingCode: 686 },
150
+ { name: "Kosovo", code: "XK", callingCode: 383 },
151
+ { name: "Kuwait (‫الكويت‬‎)", code: "KW", callingCode: 965 },
152
+ { name: "Kyrgyzstan (Кыргызстан)", code: "KG", callingCode: 996 },
153
+ { name: "Laos (ລາວ)", code: "LA", callingCode: 856 },
154
+ { name: "Latvia (Latvija)", code: "LV", callingCode: 371 },
155
+ { name: "Lebanon (‫لبنان‬‎)", code: "LB", callingCode: 961 },
156
+ { name: "Lesotho", code: "LS", callingCode: 266 },
157
+ { name: "Liberia", code: "LR", callingCode: 231 },
158
+ { name: "Libya (‫ليبيا‬‎)", code: "LY", callingCode: 218 },
159
+ { name: "Liechtenstein", code: "LI", callingCode: 423 },
160
+ { name: "Lithuania (Lietuva)", code: "LT", callingCode: 370 },
161
+ { name: "Luxembourg", code: "LU", callingCode: 352 },
162
+ { name: "Macau (澳門)", code: "MO", callingCode: 853 },
163
+ { name: "North Macedonia (Македонија)", code: "MK", callingCode: 389 },
164
+ { name: "Madagascar (Madagasikara)", code: "MG", callingCode: 261 },
165
+ { name: "Malawi", code: "MW", callingCode: 265 },
166
+ { name: "Malaysia", code: "MY", callingCode: 60 },
167
+ { name: "Maldives", code: "MV", callingCode: 960 },
168
+ { name: "Mali", code: "ML", callingCode: 223 },
169
+ { name: "Malta", code: "MT", callingCode: 356 },
170
+ { name: "Marshall Islands", code: "MH", callingCode: 692 },
171
+ { name: "Martinique", code: "MQ", callingCode: 596 },
172
+ { name: "Mauritania (‫موريتانيا‬‎)", code: "MR", callingCode: 222 },
173
+ { name: "Mauritius (Moris)", code: "MU", callingCode: 230 },
174
+ { name: "Mayotte", code: "YT", callingCode: 262 },
175
+ { name: "Mexico (México)", code: "MX", callingCode: 52 },
176
+ { name: "Micronesia", code: "FM", callingCode: 691 },
177
+ { name: "Moldova (Republica Moldova)", code: "MD", callingCode: 373 },
178
+ { name: "Monaco", code: "MC", callingCode: 377 },
179
+ { name: "Mongolia (Монгол)", code: "MN", callingCode: 976 },
180
+ { name: "Montenegro (Crna Gora)", code: "ME", callingCode: 382 },
181
+ { name: "Montserrat", code: "MS", callingCode: 1 },
182
+ { name: "Morocco (‫المغرب‬‎)", code: "MA", callingCode: 212 },
183
+ { name: "Mozambique (Moçambique)", code: "MZ", callingCode: 258 },
184
+ { name: "Myanmar (Burma) (မြန်မာ)", code: "MM", callingCode: 95 },
185
+ { name: "Namibia (Namibië)", code: "NA", callingCode: 264 },
186
+ { name: "Nauru", code: "NR", callingCode: 674 },
187
+ { name: "Nepal (नेपाल)", code: "NP", callingCode: 977 },
188
+ { name: "Netherlands (Nederland)", code: "NL", callingCode: 31 },
189
+ { name: "New Caledonia (Nouvelle-Calédonie)", code: "NC", callingCode: 687 },
190
+ { name: "New Zealand", code: "NZ", callingCode: 64 },
191
+ { name: "Nicaragua", code: "NI", callingCode: 505 },
192
+ { name: "Niger (Nijar)", code: "NE", callingCode: 227 },
193
+ { name: "Nigeria", code: "NG", callingCode: 234 },
194
+ { name: "Niue", code: "NU", callingCode: 683 },
195
+ { name: "Norfolk Island", code: "NF", callingCode: 672 },
196
+ { name: "North Korea (조선 민주주의 인민 공화국)", code: "KP", callingCode: 850 },
197
+ { name: "Northern Mariana Islands", code: "MP", callingCode: 1 },
198
+ { name: "Norway (Norge)", code: "NO", callingCode: 47 },
199
+ { name: "Oman (‫عُمان‬‎)", code: "OM", callingCode: 968 },
200
+ { name: "Pakistan (‫پاکستان‬‎)", code: "PK", callingCode: 92 },
201
+ { name: "Palau", code: "PW", callingCode: 680 },
202
+ { name: "Palestine (‫فلسطين‬‎)", code: "PS", callingCode: 970 },
203
+ { name: "Panama (Panamá)", code: "PA", callingCode: 507 },
204
+ { name: "Papua New Guinea", code: "PG", callingCode: 675 },
205
+ { name: "Paraguay", code: "PY", callingCode: 595 },
206
+ { name: "Peru (Perú)", code: "PE", callingCode: 51 },
207
+ { name: "Philippines", code: "PH", callingCode: 63 },
208
+ { name: "Poland (Polska)", code: "PL", callingCode: 48 },
209
+ { name: "Portugal", code: "PT", callingCode: 351 },
210
+ { name: "Puerto Rico", code: "PR", callingCode: 1 },
211
+ { name: "Qatar (‫قطر‬‎)", code: "QA", callingCode: 974 },
212
+ { name: "Réunion (La Réunion)", code: "RE", callingCode: 262 },
213
+ { name: "Romania (România)", code: "RO", callingCode: 40 },
214
+ { name: "Russia (Россия)", code: "RU", callingCode: 7 },
215
+ { name: "Rwanda", code: "RW", callingCode: 250 },
216
+ { name: "Saint Barthélemy", code: "BL", callingCode: 590 },
217
+ { name: "Saint Helena", code: "SH", callingCode: 290 },
218
+ { name: "Saint Kitts and Nevis", code: "KN", callingCode: 1 },
219
+ { name: "Saint Lucia", code: "LC", callingCode: 1 },
220
+ { name: "Saint Martin (Saint-Martin (partie française))", code: "MF", callingCode: 590 },
221
+ { name: "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", code: "PM", callingCode: 508 },
222
+ { name: "Saint Vincent and the Grenadines", code: "VC", callingCode: 1 },
223
+ { name: "Samoa", code: "WS", callingCode: 685 },
224
+ { name: "San Marino", code: "SM", callingCode: 378 },
225
+ { name: "São Tomé and Príncipe (São Tomé e Príncipe)", code: "ST", callingCode: 239 },
226
+ { name: "Saudi Arabia (‫المملكة العربية السعودية‬‎)", code: "SA", callingCode: 966 },
227
+ { name: "Senegal (Sénégal)", code: "SN", callingCode: 221 },
228
+ { name: "Serbia (Србија)", code: "RS", callingCode: 381 },
229
+ { name: "Seychelles", code: "SC", callingCode: 248 },
230
+ { name: "Sierra Leone", code: "SL", callingCode: 232 },
231
+ { name: "Singapore", code: "SG", callingCode: 65 },
232
+ { name: "Sint Maarten", code: "SX", callingCode: 1 },
233
+ { name: "Slovakia (Slovensko)", code: "SK", callingCode: 421 },
234
+ { name: "Slovenia (Slovenija)", code: "SI", callingCode: 386 },
235
+ { name: "Solomon Islands", code: "SB", callingCode: 677 },
236
+ { name: "Somalia (Soomaaliya)", code: "SO", callingCode: 252 },
237
+ { name: "South Africa", code: "ZA", callingCode: 27 },
238
+ { name: "South Korea (대한민국)", code: "KR", callingCode: 82 },
239
+ { name: "South Sudan (‫جنوب السودان‬‎)", code: "SS", callingCode: 211 },
240
+ { name: "Spain (España)", code: "ES", callingCode: 34 },
241
+ { name: "Sri Lanka (ශ්‍රී ලංකාව)", code: "LK", callingCode: 94 },
242
+ { name: "Sudan (‫السودان‬‎)", code: "SD", callingCode: 249 },
243
+ { name: "Suriname", code: "SR", callingCode: 597 },
244
+ { name: "Svalbard and Jan Mayen", code: "SJ", callingCode: 47 },
245
+ { name: "Sweden (Sverige)", code: "SE", callingCode: 46 },
246
+ { name: "Switzerland (Schweiz)", code: "CH", callingCode: 41 },
247
+ { name: "Syria (‫سوريا‬‎)", code: "SY", callingCode: 963 },
248
+ { name: "Taiwan (台灣)", code: "TW", callingCode: 886 },
249
+ { name: "Tajikistan", code: "TJ", callingCode: 992 },
250
+ { name: "Tanzania", code: "TZ", callingCode: 255 },
251
+ { name: "Thailand (ไทย)", code: "TH", callingCode: 66 },
252
+ { name: "Timor-Leste", code: "TL", callingCode: 670 },
253
+ { name: "Togo", code: "TG", callingCode: 228 },
254
+ { name: "Tokelau", code: "TK", callingCode: 690 },
255
+ { name: "Tonga", code: "TO", callingCode: 676 },
256
+ { name: "Trinidad and Tobago", code: "TT", callingCode: 1 },
257
+ { name: "Tunisia (‫تونس‬‎)", code: "TN", callingCode: 216 },
258
+ { name: "Turkey (Türkiye)", code: "TR", callingCode: 90 },
259
+ { name: "Turkmenistan", code: "TM", callingCode: 993 },
260
+ { name: "Turks and Caicos Islands", code: "TC", callingCode: 1 },
261
+ { name: "Tuvalu", code: "TV", callingCode: 688 },
262
+ { name: "U.S. Virgin Islands", code: "VI", callingCode: 1 },
263
+ { name: "Uganda", code: "UG", callingCode: 256 },
264
+ { name: "Ukraine (Україна)", code: "UA", callingCode: 380 },
265
+ { name: "United Arab Emirates (‫الإمارات العربية المتحدة‬‎)", code: "AE", callingCode: 971 },
266
+ { name: "United Kingdom", code: "GB", callingCode: 44 },
267
+ { name: "United States", code: "US", callingCode: 1 },
268
+ { name: "Uruguay", code: "UY", callingCode: 598 },
269
+ { name: "Uzbekistan (Oʻzbekiston)", code: "UZ", callingCode: 998 },
270
+ { name: "Vanuatu", code: "VU", callingCode: 678 },
271
+ { name: "Vatican City (Città del Vaticano)", code: "VA", callingCode: 39 },
272
+ { name: "Venezuela", code: "VE", callingCode: 58 },
273
+ { name: "Vietnam (Việt Nam)", code: "VN", callingCode: 84 },
274
+ { name: "Wallis and Futuna (Wallis-et-Futuna)", code: "WF", callingCode: 681 },
275
+ { name: "Western Sahara (‫الصحراء الغربية‬‎)", code: "EH", callingCode: 212 },
276
+ { name: "Yemen (‫اليمن‬‎)", code: "YE", callingCode: 967 },
277
+ { name: "Zambia", code: "ZM", callingCode: 260 },
278
+ { name: "Zimbabwe", code: "ZW", callingCode: 263 },
279
+ { name: "Åland Islands", code: "AX", callingCode: 358 }
280
+ ];
281
+
282
+ /* eslint-disable @typescript-eslint/no-explicit-any */
283
+ /* eslint-disable @typescript-eslint/no-unused-vars */
284
+ const ALL_COUNTRIES_CALLING_CODES = '.*';
285
+ /** Data structure for holding telephone number. */
286
+ class ISOTelNumber {
287
+ country;
288
+ national;
289
+ constructor(country, national) {
290
+ this.country = country;
291
+ this.national = national;
292
+ }
293
+ }
294
+ class SPMatTelephoneInputComponent {
295
+ injector;
296
+ cdr;
297
+ http;
298
+ _focusMonitor;
299
+ _elementRef;
300
+ _formField;
301
+ ngControl;
302
+ static nextId = 0;
303
+ countrySelect;
304
+ nationalInput;
305
+ mobile = false;
306
+ // A regular expression specified as a string. This will be used to
307
+ // construct a RegExp object, by passing it as the argument.
308
+ allowedCountries;
309
+ defaultCountry = '';
310
+ filter$ = new BehaviorSubject('');
311
+ countries$ = this.filter$.pipe(map((searchStr) => {
312
+ const countries = new Array();
313
+ const searchStrLower = searchStr.toLocaleLowerCase();
314
+ this.countries.forEach((country) => {
315
+ if (`${country.callingCode} ${country.code} ${country.name}`
316
+ .toLocaleLowerCase()
317
+ .includes(searchStrLower)) {
318
+ countries.push(country);
319
+ }
320
+ });
321
+ return countries;
322
+ }));
323
+ countries = [];
324
+ filteredCountries = new ReplaySubject(1);
325
+ isDisabled = false;
326
+ _onChange = (_) => { };
327
+ control;
328
+ onCountrySelectFocus;
329
+ onCountrySelectBlur;
330
+ phoneUtil = PhoneNumberUtil.getInstance();
331
+ parts;
332
+ stateChanges = new Subject();
333
+ focused = false;
334
+ touched = false;
335
+ controlType = 'qq-tel-input';
336
+ id = `qq-tel-input-${SPMatTelephoneInputComponent.nextId++}`;
337
+ onChange = (_) => { };
338
+ onTouched = () => { };
339
+ telForm = new FormGroup({});
340
+ /** control for the MatSelect filter keyword */
341
+ countryFilterCtrl = new FormControl('');
342
+ get empty() {
343
+ const { value: { country, national }, } = this.parts;
344
+ return !country && !national;
345
+ }
346
+ get shouldLabelFloat() {
347
+ return this.focused || !this.empty;
348
+ }
349
+ userAriaDescribedBy;
350
+ get placeholder() {
351
+ return this._placeholder;
352
+ }
353
+ set placeholder(value) {
354
+ this._placeholder = value;
355
+ this.stateChanges.next();
356
+ }
357
+ _placeholder;
358
+ get required() {
359
+ return this._required ?? this.ngControl?.control?.hasValidator(Validators.required);
360
+ }
361
+ set required(value) {
362
+ this._required = coerceBooleanProperty(value);
363
+ this.stateChanges.next();
364
+ }
365
+ _required;
366
+ searchText = '';
367
+ noEntriesFoundLabel = 'Not found';
368
+ get disabled() {
369
+ return this._disabled ?? this.ngControl?.control?.disabled;
370
+ }
371
+ set disabled(value) {
372
+ this._disabled = coerceBooleanProperty(value);
373
+ this._disabled ? this.parts.disable() : this.parts.enable();
374
+ this.stateChanges.next();
375
+ }
376
+ _disabled;
377
+ destroy = new Subject();
378
+ get value() {
379
+ if (this.parts.valid) {
380
+ const { value: { country, national }, } = this.parts;
381
+ return new ISOTelNumber(`${country.callingCode}`, national);
382
+ }
383
+ return null;
384
+ }
385
+ set value(tel) {
386
+ const { country, national } = tel || new ISOTelNumber('', '');
387
+ let ci;
388
+ if (country) {
389
+ ci = this.countries.find((ci) => `${ci.callingCode}` == country);
390
+ }
391
+ // this.phoneUtil.
392
+ this.parts.setValue({ country: ci, national });
393
+ this.stateChanges.next();
394
+ }
395
+ get errorState() {
396
+ return this.parts.invalid && this.touched;
397
+ }
398
+ onFocusIn(event) {
399
+ if (!this.focused) {
400
+ this.focused = true;
401
+ this.stateChanges.next();
402
+ }
403
+ }
404
+ onFocusOut(event) {
405
+ if (!this._elementRef.nativeElement.contains(event.relatedTarget)) {
406
+ this.touched = true;
407
+ this.focused = false;
408
+ this.onTouched();
409
+ this.stateChanges.next();
410
+ }
411
+ }
412
+ autoFocusNext(control, nextElement) {
413
+ if (!control.errors && nextElement) {
414
+ this._focusMonitor.focusVia(nextElement, 'program');
415
+ }
416
+ }
417
+ autoFocusPrev(control, prevElement) {
418
+ if (control.value.length < 1) {
419
+ this._focusMonitor.focusVia(prevElement, 'program');
420
+ }
421
+ }
422
+ setDescribedByIds(ids) {
423
+ const controlElement = this._elementRef.nativeElement.querySelector('.qq-tel-input-container');
424
+ if (controlElement) {
425
+ controlElement.setAttribute('aria-describedby', ids.join(' '));
426
+ }
427
+ }
428
+ onContainerClick() {
429
+ // this._focusMonitor.focusVia(this.countrySelect, 'program');
430
+ // if (this.parts.controls.national.valid) {
431
+ // this._focusMonitor.focusVia(this.nationalInput, 'program');
432
+ // } else if (this.parts.controls.country.valid) {
433
+ // this._focusMonitor.focusVia(this.nationalInput, 'program');
434
+ // // } else if (this.parts.controls.national.valid) {
435
+ // // this._focusMonitor.focusVia(this.nationalInput, 'program');
436
+ // } else {
437
+ // this._focusMonitor.focusVia(this.countrySelect, 'program');
438
+ // }
439
+ }
440
+ constructor(injector, cdr, http, _focusMonitor, _elementRef, _formField, ngControl, formBuilder) {
441
+ this.injector = injector;
442
+ this.cdr = cdr;
443
+ this.http = http;
444
+ this._focusMonitor = _focusMonitor;
445
+ this._elementRef = _elementRef;
446
+ this._formField = _formField;
447
+ this.ngControl = ngControl;
448
+ if (this.ngControl != null) {
449
+ this.ngControl.valueAccessor = this;
450
+ }
451
+ this.parts = formBuilder.group({
452
+ country: [undefined, Validators.required],
453
+ national: ['', Validators.required],
454
+ });
455
+ this.initCountries();
456
+ }
457
+ ngOnInit() {
458
+ this.initCountries();
459
+ // this.onCountrySelectFocus = () => {
460
+ // const options = (this.countrySelect.nativeElement as HTMLSelectElement).options;
461
+ // [].forEach.call(options, function(o: any) {
462
+ // const countryInfo: string = o.getAttribute('data-descr');
463
+ // const [name, callingCode] = countryInfo.split('.');
464
+ // o.textContent = name + ' (' + callingCode + ')';
465
+ // });
466
+ // }
467
+ // this.onCountrySelectBlur = () => {
468
+ // const options = (this.countrySelect.nativeElement as HTMLSelectElement).options;
469
+ // [].forEach.call(options, function(o: any) {
470
+ // const countryInfo: string = o.getAttribute('data-descr');
471
+ // const [name, callingCode] = countryInfo.split('.');
472
+ // o.textContent = '+' + callingCode;
473
+ // });
474
+ // }
475
+ // this.countrySelect.nativeElement.addEventListener('focus', this.onCountrySelectFocus);
476
+ // this.countrySelect.nativeElement.addEventListener('blur', this.onCountrySelectBlur);
477
+ if (this.defaultCountry) {
478
+ const country = this.countries.find((ci) => ci.code == this.defaultCountry);
479
+ this.parts.controls.country.setValue(country);
480
+ }
481
+ this.filteredCountries.next(this.countries.slice());
482
+ // listen for search field value changes
483
+ this.countryFilterCtrl.valueChanges
484
+ .pipe(takeUntil(this.destroy))
485
+ .subscribe(() => {
486
+ this.filterCountries();
487
+ });
488
+ }
489
+ setInitialValue() {
490
+ this.filteredCountries
491
+ .pipe(take(1), takeUntil(this.destroy))
492
+ .subscribe(() => {
493
+ // Setting the compareWith property to a comparison function
494
+ // triggers initializing the selection according to the initial value of
495
+ // the form control (i.e. _initializeSelection()).
496
+ // This needs to be done after the filteredCountries are loaded
497
+ // initially and after the mat-option elements are available.
498
+ this.countrySelect.compareWith = (a, b) => a && b && a.code === b.code;
499
+ });
500
+ }
501
+ filterCountries() {
502
+ if (!this.countries) {
503
+ return;
504
+ }
505
+ // get the search keyword
506
+ let search = this.countryFilterCtrl.value;
507
+ if (!search) {
508
+ this.filteredCountries.next(this.countries.slice());
509
+ return;
510
+ }
511
+ search = search.toLowerCase();
512
+ // filter the banks
513
+ this.filteredCountries.next(this.countries.filter((country) => country.name.toLowerCase().indexOf(search) > -1 ||
514
+ country.callingCode.toString().indexOf(search) > -1 ||
515
+ country.code.toLowerCase().indexOf(search) > -1));
516
+ }
517
+ ngAfterViewInit() {
518
+ const ngControl = this.injector.get(NgControl, null);
519
+ if (ngControl) {
520
+ this.control = ngControl.control;
521
+ }
522
+ this.disableComponents();
523
+ if (!this.parts.controls.country.value) {
524
+ this.detectCountry();
525
+ }
526
+ else {
527
+ this.setInitialValue();
528
+ }
529
+ }
530
+ ngOnDestroy() {
531
+ // this.countrySelect.nativeElement.removeAllListners();
532
+ this.destroy.next();
533
+ this.destroy.complete();
534
+ this.stateChanges.complete();
535
+ this._focusMonitor.stopMonitoring(this._elementRef);
536
+ }
537
+ /**
538
+ * Set the country code to the given code.
539
+ *
540
+ * @param code Numeric country code to set the value of the country
541
+ * ion-select to. Will validate the code against a built-in country
542
+ * code list.
543
+ */
544
+ setCountryCode(code) {
545
+ code = code.trim();
546
+ if (code.startsWith('+')) {
547
+ code = code.substring(1);
548
+ }
549
+ for (let index = 0; index < this.countries.length; index++) {
550
+ const country = this.countries[index];
551
+ if (`${country.callingCode}` === code) {
552
+ this.parts.controls.country.setValue(country);
553
+ this.cdr.detectChanges();
554
+ }
555
+ }
556
+ }
557
+ // ControlValueAccessor interface methods
558
+ writeValue(telNumber) {
559
+ // Check the supplied number string can be converted into a numeric value.
560
+ try {
561
+ if (telNumber) {
562
+ const phoneNumber = this.phoneUtil.parse(telNumber);
563
+ if (phoneNumber) {
564
+ const cc = phoneNumber.getCountryCode();
565
+ const country = this.countries.find((ci) => ci.callingCode === cc);
566
+ if (country) {
567
+ this.parts.controls.country.setValue(country);
568
+ this.parts.controls.national.setValue(phoneNumber.getNationalNumber());
569
+ }
570
+ }
571
+ }
572
+ else {
573
+ // null value usually means form-reset. Clear national number
574
+ // and leave selected country code intact.
575
+ this.parts.controls.country.setValue(null);
576
+ this.parts.controls.national.setValue(null);
577
+ this.parts.controls.country.setErrors(null);
578
+ this.parts.controls.national.setErrors(null);
579
+ this.parts.setErrors(null);
580
+ }
581
+ this.cdr.detectChanges();
582
+ }
583
+ catch (error) {
584
+ // empty
585
+ }
586
+ }
587
+ registerOnChange(fn) {
588
+ this._onChange = fn;
589
+ }
590
+ registerOnTouched(fn) { }
591
+ setDisabledState(isDisabled) {
592
+ this.isDisabled = isDisabled;
593
+ if (this.countrySelect && this.nationalInput) {
594
+ this.disableComponents();
595
+ }
596
+ }
597
+ onCountryChange(ev) {
598
+ const telNumberParts = this.getTelephoneNumberParts();
599
+ if (telNumberParts) {
600
+ this.notifyChange(telNumberParts);
601
+ this.control.setErrors(null);
602
+ }
603
+ else {
604
+ if (this.control) {
605
+ this.control.setErrors({ invalidPhoneNumber: true });
606
+ this.cdr.detectChanges();
607
+ }
608
+ }
609
+ }
610
+ onNationalNumberChange(ev) {
611
+ const telNumberParts = this.getTelephoneNumberParts();
612
+ if (telNumberParts) {
613
+ this.notifyChange(telNumberParts);
614
+ this.control.setErrors(null);
615
+ }
616
+ else {
617
+ if (this.control) {
618
+ this.control.setErrors({ invalidPhoneNumber: true });
619
+ this.cdr.detectChanges();
620
+ }
621
+ }
622
+ }
623
+ /**
624
+ * Returns the telephone number in ISO8601 format.
625
+ * @param numberParts
626
+ * @returns
627
+ */
628
+ ISOTelephoneNumber(numberParts) {
629
+ return `+${numberParts.callingCode}${numberParts.nationalNumber}`;
630
+ }
631
+ notifyChange(numberParts) {
632
+ const geoLocationProvider = this.injector.get(QQMAT_TELEPHONE_INPUT_CONFIG_PROVIDER, null);
633
+ if (geoLocationProvider && geoLocationProvider.saveCountrySelection) {
634
+ geoLocationProvider
635
+ .saveCountrySelection(numberParts)
636
+ .then(() => this._onChange(this.ISOTelephoneNumber(numberParts)))
637
+ .catch(() => { });
638
+ }
639
+ else {
640
+ this._onChange(this.ISOTelephoneNumber(numberParts));
641
+ }
642
+ }
643
+ get placeholderText() {
644
+ let placeholderText = this.placeholder;
645
+ if (this.required) {
646
+ placeholderText = placeholderText + '*';
647
+ }
648
+ return placeholderText;
649
+ }
650
+ get hasErrors() {
651
+ return this.control && this.control.hasError('invalidPhoneNumber');
652
+ }
653
+ disableComponents() {
654
+ const action = this.isDisabled ? 'addClass' : 'removeClass';
655
+ if (this.countrySelect) {
656
+ //this.countryCodeSelector.disabled = this.isDisabled;
657
+ }
658
+ if (this.nationalInput) {
659
+ //this.nationalNumberInput.disabled = this.isDisabled;
660
+ }
661
+ }
662
+ /**
663
+ * Returns the full telephone number, combining the selected
664
+ * country code with the national number.
665
+ *
666
+ * Leading zeros in the national number are removed.
667
+ *
668
+ * Validates the entered number using google-libphonenumber and if
669
+ * invalid, returns an empty string.
670
+ */
671
+ getTelephoneNumberParts() {
672
+ const selectedCountry = this.parts.controls.country.value;
673
+ const nationalNumber = this.parts.controls.national.value;
674
+ if (nationalNumber) {
675
+ const ci = this.countries.find((ci) => ci.callingCode == selectedCountry.callingCode);
676
+ if (ci) {
677
+ try {
678
+ const phoneNumber = this.phoneUtil.parse(nationalNumber, ci.code);
679
+ if (this.phoneUtil.isValidNumberForRegion(phoneNumber, ci.code)) {
680
+ const numberType = this.phoneUtil.getNumberType(phoneNumber);
681
+ // console.log(`Valid phone number for country ${ci.code}: ${this.phoneUtil.format(phoneNumber, PhoneNumberFormat.E164)}, type: ${numberType}`);
682
+ if (!this.mobile || numberType === PhoneNumberType.MOBILE) {
683
+ // const fullNumber = this.phoneUtil.format(phoneNumber, PhoneNumberFormat.E164);
684
+ // console.log('full tel number:', fullNumber);
685
+ return {
686
+ ...ci,
687
+ nationalNumber: nationalNumber,
688
+ };
689
+ }
690
+ }
691
+ }
692
+ catch (error) {
693
+ // do nothing
694
+ }
695
+ }
696
+ }
697
+ return null;
698
+ }
699
+ getAllowedCountries() {
700
+ if (this.allowedCountries) {
701
+ return this.allowedCountries;
702
+ }
703
+ const geoLocationProvider = this.injector.get(QQMAT_TELEPHONE_INPUT_CONFIG_PROVIDER, null);
704
+ return geoLocationProvider && geoLocationProvider.countries
705
+ ? geoLocationProvider.countries
706
+ : ALL_COUNTRIES_CALLING_CODES;
707
+ }
708
+ detectCountry() {
709
+ const geoLocationProvider = this.injector.get(QQMAT_TELEPHONE_INPUT_CONFIG_PROVIDER, null);
710
+ if (geoLocationProvider && geoLocationProvider.getCountryCode) {
711
+ geoLocationProvider
712
+ .getCountryCode(this.http)
713
+ .pipe(tap((res) => {
714
+ // console.log(`detectCountry response: ${JSON.stringify(res)}`);
715
+ if (res.countryCode) {
716
+ const cc = COUNTRY_CODES.find((cc) => cc.code == res.countryCode);
717
+ if (cc && !this.parts.controls.country.value) {
718
+ this.parts.controls.country.setValue(cc);
719
+ this.cdr.detectChanges();
720
+ }
721
+ }
722
+ }), catchError((err) => {
723
+ // console.log(`detectCountry error: ${JSON.stringify(err)}`);
724
+ return NEVER;
725
+ }))
726
+ .subscribe();
727
+ }
728
+ else {
729
+ // console.log(`QQMAT_TELEPHONE_INPUT_CONFIG_PROVIDER not available`);
730
+ }
731
+ }
732
+ // Initialize this.countries if it's not already been initialized.
733
+ initCountries() {
734
+ if (!this.countries.length) {
735
+ // determine countries we support
736
+ const ccRegex = new RegExp(this.getAllowedCountries());
737
+ COUNTRY_CODES.forEach((c) => {
738
+ if (ccRegex.test(c.code)) {
739
+ this.countries.push(c);
740
+ }
741
+ });
742
+ this.countries = this.countries.sort((a, b) => a.name.localeCompare(b.name));
743
+ }
744
+ }
745
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPMatTelephoneInputComponent, deps: [{ token: i0.Injector }, { token: i0.ChangeDetectorRef }, { token: i1.HttpClient }, { token: i2.FocusMonitor }, { token: i0.ElementRef }, { token: MAT_FORM_FIELD, optional: true }, { token: i3.NgControl, optional: true, self: true }, { token: i3.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
746
+ /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.6", type: SPMatTelephoneInputComponent, isStandalone: true, selector: "sp-mat-telephone-input", inputs: { mobile: "mobile", allowedCountries: "allowedCountries", defaultCountry: "defaultCountry", userAriaDescribedBy: ["aria-describedby", "userAriaDescribedBy"], placeholder: "placeholder", required: "required", searchText: "searchText", noEntriesFoundLabel: "noEntriesFoundLabel", disabled: "disabled", value: "value" }, providers: [
747
+ { provide: MatFormFieldControl, useExisting: SPMatTelephoneInputComponent },
748
+ ], viewQueries: [{ propertyName: "countrySelect", first: true, predicate: ["countryCodeSelector"], descendants: true, static: true }, { propertyName: "nationalInput", first: true, predicate: ["nationalNumberInput"], descendants: true }], ngImport: i0, template: `
749
+ <!--
750
+ <div
751
+ rol="group"
752
+ class="tel-input-wrapper"
753
+ [formGroup]="parts"
754
+ [attr.aria-labelledby]="_formField?.getLabelId()"
755
+ (focusin)="onFocusIn($event)"
756
+ (focusout)="onFocusOut($event)"
757
+ >
758
+ <select
759
+ #countryCodeSelector
760
+ title="Country Code"
761
+ formControlName="country"
762
+ (change)="onCountryChange($event)"
763
+ >
764
+ <option
765
+ *ngFor="let c of filteredCountries | async"
766
+ value="{{ c.code }}"
767
+ [attr.data-descr]="c.name + '.' + c.callingCode"
768
+ >
769
+ {{ c.name }} +{{ c.callingCode }}
770
+ </option>
771
+ </select>
772
+ <input
773
+ #nationalNumberInput
774
+ formControlName="national"
775
+ type="tel"
776
+ (input)="onNationalNumberChange($event)"
777
+ />
778
+ </div>
779
+ -->
780
+ <div class="tel-input-wrapper" [formGroup]="parts">
781
+ <mat-select
782
+ #countryCodeSelector
783
+ formControlName="country"
784
+ (selectionChange)="onCountryChange($event)"
785
+ >
786
+ <mat-option>
787
+ <ngx-mat-select-search
788
+ [placeholderLabel]="searchText"
789
+ [noEntriesFoundLabel]="noEntriesFoundLabel"
790
+ [formControl]="countryFilterCtrl"
791
+ ></ngx-mat-select-search>
792
+ </mat-option>
793
+ <mat-option
794
+ *ngFor="let c of filteredCountries | async"
795
+ [value]="c"
796
+ [attr.data-descr]="c.name + '.' + c.callingCode"
797
+ >
798
+ {{ c.name }} +{{ c.callingCode }}
799
+ </mat-option>
800
+ </mat-select>
801
+ <input
802
+ style="padding-left: 4px"
803
+ #nationalNumberInput
804
+ formControlName="national"
805
+ type="tel"
806
+ (input)="onNationalNumberChange($event)"
807
+ />
808
+ </div>
809
+ `, isInline: true, styles: [".tel-input-wrapper{display:flex;padding:1px}.error-border{border-color:red}.box-border{border-bottom:1px solid gray;border-radius:4px}mat-select{display:inline-block;border:none;outline:none;scroll-behavior:smooth;background:none;width:30%}mat-select:focus{border:none;outline:none;background:none;scroll-behavior:smooth}input{flex:1 1 auto;background:none;border:none}input:focus{border:none;outline:none}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i5.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i6.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: NgxMatSelectSearchModule }, { kind: "component", type: i7.MatSelectSearchComponent, selector: "ngx-mat-select-search", inputs: ["placeholderLabel", "type", "closeIcon", "closeSvgIcon", "noEntriesFoundLabel", "clearSearchInput", "searching", "disableInitialFocus", "enableClearOnEscapePressed", "preventHomeEndKeyPropagation", "disableScrollToActiveOnOptionsChanged", "ariaLabel", "showToggleAllCheckbox", "toggleAllCheckboxChecked", "toggleAllCheckboxIndeterminate", "toggleAllCheckboxTooltipMessage", "toggleAllCheckboxTooltipPosition", "hideClearSearchButton", "alwaysRestoreSelectedOptionsMulti", "recreateValuesArray"], outputs: ["toggleAll"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
810
+ }
811
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: SPMatTelephoneInputComponent, decorators: [{
812
+ type: Component,
813
+ args: [{ selector: 'sp-mat-telephone-input', template: `
814
+ <!--
815
+ <div
816
+ rol="group"
817
+ class="tel-input-wrapper"
818
+ [formGroup]="parts"
819
+ [attr.aria-labelledby]="_formField?.getLabelId()"
820
+ (focusin)="onFocusIn($event)"
821
+ (focusout)="onFocusOut($event)"
822
+ >
823
+ <select
824
+ #countryCodeSelector
825
+ title="Country Code"
826
+ formControlName="country"
827
+ (change)="onCountryChange($event)"
828
+ >
829
+ <option
830
+ *ngFor="let c of filteredCountries | async"
831
+ value="{{ c.code }}"
832
+ [attr.data-descr]="c.name + '.' + c.callingCode"
833
+ >
834
+ {{ c.name }} +{{ c.callingCode }}
835
+ </option>
836
+ </select>
837
+ <input
838
+ #nationalNumberInput
839
+ formControlName="national"
840
+ type="tel"
841
+ (input)="onNationalNumberChange($event)"
842
+ />
843
+ </div>
844
+ -->
845
+ <div class="tel-input-wrapper" [formGroup]="parts">
846
+ <mat-select
847
+ #countryCodeSelector
848
+ formControlName="country"
849
+ (selectionChange)="onCountryChange($event)"
850
+ >
851
+ <mat-option>
852
+ <ngx-mat-select-search
853
+ [placeholderLabel]="searchText"
854
+ [noEntriesFoundLabel]="noEntriesFoundLabel"
855
+ [formControl]="countryFilterCtrl"
856
+ ></ngx-mat-select-search>
857
+ </mat-option>
858
+ <mat-option
859
+ *ngFor="let c of filteredCountries | async"
860
+ [value]="c"
861
+ [attr.data-descr]="c.name + '.' + c.callingCode"
862
+ >
863
+ {{ c.name }} +{{ c.callingCode }}
864
+ </mat-option>
865
+ </mat-select>
866
+ <input
867
+ style="padding-left: 4px"
868
+ #nationalNumberInput
869
+ formControlName="national"
870
+ type="tel"
871
+ (input)="onNationalNumberChange($event)"
872
+ />
873
+ </div>
874
+ `, imports: [
875
+ CommonModule,
876
+ FormsModule,
877
+ ReactiveFormsModule,
878
+ MatSelectModule,
879
+ NgxMatSelectSearchModule,
880
+ ], providers: [
881
+ { provide: MatFormFieldControl, useExisting: SPMatTelephoneInputComponent },
882
+ ], changeDetection: ChangeDetectionStrategy.OnPush, styles: [".tel-input-wrapper{display:flex;padding:1px}.error-border{border-color:red}.box-border{border-bottom:1px solid gray;border-radius:4px}mat-select{display:inline-block;border:none;outline:none;scroll-behavior:smooth;background:none;width:30%}mat-select:focus{border:none;outline:none;background:none;scroll-behavior:smooth}input{flex:1 1 auto;background:none;border:none}input:focus{border:none;outline:none}\n"] }]
883
+ }], ctorParameters: () => [{ type: i0.Injector }, { type: i0.ChangeDetectorRef }, { type: i1.HttpClient }, { type: i2.FocusMonitor }, { type: i0.ElementRef }, { type: i8.MatFormField, decorators: [{
884
+ type: Optional
885
+ }, {
886
+ type: Inject,
887
+ args: [MAT_FORM_FIELD]
888
+ }] }, { type: i3.NgControl, decorators: [{
889
+ type: Optional
890
+ }, {
891
+ type: Self
892
+ }] }, { type: i3.FormBuilder }], propDecorators: { countrySelect: [{
893
+ type: ViewChild,
894
+ args: ['countryCodeSelector', { static: true }]
895
+ }], nationalInput: [{
896
+ type: ViewChild,
897
+ args: ['nationalNumberInput']
898
+ }], mobile: [{
899
+ type: Input
900
+ }], allowedCountries: [{
901
+ type: Input
902
+ }], defaultCountry: [{
903
+ type: Input
904
+ }], userAriaDescribedBy: [{
905
+ type: Input,
906
+ args: ['aria-describedby']
907
+ }], placeholder: [{
908
+ type: Input
909
+ }], required: [{
910
+ type: Input
911
+ }], searchText: [{
912
+ type: Input
913
+ }], noEntriesFoundLabel: [{
914
+ type: Input
915
+ }], disabled: [{
916
+ type: Input
917
+ }], value: [{
918
+ type: Input
919
+ }] } });
920
+
921
+ /**
922
+ * Generated bundle index. Do not edit.
923
+ */
924
+
925
+ export { ISOTelNumber, QQMAT_TELEPHONE_INPUT_CONFIG_PROVIDER, SPMatTelephoneInputComponent };
926
+ //# sourceMappingURL=smallpearl-ngx-helper-mat-tel-input.mjs.map