@liquid-js/lyr-extras 0.0.0-stage → 22.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/LICENSE.txt +23 -0
  2. package/README.md +61 -2
  3. package/fesm2022/liquid-js-lyr-extras-chart.mjs +871 -0
  4. package/fesm2022/liquid-js-lyr-extras-chart.mjs.map +1 -0
  5. package/fesm2022/liquid-js-lyr-extras-color-picker.mjs +819 -0
  6. package/fesm2022/liquid-js-lyr-extras-color-picker.mjs.map +1 -0
  7. package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs +921 -0
  8. package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs.map +1 -0
  9. package/fesm2022/liquid-js-lyr-extras-markdown-viewer.mjs +369 -0
  10. package/fesm2022/liquid-js-lyr-extras-markdown-viewer.mjs.map +1 -0
  11. package/fesm2022/liquid-js-lyr-extras-mask.mjs +238 -0
  12. package/fesm2022/liquid-js-lyr-extras-mask.mjs.map +1 -0
  13. package/fesm2022/liquid-js-lyr-extras-media.mjs +1142 -0
  14. package/fesm2022/liquid-js-lyr-extras-media.mjs.map +1 -0
  15. package/fesm2022/liquid-js-lyr-extras-phone-input.mjs +862 -0
  16. package/fesm2022/liquid-js-lyr-extras-phone-input.mjs.map +1 -0
  17. package/fesm2022/liquid-js-lyr-extras-qr-code.mjs +236 -0
  18. package/fesm2022/liquid-js-lyr-extras-qr-code.mjs.map +1 -0
  19. package/fesm2022/liquid-js-lyr-extras.mjs +0 -0
  20. package/package.json +159 -3
  21. package/types/liquid-js-lyr-extras-chart.d.ts +294 -0
  22. package/types/liquid-js-lyr-extras-color-picker.d.ts +311 -0
  23. package/types/liquid-js-lyr-extras-markdown-editor.d.ts +367 -0
  24. package/types/liquid-js-lyr-extras-markdown-viewer.d.ts +174 -0
  25. package/types/liquid-js-lyr-extras-mask.d.ts +130 -0
  26. package/types/liquid-js-lyr-extras-media.d.ts +517 -0
  27. package/types/liquid-js-lyr-extras-phone-input.d.ts +428 -0
  28. package/types/liquid-js-lyr-extras-qr-code.d.ts +113 -0
  29. package/types/liquid-js-lyr-extras.d.ts +1 -0
@@ -0,0 +1,862 @@
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
+ const text = value ?? "";
236
+ const number = this.parse(text);
237
+ this.pickCountry(number?.country);
238
+ this.text.set(number ? this.display(number) : text);
239
+ this.value = value ?? null;
240
+ this.setParseError(false);
241
+ }
242
+ registerOnChange(fn) {
243
+ this.onChange = fn;
244
+ }
245
+ registerOnTouched(fn) {
246
+ this.onTouched = fn;
247
+ }
248
+ registerOnValidatorChange(fn) {
249
+ this.onValidatorChange = fn;
250
+ }
251
+ setDisabledState(disabled) {
252
+ this.isDisabled.set(disabled);
253
+ }
254
+ validate() {
255
+ const problem = this.parseError() ? "invalid" : checkPhoneNumber(this.value, this.selectedCountry(), this.countries());
256
+ return problem ? { [NB_PHONE_NUMBER_ERROR]: phoneNumberError(this.errorContext, problem) } : null;
257
+ }
258
+ focus() {
259
+ this.numberField().nativeElement.focus();
260
+ }
261
+ pickCountry(code) {
262
+ if (code && code !== this.country()) this.country.set(code);
263
+ }
264
+ flag(code) {
265
+ const key = code?.toLowerCase();
266
+ return (code && flagFallbacks[code]) ?? (key && key in FlagDatabase ? key : "xx");
267
+ }
268
+ typed(event) {
269
+ const text = event.target.value;
270
+ this.text.set(text);
271
+ this.pickCountry(this.parse(text)?.country);
272
+ this.update();
273
+ }
274
+ left() {
275
+ const number = this.parse(this.text());
276
+ if (number) this.text.set(this.display(number));
277
+ this.onTouched();
278
+ }
279
+ pick() {
280
+ if (this.isDisabled() || this.readonly()) return;
281
+ const search = this.searchField().nativeElement;
282
+ search.value = "";
283
+ this.query.set("");
284
+ this.picking.set(true);
285
+ afterNextRender(() => search.focus(), { injector: this.injector });
286
+ }
287
+ searched(event) {
288
+ this.query.set(event.target.value);
289
+ }
290
+ chose(country) {
291
+ if (country && typeof country !== "string") {
292
+ this.country.set(country.code);
293
+ this.update();
294
+ }
295
+ this.stopPicking(true);
296
+ }
297
+ searchEscaped(event) {
298
+ event.preventDefault();
299
+ this.stopPicking(true);
300
+ }
301
+ searchLeft() {
302
+ this.stopPicking(false);
303
+ this.onTouched();
304
+ }
305
+ stopPicking(focus) {
306
+ this.picking.set(false);
307
+ if (focus) afterNextRender(() => this.focus(), { injector: this.injector });
308
+ }
309
+ parse(text) {
310
+ return parsePhoneNumber(text, this.selectedCountry());
311
+ }
312
+ display(number) {
313
+ return number.country ? number.formatNational() : number.formatInternational();
314
+ }
315
+ update() {
316
+ const text = this.text().trim();
317
+ const number = text ? this.parse(text) : void 0;
318
+ this.setParseError(!!text && !number);
319
+ const value = number?.number ?? null;
320
+ if ((!text || number) && value !== this.value) {
321
+ this.value = value;
322
+ this.onChange(value);
323
+ }
324
+ this.onValidatorChange();
325
+ }
326
+ setParseError(parseError) {
327
+ if (parseError !== this.parseError()) {
328
+ this.parseError.set(parseError);
329
+ this.onValidatorChange();
330
+ }
331
+ }
332
+ static {
333
+ this.ɵfac = i0.ɵɵngDeclareFactory({
334
+ minVersion: "12.0.0",
335
+ version: "22.3.0",
336
+ ngImport: i0,
337
+ type: NbPhoneInputComponent,
338
+ deps: [],
339
+ target: i0.ɵɵFactoryTarget.Component
340
+ });
341
+ }
342
+ static {
343
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
344
+ minVersion: "17.0.0",
345
+ version: "22.3.0",
346
+ type: NbPhoneInputComponent,
347
+ isStandalone: true,
348
+ selector: "nb-phone-input",
349
+ inputs: {
350
+ country: {
351
+ classPropertyName: "country",
352
+ publicName: "country",
353
+ isSignal: true,
354
+ isRequired: false,
355
+ transformFunction: null
356
+ },
357
+ countries: {
358
+ classPropertyName: "countries",
359
+ publicName: "countries",
360
+ isSignal: true,
361
+ isRequired: false,
362
+ transformFunction: null
363
+ },
364
+ sizeInput: {
365
+ classPropertyName: "sizeInput",
366
+ publicName: "size",
367
+ isSignal: true,
368
+ isRequired: false,
369
+ transformFunction: null
370
+ },
371
+ status: {
372
+ classPropertyName: "status",
373
+ publicName: "status",
374
+ isSignal: true,
375
+ isRequired: false,
376
+ transformFunction: null
377
+ },
378
+ shapeInput: {
379
+ classPropertyName: "shapeInput",
380
+ publicName: "shape",
381
+ isSignal: true,
382
+ isRequired: false,
383
+ transformFunction: null
384
+ },
385
+ fullWidth: {
386
+ classPropertyName: "fullWidth",
387
+ publicName: "fullWidth",
388
+ isSignal: true,
389
+ isRequired: false,
390
+ transformFunction: null
391
+ },
392
+ ghost: {
393
+ classPropertyName: "ghost",
394
+ publicName: "ghost",
395
+ isSignal: true,
396
+ isRequired: false,
397
+ transformFunction: null
398
+ },
399
+ disabled: {
400
+ classPropertyName: "disabled",
401
+ publicName: "disabled",
402
+ isSignal: true,
403
+ isRequired: false,
404
+ transformFunction: null
405
+ },
406
+ readonly: {
407
+ classPropertyName: "readonly",
408
+ publicName: "readonly",
409
+ isSignal: true,
410
+ isRequired: false,
411
+ transformFunction: null
412
+ },
413
+ placeholder: {
414
+ classPropertyName: "placeholder",
415
+ publicName: "placeholder",
416
+ isSignal: true,
417
+ isRequired: false,
418
+ transformFunction: null
419
+ },
420
+ overlayOffset: {
421
+ classPropertyName: "overlayOffset",
422
+ publicName: "overlayOffset",
423
+ isSignal: true,
424
+ isRequired: false,
425
+ transformFunction: null
426
+ },
427
+ ariaLabel: {
428
+ classPropertyName: "ariaLabel",
429
+ publicName: "aria-label",
430
+ isSignal: true,
431
+ isRequired: false,
432
+ transformFunction: null
433
+ },
434
+ ariaLabelledBy: {
435
+ classPropertyName: "ariaLabelledBy",
436
+ publicName: "aria-labelledby",
437
+ isSignal: true,
438
+ isRequired: false,
439
+ transformFunction: null
440
+ }
441
+ },
442
+ outputs: { country: "countryChange" },
443
+ host: {
444
+ properties: { "class.full-width": "fullWidth()" },
445
+ classAttribute: "nb-phone-input"
446
+ },
447
+ providers: [{
448
+ provide: NG_VALUE_ACCESSOR,
449
+ useExisting: forwardRef(() => NbPhoneInputComponent),
450
+ multi: true
451
+ }, {
452
+ provide: NG_VALIDATORS,
453
+ useExisting: forwardRef(() => NbPhoneInputComponent),
454
+ multi: true
455
+ }],
456
+ viewQueries: [{
457
+ propertyName: "numberField",
458
+ first: true,
459
+ predicate: ["number"],
460
+ descendants: true,
461
+ isSignal: true
462
+ }, {
463
+ propertyName: "searchField",
464
+ first: true,
465
+ predicate: ["search"],
466
+ descendants: true,
467
+ isSignal: true
468
+ }],
469
+ ngImport: i0,
470
+ 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",
471
+ 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"],
472
+ dependencies: [
473
+ {
474
+ kind: "component",
475
+ type: NbFormFieldComponent,
476
+ selector: "nb-form-field"
477
+ },
478
+ {
479
+ kind: "directive",
480
+ type: NbPrefixDirective,
481
+ selector: "[nbPrefix]"
482
+ },
483
+ {
484
+ kind: "component",
485
+ type: NbButtonComponent,
486
+ selector: "button[nbButton],a[nbButton],input[type=\"button\"][nbButton],input[type=\"submit\"][nbButton]",
487
+ inputs: ["hero", "loading"]
488
+ },
489
+ {
490
+ kind: "component",
491
+ type: NbIconComponent,
492
+ selector: "nb-icon",
493
+ inputs: [
494
+ "icon",
495
+ "pack",
496
+ "options",
497
+ "status",
498
+ "config"
499
+ ]
500
+ },
501
+ {
502
+ kind: "directive",
503
+ type: NbInputDirective,
504
+ selector: "input[nbInput],textarea[nbInput]",
505
+ inputs: [
506
+ "fieldSize",
507
+ "status",
508
+ "shape",
509
+ "fullWidth",
510
+ "ghost"
511
+ ]
512
+ },
513
+ {
514
+ kind: "directive",
515
+ type: NbAutocompleteDirective,
516
+ selector: "input[nbAutocomplete]",
517
+ inputs: [
518
+ "nbAutocomplete",
519
+ "overlayOffset",
520
+ "scrollStrategy",
521
+ "customOverlayHost"
522
+ ]
523
+ },
524
+ {
525
+ kind: "component",
526
+ type: NbAutocompleteComponent,
527
+ selector: "nb-autocomplete",
528
+ inputs: [
529
+ "handleDisplayFn",
530
+ "size",
531
+ "activeFirst",
532
+ "optionsListClass",
533
+ "optionsPanelClass",
534
+ "optionsWidth"
535
+ ],
536
+ outputs: ["selectedChange"]
537
+ },
538
+ {
539
+ kind: "component",
540
+ type: NbOptionComponent,
541
+ selector: "nb-option",
542
+ inputs: [
543
+ "value",
544
+ "disabled",
545
+ "selectAll"
546
+ ],
547
+ outputs: ["selectionChange"]
548
+ },
549
+ {
550
+ kind: "component",
551
+ type: FlagComponent,
552
+ selector: "nxt-flag",
553
+ inputs: [
554
+ "country",
555
+ "label",
556
+ "format",
557
+ "size"
558
+ ]
559
+ }
560
+ ],
561
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
562
+ encapsulation: i0.ViewEncapsulation.None
563
+ });
564
+ }
565
+ };
566
+ i0.ɵɵngDeclareClassMetadata({
567
+ minVersion: "12.0.0",
568
+ version: "22.3.0",
569
+ ngImport: i0,
570
+ type: NbPhoneInputComponent,
571
+ decorators: [{
572
+ type: Component,
573
+ args: [{
574
+ selector: "nb-phone-input",
575
+ encapsulation: ViewEncapsulation.None,
576
+ changeDetection: ChangeDetectionStrategy.OnPush,
577
+ imports: [
578
+ NbFormFieldComponent,
579
+ NbPrefixDirective,
580
+ NbButtonComponent,
581
+ NbIconComponent,
582
+ NbInputDirective,
583
+ NbAutocompleteDirective,
584
+ NbAutocompleteComponent,
585
+ NbOptionComponent,
586
+ FlagComponent
587
+ ],
588
+ providers: [{
589
+ provide: NG_VALUE_ACCESSOR,
590
+ useExisting: forwardRef(() => NbPhoneInputComponent),
591
+ multi: true
592
+ }, {
593
+ provide: NG_VALIDATORS,
594
+ useExisting: forwardRef(() => NbPhoneInputComponent),
595
+ multi: true
596
+ }],
597
+ host: {
598
+ "class": "nb-phone-input",
599
+ "[class.full-width]": "fullWidth()"
600
+ },
601
+ 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",
602
+ 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"]
603
+ }]
604
+ }],
605
+ ctorParameters: () => [],
606
+ propDecorators: {
607
+ country: [{
608
+ type: i0.Input,
609
+ args: [{
610
+ isSignal: true,
611
+ alias: "country",
612
+ required: false
613
+ }]
614
+ }, {
615
+ type: i0.Output,
616
+ args: ["countryChange"]
617
+ }],
618
+ countries: [{
619
+ type: i0.Input,
620
+ args: [{
621
+ isSignal: true,
622
+ alias: "countries",
623
+ required: false
624
+ }]
625
+ }],
626
+ sizeInput: [{
627
+ type: i0.Input,
628
+ args: [{
629
+ isSignal: true,
630
+ alias: "size",
631
+ required: false
632
+ }]
633
+ }],
634
+ status: [{
635
+ type: i0.Input,
636
+ args: [{
637
+ isSignal: true,
638
+ alias: "status",
639
+ required: false
640
+ }]
641
+ }],
642
+ shapeInput: [{
643
+ type: i0.Input,
644
+ args: [{
645
+ isSignal: true,
646
+ alias: "shape",
647
+ required: false
648
+ }]
649
+ }],
650
+ fullWidth: [{
651
+ type: i0.Input,
652
+ args: [{
653
+ isSignal: true,
654
+ alias: "fullWidth",
655
+ required: false
656
+ }]
657
+ }],
658
+ ghost: [{
659
+ type: i0.Input,
660
+ args: [{
661
+ isSignal: true,
662
+ alias: "ghost",
663
+ required: false
664
+ }]
665
+ }],
666
+ disabled: [{
667
+ type: i0.Input,
668
+ args: [{
669
+ isSignal: true,
670
+ alias: "disabled",
671
+ required: false
672
+ }]
673
+ }],
674
+ readonly: [{
675
+ type: i0.Input,
676
+ args: [{
677
+ isSignal: true,
678
+ alias: "readonly",
679
+ required: false
680
+ }]
681
+ }],
682
+ placeholder: [{
683
+ type: i0.Input,
684
+ args: [{
685
+ isSignal: true,
686
+ alias: "placeholder",
687
+ required: false
688
+ }]
689
+ }],
690
+ overlayOffset: [{
691
+ type: i0.Input,
692
+ args: [{
693
+ isSignal: true,
694
+ alias: "overlayOffset",
695
+ required: false
696
+ }]
697
+ }],
698
+ ariaLabel: [{
699
+ type: i0.Input,
700
+ args: [{
701
+ isSignal: true,
702
+ alias: "aria-label",
703
+ required: false
704
+ }]
705
+ }],
706
+ ariaLabelledBy: [{
707
+ type: i0.Input,
708
+ args: [{
709
+ isSignal: true,
710
+ alias: "aria-labelledby",
711
+ required: false
712
+ }]
713
+ }],
714
+ numberField: [{
715
+ type: i0.ViewChild,
716
+ args: ["number", { isSignal: true }]
717
+ }],
718
+ searchField: [{
719
+ type: i0.ViewChild,
720
+ args: ["search", { isSignal: true }]
721
+ }]
722
+ }
723
+ });
724
+ var NbPhoneNumberValidatorDirective = class NbPhoneNumberValidatorDirective {
725
+ constructor() {
726
+ this.country = input(void 0, {
727
+ ...ngDevMode ? { debugName: "country" } : /* istanbul ignore next */ {},
728
+ alias: "nbPhoneNumberCountry"
729
+ });
730
+ this.countries = input(void 0, {
731
+ ...ngDevMode ? { debugName: "countries" } : /* istanbul ignore next */ {},
732
+ alias: "nbPhoneNumberCountries"
733
+ });
734
+ this.message = input(void 0, {
735
+ ...ngDevMode ? { debugName: "message" } : /* istanbul ignore next */ {},
736
+ alias: "nbPhoneNumberMessage"
737
+ });
738
+ this.isInput = inject(ElementRef).nativeElement.tagName === "INPUT";
739
+ this.context = phoneNumberContext();
740
+ this.onValidatorChange = () => {};
741
+ effect(() => {
742
+ this.country();
743
+ this.countries();
744
+ this.message();
745
+ this.onValidatorChange();
746
+ });
747
+ }
748
+ validate(control) {
749
+ const error = validatePhoneNumber(control.value, {
750
+ country: this.country(),
751
+ countries: this.countries(),
752
+ message: this.message()
753
+ }, this.context);
754
+ return error ? { [NB_PHONE_NUMBER_ERROR]: error } : null;
755
+ }
756
+ registerOnValidatorChange(fn) {
757
+ this.onValidatorChange = fn;
758
+ }
759
+ static {
760
+ this.ɵfac = i0.ɵɵngDeclareFactory({
761
+ minVersion: "12.0.0",
762
+ version: "22.3.0",
763
+ ngImport: i0,
764
+ type: NbPhoneNumberValidatorDirective,
765
+ deps: [],
766
+ target: i0.ɵɵFactoryTarget.Directive
767
+ });
768
+ }
769
+ static {
770
+ this.ɵdir = i0.ɵɵngDeclareDirective({
771
+ minVersion: "17.1.0",
772
+ version: "22.3.0",
773
+ type: NbPhoneNumberValidatorDirective,
774
+ isStandalone: true,
775
+ selector: "[nbPhoneNumber][ngModel],[nbPhoneNumber][formControl],[nbPhoneNumber][formControlName]",
776
+ inputs: {
777
+ country: {
778
+ classPropertyName: "country",
779
+ publicName: "nbPhoneNumberCountry",
780
+ isSignal: true,
781
+ isRequired: false,
782
+ transformFunction: null
783
+ },
784
+ countries: {
785
+ classPropertyName: "countries",
786
+ publicName: "nbPhoneNumberCountries",
787
+ isSignal: true,
788
+ isRequired: false,
789
+ transformFunction: null
790
+ },
791
+ message: {
792
+ classPropertyName: "message",
793
+ publicName: "nbPhoneNumberMessage",
794
+ isSignal: true,
795
+ isRequired: false,
796
+ transformFunction: null
797
+ }
798
+ },
799
+ host: { properties: {
800
+ "style.text-align": "isInput ? 'left' : null",
801
+ "style.unicode-bidi": "isInput ? 'plaintext' : null"
802
+ } },
803
+ providers: [{
804
+ provide: NG_VALIDATORS,
805
+ useExisting: forwardRef(() => NbPhoneNumberValidatorDirective),
806
+ multi: true
807
+ }],
808
+ ngImport: i0
809
+ });
810
+ }
811
+ };
812
+ i0.ɵɵngDeclareClassMetadata({
813
+ minVersion: "12.0.0",
814
+ version: "22.3.0",
815
+ ngImport: i0,
816
+ type: NbPhoneNumberValidatorDirective,
817
+ decorators: [{
818
+ type: Directive,
819
+ args: [{
820
+ selector: "[nbPhoneNumber][ngModel],[nbPhoneNumber][formControl],[nbPhoneNumber][formControlName]",
821
+ providers: [{
822
+ provide: NG_VALIDATORS,
823
+ useExisting: forwardRef(() => NbPhoneNumberValidatorDirective),
824
+ multi: true
825
+ }],
826
+ host: {
827
+ "[style.text-align]": "isInput ? 'left' : null",
828
+ "[style.unicode-bidi]": "isInput ? 'plaintext' : null"
829
+ }
830
+ }]
831
+ }],
832
+ ctorParameters: () => [],
833
+ propDecorators: {
834
+ country: [{
835
+ type: i0.Input,
836
+ args: [{
837
+ isSignal: true,
838
+ alias: "nbPhoneNumberCountry",
839
+ required: false
840
+ }]
841
+ }],
842
+ countries: [{
843
+ type: i0.Input,
844
+ args: [{
845
+ isSignal: true,
846
+ alias: "nbPhoneNumberCountries",
847
+ required: false
848
+ }]
849
+ }],
850
+ message: [{
851
+ type: i0.Input,
852
+ args: [{
853
+ isSignal: true,
854
+ alias: "nbPhoneNumberMessage",
855
+ required: false
856
+ }]
857
+ }]
858
+ }
859
+ });
860
+ export { NB_PHONE_NUMBER_ERROR, NbPhoneInputComponent, NbPhoneNumberValidatorDirective, nbPhoneNumber, nbPhoneNumberValidator, provideNbCountryNames };
861
+
862
+ //# sourceMappingURL=liquid-js-lyr-extras-phone-input.mjs.map