Gazebo_simulation-Frontend/node_modules/final-form-arrays/dist/final-form-arrays.umd.min.js
2020-12-21 10:29:31 -05:00

3 lines
4.3 KiB
JavaScript

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["final-form-arrays"]={})}(this,function(e){"use strict";function o(){return(o=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var f=arguments[n];for(var i in f)Object.prototype.hasOwnProperty.call(f,i)&&(e[i]=f[i])}return e}).apply(this,arguments)}function d(e,n,f,i){void 0===i&&(i=e),delete e.fields[n.name],e.fields[f]=o({},n,{name:f,change:i.fields[f]&&i.fields[f].change,blur:i.fields[f]&&i.fields[f].blur,focus:i.fields[f]&&i.fields[f].focus,lastFieldState:void 0}),e.fields[f].change||delete e.fields[f].change,e.fields[f].blur||delete e.fields[f].blur,e.fields[f].focus||delete e.fields[f].focus}function v(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e,t,n){var r=e[0],c=e[1],f=e[2],i=n.changeValue;n.resetFieldState,i(t,r,function(e){var n=[].concat(e||[]);return n.splice(c,0,f),n});var l=o({},t.fields),s=new RegExp("^"+v(r)+"\\[(\\d+)\\](.*)");Object.keys(t.fields).sort().reverse().forEach(function(e){var n=s.exec(e);if(n){var f=Number(n[1]);if(c<=f){var i=r+"["+(f+1)+"]"+n[2];d(t,l[e],i)}}})}function u(i,t,r,c){Object.keys(c.fields).forEach(function(e){if(e.substring(0,t.length)===t){var n=e.substring(t.length),f=i+"["+r+"]"+n;d(c,c.fields[e],f)}})}function h(n,f){Object.keys(n.fields).forEach(function(e){n.fields[e]=o({},n.fields[e],{change:n.fields[e].change||f.fields[e]&&f.fields[e].change,blur:n.fields[e].blur||f.fields[e]&&f.fields[e].blur,focus:n.fields[e].focus||f.fields[e]&&f.fields[e].focus}),n.fields[e].change||delete n.fields[e].change,n.fields[e].blur||delete n.fields[e].blur,n.fields[e].focus||delete n.fields[e].focus})}function t(e,t,n){var f,r=e[0],c=e[1],i=n.changeValue,l=n.renameField;i(t,r,function(e){var n=[].concat(e||[]);return f=n[c],n.splice(c,1),n});var s=new RegExp("^"+v(r)+"\\[(\\d+)\\](.*)"),a=o({},t,{fields:o({},t.fields)});return Object.keys(t.fields).forEach(function(e){var n=s.exec(e);if(n){var f=Number(n[1]);if(f===c)delete t.fields[e];else if(c<f){delete t.fields[e];var i=r+"["+(f-1)+"]"+n[2];a.fields[i]?d(t,a.fields[e],i,a):l(t,e,i)}}}),f}var n={insert:r,concat:function(e,n,f){var i=e[0],t=e[1];(0,f.changeValue)(n,i,function(e){return e?[].concat(e,t):t})},move:function(e,n,f){var i=e[0],t=e[1],r=e[2],c=f.changeValue;if(t!==r){c(n,i,function(e){var n=[].concat(e||[]),f=n[t];return n.splice(t,1),n.splice(r,0,f),n});var l=o({},n,{fields:o({},n.fields)});if(u(i,i+"["+t+"]","tmp",n),t<r)for(var s=t+1;s<=r;s++){u(i,i+"["+s+"]",""+(s-1),n)}else for(var a=t-1;r<=a;a--){u(i,i+"["+a+"]",""+(a+1),n)}u(i,i+"[tmp]",r,n),h(n,l)}},pop:function(e,n,f){var i,t,r=e[0];if((0,f.changeValue)(n,r,function(e){if(e)return e.length?(t=e.length-1,i=e[t],e.slice(0,t)):[]}),void 0!==t){var c=new RegExp("^"+v(r)+"\\["+t+"].*");Object.keys(n.fields).forEach(function(e){c.test(e)&&delete n.fields[e]})}return i},push:function(e,n,f){var i=e[0],t=e[1];(0,f.changeValue)(n,i,function(e){return e?[].concat(e,[t]):[t]})},remove:t,removeBatch:function(e,t,n){var r=e[0],c=e[1],f=n.changeValue,l=[].concat(c);l.sort();for(var i=0;i<l.length;i++)0<i&&l[i]===l[i-1]&&l.splice(i--,1);var s=[];f(t,r,function(n){if(s=c.map(function(e){return n&&n[e]}),!n||!l.length)return n;var f=[].concat(n),i=[];return l.forEach(function(e){f.splice(e-i.length,1),i.push(n&&n[e])}),f});var a=new RegExp("^"+v(r)+"\\[(\\d+)\\](.*)"),u=o({},t,{fields:{}});return Object.keys(t.fields).forEach(function(e){var n=a.exec(e);if(n){var f=Number(n[1]);if(!~l.indexOf(f)){var i=r+"["+(f-function(e,f){return e.reduce(function(e,n){return n<f?e+1:e},0)}(l,f))+"]"+n[2];d(u,t.fields[e],i,t)}}else u.fields[e]=t.fields[e]}),t.fields=u.fields,s},shift:function(e,n,f){var i=e[0];return t([i,0],n,f)},swap:function(e,n,f){var i=e[0],t=e[1],r=e[2],c=f.changeValue;if(t!==r){c(n,i,function(e){var n=[].concat(e||[]),f=n[t];return n[t]=n[r],n[r]=f,n});var l=o({},n,{fields:o({},n.fields)}),s=i+"["+r+"]",a=i+"[tmp]";u(i,i+"["+t+"]","tmp",n),u(i,s,t,n),u(i,a,r,n),h(n,l)}},unshift:function(e,n,f){var i=e[0],t=e[1];return r([i,0,t],n,f)},update:function(e,n,f){var i=e[0],t=e[1],r=e[2];(0,f.changeValue)(n,i,function(e){var n=[].concat(e||[]);return n.splice(t,1,r),n})}};e.default=n,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=final-form-arrays.umd.min.js.map