@bpmn-io/form-js-viewer
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -628,8 +628,64 @@ import { isArray, isFunction, isNumber, bind, assign, get, set, isString } from 'min-dash'; | ||
var FormFieldRegistry = Map; | ||
class FormFieldRegistry { | ||
constructor(eventBus) { | ||
this._eventBus = eventBus; | ||
this._formFields = {}; | ||
eventBus.on('form.clear', () => this.clear()); | ||
} | ||
add(formField) { | ||
const { | ||
id | ||
} = formField; | ||
if (this._formFields[id]) { | ||
throw new Error(`form field with ID ${id} already exists`); | ||
} | ||
this._eventBus.fire('formField.add', { | ||
formField | ||
}); | ||
this._formFields[id] = formField; | ||
} | ||
remove(formField) { | ||
const { | ||
id | ||
} = formField; | ||
if (!this._formFields[id]) { | ||
return; | ||
} | ||
this._eventBus.fire('formField.remove', { | ||
formField | ||
}); | ||
delete this._formFields[id]; | ||
} | ||
get(id) { | ||
return this._formFields[id]; | ||
} | ||
getAll() { | ||
return Object.values(this._formFields); | ||
} | ||
forEach(callback) { | ||
this.getAll().forEach(formField => callback(formField)); | ||
} | ||
clear() { | ||
this._formFields = {}; | ||
} | ||
} | ||
FormFieldRegistry.$inject = ['eventBus']; | ||
class Importer { | ||
/** | ||
* @constructor | ||
* @param { import('../core/FormFieldRegistry').default } formFieldRegistry | ||
* @param { import('../core').FormFieldRegistry } formFieldRegistry | ||
* @param { import('../render/FormFields').default } formFields | ||
@@ -688,3 +744,3 @@ */ | ||
if (parentId) { | ||
// Set form field parent | ||
// set form field parent | ||
formField._parent = parentId; | ||
@@ -702,3 +758,3 @@ } | ||
} | ||
}); // Set form field path | ||
}); // set form field path | ||
@@ -715,3 +771,3 @@ | ||
}); | ||
} // Set form field ID | ||
} // set form field ID | ||
@@ -721,3 +777,3 @@ | ||
this._formFieldRegistry.set(id, formField); | ||
this._formFieldRegistry.add(formField); | ||
@@ -883,3 +939,3 @@ if (components) { | ||
return htmls.join('\n\n'); | ||
} // See https://github.com/developit/snarkdown/issues/70 | ||
} // see https://github.com/developit/snarkdown/issues/70 | ||
@@ -1704,9 +1760,7 @@ function safeMarkdown(markdown) { | ||
clear() { | ||
// Clear form services | ||
this._emit('diagram.clear'); // Clear diagram services (e.g. EventBus) | ||
// clear form services | ||
this._emit('diagram.clear'); // clear diagram services (e.g. EventBus) | ||
this._emit('form.clear'); | ||
this.get('formFieldRegistry').clear(); | ||
} | ||
@@ -1720,4 +1774,4 @@ /** | ||
destroy() { | ||
// Destroy form services | ||
this.get('eventBus').fire('form.destroy'); // Destroy diagram services (e.g. EventBus) | ||
// destroy form services | ||
this.get('eventBus').fire('form.destroy'); // destroy diagram services (e.g. EventBus) | ||
@@ -1790,3 +1844,3 @@ this.get('eventBus').fire('diagram.destroy'); | ||
const data = Array.from(formFieldRegistry.values()).reduce((data, field) => { | ||
const data = formFieldRegistry.getAll().reduce((data, field) => { | ||
const { | ||
@@ -1838,3 +1892,3 @@ disabled, | ||
const errors = Array.from(formFieldRegistry.values()).reduce((errors, field) => { | ||
const errors = formFieldRegistry.getAll().reduce((errors, field) => { | ||
const { | ||
@@ -2053,3 +2107,3 @@ disabled, | ||
export { Button, Checkbox, Default, Form, FormComponent, FormContext, FormFields, FormRenderContext, Number, Radio, Select, Text, Textfield, clone, createForm, createFormContainer, createInjector, findErrors, formFields, generateIdForType, generateIndexForType, isRequired, pathParse, pathStringify, pathsEqual, schemaVersion }; | ||
export { Button, Checkbox, Default, Form, FormComponent, FormContext, FormFieldRegistry, FormFields, FormRenderContext, Number, Radio, Select, Text, Textfield, clone, createForm, createFormContainer, createInjector, findErrors, formFields, generateIdForType, generateIndexForType, isRequired, pathParse, pathStringify, pathsEqual, schemaVersion }; | ||
//# sourceMappingURL=index.es.js.map |
export {}; |
@@ -1,2 +0,15 @@ | ||
declare const Map: MapConstructor; | ||
export default Map; | ||
declare class FormFieldRegistry { | ||
constructor(eventBus: any); | ||
_eventBus: any; | ||
_formFields: {}; | ||
add(formField: any): void; | ||
remove(formField: any): void; | ||
get(id: any): any; | ||
getAll(): any[]; | ||
forEach(callback: any): void; | ||
clear(): void; | ||
} | ||
declare namespace FormFieldRegistry { | ||
const $inject: string[]; | ||
} | ||
export default FormFieldRegistry; |
@@ -0,1 +1,2 @@ | ||
export { FormFieldRegistry }; | ||
declare namespace _default { | ||
@@ -10,6 +11,7 @@ const __depends__: ({ | ||
const eventBus: any[]; | ||
const formFieldRegistry: (string | MapConstructor)[]; | ||
const formFieldRegistry: (string | typeof FormFieldRegistry)[]; | ||
const validator: (string | typeof Validator)[]; | ||
} | ||
export default _default; | ||
import FormFieldRegistry from "./FormFieldRegistry"; | ||
import Validator from "./Validator"; |
export default class Validator { | ||
validateField(field: any, value: any): any[]; | ||
} |
@@ -0,0 +0,0 @@ /** |
declare class Importer { | ||
/** | ||
* @constructor | ||
* @param { import('../core/FormFieldRegistry').default } formFieldRegistry | ||
* @param { import('../core').FormFieldRegistry } formFieldRegistry | ||
* @param { import('../render/FormFields').default } formFields | ||
*/ | ||
constructor(formFieldRegistry: Map<any, any>, formFields: import('../render/FormFields').default); | ||
_formFieldRegistry: Map<any, any>; | ||
constructor(formFieldRegistry: import('../core').FormFieldRegistry, formFields: import('../render/FormFields').default); | ||
_formFieldRegistry: import("../core").FormFieldRegistry; | ||
_formFields: import("../render/FormFields").default; | ||
@@ -10,0 +10,0 @@ /** |
@@ -0,0 +0,0 @@ declare namespace _default { |
@@ -12,2 +12,3 @@ /** | ||
export function createForm(options: CreateFormOptions): Promise<Form>; | ||
export { FormFieldRegistry } from "./core"; | ||
export * from "./render"; | ||
@@ -14,0 +15,0 @@ export * from "./util"; |
export default function Description(props: any): import("preact").JSX.Element; |
export default function Errors(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Button(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Checkbox(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Default(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Number(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Radio(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Select(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Text(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Textfield(props: any): import("preact").JSX.Element; |
export default function FormComponent(props: any): import("preact").JSX.Element; |
export default function FormField(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ export const formFields: (typeof Checkbox | typeof Default | typeof Text)[]; |
export default function Label(props: any): import("preact").JSX.Element; |
export default function PoweredBy(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export function formFieldClasses(type: any, errors?: any[]): string; |
@@ -0,0 +0,0 @@ export default FormContext; |
@@ -0,0 +0,0 @@ export default FormRenderContext; |
export { default as FormRenderContext } from "./FormRenderContext"; | ||
export { default as FormContext } from "./FormContext"; |
@@ -0,0 +0,0 @@ export default class FormFields { |
export default function _default(type: any, strict: any): any; |
@@ -0,0 +0,0 @@ export { FormFields }; |
@@ -0,0 +0,0 @@ /** |
@@ -23,3 +23,3 @@ import { Injector } from 'didi'; | ||
additionalModules?: Module[]; | ||
container?: Element | string; | ||
container?: Element | null | string; | ||
injector?: Injector; | ||
@@ -26,0 +26,0 @@ modules?: Module[]; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export function findErrors(errors: any, path: any): any; |
export function createInjector(bootstrapModules: any): any; |
{ | ||
"name": "@bpmn-io/form-js-viewer", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "View forms - powered by bpmn.io", | ||
@@ -53,3 +53,3 @@ "exports": { | ||
], | ||
"gitHead": "702e55edc23b70571ba1e3efd6372e160f5f33cd" | ||
"gitHead": "a59ff2f3a2643df7c4d4e025fde25c2d9f04953f" | ||
} |
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
314043
4247