init
This commit is contained in:
1
unpackage/dist/build/mp-weixin/uni_modules/nutui-uni/components/cascaderitem/cascaderitem.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/nutui-uni/components/cascaderitem/cascaderitem.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js"),l=require("../_constants/event.js"),a=require("../_constants/prefix.js");require("../_utils/env.js");const t=require("../_utils/style.js");require("../../locale/locale.js");const n=require("../../locale/useTranslate.js"),o=require("../cascader/helper.js"),u=require("../cascader/tree.js"),i=require("../_utils/props.js"),s={...i.commonProps,modelValue:Array,visible:Boolean,options:i.makeArrayProp([]),lazy:Boolean,lazyLoad:Function,valueKey:i.makeStringProp("value"),textKey:i.makeStringProp("text"),childrenKey:i.makeStringProp("children"),convertConfig:Object,titleType:i.makeStringProp("line"),titleSize:i.makeStringProp("normal"),titleGutter:i.makeNumericProp(0),titleEllipsis:i.truthProp},r={[l.UPDATE_MODEL_EVENT]:e=>!0,[l.CHANGE_EVENT]:(e,l)=>!0,pathChange:e=>!0};Math||(c+d+v)();const c=()=>"../icon/icon.js",d=()=>"../tabpane/tabpane.js",v=()=>"../tabs/tabs.js",p=`${a.PREFIX}-cascader-item`,{translate:f}=n.useTranslate(p),h=e.defineComponent({name:p,options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),m=e.defineComponent({...h,props:s,emits:r,setup(a,{emit:n}){const i=a,s=n,r=e.computed((()=>t.getMainClass(i,p))),c=e.computed((()=>({lazy:i.lazy,lazyLoad:i.lazyLoad,valueKey:i.valueKey,textKey:i.textKey,childrenKey:i.childrenKey,convertConfig:i.convertConfig}))),d=e.ref(0),v=e.ref(!1),h=e.ref(i.modelValue),m=e.ref(new u.Tree([],{})),y=e.ref([]),g=e.computed((()=>c.value.lazy&&Boolean(c.value.lazyLoad))),N=new Map;let C;const E={async handleNode(e,a){const{disabled:t,loading:n}=e;if((a||!t)&&y.value[d.value])if(m.value.isLeaf(e,g.value)){if(e.leaf=!0,y.value[d.value].selectedNode=e,y.value=y.value.slice(0,e.level+1),!a){const e=y.value.map((e=>e.selectedNode));!function(e){const a=e.map((e=>e.value));h.value=a,s(l.UPDATE_MODEL_EVENT,a),s(l.CHANGE_EVENT,a,e)}(e),s("pathChange",e)}}else if(m.value.hasChildren(e,g.value)){const l=e.level+1;if(y.value[d.value].selectedNode=e,y.value=y.value.slice(0,l),y.value.push({nodes:e.children||[],selectedNode:null}),d.value=l,!a){const e=y.value.map((e=>e.selectedNode));s("pathChange",e)}}else C=e,n||(await P(e),C===e&&(y.value[d.value].selectedNode=e,E.handleNode(e,a)))},handleTabClick(e){C=null,d.value=Number(e.paneKey)},isSelected(e,l){var a;return(null==(a=null==e?void 0:e.selectedNode)?void 0:a.value)===l.value}};async function b(){const e=h.value;if(void 0===e||!m.value.nodes.length)return;if(0===e.length)return d.value=0,void(y.value=[{nodes:m.value.nodes,selectedNode:null}]);let l=e;if(g.value&&Array.isArray(e)&&e.length){l=[];const a=m.value.nodes.find((l=>l.value===e[0]));if(a){l=[a.value],v.value=!0;const t=await e.slice(1).reduce((async(e,a)=>{var t;const n=await e;await P(n);const o=null==(t=null==n?void 0:n.children)?void 0:t.find((e=>e.value===a));return o&&l.push(a),Promise.resolve(o)}),Promise.resolve(a));await P(t),v.value=!1}}if(l.length&&e===i.modelValue){m.value.getPathNodesByValue(l).forEach(((e,l)=>{d.value=l,E.handleNode(e,!0)}))}}async function P(e){if(!e)return;if(!c.value.lazyLoad)return void(e.leaf=!0);if(m.value.isLeaf(e,g.value)||m.value.hasChildren(e,g.value))return;e.loading=!0;const l=e.root?null:e;let a=N.get(e);a||(a=new Promise((l=>{var a,t;null==(t=(a=c.value).lazyLoad)||t.call(a,e,l)})),N.set(e,a));const t=await a;Array.isArray(t)&&t.length>0?m.value.updateChildren(t,l):e.leaf=!0,e.loading=!1,N.delete(e)}function j(e){return e.selectedNode?e.selectedNode.text:f("select")}return e.watch((()=>[c.value,i.options]),(()=>{!async function(){N.clear(),y.value=[],d.value=0,v.value=!1,C=null;let{options:e}=i;c.value.convertConfig&&(e=o.convertListToOptions(e,c.value.convertConfig)),m.value=new u.Tree(e,{value:c.value.valueKey,text:c.value.textKey,children:c.value.childrenKey}),g.value&&!m.value.nodes.length&&await P({root:!0,loading:!0,text:"",value:""}),y.value=[{nodes:m.value.nodes,selectedNode:null}],b()}()}),{deep:!0,immediate:!0}),e.watch((()=>i.modelValue),(e=>{e!==h.value&&(h.value=e,b())})),e.watch((()=>i.visible),(e=>{e&&Array.isArray(h.value)&&h.value.length>0&&b()})),(l,a)=>e.e({a:!v.value&&y.value.length},!v.value&&y.value.length?{b:e.f(y.value,((l,a,t)=>({a:e.f(l.nodes,((a,n,o)=>e.e({a:e.t(a.text),b:a.loading},a.loading?{c:"2a1ec3fa-2-"+t+"-"+o+",2a1ec3fa-1-"+t,d:e.p({"custom-class":"nut-cascader-item__icon-loading",loading:!0,name:"loading"})}:{e:"2a1ec3fa-3-"+t+"-"+o+",2a1ec3fa-1-"+t,f:e.p({"custom-class":"nut-cascader-item__icon-check",name:"checklist"})},{g:E.isSelected(l,a)?1:"",h:a.disabled?1:"",i:E.isSelected(l,a),j:a.disabled||void 0,k:e.o((e=>E.handleNode(a,!1)),a.value),l:a.value}))),b:a,c:"2a1ec3fa-1-"+t+",2a1ec3fa-0",d:e.p({title:j(l)})})))}:{c:e.p({title:"Loading..."})},{d:e.o(E.handleTabClick),e:e.o((e=>d.value=e)),f:e.p({"custom-class":r.value,"custom-style":i.customStyle,type:i.titleType,size:i.titleSize,"title-gutter":i.titleGutter,ellipsis:i.titleEllipsis,"title-scroll":!0,modelValue:d.value})})}});wx.createComponent(m);
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"nut-icon": "../icon/icon",
|
||||
"nut-tab-pane": "../tabpane/tabpane",
|
||||
"nut-tabs": "../tabs/tabs"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<nut-tabs wx:if="{{f}}" u-s="{{['d']}}" bindclick="{{d}}" u-i="2a1ec3fa-0" bind:__l="__l" bindupdateModelValue="{{e}}" u-p="{{f}}"><block wx:if="{{a}}"><nut-tab-pane wx:for="{{b}}" wx:for-item="pane" wx:key="b" u-s="{{['d']}}" u-i="{{pane.c}}" bind:__l="__l" u-p="{{pane.d}}"><view class="nut-cascader-pane" role="menu"><scroll-view style="height:100%" scroll-y="{{true}}"><block wx:for="{{pane.a}}" wx:for-item="node" wx:key="l"><view class="{{['nut-cascader-item__inner', node.g && 'active', node.h && 'disabled']}}" role="menuitemradio" aria-checked="{{node.i}}" aria-disabled="{{node.j}}" bindtap="{{node.k}}"><view class="nut-cascader-item__title">{{node.a}}</view><nut-icon wx:if="{{node.b}}" u-i="{{node.c}}" bind:__l="__l" u-p="{{node.d}}"/><nut-icon wx:else u-i="{{node.e}}" bind:__l="__l" u-p="{{node.f||''}}"/></view></block></scroll-view></view></nut-tab-pane></block><block wx:else><nut-tab-pane wx:if="{{c}}" u-s="{{['d']}}" u-i="2a1ec3fa-4,2a1ec3fa-0" bind:__l="__l" u-p="{{c}}"><view class="nut-cascader-pane"/></nut-tab-pane></block></nut-tabs>
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user