react-cascader-popover
Version:
react级联选择器/支持多选/单选
29 lines (25 loc) • 33.2 kB
JavaScript
(function(X,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("tslib"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","tslib","react","react-dom"],m):(X=typeof globalThis<"u"?globalThis:X||self,m(X["react-cascader-popover"]={},X.tslib,X.React,X["react-dom"]))})(this,function(X,m,A,Ke){"use strict";var Pe=document.createElement("style");Pe.textContent=`.Popover{position:fixed;right:0;bottom:0;top:0;left:0;z-index:1300}.Popover-root{opacity:0;position:absolute;transition:opacity .1s ease-in}.Popover-root-hide{opacity:0}.Popover-root-show{opacity:1}.Popover-invisible{position:fixed;right:0;bottom:0;top:0;left:0;opacity:1;transition:opacity .3s linear}.svgIcon-root{fill:currentColor}.arrow-icon{width:15px;height:15px;color:#8190b8}.checkbox{width:20px;height:20px}.svgBox{display:flex;align-items:center}.indeterminate-checkbox,.checked-checkbox{color:#7a88fe}.load-icon{width:15px;height:15px;animation:rotate-loading .9s linear infinite}@keyframes rotate-loading{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.cascader_popover{display:flex;border:1px solid #7a88fe;background:#fff;border-radius:10px;margin-top:5px;max-height:350px;height:300px;overflow-y:hidden}.cascader_popover_cell{padding:5px;border-left:1px solid #c0c7db;height:100%;overflow-y:auto}.cascader_popover_cell::-webkit-scrollbar{width:5px}.cascader_popover_cell::-webkit-scrollbar-track{background:#f5f5f5;border-radius:40px}.cascader_popover_cell::-webkit-scrollbar-thumb{border-radius:40px;background:#7a88fe}::-webkit-scrollbar-thumb:hover{cursor:"pointer"}.cascader_popover_cell*{scrollbar-width:thin;scrollbar-color:#7a88fe transparent}.cascader_popover_cell:first-child{border:0}.cascader_popover_cell_label_box{height:40px;background:#fff;border-radius:7px;padding:5px 5px 5px 10px;cursor:pointer;font-size:13px;display:flex;align-items:center;color:#242859;justify-content:space-between;box-sizing:border-box}.cascader_popover_cell_label_box_ac{background:#f7f8ff;color:#7a88fe;transition:all .3s linear}.cascader_popover_cell_label_box .label .icon{color:#8190b8;display:flex;align-items:center;margin-right:3px}.cascader_popover_cell_label_box .label{margin-right:10px;display:flex;align-items:center;font-size:13px}.cascader_popover_cell_label_box:hover .svgIcon-root{color:#7a88fe}.cascader_popover_cell_label_box:hover{background:#f7f8ff;color:#7a88fe;transition:all .3s linear}.cascader_popover_cell .MuiFormControlLabel-root .MuiCheckbox-indeterminate{color:#7a88fe}.cascader_popover_cell_label_box_arrow{display:flex;align-items:center;justify-content:center}.cascader_popover_cell_label_box_disabled{opacity:.7;color:#8190b8;background:transparent;height:40px;background:#fff;border-radius:7px;padding:5px 5px 5px 10px;font-size:13px;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;cursor:no-drop}.cascader_popover_cell_label_box_disabled .svgIcon-root{color:#8190b8;display:flex;align-items:center;margin-right:3px;opacity:.7}.cascader_popover_cell_label_box_disabled .label{margin-right:10px;display:flex;align-items:center;font-size:13px}.searchList{border:1px solid #7a88fe;background:#fff;border-radius:10px;margin-top:5px;max-height:350px;height:300px;overflow-y:hidden}.searchList .label{margin-right:0}.cascader_search_box{margin-top:5px;height:35px;background:#fff;border-radius:5px;border:1px solid #7a88fe;box-sizing:border-box;display:flex;align-items:center;overflow:hidden;position:relative}.cascader_search_input{width:100%;padding:0 10px;border:0;height:90%;outline:0;position:absolute;box-sizing:border-box}.slash{margin:0 4px}.search_text_ac{color:red}.empty_data{width:150px;height:80px;display:flex;justify-content:center;align-items:center;border:1px solid #7a88fe;background:#fff;border-radius:10px;margin-top:5px;font-size:13px;color:#999;letter-spacing:3px;cursor:no-drop}.icon{color:#8190b8;display:flex;align-items:center;margin-right:3px}.cascader_popover_cell_label_disabled{margin-top:5px;height:35px;background:#fff;border-radius:5px;border:1px solid #7a88fe;box-sizing:border-box;display:flex;align-items:center;overflow:hidden;position:relative}
`,document.head.appendChild(Pe);var xe={exports:{}},oe={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Se;function Xe(){return Se||(Se=1,process.env.NODE_ENV!=="production"&&function(){var d=A,E=Symbol.for("react.element"),b=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),T=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),z=Symbol.iterator,I="@@iterator";function W(e){if(e===null||typeof e!="object")return null;var r=z&&e[z]||e[I];return typeof r=="function"?r:null}var Y=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),h=1;h<r;h++)n[h-1]=arguments[h];$("error",e,n)}}function $(e,r,n){{var h=Y.ReactDebugCurrentFrame,C=h.getStackAddendum();C!==""&&(r+="%s",n=n.concat([C]));var j=n.map(function(w){return String(w)});j.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,j)}}var le=!1,ye=!1,fe=!1,me=!1,ce=!1,de;de=Symbol.for("react.module.reference");function Ee(e){return!!(typeof e=="string"||typeof e=="function"||e===p||e===k||ce||e===x||e===P||e===S||me||e===V||le||ye||fe||typeof e=="object"&&e!==null&&(e.$$typeof===L||e.$$typeof===R||e.$$typeof===i||e.$$typeof===T||e.$$typeof===v||e.$$typeof===de||e.getModuleId!==void 0))}function we(e,r,n){var h=e.displayName;if(h)return h;var C=r.displayName||r.name||"";return C!==""?n+"("+C+")":n}function ve(e){return e.displayName||"Context"}function H(e){if(e==null)return null;if(typeof e.tag=="number"&&O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case p:return"Fragment";case b:return"Portal";case k:return"Profiler";case x:return"StrictMode";case P:return"Suspense";case S:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case T:var r=e;return ve(r)+".Consumer";case i:var n=e;return ve(n._context)+".Provider";case v:return we(e,e.render,"ForwardRef");case R:var h=e.displayName||null;return h!==null?h:H(e.type)||"Memo";case L:{var C=e,j=C._payload,w=C._init;try{return H(w(j))}catch{return null}}}return null}var K=Object.assign,Q=0,ee,he,pe,_e,l,s,a;function c(){}c.__reactDisabledLog=!0;function u(){{if(Q===0){ee=console.log,he=console.info,pe=console.warn,_e=console.error,l=console.group,s=console.groupCollapsed,a=console.groupEnd;var e={configurable:!0,enumerable:!0,value:c,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Q++}}function t(){{if(Q--,Q===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},e,{value:ee}),info:K({},e,{value:he}),warn:K({},e,{value:pe}),error:K({},e,{value:_e}),group:K({},e,{value:l}),groupCollapsed:K({},e,{value:s}),groupEnd:K({},e,{value:a})})}Q<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _=Y.ReactCurrentDispatcher,M;function f(e,r,n){{if(M===void 0)try{throw Error()}catch(C){var h=C.stack.trim().match(/\n( *(at )?)/);M=h&&h[1]||""}return`
`+M+e}}var J=!1,G;{var re=typeof WeakMap=="function"?WeakMap:Map;G=new re}function g(e,r){if(!e||J)return"";{var n=G.get(e);if(n!==void 0)return n}var h;J=!0;var C=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var j;j=_.current,_.current=null,u();try{if(r){var w=function(){throw Error()};if(Object.defineProperty(w.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(w,[])}catch(Z){h=Z}Reflect.construct(e,[],w)}else{try{w.call()}catch(Z){h=Z}e.call(w.prototype)}}else{try{throw Error()}catch(Z){h=Z}e()}}catch(Z){if(Z&&h&&typeof Z.stack=="string"){for(var y=Z.stack.split(`
`),B=h.stack.split(`
`),N=y.length-1,D=B.length-1;N>=1&&D>=0&&y[N]!==B[D];)D--;for(;N>=1&&D>=0;N--,D--)if(y[N]!==B[D]){if(N!==1||D!==1)do if(N--,D--,D<0||y[N]!==B[D]){var U=`
`+y[N].replace(" at new "," at ");return e.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",e.displayName)),typeof e=="function"&&G.set(e,U),U}while(N>=1&&D>=0);break}}}finally{J=!1,_.current=j,t(),Error.prepareStackTrace=C}var te=e?e.displayName||e.name:"",Ge=te?f(te):"";return typeof e=="function"&&G.set(e,Ge),Ge}function F(e,r,n){return g(e,!1)}function ae(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function q(e,r,n){if(e==null)return"";if(typeof e=="function")return g(e,ae(e));if(typeof e=="string")return f(e);switch(e){case P:return f("Suspense");case S:return f("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return F(e.render);case R:return q(e.type,r,n);case L:{var h=e,C=h._payload,j=h._init;try{return q(j(C),r,n)}catch{}}}return""}var ge=Object.prototype.hasOwnProperty,De={},Fe=Y.ReactDebugCurrentFrame;function be(e){if(e){var r=e._owner,n=q(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(n)}else Fe.setExtraStackFrame(null)}function tr(e,r,n,h,C){{var j=Function.call.bind(ge);for(var w in e)if(j(e,w)){var y=void 0;try{if(typeof e[w]!="function"){var B=Error((h||"React class")+": "+n+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw B.name="Invariant Violation",B}y=e[w](r,w,h,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(N){y=N}y&&!(y instanceof Error)&&(be(C),O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",h||"React class",n,w,typeof y),be(null)),y instanceof Error&&!(y.message in De)&&(De[y.message]=!0,be(C),O("Failed %s type: %s",n,y.message),be(null))}}}var or=Array.isArray;function ke(e){return or(e)}function ir(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function lr(e){try{return Ve(e),!1}catch{return!0}}function Ve(e){return""+e}function We(e){if(lr(e))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ir(e)),Ve(e)}var se=Y.ReactCurrentOwner,cr={key:!0,ref:!0,__self:!0,__source:!0},Me,ze,Ce;Ce={};function sr(e){if(ge.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ur(e){if(ge.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function fr(e,r){if(typeof e.ref=="string"&&se.current&&r&&se.current.stateNode!==r){var n=H(se.current.type);Ce[n]||(O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',H(se.current.type),e.ref),Ce[n]=!0)}}function dr(e,r){{var n=function(){Me||(Me=!0,O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function vr(e,r){{var n=function(){ze||(ze=!0,O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var hr=function(e,r,n,h,C,j,w){var y={$$typeof:E,type:e,key:r,ref:n,props:w,_owner:j};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function pr(e,r,n,h,C){{var j,w={},y=null,B=null;n!==void 0&&(We(n),y=""+n),ur(r)&&(We(r.key),y=""+r.key),sr(r)&&(B=r.ref,fr(r,C));for(j in r)ge.call(r,j)&&!cr.hasOwnProperty(j)&&(w[j]=r[j]);if(e&&e.defaultProps){var N=e.defaultProps;for(j in N)w[j]===void 0&&(w[j]=N[j])}if(y||B){var D=typeof e=="function"?e.displayName||e.name||"Unknown":e;y&&dr(w,D),B&&vr(w,D)}return hr(e,y,B,C,h,se.current,w)}}var Re=Y.ReactCurrentOwner,Ye=Y.ReactDebugCurrentFrame;function ne(e){if(e){var r=e._owner,n=q(e.type,e._source,r?r.type:null);Ye.setExtraStackFrame(n)}else Ye.setExtraStackFrame(null)}var je;je=!1;function Te(e){return typeof e=="object"&&e!==null&&e.$$typeof===E}function Be(){{if(Re.current){var e=H(Re.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function _r(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),n=e.lineNumber;return`
Check your code at `+r+":"+n+"."}return""}}var Ie={};function gr(e){{var r=Be();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=`
Check the top-level render call using <`+n+">.")}return r}}function Ue(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=gr(r);if(Ie[n])return;Ie[n]=!0;var h="";e&&e._owner&&e._owner!==Re.current&&(h=" It was passed a child from "+H(e._owner.type)+"."),ne(e),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,h),ne(null)}}function He(e,r){{if(typeof e!="object")return;if(ke(e))for(var n=0;n<e.length;n++){var h=e[n];Te(h)&&Ue(h,r)}else if(Te(e))e._store&&(e._store.validated=!0);else if(e){var C=W(e);if(typeof C=="function"&&C!==e.entries)for(var j=C.call(e),w;!(w=j.next()).done;)Te(w.value)&&Ue(w.value,r)}}}function br(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===v||r.$$typeof===R))n=r.propTypes;else return;if(n){var h=H(r);tr(n,e.props,"prop",h,e)}else if(r.PropTypes!==void 0&&!je){je=!0;var C=H(r);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xr(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var h=r[n];if(h!=="children"&&h!=="key"){ne(e),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",h),ne(null);break}}e.ref!==null&&(ne(e),O("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}}function Je(e,r,n,h,C,j){{var w=Ee(e);if(!w){var y="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var B=_r(C);B?y+=B:y+=Be();var N;e===null?N="null":ke(e)?N="array":e!==void 0&&e.$$typeof===E?(N="<"+(H(e.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):N=typeof e,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",N,y)}var D=pr(e,r,n,C,j);if(D==null)return D;if(w){var U=r.children;if(U!==void 0)if(h)if(ke(U)){for(var te=0;te<U.length;te++)He(U[te],e);Object.freeze&&Object.freeze(U)}else O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else He(U,e)}return e===p?xr(D):br(D),D}}function yr(e,r,n){return Je(e,r,n,!0)}function mr(e,r,n){return Je(e,r,n,!1)}var Er=mr,wr=yr;oe.Fragment=p,oe.jsx=Er,oe.jsxs=wr}()),oe}var ie={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Oe;function Ze(){if(Oe)return ie;Oe=1;var d=A,E=Symbol.for("react.element"),b=Symbol.for("react.fragment"),p=Object.prototype.hasOwnProperty,x=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,k={key:!0,ref:!0,__self:!0,__source:!0};function i(T,v,P){var S,R={},L=null,V=null;P!==void 0&&(L=""+P),v.key!==void 0&&(L=""+v.key),v.ref!==void 0&&(V=v.ref);for(S in v)p.call(v,S)&&!k.hasOwnProperty(S)&&(R[S]=v[S]);if(T&&T.defaultProps)for(S in v=T.defaultProps,v)R[S]===void 0&&(R[S]=v[S]);return{$$typeof:E,type:T,key:L,ref:V,props:R,_owner:x.current}}return ie.Fragment=b,ie.jsx=i,ie.jsxs=i,ie}process.env.NODE_ENV==="production"?xe.exports=Ze():xe.exports=Xe();var o=xe.exports,ue=function(d){if(d===null||typeof d!="object")return d;var E=Array.isArray(d)?[]:{};for(var b in d)Object.prototype.hasOwnProperty.call(d,b)&&(E[b]=ue(d[b]));return Array.isArray(d)&&(E.length=d.length),E},Qe=function(d,E){for(var b=[],p=[],x=function(v,P,S){if(E.includes(v.value)&&(b.push(m.__spreadArray(m.__spreadArray([],P,!0),[v.value],!1)),p.push(m.__spreadArray(m.__spreadArray([],S,!0),[v.label],!1))),v.children)for(var R=0,L=v.children;R<L.length;R++){var V=L[R];x(V,m.__spreadArray(m.__spreadArray([],P,!0),[v.value],!1),m.__spreadArray(m.__spreadArray([],S,!0),[v.label],!1))}},k=0,i=d;k<i.length;k++){var T=i[k];x(T,[],[])}return{valueResult:b,labelResult:p}},Ae=function(d,E,b){b===void 0&&(b=""),d.forEach(function(p,x){var k,i=b!==""?"".concat(b,"-").concat(x+1):"".concat(x+1);p.cascaderNodeId=i,p.checked=!1,p.indeterminateChecked=!1,E.forEach(function(T){T.includes(p.value)&&(p.checked=!1,p.indeterminateChecked=!0)}),p.parentCascaderNodeId=b,p.children&&p.children.length?(Ae(p.children,E,i),!((k=p.children)===null||k===void 0)&&k.every(function(T){return T.checked})&&(p.checked=!0,p.indeterminateChecked=!1)):E.forEach(function(T){T.includes(p.value)&&(p.checked=!0,p.indeterminateChecked=!1)})})};function qe(d,E){var b;return function(){for(var p=this,x=[],k=0;k<arguments.length;k++)x[k]=arguments[k];clearTimeout(b),b=setTimeout(function(){d.apply(p,x)},E)}}var Le=function(d,E,b,p){return E===void 0&&(E=""),b===void 0&&(b=""),p===void 0&&(p=[]),d.forEach(function(x){var k,i=E?"".concat(E," / ").concat(x.label):x.label,T=b?"".concat(b,"/").concat(x.value):x.value;x.children&&x.children.length>0&&!x.disabled?Le(x.children,i,T,p):!x.isLoad&&(!x.children||((k=x.children)===null||k===void 0?void 0:k.length)===0)&&p.push({value:"",disabled:x.disabled,pathName:i,pathValue:T})}),p},$e=function(d){var E=A.useRef(null),b=A.useState(!1),p=b[0],x=b[1],k=A.useState(window.innerWidth),i=k[0],T=k[1],v=A.useState(!0),P=v[0],S=v[1],R=A.useState({top:0,left:0}),L=R[0],V=R[1],z=function(W){W.isDefaultPrevented(),setTimeout(function(){d.onClose()},100)},I=function(W){W.preventDefault()};return A.useEffect(function(){var W=function(){T(window.innerWidth)};return window.addEventListener("resize",qe(W,200)),function(){window.removeEventListener("resize",W)}},[]),A.useEffect(function(){if(E.current&&d.anchorEl){var W=d.anchorEl.getBoundingClientRect(),Y=W.top+d.anchorEl.offsetHeight,O=window.innerHeight-Y;if(O>E.current.offsetHeight)V({top:Y,left:W.left});else{var $=Y-(E.current.offsetHeight-O);V({top:$-20,left:W.left})}}},[E.current,i]),A.useEffect(function(){if(d.open){x(d.open),setTimeout(function(){S(!1)},100);var W=window.innerWidth-document.documentElement.clientWidth;document.body.style.overflow="hidden",document.body.style.paddingRight="".concat(W,"px"),window.addEventListener("scroll",I,{passive:!1})}else S(!0),setTimeout(function(){x(d.open)},100),document.body.style.overflow="",document.body.style.paddingRight="",window.removeEventListener("scroll",I);return function(){window.removeEventListener("scroll",I)}},[d.open]),Ke.createPortal(o.jsx(o.Fragment,{children:p?o.jsxs("div",{id:"popover-cascader",className:"Popover",children:[o.jsx("div",{onClick:z,className:"Popover-invisible"}),o.jsx("div",{ref:E,className:(P?"Popover-root-hide":"Popover-root-show")+" Popover-root",style:{top:L.top,left:L.left},children:d.children})]}):o.jsx(o.Fragment,{})}),document.body)},er=function(){return o.jsx("svg",{color:"#8190b8",className:"svgIcon-root arrow-icon",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M7.38 21.01c.49.49 1.28.49 1.77 0l8.31-8.31c.39-.39.39-1.02 0-1.41L9.15 2.98c-.49-.49-1.28-.49-1.77 0s-.49 1.28 0 1.77L14.62 12l-7.25 7.25c-.48.48-.48 1.28.01 1.76"})})},Ne=function(d){var E=d.checked,b=E===void 0?!1:E,p=d.indeterminate,x=p===void 0?!1:p,k=d.onClick,i=k===void 0?function(){}:k;return o.jsx("span",{onClick:i,className:"svgBox",children:x?o.jsx("svg",{className:"svgIcon-root checkbox indeterminate-checkbox",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"})}):b?o.jsx("svg",{className:"svgIcon-root checkbox checked-checkbox ",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})}):o.jsx("svg",{className:"svgIcon-root checkbox",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"})})})},rr=function(){return o.jsx("svg",{className:"load-icon",width:"54.408",height:"54.408",viewBox:"0 0 54.408 54.408",children:o.jsxs("g",{transform:"translate(727.5 -147.5)",children:[o.jsx("path",{d:"M1276.926-1326.907a27.035,27.035,0,0,1-10.59-2.139,27.11,27.11,0,0,1-8.646-5.829,27.111,27.111,0,0,1-5.829-8.646,27.035,27.035,0,0,1-2.139-10.589,27.037,27.037,0,0,1,2.139-10.59,27.111,27.111,0,0,1,5.829-8.646,27.111,27.111,0,0,1,8.646-5.829,27.037,27.037,0,0,1,10.59-2.139v5a22.229,22.229,0,0,0-22.2,22.2,22.229,22.229,0,0,0,22.2,22.2,22.229,22.229,0,0,0,22.2-22.2h5a27.033,27.033,0,0,1-2.139,10.589,27.11,27.11,0,0,1-5.829,8.646,27.11,27.11,0,0,1-8.646,5.829A27.033,27.033,0,0,1,1276.926-1326.907Z",transform:"translate(-1977.222 1528.815)",fill:"rgba(23,26,29,0.4)",opacity:"0"}),o.jsx("path",{d:"M1301.63-1351.611a2.5,2.5,0,0,1-2.5-2.5,22.229,22.229,0,0,0-22.2-22.2,2.5,2.5,0,0,1-2.5-2.5,2.5,2.5,0,0,1,2.5-2.5,27.035,27.035,0,0,1,10.589,2.139,27.111,27.111,0,0,1,8.646,5.829,27.11,27.11,0,0,1,5.829,8.646,27.035,27.035,0,0,1,2.139,10.59A2.5,2.5,0,0,1,1301.63-1351.611Z",transform:"translate(-1977.222 1528.815)",fill:"rgba(23,26,29,0.4)"})]})})},ar=A.memo(function(d){var E=d.list,b=d.searchValue,p=d.multipleValue,x=d.searchEmptyText,k=d.multiple,i=d.onChoose,T=A.useState([]),v=T[0],P=T[1];A.useEffect(function(){if(!(b.length<2)){var R=setTimeout(function(){var L=E[0].list,V=Le(L);P(V.filter(function(z){var I=z.pathValue.split("/");return z.value=I[I.length-1],z.pathName.toLowerCase().includes(b.toLowerCase())}))},500);return function(){clearTimeout(R)}}},[b]);var S=function(R){if(!R.disabled){var L=R.pathValue.split("/");i(L[L.length-1])}};return o.jsx(o.Fragment,{children:v.length?o.jsx("div",{className:"searchList",children:o.jsx("div",{className:"cascader_popover_cell",children:v.map(function(R,L){return o.jsx("div",{onClick:function(){return S(R)},children:o.jsx("div",{className:R.disabled?"cascader_popover_cell_label_box_disabled":"cascader_popover_cell_label_box",children:o.jsxs("div",{className:"label",children:[k?o.jsx("span",{className:"icon",children:o.jsx(Ne,{checked:!!p.includes(R.value)})}):o.jsx(o.Fragment,{}),R.pathName.split("").map(function(V,z){return o.jsx("span",{children:V==="/"?o.jsx("span",{className:"slash",children:" / "}):o.jsx("span",{className:b.split("").includes(V)?"search_text_ac":"",children:V})},z)})]})})},L)})})}):o.jsx("div",{className:"empty_data",children:x})})}),nr=A.forwardRef(function(d,E){var b=d.searchPlaceholder,p=b===void 0?"请输入关键词":b,x=d.searchEmptyText,k=x===void 0?"暂无数据":x,i=m.__rest(d,["searchPlaceholder","searchEmptyText"]),T=A.useState([]),v=T[0],P=T[1],S=A.useState(""),R=S[0],L=S[1],V=A.useState([]),z=V[0],I=V[1],W=A.useState(""),Y=W[0],O=W[1],$=A.useState({}),le=$[0],ye=$[1],fe=A.useState(!0),me=fe[0],ce=fe[1];A.useImperativeHandle(E,function(){return{setValue:ee,clearValue:de}});var de=function(){var l=m.__spreadArray([],v,!0);function s(a){a.forEach(function(c){c.checked=!1,c.indeterminateChecked=!1,c.children&&c.children.length&&s(c.children)})}i.multiple?s(l[0].list):l.forEach(function(a){a.index=-1}),P(l),O(""),I([]),i.onChange(null,[])},Ee=function(l,s,a){return m.__awaiter(void 0,void 0,void 0,function(){var c,u,t,_,M;return m.__generator(this,function(f){switch(f.label){case 0:if(l.value===Y||l.disabled||!l.isLoad&&i.multiple)return[2];if(c=m.__spreadArray([],v,!0),!l.isLoad)return c[s].index=a,u=[],c.forEach(function(J,G){G<=s&&u.push(J.list[J.index])}),O(l.value),i.onChange(l,u),i.onClose(),[2];if(!(i.loadData&&me))return[3,3];for(ce(!1),c[s].index=a,t=c.length-1;t>=0;t--)t>s&&c.splice(t,1);return le[l.value]?(c[s+1]={list:le[l.value],index:-1},P(c),ce(!0),[3,3]):[3,1];case 1:return l.isLoad&&(c[s].list[a].isLoading=!0,P(c)),[4,i.loadData(l)];case 2:_=f.sent(),ye(m.__assign(m.__assign({},le),(M={},M[l.value]=_,M))),c[s].list[a].isLoading=!1,c[s].list[a].children=_,c[s+1]={list:_,index:-1},P(function(){return m.__spreadArray([],c,!0)}),ce(!0),f.label=3;case 3:return[2]}})})},we=function(l,s,a){var c;if(!(l.value===Y||l.disabled)){var u=m.__spreadArray([],v,!0);if((!l.children||l.children.length===0)&&(u[s].index=a,!i.multiple)){var t=[];u.forEach(function(M,f){f<=s&&t.push(M.list[M.index])}),P(u),O(l.value),i.onChange(l,t),i.onClose()}for(var _=u.length-1;_>=0;_--)_>s&&_!=s&&u.splice(_,1);!((c=l.children)===null||c===void 0)&&c.length&&(u[s+1]={list:l.children,index:l.children.findIndex(function(M){return M.value===Y})},u[s].index=a,P(u))}},ve=function(l){var s=[];function a(c){c.forEach(function(u){var t;if(u.checked&&!(!((t=u.children)===null||t===void 0)&&t.length)){var _=m.__assign({},u);delete _.cascaderNodeId,delete _.parentCascaderNodeId,delete _.checked,delete _.indeterminateChecked,delete _.isLoading,s.push(_)}u.children&&u.children.length&&a(u.children)})}a(l),I(s.map(function(c){return c.value})),i.onChange(null,s)},H=function(l,s,a){var c,u;if(v[s].list[a].disabled)return;l.stopPropagation();var t=m.__spreadArray([],v,!0);t[s].list[a].checked=!t[s].list[a].checked;var _=t[s].list[a].children;function M(re){re.forEach(function(g){t[s].list[a].checked?g.checked=!0:g.checked=!1,g.indeterminateChecked=!1,g.children&&M(g.children)})}if(_&&_.length)t[s].list[a].indeterminateChecked=!1,M(_);else{t[s].index=-1;for(var f=t.length-1;f>=0;f--)f>s&&t.splice(f,1)}for(var f=s;f>0;f--){var J=t[f].list.every(function(g){return g.checked}),G=t[f].list.some(function(g){return g.indeterminateChecked||g.checked});t[f-1].list[t[f-1].index].checked=J,G?(t[f-1].list[t[f-1].index].indeterminateChecked=!0,t[f].list[t[f].index]&&(t[f].list[t[f].index].indeterminateChecked=!0)):t[f-1].list[t[f-1].index].indeterminateChecked=!1}for(var f=0;f<t.length;f++)t[f].list[t[f].index]&&(t[f].list[t[f].index].indeterminateChecked=(c=t[f].list[t[f].index].children)===null||c===void 0?void 0:c.some(function(g){return g.indeterminateChecked||g.checked}),!((u=t[f].list[t[f].index].children)===null||u===void 0)&&u.every(function(g){return g.checked})&&(t[f].list[t[f].index].indeterminateChecked=!1));ve(t[0].list),P(t)},K=function(l,s,a,c){for(var u=0;u<l.length;u++){var t=l[u];if(t.value===s)return{parentItems:m.__spreadArray(m.__spreadArray([],a,!0),[t],!1),parentIndexes:m.__spreadArray(m.__spreadArray([],c,!0),[u],!1)};if(t.children){var _=K(t.children,s,m.__spreadArray(m.__spreadArray([],a,!0),[t],!1),m.__spreadArray(m.__spreadArray([],c,!0),[u],!1));if(_)return _}}return null},Q=function(l){if(Y!==l){var s=ue(i.options),a=K(i.loadData?v[0].list:s,l,[],[]);if(a){var c=[];a.parentItems.forEach(function(t,_){t.children&&t.children.length&&c.push({list:t.children,index:a.parentIndexes[_+1]})});var u=c.length?c[c.length-1].list.filter(function(t){return t.value===l}):[];u.length&&(O(u[0].value+""),i.onChange(u[0],a.parentItems)),P(m.__spreadArray([{list:i.loadData?v[0].list:i.options,index:a.parentIndexes[0]}],c,!0))}}};A.useEffect(function(){i.anchorEl&&(L(""),setTimeout(function(){var l=document.getElementsByClassName("cascader_popover_cell");l.length&&v.forEach(function(s,a){var c,u=l[a].querySelector(".cascader_popover_cell_label_box_ac"),t=(c=u==null?void 0:u.parentElement)===null||c===void 0?void 0:c.getBoundingClientRect(),_=t?u.getBoundingClientRect().top-t.top:0;u?l[a].scrollTop=_-5||0:l[a].scrollTop=0})}))},[i.anchorEl]);var ee=function(l){if(l.length===0){i.onChange(null,[]),I([]);return}if(z.join(",")!==l.join(",")){var s=ue(i.options),a=m.__spreadArray([],v,!0),c=[];if(a.length)if(a.length===1)a.forEach(function(g){g.list.forEach(function(F){F.checked=!1,F.indeterminateChecked=!1})});else{var u=function(g){g.forEach(function(F){F.checked=!1,F.indeterminateChecked=!1,F.children&&F.children.length&&u(F.children)})};u(a[0].list)}var t=Qe(v.length?v[0].list:s,l),_=t.valueResult,M=t.labelResult;if(Ae(v.length?v[0].list:s,_),_.length){var f=a.length?a[0].list.filter(function(g){return g.value===_[0][0]}):s.filter(function(g){return g.value===_[0][0]}),J=function(g,F){g.forEach(function(ae,q){ae.value===_[0][F]&&(v.length?a[F]={list:g,index:q}:c[F]={list:g,index:q},F++),ae.children&&ae.children.length&&J(ae.children,F)})};f.length&&f[0].children&&J(f[0].children,1)}var G=M.map(function(g,F){return{label:g[g.length-1],value:_[F][_[F].length-1]}});if(I(G.map(function(g){return g.value})),i.onChange(null,G),a.length){var re=_[0].length;a.length>re&&(a=a.slice(0,re)),a[0]={list:a[0].list,index:a[0].list.findIndex(function(g){return g.value===_[0][0]})},P(a)}else c[0]={list:s,index:s.findIndex(function(g){return g.value===_[0][0]})},P(c)}};A.useEffect(function(){var l=ue(i.options);i.multiple?i.value==""?P([{list:l,index:-1}]):ee(i.value?i.value.split(","):[]):i.value?Q(i.value):P([{list:l,index:-1}])},[i.value]);var he=function(){i.onClose&&i.onClose()},pe=function(l){L(l.target.value)},_e=function(l){if(!i.multiple)O(l),Q(l),i.onClose();else{var s=z.includes(l)?z.filter(function(a){return a!==l}):m.__spreadArray(m.__spreadArray([],z,!0),[l],!1);ee(s)}};return o.jsx(o.Fragment,{children:o.jsxs($e,{anchorEl:i.anchorEl,open:i.open,onClose:he,children:[i.search?o.jsx("div",{className:"cascader_search_box",children:o.jsx("input",{type:"text",placeholder:p,value:R,onChange:pe,className:"cascader_search_input"})}):o.jsx(o.Fragment,{}),R===""?o.jsx("div",{className:"cascader_popover",children:v.map(function(l,s){return o.jsx("div",{className:"cascader_popover_cell",children:l.list.map(function(a,c){var u;return o.jsxs("div",{"data-ischeckedall":(u=a.children)===null||u===void 0?void 0:u.every(function(t){return t.checked}),className:a.disabled?"cascader_popover_cell_label_box_disabled":l.index===c||!a.children&&a.checked?"cascader_popover_cell_label_box cascader_popover_cell_label_box_ac":"cascader_popover_cell_label_box",onClick:function(){i.loadData?Ee(a,s,c):we(a,s,c)},children:[o.jsx("div",{className:"label",children:i.multiple?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"icon",children:o.jsx(Ne,{onClick:function(t){(!a.isLoad||a.children&&a.children.length)&&H(t,s,c)},checked:!!a.checked,indeterminate:a.indeterminateChecked})}),o.jsx("div",{children:a.label})]}):o.jsx("div",{children:a.label})}),a.children&&a.children.length>0||i.loadData?o.jsx("div",{className:"cascader_popover_cell_label_box_icon",children:i.loadData&&a.isLoading&&a.isLoad?o.jsx("div",{className:"cascader_popover_cell_label_box_arrow",children:o.jsx(rr,{})}):a.children&&a.children.length>0||a.isLoad?o.jsx("div",{className:"cascader_popover_cell_label_box_arrow",children:o.jsx(er,{})}):o.jsx(o.Fragment,{})}):o.jsx(o.Fragment,{})]},a.value)})},s)})}):o.jsx(ar,{searchEmptyText:k,multiple:i.multiple,multipleValue:z,list:v,searchValue:R,onChoose:_e})]})})});X.Cascader=nr,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})});