@formio/js 5.0.0-rc.65 → 5.0.0-rc.66
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +100 -4
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +4 -4
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Webform.js +2 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.js +44 -0
- package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
- package/lib/mjs/Webform.js +2 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.js +42 -0
- package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
- package/package.json +1 -1
package/dist/formio.form.js
CHANGED
@@ -2587,6 +2587,16 @@ eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;(functio
|
|
2587
2587
|
|
2588
2588
|
/***/ }),
|
2589
2589
|
|
2590
|
+
/***/ "./node_modules/atoa/atoa.js":
|
2591
|
+
/*!***********************************!*\
|
2592
|
+
!*** ./node_modules/atoa/atoa.js ***!
|
2593
|
+
\***********************************/
|
2594
|
+
/***/ (function(module) {
|
2595
|
+
|
2596
|
+
eval("module.exports = function atoa (a, n) { return Array.prototype.slice.call(a, n); }\n\n\n//# sourceURL=webpack://Formio/./node_modules/atoa/atoa.js?");
|
2597
|
+
|
2598
|
+
/***/ }),
|
2599
|
+
|
2590
2600
|
/***/ "./node_modules/autocompleter/autocomplete.js":
|
2591
2601
|
/*!****************************************************!*\
|
2592
2602
|
!*** ./node_modules/autocompleter/autocomplete.js ***!
|
@@ -2683,6 +2693,60 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
2683
2693
|
|
2684
2694
|
/***/ }),
|
2685
2695
|
|
2696
|
+
/***/ "./node_modules/contra/debounce.js":
|
2697
|
+
/*!*****************************************!*\
|
2698
|
+
!*** ./node_modules/contra/debounce.js ***!
|
2699
|
+
\*****************************************/
|
2700
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
2701
|
+
|
2702
|
+
"use strict";
|
2703
|
+
eval("\n\nvar ticky = __webpack_require__(/*! ticky */ \"./node_modules/ticky/ticky-browser.js\");\n\nmodule.exports = function debounce (fn, args, ctx) {\n if (!fn) { return; }\n ticky(function run () {\n fn.apply(ctx || null, args || []);\n });\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/contra/debounce.js?");
|
2704
|
+
|
2705
|
+
/***/ }),
|
2706
|
+
|
2707
|
+
/***/ "./node_modules/contra/emitter.js":
|
2708
|
+
/*!****************************************!*\
|
2709
|
+
!*** ./node_modules/contra/emitter.js ***!
|
2710
|
+
\****************************************/
|
2711
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
2712
|
+
|
2713
|
+
"use strict";
|
2714
|
+
eval("\n\nvar atoa = __webpack_require__(/*! atoa */ \"./node_modules/atoa/atoa.js\");\nvar debounce = __webpack_require__(/*! ./debounce */ \"./node_modules/contra/debounce.js\");\n\nmodule.exports = function emitter (thing, options) {\n var opts = options || {};\n var evt = {};\n if (thing === undefined) { thing = {}; }\n thing.on = function (type, fn) {\n if (!evt[type]) {\n evt[type] = [fn];\n } else {\n evt[type].push(fn);\n }\n return thing;\n };\n thing.once = function (type, fn) {\n fn._once = true; // thing.off(fn) still works!\n thing.on(type, fn);\n return thing;\n };\n thing.off = function (type, fn) {\n var c = arguments.length;\n if (c === 1) {\n delete evt[type];\n } else if (c === 0) {\n evt = {};\n } else {\n var et = evt[type];\n if (!et) { return thing; }\n et.splice(et.indexOf(fn), 1);\n }\n return thing;\n };\n thing.emit = function () {\n var args = atoa(arguments);\n return thing.emitterSnapshot(args.shift()).apply(this, args);\n };\n thing.emitterSnapshot = function (type) {\n var et = (evt[type] || []).slice(0);\n return function () {\n var args = atoa(arguments);\n var ctx = this || thing;\n if (type === 'error' && opts.throws !== false && !et.length) { throw args.length === 1 ? args[0] : args; }\n et.forEach(function emitter (listen) {\n if (opts.async) { debounce(listen, args, ctx); } else { listen.apply(ctx, args); }\n if (listen._once) { thing.off(type, listen); }\n });\n return thing;\n };\n };\n return thing;\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/contra/emitter.js?");
|
2715
|
+
|
2716
|
+
/***/ }),
|
2717
|
+
|
2718
|
+
/***/ "./node_modules/crossvent/src/crossvent.js":
|
2719
|
+
/*!*************************************************!*\
|
2720
|
+
!*** ./node_modules/crossvent/src/crossvent.js ***!
|
2721
|
+
\*************************************************/
|
2722
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
2723
|
+
|
2724
|
+
"use strict";
|
2725
|
+
eval("\n\nvar customEvent = __webpack_require__(/*! custom-event */ \"./node_modules/custom-event/index.js\");\nvar eventmap = __webpack_require__(/*! ./eventmap */ \"./node_modules/crossvent/src/eventmap.js\");\nvar doc = __webpack_require__.g.document;\nvar addEvent = addEventEasy;\nvar removeEvent = removeEventEasy;\nvar hardCache = [];\n\nif (!__webpack_require__.g.addEventListener) {\n addEvent = addEventHard;\n removeEvent = removeEventHard;\n}\n\nmodule.exports = {\n add: addEvent,\n remove: removeEvent,\n fabricate: fabricateEvent\n};\n\nfunction addEventEasy (el, type, fn, capturing) {\n return el.addEventListener(type, fn, capturing);\n}\n\nfunction addEventHard (el, type, fn) {\n return el.attachEvent('on' + type, wrap(el, type, fn));\n}\n\nfunction removeEventEasy (el, type, fn, capturing) {\n return el.removeEventListener(type, fn, capturing);\n}\n\nfunction removeEventHard (el, type, fn) {\n var listener = unwrap(el, type, fn);\n if (listener) {\n return el.detachEvent('on' + type, listener);\n }\n}\n\nfunction fabricateEvent (el, type, model) {\n var e = eventmap.indexOf(type) === -1 ? makeCustomEvent() : makeClassicEvent();\n if (el.dispatchEvent) {\n el.dispatchEvent(e);\n } else {\n el.fireEvent('on' + type, e);\n }\n function makeClassicEvent () {\n var e;\n if (doc.createEvent) {\n e = doc.createEvent('Event');\n e.initEvent(type, true, true);\n } else if (doc.createEventObject) {\n e = doc.createEventObject();\n }\n return e;\n }\n function makeCustomEvent () {\n return new customEvent(type, { detail: model });\n }\n}\n\nfunction wrapperFactory (el, type, fn) {\n return function wrapper (originalEvent) {\n var e = originalEvent || __webpack_require__.g.event;\n e.target = e.target || e.srcElement;\n e.preventDefault = e.preventDefault || function preventDefault () { e.returnValue = false; };\n e.stopPropagation = e.stopPropagation || function stopPropagation () { e.cancelBubble = true; };\n e.which = e.which || e.keyCode;\n fn.call(el, e);\n };\n}\n\nfunction wrap (el, type, fn) {\n var wrapper = unwrap(el, type, fn) || wrapperFactory(el, type, fn);\n hardCache.push({\n wrapper: wrapper,\n element: el,\n type: type,\n fn: fn\n });\n return wrapper;\n}\n\nfunction unwrap (el, type, fn) {\n var i = find(el, type, fn);\n if (i) {\n var wrapper = hardCache[i].wrapper;\n hardCache.splice(i, 1); // free up a tad of memory\n return wrapper;\n }\n}\n\nfunction find (el, type, fn) {\n var i, item;\n for (i = 0; i < hardCache.length; i++) {\n item = hardCache[i];\n if (item.element === el && item.type === type && item.fn === fn) {\n return i;\n }\n }\n}\n\n\n//# sourceURL=webpack://Formio/./node_modules/crossvent/src/crossvent.js?");
|
2726
|
+
|
2727
|
+
/***/ }),
|
2728
|
+
|
2729
|
+
/***/ "./node_modules/crossvent/src/eventmap.js":
|
2730
|
+
/*!************************************************!*\
|
2731
|
+
!*** ./node_modules/crossvent/src/eventmap.js ***!
|
2732
|
+
\************************************************/
|
2733
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
2734
|
+
|
2735
|
+
"use strict";
|
2736
|
+
eval("\n\nvar eventmap = [];\nvar eventname = '';\nvar ron = /^on/;\n\nfor (eventname in __webpack_require__.g) {\n if (ron.test(eventname)) {\n eventmap.push(eventname.slice(2));\n }\n}\n\nmodule.exports = eventmap;\n\n\n//# sourceURL=webpack://Formio/./node_modules/crossvent/src/eventmap.js?");
|
2737
|
+
|
2738
|
+
/***/ }),
|
2739
|
+
|
2740
|
+
/***/ "./node_modules/custom-event/index.js":
|
2741
|
+
/*!********************************************!*\
|
2742
|
+
!*** ./node_modules/custom-event/index.js ***!
|
2743
|
+
\********************************************/
|
2744
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
2745
|
+
|
2746
|
+
eval("\nvar NativeCustomEvent = __webpack_require__.g.CustomEvent;\n\nfunction useNative () {\n try {\n var p = new NativeCustomEvent('cat', { detail: { foo: 'bar' } });\n return 'cat' === p.type && 'bar' === p.detail.foo;\n } catch (e) {\n }\n return false;\n}\n\n/**\n * Cross-browser `CustomEvent` constructor.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent\n *\n * @public\n */\n\nmodule.exports = useNative() ? NativeCustomEvent :\n\n// IE >= 9\n'undefined' !== typeof document && 'function' === typeof document.createEvent ? function CustomEvent (type, params) {\n var e = document.createEvent('CustomEvent');\n if (params) {\n e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail);\n } else {\n e.initCustomEvent(type, false, false, void 0);\n }\n return e;\n} :\n\n// IE <= 8\nfunction CustomEvent (type, params) {\n var e = document.createEventObject();\n e.type = type;\n if (params) {\n e.bubbles = Boolean(params.bubbles);\n e.cancelable = Boolean(params.cancelable);\n e.detail = params.detail;\n } else {\n e.bubbles = false;\n e.cancelable = false;\n e.detail = void 0;\n }\n return e;\n}\n\n\n//# sourceURL=webpack://Formio/./node_modules/custom-event/index.js?");
|
2747
|
+
|
2748
|
+
/***/ }),
|
2749
|
+
|
2686
2750
|
/***/ "./node_modules/dayjs/dayjs.min.js":
|
2687
2751
|
/*!*****************************************!*\
|
2688
2752
|
!*** ./node_modules/dayjs/dayjs.min.js ***!
|
@@ -2743,6 +2807,28 @@ eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPAC
|
|
2743
2807
|
|
2744
2808
|
/***/ }),
|
2745
2809
|
|
2810
|
+
/***/ "./node_modules/dragula/classes.js":
|
2811
|
+
/*!*****************************************!*\
|
2812
|
+
!*** ./node_modules/dragula/classes.js ***!
|
2813
|
+
\*****************************************/
|
2814
|
+
/***/ (function(module) {
|
2815
|
+
|
2816
|
+
"use strict";
|
2817
|
+
eval("\n\nvar cache = {};\nvar start = '(?:^|\\\\s)';\nvar end = '(?:\\\\s|$)';\n\nfunction lookupClass (className) {\n var cached = cache[className];\n if (cached) {\n cached.lastIndex = 0;\n } else {\n cache[className] = cached = new RegExp(start + className + end, 'g');\n }\n return cached;\n}\n\nfunction addClass (el, className) {\n var current = el.className;\n if (!current.length) {\n el.className = className;\n } else if (!lookupClass(className).test(current)) {\n el.className += ' ' + className;\n }\n}\n\nfunction rmClass (el, className) {\n el.className = el.className.replace(lookupClass(className), ' ').trim();\n}\n\nmodule.exports = {\n add: addClass,\n rm: rmClass\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/dragula/classes.js?");
|
2818
|
+
|
2819
|
+
/***/ }),
|
2820
|
+
|
2821
|
+
/***/ "./node_modules/dragula/dragula.js":
|
2822
|
+
/*!*****************************************!*\
|
2823
|
+
!*** ./node_modules/dragula/dragula.js ***!
|
2824
|
+
\*****************************************/
|
2825
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
2826
|
+
|
2827
|
+
"use strict";
|
2828
|
+
eval("\n\nvar emitter = __webpack_require__(/*! contra/emitter */ \"./node_modules/contra/emitter.js\");\nvar crossvent = __webpack_require__(/*! crossvent */ \"./node_modules/crossvent/src/crossvent.js\");\nvar classes = __webpack_require__(/*! ./classes */ \"./node_modules/dragula/classes.js\");\nvar doc = document;\nvar documentElement = doc.documentElement;\n\nfunction dragula (initialContainers, options) {\n var len = arguments.length;\n if (len === 1 && Array.isArray(initialContainers) === false) {\n options = initialContainers;\n initialContainers = [];\n }\n var _mirror; // mirror image\n var _source; // source container\n var _item; // item being dragged\n var _offsetX; // reference x\n var _offsetY; // reference y\n var _moveX; // reference move x\n var _moveY; // reference move y\n var _initialSibling; // reference sibling when grabbed\n var _currentSibling; // reference sibling now\n var _copy; // item used for copying\n var _renderTimer; // timer for setTimeout renderMirrorImage\n var _lastDropTarget = null; // last container item was over\n var _grabbed; // holds mousedown context until first mousemove\n\n var o = options || {};\n if (o.moves === void 0) { o.moves = always; }\n if (o.accepts === void 0) { o.accepts = always; }\n if (o.invalid === void 0) { o.invalid = invalidTarget; }\n if (o.containers === void 0) { o.containers = initialContainers || []; }\n if (o.isContainer === void 0) { o.isContainer = never; }\n if (o.copy === void 0) { o.copy = false; }\n if (o.copySortSource === void 0) { o.copySortSource = false; }\n if (o.revertOnSpill === void 0) { o.revertOnSpill = false; }\n if (o.removeOnSpill === void 0) { o.removeOnSpill = false; }\n if (o.direction === void 0) { o.direction = 'vertical'; }\n if (o.ignoreInputTextSelection === void 0) { o.ignoreInputTextSelection = true; }\n if (o.mirrorContainer === void 0) { o.mirrorContainer = doc.body; }\n\n var drake = emitter({\n containers: o.containers,\n start: manualStart,\n end: end,\n cancel: cancel,\n remove: remove,\n destroy: destroy,\n canMove: canMove,\n dragging: false\n });\n\n if (o.removeOnSpill === true) {\n drake.on('over', spillOver).on('out', spillOut);\n }\n\n events();\n\n return drake;\n\n function isContainer (el) {\n return drake.containers.indexOf(el) !== -1 || o.isContainer(el);\n }\n\n function events (remove) {\n var op = remove ? 'remove' : 'add';\n touchy(documentElement, op, 'mousedown', grab);\n touchy(documentElement, op, 'mouseup', release);\n }\n\n function eventualMovements (remove) {\n var op = remove ? 'remove' : 'add';\n touchy(documentElement, op, 'mousemove', startBecauseMouseMoved);\n }\n\n function movements (remove) {\n var op = remove ? 'remove' : 'add';\n crossvent[op](documentElement, 'selectstart', preventGrabbed); // IE8\n crossvent[op](documentElement, 'click', preventGrabbed);\n }\n\n function destroy () {\n events(true);\n release({});\n }\n\n function preventGrabbed (e) {\n if (_grabbed) {\n e.preventDefault();\n }\n }\n\n function grab (e) {\n _moveX = e.clientX;\n _moveY = e.clientY;\n\n var ignore = whichMouseButton(e) !== 1 || e.metaKey || e.ctrlKey;\n if (ignore) {\n return; // we only care about honest-to-god left clicks and touch events\n }\n var item = e.target;\n var context = canStart(item);\n if (!context) {\n return;\n }\n _grabbed = context;\n eventualMovements();\n if (e.type === 'mousedown') {\n if (isInput(item)) { // see also: https://github.com/bevacqua/dragula/issues/208\n item.focus(); // fixes https://github.com/bevacqua/dragula/issues/176\n } else {\n e.preventDefault(); // fixes https://github.com/bevacqua/dragula/issues/155\n }\n }\n }\n\n function startBecauseMouseMoved (e) {\n if (!_grabbed) {\n return;\n }\n if (whichMouseButton(e) === 0) {\n release({});\n return; // when text is selected on an input and then dragged, mouseup doesn't fire. this is our only hope\n }\n\n // truthy check fixes #239, equality fixes #207, fixes #501\n if ((e.clientX !== void 0 && Math.abs(e.clientX - _moveX) <= (o.slideFactorX || 0)) &&\n (e.clientY !== void 0 && Math.abs(e.clientY - _moveY) <= (o.slideFactorY || 0))) {\n return;\n }\n\n if (o.ignoreInputTextSelection) {\n var clientX = getCoord('clientX', e) || 0;\n var clientY = getCoord('clientY', e) || 0;\n var elementBehindCursor = doc.elementFromPoint(clientX, clientY);\n if (isInput(elementBehindCursor)) {\n return;\n }\n }\n\n var grabbed = _grabbed; // call to end() unsets _grabbed\n eventualMovements(true);\n movements();\n end();\n start(grabbed);\n\n var offset = getOffset(_item);\n _offsetX = getCoord('pageX', e) - offset.left;\n _offsetY = getCoord('pageY', e) - offset.top;\n\n classes.add(_copy || _item, 'gu-transit');\n renderMirrorImage();\n drag(e);\n }\n\n function canStart (item) {\n if (drake.dragging && _mirror) {\n return;\n }\n if (isContainer(item)) {\n return; // don't drag container itself\n }\n var handle = item;\n while (getParent(item) && isContainer(getParent(item)) === false) {\n if (o.invalid(item, handle)) {\n return;\n }\n item = getParent(item); // drag target should be a top element\n if (!item) {\n return;\n }\n }\n var source = getParent(item);\n if (!source) {\n return;\n }\n if (o.invalid(item, handle)) {\n return;\n }\n\n var movable = o.moves(item, source, handle, nextEl(item));\n if (!movable) {\n return;\n }\n\n return {\n item: item,\n source: source\n };\n }\n\n function canMove (item) {\n return !!canStart(item);\n }\n\n function manualStart (item) {\n var context = canStart(item);\n if (context) {\n start(context);\n }\n }\n\n function start (context) {\n if (isCopy(context.item, context.source)) {\n _copy = context.item.cloneNode(true);\n drake.emit('cloned', _copy, context.item, 'copy');\n }\n\n _source = context.source;\n _item = context.item;\n _initialSibling = _currentSibling = nextEl(context.item);\n\n drake.dragging = true;\n drake.emit('drag', _item, _source);\n }\n\n function invalidTarget () {\n return false;\n }\n\n function end () {\n if (!drake.dragging) {\n return;\n }\n var item = _copy || _item;\n drop(item, getParent(item));\n }\n\n function ungrab () {\n _grabbed = false;\n eventualMovements(true);\n movements(true);\n }\n\n function release (e) {\n ungrab();\n\n if (!drake.dragging) {\n return;\n }\n var item = _copy || _item;\n var clientX = getCoord('clientX', e) || 0;\n var clientY = getCoord('clientY', e) || 0;\n var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY);\n var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY);\n if (dropTarget && ((_copy && o.copySortSource) || (!_copy || dropTarget !== _source))) {\n drop(item, dropTarget);\n } else if (o.removeOnSpill) {\n remove();\n } else {\n cancel();\n }\n }\n\n function drop (item, target) {\n var parent = getParent(item);\n if (_copy && o.copySortSource && target === _source) {\n parent.removeChild(_item);\n }\n if (isInitialPlacement(target)) {\n drake.emit('cancel', item, _source, _source);\n } else {\n drake.emit('drop', item, target, _source, _currentSibling);\n }\n cleanup();\n }\n\n function remove () {\n if (!drake.dragging) {\n return;\n }\n var item = _copy || _item;\n var parent = getParent(item);\n if (parent) {\n parent.removeChild(item);\n }\n drake.emit(_copy ? 'cancel' : 'remove', item, parent, _source);\n cleanup();\n }\n\n function cancel (revert) {\n if (!drake.dragging) {\n return;\n }\n var reverts = arguments.length > 0 ? revert : o.revertOnSpill;\n var item = _copy || _item;\n var parent = getParent(item);\n var initial = isInitialPlacement(parent);\n if (initial === false && reverts) {\n if (_copy) {\n if (parent) {\n parent.removeChild(_copy);\n }\n } else {\n _source.insertBefore(item, _initialSibling);\n }\n }\n if (initial || reverts) {\n drake.emit('cancel', item, _source, _source);\n } else {\n drake.emit('drop', item, parent, _source, _currentSibling);\n }\n cleanup();\n }\n\n function cleanup () {\n var item = _copy || _item;\n ungrab();\n removeMirrorImage();\n if (item) {\n classes.rm(item, 'gu-transit');\n }\n if (_renderTimer) {\n clearTimeout(_renderTimer);\n }\n drake.dragging = false;\n if (_lastDropTarget) {\n drake.emit('out', item, _lastDropTarget, _source);\n }\n drake.emit('dragend', item);\n _source = _item = _copy = _initialSibling = _currentSibling = _renderTimer = _lastDropTarget = null;\n }\n\n function isInitialPlacement (target, s) {\n var sibling;\n if (s !== void 0) {\n sibling = s;\n } else if (_mirror) {\n sibling = _currentSibling;\n } else {\n sibling = nextEl(_copy || _item);\n }\n return target === _source && sibling === _initialSibling;\n }\n\n function findDropTarget (elementBehindCursor, clientX, clientY) {\n var target = elementBehindCursor;\n while (target && !accepted()) {\n target = getParent(target);\n }\n return target;\n\n function accepted () {\n var droppable = isContainer(target);\n if (droppable === false) {\n return false;\n }\n\n var immediate = getImmediateChild(target, elementBehindCursor);\n var reference = getReference(target, immediate, clientX, clientY);\n var initial = isInitialPlacement(target, reference);\n if (initial) {\n return true; // should always be able to drop it right back where it was\n }\n return o.accepts(_item, target, _source, reference);\n }\n }\n\n function drag (e) {\n if (!_mirror) {\n return;\n }\n e.preventDefault();\n\n var clientX = getCoord('clientX', e) || 0;\n var clientY = getCoord('clientY', e) || 0;\n var x = clientX - _offsetX;\n var y = clientY - _offsetY;\n\n _mirror.style.left = x + 'px';\n _mirror.style.top = y + 'px';\n\n var item = _copy || _item;\n var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY);\n var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY);\n var changed = dropTarget !== null && dropTarget !== _lastDropTarget;\n if (changed || dropTarget === null) {\n out();\n _lastDropTarget = dropTarget;\n over();\n }\n var parent = getParent(item);\n if (dropTarget === _source && _copy && !o.copySortSource) {\n if (parent) {\n parent.removeChild(item);\n }\n return;\n }\n var reference;\n var immediate = getImmediateChild(dropTarget, elementBehindCursor);\n if (immediate !== null) {\n reference = getReference(dropTarget, immediate, clientX, clientY);\n } else if (o.revertOnSpill === true && !_copy) {\n reference = _initialSibling;\n dropTarget = _source;\n } else {\n if (_copy && parent) {\n parent.removeChild(item);\n }\n return;\n }\n if (\n (reference === null && changed) ||\n reference !== item &&\n reference !== nextEl(item)\n ) {\n _currentSibling = reference;\n dropTarget.insertBefore(item, reference);\n drake.emit('shadow', item, dropTarget, _source);\n }\n function moved (type) { drake.emit(type, item, _lastDropTarget, _source); }\n function over () { if (changed) { moved('over'); } }\n function out () { if (_lastDropTarget) { moved('out'); } }\n }\n\n function spillOver (el) {\n classes.rm(el, 'gu-hide');\n }\n\n function spillOut (el) {\n if (drake.dragging) { classes.add(el, 'gu-hide'); }\n }\n\n function renderMirrorImage () {\n if (_mirror) {\n return;\n }\n var rect = _item.getBoundingClientRect();\n _mirror = _item.cloneNode(true);\n _mirror.style.width = getRectWidth(rect) + 'px';\n _mirror.style.height = getRectHeight(rect) + 'px';\n classes.rm(_mirror, 'gu-transit');\n classes.add(_mirror, 'gu-mirror');\n o.mirrorContainer.appendChild(_mirror);\n touchy(documentElement, 'add', 'mousemove', drag);\n classes.add(o.mirrorContainer, 'gu-unselectable');\n drake.emit('cloned', _mirror, _item, 'mirror');\n }\n\n function removeMirrorImage () {\n if (_mirror) {\n classes.rm(o.mirrorContainer, 'gu-unselectable');\n touchy(documentElement, 'remove', 'mousemove', drag);\n getParent(_mirror).removeChild(_mirror);\n _mirror = null;\n }\n }\n\n function getImmediateChild (dropTarget, target) {\n var immediate = target;\n while (immediate !== dropTarget && getParent(immediate) !== dropTarget) {\n immediate = getParent(immediate);\n }\n if (immediate === documentElement) {\n return null;\n }\n return immediate;\n }\n\n function getReference (dropTarget, target, x, y) {\n var horizontal = o.direction === 'horizontal';\n var reference = target !== dropTarget ? inside() : outside();\n return reference;\n\n function outside () { // slower, but able to figure out any position\n var len = dropTarget.children.length;\n var i;\n var el;\n var rect;\n for (i = 0; i < len; i++) {\n el = dropTarget.children[i];\n rect = el.getBoundingClientRect();\n if (horizontal && (rect.left + rect.width / 2) > x) { return el; }\n if (!horizontal && (rect.top + rect.height / 2) > y) { return el; }\n }\n return null;\n }\n\n function inside () { // faster, but only available if dropped inside a child element\n var rect = target.getBoundingClientRect();\n if (horizontal) {\n return resolve(x > rect.left + getRectWidth(rect) / 2);\n }\n return resolve(y > rect.top + getRectHeight(rect) / 2);\n }\n\n function resolve (after) {\n return after ? nextEl(target) : target;\n }\n }\n\n function isCopy (item, container) {\n return typeof o.copy === 'boolean' ? o.copy : o.copy(item, container);\n }\n}\n\nfunction touchy (el, op, type, fn) {\n var touch = {\n mouseup: 'touchend',\n mousedown: 'touchstart',\n mousemove: 'touchmove'\n };\n var pointers = {\n mouseup: 'pointerup',\n mousedown: 'pointerdown',\n mousemove: 'pointermove'\n };\n var microsoft = {\n mouseup: 'MSPointerUp',\n mousedown: 'MSPointerDown',\n mousemove: 'MSPointerMove'\n };\n if (__webpack_require__.g.navigator.pointerEnabled) {\n crossvent[op](el, pointers[type], fn);\n } else if (__webpack_require__.g.navigator.msPointerEnabled) {\n crossvent[op](el, microsoft[type], fn);\n } else {\n crossvent[op](el, touch[type], fn);\n crossvent[op](el, type, fn);\n }\n}\n\nfunction whichMouseButton (e) {\n if (e.touches !== void 0) { return e.touches.length; }\n if (e.which !== void 0 && e.which !== 0) { return e.which; } // see https://github.com/bevacqua/dragula/issues/261\n if (e.buttons !== void 0) { return e.buttons; }\n var button = e.button;\n if (button !== void 0) { // see https://github.com/jquery/jquery/blob/99e8ff1baa7ae341e94bb89c3e84570c7c3ad9ea/src/event.js#L573-L575\n return button & 1 ? 1 : button & 2 ? 3 : (button & 4 ? 2 : 0);\n }\n}\n\nfunction getOffset (el) {\n var rect = el.getBoundingClientRect();\n return {\n left: rect.left + getScroll('scrollLeft', 'pageXOffset'),\n top: rect.top + getScroll('scrollTop', 'pageYOffset')\n };\n}\n\nfunction getScroll (scrollProp, offsetProp) {\n if (typeof __webpack_require__.g[offsetProp] !== 'undefined') {\n return __webpack_require__.g[offsetProp];\n }\n if (documentElement.clientHeight) {\n return documentElement[scrollProp];\n }\n return doc.body[scrollProp];\n}\n\nfunction getElementBehindPoint (point, x, y) {\n point = point || {};\n var state = point.className || '';\n var el;\n point.className += ' gu-hide';\n el = doc.elementFromPoint(x, y);\n point.className = state;\n return el;\n}\n\nfunction never () { return false; }\nfunction always () { return true; }\nfunction getRectWidth (rect) { return rect.width || (rect.right - rect.left); }\nfunction getRectHeight (rect) { return rect.height || (rect.bottom - rect.top); }\nfunction getParent (el) { return el.parentNode === doc ? null : el.parentNode; }\nfunction isInput (el) { return el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT' || isEditable(el); }\nfunction isEditable (el) {\n if (!el) { return false; } // no parents were editable\n if (el.contentEditable === 'false') { return false; } // stop the lookup\n if (el.contentEditable === 'true') { return true; } // found a contentEditable element in the chain\n return isEditable(getParent(el)); // contentEditable is set to 'inherit'\n}\n\nfunction nextEl (el) {\n return el.nextElementSibling || manually();\n function manually () {\n var sibling = el;\n do {\n sibling = sibling.nextSibling;\n } while (sibling && sibling.nodeType !== 1);\n return sibling;\n }\n}\n\nfunction getEventHost (e) {\n // on touchend event, we have to use `e.changedTouches`\n // see http://stackoverflow.com/questions/7192563/touchend-event-properties\n // see https://github.com/bevacqua/dragula/issues/34\n if (e.targetTouches && e.targetTouches.length) {\n return e.targetTouches[0];\n }\n if (e.changedTouches && e.changedTouches.length) {\n return e.changedTouches[0];\n }\n return e;\n}\n\nfunction getCoord (coord, e) {\n var host = getEventHost(e);\n var missMap = {\n pageX: 'clientX', // IE8\n pageY: 'clientY' // IE8\n };\n if (coord in missMap && !(coord in host) && missMap[coord] in host) {\n coord = missMap[coord];\n }\n return host[coord];\n}\n\nmodule.exports = dragula;\n\n\n//# sourceURL=webpack://Formio/./node_modules/dragula/dragula.js?");
|
2829
|
+
|
2830
|
+
/***/ }),
|
2831
|
+
|
2746
2832
|
/***/ "./node_modules/eventemitter3/index.js":
|
2747
2833
|
/*!*********************************************!*\
|
2748
2834
|
!*** ./node_modules/eventemitter3/index.js ***!
|
@@ -5179,6 +5265,16 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5179
5265
|
|
5180
5266
|
/***/ }),
|
5181
5267
|
|
5268
|
+
/***/ "./node_modules/ticky/ticky-browser.js":
|
5269
|
+
/*!*********************************************!*\
|
5270
|
+
!*** ./node_modules/ticky/ticky-browser.js ***!
|
5271
|
+
\*********************************************/
|
5272
|
+
/***/ (function(module) {
|
5273
|
+
|
5274
|
+
eval("var si = typeof setImmediate === 'function', tick;\nif (si) {\n tick = function (fn) { setImmediate(fn); };\n} else {\n tick = function (fn) { setTimeout(fn, 0); };\n}\n\nmodule.exports = tick;\n\n//# sourceURL=webpack://Formio/./node_modules/ticky/ticky-browser.js?");
|
5275
|
+
|
5276
|
+
/***/ }),
|
5277
|
+
|
5182
5278
|
/***/ "./node_modules/tippy.js/dist/tippy.esm.js":
|
5183
5279
|
/*!*************************************************!*\
|
5184
5280
|
!*** ./node_modules/tippy.js/dist/tippy.esm.js ***!
|
@@ -5428,7 +5524,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5428
5524
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
5429
5525
|
|
5430
5526
|
"use strict";
|
5431
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst moment_1 = __importDefault(__webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\"));\nconst compare_versions_1 = __webpack_require__(/*! compare-versions */ \"./node_modules/compare-versions/lib/esm/index.js\");\nconst EventEmitter_1 = __importDefault(__webpack_require__(/*! ./EventEmitter */ \"./lib/cjs/EventEmitter.js\"));\nconst i18n_1 = __importDefault(__webpack_require__(/*! ./i18n */ \"./lib/cjs/i18n.js\"));\nconst Formio_1 = __webpack_require__(/*! ./Formio */ \"./lib/cjs/Formio.js\");\nconst Components_1 = __importDefault(__webpack_require__(/*! ./components/Components */ \"./lib/cjs/components/Components.js\"));\nconst NestedDataComponent_1 = __importDefault(__webpack_require__(/*! ./components/_classes/nesteddata/NestedDataComponent */ \"./lib/cjs/components/_classes/nesteddata/NestedDataComponent.js\"));\nconst utils_1 = __webpack_require__(/*! ./utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst formUtils_1 = __webpack_require__(/*! ./utils/formUtils */ \"./lib/cjs/utils/formUtils.js\");\n// Initialize the available forms.\nFormio_1.Formio.forms = {};\n// Allow people to register components.\nFormio_1.Formio.registerComponent = Components_1.default.setComponent;\n/**\n *\n * @param {any} icons - The icons to use.\n * @returns {any} - The icon set.\n */\nfunction getIconSet(icons) {\n if (icons === \"fontawesome\") {\n return \"fa\";\n }\n return icons || \"\";\n}\n/**\n *\n * @param {any} options - The options to get.\n * @returns {any} - The options.\n */\nfunction getOptions(options) {\n options = lodash_1.default.defaults(options, {\n submitOnEnter: false,\n iconset: getIconSet(options && options.icons ? options.icons : Formio_1.Formio.icons),\n i18next: null,\n saveDraft: false,\n alwaysDirty: false,\n saveDraftThrottle: 5000,\n display: \"form\",\n cdnUrl: Formio_1.Formio.cdn.baseUrl,\n });\n if (!options.events) {\n options.events = new EventEmitter_1.default();\n }\n return options;\n}\n/**\n * Represents a JSON value.\n * @typedef {(string | number | boolean | null | JSONArray | JSONObject)} JSON\n */\n/**\n * Represents a JSON array.\n * @typedef {Array<JSON>} JSONArray\n */\n/**\n * Represents a JSON object.\n * @typedef {{[key: string]: JSON}} JSONObject\n */\n/**\n * @typedef {object} FormioHooks\n * @property {Function} [beforeSubmit] - A function that is called before the form is submitted.\n * @property {Function} [beforeCancel] - A function that is called before the form is canceled.\n * @property {Function} [beforeNext] - A function that is called before moving to the next page in a multi-page form.\n * @property {Function} [beforePrev] - A function that is called before moving to the previous page in a multi-page form.\n * @property {Function} [attachComponent] - A function that is called when a component is attached to the form.\n * @property {Function} [setDataValue] - A function that is called when setting the value of a data component.\n * @property {Function} [addComponents] - A function that is called when adding multiple components to the form.\n * @property {Function} [addComponent] - A function that is called when adding a single component to the form.\n * @property {Function} [customValidation] - A function that is called for custom validation of the form.\n * @property {Function} [attachWebform] - A function that is called when attaching a webform to the form.\n */\n/**\n * @typedef {object} SanitizeConfig\n * @property {string[]} [addAttr] - The attributes to add.\n * @property {string[]} [addTags] - The tags to add.\n * @property {string[]} [allowedAttrs] - The allowed attributes.\n * @property {string[]} [allowedTags] - The allowed tags.\n * @property {string[]} [allowedUriRegex] - The allowed URI regex.\n * @property {string[]} [addUriSafeAttr] - The URI safe attributes.\n */\n/**\n * @typedef {object} ButtonSettings\n * @property {boolean} [showPrevious] - Show the \"Previous\" button.\n * @property {boolean} [showNext] - Show the \"Next\" button.\n * @property {boolean} [showCancel] - Show the \"Cancel\" button.\n * @property {boolean} [showSubmit] - Show the \"Submit\" button.\n */\n/**\n * @typedef {object} FormOptions\n * @property {boolean} [saveDraft] - Enable the save draft feature.\n * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.\n * @property {boolean} [readOnly] - Set this form to readOnly.\n * @property {boolean} [noAlerts] - Disable the alerts dialog.\n * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.\n * @property {string} [template] - Custom logic for creation of elements.\n * @property {boolean} [noDefaults] - Exclude default values from the settings.\n * @property {any} [fileService] - The file service for this form.\n * @property {EventEmitter} [events] - The EventEmitter for this form.\n * @property {string} [language] - The language to render this form in.\n * @property {{[key: string]: string}} [i18next] - The i18next configuration for this form.\n * @property {boolean} [viewAsHtml] - View the form as raw HTML.\n * @property {'form' | 'html' | 'flat' | 'builder' | 'pdf'} [renderMode] - The render mode for this form.\n * @property {boolean} [highlightErrors] - Highlight any errors on the form.\n * @property {string} [componentErrorClass] - The error class for components.\n * @property {any} [templates] - The templates for this form.\n * @property {string} [iconset] - The iconset for this form.\n * @property {import('@formio/core').Component[]} [components] - The components for this form.\n * @property {{[key: string]: boolean}} [disabled] - Disabled components for this form.\n * @property {boolean} [showHiddenFields] - Show hidden fields.\n * @property {{[key: string]: boolean}} [hide] - Hidden components for this form.\n * @property {{[key: string]: boolean}} [show] - Components to show for this form.\n * @property {Formio} [formio] - The Formio instance for this form.\n * @property {string} [decimalSeparator] - The decimal separator for this form.\n * @property {string} [thousandsSeparator] - The thousands separator for this form.\n * @property {FormioHooks} [hooks] - The hooks for this form.\n * @property {boolean} [alwaysDirty] - Always be dirty.\n * @property {boolean} [skipDraftRestore] - Skip restoring a draft.\n * @property {'form' | 'wizard' | 'pdf'} [display] - The display for this form.\n * @property {string} [cdnUrl] - The CDN url for this form.\n * @property {boolean} [flatten] - Flatten the form.\n * @property {boolean} [sanitize] - Sanitize the form.\n * @property {SanitizeConfig} [sanitizeConfig] - The sanitize configuration for this form.\n * @property {ButtonSettings} [buttonSettings] - The button settings for this form.\n * @property {object} [breadcrumbSettings] - The breadcrumb settings for this form.\n * @property {boolean} [allowPrevious] - Allow the previous button (for Wizard forms).\n * @property {string[]} [wizardButtonOrder] - The order of the buttons (for Wizard forms).\n * @property {boolean} [showCheckboxBackground] - Show the checkbox background.\n * @property {boolean} [inputsOnly] - Only show inputs in the form and no labels.\n * @property {boolean} [building] - If we are in the process of building the form.\n * @property {number} [zoom] - The zoom for PDF forms.\n */\nclass Webform extends NestedDataComponent_1.default {\n /**\n * Creates a new Form instance.\n * @param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.\n * @param {import('Form').FormOptions} [options] - The options to create a new form instance.\n */\n constructor(elementOrOptions, options = undefined) {\n let element, formOptions;\n if (elementOrOptions instanceof HTMLElement || options) {\n element = elementOrOptions;\n formOptions = options || {};\n }\n else {\n formOptions = elementOrOptions || {};\n }\n super(null, getOptions(formOptions));\n this.executeShortcuts = (event) => {\n const { target } = event;\n if (!this.keyboardCatchableElement(target)) {\n return;\n }\n const ctrl = event.ctrlKey || event.metaKey;\n const keyCode = event.keyCode;\n let char = \"\";\n if (65 <= keyCode && keyCode <= 90) {\n char = String.fromCharCode(keyCode);\n }\n else if (keyCode === 13) {\n char = \"Enter\";\n }\n else if (keyCode === 27) {\n char = \"Esc\";\n }\n lodash_1.default.each(this.shortcuts, (shortcut) => {\n if (shortcut.ctrl && !ctrl) {\n return;\n }\n if (shortcut.shortcut === char) {\n shortcut.element.click();\n event.preventDefault();\n }\n });\n };\n this.setElement(element);\n // Keep track of all available forms globally.\n Formio_1.Formio.forms[this.id] = this;\n // Set the base url.\n if (this.options.baseUrl) {\n Formio_1.Formio.setBaseUrl(this.options.baseUrl);\n }\n /**\n * The type of this element.\n * @type {string}\n */\n this.type = \"form\";\n this._src = \"\";\n this._loading = false;\n this._form = {};\n this.draftEnabled = false;\n this.savingDraft = false;\n if (this.options.saveDraftThrottle) {\n this.triggerSaveDraft = lodash_1.default.throttle(this.saveDraft.bind(this), this.options.saveDraftThrottle);\n }\n else {\n this.triggerSaveDraft = this.saveDraft.bind(this);\n }\n /**\n * Determines if this form should submit the API on submit.\n * @type {boolean}\n */\n this.nosubmit = false;\n /**\n * Determines if the form has tried to be submitted, error or not.\n * @type {boolean}\n */\n this.submitted = false;\n /**\n * Determines if the form is being submitted at the moment.\n * @type {boolean}\n */\n this.submitting = false;\n /**\n * The Formio instance for this form.\n * @type {Formio}\n */\n this.formio = null;\n /**\n * The loader HTML element.\n * @type {HTMLElement}\n */\n this.loader = null;\n /**\n * The alert HTML element\n * @type {HTMLElement}\n */\n this.alert = null;\n /**\n * Promise that is triggered when the submission is done loading.\n * @type {Promise}\n */\n this.onSubmission = null;\n /**\n * Determines if this submission is explicitly set.\n * @type {boolean}\n */\n this.submissionSet = false;\n /**\n * Promise that executes when the form is ready and rendered.\n * @type {Promise}\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.formReady.then(() => {\n * console.log('The form is ready!');\n * });\n * form.src = 'https://examples.form.io/example';\n */\n this.formReady = new Promise((resolve, reject) => {\n /**\n * Called when the formReady state of this form has been resolved.\n * @type {Function}\n */\n this.formReadyResolve = resolve;\n /**\n * Called when this form could not load and is rejected.\n * @type {Function}\n */\n this.formReadyReject = reject;\n });\n /**\n * Promise that executes when the submission is ready and rendered.\n * @type {Promise}\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.submissionReady.then(() => {\n * console.log('The submission is ready!');\n * });\n * form.src = 'https://examples.form.io/example/submission/234234234234234243';\n */\n this.submissionReady = new Promise((resolve, reject) => {\n /**\n * Called when the formReady state of this form has been resolved.\n * @type {Function}\n */\n this.submissionReadyResolve = resolve;\n /**\n * Called when this form could not load and is rejected.\n * @type {Function}\n */\n this.submissionReadyReject = reject;\n });\n this.shortcuts = [];\n // Set language after everything is established.\n this.language = this.i18next.language;\n // See if we need to restore the draft from a user.\n if (this.options.saveDraft) {\n if (this.options.skipDraftRestore) {\n this.draftEnabled = true;\n this.savingDraft = false;\n }\n else {\n this.formReady.then(() => {\n const user = Formio_1.Formio.getUser();\n // Only restore a draft if the submission isn't explicitly set.\n if (user && !this.submissionSet) {\n this.restoreDraft(user._id);\n }\n });\n }\n }\n this.component.clearOnHide = false;\n // Ensure the root is set to this component.\n this.root = this;\n this.localRoot = this;\n }\n /* eslint-enable max-statements */\n get language() {\n return this.options.language;\n }\n get emptyValue() {\n return null;\n }\n componentContext() {\n return this._data;\n }\n /**\n * Sets the language for this form.\n * @param {string} lang - The language to use (e.g. 'en', 'sp', etc.)\n */\n set language(lang) {\n if (!this.i18next) {\n return;\n }\n this.options.language = lang;\n if (this.i18next.language === lang) {\n return;\n }\n this.i18next.changeLanguage(lang, (err) => {\n if (err) {\n return;\n }\n this.rebuild();\n this.emit(\"languageChanged\");\n });\n }\n get componentComponents() {\n return this.form.components;\n }\n get shadowRoot() {\n return this.options.shadowRoot;\n }\n /**\n * Add a language for translations\n * @param {string} code - The language code for the language being added.\n * @param {object} lang - The language translations.\n * @param {boolean} [active] - If this language should be set as the active language.\n */\n addLanguage(code, lang, active = false) {\n if (this.i18next) {\n var translations = lodash_1.default.assign((0, utils_1.fastCloneDeep)(i18n_1.default.resources.en.translation), lang);\n this.i18next.addResourceBundle(code, \"translation\", translations, true, true);\n if (active) {\n this.language = code;\n }\n }\n }\n keyboardCatchableElement(element) {\n if (element.nodeName === \"TEXTAREA\") {\n return false;\n }\n if (element.nodeName === \"INPUT\") {\n return [\"text\", \"email\", \"password\"].indexOf(element.type) === -1;\n }\n return true;\n }\n addShortcut(element, shortcut) {\n if (!shortcut || !/^([A-Z]|Enter|Esc)$/i.test(shortcut)) {\n return;\n }\n shortcut = lodash_1.default.capitalize(shortcut);\n if (shortcut === \"Enter\" || shortcut === \"Esc\") {\n // Restrict Enter and Esc only for buttons\n if (element.tagName !== \"BUTTON\") {\n return;\n }\n this.shortcuts.push({\n shortcut,\n element,\n });\n }\n else {\n this.shortcuts.push({\n ctrl: true,\n shortcut,\n element,\n });\n }\n }\n removeShortcut(element, shortcut) {\n if (!shortcut || !/^([A-Z]|Enter|Esc)$/i.test(shortcut)) {\n return;\n }\n lodash_1.default.remove(this.shortcuts, {\n shortcut,\n element,\n });\n }\n /**\n * Get the embed source of the form.\n * @returns {string} - The source of the form.\n */\n get src() {\n return this._src;\n }\n /**\n * Loads the submission if applicable.\n * @returns {Promise} - The promise that is triggered when the submission is loaded.\n */\n loadSubmission() {\n this.loadingSubmission = true;\n if (this.formio.submissionId) {\n this.onSubmission = this.formio\n .loadSubmission()\n .then((submission) => this.setSubmission(submission), (err) => this.submissionReadyReject(err))\n .catch((err) => this.submissionReadyReject(err));\n }\n else {\n this.submissionReadyResolve();\n }\n return this.submissionReady;\n }\n /**\n * Set the src of the form renderer.\n * @param {string} value - The source value to set.\n * @param {any} options - The options to set.\n * @returns {Promise} - The promise that is triggered when the form is set.\n */\n setSrc(value, options) {\n if (this.setUrl(value, options)) {\n this.nosubmit = false;\n return this.formio\n .loadForm({ params: { live: 1 } })\n .then((form) => {\n const setForm = this.setForm(form);\n this.loadSubmission();\n return setForm;\n })\n .catch((err) => {\n console.warn(err);\n this.formReadyReject(err);\n });\n }\n return Promise.resolve();\n }\n /**\n * Set the Form source, which is typically the Form.io embed URL.\n * @param {string} value - The value of the form embed url.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.formReady.then(() => {\n * console.log('The form is formReady!');\n * });\n * form.src = 'https://examples.form.io/example';\n */\n set src(value) {\n this.setSrc(value);\n }\n /**\n * Get the embed source of the form.\n * @returns {string} - returns the source of the form.\n */\n get url() {\n return this._src;\n }\n /**\n * Sets the url of the form renderer.\n * @param {string} value - The value to set the url to.\n * @param {any} options - The options to set.\n * @returns {boolean} - TRUE means the url was set, FALSE otherwise.\n */\n setUrl(value, options) {\n if (!value || typeof value !== \"string\" || value === this._src) {\n return false;\n }\n this._src = value;\n this.nosubmit = true;\n this.formio = this.options.formio = new Formio_1.Formio(value, options);\n if (this.type === \"form\") {\n // Set the options source so this can be passed to other components.\n this.options.src = value;\n }\n return true;\n }\n /**\n * Set the form source but don't initialize the form and submission from the url.\n * @param {string} value - The value of the form embed url.\n */\n set url(value) {\n this.setUrl(value);\n }\n /**\n * Called when both the form and submission have been loaded.\n * @returns {Promise} - The promise to trigger when both form and submission have loaded.\n */\n get ready() {\n return this.formReady.then(() => {\n return super.ready.then(() => {\n return this.loadingSubmission ? this.submissionReady : true;\n });\n });\n }\n /**\n * Returns if this form is loading.\n * @returns {boolean} - TRUE means the form is loading, FALSE otherwise.\n */\n get loading() {\n return this._loading;\n }\n /**\n * Set the loading state for this form, and also show the loader spinner.\n * @param {boolean} loading - If this form should be \"loading\" or not.\n */\n set loading(loading) {\n if (this._loading !== loading) {\n this._loading = loading;\n if (!this.loader && loading) {\n this.loader = this.ce(\"div\", {\n class: \"loader-wrapper\",\n });\n const spinner = this.ce(\"div\", {\n class: \"loader text-center\",\n });\n this.loader.appendChild(spinner);\n }\n /* eslint-disable max-depth */\n if (this.loader) {\n try {\n if (loading) {\n this.prependTo(this.loader, this.wrapper);\n }\n else {\n this.removeChildFrom(this.loader, this.wrapper);\n }\n }\n catch (err) {\n // ingore\n }\n }\n /* eslint-enable max-depth */\n }\n }\n /**\n * Sets the JSON schema for the form to be rendered.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.setForm({\n * components: [\n * {\n * type: 'textfield',\n * key: 'firstName',\n * label: 'First Name',\n * placeholder: 'Enter your first name.',\n * input: true\n * },\n * {\n * type: 'textfield',\n * key: 'lastName',\n * label: 'Last Name',\n * placeholder: 'Enter your last name',\n * input: true\n * },\n * {\n * type: 'button',\n * action: 'submit',\n * label: 'Submit',\n * theme: 'primary'\n * }\n * ]\n * });\n * @param {object} form - The JSON schema of the form @see https://examples.form.io/example for an example JSON schema.\n * @param {any} flags - Any flags to apply when setting the form.\n * @returns {Promise} - The promise that is triggered when the form is set.\n */\n setForm(form, flags = {}) {\n var _a, _b, _c;\n const isFormAlreadySet = this._form && ((_a = this._form.components) === null || _a === void 0 ? void 0 : _a.length);\n try {\n // Do not set the form again if it has been already set\n if (isFormAlreadySet && JSON.stringify(this._form) === JSON.stringify(form)) {\n return Promise.resolve();\n }\n // Create the form.\n this._form = (flags === null || flags === void 0 ? void 0 : flags.keepAsReference) ? form : lodash_1.default.cloneDeep(form);\n if (this.onSetForm) {\n this.onSetForm(lodash_1.default.cloneDeep(this._form), form);\n }\n if ((_c = (_b = this.parent) === null || _b === void 0 ? void 0 : _b.component) === null || _c === void 0 ? void 0 : _c.modalEdit) {\n return Promise.resolve();\n }\n }\n catch (err) {\n console.warn(err);\n // If provided form is not a valid JSON object, do not set it too\n return Promise.resolve();\n }\n // Allow the form to provide component overrides.\n if (form && form.settings && form.settings.components) {\n this.options.components = form.settings.components;\n }\n if (form && form.properties) {\n this.options.properties = form.properties;\n }\n // Use the sanitize config from the form settings or the global sanitize config if it is not provided in the options\n if (!this.options.sanitizeConfig && !this.builderMode) {\n this.options.sanitizeConfig =\n lodash_1.default.get(form, \"settings.sanitizeConfig\") ||\n lodash_1.default.get(form, \"globalSettings.sanitizeConfig\");\n }\n if (\"schema\" in form && (0, compare_versions_1.compareVersions)(form.schema, \"1.x\") > 0) {\n this.ready.then(() => {\n this.setAlert(\"alert alert-danger\", \"Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.\");\n });\n }\n // See if they pass a module, and evaluate it if so.\n if (form && form.module) {\n let formModule = null;\n if (typeof form.module === \"string\") {\n try {\n formModule = this.evaluate(`return ${form.module}`);\n }\n catch (err) {\n console.warn(err);\n }\n }\n else {\n formModule = form.module;\n }\n if (formModule) {\n Formio_1.Formio.use(formModule);\n // Since we got here after instantiation, we need to manually apply form options.\n if (formModule.options && formModule.options.form) {\n this.options = Object.assign(this.options, formModule.options.form);\n }\n }\n }\n this.initialized = false;\n const rebuild = this.rebuild() || Promise.resolve();\n return rebuild.then(() => {\n this.emit(\"formLoad\", form);\n this.triggerCaptcha();\n // Make sure to trigger onChange after a render event occurs to speed up form rendering.\n setTimeout(() => {\n this.onChange(flags);\n this.formReadyResolve();\n }, 0);\n return this.formReady;\n });\n }\n /**\n * Gets the form object.\n * @returns {object} - The form JSON schema.\n */\n get form() {\n if (!this._form) {\n this._form = {\n components: [],\n };\n }\n return this._form;\n }\n /**\n * Sets the form value.\n * @alias setForm\n * @param {object} form - The form schema object.\n */\n set form(form) {\n this.setForm(form);\n }\n /**\n * Returns the submission object that was set within this form.\n * @returns {object} - The submission object.\n */\n get submission() {\n return this.getValue();\n }\n /**\n * Sets the submission of a form.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.src = 'https://examples.form.io/example';\n * form.submission = {data: {\n * firstName: 'Joe',\n * lastName: 'Smith',\n * email: 'joe@example.com'\n * }};\n * @param {object} submission - The Form.io submission object.\n */\n set submission(submission) {\n this.setSubmission(submission);\n }\n /**\n * Sets a submission and returns the promise when it is ready.\n * @param {any} submission - The submission to set.\n * @param {any} flags - Any flags to apply when setting the submission.\n * @returns {Promise} - The promise that is triggered when the submission is set.\n */\n setSubmission(submission, flags = {}) {\n flags = Object.assign(Object.assign({}, flags), { fromSubmission: lodash_1.default.has(flags, \"fromSubmission\") ? flags.fromSubmission : true });\n return (this.onSubmission = this.formReady\n .then((resolveFlags) => {\n if (resolveFlags) {\n flags = Object.assign(Object.assign({}, flags), resolveFlags);\n }\n this.submissionSet = true;\n this.triggerChange(flags);\n this.emit(\"beforeSetSubmission\", submission);\n this.setValue(submission, flags);\n return this.submissionReadyResolve(submission);\n }, (err) => this.submissionReadyReject(err))\n .catch((err) => this.submissionReadyReject(err)));\n }\n handleDraftError(errName, errDetails, restoreDraft) {\n const errorMessage = lodash_1.default.trim(`${this.t(errName)} ${errDetails || \"\"}`);\n console.warn(errorMessage);\n this.emit(restoreDraft ? \"restoreDraftError\" : \"saveDraftError\", errDetails || errorMessage);\n }\n saveDraft() {\n if (!this.draftEnabled) {\n return;\n }\n if (!this.formio) {\n this.handleDraftError(\"saveDraftInstanceError\");\n return;\n }\n if (!Formio_1.Formio.getUser()) {\n this.handleDraftError(\"saveDraftAuthError\");\n return;\n }\n const draft = (0, utils_1.fastCloneDeep)(this.submission);\n draft.state = \"draft\";\n if (!this.savingDraft && !this.submitting) {\n this.emit(\"saveDraftBegin\");\n this.savingDraft = true;\n this.formio\n .saveSubmission(draft)\n .then((sub) => {\n // Set id to submission to avoid creating new draft submission\n this.submission._id = sub._id;\n this.savingDraft = false;\n this.emit(\"saveDraft\", sub);\n })\n .catch((err) => {\n this.savingDraft = false;\n this.handleDraftError(\"saveDraftError\", err);\n });\n }\n }\n /**\n * Restores a draft submission based on the user who is authenticated.\n * @param {string} userId - The user id where we need to restore the draft from.\n */\n restoreDraft(userId) {\n const formio = this.formio || this.options.formio;\n if (!formio) {\n this.handleDraftError(\"restoreDraftInstanceError\", null, true);\n return;\n }\n this.savingDraft = true;\n formio\n .loadSubmissions({\n params: {\n state: 'draft',\n owner: userId,\n sort: '-created'\n },\n })\n .then((submissions) => {\n if (submissions.length > 0 && !this.options.skipDraftRestore) {\n const draft = (0, utils_1.fastCloneDeep)(submissions[0]);\n return this.setSubmission(draft).then(() => {\n this.draftEnabled = true;\n this.savingDraft = false;\n this.emit(\"restoreDraft\", draft);\n });\n }\n // Enable drafts so that we can keep track of changes.\n this.draftEnabled = true;\n this.savingDraft = false;\n this.emit(\"restoreDraft\", null);\n })\n .catch((err) => {\n this.draftEnabled = true;\n this.savingDraft = false;\n this.handleDraftError(\"restoreDraftError\", err, true);\n });\n }\n get schema() {\n const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, [\"components\"]));\n schema.components = [];\n this.eachComponent((component) => schema.components.push(component.schema));\n return schema;\n }\n mergeData(_this, _that) {\n lodash_1.default.mergeWith(_this, _that, (thisValue, thatValue) => {\n if (Array.isArray(thisValue) &&\n Array.isArray(thatValue) &&\n thisValue.length !== thatValue.length) {\n return thatValue;\n }\n });\n }\n setValue(submission, flags = {}) {\n if (!submission || !submission.data) {\n submission = {\n data: {},\n metadata: submission.metadata,\n };\n }\n // Metadata needs to be available before setValue\n this._submission.metadata = submission.metadata ? lodash_1.default.cloneDeep(submission.metadata) : {};\n this.editing = !!submission._id;\n // Set the timezone in the options if available.\n if (!this.options.submissionTimezone &&\n submission.metadata &&\n submission.metadata.timezone) {\n this.options.submissionTimezone = submission.metadata.timezone;\n }\n const changed = super.setValue(submission.data, flags);\n if (!flags.sanitize) {\n this.mergeData(this.data, submission.data);\n }\n submission.data = this.data;\n this._submission = submission;\n return changed;\n }\n getValue() {\n if (!this._submission.data) {\n this._submission.data = {};\n }\n if (this.viewOnly) {\n return this._submission;\n }\n const submission = this._submission;\n submission.data = this.data;\n return this._submission;\n }\n /**\n * Build the form.\n * @returns {Promise} - The promise that is triggered when the form is built.\n */\n init() {\n if (this.options.submission) {\n const submission = lodash_1.default.extend({}, this.options.submission);\n this._submission = submission;\n this._data = submission.data;\n }\n else {\n this._submission = this._submission || { data: {} };\n }\n // Remove any existing components.\n if (this.components && this.components.length) {\n this.destroyComponents();\n this.components = [];\n }\n if (this.component) {\n this.component.components = this.form ? this.form.components : [];\n }\n else {\n this.component = this.form;\n }\n this.component.type = \"form\";\n this.component.input = false;\n this.addComponents();\n this.on(\"submitButton\", (options) => {\n this.submit(false, options).catch((e) => {\n options.instance.loading = false;\n return e !== false && e !== undefined && console.log(e);\n });\n }, true);\n this.on(\"checkValidity\", (data) => this.validate(data, { dirty: true, process: \"change\" }), true);\n this.on(\"requestUrl\", (args) => this.submitUrl(args.url, args.headers), true);\n this.on(\"resetForm\", () => this.resetValue(), true);\n this.on(\"deleteSubmission\", () => this.deleteSubmission(), true);\n this.on(\"refreshData\", () => this.updateValue(), true);\n this.executeFormController();\n return this.formReady;\n }\n executeFormController() {\n // If no controller value or\n // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)\n if (!this.form ||\n !this.form.controller ||\n ((!this.visible || this.component.hidden) &&\n this.component.clearOnHide &&\n !this.rootPristine)) {\n return false;\n }\n this.formReady.then(() => {\n this.evaluate(this.form.controller, {\n components: this.components,\n instance: this,\n });\n });\n }\n /**\n *\n */\n teardown() {\n this.emit(\"formDelete\", this.id);\n delete Formio_1.Formio.forms[this.id];\n delete this.executeShortcuts;\n delete this.triggerSaveDraft;\n super.teardown();\n }\n destroy(all = false) {\n this.off(\"submitButton\");\n this.off(\"checkValidity\");\n this.off(\"requestUrl\");\n this.off(\"resetForm\");\n this.off(\"deleteSubmission\");\n this.off(\"refreshData\");\n return super.destroy(all);\n }\n build(element) {\n if (element || this.element) {\n return this.ready.then(() => {\n element = element || this.element;\n super.build(element);\n });\n }\n return this.ready;\n }\n getClassName() {\n let classes = \"formio-form\";\n if (this.options.readOnly) {\n classes += \" formio-read-only\";\n }\n return classes;\n }\n render() {\n return super.render(this.renderTemplate(\"webform\", {\n classes: this.getClassName(),\n children: this.renderComponents(),\n }), this.builderMode ? \"builder\" : \"form\", true);\n }\n redraw() {\n // Don't bother if we have not built yet.\n if (!this.element) {\n return Promise.resolve();\n }\n this.clear();\n this.setContent(this.element, this.render());\n return this.attach(this.element);\n }\n attach(element) {\n this.setElement(element);\n this.loadRefs(element, { webform: \"single\" });\n const childPromise = this.attachComponents(this.refs.webform);\n this.addEventListener(document, \"keydown\", this.executeShortcuts);\n this.currentForm = this;\n this.hook(\"attachWebform\", element, this);\n return childPromise.then(() => {\n this.emit(\"render\", this.element);\n return this.setValue(this._submission, {\n noUpdateEvent: true,\n });\n });\n }\n hasRequiredFields() {\n let result = false;\n (0, formUtils_1.eachComponent)(this.form.components, (component) => {\n if (component.validate.required) {\n result = true;\n return true;\n }\n }, true);\n return result;\n }\n resetValue() {\n lodash_1.default.each(this.getComponents(), (comp) => comp.resetValue());\n this.setPristine(true);\n this.onChange({ resetValue: true });\n }\n /**\n * Sets a new alert to display in the error dialog of the form.\n * @param {string} type - The type of alert to display. \"danger\", \"success\", \"warning\", etc.\n * @param {string} message - The message to show in the alert.\n * @param {object} options - The options for the alert.\n */\n setAlert(type, message, options) {\n if (!type && this.submitted) {\n if (this.alert) {\n if (this.refs.errorRef && this.refs.errorRef.length) {\n this.refs.errorRef.forEach((el) => {\n this.removeEventListener(el, \"click\");\n this.removeEventListener(el, \"keypress\");\n });\n }\n this.removeChild(this.alert);\n this.alert = null;\n }\n return;\n }\n if (this.options.noAlerts) {\n if (!message) {\n this.emit(\"error\", false);\n }\n return;\n }\n if (this.alert) {\n try {\n if (this.refs.errorRef && this.refs.errorRef.length) {\n this.refs.errorRef.forEach((el) => {\n this.removeEventListener(el, \"click\");\n this.removeEventListener(el, \"keypress\");\n });\n }\n this.removeChild(this.alert);\n this.alert = null;\n }\n catch (err) {\n // ignore\n }\n }\n if (message) {\n const attrs = {\n class: (options && options.classes) || `alert alert-${type}`,\n id: `error-list-${this.id}`,\n };\n const templateOptions = {\n message: message instanceof HTMLElement ? message.outerHTML : message,\n attrs: attrs,\n type,\n };\n this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate(\"alert\", templateOptions), `#${attrs.id}`);\n }\n if (!this.alert) {\n return;\n }\n this.loadRefs(this.alert, { errorRef: \"multiple\" });\n if (this.refs.errorRef && this.refs.errorRef.length) {\n this.refs.errorRef.forEach((el) => {\n this.addEventListener(el, \"click\", (e) => {\n const key = e.currentTarget.dataset.componentKey;\n this.focusOnComponent(key);\n });\n this.addEventListener(el, \"keydown\", (e) => {\n if (e.keyCode === 13) {\n e.preventDefault();\n const key = e.currentTarget.dataset.componentKey;\n this.focusOnComponent(key);\n }\n });\n });\n }\n this.prepend(this.alert);\n }\n /**\n * Focus on selected component.\n * @param {string} key - The key of selected component.\n */\n focusOnComponent(key) {\n if (key) {\n const component = this.getComponent(key);\n if (component) {\n component.focus();\n }\n }\n }\n /**\n * Show the errors of this form within the alert dialog.\n * @param {object} error - An optional additional error to display along with the component errors.\n * @returns {*}\n */\n /* eslint-disable no-unused-vars */\n /**\n *\n * @param {Array} errors - An array of errors to display.\n * @param {boolean} triggerEvent - Whether or not to trigger the error event.\n * @returns {void|Array} - The errors that were set.\n */\n showErrors(errors, triggerEvent) {\n this.loading = false;\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n errors = errors.concat(this.customErrors).filter((err) => !!err);\n if (!errors.length) {\n this.setAlert(false);\n return;\n }\n // Mark any components as invalid if in a custom message.\n errors.forEach((err) => {\n const { components = [] } = err;\n if (err.component) {\n components.push(err.component);\n }\n if (err.path) {\n components.push(err.path);\n }\n components.forEach((path) => {\n const originalPath = (0, utils_1.getStringFromComponentPath)(path);\n const component = this.getComponent(path, lodash_1.default.identity, originalPath);\n if (err.fromServer) {\n if (component.serverErrors) {\n component.serverErrors.push(err);\n }\n else {\n component.serverErrors = [err];\n }\n }\n const components = lodash_1.default.compact(Array.isArray(component) ? component : [component]);\n components.forEach((component) => component.setCustomValidity(err.message, true));\n });\n });\n const displayedErrors = [];\n if (errors.length) {\n errors = lodash_1.default.uniqBy(errors, (error) => error.message);\n const createListItem = (message, index) => {\n var _a, _b, _c;\n const err = errors[index];\n const messageFromIndex = !lodash_1.default.isUndefined(index) && errors && errors[index];\n const keyOrPath = (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.formattedKeyOrPath) ||\n (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.path) ||\n ((_a = messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.context) === null || _a === void 0 ? void 0 : _a.path) ||\n (((_b = err.context) === null || _b === void 0 ? void 0 : _b.component) && ((_c = err.context) === null || _c === void 0 ? void 0 : _c.component.key)) ||\n (err.component && err.component.key) ||\n (err.fromServer && err.path);\n const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : \"\";\n if (typeof err !== \"string\" && !err.formattedKeyOrPath) {\n err.formattedKeyOrPath = formattedKeyOrPath;\n }\n return {\n message: (0, utils_1.unescapeHTML)(message),\n keyOrPath: formattedKeyOrPath,\n };\n };\n errors.forEach(({ message, context, fromServer, component }, index) => {\n const text = !(component === null || component === void 0 ? void 0 : component.label) || (context === null || context === void 0 ? void 0 : context.hasLabel) || fromServer\n ? this.t(\"alertMessage\", { message: this.t(message) })\n : this.t(\"alertMessageWithLabel\", {\n label: this.t(component === null || component === void 0 ? void 0 : component.label),\n message: this.t(message),\n });\n displayedErrors.push(createListItem(text, index));\n });\n }\n const errorsList = this.renderTemplate(\"errorsList\", { errors: displayedErrors });\n this.root.setAlert(\"danger\", errorsList);\n if (triggerEvent) {\n this.emit(\"error\", errors);\n }\n return errors;\n }\n /* eslint-enable no-unused-vars */\n /**\n * Called when the submission has completed, or if the submission needs to be sent to an external library.\n * @param {object} submission - The submission object.\n * @param {boolean} saved - Whether or not this submission was saved to the server.\n * @returns {object} - The submission object.\n */\n onSubmit(submission, saved) {\n var _a;\n this.loading = false;\n this.submitting = false;\n this.setPristine(true);\n // We want to return the submitted submission and setValue will mutate the submission so cloneDeep it here.\n this.setValue((0, utils_1.fastCloneDeep)(submission), {\n noValidate: true,\n noCheck: true,\n });\n this.setAlert(\"success\", `<p>${this.t(\"complete\")}</p>`);\n // Cancel triggered saveDraft to prevent overriding the submitted state\n if (this.draftEnabled && ((_a = this.triggerSaveDraft) === null || _a === void 0 ? void 0 : _a.cancel)) {\n this.triggerSaveDraft.cancel();\n }\n this.emit(\"submit\", submission, saved);\n if (saved) {\n this.emit(\"submitDone\", submission);\n }\n return submission;\n }\n normalizeError(error) {\n if (error) {\n if (typeof error === \"object\" && \"details\" in error) {\n error = error.details;\n }\n if (typeof error === \"string\") {\n error = { message: error };\n }\n }\n return error;\n }\n /**\n * Called when an error occurs during the submission.\n * @param {object} error - The error that occured.\n * @returns {Array} errors - All errors.\n */\n onSubmissionError(error) {\n error = this.normalizeError(error);\n this.submitting = false;\n this.setPristine(false);\n this.emit(\"submitError\", error || this.errors);\n // Allow for silent cancellations (no error message, no submit button error state)\n if (error && error.silent) {\n this.emit(\"change\", { isValid: true }, { silent: true });\n return false;\n }\n const errors = this.showErrors(error, true);\n if (this.root && this.root.alert) {\n this.scrollIntoView(this.root.alert);\n }\n return errors;\n }\n /**\n * Trigger the change event for this form.\n * @param {any} flags - The flags to set on this change event.\n * @param {any} changed - The changed object which reflects the changes in the form.\n * @param {boolean} modified - Whether or not the form has been modified.\n * @param {any} changes - The changes that have occured in the form.\n */\n onChange(flags, changed, modified, changes) {\n flags = flags || {};\n let isChangeEventEmitted = false;\n super.onChange(flags, true);\n const value = lodash_1.default.clone(this.submission);\n flags.changed = value.changed = changed;\n flags.changes = changes;\n if (modified && this.pristine) {\n this.pristine = false;\n }\n this.checkData(value.data, flags);\n const shouldValidate = !flags.noValidate ||\n flags.fromIFrame ||\n (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);\n const errors = shouldValidate\n ? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: \"change\" }))\n : [];\n value.isValid = errors.length === 0;\n this.loading = false;\n if (this.submitted) {\n // show server errors while they are not cleaned/fixed\n const nonComponentServerErrors = lodash_1.default.filter(this.serverErrors || [], (err) => !err.component && !err.path);\n this.showErrors(nonComponentServerErrors.length ? nonComponentServerErrors : errors);\n }\n // See if we need to save the draft of the form.\n if (modified && this.options.saveDraft) {\n this.triggerSaveDraft();\n }\n if (!flags || !flags.noEmit) {\n this.emit(\"change\", value, flags, modified);\n isChangeEventEmitted = true;\n }\n // The form is initialized after the first change event occurs.\n if (isChangeEventEmitted && !this.initialized) {\n this.emit(\"initialized\");\n this.initialized = true;\n }\n }\n /**\n * Send a delete request to the server.\n * @returns {Promise} - The promise that is triggered when the delete is complete.\n */\n deleteSubmission() {\n return this.formio.deleteSubmission().then(() => {\n this.emit(\"submissionDeleted\", this.submission);\n this.resetValue();\n });\n }\n /**\n * Cancels the submission.\n * @param {boolean} noconfirm - Whether or not to confirm the cancellation.\n * @alias reset\n * @returns {boolean} - TRUE means the submission was cancelled, FALSE otherwise.\n */\n cancel(noconfirm) {\n const shouldReset = this.hook(\"beforeCancel\", true);\n if (shouldReset && (noconfirm || confirm(this.t(\"confirmCancel\")))) {\n this.resetValue();\n return true;\n }\n else {\n this.emit(\"cancelSubmit\");\n return false;\n }\n }\n setMetadata(submission) {\n // Add in metadata about client submitting the form\n submission.metadata = submission.metadata || {};\n lodash_1.default.defaults(submission.metadata, {\n timezone: lodash_1.default.get(this, \"_submission.metadata.timezone\", (0, utils_1.currentTimezone)()),\n offset: parseInt(lodash_1.default.get(this, \"_submission.metadata.offset\", (0, moment_1.default)().utcOffset()), 10),\n origin: document.location.origin,\n referrer: document.referrer,\n browserName: navigator.appName,\n userAgent: navigator.userAgent,\n pathName: window.location.pathname,\n onLine: navigator.onLine,\n });\n }\n submitForm(options = {}) {\n this.clearServerErrors();\n return new Promise((resolve, reject) => {\n // Read-only forms should never submit.\n if (this.options.readOnly) {\n return resolve({\n submission: this.submission,\n saved: false,\n });\n }\n const submission = (0, utils_1.fastCloneDeep)(this.submission || {});\n this.setMetadata(submission);\n submission.state = options.state || submission.state || \"submitted\";\n const isDraft = submission.state === \"draft\";\n this.hook(\"beforeSubmit\", Object.assign(Object.assign({}, submission), { component: options.component }), (err, data) => {\n var _a;\n if (err) {\n return reject(err);\n }\n submission._vnote = data && data._vnote ? data._vnote : \"\";\n try {\n if (!isDraft && !options.noValidate) {\n if (!submission.data) {\n return reject(\"Invalid Submission\");\n }\n const errors = this.validate(submission.data, {\n dirty: true,\n silentCheck: false,\n process: \"submit\",\n });\n if (errors.length ||\n ((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === \"rejected\"))) {\n return reject(errors);\n }\n }\n }\n catch (err) {\n console.error(err);\n }\n this.everyComponent((comp) => {\n if (submission._vnote && comp.type === \"form\" && comp.component.reference) {\n lodash_1.default.get(submission.data, comp.path, {})._vnote = submission._vnote;\n }\n const { persistent } = comp.component;\n if (persistent === \"client-only\") {\n lodash_1.default.unset(submission.data, comp.path);\n }\n });\n this.hook(\"customValidation\", Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {\n if (err) {\n // If string is returned, cast to object.\n if (typeof err === \"string\") {\n err = {\n message: err,\n };\n }\n // Ensure err is an array.\n err = Array.isArray(err) ? err : [err];\n return reject(err);\n }\n this.loading = true;\n // Use the form action to submit the form if available.\n if (this._form && this._form.action) {\n const method = submission.data._id &&\n this._form.action.includes(submission.data._id)\n ? \"PUT\"\n : \"POST\";\n return Formio_1.Formio.makeStaticRequest(this._form.action, method, submission, this.formio ? this.formio.options : {})\n .then((result) => resolve({\n submission: result,\n saved: true,\n }))\n .catch((error) => {\n this.setServerErrors(error);\n return reject(error);\n });\n }\n const submitFormio = this.formio;\n if (this.nosubmit || !submitFormio) {\n return resolve({\n submission,\n saved: false,\n });\n }\n // If this is an actionUrl, then make sure to save the action and not the submission.\n const submitMethod = submitFormio.actionUrl\n ? \"saveAction\"\n : \"saveSubmission\";\n submitFormio[submitMethod](submission)\n .then((result) => resolve({\n submission: result,\n saved: true,\n }))\n .catch((error) => {\n this.setServerErrors(error);\n return reject(error);\n });\n });\n });\n });\n }\n setServerErrors(error) {\n if (error.details) {\n this.serverErrors = error.details\n .filter((err) => (err.level ? err.level === \"error\" : err))\n .map((err) => {\n err.fromServer = true;\n return err;\n });\n }\n else if (typeof error === \"string\") {\n this.serverErrors = [{ fromServer: true, level: \"error\", message: error }];\n }\n }\n executeSubmit(options) {\n this.submitted = true;\n this.submitting = true;\n return this.submitForm(options)\n .then(({ submission, saved }) => this.onSubmit(submission, saved))\n .then((results) => {\n this.submissionInProcess = false;\n return results;\n })\n .catch((err) => {\n this.submissionInProcess = false;\n return Promise.reject(this.onSubmissionError(err));\n });\n }\n clearServerErrors() {\n var _a;\n (_a = this.serverErrors) === null || _a === void 0 ? void 0 : _a.forEach((error) => {\n if (error.path) {\n const pathArray = (0, utils_1.getArrayFromComponentPath)(error.path);\n const component = this.getComponent(pathArray, lodash_1.default.identity, error.formattedKeyOrPath);\n if (component) {\n component.serverErrors = [];\n }\n }\n });\n this.serverErrors = [];\n }\n /**\n * Submits the form.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.src = 'https://examples.form.io/example';\n * form.submission = {data: {\n * firstName: 'Joe',\n * lastName: 'Smith',\n * email: 'joe@example.com'\n * }};\n * form.submit().then((submission) => {\n * console.log(submission);\n * });\n * @param {boolean} before - If this submission occured from the before handlers.\n * @param {any} options - The options to use when submitting this form.\n * @returns {Promise} - A promise when the form is done submitting.\n */\n submit(before = false, options = {}) {\n this.submissionInProcess = true;\n if (!before) {\n return this.beforeSubmit(options).then(() => this.executeSubmit(options));\n }\n else {\n return this.executeSubmit(options);\n }\n }\n submitUrl(URL, headers) {\n if (!URL) {\n return console.warn(\"Missing URL argument\");\n }\n const submission = this.submission || {};\n const API_URL = URL;\n const settings = {\n method: \"POST\",\n headers: {},\n };\n if (headers && headers.length > 0) {\n headers.map((e) => {\n if (e.header !== \"\" && e.value !== \"\") {\n settings.headers[e.header] = this.interpolate(e.value, submission);\n }\n });\n }\n if (API_URL && settings) {\n Formio_1.Formio.makeStaticRequest(API_URL, settings.method, submission, {\n headers: settings.headers,\n })\n .then(() => {\n this.emit(\"requestDone\");\n this.setAlert(\"success\", \"<p> Success </p>\");\n })\n .catch((e) => {\n const message = `${e.statusText ? e.statusText : \"\"} ${e.status ? e.status : e}`;\n this.emit(\"error\", message);\n console.error(message);\n this.setAlert(\"danger\", `<p> ${message} </p>`);\n return Promise.reject(this.onSubmissionError(e));\n });\n }\n else {\n this.emit(\"error\", \"You should add a URL to this button.\");\n this.setAlert(\"warning\", \"You should add a URL to this button.\");\n return console.warn(\"You should add a URL to this button.\");\n }\n }\n triggerCaptcha() {\n if (!this || !this.components) {\n return;\n }\n const captchaComponent = [];\n (0, formUtils_1.eachComponent)(this.components, (component) => {\n if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {\n captchaComponent.push(component);\n }\n });\n if (captchaComponent.length > 0) {\n captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);\n }\n }\n set nosubmit(value) {\n this._nosubmit = !!value;\n this.emit(\"nosubmit\", this._nosubmit);\n }\n get nosubmit() {\n return this._nosubmit || false;\n }\n get conditions() {\n var _a, _b;\n return (_b = (_a = this.schema.settings) === null || _a === void 0 ? void 0 : _a.conditions) !== null && _b !== void 0 ? _b : [];\n }\n get variables() {\n var _a, _b;\n return (_b = (_a = this.schema.settings) === null || _a === void 0 ? void 0 : _a.variables) !== null && _b !== void 0 ? _b : [];\n }\n}\nexports[\"default\"] = Webform;\nWebform.setBaseUrl = Formio_1.Formio.setBaseUrl;\nWebform.setApiUrl = Formio_1.Formio.setApiUrl;\nWebform.setAppUrl = Formio_1.Formio.setAppUrl;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Webform.js?");
|
5527
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst moment_1 = __importDefault(__webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\"));\nconst compare_versions_1 = __webpack_require__(/*! compare-versions */ \"./node_modules/compare-versions/lib/esm/index.js\");\nconst EventEmitter_1 = __importDefault(__webpack_require__(/*! ./EventEmitter */ \"./lib/cjs/EventEmitter.js\"));\nconst i18n_1 = __importDefault(__webpack_require__(/*! ./i18n */ \"./lib/cjs/i18n.js\"));\nconst Formio_1 = __webpack_require__(/*! ./Formio */ \"./lib/cjs/Formio.js\");\nconst Components_1 = __importDefault(__webpack_require__(/*! ./components/Components */ \"./lib/cjs/components/Components.js\"));\nconst NestedDataComponent_1 = __importDefault(__webpack_require__(/*! ./components/_classes/nesteddata/NestedDataComponent */ \"./lib/cjs/components/_classes/nesteddata/NestedDataComponent.js\"));\nconst utils_1 = __webpack_require__(/*! ./utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst formUtils_1 = __webpack_require__(/*! ./utils/formUtils */ \"./lib/cjs/utils/formUtils.js\");\nconst dragula_1 = __importDefault(__webpack_require__(/*! dragula */ \"./node_modules/dragula/dragula.js\"));\n// Initialize the available forms.\nFormio_1.Formio.forms = {};\n// Allow people to register components.\nFormio_1.Formio.registerComponent = Components_1.default.setComponent;\n/**\n *\n * @param {any} icons - The icons to use.\n * @returns {any} - The icon set.\n */\nfunction getIconSet(icons) {\n if (icons === \"fontawesome\") {\n return \"fa\";\n }\n return icons || \"\";\n}\n/**\n *\n * @param {any} options - The options to get.\n * @returns {any} - The options.\n */\nfunction getOptions(options) {\n options = lodash_1.default.defaults(options, {\n submitOnEnter: false,\n iconset: getIconSet(options && options.icons ? options.icons : Formio_1.Formio.icons),\n i18next: null,\n saveDraft: false,\n alwaysDirty: false,\n saveDraftThrottle: 5000,\n display: \"form\",\n cdnUrl: Formio_1.Formio.cdn.baseUrl,\n });\n if (!options.events) {\n options.events = new EventEmitter_1.default();\n }\n return options;\n}\n/**\n * Represents a JSON value.\n * @typedef {(string | number | boolean | null | JSONArray | JSONObject)} JSON\n */\n/**\n * Represents a JSON array.\n * @typedef {Array<JSON>} JSONArray\n */\n/**\n * Represents a JSON object.\n * @typedef {{[key: string]: JSON}} JSONObject\n */\n/**\n * @typedef {object} FormioHooks\n * @property {Function} [beforeSubmit] - A function that is called before the form is submitted.\n * @property {Function} [beforeCancel] - A function that is called before the form is canceled.\n * @property {Function} [beforeNext] - A function that is called before moving to the next page in a multi-page form.\n * @property {Function} [beforePrev] - A function that is called before moving to the previous page in a multi-page form.\n * @property {Function} [attachComponent] - A function that is called when a component is attached to the form.\n * @property {Function} [setDataValue] - A function that is called when setting the value of a data component.\n * @property {Function} [addComponents] - A function that is called when adding multiple components to the form.\n * @property {Function} [addComponent] - A function that is called when adding a single component to the form.\n * @property {Function} [customValidation] - A function that is called for custom validation of the form.\n * @property {Function} [attachWebform] - A function that is called when attaching a webform to the form.\n */\n/**\n * @typedef {object} SanitizeConfig\n * @property {string[]} [addAttr] - The attributes to add.\n * @property {string[]} [addTags] - The tags to add.\n * @property {string[]} [allowedAttrs] - The allowed attributes.\n * @property {string[]} [allowedTags] - The allowed tags.\n * @property {string[]} [allowedUriRegex] - The allowed URI regex.\n * @property {string[]} [addUriSafeAttr] - The URI safe attributes.\n */\n/**\n * @typedef {object} ButtonSettings\n * @property {boolean} [showPrevious] - Show the \"Previous\" button.\n * @property {boolean} [showNext] - Show the \"Next\" button.\n * @property {boolean} [showCancel] - Show the \"Cancel\" button.\n * @property {boolean} [showSubmit] - Show the \"Submit\" button.\n */\n/**\n * @typedef {object} FormOptions\n * @property {boolean} [saveDraft] - Enable the save draft feature.\n * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.\n * @property {boolean} [readOnly] - Set this form to readOnly.\n * @property {boolean} [noAlerts] - Disable the alerts dialog.\n * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.\n * @property {string} [template] - Custom logic for creation of elements.\n * @property {boolean} [noDefaults] - Exclude default values from the settings.\n * @property {any} [fileService] - The file service for this form.\n * @property {EventEmitter} [events] - The EventEmitter for this form.\n * @property {string} [language] - The language to render this form in.\n * @property {{[key: string]: string}} [i18next] - The i18next configuration for this form.\n * @property {boolean} [viewAsHtml] - View the form as raw HTML.\n * @property {'form' | 'html' | 'flat' | 'builder' | 'pdf'} [renderMode] - The render mode for this form.\n * @property {boolean} [highlightErrors] - Highlight any errors on the form.\n * @property {string} [componentErrorClass] - The error class for components.\n * @property {any} [templates] - The templates for this form.\n * @property {string} [iconset] - The iconset for this form.\n * @property {import('@formio/core').Component[]} [components] - The components for this form.\n * @property {{[key: string]: boolean}} [disabled] - Disabled components for this form.\n * @property {boolean} [showHiddenFields] - Show hidden fields.\n * @property {{[key: string]: boolean}} [hide] - Hidden components for this form.\n * @property {{[key: string]: boolean}} [show] - Components to show for this form.\n * @property {Formio} [formio] - The Formio instance for this form.\n * @property {string} [decimalSeparator] - The decimal separator for this form.\n * @property {string} [thousandsSeparator] - The thousands separator for this form.\n * @property {FormioHooks} [hooks] - The hooks for this form.\n * @property {boolean} [alwaysDirty] - Always be dirty.\n * @property {boolean} [skipDraftRestore] - Skip restoring a draft.\n * @property {'form' | 'wizard' | 'pdf'} [display] - The display for this form.\n * @property {string} [cdnUrl] - The CDN url for this form.\n * @property {boolean} [flatten] - Flatten the form.\n * @property {boolean} [sanitize] - Sanitize the form.\n * @property {SanitizeConfig} [sanitizeConfig] - The sanitize configuration for this form.\n * @property {ButtonSettings} [buttonSettings] - The button settings for this form.\n * @property {object} [breadcrumbSettings] - The breadcrumb settings for this form.\n * @property {boolean} [allowPrevious] - Allow the previous button (for Wizard forms).\n * @property {string[]} [wizardButtonOrder] - The order of the buttons (for Wizard forms).\n * @property {boolean} [showCheckboxBackground] - Show the checkbox background.\n * @property {boolean} [inputsOnly] - Only show inputs in the form and no labels.\n * @property {boolean} [building] - If we are in the process of building the form.\n * @property {number} [zoom] - The zoom for PDF forms.\n */\nclass Webform extends NestedDataComponent_1.default {\n /**\n * Creates a new Form instance.\n * @param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.\n * @param {import('Form').FormOptions} [options] - The options to create a new form instance.\n */\n constructor(elementOrOptions, options = undefined) {\n let element, formOptions;\n if (elementOrOptions instanceof HTMLElement || options) {\n element = elementOrOptions;\n formOptions = options || {};\n }\n else {\n formOptions = elementOrOptions || {};\n }\n super(null, getOptions(formOptions));\n this.executeShortcuts = (event) => {\n const { target } = event;\n if (!this.keyboardCatchableElement(target)) {\n return;\n }\n const ctrl = event.ctrlKey || event.metaKey;\n const keyCode = event.keyCode;\n let char = \"\";\n if (65 <= keyCode && keyCode <= 90) {\n char = String.fromCharCode(keyCode);\n }\n else if (keyCode === 13) {\n char = \"Enter\";\n }\n else if (keyCode === 27) {\n char = \"Esc\";\n }\n lodash_1.default.each(this.shortcuts, (shortcut) => {\n if (shortcut.ctrl && !ctrl) {\n return;\n }\n if (shortcut.shortcut === char) {\n shortcut.element.click();\n event.preventDefault();\n }\n });\n };\n this.setElement(element);\n // Keep track of all available forms globally.\n Formio_1.Formio.forms[this.id] = this;\n // Set the base url.\n if (this.options.baseUrl) {\n Formio_1.Formio.setBaseUrl(this.options.baseUrl);\n }\n /**\n * The type of this element.\n * @type {string}\n */\n this.type = \"form\";\n this._src = \"\";\n this._loading = false;\n this._form = {};\n this.draftEnabled = false;\n this.savingDraft = false;\n if (this.options.saveDraftThrottle) {\n this.triggerSaveDraft = lodash_1.default.throttle(this.saveDraft.bind(this), this.options.saveDraftThrottle);\n }\n else {\n this.triggerSaveDraft = this.saveDraft.bind(this);\n }\n /**\n * Determines if this form should submit the API on submit.\n * @type {boolean}\n */\n this.nosubmit = false;\n /**\n * Determines if the form has tried to be submitted, error or not.\n * @type {boolean}\n */\n this.submitted = false;\n /**\n * Determines if the form is being submitted at the moment.\n * @type {boolean}\n */\n this.submitting = false;\n /**\n * The Formio instance for this form.\n * @type {Formio}\n */\n this.formio = null;\n /**\n * The loader HTML element.\n * @type {HTMLElement}\n */\n this.loader = null;\n /**\n * The alert HTML element\n * @type {HTMLElement}\n */\n this.alert = null;\n /**\n * Promise that is triggered when the submission is done loading.\n * @type {Promise}\n */\n this.onSubmission = null;\n /**\n * Determines if this submission is explicitly set.\n * @type {boolean}\n */\n this.submissionSet = false;\n /**\n * Promise that executes when the form is ready and rendered.\n * @type {Promise}\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.formReady.then(() => {\n * console.log('The form is ready!');\n * });\n * form.src = 'https://examples.form.io/example';\n */\n this.formReady = new Promise((resolve, reject) => {\n /**\n * Called when the formReady state of this form has been resolved.\n * @type {Function}\n */\n this.formReadyResolve = resolve;\n /**\n * Called when this form could not load and is rejected.\n * @type {Function}\n */\n this.formReadyReject = reject;\n });\n /**\n * Promise that executes when the submission is ready and rendered.\n * @type {Promise}\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.submissionReady.then(() => {\n * console.log('The submission is ready!');\n * });\n * form.src = 'https://examples.form.io/example/submission/234234234234234243';\n */\n this.submissionReady = new Promise((resolve, reject) => {\n /**\n * Called when the formReady state of this form has been resolved.\n * @type {Function}\n */\n this.submissionReadyResolve = resolve;\n /**\n * Called when this form could not load and is rejected.\n * @type {Function}\n */\n this.submissionReadyReject = reject;\n });\n this.shortcuts = [];\n // Set language after everything is established.\n this.language = this.i18next.language;\n // See if we need to restore the draft from a user.\n if (this.options.saveDraft) {\n if (this.options.skipDraftRestore) {\n this.draftEnabled = true;\n this.savingDraft = false;\n }\n else {\n this.formReady.then(() => {\n const user = Formio_1.Formio.getUser();\n // Only restore a draft if the submission isn't explicitly set.\n if (user && !this.submissionSet) {\n this.restoreDraft(user._id);\n }\n });\n }\n }\n this.component.clearOnHide = false;\n // Ensure the root is set to this component.\n this.root = this;\n this.localRoot = this;\n this.root.dragulaLib = dragula_1.default;\n }\n /* eslint-enable max-statements */\n get language() {\n return this.options.language;\n }\n get emptyValue() {\n return null;\n }\n componentContext() {\n return this._data;\n }\n /**\n * Sets the language for this form.\n * @param {string} lang - The language to use (e.g. 'en', 'sp', etc.)\n */\n set language(lang) {\n if (!this.i18next) {\n return;\n }\n this.options.language = lang;\n if (this.i18next.language === lang) {\n return;\n }\n this.i18next.changeLanguage(lang, (err) => {\n if (err) {\n return;\n }\n this.rebuild();\n this.emit(\"languageChanged\");\n });\n }\n get componentComponents() {\n return this.form.components;\n }\n get shadowRoot() {\n return this.options.shadowRoot;\n }\n /**\n * Add a language for translations\n * @param {string} code - The language code for the language being added.\n * @param {object} lang - The language translations.\n * @param {boolean} [active] - If this language should be set as the active language.\n */\n addLanguage(code, lang, active = false) {\n if (this.i18next) {\n var translations = lodash_1.default.assign((0, utils_1.fastCloneDeep)(i18n_1.default.resources.en.translation), lang);\n this.i18next.addResourceBundle(code, \"translation\", translations, true, true);\n if (active) {\n this.language = code;\n }\n }\n }\n keyboardCatchableElement(element) {\n if (element.nodeName === \"TEXTAREA\") {\n return false;\n }\n if (element.nodeName === \"INPUT\") {\n return [\"text\", \"email\", \"password\"].indexOf(element.type) === -1;\n }\n return true;\n }\n addShortcut(element, shortcut) {\n if (!shortcut || !/^([A-Z]|Enter|Esc)$/i.test(shortcut)) {\n return;\n }\n shortcut = lodash_1.default.capitalize(shortcut);\n if (shortcut === \"Enter\" || shortcut === \"Esc\") {\n // Restrict Enter and Esc only for buttons\n if (element.tagName !== \"BUTTON\") {\n return;\n }\n this.shortcuts.push({\n shortcut,\n element,\n });\n }\n else {\n this.shortcuts.push({\n ctrl: true,\n shortcut,\n element,\n });\n }\n }\n removeShortcut(element, shortcut) {\n if (!shortcut || !/^([A-Z]|Enter|Esc)$/i.test(shortcut)) {\n return;\n }\n lodash_1.default.remove(this.shortcuts, {\n shortcut,\n element,\n });\n }\n /**\n * Get the embed source of the form.\n * @returns {string} - The source of the form.\n */\n get src() {\n return this._src;\n }\n /**\n * Loads the submission if applicable.\n * @returns {Promise} - The promise that is triggered when the submission is loaded.\n */\n loadSubmission() {\n this.loadingSubmission = true;\n if (this.formio.submissionId) {\n this.onSubmission = this.formio\n .loadSubmission()\n .then((submission) => this.setSubmission(submission), (err) => this.submissionReadyReject(err))\n .catch((err) => this.submissionReadyReject(err));\n }\n else {\n this.submissionReadyResolve();\n }\n return this.submissionReady;\n }\n /**\n * Set the src of the form renderer.\n * @param {string} value - The source value to set.\n * @param {any} options - The options to set.\n * @returns {Promise} - The promise that is triggered when the form is set.\n */\n setSrc(value, options) {\n if (this.setUrl(value, options)) {\n this.nosubmit = false;\n return this.formio\n .loadForm({ params: { live: 1 } })\n .then((form) => {\n const setForm = this.setForm(form);\n this.loadSubmission();\n return setForm;\n })\n .catch((err) => {\n console.warn(err);\n this.formReadyReject(err);\n });\n }\n return Promise.resolve();\n }\n /**\n * Set the Form source, which is typically the Form.io embed URL.\n * @param {string} value - The value of the form embed url.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.formReady.then(() => {\n * console.log('The form is formReady!');\n * });\n * form.src = 'https://examples.form.io/example';\n */\n set src(value) {\n this.setSrc(value);\n }\n /**\n * Get the embed source of the form.\n * @returns {string} - returns the source of the form.\n */\n get url() {\n return this._src;\n }\n /**\n * Sets the url of the form renderer.\n * @param {string} value - The value to set the url to.\n * @param {any} options - The options to set.\n * @returns {boolean} - TRUE means the url was set, FALSE otherwise.\n */\n setUrl(value, options) {\n if (!value || typeof value !== \"string\" || value === this._src) {\n return false;\n }\n this._src = value;\n this.nosubmit = true;\n this.formio = this.options.formio = new Formio_1.Formio(value, options);\n if (this.type === \"form\") {\n // Set the options source so this can be passed to other components.\n this.options.src = value;\n }\n return true;\n }\n /**\n * Set the form source but don't initialize the form and submission from the url.\n * @param {string} value - The value of the form embed url.\n */\n set url(value) {\n this.setUrl(value);\n }\n /**\n * Called when both the form and submission have been loaded.\n * @returns {Promise} - The promise to trigger when both form and submission have loaded.\n */\n get ready() {\n return this.formReady.then(() => {\n return super.ready.then(() => {\n return this.loadingSubmission ? this.submissionReady : true;\n });\n });\n }\n /**\n * Returns if this form is loading.\n * @returns {boolean} - TRUE means the form is loading, FALSE otherwise.\n */\n get loading() {\n return this._loading;\n }\n /**\n * Set the loading state for this form, and also show the loader spinner.\n * @param {boolean} loading - If this form should be \"loading\" or not.\n */\n set loading(loading) {\n if (this._loading !== loading) {\n this._loading = loading;\n if (!this.loader && loading) {\n this.loader = this.ce(\"div\", {\n class: \"loader-wrapper\",\n });\n const spinner = this.ce(\"div\", {\n class: \"loader text-center\",\n });\n this.loader.appendChild(spinner);\n }\n /* eslint-disable max-depth */\n if (this.loader) {\n try {\n if (loading) {\n this.prependTo(this.loader, this.wrapper);\n }\n else {\n this.removeChildFrom(this.loader, this.wrapper);\n }\n }\n catch (err) {\n // ingore\n }\n }\n /* eslint-enable max-depth */\n }\n }\n /**\n * Sets the JSON schema for the form to be rendered.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.setForm({\n * components: [\n * {\n * type: 'textfield',\n * key: 'firstName',\n * label: 'First Name',\n * placeholder: 'Enter your first name.',\n * input: true\n * },\n * {\n * type: 'textfield',\n * key: 'lastName',\n * label: 'Last Name',\n * placeholder: 'Enter your last name',\n * input: true\n * },\n * {\n * type: 'button',\n * action: 'submit',\n * label: 'Submit',\n * theme: 'primary'\n * }\n * ]\n * });\n * @param {object} form - The JSON schema of the form @see https://examples.form.io/example for an example JSON schema.\n * @param {any} flags - Any flags to apply when setting the form.\n * @returns {Promise} - The promise that is triggered when the form is set.\n */\n setForm(form, flags = {}) {\n var _a, _b, _c;\n const isFormAlreadySet = this._form && ((_a = this._form.components) === null || _a === void 0 ? void 0 : _a.length);\n try {\n // Do not set the form again if it has been already set\n if (isFormAlreadySet && JSON.stringify(this._form) === JSON.stringify(form)) {\n return Promise.resolve();\n }\n // Create the form.\n this._form = (flags === null || flags === void 0 ? void 0 : flags.keepAsReference) ? form : lodash_1.default.cloneDeep(form);\n if (this.onSetForm) {\n this.onSetForm(lodash_1.default.cloneDeep(this._form), form);\n }\n if ((_c = (_b = this.parent) === null || _b === void 0 ? void 0 : _b.component) === null || _c === void 0 ? void 0 : _c.modalEdit) {\n return Promise.resolve();\n }\n }\n catch (err) {\n console.warn(err);\n // If provided form is not a valid JSON object, do not set it too\n return Promise.resolve();\n }\n // Allow the form to provide component overrides.\n if (form && form.settings && form.settings.components) {\n this.options.components = form.settings.components;\n }\n if (form && form.properties) {\n this.options.properties = form.properties;\n }\n // Use the sanitize config from the form settings or the global sanitize config if it is not provided in the options\n if (!this.options.sanitizeConfig && !this.builderMode) {\n this.options.sanitizeConfig =\n lodash_1.default.get(form, \"settings.sanitizeConfig\") ||\n lodash_1.default.get(form, \"globalSettings.sanitizeConfig\");\n }\n if (\"schema\" in form && (0, compare_versions_1.compareVersions)(form.schema, \"1.x\") > 0) {\n this.ready.then(() => {\n this.setAlert(\"alert alert-danger\", \"Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.\");\n });\n }\n // See if they pass a module, and evaluate it if so.\n if (form && form.module) {\n let formModule = null;\n if (typeof form.module === \"string\") {\n try {\n formModule = this.evaluate(`return ${form.module}`);\n }\n catch (err) {\n console.warn(err);\n }\n }\n else {\n formModule = form.module;\n }\n if (formModule) {\n Formio_1.Formio.use(formModule);\n // Since we got here after instantiation, we need to manually apply form options.\n if (formModule.options && formModule.options.form) {\n this.options = Object.assign(this.options, formModule.options.form);\n }\n }\n }\n this.initialized = false;\n const rebuild = this.rebuild() || Promise.resolve();\n return rebuild.then(() => {\n this.emit(\"formLoad\", form);\n this.triggerCaptcha();\n // Make sure to trigger onChange after a render event occurs to speed up form rendering.\n setTimeout(() => {\n this.onChange(flags);\n this.formReadyResolve();\n }, 0);\n return this.formReady;\n });\n }\n /**\n * Gets the form object.\n * @returns {object} - The form JSON schema.\n */\n get form() {\n if (!this._form) {\n this._form = {\n components: [],\n };\n }\n return this._form;\n }\n /**\n * Sets the form value.\n * @alias setForm\n * @param {object} form - The form schema object.\n */\n set form(form) {\n this.setForm(form);\n }\n /**\n * Returns the submission object that was set within this form.\n * @returns {object} - The submission object.\n */\n get submission() {\n return this.getValue();\n }\n /**\n * Sets the submission of a form.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.src = 'https://examples.form.io/example';\n * form.submission = {data: {\n * firstName: 'Joe',\n * lastName: 'Smith',\n * email: 'joe@example.com'\n * }};\n * @param {object} submission - The Form.io submission object.\n */\n set submission(submission) {\n this.setSubmission(submission);\n }\n /**\n * Sets a submission and returns the promise when it is ready.\n * @param {any} submission - The submission to set.\n * @param {any} flags - Any flags to apply when setting the submission.\n * @returns {Promise} - The promise that is triggered when the submission is set.\n */\n setSubmission(submission, flags = {}) {\n flags = Object.assign(Object.assign({}, flags), { fromSubmission: lodash_1.default.has(flags, \"fromSubmission\") ? flags.fromSubmission : true });\n return (this.onSubmission = this.formReady\n .then((resolveFlags) => {\n if (resolveFlags) {\n flags = Object.assign(Object.assign({}, flags), resolveFlags);\n }\n this.submissionSet = true;\n this.triggerChange(flags);\n this.emit(\"beforeSetSubmission\", submission);\n this.setValue(submission, flags);\n return this.submissionReadyResolve(submission);\n }, (err) => this.submissionReadyReject(err))\n .catch((err) => this.submissionReadyReject(err)));\n }\n handleDraftError(errName, errDetails, restoreDraft) {\n const errorMessage = lodash_1.default.trim(`${this.t(errName)} ${errDetails || \"\"}`);\n console.warn(errorMessage);\n this.emit(restoreDraft ? \"restoreDraftError\" : \"saveDraftError\", errDetails || errorMessage);\n }\n saveDraft() {\n if (!this.draftEnabled) {\n return;\n }\n if (!this.formio) {\n this.handleDraftError(\"saveDraftInstanceError\");\n return;\n }\n if (!Formio_1.Formio.getUser()) {\n this.handleDraftError(\"saveDraftAuthError\");\n return;\n }\n const draft = (0, utils_1.fastCloneDeep)(this.submission);\n draft.state = \"draft\";\n if (!this.savingDraft && !this.submitting) {\n this.emit(\"saveDraftBegin\");\n this.savingDraft = true;\n this.formio\n .saveSubmission(draft)\n .then((sub) => {\n // Set id to submission to avoid creating new draft submission\n this.submission._id = sub._id;\n this.savingDraft = false;\n this.emit(\"saveDraft\", sub);\n })\n .catch((err) => {\n this.savingDraft = false;\n this.handleDraftError(\"saveDraftError\", err);\n });\n }\n }\n /**\n * Restores a draft submission based on the user who is authenticated.\n * @param {string} userId - The user id where we need to restore the draft from.\n */\n restoreDraft(userId) {\n const formio = this.formio || this.options.formio;\n if (!formio) {\n this.handleDraftError(\"restoreDraftInstanceError\", null, true);\n return;\n }\n this.savingDraft = true;\n formio\n .loadSubmissions({\n params: {\n state: 'draft',\n owner: userId,\n sort: '-created'\n },\n })\n .then((submissions) => {\n if (submissions.length > 0 && !this.options.skipDraftRestore) {\n const draft = (0, utils_1.fastCloneDeep)(submissions[0]);\n return this.setSubmission(draft).then(() => {\n this.draftEnabled = true;\n this.savingDraft = false;\n this.emit(\"restoreDraft\", draft);\n });\n }\n // Enable drafts so that we can keep track of changes.\n this.draftEnabled = true;\n this.savingDraft = false;\n this.emit(\"restoreDraft\", null);\n })\n .catch((err) => {\n this.draftEnabled = true;\n this.savingDraft = false;\n this.handleDraftError(\"restoreDraftError\", err, true);\n });\n }\n get schema() {\n const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, [\"components\"]));\n schema.components = [];\n this.eachComponent((component) => schema.components.push(component.schema));\n return schema;\n }\n mergeData(_this, _that) {\n lodash_1.default.mergeWith(_this, _that, (thisValue, thatValue) => {\n if (Array.isArray(thisValue) &&\n Array.isArray(thatValue) &&\n thisValue.length !== thatValue.length) {\n return thatValue;\n }\n });\n }\n setValue(submission, flags = {}) {\n if (!submission || !submission.data) {\n submission = {\n data: {},\n metadata: submission.metadata,\n };\n }\n // Metadata needs to be available before setValue\n this._submission.metadata = submission.metadata ? lodash_1.default.cloneDeep(submission.metadata) : {};\n this.editing = !!submission._id;\n // Set the timezone in the options if available.\n if (!this.options.submissionTimezone &&\n submission.metadata &&\n submission.metadata.timezone) {\n this.options.submissionTimezone = submission.metadata.timezone;\n }\n const changed = super.setValue(submission.data, flags);\n if (!flags.sanitize) {\n this.mergeData(this.data, submission.data);\n }\n submission.data = this.data;\n this._submission = submission;\n return changed;\n }\n getValue() {\n if (!this._submission.data) {\n this._submission.data = {};\n }\n if (this.viewOnly) {\n return this._submission;\n }\n const submission = this._submission;\n submission.data = this.data;\n return this._submission;\n }\n /**\n * Build the form.\n * @returns {Promise} - The promise that is triggered when the form is built.\n */\n init() {\n if (this.options.submission) {\n const submission = lodash_1.default.extend({}, this.options.submission);\n this._submission = submission;\n this._data = submission.data;\n }\n else {\n this._submission = this._submission || { data: {} };\n }\n // Remove any existing components.\n if (this.components && this.components.length) {\n this.destroyComponents();\n this.components = [];\n }\n if (this.component) {\n this.component.components = this.form ? this.form.components : [];\n }\n else {\n this.component = this.form;\n }\n this.component.type = \"form\";\n this.component.input = false;\n this.addComponents();\n this.on(\"submitButton\", (options) => {\n this.submit(false, options).catch((e) => {\n options.instance.loading = false;\n return e !== false && e !== undefined && console.log(e);\n });\n }, true);\n this.on(\"checkValidity\", (data) => this.validate(data, { dirty: true, process: \"change\" }), true);\n this.on(\"requestUrl\", (args) => this.submitUrl(args.url, args.headers), true);\n this.on(\"resetForm\", () => this.resetValue(), true);\n this.on(\"deleteSubmission\", () => this.deleteSubmission(), true);\n this.on(\"refreshData\", () => this.updateValue(), true);\n this.executeFormController();\n return this.formReady;\n }\n executeFormController() {\n // If no controller value or\n // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)\n if (!this.form ||\n !this.form.controller ||\n ((!this.visible || this.component.hidden) &&\n this.component.clearOnHide &&\n !this.rootPristine)) {\n return false;\n }\n this.formReady.then(() => {\n this.evaluate(this.form.controller, {\n components: this.components,\n instance: this,\n });\n });\n }\n /**\n *\n */\n teardown() {\n this.emit(\"formDelete\", this.id);\n delete Formio_1.Formio.forms[this.id];\n delete this.executeShortcuts;\n delete this.triggerSaveDraft;\n super.teardown();\n }\n destroy(all = false) {\n this.off(\"submitButton\");\n this.off(\"checkValidity\");\n this.off(\"requestUrl\");\n this.off(\"resetForm\");\n this.off(\"deleteSubmission\");\n this.off(\"refreshData\");\n return super.destroy(all);\n }\n build(element) {\n if (element || this.element) {\n return this.ready.then(() => {\n element = element || this.element;\n super.build(element);\n });\n }\n return this.ready;\n }\n getClassName() {\n let classes = \"formio-form\";\n if (this.options.readOnly) {\n classes += \" formio-read-only\";\n }\n return classes;\n }\n render() {\n return super.render(this.renderTemplate(\"webform\", {\n classes: this.getClassName(),\n children: this.renderComponents(),\n }), this.builderMode ? \"builder\" : \"form\", true);\n }\n redraw() {\n // Don't bother if we have not built yet.\n if (!this.element) {\n return Promise.resolve();\n }\n this.clear();\n this.setContent(this.element, this.render());\n return this.attach(this.element);\n }\n attach(element) {\n this.setElement(element);\n this.loadRefs(element, { webform: \"single\" });\n const childPromise = this.attachComponents(this.refs.webform);\n this.addEventListener(document, \"keydown\", this.executeShortcuts);\n this.currentForm = this;\n this.hook(\"attachWebform\", element, this);\n return childPromise.then(() => {\n this.emit(\"render\", this.element);\n return this.setValue(this._submission, {\n noUpdateEvent: true,\n });\n });\n }\n hasRequiredFields() {\n let result = false;\n (0, formUtils_1.eachComponent)(this.form.components, (component) => {\n if (component.validate.required) {\n result = true;\n return true;\n }\n }, true);\n return result;\n }\n resetValue() {\n lodash_1.default.each(this.getComponents(), (comp) => comp.resetValue());\n this.setPristine(true);\n this.onChange({ resetValue: true });\n }\n /**\n * Sets a new alert to display in the error dialog of the form.\n * @param {string} type - The type of alert to display. \"danger\", \"success\", \"warning\", etc.\n * @param {string} message - The message to show in the alert.\n * @param {object} options - The options for the alert.\n */\n setAlert(type, message, options) {\n if (!type && this.submitted) {\n if (this.alert) {\n if (this.refs.errorRef && this.refs.errorRef.length) {\n this.refs.errorRef.forEach((el) => {\n this.removeEventListener(el, \"click\");\n this.removeEventListener(el, \"keypress\");\n });\n }\n this.removeChild(this.alert);\n this.alert = null;\n }\n return;\n }\n if (this.options.noAlerts) {\n if (!message) {\n this.emit(\"error\", false);\n }\n return;\n }\n if (this.alert) {\n try {\n if (this.refs.errorRef && this.refs.errorRef.length) {\n this.refs.errorRef.forEach((el) => {\n this.removeEventListener(el, \"click\");\n this.removeEventListener(el, \"keypress\");\n });\n }\n this.removeChild(this.alert);\n this.alert = null;\n }\n catch (err) {\n // ignore\n }\n }\n if (message) {\n const attrs = {\n class: (options && options.classes) || `alert alert-${type}`,\n id: `error-list-${this.id}`,\n };\n const templateOptions = {\n message: message instanceof HTMLElement ? message.outerHTML : message,\n attrs: attrs,\n type,\n };\n this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate(\"alert\", templateOptions), `#${attrs.id}`);\n }\n if (!this.alert) {\n return;\n }\n this.loadRefs(this.alert, { errorRef: \"multiple\" });\n if (this.refs.errorRef && this.refs.errorRef.length) {\n this.refs.errorRef.forEach((el) => {\n this.addEventListener(el, \"click\", (e) => {\n const key = e.currentTarget.dataset.componentKey;\n this.focusOnComponent(key);\n });\n this.addEventListener(el, \"keydown\", (e) => {\n if (e.keyCode === 13) {\n e.preventDefault();\n const key = e.currentTarget.dataset.componentKey;\n this.focusOnComponent(key);\n }\n });\n });\n }\n this.prepend(this.alert);\n }\n /**\n * Focus on selected component.\n * @param {string} key - The key of selected component.\n */\n focusOnComponent(key) {\n if (key) {\n const component = this.getComponent(key);\n if (component) {\n component.focus();\n }\n }\n }\n /**\n * Show the errors of this form within the alert dialog.\n * @param {object} error - An optional additional error to display along with the component errors.\n * @returns {*}\n */\n /* eslint-disable no-unused-vars */\n /**\n *\n * @param {Array} errors - An array of errors to display.\n * @param {boolean} triggerEvent - Whether or not to trigger the error event.\n * @returns {void|Array} - The errors that were set.\n */\n showErrors(errors, triggerEvent) {\n this.loading = false;\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n errors = errors.concat(this.customErrors).filter((err) => !!err);\n if (!errors.length) {\n this.setAlert(false);\n return;\n }\n // Mark any components as invalid if in a custom message.\n errors.forEach((err) => {\n const { components = [] } = err;\n if (err.component) {\n components.push(err.component);\n }\n if (err.path) {\n components.push(err.path);\n }\n components.forEach((path) => {\n const originalPath = (0, utils_1.getStringFromComponentPath)(path);\n const component = this.getComponent(path, lodash_1.default.identity, originalPath);\n if (err.fromServer) {\n if (component.serverErrors) {\n component.serverErrors.push(err);\n }\n else {\n component.serverErrors = [err];\n }\n }\n const components = lodash_1.default.compact(Array.isArray(component) ? component : [component]);\n components.forEach((component) => component.setCustomValidity(err.message, true));\n });\n });\n const displayedErrors = [];\n if (errors.length) {\n errors = lodash_1.default.uniqBy(errors, (error) => error.message);\n const createListItem = (message, index) => {\n var _a, _b, _c;\n const err = errors[index];\n const messageFromIndex = !lodash_1.default.isUndefined(index) && errors && errors[index];\n const keyOrPath = (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.formattedKeyOrPath) ||\n (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.path) ||\n ((_a = messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.context) === null || _a === void 0 ? void 0 : _a.path) ||\n (((_b = err.context) === null || _b === void 0 ? void 0 : _b.component) && ((_c = err.context) === null || _c === void 0 ? void 0 : _c.component.key)) ||\n (err.component && err.component.key) ||\n (err.fromServer && err.path);\n const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : \"\";\n if (typeof err !== \"string\" && !err.formattedKeyOrPath) {\n err.formattedKeyOrPath = formattedKeyOrPath;\n }\n return {\n message: (0, utils_1.unescapeHTML)(message),\n keyOrPath: formattedKeyOrPath,\n };\n };\n errors.forEach(({ message, context, fromServer, component }, index) => {\n const text = !(component === null || component === void 0 ? void 0 : component.label) || (context === null || context === void 0 ? void 0 : context.hasLabel) || fromServer\n ? this.t(\"alertMessage\", { message: this.t(message) })\n : this.t(\"alertMessageWithLabel\", {\n label: this.t(component === null || component === void 0 ? void 0 : component.label),\n message: this.t(message),\n });\n displayedErrors.push(createListItem(text, index));\n });\n }\n const errorsList = this.renderTemplate(\"errorsList\", { errors: displayedErrors });\n this.root.setAlert(\"danger\", errorsList);\n if (triggerEvent) {\n this.emit(\"error\", errors);\n }\n return errors;\n }\n /* eslint-enable no-unused-vars */\n /**\n * Called when the submission has completed, or if the submission needs to be sent to an external library.\n * @param {object} submission - The submission object.\n * @param {boolean} saved - Whether or not this submission was saved to the server.\n * @returns {object} - The submission object.\n */\n onSubmit(submission, saved) {\n var _a;\n this.loading = false;\n this.submitting = false;\n this.setPristine(true);\n // We want to return the submitted submission and setValue will mutate the submission so cloneDeep it here.\n this.setValue((0, utils_1.fastCloneDeep)(submission), {\n noValidate: true,\n noCheck: true,\n });\n this.setAlert(\"success\", `<p>${this.t(\"complete\")}</p>`);\n // Cancel triggered saveDraft to prevent overriding the submitted state\n if (this.draftEnabled && ((_a = this.triggerSaveDraft) === null || _a === void 0 ? void 0 : _a.cancel)) {\n this.triggerSaveDraft.cancel();\n }\n this.emit(\"submit\", submission, saved);\n if (saved) {\n this.emit(\"submitDone\", submission);\n }\n return submission;\n }\n normalizeError(error) {\n if (error) {\n if (typeof error === \"object\" && \"details\" in error) {\n error = error.details;\n }\n if (typeof error === \"string\") {\n error = { message: error };\n }\n }\n return error;\n }\n /**\n * Called when an error occurs during the submission.\n * @param {object} error - The error that occured.\n * @returns {Array} errors - All errors.\n */\n onSubmissionError(error) {\n error = this.normalizeError(error);\n this.submitting = false;\n this.setPristine(false);\n this.emit(\"submitError\", error || this.errors);\n // Allow for silent cancellations (no error message, no submit button error state)\n if (error && error.silent) {\n this.emit(\"change\", { isValid: true }, { silent: true });\n return false;\n }\n const errors = this.showErrors(error, true);\n if (this.root && this.root.alert) {\n this.scrollIntoView(this.root.alert);\n }\n return errors;\n }\n /**\n * Trigger the change event for this form.\n * @param {any} flags - The flags to set on this change event.\n * @param {any} changed - The changed object which reflects the changes in the form.\n * @param {boolean} modified - Whether or not the form has been modified.\n * @param {any} changes - The changes that have occured in the form.\n */\n onChange(flags, changed, modified, changes) {\n flags = flags || {};\n let isChangeEventEmitted = false;\n super.onChange(flags, true);\n const value = lodash_1.default.clone(this.submission);\n flags.changed = value.changed = changed;\n flags.changes = changes;\n if (modified && this.pristine) {\n this.pristine = false;\n }\n this.checkData(value.data, flags);\n const shouldValidate = !flags.noValidate ||\n flags.fromIFrame ||\n (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);\n const errors = shouldValidate\n ? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: \"change\" }))\n : [];\n value.isValid = errors.length === 0;\n this.loading = false;\n if (this.submitted) {\n // show server errors while they are not cleaned/fixed\n const nonComponentServerErrors = lodash_1.default.filter(this.serverErrors || [], (err) => !err.component && !err.path);\n this.showErrors(nonComponentServerErrors.length ? nonComponentServerErrors : errors);\n }\n // See if we need to save the draft of the form.\n if (modified && this.options.saveDraft) {\n this.triggerSaveDraft();\n }\n if (!flags || !flags.noEmit) {\n this.emit(\"change\", value, flags, modified);\n isChangeEventEmitted = true;\n }\n // The form is initialized after the first change event occurs.\n if (isChangeEventEmitted && !this.initialized) {\n this.emit(\"initialized\");\n this.initialized = true;\n }\n }\n /**\n * Send a delete request to the server.\n * @returns {Promise} - The promise that is triggered when the delete is complete.\n */\n deleteSubmission() {\n return this.formio.deleteSubmission().then(() => {\n this.emit(\"submissionDeleted\", this.submission);\n this.resetValue();\n });\n }\n /**\n * Cancels the submission.\n * @param {boolean} noconfirm - Whether or not to confirm the cancellation.\n * @alias reset\n * @returns {boolean} - TRUE means the submission was cancelled, FALSE otherwise.\n */\n cancel(noconfirm) {\n const shouldReset = this.hook(\"beforeCancel\", true);\n if (shouldReset && (noconfirm || confirm(this.t(\"confirmCancel\")))) {\n this.resetValue();\n return true;\n }\n else {\n this.emit(\"cancelSubmit\");\n return false;\n }\n }\n setMetadata(submission) {\n // Add in metadata about client submitting the form\n submission.metadata = submission.metadata || {};\n lodash_1.default.defaults(submission.metadata, {\n timezone: lodash_1.default.get(this, \"_submission.metadata.timezone\", (0, utils_1.currentTimezone)()),\n offset: parseInt(lodash_1.default.get(this, \"_submission.metadata.offset\", (0, moment_1.default)().utcOffset()), 10),\n origin: document.location.origin,\n referrer: document.referrer,\n browserName: navigator.appName,\n userAgent: navigator.userAgent,\n pathName: window.location.pathname,\n onLine: navigator.onLine,\n });\n }\n submitForm(options = {}) {\n this.clearServerErrors();\n return new Promise((resolve, reject) => {\n // Read-only forms should never submit.\n if (this.options.readOnly) {\n return resolve({\n submission: this.submission,\n saved: false,\n });\n }\n const submission = (0, utils_1.fastCloneDeep)(this.submission || {});\n this.setMetadata(submission);\n submission.state = options.state || submission.state || \"submitted\";\n const isDraft = submission.state === \"draft\";\n this.hook(\"beforeSubmit\", Object.assign(Object.assign({}, submission), { component: options.component }), (err, data) => {\n var _a;\n if (err) {\n return reject(err);\n }\n submission._vnote = data && data._vnote ? data._vnote : \"\";\n try {\n if (!isDraft && !options.noValidate) {\n if (!submission.data) {\n return reject(\"Invalid Submission\");\n }\n const errors = this.validate(submission.data, {\n dirty: true,\n silentCheck: false,\n process: \"submit\",\n });\n if (errors.length ||\n ((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === \"rejected\"))) {\n return reject(errors);\n }\n }\n }\n catch (err) {\n console.error(err);\n }\n this.everyComponent((comp) => {\n if (submission._vnote && comp.type === \"form\" && comp.component.reference) {\n lodash_1.default.get(submission.data, comp.path, {})._vnote = submission._vnote;\n }\n const { persistent } = comp.component;\n if (persistent === \"client-only\") {\n lodash_1.default.unset(submission.data, comp.path);\n }\n });\n this.hook(\"customValidation\", Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {\n if (err) {\n // If string is returned, cast to object.\n if (typeof err === \"string\") {\n err = {\n message: err,\n };\n }\n // Ensure err is an array.\n err = Array.isArray(err) ? err : [err];\n return reject(err);\n }\n this.loading = true;\n // Use the form action to submit the form if available.\n if (this._form && this._form.action) {\n const method = submission.data._id &&\n this._form.action.includes(submission.data._id)\n ? \"PUT\"\n : \"POST\";\n return Formio_1.Formio.makeStaticRequest(this._form.action, method, submission, this.formio ? this.formio.options : {})\n .then((result) => resolve({\n submission: result,\n saved: true,\n }))\n .catch((error) => {\n this.setServerErrors(error);\n return reject(error);\n });\n }\n const submitFormio = this.formio;\n if (this.nosubmit || !submitFormio) {\n return resolve({\n submission,\n saved: false,\n });\n }\n // If this is an actionUrl, then make sure to save the action and not the submission.\n const submitMethod = submitFormio.actionUrl\n ? \"saveAction\"\n : \"saveSubmission\";\n submitFormio[submitMethod](submission)\n .then((result) => resolve({\n submission: result,\n saved: true,\n }))\n .catch((error) => {\n this.setServerErrors(error);\n return reject(error);\n });\n });\n });\n });\n }\n setServerErrors(error) {\n if (error.details) {\n this.serverErrors = error.details\n .filter((err) => (err.level ? err.level === \"error\" : err))\n .map((err) => {\n err.fromServer = true;\n return err;\n });\n }\n else if (typeof error === \"string\") {\n this.serverErrors = [{ fromServer: true, level: \"error\", message: error }];\n }\n }\n executeSubmit(options) {\n this.submitted = true;\n this.submitting = true;\n return this.submitForm(options)\n .then(({ submission, saved }) => this.onSubmit(submission, saved))\n .then((results) => {\n this.submissionInProcess = false;\n return results;\n })\n .catch((err) => {\n this.submissionInProcess = false;\n return Promise.reject(this.onSubmissionError(err));\n });\n }\n clearServerErrors() {\n var _a;\n (_a = this.serverErrors) === null || _a === void 0 ? void 0 : _a.forEach((error) => {\n if (error.path) {\n const pathArray = (0, utils_1.getArrayFromComponentPath)(error.path);\n const component = this.getComponent(pathArray, lodash_1.default.identity, error.formattedKeyOrPath);\n if (component) {\n component.serverErrors = [];\n }\n }\n });\n this.serverErrors = [];\n }\n /**\n * Submits the form.\n * @example\n * import Webform from '@formio/js/Webform';\n * let form = new Webform(document.getElementById('formio'));\n * form.src = 'https://examples.form.io/example';\n * form.submission = {data: {\n * firstName: 'Joe',\n * lastName: 'Smith',\n * email: 'joe@example.com'\n * }};\n * form.submit().then((submission) => {\n * console.log(submission);\n * });\n * @param {boolean} before - If this submission occured from the before handlers.\n * @param {any} options - The options to use when submitting this form.\n * @returns {Promise} - A promise when the form is done submitting.\n */\n submit(before = false, options = {}) {\n this.submissionInProcess = true;\n if (!before) {\n return this.beforeSubmit(options).then(() => this.executeSubmit(options));\n }\n else {\n return this.executeSubmit(options);\n }\n }\n submitUrl(URL, headers) {\n if (!URL) {\n return console.warn(\"Missing URL argument\");\n }\n const submission = this.submission || {};\n const API_URL = URL;\n const settings = {\n method: \"POST\",\n headers: {},\n };\n if (headers && headers.length > 0) {\n headers.map((e) => {\n if (e.header !== \"\" && e.value !== \"\") {\n settings.headers[e.header] = this.interpolate(e.value, submission);\n }\n });\n }\n if (API_URL && settings) {\n Formio_1.Formio.makeStaticRequest(API_URL, settings.method, submission, {\n headers: settings.headers,\n })\n .then(() => {\n this.emit(\"requestDone\");\n this.setAlert(\"success\", \"<p> Success </p>\");\n })\n .catch((e) => {\n const message = `${e.statusText ? e.statusText : \"\"} ${e.status ? e.status : e}`;\n this.emit(\"error\", message);\n console.error(message);\n this.setAlert(\"danger\", `<p> ${message} </p>`);\n return Promise.reject(this.onSubmissionError(e));\n });\n }\n else {\n this.emit(\"error\", \"You should add a URL to this button.\");\n this.setAlert(\"warning\", \"You should add a URL to this button.\");\n return console.warn(\"You should add a URL to this button.\");\n }\n }\n triggerCaptcha() {\n if (!this || !this.components) {\n return;\n }\n const captchaComponent = [];\n (0, formUtils_1.eachComponent)(this.components, (component) => {\n if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {\n captchaComponent.push(component);\n }\n });\n if (captchaComponent.length > 0) {\n captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);\n }\n }\n set nosubmit(value) {\n this._nosubmit = !!value;\n this.emit(\"nosubmit\", this._nosubmit);\n }\n get nosubmit() {\n return this._nosubmit || false;\n }\n get conditions() {\n var _a, _b;\n return (_b = (_a = this.schema.settings) === null || _a === void 0 ? void 0 : _a.conditions) !== null && _b !== void 0 ? _b : [];\n }\n get variables() {\n var _a, _b;\n return (_b = (_a = this.schema.settings) === null || _a === void 0 ? void 0 : _a.variables) !== null && _b !== void 0 ? _b : [];\n }\n}\nexports[\"default\"] = Webform;\nWebform.setBaseUrl = Formio_1.Formio.setBaseUrl;\nWebform.setApiUrl = Formio_1.Formio.setApiUrl;\nWebform.setAppUrl = Formio_1.Formio.setAppUrl;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Webform.js?");
|
5432
5528
|
|
5433
5529
|
/***/ }),
|
5434
5530
|
|
@@ -5560,7 +5656,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5560
5656
|
/***/ (function(__unused_webpack_module, exports) {
|
5561
5657
|
|
5562
5658
|
"use strict";
|
5563
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/* eslint-disable max-len */\nexports[\"default\"] = [\n {\n weight: 0,\n type: 'textfield',\n input: true,\n key: 'label',\n label: 'Label',\n placeholder: 'Field Label',\n tooltip: 'The label for this field that will appear next to it.',\n validate: {\n required: true\n },\n autofocus: true,\n },\n {\n type: 'select',\n input: true,\n key: 'labelPosition',\n label: 'Label Position',\n tooltip: 'Position for the label for this field.',\n weight: 20,\n defaultValue: 'top',\n dataSrc: 'values',\n data: {\n values: [\n { label: 'Top', value: 'top' },\n { label: 'Left (Left-aligned)', value: 'left-left' },\n { label: 'Left (Right-aligned)', value: 'left-right' },\n { label: 'Right (Left-aligned)', value: 'right-left' },\n { label: 'Right (Right-aligned)', value: 'right-right' },\n { label: 'Bottom', value: 'bottom' }\n ]\n }\n },\n {\n type: 'number',\n input: true,\n key: 'labelWidth',\n label: 'Label Width',\n tooltip: 'The width of label on line in percentages.',\n clearOnHide: false,\n weight: 30,\n placeholder: '30',\n suffix: '%',\n validate: {\n min: 0,\n max: 100\n },\n conditional: {\n json: {\n and: [\n { '!==': [{ var: 'data.labelPosition' }, 'top'] },\n { '!==': [{ var: 'data.labelPosition' }, 'bottom'] },\n ]\n }\n }\n },\n {\n type: 'number',\n input: true,\n key: 'labelMargin',\n label: 'Label Margin',\n tooltip: 'The width of label margin on line in percentages.',\n clearOnHide: false,\n weight: 30,\n placeholder: '3',\n suffix: '%',\n validate: {\n min: 0,\n max: 100\n },\n conditional: {\n json: {\n and: [\n { '!==': [{ var: 'data.labelPosition' }, 'top'] },\n { '!==': [{ var: 'data.labelPosition' }, 'bottom'] },\n ]\n }\n }\n },\n {\n weight: 100,\n type: 'textfield',\n input: true,\n key: 'placeholder',\n label: 'Placeholder',\n placeholder: 'Placeholder',\n tooltip: 'The placeholder text that will appear when this field is empty.'\n },\n {\n weight: 200,\n type: 'textarea',\n input: true,\n key: 'description',\n label: 'Description',\n placeholder: 'Description for this field.',\n tooltip: 'The description is text that will appear below the input field.',\n editor: 'ace',\n as: 'html',\n wysiwyg: {\n minLines: 3,\n isUseWorkerDisabled: true,\n },\n },\n {\n weight: 300,\n type: 'textarea',\n input: true,\n key: 'tooltip',\n label: 'Tooltip',\n placeholder: 'To add a tooltip to this field, enter text here.',\n tooltip: 'Adds a tooltip to the side of this field.',\n editor: 'ace',\n as: 'html',\n wysiwyg: {\n minLines: 3,\n isUseWorkerDisabled: true,\n },\n },\n {\n weight: 500,\n type: 'textfield',\n input: true,\n key: 'customClass',\n label: 'Custom CSS Class',\n placeholder: 'Custom CSS Class',\n tooltip: 'Custom CSS class to add to this component.'\n },\n {\n weight: 600,\n type: 'textfield',\n input: true,\n key: 'tabindex',\n label: 'Tab Index',\n placeholder: '0',\n tooltip: 'Sets the tabindex attribute of this component to override the tab order of the form. See the <a href=\\'https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex\\'>MDN documentation</a> on tabindex for more information.'\n },\n {\n weight: 1100,\n type: 'checkbox',\n label: 'Hidden',\n tooltip: 'A hidden field is still a part of the form, but is hidden from view.',\n key: 'hidden',\n input: true\n },\n {\n weight: 1200,\n type: 'checkbox',\n label: 'Hide Label',\n tooltip: 'Hide the label (title, if no label) of this component. This allows you to show the label in the form builder, but not when it is rendered.',\n key: 'hideLabel',\n input: true\n },\n {\n weight: 1350,\n type: 'checkbox',\n label: 'Initial Focus',\n tooltip: 'Make this field the initially focused element on this form.',\n key: 'autofocus',\n input: true\n },\n {\n weight: 1370,\n type: 'checkbox',\n label: 'Show Label in DataGrid',\n tooltip: 'Show the label inside each row when in a Datagrid.',\n key: 'dataGridLabel',\n input: true,\n customConditional(context) {\n var _a, _b;\n return (_b = (_a = context.instance.options) === null || _a === void 0 ? void 0 : _a.flags) === null || _b === void 0 ? void 0 : _b.inDataGrid;\n }\n },\n {\n weight: 1400,\n type: 'checkbox',\n label: 'Disabled',\n tooltip: 'Disable the form input.',\n key: 'disabled',\n input: true\n },\n {\n weight: 1500,\n type: 'checkbox',\n label: 'Table View',\n tooltip: 'Shows this value within the table view of the submissions.',\n key: 'tableView',\n input: true\n },\n];\n/* eslint-enable max-len */\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/_classes/component/editForm/Component.edit.display.js?");
|
5659
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/* eslint-disable max-len */\nexports[\"default\"] = [\n {\n weight: 0,\n type: 'textfield',\n input: true,\n key: 'label',\n label: 'Label',\n placeholder: 'Field Label',\n tooltip: 'The label for this field that will appear next to it.',\n validate: {\n required: true\n },\n autofocus: true,\n },\n {\n type: 'select',\n input: true,\n key: 'labelPosition',\n label: 'Label Position',\n tooltip: 'Position for the label for this field.',\n weight: 20,\n defaultValue: 'top',\n dataSrc: 'values',\n data: {\n values: [\n { label: 'Top', value: 'top' },\n { label: 'Left (Left-aligned)', value: 'left-left' },\n { label: 'Left (Right-aligned)', value: 'left-right' },\n { label: 'Right (Left-aligned)', value: 'right-left' },\n { label: 'Right (Right-aligned)', value: 'right-right' },\n { label: 'Bottom', value: 'bottom' }\n ]\n }\n },\n {\n type: 'number',\n input: true,\n key: 'labelWidth',\n label: 'Label Width',\n tooltip: 'The width of label on line in percentages.',\n clearOnHide: false,\n weight: 30,\n placeholder: '30',\n suffix: '%',\n validate: {\n min: 0,\n max: 100\n },\n conditional: {\n json: {\n and: [\n { '!==': [{ var: 'data.labelPosition' }, 'top'] },\n { '!==': [{ var: 'data.labelPosition' }, 'bottom'] },\n ]\n }\n }\n },\n {\n type: 'number',\n input: true,\n key: 'labelMargin',\n label: 'Label Margin',\n tooltip: 'The width of label margin on line in percentages.',\n clearOnHide: false,\n weight: 30,\n placeholder: '3',\n suffix: '%',\n validate: {\n min: 0,\n max: 100\n },\n conditional: {\n json: {\n and: [\n { '!==': [{ var: 'data.labelPosition' }, 'top'] },\n { '!==': [{ var: 'data.labelPosition' }, 'bottom'] },\n ]\n }\n }\n },\n {\n weight: 100,\n type: 'textfield',\n input: true,\n key: 'placeholder',\n label: 'Placeholder',\n placeholder: 'Placeholder',\n tooltip: 'The placeholder text that will appear when this field is empty.'\n },\n {\n weight: 200,\n type: 'textarea',\n input: true,\n key: 'description',\n label: 'Description',\n placeholder: 'Description for this field.',\n tooltip: 'The description is text that will appear below the input field.',\n editor: 'ace',\n as: 'html',\n wysiwyg: {\n minLines: 3,\n isUseWorkerDisabled: true,\n },\n },\n {\n weight: 300,\n type: 'textarea',\n input: true,\n key: 'tooltip',\n label: 'Tooltip',\n placeholder: 'To add a tooltip to this field, enter text here.',\n tooltip: 'Adds a tooltip to the side of this field.',\n editor: 'ace',\n as: 'html',\n wysiwyg: {\n minLines: 3,\n isUseWorkerDisabled: true,\n },\n },\n {\n weight: 500,\n type: 'textfield',\n input: true,\n key: 'customClass',\n label: 'Custom CSS Class',\n placeholder: 'Custom CSS Class',\n tooltip: 'Custom CSS class to add to this component.'\n },\n {\n weight: 600,\n type: 'textfield',\n input: true,\n key: 'tabindex',\n label: 'Tab Index',\n placeholder: '0',\n tooltip: 'Sets the tabindex attribute of this component to override the tab order of the form. See the <a href=\\'https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex\\'>MDN documentation</a> on tabindex for more information.'\n },\n {\n weight: 1100,\n type: 'checkbox',\n label: 'Hidden',\n tooltip: 'A hidden field is still a part of the form, but is hidden from view.',\n key: 'hidden',\n input: true\n },\n {\n weight: 1200,\n type: 'checkbox',\n label: 'Hide Label',\n tooltip: 'Hide the label (title, if no label) of this component. This allows you to show the label in the form builder, but not when it is rendered.',\n key: 'hideLabel',\n input: true\n },\n {\n weight: 1350,\n type: 'checkbox',\n label: 'Initial Focus',\n tooltip: 'Make this field the initially focused element on this form.',\n key: 'autofocus',\n input: true\n },\n {\n weight: 1370,\n type: 'checkbox',\n label: 'Show Label in DataGrid',\n tooltip: 'Show the label inside each row when in a Datagrid.',\n key: 'dataGridLabel',\n input: true,\n customConditional(context) {\n var _a, _b;\n return (_b = (_a = context.instance.options) === null || _a === void 0 ? void 0 : _a.flags) === null || _b === void 0 ? void 0 : _b.inDataGrid;\n }\n },\n {\n weight: 1400,\n type: 'checkbox',\n label: 'Disabled',\n tooltip: 'Disable the form input.',\n key: 'disabled',\n input: true\n },\n {\n weight: 1500,\n type: 'checkbox',\n label: 'Table View',\n tooltip: 'Shows this value within the table view of the submissions.',\n key: 'tableView',\n input: true\n },\n {\n weight: 1600,\n type: 'checkbox',\n label: 'Modal Edit',\n tooltip: 'Opens up a modal to edit the value of this component.',\n key: 'modalEdit',\n input: true\n }\n];\n/* eslint-enable max-len */\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/_classes/component/editForm/Component.edit.display.js?");
|
5564
5660
|
|
5565
5661
|
/***/ }),
|
5566
5662
|
|
@@ -9483,7 +9579,7 @@ eval("\nvar parent = __webpack_require__(/*! ../../es/object/from-entries */ \".
|
|
9483
9579
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
9484
9580
|
|
9485
9581
|
"use strict";
|
9486
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a;\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FormBuilder = exports.Form = exports.Formio = void 0;\nconst CDN_js_1 = __importDefault(__webpack_require__(/*! ./CDN.js */ \"./lib/cjs/CDN.js\"));\nclass Formio {\n static setLicense(license, norecurse = false) {\n _a.license = license;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n _a.pathType = type;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (_a.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (_a.FormioClass) {\n _a.FormioClass.clearCache();\n }\n }\n static global(prop, flag = '') {\n const globalValue = window[prop];\n if (flag && globalValue && !globalValue[flag]) {\n return null;\n }\n _a.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (_a.FormioClass && _a.FormioClass.isRenderer) {\n _a.FormioClass.use(module);\n }\n else {\n _a.modules.push(module);\n }\n }\n static createElement(type, attrs, children) {\n const element = document.createElement(type);\n if (!attrs) {\n return element;\n }\n Object.keys(attrs).forEach(key => {\n element.setAttribute(key, attrs[key]);\n });\n (children || []).forEach(child => {\n element.appendChild(_a.createElement(child.tag, child.attrs, child.children));\n });\n return element;\n }\n static addScript(wrapper, src, name, flag = '') {\n return __awaiter(this, void 0, void 0, function* () {\n if (!src) {\n return Promise.resolve();\n }\n if (typeof src !== 'string' && src.length) {\n return Promise.all(src.map(ref => _a.addScript(wrapper, ref)));\n }\n if (name && _a.global(name, flag)) {\n _a.debug(`${name} already loaded.`);\n return Promise.resolve(_a.global(name));\n }\n _a.debug('Adding Script', src);\n try {\n wrapper.appendChild(_a.createElement('script', {\n src\n }));\n }\n catch (err) {\n _a.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n _a.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (_a.global(name, flag)) {\n clearInterval(wait);\n _a.debug(`${name} loaded.`);\n resolve(_a.global(name));\n }\n }, 100);\n });\n });\n }\n static addStyles(wrapper, href) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!href) {\n return;\n }\n if (typeof href !== 'string' && href.length) {\n href.forEach(ref => _a.addStyles(wrapper, ref));\n return;\n }\n _a.debug('Adding Styles', href);\n wrapper.appendChild(_a.createElement('link', {\n rel: 'stylesheet',\n href\n }));\n });\n }\n static submitDone(instance, submission) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.debug('Submision Complete', submission);\n if (_a.config.submitDone) {\n _a.config.submitDone(submission, instance);\n }\n const successMessage = (_a.config.success || '').toString();\n if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {\n instance.element.innerHTML = `<div class=\"alert-success\" role=\"alert\">${successMessage}</div>`;\n }\n let returnUrl = _a.config.redirect;\n // Allow form based configuration for return url.\n if (!returnUrl &&\n (instance._form &&\n instance._form.settings &&\n (instance._form.settings.returnUrl ||\n instance._form.settings.redirect))) {\n _a.debug('Return url found in form configuration');\n returnUrl = instance._form.settings.returnUrl || instance._form.settings.redirect;\n }\n if (returnUrl) {\n const formSrc = instance.formio ? instance.formio.formUrl : '';\n const hasQuery = !!returnUrl.match(/\\?/);\n const isOrigin = returnUrl.indexOf(location.origin) === 0;\n returnUrl += hasQuery ? '&' : '?';\n returnUrl += `sub=${submission._id}`;\n if (!isOrigin && formSrc) {\n returnUrl += `&form=${encodeURIComponent(formSrc)}`;\n }\n _a.debug('Return URL', returnUrl);\n window.location.href = returnUrl;\n if (isOrigin) {\n window.location.reload();\n }\n }\n });\n }\n // Return the full script if the builder is being used.\n static formioScript(script, builder) {\n builder = builder || _a.config.includeBuilder;\n if (_a.fullAdded || builder) {\n _a.fullAdded = true;\n return script.replace('formio.form', 'formio.full');\n }\n return script;\n }\n static addLibrary(libWrapper, lib, name) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!lib) {\n return;\n }\n if (lib.dependencies) {\n for (let i = 0; i < lib.dependencies.length; i++) {\n const libName = lib.dependencies[i];\n yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);\n }\n }\n if (lib.css) {\n yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript((lib.global ? document.body : libWrapper), lib.js, lib.use ? name : false);\n if (lib.use) {\n _a.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && _a.license) {\n options.license = _a.license;\n }\n _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);\n }\n }\n if (lib.globalStyle) {\n const style = _a.createElement('style');\n style.type = 'text/css';\n style.innerHTML = lib.globalStyle;\n document.body.appendChild(style);\n }\n });\n }\n static addLoader(wrapper) {\n return __awaiter(this, void 0, void 0, function* () {\n wrapper.appendChild(_a.createElement('div', {\n 'class': 'formio-loader'\n }, [{\n tag: 'div',\n attrs: {\n class: 'loader-wrapper'\n },\n children: [{\n tag: 'div',\n attrs: {\n class: 'loader text-center'\n }\n }]\n }]));\n });\n }\n // eslint-disable-next-line max-statements\n static init(element, options = {}, builder = false) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});\n _a.config.libs = _a.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${_a.cdn.uswds}/uswds.min.js`,\n css: `${_a.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,\n globalStyle: `@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',\n globalStyle: `@font-face {\n font-display: block;\n font-family: \"bootstrap-icons\";\n src: url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6\") format(\"woff2\"),\n url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6\") format(\"woff\");\n }`\n }\n };\n // Add all bootswatch templates.\n ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {\n _a.config.libs[template] = {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.css`\n };\n });\n const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;\n // Create a new wrapper and add the element inside of a new wrapper.\n let wrapper = _a.createElement('div', {\n 'id': `${id}-wrapper`\n });\n element.parentNode.insertBefore(wrapper, element);\n // If we include the libraries, then we will attempt to run this in shadow dom.\n const useShadowDom = _a.config.includeLibs && !_a.config.noshadow && (typeof wrapper.attachShadow === 'function');\n if (useShadowDom) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // If this is inside of shadow dom, then we need to add the styles and scripts to the shadow dom.\n const libWrapper = useShadowDom ? wrapper : document.body;\n // Load the renderer styles.\n yield _a.addStyles(libWrapper, _a.config.embedCSS || `${_a.cdn.js}/formio.embed.css`);\n // Add a loader.\n _a.addLoader(wrapper);\n const formioSrc = _a.config.full ? 'formio.full' : 'formio.form';\n const renderer = _a.config.debug ? formioSrc : `${formioSrc}.min`;\n _a.FormioClass = yield _a.addScript(libWrapper, _a.formioScript(_a.config.script || `${_a.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n _a.FormioClass.cdn = _a.cdn;\n _a.FormioClass.setBaseUrl(options.baseUrl || _a.baseUrl || _a.config.base);\n _a.FormioClass.setProjectUrl(options.projectUrl || _a.projectUrl || _a.config.project);\n _a.FormioClass.language = _a.language;\n _a.setLicense(_a.license || _a.config.license || false);\n _a.modules.forEach((module) => {\n _a.FormioClass.use(module);\n });\n if (_a.icons) {\n _a.FormioClass.icons = _a.icons;\n }\n if (_a.pathType) {\n _a.FormioClass.setPathType(_a.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (_a.config.template && _a.config.includeLibs) {\n yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);\n }\n if (!_a.config.libraries) {\n _a.config.libraries = _a.config.modules || {};\n }\n // Adding premium if it is provided via the config.\n if (_a.config.premium) {\n _a.config.libraries.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.libraries) {\n for (const name in _a.config.libraries) {\n const lib = _a.config.libraries[name];\n lib.use = lib.use || true;\n yield _a.addLibrary(libWrapper, lib, name);\n }\n }\n yield _a.addStyles(libWrapper, _a.formioScript(_a.config.style || `${_a.cdn.js}/${renderer}.css`, builder));\n if (_a.config.before) {\n yield _a.config.before(_a.FormioClass, element, _a.config);\n }\n _a.FormioClass.license = true;\n _a._formioReady(_a.FormioClass);\n return wrapper;\n });\n }\n // Called after an instance has been created.\n static afterCreate(instance, wrapper, readyEvent) {\n return __awaiter(this, void 0, void 0, function* () {\n const loader = wrapper.querySelector('.formio-loader');\n if (loader) {\n wrapper.removeChild(loader);\n }\n _a.FormioClass.events.emit(readyEvent, instance);\n if (_a.config.after) {\n _a.debug('Calling ready callback');\n _a.config.after(instance, _a.config);\n }\n return instance;\n });\n }\n // Create a new form.\n static createForm(element, form, options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n if (_a.FormioClass) {\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield _a.init(element, options);\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (_a.config.submission) {\n _a.debug('Setting submission', _a.config.submission);\n instance.submission = _a.config.submission;\n }\n // Call the after create method.\n _a.afterCreate(instance, wrapper, 'formEmbedded');\n return instance;\n });\n });\n }\n // Create a form builder.\n static builder(element, form, options = {}) {\n var _b;\n return __awaiter(this, void 0, void 0, function* () {\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return _a.FormioClass.builder(element, form, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.builder(element, form, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\nexports.Formio = Formio;\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n _a._formioReady = ready;\n _a._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.65';\n// Create a report.\nFormio.Report = {\n create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {\n var _b;\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return _a.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.Report.create(element, submission, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nCDN_js_1.default.defaultCDN = Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nclass Form {\n constructor(element, form, options) {\n this.form = form;\n this.element = element;\n this.options = options || {};\n this.init();\n this.instance = {\n proxy: true,\n ready: this.ready,\n destroy: () => { }\n };\n }\n init() {\n if (this.instance && !this.instance.proxy) {\n this.instance.destroy();\n }\n this.element.innerHTML = '';\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.form = instance.form;\n return instance;\n });\n }\n create() {\n return Formio.createForm(this.element, this.form, this.options);\n }\n setForm(form) {\n this.form = form;\n if (this.instance) {\n this.instance.setForm(form);\n }\n }\n setDisplay(display) {\n if (this.instance.proxy) {\n return this.ready;\n }\n this.form.display = display;\n this.instance.destroy();\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.setForm(this.form);\n });\n return this.ready;\n }\n}\nexports.Form = Form;\nclass FormBuilder extends Form {\n create() {\n return Formio.builder(this.element, this.form, this.options);\n }\n}\nexports.FormBuilder = FormBuilder;\nFormio.Form = Form;\nFormio.FormBuilder = FormBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Embed.js?");
|
9582
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a;\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FormBuilder = exports.Form = exports.Formio = void 0;\nconst CDN_js_1 = __importDefault(__webpack_require__(/*! ./CDN.js */ \"./lib/cjs/CDN.js\"));\nclass Formio {\n static setLicense(license, norecurse = false) {\n _a.license = license;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n _a.pathType = type;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (_a.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (_a.FormioClass) {\n _a.FormioClass.clearCache();\n }\n }\n static global(prop, flag = '') {\n const globalValue = window[prop];\n if (flag && globalValue && !globalValue[flag]) {\n return null;\n }\n _a.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (_a.FormioClass && _a.FormioClass.isRenderer) {\n _a.FormioClass.use(module);\n }\n else {\n _a.modules.push(module);\n }\n }\n static createElement(type, attrs, children) {\n const element = document.createElement(type);\n if (!attrs) {\n return element;\n }\n Object.keys(attrs).forEach(key => {\n element.setAttribute(key, attrs[key]);\n });\n (children || []).forEach(child => {\n element.appendChild(_a.createElement(child.tag, child.attrs, child.children));\n });\n return element;\n }\n static addScript(wrapper, src, name, flag = '') {\n return __awaiter(this, void 0, void 0, function* () {\n if (!src) {\n return Promise.resolve();\n }\n if (typeof src !== 'string' && src.length) {\n return Promise.all(src.map(ref => _a.addScript(wrapper, ref)));\n }\n if (name && _a.global(name, flag)) {\n _a.debug(`${name} already loaded.`);\n return Promise.resolve(_a.global(name));\n }\n _a.debug('Adding Script', src);\n try {\n wrapper.appendChild(_a.createElement('script', {\n src\n }));\n }\n catch (err) {\n _a.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n _a.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (_a.global(name, flag)) {\n clearInterval(wait);\n _a.debug(`${name} loaded.`);\n resolve(_a.global(name));\n }\n }, 100);\n });\n });\n }\n static addStyles(wrapper, href) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!href) {\n return;\n }\n if (typeof href !== 'string' && href.length) {\n href.forEach(ref => _a.addStyles(wrapper, ref));\n return;\n }\n _a.debug('Adding Styles', href);\n wrapper.appendChild(_a.createElement('link', {\n rel: 'stylesheet',\n href\n }));\n });\n }\n static submitDone(instance, submission) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.debug('Submision Complete', submission);\n if (_a.config.submitDone) {\n _a.config.submitDone(submission, instance);\n }\n const successMessage = (_a.config.success || '').toString();\n if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {\n instance.element.innerHTML = `<div class=\"alert-success\" role=\"alert\">${successMessage}</div>`;\n }\n let returnUrl = _a.config.redirect;\n // Allow form based configuration for return url.\n if (!returnUrl &&\n (instance._form &&\n instance._form.settings &&\n (instance._form.settings.returnUrl ||\n instance._form.settings.redirect))) {\n _a.debug('Return url found in form configuration');\n returnUrl = instance._form.settings.returnUrl || instance._form.settings.redirect;\n }\n if (returnUrl) {\n const formSrc = instance.formio ? instance.formio.formUrl : '';\n const hasQuery = !!returnUrl.match(/\\?/);\n const isOrigin = returnUrl.indexOf(location.origin) === 0;\n returnUrl += hasQuery ? '&' : '?';\n returnUrl += `sub=${submission._id}`;\n if (!isOrigin && formSrc) {\n returnUrl += `&form=${encodeURIComponent(formSrc)}`;\n }\n _a.debug('Return URL', returnUrl);\n window.location.href = returnUrl;\n if (isOrigin) {\n window.location.reload();\n }\n }\n });\n }\n // Return the full script if the builder is being used.\n static formioScript(script, builder) {\n builder = builder || _a.config.includeBuilder;\n if (_a.fullAdded || builder) {\n _a.fullAdded = true;\n return script.replace('formio.form', 'formio.full');\n }\n return script;\n }\n static addLibrary(libWrapper, lib, name) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!lib) {\n return;\n }\n if (lib.dependencies) {\n for (let i = 0; i < lib.dependencies.length; i++) {\n const libName = lib.dependencies[i];\n yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);\n }\n }\n if (lib.css) {\n yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript((lib.global ? document.body : libWrapper), lib.js, lib.use ? name : false);\n if (lib.use) {\n _a.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && _a.license) {\n options.license = _a.license;\n }\n _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);\n }\n }\n if (lib.globalStyle) {\n const style = _a.createElement('style');\n style.type = 'text/css';\n style.innerHTML = lib.globalStyle;\n document.body.appendChild(style);\n }\n });\n }\n static addLoader(wrapper) {\n return __awaiter(this, void 0, void 0, function* () {\n wrapper.appendChild(_a.createElement('div', {\n 'class': 'formio-loader'\n }, [{\n tag: 'div',\n attrs: {\n class: 'loader-wrapper'\n },\n children: [{\n tag: 'div',\n attrs: {\n class: 'loader text-center'\n }\n }]\n }]));\n });\n }\n // eslint-disable-next-line max-statements\n static init(element, options = {}, builder = false) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});\n _a.config.libs = _a.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${_a.cdn.uswds}/uswds.min.js`,\n css: `${_a.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,\n globalStyle: `@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',\n globalStyle: `@font-face {\n font-display: block;\n font-family: \"bootstrap-icons\";\n src: url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6\") format(\"woff2\"),\n url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6\") format(\"woff\");\n }`\n }\n };\n // Add all bootswatch templates.\n ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {\n _a.config.libs[template] = {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.css`\n };\n });\n const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;\n // Create a new wrapper and add the element inside of a new wrapper.\n let wrapper = _a.createElement('div', {\n 'id': `${id}-wrapper`\n });\n element.parentNode.insertBefore(wrapper, element);\n // If we include the libraries, then we will attempt to run this in shadow dom.\n const useShadowDom = _a.config.includeLibs && !_a.config.noshadow && (typeof wrapper.attachShadow === 'function');\n if (useShadowDom) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // If this is inside of shadow dom, then we need to add the styles and scripts to the shadow dom.\n const libWrapper = useShadowDom ? wrapper : document.body;\n // Load the renderer styles.\n yield _a.addStyles(libWrapper, _a.config.embedCSS || `${_a.cdn.js}/formio.embed.css`);\n // Add a loader.\n _a.addLoader(wrapper);\n const formioSrc = _a.config.full ? 'formio.full' : 'formio.form';\n const renderer = _a.config.debug ? formioSrc : `${formioSrc}.min`;\n _a.FormioClass = yield _a.addScript(libWrapper, _a.formioScript(_a.config.script || `${_a.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n _a.FormioClass.cdn = _a.cdn;\n _a.FormioClass.setBaseUrl(options.baseUrl || _a.baseUrl || _a.config.base);\n _a.FormioClass.setProjectUrl(options.projectUrl || _a.projectUrl || _a.config.project);\n _a.FormioClass.language = _a.language;\n _a.setLicense(_a.license || _a.config.license || false);\n _a.modules.forEach((module) => {\n _a.FormioClass.use(module);\n });\n if (_a.icons) {\n _a.FormioClass.icons = _a.icons;\n }\n if (_a.pathType) {\n _a.FormioClass.setPathType(_a.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (_a.config.template && _a.config.includeLibs) {\n yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);\n }\n if (!_a.config.libraries) {\n _a.config.libraries = _a.config.modules || {};\n }\n // Adding premium if it is provided via the config.\n if (_a.config.premium) {\n _a.config.libraries.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.libraries) {\n for (const name in _a.config.libraries) {\n const lib = _a.config.libraries[name];\n lib.use = lib.use || true;\n yield _a.addLibrary(libWrapper, lib, name);\n }\n }\n yield _a.addStyles(libWrapper, _a.formioScript(_a.config.style || `${_a.cdn.js}/${renderer}.css`, builder));\n if (_a.config.before) {\n yield _a.config.before(_a.FormioClass, element, _a.config);\n }\n _a.FormioClass.license = true;\n _a._formioReady(_a.FormioClass);\n return wrapper;\n });\n }\n // Called after an instance has been created.\n static afterCreate(instance, wrapper, readyEvent) {\n return __awaiter(this, void 0, void 0, function* () {\n const loader = wrapper.querySelector('.formio-loader');\n if (loader) {\n wrapper.removeChild(loader);\n }\n _a.FormioClass.events.emit(readyEvent, instance);\n if (_a.config.after) {\n _a.debug('Calling ready callback');\n _a.config.after(instance, _a.config);\n }\n return instance;\n });\n }\n // Create a new form.\n static createForm(element, form, options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n if (_a.FormioClass) {\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield _a.init(element, options);\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (_a.config.submission) {\n _a.debug('Setting submission', _a.config.submission);\n instance.submission = _a.config.submission;\n }\n // Call the after create method.\n _a.afterCreate(instance, wrapper, 'formEmbedded');\n return instance;\n });\n });\n }\n // Create a form builder.\n static builder(element, form, options = {}) {\n var _b;\n return __awaiter(this, void 0, void 0, function* () {\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return _a.FormioClass.builder(element, form, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.builder(element, form, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\nexports.Formio = Formio;\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n _a._formioReady = ready;\n _a._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.66';\n// Create a report.\nFormio.Report = {\n create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {\n var _b;\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return _a.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.Report.create(element, submission, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nCDN_js_1.default.defaultCDN = Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nclass Form {\n constructor(element, form, options) {\n this.form = form;\n this.element = element;\n this.options = options || {};\n this.init();\n this.instance = {\n proxy: true,\n ready: this.ready,\n destroy: () => { }\n };\n }\n init() {\n if (this.instance && !this.instance.proxy) {\n this.instance.destroy();\n }\n this.element.innerHTML = '';\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.form = instance.form;\n return instance;\n });\n }\n create() {\n return Formio.createForm(this.element, this.form, this.options);\n }\n setForm(form) {\n this.form = form;\n if (this.instance) {\n this.instance.setForm(form);\n }\n }\n setDisplay(display) {\n if (this.instance.proxy) {\n return this.ready;\n }\n this.form.display = display;\n this.instance.destroy();\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.setForm(this.form);\n });\n return this.ready;\n }\n}\nexports.Form = Form;\nclass FormBuilder extends Form {\n create() {\n return Formio.builder(this.element, this.form, this.options);\n }\n}\nexports.FormBuilder = FormBuilder;\nFormio.Form = Form;\nFormio.FormBuilder = FormBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Embed.js?");
|
9487
9583
|
|
9488
9584
|
/***/ }),
|
9489
9585
|
|
@@ -9494,7 +9590,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
9494
9590
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
9495
9591
|
|
9496
9592
|
"use strict";
|
9497
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = void 0;\nconst sdk_1 = __webpack_require__(/*! @formio/core/sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nObject.defineProperty(exports, \"Formio\", ({ enumerable: true, get: function () { return sdk_1.Formio; } }));\nconst Embed_1 = __webpack_require__(/*! ./Embed */ \"./lib/cjs/Embed.js\");\nconst CDN_1 = __importDefault(__webpack_require__(/*! ./CDN */ \"./lib/cjs/CDN.js\"));\nconst providers_1 = __importDefault(__webpack_require__(/*! ./providers */ \"./lib/cjs/providers/index.js\"));\nsdk_1.Formio.cdn = new CDN_1.default();\nsdk_1.Formio.Providers = providers_1.default;\nsdk_1.Formio.version = '5.0.0-rc.
|
9593
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = void 0;\nconst sdk_1 = __webpack_require__(/*! @formio/core/sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nObject.defineProperty(exports, \"Formio\", ({ enumerable: true, get: function () { return sdk_1.Formio; } }));\nconst Embed_1 = __webpack_require__(/*! ./Embed */ \"./lib/cjs/Embed.js\");\nconst CDN_1 = __importDefault(__webpack_require__(/*! ./CDN */ \"./lib/cjs/CDN.js\"));\nconst providers_1 = __importDefault(__webpack_require__(/*! ./providers */ \"./lib/cjs/providers/index.js\"));\nsdk_1.Formio.cdn = new CDN_1.default();\nsdk_1.Formio.Providers = providers_1.default;\nsdk_1.Formio.version = '5.0.0-rc.66';\nCDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nconst isNil = (val) => val === null || val === undefined;\nsdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {\n const requestArgs = {\n provider: storage,\n method: 'upload',\n file: file,\n fileName: fileName,\n dir: dir\n };\n fileKey = fileKey || 'file';\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', storage);\n if (Provider) {\n const provider = new Provider(this);\n if (uploadStartCallback) {\n uploadStartCallback();\n }\n return provider.uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback, multipartOptions);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\nsdk_1.Formio.prototype.downloadFile = function (file, options) {\n const requestArgs = {\n method: 'download',\n file: file\n };\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (file.storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', file.storage);\n if (Provider) {\n const provider = new Provider(this);\n return provider.downloadFile(file, options);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\nsdk_1.Formio.prototype.deleteFile = function (file, options) {\n const requestArgs = {\n method: 'delete',\n file: file\n };\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (file.storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', file.storage);\n if (Provider) {\n const provider = new Provider(this);\n return provider.deleteFile(file, options);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\n// Esnure we proxy the following methods to the FormioEmbed class.\n['setBaseUrl', 'setApiUrl', 'setAppUrl', 'setProjectUrl', 'setPathType', 'setLicense'].forEach((fn) => {\n const baseFn = sdk_1.Formio[fn];\n sdk_1.Formio[fn] = function (arg) {\n const retVal = Embed_1.Formio[fn](arg, true);\n return baseFn ? baseFn.call(this, arg) : retVal;\n };\n});\n// For reverse compatability.\nsdk_1.Formio.Promise = Promise;\nsdk_1.Formio.formioReady = Embed_1.Formio.formioReady;\nsdk_1.Formio.config = Embed_1.Formio.config;\nsdk_1.Formio.builder = Embed_1.Formio.builder;\nsdk_1.Formio.Report = Embed_1.Formio.Report;\nsdk_1.Formio.Form = Embed_1.Formio.Form;\nsdk_1.Formio.FormBuilder = Embed_1.Formio.FormBuilder;\nsdk_1.Formio.use = Embed_1.Formio.use;\nsdk_1.Formio.createForm = Embed_1.Formio.createForm;\nsdk_1.Formio.submitDone = Embed_1.Formio.submitDone;\nsdk_1.Formio.addLibrary = Embed_1.Formio.addLibrary;\nsdk_1.Formio.addLoader = Embed_1.Formio.addLoader;\nsdk_1.Formio.addToGlobal = (global) => {\n if (typeof global === 'object' && !global.Formio) {\n global.Formio = sdk_1.Formio;\n }\n};\nif (typeof __webpack_require__.g !== 'undefined') {\n sdk_1.Formio.addToGlobal(__webpack_require__.g);\n}\nif (typeof window !== 'undefined') {\n sdk_1.Formio.addToGlobal(window);\n}\nEmbed_1.Formio._formioReady(sdk_1.Formio);\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Formio.js?");
|
9498
9594
|
|
9499
9595
|
/***/ }),
|
9500
9596
|
|