@talend/react-forms
Version:
React forms library based on json schema form.
1,381 lines (1,193 loc) • 1.47 MB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["TalendReactForms"] = factory();
else
root["TalendReactForms"] = factory();
})(this, () => {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "../../fork/json-schema-form-core/lib-esm/canonical-title-map.js":
/*!***********************************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/canonical-title-map.js ***!
\***********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
// Takes a titleMap in either object or list format and returns one
// in the list format.
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(titleMap, originalEnum) {
if (!Array.isArray(titleMap)) {
const canonical = [];
if (originalEnum) {
originalEnum.forEach(value => {
canonical.push({
name: titleMap[value],
value
});
});
} else {
Object.keys(titleMap).forEach(value => {
canonical.push({
name: titleMap[value],
value
});
});
}
return canonical;
}
return titleMap;
}
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/index.js":
/*!*********************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/index.js ***!
\*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ canonicalTitleMap: () => (/* binding */ canonicalTitleMap),
/* harmony export */ jsonref: () => (/* reexport safe */ _resolve__WEBPACK_IMPORTED_MODULE_6__.jsonref),
/* harmony export */ merge: () => (/* reexport safe */ _merge__WEBPACK_IMPORTED_MODULE_4__.merge),
/* harmony export */ schemaDefaults: () => (/* binding */ schemaDefaults),
/* harmony export */ select: () => (/* reexport safe */ _select__WEBPACK_IMPORTED_MODULE_5__.select),
/* harmony export */ sfPath: () => (/* binding */ sfPath),
/* harmony export */ traverseForm: () => (/* reexport safe */ _traverse__WEBPACK_IMPORTED_MODULE_7__.traverseForm),
/* harmony export */ traverseSchema: () => (/* reexport safe */ _traverse__WEBPACK_IMPORTED_MODULE_7__.traverseSchema),
/* harmony export */ tv4: () => (/* binding */ tv4),
/* harmony export */ validate: () => (/* reexport safe */ _validate__WEBPACK_IMPORTED_MODULE_8__.validate)
/* harmony export */ });
/* harmony import */ var tv4__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tv4 */ "../../node_modules/tv4/tv4.js");
/* harmony import */ var tv4__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tv4__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _schema_defaults__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./schema-defaults */ "../../fork/json-schema-form-core/lib-esm/schema-defaults.js");
/* harmony import */ var _sf_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sf-path */ "../../fork/json-schema-form-core/lib-esm/sf-path.js");
/* harmony import */ var _canonical_title_map__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./canonical-title-map */ "../../fork/json-schema-form-core/lib-esm/canonical-title-map.js");
/* harmony import */ var _merge__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./merge */ "../../fork/json-schema-form-core/lib-esm/merge.js");
/* harmony import */ var _select__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./select */ "../../fork/json-schema-form-core/lib-esm/select.js");
/* harmony import */ var _resolve__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./resolve */ "../../fork/json-schema-form-core/lib-esm/resolve.js");
/* harmony import */ var _traverse__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./traverse */ "../../fork/json-schema-form-core/lib-esm/traverse.js");
/* harmony import */ var _validate__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./validate */ "../../fork/json-schema-form-core/lib-esm/validate.js");
// eslint-disable-next-line prettier/prettier
// eslint-disable-next-line prettier/prettier
// eslint-disable-next-line prettier/prettier
const sfPath = _sf_path__WEBPACK_IMPORTED_MODULE_2__;
const schemaDefaults = _schema_defaults__WEBPACK_IMPORTED_MODULE_1__;
const canonicalTitleMap = _canonical_title_map__WEBPACK_IMPORTED_MODULE_3__["default"];
const tv4 = (tv4__WEBPACK_IMPORTED_MODULE_0___default());
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/merge.js":
/*!*********************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/merge.js ***!
\*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ merge: () => (/* binding */ merge)
/* harmony export */ });
/* harmony import */ var _canonical_title_map__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./canonical-title-map */ "../../fork/json-schema-form-core/lib-esm/canonical-title-map.js");
/* harmony import */ var _schema_defaults__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./schema-defaults */ "../../fork/json-schema-form-core/lib-esm/schema-defaults.js");
/* harmony import */ var _sf_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sf-path */ "../../fork/json-schema-form-core/lib-esm/sf-path.js");
// export function merge(schema, form, schemaDefaultTypes, ignore, options, readonly, asyncTemplates) {
function merge(lookup, form, typeDefaults = (0,_schema_defaults__WEBPACK_IMPORTED_MODULE_1__.createDefaults)(), ignore, options, readonly, asyncTemplates) {
let formItems = [];
let formItemRest = [];
form = form || [];
let idx = form.indexOf('*');
options = options || {};
let stdForm = {};
let idxRest = form.indexOf('...');
if (typeof lookup === 'object' && lookup.hasOwnProperty('properties')) {
readonly = readonly || lookup.readonly || lookup.readOnly;
stdForm = (0,_schema_defaults__WEBPACK_IMPORTED_MODULE_1__.defaultForm)(lookup, typeDefaults, ignore, options);
let defaultFormLookup = stdForm.lookup;
lookup = defaultFormLookup || lookup;
formItems = formItems.concat(stdForm.form);
}
if (idx !== -1) {
form = form.slice(0, idx).concat(formItems).concat(form.slice(idx + 1));
}
//simple case, we have a "...", just put the formItemRest there
if (stdForm.form && idxRest !== -1) {
let formKeys = form.map(function (obj) {
if (typeof obj === 'string') {
return obj;
} else if (obj.key) {
return obj.key;
}
}).filter(function (element) {
return element !== undefined;
});
formItemRest = formItemRest.concat(stdForm.form.map(function (obj) {
let isInside = formKeys.indexOf(obj.key[0]) !== -1;
if (!isInside) {
return obj;
}
}).filter(function (element) {
return element !== undefined;
}));
}
if (idxRest !== -1) {
form = form.slice(0, idxRest).concat(formItemRest).concat(form.slice(idxRest + 1));
}
// ok let's merge!
// We look at the supplied form and extend it with schema standards
return form.map(obj => {
// handle the shortcut with just a name
if (typeof obj === 'string') {
obj = {
key: obj
};
}
if (obj.key) {
if (typeof obj.key === 'string') {
obj.key = (0,_sf_path__WEBPACK_IMPORTED_MODULE_2__.parse)(obj.key);
}
}
// If it has a titleMap make sure it's a list
if (obj.titleMap) {
obj.titleMap = (0,_canonical_title_map__WEBPACK_IMPORTED_MODULE_0__["default"])(obj.titleMap);
}
// extend with std form from schema.
if (obj.key) {
const strid = (0,_sf_path__WEBPACK_IMPORTED_MODULE_2__.stringify)(obj.key);
if (lookup[strid]) {
const schemaDefaults = lookup[strid];
if (schemaDefaults) {
Object.keys(schemaDefaults).forEach(attr => {
if (obj[attr] === undefined) {
obj[attr] = schemaDefaults[attr];
}
});
}
}
}
// Are we inheriting readonly?
if (readonly === true) {
// Inheriting false is not cool.
obj.readonly = true;
}
// if it's a type with items, merge 'em!
if (obj.items) {
obj.items = merge(lookup, obj.items, typeDefaults, ignore, options, obj.readonly, asyncTemplates);
}
// if its has tabs, merge them also!
if (obj.tabs) {
obj.tabs.forEach(tab => {
if (tab.items) {
tab.items = merge(lookup, tab.items, typeDefaults, ignore, options, obj.readonly, asyncTemplates);
}
});
}
// Special case: checkbox
// Since have to ternary state we need a default
if (obj.type === 'checkbox') {
// Check for schema property, as the checkbox may be part of the explicitly defined form
if (obj.schema === undefined) {
obj.schema = {
default: false
};
} else if (obj.schema['default'] === undefined) {
obj.schema['default'] = false;
}
}
// Special case: template type with tempplateUrl that's needs to be loaded before rendering
// TODO: this is not a clean solution. Maybe something cleaner can be made when $ref support
// is introduced since we need to go async then anyway
if (asyncTemplates && obj.type === 'template' && !obj.template && obj.templateUrl) {
asyncTemplates.push(obj);
}
return obj;
});
}
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/resolve.js":
/*!***********************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/resolve.js ***!
\***********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ jsonref: () => (/* binding */ jsonref)
/* harmony export */ });
/* harmony import */ var json_refs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! json-refs */ "../../node_modules/json-refs/index.js");
function jsonref(schema, callBack) {
let promise = new Promise(function (resolve, reject) {
json_refs__WEBPACK_IMPORTED_MODULE_0__.resolveRefs(schema, {
filter: ['relative', 'local', 'remote']
}).then(res => {
resolve(res.resolved);
}).catch(err => {
reject(new Error(err));
});
});
if (typeof callBack === 'function') {
promise.then(resolved => {
callBack(null, resolved);
}).catch(error => {
callBack(error);
});
} else {
return promise;
}
}
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/schema-defaults.js":
/*!*******************************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/schema-defaults.js ***!
\*******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ array: () => (/* binding */ array),
/* harmony export */ checkbox: () => (/* binding */ checkbox),
/* harmony export */ checkboxes: () => (/* binding */ checkboxes),
/* harmony export */ createDefaults: () => (/* binding */ createDefaults),
/* harmony export */ defaultForm: () => (/* binding */ defaultForm),
/* harmony export */ defaultFormDefinition: () => (/* binding */ defaultFormDefinition),
/* harmony export */ fieldset: () => (/* binding */ fieldset),
/* harmony export */ integer: () => (/* binding */ integer),
/* harmony export */ number: () => (/* binding */ number),
/* harmony export */ select: () => (/* binding */ select),
/* harmony export */ stdFormObj: () => (/* binding */ stdFormObj),
/* harmony export */ text: () => (/* binding */ text)
/* harmony export */ });
/* harmony import */ var _canonical_title_map__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./canonical-title-map */ "../../fork/json-schema-form-core/lib-esm/canonical-title-map.js");
/* harmony import */ var _sf_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sf-path */ "../../fork/json-schema-form-core/lib-esm/sf-path.js");
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
/* Utils */
const stripNullType = type => {
if (Array.isArray(type) && type.length === 2) {
if (type[0] === 'null') {
return type[1];
}
if (type[1] === 'null') {
return type[0];
}
}
return type;
};
// Creates an default titleMap list from an enum, i.e. a list of strings.
const enumToTitleMap = enm => {
const titleMap = []; // canonical titleMap format is a list.
enm.forEach(name => {
titleMap.push({
name,
value: name
});
});
return titleMap;
};
/**
* Creates a default form definition from a schema.
*/
function defaultFormDefinition(schemaTypes, name, schema, options) {
const rules = schemaTypes[stripNullType(schema.type)];
if (rules) {
let def;
// We give each rule a possibility to recurse it's children.
const innerDefaultFormDefinition = (childName, childSchema, childOptions) => defaultFormDefinition(schemaTypes, childName, childSchema, childOptions);
for (let i = 0; i < rules.length; i++) {
def = rules[i](name, schema, options, innerDefaultFormDefinition);
// first handler in list that actually returns something is our handler!
if (def) {
// Do we have form defaults in the schema under the x-schema-form-attribute?
if (def.schema['x-schema-form']) {
_extends(def, def.schema['x-schema-form']);
}
return def;
}
}
}
}
/**
* Creates a form object with all common properties
*/
function stdFormObj(name, schema, options) {
options = options || {};
// The Object.assign used to be a angular.copy. Should work though.
const f = options.global && options.global.formDefaults ? _extends({}, options.global.formDefaults) : {};
if (options.global && options.global.supressPropertyTitles === true) {
f.title = schema.title;
} else {
f.title = schema.title || name;
}
if (schema.description) {
f.description = schema.description;
}
if (options.required === true || schema.required === true) {
f.required = true;
}
if (schema.maxLength) {
f.maxlength = schema.maxLength;
}
if (schema.minLength) {
f.minlength = schema.minLength;
}
if (schema.readOnly || schema.readonly) {
f.readonly = true;
}
if (schema.minimum) {
f.minimum = schema.minimum + (schema.exclusiveMinimum ? 1 : 0);
}
if (schema.maximum) {
f.maximum = schema.maximum - (schema.exclusiveMaximum ? 1 : 0);
}
// Non standard attributes (DONT USE DEPRECATED)
// If you must set stuff like this in the schema use the x-schema-form attribute
if (schema.validationMessage) {
f.validationMessage = schema.validationMessage;
}
if (schema.enumNames) {
f.titleMap = (0,_canonical_title_map__WEBPACK_IMPORTED_MODULE_0__["default"])(schema.enumNames, schema.enum);
}
f.schema = schema;
// Ng model options doesn't play nice with undefined, might be defined
// globally though
f.ngModelOptions = f.ngModelOptions || {};
return f;
}
/*** Schema types to form type mappings, with defaults ***/
function text(name, schema, options) {
if (stripNullType(schema.type) === 'string' && !schema.enum) {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'text';
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
return f;
}
}
// default in json form for number and integer is a text field
// input type="number" would be more suitable don't ya think?
function number(name, schema, options) {
if (stripNullType(schema.type) === 'number') {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'number';
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
return f;
}
}
function integer(name, schema, options) {
if (stripNullType(schema.type) === 'integer') {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'number';
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
return f;
}
}
function checkbox(name, schema, options) {
if (stripNullType(schema.type) === 'boolean') {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'checkbox';
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
return f;
}
}
function select(name, schema, options) {
if (stripNullType(schema.type) === 'string' && schema.enum) {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'select';
if (!f.titleMap) {
f.titleMap = enumToTitleMap(schema.enum);
}
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
return f;
}
}
function checkboxes(name, schema, options) {
if (stripNullType(schema.type) === 'array' && schema.items && schema.items.enum) {
const f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'checkboxes';
if (!f.titleMap) {
f.titleMap = enumToTitleMap(schema.items.enum);
}
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
return f;
}
}
function fieldset(name, schema, options, defaultFormDef) {
if (stripNullType(schema.type) === 'object') {
const f = stdFormObj(name, schema, options);
f.type = 'fieldset';
f.key = options.path;
f.items = [];
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
// recurse down into properties
if (schema.properties) {
Object.keys(schema.properties).forEach(key => {
const value = schema.properties[key];
const path = options.path.slice();
path.push(key);
if (options.ignore[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(path)] !== true) {
const required = schema.required && schema.required.indexOf(key) !== -1;
const def = defaultFormDef(key, value, {
path,
required: required || false,
lookup: options.lookup,
ignore: options.ignore,
global: options.global
});
if (def) {
f.items.push(def);
}
}
});
}
return f;
}
}
function array(name, schema, options, defaultFormDef) {
if (stripNullType(schema.type) === 'array') {
const f = stdFormObj(name, schema, options);
f.type = 'array';
f.key = options.path;
options.lookup[(0,_sf_path__WEBPACK_IMPORTED_MODULE_1__.stringify)(options.path)] = f;
const required = schema.required && schema.required.indexOf(options.path[options.path.length - 1]) !== -1;
// The default is to always just create one child. This works since if the
// schemas items declaration is of type: "object" then we get a fieldset.
// We also follow json form notatation, adding empty brackets "[]" to
// signify arrays.
const arrPath = options.path.slice();
arrPath.push('');
f.items = [defaultFormDef(name, schema.items, {
path: arrPath,
required: required || false,
lookup: options.lookup,
ignore: options.ignore,
global: options.global
})];
return f;
}
}
function createDefaults() {
// First sorted by schema type then a list.
// Order has importance. First handler returning an form snippet will be used.
return {
string: [select, text],
object: [fieldset],
number: [number],
integer: [integer],
boolean: [checkbox],
array: [checkboxes, array]
};
}
/**
* Create form defaults from schema
*/
function defaultForm(schema, defaultSchemaTypes, ignore, globalOptions) {
const form = [];
const lookup = {}; // Map path => form obj for fast lookup in merging
ignore = ignore || {};
globalOptions = globalOptions || {};
defaultSchemaTypes = defaultSchemaTypes || createDefaults();
if (schema.properties) {
Object.keys(schema.properties).forEach(key => {
if (ignore[key] !== true) {
const required = schema.required && schema.required.indexOf(key) !== -1;
const def = defaultFormDefinition(defaultSchemaTypes, key, schema.properties[key], {
path: [key],
// Path to this property in bracket notation.
lookup: lookup,
// Extra map to register with. Optimization for merger.
ignore: ignore,
// The ignore list of paths (sans root level name)
required: required,
// Is it required? (v4 json schema style)
global: globalOptions // Global options, including form defaults
});
if (def) {
form.push(def);
}
}
});
} else {
throw new Error('Not implemented. Only type "object" allowed at root level of schema.');
}
return {
form: form,
lookup: lookup
};
}
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/select.js":
/*!**********************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/select.js ***!
\**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ select: () => (/* binding */ select)
/* harmony export */ });
/* harmony import */ var _sf_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sf-path */ "../../fork/json-schema-form-core/lib-esm/sf-path.js");
const numRe = /^\d+$/;
/**
* @description
* Utility method to access deep properties without
* throwing errors when things are not defined.
* Can also set a value in a deep structure, creating objects when missing
* ex.
* var foo = Select('address.contact.name',obj)
* Select('address.contact.name',obj,'Leeroy')
*
* @param {string} projection A dot path to the property you want to get/set
* @param {object} obj (optional) The object to project on, defaults to 'this'
* @param {Any} valueToSet (opional) The value to set, if parts of the path of
* the projection is missing empty objects will be created.
* @returns {Any|undefined} returns the value at the end of the projection path
* or undefined if there is none.
*/
function select(projection, obj, valueToSet) {
if (!obj) {
obj = this;
}
// Support [] array syntax
let parts = typeof projection === 'string' ? _sf_path__WEBPACK_IMPORTED_MODULE_0__.parse(projection) : projection;
if (typeof valueToSet !== 'undefined' && parts.length === 1) {
// special case, just setting one variable
obj[parts[0]] = valueToSet;
return obj;
}
if (typeof valueToSet !== 'undefined' && typeof obj[parts[0]] === 'undefined') {
// We need to look ahead to check if array is appropriate
obj[parts[0]] = parts.length > 2 && numRe.test(parts[1]) ? [] : {};
}
let value = obj[parts[0]];
for (let i = 1; i < parts.length; i++) {
// Special case: We allow JSON Form syntax for arrays using empty brackets
// These will of course not work here so we exit if they are found.
if (parts[i] === '') {
return undefined;
}
if (typeof valueToSet !== 'undefined') {
if (i === parts.length - 1) {
// last step. Let's set the value
value[parts[i]] = valueToSet;
return valueToSet;
} else {
// Make sure to create new objects on the way if they are not there.
// We need to look ahead to check if array is appropriate
let tmp = value[parts[i]];
if (typeof tmp === 'undefined' || tmp === null) {
tmp = numRe.test(parts[i + 1]) ? [] : {};
value[parts[i]] = tmp;
}
value = tmp;
}
} else if (value) {
// Just get nex value.
value = value[parts[i]];
}
}
return value;
}
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/sf-path.js":
/*!***********************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/sf-path.js ***!
\***********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ name: () => (/* binding */ name),
/* harmony export */ normalize: () => (/* reexport safe */ objectpath__WEBPACK_IMPORTED_MODULE_0__.normalize),
/* harmony export */ parse: () => (/* reexport safe */ objectpath__WEBPACK_IMPORTED_MODULE_0__.parse),
/* harmony export */ stringify: () => (/* reexport safe */ objectpath__WEBPACK_IMPORTED_MODULE_0__.stringify)
/* harmony export */ });
/* harmony import */ var objectpath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! objectpath */ "../../node_modules/objectpath/index.js");
/* harmony import */ var objectpath__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(objectpath__WEBPACK_IMPORTED_MODULE_0__);
/**
* I am a name formatter function for processing keys into names for classes or Id.
*
* @param {Array<string>} key I am the key array of a processed schema key
* @param {string} separator I am the separator between the key items and optional form name
* @param {string} formName I am an optional form name
* @param {boolean} omitNumbers I determine if numeric values should be included in the output or withheld
*
* @return {string} I am the formatted key
*/
function name(key, separator, formName = '', omitNumbers = false) {
if (key) {
let fieldKey = key.slice();
let fieldSeparator = separator || '-';
if (omitNumbers) {
fieldKey = fieldKey.filter(function (currentKey) {
return typeof currentKey !== 'number';
});
}
return (formName.length !== 0 ? formName + fieldSeparator : '') + fieldKey.join(fieldSeparator);
}
return '';
}
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/traverse.js":
/*!************************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/traverse.js ***!
\************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ traverseForm: () => (/* binding */ traverseForm),
/* harmony export */ traverseSchema: () => (/* binding */ traverseSchema)
/* harmony export */ });
/**
* Traverse a schema, applying a function(schema,path) on every sub schema
* i.e. every property of an object.
*/
function traverseSchema(schema, fn, path, ignoreArrays) {
ignoreArrays = ignoreArrays === undefined ? true : ignoreArrays;
path = path || [];
const traverse = function (schemaObject, processorFunction, pathArray) {
processorFunction(schemaObject, pathArray);
if (schemaObject.properties) {
Object.keys(schemaObject.properties).forEach(name => {
const currentPath = pathArray.slice();
currentPath.push(name);
traverse(schemaObject.properties[name], processorFunction, currentPath);
});
}
// Only support type "array" which have a schemaObject as "items".
if (!ignoreArrays && schemaObject.items) {
const arrPath = pathArray.slice();
arrPath.push('');
traverse(schemaObject.items, processorFunction, arrPath);
}
};
traverse(schema, fn, path || []);
}
function traverseForm(form, fn) {
fn(form);
if (form.items) {
form.items.forEach(f => {
traverseForm(f, fn);
});
}
if (form.tabs) {
form.tabs.forEach(tab => {
if (tab.items) {
tab.items.forEach(f => {
traverseForm(f, fn);
});
}
});
}
}
/***/ }),
/***/ "../../fork/json-schema-form-core/lib-esm/validate.js":
/*!************************************************************!*\
!*** ../../fork/json-schema-form-core/lib-esm/validate.js ***!
\************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ validate: () => (/* binding */ validate)
/* harmony export */ });
/* harmony import */ var tv4__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tv4 */ "../../node_modules/tv4/tv4.js");
/* harmony import */ var tv4__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tv4__WEBPACK_IMPORTED_MODULE_0__);
/* Common code for validating a value against its form and schema definition */
function validateTypeSpecificInput(inputType = '', event = {}) {
var _event$target;
switch (inputType) {
case 'number':
// If the user types a non-integer value, the value is emptied by browser but still displayed in UI
if ((_event$target = event.target) !== null && _event$target !== void 0 && _event$target.validity && event.target.validity.badInput) {
return {
valid: false,
message: 'CUSTOM_ERROR_INVALID_INPUT'
};
}
break;
default:
break;
}
return {
valid: true
};
}
/**
* Validate a value against its form definition and schema.
* The value should either be of proper type or a string, some type
* coercion is applied.
*
* @param {Object} form A merged form definition, i.e. one with a schema.
* @param {Any} value the value to validate.
* @param {Object} event for input types in which the values are not available in form
* @return {Object} a tv4js result object.
*/
function validate(form, value, event) {
if (!form) {
return {
valid: true
};
}
let schema = form.schema;
if (!schema) {
return {
valid: true
};
}
// Input of type text and textareas will give us a viewValue of ''
// when empty, this is a valid value in a schema and does not count as something
// that breaks validation of 'required'. But for our own sanity an empty field should
// not validate if it's required.
if (value === '') {
value = undefined;
}
const error = validateTypeSpecificInput(form.type, event);
if (!error.valid && error.message) {
return {
valid: false,
error: {
message: error.message
}
};
}
// Version 4 of JSON Schema has the required property not on the
// property itself but on the wrapping object. Since we like to test
// only this property we wrap it in a fake object.
let wrap = {
type: 'object',
properties: {},
required: undefined
};
let propName = form.key[form.key.length - 1];
wrap.properties[propName] = schema;
if (form.required) {
wrap.required = [propName];
}
let valueWrap = {};
if (typeof value !== 'undefined') {
valueWrap[propName] = value;
}
return tv4__WEBPACK_IMPORTED_MODULE_0___default().validateResult(valueWrap, wrap);
}
/***/ }),
/***/ "../../node_modules/call-bind-apply-helpers/actualApply.js":
/*!*****************************************************************!*\
!*** ../../node_modules/call-bind-apply-helpers/actualApply.js ***!
\*****************************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var bind = __webpack_require__(/*! function-bind */ "../../node_modules/function-bind/index.js");
var $apply = __webpack_require__(/*! ./functionApply */ "../../node_modules/call-bind-apply-helpers/functionApply.js");
var $call = __webpack_require__(/*! ./functionCall */ "../../node_modules/call-bind-apply-helpers/functionCall.js");
var $reflectApply = __webpack_require__(/*! ./reflectApply */ "../../node_modules/call-bind-apply-helpers/reflectApply.js");
/** @type {import('./actualApply')} */
module.exports = $reflectApply || bind.call($call, $apply);
/***/ }),
/***/ "../../node_modules/call-bind-apply-helpers/functionApply.js":
/*!*******************************************************************!*\
!*** ../../node_modules/call-bind-apply-helpers/functionApply.js ***!
\*******************************************************************/
/***/ ((module) => {
"use strict";
/** @type {import('./functionApply')} */
module.exports = Function.prototype.apply;
/***/ }),
/***/ "../../node_modules/call-bind-apply-helpers/functionCall.js":
/*!******************************************************************!*\
!*** ../../node_modules/call-bind-apply-helpers/functionCall.js ***!
\******************************************************************/
/***/ ((module) => {
"use strict";
/** @type {import('./functionCall')} */
module.exports = Function.prototype.call;
/***/ }),
/***/ "../../node_modules/call-bind-apply-helpers/index.js":
/*!***********************************************************!*\
!*** ../../node_modules/call-bind-apply-helpers/index.js ***!
\***********************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var bind = __webpack_require__(/*! function-bind */ "../../node_modules/function-bind/index.js");
var $TypeError = __webpack_require__(/*! es-errors/type */ "../../node_modules/es-errors/type.js");
var $call = __webpack_require__(/*! ./functionCall */ "../../node_modules/call-bind-apply-helpers/functionCall.js");
var $actualApply = __webpack_require__(/*! ./actualApply */ "../../node_modules/call-bind-apply-helpers/actualApply.js");
/** @type {(args: [Function, thisArg?: unknown, ...args: unknown[]]) => Function} TODO FIXME, find a way to use import('.') */
module.exports = function callBindBasic(args) {
if (args.length < 1 || typeof args[0] !== 'function') {
throw new $TypeError('a function is required');
}
return $actualApply(bind, $call, args);
};
/***/ }),
/***/ "../../node_modules/call-bind-apply-helpers/reflectApply.js":
/*!******************************************************************!*\
!*** ../../node_modules/call-bind-apply-helpers/reflectApply.js ***!
\******************************************************************/
/***/ ((module) => {
"use strict";
/** @type {import('./reflectApply')} */
module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply;
/***/ }),
/***/ "../../node_modules/call-bound/index.js":
/*!**********************************************!*\
!*** ../../node_modules/call-bound/index.js ***!
\**********************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "../../node_modules/get-intrinsic/index.js");
var callBindBasic = __webpack_require__(/*! call-bind-apply-helpers */ "../../node_modules/call-bind-apply-helpers/index.js");
/** @type {(thisArg: string, searchString: string, position?: number) => number} */
var $indexOf = callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]);
/** @type {import('.')} */
module.exports = function callBoundIntrinsic(name, allowMissing) {
/* eslint no-extra-parens: 0 */
var intrinsic = /** @type {(this: unknown, ...args: unknown[]) => unknown} */ (GetIntrinsic(name, !!allowMissing));
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
return callBindBasic(/** @type {const} */ ([intrinsic]));
}
return intrinsic;
};
/***/ }),
/***/ "../../node_modules/component-emitter/index.js":
/*!*****************************************************!*\
!*** ../../node_modules/component-emitter/index.js ***!
\*****************************************************/
/***/ ((module) => {
/**
* Expose `Emitter`.
*/
if (true) {
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
// Remove event specific arrays for event types that no
// one is subscribed for to avoid memory leak.
if (callbacks.length === 0) {
delete this._callbacks['$' + event];
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = new Array(arguments.length - 1)
, callbacks = this._callbacks['$' + event];
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
/***/ }),
/***/ "../../node_modules/date-fns/_lib/addLeadingZeros.mjs":
/*!************************************************************!*\
!*** ../../node_modules/date-fns/_lib/addLeadingZeros.mjs ***!
\************************************************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ addLeadingZeros: () => (/* binding */ addLeadingZeros)
/* harmony export */ });
function addLeadingZeros(number, targetLength) {
const sign = number < 0 ? "-" : "";
const output = Math.abs(number).toString().padStart(targetLength, "0");
return sign + output;
}
/***/ }),
/***/ "../../node_modules/date-fns/_lib/defaultOptions.mjs":
/*!***********************************************************!*\
!*** ../../node_modules/date-fns/_lib/defaultOptions.mjs ***!
\***********************************************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ getDefaultOptions: () => (/* binding */ getDefaultOptions),
/* harmony export */ setDefaultOptions: () => (/* binding */ setDefaultOptions)
/* harmony export */ });
let defaultOptions = {};
function getDefaultOptions() {
return defaultOptions;
}
function setDefaultOptions(newOptions) {
defaultOptions = newOptions;
}
/***/ }),
/***/ "../../node_modules/date-fns/_lib/format/formatters.mjs":
/*!**************************************************************!*\
!*** ../../node_modules/date-fns/_lib/format/formatters.mjs ***!
\**************************************************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ formatters: () => (/* binding */ formatters)
/* harmony export */ });
/* harmony import */ var _getDayOfYear_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../getDayOfYear.mjs */ "../../node_modules/date-fns/getDayOfYear.mjs");
/* harmony import */ var _getISOWeek_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../getISOWeek.mjs */ "../../node_modules/date-fns/getISOWeek.mjs");
/* harmony import */ var _getISOWeekYear_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../getISOWeekYear.mjs */ "../../node_modules/date-fns/getISOWeekYear.mjs");
/* harmony import */ var _getWeek_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../getWeek.mjs */ "../../node_modules/date-fns/getWeek.mjs");
/* harmony import */ var _getWeekYear_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../getWeekYear.mjs */ "../../node_modules/date-fns/getWeekYear.mjs");
/* harmony import */ var _addLeadingZeros_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../addLeadingZeros.mjs */ "../../node_modules/date-fns/_lib/addLeadingZeros.mjs");
/* harmony import */ var _lightFormatters_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lightFormatters.mjs */ "../../node_modules/date-fns/_lib/format/lightFormatters.mjs");
const dayPeriodEnum = {
am: "am",
pm: "pm",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night",
};
/*
* | | Unit | | Unit |
* |-----|--------------------------------|-----|--------------------------------|
* | a | AM, PM | A* | Milliseconds in day |
* | b | AM, PM, noon, midnight | B | Flexible day period |
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
* | d | Day of month | D | Day of year |
* | e | Local day of week | E | Day of week |
* | f | | F* | Day of week in month |
* | g* | Modified Julian day | G | Era |
* | h | Hour [1-12] | H | Hour [0-23] |
* | i! | ISO day of week | I! | ISO week of year |
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
* | k | Hour [1-24] | K | Hour [0-11] |
* | l* | (deprecated) | L | Stand-alone month |
* | m | Minute | M | Month |
* | n | | N | |
* | o! | Ordinal number modifier | O | Timezone (GMT) |
* | p! | Long localized time | P! | Long localized date |
* | q | Stand-alone quarter | Q | Quarter |
* | r* | Related Gregorian year | R! | ISO week-numbering year |
* | s | Second | S | Fraction of second |
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
* | u | Extended year | U* | Cyclic year |
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
* | w | Local week of year | W* | Week of month |
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
* | y | Year (abs) | Y | Local week-numbering year |
* | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
*
* Letters marked by * are not implemented but reserved by Unicode standard.
*
* Letters marked by ! are non-standard, but implemented by date-fns:
* - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
* i.e. 7 for Sunday, 1 for Monday, etc.
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
* `R` is supposed to be used in conjunction with `I` and `i`
* for universal ISO week-numbering date, whereas
* `Y` is supposed to be used in conjunction with `w` and `e`
* for week-numbering date specific to the locale.
* - `P` is long localized date format
* - `p` is long localized time format
*/
const formatters = {
// Era
G: function (date, token, localize) {
const era = date.getFullYear() > 0 ? 1 : 0;
switch (token) {
// AD, BC
case "G":
case "GG":
case "GGG":
return localize.era(era, { width: "abbreviated" });
// A, B
case "GGGGG":
return localize.era(era, { width: "narrow" });
// Anno Domini, Before Christ
case "GGGG":
default:
return localize.era(era, { width: "wide" });
}
},
// Year
y: function (date, token, localize) {
// Ordinal number
if (token === "yo") {
const signedYear = date.getFullYear();
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const year = signedYear > 0 ? signedYear : 1 - signedYear;
return localize.ordinalNumber(year, { unit: "year" });
}
return _lightFormatters_mjs__WEBPACK_IMPORTED_MODULE_6__.lightFormatters.y(date, token);
},
// Local week-numbering year
Y: function (date, token, localize, options) {
const signedWeekYear = (0,_getWeekYear_mjs__WEBPACK_IMPORTED_MODULE_4__.getWeekYear)(date, options);
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
// Two digit year
if (token === "YY") {
const twoDigitYear = weekYear % 100;
return (0,_addLeadingZeros_mjs__WEBPACK_IMPORTED_MODULE_5__.addLeadingZeros)(twoDigitYear, 2);
}
// Ordinal number
if (token === "Yo") {
return localize.ordinalNumber(weekYear, { unit: "year" });
}
// Padding
return (0,_addLeadingZeros_mjs__WEBPACK_IMPORTED_MODULE_5__.addLeadingZeros)(weekYear, token.length);
},
// ISO week-numbering year
R: function (date, token) {
const isoWeekYear = (0,_getISOWeekYear_mjs__WEBPACK_IMPORTED_MODULE_2__.getISOWeekYear)(date);
// Padding
return (0,_addLeadingZeros_mjs__WEBPACK_IMPORTED_MODULE_5__.addLeadingZeros)(isoWeekYear, token.length);
},
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: function (date, token) {
const year = date.getFullYear();
return (0,_addLeadingZeros_mjs__WEBPACK_IMPORTED_MODULE_5__.addLeadingZeros)(year, token.length);
},
/