@corva/ui 0.36.0-13 → 0.36.0-14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/defineProperty";import n from"@babel/runtime/helpers/toConsumableArray";import a from"@babel/runtime/regenerator";import{useState as o,useEffect as s,useRef as i}from"react";import"
|
|
1
|
+
import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/defineProperty";import n from"@babel/runtime/helpers/toConsumableArray";import a from"@babel/runtime/regenerator";import{useState as o,useEffect as s,useRef as i}from"react";import{isEmpty as p}from"lodash";import"uuid";import"lodash/set";import"lodash/get";import"lodash/unset";import"moment";import{mapAssetGetRequest as c,getAssets as u}from"../../../clients/jsonApi/index.js";import"../../../clients/subscriptions.js";import"../../../clients/api/apiCore.js";import"../../../clients/constants.js";import{PER_PAGE as l}from"../constants.js";function m(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function f(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?m(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var d=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{sort:"name",order:"asc",fields:["".concat(e,".name"),"".concat(e,".asset_id")].concat(n(r))}},y=function(e){var r,t,n;return f(f({},e.attributes),{},{id:+e.id,programId:+(null===(r=e.relationships)||void 0===r||null===(t=r.program)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.id)})};function b(n){var i=n.appKey,p=n.assetType,u=n.assetId,l=n.parentAssetType,m=n.parentAssetId,b=n.queryParams,h=o([]),v=r(h,2),g=v[0],O=v[1],j=o(!0),x=r(j,2),w=x[0],P=x[1];return s((function(){function r(){return(r=e(a.mark((function e(){var r;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c(p)(f(f(f({},d(p)),{},t({per_page:1e4},l,m),i&&{app_key:i}),b));case 2:r=e.sent,O(r.data.map(y)),P(!1);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}P(!0),function(){r.apply(this,arguments)}()}),[p,u,l,m,i]),{assets:g,loading:w}}function h(t){var n=t.appKey,m=t.assetType,b=t.companyId,h=t.currentValue,v=t.isMultiple,g=t.parentAssetId,O=t.parentAssetType,j=t.scrollPage,x=t.searchText,w=t.setCurrentOption,P=t.queryParams,k=t.assetFields,A=o([]),T=r(A,2),I=T[0],_=T[1],D=o(!1),C=r(D,2),q=C[0],E=C[1],K=i(),S=i();return s((function(){function r(){return(r=e(a.mark((function e(){var r;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c(m)(f(f({},d(m,k)),{},{ids:v?h:[h]},P));case 2:if(r=e.sent,!p(r.data)){e.next=7;break}return e.next=6,u(f(f({},d(m,k)),{},{ids:v?h:[h]},P));case 6:r=e.sent;case 7:w((function(){if(v)return r.data.map(y);var e=r.data[0];return e?y(e):null}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(v?h.length:h)&&function(){r.apply(this,arguments)}()}),[]),s((function(){function r(){return(r=e(a.mark((function e(){var r,t,o,s,i;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,E(!0),r={per_page:l,page:j},O&&g&&(r[O]=g),b&&(r.company=b),x&&(r.search=x),n&&(r.app_key=n),t=c(m)(f(f(f({},d(m,k)),r),P)),S.current=t,e.next=11,t;case 11:if(o=e.sent,S.current===t){e.next=14;break}return e.abrupt("return");case 14:s=o.data.map(y),i=K.current!==m||1===j,_(i?s:function(e){return e.concat(s)}),K.current=m,e.next=23;break;case 20:e.prev=20,e.t0=e.catch(0),console.error(e.t0);case 23:E(!1);case 24:case"end":return e.stop()}}),e,null,[[0,20]])})))).apply(this,arguments)}!function(){r.apply(this,arguments)}()}),[m,O,g,b,x,j,n]),{assets:I,loading:q}}export{h as useAssetAutoCompleteSelectData,b as useAssetSelectData};
|