@liquid-js/lyr-extras 0.0.0-stage → 22.0.0-alpha.1
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.
- package/LICENSE.txt +23 -0
- package/README.md +61 -2
- package/fesm2022/liquid-js-lyr-extras-chart.mjs +871 -0
- package/fesm2022/liquid-js-lyr-extras-chart.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-color-picker.mjs +821 -0
- package/fesm2022/liquid-js-lyr-extras-color-picker.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs +923 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-viewer.mjs +369 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-viewer.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-mask.mjs +240 -0
- package/fesm2022/liquid-js-lyr-extras-mask.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-media.mjs +1142 -0
- package/fesm2022/liquid-js-lyr-extras-media.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-phone-input.mjs +864 -0
- package/fesm2022/liquid-js-lyr-extras-phone-input.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-qr-code.mjs +236 -0
- package/fesm2022/liquid-js-lyr-extras-qr-code.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras.mjs +0 -0
- package/package.json +159 -3
- package/types/liquid-js-lyr-extras-chart.d.ts +294 -0
- package/types/liquid-js-lyr-extras-color-picker.d.ts +311 -0
- package/types/liquid-js-lyr-extras-markdown-editor.d.ts +367 -0
- package/types/liquid-js-lyr-extras-markdown-viewer.d.ts +174 -0
- package/types/liquid-js-lyr-extras-mask.d.ts +130 -0
- package/types/liquid-js-lyr-extras-media.d.ts +517 -0
- package/types/liquid-js-lyr-extras-phone-input.d.ts +428 -0
- package/types/liquid-js-lyr-extras-qr-code.d.ts +113 -0
- package/types/liquid-js-lyr-extras.d.ts +1 -0
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Directive, ElementRef, InjectionToken, Injector, LOCALE_ID, ViewEncapsulation, afterNextRender, booleanAttribute, computed, effect, forwardRef, inject, input, linkedSignal, model, resource, signal, untracked, viewChild } from "@angular/core";
|
|
3
|
+
import { NG_VALIDATORS, NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
4
|
+
import { NbAutocompleteComponent, NbAutocompleteDirective, NbButtonComponent, NbFormFieldComponent, NbIconComponent, NbInputDirective, NbOptionComponent, NbPrefixDirective, NbValidationDirective, injectNbDefaults, injectNbTexts, injectNbValidationMessage, nbValidationParam } from "@liquid-js/lyr-core";
|
|
5
|
+
import { getCountries, getCountryCallingCode, getExampleNumber, parsePhoneNumberFromString } from "libphonenumber-js";
|
|
6
|
+
import examples from "libphonenumber-js/mobile/examples";
|
|
7
|
+
import { FlagComponent, FlagDatabase } from "nxt-flags";
|
|
8
|
+
import { validate } from "@angular/forms/signals";
|
|
9
|
+
const NB_COUNTRY_NAMES = new InjectionToken("Lyra Country Names", { factory: () => () => import("i18n-iso-countries/langs/en.json", { with: { type: "json" } }) });
|
|
10
|
+
function provideNbCountryNames(names) {
|
|
11
|
+
return [{
|
|
12
|
+
provide: NB_COUNTRY_NAMES,
|
|
13
|
+
useValue: names
|
|
14
|
+
}];
|
|
15
|
+
}
|
|
16
|
+
async function loadCountryNames(source) {
|
|
17
|
+
if (typeof source !== "function") return source;
|
|
18
|
+
const loaded = await source();
|
|
19
|
+
return "default" in loaded ? loaded.default : loaded;
|
|
20
|
+
}
|
|
21
|
+
function nbPhoneInputTexts() {
|
|
22
|
+
return {
|
|
23
|
+
number: $localize`:@@nb.phoneInput.number:Phone number`,
|
|
24
|
+
country: (name) => $localize`:@@nb.phoneInput.country:Country: ${name}:country:`,
|
|
25
|
+
noCountry: $localize`:@@nb.phoneInput.noCountry:Choose a country`,
|
|
26
|
+
search: $localize`:@@nb.phoneInput.search:Search countries`,
|
|
27
|
+
invalid: $localize`:@@nb.phoneInput.invalid:Enter a valid phone number`,
|
|
28
|
+
otherCountry: $localize`:@@nb.phoneInput.otherCountry:Enter a phone number from one of the allowed countries`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function injectNbPhoneInputTexts() {
|
|
32
|
+
return injectNbTexts("phoneInput", nbPhoneInputTexts);
|
|
33
|
+
}
|
|
34
|
+
const NB_PHONE_NUMBER_ERROR = "nbPhoneNumber";
|
|
35
|
+
const allCountries$1 = new Set(getCountries());
|
|
36
|
+
function localeCountry(locale) {
|
|
37
|
+
try {
|
|
38
|
+
const region = new Intl.Locale(locale).maximize().region;
|
|
39
|
+
return region && allCountries$1.has(region) ? region : void 0;
|
|
40
|
+
} catch {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function parsePhoneNumber(text, country) {
|
|
45
|
+
if (!text.trim()) return;
|
|
46
|
+
const number = parsePhoneNumberFromString(text, country);
|
|
47
|
+
return number?.isValid() ? number : void 0;
|
|
48
|
+
}
|
|
49
|
+
function checkPhoneNumber(value, country, countries) {
|
|
50
|
+
if (value === null || value === void 0 || value === "") return;
|
|
51
|
+
const number = parsePhoneNumber(String(value), country);
|
|
52
|
+
if (!number) return "invalid";
|
|
53
|
+
return countries && !(number.country && countries.includes(number.country)) ? "country" : void 0;
|
|
54
|
+
}
|
|
55
|
+
function phoneNumberError(context, problem, message) {
|
|
56
|
+
const own = typeof message === "function" ? message(problem) : message;
|
|
57
|
+
if (own !== void 0) return {
|
|
58
|
+
kind: NB_PHONE_NUMBER_ERROR,
|
|
59
|
+
problem,
|
|
60
|
+
message: own
|
|
61
|
+
};
|
|
62
|
+
const texts = context.texts();
|
|
63
|
+
const error = {
|
|
64
|
+
kind: NB_PHONE_NUMBER_ERROR,
|
|
65
|
+
problem,
|
|
66
|
+
message: problem === "country" ? texts.otherCountry : texts.invalid
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
...error,
|
|
70
|
+
message: context.message({
|
|
71
|
+
kind: NB_PHONE_NUMBER_ERROR,
|
|
72
|
+
params: error
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function validatePhoneNumber(value, options, context) {
|
|
77
|
+
const problem = checkPhoneNumber(value, read(options.country) ?? context.country, read(options.countries));
|
|
78
|
+
return problem ? phoneNumberError(context, problem, options.message) : void 0;
|
|
79
|
+
}
|
|
80
|
+
const read = (option) => typeof option === "function" ? option() : option;
|
|
81
|
+
function phoneNumberContext() {
|
|
82
|
+
try {
|
|
83
|
+
const texts = injectNbPhoneInputTexts();
|
|
84
|
+
return {
|
|
85
|
+
texts: () => texts(),
|
|
86
|
+
message: injectNbValidationMessage(),
|
|
87
|
+
country: localeCountry(inject(LOCALE_ID))
|
|
88
|
+
};
|
|
89
|
+
} catch {
|
|
90
|
+
const texts = nbPhoneInputTexts();
|
|
91
|
+
return {
|
|
92
|
+
texts: () => texts,
|
|
93
|
+
message: (error) => {
|
|
94
|
+
const message = nbValidationParam(error, "message");
|
|
95
|
+
return typeof message === "string" ? message : "";
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function nbPhoneNumberValidator(options = {}) {
|
|
101
|
+
const context = phoneNumberContext();
|
|
102
|
+
return (control) => {
|
|
103
|
+
const error = validatePhoneNumber(control.value, options, context);
|
|
104
|
+
return error ? { [NB_PHONE_NUMBER_ERROR]: error } : null;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function nbPhoneNumber(path, options = {}) {
|
|
108
|
+
const context = phoneNumberContext();
|
|
109
|
+
validate(path, ({ value }) => validatePhoneNumber(value(), options, context));
|
|
110
|
+
}
|
|
111
|
+
const flagFallbacks = {
|
|
112
|
+
AC: "sh",
|
|
113
|
+
TA: "sh"
|
|
114
|
+
};
|
|
115
|
+
const allCountries = new Set(getCountries());
|
|
116
|
+
const fold = (text) => text.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLocaleLowerCase();
|
|
117
|
+
var NbPhoneInputComponent = class NbPhoneInputComponent {
|
|
118
|
+
constructor() {
|
|
119
|
+
this.nbDefaults = injectNbDefaults("input");
|
|
120
|
+
this.texts = injectNbPhoneInputTexts();
|
|
121
|
+
this.errorContext = phoneNumberContext();
|
|
122
|
+
this.locale = inject(LOCALE_ID);
|
|
123
|
+
this.injector = inject(Injector);
|
|
124
|
+
this.validation = inject(NbValidationDirective, {
|
|
125
|
+
self: true,
|
|
126
|
+
optional: true
|
|
127
|
+
});
|
|
128
|
+
this.country = model(...ngDevMode ? [void 0, { debugName: "country" }] : /* istanbul ignore next */ []);
|
|
129
|
+
this.countries = input(...ngDevMode ? [void 0, { debugName: "countries" }] : /* istanbul ignore next */ []);
|
|
130
|
+
this.sizeInput = input(void 0, {
|
|
131
|
+
...ngDevMode ? { debugName: "sizeInput" } : /* istanbul ignore next */ {},
|
|
132
|
+
alias: "size"
|
|
133
|
+
});
|
|
134
|
+
this.size = linkedSignal(() => this.sizeInput() ?? this.nbDefaults().size ?? "medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
135
|
+
this.status = input("basic", ...ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []);
|
|
136
|
+
this.shapeInput = input(void 0, {
|
|
137
|
+
...ngDevMode ? { debugName: "shapeInput" } : /* istanbul ignore next */ {},
|
|
138
|
+
alias: "shape"
|
|
139
|
+
});
|
|
140
|
+
this.shape = linkedSignal(() => this.shapeInput() ?? this.nbDefaults().shape ?? "rectangle", ...ngDevMode ? [{ debugName: "shape" }] : /* istanbul ignore next */ []);
|
|
141
|
+
this.fullWidth = input(false, {
|
|
142
|
+
...ngDevMode ? { debugName: "fullWidth" } : /* istanbul ignore next */ {},
|
|
143
|
+
transform: booleanAttribute
|
|
144
|
+
});
|
|
145
|
+
this.ghost = input(false, {
|
|
146
|
+
...ngDevMode ? { debugName: "ghost" } : /* istanbul ignore next */ {},
|
|
147
|
+
transform: booleanAttribute
|
|
148
|
+
});
|
|
149
|
+
this.disabled = input(false, {
|
|
150
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
151
|
+
transform: booleanAttribute
|
|
152
|
+
});
|
|
153
|
+
this.readonly = input(false, {
|
|
154
|
+
...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
|
|
155
|
+
transform: booleanAttribute
|
|
156
|
+
});
|
|
157
|
+
this.placeholder = input(...ngDevMode ? [void 0, { debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
158
|
+
this.overlayOffset = input(8, ...ngDevMode ? [{ debugName: "overlayOffset" }] : /* istanbul ignore next */ []);
|
|
159
|
+
this.ariaLabel = input(void 0, {
|
|
160
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
161
|
+
alias: "aria-label"
|
|
162
|
+
});
|
|
163
|
+
this.ariaLabelledBy = input(void 0, {
|
|
164
|
+
...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
|
|
165
|
+
alias: "aria-labelledby"
|
|
166
|
+
});
|
|
167
|
+
this.fieldLabelledBy = computed(() => [this.ariaLabelledBy(), this.validation?.labelledBy()].filter(Boolean).join(" ") || null, ...ngDevMode ? [{ debugName: "fieldLabelledBy" }] : /* istanbul ignore next */ []);
|
|
168
|
+
this.selectedCountry = computed(() => this.country() ?? localeCountry(this.locale), ...ngDevMode ? [{ debugName: "selectedCountry" }] : /* istanbul ignore next */ []);
|
|
169
|
+
this.isDisabled = linkedSignal(() => this.disabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
170
|
+
this.resolvedStatus = computed(() => this.validation?.status() ?? this.status(), ...ngDevMode ? [{ debugName: "resolvedStatus" }] : /* istanbul ignore next */ []);
|
|
171
|
+
this.buttonStatus = computed(() => this.resolvedStatus() === "control" ? "control" : "basic", ...ngDevMode ? [{ debugName: "buttonStatus" }] : /* istanbul ignore next */ []);
|
|
172
|
+
this.text = signal("", ...ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []);
|
|
173
|
+
this.parseError = signal(false, ...ngDevMode ? [{ debugName: "parseError" }] : /* istanbul ignore next */ []);
|
|
174
|
+
this.picking = signal(false, ...ngDevMode ? [{ debugName: "picking" }] : /* istanbul ignore next */ []);
|
|
175
|
+
this.query = signal("", ...ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []);
|
|
176
|
+
this.namesSource = inject(NB_COUNTRY_NAMES);
|
|
177
|
+
this.names = resource({
|
|
178
|
+
...ngDevMode ? { debugName: "names" } : /* istanbul ignore next */ {},
|
|
179
|
+
loader: () => loadCountryNames(this.namesSource)
|
|
180
|
+
});
|
|
181
|
+
this.list = computed(() => {
|
|
182
|
+
const names = this.names.hasValue() ? this.names.value().countries : {};
|
|
183
|
+
const only = this.countries();
|
|
184
|
+
const codes = only ? only.filter((code) => allCountries.has(code)) : getCountries();
|
|
185
|
+
const list = new Array();
|
|
186
|
+
for (const code of codes) {
|
|
187
|
+
const name = names[code];
|
|
188
|
+
const all = Array.isArray(name) ? name : name ? [name] : [];
|
|
189
|
+
if (all.length) {
|
|
190
|
+
const callingCode = getCountryCallingCode(code);
|
|
191
|
+
list.push({
|
|
192
|
+
code,
|
|
193
|
+
name: all[0],
|
|
194
|
+
callingCode,
|
|
195
|
+
search: fold(`${all.join(" ")} +${callingCode} ${code}`)
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const collator = new Intl.Collator(this.locale);
|
|
200
|
+
return list.sort((a, b) => collator.compare(a.name, b.name));
|
|
201
|
+
}, ...ngDevMode ? [{ debugName: "list" }] : /* istanbul ignore next */ []);
|
|
202
|
+
this.shown = computed(() => {
|
|
203
|
+
const words = fold(this.query()).split(/\s+/).filter(Boolean);
|
|
204
|
+
return this.list().filter((country) => words.every((word) => country.search.includes(word)));
|
|
205
|
+
}, ...ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []);
|
|
206
|
+
this.countryName = computed(() => {
|
|
207
|
+
const code = this.selectedCountry();
|
|
208
|
+
return code && (this.list().find((country) => country.code === code)?.name ?? code);
|
|
209
|
+
}, ...ngDevMode ? [{ debugName: "countryName" }] : /* istanbul ignore next */ []);
|
|
210
|
+
this.countryLabel = computed(() => {
|
|
211
|
+
const name = this.countryName();
|
|
212
|
+
return name ? this.texts().country(name) : this.texts().noCountry;
|
|
213
|
+
}, ...ngDevMode ? [{ debugName: "countryLabel" }] : /* istanbul ignore next */ []);
|
|
214
|
+
this.example = computed(() => {
|
|
215
|
+
const code = this.selectedCountry();
|
|
216
|
+
return code ? getExampleNumber(code, examples)?.formatNational() ?? "" : "";
|
|
217
|
+
}, ...ngDevMode ? [{ debugName: "example" }] : /* istanbul ignore next */ []);
|
|
218
|
+
this.numberField = viewChild.required("number", ...ngDevMode ? [{ debugName: "numberField" }] : /* istanbul ignore next */ []);
|
|
219
|
+
this.searchField = viewChild.required("search", ...ngDevMode ? [{ debugName: "searchField" }] : /* istanbul ignore next */ []);
|
|
220
|
+
this.value = null;
|
|
221
|
+
this.onChange = () => {};
|
|
222
|
+
this.onTouched = () => {};
|
|
223
|
+
this.onValidatorChange = () => {};
|
|
224
|
+
this.displayCountry = (value) => typeof value === "string" ? value : value?.name ?? "";
|
|
225
|
+
this.validation?.delegateAria();
|
|
226
|
+
effect(() => {
|
|
227
|
+
this.countries();
|
|
228
|
+
untracked(() => this.onValidatorChange());
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
ngOnInit() {
|
|
232
|
+
if (!this.country()) this.pickCountry(localeCountry(this.locale));
|
|
233
|
+
}
|
|
234
|
+
writeValue(value) {
|
|
235
|
+
untracked(() => {
|
|
236
|
+
const text = value ?? "";
|
|
237
|
+
const number = this.parse(text);
|
|
238
|
+
this.pickCountry(number?.country);
|
|
239
|
+
this.text.set(number ? this.display(number) : text);
|
|
240
|
+
this.value = value ?? null;
|
|
241
|
+
this.setParseError(false);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
registerOnChange(fn) {
|
|
245
|
+
this.onChange = fn;
|
|
246
|
+
}
|
|
247
|
+
registerOnTouched(fn) {
|
|
248
|
+
this.onTouched = fn;
|
|
249
|
+
}
|
|
250
|
+
registerOnValidatorChange(fn) {
|
|
251
|
+
this.onValidatorChange = fn;
|
|
252
|
+
}
|
|
253
|
+
setDisabledState(disabled) {
|
|
254
|
+
this.isDisabled.set(disabled);
|
|
255
|
+
}
|
|
256
|
+
validate() {
|
|
257
|
+
const problem = this.parseError() ? "invalid" : checkPhoneNumber(this.value, this.selectedCountry(), this.countries());
|
|
258
|
+
return problem ? { [NB_PHONE_NUMBER_ERROR]: phoneNumberError(this.errorContext, problem) } : null;
|
|
259
|
+
}
|
|
260
|
+
focus() {
|
|
261
|
+
this.numberField().nativeElement.focus();
|
|
262
|
+
}
|
|
263
|
+
pickCountry(code) {
|
|
264
|
+
if (code && code !== this.country()) this.country.set(code);
|
|
265
|
+
}
|
|
266
|
+
flag(code) {
|
|
267
|
+
const key = code?.toLowerCase();
|
|
268
|
+
return (code && flagFallbacks[code]) ?? (key && key in FlagDatabase ? key : "xx");
|
|
269
|
+
}
|
|
270
|
+
typed(event) {
|
|
271
|
+
const text = event.target.value;
|
|
272
|
+
this.text.set(text);
|
|
273
|
+
this.pickCountry(this.parse(text)?.country);
|
|
274
|
+
this.update();
|
|
275
|
+
}
|
|
276
|
+
left() {
|
|
277
|
+
const number = this.parse(this.text());
|
|
278
|
+
if (number) this.text.set(this.display(number));
|
|
279
|
+
this.onTouched();
|
|
280
|
+
}
|
|
281
|
+
pick() {
|
|
282
|
+
if (this.isDisabled() || this.readonly()) return;
|
|
283
|
+
const search = this.searchField().nativeElement;
|
|
284
|
+
search.value = "";
|
|
285
|
+
this.query.set("");
|
|
286
|
+
this.picking.set(true);
|
|
287
|
+
afterNextRender(() => search.focus(), { injector: this.injector });
|
|
288
|
+
}
|
|
289
|
+
searched(event) {
|
|
290
|
+
this.query.set(event.target.value);
|
|
291
|
+
}
|
|
292
|
+
chose(country) {
|
|
293
|
+
if (country && typeof country !== "string") {
|
|
294
|
+
this.country.set(country.code);
|
|
295
|
+
this.update();
|
|
296
|
+
}
|
|
297
|
+
this.stopPicking(true);
|
|
298
|
+
}
|
|
299
|
+
searchEscaped(event) {
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
this.stopPicking(true);
|
|
302
|
+
}
|
|
303
|
+
searchLeft() {
|
|
304
|
+
this.stopPicking(false);
|
|
305
|
+
this.onTouched();
|
|
306
|
+
}
|
|
307
|
+
stopPicking(focus) {
|
|
308
|
+
this.picking.set(false);
|
|
309
|
+
if (focus) afterNextRender(() => this.focus(), { injector: this.injector });
|
|
310
|
+
}
|
|
311
|
+
parse(text) {
|
|
312
|
+
return parsePhoneNumber(text, this.selectedCountry());
|
|
313
|
+
}
|
|
314
|
+
display(number) {
|
|
315
|
+
return number.country ? number.formatNational() : number.formatInternational();
|
|
316
|
+
}
|
|
317
|
+
update() {
|
|
318
|
+
const text = this.text().trim();
|
|
319
|
+
const number = text ? this.parse(text) : void 0;
|
|
320
|
+
this.setParseError(!!text && !number);
|
|
321
|
+
const value = number?.number ?? null;
|
|
322
|
+
if ((!text || number) && value !== this.value) {
|
|
323
|
+
this.value = value;
|
|
324
|
+
this.onChange(value);
|
|
325
|
+
}
|
|
326
|
+
this.onValidatorChange();
|
|
327
|
+
}
|
|
328
|
+
setParseError(parseError) {
|
|
329
|
+
if (parseError !== this.parseError()) {
|
|
330
|
+
this.parseError.set(parseError);
|
|
331
|
+
this.onValidatorChange();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
static {
|
|
335
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
336
|
+
minVersion: "12.0.0",
|
|
337
|
+
version: "22.3.0",
|
|
338
|
+
ngImport: i0,
|
|
339
|
+
type: NbPhoneInputComponent,
|
|
340
|
+
deps: [],
|
|
341
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
static {
|
|
345
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
346
|
+
minVersion: "17.0.0",
|
|
347
|
+
version: "22.3.0",
|
|
348
|
+
type: NbPhoneInputComponent,
|
|
349
|
+
isStandalone: true,
|
|
350
|
+
selector: "nb-phone-input",
|
|
351
|
+
inputs: {
|
|
352
|
+
country: {
|
|
353
|
+
classPropertyName: "country",
|
|
354
|
+
publicName: "country",
|
|
355
|
+
isSignal: true,
|
|
356
|
+
isRequired: false,
|
|
357
|
+
transformFunction: null
|
|
358
|
+
},
|
|
359
|
+
countries: {
|
|
360
|
+
classPropertyName: "countries",
|
|
361
|
+
publicName: "countries",
|
|
362
|
+
isSignal: true,
|
|
363
|
+
isRequired: false,
|
|
364
|
+
transformFunction: null
|
|
365
|
+
},
|
|
366
|
+
sizeInput: {
|
|
367
|
+
classPropertyName: "sizeInput",
|
|
368
|
+
publicName: "size",
|
|
369
|
+
isSignal: true,
|
|
370
|
+
isRequired: false,
|
|
371
|
+
transformFunction: null
|
|
372
|
+
},
|
|
373
|
+
status: {
|
|
374
|
+
classPropertyName: "status",
|
|
375
|
+
publicName: "status",
|
|
376
|
+
isSignal: true,
|
|
377
|
+
isRequired: false,
|
|
378
|
+
transformFunction: null
|
|
379
|
+
},
|
|
380
|
+
shapeInput: {
|
|
381
|
+
classPropertyName: "shapeInput",
|
|
382
|
+
publicName: "shape",
|
|
383
|
+
isSignal: true,
|
|
384
|
+
isRequired: false,
|
|
385
|
+
transformFunction: null
|
|
386
|
+
},
|
|
387
|
+
fullWidth: {
|
|
388
|
+
classPropertyName: "fullWidth",
|
|
389
|
+
publicName: "fullWidth",
|
|
390
|
+
isSignal: true,
|
|
391
|
+
isRequired: false,
|
|
392
|
+
transformFunction: null
|
|
393
|
+
},
|
|
394
|
+
ghost: {
|
|
395
|
+
classPropertyName: "ghost",
|
|
396
|
+
publicName: "ghost",
|
|
397
|
+
isSignal: true,
|
|
398
|
+
isRequired: false,
|
|
399
|
+
transformFunction: null
|
|
400
|
+
},
|
|
401
|
+
disabled: {
|
|
402
|
+
classPropertyName: "disabled",
|
|
403
|
+
publicName: "disabled",
|
|
404
|
+
isSignal: true,
|
|
405
|
+
isRequired: false,
|
|
406
|
+
transformFunction: null
|
|
407
|
+
},
|
|
408
|
+
readonly: {
|
|
409
|
+
classPropertyName: "readonly",
|
|
410
|
+
publicName: "readonly",
|
|
411
|
+
isSignal: true,
|
|
412
|
+
isRequired: false,
|
|
413
|
+
transformFunction: null
|
|
414
|
+
},
|
|
415
|
+
placeholder: {
|
|
416
|
+
classPropertyName: "placeholder",
|
|
417
|
+
publicName: "placeholder",
|
|
418
|
+
isSignal: true,
|
|
419
|
+
isRequired: false,
|
|
420
|
+
transformFunction: null
|
|
421
|
+
},
|
|
422
|
+
overlayOffset: {
|
|
423
|
+
classPropertyName: "overlayOffset",
|
|
424
|
+
publicName: "overlayOffset",
|
|
425
|
+
isSignal: true,
|
|
426
|
+
isRequired: false,
|
|
427
|
+
transformFunction: null
|
|
428
|
+
},
|
|
429
|
+
ariaLabel: {
|
|
430
|
+
classPropertyName: "ariaLabel",
|
|
431
|
+
publicName: "aria-label",
|
|
432
|
+
isSignal: true,
|
|
433
|
+
isRequired: false,
|
|
434
|
+
transformFunction: null
|
|
435
|
+
},
|
|
436
|
+
ariaLabelledBy: {
|
|
437
|
+
classPropertyName: "ariaLabelledBy",
|
|
438
|
+
publicName: "aria-labelledby",
|
|
439
|
+
isSignal: true,
|
|
440
|
+
isRequired: false,
|
|
441
|
+
transformFunction: null
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
outputs: { country: "countryChange" },
|
|
445
|
+
host: {
|
|
446
|
+
properties: { "class.full-width": "fullWidth()" },
|
|
447
|
+
classAttribute: "nb-phone-input"
|
|
448
|
+
},
|
|
449
|
+
providers: [{
|
|
450
|
+
provide: NG_VALUE_ACCESSOR,
|
|
451
|
+
useExisting: forwardRef(() => NbPhoneInputComponent),
|
|
452
|
+
multi: true
|
|
453
|
+
}, {
|
|
454
|
+
provide: NG_VALIDATORS,
|
|
455
|
+
useExisting: forwardRef(() => NbPhoneInputComponent),
|
|
456
|
+
multi: true
|
|
457
|
+
}],
|
|
458
|
+
viewQueries: [{
|
|
459
|
+
propertyName: "numberField",
|
|
460
|
+
first: true,
|
|
461
|
+
predicate: ["number"],
|
|
462
|
+
descendants: true,
|
|
463
|
+
isSignal: true
|
|
464
|
+
}, {
|
|
465
|
+
propertyName: "searchField",
|
|
466
|
+
first: true,
|
|
467
|
+
predicate: ["search"],
|
|
468
|
+
descendants: true,
|
|
469
|
+
isSignal: true
|
|
470
|
+
}],
|
|
471
|
+
ngImport: i0,
|
|
472
|
+
template: "<nb-form-field class=\"nb-phone-input-number\"\n [style.display]=\"picking() ? 'none' : null\">\n <button nbPrefix\n nbButton\n ghost\n type=\"button\"\n class=\"nb-phone-input-country\"\n [size]=\"size()\"\n [status]=\"buttonStatus()\"\n [disabled]=\"isDisabled() || readonly()\"\n [attr.aria-label]=\"countryLabel()\"\n (click)=\"pick()\">\n <nxt-flag [country]=\"flag(selectedCountry())\"\n size=\"s\" />\n <nb-icon icon=\"chevron-down-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n </button>\n <input #number\n nbInput\n type=\"tel\"\n autocomplete=\"tel\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? example()\"\n [attr.aria-label]=\"fieldLabelledBy() ? null : (ariaLabel() ?? texts().number)\"\n [attr.aria-labelledby]=\"fieldLabelledBy()\"\n [attr.aria-required]=\"validation?.ariaRequired()\"\n [attr.aria-invalid]=\"validation?.ariaInvalid()\"\n [attr.aria-describedby]=\"validation?.describedBy()\"\n (input)=\"typed($event)\"\n (blur)=\"left()\" />\n</nb-form-field>\n\n<!-- Stays in the page while it's hidden, so the list it opens still takes a click after it loses focus. -->\n<nb-form-field class=\"nb-phone-input-search\"\n [style.display]=\"picking() ? null : 'none'\">\n <nb-icon nbPrefix\n icon=\"search-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n <input #search\n nbInput\n type=\"text\"\n autocomplete=\"off\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [placeholder]=\"texts().search\"\n [attr.aria-label]=\"texts().search\"\n [nbAutocomplete]=\"countryList\"\n [overlayOffset]=\"overlayOffset()\"\n (input)=\"searched($event)\"\n (keydown.escape)=\"searchEscaped($event)\"\n (blur)=\"searchLeft()\" />\n</nb-form-field>\n\n<nb-autocomplete #countryList\n [size]=\"size()\"\n [handleDisplayFn]=\"displayCountry\"\n (selectedChange)=\"chose($event)\">\n @for (country of shown(); track country.code) {\n <nb-option class=\"nb-phone-input-option\"\n [value]=\"country\">\n <nxt-flag [country]=\"flag(country.code)\"\n size=\"s\" />\n <span class=\"nb-phone-input-name\">{{ country.name }}</span>\n <span class=\"nb-phone-input-calling-code\">+{{ country.callingCode }}</span>\n </nb-option>\n }\n</nb-autocomplete>\n",
|
|
473
|
+
styles: ["nb-phone-input{display:inline-block;vertical-align:middle}nb-phone-input.full-width{display:block}nb-phone-input .nb-phone-input-country{gap:.25rem;margin-inline-end:.25rem}.nb-phone-input-option{display:flex;gap:.5rem;align-items:center}.nb-phone-input-option nxt-flag{flex:none}.nb-phone-input-option .nb-phone-input-name{flex:auto}.nb-phone-input-option .nb-phone-input-calling-code{color:var(--text-hint-color)}\n"],
|
|
474
|
+
dependencies: [
|
|
475
|
+
{
|
|
476
|
+
kind: "component",
|
|
477
|
+
type: NbFormFieldComponent,
|
|
478
|
+
selector: "nb-form-field"
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
kind: "directive",
|
|
482
|
+
type: NbPrefixDirective,
|
|
483
|
+
selector: "[nbPrefix]"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
kind: "component",
|
|
487
|
+
type: NbButtonComponent,
|
|
488
|
+
selector: "button[nbButton],a[nbButton],input[type=\"button\"][nbButton],input[type=\"submit\"][nbButton]",
|
|
489
|
+
inputs: ["hero", "loading"]
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
kind: "component",
|
|
493
|
+
type: NbIconComponent,
|
|
494
|
+
selector: "nb-icon",
|
|
495
|
+
inputs: [
|
|
496
|
+
"icon",
|
|
497
|
+
"pack",
|
|
498
|
+
"options",
|
|
499
|
+
"status",
|
|
500
|
+
"config"
|
|
501
|
+
]
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
kind: "directive",
|
|
505
|
+
type: NbInputDirective,
|
|
506
|
+
selector: "input[nbInput],textarea[nbInput]",
|
|
507
|
+
inputs: [
|
|
508
|
+
"fieldSize",
|
|
509
|
+
"status",
|
|
510
|
+
"shape",
|
|
511
|
+
"fullWidth",
|
|
512
|
+
"ghost"
|
|
513
|
+
]
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
kind: "directive",
|
|
517
|
+
type: NbAutocompleteDirective,
|
|
518
|
+
selector: "input[nbAutocomplete]",
|
|
519
|
+
inputs: [
|
|
520
|
+
"nbAutocomplete",
|
|
521
|
+
"overlayOffset",
|
|
522
|
+
"scrollStrategy",
|
|
523
|
+
"customOverlayHost"
|
|
524
|
+
]
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
kind: "component",
|
|
528
|
+
type: NbAutocompleteComponent,
|
|
529
|
+
selector: "nb-autocomplete",
|
|
530
|
+
inputs: [
|
|
531
|
+
"handleDisplayFn",
|
|
532
|
+
"size",
|
|
533
|
+
"activeFirst",
|
|
534
|
+
"optionsListClass",
|
|
535
|
+
"optionsPanelClass",
|
|
536
|
+
"optionsWidth"
|
|
537
|
+
],
|
|
538
|
+
outputs: ["selectedChange"]
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
kind: "component",
|
|
542
|
+
type: NbOptionComponent,
|
|
543
|
+
selector: "nb-option",
|
|
544
|
+
inputs: [
|
|
545
|
+
"value",
|
|
546
|
+
"disabled",
|
|
547
|
+
"selectAll"
|
|
548
|
+
],
|
|
549
|
+
outputs: ["selectionChange"]
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
kind: "component",
|
|
553
|
+
type: FlagComponent,
|
|
554
|
+
selector: "nxt-flag",
|
|
555
|
+
inputs: [
|
|
556
|
+
"country",
|
|
557
|
+
"label",
|
|
558
|
+
"format",
|
|
559
|
+
"size"
|
|
560
|
+
]
|
|
561
|
+
}
|
|
562
|
+
],
|
|
563
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
564
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
569
|
+
minVersion: "12.0.0",
|
|
570
|
+
version: "22.3.0",
|
|
571
|
+
ngImport: i0,
|
|
572
|
+
type: NbPhoneInputComponent,
|
|
573
|
+
decorators: [{
|
|
574
|
+
type: Component,
|
|
575
|
+
args: [{
|
|
576
|
+
selector: "nb-phone-input",
|
|
577
|
+
encapsulation: ViewEncapsulation.None,
|
|
578
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
579
|
+
imports: [
|
|
580
|
+
NbFormFieldComponent,
|
|
581
|
+
NbPrefixDirective,
|
|
582
|
+
NbButtonComponent,
|
|
583
|
+
NbIconComponent,
|
|
584
|
+
NbInputDirective,
|
|
585
|
+
NbAutocompleteDirective,
|
|
586
|
+
NbAutocompleteComponent,
|
|
587
|
+
NbOptionComponent,
|
|
588
|
+
FlagComponent
|
|
589
|
+
],
|
|
590
|
+
providers: [{
|
|
591
|
+
provide: NG_VALUE_ACCESSOR,
|
|
592
|
+
useExisting: forwardRef(() => NbPhoneInputComponent),
|
|
593
|
+
multi: true
|
|
594
|
+
}, {
|
|
595
|
+
provide: NG_VALIDATORS,
|
|
596
|
+
useExisting: forwardRef(() => NbPhoneInputComponent),
|
|
597
|
+
multi: true
|
|
598
|
+
}],
|
|
599
|
+
host: {
|
|
600
|
+
"class": "nb-phone-input",
|
|
601
|
+
"[class.full-width]": "fullWidth()"
|
|
602
|
+
},
|
|
603
|
+
template: "<nb-form-field class=\"nb-phone-input-number\"\n [style.display]=\"picking() ? 'none' : null\">\n <button nbPrefix\n nbButton\n ghost\n type=\"button\"\n class=\"nb-phone-input-country\"\n [size]=\"size()\"\n [status]=\"buttonStatus()\"\n [disabled]=\"isDisabled() || readonly()\"\n [attr.aria-label]=\"countryLabel()\"\n (click)=\"pick()\">\n <nxt-flag [country]=\"flag(selectedCountry())\"\n size=\"s\" />\n <nb-icon icon=\"chevron-down-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n </button>\n <input #number\n nbInput\n type=\"tel\"\n autocomplete=\"tel\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? example()\"\n [attr.aria-label]=\"fieldLabelledBy() ? null : (ariaLabel() ?? texts().number)\"\n [attr.aria-labelledby]=\"fieldLabelledBy()\"\n [attr.aria-required]=\"validation?.ariaRequired()\"\n [attr.aria-invalid]=\"validation?.ariaInvalid()\"\n [attr.aria-describedby]=\"validation?.describedBy()\"\n (input)=\"typed($event)\"\n (blur)=\"left()\" />\n</nb-form-field>\n\n<!-- Stays in the page while it's hidden, so the list it opens still takes a click after it loses focus. -->\n<nb-form-field class=\"nb-phone-input-search\"\n [style.display]=\"picking() ? null : 'none'\">\n <nb-icon nbPrefix\n icon=\"search-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n <input #search\n nbInput\n type=\"text\"\n autocomplete=\"off\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [placeholder]=\"texts().search\"\n [attr.aria-label]=\"texts().search\"\n [nbAutocomplete]=\"countryList\"\n [overlayOffset]=\"overlayOffset()\"\n (input)=\"searched($event)\"\n (keydown.escape)=\"searchEscaped($event)\"\n (blur)=\"searchLeft()\" />\n</nb-form-field>\n\n<nb-autocomplete #countryList\n [size]=\"size()\"\n [handleDisplayFn]=\"displayCountry\"\n (selectedChange)=\"chose($event)\">\n @for (country of shown(); track country.code) {\n <nb-option class=\"nb-phone-input-option\"\n [value]=\"country\">\n <nxt-flag [country]=\"flag(country.code)\"\n size=\"s\" />\n <span class=\"nb-phone-input-name\">{{ country.name }}</span>\n <span class=\"nb-phone-input-calling-code\">+{{ country.callingCode }}</span>\n </nb-option>\n }\n</nb-autocomplete>\n",
|
|
604
|
+
styles: ["nb-phone-input{display:inline-block;vertical-align:middle}nb-phone-input.full-width{display:block}nb-phone-input .nb-phone-input-country{gap:.25rem;margin-inline-end:.25rem}.nb-phone-input-option{display:flex;gap:.5rem;align-items:center}.nb-phone-input-option nxt-flag{flex:none}.nb-phone-input-option .nb-phone-input-name{flex:auto}.nb-phone-input-option .nb-phone-input-calling-code{color:var(--text-hint-color)}\n"]
|
|
605
|
+
}]
|
|
606
|
+
}],
|
|
607
|
+
ctorParameters: () => [],
|
|
608
|
+
propDecorators: {
|
|
609
|
+
country: [{
|
|
610
|
+
type: i0.Input,
|
|
611
|
+
args: [{
|
|
612
|
+
isSignal: true,
|
|
613
|
+
alias: "country",
|
|
614
|
+
required: false
|
|
615
|
+
}]
|
|
616
|
+
}, {
|
|
617
|
+
type: i0.Output,
|
|
618
|
+
args: ["countryChange"]
|
|
619
|
+
}],
|
|
620
|
+
countries: [{
|
|
621
|
+
type: i0.Input,
|
|
622
|
+
args: [{
|
|
623
|
+
isSignal: true,
|
|
624
|
+
alias: "countries",
|
|
625
|
+
required: false
|
|
626
|
+
}]
|
|
627
|
+
}],
|
|
628
|
+
sizeInput: [{
|
|
629
|
+
type: i0.Input,
|
|
630
|
+
args: [{
|
|
631
|
+
isSignal: true,
|
|
632
|
+
alias: "size",
|
|
633
|
+
required: false
|
|
634
|
+
}]
|
|
635
|
+
}],
|
|
636
|
+
status: [{
|
|
637
|
+
type: i0.Input,
|
|
638
|
+
args: [{
|
|
639
|
+
isSignal: true,
|
|
640
|
+
alias: "status",
|
|
641
|
+
required: false
|
|
642
|
+
}]
|
|
643
|
+
}],
|
|
644
|
+
shapeInput: [{
|
|
645
|
+
type: i0.Input,
|
|
646
|
+
args: [{
|
|
647
|
+
isSignal: true,
|
|
648
|
+
alias: "shape",
|
|
649
|
+
required: false
|
|
650
|
+
}]
|
|
651
|
+
}],
|
|
652
|
+
fullWidth: [{
|
|
653
|
+
type: i0.Input,
|
|
654
|
+
args: [{
|
|
655
|
+
isSignal: true,
|
|
656
|
+
alias: "fullWidth",
|
|
657
|
+
required: false
|
|
658
|
+
}]
|
|
659
|
+
}],
|
|
660
|
+
ghost: [{
|
|
661
|
+
type: i0.Input,
|
|
662
|
+
args: [{
|
|
663
|
+
isSignal: true,
|
|
664
|
+
alias: "ghost",
|
|
665
|
+
required: false
|
|
666
|
+
}]
|
|
667
|
+
}],
|
|
668
|
+
disabled: [{
|
|
669
|
+
type: i0.Input,
|
|
670
|
+
args: [{
|
|
671
|
+
isSignal: true,
|
|
672
|
+
alias: "disabled",
|
|
673
|
+
required: false
|
|
674
|
+
}]
|
|
675
|
+
}],
|
|
676
|
+
readonly: [{
|
|
677
|
+
type: i0.Input,
|
|
678
|
+
args: [{
|
|
679
|
+
isSignal: true,
|
|
680
|
+
alias: "readonly",
|
|
681
|
+
required: false
|
|
682
|
+
}]
|
|
683
|
+
}],
|
|
684
|
+
placeholder: [{
|
|
685
|
+
type: i0.Input,
|
|
686
|
+
args: [{
|
|
687
|
+
isSignal: true,
|
|
688
|
+
alias: "placeholder",
|
|
689
|
+
required: false
|
|
690
|
+
}]
|
|
691
|
+
}],
|
|
692
|
+
overlayOffset: [{
|
|
693
|
+
type: i0.Input,
|
|
694
|
+
args: [{
|
|
695
|
+
isSignal: true,
|
|
696
|
+
alias: "overlayOffset",
|
|
697
|
+
required: false
|
|
698
|
+
}]
|
|
699
|
+
}],
|
|
700
|
+
ariaLabel: [{
|
|
701
|
+
type: i0.Input,
|
|
702
|
+
args: [{
|
|
703
|
+
isSignal: true,
|
|
704
|
+
alias: "aria-label",
|
|
705
|
+
required: false
|
|
706
|
+
}]
|
|
707
|
+
}],
|
|
708
|
+
ariaLabelledBy: [{
|
|
709
|
+
type: i0.Input,
|
|
710
|
+
args: [{
|
|
711
|
+
isSignal: true,
|
|
712
|
+
alias: "aria-labelledby",
|
|
713
|
+
required: false
|
|
714
|
+
}]
|
|
715
|
+
}],
|
|
716
|
+
numberField: [{
|
|
717
|
+
type: i0.ViewChild,
|
|
718
|
+
args: ["number", { isSignal: true }]
|
|
719
|
+
}],
|
|
720
|
+
searchField: [{
|
|
721
|
+
type: i0.ViewChild,
|
|
722
|
+
args: ["search", { isSignal: true }]
|
|
723
|
+
}]
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
var NbPhoneNumberValidatorDirective = class NbPhoneNumberValidatorDirective {
|
|
727
|
+
constructor() {
|
|
728
|
+
this.country = input(void 0, {
|
|
729
|
+
...ngDevMode ? { debugName: "country" } : /* istanbul ignore next */ {},
|
|
730
|
+
alias: "nbPhoneNumberCountry"
|
|
731
|
+
});
|
|
732
|
+
this.countries = input(void 0, {
|
|
733
|
+
...ngDevMode ? { debugName: "countries" } : /* istanbul ignore next */ {},
|
|
734
|
+
alias: "nbPhoneNumberCountries"
|
|
735
|
+
});
|
|
736
|
+
this.message = input(void 0, {
|
|
737
|
+
...ngDevMode ? { debugName: "message" } : /* istanbul ignore next */ {},
|
|
738
|
+
alias: "nbPhoneNumberMessage"
|
|
739
|
+
});
|
|
740
|
+
this.isInput = inject(ElementRef).nativeElement.tagName === "INPUT";
|
|
741
|
+
this.context = phoneNumberContext();
|
|
742
|
+
this.onValidatorChange = () => {};
|
|
743
|
+
effect(() => {
|
|
744
|
+
this.country();
|
|
745
|
+
this.countries();
|
|
746
|
+
this.message();
|
|
747
|
+
this.onValidatorChange();
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
validate(control) {
|
|
751
|
+
const error = validatePhoneNumber(control.value, {
|
|
752
|
+
country: this.country(),
|
|
753
|
+
countries: this.countries(),
|
|
754
|
+
message: this.message()
|
|
755
|
+
}, this.context);
|
|
756
|
+
return error ? { [NB_PHONE_NUMBER_ERROR]: error } : null;
|
|
757
|
+
}
|
|
758
|
+
registerOnValidatorChange(fn) {
|
|
759
|
+
this.onValidatorChange = fn;
|
|
760
|
+
}
|
|
761
|
+
static {
|
|
762
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
763
|
+
minVersion: "12.0.0",
|
|
764
|
+
version: "22.3.0",
|
|
765
|
+
ngImport: i0,
|
|
766
|
+
type: NbPhoneNumberValidatorDirective,
|
|
767
|
+
deps: [],
|
|
768
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
static {
|
|
772
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
773
|
+
minVersion: "17.1.0",
|
|
774
|
+
version: "22.3.0",
|
|
775
|
+
type: NbPhoneNumberValidatorDirective,
|
|
776
|
+
isStandalone: true,
|
|
777
|
+
selector: "[nbPhoneNumber][ngModel],[nbPhoneNumber][formControl],[nbPhoneNumber][formControlName]",
|
|
778
|
+
inputs: {
|
|
779
|
+
country: {
|
|
780
|
+
classPropertyName: "country",
|
|
781
|
+
publicName: "nbPhoneNumberCountry",
|
|
782
|
+
isSignal: true,
|
|
783
|
+
isRequired: false,
|
|
784
|
+
transformFunction: null
|
|
785
|
+
},
|
|
786
|
+
countries: {
|
|
787
|
+
classPropertyName: "countries",
|
|
788
|
+
publicName: "nbPhoneNumberCountries",
|
|
789
|
+
isSignal: true,
|
|
790
|
+
isRequired: false,
|
|
791
|
+
transformFunction: null
|
|
792
|
+
},
|
|
793
|
+
message: {
|
|
794
|
+
classPropertyName: "message",
|
|
795
|
+
publicName: "nbPhoneNumberMessage",
|
|
796
|
+
isSignal: true,
|
|
797
|
+
isRequired: false,
|
|
798
|
+
transformFunction: null
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
host: { properties: {
|
|
802
|
+
"style.text-align": "isInput ? 'left' : null",
|
|
803
|
+
"style.unicode-bidi": "isInput ? 'plaintext' : null"
|
|
804
|
+
} },
|
|
805
|
+
providers: [{
|
|
806
|
+
provide: NG_VALIDATORS,
|
|
807
|
+
useExisting: forwardRef(() => NbPhoneNumberValidatorDirective),
|
|
808
|
+
multi: true
|
|
809
|
+
}],
|
|
810
|
+
ngImport: i0
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
815
|
+
minVersion: "12.0.0",
|
|
816
|
+
version: "22.3.0",
|
|
817
|
+
ngImport: i0,
|
|
818
|
+
type: NbPhoneNumberValidatorDirective,
|
|
819
|
+
decorators: [{
|
|
820
|
+
type: Directive,
|
|
821
|
+
args: [{
|
|
822
|
+
selector: "[nbPhoneNumber][ngModel],[nbPhoneNumber][formControl],[nbPhoneNumber][formControlName]",
|
|
823
|
+
providers: [{
|
|
824
|
+
provide: NG_VALIDATORS,
|
|
825
|
+
useExisting: forwardRef(() => NbPhoneNumberValidatorDirective),
|
|
826
|
+
multi: true
|
|
827
|
+
}],
|
|
828
|
+
host: {
|
|
829
|
+
"[style.text-align]": "isInput ? 'left' : null",
|
|
830
|
+
"[style.unicode-bidi]": "isInput ? 'plaintext' : null"
|
|
831
|
+
}
|
|
832
|
+
}]
|
|
833
|
+
}],
|
|
834
|
+
ctorParameters: () => [],
|
|
835
|
+
propDecorators: {
|
|
836
|
+
country: [{
|
|
837
|
+
type: i0.Input,
|
|
838
|
+
args: [{
|
|
839
|
+
isSignal: true,
|
|
840
|
+
alias: "nbPhoneNumberCountry",
|
|
841
|
+
required: false
|
|
842
|
+
}]
|
|
843
|
+
}],
|
|
844
|
+
countries: [{
|
|
845
|
+
type: i0.Input,
|
|
846
|
+
args: [{
|
|
847
|
+
isSignal: true,
|
|
848
|
+
alias: "nbPhoneNumberCountries",
|
|
849
|
+
required: false
|
|
850
|
+
}]
|
|
851
|
+
}],
|
|
852
|
+
message: [{
|
|
853
|
+
type: i0.Input,
|
|
854
|
+
args: [{
|
|
855
|
+
isSignal: true,
|
|
856
|
+
alias: "nbPhoneNumberMessage",
|
|
857
|
+
required: false
|
|
858
|
+
}]
|
|
859
|
+
}]
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
export { NB_PHONE_NUMBER_ERROR, NbPhoneInputComponent, NbPhoneNumberValidatorDirective, nbPhoneNumber, nbPhoneNumberValidator, provideNbCountryNames };
|
|
863
|
+
|
|
864
|
+
//# sourceMappingURL=liquid-js-lyr-extras-phone-input.mjs.map
|