@valtimo/components 10.8.1 → 10.8.3

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.
@@ -4780,43 +4780,50 @@ class FormioComponent {
4780
4780
  this.route = route;
4781
4781
  this.translateService = translateService;
4782
4782
  this.modalService = modalService;
4783
- this.submission = {};
4784
4783
  // eslint-disable-next-line @angular-eslint/no-output-native
4785
4784
  this.submit = new EventEmitter();
4786
4785
  // eslint-disable-next-line @angular-eslint/no-output-native
4787
4786
  this.change = new EventEmitter();
4788
4787
  this.refreshForm = new EventEmitter();
4789
- this.errors = [];
4788
+ this.submission$ = new BehaviorSubject(undefined);
4789
+ this.form$ = new BehaviorSubject(undefined);
4790
+ this.options$ = new BehaviorSubject(undefined);
4791
+ this.readOnly$ = new BehaviorSubject(false);
4792
+ this.errors$ = new BehaviorSubject([]);
4790
4793
  this.currentLanguage$ = this.translateService.stream('key').pipe(map$1(() => this.translateService.currentLang), distinctUntilChanged());
4791
- this.formioOptions$ = this.currentLanguage$.pipe(map$1(language => {
4794
+ this.formioOptions$ = combineLatest([
4795
+ this.currentLanguage$,
4796
+ this.options$,
4797
+ ]).pipe(map$1(([language, options]) => {
4792
4798
  const formioTranslations = this.translateService.instant('formioTranslations');
4793
4799
  return typeof formioTranslations === 'object'
4794
- ? Object.assign(Object.assign({}, this.options), { i18n: {
4800
+ ? Object.assign(Object.assign({}, options), { i18n: {
4795
4801
  [language]: this.stateService.flattenTranslationsObject(formioTranslations),
4796
- }, language }) : Object.assign(Object.assign({}, this.options), { language });
4802
+ }, language }) : Object.assign(Object.assign({}, options), { language });
4797
4803
  }));
4804
+ this._subscriptions = new Subscription();
4805
+ }
4806
+ set options(optionsValue) {
4807
+ this.options$.next(optionsValue);
4808
+ }
4809
+ set submission(submissionValue) {
4810
+ this.submission$.next(submissionValue);
4811
+ }
4812
+ set form(formValue) {
4813
+ this.form$.next(formValue);
4814
+ }
4815
+ set readOnly(readOnlyValue) {
4816
+ this.readOnly$.next(readOnlyValue);
4798
4817
  }
4799
4818
  ngOnInit() {
4800
- const documentDefinitionName = this.route.snapshot.paramMap.get('documentDefinitionName');
4801
- const documentId = this.route.snapshot.paramMap.get('documentId');
4802
- this.formDefinition = this.form;
4803
- this.errors = [];
4819
+ this.openRouteSubscription();
4820
+ this.errors$.next([]);
4804
4821
  this.setInitialToken();
4805
- if (documentDefinitionName) {
4806
- this.stateService.setDocumentDefinitionName(documentDefinitionName);
4807
- }
4808
- if (documentId) {
4809
- this.stateService.setDocumentId(documentId);
4810
- }
4811
4822
  this.subscribeFormRefresh();
4823
+ this.openReloadFormSubscription();
4824
+ this.openReloadSubmissionSubscription();
4812
4825
  }
4813
4826
  ngOnChanges(changes) {
4814
- var _a;
4815
- const currentForm = (_a = changes === null || changes === void 0 ? void 0 : changes.form) === null || _a === void 0 ? void 0 : _a.currentValue;
4816
- if (currentForm) {
4817
- this.formDefinition = currentForm;
4818
- this.reloadForm();
4819
- }
4820
4827
  this.setInitialToken();
4821
4828
  if (changes.formDefinitionRefresh$) {
4822
4829
  this.unsubscribeFormRefresh();
@@ -4827,21 +4834,16 @@ class FormioComponent {
4827
4834
  var _a;
4828
4835
  this.unsubscribeFormRefresh();
4829
4836
  (_a = this.tokenRefreshTimerSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
4830
- }
4831
- reloadForm() {
4832
- this.refreshForm.emit({
4833
- form: this.formDefinition,
4834
- });
4837
+ this._subscriptions.unsubscribe();
4835
4838
  }
4836
4839
  showErrors(errors) {
4837
- this.errors = errors;
4840
+ this.errors$.next(errors);
4838
4841
  }
4839
4842
  onSubmit(submission) {
4840
- this.errors = [];
4843
+ this.errors$.next([]);
4841
4844
  this.submit.emit(submission);
4842
4845
  }
4843
4846
  formReady(form) {
4844
- this.reloadForm();
4845
4847
  this.stateService.currentForm = form;
4846
4848
  }
4847
4849
  onChange(object) {
@@ -4853,6 +4855,20 @@ class FormioComponent {
4853
4855
  prevPage() {
4854
4856
  this.scrollToTop();
4855
4857
  }
4858
+ openReloadFormSubscription() {
4859
+ this._subscriptions.add(this.form$.subscribe(form => {
4860
+ this.refreshForm.emit({
4861
+ form,
4862
+ });
4863
+ }));
4864
+ }
4865
+ openReloadSubmissionSubscription() {
4866
+ this._subscriptions.add(this.submission$.subscribe(submission => {
4867
+ this.refreshForm.emit({
4868
+ submission,
4869
+ });
4870
+ }));
4871
+ }
4856
4872
  scrollToTop() {
4857
4873
  this.modalService.scrollToTop();
4858
4874
  }
@@ -4898,18 +4914,30 @@ class FormioComponent {
4898
4914
  this.formRefreshSubscription.unsubscribe();
4899
4915
  }
4900
4916
  }
4917
+ openRouteSubscription() {
4918
+ this._subscriptions.add(this.route.params.subscribe(params => {
4919
+ const documentDefinitionName = params.documentDefinitionName;
4920
+ const documentId = params.documentId;
4921
+ if (documentDefinitionName) {
4922
+ this.stateService.setDocumentDefinitionName(documentDefinitionName);
4923
+ }
4924
+ if (documentId) {
4925
+ this.stateService.setDocumentId(documentId);
4926
+ }
4927
+ }));
4928
+ }
4901
4929
  }
4902
4930
  FormioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FormioComponent, deps: [{ token: i3$1.UserProviderService }, { token: i4.NGXLogger }, { token: FormIoStateService }, { token: i1$1.ActivatedRoute }, { token: i1.TranslateService }, { token: ValtimoModalService }], target: i0.ɵɵFactoryTarget.Component });
4903
- FormioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: FormioComponent, selector: "valtimo-form-io", inputs: { form: "form", options: "options", submission: "submission", readOnly: "readOnly", formRefresh$: "formRefresh$" }, outputs: { submit: "submit", change: "change" }, usesOnChanges: true, ngImport: i0, template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async\n } as obs\"\n>\n <div *ngIf=\"errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions\"\n [submission]=\"submission\"\n [form]=\"formDefinition\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i8.FormioComponent, selector: "formio" }, { kind: "pipe", type: i1$2.AsyncPipe, name: "async" }] });
4931
+ FormioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: FormioComponent, selector: "valtimo-form-io", inputs: { options: "options", submission: "submission", form: "form", readOnly: "readOnly", formRefresh$: "formRefresh$" }, outputs: { submit: "submit", change: "change" }, usesOnChanges: true, ngImport: i0, template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async,\n submission: submission$ | async,\n readOnly: readOnly$ | async,\n form: form$ | async,\n errors: errors$ | async\n } as obs\"\n>\n <div *ngIf=\"obs.errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of obs.errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions && obs.form\"\n [submission]=\"obs.submission\"\n [form]=\"obs.form\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"obs.readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i8.FormioComponent, selector: "formio" }, { kind: "pipe", type: i1$2.AsyncPipe, name: "async" }] });
4904
4932
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FormioComponent, decorators: [{
4905
4933
  type: Component,
4906
- args: [{ selector: 'valtimo-form-io', template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async\n } as obs\"\n>\n <div *ngIf=\"errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions\"\n [submission]=\"submission\"\n [form]=\"formDefinition\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n" }]
4907
- }], ctorParameters: function () { return [{ type: i3$1.UserProviderService }, { type: i4.NGXLogger }, { type: FormIoStateService }, { type: i1$1.ActivatedRoute }, { type: i1.TranslateService }, { type: ValtimoModalService }]; }, propDecorators: { form: [{
4908
- type: Input
4909
- }], options: [{
4934
+ args: [{ selector: 'valtimo-form-io', template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async,\n submission: submission$ | async,\n readOnly: readOnly$ | async,\n form: form$ | async,\n errors: errors$ | async\n } as obs\"\n>\n <div *ngIf=\"obs.errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of obs.errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions && obs.form\"\n [submission]=\"obs.submission\"\n [form]=\"obs.form\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"obs.readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n" }]
4935
+ }], ctorParameters: function () { return [{ type: i3$1.UserProviderService }, { type: i4.NGXLogger }, { type: FormIoStateService }, { type: i1$1.ActivatedRoute }, { type: i1.TranslateService }, { type: ValtimoModalService }]; }, propDecorators: { options: [{
4910
4936
  type: Input
4911
4937
  }], submission: [{
4912
4938
  type: Input
4939
+ }], form: [{
4940
+ type: Input
4913
4941
  }], readOnly: [{
4914
4942
  type: Input
4915
4943
  }], formRefresh$: [{
@@ -6434,6 +6462,16 @@ const formIoUploaderEditForm = () => ({
6434
6462
  required: true,
6435
6463
  },
6436
6464
  },
6465
+ {
6466
+ type: 'checkbox',
6467
+ input: true,
6468
+ inputType: 'checkbox',
6469
+ key: 'validate.required',
6470
+ label: 'Required',
6471
+ validate: {
6472
+ required: false,
6473
+ },
6474
+ },
6437
6475
  {
6438
6476
  type: 'textfield',
6439
6477
  input: true,
@@ -6543,9 +6581,8 @@ function registerFormioUploadComponent(injector) {
6543
6581
  class UploaderComponent extends originalUploadComponent {
6544
6582
  setValue(value) {
6545
6583
  var _a;
6546
- let componentValue = (_a = this._customAngularElement) === null || _a === void 0 ? void 0 : _a.value;
6547
- if (componentValue) {
6548
- componentValue = value;
6584
+ if ((_a = this._customAngularElement) === null || _a === void 0 ? void 0 : _a.value) {
6585
+ this._customAngularElement.value = value;
6549
6586
  }
6550
6587
  return true;
6551
6588
  }
@@ -6583,6 +6620,16 @@ const documentenApiUploaderEditForm = () => ({
6583
6620
  required: true,
6584
6621
  },
6585
6622
  },
6623
+ {
6624
+ type: 'checkbox',
6625
+ input: true,
6626
+ inputType: 'checkbox',
6627
+ key: 'validate.required',
6628
+ label: 'Required',
6629
+ validate: {
6630
+ required: false,
6631
+ },
6632
+ },
6586
6633
  {
6587
6634
  type: 'textfield',
6588
6635
  input: true,
@@ -6881,7 +6928,10 @@ function registerDocumentenApiFormioUploadComponent(injector) {
6881
6928
  // override setValue function to allow for setting an array value
6882
6929
  class UploaderComponent extends originalUploadComponent {
6883
6930
  setValue(value) {
6884
- this._customAngularElement.value = value;
6931
+ var _a;
6932
+ if ((_a = this._customAngularElement) === null || _a === void 0 ? void 0 : _a.value) {
6933
+ this._customAngularElement.value = value;
6934
+ }
6885
6935
  return true;
6886
6936
  }
6887
6937
  }