@mintplayer/ng-bootstrap 22.11.0 → 22.13.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.
- package/fesm2022/mintplayer-ng-bootstrap-input-group.mjs +25 -4
- package/fesm2022/mintplayer-ng-bootstrap-input-group.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-bootstrap-phone-input.mjs +126 -0
- package/fesm2022/mintplayer-ng-bootstrap-phone-input.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-bootstrap-select.mjs +18 -2
- package/fesm2022/mintplayer-ng-bootstrap-select.mjs.map +1 -1
- package/package.json +5 -1
- package/phone-input/package.json +4 -0
- package/types/mintplayer-ng-bootstrap-input-group.d.ts +20 -3
- package/types/mintplayer-ng-bootstrap-phone-input.d.ts +60 -0
- package/types/mintplayer-ng-bootstrap-select.d.ts +14 -2
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { input, computed, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { BsForwardAriaDirective } from '@mintplayer/ng-bootstrap/a11y';
|
|
4
|
+
import '@mintplayer/web-components/input-group';
|
|
3
5
|
|
|
6
|
+
/**
|
|
7
|
+
* `<bs-input-group>` — joins its children into one visually continuous control.
|
|
8
|
+
*
|
|
9
|
+
* Now a wrapper over `<mp-input-group>`. The previous version was a
|
|
10
|
+
* `<div class="input-group">` plus a `::ng-deep` import of Bootstrap's module,
|
|
11
|
+
* which could not style a `<bs-select>`: the rules Bootstrap keys on
|
|
12
|
+
* `.input-group > .form-select` cannot reach inside that component's shadow root,
|
|
13
|
+
* so a select in a group got neither the flex sizing nor collapsed inner corners.
|
|
14
|
+
* The WC solves it with two channels (see `input-group.styles.scss`), which is why
|
|
15
|
+
* the styling moved there rather than being duplicated here.
|
|
16
|
+
*/
|
|
4
17
|
class BsInputGroupComponent {
|
|
18
|
+
constructor() {
|
|
19
|
+
/** Bootstrap sizing, applied to light-DOM and `mp-*` children alike. */
|
|
20
|
+
this.size = input('md', /* @ts-ignore */
|
|
21
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
22
|
+
/** `md` is the absence of a size in Bootstrap, so it is not written at all. */
|
|
23
|
+
this.sizeAttr = computed(() => (this.size() === 'md' ? null : this.size()), /* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [{ debugName: "sizeAttr" }] : /* istanbul ignore next */ []));
|
|
25
|
+
}
|
|
5
26
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: BsInputGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
27
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.0", type: BsInputGroupComponent, isStandalone: true, selector: "bs-input-group", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<mp-input-group bsForwardAria [attr.size]=\"sizeAttr()\">\n <ng-content></ng-content>\n</mp-input-group>\n", dependencies: [{ kind: "directive", type: BsForwardAriaDirective, selector: "[bsForwardAria]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
7
28
|
}
|
|
8
29
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: BsInputGroupComponent, decorators: [{
|
|
9
30
|
type: Component,
|
|
10
|
-
args: [{ selector: 'bs-input-group', changeDetection: ChangeDetectionStrategy.OnPush, template: "<
|
|
11
|
-
}] });
|
|
31
|
+
args: [{ selector: 'bs-input-group', imports: [BsForwardAriaDirective], changeDetection: ChangeDetectionStrategy.OnPush, schemas: [CUSTOM_ELEMENTS_SCHEMA], template: "<mp-input-group bsForwardAria [attr.size]=\"sizeAttr()\">\n <ng-content></ng-content>\n</mp-input-group>\n" }]
|
|
32
|
+
}], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }] } });
|
|
12
33
|
|
|
13
34
|
/**
|
|
14
35
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintplayer-ng-bootstrap-input-group.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/input-group/src/input-group/input-group.component.ts","../../../../libs/mintplayer-ng-bootstrap/input-group/src/input-group/input-group.component.html","../../../../libs/mintplayer-ng-bootstrap/input-group/mintplayer-ng-bootstrap-input-group.ts"],"sourcesContent":["import { Component,
|
|
1
|
+
{"version":3,"file":"mintplayer-ng-bootstrap-input-group.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/input-group/src/input-group/input-group.component.ts","../../../../libs/mintplayer-ng-bootstrap/input-group/src/input-group/input-group.component.html","../../../../libs/mintplayer-ng-bootstrap/input-group/mintplayer-ng-bootstrap-input-group.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, computed, input } from '@angular/core';\nimport { BsForwardAriaDirective } from '@mintplayer/ng-bootstrap/a11y';\n\n// Side-effect import: registers <mp-input-group>.\nimport '@mintplayer/web-components/input-group';\n\nexport type BsInputGroupSize = 'sm' | 'md' | 'lg';\n\n/**\n * `<bs-input-group>` — joins its children into one visually continuous control.\n *\n * Now a wrapper over `<mp-input-group>`. The previous version was a\n * `<div class=\"input-group\">` plus a `::ng-deep` import of Bootstrap's module,\n * which could not style a `<bs-select>`: the rules Bootstrap keys on\n * `.input-group > .form-select` cannot reach inside that component's shadow root,\n * so a select in a group got neither the flex sizing nor collapsed inner corners.\n * The WC solves it with two channels (see `input-group.styles.scss`), which is why\n * the styling moved there rather than being duplicated here.\n */\n@Component({\n selector: 'bs-input-group',\n templateUrl: './input-group.component.html',\n imports: [BsForwardAriaDirective],\n changeDetection: ChangeDetectionStrategy.OnPush,\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n})\nexport class BsInputGroupComponent {\n /** Bootstrap sizing, applied to light-DOM and `mp-*` children alike. */\n readonly size = input<BsInputGroupSize>('md');\n\n /** `md` is the absence of a size in Bootstrap, so it is not written at all. */\n protected readonly sizeAttr = computed(() => (this.size() === 'md' ? null : this.size()));\n}\n","<mp-input-group bsForwardAria [attr.size]=\"sizeAttr()\">\n <ng-content></ng-content>\n</mp-input-group>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAQA;;;;;;;;;;AAUG;MAQU,qBAAqB,CAAA;AAPlC,IAAA,WAAA,GAAA;;QASW,IAAA,CAAA,IAAI,GAAG,KAAK,CAAmB,IAAI;iFAAC;;QAG1B,IAAA,CAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;qFAAC;AAC1F,IAAA;8GANY,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAArB,qBAAqB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,gBAAA,EAAA,MAAA,EAAA,EAAA,IAAA,EAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EC1BlC,+GAGA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDmBY,sBAAsB,EAAA,QAAA,EAAA,iBAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FAIrB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAPjC,SAAS;+BACE,gBAAgB,EAAA,OAAA,EAEjB,CAAC,sBAAsB,CAAC,EAAA,eAAA,EAChB,uBAAuB,CAAC,MAAM,EAAA,OAAA,EACtC,CAAC,sBAAsB,CAAC,EAAA,QAAA,EAAA,+GAAA,EAAA;;;AExBnC;;AAEG;;;;"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, DestroyRef, viewChild, input, output, computed, effect, forwardRef, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import * as i1 from '@mintplayer/ng-bootstrap/a11y';
|
|
5
|
+
import { BsForwardAriaDirective, BsControlValidityDirective } from '@mintplayer/ng-bootstrap/a11y';
|
|
6
|
+
import '@mintplayer/web-components/phone-input';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `<bs-phone-input>` — a phone-number form control: country picker with flags,
|
|
10
|
+
* a dial code that cannot be edited away, and as-you-type formatting.
|
|
11
|
+
*
|
|
12
|
+
* The control value is **E.164** (`'+32470123456'`), or `null` while empty, so a
|
|
13
|
+
* form posts one canonical string. `(phoneChange)` carries the decomposed parts
|
|
14
|
+
* for consumers that need them — note `valid` is `undefined` until the selected
|
|
15
|
+
* country's validation rules have loaded, which is deliberate rather than
|
|
16
|
+
* optimistic.
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <bs-form>
|
|
20
|
+
* <bs-phone-input [(ngModel)]="phone" default-country="be"
|
|
21
|
+
* [errorMessages]="{ required: 'Enter a phone number.' }" />
|
|
22
|
+
* </bs-form>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
class BsPhoneInputComponent {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.destroyRef = inject(DestroyRef);
|
|
28
|
+
this.onChange = () => undefined;
|
|
29
|
+
this.onTouched = () => undefined;
|
|
30
|
+
/** Set by `setDisabledState` before the view exists, applied by the effect. */
|
|
31
|
+
this.disabledByForm = false;
|
|
32
|
+
this.phoneInput = viewChild.required('phoneInput');
|
|
33
|
+
/** ISO 3166-1 alpha-2, lowercase. Two-way via `(countryChange)`. */
|
|
34
|
+
this.country = input(null, /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "country" }] : /* istanbul ignore next */ []));
|
|
36
|
+
/** Country to start on when the value is empty. */
|
|
37
|
+
this.defaultCountry = input(null, /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "defaultCountry" }] : /* istanbul ignore next */ []));
|
|
39
|
+
/** BCP-47 tag for country names and their ordering. Omitted = browser locale. */
|
|
40
|
+
this.locale = input(null, /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
42
|
+
this.preferredCountries = input(null, /* @ts-ignore */
|
|
43
|
+
...(ngDevMode ? [{ debugName: "preferredCountries" }] : /* istanbul ignore next */ []));
|
|
44
|
+
this.allowedCountries = input(null, /* @ts-ignore */
|
|
45
|
+
...(ngDevMode ? [{ debugName: "allowedCountries" }] : /* istanbul ignore next */ []));
|
|
46
|
+
this.placeholder = input(null, /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
48
|
+
this.autocomplete = input('tel-national', /* @ts-ignore */
|
|
49
|
+
...(ngDevMode ? [{ debugName: "autocomplete" }] : /* istanbul ignore next */ []));
|
|
50
|
+
/** Accessible name of the number field. */
|
|
51
|
+
this.inputLabel = input(null, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "inputLabel" }] : /* istanbul ignore next */ []));
|
|
53
|
+
/** Accessible name of the country picker. */
|
|
54
|
+
this.countryLabel = input(null, /* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [{ debugName: "countryLabel" }] : /* istanbul ignore next */ []));
|
|
56
|
+
this.countryChange = output();
|
|
57
|
+
/** The full detail: E.164 value plus country, dial code, digits and validity. */
|
|
58
|
+
this.phoneChange = output();
|
|
59
|
+
this.preferredAttr = computed(() => this.preferredCountries()?.join(',') ?? null, /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "preferredAttr" }] : /* istanbul ignore next */ []));
|
|
61
|
+
this.allowedAttr = computed(() => this.allowedCountries()?.join(',') ?? null, /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "allowedAttr" }] : /* istanbul ignore next */ []));
|
|
63
|
+
effect(() => {
|
|
64
|
+
const el = this.phoneInput()?.nativeElement;
|
|
65
|
+
if (el)
|
|
66
|
+
el.disabled = this.disabledByForm;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
writeValue(value) {
|
|
70
|
+
const el = this.phoneInput()?.nativeElement;
|
|
71
|
+
// The WC decomposes E.164 into country + national digits itself, so the
|
|
72
|
+
// accessor never has to parse — and a value arriving before the view exists
|
|
73
|
+
// is applied by the same assignment once it does.
|
|
74
|
+
if (el)
|
|
75
|
+
el.value = value ?? null;
|
|
76
|
+
}
|
|
77
|
+
registerOnChange(fn) {
|
|
78
|
+
this.onChange = fn;
|
|
79
|
+
}
|
|
80
|
+
registerOnTouched(fn) {
|
|
81
|
+
this.onTouched = fn;
|
|
82
|
+
}
|
|
83
|
+
setDisabledState(isDisabled) {
|
|
84
|
+
this.disabledByForm = isDisabled;
|
|
85
|
+
const el = this.phoneInput()?.nativeElement;
|
|
86
|
+
if (el)
|
|
87
|
+
el.disabled = isDisabled;
|
|
88
|
+
}
|
|
89
|
+
onValueChange(ev) {
|
|
90
|
+
const detail = ev.detail;
|
|
91
|
+
if (this.destroyRef.destroyed)
|
|
92
|
+
return;
|
|
93
|
+
this.onChange(detail.value);
|
|
94
|
+
this.phoneChange.emit(detail);
|
|
95
|
+
}
|
|
96
|
+
onCountryChange(ev) {
|
|
97
|
+
const detail = ev.detail;
|
|
98
|
+
if (this.destroyRef.destroyed)
|
|
99
|
+
return;
|
|
100
|
+
// A country change is a user interaction with the control, and the number is
|
|
101
|
+
// usually still empty at that point — without this the field can never be
|
|
102
|
+
// touched, so a `required` error would never surface.
|
|
103
|
+
this.onTouched();
|
|
104
|
+
this.countryChange.emit(detail.country);
|
|
105
|
+
}
|
|
106
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: BsPhoneInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
107
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.0", type: BsPhoneInputComponent, isStandalone: true, selector: "bs-phone-input", inputs: { country: { classPropertyName: "country", publicName: "country", isSignal: true, isRequired: false, transformFunction: null }, defaultCountry: { classPropertyName: "defaultCountry", publicName: "defaultCountry", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, preferredCountries: { classPropertyName: "preferredCountries", publicName: "preferredCountries", isSignal: true, isRequired: false, transformFunction: null }, allowedCountries: { classPropertyName: "allowedCountries", publicName: "allowedCountries", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, inputLabel: { classPropertyName: "inputLabel", publicName: "inputLabel", isSignal: true, isRequired: false, transformFunction: null }, countryLabel: { classPropertyName: "countryLabel", publicName: "countryLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { countryChange: "countryChange", phoneChange: "phoneChange" }, providers: [
|
|
108
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BsPhoneInputComponent), multi: true },
|
|
109
|
+
], viewQueries: [{ propertyName: "phoneInput", first: true, predicate: ["phoneInput"], descendants: true, isSignal: true }], hostDirectives: [{ directive: i1.BsControlValidityDirective, inputs: ["errorMessages", "errorMessages"] }], ngImport: i0, template: "<mp-phone-input\n bsForwardAria\n #phoneInput\n [attr.country]=\"country()\"\n [attr.default-country]=\"defaultCountry()\"\n [attr.locale]=\"locale()\"\n [attr.preferred-countries]=\"preferredAttr()\"\n [attr.allowed-countries]=\"allowedAttr()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.autocomplete]=\"autocomplete()\"\n [attr.input-label]=\"inputLabel()\"\n [attr.country-label]=\"countryLabel()\"\n (value-change)=\"onValueChange($event)\"\n (country-change)=\"onCountryChange($event)\">\n</mp-phone-input>\n", dependencies: [{ kind: "directive", type: BsForwardAriaDirective, selector: "[bsForwardAria]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
110
|
+
}
|
|
111
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: BsPhoneInputComponent, decorators: [{
|
|
112
|
+
type: Component,
|
|
113
|
+
args: [{ selector: 'bs-phone-input', imports: [BsForwardAriaDirective], changeDetection: ChangeDetectionStrategy.OnPush, schemas: [CUSTOM_ELEMENTS_SCHEMA], providers: [
|
|
114
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BsPhoneInputComponent), multi: true },
|
|
115
|
+
], hostDirectives: [{
|
|
116
|
+
directive: BsControlValidityDirective,
|
|
117
|
+
inputs: ['errorMessages'],
|
|
118
|
+
}], template: "<mp-phone-input\n bsForwardAria\n #phoneInput\n [attr.country]=\"country()\"\n [attr.default-country]=\"defaultCountry()\"\n [attr.locale]=\"locale()\"\n [attr.preferred-countries]=\"preferredAttr()\"\n [attr.allowed-countries]=\"allowedAttr()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.autocomplete]=\"autocomplete()\"\n [attr.input-label]=\"inputLabel()\"\n [attr.country-label]=\"countryLabel()\"\n (value-change)=\"onValueChange($event)\"\n (country-change)=\"onCountryChange($event)\">\n</mp-phone-input>\n" }]
|
|
119
|
+
}], ctorParameters: () => [], propDecorators: { phoneInput: [{ type: i0.ViewChild, args: ['phoneInput', { isSignal: true }] }], country: [{ type: i0.Input, args: [{ isSignal: true, alias: "country", required: false }] }], defaultCountry: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultCountry", required: false }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: false }] }], preferredCountries: [{ type: i0.Input, args: [{ isSignal: true, alias: "preferredCountries", required: false }] }], allowedCountries: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowedCountries", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], inputLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputLabel", required: false }] }], countryLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "countryLabel", required: false }] }], countryChange: [{ type: i0.Output, args: ["countryChange"] }], phoneChange: [{ type: i0.Output, args: ["phoneChange"] }] } });
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Generated bundle index. Do not edit.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
export { BsPhoneInputComponent };
|
|
126
|
+
//# sourceMappingURL=mintplayer-ng-bootstrap-phone-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mintplayer-ng-bootstrap-phone-input.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/phone-input/src/component/phone-input.component.ts","../../../../libs/mintplayer-ng-bootstrap/phone-input/src/component/phone-input.component.html","../../../../libs/mintplayer-ng-bootstrap/phone-input/mintplayer-ng-bootstrap-phone-input.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n CUSTOM_ELEMENTS_SCHEMA,\n DestroyRef,\n ElementRef,\n computed,\n effect,\n forwardRef,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { BsControlValidityDirective, BsForwardAriaDirective } from '@mintplayer/ng-bootstrap/a11y';\nimport type {\n CountryChangeEventDetail,\n MpPhoneInput,\n PhoneChangeEventDetail,\n} from '@mintplayer/web-components/phone-input';\n\n// Side-effect import: registers <mp-phone-input> (and, transitively, the\n// <mp-input-group> and <mp-select> it composes).\nimport '@mintplayer/web-components/phone-input';\n\n/**\n * `<bs-phone-input>` — a phone-number form control: country picker with flags,\n * a dial code that cannot be edited away, and as-you-type formatting.\n *\n * The control value is **E.164** (`'+32470123456'`), or `null` while empty, so a\n * form posts one canonical string. `(phoneChange)` carries the decomposed parts\n * for consumers that need them — note `valid` is `undefined` until the selected\n * country's validation rules have loaded, which is deliberate rather than\n * optimistic.\n *\n * ```html\n * <bs-form>\n * <bs-phone-input [(ngModel)]=\"phone\" default-country=\"be\"\n * [errorMessages]=\"{ required: 'Enter a phone number.' }\" />\n * </bs-form>\n * ```\n */\n@Component({\n selector: 'bs-phone-input',\n templateUrl: './phone-input.component.html',\n imports: [BsForwardAriaDirective],\n changeDetection: ChangeDetectionStrategy.OnPush,\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BsPhoneInputComponent), multi: true },\n ],\n hostDirectives: [{\n directive: BsControlValidityDirective,\n inputs: ['errorMessages'],\n }],\n})\nexport class BsPhoneInputComponent implements ControlValueAccessor {\n private readonly destroyRef = inject(DestroyRef);\n private onChange: (value: string | null) => void = () => undefined;\n private onTouched: () => void = () => undefined;\n /** Set by `setDisabledState` before the view exists, applied by the effect. */\n private disabledByForm = false;\n\n private readonly phoneInput = viewChild.required<ElementRef<MpPhoneInput>>('phoneInput');\n\n /** ISO 3166-1 alpha-2, lowercase. Two-way via `(countryChange)`. */\n readonly country = input<string | null>(null);\n /** Country to start on when the value is empty. */\n readonly defaultCountry = input<string | null>(null);\n /** BCP-47 tag for country names and their ordering. Omitted = browser locale. */\n readonly locale = input<string | null>(null);\n readonly preferredCountries = input<readonly string[] | null>(null);\n readonly allowedCountries = input<readonly string[] | null>(null);\n readonly placeholder = input<string | null>(null);\n readonly autocomplete = input<string>('tel-national');\n /** Accessible name of the number field. */\n readonly inputLabel = input<string | null>(null);\n /** Accessible name of the country picker. */\n readonly countryLabel = input<string | null>(null);\n\n readonly countryChange = output<string>();\n /** The full detail: E.164 value plus country, dial code, digits and validity. */\n readonly phoneChange = output<PhoneChangeEventDetail>();\n\n protected readonly preferredAttr = computed(() => this.preferredCountries()?.join(',') ?? null);\n protected readonly allowedAttr = computed(() => this.allowedCountries()?.join(',') ?? null);\n\n constructor() {\n effect(() => {\n const el = this.phoneInput()?.nativeElement;\n if (el) el.disabled = this.disabledByForm;\n });\n }\n\n writeValue(value: string | null): void {\n const el = this.phoneInput()?.nativeElement;\n // The WC decomposes E.164 into country + national digits itself, so the\n // accessor never has to parse — and a value arriving before the view exists\n // is applied by the same assignment once it does.\n if (el) el.value = value ?? null;\n }\n\n registerOnChange(fn: (value: string | null) => void): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.disabledByForm = isDisabled;\n const el = this.phoneInput()?.nativeElement;\n if (el) el.disabled = isDisabled;\n }\n\n protected onValueChange(ev: Event): void {\n const detail = (ev as CustomEvent<PhoneChangeEventDetail>).detail;\n if (this.destroyRef.destroyed) return;\n this.onChange(detail.value);\n this.phoneChange.emit(detail);\n }\n\n protected onCountryChange(ev: Event): void {\n const detail = (ev as CustomEvent<CountryChangeEventDetail>).detail;\n if (this.destroyRef.destroyed) return;\n // A country change is a user interaction with the control, and the number is\n // usually still empty at that point — without this the field can never be\n // touched, so a `required` error would never surface.\n this.onTouched();\n this.countryChange.emit(detail.country);\n }\n}\n","<mp-phone-input\n bsForwardAria\n #phoneInput\n [attr.country]=\"country()\"\n [attr.default-country]=\"defaultCountry()\"\n [attr.locale]=\"locale()\"\n [attr.preferred-countries]=\"preferredAttr()\"\n [attr.allowed-countries]=\"allowedAttr()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.autocomplete]=\"autocomplete()\"\n [attr.input-label]=\"inputLabel()\"\n [attr.country-label]=\"countryLabel()\"\n (value-change)=\"onValueChange($event)\"\n (country-change)=\"onCountryChange($event)\">\n</mp-phone-input>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AA0BA;;;;;;;;;;;;;;;;AAgBG;MAeU,qBAAqB,CAAA;AA+BhC,IAAA,WAAA,GAAA;AA9BiB,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AACxC,QAAA,IAAA,CAAA,QAAQ,GAAmC,MAAM,SAAS;AAC1D,QAAA,IAAA,CAAA,SAAS,GAAe,MAAM,SAAS;;QAEvC,IAAA,CAAA,cAAc,GAAG,KAAK;AAEb,QAAA,IAAA,CAAA,UAAU,GAAG,SAAS,CAAC,QAAQ,CAA2B,YAAY,CAAC;;QAG/E,IAAA,CAAA,OAAO,GAAG,KAAK,CAAgB,IAAI;oFAAC;;QAEpC,IAAA,CAAA,cAAc,GAAG,KAAK,CAAgB,IAAI;2FAAC;;QAE3C,IAAA,CAAA,MAAM,GAAG,KAAK,CAAgB,IAAI;mFAAC;QACnC,IAAA,CAAA,kBAAkB,GAAG,KAAK,CAA2B,IAAI;+FAAC;QAC1D,IAAA,CAAA,gBAAgB,GAAG,KAAK,CAA2B,IAAI;6FAAC;QACxD,IAAA,CAAA,WAAW,GAAG,KAAK,CAAgB,IAAI;wFAAC;QACxC,IAAA,CAAA,YAAY,GAAG,KAAK,CAAS,cAAc;yFAAC;;QAE5C,IAAA,CAAA,UAAU,GAAG,KAAK,CAAgB,IAAI;uFAAC;;QAEvC,IAAA,CAAA,YAAY,GAAG,KAAK,CAAgB,IAAI;yFA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AAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,aAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,eAAA,CAAA,EAAA,CAAA,EAAA,WAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,aAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEhEzF;;AAEG;;;;"}
|
|
@@ -61,8 +61,20 @@ class BsSelectValueAccessor {
|
|
|
61
61
|
}
|
|
62
62
|
return `${id}: ${value}`.slice(0, 50);
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The id half of a `"<id>: <value>"` string, or null when there is no string
|
|
66
|
+
* to read.
|
|
67
|
+
*
|
|
68
|
+
* Null is a real case, not defensive padding: `<option value="">` is the
|
|
69
|
+
* idiomatic way to write a placeholder ("— none —", "Browser locale"), and
|
|
70
|
+
* `mp-select` normalizes an empty selection to `null` on its host. The host is
|
|
71
|
+
* what `hostOnChange` reads, because `mp-select` re-dispatches a composed
|
|
72
|
+
* `change` whose target is the element rather than the inner `<select>`. So
|
|
73
|
+
* selecting a placeholder threw `can't access property "split", valueString is
|
|
74
|
+
* null` and the model never updated — the control looked frozen on that option.
|
|
75
|
+
*/
|
|
64
76
|
extractId(valueString) {
|
|
65
|
-
return valueString.split(':')[0];
|
|
77
|
+
return valueString == null ? null : valueString.split(':')[0];
|
|
66
78
|
}
|
|
67
79
|
writeValue(value) {
|
|
68
80
|
this.value = value;
|
|
@@ -85,7 +97,11 @@ class BsSelectValueAccessor {
|
|
|
85
97
|
}
|
|
86
98
|
getOptionValue(valueString) {
|
|
87
99
|
const id = this.extractId(valueString);
|
|
88
|
-
|
|
100
|
+
// Options declared with a plain `value` attribute are never registered in
|
|
101
|
+
// optionMap — only `[ngValue]` registers — so falling through to the raw
|
|
102
|
+
// string is the normal path for them, and passing null through is how a
|
|
103
|
+
// placeholder selection reaches the model as "nothing chosen".
|
|
104
|
+
return id !== null && this.optionMap.has(id) ? this.optionMap.get(id) : valueString;
|
|
89
105
|
}
|
|
90
106
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: BsSelectValueAccessor, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
91
107
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.0", type: BsSelectValueAccessor, isStandalone: true, selector: "bs-select", inputs: { compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "change": "hostOnChange($event)", "blur": "hostBlur($event)" } }, providers: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintplayer-ng-bootstrap-select.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/select/src/value-accessors/select-value-accessor.ts","../../../../libs/mintplayer-ng-bootstrap/select/src/component/select.component.ts","../../../../libs/mintplayer-ng-bootstrap/select/src/component/select.component.html","../../../../libs/mintplayer-ng-bootstrap/select/mintplayer-ng-bootstrap-select.ts"],"sourcesContent":["import { Directive, effect, ElementRef, forwardRef, inject, input, OnDestroy, Renderer2 } from \"@angular/core\";\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from \"@angular/forms\";\nimport { BsSelectComponent } from \"../component/select.component\";\n\n@Directive({\n selector: 'bs-select',\n providers: [{\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => BsSelectValueAccessor),\n multi: true,\n }],\n host: {\n '(change)': 'hostOnChange($event)',\n '(blur)': 'hostBlur($event)',\n },\n})\nexport class BsSelectValueAccessor implements ControlValueAccessor {\n private _renderer = inject(Renderer2);\n private _elementRef = inject(ElementRef);\n private selectBox = inject(BsSelectComponent);\n\n onChange = (_: any) => {};\n onTouched = () => {};\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n registerOnChange(fn: (p: any) => void) {\n this.onChange = (valueString: string) => {\n // View -> Model\n this.value = this.getOptionValue(valueString);\n fn(this.value);\n // fn(valueString);\n };\n }\n setDisabledState(isDisabled: boolean): void {\n this.setProperty('disabled', isDisabled);\n }\n protected setProperty(key: string, value: any): void {\n if (this.selectBox.selectBox()) {\n this._renderer.setProperty(this.selectBox.selectBox().nativeElement, key, value);\n }\n }\n\n hostOnChange(event: Event) {\n this.onChange((<any>event.target).value);\n }\n\n hostBlur(ev: Event) {\n this.onTouched();\n }\n\n value: any;\n optionMap = new Map<string, any>();\n idCounter = 0;\n\n private compareWithFunction: (value1: any, value2: any) => boolean = Object.is;\n readonly compareWith = input<((value1: any, value2: any) => boolean) | undefined>(undefined);\n\n constructor() {\n effect(() => {\n const value = this.compareWith();\n if (value !== undefined) {\n if (typeof value !== 'function') {\n throw new Error('compareWith must be a function');\n }\n this.compareWithFunction = value;\n }\n });\n }\n\n buildValueString(id: string | null, value: any) {\n if (id == null) {\n return `${value}`;\n }\n\n if (value && (typeof value === 'object')) {\n value = 'Object';\n }\n\n return `${id}: ${value}`.slice(0, 50);\n }\n\n extractId(valueString: string) {\n return valueString.split(':')[0];\n }\n\n writeValue(value: any) {\n this.value = value;\n\n const id = this.getOptionId(value);\n const valueString = this.buildValueString(id, value);\n this.setProperty('value', valueString);\n }\n\n registerOption() {\n return (this.idCounter++).toString();\n }\n\n getOptionId(value: any) {\n for (const id of Array.from(this.optionMap.keys())) {\n if (this.compareWithFunction(this.optionMap.get(id), value)) {\n return id;\n }\n }\n\n // This shouldn't happen\n // debugger;\n \n return null;\n }\n\n getOptionValue(valueString: string) {\n const id = this.extractId(valueString);\n return this.optionMap.has(id) ? this.optionMap.get(id) : valueString;\n }\n}\n\n@Directive({\n selector: 'option',\n})\nexport class BsSelectOption implements OnDestroy {\n private element = inject(ElementRef);\n private renderer = inject(Renderer2);\n private select = inject(BsSelectValueAccessor, { optional: true, host: true });\n\n constructor() {\n if (this.select) {\n this.id = this.select.registerOption();\n }\n\n effect(() => {\n const val = this.ngValue();\n if (val !== undefined && this.select) {\n this.select.optionMap.set(this.id, val);\n this.setElementValue(this.select.buildValueString(this.id, val));\n this.select.writeValue(this.select.value);\n }\n });\n\n effect(() => {\n const val = this.value();\n if (val !== undefined) {\n this.setElementValue(val);\n if (this.select) {\n this.select.writeValue(this.select.value);\n }\n }\n });\n }\n\n id!: string;\n\n readonly ngValue = input<any>(undefined);\n\n readonly value = input<any>(undefined);\n\n setElementValue(value: string) {\n // console.log('setElementValue', value);\n // const nativeSelect = this.select['selectBox'].selectBox;\n // if (nativeSelect) {\n // this.renderer.setProperty(nativeSelect.nativeElement, 'value', value);\n // }\n this.renderer.setProperty(this.element.nativeElement, 'value', value);\n }\n\n ngOnDestroy() {\n if (this.select) {\n this.select.optionMap.delete(this.id);\n this.select.writeValue(this.select.value);\n }\n }\n}\n\n// @Directive({\n// selector: 'bs-select',\n// providers: [{\n// provide: NG_VALUE_ACCESSOR,\n// useExisting: forwardRef(() => BsSelectValueAccessor),\n// multi: true,\n// }],\n// })\n// export class BsSelectValueAccessor implements ControlValueAccessor, AfterViewInit, OnDestroy {\n// constructor(private host: BsSelectComponent) {}\n\n// destroyed$ = new Subject();\n\n// onValueChange?: (value: any) => void;\n// onTouched?: () => void;\n\n// //#region Lifecycle hooks\n// ngAfterViewInit() {\n// fromEvent(this.host.selectBox.nativeElement, 'change')\n// .pipe(takeUntil(this.destroyed$))\n// .subscribe((ev) => {\n// if (this.onValueChange) {\n// const val = (<HTMLSelectElement>ev.target).value;\n// console.log('selected', val);\n// this.onValueChange(val);\n// }\n// });\n// }\n\n// ngOnDestroy() {\n// this.destroyed$.next(true);\n// }\n// //#endregion\n\n// @Input('ngValue') set ngValue(value: any) {\n// if (this.host) {\n// this.host.opt\n// }\n// }\n\n// //#region OptionId mapping\n// private compareWithFunction: (value1: any, value2: any) => boolean = Object.is;\n// private optionMap = new Map<string, any>();\n// @Input() public set compareWith(fn: (value1: any, value2: any) => boolean) {\n// if (typeof fn !== 'function') {\n// throw new Error('compareWith must be a function');\n// }\n// this.compareWithFunction = fn;\n// }\n\n// private getOptionId(value: any) {\n// for (const id of Array.from(this.optionMap.keys())) {\n// if (this.compareWith(this.optionMap.get(id), value)) {\n// return id;\n// }\n// }\n// return null;\n// }\n\n// private getOptionValue(valueString: string) {\n// const id = this.extractId(valueString);\n// return this.optionMap.has(id) ? this.optionMap.get(id) : valueString;\n// }\n\n// private extractId(valueString: string) {\n// return valueString.split(':')[0];\n// }\n// //#endregion\n\n// //#region ControlValueAccessor implementation\n// registerOnChange(fn: (_: any) => void) {\n// this.onValueChange = (valueString: string) => {\n// this.value = this.getOptionValue(valueString);\n// fn(this.value);\n// };\n// }\n \n// registerOnTouched(fn: () => void) {\n// this.onTouched = fn;\n// }\n\n// value: any;\n// writeValue(value: any) {\n// this.value = value;\n// if (this.host.selectBox) {\n// // this.host.selectBox.nativeElement.selectedIndex = this.host.selectBox.nativeElement.options.item();\n// }\n// }\n\n// setDisabledState(isDisabled: boolean) {\n// if (this.host.selectBox) {\n// this.host.selectBox.nativeElement.disabled = isDisabled;\n// }\n// }\n// //#endregion\n\n// }\n","import {\n ChangeDetectionStrategy,\n Component,\n CUSTOM_ELEMENTS_SCHEMA,\n effect,\n ElementRef,\n forwardRef,\n inject,\n input,\n viewChild,\n} from '@angular/core';\nimport { BsSelectValueAccessor } from '../value-accessors/select-value-accessor';\nimport { BsSelectSize } from '../types/select-size';\nimport type { MpSelect } from '@mintplayer/web-components/select';\n\n// Side-effect import: registers <mp-select>.\nimport '@mintplayer/web-components/select';\nimport { BsForwardAriaDirective, BsControlValidityDirective } from '@mintplayer/ng-bootstrap/a11y';\n\n@Component({\n selector: 'bs-select',\n templateUrl: './select.component.html',\n imports: [BsForwardAriaDirective],\n styleUrls: ['./select.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n hostDirectives: [{\n directive: forwardRef(() => BsSelectValueAccessor),\n inputs: ['compareWith'],\n }, {\n directive: BsControlValidityDirective,\n inputs: ['errorMessages'],\n }],\n})\nexport class BsSelectComponent {\n constructor() {\n effect(() => {\n const el = this.selectBox()?.nativeElement;\n if (!el) return;\n el.size = this.size();\n el.multiple = this.multiple();\n el.numberVisible = this.numberVisible();\n el.disabled = this.disabled();\n });\n }\n\n // For debugging purposes\n identifier = input(0);\n\n /** Reference to the underlying `<mp-select>` WC. Read by\n * `BsSelectValueAccessor` to drive `value` / `disabled` via property\n * setters and listen for the bubbled, composed `change` event. */\n readonly selectBox = viewChild.required<ElementRef<MpSelect>>('selectBox');\n\n size = input<BsSelectSize>('md');\n multiple = input<boolean>(false);\n numberVisible = input<number | null>(null);\n disabled = input<boolean>(false);\n}\n","<mp-select bsForwardAria #selectBox>\n <ng-content></ng-content>\n</mp-select>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.BsSelectValueAccessor"],"mappings":";;;;;;;MAgBa,qBAAqB,CAAA;AAQhC,IAAA,iBAAiB,CAAC,EAAc,EAAA;AAC9B,QAAA,IAAI,CAAC,SAAS,GAAG,EAAE;IACrB;AACA,IAAA,gBAAgB,CAAC,EAAoB,EAAA;AACnC,QAAA,IAAI,CAAC,QAAQ,GAAG,CAAC,WAAmB,KAAI;;YAEtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;AAC7C,YAAA,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;;AAEhB,QAAA,CAAC;IACH;AACA,IAAA,gBAAgB,CAAC,UAAmB,EAAA;AAClC,QAAA,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1C;IACU,WAAW,CAAC,GAAW,EAAE,KAAU,EAAA;AAC3C,QAAA,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE;AAC9B,YAAA,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,a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EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,IAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,MAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,aAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,eAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEpD3E;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"mintplayer-ng-bootstrap-select.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/select/src/value-accessors/select-value-accessor.ts","../../../../libs/mintplayer-ng-bootstrap/select/src/component/select.component.ts","../../../../libs/mintplayer-ng-bootstrap/select/src/component/select.component.html","../../../../libs/mintplayer-ng-bootstrap/select/mintplayer-ng-bootstrap-select.ts"],"sourcesContent":["import { Directive, effect, ElementRef, forwardRef, inject, input, OnDestroy, Renderer2 } from \"@angular/core\";\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from \"@angular/forms\";\nimport { BsSelectComponent } from \"../component/select.component\";\n\n@Directive({\n selector: 'bs-select',\n providers: [{\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => BsSelectValueAccessor),\n multi: true,\n }],\n host: {\n '(change)': 'hostOnChange($event)',\n '(blur)': 'hostBlur($event)',\n },\n})\nexport class BsSelectValueAccessor implements ControlValueAccessor {\n private _renderer = inject(Renderer2);\n private _elementRef = inject(ElementRef);\n private selectBox = inject(BsSelectComponent);\n\n onChange = (_: any) => {};\n onTouched = () => {};\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n registerOnChange(fn: (p: any) => void) {\n this.onChange = (valueString: string) => {\n // View -> Model\n this.value = this.getOptionValue(valueString);\n fn(this.value);\n // fn(valueString);\n };\n }\n setDisabledState(isDisabled: boolean): void {\n this.setProperty('disabled', isDisabled);\n }\n protected setProperty(key: string, value: any): void {\n if (this.selectBox.selectBox()) {\n this._renderer.setProperty(this.selectBox.selectBox().nativeElement, key, value);\n }\n }\n\n hostOnChange(event: Event) {\n this.onChange((<any>event.target).value);\n }\n\n hostBlur(ev: Event) {\n this.onTouched();\n }\n\n value: any;\n optionMap = new Map<string, any>();\n idCounter = 0;\n\n private compareWithFunction: (value1: any, value2: any) => boolean = Object.is;\n readonly compareWith = input<((value1: any, value2: any) => boolean) | undefined>(undefined);\n\n constructor() {\n effect(() => {\n const value = this.compareWith();\n if (value !== undefined) {\n if (typeof value !== 'function') {\n throw new Error('compareWith must be a function');\n }\n this.compareWithFunction = value;\n }\n });\n }\n\n buildValueString(id: string | null, value: any) {\n if (id == null) {\n return `${value}`;\n }\n\n if (value && (typeof value === 'object')) {\n value = 'Object';\n }\n\n return `${id}: ${value}`.slice(0, 50);\n }\n\n /**\n * The id half of a `\"<id>: <value>\"` string, or null when there is no string\n * to read.\n *\n * Null is a real case, not defensive padding: `<option value=\"\">` is the\n * idiomatic way to write a placeholder (\"— none —\", \"Browser locale\"), and\n * `mp-select` normalizes an empty selection to `null` on its host. The host is\n * what `hostOnChange` reads, because `mp-select` re-dispatches a composed\n * `change` whose target is the element rather than the inner `<select>`. So\n * selecting a placeholder threw `can't access property \"split\", valueString is\n * null` and the model never updated — the control looked frozen on that option.\n */\n extractId(valueString: string | null | undefined): string | null {\n return valueString == null ? null : valueString.split(':')[0];\n }\n\n writeValue(value: any) {\n this.value = value;\n\n const id = this.getOptionId(value);\n const valueString = this.buildValueString(id, value);\n this.setProperty('value', valueString);\n }\n\n registerOption() {\n return (this.idCounter++).toString();\n }\n\n getOptionId(value: any) {\n for (const id of Array.from(this.optionMap.keys())) {\n if (this.compareWithFunction(this.optionMap.get(id), value)) {\n return id;\n }\n }\n\n // This shouldn't happen\n // debugger;\n \n return null;\n }\n\n getOptionValue(valueString: string | null | undefined) {\n const id = this.extractId(valueString);\n // Options declared with a plain `value` attribute are never registered in\n // optionMap — only `[ngValue]` registers — so falling through to the raw\n // string is the normal path for them, and passing null through is how a\n // placeholder selection reaches the model as \"nothing chosen\".\n return id !== null && this.optionMap.has(id) ? this.optionMap.get(id) : valueString;\n }\n}\n\n@Directive({\n selector: 'option',\n})\nexport class BsSelectOption implements OnDestroy {\n private element = inject(ElementRef);\n private renderer = inject(Renderer2);\n private select = inject(BsSelectValueAccessor, { optional: true, host: true });\n\n constructor() {\n if (this.select) {\n this.id = this.select.registerOption();\n }\n\n effect(() => {\n const val = this.ngValue();\n if (val !== undefined && this.select) {\n this.select.optionMap.set(this.id, val);\n this.setElementValue(this.select.buildValueString(this.id, val));\n this.select.writeValue(this.select.value);\n }\n });\n\n effect(() => {\n const val = this.value();\n if (val !== undefined) {\n this.setElementValue(val);\n if (this.select) {\n this.select.writeValue(this.select.value);\n }\n }\n });\n }\n\n id!: string;\n\n readonly ngValue = input<any>(undefined);\n\n readonly value = input<any>(undefined);\n\n setElementValue(value: string) {\n // console.log('setElementValue', value);\n // const nativeSelect = this.select['selectBox'].selectBox;\n // if (nativeSelect) {\n // this.renderer.setProperty(nativeSelect.nativeElement, 'value', value);\n // }\n this.renderer.setProperty(this.element.nativeElement, 'value', value);\n }\n\n ngOnDestroy() {\n if (this.select) {\n this.select.optionMap.delete(this.id);\n this.select.writeValue(this.select.value);\n }\n }\n}\n\n// @Directive({\n// selector: 'bs-select',\n// providers: [{\n// provide: NG_VALUE_ACCESSOR,\n// useExisting: forwardRef(() => BsSelectValueAccessor),\n// multi: true,\n// }],\n// })\n// export class BsSelectValueAccessor implements ControlValueAccessor, AfterViewInit, OnDestroy {\n// constructor(private host: BsSelectComponent) {}\n\n// destroyed$ = new Subject();\n\n// onValueChange?: (value: any) => void;\n// onTouched?: () => void;\n\n// //#region Lifecycle hooks\n// ngAfterViewInit() {\n// fromEvent(this.host.selectBox.nativeElement, 'change')\n// .pipe(takeUntil(this.destroyed$))\n// .subscribe((ev) => {\n// if (this.onValueChange) {\n// const val = (<HTMLSelectElement>ev.target).value;\n// console.log('selected', val);\n// this.onValueChange(val);\n// }\n// });\n// }\n\n// ngOnDestroy() {\n// this.destroyed$.next(true);\n// }\n// //#endregion\n\n// @Input('ngValue') set ngValue(value: any) {\n// if (this.host) {\n// this.host.opt\n// }\n// }\n\n// //#region OptionId mapping\n// private compareWithFunction: (value1: any, value2: any) => boolean = Object.is;\n// private optionMap = new Map<string, any>();\n// @Input() public set compareWith(fn: (value1: any, value2: any) => boolean) {\n// if (typeof fn !== 'function') {\n// throw new Error('compareWith must be a function');\n// }\n// this.compareWithFunction = fn;\n// }\n\n// private getOptionId(value: any) {\n// for (const id of Array.from(this.optionMap.keys())) {\n// if (this.compareWith(this.optionMap.get(id), value)) {\n// return id;\n// }\n// }\n// return null;\n// }\n\n// private getOptionValue(valueString: string) {\n// const id = this.extractId(valueString);\n// return this.optionMap.has(id) ? this.optionMap.get(id) : valueString;\n// }\n\n// private extractId(valueString: string) {\n// return valueString.split(':')[0];\n// }\n// //#endregion\n\n// //#region ControlValueAccessor implementation\n// registerOnChange(fn: (_: any) => void) {\n// this.onValueChange = (valueString: string) => {\n// this.value = this.getOptionValue(valueString);\n// fn(this.value);\n// };\n// }\n \n// registerOnTouched(fn: () => void) {\n// this.onTouched = fn;\n// }\n\n// value: any;\n// writeValue(value: any) {\n// this.value = value;\n// if (this.host.selectBox) {\n// // this.host.selectBox.nativeElement.selectedIndex = this.host.selectBox.nativeElement.options.item();\n// }\n// }\n\n// setDisabledState(isDisabled: boolean) {\n// if (this.host.selectBox) {\n// this.host.selectBox.nativeElement.disabled = isDisabled;\n// }\n// }\n// //#endregion\n\n// }\n","import {\n ChangeDetectionStrategy,\n Component,\n CUSTOM_ELEMENTS_SCHEMA,\n effect,\n ElementRef,\n forwardRef,\n inject,\n input,\n viewChild,\n} from '@angular/core';\nimport { BsSelectValueAccessor } from '../value-accessors/select-value-accessor';\nimport { BsSelectSize } from '../types/select-size';\nimport type { MpSelect } from '@mintplayer/web-components/select';\n\n// Side-effect import: registers <mp-select>.\nimport '@mintplayer/web-components/select';\nimport { BsForwardAriaDirective, BsControlValidityDirective } from '@mintplayer/ng-bootstrap/a11y';\n\n@Component({\n selector: 'bs-select',\n templateUrl: './select.component.html',\n imports: [BsForwardAriaDirective],\n styleUrls: ['./select.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n hostDirectives: [{\n directive: forwardRef(() => BsSelectValueAccessor),\n inputs: ['compareWith'],\n }, {\n directive: BsControlValidityDirective,\n inputs: ['errorMessages'],\n }],\n})\nexport class BsSelectComponent {\n constructor() {\n effect(() => {\n const el = this.selectBox()?.nativeElement;\n if (!el) return;\n el.size = this.size();\n el.multiple = this.multiple();\n el.numberVisible = this.numberVisible();\n el.disabled = this.disabled();\n });\n }\n\n // For debugging purposes\n identifier = input(0);\n\n /** Reference to the underlying `<mp-select>` WC. Read by\n * `BsSelectValueAccessor` to drive `value` / `disabled` via property\n * setters and listen for the bubbled, composed `change` event. */\n readonly selectBox = viewChild.required<ElementRef<MpSelect>>('selectBox');\n\n size = input<BsSelectSize>('md');\n multiple = input<boolean>(false);\n numberVisible = input<number | null>(null);\n disabled = input<boolean>(false);\n}\n","<mp-select bsForwardAria #selectBox>\n <ng-content></ng-content>\n</mp-select>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.BsSelectValueAccessor"],"mappings":";;;;;;;MAgBa,qBAAqB,CAAA;AAQhC,IAAA,iBAAiB,CAAC,EAAc,EAAA;AAC9B,QAAA,IAAI,CAAC,SAAS,GAAG,EAAE;IACrB;AACA,IAAA,gBAAgB,CAAC,EAAoB,EAAA;AACnC,QAAA,IAAI,CAAC,QAAQ,GAAG,CAAC,WAAmB,KAAI;;YAEtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;AAC7C,YAAA,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;;AAEhB,QAAA,CAAC;IACH;AACA,IAAA,gBAAgB,CAAC,UAAmB,EAAA;AAClC,QAAA,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1C;IACU,WAAW,CAAC,GAAW,EAAE,KAAU,EAAA;AAC3C,QAAA,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE;AAC9B,YAAA,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,CAAC;QAClF;IACF;AAEA,IAAA,YAAY,CAAC,KAAY,EAAA;QACvB,IAAI,CAAC,QAAQ,CAAO,KAAK,CAAC,MAAO,CAAC,KAAK,CAAC;IAC1C;AAEA,IAAA,QAAQ,CAAC,EAAS,EAAA;QAChB,IAAI,CAAC,SAAS,EAAE;IAClB;AASA,IAAA,WAAA,GAAA;AA1CQ,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;AAC7B,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;AAChC,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAE7C,QAAA,IAAA,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AAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,aAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,eAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEpD3E;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/ng-bootstrap",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "22.
|
|
4
|
+
"version": "22.13.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -245,6 +245,10 @@
|
|
|
245
245
|
"types": "./types/mintplayer-ng-bootstrap-parallax.d.ts",
|
|
246
246
|
"default": "./fesm2022/mintplayer-ng-bootstrap-parallax.mjs"
|
|
247
247
|
},
|
|
248
|
+
"./phone-input": {
|
|
249
|
+
"types": "./types/mintplayer-ng-bootstrap-phone-input.d.ts",
|
|
250
|
+
"default": "./fesm2022/mintplayer-ng-bootstrap-phone-input.mjs"
|
|
251
|
+
},
|
|
248
252
|
"./placeholder": {
|
|
249
253
|
"types": "./types/mintplayer-ng-bootstrap-placeholder.d.ts",
|
|
250
254
|
"default": "./fesm2022/mintplayer-ng-bootstrap-placeholder.mjs"
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
2
|
|
|
3
|
+
type BsInputGroupSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
/**
|
|
5
|
+
* `<bs-input-group>` — joins its children into one visually continuous control.
|
|
6
|
+
*
|
|
7
|
+
* Now a wrapper over `<mp-input-group>`. The previous version was a
|
|
8
|
+
* `<div class="input-group">` plus a `::ng-deep` import of Bootstrap's module,
|
|
9
|
+
* which could not style a `<bs-select>`: the rules Bootstrap keys on
|
|
10
|
+
* `.input-group > .form-select` cannot reach inside that component's shadow root,
|
|
11
|
+
* so a select in a group got neither the flex sizing nor collapsed inner corners.
|
|
12
|
+
* The WC solves it with two channels (see `input-group.styles.scss`), which is why
|
|
13
|
+
* the styling moved there rather than being duplicated here.
|
|
14
|
+
*/
|
|
3
15
|
declare class BsInputGroupComponent {
|
|
4
|
-
|
|
5
|
-
|
|
16
|
+
/** Bootstrap sizing, applied to light-DOM and `mp-*` children alike. */
|
|
17
|
+
readonly size: _angular_core.InputSignal<BsInputGroupSize>;
|
|
18
|
+
/** `md` is the absence of a size in Bootstrap, so it is not written at all. */
|
|
19
|
+
protected readonly sizeAttr: _angular_core.Signal<BsInputGroupSize | null>;
|
|
20
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<BsInputGroupComponent, never>;
|
|
21
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<BsInputGroupComponent, "bs-input-group", never, { "size": { "alias": "size"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
6
22
|
}
|
|
7
23
|
|
|
8
24
|
export { BsInputGroupComponent };
|
|
25
|
+
export type { BsInputGroupSize };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
3
|
+
import { PhoneChangeEventDetail } from '@mintplayer/web-components/phone-input';
|
|
4
|
+
import * as i1 from '@mintplayer/ng-bootstrap/a11y';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `<bs-phone-input>` — a phone-number form control: country picker with flags,
|
|
8
|
+
* a dial code that cannot be edited away, and as-you-type formatting.
|
|
9
|
+
*
|
|
10
|
+
* The control value is **E.164** (`'+32470123456'`), or `null` while empty, so a
|
|
11
|
+
* form posts one canonical string. `(phoneChange)` carries the decomposed parts
|
|
12
|
+
* for consumers that need them — note `valid` is `undefined` until the selected
|
|
13
|
+
* country's validation rules have loaded, which is deliberate rather than
|
|
14
|
+
* optimistic.
|
|
15
|
+
*
|
|
16
|
+
* ```html
|
|
17
|
+
* <bs-form>
|
|
18
|
+
* <bs-phone-input [(ngModel)]="phone" default-country="be"
|
|
19
|
+
* [errorMessages]="{ required: 'Enter a phone number.' }" />
|
|
20
|
+
* </bs-form>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare class BsPhoneInputComponent implements ControlValueAccessor {
|
|
24
|
+
private readonly destroyRef;
|
|
25
|
+
private onChange;
|
|
26
|
+
private onTouched;
|
|
27
|
+
/** Set by `setDisabledState` before the view exists, applied by the effect. */
|
|
28
|
+
private disabledByForm;
|
|
29
|
+
private readonly phoneInput;
|
|
30
|
+
/** ISO 3166-1 alpha-2, lowercase. Two-way via `(countryChange)`. */
|
|
31
|
+
readonly country: _angular_core.InputSignal<string | null>;
|
|
32
|
+
/** Country to start on when the value is empty. */
|
|
33
|
+
readonly defaultCountry: _angular_core.InputSignal<string | null>;
|
|
34
|
+
/** BCP-47 tag for country names and their ordering. Omitted = browser locale. */
|
|
35
|
+
readonly locale: _angular_core.InputSignal<string | null>;
|
|
36
|
+
readonly preferredCountries: _angular_core.InputSignal<readonly string[] | null>;
|
|
37
|
+
readonly allowedCountries: _angular_core.InputSignal<readonly string[] | null>;
|
|
38
|
+
readonly placeholder: _angular_core.InputSignal<string | null>;
|
|
39
|
+
readonly autocomplete: _angular_core.InputSignal<string>;
|
|
40
|
+
/** Accessible name of the number field. */
|
|
41
|
+
readonly inputLabel: _angular_core.InputSignal<string | null>;
|
|
42
|
+
/** Accessible name of the country picker. */
|
|
43
|
+
readonly countryLabel: _angular_core.InputSignal<string | null>;
|
|
44
|
+
readonly countryChange: _angular_core.OutputEmitterRef<string>;
|
|
45
|
+
/** The full detail: E.164 value plus country, dial code, digits and validity. */
|
|
46
|
+
readonly phoneChange: _angular_core.OutputEmitterRef<PhoneChangeEventDetail>;
|
|
47
|
+
protected readonly preferredAttr: _angular_core.Signal<string | null>;
|
|
48
|
+
protected readonly allowedAttr: _angular_core.Signal<string | null>;
|
|
49
|
+
constructor();
|
|
50
|
+
writeValue(value: string | null): void;
|
|
51
|
+
registerOnChange(fn: (value: string | null) => void): void;
|
|
52
|
+
registerOnTouched(fn: () => void): void;
|
|
53
|
+
setDisabledState(isDisabled: boolean): void;
|
|
54
|
+
protected onValueChange(ev: Event): void;
|
|
55
|
+
protected onCountryChange(ev: Event): void;
|
|
56
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<BsPhoneInputComponent, never>;
|
|
57
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<BsPhoneInputComponent, "bs-phone-input", never, { "country": { "alias": "country"; "required": false; "isSignal": true; }; "defaultCountry": { "alias": "defaultCountry"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; "preferredCountries": { "alias": "preferredCountries"; "required": false; "isSignal": true; }; "allowedCountries": { "alias": "allowedCountries"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "autocomplete": { "alias": "autocomplete"; "required": false; "isSignal": true; }; "inputLabel": { "alias": "inputLabel"; "required": false; "isSignal": true; }; "countryLabel": { "alias": "countryLabel"; "required": false; "isSignal": true; }; }, { "countryChange": "countryChange"; "phoneChange": "phoneChange"; }, never, never, true, [{ directive: typeof i1.BsControlValidityDirective; inputs: { "errorMessages": "errorMessages"; }; outputs: {}; }]>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { BsPhoneInputComponent };
|
|
@@ -25,11 +25,23 @@ declare class BsSelectValueAccessor implements ControlValueAccessor {
|
|
|
25
25
|
readonly compareWith: _angular_core.InputSignal<((value1: any, value2: any) => boolean) | undefined>;
|
|
26
26
|
constructor();
|
|
27
27
|
buildValueString(id: string | null, value: any): string;
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The id half of a `"<id>: <value>"` string, or null when there is no string
|
|
30
|
+
* to read.
|
|
31
|
+
*
|
|
32
|
+
* Null is a real case, not defensive padding: `<option value="">` is the
|
|
33
|
+
* idiomatic way to write a placeholder ("— none —", "Browser locale"), and
|
|
34
|
+
* `mp-select` normalizes an empty selection to `null` on its host. The host is
|
|
35
|
+
* what `hostOnChange` reads, because `mp-select` re-dispatches a composed
|
|
36
|
+
* `change` whose target is the element rather than the inner `<select>`. So
|
|
37
|
+
* selecting a placeholder threw `can't access property "split", valueString is
|
|
38
|
+
* null` and the model never updated — the control looked frozen on that option.
|
|
39
|
+
*/
|
|
40
|
+
extractId(valueString: string | null | undefined): string | null;
|
|
29
41
|
writeValue(value: any): void;
|
|
30
42
|
registerOption(): string;
|
|
31
43
|
getOptionId(value: any): string | null;
|
|
32
|
-
getOptionValue(valueString: string): any;
|
|
44
|
+
getOptionValue(valueString: string | null | undefined): any;
|
|
33
45
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<BsSelectValueAccessor, never>;
|
|
34
46
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BsSelectValueAccessor, "bs-select", never, { "compareWith": { "alias": "compareWith"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
35
47
|
}
|