@scenid/react-formulator 0.4.4 → 0.5.1
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/dist/index.cjs.js +221 -114
- package/dist/index.esm.js +220 -112
- package/package.json +2 -2
- package/src/Editable/FormRepeater.jsx +75 -48
- package/src/FormulatorFormSection.jsx +12 -5
- package/stories/Forms.stories.jsx +9 -1
- package/stories/forms/types.schemas.js +15 -0
package/dist/index.esm.js
CHANGED
|
@@ -27,8 +27,7 @@ import { createSvgIcon, unstable_useId, useControlled, useEventCallback, setRef,
|
|
|
27
27
|
import _MenuItem from '@material-ui/core/esm/MenuItem';
|
|
28
28
|
import _Switch from '@material-ui/core/esm/Switch';
|
|
29
29
|
import _Checkbox from '@material-ui/core/esm/Checkbox';
|
|
30
|
-
import
|
|
31
|
-
import _InputLabel from '@material-ui/core/esm/InputLabel';
|
|
30
|
+
import _ClickAwayListener from '@material-ui/core/esm/ClickAwayListener';
|
|
32
31
|
import _Clear from '@material-ui/icons/esm/Clear';
|
|
33
32
|
import _Save from '@material-ui/icons/esm/Save';
|
|
34
33
|
import _Button from '@material-ui/core/esm/Button';
|
|
@@ -19646,7 +19645,7 @@ function require_Error () {
|
|
|
19646
19645
|
|
|
19647
19646
|
var _super2 = _createSuper(ValidationError);
|
|
19648
19647
|
|
|
19649
|
-
function ValidationError(message, path, validator, options) {
|
|
19648
|
+
function ValidationError(message, path, validator, options, index) {
|
|
19650
19649
|
var _this2;
|
|
19651
19650
|
|
|
19652
19651
|
(0, _classCallCheck2["default"])(this, ValidationError);
|
|
@@ -19654,6 +19653,7 @@ function require_Error () {
|
|
|
19654
19653
|
_this2.path = path;
|
|
19655
19654
|
_this2.validator = validator;
|
|
19656
19655
|
_this2.options = options;
|
|
19656
|
+
_this2.index = index;
|
|
19657
19657
|
return _this2;
|
|
19658
19658
|
}
|
|
19659
19659
|
|
|
@@ -20211,90 +20211,149 @@ function requireCompiler () {
|
|
|
20211
20211
|
return compileTypeDefinition;
|
|
20212
20212
|
}()
|
|
20213
20213
|
}, {
|
|
20214
|
-
key: "
|
|
20214
|
+
key: "compileOptions",
|
|
20215
20215
|
value: function () {
|
|
20216
|
-
var
|
|
20217
|
-
var
|
|
20216
|
+
var _compileOptions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(options) {
|
|
20217
|
+
var res;
|
|
20218
20218
|
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
20219
20219
|
while (1) {
|
|
20220
20220
|
switch (_context9.prev = _context9.next) {
|
|
20221
|
+
case 0:
|
|
20222
|
+
if (!((0, _helpers.isObject)(options) && options.$ref !== undefined)) {
|
|
20223
|
+
_context9.next = 7;
|
|
20224
|
+
break;
|
|
20225
|
+
}
|
|
20226
|
+
|
|
20227
|
+
_context9.next = 3;
|
|
20228
|
+
return this.resolveRef(options.$ref);
|
|
20229
|
+
|
|
20230
|
+
case 3:
|
|
20231
|
+
res = _context9.sent;
|
|
20232
|
+
|
|
20233
|
+
if (!(0, _helpers.isObject)(res)) {
|
|
20234
|
+
_context9.next = 6;
|
|
20235
|
+
break;
|
|
20236
|
+
}
|
|
20237
|
+
|
|
20238
|
+
return _context9.abrupt("return", Object.keys(res));
|
|
20239
|
+
|
|
20240
|
+
case 6:
|
|
20241
|
+
return _context9.abrupt("return", res);
|
|
20242
|
+
|
|
20243
|
+
case 7:
|
|
20244
|
+
return _context9.abrupt("return", options);
|
|
20245
|
+
|
|
20246
|
+
case 8:
|
|
20247
|
+
case "end":
|
|
20248
|
+
return _context9.stop();
|
|
20249
|
+
}
|
|
20250
|
+
}
|
|
20251
|
+
}, _callee9, this);
|
|
20252
|
+
}));
|
|
20253
|
+
|
|
20254
|
+
function compileOptions(_x12) {
|
|
20255
|
+
return _compileOptions.apply(this, arguments);
|
|
20256
|
+
}
|
|
20257
|
+
|
|
20258
|
+
return compileOptions;
|
|
20259
|
+
}()
|
|
20260
|
+
}, {
|
|
20261
|
+
key: "compileField",
|
|
20262
|
+
value: function () {
|
|
20263
|
+
var _compileField = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(uncompiledField, name) {
|
|
20264
|
+
var field, prohibited, required, optional, type, defaultDef, options;
|
|
20265
|
+
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
20266
|
+
while (1) {
|
|
20267
|
+
switch (_context10.prev = _context10.next) {
|
|
20221
20268
|
case 0:
|
|
20222
20269
|
field = (0, _helpers.deepCopy)(uncompiledField);
|
|
20223
|
-
prohibited = field.prohibited, required = field.required, optional = field.optional, type = field.type, defaultDef = field["default"];
|
|
20270
|
+
prohibited = field.prohibited, required = field.required, optional = field.optional, type = field.type, defaultDef = field["default"], options = field.options;
|
|
20224
20271
|
|
|
20225
20272
|
if (!(type === undefined)) {
|
|
20226
|
-
|
|
20273
|
+
_context10.next = 4;
|
|
20227
20274
|
break;
|
|
20228
20275
|
}
|
|
20229
20276
|
|
|
20230
20277
|
throw new _Error.SchemaError("Field \"".concat(name, "\" is missing a type definition"));
|
|
20231
20278
|
|
|
20232
20279
|
case 4:
|
|
20233
|
-
|
|
20280
|
+
_context10.next = 6;
|
|
20234
20281
|
return this.compileTypeDefinition(type, name);
|
|
20235
20282
|
|
|
20236
20283
|
case 6:
|
|
20237
|
-
field.type =
|
|
20284
|
+
field.type = _context10.sent;
|
|
20238
20285
|
|
|
20239
20286
|
if (!(defaultDef !== undefined)) {
|
|
20240
|
-
|
|
20287
|
+
_context10.next = 11;
|
|
20241
20288
|
break;
|
|
20242
20289
|
}
|
|
20243
20290
|
|
|
20244
|
-
|
|
20291
|
+
_context10.next = 10;
|
|
20245
20292
|
return this.compileTypeDefinition(defaultDef, name);
|
|
20246
20293
|
|
|
20247
20294
|
case 10:
|
|
20248
|
-
field["default"] =
|
|
20295
|
+
field["default"] = _context10.sent;
|
|
20249
20296
|
|
|
20250
20297
|
case 11:
|
|
20251
|
-
if (!
|
|
20252
|
-
|
|
20298
|
+
if (!options) {
|
|
20299
|
+
_context10.next = 15;
|
|
20253
20300
|
break;
|
|
20254
20301
|
}
|
|
20255
20302
|
|
|
20256
|
-
|
|
20257
|
-
return this.
|
|
20303
|
+
_context10.next = 14;
|
|
20304
|
+
return this.compileOptions(options);
|
|
20258
20305
|
|
|
20259
20306
|
case 14:
|
|
20260
|
-
field.
|
|
20307
|
+
field.options = _context10.sent;
|
|
20261
20308
|
|
|
20262
20309
|
case 15:
|
|
20263
|
-
if (!(
|
|
20264
|
-
|
|
20310
|
+
if (!(prohibited !== undefined)) {
|
|
20311
|
+
_context10.next = 19;
|
|
20265
20312
|
break;
|
|
20266
20313
|
}
|
|
20267
20314
|
|
|
20268
|
-
|
|
20269
|
-
return this.compileRules(
|
|
20315
|
+
_context10.next = 18;
|
|
20316
|
+
return this.compileRules(prohibited, name);
|
|
20270
20317
|
|
|
20271
20318
|
case 18:
|
|
20272
|
-
field.
|
|
20319
|
+
field.prohibited = _context10.sent;
|
|
20273
20320
|
|
|
20274
20321
|
case 19:
|
|
20275
|
-
if (!(
|
|
20276
|
-
|
|
20322
|
+
if (!(required !== undefined)) {
|
|
20323
|
+
_context10.next = 23;
|
|
20277
20324
|
break;
|
|
20278
20325
|
}
|
|
20279
20326
|
|
|
20280
|
-
|
|
20281
|
-
return this.compileRules(
|
|
20327
|
+
_context10.next = 22;
|
|
20328
|
+
return this.compileRules(required, name);
|
|
20282
20329
|
|
|
20283
20330
|
case 22:
|
|
20284
|
-
field.
|
|
20331
|
+
field.required = _context10.sent;
|
|
20285
20332
|
|
|
20286
20333
|
case 23:
|
|
20287
|
-
|
|
20334
|
+
if (!(optional !== undefined)) {
|
|
20335
|
+
_context10.next = 27;
|
|
20336
|
+
break;
|
|
20337
|
+
}
|
|
20338
|
+
|
|
20339
|
+
_context10.next = 26;
|
|
20340
|
+
return this.compileRules(optional, name);
|
|
20341
|
+
|
|
20342
|
+
case 26:
|
|
20343
|
+
field.optional = _context10.sent;
|
|
20344
|
+
|
|
20345
|
+
case 27:
|
|
20346
|
+
return _context10.abrupt("return", field);
|
|
20288
20347
|
|
|
20289
|
-
case
|
|
20348
|
+
case 28:
|
|
20290
20349
|
case "end":
|
|
20291
|
-
return
|
|
20350
|
+
return _context10.stop();
|
|
20292
20351
|
}
|
|
20293
20352
|
}
|
|
20294
|
-
},
|
|
20353
|
+
}, _callee10, this);
|
|
20295
20354
|
}));
|
|
20296
20355
|
|
|
20297
|
-
function compileField(
|
|
20356
|
+
function compileField(_x13, _x14) {
|
|
20298
20357
|
return _compileField.apply(this, arguments);
|
|
20299
20358
|
}
|
|
20300
20359
|
|
|
@@ -20303,135 +20362,135 @@ function requireCompiler () {
|
|
|
20303
20362
|
}, {
|
|
20304
20363
|
key: "compileCatalog",
|
|
20305
20364
|
value: function () {
|
|
20306
|
-
var _compileCatalog = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
20365
|
+
var _compileCatalog = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(uncompiledCatalog) {
|
|
20307
20366
|
var _this2 = this;
|
|
20308
20367
|
|
|
20309
20368
|
var catalog, result;
|
|
20310
|
-
return _regenerator["default"].wrap(function
|
|
20369
|
+
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
|
20311
20370
|
while (1) {
|
|
20312
|
-
switch (
|
|
20371
|
+
switch (_context13.prev = _context13.next) {
|
|
20313
20372
|
case 0:
|
|
20314
20373
|
catalog = (0, _helpers.deepCopy)(uncompiledCatalog);
|
|
20315
20374
|
|
|
20316
20375
|
if ((0, _helpers.isObject)(catalog)) {
|
|
20317
|
-
|
|
20376
|
+
_context13.next = 3;
|
|
20318
20377
|
break;
|
|
20319
20378
|
}
|
|
20320
20379
|
|
|
20321
20380
|
throw new _Error.SchemaError("Invalid type of \"".concat((0, _typeof2["default"])(catalog), "\" for catalog."));
|
|
20322
20381
|
|
|
20323
20382
|
case 3:
|
|
20324
|
-
|
|
20383
|
+
_context13.next = 5;
|
|
20325
20384
|
return Promise.all(Object.entries(catalog).map( /*#__PURE__*/function () {
|
|
20326
|
-
var _ref6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
20327
|
-
return _regenerator["default"].wrap(function
|
|
20385
|
+
var _ref6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(e) {
|
|
20386
|
+
return _regenerator["default"].wrap(function _callee12$(_context12) {
|
|
20328
20387
|
while (1) {
|
|
20329
|
-
switch (
|
|
20388
|
+
switch (_context12.prev = _context12.next) {
|
|
20330
20389
|
case 0:
|
|
20331
20390
|
if (!(0, _helpers.isObject)(e[1])) {
|
|
20332
|
-
|
|
20391
|
+
_context12.next = 2;
|
|
20333
20392
|
break;
|
|
20334
20393
|
}
|
|
20335
20394
|
|
|
20336
|
-
return
|
|
20395
|
+
return _context12.abrupt("return", (0, _defineProperty2["default"])({}, e[0], e[1]));
|
|
20337
20396
|
|
|
20338
20397
|
case 2:
|
|
20339
20398
|
if (Array.isArray(e[1])) {
|
|
20340
|
-
|
|
20399
|
+
_context12.next = 4;
|
|
20341
20400
|
break;
|
|
20342
20401
|
}
|
|
20343
20402
|
|
|
20344
20403
|
throw new _Error.SchemaError("Invalid type of \"".concat((0, _typeof2["default"])(e[1]), "\" for catalog at path \"").concat(e[0], "\"."));
|
|
20345
20404
|
|
|
20346
20405
|
case 4:
|
|
20347
|
-
|
|
20348
|
-
|
|
20349
|
-
|
|
20350
|
-
|
|
20406
|
+
_context12.t0 = _defineProperty2["default"];
|
|
20407
|
+
_context12.t1 = {};
|
|
20408
|
+
_context12.t2 = e[0];
|
|
20409
|
+
_context12.next = 9;
|
|
20351
20410
|
return Promise.all(e[1].map( /*#__PURE__*/function () {
|
|
20352
|
-
var _ref8 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
20411
|
+
var _ref8 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11(ee) {
|
|
20353
20412
|
var res;
|
|
20354
|
-
return _regenerator["default"].wrap(function
|
|
20413
|
+
return _regenerator["default"].wrap(function _callee11$(_context11) {
|
|
20355
20414
|
while (1) {
|
|
20356
|
-
switch (
|
|
20415
|
+
switch (_context11.prev = _context11.next) {
|
|
20357
20416
|
case 0:
|
|
20358
20417
|
if ((0, _helpers.isObject)(ee)) {
|
|
20359
|
-
|
|
20418
|
+
_context11.next = 2;
|
|
20360
20419
|
break;
|
|
20361
20420
|
}
|
|
20362
20421
|
|
|
20363
|
-
return
|
|
20422
|
+
return _context11.abrupt("return", ee);
|
|
20364
20423
|
|
|
20365
20424
|
case 2:
|
|
20366
20425
|
if (!(ee.$ref === undefined)) {
|
|
20367
|
-
|
|
20426
|
+
_context11.next = 4;
|
|
20368
20427
|
break;
|
|
20369
20428
|
}
|
|
20370
20429
|
|
|
20371
20430
|
throw new _Error.SchemaError("Objects inside a catalog Array need to define a $ref at path \"".concat(e[0], "\"."));
|
|
20372
20431
|
|
|
20373
20432
|
case 4:
|
|
20374
|
-
|
|
20433
|
+
_context11.next = 6;
|
|
20375
20434
|
return _this2.resolveRef(ee.$ref);
|
|
20376
20435
|
|
|
20377
20436
|
case 6:
|
|
20378
|
-
res =
|
|
20437
|
+
res = _context11.sent;
|
|
20379
20438
|
|
|
20380
20439
|
if (!(0, _helpers.isObject)(res)) {
|
|
20381
|
-
|
|
20440
|
+
_context11.next = 9;
|
|
20382
20441
|
break;
|
|
20383
20442
|
}
|
|
20384
20443
|
|
|
20385
|
-
return
|
|
20444
|
+
return _context11.abrupt("return", Object.keys(res));
|
|
20386
20445
|
|
|
20387
20446
|
case 9:
|
|
20388
|
-
return
|
|
20447
|
+
return _context11.abrupt("return", res);
|
|
20389
20448
|
|
|
20390
20449
|
case 10:
|
|
20391
20450
|
case "end":
|
|
20392
|
-
return
|
|
20451
|
+
return _context11.stop();
|
|
20393
20452
|
}
|
|
20394
20453
|
}
|
|
20395
|
-
},
|
|
20454
|
+
}, _callee11);
|
|
20396
20455
|
}));
|
|
20397
20456
|
|
|
20398
|
-
return function (
|
|
20457
|
+
return function (_x17) {
|
|
20399
20458
|
return _ref8.apply(this, arguments);
|
|
20400
20459
|
};
|
|
20401
20460
|
}()));
|
|
20402
20461
|
|
|
20403
20462
|
case 9:
|
|
20404
|
-
|
|
20405
|
-
return
|
|
20463
|
+
_context12.t3 = _context12.sent;
|
|
20464
|
+
return _context12.abrupt("return", (0, _context12.t0)(_context12.t1, _context12.t2, _context12.t3));
|
|
20406
20465
|
|
|
20407
20466
|
case 11:
|
|
20408
20467
|
case "end":
|
|
20409
|
-
return
|
|
20468
|
+
return _context12.stop();
|
|
20410
20469
|
}
|
|
20411
20470
|
}
|
|
20412
|
-
},
|
|
20471
|
+
}, _callee12);
|
|
20413
20472
|
}));
|
|
20414
20473
|
|
|
20415
|
-
return function (
|
|
20474
|
+
return function (_x16) {
|
|
20416
20475
|
return _ref6.apply(this, arguments);
|
|
20417
20476
|
};
|
|
20418
20477
|
}()));
|
|
20419
20478
|
|
|
20420
20479
|
case 5:
|
|
20421
|
-
result =
|
|
20422
|
-
return
|
|
20480
|
+
result = _context13.sent;
|
|
20481
|
+
return _context13.abrupt("return", result.reduce(function (l, r) {
|
|
20423
20482
|
return _objectSpread(_objectSpread({}, l), r);
|
|
20424
20483
|
}, {}));
|
|
20425
20484
|
|
|
20426
20485
|
case 7:
|
|
20427
20486
|
case "end":
|
|
20428
|
-
return
|
|
20487
|
+
return _context13.stop();
|
|
20429
20488
|
}
|
|
20430
20489
|
}
|
|
20431
|
-
},
|
|
20490
|
+
}, _callee13);
|
|
20432
20491
|
}));
|
|
20433
20492
|
|
|
20434
|
-
function compileCatalog(
|
|
20493
|
+
function compileCatalog(_x15) {
|
|
20435
20494
|
return _compileCatalog.apply(this, arguments);
|
|
20436
20495
|
}
|
|
20437
20496
|
|
|
@@ -20440,16 +20499,16 @@ function requireCompiler () {
|
|
|
20440
20499
|
}, {
|
|
20441
20500
|
key: "process",
|
|
20442
20501
|
value: function () {
|
|
20443
|
-
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
20502
|
+
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14(schemaArg, resolver) {
|
|
20444
20503
|
var schema, catalog, properties, fieldNames, i, name, field;
|
|
20445
|
-
return _regenerator["default"].wrap(function
|
|
20504
|
+
return _regenerator["default"].wrap(function _callee14$(_context14) {
|
|
20446
20505
|
while (1) {
|
|
20447
|
-
switch (
|
|
20506
|
+
switch (_context14.prev = _context14.next) {
|
|
20448
20507
|
case 0:
|
|
20449
20508
|
this.resolver = resolver;
|
|
20450
20509
|
|
|
20451
20510
|
if ((0, _helpers.isObject)(schemaArg)) {
|
|
20452
|
-
|
|
20511
|
+
_context14.next = 3;
|
|
20453
20512
|
break;
|
|
20454
20513
|
}
|
|
20455
20514
|
|
|
@@ -20462,15 +20521,15 @@ function requireCompiler () {
|
|
|
20462
20521
|
catalog = schema.catalog, properties = schema.properties;
|
|
20463
20522
|
|
|
20464
20523
|
if (!(catalog !== undefined)) {
|
|
20465
|
-
|
|
20524
|
+
_context14.next = 11;
|
|
20466
20525
|
break;
|
|
20467
20526
|
}
|
|
20468
20527
|
|
|
20469
|
-
|
|
20528
|
+
_context14.next = 10;
|
|
20470
20529
|
return this.compileCatalog(catalog);
|
|
20471
20530
|
|
|
20472
20531
|
case 10:
|
|
20473
|
-
schema.catalog =
|
|
20532
|
+
schema.catalog = _context14.sent;
|
|
20474
20533
|
|
|
20475
20534
|
case 11:
|
|
20476
20535
|
fieldNames = Object.keys(properties);
|
|
@@ -20478,35 +20537,35 @@ function requireCompiler () {
|
|
|
20478
20537
|
|
|
20479
20538
|
case 13:
|
|
20480
20539
|
if (!(i < fieldNames.length)) {
|
|
20481
|
-
|
|
20540
|
+
_context14.next = 22;
|
|
20482
20541
|
break;
|
|
20483
20542
|
}
|
|
20484
20543
|
|
|
20485
20544
|
name = fieldNames[i];
|
|
20486
20545
|
field = properties[name];
|
|
20487
|
-
|
|
20546
|
+
_context14.next = 18;
|
|
20488
20547
|
return this.compileField(field, name);
|
|
20489
20548
|
|
|
20490
20549
|
case 18:
|
|
20491
|
-
properties[name] =
|
|
20550
|
+
properties[name] = _context14.sent;
|
|
20492
20551
|
|
|
20493
20552
|
case 19:
|
|
20494
20553
|
i++;
|
|
20495
|
-
|
|
20554
|
+
_context14.next = 13;
|
|
20496
20555
|
break;
|
|
20497
20556
|
|
|
20498
20557
|
case 22:
|
|
20499
|
-
return
|
|
20558
|
+
return _context14.abrupt("return", schema);
|
|
20500
20559
|
|
|
20501
20560
|
case 23:
|
|
20502
20561
|
case "end":
|
|
20503
|
-
return
|
|
20562
|
+
return _context14.stop();
|
|
20504
20563
|
}
|
|
20505
20564
|
}
|
|
20506
|
-
},
|
|
20565
|
+
}, _callee14, this);
|
|
20507
20566
|
}));
|
|
20508
20567
|
|
|
20509
|
-
function process(
|
|
20568
|
+
function process(_x18, _x19) {
|
|
20510
20569
|
return _process.apply(this, arguments);
|
|
20511
20570
|
}
|
|
20512
20571
|
|
|
@@ -28321,24 +28380,36 @@ function requireValidator () {
|
|
|
28321
28380
|
}
|
|
28322
28381
|
}, {
|
|
28323
28382
|
key: "validateType",
|
|
28324
|
-
value: function validateType(name, field, value, otherFields) {
|
|
28383
|
+
value: function validateType(name, field, value, otherFields, index) {
|
|
28325
28384
|
var type = field.type,
|
|
28326
28385
|
validator = field.validator,
|
|
28327
28386
|
options = field.options;
|
|
28328
28387
|
|
|
28388
|
+
if (type === 'array' && validator && Array.isArray(value)) {
|
|
28389
|
+
for (var i = 0; i < value.length; i++) {
|
|
28390
|
+
this.validateType(name, {
|
|
28391
|
+
type: 'string',
|
|
28392
|
+
validator: validator,
|
|
28393
|
+
options: options
|
|
28394
|
+
}, value[i], otherFields, i);
|
|
28395
|
+
}
|
|
28396
|
+
|
|
28397
|
+
return true;
|
|
28398
|
+
}
|
|
28399
|
+
|
|
28329
28400
|
if (validator === undefined) {
|
|
28330
|
-
if (type === undefined) throw new _Error.SchemaError("Invalid type definition \"".concat(type, "\" at path \"").concat(name, "\"."));
|
|
28401
|
+
if (type === undefined) throw new _Error.SchemaError("Invalid type definition \"".concat(type, "\" at path \"").concat(name).concat(index ? "[".concat(index, "]") : '', "\"."));
|
|
28331
28402
|
|
|
28332
28403
|
if (this.validateBaseType(type, value) === false) {
|
|
28333
|
-
if (Array.isArray(type)) throw new _Error.ValidationError("\"".concat(
|
|
28404
|
+
if (Array.isArray(type)) throw new _Error.ValidationError("invalid value for \"".concat(name).concat(index ? "[".concat(index, "]") : '', "\""), name, 'enum', type, index);else throw new _Error.ValidationError("value is not of type \"".concat(type, "\" in \"").concat(name).concat(index ? "[".concat(index, "]") : '', "\""), name, type, index);
|
|
28334
28405
|
}
|
|
28335
28406
|
} else {
|
|
28336
28407
|
var func = _TypeValidator["default"]["is".concat(validator)];
|
|
28337
28408
|
|
|
28338
|
-
if (typeof func !== 'function') throw new _Error.SchemaError("Unknown validator \"".concat(validator, "\" at path \"").concat(name, "\"."));
|
|
28409
|
+
if (typeof func !== 'function') throw new _Error.SchemaError("Unknown validator \"".concat(validator, "\" at path \"").concat(name).concat(index ? "[".concat(index, "]") : '', "\"."));
|
|
28339
28410
|
|
|
28340
28411
|
if (func(String(value), options, otherFields) === false) {
|
|
28341
|
-
throw new _Error.ValidationError('invalid', name, validator, options);
|
|
28412
|
+
throw new _Error.ValidationError('invalid', name, validator, options, index);
|
|
28342
28413
|
}
|
|
28343
28414
|
}
|
|
28344
28415
|
|
|
@@ -28425,12 +28496,14 @@ function requireValidator () {
|
|
|
28425
28496
|
this.validateType(name, schema[name], value, data);
|
|
28426
28497
|
} catch (e) {
|
|
28427
28498
|
if (!(e instanceof _Error.ValidationError)) throw e;
|
|
28428
|
-
|
|
28499
|
+
var errorEntry = {
|
|
28429
28500
|
message: e.message,
|
|
28430
28501
|
path: e.path,
|
|
28431
28502
|
validator: e.validator,
|
|
28432
28503
|
options: e.options
|
|
28433
|
-
}
|
|
28504
|
+
};
|
|
28505
|
+
if (e.index) errorEntry.index = e.index;
|
|
28506
|
+
return new FieldResult(name, data[name], undefined, isProhibited, isRequired, isOptional, true, [errorEntry]);
|
|
28434
28507
|
}
|
|
28435
28508
|
|
|
28436
28509
|
return new FieldResult(name, data[name], this.castType(name, type, value), isProhibited, isRequired, isOptional);
|
|
@@ -32063,8 +32136,9 @@ var getValue$1 = function getValue(value, catalog) {
|
|
|
32063
32136
|
var FormRepeater = function FormRepeater(_ref) {
|
|
32064
32137
|
var variant = _ref.variant,
|
|
32065
32138
|
name = _ref.name,
|
|
32139
|
+
label = _ref.label,
|
|
32066
32140
|
value = _ref.value,
|
|
32067
|
-
|
|
32141
|
+
options = _ref.options,
|
|
32068
32142
|
onChange = _ref.onChange;
|
|
32069
32143
|
|
|
32070
32144
|
var _useState = useState(value || []),
|
|
@@ -32082,6 +32156,11 @@ var FormRepeater = function FormRepeater(_ref) {
|
|
|
32082
32156
|
inputValue = _useState6[0],
|
|
32083
32157
|
setInputValue = _useState6[1];
|
|
32084
32158
|
|
|
32159
|
+
var _useState7 = useState(''),
|
|
32160
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
32161
|
+
catalogSelectValue = _useState8[0],
|
|
32162
|
+
setCatalogSelectValue = _useState8[1];
|
|
32163
|
+
|
|
32085
32164
|
var handleEntryAdd = function handleEntryAdd() {
|
|
32086
32165
|
if (inputValue.length > 0) {
|
|
32087
32166
|
setEntries([].concat(_toConsumableArray(entries), [inputValue]));
|
|
@@ -32092,6 +32171,7 @@ var FormRepeater = function FormRepeater(_ref) {
|
|
|
32092
32171
|
var handleCancelNewEntry = function handleCancelNewEntry() {
|
|
32093
32172
|
setInEdit(false);
|
|
32094
32173
|
setInputValue('');
|
|
32174
|
+
setCatalogSelectValue('');
|
|
32095
32175
|
};
|
|
32096
32176
|
|
|
32097
32177
|
var handleEntryDel = function handleEntryDel(delIndex) {
|
|
@@ -32112,15 +32192,23 @@ var FormRepeater = function FormRepeater(_ref) {
|
|
|
32112
32192
|
}, [entries]);
|
|
32113
32193
|
var blockedOptions = [];
|
|
32114
32194
|
|
|
32115
|
-
if (
|
|
32116
|
-
blockedOptions = Object.entries(
|
|
32117
|
-
return value.includes(e[0]);
|
|
32195
|
+
if (options) {
|
|
32196
|
+
blockedOptions = Object.entries(options).filter(function (e) {
|
|
32197
|
+
return Array.isArray(value) && value.includes(e[0]);
|
|
32118
32198
|
}).map(function (e) {
|
|
32119
32199
|
return e[0];
|
|
32120
32200
|
});
|
|
32121
32201
|
}
|
|
32122
32202
|
|
|
32123
|
-
return /*#__PURE__*/React__default.createElement(_Box, null, /*#__PURE__*/React__default.createElement(
|
|
32203
|
+
return /*#__PURE__*/React__default.createElement(_Box, null, /*#__PURE__*/React__default.createElement(_Typography, {
|
|
32204
|
+
variant: "body1"
|
|
32205
|
+
}, label), (!entries || (entries === null || entries === void 0 ? void 0 : entries.length) === 0) && /*#__PURE__*/React__default.createElement(_Box, {
|
|
32206
|
+
mt: 1,
|
|
32207
|
+
pl: 2
|
|
32208
|
+
}, /*#__PURE__*/React__default.createElement(_Typography, {
|
|
32209
|
+
variant: "body2",
|
|
32210
|
+
color: "textSecondary"
|
|
32211
|
+
}, "Keine Eintr\xE4ge vorhanden")), /*#__PURE__*/React__default.createElement(_List, {
|
|
32124
32212
|
dense: true
|
|
32125
32213
|
}, entries.map(function (entry, index) {
|
|
32126
32214
|
return (
|
|
@@ -32129,7 +32217,7 @@ var FormRepeater = function FormRepeater(_ref) {
|
|
|
32129
32217
|
React__default.createElement(_ListItem, {
|
|
32130
32218
|
key: "entry-".concat(index)
|
|
32131
32219
|
}, /*#__PURE__*/React__default.createElement(_ListItemText, {
|
|
32132
|
-
primary: getValue$1(entry,
|
|
32220
|
+
primary: getValue$1(entry, options)
|
|
32133
32221
|
}), /*#__PURE__*/React__default.createElement(_ListItemSecondaryAction, null, /*#__PURE__*/React__default.createElement(_IconButton, {
|
|
32134
32222
|
edge: "end",
|
|
32135
32223
|
"aria-label": "delete",
|
|
@@ -32147,10 +32235,16 @@ var FormRepeater = function FormRepeater(_ref) {
|
|
|
32147
32235
|
onClick: function onClick() {
|
|
32148
32236
|
return setInEdit(true);
|
|
32149
32237
|
}
|
|
32150
|
-
}, "
|
|
32238
|
+
}, "Eintr\xE4ge hinzuf\xFCgen")), inEdit && !options && /*#__PURE__*/React__default.createElement(_Box, {
|
|
32151
32239
|
width: "100%",
|
|
32152
32240
|
display: "flex",
|
|
32153
32241
|
alignItems: "center"
|
|
32242
|
+
}, /*#__PURE__*/React__default.createElement(_ClickAwayListener, {
|
|
32243
|
+
onClickAway: function onClickAway() {
|
|
32244
|
+
if (inputValue === '') {
|
|
32245
|
+
setInEdit(false);
|
|
32246
|
+
}
|
|
32247
|
+
}
|
|
32154
32248
|
}, /*#__PURE__*/React__default.createElement(_FormControl, {
|
|
32155
32249
|
variant: "filled",
|
|
32156
32250
|
fullWidth: true
|
|
@@ -32182,22 +32276,24 @@ var FormRepeater = function FormRepeater(_ref) {
|
|
|
32182
32276
|
onChange: function onChange(e) {
|
|
32183
32277
|
return setInputValue(e.target.value);
|
|
32184
32278
|
}
|
|
32185
|
-
}))), inEdit &&
|
|
32279
|
+
})))), inEdit && options && /*#__PURE__*/React__default.createElement(_Box, {
|
|
32186
32280
|
width: "100%",
|
|
32187
32281
|
display: "flex",
|
|
32188
32282
|
alignItems: "center"
|
|
32189
32283
|
}, /*#__PURE__*/React__default.createElement(_FormControl, {
|
|
32190
32284
|
variant: "filled",
|
|
32191
32285
|
fullWidth: true
|
|
32192
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
32193
|
-
|
|
32286
|
+
}, /*#__PURE__*/React__default.createElement(_TextField, {
|
|
32287
|
+
label: "Eintrag ausw\xE4hlen",
|
|
32288
|
+
select: true,
|
|
32289
|
+
variant: variant,
|
|
32290
|
+
value: catalogSelectValue,
|
|
32291
|
+
onBlur: handleCancelNewEntry,
|
|
32194
32292
|
onChange: function onChange(e) {
|
|
32195
|
-
|
|
32293
|
+
setCatalogSelectValue('');
|
|
32294
|
+
setEntries([].concat(_toConsumableArray(entries), [e.target.value]));
|
|
32196
32295
|
}
|
|
32197
|
-
},
|
|
32198
|
-
value: "please-select",
|
|
32199
|
-
disabled: true
|
|
32200
|
-
}, "Eintrag hinzuf\xFCgen"), Object.entries(catalog).sort(function (a, b) {
|
|
32296
|
+
}, Object.entries(options).sort(function (a, b) {
|
|
32201
32297
|
return a[1].localeCompare(b[1]);
|
|
32202
32298
|
}).map(function (e) {
|
|
32203
32299
|
return /*#__PURE__*/React__default.createElement(_MenuItem, {
|
|
@@ -32210,9 +32306,10 @@ var FormRepeater = function FormRepeater(_ref) {
|
|
|
32210
32306
|
|
|
32211
32307
|
FormRepeater.propTypes = {
|
|
32212
32308
|
variant: PropTypes__default.oneOf(['standard', 'filled', 'outlined']),
|
|
32213
|
-
name: PropTypes__default.string
|
|
32309
|
+
name: PropTypes__default.string,
|
|
32310
|
+
label: PropTypes__default.string,
|
|
32214
32311
|
value: PropTypes__default.any,
|
|
32215
|
-
|
|
32312
|
+
options: PropTypes__default.object,
|
|
32216
32313
|
onChange: PropTypes__default.func.isRequired
|
|
32217
32314
|
};
|
|
32218
32315
|
|
|
@@ -76023,11 +76120,22 @@ var FormulatorFormSection = /*#__PURE__*/function (_React$Component) {
|
|
|
76023
76120
|
var mapEntry = isRender ? renderComponentMap[field] : componentMap[mapKey];
|
|
76024
76121
|
var component = mapEntry,
|
|
76025
76122
|
props = {};
|
|
76123
|
+
console.log(schema.properties, fieldEntry);
|
|
76124
|
+
|
|
76125
|
+
if (mapKey === 'array' && schema.properties[fieldEntry].options) {
|
|
76126
|
+
props.options = schema.properties[fieldEntry].options.reduce(function (l, r) {
|
|
76127
|
+
var _translations$fieldEn;
|
|
76128
|
+
|
|
76129
|
+
return _objectSpread$1(_objectSpread$1({}, l), {}, _defineProperty({}, r, (translations === null || translations === void 0 ? void 0 : (_translations$fieldEn = translations[fieldEntry]) === null || _translations$fieldEn === void 0 ? void 0 : _translations$fieldEn[r]) || r));
|
|
76130
|
+
}, {});
|
|
76131
|
+
}
|
|
76026
76132
|
|
|
76027
76133
|
if (mapKey === 'select') {
|
|
76028
76134
|
props.options = type.map(function (value) {
|
|
76135
|
+
var _translations$field;
|
|
76136
|
+
|
|
76029
76137
|
return {
|
|
76030
|
-
label: translations
|
|
76138
|
+
label: (translations === null || translations === void 0 ? void 0 : (_translations$field = translations.field) === null || _translations$field === void 0 ? void 0 : _translations$field.value) || value,
|
|
76031
76139
|
value: value
|
|
76032
76140
|
};
|
|
76033
76141
|
});
|