@sneat/auth-ui 0.27.0 → 0.27.1

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.
@@ -62,7 +62,7 @@ export class UserRequiredFieldsModalComponent extends SneatBaseComponent {
62
62
  this.userRecordService.initUserRecord(request).subscribe({
63
63
  next: () => this.modalController.dismiss(true).catch(console.error),
64
64
  error: (err) => {
65
- this.errorLogger.logError('Failed to init user record:', err);
65
+ this.errorLogger.logError(err, 'Failed to init user record:');
66
66
  alert('Failed to init user record');
67
67
  this.submitting = false;
68
68
  },
@@ -1 +1 @@
1
- {"version":3,"file":"user-required-fields-modal.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/components/user-required-fields/user-required-fields-modal.component.ts","../../../../../../../../libs/auth/ui/src/lib/components/user-required-fields/user-required-fields-modal.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,uBAAuB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EACL,WAAW,EACX,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,OAAO,EACP,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAe,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;;;AA8BjC,MAAM,OAAO,gCAAiC,SAAQ,kBAAkB;IAmCtE;QACE,KAAK,EAAE,CAAC;QAnC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AQ,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;gBAC9D,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBACpC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YAC1B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAES,KAAK;QACb,IAAI,CAAC,eAAe;aACjB,OAAO,CAAC,KAAK,CAAC;aACd,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACtE,CAAC;8GA7EU,gCAAgC;kGAAhC,gCAAgC,iNAPhC;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,kCAAkC;aAC7C;SACF,iDC7DH,8iDAgEA,2CDzBI,WAAW,onBACX,mBAAmB,mWACnB,uBAAuB,8WACvB,SAAS,oGACT,UAAU,mFACV,QAAQ,iFACR,UAAU,8EACV,SAAS,sRACT,OAAO,2JACP,UAAU,kOACV,OAAO,0NACP,QAAQ,8eACR,cAAc,kGACd,QAAQ,6FACR,SAAS;;2FAUA,gCAAgC;kBA5B5C,SAAS;+BACE,iCAAiC,WAElC;wBACP,WAAW;wBACX,mBAAmB;wBACnB,uBAAuB;wBACvB,SAAS;wBACT,UAAU;wBACV,QAAQ;wBACR,UAAU;wBACV,SAAS;wBACT,OAAO;wBACP,UAAU;wBACV,OAAO;wBACP,QAAQ;wBACR,cAAc;wBACd,QAAQ;wBACR,SAAS;qBACV,mBACgB,uBAAuB,CAAC,MAAM,aACpC;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,kCAAkC;yBAC7C;qBACF","sourcesContent":["import { Component, inject, ChangeDetectionStrategy, input } from '@angular/core';\nimport {\n FormControl,\n FormGroup,\n FormsModule,\n ReactiveFormsModule,\n Validators,\n} from '@angular/forms';\nimport {\n IonButton,\n IonButtons,\n IonContent,\n IonFooter,\n IonHeader,\n IonIcon,\n IonInput,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonTitle,\n IonToolbar,\n ModalController,\n} from '@ionic/angular';\nimport {\n IInitUserRecordRequest,\n ISneatUserState,\n SneatUserService,\n UserRecordService,\n} from '@sneat/auth-core';\nimport { AgeGroupID, Gender } from '@sneat/core';\nimport { ClassName, ISelectItem, SelectFromListComponent } from '@sneat/ui';\nimport { ISpaceContext } from '@sneat/space-models';\nimport { SneatBaseComponent } from '@sneat/ui';\nimport { takeUntil } from 'rxjs';\n\n@Component({\n selector: 'sneat-user-required-fields-form',\n templateUrl: './user-required-fields-modal.component.html',\n imports: [\n FormsModule,\n ReactiveFormsModule,\n SelectFromListComponent,\n IonHeader,\n IonToolbar,\n IonTitle,\n IonButtons,\n IonButton,\n IonIcon,\n IonContent,\n IonItem,\n IonInput,\n IonItemDivider,\n IonLabel,\n IonFooter,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: ClassName,\n useValue: 'UserRequiredFieldsModalComponent',\n },\n ],\n})\nexport class UserRequiredFieldsModalComponent extends SneatBaseComponent {\n private readonly modalController = inject(ModalController);\n private readonly userRecordService = inject(UserRecordService);\n private readonly sneatUserService = inject(SneatUserService);\n\n readonly space = input.required<ISpaceContext>();\n\n protected readonly genders: ISelectItem[] = [\n { id: 'male', emoji: '♂️', title: 'Male' },\n { id: 'female', emoji: '♀️', title: 'Female' },\n { id: 'other', emoji: '⚥', title: 'Other' },\n { id: 'undisclosed', iconName: 'body', title: 'Undisclosed' },\n ];\n\n protected readonly ageGroups: ISelectItem[] = [\n { id: 'adult', emoji: '🧓', title: 'Adult' },\n { id: 'child', emoji: '🧒', title: 'Child' },\n ];\n\n protected readonly firstName = new FormControl('', Validators.required);\n protected readonly lastName = new FormControl('', Validators.required);\n protected readonly gender = new FormControl('', Validators.required);\n protected readonly ageGroup = new FormControl('', Validators.required);\n\n protected readonly form = new FormGroup({\n firstName: this.firstName,\n lastName: this.lastName,\n gender: this.gender,\n ageGroup: this.ageGroup,\n });\n\n protected submitting = false;\n\n protected userState?: ISneatUserState;\n\n constructor() {\n super();\n this.sneatUserService.userState.pipe(takeUntil(this.destroyed$)).subscribe({\n next: (userState) => (this.userState = userState),\n });\n }\n\n protected save(): void {\n this.submitting = true;\n if (!this.form.valid) {\n setTimeout(() => {\n alert('Please fill in all fields.');\n this.submitting = false;\n });\n return;\n }\n\n const gender = this.gender.value as Gender;\n const ageGroup = this.ageGroup.value as AgeGroupID;\n\n const request: IInitUserRecordRequest = {\n names: {\n firstName: this.firstName.value || undefined,\n lastName: this.lastName.value || undefined,\n },\n gender,\n ageGroup,\n };\n this.userRecordService.initUserRecord(request).subscribe({\n next: () => this.modalController.dismiss(true).catch(console.error),\n error: (err) => {\n this.errorLogger.logError('Failed to init user record:', err);\n alert('Failed to init user record');\n this.submitting = false;\n },\n });\n }\n\n protected close(): void {\n this.modalController\n .dismiss(false)\n .catch(this.errorLogger.logErrorHandler('Failed to close modal'));\n }\n}\n","<ion-header>\n <ion-toolbar color=\"primary\">\n <ion-title>About me</ion-title>\n <ion-buttons slot=\"end\">\n <ion-button (click)=\"close()\">\n <ion-icon name=\"close-outline\" />\n </ion-button>\n </ion-buttons>\n </ion-toolbar>\n</ion-header>\n<ion-content>\n <form (ngSubmit)=\"save()\" [formGroup]=\"form\">\n <ion-item>\n <ion-input\n label=\"First name\"\n name=\"first_name\"\n type=\"text\"\n required\n max=\"20\"\n [formControl]=\"firstName\"\n />\n </ion-item>\n <ion-item>\n <ion-input\n label=\"Last name\"\n name=\"last_name\"\n type=\"text\"\n required\n max=\"20\"\n [formControl]=\"lastName\"\n />\n </ion-item>\n @if (!gender.value) {\n <ion-item-divider>\n <ion-label>Gender</ion-label>\n </ion-item-divider>\n }\n <sneat-select-from-list\n label=\"Gender\"\n [items]=\"genders\"\n [formControl]=\"gender\"\n />\n\n @if (gender.value || ageGroup.value) {\n @if (!ageGroup.value) {\n <ion-item-divider>\n <ion-label>Age group</ion-label>\n </ion-item-divider>\n }\n <sneat-select-from-list\n label=\"Age group\"\n [items]=\"ageGroups\"\n [formControl]=\"ageGroup\"\n />\n }\n </form>\n</ion-content>\n<ion-footer>\n <ion-toolbar>\n <ion-buttons slot=\"end\">\n <ion-button [disabled]=\"submitting\" (click)=\"save()\">Save</ion-button>\n </ion-buttons>\n </ion-toolbar>\n</ion-footer>\n"]}
1
+ {"version":3,"file":"user-required-fields-modal.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/components/user-required-fields/user-required-fields-modal.component.ts","../../../../../../../../libs/auth/ui/src/lib/components/user-required-fields/user-required-fields-modal.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,uBAAuB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EACL,WAAW,EACX,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,OAAO,EACP,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAe,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;;;AA8BjC,MAAM,OAAO,gCAAiC,SAAQ,kBAAkB;IAmCtE;QACE,KAAK,EAAE,CAAC;QAnCO,oBAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;QAC1C,sBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC9C,qBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAEpD,UAAK,GAAG,KAAK,CAAC,QAAQ;kFAAiB,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;aACjB,OAAO,CAAC,KAAK,CAAC;aACd,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACtE,CAAC;8GA7EU,gCAAgC;kGAAhC,gCAAgC,iNAPhC;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,kCAAkC;aAC7C;SACF,iDC7DH,8iDAgEA,2CDzBI,WAAW,onBACX,mBAAmB,mWACnB,uBAAuB,8WACvB,SAAS,oGACT,UAAU,mFACV,QAAQ,iFACR,UAAU,8EACV,SAAS,sRACT,OAAO,2JACP,UAAU,kOACV,OAAO,0NACP,QAAQ,8eACR,cAAc,kGACd,QAAQ,6FACR,SAAS;;2FAUA,gCAAgC;kBA5B5C,SAAS;+BACE,iCAAiC,WAElC;wBACP,WAAW;wBACX,mBAAmB;wBACnB,uBAAuB;wBACvB,SAAS;wBACT,UAAU;wBACV,QAAQ;wBACR,UAAU;wBACV,SAAS;wBACT,OAAO;wBACP,UAAU;wBACV,OAAO;wBACP,QAAQ;wBACR,cAAc;wBACd,QAAQ;wBACR,SAAS;qBACV,mBACgB,uBAAuB,CAAC,MAAM,aACpC;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,kCAAkC;yBAC7C;qBACF","sourcesContent":["import { Component, inject, ChangeDetectionStrategy, input } from '@angular/core';\nimport {\n FormControl,\n FormGroup,\n FormsModule,\n ReactiveFormsModule,\n Validators,\n} from '@angular/forms';\nimport {\n IonButton,\n IonButtons,\n IonContent,\n IonFooter,\n IonHeader,\n IonIcon,\n IonInput,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonTitle,\n IonToolbar,\n ModalController,\n} from '@ionic/angular';\nimport {\n IInitUserRecordRequest,\n ISneatUserState,\n SneatUserService,\n UserRecordService,\n} from '@sneat/auth-core';\nimport { AgeGroupID, Gender } from '@sneat/core';\nimport { ClassName, ISelectItem, SelectFromListComponent } from '@sneat/ui';\nimport { ISpaceContext } from '@sneat/space-models';\nimport { SneatBaseComponent } from '@sneat/ui';\nimport { takeUntil } from 'rxjs';\n\n@Component({\n selector: 'sneat-user-required-fields-form',\n templateUrl: './user-required-fields-modal.component.html',\n imports: [\n FormsModule,\n ReactiveFormsModule,\n SelectFromListComponent,\n IonHeader,\n IonToolbar,\n IonTitle,\n IonButtons,\n IonButton,\n IonIcon,\n IonContent,\n IonItem,\n IonInput,\n IonItemDivider,\n IonLabel,\n IonFooter,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: ClassName,\n useValue: 'UserRequiredFieldsModalComponent',\n },\n ],\n})\nexport class UserRequiredFieldsModalComponent extends SneatBaseComponent {\n private readonly modalController = inject(ModalController);\n private readonly userRecordService = inject(UserRecordService);\n private readonly sneatUserService = inject(SneatUserService);\n\n readonly space = input.required<ISpaceContext>();\n\n protected readonly genders: ISelectItem[] = [\n { id: 'male', emoji: '♂️', title: 'Male' },\n { id: 'female', emoji: '♀️', title: 'Female' },\n { id: 'other', emoji: '⚥', title: 'Other' },\n { id: 'undisclosed', iconName: 'body', title: 'Undisclosed' },\n ];\n\n protected readonly ageGroups: ISelectItem[] = [\n { id: 'adult', emoji: '🧓', title: 'Adult' },\n { id: 'child', emoji: '🧒', title: 'Child' },\n ];\n\n protected readonly firstName = new FormControl('', Validators.required);\n protected readonly lastName = new FormControl('', Validators.required);\n protected readonly gender = new FormControl('', Validators.required);\n protected readonly ageGroup = new FormControl('', Validators.required);\n\n protected readonly form = new FormGroup({\n firstName: this.firstName,\n lastName: this.lastName,\n gender: this.gender,\n ageGroup: this.ageGroup,\n });\n\n protected submitting = false;\n\n protected userState?: ISneatUserState;\n\n constructor() {\n super();\n this.sneatUserService.userState.pipe(takeUntil(this.destroyed$)).subscribe({\n next: (userState) => (this.userState = userState),\n });\n }\n\n protected save(): void {\n this.submitting = true;\n if (!this.form.valid) {\n setTimeout(() => {\n alert('Please fill in all fields.');\n this.submitting = false;\n });\n return;\n }\n\n const gender = this.gender.value as Gender;\n const ageGroup = this.ageGroup.value as AgeGroupID;\n\n const request: IInitUserRecordRequest = {\n names: {\n firstName: this.firstName.value || undefined,\n lastName: this.lastName.value || undefined,\n },\n gender,\n ageGroup,\n };\n this.userRecordService.initUserRecord(request).subscribe({\n next: () => this.modalController.dismiss(true).catch(console.error),\n error: (err) => {\n this.errorLogger.logError(err, 'Failed to init user record:');\n alert('Failed to init user record');\n this.submitting = false;\n },\n });\n }\n\n protected close(): void {\n this.modalController\n .dismiss(false)\n .catch(this.errorLogger.logErrorHandler('Failed to close modal'));\n }\n}\n","<ion-header>\n <ion-toolbar color=\"primary\">\n <ion-title>About me</ion-title>\n <ion-buttons slot=\"end\">\n <ion-button (click)=\"close()\">\n <ion-icon name=\"close-outline\" />\n </ion-button>\n </ion-buttons>\n </ion-toolbar>\n</ion-header>\n<ion-content>\n <form (ngSubmit)=\"save()\" [formGroup]=\"form\">\n <ion-item>\n <ion-input\n label=\"First name\"\n name=\"first_name\"\n type=\"text\"\n required\n max=\"20\"\n [formControl]=\"firstName\"\n />\n </ion-item>\n <ion-item>\n <ion-input\n label=\"Last name\"\n name=\"last_name\"\n type=\"text\"\n required\n max=\"20\"\n [formControl]=\"lastName\"\n />\n </ion-item>\n @if (!gender.value) {\n <ion-item-divider>\n <ion-label>Gender</ion-label>\n </ion-item-divider>\n }\n <sneat-select-from-list\n label=\"Gender\"\n [items]=\"genders\"\n [formControl]=\"gender\"\n />\n\n @if (gender.value || ageGroup.value) {\n @if (!ageGroup.value) {\n <ion-item-divider>\n <ion-label>Age group</ion-label>\n </ion-item-divider>\n }\n <sneat-select-from-list\n label=\"Age group\"\n [items]=\"ageGroups\"\n [formControl]=\"ageGroup\"\n />\n }\n </form>\n</ion-content>\n<ion-footer>\n <ion-toolbar>\n <ion-buttons slot=\"end\">\n <ion-button [disabled]=\"submitting\" (click)=\"save()\">Save</ion-button>\n </ion-buttons>\n </ion-toolbar>\n</ion-footer>\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sneat/auth-ui",
3
- "version": "0.27.0",
3
+ "version": "0.27.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },