@bizy/core 19.13.6 → 19.14.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.
@@ -26,6 +26,7 @@ import Dashboard from '@uppy/dashboard';
26
26
  import XHRUpload from '@uppy/xhr-upload';
27
27
  import * as i1$1 from '@angular/router';
28
28
  import { NavigationEnd, NavigationStart, Router } from '@angular/router';
29
+ import validator from 'validator';
29
30
  import { Clipboard } from '@angular/cdk/clipboard';
30
31
  import { DeviceDetectorService } from 'ngx-device-detector';
31
32
  import * as i3 from '@angular/cdk/portal';
@@ -190,6 +191,7 @@ class BizyAudioPlayerComponent {
190
191
  this.#audioRef = this.#document.getElementById(this.id);
191
192
  if (this.#audioRef) {
192
193
  this.#audioRef.load();
194
+ this._trackPlayerRate();
193
195
  if (this.autoplay) {
194
196
  this.#audioRef.play();
195
197
  }
@@ -199,6 +201,7 @@ class BizyAudioPlayerComponent {
199
201
  this.#audioRef = this.#document.getElementById(this.id);
200
202
  if (this.#audioRef) {
201
203
  this.#audioRef.load();
204
+ this._trackPlayerRate();
202
205
  if (this.autoplay) {
203
206
  this.#audioRef.play();
204
207
  }
@@ -213,7 +216,7 @@ class BizyAudioPlayerComponent {
213
216
  _playbackRate = 1;
214
217
  #trackPlaybackRate$ = new Subject();
215
218
  #subscription = new Subscription();
216
- trackPlayerRate() {
219
+ _trackPlayerRate() {
217
220
  this.#subscription.add(this.#trackPlaybackRate$.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
218
221
  this.onTrackPlayerRate.emit(value);
219
222
  }));
@@ -240,15 +243,17 @@ class BizyAudioPlayerComponent {
240
243
  case 2:
241
244
  this.#audioRef.playbackRate = 1;
242
245
  this._playbackRate = 1;
246
+ this.#trackPlaybackRate$.next('1');
243
247
  break;
244
248
  default:
245
249
  this.#audioRef.playbackRate = 1;
246
250
  this._playbackRate = 1;
251
+ this.#trackPlaybackRate$.next('1');
247
252
  }
248
253
  }
249
254
  }
250
255
  _onDownload() {
251
- if (!this.disabled) {
256
+ if (this.disabled || !this.showDownload) {
252
257
  return;
253
258
  }
254
259
  const downloadButton = this.#renderer.createElement('a');
@@ -2926,52 +2931,249 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
2926
2931
  }] }] });
2927
2932
 
2928
2933
  class BizyValidatorService {
2929
- isEmail(email) {
2930
- const regex = /^(([^ñ<>()[\]\\.,;:\s@"]+(\.[^ñ<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2931
- return regex.test(String(email).toLowerCase());
2932
- }
2933
- isPassFormat(pass) {
2934
- const formatRegex = /(?!.*012)(?!.*123)(?!.*234)(?!.*345)(?!.*456)(?!.*567)(?!.*678)(?!.*789)(?!.*987)(?!.*876)(?!.*765)(?!.*654)(?!.*543)(?!.*432)(?!.*321)(?!.*210)(?!.*(.)\1{2,})(?!(^\D+$))(?!(^\d+$))(^.{6,}$)/;
2935
- const excludeRegex = /[^'"]$/;
2936
- const _pass = String(pass).toLowerCase();
2937
- return formatRegex.test(_pass) && excludeRegex.test(_pass);
2938
- }
2939
- isNoSpecialCharacter(name) {
2940
- const regex = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;
2941
- return regex.test(String(name).toLowerCase());
2942
- }
2934
+ isEmail = (value) => validator.isEmail(value);
2935
+ dateIsAfter = (data) => {
2936
+ if (!data || !data.date || !data.comparisonDate) {
2937
+ return false;
2938
+ }
2939
+ const date = new Date(data.date);
2940
+ const comparisonDate = new Date(data.comparisonDate);
2941
+ return validator.isAfter(date.toString(), comparisonDate.toString());
2942
+ };
2943
+ dateIsBefore = (data) => {
2944
+ if (!data || !data.date || !data.comparisonDate) {
2945
+ return false;
2946
+ }
2947
+ const date = new Date(data.date);
2948
+ const comparisonDate = new Date(data.comparisonDate);
2949
+ return validator.isBefore(date.toString(), comparisonDate.toString());
2950
+ };
2951
+ isAlpha = (value) => validator.isAlpha(value);
2952
+ isAlphanumeric = (value) => validator.isAlphanumeric(value);
2953
+ isNumeric = (value) => validator.isNumeric(value);
2943
2954
  isNumber(number) {
2944
- const regex = /^[0-9]*$/;
2945
- return regex.test(String(number).toLowerCase());
2946
- }
2947
- isPhoneNumber(number) {
2948
- const regex = /^\+{0,1}[0-9#*]+$/;
2955
+ const regex = /^-?\d+(\.\d+)?$/;
2949
2956
  return regex.test(String(number).toLowerCase());
2950
2957
  }
2951
2958
  isString(string) {
2952
2959
  return typeof string === 'string' || string instanceof String;
2953
2960
  }
2954
- isJSON(text) {
2955
- if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\/bfnrtu]/g, '@')
2956
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g, ']')
2957
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
2958
- return true;
2961
+ isInteger = (value) => validator.isInt(value);
2962
+ isBoolean = (value) => validator.isBoolean(value);
2963
+ isCreditCard = (value) => validator.isCreditCard(value);
2964
+ isDataURI = (value) => validator.isDataURI(value);
2965
+ isURL = (value) => validator.isURL(value);
2966
+ isDate = (value) => validator.isDate(value);
2967
+ isJSON = (value) => validator.isJSON(value);
2968
+ isIP = (value, version) => validator.isIP(value, { version });
2969
+ isJWT = (value) => validator.isJWT(value);
2970
+ isLowercase = (value) => validator.isLowercase(value);
2971
+ isUppercase = (value) => validator.isUppercase(value);
2972
+ isMobilePhone = (data) => validator.isMobilePhone(data.value, data.locale);
2973
+ isCUIT(cuit) {
2974
+ const regex = /(^[0-9]{2}-[0-9]{8}-[0-9]$)/i;
2975
+ const isCUIT = regex.test(String(cuit).toLowerCase());
2976
+ if (!isCUIT) {
2977
+ return false;
2978
+ }
2979
+ cuit = String(cuit).replace(/[-_]/g, '');
2980
+ if (cuit.length == 11) {
2981
+ const mult = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
2982
+ let total = 0;
2983
+ for (let i = 0; i < mult.length; i++) {
2984
+ total += parseInt(cuit[i]) * mult[i];
2985
+ }
2986
+ const mod = total % 11;
2987
+ const digit = mod === 0 ? 0 : mod === 1 ? 9 : 11 - mod;
2988
+ return digit === parseInt(cuit[10]);
2959
2989
  }
2960
2990
  return false;
2961
2991
  }
2992
+ isDNI(dni) {
2993
+ const regex = /(^[1-9]{1}[0-9]{7}$)/i;
2994
+ return regex.test(String(dni).toLowerCase());
2995
+ }
2996
+ isCBU(cbu) {
2997
+ const _isLengthOk = (cbu) => {
2998
+ return cbu.length === 22;
2999
+ };
3000
+ const _isValidAccount = (account) => {
3001
+ if (account.length !== 14) {
3002
+ return false;
3003
+ }
3004
+ const sum = Number(account[0]) * 3 +
3005
+ Number(account[1]) * 9 +
3006
+ Number(account[2]) * 7 +
3007
+ Number(account[3]) * 1 +
3008
+ Number(account[4]) * 3 +
3009
+ Number(account[5]) * 9 +
3010
+ Number(account[6]) * 7 +
3011
+ Number(account[7]) * 1 +
3012
+ Number(account[8]) * 3 +
3013
+ Number(account[9]) * 9 +
3014
+ Number(account[10]) * 7 +
3015
+ Number(account[11]) * 1 +
3016
+ Number(account[12]) * 3;
3017
+ const diff = (10 - (sum % 10)) % 10; // The result of this should be only 1 digit
3018
+ const checksum = Number(account[13]);
3019
+ return diff === checksum;
3020
+ };
3021
+ const _isValidBankCode = (code) => {
3022
+ if (code.length !== 8) {
3023
+ return false;
3024
+ }
3025
+ const bank = code.substring(0, 3);
3026
+ const checksumOne = code[3];
3027
+ const branch = code.substring(4, 4 + 3);
3028
+ const checksumTwo = code[7];
3029
+ const sum = (Number(bank[0]) * 7) +
3030
+ (Number(bank[1]) * 1) +
3031
+ (Number(bank[2]) * 3) +
3032
+ (Number(checksumOne) * 9) +
3033
+ (Number(branch[0]) * 7) +
3034
+ (Number(branch[1]) * 1) +
3035
+ (Number(branch[2]) * 3);
3036
+ const diff = (10 - (sum % 10)) % 10; // The result of this should be only 1 digit
3037
+ return diff === Number(checksumTwo);
3038
+ };
3039
+ const bankCode = cbu.substring(0, 8);
3040
+ const accountCode = cbu.substring(8, 8 + 14);
3041
+ return (_isLengthOk(cbu) &&
3042
+ _isValidBankCode(bankCode) &&
3043
+ _isValidAccount(accountCode));
3044
+ }
2962
3045
  emailValidator() {
2963
3046
  return (control) => {
2964
- return !control.value || (control.value && this.isEmail(control.value)) ? null : { bizyEmail: true };
3047
+ return !control.value || (control.value && this.isEmail(control.value))
3048
+ ? null
3049
+ : { anuraEmail: true };
2965
3050
  };
2966
3051
  }
2967
- phoneNumberValidator() {
3052
+ mobilePhoneValidator(locale) {
2968
3053
  return (control) => {
2969
- return !control.value || (control.value && this.isPhoneNumber(control.value)) ? null : { bizyPhoneNumber: true };
3054
+ return !control.value || !locale ||
3055
+ (control.value && locale && this.isMobilePhone({ value: control.value, locale }))
3056
+ ? null
3057
+ : { anuraMobilePhone: true };
2970
3058
  };
2971
3059
  }
2972
3060
  numberValidator() {
2973
3061
  return (control) => {
2974
- return !control.value || (control.value && this.isNumber(control.value)) ? null : { bizyNumber: true };
3062
+ return !control.value || (control.value && this.isNumber(control.value))
3063
+ ? null
3064
+ : { anuraNumber: true };
3065
+ };
3066
+ }
3067
+ numericValidator() {
3068
+ return (control) => {
3069
+ return !control.value || (control.value && this.isNumeric(control.value))
3070
+ ? null
3071
+ : { anuraNumeric: true };
3072
+ };
3073
+ }
3074
+ dateIsAfterValidator(comparisonDate) {
3075
+ return (control) => {
3076
+ return !control.value || !comparisonDate || (control.value && comparisonDate && !this.dateIsAfter({ date: control.value, comparisonDate }))
3077
+ ? null
3078
+ : { anuraDateIsAfter: true };
3079
+ };
3080
+ }
3081
+ dateIsBeforeValidator(comparisonDate) {
3082
+ return (control) => {
3083
+ return !control.value || !comparisonDate || (control.value && comparisonDate && !this.dateIsBefore({ date: control.value, comparisonDate }))
3084
+ ? null
3085
+ : { anuraDateIsBefore: true };
3086
+ };
3087
+ }
3088
+ alphaValidator() {
3089
+ return (control) => {
3090
+ return !control.value || (control.value && this.isAlpha(control.value))
3091
+ ? null
3092
+ : { anuraAlpha: true };
3093
+ };
3094
+ }
3095
+ alphanumericValidator() {
3096
+ return (control) => {
3097
+ return !control.value || (control.value && this.isAlphanumeric(control.value))
3098
+ ? null
3099
+ : { anuraAlphanumeric: true };
3100
+ };
3101
+ }
3102
+ integerValidator() {
3103
+ return (control) => {
3104
+ return !control.value || (control.value && this.isInteger(control.value))
3105
+ ? null
3106
+ : { anuraInteger: true };
3107
+ };
3108
+ }
3109
+ dataURIValidator() {
3110
+ return (control) => {
3111
+ return !control.value || (control.value && this.isDataURI(control.value))
3112
+ ? null
3113
+ : { anuraDataURI: true };
3114
+ };
3115
+ }
3116
+ urlValidator() {
3117
+ return (control) => {
3118
+ return !control.value || (control.value && this.isURL(control.value))
3119
+ ? null
3120
+ : { anuraURL: true };
3121
+ };
3122
+ }
3123
+ jsonValidator() {
3124
+ return (control) => {
3125
+ return !control.value || (control.value && this.isJSON(control.value))
3126
+ ? null
3127
+ : { anuraJSON: true };
3128
+ };
3129
+ }
3130
+ jwtValidator() {
3131
+ return (control) => {
3132
+ return !control.value || (control.value && this.isJWT(control.value))
3133
+ ? null
3134
+ : { anuraJWT: true };
3135
+ };
3136
+ }
3137
+ lowerCaseValidator() {
3138
+ return (control) => {
3139
+ return !control.value || (control.value && this.isLowercase(control.value))
3140
+ ? null
3141
+ : { anuraLowerCase: true };
3142
+ };
3143
+ }
3144
+ upperCaseValidator() {
3145
+ return (control) => {
3146
+ return !control.value || (control.value && this.isUppercase(control.value))
3147
+ ? null
3148
+ : { anuraUpperCase: true };
3149
+ };
3150
+ }
3151
+ cuitValidator() {
3152
+ return (control) => {
3153
+ return !control.value || (control.value && this.isCUIT(control.value))
3154
+ ? null
3155
+ : { anuraCUIT: true };
3156
+ };
3157
+ }
3158
+ dniValidator() {
3159
+ return (control) => {
3160
+ return !control.value || (control.value && this.isDNI(control.value))
3161
+ ? null
3162
+ : { anuraDNI: true };
3163
+ };
3164
+ }
3165
+ cbuValidator() {
3166
+ return (control) => {
3167
+ return !control.value || (control.value && this.isCBU(control.value))
3168
+ ? null
3169
+ : { anuraCBU: true };
3170
+ };
3171
+ }
3172
+ creditCardValidator() {
3173
+ return (control) => {
3174
+ return !control.value || (control.value && this.isCreditCard(control.value))
3175
+ ? null
3176
+ : { anuraCreditCard: true };
2975
3177
  };
2976
3178
  }
2977
3179
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: BizyValidatorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });