Comparing version 2.2.1 to 2.2.2
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).rcHooks={},e.React)}(this,(function(e,n){"use strict";function t(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var r=t(n),i=function(){return i=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},i.apply(this,arguments)};function o(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]])}return t}function u(e){var n="function"==typeof Symbol&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,i,o=t.call(e),u=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(t=o.return)&&t.call(o)}finally{if(i)throw i.error}}return u}function c(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))}function l(e){var t=n.useRef(e);t.current=e;var r=n.useCallback((function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.current;return null==r?void 0:r.apply(void 0,c([],a(e),!1))}),[t]);return r}var f=function(e,t){var r=n.useRef(!1);n.useEffect((function(){if(r.current)return e();r.current=!0}),t)},s={},d=function(e){var n=s[e];if(n){var t=n.startTime,r=n.cacheTime,i=n.data;return(new Date).getTime()-t>=r?(n.timer&&clearTimeout(n.timer),void delete s[e]):i}},v=function(e,n,t){void 0===t&&(t=3e5),s[e]&&clearTimeout(s[e].timer);var r=setTimeout((function(){delete s[e]}),t);s[e]={data:n,timer:r,cacheTime:t,startTime:(new Date).getTime()}},h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var p=function(e){var n=typeof e;return null!=e&&("object"==n||"function"==n)},y="object"==typeof h&&h&&h.Object===Object&&h,g="object"==typeof self&&self&&self.Object===Object&&self,m=y||g||Function("return this")(),b=m,w=function(){return b.Date.now()},T=/\s/;var E=function(e){for(var n=e.length;n--&&T.test(e.charAt(n)););return n},O=/^\s+/;var S=function(e){return e?e.slice(0,E(e)+1).replace(O,""):e},R=m.Symbol,C=R,j=Object.prototype,k=j.hasOwnProperty,L=j.toString,P=C?C.toStringTag:void 0;var A=function(e){var n=k.call(e,P),t=e[P];try{e[P]=void 0;var r=!0}catch(e){}var i=L.call(e);return r&&(n?e[P]=t:delete e[P]),i},x=Object.prototype.toString;var I=A,M=function(e){return x.call(e)},_=R?R.toStringTag:void 0;var F=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":_&&_ in Object(e)?I(e):M(e)},N=function(e){return null!=e&&"object"==typeof e};var W=S,D=p,z=function(e){return"symbol"==typeof e||N(e)&&"[object Symbol]"==F(e)},H=/^[-+]0x[0-9a-f]+$/i,U=/^0b[01]+$/i,V=/^0o[0-7]+$/i,B=parseInt;var K=p,$=w,q=function(e){if("number"==typeof e)return e;if(z(e))return NaN;if(D(e)){var n="function"==typeof e.valueOf?e.valueOf():e;e=D(n)?n+"":n}if("string"!=typeof e)return 0===e?e:+e;e=W(e);var t=U.test(e);return t||V.test(e)?B(e.slice(2),t?2:8):H.test(e)?NaN:+e},Y=Math.max,G=Math.min;var J=function(e,n,t){var r,i,o,u,a,c,l=0,f=!1,s=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(n){var t=r,o=i;return r=i=void 0,l=n,u=e.apply(o,t)}function h(e){return l=e,a=setTimeout(y,n),f?v(e):u}function p(e){var t=e-c;return void 0===c||t>=n||t<0||s&&e-l>=o}function y(){var e=$();if(p(e))return g(e);a=setTimeout(y,function(e){var t=n-(e-c);return s?G(t,o-(e-l)):t}(e))}function g(e){return a=void 0,d&&r?v(e):(r=i=void 0,u)}function m(){var e=$(),t=p(e);if(r=arguments,i=this,c=e,t){if(void 0===a)return h(c);if(s)return clearTimeout(a),a=setTimeout(y,n),v(c)}return void 0===a&&(a=setTimeout(y,n)),u}return n=q(n)||0,K(t)&&(f=!!t.leading,o=(s="maxWait"in t)?Y(q(t.maxWait)||0,n):o,d="trailing"in t?!!t.trailing:d),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,r=c=i=a=void 0},m.flush=function(){return void 0===a?u:g($())},m},Q=J,X=p;var Z=function(e,n,t){var r=!0,i=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return X(t)&&(r="leading"in t?!!t.leading:r,i="trailing"in t?!!t.trailing:i),Q(e,n,{leading:r,maxWait:n,trailing:i})};function ee(){return"undefined"==typeof document||void 0===document.visibilityState||"hidden"!==document.visibilityState}var ne=[];var te=!1;if("undefined"!=typeof window&&window.addEventListener&&!te){window.addEventListener("visibilitychange",(function(){if(ee())for(var e=0;e<ne.length;e++){(0,ne[e])()}}),!1),te=!0}var re=[];var ie=!1;if("undefined"!=typeof window&&window.addEventListener&&!ie){var oe=function(){if(ee()&&("undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine))for(var e=0;e<re.length;e++){(0,re[e])()}};window.addEventListener("visibilitychange",oe,!1),window.addEventListener("focus",oe,!1),ie=!0}var ue={},ae=function(e,n){return n&&ue[n]?ue[n]:n?(ue[n]=e().then((function(e){return delete ue[n],e})).catch((function(e){return delete ue[n],Promise.reject(e)})),ue[n]):e()},ce=function(){function e(e,n){this.params=[],this.pollingWhenVisibleFlag=!1,this.pollingTimer=null,this.counter=1,this.destroyed=!1,this.async=e,this.options=i({cacheTime:3e5,persisted:!1,pollingWhenHidden:!0,refreshOnWindowFocus:!1,focusTimespan:5e3},n),this.unsubscribes=[],this.init()}return e.prototype.init=function(){var e,n,t,r,i=this.options,o=i.pollingInterval,u=i.refreshOnWindowFocus,l=i.focusTimespan;if(this.updateDebounce(),o&&this.unsubscribes.push((e=this.rePolling.bind(this),ne.push(e),function(){var n=ne.indexOf(e);ne.splice(n,1)})),u){var f=(n=this.refresh.bind(this),t=l,r=!1,function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];r||(r=!0,n.apply(void 0,c([],a(e),!1)),setTimeout((function(){r=!1}),t))});this.unsubscribes.push(function(e){return re.push(e),function(){var n=re.indexOf(e);re.splice(n,1)}}(f))}},e.prototype.updateDebounce=function(){var e=this.options,n=e.debounceInterval,t=e.throttleInterval;this.debounce="number"==typeof n&&n>0?J(this._run,n):void 0,this.throttle="number"==typeof t&&t>0?Z(this._run,t):void 0},e.prototype.rePolling=function(){this.pollingWhenVisibleFlag&&(this.pollingWhenVisibleFlag=!1,this.refresh())},e.prototype.afterUpdateOptions=function(e,n){void 0===n&&(n={}),("debounceInterval"in n&&n.debounceInterval!==e.debounceInterval||"throttleInterval"in n&&n.throttleInterval!==e.throttleInterval)&&this.updateDebounce()},e.prototype.updateOptions=function(e){var n=this.options,t=i(i({},this.options),e);this.options=t,this.afterUpdateOptions(n,t)},e.prototype._run=function(){for(var e=this,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];this.pollingTimer&&clearTimeout(this.pollingTimer);var r=this.counter;this.params=n;var i=this.options,o=i.cacheKey,u=i.cacheTime,l=i.persisted,f=i.formatResult,s=i.onSuccess,h=i.onError,p=i.onFinally,y=i.onBefore,g=i.pollingWhenHidden,m=i.pollingInterval;return null==y||y(n),new Promise((function(t,i){var y;if(o&&l){var b=d(o);if(b&&r===e.counter)return null==s||s(b,n),void t(b)}null===(y=ae((function(){return e.async.apply(e,c([],a(n),!1))}),o))||void 0===y||y.then((function(i){if(r===e.counter){var a="function"==typeof f?f(i,n):i;o&&v(o,a,u),null==s||s(a,n),t(a)}})).catch((function(t){r===e.counter&&(null==h||h(t,n),i(t))})).finally((function(){if(r===e.counter&&(null==p||p(),m)){if(!ee()&&!g)return void(e.pollingWhenVisibleFlag=!0);e.pollingTimer=setTimeout((function(){e.run.apply(e,c([],a(n),!1))}),m)}}))}))},e.prototype.run=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return this.debounce?(this.debounce.apply(this,c([],a(e),!1)),Promise.resolve(null)):this.throttle?(this.throttle.apply(this,c([],a(e),!1)),Promise.resolve(null)):(this.counter+=1,this._run.apply(this,c([],a(e),!1)))},e.prototype.refresh=function(){return this.run.apply(this,c([],a(this.params),!1))},e.prototype.cancel=function(){this.debounce&&this.debounce.cancel(),this.throttle&&this.throttle.cancel(),this.pollingTimer&&(clearTimeout(this.pollingTimer),this.pollingTimer=null),this.counter+=1},e.prototype.destroy=function(e){void 0===e&&(e=!0),e&&this.cancel(),this.destroyed||(this.destroyed=!0,this.unsubscribes.forEach((function(e){return e()})),this.unsubscribes=[])},e.prototype.resume=function(){this.destroyed&&(this.destroyed=!1,this.init())},e}(),le=function(){};function fe(e,t){var r=t||{},o=r.autoRun,u=void 0===o||o,s=r.refreshDeps,v=void 0===s?[]:s,h=r.defaultParams,p=r.loadingDelay,y=r.__INTERNAL_FORMAT__,g=r.defaultLoading,m=void 0!==g&&g,b=r.initialData,w=r.cacheKey,T=void 0===w?"":w,E=r.cacheTime,O=void 0===E?3e5:E,S=r.persisted,R=void 0!==S&&S,C=r.onSuccess,j=void 0===C?le:C,k=r.onError,L=void 0===k?le:k,P=r.onFinally,A=void 0===P?le:P,x=r.onBefore,I=void 0===x?le:x,M=r.pollingInterval,_=void 0===M?0:M,F=r.pollingWhenHidden,N=void 0===F||F,W=r.refreshOnWindowFocus,D=void 0!==W&&W,z=r.focusTimespan,H=void 0===z?5e3:z,U=r.debounceInterval,V=r.throttleInterval,B=a(n.useState({params:[],loading:m,error:null,data:T?d(T):b}),2),K=B[0],$=B[1],q=n.useRef(null),Y=l(e),G=l(j),J=l(L),Q=l(A),X=l(I),Z=n.useRef(y);Z.current!==y&&(Z.current=y);var ee=n.useCallback((function(e){X(e),q.current&&clearTimeout(q.current),(T?d(T):void 0)&&R||($((function(n){return i(i({},n),{loading:!p,params:e})})),p&&(q.current=setTimeout((function(){$((function(e){return i(i({},e),{loading:!0})}))}),p)))}),[T,p,X,R]),ne=n.useCallback((function(e,n){q.current&&clearTimeout(q.current),$((function(n){return i(i({},n),{data:e,error:null,loading:!1})})),G(e,n)}),[G]),te=n.useCallback((function(e,n){q.current&&clearTimeout(q.current),$((function(n){return i(i({},n),{error:e,loading:!1})})),J(e,n)}),[J]),re=n.useRef();re.current||(re.current=new ce(Y,{cacheKey:T,cacheTime:O,persisted:R,formatResult:Z.current,onSuccess:ne,onError:te,onFinally:Q,onBefore:ee,debounceInterval:U,throttleInterval:V,pollingInterval:_,pollingWhenHidden:N,refreshOnWindowFocus:D,focusTimespan:H})),f((function(){var e;null===(e=re.current)||void 0===e||e.updateOptions({cacheKey:T,cacheTime:O,persisted:R,formatResult:Z.current,onSuccess:ne,onError:te,onFinally:Q,onBefore:ee,debounceInterval:U,throttleInterval:V,pollingInterval:_,pollingWhenHidden:N,refreshOnWindowFocus:D,focusTimespan:H})}),[G,J,T,O,R,U,V,Q,X,_,N,D,H,ne,te,ee]);var ie=n.useCallback((function(){for(var e,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return null===(e=re.current)||void 0===e?void 0:e.run.apply(e,c([],a(n),!1))}),[]),oe=n.useCallback((function(){var e;return null===(e=re.current)||void 0===e?void 0:e.refresh()}),[]),ue=n.useCallback((function(){var e;null===(e=re.current)||void 0===e||e.cancel(),q.current&&clearTimeout(q.current),$((function(e){return i(i({},e),{loading:!1})}))}),[]);return f((function(){u&&Array.isArray(v)&&v.length>0&&oe()}),c([u],a(v),!1)),n.useEffect((function(){var e;if(u){var n=Array.isArray(h)?h:void 0!==h?[h]:[];ie.apply(void 0,c([],a(n),!1))}return null===(e=re.current)||void 0===e||e.resume(),function(){var e;ue(),null===(e=re.current)||void 0===e||e.destroy(!1)}}),[]),i(i({},K),{run:ie,cancel:ue,mutate:function(e){$("function"==typeof e?function(n){return i(i({},n),{data:e(K.data)})}:function(n){return i(i({},n),{data:e})})},refresh:oe})}var se=function(e){return null!=e&&e===(null==e?void 0:e.window)};function de(e){return"function"==typeof e?e():e}var ve=function(e){var t=void 0===e?{}:e,r=t.target,i=t.threshold,o=void 0===i?100:i,u=t.onScrollLower,a=l(void 0===u?function(){}:u),c=n.useCallback((function(){if(r){var e,n=de(r);if(n)void 0===(e=n)&&(e=window),("undefined"==typeof window?0:se(e)?document.documentElement.scrollHeight:e.scrollHeight)-function(e){return void 0===e&&(e=window),"undefined"==typeof window?0:se(e)?window.scrollY:(null==e?void 0:e.scrollTop)||0}(n)<=function(e){return void 0===e&&(e=window),"undefined"==typeof window?0:se(e)?document.documentElement.clientHeight:e.clientHeight}(n)+o&&a()}}),[a,r,o]);n.useEffect((function(){if(r){var e=de(r);if(e)return e.addEventListener("scroll",c),function(){e.removeEventListener("scroll",c)}}}),[r,c])};var he=function(e){var t=n.useRef(e);t.current=e,n.useEffect((function(){return function(){return t.current()}}),[])};function pe(e,t,r){void 0===t&&(t=0),void 0===r&&(r={});var i=n.useRef(e);i.current=e;var o=n.useRef(J((function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return i.current.apply(i,c([],a(e),!1))}),t,r));return he((function(){o.current.cancel()})),{run:o.current,cancel:o.current.cancel,flush:o.current.flush}}function ye(e,t,r){void 0===t&&(t=0),void 0===r&&(r={});var i=n.useRef(e);i.current=e;var o=n.useRef(Z((function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return i.current.apply(i,c([],a(e),!1))}),t,r));return he((function(){o.current.cancel()})),{run:o.current,cancel:o.current.cancel,flush:o.current.flush}}var ge=function(){var e=r.useRef(!1);return r.useEffect((function(){return e.current=!1,function(){e.current=!0}}),[]),e};function me(e){var n=ge(),t=a(r.useState(e),2),i=t[0],o=t[1];return[i,r.useCallback((function(e){n.current||o(e)}),[])]}function be(e){return"function"==typeof e?e():e&&"current"in e?e.current:e}var we="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,Te=["top","right","bottom","left","width","height","size","weight"],Ee={characterData:!0,childList:!0,attributes:!0,subtree:!0},Oe=function(e){var n=this;this.refresh=function(){n.targetNode&&n.callback([{target:n.targetNode}],{})},this.onTransitionEnd_=function(e){var t=e.propertyName,r=void 0===t?"":t;Te.some((function(e){return r.indexOf(e)>-1}))&&n.throttleRefresh()},this.observe=function(e,t){we&&(n.targetNode=e,document.addEventListener("transitionend",n.onTransitionEnd_),window.addEventListener("resize",n.throttleRefresh),n.observer.observe(document,i(i({},Ee),t)))},this.disconnect=function(){we&&(n.throttleRefresh.cancel(),n.targetNode=null,document.removeEventListener("transitionend",n.onTransitionEnd_),window.removeEventListener("resize",n.throttleRefresh),n.observer.disconnect())},this.throttleRefresh=Z(this.refresh,50),this.targetNode=null,this.callback=e,this.observer=new MutationObserver(this.throttleRefresh)};e.clearCache=function(e){(void 0===e?Object.keys(s):Array.isArray(e)?e:[e]).forEach((function(e){s[e]&&(s[e].timer&&clearTimeout(s[e].timer),delete s[e])}))},e.useAsync=fe,e.useClickAway=function(e,n,t){void 0===t&&(t="click");var i=r.useRef(n);i.current=n,r.useEffect((function(){var n,r,o=function(n){var t;(Array.isArray(e)?e:[e]).some((function(e){var t=be(e);return!t||(null==t?void 0:t.contains(n.target))}))||null===(t=i.current)||void 0===t||t.call(i,n)},a=Array.isArray(t)?t:[t];try{for(var c=u(a),l=c.next();!l.done;l=c.next()){var f=l.value;document.addEventListener(f,o)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return function(){var e,n;try{for(var t=u(a),r=t.next();!r.done;r=t.next()){var i=r.value;document.removeEventListener(i,o)}}catch(n){e={error:n}}finally{try{r&&!r.done&&(n=t.return)&&n.call(t)}finally{if(e)throw e.error}}}}),[e,t])},e.useClientRect=function(){var e=n.useRef(null),t=a(n.useState(),2),r=t[0],i=t[1];return n.useEffect((function(){var n;e.current&&i(null===(n=e.current)||void 0===n?void 0:n.getBoundingClientRect())}),[e]),[r,e]},e.useControllableValue=function(e,t){void 0===e&&(e={}),void 0===t&&(t={});var r=t.defaultValue,i=t.defaultValuePropName,o=void 0===i?"defaultValue":i,u=t.valuePropName,l=void 0===u?"value":u,s=t.trigger,d=void 0===s?"onChange":s,v=l in e,h=e[l],p=a(n.useState((function(){return v?h:o in e?e[o]:r})),2),y=p[0],g=p[1];f((function(){v&&g(h)}),[h,v]);var m=n.useCallback((function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];v||g(n),e[d]&&e[d].apply(e,c([n],a(t),!1))}),[v,e,d]);return[v?h:y,m]},e.useDebounce=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r={});var i=a(n.useState(e),2),o=i[0],u=pe(i[1],t,r).run;return n.useEffect((function(){u(e)}),[u,e]),o},e.useDebounceFn=pe,e.useIsMounted=function(){var e=n.useRef(!1);return n.useEffect((function(){return e.current=!0,function(){e.current=!1}}),[]),e},e.useLimitList=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});var r=t||{},i=r.count,o=void 0===i?3:i,u=r.defaultLimited,c=void 0===u||u,l=n.useRef(c),f=n.useMemo((function(){return Array.isArray(e)?e:[]}),[e]),s=n.useMemo((function(){return o>0?Math.ceil(o):0}),[o]),d=n.useMemo((function(){return f.length>s}),[s,f.length]),v=a(n.useState((function(){return d&&c?f.slice(0,s):f})),2),h=v[0],p=v[1];return n.useEffect((function(){p(l.current?f.slice(0,s):f)}),[s,f]),{canLimit:d,limited:l.current,data:h,toggle:function(){d&&(l.current=!l.current),p(l.current?f.slice(0,s):f)}}},e.useLoadMore=function(e,n){var t=n||{},u=t.threshold,l=void 0===u?100:u,s=t.target,d=t.isNoMore,v=void 0===d?function(){return!1}:d,h=t.refreshDeps,p=void 0===h?[]:h,y=o(t,["threshold","target","isNoMore","refreshDeps"]),g=r.useRef([]),m=r.useRef(1),b=fe(e,i(i({defaultParams:[{current:m.current}]},y),{onError:function(e,n){var t;m.current>1&&(m.current-=1),null===(t=null==y?void 0:y.onError)||void 0===t||t.call(y,e,n)},__INTERNAL_FORMAT__:function(e){return g.current=1===m.current?e.list:g.current.concat(e.list),i(i({},e),{list:g.current})}})),w=b.run,T=b.data,E=b.loading,O=b.cancel,S=b.params,R=b.mutate,C=o(b,["run","data","loading","cancel","params","mutate"]),j=!!v&&(!E&&v(T)),k=r.useCallback((function(){var e=a(S).slice(1);return w.apply(void 0,c([{current:m.current}],a(e),!1))}),[S,w]),L=r.useCallback((function(){E&&m.current>1&&(m.current-=1),O()}),[O,E]),P=r.useCallback((function(){E||j||(m.current+=1,k())}),[E,j,k]),A=r.useCallback((function(e){var n="function"==typeof e?e(T):e;g.current=(null==n?void 0:n.list)||[],R(n)}),[T,R]),x=r.useCallback((function(){return L(),m.current=1,A((function(e){return i(i({},e),{list:[]})})),k()}),[L,k,A]),I=r.useCallback((function(){if(!E&&s)return P()}),[P,s,E]);return ve({target:s,threshold:l,onScrollLower:I}),f((function(){(void 0===(null==n?void 0:n.autoRun)||(null==n?void 0:n.autoRun))&&Array.isArray(p)&&p.length>0&&x()}),p),i(i({},C),{loading:E,data:T,run:w,refresh:x,cancel:L,mutate:A,params:S,loadMore:P,loadingMore:E&&m.current>1,noMore:j})},e.useMergeState=function(e){var n=a(r.useState(e),2),t=n[0],o=n[1];return[t,r.useCallback((function(e){o((function(n){var t=e instanceof Function?e(n):e;return t instanceof Object?i(i({},n),t):n}))}),[])]},e.useMount=function(e){n.useEffect((function(){e()}),[])},e.useMountedRef=function(){var e=n.useRef(!1);return n.useEffect((function(){return e.current=!0,function(){e.current=!1}}),[]),e},e.usePagination=function(e,n){var t=n||{},u=t.defaultPageSize,l=void 0===u?10:u,s=t.refreshDeps,d=void 0===s?[]:s,v=t.defaultParams,h=o(t,["defaultPageSize","refreshDeps","defaultParams"]),p=r.useMemo((function(){return v||[{current:1,pageSize:l}]}),[l,v]),y=fe(e,i({defaultParams:p},h)),g=y.run,m=y.data,b=y.params,w=y.loading,T=o(y,["run","data","params","loading"]),E=b&&b[0]?b[0]:p[0],O=E.current,S=E.pageSize,R=(null==m?void 0:m.total)||0,C=r.useCallback((function(e){var n=a(b),t=n[0],r=n.slice(1);g.apply(void 0,c([i(i({},t),e)],a(r),!1))}),[b,g]),j=r.useCallback((function(){C({current:O,pageSize:S})}),[C,O,S]),k=r.useCallback((function(e,n){var t=e<=0?1:e,r=n<=0?1:n,i=Math.ceil(R/r);t>i&&i>0&&(t=i),C({current:t,pageSize:r})}),[C,R]),L=r.useCallback((function(e){k(e,S)}),[k,S]),P=r.useCallback((function(e){k(O,e)}),[O,k]),A=r.useCallback((function(e,n,t,r){C({current:null==e?void 0:e.current,pageSize:null==e?void 0:e.pageSize,filters:n,sorter:t,extra:r})}),[C]);return f((function(){(void 0===(null==n?void 0:n.autoRun)||(null==n?void 0:n.autoRun))&&Array.isArray(d)&&d.length>0&&L(1)}),d),i(i({},T),{data:m,run:g,refresh:j,loading:w,params:b,pagination:{current:O,pageSize:S,total:R,onChange:k,changeCurrent:L,changePageSize:P},tableProps:{dataSource:(null==m?void 0:m.list)||[],loading:w,onChange:A,pagination:{total:R,current:O,pageSize:S}}})},e.usePersistFn=l,e.usePrevious=function(e){var t=n.useRef();return n.useEffect((function(){t.current=e})),t.current},e.useSafeState=me,e.useSize=function(e){var t=a(n.useState((function(){var n=be(e);return{width:(n||{}).clientWidth,height:(n||{}).clientHeight}})),2),r=t[0],i=t[1];return n.useEffect((function(){var n=be(e);function t(e){e&&i({width:e.clientWidth,height:e.clientHeight})}if(!n)return function(){};t(n);var r=new Oe((function(e){var n,r;try{for(var i=u(e),o=i.next();!o.done;o=i.next()){t(o.value.target)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}));return r.observe(n),function(){r.disconnect()}}),[e]),r},e.useThrottle=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r={});var i=a(n.useState(e),2),o=i[0],u=ye(i[1],t,r).run;return n.useEffect((function(){u(e)}),[u,e]),o},e.useThrottleFn=ye,e.useUnmount=he,e.useUnmountedRef=ge,e.useUpdate=function(){var e=a(me(0),2)[1];return n.useCallback((function(){e((function(e){return e+1}))}),[])},e.useUpdateEffect=f,e.useUpdateLayoutEffect=function(e,t){var r=n.useRef(!1);n.useLayoutEffect((function(){if(r.current)return e();r.current=!0}),t)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).rcHooks={},e.React)}(this,(function(e,t){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var r=n(t),i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return u}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function l(e){var n=t.useRef(e);n.current=e;var r=t.useCallback((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n.current;return null==r?void 0:r.apply(void 0,c([],a(e),!1))}),[n]);return r}var f=function(e,n){var r=t.useRef(!1);t.useEffect((function(){if(r.current)return e();r.current=!0}),n)},s={},d=function(e){var t=s[e];if(t){var n=t.startTime,r=t.cacheTime,i=t.data;return(new Date).getTime()-n>=r?(t.timer&&clearTimeout(t.timer),void delete s[e]):i}},v=function(e,t,n){void 0===n&&(n=3e5),s[e]&&clearTimeout(s[e].timer);var r=setTimeout((function(){delete s[e]}),n);s[e]={data:t,timer:r,cacheTime:n,startTime:(new Date).getTime()}},h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var p=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},y="object"==typeof h&&h&&h.Object===Object&&h,g="object"==typeof self&&self&&self.Object===Object&&self,m=y||g||Function("return this")(),b=m,w=function(){return b.Date.now()},T=/\s/;var E=function(e){for(var t=e.length;t--&&T.test(e.charAt(t)););return t},O=/^\s+/;var S=function(e){return e?e.slice(0,E(e)+1).replace(O,""):e},R=m.Symbol,C=R,j=Object.prototype,k=j.hasOwnProperty,L=j.toString,P=C?C.toStringTag:void 0;var A=function(e){var t=k.call(e,P),n=e[P];try{e[P]=void 0;var r=!0}catch(e){}var i=L.call(e);return r&&(t?e[P]=n:delete e[P]),i},x=Object.prototype.toString;var I=A,M=function(e){return x.call(e)},_=R?R.toStringTag:void 0;var F=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":_&&_ in Object(e)?I(e):M(e)},N=function(e){return null!=e&&"object"==typeof e};var W=S,D=p,z=function(e){return"symbol"==typeof e||N(e)&&"[object Symbol]"==F(e)},H=/^[-+]0x[0-9a-f]+$/i,U=/^0b[01]+$/i,V=/^0o[0-7]+$/i,B=parseInt;var K=p,$=w,q=function(e){if("number"==typeof e)return e;if(z(e))return NaN;if(D(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=D(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=W(e);var n=U.test(e);return n||V.test(e)?B(e.slice(2),n?2:8):H.test(e)?NaN:+e},Y=Math.max,G=Math.min;var J=function(e,t,n){var r,i,o,u,a,c,l=0,f=!1,s=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var n=r,o=i;return r=i=void 0,l=t,u=e.apply(o,n)}function h(e){return l=e,a=setTimeout(y,t),f?v(e):u}function p(e){var n=e-c;return void 0===c||n>=t||n<0||s&&e-l>=o}function y(){var e=$();if(p(e))return g(e);a=setTimeout(y,function(e){var n=t-(e-c);return s?G(n,o-(e-l)):n}(e))}function g(e){return a=void 0,d&&r?v(e):(r=i=void 0,u)}function m(){var e=$(),n=p(e);if(r=arguments,i=this,c=e,n){if(void 0===a)return h(c);if(s)return clearTimeout(a),a=setTimeout(y,t),v(c)}return void 0===a&&(a=setTimeout(y,t)),u}return t=q(t)||0,K(n)&&(f=!!n.leading,o=(s="maxWait"in n)?Y(q(n.maxWait)||0,t):o,d="trailing"in n?!!n.trailing:d),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,r=c=i=a=void 0},m.flush=function(){return void 0===a?u:g($())},m},Q=J,X=p;var Z=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return X(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Q(e,t,{leading:r,maxWait:t,trailing:i})};function ee(){return"undefined"==typeof document||void 0===document.visibilityState||"hidden"!==document.visibilityState}var te=[];var ne=!1;if("undefined"!=typeof window&&window.addEventListener&&!ne){window.addEventListener("visibilitychange",(function(){if(ee())for(var e=0;e<te.length;e++){(0,te[e])()}}),!1),ne=!0}var re=[];var ie=!1;if("undefined"!=typeof window&&window.addEventListener&&!ie){var oe=function(){if(ee()&&("undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine))for(var e=0;e<re.length;e++){(0,re[e])()}};window.addEventListener("visibilitychange",oe,!1),window.addEventListener("focus",oe,!1),ie=!0}var ue={},ae=function(e,t){return t&&ue[t]?ue[t]:t?(ue[t]=e().then((function(e){return delete ue[t],e})).catch((function(e){return delete ue[t],Promise.reject(e)})),ue[t]):e()},ce=function(){function e(e,t){this.params=[],this.pollingWhenVisibleFlag=!1,this.pollingTimer=null,this.counter=1,this.destroyed=!1,this.async=e,this.options=i({cacheTime:3e5,persisted:!1,pollingWhenHidden:!0,refreshOnWindowFocus:!1,focusTimespan:5e3},t),this.unsubscribes=[],this.init()}return e.prototype.init=function(){var e,t,n,r,i=this.options,o=i.pollingInterval,u=i.refreshOnWindowFocus,l=i.focusTimespan;if(this.updateDebounce(),o&&this.unsubscribes.push((e=this.rePolling.bind(this),te.push(e),function(){var t=te.indexOf(e);te.splice(t,1)})),u){var f=(t=this.refresh.bind(this),n=l,r=!1,function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];r||(r=!0,t.apply(void 0,c([],a(e),!1)),setTimeout((function(){r=!1}),n))});this.unsubscribes.push(function(e){return re.push(e),function(){var t=re.indexOf(e);re.splice(t,1)}}(f))}},e.prototype.updateDebounce=function(){var e=this.options,t=e.debounceInterval,n=e.throttleInterval;this.debounce="number"==typeof t&&t>0?J(this._run,t):void 0,this.throttle="number"==typeof n&&n>0?Z(this._run,n):void 0},e.prototype.rePolling=function(){this.pollingWhenVisibleFlag&&(this.pollingWhenVisibleFlag=!1,this.refresh())},e.prototype.afterUpdateOptions=function(e,t){void 0===t&&(t={}),("debounceInterval"in t&&t.debounceInterval!==e.debounceInterval||"throttleInterval"in t&&t.throttleInterval!==e.throttleInterval)&&this.updateDebounce()},e.prototype.updateOptions=function(e){var t=this.options,n=i(i({},this.options),e);this.options=n,this.afterUpdateOptions(t,n)},e.prototype._run=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.pollingTimer&&clearTimeout(this.pollingTimer);var r=this.counter;this.params=t;var i=this.options,o=i.cacheKey,u=i.cacheTime,l=i.persisted,f=i.formatResult,s=i.onSuccess,h=i.onError,p=i.onFinally,y=i.onBefore,g=i.pollingWhenHidden,m=i.pollingInterval;return null==y||y(t),new Promise((function(n,i){var y;if(o&&l){var b=d(o);if(b&&r===e.counter)return null==s||s(b,t),void n(b)}null===(y=ae((function(){return e.async.apply(e,c([],a(t),!1))}),o))||void 0===y||y.then((function(i){if(r===e.counter){var a="function"==typeof f?f(i,t):i;o&&v(o,a,u),null==s||s(a,t),n(a)}})).catch((function(n){r===e.counter&&(null==h||h(n,t),i(n))})).finally((function(){if(r===e.counter&&(null==p||p(),m)){if(!ee()&&!g)return void(e.pollingWhenVisibleFlag=!0);e.pollingTimer=setTimeout((function(){e.run.apply(e,c([],a(t),!1))}),m)}}))}))},e.prototype.run=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.debounce?(this.debounce.apply(this,c([],a(e),!1)),Promise.resolve(null)):this.throttle?(this.throttle.apply(this,c([],a(e),!1)),Promise.resolve(null)):(this.counter+=1,this._run.apply(this,c([],a(e),!1)))},e.prototype.refresh=function(){return this.run.apply(this,c([],a(this.params),!1))},e.prototype.cancel=function(){this.debounce&&this.debounce.cancel(),this.throttle&&this.throttle.cancel(),this.pollingTimer&&(clearTimeout(this.pollingTimer),this.pollingTimer=null),this.counter+=1},e.prototype.destroy=function(e){void 0===e&&(e=!0),e&&this.cancel(),this.destroyed||(this.destroyed=!0,this.unsubscribes.forEach((function(e){return e()})),this.unsubscribes=[])},e.prototype.resume=function(){this.destroyed&&(this.destroyed=!1,this.init())},e}(),le=function(){};function fe(e,n){var r=n||{},o=r.autoRun,u=void 0===o||o,s=r.refreshDeps,v=void 0===s?[]:s,h=r.defaultParams,p=r.loadingDelay,y=r.__INTERNAL_FORMAT__,g=r.defaultLoading,m=void 0!==g&&g,b=r.initialData,w=r.cacheKey,T=void 0===w?"":w,E=r.cacheTime,O=void 0===E?3e5:E,S=r.persisted,R=void 0!==S&&S,C=r.onSuccess,j=void 0===C?le:C,k=r.onError,L=void 0===k?le:k,P=r.onFinally,A=void 0===P?le:P,x=r.onBefore,I=void 0===x?le:x,M=r.pollingInterval,_=void 0===M?0:M,F=r.pollingWhenHidden,N=void 0===F||F,W=r.refreshOnWindowFocus,D=void 0!==W&&W,z=r.focusTimespan,H=void 0===z?5e3:z,U=r.debounceInterval,V=r.throttleInterval,B=a(t.useState({params:[],loading:m,error:null,data:T?d(T):b}),2),K=B[0],$=B[1],q=t.useRef(null),Y=l(e),G=l(j),J=l(L),Q=l(A),X=l(I),Z=t.useRef(y);Z.current!==y&&(Z.current=y);var ee=t.useCallback((function(e){X(e),q.current&&clearTimeout(q.current),(T?d(T):void 0)&&R||($((function(t){return i(i({},t),{loading:!p,params:e})})),p&&(q.current=setTimeout((function(){$((function(e){return i(i({},e),{loading:!0})}))}),p)))}),[T,p,X,R]),te=t.useCallback((function(e,t){q.current&&clearTimeout(q.current),$((function(t){return i(i({},t),{data:e,error:null,loading:!1})})),G(e,t)}),[G]),ne=t.useCallback((function(e,t){q.current&&clearTimeout(q.current),$((function(t){return i(i({},t),{error:e,loading:!1})})),J(e,t)}),[J]),re=t.useRef();re.current||(re.current=new ce(Y,{cacheKey:T,cacheTime:O,persisted:R,formatResult:Z.current,onSuccess:te,onError:ne,onFinally:Q,onBefore:ee,debounceInterval:U,throttleInterval:V,pollingInterval:_,pollingWhenHidden:N,refreshOnWindowFocus:D,focusTimespan:H})),f((function(){re.current.updateOptions({cacheKey:T,cacheTime:O,persisted:R,formatResult:Z.current,onSuccess:te,onError:ne,onFinally:Q,onBefore:ee,debounceInterval:U,throttleInterval:V,pollingInterval:_,pollingWhenHidden:N,refreshOnWindowFocus:D,focusTimespan:H})}),[G,J,T,O,R,U,V,Q,X,_,N,D,H,te,ne,ee]);var ie=t.useCallback((function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(e=re.current).run.apply(e,c([],a(t),!1))}),[]),oe=t.useCallback((function(){return re.current.refresh()}),[]),ue=t.useCallback((function(){re.current.cancel(),q.current&&clearTimeout(q.current),$((function(e){return i(i({},e),{loading:!1})}))}),[]);return f((function(){u&&Array.isArray(v)&&v.length>0&&oe()}),c([u],a(v),!1)),t.useEffect((function(){if(u){var e=Array.isArray(h)?h:void 0!==h?[h]:[];ie.apply(void 0,c([],a(e),!1))}return re.current.resume(),function(){ue(),re.current.destroy(!1)}}),[]),i(i({},K),{run:ie,cancel:ue,mutate:function(e){$("function"==typeof e?function(t){return i(i({},t),{data:e(K.data)})}:function(t){return i(i({},t),{data:e})})},refresh:oe})}var se=function(e){return null!=e&&e===(null==e?void 0:e.window)};function de(e){return"function"==typeof e?e():e}var ve=function(e){var n=void 0===e?{}:e,r=n.target,i=n.threshold,o=void 0===i?100:i,u=n.onScrollLower,a=l(void 0===u?function(){}:u),c=t.useCallback((function(){if(r){var e,t=de(r);if(t)void 0===(e=t)&&(e=window),("undefined"==typeof window?0:se(e)?document.documentElement.scrollHeight:e.scrollHeight)-function(e){return void 0===e&&(e=window),"undefined"==typeof window?0:se(e)?window.scrollY:(null==e?void 0:e.scrollTop)||0}(t)<=function(e){return void 0===e&&(e=window),"undefined"==typeof window?0:se(e)?document.documentElement.clientHeight:e.clientHeight}(t)+o&&a()}}),[a,r,o]);t.useEffect((function(){if(r){var e=de(r);if(e)return e.addEventListener("scroll",c),function(){e.removeEventListener("scroll",c)}}}),[r,c])};var he=function(e){var n=t.useRef(e);n.current=e,t.useEffect((function(){return function(){return n.current()}}),[])};function pe(e,n,r){void 0===n&&(n=0),void 0===r&&(r={});var i=t.useRef(e);i.current=e;var o=t.useRef(J((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i.current.apply(i,c([],a(e),!1))}),n,r));return he((function(){o.current.cancel()})),{run:o.current,cancel:o.current.cancel,flush:o.current.flush}}function ye(e,n,r){void 0===n&&(n=0),void 0===r&&(r={});var i=t.useRef(e);i.current=e;var o=t.useRef(Z((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i.current.apply(i,c([],a(e),!1))}),n,r));return he((function(){o.current.cancel()})),{run:o.current,cancel:o.current.cancel,flush:o.current.flush}}var ge=function(){var e=r.useRef(!1);return r.useEffect((function(){return e.current=!1,function(){e.current=!0}}),[]),e};function me(e){var t=ge(),n=a(r.useState(e),2),i=n[0],o=n[1];return[i,r.useCallback((function(e){t.current||o(e)}),[])]}function be(e){return"function"==typeof e?e():e&&"current"in e?e.current:e}var we="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,Te=["top","right","bottom","left","width","height","size","weight"],Ee={characterData:!0,childList:!0,attributes:!0,subtree:!0},Oe=function(e){var t=this;this.refresh=function(){t.targetNode&&t.callback([{target:t.targetNode}],{})},this.onTransitionEnd_=function(e){var n=e.propertyName,r=void 0===n?"":n;Te.some((function(e){return r.indexOf(e)>-1}))&&t.throttleRefresh()},this.observe=function(e,n){we&&(t.targetNode=e,document.addEventListener("transitionend",t.onTransitionEnd_),window.addEventListener("resize",t.throttleRefresh),t.observer.observe(document,i(i({},Ee),n)))},this.disconnect=function(){we&&(t.throttleRefresh.cancel(),t.targetNode=null,document.removeEventListener("transitionend",t.onTransitionEnd_),window.removeEventListener("resize",t.throttleRefresh),t.observer.disconnect())},this.throttleRefresh=Z(this.refresh,50),this.targetNode=null,this.callback=e,this.observer=new MutationObserver(this.throttleRefresh)};e.clearCache=function(e){(void 0===e?Object.keys(s):Array.isArray(e)?e:[e]).forEach((function(e){s[e]&&(s[e].timer&&clearTimeout(s[e].timer),delete s[e])}))},e.useAsync=fe,e.useClickAway=function(e,t,n){void 0===n&&(n="click");var i=r.useRef(t);i.current=t,r.useEffect((function(){var t,r,o=function(t){var n;(Array.isArray(e)?e:[e]).some((function(e){var n=be(e);return!n||(null==n?void 0:n.contains(t.target))}))||null===(n=i.current)||void 0===n||n.call(i,t)},a=Array.isArray(n)?n:[n];try{for(var c=u(a),l=c.next();!l.done;l=c.next()){var f=l.value;document.addEventListener(f,o)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return function(){var e,t;try{for(var n=u(a),r=n.next();!r.done;r=n.next()){var i=r.value;document.removeEventListener(i,o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}}}),[e,n])},e.useClientRect=function(){var e=t.useRef(null),n=a(t.useState(),2),r=n[0],i=n[1];return t.useEffect((function(){var t;e.current&&i(null===(t=e.current)||void 0===t?void 0:t.getBoundingClientRect())}),[e]),[r,e]},e.useControllableValue=function(e,n){void 0===e&&(e={}),void 0===n&&(n={});var r=n.defaultValue,i=n.defaultValuePropName,o=void 0===i?"defaultValue":i,u=n.valuePropName,l=void 0===u?"value":u,s=n.trigger,d=void 0===s?"onChange":s,v=l in e,h=e[l],p=a(t.useState((function(){return v?h:o in e?e[o]:r})),2),y=p[0],g=p[1];f((function(){v&&g(h)}),[h,v]);var m=t.useCallback((function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];v||g(t),e[d]&&e[d].apply(e,c([t],a(n),!1))}),[v,e,d]);return[v?h:y,m]},e.useDebounce=function(e,n,r){void 0===n&&(n=0),void 0===r&&(r={});var i=a(t.useState(e),2),o=i[0],u=pe(i[1],n,r).run;return t.useEffect((function(){u(e)}),[u,e]),o},e.useDebounceFn=pe,e.useIsMounted=function(){var e=t.useRef(!1);return t.useEffect((function(){return e.current=!0,function(){e.current=!1}}),[]),e},e.useLimitList=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});var r=n||{},i=r.count,o=void 0===i?3:i,u=r.defaultLimited,c=void 0===u||u,l=t.useRef(c),f=t.useMemo((function(){return Array.isArray(e)?e:[]}),[e]),s=t.useMemo((function(){return o>0?Math.ceil(o):0}),[o]),d=t.useMemo((function(){return f.length>s}),[s,f.length]),v=a(t.useState((function(){return d&&c?f.slice(0,s):f})),2),h=v[0],p=v[1];return t.useEffect((function(){p(l.current?f.slice(0,s):f)}),[s,f]),{canLimit:d,limited:l.current,data:h,toggle:function(){d&&(l.current=!l.current),p(l.current?f.slice(0,s):f)}}},e.useLoadMore=function(e,t){var n=t||{},u=n.threshold,l=void 0===u?100:u,s=n.target,d=n.isNoMore,v=void 0===d?function(){return!1}:d,h=n.refreshDeps,p=void 0===h?[]:h,y=n.autoRun,g=void 0===y||y,m=o(n,["threshold","target","isNoMore","refreshDeps","autoRun"]),b=r.useRef([]),w=r.useRef(1),T=fe(e,i(i({defaultParams:[{current:w.current}],autoRun:g},m),{onError:function(e,t){var n;w.current>1&&(w.current-=1),null===(n=null==m?void 0:m.onError)||void 0===n||n.call(m,e,t)},__INTERNAL_FORMAT__:function(e){return b.current=1===w.current?e.list:b.current.concat(e.list),i(i({},e),{list:b.current})}})),E=T.run,O=T.data,S=T.loading,R=T.cancel,C=T.params,j=T.mutate,k=o(T,["run","data","loading","cancel","params","mutate"]),L=!!v&&(!S&&v(O)),P=r.useCallback((function(){var e=a(C).slice(1);return E.apply(void 0,c([{current:w.current}],a(e),!1))}),[C,E]),A=r.useCallback((function(){S&&w.current>1&&(w.current-=1),R()}),[R,S]),x=r.useCallback((function(){S||L||(w.current+=1,P())}),[S,L,P]),I=r.useCallback((function(e){var t="function"==typeof e?e(O):e;b.current=(null==t?void 0:t.list)||[],j(t)}),[O,j]),M=r.useCallback((function(){return A(),w.current=1,I((function(e){return i(i({},e),{list:[]})})),P()}),[A,P,I]),_=r.useCallback((function(){if(!S&&s)return x()}),[x,s,S]);return ve({target:s,threshold:l,onScrollLower:_}),f((function(){g&&Array.isArray(p)&&p.length>0&&M()}),p),i(i({},k),{loading:S,data:O,run:E,refresh:M,cancel:A,mutate:I,params:C,loadMore:x,loadingMore:S&&w.current>1,noMore:L})},e.useMergeState=function(e){var t=a(r.useState(e),2),n=t[0],o=t[1];return[n,r.useCallback((function(e){o((function(t){var n=e instanceof Function?e(t):e;return n instanceof Object?i(i({},t),n):t}))}),[])]},e.useMount=function(e){t.useEffect((function(){e()}),[])},e.useMountedRef=function(){var e=t.useRef(!1);return t.useEffect((function(){return e.current=!0,function(){e.current=!1}}),[]),e},e.usePagination=function(e,t){var n=t||{},u=n.defaultPageSize,l=void 0===u?10:u,s=n.refreshDeps,d=void 0===s?[]:s,v=n.defaultParams,h=n.autoRun,p=void 0===h||h,y=o(n,["defaultPageSize","refreshDeps","defaultParams","autoRun"]),g=r.useMemo((function(){return v||[{current:1,pageSize:l}]}),[l,v]),m=fe(e,i({defaultParams:g,autoRun:p},y)),b=m.run,w=m.data,T=m.params,E=m.loading,O=o(m,["run","data","params","loading"]),S=T&&T[0]?T[0]:g[0],R=S.current,C=S.pageSize,j=(null==w?void 0:w.total)||0,k=r.useCallback((function(e){var t=a(T),n=t[0],r=t.slice(1);b.apply(void 0,c([i(i({},n),e)],a(r),!1))}),[T,b]),L=r.useCallback((function(){k({current:R,pageSize:C})}),[k,R,C]),P=r.useCallback((function(e,t){var n=e<=0?1:e,r=t<=0?1:t,i=Math.ceil(j/r);n>i&&i>0&&(n=i),k({current:n,pageSize:r})}),[k,j]),A=r.useCallback((function(e){P(e,C)}),[P,C]),x=r.useCallback((function(e){P(R,e)}),[R,P]),I=r.useCallback((function(e,t,n,r){k({current:null==e?void 0:e.current,pageSize:null==e?void 0:e.pageSize,filters:t,sorter:n,extra:r})}),[k]);return f((function(){p&&Array.isArray(d)&&d.length>0&&A(1)}),d),i(i({},O),{data:w,run:b,refresh:L,loading:E,params:T,pagination:{current:R,pageSize:C,total:j,onChange:P,changeCurrent:A,changePageSize:x},tableProps:{dataSource:(null==w?void 0:w.list)||[],loading:E,onChange:I,pagination:{total:j,current:R,pageSize:C}}})},e.usePersistFn=l,e.usePrevious=function(e){var n=t.useRef();return t.useEffect((function(){n.current=e})),n.current},e.useSafeState=me,e.useSize=function(e){var n=a(t.useState((function(){var t=be(e);return{width:(t||{}).clientWidth,height:(t||{}).clientHeight}})),2),r=n[0],i=n[1];return t.useEffect((function(){var t=be(e);function n(e){e&&i({width:e.clientWidth,height:e.clientHeight})}if(!t)return function(){};n(t);var r=new Oe((function(e){var t,r;try{for(var i=u(e),o=i.next();!o.done;o=i.next()){n(o.value.target)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}));return r.observe(t),function(){r.disconnect()}}),[e]),r},e.useThrottle=function(e,n,r){void 0===n&&(n=0),void 0===r&&(r={});var i=a(t.useState(e),2),o=i[0],u=ye(i[1],n,r).run;return t.useEffect((function(){u(e)}),[u,e]),o},e.useThrottleFn=ye,e.useUnmount=he,e.useUnmountedRef=ge,e.useUpdate=function(){var e=a(me(0),2)[1];return t.useCallback((function(){e((function(e){return e+1}))}),[])},e.useUpdateEffect=f,e.useUpdateLayoutEffect=function(e,n){var r=t.useRef(!1);t.useLayoutEffect((function(){if(r.current)return e();r.current=!0}),n)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=rcHooks.min.js.map |
@@ -18,6 +18,6 @@ import { Options, AsyncFunction } from './Async'; | ||
declare function useAsync<R = any, P extends any[] = any[]>(asyncFn: AsyncFunction<R, P>, options?: AsyncOptions<R, P>): { | ||
run: (...args: P) => any; | ||
run: (...args: P) => Promise<null> | Promise<R>; | ||
cancel: () => void; | ||
mutate: (newData: R | ((oldData: R) => R) | undefined) => void; | ||
refresh: () => any; | ||
refresh: () => Promise<null> | Promise<R>; | ||
params: P; | ||
@@ -24,0 +24,0 @@ loading: boolean; |
@@ -66,2 +66,3 @@ import { __assign, __read, __spreadArray } from "tslib"; | ||
}, [onErrorPersist]); | ||
// @ts-ignore | ||
var asyncInstanceRef = useRef(); | ||
@@ -87,4 +88,3 @@ if (!asyncInstanceRef.current) { | ||
useUpdateEffect(function () { | ||
var _a; | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.updateOptions({ | ||
asyncInstanceRef.current.updateOptions({ | ||
cacheKey: cacheKey, | ||
@@ -130,12 +130,10 @@ cacheTime: cacheTime, | ||
} | ||
return (_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.run.apply(_a, __spreadArray([], __read(args), false)); | ||
return (_a = asyncInstanceRef.current).run.apply(_a, __spreadArray([], __read(args), false)); | ||
}, []); | ||
// 使用上一次执行异步的参数,重新执行 | ||
var refresh = useCallback(function () { | ||
var _a; | ||
return (_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.refresh(); | ||
return asyncInstanceRef.current.refresh(); | ||
}, []); | ||
var cancel = useCallback(function () { | ||
var _a; | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.cancel(); | ||
asyncInstanceRef.current.cancel(); | ||
// 取消延迟loading | ||
@@ -165,3 +163,2 @@ if (loadingDelayTimerRef.current) { | ||
useEffect(function () { | ||
var _a; | ||
// 默认自动执行 | ||
@@ -176,7 +173,6 @@ if (autoRun) { | ||
// 如果销毁过,可以重新恢复异步实例 | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.resume(); | ||
asyncInstanceRef.current.resume(); | ||
return function () { | ||
var _a; | ||
cancel(); | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy(false); | ||
asyncInstanceRef.current.destroy(false); | ||
}; | ||
@@ -183,0 +179,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps |
@@ -23,4 +23,4 @@ import type { AsyncOptions } from '.'; | ||
current: number; | ||
}, ...args: any[]) => any; | ||
refresh: () => any; | ||
}, ...args: any[]) => Promise<null> | Promise<R>; | ||
refresh: () => Promise<null> | Promise<R>; | ||
cancel: () => void; | ||
@@ -27,0 +27,0 @@ mutate: (newData: R | ((oldData: R) => R) | undefined) => void; |
@@ -7,10 +7,10 @@ import { __assign, __read, __rest, __spreadArray } from "tslib"; | ||
function useLoadMore(asyncFn, options) { | ||
var _a = (options || {}), _b = _a.threshold, threshold = _b === void 0 ? 100 : _b, target = _a.target, _c = _a.isNoMore, isNoMore = _c === void 0 ? function () { return false; } : _c, _d = _a.refreshDeps, refreshDeps = _d === void 0 ? [] : _d, restOptions = __rest(_a, ["threshold", "target", "isNoMore", "refreshDeps"]); | ||
var _a = (options || {}), _b = _a.threshold, threshold = _b === void 0 ? 100 : _b, target = _a.target, _c = _a.isNoMore, isNoMore = _c === void 0 ? function () { return false; } : _c, _d = _a.refreshDeps, refreshDeps = _d === void 0 ? [] : _d, _e = _a.autoRun, autoRun = _e === void 0 ? true : _e, restOptions = __rest(_a, ["threshold", "target", "isNoMore", "refreshDeps", "autoRun"]); | ||
var dataGroup = React.useRef([]); // 缓存之前请求的列表数据 | ||
var currentPageRef = React.useRef(1); // 当前页码 | ||
var _e = useAsync(asyncFn, __assign(__assign({ defaultParams: [ | ||
var _f = useAsync(asyncFn, __assign(__assign({ defaultParams: [ | ||
{ | ||
current: currentPageRef.current | ||
} | ||
] }, restOptions), { onError: function (err, _params) { | ||
], autoRun: autoRun }, restOptions), { onError: function (err, _params) { | ||
var _a; | ||
@@ -26,3 +26,3 @@ // 加载失败并且当前页码大于第一页,页码自减一 | ||
return __assign(__assign({}, res), { list: dataGroup.current }); | ||
} })), run = _e.run, data = _e.data, loading = _e.loading, reqCancel = _e.cancel, params = _e.params, reqMutate = _e.mutate, restAsyncReturn = __rest(_e, ["run", "data", "loading", "cancel", "params", "mutate"]); | ||
} })), run = _f.run, data = _f.data, loading = _f.loading, reqCancel = _f.cancel, params = _f.params, reqMutate = _f.mutate, restAsyncReturn = __rest(_f, ["run", "data", "loading", "cancel", "params", "mutate"]); | ||
var noMore = isNoMore ? !loading && isNoMore(data) : false; | ||
@@ -72,4 +72,3 @@ var loadData = React.useCallback(function () { | ||
useUpdateEffect(function () { | ||
var isAutoRun = typeof (options === null || options === void 0 ? void 0 : options.autoRun) === 'undefined' || (options === null || options === void 0 ? void 0 : options.autoRun); | ||
if (isAutoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
if (autoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
refresh(); | ||
@@ -76,0 +75,0 @@ } |
@@ -24,3 +24,3 @@ import type { AsyncOptions } from '.'; | ||
pageSize: number; | ||
}, ...args: any[]) => any; | ||
}, ...args: any[]) => Promise<null> | Promise<R>; | ||
refresh: () => void; | ||
@@ -27,0 +27,0 @@ loading: boolean; |
@@ -6,6 +6,6 @@ import { __assign, __read, __rest, __spreadArray } from "tslib"; | ||
export function usePagination(asyncFn, options) { | ||
var _a = options || {}, _b = _a.defaultPageSize, defaultPageSize = _b === void 0 ? 10 : _b, _c = _a.refreshDeps, refreshDeps = _c === void 0 ? [] : _c, defaultParamsProp = _a.defaultParams, restOptions = __rest(_a, ["defaultPageSize", "refreshDeps", "defaultParams"]); | ||
var _a = options || {}, _b = _a.defaultPageSize, defaultPageSize = _b === void 0 ? 10 : _b, _c = _a.refreshDeps, refreshDeps = _c === void 0 ? [] : _c, defaultParamsProp = _a.defaultParams, _d = _a.autoRun, autoRun = _d === void 0 ? true : _d, restOptions = __rest(_a, ["defaultPageSize", "refreshDeps", "defaultParams", "autoRun"]); | ||
var defaultParams = React.useMemo(function () { return defaultParamsProp || [{ current: 1, pageSize: defaultPageSize }]; }, [defaultPageSize, defaultParamsProp]); | ||
var _d = useAsync(asyncFn, __assign({ defaultParams: defaultParams }, restOptions)), run = _d.run, data = _d.data, params = _d.params, loading = _d.loading, restAsyncReturn = __rest(_d, ["run", "data", "params", "loading"]); | ||
var _e = params && params[0] ? params[0] : defaultParams[0], current = _e.current, pageSize = _e.pageSize; | ||
var _e = useAsync(asyncFn, __assign({ defaultParams: defaultParams, autoRun: autoRun }, restOptions)), run = _e.run, data = _e.data, params = _e.params, loading = _e.loading, restAsyncReturn = __rest(_e, ["run", "data", "params", "loading"]); | ||
var _f = params && params[0] ? params[0] : defaultParams[0], current = _f.current, pageSize = _f.pageSize; | ||
var total = (data === null || data === void 0 ? void 0 : data.total) || 0; | ||
@@ -47,4 +47,3 @@ var changePagination = React.useCallback(function (pagination) { | ||
useUpdateEffect(function () { | ||
var isAutoRun = typeof (options === null || options === void 0 ? void 0 : options.autoRun) === 'undefined' || (options === null || options === void 0 ? void 0 : options.autoRun); | ||
if (isAutoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
if (autoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
changeCurrent(1); | ||
@@ -51,0 +50,0 @@ } |
@@ -18,6 +18,6 @@ import { Options, AsyncFunction } from './Async'; | ||
declare function useAsync<R = any, P extends any[] = any[]>(asyncFn: AsyncFunction<R, P>, options?: AsyncOptions<R, P>): { | ||
run: (...args: P) => any; | ||
run: (...args: P) => Promise<null> | Promise<R>; | ||
cancel: () => void; | ||
mutate: (newData: R | ((oldData: R) => R) | undefined) => void; | ||
refresh: () => any; | ||
refresh: () => Promise<null> | Promise<R>; | ||
params: P; | ||
@@ -24,0 +24,0 @@ loading: boolean; |
@@ -68,2 +68,3 @@ "use strict"; | ||
}, [onErrorPersist]); | ||
// @ts-ignore | ||
var asyncInstanceRef = (0, react_1.useRef)(); | ||
@@ -89,4 +90,3 @@ if (!asyncInstanceRef.current) { | ||
(0, useUpdateEffect_1.default)(function () { | ||
var _a; | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.updateOptions({ | ||
asyncInstanceRef.current.updateOptions({ | ||
cacheKey: cacheKey, | ||
@@ -132,12 +132,10 @@ cacheTime: cacheTime, | ||
} | ||
return (_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.run.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)); | ||
return (_a = asyncInstanceRef.current).run.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)); | ||
}, []); | ||
// 使用上一次执行异步的参数,重新执行 | ||
var refresh = (0, react_1.useCallback)(function () { | ||
var _a; | ||
return (_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.refresh(); | ||
return asyncInstanceRef.current.refresh(); | ||
}, []); | ||
var cancel = (0, react_1.useCallback)(function () { | ||
var _a; | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.cancel(); | ||
asyncInstanceRef.current.cancel(); | ||
// 取消延迟loading | ||
@@ -167,3 +165,2 @@ if (loadingDelayTimerRef.current) { | ||
(0, react_1.useEffect)(function () { | ||
var _a; | ||
// 默认自动执行 | ||
@@ -178,7 +175,6 @@ if (autoRun) { | ||
// 如果销毁过,可以重新恢复异步实例 | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.resume(); | ||
asyncInstanceRef.current.resume(); | ||
return function () { | ||
var _a; | ||
cancel(); | ||
(_a = asyncInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy(false); | ||
asyncInstanceRef.current.destroy(false); | ||
}; | ||
@@ -185,0 +181,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps |
@@ -23,4 +23,4 @@ import type { AsyncOptions } from '.'; | ||
current: number; | ||
}, ...args: any[]) => any; | ||
refresh: () => any; | ||
}, ...args: any[]) => Promise<null> | Promise<R>; | ||
refresh: () => Promise<null> | Promise<R>; | ||
cancel: () => void; | ||
@@ -27,0 +27,0 @@ mutate: (newData: R | ((oldData: R) => R) | undefined) => void; |
@@ -9,10 +9,10 @@ "use strict"; | ||
function useLoadMore(asyncFn, options) { | ||
var _a = (options || {}), _b = _a.threshold, threshold = _b === void 0 ? 100 : _b, target = _a.target, _c = _a.isNoMore, isNoMore = _c === void 0 ? function () { return false; } : _c, _d = _a.refreshDeps, refreshDeps = _d === void 0 ? [] : _d, restOptions = tslib_1.__rest(_a, ["threshold", "target", "isNoMore", "refreshDeps"]); | ||
var _a = (options || {}), _b = _a.threshold, threshold = _b === void 0 ? 100 : _b, target = _a.target, _c = _a.isNoMore, isNoMore = _c === void 0 ? function () { return false; } : _c, _d = _a.refreshDeps, refreshDeps = _d === void 0 ? [] : _d, _e = _a.autoRun, autoRun = _e === void 0 ? true : _e, restOptions = tslib_1.__rest(_a, ["threshold", "target", "isNoMore", "refreshDeps", "autoRun"]); | ||
var dataGroup = React.useRef([]); // 缓存之前请求的列表数据 | ||
var currentPageRef = React.useRef(1); // 当前页码 | ||
var _e = (0, _1.default)(asyncFn, tslib_1.__assign(tslib_1.__assign({ defaultParams: [ | ||
var _f = (0, _1.default)(asyncFn, tslib_1.__assign(tslib_1.__assign({ defaultParams: [ | ||
{ | ||
current: currentPageRef.current | ||
} | ||
] }, restOptions), { onError: function (err, _params) { | ||
], autoRun: autoRun }, restOptions), { onError: function (err, _params) { | ||
var _a; | ||
@@ -28,3 +28,3 @@ // 加载失败并且当前页码大于第一页,页码自减一 | ||
return tslib_1.__assign(tslib_1.__assign({}, res), { list: dataGroup.current }); | ||
} })), run = _e.run, data = _e.data, loading = _e.loading, reqCancel = _e.cancel, params = _e.params, reqMutate = _e.mutate, restAsyncReturn = tslib_1.__rest(_e, ["run", "data", "loading", "cancel", "params", "mutate"]); | ||
} })), run = _f.run, data = _f.data, loading = _f.loading, reqCancel = _f.cancel, params = _f.params, reqMutate = _f.mutate, restAsyncReturn = tslib_1.__rest(_f, ["run", "data", "loading", "cancel", "params", "mutate"]); | ||
var noMore = isNoMore ? !loading && isNoMore(data) : false; | ||
@@ -74,4 +74,3 @@ var loadData = React.useCallback(function () { | ||
(0, useUpdateEffect_1.default)(function () { | ||
var isAutoRun = typeof (options === null || options === void 0 ? void 0 : options.autoRun) === 'undefined' || (options === null || options === void 0 ? void 0 : options.autoRun); | ||
if (isAutoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
if (autoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
refresh(); | ||
@@ -78,0 +77,0 @@ } |
@@ -24,3 +24,3 @@ import type { AsyncOptions } from '.'; | ||
pageSize: number; | ||
}, ...args: any[]) => any; | ||
}, ...args: any[]) => Promise<null> | Promise<R>; | ||
refresh: () => void; | ||
@@ -27,0 +27,0 @@ loading: boolean; |
@@ -9,6 +9,6 @@ "use strict"; | ||
function usePagination(asyncFn, options) { | ||
var _a = options || {}, _b = _a.defaultPageSize, defaultPageSize = _b === void 0 ? 10 : _b, _c = _a.refreshDeps, refreshDeps = _c === void 0 ? [] : _c, defaultParamsProp = _a.defaultParams, restOptions = tslib_1.__rest(_a, ["defaultPageSize", "refreshDeps", "defaultParams"]); | ||
var _a = options || {}, _b = _a.defaultPageSize, defaultPageSize = _b === void 0 ? 10 : _b, _c = _a.refreshDeps, refreshDeps = _c === void 0 ? [] : _c, defaultParamsProp = _a.defaultParams, _d = _a.autoRun, autoRun = _d === void 0 ? true : _d, restOptions = tslib_1.__rest(_a, ["defaultPageSize", "refreshDeps", "defaultParams", "autoRun"]); | ||
var defaultParams = React.useMemo(function () { return defaultParamsProp || [{ current: 1, pageSize: defaultPageSize }]; }, [defaultPageSize, defaultParamsProp]); | ||
var _d = (0, _1.default)(asyncFn, tslib_1.__assign({ defaultParams: defaultParams }, restOptions)), run = _d.run, data = _d.data, params = _d.params, loading = _d.loading, restAsyncReturn = tslib_1.__rest(_d, ["run", "data", "params", "loading"]); | ||
var _e = params && params[0] ? params[0] : defaultParams[0], current = _e.current, pageSize = _e.pageSize; | ||
var _e = (0, _1.default)(asyncFn, tslib_1.__assign({ defaultParams: defaultParams, autoRun: autoRun }, restOptions)), run = _e.run, data = _e.data, params = _e.params, loading = _e.loading, restAsyncReturn = tslib_1.__rest(_e, ["run", "data", "params", "loading"]); | ||
var _f = params && params[0] ? params[0] : defaultParams[0], current = _f.current, pageSize = _f.pageSize; | ||
var total = (data === null || data === void 0 ? void 0 : data.total) || 0; | ||
@@ -50,4 +50,3 @@ var changePagination = React.useCallback(function (pagination) { | ||
(0, useUpdateEffect_1.default)(function () { | ||
var isAutoRun = typeof (options === null || options === void 0 ? void 0 : options.autoRun) === 'undefined' || (options === null || options === void 0 ? void 0 : options.autoRun); | ||
if (isAutoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
if (autoRun && Array.isArray(refreshDeps) && refreshDeps.length > 0) { | ||
changeCurrent(1); | ||
@@ -54,0 +53,0 @@ } |
{ | ||
"name": "rc-hooks", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "React Hooks Library.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
354287
5315