@bpmn-io/form-js-viewer
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -11,105 +11,2 @@ import Ids from 'ids'; | ||
function createInjector(bootstrapModules) { | ||
const modules = [], | ||
components = []; | ||
function hasModule(module) { | ||
return modules.includes(module); | ||
} | ||
function addModule(module) { | ||
modules.push(module); | ||
} | ||
function visit(module) { | ||
if (hasModule(module)) { | ||
return; | ||
} | ||
(module.__depends__ || []).forEach(visit); | ||
if (hasModule(module)) { | ||
return; | ||
} | ||
addModule(module); | ||
(module.__init__ || []).forEach(function (component) { | ||
components.push(component); | ||
}); | ||
} | ||
bootstrapModules.forEach(visit); | ||
const injector = new Injector(modules); | ||
components.forEach(function (component) { | ||
try { | ||
injector[typeof component === 'string' ? 'get' : 'invoke'](component); | ||
} catch (err) { | ||
console.error('Failed to instantiate component'); | ||
console.error(err.stack); | ||
throw err; | ||
} | ||
}); | ||
return injector; | ||
} | ||
/** | ||
* @param {string?} prefix | ||
* | ||
* @returns Element | ||
*/ | ||
function createFormContainer(prefix = 'fjs') { | ||
const container = document.createElement('div'); | ||
container.classList.add(`${prefix}-container`); | ||
return container; | ||
} | ||
function findErrors(errors, path) { | ||
return errors[pathStringify(path)]; | ||
} | ||
function isRequired(field) { | ||
return field.required; | ||
} | ||
function pathParse(path) { | ||
if (!path) { | ||
return []; | ||
} | ||
return path.split('.').map(key => { | ||
return isNaN(parseInt(key)) ? key : parseInt(key); | ||
}); | ||
} | ||
function pathsEqual(a, b) { | ||
return a && b && a.length === b.length && a.every((value, index) => value === b[index]); | ||
} | ||
function pathStringify(path) { | ||
if (!path) { | ||
return ''; | ||
} | ||
return path.join('.'); | ||
} | ||
const indices = {}; | ||
function generateIndexForType(type) { | ||
if (type in indices) { | ||
indices[type]++; | ||
} else { | ||
indices[type] = 1; | ||
} | ||
return indices[type]; | ||
} | ||
function generateIdForType(type) { | ||
return `${type}${generateIndexForType(type)}`; | ||
} | ||
/** | ||
* @template T | ||
* @param {T} data | ||
* @param {(this: any, key: string, value: any) => any} [replacer] | ||
* @return {T} | ||
*/ | ||
function clone(data, replacer) { | ||
return JSON.parse(JSON.stringify(data, replacer)); | ||
} | ||
var FN_REF = '__fn'; | ||
@@ -628,2 +525,3 @@ var DEFAULT_PRIORITY = 1000; | ||
} | ||
Validator.$inject = []; | ||
@@ -694,2 +592,105 @@ class FormFieldRegistry { | ||
function createInjector(bootstrapModules) { | ||
const modules = [], | ||
components = []; | ||
function hasModule(module) { | ||
return modules.includes(module); | ||
} | ||
function addModule(module) { | ||
modules.push(module); | ||
} | ||
function visit(module) { | ||
if (hasModule(module)) { | ||
return; | ||
} | ||
(module.__depends__ || []).forEach(visit); | ||
if (hasModule(module)) { | ||
return; | ||
} | ||
addModule(module); | ||
(module.__init__ || []).forEach(function (component) { | ||
components.push(component); | ||
}); | ||
} | ||
bootstrapModules.forEach(visit); | ||
const injector = new Injector(modules); | ||
components.forEach(function (component) { | ||
try { | ||
injector[typeof component === 'string' ? 'get' : 'invoke'](component); | ||
} catch (err) { | ||
console.error('Failed to instantiate component'); | ||
console.error(err.stack); | ||
throw err; | ||
} | ||
}); | ||
return injector; | ||
} | ||
/** | ||
* @param {string?} prefix | ||
* | ||
* @returns Element | ||
*/ | ||
function createFormContainer(prefix = 'fjs') { | ||
const container = document.createElement('div'); | ||
container.classList.add(`${prefix}-container`); | ||
return container; | ||
} | ||
function findErrors(errors, path) { | ||
return errors[pathStringify(path)]; | ||
} | ||
function isRequired(field) { | ||
return field.required; | ||
} | ||
function pathParse(path) { | ||
if (!path) { | ||
return []; | ||
} | ||
return path.split('.').map(key => { | ||
return isNaN(parseInt(key)) ? key : parseInt(key); | ||
}); | ||
} | ||
function pathsEqual(a, b) { | ||
return a && b && a.length === b.length && a.every((value, index) => value === b[index]); | ||
} | ||
function pathStringify(path) { | ||
if (!path) { | ||
return ''; | ||
} | ||
return path.join('.'); | ||
} | ||
const indices = {}; | ||
function generateIndexForType(type) { | ||
if (type in indices) { | ||
indices[type]++; | ||
} else { | ||
indices[type] = 1; | ||
} | ||
return indices[type]; | ||
} | ||
function generateIdForType(type) { | ||
return `${type}${generateIndexForType(type)}`; | ||
} | ||
/** | ||
* @template T | ||
* @param {T} data | ||
* @param {(this: any, key: string, value: any) => any} [replacer] | ||
* @return {T} | ||
*/ | ||
function clone(data, replacer) { | ||
return JSON.parse(JSON.stringify(data, replacer)); | ||
} | ||
class Importer { | ||
@@ -1771,2 +1772,6 @@ /** | ||
* } } State | ||
* | ||
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority | ||
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority | ||
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType | ||
*/ | ||
@@ -1787,4 +1792,10 @@ | ||
* @public | ||
* @type {OnEventType} | ||
*/ | ||
this.on = this._onEvent; | ||
/** | ||
* @public | ||
* @type {String} | ||
*/ | ||
this._id = ids.next(); | ||
@@ -2038,3 +2049,2 @@ /** | ||
* @param {FormEvent} type | ||
* @param {number} priority | ||
* @param {Function} handler | ||
@@ -2044,11 +2054,2 @@ */ | ||
on(type, priority, handler) { | ||
this.get('eventBus').on(type, priority, handler); | ||
} | ||
/** | ||
* @param {FormEvent} type | ||
* @param {Function} handler | ||
*/ | ||
off(type, handler) { | ||
@@ -2142,3 +2143,11 @@ this.get('eventBus').off(type, handler); | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
_onEvent(type, priority, handler) { | ||
this.get('eventBus').on(type, priority, handler); | ||
} | ||
} | ||
@@ -2145,0 +2154,0 @@ |
@@ -1,3 +0,7 @@ | ||
export default class Validator { | ||
declare class Validator { | ||
validateField(field: any, value: any): any[]; | ||
} | ||
declare namespace Validator { | ||
const $inject: any[]; | ||
} | ||
export default Validator; |
@@ -12,2 +12,7 @@ /** | ||
* @public | ||
* @type {OnEventType} | ||
*/ | ||
public on: OnEventType; | ||
/** | ||
* @public | ||
* @type {String} | ||
@@ -75,10 +80,4 @@ */ | ||
* @param {FormEvent} type | ||
* @param {number} priority | ||
* @param {Function} handler | ||
*/ | ||
on(type: FormEvent, priority: number, handler: Function): void; | ||
/** | ||
* @param {FormEvent} type | ||
* @param {Function} handler | ||
*/ | ||
off(type: FormEvent, handler: Function): void; | ||
@@ -117,2 +116,6 @@ /** | ||
_setState(state: any): void; | ||
/** | ||
* @internal | ||
*/ | ||
_onEvent(type: any, priority: any, handler: any): void; | ||
} | ||
@@ -134,1 +137,4 @@ export type Injector = any; | ||
}; | ||
export type OnEventWithPriority = OnEventWithPriority; | ||
export type OnEventWithOutPriority = OnEventWithOutPriority; | ||
export type OnEventType = OnEventWithPriority & OnEventWithOutPriority; |
{ | ||
"name": "@bpmn-io/form-js-viewer", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "View forms - powered by bpmn.io", | ||
@@ -54,3 +54,3 @@ "exports": { | ||
], | ||
"gitHead": "978132ea4bda84b1045b815e24f2dab9a102ccd9" | ||
"gitHead": "75a12520e4a55c2d3b4fcab6464fe86026ba40b2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
327346
4388