1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | (function (global, factory) {
|
14 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
15 | typeof define === 'function' && define.amd ? define(factory) :
|
16 | (global = global || self, global.DmnJS = factory());
|
17 | }(this, (function () { 'use strict';
|
18 |
|
19 | function _typeof(obj) {
|
20 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
21 | _typeof = function (obj) {
|
22 | return typeof obj;
|
23 | };
|
24 | } else {
|
25 | _typeof = function (obj) {
|
26 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
27 | };
|
28 | }
|
29 |
|
30 | return _typeof(obj);
|
31 | }
|
32 |
|
33 | function _classCallCheck(instance, Constructor) {
|
34 | if (!(instance instanceof Constructor)) {
|
35 | throw new TypeError("Cannot call a class as a function");
|
36 | }
|
37 | }
|
38 |
|
39 | function _defineProperties(target, props) {
|
40 | for (var i = 0; i < props.length; i++) {
|
41 | var descriptor = props[i];
|
42 | descriptor.enumerable = descriptor.enumerable || false;
|
43 | descriptor.configurable = true;
|
44 | if ("value" in descriptor) descriptor.writable = true;
|
45 | Object.defineProperty(target, descriptor.key, descriptor);
|
46 | }
|
47 | }
|
48 |
|
49 | function _createClass(Constructor, protoProps, staticProps) {
|
50 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
51 | if (staticProps) _defineProperties(Constructor, staticProps);
|
52 | return Constructor;
|
53 | }
|
54 |
|
55 | function _inherits(subClass, superClass) {
|
56 | if (typeof superClass !== "function" && superClass !== null) {
|
57 | throw new TypeError("Super expression must either be null or a function");
|
58 | }
|
59 |
|
60 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
61 | constructor: {
|
62 | value: subClass,
|
63 | writable: true,
|
64 | configurable: true
|
65 | }
|
66 | });
|
67 | if (superClass) _setPrototypeOf(subClass, superClass);
|
68 | }
|
69 |
|
70 | function _getPrototypeOf(o) {
|
71 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
72 | return o.__proto__ || Object.getPrototypeOf(o);
|
73 | };
|
74 | return _getPrototypeOf(o);
|
75 | }
|
76 |
|
77 | function _setPrototypeOf(o, p) {
|
78 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
79 | o.__proto__ = p;
|
80 | return o;
|
81 | };
|
82 |
|
83 | return _setPrototypeOf(o, p);
|
84 | }
|
85 |
|
86 | function _assertThisInitialized(self) {
|
87 | if (self === void 0) {
|
88 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
89 | }
|
90 |
|
91 | return self;
|
92 | }
|
93 |
|
94 | function _possibleConstructorReturn(self, call) {
|
95 | if (call && (typeof call === "object" || typeof call === "function")) {
|
96 | return call;
|
97 | }
|
98 |
|
99 | return _assertThisInitialized(self);
|
100 | }
|
101 |
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | var nativeToString = Object.prototype.toString;
|
111 | var nativeHasOwnProperty = Object.prototype.hasOwnProperty;
|
112 |
|
113 | function isUndefined(obj) {
|
114 | return obj === undefined;
|
115 | }
|
116 |
|
117 | function isDefined(obj) {
|
118 | return obj !== undefined;
|
119 | }
|
120 |
|
121 | function isArray(obj) {
|
122 | return nativeToString.call(obj) === '[object Array]';
|
123 | }
|
124 |
|
125 | function isObject(obj) {
|
126 | return nativeToString.call(obj) === '[object Object]';
|
127 | }
|
128 |
|
129 | function isNumber(obj) {
|
130 | return nativeToString.call(obj) === '[object Number]';
|
131 | }
|
132 |
|
133 | function isFunction(obj) {
|
134 | var tag = nativeToString.call(obj);
|
135 | return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object AsyncGeneratorFunction]' || tag === '[object Proxy]';
|
136 | }
|
137 |
|
138 | function isString(obj) {
|
139 | return nativeToString.call(obj) === '[object String]';
|
140 | }
|
141 | |
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | function has(target, key) {
|
152 | return nativeHasOwnProperty.call(target, key);
|
153 | }
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | function find(collection, matcher) {
|
165 | matcher = toMatcher(matcher);
|
166 | var match;
|
167 | forEach(collection, function (val, key) {
|
168 | if (matcher(val, key)) {
|
169 | match = val;
|
170 | return false;
|
171 | }
|
172 | });
|
173 | return match;
|
174 | }
|
175 | |
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 | function filter(collection, matcher) {
|
186 | var result = [];
|
187 | forEach(collection, function (val, key) {
|
188 | if (matcher(val, key)) {
|
189 | result.push(val);
|
190 | }
|
191 | });
|
192 | return result;
|
193 | }
|
194 | |
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 | function forEach(collection, iterator) {
|
206 | var val, result;
|
207 |
|
208 | if (isUndefined(collection)) {
|
209 | return;
|
210 | }
|
211 |
|
212 | var convertKey = isArray(collection) ? toNum : identity;
|
213 |
|
214 | for (var key in collection) {
|
215 | if (has(collection, key)) {
|
216 | val = collection[key];
|
217 | result = iterator(val, convertKey(key));
|
218 |
|
219 | if (result === false) {
|
220 | return val;
|
221 | }
|
222 | }
|
223 | }
|
224 | }
|
225 | |
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 | function reduce(collection, iterator, result) {
|
237 | forEach(collection, function (value, idx) {
|
238 | result = iterator(result, value, idx);
|
239 | });
|
240 | return result;
|
241 | }
|
242 | |
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 | function every(collection, matcher) {
|
254 | return !!reduce(collection, function (matches, val, key) {
|
255 | return matches && matcher(val, key);
|
256 | }, true);
|
257 | }
|
258 | |
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | function map(collection, fn) {
|
270 | var result = [];
|
271 | forEach(collection, function (val, key) {
|
272 | result.push(fn(val, key));
|
273 | });
|
274 | return result;
|
275 | }
|
276 | |
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 | function matchPattern(pattern) {
|
292 | return function (el) {
|
293 | return every(pattern, function (val, key) {
|
294 | return el[key] === val;
|
295 | });
|
296 | };
|
297 | }
|
298 |
|
299 | function toMatcher(matcher) {
|
300 | return isFunction(matcher) ? matcher : function (e) {
|
301 | return e === matcher;
|
302 | };
|
303 | }
|
304 |
|
305 | function identity(arg) {
|
306 | return arg;
|
307 | }
|
308 |
|
309 | function toNum(arg) {
|
310 | return Number(arg);
|
311 | }
|
312 | |
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 | function debounce(fn, timeout) {
|
324 | var timer;
|
325 | var lastArgs;
|
326 | var lastThis;
|
327 | var lastNow;
|
328 |
|
329 | function fire() {
|
330 | var now = Date.now();
|
331 | var scheduledDiff = lastNow + timeout - now;
|
332 |
|
333 | if (scheduledDiff > 0) {
|
334 | return schedule(scheduledDiff);
|
335 | }
|
336 |
|
337 | fn.apply(lastThis, lastArgs);
|
338 | timer = lastNow = lastArgs = lastThis = undefined;
|
339 | }
|
340 |
|
341 | function schedule(timeout) {
|
342 | timer = setTimeout(fire, timeout);
|
343 | }
|
344 |
|
345 | return function () {
|
346 | lastNow = Date.now();
|
347 |
|
348 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
349 | args[_key] = arguments[_key];
|
350 | }
|
351 |
|
352 | lastArgs = args;
|
353 | lastThis = this;
|
354 |
|
355 | if (!timer) {
|
356 | schedule(timeout);
|
357 | }
|
358 | };
|
359 | }
|
360 | |
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 | function bind(fn, target) {
|
371 | return fn.bind(target);
|
372 | }
|
373 |
|
374 | function _extends() {
|
375 | _extends = Object.assign || function (target) {
|
376 | for (var i = 1; i < arguments.length; i++) {
|
377 | var source = arguments[i];
|
378 |
|
379 | for (var key in source) {
|
380 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
381 | target[key] = source[key];
|
382 | }
|
383 | }
|
384 | }
|
385 |
|
386 | return target;
|
387 | };
|
388 |
|
389 | return _extends.apply(this, arguments);
|
390 | }
|
391 | |
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 | function assign(target) {
|
402 | for (var _len = arguments.length, others = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
403 | others[_key - 1] = arguments[_key];
|
404 | }
|
405 |
|
406 | return _extends.apply(void 0, [target].concat(others));
|
407 | }
|
408 | |
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 | function pick(target, properties) {
|
419 | var result = {};
|
420 | var obj = Object(target);
|
421 | forEach(properties, function (prop) {
|
422 | if (prop in obj) {
|
423 | result[prop] = target[prop];
|
424 | }
|
425 | });
|
426 | return result;
|
427 | }
|
428 |
|
429 | var FN_REF = '__fn';
|
430 | var DEFAULT_PRIORITY = 1000;
|
431 | var slice = Array.prototype.slice;
|
432 | |
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 | function EventBus() {
|
517 | this._listeners = {};
|
518 |
|
519 |
|
520 | this.on('diagram.destroy', 1, this._destroy, this);
|
521 | }
|
522 | |
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 | EventBus.prototype.on = function (events, priority, callback, that) {
|
541 | events = isArray(events) ? events : [events];
|
542 |
|
543 | if (isFunction(priority)) {
|
544 | that = callback;
|
545 | callback = priority;
|
546 | priority = DEFAULT_PRIORITY;
|
547 | }
|
548 |
|
549 | if (!isNumber(priority)) {
|
550 | throw new Error('priority must be a number');
|
551 | }
|
552 |
|
553 | var actualCallback = callback;
|
554 |
|
555 | if (that) {
|
556 | actualCallback = bind(callback, that);
|
557 |
|
558 |
|
559 |
|
560 | actualCallback[FN_REF] = callback[FN_REF] || callback;
|
561 | }
|
562 |
|
563 | var self = this;
|
564 | events.forEach(function (e) {
|
565 | self._addListener(e, {
|
566 | priority: priority,
|
567 | callback: actualCallback,
|
568 | next: null
|
569 | });
|
570 | });
|
571 | };
|
572 | |
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 | EventBus.prototype.once = function (event, priority, callback, that) {
|
583 | var self = this;
|
584 |
|
585 | if (isFunction(priority)) {
|
586 | that = callback;
|
587 | callback = priority;
|
588 | priority = DEFAULT_PRIORITY;
|
589 | }
|
590 |
|
591 | if (!isNumber(priority)) {
|
592 | throw new Error('priority must be a number');
|
593 | }
|
594 |
|
595 | function wrappedCallback() {
|
596 | var result = callback.apply(that, arguments);
|
597 | self.off(event, wrappedCallback);
|
598 | return result;
|
599 | }
|
600 |
|
601 |
|
602 |
|
603 |
|
604 | wrappedCallback[FN_REF] = callback;
|
605 | this.on(event, priority, wrappedCallback);
|
606 | };
|
607 | |
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 | EventBus.prototype.off = function (events, callback) {
|
618 | events = isArray(events) ? events : [events];
|
619 | var self = this;
|
620 | events.forEach(function (event) {
|
621 | self._removeListener(event, callback);
|
622 | });
|
623 | };
|
624 | |
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 | EventBus.prototype.createEvent = function (data) {
|
634 | var event = new InternalEvent();
|
635 | event.init(data);
|
636 | return event;
|
637 | };
|
638 | |
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 | EventBus.prototype.fire = function (type, data) {
|
671 | var event, firstListener, returnValue, args;
|
672 | args = slice.call(arguments);
|
673 |
|
674 | if (_typeof(type) === 'object') {
|
675 | data = type;
|
676 | type = data.type;
|
677 | }
|
678 |
|
679 | if (!type) {
|
680 | throw new Error('no event type specified');
|
681 | }
|
682 |
|
683 | firstListener = this._listeners[type];
|
684 |
|
685 | if (!firstListener) {
|
686 | return;
|
687 | }
|
688 |
|
689 |
|
690 |
|
691 | if (data instanceof InternalEvent) {
|
692 |
|
693 | event = data;
|
694 | } else {
|
695 | event = this.createEvent(data);
|
696 | }
|
697 |
|
698 |
|
699 | args[0] = event;
|
700 |
|
701 | var originalType = event.type;
|
702 |
|
703 | if (type !== originalType) {
|
704 | event.type = type;
|
705 | }
|
706 |
|
707 | try {
|
708 | returnValue = this._invokeListeners(event, args, firstListener);
|
709 | } finally {
|
710 |
|
711 | if (type !== originalType) {
|
712 | event.type = originalType;
|
713 | }
|
714 | }
|
715 |
|
716 |
|
717 |
|
718 | if (returnValue === undefined && event.defaultPrevented) {
|
719 | returnValue = false;
|
720 | }
|
721 |
|
722 | return returnValue;
|
723 | };
|
724 |
|
725 | EventBus.prototype.handleError = function (error) {
|
726 | return this.fire('error', {
|
727 | error: error
|
728 | }) === false;
|
729 | };
|
730 |
|
731 | EventBus.prototype._destroy = function () {
|
732 | this._listeners = {};
|
733 | };
|
734 |
|
735 | EventBus.prototype._invokeListeners = function (event, args, listener) {
|
736 | var returnValue;
|
737 |
|
738 | while (listener) {
|
739 |
|
740 | if (event.cancelBubble) {
|
741 | break;
|
742 | }
|
743 |
|
744 | returnValue = this._invokeListener(event, args, listener);
|
745 | listener = listener.next;
|
746 | }
|
747 |
|
748 | return returnValue;
|
749 | };
|
750 |
|
751 | EventBus.prototype._invokeListener = function (event, args, listener) {
|
752 | var returnValue;
|
753 |
|
754 | try {
|
755 |
|
756 | returnValue = invokeFunction(listener.callback, args);
|
757 |
|
758 | if (returnValue !== undefined) {
|
759 | event.returnValue = returnValue;
|
760 | event.stopPropagation();
|
761 | }
|
762 |
|
763 |
|
764 | if (returnValue === false) {
|
765 | event.preventDefault();
|
766 | }
|
767 | } catch (e) {
|
768 | if (!this.handleError(e)) {
|
769 | console.error('unhandled error in event listener');
|
770 | console.error(e.stack);
|
771 | throw e;
|
772 | }
|
773 | }
|
774 |
|
775 | return returnValue;
|
776 | };
|
777 | |
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 | EventBus.prototype._addListener = function (event, newListener) {
|
796 | var listener = this._getListeners(event),
|
797 | previousListener;
|
798 |
|
799 |
|
800 | if (!listener) {
|
801 | this._setListeners(event, newListener);
|
802 |
|
803 | return;
|
804 | }
|
805 |
|
806 |
|
807 |
|
808 | while (listener) {
|
809 | if (listener.priority < newListener.priority) {
|
810 | newListener.next = listener;
|
811 |
|
812 | if (previousListener) {
|
813 | previousListener.next = newListener;
|
814 | } else {
|
815 | this._setListeners(event, newListener);
|
816 | }
|
817 |
|
818 | return;
|
819 | }
|
820 |
|
821 | previousListener = listener;
|
822 | listener = listener.next;
|
823 | }
|
824 |
|
825 |
|
826 | previousListener.next = newListener;
|
827 | };
|
828 |
|
829 | EventBus.prototype._getListeners = function (name) {
|
830 | return this._listeners[name];
|
831 | };
|
832 |
|
833 | EventBus.prototype._setListeners = function (name, listener) {
|
834 | this._listeners[name] = listener;
|
835 | };
|
836 |
|
837 | EventBus.prototype._removeListener = function (event, callback) {
|
838 | var listener = this._getListeners(event),
|
839 | nextListener,
|
840 | previousListener,
|
841 | listenerCallback;
|
842 |
|
843 | if (!callback) {
|
844 |
|
845 | this._setListeners(event, null);
|
846 |
|
847 | return;
|
848 | }
|
849 |
|
850 | while (listener) {
|
851 | nextListener = listener.next;
|
852 | listenerCallback = listener.callback;
|
853 |
|
854 | if (listenerCallback === callback || listenerCallback[FN_REF] === callback) {
|
855 | if (previousListener) {
|
856 | previousListener.next = nextListener;
|
857 | } else {
|
858 |
|
859 | this._setListeners(event, nextListener);
|
860 | }
|
861 | }
|
862 |
|
863 | previousListener = listener;
|
864 | listener = nextListener;
|
865 | }
|
866 | };
|
867 | |
868 |
|
869 |
|
870 |
|
871 |
|
872 | function InternalEvent() {}
|
873 |
|
874 | InternalEvent.prototype.stopPropagation = function () {
|
875 | this.cancelBubble = true;
|
876 | };
|
877 |
|
878 | InternalEvent.prototype.preventDefault = function () {
|
879 | this.defaultPrevented = true;
|
880 | };
|
881 |
|
882 | InternalEvent.prototype.init = function (data) {
|
883 | assign(this, data || {});
|
884 | };
|
885 | |
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 | function invokeFunction(fn, args) {
|
896 | return fn.apply(null, args);
|
897 | }
|
898 |
|
899 | |
900 |
|
901 |
|
902 |
|
903 | function Base() {}
|
904 |
|
905 | Base.prototype.get = function (name) {
|
906 | return this.$model.properties.get(this, name);
|
907 | };
|
908 |
|
909 | Base.prototype.set = function (name, value) {
|
910 | this.$model.properties.set(this, name, value);
|
911 | };
|
912 | |
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 | function Factory(model, properties) {
|
921 | this.model = model;
|
922 | this.properties = properties;
|
923 | }
|
924 |
|
925 | Factory.prototype.createType = function (descriptor) {
|
926 | var model = this.model;
|
927 | var props = this.properties,
|
928 | prototype = Object.create(Base.prototype);
|
929 |
|
930 | forEach(descriptor.properties, function (p) {
|
931 | if (!p.isMany && p["default"] !== undefined) {
|
932 | prototype[p.name] = p["default"];
|
933 | }
|
934 | });
|
935 | props.defineModel(prototype, model);
|
936 | props.defineDescriptor(prototype, descriptor);
|
937 | var name = descriptor.ns.name;
|
938 | |
939 |
|
940 |
|
941 |
|
942 | function ModdleElement(attrs) {
|
943 | props.define(this, '$type', {
|
944 | value: name,
|
945 | enumerable: true
|
946 | });
|
947 | props.define(this, '$attrs', {
|
948 | value: {}
|
949 | });
|
950 | props.define(this, '$parent', {
|
951 | writable: true
|
952 | });
|
953 | forEach(attrs, bind(function (val, key) {
|
954 | this.set(key, val);
|
955 | }, this));
|
956 | }
|
957 |
|
958 | ModdleElement.prototype = prototype;
|
959 | ModdleElement.hasType = prototype.$instanceOf = this.model.hasType;
|
960 |
|
961 | props.defineModel(ModdleElement, model);
|
962 | props.defineDescriptor(ModdleElement, descriptor);
|
963 | return ModdleElement;
|
964 | };
|
965 | |
966 |
|
967 |
|
968 |
|
969 |
|
970 | var BUILTINS = {
|
971 | String: true,
|
972 | Boolean: true,
|
973 | Integer: true,
|
974 | Real: true,
|
975 | Element: true
|
976 | };
|
977 | |
978 |
|
979 |
|
980 |
|
981 | var TYPE_CONVERTERS = {
|
982 | String: function String(s) {
|
983 | return s;
|
984 | },
|
985 | Boolean: function Boolean(s) {
|
986 | return s === 'true';
|
987 | },
|
988 | Integer: function Integer(s) {
|
989 | return parseInt(s, 10);
|
990 | },
|
991 | Real: function Real(s) {
|
992 | return parseFloat(s, 10);
|
993 | }
|
994 | };
|
995 | |
996 |
|
997 |
|
998 |
|
999 | function coerceType(type, value) {
|
1000 | var converter = TYPE_CONVERTERS[type];
|
1001 |
|
1002 | if (converter) {
|
1003 | return converter(value);
|
1004 | } else {
|
1005 | return value;
|
1006 | }
|
1007 | }
|
1008 | |
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 | function isBuiltIn(type) {
|
1014 | return !!BUILTINS[type];
|
1015 | }
|
1016 | |
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 | function isSimple(type) {
|
1022 | return !!TYPE_CONVERTERS[type];
|
1023 | }
|
1024 | |
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 | function parseName(name, defaultPrefix) {
|
1036 | var parts = name.split(/:/),
|
1037 | localName,
|
1038 | prefix;
|
1039 |
|
1040 | if (parts.length === 1) {
|
1041 | localName = name;
|
1042 | prefix = defaultPrefix;
|
1043 | } else
|
1044 | if (parts.length === 2) {
|
1045 | localName = parts[1];
|
1046 | prefix = parts[0];
|
1047 | } else {
|
1048 | throw new Error('expected <prefix:localName> or <localName>, got ' + name);
|
1049 | }
|
1050 |
|
1051 | name = (prefix ? prefix + ':' : '') + localName;
|
1052 | return {
|
1053 | name: name,
|
1054 | prefix: prefix,
|
1055 | localName: localName
|
1056 | };
|
1057 | }
|
1058 | |
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 | function DescriptorBuilder(nameNs) {
|
1064 | this.ns = nameNs;
|
1065 | this.name = nameNs.name;
|
1066 | this.allTypes = [];
|
1067 | this.allTypesByName = {};
|
1068 | this.properties = [];
|
1069 | this.propertiesByName = {};
|
1070 | }
|
1071 |
|
1072 | DescriptorBuilder.prototype.build = function () {
|
1073 | return pick(this, ['ns', 'name', 'allTypes', 'allTypesByName', 'properties', 'propertiesByName', 'bodyProperty', 'idProperty']);
|
1074 | };
|
1075 | |
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 | DescriptorBuilder.prototype.addProperty = function (p, idx, validate) {
|
1085 | if (typeof idx === 'boolean') {
|
1086 | validate = idx;
|
1087 | idx = undefined;
|
1088 | }
|
1089 |
|
1090 | this.addNamedProperty(p, validate !== false);
|
1091 | var properties = this.properties;
|
1092 |
|
1093 | if (idx !== undefined) {
|
1094 | properties.splice(idx, 0, p);
|
1095 | } else {
|
1096 | properties.push(p);
|
1097 | }
|
1098 | };
|
1099 |
|
1100 | DescriptorBuilder.prototype.replaceProperty = function (oldProperty, newProperty, replace) {
|
1101 | var oldNameNs = oldProperty.ns;
|
1102 | var props = this.properties,
|
1103 | propertiesByName = this.propertiesByName,
|
1104 | rename = oldProperty.name !== newProperty.name;
|
1105 |
|
1106 | if (oldProperty.isId) {
|
1107 | if (!newProperty.isId) {
|
1108 | throw new Error('property <' + newProperty.ns.name + '> must be id property ' + 'to refine <' + oldProperty.ns.name + '>');
|
1109 | }
|
1110 |
|
1111 | this.setIdProperty(newProperty, false);
|
1112 | }
|
1113 |
|
1114 | if (oldProperty.isBody) {
|
1115 | if (!newProperty.isBody) {
|
1116 | throw new Error('property <' + newProperty.ns.name + '> must be body property ' + 'to refine <' + oldProperty.ns.name + '>');
|
1117 | }
|
1118 |
|
1119 |
|
1120 | this.setBodyProperty(newProperty, false);
|
1121 | }
|
1122 |
|
1123 |
|
1124 | var idx = props.indexOf(oldProperty);
|
1125 |
|
1126 | if (idx === -1) {
|
1127 | throw new Error('property <' + oldNameNs.name + '> not found in property list');
|
1128 | }
|
1129 |
|
1130 |
|
1131 | props.splice(idx, 1);
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 | this.addProperty(newProperty, replace ? undefined : idx, rename);
|
1138 |
|
1139 | propertiesByName[oldNameNs.name] = propertiesByName[oldNameNs.localName] = newProperty;
|
1140 | };
|
1141 |
|
1142 | DescriptorBuilder.prototype.redefineProperty = function (p, targetPropertyName, replace) {
|
1143 | var nsPrefix = p.ns.prefix;
|
1144 | var parts = targetPropertyName.split('#');
|
1145 | var name = parseName(parts[0], nsPrefix);
|
1146 | var attrName = parseName(parts[1], name.prefix).name;
|
1147 | var redefinedProperty = this.propertiesByName[attrName];
|
1148 |
|
1149 | if (!redefinedProperty) {
|
1150 | throw new Error('refined property <' + attrName + '> not found');
|
1151 | } else {
|
1152 | this.replaceProperty(redefinedProperty, p, replace);
|
1153 | }
|
1154 |
|
1155 | delete p.redefines;
|
1156 | };
|
1157 |
|
1158 | DescriptorBuilder.prototype.addNamedProperty = function (p, validate) {
|
1159 | var ns = p.ns,
|
1160 | propsByName = this.propertiesByName;
|
1161 |
|
1162 | if (validate) {
|
1163 | this.assertNotDefined(p, ns.name);
|
1164 | this.assertNotDefined(p, ns.localName);
|
1165 | }
|
1166 |
|
1167 | propsByName[ns.name] = propsByName[ns.localName] = p;
|
1168 | };
|
1169 |
|
1170 | DescriptorBuilder.prototype.removeNamedProperty = function (p) {
|
1171 | var ns = p.ns,
|
1172 | propsByName = this.propertiesByName;
|
1173 | delete propsByName[ns.name];
|
1174 | delete propsByName[ns.localName];
|
1175 | };
|
1176 |
|
1177 | DescriptorBuilder.prototype.setBodyProperty = function (p, validate) {
|
1178 | if (validate && this.bodyProperty) {
|
1179 | throw new Error('body property defined multiple times ' + '(<' + this.bodyProperty.ns.name + '>, <' + p.ns.name + '>)');
|
1180 | }
|
1181 |
|
1182 | this.bodyProperty = p;
|
1183 | };
|
1184 |
|
1185 | DescriptorBuilder.prototype.setIdProperty = function (p, validate) {
|
1186 | if (validate && this.idProperty) {
|
1187 | throw new Error('id property defined multiple times ' + '(<' + this.idProperty.ns.name + '>, <' + p.ns.name + '>)');
|
1188 | }
|
1189 |
|
1190 | this.idProperty = p;
|
1191 | };
|
1192 |
|
1193 | DescriptorBuilder.prototype.assertNotDefined = function (p, name) {
|
1194 | var propertyName = p.name,
|
1195 | definedProperty = this.propertiesByName[propertyName];
|
1196 |
|
1197 | if (definedProperty) {
|
1198 | throw new Error('property <' + propertyName + '> already defined; ' + 'override of <' + definedProperty.definedBy.ns.name + '#' + definedProperty.ns.name + '> by ' + '<' + p.definedBy.ns.name + '#' + p.ns.name + '> not allowed without redefines');
|
1199 | }
|
1200 | };
|
1201 |
|
1202 | DescriptorBuilder.prototype.hasProperty = function (name) {
|
1203 | return this.propertiesByName[name];
|
1204 | };
|
1205 |
|
1206 | DescriptorBuilder.prototype.addTrait = function (t, inherited) {
|
1207 | var typesByName = this.allTypesByName,
|
1208 | types = this.allTypes;
|
1209 | var typeName = t.name;
|
1210 |
|
1211 | if (typeName in typesByName) {
|
1212 | return;
|
1213 | }
|
1214 |
|
1215 | forEach(t.properties, bind(function (p) {
|
1216 |
|
1217 | p = assign({}, p, {
|
1218 | name: p.ns.localName,
|
1219 | inherited: inherited
|
1220 | });
|
1221 | Object.defineProperty(p, 'definedBy', {
|
1222 | value: t
|
1223 | });
|
1224 | var replaces = p.replaces,
|
1225 | redefines = p.redefines;
|
1226 |
|
1227 | if (replaces || redefines) {
|
1228 | this.redefineProperty(p, replaces || redefines, replaces);
|
1229 | } else {
|
1230 | if (p.isBody) {
|
1231 | this.setBodyProperty(p);
|
1232 | }
|
1233 |
|
1234 | if (p.isId) {
|
1235 | this.setIdProperty(p);
|
1236 | }
|
1237 |
|
1238 | this.addProperty(p);
|
1239 | }
|
1240 | }, this));
|
1241 | types.push(t);
|
1242 | typesByName[typeName] = t;
|
1243 | };
|
1244 | |
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 | function Registry(packages, properties) {
|
1253 | this.packageMap = {};
|
1254 | this.typeMap = {};
|
1255 | this.packages = [];
|
1256 | this.properties = properties;
|
1257 | forEach(packages, bind(this.registerPackage, this));
|
1258 | }
|
1259 |
|
1260 | Registry.prototype.getPackage = function (uriOrPrefix) {
|
1261 | return this.packageMap[uriOrPrefix];
|
1262 | };
|
1263 |
|
1264 | Registry.prototype.getPackages = function () {
|
1265 | return this.packages;
|
1266 | };
|
1267 |
|
1268 | Registry.prototype.registerPackage = function (pkg) {
|
1269 |
|
1270 | pkg = assign({}, pkg);
|
1271 | var pkgMap = this.packageMap;
|
1272 | ensureAvailable(pkgMap, pkg, 'prefix');
|
1273 | ensureAvailable(pkgMap, pkg, 'uri');
|
1274 |
|
1275 | forEach(pkg.types, bind(function (descriptor) {
|
1276 | this.registerType(descriptor, pkg);
|
1277 | }, this));
|
1278 | pkgMap[pkg.uri] = pkgMap[pkg.prefix] = pkg;
|
1279 | this.packages.push(pkg);
|
1280 | };
|
1281 | |
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 | Registry.prototype.registerType = function (type, pkg) {
|
1287 | type = assign({}, type, {
|
1288 | superClass: (type.superClass || []).slice(),
|
1289 | "extends": (type["extends"] || []).slice(),
|
1290 | properties: (type.properties || []).slice(),
|
1291 | meta: assign(type.meta || {})
|
1292 | });
|
1293 | var ns = parseName(type.name, pkg.prefix),
|
1294 | name = ns.name,
|
1295 | propertiesByName = {};
|
1296 |
|
1297 | forEach(type.properties, bind(function (p) {
|
1298 |
|
1299 | var propertyNs = parseName(p.name, ns.prefix),
|
1300 | propertyName = propertyNs.name;
|
1301 |
|
1302 | if (!isBuiltIn(p.type)) {
|
1303 | p.type = parseName(p.type, propertyNs.prefix).name;
|
1304 | }
|
1305 |
|
1306 | assign(p, {
|
1307 | ns: propertyNs,
|
1308 | name: propertyName
|
1309 | });
|
1310 | propertiesByName[propertyName] = p;
|
1311 | }, this));
|
1312 |
|
1313 | assign(type, {
|
1314 | ns: ns,
|
1315 | name: name,
|
1316 | propertiesByName: propertiesByName
|
1317 | });
|
1318 | forEach(type["extends"], bind(function (extendsName) {
|
1319 | var extended = this.typeMap[extendsName];
|
1320 | extended.traits = extended.traits || [];
|
1321 | extended.traits.push(name);
|
1322 | }, this));
|
1323 |
|
1324 | this.definePackage(type, pkg);
|
1325 |
|
1326 | this.typeMap[name] = type;
|
1327 | };
|
1328 | |
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 | Registry.prototype.mapTypes = function (nsName, iterator, trait) {
|
1340 | var type = isBuiltIn(nsName.name) ? {
|
1341 | name: nsName.name
|
1342 | } : this.typeMap[nsName.name];
|
1343 | var self = this;
|
1344 | |
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 | function traverseTrait(cls) {
|
1351 | return traverseSuper(cls, true);
|
1352 | }
|
1353 | |
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 | function traverseSuper(cls, trait) {
|
1362 | var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
|
1363 | self.mapTypes(parentNs, iterator, trait);
|
1364 | }
|
1365 |
|
1366 | if (!type) {
|
1367 | throw new Error('unknown type <' + nsName.name + '>');
|
1368 | }
|
1369 |
|
1370 | forEach(type.superClass, trait ? traverseTrait : traverseSuper);
|
1371 |
|
1372 | iterator(type, !trait);
|
1373 | forEach(type.traits, traverseTrait);
|
1374 | };
|
1375 | |
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 | Registry.prototype.getEffectiveDescriptor = function (name) {
|
1385 | var nsName = parseName(name);
|
1386 | var builder = new DescriptorBuilder(nsName);
|
1387 | this.mapTypes(nsName, function (type, inherited) {
|
1388 | builder.addTrait(type, inherited);
|
1389 | });
|
1390 | var descriptor = builder.build();
|
1391 |
|
1392 | this.definePackage(descriptor, descriptor.allTypes[descriptor.allTypes.length - 1].$pkg);
|
1393 | return descriptor;
|
1394 | };
|
1395 |
|
1396 | Registry.prototype.definePackage = function (target, pkg) {
|
1397 | this.properties.define(target, '$pkg', {
|
1398 | value: pkg
|
1399 | });
|
1400 | };
|
1401 |
|
1402 |
|
1403 | function ensureAvailable(packageMap, pkg, identifierKey) {
|
1404 | var value = pkg[identifierKey];
|
1405 |
|
1406 | if (value in packageMap) {
|
1407 | throw new Error('package with ' + identifierKey + ' <' + value + '> already defined');
|
1408 | }
|
1409 | }
|
1410 | |
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 | function Properties(model) {
|
1418 | this.model = model;
|
1419 | }
|
1420 | |
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 | Properties.prototype.set = function (target, name, value) {
|
1431 | var property = this.model.getPropertyDescriptor(target, name);
|
1432 | var propertyName = property && property.name;
|
1433 |
|
1434 | if (isUndefined$1(value)) {
|
1435 |
|
1436 |
|
1437 | if (property) {
|
1438 | delete target[propertyName];
|
1439 | } else {
|
1440 | delete target.$attrs[name];
|
1441 | }
|
1442 | } else {
|
1443 |
|
1444 |
|
1445 | if (property) {
|
1446 | if (propertyName in target) {
|
1447 | target[propertyName] = value;
|
1448 | } else {
|
1449 | defineProperty(target, property, value);
|
1450 | }
|
1451 | } else {
|
1452 | target.$attrs[name] = value;
|
1453 | }
|
1454 | }
|
1455 | };
|
1456 | |
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 | Properties.prototype.get = function (target, name) {
|
1467 | var property = this.model.getPropertyDescriptor(target, name);
|
1468 |
|
1469 | if (!property) {
|
1470 | return target.$attrs[name];
|
1471 | }
|
1472 |
|
1473 | var propertyName = property.name;
|
1474 |
|
1475 | if (!target[propertyName] && property.isMany) {
|
1476 | defineProperty(target, property, []);
|
1477 | }
|
1478 |
|
1479 | return target[propertyName];
|
1480 | };
|
1481 | |
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 | Properties.prototype.define = function (target, name, options) {
|
1491 | Object.defineProperty(target, name, options);
|
1492 | };
|
1493 | |
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 | Properties.prototype.defineDescriptor = function (target, descriptor) {
|
1499 | this.define(target, '$descriptor', {
|
1500 | value: descriptor
|
1501 | });
|
1502 | };
|
1503 | |
1504 |
|
1505 |
|
1506 |
|
1507 |
|
1508 | Properties.prototype.defineModel = function (target, model) {
|
1509 | this.define(target, '$model', {
|
1510 | value: model
|
1511 | });
|
1512 | };
|
1513 |
|
1514 | function isUndefined$1(val) {
|
1515 | return typeof val === 'undefined';
|
1516 | }
|
1517 |
|
1518 | function defineProperty(target, property, value) {
|
1519 | Object.defineProperty(target, property.name, {
|
1520 | enumerable: !property.isReference,
|
1521 | writable: true,
|
1522 | value: value,
|
1523 | configurable: true
|
1524 | });
|
1525 | }
|
1526 |
|
1527 | |
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 |
|
1544 |
|
1545 |
|
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 | function Moddle(packages) {
|
1551 | this.properties = new Properties(this);
|
1552 | this.factory = new Factory(this, this.properties);
|
1553 | this.registry = new Registry(packages, this.properties);
|
1554 | this.typeCache = {};
|
1555 | }
|
1556 | |
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 | Moddle.prototype.create = function (descriptor, attrs) {
|
1573 | var Type = this.getType(descriptor);
|
1574 |
|
1575 | if (!Type) {
|
1576 | throw new Error('unknown type <' + descriptor + '>');
|
1577 | }
|
1578 |
|
1579 | return new Type(attrs);
|
1580 | };
|
1581 | |
1582 |
|
1583 |
|
1584 |
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 | Moddle.prototype.getType = function (descriptor) {
|
1597 | var cache = this.typeCache;
|
1598 | var name = isString(descriptor) ? descriptor : descriptor.ns.name;
|
1599 | var type = cache[name];
|
1600 |
|
1601 | if (!type) {
|
1602 | descriptor = this.registry.getEffectiveDescriptor(name);
|
1603 | type = cache[name] = this.factory.createType(descriptor);
|
1604 | }
|
1605 |
|
1606 | return type;
|
1607 | };
|
1608 | |
1609 |
|
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 | Moddle.prototype.createAny = function (name, nsUri, properties) {
|
1638 | var nameNs = parseName(name);
|
1639 | var element = {
|
1640 | $type: name,
|
1641 | $instanceOf: function $instanceOf(type) {
|
1642 | return type === this.$type;
|
1643 | }
|
1644 | };
|
1645 | var descriptor = {
|
1646 | name: name,
|
1647 | isGeneric: true,
|
1648 | ns: {
|
1649 | prefix: nameNs.prefix,
|
1650 | localName: nameNs.localName,
|
1651 | uri: nsUri
|
1652 | }
|
1653 | };
|
1654 | this.properties.defineDescriptor(element, descriptor);
|
1655 | this.properties.defineModel(element, this);
|
1656 | this.properties.define(element, '$parent', {
|
1657 | enumerable: false,
|
1658 | writable: true
|
1659 | });
|
1660 | forEach(properties, function (a, key) {
|
1661 | if (isObject(a) && a.value !== undefined) {
|
1662 | element[a.name] = a.value;
|
1663 | } else {
|
1664 | element[key] = a;
|
1665 | }
|
1666 | });
|
1667 | return element;
|
1668 | };
|
1669 | |
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 | Moddle.prototype.getPackage = function (uriOrPrefix) {
|
1677 | return this.registry.getPackage(uriOrPrefix);
|
1678 | };
|
1679 | |
1680 |
|
1681 |
|
1682 |
|
1683 |
|
1684 |
|
1685 |
|
1686 | Moddle.prototype.getPackages = function () {
|
1687 | return this.registry.getPackages();
|
1688 | };
|
1689 | |
1690 |
|
1691 |
|
1692 |
|
1693 |
|
1694 | Moddle.prototype.getElementDescriptor = function (element) {
|
1695 | return element.$descriptor;
|
1696 | };
|
1697 | |
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 | Moddle.prototype.hasType = function (element, type) {
|
1706 | if (type === undefined) {
|
1707 | type = element;
|
1708 | element = this;
|
1709 | }
|
1710 |
|
1711 | var descriptor = element.$model.getElementDescriptor(element);
|
1712 | return type in descriptor.allTypesByName;
|
1713 | };
|
1714 | |
1715 |
|
1716 |
|
1717 |
|
1718 |
|
1719 | Moddle.prototype.getPropertyDescriptor = function (element, property) {
|
1720 | return this.getElementDescriptor(element).propertiesByName[property];
|
1721 | };
|
1722 | |
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 | Moddle.prototype.getTypeDescriptor = function (type) {
|
1728 | return this.registry.typeMap[type];
|
1729 | };
|
1730 |
|
1731 | var fromCharCode = String.fromCharCode;
|
1732 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
1733 | var ENTITY_PATTERN = /&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig;
|
1734 | var ENTITY_MAPPING = {
|
1735 | 'amp': '&',
|
1736 | 'apos': '\'',
|
1737 | 'gt': '>',
|
1738 | 'lt': '<',
|
1739 | 'quot': '"'
|
1740 | };
|
1741 |
|
1742 | Object.keys(ENTITY_MAPPING).forEach(function (k) {
|
1743 | ENTITY_MAPPING[k.toUpperCase()] = ENTITY_MAPPING[k];
|
1744 | });
|
1745 |
|
1746 | function replaceEntities(_, d, x, z) {
|
1747 |
|
1748 | if (z) {
|
1749 | if (hasOwnProperty.call(ENTITY_MAPPING, z)) {
|
1750 | return ENTITY_MAPPING[z];
|
1751 | } else {
|
1752 |
|
1753 | return '&' + z + ';';
|
1754 | }
|
1755 | }
|
1756 |
|
1757 |
|
1758 | if (d) {
|
1759 | return fromCharCode(d);
|
1760 | }
|
1761 |
|
1762 |
|
1763 | return fromCharCode(parseInt(x, 16));
|
1764 | }
|
1765 | |
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 | function decodeEntities(s) {
|
1777 | if (s.length > 3 && s.indexOf('&') !== -1) {
|
1778 | return s.replace(ENTITY_PATTERN, replaceEntities);
|
1779 | }
|
1780 |
|
1781 | return s;
|
1782 | }
|
1783 |
|
1784 | var XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
|
1785 | var XSI_PREFIX = 'xsi';
|
1786 | var XSI_TYPE = 'xsi:type';
|
1787 | var NON_WHITESPACE_OUTSIDE_ROOT_NODE = 'non-whitespace outside of root node';
|
1788 |
|
1789 | function error(msg) {
|
1790 | return new Error(msg);
|
1791 | }
|
1792 |
|
1793 | function missingNamespaceForPrefix(prefix) {
|
1794 | return 'missing namespace for prefix <' + prefix + '>';
|
1795 | }
|
1796 |
|
1797 | function getter(getFn) {
|
1798 | return {
|
1799 | 'get': getFn,
|
1800 | 'enumerable': true
|
1801 | };
|
1802 | }
|
1803 |
|
1804 | function cloneNsMatrix(nsMatrix) {
|
1805 | var clone = {},
|
1806 | key;
|
1807 |
|
1808 | for (key in nsMatrix) {
|
1809 | clone[key] = nsMatrix[key];
|
1810 | }
|
1811 |
|
1812 | return clone;
|
1813 | }
|
1814 |
|
1815 | function uriPrefix(prefix) {
|
1816 | return prefix + '$uri';
|
1817 | }
|
1818 |
|
1819 | function buildNsMatrix(nsUriToPrefix) {
|
1820 | var nsMatrix = {},
|
1821 | uri,
|
1822 | prefix;
|
1823 |
|
1824 | for (uri in nsUriToPrefix) {
|
1825 | prefix = nsUriToPrefix[uri];
|
1826 | nsMatrix[prefix] = prefix;
|
1827 | nsMatrix[uriPrefix(prefix)] = uri;
|
1828 | }
|
1829 |
|
1830 | return nsMatrix;
|
1831 | }
|
1832 |
|
1833 | function noopGetContext() {
|
1834 | return {
|
1835 | 'line': 0,
|
1836 | 'column': 0
|
1837 | };
|
1838 | }
|
1839 |
|
1840 | function throwFunc(err) {
|
1841 | throw err;
|
1842 | }
|
1843 | |
1844 |
|
1845 |
|
1846 |
|
1847 |
|
1848 |
|
1849 |
|
1850 |
|
1851 |
|
1852 | function Parser(options) {
|
1853 | if (!this) {
|
1854 | return new Parser(options);
|
1855 | }
|
1856 |
|
1857 | var proxy = options && options['proxy'];
|
1858 | var onText,
|
1859 | onOpenTag,
|
1860 | onCloseTag,
|
1861 | onCDATA,
|
1862 | onError = throwFunc,
|
1863 | onWarning,
|
1864 | onComment,
|
1865 | onQuestion,
|
1866 | onAttention;
|
1867 | var getContext = noopGetContext;
|
1868 | |
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 |
|
1874 | var maybeNS = false;
|
1875 | |
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 | var isNamespace = false;
|
1882 | |
1883 |
|
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 | var returnError = null;
|
1889 | |
1890 |
|
1891 |
|
1892 |
|
1893 |
|
1894 |
|
1895 | var parseStop = false;
|
1896 | |
1897 |
|
1898 |
|
1899 |
|
1900 |
|
1901 |
|
1902 |
|
1903 |
|
1904 |
|
1905 | var nsUriToPrefix;
|
1906 | |
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 | function handleError(err) {
|
1913 | if (!(err instanceof Error)) {
|
1914 | err = error(err);
|
1915 | }
|
1916 |
|
1917 | returnError = err;
|
1918 | onError(err, getContext);
|
1919 | }
|
1920 | |
1921 |
|
1922 |
|
1923 |
|
1924 |
|
1925 |
|
1926 |
|
1927 | function handleWarning(err) {
|
1928 | if (!onWarning) {
|
1929 | return;
|
1930 | }
|
1931 |
|
1932 | if (!(err instanceof Error)) {
|
1933 | err = error(err);
|
1934 | }
|
1935 |
|
1936 | onWarning(err, getContext);
|
1937 | }
|
1938 | |
1939 |
|
1940 |
|
1941 |
|
1942 |
|
1943 |
|
1944 |
|
1945 |
|
1946 |
|
1947 |
|
1948 | this['on'] = function (name, cb) {
|
1949 | if (typeof cb !== 'function') {
|
1950 | throw error('required args <name, cb>');
|
1951 | }
|
1952 |
|
1953 | switch (name) {
|
1954 | case 'openTag':
|
1955 | onOpenTag = cb;
|
1956 | break;
|
1957 |
|
1958 | case 'text':
|
1959 | onText = cb;
|
1960 | break;
|
1961 |
|
1962 | case 'closeTag':
|
1963 | onCloseTag = cb;
|
1964 | break;
|
1965 |
|
1966 | case 'error':
|
1967 | onError = cb;
|
1968 | break;
|
1969 |
|
1970 | case 'warn':
|
1971 | onWarning = cb;
|
1972 | break;
|
1973 |
|
1974 | case 'cdata':
|
1975 | onCDATA = cb;
|
1976 | break;
|
1977 |
|
1978 | case 'attention':
|
1979 | onAttention = cb;
|
1980 | break;
|
1981 |
|
1982 |
|
1983 | case 'question':
|
1984 | onQuestion = cb;
|
1985 | break;
|
1986 |
|
1987 |
|
1988 | case 'comment':
|
1989 | onComment = cb;
|
1990 | break;
|
1991 |
|
1992 | default:
|
1993 | throw error('unsupported event: ' + name);
|
1994 | }
|
1995 |
|
1996 | return this;
|
1997 | };
|
1998 | |
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 |
|
2014 | this['ns'] = function (nsMap) {
|
2015 | if (typeof nsMap === 'undefined') {
|
2016 | nsMap = {};
|
2017 | }
|
2018 |
|
2019 | if (_typeof(nsMap) !== 'object') {
|
2020 | throw error('required args <nsMap={}>');
|
2021 | }
|
2022 |
|
2023 | var _nsUriToPrefix = {},
|
2024 | k;
|
2025 |
|
2026 | for (k in nsMap) {
|
2027 | _nsUriToPrefix[k] = nsMap[k];
|
2028 | }
|
2029 |
|
2030 |
|
2031 | _nsUriToPrefix[XSI_URI] = XSI_PREFIX;
|
2032 | isNamespace = true;
|
2033 | nsUriToPrefix = _nsUriToPrefix;
|
2034 | return this;
|
2035 | };
|
2036 | |
2037 |
|
2038 |
|
2039 |
|
2040 |
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 | this['parse'] = function (xml) {
|
2046 | if (typeof xml !== 'string') {
|
2047 | throw error('required args <xml=string>');
|
2048 | }
|
2049 |
|
2050 | returnError = null;
|
2051 | parse(xml);
|
2052 | getContext = noopGetContext;
|
2053 | parseStop = false;
|
2054 | return returnError;
|
2055 | };
|
2056 | |
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 | this['stop'] = function () {
|
2062 | parseStop = true;
|
2063 | };
|
2064 | |
2065 |
|
2066 |
|
2067 |
|
2068 |
|
2069 |
|
2070 |
|
2071 | function parse(xml) {
|
2072 | var nsMatrixStack = isNamespace ? [] : null,
|
2073 | nsMatrix = isNamespace ? buildNsMatrix(nsUriToPrefix) : null,
|
2074 | _nsMatrix,
|
2075 | nodeStack = [],
|
2076 | anonymousNsCount = 0,
|
2077 | tagStart = false,
|
2078 | tagEnd = false,
|
2079 | i = 0,
|
2080 | j = 0,
|
2081 | x,
|
2082 | y,
|
2083 | q,
|
2084 | w,
|
2085 | v,
|
2086 | xmlns,
|
2087 | elementName,
|
2088 | _elementName,
|
2089 | elementProxy;
|
2090 |
|
2091 | var attrsString = '',
|
2092 | attrsStart = 0,
|
2093 | cachedAttrs
|
2094 | ;
|
2095 | |
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 |
|
2102 |
|
2103 |
|
2104 | function getAttrs() {
|
2105 | if (cachedAttrs !== null) {
|
2106 | return cachedAttrs;
|
2107 | }
|
2108 |
|
2109 | var nsUri,
|
2110 | nsUriPrefix,
|
2111 | nsName,
|
2112 | defaultAlias = isNamespace && nsMatrix['xmlns'],
|
2113 | attrList = isNamespace && maybeNS ? [] : null,
|
2114 | i = attrsStart,
|
2115 | s = attrsString,
|
2116 | l = s.length,
|
2117 | hasNewMatrix,
|
2118 | newalias,
|
2119 | value,
|
2120 | alias,
|
2121 | name,
|
2122 | attrs = {},
|
2123 | seenAttrs = {},
|
2124 | skipAttr,
|
2125 | w,
|
2126 | j;
|
2127 |
|
2128 | parseAttr: for (; i < l; i++) {
|
2129 | skipAttr = false;
|
2130 | w = s.charCodeAt(i);
|
2131 |
|
2132 | if (w === 32 || w < 14 && w > 8) {
|
2133 |
|
2134 | continue;
|
2135 | }
|
2136 |
|
2137 |
|
2138 | if (w < 65 || w > 122 || w > 90 && w < 97) {
|
2139 | if (w !== 95 && w !== 58) {
|
2140 |
|
2141 | handleWarning('illegal first char attribute name');
|
2142 | skipAttr = true;
|
2143 | }
|
2144 | }
|
2145 |
|
2146 |
|
2147 | for (j = i + 1; j < l; j++) {
|
2148 | w = s.charCodeAt(j);
|
2149 |
|
2150 | if (w > 96 && w < 123 || w > 64 && w < 91 || w > 47 && w < 59 || w === 46 ||
|
2151 | w === 45 ||
|
2152 | w === 95
|
2153 | ) {
|
2154 | continue;
|
2155 | }
|
2156 |
|
2157 |
|
2158 | if (w === 32 || w < 14 && w > 8) {
|
2159 |
|
2160 | handleWarning('missing attribute value');
|
2161 | i = j;
|
2162 | continue parseAttr;
|
2163 | }
|
2164 |
|
2165 |
|
2166 | if (w === 61) {
|
2167 |
|
2168 | break;
|
2169 | }
|
2170 |
|
2171 | handleWarning('illegal attribute name char');
|
2172 | skipAttr = true;
|
2173 | }
|
2174 |
|
2175 | name = s.substring(i, j);
|
2176 |
|
2177 | if (name === 'xmlns:xmlns') {
|
2178 | handleWarning('illegal declaration of xmlns');
|
2179 | skipAttr = true;
|
2180 | }
|
2181 |
|
2182 | w = s.charCodeAt(j + 1);
|
2183 |
|
2184 | if (w === 34) {
|
2185 |
|
2186 | j = s.indexOf('"', i = j + 2);
|
2187 |
|
2188 | if (j === -1) {
|
2189 | j = s.indexOf('\'', i);
|
2190 |
|
2191 | if (j !== -1) {
|
2192 | handleWarning('attribute value quote missmatch');
|
2193 | skipAttr = true;
|
2194 | }
|
2195 | }
|
2196 | } else if (w === 39) {
|
2197 |
|
2198 | j = s.indexOf('\'', i = j + 2);
|
2199 |
|
2200 | if (j === -1) {
|
2201 | j = s.indexOf('"', i);
|
2202 |
|
2203 | if (j !== -1) {
|
2204 | handleWarning('attribute value quote missmatch');
|
2205 | skipAttr = true;
|
2206 | }
|
2207 | }
|
2208 | } else {
|
2209 | handleWarning('missing attribute value quotes');
|
2210 | skipAttr = true;
|
2211 |
|
2212 | for (j = j + 1; j < l; j++) {
|
2213 | w = s.charCodeAt(j + 1);
|
2214 |
|
2215 | if (w === 32 || w < 14 && w > 8) {
|
2216 |
|
2217 | break;
|
2218 | }
|
2219 | }
|
2220 | }
|
2221 |
|
2222 | if (j === -1) {
|
2223 | handleWarning('missing closing quotes');
|
2224 | j = l;
|
2225 | skipAttr = true;
|
2226 | }
|
2227 |
|
2228 | if (!skipAttr) {
|
2229 | value = s.substring(i, j);
|
2230 | }
|
2231 |
|
2232 | i = j;
|
2233 |
|
2234 |
|
2235 |
|
2236 | for (; j + 1 < l; j++) {
|
2237 | w = s.charCodeAt(j + 1);
|
2238 |
|
2239 | if (w === 32 || w < 14 && w > 8) {
|
2240 |
|
2241 | break;
|
2242 | }
|
2243 |
|
2244 |
|
2245 | if (i === j) {
|
2246 | handleWarning('illegal character after attribute end');
|
2247 | skipAttr = true;
|
2248 | }
|
2249 | }
|
2250 |
|
2251 |
|
2252 | i = j + 1;
|
2253 |
|
2254 | if (skipAttr) {
|
2255 | continue parseAttr;
|
2256 | }
|
2257 |
|
2258 |
|
2259 | if (name in seenAttrs) {
|
2260 | handleWarning('attribute <' + name + '> already defined');
|
2261 | continue;
|
2262 | }
|
2263 |
|
2264 | seenAttrs[name] = true;
|
2265 |
|
2266 | if (!isNamespace) {
|
2267 | attrs[name] = value;
|
2268 | continue;
|
2269 | }
|
2270 |
|
2271 |
|
2272 | if (maybeNS) {
|
2273 | newalias = name === 'xmlns' ? 'xmlns' : name.charCodeAt(0) === 120 && name.substr(0, 6) === 'xmlns:' ? name.substr(6) : null;
|
2274 |
|
2275 | if (newalias !== null) {
|
2276 | nsUri = decodeEntities(value);
|
2277 | nsUriPrefix = uriPrefix(newalias);
|
2278 | alias = nsUriToPrefix[nsUri];
|
2279 |
|
2280 | if (!alias) {
|
2281 |
|
2282 | if (newalias === 'xmlns' || nsUriPrefix in nsMatrix && nsMatrix[nsUriPrefix] !== nsUri) {
|
2283 |
|
2284 | do {
|
2285 | alias = 'ns' + anonymousNsCount++;
|
2286 | } while (typeof nsMatrix[alias] !== 'undefined');
|
2287 | } else {
|
2288 | alias = newalias;
|
2289 | }
|
2290 |
|
2291 | nsUriToPrefix[nsUri] = alias;
|
2292 | }
|
2293 |
|
2294 | if (nsMatrix[newalias] !== alias) {
|
2295 | if (!hasNewMatrix) {
|
2296 | nsMatrix = cloneNsMatrix(nsMatrix);
|
2297 | hasNewMatrix = true;
|
2298 | }
|
2299 |
|
2300 | nsMatrix[newalias] = alias;
|
2301 |
|
2302 | if (newalias === 'xmlns') {
|
2303 | nsMatrix[uriPrefix(alias)] = nsUri;
|
2304 | defaultAlias = alias;
|
2305 | }
|
2306 |
|
2307 | nsMatrix[nsUriPrefix] = nsUri;
|
2308 | }
|
2309 |
|
2310 |
|
2311 | attrs[name] = value;
|
2312 | continue;
|
2313 | }
|
2314 |
|
2315 |
|
2316 |
|
2317 | attrList.push(name, value);
|
2318 | continue;
|
2319 | }
|
2320 |
|
2321 |
|
2322 |
|
2323 |
|
2324 |
|
2325 | w = name.indexOf(':');
|
2326 |
|
2327 | if (w === -1) {
|
2328 | attrs[name] = value;
|
2329 | continue;
|
2330 | }
|
2331 |
|
2332 |
|
2333 | if (!(nsName = nsMatrix[name.substring(0, w)])) {
|
2334 | handleWarning(missingNamespaceForPrefix(name.substring(0, w)));
|
2335 | continue;
|
2336 | }
|
2337 |
|
2338 | name = defaultAlias === nsName ? name.substr(w + 1) : nsName + name.substr(w);
|
2339 |
|
2340 |
|
2341 | if (name === XSI_TYPE) {
|
2342 | w = value.indexOf(':');
|
2343 |
|
2344 | if (w !== -1) {
|
2345 | nsName = value.substring(0, w);
|
2346 |
|
2347 | nsName = nsMatrix[nsName] || nsName;
|
2348 | value = nsName + value.substring(w);
|
2349 | } else {
|
2350 | value = defaultAlias + ':' + value;
|
2351 | }
|
2352 | }
|
2353 |
|
2354 |
|
2355 | attrs[name] = value;
|
2356 | }
|
2357 |
|
2358 |
|
2359 | if (maybeNS) {
|
2360 |
|
2361 | for (i = 0, l = attrList.length; i < l; i++) {
|
2362 | name = attrList[i++];
|
2363 | value = attrList[i];
|
2364 | w = name.indexOf(':');
|
2365 |
|
2366 | if (w !== -1) {
|
2367 |
|
2368 | if (!(nsName = nsMatrix[name.substring(0, w)])) {
|
2369 | handleWarning(missingNamespaceForPrefix(name.substring(0, w)));
|
2370 | continue;
|
2371 | }
|
2372 |
|
2373 | name = defaultAlias === nsName ? name.substr(w + 1) : nsName + name.substr(w);
|
2374 |
|
2375 |
|
2376 | if (name === XSI_TYPE) {
|
2377 | w = value.indexOf(':');
|
2378 |
|
2379 | if (w !== -1) {
|
2380 | nsName = value.substring(0, w);
|
2381 |
|
2382 | nsName = nsMatrix[nsName] || nsName;
|
2383 | value = nsName + value.substring(w);
|
2384 | } else {
|
2385 | value = defaultAlias + ':' + value;
|
2386 | }
|
2387 | }
|
2388 |
|
2389 | }
|
2390 |
|
2391 | attrs[name] = value;
|
2392 | }
|
2393 |
|
2394 | }
|
2395 |
|
2396 | return cachedAttrs = attrs;
|
2397 | }
|
2398 | |
2399 |
|
2400 |
|
2401 |
|
2402 |
|
2403 |
|
2404 |
|
2405 |
|
2406 | function getParseContext() {
|
2407 | var splitsRe = /(\r\n|\r|\n)/g;
|
2408 | var line = 0;
|
2409 | var column = 0;
|
2410 | var startOfLine = 0;
|
2411 | var endOfLine = j;
|
2412 | var match;
|
2413 | var data;
|
2414 |
|
2415 | while (i >= startOfLine) {
|
2416 | match = splitsRe.exec(xml);
|
2417 |
|
2418 | if (!match) {
|
2419 | break;
|
2420 | }
|
2421 |
|
2422 |
|
2423 | endOfLine = match[0].length + match.index;
|
2424 |
|
2425 | if (endOfLine > i) {
|
2426 | break;
|
2427 | }
|
2428 |
|
2429 |
|
2430 | line += 1;
|
2431 | startOfLine = endOfLine;
|
2432 | }
|
2433 |
|
2434 |
|
2435 | if (i == -1) {
|
2436 | column = endOfLine;
|
2437 | data = xml.substring(j);
|
2438 | } else
|
2439 | if (j === 0) {
|
2440 | data = xml.substring(j, i);
|
2441 | }
|
2442 | else {
|
2443 | column = i - startOfLine;
|
2444 | data = j == -1 ? xml.substring(i) : xml.substring(i, j + 1);
|
2445 | }
|
2446 |
|
2447 | return {
|
2448 | 'data': data,
|
2449 | 'line': line,
|
2450 | 'column': column
|
2451 | };
|
2452 | }
|
2453 |
|
2454 | getContext = getParseContext;
|
2455 |
|
2456 | if (proxy) {
|
2457 | elementProxy = Object.create({}, {
|
2458 | 'name': getter(function () {
|
2459 | return elementName;
|
2460 | }),
|
2461 | 'originalName': getter(function () {
|
2462 | return _elementName;
|
2463 | }),
|
2464 | 'attrs': getter(getAttrs),
|
2465 | 'ns': getter(function () {
|
2466 | return nsMatrix;
|
2467 | })
|
2468 | });
|
2469 | }
|
2470 |
|
2471 |
|
2472 | while (j !== -1) {
|
2473 | if (xml.charCodeAt(j) === 60) {
|
2474 |
|
2475 | i = j;
|
2476 | } else {
|
2477 | i = xml.indexOf('<', j);
|
2478 | }
|
2479 |
|
2480 |
|
2481 | if (i === -1) {
|
2482 | if (nodeStack.length) {
|
2483 | return handleError('unexpected end of file');
|
2484 | }
|
2485 |
|
2486 | if (j === 0) {
|
2487 | return handleError('missing start tag');
|
2488 | }
|
2489 |
|
2490 | if (j < xml.length) {
|
2491 | if (xml.substring(j).trim()) {
|
2492 | handleWarning(NON_WHITESPACE_OUTSIDE_ROOT_NODE);
|
2493 | }
|
2494 | }
|
2495 |
|
2496 | return;
|
2497 | }
|
2498 |
|
2499 |
|
2500 | if (j !== i) {
|
2501 | if (nodeStack.length) {
|
2502 | if (onText) {
|
2503 | onText(xml.substring(j, i), decodeEntities, getContext);
|
2504 |
|
2505 | if (parseStop) {
|
2506 | return;
|
2507 | }
|
2508 | }
|
2509 | } else {
|
2510 | if (xml.substring(j, i).trim()) {
|
2511 | handleWarning(NON_WHITESPACE_OUTSIDE_ROOT_NODE);
|
2512 |
|
2513 | if (parseStop) {
|
2514 | return;
|
2515 | }
|
2516 | }
|
2517 | }
|
2518 | }
|
2519 |
|
2520 | w = xml.charCodeAt(i + 1);
|
2521 |
|
2522 | if (w === 33) {
|
2523 |
|
2524 | q = xml.charCodeAt(i + 2);
|
2525 |
|
2526 | if (q === 91 && xml.substr(i + 3, 6) === 'CDATA[') {
|
2527 |
|
2528 | j = xml.indexOf(']]>', i);
|
2529 |
|
2530 | if (j === -1) {
|
2531 | return handleError('unclosed cdata');
|
2532 | }
|
2533 |
|
2534 | if (onCDATA) {
|
2535 | onCDATA(xml.substring(i + 9, j), getContext);
|
2536 |
|
2537 | if (parseStop) {
|
2538 | return;
|
2539 | }
|
2540 | }
|
2541 |
|
2542 | j += 3;
|
2543 | continue;
|
2544 | }
|
2545 |
|
2546 |
|
2547 | if (q === 45 && xml.charCodeAt(i + 3) === 45) {
|
2548 |
|
2549 | j = xml.indexOf('-->', i);
|
2550 |
|
2551 | if (j === -1) {
|
2552 | return handleError('unclosed comment');
|
2553 | }
|
2554 |
|
2555 | if (onComment) {
|
2556 | onComment(xml.substring(i + 4, j), decodeEntities, getContext);
|
2557 |
|
2558 | if (parseStop) {
|
2559 | return;
|
2560 | }
|
2561 | }
|
2562 |
|
2563 | j += 3;
|
2564 | continue;
|
2565 | }
|
2566 | }
|
2567 |
|
2568 |
|
2569 | if (w === 63) {
|
2570 |
|
2571 | j = xml.indexOf('?>', i);
|
2572 |
|
2573 | if (j === -1) {
|
2574 | return handleError('unclosed question');
|
2575 | }
|
2576 |
|
2577 | if (onQuestion) {
|
2578 | onQuestion(xml.substring(i, j + 2), getContext);
|
2579 |
|
2580 | if (parseStop) {
|
2581 | return;
|
2582 | }
|
2583 | }
|
2584 |
|
2585 | j += 2;
|
2586 | continue;
|
2587 | }
|
2588 |
|
2589 |
|
2590 |
|
2591 |
|
2592 | for (x = i + 1;; x++) {
|
2593 | v = xml.charCodeAt(x);
|
2594 |
|
2595 | if (isNaN(v)) {
|
2596 | j = -1;
|
2597 | return handleError('unclosed tag');
|
2598 | }
|
2599 |
|
2600 |
|
2601 |
|
2602 |
|
2603 |
|
2604 | if (v === 34) {
|
2605 |
|
2606 | q = xml.indexOf('"', x + 1);
|
2607 | x = q !== -1 ? q : x;
|
2608 | } else if (v === 39) {
|
2609 |
|
2610 | q = xml.indexOf("'", x + 1);
|
2611 | x = q !== -1 ? q : x;
|
2612 | } else if (v === 62) {
|
2613 |
|
2614 | j = x;
|
2615 | break;
|
2616 | }
|
2617 | }
|
2618 |
|
2619 |
|
2620 |
|
2621 | if (w === 33) {
|
2622 |
|
2623 | if (onAttention) {
|
2624 | onAttention(xml.substring(i, j + 1), decodeEntities, getContext);
|
2625 |
|
2626 | if (parseStop) {
|
2627 | return;
|
2628 | }
|
2629 | }
|
2630 |
|
2631 | j += 1;
|
2632 | continue;
|
2633 | }
|
2634 |
|
2635 |
|
2636 |
|
2637 | cachedAttrs = {};
|
2638 |
|
2639 | if (w === 47) {
|
2640 |
|
2641 | tagStart = false;
|
2642 | tagEnd = true;
|
2643 |
|
2644 | if (!nodeStack.length) {
|
2645 | return handleError('missing open tag');
|
2646 | }
|
2647 |
|
2648 |
|
2649 | x = elementName = nodeStack.pop();
|
2650 | q = i + 2 + x.length;
|
2651 |
|
2652 | if (xml.substring(i + 2, q) !== x) {
|
2653 | return handleError('closing tag mismatch');
|
2654 | }
|
2655 |
|
2656 |
|
2657 | for (; q < j; q++) {
|
2658 | w = xml.charCodeAt(q);
|
2659 |
|
2660 | if (w === 32 || w > 8 && w < 14) {
|
2661 |
|
2662 | continue;
|
2663 | }
|
2664 |
|
2665 | return handleError('close tag');
|
2666 | }
|
2667 | } else {
|
2668 | if (xml.charCodeAt(j - 1) === 47) {
|
2669 |
|
2670 | x = elementName = xml.substring(i + 1, j - 1);
|
2671 | tagStart = true;
|
2672 | tagEnd = true;
|
2673 | } else {
|
2674 | x = elementName = xml.substring(i + 1, j);
|
2675 | tagStart = true;
|
2676 | tagEnd = false;
|
2677 | }
|
2678 |
|
2679 | if (!(w > 96 && w < 123 || w > 64 && w < 91 || w === 95 || w === 58)) {
|
2680 |
|
2681 | return handleError('illegal first char nodeName');
|
2682 | }
|
2683 |
|
2684 | for (q = 1, y = x.length; q < y; q++) {
|
2685 | w = x.charCodeAt(q);
|
2686 |
|
2687 | if (w > 96 && w < 123 || w > 64 && w < 91 || w > 47 && w < 59 || w === 45 || w === 95 || w == 46) {
|
2688 | continue;
|
2689 | }
|
2690 |
|
2691 | if (w === 32 || w < 14 && w > 8) {
|
2692 |
|
2693 | elementName = x.substring(0, q);
|
2694 |
|
2695 | cachedAttrs = null;
|
2696 | break;
|
2697 | }
|
2698 |
|
2699 | return handleError('invalid nodeName');
|
2700 | }
|
2701 |
|
2702 | if (!tagEnd) {
|
2703 | nodeStack.push(elementName);
|
2704 | }
|
2705 | }
|
2706 |
|
2707 | if (isNamespace) {
|
2708 | _nsMatrix = nsMatrix;
|
2709 |
|
2710 | if (tagStart) {
|
2711 |
|
2712 |
|
2713 | if (!tagEnd) {
|
2714 | nsMatrixStack.push(_nsMatrix);
|
2715 | }
|
2716 |
|
2717 | if (cachedAttrs === null) {
|
2718 |
|
2719 |
|
2720 |
|
2721 | if (maybeNS = x.indexOf('xmlns', q) !== -1) {
|
2722 | attrsStart = q;
|
2723 | attrsString = x;
|
2724 | getAttrs();
|
2725 | maybeNS = false;
|
2726 | }
|
2727 | }
|
2728 | }
|
2729 |
|
2730 | _elementName = elementName;
|
2731 | w = elementName.indexOf(':');
|
2732 |
|
2733 | if (w !== -1) {
|
2734 | xmlns = nsMatrix[elementName.substring(0, w)];
|
2735 |
|
2736 | if (!xmlns) {
|
2737 | return handleError('missing namespace on <' + _elementName + '>');
|
2738 | }
|
2739 |
|
2740 | elementName = elementName.substr(w + 1);
|
2741 | } else {
|
2742 | xmlns = nsMatrix['xmlns'];
|
2743 |
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 | }
|
2749 |
|
2750 |
|
2751 | if (xmlns) {
|
2752 | elementName = xmlns + ':' + elementName;
|
2753 | }
|
2754 | }
|
2755 |
|
2756 | if (tagStart) {
|
2757 | attrsStart = q;
|
2758 | attrsString = x;
|
2759 |
|
2760 | if (onOpenTag) {
|
2761 | if (proxy) {
|
2762 | onOpenTag(elementProxy, decodeEntities, tagEnd, getContext);
|
2763 | } else {
|
2764 | onOpenTag(elementName, getAttrs, decodeEntities, tagEnd, getContext);
|
2765 | }
|
2766 |
|
2767 | if (parseStop) {
|
2768 | return;
|
2769 | }
|
2770 | }
|
2771 | }
|
2772 |
|
2773 | if (tagEnd) {
|
2774 | if (onCloseTag) {
|
2775 | onCloseTag(proxy ? elementProxy : elementName, decodeEntities, tagStart, getContext);
|
2776 |
|
2777 | if (parseStop) {
|
2778 | return;
|
2779 | }
|
2780 | }
|
2781 |
|
2782 |
|
2783 | if (isNamespace) {
|
2784 | if (!tagStart) {
|
2785 | nsMatrix = nsMatrixStack.pop();
|
2786 | } else {
|
2787 | nsMatrix = _nsMatrix;
|
2788 | }
|
2789 | }
|
2790 | }
|
2791 |
|
2792 | j += 1;
|
2793 | }
|
2794 | }
|
2795 |
|
2796 |
|
2797 | }
|
2798 |
|
2799 | function hasLowerCaseAlias(pkg) {
|
2800 | return pkg.xml && pkg.xml.tagAlias === 'lowerCase';
|
2801 | }
|
2802 |
|
2803 | var DEFAULT_NS_MAP = {
|
2804 | 'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
2805 | 'xml': 'http://www.w3.org/XML/1998/namespace'
|
2806 | };
|
2807 | var XSI_TYPE$1 = 'xsi:type';
|
2808 |
|
2809 | function serializeFormat(element) {
|
2810 | return element.xml && element.xml.serialize;
|
2811 | }
|
2812 |
|
2813 | function serializeAsType(element) {
|
2814 | return serializeFormat(element) === XSI_TYPE$1;
|
2815 | }
|
2816 |
|
2817 | function serializeAsProperty(element) {
|
2818 | return serializeFormat(element) === 'property';
|
2819 | }
|
2820 |
|
2821 | function capitalize(str) {
|
2822 | return str.charAt(0).toUpperCase() + str.slice(1);
|
2823 | }
|
2824 |
|
2825 | function aliasToName(aliasNs, pkg) {
|
2826 | if (!hasLowerCaseAlias(pkg)) {
|
2827 | return aliasNs.name;
|
2828 | }
|
2829 |
|
2830 | return aliasNs.prefix + ':' + capitalize(aliasNs.localName);
|
2831 | }
|
2832 |
|
2833 | function prefixedToName(nameNs, pkg) {
|
2834 | var name = nameNs.name,
|
2835 | localName = nameNs.localName;
|
2836 | var typePrefix = pkg.xml && pkg.xml.typePrefix;
|
2837 |
|
2838 | if (typePrefix && localName.indexOf(typePrefix) === 0) {
|
2839 | return nameNs.prefix + ':' + localName.slice(typePrefix.length);
|
2840 | } else {
|
2841 | return name;
|
2842 | }
|
2843 | }
|
2844 |
|
2845 | function normalizeXsiTypeName(name, model) {
|
2846 | var nameNs = parseName(name);
|
2847 | var pkg = model.getPackage(nameNs.prefix);
|
2848 | return prefixedToName(nameNs, pkg);
|
2849 | }
|
2850 |
|
2851 | function error$1(message) {
|
2852 | return new Error(message);
|
2853 | }
|
2854 | |
2855 |
|
2856 |
|
2857 |
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 | function getModdleDescriptor(element) {
|
2864 | return element.$descriptor;
|
2865 | }
|
2866 |
|
2867 | function defer(fn) {
|
2868 | setTimeout(fn, 0);
|
2869 | }
|
2870 | |
2871 |
|
2872 |
|
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 | function Context(options) {
|
2882 | |
2883 |
|
2884 |
|
2885 |
|
2886 | |
2887 |
|
2888 |
|
2889 | assign(this, options);
|
2890 | this.elementsById = {};
|
2891 | this.references = [];
|
2892 | this.warnings = [];
|
2893 | |
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 |
|
2899 | this.addReference = function (reference) {
|
2900 | this.references.push(reference);
|
2901 | };
|
2902 | |
2903 |
|
2904 |
|
2905 |
|
2906 |
|
2907 |
|
2908 |
|
2909 | this.addElement = function (element) {
|
2910 | if (!element) {
|
2911 | throw error$1('expected element');
|
2912 | }
|
2913 |
|
2914 | var elementsById = this.elementsById;
|
2915 | var descriptor = getModdleDescriptor(element);
|
2916 | var idProperty = descriptor.idProperty,
|
2917 | id;
|
2918 |
|
2919 | if (idProperty) {
|
2920 | id = element.get(idProperty.name);
|
2921 |
|
2922 | if (id) {
|
2923 |
|
2924 | if (!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(id)) {
|
2925 | throw new Error('illegal ID <' + id + '>');
|
2926 | }
|
2927 |
|
2928 | if (elementsById[id]) {
|
2929 | throw error$1('duplicate ID <' + id + '>');
|
2930 | }
|
2931 |
|
2932 | elementsById[id] = element;
|
2933 | }
|
2934 | }
|
2935 | };
|
2936 | |
2937 |
|
2938 |
|
2939 |
|
2940 |
|
2941 |
|
2942 |
|
2943 |
|
2944 |
|
2945 | this.addWarning = function (warning) {
|
2946 | this.warnings.push(warning);
|
2947 | };
|
2948 | }
|
2949 |
|
2950 | function BaseHandler() {}
|
2951 |
|
2952 | BaseHandler.prototype.handleEnd = function () {};
|
2953 |
|
2954 | BaseHandler.prototype.handleText = function () {};
|
2955 |
|
2956 | BaseHandler.prototype.handleNode = function () {};
|
2957 | |
2958 |
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 |
|
2966 | function NoopHandler() {}
|
2967 |
|
2968 | NoopHandler.prototype = Object.create(BaseHandler.prototype);
|
2969 |
|
2970 | NoopHandler.prototype.handleNode = function () {
|
2971 | return this;
|
2972 | };
|
2973 |
|
2974 | function BodyHandler() {}
|
2975 |
|
2976 | BodyHandler.prototype = Object.create(BaseHandler.prototype);
|
2977 |
|
2978 | BodyHandler.prototype.handleText = function (text) {
|
2979 | this.body = (this.body || '') + text;
|
2980 | };
|
2981 |
|
2982 | function ReferenceHandler(property, context) {
|
2983 | this.property = property;
|
2984 | this.context = context;
|
2985 | }
|
2986 |
|
2987 | ReferenceHandler.prototype = Object.create(BodyHandler.prototype);
|
2988 |
|
2989 | ReferenceHandler.prototype.handleNode = function (node) {
|
2990 | if (this.element) {
|
2991 | throw error$1('expected no sub nodes');
|
2992 | } else {
|
2993 | this.element = this.createReference(node);
|
2994 | }
|
2995 |
|
2996 | return this;
|
2997 | };
|
2998 |
|
2999 | ReferenceHandler.prototype.handleEnd = function () {
|
3000 | this.element.id = this.body;
|
3001 | };
|
3002 |
|
3003 | ReferenceHandler.prototype.createReference = function (node) {
|
3004 | return {
|
3005 | property: this.property.ns.name,
|
3006 | id: ''
|
3007 | };
|
3008 | };
|
3009 |
|
3010 | function ValueHandler(propertyDesc, element) {
|
3011 | this.element = element;
|
3012 | this.propertyDesc = propertyDesc;
|
3013 | }
|
3014 |
|
3015 | ValueHandler.prototype = Object.create(BodyHandler.prototype);
|
3016 |
|
3017 | ValueHandler.prototype.handleEnd = function () {
|
3018 | var value = this.body || '',
|
3019 | element = this.element,
|
3020 | propertyDesc = this.propertyDesc;
|
3021 | value = coerceType(propertyDesc.type, value);
|
3022 |
|
3023 | if (propertyDesc.isMany) {
|
3024 | element.get(propertyDesc.name).push(value);
|
3025 | } else {
|
3026 | element.set(propertyDesc.name, value);
|
3027 | }
|
3028 | };
|
3029 |
|
3030 | function BaseElementHandler() {}
|
3031 |
|
3032 | BaseElementHandler.prototype = Object.create(BodyHandler.prototype);
|
3033 |
|
3034 | BaseElementHandler.prototype.handleNode = function (node) {
|
3035 | var parser = this,
|
3036 | element = this.element;
|
3037 |
|
3038 | if (!element) {
|
3039 | element = this.element = this.createElement(node);
|
3040 | this.context.addElement(element);
|
3041 | } else {
|
3042 | parser = this.handleChild(node);
|
3043 | }
|
3044 |
|
3045 | return parser;
|
3046 | };
|
3047 | |
3048 |
|
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 | function ElementHandler(model, typeName, context) {
|
3054 | this.model = model;
|
3055 | this.type = model.getType(typeName);
|
3056 | this.context = context;
|
3057 | }
|
3058 |
|
3059 | ElementHandler.prototype = Object.create(BaseElementHandler.prototype);
|
3060 |
|
3061 | ElementHandler.prototype.addReference = function (reference) {
|
3062 | this.context.addReference(reference);
|
3063 | };
|
3064 |
|
3065 | ElementHandler.prototype.handleText = function (text) {
|
3066 | var element = this.element,
|
3067 | descriptor = getModdleDescriptor(element),
|
3068 | bodyProperty = descriptor.bodyProperty;
|
3069 |
|
3070 | if (!bodyProperty) {
|
3071 | throw error$1('unexpected body text <' + text + '>');
|
3072 | }
|
3073 |
|
3074 | BodyHandler.prototype.handleText.call(this, text);
|
3075 | };
|
3076 |
|
3077 | ElementHandler.prototype.handleEnd = function () {
|
3078 | var value = this.body,
|
3079 | element = this.element,
|
3080 | descriptor = getModdleDescriptor(element),
|
3081 | bodyProperty = descriptor.bodyProperty;
|
3082 |
|
3083 | if (bodyProperty && value !== undefined) {
|
3084 | value = coerceType(bodyProperty.type, value);
|
3085 | element.set(bodyProperty.name, value);
|
3086 | }
|
3087 | };
|
3088 | |
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 | ElementHandler.prototype.createElement = function (node) {
|
3096 | var attributes = node.attributes,
|
3097 | Type = this.type,
|
3098 | descriptor = getModdleDescriptor(Type),
|
3099 | context = this.context,
|
3100 | instance = new Type({}),
|
3101 | model = this.model,
|
3102 | propNameNs;
|
3103 | forEach(attributes, function (value, name) {
|
3104 | var prop = descriptor.propertiesByName[name],
|
3105 | values;
|
3106 |
|
3107 | if (prop && prop.isReference) {
|
3108 | if (!prop.isMany) {
|
3109 | context.addReference({
|
3110 | element: instance,
|
3111 | property: prop.ns.name,
|
3112 | id: value
|
3113 | });
|
3114 | } else {
|
3115 |
|
3116 | values = value.split(' ');
|
3117 | forEach(values, function (v) {
|
3118 | context.addReference({
|
3119 | element: instance,
|
3120 | property: prop.ns.name,
|
3121 | id: v
|
3122 | });
|
3123 | });
|
3124 | }
|
3125 | } else {
|
3126 | if (prop) {
|
3127 | value = coerceType(prop.type, value);
|
3128 | } else if (name !== 'xmlns') {
|
3129 | propNameNs = parseName(name, descriptor.ns.prefix);
|
3130 |
|
3131 |
|
3132 | if (model.getPackage(propNameNs.prefix)) {
|
3133 | context.addWarning({
|
3134 | message: 'unknown attribute <' + name + '>',
|
3135 | element: instance,
|
3136 | property: name,
|
3137 | value: value
|
3138 | });
|
3139 | }
|
3140 | }
|
3141 |
|
3142 | instance.set(name, value);
|
3143 | }
|
3144 | });
|
3145 | return instance;
|
3146 | };
|
3147 |
|
3148 | ElementHandler.prototype.getPropertyForNode = function (node) {
|
3149 | var name = node.name;
|
3150 | var nameNs = parseName(name);
|
3151 | var type = this.type,
|
3152 | model = this.model,
|
3153 | descriptor = getModdleDescriptor(type);
|
3154 | var propertyName = nameNs.name,
|
3155 | property = descriptor.propertiesByName[propertyName],
|
3156 | elementTypeName,
|
3157 | elementType;
|
3158 |
|
3159 | if (property && !property.isAttr) {
|
3160 | if (serializeAsType(property)) {
|
3161 | elementTypeName = node.attributes[XSI_TYPE$1];
|
3162 |
|
3163 |
|
3164 | if (elementTypeName) {
|
3165 |
|
3166 |
|
3167 | elementTypeName = normalizeXsiTypeName(elementTypeName, model);
|
3168 | elementType = model.getType(elementTypeName);
|
3169 | return assign({}, property, {
|
3170 | effectiveType: getModdleDescriptor(elementType).name
|
3171 | });
|
3172 | }
|
3173 | }
|
3174 |
|
3175 |
|
3176 | return property;
|
3177 | }
|
3178 |
|
3179 | var pkg = model.getPackage(nameNs.prefix);
|
3180 |
|
3181 | if (pkg) {
|
3182 | elementTypeName = aliasToName(nameNs, pkg);
|
3183 | elementType = model.getType(elementTypeName);
|
3184 |
|
3185 | property = find(descriptor.properties, function (p) {
|
3186 | return !p.isVirtual && !p.isReference && !p.isAttribute && elementType.hasType(p.type);
|
3187 | });
|
3188 |
|
3189 | if (property) {
|
3190 | return assign({}, property, {
|
3191 | effectiveType: getModdleDescriptor(elementType).name
|
3192 | });
|
3193 | }
|
3194 | } else {
|
3195 |
|
3196 | property = find(descriptor.properties, function (p) {
|
3197 | return !p.isReference && !p.isAttribute && p.type === 'Element';
|
3198 | });
|
3199 |
|
3200 | if (property) {
|
3201 | return property;
|
3202 | }
|
3203 | }
|
3204 |
|
3205 | throw error$1('unrecognized element <' + nameNs.name + '>');
|
3206 | };
|
3207 |
|
3208 | ElementHandler.prototype.toString = function () {
|
3209 | return 'ElementDescriptor[' + getModdleDescriptor(this.type).name + ']';
|
3210 | };
|
3211 |
|
3212 | ElementHandler.prototype.valueHandler = function (propertyDesc, element) {
|
3213 | return new ValueHandler(propertyDesc, element);
|
3214 | };
|
3215 |
|
3216 | ElementHandler.prototype.referenceHandler = function (propertyDesc) {
|
3217 | return new ReferenceHandler(propertyDesc, this.context);
|
3218 | };
|
3219 |
|
3220 | ElementHandler.prototype.handler = function (type) {
|
3221 | if (type === 'Element') {
|
3222 | return new GenericElementHandler(this.model, type, this.context);
|
3223 | } else {
|
3224 | return new ElementHandler(this.model, type, this.context);
|
3225 | }
|
3226 | };
|
3227 | |
3228 |
|
3229 |
|
3230 |
|
3231 |
|
3232 |
|
3233 |
|
3234 | ElementHandler.prototype.handleChild = function (node) {
|
3235 | var propertyDesc, type, element, childHandler;
|
3236 | propertyDesc = this.getPropertyForNode(node);
|
3237 | element = this.element;
|
3238 | type = propertyDesc.effectiveType || propertyDesc.type;
|
3239 |
|
3240 | if (isSimple(type)) {
|
3241 | return this.valueHandler(propertyDesc, element);
|
3242 | }
|
3243 |
|
3244 | if (propertyDesc.isReference) {
|
3245 | childHandler = this.referenceHandler(propertyDesc).handleNode(node);
|
3246 | } else {
|
3247 | childHandler = this.handler(type).handleNode(node);
|
3248 | }
|
3249 |
|
3250 | var newElement = childHandler.element;
|
3251 |
|
3252 |
|
3253 | if (newElement !== undefined) {
|
3254 | if (propertyDesc.isMany) {
|
3255 | element.get(propertyDesc.name).push(newElement);
|
3256 | } else {
|
3257 | element.set(propertyDesc.name, newElement);
|
3258 | }
|
3259 |
|
3260 | if (propertyDesc.isReference) {
|
3261 | assign(newElement, {
|
3262 | element: element
|
3263 | });
|
3264 | this.context.addReference(newElement);
|
3265 | } else {
|
3266 |
|
3267 | newElement.$parent = element;
|
3268 | }
|
3269 | }
|
3270 |
|
3271 | return childHandler;
|
3272 | };
|
3273 | |
3274 |
|
3275 |
|
3276 |
|
3277 |
|
3278 |
|
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 |
|
3284 | function RootElementHandler(model, typeName, context) {
|
3285 | ElementHandler.call(this, model, typeName, context);
|
3286 | }
|
3287 |
|
3288 | RootElementHandler.prototype = Object.create(ElementHandler.prototype);
|
3289 |
|
3290 | RootElementHandler.prototype.createElement = function (node) {
|
3291 | var name = node.name,
|
3292 | nameNs = parseName(name),
|
3293 | model = this.model,
|
3294 | type = this.type,
|
3295 | pkg = model.getPackage(nameNs.prefix),
|
3296 | typeName = pkg && aliasToName(nameNs, pkg) || name;
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 | if (!type.hasType(typeName)) {
|
3302 | throw error$1('unexpected element <' + node.originalName + '>');
|
3303 | }
|
3304 |
|
3305 | return ElementHandler.prototype.createElement.call(this, node);
|
3306 | };
|
3307 |
|
3308 | function GenericElementHandler(model, typeName, context) {
|
3309 | this.model = model;
|
3310 | this.context = context;
|
3311 | }
|
3312 |
|
3313 | GenericElementHandler.prototype = Object.create(BaseElementHandler.prototype);
|
3314 |
|
3315 | GenericElementHandler.prototype.createElement = function (node) {
|
3316 | var name = node.name,
|
3317 | ns = parseName(name),
|
3318 | prefix = ns.prefix,
|
3319 | uri = node.ns[prefix + '$uri'],
|
3320 | attributes = node.attributes;
|
3321 | return this.model.createAny(name, uri, attributes);
|
3322 | };
|
3323 |
|
3324 | GenericElementHandler.prototype.handleChild = function (node) {
|
3325 | var handler = new GenericElementHandler(this.model, 'Element', this.context).handleNode(node),
|
3326 | element = this.element;
|
3327 | var newElement = handler.element,
|
3328 | children;
|
3329 |
|
3330 | if (newElement !== undefined) {
|
3331 | children = element.$children = element.$children || [];
|
3332 | children.push(newElement);
|
3333 |
|
3334 | newElement.$parent = element;
|
3335 | }
|
3336 |
|
3337 | return handler;
|
3338 | };
|
3339 |
|
3340 | GenericElementHandler.prototype.handleEnd = function () {
|
3341 | if (this.body) {
|
3342 | this.element.$body = this.body;
|
3343 | }
|
3344 | };
|
3345 | |
3346 |
|
3347 |
|
3348 |
|
3349 |
|
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 | function Reader(options) {
|
3355 | if (options instanceof Moddle) {
|
3356 | options = {
|
3357 | model: options
|
3358 | };
|
3359 | }
|
3360 |
|
3361 | assign(this, {
|
3362 | lax: false
|
3363 | }, options);
|
3364 | }
|
3365 | |
3366 |
|
3367 |
|
3368 |
|
3369 |
|
3370 |
|
3371 |
|
3372 |
|
3373 |
|
3374 | Reader.prototype.fromXML = function (xml, options, done) {
|
3375 | var rootHandler = options.rootHandler;
|
3376 |
|
3377 | if (options instanceof ElementHandler) {
|
3378 |
|
3379 | rootHandler = options;
|
3380 | options = {};
|
3381 | } else {
|
3382 | if (typeof options === 'string') {
|
3383 |
|
3384 | rootHandler = this.handler(options);
|
3385 | options = {};
|
3386 | } else if (typeof rootHandler === 'string') {
|
3387 |
|
3388 | rootHandler = this.handler(rootHandler);
|
3389 | }
|
3390 | }
|
3391 |
|
3392 | var model = this.model,
|
3393 | lax = this.lax;
|
3394 | var context = new Context(assign({}, options, {
|
3395 | rootHandler: rootHandler
|
3396 | })),
|
3397 | parser = new Parser({
|
3398 | proxy: true
|
3399 | }),
|
3400 | stack = createStack();
|
3401 | rootHandler.context = context;
|
3402 |
|
3403 | stack.push(rootHandler);
|
3404 | |
3405 |
|
3406 |
|
3407 |
|
3408 |
|
3409 |
|
3410 |
|
3411 |
|
3412 |
|
3413 |
|
3414 | function handleError(err, getContext, lax) {
|
3415 | var ctx = getContext();
|
3416 | var line = ctx.line,
|
3417 | column = ctx.column,
|
3418 | data = ctx.data;
|
3419 |
|
3420 |
|
3421 |
|
3422 | if (data.charAt(0) === '<' && data.indexOf(' ') !== -1) {
|
3423 | data = data.slice(0, data.indexOf(' ')) + '>';
|
3424 | }
|
3425 |
|
3426 | var message = 'unparsable content ' + (data ? data + ' ' : '') + 'detected\n\t' + 'line: ' + line + '\n\t' + 'column: ' + column + '\n\t' + 'nested error: ' + err.message;
|
3427 |
|
3428 | if (lax) {
|
3429 | context.addWarning({
|
3430 | message: message,
|
3431 | error: err
|
3432 | });
|
3433 | return true;
|
3434 | } else {
|
3435 | throw error$1(message);
|
3436 | }
|
3437 | }
|
3438 |
|
3439 | function handleWarning(err, getContext) {
|
3440 |
|
3441 | return handleError(err, getContext, true);
|
3442 | }
|
3443 | |
3444 |
|
3445 |
|
3446 |
|
3447 |
|
3448 | function resolveReferences() {
|
3449 | var elementsById = context.elementsById;
|
3450 | var references = context.references;
|
3451 | var i, r;
|
3452 |
|
3453 | for (i = 0; r = references[i]; i++) {
|
3454 | var element = r.element;
|
3455 | var reference = elementsById[r.id];
|
3456 | var property = getModdleDescriptor(element).propertiesByName[r.property];
|
3457 |
|
3458 | if (!reference) {
|
3459 | context.addWarning({
|
3460 | message: 'unresolved reference <' + r.id + '>',
|
3461 | element: r.element,
|
3462 | property: r.property,
|
3463 | value: r.id
|
3464 | });
|
3465 | }
|
3466 |
|
3467 | if (property.isMany) {
|
3468 | var collection = element.get(property.name),
|
3469 | idx = collection.indexOf(r);
|
3470 |
|
3471 |
|
3472 | if (idx === -1) {
|
3473 | idx = collection.length;
|
3474 | }
|
3475 |
|
3476 | if (!reference) {
|
3477 |
|
3478 | collection.splice(idx, 1);
|
3479 | } else {
|
3480 |
|
3481 | collection[idx] = reference;
|
3482 | }
|
3483 | } else {
|
3484 | element.set(property.name, reference);
|
3485 | }
|
3486 | }
|
3487 | }
|
3488 |
|
3489 | function handleClose() {
|
3490 | stack.pop().handleEnd();
|
3491 | }
|
3492 |
|
3493 | var PREAMBLE_START_PATTERN = /^<\?xml /i;
|
3494 | var ENCODING_PATTERN = / encoding="([^"]+)"/i;
|
3495 | var UTF_8_PATTERN = /^utf-8$/i;
|
3496 |
|
3497 | function handleQuestion(question) {
|
3498 | if (!PREAMBLE_START_PATTERN.test(question)) {
|
3499 | return;
|
3500 | }
|
3501 |
|
3502 | var match = ENCODING_PATTERN.exec(question);
|
3503 | var encoding = match && match[1];
|
3504 |
|
3505 | if (!encoding || UTF_8_PATTERN.test(encoding)) {
|
3506 | return;
|
3507 | }
|
3508 |
|
3509 | context.addWarning({
|
3510 | message: 'unsupported document encoding <' + encoding + '>, ' + 'falling back to UTF-8'
|
3511 | });
|
3512 | }
|
3513 |
|
3514 | function handleOpen(node, getContext) {
|
3515 | var handler = stack.peek();
|
3516 |
|
3517 | try {
|
3518 | stack.push(handler.handleNode(node));
|
3519 | } catch (err) {
|
3520 | if (handleError(err, getContext, lax)) {
|
3521 | stack.push(new NoopHandler());
|
3522 | }
|
3523 | }
|
3524 | }
|
3525 |
|
3526 | function handleCData(text, getContext) {
|
3527 | try {
|
3528 | stack.peek().handleText(text);
|
3529 | } catch (err) {
|
3530 | handleWarning(err, getContext);
|
3531 | }
|
3532 | }
|
3533 |
|
3534 | function handleText(text, getContext) {
|
3535 |
|
3536 |
|
3537 | text = text.trim();
|
3538 |
|
3539 | if (!text) {
|
3540 | return;
|
3541 | }
|
3542 |
|
3543 | handleCData(text, getContext);
|
3544 | }
|
3545 |
|
3546 | var uriMap = model.getPackages().reduce(function (uriMap, p) {
|
3547 | uriMap[p.uri] = p.prefix;
|
3548 | return uriMap;
|
3549 | }, {
|
3550 | 'http://www.w3.org/XML/1998/namespace': 'xml'
|
3551 |
|
3552 | });
|
3553 | parser.ns(uriMap).on('openTag', function (obj, decodeStr, selfClosing, getContext) {
|
3554 |
|
3555 | var attrs = obj.attrs || {};
|
3556 | var decodedAttrs = Object.keys(attrs).reduce(function (d, key) {
|
3557 | var value = decodeStr(attrs[key]);
|
3558 | d[key] = value;
|
3559 | return d;
|
3560 | }, {});
|
3561 | var node = {
|
3562 | name: obj.name,
|
3563 | originalName: obj.originalName,
|
3564 | attributes: decodedAttrs,
|
3565 | ns: obj.ns
|
3566 | };
|
3567 | handleOpen(node, getContext);
|
3568 | }).on('question', handleQuestion).on('closeTag', handleClose).on('cdata', handleCData).on('text', function (text, decodeEntities, getContext) {
|
3569 | handleText(decodeEntities(text), getContext);
|
3570 | }).on('error', handleError).on('warn', handleWarning);
|
3571 |
|
3572 |
|
3573 |
|
3574 |
|
3575 | defer(function () {
|
3576 | var err;
|
3577 |
|
3578 | try {
|
3579 | parser.parse(xml);
|
3580 | resolveReferences();
|
3581 | } catch (e) {
|
3582 | err = e;
|
3583 | }
|
3584 |
|
3585 | var element = rootHandler.element;
|
3586 |
|
3587 |
|
3588 | if (!err && !element) {
|
3589 | err = error$1('failed to parse document as <' + rootHandler.type.$descriptor.name + '>');
|
3590 | }
|
3591 |
|
3592 | done(err, err ? undefined : element, context);
|
3593 | });
|
3594 | };
|
3595 |
|
3596 | Reader.prototype.handler = function (name) {
|
3597 | return new RootElementHandler(this.model, name);
|
3598 | };
|
3599 |
|
3600 |
|
3601 | function createStack() {
|
3602 | var stack = [];
|
3603 | Object.defineProperty(stack, 'peek', {
|
3604 | value: function value() {
|
3605 | return this[this.length - 1];
|
3606 | }
|
3607 | });
|
3608 | return stack;
|
3609 | }
|
3610 |
|
3611 | var XML_PREAMBLE = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
3612 | var ESCAPE_ATTR_CHARS = /<|>|'|"|&|\n\r|\n/g;
|
3613 | var ESCAPE_CHARS = /<|>|&/g;
|
3614 |
|
3615 | function Namespaces(parent) {
|
3616 | var prefixMap = {};
|
3617 | var uriMap = {};
|
3618 | var used = {};
|
3619 | var wellknown = [];
|
3620 | var custom = [];
|
3621 |
|
3622 | this.byUri = function (uri) {
|
3623 | return uriMap[uri] || parent && parent.byUri(uri);
|
3624 | };
|
3625 |
|
3626 | this.add = function (ns, isWellknown) {
|
3627 | uriMap[ns.uri] = ns;
|
3628 |
|
3629 | if (isWellknown) {
|
3630 | wellknown.push(ns);
|
3631 | } else {
|
3632 | custom.push(ns);
|
3633 | }
|
3634 |
|
3635 | this.mapPrefix(ns.prefix, ns.uri);
|
3636 | };
|
3637 |
|
3638 | this.uriByPrefix = function (prefix) {
|
3639 | return prefixMap[prefix || 'xmlns'];
|
3640 | };
|
3641 |
|
3642 | this.mapPrefix = function (prefix, uri) {
|
3643 | prefixMap[prefix || 'xmlns'] = uri;
|
3644 | };
|
3645 |
|
3646 | this.getNSKey = function (ns) {
|
3647 | return ns.prefix !== undefined ? ns.uri + '|' + ns.prefix : ns.uri;
|
3648 | };
|
3649 |
|
3650 | this.logUsed = function (ns) {
|
3651 | var uri = ns.uri;
|
3652 | var nsKey = this.getNSKey(ns);
|
3653 | used[nsKey] = this.byUri(uri);
|
3654 |
|
3655 | if (parent) {
|
3656 | parent.logUsed(ns);
|
3657 | }
|
3658 | };
|
3659 |
|
3660 | this.getUsed = function (ns) {
|
3661 | function isUsed(ns) {
|
3662 | var nsKey = self.getNSKey(ns);
|
3663 | return used[nsKey];
|
3664 | }
|
3665 |
|
3666 | var self = this;
|
3667 | var allNs = [].concat(wellknown, custom);
|
3668 | return allNs.filter(isUsed);
|
3669 | };
|
3670 | }
|
3671 |
|
3672 | function lower(string) {
|
3673 | return string.charAt(0).toLowerCase() + string.slice(1);
|
3674 | }
|
3675 |
|
3676 | function nameToAlias(name, pkg) {
|
3677 | if (hasLowerCaseAlias(pkg)) {
|
3678 | return lower(name);
|
3679 | } else {
|
3680 | return name;
|
3681 | }
|
3682 | }
|
3683 |
|
3684 | function inherits(ctor, superCtor) {
|
3685 | ctor.super_ = superCtor;
|
3686 | ctor.prototype = Object.create(superCtor.prototype, {
|
3687 | constructor: {
|
3688 | value: ctor,
|
3689 | enumerable: false,
|
3690 | writable: true,
|
3691 | configurable: true
|
3692 | }
|
3693 | });
|
3694 | }
|
3695 |
|
3696 | function nsName(ns) {
|
3697 | if (isString(ns)) {
|
3698 | return ns;
|
3699 | } else {
|
3700 | return (ns.prefix ? ns.prefix + ':' : '') + ns.localName;
|
3701 | }
|
3702 | }
|
3703 |
|
3704 | function getNsAttrs(namespaces) {
|
3705 | return map(namespaces.getUsed(), function (ns) {
|
3706 | var name = 'xmlns' + (ns.prefix ? ':' + ns.prefix : '');
|
3707 | return {
|
3708 | name: name,
|
3709 | value: ns.uri
|
3710 | };
|
3711 | });
|
3712 | }
|
3713 |
|
3714 | function getElementNs(ns, descriptor) {
|
3715 | if (descriptor.isGeneric) {
|
3716 | return assign({
|
3717 | localName: descriptor.ns.localName
|
3718 | }, ns);
|
3719 | } else {
|
3720 | return assign({
|
3721 | localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg)
|
3722 | }, ns);
|
3723 | }
|
3724 | }
|
3725 |
|
3726 | function getPropertyNs(ns, descriptor) {
|
3727 | return assign({
|
3728 | localName: descriptor.ns.localName
|
3729 | }, ns);
|
3730 | }
|
3731 |
|
3732 | function getSerializableProperties(element) {
|
3733 | var descriptor = element.$descriptor;
|
3734 | return filter(descriptor.properties, function (p) {
|
3735 | var name = p.name;
|
3736 |
|
3737 | if (p.isVirtual) {
|
3738 | return false;
|
3739 | }
|
3740 |
|
3741 |
|
3742 | if (!element.hasOwnProperty(name)) {
|
3743 | return false;
|
3744 | }
|
3745 |
|
3746 | var value = element[name];
|
3747 |
|
3748 | if (value === p["default"]) {
|
3749 | return false;
|
3750 | }
|
3751 |
|
3752 |
|
3753 | if (value === null) {
|
3754 | return false;
|
3755 | }
|
3756 |
|
3757 | return p.isMany ? value.length : true;
|
3758 | });
|
3759 | }
|
3760 |
|
3761 | var ESCAPE_ATTR_MAP = {
|
3762 | '\n': '#10',
|
3763 | '\n\r': '#10',
|
3764 | '"': '#34',
|
3765 | '\'': '#39',
|
3766 | '<': '#60',
|
3767 | '>': '#62',
|
3768 | '&': '#38'
|
3769 | };
|
3770 | var ESCAPE_MAP = {
|
3771 | '<': 'lt',
|
3772 | '>': 'gt',
|
3773 | '&': 'amp'
|
3774 | };
|
3775 |
|
3776 | function escape(str, charPattern, replaceMap) {
|
3777 |
|
3778 | str = isString(str) ? str : '' + str;
|
3779 | return str.replace(charPattern, function (s) {
|
3780 | return '&' + replaceMap[s] + ';';
|
3781 | });
|
3782 | }
|
3783 | |
3784 |
|
3785 |
|
3786 |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 | function escapeAttr(str) {
|
3792 | return escape(str, ESCAPE_ATTR_CHARS, ESCAPE_ATTR_MAP);
|
3793 | }
|
3794 |
|
3795 | function escapeBody(str) {
|
3796 | return escape(str, ESCAPE_CHARS, ESCAPE_MAP);
|
3797 | }
|
3798 |
|
3799 | function filterAttributes(props) {
|
3800 | return filter(props, function (p) {
|
3801 | return p.isAttr;
|
3802 | });
|
3803 | }
|
3804 |
|
3805 | function filterContained(props) {
|
3806 | return filter(props, function (p) {
|
3807 | return !p.isAttr;
|
3808 | });
|
3809 | }
|
3810 |
|
3811 | function ReferenceSerializer(tagName) {
|
3812 | this.tagName = tagName;
|
3813 | }
|
3814 |
|
3815 | ReferenceSerializer.prototype.build = function (element) {
|
3816 | this.element = element;
|
3817 | return this;
|
3818 | };
|
3819 |
|
3820 | ReferenceSerializer.prototype.serializeTo = function (writer) {
|
3821 | writer.appendIndent().append('<' + this.tagName + '>' + this.element.id + '</' + this.tagName + '>').appendNewLine();
|
3822 | };
|
3823 |
|
3824 | function BodySerializer() {}
|
3825 |
|
3826 | BodySerializer.prototype.serializeValue = BodySerializer.prototype.serializeTo = function (writer) {
|
3827 | writer.append(this.escape ? escapeBody(this.value) : this.value);
|
3828 | };
|
3829 |
|
3830 | BodySerializer.prototype.build = function (prop, value) {
|
3831 | this.value = value;
|
3832 |
|
3833 | if (prop.type === 'String' && value.search(ESCAPE_CHARS) !== -1) {
|
3834 | this.escape = true;
|
3835 | }
|
3836 |
|
3837 | return this;
|
3838 | };
|
3839 |
|
3840 | function ValueSerializer(tagName) {
|
3841 | this.tagName = tagName;
|
3842 | }
|
3843 |
|
3844 | inherits(ValueSerializer, BodySerializer);
|
3845 |
|
3846 | ValueSerializer.prototype.serializeTo = function (writer) {
|
3847 | writer.appendIndent().append('<' + this.tagName + '>');
|
3848 | this.serializeValue(writer);
|
3849 | writer.append('</' + this.tagName + '>').appendNewLine();
|
3850 | };
|
3851 |
|
3852 | function ElementSerializer(parent, propertyDescriptor) {
|
3853 | this.body = [];
|
3854 | this.attrs = [];
|
3855 | this.parent = parent;
|
3856 | this.propertyDescriptor = propertyDescriptor;
|
3857 | }
|
3858 |
|
3859 | ElementSerializer.prototype.build = function (element) {
|
3860 | this.element = element;
|
3861 | var elementDescriptor = element.$descriptor,
|
3862 | propertyDescriptor = this.propertyDescriptor;
|
3863 | var otherAttrs, properties;
|
3864 | var isGeneric = elementDescriptor.isGeneric;
|
3865 |
|
3866 | if (isGeneric) {
|
3867 | otherAttrs = this.parseGeneric(element);
|
3868 | } else {
|
3869 | otherAttrs = this.parseNsAttributes(element);
|
3870 | }
|
3871 |
|
3872 | if (propertyDescriptor) {
|
3873 | this.ns = this.nsPropertyTagName(propertyDescriptor);
|
3874 | } else {
|
3875 | this.ns = this.nsTagName(elementDescriptor);
|
3876 | }
|
3877 |
|
3878 |
|
3879 | this.tagName = this.addTagName(this.ns);
|
3880 |
|
3881 | if (!isGeneric) {
|
3882 | properties = getSerializableProperties(element);
|
3883 | this.parseAttributes(filterAttributes(properties));
|
3884 | this.parseContainments(filterContained(properties));
|
3885 | }
|
3886 |
|
3887 | this.parseGenericAttributes(element, otherAttrs);
|
3888 | return this;
|
3889 | };
|
3890 |
|
3891 | ElementSerializer.prototype.nsTagName = function (descriptor) {
|
3892 | var effectiveNs = this.logNamespaceUsed(descriptor.ns);
|
3893 | return getElementNs(effectiveNs, descriptor);
|
3894 | };
|
3895 |
|
3896 | ElementSerializer.prototype.nsPropertyTagName = function (descriptor) {
|
3897 | var effectiveNs = this.logNamespaceUsed(descriptor.ns);
|
3898 | return getPropertyNs(effectiveNs, descriptor);
|
3899 | };
|
3900 |
|
3901 | ElementSerializer.prototype.isLocalNs = function (ns) {
|
3902 | return ns.uri === this.ns.uri;
|
3903 | };
|
3904 | |
3905 |
|
3906 |
|
3907 |
|
3908 |
|
3909 |
|
3910 |
|
3911 |
|
3912 |
|
3913 |
|
3914 | ElementSerializer.prototype.nsAttributeName = function (element) {
|
3915 | var ns;
|
3916 |
|
3917 | if (isString(element)) {
|
3918 | ns = parseName(element);
|
3919 | } else {
|
3920 | ns = element.ns;
|
3921 | }
|
3922 |
|
3923 |
|
3924 | if (element.inherited) {
|
3925 | return {
|
3926 | localName: ns.localName
|
3927 | };
|
3928 | }
|
3929 |
|
3930 |
|
3931 | var effectiveNs = this.logNamespaceUsed(ns);
|
3932 |
|
3933 | this.getNamespaces().logUsed(effectiveNs);
|
3934 |
|
3935 | if (this.isLocalNs(effectiveNs)) {
|
3936 | return {
|
3937 | localName: ns.localName
|
3938 | };
|
3939 | } else {
|
3940 | return assign({
|
3941 | localName: ns.localName
|
3942 | }, effectiveNs);
|
3943 | }
|
3944 | };
|
3945 |
|
3946 | ElementSerializer.prototype.parseGeneric = function (element) {
|
3947 | var self = this,
|
3948 | body = this.body;
|
3949 | var attributes = [];
|
3950 | forEach(element, function (val, key) {
|
3951 | var nonNsAttr;
|
3952 |
|
3953 | if (key === '$body') {
|
3954 | body.push(new BodySerializer().build({
|
3955 | type: 'String'
|
3956 | }, val));
|
3957 | } else if (key === '$children') {
|
3958 | forEach(val, function (child) {
|
3959 | body.push(new ElementSerializer(self).build(child));
|
3960 | });
|
3961 | } else if (key.indexOf('$') !== 0) {
|
3962 | nonNsAttr = self.parseNsAttribute(element, key, val);
|
3963 |
|
3964 | if (nonNsAttr) {
|
3965 | attributes.push({
|
3966 | name: key,
|
3967 | value: val
|
3968 | });
|
3969 | }
|
3970 | }
|
3971 | });
|
3972 | return attributes;
|
3973 | };
|
3974 |
|
3975 | ElementSerializer.prototype.parseNsAttribute = function (element, name, value) {
|
3976 | var model = element.$model;
|
3977 | var nameNs = parseName(name);
|
3978 | var ns;
|
3979 |
|
3980 | if (nameNs.prefix === 'xmlns') {
|
3981 | ns = {
|
3982 | prefix: nameNs.localName,
|
3983 | uri: value
|
3984 | };
|
3985 | }
|
3986 |
|
3987 |
|
3988 | if (!nameNs.prefix && nameNs.localName === 'xmlns') {
|
3989 | ns = {
|
3990 | uri: value
|
3991 | };
|
3992 | }
|
3993 |
|
3994 | if (!ns) {
|
3995 | return {
|
3996 | name: name,
|
3997 | value: value
|
3998 | };
|
3999 | }
|
4000 |
|
4001 | if (model && model.getPackage(value)) {
|
4002 |
|
4003 | this.logNamespace(ns, true, true);
|
4004 | } else {
|
4005 |
|
4006 | var actualNs = this.logNamespaceUsed(ns, true);
|
4007 | this.getNamespaces().logUsed(actualNs);
|
4008 | }
|
4009 | };
|
4010 | |
4011 |
|
4012 |
|
4013 |
|
4014 |
|
4015 |
|
4016 |
|
4017 |
|
4018 | ElementSerializer.prototype.parseNsAttributes = function (element, attrs) {
|
4019 | var self = this;
|
4020 | var genericAttrs = element.$attrs;
|
4021 | var attributes = [];
|
4022 |
|
4023 |
|
4024 |
|
4025 | forEach(genericAttrs, function (value, name) {
|
4026 | var nonNsAttr = self.parseNsAttribute(element, name, value);
|
4027 |
|
4028 | if (nonNsAttr) {
|
4029 | attributes.push(nonNsAttr);
|
4030 | }
|
4031 | });
|
4032 | return attributes;
|
4033 | };
|
4034 |
|
4035 | ElementSerializer.prototype.parseGenericAttributes = function (element, attributes) {
|
4036 | var self = this;
|
4037 | forEach(attributes, function (attr) {
|
4038 |
|
4039 |
|
4040 | if (attr.name === XSI_TYPE$1) {
|
4041 | return;
|
4042 | }
|
4043 |
|
4044 | try {
|
4045 | self.addAttribute(self.nsAttributeName(attr.name), attr.value);
|
4046 | } catch (e) {
|
4047 | console.warn('missing namespace information for ', attr.name, '=', attr.value, 'on', element, e);
|
4048 | }
|
4049 | });
|
4050 | };
|
4051 |
|
4052 | ElementSerializer.prototype.parseContainments = function (properties) {
|
4053 | var self = this,
|
4054 | body = this.body,
|
4055 | element = this.element;
|
4056 | forEach(properties, function (p) {
|
4057 | var value = element.get(p.name),
|
4058 | isReference = p.isReference,
|
4059 | isMany = p.isMany;
|
4060 |
|
4061 | if (!isMany) {
|
4062 | value = [value];
|
4063 | }
|
4064 |
|
4065 | if (p.isBody) {
|
4066 | body.push(new BodySerializer().build(p, value[0]));
|
4067 | } else if (isSimple(p.type)) {
|
4068 | forEach(value, function (v) {
|
4069 | body.push(new ValueSerializer(self.addTagName(self.nsPropertyTagName(p))).build(p, v));
|
4070 | });
|
4071 | } else if (isReference) {
|
4072 | forEach(value, function (v) {
|
4073 | body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
|
4074 | });
|
4075 | } else {
|
4076 |
|
4077 |
|
4078 | var asType = serializeAsType(p),
|
4079 | asProperty = serializeAsProperty(p);
|
4080 | forEach(value, function (v) {
|
4081 | var serializer;
|
4082 |
|
4083 | if (asType) {
|
4084 | serializer = new TypeSerializer(self, p);
|
4085 | } else if (asProperty) {
|
4086 | serializer = new ElementSerializer(self, p);
|
4087 | } else {
|
4088 | serializer = new ElementSerializer(self);
|
4089 | }
|
4090 |
|
4091 | body.push(serializer.build(v));
|
4092 | });
|
4093 | }
|
4094 | });
|
4095 | };
|
4096 |
|
4097 | ElementSerializer.prototype.getNamespaces = function (local) {
|
4098 | var namespaces = this.namespaces,
|
4099 | parent = this.parent,
|
4100 | parentNamespaces;
|
4101 |
|
4102 | if (!namespaces) {
|
4103 | parentNamespaces = parent && parent.getNamespaces();
|
4104 |
|
4105 | if (local || !parentNamespaces) {
|
4106 | this.namespaces = namespaces = new Namespaces(parentNamespaces);
|
4107 | } else {
|
4108 | namespaces = parentNamespaces;
|
4109 | }
|
4110 | }
|
4111 |
|
4112 | return namespaces;
|
4113 | };
|
4114 |
|
4115 | ElementSerializer.prototype.logNamespace = function (ns, wellknown, local) {
|
4116 | var namespaces = this.getNamespaces(local);
|
4117 | var nsUri = ns.uri,
|
4118 | nsPrefix = ns.prefix;
|
4119 | var existing = namespaces.byUri(nsUri);
|
4120 |
|
4121 | if (nsPrefix !== 'xml' && (!existing || local)) {
|
4122 | namespaces.add(ns, wellknown);
|
4123 | }
|
4124 |
|
4125 | namespaces.mapPrefix(nsPrefix, nsUri);
|
4126 | return ns;
|
4127 | };
|
4128 |
|
4129 | ElementSerializer.prototype.logNamespaceUsed = function (ns, local) {
|
4130 | var element = this.element,
|
4131 | model = element.$model,
|
4132 | namespaces = this.getNamespaces(local);
|
4133 |
|
4134 |
|
4135 |
|
4136 |
|
4137 |
|
4138 | var prefix = ns.prefix,
|
4139 | uri = ns.uri,
|
4140 | newPrefix,
|
4141 | idx,
|
4142 | wellknownUri;
|
4143 |
|
4144 | if (!prefix && !uri) {
|
4145 | return {
|
4146 | localName: ns.localName
|
4147 | };
|
4148 | }
|
4149 |
|
4150 | wellknownUri = DEFAULT_NS_MAP[prefix] || model && (model.getPackage(prefix) || {}).uri;
|
4151 | uri = uri || wellknownUri || namespaces.uriByPrefix(prefix);
|
4152 |
|
4153 | if (!uri) {
|
4154 | throw new Error('no namespace uri given for prefix <' + prefix + '>');
|
4155 | }
|
4156 |
|
4157 | ns = namespaces.byUri(uri);
|
4158 |
|
4159 | if (!ns) {
|
4160 | newPrefix = prefix;
|
4161 | idx = 1;
|
4162 |
|
4163 | while (namespaces.uriByPrefix(newPrefix)) {
|
4164 | newPrefix = prefix + '_' + idx++;
|
4165 | }
|
4166 |
|
4167 | ns = this.logNamespace({
|
4168 | prefix: newPrefix,
|
4169 | uri: uri
|
4170 | }, wellknownUri === uri);
|
4171 | }
|
4172 |
|
4173 | if (prefix) {
|
4174 | namespaces.mapPrefix(prefix, uri);
|
4175 | }
|
4176 |
|
4177 | return ns;
|
4178 | };
|
4179 |
|
4180 | ElementSerializer.prototype.parseAttributes = function (properties) {
|
4181 | var self = this,
|
4182 | element = this.element;
|
4183 | forEach(properties, function (p) {
|
4184 | var value = element.get(p.name);
|
4185 |
|
4186 | if (p.isReference) {
|
4187 | if (!p.isMany) {
|
4188 | value = value.id;
|
4189 | } else {
|
4190 | var values = [];
|
4191 | forEach(value, function (v) {
|
4192 | values.push(v.id);
|
4193 | });
|
4194 |
|
4195 | value = values.join(' ');
|
4196 | }
|
4197 | }
|
4198 |
|
4199 | self.addAttribute(self.nsAttributeName(p), value);
|
4200 | });
|
4201 | };
|
4202 |
|
4203 | ElementSerializer.prototype.addTagName = function (nsTagName) {
|
4204 | var actualNs = this.logNamespaceUsed(nsTagName);
|
4205 | this.getNamespaces().logUsed(actualNs);
|
4206 | return nsName(nsTagName);
|
4207 | };
|
4208 |
|
4209 | ElementSerializer.prototype.addAttribute = function (name, value) {
|
4210 | var attrs = this.attrs;
|
4211 |
|
4212 | if (isString(value)) {
|
4213 | value = escapeAttr(value);
|
4214 | }
|
4215 |
|
4216 | attrs.push({
|
4217 | name: name,
|
4218 | value: value
|
4219 | });
|
4220 | };
|
4221 |
|
4222 | ElementSerializer.prototype.serializeAttributes = function (writer) {
|
4223 | var attrs = this.attrs,
|
4224 | namespaces = this.namespaces;
|
4225 |
|
4226 | if (namespaces) {
|
4227 | attrs = getNsAttrs(namespaces).concat(attrs);
|
4228 | }
|
4229 |
|
4230 | forEach(attrs, function (a) {
|
4231 | writer.append(' ').append(nsName(a.name)).append('="').append(a.value).append('"');
|
4232 | });
|
4233 | };
|
4234 |
|
4235 | ElementSerializer.prototype.serializeTo = function (writer) {
|
4236 | var firstBody = this.body[0],
|
4237 | indent = firstBody && firstBody.constructor !== BodySerializer;
|
4238 | writer.appendIndent().append('<' + this.tagName);
|
4239 | this.serializeAttributes(writer);
|
4240 | writer.append(firstBody ? '>' : ' />');
|
4241 |
|
4242 | if (firstBody) {
|
4243 | if (indent) {
|
4244 | writer.appendNewLine().indent();
|
4245 | }
|
4246 |
|
4247 | forEach(this.body, function (b) {
|
4248 | b.serializeTo(writer);
|
4249 | });
|
4250 |
|
4251 | if (indent) {
|
4252 | writer.unindent().appendIndent();
|
4253 | }
|
4254 |
|
4255 | writer.append('</' + this.tagName + '>');
|
4256 | }
|
4257 |
|
4258 | writer.appendNewLine();
|
4259 | };
|
4260 | |
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 | function TypeSerializer(parent, propertyDescriptor) {
|
4266 | ElementSerializer.call(this, parent, propertyDescriptor);
|
4267 | }
|
4268 |
|
4269 | inherits(TypeSerializer, ElementSerializer);
|
4270 |
|
4271 | TypeSerializer.prototype.parseNsAttributes = function (element) {
|
4272 |
|
4273 | var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element);
|
4274 | var descriptor = element.$descriptor;
|
4275 |
|
4276 | if (descriptor.name === this.propertyDescriptor.type) {
|
4277 | return attributes;
|
4278 | }
|
4279 |
|
4280 | var typeNs = this.typeNs = this.nsTagName(descriptor);
|
4281 | this.getNamespaces().logUsed(this.typeNs);
|
4282 |
|
4283 |
|
4284 | var pkg = element.$model.getPackage(typeNs.uri),
|
4285 | typePrefix = pkg.xml && pkg.xml.typePrefix || '';
|
4286 | this.addAttribute(this.nsAttributeName(XSI_TYPE$1), (typeNs.prefix ? typeNs.prefix + ':' : '') + typePrefix + descriptor.ns.localName);
|
4287 | return attributes;
|
4288 | };
|
4289 |
|
4290 | TypeSerializer.prototype.isLocalNs = function (ns) {
|
4291 | return ns.uri === (this.typeNs || this.ns).uri;
|
4292 | };
|
4293 |
|
4294 | function SavingWriter() {
|
4295 | this.value = '';
|
4296 |
|
4297 | this.write = function (str) {
|
4298 | this.value += str;
|
4299 | };
|
4300 | }
|
4301 |
|
4302 | function FormatingWriter(out, format) {
|
4303 | var indent = [''];
|
4304 |
|
4305 | this.append = function (str) {
|
4306 | out.write(str);
|
4307 | return this;
|
4308 | };
|
4309 |
|
4310 | this.appendNewLine = function () {
|
4311 | if (format) {
|
4312 | out.write('\n');
|
4313 | }
|
4314 |
|
4315 | return this;
|
4316 | };
|
4317 |
|
4318 | this.appendIndent = function () {
|
4319 | if (format) {
|
4320 | out.write(indent.join(' '));
|
4321 | }
|
4322 |
|
4323 | return this;
|
4324 | };
|
4325 |
|
4326 | this.indent = function () {
|
4327 | indent.push('');
|
4328 | return this;
|
4329 | };
|
4330 |
|
4331 | this.unindent = function () {
|
4332 | indent.pop();
|
4333 | return this;
|
4334 | };
|
4335 | }
|
4336 | |
4337 |
|
4338 |
|
4339 |
|
4340 |
|
4341 |
|
4342 |
|
4343 | function Writer(options) {
|
4344 | options = assign({
|
4345 | format: false,
|
4346 | preamble: true
|
4347 | }, options || {});
|
4348 |
|
4349 | function toXML(tree, writer) {
|
4350 | var internalWriter = writer || new SavingWriter();
|
4351 | var formatingWriter = new FormatingWriter(internalWriter, options.format);
|
4352 |
|
4353 | if (options.preamble) {
|
4354 | formatingWriter.append(XML_PREAMBLE);
|
4355 | }
|
4356 |
|
4357 | new ElementSerializer().build(tree).serializeTo(formatingWriter);
|
4358 |
|
4359 | if (!writer) {
|
4360 | return internalWriter.value;
|
4361 | }
|
4362 | }
|
4363 |
|
4364 | return {
|
4365 | toXML: toXML
|
4366 | };
|
4367 | }
|
4368 |
|
4369 | |
4370 |
|
4371 |
|
4372 |
|
4373 |
|
4374 |
|
4375 |
|
4376 |
|
4377 |
|
4378 |
|
4379 | function DmnModdle(packages, options) {
|
4380 | Moddle.call(this, packages, options);
|
4381 | }
|
4382 |
|
4383 | DmnModdle.prototype = Object.create(Moddle.prototype);
|
4384 | |
4385 |
|
4386 |
|
4387 |
|
4388 |
|
4389 |
|
4390 |
|
4391 |
|
4392 |
|
4393 |
|
4394 | DmnModdle.prototype.fromXML = function (xmlStr, typeName, options, done) {
|
4395 | if (!isString(typeName)) {
|
4396 | done = options;
|
4397 | options = typeName;
|
4398 | typeName = 'dmn:Definitions';
|
4399 | }
|
4400 |
|
4401 | if (isFunction(options)) {
|
4402 | done = options;
|
4403 | options = {};
|
4404 | }
|
4405 |
|
4406 | var reader = new Reader(assign({
|
4407 | model: this,
|
4408 | lax: true
|
4409 | }, options));
|
4410 | var rootHandler = reader.handler(typeName);
|
4411 | reader.fromXML(xmlStr, rootHandler, done);
|
4412 | };
|
4413 | |
4414 |
|
4415 |
|
4416 |
|
4417 |
|
4418 |
|
4419 |
|
4420 |
|
4421 |
|
4422 | DmnModdle.prototype.toXML = function (element, options, done) {
|
4423 | if (isFunction(options)) {
|
4424 | done = options;
|
4425 | options = {};
|
4426 | }
|
4427 |
|
4428 | var writer = new Writer(options);
|
4429 | var result;
|
4430 | var err;
|
4431 |
|
4432 | try {
|
4433 | result = writer.toXML(element);
|
4434 | } catch (e) {
|
4435 | err = e;
|
4436 | }
|
4437 |
|
4438 | return done(err, result);
|
4439 | };
|
4440 |
|
4441 | var name = "DC";
|
4442 | var prefix = "dc";
|
4443 | var uri = "http://www.omg.org/spec/DMN/20180521/DC/";
|
4444 | var types = [{
|
4445 | name: "Dimension",
|
4446 | properties: [{
|
4447 | name: "width",
|
4448 | isAttr: true,
|
4449 | type: "Real"
|
4450 | }, {
|
4451 | name: "height",
|
4452 | isAttr: true,
|
4453 | type: "Real"
|
4454 | }]
|
4455 | }, {
|
4456 | name: "Bounds",
|
4457 | properties: [{
|
4458 | name: "height",
|
4459 | isAttr: true,
|
4460 | type: "Real"
|
4461 | }, {
|
4462 | name: "width",
|
4463 | isAttr: true,
|
4464 | type: "Real"
|
4465 | }, {
|
4466 | name: "x",
|
4467 | isAttr: true,
|
4468 | type: "Real"
|
4469 | }, {
|
4470 | name: "y",
|
4471 | isAttr: true,
|
4472 | type: "Real"
|
4473 | }]
|
4474 | }, {
|
4475 | name: "Point",
|
4476 | properties: [{
|
4477 | name: "x",
|
4478 | isAttr: true,
|
4479 | type: "Real"
|
4480 | }, {
|
4481 | name: "y",
|
4482 | isAttr: true,
|
4483 | type: "Real"
|
4484 | }]
|
4485 | }, {
|
4486 | name: "Color",
|
4487 | properties: [{
|
4488 | name: "red",
|
4489 | type: "UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"
|
4490 | }, {
|
4491 | name: "green",
|
4492 | type: "UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"
|
4493 | }, {
|
4494 | name: "blue",
|
4495 | type: "UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"
|
4496 | }]
|
4497 | }];
|
4498 | var associations = [];
|
4499 | var enumerations = [{
|
4500 | name: "AlignmentKind",
|
4501 | literalValues: [{
|
4502 | name: "start"
|
4503 | }, {
|
4504 | name: "center"
|
4505 | }, {
|
4506 | name: "end"
|
4507 | }]
|
4508 | }];
|
4509 | var DcPackage = {
|
4510 | name: name,
|
4511 | prefix: prefix,
|
4512 | uri: uri,
|
4513 | types: types,
|
4514 | associations: associations,
|
4515 | enumerations: enumerations
|
4516 | };
|
4517 | var name$1 = "DI";
|
4518 | var prefix$1 = "di";
|
4519 | var uri$1 = "http://www.omg.org/spec/DMN/20180521/DI/";
|
4520 | var types$1 = [{
|
4521 | name: "DiagramElement",
|
4522 | isAbstract: true,
|
4523 | properties: [{
|
4524 | name: "id",
|
4525 | isAttr: true,
|
4526 | isId: true,
|
4527 | type: "String"
|
4528 | }, {
|
4529 | name: "style",
|
4530 | isReference: true,
|
4531 | type: "Style",
|
4532 | xml: {
|
4533 | serialize: "property"
|
4534 | }
|
4535 | }, {
|
4536 | name: "sharedStyle",
|
4537 | isReference: true,
|
4538 | isVirtual: true,
|
4539 | type: "Style"
|
4540 | }]
|
4541 | }, {
|
4542 | name: "Diagram",
|
4543 | superClass: ["DiagramElement"],
|
4544 | properties: [{
|
4545 | name: "name",
|
4546 | isAttr: true,
|
4547 | type: "String"
|
4548 | }, {
|
4549 | name: "documentation",
|
4550 | isAttr: true,
|
4551 | type: "String"
|
4552 | }, {
|
4553 | name: "resolution",
|
4554 | isAttr: true,
|
4555 | type: "Real"
|
4556 | }]
|
4557 | }, {
|
4558 | name: "Shape",
|
4559 | isAbstract: true,
|
4560 | properties: [{
|
4561 | name: "bounds",
|
4562 | type: "dc:Bounds"
|
4563 | }],
|
4564 | superClass: ["DiagramElement"]
|
4565 | }, {
|
4566 | name: "Edge",
|
4567 | isAbstract: true,
|
4568 | properties: [{
|
4569 | name: "waypoint",
|
4570 | type: "dc:Point",
|
4571 | isMany: true,
|
4572 | xml: {
|
4573 | serialize: "property"
|
4574 | }
|
4575 | }],
|
4576 | superClass: ["DiagramElement"]
|
4577 | }, {
|
4578 | name: "Style",
|
4579 | isAbstract: true,
|
4580 | properties: [{
|
4581 | name: "id",
|
4582 | isAttr: true,
|
4583 | isId: true,
|
4584 | type: "String"
|
4585 | }]
|
4586 | }];
|
4587 | var associations$1 = [];
|
4588 | var enumerations$1 = [];
|
4589 | var xml = {
|
4590 | tagAlias: "lowerCase"
|
4591 | };
|
4592 | var DiPackage = {
|
4593 | name: name$1,
|
4594 | prefix: prefix$1,
|
4595 | uri: uri$1,
|
4596 | types: types$1,
|
4597 | associations: associations$1,
|
4598 | enumerations: enumerations$1,
|
4599 | xml: xml
|
4600 | };
|
4601 | var name$2 = "DMN";
|
4602 | var prefix$2 = "dmn";
|
4603 | var uri$2 = "https://www.omg.org/spec/DMN/20191111/MODEL/";
|
4604 | var types$2 = [{
|
4605 | name: "AuthorityRequirement",
|
4606 | superClass: ["DMNElement"],
|
4607 | properties: [{
|
4608 | name: "requiredAuthority",
|
4609 | type: "DMNElementReference",
|
4610 | xml: {
|
4611 | serialize: "property"
|
4612 | }
|
4613 | }, {
|
4614 | name: "requiredDecision",
|
4615 | type: "DMNElementReference",
|
4616 | xml: {
|
4617 | serialize: "property"
|
4618 | }
|
4619 | }, {
|
4620 | name: "requiredInput",
|
4621 | type: "DMNElementReference",
|
4622 | xml: {
|
4623 | serialize: "property"
|
4624 | }
|
4625 | }]
|
4626 | }, {
|
4627 | name: "ItemDefinition",
|
4628 | superClass: ["NamedElement"],
|
4629 | properties: [{
|
4630 | name: "typeRef",
|
4631 | type: "String"
|
4632 | }, {
|
4633 | name: "allowedValues",
|
4634 | type: "UnaryTests",
|
4635 | xml: {
|
4636 | serialize: "property"
|
4637 | }
|
4638 | }, {
|
4639 | name: "typeLanguage",
|
4640 | type: "String",
|
4641 | isAttr: true
|
4642 | }, {
|
4643 | name: "itemComponent",
|
4644 | type: "ItemDefinition",
|
4645 | isMany: true,
|
4646 | xml: {
|
4647 | serialize: "property"
|
4648 | }
|
4649 | }, {
|
4650 | name: "functionItem",
|
4651 | type: "FunctionItem"
|
4652 | }, {
|
4653 | name: "isCollection",
|
4654 | isAttr: true,
|
4655 | type: "Boolean"
|
4656 | }]
|
4657 | }, {
|
4658 | name: "Definitions",
|
4659 | superClass: ["NamedElement"],
|
4660 | properties: [{
|
4661 | name: "import",
|
4662 | type: "Import",
|
4663 | isMany: true
|
4664 | }, {
|
4665 | name: "itemDefinition",
|
4666 | type: "ItemDefinition",
|
4667 | isMany: true
|
4668 | }, {
|
4669 | name: "drgElement",
|
4670 | type: "DRGElement",
|
4671 | isMany: true
|
4672 | }, {
|
4673 | name: "artifact",
|
4674 | type: "Artifact",
|
4675 | isMany: true
|
4676 | }, {
|
4677 | name: "elementCollection",
|
4678 | type: "ElementCollection",
|
4679 | isMany: true
|
4680 | }, {
|
4681 | name: "businessContextElement",
|
4682 | type: "BusinessContextElement",
|
4683 | isMany: true
|
4684 | }, {
|
4685 | name: "namespace",
|
4686 | type: "String",
|
4687 | isAttr: true
|
4688 | }, {
|
4689 | name: "expressionLanguage",
|
4690 | type: "String",
|
4691 | isAttr: true
|
4692 | }, {
|
4693 | name: "typeLanguage",
|
4694 | type: "String",
|
4695 | isAttr: true
|
4696 | }, {
|
4697 | name: "exporter",
|
4698 | isAttr: true,
|
4699 | type: "String"
|
4700 | }, {
|
4701 | name: "exporterVersion",
|
4702 | isAttr: true,
|
4703 | type: "String"
|
4704 | }, {
|
4705 | name: "dmnDI",
|
4706 | type: "dmndi:DMNDI"
|
4707 | }]
|
4708 | }, {
|
4709 | name: "KnowledgeSource",
|
4710 | superClass: ["DRGElement"],
|
4711 | properties: [{
|
4712 | name: "authorityRequirement",
|
4713 | type: "AuthorityRequirement",
|
4714 | isMany: true
|
4715 | }, {
|
4716 | name: "type",
|
4717 | type: "String"
|
4718 | }, {
|
4719 | name: "owner",
|
4720 | type: "DMNElementReference",
|
4721 | xml: {
|
4722 | serialize: "property"
|
4723 | }
|
4724 | }, {
|
4725 | name: "locationURI",
|
4726 | type: "String",
|
4727 | isAttr: true
|
4728 | }]
|
4729 | }, {
|
4730 | name: "DecisionRule",
|
4731 | superClass: ["DMNElement"],
|
4732 | properties: [{
|
4733 | name: "inputEntry",
|
4734 | type: "UnaryTests",
|
4735 | isMany: true,
|
4736 | xml: {
|
4737 | serialize: "property"
|
4738 | }
|
4739 | }, {
|
4740 | name: "outputEntry",
|
4741 | type: "LiteralExpression",
|
4742 | isMany: true,
|
4743 | xml: {
|
4744 | serialize: "property"
|
4745 | }
|
4746 | }, {
|
4747 | name: "annotationEntry",
|
4748 | type: "RuleAnnotation",
|
4749 | isMany: true,
|
4750 | xml: {
|
4751 | serialize: "property"
|
4752 | }
|
4753 | }]
|
4754 | }, {
|
4755 | name: "Expression",
|
4756 | isAbstract: true,
|
4757 | superClass: ["DMNElement"],
|
4758 | properties: [{
|
4759 | name: "typeRef",
|
4760 | isAttr: true,
|
4761 | type: "String"
|
4762 | }]
|
4763 | }, {
|
4764 | name: "InformationItem",
|
4765 | superClass: ["NamedElement"],
|
4766 | properties: [{
|
4767 | name: "typeRef",
|
4768 | isAttr: true,
|
4769 | type: "String"
|
4770 | }]
|
4771 | }, {
|
4772 | name: "Decision",
|
4773 | superClass: ["DRGElement"],
|
4774 | properties: [{
|
4775 | name: "question",
|
4776 | type: "String",
|
4777 | xml: {
|
4778 | serialize: "property"
|
4779 | }
|
4780 | }, {
|
4781 | name: "allowedAnswers",
|
4782 | type: "String",
|
4783 | xml: {
|
4784 | serialize: "property"
|
4785 | }
|
4786 | }, {
|
4787 | name: "variable",
|
4788 | type: "InformationItem",
|
4789 | xml: {
|
4790 | serialize: "property"
|
4791 | }
|
4792 | }, {
|
4793 | name: "informationRequirement",
|
4794 | type: "InformationRequirement",
|
4795 | isMany: true
|
4796 | }, {
|
4797 | name: "knowledgeRequirement",
|
4798 | type: "KnowledgeRequirement",
|
4799 | isMany: true
|
4800 | }, {
|
4801 | name: "authorityRequirement",
|
4802 | type: "AuthorityRequirement",
|
4803 | isMany: true
|
4804 | }, {
|
4805 | name: "supportedObjective",
|
4806 | isMany: true,
|
4807 | type: "DMNElementReference",
|
4808 | xml: {
|
4809 | serialize: "property"
|
4810 | }
|
4811 | }, {
|
4812 | name: "impactedPerformanceIndicator",
|
4813 | type: "DMNElementReference",
|
4814 | isMany: true,
|
4815 | xml: {
|
4816 | serialize: "property"
|
4817 | }
|
4818 | }, {
|
4819 | name: "decisionMaker",
|
4820 | type: "DMNElementReference",
|
4821 | isMany: true,
|
4822 | xml: {
|
4823 | serialize: "property"
|
4824 | }
|
4825 | }, {
|
4826 | name: "decisionOwner",
|
4827 | type: "DMNElementReference",
|
4828 | isMany: true,
|
4829 | xml: {
|
4830 | serialize: "property"
|
4831 | }
|
4832 | }, {
|
4833 | name: "usingProcess",
|
4834 | isMany: true,
|
4835 | type: "DMNElementReference",
|
4836 | xml: {
|
4837 | serialize: "property"
|
4838 | }
|
4839 | }, {
|
4840 | name: "usingTask",
|
4841 | isMany: true,
|
4842 | type: "DMNElementReference",
|
4843 | xml: {
|
4844 | serialize: "property"
|
4845 | }
|
4846 | }, {
|
4847 | name: "decisionLogic",
|
4848 | type: "Expression"
|
4849 | }]
|
4850 | }, {
|
4851 | name: "Invocation",
|
4852 | superClass: ["Expression"],
|
4853 | properties: [{
|
4854 | name: "calledFunction",
|
4855 | type: "Expression"
|
4856 | }, {
|
4857 | name: "binding",
|
4858 | type: "Binding",
|
4859 | isMany: true
|
4860 | }]
|
4861 | }, {
|
4862 | name: "OrganisationalUnit",
|
4863 | superClass: ["BusinessContextElement"],
|
4864 | properties: [{
|
4865 | name: "decisionMade",
|
4866 | type: "Decision",
|
4867 | isReference: true,
|
4868 | isMany: true
|
4869 | }, {
|
4870 | name: "decisionOwned",
|
4871 | type: "Decision",
|
4872 | isReference: true,
|
4873 | isMany: true
|
4874 | }]
|
4875 | }, {
|
4876 | name: "Import",
|
4877 | superClass: ["NamedElement"],
|
4878 | properties: [{
|
4879 | name: "importType",
|
4880 | type: "String",
|
4881 | isAttr: true
|
4882 | }, {
|
4883 | name: "locationURI",
|
4884 | type: "String",
|
4885 | isAttr: true
|
4886 | }, {
|
4887 | name: "namespace",
|
4888 | type: "String",
|
4889 | isAttr: true
|
4890 | }]
|
4891 | }, {
|
4892 | name: "InformationRequirement",
|
4893 | superClass: ["DMNElement"],
|
4894 | properties: [{
|
4895 | name: "requiredDecision",
|
4896 | type: "DMNElementReference",
|
4897 | xml: {
|
4898 | serialize: "property"
|
4899 | }
|
4900 | }, {
|
4901 | name: "requiredInput",
|
4902 | type: "DMNElementReference",
|
4903 | xml: {
|
4904 | serialize: "property"
|
4905 | }
|
4906 | }]
|
4907 | }, {
|
4908 | name: "ElementCollection",
|
4909 | superClass: ["NamedElement"],
|
4910 | properties: [{
|
4911 | name: "drgElement",
|
4912 | type: "DMNElementReference",
|
4913 | isMany: true,
|
4914 | xml: {
|
4915 | serialize: "property"
|
4916 | }
|
4917 | }]
|
4918 | }, {
|
4919 | name: "DRGElement",
|
4920 | isAbstract: true,
|
4921 | superClass: ["NamedElement"],
|
4922 | properties: []
|
4923 | }, {
|
4924 | name: "InputData",
|
4925 | superClass: ["DRGElement"],
|
4926 | properties: [{
|
4927 | name: "variable",
|
4928 | type: "InformationItem",
|
4929 | xml: {
|
4930 | serialize: "property"
|
4931 | }
|
4932 | }]
|
4933 | }, {
|
4934 | name: "DMNElement",
|
4935 | isAbstract: true,
|
4936 | properties: [{
|
4937 | name: "description",
|
4938 | type: "String"
|
4939 | }, {
|
4940 | name: "extensionElements",
|
4941 | type: "ExtensionElements"
|
4942 | }, {
|
4943 | name: "id",
|
4944 | type: "String",
|
4945 | isAttr: true,
|
4946 | isId: true
|
4947 | }, {
|
4948 | name: "extensionAttribute",
|
4949 | type: "ExtensionAttribute",
|
4950 | isMany: true
|
4951 | }, {
|
4952 | name: "label",
|
4953 | isAttr: true,
|
4954 | type: "String"
|
4955 | }]
|
4956 | }, {
|
4957 | name: "InputClause",
|
4958 | superClass: ["DMNElement"],
|
4959 | properties: [{
|
4960 | name: "inputExpression",
|
4961 | type: "LiteralExpression",
|
4962 | xml: {
|
4963 | serialize: "property"
|
4964 | }
|
4965 | }, {
|
4966 | name: "inputValues",
|
4967 | type: "UnaryTests",
|
4968 | xml: {
|
4969 | serialize: "property"
|
4970 | }
|
4971 | }]
|
4972 | }, {
|
4973 | name: "DecisionTable",
|
4974 | superClass: ["Expression"],
|
4975 | properties: [{
|
4976 | name: "input",
|
4977 | type: "InputClause",
|
4978 | isMany: true,
|
4979 | xml: {
|
4980 | serialize: "property"
|
4981 | }
|
4982 | }, {
|
4983 | name: "output",
|
4984 | type: "OutputClause",
|
4985 | isMany: true,
|
4986 | xml: {
|
4987 | serialize: "property"
|
4988 | }
|
4989 | }, {
|
4990 | name: "annotation",
|
4991 | type: "RuleAnnotationClause",
|
4992 | isMany: true,
|
4993 | xml: {
|
4994 | serialize: "property"
|
4995 | }
|
4996 | }, {
|
4997 | name: "rule",
|
4998 | type: "DecisionRule",
|
4999 | isMany: true,
|
5000 | xml: {
|
5001 | serialize: "property"
|
5002 | }
|
5003 | }, {
|
5004 | name: "hitPolicy",
|
5005 | type: "HitPolicy",
|
5006 | isAttr: true,
|
5007 | "default": "UNIQUE"
|
5008 | }, {
|
5009 | name: "aggregation",
|
5010 | type: "BuiltinAggregator",
|
5011 | isAttr: true
|
5012 | }, {
|
5013 | name: "preferredOrientation",
|
5014 | type: "DecisionTableOrientation",
|
5015 | isAttr: true
|
5016 | }, {
|
5017 | name: "outputLabel",
|
5018 | isAttr: true,
|
5019 | type: "String"
|
5020 | }]
|
5021 | }, {
|
5022 | name: "LiteralExpression",
|
5023 | superClass: ["Expression"],
|
5024 | properties: [{
|
5025 | name: "expressionLanguage",
|
5026 | type: "String",
|
5027 | isAttr: true
|
5028 | }, {
|
5029 | name: "text",
|
5030 | type: "String"
|
5031 | }, {
|
5032 | name: "importedValues",
|
5033 | type: "ImportedValues"
|
5034 | }]
|
5035 | }, {
|
5036 | name: "Binding",
|
5037 | properties: [{
|
5038 | name: "parameter",
|
5039 | type: "InformationItem",
|
5040 | xml: {
|
5041 | serialize: "property"
|
5042 | }
|
5043 | }, {
|
5044 | name: "bindingFormula",
|
5045 | type: "Expression"
|
5046 | }]
|
5047 | }, {
|
5048 | name: "KnowledgeRequirement",
|
5049 | superClass: ["DMNElement"],
|
5050 | properties: [{
|
5051 | name: "requiredKnowledge",
|
5052 | type: "DMNElementReference",
|
5053 | xml: {
|
5054 | serialize: "property"
|
5055 | }
|
5056 | }]
|
5057 | }, {
|
5058 | name: "BusinessKnowledgeModel",
|
5059 | superClass: ["Invocable"],
|
5060 | properties: [{
|
5061 | name: "encapsulatedLogic",
|
5062 | type: "FunctionDefinition",
|
5063 | xml: {
|
5064 | serialize: "property"
|
5065 | }
|
5066 | }, {
|
5067 | name: "knowledgeRequirement",
|
5068 | type: "KnowledgeRequirement",
|
5069 | isMany: true
|
5070 | }, {
|
5071 | name: "authorityRequirement",
|
5072 | type: "AuthorityRequirement",
|
5073 | isMany: true
|
5074 | }]
|
5075 | }, {
|
5076 | name: "BusinessContextElement",
|
5077 | isAbstract: true,
|
5078 | superClass: ["NamedElement"],
|
5079 | properties: [{
|
5080 | name: "URI",
|
5081 | type: "String",
|
5082 | isAttr: true
|
5083 | }]
|
5084 | }, {
|
5085 | name: "PerformanceIndicator",
|
5086 | superClass: ["BusinessContextElement"],
|
5087 | properties: [{
|
5088 | name: "impactingDecision",
|
5089 | type: "DMNElementReference",
|
5090 | isMany: true,
|
5091 | xml: {
|
5092 | serialize: "property"
|
5093 | }
|
5094 | }]
|
5095 | }, {
|
5096 | name: "FunctionDefinition",
|
5097 | superClass: ["Expression"],
|
5098 | properties: [{
|
5099 | name: "formalParameter",
|
5100 | type: "InformationItem",
|
5101 | isMany: true,
|
5102 | xml: {
|
5103 | serialize: "property"
|
5104 | }
|
5105 | }, {
|
5106 | name: "body",
|
5107 | type: "Expression"
|
5108 | }, {
|
5109 | name: "kind",
|
5110 | type: "FunctionKind",
|
5111 | isAttr: true
|
5112 | }]
|
5113 | }, {
|
5114 | name: "Context",
|
5115 | superClass: ["Expression"],
|
5116 | properties: [{
|
5117 | name: "contextEntry",
|
5118 | type: "ContextEntry",
|
5119 | isMany: true
|
5120 | }]
|
5121 | }, {
|
5122 | name: "ContextEntry",
|
5123 | superClass: ["DMNElement"],
|
5124 | properties: [{
|
5125 | name: "variable",
|
5126 | type: "InformationItem",
|
5127 | xml: {
|
5128 | serialize: "property"
|
5129 | }
|
5130 | }, {
|
5131 | name: "value",
|
5132 | type: "Expression"
|
5133 | }]
|
5134 | }, {
|
5135 | name: "List",
|
5136 | superClass: ["Expression"],
|
5137 | properties: [{
|
5138 | name: "elements",
|
5139 | isMany: true,
|
5140 | type: "Expression"
|
5141 | }]
|
5142 | }, {
|
5143 | name: "Relation",
|
5144 | superClass: ["Expression"],
|
5145 | properties: [{
|
5146 | name: "column",
|
5147 | type: "InformationItem",
|
5148 | isMany: true,
|
5149 | xml: {
|
5150 | serialize: "property"
|
5151 | }
|
5152 | }, {
|
5153 | name: "row",
|
5154 | type: "List",
|
5155 | isMany: true,
|
5156 | xml: {
|
5157 | serialize: "property"
|
5158 | }
|
5159 | }]
|
5160 | }, {
|
5161 | name: "OutputClause",
|
5162 | superClass: ["DMNElement"],
|
5163 | properties: [{
|
5164 | name: "outputValues",
|
5165 | type: "UnaryTests",
|
5166 | xml: {
|
5167 | serialize: "property"
|
5168 | }
|
5169 | }, {
|
5170 | name: "defaultOutputEntry",
|
5171 | type: "LiteralExpression",
|
5172 | xml: {
|
5173 | serialize: "property"
|
5174 | }
|
5175 | }, {
|
5176 | name: "name",
|
5177 | isAttr: true,
|
5178 | type: "String"
|
5179 | }, {
|
5180 | name: "typeRef",
|
5181 | isAttr: true,
|
5182 | type: "String"
|
5183 | }]
|
5184 | }, {
|
5185 | name: "UnaryTests",
|
5186 | superClass: ["Expression"],
|
5187 | properties: [{
|
5188 | name: "text",
|
5189 | type: "String"
|
5190 | }, {
|
5191 | name: "expressionLanguage",
|
5192 | type: "String",
|
5193 | isAttr: true
|
5194 | }]
|
5195 | }, {
|
5196 | name: "NamedElement",
|
5197 | isAbstract: true,
|
5198 | superClass: ["DMNElement"],
|
5199 | properties: [{
|
5200 | name: "name",
|
5201 | isAttr: true,
|
5202 | type: "String"
|
5203 | }]
|
5204 | }, {
|
5205 | name: "ImportedValues",
|
5206 | superClass: ["Import"],
|
5207 | properties: [{
|
5208 | name: "importedElement",
|
5209 | type: "String"
|
5210 | }, {
|
5211 | name: "expressionLanguage",
|
5212 | type: "String",
|
5213 | isAttr: true
|
5214 | }]
|
5215 | }, {
|
5216 | name: "DecisionService",
|
5217 | superClass: ["Invocable"],
|
5218 | properties: [{
|
5219 | name: "outputDecision",
|
5220 | type: "DMNElementReference",
|
5221 | isMany: true,
|
5222 | xml: {
|
5223 | serialize: "property"
|
5224 | }
|
5225 | }, {
|
5226 | name: "encapsulatedDecision",
|
5227 | type: "DMNElementReference",
|
5228 | isMany: true,
|
5229 | xml: {
|
5230 | serialize: "property"
|
5231 | }
|
5232 | }, {
|
5233 | name: "inputDecision",
|
5234 | type: "DMNElementReference",
|
5235 | isMany: true,
|
5236 | xml: {
|
5237 | serialize: "property"
|
5238 | }
|
5239 | }, {
|
5240 | name: "inputData",
|
5241 | type: "DMNElementReference",
|
5242 | isMany: true,
|
5243 | xml: {
|
5244 | serialize: "property"
|
5245 | }
|
5246 | }]
|
5247 | }, {
|
5248 | name: "ExtensionElements",
|
5249 | properties: [{
|
5250 | name: "values",
|
5251 | type: "Element",
|
5252 | isMany: true
|
5253 | }]
|
5254 | }, {
|
5255 | name: "ExtensionAttribute",
|
5256 | properties: [{
|
5257 | name: "value",
|
5258 | type: "Element"
|
5259 | }, {
|
5260 | name: "valueRef",
|
5261 | type: "Element",
|
5262 | isAttr: true,
|
5263 | isReference: true
|
5264 | }, {
|
5265 | name: "name",
|
5266 | isAttr: true,
|
5267 | type: "String"
|
5268 | }]
|
5269 | }, {
|
5270 | name: "Element",
|
5271 | isAbstract: true,
|
5272 | properties: [{
|
5273 | name: "extensionAttribute",
|
5274 | type: "ExtensionAttribute",
|
5275 | isAttr: true,
|
5276 | isReference: true
|
5277 | }, {
|
5278 | name: "elements",
|
5279 | type: "ExtensionElements",
|
5280 | isAttr: true,
|
5281 | isReference: true
|
5282 | }]
|
5283 | }, {
|
5284 | name: "Artifact",
|
5285 | isAbstract: true,
|
5286 | superClass: ["DMNElement"],
|
5287 | properties: []
|
5288 | }, {
|
5289 | name: "Association",
|
5290 | superClass: ["Artifact"],
|
5291 | properties: [{
|
5292 | name: "sourceRef",
|
5293 | type: "DMNElementReference",
|
5294 | xml: {
|
5295 | serialize: "property"
|
5296 | }
|
5297 | }, {
|
5298 | name: "targetRef",
|
5299 | type: "DMNElementReference",
|
5300 | xml: {
|
5301 | serialize: "property"
|
5302 | }
|
5303 | }, {
|
5304 | name: "associationDirection",
|
5305 | type: "AssociationDirection",
|
5306 | isAttr: true
|
5307 | }]
|
5308 | }, {
|
5309 | name: "TextAnnotation",
|
5310 | superClass: ["Artifact"],
|
5311 | properties: [{
|
5312 | name: "text",
|
5313 | type: "String"
|
5314 | }, {
|
5315 | name: "textFormat",
|
5316 | isAttr: true,
|
5317 | type: "String",
|
5318 | "default": "text/plain"
|
5319 | }]
|
5320 | }, {
|
5321 | name: "RuleAnnotationClause",
|
5322 | properties: [{
|
5323 | name: "name",
|
5324 | isAttr: true,
|
5325 | type: "String"
|
5326 | }]
|
5327 | }, {
|
5328 | name: "RuleAnnotation",
|
5329 | properties: [{
|
5330 | name: "text",
|
5331 | type: "String"
|
5332 | }]
|
5333 | }, {
|
5334 | name: "Invocable",
|
5335 | isAbstract: true,
|
5336 | superClass: ["DRGElement"],
|
5337 | properties: [{
|
5338 | name: "variable",
|
5339 | type: "InformationItem",
|
5340 | xml: {
|
5341 | serialize: "property"
|
5342 | }
|
5343 | }]
|
5344 | }, {
|
5345 | name: "Group",
|
5346 | superClass: ["Artifact"],
|
5347 | properties: [{
|
5348 | name: "name",
|
5349 | isAttr: true,
|
5350 | type: "String"
|
5351 | }]
|
5352 | }, {
|
5353 | name: "FunctionItem",
|
5354 | superClass: ["DMNElement"],
|
5355 | properties: [{
|
5356 | name: "parameters",
|
5357 | isMany: true,
|
5358 | type: "InformationItem",
|
5359 | xml: {
|
5360 | serialize: "property"
|
5361 | }
|
5362 | }, {
|
5363 | name: "outputTypeRef",
|
5364 | isAttr: true,
|
5365 | type: "String"
|
5366 | }]
|
5367 | }, {
|
5368 | name: "DMNElementReference",
|
5369 | properties: [{
|
5370 | isAttr: true,
|
5371 | name: "href",
|
5372 | type: "String"
|
5373 | }]
|
5374 | }];
|
5375 | var enumerations$2 = [{
|
5376 | name: "HitPolicy",
|
5377 | literalValues: [{
|
5378 | name: "UNIQUE"
|
5379 | }, {
|
5380 | name: "FIRST"
|
5381 | }, {
|
5382 | name: "PRIORITY"
|
5383 | }, {
|
5384 | name: "ANY"
|
5385 | }, {
|
5386 | name: "COLLECT"
|
5387 | }, {
|
5388 | name: "RULE ORDER"
|
5389 | }, {
|
5390 | name: "OUTPUT ORDER"
|
5391 | }]
|
5392 | }, {
|
5393 | name: "BuiltinAggregator",
|
5394 | literalValues: [{
|
5395 | name: "SUM"
|
5396 | }, {
|
5397 | name: "COUNT"
|
5398 | }, {
|
5399 | name: "MIN"
|
5400 | }, {
|
5401 | name: "MAX"
|
5402 | }]
|
5403 | }, {
|
5404 | name: "DecisionTableOrientation",
|
5405 | literalValues: [{
|
5406 | name: "Rule-as-Row"
|
5407 | }, {
|
5408 | name: "Rule-as-Column"
|
5409 | }, {
|
5410 | name: "CrossTable"
|
5411 | }]
|
5412 | }, {
|
5413 | name: "AssociationDirection",
|
5414 | literalValues: [{
|
5415 | name: "None"
|
5416 | }, {
|
5417 | name: "One"
|
5418 | }, {
|
5419 | name: "Both"
|
5420 | }]
|
5421 | }, {
|
5422 | name: "FunctionKind",
|
5423 | literalValues: [{
|
5424 | name: "FEEL"
|
5425 | }, {
|
5426 | name: "Java"
|
5427 | }, {
|
5428 | name: "PMML"
|
5429 | }]
|
5430 | }];
|
5431 | var associations$2 = [];
|
5432 | var xml$1 = {
|
5433 | tagAlias: "lowerCase"
|
5434 | };
|
5435 | var DmnPackage = {
|
5436 | name: name$2,
|
5437 | prefix: prefix$2,
|
5438 | uri: uri$2,
|
5439 | types: types$2,
|
5440 | enumerations: enumerations$2,
|
5441 | associations: associations$2,
|
5442 | xml: xml$1
|
5443 | };
|
5444 | var name$3 = "DMNDI";
|
5445 | var prefix$3 = "dmndi";
|
5446 | var uri$3 = "https://www.omg.org/spec/DMN/20191111/DMNDI/";
|
5447 | var types$3 = [{
|
5448 | name: "DMNDI",
|
5449 | properties: [{
|
5450 | name: "diagrams",
|
5451 | type: "DMNDiagram",
|
5452 | isMany: true
|
5453 | }, {
|
5454 | name: "styles",
|
5455 | type: "DMNStyle",
|
5456 | isMany: true
|
5457 | }]
|
5458 | }, {
|
5459 | name: "DMNStyle",
|
5460 | superClass: ["di:Style"],
|
5461 | properties: [{
|
5462 | name: "fillColor",
|
5463 | type: "dc:Color",
|
5464 | isAttr: true
|
5465 | }, {
|
5466 | name: "strokeColor",
|
5467 | type: "dc:Color",
|
5468 | isAttr: true
|
5469 | }, {
|
5470 | name: "fontColor",
|
5471 | type: "dc:Color",
|
5472 | isAttr: true
|
5473 | }, {
|
5474 | name: "fontSize",
|
5475 | isAttr: true,
|
5476 | type: "Real"
|
5477 | }, {
|
5478 | name: "fontFamily",
|
5479 | isAttr: true,
|
5480 | type: "String"
|
5481 | }, {
|
5482 | name: "fontItalic",
|
5483 | isAttr: true,
|
5484 | type: "Boolean"
|
5485 | }, {
|
5486 | name: "fontBold",
|
5487 | isAttr: true,
|
5488 | type: "Boolean"
|
5489 | }, {
|
5490 | name: "fontUnderline",
|
5491 | isAttr: true,
|
5492 | type: "Boolean"
|
5493 | }, {
|
5494 | name: "fontStrikeThrough",
|
5495 | isAttr: true,
|
5496 | type: "Boolean"
|
5497 | }, {
|
5498 | name: "labelHorizontalAlignment",
|
5499 | type: "dc:AlignmentKind",
|
5500 | isAttr: true
|
5501 | }, {
|
5502 | name: "labelVerticalAlignment",
|
5503 | type: "dc:AlignmentKind",
|
5504 | isAttr: true
|
5505 | }]
|
5506 | }, {
|
5507 | name: "DMNDiagram",
|
5508 | superClass: ["di:Diagram"],
|
5509 | properties: [{
|
5510 | name: "dmnElementRef",
|
5511 | type: "dmn:DMNElement",
|
5512 | isAttr: true,
|
5513 | isReference: true
|
5514 | }, {
|
5515 | name: "size",
|
5516 | type: "Size"
|
5517 | }, {
|
5518 | name: "localStyle",
|
5519 | type: "DMNStyle",
|
5520 | isVirtual: true
|
5521 | }, {
|
5522 | name: "sharedStyle",
|
5523 | type: "DMNStyle",
|
5524 | isVirtual: true,
|
5525 | isReference: true,
|
5526 | redefines: "di:DiagramElement#sharedStyle"
|
5527 | }, {
|
5528 | name: "diagramElements",
|
5529 | type: "DMNDiagramElement",
|
5530 | isMany: true
|
5531 | }]
|
5532 | }, {
|
5533 | name: "DMNDiagramElement",
|
5534 | isAbstract: true,
|
5535 | superClass: ["di:DiagramElement"],
|
5536 | properties: [{
|
5537 | name: "dmnElementRef",
|
5538 | type: "dmn:DMNElement",
|
5539 | isAttr: true,
|
5540 | isReference: true
|
5541 | }, {
|
5542 | name: "sharedStyle",
|
5543 | type: "DMNStyle",
|
5544 | isVirtual: true,
|
5545 | isReference: true,
|
5546 | redefines: "di:DiagramElement#sharedStyle"
|
5547 | }, {
|
5548 | name: "localStyle",
|
5549 | type: "DMNStyle",
|
5550 | isVirtual: true
|
5551 | }, {
|
5552 | name: "label",
|
5553 | type: "DMNLabel"
|
5554 | }]
|
5555 | }, {
|
5556 | name: "DMNLabel",
|
5557 | superClass: ["di:Shape"],
|
5558 | properties: [{
|
5559 | name: "text",
|
5560 | type: "Text"
|
5561 | }]
|
5562 | }, {
|
5563 | name: "DMNShape",
|
5564 | superClass: ["di:Shape", "DMNDiagramElement"],
|
5565 | properties: [{
|
5566 | name: "isListedInputData",
|
5567 | isAttr: true,
|
5568 | type: "Boolean"
|
5569 | }, {
|
5570 | name: "decisionServiceDividerLine",
|
5571 | type: "DMNDecisionServiceDividerLine"
|
5572 | }, {
|
5573 | name: "isCollapsed",
|
5574 | isAttr: true,
|
5575 | type: "Boolean"
|
5576 | }]
|
5577 | }, {
|
5578 | name: "DMNEdge",
|
5579 | superClass: ["di:Edge", "DMNDiagramElement"],
|
5580 | properties: [{
|
5581 | name: "sourceElement",
|
5582 | type: "DMNDiagramElement",
|
5583 | isAttr: true,
|
5584 | isReference: true
|
5585 | }, {
|
5586 | name: "targetElement",
|
5587 | type: "DMNDiagramElement",
|
5588 | isAttr: true,
|
5589 | isReference: true
|
5590 | }]
|
5591 | }, {
|
5592 | name: "DMNDecisionServiceDividerLine",
|
5593 | superClass: ["di:Edge"]
|
5594 | }, {
|
5595 | name: "Text",
|
5596 | properties: [{
|
5597 | name: "text",
|
5598 | isBody: true,
|
5599 | type: "String"
|
5600 | }]
|
5601 | }, {
|
5602 | name: "Size",
|
5603 | superClass: ["dc:Dimension"]
|
5604 | }];
|
5605 | var associations$3 = [];
|
5606 | var enumerations$3 = [];
|
5607 | var DmnDiPackage = {
|
5608 | name: name$3,
|
5609 | prefix: prefix$3,
|
5610 | uri: uri$3,
|
5611 | types: types$3,
|
5612 | associations: associations$3,
|
5613 | enumerations: enumerations$3
|
5614 | };
|
5615 | var name$4 = "bpmn.io DI for DMN";
|
5616 | var uri$4 = "http://bpmn.io/schema/dmn/biodi/2.0";
|
5617 | var prefix$4 = "biodi";
|
5618 | var xml$2 = {
|
5619 | tagAlias: "lowerCase"
|
5620 | };
|
5621 | var types$4 = [{
|
5622 | name: "DecisionTable",
|
5623 | isAbstract: true,
|
5624 | "extends": ["dmn:DecisionTable"],
|
5625 | properties: [{
|
5626 | name: "annotationsWidth",
|
5627 | isAttr: true,
|
5628 | type: "Integer"
|
5629 | }]
|
5630 | }, {
|
5631 | name: "OutputClause",
|
5632 | isAbstract: true,
|
5633 | "extends": ["dmn:OutputClause"],
|
5634 | properties: [{
|
5635 | name: "width",
|
5636 | isAttr: true,
|
5637 | type: "Integer"
|
5638 | }]
|
5639 | }, {
|
5640 | name: "InputClause",
|
5641 | isAbstract: true,
|
5642 | "extends": ["dmn:InputClause"],
|
5643 | properties: [{
|
5644 | name: "width",
|
5645 | isAttr: true,
|
5646 | type: "Integer"
|
5647 | }]
|
5648 | }];
|
5649 | var BioDiPackage = {
|
5650 | name: name$4,
|
5651 | uri: uri$4,
|
5652 | prefix: prefix$4,
|
5653 | xml: xml$2,
|
5654 | types: types$4
|
5655 | };
|
5656 | var packages = {
|
5657 | dc: DcPackage,
|
5658 | di: DiPackage,
|
5659 | dmn: DmnPackage,
|
5660 | dmndi: DmnDiPackage,
|
5661 | biodi: BioDiPackage
|
5662 | };
|
5663 |
|
5664 | function simple(additionalPackages, options) {
|
5665 | var pks = assign({}, packages, additionalPackages);
|
5666 | return new DmnModdle(pks, options);
|
5667 | }
|
5668 |
|
5669 | var name$5 = "Camunda";
|
5670 | var uri$5 = "http://camunda.org/schema/1.0/dmn";
|
5671 | var prefix$5 = "camunda";
|
5672 | var xml$3 = {
|
5673 | tagAlias: "lowerCase"
|
5674 | };
|
5675 | var associations$4 = [
|
5676 | ];
|
5677 | var types$5 = [
|
5678 | {
|
5679 | name: "Decision",
|
5680 | isAbstract: true,
|
5681 | "extends": [
|
5682 | "dmn:Decision"
|
5683 | ],
|
5684 | properties: [
|
5685 | {
|
5686 | name: "versionTag",
|
5687 | isAttr: true,
|
5688 | type: "String"
|
5689 | },
|
5690 | {
|
5691 | name: "historyTimeToLive",
|
5692 | isAttr: true,
|
5693 | type: "String"
|
5694 | }
|
5695 | ]
|
5696 | },
|
5697 | {
|
5698 | name: "InputClause",
|
5699 | "extends": [
|
5700 | "dmn:InputClause"
|
5701 | ],
|
5702 | properties: [
|
5703 | {
|
5704 | name: "inputVariable",
|
5705 | isAttr: true,
|
5706 | type: "String"
|
5707 | }
|
5708 | ]
|
5709 | }
|
5710 | ];
|
5711 | var emumerations = [
|
5712 | ];
|
5713 | var CamundaModdle = {
|
5714 | name: name$5,
|
5715 | uri: uri$5,
|
5716 | prefix: prefix$5,
|
5717 | xml: xml$3,
|
5718 | associations: associations$4,
|
5719 | types: types$5,
|
5720 | emumerations: emumerations
|
5721 | };
|
5722 |
|
5723 | |
5724 |
|
5725 |
|
5726 |
|
5727 |
|
5728 |
|
5729 |
|
5730 |
|
5731 | function attr(el, name, val) {
|
5732 |
|
5733 | if (arguments.length == 2) {
|
5734 | return el.getAttribute(name);
|
5735 | }
|
5736 |
|
5737 |
|
5738 | if (val === null) {
|
5739 | return el.removeAttribute(name);
|
5740 | }
|
5741 |
|
5742 |
|
5743 | el.setAttribute(name, val);
|
5744 | return el;
|
5745 | }
|
5746 |
|
5747 | var indexOf = [].indexOf;
|
5748 |
|
5749 | var indexof = function indexof(arr, obj) {
|
5750 | if (indexOf) return arr.indexOf(obj);
|
5751 |
|
5752 | for (var i = 0; i < arr.length; ++i) {
|
5753 | if (arr[i] === obj) return i;
|
5754 | }
|
5755 |
|
5756 | return -1;
|
5757 | };
|
5758 | |
5759 |
|
5760 |
|
5761 |
|
5762 |
|
5763 |
|
5764 | |
5765 |
|
5766 |
|
5767 |
|
5768 |
|
5769 | var re = /\s+/;
|
5770 | |
5771 |
|
5772 |
|
5773 |
|
5774 | var toString = Object.prototype.toString;
|
5775 | |
5776 |
|
5777 |
|
5778 |
|
5779 |
|
5780 |
|
5781 |
|
5782 |
|
5783 | function classes(el) {
|
5784 | return new ClassList(el);
|
5785 | }
|
5786 | |
5787 |
|
5788 |
|
5789 |
|
5790 |
|
5791 |
|
5792 |
|
5793 |
|
5794 | function ClassList(el) {
|
5795 | if (!el || !el.nodeType) {
|
5796 | throw new Error('A DOM element reference is required');
|
5797 | }
|
5798 |
|
5799 | this.el = el;
|
5800 | this.list = el.classList;
|
5801 | }
|
5802 | |
5803 |
|
5804 |
|
5805 |
|
5806 |
|
5807 |
|
5808 |
|
5809 |
|
5810 |
|
5811 | ClassList.prototype.add = function (name) {
|
5812 |
|
5813 | if (this.list) {
|
5814 | this.list.add(name);
|
5815 | return this;
|
5816 | }
|
5817 |
|
5818 |
|
5819 | var arr = this.array();
|
5820 | var i = indexof(arr, name);
|
5821 | if (!~i) arr.push(name);
|
5822 | this.el.className = arr.join(' ');
|
5823 | return this;
|
5824 | };
|
5825 | |
5826 |
|
5827 |
|
5828 |
|
5829 |
|
5830 |
|
5831 |
|
5832 |
|
5833 |
|
5834 |
|
5835 |
|
5836 | ClassList.prototype.remove = function (name) {
|
5837 | if ('[object RegExp]' == toString.call(name)) {
|
5838 | return this.removeMatching(name);
|
5839 | }
|
5840 |
|
5841 |
|
5842 | if (this.list) {
|
5843 | this.list.remove(name);
|
5844 | return this;
|
5845 | }
|
5846 |
|
5847 |
|
5848 | var arr = this.array();
|
5849 | var i = indexof(arr, name);
|
5850 | if (~i) arr.splice(i, 1);
|
5851 | this.el.className = arr.join(' ');
|
5852 | return this;
|
5853 | };
|
5854 | |
5855 |
|
5856 |
|
5857 |
|
5858 |
|
5859 |
|
5860 |
|
5861 |
|
5862 |
|
5863 | ClassList.prototype.removeMatching = function (re) {
|
5864 | var arr = this.array();
|
5865 |
|
5866 | for (var i = 0; i < arr.length; i++) {
|
5867 | if (re.test(arr[i])) {
|
5868 | this.remove(arr[i]);
|
5869 | }
|
5870 | }
|
5871 |
|
5872 | return this;
|
5873 | };
|
5874 | |
5875 |
|
5876 |
|
5877 |
|
5878 |
|
5879 |
|
5880 |
|
5881 |
|
5882 |
|
5883 |
|
5884 |
|
5885 |
|
5886 |
|
5887 | ClassList.prototype.toggle = function (name, force) {
|
5888 |
|
5889 | if (this.list) {
|
5890 | if ('undefined' !== typeof force) {
|
5891 | if (force !== this.list.toggle(name, force)) {
|
5892 | this.list.toggle(name);
|
5893 | }
|
5894 | } else {
|
5895 | this.list.toggle(name);
|
5896 | }
|
5897 |
|
5898 | return this;
|
5899 | }
|
5900 |
|
5901 |
|
5902 | if ('undefined' !== typeof force) {
|
5903 | if (!force) {
|
5904 | this.remove(name);
|
5905 | } else {
|
5906 | this.add(name);
|
5907 | }
|
5908 | } else {
|
5909 | if (this.has(name)) {
|
5910 | this.remove(name);
|
5911 | } else {
|
5912 | this.add(name);
|
5913 | }
|
5914 | }
|
5915 |
|
5916 | return this;
|
5917 | };
|
5918 | |
5919 |
|
5920 |
|
5921 |
|
5922 |
|
5923 |
|
5924 |
|
5925 |
|
5926 | ClassList.prototype.array = function () {
|
5927 | var className = this.el.getAttribute('class') || '';
|
5928 | var str = className.replace(/^\s+|\s+$/g, '');
|
5929 | var arr = str.split(re);
|
5930 | if ('' === arr[0]) arr.shift();
|
5931 | return arr;
|
5932 | };
|
5933 | |
5934 |
|
5935 |
|
5936 |
|
5937 |
|
5938 |
|
5939 |
|
5940 |
|
5941 |
|
5942 | ClassList.prototype.has = ClassList.prototype.contains = function (name) {
|
5943 | return this.list ? this.list.contains(name) : !!~indexof(this.array(), name);
|
5944 | };
|
5945 | |
5946 |
|
5947 |
|
5948 |
|
5949 |
|
5950 | function clear(el) {
|
5951 | var c;
|
5952 |
|
5953 | while (el.childNodes.length) {
|
5954 | c = el.childNodes[0];
|
5955 | el.removeChild(c);
|
5956 | }
|
5957 |
|
5958 | return el;
|
5959 | }
|
5960 |
|
5961 | var proto = typeof Element !== 'undefined' ? Element.prototype : {};
|
5962 | var vendor = proto.matches || proto.matchesSelector || proto.webkitMatchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector;
|
5963 | var matchesSelector = match;
|
5964 | |
5965 |
|
5966 |
|
5967 |
|
5968 |
|
5969 |
|
5970 |
|
5971 |
|
5972 |
|
5973 | function match(el, selector) {
|
5974 | if (!el || el.nodeType !== 1) return false;
|
5975 | if (vendor) return vendor.call(el, selector);
|
5976 | var nodes = el.parentNode.querySelectorAll(selector);
|
5977 |
|
5978 | for (var i = 0; i < nodes.length; i++) {
|
5979 | if (nodes[i] == el) return true;
|
5980 | }
|
5981 |
|
5982 | return false;
|
5983 | }
|
5984 | |
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 |
|
5990 |
|
5991 |
|
5992 |
|
5993 | function closest(element, selector, checkYourSelf) {
|
5994 | var currentElem = checkYourSelf ? element : element.parentNode;
|
5995 |
|
5996 | while (currentElem && currentElem.nodeType !== document.DOCUMENT_NODE && currentElem.nodeType !== document.DOCUMENT_FRAGMENT_NODE) {
|
5997 | if (matchesSelector(currentElem, selector)) {
|
5998 | return currentElem;
|
5999 | }
|
6000 |
|
6001 | currentElem = currentElem.parentNode;
|
6002 | }
|
6003 |
|
6004 | return matchesSelector(currentElem, selector) ? currentElem : null;
|
6005 | }
|
6006 |
|
6007 | var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent',
|
6008 | unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
|
6009 | prefix$6 = bind$1 !== 'addEventListener' ? 'on' : '';
|
6010 | |
6011 |
|
6012 |
|
6013 |
|
6014 |
|
6015 |
|
6016 |
|
6017 |
|
6018 |
|
6019 |
|
6020 |
|
6021 | var bind_1 = function bind_1(el, type, fn, capture) {
|
6022 | el[bind$1](prefix$6 + type, fn, capture || false);
|
6023 | return fn;
|
6024 | };
|
6025 | |
6026 |
|
6027 |
|
6028 |
|
6029 |
|
6030 |
|
6031 |
|
6032 |
|
6033 |
|
6034 |
|
6035 |
|
6036 |
|
6037 | var unbind_1 = function unbind_1(el, type, fn, capture) {
|
6038 | el[unbind](prefix$6 + type, fn, capture || false);
|
6039 | return fn;
|
6040 | };
|
6041 |
|
6042 | var componentEvent = {
|
6043 | bind: bind_1,
|
6044 | unbind: unbind_1
|
6045 | };
|
6046 | |
6047 |
|
6048 |
|
6049 |
|
6050 | |
6051 |
|
6052 |
|
6053 |
|
6054 |
|
6055 |
|
6056 |
|
6057 |
|
6058 |
|
6059 |
|
6060 |
|
6061 |
|
6062 |
|
6063 |
|
6064 |
|
6065 |
|
6066 | var forceCaptureEvents = ['focus', 'blur'];
|
6067 |
|
6068 | function bind$1$1(el, selector, type, fn, capture) {
|
6069 | if (forceCaptureEvents.indexOf(type) !== -1) {
|
6070 | capture = true;
|
6071 | }
|
6072 |
|
6073 | return componentEvent.bind(el, type, function (e) {
|
6074 | var target = e.target || e.srcElement;
|
6075 | e.delegateTarget = closest(target, selector, true);
|
6076 |
|
6077 | if (e.delegateTarget) {
|
6078 | fn.call(el, e);
|
6079 | }
|
6080 | }, capture);
|
6081 | }
|
6082 | |
6083 |
|
6084 |
|
6085 |
|
6086 |
|
6087 |
|
6088 |
|
6089 |
|
6090 |
|
6091 |
|
6092 |
|
6093 | function unbind$1(el, type, fn, capture) {
|
6094 | if (forceCaptureEvents.indexOf(type) !== -1) {
|
6095 | capture = true;
|
6096 | }
|
6097 |
|
6098 | return componentEvent.unbind(el, type, fn, capture);
|
6099 | }
|
6100 |
|
6101 | var delegate = {
|
6102 | bind: bind$1$1,
|
6103 | unbind: unbind$1
|
6104 | };
|
6105 | |
6106 |
|
6107 |
|
6108 |
|
6109 | var domify = parse;
|
6110 | |
6111 |
|
6112 |
|
6113 |
|
6114 | var innerHTMLBug = false;
|
6115 | var bugTestDiv;
|
6116 |
|
6117 | if (typeof document !== 'undefined') {
|
6118 | bugTestDiv = document.createElement('div');
|
6119 |
|
6120 | bugTestDiv.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>';
|
6121 |
|
6122 |
|
6123 | innerHTMLBug = !bugTestDiv.getElementsByTagName('link').length;
|
6124 | bugTestDiv = undefined;
|
6125 | }
|
6126 | |
6127 |
|
6128 |
|
6129 |
|
6130 |
|
6131 | var map$1 = {
|
6132 | legend: [1, '<fieldset>', '</fieldset>'],
|
6133 | tr: [2, '<table><tbody>', '</tbody></table>'],
|
6134 | col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
|
6135 |
|
6136 |
|
6137 | _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', '']
|
6138 | };
|
6139 | map$1.td = map$1.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
|
6140 | map$1.option = map$1.optgroup = [1, '<select multiple="multiple">', '</select>'];
|
6141 | map$1.thead = map$1.tbody = map$1.colgroup = map$1.caption = map$1.tfoot = [1, '<table>', '</table>'];
|
6142 | map$1.polyline = map$1.ellipse = map$1.polygon = map$1.circle = map$1.text = map$1.line = map$1.path = map$1.rect = map$1.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">', '</svg>'];
|
6143 | |
6144 |
|
6145 |
|
6146 |
|
6147 |
|
6148 |
|
6149 |
|
6150 |
|
6151 |
|
6152 |
|
6153 |
|
6154 | function parse(html, doc) {
|
6155 | if ('string' != typeof html) throw new TypeError('String expected');
|
6156 |
|
6157 | if (!doc) doc = document;
|
6158 |
|
6159 | var m = /<([\w:]+)/.exec(html);
|
6160 | if (!m) return doc.createTextNode(html);
|
6161 | html = html.replace(/^\s+|\s+$/g, '');
|
6162 |
|
6163 | var tag = m[1];
|
6164 |
|
6165 | if (tag == 'body') {
|
6166 | var el = doc.createElement('html');
|
6167 | el.innerHTML = html;
|
6168 | return el.removeChild(el.lastChild);
|
6169 | }
|
6170 |
|
6171 |
|
6172 | var wrap = map$1[tag] || map$1._default;
|
6173 | var depth = wrap[0];
|
6174 | var prefix = wrap[1];
|
6175 | var suffix = wrap[2];
|
6176 | var el = doc.createElement('div');
|
6177 | el.innerHTML = prefix + html + suffix;
|
6178 |
|
6179 | while (depth--) {
|
6180 | el = el.lastChild;
|
6181 | }
|
6182 |
|
6183 |
|
6184 | if (el.firstChild == el.lastChild) {
|
6185 | return el.removeChild(el.firstChild);
|
6186 | }
|
6187 |
|
6188 |
|
6189 | var fragment = doc.createDocumentFragment();
|
6190 |
|
6191 | while (el.firstChild) {
|
6192 | fragment.appendChild(el.removeChild(el.firstChild));
|
6193 | }
|
6194 |
|
6195 | return fragment;
|
6196 | }
|
6197 |
|
6198 | function query(selector, el) {
|
6199 | el = el || document;
|
6200 | return el.querySelector(selector);
|
6201 | }
|
6202 |
|
6203 | function all(selector, el) {
|
6204 | el = el || document;
|
6205 | return el.querySelectorAll(selector);
|
6206 | }
|
6207 |
|
6208 | function remove(el) {
|
6209 | el.parentNode && el.parentNode.removeChild(el);
|
6210 | }
|
6211 |
|
6212 | function ownKeys(object, enumerableOnly) {
|
6213 | var keys = Object.keys(object);
|
6214 |
|
6215 | if (Object.getOwnPropertySymbols) {
|
6216 | var symbols = Object.getOwnPropertySymbols(object);
|
6217 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
6218 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
6219 | });
|
6220 | keys.push.apply(keys, symbols);
|
6221 | }
|
6222 |
|
6223 | return keys;
|
6224 | }
|
6225 |
|
6226 | function _objectSpread(target) {
|
6227 | for (var i = 1; i < arguments.length; i++) {
|
6228 | var source = arguments[i] != null ? arguments[i] : {};
|
6229 |
|
6230 | if (i % 2) {
|
6231 | ownKeys(source, true).forEach(function (key) {
|
6232 | _defineProperty(target, key, source[key]);
|
6233 | });
|
6234 | } else if (Object.getOwnPropertyDescriptors) {
|
6235 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
6236 | } else {
|
6237 | ownKeys(source).forEach(function (key) {
|
6238 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
6239 | });
|
6240 | }
|
6241 | }
|
6242 |
|
6243 | return target;
|
6244 | }
|
6245 |
|
6246 | function _toConsumableArray(arr) {
|
6247 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
6248 | }
|
6249 |
|
6250 | function _nonIterableSpread() {
|
6251 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
6252 | }
|
6253 |
|
6254 | function _iterableToArray(iter) {
|
6255 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
6256 | }
|
6257 |
|
6258 | function _arrayWithoutHoles(arr) {
|
6259 | if (Array.isArray(arr)) {
|
6260 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
6261 | arr2[i] = arr[i];
|
6262 | }
|
6263 |
|
6264 | return arr2;
|
6265 | }
|
6266 | }
|
6267 |
|
6268 | function _typeof$1(obj) {
|
6269 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
6270 | _typeof$1 = function _typeof$1(obj) {
|
6271 | return _typeof(obj);
|
6272 | };
|
6273 | } else {
|
6274 | _typeof$1 = function _typeof$1(obj) {
|
6275 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
6276 | };
|
6277 | }
|
6278 |
|
6279 | return _typeof$1(obj);
|
6280 | }
|
6281 |
|
6282 | function _classCallCheck$1(instance, Constructor) {
|
6283 | if (!(instance instanceof Constructor)) {
|
6284 | throw new TypeError("Cannot call a class as a function");
|
6285 | }
|
6286 | }
|
6287 |
|
6288 | function _defineProperties$1(target, props) {
|
6289 | for (var i = 0; i < props.length; i++) {
|
6290 | var descriptor = props[i];
|
6291 | descriptor.enumerable = descriptor.enumerable || false;
|
6292 | descriptor.configurable = true;
|
6293 | if ("value" in descriptor) descriptor.writable = true;
|
6294 | Object.defineProperty(target, descriptor.key, descriptor);
|
6295 | }
|
6296 | }
|
6297 |
|
6298 | function _createClass$1(Constructor, protoProps, staticProps) {
|
6299 | if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
6300 | if (staticProps) _defineProperties$1(Constructor, staticProps);
|
6301 | return Constructor;
|
6302 | }
|
6303 |
|
6304 | function _defineProperty(obj, key, value) {
|
6305 | if (key in obj) {
|
6306 | Object.defineProperty(obj, key, {
|
6307 | value: value,
|
6308 | enumerable: true,
|
6309 | configurable: true,
|
6310 | writable: true
|
6311 | });
|
6312 | } else {
|
6313 | obj[key] = value;
|
6314 | }
|
6315 |
|
6316 | return obj;
|
6317 | }
|
6318 | var DEFAULT_CONTAINER_OPTIONS = {
|
6319 | width: '100%',
|
6320 | height: '100%',
|
6321 | position: 'relative'
|
6322 | };
|
6323 | |
6324 |
|
6325 |
|
6326 |
|
6327 |
|
6328 |
|
6329 | var Manager =
|
6330 |
|
6331 | function () {
|
6332 | |
6333 |
|
6334 |
|
6335 |
|
6336 |
|
6337 |
|
6338 |
|
6339 | function Manager() {
|
6340 | var _this = this;
|
6341 |
|
6342 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
6343 |
|
6344 | _classCallCheck$1(this, Manager);
|
6345 |
|
6346 | _defineProperty(this, "_viewsChanged", function () {
|
6347 | _this._emit('views.changed', {
|
6348 | views: _this._views,
|
6349 | activeView: _this._activeView
|
6350 | });
|
6351 | });
|
6352 |
|
6353 | this._eventBus = new EventBus();
|
6354 | this._viewsChanged = debounce(this._viewsChanged, 0);
|
6355 | this._views = [];
|
6356 | this._viewers = {};
|
6357 |
|
6358 | this._init(options);
|
6359 | }
|
6360 | |
6361 |
|
6362 |
|
6363 |
|
6364 |
|
6365 |
|
6366 |
|
6367 |
|
6368 |
|
6369 |
|
6370 |
|
6371 |
|
6372 |
|
6373 |
|
6374 |
|
6375 |
|
6376 |
|
6377 |
|
6378 |
|
6379 |
|
6380 |
|
6381 |
|
6382 |
|
6383 |
|
6384 |
|
6385 | _createClass$1(Manager, [{
|
6386 | key: "importXML",
|
6387 | value: function importXML(xml, options, done) {
|
6388 | var _this2 = this;
|
6389 |
|
6390 | if (_typeof$1(options) !== 'object') {
|
6391 | done = options;
|
6392 | options = {
|
6393 | open: true
|
6394 | };
|
6395 | }
|
6396 |
|
6397 | if (typeof done !== 'function') {
|
6398 | done = noop;
|
6399 | }
|
6400 |
|
6401 |
|
6402 |
|
6403 | xml = this._emit('import.parse.start', {
|
6404 | xml: xml
|
6405 | }) || xml;
|
6406 |
|
6407 | this._moddle.fromXML(xml, 'dmn:Definitions', function (err, definitions, context) {
|
6408 |
|
6409 |
|
6410 | definitions = _this2._emit('import.parse.complete', {
|
6411 | error: err,
|
6412 | definitions: definitions,
|
6413 | context: context
|
6414 | }) || definitions;
|
6415 | var parseWarnings = context.warnings;
|
6416 |
|
6417 | _this2._setDefinitions(definitions);
|
6418 |
|
6419 | if (err) {
|
6420 | err = checkDMNCompatibilityError(err, xml) || checkValidationError(err) || err;
|
6421 | }
|
6422 |
|
6423 | if (err || !options.open) {
|
6424 | _this2._emit('import.done', {
|
6425 | error: err,
|
6426 | warmings: parseWarnings
|
6427 | });
|
6428 |
|
6429 | return done(err, parseWarnings);
|
6430 | }
|
6431 |
|
6432 | var view = _this2._activeView || _this2._getInitialView(_this2._views);
|
6433 |
|
6434 | if (!view) {
|
6435 | return done(new Error('no displayable contents'));
|
6436 | }
|
6437 |
|
6438 | _this2.open(view, function (err, warnings) {
|
6439 | var allWarnings = [].concat(parseWarnings, warnings || []);
|
6440 |
|
6441 | _this2._emit('import.done', {
|
6442 | error: err,
|
6443 | warnings: allWarnings
|
6444 | });
|
6445 |
|
6446 | done(err, allWarnings);
|
6447 | });
|
6448 | });
|
6449 | }
|
6450 | }, {
|
6451 | key: "getDefinitions",
|
6452 | value: function getDefinitions() {
|
6453 | return this._definitions;
|
6454 | }
|
6455 | |
6456 |
|
6457 |
|
6458 |
|
6459 |
|
6460 |
|
6461 | }, {
|
6462 | key: "getActiveView",
|
6463 | value: function getActiveView() {
|
6464 | return this._activeView;
|
6465 | }
|
6466 | |
6467 |
|
6468 |
|
6469 |
|
6470 |
|
6471 |
|
6472 | }, {
|
6473 | key: "getActiveViewer",
|
6474 | value: function getActiveViewer() {
|
6475 | var activeView = this.getActiveView();
|
6476 | return activeView && this._getViewer(activeView);
|
6477 | }
|
6478 | }, {
|
6479 | key: "getView",
|
6480 | value: function getView(element) {
|
6481 | return this._views.filter(function (v) {
|
6482 | return v.element === element;
|
6483 | })[0];
|
6484 | }
|
6485 | }, {
|
6486 | key: "getViews",
|
6487 | value: function getViews() {
|
6488 | return this._views;
|
6489 | }
|
6490 | |
6491 |
|
6492 |
|
6493 |
|
6494 |
|
6495 |
|
6496 |
|
6497 |
|
6498 |
|
6499 |
|
6500 |
|
6501 |
|
6502 |
|
6503 |
|
6504 |
|
6505 |
|
6506 |
|
6507 |
|
6508 |
|
6509 |
|
6510 | }, {
|
6511 | key: "saveXML",
|
6512 | value: function saveXML(options, done) {
|
6513 | var _this3 = this;
|
6514 |
|
6515 | if (typeof options === 'function') {
|
6516 | done = options;
|
6517 | options = {};
|
6518 | }
|
6519 |
|
6520 | var definitions = this._definitions;
|
6521 |
|
6522 | if (!definitions) {
|
6523 | return done(new Error('no definitions loaded'));
|
6524 | }
|
6525 |
|
6526 |
|
6527 | definitions = this._emit('saveXML.start', {
|
6528 | definitions: definitions
|
6529 | }) || definitions;
|
6530 |
|
6531 | this._moddle.toXML(definitions, options, function (err, xml) {
|
6532 | try {
|
6533 | xml = _this3._emit('saveXML.serialized', {
|
6534 | error: err,
|
6535 | xml: xml
|
6536 | }) || xml;
|
6537 |
|
6538 | _this3._emit('saveXML.done', {
|
6539 | error: err,
|
6540 | xml: xml
|
6541 | });
|
6542 | } catch (e) {
|
6543 | console.error('error in saveXML life-cycle listener', e);
|
6544 | }
|
6545 |
|
6546 | done(err, xml);
|
6547 | });
|
6548 | }
|
6549 | |
6550 |
|
6551 |
|
6552 |
|
6553 |
|
6554 |
|
6555 |
|
6556 |
|
6557 |
|
6558 |
|
6559 |
|
6560 | }, {
|
6561 | key: "on",
|
6562 | value: function on() {
|
6563 | var _this$_eventBus;
|
6564 |
|
6565 | (_this$_eventBus = this._eventBus).on.apply(_this$_eventBus, arguments);
|
6566 | }
|
6567 | |
6568 |
|
6569 |
|
6570 |
|
6571 |
|
6572 |
|
6573 |
|
6574 | }, {
|
6575 | key: "off",
|
6576 | value: function off() {
|
6577 | var _this$_eventBus2;
|
6578 |
|
6579 | (_this$_eventBus2 = this._eventBus).off.apply(_this$_eventBus2, arguments);
|
6580 | }
|
6581 | |
6582 |
|
6583 |
|
6584 |
|
6585 |
|
6586 |
|
6587 |
|
6588 |
|
6589 |
|
6590 | }, {
|
6591 | key: "once",
|
6592 | value: function once() {
|
6593 | var _this$_eventBus3;
|
6594 |
|
6595 | (_this$_eventBus3 = this._eventBus).once.apply(_this$_eventBus3, arguments);
|
6596 | }
|
6597 | }, {
|
6598 | key: "attachTo",
|
6599 | value: function attachTo(parentNode) {
|
6600 |
|
6601 | if (parentNode.get && parentNode.constructor.prototype.jquery) {
|
6602 | parentNode = parentNode.get(0);
|
6603 | }
|
6604 |
|
6605 | if (typeof parentNode === 'string') {
|
6606 | parentNode = query(parentNode);
|
6607 | }
|
6608 |
|
6609 | parentNode.appendChild(this._container);
|
6610 |
|
6611 | this._emit('attach', {});
|
6612 | }
|
6613 | }, {
|
6614 | key: "detach",
|
6615 | value: function detach() {
|
6616 | this._emit('detach', {});
|
6617 |
|
6618 | remove(this._container);
|
6619 | }
|
6620 | }, {
|
6621 | key: "destroy",
|
6622 | value: function destroy() {
|
6623 | var _this4 = this;
|
6624 |
|
6625 | Object.keys(this._viewers).forEach(function (viewerId) {
|
6626 | var viewer = _this4._viewers[viewerId];
|
6627 | safeExecute(viewer, 'destroy');
|
6628 | });
|
6629 | remove(this._container);
|
6630 | }
|
6631 | }, {
|
6632 | key: "_init",
|
6633 | value: function _init(options) {
|
6634 | this._options = options;
|
6635 | this._moddle = this._createModdle(options);
|
6636 | this._viewers = {};
|
6637 | this._views = [];
|
6638 | var container = domify('<div class="dmn-js-parent"></div>');
|
6639 | var containerOptions = assign({}, DEFAULT_CONTAINER_OPTIONS, options);
|
6640 | assign(container.style, {
|
6641 | width: ensureUnit(containerOptions.width),
|
6642 | height: ensureUnit(containerOptions.height),
|
6643 | position: containerOptions.position
|
6644 | });
|
6645 | this._container = container;
|
6646 |
|
6647 | if (options.container) {
|
6648 | this.attachTo(options.container);
|
6649 | }
|
6650 | }
|
6651 | |
6652 |
|
6653 |
|
6654 |
|
6655 |
|
6656 |
|
6657 |
|
6658 | }, {
|
6659 | key: "open",
|
6660 | value: function open(view) {
|
6661 | var done = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
6662 |
|
6663 | this._switchView(view, done);
|
6664 | }
|
6665 | }, {
|
6666 | key: "_setDefinitions",
|
6667 | value: function _setDefinitions(definitions) {
|
6668 | this._definitions = definitions;
|
6669 |
|
6670 | this._updateViews();
|
6671 | }
|
6672 | }, {
|
6673 | key: "_updateViews",
|
6674 |
|
6675 | |
6676 |
|
6677 |
|
6678 |
|
6679 | value: function _updateViews() {
|
6680 | var definitions = this._definitions;
|
6681 |
|
6682 | if (!definitions) {
|
6683 | this._views = [];
|
6684 |
|
6685 | this._switchView(null);
|
6686 |
|
6687 | return;
|
6688 | }
|
6689 |
|
6690 | var viewProviders = this._getViewProviders();
|
6691 |
|
6692 | var displayableElements = [definitions].concat(_toConsumableArray(definitions.drgElement || []));
|
6693 |
|
6694 | var views = this._views,
|
6695 | newViews = [];
|
6696 | var _iteratorNormalCompletion = true;
|
6697 | var _didIteratorError = false;
|
6698 | var _iteratorError = undefined;
|
6699 |
|
6700 | try {
|
6701 | for (var _iterator = displayableElements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
6702 | var element = _step.value;
|
6703 | var provider = find(viewProviders, function (provider) {
|
6704 | if (typeof provider.opens === 'string') {
|
6705 | return provider.opens === element.$type;
|
6706 | } else {
|
6707 | return provider.opens(element);
|
6708 | }
|
6709 | });
|
6710 |
|
6711 | if (!provider) {
|
6712 | continue;
|
6713 | }
|
6714 |
|
6715 | var view = {
|
6716 | element: element,
|
6717 | id: element.id,
|
6718 | name: element.name,
|
6719 | type: provider.id
|
6720 | };
|
6721 | newViews.push(view);
|
6722 | }
|
6723 | } catch (err) {
|
6724 | _didIteratorError = true;
|
6725 | _iteratorError = err;
|
6726 | } finally {
|
6727 | try {
|
6728 | if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
6729 | _iterator["return"]();
|
6730 | }
|
6731 | } finally {
|
6732 | if (_didIteratorError) {
|
6733 | throw _iteratorError;
|
6734 | }
|
6735 | }
|
6736 | }
|
6737 |
|
6738 | var activeView = this._activeView,
|
6739 | newActiveView;
|
6740 |
|
6741 | if (activeView) {
|
6742 |
|
6743 | newActiveView = find(newViews, function (view) {
|
6744 | return viewsEqual(activeView, view);
|
6745 | }) || this._getInitialView(newViews);
|
6746 |
|
6747 | if (!newActiveView) {
|
6748 | return this._switchView(null);
|
6749 | }
|
6750 | }
|
6751 |
|
6752 |
|
6753 |
|
6754 |
|
6755 |
|
6756 | var activeViewChanged = !viewsEqual(activeView, newActiveView) || viewNameChanged(activeView, newActiveView);
|
6757 | var viewsChanged = views.length !== newViews.length || !every(newViews, function (newView) {
|
6758 | return find(views, function (view) {
|
6759 | return viewsEqual(view, newView) && !viewNameChanged(view, newView);
|
6760 | });
|
6761 | });
|
6762 | this._activeView = newActiveView;
|
6763 | this._views = newViews;
|
6764 |
|
6765 | if (activeViewChanged || viewsChanged) {
|
6766 | this._viewsChanged();
|
6767 | }
|
6768 | }
|
6769 | }, {
|
6770 | key: "_getInitialView",
|
6771 | value: function _getInitialView(views) {
|
6772 | return views[0];
|
6773 | }
|
6774 | |
6775 |
|
6776 |
|
6777 |
|
6778 |
|
6779 |
|
6780 |
|
6781 | }, {
|
6782 | key: "_switchView",
|
6783 | value: function _switchView(newView) {
|
6784 | var _this5 = this;
|
6785 |
|
6786 | var done = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
6787 |
|
6788 | var complete = function complete(err, warnings) {
|
6789 | _this5._viewsChanged();
|
6790 |
|
6791 | done(err, warnings);
|
6792 | };
|
6793 |
|
6794 | var activeView = this.getActiveView(),
|
6795 | activeViewer;
|
6796 |
|
6797 | var newViewer = newView && this._getViewer(newView),
|
6798 | element = newView && newView.element;
|
6799 |
|
6800 | if (activeView) {
|
6801 | activeViewer = this._getViewer(activeView);
|
6802 |
|
6803 | if (activeViewer !== newViewer) {
|
6804 | safeExecute(activeViewer, 'clear');
|
6805 | activeViewer.detach();
|
6806 | }
|
6807 | }
|
6808 |
|
6809 | this._activeView = newView;
|
6810 |
|
6811 | if (newViewer) {
|
6812 | if (activeViewer !== newViewer) {
|
6813 | newViewer.attachTo(this._container);
|
6814 | }
|
6815 |
|
6816 | this._emit('import.render.start', {
|
6817 | view: newView,
|
6818 | element: element
|
6819 | });
|
6820 |
|
6821 | return newViewer.open(element, function (err, warnings) {
|
6822 | _this5._emit('import.render.complete', {
|
6823 | view: newView,
|
6824 | error: err,
|
6825 | warnings: warnings
|
6826 | });
|
6827 |
|
6828 | complete(err, warnings);
|
6829 | });
|
6830 | }
|
6831 |
|
6832 |
|
6833 | complete();
|
6834 | }
|
6835 | }, {
|
6836 | key: "_getViewer",
|
6837 | value: function _getViewer(view) {
|
6838 | var type = view.type;
|
6839 | var viewer = this._viewers[type];
|
6840 |
|
6841 | if (!viewer) {
|
6842 | viewer = this._viewers[type] = this._createViewer(view.type);
|
6843 |
|
6844 | this._emit('viewer.created', {
|
6845 | type: type,
|
6846 | viewer: viewer
|
6847 | });
|
6848 | }
|
6849 |
|
6850 | return viewer;
|
6851 | }
|
6852 | }, {
|
6853 | key: "_createViewer",
|
6854 | value: function _createViewer(id) {
|
6855 | var provider = find(this._getViewProviders(), function (provider) {
|
6856 | return provider.id === id;
|
6857 | });
|
6858 |
|
6859 | if (!provider) {
|
6860 | throw new Error('no provider for view type <' + id + '>');
|
6861 | }
|
6862 |
|
6863 | var Viewer = provider.constructor;
|
6864 | var providerOptions = this._options[id] || {};
|
6865 | var commonOptions = this._options.common || {};
|
6866 | return new Viewer(_objectSpread({}, commonOptions, {}, providerOptions, {
|
6867 | additionalModules: [].concat(_toConsumableArray(providerOptions.additionalModules || []), [{
|
6868 | _parent: ['value', this],
|
6869 | moddle: ['value', this._moddle]
|
6870 | }])
|
6871 | }));
|
6872 | }
|
6873 | |
6874 |
|
6875 |
|
6876 |
|
6877 | }, {
|
6878 | key: "_emit",
|
6879 | value: function _emit() {
|
6880 | var _this$_eventBus4;
|
6881 |
|
6882 | (_this$_eventBus4 = this._eventBus).fire.apply(_this$_eventBus4, arguments);
|
6883 | }
|
6884 | }, {
|
6885 | key: "_createModdle",
|
6886 | value: function _createModdle(options) {
|
6887 | return new simple(assign({
|
6888 | camunda: CamundaModdle
|
6889 | }, options.moddleExtensions));
|
6890 | }
|
6891 | |
6892 |
|
6893 |
|
6894 |
|
6895 |
|
6896 |
|
6897 |
|
6898 |
|
6899 | }, {
|
6900 | key: "_getViewProviders",
|
6901 | value: function _getViewProviders() {
|
6902 | return [];
|
6903 | }
|
6904 | }]);
|
6905 |
|
6906 | return Manager;
|
6907 | }();
|
6908 |
|
6909 | function noop() {}
|
6910 | |
6911 |
|
6912 |
|
6913 |
|
6914 |
|
6915 | function ensureUnit(val) {
|
6916 | return val + (isNumber(val) ? 'px' : '');
|
6917 | }
|
6918 |
|
6919 | function checkDMNCompatibilityError(err, xml) {
|
6920 |
|
6921 | if (err.message !== 'failed to parse document as <dmn:Definitions>') {
|
6922 | return null;
|
6923 | }
|
6924 |
|
6925 | var olderDMNVersion = xml.indexOf('"http://www.omg.org/spec/DMN/20151101/dmn.xsd"') !== -1 && '1.1' || xml.indexOf('"http://www.omg.org/spec/DMN/20180521/MODEL/"') !== -1 && '1.2';
|
6926 |
|
6927 | if (!olderDMNVersion) {
|
6928 | return null;
|
6929 | }
|
6930 |
|
6931 | err = new Error('unsupported DMN ' + olderDMNVersion + ' file detected; ' + 'only DMN 1.3 files can be opened');
|
6932 | console.error('Cannot open what looks like a DMN ' + olderDMNVersion + ' diagram. ' + 'Please refer to https://bpmn.io/l/dmn-compatibility.html ' + 'to learn how to make the toolkit compatible with older DMN files', err);
|
6933 | return err;
|
6934 | }
|
6935 |
|
6936 | function checkValidationError(err) {
|
6937 |
|
6938 |
|
6939 | var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/,
|
6940 | match = pattern.exec(err.message);
|
6941 |
|
6942 | if (!match) {
|
6943 | return null;
|
6944 | }
|
6945 |
|
6946 | err.message = 'unparsable content <' + match[1] + '> detected; ' + 'this may indicate an invalid DMN 1.3 diagram file' + match[2];
|
6947 | return err;
|
6948 | }
|
6949 |
|
6950 | function viewsEqual(a, b) {
|
6951 | if (!isDefined(a)) {
|
6952 | if (!isDefined(b)) {
|
6953 | return true;
|
6954 | } else {
|
6955 | return false;
|
6956 | }
|
6957 | }
|
6958 |
|
6959 | if (!isDefined(b)) {
|
6960 | return false;
|
6961 | }
|
6962 |
|
6963 |
|
6964 | return a.element === b.element || a.id === b.id;
|
6965 | }
|
6966 |
|
6967 | function viewNameChanged(a, b) {
|
6968 | return !a || !b || a.name !== b.name;
|
6969 | }
|
6970 |
|
6971 | function safeExecute(viewer, method) {
|
6972 | if (isFunction(viewer[method])) {
|
6973 | viewer[method]();
|
6974 | }
|
6975 | }
|
6976 |
|
6977 | var CLASS_PATTERN = /^class /;
|
6978 |
|
6979 | function isClass(fn) {
|
6980 | return CLASS_PATTERN.test(fn.toString());
|
6981 | }
|
6982 |
|
6983 | function isArray$1(obj) {
|
6984 | return Object.prototype.toString.call(obj) === '[object Array]';
|
6985 | }
|
6986 |
|
6987 | function annotate() {
|
6988 | var args = Array.prototype.slice.call(arguments);
|
6989 |
|
6990 | if (args.length === 1 && isArray$1(args[0])) {
|
6991 | args = args[0];
|
6992 | }
|
6993 |
|
6994 | var fn = args.pop();
|
6995 | fn.$inject = args;
|
6996 | return fn;
|
6997 | }
|
6998 |
|
6999 |
|
7000 |
|
7001 |
|
7002 |
|
7003 |
|
7004 |
|
7005 |
|
7006 |
|
7007 |
|
7008 |
|
7009 |
|
7010 |
|
7011 | var CONSTRUCTOR_ARGS = /constructor\s*[^(]*\(\s*([^)]*)\)/m;
|
7012 | var FN_ARGS = /^function\s*[^(]*\(\s*([^)]*)\)/m;
|
7013 | var FN_ARG = /\/\*([^*]*)\*\//m;
|
7014 |
|
7015 | function parse$1(fn) {
|
7016 | if (typeof fn !== 'function') {
|
7017 | throw new Error('Cannot annotate "' + fn + '". Expected a function!');
|
7018 | }
|
7019 |
|
7020 | var match = fn.toString().match(isClass(fn) ? CONSTRUCTOR_ARGS : FN_ARGS);
|
7021 |
|
7022 | if (!match) {
|
7023 | return [];
|
7024 | }
|
7025 |
|
7026 | return match[1] && match[1].split(',').map(function (arg) {
|
7027 | match = arg.match(FN_ARG);
|
7028 | return match ? match[1].trim() : arg.trim();
|
7029 | }) || [];
|
7030 | }
|
7031 |
|
7032 | function Module() {
|
7033 | var providers = [];
|
7034 |
|
7035 | this.factory = function (name, factory) {
|
7036 | providers.push([name, 'factory', factory]);
|
7037 | return this;
|
7038 | };
|
7039 |
|
7040 | this.value = function (name, value) {
|
7041 | providers.push([name, 'value', value]);
|
7042 | return this;
|
7043 | };
|
7044 |
|
7045 | this.type = function (name, type) {
|
7046 | providers.push([name, 'type', type]);
|
7047 | return this;
|
7048 | };
|
7049 |
|
7050 | this.forEach = function (iterator) {
|
7051 | providers.forEach(iterator);
|
7052 | };
|
7053 | }
|
7054 |
|
7055 | var _typeof$2 = typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol" ? function (obj) {
|
7056 | return _typeof(obj);
|
7057 | } : function (obj) {
|
7058 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
7059 | };
|
7060 |
|
7061 | function _toConsumableArray$1(arr) {
|
7062 | if (Array.isArray(arr)) {
|
7063 | for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
7064 | arr2[i] = arr[i];
|
7065 | }
|
7066 |
|
7067 | return arr2;
|
7068 | } else {
|
7069 | return Array.from(arr);
|
7070 | }
|
7071 | }
|
7072 |
|
7073 | function Injector(modules, parent) {
|
7074 | parent = parent || {
|
7075 | get: function get(name, strict) {
|
7076 | currentlyResolving.push(name);
|
7077 |
|
7078 | if (strict === false) {
|
7079 | return null;
|
7080 | } else {
|
7081 | throw error('No provider for "' + name + '"!');
|
7082 | }
|
7083 | }
|
7084 | };
|
7085 | var currentlyResolving = [];
|
7086 | var providers = this._providers = Object.create(parent._providers || null);
|
7087 | var instances = this._instances = Object.create(null);
|
7088 | var self = instances.injector = this;
|
7089 |
|
7090 | var error = function error(msg) {
|
7091 | var stack = currentlyResolving.join(' -> ');
|
7092 | currentlyResolving.length = 0;
|
7093 | return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg);
|
7094 | };
|
7095 | |
7096 |
|
7097 |
|
7098 |
|
7099 |
|
7100 |
|
7101 |
|
7102 |
|
7103 |
|
7104 |
|
7105 | var get = function get(name, strict) {
|
7106 | if (!providers[name] && name.indexOf('.') !== -1) {
|
7107 | var parts = name.split('.');
|
7108 | var pivot = get(parts.shift());
|
7109 |
|
7110 | while (parts.length) {
|
7111 | pivot = pivot[parts.shift()];
|
7112 | }
|
7113 |
|
7114 | return pivot;
|
7115 | }
|
7116 |
|
7117 | if (hasProp(instances, name)) {
|
7118 | return instances[name];
|
7119 | }
|
7120 |
|
7121 | if (hasProp(providers, name)) {
|
7122 | if (currentlyResolving.indexOf(name) !== -1) {
|
7123 | currentlyResolving.push(name);
|
7124 | throw error('Cannot resolve circular dependency!');
|
7125 | }
|
7126 |
|
7127 | currentlyResolving.push(name);
|
7128 | instances[name] = providers[name][0](providers[name][1]);
|
7129 | currentlyResolving.pop();
|
7130 | return instances[name];
|
7131 | }
|
7132 |
|
7133 | return parent.get(name, strict);
|
7134 | };
|
7135 |
|
7136 | var fnDef = function fnDef(fn) {
|
7137 | var locals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
7138 |
|
7139 | if (typeof fn !== 'function') {
|
7140 | if (isArray$1(fn)) {
|
7141 | fn = annotate(fn.slice());
|
7142 | } else {
|
7143 | throw new Error('Cannot invoke "' + fn + '". Expected a function!');
|
7144 | }
|
7145 | }
|
7146 |
|
7147 | var inject = fn.$inject || parse$1(fn);
|
7148 | var dependencies = inject.map(function (dep) {
|
7149 | if (hasProp(locals, dep)) {
|
7150 | return locals[dep];
|
7151 | } else {
|
7152 | return get(dep);
|
7153 | }
|
7154 | });
|
7155 | return {
|
7156 | fn: fn,
|
7157 | dependencies: dependencies
|
7158 | };
|
7159 | };
|
7160 |
|
7161 | var instantiate = function instantiate(Type) {
|
7162 | var _fnDef = fnDef(Type),
|
7163 | dependencies = _fnDef.dependencies,
|
7164 | fn = _fnDef.fn;
|
7165 |
|
7166 | return new (Function.prototype.bind.apply(fn, [null].concat(_toConsumableArray$1(dependencies))))();
|
7167 | };
|
7168 |
|
7169 | var invoke = function invoke(func, context, locals) {
|
7170 | var _fnDef2 = fnDef(func, locals),
|
7171 | dependencies = _fnDef2.dependencies,
|
7172 | fn = _fnDef2.fn;
|
7173 |
|
7174 | return fn.call.apply(fn, [context].concat(_toConsumableArray$1(dependencies)));
|
7175 | };
|
7176 |
|
7177 | var createPrivateInjectorFactory = function createPrivateInjectorFactory(privateChildInjector) {
|
7178 | return annotate(function (key) {
|
7179 | return privateChildInjector.get(key);
|
7180 | });
|
7181 | };
|
7182 |
|
7183 | var createChild = function createChild(modules, forceNewInstances) {
|
7184 | if (forceNewInstances && forceNewInstances.length) {
|
7185 | var fromParentModule = Object.create(null);
|
7186 | var matchedScopes = Object.create(null);
|
7187 | var privateInjectorsCache = [];
|
7188 | var privateChildInjectors = [];
|
7189 | var privateChildFactories = [];
|
7190 | var provider;
|
7191 | var cacheIdx;
|
7192 | var privateChildInjector;
|
7193 | var privateChildInjectorFactory;
|
7194 |
|
7195 | for (var name in providers) {
|
7196 | provider = providers[name];
|
7197 |
|
7198 | if (forceNewInstances.indexOf(name) !== -1) {
|
7199 | if (provider[2] === 'private') {
|
7200 | cacheIdx = privateInjectorsCache.indexOf(provider[3]);
|
7201 |
|
7202 | if (cacheIdx === -1) {
|
7203 | privateChildInjector = provider[3].createChild([], forceNewInstances);
|
7204 | privateChildInjectorFactory = createPrivateInjectorFactory(privateChildInjector);
|
7205 | privateInjectorsCache.push(provider[3]);
|
7206 | privateChildInjectors.push(privateChildInjector);
|
7207 | privateChildFactories.push(privateChildInjectorFactory);
|
7208 | fromParentModule[name] = [privateChildInjectorFactory, name, 'private', privateChildInjector];
|
7209 | } else {
|
7210 | fromParentModule[name] = [privateChildFactories[cacheIdx], name, 'private', privateChildInjectors[cacheIdx]];
|
7211 | }
|
7212 | } else {
|
7213 | fromParentModule[name] = [provider[2], provider[1]];
|
7214 | }
|
7215 |
|
7216 | matchedScopes[name] = true;
|
7217 | }
|
7218 |
|
7219 | if ((provider[2] === 'factory' || provider[2] === 'type') && provider[1].$scope) {
|
7220 |
|
7221 | forceNewInstances.forEach(function (scope) {
|
7222 | if (provider[1].$scope.indexOf(scope) !== -1) {
|
7223 | fromParentModule[name] = [provider[2], provider[1]];
|
7224 | matchedScopes[scope] = true;
|
7225 | }
|
7226 | });
|
7227 | }
|
7228 | }
|
7229 |
|
7230 | forceNewInstances.forEach(function (scope) {
|
7231 | if (!matchedScopes[scope]) {
|
7232 | throw new Error('No provider for "' + scope + '". Cannot use provider from the parent!');
|
7233 | }
|
7234 | });
|
7235 | modules.unshift(fromParentModule);
|
7236 | }
|
7237 |
|
7238 | return new Injector(modules, self);
|
7239 | };
|
7240 |
|
7241 | var factoryMap = {
|
7242 | factory: invoke,
|
7243 | type: instantiate,
|
7244 | value: function value(_value) {
|
7245 | return _value;
|
7246 | }
|
7247 | };
|
7248 | modules.forEach(function (module) {
|
7249 | function arrayUnwrap(type, value) {
|
7250 | if (type !== 'value' && isArray$1(value)) {
|
7251 | value = annotate(value.slice());
|
7252 | }
|
7253 |
|
7254 | return value;
|
7255 | }
|
7256 |
|
7257 |
|
7258 | if (module instanceof Module) {
|
7259 | module.forEach(function (provider) {
|
7260 | var name = provider[0];
|
7261 | var type = provider[1];
|
7262 | var value = provider[2];
|
7263 | providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
|
7264 | });
|
7265 | } else if ((typeof module === 'undefined' ? 'undefined' : _typeof$2(module)) === 'object') {
|
7266 | if (module.__exports__) {
|
7267 | var clonedModule = Object.keys(module).reduce(function (m, key) {
|
7268 | if (key.substring(0, 2) !== '__') {
|
7269 | m[key] = module[key];
|
7270 | }
|
7271 |
|
7272 | return m;
|
7273 | }, Object.create(null));
|
7274 | var privateInjector = new Injector((module.__modules__ || []).concat([clonedModule]), self);
|
7275 | var getFromPrivateInjector = annotate(function (key) {
|
7276 | return privateInjector.get(key);
|
7277 | });
|
7278 |
|
7279 | module.__exports__.forEach(function (key) {
|
7280 | providers[key] = [getFromPrivateInjector, key, 'private', privateInjector];
|
7281 | });
|
7282 | } else {
|
7283 | Object.keys(module).forEach(function (name) {
|
7284 | if (module[name][2] === 'private') {
|
7285 | providers[name] = module[name];
|
7286 | return;
|
7287 | }
|
7288 |
|
7289 | var type = module[name][0];
|
7290 | var value = module[name][1];
|
7291 | providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
|
7292 | });
|
7293 | }
|
7294 | }
|
7295 | });
|
7296 |
|
7297 | this.get = get;
|
7298 | this.invoke = invoke;
|
7299 | this.instantiate = instantiate;
|
7300 | this.createChild = createChild;
|
7301 | } // helpers /////////////////
|
7302 |
|
7303 |
|
7304 | function hasProp(obj, prop) {
|
7305 | return Object.hasOwnProperty.call(obj, prop);
|
7306 | }
|
7307 |
|
7308 | function createCommonjsModule(fn, module) {
|
7309 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
7310 | }
|
7311 |
|
7312 | var inherits_browser = createCommonjsModule(function (module) {
|
7313 | if (typeof Object.create === 'function') {
|
7314 |
|
7315 | module.exports = function inherits(ctor, superCtor) {
|
7316 | ctor.super_ = superCtor;
|
7317 | ctor.prototype = Object.create(superCtor.prototype, {
|
7318 | constructor: {
|
7319 | value: ctor,
|
7320 | enumerable: false,
|
7321 | writable: true,
|
7322 | configurable: true
|
7323 | }
|
7324 | });
|
7325 | };
|
7326 | } else {
|
7327 |
|
7328 | module.exports = function inherits(ctor, superCtor) {
|
7329 | ctor.super_ = superCtor;
|
7330 |
|
7331 | var TempCtor = function TempCtor() {};
|
7332 |
|
7333 | TempCtor.prototype = superCtor.prototype;
|
7334 | ctor.prototype = new TempCtor();
|
7335 | ctor.prototype.constructor = ctor;
|
7336 | };
|
7337 | }
|
7338 | });
|
7339 |
|
7340 | var DEFAULT_RENDER_PRIORITY = 1000;
|
7341 | |
7342 |
|
7343 |
|
7344 |
|
7345 |
|
7346 |
|
7347 |
|
7348 | function BaseRenderer(eventBus, renderPriority) {
|
7349 | var self = this;
|
7350 | renderPriority = renderPriority || DEFAULT_RENDER_PRIORITY;
|
7351 | eventBus.on(['render.shape', 'render.connection'], renderPriority, function (evt, context) {
|
7352 | var type = evt.type,
|
7353 | element = context.element,
|
7354 | visuals = context.gfx;
|
7355 |
|
7356 | if (self.canRender(element)) {
|
7357 | if (type === 'render.shape') {
|
7358 | return self.drawShape(visuals, element);
|
7359 | } else {
|
7360 | return self.drawConnection(visuals, element);
|
7361 | }
|
7362 | }
|
7363 | });
|
7364 | eventBus.on(['render.getShapePath', 'render.getConnectionPath'], renderPriority, function (evt, element) {
|
7365 | if (self.canRender(element)) {
|
7366 | if (evt.type === 'render.getShapePath') {
|
7367 | return self.getShapePath(element);
|
7368 | } else {
|
7369 | return self.getConnectionPath(element);
|
7370 | }
|
7371 | }
|
7372 | });
|
7373 | }
|
7374 | |
7375 |
|
7376 |
|
7377 |
|
7378 |
|
7379 |
|
7380 |
|
7381 |
|
7382 |
|
7383 | BaseRenderer.prototype.canRender = function () {};
|
7384 | |
7385 |
|
7386 |
|
7387 |
|
7388 |
|
7389 |
|
7390 |
|
7391 |
|
7392 |
|
7393 |
|
7394 | BaseRenderer.prototype.drawShape = function () {};
|
7395 | |
7396 |
|
7397 |
|
7398 |
|
7399 |
|
7400 |
|
7401 |
|
7402 |
|
7403 |
|
7404 |
|
7405 | BaseRenderer.prototype.drawConnection = function () {};
|
7406 | |
7407 |
|
7408 |
|
7409 |
|
7410 |
|
7411 |
|
7412 |
|
7413 |
|
7414 |
|
7415 | BaseRenderer.prototype.getShapePath = function () {};
|
7416 | |
7417 |
|
7418 |
|
7419 |
|
7420 |
|
7421 |
|
7422 |
|
7423 |
|
7424 |
|
7425 | BaseRenderer.prototype.getConnectionPath = function () {};
|
7426 |
|
7427 | function ensureImported(element, target) {
|
7428 | if (element.ownerDocument !== target.ownerDocument) {
|
7429 | try {
|
7430 |
|
7431 | return target.ownerDocument.importNode(element, true);
|
7432 | } catch (e) {
|
7433 | }
|
7434 | }
|
7435 |
|
7436 | return element;
|
7437 | }
|
7438 | |
7439 |
|
7440 |
|
7441 |
|
7442 | |
7443 |
|
7444 |
|
7445 |
|
7446 |
|
7447 |
|
7448 |
|
7449 |
|
7450 |
|
7451 |
|
7452 | function appendTo(element, target) {
|
7453 | return target.appendChild(ensureImported(element, target));
|
7454 | }
|
7455 | |
7456 |
|
7457 |
|
7458 |
|
7459 | |
7460 |
|
7461 |
|
7462 |
|
7463 |
|
7464 |
|
7465 |
|
7466 |
|
7467 |
|
7468 |
|
7469 | function append(target, node) {
|
7470 | appendTo(node, target);
|
7471 | return target;
|
7472 | }
|
7473 | |
7474 |
|
7475 |
|
7476 |
|
7477 |
|
7478 | var LENGTH_ATTR = 2;
|
7479 | var CSS_PROPERTIES = {
|
7480 | 'alignment-baseline': 1,
|
7481 | 'baseline-shift': 1,
|
7482 | 'clip': 1,
|
7483 | 'clip-path': 1,
|
7484 | 'clip-rule': 1,
|
7485 | 'color': 1,
|
7486 | 'color-interpolation': 1,
|
7487 | 'color-interpolation-filters': 1,
|
7488 | 'color-profile': 1,
|
7489 | 'color-rendering': 1,
|
7490 | 'cursor': 1,
|
7491 | 'direction': 1,
|
7492 | 'display': 1,
|
7493 | 'dominant-baseline': 1,
|
7494 | 'enable-background': 1,
|
7495 | 'fill': 1,
|
7496 | 'fill-opacity': 1,
|
7497 | 'fill-rule': 1,
|
7498 | 'filter': 1,
|
7499 | 'flood-color': 1,
|
7500 | 'flood-opacity': 1,
|
7501 | 'font': 1,
|
7502 | 'font-family': 1,
|
7503 | 'font-size': LENGTH_ATTR,
|
7504 | 'font-size-adjust': 1,
|
7505 | 'font-stretch': 1,
|
7506 | 'font-style': 1,
|
7507 | 'font-variant': 1,
|
7508 | 'font-weight': 1,
|
7509 | 'glyph-orientation-horizontal': 1,
|
7510 | 'glyph-orientation-vertical': 1,
|
7511 | 'image-rendering': 1,
|
7512 | 'kerning': 1,
|
7513 | 'letter-spacing': 1,
|
7514 | 'lighting-color': 1,
|
7515 | 'marker': 1,
|
7516 | 'marker-end': 1,
|
7517 | 'marker-mid': 1,
|
7518 | 'marker-start': 1,
|
7519 | 'mask': 1,
|
7520 | 'opacity': 1,
|
7521 | 'overflow': 1,
|
7522 | 'pointer-events': 1,
|
7523 | 'shape-rendering': 1,
|
7524 | 'stop-color': 1,
|
7525 | 'stop-opacity': 1,
|
7526 | 'stroke': 1,
|
7527 | 'stroke-dasharray': 1,
|
7528 | 'stroke-dashoffset': 1,
|
7529 | 'stroke-linecap': 1,
|
7530 | 'stroke-linejoin': 1,
|
7531 | 'stroke-miterlimit': 1,
|
7532 | 'stroke-opacity': 1,
|
7533 | 'stroke-width': LENGTH_ATTR,
|
7534 | 'text-anchor': 1,
|
7535 | 'text-decoration': 1,
|
7536 | 'text-rendering': 1,
|
7537 | 'unicode-bidi': 1,
|
7538 | 'visibility': 1,
|
7539 | 'word-spacing': 1,
|
7540 | 'writing-mode': 1
|
7541 | };
|
7542 |
|
7543 | function getAttribute(node, name) {
|
7544 | if (CSS_PROPERTIES[name]) {
|
7545 | return node.style[name];
|
7546 | } else {
|
7547 | return node.getAttributeNS(null, name);
|
7548 | }
|
7549 | }
|
7550 |
|
7551 | function setAttribute(node, name, value) {
|
7552 | var hyphenated = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
7553 | var type = CSS_PROPERTIES[hyphenated];
|
7554 |
|
7555 | if (type) {
|
7556 |
|
7557 | if (type === LENGTH_ATTR && typeof value === 'number') {
|
7558 | value = String(value) + 'px';
|
7559 | }
|
7560 |
|
7561 | node.style[hyphenated] = value;
|
7562 | } else {
|
7563 | node.setAttributeNS(null, name, value);
|
7564 | }
|
7565 | }
|
7566 |
|
7567 | function setAttributes(node, attrs) {
|
7568 | var names = Object.keys(attrs),
|
7569 | i,
|
7570 | name;
|
7571 |
|
7572 | for (i = 0, name; name = names[i]; i++) {
|
7573 | setAttribute(node, name, attrs[name]);
|
7574 | }
|
7575 | }
|
7576 | |
7577 |
|
7578 |
|
7579 |
|
7580 |
|
7581 |
|
7582 |
|
7583 |
|
7584 |
|
7585 |
|
7586 |
|
7587 |
|
7588 | function attr$1(node, name, value) {
|
7589 | if (typeof name === 'string') {
|
7590 | if (value !== undefined) {
|
7591 | setAttribute(node, name, value);
|
7592 | } else {
|
7593 | return getAttribute(node, name);
|
7594 | }
|
7595 | } else {
|
7596 | setAttributes(node, name);
|
7597 | }
|
7598 |
|
7599 | return node;
|
7600 | }
|
7601 | |
7602 |
|
7603 |
|
7604 |
|
7605 |
|
7606 | function index(arr, obj) {
|
7607 | if (arr.indexOf) {
|
7608 | return arr.indexOf(obj);
|
7609 | }
|
7610 |
|
7611 | for (var i = 0; i < arr.length; ++i) {
|
7612 | if (arr[i] === obj) {
|
7613 | return i;
|
7614 | }
|
7615 | }
|
7616 |
|
7617 | return -1;
|
7618 | }
|
7619 |
|
7620 | var re$1 = /\s+/;
|
7621 | var toString$1 = Object.prototype.toString;
|
7622 |
|
7623 | function defined(o) {
|
7624 | return typeof o !== 'undefined';
|
7625 | }
|
7626 | |
7627 |
|
7628 |
|
7629 |
|
7630 |
|
7631 |
|
7632 |
|
7633 |
|
7634 |
|
7635 | function classes$1(el) {
|
7636 | return new ClassList$1(el);
|
7637 | }
|
7638 |
|
7639 | function ClassList$1(el) {
|
7640 | if (!el || !el.nodeType) {
|
7641 | throw new Error('A DOM element reference is required');
|
7642 | }
|
7643 |
|
7644 | this.el = el;
|
7645 | this.list = el.classList;
|
7646 | }
|
7647 | |
7648 |
|
7649 |
|
7650 |
|
7651 |
|
7652 |
|
7653 |
|
7654 |
|
7655 |
|
7656 | ClassList$1.prototype.add = function (name) {
|
7657 |
|
7658 | if (this.list) {
|
7659 | this.list.add(name);
|
7660 | return this;
|
7661 | }
|
7662 |
|
7663 |
|
7664 | var arr = this.array();
|
7665 | var i = index(arr, name);
|
7666 |
|
7667 | if (!~i) {
|
7668 | arr.push(name);
|
7669 | }
|
7670 |
|
7671 | if (defined(this.el.className.baseVal)) {
|
7672 | this.el.className.baseVal = arr.join(' ');
|
7673 | } else {
|
7674 | this.el.className = arr.join(' ');
|
7675 | }
|
7676 |
|
7677 | return this;
|
7678 | };
|
7679 | |
7680 |
|
7681 |
|
7682 |
|
7683 |
|
7684 |
|
7685 |
|
7686 |
|
7687 |
|
7688 |
|
7689 |
|
7690 | ClassList$1.prototype.remove = function (name) {
|
7691 | if ('[object RegExp]' === toString$1.call(name)) {
|
7692 | return this.removeMatching(name);
|
7693 | }
|
7694 |
|
7695 |
|
7696 | if (this.list) {
|
7697 | this.list.remove(name);
|
7698 | return this;
|
7699 | }
|
7700 |
|
7701 |
|
7702 | var arr = this.array();
|
7703 | var i = index(arr, name);
|
7704 |
|
7705 | if (~i) {
|
7706 | arr.splice(i, 1);
|
7707 | }
|
7708 |
|
7709 | this.el.className.baseVal = arr.join(' ');
|
7710 | return this;
|
7711 | };
|
7712 | |
7713 |
|
7714 |
|
7715 |
|
7716 |
|
7717 |
|
7718 |
|
7719 |
|
7720 |
|
7721 | ClassList$1.prototype.removeMatching = function (re) {
|
7722 | var arr = this.array();
|
7723 |
|
7724 | for (var i = 0; i < arr.length; i++) {
|
7725 | if (re.test(arr[i])) {
|
7726 | this.remove(arr[i]);
|
7727 | }
|
7728 | }
|
7729 |
|
7730 | return this;
|
7731 | };
|
7732 | |
7733 |
|
7734 |
|
7735 |
|
7736 |
|
7737 |
|
7738 |
|
7739 |
|
7740 |
|
7741 |
|
7742 |
|
7743 |
|
7744 |
|
7745 | ClassList$1.prototype.toggle = function (name, force) {
|
7746 |
|
7747 | if (this.list) {
|
7748 | if (defined(force)) {
|
7749 | if (force !== this.list.toggle(name, force)) {
|
7750 | this.list.toggle(name);
|
7751 | }
|
7752 | } else {
|
7753 | this.list.toggle(name);
|
7754 | }
|
7755 |
|
7756 | return this;
|
7757 | }
|
7758 |
|
7759 |
|
7760 | if (defined(force)) {
|
7761 | if (!force) {
|
7762 | this.remove(name);
|
7763 | } else {
|
7764 | this.add(name);
|
7765 | }
|
7766 | } else {
|
7767 | if (this.has(name)) {
|
7768 | this.remove(name);
|
7769 | } else {
|
7770 | this.add(name);
|
7771 | }
|
7772 | }
|
7773 |
|
7774 | return this;
|
7775 | };
|
7776 | |
7777 |
|
7778 |
|
7779 |
|
7780 |
|
7781 |
|
7782 |
|
7783 |
|
7784 | ClassList$1.prototype.array = function () {
|
7785 | var className = this.el.getAttribute('class') || '';
|
7786 | var str = className.replace(/^\s+|\s+$/g, '');
|
7787 | var arr = str.split(re$1);
|
7788 |
|
7789 | if ('' === arr[0]) {
|
7790 | arr.shift();
|
7791 | }
|
7792 |
|
7793 | return arr;
|
7794 | };
|
7795 | |
7796 |
|
7797 |
|
7798 |
|
7799 |
|
7800 |
|
7801 |
|
7802 |
|
7803 |
|
7804 | ClassList$1.prototype.has = ClassList$1.prototype.contains = function (name) {
|
7805 | return this.list ? this.list.contains(name) : !!~index(this.array(), name);
|
7806 | };
|
7807 |
|
7808 | function remove$1(element) {
|
7809 | var parent = element.parentNode;
|
7810 |
|
7811 | if (parent) {
|
7812 | parent.removeChild(element);
|
7813 | }
|
7814 |
|
7815 | return element;
|
7816 | }
|
7817 | |
7818 |
|
7819 |
|
7820 |
|
7821 | |
7822 |
|
7823 |
|
7824 |
|
7825 |
|
7826 |
|
7827 |
|
7828 |
|
7829 | function clear$1(element) {
|
7830 | var child;
|
7831 |
|
7832 | while (child = element.firstChild) {
|
7833 | remove$1(child);
|
7834 | }
|
7835 |
|
7836 | return element;
|
7837 | }
|
7838 |
|
7839 | var ns = {
|
7840 | svg: 'http://www.w3.org/2000/svg'
|
7841 | };
|
7842 | |
7843 |
|
7844 |
|
7845 |
|
7846 | var SVG_START = '<svg xmlns="' + ns.svg + '"';
|
7847 |
|
7848 | function parse$2(svg) {
|
7849 | var unwrap = false;
|
7850 |
|
7851 | if (svg.substring(0, 4) === '<svg') {
|
7852 | if (svg.indexOf(ns.svg) === -1) {
|
7853 | svg = SVG_START + svg.substring(4);
|
7854 | }
|
7855 | } else {
|
7856 |
|
7857 | svg = SVG_START + '>' + svg + '</svg>';
|
7858 | unwrap = true;
|
7859 | }
|
7860 |
|
7861 | var parsed = parseDocument(svg);
|
7862 |
|
7863 | if (!unwrap) {
|
7864 | return parsed;
|
7865 | }
|
7866 |
|
7867 | var fragment = document.createDocumentFragment();
|
7868 | var parent = parsed.firstChild;
|
7869 |
|
7870 | while (parent.firstChild) {
|
7871 | fragment.appendChild(parent.firstChild);
|
7872 | }
|
7873 |
|
7874 | return fragment;
|
7875 | }
|
7876 |
|
7877 | function parseDocument(svg) {
|
7878 | var parser;
|
7879 |
|
7880 | parser = new DOMParser();
|
7881 | parser.async = false;
|
7882 | return parser.parseFromString(svg, 'text/xml');
|
7883 | }
|
7884 | |
7885 |
|
7886 |
|
7887 |
|
7888 | |
7889 |
|
7890 |
|
7891 |
|
7892 |
|
7893 |
|
7894 |
|
7895 |
|
7896 |
|
7897 |
|
7898 | function create(name, attrs) {
|
7899 | var element;
|
7900 |
|
7901 | if (name.charAt(0) === '<') {
|
7902 | element = parse$2(name).firstChild;
|
7903 | element = document.importNode(element, true);
|
7904 | } else {
|
7905 | element = document.createElementNS(ns.svg, name);
|
7906 | }
|
7907 |
|
7908 | if (attrs) {
|
7909 | attr$1(element, attrs);
|
7910 | }
|
7911 |
|
7912 | return element;
|
7913 | }
|
7914 | |
7915 |
|
7916 |
|
7917 |
|
7918 |
|
7919 |
|
7920 | var node = create('svg');
|
7921 |
|
7922 | function extend(object, props) {
|
7923 | var i,
|
7924 | k,
|
7925 | keys = Object.keys(props);
|
7926 |
|
7927 | for (i = 0; k = keys[i]; i++) {
|
7928 | object[k] = props[k];
|
7929 | }
|
7930 |
|
7931 | return object;
|
7932 | }
|
7933 | |
7934 |
|
7935 |
|
7936 |
|
7937 |
|
7938 |
|
7939 |
|
7940 |
|
7941 |
|
7942 |
|
7943 |
|
7944 |
|
7945 |
|
7946 | function createMatrix(a, b, c, d, e, f) {
|
7947 | var matrix = node.createSVGMatrix();
|
7948 |
|
7949 | switch (arguments.length) {
|
7950 | case 0:
|
7951 | return matrix;
|
7952 |
|
7953 | case 1:
|
7954 | return extend(matrix, a);
|
7955 |
|
7956 | case 6:
|
7957 | return extend(matrix, {
|
7958 | a: a,
|
7959 | b: b,
|
7960 | c: c,
|
7961 | d: d,
|
7962 | e: e,
|
7963 | f: f
|
7964 | });
|
7965 | }
|
7966 | }
|
7967 |
|
7968 | function createTransform(matrix) {
|
7969 | if (matrix) {
|
7970 | return node.createSVGTransformFromMatrix(matrix);
|
7971 | } else {
|
7972 | return node.createSVGTransform();
|
7973 | }
|
7974 | }
|
7975 | |
7976 |
|
7977 |
|
7978 |
|
7979 |
|
7980 | var TEXT_ENTITIES = /([&<>]{1})/g;
|
7981 | var ATTR_ENTITIES = /([\n\r"]{1})/g;
|
7982 | var ENTITY_REPLACEMENT = {
|
7983 | '&': '&',
|
7984 | '<': '<',
|
7985 | '>': '>',
|
7986 | '"': '\''
|
7987 | };
|
7988 |
|
7989 | function escape$1(str, pattern) {
|
7990 | function replaceFn(match, entity) {
|
7991 | return ENTITY_REPLACEMENT[entity] || entity;
|
7992 | }
|
7993 |
|
7994 | return str.replace(pattern, replaceFn);
|
7995 | }
|
7996 |
|
7997 | function serialize(node, output) {
|
7998 | var i, len, attrMap, attrNode, childNodes;
|
7999 |
|
8000 | switch (node.nodeType) {
|
8001 |
|
8002 | case 3:
|
8003 |
|
8004 | output.push(escape$1(node.textContent, TEXT_ENTITIES));
|
8005 | break;
|
8006 |
|
8007 |
|
8008 | case 1:
|
8009 | output.push('<', node.tagName);
|
8010 |
|
8011 | if (node.hasAttributes()) {
|
8012 | attrMap = node.attributes;
|
8013 |
|
8014 | for (i = 0, len = attrMap.length; i < len; ++i) {
|
8015 | attrNode = attrMap.item(i);
|
8016 | output.push(' ', attrNode.name, '="', escape$1(attrNode.value, ATTR_ENTITIES), '"');
|
8017 | }
|
8018 | }
|
8019 |
|
8020 | if (node.hasChildNodes()) {
|
8021 | output.push('>');
|
8022 | childNodes = node.childNodes;
|
8023 |
|
8024 | for (i = 0, len = childNodes.length; i < len; ++i) {
|
8025 | serialize(childNodes.item(i), output);
|
8026 | }
|
8027 |
|
8028 | output.push('</', node.tagName, '>');
|
8029 | } else {
|
8030 | output.push('/>');
|
8031 | }
|
8032 |
|
8033 | break;
|
8034 |
|
8035 |
|
8036 | case 8:
|
8037 | output.push('<!--', escape$1(node.nodeValue, TEXT_ENTITIES), '-->');
|
8038 | break;
|
8039 |
|
8040 |
|
8041 | case 4:
|
8042 | output.push('<![CDATA[', node.nodeValue, ']]>');
|
8043 | break;
|
8044 |
|
8045 | default:
|
8046 | throw new Error('unable to handle node ' + node.nodeType);
|
8047 | }
|
8048 |
|
8049 | return output;
|
8050 | }
|
8051 | |
8052 |
|
8053 |
|
8054 |
|
8055 |
|
8056 |
|
8057 | function set(element, svg) {
|
8058 | var parsed = parse$2(svg);
|
8059 |
|
8060 | clear$1(element);
|
8061 |
|
8062 | if (!svg) {
|
8063 | return;
|
8064 | }
|
8065 |
|
8066 | if (!isFragment(parsed)) {
|
8067 |
|
8068 | parsed = parsed.documentElement;
|
8069 | }
|
8070 |
|
8071 | var nodes = slice$1(parsed.childNodes);
|
8072 |
|
8073 | for (var i = 0; i < nodes.length; i++) {
|
8074 | appendTo(nodes[i], element);
|
8075 | }
|
8076 | }
|
8077 |
|
8078 | function get(element) {
|
8079 | var child = element.firstChild,
|
8080 | output = [];
|
8081 |
|
8082 | while (child) {
|
8083 | serialize(child, output);
|
8084 | child = child.nextSibling;
|
8085 | }
|
8086 |
|
8087 | return output.join('');
|
8088 | }
|
8089 |
|
8090 | function isFragment(node) {
|
8091 | return node.nodeName === '#document-fragment';
|
8092 | }
|
8093 |
|
8094 | function innerSVG(element, svg) {
|
8095 | if (svg !== undefined) {
|
8096 | try {
|
8097 | set(element, svg);
|
8098 | } catch (e) {
|
8099 | throw new Error('error parsing SVG: ' + e.message);
|
8100 | }
|
8101 |
|
8102 | return element;
|
8103 | } else {
|
8104 | return get(element);
|
8105 | }
|
8106 | }
|
8107 |
|
8108 | function slice$1(arr) {
|
8109 | return Array.prototype.slice.call(arr);
|
8110 | }
|
8111 | |
8112 |
|
8113 |
|
8114 |
|
8115 |
|
8116 | function wrapMatrix(transformList, transform) {
|
8117 | if (transform instanceof SVGMatrix) {
|
8118 | return transformList.createSVGTransformFromMatrix(transform);
|
8119 | }
|
8120 |
|
8121 | return transform;
|
8122 | }
|
8123 |
|
8124 | function setTransforms(transformList, transforms) {
|
8125 | var i, t;
|
8126 | transformList.clear();
|
8127 |
|
8128 | for (i = 0; t = transforms[i]; i++) {
|
8129 | transformList.appendItem(wrapMatrix(transformList, t));
|
8130 | }
|
8131 | }
|
8132 | |
8133 |
|
8134 |
|
8135 |
|
8136 |
|
8137 |
|
8138 |
|
8139 |
|
8140 |
|
8141 |
|
8142 | function transform(node, transforms) {
|
8143 | var transformList = node.transform.baseVal;
|
8144 |
|
8145 | if (transforms) {
|
8146 | if (!Array.isArray(transforms)) {
|
8147 | transforms = [transforms];
|
8148 | }
|
8149 |
|
8150 | setTransforms(transformList, transforms);
|
8151 | }
|
8152 |
|
8153 | return transformList.consolidate();
|
8154 | }
|
8155 |
|
8156 | function componentsToPath(elements) {
|
8157 | return elements.join(',').replace(/,?([A-z]),?/g, '$1');
|
8158 | }
|
8159 | function toSVGPoints(points) {
|
8160 | var result = '';
|
8161 |
|
8162 | for (var i = 0, p; p = points[i]; i++) {
|
8163 | result += p.x + ',' + p.y + ' ';
|
8164 | }
|
8165 |
|
8166 | return result;
|
8167 | }
|
8168 | function createLine(points, attrs) {
|
8169 | var line = create('polyline');
|
8170 | attr$1(line, {
|
8171 | points: toSVGPoints(points)
|
8172 | });
|
8173 |
|
8174 | if (attrs) {
|
8175 | attr$1(line, attrs);
|
8176 | }
|
8177 |
|
8178 | return line;
|
8179 | }
|
8180 | function updateLine(gfx, points) {
|
8181 | attr$1(gfx, {
|
8182 | points: toSVGPoints(points)
|
8183 | });
|
8184 | return gfx;
|
8185 | }
|
8186 |
|
8187 | |
8188 |
|
8189 |
|
8190 |
|
8191 |
|
8192 |
|
8193 |
|
8194 |
|
8195 | function getBBox(elements, stopRecursion) {
|
8196 | stopRecursion = !!stopRecursion;
|
8197 |
|
8198 | if (!isArray(elements)) {
|
8199 | elements = [elements];
|
8200 | }
|
8201 |
|
8202 | var minX, minY, maxX, maxY;
|
8203 | forEach(elements, function (element) {
|
8204 |
|
8205 | var bbox = element;
|
8206 |
|
8207 | if (element.waypoints && !stopRecursion) {
|
8208 | bbox = getBBox(element.waypoints, true);
|
8209 | }
|
8210 |
|
8211 | var x = bbox.x,
|
8212 | y = bbox.y,
|
8213 | height = bbox.height || 0,
|
8214 | width = bbox.width || 0;
|
8215 |
|
8216 | if (x < minX || minX === undefined) {
|
8217 | minX = x;
|
8218 | }
|
8219 |
|
8220 | if (y < minY || minY === undefined) {
|
8221 | minY = y;
|
8222 | }
|
8223 |
|
8224 | if (x + width > maxX || maxX === undefined) {
|
8225 | maxX = x + width;
|
8226 | }
|
8227 |
|
8228 | if (y + height > maxY || maxY === undefined) {
|
8229 | maxY = y + height;
|
8230 | }
|
8231 | });
|
8232 | return {
|
8233 | x: minX,
|
8234 | y: minY,
|
8235 | height: maxY - minY,
|
8236 | width: maxX - minX
|
8237 | };
|
8238 | }
|
8239 | function getType(element) {
|
8240 | if ('waypoints' in element) {
|
8241 | return 'connection';
|
8242 | }
|
8243 |
|
8244 | if ('x' in element) {
|
8245 | return 'shape';
|
8246 | }
|
8247 |
|
8248 | return 'root';
|
8249 | }
|
8250 | function isFrameElement(element) {
|
8251 | return !!(element && element.isFrame);
|
8252 | }
|
8253 |
|
8254 |
|
8255 |
|
8256 | var DEFAULT_RENDER_PRIORITY$1 = 1;
|
8257 | |
8258 |
|
8259 |
|
8260 |
|
8261 |
|
8262 |
|
8263 |
|
8264 | function DefaultRenderer(eventBus, styles) {
|
8265 |
|
8266 | BaseRenderer.call(this, eventBus, DEFAULT_RENDER_PRIORITY$1);
|
8267 | this.CONNECTION_STYLE = styles.style(['no-fill'], {
|
8268 | strokeWidth: 5,
|
8269 | stroke: 'fuchsia'
|
8270 | });
|
8271 | this.SHAPE_STYLE = styles.style({
|
8272 | fill: 'white',
|
8273 | stroke: 'fuchsia',
|
8274 | strokeWidth: 2
|
8275 | });
|
8276 | this.FRAME_STYLE = styles.style(['no-fill'], {
|
8277 | stroke: 'fuchsia',
|
8278 | strokeDasharray: 4,
|
8279 | strokeWidth: 2
|
8280 | });
|
8281 | }
|
8282 | inherits_browser(DefaultRenderer, BaseRenderer);
|
8283 |
|
8284 | DefaultRenderer.prototype.canRender = function () {
|
8285 | return true;
|
8286 | };
|
8287 |
|
8288 | DefaultRenderer.prototype.drawShape = function drawShape(visuals, element) {
|
8289 | var rect = create('rect');
|
8290 | attr$1(rect, {
|
8291 | x: 0,
|
8292 | y: 0,
|
8293 | width: element.width || 0,
|
8294 | height: element.height || 0
|
8295 | });
|
8296 |
|
8297 | if (isFrameElement(element)) {
|
8298 | attr$1(rect, this.FRAME_STYLE);
|
8299 | } else {
|
8300 | attr$1(rect, this.SHAPE_STYLE);
|
8301 | }
|
8302 |
|
8303 | append(visuals, rect);
|
8304 | return rect;
|
8305 | };
|
8306 |
|
8307 | DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection) {
|
8308 | var line = createLine(connection.waypoints, this.CONNECTION_STYLE);
|
8309 | append(visuals, line);
|
8310 | return line;
|
8311 | };
|
8312 |
|
8313 | DefaultRenderer.prototype.getShapePath = function getShapePath(shape) {
|
8314 | var x = shape.x,
|
8315 | y = shape.y,
|
8316 | width = shape.width,
|
8317 | height = shape.height;
|
8318 | var shapePath = [['M', x, y], ['l', width, 0], ['l', 0, height], ['l', -width, 0], ['z']];
|
8319 | return componentsToPath(shapePath);
|
8320 | };
|
8321 |
|
8322 | DefaultRenderer.prototype.getConnectionPath = function getConnectionPath(connection) {
|
8323 | var waypoints = connection.waypoints;
|
8324 | var idx,
|
8325 | point,
|
8326 | connectionPath = [];
|
8327 |
|
8328 | for (idx = 0; point = waypoints[idx]; idx++) {
|
8329 |
|
8330 |
|
8331 | point = point.original || point;
|
8332 | connectionPath.push([idx === 0 ? 'M' : 'L', point.x, point.y]);
|
8333 | }
|
8334 |
|
8335 | return componentsToPath(connectionPath);
|
8336 | };
|
8337 |
|
8338 | DefaultRenderer.$inject = ['eventBus', 'styles'];
|
8339 |
|
8340 | |
8341 |
|
8342 |
|
8343 |
|
8344 | function Styles() {
|
8345 | var defaultTraits = {
|
8346 | 'no-fill': {
|
8347 | fill: 'none'
|
8348 | },
|
8349 | 'no-border': {
|
8350 | strokeOpacity: 0.0
|
8351 | },
|
8352 | 'no-events': {
|
8353 | pointerEvents: 'none'
|
8354 | }
|
8355 | };
|
8356 | var self = this;
|
8357 | |
8358 |
|
8359 |
|
8360 |
|
8361 |
|
8362 |
|
8363 |
|
8364 |
|
8365 |
|
8366 |
|
8367 | this.cls = function (className, traits, additionalAttrs) {
|
8368 | var attrs = this.style(traits, additionalAttrs);
|
8369 | return assign(attrs, {
|
8370 | 'class': className
|
8371 | });
|
8372 | };
|
8373 | |
8374 |
|
8375 |
|
8376 |
|
8377 |
|
8378 |
|
8379 |
|
8380 |
|
8381 |
|
8382 |
|
8383 | this.style = function (traits, additionalAttrs) {
|
8384 | if (!isArray(traits) && !additionalAttrs) {
|
8385 | additionalAttrs = traits;
|
8386 | traits = [];
|
8387 | }
|
8388 |
|
8389 | var attrs = reduce(traits, function (attrs, t) {
|
8390 | return assign(attrs, defaultTraits[t] || {});
|
8391 | }, {});
|
8392 | return additionalAttrs ? assign(attrs, additionalAttrs) : attrs;
|
8393 | };
|
8394 |
|
8395 | this.computeStyle = function (custom, traits, defaultStyles) {
|
8396 | if (!isArray(traits)) {
|
8397 | defaultStyles = traits;
|
8398 | traits = [];
|
8399 | }
|
8400 |
|
8401 | return self.style(traits || [], assign({}, defaultStyles, custom || {}));
|
8402 | };
|
8403 | }
|
8404 |
|
8405 | var DrawModule = {
|
8406 | __init__: ['defaultRenderer'],
|
8407 | defaultRenderer: ['type', DefaultRenderer],
|
8408 | styles: ['type', Styles]
|
8409 | };
|
8410 |
|
8411 | |
8412 |
|
8413 |
|
8414 |
|
8415 |
|
8416 |
|
8417 |
|
8418 |
|
8419 | function remove$2(collection, element) {
|
8420 | if (!collection || !element) {
|
8421 | return -1;
|
8422 | }
|
8423 |
|
8424 | var idx = collection.indexOf(element);
|
8425 |
|
8426 | if (idx !== -1) {
|
8427 | collection.splice(idx, 1);
|
8428 | }
|
8429 |
|
8430 | return idx;
|
8431 | }
|
8432 | |
8433 |
|
8434 |
|
8435 |
|
8436 |
|
8437 |
|
8438 |
|
8439 |
|
8440 |
|
8441 | function add(collection, element, idx) {
|
8442 | if (!collection || !element) {
|
8443 | return;
|
8444 | }
|
8445 |
|
8446 | if (typeof idx !== 'number') {
|
8447 | idx = -1;
|
8448 | }
|
8449 |
|
8450 | var currentIdx = collection.indexOf(element);
|
8451 |
|
8452 | if (currentIdx !== -1) {
|
8453 | if (currentIdx === idx) {
|
8454 |
|
8455 | return;
|
8456 | } else {
|
8457 | if (idx !== -1) {
|
8458 |
|
8459 | collection.splice(currentIdx, 1);
|
8460 | } else {
|
8461 |
|
8462 | return;
|
8463 | }
|
8464 | }
|
8465 | }
|
8466 |
|
8467 | if (idx !== -1) {
|
8468 |
|
8469 | collection.splice(idx, 0, element);
|
8470 | } else {
|
8471 |
|
8472 | collection.push(element);
|
8473 | }
|
8474 | }
|
8475 |
|
8476 | function round(number, resolution) {
|
8477 | return Math.round(number * resolution) / resolution;
|
8478 | }
|
8479 |
|
8480 | function ensurePx(number) {
|
8481 | return isNumber(number) ? number + 'px' : number;
|
8482 | }
|
8483 | |
8484 |
|
8485 |
|
8486 |
|
8487 |
|
8488 |
|
8489 |
|
8490 |
|
8491 |
|
8492 | function createContainer(options) {
|
8493 | options = assign({}, {
|
8494 | width: '100%',
|
8495 | height: '100%'
|
8496 | }, options);
|
8497 | var container = options.container || document.body;
|
8498 |
|
8499 |
|
8500 |
|
8501 | var parent = document.createElement('div');
|
8502 | parent.setAttribute('class', 'djs-container');
|
8503 | assign(parent.style, {
|
8504 | position: 'relative',
|
8505 | overflow: 'hidden',
|
8506 | width: ensurePx(options.width),
|
8507 | height: ensurePx(options.height)
|
8508 | });
|
8509 | container.appendChild(parent);
|
8510 | return parent;
|
8511 | }
|
8512 |
|
8513 | function createGroup(parent, cls, childIndex) {
|
8514 | var group = create('g');
|
8515 | classes$1(group).add(cls);
|
8516 | var index = childIndex !== undefined ? childIndex : parent.childNodes.length - 1;
|
8517 |
|
8518 |
|
8519 | parent.insertBefore(group, parent.childNodes[index] || null);
|
8520 | return group;
|
8521 | }
|
8522 |
|
8523 | var BASE_LAYER = 'base';
|
8524 | var REQUIRED_MODEL_ATTRS = {
|
8525 | shape: ['x', 'y', 'width', 'height'],
|
8526 | connection: ['waypoints']
|
8527 | };
|
8528 | |
8529 |
|
8530 |
|
8531 |
|
8532 |
|
8533 |
|
8534 |
|
8535 |
|
8536 |
|
8537 |
|
8538 |
|
8539 |
|
8540 |
|
8541 |
|
8542 | function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
8543 | this._eventBus = eventBus;
|
8544 | this._elementRegistry = elementRegistry;
|
8545 | this._graphicsFactory = graphicsFactory;
|
8546 |
|
8547 | this._init(config || {});
|
8548 | }
|
8549 | Canvas.$inject = ['config.canvas', 'eventBus', 'graphicsFactory', 'elementRegistry'];
|
8550 |
|
8551 | Canvas.prototype._init = function (config) {
|
8552 | var eventBus = this._eventBus;
|
8553 |
|
8554 |
|
8555 |
|
8556 |
|
8557 |
|
8558 |
|
8559 |
|
8560 |
|
8561 |
|
8562 |
|
8563 |
|
8564 |
|
8565 | var container = this._container = createContainer(config);
|
8566 | var svg = this._svg = create('svg');
|
8567 | attr$1(svg, {
|
8568 | width: '100%',
|
8569 | height: '100%'
|
8570 | });
|
8571 | append(container, svg);
|
8572 | var viewport = this._viewport = createGroup(svg, 'viewport');
|
8573 | this._layers = {};
|
8574 |
|
8575 |
|
8576 | if (config.deferUpdate !== false) {
|
8577 | this._viewboxChanged = debounce(bind(this._viewboxChanged, this), 300);
|
8578 | }
|
8579 |
|
8580 | eventBus.on('diagram.init', function () {
|
8581 | |
8582 |
|
8583 |
|
8584 |
|
8585 |
|
8586 |
|
8587 |
|
8588 |
|
8589 |
|
8590 |
|
8591 |
|
8592 | eventBus.fire('canvas.init', {
|
8593 | svg: svg,
|
8594 | viewport: viewport
|
8595 | });
|
8596 | }, this);
|
8597 |
|
8598 |
|
8599 | eventBus.on(['shape.added', 'connection.added', 'shape.removed', 'connection.removed', 'elements.changed'], function () {
|
8600 | delete this._cachedViewbox;
|
8601 | }, this);
|
8602 | eventBus.on('diagram.destroy', 500, this._destroy, this);
|
8603 | eventBus.on('diagram.clear', 500, this._clear, this);
|
8604 | };
|
8605 |
|
8606 | Canvas.prototype._destroy = function (emit) {
|
8607 | this._eventBus.fire('canvas.destroy', {
|
8608 | svg: this._svg,
|
8609 | viewport: this._viewport
|
8610 | });
|
8611 |
|
8612 | var parent = this._container.parentNode;
|
8613 |
|
8614 | if (parent) {
|
8615 | parent.removeChild(this._container);
|
8616 | }
|
8617 |
|
8618 | delete this._svg;
|
8619 | delete this._container;
|
8620 | delete this._layers;
|
8621 | delete this._rootElement;
|
8622 | delete this._viewport;
|
8623 | };
|
8624 |
|
8625 | Canvas.prototype._clear = function () {
|
8626 | var self = this;
|
8627 |
|
8628 | var allElements = this._elementRegistry.getAll();
|
8629 |
|
8630 |
|
8631 | allElements.forEach(function (element) {
|
8632 | var type = getType(element);
|
8633 |
|
8634 | if (type === 'root') {
|
8635 | self.setRootElement(null, true);
|
8636 | } else {
|
8637 | self._removeElement(element, type);
|
8638 | }
|
8639 | });
|
8640 |
|
8641 | delete this._cachedViewbox;
|
8642 | };
|
8643 | |
8644 |
|
8645 |
|
8646 |
|
8647 |
|
8648 |
|
8649 |
|
8650 |
|
8651 | Canvas.prototype.getDefaultLayer = function () {
|
8652 | return this.getLayer(BASE_LAYER, 0);
|
8653 | };
|
8654 | |
8655 |
|
8656 |
|
8657 |
|
8658 |
|
8659 |
|
8660 |
|
8661 |
|
8662 |
|
8663 |
|
8664 |
|
8665 |
|
8666 |
|
8667 |
|
8668 |
|
8669 |
|
8670 |
|
8671 | Canvas.prototype.getLayer = function (name, index) {
|
8672 | if (!name) {
|
8673 | throw new Error('must specify a name');
|
8674 | }
|
8675 |
|
8676 | var layer = this._layers[name];
|
8677 |
|
8678 | if (!layer) {
|
8679 | layer = this._layers[name] = this._createLayer(name, index);
|
8680 | }
|
8681 |
|
8682 |
|
8683 |
|
8684 | if (typeof index !== 'undefined' && layer.index !== index) {
|
8685 | throw new Error('layer <' + name + '> already created at index <' + index + '>');
|
8686 | }
|
8687 |
|
8688 | return layer.group;
|
8689 | };
|
8690 | |
8691 |
|
8692 |
|
8693 |
|
8694 |
|
8695 |
|
8696 |
|
8697 |
|
8698 |
|
8699 |
|
8700 | Canvas.prototype._createLayer = function (name, index) {
|
8701 | if (!index) {
|
8702 | index = 0;
|
8703 | }
|
8704 |
|
8705 | var childIndex = reduce(this._layers, function (childIndex, layer) {
|
8706 | if (index >= layer.index) {
|
8707 | childIndex++;
|
8708 | }
|
8709 |
|
8710 | return childIndex;
|
8711 | }, 0);
|
8712 | return {
|
8713 | group: createGroup(this._viewport, 'layer-' + name, childIndex),
|
8714 | index: index
|
8715 | };
|
8716 | };
|
8717 | |
8718 |
|
8719 |
|
8720 |
|
8721 |
|
8722 |
|
8723 |
|
8724 |
|
8725 | Canvas.prototype.getContainer = function () {
|
8726 | return this._container;
|
8727 | };
|
8728 |
|
8729 |
|
8730 | Canvas.prototype._updateMarker = function (element, marker, add) {
|
8731 | var container;
|
8732 |
|
8733 | if (!element.id) {
|
8734 | element = this._elementRegistry.get(element);
|
8735 | }
|
8736 |
|
8737 |
|
8738 | container = this._elementRegistry._elements[element.id];
|
8739 |
|
8740 | if (!container) {
|
8741 | return;
|
8742 | }
|
8743 |
|
8744 | forEach([container.gfx, container.secondaryGfx], function (gfx) {
|
8745 | if (gfx) {
|
8746 |
|
8747 | if (add) {
|
8748 | classes$1(gfx).add(marker);
|
8749 | } else {
|
8750 | classes$1(gfx).remove(marker);
|
8751 | }
|
8752 | }
|
8753 | });
|
8754 | |
8755 |
|
8756 |
|
8757 |
|
8758 |
|
8759 |
|
8760 |
|
8761 |
|
8762 |
|
8763 |
|
8764 |
|
8765 | this._eventBus.fire('element.marker.update', {
|
8766 | element: element,
|
8767 | gfx: container.gfx,
|
8768 | marker: marker,
|
8769 | add: !!add
|
8770 | });
|
8771 | };
|
8772 | |
8773 |
|
8774 |
|
8775 |
|
8776 |
|
8777 |
|
8778 |
|
8779 |
|
8780 |
|
8781 |
|
8782 |
|
8783 |
|
8784 |
|
8785 |
|
8786 |
|
8787 |
|
8788 |
|
8789 |
|
8790 | Canvas.prototype.addMarker = function (element, marker) {
|
8791 | this._updateMarker(element, marker, true);
|
8792 | };
|
8793 | |
8794 |
|
8795 |
|
8796 |
|
8797 |
|
8798 |
|
8799 |
|
8800 |
|
8801 |
|
8802 |
|
8803 |
|
8804 | Canvas.prototype.removeMarker = function (element, marker) {
|
8805 | this._updateMarker(element, marker, false);
|
8806 | };
|
8807 | |
8808 |
|
8809 |
|
8810 |
|
8811 |
|
8812 |
|
8813 |
|
8814 |
|
8815 | Canvas.prototype.hasMarker = function (element, marker) {
|
8816 | if (!element.id) {
|
8817 | element = this._elementRegistry.get(element);
|
8818 | }
|
8819 |
|
8820 | var gfx = this.getGraphics(element);
|
8821 | return classes$1(gfx).has(marker);
|
8822 | };
|
8823 | |
8824 |
|
8825 |
|
8826 |
|
8827 |
|
8828 |
|
8829 |
|
8830 |
|
8831 |
|
8832 |
|
8833 |
|
8834 | Canvas.prototype.toggleMarker = function (element, marker) {
|
8835 | if (this.hasMarker(element, marker)) {
|
8836 | this.removeMarker(element, marker);
|
8837 | } else {
|
8838 | this.addMarker(element, marker);
|
8839 | }
|
8840 | };
|
8841 |
|
8842 | Canvas.prototype.getRootElement = function () {
|
8843 | if (!this._rootElement) {
|
8844 | this.setRootElement({
|
8845 | id: '__implicitroot',
|
8846 | children: []
|
8847 | });
|
8848 | }
|
8849 |
|
8850 | return this._rootElement;
|
8851 | };
|
8852 |
|
8853 | |
8854 |
|
8855 |
|
8856 |
|
8857 |
|
8858 |
|
8859 |
|
8860 |
|
8861 |
|
8862 |
|
8863 |
|
8864 | Canvas.prototype.setRootElement = function (element, override) {
|
8865 | if (element) {
|
8866 | this._ensureValid('root', element);
|
8867 | }
|
8868 |
|
8869 | var currentRoot = this._rootElement,
|
8870 | elementRegistry = this._elementRegistry,
|
8871 | eventBus = this._eventBus;
|
8872 |
|
8873 | if (currentRoot) {
|
8874 | if (!override) {
|
8875 | throw new Error('rootElement already set, need to specify override');
|
8876 | }
|
8877 |
|
8878 |
|
8879 | eventBus.fire('root.remove', {
|
8880 | element: currentRoot
|
8881 | });
|
8882 | eventBus.fire('root.removed', {
|
8883 | element: currentRoot
|
8884 | });
|
8885 | elementRegistry.remove(currentRoot);
|
8886 | }
|
8887 |
|
8888 | if (element) {
|
8889 | var gfx = this.getDefaultLayer();
|
8890 |
|
8891 | eventBus.fire('root.add', {
|
8892 | element: element
|
8893 | });
|
8894 | elementRegistry.add(element, gfx, this._svg);
|
8895 | eventBus.fire('root.added', {
|
8896 | element: element,
|
8897 | gfx: gfx
|
8898 | });
|
8899 | }
|
8900 |
|
8901 | this._rootElement = element;
|
8902 | return element;
|
8903 | };
|
8904 |
|
8905 |
|
8906 | Canvas.prototype._ensureValid = function (type, element) {
|
8907 | if (!element.id) {
|
8908 | throw new Error('element must have an id');
|
8909 | }
|
8910 |
|
8911 | if (this._elementRegistry.get(element.id)) {
|
8912 | throw new Error('element with id ' + element.id + ' already exists');
|
8913 | }
|
8914 |
|
8915 | var requiredAttrs = REQUIRED_MODEL_ATTRS[type];
|
8916 | var valid = every(requiredAttrs, function (attr) {
|
8917 | return typeof element[attr] !== 'undefined';
|
8918 | });
|
8919 |
|
8920 | if (!valid) {
|
8921 | throw new Error('must supply { ' + requiredAttrs.join(', ') + ' } with ' + type);
|
8922 | }
|
8923 | };
|
8924 |
|
8925 | Canvas.prototype._setParent = function (element, parent, parentIndex) {
|
8926 | add(parent.children, element, parentIndex);
|
8927 | element.parent = parent;
|
8928 | };
|
8929 | |
8930 |
|
8931 |
|
8932 |
|
8933 |
|
8934 |
|
8935 |
|
8936 |
|
8937 |
|
8938 |
|
8939 |
|
8940 |
|
8941 |
|
8942 |
|
8943 |
|
8944 |
|
8945 |
|
8946 |
|
8947 |
|
8948 |
|
8949 |
|
8950 |
|
8951 | Canvas.prototype._addElement = function (type, element, parent, parentIndex) {
|
8952 | parent = parent || this.getRootElement();
|
8953 | var eventBus = this._eventBus,
|
8954 | graphicsFactory = this._graphicsFactory;
|
8955 |
|
8956 | this._ensureValid(type, element);
|
8957 |
|
8958 | eventBus.fire(type + '.add', {
|
8959 | element: element,
|
8960 | parent: parent
|
8961 | });
|
8962 |
|
8963 | this._setParent(element, parent, parentIndex);
|
8964 |
|
8965 |
|
8966 | var gfx = graphicsFactory.create(type, element, parentIndex);
|
8967 |
|
8968 | this._elementRegistry.add(element, gfx);
|
8969 |
|
8970 |
|
8971 | graphicsFactory.update(type, element, gfx);
|
8972 | eventBus.fire(type + '.added', {
|
8973 | element: element,
|
8974 | gfx: gfx
|
8975 | });
|
8976 | return element;
|
8977 | };
|
8978 | |
8979 |
|
8980 |
|
8981 |
|
8982 |
|
8983 |
|
8984 |
|
8985 |
|
8986 |
|
8987 |
|
8988 |
|
8989 | Canvas.prototype.addShape = function (shape, parent, parentIndex) {
|
8990 | return this._addElement('shape', shape, parent, parentIndex);
|
8991 | };
|
8992 | |
8993 |
|
8994 |
|
8995 |
|
8996 |
|
8997 |
|
8998 |
|
8999 |
|
9000 |
|
9001 |
|
9002 |
|
9003 | Canvas.prototype.addConnection = function (connection, parent, parentIndex) {
|
9004 | return this._addElement('connection', connection, parent, parentIndex);
|
9005 | };
|
9006 | |
9007 |
|
9008 |
|
9009 |
|
9010 |
|
9011 | Canvas.prototype._removeElement = function (element, type) {
|
9012 | var elementRegistry = this._elementRegistry,
|
9013 | graphicsFactory = this._graphicsFactory,
|
9014 | eventBus = this._eventBus;
|
9015 | element = elementRegistry.get(element.id || element);
|
9016 |
|
9017 | if (!element) {
|
9018 |
|
9019 | return;
|
9020 | }
|
9021 |
|
9022 | eventBus.fire(type + '.remove', {
|
9023 | element: element
|
9024 | });
|
9025 | graphicsFactory.remove(element);
|
9026 |
|
9027 | remove$2(element.parent && element.parent.children, element);
|
9028 | element.parent = null;
|
9029 | eventBus.fire(type + '.removed', {
|
9030 | element: element
|
9031 | });
|
9032 | elementRegistry.remove(element);
|
9033 | return element;
|
9034 | };
|
9035 | |
9036 |
|
9037 |
|
9038 |
|
9039 |
|
9040 |
|
9041 |
|
9042 |
|
9043 |
|
9044 | Canvas.prototype.removeShape = function (shape) {
|
9045 | |
9046 |
|
9047 |
|
9048 |
|
9049 |
|
9050 |
|
9051 |
|
9052 |
|
9053 |
|
9054 |
|
9055 |
|
9056 | |
9057 |
|
9058 |
|
9059 |
|
9060 |
|
9061 |
|
9062 |
|
9063 |
|
9064 |
|
9065 |
|
9066 | return this._removeElement(shape, 'shape');
|
9067 | };
|
9068 | |
9069 |
|
9070 |
|
9071 |
|
9072 |
|
9073 |
|
9074 |
|
9075 |
|
9076 |
|
9077 | Canvas.prototype.removeConnection = function (connection) {
|
9078 | |
9079 |
|
9080 |
|
9081 |
|
9082 |
|
9083 |
|
9084 |
|
9085 |
|
9086 |
|
9087 |
|
9088 |
|
9089 | |
9090 |
|
9091 |
|
9092 |
|
9093 |
|
9094 |
|
9095 |
|
9096 |
|
9097 |
|
9098 |
|
9099 | return this._removeElement(connection, 'connection');
|
9100 | };
|
9101 | |
9102 |
|
9103 |
|
9104 |
|
9105 |
|
9106 |
|
9107 |
|
9108 |
|
9109 |
|
9110 |
|
9111 | Canvas.prototype.getGraphics = function (element, secondary) {
|
9112 | return this._elementRegistry.getGraphics(element, secondary);
|
9113 | };
|
9114 | |
9115 |
|
9116 |
|
9117 |
|
9118 |
|
9119 |
|
9120 |
|
9121 | Canvas.prototype._changeViewbox = function (changeFn) {
|
9122 |
|
9123 | this._eventBus.fire('canvas.viewbox.changing');
|
9124 |
|
9125 |
|
9126 | changeFn.apply(this);
|
9127 |
|
9128 |
|
9129 |
|
9130 | this._cachedViewbox = null;
|
9131 |
|
9132 |
|
9133 | this._viewboxChanged();
|
9134 | };
|
9135 |
|
9136 | Canvas.prototype._viewboxChanged = function () {
|
9137 | this._eventBus.fire('canvas.viewbox.changed', {
|
9138 | viewbox: this.viewbox()
|
9139 | });
|
9140 | };
|
9141 | |
9142 |
|
9143 |
|
9144 |
|
9145 |
|
9146 |
|
9147 |
|
9148 |
|
9149 |
|
9150 |
|
9151 |
|
9152 |
|
9153 |
|
9154 |
|
9155 |
|
9156 |
|
9157 |
|
9158 |
|
9159 |
|
9160 |
|
9161 |
|
9162 |
|
9163 |
|
9164 |
|
9165 |
|
9166 |
|
9167 |
|
9168 |
|
9169 |
|
9170 |
|
9171 |
|
9172 |
|
9173 |
|
9174 |
|
9175 |
|
9176 |
|
9177 |
|
9178 |
|
9179 |
|
9180 |
|
9181 |
|
9182 |
|
9183 |
|
9184 |
|
9185 |
|
9186 |
|
9187 |
|
9188 | Canvas.prototype.viewbox = function (box) {
|
9189 | if (box === undefined && this._cachedViewbox) {
|
9190 | return this._cachedViewbox;
|
9191 | }
|
9192 |
|
9193 | var viewport = this._viewport,
|
9194 | innerBox,
|
9195 | outerBox = this.getSize(),
|
9196 | matrix,
|
9197 | transform$1,
|
9198 | scale,
|
9199 | x,
|
9200 | y;
|
9201 |
|
9202 | if (!box) {
|
9203 |
|
9204 |
|
9205 |
|
9206 | innerBox = this.getDefaultLayer().getBBox();
|
9207 | transform$1 = transform(viewport);
|
9208 | matrix = transform$1 ? transform$1.matrix : createMatrix();
|
9209 | scale = round(matrix.a, 1000);
|
9210 | x = round(-matrix.e || 0, 1000);
|
9211 | y = round(-matrix.f || 0, 1000);
|
9212 | box = this._cachedViewbox = {
|
9213 | x: x ? x / scale : 0,
|
9214 | y: y ? y / scale : 0,
|
9215 | width: outerBox.width / scale,
|
9216 | height: outerBox.height / scale,
|
9217 | scale: scale,
|
9218 | inner: {
|
9219 | width: innerBox.width,
|
9220 | height: innerBox.height,
|
9221 | x: innerBox.x,
|
9222 | y: innerBox.y
|
9223 | },
|
9224 | outer: outerBox
|
9225 | };
|
9226 | return box;
|
9227 | } else {
|
9228 | this._changeViewbox(function () {
|
9229 | scale = Math.min(outerBox.width / box.width, outerBox.height / box.height);
|
9230 |
|
9231 | var matrix = this._svg.createSVGMatrix().scale(scale).translate(-box.x, -box.y);
|
9232 |
|
9233 | transform(viewport, matrix);
|
9234 | });
|
9235 | }
|
9236 |
|
9237 | return box;
|
9238 | };
|
9239 | |
9240 |
|
9241 |
|
9242 |
|
9243 |
|
9244 |
|
9245 |
|
9246 |
|
9247 |
|
9248 |
|
9249 | Canvas.prototype.scroll = function (delta) {
|
9250 | var node = this._viewport;
|
9251 | var matrix = node.getCTM();
|
9252 |
|
9253 | if (delta) {
|
9254 | this._changeViewbox(function () {
|
9255 | delta = assign({
|
9256 | dx: 0,
|
9257 | dy: 0
|
9258 | }, delta || {});
|
9259 | matrix = this._svg.createSVGMatrix().translate(delta.dx, delta.dy).multiply(matrix);
|
9260 | setCTM(node, matrix);
|
9261 | });
|
9262 | }
|
9263 |
|
9264 | return {
|
9265 | x: matrix.e,
|
9266 | y: matrix.f
|
9267 | };
|
9268 | };
|
9269 | |
9270 |
|
9271 |
|
9272 |
|
9273 |
|
9274 |
|
9275 |
|
9276 |
|
9277 |
|
9278 |
|
9279 |
|
9280 |
|
9281 |
|
9282 |
|
9283 |
|
9284 | Canvas.prototype.zoom = function (newScale, center) {
|
9285 | if (!newScale) {
|
9286 | return this.viewbox(newScale).scale;
|
9287 | }
|
9288 |
|
9289 | if (newScale === 'fit-viewport') {
|
9290 | return this._fitViewport(center);
|
9291 | }
|
9292 |
|
9293 | var outer, matrix;
|
9294 |
|
9295 | this._changeViewbox(function () {
|
9296 | if (_typeof(center) !== 'object') {
|
9297 | outer = this.viewbox().outer;
|
9298 | center = {
|
9299 | x: outer.width / 2,
|
9300 | y: outer.height / 2
|
9301 | };
|
9302 | }
|
9303 |
|
9304 | matrix = this._setZoom(newScale, center);
|
9305 | });
|
9306 |
|
9307 | return round(matrix.a, 1000);
|
9308 | };
|
9309 |
|
9310 | function setCTM(node, m) {
|
9311 | var mstr = 'matrix(' + m.a + ',' + m.b + ',' + m.c + ',' + m.d + ',' + m.e + ',' + m.f + ')';
|
9312 | node.setAttribute('transform', mstr);
|
9313 | }
|
9314 |
|
9315 | Canvas.prototype._fitViewport = function (center) {
|
9316 | var vbox = this.viewbox(),
|
9317 | outer = vbox.outer,
|
9318 | inner = vbox.inner,
|
9319 | newScale,
|
9320 | newViewbox;
|
9321 |
|
9322 |
|
9323 |
|
9324 |
|
9325 |
|
9326 |
|
9327 | if (inner.x >= 0 && inner.y >= 0 && inner.x + inner.width <= outer.width && inner.y + inner.height <= outer.height && !center) {
|
9328 | newViewbox = {
|
9329 | x: 0,
|
9330 | y: 0,
|
9331 | width: Math.max(inner.width + inner.x, outer.width),
|
9332 | height: Math.max(inner.height + inner.y, outer.height)
|
9333 | };
|
9334 | } else {
|
9335 | newScale = Math.min(1, outer.width / inner.width, outer.height / inner.height);
|
9336 | newViewbox = {
|
9337 | x: inner.x + (center ? inner.width / 2 - outer.width / newScale / 2 : 0),
|
9338 | y: inner.y + (center ? inner.height / 2 - outer.height / newScale / 2 : 0),
|
9339 | width: outer.width / newScale,
|
9340 | height: outer.height / newScale
|
9341 | };
|
9342 | }
|
9343 |
|
9344 | this.viewbox(newViewbox);
|
9345 | return this.viewbox(false).scale;
|
9346 | };
|
9347 |
|
9348 | Canvas.prototype._setZoom = function (scale, center) {
|
9349 | var svg = this._svg,
|
9350 | viewport = this._viewport;
|
9351 | var matrix = svg.createSVGMatrix();
|
9352 | var point = svg.createSVGPoint();
|
9353 | var centerPoint, originalPoint, currentMatrix, scaleMatrix, newMatrix;
|
9354 | currentMatrix = viewport.getCTM();
|
9355 | var currentScale = currentMatrix.a;
|
9356 |
|
9357 | if (center) {
|
9358 | centerPoint = assign(point, center);
|
9359 |
|
9360 | originalPoint = centerPoint.matrixTransform(currentMatrix.inverse());
|
9361 |
|
9362 | scaleMatrix = matrix.translate(originalPoint.x, originalPoint.y).scale(1 / currentScale * scale).translate(-originalPoint.x, -originalPoint.y);
|
9363 | newMatrix = currentMatrix.multiply(scaleMatrix);
|
9364 | } else {
|
9365 | newMatrix = matrix.scale(scale);
|
9366 | }
|
9367 |
|
9368 | setCTM(this._viewport, newMatrix);
|
9369 | return newMatrix;
|
9370 | };
|
9371 | |
9372 |
|
9373 |
|
9374 |
|
9375 |
|
9376 |
|
9377 |
|
9378 | Canvas.prototype.getSize = function () {
|
9379 | return {
|
9380 | width: this._container.clientWidth,
|
9381 | height: this._container.clientHeight
|
9382 | };
|
9383 | };
|
9384 | |
9385 |
|
9386 |
|
9387 |
|
9388 |
|
9389 |
|
9390 |
|
9391 |
|
9392 |
|
9393 |
|
9394 |
|
9395 |
|
9396 | Canvas.prototype.getAbsoluteBBox = function (element) {
|
9397 | var vbox = this.viewbox();
|
9398 | var bbox;
|
9399 |
|
9400 |
|
9401 | if (element.waypoints) {
|
9402 | var gfx = this.getGraphics(element);
|
9403 | bbox = gfx.getBBox();
|
9404 | }
|
9405 |
|
9406 | else {
|
9407 | bbox = element;
|
9408 | }
|
9409 |
|
9410 | var x = bbox.x * vbox.scale - vbox.x * vbox.scale;
|
9411 | var y = bbox.y * vbox.scale - vbox.y * vbox.scale;
|
9412 | var width = bbox.width * vbox.scale;
|
9413 | var height = bbox.height * vbox.scale;
|
9414 | return {
|
9415 | x: x,
|
9416 | y: y,
|
9417 | width: width,
|
9418 | height: height
|
9419 | };
|
9420 | };
|
9421 | |
9422 |
|
9423 |
|
9424 |
|
9425 |
|
9426 |
|
9427 | Canvas.prototype.resized = function () {
|
9428 |
|
9429 | delete this._cachedViewbox;
|
9430 |
|
9431 | this._eventBus.fire('canvas.resized');
|
9432 | };
|
9433 |
|
9434 | var ELEMENT_ID = 'data-element-id';
|
9435 | |
9436 |
|
9437 |
|
9438 |
|
9439 |
|
9440 |
|
9441 | function ElementRegistry(eventBus) {
|
9442 | this._elements = {};
|
9443 | this._eventBus = eventBus;
|
9444 | }
|
9445 | ElementRegistry.$inject = ['eventBus'];
|
9446 | |
9447 |
|
9448 |
|
9449 |
|
9450 |
|
9451 |
|
9452 |
|
9453 |
|
9454 | ElementRegistry.prototype.add = function (element, gfx, secondaryGfx) {
|
9455 | var id = element.id;
|
9456 |
|
9457 | this._validateId(id);
|
9458 |
|
9459 |
|
9460 | attr$1(gfx, ELEMENT_ID, id);
|
9461 |
|
9462 | if (secondaryGfx) {
|
9463 | attr$1(secondaryGfx, ELEMENT_ID, id);
|
9464 | }
|
9465 |
|
9466 | this._elements[id] = {
|
9467 | element: element,
|
9468 | gfx: gfx,
|
9469 | secondaryGfx: secondaryGfx
|
9470 | };
|
9471 | };
|
9472 | |
9473 |
|
9474 |
|
9475 |
|
9476 |
|
9477 |
|
9478 |
|
9479 | ElementRegistry.prototype.remove = function (element) {
|
9480 | var elements = this._elements,
|
9481 | id = element.id || element,
|
9482 | container = id && elements[id];
|
9483 |
|
9484 | if (container) {
|
9485 |
|
9486 | attr$1(container.gfx, ELEMENT_ID, '');
|
9487 |
|
9488 | if (container.secondaryGfx) {
|
9489 | attr$1(container.secondaryGfx, ELEMENT_ID, '');
|
9490 | }
|
9491 |
|
9492 | delete elements[id];
|
9493 | }
|
9494 | };
|
9495 | |
9496 |
|
9497 |
|
9498 |
|
9499 |
|
9500 |
|
9501 |
|
9502 |
|
9503 | ElementRegistry.prototype.updateId = function (element, newId) {
|
9504 | this._validateId(newId);
|
9505 |
|
9506 | if (typeof element === 'string') {
|
9507 | element = this.get(element);
|
9508 | }
|
9509 |
|
9510 | this._eventBus.fire('element.updateId', {
|
9511 | element: element,
|
9512 | newId: newId
|
9513 | });
|
9514 |
|
9515 | var gfx = this.getGraphics(element),
|
9516 | secondaryGfx = this.getGraphics(element, true);
|
9517 | this.remove(element);
|
9518 | element.id = newId;
|
9519 | this.add(element, gfx, secondaryGfx);
|
9520 | };
|
9521 | |
9522 |
|
9523 |
|
9524 |
|
9525 |
|
9526 |
|
9527 |
|
9528 |
|
9529 |
|
9530 |
|
9531 |
|
9532 |
|
9533 |
|
9534 |
|
9535 |
|
9536 | ElementRegistry.prototype.get = function (filter) {
|
9537 | var id;
|
9538 |
|
9539 | if (typeof filter === 'string') {
|
9540 | id = filter;
|
9541 | } else {
|
9542 | id = filter && attr$1(filter, ELEMENT_ID);
|
9543 | }
|
9544 |
|
9545 | var container = this._elements[id];
|
9546 | return container && container.element;
|
9547 | };
|
9548 | |
9549 |
|
9550 |
|
9551 |
|
9552 |
|
9553 |
|
9554 |
|
9555 |
|
9556 |
|
9557 | ElementRegistry.prototype.filter = function (fn) {
|
9558 | var filtered = [];
|
9559 | this.forEach(function (element, gfx) {
|
9560 | if (fn(element, gfx)) {
|
9561 | filtered.push(element);
|
9562 | }
|
9563 | });
|
9564 | return filtered;
|
9565 | };
|
9566 | |
9567 |
|
9568 |
|
9569 |
|
9570 |
|
9571 |
|
9572 |
|
9573 | ElementRegistry.prototype.getAll = function () {
|
9574 | return this.filter(function (e) {
|
9575 | return e;
|
9576 | });
|
9577 | };
|
9578 | |
9579 |
|
9580 |
|
9581 |
|
9582 |
|
9583 |
|
9584 |
|
9585 | ElementRegistry.prototype.forEach = function (fn) {
|
9586 | var map = this._elements;
|
9587 | Object.keys(map).forEach(function (id) {
|
9588 | var container = map[id],
|
9589 | element = container.element,
|
9590 | gfx = container.gfx;
|
9591 | return fn(element, gfx);
|
9592 | });
|
9593 | };
|
9594 | |
9595 |
|
9596 |
|
9597 |
|
9598 |
|
9599 |
|
9600 |
|
9601 |
|
9602 |
|
9603 |
|
9604 |
|
9605 |
|
9606 |
|
9607 |
|
9608 |
|
9609 |
|
9610 |
|
9611 | ElementRegistry.prototype.getGraphics = function (filter, secondary) {
|
9612 | var id = filter.id || filter;
|
9613 | var container = this._elements[id];
|
9614 | return container && (secondary ? container.secondaryGfx : container.gfx);
|
9615 | };
|
9616 | |
9617 |
|
9618 |
|
9619 |
|
9620 |
|
9621 |
|
9622 |
|
9623 |
|
9624 |
|
9625 |
|
9626 | ElementRegistry.prototype._validateId = function (id) {
|
9627 | if (!id) {
|
9628 | throw new Error('element must have an id');
|
9629 | }
|
9630 |
|
9631 | if (this._elements[id]) {
|
9632 | throw new Error('element with id ' + id + ' already added');
|
9633 | }
|
9634 | };
|
9635 |
|
9636 | |
9637 |
|
9638 |
|
9639 |
|
9640 |
|
9641 |
|
9642 |
|
9643 | |
9644 |
|
9645 |
|
9646 |
|
9647 |
|
9648 |
|
9649 |
|
9650 |
|
9651 |
|
9652 |
|
9653 |
|
9654 |
|
9655 |
|
9656 |
|
9657 | function extend$1(collection, refs, property, target) {
|
9658 | var inverseProperty = property.inverse;
|
9659 | |
9660 |
|
9661 |
|
9662 |
|
9663 |
|
9664 |
|
9665 |
|
9666 |
|
9667 | Object.defineProperty(collection, 'remove', {
|
9668 | value: function value(element) {
|
9669 | var idx = this.indexOf(element);
|
9670 |
|
9671 | if (idx !== -1) {
|
9672 | this.splice(idx, 1);
|
9673 |
|
9674 | refs.unset(element, inverseProperty, target);
|
9675 | }
|
9676 |
|
9677 | return element;
|
9678 | }
|
9679 | });
|
9680 | |
9681 |
|
9682 |
|
9683 |
|
9684 |
|
9685 |
|
9686 |
|
9687 |
|
9688 | Object.defineProperty(collection, 'contains', {
|
9689 | value: function value(element) {
|
9690 | return this.indexOf(element) !== -1;
|
9691 | }
|
9692 | });
|
9693 | |
9694 |
|
9695 |
|
9696 |
|
9697 |
|
9698 |
|
9699 |
|
9700 |
|
9701 |
|
9702 |
|
9703 | Object.defineProperty(collection, 'add', {
|
9704 | value: function value(element, idx) {
|
9705 | var currentIdx = this.indexOf(element);
|
9706 |
|
9707 | if (typeof idx === 'undefined') {
|
9708 | if (currentIdx !== -1) {
|
9709 |
|
9710 | return;
|
9711 | }
|
9712 |
|
9713 |
|
9714 | idx = this.length;
|
9715 | }
|
9716 |
|
9717 |
|
9718 | if (currentIdx !== -1) {
|
9719 |
|
9720 | this.splice(currentIdx, 1);
|
9721 | }
|
9722 |
|
9723 |
|
9724 | this.splice(idx, 0, element);
|
9725 |
|
9726 | if (currentIdx === -1) {
|
9727 |
|
9728 |
|
9729 | refs.set(element, inverseProperty, target);
|
9730 | }
|
9731 | }
|
9732 | });
|
9733 |
|
9734 |
|
9735 | Object.defineProperty(collection, '__refs_collection', {
|
9736 | value: true
|
9737 | });
|
9738 | return collection;
|
9739 | }
|
9740 |
|
9741 | function isExtended(collection) {
|
9742 | return collection.__refs_collection === true;
|
9743 | }
|
9744 |
|
9745 | var extend_1 = extend$1;
|
9746 | var isExtended_1 = isExtended;
|
9747 | var collection = {
|
9748 | extend: extend_1,
|
9749 | isExtended: isExtended_1
|
9750 | };
|
9751 |
|
9752 | function hasOwnProperty$1(e, property) {
|
9753 | return Object.prototype.hasOwnProperty.call(e, property.name || property);
|
9754 | }
|
9755 |
|
9756 | function defineCollectionProperty(ref, property, target) {
|
9757 | var collection$1 = collection.extend(target[property.name] || [], ref, property, target);
|
9758 | Object.defineProperty(target, property.name, {
|
9759 | enumerable: property.enumerable,
|
9760 | value: collection$1
|
9761 | });
|
9762 |
|
9763 | if (collection$1.length) {
|
9764 | collection$1.forEach(function (o) {
|
9765 | ref.set(o, property.inverse, target);
|
9766 | });
|
9767 | }
|
9768 | }
|
9769 |
|
9770 | function defineProperty$1(ref, property, target) {
|
9771 | var inverseProperty = property.inverse;
|
9772 | var _value = target[property.name];
|
9773 | Object.defineProperty(target, property.name, {
|
9774 | configurable: property.configurable,
|
9775 | enumerable: property.enumerable,
|
9776 | get: function get() {
|
9777 | return _value;
|
9778 | },
|
9779 | set: function set(value) {
|
9780 |
|
9781 | if (value === _value) {
|
9782 | return;
|
9783 | }
|
9784 |
|
9785 | var old = _value;
|
9786 |
|
9787 | _value = null;
|
9788 |
|
9789 | if (old) {
|
9790 | ref.unset(old, inverseProperty, target);
|
9791 | }
|
9792 |
|
9793 |
|
9794 | _value = value;
|
9795 |
|
9796 | ref.set(_value, inverseProperty, target);
|
9797 | }
|
9798 | });
|
9799 | }
|
9800 | |
9801 |
|
9802 |
|
9803 |
|
9804 |
|
9805 |
|
9806 |
|
9807 |
|
9808 |
|
9809 |
|
9810 |
|
9811 |
|
9812 |
|
9813 |
|
9814 |
|
9815 |
|
9816 |
|
9817 |
|
9818 |
|
9819 |
|
9820 |
|
9821 |
|
9822 |
|
9823 |
|
9824 |
|
9825 |
|
9826 |
|
9827 |
|
9828 |
|
9829 |
|
9830 |
|
9831 |
|
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 |
|
9838 |
|
9839 |
|
9840 |
|
9841 |
|
9842 |
|
9843 |
|
9844 |
|
9845 | function Refs(a, b) {
|
9846 | if (!(this instanceof Refs)) {
|
9847 | return new Refs(a, b);
|
9848 | }
|
9849 |
|
9850 |
|
9851 | a.inverse = b;
|
9852 | b.inverse = a;
|
9853 | this.props = {};
|
9854 | this.props[a.name] = a;
|
9855 | this.props[b.name] = b;
|
9856 | }
|
9857 | |
9858 |
|
9859 |
|
9860 |
|
9861 |
|
9862 |
|
9863 |
|
9864 |
|
9865 |
|
9866 |
|
9867 |
|
9868 | Refs.prototype.bind = function (target, property) {
|
9869 | if (typeof property === 'string') {
|
9870 | if (!this.props[property]) {
|
9871 | throw new Error('no property <' + property + '> in ref');
|
9872 | }
|
9873 |
|
9874 | property = this.props[property];
|
9875 | }
|
9876 |
|
9877 | if (property.collection) {
|
9878 | defineCollectionProperty(this, property, target);
|
9879 | } else {
|
9880 | defineProperty$1(this, property, target);
|
9881 | }
|
9882 | };
|
9883 |
|
9884 | Refs.prototype.ensureRefsCollection = function (target, property) {
|
9885 | var collection$1 = target[property.name];
|
9886 |
|
9887 | if (!collection.isExtended(collection$1)) {
|
9888 | defineCollectionProperty(this, property, target);
|
9889 | }
|
9890 |
|
9891 | return collection$1;
|
9892 | };
|
9893 |
|
9894 | Refs.prototype.ensureBound = function (target, property) {
|
9895 | if (!hasOwnProperty$1(target, property)) {
|
9896 | this.bind(target, property);
|
9897 | }
|
9898 | };
|
9899 |
|
9900 | Refs.prototype.unset = function (target, property, value) {
|
9901 | if (target) {
|
9902 | this.ensureBound(target, property);
|
9903 |
|
9904 | if (property.collection) {
|
9905 | this.ensureRefsCollection(target, property).remove(value);
|
9906 | } else {
|
9907 | target[property.name] = undefined;
|
9908 | }
|
9909 | }
|
9910 | };
|
9911 |
|
9912 | Refs.prototype.set = function (target, property, value) {
|
9913 | if (target) {
|
9914 | this.ensureBound(target, property);
|
9915 |
|
9916 | if (property.collection) {
|
9917 | this.ensureRefsCollection(target, property).add(value);
|
9918 | } else {
|
9919 | target[property.name] = value;
|
9920 | }
|
9921 | }
|
9922 | };
|
9923 |
|
9924 | var refs = Refs;
|
9925 |
|
9926 | var objectRefs = refs;
|
9927 | var Collection = collection;
|
9928 | objectRefs.Collection = Collection;
|
9929 |
|
9930 | var parentRefs = new objectRefs({
|
9931 | name: 'children',
|
9932 | enumerable: true,
|
9933 | collection: true
|
9934 | }, {
|
9935 | name: 'parent'
|
9936 | }),
|
9937 | labelRefs = new objectRefs({
|
9938 | name: 'labels',
|
9939 | enumerable: true,
|
9940 | collection: true
|
9941 | }, {
|
9942 | name: 'labelTarget'
|
9943 | }),
|
9944 | attacherRefs = new objectRefs({
|
9945 | name: 'attachers',
|
9946 | collection: true
|
9947 | }, {
|
9948 | name: 'host'
|
9949 | }),
|
9950 | outgoingRefs = new objectRefs({
|
9951 | name: 'outgoing',
|
9952 | collection: true
|
9953 | }, {
|
9954 | name: 'source'
|
9955 | }),
|
9956 | incomingRefs = new objectRefs({
|
9957 | name: 'incoming',
|
9958 | collection: true
|
9959 | }, {
|
9960 | name: 'target'
|
9961 | });
|
9962 | |
9963 |
|
9964 |
|
9965 |
|
9966 | |
9967 |
|
9968 |
|
9969 |
|
9970 | |
9971 |
|
9972 |
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 |
|
9978 | function Base$1() {
|
9979 | |
9980 |
|
9981 |
|
9982 |
|
9983 |
|
9984 |
|
9985 | Object.defineProperty(this, 'businessObject', {
|
9986 | writable: true
|
9987 | });
|
9988 | |
9989 |
|
9990 |
|
9991 |
|
9992 |
|
9993 |
|
9994 |
|
9995 | Object.defineProperty(this, 'label', {
|
9996 | get: function get() {
|
9997 | return this.labels[0];
|
9998 | },
|
9999 | set: function set(newLabel) {
|
10000 | var label = this.label,
|
10001 | labels = this.labels;
|
10002 |
|
10003 | if (!newLabel && label) {
|
10004 | labels.remove(label);
|
10005 | } else {
|
10006 | labels.add(newLabel, 0);
|
10007 | }
|
10008 | }
|
10009 | });
|
10010 | |
10011 |
|
10012 |
|
10013 |
|
10014 |
|
10015 |
|
10016 |
|
10017 | parentRefs.bind(this, 'parent');
|
10018 | |
10019 |
|
10020 |
|
10021 |
|
10022 |
|
10023 |
|
10024 |
|
10025 | labelRefs.bind(this, 'labels');
|
10026 | |
10027 |
|
10028 |
|
10029 |
|
10030 |
|
10031 |
|
10032 |
|
10033 | outgoingRefs.bind(this, 'outgoing');
|
10034 | |
10035 |
|
10036 |
|
10037 |
|
10038 |
|
10039 |
|
10040 |
|
10041 | incomingRefs.bind(this, 'incoming');
|
10042 | }
|
10043 | |
10044 |
|
10045 |
|
10046 |
|
10047 |
|
10048 |
|
10049 |
|
10050 |
|
10051 |
|
10052 | function Shape() {
|
10053 | Base$1.call(this);
|
10054 | |
10055 |
|
10056 |
|
10057 |
|
10058 |
|
10059 |
|
10060 |
|
10061 | |
10062 |
|
10063 |
|
10064 |
|
10065 |
|
10066 |
|
10067 |
|
10068 | parentRefs.bind(this, 'children');
|
10069 | |
10070 |
|
10071 |
|
10072 |
|
10073 |
|
10074 | attacherRefs.bind(this, 'host');
|
10075 | |
10076 |
|
10077 |
|
10078 |
|
10079 |
|
10080 | attacherRefs.bind(this, 'attachers');
|
10081 | }
|
10082 | inherits_browser(Shape, Base$1);
|
10083 | |
10084 |
|
10085 |
|
10086 |
|
10087 |
|
10088 |
|
10089 |
|
10090 |
|
10091 |
|
10092 | function Root() {
|
10093 | Shape.call(this);
|
10094 | }
|
10095 | inherits_browser(Root, Shape);
|
10096 | |
10097 |
|
10098 |
|
10099 |
|
10100 |
|
10101 |
|
10102 |
|
10103 |
|
10104 |
|
10105 | function Label() {
|
10106 | Shape.call(this);
|
10107 | |
10108 |
|
10109 |
|
10110 |
|
10111 |
|
10112 |
|
10113 |
|
10114 | labelRefs.bind(this, 'labelTarget');
|
10115 | }
|
10116 | inherits_browser(Label, Shape);
|
10117 | |
10118 |
|
10119 |
|
10120 |
|
10121 |
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 | function Connection() {
|
10127 | Base$1.call(this);
|
10128 | |
10129 |
|
10130 |
|
10131 |
|
10132 |
|
10133 |
|
10134 |
|
10135 | outgoingRefs.bind(this, 'source');
|
10136 | |
10137 |
|
10138 |
|
10139 |
|
10140 |
|
10141 |
|
10142 |
|
10143 | incomingRefs.bind(this, 'target');
|
10144 | }
|
10145 | inherits_browser(Connection, Base$1);
|
10146 | var types$6 = {
|
10147 | connection: Connection,
|
10148 | shape: Shape,
|
10149 | label: Label,
|
10150 | root: Root
|
10151 | };
|
10152 | |
10153 |
|
10154 |
|
10155 |
|
10156 |
|
10157 |
|
10158 |
|
10159 |
|
10160 |
|
10161 |
|
10162 |
|
10163 |
|
10164 |
|
10165 |
|
10166 |
|
10167 |
|
10168 |
|
10169 |
|
10170 | function create$1(type, attrs) {
|
10171 | var Type = types$6[type];
|
10172 |
|
10173 | if (!Type) {
|
10174 | throw new Error('unknown type: <' + type + '>');
|
10175 | }
|
10176 |
|
10177 | return assign(new Type(), attrs);
|
10178 | }
|
10179 |
|
10180 | |
10181 |
|
10182 |
|
10183 |
|
10184 | function ElementFactory() {
|
10185 | this._uid = 12;
|
10186 | }
|
10187 |
|
10188 | ElementFactory.prototype.createRoot = function (attrs) {
|
10189 | return this.create('root', attrs);
|
10190 | };
|
10191 |
|
10192 | ElementFactory.prototype.createLabel = function (attrs) {
|
10193 | return this.create('label', attrs);
|
10194 | };
|
10195 |
|
10196 | ElementFactory.prototype.createShape = function (attrs) {
|
10197 | return this.create('shape', attrs);
|
10198 | };
|
10199 |
|
10200 | ElementFactory.prototype.createConnection = function (attrs) {
|
10201 | return this.create('connection', attrs);
|
10202 | };
|
10203 | |
10204 |
|
10205 |
|
10206 |
|
10207 |
|
10208 |
|
10209 |
|
10210 |
|
10211 |
|
10212 |
|
10213 | ElementFactory.prototype.create = function (type, attrs) {
|
10214 | attrs = assign({}, attrs || {});
|
10215 |
|
10216 | if (!attrs.id) {
|
10217 | attrs.id = type + '_' + this._uid++;
|
10218 | }
|
10219 |
|
10220 | return create$1(type, attrs);
|
10221 | };
|
10222 |
|
10223 | |
10224 |
|
10225 |
|
10226 |
|
10227 |
|
10228 |
|
10229 |
|
10230 | |
10231 |
|
10232 |
|
10233 |
|
10234 |
|
10235 |
|
10236 |
|
10237 | function getVisual(gfx) {
|
10238 | return gfx.childNodes[0];
|
10239 | }
|
10240 | |
10241 |
|
10242 |
|
10243 |
|
10244 |
|
10245 |
|
10246 |
|
10247 | function getChildren(gfx) {
|
10248 | return gfx.parentNode.childNodes[1];
|
10249 | }
|
10250 |
|
10251 | |
10252 |
|
10253 |
|
10254 |
|
10255 |
|
10256 |
|
10257 | function translate(gfx, x, y) {
|
10258 | var translate = createTransform();
|
10259 | translate.setTranslate(x, y);
|
10260 | transform(gfx, translate);
|
10261 | }
|
10262 |
|
10263 | |
10264 |
|
10265 |
|
10266 |
|
10267 |
|
10268 |
|
10269 |
|
10270 | function GraphicsFactory(eventBus, elementRegistry) {
|
10271 | this._eventBus = eventBus;
|
10272 | this._elementRegistry = elementRegistry;
|
10273 | }
|
10274 | GraphicsFactory.$inject = ['eventBus', 'elementRegistry'];
|
10275 |
|
10276 | GraphicsFactory.prototype._getChildrenContainer = function (element) {
|
10277 | var gfx = this._elementRegistry.getGraphics(element);
|
10278 |
|
10279 | var childrenGfx;
|
10280 |
|
10281 | if (!element.parent) {
|
10282 | childrenGfx = gfx;
|
10283 | } else {
|
10284 | childrenGfx = getChildren(gfx);
|
10285 |
|
10286 | if (!childrenGfx) {
|
10287 | childrenGfx = create('g');
|
10288 | classes$1(childrenGfx).add('djs-children');
|
10289 | append(gfx.parentNode, childrenGfx);
|
10290 | }
|
10291 | }
|
10292 |
|
10293 | return childrenGfx;
|
10294 | };
|
10295 | |
10296 |
|
10297 |
|
10298 |
|
10299 |
|
10300 |
|
10301 | GraphicsFactory.prototype._clear = function (gfx) {
|
10302 | var visual = getVisual(gfx);
|
10303 | clear(visual);
|
10304 | return visual;
|
10305 | };
|
10306 | |
10307 |
|
10308 |
|
10309 |
|
10310 |
|
10311 |
|
10312 |
|
10313 |
|
10314 |
|
10315 |
|
10316 |
|
10317 |
|
10318 |
|
10319 |
|
10320 |
|
10321 |
|
10322 |
|
10323 |
|
10324 |
|
10325 |
|
10326 |
|
10327 |
|
10328 |
|
10329 |
|
10330 |
|
10331 |
|
10332 |
|
10333 |
|
10334 |
|
10335 | GraphicsFactory.prototype._createContainer = function (type, childrenGfx, parentIndex, isFrame) {
|
10336 | var outerGfx = create('g');
|
10337 | classes$1(outerGfx).add('djs-group');
|
10338 |
|
10339 | if (typeof parentIndex !== 'undefined') {
|
10340 | prependTo(outerGfx, childrenGfx, childrenGfx.childNodes[parentIndex]);
|
10341 | } else {
|
10342 | append(childrenGfx, outerGfx);
|
10343 | }
|
10344 |
|
10345 | var gfx = create('g');
|
10346 | classes$1(gfx).add('djs-element');
|
10347 | classes$1(gfx).add('djs-' + type);
|
10348 |
|
10349 | if (isFrame) {
|
10350 | classes$1(gfx).add('djs-frame');
|
10351 | }
|
10352 |
|
10353 | append(outerGfx, gfx);
|
10354 |
|
10355 | var visual = create('g');
|
10356 | classes$1(visual).add('djs-visual');
|
10357 | append(gfx, visual);
|
10358 | return gfx;
|
10359 | };
|
10360 |
|
10361 | GraphicsFactory.prototype.create = function (type, element, parentIndex) {
|
10362 | var childrenGfx = this._getChildrenContainer(element.parent);
|
10363 |
|
10364 | return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
|
10365 | };
|
10366 |
|
10367 | GraphicsFactory.prototype.updateContainments = function (elements) {
|
10368 | var self = this,
|
10369 | elementRegistry = this._elementRegistry,
|
10370 | parents;
|
10371 | parents = reduce(elements, function (map, e) {
|
10372 | if (e.parent) {
|
10373 | map[e.parent.id] = e.parent;
|
10374 | }
|
10375 |
|
10376 | return map;
|
10377 | }, {});
|
10378 |
|
10379 |
|
10380 | forEach(parents, function (parent) {
|
10381 | var children = parent.children;
|
10382 |
|
10383 | if (!children) {
|
10384 | return;
|
10385 | }
|
10386 |
|
10387 | var childrenGfx = self._getChildrenContainer(parent);
|
10388 |
|
10389 | forEach(children.slice().reverse(), function (child) {
|
10390 | var childGfx = elementRegistry.getGraphics(child);
|
10391 | prependTo(childGfx.parentNode, childrenGfx);
|
10392 | });
|
10393 | });
|
10394 | };
|
10395 |
|
10396 | GraphicsFactory.prototype.drawShape = function (visual, element) {
|
10397 | var eventBus = this._eventBus;
|
10398 | return eventBus.fire('render.shape', {
|
10399 | gfx: visual,
|
10400 | element: element
|
10401 | });
|
10402 | };
|
10403 |
|
10404 | GraphicsFactory.prototype.getShapePath = function (element) {
|
10405 | var eventBus = this._eventBus;
|
10406 | return eventBus.fire('render.getShapePath', element);
|
10407 | };
|
10408 |
|
10409 | GraphicsFactory.prototype.drawConnection = function (visual, element) {
|
10410 | var eventBus = this._eventBus;
|
10411 | return eventBus.fire('render.connection', {
|
10412 | gfx: visual,
|
10413 | element: element
|
10414 | });
|
10415 | };
|
10416 |
|
10417 | GraphicsFactory.prototype.getConnectionPath = function (waypoints) {
|
10418 | var eventBus = this._eventBus;
|
10419 | return eventBus.fire('render.getConnectionPath', waypoints);
|
10420 | };
|
10421 |
|
10422 | GraphicsFactory.prototype.update = function (type, element, gfx) {
|
10423 |
|
10424 | if (!element.parent) {
|
10425 | return;
|
10426 | }
|
10427 |
|
10428 | var visual = this._clear(gfx);
|
10429 |
|
10430 |
|
10431 | if (type === 'shape') {
|
10432 | this.drawShape(visual, element);
|
10433 |
|
10434 | translate(gfx, element.x, element.y);
|
10435 | } else if (type === 'connection') {
|
10436 | this.drawConnection(visual, element);
|
10437 | } else {
|
10438 | throw new Error('unknown type: ' + type);
|
10439 | }
|
10440 |
|
10441 | if (element.hidden) {
|
10442 | attr$1(gfx, 'display', 'none');
|
10443 | } else {
|
10444 | attr$1(gfx, 'display', 'block');
|
10445 | }
|
10446 | };
|
10447 |
|
10448 | GraphicsFactory.prototype.remove = function (element) {
|
10449 | var gfx = this._elementRegistry.getGraphics(element);
|
10450 |
|
10451 |
|
10452 | remove$1(gfx.parentNode);
|
10453 | };
|
10454 |
|
10455 |
|
10456 | function prependTo(newNode, parentNode, siblingNode) {
|
10457 | var node = siblingNode || parentNode.firstChild;
|
10458 |
|
10459 |
|
10460 | if (newNode === node) {
|
10461 | return;
|
10462 | }
|
10463 |
|
10464 | parentNode.insertBefore(newNode, node);
|
10465 | }
|
10466 |
|
10467 | var CoreModule = {
|
10468 | __depends__: [DrawModule],
|
10469 | __init__: ['canvas'],
|
10470 | canvas: ['type', Canvas],
|
10471 | elementRegistry: ['type', ElementRegistry],
|
10472 | elementFactory: ['type', ElementFactory],
|
10473 | eventBus: ['type', EventBus],
|
10474 | graphicsFactory: ['type', GraphicsFactory]
|
10475 | };
|
10476 |
|
10477 | |
10478 |
|
10479 |
|
10480 |
|
10481 |
|
10482 |
|
10483 |
|
10484 |
|
10485 |
|
10486 | function bootstrap(bootstrapModules) {
|
10487 | var modules = [],
|
10488 | components = [];
|
10489 |
|
10490 | function hasModule(m) {
|
10491 | return modules.indexOf(m) >= 0;
|
10492 | }
|
10493 |
|
10494 | function addModule(m) {
|
10495 | modules.push(m);
|
10496 | }
|
10497 |
|
10498 | function visit(m) {
|
10499 | if (hasModule(m)) {
|
10500 | return;
|
10501 | }
|
10502 |
|
10503 | (m.__depends__ || []).forEach(visit);
|
10504 |
|
10505 | if (hasModule(m)) {
|
10506 | return;
|
10507 | }
|
10508 |
|
10509 | addModule(m);
|
10510 | (m.__init__ || []).forEach(function (c) {
|
10511 | components.push(c);
|
10512 | });
|
10513 | }
|
10514 |
|
10515 | bootstrapModules.forEach(visit);
|
10516 | var injector = new Injector(modules);
|
10517 | components.forEach(function (c) {
|
10518 | try {
|
10519 |
|
10520 | injector[typeof c === 'string' ? 'get' : 'invoke'](c);
|
10521 | } catch (e) {
|
10522 | console.error('Failed to instantiate component');
|
10523 | console.error(e.stack);
|
10524 | throw e;
|
10525 | }
|
10526 | });
|
10527 | return injector;
|
10528 | }
|
10529 | |
10530 |
|
10531 |
|
10532 |
|
10533 |
|
10534 |
|
10535 |
|
10536 |
|
10537 |
|
10538 | function createInjector(options) {
|
10539 | options = options || {};
|
10540 | var configModule = {
|
10541 | 'config': ['value', options]
|
10542 | };
|
10543 | var modules = [configModule, CoreModule].concat(options.modules || []);
|
10544 | return bootstrap(modules);
|
10545 | }
|
10546 | |
10547 |
|
10548 |
|
10549 |
|
10550 |
|
10551 |
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 |
|
10558 |
|
10559 |
|
10560 |
|
10561 |
|
10562 |
|
10563 |
|
10564 |
|
10565 |
|
10566 |
|
10567 |
|
10568 |
|
10569 |
|
10570 |
|
10571 |
|
10572 |
|
10573 |
|
10574 |
|
10575 |
|
10576 |
|
10577 |
|
10578 |
|
10579 |
|
10580 |
|
10581 |
|
10582 |
|
10583 |
|
10584 |
|
10585 |
|
10586 |
|
10587 |
|
10588 |
|
10589 |
|
10590 |
|
10591 |
|
10592 |
|
10593 |
|
10594 |
|
10595 |
|
10596 |
|
10597 | function Diagram(options, injector) {
|
10598 |
|
10599 | this.injector = injector = injector || createInjector(options);
|
10600 |
|
10601 | |
10602 |
|
10603 |
|
10604 |
|
10605 |
|
10606 |
|
10607 |
|
10608 |
|
10609 |
|
10610 | this.get = injector.get;
|
10611 | |
10612 |
|
10613 |
|
10614 |
|
10615 |
|
10616 |
|
10617 |
|
10618 |
|
10619 |
|
10620 | this.invoke = injector.invoke;
|
10621 |
|
10622 |
|
10623 | |
10624 |
|
10625 |
|
10626 |
|
10627 |
|
10628 |
|
10629 |
|
10630 |
|
10631 |
|
10632 |
|
10633 |
|
10634 |
|
10635 |
|
10636 |
|
10637 |
|
10638 |
|
10639 |
|
10640 |
|
10641 | this.get('eventBus').fire('diagram.init');
|
10642 | }
|
10643 | |
10644 |
|
10645 |
|
10646 |
|
10647 |
|
10648 |
|
10649 | Diagram.prototype.destroy = function () {
|
10650 | this.get('eventBus').fire('diagram.destroy');
|
10651 | };
|
10652 | |
10653 |
|
10654 |
|
10655 |
|
10656 |
|
10657 | Diagram.prototype.clear = function () {
|
10658 | this.get('eventBus').fire('diagram.clear');
|
10659 | };
|
10660 |
|
10661 | |
10662 |
|
10663 |
|
10664 |
|
10665 |
|
10666 |
|
10667 |
|
10668 |
|
10669 |
|
10670 | function is(element, type) {
|
10671 | var bo = getBusinessObject(element);
|
10672 | return bo && typeof bo.$instanceOf === 'function' && bo.$instanceOf(type);
|
10673 | }
|
10674 | |
10675 |
|
10676 |
|
10677 |
|
10678 |
|
10679 |
|
10680 |
|
10681 |
|
10682 | function getBusinessObject(element) {
|
10683 | return element && element.businessObject || element;
|
10684 | }
|
10685 | function getName(element) {
|
10686 | return getBusinessObject(element).name;
|
10687 | }
|
10688 |
|
10689 | var diRefs = new objectRefs({
|
10690 | name: 'dmnElementRef',
|
10691 | enumerable: true
|
10692 | }, {
|
10693 | name: 'di',
|
10694 | configurable: true
|
10695 | });
|
10696 | function DRDTreeWalker(handler, options) {
|
10697 |
|
10698 |
|
10699 | var deferred = [];
|
10700 |
|
10701 | function visit(element) {
|
10702 | var gfx = element.gfx;
|
10703 |
|
10704 | if (gfx) {
|
10705 | throw new Error('already rendered ' + element.id);
|
10706 | }
|
10707 |
|
10708 |
|
10709 | return handler.element(element);
|
10710 | }
|
10711 |
|
10712 | function visitRoot(element) {
|
10713 | return handler.root(element);
|
10714 | }
|
10715 |
|
10716 | function visitIfDi(element) {
|
10717 | try {
|
10718 | var gfx = element.di && visit(element);
|
10719 | return gfx;
|
10720 | } catch (e) {
|
10721 | logError(e.message, {
|
10722 | element: element,
|
10723 | error: e
|
10724 | });
|
10725 | }
|
10726 | }
|
10727 |
|
10728 | |
10729 |
|
10730 |
|
10731 |
|
10732 |
|
10733 |
|
10734 |
|
10735 |
|
10736 |
|
10737 |
|
10738 | function handleDefinitions(definitions, diagram) {
|
10739 |
|
10740 | var dmnDI = definitions.dmnDI;
|
10741 |
|
10742 | if (!dmnDI) {
|
10743 | throw new Error('no dmndi:DMNDI');
|
10744 | }
|
10745 |
|
10746 | var diagrams = dmnDI.diagrams || [];
|
10747 |
|
10748 | if (diagram && diagrams.indexOf(diagram) === -1) {
|
10749 | throw new Error('diagram not part of dmndi:DMNDI');
|
10750 | }
|
10751 |
|
10752 | if (!diagram && diagrams && diagrams.length) {
|
10753 | diagram = diagrams[0];
|
10754 | }
|
10755 |
|
10756 |
|
10757 | if (!diagram) {
|
10758 | throw new Error('no diagram to display');
|
10759 | }
|
10760 |
|
10761 |
|
10762 | definitions.di = diagram;
|
10763 |
|
10764 | handleDiagram(diagram);
|
10765 | visitRoot(definitions);
|
10766 | handleDrgElements(definitions.get('drgElement'));
|
10767 | handleArtifacts(definitions.get('artifact'));
|
10768 | handleDeferred();
|
10769 | }
|
10770 |
|
10771 | function handleDrgElements(elements) {
|
10772 | forEach(elements, function (element) {
|
10773 | visitIfDi(element);
|
10774 | handleRequirements(element);
|
10775 | });
|
10776 | }
|
10777 |
|
10778 | function handleArtifacts(elements) {
|
10779 | forEach(elements, function (element) {
|
10780 | if (is(element, 'dmn:Association')) {
|
10781 | handleAssociation(element);
|
10782 | } else {
|
10783 | visitIfDi(element);
|
10784 | }
|
10785 | });
|
10786 | }
|
10787 | |
10788 |
|
10789 |
|
10790 |
|
10791 |
|
10792 |
|
10793 |
|
10794 | function handleAssociation(element) {
|
10795 | defer(function () {
|
10796 | visitIfDi(element);
|
10797 | });
|
10798 | }
|
10799 | |
10800 |
|
10801 |
|
10802 |
|
10803 |
|
10804 |
|
10805 |
|
10806 | function handleRequirements(element) {
|
10807 | forEach(['informationRequirement', 'knowledgeRequirement', 'authorityRequirement'], function (requirements) {
|
10808 | forEach(element[requirements], function (requirement) {
|
10809 | defer(function () {
|
10810 | visitIfDi(requirement);
|
10811 | });
|
10812 | });
|
10813 | });
|
10814 | }
|
10815 |
|
10816 |
|
10817 | function handleDiagram(diagram) {
|
10818 | forEach(diagram.diagramElements, handleDiagramElement);
|
10819 | }
|
10820 |
|
10821 | function handleDiagramElement(diagramElement) {
|
10822 | registerDi(diagramElement);
|
10823 | }
|
10824 |
|
10825 | function registerDi(di) {
|
10826 | var dmnElement = di.dmnElementRef;
|
10827 |
|
10828 | if (dmnElement) {
|
10829 | if (dmnElement.di) {
|
10830 | logError('multiple DI elements defined for element', {
|
10831 | element: dmnElement
|
10832 | });
|
10833 | } else {
|
10834 | diRefs.bind(dmnElement, 'di');
|
10835 | dmnElement.di = di;
|
10836 | }
|
10837 | } else {
|
10838 | logError('no DMN element referenced in element', {
|
10839 | element: di
|
10840 | });
|
10841 | }
|
10842 | }
|
10843 |
|
10844 | function defer(fn) {
|
10845 | deferred.push(fn);
|
10846 | }
|
10847 |
|
10848 | function handleDeferred() {
|
10849 | forEach(deferred, function (d) {
|
10850 | d();
|
10851 | });
|
10852 | }
|
10853 |
|
10854 | function logError(message, context) {
|
10855 | handler.error(message, context);
|
10856 | }
|
10857 |
|
10858 |
|
10859 | return {
|
10860 | handleDefinitions: handleDefinitions
|
10861 | };
|
10862 | }
|
10863 |
|
10864 | |
10865 |
|
10866 |
|
10867 |
|
10868 |
|
10869 |
|
10870 |
|
10871 |
|
10872 |
|
10873 |
|
10874 |
|
10875 | function importDRD(drd, definitions, done) {
|
10876 | var importer = drd.get('drdImporter'),
|
10877 | eventBus = drd.get('eventBus');
|
10878 | var error,
|
10879 | warnings = [];
|
10880 |
|
10881 | function render(definitions) {
|
10882 | var visitor = {
|
10883 | root: function root(element) {
|
10884 | return importer.root(element);
|
10885 | },
|
10886 | element: function element(_element, di) {
|
10887 | return importer.add(_element, di);
|
10888 | },
|
10889 | error: function error(message, context) {
|
10890 | warnings.push({
|
10891 | message: message,
|
10892 | context: context
|
10893 | });
|
10894 | }
|
10895 | };
|
10896 | var walker = new DRDTreeWalker(visitor);
|
10897 |
|
10898 | walker.handleDefinitions(definitions);
|
10899 | }
|
10900 |
|
10901 | eventBus.fire('import.start', {
|
10902 | definitions: definitions
|
10903 | });
|
10904 |
|
10905 | try {
|
10906 | render(definitions);
|
10907 | } catch (e) {
|
10908 | error = e;
|
10909 | }
|
10910 |
|
10911 | eventBus.fire('import.done', {
|
10912 | error: error,
|
10913 | warnings: warnings
|
10914 | });
|
10915 | done(error, warnings);
|
10916 | }
|
10917 |
|
10918 | function DrdRenderer(eventBus, pathMap, styles, textRenderer) {
|
10919 | BaseRenderer.call(this, eventBus);
|
10920 | var markers = {};
|
10921 |
|
10922 | function addMarker(id, element) {
|
10923 | markers[id] = element;
|
10924 | }
|
10925 |
|
10926 | function marker(id) {
|
10927 | var marker = markers[id];
|
10928 | return 'url(#' + marker.id + ')';
|
10929 | }
|
10930 |
|
10931 | function initMarkers(svg) {
|
10932 | function createMarker(id, options) {
|
10933 | var attrs = assign({
|
10934 | strokeWidth: 1,
|
10935 | strokeLinecap: 'round',
|
10936 | strokeDasharray: 'none'
|
10937 | }, options.attrs);
|
10938 | var ref = options.ref || {
|
10939 | x: 0,
|
10940 | y: 0
|
10941 | };
|
10942 | var scale = options.scale || 1;
|
10943 |
|
10944 |
|
10945 | if (attrs.strokeDasharray === 'none') {
|
10946 | attrs.strokeDasharray = [10000, 1];
|
10947 | }
|
10948 |
|
10949 | var marker = create('marker');
|
10950 | attr$1(options.element, attrs);
|
10951 | append(marker, options.element);
|
10952 | attr$1(marker, {
|
10953 | id: id,
|
10954 | viewBox: '0 0 20 20',
|
10955 | refX: ref.x,
|
10956 | refY: ref.y,
|
10957 | markerWidth: 20 * scale,
|
10958 | markerHeight: 20 * scale,
|
10959 | orient: 'auto'
|
10960 | });
|
10961 | var defs = query('defs', svg);
|
10962 |
|
10963 | if (!defs) {
|
10964 | defs = create('defs');
|
10965 | append(svg, defs);
|
10966 | }
|
10967 |
|
10968 | append(defs, marker);
|
10969 | return addMarker(id, marker);
|
10970 | }
|
10971 |
|
10972 | var associationStart = create('path');
|
10973 | attr$1(associationStart, {
|
10974 | d: 'M 11 5 L 1 10 L 11 15'
|
10975 | });
|
10976 | createMarker('association-start', {
|
10977 | element: associationStart,
|
10978 | attrs: {
|
10979 | fill: 'none',
|
10980 | stroke: 'black',
|
10981 | strokeWidth: 1.5
|
10982 | },
|
10983 | ref: {
|
10984 | x: 1,
|
10985 | y: 10
|
10986 | },
|
10987 | scale: 0.5
|
10988 | });
|
10989 | var associationEnd = create('path');
|
10990 | attr$1(associationEnd, {
|
10991 | d: 'M 1 5 L 11 10 L 1 15'
|
10992 | });
|
10993 | createMarker('association-end', {
|
10994 | element: associationEnd,
|
10995 | attrs: {
|
10996 | fill: 'none',
|
10997 | stroke: 'black',
|
10998 | strokeWidth: 1.5
|
10999 | },
|
11000 | ref: {
|
11001 | x: 12,
|
11002 | y: 10
|
11003 | },
|
11004 | scale: 0.5
|
11005 | });
|
11006 | var informationRequirementEnd = create('path');
|
11007 | attr$1(informationRequirementEnd, {
|
11008 | d: 'M 1 5 L 11 10 L 1 15 Z'
|
11009 | });
|
11010 | createMarker('information-requirement-end', {
|
11011 | element: informationRequirementEnd,
|
11012 | ref: {
|
11013 | x: 11,
|
11014 | y: 10
|
11015 | },
|
11016 | scale: 1
|
11017 | });
|
11018 | var knowledgeRequirementEnd = create('path');
|
11019 | attr$1(knowledgeRequirementEnd, {
|
11020 | d: 'M 1 3 L 11 10 L 1 17'
|
11021 | });
|
11022 | createMarker('knowledge-requirement-end', {
|
11023 | element: knowledgeRequirementEnd,
|
11024 | attrs: {
|
11025 | fill: 'none',
|
11026 | stroke: 'black',
|
11027 | strokeWidth: 2
|
11028 | },
|
11029 | ref: {
|
11030 | x: 11,
|
11031 | y: 10
|
11032 | },
|
11033 | scale: 0.8
|
11034 | });
|
11035 | var authorityRequirementEnd = create('circle');
|
11036 | attr$1(authorityRequirementEnd, {
|
11037 | cx: 3,
|
11038 | cy: 3,
|
11039 | r: 3
|
11040 | });
|
11041 | createMarker('authority-requirement-end', {
|
11042 | element: authorityRequirementEnd,
|
11043 | ref: {
|
11044 | x: 3,
|
11045 | y: 3
|
11046 | },
|
11047 | scale: 0.9
|
11048 | });
|
11049 | }
|
11050 |
|
11051 | function computeStyle(custom, traits, defaultStyles) {
|
11052 | if (!isArray(traits)) {
|
11053 | defaultStyles = traits;
|
11054 | traits = [];
|
11055 | }
|
11056 |
|
11057 | return styles.style(traits || [], assign(defaultStyles, custom || {}));
|
11058 | }
|
11059 |
|
11060 | function drawRect(p, width, height, r, offset, attrs) {
|
11061 | if (isObject(offset)) {
|
11062 | attrs = offset;
|
11063 | offset = 0;
|
11064 | }
|
11065 |
|
11066 | offset = offset || 0;
|
11067 | attrs = computeStyle(attrs, {
|
11068 | stroke: 'black',
|
11069 | strokeWidth: 2,
|
11070 | fill: 'white'
|
11071 | });
|
11072 | var rect = create('rect');
|
11073 | attr$1(rect, {
|
11074 | x: offset,
|
11075 | y: offset,
|
11076 | width: width - offset * 2,
|
11077 | height: height - offset * 2,
|
11078 | rx: r,
|
11079 | ry: r
|
11080 | });
|
11081 | attr$1(rect, attrs);
|
11082 | append(p, rect);
|
11083 | return rect;
|
11084 | }
|
11085 |
|
11086 | function renderLabel(p, label, options) {
|
11087 | var text = textRenderer.createText(label || '', options);
|
11088 | attr(text, 'class', 'djs-label');
|
11089 | append(p, text);
|
11090 | return text;
|
11091 | }
|
11092 |
|
11093 | function renderEmbeddedLabel(p, element, align) {
|
11094 | var name = getName(element);
|
11095 | return renderLabel(p, name, {
|
11096 | box: element,
|
11097 | align: align,
|
11098 | padding: 5
|
11099 | });
|
11100 | }
|
11101 |
|
11102 | function drawPath(p, d, attrs) {
|
11103 | attrs = computeStyle(attrs, ['no-fill'], {
|
11104 | strokeWidth: 2,
|
11105 | stroke: 'black'
|
11106 | });
|
11107 | var path = create('path');
|
11108 | attr$1(path, {
|
11109 | d: d
|
11110 | });
|
11111 | attr$1(path, attrs);
|
11112 | append(p, path);
|
11113 | return path;
|
11114 | }
|
11115 |
|
11116 | var handlers = {
|
11117 | 'dmn:Decision': function dmnDecision(p, element, attrs) {
|
11118 | var rect = drawRect(p, element.width, element.height, 0, attrs);
|
11119 | renderEmbeddedLabel(p, element, 'center-middle');
|
11120 | return rect;
|
11121 | },
|
11122 | 'dmn:KnowledgeSource': function dmnKnowledgeSource(p, element, attrs) {
|
11123 | var pathData = pathMap.getScaledPath('KNOWLEDGE_SOURCE', {
|
11124 | xScaleFactor: 1.021,
|
11125 | yScaleFactor: 1,
|
11126 | containerWidth: element.width,
|
11127 | containerHeight: element.height,
|
11128 | position: {
|
11129 | mx: 0.0,
|
11130 | my: 0.075
|
11131 | }
|
11132 | });
|
11133 | var knowledgeSource = drawPath(p, pathData, {
|
11134 | strokeWidth: 2,
|
11135 | fill: 'white',
|
11136 | stroke: 'black'
|
11137 | });
|
11138 | renderEmbeddedLabel(p, element, 'center-middle');
|
11139 | return knowledgeSource;
|
11140 | },
|
11141 | 'dmn:BusinessKnowledgeModel': function dmnBusinessKnowledgeModel(p, element, attrs) {
|
11142 | var pathData = pathMap.getScaledPath('BUSINESS_KNOWLEDGE_MODEL', {
|
11143 | xScaleFactor: 1,
|
11144 | yScaleFactor: 1,
|
11145 | containerWidth: element.width,
|
11146 | containerHeight: element.height,
|
11147 | position: {
|
11148 | mx: 0.0,
|
11149 | my: 0.3
|
11150 | }
|
11151 | });
|
11152 | var businessKnowledge = drawPath(p, pathData, {
|
11153 | strokeWidth: 2,
|
11154 | fill: 'white',
|
11155 | stroke: 'black'
|
11156 | });
|
11157 | renderEmbeddedLabel(p, element, 'center-middle');
|
11158 | return businessKnowledge;
|
11159 | },
|
11160 | 'dmn:InputData': function dmnInputData(p, element, attrs) {
|
11161 | var rect = drawRect(p, element.width, element.height, 22, attrs);
|
11162 | renderEmbeddedLabel(p, element, 'center-middle');
|
11163 | return rect;
|
11164 | },
|
11165 | 'dmn:TextAnnotation': function dmnTextAnnotation(p, element, attrs) {
|
11166 | var style = {
|
11167 | 'fill': 'none',
|
11168 | 'stroke': 'none'
|
11169 | };
|
11170 | var textElement = drawRect(p, element.width, element.height, 0, 0, style);
|
11171 | var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
|
11172 | xScaleFactor: 1,
|
11173 | yScaleFactor: 1,
|
11174 | containerWidth: element.width,
|
11175 | containerHeight: element.height,
|
11176 | position: {
|
11177 | mx: 0.0,
|
11178 | my: 0.0
|
11179 | }
|
11180 | });
|
11181 | drawPath(p, textPathData);
|
11182 | var text = getSemantic(element).text || '';
|
11183 | renderLabel(p, text, {
|
11184 | box: element,
|
11185 | align: 'left-top',
|
11186 | padding: 5
|
11187 | });
|
11188 | return textElement;
|
11189 | },
|
11190 | 'dmn:Association': function dmnAssociation(p, element, attrs) {
|
11191 | var semantic = getSemantic(element);
|
11192 | attrs = assign({
|
11193 | strokeDasharray: '0.5, 5',
|
11194 | strokeLinecap: 'round',
|
11195 | strokeLinejoin: 'round',
|
11196 | fill: 'none'
|
11197 | }, attrs || {});
|
11198 |
|
11199 | if (semantic.associationDirection === 'One' || semantic.associationDirection === 'Both') {
|
11200 | attrs.markerEnd = marker('association-end');
|
11201 | }
|
11202 |
|
11203 | if (semantic.associationDirection === 'Both') {
|
11204 | attrs.markerStart = marker('association-start');
|
11205 | }
|
11206 |
|
11207 | return drawLine(p, element.waypoints, attrs);
|
11208 | },
|
11209 | 'dmn:InformationRequirement': function dmnInformationRequirement(p, element, attrs) {
|
11210 | attrs = assign({
|
11211 | strokeWidth: 1,
|
11212 | strokeLinecap: 'round',
|
11213 | strokeLinejoin: 'round',
|
11214 | markerEnd: marker('information-requirement-end')
|
11215 | }, attrs || {});
|
11216 | return drawLine(p, element.waypoints, attrs);
|
11217 | },
|
11218 | 'dmn:KnowledgeRequirement': function dmnKnowledgeRequirement(p, element, attrs) {
|
11219 | attrs = assign({
|
11220 | strokeWidth: 1,
|
11221 | strokeDasharray: 5,
|
11222 | strokeLinecap: 'round',
|
11223 | strokeLinejoin: 'round',
|
11224 | markerEnd: marker('knowledge-requirement-end')
|
11225 | }, attrs || {});
|
11226 | return drawLine(p, element.waypoints, attrs);
|
11227 | },
|
11228 | 'dmn:AuthorityRequirement': function dmnAuthorityRequirement(p, element, attrs) {
|
11229 | attrs = assign({
|
11230 | strokeWidth: 1.5,
|
11231 | strokeDasharray: 5,
|
11232 | strokeLinecap: 'round',
|
11233 | strokeLinejoin: 'round',
|
11234 | markerEnd: marker('authority-requirement-end')
|
11235 | }, attrs || {});
|
11236 | return drawLine(p, element.waypoints, attrs);
|
11237 | }
|
11238 | };
|
11239 |
|
11240 | function drawShape(parent, element) {
|
11241 | var h = handlers[element.type];
|
11242 |
|
11243 | if (!h) {
|
11244 | return BaseRenderer.prototype.drawShape.apply(this, [parent, element]);
|
11245 | } else {
|
11246 | return h(parent, element);
|
11247 | }
|
11248 | }
|
11249 |
|
11250 | function drawConnection(parent, element) {
|
11251 | var type = element.type;
|
11252 | var h = handlers[type];
|
11253 |
|
11254 | if (!h) {
|
11255 | return BaseRenderer.prototype.drawConnection.apply(this, [parent, element]);
|
11256 | } else {
|
11257 | return h(parent, element);
|
11258 | }
|
11259 | }
|
11260 |
|
11261 | function drawLine(p, waypoints, attrs) {
|
11262 | attrs = computeStyle(attrs, ['no-fill'], {
|
11263 | stroke: 'black',
|
11264 | strokeWidth: 2,
|
11265 | fill: 'none'
|
11266 | });
|
11267 | var line = createLine(waypoints, attrs);
|
11268 | append(p, line);
|
11269 | return line;
|
11270 | }
|
11271 |
|
11272 | this.canRender = function (element) {
|
11273 | return is(element, 'dmn:DMNElement') || is(element, 'dmn:InformationRequirement') || is(element, 'dmn:KnowledgeRequirement') || is(element, 'dmn:AuthorityRequirement');
|
11274 | };
|
11275 |
|
11276 | this.drawShape = drawShape;
|
11277 | this.drawConnection = drawConnection;
|
11278 |
|
11279 |
|
11280 | eventBus.on('canvas.init', function (event) {
|
11281 | initMarkers(event.svg);
|
11282 | });
|
11283 | }
|
11284 | inherits_browser(DrdRenderer, BaseRenderer);
|
11285 | DrdRenderer.$inject = ['eventBus', 'pathMap', 'styles', 'textRenderer'];
|
11286 |
|
11287 | function getSemantic(element) {
|
11288 | return element.businessObject;
|
11289 | }
|
11290 |
|
11291 | var DEFAULT_BOX_PADDING = 0;
|
11292 | var DEFAULT_LABEL_SIZE = {
|
11293 | width: 150,
|
11294 | height: 50
|
11295 | };
|
11296 |
|
11297 | function parseAlign(align) {
|
11298 | var parts = align.split('-');
|
11299 | return {
|
11300 | horizontal: parts[0] || 'center',
|
11301 | vertical: parts[1] || 'top'
|
11302 | };
|
11303 | }
|
11304 |
|
11305 | function parsePadding(padding) {
|
11306 | if (isObject(padding)) {
|
11307 | return assign({
|
11308 | top: 0,
|
11309 | left: 0,
|
11310 | right: 0,
|
11311 | bottom: 0
|
11312 | }, padding);
|
11313 | } else {
|
11314 | return {
|
11315 | top: padding,
|
11316 | left: padding,
|
11317 | right: padding,
|
11318 | bottom: padding
|
11319 | };
|
11320 | }
|
11321 | }
|
11322 |
|
11323 | function getTextBBox(text, fakeText) {
|
11324 | fakeText.textContent = text;
|
11325 | var textBBox;
|
11326 |
|
11327 | try {
|
11328 | var bbox,
|
11329 | emptyLine = text === '';
|
11330 |
|
11331 |
|
11332 | fakeText.textContent = emptyLine ? 'dummy' : text;
|
11333 | textBBox = fakeText.getBBox();
|
11334 |
|
11335 |
|
11336 | bbox = {
|
11337 | width: textBBox.width + textBBox.x * 2,
|
11338 | height: textBBox.height
|
11339 | };
|
11340 |
|
11341 | if (emptyLine) {
|
11342 |
|
11343 | bbox.width = 0;
|
11344 | }
|
11345 |
|
11346 | return bbox;
|
11347 | } catch (e) {
|
11348 | return {
|
11349 | width: 0,
|
11350 | height: 0
|
11351 | };
|
11352 | }
|
11353 | }
|
11354 | |
11355 |
|
11356 |
|
11357 |
|
11358 |
|
11359 |
|
11360 |
|
11361 |
|
11362 |
|
11363 |
|
11364 | function layoutNext(lines, maxWidth, fakeText) {
|
11365 | var originalLine = lines.shift(),
|
11366 | fitLine = originalLine;
|
11367 | var textBBox;
|
11368 |
|
11369 | for (;;) {
|
11370 | textBBox = getTextBBox(fitLine, fakeText);
|
11371 | textBBox.width = fitLine ? textBBox.width : 0;
|
11372 |
|
11373 | if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 2) {
|
11374 | return fit(lines, fitLine, originalLine, textBBox);
|
11375 | }
|
11376 |
|
11377 | fitLine = shortenLine(fitLine, textBBox.width, maxWidth);
|
11378 | }
|
11379 | }
|
11380 |
|
11381 | function fit(lines, fitLine, originalLine, textBBox) {
|
11382 | if (fitLine.length < originalLine.length) {
|
11383 | var remainder = originalLine.slice(fitLine.length).trim();
|
11384 | lines.unshift(remainder);
|
11385 | }
|
11386 |
|
11387 | return {
|
11388 | width: textBBox.width,
|
11389 | height: textBBox.height,
|
11390 | text: fitLine
|
11391 | };
|
11392 | }
|
11393 | |
11394 |
|
11395 |
|
11396 |
|
11397 |
|
11398 |
|
11399 |
|
11400 |
|
11401 |
|
11402 |
|
11403 | function semanticShorten(line, maxLength) {
|
11404 | var parts = line.split(/(\s|-)/g),
|
11405 | part,
|
11406 | shortenedParts = [],
|
11407 | length = 0;
|
11408 |
|
11409 | if (parts.length > 1) {
|
11410 | while (part = parts.shift()) {
|
11411 | if (part.length + length < maxLength) {
|
11412 | shortenedParts.push(part);
|
11413 | length += part.length;
|
11414 | } else {
|
11415 |
|
11416 | if (part === '-') {
|
11417 | shortenedParts.pop();
|
11418 | }
|
11419 |
|
11420 | break;
|
11421 | }
|
11422 | }
|
11423 | }
|
11424 |
|
11425 | return shortenedParts.join('');
|
11426 | }
|
11427 |
|
11428 | function shortenLine(line, width, maxWidth) {
|
11429 | var length = Math.max(line.length * (maxWidth / width), 1);
|
11430 |
|
11431 | var shortenedLine = semanticShorten(line, length);
|
11432 |
|
11433 | if (!shortenedLine) {
|
11434 |
|
11435 | shortenedLine = line.slice(0, Math.max(Math.round(length - 1), 1));
|
11436 | }
|
11437 |
|
11438 | return shortenedLine;
|
11439 | }
|
11440 |
|
11441 | function getHelperSvg() {
|
11442 | var helperSvg = document.getElementById('helper-svg');
|
11443 |
|
11444 | if (!helperSvg) {
|
11445 | helperSvg = create('svg');
|
11446 | attr$1(helperSvg, {
|
11447 | id: 'helper-svg',
|
11448 | width: 0,
|
11449 | height: 0,
|
11450 | style: 'visibility: hidden; position: fixed'
|
11451 | });
|
11452 | document.body.appendChild(helperSvg);
|
11453 | }
|
11454 |
|
11455 | return helperSvg;
|
11456 | }
|
11457 | |
11458 |
|
11459 |
|
11460 |
|
11461 |
|
11462 |
|
11463 |
|
11464 |
|
11465 |
|
11466 |
|
11467 |
|
11468 | function Text(config) {
|
11469 | this._config = assign({}, {
|
11470 | size: DEFAULT_LABEL_SIZE,
|
11471 | padding: DEFAULT_BOX_PADDING,
|
11472 | style: {},
|
11473 | align: 'center-top'
|
11474 | }, config || {});
|
11475 | }
|
11476 | |
11477 |
|
11478 |
|
11479 |
|
11480 |
|
11481 |
|
11482 |
|
11483 |
|
11484 |
|
11485 | Text.prototype.createText = function (text, options) {
|
11486 | return this.layoutText(text, options).element;
|
11487 | };
|
11488 | |
11489 |
|
11490 |
|
11491 |
|
11492 |
|
11493 |
|
11494 |
|
11495 |
|
11496 |
|
11497 |
|
11498 | Text.prototype.getDimensions = function (text, options) {
|
11499 | return this.layoutText(text, options).dimensions;
|
11500 | };
|
11501 | |
11502 |
|
11503 |
|
11504 |
|
11505 |
|
11506 |
|
11507 |
|
11508 |
|
11509 |
|
11510 |
|
11511 |
|
11512 |
|
11513 |
|
11514 |
|
11515 |
|
11516 |
|
11517 |
|
11518 |
|
11519 | Text.prototype.layoutText = function (text, options) {
|
11520 | var box = assign({}, this._config.size, options.box),
|
11521 | style = assign({}, this._config.style, options.style),
|
11522 | align = parseAlign(options.align || this._config.align),
|
11523 | padding = parsePadding(options.padding !== undefined ? options.padding : this._config.padding),
|
11524 | fitBox = options.fitBox || false;
|
11525 | var lineHeight = getLineHeight(style);
|
11526 | var lines = text.split(/\r?\n/g),
|
11527 | layouted = [];
|
11528 | var maxWidth = box.width - padding.left - padding.right;
|
11529 |
|
11530 | var helperText = create('text');
|
11531 | attr$1(helperText, {
|
11532 | x: 0,
|
11533 | y: 0
|
11534 | });
|
11535 | attr$1(helperText, style);
|
11536 | var helperSvg = getHelperSvg();
|
11537 | append(helperSvg, helperText);
|
11538 |
|
11539 | while (lines.length) {
|
11540 | layouted.push(layoutNext(lines, maxWidth, helperText));
|
11541 | }
|
11542 |
|
11543 | if (align.vertical === 'middle') {
|
11544 | padding.top = padding.bottom = 0;
|
11545 | }
|
11546 |
|
11547 | var totalHeight = reduce(layouted, function (sum, line, idx) {
|
11548 | return sum + (lineHeight || line.height);
|
11549 | }, 0) + padding.top + padding.bottom;
|
11550 | var maxLineWidth = reduce(layouted, function (sum, line, idx) {
|
11551 | return line.width > sum ? line.width : sum;
|
11552 | }, 0);
|
11553 |
|
11554 | var y = padding.top;
|
11555 |
|
11556 | if (align.vertical === 'middle') {
|
11557 | y += (box.height - totalHeight) / 2;
|
11558 | }
|
11559 |
|
11560 |
|
11561 | y -= (lineHeight || layouted[0].height) / 4;
|
11562 | var textElement = create('text');
|
11563 | attr$1(textElement, style);
|
11564 |
|
11565 |
|
11566 | forEach(layouted, function (line) {
|
11567 | var x;
|
11568 | y += lineHeight || line.height;
|
11569 |
|
11570 | switch (align.horizontal) {
|
11571 | case 'left':
|
11572 | x = padding.left;
|
11573 | break;
|
11574 |
|
11575 | case 'right':
|
11576 | x = (fitBox ? maxLineWidth : maxWidth) - padding.right - line.width;
|
11577 | break;
|
11578 |
|
11579 | default:
|
11580 |
|
11581 | x = Math.max(((fitBox ? maxLineWidth : maxWidth) - line.width) / 2 + padding.left, 0);
|
11582 | }
|
11583 |
|
11584 | var tspan = create('tspan');
|
11585 | attr$1(tspan, {
|
11586 | x: x,
|
11587 | y: y
|
11588 | });
|
11589 | tspan.textContent = line.text;
|
11590 | append(textElement, tspan);
|
11591 | });
|
11592 | remove$1(helperText);
|
11593 | var dimensions = {
|
11594 | width: maxLineWidth,
|
11595 | height: totalHeight
|
11596 | };
|
11597 | return {
|
11598 | dimensions: dimensions,
|
11599 | element: textElement
|
11600 | };
|
11601 | };
|
11602 |
|
11603 | function getLineHeight(style) {
|
11604 | if ('fontSize' in style && 'lineHeight' in style) {
|
11605 | return style.lineHeight * parseInt(style.fontSize, 10);
|
11606 | }
|
11607 | }
|
11608 |
|
11609 | var DEFAULT_FONT_SIZE = 12;
|
11610 | var LINE_HEIGHT_RATIO = 1.2;
|
11611 | var MIN_TEXT_ANNOTATION_HEIGHT = 30;
|
11612 | function TextRenderer(config) {
|
11613 | var defaultStyle = assign({
|
11614 | fontFamily: 'Arial, sans-serif',
|
11615 | fontSize: DEFAULT_FONT_SIZE,
|
11616 | fontWeight: 'normal',
|
11617 | lineHeight: LINE_HEIGHT_RATIO
|
11618 | }, config && config.defaultStyle || {});
|
11619 | var fontSize = parseInt(defaultStyle.fontSize, 10) - 1;
|
11620 | var externalStyle = assign({}, defaultStyle, {
|
11621 | fontSize: fontSize
|
11622 | }, config && config.externalStyle || {});
|
11623 | var textUtil = new Text({
|
11624 | style: defaultStyle
|
11625 | });
|
11626 | |
11627 |
|
11628 |
|
11629 |
|
11630 |
|
11631 |
|
11632 |
|
11633 |
|
11634 |
|
11635 |
|
11636 | this.getExternalLabelBounds = function (bounds, text) {
|
11637 | var layoutedDimensions = textUtil.getDimensions(text, {
|
11638 | box: {
|
11639 | width: 90,
|
11640 | height: 30,
|
11641 | x: bounds.width / 2 + bounds.x,
|
11642 | y: bounds.height / 2 + bounds.y
|
11643 | },
|
11644 | style: externalStyle
|
11645 | });
|
11646 |
|
11647 | return {
|
11648 | x: Math.round(bounds.x + bounds.width / 2 - layoutedDimensions.width / 2),
|
11649 | y: Math.round(bounds.y),
|
11650 | width: Math.ceil(layoutedDimensions.width),
|
11651 | height: Math.ceil(layoutedDimensions.height)
|
11652 | };
|
11653 | };
|
11654 | |
11655 |
|
11656 |
|
11657 |
|
11658 |
|
11659 |
|
11660 |
|
11661 |
|
11662 |
|
11663 |
|
11664 | this.getTextAnnotationBounds = function (bounds, text) {
|
11665 | var layoutedDimensions = textUtil.getDimensions(text, {
|
11666 | box: bounds,
|
11667 | style: defaultStyle,
|
11668 | align: 'left-top',
|
11669 | padding: 5
|
11670 | });
|
11671 | return {
|
11672 | x: bounds.x,
|
11673 | y: bounds.y,
|
11674 | width: bounds.width,
|
11675 | height: Math.max(MIN_TEXT_ANNOTATION_HEIGHT, Math.round(layoutedDimensions.height))
|
11676 | };
|
11677 | };
|
11678 | |
11679 |
|
11680 |
|
11681 |
|
11682 |
|
11683 |
|
11684 |
|
11685 |
|
11686 |
|
11687 |
|
11688 | this.createText = function (text, options) {
|
11689 | return textUtil.createText(text, options || {});
|
11690 | };
|
11691 | |
11692 |
|
11693 |
|
11694 |
|
11695 |
|
11696 | this.getDefaultStyle = function () {
|
11697 | return defaultStyle;
|
11698 | };
|
11699 | |
11700 |
|
11701 |
|
11702 |
|
11703 |
|
11704 | this.getExternalStyle = function () {
|
11705 | return externalStyle;
|
11706 | };
|
11707 | }
|
11708 | TextRenderer.$inject = ['config.textRenderer'];
|
11709 |
|
11710 |
|
11711 |
|
11712 | |
11713 |
|
11714 |
|
11715 | function PathMap() {
|
11716 | |
11717 |
|
11718 |
|
11719 |
|
11720 |
|
11721 |
|
11722 |
|
11723 |
|
11724 |
|
11725 |
|
11726 |
|
11727 |
|
11728 |
|
11729 |
|
11730 |
|
11731 |
|
11732 |
|
11733 |
|
11734 |
|
11735 |
|
11736 |
|
11737 |
|
11738 |
|
11739 |
|
11740 |
|
11741 |
|
11742 |
|
11743 |
|
11744 |
|
11745 |
|
11746 |
|
11747 |
|
11748 |
|
11749 |
|
11750 |
|
11751 |
|
11752 |
|
11753 | this.pathMap = {
|
11754 | 'KNOWLEDGE_SOURCE': {
|
11755 | d: 'm {mx},{my} ' + 'l 0,{e.y0} ' + 'c {e.x0},{e.y1} {e.x1},-{e.y2} {e.x2},-{e.y3} ' + 'c {e.x3},-{e.y4} {e.x4},{e.y5} {e.x5},{e.y6} ' + 'l 0,-{e.y7}z',
|
11756 | width: 100,
|
11757 | height: 65,
|
11758 | widthElements: [29.8, 48.4, 67.2, 12.2, 19.8, 30.8],
|
11759 | heightElements: [55.3, 19.7, 4.2, 6.7, 2.3, 1.6, 6.2, 54.6]
|
11760 | },
|
11761 | 'BUSINESS_KNOWLEDGE_MODEL': {
|
11762 | d: 'm {mx},{my} l {e.x0},-{e.y0} l {e.x1},0 l 0,{e.y1} l -{e.x2},{e.y2} l -{e.x3},0z',
|
11763 | width: 125,
|
11764 | height: 45,
|
11765 | widthElements: [13.8, 109.2, 13.8, 109.1],
|
11766 | heightElements: [13.2, 29.8, 13.2]
|
11767 | },
|
11768 | 'TEXT_ANNOTATION': {
|
11769 | d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0',
|
11770 | width: 10,
|
11771 | height: 30,
|
11772 | widthElements: [10],
|
11773 | heightElements: [30]
|
11774 | }
|
11775 | };
|
11776 |
|
11777 | this.getRawPath = function getRawPath(pathId) {
|
11778 | return this.pathMap[pathId].d;
|
11779 | };
|
11780 | |
11781 |
|
11782 |
|
11783 |
|
11784 |
|
11785 |
|
11786 |
|
11787 |
|
11788 |
|
11789 |
|
11790 |
|
11791 |
|
11792 |
|
11793 |
|
11794 |
|
11795 |
|
11796 |
|
11797 |
|
11798 |
|
11799 |
|
11800 |
|
11801 |
|
11802 |
|
11803 |
|
11804 |
|
11805 |
|
11806 |
|
11807 |
|
11808 |
|
11809 |
|
11810 |
|
11811 |
|
11812 |
|
11813 |
|
11814 |
|
11815 |
|
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 |
|
11821 |
|
11822 |
|
11823 |
|
11824 |
|
11825 |
|
11826 |
|
11827 |
|
11828 |
|
11829 |
|
11830 |
|
11831 | this.getScaledPath = function getScaledPath(pathId, param) {
|
11832 | var rawPath = this.pathMap[pathId];
|
11833 |
|
11834 |
|
11835 | var mx, my;
|
11836 |
|
11837 | if (param.abspos) {
|
11838 | mx = param.abspos.x;
|
11839 | my = param.abspos.y;
|
11840 | } else {
|
11841 | mx = param.containerWidth * param.position.mx;
|
11842 | my = param.containerHeight * param.position.my;
|
11843 | }
|
11844 |
|
11845 | var coordinates = {};
|
11846 |
|
11847 | if (param.position) {
|
11848 |
|
11849 | var heightRatio = param.containerHeight / rawPath.height * param.yScaleFactor;
|
11850 | var widthRatio = param.containerWidth / rawPath.width * param.xScaleFactor;
|
11851 |
|
11852 | for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
|
11853 | coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
|
11854 | }
|
11855 |
|
11856 |
|
11857 | for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
|
11858 | coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
|
11859 | }
|
11860 | }
|
11861 |
|
11862 |
|
11863 | var path = format(rawPath.d, {
|
11864 | mx: mx,
|
11865 | my: my,
|
11866 | e: coordinates
|
11867 | });
|
11868 | return path;
|
11869 | };
|
11870 | }
|
11871 |
|
11872 |
|
11873 | var tokenRegex = /\{([^}]+)\}/g,
|
11874 | objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;
|
11875 |
|
11876 | function replacer(all, key, obj) {
|
11877 | var res = obj;
|
11878 | key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
|
11879 | name = name || quotedName;
|
11880 |
|
11881 | if (res) {
|
11882 | if (name in res) {
|
11883 | res = res[name];
|
11884 | }
|
11885 |
|
11886 | typeof res == 'function' && isFunc && (res = res());
|
11887 | }
|
11888 | });
|
11889 | res = (res == null || res == obj ? all : res) + '';
|
11890 | return res;
|
11891 | }
|
11892 |
|
11893 | function format(str, obj) {
|
11894 | return String(str).replace(tokenRegex, function (all, key) {
|
11895 | return replacer(all, key, obj);
|
11896 | });
|
11897 | }
|
11898 |
|
11899 | var DrawModule$1 = {
|
11900 | __init__: ['drdRenderer'],
|
11901 | drdRenderer: ['type', DrdRenderer],
|
11902 | textRenderer: ['type', TextRenderer],
|
11903 | pathMap: ['type', PathMap]
|
11904 | };
|
11905 |
|
11906 | function DrdImporter(eventBus, canvas, elementFactory, elementRegistry) {
|
11907 | this._eventBus = eventBus;
|
11908 | this._canvas = canvas;
|
11909 | this._elementRegistry = elementRegistry;
|
11910 | this._elementFactory = elementFactory;
|
11911 | }
|
11912 | DrdImporter.$inject = ['eventBus', 'canvas', 'elementFactory', 'elementRegistry'];
|
11913 |
|
11914 | DrdImporter.prototype.root = function (semantic) {
|
11915 | var element = this._elementFactory.createRoot(elementData(semantic));
|
11916 |
|
11917 | this._canvas.setRootElement(element);
|
11918 |
|
11919 | return element;
|
11920 | };
|
11921 | |
11922 |
|
11923 |
|
11924 |
|
11925 |
|
11926 | DrdImporter.prototype.add = function (semantic) {
|
11927 | var elementFactory = this._elementFactory,
|
11928 | canvas = this._canvas,
|
11929 | eventBus = this._eventBus,
|
11930 | di = semantic.di;
|
11931 | var element, waypoints, source, target, elementDefinition, bounds;
|
11932 |
|
11933 | if (di.$instanceOf('dmndi:DMNShape')) {
|
11934 | bounds = di.bounds;
|
11935 | elementDefinition = elementData(semantic, {
|
11936 | x: Math.round(bounds.x),
|
11937 | y: Math.round(bounds.y),
|
11938 | width: Math.round(bounds.width),
|
11939 | height: Math.round(bounds.height)
|
11940 | });
|
11941 | element = elementFactory.createShape(elementDefinition);
|
11942 | canvas.addShape(element);
|
11943 | eventBus.fire('drdElement.added', {
|
11944 | element: element,
|
11945 | di: di
|
11946 | });
|
11947 | } else if (di.$instanceOf('dmndi:DMNEdge')) {
|
11948 | waypoints = collectWaypoints(di);
|
11949 | source = this._getSource(semantic);
|
11950 | target = this._getTarget(semantic);
|
11951 |
|
11952 | if (source && target) {
|
11953 | elementDefinition = elementData(semantic, {
|
11954 | hidden: false,
|
11955 | source: source,
|
11956 | target: target,
|
11957 | waypoints: waypoints
|
11958 | });
|
11959 | element = elementFactory.createConnection(elementDefinition);
|
11960 | canvas.addConnection(element);
|
11961 | eventBus.fire('drdElement.added', {
|
11962 | element: element,
|
11963 | di: di
|
11964 | });
|
11965 | }
|
11966 | } else {
|
11967 | throw new Error('unknown di for element ' + semantic.id);
|
11968 | }
|
11969 |
|
11970 | return element;
|
11971 | };
|
11972 |
|
11973 | DrdImporter.prototype._getSource = function (semantic) {
|
11974 | var href, elementReference;
|
11975 |
|
11976 | if (is(semantic, 'dmn:Association')) {
|
11977 | elementReference = semantic.sourceRef;
|
11978 | } else if (is(semantic, 'dmn:InformationRequirement')) {
|
11979 | elementReference = semantic.requiredDecision || semantic.requiredInput;
|
11980 | } else if (is(semantic, 'dmn:KnowledgeRequirement')) {
|
11981 | elementReference = semantic.requiredKnowledge;
|
11982 | } else if (is(semantic, 'dmn:AuthorityRequirement')) {
|
11983 | elementReference = semantic.requiredDecision || semantic.requiredInput || semantic.requiredAuthority;
|
11984 | }
|
11985 |
|
11986 | if (elementReference) {
|
11987 | href = elementReference.href;
|
11988 | }
|
11989 |
|
11990 | if (href) {
|
11991 | return this._getShape(getIdFromHref(href));
|
11992 | }
|
11993 | };
|
11994 |
|
11995 | DrdImporter.prototype._getTarget = function (semantic) {
|
11996 | if (is(semantic, 'dmn:Association')) {
|
11997 | return semantic.targetRef && this._getShape(getIdFromHref(semantic.targetRef.href));
|
11998 | }
|
11999 |
|
12000 | return this._getShape(semantic.$parent.id);
|
12001 | };
|
12002 |
|
12003 | DrdImporter.prototype._getShape = function (id) {
|
12004 | return this._elementRegistry.get(id);
|
12005 | };
|
12006 |
|
12007 |
|
12008 | function elementData(semantic, attrs) {
|
12009 | return assign({
|
12010 | id: semantic.id,
|
12011 | type: semantic.$type,
|
12012 | businessObject: semantic
|
12013 | }, attrs);
|
12014 | }
|
12015 |
|
12016 | function collectWaypoints(edge) {
|
12017 | var waypoints = edge.waypoint;
|
12018 |
|
12019 | if (waypoints) {
|
12020 | return map(waypoints, function (waypoint) {
|
12021 | var position = {
|
12022 | x: waypoint.x,
|
12023 | y: waypoint.y
|
12024 | };
|
12025 | return assign({
|
12026 | original: position
|
12027 | }, position);
|
12028 | });
|
12029 | }
|
12030 | }
|
12031 |
|
12032 | function getIdFromHref(href) {
|
12033 | return href.split('#').pop();
|
12034 | }
|
12035 |
|
12036 | var ImportModule = {
|
12037 | drdImporter: ['type', DrdImporter]
|
12038 | };
|
12039 |
|
12040 | var CoreModule$1 = {
|
12041 | __depends__: [DrawModule$1, ImportModule]
|
12042 | };
|
12043 |
|
12044 | |
12045 |
|
12046 |
|
12047 |
|
12048 |
|
12049 |
|
12050 |
|
12051 |
|
12052 |
|
12053 |
|
12054 |
|
12055 |
|
12056 |
|
12057 |
|
12058 |
|
12059 |
|
12060 |
|
12061 |
|
12062 | function translate$1(template, replacements) {
|
12063 | replacements = replacements || {};
|
12064 | return template.replace(/{([^}]+)}/g, function (_, key) {
|
12065 | return replacements[key] || '{' + key + '}';
|
12066 | });
|
12067 | }
|
12068 |
|
12069 | var TranslateModule = {
|
12070 | translate: ['value', translate$1]
|
12071 | };
|
12072 |
|
12073 | function getOriginal(event) {
|
12074 | return event.originalEvent || event.srcEvent;
|
12075 | }
|
12076 |
|
12077 | function isMac() {
|
12078 | return /mac/i.test(navigator.platform);
|
12079 | }
|
12080 |
|
12081 | function isPrimaryButton(event) {
|
12082 |
|
12083 | return !(getOriginal(event) || event).button;
|
12084 | }
|
12085 | function hasPrimaryModifier(event) {
|
12086 | var originalEvent = getOriginal(event) || event;
|
12087 |
|
12088 | if (!isPrimaryButton(event)) {
|
12089 | return false;
|
12090 | }
|
12091 |
|
12092 |
|
12093 | if (isMac()) {
|
12094 | return originalEvent.metaKey;
|
12095 | } else {
|
12096 | return originalEvent.ctrlKey;
|
12097 | }
|
12098 | }
|
12099 |
|
12100 | function allowAll(e) {
|
12101 | return true;
|
12102 | }
|
12103 |
|
12104 | var LOW_PRIORITY = 500;
|
12105 | |
12106 |
|
12107 |
|
12108 |
|
12109 |
|
12110 |
|
12111 |
|
12112 |
|
12113 |
|
12114 |
|
12115 |
|
12116 |
|
12117 |
|
12118 |
|
12119 |
|
12120 |
|
12121 |
|
12122 |
|
12123 |
|
12124 |
|
12125 |
|
12126 |
|
12127 | function InteractionEvents(eventBus, elementRegistry, styles) {
|
12128 | var self = this;
|
12129 | |
12130 |
|
12131 |
|
12132 |
|
12133 |
|
12134 |
|
12135 |
|
12136 |
|
12137 |
|
12138 | function fire(type, event, element) {
|
12139 | if (isIgnored(type, event)) {
|
12140 | return;
|
12141 | }
|
12142 |
|
12143 | var target, gfx, returnValue;
|
12144 |
|
12145 | if (!element) {
|
12146 | target = event.delegateTarget || event.target;
|
12147 |
|
12148 | if (target) {
|
12149 | gfx = target;
|
12150 | element = elementRegistry.get(gfx);
|
12151 | }
|
12152 | } else {
|
12153 | gfx = elementRegistry.getGraphics(element);
|
12154 | }
|
12155 |
|
12156 | if (!gfx || !element) {
|
12157 | return;
|
12158 | }
|
12159 |
|
12160 | returnValue = eventBus.fire(type, {
|
12161 | element: element,
|
12162 | gfx: gfx,
|
12163 | originalEvent: event
|
12164 | });
|
12165 |
|
12166 | if (returnValue === false) {
|
12167 | event.stopPropagation();
|
12168 | event.preventDefault();
|
12169 | }
|
12170 | }
|
12171 |
|
12172 |
|
12173 | var handlers = {};
|
12174 |
|
12175 | function mouseHandler(localEventName) {
|
12176 | return handlers[localEventName];
|
12177 | }
|
12178 |
|
12179 | function isIgnored(localEventName, event) {
|
12180 | var filter = ignoredFilters[localEventName] || isPrimaryButton;
|
12181 |
|
12182 |
|
12183 |
|
12184 | return !filter(event);
|
12185 | }
|
12186 |
|
12187 | var bindings = {
|
12188 | click: 'element.click',
|
12189 | contextmenu: 'element.contextmenu',
|
12190 | dblclick: 'element.dblclick',
|
12191 | mousedown: 'element.mousedown',
|
12192 | mousemove: 'element.mousemove',
|
12193 | mouseover: 'element.hover',
|
12194 | mouseout: 'element.out',
|
12195 | mouseup: 'element.mouseup'
|
12196 | };
|
12197 | var ignoredFilters = {
|
12198 | 'element.contextmenu': allowAll
|
12199 | };
|
12200 |
|
12201 | |
12202 |
|
12203 |
|
12204 |
|
12205 |
|
12206 |
|
12207 |
|
12208 |
|
12209 |
|
12210 | function triggerMouseEvent(eventName, event, targetElement) {
|
12211 |
|
12212 | var localEventName = bindings[eventName];
|
12213 |
|
12214 | if (!localEventName) {
|
12215 | throw new Error('unmapped DOM event name <' + eventName + '>');
|
12216 | }
|
12217 |
|
12218 | return fire(localEventName, event, targetElement);
|
12219 | }
|
12220 |
|
12221 | var ELEMENT_SELECTOR = 'svg, .djs-element';
|
12222 |
|
12223 | function registerEvent(node, event, localEvent, ignoredFilter) {
|
12224 | var handler = handlers[localEvent] = function (event) {
|
12225 | fire(localEvent, event);
|
12226 | };
|
12227 |
|
12228 | if (ignoredFilter) {
|
12229 | ignoredFilters[localEvent] = ignoredFilter;
|
12230 | }
|
12231 |
|
12232 | handler.$delegate = delegate.bind(node, ELEMENT_SELECTOR, event, handler);
|
12233 | }
|
12234 |
|
12235 | function unregisterEvent(node, event, localEvent) {
|
12236 | var handler = mouseHandler(localEvent);
|
12237 |
|
12238 | if (!handler) {
|
12239 | return;
|
12240 | }
|
12241 |
|
12242 | delegate.unbind(node, event, handler.$delegate);
|
12243 | }
|
12244 |
|
12245 | function registerEvents(svg) {
|
12246 | forEach(bindings, function (val, key) {
|
12247 | registerEvent(svg, key, val);
|
12248 | });
|
12249 | }
|
12250 |
|
12251 | function unregisterEvents(svg) {
|
12252 | forEach(bindings, function (val, key) {
|
12253 | unregisterEvent(svg, key, val);
|
12254 | });
|
12255 | }
|
12256 |
|
12257 | eventBus.on('canvas.destroy', function (event) {
|
12258 | unregisterEvents(event.svg);
|
12259 | });
|
12260 | eventBus.on('canvas.init', function (event) {
|
12261 | registerEvents(event.svg);
|
12262 | });
|
12263 |
|
12264 | eventBus.on(['shape.added', 'connection.added'], function (event) {
|
12265 | var element = event.element,
|
12266 | gfx = event.gfx;
|
12267 | eventBus.fire('interactionEvents.createHit', {
|
12268 | element: element,
|
12269 | gfx: gfx
|
12270 | });
|
12271 | });
|
12272 |
|
12273 |
|
12274 |
|
12275 | eventBus.on(['shape.changed', 'connection.changed'], LOW_PRIORITY, function (event) {
|
12276 | var element = event.element,
|
12277 | gfx = event.gfx;
|
12278 | eventBus.fire('interactionEvents.updateHit', {
|
12279 | element: element,
|
12280 | gfx: gfx
|
12281 | });
|
12282 | });
|
12283 | eventBus.on('interactionEvents.createHit', LOW_PRIORITY, function (event) {
|
12284 | var element = event.element,
|
12285 | gfx = event.gfx;
|
12286 | self.createDefaultHit(element, gfx);
|
12287 | });
|
12288 | eventBus.on('interactionEvents.updateHit', function (event) {
|
12289 | var element = event.element,
|
12290 | gfx = event.gfx;
|
12291 | self.updateDefaultHit(element, gfx);
|
12292 | });
|
12293 |
|
12294 | var STROKE_HIT_STYLE = createHitStyle('djs-hit djs-hit-stroke');
|
12295 | var CLICK_STROKE_HIT_STYLE = createHitStyle('djs-hit djs-hit-click-stroke');
|
12296 | var ALL_HIT_STYLE = createHitStyle('djs-hit djs-hit-all');
|
12297 | var HIT_TYPES = {
|
12298 | 'all': ALL_HIT_STYLE,
|
12299 | 'click-stroke': CLICK_STROKE_HIT_STYLE,
|
12300 | 'stroke': STROKE_HIT_STYLE
|
12301 | };
|
12302 |
|
12303 | function createHitStyle(classNames, attrs) {
|
12304 | attrs = assign({
|
12305 | stroke: 'white',
|
12306 | strokeWidth: 15
|
12307 | }, attrs || {});
|
12308 | return styles.cls(classNames, ['no-fill', 'no-border'], attrs);
|
12309 | }
|
12310 |
|
12311 |
|
12312 | function applyStyle(hit, type) {
|
12313 | var attrs = HIT_TYPES[type];
|
12314 |
|
12315 | if (!attrs) {
|
12316 | throw new Error('invalid hit type <' + type + '>');
|
12317 | }
|
12318 |
|
12319 | attr$1(hit, attrs);
|
12320 | return hit;
|
12321 | }
|
12322 |
|
12323 | function appendHit(gfx, hit) {
|
12324 | append(gfx, hit);
|
12325 | }
|
12326 |
|
12327 | |
12328 |
|
12329 |
|
12330 |
|
12331 |
|
12332 |
|
12333 |
|
12334 | this.removeHits = function (gfx) {
|
12335 | var hits = all('.djs-hit', gfx);
|
12336 | forEach(hits, remove$1);
|
12337 | };
|
12338 | |
12339 |
|
12340 |
|
12341 |
|
12342 |
|
12343 |
|
12344 |
|
12345 |
|
12346 |
|
12347 |
|
12348 | this.createDefaultHit = function (element, gfx) {
|
12349 | var waypoints = element.waypoints,
|
12350 | isFrame = element.isFrame,
|
12351 | boxType;
|
12352 |
|
12353 | if (waypoints) {
|
12354 | return this.createWaypointsHit(gfx, waypoints);
|
12355 | } else {
|
12356 | boxType = isFrame ? 'stroke' : 'all';
|
12357 | return this.createBoxHit(gfx, boxType, {
|
12358 | width: element.width,
|
12359 | height: element.height
|
12360 | });
|
12361 | }
|
12362 | };
|
12363 | |
12364 |
|
12365 |
|
12366 |
|
12367 |
|
12368 |
|
12369 |
|
12370 |
|
12371 |
|
12372 |
|
12373 | this.createWaypointsHit = function (gfx, waypoints) {
|
12374 | var hit = createLine(waypoints);
|
12375 | applyStyle(hit, 'stroke');
|
12376 | appendHit(gfx, hit);
|
12377 | return hit;
|
12378 | };
|
12379 | |
12380 |
|
12381 |
|
12382 |
|
12383 |
|
12384 |
|
12385 |
|
12386 |
|
12387 |
|
12388 |
|
12389 |
|
12390 | this.createBoxHit = function (gfx, type, attrs) {
|
12391 | attrs = assign({
|
12392 | x: 0,
|
12393 | y: 0
|
12394 | }, attrs);
|
12395 | var hit = create('rect');
|
12396 | applyStyle(hit, type);
|
12397 | attr$1(hit, attrs);
|
12398 | appendHit(gfx, hit);
|
12399 | return hit;
|
12400 | };
|
12401 | |
12402 |
|
12403 |
|
12404 |
|
12405 |
|
12406 |
|
12407 |
|
12408 |
|
12409 |
|
12410 |
|
12411 | this.updateDefaultHit = function (element, gfx) {
|
12412 | var hit = query('.djs-hit', gfx);
|
12413 |
|
12414 | if (!hit) {
|
12415 | return;
|
12416 | }
|
12417 |
|
12418 | if (element.waypoints) {
|
12419 | updateLine(hit, element.waypoints);
|
12420 | } else {
|
12421 | attr$1(hit, {
|
12422 | width: element.width,
|
12423 | height: element.height
|
12424 | });
|
12425 | }
|
12426 |
|
12427 | return hit;
|
12428 | };
|
12429 |
|
12430 | this.fire = fire;
|
12431 | this.triggerMouseEvent = triggerMouseEvent;
|
12432 | this.mouseHandler = mouseHandler;
|
12433 | this.registerEvent = registerEvent;
|
12434 | this.unregisterEvent = unregisterEvent;
|
12435 | }
|
12436 | InteractionEvents.$inject = ['eventBus', 'elementRegistry', 'styles'];
|
12437 | |
12438 |
|
12439 |
|
12440 |
|
12441 |
|
12442 |
|
12443 |
|
12444 |
|
12445 |
|
12446 |
|
12447 |
|
12448 | |
12449 |
|
12450 |
|
12451 |
|
12452 |
|
12453 |
|
12454 |
|
12455 |
|
12456 |
|
12457 |
|
12458 |
|
12459 | |
12460 |
|
12461 |
|
12462 |
|
12463 |
|
12464 |
|
12465 |
|
12466 |
|
12467 |
|
12468 |
|
12469 |
|
12470 | |
12471 |
|
12472 |
|
12473 |
|
12474 |
|
12475 |
|
12476 |
|
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 | |
12482 |
|
12483 |
|
12484 |
|
12485 |
|
12486 |
|
12487 |
|
12488 |
|
12489 |
|
12490 |
|
12491 |
|
12492 | |
12493 |
|
12494 |
|
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 | |
12504 |
|
12505 |
|
12506 |
|
12507 |
|
12508 |
|
12509 |
|
12510 |
|
12511 |
|
12512 |
|
12513 |
|
12514 |
|
12515 | var InteractionEventsModule = {
|
12516 | __init__: ['interactionEvents'],
|
12517 | interactionEvents: ['type', InteractionEvents]
|
12518 | };
|
12519 |
|
12520 | var LOW_PRIORITY$1 = 500;
|
12521 | |
12522 |
|
12523 |
|
12524 |
|
12525 |
|
12526 |
|
12527 |
|
12528 |
|
12529 |
|
12530 |
|
12531 |
|
12532 | function Outline(eventBus, styles, elementRegistry) {
|
12533 | this.offset = 6;
|
12534 | var OUTLINE_STYLE = styles.cls('djs-outline', ['no-fill']);
|
12535 | var self = this;
|
12536 |
|
12537 | function createOutline(gfx, bounds) {
|
12538 | var outline = create('rect');
|
12539 | attr$1(outline, assign({
|
12540 | x: 10,
|
12541 | y: 10,
|
12542 | width: 100,
|
12543 | height: 100
|
12544 | }, OUTLINE_STYLE));
|
12545 | append(gfx, outline);
|
12546 | return outline;
|
12547 | }
|
12548 |
|
12549 |
|
12550 |
|
12551 | eventBus.on(['shape.added', 'shape.changed'], LOW_PRIORITY$1, function (event) {
|
12552 | var element = event.element,
|
12553 | gfx = event.gfx;
|
12554 | var outline = query('.djs-outline', gfx);
|
12555 |
|
12556 | if (!outline) {
|
12557 | outline = createOutline(gfx);
|
12558 | }
|
12559 |
|
12560 | self.updateShapeOutline(outline, element);
|
12561 | });
|
12562 | eventBus.on(['connection.added', 'connection.changed'], function (event) {
|
12563 | var element = event.element,
|
12564 | gfx = event.gfx;
|
12565 | var outline = query('.djs-outline', gfx);
|
12566 |
|
12567 | if (!outline) {
|
12568 | outline = createOutline(gfx);
|
12569 | }
|
12570 |
|
12571 | self.updateConnectionOutline(outline, element);
|
12572 | });
|
12573 | }
|
12574 | |
12575 |
|
12576 |
|
12577 |
|
12578 |
|
12579 |
|
12580 |
|
12581 |
|
12582 | Outline.prototype.updateShapeOutline = function (outline, element) {
|
12583 | attr$1(outline, {
|
12584 | x: -this.offset,
|
12585 | y: -this.offset,
|
12586 | width: element.width + this.offset * 2,
|
12587 | height: element.height + this.offset * 2
|
12588 | });
|
12589 | };
|
12590 | |
12591 |
|
12592 |
|
12593 |
|
12594 |
|
12595 |
|
12596 |
|
12597 |
|
12598 |
|
12599 | Outline.prototype.updateConnectionOutline = function (outline, connection) {
|
12600 | var bbox = getBBox(connection);
|
12601 | attr$1(outline, {
|
12602 | x: bbox.x - this.offset,
|
12603 | y: bbox.y - this.offset,
|
12604 | width: bbox.width + this.offset * 2,
|
12605 | height: bbox.height + this.offset * 2
|
12606 | });
|
12607 | };
|
12608 |
|
12609 | Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
|
12610 |
|
12611 | var OutlineModule = {
|
12612 | __init__: ['outline'],
|
12613 | outline: ['type', Outline]
|
12614 | };
|
12615 |
|
12616 | |
12617 |
|
12618 |
|
12619 |
|
12620 |
|
12621 |
|
12622 |
|
12623 |
|
12624 |
|
12625 | function Selection(eventBus) {
|
12626 | this._eventBus = eventBus;
|
12627 | this._selectedElements = [];
|
12628 | var self = this;
|
12629 | eventBus.on(['shape.remove', 'connection.remove'], function (e) {
|
12630 | var element = e.element;
|
12631 | self.deselect(element);
|
12632 | });
|
12633 | eventBus.on(['diagram.clear'], function (e) {
|
12634 | self.select(null);
|
12635 | });
|
12636 | }
|
12637 | Selection.$inject = ['eventBus'];
|
12638 |
|
12639 | Selection.prototype.deselect = function (element) {
|
12640 | var selectedElements = this._selectedElements;
|
12641 | var idx = selectedElements.indexOf(element);
|
12642 |
|
12643 | if (idx !== -1) {
|
12644 | var oldSelection = selectedElements.slice();
|
12645 | selectedElements.splice(idx, 1);
|
12646 |
|
12647 | this._eventBus.fire('selection.changed', {
|
12648 | oldSelection: oldSelection,
|
12649 | newSelection: selectedElements
|
12650 | });
|
12651 | }
|
12652 | };
|
12653 |
|
12654 | Selection.prototype.get = function () {
|
12655 | return this._selectedElements;
|
12656 | };
|
12657 |
|
12658 | Selection.prototype.isSelected = function (element) {
|
12659 | return this._selectedElements.indexOf(element) !== -1;
|
12660 | };
|
12661 | |
12662 |
|
12663 |
|
12664 |
|
12665 |
|
12666 |
|
12667 |
|
12668 |
|
12669 |
|
12670 |
|
12671 |
|
12672 |
|
12673 |
|
12674 | Selection.prototype.select = function (elements, add) {
|
12675 | var selectedElements = this._selectedElements,
|
12676 | oldSelection = selectedElements.slice();
|
12677 |
|
12678 | if (!isArray(elements)) {
|
12679 | elements = elements ? [elements] : [];
|
12680 | }
|
12681 |
|
12682 |
|
12683 |
|
12684 | if (add) {
|
12685 | forEach(elements, function (element) {
|
12686 | if (selectedElements.indexOf(element) !== -1) {
|
12687 |
|
12688 | return;
|
12689 | } else {
|
12690 | selectedElements.push(element);
|
12691 | }
|
12692 | });
|
12693 | } else {
|
12694 | this._selectedElements = selectedElements = elements.slice();
|
12695 | }
|
12696 |
|
12697 | this._eventBus.fire('selection.changed', {
|
12698 | oldSelection: oldSelection,
|
12699 | newSelection: selectedElements
|
12700 | });
|
12701 | };
|
12702 |
|
12703 | var MARKER_HOVER = 'hover',
|
12704 | MARKER_SELECTED = 'selected';
|
12705 | |
12706 |
|
12707 |
|
12708 |
|
12709 |
|
12710 |
|
12711 |
|
12712 |
|
12713 |
|
12714 |
|
12715 |
|
12716 |
|
12717 |
|
12718 | function SelectionVisuals(events, canvas, selection, styles) {
|
12719 | this._multiSelectionBox = null;
|
12720 |
|
12721 | function addMarker(e, cls) {
|
12722 | canvas.addMarker(e, cls);
|
12723 | }
|
12724 |
|
12725 | function removeMarker(e, cls) {
|
12726 | canvas.removeMarker(e, cls);
|
12727 | }
|
12728 |
|
12729 | events.on('element.hover', function (event) {
|
12730 | addMarker(event.element, MARKER_HOVER);
|
12731 | });
|
12732 | events.on('element.out', function (event) {
|
12733 | removeMarker(event.element, MARKER_HOVER);
|
12734 | });
|
12735 | events.on('selection.changed', function (event) {
|
12736 | function deselect(s) {
|
12737 | removeMarker(s, MARKER_SELECTED);
|
12738 | }
|
12739 |
|
12740 | function select(s) {
|
12741 | addMarker(s, MARKER_SELECTED);
|
12742 | }
|
12743 |
|
12744 | var oldSelection = event.oldSelection,
|
12745 | newSelection = event.newSelection;
|
12746 | forEach(oldSelection, function (e) {
|
12747 | if (newSelection.indexOf(e) === -1) {
|
12748 | deselect(e);
|
12749 | }
|
12750 | });
|
12751 | forEach(newSelection, function (e) {
|
12752 | if (oldSelection.indexOf(e) === -1) {
|
12753 | select(e);
|
12754 | }
|
12755 | });
|
12756 | });
|
12757 | }
|
12758 | SelectionVisuals.$inject = ['eventBus', 'canvas', 'selection', 'styles'];
|
12759 |
|
12760 | function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
|
12761 | eventBus.on('create.end', 500, function (e) {
|
12762 | var context = e.context,
|
12763 | canExecute = context.canExecute,
|
12764 | elements = context.elements,
|
12765 | hints = context.hints || {},
|
12766 | autoSelect = hints.autoSelect;
|
12767 |
|
12768 | if (canExecute) {
|
12769 | if (autoSelect === false) {
|
12770 |
|
12771 | return;
|
12772 | }
|
12773 |
|
12774 | if (isArray(autoSelect)) {
|
12775 | selection.select(autoSelect);
|
12776 | } else {
|
12777 |
|
12778 | selection.select(elements.filter(isShown));
|
12779 | }
|
12780 | }
|
12781 | });
|
12782 | eventBus.on('connect.end', 500, function (e) {
|
12783 |
|
12784 |
|
12785 | if (e.context.canExecute && e.context.hover) {
|
12786 | selection.select(e.context.hover);
|
12787 | }
|
12788 | });
|
12789 | eventBus.on('shape.move.end', 500, function (e) {
|
12790 | var previousSelection = e.previousSelection || [];
|
12791 | var shape = elementRegistry.get(e.context.shape.id);
|
12792 |
|
12793 |
|
12794 | var inSelection = find(previousSelection, function (selectedShape) {
|
12795 | return shape.id === selectedShape.id;
|
12796 | });
|
12797 |
|
12798 | if (!inSelection) {
|
12799 | selection.select(shape);
|
12800 | }
|
12801 | });
|
12802 |
|
12803 | eventBus.on('element.click', function (event) {
|
12804 | var element = event.element;
|
12805 |
|
12806 |
|
12807 | if (element === canvas.getRootElement()) {
|
12808 | element = null;
|
12809 | }
|
12810 |
|
12811 | var isSelected = selection.isSelected(element),
|
12812 | isMultiSelect = selection.get().length > 1;
|
12813 |
|
12814 | var add = hasPrimaryModifier(event);
|
12815 |
|
12816 | if (isSelected && isMultiSelect) {
|
12817 | if (add) {
|
12818 | return selection.deselect(element);
|
12819 | } else {
|
12820 | return selection.select(element);
|
12821 | }
|
12822 | } else if (!isSelected) {
|
12823 | selection.select(element, add);
|
12824 | } else {
|
12825 | selection.deselect(element);
|
12826 | }
|
12827 | });
|
12828 | }
|
12829 | SelectionBehavior.$inject = ['eventBus', 'selection', 'canvas', 'elementRegistry'];
|
12830 |
|
12831 | function isShown(element) {
|
12832 | return !element.hidden;
|
12833 | }
|
12834 |
|
12835 | var SelectionModule = {
|
12836 | __init__: ['selectionVisuals', 'selectionBehavior'],
|
12837 | __depends__: [InteractionEventsModule, OutlineModule],
|
12838 | selection: ['type', Selection],
|
12839 | selectionVisuals: ['type', SelectionVisuals],
|
12840 | selectionBehavior: ['type', SelectionBehavior]
|
12841 | };
|
12842 |
|
12843 | |
12844 |
|
12845 |
|
12846 |
|
12847 |
|
12848 |
|
12849 |
|
12850 |
|
12851 |
|
12852 |
|
12853 |
|
12854 | function IdGenerator(prefix) {
|
12855 | this._counter = 0;
|
12856 | this._prefix = (prefix ? prefix + '-' : '') + Math.floor(Math.random() * 1000000000) + '-';
|
12857 | }
|
12858 | |
12859 |
|
12860 |
|
12861 |
|
12862 |
|
12863 |
|
12864 |
|
12865 |
|
12866 | IdGenerator.prototype.next = function () {
|
12867 | return this._prefix + ++this._counter;
|
12868 | };
|
12869 |
|
12870 | var ids = new IdGenerator('ov');
|
12871 | var LOW_PRIORITY$2 = 500;
|
12872 | |
12873 |
|
12874 |
|
12875 |
|
12876 |
|
12877 |
|
12878 |
|
12879 |
|
12880 |
|
12881 |
|
12882 |
|
12883 |
|
12884 |
|
12885 |
|
12886 |
|
12887 |
|
12888 |
|
12889 |
|
12890 |
|
12891 |
|
12892 |
|
12893 |
|
12894 |
|
12895 |
|
12896 |
|
12897 |
|
12898 |
|
12899 |
|
12900 |
|
12901 |
|
12902 |
|
12903 |
|
12904 |
|
12905 |
|
12906 |
|
12907 |
|
12908 |
|
12909 |
|
12910 |
|
12911 |
|
12912 |
|
12913 |
|
12914 |
|
12915 |
|
12916 |
|
12917 |
|
12918 |
|
12919 |
|
12920 |
|
12921 |
|
12922 |
|
12923 |
|
12924 |
|
12925 |
|
12926 |
|
12927 |
|
12928 |
|
12929 |
|
12930 |
|
12931 |
|
12932 |
|
12933 |
|
12934 |
|
12935 |
|
12936 |
|
12937 | function Overlays(config, eventBus, canvas, elementRegistry) {
|
12938 | this._eventBus = eventBus;
|
12939 | this._canvas = canvas;
|
12940 | this._elementRegistry = elementRegistry;
|
12941 | this._ids = ids;
|
12942 | this._overlayDefaults = assign({
|
12943 |
|
12944 | show: null,
|
12945 |
|
12946 | scale: true
|
12947 | }, config && config.defaults);
|
12948 | |
12949 |
|
12950 |
|
12951 |
|
12952 | this._overlays = {};
|
12953 | |
12954 |
|
12955 |
|
12956 |
|
12957 | this._overlayContainers = [];
|
12958 |
|
12959 | this._overlayRoot = createRoot(canvas.getContainer());
|
12960 |
|
12961 | this._init();
|
12962 | }
|
12963 | Overlays.$inject = ['config.overlays', 'eventBus', 'canvas', 'elementRegistry'];
|
12964 | |
12965 |
|
12966 |
|
12967 |
|
12968 |
|
12969 |
|
12970 |
|
12971 |
|
12972 |
|
12973 |
|
12974 |
|
12975 |
|
12976 |
|
12977 |
|
12978 |
|
12979 |
|
12980 |
|
12981 |
|
12982 |
|
12983 |
|
12984 |
|
12985 |
|
12986 |
|
12987 |
|
12988 |
|
12989 |
|
12990 |
|
12991 | Overlays.prototype.get = function (search) {
|
12992 | if (isString(search)) {
|
12993 | search = {
|
12994 | id: search
|
12995 | };
|
12996 | }
|
12997 |
|
12998 | if (isString(search.element)) {
|
12999 | search.element = this._elementRegistry.get(search.element);
|
13000 | }
|
13001 |
|
13002 | if (search.element) {
|
13003 | var container = this._getOverlayContainer(search.element, true);
|
13004 |
|
13005 |
|
13006 | if (container) {
|
13007 | return search.type ? filter(container.overlays, matchPattern({
|
13008 | type: search.type
|
13009 | })) : container.overlays.slice();
|
13010 | } else {
|
13011 | return [];
|
13012 | }
|
13013 | } else if (search.type) {
|
13014 | return filter(this._overlays, matchPattern({
|
13015 | type: search.type
|
13016 | }));
|
13017 | } else {
|
13018 |
|
13019 | return search.id ? this._overlays[search.id] : null;
|
13020 | }
|
13021 | };
|
13022 | |
13023 |
|
13024 |
|
13025 |
|
13026 |
|
13027 |
|
13028 |
|
13029 |
|
13030 |
|
13031 |
|
13032 |
|
13033 |
|
13034 |
|
13035 |
|
13036 |
|
13037 |
|
13038 |
|
13039 |
|
13040 |
|
13041 |
|
13042 |
|
13043 |
|
13044 |
|
13045 |
|
13046 |
|
13047 | Overlays.prototype.add = function (element, type, overlay) {
|
13048 | if (isObject(type)) {
|
13049 | overlay = type;
|
13050 | type = null;
|
13051 | }
|
13052 |
|
13053 | if (!element.id) {
|
13054 | element = this._elementRegistry.get(element);
|
13055 | }
|
13056 |
|
13057 | if (!overlay.position) {
|
13058 | throw new Error('must specifiy overlay position');
|
13059 | }
|
13060 |
|
13061 | if (!overlay.html) {
|
13062 | throw new Error('must specifiy overlay html');
|
13063 | }
|
13064 |
|
13065 | if (!element) {
|
13066 | throw new Error('invalid element specified');
|
13067 | }
|
13068 |
|
13069 | var id = this._ids.next();
|
13070 |
|
13071 | overlay = assign({}, this._overlayDefaults, overlay, {
|
13072 | id: id,
|
13073 | type: type,
|
13074 | element: element,
|
13075 | html: overlay.html
|
13076 | });
|
13077 |
|
13078 | this._addOverlay(overlay);
|
13079 |
|
13080 | return id;
|
13081 | };
|
13082 | |
13083 |
|
13084 |
|
13085 |
|
13086 |
|
13087 |
|
13088 |
|
13089 |
|
13090 |
|
13091 |
|
13092 | Overlays.prototype.remove = function (filter) {
|
13093 | var overlays = this.get(filter) || [];
|
13094 |
|
13095 | if (!isArray(overlays)) {
|
13096 | overlays = [overlays];
|
13097 | }
|
13098 |
|
13099 | var self = this;
|
13100 | forEach(overlays, function (overlay) {
|
13101 | var container = self._getOverlayContainer(overlay.element, true);
|
13102 |
|
13103 | if (overlay) {
|
13104 | remove(overlay.html);
|
13105 | remove(overlay.htmlContainer);
|
13106 | delete overlay.htmlContainer;
|
13107 | delete overlay.element;
|
13108 | delete self._overlays[overlay.id];
|
13109 | }
|
13110 |
|
13111 | if (container) {
|
13112 | var idx = container.overlays.indexOf(overlay);
|
13113 |
|
13114 | if (idx !== -1) {
|
13115 | container.overlays.splice(idx, 1);
|
13116 | }
|
13117 | }
|
13118 | });
|
13119 | };
|
13120 |
|
13121 | Overlays.prototype.show = function () {
|
13122 | setVisible(this._overlayRoot);
|
13123 | };
|
13124 |
|
13125 | Overlays.prototype.hide = function () {
|
13126 | setVisible(this._overlayRoot, false);
|
13127 | };
|
13128 |
|
13129 | Overlays.prototype.clear = function () {
|
13130 | this._overlays = {};
|
13131 | this._overlayContainers = [];
|
13132 | clear(this._overlayRoot);
|
13133 | };
|
13134 |
|
13135 | Overlays.prototype._updateOverlayContainer = function (container) {
|
13136 | var element = container.element,
|
13137 | html = container.html;
|
13138 |
|
13139 |
|
13140 | var x = element.x,
|
13141 | y = element.y;
|
13142 |
|
13143 | if (element.waypoints) {
|
13144 | var bbox = getBBox(element);
|
13145 | x = bbox.x;
|
13146 | y = bbox.y;
|
13147 | }
|
13148 |
|
13149 | setPosition(html, x, y);
|
13150 | attr(container.html, 'data-container-id', element.id);
|
13151 | };
|
13152 |
|
13153 | Overlays.prototype._updateOverlay = function (overlay) {
|
13154 | var position = overlay.position,
|
13155 | htmlContainer = overlay.htmlContainer,
|
13156 | element = overlay.element;
|
13157 |
|
13158 |
|
13159 |
|
13160 | var left = position.left,
|
13161 | top = position.top;
|
13162 |
|
13163 | if (position.right !== undefined) {
|
13164 | var width;
|
13165 |
|
13166 | if (element.waypoints) {
|
13167 | width = getBBox(element).width;
|
13168 | } else {
|
13169 | width = element.width;
|
13170 | }
|
13171 |
|
13172 | left = position.right * -1 + width;
|
13173 | }
|
13174 |
|
13175 | if (position.bottom !== undefined) {
|
13176 | var height;
|
13177 |
|
13178 | if (element.waypoints) {
|
13179 | height = getBBox(element).height;
|
13180 | } else {
|
13181 | height = element.height;
|
13182 | }
|
13183 |
|
13184 | top = position.bottom * -1 + height;
|
13185 | }
|
13186 |
|
13187 | setPosition(htmlContainer, left || 0, top || 0);
|
13188 | };
|
13189 |
|
13190 | Overlays.prototype._createOverlayContainer = function (element) {
|
13191 | var html = domify('<div class="djs-overlays" style="position: absolute" />');
|
13192 |
|
13193 | this._overlayRoot.appendChild(html);
|
13194 |
|
13195 | var container = {
|
13196 | html: html,
|
13197 | element: element,
|
13198 | overlays: []
|
13199 | };
|
13200 |
|
13201 | this._updateOverlayContainer(container);
|
13202 |
|
13203 | this._overlayContainers.push(container);
|
13204 |
|
13205 | return container;
|
13206 | };
|
13207 |
|
13208 | Overlays.prototype._updateRoot = function (viewbox) {
|
13209 | var scale = viewbox.scale || 1;
|
13210 | var matrix = 'matrix(' + [scale, 0, 0, scale, -1 * viewbox.x * scale, -1 * viewbox.y * scale].join(',') + ')';
|
13211 | setTransform(this._overlayRoot, matrix);
|
13212 | };
|
13213 |
|
13214 | Overlays.prototype._getOverlayContainer = function (element, raw) {
|
13215 | var container = find(this._overlayContainers, function (c) {
|
13216 | return c.element === element;
|
13217 | });
|
13218 |
|
13219 | if (!container && !raw) {
|
13220 | return this._createOverlayContainer(element);
|
13221 | }
|
13222 |
|
13223 | return container;
|
13224 | };
|
13225 |
|
13226 | Overlays.prototype._addOverlay = function (overlay) {
|
13227 | var id = overlay.id,
|
13228 | element = overlay.element,
|
13229 | html = overlay.html,
|
13230 | htmlContainer,
|
13231 | overlayContainer;
|
13232 |
|
13233 | if (html.get && html.constructor.prototype.jquery) {
|
13234 | html = html.get(0);
|
13235 | }
|
13236 |
|
13237 |
|
13238 |
|
13239 | if (isString(html)) {
|
13240 | html = domify(html);
|
13241 | }
|
13242 |
|
13243 | overlayContainer = this._getOverlayContainer(element);
|
13244 | htmlContainer = domify('<div class="djs-overlay" data-overlay-id="' + id + '" style="position: absolute">');
|
13245 | htmlContainer.appendChild(html);
|
13246 |
|
13247 | if (overlay.type) {
|
13248 | classes(htmlContainer).add('djs-overlay-' + overlay.type);
|
13249 | }
|
13250 |
|
13251 | overlay.htmlContainer = htmlContainer;
|
13252 | overlayContainer.overlays.push(overlay);
|
13253 | overlayContainer.html.appendChild(htmlContainer);
|
13254 | this._overlays[id] = overlay;
|
13255 |
|
13256 | this._updateOverlay(overlay);
|
13257 |
|
13258 | this._updateOverlayVisibilty(overlay, this._canvas.viewbox());
|
13259 | };
|
13260 |
|
13261 | Overlays.prototype._updateOverlayVisibilty = function (overlay, viewbox) {
|
13262 | var show = overlay.show,
|
13263 | minZoom = show && show.minZoom,
|
13264 | maxZoom = show && show.maxZoom,
|
13265 | htmlContainer = overlay.htmlContainer,
|
13266 | visible = true;
|
13267 |
|
13268 | if (show) {
|
13269 | if (isDefined(minZoom) && minZoom > viewbox.scale || isDefined(maxZoom) && maxZoom < viewbox.scale) {
|
13270 | visible = false;
|
13271 | }
|
13272 |
|
13273 | setVisible(htmlContainer, visible);
|
13274 | }
|
13275 |
|
13276 | this._updateOverlayScale(overlay, viewbox);
|
13277 | };
|
13278 |
|
13279 | Overlays.prototype._updateOverlayScale = function (overlay, viewbox) {
|
13280 | var shouldScale = overlay.scale,
|
13281 | minScale,
|
13282 | maxScale,
|
13283 | htmlContainer = overlay.htmlContainer;
|
13284 | var scale,
|
13285 | transform = '';
|
13286 |
|
13287 | if (shouldScale !== true) {
|
13288 | if (shouldScale === false) {
|
13289 | minScale = 1;
|
13290 | maxScale = 1;
|
13291 | } else {
|
13292 | minScale = shouldScale.min;
|
13293 | maxScale = shouldScale.max;
|
13294 | }
|
13295 |
|
13296 | if (isDefined(minScale) && viewbox.scale < minScale) {
|
13297 | scale = (1 / viewbox.scale || 1) * minScale;
|
13298 | }
|
13299 |
|
13300 | if (isDefined(maxScale) && viewbox.scale > maxScale) {
|
13301 | scale = (1 / viewbox.scale || 1) * maxScale;
|
13302 | }
|
13303 | }
|
13304 |
|
13305 | if (isDefined(scale)) {
|
13306 | transform = 'scale(' + scale + ',' + scale + ')';
|
13307 | }
|
13308 |
|
13309 | setTransform(htmlContainer, transform);
|
13310 | };
|
13311 |
|
13312 | Overlays.prototype._updateOverlaysVisibilty = function (viewbox) {
|
13313 | var self = this;
|
13314 | forEach(this._overlays, function (overlay) {
|
13315 | self._updateOverlayVisibilty(overlay, viewbox);
|
13316 | });
|
13317 | };
|
13318 |
|
13319 | Overlays.prototype._init = function () {
|
13320 | var eventBus = this._eventBus;
|
13321 | var self = this;
|
13322 |
|
13323 | function updateViewbox(viewbox) {
|
13324 | self._updateRoot(viewbox);
|
13325 |
|
13326 | self._updateOverlaysVisibilty(viewbox);
|
13327 |
|
13328 | self.show();
|
13329 | }
|
13330 |
|
13331 | eventBus.on('canvas.viewbox.changing', function (event) {
|
13332 | self.hide();
|
13333 | });
|
13334 | eventBus.on('canvas.viewbox.changed', function (event) {
|
13335 | updateViewbox(event.viewbox);
|
13336 | });
|
13337 |
|
13338 | eventBus.on(['shape.remove', 'connection.remove'], function (e) {
|
13339 | var element = e.element;
|
13340 | var overlays = self.get({
|
13341 | element: element
|
13342 | });
|
13343 | forEach(overlays, function (o) {
|
13344 | self.remove(o.id);
|
13345 | });
|
13346 |
|
13347 | var container = self._getOverlayContainer(element);
|
13348 |
|
13349 | if (container) {
|
13350 | remove(container.html);
|
13351 |
|
13352 | var i = self._overlayContainers.indexOf(container);
|
13353 |
|
13354 | if (i !== -1) {
|
13355 | self._overlayContainers.splice(i, 1);
|
13356 | }
|
13357 | }
|
13358 | });
|
13359 |
|
13360 | eventBus.on('element.changed', LOW_PRIORITY$2, function (e) {
|
13361 | var element = e.element;
|
13362 |
|
13363 | var container = self._getOverlayContainer(element, true);
|
13364 |
|
13365 | if (container) {
|
13366 | forEach(container.overlays, function (overlay) {
|
13367 | self._updateOverlay(overlay);
|
13368 | });
|
13369 |
|
13370 | self._updateOverlayContainer(container);
|
13371 | }
|
13372 | });
|
13373 |
|
13374 | eventBus.on('element.marker.update', function (e) {
|
13375 | var container = self._getOverlayContainer(e.element, true);
|
13376 |
|
13377 | if (container) {
|
13378 | classes(container.html)[e.add ? 'add' : 'remove'](e.marker);
|
13379 | }
|
13380 | });
|
13381 |
|
13382 | eventBus.on('diagram.clear', this.clear, this);
|
13383 | };
|
13384 |
|
13385 |
|
13386 | function createRoot(parentNode) {
|
13387 | var root = domify('<div class="djs-overlay-container" style="position: absolute; width: 0; height: 0;" />');
|
13388 | parentNode.insertBefore(root, parentNode.firstChild);
|
13389 | return root;
|
13390 | }
|
13391 |
|
13392 | function setPosition(el, x, y) {
|
13393 | assign(el.style, {
|
13394 | left: x + 'px',
|
13395 | top: y + 'px'
|
13396 | });
|
13397 | }
|
13398 |
|
13399 | function setVisible(el, visible) {
|
13400 | el.style.display = visible === false ? 'none' : '';
|
13401 | }
|
13402 |
|
13403 | function setTransform(el, transform) {
|
13404 | el.style['transform-origin'] = 'top left';
|
13405 | ['', '-ms-', '-webkit-'].forEach(function (prefix) {
|
13406 | el.style[prefix + 'transform'] = transform;
|
13407 | });
|
13408 | }
|
13409 |
|
13410 | var OverlaysModule = {
|
13411 | __init__: ['overlays'],
|
13412 | overlays: ['type', Overlays]
|
13413 | };
|
13414 |
|
13415 | function DefinitionPropertiesView(eventBus, canvas) {
|
13416 | this._eventBus = eventBus;
|
13417 | this._canvas = canvas;
|
13418 | eventBus.on('diagram.init', function () {
|
13419 | this._init();
|
13420 | }, this);
|
13421 | eventBus.on('import.done', function (event) {
|
13422 | if (!event.error) {
|
13423 | this.update();
|
13424 | }
|
13425 | }, this);
|
13426 | }
|
13427 | DefinitionPropertiesView.$inject = ['eventBus', 'canvas'];
|
13428 | |
13429 |
|
13430 |
|
13431 |
|
13432 | DefinitionPropertiesView.prototype._init = function () {
|
13433 | var canvas = this._canvas,
|
13434 | eventBus = this._eventBus;
|
13435 | var parent = canvas.getContainer(),
|
13436 | container = this._container = domify(DefinitionPropertiesView.HTML_MARKUP);
|
13437 | parent.appendChild(container);
|
13438 | this.nameElement = query('.dmn-definitions-name', this._container);
|
13439 | this.idElement = query('.dmn-definitions-id', this._container);
|
13440 | delegate.bind(container, '.dmn-definitions-name, .dmn-definitions-id', 'mousedown', function (event) {
|
13441 | event.stopPropagation();
|
13442 | });
|
13443 | eventBus.fire('definitionIdView.create', {
|
13444 | html: container
|
13445 | });
|
13446 | };
|
13447 |
|
13448 | DefinitionPropertiesView.prototype.update = function () {
|
13449 | var businessObject = this._canvas.getRootElement().businessObject;
|
13450 |
|
13451 | this.nameElement.textContent = businessObject.name;
|
13452 | this.idElement.textContent = businessObject.id;
|
13453 | };
|
13454 |
|
13455 |
|
13456 |
|
13457 | DefinitionPropertiesView.HTML_MARKUP = '<div class="dmn-definitions">' + '<div class="dmn-definitions-name" title="Definition Name"></div>' + '<div class="dmn-definitions-id" title="Definition ID"></div>' + '</div>';
|
13458 |
|
13459 | function PaletteAdapter(eventBus, canvas) {
|
13460 | function toggleMarker(cls, on) {
|
13461 | var container = canvas.getContainer();
|
13462 | classes(container).toggle(cls, on);
|
13463 | }
|
13464 |
|
13465 | eventBus.on('palette.create', function () {
|
13466 | toggleMarker('with-palette', true);
|
13467 | });
|
13468 | eventBus.on('palette.changed', function (event) {
|
13469 | toggleMarker('with-palette-two-column', event.twoColumn);
|
13470 | });
|
13471 | }
|
13472 | PaletteAdapter.$inject = ['eventBus', 'canvas'];
|
13473 |
|
13474 | var DefinitionPropertiesModule = {
|
13475 | __init__: ['definitionPropertiesView', 'definitionPropertiesPaletteAdapter'],
|
13476 | definitionPropertiesView: ['type', DefinitionPropertiesView],
|
13477 | definitionPropertiesPaletteAdapter: ['type', PaletteAdapter]
|
13478 | };
|
13479 |
|
13480 | function _classCallCheck$2(instance, Constructor) {
|
13481 | if (!(instance instanceof Constructor)) {
|
13482 | throw new TypeError("Cannot call a class as a function");
|
13483 | }
|
13484 | }
|
13485 |
|
13486 | function _defineProperties$2(target, props) {
|
13487 | for (var i = 0; i < props.length; i++) {
|
13488 | var descriptor = props[i];
|
13489 | descriptor.enumerable = descriptor.enumerable || false;
|
13490 | descriptor.configurable = true;
|
13491 | if ("value" in descriptor) descriptor.writable = true;
|
13492 | Object.defineProperty(target, descriptor.key, descriptor);
|
13493 | }
|
13494 | }
|
13495 |
|
13496 | function _createClass$2(Constructor, protoProps, staticProps) {
|
13497 | if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
13498 | if (staticProps) _defineProperties$2(Constructor, staticProps);
|
13499 | return Constructor;
|
13500 | }
|
13501 | var PROVIDERS = [{
|
13502 | className: 'dmn-icon-decision-table',
|
13503 | matches: function matches(el) {
|
13504 | var businessObject = el.businessObject;
|
13505 | return is(businessObject, 'dmn:Decision') && is(businessObject.decisionLogic, 'dmn:DecisionTable');
|
13506 | }
|
13507 | }, {
|
13508 | className: 'dmn-icon-literal-expression',
|
13509 | matches: function matches(el) {
|
13510 | var businessObject = el.businessObject;
|
13511 | return is(businessObject, 'dmn:Decision') && is(businessObject.decisionLogic, 'dmn:LiteralExpression');
|
13512 | }
|
13513 | }];
|
13514 | |
13515 |
|
13516 |
|
13517 |
|
13518 |
|
13519 | var DrillDown =
|
13520 |
|
13521 | function () {
|
13522 | function DrillDown(injector, eventBus, overlays, config) {
|
13523 | var _this = this;
|
13524 |
|
13525 | _classCallCheck$2(this, DrillDown);
|
13526 |
|
13527 | this._injector = injector;
|
13528 | this._eventBus = eventBus;
|
13529 | this._overlays = overlays;
|
13530 | this._config = config || {
|
13531 | enabled: true
|
13532 | };
|
13533 | eventBus.on(['shape.added'], function (_ref) {
|
13534 | var element = _ref.element;
|
13535 |
|
13536 | for (var i = 0; i < PROVIDERS.length; i++) {
|
13537 | var _PROVIDERS$i = PROVIDERS[i],
|
13538 | matches = _PROVIDERS$i.matches,
|
13539 | className = _PROVIDERS$i.className;
|
13540 | var editable = matches && matches(element);
|
13541 |
|
13542 | if (editable) {
|
13543 | _this.addOverlay(element, className);
|
13544 | }
|
13545 | }
|
13546 | });
|
13547 | }
|
13548 | |
13549 |
|
13550 |
|
13551 |
|
13552 |
|
13553 |
|
13554 |
|
13555 |
|
13556 |
|
13557 | _createClass$2(DrillDown, [{
|
13558 | key: "addOverlay",
|
13559 | value: function addOverlay(element, className) {
|
13560 | var html = domify("\n <div class=\"drill-down-overlay\">\n <span class=\"".concat(className, "\"></span>\n </div>\n "));
|
13561 |
|
13562 | var overlayId = this._overlays.add(element, {
|
13563 | position: {
|
13564 | top: 2,
|
13565 | left: 2
|
13566 | },
|
13567 | html: html
|
13568 | });
|
13569 |
|
13570 |
|
13571 | if (this._config.enabled !== false) {
|
13572 | classes(html).add('interactive');
|
13573 | this.bindEventListener(element, html, overlayId);
|
13574 | }
|
13575 | }
|
13576 | |
13577 |
|
13578 |
|
13579 |
|
13580 |
|
13581 |
|
13582 | }, {
|
13583 | key: "bindEventListener",
|
13584 | value: function bindEventListener(element, overlay, id) {
|
13585 | var _this2 = this;
|
13586 |
|
13587 | var overlays = this._overlays,
|
13588 | eventBus = this._eventBus;
|
13589 | var overlaysRoot = overlays._overlayRoot;
|
13590 | delegate.bind(overlaysRoot, '[data-overlay-id="' + id + '"]', 'click', function () {
|
13591 | var triggerDefault = eventBus.fire('drillDown.click', {
|
13592 | element: element
|
13593 | });
|
13594 |
|
13595 | if (triggerDefault === false) {
|
13596 | return;
|
13597 | }
|
13598 |
|
13599 | _this2.drillDown(element);
|
13600 | });
|
13601 | }
|
13602 | |
13603 |
|
13604 |
|
13605 |
|
13606 |
|
13607 |
|
13608 |
|
13609 |
|
13610 | }, {
|
13611 | key: "drillDown",
|
13612 | value: function drillDown(element) {
|
13613 | var parent = this._injector.get('_parent', false);
|
13614 |
|
13615 |
|
13616 | if (!parent) {
|
13617 | return false;
|
13618 | }
|
13619 |
|
13620 | var view = parent.getView(element.businessObject);
|
13621 |
|
13622 | if (!view) {
|
13623 | return false;
|
13624 | }
|
13625 |
|
13626 | parent.open(view);
|
13627 | return true;
|
13628 | }
|
13629 | }]);
|
13630 |
|
13631 | return DrillDown;
|
13632 | }();
|
13633 | DrillDown.$inject = ['injector', 'eventBus', 'overlays', 'config.drillDown'];
|
13634 |
|
13635 | var DrillDownModule = {
|
13636 | __depends__: [OverlaysModule],
|
13637 | __init__: ['drillDown'],
|
13638 | drillDown: ['type', DrillDown]
|
13639 | };
|
13640 |
|
13641 | |
13642 |
|
13643 |
|
13644 |
|
13645 |
|
13646 |
|
13647 |
|
13648 | var BPMNIO_LOGO_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.02 5.57" width="53" height="21" style="vertical-align:middle"><path fill="currentColor" d="M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"/><path fill="currentColor" d="M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"/></svg>';
|
13649 | var BPMNIO_IMG = BPMNIO_LOGO_SVG;
|
13650 |
|
13651 | function css(attrs) {
|
13652 | return attrs.join(';');
|
13653 | }
|
13654 |
|
13655 | var LINK_STYLES = css(['color: #404040']);
|
13656 | var LIGHTBOX_STYLES = css(['z-index: 1001', 'position: fixed', 'top: 0', 'left: 0', 'right: 0', 'bottom: 0']);
|
13657 | var BACKDROP_STYLES = css(['width: 100%', 'height: 100%', 'background: rgba(40,40,40,0.2)']);
|
13658 | var NOTICE_STYLES = css(['position: absolute', 'left: 50%', 'top: 40%', 'transform: translate(-50%)', 'width: 260px', 'padding: 10px', 'background: white', 'box-shadow: 0 1px 4px rgba(0,0,0,0.3)', 'font-family: Helvetica, Arial, sans-serif', 'font-size: 14px', 'display: flex', 'line-height: 1.3']);
|
13659 |
|
13660 |
|
13661 | var LIGHTBOX_MARKUP = '<div class="bjs-powered-by-lightbox" style="' + LIGHTBOX_STYLES + '">' + '<div class="backdrop" style="' + BACKDROP_STYLES + '"></div>' + '<div class="notice" style="' + NOTICE_STYLES + '">' + '<a href="https://bpmn.io" target="_blank" rel="noopener" style="margin: 15px 20px 15px 10px; align-self: center;' + LINK_STYLES + '">' + BPMNIO_IMG + '</a>' + '<span>' + 'Web-based tooling for BPMN, DMN and CMMN diagrams ' + 'powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.' + '</span>' + '</div>' + '</div>';
|
13662 |
|
13663 |
|
13664 | var lightbox;
|
13665 | function open() {
|
13666 | if (!lightbox) {
|
13667 | lightbox = domify(LIGHTBOX_MARKUP);
|
13668 | delegate.bind(lightbox, '.backdrop', 'click', function (event) {
|
13669 | document.body.removeChild(lightbox);
|
13670 | });
|
13671 | }
|
13672 |
|
13673 | document.body.appendChild(lightbox);
|
13674 | }
|
13675 |
|
13676 | function ownKeys$1(object, enumerableOnly) {
|
13677 | var keys = Object.keys(object);
|
13678 |
|
13679 | if (Object.getOwnPropertySymbols) {
|
13680 | var symbols = Object.getOwnPropertySymbols(object);
|
13681 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
13682 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
13683 | });
|
13684 | keys.push.apply(keys, symbols);
|
13685 | }
|
13686 |
|
13687 | return keys;
|
13688 | }
|
13689 |
|
13690 | function _objectSpread$1(target) {
|
13691 | for (var i = 1; i < arguments.length; i++) {
|
13692 | var source = arguments[i] != null ? arguments[i] : {};
|
13693 |
|
13694 | if (i % 2) {
|
13695 | ownKeys$1(source, true).forEach(function (key) {
|
13696 | _defineProperty$1(target, key, source[key]);
|
13697 | });
|
13698 | } else if (Object.getOwnPropertyDescriptors) {
|
13699 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
13700 | } else {
|
13701 | ownKeys$1(source).forEach(function (key) {
|
13702 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
13703 | });
|
13704 | }
|
13705 | }
|
13706 |
|
13707 | return target;
|
13708 | }
|
13709 |
|
13710 | function _defineProperty$1(obj, key, value) {
|
13711 | if (key in obj) {
|
13712 | Object.defineProperty(obj, key, {
|
13713 | value: value,
|
13714 | enumerable: true,
|
13715 | configurable: true,
|
13716 | writable: true
|
13717 | });
|
13718 | } else {
|
13719 | obj[key] = value;
|
13720 | }
|
13721 |
|
13722 | return obj;
|
13723 | }
|
13724 |
|
13725 | function _toConsumableArray$2(arr) {
|
13726 | return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _nonIterableSpread$1();
|
13727 | }
|
13728 |
|
13729 | function _nonIterableSpread$1() {
|
13730 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
13731 | }
|
13732 |
|
13733 | function _iterableToArray$1(iter) {
|
13734 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
13735 | }
|
13736 |
|
13737 | function _arrayWithoutHoles$1(arr) {
|
13738 | if (Array.isArray(arr)) {
|
13739 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
13740 | arr2[i] = arr[i];
|
13741 | }
|
13742 |
|
13743 | return arr2;
|
13744 | }
|
13745 | }
|
13746 |
|
13747 | function _objectWithoutProperties(source, excluded) {
|
13748 | if (source == null) return {};
|
13749 |
|
13750 | var target = _objectWithoutPropertiesLoose(source, excluded);
|
13751 |
|
13752 | var key, i;
|
13753 |
|
13754 | if (Object.getOwnPropertySymbols) {
|
13755 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
13756 |
|
13757 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
13758 | key = sourceSymbolKeys[i];
|
13759 | if (excluded.indexOf(key) >= 0) continue;
|
13760 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
13761 | target[key] = source[key];
|
13762 | }
|
13763 | }
|
13764 |
|
13765 | return target;
|
13766 | }
|
13767 |
|
13768 | function _objectWithoutPropertiesLoose(source, excluded) {
|
13769 | if (source == null) return {};
|
13770 | var target = {};
|
13771 | var sourceKeys = Object.keys(source);
|
13772 | var key, i;
|
13773 |
|
13774 | for (i = 0; i < sourceKeys.length; i++) {
|
13775 | key = sourceKeys[i];
|
13776 | if (excluded.indexOf(key) >= 0) continue;
|
13777 | target[key] = source[key];
|
13778 | }
|
13779 |
|
13780 | return target;
|
13781 | }
|
13782 | |
13783 |
|
13784 |
|
13785 |
|
13786 |
|
13787 |
|
13788 |
|
13789 |
|
13790 |
|
13791 |
|
13792 |
|
13793 |
|
13794 |
|
13795 |
|
13796 |
|
13797 |
|
13798 |
|
13799 |
|
13800 |
|
13801 |
|
13802 |
|
13803 |
|
13804 |
|
13805 |
|
13806 |
|
13807 |
|
13808 |
|
13809 |
|
13810 |
|
13811 |
|
13812 |
|
13813 |
|
13814 |
|
13815 |
|
13816 |
|
13817 |
|
13818 |
|
13819 |
|
13820 |
|
13821 |
|
13822 |
|
13823 |
|
13824 |
|
13825 |
|
13826 |
|
13827 |
|
13828 |
|
13829 |
|
13830 | function Viewer(options) {
|
13831 | this._container = this._createContainer();
|
13832 |
|
13833 |
|
13834 | addProjectLogo(this._container);
|
13835 |
|
13836 |
|
13837 | this._init(this._container, options);
|
13838 | }
|
13839 | inherits_browser(Viewer, Diagram);
|
13840 | |
13841 |
|
13842 |
|
13843 |
|
13844 |
|
13845 |
|
13846 |
|
13847 |
|
13848 | Viewer.prototype.saveSVG = function (options, done) {
|
13849 | if (!done) {
|
13850 | done = options;
|
13851 | options = {};
|
13852 | }
|
13853 |
|
13854 | var canvas = this.get('canvas');
|
13855 | var contentNode = canvas.getDefaultLayer(),
|
13856 | defsNode = query('defs', canvas._svg);
|
13857 | var contents = innerSVG(contentNode),
|
13858 | defs = defsNode && defsNode.outerHTML || '';
|
13859 | var bbox = contentNode.getBBox();
|
13860 |
|
13861 |
|
13862 | var svg = '<?xml version="1.0" encoding="utf-8"?>\n' + '<!-- created with dmn-js / http://bpmn.io -->\n' + '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' + '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' + 'width="' + bbox.width + '" height="' + bbox.height + '" ' + 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' + defs + contents + '</svg>';
|
13863 |
|
13864 |
|
13865 | done(null, svg);
|
13866 | };
|
13867 |
|
13868 | Viewer.prototype.getModules = function () {
|
13869 | return this._modules;
|
13870 | };
|
13871 | |
13872 |
|
13873 |
|
13874 |
|
13875 |
|
13876 |
|
13877 | Viewer.prototype.destroy = function () {
|
13878 |
|
13879 | Diagram.prototype.destroy.call(this);
|
13880 |
|
13881 | remove(this._container);
|
13882 | };
|
13883 | |
13884 |
|
13885 |
|
13886 |
|
13887 |
|
13888 |
|
13889 |
|
13890 |
|
13891 |
|
13892 |
|
13893 |
|
13894 |
|
13895 | Viewer.prototype.on = function (event, priority, callback, target) {
|
13896 | return this.get('eventBus').on(event, priority, callback, target);
|
13897 | };
|
13898 | |
13899 |
|
13900 |
|
13901 |
|
13902 |
|
13903 |
|
13904 |
|
13905 |
|
13906 | Viewer.prototype.off = function (event, callback) {
|
13907 | this.get('eventBus').off(event, callback);
|
13908 | };
|
13909 |
|
13910 | Viewer.prototype._init = function (container, options) {
|
13911 | var additionalModules = options.additionalModules,
|
13912 | canvas = options.canvas,
|
13913 | additionalOptions = _objectWithoutProperties(options, ["additionalModules", "canvas"]);
|
13914 |
|
13915 | var baseModules = options.modules || this.getModules(),
|
13916 | staticModules = [{
|
13917 | drd: ['value', this]
|
13918 | }];
|
13919 | var modules = [].concat(staticModules, _toConsumableArray$2(baseModules), _toConsumableArray$2(additionalModules || []));
|
13920 |
|
13921 | var diagramOptions = _objectSpread$1({}, additionalOptions, {
|
13922 | canvas: _objectSpread$1({}, canvas, {
|
13923 | container: container
|
13924 | }),
|
13925 | modules: modules
|
13926 | });
|
13927 |
|
13928 |
|
13929 | Diagram.call(this, diagramOptions);
|
13930 |
|
13931 | if (options && options.container) {
|
13932 | this.attachTo(options.container);
|
13933 | }
|
13934 | };
|
13935 | |
13936 |
|
13937 |
|
13938 |
|
13939 |
|
13940 |
|
13941 |
|
13942 |
|
13943 |
|
13944 |
|
13945 | Viewer.prototype._emit = function (type, event) {
|
13946 | return this.get('eventBus').fire(type, event);
|
13947 | };
|
13948 |
|
13949 | Viewer.prototype._createContainer = function () {
|
13950 | return domify('<div class="dmn-drd-container"></div>');
|
13951 | };
|
13952 |
|
13953 | Viewer.prototype.open = function (definitions, done) {
|
13954 | var err;
|
13955 |
|
13956 |
|
13957 | try {
|
13958 | if (this._definitions) {
|
13959 |
|
13960 | this.clear();
|
13961 | }
|
13962 |
|
13963 |
|
13964 | this._definitions = definitions;
|
13965 |
|
13966 | return importDRD(this, definitions, done);
|
13967 | } catch (e) {
|
13968 | err = e;
|
13969 | }
|
13970 |
|
13971 | return done(err);
|
13972 | };
|
13973 | |
13974 |
|
13975 |
|
13976 |
|
13977 |
|
13978 |
|
13979 |
|
13980 | Viewer.prototype.attachTo = function (parentNode) {
|
13981 | if (!parentNode) {
|
13982 | throw new Error('parentNode required');
|
13983 | }
|
13984 |
|
13985 |
|
13986 |
|
13987 | this.detach();
|
13988 | var container = this._container;
|
13989 | parentNode.appendChild(container);
|
13990 |
|
13991 | this._emit('attach', {});
|
13992 |
|
13993 | this.get('canvas').resized();
|
13994 | };
|
13995 | |
13996 |
|
13997 |
|
13998 |
|
13999 |
|
14000 | Viewer.prototype.detach = function () {
|
14001 | var container = this._container,
|
14002 | parentNode = container.parentNode;
|
14003 |
|
14004 | if (!parentNode) {
|
14005 | return;
|
14006 | }
|
14007 |
|
14008 | this._emit('detach', {});
|
14009 |
|
14010 | parentNode.removeChild(container);
|
14011 | };
|
14012 | Viewer.prototype._modules = [CoreModule$1, TranslateModule, SelectionModule, OverlaysModule, DefinitionPropertiesModule, DrillDownModule];
|
14013 | |
14014 |
|
14015 |
|
14016 |
|
14017 |
|
14018 |
|
14019 |
|
14020 |
|
14021 |
|
14022 | function addProjectLogo(container) {
|
14023 | var linkMarkup = '<a href="http://bpmn.io" ' + 'target="_blank" ' + 'class="bjs-powered-by" ' + 'title="Powered by bpmn.io" ' + 'style="position: absolute; bottom: 15px; right: 15px; z-index: 100; ' + LINK_STYLES + '">' + BPMNIO_IMG + '</a>';
|
14024 | var linkElement = domify(linkMarkup);
|
14025 | container.appendChild(linkElement);
|
14026 | componentEvent.bind(linkElement, 'click', function (event) {
|
14027 | open();
|
14028 | event.preventDefault();
|
14029 | });
|
14030 | }
|
14031 |
|
14032 |
|
14033 | var CLASS_PATTERN$1 = /^class /;
|
14034 |
|
14035 | function isClass$1(fn) {
|
14036 | return CLASS_PATTERN$1.test(fn.toString());
|
14037 | }
|
14038 |
|
14039 | function isArray$2(obj) {
|
14040 | return Object.prototype.toString.call(obj) === '[object Array]';
|
14041 | }
|
14042 |
|
14043 | function annotate$1() {
|
14044 | var args = Array.prototype.slice.call(arguments);
|
14045 |
|
14046 | if (args.length === 1 && isArray$2(args[0])) {
|
14047 | args = args[0];
|
14048 | }
|
14049 |
|
14050 | var fn = args.pop();
|
14051 | fn.$inject = args;
|
14052 | return fn;
|
14053 | }
|
14054 |
|
14055 |
|
14056 |
|
14057 |
|
14058 |
|
14059 |
|
14060 |
|
14061 |
|
14062 |
|
14063 |
|
14064 |
|
14065 |
|
14066 |
|
14067 | var CONSTRUCTOR_ARGS$1 = /constructor\s*[^(]*\(\s*([^)]*)\)/m;
|
14068 | var FN_ARGS$1 = /^function\s*[^(]*\(\s*([^)]*)\)/m;
|
14069 | var FN_ARG$1 = /\/\*([^*]*)\*\//m;
|
14070 |
|
14071 | function parse$3(fn) {
|
14072 | if (typeof fn !== 'function') {
|
14073 | throw new Error('Cannot annotate "' + fn + '". Expected a function!');
|
14074 | }
|
14075 |
|
14076 | var match = fn.toString().match(isClass$1(fn) ? CONSTRUCTOR_ARGS$1 : FN_ARGS$1);
|
14077 |
|
14078 | if (!match) {
|
14079 | return [];
|
14080 | }
|
14081 |
|
14082 | return match[1] && match[1].split(',').map(function (arg) {
|
14083 | match = arg.match(FN_ARG$1);
|
14084 | return match ? match[1].trim() : arg.trim();
|
14085 | }) || [];
|
14086 | }
|
14087 |
|
14088 | function Module$1() {
|
14089 | var providers = [];
|
14090 |
|
14091 | this.factory = function (name, factory) {
|
14092 | providers.push([name, 'factory', factory]);
|
14093 | return this;
|
14094 | };
|
14095 |
|
14096 | this.value = function (name, value) {
|
14097 | providers.push([name, 'value', value]);
|
14098 | return this;
|
14099 | };
|
14100 |
|
14101 | this.type = function (name, type) {
|
14102 | providers.push([name, 'type', type]);
|
14103 | return this;
|
14104 | };
|
14105 |
|
14106 | this.forEach = function (iterator) {
|
14107 | providers.forEach(iterator);
|
14108 | };
|
14109 | }
|
14110 |
|
14111 | var _typeof$3 = typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol" ? function (obj) {
|
14112 | return _typeof(obj);
|
14113 | } : function (obj) {
|
14114 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
14115 | };
|
14116 |
|
14117 | function _toConsumableArray$3(arr) {
|
14118 | if (Array.isArray(arr)) {
|
14119 | for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
14120 | arr2[i] = arr[i];
|
14121 | }
|
14122 |
|
14123 | return arr2;
|
14124 | } else {
|
14125 | return Array.from(arr);
|
14126 | }
|
14127 | }
|
14128 |
|
14129 | function Injector$1(modules, parent) {
|
14130 | parent = parent || {
|
14131 | get: function get(name, strict) {
|
14132 | currentlyResolving.push(name);
|
14133 |
|
14134 | if (strict === false) {
|
14135 | return null;
|
14136 | } else {
|
14137 | throw error('No provider for "' + name + '"!');
|
14138 | }
|
14139 | }
|
14140 | };
|
14141 | var currentlyResolving = [];
|
14142 | var providers = this._providers = Object.create(parent._providers || null);
|
14143 | var instances = this._instances = Object.create(null);
|
14144 | var self = instances.injector = this;
|
14145 |
|
14146 | var error = function error(msg) {
|
14147 | var stack = currentlyResolving.join(' -> ');
|
14148 | currentlyResolving.length = 0;
|
14149 | return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg);
|
14150 | };
|
14151 | |
14152 |
|
14153 |
|
14154 |
|
14155 |
|
14156 |
|
14157 |
|
14158 |
|
14159 |
|
14160 |
|
14161 | var get = function get(name, strict) {
|
14162 | if (!providers[name] && name.indexOf('.') !== -1) {
|
14163 | var parts = name.split('.');
|
14164 | var pivot = get(parts.shift());
|
14165 |
|
14166 | while (parts.length) {
|
14167 | pivot = pivot[parts.shift()];
|
14168 | }
|
14169 |
|
14170 | return pivot;
|
14171 | }
|
14172 |
|
14173 | if (hasProp$1(instances, name)) {
|
14174 | return instances[name];
|
14175 | }
|
14176 |
|
14177 | if (hasProp$1(providers, name)) {
|
14178 | if (currentlyResolving.indexOf(name) !== -1) {
|
14179 | currentlyResolving.push(name);
|
14180 | throw error('Cannot resolve circular dependency!');
|
14181 | }
|
14182 |
|
14183 | currentlyResolving.push(name);
|
14184 | instances[name] = providers[name][0](providers[name][1]);
|
14185 | currentlyResolving.pop();
|
14186 | return instances[name];
|
14187 | }
|
14188 |
|
14189 | return parent.get(name, strict);
|
14190 | };
|
14191 |
|
14192 | var fnDef = function fnDef(fn) {
|
14193 | var locals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
14194 |
|
14195 | if (typeof fn !== 'function') {
|
14196 | if (isArray$2(fn)) {
|
14197 | fn = annotate$1(fn.slice());
|
14198 | } else {
|
14199 | throw new Error('Cannot invoke "' + fn + '". Expected a function!');
|
14200 | }
|
14201 | }
|
14202 |
|
14203 | var inject = fn.$inject || parse$3(fn);
|
14204 | var dependencies = inject.map(function (dep) {
|
14205 | if (hasProp$1(locals, dep)) {
|
14206 | return locals[dep];
|
14207 | } else {
|
14208 | return get(dep);
|
14209 | }
|
14210 | });
|
14211 | return {
|
14212 | fn: fn,
|
14213 | dependencies: dependencies
|
14214 | };
|
14215 | };
|
14216 |
|
14217 | var instantiate = function instantiate(Type) {
|
14218 | var _fnDef = fnDef(Type),
|
14219 | dependencies = _fnDef.dependencies,
|
14220 | fn = _fnDef.fn;
|
14221 |
|
14222 | return new (Function.prototype.bind.apply(fn, [null].concat(_toConsumableArray$3(dependencies))))();
|
14223 | };
|
14224 |
|
14225 | var invoke = function invoke(func, context, locals) {
|
14226 | var _fnDef2 = fnDef(func, locals),
|
14227 | dependencies = _fnDef2.dependencies,
|
14228 | fn = _fnDef2.fn;
|
14229 |
|
14230 | return fn.call.apply(fn, [context].concat(_toConsumableArray$3(dependencies)));
|
14231 | };
|
14232 |
|
14233 | var createPrivateInjectorFactory = function createPrivateInjectorFactory(privateChildInjector) {
|
14234 | return annotate$1(function (key) {
|
14235 | return privateChildInjector.get(key);
|
14236 | });
|
14237 | };
|
14238 |
|
14239 | var createChild = function createChild(modules, forceNewInstances) {
|
14240 | if (forceNewInstances && forceNewInstances.length) {
|
14241 | var fromParentModule = Object.create(null);
|
14242 | var matchedScopes = Object.create(null);
|
14243 | var privateInjectorsCache = [];
|
14244 | var privateChildInjectors = [];
|
14245 | var privateChildFactories = [];
|
14246 | var provider;
|
14247 | var cacheIdx;
|
14248 | var privateChildInjector;
|
14249 | var privateChildInjectorFactory;
|
14250 |
|
14251 | for (var name in providers) {
|
14252 | provider = providers[name];
|
14253 |
|
14254 | if (forceNewInstances.indexOf(name) !== -1) {
|
14255 | if (provider[2] === 'private') {
|
14256 | cacheIdx = privateInjectorsCache.indexOf(provider[3]);
|
14257 |
|
14258 | if (cacheIdx === -1) {
|
14259 | privateChildInjector = provider[3].createChild([], forceNewInstances);
|
14260 | privateChildInjectorFactory = createPrivateInjectorFactory(privateChildInjector);
|
14261 | privateInjectorsCache.push(provider[3]);
|
14262 | privateChildInjectors.push(privateChildInjector);
|
14263 | privateChildFactories.push(privateChildInjectorFactory);
|
14264 | fromParentModule[name] = [privateChildInjectorFactory, name, 'private', privateChildInjector];
|
14265 | } else {
|
14266 | fromParentModule[name] = [privateChildFactories[cacheIdx], name, 'private', privateChildInjectors[cacheIdx]];
|
14267 | }
|
14268 | } else {
|
14269 | fromParentModule[name] = [provider[2], provider[1]];
|
14270 | }
|
14271 |
|
14272 | matchedScopes[name] = true;
|
14273 | }
|
14274 |
|
14275 | if ((provider[2] === 'factory' || provider[2] === 'type') && provider[1].$scope) {
|
14276 |
|
14277 | forceNewInstances.forEach(function (scope) {
|
14278 | if (provider[1].$scope.indexOf(scope) !== -1) {
|
14279 | fromParentModule[name] = [provider[2], provider[1]];
|
14280 | matchedScopes[scope] = true;
|
14281 | }
|
14282 | });
|
14283 | }
|
14284 | }
|
14285 |
|
14286 | forceNewInstances.forEach(function (scope) {
|
14287 | if (!matchedScopes[scope]) {
|
14288 | throw new Error('No provider for "' + scope + '". Cannot use provider from the parent!');
|
14289 | }
|
14290 | });
|
14291 | modules.unshift(fromParentModule);
|
14292 | }
|
14293 |
|
14294 | return new Injector$1(modules, self);
|
14295 | };
|
14296 |
|
14297 | var factoryMap = {
|
14298 | factory: invoke,
|
14299 | type: instantiate,
|
14300 | value: function value(_value) {
|
14301 | return _value;
|
14302 | }
|
14303 | };
|
14304 | modules.forEach(function (module) {
|
14305 | function arrayUnwrap(type, value) {
|
14306 | if (type !== 'value' && isArray$2(value)) {
|
14307 | value = annotate$1(value.slice());
|
14308 | }
|
14309 |
|
14310 | return value;
|
14311 | }
|
14312 |
|
14313 |
|
14314 | if (module instanceof Module$1) {
|
14315 | module.forEach(function (provider) {
|
14316 | var name = provider[0];
|
14317 | var type = provider[1];
|
14318 | var value = provider[2];
|
14319 | providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
|
14320 | });
|
14321 | } else if ((typeof module === 'undefined' ? 'undefined' : _typeof$3(module)) === 'object') {
|
14322 | if (module.__exports__) {
|
14323 | var clonedModule = Object.keys(module).reduce(function (m, key) {
|
14324 | if (key.substring(0, 2) !== '__') {
|
14325 | m[key] = module[key];
|
14326 | }
|
14327 |
|
14328 | return m;
|
14329 | }, Object.create(null));
|
14330 | var privateInjector = new Injector$1((module.__modules__ || []).concat([clonedModule]), self);
|
14331 | var getFromPrivateInjector = annotate$1(function (key) {
|
14332 | return privateInjector.get(key);
|
14333 | });
|
14334 |
|
14335 | module.__exports__.forEach(function (key) {
|
14336 | providers[key] = [getFromPrivateInjector, key, 'private', privateInjector];
|
14337 | });
|
14338 | } else {
|
14339 | Object.keys(module).forEach(function (name) {
|
14340 | if (module[name][2] === 'private') {
|
14341 | providers[name] = module[name];
|
14342 | return;
|
14343 | }
|
14344 |
|
14345 | var type = module[name][0];
|
14346 | var value = module[name][1];
|
14347 | providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
|
14348 | });
|
14349 | }
|
14350 | }
|
14351 | });
|
14352 |
|
14353 | this.get = get;
|
14354 | this.invoke = invoke;
|
14355 | this.instantiate = instantiate;
|
14356 | this.createChild = createChild;
|
14357 | } // helpers /////////////////
|
14358 |
|
14359 |
|
14360 | function hasProp$1(obj, prop) {
|
14361 | return Object.hasOwnProperty.call(obj, prop);
|
14362 | }
|
14363 |
|
14364 | |
14365 |
|
14366 |
|
14367 |
|
14368 |
|
14369 |
|
14370 |
|
14371 |
|
14372 | var nativeToString$1 = Object.prototype.toString;
|
14373 |
|
14374 | function isNumber$1(obj) {
|
14375 | return nativeToString$1.call(obj) === '[object Number]';
|
14376 | }
|
14377 |
|
14378 | function isFunction$1(obj) {
|
14379 | var tag = nativeToString$1.call(obj);
|
14380 | return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object AsyncGeneratorFunction]' || tag === '[object Proxy]';
|
14381 | }
|
14382 |
|
14383 | function _extends$1() {
|
14384 | _extends$1 = Object.assign || function (target) {
|
14385 | for (var i = 1; i < arguments.length; i++) {
|
14386 | var source = arguments[i];
|
14387 |
|
14388 | for (var key in source) {
|
14389 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
14390 | target[key] = source[key];
|
14391 | }
|
14392 | }
|
14393 | }
|
14394 |
|
14395 | return target;
|
14396 | };
|
14397 |
|
14398 | return _extends$1.apply(this, arguments);
|
14399 | }
|
14400 | |
14401 |
|
14402 |
|
14403 |
|
14404 |
|
14405 |
|
14406 |
|
14407 |
|
14408 |
|
14409 |
|
14410 | function assign$1(target) {
|
14411 | for (var _len = arguments.length, others = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
14412 | others[_key - 1] = arguments[_key];
|
14413 | }
|
14414 |
|
14415 | return _extends$1.apply(void 0, [target].concat(others));
|
14416 | }
|
14417 |
|
14418 | function _typeof$4(obj) {
|
14419 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
14420 | _typeof$4 = function _typeof$1(obj) {
|
14421 | return _typeof(obj);
|
14422 | };
|
14423 | } else {
|
14424 | _typeof$4 = function _typeof$1(obj) {
|
14425 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
14426 | };
|
14427 | }
|
14428 |
|
14429 | return _typeof$4(obj);
|
14430 | }
|
14431 |
|
14432 | function _possibleConstructorReturn$1(self, call) {
|
14433 | if (call && (_typeof$4(call) === "object" || typeof call === "function")) {
|
14434 | return call;
|
14435 | }
|
14436 |
|
14437 | return _assertThisInitialized$1(self);
|
14438 | }
|
14439 |
|
14440 | function _getPrototypeOf$1(o) {
|
14441 | _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
14442 | return o.__proto__ || Object.getPrototypeOf(o);
|
14443 | };
|
14444 | return _getPrototypeOf$1(o);
|
14445 | }
|
14446 |
|
14447 | function _assertThisInitialized$1(self) {
|
14448 | if (self === void 0) {
|
14449 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
14450 | }
|
14451 |
|
14452 | return self;
|
14453 | }
|
14454 |
|
14455 | function _inherits$1(subClass, superClass) {
|
14456 | if (typeof superClass !== "function" && superClass !== null) {
|
14457 | throw new TypeError("Super expression must either be null or a function");
|
14458 | }
|
14459 |
|
14460 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
14461 | constructor: {
|
14462 | value: subClass,
|
14463 | writable: true,
|
14464 | configurable: true
|
14465 | }
|
14466 | });
|
14467 | if (superClass) _setPrototypeOf$1(subClass, superClass);
|
14468 | }
|
14469 |
|
14470 | function _setPrototypeOf$1(o, p) {
|
14471 | _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
14472 | o.__proto__ = p;
|
14473 | return o;
|
14474 | };
|
14475 |
|
14476 | return _setPrototypeOf$1(o, p);
|
14477 | }
|
14478 |
|
14479 | function _classCallCheck$3(instance, Constructor) {
|
14480 | if (!(instance instanceof Constructor)) {
|
14481 | throw new TypeError("Cannot call a class as a function");
|
14482 | }
|
14483 | }
|
14484 | var Base$2 = function Base(attrs) {
|
14485 | _classCallCheck$3(this, Base);
|
14486 |
|
14487 | assign$1(this, attrs);
|
14488 | |
14489 |
|
14490 |
|
14491 |
|
14492 |
|
14493 |
|
14494 |
|
14495 | defineProperty$2(this, 'businessObject', {
|
14496 | writable: true
|
14497 | });
|
14498 | };
|
14499 | var Root$1 =
|
14500 |
|
14501 | function (_Base) {
|
14502 | _inherits$1(Root, _Base);
|
14503 |
|
14504 | function Root(attrs) {
|
14505 | var _this;
|
14506 |
|
14507 | _classCallCheck$3(this, Root);
|
14508 |
|
14509 | _this = _possibleConstructorReturn$1(this, _getPrototypeOf$1(Root).call(this, attrs));
|
14510 | |
14511 |
|
14512 |
|
14513 |
|
14514 |
|
14515 |
|
14516 |
|
14517 | defineProperty$2(_assertThisInitialized$1(_this), 'rows', {
|
14518 | enumerable: true,
|
14519 | value: _this.rows || []
|
14520 | });
|
14521 | |
14522 |
|
14523 |
|
14524 |
|
14525 |
|
14526 |
|
14527 |
|
14528 | defineProperty$2(_assertThisInitialized$1(_this), 'cols', {
|
14529 | enumerable: true,
|
14530 | value: _this.cols || []
|
14531 | });
|
14532 | return _this;
|
14533 | }
|
14534 |
|
14535 | return Root;
|
14536 | }(Base$2);
|
14537 | var Row =
|
14538 |
|
14539 | function (_Base2) {
|
14540 | _inherits$1(Row, _Base2);
|
14541 |
|
14542 | function Row(attrs) {
|
14543 | var _this2;
|
14544 |
|
14545 | _classCallCheck$3(this, Row);
|
14546 |
|
14547 | _this2 = _possibleConstructorReturn$1(this, _getPrototypeOf$1(Row).call(this, attrs));
|
14548 | |
14549 |
|
14550 |
|
14551 |
|
14552 |
|
14553 |
|
14554 |
|
14555 | defineProperty$2(_assertThisInitialized$1(_this2), 'root', {
|
14556 | writable: true
|
14557 | });
|
14558 | |
14559 |
|
14560 |
|
14561 |
|
14562 |
|
14563 |
|
14564 |
|
14565 | defineProperty$2(_assertThisInitialized$1(_this2), 'cells', {
|
14566 | enumerable: true,
|
14567 | value: _this2.cells || []
|
14568 | });
|
14569 | return _this2;
|
14570 | }
|
14571 |
|
14572 | return Row;
|
14573 | }(Base$2);
|
14574 | var Col =
|
14575 |
|
14576 | function (_Base3) {
|
14577 | _inherits$1(Col, _Base3);
|
14578 |
|
14579 | function Col(attrs) {
|
14580 | var _this3;
|
14581 |
|
14582 | _classCallCheck$3(this, Col);
|
14583 |
|
14584 | _this3 = _possibleConstructorReturn$1(this, _getPrototypeOf$1(Col).call(this, attrs));
|
14585 | |
14586 |
|
14587 |
|
14588 |
|
14589 |
|
14590 |
|
14591 |
|
14592 | defineProperty$2(_assertThisInitialized$1(_this3), 'root', {
|
14593 | writable: true
|
14594 | });
|
14595 | |
14596 |
|
14597 |
|
14598 |
|
14599 |
|
14600 |
|
14601 |
|
14602 | defineProperty$2(_assertThisInitialized$1(_this3), 'cells', {
|
14603 | enumerable: true,
|
14604 | value: _this3.cells || []
|
14605 | });
|
14606 | return _this3;
|
14607 | }
|
14608 |
|
14609 | return Col;
|
14610 | }(Base$2);
|
14611 | var Cell =
|
14612 |
|
14613 | function (_Base4) {
|
14614 | _inherits$1(Cell, _Base4);
|
14615 |
|
14616 | function Cell(attrs) {
|
14617 | var _this4;
|
14618 |
|
14619 | _classCallCheck$3(this, Cell);
|
14620 |
|
14621 | _this4 = _possibleConstructorReturn$1(this, _getPrototypeOf$1(Cell).call(this, attrs));
|
14622 | |
14623 |
|
14624 |
|
14625 |
|
14626 |
|
14627 |
|
14628 |
|
14629 | defineProperty$2(_assertThisInitialized$1(_this4), 'row', {
|
14630 | writable: true
|
14631 | });
|
14632 | |
14633 |
|
14634 |
|
14635 |
|
14636 |
|
14637 |
|
14638 |
|
14639 | defineProperty$2(_assertThisInitialized$1(_this4), 'col', {
|
14640 | writable: true
|
14641 | });
|
14642 | return _this4;
|
14643 | }
|
14644 |
|
14645 | return Cell;
|
14646 | }(Base$2);
|
14647 | var TYPES = {
|
14648 | root: Root$1,
|
14649 | row: Row,
|
14650 | col: Col,
|
14651 | cell: Cell
|
14652 | };
|
14653 | function create$2(type, attrs) {
|
14654 | var Type = TYPES[type];
|
14655 |
|
14656 | if (!Type) {
|
14657 | throw new Error('unknown type ' + type);
|
14658 | }
|
14659 |
|
14660 | return new Type(attrs);
|
14661 | }
|
14662 |
|
14663 | function defineProperty$2(el, prop, options) {
|
14664 | Object.defineProperty(el, prop, options);
|
14665 | }
|
14666 |
|
14667 | function _classCallCheck$4(instance, Constructor) {
|
14668 | if (!(instance instanceof Constructor)) {
|
14669 | throw new TypeError("Cannot call a class as a function");
|
14670 | }
|
14671 | }
|
14672 |
|
14673 | function _defineProperties$3(target, props) {
|
14674 | for (var i = 0; i < props.length; i++) {
|
14675 | var descriptor = props[i];
|
14676 | descriptor.enumerable = descriptor.enumerable || false;
|
14677 | descriptor.configurable = true;
|
14678 | if ("value" in descriptor) descriptor.writable = true;
|
14679 | Object.defineProperty(target, descriptor.key, descriptor);
|
14680 | }
|
14681 | }
|
14682 |
|
14683 | function _createClass$3(Constructor, protoProps, staticProps) {
|
14684 | if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
14685 | if (staticProps) _defineProperties$3(Constructor, staticProps);
|
14686 | return Constructor;
|
14687 | }
|
14688 |
|
14689 | var ElementFactory$1 =
|
14690 |
|
14691 | function () {
|
14692 | function ElementFactory() {
|
14693 | _classCallCheck$4(this, ElementFactory);
|
14694 |
|
14695 | this._uid = 12;
|
14696 | }
|
14697 |
|
14698 | _createClass$3(ElementFactory, [{
|
14699 | key: "create",
|
14700 | value: function create(type) {
|
14701 | var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
14702 |
|
14703 | if (!attrs.id) {
|
14704 | attrs.id = type + '_' + this._uid++;
|
14705 | }
|
14706 |
|
14707 | return create$2(type, attrs);
|
14708 | }
|
14709 | }, {
|
14710 | key: "createRoot",
|
14711 | value: function createRoot(attrs) {
|
14712 | return this.create('root', attrs);
|
14713 | }
|
14714 | }, {
|
14715 | key: "createRow",
|
14716 | value: function createRow(attrs) {
|
14717 | return this.create('row', attrs);
|
14718 | }
|
14719 | }, {
|
14720 | key: "createCol",
|
14721 | value: function createCol(attrs) {
|
14722 | return this.create('col', attrs);
|
14723 | }
|
14724 | }, {
|
14725 | key: "createCell",
|
14726 | value: function createCell(attrs) {
|
14727 | return this.create('cell', attrs);
|
14728 | }
|
14729 | }]);
|
14730 |
|
14731 | return ElementFactory;
|
14732 | }();
|
14733 |
|
14734 | function _classCallCheck$5(instance, Constructor) {
|
14735 | if (!(instance instanceof Constructor)) {
|
14736 | throw new TypeError("Cannot call a class as a function");
|
14737 | }
|
14738 | }
|
14739 |
|
14740 | function _defineProperties$4(target, props) {
|
14741 | for (var i = 0; i < props.length; i++) {
|
14742 | var descriptor = props[i];
|
14743 | descriptor.enumerable = descriptor.enumerable || false;
|
14744 | descriptor.configurable = true;
|
14745 | if ("value" in descriptor) descriptor.writable = true;
|
14746 | Object.defineProperty(target, descriptor.key, descriptor);
|
14747 | }
|
14748 | }
|
14749 |
|
14750 | function _createClass$4(Constructor, protoProps, staticProps) {
|
14751 | if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
14752 | if (staticProps) _defineProperties$4(Constructor, staticProps);
|
14753 | return Constructor;
|
14754 | }
|
14755 |
|
14756 | var ElementRegistry$1 =
|
14757 |
|
14758 | function () {
|
14759 | function ElementRegistry(eventBus) {
|
14760 | _classCallCheck$5(this, ElementRegistry);
|
14761 |
|
14762 | this._eventBus = eventBus;
|
14763 | this._elements = {};
|
14764 | eventBus.on('table.clear', this.clear.bind(this));
|
14765 | }
|
14766 |
|
14767 | _createClass$4(ElementRegistry, [{
|
14768 | key: "add",
|
14769 | value: function add(element, type) {
|
14770 | var id = element.id;
|
14771 | this._elements[id] = element;
|
14772 | }
|
14773 | }, {
|
14774 | key: "remove",
|
14775 | value: function remove(element) {
|
14776 | var id = element.id || element;
|
14777 | delete this._elements[id];
|
14778 | }
|
14779 | }, {
|
14780 | key: "get",
|
14781 | value: function get(id) {
|
14782 | return this._elements[id];
|
14783 | }
|
14784 | }, {
|
14785 | key: "getAll",
|
14786 | value: function getAll() {
|
14787 | return values(this._elements);
|
14788 | }
|
14789 | }, {
|
14790 | key: "forEach",
|
14791 | value: function forEach(fn) {
|
14792 | values(this._elements).forEach(function (element) {
|
14793 | return fn(element);
|
14794 | });
|
14795 | }
|
14796 | }, {
|
14797 | key: "filter",
|
14798 | value: function filter(fn) {
|
14799 | return values(this._elements).filter(function (element) {
|
14800 | return fn(element);
|
14801 | });
|
14802 | }
|
14803 | }, {
|
14804 | key: "clear",
|
14805 | value: function clear() {
|
14806 | this._elements = {};
|
14807 | }
|
14808 | }, {
|
14809 | key: "updateId",
|
14810 | value: function updateId(element, newId) {
|
14811 | this._validateId(newId);
|
14812 |
|
14813 | if (typeof element === 'string') {
|
14814 | element = this.get(element);
|
14815 | }
|
14816 |
|
14817 | this._eventBus.fire('element.updateId', {
|
14818 | element: element,
|
14819 | newId: newId
|
14820 | });
|
14821 |
|
14822 | this.remove(element);
|
14823 | element.id = newId;
|
14824 | this.add(element);
|
14825 | }
|
14826 | |
14827 |
|
14828 |
|
14829 |
|
14830 |
|
14831 |
|
14832 |
|
14833 |
|
14834 |
|
14835 | }, {
|
14836 | key: "_validateId",
|
14837 | value: function _validateId(id) {
|
14838 | if (!id) {
|
14839 | throw new Error('element must have an id');
|
14840 | }
|
14841 |
|
14842 | if (this._elements[id]) {
|
14843 | throw new Error('element with id ' + id + ' already added');
|
14844 | }
|
14845 | }
|
14846 | }]);
|
14847 |
|
14848 | return ElementRegistry;
|
14849 | }();
|
14850 | ElementRegistry$1.$inject = ['eventBus'];
|
14851 |
|
14852 | function values(obj) {
|
14853 | return Object.keys(obj).map(function (k) {
|
14854 | return obj[k];
|
14855 | });
|
14856 | }
|
14857 |
|
14858 | function _classCallCheck$6(instance, Constructor) {
|
14859 | if (!(instance instanceof Constructor)) {
|
14860 | throw new TypeError("Cannot call a class as a function");
|
14861 | }
|
14862 | }
|
14863 |
|
14864 | function _defineProperties$5(target, props) {
|
14865 | for (var i = 0; i < props.length; i++) {
|
14866 | var descriptor = props[i];
|
14867 | descriptor.enumerable = descriptor.enumerable || false;
|
14868 | descriptor.configurable = true;
|
14869 | if ("value" in descriptor) descriptor.writable = true;
|
14870 | Object.defineProperty(target, descriptor.key, descriptor);
|
14871 | }
|
14872 | }
|
14873 |
|
14874 | function _createClass$5(Constructor, protoProps, staticProps) {
|
14875 | if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
|
14876 | if (staticProps) _defineProperties$5(Constructor, staticProps);
|
14877 | return Constructor;
|
14878 | }
|
14879 |
|
14880 | var ChangeSupport =
|
14881 |
|
14882 | function () {
|
14883 | function ChangeSupport(eventBus) {
|
14884 | var _this = this;
|
14885 |
|
14886 | _classCallCheck$6(this, ChangeSupport);
|
14887 |
|
14888 | this._listeners = {};
|
14889 | eventBus.on('elements.changed', function (_ref) {
|
14890 | var elements = _ref.elements;
|
14891 |
|
14892 | _this.elementsChanged(elements);
|
14893 | });
|
14894 | eventBus.on('root.remove', function (context) {
|
14895 | var oldRootId = context.root.id;
|
14896 |
|
14897 | if (_this._listeners[oldRootId]) {
|
14898 | eventBus.once('root.add', function (context) {
|
14899 | var newRootId = context.root.id;
|
14900 |
|
14901 | _this.updateId(oldRootId, newRootId);
|
14902 | });
|
14903 | }
|
14904 | });
|
14905 | eventBus.on('element.updateId', function (_ref2) {
|
14906 | var element = _ref2.element,
|
14907 | newId = _ref2.newId;
|
14908 |
|
14909 | _this.updateId(element.id, newId);
|
14910 | });
|
14911 | }
|
14912 |
|
14913 | _createClass$5(ChangeSupport, [{
|
14914 | key: "elementsChanged",
|
14915 | value: function elementsChanged(elements) {
|
14916 | var invoked = {};
|
14917 | var elementsLength = elements.length;
|
14918 |
|
14919 | for (var i = 0; i < elementsLength; i++) {
|
14920 | var id = elements[i].id;
|
14921 |
|
14922 | if (invoked[id]) {
|
14923 | return;
|
14924 | }
|
14925 |
|
14926 | invoked[id] = true;
|
14927 | var listenersLength = this._listeners[id] && this._listeners[id].length;
|
14928 |
|
14929 | if (listenersLength) {
|
14930 | for (var j = 0; j < listenersLength; j++) {
|
14931 |
|
14932 | this._listeners[id][j] && this._listeners[id][j]();
|
14933 | }
|
14934 | }
|
14935 | }
|
14936 | }
|
14937 | }, {
|
14938 | key: "onElementsChanged",
|
14939 | value: function onElementsChanged(id, listener) {
|
14940 | if (!this._listeners[id]) {
|
14941 | this._listeners[id] = [];
|
14942 | }
|
14943 |
|
14944 |
|
14945 | this._listeners[id][this._listeners[id].length] = listener;
|
14946 | }
|
14947 | }, {
|
14948 | key: "offElementsChanged",
|
14949 | value: function offElementsChanged(id, listener) {
|
14950 | if (!this._listeners[id]) {
|
14951 | return;
|
14952 | }
|
14953 |
|
14954 | if (listener) {
|
14955 | var idx = this._listeners[id].indexOf(listener);
|
14956 |
|
14957 | if (idx !== -1) {
|
14958 | this._listeners[id].splice(idx, 1);
|
14959 | }
|
14960 | } else {
|
14961 | this._listeners[id].length = 0;
|
14962 | }
|
14963 | }
|
14964 | }, {
|
14965 | key: "updateId",
|
14966 | value: function updateId(oldId, newId) {
|
14967 | if (this._listeners[oldId]) {
|
14968 | this._listeners[newId] = this._listeners[oldId];
|
14969 | delete this._listeners[oldId];
|
14970 | }
|
14971 | }
|
14972 | }]);
|
14973 |
|
14974 | return ChangeSupport;
|
14975 | }();
|
14976 | ChangeSupport.$inject = ['eventBus'];
|
14977 |
|
14978 | function _classCallCheck$7(instance, Constructor) {
|
14979 | if (!(instance instanceof Constructor)) {
|
14980 | throw new TypeError("Cannot call a class as a function");
|
14981 | }
|
14982 | }
|
14983 |
|
14984 | function _defineProperties$6(target, props) {
|
14985 | for (var i = 0; i < props.length; i++) {
|
14986 | var descriptor = props[i];
|
14987 | descriptor.enumerable = descriptor.enumerable || false;
|
14988 | descriptor.configurable = true;
|
14989 | if ("value" in descriptor) descriptor.writable = true;
|
14990 | Object.defineProperty(target, descriptor.key, descriptor);
|
14991 | }
|
14992 | }
|
14993 |
|
14994 | function _createClass$6(Constructor, protoProps, staticProps) {
|
14995 | if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
|
14996 | if (staticProps) _defineProperties$6(Constructor, staticProps);
|
14997 | return Constructor;
|
14998 | }
|
14999 | var DEFAULT_PRIORITY$1 = 1000;
|
15000 |
|
15001 | var Components =
|
15002 |
|
15003 | function () {
|
15004 | function Components() {
|
15005 | _classCallCheck$7(this, Components);
|
15006 |
|
15007 | this._listeners = {};
|
15008 | }
|
15009 |
|
15010 | _createClass$6(Components, [{
|
15011 | key: "getComponent",
|
15012 | value: function getComponent(type, context) {
|
15013 | var listeners = this._listeners[type];
|
15014 |
|
15015 | if (!listeners) {
|
15016 | return;
|
15017 | }
|
15018 |
|
15019 | var component;
|
15020 |
|
15021 | for (var i = 0; i < listeners.length; i++) {
|
15022 | component = listeners[i].callback(context);
|
15023 |
|
15024 | if (component) {
|
15025 | break;
|
15026 | }
|
15027 | }
|
15028 |
|
15029 | return component;
|
15030 | }
|
15031 | }, {
|
15032 | key: "getComponents",
|
15033 | value: function getComponents(type, context) {
|
15034 | var listeners = this._listeners[type];
|
15035 | var components = [];
|
15036 |
|
15037 | if (!listeners) {
|
15038 | return components;
|
15039 | }
|
15040 |
|
15041 | for (var i = 0; i < listeners.length; i++) {
|
15042 | var component = listeners[i].callback(context);
|
15043 |
|
15044 | if (component) {
|
15045 | components.push(component);
|
15046 | }
|
15047 | }
|
15048 |
|
15049 | if (!components.length) {
|
15050 | return components;
|
15051 | }
|
15052 |
|
15053 | return components;
|
15054 | }
|
15055 | }, {
|
15056 | key: "onGetComponent",
|
15057 | value: function onGetComponent(type, priority, callback) {
|
15058 | if (isFunction$1(priority)) {
|
15059 | callback = priority;
|
15060 | priority = DEFAULT_PRIORITY$1;
|
15061 | }
|
15062 |
|
15063 | if (!isNumber$1(priority)) {
|
15064 | throw new Error('priority must be a number');
|
15065 | }
|
15066 |
|
15067 | var listeners = this._getListeners(type);
|
15068 |
|
15069 | var existingListener, idx;
|
15070 | var newListener = {
|
15071 | priority: priority,
|
15072 | callback: callback
|
15073 | };
|
15074 |
|
15075 | for (idx = 0; existingListener = listeners[idx]; idx++) {
|
15076 | if (existingListener.priority < priority) {
|
15077 |
|
15078 | listeners.splice(idx, 0, newListener);
|
15079 | return;
|
15080 | }
|
15081 | }
|
15082 |
|
15083 | listeners.push(newListener);
|
15084 | }
|
15085 | }, {
|
15086 | key: "offGetComponent",
|
15087 | value: function offGetComponent(type, callback) {
|
15088 | var listeners = this._getListeners(type);
|
15089 |
|
15090 | var listener, listenerCallback, idx;
|
15091 |
|
15092 | if (callback) {
|
15093 |
|
15094 |
|
15095 | for (idx = listeners.length - 1; listener = listeners[idx]; idx--) {
|
15096 | listenerCallback = listener.callback;
|
15097 |
|
15098 | if (listenerCallback === callback) {
|
15099 | listeners.splice(idx, 1);
|
15100 | }
|
15101 | }
|
15102 | } else {
|
15103 |
|
15104 | listeners.length = 0;
|
15105 | }
|
15106 | }
|
15107 | }, {
|
15108 | key: "_getListeners",
|
15109 | value: function _getListeners(type) {
|
15110 | var listeners = this._listeners[type];
|
15111 |
|
15112 | if (!listeners) {
|
15113 | this._listeners[type] = listeners = [];
|
15114 | }
|
15115 |
|
15116 | return listeners;
|
15117 | }
|
15118 | }]);
|
15119 |
|
15120 | return Components;
|
15121 | }();
|
15122 |
|
15123 | var NO_OP = '$NO_OP';
|
15124 | var ERROR_MSG = 'a runtime error occured! Use Inferno in development environment to find the error.';
|
15125 |
|
15126 |
|
15127 | var isArray$3 = Array.isArray;
|
15128 |
|
15129 | function isStringOrNumber(o) {
|
15130 | var type = _typeof(o);
|
15131 |
|
15132 | return type === 'string' || type === 'number';
|
15133 | }
|
15134 |
|
15135 | function isNullOrUndef(o) {
|
15136 | return isUndefined$2(o) || isNull(o);
|
15137 | }
|
15138 |
|
15139 | function isInvalid(o) {
|
15140 | return isNull(o) || o === false || isTrue(o) || isUndefined$2(o);
|
15141 | }
|
15142 |
|
15143 | function isFunction$2(o) {
|
15144 | return typeof o === 'function';
|
15145 | }
|
15146 |
|
15147 | function isString$1(o) {
|
15148 | return typeof o === 'string';
|
15149 | }
|
15150 |
|
15151 | function isNumber$2(o) {
|
15152 | return typeof o === 'number';
|
15153 | }
|
15154 |
|
15155 | function isNull(o) {
|
15156 | return o === null;
|
15157 | }
|
15158 |
|
15159 | function isTrue(o) {
|
15160 | return o === true;
|
15161 | }
|
15162 |
|
15163 | function isUndefined$2(o) {
|
15164 | return o === void 0;
|
15165 | }
|
15166 |
|
15167 | function isObject$1(o) {
|
15168 | return _typeof(o) === 'object';
|
15169 | }
|
15170 |
|
15171 | function throwError(message) {
|
15172 | if (!message) {
|
15173 | message = ERROR_MSG;
|
15174 | }
|
15175 |
|
15176 | throw new Error("Inferno Error: " + message);
|
15177 | }
|
15178 |
|
15179 | function combineFrom(first, second) {
|
15180 | var out = {};
|
15181 |
|
15182 | if (first) {
|
15183 | for (var key in first) {
|
15184 | out[key] = first[key];
|
15185 | }
|
15186 | }
|
15187 |
|
15188 | if (second) {
|
15189 | for (var key$1 in second) {
|
15190 | out[key$1] = second[key$1];
|
15191 | }
|
15192 | }
|
15193 |
|
15194 | return out;
|
15195 | }
|
15196 |
|
15197 | var keyPrefix = '$';
|
15198 |
|
15199 | function getVNode(childFlags, children, className, flags, key, props, ref, type) {
|
15200 | return {
|
15201 | childFlags: childFlags,
|
15202 | children: children,
|
15203 | className: className,
|
15204 | dom: null,
|
15205 | flags: flags,
|
15206 | key: key === void 0 ? null : key,
|
15207 | parentVNode: null,
|
15208 | props: props === void 0 ? null : props,
|
15209 | ref: ref === void 0 ? null : ref,
|
15210 | type: type
|
15211 | };
|
15212 | }
|
15213 |
|
15214 | function createVNode(flags, type, className, children, childFlags, props, key, ref) {
|
15215 | var childFlag = childFlags === void 0 ? 1
|
15216 |
|
15217 | : childFlags;
|
15218 | var vNode = getVNode(childFlag, children, className, flags, key, props, ref, type);
|
15219 |
|
15220 | if (childFlag === 0
|
15221 |
|
15222 | ) {
|
15223 | normalizeChildren(vNode, vNode.children);
|
15224 | }
|
15225 |
|
15226 | return vNode;
|
15227 | }
|
15228 |
|
15229 | function createComponentVNode(flags, type, props, key, ref) {
|
15230 | if ((flags & 2
|
15231 |
|
15232 | ) > 0) {
|
15233 | flags = type.prototype && isFunction$2(type.prototype.render) ? 4
|
15234 |
|
15235 | : 8
|
15236 |
|
15237 | ;
|
15238 | }
|
15239 |
|
15240 |
|
15241 | var defaultProps = type.defaultProps;
|
15242 |
|
15243 | if (!isNullOrUndef(defaultProps)) {
|
15244 | if (!props) {
|
15245 | props = {};
|
15246 | }
|
15247 |
|
15248 | for (var prop in defaultProps) {
|
15249 | if (isUndefined$2(props[prop])) {
|
15250 | props[prop] = defaultProps[prop];
|
15251 | }
|
15252 | }
|
15253 | }
|
15254 |
|
15255 | if ((flags & 8
|
15256 |
|
15257 | ) > 0) {
|
15258 | var defaultHooks = type.defaultHooks;
|
15259 |
|
15260 | if (!isNullOrUndef(defaultHooks)) {
|
15261 | if (!ref) {
|
15262 |
|
15263 | ref = defaultHooks;
|
15264 | } else {
|
15265 | for (var prop$1 in defaultHooks) {
|
15266 | if (isUndefined$2(ref[prop$1])) {
|
15267 | ref[prop$1] = defaultHooks[prop$1];
|
15268 | }
|
15269 | }
|
15270 | }
|
15271 | }
|
15272 | }
|
15273 |
|
15274 | var vNode = getVNode(1
|
15275 |
|
15276 | , null, null, flags, key, props, ref, type);
|
15277 | var optsVNode = options.createVNode;
|
15278 |
|
15279 | if (isFunction$2(optsVNode)) {
|
15280 | optsVNode(vNode);
|
15281 | }
|
15282 |
|
15283 | return vNode;
|
15284 | }
|
15285 |
|
15286 | function createTextVNode(text, key) {
|
15287 | return getVNode(1
|
15288 |
|
15289 | , isNullOrUndef(text) ? '' : text, null, 16
|
15290 |
|
15291 | , key, null, null, null);
|
15292 | }
|
15293 |
|
15294 | function normalizeProps(vNode) {
|
15295 | var props = vNode.props;
|
15296 |
|
15297 | if (props) {
|
15298 | var flags = vNode.flags;
|
15299 |
|
15300 | if (flags & 481
|
15301 |
|
15302 | ) {
|
15303 | if (props.children !== void 0 && isNullOrUndef(vNode.children)) {
|
15304 | normalizeChildren(vNode, props.children);
|
15305 | }
|
15306 |
|
15307 | if (props.className !== void 0) {
|
15308 | vNode.className = props.className || null;
|
15309 | props.className = undefined;
|
15310 | }
|
15311 | }
|
15312 |
|
15313 | if (props.key !== void 0) {
|
15314 | vNode.key = props.key;
|
15315 | props.key = undefined;
|
15316 | }
|
15317 |
|
15318 | if (props.ref !== void 0) {
|
15319 | if (flags & 8
|
15320 |
|
15321 | ) {
|
15322 | vNode.ref = combineFrom(vNode.ref, props.ref);
|
15323 | } else {
|
15324 | vNode.ref = props.ref;
|
15325 | }
|
15326 |
|
15327 | props.ref = undefined;
|
15328 | }
|
15329 | }
|
15330 |
|
15331 | return vNode;
|
15332 | }
|
15333 |
|
15334 | function directClone(vNodeToClone) {
|
15335 | var newVNode;
|
15336 | var flags = vNodeToClone.flags;
|
15337 |
|
15338 | if (flags & 14
|
15339 |
|
15340 | ) {
|
15341 | var props;
|
15342 | var propsToClone = vNodeToClone.props;
|
15343 |
|
15344 | if (!isNull(propsToClone)) {
|
15345 | props = {};
|
15346 |
|
15347 | for (var key in propsToClone) {
|
15348 | props[key] = propsToClone[key];
|
15349 | }
|
15350 | }
|
15351 |
|
15352 | newVNode = createComponentVNode(flags, vNodeToClone.type, props, vNodeToClone.key, vNodeToClone.ref);
|
15353 | } else if (flags & 481
|
15354 |
|
15355 | ) {
|
15356 | var children = vNodeToClone.children;
|
15357 | newVNode = createVNode(flags, vNodeToClone.type, vNodeToClone.className, children, vNodeToClone.childFlags, vNodeToClone.props, vNodeToClone.key, vNodeToClone.ref);
|
15358 | } else if (flags & 16
|
15359 |
|
15360 | ) {
|
15361 | newVNode = createTextVNode(vNodeToClone.children, vNodeToClone.key);
|
15362 | } else if (flags & 1024
|
15363 |
|
15364 | ) {
|
15365 | newVNode = vNodeToClone;
|
15366 | }
|
15367 |
|
15368 | return newVNode;
|
15369 | }
|
15370 |
|
15371 | function createVoidVNode() {
|
15372 | return createTextVNode('', null);
|
15373 | }
|
15374 |
|
15375 | function _normalizeVNodes(nodes, result, index, currentKey) {
|
15376 | for (var len = nodes.length; index < len; index++) {
|
15377 | var n = nodes[index];
|
15378 |
|
15379 | if (!isInvalid(n)) {
|
15380 | var newKey = currentKey + keyPrefix + index;
|
15381 |
|
15382 | if (isArray$3(n)) {
|
15383 | _normalizeVNodes(n, result, 0, newKey);
|
15384 | } else {
|
15385 | if (isStringOrNumber(n)) {
|
15386 | n = createTextVNode(n, newKey);
|
15387 | } else {
|
15388 | var oldKey = n.key;
|
15389 | var isPrefixedKey = isString$1(oldKey) && oldKey[0] === keyPrefix;
|
15390 |
|
15391 | if (!isNull(n.dom) || isPrefixedKey) {
|
15392 | n = directClone(n);
|
15393 | }
|
15394 |
|
15395 | if (isNull(oldKey) || isPrefixedKey) {
|
15396 | n.key = newKey;
|
15397 | } else {
|
15398 | n.key = currentKey + oldKey;
|
15399 | }
|
15400 | }
|
15401 |
|
15402 | result.push(n);
|
15403 | }
|
15404 | }
|
15405 | }
|
15406 | }
|
15407 |
|
15408 | function normalizeChildren(vNode, children) {
|
15409 | var newChildren;
|
15410 | var newChildFlags = 1
|
15411 |
|
15412 | ;
|
15413 |
|
15414 | if (isInvalid(children)) {
|
15415 | newChildren = children;
|
15416 | } else if (isString$1(children)) {
|
15417 | newChildFlags = 2
|
15418 |
|
15419 | ;
|
15420 | newChildren = createTextVNode(children);
|
15421 | } else if (isNumber$2(children)) {
|
15422 | newChildFlags = 2
|
15423 |
|
15424 | ;
|
15425 | newChildren = createTextVNode(children + '');
|
15426 | } else if (isArray$3(children)) {
|
15427 | var len = children.length;
|
15428 |
|
15429 | if (len === 0) {
|
15430 | newChildren = null;
|
15431 | newChildFlags = 1
|
15432 |
|
15433 | ;
|
15434 | } else {
|
15435 |
|
15436 |
|
15437 |
|
15438 |
|
15439 | if (Object.isFrozen(children) || children['$'] === true) {
|
15440 | children = children.slice();
|
15441 | }
|
15442 |
|
15443 | newChildFlags = 8
|
15444 |
|
15445 | ;
|
15446 |
|
15447 | for (var i = 0; i < len; i++) {
|
15448 | var n = children[i];
|
15449 |
|
15450 | if (isInvalid(n) || isArray$3(n)) {
|
15451 | newChildren = newChildren || children.slice(0, i);
|
15452 |
|
15453 | _normalizeVNodes(children, newChildren, i, '');
|
15454 |
|
15455 | break;
|
15456 | } else if (isStringOrNumber(n)) {
|
15457 | newChildren = newChildren || children.slice(0, i);
|
15458 | newChildren.push(createTextVNode(n, keyPrefix + i));
|
15459 | } else {
|
15460 | var key = n.key;
|
15461 | var isNullDom = isNull(n.dom);
|
15462 | var isNullKey = isNull(key);
|
15463 | var isPrefixed = !isNullKey && key[0] === keyPrefix;
|
15464 |
|
15465 | if (!isNullDom || isNullKey || isPrefixed) {
|
15466 | newChildren = newChildren || children.slice(0, i);
|
15467 |
|
15468 | if (!isNullDom || isPrefixed) {
|
15469 | n = directClone(n);
|
15470 | }
|
15471 |
|
15472 | if (isNullKey || isPrefixed) {
|
15473 | n.key = keyPrefix + i;
|
15474 | }
|
15475 |
|
15476 | newChildren.push(n);
|
15477 | } else if (newChildren) {
|
15478 | newChildren.push(n);
|
15479 | }
|
15480 | }
|
15481 | }
|
15482 |
|
15483 | newChildren = newChildren || children;
|
15484 | newChildren.$ = true;
|
15485 | }
|
15486 | } else {
|
15487 | newChildren = children;
|
15488 |
|
15489 | if (!isNull(children.dom)) {
|
15490 | newChildren = directClone(children);
|
15491 | }
|
15492 |
|
15493 | newChildFlags = 2
|
15494 |
|
15495 | ;
|
15496 | }
|
15497 |
|
15498 | vNode.children = newChildren;
|
15499 | vNode.childFlags = newChildFlags;
|
15500 | return vNode;
|
15501 | }
|
15502 |
|
15503 | var options = {
|
15504 | afterMount: null,
|
15505 | afterRender: null,
|
15506 | afterUpdate: null,
|
15507 | beforeRender: null,
|
15508 | beforeUnmount: null,
|
15509 | createVNode: null,
|
15510 | roots: []
|
15511 | };
|
15512 |
|
15513 | var xlinkNS = 'http://www.w3.org/1999/xlink';
|
15514 | var xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
15515 | var svgNS = 'http://www.w3.org/2000/svg';
|
15516 | var namespaces = {
|
15517 | 'xlink:actuate': xlinkNS,
|
15518 | 'xlink:arcrole': xlinkNS,
|
15519 | 'xlink:href': xlinkNS,
|
15520 | 'xlink:role': xlinkNS,
|
15521 | 'xlink:show': xlinkNS,
|
15522 | 'xlink:title': xlinkNS,
|
15523 | 'xlink:type': xlinkNS,
|
15524 | 'xml:base': xmlNS,
|
15525 | 'xml:lang': xmlNS,
|
15526 | 'xml:space': xmlNS
|
15527 | };
|
15528 |
|
15529 |
|
15530 | var EMPTY_OBJ = {};
|
15531 | var LIFECYCLE = [];
|
15532 |
|
15533 | function appendChild(parentDom, dom) {
|
15534 | parentDom.appendChild(dom);
|
15535 | }
|
15536 |
|
15537 | function insertOrAppend(parentDom, newNode, nextNode) {
|
15538 | if (isNullOrUndef(nextNode)) {
|
15539 | appendChild(parentDom, newNode);
|
15540 | } else {
|
15541 | parentDom.insertBefore(newNode, nextNode);
|
15542 | }
|
15543 | }
|
15544 |
|
15545 | function documentCreateElement(tag, isSVG) {
|
15546 | if (isSVG === true) {
|
15547 | return document.createElementNS(svgNS, tag);
|
15548 | }
|
15549 |
|
15550 | return document.createElement(tag);
|
15551 | }
|
15552 |
|
15553 | function replaceChild(parentDom, newDom, lastDom) {
|
15554 | parentDom.replaceChild(newDom, lastDom);
|
15555 | }
|
15556 |
|
15557 | function removeChild(parentDom, dom) {
|
15558 | parentDom.removeChild(dom);
|
15559 | }
|
15560 |
|
15561 | function callAll(arrayFn) {
|
15562 | var listener;
|
15563 |
|
15564 | while ((listener = arrayFn.shift()) !== undefined) {
|
15565 | listener();
|
15566 | }
|
15567 | }
|
15568 |
|
15569 | var attachedEventCounts = {};
|
15570 | var attachedEvents = {};
|
15571 |
|
15572 | function handleEvent(name, nextEvent, dom) {
|
15573 | var eventsLeft = attachedEventCounts[name];
|
15574 | var eventsObject = dom.$EV;
|
15575 |
|
15576 | if (nextEvent) {
|
15577 | if (!eventsLeft) {
|
15578 | attachedEvents[name] = attachEventToDocument(name);
|
15579 | attachedEventCounts[name] = 0;
|
15580 | }
|
15581 |
|
15582 | if (!eventsObject) {
|
15583 | eventsObject = dom.$EV = {};
|
15584 | }
|
15585 |
|
15586 | if (!eventsObject[name]) {
|
15587 | attachedEventCounts[name]++;
|
15588 | }
|
15589 |
|
15590 | eventsObject[name] = nextEvent;
|
15591 | } else if (eventsObject && eventsObject[name]) {
|
15592 | attachedEventCounts[name]--;
|
15593 |
|
15594 | if (eventsLeft === 1) {
|
15595 | document.removeEventListener(normalizeEventName(name), attachedEvents[name]);
|
15596 | attachedEvents[name] = null;
|
15597 | }
|
15598 |
|
15599 | eventsObject[name] = nextEvent;
|
15600 | }
|
15601 | }
|
15602 |
|
15603 | function dispatchEvents(event, target, isClick, name, eventData) {
|
15604 | var dom = target;
|
15605 |
|
15606 | while (!isNull(dom)) {
|
15607 |
|
15608 |
|
15609 |
|
15610 | if (isClick && dom.disabled) {
|
15611 | return;
|
15612 | }
|
15613 |
|
15614 | var eventsObject = dom.$EV;
|
15615 |
|
15616 | if (eventsObject) {
|
15617 | var currentEvent = eventsObject[name];
|
15618 |
|
15619 | if (currentEvent) {
|
15620 |
|
15621 | eventData.dom = dom;
|
15622 |
|
15623 | if (currentEvent.event) {
|
15624 | currentEvent.event(currentEvent.data, event);
|
15625 | } else {
|
15626 | currentEvent(event);
|
15627 | }
|
15628 |
|
15629 | if (event.cancelBubble) {
|
15630 | return;
|
15631 | }
|
15632 | }
|
15633 | }
|
15634 |
|
15635 | dom = dom.parentNode;
|
15636 | }
|
15637 | }
|
15638 |
|
15639 | function normalizeEventName(name) {
|
15640 | return name.substr(2).toLowerCase();
|
15641 | }
|
15642 |
|
15643 | function stopPropagation() {
|
15644 | this.cancelBubble = true;
|
15645 |
|
15646 | if (!this.immediatePropagationStopped) {
|
15647 | this.stopImmediatePropagation();
|
15648 | }
|
15649 | }
|
15650 |
|
15651 | function attachEventToDocument(name) {
|
15652 | var docEvent = function docEvent(event) {
|
15653 | var type = event.type;
|
15654 | var isClick = type === 'click' || type === 'dblclick';
|
15655 |
|
15656 | if (isClick && event.button !== 0) {
|
15657 |
|
15658 |
|
15659 |
|
15660 | event.preventDefault();
|
15661 | event.stopPropagation();
|
15662 | return false;
|
15663 | }
|
15664 |
|
15665 | event.stopPropagation = stopPropagation;
|
15666 |
|
15667 | var eventData = {
|
15668 | dom: document
|
15669 | };
|
15670 | Object.defineProperty(event, 'currentTarget', {
|
15671 | configurable: true,
|
15672 | get: function get() {
|
15673 | return eventData.dom;
|
15674 | }
|
15675 | });
|
15676 | dispatchEvents(event, event.target, isClick, name, eventData);
|
15677 | return;
|
15678 | };
|
15679 |
|
15680 | document.addEventListener(normalizeEventName(name), docEvent);
|
15681 | return docEvent;
|
15682 | }
|
15683 |
|
15684 | function isSameInnerHTML(dom, innerHTML) {
|
15685 | var tempdom = document.createElement('i');
|
15686 | tempdom.innerHTML = innerHTML;
|
15687 | return tempdom.innerHTML === dom.innerHTML;
|
15688 | }
|
15689 |
|
15690 | function isSamePropsInnerHTML(dom, props) {
|
15691 | return Boolean(props && props.dangerouslySetInnerHTML && props.dangerouslySetInnerHTML.__html && isSameInnerHTML(dom, props.dangerouslySetInnerHTML.__html));
|
15692 | }
|
15693 |
|
15694 | function triggerEventListener(props, methodName, e) {
|
15695 | if (props[methodName]) {
|
15696 | var listener = props[methodName];
|
15697 |
|
15698 | if (listener.event) {
|
15699 | listener.event(listener.data, e);
|
15700 | } else {
|
15701 | listener(e);
|
15702 | }
|
15703 | } else {
|
15704 | var nativeListenerName = methodName.toLowerCase();
|
15705 |
|
15706 | if (props[nativeListenerName]) {
|
15707 | props[nativeListenerName](e);
|
15708 | }
|
15709 | }
|
15710 | }
|
15711 |
|
15712 | function createWrappedFunction(methodName, applyValue) {
|
15713 | var fnMethod = function fnMethod(e) {
|
15714 | e.stopPropagation();
|
15715 | var vNode = this.$V;
|
15716 |
|
15717 | if (!vNode) {
|
15718 | return;
|
15719 | }
|
15720 |
|
15721 | var props = vNode.props || EMPTY_OBJ;
|
15722 | var dom = vNode.dom;
|
15723 |
|
15724 | if (isString$1(methodName)) {
|
15725 | triggerEventListener(props, methodName, e);
|
15726 | } else {
|
15727 | for (var i = 0; i < methodName.length; i++) {
|
15728 | triggerEventListener(props, methodName[i], e);
|
15729 | }
|
15730 | }
|
15731 |
|
15732 | if (isFunction$2(applyValue)) {
|
15733 | var newVNode = this.$V;
|
15734 | var newProps = newVNode.props || EMPTY_OBJ;
|
15735 | applyValue(newProps, dom, false, newVNode);
|
15736 | }
|
15737 | };
|
15738 |
|
15739 | Object.defineProperty(fnMethod, 'wrapped', {
|
15740 | configurable: false,
|
15741 | enumerable: false,
|
15742 | value: true,
|
15743 | writable: false
|
15744 | });
|
15745 | return fnMethod;
|
15746 | }
|
15747 |
|
15748 | function isCheckedType(type) {
|
15749 | return type === 'checkbox' || type === 'radio';
|
15750 | }
|
15751 |
|
15752 | var onTextInputChange = createWrappedFunction('onInput', applyValueInput);
|
15753 | var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput);
|
15754 |
|
15755 |
|
15756 | function emptywrapper(event) {
|
15757 | event.stopPropagation();
|
15758 | }
|
15759 |
|
15760 | emptywrapper.wrapped = true;
|
15761 |
|
15762 | function inputEvents(dom, nextPropsOrEmpty) {
|
15763 | if (isCheckedType(nextPropsOrEmpty.type)) {
|
15764 | dom.onchange = wrappedOnChange;
|
15765 | dom.onclick = emptywrapper;
|
15766 | } else {
|
15767 | dom.oninput = onTextInputChange;
|
15768 | }
|
15769 | }
|
15770 |
|
15771 | function applyValueInput(nextPropsOrEmpty, dom) {
|
15772 | var type = nextPropsOrEmpty.type;
|
15773 | var value = nextPropsOrEmpty.value;
|
15774 | var checked = nextPropsOrEmpty.checked;
|
15775 | var multiple = nextPropsOrEmpty.multiple;
|
15776 | var defaultValue = nextPropsOrEmpty.defaultValue;
|
15777 | var hasValue = !isNullOrUndef(value);
|
15778 |
|
15779 | if (type && type !== dom.type) {
|
15780 | dom.setAttribute('type', type);
|
15781 | }
|
15782 |
|
15783 | if (!isNullOrUndef(multiple) && multiple !== dom.multiple) {
|
15784 | dom.multiple = multiple;
|
15785 | }
|
15786 |
|
15787 | if (!isNullOrUndef(defaultValue) && !hasValue) {
|
15788 | dom.defaultValue = defaultValue + '';
|
15789 | }
|
15790 |
|
15791 | if (isCheckedType(type)) {
|
15792 | if (hasValue) {
|
15793 | dom.value = value;
|
15794 | }
|
15795 |
|
15796 | if (!isNullOrUndef(checked)) {
|
15797 | dom.checked = checked;
|
15798 | }
|
15799 | } else {
|
15800 | if (hasValue && dom.value !== value) {
|
15801 | dom.defaultValue = value;
|
15802 | dom.value = value;
|
15803 | } else if (!isNullOrUndef(checked)) {
|
15804 | dom.checked = checked;
|
15805 | }
|
15806 | }
|
15807 | }
|
15808 |
|
15809 | function updateChildOptionGroup(vNode, value) {
|
15810 | var type = vNode.type;
|
15811 |
|
15812 | if (type === 'optgroup') {
|
15813 | var children = vNode.children;
|
15814 | var childFlags = vNode.childFlags;
|
15815 |
|
15816 | if (childFlags & 12
|
15817 |
|
15818 | ) {
|
15819 | for (var i = 0, len = children.length; i < len; i++) {
|
15820 | updateChildOption(children[i], value);
|
15821 | }
|
15822 | } else if (childFlags === 2
|
15823 |
|
15824 | ) {
|
15825 | updateChildOption(children, value);
|
15826 | }
|
15827 | } else {
|
15828 | updateChildOption(vNode, value);
|
15829 | }
|
15830 | }
|
15831 |
|
15832 | function updateChildOption(vNode, value) {
|
15833 | var props = vNode.props || EMPTY_OBJ;
|
15834 | var dom = vNode.dom;
|
15835 |
|
15836 | dom.value = props.value;
|
15837 |
|
15838 | if (isArray$3(value) && value.indexOf(props.value) !== -1 || props.value === value) {
|
15839 | dom.selected = true;
|
15840 | } else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) {
|
15841 | dom.selected = props.selected || false;
|
15842 | }
|
15843 | }
|
15844 |
|
15845 | var onSelectChange = createWrappedFunction('onChange', applyValueSelect);
|
15846 |
|
15847 | function selectEvents(dom) {
|
15848 | dom.onchange = onSelectChange;
|
15849 | }
|
15850 |
|
15851 | function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) {
|
15852 | var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple);
|
15853 |
|
15854 | if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) {
|
15855 | dom.multiple = multiplePropInBoolean;
|
15856 | }
|
15857 |
|
15858 | var childFlags = vNode.childFlags;
|
15859 |
|
15860 | if ((childFlags & 1
|
15861 |
|
15862 | ) === 0) {
|
15863 | var children = vNode.children;
|
15864 | var value = nextPropsOrEmpty.value;
|
15865 |
|
15866 | if (mounting && isNullOrUndef(value)) {
|
15867 | value = nextPropsOrEmpty.defaultValue;
|
15868 | }
|
15869 |
|
15870 | if (childFlags & 12
|
15871 |
|
15872 | ) {
|
15873 | for (var i = 0, len = children.length; i < len; i++) {
|
15874 | updateChildOptionGroup(children[i], value);
|
15875 | }
|
15876 | } else if (childFlags === 2
|
15877 |
|
15878 | ) {
|
15879 | updateChildOptionGroup(children, value);
|
15880 | }
|
15881 | }
|
15882 | }
|
15883 |
|
15884 | var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea);
|
15885 | var wrappedOnChange$1 = createWrappedFunction('onChange');
|
15886 |
|
15887 | function textAreaEvents(dom, nextPropsOrEmpty) {
|
15888 | dom.oninput = onTextareaInputChange;
|
15889 |
|
15890 | if (nextPropsOrEmpty.onChange) {
|
15891 | dom.onchange = wrappedOnChange$1;
|
15892 | }
|
15893 | }
|
15894 |
|
15895 | function applyValueTextArea(nextPropsOrEmpty, dom, mounting) {
|
15896 | var value = nextPropsOrEmpty.value;
|
15897 | var domValue = dom.value;
|
15898 |
|
15899 | if (isNullOrUndef(value)) {
|
15900 | if (mounting) {
|
15901 | var defaultValue = nextPropsOrEmpty.defaultValue;
|
15902 |
|
15903 | if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) {
|
15904 | dom.defaultValue = defaultValue;
|
15905 | dom.value = defaultValue;
|
15906 | }
|
15907 | }
|
15908 | } else if (domValue !== value) {
|
15909 |
|
15910 | dom.defaultValue = value;
|
15911 | dom.value = value;
|
15912 | }
|
15913 | }
|
15914 | |
15915 |
|
15916 |
|
15917 |
|
15918 |
|
15919 |
|
15920 |
|
15921 | function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) {
|
15922 | if (flags & 64
|
15923 |
|
15924 | ) {
|
15925 | applyValueInput(nextPropsOrEmpty, dom);
|
15926 | } else if (flags & 256
|
15927 |
|
15928 | ) {
|
15929 | applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode);
|
15930 | } else if (flags & 128
|
15931 |
|
15932 | ) {
|
15933 | applyValueTextArea(nextPropsOrEmpty, dom, mounting);
|
15934 | }
|
15935 |
|
15936 | if (isControlled) {
|
15937 | dom.$V = vNode;
|
15938 | }
|
15939 | }
|
15940 |
|
15941 | function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) {
|
15942 | if (flags & 64
|
15943 |
|
15944 | ) {
|
15945 | inputEvents(dom, nextPropsOrEmpty);
|
15946 | } else if (flags & 256
|
15947 |
|
15948 | ) {
|
15949 | selectEvents(dom);
|
15950 | } else if (flags & 128
|
15951 |
|
15952 | ) {
|
15953 | textAreaEvents(dom, nextPropsOrEmpty);
|
15954 | }
|
15955 | }
|
15956 |
|
15957 | function isControlledFormElement(nextPropsOrEmpty) {
|
15958 | return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value);
|
15959 | }
|
15960 |
|
15961 | function remove$3(vNode, parentDom) {
|
15962 | unmount(vNode);
|
15963 |
|
15964 | if (!isNull(parentDom)) {
|
15965 | removeChild(parentDom, vNode.dom);
|
15966 |
|
15967 | vNode.dom = null;
|
15968 | }
|
15969 | }
|
15970 |
|
15971 | function unmount(vNode) {
|
15972 | var flags = vNode.flags;
|
15973 |
|
15974 | if (flags & 481
|
15975 |
|
15976 | ) {
|
15977 | var ref = vNode.ref;
|
15978 | var props = vNode.props;
|
15979 |
|
15980 | if (isFunction$2(ref)) {
|
15981 | ref(null);
|
15982 | }
|
15983 |
|
15984 | var children = vNode.children;
|
15985 | var childFlags = vNode.childFlags;
|
15986 |
|
15987 | if (childFlags & 12
|
15988 |
|
15989 | ) {
|
15990 | unmountAllChildren(children);
|
15991 | } else if (childFlags === 2
|
15992 |
|
15993 | ) {
|
15994 | unmount(children);
|
15995 | }
|
15996 |
|
15997 | if (!isNull(props)) {
|
15998 | for (var name in props) {
|
15999 | switch (name) {
|
16000 | case 'onClick':
|
16001 | case 'onDblClick':
|
16002 | case 'onFocusIn':
|
16003 | case 'onFocusOut':
|
16004 | case 'onKeyDown':
|
16005 | case 'onKeyPress':
|
16006 | case 'onKeyUp':
|
16007 | case 'onMouseDown':
|
16008 | case 'onMouseMove':
|
16009 | case 'onMouseUp':
|
16010 | case 'onSubmit':
|
16011 | case 'onTouchEnd':
|
16012 | case 'onTouchMove':
|
16013 | case 'onTouchStart':
|
16014 | handleEvent(name, null, vNode.dom);
|
16015 | break;
|
16016 | }
|
16017 | }
|
16018 | }
|
16019 | } else if (flags & 14
|
16020 |
|
16021 | ) {
|
16022 | var instance = vNode.children;
|
16023 | var ref$1 = vNode.ref;
|
16024 |
|
16025 | if (flags & 4
|
16026 |
|
16027 | ) {
|
16028 | if (isFunction$2(options.beforeUnmount)) {
|
16029 | options.beforeUnmount(vNode);
|
16030 | }
|
16031 |
|
16032 | if (isFunction$2(instance.componentWillUnmount)) {
|
16033 | instance.componentWillUnmount();
|
16034 | }
|
16035 |
|
16036 | if (isFunction$2(ref$1)) {
|
16037 | ref$1(null);
|
16038 | }
|
16039 |
|
16040 | instance.$UN = true;
|
16041 | unmount(instance.$LI);
|
16042 | } else {
|
16043 | if (!isNullOrUndef(ref$1) && isFunction$2(ref$1.onComponentWillUnmount)) {
|
16044 | ref$1.onComponentWillUnmount(vNode.dom, vNode.props || EMPTY_OBJ);
|
16045 | }
|
16046 |
|
16047 | unmount(instance);
|
16048 | }
|
16049 | } else if (flags & 1024
|
16050 |
|
16051 | ) {
|
16052 | var children$1 = vNode.children;
|
16053 |
|
16054 | if (!isNull(children$1) && isObject$1(children$1)) {
|
16055 | remove$3(children$1, vNode.type);
|
16056 | }
|
16057 | }
|
16058 | }
|
16059 |
|
16060 | function unmountAllChildren(children) {
|
16061 | for (var i = 0, len = children.length; i < len; i++) {
|
16062 | unmount(children[i]);
|
16063 | }
|
16064 | }
|
16065 |
|
16066 | function removeAllChildren(dom, children) {
|
16067 | unmountAllChildren(children);
|
16068 | dom.textContent = '';
|
16069 | }
|
16070 |
|
16071 | function createLinkEvent(linkEvent, nextValue) {
|
16072 | return function (e) {
|
16073 | linkEvent(nextValue.data, e);
|
16074 | };
|
16075 | }
|
16076 |
|
16077 | function patchEvent(name, lastValue, nextValue, dom) {
|
16078 | var nameLowerCase = name.toLowerCase();
|
16079 |
|
16080 | if (!isFunction$2(nextValue) && !isNullOrUndef(nextValue)) {
|
16081 | var linkEvent = nextValue.event;
|
16082 |
|
16083 | if (linkEvent && isFunction$2(linkEvent)) {
|
16084 | dom[nameLowerCase] = createLinkEvent(linkEvent, nextValue);
|
16085 | }
|
16086 | } else {
|
16087 | var domEvent = dom[nameLowerCase];
|
16088 |
|
16089 | if (!domEvent || !domEvent.wrapped) {
|
16090 | dom[nameLowerCase] = nextValue;
|
16091 | }
|
16092 | }
|
16093 | }
|
16094 |
|
16095 | function getNumberStyleValue(style, value) {
|
16096 | switch (style) {
|
16097 | case 'animationIterationCount':
|
16098 | case 'borderImageOutset':
|
16099 | case 'borderImageSlice':
|
16100 | case 'borderImageWidth':
|
16101 | case 'boxFlex':
|
16102 | case 'boxFlexGroup':
|
16103 | case 'boxOrdinalGroup':
|
16104 | case 'columnCount':
|
16105 | case 'fillOpacity':
|
16106 | case 'flex':
|
16107 | case 'flexGrow':
|
16108 | case 'flexNegative':
|
16109 | case 'flexOrder':
|
16110 | case 'flexPositive':
|
16111 | case 'flexShrink':
|
16112 | case 'floodOpacity':
|
16113 | case 'fontWeight':
|
16114 | case 'gridColumn':
|
16115 | case 'gridRow':
|
16116 | case 'lineClamp':
|
16117 | case 'lineHeight':
|
16118 | case 'opacity':
|
16119 | case 'order':
|
16120 | case 'orphans':
|
16121 | case 'stopOpacity':
|
16122 | case 'strokeDasharray':
|
16123 | case 'strokeDashoffset':
|
16124 | case 'strokeMiterlimit':
|
16125 | case 'strokeOpacity':
|
16126 | case 'strokeWidth':
|
16127 | case 'tabSize':
|
16128 | case 'widows':
|
16129 | case 'zIndex':
|
16130 | case 'zoom':
|
16131 | return value;
|
16132 |
|
16133 | default:
|
16134 | return value + 'px';
|
16135 | }
|
16136 | }
|
16137 |
|
16138 |
|
16139 |
|
16140 | function patchStyle(lastAttrValue, nextAttrValue, dom) {
|
16141 | var domStyle = dom.style;
|
16142 | var style;
|
16143 | var value;
|
16144 |
|
16145 | if (isString$1(nextAttrValue)) {
|
16146 | domStyle.cssText = nextAttrValue;
|
16147 | return;
|
16148 | }
|
16149 |
|
16150 | if (!isNullOrUndef(lastAttrValue) && !isString$1(lastAttrValue)) {
|
16151 | for (style in nextAttrValue) {
|
16152 |
|
16153 | value = nextAttrValue[style];
|
16154 |
|
16155 | if (value !== lastAttrValue[style]) {
|
16156 | domStyle[style] = isNumber$2(value) ? getNumberStyleValue(style, value) : value;
|
16157 | }
|
16158 | }
|
16159 |
|
16160 | for (style in lastAttrValue) {
|
16161 | if (isNullOrUndef(nextAttrValue[style])) {
|
16162 | domStyle[style] = '';
|
16163 | }
|
16164 | }
|
16165 | } else {
|
16166 | for (style in nextAttrValue) {
|
16167 | value = nextAttrValue[style];
|
16168 | domStyle[style] = isNumber$2(value) ? getNumberStyleValue(style, value) : value;
|
16169 | }
|
16170 | }
|
16171 | }
|
16172 |
|
16173 | function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) {
|
16174 | switch (prop) {
|
16175 | case 'onClick':
|
16176 | case 'onDblClick':
|
16177 | case 'onFocusIn':
|
16178 | case 'onFocusOut':
|
16179 | case 'onKeyDown':
|
16180 | case 'onKeyPress':
|
16181 | case 'onKeyUp':
|
16182 | case 'onMouseDown':
|
16183 | case 'onMouseMove':
|
16184 | case 'onMouseUp':
|
16185 | case 'onSubmit':
|
16186 | case 'onTouchEnd':
|
16187 | case 'onTouchMove':
|
16188 | case 'onTouchStart':
|
16189 | handleEvent(prop, nextValue, dom);
|
16190 | break;
|
16191 |
|
16192 | case 'children':
|
16193 | case 'childrenType':
|
16194 | case 'className':
|
16195 | case 'defaultValue':
|
16196 | case 'key':
|
16197 | case 'multiple':
|
16198 | case 'ref':
|
16199 | return;
|
16200 |
|
16201 | case 'allowfullscreen':
|
16202 | case 'autoFocus':
|
16203 | case 'autoplay':
|
16204 | case 'capture':
|
16205 | case 'checked':
|
16206 | case 'controls':
|
16207 | case 'default':
|
16208 | case 'disabled':
|
16209 | case 'hidden':
|
16210 | case 'indeterminate':
|
16211 | case 'loop':
|
16212 | case 'muted':
|
16213 | case 'novalidate':
|
16214 | case 'open':
|
16215 | case 'readOnly':
|
16216 | case 'required':
|
16217 | case 'reversed':
|
16218 | case 'scoped':
|
16219 | case 'seamless':
|
16220 | case 'selected':
|
16221 | prop = prop === 'autoFocus' ? prop.toLowerCase() : prop;
|
16222 | dom[prop] = !!nextValue;
|
16223 | break;
|
16224 |
|
16225 | case 'defaultChecked':
|
16226 | case 'value':
|
16227 | case 'volume':
|
16228 | if (hasControlledValue && prop === 'value') {
|
16229 | return;
|
16230 | }
|
16231 |
|
16232 | var value = isNullOrUndef(nextValue) ? '' : nextValue;
|
16233 |
|
16234 | if (dom[prop] !== value) {
|
16235 | dom[prop] = value;
|
16236 | }
|
16237 |
|
16238 | break;
|
16239 |
|
16240 | case 'dangerouslySetInnerHTML':
|
16241 | var lastHtml = lastValue && lastValue.__html || '';
|
16242 | var nextHtml = nextValue && nextValue.__html || '';
|
16243 |
|
16244 | if (lastHtml !== nextHtml) {
|
16245 | if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) {
|
16246 | if (!isNull(lastVNode)) {
|
16247 | if (lastVNode.childFlags & 12
|
16248 |
|
16249 | ) {
|
16250 | unmountAllChildren(lastVNode.children);
|
16251 | } else if (lastVNode.childFlags === 2
|
16252 |
|
16253 | ) {
|
16254 | unmount(lastVNode.children);
|
16255 | }
|
16256 |
|
16257 | lastVNode.children = null;
|
16258 | lastVNode.childFlags = 1
|
16259 |
|
16260 | ;
|
16261 | }
|
16262 |
|
16263 | dom.innerHTML = nextHtml;
|
16264 | }
|
16265 | }
|
16266 |
|
16267 | break;
|
16268 |
|
16269 | default:
|
16270 | if (prop[0] === 'o' && prop[1] === 'n') {
|
16271 | patchEvent(prop, lastValue, nextValue, dom);
|
16272 | } else if (isNullOrUndef(nextValue)) {
|
16273 | dom.removeAttribute(prop);
|
16274 | } else if (prop === 'style') {
|
16275 | patchStyle(lastValue, nextValue, dom);
|
16276 | } else if (isSVG && namespaces[prop]) {
|
16277 |
|
16278 |
|
16279 | dom.setAttributeNS(namespaces[prop], prop, nextValue);
|
16280 | } else {
|
16281 | dom.setAttribute(prop, nextValue);
|
16282 | }
|
16283 |
|
16284 | break;
|
16285 | }
|
16286 | }
|
16287 |
|
16288 | function mountProps(vNode, flags, props, dom, isSVG) {
|
16289 | var hasControlledValue = false;
|
16290 | var isFormElement = (flags & 448
|
16291 |
|
16292 | ) > 0;
|
16293 |
|
16294 | if (isFormElement) {
|
16295 | hasControlledValue = isControlledFormElement(props);
|
16296 |
|
16297 | if (hasControlledValue) {
|
16298 | addFormElementEventHandlers(flags, dom, props);
|
16299 | }
|
16300 | }
|
16301 |
|
16302 | for (var prop in props) {
|
16303 |
|
16304 | patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null);
|
16305 | }
|
16306 |
|
16307 | if (isFormElement) {
|
16308 | processElement(flags, vNode, dom, props, true, hasControlledValue);
|
16309 | }
|
16310 | }
|
16311 |
|
16312 | function createClassComponentInstance(vNode, Component, props, context) {
|
16313 | var instance = new Component(props, context);
|
16314 | vNode.children = instance;
|
16315 | instance.$V = vNode;
|
16316 | instance.$BS = false;
|
16317 | instance.context = context;
|
16318 |
|
16319 | if (instance.props === EMPTY_OBJ) {
|
16320 | instance.props = props;
|
16321 | }
|
16322 |
|
16323 | instance.$UN = false;
|
16324 |
|
16325 | if (isFunction$2(instance.componentWillMount)) {
|
16326 | instance.$BR = true;
|
16327 | instance.componentWillMount();
|
16328 |
|
16329 | if (instance.$PSS) {
|
16330 | var state = instance.state;
|
16331 | var pending = instance.$PS;
|
16332 |
|
16333 | if (isNull(state)) {
|
16334 | instance.state = pending;
|
16335 | } else {
|
16336 | for (var key in pending) {
|
16337 | state[key] = pending[key];
|
16338 | }
|
16339 | }
|
16340 |
|
16341 | instance.$PSS = false;
|
16342 | instance.$PS = null;
|
16343 | }
|
16344 |
|
16345 | instance.$BR = false;
|
16346 | }
|
16347 |
|
16348 | if (isFunction$2(options.beforeRender)) {
|
16349 | options.beforeRender(instance);
|
16350 | }
|
16351 |
|
16352 | var input = handleComponentInput(instance.render(props, instance.state, context), vNode);
|
16353 | var childContext;
|
16354 |
|
16355 | if (isFunction$2(instance.getChildContext)) {
|
16356 | childContext = instance.getChildContext();
|
16357 | }
|
16358 |
|
16359 | if (isNullOrUndef(childContext)) {
|
16360 | instance.$CX = context;
|
16361 | } else {
|
16362 | instance.$CX = combineFrom(context, childContext);
|
16363 | }
|
16364 |
|
16365 | if (isFunction$2(options.afterRender)) {
|
16366 | options.afterRender(instance);
|
16367 | }
|
16368 |
|
16369 | instance.$LI = input;
|
16370 | return instance;
|
16371 | }
|
16372 |
|
16373 | function handleComponentInput(input, componentVNode) {
|
16374 | if (isInvalid(input)) {
|
16375 | input = createVoidVNode();
|
16376 | } else if (isStringOrNumber(input)) {
|
16377 | input = createTextVNode(input, null);
|
16378 | } else {
|
16379 | if (input.dom) {
|
16380 | input = directClone(input);
|
16381 | }
|
16382 |
|
16383 | if (input.flags & 14
|
16384 |
|
16385 | ) {
|
16386 |
|
16387 |
|
16388 |
|
16389 | input.parentVNode = componentVNode;
|
16390 | }
|
16391 | }
|
16392 |
|
16393 | return input;
|
16394 | }
|
16395 |
|
16396 | function mount(vNode, parentDom, lifecycle, context, isSVG) {
|
16397 | var flags = vNode.flags;
|
16398 |
|
16399 | if (flags & 481
|
16400 |
|
16401 | ) {
|
16402 | return mountElement(vNode, parentDom, lifecycle, context, isSVG);
|
16403 | }
|
16404 |
|
16405 | if (flags & 14
|
16406 |
|
16407 | ) {
|
16408 | return mountComponent(vNode, parentDom, lifecycle, context, isSVG, (flags & 4
|
16409 |
|
16410 | ) > 0);
|
16411 | }
|
16412 |
|
16413 | if (flags & 512
|
16414 |
|
16415 | || flags & 16
|
16416 |
|
16417 | ) {
|
16418 | return mountText(vNode, parentDom);
|
16419 | }
|
16420 |
|
16421 | if (flags & 1024
|
16422 |
|
16423 | ) {
|
16424 | mount(vNode.children, vNode.type, lifecycle, context, false);
|
16425 | return vNode.dom = mountText(createVoidVNode(), parentDom);
|
16426 | }
|
16427 | }
|
16428 |
|
16429 | function mountText(vNode, parentDom) {
|
16430 | var dom = vNode.dom = document.createTextNode(vNode.children);
|
16431 |
|
16432 | if (!isNull(parentDom)) {
|
16433 | appendChild(parentDom, dom);
|
16434 | }
|
16435 |
|
16436 | return dom;
|
16437 | }
|
16438 |
|
16439 | function mountElement(vNode, parentDom, lifecycle, context, isSVG) {
|
16440 | var flags = vNode.flags;
|
16441 | var children = vNode.children;
|
16442 | var props = vNode.props;
|
16443 | var className = vNode.className;
|
16444 | var ref = vNode.ref;
|
16445 | var childFlags = vNode.childFlags;
|
16446 | isSVG = isSVG || (flags & 32
|
16447 |
|
16448 | ) > 0;
|
16449 | var dom = documentCreateElement(vNode.type, isSVG);
|
16450 | vNode.dom = dom;
|
16451 |
|
16452 | if (!isNullOrUndef(className) && className !== '') {
|
16453 | if (isSVG) {
|
16454 | dom.setAttribute('class', className);
|
16455 | } else {
|
16456 | dom.className = className;
|
16457 | }
|
16458 | }
|
16459 |
|
16460 | if (!isNull(parentDom)) {
|
16461 | appendChild(parentDom, dom);
|
16462 | }
|
16463 |
|
16464 | if ((childFlags & 1
|
16465 |
|
16466 | ) === 0) {
|
16467 | var childrenIsSVG = isSVG === true && vNode.type !== 'foreignObject';
|
16468 |
|
16469 | if (childFlags === 2
|
16470 |
|
16471 | ) {
|
16472 | mount(children, dom, lifecycle, context, childrenIsSVG);
|
16473 | } else if (childFlags & 12
|
16474 |
|
16475 | ) {
|
16476 | mountArrayChildren(children, dom, lifecycle, context, childrenIsSVG);
|
16477 | }
|
16478 | }
|
16479 |
|
16480 | if (!isNull(props)) {
|
16481 | mountProps(vNode, flags, props, dom, isSVG);
|
16482 | }
|
16483 |
|
16484 | if (isFunction$2(ref)) {
|
16485 | mountRef(dom, ref, lifecycle);
|
16486 | }
|
16487 |
|
16488 | return dom;
|
16489 | }
|
16490 |
|
16491 | function mountArrayChildren(children, dom, lifecycle, context, isSVG) {
|
16492 | for (var i = 0, len = children.length; i < len; i++) {
|
16493 | var child = children[i];
|
16494 |
|
16495 | if (!isNull(child.dom)) {
|
16496 | children[i] = child = directClone(child);
|
16497 | }
|
16498 |
|
16499 | mount(child, dom, lifecycle, context, isSVG);
|
16500 | }
|
16501 | }
|
16502 |
|
16503 | function mountComponent(vNode, parentDom, lifecycle, context, isSVG, isClass) {
|
16504 | var dom;
|
16505 | var type = vNode.type;
|
16506 | var props = vNode.props || EMPTY_OBJ;
|
16507 | var ref = vNode.ref;
|
16508 |
|
16509 | if (isClass) {
|
16510 | var instance = createClassComponentInstance(vNode, type, props, context);
|
16511 | vNode.dom = dom = mount(instance.$LI, null, lifecycle, instance.$CX, isSVG);
|
16512 | mountClassComponentCallbacks(vNode, ref, instance, lifecycle);
|
16513 | instance.$UPD = false;
|
16514 | } else {
|
16515 | var input = handleComponentInput(type(props, context), vNode);
|
16516 | vNode.children = input;
|
16517 | vNode.dom = dom = mount(input, null, lifecycle, context, isSVG);
|
16518 | mountFunctionalComponentCallbacks(props, ref, dom, lifecycle);
|
16519 | }
|
16520 |
|
16521 | if (!isNull(parentDom)) {
|
16522 | appendChild(parentDom, dom);
|
16523 | }
|
16524 |
|
16525 | return dom;
|
16526 | }
|
16527 |
|
16528 | function createClassMountCallback(instance, hasAfterMount, afterMount, vNode, hasDidMount) {
|
16529 | return function () {
|
16530 | instance.$UPD = true;
|
16531 |
|
16532 | if (hasAfterMount) {
|
16533 | afterMount(vNode);
|
16534 | }
|
16535 |
|
16536 | if (hasDidMount) {
|
16537 | instance.componentDidMount();
|
16538 | }
|
16539 |
|
16540 | instance.$UPD = false;
|
16541 | };
|
16542 | }
|
16543 |
|
16544 | function mountClassComponentCallbacks(vNode, ref, instance, lifecycle) {
|
16545 | if (isFunction$2(ref)) {
|
16546 | ref(instance);
|
16547 | }
|
16548 |
|
16549 | var hasDidMount = isFunction$2(instance.componentDidMount);
|
16550 | var afterMount = options.afterMount;
|
16551 | var hasAfterMount = isFunction$2(afterMount);
|
16552 |
|
16553 | if (hasDidMount || hasAfterMount) {
|
16554 | lifecycle.push(createClassMountCallback(instance, hasAfterMount, afterMount, vNode, hasDidMount));
|
16555 | }
|
16556 | }
|
16557 |
|
16558 |
|
16559 | function createOnMountCallback(ref, dom, props) {
|
16560 | return function () {
|
16561 | return ref.onComponentDidMount(dom, props);
|
16562 | };
|
16563 | }
|
16564 |
|
16565 | function mountFunctionalComponentCallbacks(props, ref, dom, lifecycle) {
|
16566 | if (!isNullOrUndef(ref)) {
|
16567 | if (isFunction$2(ref.onComponentWillMount)) {
|
16568 | ref.onComponentWillMount(props);
|
16569 | }
|
16570 |
|
16571 | if (isFunction$2(ref.onComponentDidMount)) {
|
16572 | lifecycle.push(createOnMountCallback(ref, dom, props));
|
16573 | }
|
16574 | }
|
16575 | }
|
16576 |
|
16577 | function mountRef(dom, value, lifecycle) {
|
16578 | lifecycle.push(function () {
|
16579 | return value(dom);
|
16580 | });
|
16581 | }
|
16582 |
|
16583 | function hydrateComponent(vNode, dom, lifecycle, context, isSVG, isClass) {
|
16584 | var type = vNode.type;
|
16585 | var ref = vNode.ref;
|
16586 | var props = vNode.props || EMPTY_OBJ;
|
16587 |
|
16588 | if (isClass) {
|
16589 | var instance = createClassComponentInstance(vNode, type, props, context);
|
16590 | var input = instance.$LI;
|
16591 | hydrateVNode(input, dom, lifecycle, instance.$CX, isSVG);
|
16592 | vNode.dom = input.dom;
|
16593 | mountClassComponentCallbacks(vNode, ref, instance, lifecycle);
|
16594 | instance.$UPD = false;
|
16595 | } else {
|
16596 | var input$1 = handleComponentInput(type(props, context), vNode);
|
16597 | hydrateVNode(input$1, dom, lifecycle, context, isSVG);
|
16598 | vNode.children = input$1;
|
16599 | vNode.dom = input$1.dom;
|
16600 | mountFunctionalComponentCallbacks(props, ref, dom, lifecycle);
|
16601 | }
|
16602 | }
|
16603 |
|
16604 | function hydrateElement(vNode, dom, lifecycle, context, isSVG) {
|
16605 | var children = vNode.children;
|
16606 | var props = vNode.props;
|
16607 | var className = vNode.className;
|
16608 | var flags = vNode.flags;
|
16609 | var ref = vNode.ref;
|
16610 | isSVG = isSVG || (flags & 32
|
16611 |
|
16612 | ) > 0;
|
16613 |
|
16614 | if (dom.nodeType !== 1 || dom.tagName.toLowerCase() !== vNode.type) {
|
16615 | var newDom = mountElement(vNode, null, lifecycle, context, isSVG);
|
16616 | vNode.dom = newDom;
|
16617 | replaceChild(dom.parentNode, newDom, dom);
|
16618 | } else {
|
16619 | vNode.dom = dom;
|
16620 | var childNode = dom.firstChild;
|
16621 | var childFlags = vNode.childFlags;
|
16622 |
|
16623 | if ((childFlags & 1
|
16624 |
|
16625 | ) === 0) {
|
16626 | var nextSibling = null;
|
16627 |
|
16628 | while (childNode) {
|
16629 | nextSibling = childNode.nextSibling;
|
16630 |
|
16631 | if (childNode.nodeType === 8) {
|
16632 | if (childNode.data === '!') {
|
16633 | dom.replaceChild(document.createTextNode(''), childNode);
|
16634 | } else {
|
16635 | dom.removeChild(childNode);
|
16636 | }
|
16637 | }
|
16638 |
|
16639 | childNode = nextSibling;
|
16640 | }
|
16641 |
|
16642 | childNode = dom.firstChild;
|
16643 |
|
16644 | if (childFlags === 2
|
16645 |
|
16646 | ) {
|
16647 | if (isNull(childNode)) {
|
16648 | mount(children, dom, lifecycle, context, isSVG);
|
16649 | } else {
|
16650 | nextSibling = childNode.nextSibling;
|
16651 | hydrateVNode(children, childNode, lifecycle, context, isSVG);
|
16652 | childNode = nextSibling;
|
16653 | }
|
16654 | } else if (childFlags & 12
|
16655 |
|
16656 | ) {
|
16657 | for (var i = 0, len = children.length; i < len; i++) {
|
16658 | var child = children[i];
|
16659 |
|
16660 | if (isNull(childNode)) {
|
16661 | mount(child, dom, lifecycle, context, isSVG);
|
16662 | } else {
|
16663 | nextSibling = childNode.nextSibling;
|
16664 | hydrateVNode(child, childNode, lifecycle, context, isSVG);
|
16665 | childNode = nextSibling;
|
16666 | }
|
16667 | }
|
16668 | }
|
16669 |
|
16670 |
|
16671 | while (childNode) {
|
16672 | nextSibling = childNode.nextSibling;
|
16673 | dom.removeChild(childNode);
|
16674 | childNode = nextSibling;
|
16675 | }
|
16676 | } else if (!isNull(dom.firstChild) && !isSamePropsInnerHTML(dom, props)) {
|
16677 | dom.textContent = '';
|
16678 |
|
16679 | if (flags & 448
|
16680 |
|
16681 | ) {
|
16682 |
|
16683 | dom.defaultValue = '';
|
16684 | }
|
16685 | }
|
16686 |
|
16687 | if (!isNull(props)) {
|
16688 | mountProps(vNode, flags, props, dom, isSVG);
|
16689 | }
|
16690 |
|
16691 | if (isNullOrUndef(className)) {
|
16692 | if (dom.className !== '') {
|
16693 | dom.removeAttribute('class');
|
16694 | }
|
16695 | } else if (isSVG) {
|
16696 | dom.setAttribute('class', className);
|
16697 | } else {
|
16698 | dom.className = className;
|
16699 | }
|
16700 |
|
16701 | if (isFunction$2(ref)) {
|
16702 | mountRef(dom, ref, lifecycle);
|
16703 | }
|
16704 | }
|
16705 | }
|
16706 |
|
16707 | function hydrateText(vNode, dom) {
|
16708 | if (dom.nodeType !== 3) {
|
16709 | var newDom = mountText(vNode, null);
|
16710 | vNode.dom = newDom;
|
16711 | replaceChild(dom.parentNode, newDom, dom);
|
16712 | } else {
|
16713 | var text = vNode.children;
|
16714 |
|
16715 | if (dom.nodeValue !== text) {
|
16716 | dom.nodeValue = text;
|
16717 | }
|
16718 |
|
16719 | vNode.dom = dom;
|
16720 | }
|
16721 | }
|
16722 |
|
16723 | function hydrateVNode(vNode, dom, lifecycle, context, isSVG) {
|
16724 | var flags = vNode.flags;
|
16725 |
|
16726 | if (flags & 14
|
16727 |
|
16728 | ) {
|
16729 | hydrateComponent(vNode, dom, lifecycle, context, isSVG, (flags & 4
|
16730 |
|
16731 | ) > 0);
|
16732 | } else if (flags & 481
|
16733 |
|
16734 | ) {
|
16735 | hydrateElement(vNode, dom, lifecycle, context, isSVG);
|
16736 | } else if (flags & 16
|
16737 |
|
16738 | ) {
|
16739 | hydrateText(vNode, dom);
|
16740 | } else if (flags & 512
|
16741 |
|
16742 | ) {
|
16743 | vNode.dom = dom;
|
16744 | } else {
|
16745 | throwError();
|
16746 | }
|
16747 | }
|
16748 |
|
16749 | function hydrate(input, parentDom, callback) {
|
16750 | var dom = parentDom.firstChild;
|
16751 |
|
16752 | if (!isNull(dom)) {
|
16753 | if (!isInvalid(input)) {
|
16754 | hydrateVNode(input, dom, LIFECYCLE, EMPTY_OBJ, false);
|
16755 | }
|
16756 |
|
16757 | dom = parentDom.firstChild;
|
16758 |
|
16759 | while (dom = dom.nextSibling) {
|
16760 | parentDom.removeChild(dom);
|
16761 | }
|
16762 | }
|
16763 |
|
16764 | if (LIFECYCLE.length > 0) {
|
16765 | callAll(LIFECYCLE);
|
16766 | }
|
16767 |
|
16768 | if (!parentDom.$V) {
|
16769 | options.roots.push(parentDom);
|
16770 | }
|
16771 |
|
16772 | parentDom.$V = input;
|
16773 |
|
16774 | if (isFunction$2(callback)) {
|
16775 | callback();
|
16776 | }
|
16777 | }
|
16778 |
|
16779 | function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, isSVG) {
|
16780 | unmount(lastNode);
|
16781 | replaceChild(parentDom, mount(nextNode, null, lifecycle, context, isSVG), lastNode.dom);
|
16782 | }
|
16783 |
|
16784 | function patch(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG) {
|
16785 | if (lastVNode !== nextVNode) {
|
16786 | var nextFlags = nextVNode.flags | 0;
|
16787 |
|
16788 | if (lastVNode.flags !== nextFlags || nextFlags & 2048
|
16789 |
|
16790 | ) {
|
16791 | replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
|
16792 | } else if (nextFlags & 481
|
16793 |
|
16794 | ) {
|
16795 | patchElement(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
|
16796 | } else if (nextFlags & 14
|
16797 |
|
16798 | ) {
|
16799 | patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, (nextFlags & 4
|
16800 |
|
16801 | ) > 0);
|
16802 | } else if (nextFlags & 16
|
16803 |
|
16804 | ) {
|
16805 | patchText(lastVNode, nextVNode, parentDom);
|
16806 | } else if (nextFlags & 512
|
16807 |
|
16808 | ) {
|
16809 | nextVNode.dom = lastVNode.dom;
|
16810 | } else {
|
16811 |
|
16812 | patchPortal(lastVNode, nextVNode, lifecycle, context);
|
16813 | }
|
16814 | }
|
16815 | }
|
16816 |
|
16817 | function patchPortal(lastVNode, nextVNode, lifecycle, context) {
|
16818 | var lastContainer = lastVNode.type;
|
16819 | var nextContainer = nextVNode.type;
|
16820 | var nextChildren = nextVNode.children;
|
16821 | patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, lifecycle, context, false);
|
16822 | nextVNode.dom = lastVNode.dom;
|
16823 |
|
16824 | if (lastContainer !== nextContainer && !isInvalid(nextChildren)) {
|
16825 | var node = nextChildren.dom;
|
16826 | lastContainer.removeChild(node);
|
16827 | nextContainer.appendChild(node);
|
16828 | }
|
16829 | }
|
16830 |
|
16831 | function patchElement(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG) {
|
16832 | var nextTag = nextVNode.type;
|
16833 |
|
16834 | if (lastVNode.type !== nextTag) {
|
16835 | replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
|
16836 | } else {
|
16837 | var dom = lastVNode.dom;
|
16838 | var nextFlags = nextVNode.flags;
|
16839 | var lastProps = lastVNode.props;
|
16840 | var nextProps = nextVNode.props;
|
16841 | var isFormElement = false;
|
16842 | var hasControlledValue = false;
|
16843 | var nextPropsOrEmpty;
|
16844 | nextVNode.dom = dom;
|
16845 | isSVG = isSVG || (nextFlags & 32
|
16846 |
|
16847 | ) > 0;
|
16848 |
|
16849 | if (lastProps !== nextProps) {
|
16850 | var lastPropsOrEmpty = lastProps || EMPTY_OBJ;
|
16851 | nextPropsOrEmpty = nextProps || EMPTY_OBJ;
|
16852 |
|
16853 | if (nextPropsOrEmpty !== EMPTY_OBJ) {
|
16854 | isFormElement = (nextFlags & 448
|
16855 |
|
16856 | ) > 0;
|
16857 |
|
16858 | if (isFormElement) {
|
16859 | hasControlledValue = isControlledFormElement(nextPropsOrEmpty);
|
16860 | }
|
16861 |
|
16862 | for (var prop in nextPropsOrEmpty) {
|
16863 | var lastValue = lastPropsOrEmpty[prop];
|
16864 | var nextValue = nextPropsOrEmpty[prop];
|
16865 |
|
16866 | if (lastValue !== nextValue) {
|
16867 | patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode);
|
16868 | }
|
16869 | }
|
16870 | }
|
16871 |
|
16872 | if (lastPropsOrEmpty !== EMPTY_OBJ) {
|
16873 | for (var prop$1 in lastPropsOrEmpty) {
|
16874 |
|
16875 | if (!nextPropsOrEmpty.hasOwnProperty(prop$1) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) {
|
16876 | patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode);
|
16877 | }
|
16878 | }
|
16879 | }
|
16880 | }
|
16881 |
|
16882 | var lastChildren = lastVNode.children;
|
16883 | var nextChildren = nextVNode.children;
|
16884 | var nextRef = nextVNode.ref;
|
16885 | var lastClassName = lastVNode.className;
|
16886 | var nextClassName = nextVNode.className;
|
16887 |
|
16888 | if (lastChildren !== nextChildren) {
|
16889 | patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastChildren, nextChildren, dom, lifecycle, context, isSVG && nextTag !== 'foreignObject');
|
16890 | }
|
16891 |
|
16892 | if (isFormElement) {
|
16893 | processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue);
|
16894 | }
|
16895 |
|
16896 |
|
16897 | if (lastClassName !== nextClassName) {
|
16898 | if (isNullOrUndef(nextClassName)) {
|
16899 | dom.removeAttribute('class');
|
16900 | } else if (isSVG) {
|
16901 | dom.setAttribute('class', nextClassName);
|
16902 | } else {
|
16903 | dom.className = nextClassName;
|
16904 | }
|
16905 | }
|
16906 |
|
16907 | if (isFunction$2(nextRef) && lastVNode.ref !== nextRef) {
|
16908 | mountRef(dom, nextRef, lifecycle);
|
16909 | }
|
16910 | }
|
16911 | }
|
16912 |
|
16913 | function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG) {
|
16914 | switch (lastChildFlags) {
|
16915 | case 2
|
16916 |
|
16917 | :
|
16918 | switch (nextChildFlags) {
|
16919 | case 2
|
16920 |
|
16921 | :
|
16922 | patch(lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG);
|
16923 | break;
|
16924 |
|
16925 | case 1
|
16926 |
|
16927 | :
|
16928 | remove$3(lastChildren, parentDOM);
|
16929 | break;
|
16930 |
|
16931 | default:
|
16932 | remove$3(lastChildren, parentDOM);
|
16933 | mountArrayChildren(nextChildren, parentDOM, lifecycle, context, isSVG);
|
16934 | break;
|
16935 | }
|
16936 |
|
16937 | break;
|
16938 |
|
16939 | case 1
|
16940 |
|
16941 | :
|
16942 | switch (nextChildFlags) {
|
16943 | case 2
|
16944 |
|
16945 | :
|
16946 | mount(nextChildren, parentDOM, lifecycle, context, isSVG);
|
16947 | break;
|
16948 |
|
16949 | case 1
|
16950 |
|
16951 | :
|
16952 | break;
|
16953 |
|
16954 | default:
|
16955 | mountArrayChildren(nextChildren, parentDOM, lifecycle, context, isSVG);
|
16956 | break;
|
16957 | }
|
16958 |
|
16959 | break;
|
16960 |
|
16961 | default:
|
16962 | if (nextChildFlags & 12
|
16963 |
|
16964 | ) {
|
16965 | var lastLength = lastChildren.length;
|
16966 | var nextLength = nextChildren.length;
|
16967 |
|
16968 | if (lastLength === 0) {
|
16969 | if (nextLength > 0) {
|
16970 | mountArrayChildren(nextChildren, parentDOM, lifecycle, context, isSVG);
|
16971 | }
|
16972 | } else if (nextLength === 0) {
|
16973 | removeAllChildren(parentDOM, lastChildren);
|
16974 | } else if (nextChildFlags === 8
|
16975 |
|
16976 | && lastChildFlags === 8
|
16977 |
|
16978 | ) {
|
16979 | patchKeyedChildren(lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG, lastLength, nextLength);
|
16980 | } else {
|
16981 | patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG, lastLength, nextLength);
|
16982 | }
|
16983 | } else if (nextChildFlags === 1
|
16984 |
|
16985 | ) {
|
16986 | removeAllChildren(parentDOM, lastChildren);
|
16987 | } else {
|
16988 | removeAllChildren(parentDOM, lastChildren);
|
16989 | mount(nextChildren, parentDOM, lifecycle, context, isSVG);
|
16990 | }
|
16991 |
|
16992 | break;
|
16993 | }
|
16994 | }
|
16995 |
|
16996 | function updateClassComponent(instance, nextState, nextVNode, nextProps, parentDom, lifecycle, context, isSVG, force, fromSetState) {
|
16997 | var lastState = instance.state;
|
16998 | var lastProps = instance.props;
|
16999 | nextVNode.children = instance;
|
17000 | var renderOutput;
|
17001 |
|
17002 | if (instance.$UN) {
|
17003 | return;
|
17004 | }
|
17005 |
|
17006 | if (lastProps !== nextProps || nextProps === EMPTY_OBJ) {
|
17007 | if (!fromSetState && isFunction$2(instance.componentWillReceiveProps)) {
|
17008 | instance.$BR = true;
|
17009 | instance.componentWillReceiveProps(nextProps, context);
|
17010 |
|
17011 | if (instance.$UN) {
|
17012 | return;
|
17013 | }
|
17014 |
|
17015 | instance.$BR = false;
|
17016 | }
|
17017 |
|
17018 | if (instance.$PSS) {
|
17019 | nextState = combineFrom(nextState, instance.$PS);
|
17020 | instance.$PSS = false;
|
17021 | instance.$PS = null;
|
17022 | }
|
17023 | }
|
17024 |
|
17025 |
|
17026 |
|
17027 | var hasSCU = isFunction$2(instance.shouldComponentUpdate);
|
17028 |
|
17029 | if (force || !hasSCU || hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context)) {
|
17030 | if (isFunction$2(instance.componentWillUpdate)) {
|
17031 | instance.$BS = true;
|
17032 | instance.componentWillUpdate(nextProps, nextState, context);
|
17033 | instance.$BS = false;
|
17034 | }
|
17035 |
|
17036 | instance.props = nextProps;
|
17037 | instance.state = nextState;
|
17038 | instance.context = context;
|
17039 |
|
17040 | if (isFunction$2(options.beforeRender)) {
|
17041 | options.beforeRender(instance);
|
17042 | }
|
17043 |
|
17044 | renderOutput = instance.render(nextProps, nextState, context);
|
17045 |
|
17046 | if (isFunction$2(options.afterRender)) {
|
17047 | options.afterRender(instance);
|
17048 | }
|
17049 |
|
17050 | var didUpdate = renderOutput !== NO_OP;
|
17051 | var childContext;
|
17052 |
|
17053 | if (isFunction$2(instance.getChildContext)) {
|
17054 | childContext = instance.getChildContext();
|
17055 | }
|
17056 |
|
17057 | if (isNullOrUndef(childContext)) {
|
17058 | childContext = context;
|
17059 | } else {
|
17060 | childContext = combineFrom(context, childContext);
|
17061 | }
|
17062 |
|
17063 | instance.$CX = childContext;
|
17064 |
|
17065 | if (didUpdate) {
|
17066 | var lastInput = instance.$LI;
|
17067 | var nextInput = instance.$LI = handleComponentInput(renderOutput, nextVNode);
|
17068 | patch(lastInput, nextInput, parentDom, lifecycle, childContext, isSVG);
|
17069 |
|
17070 | if (isFunction$2(instance.componentDidUpdate)) {
|
17071 | instance.componentDidUpdate(lastProps, lastState);
|
17072 | }
|
17073 |
|
17074 | if (isFunction$2(options.afterUpdate)) {
|
17075 | options.afterUpdate(nextVNode);
|
17076 | }
|
17077 | }
|
17078 | } else {
|
17079 | instance.props = nextProps;
|
17080 | instance.state = nextState;
|
17081 | instance.context = context;
|
17082 | }
|
17083 |
|
17084 | nextVNode.dom = instance.$LI.dom;
|
17085 | }
|
17086 |
|
17087 | function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isClass) {
|
17088 | var nextType = nextVNode.type;
|
17089 | var lastKey = lastVNode.key;
|
17090 | var nextKey = nextVNode.key;
|
17091 |
|
17092 | if (lastVNode.type !== nextType || lastKey !== nextKey) {
|
17093 | replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
|
17094 | } else {
|
17095 | var nextProps = nextVNode.props || EMPTY_OBJ;
|
17096 |
|
17097 | if (isClass) {
|
17098 | var instance = lastVNode.children;
|
17099 | instance.$UPD = true;
|
17100 | updateClassComponent(instance, instance.state, nextVNode, nextProps, parentDom, lifecycle, context, isSVG, false, false);
|
17101 | instance.$V = nextVNode;
|
17102 | instance.$UPD = false;
|
17103 | } else {
|
17104 | var shouldUpdate = true;
|
17105 | var lastProps = lastVNode.props;
|
17106 | var nextHooks = nextVNode.ref;
|
17107 | var nextHooksDefined = !isNullOrUndef(nextHooks);
|
17108 | var lastInput = lastVNode.children;
|
17109 | nextVNode.dom = lastVNode.dom;
|
17110 | nextVNode.children = lastInput;
|
17111 |
|
17112 | if (nextHooksDefined && isFunction$2(nextHooks.onComponentShouldUpdate)) {
|
17113 | shouldUpdate = nextHooks.onComponentShouldUpdate(lastProps, nextProps);
|
17114 | }
|
17115 |
|
17116 | if (shouldUpdate !== false) {
|
17117 | if (nextHooksDefined && isFunction$2(nextHooks.onComponentWillUpdate)) {
|
17118 | nextHooks.onComponentWillUpdate(lastProps, nextProps);
|
17119 | }
|
17120 |
|
17121 | var nextInput = nextType(nextProps, context);
|
17122 |
|
17123 | if (nextInput !== NO_OP) {
|
17124 | nextInput = handleComponentInput(nextInput, nextVNode);
|
17125 | patch(lastInput, nextInput, parentDom, lifecycle, context, isSVG);
|
17126 | nextVNode.children = nextInput;
|
17127 | nextVNode.dom = nextInput.dom;
|
17128 |
|
17129 | if (nextHooksDefined && isFunction$2(nextHooks.onComponentDidUpdate)) {
|
17130 | nextHooks.onComponentDidUpdate(lastProps, nextProps);
|
17131 | }
|
17132 | }
|
17133 | } else if (lastInput.flags & 14
|
17134 |
|
17135 | ) {
|
17136 | lastInput.parentVNode = nextVNode;
|
17137 | }
|
17138 | }
|
17139 | }
|
17140 | }
|
17141 |
|
17142 | function patchText(lastVNode, nextVNode, parentDom) {
|
17143 | var nextText = nextVNode.children;
|
17144 | var textNode = parentDom.firstChild;
|
17145 | var dom;
|
17146 |
|
17147 | if (isNull(textNode)) {
|
17148 | parentDom.textContent = nextText;
|
17149 | dom = parentDom.firstChild;
|
17150 | } else {
|
17151 | dom = lastVNode.dom;
|
17152 |
|
17153 | if (nextText !== lastVNode.children) {
|
17154 | dom.nodeValue = nextText;
|
17155 | }
|
17156 | }
|
17157 |
|
17158 | nextVNode.dom = dom;
|
17159 | }
|
17160 |
|
17161 | function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, isSVG, lastChildrenLength, nextChildrenLength) {
|
17162 | var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength;
|
17163 | var i = 0;
|
17164 | var nextChild;
|
17165 |
|
17166 | for (; i < commonLength; i++) {
|
17167 | nextChild = nextChildren[i];
|
17168 |
|
17169 | if (nextChild.dom) {
|
17170 | nextChild = nextChildren[i] = directClone(nextChild);
|
17171 | }
|
17172 |
|
17173 | patch(lastChildren[i], nextChild, dom, lifecycle, context, isSVG);
|
17174 | }
|
17175 |
|
17176 | if (lastChildrenLength < nextChildrenLength) {
|
17177 | for (i = commonLength; i < nextChildrenLength; i++) {
|
17178 | nextChild = nextChildren[i];
|
17179 |
|
17180 | if (nextChild.dom) {
|
17181 | nextChild = nextChildren[i] = directClone(nextChild);
|
17182 | }
|
17183 |
|
17184 | mount(nextChild, dom, lifecycle, context, isSVG);
|
17185 | }
|
17186 | } else if (lastChildrenLength > nextChildrenLength) {
|
17187 | for (i = commonLength; i < lastChildrenLength; i++) {
|
17188 | remove$3(lastChildren[i], dom);
|
17189 | }
|
17190 | }
|
17191 | }
|
17192 |
|
17193 | function patchKeyedChildren(a, b, dom, lifecycle, context, isSVG, aLength, bLength) {
|
17194 | var aEnd = aLength - 1;
|
17195 | var bEnd = bLength - 1;
|
17196 | var aStart = 0;
|
17197 | var bStart = 0;
|
17198 | var i;
|
17199 | var j;
|
17200 | var aNode = a[aStart];
|
17201 | var bNode = b[bStart];
|
17202 | var nextNode;
|
17203 | var nextPos;
|
17204 |
|
17205 |
|
17206 | outer: {
|
17207 |
|
17208 | while (aNode.key === bNode.key) {
|
17209 | if (bNode.dom) {
|
17210 | b[bStart] = bNode = directClone(bNode);
|
17211 | }
|
17212 |
|
17213 | patch(aNode, bNode, dom, lifecycle, context, isSVG);
|
17214 | aStart++;
|
17215 | bStart++;
|
17216 |
|
17217 | if (aStart > aEnd || bStart > bEnd) {
|
17218 | break outer;
|
17219 | }
|
17220 |
|
17221 | aNode = a[aStart];
|
17222 | bNode = b[bStart];
|
17223 | }
|
17224 |
|
17225 | aNode = a[aEnd];
|
17226 | bNode = b[bEnd];
|
17227 |
|
17228 | while (aNode.key === bNode.key) {
|
17229 | if (bNode.dom) {
|
17230 | b[bEnd] = bNode = directClone(bNode);
|
17231 | }
|
17232 |
|
17233 | patch(aNode, bNode, dom, lifecycle, context, isSVG);
|
17234 | aEnd--;
|
17235 | bEnd--;
|
17236 |
|
17237 | if (aStart > aEnd || bStart > bEnd) {
|
17238 | break outer;
|
17239 | }
|
17240 |
|
17241 | aNode = a[aEnd];
|
17242 | bNode = b[bEnd];
|
17243 | }
|
17244 | }
|
17245 |
|
17246 | if (aStart > aEnd) {
|
17247 | if (bStart <= bEnd) {
|
17248 | nextPos = bEnd + 1;
|
17249 | nextNode = nextPos < bLength ? b[nextPos].dom : null;
|
17250 |
|
17251 | while (bStart <= bEnd) {
|
17252 | bNode = b[bStart];
|
17253 |
|
17254 | if (bNode.dom) {
|
17255 | b[bStart] = bNode = directClone(bNode);
|
17256 | }
|
17257 |
|
17258 | bStart++;
|
17259 | insertOrAppend(dom, mount(bNode, null, lifecycle, context, isSVG), nextNode);
|
17260 | }
|
17261 | }
|
17262 | } else if (bStart > bEnd) {
|
17263 | while (aStart <= aEnd) {
|
17264 | remove$3(a[aStart++], dom);
|
17265 | }
|
17266 | } else {
|
17267 | var aLeft = aEnd - aStart + 1;
|
17268 | var bLeft = bEnd - bStart + 1;
|
17269 | var sources = [];
|
17270 |
|
17271 | for (i = 0; i < bLeft; i++) {
|
17272 | sources.push(0);
|
17273 | }
|
17274 |
|
17275 |
|
17276 | var canRemoveWholeContent = aLeft === aLength;
|
17277 | var moved = false;
|
17278 | var pos = 0;
|
17279 | var patched = 0;
|
17280 |
|
17281 | if (bLength < 4 || (aLeft | bLeft) < 32) {
|
17282 | for (i = aStart; i <= aEnd; i++) {
|
17283 | aNode = a[i];
|
17284 |
|
17285 | if (patched < bLeft) {
|
17286 | for (j = bStart; j <= bEnd; j++) {
|
17287 | bNode = b[j];
|
17288 |
|
17289 | if (aNode.key === bNode.key) {
|
17290 | sources[j - bStart] = i + 1;
|
17291 |
|
17292 | if (canRemoveWholeContent) {
|
17293 | canRemoveWholeContent = false;
|
17294 |
|
17295 | while (i > aStart) {
|
17296 | remove$3(a[aStart++], dom);
|
17297 | }
|
17298 | }
|
17299 |
|
17300 | if (pos > j) {
|
17301 | moved = true;
|
17302 | } else {
|
17303 | pos = j;
|
17304 | }
|
17305 |
|
17306 | if (bNode.dom) {
|
17307 | b[j] = bNode = directClone(bNode);
|
17308 | }
|
17309 |
|
17310 | patch(aNode, bNode, dom, lifecycle, context, isSVG);
|
17311 | patched++;
|
17312 | break;
|
17313 | }
|
17314 | }
|
17315 |
|
17316 | if (!canRemoveWholeContent && j > bEnd) {
|
17317 | remove$3(aNode, dom);
|
17318 | }
|
17319 | } else if (!canRemoveWholeContent) {
|
17320 | remove$3(aNode, dom);
|
17321 | }
|
17322 | }
|
17323 | } else {
|
17324 | var keyIndex = {};
|
17325 |
|
17326 | for (i = bStart; i <= bEnd; i++) {
|
17327 | keyIndex[b[i].key] = i;
|
17328 | }
|
17329 |
|
17330 |
|
17331 | for (i = aStart; i <= aEnd; i++) {
|
17332 | aNode = a[i];
|
17333 |
|
17334 | if (patched < bLeft) {
|
17335 | j = keyIndex[aNode.key];
|
17336 |
|
17337 | if (j !== void 0) {
|
17338 | if (canRemoveWholeContent) {
|
17339 | canRemoveWholeContent = false;
|
17340 |
|
17341 | while (i > aStart) {
|
17342 | remove$3(a[aStart++], dom);
|
17343 | }
|
17344 | }
|
17345 |
|
17346 | bNode = b[j];
|
17347 | sources[j - bStart] = i + 1;
|
17348 |
|
17349 | if (pos > j) {
|
17350 | moved = true;
|
17351 | } else {
|
17352 | pos = j;
|
17353 | }
|
17354 |
|
17355 | if (bNode.dom) {
|
17356 | b[j] = bNode = directClone(bNode);
|
17357 | }
|
17358 |
|
17359 | patch(aNode, bNode, dom, lifecycle, context, isSVG);
|
17360 | patched++;
|
17361 | } else if (!canRemoveWholeContent) {
|
17362 | remove$3(aNode, dom);
|
17363 | }
|
17364 | } else if (!canRemoveWholeContent) {
|
17365 | remove$3(aNode, dom);
|
17366 | }
|
17367 | }
|
17368 | }
|
17369 |
|
17370 |
|
17371 | if (canRemoveWholeContent) {
|
17372 | removeAllChildren(dom, a);
|
17373 | mountArrayChildren(b, dom, lifecycle, context, isSVG);
|
17374 | } else {
|
17375 | if (moved) {
|
17376 | var seq = lis_algorithm(sources);
|
17377 | j = seq.length - 1;
|
17378 |
|
17379 | for (i = bLeft - 1; i >= 0; i--) {
|
17380 | if (sources[i] === 0) {
|
17381 | pos = i + bStart;
|
17382 | bNode = b[pos];
|
17383 |
|
17384 | if (bNode.dom) {
|
17385 | b[pos] = bNode = directClone(bNode);
|
17386 | }
|
17387 |
|
17388 | nextPos = pos + 1;
|
17389 | insertOrAppend(dom, mount(bNode, null, lifecycle, context, isSVG), nextPos < bLength ? b[nextPos].dom : null);
|
17390 | } else if (j < 0 || i !== seq[j]) {
|
17391 | pos = i + bStart;
|
17392 | bNode = b[pos];
|
17393 | nextPos = pos + 1;
|
17394 | insertOrAppend(dom, bNode.dom, nextPos < bLength ? b[nextPos].dom : null);
|
17395 | } else {
|
17396 | j--;
|
17397 | }
|
17398 | }
|
17399 | } else if (patched !== bLeft) {
|
17400 |
|
17401 |
|
17402 | for (i = bLeft - 1; i >= 0; i--) {
|
17403 | if (sources[i] === 0) {
|
17404 | pos = i + bStart;
|
17405 | bNode = b[pos];
|
17406 |
|
17407 | if (bNode.dom) {
|
17408 | b[pos] = bNode = directClone(bNode);
|
17409 | }
|
17410 |
|
17411 | nextPos = pos + 1;
|
17412 | insertOrAppend(dom, mount(bNode, null, lifecycle, context, isSVG), nextPos < bLength ? b[nextPos].dom : null);
|
17413 | }
|
17414 | }
|
17415 | }
|
17416 | }
|
17417 | }
|
17418 | }
|
17419 |
|
17420 |
|
17421 | function lis_algorithm(arr) {
|
17422 | var p = arr.slice();
|
17423 | var result = [0];
|
17424 | var i;
|
17425 | var j;
|
17426 | var u;
|
17427 | var v;
|
17428 | var c;
|
17429 | var len = arr.length;
|
17430 |
|
17431 | for (i = 0; i < len; i++) {
|
17432 | var arrI = arr[i];
|
17433 |
|
17434 | if (arrI !== 0) {
|
17435 | j = result[result.length - 1];
|
17436 |
|
17437 | if (arr[j] < arrI) {
|
17438 | p[i] = j;
|
17439 | result.push(i);
|
17440 | continue;
|
17441 | }
|
17442 |
|
17443 | u = 0;
|
17444 | v = result.length - 1;
|
17445 |
|
17446 | while (u < v) {
|
17447 | c = (u + v) / 2 | 0;
|
17448 |
|
17449 | if (arr[result[c]] < arrI) {
|
17450 | u = c + 1;
|
17451 | } else {
|
17452 | v = c;
|
17453 | }
|
17454 | }
|
17455 |
|
17456 | if (arrI < arr[result[u]]) {
|
17457 | if (u > 0) {
|
17458 | p[i] = result[u - 1];
|
17459 | }
|
17460 |
|
17461 | result[u] = i;
|
17462 | }
|
17463 | }
|
17464 | }
|
17465 |
|
17466 | u = result.length;
|
17467 | v = result[u - 1];
|
17468 |
|
17469 | while (u-- > 0) {
|
17470 | result[u] = v;
|
17471 | v = p[v];
|
17472 | }
|
17473 |
|
17474 | return result;
|
17475 | }
|
17476 |
|
17477 | var roots = options.roots;
|
17478 |
|
17479 | function render(input, parentDom, callback) {
|
17480 | if (input === NO_OP) {
|
17481 | return;
|
17482 | }
|
17483 |
|
17484 | var rootLen = roots.length;
|
17485 | var rootInput;
|
17486 | var index;
|
17487 |
|
17488 | for (index = 0; index < rootLen; index++) {
|
17489 | if (roots[index] === parentDom) {
|
17490 | rootInput = parentDom.$V;
|
17491 | break;
|
17492 | }
|
17493 | }
|
17494 |
|
17495 | if (isUndefined$2(rootInput)) {
|
17496 | if (!isInvalid(input)) {
|
17497 | if (input.dom) {
|
17498 | input = directClone(input);
|
17499 | }
|
17500 |
|
17501 | if (isNull(parentDom.firstChild)) {
|
17502 | mount(input, parentDom, LIFECYCLE, EMPTY_OBJ, false);
|
17503 | parentDom.$V = input;
|
17504 | roots.push(parentDom);
|
17505 | } else {
|
17506 | hydrate(input, parentDom);
|
17507 | }
|
17508 |
|
17509 | rootInput = input;
|
17510 | }
|
17511 | } else {
|
17512 | if (isNullOrUndef(input)) {
|
17513 | remove$3(rootInput, parentDom);
|
17514 | roots.splice(index, 1);
|
17515 | } else {
|
17516 | if (input.dom) {
|
17517 | input = directClone(input);
|
17518 | }
|
17519 |
|
17520 | patch(rootInput, input, parentDom, LIFECYCLE, EMPTY_OBJ, false);
|
17521 | rootInput = parentDom.$V = input;
|
17522 | }
|
17523 | }
|
17524 |
|
17525 | if (LIFECYCLE.length > 0) {
|
17526 | callAll(LIFECYCLE);
|
17527 | }
|
17528 |
|
17529 | if (isFunction$2(callback)) {
|
17530 | callback();
|
17531 | }
|
17532 |
|
17533 | if (rootInput && rootInput.flags & 14
|
17534 |
|
17535 | ) {
|
17536 | return rootInput.children;
|
17537 | }
|
17538 | }
|
17539 |
|
17540 | var resolvedPromise = typeof Promise === 'undefined' ? null : Promise.resolve();
|
17541 |
|
17542 | var fallbackMethod = typeof requestAnimationFrame === 'undefined' ? setTimeout : requestAnimationFrame.bind(window);
|
17543 |
|
17544 | function nextTick(fn) {
|
17545 | if (resolvedPromise) {
|
17546 | return resolvedPromise.then(fn);
|
17547 | }
|
17548 |
|
17549 | return fallbackMethod(fn);
|
17550 | }
|
17551 |
|
17552 | function queueStateChanges(component, newState, callback) {
|
17553 | if (isFunction$2(newState)) {
|
17554 | newState = newState(component.state, component.props, component.context);
|
17555 | }
|
17556 |
|
17557 | var pending = component.$PS;
|
17558 |
|
17559 | if (isNullOrUndef(pending)) {
|
17560 | component.$PS = newState;
|
17561 | } else {
|
17562 | for (var stateKey in newState) {
|
17563 | pending[stateKey] = newState[stateKey];
|
17564 | }
|
17565 | }
|
17566 |
|
17567 | if (!component.$PSS && !component.$BR) {
|
17568 | if (!component.$UPD) {
|
17569 | component.$PSS = true;
|
17570 | component.$UPD = true;
|
17571 | applyState(component, false, callback);
|
17572 | component.$UPD = false;
|
17573 | } else {
|
17574 |
|
17575 | var queue = component.$QU;
|
17576 |
|
17577 | if (isNull(queue)) {
|
17578 | queue = component.$QU = [];
|
17579 | nextTick(promiseCallback(component, queue));
|
17580 | }
|
17581 |
|
17582 | if (isFunction$2(callback)) {
|
17583 | queue.push(callback);
|
17584 | }
|
17585 | }
|
17586 | } else {
|
17587 | component.$PSS = true;
|
17588 |
|
17589 | if (component.$BR && isFunction$2(callback)) {
|
17590 | LIFECYCLE.push(callback.bind(component));
|
17591 | }
|
17592 | }
|
17593 | }
|
17594 |
|
17595 | function promiseCallback(component, queue) {
|
17596 | return function () {
|
17597 | component.$QU = null;
|
17598 | component.$UPD = true;
|
17599 | applyState(component, false, function () {
|
17600 | for (var i = 0, len = queue.length; i < len; i++) {
|
17601 | queue[i].call(component);
|
17602 | }
|
17603 | });
|
17604 | component.$UPD = false;
|
17605 | };
|
17606 | }
|
17607 |
|
17608 | function applyState(component, force, callback) {
|
17609 | if (component.$UN) {
|
17610 | return;
|
17611 | }
|
17612 |
|
17613 | if (force || !component.$BR) {
|
17614 | component.$PSS = false;
|
17615 | var pendingState = component.$PS;
|
17616 | var prevState = component.state;
|
17617 | var nextState = combineFrom(prevState, pendingState);
|
17618 | var props = component.props;
|
17619 | var context = component.context;
|
17620 | component.$PS = null;
|
17621 | var vNode = component.$V;
|
17622 | var lastInput = component.$LI;
|
17623 | var parentDom = lastInput.dom && lastInput.dom.parentNode;
|
17624 | updateClassComponent(component, nextState, vNode, props, parentDom, LIFECYCLE, context, (vNode.flags & 32
|
17625 |
|
17626 | ) > 0, force, true);
|
17627 |
|
17628 | if (component.$UN) {
|
17629 | return;
|
17630 | }
|
17631 |
|
17632 | if ((component.$LI.flags & 1024
|
17633 |
|
17634 | ) === 0) {
|
17635 | var dom = component.$LI.dom;
|
17636 |
|
17637 | while (!isNull(vNode = vNode.parentVNode)) {
|
17638 | if ((vNode.flags & 14
|
17639 |
|
17640 | ) > 0) {
|
17641 | vNode.dom = dom;
|
17642 | }
|
17643 | }
|
17644 | }
|
17645 |
|
17646 | if (LIFECYCLE.length > 0) {
|
17647 | callAll(LIFECYCLE);
|
17648 | }
|
17649 | } else {
|
17650 | component.state = component.$PS;
|
17651 | component.$PS = null;
|
17652 | }
|
17653 |
|
17654 | if (isFunction$2(callback)) {
|
17655 | callback.call(component);
|
17656 | }
|
17657 | }
|
17658 |
|
17659 | var Component = function Component(props, context) {
|
17660 | this.state = null;
|
17661 |
|
17662 | this.$BR = false;
|
17663 |
|
17664 | this.$BS = true;
|
17665 |
|
17666 | this.$PSS = false;
|
17667 |
|
17668 | this.$PS = null;
|
17669 |
|
17670 | this.$LI = null;
|
17671 |
|
17672 | this.$V = null;
|
17673 |
|
17674 | this.$UN = false;
|
17675 |
|
17676 | this.$CX = null;
|
17677 |
|
17678 | this.$UPD = true;
|
17679 |
|
17680 | this.$QU = null;
|
17681 |
|
17682 |
|
17683 |
|
17684 | this.props = props || EMPTY_OBJ;
|
17685 |
|
17686 |
|
17687 | this.context = context || EMPTY_OBJ;
|
17688 | };
|
17689 |
|
17690 | Component.prototype.forceUpdate = function forceUpdate(callback) {
|
17691 | if (this.$UN) {
|
17692 | return;
|
17693 | }
|
17694 |
|
17695 | applyState(this, true, callback);
|
17696 | };
|
17697 |
|
17698 | Component.prototype.setState = function setState(newState, callback) {
|
17699 | if (this.$UN) {
|
17700 | return;
|
17701 | }
|
17702 |
|
17703 | if (!this.$BS) {
|
17704 | queueStateChanges(this, newState, callback);
|
17705 | } else {
|
17706 | return;
|
17707 | }
|
17708 | };
|
17709 |
|
17710 |
|
17711 | Component.prototype.render = function render(nextProps, nextState, nextContext) {};
|
17712 |
|
17713 |
|
17714 | Component.defaultProps = null;
|
17715 |
|
17716 | function _typeof$5(obj) {
|
17717 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
17718 | _typeof$5 = function _typeof$1(obj) {
|
17719 | return _typeof(obj);
|
17720 | };
|
17721 | } else {
|
17722 | _typeof$5 = function _typeof$1(obj) {
|
17723 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
17724 | };
|
17725 | }
|
17726 |
|
17727 | return _typeof$5(obj);
|
17728 | }
|
17729 |
|
17730 | function _classCallCheck$8(instance, Constructor) {
|
17731 | if (!(instance instanceof Constructor)) {
|
17732 | throw new TypeError("Cannot call a class as a function");
|
17733 | }
|
17734 | }
|
17735 |
|
17736 | function _defineProperties$7(target, props) {
|
17737 | for (var i = 0; i < props.length; i++) {
|
17738 | var descriptor = props[i];
|
17739 | descriptor.enumerable = descriptor.enumerable || false;
|
17740 | descriptor.configurable = true;
|
17741 | if ("value" in descriptor) descriptor.writable = true;
|
17742 | Object.defineProperty(target, descriptor.key, descriptor);
|
17743 | }
|
17744 | }
|
17745 |
|
17746 | function _createClass$7(Constructor, protoProps, staticProps) {
|
17747 | if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
|
17748 | if (staticProps) _defineProperties$7(Constructor, staticProps);
|
17749 | return Constructor;
|
17750 | }
|
17751 |
|
17752 | function _possibleConstructorReturn$2(self, call) {
|
17753 | if (call && (_typeof$5(call) === "object" || typeof call === "function")) {
|
17754 | return call;
|
17755 | }
|
17756 |
|
17757 | return _assertThisInitialized$2(self);
|
17758 | }
|
17759 |
|
17760 | function _getPrototypeOf$2(o) {
|
17761 | _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
17762 | return o.__proto__ || Object.getPrototypeOf(o);
|
17763 | };
|
17764 | return _getPrototypeOf$2(o);
|
17765 | }
|
17766 |
|
17767 | function _assertThisInitialized$2(self) {
|
17768 | if (self === void 0) {
|
17769 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
17770 | }
|
17771 |
|
17772 | return self;
|
17773 | }
|
17774 |
|
17775 | function _inherits$2(subClass, superClass) {
|
17776 | if (typeof superClass !== "function" && superClass !== null) {
|
17777 | throw new TypeError("Super expression must either be null or a function");
|
17778 | }
|
17779 |
|
17780 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
17781 | constructor: {
|
17782 | value: subClass,
|
17783 | writable: true,
|
17784 | configurable: true
|
17785 | }
|
17786 | });
|
17787 | if (superClass) _setPrototypeOf$2(subClass, superClass);
|
17788 | }
|
17789 |
|
17790 | function _setPrototypeOf$2(o, p) {
|
17791 | _setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
17792 | o.__proto__ = p;
|
17793 | return o;
|
17794 | };
|
17795 |
|
17796 | return _setPrototypeOf$2(o, p);
|
17797 | }
|
17798 |
|
17799 | var TableComponent =
|
17800 |
|
17801 | function (_Component) {
|
17802 | _inherits$2(TableComponent, _Component);
|
17803 |
|
17804 | function TableComponent(props) {
|
17805 | var _this;
|
17806 |
|
17807 | _classCallCheck$8(this, TableComponent);
|
17808 |
|
17809 | _this = _possibleConstructorReturn$2(this, _getPrototypeOf$2(TableComponent).call(this, props));
|
17810 | var injector = _this._injector = props.injector;
|
17811 | _this._sheet = injector.get('sheet');
|
17812 | _this._changeSupport = injector.get('changeSupport');
|
17813 | _this._components = injector.get('components');
|
17814 | _this.onElementsChanged = _this.onElementsChanged.bind(_assertThisInitialized$2(_this));
|
17815 | return _this;
|
17816 | }
|
17817 |
|
17818 | _createClass$7(TableComponent, [{
|
17819 | key: "onElementsChanged",
|
17820 | value: function onElementsChanged() {
|
17821 | this.forceUpdate();
|
17822 | }
|
17823 | }, {
|
17824 | key: "getChildContext",
|
17825 | value: function getChildContext() {
|
17826 | return {
|
17827 | changeSupport: this._changeSupport,
|
17828 | components: this._components,
|
17829 | injector: this._injector
|
17830 | };
|
17831 | }
|
17832 | }, {
|
17833 | key: "componentWillMount",
|
17834 | value: function componentWillMount() {
|
17835 | var _this$_sheet$getRoot = this._sheet.getRoot(),
|
17836 | id = _this$_sheet$getRoot.id;
|
17837 |
|
17838 | this._changeSupport.onElementsChanged(id, this.onElementsChanged);
|
17839 | }
|
17840 | }, {
|
17841 | key: "componentWillUnmount",
|
17842 | value: function componentWillUnmount() {
|
17843 | var _this$_sheet$getRoot2 = this._sheet.getRoot(),
|
17844 | id = _this$_sheet$getRoot2.id;
|
17845 |
|
17846 | this._changeSupport.offElementsChanged(id, this.onElementsChanged);
|
17847 | }
|
17848 | }, {
|
17849 | key: "render",
|
17850 | value: function render() {
|
17851 | var _this$_sheet$getRoot3 = this._sheet.getRoot(),
|
17852 | rows = _this$_sheet$getRoot3.rows,
|
17853 | cols = _this$_sheet$getRoot3.cols;
|
17854 |
|
17855 | var beforeTableComponents = this._components.getComponents('table.before');
|
17856 |
|
17857 | var afterTableComponents = this._components.getComponents('table.after');
|
17858 |
|
17859 | var Head = this._components.getComponent('table.head');
|
17860 |
|
17861 | var Body = this._components.getComponent('table.body');
|
17862 |
|
17863 | var Foot = this._components.getComponent('table.foot');
|
17864 |
|
17865 | return createVNode(1, "div", "tjs-container", [beforeTableComponents && beforeTableComponents.map(function (Component, index) {
|
17866 | return createComponentVNode(2, Component, null, index);
|
17867 | }), createVNode(1, "table", "tjs-table", [Head && createComponentVNode(2, Head, {
|
17868 | "rows": rows,
|
17869 | "cols": cols
|
17870 | }), Body && createComponentVNode(2, Body, {
|
17871 | "rows": rows,
|
17872 | "cols": cols
|
17873 | }), Foot && createComponentVNode(2, Foot, {
|
17874 | "rows": rows,
|
17875 | "cols": cols
|
17876 | })], 0), afterTableComponents && afterTableComponents.map(function (Component, index) {
|
17877 | return createComponentVNode(2, Component, null, index);
|
17878 | })], 0);
|
17879 | }
|
17880 | }]);
|
17881 |
|
17882 | return TableComponent;
|
17883 | }(Component);
|
17884 |
|
17885 | function _classCallCheck$9(instance, Constructor) {
|
17886 | if (!(instance instanceof Constructor)) {
|
17887 | throw new TypeError("Cannot call a class as a function");
|
17888 | }
|
17889 | }
|
17890 |
|
17891 | function _defineProperties$8(target, props) {
|
17892 | for (var i = 0; i < props.length; i++) {
|
17893 | var descriptor = props[i];
|
17894 | descriptor.enumerable = descriptor.enumerable || false;
|
17895 | descriptor.configurable = true;
|
17896 | if ("value" in descriptor) descriptor.writable = true;
|
17897 | Object.defineProperty(target, descriptor.key, descriptor);
|
17898 | }
|
17899 | }
|
17900 |
|
17901 | function _createClass$8(Constructor, protoProps, staticProps) {
|
17902 | if (protoProps) _defineProperties$8(Constructor.prototype, protoProps);
|
17903 | if (staticProps) _defineProperties$8(Constructor, staticProps);
|
17904 | return Constructor;
|
17905 | }
|
17906 |
|
17907 | var Renderer =
|
17908 |
|
17909 | function () {
|
17910 | function Renderer(changeSupport, components, config, eventBus, injector) {
|
17911 | _classCallCheck$9(this, Renderer);
|
17912 |
|
17913 | var container = config.container;
|
17914 | this._container = container;
|
17915 | eventBus.on('root.added', function () {
|
17916 | render(createComponentVNode(2, TableComponent, {
|
17917 | "injector": injector
|
17918 | }), container);
|
17919 | });
|
17920 | eventBus.on('root.remove', function () {
|
17921 | render(null, container);
|
17922 | });
|
17923 | }
|
17924 |
|
17925 | _createClass$8(Renderer, [{
|
17926 | key: "getContainer",
|
17927 | value: function getContainer() {
|
17928 | return this._container;
|
17929 | }
|
17930 | }]);
|
17931 |
|
17932 | return Renderer;
|
17933 | }();
|
17934 | Renderer.$inject = ['changeSupport', 'components', 'config.renderer', 'eventBus', 'injector'];
|
17935 |
|
17936 | var renderModule = {
|
17937 | __init__: ['changeSupport', 'components', 'renderer'],
|
17938 | changeSupport: ['type', ChangeSupport],
|
17939 | components: ['type', Components],
|
17940 | renderer: ['type', Renderer]
|
17941 | };
|
17942 |
|
17943 | function _classCallCheck$a(instance, Constructor) {
|
17944 | if (!(instance instanceof Constructor)) {
|
17945 | throw new TypeError("Cannot call a class as a function");
|
17946 | }
|
17947 | }
|
17948 |
|
17949 | function _defineProperties$9(target, props) {
|
17950 | for (var i = 0; i < props.length; i++) {
|
17951 | var descriptor = props[i];
|
17952 | descriptor.enumerable = descriptor.enumerable || false;
|
17953 | descriptor.configurable = true;
|
17954 | if ("value" in descriptor) descriptor.writable = true;
|
17955 | Object.defineProperty(target, descriptor.key, descriptor);
|
17956 | }
|
17957 | }
|
17958 |
|
17959 | function _createClass$9(Constructor, protoProps, staticProps) {
|
17960 | if (protoProps) _defineProperties$9(Constructor.prototype, protoProps);
|
17961 | if (staticProps) _defineProperties$9(Constructor, staticProps);
|
17962 | return Constructor;
|
17963 | }
|
17964 |
|
17965 | var Sheet =
|
17966 |
|
17967 | function () {
|
17968 | function Sheet(elementRegistry, eventBus) {
|
17969 | var _this = this;
|
17970 |
|
17971 | _classCallCheck$a(this, Sheet);
|
17972 |
|
17973 | this._elementRegistry = elementRegistry;
|
17974 | this._eventBus = eventBus;
|
17975 | this._root = null;
|
17976 | eventBus.on('table.clear', function () {
|
17977 | _this.setRoot(null);
|
17978 | });
|
17979 | }
|
17980 |
|
17981 | _createClass$9(Sheet, [{
|
17982 | key: "setRoot",
|
17983 | value: function setRoot(root) {
|
17984 | if (this._root) {
|
17985 | var oldRoot = this._root;
|
17986 |
|
17987 | this._eventBus.fire('root.remove', {
|
17988 | root: oldRoot
|
17989 | });
|
17990 |
|
17991 | this._root = null;
|
17992 |
|
17993 | this._eventBus.fire('root.removed', {
|
17994 | root: oldRoot
|
17995 | });
|
17996 | }
|
17997 |
|
17998 | if (root) {
|
17999 | this._eventBus.fire('root.add', {
|
18000 | root: root
|
18001 | });
|
18002 | }
|
18003 |
|
18004 | this._root = root;
|
18005 |
|
18006 | if (root) {
|
18007 | this._eventBus.fire('root.added', {
|
18008 | root: root
|
18009 | });
|
18010 | }
|
18011 | }
|
18012 | }, {
|
18013 | key: "getRoot",
|
18014 | value: function getRoot() {
|
18015 | if (!this._root) {
|
18016 | this.setRoot({
|
18017 | id: '__implicitroot',
|
18018 | rows: [],
|
18019 | cols: []
|
18020 | });
|
18021 | }
|
18022 |
|
18023 | return this._root;
|
18024 | }
|
18025 | |
18026 |
|
18027 |
|
18028 |
|
18029 |
|
18030 |
|
18031 | }, {
|
18032 | key: "addRow",
|
18033 | value: function addRow(row, index) {
|
18034 | var _this2 = this;
|
18035 |
|
18036 | var root = this.getRoot();
|
18037 |
|
18038 | if (root.cols.length != row.cells.length) {
|
18039 | throw new Error('number of cells is not equal to number of cols');
|
18040 | }
|
18041 |
|
18042 | if (typeof index === 'undefined') {
|
18043 | index = root.rows.length;
|
18044 | }
|
18045 |
|
18046 | addAtIndex(index, root.rows, row);
|
18047 | row.root = root;
|
18048 |
|
18049 | this._elementRegistry.add(row);
|
18050 |
|
18051 | row.cells.forEach(function (cell, idx) {
|
18052 | _this2._elementRegistry.add(cell);
|
18053 |
|
18054 | cell.row = row;
|
18055 | cell.col = root.cols[idx];
|
18056 | addAtIndex(index, root.cols[idx].cells, cell);
|
18057 | });
|
18058 |
|
18059 | this._eventBus.fire('row.add', {
|
18060 | row: row
|
18061 | });
|
18062 |
|
18063 | return row;
|
18064 | }
|
18065 | |
18066 |
|
18067 |
|
18068 |
|
18069 |
|
18070 |
|
18071 | }, {
|
18072 | key: "removeRow",
|
18073 | value: function removeRow(row) {
|
18074 | var _this3 = this;
|
18075 |
|
18076 | var root = this.getRoot();
|
18077 |
|
18078 | if (typeof row === 'string') {
|
18079 | row = this._elementRegistry.get(row);
|
18080 | }
|
18081 |
|
18082 | var index = root.rows.indexOf(row);
|
18083 |
|
18084 | if (index === -1) {
|
18085 | return;
|
18086 | }
|
18087 |
|
18088 | removeAtIndex(index, root.rows);
|
18089 | row.root = undefined;
|
18090 |
|
18091 | this._elementRegistry.remove(row);
|
18092 |
|
18093 | row.cells.forEach(function (cell, idx) {
|
18094 | _this3._elementRegistry.remove(cell);
|
18095 |
|
18096 | cell.col = undefined;
|
18097 | removeAtIndex(index, root.cols[idx].cells);
|
18098 | });
|
18099 |
|
18100 | this._eventBus.fire('row.remove', {
|
18101 | row: row
|
18102 | });
|
18103 | }
|
18104 | |
18105 |
|
18106 |
|
18107 |
|
18108 |
|
18109 |
|
18110 |
|
18111 | }, {
|
18112 | key: "addCol",
|
18113 | value: function addCol(col, index) {
|
18114 | var _this4 = this;
|
18115 |
|
18116 | var root = this.getRoot();
|
18117 |
|
18118 | this._elementRegistry.add(col);
|
18119 |
|
18120 | if (root.rows.length != col.cells.length) {
|
18121 | throw new Error('number of cells is not equal to number of rows');
|
18122 | }
|
18123 |
|
18124 | if (typeof index === 'undefined') {
|
18125 | index = root.cols.length;
|
18126 | }
|
18127 |
|
18128 | addAtIndex(index, root.cols, col);
|
18129 | col.root = root;
|
18130 | col.cells.forEach(function (cell, idx) {
|
18131 | _this4._elementRegistry.add(cell);
|
18132 |
|
18133 | cell.col = col;
|
18134 | cell.row = root.rows[idx];
|
18135 | addAtIndex(index, root.rows[idx].cells, cell);
|
18136 | });
|
18137 |
|
18138 | this._eventBus.fire('col.add', {
|
18139 | col: col
|
18140 | });
|
18141 |
|
18142 | return col;
|
18143 | }
|
18144 | |
18145 |
|
18146 |
|
18147 |
|
18148 |
|
18149 |
|
18150 | }, {
|
18151 | key: "removeCol",
|
18152 | value: function removeCol(col) {
|
18153 | var _this5 = this;
|
18154 |
|
18155 | var root = this.getRoot();
|
18156 |
|
18157 | if (typeof col === 'string') {
|
18158 | col = this._elementRegistry.get(col);
|
18159 | }
|
18160 |
|
18161 | var index = root.cols.indexOf(col);
|
18162 |
|
18163 | if (index === -1) {
|
18164 | return;
|
18165 | }
|
18166 |
|
18167 | removeAtIndex(index, root.cols);
|
18168 | col.root = undefined;
|
18169 |
|
18170 | this._elementRegistry.remove(col);
|
18171 |
|
18172 | col.cells.forEach(function (cell, idx) {
|
18173 | _this5._elementRegistry.remove(cell);
|
18174 |
|
18175 | cell.row = undefined;
|
18176 | removeAtIndex(index, root.rows[idx].cells);
|
18177 | });
|
18178 |
|
18179 | this._eventBus.fire('col.remove', {
|
18180 | col: col
|
18181 | });
|
18182 | }
|
18183 | }, {
|
18184 | key: "resized",
|
18185 | value: function resized() {
|
18186 | this._eventBus.fire('sheet.resized');
|
18187 | }
|
18188 | }]);
|
18189 |
|
18190 | return Sheet;
|
18191 | }();
|
18192 | Sheet.$inject = ['elementRegistry', 'eventBus'];
|
18193 |
|
18194 | |
18195 |
|
18196 |
|
18197 |
|
18198 |
|
18199 |
|
18200 |
|
18201 |
|
18202 | function addAtIndex(index, array, value) {
|
18203 | return array.splice(index, 0, value);
|
18204 | }
|
18205 | |
18206 |
|
18207 |
|
18208 |
|
18209 |
|
18210 |
|
18211 |
|
18212 | function removeAtIndex(index, array) {
|
18213 | return array.splice(index, 1);
|
18214 | }
|
18215 |
|
18216 | var core = {
|
18217 | __depends__: [renderModule],
|
18218 | __init__: ['elementFactory', 'sheet'],
|
18219 | elementFactory: ['type', ElementFactory$1],
|
18220 | elementRegistry: ['type', ElementRegistry$1],
|
18221 | eventBus: ['type', EventBus],
|
18222 | sheet: ['type', Sheet]
|
18223 | };
|
18224 |
|
18225 | function _objectWithoutProperties$1(source, excluded) {
|
18226 | if (source == null) return {};
|
18227 |
|
18228 | var target = _objectWithoutPropertiesLoose$1(source, excluded);
|
18229 |
|
18230 | var key, i;
|
18231 |
|
18232 | if (Object.getOwnPropertySymbols) {
|
18233 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
18234 |
|
18235 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
18236 | key = sourceSymbolKeys[i];
|
18237 | if (excluded.indexOf(key) >= 0) continue;
|
18238 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
18239 | target[key] = source[key];
|
18240 | }
|
18241 | }
|
18242 |
|
18243 | return target;
|
18244 | }
|
18245 |
|
18246 | function _objectWithoutPropertiesLoose$1(source, excluded) {
|
18247 | if (source == null) return {};
|
18248 | var target = {};
|
18249 | var sourceKeys = Object.keys(source);
|
18250 | var key, i;
|
18251 |
|
18252 | for (i = 0; i < sourceKeys.length; i++) {
|
18253 | key = sourceKeys[i];
|
18254 | if (excluded.indexOf(key) >= 0) continue;
|
18255 | target[key] = source[key];
|
18256 | }
|
18257 |
|
18258 | return target;
|
18259 | }
|
18260 |
|
18261 | function _classCallCheck$b(instance, Constructor) {
|
18262 | if (!(instance instanceof Constructor)) {
|
18263 | throw new TypeError("Cannot call a class as a function");
|
18264 | }
|
18265 | }
|
18266 |
|
18267 | function _defineProperties$a(target, props) {
|
18268 | for (var i = 0; i < props.length; i++) {
|
18269 | var descriptor = props[i];
|
18270 | descriptor.enumerable = descriptor.enumerable || false;
|
18271 | descriptor.configurable = true;
|
18272 | if ("value" in descriptor) descriptor.writable = true;
|
18273 | Object.defineProperty(target, descriptor.key, descriptor);
|
18274 | }
|
18275 | }
|
18276 |
|
18277 | function _createClass$a(Constructor, protoProps, staticProps) {
|
18278 | if (protoProps) _defineProperties$a(Constructor.prototype, protoProps);
|
18279 | if (staticProps) _defineProperties$a(Constructor, staticProps);
|
18280 | return Constructor;
|
18281 | }
|
18282 |
|
18283 | var Table =
|
18284 |
|
18285 | function () {
|
18286 | function Table() {
|
18287 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
18288 |
|
18289 | _classCallCheck$b(this, Table);
|
18290 |
|
18291 | var injector = options.injector;
|
18292 |
|
18293 | if (!injector) {
|
18294 | var _this$_init = this._init(options),
|
18295 | modules = _this$_init.modules,
|
18296 | config = _this$_init.config;
|
18297 |
|
18298 | injector = createInjector$1(config, modules);
|
18299 | }
|
18300 |
|
18301 | this.get = injector.get;
|
18302 | this.invoke = injector.invoke;
|
18303 | this.get('eventBus').fire('table.init');
|
18304 | this.get('eventBus').fire('diagram.init');
|
18305 | }
|
18306 | |
18307 |
|
18308 |
|
18309 |
|
18310 |
|
18311 |
|
18312 |
|
18313 |
|
18314 |
|
18315 | _createClass$a(Table, [{
|
18316 | key: "_init",
|
18317 | value: function _init(options) {
|
18318 | var modules = options.modules,
|
18319 | config = _objectWithoutProperties$1(options, ["modules"]);
|
18320 |
|
18321 | return {
|
18322 | modules: modules,
|
18323 | config: config
|
18324 | };
|
18325 | }
|
18326 | |
18327 |
|
18328 |
|
18329 |
|
18330 | }, {
|
18331 | key: "destroy",
|
18332 | value: function destroy() {
|
18333 | var eventBus = this.get('eventBus');
|
18334 | eventBus.fire('table.destroy');
|
18335 | eventBus.fire('diagram.destroy');
|
18336 | }
|
18337 | |
18338 |
|
18339 |
|
18340 |
|
18341 | }, {
|
18342 | key: "clear",
|
18343 | value: function clear() {
|
18344 | var eventBus = this.get('eventBus');
|
18345 | eventBus.fire('table.clear');
|
18346 | eventBus.fire('diagram.clear');
|
18347 | }
|
18348 | }]);
|
18349 |
|
18350 | return Table;
|
18351 | }();
|
18352 |
|
18353 | function bootstrap$1(bootstrapModules) {
|
18354 | var modules = [],
|
18355 | components = [];
|
18356 |
|
18357 | function hasModule(m) {
|
18358 | return modules.indexOf(m) >= 0;
|
18359 | }
|
18360 |
|
18361 | function addModule(m) {
|
18362 | modules.push(m);
|
18363 | }
|
18364 |
|
18365 | function visit(m) {
|
18366 | if (hasModule(m)) {
|
18367 | return;
|
18368 | }
|
18369 |
|
18370 | (m.__depends__ || []).forEach(visit);
|
18371 |
|
18372 | if (hasModule(m)) {
|
18373 | return;
|
18374 | }
|
18375 |
|
18376 | addModule(m);
|
18377 | (m.__init__ || []).forEach(function (c) {
|
18378 | components.push(c);
|
18379 | });
|
18380 | }
|
18381 |
|
18382 | bootstrapModules.forEach(visit);
|
18383 | var injector = new Injector$1(modules);
|
18384 | components.forEach(function (c) {
|
18385 | try {
|
18386 |
|
18387 | injector[typeof c === 'string' ? 'get' : 'invoke'](c);
|
18388 | } catch (e) {
|
18389 | console.error('Failed to instantiate component');
|
18390 | console.error(e.stack);
|
18391 | throw e;
|
18392 | }
|
18393 | });
|
18394 | return injector;
|
18395 | }
|
18396 |
|
18397 | function createInjector$1(config, modules) {
|
18398 | var bootstrapModules = [{
|
18399 | config: ['value', config]
|
18400 | }, core].concat(modules || []);
|
18401 | return bootstrap$1(bootstrapModules);
|
18402 | }
|
18403 |
|
18404 | function elementToString(element) {
|
18405 | if (!element) {
|
18406 | return '<null>';
|
18407 | }
|
18408 |
|
18409 | var id = element.id ? " id=\"".concat(element.id, "\"") : '';
|
18410 | return "<".concat(element.$type).concat(id, " />");
|
18411 | }
|
18412 |
|
18413 | function TableTreeWalker(handler, options) {
|
18414 | function visit(element, ctx, definitions) {
|
18415 | var gfx = element.gfx;
|
18416 |
|
18417 | if (gfx) {
|
18418 | throw new Error("already rendered ".concat(elementToString(element)));
|
18419 | }
|
18420 |
|
18421 |
|
18422 | return handler.element(element, ctx, definitions);
|
18423 | }
|
18424 |
|
18425 | function visitTable(element) {
|
18426 | return handler.table(element);
|
18427 | }
|
18428 |
|
18429 |
|
18430 | function handleDecision(decision) {
|
18431 | if (!decision.id) {
|
18432 | decision.id = 'decision';
|
18433 | }
|
18434 |
|
18435 | var table = decision.decisionLogic;
|
18436 |
|
18437 | if (table) {
|
18438 | if (!table.output) {
|
18439 | throw new Error("missing output for ".concat(elementToString(table)));
|
18440 | }
|
18441 |
|
18442 | var ctx = visitTable(table);
|
18443 |
|
18444 | if (table.input) {
|
18445 | handleClauses(table.input, ctx, table);
|
18446 | }
|
18447 |
|
18448 | handleClauses(table.output, ctx, table);
|
18449 |
|
18450 |
|
18451 | handleRules(table.rule, ctx, table);
|
18452 | } else {
|
18453 | throw new Error("no table for ".concat(elementToString(decision)));
|
18454 | }
|
18455 | }
|
18456 |
|
18457 | function handleClauses(clauses, context, definitions) {
|
18458 | forEach(clauses, function (e) {
|
18459 | visit(e, context, definitions);
|
18460 | });
|
18461 | }
|
18462 |
|
18463 | function handleRules(rules, context, definitions) {
|
18464 | forEach(rules, function (e) {
|
18465 | visit(e, context, definitions);
|
18466 | handleEntry(e.inputEntry, e);
|
18467 | handleEntry(e.outputEntry, e);
|
18468 | });
|
18469 | }
|
18470 |
|
18471 | function handleEntry(entry, context, definitions) {
|
18472 | forEach(entry, function (e) {
|
18473 | visit(e, context, definitions);
|
18474 | });
|
18475 | }
|
18476 |
|
18477 |
|
18478 | return {
|
18479 | handleDecision: handleDecision
|
18480 | };
|
18481 | }
|
18482 |
|
18483 | |
18484 |
|
18485 |
|
18486 |
|
18487 |
|
18488 |
|
18489 |
|
18490 |
|
18491 |
|
18492 |
|
18493 |
|
18494 | function importDecision(decisionTable, decision, done) {
|
18495 | var importer = decisionTable.get('tableImporter'),
|
18496 | eventBus = decisionTable.get('eventBus'),
|
18497 | sheet = decisionTable.get('sheet');
|
18498 | var hasModeling = decisionTable.get('modeling', false);
|
18499 | var error,
|
18500 | warnings = [];
|
18501 |
|
18502 | function render(decision) {
|
18503 | var visitor = {
|
18504 | create: function create(type, parent, clause, rule) {
|
18505 | return importer.create(type, parent, clause, rule);
|
18506 | },
|
18507 | table: function table(element) {
|
18508 | return importer.add(element);
|
18509 | },
|
18510 | element: function element(_element, parentShape, definitions) {
|
18511 | return importer.add(_element, parentShape, definitions);
|
18512 | },
|
18513 | error: function error(message, context) {
|
18514 | warnings.push({
|
18515 | message: message,
|
18516 | context: context
|
18517 | });
|
18518 | }
|
18519 | };
|
18520 | var walker = new TableTreeWalker(visitor, {
|
18521 | canAddMissingEntries: hasModeling
|
18522 | });
|
18523 |
|
18524 | walker.handleDecision(decision);
|
18525 | }
|
18526 |
|
18527 | eventBus.fire('import.render.start', {
|
18528 | decision: decision
|
18529 | });
|
18530 |
|
18531 | try {
|
18532 | render(decision);
|
18533 | } catch (e) {
|
18534 | error = e;
|
18535 | }
|
18536 |
|
18537 | eventBus.fire('import.render.complete', {
|
18538 | error: error,
|
18539 | warnings: warnings
|
18540 | });
|
18541 | eventBus.fire('elements.changed', {
|
18542 | elements: [sheet.getRoot()]
|
18543 | });
|
18544 | done(error, warnings);
|
18545 | }
|
18546 |
|
18547 | function _typeof$6(obj) {
|
18548 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
18549 | _typeof$6 = function _typeof$1(obj) {
|
18550 | return _typeof(obj);
|
18551 | };
|
18552 | } else {
|
18553 | _typeof$6 = function _typeof$1(obj) {
|
18554 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
18555 | };
|
18556 | }
|
18557 |
|
18558 | return _typeof$6(obj);
|
18559 | }
|
18560 |
|
18561 | function ownKeys$2(object, enumerableOnly) {
|
18562 | var keys = Object.keys(object);
|
18563 |
|
18564 | if (Object.getOwnPropertySymbols) {
|
18565 | keys.push.apply(keys, Object.getOwnPropertySymbols(object));
|
18566 | }
|
18567 |
|
18568 | if (enumerableOnly) keys = keys.filter(function (sym) {
|
18569 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
18570 | });
|
18571 | return keys;
|
18572 | }
|
18573 |
|
18574 | function _objectSpread$2(target) {
|
18575 | for (var i = 1; i < arguments.length; i++) {
|
18576 | var source = arguments[i] != null ? arguments[i] : {};
|
18577 |
|
18578 | if (i % 2) {
|
18579 | ownKeys$2(source, true).forEach(function (key) {
|
18580 | _defineProperty$2(target, key, source[key]);
|
18581 | });
|
18582 | } else if (Object.getOwnPropertyDescriptors) {
|
18583 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
18584 | } else {
|
18585 | ownKeys$2(source).forEach(function (key) {
|
18586 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
18587 | });
|
18588 | }
|
18589 | }
|
18590 |
|
18591 | return target;
|
18592 | }
|
18593 |
|
18594 | function _defineProperty$2(obj, key, value) {
|
18595 | if (key in obj) {
|
18596 | Object.defineProperty(obj, key, {
|
18597 | value: value,
|
18598 | enumerable: true,
|
18599 | configurable: true,
|
18600 | writable: true
|
18601 | });
|
18602 | } else {
|
18603 | obj[key] = value;
|
18604 | }
|
18605 |
|
18606 | return obj;
|
18607 | }
|
18608 |
|
18609 | function _toConsumableArray$4(arr) {
|
18610 | return _arrayWithoutHoles$2(arr) || _iterableToArray$2(arr) || _nonIterableSpread$2();
|
18611 | }
|
18612 |
|
18613 | function _nonIterableSpread$2() {
|
18614 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
18615 | }
|
18616 |
|
18617 | function _iterableToArray$2(iter) {
|
18618 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
18619 | }
|
18620 |
|
18621 | function _arrayWithoutHoles$2(arr) {
|
18622 | if (Array.isArray(arr)) {
|
18623 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
18624 | arr2[i] = arr[i];
|
18625 | }
|
18626 |
|
18627 | return arr2;
|
18628 | }
|
18629 | }
|
18630 |
|
18631 | function newSet() {
|
18632 | return {
|
18633 | elements: [],
|
18634 | index: {}
|
18635 | };
|
18636 | }
|
18637 |
|
18638 | function add$1(set, element) {
|
18639 | var elements = set.elements,
|
18640 | index = set.index;
|
18641 |
|
18642 | if (index[element]) {
|
18643 | return set;
|
18644 | } else {
|
18645 | return {
|
18646 | elements: [].concat(_toConsumableArray$4(elements), [element]),
|
18647 | index: _objectSpread$2({}, index, _defineProperty$2({}, element, true))
|
18648 | };
|
18649 | }
|
18650 | }
|
18651 |
|
18652 | function join(set, separator) {
|
18653 | return set.elements.join(separator);
|
18654 | }
|
18655 |
|
18656 | function classNames() {
|
18657 | var set = newSet();
|
18658 |
|
18659 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
18660 | args[_key] = arguments[_key];
|
18661 | }
|
18662 |
|
18663 | args.forEach(function (item) {
|
18664 | var type = _typeof$6(item);
|
18665 |
|
18666 | if (type === 'string' && item.length > 0) {
|
18667 | set = add$1(set, item);
|
18668 | } else if (type === 'object' && item !== null) {
|
18669 | Object.keys(item).forEach(function (key) {
|
18670 | var value = item[key];
|
18671 |
|
18672 | if (value) {
|
18673 | set = add$1(set, key);
|
18674 | }
|
18675 | });
|
18676 | }
|
18677 | });
|
18678 | return join(set, ' ');
|
18679 | }
|
18680 |
|
18681 | function _toConsumableArray$5(arr) {
|
18682 | return _arrayWithoutHoles$3(arr) || _iterableToArray$3(arr) || _nonIterableSpread$3();
|
18683 | }
|
18684 |
|
18685 | function _nonIterableSpread$3() {
|
18686 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
18687 | }
|
18688 |
|
18689 | function _iterableToArray$3(iter) {
|
18690 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
18691 | }
|
18692 |
|
18693 | function _arrayWithoutHoles$3(arr) {
|
18694 | if (Array.isArray(arr)) {
|
18695 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
18696 | arr2[i] = arr[i];
|
18697 | }
|
18698 |
|
18699 | return arr2;
|
18700 | }
|
18701 | }
|
18702 |
|
18703 | function inject(component) {
|
18704 | var Type = component.constructor;
|
18705 | return injectType(Type, component);
|
18706 | }
|
18707 | function injectType(Type, component) {
|
18708 | var annotation = Type.$inject;
|
18709 |
|
18710 | if (!annotation) {
|
18711 | return;
|
18712 | }
|
18713 |
|
18714 | var injector = component.context.injector;
|
18715 | var setupFn = [].concat(_toConsumableArray$5(annotation), [function () {
|
18716 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
18717 | args[_key] = arguments[_key];
|
18718 | }
|
18719 |
|
18720 | for (var idx in args) {
|
18721 | var name = annotation[idx];
|
18722 | var value = args[idx];
|
18723 | component[name] = value;
|
18724 | }
|
18725 | }]);
|
18726 | injector.invoke(setupFn);
|
18727 | }
|
18728 |
|
18729 | |
18730 |
|
18731 |
|
18732 |
|
18733 |
|
18734 |
|
18735 |
|
18736 |
|
18737 |
|
18738 |
|
18739 |
|
18740 | function compose(self) {
|
18741 | for (var _len = arguments.length, fns = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
18742 | fns[_key - 1] = arguments[_key];
|
18743 | }
|
18744 |
|
18745 | return function () {
|
18746 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
18747 | args[_key2] = arguments[_key2];
|
18748 | }
|
18749 |
|
18750 | var result;
|
18751 | fns.forEach(function (fn) {
|
18752 | result = fn.call.apply(fn, [self].concat(args));
|
18753 |
|
18754 | if (typeof result !== 'undefined') {
|
18755 | return false;
|
18756 | }
|
18757 | });
|
18758 | return result;
|
18759 | }.bind(self);
|
18760 | }
|
18761 |
|
18762 | |
18763 |
|
18764 |
|
18765 |
|
18766 |
|
18767 |
|
18768 |
|
18769 | function mixin(component, mixinDef) {
|
18770 | Object.keys(mixinDef).forEach(function (key) {
|
18771 | if (key === '$inject' || key === '__init') {
|
18772 | return;
|
18773 | }
|
18774 |
|
18775 | var mixinFn = mixinDef[key];
|
18776 |
|
18777 | if (key === 'constructor') {
|
18778 | mixinFn.call(component, component.props, component.context);
|
18779 | }
|
18780 |
|
18781 | var componentFn = component[key];
|
18782 |
|
18783 | if (typeof componentFn !== 'undefined') {
|
18784 | if (typeof componentFn !== 'function') {
|
18785 | throw new Error("failed to mixin <".concat(key, ">: cannot combine with non-fn component value"));
|
18786 | }
|
18787 |
|
18788 | component[key] = compose(component, componentFn, mixinFn);
|
18789 | } else {
|
18790 | component[key] = mixinFn.bind(component);
|
18791 | }
|
18792 | });
|
18793 |
|
18794 | if ('$inject' in mixinDef) {
|
18795 | injectType(mixinDef, component);
|
18796 | }
|
18797 |
|
18798 |
|
18799 | if ('__init' in mixinDef) {
|
18800 | mixinDef.__init.call(component, component.props, component.context);
|
18801 | }
|
18802 | }
|
18803 |
|
18804 | |
18805 |
|
18806 |
|
18807 |
|
18808 | var SelectionAware = {
|
18809 | getSelectionClasses: function getSelectionClasses() {
|
18810 | var _this$state = this.state,
|
18811 | selected = _this$state.selected,
|
18812 | selectedSecondary = _this$state.selectedSecondary,
|
18813 | focussed = _this$state.focussed;
|
18814 | return classNames({
|
18815 | 'selected': selected,
|
18816 | 'selected-secondary': selectedSecondary,
|
18817 | 'focussed': focussed
|
18818 | });
|
18819 | },
|
18820 | selectionChanged: function selectionChanged(newSelection) {
|
18821 |
|
18822 | this.setState(newSelection);
|
18823 | },
|
18824 | componentWillUpdate: function componentWillUpdate(newProps) {
|
18825 | if (newProps.elementId !== this.props.elementId) {
|
18826 | this.updateSelectionSubscription(false);
|
18827 | }
|
18828 | },
|
18829 | componentDidUpdate: function componentDidUpdate(oldProps) {
|
18830 | if (oldProps.elementId !== this.props.elementId) {
|
18831 | this.updateSelectionSubscription(true);
|
18832 | }
|
18833 | },
|
18834 | componentDidMount: function componentDidMount() {
|
18835 | this.updateSelectionSubscription(true);
|
18836 | },
|
18837 | componentWillUnmount: function componentWillUnmount() {
|
18838 | this.updateSelectionSubscription(false);
|
18839 | },
|
18840 | updateSelectionSubscription: function updateSelectionSubscription(enable) {
|
18841 | var elementId = this.props.elementId;
|
18842 |
|
18843 | if (!elementId) {
|
18844 | return;
|
18845 | }
|
18846 |
|
18847 | if (elementId) {
|
18848 | this.eventBus[enable ? 'on' : 'off']("selection.".concat(elementId, ".changed"), this.selectionChanged);
|
18849 | }
|
18850 | }
|
18851 | };
|
18852 | SelectionAware.$inject = ['eventBus'];
|
18853 |
|
18854 | function _typeof$7(obj) {
|
18855 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
18856 | _typeof$7 = function _typeof$1(obj) {
|
18857 | return _typeof(obj);
|
18858 | };
|
18859 | } else {
|
18860 | _typeof$7 = function _typeof$1(obj) {
|
18861 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
18862 | };
|
18863 | }
|
18864 |
|
18865 | return _typeof$7(obj);
|
18866 | }
|
18867 |
|
18868 | function ownKeys$3(object, enumerableOnly) {
|
18869 | var keys = Object.keys(object);
|
18870 |
|
18871 | if (Object.getOwnPropertySymbols) {
|
18872 | keys.push.apply(keys, Object.getOwnPropertySymbols(object));
|
18873 | }
|
18874 |
|
18875 | if (enumerableOnly) keys = keys.filter(function (sym) {
|
18876 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
18877 | });
|
18878 | return keys;
|
18879 | }
|
18880 |
|
18881 | function _objectSpread$3(target) {
|
18882 | for (var i = 1; i < arguments.length; i++) {
|
18883 | var source = arguments[i] != null ? arguments[i] : {};
|
18884 |
|
18885 | if (i % 2) {
|
18886 | ownKeys$3(source, true).forEach(function (key) {
|
18887 | _defineProperty$3(target, key, source[key]);
|
18888 | });
|
18889 | } else if (Object.getOwnPropertyDescriptors) {
|
18890 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
18891 | } else {
|
18892 | ownKeys$3(source).forEach(function (key) {
|
18893 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
18894 | });
|
18895 | }
|
18896 | }
|
18897 |
|
18898 | return target;
|
18899 | }
|
18900 |
|
18901 | function _defineProperty$3(obj, key, value) {
|
18902 | if (key in obj) {
|
18903 | Object.defineProperty(obj, key, {
|
18904 | value: value,
|
18905 | enumerable: true,
|
18906 | configurable: true,
|
18907 | writable: true
|
18908 | });
|
18909 | } else {
|
18910 | obj[key] = value;
|
18911 | }
|
18912 |
|
18913 | return obj;
|
18914 | }
|
18915 |
|
18916 | function _objectWithoutProperties$2(source, excluded) {
|
18917 | if (source == null) return {};
|
18918 |
|
18919 | var target = _objectWithoutPropertiesLoose$2(source, excluded);
|
18920 |
|
18921 | var key, i;
|
18922 |
|
18923 | if (Object.getOwnPropertySymbols) {
|
18924 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
18925 |
|
18926 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
18927 | key = sourceSymbolKeys[i];
|
18928 | if (excluded.indexOf(key) >= 0) continue;
|
18929 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
18930 | target[key] = source[key];
|
18931 | }
|
18932 | }
|
18933 |
|
18934 | return target;
|
18935 | }
|
18936 |
|
18937 | function _objectWithoutPropertiesLoose$2(source, excluded) {
|
18938 | if (source == null) return {};
|
18939 | var target = {};
|
18940 | var sourceKeys = Object.keys(source);
|
18941 | var key, i;
|
18942 |
|
18943 | for (i = 0; i < sourceKeys.length; i++) {
|
18944 | key = sourceKeys[i];
|
18945 | if (excluded.indexOf(key) >= 0) continue;
|
18946 | target[key] = source[key];
|
18947 | }
|
18948 |
|
18949 | return target;
|
18950 | }
|
18951 |
|
18952 | function _classCallCheck$c(instance, Constructor) {
|
18953 | if (!(instance instanceof Constructor)) {
|
18954 | throw new TypeError("Cannot call a class as a function");
|
18955 | }
|
18956 | }
|
18957 |
|
18958 | function _defineProperties$b(target, props) {
|
18959 | for (var i = 0; i < props.length; i++) {
|
18960 | var descriptor = props[i];
|
18961 | descriptor.enumerable = descriptor.enumerable || false;
|
18962 | descriptor.configurable = true;
|
18963 | if ("value" in descriptor) descriptor.writable = true;
|
18964 | Object.defineProperty(target, descriptor.key, descriptor);
|
18965 | }
|
18966 | }
|
18967 |
|
18968 | function _createClass$b(Constructor, protoProps, staticProps) {
|
18969 | if (protoProps) _defineProperties$b(Constructor.prototype, protoProps);
|
18970 | if (staticProps) _defineProperties$b(Constructor, staticProps);
|
18971 | return Constructor;
|
18972 | }
|
18973 |
|
18974 | function _possibleConstructorReturn$3(self, call) {
|
18975 | if (call && (_typeof$7(call) === "object" || typeof call === "function")) {
|
18976 | return call;
|
18977 | }
|
18978 |
|
18979 | return _assertThisInitialized$3(self);
|
18980 | }
|
18981 |
|
18982 | function _getPrototypeOf$3(o) {
|
18983 | _getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
18984 | return o.__proto__ || Object.getPrototypeOf(o);
|
18985 | };
|
18986 | return _getPrototypeOf$3(o);
|
18987 | }
|
18988 |
|
18989 | function _assertThisInitialized$3(self) {
|
18990 | if (self === void 0) {
|
18991 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
18992 | }
|
18993 |
|
18994 | return self;
|
18995 | }
|
18996 |
|
18997 | function _inherits$3(subClass, superClass) {
|
18998 | if (typeof superClass !== "function" && superClass !== null) {
|
18999 | throw new TypeError("Super expression must either be null or a function");
|
19000 | }
|
19001 |
|
19002 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
19003 | constructor: {
|
19004 | value: subClass,
|
19005 | writable: true,
|
19006 | configurable: true
|
19007 | }
|
19008 | });
|
19009 | if (superClass) _setPrototypeOf$3(subClass, superClass);
|
19010 | }
|
19011 |
|
19012 | function _setPrototypeOf$3(o, p) {
|
19013 | _setPrototypeOf$3 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
19014 | o.__proto__ = p;
|
19015 | return o;
|
19016 | };
|
19017 |
|
19018 | return _setPrototypeOf$3(o, p);
|
19019 | }
|
19020 |
|
19021 | var BaseCell =
|
19022 |
|
19023 | function (_Component) {
|
19024 | _inherits$3(BaseCell, _Component);
|
19025 |
|
19026 | function BaseCell(props, context) {
|
19027 | var _this;
|
19028 |
|
19029 | _classCallCheck$c(this, BaseCell);
|
19030 |
|
19031 | _this = _possibleConstructorReturn$3(this, _getPrototypeOf$3(BaseCell).call(this, props, context));
|
19032 | mixin(_assertThisInitialized$3(_this), SelectionAware);
|
19033 | inject(_assertThisInitialized$3(_this));
|
19034 | return _this;
|
19035 | }
|
19036 |
|
19037 | _createClass$b(BaseCell, [{
|
19038 | key: "getRenderProps",
|
19039 | value: function getRenderProps() {
|
19040 | var _this$props = this.props,
|
19041 | className = _this$props.className,
|
19042 | elementId = _this$props.elementId,
|
19043 | coords = _this$props.coords,
|
19044 | props = _objectWithoutProperties$2(_this$props, ["className", "elementId", "coords"]);
|
19045 |
|
19046 | for (var _len = arguments.length, cls = new Array(_len), _key = 0; _key < _len; _key++) {
|
19047 | cls[_key] = arguments[_key];
|
19048 | }
|
19049 |
|
19050 | var baseProps = {
|
19051 | className: classNames.apply(void 0, cls.concat([this.getSelectionClasses(), className]))
|
19052 | };
|
19053 |
|
19054 | if (elementId) {
|
19055 | baseProps['data-element-id'] = elementId;
|
19056 | }
|
19057 |
|
19058 | if (coords) {
|
19059 | baseProps['data-coords'] = coords;
|
19060 | }
|
19061 |
|
19062 | return _objectSpread$3({}, baseProps, {}, props);
|
19063 | }
|
19064 | }]);
|
19065 |
|
19066 | return BaseCell;
|
19067 | }(Component);
|
19068 |
|
19069 | function _typeof$8(obj) {
|
19070 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
19071 | _typeof$8 = function _typeof$1(obj) {
|
19072 | return _typeof(obj);
|
19073 | };
|
19074 | } else {
|
19075 | _typeof$8 = function _typeof$1(obj) {
|
19076 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
19077 | };
|
19078 | }
|
19079 |
|
19080 | return _typeof$8(obj);
|
19081 | }
|
19082 |
|
19083 | function ownKeys$4(object, enumerableOnly) {
|
19084 | var keys = Object.keys(object);
|
19085 |
|
19086 | if (Object.getOwnPropertySymbols) {
|
19087 | keys.push.apply(keys, Object.getOwnPropertySymbols(object));
|
19088 | }
|
19089 |
|
19090 | if (enumerableOnly) keys = keys.filter(function (sym) {
|
19091 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
19092 | });
|
19093 | return keys;
|
19094 | }
|
19095 |
|
19096 | function _objectSpread$4(target) {
|
19097 | for (var i = 1; i < arguments.length; i++) {
|
19098 | var source = arguments[i] != null ? arguments[i] : {};
|
19099 |
|
19100 | if (i % 2) {
|
19101 | ownKeys$4(source, true).forEach(function (key) {
|
19102 | _defineProperty$4(target, key, source[key]);
|
19103 | });
|
19104 | } else if (Object.getOwnPropertyDescriptors) {
|
19105 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
19106 | } else {
|
19107 | ownKeys$4(source).forEach(function (key) {
|
19108 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
19109 | });
|
19110 | }
|
19111 | }
|
19112 |
|
19113 | return target;
|
19114 | }
|
19115 |
|
19116 | function _defineProperty$4(obj, key, value) {
|
19117 | if (key in obj) {
|
19118 | Object.defineProperty(obj, key, {
|
19119 | value: value,
|
19120 | enumerable: true,
|
19121 | configurable: true,
|
19122 | writable: true
|
19123 | });
|
19124 | } else {
|
19125 | obj[key] = value;
|
19126 | }
|
19127 |
|
19128 | return obj;
|
19129 | }
|
19130 |
|
19131 | function _classCallCheck$d(instance, Constructor) {
|
19132 | if (!(instance instanceof Constructor)) {
|
19133 | throw new TypeError("Cannot call a class as a function");
|
19134 | }
|
19135 | }
|
19136 |
|
19137 | function _defineProperties$c(target, props) {
|
19138 | for (var i = 0; i < props.length; i++) {
|
19139 | var descriptor = props[i];
|
19140 | descriptor.enumerable = descriptor.enumerable || false;
|
19141 | descriptor.configurable = true;
|
19142 | if ("value" in descriptor) descriptor.writable = true;
|
19143 | Object.defineProperty(target, descriptor.key, descriptor);
|
19144 | }
|
19145 | }
|
19146 |
|
19147 | function _createClass$c(Constructor, protoProps, staticProps) {
|
19148 | if (protoProps) _defineProperties$c(Constructor.prototype, protoProps);
|
19149 | if (staticProps) _defineProperties$c(Constructor, staticProps);
|
19150 | return Constructor;
|
19151 | }
|
19152 |
|
19153 | function _possibleConstructorReturn$4(self, call) {
|
19154 | if (call && (_typeof$8(call) === "object" || typeof call === "function")) {
|
19155 | return call;
|
19156 | }
|
19157 |
|
19158 | return _assertThisInitialized$4(self);
|
19159 | }
|
19160 |
|
19161 | function _assertThisInitialized$4(self) {
|
19162 | if (self === void 0) {
|
19163 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
19164 | }
|
19165 |
|
19166 | return self;
|
19167 | }
|
19168 |
|
19169 | function _getPrototypeOf$4(o) {
|
19170 | _getPrototypeOf$4 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
19171 | return o.__proto__ || Object.getPrototypeOf(o);
|
19172 | };
|
19173 | return _getPrototypeOf$4(o);
|
19174 | }
|
19175 |
|
19176 | function _inherits$4(subClass, superClass) {
|
19177 | if (typeof superClass !== "function" && superClass !== null) {
|
19178 | throw new TypeError("Super expression must either be null or a function");
|
19179 | }
|
19180 |
|
19181 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
19182 | constructor: {
|
19183 | value: subClass,
|
19184 | writable: true,
|
19185 | configurable: true
|
19186 | }
|
19187 | });
|
19188 | if (superClass) _setPrototypeOf$4(subClass, superClass);
|
19189 | }
|
19190 |
|
19191 | function _setPrototypeOf$4(o, p) {
|
19192 | _setPrototypeOf$4 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
19193 | o.__proto__ = p;
|
19194 | return o;
|
19195 | };
|
19196 |
|
19197 | return _setPrototypeOf$4(o, p);
|
19198 | }
|
19199 |
|
19200 | var HeaderCell =
|
19201 |
|
19202 | function (_BaseCell) {
|
19203 | _inherits$4(HeaderCell, _BaseCell);
|
19204 |
|
19205 | function HeaderCell(props, context) {
|
19206 | var _this;
|
19207 |
|
19208 | _classCallCheck$d(this, HeaderCell);
|
19209 |
|
19210 | _this = _possibleConstructorReturn$4(this, _getPrototypeOf$4(HeaderCell).call(this, props, context));
|
19211 | _this.state = {};
|
19212 | return _this;
|
19213 | }
|
19214 |
|
19215 | _createClass$c(HeaderCell, [{
|
19216 | key: "render",
|
19217 | value: function render() {
|
19218 | var children = this.props.children;
|
19219 | var props = this.getRenderProps('cell');
|
19220 | return normalizeProps(createVNode(1, "td", null, children, 0, _objectSpread$4({}, props)));
|
19221 | }
|
19222 | }]);
|
19223 |
|
19224 | return HeaderCell;
|
19225 | }(BaseCell);
|
19226 |
|
19227 | function ownKeys$5(object, enumerableOnly) {
|
19228 | var keys = Object.keys(object);
|
19229 |
|
19230 | if (Object.getOwnPropertySymbols) {
|
19231 | var symbols = Object.getOwnPropertySymbols(object);
|
19232 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
19233 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
19234 | });
|
19235 | keys.push.apply(keys, symbols);
|
19236 | }
|
19237 |
|
19238 | return keys;
|
19239 | }
|
19240 |
|
19241 | function _objectSpread$5(target) {
|
19242 | for (var i = 1; i < arguments.length; i++) {
|
19243 | var source = arguments[i] != null ? arguments[i] : {};
|
19244 |
|
19245 | if (i % 2) {
|
19246 | ownKeys$5(source, true).forEach(function (key) {
|
19247 | _defineProperty$5(target, key, source[key]);
|
19248 | });
|
19249 | } else if (Object.getOwnPropertyDescriptors) {
|
19250 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
19251 | } else {
|
19252 | ownKeys$5(source).forEach(function (key) {
|
19253 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
19254 | });
|
19255 | }
|
19256 | }
|
19257 |
|
19258 | return target;
|
19259 | }
|
19260 |
|
19261 | function _defineProperty$5(obj, key, value) {
|
19262 | if (key in obj) {
|
19263 | Object.defineProperty(obj, key, {
|
19264 | value: value,
|
19265 | enumerable: true,
|
19266 | configurable: true,
|
19267 | writable: true
|
19268 | });
|
19269 | } else {
|
19270 | obj[key] = value;
|
19271 | }
|
19272 |
|
19273 | return obj;
|
19274 | }
|
19275 |
|
19276 | function _objectWithoutProperties$3(source, excluded) {
|
19277 | if (source == null) return {};
|
19278 |
|
19279 | var target = _objectWithoutPropertiesLoose$3(source, excluded);
|
19280 |
|
19281 | var key, i;
|
19282 |
|
19283 | if (Object.getOwnPropertySymbols) {
|
19284 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
19285 |
|
19286 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
19287 | key = sourceSymbolKeys[i];
|
19288 | if (excluded.indexOf(key) >= 0) continue;
|
19289 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
19290 | target[key] = source[key];
|
19291 | }
|
19292 | }
|
19293 |
|
19294 | return target;
|
19295 | }
|
19296 |
|
19297 | function _objectWithoutPropertiesLoose$3(source, excluded) {
|
19298 | if (source == null) return {};
|
19299 | var target = {};
|
19300 | var sourceKeys = Object.keys(source);
|
19301 | var key, i;
|
19302 |
|
19303 | for (i = 0; i < sourceKeys.length; i++) {
|
19304 | key = sourceKeys[i];
|
19305 | if (excluded.indexOf(key) >= 0) continue;
|
19306 | target[key] = source[key];
|
19307 | }
|
19308 |
|
19309 | return target;
|
19310 | }
|
19311 | |
19312 |
|
19313 |
|
19314 |
|
19315 |
|
19316 |
|
19317 |
|
19318 | var ComponentWithSlots = {
|
19319 | slotFill: function slotFill(slotProps, DefaultFill) {
|
19320 | var type = slotProps.type,
|
19321 | context = slotProps.context,
|
19322 | props = _objectWithoutProperties$3(slotProps, ["type", "context"]);
|
19323 |
|
19324 | var Fill = this.components.getComponent(type, context) || DefaultFill;
|
19325 |
|
19326 | if (Fill) {
|
19327 | return normalizeProps(createComponentVNode(2, Fill, _objectSpread$5({}, context, {}, props)));
|
19328 | }
|
19329 |
|
19330 | return null;
|
19331 | },
|
19332 | slotFills: function slotFills(slotProps) {
|
19333 | var type = slotProps.type,
|
19334 | context = slotProps.context,
|
19335 | props = _objectWithoutProperties$3(slotProps, ["type", "context"]);
|
19336 |
|
19337 | var fills = this.components.getComponents(type, context);
|
19338 | return fills.map(function (Fill) {
|
19339 | return normalizeProps(createComponentVNode(2, Fill, _objectSpread$5({}, context, {}, props)));
|
19340 | });
|
19341 | }
|
19342 | };
|
19343 | ComponentWithSlots.$inject = ['components'];
|
19344 |
|
19345 | function _typeof$9(obj) {
|
19346 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
19347 | _typeof$9 = function _typeof$1(obj) {
|
19348 | return _typeof(obj);
|
19349 | };
|
19350 | } else {
|
19351 | _typeof$9 = function _typeof$1(obj) {
|
19352 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
19353 | };
|
19354 | }
|
19355 |
|
19356 | return _typeof$9(obj);
|
19357 | }
|
19358 |
|
19359 | function _classCallCheck$e(instance, Constructor) {
|
19360 | if (!(instance instanceof Constructor)) {
|
19361 | throw new TypeError("Cannot call a class as a function");
|
19362 | }
|
19363 | }
|
19364 |
|
19365 | function _defineProperties$d(target, props) {
|
19366 | for (var i = 0; i < props.length; i++) {
|
19367 | var descriptor = props[i];
|
19368 | descriptor.enumerable = descriptor.enumerable || false;
|
19369 | descriptor.configurable = true;
|
19370 | if ("value" in descriptor) descriptor.writable = true;
|
19371 | Object.defineProperty(target, descriptor.key, descriptor);
|
19372 | }
|
19373 | }
|
19374 |
|
19375 | function _createClass$d(Constructor, protoProps, staticProps) {
|
19376 | if (protoProps) _defineProperties$d(Constructor.prototype, protoProps);
|
19377 | if (staticProps) _defineProperties$d(Constructor, staticProps);
|
19378 | return Constructor;
|
19379 | }
|
19380 |
|
19381 | function _possibleConstructorReturn$5(self, call) {
|
19382 | if (call && (_typeof$9(call) === "object" || typeof call === "function")) {
|
19383 | return call;
|
19384 | }
|
19385 |
|
19386 | return _assertThisInitialized$5(self);
|
19387 | }
|
19388 |
|
19389 | function _getPrototypeOf$5(o) {
|
19390 | _getPrototypeOf$5 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
19391 | return o.__proto__ || Object.getPrototypeOf(o);
|
19392 | };
|
19393 | return _getPrototypeOf$5(o);
|
19394 | }
|
19395 |
|
19396 | function _assertThisInitialized$5(self) {
|
19397 | if (self === void 0) {
|
19398 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
19399 | }
|
19400 |
|
19401 | return self;
|
19402 | }
|
19403 |
|
19404 | function _inherits$5(subClass, superClass) {
|
19405 | if (typeof superClass !== "function" && superClass !== null) {
|
19406 | throw new TypeError("Super expression must either be null or a function");
|
19407 | }
|
19408 |
|
19409 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
19410 | constructor: {
|
19411 | value: subClass,
|
19412 | writable: true,
|
19413 | configurable: true
|
19414 | }
|
19415 | });
|
19416 | if (superClass) _setPrototypeOf$5(subClass, superClass);
|
19417 | }
|
19418 |
|
19419 | function _setPrototypeOf$5(o, p) {
|
19420 | _setPrototypeOf$5 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
19421 | o.__proto__ = p;
|
19422 | return o;
|
19423 | };
|
19424 |
|
19425 | return _setPrototypeOf$5(o, p);
|
19426 | }
|
19427 |
|
19428 | function _defineProperty$6(obj, key, value) {
|
19429 | if (key in obj) {
|
19430 | Object.defineProperty(obj, key, {
|
19431 | value: value,
|
19432 | enumerable: true,
|
19433 | configurable: true,
|
19434 | writable: true
|
19435 | });
|
19436 | } else {
|
19437 | obj[key] = value;
|
19438 | }
|
19439 |
|
19440 | return obj;
|
19441 | }
|
19442 | var MIN_WIDTH = 400;
|
19443 |
|
19444 | var AnnotationHeader =
|
19445 |
|
19446 | function (_Component) {
|
19447 | _inherits$5(AnnotationHeader, _Component);
|
19448 |
|
19449 | function AnnotationHeader(props, context) {
|
19450 | var _this;
|
19451 |
|
19452 | _classCallCheck$e(this, AnnotationHeader);
|
19453 |
|
19454 | _this = _possibleConstructorReturn$5(this, _getPrototypeOf$5(AnnotationHeader).call(this, props, context));
|
19455 |
|
19456 | _defineProperty$6(_assertThisInitialized$5(_this), "onElementsChanged", function () {
|
19457 | _this.forceUpdate();
|
19458 | });
|
19459 |
|
19460 | mixin(_assertThisInitialized$5(_this), ComponentWithSlots);
|
19461 | inject(_assertThisInitialized$5(_this));
|
19462 | return _this;
|
19463 | }
|
19464 |
|
19465 | _createClass$d(AnnotationHeader, [{
|
19466 | key: "componentDidMount",
|
19467 | value: function componentDidMount() {
|
19468 | this.changeSupport.onElementsChanged(this.getRoot(), this.onElementsChanged);
|
19469 | }
|
19470 | }, {
|
19471 | key: "componentWillUnmount",
|
19472 | value: function componentWillUnmount() {
|
19473 | this.changeSupport.offElementsChanged(this.getRoot(), this.onElementsChanged);
|
19474 | }
|
19475 | }, {
|
19476 | key: "getRoot",
|
19477 | value: function getRoot() {
|
19478 | return this.sheet.getRoot();
|
19479 | }
|
19480 | }, {
|
19481 | key: "render",
|
19482 | value: function render() {
|
19483 | var decisionTable = this.getRoot();
|
19484 | var annotationsWidth = decisionTable.businessObject.get('annotationsWidth');
|
19485 | var width = (annotationsWidth || MIN_WIDTH) + 'px';
|
19486 | return createVNode(1, "th", "annotation header", [this.slotFills({
|
19487 | type: 'cell-inner',
|
19488 | context: {
|
19489 | cellType: 'annotations',
|
19490 | col: this.sheet.getRoot(),
|
19491 | minWidth: MIN_WIDTH
|
19492 | }
|
19493 | }), this.translate('Annotations')], 0, {
|
19494 | "style": {
|
19495 | width: width
|
19496 | }
|
19497 | });
|
19498 | }
|
19499 | }]);
|
19500 |
|
19501 | return AnnotationHeader;
|
19502 | }(Component);
|
19503 | AnnotationHeader.$inject = ['changeSupport', 'sheet', 'translate'];
|
19504 |
|
19505 | function AnnotationCell(props) {
|
19506 | var row = props.row;
|
19507 | var _row$businessObject = row.businessObject,
|
19508 | id = _row$businessObject.id,
|
19509 | description = _row$businessObject.description;
|
19510 | return createComponentVNode(2, HeaderCell, {
|
19511 | "className": "annotation",
|
19512 | "elementId": id + '__annotation',
|
19513 | children: description || '-'
|
19514 | });
|
19515 | }
|
19516 |
|
19517 | function AnnotationsProvider(components) {
|
19518 | components.onGetComponent('cell', function (_ref) {
|
19519 | var cellType = _ref.cellType;
|
19520 |
|
19521 | if (cellType === 'after-label-cells') {
|
19522 | return AnnotationHeader;
|
19523 | } else if (cellType === 'after-rule-cells') {
|
19524 | return AnnotationCell;
|
19525 | }
|
19526 | });
|
19527 | }
|
19528 | AnnotationsProvider.$inject = ['components'];
|
19529 |
|
19530 | var annotationsModule = {
|
19531 | __init__: ['annotationsProvider'],
|
19532 | annotationsProvider: ['type', AnnotationsProvider]
|
19533 | };
|
19534 |
|
19535 | function _toConsumableArray$6(arr) {
|
19536 | return _arrayWithoutHoles$4(arr) || _iterableToArray$4(arr) || _nonIterableSpread$4();
|
19537 | }
|
19538 |
|
19539 | function _nonIterableSpread$4() {
|
19540 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
19541 | }
|
19542 |
|
19543 | function _iterableToArray$4(iter) {
|
19544 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
19545 | }
|
19546 |
|
19547 | function _arrayWithoutHoles$4(arr) {
|
19548 | if (Array.isArray(arr)) {
|
19549 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
19550 | arr2[i] = arr[i];
|
19551 | }
|
19552 |
|
19553 | return arr2;
|
19554 | }
|
19555 | }
|
19556 |
|
19557 | function _classCallCheck$f(instance, Constructor) {
|
19558 | if (!(instance instanceof Constructor)) {
|
19559 | throw new TypeError("Cannot call a class as a function");
|
19560 | }
|
19561 | }
|
19562 |
|
19563 | function _defineProperties$e(target, props) {
|
19564 | for (var i = 0; i < props.length; i++) {
|
19565 | var descriptor = props[i];
|
19566 | descriptor.enumerable = descriptor.enumerable || false;
|
19567 | descriptor.configurable = true;
|
19568 | if ("value" in descriptor) descriptor.writable = true;
|
19569 | Object.defineProperty(target, descriptor.key, descriptor);
|
19570 | }
|
19571 | }
|
19572 |
|
19573 | function _createClass$e(Constructor, protoProps, staticProps) {
|
19574 | if (protoProps) _defineProperties$e(Constructor.prototype, protoProps);
|
19575 | if (staticProps) _defineProperties$e(Constructor, staticProps);
|
19576 | return Constructor;
|
19577 | }
|
19578 |
|
19579 | function elementData$1(semantic, attrs) {
|
19580 | return assign({
|
19581 | id: semantic.id,
|
19582 | type: semantic.$type,
|
19583 | businessObject: semantic
|
19584 | }, attrs);
|
19585 | }
|
19586 |
|
19587 | var TableImporter =
|
19588 |
|
19589 | function () {
|
19590 | function TableImporter(elementFactory, eventBus, sheet) {
|
19591 | _classCallCheck$f(this, TableImporter);
|
19592 |
|
19593 | this._elementFactory = elementFactory;
|
19594 | this._eventBus = eventBus;
|
19595 | this._sheet = sheet;
|
19596 | }
|
19597 | |
19598 |
|
19599 |
|
19600 |
|
19601 |
|
19602 | _createClass$e(TableImporter, [{
|
19603 | key: "add",
|
19604 | value: function add(semantic) {
|
19605 | var _this = this;
|
19606 |
|
19607 | var element;
|
19608 |
|
19609 | if (is(semantic, 'dmn:DecisionTable')) {
|
19610 | element = this._elementFactory.createRoot(elementData$1(semantic));
|
19611 |
|
19612 | this._sheet.setRoot(element);
|
19613 | }
|
19614 | else if (is(semantic, 'dmn:InputClause')) {
|
19615 | element = this._elementFactory.createCol(elementData$1(semantic));
|
19616 |
|
19617 | this._sheet.addCol(element);
|
19618 | }
|
19619 | else if (is(semantic, 'dmn:OutputClause')) {
|
19620 | element = this._elementFactory.createCol(elementData$1(semantic));
|
19621 |
|
19622 | this._sheet.addCol(element);
|
19623 | }
|
19624 | else if (is(semantic, 'dmn:DecisionRule')) {
|
19625 | if (!semantic.inputEntry) {
|
19626 | semantic.inputEntry = [];
|
19627 | }
|
19628 |
|
19629 | if (!semantic.outputEntry) {
|
19630 | semantic.outputEntry = [];
|
19631 | }
|
19632 |
|
19633 | var cells = [].concat(_toConsumableArray$6(semantic.inputEntry), _toConsumableArray$6(semantic.outputEntry)).map(function (entry) {
|
19634 | return _this._elementFactory.createCell(elementData$1(entry));
|
19635 | });
|
19636 | element = this._elementFactory.createRow(assign(elementData$1(semantic), {
|
19637 | cells: cells
|
19638 | }));
|
19639 |
|
19640 | this._sheet.addRow(element);
|
19641 | }
|
19642 |
|
19643 | this._eventBus.fire('dmnElement.added', {
|
19644 | element: element
|
19645 | });
|
19646 |
|
19647 | return element;
|
19648 | }
|
19649 | }]);
|
19650 |
|
19651 | return TableImporter;
|
19652 | }();
|
19653 | TableImporter.$inject = ['elementFactory', 'eventBus', 'sheet'];
|
19654 |
|
19655 | var importModule = {
|
19656 | __depends__: [TranslateModule],
|
19657 | tableImporter: ['type', TableImporter]
|
19658 | };
|
19659 |
|
19660 | var coreModule = {
|
19661 | __depends__: [importModule, renderModule]
|
19662 | };
|
19663 |
|
19664 | function _typeof$a(obj) {
|
19665 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
19666 | _typeof$a = function _typeof$1(obj) {
|
19667 | return _typeof(obj);
|
19668 | };
|
19669 | } else {
|
19670 | _typeof$a = function _typeof$1(obj) {
|
19671 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
19672 | };
|
19673 | }
|
19674 |
|
19675 | return _typeof$a(obj);
|
19676 | }
|
19677 |
|
19678 | function _classCallCheck$g(instance, Constructor) {
|
19679 | if (!(instance instanceof Constructor)) {
|
19680 | throw new TypeError("Cannot call a class as a function");
|
19681 | }
|
19682 | }
|
19683 |
|
19684 | function _defineProperties$f(target, props) {
|
19685 | for (var i = 0; i < props.length; i++) {
|
19686 | var descriptor = props[i];
|
19687 | descriptor.enumerable = descriptor.enumerable || false;
|
19688 | descriptor.configurable = true;
|
19689 | if ("value" in descriptor) descriptor.writable = true;
|
19690 | Object.defineProperty(target, descriptor.key, descriptor);
|
19691 | }
|
19692 | }
|
19693 |
|
19694 | function _createClass$f(Constructor, protoProps, staticProps) {
|
19695 | if (protoProps) _defineProperties$f(Constructor.prototype, protoProps);
|
19696 | if (staticProps) _defineProperties$f(Constructor, staticProps);
|
19697 | return Constructor;
|
19698 | }
|
19699 |
|
19700 | function _possibleConstructorReturn$6(self, call) {
|
19701 | if (call && (_typeof$a(call) === "object" || typeof call === "function")) {
|
19702 | return call;
|
19703 | }
|
19704 |
|
19705 | return _assertThisInitialized$6(self);
|
19706 | }
|
19707 |
|
19708 | function _getPrototypeOf$6(o) {
|
19709 | _getPrototypeOf$6 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
19710 | return o.__proto__ || Object.getPrototypeOf(o);
|
19711 | };
|
19712 | return _getPrototypeOf$6(o);
|
19713 | }
|
19714 |
|
19715 | function _assertThisInitialized$6(self) {
|
19716 | if (self === void 0) {
|
19717 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
19718 | }
|
19719 |
|
19720 | return self;
|
19721 | }
|
19722 |
|
19723 | function _inherits$6(subClass, superClass) {
|
19724 | if (typeof superClass !== "function" && superClass !== null) {
|
19725 | throw new TypeError("Super expression must either be null or a function");
|
19726 | }
|
19727 |
|
19728 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
19729 | constructor: {
|
19730 | value: subClass,
|
19731 | writable: true,
|
19732 | configurable: true
|
19733 | }
|
19734 | });
|
19735 | if (superClass) _setPrototypeOf$6(subClass, superClass);
|
19736 | }
|
19737 |
|
19738 | function _setPrototypeOf$6(o, p) {
|
19739 | _setPrototypeOf$6 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
19740 | o.__proto__ = p;
|
19741 | return o;
|
19742 | };
|
19743 |
|
19744 | return _setPrototypeOf$6(o, p);
|
19745 | }
|
19746 |
|
19747 | function _defineProperty$7(obj, key, value) {
|
19748 | if (key in obj) {
|
19749 | Object.defineProperty(obj, key, {
|
19750 | value: value,
|
19751 | enumerable: true,
|
19752 | configurable: true,
|
19753 | writable: true
|
19754 | });
|
19755 | } else {
|
19756 | obj[key] = value;
|
19757 | }
|
19758 |
|
19759 | return obj;
|
19760 | }
|
19761 |
|
19762 | var DecisionTableHead =
|
19763 |
|
19764 | function (_Component) {
|
19765 | _inherits$6(DecisionTableHead, _Component);
|
19766 |
|
19767 | function DecisionTableHead(props, context) {
|
19768 | var _this;
|
19769 |
|
19770 | _classCallCheck$g(this, DecisionTableHead);
|
19771 |
|
19772 | _this = _possibleConstructorReturn$6(this, _getPrototypeOf$6(DecisionTableHead).call(this, props, context));
|
19773 |
|
19774 | _defineProperty$7(_assertThisInitialized$6(_this), "onElementsChanged", function () {
|
19775 | _this.forceUpdate();
|
19776 | });
|
19777 |
|
19778 | mixin(_assertThisInitialized$6(_this), ComponentWithSlots);
|
19779 | _this._sheet = context.injector.get('sheet');
|
19780 | _this._changeSupport = context.changeSupport;
|
19781 | return _this;
|
19782 | }
|
19783 |
|
19784 | _createClass$f(DecisionTableHead, [{
|
19785 | key: "componentWillMount",
|
19786 | value: function componentWillMount() {
|
19787 | var root = this._sheet.getRoot();
|
19788 |
|
19789 | this._changeSupport.onElementsChanged(root.id, this.onElementsChanged);
|
19790 | }
|
19791 | }, {
|
19792 | key: "componentWillUnmount",
|
19793 | value: function componentWillUnmount() {
|
19794 | var root = this._sheet.getRoot();
|
19795 |
|
19796 | this._changeSupport.offElementsChanged(root.id, this.onElementsChanged);
|
19797 | }
|
19798 | }, {
|
19799 | key: "render",
|
19800 | value: function render() {
|
19801 | var _this2 = this;
|
19802 |
|
19803 | var root = this._sheet.getRoot();
|
19804 |
|
19805 | if (!is(root, 'dmn:DMNElement')) {
|
19806 | return null;
|
19807 | }
|
19808 |
|
19809 | var businessObject = getBusinessObject(root);
|
19810 | var inputs = businessObject.input,
|
19811 | outputs = businessObject.output;
|
19812 | return createVNode(1, "thead", null, createVNode(1, "tr", null, [createVNode(1, "th", "index-column"), this.slotFills({
|
19813 | type: 'cell',
|
19814 | context: {
|
19815 | cellType: 'before-label-cells'
|
19816 | }
|
19817 | }), inputs && inputs.map(function (input, index) {
|
19818 | var width = input.width || '192px';
|
19819 | return _this2.slotFill({
|
19820 | type: 'cell',
|
19821 | context: {
|
19822 | cellType: 'input-header',
|
19823 | input: input,
|
19824 | index: index,
|
19825 | inputsLength: inputs.length,
|
19826 | width: width
|
19827 | },
|
19828 | key: input.id
|
19829 | }, DefaultInputHeaderCell);
|
19830 | }), outputs.map(function (output, index) {
|
19831 | return _this2.slotFill({
|
19832 | type: 'cell',
|
19833 | context: {
|
19834 | cellType: 'output-header',
|
19835 | output: output,
|
19836 | index: index,
|
19837 | outputsLength: outputs.length
|
19838 | },
|
19839 | key: output.id
|
19840 | }, DefaultOutputHeaderCell);
|
19841 | }), this.slotFills({
|
19842 | type: 'cell',
|
19843 | context: {
|
19844 | cellType: 'after-label-cells'
|
19845 | }
|
19846 | })], 0), 2);
|
19847 | }
|
19848 | }]);
|
19849 |
|
19850 | return DecisionTableHead;
|
19851 | }(Component);
|
19852 |
|
19853 | function DefaultInputHeaderCell(props, context) {
|
19854 | var input = props.input,
|
19855 | className = props.className,
|
19856 | index = props.index;
|
19857 | var label = input.label,
|
19858 | inputExpression = input.inputExpression,
|
19859 | inputValues = input.inputValues;
|
19860 | var translate = context.injector.get('translate');
|
19861 | var actualClassName = (className || '') + ' input-cell';
|
19862 | return createVNode(1, "th", actualClassName, [createVNode(1, "div", "clause", index === 0 ? translate('When') : translate('And'), 0), label ? createVNode(1, "div", "input-label", label, 0, {
|
19863 | "title": translate('Input Label')
|
19864 | }) : createVNode(1, "div", "input-expression", inputExpression.text || '-', 0, {
|
19865 | "title": translate('Input Expression')
|
19866 | }), createVNode(1, "div", "input-variable", inputValues && inputValues.text || inputExpression.typeRef, 0, {
|
19867 | "title": inputValues && inputValues.text ? translate('Input Values') : translate('Input Type')
|
19868 | })], 0, {
|
19869 | "data-col-id": input.id
|
19870 | }, input.id);
|
19871 | }
|
19872 |
|
19873 | function DefaultOutputHeaderCell(props, context) {
|
19874 | var output = props.output,
|
19875 | className = props.className,
|
19876 | index = props.index;
|
19877 | var label = output.label,
|
19878 | name = output.name,
|
19879 | outputValues = output.outputValues,
|
19880 | typeRef = output.typeRef;
|
19881 | var translate = context.injector.get('translate');
|
19882 | var actualClassName = (className || '') + ' output-cell';
|
19883 | return createVNode(1, "th", actualClassName, [createVNode(1, "div", "clause", index === 0 ? translate('Then') : translate('And'), 0), label ? createVNode(1, "div", "output-label", label, 0, {
|
19884 | "title": translate('Output Label')
|
19885 | }) : createVNode(1, "div", "output-name", name || '-', 0, {
|
19886 | "title": translate('Output Name')
|
19887 | }), createVNode(1, "div", "output-variable", outputValues && outputValues.text || typeRef, 0, {
|
19888 | "title": outputValues && outputValues.text ? translate('Output Values') : translate('Output Type')
|
19889 | })], 0, null, output.id);
|
19890 | }
|
19891 |
|
19892 | function DecisionTableHeadProvider(components) {
|
19893 | components.onGetComponent('table.head', function () {
|
19894 | return DecisionTableHead;
|
19895 | });
|
19896 | }
|
19897 | DecisionTableHeadProvider.$inject = ['components'];
|
19898 |
|
19899 | var decisionTableHeadModule = {
|
19900 | __init__: ['decisionTableHeadProvider'],
|
19901 | decisionTableHeadProvider: ['type', DecisionTableHeadProvider]
|
19902 | };
|
19903 |
|
19904 | function _typeof$b(obj) {
|
19905 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
19906 | _typeof$b = function _typeof$1(obj) {
|
19907 | return _typeof(obj);
|
19908 | };
|
19909 | } else {
|
19910 | _typeof$b = function _typeof$1(obj) {
|
19911 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
19912 | };
|
19913 | }
|
19914 |
|
19915 | return _typeof$b(obj);
|
19916 | }
|
19917 |
|
19918 | function _classCallCheck$h(instance, Constructor) {
|
19919 | if (!(instance instanceof Constructor)) {
|
19920 | throw new TypeError("Cannot call a class as a function");
|
19921 | }
|
19922 | }
|
19923 |
|
19924 | function _defineProperties$g(target, props) {
|
19925 | for (var i = 0; i < props.length; i++) {
|
19926 | var descriptor = props[i];
|
19927 | descriptor.enumerable = descriptor.enumerable || false;
|
19928 | descriptor.configurable = true;
|
19929 | if ("value" in descriptor) descriptor.writable = true;
|
19930 | Object.defineProperty(target, descriptor.key, descriptor);
|
19931 | }
|
19932 | }
|
19933 |
|
19934 | function _createClass$g(Constructor, protoProps, staticProps) {
|
19935 | if (protoProps) _defineProperties$g(Constructor.prototype, protoProps);
|
19936 | if (staticProps) _defineProperties$g(Constructor, staticProps);
|
19937 | return Constructor;
|
19938 | }
|
19939 |
|
19940 | function _possibleConstructorReturn$7(self, call) {
|
19941 | if (call && (_typeof$b(call) === "object" || typeof call === "function")) {
|
19942 | return call;
|
19943 | }
|
19944 |
|
19945 | return _assertThisInitialized$7(self);
|
19946 | }
|
19947 |
|
19948 | function _getPrototypeOf$7(o) {
|
19949 | _getPrototypeOf$7 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
19950 | return o.__proto__ || Object.getPrototypeOf(o);
|
19951 | };
|
19952 | return _getPrototypeOf$7(o);
|
19953 | }
|
19954 |
|
19955 | function _assertThisInitialized$7(self) {
|
19956 | if (self === void 0) {
|
19957 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
19958 | }
|
19959 |
|
19960 | return self;
|
19961 | }
|
19962 |
|
19963 | function _inherits$7(subClass, superClass) {
|
19964 | if (typeof superClass !== "function" && superClass !== null) {
|
19965 | throw new TypeError("Super expression must either be null or a function");
|
19966 | }
|
19967 |
|
19968 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
19969 | constructor: {
|
19970 | value: subClass,
|
19971 | writable: true,
|
19972 | configurable: true
|
19973 | }
|
19974 | });
|
19975 | if (superClass) _setPrototypeOf$7(subClass, superClass);
|
19976 | }
|
19977 |
|
19978 | function _setPrototypeOf$7(o, p) {
|
19979 | _setPrototypeOf$7 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
19980 | o.__proto__ = p;
|
19981 | return o;
|
19982 | };
|
19983 |
|
19984 | return _setPrototypeOf$7(o, p);
|
19985 | }
|
19986 |
|
19987 | var DecisionTablePropertiesComponent =
|
19988 |
|
19989 | function (_Component) {
|
19990 | _inherits$7(DecisionTablePropertiesComponent, _Component);
|
19991 |
|
19992 | function DecisionTablePropertiesComponent(props, context) {
|
19993 | var _this;
|
19994 |
|
19995 | _classCallCheck$h(this, DecisionTablePropertiesComponent);
|
19996 |
|
19997 | _this = _possibleConstructorReturn$7(this, _getPrototypeOf$7(DecisionTablePropertiesComponent).call(this, props, context));
|
19998 | inject(_assertThisInitialized$7(_this));
|
19999 | return _this;
|
20000 | }
|
20001 |
|
20002 | _createClass$g(DecisionTablePropertiesComponent, [{
|
20003 | key: "render",
|
20004 | value: function render() {
|
20005 | var root = this.sheet.getRoot();
|
20006 |
|
20007 | if (!is(root, 'dmn:DMNElement')) {
|
20008 | return null;
|
20009 | }
|
20010 |
|
20011 | var name = root.businessObject.$parent.name;
|
20012 | var HitPolicy = this.components.getComponent('hit-policy') || NullComponent;
|
20013 | return createVNode(1, "div", "decision-table-properties", [createVNode(1, "p", "decision-table-name", name, 0, {
|
20014 | "title": 'Decision Name: ' + name
|
20015 | }), createVNode(1, "span", "decision-table-header-separator"), createComponentVNode(2, HitPolicy)], 4);
|
20016 | }
|
20017 | }]);
|
20018 |
|
20019 | return DecisionTablePropertiesComponent;
|
20020 | }(Component);
|
20021 | DecisionTablePropertiesComponent.$inject = ['sheet', 'components'];
|
20022 |
|
20023 | function NullComponent() {
|
20024 | return null;
|
20025 | }
|
20026 |
|
20027 | function _classCallCheck$i(instance, Constructor) {
|
20028 | if (!(instance instanceof Constructor)) {
|
20029 | throw new TypeError("Cannot call a class as a function");
|
20030 | }
|
20031 | }
|
20032 | var LOW_PRIORITY$3 = 500;
|
20033 |
|
20034 | var DecisionTableProperties = function DecisionTableProperties(components) {
|
20035 | _classCallCheck$i(this, DecisionTableProperties);
|
20036 |
|
20037 | components.onGetComponent('table.before', LOW_PRIORITY$3, function () {
|
20038 | return DecisionTablePropertiesComponent;
|
20039 | });
|
20040 | };
|
20041 | DecisionTableProperties.$inject = ['components'];
|
20042 |
|
20043 | var decisionTablePropertiesModule = {
|
20044 | __init__: ['decisionTableProperties'],
|
20045 | decisionTableProperties: ['type', DecisionTableProperties]
|
20046 | };
|
20047 |
|
20048 | function _typeof$c(obj) {
|
20049 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
20050 | _typeof$c = function _typeof$1(obj) {
|
20051 | return _typeof(obj);
|
20052 | };
|
20053 | } else {
|
20054 | _typeof$c = function _typeof$1(obj) {
|
20055 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
20056 | };
|
20057 | }
|
20058 |
|
20059 | return _typeof$c(obj);
|
20060 | }
|
20061 |
|
20062 | function _classCallCheck$j(instance, Constructor) {
|
20063 | if (!(instance instanceof Constructor)) {
|
20064 | throw new TypeError("Cannot call a class as a function");
|
20065 | }
|
20066 | }
|
20067 |
|
20068 | function _defineProperties$h(target, props) {
|
20069 | for (var i = 0; i < props.length; i++) {
|
20070 | var descriptor = props[i];
|
20071 | descriptor.enumerable = descriptor.enumerable || false;
|
20072 | descriptor.configurable = true;
|
20073 | if ("value" in descriptor) descriptor.writable = true;
|
20074 | Object.defineProperty(target, descriptor.key, descriptor);
|
20075 | }
|
20076 | }
|
20077 |
|
20078 | function _createClass$h(Constructor, protoProps, staticProps) {
|
20079 | if (protoProps) _defineProperties$h(Constructor.prototype, protoProps);
|
20080 | if (staticProps) _defineProperties$h(Constructor, staticProps);
|
20081 | return Constructor;
|
20082 | }
|
20083 |
|
20084 | function _possibleConstructorReturn$8(self, call) {
|
20085 | if (call && (_typeof$c(call) === "object" || typeof call === "function")) {
|
20086 | return call;
|
20087 | }
|
20088 |
|
20089 | return _assertThisInitialized$8(self);
|
20090 | }
|
20091 |
|
20092 | function _assertThisInitialized$8(self) {
|
20093 | if (self === void 0) {
|
20094 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
20095 | }
|
20096 |
|
20097 | return self;
|
20098 | }
|
20099 |
|
20100 | function _getPrototypeOf$8(o) {
|
20101 | _getPrototypeOf$8 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
20102 | return o.__proto__ || Object.getPrototypeOf(o);
|
20103 | };
|
20104 | return _getPrototypeOf$8(o);
|
20105 | }
|
20106 |
|
20107 | function _inherits$8(subClass, superClass) {
|
20108 | if (typeof superClass !== "function" && superClass !== null) {
|
20109 | throw new TypeError("Super expression must either be null or a function");
|
20110 | }
|
20111 |
|
20112 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
20113 | constructor: {
|
20114 | value: subClass,
|
20115 | writable: true,
|
20116 | configurable: true
|
20117 | }
|
20118 | });
|
20119 | if (superClass) _setPrototypeOf$8(subClass, superClass);
|
20120 | }
|
20121 |
|
20122 | function _setPrototypeOf$8(o, p) {
|
20123 | _setPrototypeOf$8 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
20124 | o.__proto__ = p;
|
20125 | return o;
|
20126 | };
|
20127 |
|
20128 | return _setPrototypeOf$8(o, p);
|
20129 | }
|
20130 |
|
20131 | var DecisionRulesIndexCellComponent =
|
20132 |
|
20133 | function (_Component) {
|
20134 | _inherits$8(DecisionRulesIndexCellComponent, _Component);
|
20135 |
|
20136 | function DecisionRulesIndexCellComponent() {
|
20137 | _classCallCheck$j(this, DecisionRulesIndexCellComponent);
|
20138 |
|
20139 | return _possibleConstructorReturn$8(this, _getPrototypeOf$8(DecisionRulesIndexCellComponent).apply(this, arguments));
|
20140 | }
|
20141 |
|
20142 | _createClass$h(DecisionRulesIndexCellComponent, [{
|
20143 | key: "render",
|
20144 | value: function render() {
|
20145 | var _this$props = this.props,
|
20146 | row = _this$props.row,
|
20147 | rowIndex = _this$props.rowIndex;
|
20148 | var components = this.context.components;
|
20149 | var innerComponents = components.getComponents('cell-inner', {
|
20150 | cellType: 'rule-index',
|
20151 | row: row,
|
20152 | rowIndex: rowIndex
|
20153 | });
|
20154 | return createVNode(1, "td", "rule-index", [innerComponents && innerComponents.map(function (InnerComponent) {
|
20155 | return createComponentVNode(2, InnerComponent, {
|
20156 | "row": row,
|
20157 | "rowIndex": rowIndex
|
20158 | });
|
20159 | }), rowIndex + 1], 0, {
|
20160 | "data-row-id": row.id
|
20161 | });
|
20162 | }
|
20163 | }]);
|
20164 |
|
20165 | return DecisionRulesIndexCellComponent;
|
20166 | }(Component);
|
20167 |
|
20168 | function _classCallCheck$k(instance, Constructor) {
|
20169 | if (!(instance instanceof Constructor)) {
|
20170 | throw new TypeError("Cannot call a class as a function");
|
20171 | }
|
20172 | }
|
20173 |
|
20174 | var DecisionRuleIndices = function DecisionRuleIndices(components) {
|
20175 | _classCallCheck$k(this, DecisionRuleIndices);
|
20176 |
|
20177 | components.onGetComponent('cell', function (_ref) {
|
20178 | var cellType = _ref.cellType;
|
20179 |
|
20180 | if (cellType === 'before-rule-cells') {
|
20181 | return DecisionRulesIndexCellComponent;
|
20182 | }
|
20183 | });
|
20184 | };
|
20185 | DecisionRuleIndices.$inject = ['components'];
|
20186 |
|
20187 | var decisionRuleIndicesModule = {
|
20188 | __init__: ['decisionRuleIndices'],
|
20189 | decisionRuleIndices: ['type', DecisionRuleIndices]
|
20190 | };
|
20191 |
|
20192 | function _classCallCheck$l(instance, Constructor) {
|
20193 | if (!(instance instanceof Constructor)) {
|
20194 | throw new TypeError("Cannot call a class as a function");
|
20195 | }
|
20196 | }
|
20197 |
|
20198 | function _defineProperties$i(target, props) {
|
20199 | for (var i = 0; i < props.length; i++) {
|
20200 | var descriptor = props[i];
|
20201 | descriptor.enumerable = descriptor.enumerable || false;
|
20202 | descriptor.configurable = true;
|
20203 | if ("value" in descriptor) descriptor.writable = true;
|
20204 | Object.defineProperty(target, descriptor.key, descriptor);
|
20205 | }
|
20206 | }
|
20207 |
|
20208 | function _createClass$i(Constructor, protoProps, staticProps) {
|
20209 | if (protoProps) _defineProperties$i(Constructor.prototype, protoProps);
|
20210 | if (staticProps) _defineProperties$i(Constructor, staticProps);
|
20211 | return Constructor;
|
20212 | }
|
20213 | var EXPRESSION_LANGUAGE_OPTIONS = [{
|
20214 | label: 'FEEL',
|
20215 | value: 'feel'
|
20216 | }, {
|
20217 | label: 'JUEL',
|
20218 | value: 'juel'
|
20219 | }, {
|
20220 | label: 'JavaScript',
|
20221 | value: 'javascript'
|
20222 | }, {
|
20223 | label: 'Groovy',
|
20224 | value: 'groovy'
|
20225 | }, {
|
20226 | label: 'Python',
|
20227 | value: 'python'
|
20228 | }, {
|
20229 | label: 'JRuby',
|
20230 | value: 'jruby'
|
20231 | }];
|
20232 | |
20233 |
|
20234 |
|
20235 |
|
20236 |
|
20237 |
|
20238 | |
20239 |
|
20240 |
|
20241 |
|
20242 |
|
20243 |
|
20244 |
|
20245 |
|
20246 |
|
20247 |
|
20248 |
|
20249 |
|
20250 |
|
20251 |
|
20252 |
|
20253 |
|
20254 |
|
20255 |
|
20256 |
|
20257 |
|
20258 |
|
20259 |
|
20260 | var ExpressionLanguages =
|
20261 |
|
20262 | function () {
|
20263 | function ExpressionLanguages(injector) {
|
20264 | _classCallCheck$l(this, ExpressionLanguages);
|
20265 |
|
20266 | this._injector = injector;
|
20267 | var config = injector.get('config.expressionLanguages') || {};
|
20268 | this._config = {
|
20269 | options: EXPRESSION_LANGUAGE_OPTIONS,
|
20270 | defaults: {
|
20271 | editor: 'feel'
|
20272 | }
|
20273 | };
|
20274 |
|
20275 | if (config.options) {
|
20276 | this._config.options = config.options;
|
20277 | }
|
20278 |
|
20279 | var legacyDefaults = this._getLegacyDefaults();
|
20280 |
|
20281 | assign(this._config.defaults, legacyDefaults, config.defaults);
|
20282 | }
|
20283 | |
20284 |
|
20285 |
|
20286 |
|
20287 |
|
20288 |
|
20289 |
|
20290 |
|
20291 |
|
20292 | _createClass$i(ExpressionLanguages, [{
|
20293 | key: "getDefault",
|
20294 | value: function getDefault(componentName) {
|
20295 | var defaults = this._config.defaults;
|
20296 | var defaultFromConfig = defaults[componentName] || defaults.editor;
|
20297 | return this._getLanguageByValue(defaultFromConfig) || this.getAll()[0];
|
20298 | }
|
20299 | |
20300 |
|
20301 |
|
20302 |
|
20303 |
|
20304 |
|
20305 |
|
20306 | }, {
|
20307 | key: "getLabel",
|
20308 | value: function getLabel(expressionLanguageValue) {
|
20309 | var langauge = this._getLanguageByValue(expressionLanguageValue);
|
20310 |
|
20311 | return langauge ? langauge.label : expressionLanguageValue;
|
20312 | }
|
20313 | |
20314 |
|
20315 |
|
20316 |
|
20317 |
|
20318 |
|
20319 | }, {
|
20320 | key: "getAll",
|
20321 | value: function getAll() {
|
20322 | return this._config.options;
|
20323 | }
|
20324 | }, {
|
20325 | key: "_getLegacyDefaults",
|
20326 | value: function _getLegacyDefaults() {
|
20327 | var defaults = {},
|
20328 | injector = this._injector;
|
20329 | var inputCellValue = injector.get('config.defaultInputExpressionLanguage');
|
20330 | var outputCellValue = injector.get('config.defaultOutputExpressionLanguage');
|
20331 |
|
20332 | if (inputCellValue) {
|
20333 | defaults.inputCell = inputCellValue;
|
20334 | }
|
20335 |
|
20336 | if (outputCellValue) {
|
20337 | defaults.outputCell = outputCellValue;
|
20338 | }
|
20339 |
|
20340 | return defaults;
|
20341 | }
|
20342 | }, {
|
20343 | key: "_getLanguageByValue",
|
20344 | value: function _getLanguageByValue(value) {
|
20345 | return find(this.getAll(), function (language) {
|
20346 | return value === language.value;
|
20347 | });
|
20348 | }
|
20349 | }]);
|
20350 |
|
20351 | return ExpressionLanguages;
|
20352 | }();
|
20353 | ExpressionLanguages.$inject = ['injector'];
|
20354 |
|
20355 | var ExpressionLanguagesModule = {
|
20356 | __init__: ['expressionLanguages'],
|
20357 | expressionLanguages: ['type', ExpressionLanguages]
|
20358 | };
|
20359 |
|
20360 | function _typeof$d(obj) {
|
20361 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
20362 | _typeof$d = function _typeof$1(obj) {
|
20363 | return _typeof(obj);
|
20364 | };
|
20365 | } else {
|
20366 | _typeof$d = function _typeof$1(obj) {
|
20367 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
20368 | };
|
20369 | }
|
20370 |
|
20371 | return _typeof$d(obj);
|
20372 | }
|
20373 |
|
20374 | function _classCallCheck$m(instance, Constructor) {
|
20375 | if (!(instance instanceof Constructor)) {
|
20376 | throw new TypeError("Cannot call a class as a function");
|
20377 | }
|
20378 | }
|
20379 |
|
20380 | function _defineProperties$j(target, props) {
|
20381 | for (var i = 0; i < props.length; i++) {
|
20382 | var descriptor = props[i];
|
20383 | descriptor.enumerable = descriptor.enumerable || false;
|
20384 | descriptor.configurable = true;
|
20385 | if ("value" in descriptor) descriptor.writable = true;
|
20386 | Object.defineProperty(target, descriptor.key, descriptor);
|
20387 | }
|
20388 | }
|
20389 |
|
20390 | function _createClass$j(Constructor, protoProps, staticProps) {
|
20391 | if (protoProps) _defineProperties$j(Constructor.prototype, protoProps);
|
20392 | if (staticProps) _defineProperties$j(Constructor, staticProps);
|
20393 | return Constructor;
|
20394 | }
|
20395 |
|
20396 | function _possibleConstructorReturn$9(self, call) {
|
20397 | if (call && (_typeof$d(call) === "object" || typeof call === "function")) {
|
20398 | return call;
|
20399 | }
|
20400 |
|
20401 | return _assertThisInitialized$9(self);
|
20402 | }
|
20403 |
|
20404 | function _assertThisInitialized$9(self) {
|
20405 | if (self === void 0) {
|
20406 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
20407 | }
|
20408 |
|
20409 | return self;
|
20410 | }
|
20411 |
|
20412 | function _getPrototypeOf$9(o) {
|
20413 | _getPrototypeOf$9 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
20414 | return o.__proto__ || Object.getPrototypeOf(o);
|
20415 | };
|
20416 | return _getPrototypeOf$9(o);
|
20417 | }
|
20418 |
|
20419 | function _inherits$9(subClass, superClass) {
|
20420 | if (typeof superClass !== "function" && superClass !== null) {
|
20421 | throw new TypeError("Super expression must either be null or a function");
|
20422 | }
|
20423 |
|
20424 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
20425 | constructor: {
|
20426 | value: subClass,
|
20427 | writable: true,
|
20428 | configurable: true
|
20429 | }
|
20430 | });
|
20431 | if (superClass) _setPrototypeOf$9(subClass, superClass);
|
20432 | }
|
20433 |
|
20434 | function _setPrototypeOf$9(o, p) {
|
20435 | _setPrototypeOf$9 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
20436 | o.__proto__ = p;
|
20437 | return o;
|
20438 | };
|
20439 |
|
20440 | return _setPrototypeOf$9(o, p);
|
20441 | }
|
20442 |
|
20443 | var DecisionRulesBodyComponent =
|
20444 |
|
20445 | function (_Component) {
|
20446 | _inherits$9(DecisionRulesBodyComponent, _Component);
|
20447 |
|
20448 | function DecisionRulesBodyComponent() {
|
20449 | _classCallCheck$m(this, DecisionRulesBodyComponent);
|
20450 |
|
20451 | return _possibleConstructorReturn$9(this, _getPrototypeOf$9(DecisionRulesBodyComponent).apply(this, arguments));
|
20452 | }
|
20453 |
|
20454 | _createClass$j(DecisionRulesBodyComponent, [{
|
20455 | key: "render",
|
20456 | value: function render(_ref) {
|
20457 | var rows = _ref.rows,
|
20458 | cols = _ref.cols;
|
20459 | var components = this.context.components;
|
20460 | return createVNode(1, "tbody", null, rows.map(function (row, rowIndex) {
|
20461 | var RowComponent = components.getComponent('row', {
|
20462 | rowType: 'rule'
|
20463 | });
|
20464 | return RowComponent && createComponentVNode(2, RowComponent, {
|
20465 | "row": row,
|
20466 | "rowIndex": rowIndex,
|
20467 | "cols": cols
|
20468 | }, row.id);
|
20469 | }), 0);
|
20470 | }
|
20471 | }]);
|
20472 |
|
20473 | return DecisionRulesBodyComponent;
|
20474 | }(Component);
|
20475 |
|
20476 | function _typeof$e(obj) {
|
20477 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
20478 | _typeof$e = function _typeof$1(obj) {
|
20479 | return _typeof(obj);
|
20480 | };
|
20481 | } else {
|
20482 | _typeof$e = function _typeof$1(obj) {
|
20483 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
20484 | };
|
20485 | }
|
20486 |
|
20487 | return _typeof$e(obj);
|
20488 | }
|
20489 |
|
20490 | function _classCallCheck$n(instance, Constructor) {
|
20491 | if (!(instance instanceof Constructor)) {
|
20492 | throw new TypeError("Cannot call a class as a function");
|
20493 | }
|
20494 | }
|
20495 |
|
20496 | function _defineProperties$k(target, props) {
|
20497 | for (var i = 0; i < props.length; i++) {
|
20498 | var descriptor = props[i];
|
20499 | descriptor.enumerable = descriptor.enumerable || false;
|
20500 | descriptor.configurable = true;
|
20501 | if ("value" in descriptor) descriptor.writable = true;
|
20502 | Object.defineProperty(target, descriptor.key, descriptor);
|
20503 | }
|
20504 | }
|
20505 |
|
20506 | function _createClass$k(Constructor, protoProps, staticProps) {
|
20507 | if (protoProps) _defineProperties$k(Constructor.prototype, protoProps);
|
20508 | if (staticProps) _defineProperties$k(Constructor, staticProps);
|
20509 | return Constructor;
|
20510 | }
|
20511 |
|
20512 | function _possibleConstructorReturn$a(self, call) {
|
20513 | if (call && (_typeof$e(call) === "object" || typeof call === "function")) {
|
20514 | return call;
|
20515 | }
|
20516 |
|
20517 | return _assertThisInitialized$a(self);
|
20518 | }
|
20519 |
|
20520 | function _getPrototypeOf$a(o) {
|
20521 | _getPrototypeOf$a = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
20522 | return o.__proto__ || Object.getPrototypeOf(o);
|
20523 | };
|
20524 | return _getPrototypeOf$a(o);
|
20525 | }
|
20526 |
|
20527 | function _assertThisInitialized$a(self) {
|
20528 | if (self === void 0) {
|
20529 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
20530 | }
|
20531 |
|
20532 | return self;
|
20533 | }
|
20534 |
|
20535 | function _inherits$a(subClass, superClass) {
|
20536 | if (typeof superClass !== "function" && superClass !== null) {
|
20537 | throw new TypeError("Super expression must either be null or a function");
|
20538 | }
|
20539 |
|
20540 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
20541 | constructor: {
|
20542 | value: subClass,
|
20543 | writable: true,
|
20544 | configurable: true
|
20545 | }
|
20546 | });
|
20547 | if (superClass) _setPrototypeOf$a(subClass, superClass);
|
20548 | }
|
20549 |
|
20550 | function _setPrototypeOf$a(o, p) {
|
20551 | _setPrototypeOf$a = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
20552 | o.__proto__ = p;
|
20553 | return o;
|
20554 | };
|
20555 |
|
20556 | return _setPrototypeOf$a(o, p);
|
20557 | }
|
20558 |
|
20559 | var DecisionRulesRowComponent =
|
20560 |
|
20561 | function (_Component) {
|
20562 | _inherits$a(DecisionRulesRowComponent, _Component);
|
20563 |
|
20564 | function DecisionRulesRowComponent(props, context) {
|
20565 | var _this;
|
20566 |
|
20567 | _classCallCheck$n(this, DecisionRulesRowComponent);
|
20568 |
|
20569 | _this = _possibleConstructorReturn$a(this, _getPrototypeOf$a(DecisionRulesRowComponent).call(this, props, context));
|
20570 | mixin(_assertThisInitialized$a(_this), ComponentWithSlots);
|
20571 | return _this;
|
20572 | }
|
20573 |
|
20574 | _createClass$k(DecisionRulesRowComponent, [{
|
20575 | key: "render",
|
20576 | value: function render() {
|
20577 | var _this2 = this;
|
20578 |
|
20579 | var _this$props = this.props,
|
20580 | row = _this$props.row,
|
20581 | rowIndex = _this$props.rowIndex,
|
20582 | cols = _this$props.cols;
|
20583 | var cells = row.cells;
|
20584 | return createVNode(1, "tr", null, [this.slotFills({
|
20585 | type: 'cell',
|
20586 | context: {
|
20587 | cellType: 'before-rule-cells',
|
20588 | row: row,
|
20589 | rowIndex: rowIndex
|
20590 | }
|
20591 | }), cells.map(function (cell, colIndex) {
|
20592 | return _this2.slotFill({
|
20593 | type: 'cell',
|
20594 | context: {
|
20595 | cellType: 'rule',
|
20596 | cell: cell,
|
20597 | rowIndex: rowIndex,
|
20598 | colIndex: colIndex
|
20599 | },
|
20600 | key: cell.id,
|
20601 | row: row,
|
20602 | col: cols[colIndex]
|
20603 | });
|
20604 | }), this.slotFills({
|
20605 | type: 'cell',
|
20606 | context: {
|
20607 | cellType: 'after-rule-cells',
|
20608 | row: row,
|
20609 | rowIndex: rowIndex
|
20610 | }
|
20611 | })], 0);
|
20612 | }
|
20613 | }]);
|
20614 |
|
20615 | return DecisionRulesRowComponent;
|
20616 | }(Component);
|
20617 |
|
20618 | function _typeof$f(obj) {
|
20619 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
20620 | _typeof$f = function _typeof$1(obj) {
|
20621 | return _typeof(obj);
|
20622 | };
|
20623 | } else {
|
20624 | _typeof$f = function _typeof$1(obj) {
|
20625 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
20626 | };
|
20627 | }
|
20628 |
|
20629 | return _typeof$f(obj);
|
20630 | }
|
20631 |
|
20632 | function _classCallCheck$o(instance, Constructor) {
|
20633 | if (!(instance instanceof Constructor)) {
|
20634 | throw new TypeError("Cannot call a class as a function");
|
20635 | }
|
20636 | }
|
20637 |
|
20638 | function _defineProperties$l(target, props) {
|
20639 | for (var i = 0; i < props.length; i++) {
|
20640 | var descriptor = props[i];
|
20641 | descriptor.enumerable = descriptor.enumerable || false;
|
20642 | descriptor.configurable = true;
|
20643 | if ("value" in descriptor) descriptor.writable = true;
|
20644 | Object.defineProperty(target, descriptor.key, descriptor);
|
20645 | }
|
20646 | }
|
20647 |
|
20648 | function _createClass$l(Constructor, protoProps, staticProps) {
|
20649 | if (protoProps) _defineProperties$l(Constructor.prototype, protoProps);
|
20650 | if (staticProps) _defineProperties$l(Constructor, staticProps);
|
20651 | return Constructor;
|
20652 | }
|
20653 |
|
20654 | function _possibleConstructorReturn$b(self, call) {
|
20655 | if (call && (_typeof$f(call) === "object" || typeof call === "function")) {
|
20656 | return call;
|
20657 | }
|
20658 |
|
20659 | return _assertThisInitialized$b(self);
|
20660 | }
|
20661 |
|
20662 | function _assertThisInitialized$b(self) {
|
20663 | if (self === void 0) {
|
20664 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
20665 | }
|
20666 |
|
20667 | return self;
|
20668 | }
|
20669 |
|
20670 | function _getPrototypeOf$b(o) {
|
20671 | _getPrototypeOf$b = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
20672 | return o.__proto__ || Object.getPrototypeOf(o);
|
20673 | };
|
20674 | return _getPrototypeOf$b(o);
|
20675 | }
|
20676 |
|
20677 | function _inherits$b(subClass, superClass) {
|
20678 | if (typeof superClass !== "function" && superClass !== null) {
|
20679 | throw new TypeError("Super expression must either be null or a function");
|
20680 | }
|
20681 |
|
20682 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
20683 | constructor: {
|
20684 | value: subClass,
|
20685 | writable: true,
|
20686 | configurable: true
|
20687 | }
|
20688 | });
|
20689 | if (superClass) _setPrototypeOf$b(subClass, superClass);
|
20690 | }
|
20691 |
|
20692 | function _setPrototypeOf$b(o, p) {
|
20693 | _setPrototypeOf$b = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
20694 | o.__proto__ = p;
|
20695 | return o;
|
20696 | };
|
20697 |
|
20698 | return _setPrototypeOf$b(o, p);
|
20699 | }
|
20700 |
|
20701 | var DecisionRulesCellComponent =
|
20702 |
|
20703 | function (_Component) {
|
20704 | _inherits$b(DecisionRulesCellComponent, _Component);
|
20705 |
|
20706 | function DecisionRulesCellComponent() {
|
20707 | _classCallCheck$o(this, DecisionRulesCellComponent);
|
20708 |
|
20709 | return _possibleConstructorReturn$b(this, _getPrototypeOf$b(DecisionRulesCellComponent).apply(this, arguments));
|
20710 | }
|
20711 |
|
20712 | _createClass$l(DecisionRulesCellComponent, [{
|
20713 | key: "render",
|
20714 | value: function render() {
|
20715 | var _this$props = this.props,
|
20716 | cell = _this$props.cell,
|
20717 | row = _this$props.row,
|
20718 | col = _this$props.col;
|
20719 |
|
20720 | if (is(cell, 'dmn:UnaryTests')) {
|
20721 | return createComponentVNode(2, HeaderCell, {
|
20722 | "className": "input-cell",
|
20723 | "elementId": cell.id,
|
20724 | "data-row-id": row.id,
|
20725 | "data-col-id": col.id,
|
20726 | children: cell.businessObject.text
|
20727 | });
|
20728 | } else {
|
20729 | return createComponentVNode(2, HeaderCell, {
|
20730 | "className": "output-cell",
|
20731 | "elementId": cell.id,
|
20732 | "data-row-id": row.id,
|
20733 | "data-col-id": col.id,
|
20734 | children: cell.businessObject.text
|
20735 | });
|
20736 | }
|
20737 | }
|
20738 | }]);
|
20739 |
|
20740 | return DecisionRulesCellComponent;
|
20741 | }(Component);
|
20742 |
|
20743 | function _classCallCheck$p(instance, Constructor) {
|
20744 | if (!(instance instanceof Constructor)) {
|
20745 | throw new TypeError("Cannot call a class as a function");
|
20746 | }
|
20747 | }
|
20748 |
|
20749 | var Rules = function Rules(components) {
|
20750 | _classCallCheck$p(this, Rules);
|
20751 |
|
20752 | components.onGetComponent('table.body', function () {
|
20753 | return DecisionRulesBodyComponent;
|
20754 | });
|
20755 | components.onGetComponent('row', function (_ref) {
|
20756 | var rowType = _ref.rowType;
|
20757 |
|
20758 | if (rowType === 'rule') {
|
20759 | return DecisionRulesRowComponent;
|
20760 | }
|
20761 | });
|
20762 | components.onGetComponent('cell', function (_ref2) {
|
20763 | var cellType = _ref2.cellType;
|
20764 |
|
20765 | if (cellType === 'rule') {
|
20766 | return DecisionRulesCellComponent;
|
20767 | }
|
20768 | });
|
20769 | };
|
20770 | Rules.$inject = ['components'];
|
20771 |
|
20772 | var decisoinRulesModule = {
|
20773 | __depends__: [ExpressionLanguagesModule],
|
20774 | __init__: ['decisionRules'],
|
20775 | decisionRules: ['type', Rules]
|
20776 | };
|
20777 |
|
20778 |
|
20779 | var HIT_POLICIES = [{
|
20780 | label: 'Unique',
|
20781 | value: {
|
20782 | hitPolicy: 'UNIQUE',
|
20783 | aggregation: undefined
|
20784 | },
|
20785 | explanation: 'No overlap is possible and all rules are disjoint. Only a single rule can be matched'
|
20786 | }, {
|
20787 | label: 'First',
|
20788 | value: {
|
20789 | hitPolicy: 'FIRST',
|
20790 | aggregation: undefined
|
20791 | },
|
20792 | explanation: 'Rules may overlap. The first matching rule will be chosen'
|
20793 | }, {
|
20794 | label: 'Priority',
|
20795 | value: {
|
20796 | hitPolicy: 'PRIORITY',
|
20797 | aggregation: undefined
|
20798 | },
|
20799 | explanation: 'Rules may overlap. The one with the highest priority will be chosen'
|
20800 | }, {
|
20801 | label: 'Any',
|
20802 | value: {
|
20803 | hitPolicy: 'ANY',
|
20804 | aggregation: undefined
|
20805 | },
|
20806 | explanation: 'Rules may overlap. Their output have to match'
|
20807 | }, {
|
20808 | label: 'Collect',
|
20809 | value: {
|
20810 | hitPolicy: 'COLLECT',
|
20811 | aggregation: undefined
|
20812 | },
|
20813 | explanation: 'Collects the values of all matching rules'
|
20814 | }, {
|
20815 | label: 'Collect (Sum)',
|
20816 | value: {
|
20817 | hitPolicy: 'COLLECT',
|
20818 | aggregation: 'SUM'
|
20819 | },
|
20820 | explanation: 'Collects the values of all matching rules and sums up to a single value'
|
20821 | }, {
|
20822 | label: 'Collect (Min)',
|
20823 | value: {
|
20824 | hitPolicy: 'COLLECT',
|
20825 | aggregation: 'MIN'
|
20826 | },
|
20827 | explanation: 'Collects the values of all matching rules and uses the lowest value'
|
20828 | }, {
|
20829 | label: 'Collect (Max)',
|
20830 | value: {
|
20831 | hitPolicy: 'COLLECT',
|
20832 | aggregation: 'MAX'
|
20833 | },
|
20834 | explanation: 'Collects the values of all matching rules and uses the highest value'
|
20835 | }, {
|
20836 | label: 'Collect (Count)',
|
20837 | value: {
|
20838 | hitPolicy: 'COLLECT',
|
20839 | aggregation: 'COUNT'
|
20840 | },
|
20841 | explanation: 'Collects the values of all matching rules and counts the number of them'
|
20842 | }, {
|
20843 | label: 'Rule order',
|
20844 | value: {
|
20845 | hitPolicy: 'RULE ORDER',
|
20846 | aggregation: undefined
|
20847 | },
|
20848 | explanation: 'Collects the values of all matching rules in rule order'
|
20849 | }, {
|
20850 | label: 'Output order',
|
20851 | value: {
|
20852 | hitPolicy: 'OUTPUT ORDER',
|
20853 | aggregation: undefined
|
20854 | },
|
20855 | explanation: 'Collects the values of all matching rules in decreasing output priority order'
|
20856 | }];
|
20857 |
|
20858 | function _typeof$g(obj) {
|
20859 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
20860 | _typeof$g = function _typeof$1(obj) {
|
20861 | return _typeof(obj);
|
20862 | };
|
20863 | } else {
|
20864 | _typeof$g = function _typeof$1(obj) {
|
20865 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
20866 | };
|
20867 | }
|
20868 |
|
20869 | return _typeof$g(obj);
|
20870 | }
|
20871 |
|
20872 | function _classCallCheck$q(instance, Constructor) {
|
20873 | if (!(instance instanceof Constructor)) {
|
20874 | throw new TypeError("Cannot call a class as a function");
|
20875 | }
|
20876 | }
|
20877 |
|
20878 | function _defineProperties$m(target, props) {
|
20879 | for (var i = 0; i < props.length; i++) {
|
20880 | var descriptor = props[i];
|
20881 | descriptor.enumerable = descriptor.enumerable || false;
|
20882 | descriptor.configurable = true;
|
20883 | if ("value" in descriptor) descriptor.writable = true;
|
20884 | Object.defineProperty(target, descriptor.key, descriptor);
|
20885 | }
|
20886 | }
|
20887 |
|
20888 | function _createClass$m(Constructor, protoProps, staticProps) {
|
20889 | if (protoProps) _defineProperties$m(Constructor.prototype, protoProps);
|
20890 | if (staticProps) _defineProperties$m(Constructor, staticProps);
|
20891 | return Constructor;
|
20892 | }
|
20893 |
|
20894 | function _possibleConstructorReturn$c(self, call) {
|
20895 | if (call && (_typeof$g(call) === "object" || typeof call === "function")) {
|
20896 | return call;
|
20897 | }
|
20898 |
|
20899 | return _assertThisInitialized$c(self);
|
20900 | }
|
20901 |
|
20902 | function _getPrototypeOf$c(o) {
|
20903 | _getPrototypeOf$c = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
20904 | return o.__proto__ || Object.getPrototypeOf(o);
|
20905 | };
|
20906 | return _getPrototypeOf$c(o);
|
20907 | }
|
20908 |
|
20909 | function _assertThisInitialized$c(self) {
|
20910 | if (self === void 0) {
|
20911 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
20912 | }
|
20913 |
|
20914 | return self;
|
20915 | }
|
20916 |
|
20917 | function _inherits$c(subClass, superClass) {
|
20918 | if (typeof superClass !== "function" && superClass !== null) {
|
20919 | throw new TypeError("Super expression must either be null or a function");
|
20920 | }
|
20921 |
|
20922 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
20923 | constructor: {
|
20924 | value: subClass,
|
20925 | writable: true,
|
20926 | configurable: true
|
20927 | }
|
20928 | });
|
20929 | if (superClass) _setPrototypeOf$c(subClass, superClass);
|
20930 | }
|
20931 |
|
20932 | function _setPrototypeOf$c(o, p) {
|
20933 | _setPrototypeOf$c = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
20934 | o.__proto__ = p;
|
20935 | return o;
|
20936 | };
|
20937 |
|
20938 | return _setPrototypeOf$c(o, p);
|
20939 | }
|
20940 |
|
20941 | var HitPolicy =
|
20942 |
|
20943 | function (_Component) {
|
20944 | _inherits$c(HitPolicy, _Component);
|
20945 |
|
20946 | function HitPolicy(props, context) {
|
20947 | var _this;
|
20948 |
|
20949 | _classCallCheck$q(this, HitPolicy);
|
20950 |
|
20951 | _this = _possibleConstructorReturn$c(this, _getPrototypeOf$c(HitPolicy).call(this, props, context));
|
20952 | inject(_assertThisInitialized$c(_this));
|
20953 | return _this;
|
20954 | }
|
20955 |
|
20956 | _createClass$m(HitPolicy, [{
|
20957 | key: "getRoot",
|
20958 | value: function getRoot() {
|
20959 | return this.sheet.getRoot();
|
20960 | }
|
20961 | }, {
|
20962 | key: "render",
|
20963 | value: function render() {
|
20964 | var root = this.getRoot(),
|
20965 | businessObject = root.businessObject;
|
20966 | var aggregation = businessObject.aggregation,
|
20967 | hitPolicy = businessObject.hitPolicy;
|
20968 | var hitPolicyEntry = find(HIT_POLICIES, function (entry) {
|
20969 | return isEqualHitPolicy(entry.value, {
|
20970 | aggregation: aggregation,
|
20971 | hitPolicy: hitPolicy
|
20972 | });
|
20973 | });
|
20974 | return createVNode(1, "span", "hit-policy header", [createVNode(1, "label", "dms-label", createTextVNode("Hit Policy:"), 2), createVNode(1, "span", "hit-policy-value", hitPolicyEntry.label, 0)], 4, {
|
20975 | "title": hitPolicyEntry.explanation
|
20976 | });
|
20977 | }
|
20978 | }]);
|
20979 |
|
20980 | return HitPolicy;
|
20981 | }(Component);
|
20982 | HitPolicy.$inject = ['sheet'];
|
20983 |
|
20984 | function isEqualHitPolicy(a, b) {
|
20985 | return a.hitPolicy === b.hitPolicy && a.aggregation === b.aggregation;
|
20986 | }
|
20987 |
|
20988 | function HitPolicyProvider(components) {
|
20989 | components.onGetComponent('hit-policy', function () {
|
20990 | return HitPolicy;
|
20991 | });
|
20992 | }
|
20993 | HitPolicyProvider.$inject = ['components'];
|
20994 |
|
20995 | var hitPolicyModule = {
|
20996 | __init__: ['hitPolicyProvider'],
|
20997 | hitPolicyProvider: ['type', HitPolicyProvider]
|
20998 | };
|
20999 |
|
21000 | function _typeof$h(obj) {
|
21001 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
21002 | _typeof$h = function _typeof$1(obj) {
|
21003 | return _typeof(obj);
|
21004 | };
|
21005 | } else {
|
21006 | _typeof$h = function _typeof$1(obj) {
|
21007 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
21008 | };
|
21009 | }
|
21010 |
|
21011 | return _typeof$h(obj);
|
21012 | }
|
21013 |
|
21014 | function _classCallCheck$r(instance, Constructor) {
|
21015 | if (!(instance instanceof Constructor)) {
|
21016 | throw new TypeError("Cannot call a class as a function");
|
21017 | }
|
21018 | }
|
21019 |
|
21020 | function _defineProperties$n(target, props) {
|
21021 | for (var i = 0; i < props.length; i++) {
|
21022 | var descriptor = props[i];
|
21023 | descriptor.enumerable = descriptor.enumerable || false;
|
21024 | descriptor.configurable = true;
|
21025 | if ("value" in descriptor) descriptor.writable = true;
|
21026 | Object.defineProperty(target, descriptor.key, descriptor);
|
21027 | }
|
21028 | }
|
21029 |
|
21030 | function _createClass$n(Constructor, protoProps, staticProps) {
|
21031 | if (protoProps) _defineProperties$n(Constructor.prototype, protoProps);
|
21032 | if (staticProps) _defineProperties$n(Constructor, staticProps);
|
21033 | return Constructor;
|
21034 | }
|
21035 |
|
21036 | function _possibleConstructorReturn$d(self, call) {
|
21037 | if (call && (_typeof$h(call) === "object" || typeof call === "function")) {
|
21038 | return call;
|
21039 | }
|
21040 |
|
21041 | return _assertThisInitialized$d(self);
|
21042 | }
|
21043 |
|
21044 | function _getPrototypeOf$d(o) {
|
21045 | _getPrototypeOf$d = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
21046 | return o.__proto__ || Object.getPrototypeOf(o);
|
21047 | };
|
21048 | return _getPrototypeOf$d(o);
|
21049 | }
|
21050 |
|
21051 | function _assertThisInitialized$d(self) {
|
21052 | if (self === void 0) {
|
21053 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
21054 | }
|
21055 |
|
21056 | return self;
|
21057 | }
|
21058 |
|
21059 | function _inherits$d(subClass, superClass) {
|
21060 | if (typeof superClass !== "function" && superClass !== null) {
|
21061 | throw new TypeError("Super expression must either be null or a function");
|
21062 | }
|
21063 |
|
21064 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
21065 | constructor: {
|
21066 | value: subClass,
|
21067 | writable: true,
|
21068 | configurable: true
|
21069 | }
|
21070 | });
|
21071 | if (superClass) _setPrototypeOf$d(subClass, superClass);
|
21072 | }
|
21073 |
|
21074 | function _setPrototypeOf$d(o, p) {
|
21075 | _setPrototypeOf$d = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
21076 | o.__proto__ = p;
|
21077 | return o;
|
21078 | };
|
21079 |
|
21080 | return _setPrototypeOf$d(o, p);
|
21081 | }
|
21082 |
|
21083 | function _defineProperty$8(obj, key, value) {
|
21084 | if (key in obj) {
|
21085 | Object.defineProperty(obj, key, {
|
21086 | value: value,
|
21087 | enumerable: true,
|
21088 | configurable: true,
|
21089 | writable: true
|
21090 | });
|
21091 | } else {
|
21092 | obj[key] = value;
|
21093 | }
|
21094 |
|
21095 | return obj;
|
21096 | }
|
21097 |
|
21098 | var ViewDrdComponent =
|
21099 |
|
21100 | function (_Component) {
|
21101 | _inherits$d(ViewDrdComponent, _Component);
|
21102 |
|
21103 | function ViewDrdComponent(props, context) {
|
21104 | var _this;
|
21105 |
|
21106 | _classCallCheck$r(this, ViewDrdComponent);
|
21107 |
|
21108 | _this = _possibleConstructorReturn$d(this, _getPrototypeOf$d(ViewDrdComponent).call(this, props, context));
|
21109 |
|
21110 | _defineProperty$8(_assertThisInitialized$d(_this), "onClick", function () {
|
21111 | _this._eventBus.fire('showDrd');
|
21112 | });
|
21113 |
|
21114 | var injector = context.injector;
|
21115 | _this._eventBus = injector.get('eventBus');
|
21116 | return _this;
|
21117 | }
|
21118 |
|
21119 | _createClass$n(ViewDrdComponent, [{
|
21120 | key: "render",
|
21121 | value: function render() {
|
21122 | var _this2 = this;
|
21123 |
|
21124 | return createVNode(1, "div", "view-drd", createVNode(1, "button", "view-drd-button", createTextVNode("View DRD"), 2, {
|
21125 | "onClick": this.onClick
|
21126 | }), 2, null, null, function (node) {
|
21127 | return _this2.node = node;
|
21128 | });
|
21129 | }
|
21130 | }]);
|
21131 |
|
21132 | return ViewDrdComponent;
|
21133 | }(Component);
|
21134 |
|
21135 | function _classCallCheck$s(instance, Constructor) {
|
21136 | if (!(instance instanceof Constructor)) {
|
21137 | throw new TypeError("Cannot call a class as a function");
|
21138 | }
|
21139 | }
|
21140 |
|
21141 | function _defineProperties$o(target, props) {
|
21142 | for (var i = 0; i < props.length; i++) {
|
21143 | var descriptor = props[i];
|
21144 | descriptor.enumerable = descriptor.enumerable || false;
|
21145 | descriptor.configurable = true;
|
21146 | if ("value" in descriptor) descriptor.writable = true;
|
21147 | Object.defineProperty(target, descriptor.key, descriptor);
|
21148 | }
|
21149 | }
|
21150 |
|
21151 | function _createClass$o(Constructor, protoProps, staticProps) {
|
21152 | if (protoProps) _defineProperties$o(Constructor.prototype, protoProps);
|
21153 | if (staticProps) _defineProperties$o(Constructor, staticProps);
|
21154 | return Constructor;
|
21155 | }
|
21156 |
|
21157 | var ViewDrd =
|
21158 |
|
21159 | function () {
|
21160 | function ViewDrd(components, eventBus, injector, sheet) {
|
21161 | var _this = this;
|
21162 |
|
21163 | _classCallCheck$s(this, ViewDrd);
|
21164 |
|
21165 | this._injector = injector;
|
21166 | this._sheet = sheet;
|
21167 | components.onGetComponent('table.before', function () {
|
21168 | if (_this.canViewDrd()) {
|
21169 | return ViewDrdComponent;
|
21170 | }
|
21171 | });
|
21172 | eventBus.on('showDrd', function () {
|
21173 | var parent = injector.get('_parent', false);
|
21174 | var root = sheet.getRoot();
|
21175 | var definitions = getDefinitions(root);
|
21176 |
|
21177 | if (!definitions) {
|
21178 | return;
|
21179 | }
|
21180 |
|
21181 |
|
21182 | var view = parent.getView(definitions);
|
21183 | parent.open(view);
|
21184 | });
|
21185 | }
|
21186 |
|
21187 | _createClass$o(ViewDrd, [{
|
21188 | key: "canViewDrd",
|
21189 | value: function canViewDrd() {
|
21190 | var parent = this._injector.get('_parent', false);
|
21191 |
|
21192 | if (!parent) {
|
21193 | return false;
|
21194 | }
|
21195 |
|
21196 | var root = this._sheet.getRoot();
|
21197 |
|
21198 | var definitions = getDefinitions(root);
|
21199 | return !!parent.getView(definitions);
|
21200 | }
|
21201 | }]);
|
21202 |
|
21203 | return ViewDrd;
|
21204 | }();
|
21205 | ViewDrd.$inject = ['components', 'eventBus', 'injector', 'sheet'];
|
21206 |
|
21207 | function getDefinitions(root) {
|
21208 | var businessObject = root.businessObject;
|
21209 |
|
21210 | if (!businessObject) {
|
21211 | return;
|
21212 | }
|
21213 |
|
21214 | var decision = businessObject.$parent;
|
21215 | var definitions = decision.$parent;
|
21216 | return definitions;
|
21217 | }
|
21218 |
|
21219 | var viewDrdModule = {
|
21220 | __init__: ['viewDrd'],
|
21221 | viewDrd: ['type', ViewDrd]
|
21222 | };
|
21223 |
|
21224 | function Logo() {
|
21225 | return createVNode(32, "svg", null, [createVNode(1, "path", null, null, 1, {
|
21226 | "fill": 'currentColor',
|
21227 | "d": 'M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z'
|
21228 | }), createVNode(1, "path", null, null, 1, {
|
21229 | "fill": 'currentColor',
|
21230 | "d": 'M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z'
|
21231 | })], 4, {
|
21232 | "xmlns": 'http://www.w3.org/2000/svg',
|
21233 | "viewBox": '0 0 14.02 5.57',
|
21234 | "width": '53',
|
21235 | "height": '21',
|
21236 | "style": 'vertical-align:middle'
|
21237 | });
|
21238 | }
|
21239 |
|
21240 | function _typeof$i(obj) {
|
21241 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
21242 | _typeof$i = function _typeof$1(obj) {
|
21243 | return _typeof(obj);
|
21244 | };
|
21245 | } else {
|
21246 | _typeof$i = function _typeof$1(obj) {
|
21247 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
21248 | };
|
21249 | }
|
21250 |
|
21251 | return _typeof$i(obj);
|
21252 | }
|
21253 |
|
21254 | function _classCallCheck$t(instance, Constructor) {
|
21255 | if (!(instance instanceof Constructor)) {
|
21256 | throw new TypeError("Cannot call a class as a function");
|
21257 | }
|
21258 | }
|
21259 |
|
21260 | function _defineProperties$p(target, props) {
|
21261 | for (var i = 0; i < props.length; i++) {
|
21262 | var descriptor = props[i];
|
21263 | descriptor.enumerable = descriptor.enumerable || false;
|
21264 | descriptor.configurable = true;
|
21265 | if ("value" in descriptor) descriptor.writable = true;
|
21266 | Object.defineProperty(target, descriptor.key, descriptor);
|
21267 | }
|
21268 | }
|
21269 |
|
21270 | function _createClass$p(Constructor, protoProps, staticProps) {
|
21271 | if (protoProps) _defineProperties$p(Constructor.prototype, protoProps);
|
21272 | if (staticProps) _defineProperties$p(Constructor, staticProps);
|
21273 | return Constructor;
|
21274 | }
|
21275 |
|
21276 | function _possibleConstructorReturn$e(self, call) {
|
21277 | if (call && (_typeof$i(call) === "object" || typeof call === "function")) {
|
21278 | return call;
|
21279 | }
|
21280 |
|
21281 | return _assertThisInitialized$e(self);
|
21282 | }
|
21283 |
|
21284 | function _getPrototypeOf$e(o) {
|
21285 | _getPrototypeOf$e = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
21286 | return o.__proto__ || Object.getPrototypeOf(o);
|
21287 | };
|
21288 | return _getPrototypeOf$e(o);
|
21289 | }
|
21290 |
|
21291 | function _assertThisInitialized$e(self) {
|
21292 | if (self === void 0) {
|
21293 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
21294 | }
|
21295 |
|
21296 | return self;
|
21297 | }
|
21298 |
|
21299 | function _inherits$e(subClass, superClass) {
|
21300 | if (typeof superClass !== "function" && superClass !== null) {
|
21301 | throw new TypeError("Super expression must either be null or a function");
|
21302 | }
|
21303 |
|
21304 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
21305 | constructor: {
|
21306 | value: subClass,
|
21307 | writable: true,
|
21308 | configurable: true
|
21309 | }
|
21310 | });
|
21311 | if (superClass) _setPrototypeOf$e(subClass, superClass);
|
21312 | }
|
21313 |
|
21314 | function _setPrototypeOf$e(o, p) {
|
21315 | _setPrototypeOf$e = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
21316 | o.__proto__ = p;
|
21317 | return o;
|
21318 | };
|
21319 |
|
21320 | return _setPrototypeOf$e(o, p);
|
21321 | }
|
21322 |
|
21323 | function _defineProperty$9(obj, key, value) {
|
21324 | if (key in obj) {
|
21325 | Object.defineProperty(obj, key, {
|
21326 | value: value,
|
21327 | enumerable: true,
|
21328 | configurable: true,
|
21329 | writable: true
|
21330 | });
|
21331 | } else {
|
21332 | obj[key] = value;
|
21333 | }
|
21334 |
|
21335 | return obj;
|
21336 | }
|
21337 |
|
21338 | var PoweredByLogoComponent =
|
21339 |
|
21340 | function (_Component) {
|
21341 | _inherits$e(PoweredByLogoComponent, _Component);
|
21342 |
|
21343 | function PoweredByLogoComponent(props, context) {
|
21344 | var _this;
|
21345 |
|
21346 | _classCallCheck$t(this, PoweredByLogoComponent);
|
21347 |
|
21348 | _this = _possibleConstructorReturn$e(this, _getPrototypeOf$e(PoweredByLogoComponent).call(this, props, context));
|
21349 |
|
21350 | _defineProperty$9(_assertThisInitialized$e(_this), "onClick", function () {
|
21351 | _this._eventBus.fire('poweredBy.show');
|
21352 | });
|
21353 |
|
21354 | var injector = context.injector;
|
21355 | _this._eventBus = injector.get('eventBus');
|
21356 | return _this;
|
21357 | }
|
21358 |
|
21359 | _createClass$p(PoweredByLogoComponent, [{
|
21360 | key: "render",
|
21361 | value: function render() {
|
21362 | var _this2 = this;
|
21363 |
|
21364 | return createVNode(1, "div", 'powered-by', createVNode(1, "div", 'powered-by__logo', createComponentVNode(2, Logo), 2, {
|
21365 | "title": 'Powered by bpmn.io',
|
21366 | "onClick": this.onClick
|
21367 | }, null, function (node) {
|
21368 | return _this2.node = node;
|
21369 | }), 2);
|
21370 | }
|
21371 | }]);
|
21372 |
|
21373 | return PoweredByLogoComponent;
|
21374 | }(Component);
|
21375 |
|
21376 | function _typeof$j(obj) {
|
21377 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
21378 | _typeof$j = function _typeof$1(obj) {
|
21379 | return _typeof(obj);
|
21380 | };
|
21381 | } else {
|
21382 | _typeof$j = function _typeof$1(obj) {
|
21383 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
21384 | };
|
21385 | }
|
21386 |
|
21387 | return _typeof$j(obj);
|
21388 | }
|
21389 |
|
21390 | function _classCallCheck$u(instance, Constructor) {
|
21391 | if (!(instance instanceof Constructor)) {
|
21392 | throw new TypeError("Cannot call a class as a function");
|
21393 | }
|
21394 | }
|
21395 |
|
21396 | function _defineProperties$q(target, props) {
|
21397 | for (var i = 0; i < props.length; i++) {
|
21398 | var descriptor = props[i];
|
21399 | descriptor.enumerable = descriptor.enumerable || false;
|
21400 | descriptor.configurable = true;
|
21401 | if ("value" in descriptor) descriptor.writable = true;
|
21402 | Object.defineProperty(target, descriptor.key, descriptor);
|
21403 | }
|
21404 | }
|
21405 |
|
21406 | function _createClass$q(Constructor, protoProps, staticProps) {
|
21407 | if (protoProps) _defineProperties$q(Constructor.prototype, protoProps);
|
21408 | if (staticProps) _defineProperties$q(Constructor, staticProps);
|
21409 | return Constructor;
|
21410 | }
|
21411 |
|
21412 | function _possibleConstructorReturn$f(self, call) {
|
21413 | if (call && (_typeof$j(call) === "object" || typeof call === "function")) {
|
21414 | return call;
|
21415 | }
|
21416 |
|
21417 | return _assertThisInitialized$f(self);
|
21418 | }
|
21419 |
|
21420 | function _getPrototypeOf$f(o) {
|
21421 | _getPrototypeOf$f = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
21422 | return o.__proto__ || Object.getPrototypeOf(o);
|
21423 | };
|
21424 | return _getPrototypeOf$f(o);
|
21425 | }
|
21426 |
|
21427 | function _assertThisInitialized$f(self) {
|
21428 | if (self === void 0) {
|
21429 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
21430 | }
|
21431 |
|
21432 | return self;
|
21433 | }
|
21434 |
|
21435 | function _inherits$f(subClass, superClass) {
|
21436 | if (typeof superClass !== "function" && superClass !== null) {
|
21437 | throw new TypeError("Super expression must either be null or a function");
|
21438 | }
|
21439 |
|
21440 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
21441 | constructor: {
|
21442 | value: subClass,
|
21443 | writable: true,
|
21444 | configurable: true
|
21445 | }
|
21446 | });
|
21447 | if (superClass) _setPrototypeOf$f(subClass, superClass);
|
21448 | }
|
21449 |
|
21450 | function _setPrototypeOf$f(o, p) {
|
21451 | _setPrototypeOf$f = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
21452 | o.__proto__ = p;
|
21453 | return o;
|
21454 | };
|
21455 |
|
21456 | return _setPrototypeOf$f(o, p);
|
21457 | }
|
21458 |
|
21459 | var PoweredByOverlayComponent =
|
21460 |
|
21461 | function (_Component) {
|
21462 | _inherits$f(PoweredByOverlayComponent, _Component);
|
21463 |
|
21464 | function PoweredByOverlayComponent(props) {
|
21465 | var _this;
|
21466 |
|
21467 | _classCallCheck$u(this, PoweredByOverlayComponent);
|
21468 |
|
21469 | _this = _possibleConstructorReturn$f(this, _getPrototypeOf$f(PoweredByOverlayComponent).call(this, props));
|
21470 | _this.state = {
|
21471 | show: false
|
21472 | };
|
21473 | _this.onClick = _this.onClick.bind(_assertThisInitialized$f(_this));
|
21474 | _this.onShow = _this.onShow.bind(_assertThisInitialized$f(_this));
|
21475 | return _this;
|
21476 | }
|
21477 |
|
21478 | _createClass$q(PoweredByOverlayComponent, [{
|
21479 | key: "onClick",
|
21480 | value: function onClick() {
|
21481 | this.setState({
|
21482 | show: false
|
21483 | });
|
21484 | }
|
21485 | }, {
|
21486 | key: "onShow",
|
21487 | value: function onShow() {
|
21488 | this.setState({
|
21489 | show: true
|
21490 | });
|
21491 | }
|
21492 | }, {
|
21493 | key: "componentWillMount",
|
21494 | value: function componentWillMount() {
|
21495 | var eventBus = this._eventBus = this.context.injector.get('eventBus');
|
21496 | eventBus.on('poweredBy.show', this.onShow);
|
21497 | }
|
21498 | }, {
|
21499 | key: "componentWillUnmount",
|
21500 | value: function componentWillUnmount() {
|
21501 | this._eventBus.off('poweredBy.show', this.onShow);
|
21502 | }
|
21503 | }, {
|
21504 | key: "render",
|
21505 | value: function render() {
|
21506 | var show = this.state.show;
|
21507 | return show && createVNode(1, "div", "powered-by-overlay", createVNode(1, "div", "powered-by-overlay-content", [createVNode(1, "a", "logo", createComponentVNode(2, Logo), 2, {
|
21508 | "href": "https://bpmn.io",
|
21509 | "target": "_blank",
|
21510 | "rel": "noopener"
|
21511 | }), createVNode(1, "span", null, [createTextVNode("Web-based tooling for BPMN, DMN and CMMN diagrams powered by "), createVNode(1, "a", null, createTextVNode("bpmn.io"), 2, {
|
21512 | "href": "http://bpmn.io",
|
21513 | "target": "_blank"
|
21514 | }), createTextVNode(".")], 4)], 4, {
|
21515 | "onClick": function onClick(e) {
|
21516 | return e.stopPropagation();
|
21517 | }
|
21518 | }), 2, {
|
21519 | "onClick": this.onClick
|
21520 | });
|
21521 | }
|
21522 | }]);
|
21523 |
|
21524 | return PoweredByOverlayComponent;
|
21525 | }(Component);
|
21526 |
|
21527 | function _classCallCheck$v(instance, Constructor) {
|
21528 | if (!(instance instanceof Constructor)) {
|
21529 | throw new TypeError("Cannot call a class as a function");
|
21530 | }
|
21531 | }
|
21532 |
|
21533 | var PoweredBy = function PoweredBy(components, eventBus) {
|
21534 | _classCallCheck$v(this, PoweredBy);
|
21535 |
|
21536 | components.onGetComponent('table.before', function () {
|
21537 | return PoweredByLogoComponent;
|
21538 | });
|
21539 | components.onGetComponent('table.before', function () {
|
21540 | return PoweredByOverlayComponent;
|
21541 | });
|
21542 | };
|
21543 | PoweredBy.$inject = ['components', 'eventBus'];
|
21544 |
|
21545 | var PoweredByModule = {
|
21546 | __init__: ['poweredBy'],
|
21547 | poweredBy: ['type', PoweredBy]
|
21548 | };
|
21549 |
|
21550 | function _typeof$k(obj) {
|
21551 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
21552 | _typeof$k = function _typeof$1(obj) {
|
21553 | return _typeof(obj);
|
21554 | };
|
21555 | } else {
|
21556 | _typeof$k = function _typeof$1(obj) {
|
21557 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
21558 | };
|
21559 | }
|
21560 |
|
21561 | return _typeof$k(obj);
|
21562 | }
|
21563 |
|
21564 | function _toConsumableArray$7(arr) {
|
21565 | return _arrayWithoutHoles$5(arr) || _iterableToArray$5(arr) || _nonIterableSpread$5();
|
21566 | }
|
21567 |
|
21568 | function _nonIterableSpread$5() {
|
21569 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
21570 | }
|
21571 |
|
21572 | function _iterableToArray$5(iter) {
|
21573 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
21574 | }
|
21575 |
|
21576 | function _arrayWithoutHoles$5(arr) {
|
21577 | if (Array.isArray(arr)) {
|
21578 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
21579 | arr2[i] = arr[i];
|
21580 | }
|
21581 |
|
21582 | return arr2;
|
21583 | }
|
21584 | }
|
21585 |
|
21586 | function _objectWithoutProperties$4(source, excluded) {
|
21587 | if (source == null) return {};
|
21588 |
|
21589 | var target = _objectWithoutPropertiesLoose$4(source, excluded);
|
21590 |
|
21591 | var key, i;
|
21592 |
|
21593 | if (Object.getOwnPropertySymbols) {
|
21594 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
21595 |
|
21596 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
21597 | key = sourceSymbolKeys[i];
|
21598 | if (excluded.indexOf(key) >= 0) continue;
|
21599 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
21600 | target[key] = source[key];
|
21601 | }
|
21602 | }
|
21603 |
|
21604 | return target;
|
21605 | }
|
21606 |
|
21607 | function _objectWithoutPropertiesLoose$4(source, excluded) {
|
21608 | if (source == null) return {};
|
21609 | var target = {};
|
21610 | var sourceKeys = Object.keys(source);
|
21611 | var key, i;
|
21612 |
|
21613 | for (i = 0; i < sourceKeys.length; i++) {
|
21614 | key = sourceKeys[i];
|
21615 | if (excluded.indexOf(key) >= 0) continue;
|
21616 | target[key] = source[key];
|
21617 | }
|
21618 |
|
21619 | return target;
|
21620 | }
|
21621 |
|
21622 | function _classCallCheck$w(instance, Constructor) {
|
21623 | if (!(instance instanceof Constructor)) {
|
21624 | throw new TypeError("Cannot call a class as a function");
|
21625 | }
|
21626 | }
|
21627 |
|
21628 | function _defineProperties$r(target, props) {
|
21629 | for (var i = 0; i < props.length; i++) {
|
21630 | var descriptor = props[i];
|
21631 | descriptor.enumerable = descriptor.enumerable || false;
|
21632 | descriptor.configurable = true;
|
21633 | if ("value" in descriptor) descriptor.writable = true;
|
21634 | Object.defineProperty(target, descriptor.key, descriptor);
|
21635 | }
|
21636 | }
|
21637 |
|
21638 | function _createClass$r(Constructor, protoProps, staticProps) {
|
21639 | if (protoProps) _defineProperties$r(Constructor.prototype, protoProps);
|
21640 | if (staticProps) _defineProperties$r(Constructor, staticProps);
|
21641 | return Constructor;
|
21642 | }
|
21643 |
|
21644 | function _possibleConstructorReturn$g(self, call) {
|
21645 | if (call && (_typeof$k(call) === "object" || typeof call === "function")) {
|
21646 | return call;
|
21647 | }
|
21648 |
|
21649 | return _assertThisInitialized$g(self);
|
21650 | }
|
21651 |
|
21652 | function _assertThisInitialized$g(self) {
|
21653 | if (self === void 0) {
|
21654 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
21655 | }
|
21656 |
|
21657 | return self;
|
21658 | }
|
21659 |
|
21660 | function _get(target, property, receiver) {
|
21661 | if (typeof Reflect !== "undefined" && Reflect.get) {
|
21662 | _get = Reflect.get;
|
21663 | } else {
|
21664 | _get = function _get(target, property, receiver) {
|
21665 | var base = _superPropBase(target, property);
|
21666 |
|
21667 | if (!base) return;
|
21668 | var desc = Object.getOwnPropertyDescriptor(base, property);
|
21669 |
|
21670 | if (desc.get) {
|
21671 | return desc.get.call(receiver);
|
21672 | }
|
21673 |
|
21674 | return desc.value;
|
21675 | };
|
21676 | }
|
21677 |
|
21678 | return _get(target, property, receiver || target);
|
21679 | }
|
21680 |
|
21681 | function _superPropBase(object, property) {
|
21682 | while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
21683 | object = _getPrototypeOf$g(object);
|
21684 | if (object === null) break;
|
21685 | }
|
21686 |
|
21687 | return object;
|
21688 | }
|
21689 |
|
21690 | function _getPrototypeOf$g(o) {
|
21691 | _getPrototypeOf$g = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
21692 | return o.__proto__ || Object.getPrototypeOf(o);
|
21693 | };
|
21694 | return _getPrototypeOf$g(o);
|
21695 | }
|
21696 |
|
21697 | function _inherits$g(subClass, superClass) {
|
21698 | if (typeof superClass !== "function" && superClass !== null) {
|
21699 | throw new TypeError("Super expression must either be null or a function");
|
21700 | }
|
21701 |
|
21702 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
21703 | constructor: {
|
21704 | value: subClass,
|
21705 | writable: true,
|
21706 | configurable: true
|
21707 | }
|
21708 | });
|
21709 | if (superClass) _setPrototypeOf$g(subClass, superClass);
|
21710 | }
|
21711 |
|
21712 | function _setPrototypeOf$g(o, p) {
|
21713 | _setPrototypeOf$g = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
21714 | o.__proto__ = p;
|
21715 | return o;
|
21716 | };
|
21717 |
|
21718 | return _setPrototypeOf$g(o, p);
|
21719 | }
|
21720 |
|
21721 | var Viewer$1 =
|
21722 |
|
21723 | function (_Table) {
|
21724 | _inherits$g(Viewer, _Table);
|
21725 |
|
21726 | function Viewer() {
|
21727 | var _this;
|
21728 |
|
21729 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
21730 |
|
21731 | _classCallCheck$w(this, Viewer);
|
21732 |
|
21733 | var container = Viewer._createContainer();
|
21734 |
|
21735 | _this = _possibleConstructorReturn$g(this, _getPrototypeOf$g(Viewer).call(this, assign(options, {
|
21736 | renderer: {
|
21737 | container: container
|
21738 | }
|
21739 | })));
|
21740 | _this._container = container;
|
21741 | return _this;
|
21742 | }
|
21743 |
|
21744 | _createClass$r(Viewer, [{
|
21745 | key: "open",
|
21746 | value: function open(decision, done) {
|
21747 | var err;
|
21748 |
|
21749 |
|
21750 | try {
|
21751 | if (this._decision) {
|
21752 |
|
21753 | this.clear();
|
21754 | }
|
21755 |
|
21756 |
|
21757 | this._decision = decision;
|
21758 |
|
21759 | return importDecision(this, decision, done);
|
21760 | } catch (e) {
|
21761 | err = e;
|
21762 | }
|
21763 |
|
21764 |
|
21765 | return done(err);
|
21766 | }
|
21767 | |
21768 |
|
21769 |
|
21770 |
|
21771 |
|
21772 |
|
21773 |
|
21774 |
|
21775 | }, {
|
21776 | key: "_init",
|
21777 | value: function _init(options) {
|
21778 | var modules = options.modules,
|
21779 | additionalModules = options.additionalModules,
|
21780 | config = _objectWithoutProperties$4(options, ["modules", "additionalModules"]);
|
21781 |
|
21782 | var baseModules = modules || this.getModules();
|
21783 | var extraModules = additionalModules || [];
|
21784 | var staticModules = [{
|
21785 | decisionTable: ['value', this]
|
21786 | }];
|
21787 | var allModules = [PoweredByModule].concat(_toConsumableArray$7(baseModules), _toConsumableArray$7(extraModules), staticModules);
|
21788 | return {
|
21789 | modules: allModules,
|
21790 | config: config
|
21791 | };
|
21792 | }
|
21793 | |
21794 |
|
21795 |
|
21796 |
|
21797 |
|
21798 |
|
21799 |
|
21800 |
|
21801 |
|
21802 |
|
21803 |
|
21804 | }, {
|
21805 | key: "on",
|
21806 | value: function on(event, priority, callback, target) {
|
21807 | return this.get('eventBus').on(event, priority, callback, target);
|
21808 | }
|
21809 | |
21810 |
|
21811 |
|
21812 |
|
21813 |
|
21814 |
|
21815 |
|
21816 | }, {
|
21817 | key: "off",
|
21818 | value: function off(event, callback) {
|
21819 | this.get('eventBus').off(event, callback);
|
21820 | }
|
21821 | |
21822 |
|
21823 |
|
21824 |
|
21825 |
|
21826 |
|
21827 |
|
21828 |
|
21829 |
|
21830 | }, {
|
21831 | key: "_emit",
|
21832 | value: function _emit(type, event) {
|
21833 | return this.get('eventBus').fire(type, event);
|
21834 | }
|
21835 | |
21836 |
|
21837 |
|
21838 |
|
21839 |
|
21840 |
|
21841 | }, {
|
21842 | key: "attachTo",
|
21843 | value: function attachTo(parentNode) {
|
21844 | if (!parentNode) {
|
21845 | throw new Error('parentNode required');
|
21846 | }
|
21847 |
|
21848 |
|
21849 |
|
21850 | this.detach();
|
21851 | var container = this._container;
|
21852 | parentNode.appendChild(container);
|
21853 |
|
21854 | this._emit('attach', {});
|
21855 | }
|
21856 | |
21857 |
|
21858 |
|
21859 |
|
21860 | }, {
|
21861 | key: "detach",
|
21862 | value: function detach() {
|
21863 | var container = this._container,
|
21864 | parentNode = container.parentNode;
|
21865 |
|
21866 | if (!parentNode) {
|
21867 | return;
|
21868 | }
|
21869 |
|
21870 | this._emit('detach', {});
|
21871 |
|
21872 | remove(container);
|
21873 | }
|
21874 | }, {
|
21875 | key: "destroy",
|
21876 | value: function destroy() {
|
21877 | _get(_getPrototypeOf$g(Viewer.prototype), "destroy", this).call(this);
|
21878 |
|
21879 | this.detach();
|
21880 | }
|
21881 | }, {
|
21882 | key: "getModules",
|
21883 | value: function getModules() {
|
21884 | return Viewer._getModules();
|
21885 | }
|
21886 | }], [{
|
21887 | key: "_getModules",
|
21888 | value: function _getModules() {
|
21889 | return [annotationsModule, coreModule, TranslateModule, decisionTableHeadModule, decisionTablePropertiesModule, decisionRuleIndicesModule, decisoinRulesModule, hitPolicyModule, viewDrdModule];
|
21890 | }
|
21891 | }, {
|
21892 | key: "_createContainer",
|
21893 | value: function _createContainer() {
|
21894 | return domify('<div class="dmn-decision-table-container"></div>');
|
21895 | }
|
21896 | }]);
|
21897 |
|
21898 | return Viewer;
|
21899 | }(Table);
|
21900 |
|
21901 | function _classCallCheck$x(instance, Constructor) {
|
21902 | if (!(instance instanceof Constructor)) {
|
21903 | throw new TypeError("Cannot call a class as a function");
|
21904 | }
|
21905 | }
|
21906 |
|
21907 | function _defineProperties$s(target, props) {
|
21908 | for (var i = 0; i < props.length; i++) {
|
21909 | var descriptor = props[i];
|
21910 | descriptor.enumerable = descriptor.enumerable || false;
|
21911 | descriptor.configurable = true;
|
21912 | if ("value" in descriptor) descriptor.writable = true;
|
21913 | Object.defineProperty(target, descriptor.key, descriptor);
|
21914 | }
|
21915 | }
|
21916 |
|
21917 | function _createClass$s(Constructor, protoProps, staticProps) {
|
21918 | if (protoProps) _defineProperties$s(Constructor.prototype, protoProps);
|
21919 | if (staticProps) _defineProperties$s(Constructor, staticProps);
|
21920 | return Constructor;
|
21921 | }
|
21922 |
|
21923 | var ChangeSupport$1 =
|
21924 |
|
21925 | function () {
|
21926 | function ChangeSupport(eventBus) {
|
21927 | var _this = this;
|
21928 |
|
21929 | _classCallCheck$x(this, ChangeSupport);
|
21930 |
|
21931 | this._listeners = {};
|
21932 | eventBus.on('elements.changed', function (_ref) {
|
21933 | var elements = _ref.elements;
|
21934 |
|
21935 | _this.elementsChanged(elements);
|
21936 | });
|
21937 | eventBus.on('element.updateId', function (_ref2) {
|
21938 | var element = _ref2.element,
|
21939 | newId = _ref2.newId;
|
21940 |
|
21941 | _this.updateId(element.id, newId);
|
21942 | });
|
21943 | }
|
21944 |
|
21945 | _createClass$s(ChangeSupport, [{
|
21946 | key: "elementsChanged",
|
21947 | value: function elementsChanged(elements) {
|
21948 | var invoked = {};
|
21949 | var elementsLength = elements.length;
|
21950 |
|
21951 | for (var i = 0; i < elementsLength; i++) {
|
21952 | var id = elements[i].id;
|
21953 |
|
21954 | if (invoked[id]) {
|
21955 | return;
|
21956 | }
|
21957 |
|
21958 | invoked[id] = true;
|
21959 | var listenersLength = this._listeners[id] && this._listeners[id].length;
|
21960 |
|
21961 | if (listenersLength) {
|
21962 | for (var j = 0; j < listenersLength; j++) {
|
21963 |
|
21964 | this._listeners[id][j] && this._listeners[id][j]();
|
21965 | }
|
21966 | }
|
21967 | }
|
21968 | }
|
21969 | }, {
|
21970 | key: "onElementsChanged",
|
21971 | value: function onElementsChanged(id, listener) {
|
21972 | if (!this._listeners[id]) {
|
21973 | this._listeners[id] = [];
|
21974 | }
|
21975 |
|
21976 |
|
21977 | this._listeners[id][this._listeners[id].length] = listener;
|
21978 | }
|
21979 | }, {
|
21980 | key: "offElementsChanged",
|
21981 | value: function offElementsChanged(id, listener) {
|
21982 | if (!this._listeners[id]) {
|
21983 | return;
|
21984 | }
|
21985 |
|
21986 | if (listener) {
|
21987 | var idx = this._listeners[id].indexOf(listener);
|
21988 |
|
21989 | if (idx !== -1) {
|
21990 | this._listeners[id].splice(idx, 1);
|
21991 | }
|
21992 | } else {
|
21993 | this._listeners[id].length = 0;
|
21994 | }
|
21995 | }
|
21996 | }, {
|
21997 | key: "updateId",
|
21998 | value: function updateId(oldId, newId) {
|
21999 | if (this._listeners[oldId]) {
|
22000 | this._listeners[newId] = this._listeners[oldId];
|
22001 | delete this._listeners[oldId];
|
22002 | }
|
22003 | }
|
22004 | }]);
|
22005 |
|
22006 | return ChangeSupport;
|
22007 | }();
|
22008 | ChangeSupport$1.$inject = ['eventBus'];
|
22009 |
|
22010 | function _classCallCheck$y(instance, Constructor) {
|
22011 | if (!(instance instanceof Constructor)) {
|
22012 | throw new TypeError("Cannot call a class as a function");
|
22013 | }
|
22014 | }
|
22015 |
|
22016 | function _defineProperties$t(target, props) {
|
22017 | for (var i = 0; i < props.length; i++) {
|
22018 | var descriptor = props[i];
|
22019 | descriptor.enumerable = descriptor.enumerable || false;
|
22020 | descriptor.configurable = true;
|
22021 | if ("value" in descriptor) descriptor.writable = true;
|
22022 | Object.defineProperty(target, descriptor.key, descriptor);
|
22023 | }
|
22024 | }
|
22025 |
|
22026 | function _createClass$t(Constructor, protoProps, staticProps) {
|
22027 | if (protoProps) _defineProperties$t(Constructor.prototype, protoProps);
|
22028 | if (staticProps) _defineProperties$t(Constructor, staticProps);
|
22029 | return Constructor;
|
22030 | }
|
22031 | var DEFAULT_PRIORITY$2 = 1000;
|
22032 |
|
22033 | var Components$1 =
|
22034 |
|
22035 | function () {
|
22036 | function Components() {
|
22037 | _classCallCheck$y(this, Components);
|
22038 |
|
22039 | this._listeners = {};
|
22040 | }
|
22041 |
|
22042 | _createClass$t(Components, [{
|
22043 | key: "getComponent",
|
22044 | value: function getComponent(type, context) {
|
22045 | var listeners = this._listeners[type];
|
22046 |
|
22047 | if (!listeners) {
|
22048 | return;
|
22049 | }
|
22050 |
|
22051 | var component;
|
22052 |
|
22053 | for (var i = 0; i < listeners.length; i++) {
|
22054 | component = listeners[i].callback(context);
|
22055 |
|
22056 | if (component) {
|
22057 | break;
|
22058 | }
|
22059 | }
|
22060 |
|
22061 | return component;
|
22062 | }
|
22063 | }, {
|
22064 | key: "getComponents",
|
22065 | value: function getComponents(type, context) {
|
22066 | var listeners = this._listeners[type];
|
22067 |
|
22068 | if (!listeners) {
|
22069 | return;
|
22070 | }
|
22071 |
|
22072 | var components = [];
|
22073 |
|
22074 | for (var i = 0; i < listeners.length; i++) {
|
22075 | var component = listeners[i].callback(context);
|
22076 |
|
22077 | if (component) {
|
22078 | components.push(component);
|
22079 | }
|
22080 | }
|
22081 |
|
22082 | if (!components.length) {
|
22083 | return;
|
22084 | }
|
22085 |
|
22086 | return components;
|
22087 | }
|
22088 | }, {
|
22089 | key: "onGetComponent",
|
22090 | value: function onGetComponent(type, priority, callback) {
|
22091 | if (isFunction(priority)) {
|
22092 | callback = priority;
|
22093 | priority = DEFAULT_PRIORITY$2;
|
22094 | }
|
22095 |
|
22096 | if (!isNumber(priority)) {
|
22097 | throw new Error('priority must be a number');
|
22098 | }
|
22099 |
|
22100 | var listeners = this._getListeners(type);
|
22101 |
|
22102 | var existingListener, idx;
|
22103 | var newListener = {
|
22104 | priority: priority,
|
22105 | callback: callback
|
22106 | };
|
22107 |
|
22108 | for (idx = 0; existingListener = listeners[idx]; idx++) {
|
22109 | if (existingListener.priority < priority) {
|
22110 |
|
22111 | listeners.splice(idx, 0, newListener);
|
22112 | return;
|
22113 | }
|
22114 | }
|
22115 |
|
22116 | listeners.push(newListener);
|
22117 | }
|
22118 | }, {
|
22119 | key: "offGetComponent",
|
22120 | value: function offGetComponent(type, callback) {
|
22121 | var listeners = this._getListeners(type);
|
22122 |
|
22123 | var listener, listenerCallback, idx;
|
22124 |
|
22125 | if (callback) {
|
22126 |
|
22127 |
|
22128 | for (idx = listeners.length - 1; listener = listeners[idx]; idx--) {
|
22129 | listenerCallback = listener.callback;
|
22130 |
|
22131 | if (listenerCallback === callback) {
|
22132 | listeners.splice(idx, 1);
|
22133 | }
|
22134 | }
|
22135 | } else {
|
22136 |
|
22137 | listeners.length = 0;
|
22138 | }
|
22139 | }
|
22140 | }, {
|
22141 | key: "_getListeners",
|
22142 | value: function _getListeners(type) {
|
22143 | var listeners = this._listeners[type];
|
22144 |
|
22145 | if (!listeners) {
|
22146 | this._listeners[type] = listeners = [];
|
22147 | }
|
22148 |
|
22149 | return listeners;
|
22150 | }
|
22151 | }]);
|
22152 |
|
22153 | return Components;
|
22154 | }();
|
22155 |
|
22156 | function _typeof$l(obj) {
|
22157 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
22158 | _typeof$l = function _typeof$1(obj) {
|
22159 | return _typeof(obj);
|
22160 | };
|
22161 | } else {
|
22162 | _typeof$l = function _typeof$1(obj) {
|
22163 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
22164 | };
|
22165 | }
|
22166 |
|
22167 | return _typeof$l(obj);
|
22168 | }
|
22169 |
|
22170 | function _classCallCheck$z(instance, Constructor) {
|
22171 | if (!(instance instanceof Constructor)) {
|
22172 | throw new TypeError("Cannot call a class as a function");
|
22173 | }
|
22174 | }
|
22175 |
|
22176 | function _defineProperties$u(target, props) {
|
22177 | for (var i = 0; i < props.length; i++) {
|
22178 | var descriptor = props[i];
|
22179 | descriptor.enumerable = descriptor.enumerable || false;
|
22180 | descriptor.configurable = true;
|
22181 | if ("value" in descriptor) descriptor.writable = true;
|
22182 | Object.defineProperty(target, descriptor.key, descriptor);
|
22183 | }
|
22184 | }
|
22185 |
|
22186 | function _createClass$u(Constructor, protoProps, staticProps) {
|
22187 | if (protoProps) _defineProperties$u(Constructor.prototype, protoProps);
|
22188 | if (staticProps) _defineProperties$u(Constructor, staticProps);
|
22189 | return Constructor;
|
22190 | }
|
22191 |
|
22192 | function _possibleConstructorReturn$h(self, call) {
|
22193 | if (call && (_typeof$l(call) === "object" || typeof call === "function")) {
|
22194 | return call;
|
22195 | }
|
22196 |
|
22197 | return _assertThisInitialized$h(self);
|
22198 | }
|
22199 |
|
22200 | function _assertThisInitialized$h(self) {
|
22201 | if (self === void 0) {
|
22202 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
22203 | }
|
22204 |
|
22205 | return self;
|
22206 | }
|
22207 |
|
22208 | function _getPrototypeOf$h(o) {
|
22209 | _getPrototypeOf$h = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
22210 | return o.__proto__ || Object.getPrototypeOf(o);
|
22211 | };
|
22212 | return _getPrototypeOf$h(o);
|
22213 | }
|
22214 |
|
22215 | function _inherits$h(subClass, superClass) {
|
22216 | if (typeof superClass !== "function" && superClass !== null) {
|
22217 | throw new TypeError("Super expression must either be null or a function");
|
22218 | }
|
22219 |
|
22220 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
22221 | constructor: {
|
22222 | value: subClass,
|
22223 | writable: true,
|
22224 | configurable: true
|
22225 | }
|
22226 | });
|
22227 | if (superClass) _setPrototypeOf$h(subClass, superClass);
|
22228 | }
|
22229 |
|
22230 | function _setPrototypeOf$h(o, p) {
|
22231 | _setPrototypeOf$h = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
22232 | o.__proto__ = p;
|
22233 | return o;
|
22234 | };
|
22235 |
|
22236 | return _setPrototypeOf$h(o, p);
|
22237 | }
|
22238 |
|
22239 | var ViewerComponent =
|
22240 |
|
22241 | function (_Component) {
|
22242 | _inherits$h(ViewerComponent, _Component);
|
22243 |
|
22244 | function ViewerComponent(props) {
|
22245 | var _this;
|
22246 |
|
22247 | _classCallCheck$z(this, ViewerComponent);
|
22248 |
|
22249 | _this = _possibleConstructorReturn$h(this, _getPrototypeOf$h(ViewerComponent).call(this, props));
|
22250 | var injector = _this._injector = props.injector;
|
22251 | _this._changeSupport = injector.get('changeSupport');
|
22252 | _this._components = injector.get('components');
|
22253 | _this._renderer = injector.get('renderer');
|
22254 | return _this;
|
22255 | }
|
22256 |
|
22257 | _createClass$u(ViewerComponent, [{
|
22258 | key: "getChildContext",
|
22259 | value: function getChildContext() {
|
22260 | return {
|
22261 | changeSupport: this._changeSupport,
|
22262 | components: this._components,
|
22263 | renderer: this._renderer,
|
22264 | injector: this._injector
|
22265 | };
|
22266 | }
|
22267 | }, {
|
22268 | key: "render",
|
22269 | value: function render() {
|
22270 | var components = this._components.getComponents('viewer');
|
22271 |
|
22272 | return createVNode(1, "div", "viewer-container", components && components.map(function (Component, index) {
|
22273 | return createComponentVNode(2, Component, null, index);
|
22274 | }), 0);
|
22275 | }
|
22276 | }]);
|
22277 |
|
22278 | return ViewerComponent;
|
22279 | }(Component);
|
22280 |
|
22281 | function _classCallCheck$A(instance, Constructor) {
|
22282 | if (!(instance instanceof Constructor)) {
|
22283 | throw new TypeError("Cannot call a class as a function");
|
22284 | }
|
22285 | }
|
22286 |
|
22287 | function _defineProperties$v(target, props) {
|
22288 | for (var i = 0; i < props.length; i++) {
|
22289 | var descriptor = props[i];
|
22290 | descriptor.enumerable = descriptor.enumerable || false;
|
22291 | descriptor.configurable = true;
|
22292 | if ("value" in descriptor) descriptor.writable = true;
|
22293 | Object.defineProperty(target, descriptor.key, descriptor);
|
22294 | }
|
22295 | }
|
22296 |
|
22297 | function _createClass$v(Constructor, protoProps, staticProps) {
|
22298 | if (protoProps) _defineProperties$v(Constructor.prototype, protoProps);
|
22299 | if (staticProps) _defineProperties$v(Constructor, staticProps);
|
22300 | return Constructor;
|
22301 | }
|
22302 |
|
22303 | var Renderer$1 =
|
22304 |
|
22305 | function () {
|
22306 | function Renderer(changeSupport, components, config, eventBus, injector) {
|
22307 | _classCallCheck$A(this, Renderer);
|
22308 |
|
22309 | var container = config.container;
|
22310 | this._container = container;
|
22311 | eventBus.on('renderer.mount', function () {
|
22312 | render(createComponentVNode(2, ViewerComponent, {
|
22313 | "injector": injector
|
22314 | }), container);
|
22315 | });
|
22316 | eventBus.on('renderer.unmount', function () {
|
22317 | render(null, container);
|
22318 | });
|
22319 | }
|
22320 |
|
22321 | _createClass$v(Renderer, [{
|
22322 | key: "getContainer",
|
22323 | value: function getContainer() {
|
22324 | return this._container;
|
22325 | }
|
22326 | }]);
|
22327 |
|
22328 | return Renderer;
|
22329 | }();
|
22330 | Renderer$1.$inject = ['changeSupport', 'components', 'config.renderer', 'eventBus', 'injector'];
|
22331 |
|
22332 | var core$1 = {
|
22333 | __init__: ['changeSupport', 'components', 'renderer'],
|
22334 | changeSupport: ['type', ChangeSupport$1],
|
22335 | components: ['type', Components$1],
|
22336 | eventBus: ['type', EventBus],
|
22337 | renderer: ['type', Renderer$1]
|
22338 | };
|
22339 |
|
22340 | function _objectWithoutProperties$5(source, excluded) {
|
22341 | if (source == null) return {};
|
22342 |
|
22343 | var target = _objectWithoutPropertiesLoose$5(source, excluded);
|
22344 |
|
22345 | var key, i;
|
22346 |
|
22347 | if (Object.getOwnPropertySymbols) {
|
22348 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
22349 |
|
22350 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
22351 | key = sourceSymbolKeys[i];
|
22352 | if (excluded.indexOf(key) >= 0) continue;
|
22353 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
22354 | target[key] = source[key];
|
22355 | }
|
22356 | }
|
22357 |
|
22358 | return target;
|
22359 | }
|
22360 |
|
22361 | function _objectWithoutPropertiesLoose$5(source, excluded) {
|
22362 | if (source == null) return {};
|
22363 | var target = {};
|
22364 | var sourceKeys = Object.keys(source);
|
22365 | var key, i;
|
22366 |
|
22367 | for (i = 0; i < sourceKeys.length; i++) {
|
22368 | key = sourceKeys[i];
|
22369 | if (excluded.indexOf(key) >= 0) continue;
|
22370 | target[key] = source[key];
|
22371 | }
|
22372 |
|
22373 | return target;
|
22374 | }
|
22375 |
|
22376 | function _classCallCheck$B(instance, Constructor) {
|
22377 | if (!(instance instanceof Constructor)) {
|
22378 | throw new TypeError("Cannot call a class as a function");
|
22379 | }
|
22380 | }
|
22381 |
|
22382 | function _defineProperties$w(target, props) {
|
22383 | for (var i = 0; i < props.length; i++) {
|
22384 | var descriptor = props[i];
|
22385 | descriptor.enumerable = descriptor.enumerable || false;
|
22386 | descriptor.configurable = true;
|
22387 | if ("value" in descriptor) descriptor.writable = true;
|
22388 | Object.defineProperty(target, descriptor.key, descriptor);
|
22389 | }
|
22390 | }
|
22391 |
|
22392 | function _createClass$w(Constructor, protoProps, staticProps) {
|
22393 | if (protoProps) _defineProperties$w(Constructor.prototype, protoProps);
|
22394 | if (staticProps) _defineProperties$w(Constructor, staticProps);
|
22395 | return Constructor;
|
22396 | }
|
22397 | |
22398 |
|
22399 |
|
22400 |
|
22401 | var Viewer$2 =
|
22402 |
|
22403 | function () {
|
22404 | function Viewer() {
|
22405 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
22406 |
|
22407 | _classCallCheck$B(this, Viewer);
|
22408 |
|
22409 | var injector = options.injector;
|
22410 |
|
22411 | if (!injector) {
|
22412 | var _this$_init = this._init(options),
|
22413 | modules = _this$_init.modules,
|
22414 | config = _this$_init.config;
|
22415 |
|
22416 | injector = createInjector$2(config, modules);
|
22417 | }
|
22418 |
|
22419 | this.get = injector.get;
|
22420 | this.invoke = injector.invoke;
|
22421 | this.get('eventBus').fire('viewer.init');
|
22422 | }
|
22423 | |
22424 |
|
22425 |
|
22426 |
|
22427 |
|
22428 |
|
22429 |
|
22430 |
|
22431 |
|
22432 | _createClass$w(Viewer, [{
|
22433 | key: "_init",
|
22434 | value: function _init(options) {
|
22435 | var modules = options.modules,
|
22436 | config = _objectWithoutProperties$5(options, ["modules"]);
|
22437 |
|
22438 | return {
|
22439 | modules: modules,
|
22440 | config: config
|
22441 | };
|
22442 | }
|
22443 | |
22444 |
|
22445 |
|
22446 |
|
22447 | }, {
|
22448 | key: "destroy",
|
22449 | value: function destroy() {
|
22450 | var eventBus = this.get('eventBus');
|
22451 | eventBus.fire('viewer.destroy');
|
22452 | }
|
22453 | |
22454 |
|
22455 |
|
22456 |
|
22457 | }, {
|
22458 | key: "clear",
|
22459 | value: function clear() {
|
22460 | var eventBus = this.get('eventBus');
|
22461 | eventBus.fire('viewer.clear');
|
22462 | }
|
22463 | }]);
|
22464 |
|
22465 | return Viewer;
|
22466 | }();
|
22467 |
|
22468 | function bootstrap$2(bootstrapModules) {
|
22469 | var modules = [],
|
22470 | components = [];
|
22471 |
|
22472 | function hasModule(m) {
|
22473 | return modules.indexOf(m) >= 0;
|
22474 | }
|
22475 |
|
22476 | function addModule(m) {
|
22477 | modules.push(m);
|
22478 | }
|
22479 |
|
22480 | function visit(m) {
|
22481 | if (hasModule(m)) {
|
22482 | return;
|
22483 | }
|
22484 |
|
22485 | (m.__depends__ || []).forEach(visit);
|
22486 |
|
22487 | if (hasModule(m)) {
|
22488 | return;
|
22489 | }
|
22490 |
|
22491 | addModule(m);
|
22492 | (m.__init__ || []).forEach(function (c) {
|
22493 | components.push(c);
|
22494 | });
|
22495 | }
|
22496 |
|
22497 | bootstrapModules.forEach(visit);
|
22498 | var injector = new Injector(modules);
|
22499 | components.forEach(function (c) {
|
22500 | try {
|
22501 |
|
22502 | injector[typeof c === 'string' ? 'get' : 'invoke'](c);
|
22503 | } catch (e) {
|
22504 | console.error('Failed to instantiate component');
|
22505 | console.error(e.stack);
|
22506 | throw e;
|
22507 | }
|
22508 | });
|
22509 | return injector;
|
22510 | }
|
22511 |
|
22512 | function createInjector$2(config, modules) {
|
22513 | var bootstrapModules = [{
|
22514 | config: ['value', config]
|
22515 | }, core$1].concat(modules || []);
|
22516 | return bootstrap$2(bootstrapModules);
|
22517 | }
|
22518 |
|
22519 | function _classCallCheck$C(instance, Constructor) {
|
22520 | if (!(instance instanceof Constructor)) {
|
22521 | throw new TypeError("Cannot call a class as a function");
|
22522 | }
|
22523 | }
|
22524 |
|
22525 | function _defineProperties$x(target, props) {
|
22526 | for (var i = 0; i < props.length; i++) {
|
22527 | var descriptor = props[i];
|
22528 | descriptor.enumerable = descriptor.enumerable || false;
|
22529 | descriptor.configurable = true;
|
22530 | if ("value" in descriptor) descriptor.writable = true;
|
22531 | Object.defineProperty(target, descriptor.key, descriptor);
|
22532 | }
|
22533 | }
|
22534 |
|
22535 | function _createClass$x(Constructor, protoProps, staticProps) {
|
22536 | if (protoProps) _defineProperties$x(Constructor.prototype, protoProps);
|
22537 | if (staticProps) _defineProperties$x(Constructor, staticProps);
|
22538 | return Constructor;
|
22539 | }
|
22540 | |
22541 |
|
22542 |
|
22543 |
|
22544 |
|
22545 |
|
22546 |
|
22547 |
|
22548 | var ElementRegistry$2 =
|
22549 |
|
22550 | function () {
|
22551 | function ElementRegistry(viewer, eventBus) {
|
22552 | _classCallCheck$C(this, ElementRegistry);
|
22553 |
|
22554 | this._eventBus = eventBus;
|
22555 | this._viewer = viewer;
|
22556 | }
|
22557 |
|
22558 | _createClass$x(ElementRegistry, [{
|
22559 | key: "getDecision",
|
22560 | value: function getDecision() {
|
22561 | return this._viewer.getDecision();
|
22562 | }
|
22563 | }, {
|
22564 | key: "updateId",
|
22565 | value: function updateId(element, newId) {
|
22566 | var decision = this.getDecision();
|
22567 |
|
22568 | if (element !== decision) {
|
22569 | throw new Error('element !== decision');
|
22570 | }
|
22571 |
|
22572 | this._eventBus.fire('element.updateId', {
|
22573 | element: element,
|
22574 | newId: newId
|
22575 | });
|
22576 |
|
22577 | element.id = newId;
|
22578 | }
|
22579 | }]);
|
22580 |
|
22581 | return ElementRegistry;
|
22582 | }();
|
22583 | ElementRegistry$2.$inject = ['viewer', 'eventBus'];
|
22584 |
|
22585 | var CoreModule$2 = {
|
22586 | __init__: ['elementRegistry'],
|
22587 | elementRegistry: ['type', ElementRegistry$2]
|
22588 | };
|
22589 |
|
22590 | function _typeof$m(obj) {
|
22591 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
22592 | _typeof$m = function _typeof$1(obj) {
|
22593 | return _typeof(obj);
|
22594 | };
|
22595 | } else {
|
22596 | _typeof$m = function _typeof$1(obj) {
|
22597 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
22598 | };
|
22599 | }
|
22600 |
|
22601 | return _typeof$m(obj);
|
22602 | }
|
22603 |
|
22604 | function _classCallCheck$D(instance, Constructor) {
|
22605 | if (!(instance instanceof Constructor)) {
|
22606 | throw new TypeError("Cannot call a class as a function");
|
22607 | }
|
22608 | }
|
22609 |
|
22610 | function _defineProperties$y(target, props) {
|
22611 | for (var i = 0; i < props.length; i++) {
|
22612 | var descriptor = props[i];
|
22613 | descriptor.enumerable = descriptor.enumerable || false;
|
22614 | descriptor.configurable = true;
|
22615 | if ("value" in descriptor) descriptor.writable = true;
|
22616 | Object.defineProperty(target, descriptor.key, descriptor);
|
22617 | }
|
22618 | }
|
22619 |
|
22620 | function _createClass$y(Constructor, protoProps, staticProps) {
|
22621 | if (protoProps) _defineProperties$y(Constructor.prototype, protoProps);
|
22622 | if (staticProps) _defineProperties$y(Constructor, staticProps);
|
22623 | return Constructor;
|
22624 | }
|
22625 |
|
22626 | function _possibleConstructorReturn$i(self, call) {
|
22627 | if (call && (_typeof$m(call) === "object" || typeof call === "function")) {
|
22628 | return call;
|
22629 | }
|
22630 |
|
22631 | return _assertThisInitialized$i(self);
|
22632 | }
|
22633 |
|
22634 | function _assertThisInitialized$i(self) {
|
22635 | if (self === void 0) {
|
22636 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
22637 | }
|
22638 |
|
22639 | return self;
|
22640 | }
|
22641 |
|
22642 | function _getPrototypeOf$i(o) {
|
22643 | _getPrototypeOf$i = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
22644 | return o.__proto__ || Object.getPrototypeOf(o);
|
22645 | };
|
22646 | return _getPrototypeOf$i(o);
|
22647 | }
|
22648 |
|
22649 | function _inherits$i(subClass, superClass) {
|
22650 | if (typeof superClass !== "function" && superClass !== null) {
|
22651 | throw new TypeError("Super expression must either be null or a function");
|
22652 | }
|
22653 |
|
22654 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
22655 | constructor: {
|
22656 | value: subClass,
|
22657 | writable: true,
|
22658 | configurable: true
|
22659 | }
|
22660 | });
|
22661 | if (superClass) _setPrototypeOf$i(subClass, superClass);
|
22662 | }
|
22663 |
|
22664 | function _setPrototypeOf$i(o, p) {
|
22665 | _setPrototypeOf$i = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
22666 | o.__proto__ = p;
|
22667 | return o;
|
22668 | };
|
22669 |
|
22670 | return _setPrototypeOf$i(o, p);
|
22671 | }
|
22672 |
|
22673 | var DecisionPropertiesComponent =
|
22674 |
|
22675 | function (_Component) {
|
22676 | _inherits$i(DecisionPropertiesComponent, _Component);
|
22677 |
|
22678 | function DecisionPropertiesComponent(props, context) {
|
22679 | var _this;
|
22680 |
|
22681 | _classCallCheck$D(this, DecisionPropertiesComponent);
|
22682 |
|
22683 | _this = _possibleConstructorReturn$i(this, _getPrototypeOf$i(DecisionPropertiesComponent).call(this, props, context));
|
22684 | _this._viewer = context.injector.get('viewer');
|
22685 | return _this;
|
22686 | }
|
22687 |
|
22688 | _createClass$y(DecisionPropertiesComponent, [{
|
22689 | key: "render",
|
22690 | value: function render() {
|
22691 |
|
22692 | var _this$_viewer$getDeci = this._viewer.getDecision(),
|
22693 | name = _this$_viewer$getDeci.name;
|
22694 |
|
22695 | return createVNode(1, "div", "decision-properties", createVNode(1, "h3", "decision-name", name, 0), 2);
|
22696 | }
|
22697 | }]);
|
22698 |
|
22699 | return DecisionPropertiesComponent;
|
22700 | }(Component);
|
22701 |
|
22702 | function _classCallCheck$E(instance, Constructor) {
|
22703 | if (!(instance instanceof Constructor)) {
|
22704 | throw new TypeError("Cannot call a class as a function");
|
22705 | }
|
22706 | }
|
22707 | var HIGH_PRIORITY = 1500;
|
22708 |
|
22709 | var DecisionProperties = function DecisionProperties(components) {
|
22710 | _classCallCheck$E(this, DecisionProperties);
|
22711 |
|
22712 | components.onGetComponent('viewer', HIGH_PRIORITY, function () {
|
22713 | return DecisionPropertiesComponent;
|
22714 | });
|
22715 | };
|
22716 | DecisionProperties.$inject = ['components'];
|
22717 |
|
22718 | var DecisionPropertiesModule = {
|
22719 | __init__: ['decisionProperties'],
|
22720 | decisionProperties: ['type', DecisionProperties]
|
22721 | };
|
22722 |
|
22723 | function _typeof$n(obj) {
|
22724 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
22725 | _typeof$n = function _typeof$1(obj) {
|
22726 | return _typeof(obj);
|
22727 | };
|
22728 | } else {
|
22729 | _typeof$n = function _typeof$1(obj) {
|
22730 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
22731 | };
|
22732 | }
|
22733 |
|
22734 | return _typeof$n(obj);
|
22735 | }
|
22736 |
|
22737 | function _classCallCheck$F(instance, Constructor) {
|
22738 | if (!(instance instanceof Constructor)) {
|
22739 | throw new TypeError("Cannot call a class as a function");
|
22740 | }
|
22741 | }
|
22742 |
|
22743 | function _defineProperties$z(target, props) {
|
22744 | for (var i = 0; i < props.length; i++) {
|
22745 | var descriptor = props[i];
|
22746 | descriptor.enumerable = descriptor.enumerable || false;
|
22747 | descriptor.configurable = true;
|
22748 | if ("value" in descriptor) descriptor.writable = true;
|
22749 | Object.defineProperty(target, descriptor.key, descriptor);
|
22750 | }
|
22751 | }
|
22752 |
|
22753 | function _createClass$z(Constructor, protoProps, staticProps) {
|
22754 | if (protoProps) _defineProperties$z(Constructor.prototype, protoProps);
|
22755 | if (staticProps) _defineProperties$z(Constructor, staticProps);
|
22756 | return Constructor;
|
22757 | }
|
22758 |
|
22759 | function _possibleConstructorReturn$j(self, call) {
|
22760 | if (call && (_typeof$n(call) === "object" || typeof call === "function")) {
|
22761 | return call;
|
22762 | }
|
22763 |
|
22764 | return _assertThisInitialized$j(self);
|
22765 | }
|
22766 |
|
22767 | function _assertThisInitialized$j(self) {
|
22768 | if (self === void 0) {
|
22769 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
22770 | }
|
22771 |
|
22772 | return self;
|
22773 | }
|
22774 |
|
22775 | function _getPrototypeOf$j(o) {
|
22776 | _getPrototypeOf$j = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
22777 | return o.__proto__ || Object.getPrototypeOf(o);
|
22778 | };
|
22779 | return _getPrototypeOf$j(o);
|
22780 | }
|
22781 |
|
22782 | function _inherits$j(subClass, superClass) {
|
22783 | if (typeof superClass !== "function" && superClass !== null) {
|
22784 | throw new TypeError("Super expression must either be null or a function");
|
22785 | }
|
22786 |
|
22787 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
22788 | constructor: {
|
22789 | value: subClass,
|
22790 | writable: true,
|
22791 | configurable: true
|
22792 | }
|
22793 | });
|
22794 | if (superClass) _setPrototypeOf$j(subClass, superClass);
|
22795 | }
|
22796 |
|
22797 | function _setPrototypeOf$j(o, p) {
|
22798 | _setPrototypeOf$j = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
22799 | o.__proto__ = p;
|
22800 | return o;
|
22801 | };
|
22802 |
|
22803 | return _setPrototypeOf$j(o, p);
|
22804 | }
|
22805 |
|
22806 | var LiteralExpressionPropertiesComponent =
|
22807 |
|
22808 | function (_Component) {
|
22809 | _inherits$j(LiteralExpressionPropertiesComponent, _Component);
|
22810 |
|
22811 | function LiteralExpressionPropertiesComponent(props, context) {
|
22812 | var _this;
|
22813 |
|
22814 | _classCallCheck$F(this, LiteralExpressionPropertiesComponent);
|
22815 |
|
22816 | _this = _possibleConstructorReturn$j(this, _getPrototypeOf$j(LiteralExpressionPropertiesComponent).call(this, props, context));
|
22817 | _this._viewer = context.injector.get('viewer');
|
22818 | return _this;
|
22819 | }
|
22820 |
|
22821 | _createClass$z(LiteralExpressionPropertiesComponent, [{
|
22822 | key: "render",
|
22823 | value: function render() {
|
22824 | var _this$_viewer$getDeci = this._viewer.getDecision(),
|
22825 | literalExpression = _this$_viewer$getDeci.decisionLogic,
|
22826 | variable = _this$_viewer$getDeci.variable;
|
22827 |
|
22828 | return createVNode(1, "div", "literal-expression-properties", createVNode(1, "table", null, [createVNode(1, "tr", null, [createVNode(1, "td", null, createTextVNode("Variable Name:"), 2), createVNode(1, "td", null, createVNode(1, "span", null, variable.name || '-', 0), 2)], 4), createVNode(1, "tr", null, [createVNode(1, "td", null, createTextVNode("Variable Type:"), 2), createVNode(1, "td", null, createVNode(1, "span", null, variable.typeRef || '-', 0), 2)], 4), createVNode(1, "tr", null, [createVNode(1, "td", null, createTextVNode("Expression Language:"), 2), createVNode(1, "td", null, createVNode(1, "span", null, literalExpression.expressionLanguage || '-', 0), 2)], 4)], 4), 2);
|
22829 | }
|
22830 | }]);
|
22831 |
|
22832 | return LiteralExpressionPropertiesComponent;
|
22833 | }(Component);
|
22834 |
|
22835 | function _classCallCheck$G(instance, Constructor) {
|
22836 | if (!(instance instanceof Constructor)) {
|
22837 | throw new TypeError("Cannot call a class as a function");
|
22838 | }
|
22839 | }
|
22840 | var LOW_PRIORITY$4 = 500;
|
22841 |
|
22842 | var DecisionProperties$1 = function DecisionProperties(components) {
|
22843 | _classCallCheck$G(this, DecisionProperties);
|
22844 |
|
22845 | components.onGetComponent('viewer', LOW_PRIORITY$4, function () {
|
22846 | return LiteralExpressionPropertiesComponent;
|
22847 | });
|
22848 | };
|
22849 | DecisionProperties$1.$inject = ['components'];
|
22850 |
|
22851 | var LiteralExpressionPropertiesModule = {
|
22852 | __depends__: [ExpressionLanguagesModule],
|
22853 | __init__: ['literalExpressionProperties'],
|
22854 | literalExpressionProperties: ['type', DecisionProperties$1]
|
22855 | };
|
22856 |
|
22857 | function _typeof$o(obj) {
|
22858 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
22859 | _typeof$o = function _typeof$1(obj) {
|
22860 | return _typeof(obj);
|
22861 | };
|
22862 | } else {
|
22863 | _typeof$o = function _typeof$1(obj) {
|
22864 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
22865 | };
|
22866 | }
|
22867 |
|
22868 | return _typeof$o(obj);
|
22869 | }
|
22870 |
|
22871 | function _classCallCheck$H(instance, Constructor) {
|
22872 | if (!(instance instanceof Constructor)) {
|
22873 | throw new TypeError("Cannot call a class as a function");
|
22874 | }
|
22875 | }
|
22876 |
|
22877 | function _defineProperties$A(target, props) {
|
22878 | for (var i = 0; i < props.length; i++) {
|
22879 | var descriptor = props[i];
|
22880 | descriptor.enumerable = descriptor.enumerable || false;
|
22881 | descriptor.configurable = true;
|
22882 | if ("value" in descriptor) descriptor.writable = true;
|
22883 | Object.defineProperty(target, descriptor.key, descriptor);
|
22884 | }
|
22885 | }
|
22886 |
|
22887 | function _createClass$A(Constructor, protoProps, staticProps) {
|
22888 | if (protoProps) _defineProperties$A(Constructor.prototype, protoProps);
|
22889 | if (staticProps) _defineProperties$A(Constructor, staticProps);
|
22890 | return Constructor;
|
22891 | }
|
22892 |
|
22893 | function _possibleConstructorReturn$k(self, call) {
|
22894 | if (call && (_typeof$o(call) === "object" || typeof call === "function")) {
|
22895 | return call;
|
22896 | }
|
22897 |
|
22898 | return _assertThisInitialized$k(self);
|
22899 | }
|
22900 |
|
22901 | function _getPrototypeOf$k(o) {
|
22902 | _getPrototypeOf$k = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
22903 | return o.__proto__ || Object.getPrototypeOf(o);
|
22904 | };
|
22905 | return _getPrototypeOf$k(o);
|
22906 | }
|
22907 |
|
22908 | function _assertThisInitialized$k(self) {
|
22909 | if (self === void 0) {
|
22910 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
22911 | }
|
22912 |
|
22913 | return self;
|
22914 | }
|
22915 |
|
22916 | function _inherits$k(subClass, superClass) {
|
22917 | if (typeof superClass !== "function" && superClass !== null) {
|
22918 | throw new TypeError("Super expression must either be null or a function");
|
22919 | }
|
22920 |
|
22921 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
22922 | constructor: {
|
22923 | value: subClass,
|
22924 | writable: true,
|
22925 | configurable: true
|
22926 | }
|
22927 | });
|
22928 | if (superClass) _setPrototypeOf$k(subClass, superClass);
|
22929 | }
|
22930 |
|
22931 | function _setPrototypeOf$k(o, p) {
|
22932 | _setPrototypeOf$k = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
22933 | o.__proto__ = p;
|
22934 | return o;
|
22935 | };
|
22936 |
|
22937 | return _setPrototypeOf$k(o, p);
|
22938 | }
|
22939 |
|
22940 | function _defineProperty$a(obj, key, value) {
|
22941 | if (key in obj) {
|
22942 | Object.defineProperty(obj, key, {
|
22943 | value: value,
|
22944 | enumerable: true,
|
22945 | configurable: true,
|
22946 | writable: true
|
22947 | });
|
22948 | } else {
|
22949 | obj[key] = value;
|
22950 | }
|
22951 |
|
22952 | return obj;
|
22953 | }
|
22954 |
|
22955 | var PoweredByLogoComponent$1 =
|
22956 |
|
22957 | function (_Component) {
|
22958 | _inherits$k(PoweredByLogoComponent, _Component);
|
22959 |
|
22960 | function PoweredByLogoComponent(props, context) {
|
22961 | var _this;
|
22962 |
|
22963 | _classCallCheck$H(this, PoweredByLogoComponent);
|
22964 |
|
22965 | _this = _possibleConstructorReturn$k(this, _getPrototypeOf$k(PoweredByLogoComponent).call(this, props, context));
|
22966 |
|
22967 | _defineProperty$a(_assertThisInitialized$k(_this), "onClick", function () {
|
22968 | _this._eventBus.fire('poweredBy.show');
|
22969 | });
|
22970 |
|
22971 | var injector = context.injector;
|
22972 | _this._eventBus = injector.get('eventBus');
|
22973 | return _this;
|
22974 | }
|
22975 |
|
22976 | _createClass$A(PoweredByLogoComponent, [{
|
22977 | key: "render",
|
22978 | value: function render() {
|
22979 | var _this2 = this;
|
22980 |
|
22981 | return createVNode(1, "div", "powered-by", createVNode(1, "div", "powered-by__logo", createComponentVNode(2, Logo), 2), 2, {
|
22982 | "onClick": this.onClick,
|
22983 | "title": "Powered by bpmn.io"
|
22984 | }, null, function (node) {
|
22985 | return _this2.node = node;
|
22986 | });
|
22987 | }
|
22988 | }]);
|
22989 |
|
22990 | return PoweredByLogoComponent;
|
22991 | }(Component);
|
22992 |
|
22993 | function _typeof$p(obj) {
|
22994 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
22995 | _typeof$p = function _typeof$1(obj) {
|
22996 | return _typeof(obj);
|
22997 | };
|
22998 | } else {
|
22999 | _typeof$p = function _typeof$1(obj) {
|
23000 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
23001 | };
|
23002 | }
|
23003 |
|
23004 | return _typeof$p(obj);
|
23005 | }
|
23006 |
|
23007 | function _classCallCheck$I(instance, Constructor) {
|
23008 | if (!(instance instanceof Constructor)) {
|
23009 | throw new TypeError("Cannot call a class as a function");
|
23010 | }
|
23011 | }
|
23012 |
|
23013 | function _defineProperties$B(target, props) {
|
23014 | for (var i = 0; i < props.length; i++) {
|
23015 | var descriptor = props[i];
|
23016 | descriptor.enumerable = descriptor.enumerable || false;
|
23017 | descriptor.configurable = true;
|
23018 | if ("value" in descriptor) descriptor.writable = true;
|
23019 | Object.defineProperty(target, descriptor.key, descriptor);
|
23020 | }
|
23021 | }
|
23022 |
|
23023 | function _createClass$B(Constructor, protoProps, staticProps) {
|
23024 | if (protoProps) _defineProperties$B(Constructor.prototype, protoProps);
|
23025 | if (staticProps) _defineProperties$B(Constructor, staticProps);
|
23026 | return Constructor;
|
23027 | }
|
23028 |
|
23029 | function _possibleConstructorReturn$l(self, call) {
|
23030 | if (call && (_typeof$p(call) === "object" || typeof call === "function")) {
|
23031 | return call;
|
23032 | }
|
23033 |
|
23034 | return _assertThisInitialized$l(self);
|
23035 | }
|
23036 |
|
23037 | function _getPrototypeOf$l(o) {
|
23038 | _getPrototypeOf$l = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
23039 | return o.__proto__ || Object.getPrototypeOf(o);
|
23040 | };
|
23041 | return _getPrototypeOf$l(o);
|
23042 | }
|
23043 |
|
23044 | function _assertThisInitialized$l(self) {
|
23045 | if (self === void 0) {
|
23046 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
23047 | }
|
23048 |
|
23049 | return self;
|
23050 | }
|
23051 |
|
23052 | function _inherits$l(subClass, superClass) {
|
23053 | if (typeof superClass !== "function" && superClass !== null) {
|
23054 | throw new TypeError("Super expression must either be null or a function");
|
23055 | }
|
23056 |
|
23057 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
23058 | constructor: {
|
23059 | value: subClass,
|
23060 | writable: true,
|
23061 | configurable: true
|
23062 | }
|
23063 | });
|
23064 | if (superClass) _setPrototypeOf$l(subClass, superClass);
|
23065 | }
|
23066 |
|
23067 | function _setPrototypeOf$l(o, p) {
|
23068 | _setPrototypeOf$l = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
23069 | o.__proto__ = p;
|
23070 | return o;
|
23071 | };
|
23072 |
|
23073 | return _setPrototypeOf$l(o, p);
|
23074 | }
|
23075 |
|
23076 | var PoweredByOverlayComponent$1 =
|
23077 |
|
23078 | function (_Component) {
|
23079 | _inherits$l(PoweredByOverlayComponent, _Component);
|
23080 |
|
23081 | function PoweredByOverlayComponent(props) {
|
23082 | var _this;
|
23083 |
|
23084 | _classCallCheck$I(this, PoweredByOverlayComponent);
|
23085 |
|
23086 | _this = _possibleConstructorReturn$l(this, _getPrototypeOf$l(PoweredByOverlayComponent).call(this, props));
|
23087 | _this.state = {
|
23088 | show: false
|
23089 | };
|
23090 | _this.onClick = _this.onClick.bind(_assertThisInitialized$l(_this));
|
23091 | _this.onShow = _this.onShow.bind(_assertThisInitialized$l(_this));
|
23092 | return _this;
|
23093 | }
|
23094 |
|
23095 | _createClass$B(PoweredByOverlayComponent, [{
|
23096 | key: "onClick",
|
23097 | value: function onClick() {
|
23098 | this.setState({
|
23099 | show: false
|
23100 | });
|
23101 | }
|
23102 | }, {
|
23103 | key: "onShow",
|
23104 | value: function onShow() {
|
23105 | this.setState({
|
23106 | show: true
|
23107 | });
|
23108 | }
|
23109 | }, {
|
23110 | key: "componentWillMount",
|
23111 | value: function componentWillMount() {
|
23112 | var eventBus = this._eventBus = this.context.injector.get('eventBus');
|
23113 | eventBus.on('poweredBy.show', this.onShow);
|
23114 | }
|
23115 | }, {
|
23116 | key: "componentWillUnmount",
|
23117 | value: function componentWillUnmount() {
|
23118 | this._eventBus.off('poweredBy.show', this.onShow);
|
23119 | }
|
23120 | }, {
|
23121 | key: "render",
|
23122 | value: function render() {
|
23123 | var show = this.state.show;
|
23124 | return show && createVNode(1, "div", "powered-by-overlay", createVNode(1, "div", "powered-by-overlay-content", [createVNode(1, "a", "logo", createComponentVNode(2, Logo), 2, {
|
23125 | "href": "https://bpmn.io",
|
23126 | "target": "_blank",
|
23127 | "rel": "noopener"
|
23128 | }), createVNode(1, "span", null, [createTextVNode("Web-based tooling for BPMN, DMN and CMMN diagrams powered by "), createVNode(1, "a", null, createTextVNode("bpmn.io"), 2, {
|
23129 | "href": "http://bpmn.io",
|
23130 | "target": "_blank"
|
23131 | }), createTextVNode(".")], 4)], 4, {
|
23132 | "onClick": function onClick(e) {
|
23133 | return e.stopPropagation();
|
23134 | }
|
23135 | }), 2, {
|
23136 | "onClick": this.onClick
|
23137 | });
|
23138 | }
|
23139 | }]);
|
23140 |
|
23141 | return PoweredByOverlayComponent;
|
23142 | }(Component);
|
23143 |
|
23144 | function _classCallCheck$J(instance, Constructor) {
|
23145 | if (!(instance instanceof Constructor)) {
|
23146 | throw new TypeError("Cannot call a class as a function");
|
23147 | }
|
23148 | }
|
23149 | var HIGHER_PRIORITY = 2000;
|
23150 |
|
23151 | var PoweredBy$1 = function PoweredBy(components, eventBus) {
|
23152 | _classCallCheck$J(this, PoweredBy);
|
23153 |
|
23154 | components.onGetComponent('viewer', HIGHER_PRIORITY, function () {
|
23155 | return PoweredByLogoComponent$1;
|
23156 | });
|
23157 | components.onGetComponent('viewer', function () {
|
23158 | return PoweredByOverlayComponent$1;
|
23159 | });
|
23160 | };
|
23161 | PoweredBy$1.$inject = ['components', 'eventBus'];
|
23162 |
|
23163 | var PoweredByModule$1 = {
|
23164 | __init__: ['poweredBy'],
|
23165 | poweredBy: ['type', PoweredBy$1]
|
23166 | };
|
23167 |
|
23168 | function _typeof$q(obj) {
|
23169 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
23170 | _typeof$q = function _typeof$1(obj) {
|
23171 | return _typeof(obj);
|
23172 | };
|
23173 | } else {
|
23174 | _typeof$q = function _typeof$1(obj) {
|
23175 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
23176 | };
|
23177 | }
|
23178 |
|
23179 | return _typeof$q(obj);
|
23180 | }
|
23181 |
|
23182 | function _classCallCheck$K(instance, Constructor) {
|
23183 | if (!(instance instanceof Constructor)) {
|
23184 | throw new TypeError("Cannot call a class as a function");
|
23185 | }
|
23186 | }
|
23187 |
|
23188 | function _defineProperties$C(target, props) {
|
23189 | for (var i = 0; i < props.length; i++) {
|
23190 | var descriptor = props[i];
|
23191 | descriptor.enumerable = descriptor.enumerable || false;
|
23192 | descriptor.configurable = true;
|
23193 | if ("value" in descriptor) descriptor.writable = true;
|
23194 | Object.defineProperty(target, descriptor.key, descriptor);
|
23195 | }
|
23196 | }
|
23197 |
|
23198 | function _createClass$C(Constructor, protoProps, staticProps) {
|
23199 | if (protoProps) _defineProperties$C(Constructor.prototype, protoProps);
|
23200 | if (staticProps) _defineProperties$C(Constructor, staticProps);
|
23201 | return Constructor;
|
23202 | }
|
23203 |
|
23204 | function _possibleConstructorReturn$m(self, call) {
|
23205 | if (call && (_typeof$q(call) === "object" || typeof call === "function")) {
|
23206 | return call;
|
23207 | }
|
23208 |
|
23209 | return _assertThisInitialized$m(self);
|
23210 | }
|
23211 |
|
23212 | function _assertThisInitialized$m(self) {
|
23213 | if (self === void 0) {
|
23214 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
23215 | }
|
23216 |
|
23217 | return self;
|
23218 | }
|
23219 |
|
23220 | function _getPrototypeOf$m(o) {
|
23221 | _getPrototypeOf$m = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
23222 | return o.__proto__ || Object.getPrototypeOf(o);
|
23223 | };
|
23224 | return _getPrototypeOf$m(o);
|
23225 | }
|
23226 |
|
23227 | function _inherits$m(subClass, superClass) {
|
23228 | if (typeof superClass !== "function" && superClass !== null) {
|
23229 | throw new TypeError("Super expression must either be null or a function");
|
23230 | }
|
23231 |
|
23232 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
23233 | constructor: {
|
23234 | value: subClass,
|
23235 | writable: true,
|
23236 | configurable: true
|
23237 | }
|
23238 | });
|
23239 | if (superClass) _setPrototypeOf$m(subClass, superClass);
|
23240 | }
|
23241 |
|
23242 | function _setPrototypeOf$m(o, p) {
|
23243 | _setPrototypeOf$m = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
23244 | o.__proto__ = p;
|
23245 | return o;
|
23246 | };
|
23247 |
|
23248 | return _setPrototypeOf$m(o, p);
|
23249 | }
|
23250 |
|
23251 | var TextareaComponent =
|
23252 |
|
23253 | function (_Component) {
|
23254 | _inherits$m(TextareaComponent, _Component);
|
23255 |
|
23256 | function TextareaComponent(props, context) {
|
23257 | var _this;
|
23258 |
|
23259 | _classCallCheck$K(this, TextareaComponent);
|
23260 |
|
23261 | _this = _possibleConstructorReturn$m(this, _getPrototypeOf$m(TextareaComponent).call(this, props, context));
|
23262 | _this._viewer = context.injector.get('viewer');
|
23263 | return _this;
|
23264 | }
|
23265 |
|
23266 | _createClass$C(TextareaComponent, [{
|
23267 | key: "render",
|
23268 | value: function render() {
|
23269 | var text = this._viewer.getDecision().decisionLogic.text;
|
23270 |
|
23271 | return createVNode(1, "div", "textarea", createVNode(1, "div", "content", text, 0), 2);
|
23272 | }
|
23273 | }]);
|
23274 |
|
23275 | return TextareaComponent;
|
23276 | }(Component);
|
23277 |
|
23278 | function _classCallCheck$L(instance, Constructor) {
|
23279 | if (!(instance instanceof Constructor)) {
|
23280 | throw new TypeError("Cannot call a class as a function");
|
23281 | }
|
23282 | }
|
23283 |
|
23284 | var Textarea = function Textarea(components) {
|
23285 | _classCallCheck$L(this, Textarea);
|
23286 |
|
23287 | components.onGetComponent('viewer', function () {
|
23288 | return TextareaComponent;
|
23289 | });
|
23290 | };
|
23291 | Textarea.$inject = ['components'];
|
23292 |
|
23293 | var TextareaModule = {
|
23294 | __init__: ['textarea'],
|
23295 | textarea: ['type', Textarea]
|
23296 | };
|
23297 |
|
23298 | function _typeof$r(obj) {
|
23299 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
23300 | _typeof$r = function _typeof$1(obj) {
|
23301 | return _typeof(obj);
|
23302 | };
|
23303 | } else {
|
23304 | _typeof$r = function _typeof$1(obj) {
|
23305 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
23306 | };
|
23307 | }
|
23308 |
|
23309 | return _typeof$r(obj);
|
23310 | }
|
23311 |
|
23312 | function _classCallCheck$M(instance, Constructor) {
|
23313 | if (!(instance instanceof Constructor)) {
|
23314 | throw new TypeError("Cannot call a class as a function");
|
23315 | }
|
23316 | }
|
23317 |
|
23318 | function _defineProperties$D(target, props) {
|
23319 | for (var i = 0; i < props.length; i++) {
|
23320 | var descriptor = props[i];
|
23321 | descriptor.enumerable = descriptor.enumerable || false;
|
23322 | descriptor.configurable = true;
|
23323 | if ("value" in descriptor) descriptor.writable = true;
|
23324 | Object.defineProperty(target, descriptor.key, descriptor);
|
23325 | }
|
23326 | }
|
23327 |
|
23328 | function _createClass$D(Constructor, protoProps, staticProps) {
|
23329 | if (protoProps) _defineProperties$D(Constructor.prototype, protoProps);
|
23330 | if (staticProps) _defineProperties$D(Constructor, staticProps);
|
23331 | return Constructor;
|
23332 | }
|
23333 |
|
23334 | function _possibleConstructorReturn$n(self, call) {
|
23335 | if (call && (_typeof$r(call) === "object" || typeof call === "function")) {
|
23336 | return call;
|
23337 | }
|
23338 |
|
23339 | return _assertThisInitialized$n(self);
|
23340 | }
|
23341 |
|
23342 | function _getPrototypeOf$n(o) {
|
23343 | _getPrototypeOf$n = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
23344 | return o.__proto__ || Object.getPrototypeOf(o);
|
23345 | };
|
23346 | return _getPrototypeOf$n(o);
|
23347 | }
|
23348 |
|
23349 | function _assertThisInitialized$n(self) {
|
23350 | if (self === void 0) {
|
23351 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
23352 | }
|
23353 |
|
23354 | return self;
|
23355 | }
|
23356 |
|
23357 | function _inherits$n(subClass, superClass) {
|
23358 | if (typeof superClass !== "function" && superClass !== null) {
|
23359 | throw new TypeError("Super expression must either be null or a function");
|
23360 | }
|
23361 |
|
23362 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
23363 | constructor: {
|
23364 | value: subClass,
|
23365 | writable: true,
|
23366 | configurable: true
|
23367 | }
|
23368 | });
|
23369 | if (superClass) _setPrototypeOf$n(subClass, superClass);
|
23370 | }
|
23371 |
|
23372 | function _setPrototypeOf$n(o, p) {
|
23373 | _setPrototypeOf$n = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
23374 | o.__proto__ = p;
|
23375 | return o;
|
23376 | };
|
23377 |
|
23378 | return _setPrototypeOf$n(o, p);
|
23379 | }
|
23380 |
|
23381 | function _defineProperty$b(obj, key, value) {
|
23382 | if (key in obj) {
|
23383 | Object.defineProperty(obj, key, {
|
23384 | value: value,
|
23385 | enumerable: true,
|
23386 | configurable: true,
|
23387 | writable: true
|
23388 | });
|
23389 | } else {
|
23390 | obj[key] = value;
|
23391 | }
|
23392 |
|
23393 | return obj;
|
23394 | }
|
23395 |
|
23396 | var ViewDrdComponent$1 =
|
23397 |
|
23398 | function (_Component) {
|
23399 | _inherits$n(ViewDrdComponent, _Component);
|
23400 |
|
23401 | function ViewDrdComponent(props, context) {
|
23402 | var _this;
|
23403 |
|
23404 | _classCallCheck$M(this, ViewDrdComponent);
|
23405 |
|
23406 | _this = _possibleConstructorReturn$n(this, _getPrototypeOf$n(ViewDrdComponent).call(this, props, context));
|
23407 |
|
23408 | _defineProperty$b(_assertThisInitialized$n(_this), "onClick", function () {
|
23409 | _this._eventBus.fire('showDrd');
|
23410 | });
|
23411 |
|
23412 | var injector = context.injector;
|
23413 | _this._eventBus = injector.get('eventBus');
|
23414 | return _this;
|
23415 | }
|
23416 |
|
23417 | _createClass$D(ViewDrdComponent, [{
|
23418 | key: "render",
|
23419 | value: function render() {
|
23420 | var _this2 = this;
|
23421 |
|
23422 | return createVNode(1, "div", "view-drd", createVNode(1, "button", "view-drd-button", createTextVNode("View DRD"), 2, {
|
23423 | "onClick": this.onClick
|
23424 | }), 2, null, null, function (node) {
|
23425 | return _this2.node = node;
|
23426 | });
|
23427 | }
|
23428 | }]);
|
23429 |
|
23430 | return ViewDrdComponent;
|
23431 | }(Component);
|
23432 |
|
23433 | function _classCallCheck$N(instance, Constructor) {
|
23434 | if (!(instance instanceof Constructor)) {
|
23435 | throw new TypeError("Cannot call a class as a function");
|
23436 | }
|
23437 | }
|
23438 |
|
23439 | function _defineProperties$E(target, props) {
|
23440 | for (var i = 0; i < props.length; i++) {
|
23441 | var descriptor = props[i];
|
23442 | descriptor.enumerable = descriptor.enumerable || false;
|
23443 | descriptor.configurable = true;
|
23444 | if ("value" in descriptor) descriptor.writable = true;
|
23445 | Object.defineProperty(target, descriptor.key, descriptor);
|
23446 | }
|
23447 | }
|
23448 |
|
23449 | function _createClass$E(Constructor, protoProps, staticProps) {
|
23450 | if (protoProps) _defineProperties$E(Constructor.prototype, protoProps);
|
23451 | if (staticProps) _defineProperties$E(Constructor, staticProps);
|
23452 | return Constructor;
|
23453 | }
|
23454 | var VERY_HIGH_PRIORITY = 2000;
|
23455 |
|
23456 | var ViewDrd$1 =
|
23457 |
|
23458 | function () {
|
23459 | function ViewDrd(components, viewer, eventBus, injector) {
|
23460 | var _this = this;
|
23461 |
|
23462 | _classCallCheck$N(this, ViewDrd);
|
23463 |
|
23464 | this._injector = injector;
|
23465 | this._viewer = viewer;
|
23466 | components.onGetComponent('viewer', VERY_HIGH_PRIORITY, function () {
|
23467 | if (_this.canViewDrd()) {
|
23468 | return ViewDrdComponent$1;
|
23469 | }
|
23470 | });
|
23471 | eventBus.on('showDrd', function () {
|
23472 | var parent = injector.get('_parent', false);
|
23473 |
|
23474 | var definitions = _this.getDefinitions();
|
23475 |
|
23476 |
|
23477 | var view = parent.getView(definitions);
|
23478 | parent.open(view);
|
23479 | });
|
23480 | }
|
23481 |
|
23482 | _createClass$E(ViewDrd, [{
|
23483 | key: "canViewDrd",
|
23484 | value: function canViewDrd() {
|
23485 | var parent = this._injector.get('_parent', false);
|
23486 |
|
23487 | if (!parent) {
|
23488 | return;
|
23489 | }
|
23490 |
|
23491 |
|
23492 | var definitions = this.getDefinitions();
|
23493 | return !!parent.getView(definitions);
|
23494 | }
|
23495 | }, {
|
23496 | key: "getDefinitions",
|
23497 | value: function getDefinitions() {
|
23498 | return _getDefinitions(this._viewer.getDecision());
|
23499 | }
|
23500 | }]);
|
23501 |
|
23502 | return ViewDrd;
|
23503 | }();
|
23504 | ViewDrd$1.$inject = ['components', 'viewer', 'eventBus', 'injector'];
|
23505 |
|
23506 | function _getDefinitions(decision) {
|
23507 | var definitions = decision.$parent;
|
23508 | return definitions;
|
23509 | }
|
23510 |
|
23511 | var ViewDrdModule = {
|
23512 | __init__: ['viewDrd'],
|
23513 | viewDrd: ['type', ViewDrd$1]
|
23514 | };
|
23515 |
|
23516 | function _typeof$s(obj) {
|
23517 | if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
|
23518 | _typeof$s = function _typeof$1(obj) {
|
23519 | return _typeof(obj);
|
23520 | };
|
23521 | } else {
|
23522 | _typeof$s = function _typeof$1(obj) {
|
23523 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
|
23524 | };
|
23525 | }
|
23526 |
|
23527 | return _typeof$s(obj);
|
23528 | }
|
23529 |
|
23530 | function _toConsumableArray$8(arr) {
|
23531 | return _arrayWithoutHoles$6(arr) || _iterableToArray$6(arr) || _nonIterableSpread$6();
|
23532 | }
|
23533 |
|
23534 | function _nonIterableSpread$6() {
|
23535 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
23536 | }
|
23537 |
|
23538 | function _iterableToArray$6(iter) {
|
23539 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
23540 | }
|
23541 |
|
23542 | function _arrayWithoutHoles$6(arr) {
|
23543 | if (Array.isArray(arr)) {
|
23544 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
23545 | arr2[i] = arr[i];
|
23546 | }
|
23547 |
|
23548 | return arr2;
|
23549 | }
|
23550 | }
|
23551 |
|
23552 | function _objectWithoutProperties$6(source, excluded) {
|
23553 | if (source == null) return {};
|
23554 |
|
23555 | var target = _objectWithoutPropertiesLoose$6(source, excluded);
|
23556 |
|
23557 | var key, i;
|
23558 |
|
23559 | if (Object.getOwnPropertySymbols) {
|
23560 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
23561 |
|
23562 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
23563 | key = sourceSymbolKeys[i];
|
23564 | if (excluded.indexOf(key) >= 0) continue;
|
23565 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
23566 | target[key] = source[key];
|
23567 | }
|
23568 | }
|
23569 |
|
23570 | return target;
|
23571 | }
|
23572 |
|
23573 | function _objectWithoutPropertiesLoose$6(source, excluded) {
|
23574 | if (source == null) return {};
|
23575 | var target = {};
|
23576 | var sourceKeys = Object.keys(source);
|
23577 | var key, i;
|
23578 |
|
23579 | for (i = 0; i < sourceKeys.length; i++) {
|
23580 | key = sourceKeys[i];
|
23581 | if (excluded.indexOf(key) >= 0) continue;
|
23582 | target[key] = source[key];
|
23583 | }
|
23584 |
|
23585 | return target;
|
23586 | }
|
23587 |
|
23588 | function _classCallCheck$O(instance, Constructor) {
|
23589 | if (!(instance instanceof Constructor)) {
|
23590 | throw new TypeError("Cannot call a class as a function");
|
23591 | }
|
23592 | }
|
23593 |
|
23594 | function _defineProperties$F(target, props) {
|
23595 | for (var i = 0; i < props.length; i++) {
|
23596 | var descriptor = props[i];
|
23597 | descriptor.enumerable = descriptor.enumerable || false;
|
23598 | descriptor.configurable = true;
|
23599 | if ("value" in descriptor) descriptor.writable = true;
|
23600 | Object.defineProperty(target, descriptor.key, descriptor);
|
23601 | }
|
23602 | }
|
23603 |
|
23604 | function _createClass$F(Constructor, protoProps, staticProps) {
|
23605 | if (protoProps) _defineProperties$F(Constructor.prototype, protoProps);
|
23606 | if (staticProps) _defineProperties$F(Constructor, staticProps);
|
23607 | return Constructor;
|
23608 | }
|
23609 |
|
23610 | function _possibleConstructorReturn$o(self, call) {
|
23611 | if (call && (_typeof$s(call) === "object" || typeof call === "function")) {
|
23612 | return call;
|
23613 | }
|
23614 |
|
23615 | return _assertThisInitialized$o(self);
|
23616 | }
|
23617 |
|
23618 | function _assertThisInitialized$o(self) {
|
23619 | if (self === void 0) {
|
23620 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
23621 | }
|
23622 |
|
23623 | return self;
|
23624 | }
|
23625 |
|
23626 | function _get$1(target, property, receiver) {
|
23627 | if (typeof Reflect !== "undefined" && Reflect.get) {
|
23628 | _get$1 = Reflect.get;
|
23629 | } else {
|
23630 | _get$1 = function _get(target, property, receiver) {
|
23631 | var base = _superPropBase$1(target, property);
|
23632 |
|
23633 | if (!base) return;
|
23634 | var desc = Object.getOwnPropertyDescriptor(base, property);
|
23635 |
|
23636 | if (desc.get) {
|
23637 | return desc.get.call(receiver);
|
23638 | }
|
23639 |
|
23640 | return desc.value;
|
23641 | };
|
23642 | }
|
23643 |
|
23644 | return _get$1(target, property, receiver || target);
|
23645 | }
|
23646 |
|
23647 | function _superPropBase$1(object, property) {
|
23648 | while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
23649 | object = _getPrototypeOf$o(object);
|
23650 | if (object === null) break;
|
23651 | }
|
23652 |
|
23653 | return object;
|
23654 | }
|
23655 |
|
23656 | function _getPrototypeOf$o(o) {
|
23657 | _getPrototypeOf$o = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
23658 | return o.__proto__ || Object.getPrototypeOf(o);
|
23659 | };
|
23660 | return _getPrototypeOf$o(o);
|
23661 | }
|
23662 |
|
23663 | function _inherits$o(subClass, superClass) {
|
23664 | if (typeof superClass !== "function" && superClass !== null) {
|
23665 | throw new TypeError("Super expression must either be null or a function");
|
23666 | }
|
23667 |
|
23668 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
23669 | constructor: {
|
23670 | value: subClass,
|
23671 | writable: true,
|
23672 | configurable: true
|
23673 | }
|
23674 | });
|
23675 | if (superClass) _setPrototypeOf$o(subClass, superClass);
|
23676 | }
|
23677 |
|
23678 | function _setPrototypeOf$o(o, p) {
|
23679 | _setPrototypeOf$o = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
23680 | o.__proto__ = p;
|
23681 | return o;
|
23682 | };
|
23683 |
|
23684 | return _setPrototypeOf$o(o, p);
|
23685 | }
|
23686 |
|
23687 | var Viewer$3 =
|
23688 |
|
23689 | function (_BaseViewer) {
|
23690 | _inherits$o(Viewer, _BaseViewer);
|
23691 |
|
23692 | function Viewer() {
|
23693 | var _this;
|
23694 |
|
23695 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
23696 |
|
23697 | _classCallCheck$O(this, Viewer);
|
23698 |
|
23699 | var container = Viewer._createContainer();
|
23700 |
|
23701 | _this = _possibleConstructorReturn$o(this, _getPrototypeOf$o(Viewer).call(this, assign(options, {
|
23702 | renderer: {
|
23703 | container: container
|
23704 | }
|
23705 | })));
|
23706 | _this._container = container;
|
23707 | return _this;
|
23708 | }
|
23709 |
|
23710 | _createClass$F(Viewer, [{
|
23711 | key: "open",
|
23712 | value: function open(decision, done) {
|
23713 | var err;
|
23714 |
|
23715 |
|
23716 | try {
|
23717 | if (this._decision) {
|
23718 |
|
23719 | this.clear();
|
23720 |
|
23721 | this.get('eventBus').fire('renderer.unmount');
|
23722 | }
|
23723 |
|
23724 |
|
23725 | this._decision = decision;
|
23726 |
|
23727 | this.get('eventBus').fire('import', decision);
|
23728 | this.get('eventBus').fire('renderer.mount');
|
23729 | } catch (e) {
|
23730 | err = e;
|
23731 | }
|
23732 |
|
23733 |
|
23734 | return done(err);
|
23735 | }
|
23736 | |
23737 |
|
23738 |
|
23739 |
|
23740 |
|
23741 |
|
23742 |
|
23743 |
|
23744 | }, {
|
23745 | key: "_init",
|
23746 | value: function _init(options) {
|
23747 | var modules = options.modules,
|
23748 | additionalModules = options.additionalModules,
|
23749 | config = _objectWithoutProperties$6(options, ["modules", "additionalModules"]);
|
23750 |
|
23751 | var baseModules = modules || this.getModules();
|
23752 | var extraModules = additionalModules || [];
|
23753 | var staticModules = [{
|
23754 | viewer: ['value', this]
|
23755 | }];
|
23756 | var allModules = [].concat(_toConsumableArray$8(baseModules), _toConsumableArray$8(extraModules), staticModules);
|
23757 | return {
|
23758 | modules: allModules,
|
23759 | config: config
|
23760 | };
|
23761 | }
|
23762 | |
23763 |
|
23764 |
|
23765 |
|
23766 |
|
23767 |
|
23768 |
|
23769 |
|
23770 |
|
23771 |
|
23772 |
|
23773 | }, {
|
23774 | key: "on",
|
23775 | value: function on(event, priority, callback, target) {
|
23776 | return this.get('eventBus').on(event, priority, callback, target);
|
23777 | }
|
23778 | |
23779 |
|
23780 |
|
23781 |
|
23782 |
|
23783 |
|
23784 |
|
23785 | }, {
|
23786 | key: "off",
|
23787 | value: function off(event, callback) {
|
23788 | this.get('eventBus').off(event, callback);
|
23789 | }
|
23790 | |
23791 |
|
23792 |
|
23793 |
|
23794 |
|
23795 |
|
23796 |
|
23797 |
|
23798 |
|
23799 | }, {
|
23800 | key: "_emit",
|
23801 | value: function _emit(type, event) {
|
23802 | return this.get('eventBus').fire(type, event);
|
23803 | }
|
23804 | |
23805 |
|
23806 |
|
23807 |
|
23808 |
|
23809 |
|
23810 | }, {
|
23811 | key: "getDecision",
|
23812 | value: function getDecision() {
|
23813 | return this._decision;
|
23814 | }
|
23815 | |
23816 |
|
23817 |
|
23818 |
|
23819 |
|
23820 |
|
23821 | }, {
|
23822 | key: "attachTo",
|
23823 | value: function attachTo(parentNode) {
|
23824 | if (!parentNode) {
|
23825 | throw new Error('parentNode required');
|
23826 | }
|
23827 |
|
23828 |
|
23829 |
|
23830 | this.detach();
|
23831 | parentNode.appendChild(this._container);
|
23832 |
|
23833 | this._emit('attach', {});
|
23834 | }
|
23835 | |
23836 |
|
23837 |
|
23838 |
|
23839 | }, {
|
23840 | key: "detach",
|
23841 | value: function detach() {
|
23842 | var container = this._container,
|
23843 | parentNode = container.parentNode;
|
23844 |
|
23845 | if (!parentNode) {
|
23846 | return;
|
23847 | }
|
23848 |
|
23849 | this._emit('detach', {});
|
23850 |
|
23851 | remove(container);
|
23852 | }
|
23853 | }, {
|
23854 | key: "destroy",
|
23855 | value: function destroy() {
|
23856 | _get$1(_getPrototypeOf$o(Viewer.prototype), "destroy", this).call(this);
|
23857 |
|
23858 | this.detach();
|
23859 | }
|
23860 | }, {
|
23861 | key: "getModules",
|
23862 | value: function getModules() {
|
23863 | return Viewer._getModules();
|
23864 | }
|
23865 | }], [{
|
23866 | key: "_getModules",
|
23867 | value: function _getModules() {
|
23868 | return [CoreModule$2, DecisionPropertiesModule, LiteralExpressionPropertiesModule, PoweredByModule$1, TextareaModule, ViewDrdModule];
|
23869 | }
|
23870 | }, {
|
23871 | key: "_createContainer",
|
23872 | value: function _createContainer() {
|
23873 | return domify('<div class="dmn-literal-expression-container"></div>');
|
23874 | }
|
23875 | }]);
|
23876 |
|
23877 | return Viewer;
|
23878 | }(Viewer$2);
|
23879 |
|
23880 | |
23881 |
|
23882 |
|
23883 |
|
23884 |
|
23885 |
|
23886 |
|
23887 | function containsDi(definitions) {
|
23888 | return definitions.dmnDI && definitions.dmnDI.diagrams && definitions.dmnDI.diagrams[0];
|
23889 | }
|
23890 |
|
23891 | |
23892 |
|
23893 |
|
23894 |
|
23895 | var Viewer$4 =
|
23896 |
|
23897 | function (_Manager) {
|
23898 | _inherits(Viewer$2, _Manager);
|
23899 |
|
23900 | function Viewer$2() {
|
23901 | _classCallCheck(this, Viewer$2);
|
23902 |
|
23903 | return _possibleConstructorReturn(this, _getPrototypeOf(Viewer$2).apply(this, arguments));
|
23904 | }
|
23905 |
|
23906 | _createClass(Viewer$2, [{
|
23907 | key: "_getViewProviders",
|
23908 | value: function _getViewProviders() {
|
23909 | return [{
|
23910 | id: 'drd',
|
23911 | constructor: Viewer,
|
23912 | opens: function opens(element) {
|
23913 | return is(element, 'dmn:Definitions') && containsDi(element);
|
23914 | }
|
23915 | }, {
|
23916 | id: 'decisionTable',
|
23917 | constructor: Viewer$1,
|
23918 | opens: function opens(element) {
|
23919 | return is(element, 'dmn:Decision') && is(element.decisionLogic, 'dmn:DecisionTable');
|
23920 | }
|
23921 | }, {
|
23922 | id: 'literalExpression',
|
23923 | constructor: Viewer$3,
|
23924 | opens: function opens(element) {
|
23925 | return is(element, 'dmn:Decision') && is(element.decisionLogic, 'dmn:LiteralExpression');
|
23926 | }
|
23927 | }];
|
23928 | }
|
23929 | }]);
|
23930 |
|
23931 | return Viewer$2;
|
23932 | }(Manager);
|
23933 |
|
23934 | return Viewer$4;
|
23935 |
|
23936 | })));
|