@elderbyte/ngx-starter 20.4.7 → 20.4.8
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.
|
@@ -2036,54 +2036,54 @@ class PhoneFormatService {
|
|
|
2036
2036
|
* Public API *
|
|
2037
2037
|
* *
|
|
2038
2038
|
**************************************************************************/
|
|
2039
|
-
formatPhoneNumber(
|
|
2040
|
-
if (!config
|
|
2041
|
-
return
|
|
2042
|
-
}
|
|
2043
|
-
else {
|
|
2044
|
-
return this.applyFormattingPerConfig(number, config);
|
|
2039
|
+
formatPhoneNumber(nr, config) {
|
|
2040
|
+
if (!config?.countryCode) {
|
|
2041
|
+
return nr;
|
|
2045
2042
|
}
|
|
2043
|
+
const phoneNrBody = this.preparePhoneNumberBody(nr, config);
|
|
2044
|
+
const transformedBody = this.applyRegexTransform(phoneNrBody, config);
|
|
2045
|
+
return this.addPrefix(transformedBody, config);
|
|
2046
2046
|
}
|
|
2047
2047
|
/***************************************************************************
|
|
2048
2048
|
* *
|
|
2049
2049
|
* Private Methods *
|
|
2050
2050
|
* *
|
|
2051
2051
|
**************************************************************************/
|
|
2052
|
-
|
|
2053
|
-
let
|
|
2054
|
-
if (config.
|
|
2055
|
-
|
|
2056
|
-
|
|
2052
|
+
addPrefix(body, config) {
|
|
2053
|
+
let prefix = '';
|
|
2054
|
+
if (config.customPrefix !== undefined && config.customPrefix !== null) {
|
|
2055
|
+
prefix = config.customPrefix;
|
|
2056
|
+
}
|
|
2057
|
+
else {
|
|
2058
|
+
prefix = config.countryCode + ' ';
|
|
2057
2059
|
}
|
|
2058
|
-
|
|
2059
|
-
return `${prefix}${phoneNrBody}`;
|
|
2060
|
+
return `${prefix}${body}`;
|
|
2060
2061
|
}
|
|
2061
2062
|
preparePhoneNumberBody(number, config) {
|
|
2062
2063
|
const clean = this.cleanNumberString(number);
|
|
2063
|
-
const withoutDialingCode = this.removeDialingCode(clean, config.
|
|
2064
|
-
|
|
2064
|
+
const withoutDialingCode = this.removeDialingCode(clean, config.countryCode);
|
|
2065
|
+
const withoutLeadingZeros = withoutDialingCode.replace(/^0+/, '');
|
|
2066
|
+
return withoutLeadingZeros;
|
|
2065
2067
|
}
|
|
2066
2068
|
cleanNumberString(number) {
|
|
2067
|
-
|
|
2068
|
-
return number.replace(regex, '');
|
|
2069
|
-
}
|
|
2070
|
-
handleWithoutConfig(number, countryCode) {
|
|
2071
|
-
if (!countryCode) {
|
|
2072
|
-
return number;
|
|
2073
|
-
}
|
|
2074
|
-
else {
|
|
2075
|
-
return countryCode + ' ' + number;
|
|
2076
|
-
}
|
|
2069
|
+
return number.replace(/[^0-9+]/g, '');
|
|
2077
2070
|
}
|
|
2078
|
-
removeDialingCode(phoneNr,
|
|
2079
|
-
const dialingCodeWithDoubleZero =
|
|
2080
|
-
for (const prefix of [
|
|
2071
|
+
removeDialingCode(phoneNr, countryCode) {
|
|
2072
|
+
const dialingCodeWithDoubleZero = countryCode.replace('+', '00');
|
|
2073
|
+
for (const prefix of [countryCode, dialingCodeWithDoubleZero]) {
|
|
2081
2074
|
if (phoneNr.startsWith(prefix)) {
|
|
2082
2075
|
return phoneNr.slice(prefix.length);
|
|
2083
2076
|
}
|
|
2084
2077
|
}
|
|
2085
2078
|
return phoneNr;
|
|
2086
2079
|
}
|
|
2080
|
+
applyRegexTransform(phoneNrBody, config) {
|
|
2081
|
+
if (!config?.bodyFormat) {
|
|
2082
|
+
return phoneNrBody;
|
|
2083
|
+
}
|
|
2084
|
+
const [regex, format] = config.bodyFormat;
|
|
2085
|
+
return phoneNrBody.replace(regex, format);
|
|
2086
|
+
}
|
|
2087
2087
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PhoneFormatService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2088
2088
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PhoneFormatService, providedIn: 'root' }); }
|
|
2089
2089
|
}
|
|
@@ -2099,48 +2099,59 @@ class CountryPhoneFormatService {
|
|
|
2099
2099
|
this.countryPhoneFormats = {
|
|
2100
2100
|
'+41': {
|
|
2101
2101
|
country: 'CH',
|
|
2102
|
-
|
|
2103
|
-
bodyFormat: [/^(\d{2})(\d{3})(\d{2})(\d{2})$/, '$1 $2 $3 $4'],
|
|
2104
|
-
customPrefix: '0',
|
|
2105
|
-
},
|
|
2106
|
-
'0041': {
|
|
2107
|
-
country: 'CH',
|
|
2108
|
-
dialingCode: '+41',
|
|
2102
|
+
countryCode: '+41',
|
|
2109
2103
|
bodyFormat: [/^(\d{2})(\d{3})(\d{2})(\d{2})$/, '$1 $2 $3 $4'],
|
|
2110
2104
|
customPrefix: '0',
|
|
2111
2105
|
},
|
|
2112
2106
|
'+423': {
|
|
2113
2107
|
country: 'LI',
|
|
2114
|
-
|
|
2108
|
+
countryCode: '+423',
|
|
2115
2109
|
bodyFormat: [/^(\d{3})(\d{4})$/, '$1 $2'],
|
|
2116
2110
|
},
|
|
2117
2111
|
'+49': {
|
|
2118
2112
|
country: 'DE',
|
|
2119
|
-
|
|
2113
|
+
countryCode: '+49',
|
|
2120
2114
|
},
|
|
2121
2115
|
'+43': {
|
|
2122
2116
|
country: 'AT',
|
|
2123
|
-
|
|
2117
|
+
countryCode: '+43',
|
|
2124
2118
|
},
|
|
2125
2119
|
'+33': {
|
|
2126
2120
|
country: 'FR',
|
|
2127
|
-
|
|
2121
|
+
countryCode: '+33',
|
|
2128
2122
|
},
|
|
2129
2123
|
'+44': {
|
|
2130
2124
|
country: 'GB',
|
|
2131
|
-
|
|
2125
|
+
countryCode: '+44',
|
|
2132
2126
|
},
|
|
2133
2127
|
'+1': {
|
|
2134
2128
|
country: 'US',
|
|
2135
|
-
|
|
2129
|
+
countryCode: '+1',
|
|
2136
2130
|
},
|
|
2137
2131
|
};
|
|
2138
2132
|
}
|
|
2139
|
-
|
|
2140
|
-
|
|
2133
|
+
/***************************************************************************
|
|
2134
|
+
* *
|
|
2135
|
+
* Public API *
|
|
2136
|
+
* *
|
|
2137
|
+
**************************************************************************/
|
|
2138
|
+
getCountryPhoneFormat(countryCode) {
|
|
2139
|
+
if (!countryCode) {
|
|
2140
|
+
return null;
|
|
2141
|
+
}
|
|
2142
|
+
const cleanedCode = countryCode.replace(/^00/, '+');
|
|
2143
|
+
if (this.countryPhoneFormats[cleanedCode]) {
|
|
2144
|
+
return this.countryPhoneFormats[cleanedCode];
|
|
2145
|
+
}
|
|
2146
|
+
return {
|
|
2147
|
+
country: null,
|
|
2148
|
+
countryCode: cleanedCode,
|
|
2149
|
+
bodyFormat: null,
|
|
2150
|
+
};
|
|
2141
2151
|
}
|
|
2142
|
-
getCountry(
|
|
2143
|
-
|
|
2152
|
+
getCountry(countryCode) {
|
|
2153
|
+
const countryFormat = this.countryPhoneFormats[countryCode];
|
|
2154
|
+
return countryFormat?.country || null;
|
|
2144
2155
|
}
|
|
2145
2156
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: CountryPhoneFormatService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2146
2157
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: CountryPhoneFormatService, providedIn: 'root' }); }
|
|
@@ -2159,7 +2170,7 @@ class PhonePipe {
|
|
|
2159
2170
|
}
|
|
2160
2171
|
transform(phoneNumber) {
|
|
2161
2172
|
const countryPhoneFormat = this.countryPhoneFormats.getCountryPhoneFormat(phoneNumber.countryCode);
|
|
2162
|
-
return this.phoneFormat.formatPhoneNumber(phoneNumber.number,
|
|
2173
|
+
return this.phoneFormat.formatPhoneNumber(phoneNumber.number, countryPhoneFormat);
|
|
2163
2174
|
}
|
|
2164
2175
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: PhonePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2165
2176
|
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: PhonePipe, isStandalone: true, name: "phone" }); }
|
|
@@ -25937,8 +25948,10 @@ class ElderMultiSelectBase extends ElderSelectBase {
|
|
|
25937
25948
|
return valueLoadRequest$.pipe(map((loaded) => {
|
|
25938
25949
|
loaded.forEach((v, k) => existing.set(k, v));
|
|
25939
25950
|
return existing;
|
|
25940
|
-
}), map((allValuesMap) =>
|
|
25941
|
-
|
|
25951
|
+
}), map((allValuesMap) => {
|
|
25952
|
+
// Sort entities by id order
|
|
25953
|
+
return ids.map((id) => allValuesMap.get(id)).filter((entity) => !!entity);
|
|
25954
|
+
}));
|
|
25942
25955
|
}
|
|
25943
25956
|
else {
|
|
25944
25957
|
this.logger.warn('Failed to select value by Ids: ' + ids + ' - DataContext not available.');
|