2 lines
3.0 KiB
JavaScript
2 lines
3.0 KiB
JavaScript
"use strict";var e=Object.defineProperty,a=Object.defineProperties,l=Object.getOwnPropertyDescriptors,t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,o=(a,l,t)=>l in a?e(a,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[l]=t;const n=require("../../../../common/vendor.js");if(!Array){n.resolveComponent("wd-icon")()}Math;const c=n.defineComponent((s=((e,a)=>{for(var l in a||(a={}))r.call(a,l)&&o(e,l,a[l]);if(t)for(var l of t(a))u.call(a,l)&&o(e,l,a[l]);return e})({},{name:"wd-search",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),i={props:n.searchProps,emits:["update:modelValue","change","clear","search","focus","blur","cancel"],setup(e,{emit:a}){const l=e,t=a,{translate:r}=n.useTranslate("search"),u=n.ref(!1),o=n.ref(!1),c=n.ref(""),s=n.ref(!0),i=n.ref(!1);n.watch((()=>l.modelValue),(e=>{c.value=e,e&&(o.value=!0)}),{immediate:!0}),n.watch((()=>l.focus),(e=>{if(e){if(l.disabled)return;f()}})),n.onMounted((()=>{l.focus&&f()}));const v=n.computed((()=>`wd-search ${l.light?"is-light":""} ${l.hideCancel?"is-without-cancel":""} ${l.customClass}`)),d=n.computed((()=>{const e={display:""===c.value&&s.value?"flex":"none"};return n.objToStyle(e)}));function h(e){o.value=e,n.requestAnimationFrame((()=>{u.value=e}))}function f(){l.disabled||n.requestAnimationFrame().then((()=>n.requestAnimationFrame())).then((()=>n.requestAnimationFrame())).then((()=>{s.value=!1,h(!0)}))}function m(e){c.value=e.detail.value,t("update:modelValue",e.detail.value),t("change",{value:e.detail.value})}function p(){c.value="",i.value=!0,l.focusWhenClear&&(u.value=!1),n.requestAnimationFrame().then((()=>n.requestAnimationFrame())).then((()=>n.requestAnimationFrame())).then((()=>{l.focusWhenClear?(s.value=!1,h(!0)):(s.value=!0,h(!1)),t("change",{value:""}),t("update:modelValue",""),t("clear")}))}function b({detail:{value:e}}){t("search",{value:e})}function w(){i.value?i.value=!1:(s.value=!1,t("focus",{value:c.value}))}function y(){i.value||(s.value=!c.value,o.value=!s.value,u.value=!1,t("blur",{value:c.value}))}function _(){t("cancel",{value:c.value})}return(e,a)=>n.e({a:!e.placeholderLeft},e.placeholderLeft?{}:{b:n.p({name:"search",size:"18px","custom-class":"wd-search__search-icon"}),c:n.t(e.placeholder||n.unref(r)("search")),d:n.s(d.value),e:n.o(f)},{f:o.value||c.value||e.placeholderLeft},o.value||c.value||e.placeholderLeft?{g:n.p({name:"search",size:"18px","custom-class":"wd-search__search-left-icon"})}:{},{h:o.value||c.value||e.placeholderLeft},o.value||c.value||e.placeholderLeft?{i:e.placeholder||n.unref(r)("search"),j:n.o(w),k:n.o([e=>c.value=e.detail.value,m]),l:n.o(y),m:n.o(b),n:e.disabled,o:e.maxlength,p:u.value,q:c.value}:{},{r:c.value},c.value?{s:n.o(p),t:n.p({"custom-class":"wd-search__clear wd-search__clear-icon",name:"error-fill",size:"16px"})}:{},{v:!e.hideCancel},e.hideCancel?{}:{w:n.t(e.cancelTxt||n.unref(r)("cancel")),x:n.o(_)},{y:n.n(v.value),z:n.s(e.customStyle)})}},a(s,l(i))));var s,i;const v=n._export_sfc(c,[["__scopeId","data-v-901c5d7b"]]);wx.createComponent(v);
|