mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
var e=Object.defineProperty,o=Object.defineProperties,l=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,u=(o,l,a)=>l in o?e(o,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[l]=a,s=(e,o)=>{for(var l in o||(o={}))t.call(o,l)&&u(e,l,o[l]);if(a)for(var l of a(o))n.call(o,l)&&u(e,l,o[l]);return e},i=(e,a)=>o(e,l(a));import{u as d,_ as r}from"./wd-message-box.fnmIfhPa.js";import{d as c,a3 as p,r as m,J as v,c as f,C as g,a7 as b,ac as h,b as w,z as y,g as _,w as x,h as V,D as $,aF as k,E as j,m as C,F as z,n as K,i as O,q as S,k as P,j as T,t as I,a8 as U,B as H,Y as F,Z as N,L as q,e as B,f as E,l as M,K as Q,u as G}from"./index-ChV97F5w.js";import{q as L,e as Y,g as A,l as D,a as X,_ as J}from"./page-wraper.D9WpzC1k.js";import{b as W,m as Z,c as R,a as ee,n as oe,f as le,w as ae,_ as te}from"./base64.D3gEw_Hf.js";import{p as ne,r as ue,c as se}from"./clickoutside.CJmLG0WC.js";import{u as ie}from"./useChildren.C_02WC2s.js";import{_ as de}from"./demo-block.bo7yY1Pq.js";import{_ as re}from"./wd-slider.Dosr1Emp.js";import{_ as ce}from"./wd-button.DXEkLyH0.js";import{w as pe}from"./wd-sort-button.1KZLKNXP.js";import"./wd-input.Bbnatfb8.js";import"./useTranslate.BPiTMMfr.js";import"./wd-root-portal.BUSGVytV.js";import"./useTouch.yh-0Hnfy.js";const me=Symbol("wd-drop-menu"),ve=i(s({},W),{zIndex:Z(12),direction:ee("down"),modal:R(!0),closeOnClickModal:R(!0),duration:Z(200)}),fe=i(s({},W),{customTitle:ee(""),customIcon:ee(""),modelValue:[String,Number],options:le(),disabled:R(!1),iconName:ee("check"),title:String,icon:ee("arrow-down"),iconSize:oe,beforeToggle:Function,valueKey:ee("value"),labelKey:ee("label"),tipKey:ee("tip"),customPopupClass:ee(""),customPopupStyle:ee(""),popupHeight:ee(""),rootPortal:R(!1)}),ge=te(c(i(s({},{name:"wd-drop-menu-item",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),{props:fe,emits:["update:modelValue","change","open","opened","close","closed"],setup(e,{expose:o,emit:l}){const a=e,t=l,n=p(L,null),u=m(!1),s=m(!1),i=m(),d=m(12),r=m(0),{parent:c}=Y(me),{proxy:F}=v(),N=f((()=>{let e="";return e=u.value&&c?"down"===c.props.direction?`top: calc(var(--window-top) + ${c.offset.value}px); bottom: 0;`:`top: 0; bottom: calc(var(--window-bottom) + ${c.offset.value}px)`:"",e}));function q(){s.value&&(U(a.beforeToggle)?a.beforeToggle({status:!1,resolve:e=>{e&&B()}}):B())}function B(){s.value&&(s.value=!1)}function E(){s.value||(U(a.beforeToggle)?a.beforeToggle({status:!0,resolve:e=>{e&&M()}}):M())}function M(){u.value=!0,s.value=!0,c&&(r.value=Number(c.props.duration),i.value="down"===c.props.direction?"top":"bottom")}function Q(){u.value=!1,t("closed")}function G(){t("open")}function D(){t("opened")}function X(){t("close")}return g((()=>a.modelValue),(e=>{H(e)&&"number"!=typeof e&&"string"!=typeof e&&console.error("[wot-design] warning(wd-drop-menu-item): the type of value should be a number or a string.")}),{deep:!0,immediate:!0}),b((()=>{n&&n.pushToQueue?n.pushToQueue(F):ne(F)})),h((()=>{n&&n.removeFromQueue?n.removeFromQueue(F):ue(F)})),o({getShowPop:function(){return s.value},open:E,close:q,toggle:function(){s.value?q():E()}}),(e,o)=>{const l=P,n=O,c=k;return u.value?(_(),w(n,{key:0,class:S(`wd-drop-item ${e.customClass}`),style:j(`pointer-events: none; z-index: ${d.value}; ${N.value};${e.customStyle}`)},{default:x((()=>[V(A,{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=e=>s.value=e),"z-index":d.value,duration:r.value,position:i.value,"custom-style":`position: absolute; pointer-events: auto; max-height: ${e.popupHeight?e.popupHeight:"80%"}; ${e.customPopupStyle}`,"custom-class":e.customPopupClass,modal:!1,"close-on-click-modal":!1,"root-portal":e.rootPortal,onBeforeEnter:G,onAfterEnter:D,onBeforeLeave:X,onAfterLeave:Q},{default:x((()=>[e.options.length?(_(),w(c,{key:0,style:j(e.popupHeight?{height:e.popupHeight}:""),"scroll-y":"","scroll-with-animation":"","show-scrollbar":!0},{default:x((()=>[(_(!0),C(z,null,K(e.options,((o,u)=>(_(),w(n,{key:u,onClick:e=>function(e){if(a.disabled)return;const{valueKey:o}=a,l=a.options[e],n=void 0!==l[o]?l[o]:l;t("update:modelValue",n),t("change",{value:n,selectedItem:l}),q()}(u),class:S("wd-drop-item__option "+((""!==o[e.valueKey]?o[e.valueKey]:o)===e.modelValue?"is-active":""))},{default:x((()=>[V(n,{class:S(`wd-drop-item__title ${e.customTitle}`)},{default:x((()=>[V(l,null,{default:x((()=>[T(I(o[e.labelKey]?o[e.labelKey]:o),1)])),_:2},1024),o[e.tipKey]?(_(),w(l,{key:0,class:"wd-drop-item__tip"},{default:x((()=>[T(I(o[e.tipKey]),1)])),_:2},1024)):y("",!0)])),_:2},1032,["class"]),(""!==o[e.valueKey]?o[e.valueKey]:o)===e.modelValue?(_(),w(ae,{key:0,name:e.iconName,"custom-class":`wd-drop-item__icon ${e.customIcon}`},null,8,["name","custom-class"])):y("",!0)])),_:2},1032,["onClick","class"])))),128))])),_:1},8,["style"])):$(e.$slots,"default",{key:1},void 0,!0)])),_:3},8,["modelValue","z-index","duration","position","custom-style","custom-class","root-portal"])])),_:3},8,["class","style"])):y("",!0)}}})),[["__scopeId","data-v-e159c837"]]),be=te(c(i(s({},{name:"wd-drop-menu",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),{props:ve,setup(e){const o=e,l=p(L,null),a=m(`dropMenuId${F()}`),t=m(0),n=m(0),u=f((()=>"down"===o.direction?`top: calc(var(--window-top) + ${t.value}px); bottom: 0;`:`top: 0; bottom: calc(var(--window-bottom) + ${t.value}px)`)),{proxy:s}=v(),{linkChildren:i,children:d}=ie(me),r=f((()=>d.some((e=>e.$.exposed.getShowPop())))),c=m(!1);let h;function k(){}function P(e){const{title:o,modelValue:l,options:a,valueKey:t,labelKey:n}=e;if(o)return o;for(let u=0,s=a.length;u<s;u++)if(l===a[u][t])return a[u][n];console.error("[wot-design] warning(wd-drop-menu-item): no value is matched in the options option.")}function U(e){q(`#${a.value}`,!1,s).then((l=>{if(!l)return;const{top:a,bottom:u}=l;"down"===o.direction?t.value=Number(u):t.value=n.value-Number(a),e.$.exposed.toggle()}))}function H(){o.closeOnClickModal&&d.forEach((e=>{e.$.exposed.close()}))}return g(r,(e=>{h&&clearTimeout(h),e?c.value=!0:h=setTimeout((()=>{c.value=!1,h=null}),16)})),i({props:o,fold:U,offset:t}),g((()=>o.direction),(e=>{["up","down"].includes(e)||console.error("[wot ui] warning(wd-drop-menu): direction must be 'up' or 'down'")}),{deep:!0,immediate:!0}),b((()=>{n.value=N().windowHeight})),(e,o)=>{const t=O,n=B(E("wd-icon"),ae);return _(),w(t,{style:j(e.customStyle),class:S(`wd-drop-menu ${e.customClass}`),onClick:Q(k,["stop","prevent"]),id:a.value},{default:x((()=>[e.modal?(_(),w(D,{key:0,show:c.value,duration:e.duration,"z-index":12,"custom-style":u.value,onClick:H,onTouchmove:k},null,8,["show","duration","custom-style"])):y("",!0),V(t,{class:"wd-drop-menu__list"},{default:x((()=>[(_(!0),C(z,null,K(M(d),((e,o)=>(_(),w(t,{key:o,onClick:o=>function(e){e&&!e.disabled&&(l&&l.closeOther?l.closeOther(e):se(e),U(e))}(e),class:S(`wd-drop-menu__item ${e.disabled?"is-disabled":""} ${e.$.exposed.getShowPop()?"is-active":""}`)},{default:x((()=>[V(t,{class:"wd-drop-menu__item-title"},{default:x((()=>[V(t,{class:"wd-drop-menu__item-title-text"},{default:x((()=>[T(I(P(e)),1)])),_:2},1024),V(n,{name:e.icon,size:e.iconSize,"custom-class":"wd-drop-menu__arrow"},null,8,["name","size"])])),_:2},1024)])),_:2},1032,["onClick","class"])))),128))])),_:1}),$(e.$slots,"default",{},void 0,!0)])),_:3},8,["style","class","id"])}}})),[["__scopeId","data-v-c72dab99"]]),he=te(c({__name:"Index",setup(e){const{t:o}=G(),l=d(),a=m(),t=m(),n=m(30),u=m(1),s=m(0),i=m(0),c=m(0),p=m(0),v=m(0),f=m(0),g=m(0),b=m(0),h=m(0),y=m([{label:o("quan-bu-shang-pin"),value:0},{label:o("xin-kuan-shang-pin"),value:1,tip:o("zhe-shi-bu-chong-xin-xi")},{label:o("zhe-shi-bi-jiao-chang-de-shai-xuan-tiao-jian-zhe-shi-bi-jiao-chang-de-shai-xuan-tiao-jian"),value:2}]),$=m([{label:o("zong-he"),value:0},{label:o("xiao-liang"),value:1},{label:o("shang-jia-shi-jian"),value:2}]);function k(){var e;null==(e=t.value)||e.initSlider()}function j({value:e}){console.log(e)}function C({value:e}){console.log(e)}function z({value:e}){console.log(e)}function K({value:e}){console.log(e)}function S({value:e}){console.log(e)}function P({value:e}){console.log(e)}function U({value:e}){console.log(e)}function H({value:e}){console.log(e)}function F({value:e}){console.log(e)}function N(){a.value.close()}const q=({status:e,resolve:a})=>{l.confirm({title:`${o(e?"yi-bu-da-kai":"yi-bu-guan-bi")}`,msg:`${o(e?"que-ding-yao-da-kai-xia-la-cai-dan-ma":"que-ding-yao-guan-bi-xia-la-cai-dan-ma")}`}).then((()=>{a(!0)})).catch((()=>{a(!1)}))};return(e,o)=>{const l=B(E("wd-message-box"),r),d=O,m=B(E("wd-drop-menu-item"),ge),M=B(E("wd-drop-menu"),be),G=B(E("demo-block"),de),L=B(E("wd-slider"),re),Y=B(E("wd-cell"),J),A=B(E("wd-button"),ce),D=B(E("wd-sort-button"),pe),W=B(E("page-wraper"),X);return _(),w(W,null,{default:x((()=>[V(d,{onClick:o[0]||(o[0]=Q((()=>{}),["stop"]))},{default:x((()=>[V(l)])),_:1}),V(d,{class:"demo-body"},{default:x((()=>[V(G,{title:e.$t("jiBenYongFa"),transparent:""},{default:x((()=>[V(M,null,{default:x((()=>[V(m,{modelValue:u.value,"onUpdate:modelValue":o[1]||(o[1]=e=>u.value=e),options:y.value,onChange:j},null,8,["modelValue","options"]),V(m,{modelValue:s.value,"onUpdate:modelValue":o[2]||(o[2]=e=>s.value=e),options:$.value,onChange:C},null,8,["modelValue","options"])])),_:1})])),_:1},8,["title"]),V(G,{title:e.$t("zi-ding-yi-cai-dan-nei-rong"),transparent:""},{default:x((()=>[V(M,null,{default:x((()=>[V(m,{modelValue:i.value,"onUpdate:modelValue":o[3]||(o[3]=e=>i.value=e),options:y.value,onChange:z},null,8,["modelValue","options"]),V(m,{ref_key:"dropMenu",ref:a,title:e.$t("shai-xuan"),onOpened:k},{default:x((()=>[V(d,null,{default:x((()=>[V(L,{modelValue:n.value,"onUpdate:modelValue":o[4]||(o[4]=e=>n.value=e),ref_key:"slider",ref:t},null,8,["modelValue"]),V(Y,{title:e.$t("biao-ti-wen-zi-10"),value:e.$t("nei-rong")},null,8,["title","value"]),V(Y,{title:e.$t("biao-ti-wen-zi-10"),label:e.$t("miaoShuXinXi-0"),value:e.$t("nei-rong")},null,8,["title","label","value"]),V(d,{style:{padding:"0 10px 20px","box-sizing":"border-box"}},{default:x((()=>[V(A,{block:"",size:"large",onClick:N},{default:x((()=>[T(I(e.$t("zhu-yao-an-niu")),1)])),_:1})])),_:1})])),_:1})])),_:1},8,["title"])])),_:1})])),_:1},8,["title"]),V(G,{title:e.$t("zi-ding-yi-cai-dan-xuan-xiang"),transparent:""},{default:x((()=>[V(d,{class:"custom-menu"},{default:x((()=>[V(M,{"custom-style":"flex: 1; min-width: 0"},{default:x((()=>[V(m,{modelValue:c.value,"onUpdate:modelValue":o[5]||(o[5]=e=>c.value=e),options:y.value,onChange:K},null,8,["modelValue","options"])])),_:1}),V(d,{style:{flex:"1"}},{default:x((()=>[V(D,{modelValue:p.value,"onUpdate:modelValue":o[6]||(o[6]=e=>p.value=e),title:e.$t("shang-jia-shi-jian"),onChange:S},null,8,["modelValue","title"])])),_:1})])),_:1})])),_:1},8,["title"]),V(G,{title:e.$t("zi-ding-yi-cai-dan-tu-biao"),transparent:""},{default:x((()=>[V(M,null,{default:x((()=>[V(m,{title:e.$t("di-tu"),icon:"location","icon-size":"14px"},null,8,["title"])])),_:1})])),_:1},8,["title"]),V(G,{title:e.$t("yi-bu-da-kai-guan-bi"),transparent:""},{default:x((()=>[V(M,null,{default:x((()=>[V(m,{modelValue:h.value,"onUpdate:modelValue":o[7]||(o[7]=e=>h.value=e),options:y.value,onChange:j,"before-toggle":q},null,8,["modelValue","options"])])),_:1})])),_:1},8,["title"]),V(G,{title:e.$t("xiang-shang-dan-chu"),transparent:""},{default:x((()=>[V(M,{direction:"up"},{default:x((()=>[V(m,{modelValue:v.value,"onUpdate:modelValue":o[8]||(o[8]=e=>v.value=e),options:y.value,onChange:P,"custom-title":"custom-title","custom-icon":"custom-icon"},null,8,["modelValue","options"]),V(m,{modelValue:f.value,"onUpdate:modelValue":o[9]||(o[9]=e=>f.value=e),options:$.value,onChange:U},null,8,["modelValue","options"])])),_:1})])),_:1},8,["title"]),V(G,{title:e.$t("jinYong"),transparent:""},{default:x((()=>[V(M,{direction:"up"},{default:x((()=>[V(m,{modelValue:g.value,"onUpdate:modelValue":o[10]||(o[10]=e=>g.value=e),disabled:"",options:y.value,onChange:H},null,8,["modelValue","options"]),V(m,{modelValue:b.value,"onUpdate:modelValue":o[11]||(o[11]=e=>b.value=e),options:$.value,onChange:F},null,8,["modelValue","options"])])),_:1})])),_:1},8,["title"])])),_:1})])),_:1})}}}),[["__scopeId","data-v-c5279a60"]]);export{he as default};
|