@ng-formworks/core 16.6.0 → 16.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/json-schema-form.component.mjs +4 -2
- package/esm2022/lib/json-schema-form.service.mjs +31 -11
- package/esm2022/lib/shared/form-group.functions.mjs +82 -25
- package/esm2022/lib/shared/json-schema.functions.mjs +62 -4
- package/esm2022/lib/shared/jsonpointer.functions.mjs +2 -2
- package/esm2022/lib/shared/layout.functions.mjs +71 -22
- package/esm2022/lib/widget-library/checkbox.component.mjs +9 -4
- package/esm2022/lib/widget-library/index.mjs +4 -2
- package/esm2022/lib/widget-library/one-of.component.mjs +25 -9
- package/esm2022/lib/widget-library/root.component.mjs +59 -1
- package/esm2022/lib/widget-library/selectcheckbox.component.mjs +186 -0
- package/esm2022/lib/widget-library/widget-library.module.mjs +4 -3
- package/esm2022/lib/widget-library/widget-library.service.mjs +6 -4
- package/fesm2022/ng-formworks-core.mjs +620 -175
- package/fesm2022/ng-formworks-core.mjs.map +1 -1
- package/lib/shared/form-group.functions.d.ts +2 -0
- package/lib/shared/json-schema.functions.d.ts +1 -2
- package/lib/widget-library/index.d.ts +2 -1
- package/lib/widget-library/selectcheckbox.component.d.ts +55 -0
- package/lib/widget-library/widget-library.module.d.ts +7 -6
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i2 from '@angular/common';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Injectable, ViewContainerRef, Component, Input, ViewChild, Directive, ChangeDetectionStrategy,
|
|
4
|
+
import { Injectable, ViewContainerRef, Component, Input, ViewChild, Directive, ChangeDetectionStrategy, Inject, inject, NgModule, forwardRef, EventEmitter, Output } from '@angular/core';
|
|
5
5
|
import * as i3 from '@angular/forms';
|
|
6
6
|
import { UntypedFormControl, UntypedFormArray, UntypedFormGroup, FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
7
7
|
import addFormats from 'ajv-formats';
|
|
@@ -10,7 +10,7 @@ import jsonDraft6 from 'ajv/lib/refs/json-schema-draft-06.json';
|
|
|
10
10
|
import jsonDraft7 from 'ajv/lib/refs/json-schema-draft-07.json';
|
|
11
11
|
import cloneDeep from 'lodash/cloneDeep';
|
|
12
12
|
import { from, Observable, forkJoin, Subject, BehaviorSubject, lastValueFrom } from 'rxjs';
|
|
13
|
-
import { some, isNil, isEmpty as isEmpty$1, isObject as isObject$1, isEqual as isEqual$2 } from 'lodash';
|
|
13
|
+
import { some, isNil, isEmpty as isEmpty$1, isObject as isObject$1, pick, isEqual as isEqual$2 } from 'lodash';
|
|
14
14
|
import isEqual$1 from 'lodash/isEqual';
|
|
15
15
|
import { map, takeUntil } from 'rxjs/operators';
|
|
16
16
|
import omit from 'lodash/omit';
|
|
@@ -4586,18 +4586,76 @@ function fixRequiredArrayProperties(schema) {
|
|
|
4586
4586
|
* @param schema:any
|
|
4587
4587
|
* @param negate:boolean=false
|
|
4588
4588
|
* @returns
|
|
4589
|
-
|
|
4590
4589
|
*/
|
|
4591
|
-
|
|
4590
|
+
//TODO also handle ifs with mixed conditional such as allOf/oneOf etc
|
|
4591
|
+
/*
|
|
4592
|
+
|
|
4593
|
+
"if": {
|
|
4594
|
+
"allOf": [
|
|
4595
|
+
{
|
|
4596
|
+
"properties": {
|
|
4597
|
+
"animalType": {
|
|
4598
|
+
"enum": ["Cat", "Fish"]
|
|
4599
|
+
}
|
|
4600
|
+
}
|
|
4601
|
+
},
|
|
4602
|
+
{
|
|
4603
|
+
"properties": {
|
|
4604
|
+
"color": {
|
|
4605
|
+
"const": "orange"
|
|
4606
|
+
}
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
]
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
|
|
4613
|
+
|
|
4614
|
+
*/
|
|
4615
|
+
function convertJSONSchemaIfToCondition(schema, layoutNode, negate = false) {
|
|
4592
4616
|
let conditionFun = "";
|
|
4593
4617
|
let condition = {};
|
|
4594
4618
|
let notOp = negate ? "!" : "";
|
|
4619
|
+
// expects "dataPointer" to be like "/a/b/c"
|
|
4620
|
+
//TODO-test
|
|
4621
|
+
//dataPointer can be something like /cities/-/name
|
|
4622
|
+
//must end up like model.cities[arrayIndices].name
|
|
4623
|
+
//also check can possibly be nested array like /cities/-/sites/-/siteName
|
|
4624
|
+
//in this case must probably end up like
|
|
4625
|
+
// /cities/arrayIndices[0]/sites/arrayIndices[1]/siteName
|
|
4626
|
+
//but it seems evaluatCondition support only one level for now
|
|
4627
|
+
//and uses arrayIndices as the last index only -check?
|
|
4628
|
+
let parentPath = layoutNode.dataPointer ? layoutNode.dataPointer
|
|
4629
|
+
.split("/")
|
|
4630
|
+
.slice(1, -1)
|
|
4631
|
+
.map((part, ind) => {
|
|
4632
|
+
let sep = ind == 0 ? "" : ".";
|
|
4633
|
+
let ret = part == "-" ? "[arrayIndices]" : sep + part;
|
|
4634
|
+
return ret;
|
|
4635
|
+
})
|
|
4636
|
+
.join("")
|
|
4637
|
+
: "";
|
|
4638
|
+
let modelPath = parentPath ? `model.${parentPath}` : "model";
|
|
4639
|
+
let checkPath = modelPath.split('.')
|
|
4640
|
+
.map((_, index, array) => {
|
|
4641
|
+
return array.slice(0, index + 1).join('.'); // Build each part of the path dynamically
|
|
4642
|
+
}).join(' && '); // Join the parts with '&&'
|
|
4643
|
+
// .reduce((accumulator, currentPart, index) => {
|
|
4644
|
+
// const currentExpression = index === 0 ? currentPart : `${accumulator}.${currentPart}`;
|
|
4645
|
+
// return index === 0 ? currentExpression : `${accumulator} && ${currentExpression}`;
|
|
4646
|
+
// }, '');
|
|
4595
4647
|
if (schema.if) {
|
|
4596
4648
|
Object.keys(schema.if.properties).forEach((ifProp, ind) => {
|
|
4597
4649
|
let amper = ind > 0 ? "&" : "";
|
|
4598
4650
|
//Note the model value is first converted to string and so is the condition
|
|
4599
4651
|
//so that booleans and numbers can also be compared
|
|
4600
|
-
|
|
4652
|
+
//changed to an includesList to handle cases such as
|
|
4653
|
+
const includesList = hasOwn(schema.if.properties[ifProp], "const") ? [schema.if.properties[ifProp].const]
|
|
4654
|
+
: hasOwn(schema.if.properties[ifProp], "enum") ? schema.if.properties[ifProp].enum
|
|
4655
|
+
: [];
|
|
4656
|
+
const includesListAsStr = includesList.map(val => { return `"${val}"`; });
|
|
4657
|
+
conditionFun += `${amper} ${checkPath} && [${includesListAsStr}].includes(${modelPath}.${ifProp}+"")`;
|
|
4658
|
+
//conditionFun+=`${amper} ${checkPath} && ${modelPath}.${ifProp}+""=='${schema.if.properties[ifProp].const}'`
|
|
4601
4659
|
});
|
|
4602
4660
|
}
|
|
4603
4661
|
condition["functionBody"] = `return ${notOp}(${conditionFun})`;
|
|
@@ -5027,7 +5085,7 @@ function buildFormGroupTemplate(jsf, nodeValue = null, setValues = true, schemaP
|
|
|
5027
5085
|
["then", "else"].forEach(con => {
|
|
5028
5086
|
if (hasOwn(schema, con)) {
|
|
5029
5087
|
const keySchemaPointer = `/${con}`;
|
|
5030
|
-
let thenFGTemplate = buildFormGroupTemplate(jsf, nodeValue,
|
|
5088
|
+
let thenFGTemplate = buildFormGroupTemplate(jsf, nodeValue, setValues, //false,//JsonPointer.get(nodeValue, keySchemaPointer), setValues,
|
|
5031
5089
|
schemaPointer + keySchemaPointer, dataPointer, templatePointer + `/controls/${con}`);
|
|
5032
5090
|
Object.assign(controls, thenFGTemplate.controls);
|
|
5033
5091
|
}
|
|
@@ -5088,7 +5146,9 @@ function buildFormGroupTemplate(jsf, nodeValue = null, setValues = true, schemaP
|
|
|
5088
5146
|
if (foundKeys && foundKeys.length > 0) {
|
|
5089
5147
|
const keySchemaPointer = `/${ofType}/${ind}`;
|
|
5090
5148
|
//console.log(`found:${keySchemaPointer}`);
|
|
5091
|
-
let newNodeValue =
|
|
5149
|
+
let newNodeValue = nodeValue;
|
|
5150
|
+
//JsonPointer.get(nodeValue, dataPointer);
|
|
5151
|
+
//JsonPointer.get(nodeValue, keySchemaPointer);
|
|
5092
5152
|
if (ofType == "oneOf") {
|
|
5093
5153
|
newNodeValue = nodeValue;
|
|
5094
5154
|
}
|
|
@@ -5115,16 +5175,59 @@ function buildFormGroupTemplate(jsf, nodeValue = null, setValues = true, schemaP
|
|
|
5115
5175
|
//if key is a $oneOf key then it was inserted at the root of the controls
|
|
5116
5176
|
//as form control name will be the full(escaped) path
|
|
5117
5177
|
const pointerPath = key.startsWith('$oneOf') ? controlItem.schemaPointer : keySchemaPointer;
|
|
5118
|
-
let oneOfItemSchema = JsonPointer.get(schema,
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5178
|
+
let oneOfItemSchema = JsonPointer.get(jsf.schema, controlItem.schemaPointer);
|
|
5179
|
+
//JsonPointer.get(schema,pointerPath);
|
|
5180
|
+
let dPointer = controlItem.schemaPointer.replace(/(anyOf|allOf|oneOf|none)\/[\d]+\//g, '')
|
|
5181
|
+
.replace(/(if|then|else|properties)\//g, '').replace(/\/items\//g, '/-/');
|
|
5182
|
+
dPointer = dPointer.indexOf(dataPointer) == 0
|
|
5183
|
+
? dPointer.substring(dataPointer.length) : dPointer;
|
|
5184
|
+
//dataPointer+"/"+controlItem.schemaPointer.split("/").slice(-1)[0];
|
|
5185
|
+
////controlItem.schemaPointer.replace(/(anyOf|allOf|oneOf|none)\/[\d]+\//g, '')
|
|
5186
|
+
////.replace(/(if|then|else|properties)\//g, '').replace(/\/items\//g,'/-/');
|
|
5187
|
+
//JsonPointer.toDataPointer(controlItem.schemaPointer,jsf.schema);
|
|
5188
|
+
//console.log(`dataPointer:${dataPointer}\ndPointer:${dPointer}`)
|
|
5189
|
+
let dVal = //JsonPointer.get(jsf.formValues,dPointer);
|
|
5190
|
+
JsonPointer.get(nodeValue, dPointer);
|
|
5191
|
+
let fkey = key;
|
|
5192
|
+
let oneOfItemValue = dVal;
|
|
5193
|
+
/*
|
|
5194
|
+
if(hasOwn(oneOfItemSchema,"if") && controlItem.schemaPointer
|
|
5195
|
+
&& controlItem.schemaPointer.indexOf(keySchemaPointer)==0){
|
|
5196
|
+
let parts=controlItem.schemaPointer
|
|
5197
|
+
.split(keySchemaPointer).join('').split("/")
|
|
5198
|
+
let thenOrElse=parts[1];
|
|
5199
|
+
fkey=parts[parts.length-1];
|
|
5200
|
+
oneOfItemSchema=oneOfItemSchema[thenOrElse];
|
|
5201
|
+
}
|
|
5202
|
+
|
|
5203
|
+
if(oneOfItemSchema.properties && jsf.formValues===undefined){
|
|
5204
|
+
//check if no form data values were supplied
|
|
5205
|
+
//then set it to default otherwise to its nodevalue
|
|
5206
|
+
oneOfItemValue=oneOfItemSchema.default
|
|
5207
|
+
oneOfItemValue[fkey]=oneOfItemSchema.properties[fkey]?.default;
|
|
5208
|
+
}
|
|
5209
|
+
if(oneOfItemSchema.properties && jsf.formValues!=undefined){
|
|
5210
|
+
oneOfItemValue ={};
|
|
5211
|
+
//nodeValue||{};
|
|
5212
|
+
oneOfItemValue[fkey]=nodeValue&&nodeValue[fkey];
|
|
5213
|
+
}
|
|
5214
|
+
if(!oneOfItemSchema.properties && jsf.formValues==undefined){
|
|
5215
|
+
oneOfItemValue=oneOfItemSchema.default;
|
|
5216
|
+
}
|
|
5217
|
+
*/
|
|
5218
|
+
if (hasOwn(controlItem, "value")) {
|
|
5219
|
+
if (!jsf.ajv.validate(oneOfItemSchema, oneOfItemValue)) {
|
|
5220
|
+
controlItem.value.value = null;
|
|
5221
|
+
}
|
|
5222
|
+
else {
|
|
5223
|
+
///controlItem.value.value=oneOfItemValue[fkey];
|
|
5224
|
+
controlItem.value.value = oneOfItemSchema.properties ? oneOfItemValue[fkey] : oneOfItemValue;
|
|
5225
|
+
}
|
|
5123
5226
|
}
|
|
5124
5227
|
//controls[controlKey] = controlItem;
|
|
5125
5228
|
//allOfFGTemplate.controls[key].schemaPointer ||`${schemaPointer}${keySchemaPointer}/${key}`;
|
|
5126
5229
|
//allOfFGTemplate.controls[key].schemaPointer || schemaPointer + keySchemaPointer;
|
|
5127
|
-
controls[key] = cloneDeep(allOfFGTemplate.controls[key]);
|
|
5230
|
+
///////controls[key] = cloneDeep(allOfFGTemplate.controls[key]);
|
|
5128
5231
|
//add schemacontrol to root
|
|
5129
5232
|
//controls[controlKey]=controlItem
|
|
5130
5233
|
controls[`_${ofType}`] = controls[`_${ofType}`] || {};
|
|
@@ -5138,7 +5241,7 @@ function buildFormGroupTemplate(jsf, nodeValue = null, setValues = true, schemaP
|
|
|
5138
5241
|
});
|
|
5139
5242
|
jsf.formOptions.fieldsRequired = setRequiredFields(schema, controls);
|
|
5140
5243
|
}
|
|
5141
|
-
return { controlType, controls, validators };
|
|
5244
|
+
return { controlType, controls, validators, schemaPointer };
|
|
5142
5245
|
case 'FormArray':
|
|
5143
5246
|
controls = [];
|
|
5144
5247
|
const minItems = Math.max(schema.minItems || 0, nodeOptions.get('minItems') || 0);
|
|
@@ -5195,7 +5298,7 @@ function buildFormGroupTemplate(jsf, nodeValue = null, setValues = true, schemaP
|
|
|
5195
5298
|
}
|
|
5196
5299
|
}
|
|
5197
5300
|
}
|
|
5198
|
-
return { controlType, controls, validators };
|
|
5301
|
+
return { controlType, controls, validators, schemaPointer };
|
|
5199
5302
|
case '$ref':
|
|
5200
5303
|
const schemaRef = JsonPointer.compile(schema.$ref);
|
|
5201
5304
|
const dataRef = JsonPointer.toDataPointer(schemaRef, schema);
|
|
@@ -5217,7 +5320,7 @@ function buildFormGroupTemplate(jsf, nodeValue = null, setValues = true, schemaP
|
|
|
5217
5320
|
value: setValues && isPrimitive(nodeValue) ? nodeValue : null,
|
|
5218
5321
|
disabled: nodeOptions.get('disabled') || false
|
|
5219
5322
|
};
|
|
5220
|
-
return { controlType, value, validators };
|
|
5323
|
+
return { controlType, value, validators, schemaPointer };
|
|
5221
5324
|
//TODO may make an IFThenElse widget or integrate it with the section
|
|
5222
5325
|
//widget
|
|
5223
5326
|
case 'IfThenElse':
|
|
@@ -5227,20 +5330,26 @@ function buildFormGroupTemplate(jsf, nodeValue = null, setValues = true, schemaP
|
|
|
5227
5330
|
["then", "else"].forEach(con => {
|
|
5228
5331
|
if (hasOwn(schema, con)) {
|
|
5229
5332
|
const keySchemaPointer = `/${con}`;
|
|
5230
|
-
let thenTFGTemplate = buildFormGroupTemplate(jsf, nodeValue,
|
|
5333
|
+
let thenTFGTemplate = buildFormGroupTemplate(jsf, nodeValue, setValues, //false,
|
|
5334
|
+
schemaPointer + keySchemaPointer, dataPointer, templatePointer + `/controls/${con}`);
|
|
5231
5335
|
//NB same property can be in both then and else
|
|
5232
5336
|
//so key must be the unique path to control
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5337
|
+
//let ifItemSchema=JsonPointer.get(schema,keySchemaPointer);
|
|
5338
|
+
//let ifItemValue;
|
|
5339
|
+
if (hasOwn(thenTFGTemplate, 'controls')) {
|
|
5340
|
+
Object.keys(thenTFGTemplate.controls).forEach(key => {
|
|
5341
|
+
let controlKey = thenTFGTemplate.controls[key].schemaPointer;
|
|
5342
|
+
if (controlKey) {
|
|
5343
|
+
controlKey = path2ControlKey(controlKey);
|
|
5344
|
+
let cItem = Object.assign({}, thenTFGTemplate.controls[key]);
|
|
5345
|
+
controls[controlKey] = cItem;
|
|
5346
|
+
}
|
|
5347
|
+
});
|
|
5348
|
+
}
|
|
5240
5349
|
}
|
|
5241
5350
|
});
|
|
5242
5351
|
}
|
|
5243
|
-
return { controlType, controls, validators };
|
|
5352
|
+
return { controlType, controls, validators, schemaPointer };
|
|
5244
5353
|
default:
|
|
5245
5354
|
return null;
|
|
5246
5355
|
}
|
|
@@ -5438,7 +5547,7 @@ function formatFormData(formData, dataMap, recursiveRefMap, arrayMap, returnEmpt
|
|
|
5438
5547
|
}
|
|
5439
5548
|
else if (typeof value !== 'object' || isDate(value) ||
|
|
5440
5549
|
(value === null && returnEmptyFields)) {
|
|
5441
|
-
if (genericPointer.
|
|
5550
|
+
if (genericPointer.indexOf("/$") >= 0) {
|
|
5442
5551
|
return formattedData;
|
|
5443
5552
|
}
|
|
5444
5553
|
console.error('formatFormData error: ' +
|
|
@@ -5473,7 +5582,8 @@ function getControl(formGroup, dataPointer, returnGroup = false, schemaPointer)
|
|
|
5473
5582
|
// If dataPointer input is not a valid JSON pointer, check to
|
|
5474
5583
|
// see if it is instead a valid object path, using dot notaion
|
|
5475
5584
|
if (typeof dataPointer === 'string') {
|
|
5476
|
-
const
|
|
5585
|
+
const controlPath = !!schemaPointer ? path2ControlKey(schemaPointer) : dataPointer;
|
|
5586
|
+
const formControl = formGroup.get(controlPath);
|
|
5477
5587
|
if (formControl) {
|
|
5478
5588
|
return formControl;
|
|
5479
5589
|
}
|
|
@@ -5493,7 +5603,8 @@ function getControl(formGroup, dataPointer, returnGroup = false, schemaPointer)
|
|
|
5493
5603
|
// try using formGroup.get() to return the control
|
|
5494
5604
|
if (typeof formGroup.get === 'function' &&
|
|
5495
5605
|
dataPointerArray.every(key => key.indexOf('.') === -1)) {
|
|
5496
|
-
const
|
|
5606
|
+
const controlPath = !!schemaPointer ? path2ControlKey(schemaPointer) : dataPointerArray.join('.');
|
|
5607
|
+
const formControl = formGroup.get(controlPath);
|
|
5497
5608
|
if (formControl) {
|
|
5498
5609
|
return formControl;
|
|
5499
5610
|
}
|
|
@@ -5506,7 +5617,11 @@ function getControl(formGroup, dataPointer, returnGroup = false, schemaPointer)
|
|
|
5506
5617
|
if (hasOwn(subGroup, 'controls')) {
|
|
5507
5618
|
subGroup = subGroup.controls;
|
|
5508
5619
|
}
|
|
5509
|
-
if (
|
|
5620
|
+
if (schemaPointer && hasOwn(subGroup, path2ControlKey(schemaPointer))) {
|
|
5621
|
+
subGroup = subGroup[path2ControlKey(schemaPointer)];
|
|
5622
|
+
return subGroup;
|
|
5623
|
+
}
|
|
5624
|
+
else if (isArray(subGroup) && (key === '-')) {
|
|
5510
5625
|
subGroup = subGroup[subGroup.length - 1];
|
|
5511
5626
|
}
|
|
5512
5627
|
else if (hasOwn(subGroup, key)) {
|
|
@@ -5752,7 +5867,6 @@ function buildLayout_original(jsf, widgetLibrary) {
|
|
|
5752
5867
|
schemaPointer = JsonPointer.toSchemaPointer(shortDataPointer, jsf.schema);
|
|
5753
5868
|
nodeDataMap.set('schemaPointer', schemaPointer);
|
|
5754
5869
|
}
|
|
5755
|
-
nodeDataMap.set('disabled', !!newNode.options.disabled);
|
|
5756
5870
|
nodeSchema = JsonPointer.get(jsf.schema, schemaPointer);
|
|
5757
5871
|
if (nodeSchema) {
|
|
5758
5872
|
if (!hasOwn(newNode, 'type')) {
|
|
@@ -5773,6 +5887,7 @@ function buildLayout_original(jsf, widgetLibrary) {
|
|
|
5773
5887
|
newNode.dataType =
|
|
5774
5888
|
nodeSchema.type || (hasOwn(nodeSchema, '$ref') ? '$ref' : null);
|
|
5775
5889
|
updateInputOptions(newNode, nodeSchema, jsf);
|
|
5890
|
+
nodeDataMap.set('disabled', !!newNode.options.disabled);
|
|
5776
5891
|
// Present checkboxes as single control, rather than array
|
|
5777
5892
|
if (newNode.type === 'checkboxes' && hasOwn(nodeSchema, 'items')) {
|
|
5778
5893
|
updateInputOptions(newNode, nodeSchema.items, jsf);
|
|
@@ -6196,6 +6311,37 @@ function fixNestedArrayLayout(options) {
|
|
|
6196
6311
|
* //
|
|
6197
6312
|
*/
|
|
6198
6313
|
function buildLayoutFromSchema(jsf, widgetLibrary, nodeValue = null, schemaPointer = '', dataPointer = '', arrayItem = false, arrayItemType = null, removable = null, forRefLibrary = false, dataPointerPrefix = '', jsonSchema) {
|
|
6314
|
+
function applyITEConditions(builtLayout, schPointer, keySchemaPointer, negateClause, parentLayout) {
|
|
6315
|
+
if (builtLayout) {
|
|
6316
|
+
if (parentLayout && parentLayout.isITEItem && parentLayout.options.condition) {
|
|
6317
|
+
return;
|
|
6318
|
+
}
|
|
6319
|
+
if (isArray(builtLayout)) {
|
|
6320
|
+
builtLayout.forEach(item => {
|
|
6321
|
+
item.isITEItem = true;
|
|
6322
|
+
item.options.condition = convertJSONSchemaIfToCondition(schema, item, negateClause);
|
|
6323
|
+
applyITEConditions(item, schPointer, keySchemaPointer, negateClause, builtLayout);
|
|
6324
|
+
//item.schemaPointer = schPointer + keySchemaPointer + item.dataPointer;
|
|
6325
|
+
//item.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6326
|
+
//newSection.push(item);
|
|
6327
|
+
});
|
|
6328
|
+
}
|
|
6329
|
+
else if (hasOwn(builtLayout, "items")) {
|
|
6330
|
+
applyITEConditions(builtLayout.items, schPointer, keySchemaPointer, negateClause, builtLayout);
|
|
6331
|
+
// builtLayout.items.forEach(item => {
|
|
6332
|
+
// item.isITEItem=true;
|
|
6333
|
+
// item.options.condition = convertJSONSchemaIfToCondition(schema,item, negateClause);
|
|
6334
|
+
// applyITEConditions(item,schPointer,keySchemaPointer,negateClause)
|
|
6335
|
+
// });
|
|
6336
|
+
}
|
|
6337
|
+
else {
|
|
6338
|
+
builtLayout.isITEItem = true;
|
|
6339
|
+
//builtLayout.schemaPointer = `${schPointer}${keySchemaPointer}/${builtLayout.name}`;
|
|
6340
|
+
builtLayout.options.condition = convertJSONSchemaIfToCondition(schema, builtLayout, negateClause);
|
|
6341
|
+
//newSection.push(builtLayout)
|
|
6342
|
+
}
|
|
6343
|
+
}
|
|
6344
|
+
}
|
|
6199
6345
|
const jsSchema = jsonSchema || jsf.schema;
|
|
6200
6346
|
const schema = JsonPointer.get(jsSchema, schemaPointer);
|
|
6201
6347
|
//JsonPointer.get(jsf.schema, schemaPointer);
|
|
@@ -6233,6 +6379,7 @@ function buildLayoutFromSchema(jsf, widgetLibrary, nodeValue = null, schemaPoint
|
|
|
6233
6379
|
if (!jsf.dataMap.has(shortDataPointer)) {
|
|
6234
6380
|
jsf.dataMap.set(shortDataPointer, new Map());
|
|
6235
6381
|
}
|
|
6382
|
+
updateInputOptions(newNode, schema, jsf);
|
|
6236
6383
|
const nodeDataMap = jsf.dataMap.get(shortDataPointer);
|
|
6237
6384
|
if (!nodeDataMap.has('inputType')) {
|
|
6238
6385
|
nodeDataMap.set('schemaPointer', schemaPointer);
|
|
@@ -6240,7 +6387,7 @@ function buildLayoutFromSchema(jsf, widgetLibrary, nodeValue = null, schemaPoint
|
|
|
6240
6387
|
nodeDataMap.set('widget', newNode.widget);
|
|
6241
6388
|
nodeDataMap.set('disabled', !!newNode.options.disabled);
|
|
6242
6389
|
}
|
|
6243
|
-
updateInputOptions(newNode, schema, jsf);
|
|
6390
|
+
//updateInputOptions(newNode, schema, jsf);
|
|
6244
6391
|
if (!newNode.options.title && newNode.name && !/^\d+$/.test(newNode.name)) {
|
|
6245
6392
|
newNode.options.title = fixTitle(newNode.name);
|
|
6246
6393
|
}
|
|
@@ -6268,6 +6415,7 @@ function buildLayoutFromSchema(jsf, widgetLibrary, nodeValue = null, schemaPoint
|
|
|
6268
6415
|
'/properties/' + key : '/additionalProperties';
|
|
6269
6416
|
const innerItem = buildLayoutFromSchema(jsf, widgetLibrary, isObject(nodeValue) ? nodeValue[key] : null, schemaPointer + keySchemaPointer, dataPointer + '/' + key, false, null, null, forRefLibrary, dataPointerPrefix);
|
|
6270
6417
|
if (innerItem) {
|
|
6418
|
+
innerItem.schemaPointer = schemaPointer + keySchemaPointer;
|
|
6271
6419
|
if (isInputRequired(schema, '/' + key)) {
|
|
6272
6420
|
innerItem.options.required = true;
|
|
6273
6421
|
jsf.fieldsRequired = true;
|
|
@@ -6292,38 +6440,50 @@ function buildLayoutFromSchema(jsf, widgetLibrary, nodeValue = null, schemaPoint
|
|
|
6292
6440
|
}
|
|
6293
6441
|
schema[ofType].forEach((ofItem, ind) => {
|
|
6294
6442
|
const keySchemaPointer = `/${ofType}/${ind}`;
|
|
6295
|
-
const innerItem = buildLayoutFromSchema(jsf, widgetLibrary, ofItem, schemaPointer + keySchemaPointer, dataPointer, false, null, null, forRefLibrary
|
|
6443
|
+
const innerItem = buildLayoutFromSchema(jsf, widgetLibrary, ofItem, schemaPointer + keySchemaPointer, dataPointer, false, null, null, ofType == "oneOf" /*forRefLibrary*/, dataPointerPrefix);
|
|
6296
6444
|
if (innerItem) {
|
|
6297
6445
|
//newSection.push(innerItem);
|
|
6298
6446
|
if (innerItem.items) {
|
|
6299
6447
|
innerItem.items.forEach(innerItemLevel2 => {
|
|
6300
6448
|
const l2SchemaPointer = hasOwn(ofItem, 'properties') ?
|
|
6301
6449
|
'/properties/' + innerItemLevel2.name : innerItemLevel2.name;
|
|
6302
|
-
innerItemLevel2.oneOfPointer =
|
|
6303
|
-
innerItemLevel2.schemaPointer
|
|
6450
|
+
//innerItemLevel2.oneOfPointer = schemaPointer + keySchemaPointer + l2SchemaPointer;
|
|
6451
|
+
// innerItemLevel2.schemaPointer=innerItemLevel2.schemaPointer;
|
|
6452
|
+
innerItemLevel2.oneOfPointer = innerItemLevel2.schemaPointer;
|
|
6304
6453
|
});
|
|
6305
6454
|
}
|
|
6455
|
+
//TODO review-will never reach here if forRefLibrary==true
|
|
6306
6456
|
if (isArray(innerItem)) {
|
|
6457
|
+
let outerOneOfItemTpl = cloneDeep(newNode);
|
|
6458
|
+
outerOneOfItemTpl;
|
|
6307
6459
|
innerItem.forEach(item => {
|
|
6308
6460
|
const l2SchemaPointer = hasOwn(ofItem, 'properties') ?
|
|
6309
6461
|
'/properties/' + item.name : item.name;
|
|
6310
6462
|
if (outerOneOfItem) {
|
|
6311
|
-
item.oneOfPointer =
|
|
6463
|
+
////item.oneOfPointer = schemaPointer + keySchemaPointer + l2SchemaPointer;
|
|
6312
6464
|
//schemaPointer + keySchemaPointer + item.dataPointer;
|
|
6313
|
-
item.schemaPointer
|
|
6314
|
-
|
|
6465
|
+
////item.schemaPointer=item.oneOfPointer;
|
|
6466
|
+
/*
|
|
6467
|
+
outerOneOfItem.items=outerOneOfItem.items||[];
|
|
6315
6468
|
outerOneOfItem.items.push(item);
|
|
6469
|
+
*/
|
|
6470
|
+
outerOneOfItemTpl.items = outerOneOfItemTpl.items || [];
|
|
6471
|
+
outerOneOfItemTpl.items.push(item);
|
|
6316
6472
|
}
|
|
6317
6473
|
else {
|
|
6318
6474
|
newSection.push(item);
|
|
6319
6475
|
}
|
|
6320
6476
|
});
|
|
6477
|
+
if (outerOneOfItem) {
|
|
6478
|
+
outerOneOfItem.items = outerOneOfItem.items || [];
|
|
6479
|
+
outerOneOfItem.items.push(outerOneOfItemTpl);
|
|
6480
|
+
}
|
|
6321
6481
|
//TODO test-might not work for more than 2 levels of nesting
|
|
6322
6482
|
}
|
|
6323
6483
|
else {
|
|
6324
6484
|
if (outerOneOfItem) {
|
|
6325
6485
|
innerItem.oneOfPointer = schemaPointer + keySchemaPointer; // + innerItem.dataPointer;
|
|
6326
|
-
innerItem.schemaPointer
|
|
6486
|
+
////innerItem.schemaPointer=innerItem.oneOfPointer;
|
|
6327
6487
|
outerOneOfItem.items = outerOneOfItem.items || [];
|
|
6328
6488
|
outerOneOfItem.items.push(innerItem);
|
|
6329
6489
|
}
|
|
@@ -6340,18 +6500,19 @@ function buildLayoutFromSchema(jsf, widgetLibrary, nodeValue = null, schemaPoint
|
|
|
6340
6500
|
if (hasOwn(schema, con)) {
|
|
6341
6501
|
const keySchemaPointer = `/${con}`;
|
|
6342
6502
|
const negateClause = con == "else";
|
|
6343
|
-
const innerItem = buildLayoutFromSchema(jsf, widgetLibrary, nodeValue
|
|
6503
|
+
const innerItem = buildLayoutFromSchema(jsf, widgetLibrary, nodeValue[con], schemaPointer + keySchemaPointer, dataPointer, false, null, null, forRefLibrary, dataPointerPrefix);
|
|
6344
6504
|
if (innerItem) {
|
|
6505
|
+
applyITEConditions(innerItem, schemaPointer, keySchemaPointer, negateClause);
|
|
6345
6506
|
if (isArray(innerItem)) {
|
|
6346
6507
|
innerItem.forEach(item => {
|
|
6347
|
-
item.schemaPointer = schemaPointer + keySchemaPointer + item.dataPointer;
|
|
6348
|
-
item.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6508
|
+
//item.schemaPointer = schemaPointer + keySchemaPointer + item.dataPointer;
|
|
6509
|
+
//item.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6349
6510
|
newSection.push(item);
|
|
6350
6511
|
});
|
|
6351
6512
|
}
|
|
6352
6513
|
else {
|
|
6353
|
-
innerItem.schemaPointer = schemaPointer + keySchemaPointer + innerItem.dataPointer;
|
|
6354
|
-
innerItem.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6514
|
+
//innerItem.schemaPointer = schemaPointer + keySchemaPointer + innerItem.dataPointer;
|
|
6515
|
+
//innerItem.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6355
6516
|
newSection.push(innerItem);
|
|
6356
6517
|
}
|
|
6357
6518
|
}
|
|
@@ -6566,24 +6727,27 @@ function buildLayoutFromSchema(jsf, widgetLibrary, nodeValue = null, schemaPoint
|
|
|
6566
6727
|
if (hasOwn(schema, con)) {
|
|
6567
6728
|
const keySchemaPointer = `/${con}`;
|
|
6568
6729
|
const negateClause = con == "else";
|
|
6569
|
-
const innerItem = buildLayoutFromSchema(jsf, widgetLibrary, nodeValue
|
|
6730
|
+
const innerItem = buildLayoutFromSchema(jsf, widgetLibrary, nodeValue[con], schemaPointer + keySchemaPointer, dataPointer, false, null, null, forRefLibrary, dataPointerPrefix);
|
|
6570
6731
|
if (innerItem) {
|
|
6732
|
+
applyITEConditions(innerItem, schemaPointer, keySchemaPointer, negateClause);
|
|
6571
6733
|
if (isArray(innerItem)) {
|
|
6572
6734
|
innerItem.forEach(item => {
|
|
6573
|
-
item.schemaPointer = schemaPointer + keySchemaPointer + item.dataPointer;
|
|
6574
|
-
item.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6735
|
+
//item.schemaPointer = schemaPointer + keySchemaPointer + item.dataPointer;
|
|
6736
|
+
//item.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6575
6737
|
newSection.push(item);
|
|
6576
|
-
newNode = newSection
|
|
6738
|
+
/////// newNode = newSection
|
|
6577
6739
|
});
|
|
6578
6740
|
}
|
|
6579
6741
|
else {
|
|
6580
|
-
innerItem.schemaPointer = schemaPointer + keySchemaPointer + innerItem.dataPointer;
|
|
6581
|
-
innerItem.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6582
|
-
newNode = innerItem
|
|
6742
|
+
//innerItem.schemaPointer = schemaPointer + keySchemaPointer + innerItem.dataPointer;
|
|
6743
|
+
//innerItem.options.condition = convertJSONSchemaIfToCondition(schema, negateClause);
|
|
6744
|
+
///////newNode = innerItem
|
|
6745
|
+
newSection.push(innerItem);
|
|
6583
6746
|
}
|
|
6584
6747
|
}
|
|
6585
6748
|
}
|
|
6586
6749
|
});
|
|
6750
|
+
newNode = newSection;
|
|
6587
6751
|
}
|
|
6588
6752
|
return newNode;
|
|
6589
6753
|
}
|
|
@@ -7312,7 +7476,8 @@ class JsonSchemaFormService {
|
|
|
7312
7476
|
ctx.formControl = this.getFormControl(ctx);
|
|
7313
7477
|
//introduced to check if the node is part of ITE conditional
|
|
7314
7478
|
//then change or add the control
|
|
7315
|
-
if (layoutNode?.schemaPointer
|
|
7479
|
+
if (layoutNode?.schemaPointer && layoutNode.isITEItem ||
|
|
7480
|
+
(layoutNode?.schemaPointer && layoutNode?.oneOfPointer)) {
|
|
7316
7481
|
//before changing control, need to set the new data type for data formatting
|
|
7317
7482
|
const schemaType = this.dataMap.get(layoutNode?.dataPointer).get("schemaType");
|
|
7318
7483
|
if (schemaType != layoutNode.dataType) {
|
|
@@ -7353,11 +7518,24 @@ class JsonSchemaFormService {
|
|
|
7353
7518
|
}
|
|
7354
7519
|
//if this is a ITE conditional field, the value would not have been
|
|
7355
7520
|
//set, as the control would only be initialized when the condition is true
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
ctx.formControl
|
|
7521
|
+
//TODO-review need to decide which of the data sets between data,formValues and default
|
|
7522
|
+
//to use for the value
|
|
7523
|
+
if (ctx.options?.condition || layoutNode?.oneOfPointer) {
|
|
7524
|
+
const dataPointer = this.getDataPointer(ctx);
|
|
7525
|
+
const controlValue = ctx.formControl.value;
|
|
7526
|
+
const dataValue = JsonPointer.has(this.data, dataPointer) ?
|
|
7527
|
+
JsonPointer.get(this.data, dataPointer) : undefined;
|
|
7528
|
+
const formValue = JsonPointer.has(this.formValues, dataPointer) ?
|
|
7529
|
+
JsonPointer.get(this.formValues, dataPointer) : undefined;
|
|
7530
|
+
const schemaDefault = ctx.options?.default;
|
|
7531
|
+
//if initial formValues was supplied and controlValue matches formValue then likely
|
|
7532
|
+
//control was initially created with the formValue then set value to data value
|
|
7533
|
+
//if no formValues was supplied and controlValue matches schemaDefault then likely
|
|
7534
|
+
//control was initially created with the default then set value to data value
|
|
7535
|
+
const value = this.formValues && isEqual$1(formValue, controlValue) ? dataValue
|
|
7536
|
+
: !this.formValues && isEqual$1(schemaDefault, controlValue) ? dataValue
|
|
7537
|
+
: schemaDefault;
|
|
7538
|
+
ctx.formControl?.patchValue(value);
|
|
7361
7539
|
}
|
|
7362
7540
|
return ctx.boundControl;
|
|
7363
7541
|
}
|
|
@@ -7473,7 +7651,9 @@ class JsonSchemaFormService {
|
|
|
7473
7651
|
ctx.layoutNode.type === '$ref') {
|
|
7474
7652
|
return null;
|
|
7475
7653
|
}
|
|
7476
|
-
|
|
7654
|
+
const schemaPointer = ctx.layoutNode?.isITEItem ? ctx.layoutNode?.schemaPointer : null;
|
|
7655
|
+
const oneOfPointer = ctx.layoutNode?.oneOfPointer;
|
|
7656
|
+
return getControl(this.formGroup, this.getDataPointer(ctx), false, schemaPointer || oneOfPointer);
|
|
7477
7657
|
}
|
|
7478
7658
|
setFormControl(ctx, control) {
|
|
7479
7659
|
if (!ctx || !ctx.layoutNode ||
|
|
@@ -7489,14 +7669,18 @@ class JsonSchemaFormService {
|
|
|
7489
7669
|
ctx.layoutNode.type === '$ref') {
|
|
7490
7670
|
return null;
|
|
7491
7671
|
}
|
|
7492
|
-
const
|
|
7672
|
+
const schemaPointer = ctx.layoutNode?.isITEItem ? ctx.layoutNode?.schemaPointer : null;
|
|
7673
|
+
const oneOfPointer = ctx.layoutNode?.oneOfPointer;
|
|
7674
|
+
const control = getControl(this.formGroup, this.getDataPointer(ctx), false, schemaPointer || oneOfPointer);
|
|
7493
7675
|
return control ? control.value : null;
|
|
7494
7676
|
}
|
|
7495
7677
|
getFormControlGroup(ctx) {
|
|
7496
7678
|
if (!ctx.layoutNode || !isDefined(ctx.layoutNode.dataPointer)) {
|
|
7497
7679
|
return null;
|
|
7498
7680
|
}
|
|
7499
|
-
|
|
7681
|
+
const schemaPointer = ctx.layoutNode?.isITEItem ? ctx.layoutNode?.schemaPointer : null;
|
|
7682
|
+
const oneOfPointer = ctx.layoutNode?.oneOfPointer;
|
|
7683
|
+
return getControl(this.formGroup, this.getDataPointer(ctx), true, schemaPointer || oneOfPointer);
|
|
7500
7684
|
}
|
|
7501
7685
|
getFormControlName(ctx) {
|
|
7502
7686
|
if (!ctx.layoutNode ||
|
|
@@ -7858,6 +8042,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
7858
8042
|
type: Input
|
|
7859
8043
|
}] } });
|
|
7860
8044
|
|
|
8045
|
+
///NB issue caused by sortablejs when it its destroyed
|
|
8046
|
+
//this mainly affects checkboxes coupled with conditions
|
|
8047
|
+
//-the value is rechecked
|
|
8048
|
+
//-see https://github.com/SortableJS/Sortable/issues/1052#issuecomment-369613072
|
|
7861
8049
|
class CheckboxComponent {
|
|
7862
8050
|
constructor(jsf) {
|
|
7863
8051
|
this.jsf = jsf;
|
|
@@ -7870,7 +8058,8 @@ class CheckboxComponent {
|
|
|
7870
8058
|
this.options = this.layoutNode.options || {};
|
|
7871
8059
|
this.jsf.initializeControl(this);
|
|
7872
8060
|
if (this.controlValue === null || this.controlValue === undefined) {
|
|
7873
|
-
this.controlValue =
|
|
8061
|
+
this.controlValue = false;
|
|
8062
|
+
this.jsf.updateValue(this, this.falseValue);
|
|
7874
8063
|
}
|
|
7875
8064
|
}
|
|
7876
8065
|
updateValue(event) {
|
|
@@ -7900,7 +8089,7 @@ class CheckboxComponent {
|
|
|
7900
8089
|
type="checkbox">
|
|
7901
8090
|
<input *ngIf="!boundControl"
|
|
7902
8091
|
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
7903
|
-
[checked]="isChecked
|
|
8092
|
+
[checked]="isChecked"
|
|
7904
8093
|
[class]="(options?.fieldHtmlClass || '') + (isChecked ?
|
|
7905
8094
|
(' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
|
|
7906
8095
|
(' ' + (options?.style?.unselected || '')))"
|
|
@@ -7937,7 +8126,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
7937
8126
|
type="checkbox">
|
|
7938
8127
|
<input *ngIf="!boundControl"
|
|
7939
8128
|
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
7940
|
-
[checked]="isChecked
|
|
8129
|
+
[checked]="isChecked"
|
|
7941
8130
|
[class]="(options?.fieldHtmlClass || '') + (isChecked ?
|
|
7942
8131
|
(' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
|
|
7943
8132
|
(' ' + (options?.style?.unselected || '')))"
|
|
@@ -8759,14 +8948,30 @@ class OneOfComponent {
|
|
|
8759
8948
|
let parts = controlName.split('$');
|
|
8760
8949
|
let fieldName = parts[parts.length - 1];
|
|
8761
8950
|
let controlValue = this.jsf.formGroup.controls[controlName].value;
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8951
|
+
let controlSchema = JsonPointer.get(this.jsf.schema, parts.join("/"));
|
|
8952
|
+
let schemaPointer = parts.join("/");
|
|
8953
|
+
let dPointer = schemaPointer.replace(/(anyOf|allOf|oneOf|none)\/[\d]+\//g, '')
|
|
8954
|
+
.replace(/(if|then|else|properties)\//g, '').replace(/\/items\//g, '/-/');
|
|
8955
|
+
//JsonPointer.toDataPointer(parts.join("/"),this.jsf.schema);
|
|
8956
|
+
let dVal = JsonPointer.get(this.jsf.formValues, dPointer);
|
|
8957
|
+
let compareVal = dVal; //formValue;
|
|
8958
|
+
//compare only values that are in the subschema properties
|
|
8959
|
+
if (controlSchema && controlSchema.properties) {
|
|
8960
|
+
compareVal = isObject$1(dVal) && hasOwn(dVal, fieldName) ?
|
|
8961
|
+
pick(dVal[fieldName], Object.keys(controlSchema.properties))
|
|
8962
|
+
: pick(dVal, Object.keys(controlSchema.properties));
|
|
8767
8963
|
}
|
|
8768
|
-
|
|
8769
|
-
|
|
8964
|
+
/*
|
|
8965
|
+
if(isObject(compareVal) && hasOwn(compareVal,fieldName) &&
|
|
8966
|
+
isEqual(compareVal[fieldName],controlValue)
|
|
8967
|
+
){
|
|
8968
|
+
foundInd=ind;
|
|
8969
|
+
}else //if(formValue || controlValue){
|
|
8970
|
+
if(isEqual(compareVal,controlValue)){
|
|
8971
|
+
foundInd=ind;
|
|
8972
|
+
}
|
|
8973
|
+
*/
|
|
8974
|
+
if (isEqual$2(compareVal, controlValue)) {
|
|
8770
8975
|
foundInd = ind;
|
|
8771
8976
|
}
|
|
8772
8977
|
});
|
|
@@ -9124,6 +9329,64 @@ class RootComponent {
|
|
|
9124
9329
|
}
|
|
9125
9330
|
sortableInit(sortable) {
|
|
9126
9331
|
this.sortableObj = sortable;
|
|
9332
|
+
//Sortable.utils.on(this.sortableObj.el,"nulling",(s)=>{console.log("event nulling sortablejs")})
|
|
9333
|
+
///NB issue caused by sortablejs when it its destroyed
|
|
9334
|
+
//this mainly affects checkboxes coupled with conditions
|
|
9335
|
+
//-the value is rechecked
|
|
9336
|
+
//-see https://github.com/SortableJS/Sortable/issues/1052#issuecomment-369613072
|
|
9337
|
+
/* attempt to monkey patch sortable js
|
|
9338
|
+
const originalMethod = sortable._nulling;
|
|
9339
|
+
let zone=this.zone;
|
|
9340
|
+
sortable._nulling=function() {
|
|
9341
|
+
console.log(`pluginEvent 2 ${pluginEvent}`)
|
|
9342
|
+
zone.runOutsideAngular(() => {
|
|
9343
|
+
console.log(`pluginEvent3 ${pluginEvent}`)
|
|
9344
|
+
pluginEvent('nulling', this);
|
|
9345
|
+
|
|
9346
|
+
rootEl =
|
|
9347
|
+
dragEl =
|
|
9348
|
+
parentEl =
|
|
9349
|
+
ghostEl =
|
|
9350
|
+
nextEl =
|
|
9351
|
+
cloneEl =
|
|
9352
|
+
lastDownEl =
|
|
9353
|
+
cloneHidden =
|
|
9354
|
+
|
|
9355
|
+
tapEvt =
|
|
9356
|
+
touchEvt =
|
|
9357
|
+
|
|
9358
|
+
moved =
|
|
9359
|
+
newIndex =
|
|
9360
|
+
newDraggableIndex =
|
|
9361
|
+
oldIndex =
|
|
9362
|
+
oldDraggableIndex =
|
|
9363
|
+
|
|
9364
|
+
lastTarget =
|
|
9365
|
+
lastDirection =
|
|
9366
|
+
|
|
9367
|
+
putSortable =
|
|
9368
|
+
activeGroup =
|
|
9369
|
+
Sortable.dragged =
|
|
9370
|
+
Sortable.ghost =
|
|
9371
|
+
Sortable.clone =
|
|
9372
|
+
Sortable.active = null;
|
|
9373
|
+
|
|
9374
|
+
|
|
9375
|
+
let el = this.el;
|
|
9376
|
+
savedInputChecked.forEach(function (checkEl) {
|
|
9377
|
+
if (el.contains(checkEl)) {
|
|
9378
|
+
checkEl.checked = true;
|
|
9379
|
+
}
|
|
9380
|
+
});
|
|
9381
|
+
|
|
9382
|
+
savedInputChecked.length =
|
|
9383
|
+
lastDx =
|
|
9384
|
+
lastDy = 0;
|
|
9385
|
+
|
|
9386
|
+
})
|
|
9387
|
+
|
|
9388
|
+
}.bind(sortable)
|
|
9389
|
+
*/
|
|
9127
9390
|
}
|
|
9128
9391
|
isDraggable(node) {
|
|
9129
9392
|
let result = node.arrayItem && node.type !== '$ref' &&
|
|
@@ -9749,43 +10012,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
9749
10012
|
type: Input
|
|
9750
10013
|
}] } });
|
|
9751
10014
|
|
|
9752
|
-
class TabComponent {
|
|
9753
|
-
constructor(jsf) {
|
|
9754
|
-
this.jsf = jsf;
|
|
9755
|
-
}
|
|
9756
|
-
ngOnInit() {
|
|
9757
|
-
this.options = this.layoutNode.options || {};
|
|
9758
|
-
}
|
|
9759
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TabComponent, deps: [{ token: JsonSchemaFormService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
9760
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: TabComponent, selector: "tab-widget", inputs: { layoutNode: "layoutNode", layoutIndex: "layoutIndex", dataIndex: "dataIndex" }, ngImport: i0, template: `
|
|
9761
|
-
<div [class]="options?.htmlClass || ''">
|
|
9762
|
-
<root-widget
|
|
9763
|
-
[dataIndex]="dataIndex"
|
|
9764
|
-
[layoutIndex]="layoutIndex"
|
|
9765
|
-
[layout]="layoutNode.items"></root-widget>
|
|
9766
|
-
</div>`, isInline: true, dependencies: [{ kind: "component", type: RootComponent, selector: "root-widget", inputs: ["dataIndex", "layoutIndex", "layout", "isOrderable", "isFlexItem"] }] }); }
|
|
9767
|
-
}
|
|
9768
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TabComponent, decorators: [{
|
|
9769
|
-
type: Component,
|
|
9770
|
-
args: [{
|
|
9771
|
-
// tslint:disable-next-line:component-selector
|
|
9772
|
-
selector: 'tab-widget',
|
|
9773
|
-
template: `
|
|
9774
|
-
<div [class]="options?.htmlClass || ''">
|
|
9775
|
-
<root-widget
|
|
9776
|
-
[dataIndex]="dataIndex"
|
|
9777
|
-
[layoutIndex]="layoutIndex"
|
|
9778
|
-
[layout]="layoutNode.items"></root-widget>
|
|
9779
|
-
</div>`,
|
|
9780
|
-
}]
|
|
9781
|
-
}], ctorParameters: function () { return [{ type: JsonSchemaFormService }]; }, propDecorators: { layoutNode: [{
|
|
9782
|
-
type: Input
|
|
9783
|
-
}], layoutIndex: [{
|
|
9784
|
-
type: Input
|
|
9785
|
-
}], dataIndex: [{
|
|
9786
|
-
type: Input
|
|
9787
|
-
}] } });
|
|
9788
|
-
|
|
9789
10015
|
class TemplateComponent {
|
|
9790
10016
|
constructor(jsf) {
|
|
9791
10017
|
this.jsf = jsf;
|
|
@@ -10019,6 +10245,7 @@ class WidgetLibraryService {
|
|
|
10019
10245
|
'wizard': 'section',
|
|
10020
10246
|
// Widgets included for compatibility with other libraries
|
|
10021
10247
|
'textline': 'text',
|
|
10248
|
+
'selectcheckbox': SelectCheckboxComponent,
|
|
10022
10249
|
// Recommended 3rd-party add-on widgets (TODO: create wrappers for these...)
|
|
10023
10250
|
// 'ng2-select': Select control replacement - http://valor-software.com/ng2-select/
|
|
10024
10251
|
// 'flatpickr': Flatpickr date picker - https://github.com/chmln/flatpickr
|
|
@@ -10135,73 +10362,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
10135
10362
|
}]
|
|
10136
10363
|
}], ctorParameters: function () { return []; } });
|
|
10137
10364
|
|
|
10138
|
-
const BASIC_WIDGETS = [
|
|
10139
|
-
AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent,
|
|
10140
|
-
CheckboxesComponent, FileComponent, HiddenComponent, InputComponent,
|
|
10141
|
-
MessageComponent, NoneComponent, NumberComponent, RadiosComponent,
|
|
10142
|
-
RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent,
|
|
10143
|
-
SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent,
|
|
10144
|
-
TemplateComponent, TextareaComponent
|
|
10145
|
-
];
|
|
10146
|
-
|
|
10147
|
-
class WidgetLibraryModule {
|
|
10148
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
10149
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, declarations: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, OrderableDirective, ElementAttributeDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule, i3$1.SortablejsModule], exports: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, OrderableDirective, ElementAttributeDirective] }); }
|
|
10150
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, imports: [CommonModule, FormsModule, ReactiveFormsModule,
|
|
10151
|
-
SortablejsModule.forRoot({
|
|
10152
|
-
//disabled:false,
|
|
10153
|
-
//draggable:".draggableitem",//">:not(.nonsort)",//">.draggable-item",//":not(.nonsort)",//">*",//":not(.nonsort)",//":not(.non-draggable)",
|
|
10154
|
-
filter: ".sortable-filter",
|
|
10155
|
-
preventOnFilter: false,
|
|
10156
|
-
onMove: function (/**Event*/ evt, /**Event*/ originalEvent) {
|
|
10157
|
-
if (evt.related.classList.contains("sortable-fixed")) {
|
|
10158
|
-
//console.log(evt.related);
|
|
10159
|
-
return false;
|
|
10160
|
-
}
|
|
10161
|
-
}
|
|
10162
|
-
})] }); }
|
|
10163
|
-
}
|
|
10164
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, decorators: [{
|
|
10165
|
-
type: NgModule,
|
|
10166
|
-
args: [{
|
|
10167
|
-
imports: [CommonModule, FormsModule, ReactiveFormsModule,
|
|
10168
|
-
SortablejsModule.forRoot({
|
|
10169
|
-
//disabled:false,
|
|
10170
|
-
//draggable:".draggableitem",//">:not(.nonsort)",//">.draggable-item",//":not(.nonsort)",//">*",//":not(.nonsort)",//":not(.non-draggable)",
|
|
10171
|
-
filter: ".sortable-filter",
|
|
10172
|
-
preventOnFilter: false,
|
|
10173
|
-
onMove: function (/**Event*/ evt, /**Event*/ originalEvent) {
|
|
10174
|
-
if (evt.related.classList.contains("sortable-fixed")) {
|
|
10175
|
-
//console.log(evt.related);
|
|
10176
|
-
return false;
|
|
10177
|
-
}
|
|
10178
|
-
}
|
|
10179
|
-
})],
|
|
10180
|
-
declarations: [...BASIC_WIDGETS, OrderableDirective, ElementAttributeDirective],
|
|
10181
|
-
exports: [...BASIC_WIDGETS, OrderableDirective, ElementAttributeDirective]
|
|
10182
|
-
}]
|
|
10183
|
-
}] });
|
|
10184
|
-
|
|
10185
|
-
// No framework - plain HTML controls (styles from form layout only)
|
|
10186
|
-
class NoFrameworkModule {
|
|
10187
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
10188
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, declarations: [NoFrameworkComponent], imports: [CommonModule, WidgetLibraryModule], exports: [NoFrameworkComponent] }); }
|
|
10189
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, providers: [
|
|
10190
|
-
{ provide: Framework, useClass: NoFramework, multi: true }
|
|
10191
|
-
], imports: [CommonModule, WidgetLibraryModule] }); }
|
|
10192
|
-
}
|
|
10193
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, decorators: [{
|
|
10194
|
-
type: NgModule,
|
|
10195
|
-
args: [{
|
|
10196
|
-
imports: [CommonModule, WidgetLibraryModule],
|
|
10197
|
-
declarations: [NoFrameworkComponent],
|
|
10198
|
-
exports: [NoFrameworkComponent],
|
|
10199
|
-
providers: [
|
|
10200
|
-
{ provide: Framework, useClass: NoFramework, multi: true }
|
|
10201
|
-
]
|
|
10202
|
-
}]
|
|
10203
|
-
}] });
|
|
10204
|
-
|
|
10205
10365
|
// Possible future frameworks:
|
|
10206
10366
|
// - Foundation 6:
|
|
10207
10367
|
// http://justindavis.co/2017/06/15/using-foundation-6-in-angular-4/
|
|
@@ -10369,6 +10529,289 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
10369
10529
|
args: [WidgetLibraryService]
|
|
10370
10530
|
}] }, { type: i1.HttpClient }]; } });
|
|
10371
10531
|
|
|
10532
|
+
//component created as a fallback for the checkbox/sortabljs issue
|
|
10533
|
+
//its meant to display a select as a checkbox
|
|
10534
|
+
class SelectCheckboxComponent {
|
|
10535
|
+
constructor() {
|
|
10536
|
+
this.jsf = inject(JsonSchemaFormService);
|
|
10537
|
+
this.jsfFLService = inject(FrameworkLibraryService);
|
|
10538
|
+
this.controlDisabled = false;
|
|
10539
|
+
this.boundControl = false;
|
|
10540
|
+
this.selectList = [];
|
|
10541
|
+
this.selectListFlatGroup = [];
|
|
10542
|
+
this.isArray = isArray;
|
|
10543
|
+
this.frameworkStyles = {
|
|
10544
|
+
daisyui: { selectClass: "select-box", optionClass: "checkbox tw:dui-checkbox", optionChecked: "active", optionUnchecked: "" },
|
|
10545
|
+
"bootstrap-3": { selectClass: "select-box", optionClass: "bs3-option checkbox display-inline-block", optionChecked: "active", optionUnchecked: "" },
|
|
10546
|
+
"bootstrap-4": { selectClass: "select-box", optionClass: "bs4-option checkbox display-inline-block", optionChecked: "active", optionUnchecked: "" },
|
|
10547
|
+
"bootstrap-5": { selectClass: " select-box", optionClass: "form-check-input display-inline-block", optionChecked: "active", optionUnchecked: "" },
|
|
10548
|
+
//"material-design":{selectClass:" ",optionClass:" "}
|
|
10549
|
+
};
|
|
10550
|
+
}
|
|
10551
|
+
ngOnInit() {
|
|
10552
|
+
this.options = this.layoutNode.options || {};
|
|
10553
|
+
this.activeFramework = this.jsfFLService.activeFramework.name;
|
|
10554
|
+
this.selectList = buildTitleMap(
|
|
10555
|
+
//this.options.titleMap || this.options.enumNames,
|
|
10556
|
+
//TODO review-title is set to null in the setTitle() method of CssFrameworkComponent
|
|
10557
|
+
this.options.enumNames || (this.options?.title && [this.options?.title])
|
|
10558
|
+
|| [this.layoutNode.name],
|
|
10559
|
+
//this.options.enum,
|
|
10560
|
+
[true],
|
|
10561
|
+
//make required true to avoid creating 'none' select option
|
|
10562
|
+
true, !!this.options.flatList);
|
|
10563
|
+
//the selectListFlatGroup array will be used to update the formArray values
|
|
10564
|
+
//while the selectList array will be bound to the form select
|
|
10565
|
+
//as either a grouped select or a flat select
|
|
10566
|
+
/*
|
|
10567
|
+
this.selectListFlatGroup = buildTitleMap(
|
|
10568
|
+
this.options.titleMap || this.options.enumNames,
|
|
10569
|
+
this.options.enum, !!this.options.required, true
|
|
10570
|
+
)
|
|
10571
|
+
*/
|
|
10572
|
+
this.jsf.initializeControl(this);
|
|
10573
|
+
this.selectValue = [this.controlValue];
|
|
10574
|
+
}
|
|
10575
|
+
deselectAll() {
|
|
10576
|
+
this.selectListFlatGroup.forEach(selItem => {
|
|
10577
|
+
selItem.checked = false;
|
|
10578
|
+
});
|
|
10579
|
+
}
|
|
10580
|
+
updateValue(event) {
|
|
10581
|
+
this.options.showErrors = true;
|
|
10582
|
+
this.controlValue = this.selectValue[0];
|
|
10583
|
+
this.jsf.updateValue(this, this.controlValue);
|
|
10584
|
+
}
|
|
10585
|
+
onSelectClicked($event) {
|
|
10586
|
+
this.selectValue = this.selectValue && this.selectValue[0] ? [false] : [true];
|
|
10587
|
+
this.controlValue = this.selectValue[0];
|
|
10588
|
+
this.jsf.updateValue(this, this.controlValue);
|
|
10589
|
+
}
|
|
10590
|
+
ngOnDestroy() {
|
|
10591
|
+
let nullVal = this.options.multiple ? [null] : null;
|
|
10592
|
+
this.formControl.reset(nullVal);
|
|
10593
|
+
this.controlValue = null;
|
|
10594
|
+
}
|
|
10595
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
10596
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SelectCheckboxComponent, selector: "selectcheckbox-widget", inputs: { layoutNode: "layoutNode", layoutIndex: "layoutIndex", dataIndex: "dataIndex" }, ngImport: i0, template: `
|
|
10597
|
+
<div
|
|
10598
|
+
[class]="options?.htmlClass || ''">
|
|
10599
|
+
<select *ngIf="boundControl"
|
|
10600
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
10601
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
10602
|
+
[attr.required]="options?.required"
|
|
10603
|
+
[class]=" frameworkStyles[activeFramework].selectClass"
|
|
10604
|
+
[multiple]="true"
|
|
10605
|
+
[id]="'control' + layoutNode?._id"
|
|
10606
|
+
[name]="controlName"
|
|
10607
|
+
[ngModel]="selectValue"
|
|
10608
|
+
>
|
|
10609
|
+
<ng-template ngFor let-selectItem [ngForOf]="selectList">
|
|
10610
|
+
<option *ngIf="!isArray(selectItem?.items)"
|
|
10611
|
+
[class]="frameworkStyles[activeFramework].optionClass"
|
|
10612
|
+
[class.active]="selectItem?.value === controlValue"
|
|
10613
|
+
[class.unchecked-notusing]="selectItem?.value != controlValue"
|
|
10614
|
+
[value]="selectItem?.value"
|
|
10615
|
+
(click)="onSelectClicked($event)"
|
|
10616
|
+
type="checkbox"
|
|
10617
|
+
>
|
|
10618
|
+
</option>
|
|
10619
|
+
<!--NB the text is out of the option element to display besides the checkbox-->
|
|
10620
|
+
<span [innerHTML]="selectItem?.name"></span>
|
|
10621
|
+
</ng-template>
|
|
10622
|
+
</select>
|
|
10623
|
+
<select *ngIf="!boundControl"
|
|
10624
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
10625
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
10626
|
+
[attr.required]="options?.required"
|
|
10627
|
+
[class]="frameworkStyles[activeFramework].selectClass +' select-box'"
|
|
10628
|
+
[multiple]="true"
|
|
10629
|
+
[disabled]="controlDisabled"
|
|
10630
|
+
[id]="'control' + layoutNode?._id"
|
|
10631
|
+
[name]="controlName"
|
|
10632
|
+
(change)="updateValue($event)">
|
|
10633
|
+
<ng-template ngFor let-selectItem [ngForOf]="selectList">
|
|
10634
|
+
<option *ngIf="!isArray(selectItem?.items)"
|
|
10635
|
+
[selected]="selectItem?.value === controlValue"
|
|
10636
|
+
[class]="frameworkStyles[activeFramework].optionClass"
|
|
10637
|
+
[class.checked-notusing]="selectItem?.value === controlValue"
|
|
10638
|
+
[class.unchecked-notusing]]="selectItem?.value != controlValue"
|
|
10639
|
+
[value]="selectItem?.value"
|
|
10640
|
+
type="checkbox">
|
|
10641
|
+
</option>
|
|
10642
|
+
<!--NB the text is out of the option element to display besides the checkbox-->
|
|
10643
|
+
<span [innerHTML]="selectItem?.name"></span>
|
|
10644
|
+
</ng-template>
|
|
10645
|
+
</select>
|
|
10646
|
+
|
|
10647
|
+
</div>`, isInline: true, styles: [".select-box{font-size:16px;border:none;appearance:none;-webkit-appearance:none;-moz-appearance:none;height:25px;overflow:hidden;text-overflow:ellipsis;background-color:#fff;color:#000;background-color:transparent}.select-box:focus{outline:none}.select-option{font-size:20px;color:#000;background-color:#fff;display:inline-block}.unchecked:before{content:\"\\2610\";left:5px;top:50%;transform:translateY(-50%);font-size:30px}.checked:before{content:\"\\2611\";left:5px;top:50%;transform:translateY(-50%);font-size:30px}.select-option:checked{background-image:linear-gradient(0deg,#fff 0% 100%);color:#000}.select-box[multiple]:focus{background-color:transparent;color:#00f;-webkit-text-fill-color:black}.display-inline-block{display:inline-block}.bs4-option,.bs3-option{width:14px;height:14px;border:solid 1px;color:#a9a9a9;min-block-size:auto;border-radius:3px}.bs4-option:checked[type=checkbox],.bs3-option:checked[type=checkbox]{background-image:url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%3C!--%20License%3A%20MIT.%20Made%20by%20jaynewey%3A%20https%3A%2F%2Fgithub.com%2Fjaynewey%2Fcharm-icons%20--%3E%3Csvg%20viewBox%3D%220%200%2016%2016%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20fill%3D%22none%22%20stroke%3D%22%23000000%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222.5%22%3E%3Cpolyline%20points%3D%224%208.75%2C6.25%2012.25%2C13.25%203.5%22%2F%3E%3C%2Fsvg%3E);background-color:#00ced1}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.SelectMultipleControlValueAccessor, selector: "select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
|
|
10648
|
+
}
|
|
10649
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectCheckboxComponent, decorators: [{
|
|
10650
|
+
type: Component,
|
|
10651
|
+
args: [{ selector: 'selectcheckbox-widget', template: `
|
|
10652
|
+
<div
|
|
10653
|
+
[class]="options?.htmlClass || ''">
|
|
10654
|
+
<select *ngIf="boundControl"
|
|
10655
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
10656
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
10657
|
+
[attr.required]="options?.required"
|
|
10658
|
+
[class]=" frameworkStyles[activeFramework].selectClass"
|
|
10659
|
+
[multiple]="true"
|
|
10660
|
+
[id]="'control' + layoutNode?._id"
|
|
10661
|
+
[name]="controlName"
|
|
10662
|
+
[ngModel]="selectValue"
|
|
10663
|
+
>
|
|
10664
|
+
<ng-template ngFor let-selectItem [ngForOf]="selectList">
|
|
10665
|
+
<option *ngIf="!isArray(selectItem?.items)"
|
|
10666
|
+
[class]="frameworkStyles[activeFramework].optionClass"
|
|
10667
|
+
[class.active]="selectItem?.value === controlValue"
|
|
10668
|
+
[class.unchecked-notusing]="selectItem?.value != controlValue"
|
|
10669
|
+
[value]="selectItem?.value"
|
|
10670
|
+
(click)="onSelectClicked($event)"
|
|
10671
|
+
type="checkbox"
|
|
10672
|
+
>
|
|
10673
|
+
</option>
|
|
10674
|
+
<!--NB the text is out of the option element to display besides the checkbox-->
|
|
10675
|
+
<span [innerHTML]="selectItem?.name"></span>
|
|
10676
|
+
</ng-template>
|
|
10677
|
+
</select>
|
|
10678
|
+
<select *ngIf="!boundControl"
|
|
10679
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
10680
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
10681
|
+
[attr.required]="options?.required"
|
|
10682
|
+
[class]="frameworkStyles[activeFramework].selectClass +' select-box'"
|
|
10683
|
+
[multiple]="true"
|
|
10684
|
+
[disabled]="controlDisabled"
|
|
10685
|
+
[id]="'control' + layoutNode?._id"
|
|
10686
|
+
[name]="controlName"
|
|
10687
|
+
(change)="updateValue($event)">
|
|
10688
|
+
<ng-template ngFor let-selectItem [ngForOf]="selectList">
|
|
10689
|
+
<option *ngIf="!isArray(selectItem?.items)"
|
|
10690
|
+
[selected]="selectItem?.value === controlValue"
|
|
10691
|
+
[class]="frameworkStyles[activeFramework].optionClass"
|
|
10692
|
+
[class.checked-notusing]="selectItem?.value === controlValue"
|
|
10693
|
+
[class.unchecked-notusing]]="selectItem?.value != controlValue"
|
|
10694
|
+
[value]="selectItem?.value"
|
|
10695
|
+
type="checkbox">
|
|
10696
|
+
</option>
|
|
10697
|
+
<!--NB the text is out of the option element to display besides the checkbox-->
|
|
10698
|
+
<span [innerHTML]="selectItem?.name"></span>
|
|
10699
|
+
</ng-template>
|
|
10700
|
+
</select>
|
|
10701
|
+
|
|
10702
|
+
</div>`, standalone: false, styles: [".select-box{font-size:16px;border:none;appearance:none;-webkit-appearance:none;-moz-appearance:none;height:25px;overflow:hidden;text-overflow:ellipsis;background-color:#fff;color:#000;background-color:transparent}.select-box:focus{outline:none}.select-option{font-size:20px;color:#000;background-color:#fff;display:inline-block}.unchecked:before{content:\"\\2610\";left:5px;top:50%;transform:translateY(-50%);font-size:30px}.checked:before{content:\"\\2611\";left:5px;top:50%;transform:translateY(-50%);font-size:30px}.select-option:checked{background-image:linear-gradient(0deg,#fff 0% 100%);color:#000}.select-box[multiple]:focus{background-color:transparent;color:#00f;-webkit-text-fill-color:black}.display-inline-block{display:inline-block}.bs4-option,.bs3-option{width:14px;height:14px;border:solid 1px;color:#a9a9a9;min-block-size:auto;border-radius:3px}.bs4-option:checked[type=checkbox],.bs3-option:checked[type=checkbox]{background-image:url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%3C!--%20License%3A%20MIT.%20Made%20by%20jaynewey%3A%20https%3A%2F%2Fgithub.com%2Fjaynewey%2Fcharm-icons%20--%3E%3Csvg%20viewBox%3D%220%200%2016%2016%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20fill%3D%22none%22%20stroke%3D%22%23000000%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222.5%22%3E%3Cpolyline%20points%3D%224%208.75%2C6.25%2012.25%2C13.25%203.5%22%2F%3E%3C%2Fsvg%3E);background-color:#00ced1}\n"] }]
|
|
10703
|
+
}], propDecorators: { layoutNode: [{
|
|
10704
|
+
type: Input
|
|
10705
|
+
}], layoutIndex: [{
|
|
10706
|
+
type: Input
|
|
10707
|
+
}], dataIndex: [{
|
|
10708
|
+
type: Input
|
|
10709
|
+
}] } });
|
|
10710
|
+
|
|
10711
|
+
class TabComponent {
|
|
10712
|
+
constructor(jsf) {
|
|
10713
|
+
this.jsf = jsf;
|
|
10714
|
+
}
|
|
10715
|
+
ngOnInit() {
|
|
10716
|
+
this.options = this.layoutNode.options || {};
|
|
10717
|
+
}
|
|
10718
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TabComponent, deps: [{ token: JsonSchemaFormService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
10719
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: TabComponent, selector: "tab-widget", inputs: { layoutNode: "layoutNode", layoutIndex: "layoutIndex", dataIndex: "dataIndex" }, ngImport: i0, template: `
|
|
10720
|
+
<div [class]="options?.htmlClass || ''">
|
|
10721
|
+
<root-widget
|
|
10722
|
+
[dataIndex]="dataIndex"
|
|
10723
|
+
[layoutIndex]="layoutIndex"
|
|
10724
|
+
[layout]="layoutNode.items"></root-widget>
|
|
10725
|
+
</div>`, isInline: true, dependencies: [{ kind: "component", type: RootComponent, selector: "root-widget", inputs: ["dataIndex", "layoutIndex", "layout", "isOrderable", "isFlexItem"] }] }); }
|
|
10726
|
+
}
|
|
10727
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TabComponent, decorators: [{
|
|
10728
|
+
type: Component,
|
|
10729
|
+
args: [{
|
|
10730
|
+
// tslint:disable-next-line:component-selector
|
|
10731
|
+
selector: 'tab-widget',
|
|
10732
|
+
template: `
|
|
10733
|
+
<div [class]="options?.htmlClass || ''">
|
|
10734
|
+
<root-widget
|
|
10735
|
+
[dataIndex]="dataIndex"
|
|
10736
|
+
[layoutIndex]="layoutIndex"
|
|
10737
|
+
[layout]="layoutNode.items"></root-widget>
|
|
10738
|
+
</div>`,
|
|
10739
|
+
}]
|
|
10740
|
+
}], ctorParameters: function () { return [{ type: JsonSchemaFormService }]; }, propDecorators: { layoutNode: [{
|
|
10741
|
+
type: Input
|
|
10742
|
+
}], layoutIndex: [{
|
|
10743
|
+
type: Input
|
|
10744
|
+
}], dataIndex: [{
|
|
10745
|
+
type: Input
|
|
10746
|
+
}] } });
|
|
10747
|
+
|
|
10748
|
+
const BASIC_WIDGETS = [
|
|
10749
|
+
AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent,
|
|
10750
|
+
CheckboxesComponent, FileComponent, HiddenComponent, InputComponent,
|
|
10751
|
+
MessageComponent, NoneComponent, NumberComponent, RadiosComponent,
|
|
10752
|
+
RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent,
|
|
10753
|
+
SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent,
|
|
10754
|
+
TemplateComponent, TextareaComponent, SelectCheckboxComponent
|
|
10755
|
+
];
|
|
10756
|
+
|
|
10757
|
+
class WidgetLibraryModule {
|
|
10758
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
10759
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, declarations: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, SelectCheckboxComponent, OrderableDirective, ElementAttributeDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule, i3$1.SortablejsModule], exports: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, SelectCheckboxComponent, OrderableDirective, ElementAttributeDirective] }); }
|
|
10760
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, imports: [CommonModule, FormsModule, ReactiveFormsModule,
|
|
10761
|
+
SortablejsModule.forRoot({
|
|
10762
|
+
//disabled:false,
|
|
10763
|
+
//draggable:".draggableitem",//">:not(.nonsort)",//">.draggable-item",//":not(.nonsort)",//">*",//":not(.nonsort)",//":not(.non-draggable)",
|
|
10764
|
+
filter: ".sortable-filter",
|
|
10765
|
+
preventOnFilter: false,
|
|
10766
|
+
onMove: function (/**Event*/ evt, /**Event*/ originalEvent) {
|
|
10767
|
+
if (evt.related.classList.contains("sortable-fixed")) {
|
|
10768
|
+
//console.log(evt.related);
|
|
10769
|
+
return false;
|
|
10770
|
+
}
|
|
10771
|
+
}
|
|
10772
|
+
})] }); }
|
|
10773
|
+
}
|
|
10774
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WidgetLibraryModule, decorators: [{
|
|
10775
|
+
type: NgModule,
|
|
10776
|
+
args: [{
|
|
10777
|
+
imports: [CommonModule, FormsModule, ReactiveFormsModule,
|
|
10778
|
+
SortablejsModule.forRoot({
|
|
10779
|
+
//disabled:false,
|
|
10780
|
+
//draggable:".draggableitem",//">:not(.nonsort)",//">.draggable-item",//":not(.nonsort)",//">*",//":not(.nonsort)",//":not(.non-draggable)",
|
|
10781
|
+
filter: ".sortable-filter",
|
|
10782
|
+
preventOnFilter: false,
|
|
10783
|
+
onMove: function (/**Event*/ evt, /**Event*/ originalEvent) {
|
|
10784
|
+
if (evt.related.classList.contains("sortable-fixed")) {
|
|
10785
|
+
//console.log(evt.related);
|
|
10786
|
+
return false;
|
|
10787
|
+
}
|
|
10788
|
+
}
|
|
10789
|
+
})],
|
|
10790
|
+
declarations: [...BASIC_WIDGETS, OrderableDirective, ElementAttributeDirective],
|
|
10791
|
+
exports: [...BASIC_WIDGETS, OrderableDirective, ElementAttributeDirective]
|
|
10792
|
+
}]
|
|
10793
|
+
}] });
|
|
10794
|
+
|
|
10795
|
+
// No framework - plain HTML controls (styles from form layout only)
|
|
10796
|
+
class NoFrameworkModule {
|
|
10797
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
10798
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, declarations: [NoFrameworkComponent], imports: [CommonModule, WidgetLibraryModule], exports: [NoFrameworkComponent] }); }
|
|
10799
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, providers: [
|
|
10800
|
+
{ provide: Framework, useClass: NoFramework, multi: true }
|
|
10801
|
+
], imports: [CommonModule, WidgetLibraryModule] }); }
|
|
10802
|
+
}
|
|
10803
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NoFrameworkModule, decorators: [{
|
|
10804
|
+
type: NgModule,
|
|
10805
|
+
args: [{
|
|
10806
|
+
imports: [CommonModule, WidgetLibraryModule],
|
|
10807
|
+
declarations: [NoFrameworkComponent],
|
|
10808
|
+
exports: [NoFrameworkComponent],
|
|
10809
|
+
providers: [
|
|
10810
|
+
{ provide: Framework, useClass: NoFramework, multi: true }
|
|
10811
|
+
]
|
|
10812
|
+
}]
|
|
10813
|
+
}] });
|
|
10814
|
+
|
|
10372
10815
|
const JSON_SCHEMA_FORM_VALUE_ACCESSOR = {
|
|
10373
10816
|
provide: NG_VALUE_ACCESSOR,
|
|
10374
10817
|
useExisting: forwardRef(() => JsonSchemaFormComponent),
|
|
@@ -10692,7 +11135,9 @@ class JsonSchemaFormComponent {
|
|
|
10692
11135
|
*/
|
|
10693
11136
|
initializeAjv() {
|
|
10694
11137
|
const form = this.form;
|
|
10695
|
-
const ajvOptions = cloneDeep(this.ajvOptions) ||
|
|
11138
|
+
const ajvOptions = cloneDeep(this.ajvOptions) ||
|
|
11139
|
+
(form && hasOwn(form, 'ajvOptions') && isObject(form.ajvOptions)
|
|
11140
|
+
&& cloneDeep(form.ajvOptions));
|
|
10696
11141
|
if (ajvOptions) {
|
|
10697
11142
|
this.ajvInstanceName = this.jsf.createAndRegisterAjvInstance(ajvOptions).name;
|
|
10698
11143
|
}
|
|
@@ -11159,5 +11604,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
11159
11604
|
* Generated bundle index. Do not edit.
|
|
11160
11605
|
*/
|
|
11161
11606
|
|
|
11162
|
-
export { AddReferenceComponent, BASIC_WIDGETS, ButtonComponent, CheckboxComponent, CheckboxesComponent, ElementAttributeDirective, FileComponent, Framework, FrameworkLibraryService, HiddenComponent, InputComponent, JsonPointer, JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormService, JsonValidators, MessageComponent, NoneComponent, NumberComponent, OneOfComponent, OrderableDirective, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, WidgetLibraryModule, WidgetLibraryService, _executeAsyncValidators, _executeValidators, _mergeErrors, _mergeObjects, _toPromise, addClasses, buildFormGroup, buildFormGroupTemplate, buildLayout, buildLayoutFromSchema, buildSchemaFromData, buildSchemaFromLayout, buildTitleMap, checkInlineType, combineAllOf, commonItems, convertSchemaToDraft6, copy, deValidationMessages, enValidationMessages, esValidationMessages, fixRequiredArrayProperties, fixTitle, forEach, forEachCopy, formatFormData, frValidationMessages, getControl, getControlValidators, getFromSchema, getInputType, getLayoutNode, getSubSchema, getTitleMapFromOneOf, getType, hasNonNullValue, hasOwn, hasValue, inArray, isArray, isBoolean, isDate, isDefined, isEmpty, isFunction, isInputRequired, isInteger, isMap, isNumber, isObject, isObservable, isPrimitive, isPromise, isSet, isString, isType, itValidationMessages, mapLayout, mergeFilteredObject, mergeSchemas, path2ControlKey, ptValidationMessages, removeRecursiveReferences, resolveSchemaReferences, setControl, setRequiredFields, toJavaScriptType, toObservable, toSchemaType, toTitleCase, uniqueItems, updateInputOptions, xor, zhValidationMessages };
|
|
11607
|
+
export { AddReferenceComponent, BASIC_WIDGETS, ButtonComponent, CheckboxComponent, CheckboxesComponent, ElementAttributeDirective, FileComponent, Framework, FrameworkLibraryService, HiddenComponent, InputComponent, JsonPointer, JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormService, JsonValidators, MessageComponent, NoneComponent, NumberComponent, OneOfComponent, OrderableDirective, RadiosComponent, RootComponent, SectionComponent, SelectCheckboxComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, WidgetLibraryModule, WidgetLibraryService, _executeAsyncValidators, _executeValidators, _mergeErrors, _mergeObjects, _toPromise, addClasses, buildFormGroup, buildFormGroupTemplate, buildLayout, buildLayoutFromSchema, buildSchemaFromData, buildSchemaFromLayout, buildTitleMap, checkInlineType, combineAllOf, commonItems, convertSchemaToDraft6, copy, deValidationMessages, enValidationMessages, esValidationMessages, fixRequiredArrayProperties, fixTitle, forEach, forEachCopy, formatFormData, frValidationMessages, getControl, getControlValidators, getFromSchema, getInputType, getLayoutNode, getSubSchema, getTitleMapFromOneOf, getType, hasNonNullValue, hasOwn, hasValue, inArray, isArray, isBoolean, isDate, isDefined, isEmpty, isFunction, isInputRequired, isInteger, isMap, isNumber, isObject, isObservable, isPrimitive, isPromise, isSet, isString, isType, itValidationMessages, mapLayout, mergeFilteredObject, mergeSchemas, path2ControlKey, ptValidationMessages, removeRecursiveReferences, resolveSchemaReferences, setControl, setRequiredFields, toJavaScriptType, toObservable, toSchemaType, toTitleCase, uniqueItems, updateInputOptions, xor, zhValidationMessages };
|
|
11163
11608
|
//# sourceMappingURL=ng-formworks-core.mjs.map
|