@ng-formworks/core 16.2.7 → 16.3.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.
Files changed (177) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +833 -0
  3. package/esm2022/lib/framework-library/framework-library.service.mjs +175 -0
  4. package/esm2022/lib/framework-library/framework.mjs +15 -0
  5. package/esm2022/lib/framework-library/no-framework.component.mjs +18 -0
  6. package/esm2022/lib/framework-library/no-framework.module.mjs +27 -0
  7. package/esm2022/lib/framework-library/no.framework.mjs +19 -0
  8. package/esm2022/lib/json-schema-form.component.mjs +765 -0
  9. package/esm2022/lib/json-schema-form.module.mjs +26 -0
  10. package/esm2022/lib/json-schema-form.service.mjs +676 -0
  11. package/esm2022/lib/locale/de-validation-messages.mjs +60 -0
  12. package/esm2022/lib/locale/en-validation-messages.mjs +60 -0
  13. package/esm2022/lib/locale/es-validation-messages.mjs +57 -0
  14. package/esm2022/lib/locale/fr-validation-messages.mjs +60 -0
  15. package/esm2022/lib/locale/index.mjs +8 -0
  16. package/esm2022/lib/locale/it-validation-messages.mjs +60 -0
  17. package/esm2022/lib/locale/pt-validation-messages.mjs +60 -0
  18. package/esm2022/lib/locale/zh-validation-messages.mjs +60 -0
  19. package/esm2022/lib/shared/convert-schema-to-draft6.function.mjs +300 -0
  20. package/esm2022/lib/shared/form-group.functions.mjs +442 -0
  21. package/esm2022/lib/shared/format-regex.constants.mjs +54 -0
  22. package/esm2022/lib/shared/index.mjs +12 -0
  23. package/esm2022/lib/shared/json-schema.functions.mjs +784 -0
  24. package/esm2022/lib/shared/json.validators.mjs +884 -0
  25. package/esm2022/lib/shared/jsonpointer.functions.mjs +1026 -0
  26. package/esm2022/lib/shared/layout.functions.mjs +1154 -0
  27. package/esm2022/lib/shared/merge-schemas.function.mjs +345 -0
  28. package/esm2022/lib/shared/utility.functions.mjs +380 -0
  29. package/esm2022/lib/shared/validator.functions.mjs +584 -0
  30. package/esm2022/lib/widget-library/add-reference.component.mjs +61 -0
  31. package/esm2022/lib/widget-library/button.component.mjs +72 -0
  32. package/esm2022/lib/widget-library/checkbox.component.mjs +105 -0
  33. package/esm2022/lib/widget-library/checkboxes.component.mjs +147 -0
  34. package/esm2022/lib/widget-library/file.component.mjs +35 -0
  35. package/esm2022/lib/widget-library/hidden.component.mjs +54 -0
  36. package/esm2022/lib/widget-library/index.mjs +55 -0
  37. package/esm2022/lib/widget-library/input.component.mjs +119 -0
  38. package/esm2022/lib/widget-library/message.component.mjs +38 -0
  39. package/esm2022/lib/widget-library/none.component.mjs +21 -0
  40. package/esm2022/lib/widget-library/number.component.mjs +123 -0
  41. package/esm2022/lib/widget-library/one-of.component.mjs +35 -0
  42. package/esm2022/lib/widget-library/orderable.directive.mjs +123 -0
  43. package/esm2022/lib/widget-library/radios.component.mjs +153 -0
  44. package/esm2022/lib/widget-library/root.component.mjs +79 -0
  45. package/esm2022/lib/widget-library/section.component.mjs +199 -0
  46. package/esm2022/lib/widget-library/select-framework.component.mjs +51 -0
  47. package/esm2022/lib/widget-library/select-widget.component.mjs +46 -0
  48. package/esm2022/lib/widget-library/select.component.mjs +150 -0
  49. package/esm2022/lib/widget-library/submit.component.mjs +82 -0
  50. package/esm2022/lib/widget-library/tab.component.mjs +41 -0
  51. package/esm2022/lib/widget-library/tabs.component.mjs +108 -0
  52. package/esm2022/lib/widget-library/template.component.mjs +46 -0
  53. package/esm2022/lib/widget-library/textarea.component.mjs +104 -0
  54. package/esm2022/lib/widget-library/widget-library.module.mjs +42 -0
  55. package/esm2022/lib/widget-library/widget-library.service.mjs +226 -0
  56. package/esm2022/ng-formworks-core.mjs +5 -0
  57. package/esm2022/public_api.mjs +13 -0
  58. package/fesm2022/ng-formworks-core.mjs +10147 -0
  59. package/fesm2022/ng-formworks-core.mjs.map +1 -0
  60. package/index.d.ts +5 -0
  61. package/lib/framework-library/framework-library.service.d.ts +55 -0
  62. package/lib/framework-library/framework.d.ts +13 -0
  63. package/lib/framework-library/no-framework.component.d.ts +8 -0
  64. package/lib/framework-library/no-framework.module.d.ts +9 -0
  65. package/lib/framework-library/no.framework.d.ts +10 -0
  66. package/lib/json-schema-form.component.d.ts +218 -0
  67. package/lib/json-schema-form.module.d.ts +11 -0
  68. package/lib/json-schema-form.service.d.ts +115 -0
  69. package/lib/locale/de-validation-messages.d.ts +1 -0
  70. package/lib/locale/en-validation-messages.d.ts +1 -0
  71. package/lib/locale/es-validation-messages.d.ts +1 -0
  72. package/lib/locale/fr-validation-messages.d.ts +1 -0
  73. package/lib/locale/it-validation-messages.d.ts +1 -0
  74. package/lib/locale/pt-validation-messages.d.ts +1 -0
  75. package/lib/locale/zh-validation-messages.d.ts +1 -0
  76. package/lib/shared/convert-schema-to-draft6.function.d.ts +21 -0
  77. package/lib/shared/form-group.functions.d.ts +100 -0
  78. package/lib/shared/format-regex.constants.d.ts +19 -0
  79. package/lib/shared/index.d.ts +9 -0
  80. package/lib/shared/json-schema.functions.d.ts +193 -0
  81. package/lib/shared/json.validators.d.ts +441 -0
  82. package/lib/shared/jsonpointer.functions.d.ts +416 -0
  83. package/lib/shared/layout.functions.d.ts +83 -0
  84. package/lib/shared/merge-schemas.function.d.ts +19 -0
  85. package/lib/shared/utility.functions.d.ts +165 -0
  86. package/{src/lib/shared/validator.functions.ts → lib/shared/validator.functions.d.ts} +40 -277
  87. package/lib/widget-library/add-reference.component.d.ts +20 -0
  88. package/lib/widget-library/button.component.d.ts +21 -0
  89. package/lib/widget-library/checkbox.component.d.ts +24 -0
  90. package/lib/widget-library/checkboxes.component.d.ts +24 -0
  91. package/lib/widget-library/file.component.d.ts +21 -0
  92. package/lib/widget-library/hidden.component.d.ts +19 -0
  93. package/{src/lib/widget-library/index.ts → lib/widget-library/index.d.ts} +1 -10
  94. package/lib/widget-library/input.component.d.ts +22 -0
  95. package/lib/widget-library/message.component.d.ts +15 -0
  96. package/lib/widget-library/none.component.d.ts +8 -0
  97. package/lib/widget-library/number.component.d.ts +25 -0
  98. package/lib/widget-library/one-of.component.d.ts +21 -0
  99. package/lib/widget-library/orderable.directive.d.ts +41 -0
  100. package/lib/widget-library/radios.component.d.ts +23 -0
  101. package/lib/widget-library/root.component.d.ts +17 -0
  102. package/lib/widget-library/section.component.d.ts +19 -0
  103. package/lib/widget-library/select-framework.component.d.ts +18 -0
  104. package/lib/widget-library/select-widget.component.d.ts +18 -0
  105. package/lib/widget-library/select.component.d.ts +24 -0
  106. package/lib/widget-library/submit.component.d.ts +24 -0
  107. package/lib/widget-library/tab.component.d.ts +14 -0
  108. package/lib/widget-library/tabs.component.d.ts +20 -0
  109. package/lib/widget-library/template.component.d.ts +18 -0
  110. package/lib/widget-library/textarea.component.d.ts +21 -0
  111. package/lib/widget-library/widget-library.module.d.ts +31 -0
  112. package/lib/widget-library/widget-library.service.d.ts +22 -0
  113. package/package.json +64 -53
  114. package/{src/public_api.ts → public_api.d.ts} +1 -13
  115. package/karma.conf.js +0 -46
  116. package/ng-package.json +0 -11
  117. package/src/lib/framework-library/framework-library.service.ts +0 -195
  118. package/src/lib/framework-library/framework.ts +0 -11
  119. package/src/lib/framework-library/no-framework.component.html +0 -2
  120. package/src/lib/framework-library/no-framework.component.ts +0 -11
  121. package/src/lib/framework-library/no-framework.module.ts +0 -18
  122. package/src/lib/framework-library/no.framework.ts +0 -11
  123. package/src/lib/json-schema-form.component.html +0 -7
  124. package/src/lib/json-schema-form.component.ts +0 -809
  125. package/src/lib/json-schema-form.module.ts +0 -17
  126. package/src/lib/json-schema-form.service.ts +0 -907
  127. package/src/lib/locale/de-validation-messages.ts +0 -58
  128. package/src/lib/locale/en-validation-messages.ts +0 -58
  129. package/src/lib/locale/es-validation-messages.ts +0 -55
  130. package/src/lib/locale/fr-validation-messages.ts +0 -58
  131. package/src/lib/locale/it-validation-messages.ts +0 -58
  132. package/src/lib/locale/pt-validation-messages.ts +0 -58
  133. package/src/lib/locale/zh-validation-messages.ts +0 -58
  134. package/src/lib/locale-dates/en-US.ts +0 -5
  135. package/src/lib/shared/convert-schema-to-draft6.function.ts +0 -321
  136. package/src/lib/shared/form-group.functions.ts +0 -522
  137. package/src/lib/shared/format-regex.constants.ts +0 -73
  138. package/src/lib/shared/index.ts +0 -40
  139. package/src/lib/shared/json-schema.functions.ts +0 -788
  140. package/src/lib/shared/json.validators.ts +0 -878
  141. package/src/lib/shared/jsonpointer.functions.ts +0 -1012
  142. package/src/lib/shared/jspointer.functions.json.spec.ts +0 -103
  143. package/src/lib/shared/layout.functions.ts +0 -1233
  144. package/src/lib/shared/merge-schemas.function.ts +0 -329
  145. package/src/lib/shared/utility.functions.ts +0 -373
  146. package/src/lib/shared/validator.functions.spec.ts +0 -55
  147. package/src/lib/widget-library/add-reference.component.ts +0 -59
  148. package/src/lib/widget-library/button.component.ts +0 -54
  149. package/src/lib/widget-library/checkbox.component.ts +0 -74
  150. package/src/lib/widget-library/checkboxes.component.ts +0 -104
  151. package/src/lib/widget-library/file.component.ts +0 -36
  152. package/src/lib/widget-library/hidden.component.ts +0 -39
  153. package/src/lib/widget-library/input.component.ts +0 -76
  154. package/src/lib/widget-library/message.component.ts +0 -29
  155. package/src/lib/widget-library/none.component.ts +0 -12
  156. package/src/lib/widget-library/number.component.ts +0 -79
  157. package/src/lib/widget-library/one-of.component.ts +0 -36
  158. package/src/lib/widget-library/orderable.directive.ts +0 -130
  159. package/src/lib/widget-library/radios.component.ts +0 -101
  160. package/src/lib/widget-library/root.component.ts +0 -78
  161. package/src/lib/widget-library/section.component.ts +0 -133
  162. package/src/lib/widget-library/select-framework.component.ts +0 -50
  163. package/src/lib/widget-library/select-widget.component.ts +0 -46
  164. package/src/lib/widget-library/select.component.ts +0 -96
  165. package/src/lib/widget-library/submit.component.ts +0 -68
  166. package/src/lib/widget-library/tab.component.ts +0 -29
  167. package/src/lib/widget-library/tabs.component.ts +0 -83
  168. package/src/lib/widget-library/template.component.ts +0 -52
  169. package/src/lib/widget-library/textarea.component.ts +0 -68
  170. package/src/lib/widget-library/widget-library.module.ts +0 -13
  171. package/src/lib/widget-library/widget-library.service.ts +0 -234
  172. package/src/test.ts +0 -18
  173. package/tsconfig.lib.json +0 -25
  174. package/tsconfig.lib.prod.json +0 -9
  175. package/tsconfig.spec.json +0 -17
  176. package/tslint.json +0 -11
  177. /package/{src/lib/locale/index.ts → lib/locale/index.d.ts} +0 -0
@@ -1,195 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { Inject, Injectable } from '@angular/core';
3
- import { Observable, Subject, lastValueFrom } from 'rxjs';
4
- import { hasOwn } from '../shared/utility.functions';
5
- import { WidgetLibraryService } from '../widget-library/widget-library.service';
6
- import { Framework } from './framework';
7
-
8
- // Possible future frameworks:
9
- // - Foundation 6:
10
- // http://justindavis.co/2017/06/15/using-foundation-6-in-angular-4/
11
- // https://github.com/zurb/foundation-sites
12
- // - Semantic UI:
13
- // https://github.com/edcarroll/ng2-semantic-ui
14
- // https://github.com/vladotesanovic/ngSemantic
15
-
16
- @Injectable({
17
- providedIn: 'root',
18
- })
19
- export class FrameworkLibraryService {
20
- activeFramework: Framework = null;
21
- stylesheets: (HTMLStyleElement|HTMLLinkElement)[];
22
- scripts: HTMLScriptElement[];
23
- loadExternalAssets = false;
24
- defaultFramework: string;
25
- frameworkLibrary: { [name: string]: Framework } = {};
26
-
27
- activeFrameworkName$: Observable<string>;
28
- private activeFrameworkNameSubject: Subject<string>;
29
- private activeFrameworkName:string;
30
-
31
- constructor(
32
- @Inject(Framework) private frameworks: any[],
33
- @Inject(WidgetLibraryService) private widgetLibrary: WidgetLibraryService,
34
- private http: HttpClient,
35
- ) {
36
- this.frameworks.forEach(framework =>
37
- this.frameworkLibrary[framework.name] = framework
38
- );
39
- this.defaultFramework = this.frameworks[0].name;
40
- //this.setFramework(this.defaultFramework);
41
-
42
- this.activeFrameworkName=this.defaultFramework;
43
- this.activeFrameworkNameSubject = new Subject<string>();
44
- this.activeFrameworkName$ = this.activeFrameworkNameSubject.asObservable();
45
- this.setFramework(this.defaultFramework);
46
- }
47
-
48
- public setLoadExternalAssets(loadExternalAssets = true): void {
49
- this.loadExternalAssets = !!loadExternalAssets;
50
- }
51
-
52
- public setFramework(
53
- framework: string|Framework = this.defaultFramework,
54
- loadExternalAssets = this.loadExternalAssets
55
- ): boolean {
56
- this.activeFramework =
57
- typeof framework === 'string' && this.hasFramework(framework) ?
58
- this.frameworkLibrary[framework] :
59
- typeof framework === 'object' && hasOwn(framework, 'framework') ?
60
- framework :
61
- this.frameworkLibrary[this.defaultFramework];
62
- if(this.activeFramework.name !=this.activeFrameworkName){
63
- this.activeFrameworkName=this.activeFramework.name;
64
- this.activeFrameworkNameSubject.next(this.activeFrameworkName);
65
- }
66
- return this.registerFrameworkWidgets(this.activeFramework);
67
- }
68
-
69
- registerFrameworkWidgets(framework: Framework): boolean {
70
- return hasOwn(framework, 'widgets') ?
71
- this.widgetLibrary.registerFrameworkWidgets(framework.widgets) :
72
- this.widgetLibrary.unRegisterFrameworkWidgets();
73
- }
74
-
75
- public hasFramework(type: string): boolean {
76
- return hasOwn(this.frameworkLibrary, type);
77
- }
78
-
79
- public getFramework(): any {
80
- if (!this.activeFramework) { this.setFramework('default', true); }
81
- return this.activeFramework.framework;
82
- }
83
-
84
- public getFrameworkList():{name:string,text:string}[] {
85
- return this.frameworks.map(fw=>{
86
- return {name:fw.name,text:fw.text};
87
- })
88
-
89
- }
90
-
91
- public getFrameworkWidgets(): any {
92
- return this.activeFramework.widgets || {};
93
- }
94
-
95
-
96
-
97
- public getFrameworkStylesheets(load: boolean = this.loadExternalAssets): string[] {
98
- return (load && this.activeFramework.stylesheets) || [];
99
- }
100
-
101
- public getFrameworkScripts(load: boolean = this.loadExternalAssets): string[] {
102
- return (load && this.activeFramework.scripts) || [];
103
- }
104
-
105
- //applies to CssFramework classes
106
- public getFrameworkConfig(existingFramework?:any): any {
107
- let actFramework:Framework& { [key: string]: any; }=existingFramework||this.activeFramework;
108
- return actFramework.config;
109
- }
110
-
111
- //this will load the list of assets to be loaded at runtime in case the dependent framework
112
- //scripts and styles are include locally with the parent app
113
- public getFrameworkAssetConfig(existingFramework?:any,useAssetRelPath=true):Promise<{stylesheets:string[],scripts:string[]}>{
114
- let actFramework:Framework& { [key: string]: any; }=existingFramework||this.activeFramework;
115
- //TODO move this into config
116
- const assetConfigPath = `assets/${actFramework.name}/cssframework`
117
- const assetConfigURL = `${assetConfigPath}/assets.json`;
118
- let subs=this.http
119
- .get(assetConfigURL, { responseType: 'text' })
120
- //.subscribe(assetConfig => {
121
- // assetConfig
122
- //})
123
-
124
- return lastValueFrom(subs).then(assetCfgText=>{
125
- let assetCfg=JSON.parse(assetCfgText);
126
- if(useAssetRelPath){
127
- assetCfg.stylesheets=assetCfg.stylesheets.map(styleLink=>{
128
- //ignore relative path if url starts with known protocol or //
129
- let nonRelPrefixes=["/","//","http:","https:"];//"//" list for completeness
130
- let isNonRel=false;
131
- nonRelPrefixes.forEach(prefix=>{
132
- isNonRel=isNonRel||styleLink.indexOf(prefix)==0;
133
- })
134
- if(isNonRel){
135
- return styleLink;
136
- }
137
- return `${assetConfigPath}/${styleLink}`;
138
- })
139
- assetCfg.scripts=assetCfg.scripts.map(scriptLink=>{
140
- return `${assetConfigPath}/${scriptLink}`;
141
- })
142
- }
143
- return assetCfg
144
- });
145
- }
146
-
147
- //applies to CssFramework classes
148
- public getFrameworkThemes():{name:string,text:string}[] {
149
- let cssfwConfig=this.getFrameworkConfig();
150
- let themes;
151
- if(cssfwConfig){
152
- themes=cssfwConfig?.widgetstyles?.__themes__||[]
153
- }
154
- return themes
155
- }
156
-
157
- //applies to CssFramework classes
158
- public requestThemeChange(name:string,validateThemeExists:boolean=false,existingFramework?:any){
159
- let actFramework:Framework& { [key: string]: any; }=existingFramework||this.activeFramework;
160
- if(actFramework.requestThemeChange){
161
- if(validateThemeExists){
162
- let themes=this.getFrameworkThemes();
163
- let foundThemes=themes.filter(thm=>{return thm.name==name});
164
- if(!foundThemes|| foundThemes.length==0){
165
- return false;
166
- }
167
- }
168
- actFramework.requestThemeChange(name);
169
- return true;
170
- }
171
- }
172
- //applies to CssFramework classes
173
- public getActiveTheme(existingFramework?:any):{name:string,text:string}{
174
- let actFramework:Framework& { [key: string]: any; }=existingFramework||this.activeFramework;
175
- if(actFramework.getActiveTheme){
176
- return actFramework.getActiveTheme();
177
- }
178
- }
179
-
180
- //applies to CssFramework classes
181
- public registerTheme(newTheme:{name:string,text:string},existingFramework?:any):boolean{
182
- let actFramework:Framework& { [key: string]: any; }=existingFramework||this.activeFramework;
183
- if(actFramework.registerTheme){
184
- return actFramework.registerTheme(newTheme);
185
- }
186
- }
187
-
188
- //applies to CssFramework classes
189
- public unregisterTheme(name:string,existingFramework?:any):boolean{
190
- let actFramework:Framework& { [key: string]: any; }=existingFramework||this.activeFramework;
191
- if(actFramework.registerTheme){
192
- return actFramework.unregisterTheme(name);
193
- }
194
- }
195
- }
@@ -1,11 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- @Injectable()
4
- export class Framework {
5
- name: string;
6
- text:string;
7
- framework: any;
8
- widgets?: { [key: string]: any } = {};
9
- stylesheets?: string[] = [];
10
- scripts?: string[] = [];
11
- }
@@ -1,2 +0,0 @@
1
- <select-widget-widget [dataIndex]="dataIndex" [layoutIndex]="layoutIndex" [layoutNode]="layoutNode">
2
- </select-widget-widget>
@@ -1,11 +0,0 @@
1
- import { Component, Input } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'no-framework',
5
- templateUrl: './no-framework.component.html',
6
- })
7
- export class NoFrameworkComponent {
8
- @Input() layoutNode: any;
9
- @Input() layoutIndex: number[];
10
- @Input() dataIndex: number[];
11
- }
@@ -1,18 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { Framework } from './framework';
3
- import { NgModule } from '@angular/core';
4
- import { NoFramework } from './no.framework';
5
- import { NoFrameworkComponent } from './no-framework.component';
6
- import { WidgetLibraryModule } from '../widget-library/widget-library.module';
7
-
8
- // No framework - plain HTML controls (styles from form layout only)
9
-
10
- @NgModule({
11
- imports: [CommonModule, WidgetLibraryModule],
12
- declarations: [NoFrameworkComponent],
13
- exports: [NoFrameworkComponent],
14
- providers: [
15
- { provide: Framework, useClass: NoFramework, multi: true }
16
- ]
17
- })
18
- export class NoFrameworkModule { }
@@ -1,11 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Framework } from './framework';
3
- import { NoFrameworkComponent } from './no-framework.component';
4
- // No framework - plain HTML controls (styles from form layout only)
5
-
6
- @Injectable()
7
- export class NoFramework extends Framework {
8
- name = 'no-framework';
9
- text ='None (plain HTML)';
10
- framework = NoFrameworkComponent;
11
- }
@@ -1,7 +0,0 @@
1
- <form [autocomplete]="jsf?.formOptions?.autocomplete ? 'on' : 'off'" class="json-schema-form" (ngSubmit)="submitForm()">
2
- <root-widget [layout]="jsf?.layout"></root-widget>
3
- </form>
4
- <div *ngIf="debug || jsf?.formOptions?.debug">
5
- Debug output:
6
- <pre>{{debugOutput}}</pre>
7
- </div>