vxe-pc-ui 4.9.44 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/icon/style.css +1 -1
- package/es/select/src/select.js +7 -2
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/utils.js +4 -4
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +11 -7
- package/lib/index.umd.min.js +1 -1
- package/lib/select/src/select.js +5 -1
- package/lib/select/src/select.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/src/utils.js +4 -4
- package/lib/ui/src/utils.min.js +1 -1
- package/package.json +1 -1
- package/packages/select/src/select.ts +7 -2
- package/packages/ui/src/utils.ts +4 -4
- package/types/components/select.d.ts +1 -0
- package/types/components/table-plugins/extend-cell-area.d.ts +18 -0
- package/types/components/table.d.ts +1 -0
- /package/es/icon/{iconfont.1760430417319.ttf → iconfont.1760599854482.ttf} +0 -0
- /package/es/icon/{iconfont.1760430417319.woff → iconfont.1760599854482.woff} +0 -0
- /package/es/icon/{iconfont.1760430417319.woff2 → iconfont.1760599854482.woff2} +0 -0
- /package/es/{iconfont.1760430417319.ttf → iconfont.1760599854482.ttf} +0 -0
- /package/es/{iconfont.1760430417319.woff → iconfont.1760599854482.woff} +0 -0
- /package/es/{iconfont.1760430417319.woff2 → iconfont.1760599854482.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1760430417319.ttf → iconfont.1760599854482.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1760430417319.woff → iconfont.1760599854482.woff} +0 -0
- /package/lib/icon/style/{iconfont.1760430417319.woff2 → iconfont.1760599854482.woff2} +0 -0
- /package/lib/{iconfont.1760430417319.ttf → iconfont.1760599854482.ttf} +0 -0
- /package/lib/{iconfont.1760430417319.woff → iconfont.1760599854482.woff} +0 -0
- /package/lib/{iconfont.1760430417319.woff2 → iconfont.1760599854482.woff2} +0 -0
package/lib/select/src/select.js
CHANGED
|
@@ -1356,7 +1356,8 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
1356
1356
|
const groupLabelField = computeGroupLabelField.value;
|
|
1357
1357
|
const selectVals = computeSelectVals.value;
|
|
1358
1358
|
const {
|
|
1359
|
-
useKey
|
|
1359
|
+
useKey,
|
|
1360
|
+
height
|
|
1360
1361
|
} = optionOpts;
|
|
1361
1362
|
const optionSlot = slots.option;
|
|
1362
1363
|
return list.map((option, cIndex) => {
|
|
@@ -1398,6 +1399,9 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
1398
1399
|
}],
|
|
1399
1400
|
optid: optid,
|
|
1400
1401
|
title: optLabel || null,
|
|
1402
|
+
style: height ? {
|
|
1403
|
+
height: (0, _dom.toCssUnit)(height)
|
|
1404
|
+
} : undefined,
|
|
1401
1405
|
onMousedown: evnt => {
|
|
1402
1406
|
const isLeftBtn = evnt.button === 0;
|
|
1403
1407
|
if (isLeftBtn) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _vue=require("vue"),_comp=require("../../ui/src/comp"),_xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../ui"),_dom=require("../../ui/src/dom"),_utils=require("../../ui/src/utils"),_vn=require("../../ui/src/vn"),_input=_interopRequireDefault(require("../../input/src/input")),_button=_interopRequireDefault(require("../../button/src/button"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function isOptionVisible(e){return!1!==e.visible}function getOptUniqueId(){return _xeUtils.default.uniqueId("opt_")}function createInternalData(){return{synchData:[],fullData:[],afterVisibleList:[],optAddMaps:{},optGroupKeyMaps:{},optFullValMaps:{},remoteValMaps:{},lastScrollLeft:0,lastScrollTop:0,scrollYStore:{startIndex:0,endIndex:0,visibleSize:0,offsetSize:0,rowHeight:0},lastScrollTime:0,hpTimeout:void 0}}var _default=exports.default=(0,_comp.defineVxeComponent)({name:"VxeSelect",props:{modelValue:[String,Number,Boolean,Array],defaultConfig:Object,clearable:Boolean,placeholder:String,readonly:{type:Boolean,default:null},loading:Boolean,disabled:{type:Boolean,default:null},multiple:Boolean,multiCharOverflow:{type:[Number,String],default:()=>(0,_ui.getConfig)().select.multiCharOverflow},prefixIcon:String,allowCreate:{type:Boolean,default:()=>(0,_ui.getConfig)().select.allowCreate},placement:String,lazyOptions:Array,options:Array,optionProps:Object,optionGroups:Array,optionGroupProps:Object,optionConfig:Object,className:[String,Function],popupClassName:[String,Function],max:{type:[String,Number],default:null},zIndex:Number,size:{type:String,default:()=>(0,_ui.getConfig)().select.size||(0,_ui.getConfig)().size},filterable:Boolean,filterMethod:Function,remote:Boolean,remoteConfig:Object,emptyText:String,showTotalButoon:{type:Boolean,default:()=>(0,_ui.getConfig)().select.showTotalButoon},showCheckedButoon:{type:Boolean,default:()=>(0,_ui.getConfig)().select.showCheckedButoon},showClearButton:{type:Boolean,default:()=>(0,_ui.getConfig)().select.showClearButton},transfer:{type:Boolean,default:null},virtualYConfig:Object,scrollY:Object,remoteMethod:Function,optionId:{type:String,default:()=>(0,_ui.getConfig)().select.optionId},optionKey:Boolean},emits:["update:modelValue","change","all-change","clear","blur","focus","click","scroll","visible-change"],setup(V,e){const{slots:C,emit:a}=e,b=(0,_vue.inject)("$xeModal",null),T=(0,_vue.inject)("$xeDrawer",null),E=(0,_vue.inject)("$xeTable",null),i=(0,_vue.inject)("$xeForm",null),o=(0,_vue.inject)("xeFormItemInfo",null);var t=_xeUtils.default.uniqueId();const L=(0,_vue.ref)(),O=(0,_vue.ref)(),P=(0,_vue.ref)(),w=(0,_vue.ref)(),A=(0,_vue.ref)(),k=(0,_vue.ref)(),Y=(0,_ui.useSize)(V)["computeSize"],M=(0,_vue.reactive)({initialized:!1,scrollYLoad:!1,bodyHeight:0,topSpaceHeight:0,optList:[],staticOptions:[],reactFlag:0,currentOption:null,searchValue:"",searchLoading:!1,panelIndex:0,panelStyle:{},panelPlacement:null,triggerFocusPanel:!1,visiblePanel:!1,isAniVisible:!1,isActivated:!1}),S=createInternalData(),y={refElem:L},F={xID:t,props:V,context:e,reactData:M,internalData:S,getRefMaps:()=>y},z=(0,_vue.computed)(()=>{var e=V["readonly"];return null===e?!!i&&i.props.readonly:e}),B=(0,_vue.computed)(()=>{var e=V["disabled"];return null===e?!!i&&i.props.disabled:e}),H=(0,_vue.computed)(()=>{var e=V["transfer"];if(null===e){var t=(0,_ui.getConfig)().select.transfer;if(_xeUtils.default.isBoolean(t))return t;if(E||b||T||i)return!0}return e}),j=(0,_vue.computed)(()=>{var e=V["placeholder"];return(e=e||(0,_ui.getConfig)().select.placeholder)?(0,_utils.getFuncText)(e):(0,_ui.getI18n)("vxe.base.pleaseSelect")}),q=(0,_vue.computed)(()=>Object.assign({},V.defaultConfig)),K=(0,_vue.computed)(()=>Object.assign({},V.optionProps)),$=(0,_vue.computed)(()=>Object.assign({},V.optionGroupProps)),c=(0,_vue.computed)(()=>{return K.value.label||"label"}),I=(0,_vue.computed)(()=>{return K.value.value||"value"}),G=(0,_vue.computed)(()=>{return $.value.label||"label"}),R=(0,_vue.computed)(()=>{return $.value.options||"options"}),W=(0,_vue.computed)(()=>{var e=D.value;return ae(e)}),X=(0,_vue.computed)(()=>Object.assign({},(0,_ui.getConfig)().select.virtualYConfig||(0,_ui.getConfig)().select.scrollY,V.virtualYConfig||V.scrollY)),Z=(0,_vue.computed)(()=>Object.assign({},(0,_ui.getConfig)().select.remoteConfig,V.remoteConfig)),J=(0,_vue.computed)(()=>Object.assign({},(0,_ui.getConfig)().select.optionConfig,V.optionConfig)),Q=(0,_vue.computed)(()=>_xeUtils.default.toNumber(V.multiCharOverflow)),D=(0,_vue.computed)(()=>{var{modelValue:e,multiple:t}=V;let l=[];return _xeUtils.default.isArray(e)?l=e:t?(0,_utils.eqEmptyValue)(e)||(l=-1<(""+e).indexOf(",")?(""+e).split(","):[e]):l=null==e?[]:[e],l}),ee=(0,_vue.computed)(()=>{var e=V["remote"],t=M["reactFlag"],l=D.value;return(e&&t?l.map(e=>ie(e)):l.map(e=>oe(e))).join(", ")}),te=(0,_vue.computed)(()=>{var{remote:e,multiple:t}=V,l=M["reactFlag"],a=Q.value,i=D.value;return e&&l?i.map(e=>ie(e)).join(", "):(e=i.map(e=>oe(e)),t&&0<a&&e.length>a?e.slice(0,a)+"...":e.join(", "))}),N=(e,t)=>e&&(_xeUtils.default.isString(e)&&(e=C[e]||null),_xeUtils.default.isFunction(e))?(0,_vn.getSlotVNs)(e(t)):[],r=(e,t,l)=>{a(e,(0,_ui.createEvent)(l,{$select:F},t))},le=e=>{a("update:modelValue",e)},_=()=>{return J.value.keyField||V.optionId||"_X_OPTION_KEY"},U=e=>{e=e[_()];return e?encodeURIComponent(e):""},ae=e=>{var{multiple:t,max:l}=V;return!(!t||!l)&&e.length>=_xeUtils.default.toNumber(l)},ie=t=>{var e=V["lazyOptions"],{remoteValMaps:l,optFullValMaps:a}=S;const i=I.value;var o=c.value,l=l[t]||a[t],a=l?l.item:null;if(a)return _xeUtils.default.toValueString(a[o]);if(e){l=e.find(e=>e[i]===t);if(l)return l[o]}return t},oe=t=>{var e=V["lazyOptions"],l=S["optFullValMaps"];const a=I.value;var i=c.value,l=M.reactFlag?l[t]:null;if(l)return l.item[i];if(e){l=e.find(e=>e[a]===t);if(l)return l[i]}return t},g=()=>{const{modelValue:t,filterable:e,filterMethod:l}=V,a=M["searchValue"],{fullData:i,optFullValMaps:o}=S,n=c.value,r=I.value,u=(""+(a||"")).toLowerCase();let s=[];return(s=e&&l?i.filter(e=>isOptionVisible(e)&&l({$select:F,group:null,option:e,searchValue:a,value:t})):e?i.filter(e=>isOptionVisible(e)&&(!u||-1<(""+(e[n]||e[r])).toLowerCase().indexOf(u))):i.filter(isOptionVisible)).forEach((e,t)=>{e=o[e[r]];e&&(e._index=t)}),S.afterVisibleList=s,(0,_vue.nextTick)()},ne=e=>{e&&(M.currentOption=e)},u=()=>{const l=V["placement"],a=M["panelIndex"],i=L.value,o=A.value,n=H.value;var e=()=>{var e=(0,_dom.updatePanelPlacement)(i,o,{placement:l,teleportTo:n}),t=Object.assign(e.style,{zIndex:a});M.panelStyle=t,M.panelPlacement=e.placement};return e(),(0,_vue.nextTick)().then(e)},v=()=>{var{loading:e,filterable:t,remote:l}=V,{fullData:a,hpTimeout:i}=S,o=B.value,n=Z.value;e||o||(i&&(clearTimeout(i),S.hpTimeout=void 0),M.initialized||(M.initialized=!0),M.isActivated=!0,M.isAniVisible=!0,t&&(l&&n.enabled&&n.autoLoad&&!a.length?ye:(g(),f))(),setTimeout(()=>{M.visiblePanel=!0,V.filterable&&(0,_vue.nextTick)(()=>{var e=P.value;e&&e.focus()});x().then(()=>{(0,_vue.nextTick)(()=>{var{isAniVisible:e,visiblePanel:t}=M,l=S["optFullValMaps"],a=D.value;a.length&&e&&t&&(e=M.reactFlag?l[""+a[0]]:null)&&Oe(e.item)}),m()})},10),setTimeout(()=>{x().then(()=>m())},100),(e=V.zIndex)?M.panelIndex=e:M.panelIndex<(0,_utils.getLastZIndex)()&&(M.panelIndex=(0,_utils.nextZIndex)()),u(),r("visible-change",{visible:!0},null))},d=()=>{M.searchValue="",M.searchLoading=!1,M.visiblePanel=!1,S.hpTimeout=setTimeout(()=>{M.isAniVisible=!1},350),r("visible-change",{visible:!1},null)},s=(e,t,l)=>{le(t),t!==V.modelValue&&(r("change",{value:t,option:l},e),i)&&o&&i.triggerItemEvent(e,o.itemConfig.field,t)},p=(e,t)=>{S.remoteValMaps={},s(e,t,null),r("clear",{value:t},e)},re=e=>{e=e.$event;p(e,null),d()},ue=e=>{var e=e["$event"],{multiple:t,max:l}=V,a=M["optList"],i=I.value;if(t){var o=D.value.slice(0);for(let e=0;e<a.length;e++){const n=a[e][i];if(ae(o)){_ui.VxeUI&&_ui.VxeUI.modal.message({content:(0,_ui.getI18n)("vxe.select.overSizeErr",[l]),status:"warning"});break}o.some(e=>e===n)||o.push(n)}s(e,o,a[0]),r("all-change",{value:o},e)}},se=e=>{e=e.$event;p(e,null),d()},ce=(t,l)=>{var e=V["multiple"],a=S["remoteValMaps"];const i=l[I.value];var o=a[i];if(M.visiblePanel){if(o?o.item=l:a[i]={key:U(l),item:l,_index:-1},e){let e=[];o=D.value,a=_xeUtils.default.findIndexOf(o,e=>e===i);e=-1===a?o.concat([i]):o.filter(e=>e!==i),s(t,e,l)}else s(t,i,l),d();M.reactFlag++}},ve=e=>{var t=M["visiblePanel"];B.value||t&&(t=A.value,((0,_dom.getEventTargetNode)(e,t).flag?u:d)())},de=e=>{var t,l,a=M["visiblePanel"];B.value||(t=L.value,l=A.value,M.isActivated=(0,_dom.getEventTargetNode)(e,t).flag||(0,_dom.getEventTargetNode)(e,l).flag,a&&!M.isActivated&&d())},h=e=>{var t=e.disabled,e=U(e);return!t&&!ke(e)},pe=(e,t)=>{var l=V["allowCreate"],a=M["optList"],{optFullValMaps:i,optAddMaps:o,afterVisibleList:n}=S,r=I.value;let u=n,s=0;if(l&&a.length&&(n=a[0],o[l=U(n)])&&(s=1,u=[o[l]].concat(u)),!e)if(t)for(let e=0;e<u.length;e++){var c=u[e];if(h(c))return c}else for(let e=u.length-1;0<=e;e--){var v=u[e];if(h(v))return v}let d=0;a=e?i[e[r]]:null;if(-1<(d=a?a._index+s:d))if(t)for(let e=d+1;e<=u.length-1;e++){var p=u[e];if(h(p))return p}else if(0<d)for(let e=d-1;0<=e;e--){var f=u[e];if(h(f))return f}return null},fe=t=>{var e=V["clearable"],{visiblePanel:l,currentOption:a}=M;if(!B.value){var i=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.TAB),o=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ENTER),n=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ESCAPE),r=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ARROW_UP),u=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ARROW_DOWN),s=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.DELETE);if(i&&(M.isActivated=!1),l){if(n||i)d();else if(o)a&&(t.preventDefault(),t.stopPropagation(),ce(t,a));else if(r||u){t.preventDefault();let e=pe(a,u);(e=e||pe(null,u))&&(ne(e),Oe(e,u))}}else(r||u||o)&&M.isActivated&&(t.preventDefault(),v());M.isActivated&&s&&e&&p(t,null)}},_e=()=>{var{visiblePanel:e,isActivated:t}=M;e&&d(),t&&(M.isActivated=!1),(e||t)&&(e=O.value)&&e.blur()},ge=()=>{var e=M["visiblePanel"];e&&u()},he=e=>{B.value||M.visiblePanel||(M.triggerFocusPanel=!0,v(),setTimeout(()=>{M.triggerFocusPanel=!1},500)),r("focus",{},e)},me=e=>{Ie(e),r("click",{triggerButton:!1,visible:M.visiblePanel},e)},xe=e=>{M.isActivated=!1,r("blur",{},e)},be=e=>{Ie(e),r("click",{triggerButton:!0,visible:M.visiblePanel},e)},Te=e=>{M.searchValue=e},Ee=()=>{M.isActivated=!0},ye=()=>{var{modelValue:e,remote:t,remoteMethod:l}=V,a=M["searchValue"],i=Z.value,l=i.queryMethod||l;t&&l&&i.enabled?(M.searchLoading=!0,Promise.resolve(l({$select:F,searchValue:a,value:e})).then(()=>(0,_vue.nextTick)()).catch(()=>(0,_vue.nextTick)()).finally(()=>{M.searchLoading=!1,g(),f()})):(g(),f())},Se=_xeUtils.default.debounce(ye,350,{trailing:!0}),Ie=e=>{e=e.$event;e.preventDefault(),M.triggerFocusPanel?M.triggerFocusPanel=!1:(M.visiblePanel?d:v)()},Ve=()=>{var e=M["scrollYLoad"],{scrollYStore:t,afterVisibleList:l}=S;M.bodyHeight=e?l.length*t.rowHeight:0,M.topSpaceHeight=e?Math.max(t.startIndex*t.rowHeight,0):0},Ce=()=>{var{filterable:e,allowCreate:t}=V;const{scrollYLoad:l,searchValue:a}=M;var{optAddMaps:i,scrollYStore:o,afterVisibleList:n}=S;const r=c.value;var u=I.value,o=l?n.slice(o.startIndex,o.endIndex):n.slice(0);return e&&t&&a&&(o.some(e=>e[r]===a)||(n=i[a]||(0,_vue.reactive)({[_()]:a,[r]:a,[u]:a}),i[a]=n,o.unshift(n))),M.optList=o,(0,_vue.nextTick)()},f=()=>{Ce(),Ve()},Le=()=>(0,_vue.nextTick)().then(()=>{var e=M["scrollYLoad"],t=S["scrollYStore"],l=k.value,a=X.value;let i=0,o;(o=l?o||l.children[0]:o)&&(i=o.offsetHeight),i=Math.max(20,i),t.rowHeight=i,(e?(l=w.value,e=Math.max(8,l?Math.ceil(l.clientHeight/i):0),l=Math.max(0,Math.min(2,_xeUtils.default.toNumber(a.oSize))),t.offsetSize=l,t.visibleSize=e,t.endIndex=Math.max(t.startIndex,e+l,t.endIndex),f):Ve)()}),Oe=(e,t)=>{var l,a,i=M["scrollYLoad"],{optFullValMaps:o,scrollYStore:n}=S,o=o[e[I.value]];o&&(e=o.key,-1<(o=o._index))&&(l=w.value,a=A.value)&&(a=a.querySelector(`[optid='${e}']`),l)&&(a?(e=l.offsetHeight,t?a.offsetTop+a.offsetHeight-l.scrollTop>e?l.scrollTop=a.offsetTop+a.offsetHeight-e:(a.offsetTop+1<l.scrollTop||a.offsetTop+1>l.scrollTop+l.clientHeight)&&(l.scrollTop=a.offsetTop-1):a.offsetTop+1<l.scrollTop||a.offsetTop+1>l.scrollTop+l.clientHeight?l.scrollTop=a.offsetTop-1:a.offsetTop+a.offsetHeight-l.scrollTop>e&&(l.scrollTop=a.offsetTop+a.offsetHeight-e)):i&&(l.scrollTop=t?o*n.rowHeight-l.clientHeight+n.rowHeight:o*n.rowHeight))},Pe=(e,t)=>{var l=w.value;return l&&(_xeUtils.default.isNumber(e)&&(l.scrollLeft=e),_xeUtils.default.isNumber(t))&&(l.scrollTop=t),M.scrollYLoad?new Promise(e=>{setTimeout(()=>{(0,_vue.nextTick)(()=>{e()})},50)}):(0,_vue.nextTick)()},m=()=>{const{lastScrollLeft:e,lastScrollTop:t}=S;return n().then(()=>{if(e||t)return S.lastScrollLeft=0,S.lastScrollTop=0,Pe(e,t)})},x=()=>{var e=L.value;return e&&e.clientWidth&&e.clientHeight?Le():Promise.resolve()},we=e=>{var t=S["scrollYStore"],{startIndex:l,endIndex:a,visibleSize:i,offsetSize:o,rowHeight:n}=t,e=e.target.scrollTop,e=Math.floor(e/n),n=Math.max(0,e-1-o),o=e+i+o;!(e<=l||a-i-1<=e)||l===n&&a===o||(t.startIndex=n,t.endIndex=o,f())},Ae=e=>{var t=e.target,l=t.scrollTop,t=t.scrollLeft,a=t!==S.lastScrollLeft,i=l!==S.lastScrollTop;S.lastScrollTop=l,S.lastScrollLeft=t,M.scrollYLoad&&we(e),S.lastScrollTime=Date.now(),r("scroll",{scrollLeft:t,scrollTop:l,isX:a,isY:i},e)},l=e=>{{var t=e||[];const r=R.value,u=I.value,s=_(),c={},v={},d=[],p=e=>{d.push(e);let t=U(e);t||(t=getOptUniqueId(),e[s]=t),v[e[u]]={key:t,item:e,_index:-1}};t.forEach(e=>{p(e),e[r]&&(c[e[s]]=e)[r].forEach(p)}),S.fullData=d,S.optGroupKeyMaps=c,S.optFullValMaps=v,M.reactFlag++,g()}var{isLoaded:t,fullData:l,scrollYStore:a}=S,i=q.value,o=X.value;const n=I.value;if(Object.assign(a,{startIndex:0,endIndex:1,visibleSize:0}),S.synchData=e||[],M.scrollYLoad=!!o.enabled&&-1<o.gt&&(0===o.gt||o.gt<=l.length),Ce(),!t){a=i["selectMode"];if(0<e.length&&_xeUtils.default.eqNull(V.modelValue)){if("first"===a||"last"===a){const f=_xeUtils.default[a](e);f&&(0,_vue.nextTick)(()=>{_xeUtils.default.eqNull(V.modelValue)&&le(f[n])})}S.isLoaded=!0}}return Le().then(()=>{m()})},n=()=>{var e=w.value;return e&&(e.scrollTop=0,e.scrollLeft=0),S.lastScrollTop=0,(S.lastScrollLeft=0,_vue.nextTick)()},ke=e=>{var t=S["optGroupKeyMaps"];return!!t[e]};t={dispatchEvent:r,loadData:l,reloadData(e){return S.isLoaded=!1,n(),l(e)},isPanelVisible(){return M.visiblePanel},togglePanel(){return(M.visiblePanel?d:v)(),(0,_vue.nextTick)()},hidePanel(){return M.visiblePanel&&d(),(0,_vue.nextTick)()},showPanel(){return M.visiblePanel||v(),(0,_vue.nextTick)()},refreshOption(){return g(),f(),(0,_vue.nextTick)()},focus(){var e=O.value;return e&&e.blur(),M.isActivated=!0,(0,_vue.nextTick)()},blur(){var e=O.value;return e&&e.blur(),(M.isActivated=!1,_vue.nextTick)()},recalculate:x,clearScroll:n};Object.assign(F,t);const Me=e=>{const{allowCreate:f,optionKey:_}=V,g=M["currentOption"],h=S["optAddMaps"];var t=J.value;const m=c.value,x=I.value,b=G.value,T=D.value,E=t["useKey"],y=C.option;return e.map((t,e)=>{var{slots:l,className:a}=t,i=U(t),o=t[x];const n=ke(i);var r=!(!f||!h[i]),u=!r&&-1<T.indexOf(o),s=r||!n||isOptionVisible(t);const c=!r&&(v=u,!!t.disabled||!(!W.value||v));var v=l?l.default:null,l={option:t,group:n?t:null,$select:F};let d="",p=[];return p=y?N(y,l):v?N(v,l):d=(0,_utils.getFuncText)(t[n?b:m]||o),s?(0,_vue.h)("div",{key:E||_?i:e,class:["vxe-select-option",a?_xeUtils.default.isFunction(a)?a(l):a:"",{"vxe-select-optgroup":n,"is--disabled":c,"is--selected":u,"is--add":r,"is--hover":g&&U(g)===i}],optid:i,title:d||null,onMousedown:e=>{0===e.button&&e.stopPropagation()},onClick:e=>{c||n||ce(e,t)},onMouseenter:()=>{var e;c||n||(e=S.lastScrollTime)&&Date.now()<e+250||ne(t)}},f?[(0,_vue.h)("span",{key:1,class:"vxe-select-option--label"},p),r?(0,_vue.h)("span",{key:2,class:"vxe-select-option--add-icon"},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().SELECT_ADD_OPTION})]):(0,_ui.renderEmptyElement)(F)]:p):(0,_ui.renderEmptyElement)(F)})};return(0,_vue.watch)(()=>M.staticOptions,e=>{l(e)}),(0,_vue.watch)(()=>V.options,e=>{l(e||[])}),(0,_vue.watch)(()=>V.optionGroups,e=>{l(e||[])}),(0,_vue.onMounted)(()=>{(0,_vue.nextTick)(()=>{var{options:e,optionGroups:t}=V;t?l(t):e&&l(e)}),_ui.globalEvents.on(F,"mousewheel",ve),_ui.globalEvents.on(F,"mousedown",de),_ui.globalEvents.on(F,"keydown",fe),_ui.globalEvents.on(F,"blur",_e),_ui.globalEvents.on(F,"resize",ge)}),(0,_vue.onUnmounted)(()=>{_ui.globalEvents.off(F,"mousewheel"),_ui.globalEvents.off(F,"mousedown"),_ui.globalEvents.off(F,"keydown"),_ui.globalEvents.off(F,"blur"),_ui.globalEvents.off(F,"resize"),_xeUtils.default.assign(S,createInternalData())}),(0,_vue.provide)("$xeSelect",F),F.renderVN=()=>{var{className:e,popupClassName:t,multiple:l,loading:a,filterable:i,showTotalButoon:o,showCheckedButoon:n,showClearButton:r}=V,{initialized:u,isActivated:s,isAniVisible:c,optList:v,visiblePanel:d,bodyHeight:p,topSpaceHeight:f}=M,_=Y.value,g=B.value,h=te.value,m=ee.value,x=H.value,b=z.value,T=j.value,E=C.default,y=C.header,S=C.footer;const I=C.prefix;return b?(0,_vue.h)("div",{ref:L,class:["vxe-select--readonly",e]},[(0,_vue.h)("div",{class:"vxe-select-slots",ref:"hideOption"},E?E({}):[]),(0,_vue.h)("span",{class:"vxe-select-label",title:m},h)]):(b=D.value,(0,_vue.h)("div",{ref:L,class:["vxe-select",e?_xeUtils.default.isFunction(e)?e({$select:F}):e:"",{["size--"+_]:_,"is--visible":d,"is--disabled":g,"is--filter":i,"is--loading":a,"is--active":s}]},[(0,_vue.h)("div",{class:"vxe-select-slots",ref:"hideOption"},E?E({}):[]),(0,_vue.h)(_input.default,{ref:O,clearable:V.clearable,placeholder:T,readonly:!0,disabled:g,type:"text",prefixIcon:V.prefixIcon,suffixIcon:a?(0,_ui.getIcon)().SELECT_LOADED:d?(0,_ui.getIcon)().SELECT_OPEN:(0,_ui.getIcon)().SELECT_CLOSE,autoFocus:!1,title:m,modelValue:h,onClear:re,onClick:me,onFocus:he,onBlur:xe,onSuffixClick:be},I?{prefix:()=>I({})}:{}),(0,_vue.h)(_vue.Teleport,{to:"body",disabled:!x||!u},[(0,_vue.h)("div",{ref:A,class:["vxe-table--ignore-clear vxe-select--panel",t?_xeUtils.default.isFunction(t)?t({$select:F}):t:"",{["size--"+_]:_,"is--transfer":x,"ani--leave":!a&&c,"ani--enter":!a&&d}],placement:M.panelPlacement,style:M.panelStyle},u&&(d||c)?[(0,_vue.h)("div",{class:"vxe-select--panel-wrapper"},[i?(0,_vue.h)("div",{class:"vxe-select--panel-search"},[(0,_vue.h)(_input.default,{ref:P,class:"vxe-select-search--input",modelValue:M.searchValue,type:"text",clearable:!0,disabled:!1,readonly:!1,placeholder:(0,_ui.getI18n)("vxe.select.search"),prefixIcon:(0,_ui.getIcon)().INPUT_SEARCH,"onUpdate:modelValue":Te,onFocus:Ee,onChange:Se,onSearch:Se})]):(0,_ui.renderEmptyElement)(F),o||n&&l||r||y?(0,_vue.h)("div",{class:"vxe-select--panel-header"},y?N(y,{}):[(0,_vue.h)("div",{class:"vxe-select--header-button"},[o?(0,_vue.h)("div",{class:"vxe-select--header-total"},(0,_ui.getI18n)("vxe.select.total",[b.length,v.length])):(0,_ui.renderEmptyElement)(F),(0,_vue.h)("div",{class:"vxe-select--header-btns"},[n&&l?(0,_vue.h)(_button.default,{content:(0,_ui.getI18n)("vxe.select.allChecked"),mode:"text",onClick:ue}):(0,_ui.renderEmptyElement)(F),r?(0,_vue.h)(_button.default,{content:(0,_ui.getI18n)("vxe.select.clear"),mode:"text",onClick:se}):(0,_ui.renderEmptyElement)(F)])])]):(0,_ui.renderEmptyElement)(F),(0,_vue.h)("div",{class:"vxe-select--panel-body"},[(0,_vue.h)("div",{ref:w,class:"vxe-select-option--wrapper",onScroll:Ae},[(0,_vue.h)("div",{class:"vxe-select--y-space",style:{height:p?p+"px":""}}),(0,_vue.h)("div",{ref:k,class:"vxe-select--body",style:{transform:`translateY(${f}px)`}},(()=>{var{optList:e,searchLoading:t}=M;return t?[(0,_vue.h)("div",{class:"vxe-select--search-loading"},[(0,_vue.h)("i",{class:["vxe-select--search-icon",(0,_ui.getIcon)().SELECT_LOADED]}),(0,_vue.h)("span",{class:"vxe-select--search-text"},(0,_ui.getI18n)("vxe.select.loadingText"))])]:e.length?Me(e):[(0,_vue.h)("div",{class:"vxe-select--empty-placeholder"},V.emptyText||(0,_ui.getI18n)("vxe.select.emptyText"))]})())])]),S?(0,_vue.h)("div",{class:"vxe-select--panel-footer"},N(S,{})):(0,_ui.renderEmptyElement)(F)])]:[])])]))},F},render(){return this.renderVN()}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _vue=require("vue"),_comp=require("../../ui/src/comp"),_xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../ui"),_dom=require("../../ui/src/dom"),_utils=require("../../ui/src/utils"),_vn=require("../../ui/src/vn"),_input=_interopRequireDefault(require("../../input/src/input")),_button=_interopRequireDefault(require("../../button/src/button"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function isOptionVisible(e){return!1!==e.visible}function getOptUniqueId(){return _xeUtils.default.uniqueId("opt_")}function createInternalData(){return{synchData:[],fullData:[],afterVisibleList:[],optAddMaps:{},optGroupKeyMaps:{},optFullValMaps:{},remoteValMaps:{},lastScrollLeft:0,lastScrollTop:0,scrollYStore:{startIndex:0,endIndex:0,visibleSize:0,offsetSize:0,rowHeight:0},lastScrollTime:0,hpTimeout:void 0}}var _default=exports.default=(0,_comp.defineVxeComponent)({name:"VxeSelect",props:{modelValue:[String,Number,Boolean,Array],defaultConfig:Object,clearable:Boolean,placeholder:String,readonly:{type:Boolean,default:null},loading:Boolean,disabled:{type:Boolean,default:null},multiple:Boolean,multiCharOverflow:{type:[Number,String],default:()=>(0,_ui.getConfig)().select.multiCharOverflow},prefixIcon:String,allowCreate:{type:Boolean,default:()=>(0,_ui.getConfig)().select.allowCreate},placement:String,lazyOptions:Array,options:Array,optionProps:Object,optionGroups:Array,optionGroupProps:Object,optionConfig:Object,className:[String,Function],popupClassName:[String,Function],max:{type:[String,Number],default:null},zIndex:Number,size:{type:String,default:()=>(0,_ui.getConfig)().select.size||(0,_ui.getConfig)().size},filterable:Boolean,filterMethod:Function,remote:Boolean,remoteConfig:Object,emptyText:String,showTotalButoon:{type:Boolean,default:()=>(0,_ui.getConfig)().select.showTotalButoon},showCheckedButoon:{type:Boolean,default:()=>(0,_ui.getConfig)().select.showCheckedButoon},showClearButton:{type:Boolean,default:()=>(0,_ui.getConfig)().select.showClearButton},transfer:{type:Boolean,default:null},virtualYConfig:Object,scrollY:Object,remoteMethod:Function,optionId:{type:String,default:()=>(0,_ui.getConfig)().select.optionId},optionKey:Boolean},emits:["update:modelValue","change","all-change","clear","blur","focus","click","scroll","visible-change"],setup(V,e){const{slots:C,emit:a}=e,b=(0,_vue.inject)("$xeModal",null),T=(0,_vue.inject)("$xeDrawer",null),E=(0,_vue.inject)("$xeTable",null),i=(0,_vue.inject)("$xeForm",null),o=(0,_vue.inject)("xeFormItemInfo",null);var t=_xeUtils.default.uniqueId();const L=(0,_vue.ref)(),O=(0,_vue.ref)(),P=(0,_vue.ref)(),w=(0,_vue.ref)(),A=(0,_vue.ref)(),k=(0,_vue.ref)(),z=(0,_ui.useSize)(V)["computeSize"],M=(0,_vue.reactive)({initialized:!1,scrollYLoad:!1,bodyHeight:0,topSpaceHeight:0,optList:[],staticOptions:[],reactFlag:0,currentOption:null,searchValue:"",searchLoading:!1,panelIndex:0,panelStyle:{},panelPlacement:null,triggerFocusPanel:!1,visiblePanel:!1,isAniVisible:!1,isActivated:!1}),I=createInternalData(),y={refElem:L},F={xID:t,props:V,context:e,reactData:M,internalData:I,getRefMaps:()=>y},H=(0,_vue.computed)(()=>{var e=V["readonly"];return null===e?!!i&&i.props.readonly:e}),B=(0,_vue.computed)(()=>{var e=V["disabled"];return null===e?!!i&&i.props.disabled:e}),j=(0,_vue.computed)(()=>{var e=V["transfer"];if(null===e){var t=(0,_ui.getConfig)().select.transfer;if(_xeUtils.default.isBoolean(t))return t;if(E||b||T||i)return!0}return e}),q=(0,_vue.computed)(()=>{var e=V["placeholder"];return(e=e||(0,_ui.getConfig)().select.placeholder)?(0,_utils.getFuncText)(e):(0,_ui.getI18n)("vxe.base.pleaseSelect")}),S=(0,_vue.computed)(()=>Object.assign({},V.defaultConfig)),K=(0,_vue.computed)(()=>Object.assign({},V.optionProps)),$=(0,_vue.computed)(()=>Object.assign({},V.optionGroupProps)),c=(0,_vue.computed)(()=>{return K.value.label||"label"}),D=(0,_vue.computed)(()=>{return K.value.value||"value"}),G=(0,_vue.computed)(()=>{return $.value.label||"label"}),R=(0,_vue.computed)(()=>{return $.value.options||"options"}),W=(0,_vue.computed)(()=>{var e=N.value;return ae(e)}),X=(0,_vue.computed)(()=>Object.assign({},(0,_ui.getConfig)().select.virtualYConfig||(0,_ui.getConfig)().select.scrollY,V.virtualYConfig||V.scrollY)),Z=(0,_vue.computed)(()=>Object.assign({},(0,_ui.getConfig)().select.remoteConfig,V.remoteConfig)),J=(0,_vue.computed)(()=>Object.assign({},(0,_ui.getConfig)().select.optionConfig,V.optionConfig)),Q=(0,_vue.computed)(()=>_xeUtils.default.toNumber(V.multiCharOverflow)),N=(0,_vue.computed)(()=>{var{modelValue:e,multiple:t}=V;let l=[];return _xeUtils.default.isArray(e)?l=e:t?(0,_utils.eqEmptyValue)(e)||(l=-1<(""+e).indexOf(",")?(""+e).split(","):[e]):l=null==e?[]:[e],l}),ee=(0,_vue.computed)(()=>{var e=V["remote"],t=M["reactFlag"],l=N.value;return(e&&t?l.map(e=>ie(e)):l.map(e=>oe(e))).join(", ")}),te=(0,_vue.computed)(()=>{var{remote:e,multiple:t}=V,l=M["reactFlag"],a=Q.value,i=N.value;return e&&l?i.map(e=>ie(e)).join(", "):(e=i.map(e=>oe(e)),t&&0<a&&e.length>a?e.slice(0,a)+"...":e.join(", "))}),U=(e,t)=>e&&(_xeUtils.default.isString(e)&&(e=C[e]||null),_xeUtils.default.isFunction(e))?(0,_vn.getSlotVNs)(e(t)):[],r=(e,t,l)=>{a(e,(0,_ui.createEvent)(l,{$select:F},t))},le=e=>{a("update:modelValue",e)},_=()=>{return J.value.keyField||V.optionId||"_X_OPTION_KEY"},Y=e=>{e=e[_()];return e?encodeURIComponent(e):""},ae=e=>{var{multiple:t,max:l}=V;return!(!t||!l)&&e.length>=_xeUtils.default.toNumber(l)},ie=t=>{var e=V["lazyOptions"],{remoteValMaps:l,optFullValMaps:a}=I;const i=D.value;var o=c.value,l=l[t]||a[t],a=l?l.item:null;if(a)return _xeUtils.default.toValueString(a[o]);if(e){l=e.find(e=>e[i]===t);if(l)return l[o]}return t},oe=t=>{var e=V["lazyOptions"],l=I["optFullValMaps"];const a=D.value;var i=c.value,l=M.reactFlag?l[t]:null;if(l)return l.item[i];if(e){l=e.find(e=>e[a]===t);if(l)return l[i]}return t},g=()=>{const{modelValue:t,filterable:e,filterMethod:l}=V,a=M["searchValue"],{fullData:i,optFullValMaps:o}=I,n=c.value,r=D.value,u=(""+(a||"")).toLowerCase();let s=[];return(s=e&&l?i.filter(e=>isOptionVisible(e)&&l({$select:F,group:null,option:e,searchValue:a,value:t})):e?i.filter(e=>isOptionVisible(e)&&(!u||-1<(""+(e[n]||e[r])).toLowerCase().indexOf(u))):i.filter(isOptionVisible)).forEach((e,t)=>{e=o[e[r]];e&&(e._index=t)}),I.afterVisibleList=s,(0,_vue.nextTick)()},ne=e=>{e&&(M.currentOption=e)},u=()=>{const l=V["placement"],a=M["panelIndex"],i=L.value,o=A.value,n=j.value;var e=()=>{var e=(0,_dom.updatePanelPlacement)(i,o,{placement:l,teleportTo:n}),t=Object.assign(e.style,{zIndex:a});M.panelStyle=t,M.panelPlacement=e.placement};return e(),(0,_vue.nextTick)().then(e)},v=()=>{var{loading:e,filterable:t,remote:l}=V,{fullData:a,hpTimeout:i}=I,o=B.value,n=Z.value;e||o||(i&&(clearTimeout(i),I.hpTimeout=void 0),M.initialized||(M.initialized=!0),M.isActivated=!0,M.isAniVisible=!0,t&&(l&&n.enabled&&n.autoLoad&&!a.length?ye:(g(),f))(),setTimeout(()=>{M.visiblePanel=!0,V.filterable&&(0,_vue.nextTick)(()=>{var e=P.value;e&&e.focus()});x().then(()=>{(0,_vue.nextTick)(()=>{var{isAniVisible:e,visiblePanel:t}=M,l=I["optFullValMaps"],a=N.value;a.length&&e&&t&&(e=M.reactFlag?l[""+a[0]]:null)&&Oe(e.item)}),m()})},10),setTimeout(()=>{x().then(()=>m())},100),(e=V.zIndex)?M.panelIndex=e:M.panelIndex<(0,_utils.getLastZIndex)()&&(M.panelIndex=(0,_utils.nextZIndex)()),u(),r("visible-change",{visible:!0},null))},d=()=>{M.searchValue="",M.searchLoading=!1,M.visiblePanel=!1,I.hpTimeout=setTimeout(()=>{M.isAniVisible=!1},350),r("visible-change",{visible:!1},null)},s=(e,t,l)=>{le(t),t!==V.modelValue&&(r("change",{value:t,option:l},e),i)&&o&&i.triggerItemEvent(e,o.itemConfig.field,t)},p=(e,t)=>{I.remoteValMaps={},s(e,t,null),r("clear",{value:t},e)},re=e=>{e=e.$event;p(e,null),d()},ue=e=>{var e=e["$event"],{multiple:t,max:l}=V,a=M["optList"],i=D.value;if(t){var o=N.value.slice(0);for(let e=0;e<a.length;e++){const n=a[e][i];if(ae(o)){_ui.VxeUI&&_ui.VxeUI.modal.message({content:(0,_ui.getI18n)("vxe.select.overSizeErr",[l]),status:"warning"});break}o.some(e=>e===n)||o.push(n)}s(e,o,a[0]),r("all-change",{value:o},e)}},se=e=>{e=e.$event;p(e,null),d()},ce=(t,l)=>{var e=V["multiple"],a=I["remoteValMaps"];const i=l[D.value];var o=a[i];if(M.visiblePanel){if(o?o.item=l:a[i]={key:Y(l),item:l,_index:-1},e){let e=[];o=N.value,a=_xeUtils.default.findIndexOf(o,e=>e===i);e=-1===a?o.concat([i]):o.filter(e=>e!==i),s(t,e,l)}else s(t,i,l),d();M.reactFlag++}},ve=e=>{var t=M["visiblePanel"];B.value||t&&(t=A.value,((0,_dom.getEventTargetNode)(e,t).flag?u:d)())},de=e=>{var t,l,a=M["visiblePanel"];B.value||(t=L.value,l=A.value,M.isActivated=(0,_dom.getEventTargetNode)(e,t).flag||(0,_dom.getEventTargetNode)(e,l).flag,a&&!M.isActivated&&d())},h=e=>{var t=e.disabled,e=Y(e);return!t&&!ke(e)},pe=(e,t)=>{var l=V["allowCreate"],a=M["optList"],{optFullValMaps:i,optAddMaps:o,afterVisibleList:n}=I,r=D.value;let u=n,s=0;if(l&&a.length&&(n=a[0],o[l=Y(n)])&&(s=1,u=[o[l]].concat(u)),!e)if(t)for(let e=0;e<u.length;e++){var c=u[e];if(h(c))return c}else for(let e=u.length-1;0<=e;e--){var v=u[e];if(h(v))return v}let d=0;a=e?i[e[r]]:null;if(-1<(d=a?a._index+s:d))if(t)for(let e=d+1;e<=u.length-1;e++){var p=u[e];if(h(p))return p}else if(0<d)for(let e=d-1;0<=e;e--){var f=u[e];if(h(f))return f}return null},fe=t=>{var e=V["clearable"],{visiblePanel:l,currentOption:a}=M;if(!B.value){var i=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.TAB),o=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ENTER),n=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ESCAPE),r=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ARROW_UP),u=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.ARROW_DOWN),s=_ui.globalEvents.hasKey(t,_ui.GLOBAL_EVENT_KEYS.DELETE);if(i&&(M.isActivated=!1),l){if(n||i)d();else if(o)a&&(t.preventDefault(),t.stopPropagation(),ce(t,a));else if(r||u){t.preventDefault();let e=pe(a,u);(e=e||pe(null,u))&&(ne(e),Oe(e,u))}}else(r||u||o)&&M.isActivated&&(t.preventDefault(),v());M.isActivated&&s&&e&&p(t,null)}},_e=()=>{var{visiblePanel:e,isActivated:t}=M;e&&d(),t&&(M.isActivated=!1),(e||t)&&(e=O.value)&&e.blur()},ge=()=>{var e=M["visiblePanel"];e&&u()},he=e=>{B.value||M.visiblePanel||(M.triggerFocusPanel=!0,v(),setTimeout(()=>{M.triggerFocusPanel=!1},500)),r("focus",{},e)},me=e=>{Ie(e),r("click",{triggerButton:!1,visible:M.visiblePanel},e)},xe=e=>{M.isActivated=!1,r("blur",{},e)},be=e=>{Ie(e),r("click",{triggerButton:!0,visible:M.visiblePanel},e)},Te=e=>{M.searchValue=e},Ee=()=>{M.isActivated=!0},ye=()=>{var{modelValue:e,remote:t,remoteMethod:l}=V,a=M["searchValue"],i=Z.value,l=i.queryMethod||l;t&&l&&i.enabled?(M.searchLoading=!0,Promise.resolve(l({$select:F,searchValue:a,value:e})).then(()=>(0,_vue.nextTick)()).catch(()=>(0,_vue.nextTick)()).finally(()=>{M.searchLoading=!1,g(),f()})):(g(),f())},Se=_xeUtils.default.debounce(ye,350,{trailing:!0}),Ie=e=>{e=e.$event;e.preventDefault(),M.triggerFocusPanel?M.triggerFocusPanel=!1:(M.visiblePanel?d:v)()},Ve=()=>{var e=M["scrollYLoad"],{scrollYStore:t,afterVisibleList:l}=I;M.bodyHeight=e?l.length*t.rowHeight:0,M.topSpaceHeight=e?Math.max(t.startIndex*t.rowHeight,0):0},Ce=()=>{var{filterable:e,allowCreate:t}=V;const{scrollYLoad:l,searchValue:a}=M;var{optAddMaps:i,scrollYStore:o,afterVisibleList:n}=I;const r=c.value;var u=D.value,o=l?n.slice(o.startIndex,o.endIndex):n.slice(0);return e&&t&&a&&(o.some(e=>e[r]===a)||(n=i[a]||(0,_vue.reactive)({[_()]:a,[r]:a,[u]:a}),i[a]=n,o.unshift(n))),M.optList=o,(0,_vue.nextTick)()},f=()=>{Ce(),Ve()},Le=()=>(0,_vue.nextTick)().then(()=>{var e=M["scrollYLoad"],t=I["scrollYStore"],l=k.value,a=X.value;let i=0,o;(o=l?o||l.children[0]:o)&&(i=o.offsetHeight),i=Math.max(20,i),t.rowHeight=i,(e?(l=w.value,e=Math.max(8,l?Math.ceil(l.clientHeight/i):0),l=Math.max(0,Math.min(2,_xeUtils.default.toNumber(a.oSize))),t.offsetSize=l,t.visibleSize=e,t.endIndex=Math.max(t.startIndex,e+l,t.endIndex),f):Ve)()}),Oe=(e,t)=>{var l,a,i=M["scrollYLoad"],{optFullValMaps:o,scrollYStore:n}=I,o=o[e[D.value]];o&&(e=o.key,-1<(o=o._index))&&(l=w.value,a=A.value)&&(a=a.querySelector(`[optid='${e}']`),l)&&(a?(e=l.offsetHeight,t?a.offsetTop+a.offsetHeight-l.scrollTop>e?l.scrollTop=a.offsetTop+a.offsetHeight-e:(a.offsetTop+1<l.scrollTop||a.offsetTop+1>l.scrollTop+l.clientHeight)&&(l.scrollTop=a.offsetTop-1):a.offsetTop+1<l.scrollTop||a.offsetTop+1>l.scrollTop+l.clientHeight?l.scrollTop=a.offsetTop-1:a.offsetTop+a.offsetHeight-l.scrollTop>e&&(l.scrollTop=a.offsetTop+a.offsetHeight-e)):i&&(l.scrollTop=t?o*n.rowHeight-l.clientHeight+n.rowHeight:o*n.rowHeight))},Pe=(e,t)=>{var l=w.value;return l&&(_xeUtils.default.isNumber(e)&&(l.scrollLeft=e),_xeUtils.default.isNumber(t))&&(l.scrollTop=t),M.scrollYLoad?new Promise(e=>{setTimeout(()=>{(0,_vue.nextTick)(()=>{e()})},50)}):(0,_vue.nextTick)()},m=()=>{const{lastScrollLeft:e,lastScrollTop:t}=I;return n().then(()=>{if(e||t)return I.lastScrollLeft=0,I.lastScrollTop=0,Pe(e,t)})},x=()=>{var e=L.value;return e&&e.clientWidth&&e.clientHeight?Le():Promise.resolve()},we=e=>{var t=I["scrollYStore"],{startIndex:l,endIndex:a,visibleSize:i,offsetSize:o,rowHeight:n}=t,e=e.target.scrollTop,e=Math.floor(e/n),n=Math.max(0,e-1-o),o=e+i+o;!(e<=l||a-i-1<=e)||l===n&&a===o||(t.startIndex=n,t.endIndex=o,f())},Ae=e=>{var t=e.target,l=t.scrollTop,t=t.scrollLeft,a=t!==I.lastScrollLeft,i=l!==I.lastScrollTop;I.lastScrollTop=l,I.lastScrollLeft=t,M.scrollYLoad&&we(e),I.lastScrollTime=Date.now(),r("scroll",{scrollLeft:t,scrollTop:l,isX:a,isY:i},e)},l=e=>{{var t=e||[];const r=R.value,u=D.value,s=_(),c={},v={},d=[],p=e=>{d.push(e);let t=Y(e);t||(t=getOptUniqueId(),e[s]=t),v[e[u]]={key:t,item:e,_index:-1}};t.forEach(e=>{p(e),e[r]&&(c[e[s]]=e)[r].forEach(p)}),I.fullData=d,I.optGroupKeyMaps=c,I.optFullValMaps=v,M.reactFlag++,g()}var{isLoaded:t,fullData:l,scrollYStore:a}=I,i=S.value,o=X.value;const n=D.value;if(Object.assign(a,{startIndex:0,endIndex:1,visibleSize:0}),I.synchData=e||[],M.scrollYLoad=!!o.enabled&&-1<o.gt&&(0===o.gt||o.gt<=l.length),Ce(),!t){a=i["selectMode"];if(0<e.length&&_xeUtils.default.eqNull(V.modelValue)){if("first"===a||"last"===a){const f=_xeUtils.default[a](e);f&&(0,_vue.nextTick)(()=>{_xeUtils.default.eqNull(V.modelValue)&&le(f[n])})}I.isLoaded=!0}}return Le().then(()=>{m()})},n=()=>{var e=w.value;return e&&(e.scrollTop=0,e.scrollLeft=0),I.lastScrollTop=0,(I.lastScrollLeft=0,_vue.nextTick)()},ke=e=>{var t=I["optGroupKeyMaps"];return!!t[e]};t={dispatchEvent:r,loadData:l,reloadData(e){return I.isLoaded=!1,n(),l(e)},isPanelVisible(){return M.visiblePanel},togglePanel(){return(M.visiblePanel?d:v)(),(0,_vue.nextTick)()},hidePanel(){return M.visiblePanel&&d(),(0,_vue.nextTick)()},showPanel(){return M.visiblePanel||v(),(0,_vue.nextTick)()},refreshOption(){return g(),f(),(0,_vue.nextTick)()},focus(){var e=O.value;return e&&e.blur(),M.isActivated=!0,(0,_vue.nextTick)()},blur(){var e=O.value;return e&&e.blur(),(M.isActivated=!1,_vue.nextTick)()},recalculate:x,clearScroll:n};Object.assign(F,t);const Me=e=>{const{allowCreate:f,optionKey:_}=V,g=M["currentOption"],h=I["optAddMaps"];var t=J.value;const m=c.value,x=D.value,b=G.value,T=N.value,{useKey:E,height:y}=t,S=C.option;return e.map((t,e)=>{var{slots:l,className:a}=t,i=Y(t),o=t[x];const n=ke(i);var r=!(!f||!h[i]),u=!r&&-1<T.indexOf(o),s=r||!n||isOptionVisible(t);const c=!r&&(v=u,!!t.disabled||!(!W.value||v));var v=l?l.default:null,l={option:t,group:n?t:null,$select:F};let d="",p=[];return p=S?U(S,l):v?U(v,l):d=(0,_utils.getFuncText)(t[n?b:m]||o),s?(0,_vue.h)("div",{key:E||_?i:e,class:["vxe-select-option",a?_xeUtils.default.isFunction(a)?a(l):a:"",{"vxe-select-optgroup":n,"is--disabled":c,"is--selected":u,"is--add":r,"is--hover":g&&Y(g)===i}],optid:i,title:d||null,style:y?{height:(0,_dom.toCssUnit)(y)}:void 0,onMousedown:e=>{0===e.button&&e.stopPropagation()},onClick:e=>{c||n||ce(e,t)},onMouseenter:()=>{var e;c||n||(e=I.lastScrollTime)&&Date.now()<e+250||ne(t)}},f?[(0,_vue.h)("span",{key:1,class:"vxe-select-option--label"},p),r?(0,_vue.h)("span",{key:2,class:"vxe-select-option--add-icon"},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().SELECT_ADD_OPTION})]):(0,_ui.renderEmptyElement)(F)]:p):(0,_ui.renderEmptyElement)(F)})};return(0,_vue.watch)(()=>M.staticOptions,e=>{l(e)}),(0,_vue.watch)(()=>V.options,e=>{l(e||[])}),(0,_vue.watch)(()=>V.optionGroups,e=>{l(e||[])}),(0,_vue.onMounted)(()=>{(0,_vue.nextTick)(()=>{var{options:e,optionGroups:t}=V;t?l(t):e&&l(e)}),_ui.globalEvents.on(F,"mousewheel",ve),_ui.globalEvents.on(F,"mousedown",de),_ui.globalEvents.on(F,"keydown",fe),_ui.globalEvents.on(F,"blur",_e),_ui.globalEvents.on(F,"resize",ge)}),(0,_vue.onUnmounted)(()=>{_ui.globalEvents.off(F,"mousewheel"),_ui.globalEvents.off(F,"mousedown"),_ui.globalEvents.off(F,"keydown"),_ui.globalEvents.off(F,"blur"),_ui.globalEvents.off(F,"resize"),_xeUtils.default.assign(I,createInternalData())}),(0,_vue.provide)("$xeSelect",F),F.renderVN=()=>{var{className:e,popupClassName:t,multiple:l,loading:a,filterable:i,showTotalButoon:o,showCheckedButoon:n,showClearButton:r}=V,{initialized:u,isActivated:s,isAniVisible:c,optList:v,visiblePanel:d,bodyHeight:p,topSpaceHeight:f}=M,_=z.value,g=B.value,h=te.value,m=ee.value,x=j.value,b=H.value,T=q.value,E=C.default,y=C.header,S=C.footer;const I=C.prefix;return b?(0,_vue.h)("div",{ref:L,class:["vxe-select--readonly",e]},[(0,_vue.h)("div",{class:"vxe-select-slots",ref:"hideOption"},E?E({}):[]),(0,_vue.h)("span",{class:"vxe-select-label",title:m},h)]):(b=N.value,(0,_vue.h)("div",{ref:L,class:["vxe-select",e?_xeUtils.default.isFunction(e)?e({$select:F}):e:"",{["size--"+_]:_,"is--visible":d,"is--disabled":g,"is--filter":i,"is--loading":a,"is--active":s}]},[(0,_vue.h)("div",{class:"vxe-select-slots",ref:"hideOption"},E?E({}):[]),(0,_vue.h)(_input.default,{ref:O,clearable:V.clearable,placeholder:T,readonly:!0,disabled:g,type:"text",prefixIcon:V.prefixIcon,suffixIcon:a?(0,_ui.getIcon)().SELECT_LOADED:d?(0,_ui.getIcon)().SELECT_OPEN:(0,_ui.getIcon)().SELECT_CLOSE,autoFocus:!1,title:m,modelValue:h,onClear:re,onClick:me,onFocus:he,onBlur:xe,onSuffixClick:be},I?{prefix:()=>I({})}:{}),(0,_vue.h)(_vue.Teleport,{to:"body",disabled:!x||!u},[(0,_vue.h)("div",{ref:A,class:["vxe-table--ignore-clear vxe-select--panel",t?_xeUtils.default.isFunction(t)?t({$select:F}):t:"",{["size--"+_]:_,"is--transfer":x,"ani--leave":!a&&c,"ani--enter":!a&&d}],placement:M.panelPlacement,style:M.panelStyle},u&&(d||c)?[(0,_vue.h)("div",{class:"vxe-select--panel-wrapper"},[i?(0,_vue.h)("div",{class:"vxe-select--panel-search"},[(0,_vue.h)(_input.default,{ref:P,class:"vxe-select-search--input",modelValue:M.searchValue,type:"text",clearable:!0,disabled:!1,readonly:!1,placeholder:(0,_ui.getI18n)("vxe.select.search"),prefixIcon:(0,_ui.getIcon)().INPUT_SEARCH,"onUpdate:modelValue":Te,onFocus:Ee,onChange:Se,onSearch:Se})]):(0,_ui.renderEmptyElement)(F),o||n&&l||r||y?(0,_vue.h)("div",{class:"vxe-select--panel-header"},y?U(y,{}):[(0,_vue.h)("div",{class:"vxe-select--header-button"},[o?(0,_vue.h)("div",{class:"vxe-select--header-total"},(0,_ui.getI18n)("vxe.select.total",[b.length,v.length])):(0,_ui.renderEmptyElement)(F),(0,_vue.h)("div",{class:"vxe-select--header-btns"},[n&&l?(0,_vue.h)(_button.default,{content:(0,_ui.getI18n)("vxe.select.allChecked"),mode:"text",onClick:ue}):(0,_ui.renderEmptyElement)(F),r?(0,_vue.h)(_button.default,{content:(0,_ui.getI18n)("vxe.select.clear"),mode:"text",onClick:se}):(0,_ui.renderEmptyElement)(F)])])]):(0,_ui.renderEmptyElement)(F),(0,_vue.h)("div",{class:"vxe-select--panel-body"},[(0,_vue.h)("div",{ref:w,class:"vxe-select-option--wrapper",onScroll:Ae},[(0,_vue.h)("div",{class:"vxe-select--y-space",style:{height:p?p+"px":""}}),(0,_vue.h)("div",{ref:k,class:"vxe-select--body",style:{transform:`translateY(${f}px)`}},(()=>{var{optList:e,searchLoading:t}=M;return t?[(0,_vue.h)("div",{class:"vxe-select--search-loading"},[(0,_vue.h)("i",{class:["vxe-select--search-icon",(0,_ui.getIcon)().SELECT_LOADED]}),(0,_vue.h)("span",{class:"vxe-select--search-text"},(0,_ui.getI18n)("vxe.select.loadingText"))])]:e.length?Me(e):[(0,_vue.h)("div",{class:"vxe-select--empty-placeholder"},V.emptyText||(0,_ui.getI18n)("vxe.select.emptyText"))]})())])]),S?(0,_vue.h)("div",{class:"vxe-select--panel-footer"},U(S,{})):(0,_ui.renderEmptyElement)(F)])]:[])])]))},F},render(){return this.renderVN()}});
|