instruments-f42bb069.js 15 KB

1
  1. import{aU as w,bh as pe,bi as P,bj as Q,d as E,bk as M,bl as F,bm as U,l as y,bn as Oe,bo as me,bp as ne,bq as He,br as oe,f as c,bs as fe,bt as ie,bu as ve,bv as J,bw as G,bx as ae,by as he,e as p,bz as Pe,w as A,bA as j,bB as ge,bC as we,as as Z,bD as Ee,aX as le,bE as De,bF as Me,c as Ae,bG as re,bH as Le,bI as Ne}from"./index-369af630.js";import{T as Re,c as $e,u as _e}from"./index-619637fd.js";const[Ve,B,se]=w("picker"),be=e=>e.find(n=>!n.disabled)||e[0];function Fe(e,n){const t=e[0];if(t){if(Array.isArray(t))return"multiple";if(n.children in t)return"cascade"}return"default"}function ee(e,n){n=Q(n,0,e.length);for(let t=n;t<e.length;t++)if(!e[t].disabled)return t;for(let t=n-1;t>=0;t--)if(!e[t].disabled)return t;return 0}const ce=(e,n,t)=>n!==void 0&&!!e.find(i=>i[t.value]===n);function te(e,n,t){const i=e.findIndex(m=>m[t.value]===n),a=ee(e,i);return e[a]}function Ie(e,n,t){const i=[];let a={[n.children]:e},m=0;for(;a&&a[n.children];){const u=a[n.children],d=t.value[m];if(a=pe(d)?te(u,d,n):void 0,!a&&u.length){const r=be(u)[n.value];a=te(u,r,n)}m++,i.push(u)}return i}function Ge(e){const{transform:n}=window.getComputedStyle(e),t=n.slice(7,n.length-1).split(", ")[5];return Number(t)}function Ue(e){return P({text:"text",value:"value",children:"children"},e)}const ue=200,de=300,We=15,[Te,z]=w("picker-column"),Ce=Symbol(Te);var Ke=E({name:Te,props:{value:M,fields:F(Object),options:U(),readonly:Boolean,allowHtml:Boolean,optionHeight:F(Number),swipeDuration:F(M),visibleOptionNum:F(M)},emits:["change","clickOption"],setup(e,{emit:n,slots:t}){let i,a,m,u,d;const r=y(),T=y(),g=y(0),b=y(0),x=Oe(),v=()=>e.options.length,k=()=>e.optionHeight*(+e.visibleOptionNum-1)/2,C=s=>{const h=ee(e.options,s),o=-h*e.optionHeight,l=()=>{const f=e.options[h][e.fields.value];f!==e.value&&n("change",f)};i&&o!==g.value?d=l:l(),g.value=o},S=()=>e.readonly||!e.options.length,O=s=>{i||S()||(d=null,b.value=ue,C(s),n("clickOption",e.options[s]))},L=s=>Q(Math.round(-s/e.optionHeight),0,v()-1),N=(s,h)=>{const o=Math.abs(s/h);s=g.value+o/.003*(s<0?-1:1);const l=L(s);b.value=+e.swipeDuration,C(l)},R=()=>{i=!1,b.value=0,d&&(d(),d=null)},K=s=>{if(!S()){if(x.start(s),i){const h=Ge(T.value);g.value=Math.min(0,h-k())}b.value=0,a=g.value,m=Date.now(),u=a,d=null}},Y=s=>{if(S())return;x.move(s),x.isVertical()&&(i=!0,fe(s,!0)),g.value=Q(a+x.deltaY.value,-(v()*e.optionHeight),e.optionHeight);const h=Date.now();h-m>de&&(m=h,u=g.value)},$=()=>{if(S())return;const s=g.value-u,h=Date.now()-m;if(h<de&&Math.abs(s)>We){N(s,h);return}const l=L(g.value);b.value=ue,C(l),setTimeout(()=>{i=!1},0)},_=()=>{const s={height:`${e.optionHeight}px`};return e.options.map((h,o)=>{const l=h[e.fields.text],{disabled:f}=h,V=h[e.fields.value],D={role:"button",style:s,tabindex:f?-1:0,class:[z("item",{disabled:f,selected:V===e.value}),h.className],onClick:()=>O(o)},Be={class:"van-ellipsis",[e.allowHtml?"innerHTML":"textContent"]:l};return c("li",D,[t.option?t.option(h,o):c("div",Be,null)])})};return me(Ce),ne({stopMomentum:R}),He(()=>{const s=e.options.findIndex(l=>l[e.fields.value]===e.value),o=-ee(e.options,s)*e.optionHeight;g.value=o}),oe("touchmove",Y,{target:r}),()=>c("div",{ref:r,class:z(),onTouchstartPassive:K,onTouchend:$,onTouchcancel:$},[c("ul",{ref:T,style:{transform:`translate3d(0, ${g.value+k()}px, 0)`,transitionDuration:`${b.value}ms`,transitionProperty:b.value?"all":"none"},class:z("wrapper"),onTransitionend:R},[_()])])}});const[Ye]=w("picker-toolbar"),W={title:String,cancelButtonText:String,confirmButtonText:String},Se=["cancel","confirm","title","toolbar"],je=Object.keys(W);var xe=E({name:Ye,props:W,emits:["confirm","cancel"],setup(e,{emit:n,slots:t}){const i=()=>{if(t.title)return t.title();if(e.title)return c("div",{class:[B("title"),"van-ellipsis"]},[e.title])},a=()=>n("cancel"),m=()=>n("confirm"),u=()=>{const r=e.cancelButtonText||se("cancel");return c("button",{type:"button",class:[B("cancel"),ie],onClick:a},[t.cancel?t.cancel():r])},d=()=>{const r=e.confirmButtonText||se("confirm");return c("button",{type:"button",class:[B("confirm"),ie],onClick:m},[t.confirm?t.confirm():r])};return()=>c("div",{class:B("toolbar")},[t.toolbar?t.toolbar():[u(),i(),d()]])}});const[ke,X]=w("picker-group"),ye=Symbol(ke),ze=P({tabs:U(),nextStepText:String},W);E({name:ke,props:ze,emits:["confirm","cancel"],setup(e,{emit:n,slots:t}){const i=y(0),{children:a,linkChildren:m}=ve(ye);m();const u=()=>i.value<e.tabs.length-1&&e.nextStepText,d=()=>{u()?i.value++:n("confirm",a.map(T=>T.confirm()))},r=()=>n("cancel");return()=>{var T;const g=(T=t.default)==null?void 0:T.call(t),b=u()?e.nextStepText:e.confirmButtonText;return c("div",{class:X()},[c(xe,{title:e.title,cancelButtonText:e.cancelButtonText,confirmButtonText:b,onConfirm:d,onCancel:r},J(t,Se)),c(Re,{active:i.value,"onUpdate:active":x=>i.value=x,class:X("tabs"),shrink:!0,animated:!0,lazyRender:!1},{default:()=>[e.tabs.map((x,v)=>c($e,{title:x,titleClass:X("tab-title")},{default:()=>[g==null?void 0:g[v]]}))]})])}}});const Xe=P({loading:Boolean,readonly:Boolean,allowHtml:Boolean,optionHeight:G(44),showToolbar:ae,swipeDuration:G(1e3),visibleOptionNum:G(6)},W),qe=P({},Xe,{columns:U(),modelValue:U(),toolbarPosition:he("top"),columnsFieldNames:Object});var Qe=E({name:Ve,props:qe,emits:["confirm","cancel","change","clickOption","update:modelValue"],setup(e,{emit:n,slots:t}){const i=y(),a=y(e.modelValue.slice(0)),{parent:m}=me(ye),{children:u,linkChildren:d}=ve(Ce);d();const r=p(()=>Ue(e.columnsFieldNames)),T=p(()=>Pe(e.optionHeight)),g=p(()=>Fe(e.columns,r.value)),b=p(()=>{const{columns:o}=e;switch(g.value){case"multiple":return o;case"cascade":return Ie(o,r.value,a);default:return[o]}}),x=p(()=>b.value.some(o=>o.length)),v=p(()=>b.value.map((o,l)=>te(o,a.value[l],r.value))),k=p(()=>b.value.map((o,l)=>o.findIndex(f=>f[r.value.value]===a.value[l]))),C=(o,l)=>{if(a.value[o]!==l){const f=a.value.slice(0);f[o]=l,a.value=f}},S=()=>({selectedValues:a.value.slice(0),selectedOptions:v.value,selectedIndexes:k.value}),O=(o,l)=>{C(l,o),g.value==="cascade"&&a.value.forEach((f,V)=>{const D=b.value[V];ce(D,f,r.value)||C(V,D.length?D[0][r.value.value]:void 0)}),Z(()=>{n("change",P({columnIndex:l},S()))})},L=(o,l)=>n("clickOption",P({columnIndex:l,currentOption:o},S())),N=()=>{u.forEach(l=>l.stopMomentum());const o=S();return Z(()=>{n("confirm",o)}),o},R=()=>n("cancel",S()),K=()=>b.value.map((o,l)=>c(Ke,{value:a.value[l],fields:r.value,options:o,readonly:e.readonly,allowHtml:e.allowHtml,optionHeight:T.value,swipeDuration:e.swipeDuration,visibleOptionNum:e.visibleOptionNum,onChange:f=>O(f,l),onClickOption:f=>L(f,l)},{option:t.option})),Y=o=>{if(x.value){const l={height:`${T.value}px`},f={backgroundSize:`100% ${(o-T.value)/2}px`};return[c("div",{class:B("mask"),style:f},null),c("div",{class:[Ee,B("frame")],style:l},null)]}},$=()=>{const o=T.value*+e.visibleOptionNum,l={height:`${o}px`};return c("div",{ref:i,class:B("columns"),style:l},[K(),Y(o)])},_=()=>{if(e.showToolbar&&!m)return c(xe,we(J(e,je),{onConfirm:N,onCancel:R}),J(t,Se))};A(b,o=>{o.forEach((l,f)=>{l.length&&!ce(l,a.value[f],r.value)&&C(f,be(l)[r.value.value])})},{immediate:!0});let s;return A(()=>e.modelValue,o=>{!j(o,a.value)&&!j(o,s)&&(a.value=o.slice(0),s=o.slice(0))},{deep:!0}),A(a,o=>{j(o,e.modelValue)||(s=o.slice(0),n("update:modelValue",s))},{immediate:!0}),oe("touchmove",fe,{target:i}),ne({confirm:N,getSelectedOptions:()=>v.value}),()=>{var o,l;return c("div",{class:B()},[e.toolbarPosition==="top"?_():null,e.loading?c(ge,{class:B("loading")},null):null,(o=t["columns-top"])==null?void 0:o.call(t),$(),(l=t["columns-bottom"])==null?void 0:l.call(t),e.toolbarPosition==="bottom"?_():null])}}});const rt=le(Qe),[Je,H,Ze]=w("list"),et={error:Boolean,offset:G(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:he("down"),loadingText:String,finishedText:String,immediateCheck:ae};var tt=E({name:Je,props:et,emits:["load","update:error","update:loading"],setup(e,{emit:n,slots:t}){const i=y(e.loading),a=y(),m=y(),u=_e(),d=De(a),r=()=>{Z(()=>{if(i.value||e.finished||e.disabled||e.error||(u==null?void 0:u.value)===!1)return;const{direction:v}=e,k=+e.offset,C=re(d);if(!C.height||Le(a))return;let S=!1;const O=re(m);v==="up"?S=C.top-O.top<=k:S=O.bottom-C.bottom<=k,S&&(i.value=!0,n("update:loading",!0),n("load"))})},T=()=>{if(e.finished){const v=t.finished?t.finished():e.finishedText;if(v)return c("div",{class:H("finished-text")},[v])}},g=()=>{n("update:error",!1),r()},b=()=>{if(e.error){const v=t.error?t.error():e.errorText;if(v)return c("div",{role:"button",class:H("error-text"),tabindex:0,onClick:g},[v])}},x=()=>{if(i.value&&!e.finished&&!e.disabled)return c("div",{class:H("loading")},[t.loading?t.loading():c(ge,{class:H("loading-icon")},{default:()=>[e.loadingText||Ze("loading")]})])};return A(()=>[e.loading,e.finished,e.error],r),u&&A(u,v=>{v&&r()}),Me(()=>{i.value=e.loading}),Ae(()=>{e.immediateCheck&&r()}),ne({check:r}),oe("scroll",r,{target:d,passive:!0}),()=>{var v;const k=(v=t.default)==null?void 0:v.call(t),C=c("div",{ref:m,class:H("placeholder")},null);return c("div",{ref:a,role:"feed",class:H(),"aria-busy":i.value},[e.direction==="down"?k:C,x(),T(),b(),e.direction==="up"?k:C])}}});const st=le(tt),[nt,q]=w("progress"),ot={color:String,inactive:Boolean,pivotText:String,textColor:String,showPivot:ae,pivotColor:String,trackColor:String,strokeWidth:M,percentage:{type:M,default:0,validator:e=>+e>=0&&+e<=100}};var at=E({name:nt,props:ot,setup(e){const n=p(()=>e.inactive?void 0:e.color),t=()=>{const{textColor:i,pivotText:a,pivotColor:m,percentage:u}=e,d=a!=null?a:`${u}%`;if(e.showPivot&&d){const r={color:i,left:`${+u}%`,transform:`translate(-${+u}%,-50%)`,background:m||n.value};return c("span",{style:r,class:q("pivot",{inactive:e.inactive})},[d])}};return()=>{const{trackColor:i,percentage:a,strokeWidth:m}=e,u={background:i,height:Ne(m)},d={width:`${a}%`,background:n.value};return c("div",{class:q(),style:u},[c("span",{class:q("portion",{inactive:e.inactive}),style:d},null),t()])}}});const ct=le(at),I={"Acoustic Grand Piano":"大钢琴","Bright Acoustic Piano":"明亮的钢琴","Electric Grand Piano":"电钢琴","Rhodes Piano":"柔和的电钢琴","Chorused Piano":"加合唱效果的电钢琴",Harpsichord:"羽管键琴",Clavichord:"科拉维科特琴",Celesta:"钢片琴",Glockenspiel:"钢片琴","Music box":"八音盒",Vibraphone:"颤音琴",Marimba:"马林巴",Xylophone:"木琴","Tubular Bells":"管钟",Dulcimer:"大扬琴","Hammond Organ":"击杆风琴","Percussive Organ":"打击式风琴","Rock Organ":"摇滚风琴","Church Organ":"教堂风琴","Reed Organ":"簧管风琴",Accordian:"手风琴",Harmonica:"口琴","Tango Accordian":"探戈手风琴","Acoustic Guitar":"钢弦吉他","Electric Guitar":"闷音电吉他","Overdriven Guitar":"加驱动效果的电吉他","Distortion Guitar":"加失真效果的电吉他","Guitar Harmonics":"吉他和音","Acoustic Bass":"大贝司","Electric Bass":"电贝司","Fretless Bass":"无品贝司","Slap Bass":"掌击","Synth Bass":"电子合成",Violin:"小提琴",Viola:"中提琴",Cello:"大提琴",Contrabass:"低音大提琴","Tremolo Strings":"弦乐群颤音音色","Pizzicato Strings":"弦乐群拨弦音色","Orchestral Harp":"竖琴",Timpani:"定音鼓","String Ensemble":"弦乐合奏音色","Synth Strings":"合成弦乐合奏音色","Choir Aahs":"人声合唱","Voice Oohs":"人声","Synth Voice":"合成人声","Orchestra Hit":"管弦乐敲击齐奏",Trumpet:"小号",Trombone:"长号",Tuba:"大号","Muted Trumpet":"加弱音器小号","French Horn":"法国号","Brass Section":"铜管组","Synth Brass":"合成铜管音色","Soprano Sax":"高音萨克斯管","Alto Sax":"中音萨克斯管","Tenor Sax":"次中音萨克斯管","Baritone Sax":"低音萨克斯管",Oboe:"双簧管","English Horn":"英国管",Bassoon:"巴松",Clarinet:"单簧管","Soprano Saxophone":"高音萨克斯管","Alto Saxophone":"中音萨克斯管","Tenor Saxophone":"次中音萨克斯管","Baritone Saxophone":"低音萨克斯管",Piccolo:"短笛",Flute:"长笛",Recorder:"竖笛","Soprano Recorder":"高音竖笛","Pan Flute":"排箫","Bottle Blow":"瓶木管",Whistle:"口哨声",Ocarina:"陶笛",Lead:"合成主音","Lead lead":"合成主音","Pad age":"合成音色",Pad:"合成音色",FX:"合成效果 科幻",Sitar:"西塔尔",Banjo:"班卓琴",Shamisen:"三昧线",Koto:"十三弦筝",Kalimba:"卡林巴",Bagpipe:"风笛",Fiddle:"民族提琴",Shanai:"山奈","Tinkle Bell":"叮当铃",Agogos:"阿戈戈铃","Steel Drums":"钢鼓","Taiko Drum":"太鼓","Melodic Toms":"嗵嗵鼓","Synth Drums":"合成鼓","Reverse Cymbals":"反向镲","Agogo Bells":"阿戈戈铃","Taiko Drums":"太鼓",Bongos:"邦戈鼓","Bongo Bell":"邦戈铃",Congas:"康加鼓",Guiro:"刮壶","Guitar Fret Noise":"吉他换把杂音","Breath Noise":"呼吸声",Seashore:"海浪声","Bird Tweet":"鸟鸣","Telephone Ring":"电话铃",Helicopter:"直升机",Applause:"鼓掌声",Gunshot:"枪声","Acoustic Bass Drum":"大鼓","Bass Drum":"大鼓","Side Drum":"小鼓鼓边","Acoustic Snare":"小鼓","Hand Claps":"拍手","Electric Snare":"小鼓","Low Floor Tom":"低音嗵鼓","Closed Hi-Hat":"闭合踩镲","High Floor Tom":"高音落地嗵鼓","Pedal Hi-Hat":"脚踏踩镲","Low Tom":"低音嗵鼓","Open Hi-Hat":"开音踩镲","Low-Mid Tom":"中低音嗵鼓","Hi Mid Tom":"高音鼓","Crash Cymbals":"对镲","High Tom":"高音嗵鼓","Ride Cymbals":"叮叮镲","Chinese Cymbals":"中国镲","Ride Bell":"圆铃",Tambourine:"铃鼓","Splash Cymbal":"溅音镲",Cowbell:"牛铃","Crash Cymbal":"强音钹","Vibra-Slap":"颤音器","Ride Cymbal":"打点钹","Hi Bongo":"高音邦戈鼓","Low Bongo":"低音邦戈鼓","Mute Hi Conga":"弱音高音康加鼓","Open Hi Conga":"强音高音康加鼓","Low Conga":"低音康加鼓","High Timbale":"高音天巴鼓","Low Timbale":"低音天巴鼓","High Agogo":"高音阿戈戈铃","Low Agogo":"低音阿戈戈铃",Cabasa:"卡巴萨",Maracas:"沙锤","Short Whistle":"短口哨","Long Whistle":"长口哨","Short Guiro":"短刮壶","Long Guiro":"长刮壶",Claves:"响棒","Hi Wood Block":"高音木鱼","Low Wood Block":"低音木鱼","Mute Triangle":"弱音三角铁","Open Triangle":"强音三角铁","Drum Set":"架子鼓","Hulusi flute":"葫芦丝",Melodica:"口风琴","Snare Drum":"小军鼓",Cymbal:"镲",Cymbals:"镲","Horn in F":"圆号",Triangle:"三角铁",Vibrato:"颤音琴","Suspend Cymbals":"吊镲","Suspended Cymbals":"吊镲","Tom-Toms":"嗵嗵鼓",Bell:"铃铛",Bells:"铃铛","Alto Clarinet":"中音单簧管","Bass Clarinet":"低音单簧管",Cornet:"短号",Euphonium:"上低音号","crash cymbals":"对镲",Castanets:"响板",Shaker:"沙锤","Mark tree":"音树",Chimes:"管钟","Mark Tree":"音树","Tom-toms":"嗵嗵鼓","Hi-Hat":"踩镲","Sleigh Bells":"雪橇铃",Flexatone:"弹音器","Brake drum":"闸鼓",Gong:"锣","concert tom":"音乐会嗵嗵鼓","brake drum":"车轮鼓","finger cymbal":"指钹","ride cymbal":"叮叮镲","Concert Toms":"音乐会嗵嗵鼓",Vibraslap:"弹音器","Wood Blocks":"木鱼","Temple Blocks":"木鱼","Wood Block":"木鱼","Field Drum":"军鼓","Quad-Toms":"筒鼓",Quads:"筒鼓","Drums set":"架子鼓","High Bongo":"邦戈",Timbales:"天巴鼓"},ut=(e="")=>{if(e=e.toLocaleLowerCase().replace(/ /g,""),!e)return"";for(let n in I)if(n.toLocaleLowerCase().replace(/ /g,"").includes(e))return I[n];for(let n in I){const t=n.toLocaleLowerCase().replace(/ /g,"");if(e.includes(t))return I[n]}return""};export{st as L,ct as P,rt as a,ut as g};