monkey-style-guide 2.0.86 → 2.0.88

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/assets/scss/partials/components/_index.scss +1 -0
  2. package/assets/scss/partials/components/_input-phone.scss +17 -0
  3. package/bundles/monkey-style-guide.umd.js +228 -9
  4. package/bundles/monkey-style-guide.umd.js.map +1 -1
  5. package/esm2015/lib/components/date-range-picker/date-range-picker.component.js +9 -6
  6. package/esm2015/lib/components/index.js +2 -1
  7. package/esm2015/lib/components/index.ngsummary.json +1 -1
  8. package/esm2015/lib/components/input-phone/index.js +3 -0
  9. package/esm2015/lib/components/input-phone/index.ngsummary.json +1 -0
  10. package/esm2015/lib/components/input-phone/input-phone.component.js +205 -0
  11. package/esm2015/lib/components/input-phone/input-phone.component.ngfactory.js +27 -0
  12. package/esm2015/lib/components/input-phone/input-phone.component.ngsummary.json +1 -0
  13. package/esm2015/lib/components/input-phone/input-phone.module.js +25 -0
  14. package/esm2015/lib/components/input-phone/input-phone.module.ngfactory.js +18 -0
  15. package/esm2015/lib/components/input-phone/input-phone.module.ngsummary.json +1 -0
  16. package/esm2015/monkey-style-guide.ngsummary.json +1 -1
  17. package/esm2015/public-api.ngsummary.json +1 -1
  18. package/fesm2015/monkey-style-guide.js +225 -6
  19. package/fesm2015/monkey-style-guide.js.map +1 -1
  20. package/lib/components/index.d.ts +1 -0
  21. package/lib/components/input-phone/index.d.ts +2 -0
  22. package/lib/components/input-phone/input-phone.component.d.ts +61 -0
  23. package/lib/components/input-phone/input-phone.component.ngfactory.d.ts +1 -0
  24. package/lib/components/input-phone/input-phone.module.d.ts +2 -0
  25. package/lib/components/input-phone/input-phone.module.ngfactory.d.ts +3 -0
  26. package/monkey-style-guide-2.0.88.tgz +0 -0
  27. package/monkey-style-guide.metadata.json +1 -1
  28. package/package.json +3 -2
  29. package/monkey-style-guide-2.0.86.tgz +0 -0
@@ -6,6 +6,7 @@ import { FormsModule, ReactiveFormsModule, Validators, NG_VALUE_ACCESSOR, FormBu
6
6
  import { takeUntil } from 'rxjs/operators';
7
7
  import * as moment_ from 'moment';
8
8
  import { NgxMaskModule } from 'ngx-mask';
9
+ import { PhoneNumberUtil, AsYouTypeFormatter, PhoneNumberFormat } from 'google-libphonenumber';
9
10
  import { DomSanitizer } from '@angular/platform-browser';
10
11
 
11
12
  class MonkeyStyleGuideService {
@@ -2127,10 +2128,13 @@ class MonkeyDateRangePickerComponent {
2127
2128
  this.onModelTouched = fn;
2128
2129
  }
2129
2130
  set value(value) {
2130
- this._dateForm.setValue(value);
2131
- this.cdr.detectChanges();
2132
- this.onModelChange(this._dateForm.value);
2133
- this.onModelTouched(this._dateForm.value);
2131
+ if (Object.prototype.hasOwnProperty.call(value, 'startDate') &&
2132
+ Object.prototype.hasOwnProperty.call(value, 'endDate')) {
2133
+ this._dateForm.setValue(value);
2134
+ this.cdr.detectChanges();
2135
+ this.onModelChange(this._dateForm.value);
2136
+ this.onModelTouched(this._dateForm.value);
2137
+ }
2134
2138
  }
2135
2139
  get value() {
2136
2140
  return this._dateForm.value;
@@ -2185,7 +2189,7 @@ class MonkeyDateRangePickerComponent {
2185
2189
  let dayFormatted = day.format('YYYY-MM-DD');
2186
2190
  if (_dateForm.valid) {
2187
2191
  _dateForm.setValue({ startDate: null, endDate: null });
2188
- this.writeValue(null);
2192
+ this.writeValue(_dateForm.value);
2189
2193
  return;
2190
2194
  }
2191
2195
  if (!_dateForm.get('startDate').value) {
@@ -2827,6 +2831,203 @@ MonkeyInputModule.decorators = [
2827
2831
  },] }
2828
2832
  ];
2829
2833
 
2834
+ /**************************
2835
+ * Copyright Monkey Exchange. All Rights Reserved
2836
+ * This style guide was developed by Monkey Exchange Team
2837
+ * MIT Licence
2838
+ **************************/
2839
+ const phoneUtil = PhoneNumberUtil.getInstance();
2840
+ const formatter = new AsYouTypeFormatter('US');
2841
+ class MonkeyInputPhoneComponent {
2842
+ constructor(currencyPipe, settingsService, cdr) {
2843
+ this.currencyPipe = currencyPipe;
2844
+ this.settingsService = settingsService;
2845
+ this.cdr = cdr;
2846
+ this.name = `mecx-input-phone-${MonkeyUtils.getRandomString(10)}`;
2847
+ this.helperMessage = '';
2848
+ this.placeholder = '';
2849
+ this.maxLength = 255;
2850
+ this.maxDateToday = false;
2851
+ this.onChange = new EventEmitter();
2852
+ this.onModelChange = (value) => { };
2853
+ this.onModelTouched = (value) => { };
2854
+ this._id = `mecx-input-phone-${MonkeyUtils.getRandomString(10)}`;
2855
+ this._disabled = false;
2856
+ this._maxDateToday = new Date().toISOString().split('T')[0];
2857
+ this._symbol = '';
2858
+ this._countryCodes = [];
2859
+ }
2860
+ handleValue(value, apply = false) {
2861
+ if (this.onlyNumber) {
2862
+ return MonkeyUtils.handleOnlyNumbers(`${value}`);
2863
+ }
2864
+ else if (this.onlyAlphaNumeric)
2865
+ return MonkeyUtils.handleOnlyAlphaNumeric(`${value}`);
2866
+ else if (this.upperCase)
2867
+ return `${value}`.toUpperCase();
2868
+ else if (this.lowerCase)
2869
+ return `${value}`.toLowerCase();
2870
+ else if (this.capitalize)
2871
+ return MonkeyUtils.capitalize(`${value}`.toUpperCase());
2872
+ else if (this.currency || this.percent) {
2873
+ return MonkeyUtils.handleOnlyNumbers(`${value}`) / (apply ? 100 : 1);
2874
+ }
2875
+ return value;
2876
+ }
2877
+ replaceZero(value) {
2878
+ return `${value}`.replace(new RegExp(/0/, 'g'), '');
2879
+ }
2880
+ formatValue(value) {
2881
+ //console.log(this.phoneUtil);
2882
+ //console.log(this.phoneUtil.formatInOriginalFormat(value, 'US'));
2883
+ //this.phoneUtil.inputDigit('2');
2884
+ console.log(formatter.inputDigit(value));
2885
+ const number = phoneUtil.parse(value, 'BR');
2886
+ console.log(phoneUtil.isPossibleNumber(number));
2887
+ console.log(phoneUtil.format(number, PhoneNumberFormat.INTERNATIONAL));
2888
+ return phoneUtil.format(number, PhoneNumberFormat.INTERNATIONAL);
2889
+ }
2890
+ handleSymbol() {
2891
+ var _a;
2892
+ const { settings } = this;
2893
+ if (this.currency) {
2894
+ this._symbol = {
2895
+ BRL: 'R$',
2896
+ CLP: 'CLP',
2897
+ }[((_a = settings === null || settings === void 0 ? void 0 : settings.currency) === null || _a === void 0 ? void 0 : _a.code) || 'BRL'];
2898
+ }
2899
+ else if (this.percent) {
2900
+ this._symbol = '%';
2901
+ }
2902
+ }
2903
+ ngOnInit() {
2904
+ const { settingsService } = this;
2905
+ this._oldType = this.type;
2906
+ settingsService.settings().subscribe((val) => {
2907
+ this.settings = val;
2908
+ this.handleSymbol();
2909
+ });
2910
+ this._countryCodes = phoneUtil
2911
+ .getSupportedRegions()
2912
+ .map((code) => {
2913
+ return phoneUtil.getCountryCodeForRegion(code);
2914
+ })
2915
+ .filter((v, i, a) => a.indexOf(v) === i)
2916
+ .sort((a, b) => (a < b ? -1 : 1));
2917
+ }
2918
+ registerOnChange(fn) {
2919
+ this.onModelChange = fn;
2920
+ }
2921
+ registerOnTouched(fn) {
2922
+ this.onModelTouched = fn;
2923
+ }
2924
+ setDisabledState(isDisabled) {
2925
+ this._disabled = isDisabled;
2926
+ }
2927
+ set value(value) {
2928
+ this.handledValue = value;
2929
+ this._formatedValue = this.formatValue(value);
2930
+ this.cdr.detectChanges();
2931
+ this.onModelChange(this.handledValue);
2932
+ this.onModelTouched(this.handledValue);
2933
+ }
2934
+ get value() {
2935
+ return this.handledValue;
2936
+ }
2937
+ writeValue(value) {
2938
+ this.value = value;
2939
+ }
2940
+ onChangeValue(event) {
2941
+ const value = this._formatedValue;
2942
+ event === null || event === void 0 ? void 0 : event.preventDefault();
2943
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
2944
+ const handled = this.handleValue(value, true);
2945
+ this.writeValue(handled);
2946
+ this.onChange.next(handled);
2947
+ }
2948
+ onShowAndHidePassword() {
2949
+ this.type = this.type === 'password' ? 'text' : 'password';
2950
+ }
2951
+ onClick() {
2952
+ var _a, _b, _c;
2953
+ (_c = (_b = (_a = document === null || document === void 0 ? void 0 : document.getElementById(this._id)) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('input')) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.focus();
2954
+ }
2955
+ onKeyPress(event) {
2956
+ var _a;
2957
+ let pattern = null;
2958
+ const cmp = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value;
2959
+ const inputChar = String.fromCharCode(event.charCode);
2960
+ if (this.currency || this.onlyNumber || this.percent) {
2961
+ pattern = /[0-9]/;
2962
+ if (inputChar === '0' && !this.replaceZero(cmp)) {
2963
+ event.preventDefault();
2964
+ return;
2965
+ }
2966
+ }
2967
+ else if (this.onlyAlphaNumeric) {
2968
+ pattern = /[^0-9A-Za-z]/;
2969
+ }
2970
+ if (pattern && !pattern.test(inputChar)) {
2971
+ event.preventDefault();
2972
+ }
2973
+ }
2974
+ }
2975
+ MonkeyInputPhoneComponent.decorators = [
2976
+ { type: Component, args: [{
2977
+ selector: 'monkey-input-phone',
2978
+ template: `
2979
+ <monkey-select
2980
+ [label]="'teste'"
2981
+ errorMessage=""
2982
+ errorMessage=""
2983
+ [placeholder]="'Selecione um banco'"
2984
+ >
2985
+ <monkey-option label="op" value="op"> </monkey-option>
2986
+ <monkey-option label="op" value="op"> </monkey-option>
2987
+ <monkey-option label="op" value="op"> </monkey-option>
2988
+ </monkey-select>
2989
+ `,
2990
+ encapsulation: ViewEncapsulation.None,
2991
+ providers: [
2992
+ {
2993
+ provide: NG_VALUE_ACCESSOR,
2994
+ useExisting: forwardRef(() => MonkeyInputPhoneComponent),
2995
+ multi: true,
2996
+ },
2997
+ CurrencyPipe,
2998
+ ]
2999
+ },] }
3000
+ ];
3001
+ MonkeyInputPhoneComponent.ctorParameters = () => [
3002
+ { type: CurrencyPipe },
3003
+ { type: MonkeyStyleGuideSettingsService },
3004
+ { type: ChangeDetectorRef }
3005
+ ];
3006
+ MonkeyInputPhoneComponent.propDecorators = {
3007
+ name: [{ type: Input }],
3008
+ label: [{ type: Input }],
3009
+ helperMessage: [{ type: Input }],
3010
+ placeholder: [{ type: Input }],
3011
+ icon: [{ type: Input }],
3012
+ type: [{ type: Input }],
3013
+ infoMessage: [{ type: Input }],
3014
+ errorMessage: [{ type: Input }],
3015
+ mask: [{ type: Input }],
3016
+ prefix: [{ type: Input }],
3017
+ maxLength: [{ type: Input }],
3018
+ onlyNumber: [{ type: Input }],
3019
+ onlyAlphaNumeric: [{ type: Input }],
3020
+ upperCase: [{ type: Input }],
3021
+ lowerCase: [{ type: Input }],
3022
+ capitalize: [{ type: Input }],
3023
+ currency: [{ type: Input }],
3024
+ percent: [{ type: Input }],
3025
+ maxDateToday: [{ type: Input }],
3026
+ onChange: [{ type: Output }],
3027
+ value: [{ type: Input }],
3028
+ onClick: [{ type: HostListener, args: ['click',] }]
3029
+ };
3030
+
2830
3031
  /**************************
2831
3032
  * Copyright Monkey Exchange. All Rights Reserved
2832
3033
  * This style guide was developed by Monkey Exchange Team
@@ -3764,6 +3965,24 @@ MonkeySelectModule.decorators = [
3764
3965
  },] }
3765
3966
  ];
3766
3967
 
3968
+ class MonkeyInputPhoneModule {
3969
+ }
3970
+ MonkeyInputPhoneModule.decorators = [
3971
+ { type: NgModule, args: [{
3972
+ declarations: [MonkeyInputPhoneComponent],
3973
+ imports: [
3974
+ CommonModule,
3975
+ FormsModule,
3976
+ ReactiveFormsModule,
3977
+ NgxMaskModule.forRoot(),
3978
+ MonkeyIconModule,
3979
+ MonkeySelectModule,
3980
+ ],
3981
+ exports: [MonkeyInputPhoneComponent],
3982
+ schemas: [NO_ERRORS_SCHEMA],
3983
+ },] }
3984
+ ];
3985
+
3767
3986
  /**************************
3768
3987
  * Copyright Monkey Exchange. All Rights Reserved
3769
3988
  * This style guide was developed by Monkey Exchange Team
@@ -5389,5 +5608,5 @@ MonkeyStyleGuideModule.decorators = [
5389
5608
  * Generated bundle index. Do not edit.
5390
5609
  */
5391
5610
 
5392
- export { MonkeyBadgeComponent, MonkeyBadgeModule, MonkeyButtonAvatarComponent, MonkeyButtonComponent, MonkeyButtonDropdownComponent, MonkeyButtonModule, MonkeyCheckboxComponent, MonkeyCheckboxModule, MonkeyDateRangePickerComponent, MonkeyDateRangePickerModule, MonkeyExpansionComponent, MonkeyExpansionModule, MonkeyFileUploadComponent, MonkeyFileUploadModule, MonkeyIconArrowDownComponent, MonkeyIconArrowLeftComponent, MonkeyIconArrowRightComponent, MonkeyIconArrowUpComponent, MonkeyIconBankComponent, MonkeyIconBellComponent, MonkeyIconBookComponent, MonkeyIconBoxComponent, MonkeyIconCNPJComponent, MonkeyIconCalendarComponent, MonkeyIconCameraComponent, MonkeyIconChatComponent, MonkeyIconCheckCircleComponent, MonkeyIconCheckCircleOutComponent, MonkeyIconCheckComponent, MonkeyIconCheckGreyComponent, MonkeyIconCheckWhiteComponent, MonkeyIconClipboardComponent, MonkeyIconClockComponent, MonkeyIconCloseComponent, MonkeyIconCodepenComponent, MonkeyIconCompanyNameComponent, MonkeyIconComponent, MonkeyIconContractComponent, MonkeyIconDeleteComponent, MonkeyIconDocumentComponent, MonkeyIconDollarSignComponent, MonkeyIconDomainComponent, MonkeyIconDownloadComponent, MonkeyIconEditComponent, MonkeyIconEmailComponent, MonkeyIconEmptyDocComponent, MonkeyIconErrorComponent, MonkeyIconEyeClosedComponent, MonkeyIconEyeOpenComponent, MonkeyIconFilterComponent, MonkeyIconGridComponent, MonkeyIconHelpComponent, MonkeyIconHexagonComponent, MonkeyIconHomeComponent, MonkeyIconImageComponent, MonkeyIconListComponent, MonkeyIconLocationPinComponent, MonkeyIconLoginComponent, MonkeyIconLogoutComponent, MonkeyIconMenuComponent, MonkeyIconModule, MonkeyIconMoneySignComponent, MonkeyIconMoreComponent, MonkeyIconOfferedComponent, MonkeyIconPasswordComponent, MonkeyIconPeopleComponent, MonkeyIconPercentComponent, MonkeyIconPersonDocumentComponent, MonkeyIconPersonSadComponent, MonkeyIconPhoneComponent, MonkeyIconPorkComponent, MonkeyIconRefreshComponent, MonkeyIconRepeatComponent, MonkeyIconSearchComponent, MonkeyIconSecondWarningComponent, MonkeyIconSettingsComponent, MonkeyIconTrashComponent, MonkeyIconUploadComponent, MonkeyIconUserComponent, MonkeyIconWalletComponent, MonkeyIconWarningComponent, MonkeyImageCropComponent, MonkeyImageCropModule, MonkeyInputComponent, MonkeyInputFilterComponent, MonkeyInputModule, MonkeyModalComponent, MonkeyModalModule, MonkeyOptionComponent, MonkeyOptionModule, MonkeyRadioButtonComponent, MonkeyRadioButtonModule, MonkeySelectComponent, MonkeySelectFilterComponent, MonkeySelectModule, MonkeySelectMultipleComponent, MonkeySelectSearchComponent, MonkeyStepperComponent, MonkeyStepperModule, MonkeyStyleGuideModalFixedService, MonkeyStyleGuideModalService, MonkeyStyleGuideModule, MonkeyStyleGuideSettingsService, MonkeyStyleGuideSnackbarService, MonkeyTabComponent, MonkeyTabModule, MonkeyTableColumnComponent, MonkeyTableComponent, MonkeyTableModule, MonkeyToggleComponent, MonkeyToggleModule, MonkeyUtils, MonkeyWizardComponent, MonkeyWizardModule, ɵ0, MonkeyStyleGuideService as ɵa, MonkeyStyleGuideSettingsService as ɵb, MonkeyStyleGuideThemeSettingsService as ɵc, MonkeyStyleGuideSnackbarService as ɵd };
5611
+ export { MonkeyBadgeComponent, MonkeyBadgeModule, MonkeyButtonAvatarComponent, MonkeyButtonComponent, MonkeyButtonDropdownComponent, MonkeyButtonModule, MonkeyCheckboxComponent, MonkeyCheckboxModule, MonkeyDateRangePickerComponent, MonkeyDateRangePickerModule, MonkeyExpansionComponent, MonkeyExpansionModule, MonkeyFileUploadComponent, MonkeyFileUploadModule, MonkeyIconArrowDownComponent, MonkeyIconArrowLeftComponent, MonkeyIconArrowRightComponent, MonkeyIconArrowUpComponent, MonkeyIconBankComponent, MonkeyIconBellComponent, MonkeyIconBookComponent, MonkeyIconBoxComponent, MonkeyIconCNPJComponent, MonkeyIconCalendarComponent, MonkeyIconCameraComponent, MonkeyIconChatComponent, MonkeyIconCheckCircleComponent, MonkeyIconCheckCircleOutComponent, MonkeyIconCheckComponent, MonkeyIconCheckGreyComponent, MonkeyIconCheckWhiteComponent, MonkeyIconClipboardComponent, MonkeyIconClockComponent, MonkeyIconCloseComponent, MonkeyIconCodepenComponent, MonkeyIconCompanyNameComponent, MonkeyIconComponent, MonkeyIconContractComponent, MonkeyIconDeleteComponent, MonkeyIconDocumentComponent, MonkeyIconDollarSignComponent, MonkeyIconDomainComponent, MonkeyIconDownloadComponent, MonkeyIconEditComponent, MonkeyIconEmailComponent, MonkeyIconEmptyDocComponent, MonkeyIconErrorComponent, MonkeyIconEyeClosedComponent, MonkeyIconEyeOpenComponent, MonkeyIconFilterComponent, MonkeyIconGridComponent, MonkeyIconHelpComponent, MonkeyIconHexagonComponent, MonkeyIconHomeComponent, MonkeyIconImageComponent, MonkeyIconListComponent, MonkeyIconLocationPinComponent, MonkeyIconLoginComponent, MonkeyIconLogoutComponent, MonkeyIconMenuComponent, MonkeyIconModule, MonkeyIconMoneySignComponent, MonkeyIconMoreComponent, MonkeyIconOfferedComponent, MonkeyIconPasswordComponent, MonkeyIconPeopleComponent, MonkeyIconPercentComponent, MonkeyIconPersonDocumentComponent, MonkeyIconPersonSadComponent, MonkeyIconPhoneComponent, MonkeyIconPorkComponent, MonkeyIconRefreshComponent, MonkeyIconRepeatComponent, MonkeyIconSearchComponent, MonkeyIconSecondWarningComponent, MonkeyIconSettingsComponent, MonkeyIconTrashComponent, MonkeyIconUploadComponent, MonkeyIconUserComponent, MonkeyIconWalletComponent, MonkeyIconWarningComponent, MonkeyImageCropComponent, MonkeyImageCropModule, MonkeyInputComponent, MonkeyInputFilterComponent, MonkeyInputModule, MonkeyInputPhoneComponent, MonkeyInputPhoneModule, MonkeyModalComponent, MonkeyModalModule, MonkeyOptionComponent, MonkeyOptionModule, MonkeyRadioButtonComponent, MonkeyRadioButtonModule, MonkeySelectComponent, MonkeySelectFilterComponent, MonkeySelectModule, MonkeySelectMultipleComponent, MonkeySelectSearchComponent, MonkeyStepperComponent, MonkeyStepperModule, MonkeyStyleGuideModalFixedService, MonkeyStyleGuideModalService, MonkeyStyleGuideModule, MonkeyStyleGuideSettingsService, MonkeyStyleGuideSnackbarService, MonkeyTabComponent, MonkeyTabModule, MonkeyTableColumnComponent, MonkeyTableComponent, MonkeyTableModule, MonkeyToggleComponent, MonkeyToggleModule, MonkeyUtils, MonkeyWizardComponent, MonkeyWizardModule, ɵ0, MonkeyStyleGuideService as ɵa, MonkeyStyleGuideSettingsService as ɵb, MonkeyStyleGuideThemeSettingsService as ɵc, MonkeyStyleGuideSnackbarService as ɵd };
5393
5612
  //# sourceMappingURL=monkey-style-guide.js.map