0.1.18 • Published 8 months ago
@pundima-lakshan/bpmn-form-extended v0.1.18
Acknowledgments
This is a fork from EinArlyn/bpmn-form-extended library to be used in my own project
bpmn-form-extended
The library is intended to expand the bpmn-js component base. Allows you to add custom components to the bpmn-js model.
Project structure
assets
css- folder with css filesfonts- font folderjs- folder with js filessvg- folder with svg files
custom components
components- folder with custom componentsproperties-panel- folder with custom property panelsindex.js- file for importing all custom components
form-js - overriding form-js library functions
base-form.js- overriding the basic functions of the form-js libraryform-editor.js- description and configuration of the form editorform-viewer.js- description and settings for viewing forms
How to add your own component
- Create a component folder in the
componentsfolder - Create a file
index.jsin the component folder - Implement the component in the
index.jsfile - Import the component into the
index.jsfile in thecustom/componentsfolder - Add a component class and register it
- Add a new component to
RenderExtension
How to add your own properties panel
- Create a properties panel folder in the
properties-panelfolder - Create a file
index.jsin the properties panel folder - Implement the properties panel in the
index.jsfile - Import the properties panel into the
index.jsfile in thecustom/properties-panelfolder - Add a property panel class and register it
- Add a new property panel to
PropertiesPanelExtension
How to add a library to a React + Vite project
- Install the library using npm
npm install @einarlyn/bpmn-form-extended- Importing css styles in a folder of your choice (example: main.js)
import "@einarlyn/bpmn-form-extended/dist/assets/css/styles.css";- Along the path
src/pluginswe create a fileminifyBundles.tsand place the following code in it
import { minify } from "terser";
const minifyBundles = () => {
return {
name: "minifyBundles",
async generateBundle(_options: any, bundle: any) {
for (const key in bundle) {
if (bundle[key].type === "chunk" && !key.includes("customFormEditor")) {
const minifyCode = await minify(bundle[key].code, {
sourceMap: false,
});
bundle[key].code = minifyCode.code;
} else if (
bundle[key].type === "chunk" &&
key.includes("customFormEditor")
) {
bundle[key].code = bundle[key].code.replaceAll(
"formFields2",
"formFields"
);
const minifyCode = await minify(bundle[key].code, {
mangle: {
reserved: ["RangeField", "formFields.register", "formFields"],
},
sourceMap: false,
});
bundle[key].code = minifyCode.code;
}
}
return bundle;
},
};
};
export default minifyBundles;- In the
vite.config.tsfile we add the propertyoptimizeDeps
optimizeDeps: {
exclude: [
'@einarlyn/bpmn-form-extended',
],
},- In the
vite.config.tsfile add theminifyBundlesplugin
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('bpmn-form-extended')) {
return 'customFormEditor';
}
return 'app';
},
},
plugins: [minifyBundles()],
},
minify: false,
},- Create type declarations in
decs.d.tsto stop typescript from complaining
declare module "@einarlyn/bpmn-form-extended";- Usage in React project
...
const formEditor = new FormEditor({
container: editorContainerRef.current,
// additionalModules: [RangeField, FileEditorField, RangeFieldPropertiesProvider],
}).customForm;
...Extended components and properties
Range
New range component
File Editor
Extend file input enabling to view uploaded files
Events
fileEditor.open - click on file editor icon
Input Field - custom property
Add option to include auto initialize options
0.1.18
8 months ago
0.1.17
8 months ago
0.1.15
8 months ago
0.1.14
8 months ago
0.1.13
8 months ago
0.1.12
8 months ago
0.1.11
8 months ago
0.1.10
8 months ago
0.1.9
8 months ago
0.1.8
8 months ago
0.1.7
8 months ago
0.1.6
8 months ago
0.1.5
9 months ago
0.1.4
9 months ago
0.1.3
9 months ago
0.1.2
9 months ago
0.1.1
9 months ago
0.1.0
9 months ago