@ng-formworks/core 17.2.7 → 18.0.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 +834 -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 +1158 -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 +10151 -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/{src/lib/locale/index.ts → lib/locale/index.d.ts} +7 -7
  74. package/lib/locale/it-validation-messages.d.ts +1 -0
  75. package/lib/locale/pt-validation-messages.d.ts +1 -0
  76. package/lib/locale/zh-validation-messages.d.ts +1 -0
  77. package/lib/shared/convert-schema-to-draft6.function.d.ts +21 -0
  78. package/lib/shared/form-group.functions.d.ts +100 -0
  79. package/lib/shared/format-regex.constants.d.ts +19 -0
  80. package/lib/shared/index.d.ts +9 -0
  81. package/lib/shared/json-schema.functions.d.ts +193 -0
  82. package/lib/shared/json.validators.d.ts +441 -0
  83. package/lib/shared/jsonpointer.functions.d.ts +416 -0
  84. package/lib/shared/layout.functions.d.ts +83 -0
  85. package/lib/shared/merge-schemas.function.d.ts +19 -0
  86. package/lib/shared/utility.functions.d.ts +165 -0
  87. package/{src/lib/shared/validator.functions.ts → lib/shared/validator.functions.d.ts} +364 -601
  88. package/lib/widget-library/add-reference.component.d.ts +20 -0
  89. package/lib/widget-library/button.component.d.ts +21 -0
  90. package/lib/widget-library/checkbox.component.d.ts +24 -0
  91. package/lib/widget-library/checkboxes.component.d.ts +24 -0
  92. package/lib/widget-library/file.component.d.ts +21 -0
  93. package/lib/widget-library/hidden.component.d.ts +19 -0
  94. package/{src/lib/widget-library/index.ts → lib/widget-library/index.d.ts} +47 -56
  95. package/lib/widget-library/input.component.d.ts +22 -0
  96. package/lib/widget-library/message.component.d.ts +15 -0
  97. package/lib/widget-library/none.component.d.ts +8 -0
  98. package/lib/widget-library/number.component.d.ts +25 -0
  99. package/lib/widget-library/one-of.component.d.ts +21 -0
  100. package/lib/widget-library/orderable.directive.d.ts +41 -0
  101. package/lib/widget-library/radios.component.d.ts +23 -0
  102. package/lib/widget-library/root.component.d.ts +17 -0
  103. package/lib/widget-library/section.component.d.ts +19 -0
  104. package/lib/widget-library/select-framework.component.d.ts +18 -0
  105. package/lib/widget-library/select-widget.component.d.ts +18 -0
  106. package/lib/widget-library/select.component.d.ts +24 -0
  107. package/lib/widget-library/submit.component.d.ts +24 -0
  108. package/lib/widget-library/tab.component.d.ts +14 -0
  109. package/lib/widget-library/tabs.component.d.ts +20 -0
  110. package/lib/widget-library/template.component.d.ts +18 -0
  111. package/lib/widget-library/textarea.component.d.ts +21 -0
  112. package/lib/widget-library/widget-library.module.d.ts +31 -0
  113. package/lib/widget-library/widget-library.service.d.ts +22 -0
  114. package/package.json +66 -53
  115. package/{src/public_api.ts → public_api.d.ts} +9 -21
  116. package/karma.conf.js +0 -46
  117. package/ng-package.json +0 -11
  118. package/src/lib/framework-library/framework-library.service.ts +0 -195
  119. package/src/lib/framework-library/framework.ts +0 -11
  120. package/src/lib/framework-library/no-framework.component.html +0 -2
  121. package/src/lib/framework-library/no-framework.component.ts +0 -11
  122. package/src/lib/framework-library/no-framework.module.ts +0 -18
  123. package/src/lib/framework-library/no.framework.ts +0 -11
  124. package/src/lib/json-schema-form.component.html +0 -7
  125. package/src/lib/json-schema-form.component.ts +0 -809
  126. package/src/lib/json-schema-form.module.ts +0 -17
  127. package/src/lib/json-schema-form.service.ts +0 -907
  128. package/src/lib/locale/de-validation-messages.ts +0 -58
  129. package/src/lib/locale/en-validation-messages.ts +0 -58
  130. package/src/lib/locale/es-validation-messages.ts +0 -55
  131. package/src/lib/locale/fr-validation-messages.ts +0 -58
  132. package/src/lib/locale/it-validation-messages.ts +0 -58
  133. package/src/lib/locale/pt-validation-messages.ts +0 -58
  134. package/src/lib/locale/zh-validation-messages.ts +0 -58
  135. package/src/lib/locale-dates/en-US.ts +0 -5
  136. package/src/lib/shared/convert-schema-to-draft6.function.ts +0 -321
  137. package/src/lib/shared/form-group.functions.ts +0 -522
  138. package/src/lib/shared/format-regex.constants.ts +0 -73
  139. package/src/lib/shared/index.ts +0 -40
  140. package/src/lib/shared/json-schema.functions.ts +0 -788
  141. package/src/lib/shared/json.validators.ts +0 -878
  142. package/src/lib/shared/jsonpointer.functions.ts +0 -1012
  143. package/src/lib/shared/jspointer.functions.json.spec.ts +0 -103
  144. package/src/lib/shared/layout.functions.ts +0 -1233
  145. package/src/lib/shared/merge-schemas.function.ts +0 -329
  146. package/src/lib/shared/utility.functions.ts +0 -373
  147. package/src/lib/shared/validator.functions.spec.ts +0 -55
  148. package/src/lib/widget-library/add-reference.component.ts +0 -59
  149. package/src/lib/widget-library/button.component.ts +0 -54
  150. package/src/lib/widget-library/checkbox.component.ts +0 -74
  151. package/src/lib/widget-library/checkboxes.component.ts +0 -104
  152. package/src/lib/widget-library/file.component.ts +0 -36
  153. package/src/lib/widget-library/hidden.component.ts +0 -39
  154. package/src/lib/widget-library/input.component.ts +0 -76
  155. package/src/lib/widget-library/message.component.ts +0 -29
  156. package/src/lib/widget-library/none.component.ts +0 -12
  157. package/src/lib/widget-library/number.component.ts +0 -79
  158. package/src/lib/widget-library/one-of.component.ts +0 -36
  159. package/src/lib/widget-library/orderable.directive.ts +0 -130
  160. package/src/lib/widget-library/radios.component.ts +0 -101
  161. package/src/lib/widget-library/root.component.ts +0 -78
  162. package/src/lib/widget-library/section.component.ts +0 -133
  163. package/src/lib/widget-library/select-framework.component.ts +0 -50
  164. package/src/lib/widget-library/select-widget.component.ts +0 -46
  165. package/src/lib/widget-library/select.component.ts +0 -96
  166. package/src/lib/widget-library/submit.component.ts +0 -68
  167. package/src/lib/widget-library/tab.component.ts +0 -29
  168. package/src/lib/widget-library/tabs.component.ts +0 -83
  169. package/src/lib/widget-library/template.component.ts +0 -52
  170. package/src/lib/widget-library/textarea.component.ts +0 -68
  171. package/src/lib/widget-library/widget-library.module.ts +0 -13
  172. package/src/lib/widget-library/widget-library.service.ts +0 -234
  173. package/src/test.ts +0 -18
  174. package/tsconfig.lib.json +0 -25
  175. package/tsconfig.lib.prod.json +0 -9
  176. package/tsconfig.spec.json +0 -17
  177. package/tslint.json +0 -11
@@ -1,68 +0,0 @@
1
- import { AbstractControl } from '@angular/forms';
2
- import { Component, Input, OnInit } from '@angular/core';
3
- import { JsonSchemaFormService } from '../json-schema-form.service';
4
-
5
-
6
- @Component({
7
- // tslint:disable-next-line:component-selector
8
- selector: 'textarea-widget',
9
- template: `
10
- <div
11
- [class]="options?.htmlClass || ''">
12
- <label *ngIf="options?.title"
13
- [attr.for]="'control' + layoutNode?._id"
14
- [class]="options?.labelHtmlClass || ''"
15
- [style.display]="options?.notitle ? 'none' : ''"
16
- [innerHTML]="options?.title"></label>
17
- <textarea *ngIf="boundControl"
18
- [formControl]="formControl"
19
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
20
- [attr.maxlength]="options?.maxLength"
21
- [attr.minlength]="options?.minLength"
22
- [attr.pattern]="options?.pattern"
23
- [attr.placeholder]="options?.placeholder"
24
- [attr.readonly]="options?.readonly ? 'readonly' : null"
25
- [attr.required]="options?.required"
26
- [class]="options?.fieldHtmlClass || ''"
27
- [id]="'control' + layoutNode?._id"
28
- [name]="controlName"></textarea>
29
- <textarea *ngIf="!boundControl"
30
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
31
- [attr.maxlength]="options?.maxLength"
32
- [attr.minlength]="options?.minLength"
33
- [attr.pattern]="options?.pattern"
34
- [attr.placeholder]="options?.placeholder"
35
- [attr.readonly]="options?.readonly ? 'readonly' : null"
36
- [attr.required]="options?.required"
37
- [class]="options?.fieldHtmlClass || ''"
38
- [disabled]="controlDisabled"
39
- [id]="'control' + layoutNode?._id"
40
- [name]="controlName"
41
- [value]="controlValue"
42
- (input)="updateValue($event)">{{controlValue}}</textarea>
43
- </div>`,
44
- })
45
- export class TextareaComponent implements OnInit {
46
- formControl: AbstractControl;
47
- controlName: string;
48
- controlValue: any;
49
- controlDisabled = false;
50
- boundControl = false;
51
- options: any;
52
- @Input() layoutNode: any;
53
- @Input() layoutIndex: number[];
54
- @Input() dataIndex: number[];
55
-
56
- constructor(
57
- private jsf: JsonSchemaFormService
58
- ) { }
59
-
60
- ngOnInit() {
61
- this.options = this.layoutNode.options || {};
62
- this.jsf.initializeControl(this);
63
- }
64
-
65
- updateValue(event) {
66
- this.jsf.updateValue(this, event.target.value);
67
- }
68
- }
@@ -1,13 +0,0 @@
1
- import { BASIC_WIDGETS } from './index';
2
- import { CommonModule } from '@angular/common';
3
- import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4
- import { NgModule } from '@angular/core';
5
- import { OrderableDirective } from './orderable.directive';
6
-
7
- @NgModule({
8
- imports: [CommonModule, FormsModule, ReactiveFormsModule],
9
- declarations: [...BASIC_WIDGETS, OrderableDirective],
10
- exports: [...BASIC_WIDGETS, OrderableDirective]
11
- })
12
- export class WidgetLibraryModule {
13
- }
@@ -1,234 +0,0 @@
1
- import { AddReferenceComponent } from './add-reference.component';
2
- import { ButtonComponent } from './button.component';
3
- import { CheckboxComponent } from './checkbox.component';
4
- import { CheckboxesComponent } from './checkboxes.component';
5
- import { FileComponent } from './file.component';
6
- import { hasOwn } from '../shared/utility.functions';
7
- import { Injectable } from '@angular/core';
8
- import { InputComponent } from './input.component';
9
- import { MessageComponent } from './message.component';
10
- import { NoneComponent } from './none.component';
11
- import { NumberComponent } from './number.component';
12
- import { OneOfComponent } from './one-of.component';
13
- import { RadiosComponent } from './radios.component';
14
- import { RootComponent } from './root.component';
15
- import { SectionComponent } from './section.component';
16
- import { SelectComponent } from './select.component';
17
- import { SelectFrameworkComponent } from './select-framework.component';
18
- import { SelectWidgetComponent } from './select-widget.component';
19
- import { SubmitComponent } from './submit.component';
20
- import { TabsComponent } from './tabs.component';
21
- import { TemplateComponent } from './template.component';
22
- import { TextareaComponent } from './textarea.component';
23
-
24
- @Injectable({
25
- providedIn: 'root',
26
- })
27
- export class WidgetLibraryService {
28
-
29
- defaultWidget = 'text';
30
- widgetLibrary: any = {
31
-
32
- // Angular JSON Schema Form administrative widgets
33
- 'none': NoneComponent, // Placeholder, for development - displays nothing
34
- 'root': RootComponent, // Form root, renders a complete layout
35
- 'select-framework': SelectFrameworkComponent, // Applies the selected framework to a specified widget
36
- 'select-widget': SelectWidgetComponent, // Displays a specified widget
37
- '$ref': AddReferenceComponent, // Button to add a new array item or $ref element
38
-
39
- // Free-form text HTML 'input' form control widgets <input type="...">
40
- 'email': 'text',
41
- 'integer': 'number', // Note: 'integer' is not a recognized HTML input type
42
- 'number': NumberComponent,
43
- 'password': 'text',
44
- 'search': 'text',
45
- 'tel': 'text',
46
- 'text': InputComponent,
47
- 'url': 'text',
48
-
49
- // Controlled text HTML 'input' form control widgets <input type="...">
50
- 'color': 'text',
51
- 'date': 'text',
52
- 'datetime': 'text',
53
- 'datetime-local': 'text',
54
- 'month': 'text',
55
- 'range': 'number',
56
- 'time': 'text',
57
- 'week': 'text',
58
-
59
- // Non-text HTML 'input' form control widgets <input type="...">
60
- // 'button': <input type="button"> not used, use <button> instead
61
- 'checkbox': CheckboxComponent, // TODO: Set ternary = true for 3-state ??
62
- 'file': FileComponent, // TODO: Finish 'file' widget
63
- 'hidden': 'text',
64
- 'image': 'text', // TODO: Figure out how to handle these
65
- 'radio': 'radios',
66
- 'reset': 'submit', // TODO: Figure out how to handle these
67
- 'submit': SubmitComponent,
68
-
69
- // Other (non-'input') HTML form control widgets
70
- 'button': ButtonComponent,
71
- 'select': SelectComponent,
72
- // 'option': automatically generated by select widgets
73
- // 'optgroup': automatically generated by select widgets
74
- 'textarea': TextareaComponent,
75
-
76
- // HTML form control widget sets
77
- 'checkboxes': CheckboxesComponent, // Grouped list of checkboxes
78
- 'checkboxes-inline': 'checkboxes', // Checkboxes in one line
79
- 'checkboxbuttons': 'checkboxes', // Checkboxes as html buttons
80
- 'radios': RadiosComponent, // Grouped list of radio buttons
81
- 'radios-inline': 'radios', // Radio controls in one line
82
- 'radiobuttons': 'radios', // Radio controls as html buttons
83
-
84
- // HTML Layout widgets
85
- // 'label': automatically added to data widgets
86
- // 'legend': automatically added to fieldsets
87
- 'section': SectionComponent, // Just a div <div>
88
- 'div': 'section', // Still just a div <div>
89
- 'fieldset': 'section', // A fieldset, with an optional legend <fieldset>
90
- 'flex': 'section', // A flexbox container <div style="display: flex">
91
-
92
- // Non-HTML layout widgets
93
- 'one-of': OneOfComponent, // A select box that changes another input
94
- // TODO: Finish 'one-of' widget
95
- 'array': 'section', // A list you can add, remove and reorder <fieldset>
96
- 'tabarray': 'tabs', // A tabbed version of array
97
- 'tab': 'section', // A tab group, similar to a fieldset or section <fieldset>
98
- 'tabs': TabsComponent, // A tabbed set of panels with different controls
99
- 'message': MessageComponent, // Insert arbitrary html
100
- 'help': 'message', // Insert arbitrary html
101
- 'msg': 'message', // Insert arbitrary html
102
- 'html': 'message', // Insert arbitrary html
103
- 'template': TemplateComponent, // Insert a custom Angular component
104
-
105
- // Widgets included for compatibility with JSON Form API
106
- 'advancedfieldset': 'section', // Adds 'Advanced settings' title <fieldset>
107
- 'authfieldset': 'section', // Adds 'Authentication settings' title <fieldset>
108
- 'optionfieldset': 'one-of', // Option control, displays selected sub-item <fieldset>
109
- 'selectfieldset': 'one-of', // Select control, displays selected sub-item <fieldset>
110
- 'conditional': 'section', // Identical to 'section' (depeciated) <div>
111
- 'actions': 'section', // Horizontal button list, can only submit, uses buttons as items <div>
112
- 'tagsinput': 'section', // For entering short text tags <div>
113
- // See: http://ulion.github.io/jsonform/playground/?example=fields-checkboxbuttons
114
-
115
- // Widgets included for compatibility with React JSON Schema Form API
116
- 'updown': 'number',
117
- 'date-time': 'datetime-local',
118
- 'alt-datetime': 'datetime-local',
119
- 'alt-date': 'date',
120
-
121
- // Widgets included for compatibility with Angular Schema Form API
122
- 'wizard': 'section', // TODO: Sequential panels with "Next" and "Previous" buttons
123
-
124
- // Widgets included for compatibility with other libraries
125
- 'textline': 'text',
126
-
127
- // Recommended 3rd-party add-on widgets (TODO: create wrappers for these...)
128
- // 'ng2-select': Select control replacement - http://valor-software.com/ng2-select/
129
- // 'flatpickr': Flatpickr date picker - https://github.com/chmln/flatpickr
130
- // 'pikaday': Pikaday date picker - https://github.com/dbushell/Pikaday
131
- // 'spectrum': Spectrum color picker - http://bgrins.github.io/spectrum
132
- // 'bootstrap-slider': Bootstrap Slider range control - https://github.com/seiyria/bootstrap-slider
133
- // 'ace': ACE code editor - https://ace.c9.io
134
- // 'ckeditor': CKEditor HTML / rich text editor - http://ckeditor.com
135
- // 'tinymce': TinyMCE HTML / rich text editor - https://www.tinymce.com
136
- // 'imageselect': Bootstrap drop-down image selector - http://silviomoreto.github.io/bootstrap-select
137
- // 'wysihtml5': HTML editor - http://jhollingworth.github.io/bootstrap-wysihtml5
138
- // 'quill': Quill HTML / rich text editor (?) - https://quilljs.com
139
- };
140
- registeredWidgets: any = { };
141
- frameworkWidgets: any = { };
142
- activeWidgets: any = { };
143
-
144
- constructor() {
145
- this.setActiveWidgets();
146
- }
147
-
148
- setActiveWidgets(): boolean {
149
- this.activeWidgets = Object.assign(
150
- { }, this.widgetLibrary, this.frameworkWidgets, this.registeredWidgets
151
- );
152
- for (const widgetName of Object.keys(this.activeWidgets)) {
153
- let widget: any = this.activeWidgets[widgetName];
154
- // Resolve aliases
155
- if (typeof widget === 'string') {
156
- const usedAliases: string[] = [];
157
- while (typeof widget === 'string' && !usedAliases.includes(widget)) {
158
- usedAliases.push(widget);
159
- widget = this.activeWidgets[widget];
160
- }
161
- if (typeof widget !== 'string') {
162
- this.activeWidgets[widgetName] = widget;
163
- }
164
- }
165
- }
166
- return true;
167
- }
168
-
169
- setDefaultWidget(type: string): boolean {
170
- if (!this.hasWidget(type)) { return false; }
171
- this.defaultWidget = type;
172
- return true;
173
- }
174
-
175
- hasWidget(type: string, widgetSet = 'activeWidgets'): boolean {
176
- if (!type || typeof type !== 'string') { return false; }
177
- return hasOwn(this[widgetSet], type);
178
- }
179
-
180
- hasDefaultWidget(type: string): boolean {
181
- return this.hasWidget(type, 'widgetLibrary');
182
- }
183
-
184
- registerWidget(type: string, widget: any): boolean {
185
- if (!type || !widget || typeof type !== 'string') { return false; }
186
- this.registeredWidgets[type] = widget;
187
- return this.setActiveWidgets();
188
- }
189
-
190
- unRegisterWidget(type: string): boolean {
191
- if (!hasOwn(this.registeredWidgets, type)) { return false; }
192
- delete this.registeredWidgets[type];
193
- return this.setActiveWidgets();
194
- }
195
-
196
- unRegisterAllWidgets(unRegisterFrameworkWidgets = true): boolean {
197
- this.registeredWidgets = { };
198
- if (unRegisterFrameworkWidgets) { this.frameworkWidgets = { }; }
199
- return this.setActiveWidgets();
200
- }
201
-
202
- registerFrameworkWidgets(widgets: any): boolean {
203
- if (widgets === null || typeof widgets !== 'object') { widgets = { }; }
204
- this.frameworkWidgets = widgets;
205
- return this.setActiveWidgets();
206
- }
207
-
208
- unRegisterFrameworkWidgets(): boolean {
209
- if (Object.keys(this.frameworkWidgets).length) {
210
- this.frameworkWidgets = { };
211
- return this.setActiveWidgets();
212
- }
213
- return false;
214
- }
215
-
216
- getWidget(type?: string, widgetSet = 'activeWidgets'): any {
217
- if (this.hasWidget(type, widgetSet)) {
218
- return this[widgetSet][type];
219
- } else if (this.hasWidget(this.defaultWidget, widgetSet)) {
220
- return this[widgetSet][this.defaultWidget];
221
- } else {
222
- return null;
223
- }
224
- }
225
-
226
- getAllWidgets(): any {
227
- return {
228
- widgetLibrary: this.widgetLibrary,
229
- registeredWidgets: this.registeredWidgets,
230
- frameworkWidgets: this.frameworkWidgets,
231
- activeWidgets: this.activeWidgets,
232
- };
233
- }
234
- }
package/src/test.ts DELETED
@@ -1,18 +0,0 @@
1
- // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
-
3
- import 'core-js/es/reflect';
4
- import 'zone.js';
5
- import 'zone.js/testing';
6
- import { getTestBed } from '@angular/core/testing';
7
- import {
8
- BrowserDynamicTestingModule,
9
- platformBrowserDynamicTesting
10
- } from '@angular/platform-browser-dynamic/testing';
11
-
12
- // First, initialize the Angular testing environment.
13
- getTestBed().initTestEnvironment(
14
- BrowserDynamicTestingModule,
15
- platformBrowserDynamicTesting(), {
16
- teardown: { destroyAfterEach: false }
17
- }
18
- );
package/tsconfig.lib.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../out-tsc/lib",
5
- "declarationMap": true,
6
- "declaration": true,
7
- "inlineSources": true,
8
- "types": [],
9
- "lib": [
10
- "dom",
11
- "es2018"
12
- ]
13
- },
14
- "angularCompilerOptions": {
15
- "skipTemplateCodegen": true,
16
- "strictMetadataEmit": true,
17
- "fullTemplateTypeCheck": true,
18
- "strictInjectionParameters": true,
19
- "enableResourceInlining": true
20
- },
21
- "exclude": [
22
- "src/test.ts",
23
- "**/*.spec.ts"
24
- ]
25
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.lib.json",
3
- "compilerOptions": {
4
- "declarationMap": false
5
- },
6
- "angularCompilerOptions": {
7
- "compilationMode": "partial"
8
- }
9
- }
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../out-tsc/spec",
5
- "types": [
6
- "jasmine",
7
- "node"
8
- ]
9
- },
10
- "files": [
11
- "src/test.ts"
12
- ],
13
- "include": [
14
- "**/*.spec.ts",
15
- "**/*.d.ts"
16
- ]
17
- }
package/tslint.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../../tslint.json",
3
- "rules": {
4
- "directive-selector": [
5
- true,
6
- "attribute",
7
- "lib",
8
- "camelCase"
9
- ]
10
- }
11
- }