@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 CHANGED
@@ -18,109 +18,6 @@ var Ids__default = /*#__PURE__*/_interopDefaultLegacy(Ids);
18
18
  var snarkdown__default = /*#__PURE__*/_interopDefaultLegacy(snarkdown);
19
19
  var Markup__default = /*#__PURE__*/_interopDefaultLegacy(Markup);
20
20
 
21
- function createInjector(bootstrapModules) {
22
- const modules = [],
23
- components = [];
24
-
25
- function hasModule(module) {
26
- return modules.includes(module);
27
- }
28
-
29
- function addModule(module) {
30
- modules.push(module);
31
- }
32
-
33
- function visit(module) {
34
- if (hasModule(module)) {
35
- return;
36
- }
37
-
38
- (module.__depends__ || []).forEach(visit);
39
-
40
- if (hasModule(module)) {
41
- return;
42
- }
43
-
44
- addModule(module);
45
- (module.__init__ || []).forEach(function (component) {
46
- components.push(component);
47
- });
48
- }
49
-
50
- bootstrapModules.forEach(visit);
51
- const injector = new didi.Injector(modules);
52
- components.forEach(function (component) {
53
- try {
54
- injector[typeof component === 'string' ? 'get' : 'invoke'](component);
55
- } catch (err) {
56
- console.error('Failed to instantiate component');
57
- console.error(err.stack);
58
- throw err;
59
- }
60
- });
61
- return injector;
62
- }
63
-
64
- /**
65
- * @param {string?} prefix
66
- *
67
- * @returns Element
68
- */
69
- function createFormContainer(prefix = 'fjs') {
70
- const container = document.createElement('div');
71
- container.classList.add(`${prefix}-container`);
72
- return container;
73
- }
74
-
75
- function findErrors(errors, path) {
76
- return errors[pathStringify(path)];
77
- }
78
- function isRequired(field) {
79
- return field.required;
80
- }
81
- function pathParse(path) {
82
- if (!path) {
83
- return [];
84
- }
85
-
86
- return path.split('.').map(key => {
87
- return isNaN(parseInt(key)) ? key : parseInt(key);
88
- });
89
- }
90
- function pathsEqual(a, b) {
91
- return a && b && a.length === b.length && a.every((value, index) => value === b[index]);
92
- }
93
- function pathStringify(path) {
94
- if (!path) {
95
- return '';
96
- }
97
-
98
- return path.join('.');
99
- }
100
- const indices = {};
101
- function generateIndexForType(type) {
102
- if (type in indices) {
103
- indices[type]++;
104
- } else {
105
- indices[type] = 1;
106
- }
107
-
108
- return indices[type];
109
- }
110
- function generateIdForType(type) {
111
- return `${type}${generateIndexForType(type)}`;
112
- }
113
- /**
114
- * @template T
115
- * @param {T} data
116
- * @param {(this: any, key: string, value: any) => any} [replacer]
117
- * @return {T}
118
- */
119
-
120
- function clone(data, replacer) {
121
- return JSON.parse(JSON.stringify(data, replacer));
122
- }
123
-
124
21
  var FN_REF = '__fn';
125
22
  var DEFAULT_PRIORITY = 1000;
126
23
  var slice = Array.prototype.slice;
@@ -634,6 +531,7 @@ class Validator {
634
531
  }
635
532
 
636
533
  }
534
+ Validator.$inject = [];
637
535
 
638
536
  class FormFieldRegistry {
639
537
  constructor(eventBus) {
@@ -699,6 +597,109 @@ class FormFieldRegistry {
699
597
  }
700
598
  FormFieldRegistry.$inject = ['eventBus'];
701
599
 
600
+ function createInjector(bootstrapModules) {
601
+ const modules = [],
602
+ components = [];
603
+
604
+ function hasModule(module) {
605
+ return modules.includes(module);
606
+ }
607
+
608
+ function addModule(module) {
609
+ modules.push(module);
610
+ }
611
+
612
+ function visit(module) {
613
+ if (hasModule(module)) {
614
+ return;
615
+ }
616
+
617
+ (module.__depends__ || []).forEach(visit);
618
+
619
+ if (hasModule(module)) {
620
+ return;
621
+ }
622
+
623
+ addModule(module);
624
+ (module.__init__ || []).forEach(function (component) {
625
+ components.push(component);
626
+ });
627
+ }
628
+
629
+ bootstrapModules.forEach(visit);
630
+ const injector = new didi.Injector(modules);
631
+ components.forEach(function (component) {
632
+ try {
633
+ injector[typeof component === 'string' ? 'get' : 'invoke'](component);
634
+ } catch (err) {
635
+ console.error('Failed to instantiate component');
636
+ console.error(err.stack);
637
+ throw err;
638
+ }
639
+ });
640
+ return injector;
641
+ }
642
+
643
+ /**
644
+ * @param {string?} prefix
645
+ *
646
+ * @returns Element
647
+ */
648
+ function createFormContainer(prefix = 'fjs') {
649
+ const container = document.createElement('div');
650
+ container.classList.add(`${prefix}-container`);
651
+ return container;
652
+ }
653
+
654
+ function findErrors(errors, path) {
655
+ return errors[pathStringify(path)];
656
+ }
657
+ function isRequired(field) {
658
+ return field.required;
659
+ }
660
+ function pathParse(path) {
661
+ if (!path) {
662
+ return [];
663
+ }
664
+
665
+ return path.split('.').map(key => {
666
+ return isNaN(parseInt(key)) ? key : parseInt(key);
667
+ });
668
+ }
669
+ function pathsEqual(a, b) {
670
+ return a && b && a.length === b.length && a.every((value, index) => value === b[index]);
671
+ }
672
+ function pathStringify(path) {
673
+ if (!path) {
674
+ return '';
675
+ }
676
+
677
+ return path.join('.');
678
+ }
679
+ const indices = {};
680
+ function generateIndexForType(type) {
681
+ if (type in indices) {
682
+ indices[type]++;
683
+ } else {
684
+ indices[type] = 1;
685
+ }
686
+
687
+ return indices[type];
688
+ }
689
+ function generateIdForType(type) {
690
+ return `${type}${generateIndexForType(type)}`;
691
+ }
692
+ /**
693
+ * @template T
694
+ * @param {T} data
695
+ * @param {(this: any, key: string, value: any) => any} [replacer]
696
+ * @return {T}
697
+ */
698
+
699
+ function clone(data, replacer) {
700
+ return JSON.parse(JSON.stringify(data, replacer));
701
+ }
702
+
702
703
  class Importer {
703
704
  /**
704
705
  * @constructor
@@ -1775,6 +1776,10 @@ var core = {
1775
1776
  * properties: FormProperties,
1776
1777
  * schema: Schema
1777
1778
  * } } State
1779
+ *
1780
+ * @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
1781
+ * @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
1782
+ * @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
1778
1783
  */
1779
1784
 
1780
1785
  const ids = new Ids__default['default']([32, 36, 1]);
@@ -1788,10 +1793,16 @@ class Form {
1788
1793
  * @param {FormOptions} options
1789
1794
  */
1790
1795
  constructor(options = {}) {
1796
+ /**
1797
+ * @public
1798
+ * @type {OnEventType}
1799
+ */
1800
+ this.on = this._onEvent;
1791
1801
  /**
1792
1802
  * @public
1793
1803
  * @type {String}
1794
1804
  */
1805
+
1795
1806
  this._id = ids.next();
1796
1807
  /**
1797
1808
  * @private
@@ -2038,16 +2049,6 @@ class Form {
2038
2049
  properties
2039
2050
  });
2040
2051
  }
2041
- /**
2042
- * @param {FormEvent} type
2043
- * @param {number} priority
2044
- * @param {Function} handler
2045
- */
2046
-
2047
-
2048
- on(type, priority, handler) {
2049
- this.get('eventBus').on(type, priority, handler);
2050
- }
2051
2052
  /**
2052
2053
  * @param {FormEvent} type
2053
2054
  * @param {Function} handler
@@ -2142,6 +2143,14 @@ class Form {
2142
2143
 
2143
2144
  this._emit('changed', this._getState());
2144
2145
  }
2146
+ /**
2147
+ * @internal
2148
+ */
2149
+
2150
+
2151
+ _onEvent(type, priority, handler) {
2152
+ this.get('eventBus').on(type, priority, handler);
2153
+ }
2145
2154
 
2146
2155
  }
2147
2156