@ng-formworks/cssframework 16.3.0 → 17.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.
- package/esm2022/lib/css-framework.component.mjs +264 -264
- package/esm2022/lib/css-framework.defs.mjs +8 -8
- package/esm2022/lib/css-framework.module.mjs +44 -44
- package/esm2022/lib/css-framework.service.mjs +32 -32
- package/esm2022/lib/css.framework.mjs +84 -84
- package/esm2022/ng-formworks-cssframework.mjs +4 -4
- package/esm2022/public-api.mjs +8 -8
- package/fesm2022/ng-formworks-cssframework.mjs +409 -409
- package/fesm2022/ng-formworks-cssframework.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/css-framework.component.d.ts +41 -41
- package/lib/css-framework.defs.d.ts +69 -69
- package/lib/css-framework.module.d.ts +9 -9
- package/lib/css-framework.service.d.ts +12 -12
- package/lib/css.framework.d.ts +18 -18
- package/package.json +4 -4
- package/public-api.d.ts +5 -5
|
@@ -7,425 +7,425 @@ import { Subject } from 'rxjs';
|
|
|
7
7
|
import * as i3 from '@angular/common';
|
|
8
8
|
import { CommonModule } from '@angular/common';
|
|
9
9
|
|
|
10
|
-
class CssframeworkService {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.frameworkThemeSubject = new Subject();
|
|
13
|
-
this.frameworkTheme$ = this.frameworkThemeSubject.asObservable();
|
|
14
|
-
}
|
|
15
|
-
//TODO-review: this acts as a public api to change the theme
|
|
16
|
-
//but doesn't do the actual change, instead it relies on
|
|
17
|
-
//the CssFramewkCoromponent having subscribed to listen
|
|
18
|
-
//and perform the actual theme change
|
|
19
|
-
requestThemeChange(themeName) {
|
|
20
|
-
this.frameworkThemeSubject.next(themeName);
|
|
21
|
-
this.activeRequestedTheme = themeName;
|
|
22
|
-
}
|
|
23
|
-
//TODO-review:there's no way of knowing what the individual component instance
|
|
24
|
-
//has set its theme to, this is just the theme made through the requestThemeChange
|
|
25
|
-
//calls and not guaranteed to correspond to the actual theme set by the
|
|
26
|
-
//component instance themselves
|
|
27
|
-
getActiveRequestedTheme() {
|
|
28
|
-
return this.activeRequestedTheme;
|
|
29
|
-
}
|
|
30
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
31
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
32
|
-
}
|
|
33
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
34
|
-
type: Injectable,
|
|
35
|
-
args: [{
|
|
36
|
-
providedIn: 'root'
|
|
37
|
-
}]
|
|
38
|
-
}], ctorParameters:
|
|
10
|
+
class CssframeworkService {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.frameworkThemeSubject = new Subject();
|
|
13
|
+
this.frameworkTheme$ = this.frameworkThemeSubject.asObservable();
|
|
14
|
+
}
|
|
15
|
+
//TODO-review: this acts as a public api to change the theme
|
|
16
|
+
//but doesn't do the actual change, instead it relies on
|
|
17
|
+
//the CssFramewkCoromponent having subscribed to listen
|
|
18
|
+
//and perform the actual theme change
|
|
19
|
+
requestThemeChange(themeName) {
|
|
20
|
+
this.frameworkThemeSubject.next(themeName);
|
|
21
|
+
this.activeRequestedTheme = themeName;
|
|
22
|
+
}
|
|
23
|
+
//TODO-review:there's no way of knowing what the individual component instance
|
|
24
|
+
//has set its theme to, this is just the theme made through the requestThemeChange
|
|
25
|
+
//calls and not guaranteed to correspond to the actual theme set by the
|
|
26
|
+
//component instance themselves
|
|
27
|
+
getActiveRequestedTheme() {
|
|
28
|
+
return this.activeRequestedTheme;
|
|
29
|
+
}
|
|
30
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssframeworkService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
31
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssframeworkService, providedIn: 'root' }); }
|
|
32
|
+
}
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssframeworkService, decorators: [{
|
|
34
|
+
type: Injectable,
|
|
35
|
+
args: [{
|
|
36
|
+
providedIn: 'root'
|
|
37
|
+
}]
|
|
38
|
+
}], ctorParameters: () => [] });
|
|
39
39
|
|
|
40
|
-
class CssFrameworkComponent {
|
|
41
|
-
//TODO-move to ng-formworks/core utility.functions.ts
|
|
42
|
-
applyCssClasses(type, widgetOptions, styleOptions) {
|
|
43
|
-
//console.log("applyCssClasses for type:"+type);
|
|
44
|
-
let cssClasses = this.widgetStyles[type];
|
|
45
|
-
if (!cssClasses || _.isEmpty(cssClasses)) {
|
|
46
|
-
cssClasses = this.widgetStyles.default;
|
|
47
|
-
}
|
|
48
|
-
Object.keys(cssClasses).forEach(catName => {
|
|
49
|
-
let classList = cssClasses[catName];
|
|
50
|
-
if (classList.length) {
|
|
51
|
-
widgetOptions[catName] = addClasses(widgetOptions[catName], classList);
|
|
52
|
-
}
|
|
53
|
-
if (styleOptions) {
|
|
54
|
-
widgetOptions[catName] = addClasses(widgetOptions[catName], styleOptions);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
flattenWidgetStyles(wstyles) {
|
|
59
|
-
var flattened = {};
|
|
60
|
-
let ignore = ['__themes__'];
|
|
61
|
-
Object.keys(wstyles).forEach(wkey => {
|
|
62
|
-
let wstyle = wstyles[wkey];
|
|
63
|
-
if (ignore.indexOf(wkey) >= 0) {
|
|
64
|
-
flattened[wkey] = wstyle;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (_.isArray(wstyle)) {
|
|
68
|
-
flattened[wkey] = wstyle.join(" ");
|
|
69
|
-
}
|
|
70
|
-
if (_.isObject(wstyle)) { //is csscategories
|
|
71
|
-
flattened[wkey] = flattened[wkey] || {};
|
|
72
|
-
Object.keys(wstyle).forEach(catName => {
|
|
73
|
-
let cssCat = wstyle[catName];
|
|
74
|
-
if (_.isArray(cssCat)) {
|
|
75
|
-
flattened[wkey][catName] = cssCat.join(" ");
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
flattened[wkey][catName] = cssCat;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (_.isString(wstyle)) {
|
|
83
|
-
flattened[wkey] = wstyle;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return flattened;
|
|
87
|
-
}
|
|
88
|
-
constructor(changeDetector, jsf, jsfFLService, cssFWService
|
|
89
|
-
/*@Inject(CSS_FRAMEWORK_CFG ) fwcfg: css_fw.frameworkcfg*/
|
|
90
|
-
) {
|
|
91
|
-
this.changeDetector = changeDetector;
|
|
92
|
-
this.jsf = jsf;
|
|
93
|
-
this.jsfFLService = jsfFLService;
|
|
94
|
-
this.cssFWService = cssFWService;
|
|
95
|
-
this.frameworkInitialized = false;
|
|
96
|
-
this.formControl = null;
|
|
97
|
-
this.debugOutput = '';
|
|
98
|
-
this.debug = '';
|
|
99
|
-
this.parentArray = null;
|
|
100
|
-
this.isOrderable = false;
|
|
101
|
-
this.defaultStyling = {
|
|
102
|
-
array: {},
|
|
103
|
-
default: { fieldHtmlClass: "cssfw-form-control" },
|
|
104
|
-
__themes__: [{ name: 'notheme', text: 'None' }],
|
|
105
|
-
__remove_item__: "cssfw-remove-item",
|
|
106
|
-
__array_item_nonref__: {
|
|
107
|
-
"htmlClass": "cssfw-array-item-nonref"
|
|
108
|
-
},
|
|
109
|
-
__active__: { activeClass: "cssfw-active" },
|
|
110
|
-
__array__: { htmlClass: "cssfw-array" },
|
|
111
|
-
__control_label__: { labelHtmlClass: "cssfw-control-label" },
|
|
112
|
-
__form_group__: { htmlClass: "cssfw-form-group" },
|
|
113
|
-
__field_addon_left__: "cssfw-addon-left",
|
|
114
|
-
__field_addon_right__: "cssfw-addon-right",
|
|
115
|
-
__help_block__: "cssfw-help-block",
|
|
116
|
-
__required_asterisk__: "cssfw-required-astersisk",
|
|
117
|
-
__screen_reader__: "cssfw-screen-reader"
|
|
118
|
-
};
|
|
119
|
-
let activeFramework = this.jsfFLService.activeFramework;
|
|
120
|
-
let fwcfg = activeFramework.config || {};
|
|
121
|
-
this.widgetStyles = Object.assign(this.defaultStyling, fwcfg.widgetstyles);
|
|
122
|
-
let defaultTheme = this.widgetStyles.__themes__[0];
|
|
123
|
-
let defaultThemeName = cssFWService.activeRequestedTheme || defaultTheme.name;
|
|
124
|
-
this.theme = this.options?.theme || defaultThemeName;
|
|
125
|
-
this.frameworkThemeSubs = cssFWService.frameworkTheme$.subscribe(newTheme => {
|
|
126
|
-
this.theme = newTheme;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
ngOnDestroy() {
|
|
130
|
-
this.frameworkThemeSubs.unsubscribe();
|
|
131
|
-
this.frameworkThemeSubs = null;
|
|
132
|
-
}
|
|
133
|
-
get showRemoveButton() {
|
|
134
|
-
if (!this.options.removable || this.options.readonly ||
|
|
135
|
-
this.layoutNode.type === '$ref') {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
if (this.layoutNode.recursiveReference) {
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
if (!this.layoutNode.arrayItem || !this.parentArray) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
// If array length <= minItems, don't allow removing any items
|
|
145
|
-
return this.parentArray.items.length - 1 <= this.parentArray.options.minItems ? false :
|
|
146
|
-
// For removable list items, allow removing any item
|
|
147
|
-
this.layoutNode.arrayItemType === 'list' ? true :
|
|
148
|
-
// For removable tuple items, only allow removing last item in list
|
|
149
|
-
this.layoutIndex[this.layoutIndex.length - 1] === this.parentArray.items.length - 2;
|
|
150
|
-
}
|
|
151
|
-
ngOnInit() {
|
|
152
|
-
this.initializeFramework();
|
|
153
|
-
if (this.layoutNode.arrayItem && this.layoutNode.type !== '$ref') {
|
|
154
|
-
this.parentArray = this.jsf.getParentNode(this);
|
|
155
|
-
if (this.parentArray) {
|
|
156
|
-
this.isOrderable = this.layoutNode.arrayItemType === 'list' &&
|
|
157
|
-
!this.options.readonly && this.parentArray.options.orderable;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
ngOnChanges() {
|
|
162
|
-
if (!this.frameworkInitialized) {
|
|
163
|
-
this.initializeFramework();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
initializeFramework() {
|
|
167
|
-
if (this.layoutNode) {
|
|
168
|
-
this.options = cloneDeep(this.layoutNode.options);
|
|
169
|
-
this.widgetLayoutNode = {
|
|
170
|
-
...this.layoutNode,
|
|
171
|
-
options: cloneDeep(this.layoutNode.options)
|
|
172
|
-
};
|
|
173
|
-
this.widgetOptions = this.widgetLayoutNode.options;
|
|
174
|
-
this.formControl = this.jsf.getFormControl(this);
|
|
175
|
-
this.options.isInputWidget = inArray(this.layoutNode.type, [
|
|
176
|
-
'button', 'checkbox', 'checkboxes-inline', 'checkboxes', 'color',
|
|
177
|
-
'date', 'datetime-local', 'datetime', 'email', 'file', 'hidden',
|
|
178
|
-
'image', 'integer', 'month', 'number', 'password', 'radio',
|
|
179
|
-
'radiobuttons', 'radios-inline', 'radios', 'range', 'reset', 'search',
|
|
180
|
-
'select', 'submit', 'tel', 'text', 'textarea', 'time', 'url', 'week'
|
|
181
|
-
]);
|
|
182
|
-
this.options.title = this.setTitle();
|
|
183
|
-
this.options.htmlClass =
|
|
184
|
-
addClasses(this.options.htmlClass, 'schema-form-' + this.layoutNode.type);
|
|
185
|
-
if (this.layoutNode.type === 'array') {
|
|
186
|
-
this.options.htmlClass = addClasses(this.options.htmlClass, this.widgetStyles.__array__.htmlClass);
|
|
187
|
-
}
|
|
188
|
-
else if (this.layoutNode.arrayItem && this.layoutNode.type !== '$ref') {
|
|
189
|
-
this.options.htmlClass = addClasses(this.options.htmlClass, this.widgetStyles.__array_item_nonref__.htmlClass);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
this.options.htmlClass = addClasses(this.options.htmlClass, this.widgetStyles.__form_group__.htmlClass);
|
|
193
|
-
}
|
|
194
|
-
/*
|
|
195
|
-
this.options.htmlClass =
|
|
196
|
-
this.layoutNode.type === 'array' ?
|
|
197
|
-
addClasses(this.options.htmlClass, ['border','shadow-md','p-1']) :
|
|
198
|
-
this.layoutNode.arrayItem && this.layoutNode.type !== '$ref' ?
|
|
199
|
-
addClasses(this.options.htmlClass, ['border','shadow-md','p-1']) :
|
|
200
|
-
addClasses(this.options.htmlClass, 'mb-1');
|
|
201
|
-
*/
|
|
202
|
-
/*
|
|
203
|
-
this.options.htmlClass =
|
|
204
|
-
this.layoutNode.type === 'array' ?
|
|
205
|
-
addClasses(this.options.htmlClass, this.widgetStyles.array.htmlClass):
|
|
206
|
-
this.layoutNode.arrayItem && this.layoutNode.type !== '$ref' ?
|
|
207
|
-
addClasses(this.options.htmlClass, this.widgetStyles.__array_item_nonref__.htmlClass):
|
|
208
|
-
addClasses(this.options.htmlClass, this.widgetStyles.__form_group__.htmlClass);
|
|
209
|
-
*/
|
|
210
|
-
this.widgetOptions.htmlClass = '';
|
|
211
|
-
this.options.labelHtmlClass =
|
|
212
|
-
addClasses(this.options.labelHtmlClass, this.widgetStyles.__control_label__.labelHtmlClass);
|
|
213
|
-
this.widgetOptions.activeClass =
|
|
214
|
-
addClasses(this.widgetOptions.activeClass, this.widgetStyles.__active__.activeClass);
|
|
215
|
-
this.options.fieldAddonLeft =
|
|
216
|
-
this.options.fieldAddonLeft || this.options.prepend;
|
|
217
|
-
this.options.fieldAddonRight =
|
|
218
|
-
this.options.fieldAddonRight || this.options.append;
|
|
219
|
-
// Add asterisk to titles if required
|
|
220
|
-
if (this.options.title && this.layoutNode.type !== 'tab' &&
|
|
221
|
-
!this.options.notitle && this.options.required &&
|
|
222
|
-
!this.options.title.includes('*')) {
|
|
223
|
-
let required_asterisk_class = this.widgetStyles.__required_asterisk__ || 'text-danger';
|
|
224
|
-
this.options.title += ` <strong class="${required_asterisk_class}">*</strong>`;
|
|
225
|
-
}
|
|
226
|
-
if (this.layoutNode.type == 'optionfieldset') {
|
|
227
|
-
this.options.messageLocation = 'top';
|
|
228
|
-
}
|
|
229
|
-
// Set miscelaneous styles and settings for each control type
|
|
230
|
-
this.applyCssClasses(this.layoutNode.type, this.widgetOptions, this.options.style);
|
|
231
|
-
if (this.formControl) {
|
|
232
|
-
this.updateHelpBlock(this.formControl.status);
|
|
233
|
-
this.formControl.statusChanges.subscribe(status => this.updateHelpBlock(status));
|
|
234
|
-
if (this.options.debug) {
|
|
235
|
-
const vars = [];
|
|
236
|
-
this.debugOutput = map(vars, thisVar => JSON.stringify(thisVar, null, 2)).join('\n');
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
this.frameworkInitialized = true;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
updateHelpBlock(status) {
|
|
243
|
-
this.options.helpBlock = status === 'INVALID' &&
|
|
244
|
-
this.options.enableErrorState && this.formControl.errors &&
|
|
245
|
-
(this.formControl.dirty || this.options.feedbackOnRender) ?
|
|
246
|
-
this.jsf.formatErrors(this.formControl.errors, this.options.validationMessages) :
|
|
247
|
-
this.options.description || this.options.help || null;
|
|
248
|
-
}
|
|
249
|
-
setTitle() {
|
|
250
|
-
switch (this.layoutNode.type) {
|
|
251
|
-
case 'button':
|
|
252
|
-
case 'checkbox':
|
|
253
|
-
case 'section':
|
|
254
|
-
case 'help':
|
|
255
|
-
case 'msg':
|
|
256
|
-
case 'submit':
|
|
257
|
-
case 'message':
|
|
258
|
-
case 'tabarray':
|
|
259
|
-
case 'tabs':
|
|
260
|
-
case '$ref':
|
|
261
|
-
return null;
|
|
262
|
-
case 'advancedfieldset':
|
|
263
|
-
this.widgetOptions.expandable = true;
|
|
264
|
-
this.widgetOptions.title = 'Advanced options';
|
|
265
|
-
return null;
|
|
266
|
-
case 'authfieldset':
|
|
267
|
-
this.widgetOptions.expandable = true;
|
|
268
|
-
this.widgetOptions.title = 'Authentication settings';
|
|
269
|
-
return null;
|
|
270
|
-
case 'fieldset':
|
|
271
|
-
this.widgetOptions.title = this.options.title;
|
|
272
|
-
return null;
|
|
273
|
-
default:
|
|
274
|
-
this.widgetOptions.title = null;
|
|
275
|
-
return this.jsf.setItemTitle(this);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
removeItem() {
|
|
279
|
-
this.jsf.removeItem(this);
|
|
280
|
-
}
|
|
281
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
282
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
283
|
-
}
|
|
284
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
285
|
-
type: Component,
|
|
286
|
-
args: [{ selector: 'css-framework', encapsulation: ViewEncapsulation.None, template: "<div [attr.data-bs-theme]=\"theme\" [attr.data-theme]=\"theme\" [class]=\"options?.htmlClass || ''\" [class.has-feedback]=\"options?.feedback && options?.isInputWidget &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.has-error]=\"options?.enableErrorState && formControl?.errors &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.has-success]=\"options?.enableSuccessState && !formControl?.errors &&\r\n (formControl?.dirty || options?.feedbackOnRender)\">\r\n\r\n <button *ngIf=\"showRemoveButton\" [class]=\"widgetStyles.__remove_item__\" type=\"button\" (click)=\"removeItem()\">\r\n <span aria-hidden=\"true\">×</span>\r\n <span [class]=\"widgetStyles.__screen_reader__\">Close</span>\r\n </button>\r\n <div *ngIf=\"options?.messageLocation === 'top'\">\r\n <p *ngIf=\"options?.helpBlock\" [class]=\"widgetStyles.__help_block__\" [innerHTML]=\"options?.helpBlock\"></p>\r\n </div>\r\n\r\n <label *ngIf=\"options?.title && layoutNode?.type !== 'tab'\" [attr.for]=\"'control' + layoutNode?._id\" [class]=\"options?.labelHtmlClass || ''\" [class.sr-only]=\"options?.notitle\" [innerHTML]=\"options?.title\"></label>\r\n <p *ngIf=\"layoutNode?.type === 'submit' && jsf?.formOptions?.fieldsRequired\">\r\n <strong [class]=\"widgetStyles.__required_asterisk__\">*</strong> = required fields\r\n </p>\r\n <div [class.input-group]=\"options?.fieldAddonLeft || options?.fieldAddonRight\">\r\n <span *ngIf=\"options?.fieldAddonLeft\" [class]=\"widgetStyles.__field_addon_left__\" [innerHTML]=\"options?.fieldAddonLeft\"></span>\r\n\r\n <select-widget-widget [layoutNode]=\"widgetLayoutNode\" [dataIndex]=\"dataIndex\" [layoutIndex]=\"layoutIndex\"></select-widget-widget>\r\n\r\n <span *ngIf=\"options?.fieldAddonRight\" [class]=\"widgetStyles.__field_addon_right__\" [innerHTML]=\"options?.fieldAddonRight\"></span>\r\n </div>\r\n\r\n <span *ngIf=\"options?.feedback && options?.isInputWidget &&\r\n !options?.fieldAddonRight && !layoutNode.arrayItem &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.glyphicon-ok]=\"options?.enableSuccessState && !formControl?.errors\" [class.glyphicon-remove]=\"options?.enableErrorState && formControl?.errors\" aria-hidden=\"true\" class=\"form-control-feedback glyphicon\"></span>\r\n <div *ngIf=\"options?.messageLocation !== 'top'\">\r\n <p *ngIf=\"options?.helpBlock\" [class]=\"widgetStyles.__help_block__\" [innerHTML]=\"options?.helpBlock\"></p>\r\n </div>\r\n\r\n</div>\r\n\r\n<div *ngIf=\"debug && debugOutput\">debug:\r\n <pre>{{debugOutput}}</pre>\r\n</div>\r\n\r\n<!--\r\n<div class=\"btn input input-bordered input-primary w-full max-w-xs\r\nbtn-neutral\r\nbtn-primary\r\nbtn-secondary\r\nbtn-accent\r\nbtn-info\r\nbtn-success\r\nbtn-warning\r\nbtn-error\r\nbtn-ghost\r\nbtn-link\r\nbtn-outline\r\nbtn-active\r\nbtn-disabled\r\nglass\r\nno-animation\r\nbtn-lg\r\nbtn-md\r\nbtn-sm\r\nbtn-xs\r\nbtn-wide\r\nbtn-block\r\nbtn-circle\r\nbtn-square\r\nhidden\r\n\">defs al</div>\r\n-->\r\n<!--<input type=\"text\" placeholder=\"Type here\" class=\"input input-bordered input-primary w-full max-w-xs\" />-->", styles: [":host ::ng-deep .list-group-item .form-control-feedback{top:40px}:host ::ng-deep .checkbox,:host ::ng-deep .radio{margin-top:0;margin-bottom:0}:host ::ng-deep .checkbox-inline,:host ::ng-deep .checkbox-inline+.checkbox-inline,:host ::ng-deep .checkbox-inline+.radio-inline,:host ::ng-deep .radio-inline,:host ::ng-deep .radio-inline+.radio-inline,:host ::ng-deep .radio-inline+.checkbox-inline{margin-left:0;margin-right:10px}:host ::ng-deep .checkbox-inline:last-child,:host ::ng-deep .radio-inline:last-child{margin-right:0}:host ::ng-deep .ng-invalid.ng-touched{border:1px solid #f44336}.checkbox-inline,.checkbox-inline+.checkbox-inline,.checkbox-inline+.radio-inline,.radio-inline,.radio-inline+.radio-inline,.radio-inline+.checkbox-inline{margin-left:0;margin-right:10px}.checkbox-inline:last-child,.radio-inline:last-child{margin-right:0}.ng-invalid.ng-touched{border:1px solid #f44336}\n"] }]
|
|
287
|
-
}], ctorParameters:
|
|
288
|
-
type: Input
|
|
289
|
-
}], layoutIndex: [{
|
|
290
|
-
type: Input
|
|
291
|
-
}], dataIndex: [{
|
|
292
|
-
type: Input
|
|
293
|
-
}], widgetStyles: [{
|
|
294
|
-
type: Input
|
|
40
|
+
class CssFrameworkComponent {
|
|
41
|
+
//TODO-move to ng-formworks/core utility.functions.ts
|
|
42
|
+
applyCssClasses(type, widgetOptions, styleOptions) {
|
|
43
|
+
//console.log("applyCssClasses for type:"+type);
|
|
44
|
+
let cssClasses = this.widgetStyles[type];
|
|
45
|
+
if (!cssClasses || _.isEmpty(cssClasses)) {
|
|
46
|
+
cssClasses = this.widgetStyles.default;
|
|
47
|
+
}
|
|
48
|
+
Object.keys(cssClasses).forEach(catName => {
|
|
49
|
+
let classList = cssClasses[catName];
|
|
50
|
+
if (classList.length) {
|
|
51
|
+
widgetOptions[catName] = addClasses(widgetOptions[catName], classList);
|
|
52
|
+
}
|
|
53
|
+
if (styleOptions) {
|
|
54
|
+
widgetOptions[catName] = addClasses(widgetOptions[catName], styleOptions);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
flattenWidgetStyles(wstyles) {
|
|
59
|
+
var flattened = {};
|
|
60
|
+
let ignore = ['__themes__'];
|
|
61
|
+
Object.keys(wstyles).forEach(wkey => {
|
|
62
|
+
let wstyle = wstyles[wkey];
|
|
63
|
+
if (ignore.indexOf(wkey) >= 0) {
|
|
64
|
+
flattened[wkey] = wstyle;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (_.isArray(wstyle)) {
|
|
68
|
+
flattened[wkey] = wstyle.join(" ");
|
|
69
|
+
}
|
|
70
|
+
if (_.isObject(wstyle)) { //is csscategories
|
|
71
|
+
flattened[wkey] = flattened[wkey] || {};
|
|
72
|
+
Object.keys(wstyle).forEach(catName => {
|
|
73
|
+
let cssCat = wstyle[catName];
|
|
74
|
+
if (_.isArray(cssCat)) {
|
|
75
|
+
flattened[wkey][catName] = cssCat.join(" ");
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
flattened[wkey][catName] = cssCat;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (_.isString(wstyle)) {
|
|
83
|
+
flattened[wkey] = wstyle;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return flattened;
|
|
87
|
+
}
|
|
88
|
+
constructor(changeDetector, jsf, jsfFLService, cssFWService
|
|
89
|
+
/*@Inject(CSS_FRAMEWORK_CFG ) fwcfg: css_fw.frameworkcfg*/
|
|
90
|
+
) {
|
|
91
|
+
this.changeDetector = changeDetector;
|
|
92
|
+
this.jsf = jsf;
|
|
93
|
+
this.jsfFLService = jsfFLService;
|
|
94
|
+
this.cssFWService = cssFWService;
|
|
95
|
+
this.frameworkInitialized = false;
|
|
96
|
+
this.formControl = null;
|
|
97
|
+
this.debugOutput = '';
|
|
98
|
+
this.debug = '';
|
|
99
|
+
this.parentArray = null;
|
|
100
|
+
this.isOrderable = false;
|
|
101
|
+
this.defaultStyling = {
|
|
102
|
+
array: {},
|
|
103
|
+
default: { fieldHtmlClass: "cssfw-form-control" },
|
|
104
|
+
__themes__: [{ name: 'notheme', text: 'None' }],
|
|
105
|
+
__remove_item__: "cssfw-remove-item",
|
|
106
|
+
__array_item_nonref__: {
|
|
107
|
+
"htmlClass": "cssfw-array-item-nonref"
|
|
108
|
+
},
|
|
109
|
+
__active__: { activeClass: "cssfw-active" },
|
|
110
|
+
__array__: { htmlClass: "cssfw-array" },
|
|
111
|
+
__control_label__: { labelHtmlClass: "cssfw-control-label" },
|
|
112
|
+
__form_group__: { htmlClass: "cssfw-form-group" },
|
|
113
|
+
__field_addon_left__: "cssfw-addon-left",
|
|
114
|
+
__field_addon_right__: "cssfw-addon-right",
|
|
115
|
+
__help_block__: "cssfw-help-block",
|
|
116
|
+
__required_asterisk__: "cssfw-required-astersisk",
|
|
117
|
+
__screen_reader__: "cssfw-screen-reader"
|
|
118
|
+
};
|
|
119
|
+
let activeFramework = this.jsfFLService.activeFramework;
|
|
120
|
+
let fwcfg = activeFramework.config || {};
|
|
121
|
+
this.widgetStyles = Object.assign(this.defaultStyling, fwcfg.widgetstyles);
|
|
122
|
+
let defaultTheme = this.widgetStyles.__themes__[0];
|
|
123
|
+
let defaultThemeName = cssFWService.activeRequestedTheme || defaultTheme.name;
|
|
124
|
+
this.theme = this.options?.theme || defaultThemeName;
|
|
125
|
+
this.frameworkThemeSubs = cssFWService.frameworkTheme$.subscribe(newTheme => {
|
|
126
|
+
this.theme = newTheme;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
ngOnDestroy() {
|
|
130
|
+
this.frameworkThemeSubs.unsubscribe();
|
|
131
|
+
this.frameworkThemeSubs = null;
|
|
132
|
+
}
|
|
133
|
+
get showRemoveButton() {
|
|
134
|
+
if (!this.options.removable || this.options.readonly ||
|
|
135
|
+
this.layoutNode.type === '$ref') {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if (this.layoutNode.recursiveReference) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if (!this.layoutNode.arrayItem || !this.parentArray) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
// If array length <= minItems, don't allow removing any items
|
|
145
|
+
return this.parentArray.items.length - 1 <= this.parentArray.options.minItems ? false :
|
|
146
|
+
// For removable list items, allow removing any item
|
|
147
|
+
this.layoutNode.arrayItemType === 'list' ? true :
|
|
148
|
+
// For removable tuple items, only allow removing last item in list
|
|
149
|
+
this.layoutIndex[this.layoutIndex.length - 1] === this.parentArray.items.length - 2;
|
|
150
|
+
}
|
|
151
|
+
ngOnInit() {
|
|
152
|
+
this.initializeFramework();
|
|
153
|
+
if (this.layoutNode.arrayItem && this.layoutNode.type !== '$ref') {
|
|
154
|
+
this.parentArray = this.jsf.getParentNode(this);
|
|
155
|
+
if (this.parentArray) {
|
|
156
|
+
this.isOrderable = this.layoutNode.arrayItemType === 'list' &&
|
|
157
|
+
!this.options.readonly && this.parentArray.options.orderable;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
ngOnChanges() {
|
|
162
|
+
if (!this.frameworkInitialized) {
|
|
163
|
+
this.initializeFramework();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
initializeFramework() {
|
|
167
|
+
if (this.layoutNode) {
|
|
168
|
+
this.options = cloneDeep(this.layoutNode.options);
|
|
169
|
+
this.widgetLayoutNode = {
|
|
170
|
+
...this.layoutNode,
|
|
171
|
+
options: cloneDeep(this.layoutNode.options)
|
|
172
|
+
};
|
|
173
|
+
this.widgetOptions = this.widgetLayoutNode.options;
|
|
174
|
+
this.formControl = this.jsf.getFormControl(this);
|
|
175
|
+
this.options.isInputWidget = inArray(this.layoutNode.type, [
|
|
176
|
+
'button', 'checkbox', 'checkboxes-inline', 'checkboxes', 'color',
|
|
177
|
+
'date', 'datetime-local', 'datetime', 'email', 'file', 'hidden',
|
|
178
|
+
'image', 'integer', 'month', 'number', 'password', 'radio',
|
|
179
|
+
'radiobuttons', 'radios-inline', 'radios', 'range', 'reset', 'search',
|
|
180
|
+
'select', 'submit', 'tel', 'text', 'textarea', 'time', 'url', 'week'
|
|
181
|
+
]);
|
|
182
|
+
this.options.title = this.setTitle();
|
|
183
|
+
this.options.htmlClass =
|
|
184
|
+
addClasses(this.options.htmlClass, 'schema-form-' + this.layoutNode.type);
|
|
185
|
+
if (this.layoutNode.type === 'array') {
|
|
186
|
+
this.options.htmlClass = addClasses(this.options.htmlClass, this.widgetStyles.__array__.htmlClass);
|
|
187
|
+
}
|
|
188
|
+
else if (this.layoutNode.arrayItem && this.layoutNode.type !== '$ref') {
|
|
189
|
+
this.options.htmlClass = addClasses(this.options.htmlClass, this.widgetStyles.__array_item_nonref__.htmlClass);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
this.options.htmlClass = addClasses(this.options.htmlClass, this.widgetStyles.__form_group__.htmlClass);
|
|
193
|
+
}
|
|
194
|
+
/*
|
|
195
|
+
this.options.htmlClass =
|
|
196
|
+
this.layoutNode.type === 'array' ?
|
|
197
|
+
addClasses(this.options.htmlClass, ['border','shadow-md','p-1']) :
|
|
198
|
+
this.layoutNode.arrayItem && this.layoutNode.type !== '$ref' ?
|
|
199
|
+
addClasses(this.options.htmlClass, ['border','shadow-md','p-1']) :
|
|
200
|
+
addClasses(this.options.htmlClass, 'mb-1');
|
|
201
|
+
*/
|
|
202
|
+
/*
|
|
203
|
+
this.options.htmlClass =
|
|
204
|
+
this.layoutNode.type === 'array' ?
|
|
205
|
+
addClasses(this.options.htmlClass, this.widgetStyles.array.htmlClass):
|
|
206
|
+
this.layoutNode.arrayItem && this.layoutNode.type !== '$ref' ?
|
|
207
|
+
addClasses(this.options.htmlClass, this.widgetStyles.__array_item_nonref__.htmlClass):
|
|
208
|
+
addClasses(this.options.htmlClass, this.widgetStyles.__form_group__.htmlClass);
|
|
209
|
+
*/
|
|
210
|
+
this.widgetOptions.htmlClass = '';
|
|
211
|
+
this.options.labelHtmlClass =
|
|
212
|
+
addClasses(this.options.labelHtmlClass, this.widgetStyles.__control_label__.labelHtmlClass);
|
|
213
|
+
this.widgetOptions.activeClass =
|
|
214
|
+
addClasses(this.widgetOptions.activeClass, this.widgetStyles.__active__.activeClass);
|
|
215
|
+
this.options.fieldAddonLeft =
|
|
216
|
+
this.options.fieldAddonLeft || this.options.prepend;
|
|
217
|
+
this.options.fieldAddonRight =
|
|
218
|
+
this.options.fieldAddonRight || this.options.append;
|
|
219
|
+
// Add asterisk to titles if required
|
|
220
|
+
if (this.options.title && this.layoutNode.type !== 'tab' &&
|
|
221
|
+
!this.options.notitle && this.options.required &&
|
|
222
|
+
!this.options.title.includes('*')) {
|
|
223
|
+
let required_asterisk_class = this.widgetStyles.__required_asterisk__ || 'text-danger';
|
|
224
|
+
this.options.title += ` <strong class="${required_asterisk_class}">*</strong>`;
|
|
225
|
+
}
|
|
226
|
+
if (this.layoutNode.type == 'optionfieldset') {
|
|
227
|
+
this.options.messageLocation = 'top';
|
|
228
|
+
}
|
|
229
|
+
// Set miscelaneous styles and settings for each control type
|
|
230
|
+
this.applyCssClasses(this.layoutNode.type, this.widgetOptions, this.options.style);
|
|
231
|
+
if (this.formControl) {
|
|
232
|
+
this.updateHelpBlock(this.formControl.status);
|
|
233
|
+
this.formControl.statusChanges.subscribe(status => this.updateHelpBlock(status));
|
|
234
|
+
if (this.options.debug) {
|
|
235
|
+
const vars = [];
|
|
236
|
+
this.debugOutput = map(vars, thisVar => JSON.stringify(thisVar, null, 2)).join('\n');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
this.frameworkInitialized = true;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
updateHelpBlock(status) {
|
|
243
|
+
this.options.helpBlock = status === 'INVALID' &&
|
|
244
|
+
this.options.enableErrorState && this.formControl.errors &&
|
|
245
|
+
(this.formControl.dirty || this.options.feedbackOnRender) ?
|
|
246
|
+
this.jsf.formatErrors(this.formControl.errors, this.options.validationMessages) :
|
|
247
|
+
this.options.description || this.options.help || null;
|
|
248
|
+
}
|
|
249
|
+
setTitle() {
|
|
250
|
+
switch (this.layoutNode.type) {
|
|
251
|
+
case 'button':
|
|
252
|
+
case 'checkbox':
|
|
253
|
+
case 'section':
|
|
254
|
+
case 'help':
|
|
255
|
+
case 'msg':
|
|
256
|
+
case 'submit':
|
|
257
|
+
case 'message':
|
|
258
|
+
case 'tabarray':
|
|
259
|
+
case 'tabs':
|
|
260
|
+
case '$ref':
|
|
261
|
+
return null;
|
|
262
|
+
case 'advancedfieldset':
|
|
263
|
+
this.widgetOptions.expandable = true;
|
|
264
|
+
this.widgetOptions.title = 'Advanced options';
|
|
265
|
+
return null;
|
|
266
|
+
case 'authfieldset':
|
|
267
|
+
this.widgetOptions.expandable = true;
|
|
268
|
+
this.widgetOptions.title = 'Authentication settings';
|
|
269
|
+
return null;
|
|
270
|
+
case 'fieldset':
|
|
271
|
+
this.widgetOptions.title = this.options.title;
|
|
272
|
+
return null;
|
|
273
|
+
default:
|
|
274
|
+
this.widgetOptions.title = null;
|
|
275
|
+
return this.jsf.setItemTitle(this);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
removeItem() {
|
|
279
|
+
this.jsf.removeItem(this);
|
|
280
|
+
}
|
|
281
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFrameworkComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.JsonSchemaFormService }, { token: i1.FrameworkLibraryService }, { token: CssframeworkService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
282
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: CssFrameworkComponent, selector: "css-framework", inputs: { layoutNode: "layoutNode", layoutIndex: "layoutIndex", dataIndex: "dataIndex", widgetStyles: "widgetStyles" }, usesOnChanges: true, ngImport: i0, template: "<div [attr.data-bs-theme]=\"theme\" [attr.data-theme]=\"theme\" [class]=\"options?.htmlClass || ''\" [class.has-feedback]=\"options?.feedback && options?.isInputWidget &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.has-error]=\"options?.enableErrorState && formControl?.errors &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.has-success]=\"options?.enableSuccessState && !formControl?.errors &&\r\n (formControl?.dirty || options?.feedbackOnRender)\">\r\n\r\n <button *ngIf=\"showRemoveButton\" [class]=\"widgetStyles.__remove_item__\" type=\"button\" (click)=\"removeItem()\">\r\n <span aria-hidden=\"true\">×</span>\r\n <span [class]=\"widgetStyles.__screen_reader__\">Close</span>\r\n </button>\r\n <div *ngIf=\"options?.messageLocation === 'top'\">\r\n <p *ngIf=\"options?.helpBlock\" [class]=\"widgetStyles.__help_block__\" [innerHTML]=\"options?.helpBlock\"></p>\r\n </div>\r\n\r\n <label *ngIf=\"options?.title && layoutNode?.type !== 'tab'\" [attr.for]=\"'control' + layoutNode?._id\" [class]=\"options?.labelHtmlClass || ''\" [class.sr-only]=\"options?.notitle\" [innerHTML]=\"options?.title\"></label>\r\n <p *ngIf=\"layoutNode?.type === 'submit' && jsf?.formOptions?.fieldsRequired\">\r\n <strong [class]=\"widgetStyles.__required_asterisk__\">*</strong> = required fields\r\n </p>\r\n <div [class.input-group]=\"options?.fieldAddonLeft || options?.fieldAddonRight\">\r\n <span *ngIf=\"options?.fieldAddonLeft\" [class]=\"widgetStyles.__field_addon_left__\" [innerHTML]=\"options?.fieldAddonLeft\"></span>\r\n\r\n <select-widget-widget [layoutNode]=\"widgetLayoutNode\" [dataIndex]=\"dataIndex\" [layoutIndex]=\"layoutIndex\"></select-widget-widget>\r\n\r\n <span *ngIf=\"options?.fieldAddonRight\" [class]=\"widgetStyles.__field_addon_right__\" [innerHTML]=\"options?.fieldAddonRight\"></span>\r\n </div>\r\n\r\n <span *ngIf=\"options?.feedback && options?.isInputWidget &&\r\n !options?.fieldAddonRight && !layoutNode.arrayItem &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.glyphicon-ok]=\"options?.enableSuccessState && !formControl?.errors\" [class.glyphicon-remove]=\"options?.enableErrorState && formControl?.errors\" aria-hidden=\"true\" class=\"form-control-feedback glyphicon\"></span>\r\n <div *ngIf=\"options?.messageLocation !== 'top'\">\r\n <p *ngIf=\"options?.helpBlock\" [class]=\"widgetStyles.__help_block__\" [innerHTML]=\"options?.helpBlock\"></p>\r\n </div>\r\n\r\n</div>\r\n\r\n<div *ngIf=\"debug && debugOutput\">debug:\r\n <pre>{{debugOutput}}</pre>\r\n</div>\r\n\r\n<!--\r\n<div class=\"btn input input-bordered input-primary w-full max-w-xs\r\nbtn-neutral\r\nbtn-primary\r\nbtn-secondary\r\nbtn-accent\r\nbtn-info\r\nbtn-success\r\nbtn-warning\r\nbtn-error\r\nbtn-ghost\r\nbtn-link\r\nbtn-outline\r\nbtn-active\r\nbtn-disabled\r\nglass\r\nno-animation\r\nbtn-lg\r\nbtn-md\r\nbtn-sm\r\nbtn-xs\r\nbtn-wide\r\nbtn-block\r\nbtn-circle\r\nbtn-square\r\nhidden\r\n\">defs al</div>\r\n-->\r\n<!--<input type=\"text\" placeholder=\"Type here\" class=\"input input-bordered input-primary w-full max-w-xs\" />-->", styles: [":host ::ng-deep .list-group-item .form-control-feedback{top:40px}:host ::ng-deep .checkbox,:host ::ng-deep .radio{margin-top:0;margin-bottom:0}:host ::ng-deep .checkbox-inline,:host ::ng-deep .checkbox-inline+.checkbox-inline,:host ::ng-deep .checkbox-inline+.radio-inline,:host ::ng-deep .radio-inline,:host ::ng-deep .radio-inline+.radio-inline,:host ::ng-deep .radio-inline+.checkbox-inline{margin-left:0;margin-right:10px}:host ::ng-deep .checkbox-inline:last-child,:host ::ng-deep .radio-inline:last-child{margin-right:0}:host ::ng-deep .ng-invalid.ng-touched{border:1px solid #f44336}.checkbox-inline,.checkbox-inline+.checkbox-inline,.checkbox-inline+.radio-inline,.radio-inline,.radio-inline+.radio-inline,.radio-inline+.checkbox-inline{margin-left:0;margin-right:10px}.checkbox-inline:last-child,.radio-inline:last-child{margin-right:0}.ng-invalid.ng-touched{border:1px solid #f44336}\n"], dependencies: [{ kind: "component", type: i1.SelectWidgetComponent, selector: "select-widget-widget", inputs: ["layoutNode", "layoutIndex", "dataIndex"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
283
|
+
}
|
|
284
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFrameworkComponent, decorators: [{
|
|
285
|
+
type: Component,
|
|
286
|
+
args: [{ selector: 'css-framework', encapsulation: ViewEncapsulation.None, template: "<div [attr.data-bs-theme]=\"theme\" [attr.data-theme]=\"theme\" [class]=\"options?.htmlClass || ''\" [class.has-feedback]=\"options?.feedback && options?.isInputWidget &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.has-error]=\"options?.enableErrorState && formControl?.errors &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.has-success]=\"options?.enableSuccessState && !formControl?.errors &&\r\n (formControl?.dirty || options?.feedbackOnRender)\">\r\n\r\n <button *ngIf=\"showRemoveButton\" [class]=\"widgetStyles.__remove_item__\" type=\"button\" (click)=\"removeItem()\">\r\n <span aria-hidden=\"true\">×</span>\r\n <span [class]=\"widgetStyles.__screen_reader__\">Close</span>\r\n </button>\r\n <div *ngIf=\"options?.messageLocation === 'top'\">\r\n <p *ngIf=\"options?.helpBlock\" [class]=\"widgetStyles.__help_block__\" [innerHTML]=\"options?.helpBlock\"></p>\r\n </div>\r\n\r\n <label *ngIf=\"options?.title && layoutNode?.type !== 'tab'\" [attr.for]=\"'control' + layoutNode?._id\" [class]=\"options?.labelHtmlClass || ''\" [class.sr-only]=\"options?.notitle\" [innerHTML]=\"options?.title\"></label>\r\n <p *ngIf=\"layoutNode?.type === 'submit' && jsf?.formOptions?.fieldsRequired\">\r\n <strong [class]=\"widgetStyles.__required_asterisk__\">*</strong> = required fields\r\n </p>\r\n <div [class.input-group]=\"options?.fieldAddonLeft || options?.fieldAddonRight\">\r\n <span *ngIf=\"options?.fieldAddonLeft\" [class]=\"widgetStyles.__field_addon_left__\" [innerHTML]=\"options?.fieldAddonLeft\"></span>\r\n\r\n <select-widget-widget [layoutNode]=\"widgetLayoutNode\" [dataIndex]=\"dataIndex\" [layoutIndex]=\"layoutIndex\"></select-widget-widget>\r\n\r\n <span *ngIf=\"options?.fieldAddonRight\" [class]=\"widgetStyles.__field_addon_right__\" [innerHTML]=\"options?.fieldAddonRight\"></span>\r\n </div>\r\n\r\n <span *ngIf=\"options?.feedback && options?.isInputWidget &&\r\n !options?.fieldAddonRight && !layoutNode.arrayItem &&\r\n (formControl?.dirty || options?.feedbackOnRender)\" [class.glyphicon-ok]=\"options?.enableSuccessState && !formControl?.errors\" [class.glyphicon-remove]=\"options?.enableErrorState && formControl?.errors\" aria-hidden=\"true\" class=\"form-control-feedback glyphicon\"></span>\r\n <div *ngIf=\"options?.messageLocation !== 'top'\">\r\n <p *ngIf=\"options?.helpBlock\" [class]=\"widgetStyles.__help_block__\" [innerHTML]=\"options?.helpBlock\"></p>\r\n </div>\r\n\r\n</div>\r\n\r\n<div *ngIf=\"debug && debugOutput\">debug:\r\n <pre>{{debugOutput}}</pre>\r\n</div>\r\n\r\n<!--\r\n<div class=\"btn input input-bordered input-primary w-full max-w-xs\r\nbtn-neutral\r\nbtn-primary\r\nbtn-secondary\r\nbtn-accent\r\nbtn-info\r\nbtn-success\r\nbtn-warning\r\nbtn-error\r\nbtn-ghost\r\nbtn-link\r\nbtn-outline\r\nbtn-active\r\nbtn-disabled\r\nglass\r\nno-animation\r\nbtn-lg\r\nbtn-md\r\nbtn-sm\r\nbtn-xs\r\nbtn-wide\r\nbtn-block\r\nbtn-circle\r\nbtn-square\r\nhidden\r\n\">defs al</div>\r\n-->\r\n<!--<input type=\"text\" placeholder=\"Type here\" class=\"input input-bordered input-primary w-full max-w-xs\" />-->", styles: [":host ::ng-deep .list-group-item .form-control-feedback{top:40px}:host ::ng-deep .checkbox,:host ::ng-deep .radio{margin-top:0;margin-bottom:0}:host ::ng-deep .checkbox-inline,:host ::ng-deep .checkbox-inline+.checkbox-inline,:host ::ng-deep .checkbox-inline+.radio-inline,:host ::ng-deep .radio-inline,:host ::ng-deep .radio-inline+.radio-inline,:host ::ng-deep .radio-inline+.checkbox-inline{margin-left:0;margin-right:10px}:host ::ng-deep .checkbox-inline:last-child,:host ::ng-deep .radio-inline:last-child{margin-right:0}:host ::ng-deep .ng-invalid.ng-touched{border:1px solid #f44336}.checkbox-inline,.checkbox-inline+.checkbox-inline,.checkbox-inline+.radio-inline,.radio-inline,.radio-inline+.radio-inline,.radio-inline+.checkbox-inline{margin-left:0;margin-right:10px}.checkbox-inline:last-child,.radio-inline:last-child{margin-right:0}.ng-invalid.ng-touched{border:1px solid #f44336}\n"] }]
|
|
287
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i1.JsonSchemaFormService }, { type: i1.FrameworkLibraryService }, { type: CssframeworkService }], propDecorators: { layoutNode: [{
|
|
288
|
+
type: Input
|
|
289
|
+
}], layoutIndex: [{
|
|
290
|
+
type: Input
|
|
291
|
+
}], dataIndex: [{
|
|
292
|
+
type: Input
|
|
293
|
+
}], widgetStyles: [{
|
|
294
|
+
type: Input
|
|
295
295
|
}] } });
|
|
296
296
|
|
|
297
|
-
const CSS_FRAMEWORK_CFG = new InjectionToken('CSS_FRAMEWORK_CFG');
|
|
298
|
-
var css_fw;
|
|
299
|
-
(function (css_fw) {
|
|
300
|
-
class csscategories {
|
|
301
|
-
}
|
|
302
|
-
css_fw.csscategories = csscategories;
|
|
297
|
+
const CSS_FRAMEWORK_CFG = new InjectionToken('CSS_FRAMEWORK_CFG');
|
|
298
|
+
var css_fw;
|
|
299
|
+
(function (css_fw) {
|
|
300
|
+
class csscategories {
|
|
301
|
+
}
|
|
302
|
+
css_fw.csscategories = csscategories;
|
|
303
303
|
})(css_fw || (css_fw = {}));
|
|
304
304
|
|
|
305
|
-
class CssFrameworkModule {
|
|
306
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
307
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
308
|
-
CommonModule,
|
|
309
|
-
WidgetLibraryModule], exports: [CssFrameworkComponent] }); }
|
|
310
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
311
|
-
JsonSchemaFormService,
|
|
312
|
-
FrameworkLibraryService,
|
|
313
|
-
WidgetLibraryService,
|
|
314
|
-
CssframeworkService
|
|
315
|
-
// { provide: Framework, useClass: CssFramework, multi: true },
|
|
316
|
-
], imports: [JsonSchemaFormModule,
|
|
317
|
-
CommonModule,
|
|
318
|
-
WidgetLibraryModule] }); }
|
|
319
|
-
}
|
|
320
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
321
|
-
type: NgModule,
|
|
322
|
-
args: [{
|
|
323
|
-
declarations: [
|
|
324
|
-
CssFrameworkComponent
|
|
325
|
-
],
|
|
326
|
-
imports: [
|
|
327
|
-
JsonSchemaFormModule,
|
|
328
|
-
CommonModule,
|
|
329
|
-
WidgetLibraryModule,
|
|
330
|
-
],
|
|
331
|
-
exports: [
|
|
332
|
-
CssFrameworkComponent
|
|
333
|
-
],
|
|
334
|
-
providers: [
|
|
335
|
-
JsonSchemaFormService,
|
|
336
|
-
FrameworkLibraryService,
|
|
337
|
-
WidgetLibraryService,
|
|
338
|
-
CssframeworkService
|
|
339
|
-
// { provide: Framework, useClass: CssFramework, multi: true },
|
|
340
|
-
]
|
|
341
|
-
}]
|
|
305
|
+
class CssFrameworkModule {
|
|
306
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFrameworkModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
307
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: CssFrameworkModule, declarations: [CssFrameworkComponent], imports: [JsonSchemaFormModule,
|
|
308
|
+
CommonModule,
|
|
309
|
+
WidgetLibraryModule], exports: [CssFrameworkComponent] }); }
|
|
310
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFrameworkModule, providers: [
|
|
311
|
+
JsonSchemaFormService,
|
|
312
|
+
FrameworkLibraryService,
|
|
313
|
+
WidgetLibraryService,
|
|
314
|
+
CssframeworkService
|
|
315
|
+
// { provide: Framework, useClass: CssFramework, multi: true },
|
|
316
|
+
], imports: [JsonSchemaFormModule,
|
|
317
|
+
CommonModule,
|
|
318
|
+
WidgetLibraryModule] }); }
|
|
319
|
+
}
|
|
320
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFrameworkModule, decorators: [{
|
|
321
|
+
type: NgModule,
|
|
322
|
+
args: [{
|
|
323
|
+
declarations: [
|
|
324
|
+
CssFrameworkComponent
|
|
325
|
+
],
|
|
326
|
+
imports: [
|
|
327
|
+
JsonSchemaFormModule,
|
|
328
|
+
CommonModule,
|
|
329
|
+
WidgetLibraryModule,
|
|
330
|
+
],
|
|
331
|
+
exports: [
|
|
332
|
+
CssFrameworkComponent
|
|
333
|
+
],
|
|
334
|
+
providers: [
|
|
335
|
+
JsonSchemaFormService,
|
|
336
|
+
FrameworkLibraryService,
|
|
337
|
+
WidgetLibraryService,
|
|
338
|
+
CssframeworkService
|
|
339
|
+
// { provide: Framework, useClass: CssFramework, multi: true },
|
|
340
|
+
]
|
|
341
|
+
}]
|
|
342
342
|
}] });
|
|
343
343
|
|
|
344
|
-
class CssFramework extends Framework {
|
|
345
|
-
constructor(cfg, cssFWService) {
|
|
346
|
-
super();
|
|
347
|
-
this.cssFWService = cssFWService;
|
|
348
|
-
this.name = 'css';
|
|
349
|
-
this.framework = CssFrameworkComponent;
|
|
350
|
-
this.name = cfg.name;
|
|
351
|
-
this.text = cfg.text || this.name;
|
|
352
|
-
this.stylesheets = cfg.stylesheets;
|
|
353
|
-
this.scripts = cfg.scripts;
|
|
354
|
-
this.config = cfg;
|
|
355
|
-
this.widgets = cfg.widgets;
|
|
356
|
-
}
|
|
357
|
-
getActiveTheme() {
|
|
358
|
-
let activeRequestedThemeName = this.cssFWService.getActiveRequestedTheme();
|
|
359
|
-
let frameWorkThemes = this.config?.widgetstyles?.__themes__;
|
|
360
|
-
let theme = frameWorkThemes && frameWorkThemes[0];
|
|
361
|
-
if (activeRequestedThemeName) { //if not set return first theme in config;
|
|
362
|
-
theme = { name: activeRequestedThemeName, text: activeRequestedThemeName };
|
|
363
|
-
if (frameWorkThemes) {
|
|
364
|
-
let filtered = frameWorkThemes.filter(theme => { return theme.name == activeRequestedThemeName; });
|
|
365
|
-
theme = (filtered && filtered[0]) || theme;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return theme;
|
|
369
|
-
}
|
|
370
|
-
requestThemeChange(name) {
|
|
371
|
-
this.cssFWService.requestThemeChange(name);
|
|
372
|
-
}
|
|
373
|
-
registerTheme(newTheme, overwrite = true) {
|
|
374
|
-
let themeList = this.config?.widgetstyles?.__themes__ || [];
|
|
375
|
-
let matchedThemes = themeList.filter(theme => { return newTheme.name == theme.name; });
|
|
376
|
-
if (matchedThemes && matchedThemes[0]) {
|
|
377
|
-
if (overwrite) {
|
|
378
|
-
matchedThemes[0].text = newTheme.text;
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
if (!overwrite) {
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
if (!matchedThemes || matchedThemes.length == 0) {
|
|
386
|
-
let cfg = this.config;
|
|
387
|
-
cfg.widgetstyles = this.config.widgetstyles || {};
|
|
388
|
-
cfg.widgetstyles.__themes__ = cfg.widgetstyles.__themes__ || [];
|
|
389
|
-
cfg.widgetstyles.__themes__.push(newTheme);
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
;
|
|
394
|
-
unregisterTheme(name) {
|
|
395
|
-
let themeList = this.config?.widgetstyles?.__themes__;
|
|
396
|
-
let foundInd = -1;
|
|
397
|
-
if (themeList) {
|
|
398
|
-
themeList.forEach((theme, ind) => {
|
|
399
|
-
if (name == theme.name) {
|
|
400
|
-
foundInd = ind;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
if (foundInd >= 0) {
|
|
404
|
-
themeList.splice(foundInd, 1);
|
|
405
|
-
return true;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return false;
|
|
409
|
-
}
|
|
410
|
-
getConfig() {
|
|
411
|
-
return this.config;
|
|
412
|
-
}
|
|
413
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
414
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
415
|
-
}
|
|
416
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
417
|
-
type: Injectable
|
|
418
|
-
}], ctorParameters:
|
|
419
|
-
type: Inject,
|
|
420
|
-
args: [CSS_FRAMEWORK_CFG]
|
|
421
|
-
}] }, { type: CssframeworkService }]
|
|
344
|
+
class CssFramework extends Framework {
|
|
345
|
+
constructor(cfg, cssFWService) {
|
|
346
|
+
super();
|
|
347
|
+
this.cssFWService = cssFWService;
|
|
348
|
+
this.name = 'css';
|
|
349
|
+
this.framework = CssFrameworkComponent;
|
|
350
|
+
this.name = cfg.name;
|
|
351
|
+
this.text = cfg.text || this.name;
|
|
352
|
+
this.stylesheets = cfg.stylesheets;
|
|
353
|
+
this.scripts = cfg.scripts;
|
|
354
|
+
this.config = cfg;
|
|
355
|
+
this.widgets = cfg.widgets;
|
|
356
|
+
}
|
|
357
|
+
getActiveTheme() {
|
|
358
|
+
let activeRequestedThemeName = this.cssFWService.getActiveRequestedTheme();
|
|
359
|
+
let frameWorkThemes = this.config?.widgetstyles?.__themes__;
|
|
360
|
+
let theme = frameWorkThemes && frameWorkThemes[0];
|
|
361
|
+
if (activeRequestedThemeName) { //if not set return first theme in config;
|
|
362
|
+
theme = { name: activeRequestedThemeName, text: activeRequestedThemeName };
|
|
363
|
+
if (frameWorkThemes) {
|
|
364
|
+
let filtered = frameWorkThemes.filter(theme => { return theme.name == activeRequestedThemeName; });
|
|
365
|
+
theme = (filtered && filtered[0]) || theme;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return theme;
|
|
369
|
+
}
|
|
370
|
+
requestThemeChange(name) {
|
|
371
|
+
this.cssFWService.requestThemeChange(name);
|
|
372
|
+
}
|
|
373
|
+
registerTheme(newTheme, overwrite = true) {
|
|
374
|
+
let themeList = this.config?.widgetstyles?.__themes__ || [];
|
|
375
|
+
let matchedThemes = themeList.filter(theme => { return newTheme.name == theme.name; });
|
|
376
|
+
if (matchedThemes && matchedThemes[0]) {
|
|
377
|
+
if (overwrite) {
|
|
378
|
+
matchedThemes[0].text = newTheme.text;
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
if (!overwrite) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (!matchedThemes || matchedThemes.length == 0) {
|
|
386
|
+
let cfg = this.config;
|
|
387
|
+
cfg.widgetstyles = this.config.widgetstyles || {};
|
|
388
|
+
cfg.widgetstyles.__themes__ = cfg.widgetstyles.__themes__ || [];
|
|
389
|
+
cfg.widgetstyles.__themes__.push(newTheme);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
;
|
|
394
|
+
unregisterTheme(name) {
|
|
395
|
+
let themeList = this.config?.widgetstyles?.__themes__;
|
|
396
|
+
let foundInd = -1;
|
|
397
|
+
if (themeList) {
|
|
398
|
+
themeList.forEach((theme, ind) => {
|
|
399
|
+
if (name == theme.name) {
|
|
400
|
+
foundInd = ind;
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
if (foundInd >= 0) {
|
|
404
|
+
themeList.splice(foundInd, 1);
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
getConfig() {
|
|
411
|
+
return this.config;
|
|
412
|
+
}
|
|
413
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFramework, deps: [{ token: CSS_FRAMEWORK_CFG }, { token: CssframeworkService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
414
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFramework }); }
|
|
415
|
+
}
|
|
416
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CssFramework, decorators: [{
|
|
417
|
+
type: Injectable
|
|
418
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
419
|
+
type: Inject,
|
|
420
|
+
args: [CSS_FRAMEWORK_CFG]
|
|
421
|
+
}] }, { type: CssframeworkService }] });
|
|
422
422
|
|
|
423
|
-
/*
|
|
424
|
-
* Public API Surface of ng-formworks-cssframework
|
|
423
|
+
/*
|
|
424
|
+
* Public API Surface of ng-formworks-cssframework
|
|
425
425
|
*/
|
|
426
426
|
|
|
427
|
-
/**
|
|
428
|
-
* Generated bundle index. Do not edit.
|
|
427
|
+
/**
|
|
428
|
+
* Generated bundle index. Do not edit.
|
|
429
429
|
*/
|
|
430
430
|
|
|
431
431
|
export { CSS_FRAMEWORK_CFG, CssFramework, CssFrameworkComponent, CssFrameworkModule, CssframeworkService, css_fw };
|