@bpmn-io/form-js-viewer 0.7.0 → 0.7.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 +122 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +122 -113
- package/dist/index.es.js.map +1 -1
- package/dist/types/Form.d.ts +12 -6
- package/dist/types/core/Validator.d.ts +5 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -8,109 +8,6 @@ import Markup from 'preact-markup';
|
|
|
8
8
|
import { createPortal } from 'preact/compat';
|
|
9
9
|
import { Injector } from 'didi';
|
|
10
10
|
|
|
11
|
-
function createInjector(bootstrapModules) {
|
|
12
|
-
const modules = [],
|
|
13
|
-
components = [];
|
|
14
|
-
|
|
15
|
-
function hasModule(module) {
|
|
16
|
-
return modules.includes(module);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function addModule(module) {
|
|
20
|
-
modules.push(module);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function visit(module) {
|
|
24
|
-
if (hasModule(module)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
(module.__depends__ || []).forEach(visit);
|
|
29
|
-
|
|
30
|
-
if (hasModule(module)) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
addModule(module);
|
|
35
|
-
(module.__init__ || []).forEach(function (component) {
|
|
36
|
-
components.push(component);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
bootstrapModules.forEach(visit);
|
|
41
|
-
const injector = new Injector(modules);
|
|
42
|
-
components.forEach(function (component) {
|
|
43
|
-
try {
|
|
44
|
-
injector[typeof component === 'string' ? 'get' : 'invoke'](component);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error('Failed to instantiate component');
|
|
47
|
-
console.error(err.stack);
|
|
48
|
-
throw err;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return injector;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @param {string?} prefix
|
|
56
|
-
*
|
|
57
|
-
* @returns Element
|
|
58
|
-
*/
|
|
59
|
-
function createFormContainer(prefix = 'fjs') {
|
|
60
|
-
const container = document.createElement('div');
|
|
61
|
-
container.classList.add(`${prefix}-container`);
|
|
62
|
-
return container;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function findErrors(errors, path) {
|
|
66
|
-
return errors[pathStringify(path)];
|
|
67
|
-
}
|
|
68
|
-
function isRequired(field) {
|
|
69
|
-
return field.required;
|
|
70
|
-
}
|
|
71
|
-
function pathParse(path) {
|
|
72
|
-
if (!path) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return path.split('.').map(key => {
|
|
77
|
-
return isNaN(parseInt(key)) ? key : parseInt(key);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function pathsEqual(a, b) {
|
|
81
|
-
return a && b && a.length === b.length && a.every((value, index) => value === b[index]);
|
|
82
|
-
}
|
|
83
|
-
function pathStringify(path) {
|
|
84
|
-
if (!path) {
|
|
85
|
-
return '';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return path.join('.');
|
|
89
|
-
}
|
|
90
|
-
const indices = {};
|
|
91
|
-
function generateIndexForType(type) {
|
|
92
|
-
if (type in indices) {
|
|
93
|
-
indices[type]++;
|
|
94
|
-
} else {
|
|
95
|
-
indices[type] = 1;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return indices[type];
|
|
99
|
-
}
|
|
100
|
-
function generateIdForType(type) {
|
|
101
|
-
return `${type}${generateIndexForType(type)}`;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* @template T
|
|
105
|
-
* @param {T} data
|
|
106
|
-
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
107
|
-
* @return {T}
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
function clone(data, replacer) {
|
|
111
|
-
return JSON.parse(JSON.stringify(data, replacer));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
11
|
var FN_REF = '__fn';
|
|
115
12
|
var DEFAULT_PRIORITY = 1000;
|
|
116
13
|
var slice = Array.prototype.slice;
|
|
@@ -624,6 +521,7 @@ class Validator {
|
|
|
624
521
|
}
|
|
625
522
|
|
|
626
523
|
}
|
|
524
|
+
Validator.$inject = [];
|
|
627
525
|
|
|
628
526
|
class FormFieldRegistry {
|
|
629
527
|
constructor(eventBus) {
|
|
@@ -689,6 +587,109 @@ class FormFieldRegistry {
|
|
|
689
587
|
}
|
|
690
588
|
FormFieldRegistry.$inject = ['eventBus'];
|
|
691
589
|
|
|
590
|
+
function createInjector(bootstrapModules) {
|
|
591
|
+
const modules = [],
|
|
592
|
+
components = [];
|
|
593
|
+
|
|
594
|
+
function hasModule(module) {
|
|
595
|
+
return modules.includes(module);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function addModule(module) {
|
|
599
|
+
modules.push(module);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function visit(module) {
|
|
603
|
+
if (hasModule(module)) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
(module.__depends__ || []).forEach(visit);
|
|
608
|
+
|
|
609
|
+
if (hasModule(module)) {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
addModule(module);
|
|
614
|
+
(module.__init__ || []).forEach(function (component) {
|
|
615
|
+
components.push(component);
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
bootstrapModules.forEach(visit);
|
|
620
|
+
const injector = new Injector(modules);
|
|
621
|
+
components.forEach(function (component) {
|
|
622
|
+
try {
|
|
623
|
+
injector[typeof component === 'string' ? 'get' : 'invoke'](component);
|
|
624
|
+
} catch (err) {
|
|
625
|
+
console.error('Failed to instantiate component');
|
|
626
|
+
console.error(err.stack);
|
|
627
|
+
throw err;
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
return injector;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* @param {string?} prefix
|
|
635
|
+
*
|
|
636
|
+
* @returns Element
|
|
637
|
+
*/
|
|
638
|
+
function createFormContainer(prefix = 'fjs') {
|
|
639
|
+
const container = document.createElement('div');
|
|
640
|
+
container.classList.add(`${prefix}-container`);
|
|
641
|
+
return container;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function findErrors(errors, path) {
|
|
645
|
+
return errors[pathStringify(path)];
|
|
646
|
+
}
|
|
647
|
+
function isRequired(field) {
|
|
648
|
+
return field.required;
|
|
649
|
+
}
|
|
650
|
+
function pathParse(path) {
|
|
651
|
+
if (!path) {
|
|
652
|
+
return [];
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
return path.split('.').map(key => {
|
|
656
|
+
return isNaN(parseInt(key)) ? key : parseInt(key);
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
function pathsEqual(a, b) {
|
|
660
|
+
return a && b && a.length === b.length && a.every((value, index) => value === b[index]);
|
|
661
|
+
}
|
|
662
|
+
function pathStringify(path) {
|
|
663
|
+
if (!path) {
|
|
664
|
+
return '';
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
return path.join('.');
|
|
668
|
+
}
|
|
669
|
+
const indices = {};
|
|
670
|
+
function generateIndexForType(type) {
|
|
671
|
+
if (type in indices) {
|
|
672
|
+
indices[type]++;
|
|
673
|
+
} else {
|
|
674
|
+
indices[type] = 1;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return indices[type];
|
|
678
|
+
}
|
|
679
|
+
function generateIdForType(type) {
|
|
680
|
+
return `${type}${generateIndexForType(type)}`;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* @template T
|
|
684
|
+
* @param {T} data
|
|
685
|
+
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
686
|
+
* @return {T}
|
|
687
|
+
*/
|
|
688
|
+
|
|
689
|
+
function clone(data, replacer) {
|
|
690
|
+
return JSON.parse(JSON.stringify(data, replacer));
|
|
691
|
+
}
|
|
692
|
+
|
|
692
693
|
class Importer {
|
|
693
694
|
/**
|
|
694
695
|
* @constructor
|
|
@@ -1765,6 +1766,10 @@ var core = {
|
|
|
1765
1766
|
* properties: FormProperties,
|
|
1766
1767
|
* schema: Schema
|
|
1767
1768
|
* } } State
|
|
1769
|
+
*
|
|
1770
|
+
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
1771
|
+
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
1772
|
+
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
1768
1773
|
*/
|
|
1769
1774
|
|
|
1770
1775
|
const ids = new Ids([32, 36, 1]);
|
|
@@ -1778,10 +1783,16 @@ class Form {
|
|
|
1778
1783
|
* @param {FormOptions} options
|
|
1779
1784
|
*/
|
|
1780
1785
|
constructor(options = {}) {
|
|
1786
|
+
/**
|
|
1787
|
+
* @public
|
|
1788
|
+
* @type {OnEventType}
|
|
1789
|
+
*/
|
|
1790
|
+
this.on = this._onEvent;
|
|
1781
1791
|
/**
|
|
1782
1792
|
* @public
|
|
1783
1793
|
* @type {String}
|
|
1784
1794
|
*/
|
|
1795
|
+
|
|
1785
1796
|
this._id = ids.next();
|
|
1786
1797
|
/**
|
|
1787
1798
|
* @private
|
|
@@ -2028,16 +2039,6 @@ class Form {
|
|
|
2028
2039
|
properties
|
|
2029
2040
|
});
|
|
2030
2041
|
}
|
|
2031
|
-
/**
|
|
2032
|
-
* @param {FormEvent} type
|
|
2033
|
-
* @param {number} priority
|
|
2034
|
-
* @param {Function} handler
|
|
2035
|
-
*/
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
on(type, priority, handler) {
|
|
2039
|
-
this.get('eventBus').on(type, priority, handler);
|
|
2040
|
-
}
|
|
2041
2042
|
/**
|
|
2042
2043
|
* @param {FormEvent} type
|
|
2043
2044
|
* @param {Function} handler
|
|
@@ -2132,6 +2133,14 @@ class Form {
|
|
|
2132
2133
|
|
|
2133
2134
|
this._emit('changed', this._getState());
|
|
2134
2135
|
}
|
|
2136
|
+
/**
|
|
2137
|
+
* @internal
|
|
2138
|
+
*/
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
_onEvent(type, priority, handler) {
|
|
2142
|
+
this.get('eventBus').on(type, priority, handler);
|
|
2143
|
+
}
|
|
2135
2144
|
|
|
2136
2145
|
}
|
|
2137
2146
|
|