@scvzerng/element-plus-search-vue2 0.0.17 → 0.1.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/dist/ElementPlusSearch.es.js +515 -309
- package/dist/ElementPlusSearch.umd.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/shared/src/SearchBarState.d.ts +38 -0
- package/dist/types/shared/src/SearchBarState.d.ts.map +1 -0
- package/dist/types/shared/src/Searches.d.ts +15 -0
- package/dist/types/shared/src/Searches.d.ts.map +1 -0
- package/dist/types/shared/src/core/SearchBarCore.d.ts +25 -0
- package/dist/types/shared/src/core/SearchBarCore.d.ts.map +1 -0
- package/dist/types/shared/src/core/index.d.ts +2 -0
- package/dist/types/shared/src/core/index.d.ts.map +1 -0
- package/dist/types/shared/src/index.d.ts +8 -0
- package/dist/types/shared/src/index.d.ts.map +1 -0
- package/dist/types/{model → shared/src/model}/SearchConfig.d.ts +10 -17
- package/dist/types/shared/src/model/SearchConfig.d.ts.map +1 -0
- package/dist/types/shared/src/model/SearchItem.d.ts +28 -0
- package/dist/types/shared/src/model/SearchItem.d.ts.map +1 -0
- package/dist/types/{model → shared/src/model}/SearchTag.d.ts +6 -6
- package/dist/types/shared/src/model/SearchTag.d.ts.map +1 -0
- package/dist/types/shared/src/model/index.d.ts +4 -0
- package/dist/types/shared/src/model/index.d.ts.map +1 -0
- package/dist/types/shared/src/setting/use-setting.d.ts +43 -0
- package/dist/types/shared/src/setting/use-setting.d.ts.map +1 -0
- package/dist/types/shared/src/storage/ConfigStorage.d.ts +22 -0
- package/dist/types/shared/src/storage/ConfigStorage.d.ts.map +1 -0
- package/dist/types/shared/src/storage/index.d.ts +2 -0
- package/dist/types/shared/src/storage/index.d.ts.map +1 -0
- package/dist/types/shared/src/types/SearchBarState.d.ts +17 -0
- package/dist/types/shared/src/types/SearchBarState.d.ts.map +1 -0
- package/dist/types/shared/src/types/SearchValueLike.d.ts +6 -0
- package/dist/types/shared/src/types/SearchValueLike.d.ts.map +1 -0
- package/dist/types/shared/src/types/Searchable.d.ts +20 -0
- package/dist/types/shared/src/types/Searchable.d.ts.map +1 -0
- package/dist/types/shared/src/types/index.d.ts +52 -0
- package/dist/types/shared/src/types/index.d.ts.map +1 -0
- package/dist/types/{SearchBar.vue.d.ts → vue2/src/SearchBar.vue.d.ts} +9 -9
- package/dist/types/vue2/src/SearchBar.vue.d.ts.map +1 -0
- package/dist/types/{SearchBarItem.vue.d.ts → vue2/src/SearchBarItem.vue.d.ts} +2 -1
- package/dist/types/vue2/src/SearchBarItem.vue.d.ts.map +1 -0
- package/dist/types/vue2/src/SearchBarState.d.ts +7 -0
- package/dist/types/vue2/src/SearchBarState.d.ts.map +1 -0
- package/dist/types/{SearchItemRender.d.ts → vue2/src/SearchItemRender.d.ts} +4 -3
- package/dist/types/vue2/src/SearchItemRender.d.ts.map +1 -0
- package/dist/types/{SearchTagsRender.vue.d.ts → vue2/src/SearchTagsRender.vue.d.ts} +1 -0
- package/dist/types/vue2/src/SearchTagsRender.vue.d.ts.map +1 -0
- package/dist/types/vue2/src/asserts/PinIcon.vue.d.ts +15 -0
- package/dist/types/vue2/src/asserts/PinIcon.vue.d.ts.map +1 -0
- package/dist/types/vue2/src/componentTextGetters.d.ts +3 -0
- package/dist/types/vue2/src/componentTextGetters.d.ts.map +1 -0
- package/dist/types/{helper → vue2/src/helper}/vModel.d.ts +2 -1
- package/dist/types/vue2/src/helper/vModel.d.ts.map +1 -0
- package/dist/types/vue2/src/index.d.ts +19 -0
- package/dist/types/vue2/src/index.d.ts.map +1 -0
- package/dist/types/{setting → vue2/src/setting}/SearchSettingsDrawer.vue.d.ts +2 -1
- package/dist/types/vue2/src/setting/SearchSettingsDrawer.vue.d.ts.map +1 -0
- package/dist/types/{setting → vue2/src/setting}/SettingButton.vue.d.ts +1 -0
- package/dist/types/vue2/src/setting/SettingButton.vue.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/favicon.ico +0 -0
- package/dist/types/SearchBarState.d.ts +0 -22
- package/dist/types/index.d.ts +0 -44
- package/dist/types/model/SearchItem.d.ts +0 -28
- package/dist/types/setting/use-setting.d.ts +0 -22
- package/dist/types/types/SearchValueLike.d.ts +0 -5
- package/dist/types/types/Searchable.d.ts +0 -44
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("lodash-unified"),require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","lodash-unified","vue","@vueuse/core"],h):(d=typeof globalThis<"u"?globalThis:d||self,h(d.ElementPlusSearch={},d.lodashUnified,d.vue,d.core))})(this,function(d,h,l,P){"use strict";const R=i=>({model:{value:h.get(i,"value"),callback:e=>{h.set(i,"value",e)}}}),j=l.defineComponent({name:"SearchTags"}),$=l.defineComponent({...j,props:{tags:null},setup(i){const e=i,t=l.ref(),s=()=>{t.value.scrollBy({left:-200,behavior:"smooth"})},r=()=>{t.value.scrollBy({left:200,behavior:"smooth"})},n=l.ref(!1),o=()=>{const u=Array.from(t.value.children);return h.sum(u.map(m=>m.getBoundingClientRect().width))},f=()=>t.value.getBoundingClientRect().width;return P.useMutationObserver(t,()=>{n.value=o()>f()},{subtree:!0,childList:!0,attributes:!0}),{__sfc:!0,props:e,scrollContainer:t,scrollLeft:s,scrollRight:r,showScrollBar:n,getTagsWidth:o,getContainerWidth:f}}});function y(i,e,t,s,r,n,o,f){var u=typeof i=="function"?i.options:i;return e&&(u.render=e,u.staticRenderFns=t,u._compiled=!0),n&&(u._scopeId="data-v-"+n),{exports:i,options:u}}var N=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"tags-scroll-container"},[t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-left-bar",attrs:{"disable-transitions":"",size:"medium",type:"info"},on:{click:s.scrollLeft}},[t("i",{staticClass:"el-icon-arrow-left"})]),t("div",{ref:"scrollContainer",staticClass:"search-tags"},e._l(e.tags,function(r){return t("el-tag",{key:r.field,staticClass:"search-tag",attrs:{"disable-transitions":"",closable:!r.required,type:r.required?"primary":"info"},on:{close:()=>r.clean()}},[t("span",[e._v(" "+e._s(r.label)+" ")]),e._v(": "),t("span",{domProps:{innerHTML:e._s(r.valueText)}})])}),1),t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-right-bar",attrs:{"disable-transitions":"",size:"medium",type:"info"},on:{click:s.scrollRight}},[t("i",{staticClass:"el-icon-arrow-right"})])],1)},I=[],k=y($,N,I,!1,null,null);const V=k.exports;var Y=Object.defineProperty,q=(i,e,t)=>e in i?Y(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,p=(i,e,t)=>q(i,typeof e!="symbol"?e+"":e,t);const D=6;class M{constructor(e,t){p(this,"field"),p(this,"label"),p(this,"value"),p(this,"required"),p(this,"index"),p(this,"visible"),p(this,"disabled"),p(this,"span"),p(this,"initValue"),p(this,"enable"),p(this,"pinned"),p(this,"tagFilter"),p(this,"render"),p(this,"transform"),p(this,"onChange");var s,r,n,o,f;this.field=e.field,this.label=e.label,this.value=e.initValue,this.required=e.required,this.initValue=e.initValue,this.index=t,this.visible=(s=e.visible)!=null?s:!0,this.span=(r=e.span)!=null?r:D,this.render=e.render,this.tagFilter=e.tagFilter,this.transform=e.transform,this.enable=(n=e.enable)!=null?n:!0,this.disabled=(o=e.disabled)!=null?o:!1,this.pinned=(f=e.pinned)!=null?f:!1,e.onChange&&(this.onChange=P.useDebounceFn((u,m)=>e.onChange(u,m),50))}clean(){Array.isArray(this.value)?this.value=[]:this.value=void 0}reset(){this.value=this.initValue}isEnable(e){return h.isFunction(this.enable)?this.enable(e.getSearchObject()):this.enable}isDisabled(e){return h.isFunction(this.disabled)?this.disabled(e.getSearchObject()):this.disabled}}var Q=Object.defineProperty,H=(i,e,t)=>e in i?Q(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,v=(i,e,t)=>H(i,typeof e!="symbol"?e+"":e,t);class b{constructor(e,t,s,r,n){v(this,"field"),v(this,"span"),v(this,"index"),v(this,"visible"),v(this,"pinned"),this.field=e,this.span=t,this.index=s,this.visible=r,this.pinned=n}static fromSearchItem(e,t){return new b(e.field,e.span,t??e.index,e.visible,e.pinned)}static formSearchConfig(e,t){var s,r,n;return new b(e.field,(s=e.span)!=null?s:D,t??e,(r=e.visible)!=null?r:!0,(n=e.pinned)!=null?n:!1)}static fromString(e){const[t,s,r,n,o]=e.split("_");return new b(s,Number(r),Number(t),n==="true",o==="true")}toString(){return`${this.index}_${this.field}_${this.span}_${this.visible}_${this.pinned}`}merge(e){this.span=e.span,this.index=e.index,this.visible=e.visible,this.pinned=e.pinned}}const F=i=>`searches_layouts_${i}`;class X{constructor(e,t){v(this,"id"),v(this,"state"),v(this,"itemLayouts"),v(this,"initialLayouts"),this.id=e.id,this.initialLayouts=t,this.state=e,this.itemLayouts=h.keyBy(e.items.map(b.fromSearchItem),s=>s.field),this.restoreCachedLayouts()}restoreCachedLayouts(){const e=localStorage.getItem(F(this.id));e&&e.split(",").forEach(t=>{const s=b.fromString(t),r=this.itemLayouts[s.field];r&&r.merge(s)})}sync(e,t,s){if(e.length!==Object.keys(this.itemLayouts).length)throw new Error("同步布局字段数量不一致");e.forEach((r,n)=>{const o=this.itemLayouts[r];o.index=n,o.visible=t.has(r),o.pinned=s.has(r)})}persistent(){localStorage.setItem(F(this.id),Object.values(this.itemLayouts).map(e=>e.toString()).join(",")),this.state.updateTags()}reset(){this.initialLayouts.forEach(e=>{const t=this.itemLayouts[e.field];t&&t.merge(e)})}}var W=Object.defineProperty,K=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_=(i,e,t)=>K(i,typeof e!="symbol"?e+"":e,t);const U=[{isApply(i){return i.contains("el-radio-group")},getText(i){var e,t;return(t=(e=i.querySelector(".is-active"))==null?void 0:e.querySelector("input"))==null?void 0:t.value}},{isApply(i){return i.contains("el-checkbox-group")},getText(i){var e;const t=Array.from((e=i.querySelectorAll(".el-checkbox__input.is-checked"))!=null?e:[]).map(s=>{var r;return(r=s.querySelector("input"))==null?void 0:r.value}).filter(s=>s);return t.length===1?t[0]:`${t[0]} 等${t.length}条`}},{isApply(i){return i.contains("el-input")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-input-number")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-select")},getText(i,e){var t;const s=i.querySelectorAll(".el-select__tags-text");return s.length>0?e.value.length>1?`${s[0].textContent} 等${e.value.length}条`:s[0].textContent:(t=i.querySelector("input"))==null?void 0:t.value}},{isApply(i){return i.contains("el-cascader")},getText(i){var e;return(e=i.querySelector("input"))==null?void 0:e.value}},{isApply(i){return i.contains("el-switch")},getText(i){return i.querySelector(".is-active").innerHTML}},{isApply(i){return i.contains("el-slider")},getText(i,e){return e.value}},{isApply(i){return i.contains("el-date-editor")},getText(i,e){return e.value?e.value.join(" ~ "):e.value}}];class B{constructor(e,t){_(this,"id"),_(this,"field"),_(this,"value"),_(this,"label"),_(this,"valueText"),_(this,"required"),_(this,"item"),_(this,"state");var s;this.id=`#${e.id}-${t.field}`,this.state=e,this.field=t.field,this.value=t.value,this.label=t.label,this.item=t,this.required=(s=t.required)!=null?s:!1,this.updateValueText()}static hasValue(e){return h.isNumber(e.value)||h.isBoolean(e.value)?!0:!h.isEmpty(e.value)}updateValueText(){const e=document.querySelector(this.id);if(!e)return;if(e.children.length!==1)throw new Error("holder children length is not 1");const t=e.children[0],s=U.find(r=>r.isApply(t.classList));s&&(this.valueText=s.getText(t,this))}async clean(){this.item.clean(),await this.state.doSearch()}}var z=Object.defineProperty,G=(i,e,t)=>e in i?z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,S=(i,e,t)=>G(i,typeof e!="symbol"?e+"":e,t);class J{constructor(e,t,s){this.id=e,S(this,"items"),S(this,"config"),S(this,"searching"),S(this,"tags"),S(this,"searchCallback"),S(this,"sourceSearchable"),S(this,"_lastSearchObject",{time:0,data:null}),this.id=e,this.items=t.map((r,n)=>new M(r,n)),this.config=new X(this,t.map((r,n)=>b.formSearchConfig(r,n))),this.sourceSearchable=t,this.searching=!1,this.searchCallback=s,this.tags=[]}updateSearchTag(e){var t;(t=this.tags.find(s=>s.field===e))==null||t.updateValueText()}updateTags(){this.tags=this.items.filter(e=>e.tagFilter?e.tagFilter(e.value):B.hasValue(e)).map(e=>new B(this,e)).sort((e,t)=>this.config.itemLayouts[e.field].index-this.config.itemLayouts[t.field].index)}getSearchObject(e){const t=Date.now();return this._lastSearchObject.data&&t-this._lastSearchObject.time<50?this._lastSearchObject.data:(this._lastSearchObject={time:t,data:T.from(this.items).toCondition(e)},this._lastSearchObject.data)}async doSearch(){if(!this.searching)try{this.searching=!0,await this.searchCallback(this.getSearchObject()),this.updateTags()}finally{this.searching=!1}}async reset(e){this.items.forEach(t=>t.reset()),e&&await this.doSearch()}setSearchValue(e,t,s=r=>!0){const r=this.items.find(n=>n.field===e);r&&s&&s(r.value)&&(r.value=t)}}const Z=()=>{const i=l.shallowRef(),e=l.ref(),t=l.ref([]),s=l.ref(!1),r=l.ref(),n=l.ref([]),o=l.ref(300),f=a=>{i.value=a,t.value=[{label:"全部",id:"all",children:i.value.items.sort((c,g)=>a.config.itemLayouts[c.field].index-a.config.itemLayouts[g.field].index).map(c=>({label:c.label,id:c.field,disabled:!c.isEnable(a),pinned:a.config.itemLayouts[c.field].pinned}))}],r.value=Object.keys(a.config.itemLayouts).filter(c=>{var g;return(g=a.config.itemLayouts[c])==null?void 0:g.visible})};return{treeRef:e,visible:s,snapshot:t,defaultCheckedKeys:r,drawerWidth:o,updateSnapshot:f,show:a=>{f(a),s.value=!0},save:()=>{i.value.config.sync(t.value[0].children.map(a=>a.id),new Set(e.value.getCheckedKeys()),new Set(t.value[0].children.filter(a=>a.pinned).map(a=>a.id))),i.value.config.persistent(),s.value=!1},reset:()=>{i.value.config.reset(),f(i.value)},keepSelection:()=>{n.value=e.value.getCheckedKeys()},restoreSelection:()=>{e.value.setCheckedKeys(n.value),n.value=[]},allowDrop:(a,c,g)=>g==="inner"?!1:!((Oe,De)=>{let E=Oe.parent;for(;E;){if(E===De)return!0;E=E.parent}return!1})(a,c),allowDrag:a=>!a.disabled,onPinnedChange:a=>{a.data.pinned=!a.data.pinned}}},ee="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAdlJREFUWEftlT9rFEEYxp/nJCii2NhYWNiLnV9CSGFtYGdGd4IkRUQMXhA9RSX+AYXTFLPH7mwO0ohW/vkAfgALsbSxuM7CRtDovrIQNcTkdmc9CchuuzPP83t/O8sQu/xwl/vRArQG/h8Dyti7KOSj98mdkD9rYgYiHT8jeRqFXA6BmByAOXeW6Aw2pu/61C3XMTEJACpjbwJY2lwoIpfyLLlfBfFXANba/V/X5QnIU9sV1YFoDKC1Plpw6iWB4+OmrIIIAShVd0XkEDqdFxB5SuDwtpMD31hwGhQlxOs8dY93ggwCiEw8JHim6ruikDnvk5XKdUDwZUSl4wFIs2O4YM1nrhpyIyDEwK9OZewDAAt/QAjeHjyw92S/3/9SZ/pyTSOASMfXSV7dUvLp+zpODIfuQ93yRgCRjrskbwNyUQTHSM6XQYXI9GqWPA8pDwZQxpbaS/0XfOoelgHKxA5gDGDRp+7ePwOItD1PYkVEruVZcmNTEZWJcxR4F3IH/Nxf6wz8Li9u5dngytYpe71eZzQa7XPOfZ64gUjPalJSAMs+dd3Qgqr1Yw3MzNgje6bwnsQjn7rFqrAm78cCKGOXCsib1TR51SS8zp5aZ6BOUNM1LUBroDXwAyP2oSHYDQ3tAAAAAElFTkSuQmCC",te="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAc1JREFUWEftlT1oFUEUhb+zKEgQbGxSWNiLTUip82ohhbWFvl1EgiFExJAn4h8q8QdioYFIdoIEbEJSqWl3EUuxCJY29haCCBLx6kteBKPv7c7mSUB225l7znfPzN0Ru/xpl/2pAeoE/p8EXGr3FPExa+puyGT1LQHnbUVwEjEVAtE3gEZqCWJ+o3ujlSWaLpPEzgHM5Dy3JC5vM7yUxXpQBLEjgKE5G9i/lyXBiS5GhRCVAY57OxQZLxFHCrrsCVEeYDPqFuKAfedFJJYRB/9qbnwjYgTjDMarLNHjbpBBAA3PIuJU0bmaOJ83NVu0r71eHmDjdpvcAvOCuJu4wbM8ViHkVn0YQKeqkdoMYmI7hMHawGeGV8f1tUz34Ql0VJ23G4Krv5kYn9b3cPT1aX0oa14JwHlrCe6YcVHiMDDWMRzJYj0PMQ8GaKQ28XMKZjAuZIketgVcak8kzpoxmSe6/88AnLdRwazBtTzWzV9Gm+P5VBHvQt6AoEu4ZQ7czmJd+aPL6xYNDbLvzTl96XsCzltT4DGms0StUIOi/T3H8NiiDUbrvMd4lCeaLBKrst4TwKXWfuHe5olWq4iXqan0IyojXHZPDVAnUCfwAyFMiSGfgbcLAAAAAElFTkSuQmCC",se=l.defineComponent({__name:"SearchSettingsDrawer",setup(i,{expose:e}){const{treeRef:t,visible:s,snapshot:r,drawerWidth:n,defaultCheckedKeys:o,show:f,allowDrop:u,allowDrag:m,keepSelection:w,restoreSelection:A,save:C,reset:x,onPinnedChange:L}=Z();return e({show:f}),{__sfc:!0,treeRef:t,visible:s,snapshot:r,drawerWidth:n,defaultCheckedKeys:o,show:f,allowDrop:u,allowDrag:m,keepSelection:w,restoreSelection:A,save:C,reset:x,onPinnedChange:L,pin:ee,activePin:te}}});var re=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("el-drawer",{attrs:{size:s.drawerWidth,title:"搜索项配置",visible:s.visible,"modal-append-to-body":!0,"append-to-body":!0},on:{"update:visible":function(r){s.visible=r}}},[t("div",{staticClass:"setting-container"},[t("el-tree",{ref:"treeRef",staticClass:"tree",attrs:{"default-expand-all":"","default-checked-keys":s.defaultCheckedKeys,"node-key":"id",draggable:"","show-checkbox":"",data:s.snapshot,"allow-drop":s.allowDrop,"allow-drag":s.allowDrag,"expand-on-click-node":!1},on:{"node-drag-start":s.keepSelection,"node-drag-end":s.restoreSelection},scopedSlots:e._u([{key:"default",fn:function({node:r}){return[t("span",{staticClass:"custom-tree-node"},[t("span",[e._v(e._s(r.label))]),r.data.id!=="all"?t("span",{on:{click:function(n){return s.onPinnedChange(r)}}},[t("img",{attrs:{src:r.data.pinned?s.activePin:s.pin,alt:"固定"}})]):e._e()])]}}])}),t("div",{staticClass:"footer"},[t("el-button",{on:{click:s.reset}},[e._v("重置")]),t("el-button",{attrs:{type:"primary"},on:{click:s.save}},[e._v("保存")])],1)],1)])},ie=[],ne=y(se,re,ie,!1,null,null);const ae=ne.exports,le=l.defineComponent({__name:"SettingButton",props:{state:null},setup(i){const e=i,t=l.ref();return{__sfc:!0,props:e,searchSettingDialogRef:t,showSearchLayoutDialog:()=>{t.value.show(e.state)},SearchSettingsDrawer:ae}}});var oe=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticStyle:{"margin-right":"10px"}},[t("el-tooltip",{attrs:{content:"搜索项设置"}},[t("el-button",{staticClass:"icon-button",staticStyle:{height:"100%"},on:{click:s.showSearchLayoutDialog}},[t("i",{staticClass:"el-icon-s-tools"})])],1),t(s.SearchSettingsDrawer,{ref:"searchSettingDialogRef"})],1)},ce=[],ue=y(le,oe,ce,!1,null,"b401b1ee");const de=ue.exports,he={functional:!0,props:{search:{type:Object,required:!0},api:{type:Object}},render(i,e){var t;const{props:s}=e,r=s.search.render(s.search);if(r.componentOptions.propsData||(r.componentOptions.propsData={}),r.componentOptions.listeners||(r.componentOptions.listeners={}),r.componentOptions.listeners||(r.componentOptions.listeners={}),(t=r.data)!=null&&t.attrs||(r.data.attrs={}),r.data.attrs.labelChange=()=>{s.api.updateSearchTag(s.search.field)},r.componentOptions.listeners.input){const n=r.componentOptions.listeners.input;r.componentOptions.listeners.input=o=>{s.search.onChange&&s.search.onChange(o,s.api),n(o)}}return r.componentOptions.propsData.disabled=s.search.isDisabled(s.api),r}},pe=l.defineComponent({__name:"SearchBarItem",props:{item:null},setup(i){const e=i,t=l.inject("search-bar-state"),s=l.inject("search-bar-id");return{__sfc:!0,props:e,state:t,id:s,SearchItemRender:he}}});var fe=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-item"},[t("div",{staticClass:"search-item-title"},[e._v(e._s(e.item.label))]),t("div",{staticClass:"search-item-content",attrs:{id:`${s.id}-${e.item.field}`}},[t(s.SearchItemRender,{attrs:{search:e.item,api:s.state}})],1)])},ve=[],_e=y(pe,fe,ve,!1,null,"9e3df4b4");const me=_e.exports,ge=l.defineComponent({__name:"SearchBar",props:{searches:null,id:null,onSearch:{type:Function},defaultSpan:{default:6},maxRows:{default:2},itemHeight:{default:67},resetAutoSearch:{type:Boolean,default:!0}},emits:["change"],setup(i,{expose:e,emit:t}){const s=i,r=l.reactive(new J(s.id,s.searches,s.onSearch)),n=l.ref(!1),o=l.ref();P.useMutationObserver(o,()=>{r.updateTags()},{childList:!0});const f=l.computed(()=>w.value.filter(a=>A(a).visible).length>0),u=l.ref([]),m=l.computed(()=>u.value.filter(a=>A(a).pinned)),w=l.computed(()=>u.value.filter(a=>!A(a).pinned));P.watchDebounced(()=>[r.items,r.config.itemLayouts],()=>{const a=[...r.items.filter(c=>c.pinned),...r.items.filter(c=>!c.pinned)];u.value=a.sort((c,g)=>r.config.itemLayouts[c.field].index-r.config.itemLayouts[g.field].index).filter(c=>c.isEnable(r)),t("change",r.getSearchObject(),r)},{debounce:100,immediate:!0,deep:!0});const A=a=>r.config.itemLayouts[a.field],C=()=>r.items,x=()=>r.getSearchObject(),L=a=>{r.searching=a},O=()=>r.updateTags();return l.provide("search-bar-state",r),l.provide("search-bar-id",s.id),e({getSearchItems:C,getSearchObject:x,updateSearching:L,updateTags:O}),{__sfc:!0,props:s,state:r,expanded:n,itemContainerRef:o,isShowSpanIcon:f,sortedItems:u,sortedPinnedItems:m,sortedNormalItems:w,emits:t,getLayout:A,getSearchItems:C,getSearchObject:x,updateSearching:L,updateTags:O,SearchTagsRender:V,SettingButton:de,SearchBarItem:me}}});var be=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-bar-container"},[t("el-row",{ref:"itemContainerRef",class:"search",staticStyle:{"flex-wrap":"wrap"},attrs:{type:"flex",gutter:16}},[e._l(s.sortedPinnedItems,function(r){return t("el-col",{directives:[{name:"show",rawName:"v-show",value:s.getLayout(r).visible,expression:"getLayout(item).visible"}],key:r.field,attrs:{span:s.getLayout(r).span}},[t(s.SearchBarItem,{attrs:{item:r}})],1)}),t("el-collapse-transition",[t("div",{directives:[{name:"show",rawName:"v-show",value:s.expanded,expression:"expanded"}],staticStyle:{width:"100%"}},e._l(s.sortedNormalItems,function(r){return t("el-col",{directives:[{name:"show",rawName:"v-show",value:s.getLayout(r).visible,expression:"getLayout(item).visible"}],key:r.field,attrs:{span:s.getLayout(r).span}},[t(s.SearchBarItem,{attrs:{item:r}})],1)}),1)])],2),t("div",{staticClass:"search-bottom"},[s.state.tags.length>0?t(s.SearchTagsRender,{attrs:{tags:s.state.tags}}):e._e(),t("div",{staticClass:"actions"},[t("el-tooltip",{attrs:{content:s.expanded?"收起":"更多搜索条件"}},[t("el-button",{directives:[{name:"show",rawName:"v-show",value:s.isShowSpanIcon,expression:"isShowSpanIcon"}],staticClass:"icon-button",staticStyle:{"margin-right":"10px"},on:{click:function(r){s.expanded=!s.expanded}}},[t("i",{class:[s.expanded?"el-icon-arrow-up":"el-icon-arrow-down"]})])],1),t(s.SettingButton,{attrs:{state:s.state}}),t("el-button",{attrs:{type:"primary",loading:s.state.searching,disabled:s.state.searching},on:{click:()=>s.state.doSearch()}},[e._v("查 询 ")]),t("el-button",{on:{click:()=>s.state.reset(e.resetAutoSearch)}},[e._v("重 置")])],1)],1)],1)},Se=[],Ae=y(ge,be,Se,!1,null,null);const ye=Ae.exports;var we=Object.defineProperty,Ce=(i,e,t)=>e in i?we(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,xe=(i,e,t)=>Ce(i,e+"",t);const Le=i=>h.isEmpty(i),Pe=()=>!0,Te=(i,e)=>{const t=i.getSearchObject();let s=!0;for(const[r,n]of Object.entries(e)){const o=t[r];s=n(o),s||(s=!1)}return()=>s},Ee=(i,e,t)=>({refreshCallback:async s=>{const r=e.value.getSearchObject();try{return e.value.updateSearching(!0),await i(r,s)}finally{e.value.updateSearching(!1),e.value.updateTags()}},searchCallback:async()=>{var s;for(const r of t)await((s=r.value)==null?void 0:s.refresh())}});class T{constructor(e){xe(this,"record"),this.record=e}static from(e){const t=e.filter(s=>s.value===void 0?!1:Array.isArray(s.value)?s.value.length>0:!0).reduce((s,r)=>{const n=r.transform?r.transform(r.value):r.value;return{...s,...h.isPlainObject(n)?n:{[r.field]:n}}},{});return new T(t)}transform(e,t){const s=this.record[e],r=t(s);return delete this.record[e],this.record={...this.record,...r},this}toCondition(e){return{...this.record,...e}}}d.APPLY_ALWAYS=Pe,d.APPLY_WHEN_NOT_VALUE=Le,d.APPLY_WITH_MULTIPLE_VALUE=Te,d.SearchBar=ye,d.Searches=T,d.useSearchProxy=Ee,d.vModel=R,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("lodash-unified"),require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","lodash-unified","vue","@vueuse/core"],f):(c=typeof globalThis<"u"?globalThis:c||self,f(c.ElementPlusSearch={},c.lodashUnified,c.vue,c.core))})(this,function(c,f,l,P){"use strict";const I=r=>({model:{value:f.get(r,"value"),callback:e=>{f.set(r,"value",e)}}}),k=l.defineComponent({name:"SearchTags"}),M=l.defineComponent({...k,props:{tags:null},setup(r){const e=r,t=l.ref(),s=()=>{t.value.scrollBy({left:-200,behavior:"smooth"})},i=()=>{t.value.scrollBy({left:200,behavior:"smooth"})},a=l.ref(!1),o=()=>{const g=Array.from(t.value.children);return f.sum(g.map(y=>y.getBoundingClientRect().width))},n=()=>t.value.getBoundingClientRect().width,h=()=>{t.value&&(a.value=o()>n())};return l.watch(()=>e.tags,()=>{l.nextTick(()=>{h()})},{immediate:!0,deep:!0}),{__sfc:!0,props:e,scrollContainer:t,scrollLeft:s,scrollRight:i,showScrollBar:a,getTagsWidth:o,getContainerWidth:n,checkScrollBar:h}}});function C(r,e,t,s,i,a,o,n){var h=typeof r=="function"?r.options:r;return e&&(h.render=e,h.staticRenderFns=t,h._compiled=!0),a&&(h._scopeId="data-v-"+a),{exports:r,options:h}}var H=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"tags-scroll-container"},[t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-left-bar",attrs:{"disable-transitions":"",size:"medium",type:"info"},on:{click:s.scrollLeft}},[t("i",{staticClass:"el-icon-arrow-left"})]),t("div",{ref:"scrollContainer",staticClass:"search-tags"},e._l(e.tags,function(i){return t("el-tag",{key:i.field,staticClass:"search-tag",attrs:{"disable-transitions":"",closable:!i.required,type:i.required?"primary":"info"},on:{close:()=>i.clean()}},[t("span",[e._v(" "+e._s(i.label)+" ")]),e._v(": "),t("span",{domProps:{innerHTML:e._s(i.valueText)}})])}),1),t("el-tag",{directives:[{name:"show",rawName:"v-show",value:s.showScrollBar,expression:"showScrollBar"}],staticClass:"scroll-right-bar",attrs:{"disable-transitions":"",size:"medium",type:"info"},on:{click:s.scrollRight}},[t("i",{staticClass:"el-icon-arrow-right"})])],1)},W=[],K=C(M,H,W,!1,null,null);const G=K.exports;var Y=Object.defineProperty,z=(r,e,t)=>e in r?Y(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>z(r,typeof e!="symbol"?e+"":e,t);const A=6;class V{constructor(e,t,s){p(this,"field"),p(this,"label"),p(this,"value"),p(this,"required"),p(this,"index"),p(this,"visible"),p(this,"disabled"),p(this,"span"),p(this,"initValue"),p(this,"enable"),p(this,"pinned"),p(this,"tagFilter"),p(this,"render"),p(this,"transform"),p(this,"onChange");var i,a,o,n,h;this.field=e.field,this.label=e.label,this.value=e.initValue,this.required=e.required,this.initValue=e.initValue,this.index=t,this.visible=(i=e.visible)!=null?i:!0,this.span=(a=e.span)!=null?a:A,this.render=e.render,this.tagFilter=e.tagFilter,this.transform=e.transform,this.enable=(o=e.enable)!=null?o:!0,this.disabled=(n=e.disabled)!=null?n:!1,this.pinned=(h=e.pinned)!=null?h:!1,e.onChange&&s&&(this.onChange=s((g,y)=>e.onChange(g,y),50))}clean(){Array.isArray(this.value)?this.value=[]:this.value=void 0}reset(){this.value=this.initValue}isEnable(e){return f.isFunction(this.enable)?this.enable(e.getSearchObject()):this.enable}isDisabled(e){return f.isFunction(this.disabled)?this.disabled(e.getSearchObject()):this.disabled}}var U=Object.defineProperty,X=(r,e,t)=>e in r?U(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,J=(r,e,t)=>X(r,e+"",t);class B{cacheKey(e){return`searches_layouts_${e}`}async load(e){const t=localStorage.getItem(this.cacheKey(e));return t?t.split(",").map(s=>{const[i,a,o,n,h]=s.split("_");return{field:a,span:Number(o),index:Number(i),visible:n==="true",pinned:h==="true"}}):null}async save(e,t){const s=t.map(i=>`${i.index}_${i.field}_${i.span}_${i.visible}_${i.pinned}`).join(",");localStorage.setItem(this.cacheKey(e),s)}}class Q{constructor(){J(this,"cache",new Map)}async load(e){var t;return(t=this.cache.get(e))!=null?t:null}async save(e,t){this.cache.set(e,t)}}var Z=Object.defineProperty,ee=(r,e,t)=>e in r?Z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,v=(r,e,t)=>ee(r,typeof e!="symbol"?e+"":e,t);class S{constructor(e,t,s,i,a){v(this,"field"),v(this,"span"),v(this,"index"),v(this,"visible"),v(this,"pinned"),this.field=e,this.span=t,this.index=s,this.visible=i,this.pinned=a}static fromSearchItem(e,t){return new S(e.field,e.span,t??e.index,e.visible,e.pinned)}static formSearchConfig(e,t){var s,i,a;return new S(e.field,(s=e.span)!=null?s:A,t??e,(i=e.visible)!=null?i:!0,(a=e.pinned)!=null?a:!1)}static fromLayoutData(e){return new S(e.field,e.span,e.index,e.visible,e.pinned)}toLayoutData(){return{field:this.field,span:this.span,index:this.index,visible:this.visible,pinned:this.pinned}}merge(e){this.span=e.span,this.index=e.index,this.visible=e.visible,this.pinned=e.pinned}}class E{constructor(e,t,s){v(this,"id"),v(this,"state"),v(this,"itemLayouts"),v(this,"initialLayouts"),v(this,"storage"),this.id=e.id,this.initialLayouts=t,this.state=e,this.storage=s??new B,this.itemLayouts=f.keyBy(e.items.map(S.fromSearchItem),i=>i.field),this.restoreCachedLayouts()}async restoreCachedLayouts(){const e=await this.storage.load(this.id);e&&e.forEach(t=>{const s=this.itemLayouts[t.field];s&&s.merge(S.fromLayoutData(t))})}sync(e,t,s){if(e.length!==Object.keys(this.itemLayouts).length)throw new Error("同步布局字段数量不一致");e.forEach((i,a)=>{const o=this.itemLayouts[i];o.index=a,o.visible=t.has(i),o.pinned=s.has(i)})}async persistent(){await this.storage.save(this.id,Object.values(this.itemLayouts).map(e=>e.toLayoutData())),this.state.updateTags()}reset(){this.initialLayouts.forEach(e=>{const t=this.itemLayouts[e.field];t&&t.merge(e)})}}var te=Object.defineProperty,se=(r,e,t)=>e in r?te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,b=(r,e,t)=>se(r,typeof e!="symbol"?e+"":e,t);class D{constructor(e,t,s){b(this,"id"),b(this,"field"),b(this,"value"),b(this,"label"),b(this,"valueText"),b(this,"required"),b(this,"item"),b(this,"state"),b(this,"componentTextGetters");var i;this.id=`#${e.id}-${t.field}`,this.state=e,this.field=t.field,this.value=t.value,this.label=t.label,this.item=t,this.required=(i=t.required)!=null?i:!1,this.componentTextGetters=s,this.updateValueText()}static hasValue(e){return f.isNumber(e.value)||f.isBoolean(e.value)?!0:!f.isEmpty(e.value)}updateValueText(){const e=document.querySelector(this.id);if(!e||e.children.length!==1)return;const t=e.children[0],s=this.componentTextGetters.find(i=>i.isApply(t.classList));s&&(this.valueText=s.getText(t,this))}async clean(){this.item.clean(),await this.state.doSearch()}}var ie=Object.defineProperty,re=(r,e,t)=>e in r?ie(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ae=(r,e,t)=>re(r,e+"",t);const ne=r=>f.isEmpty(r),le=()=>!0,oe=(r,e)=>{const t=r.getSearchObject();let s=!0;for(const[i,a]of Object.entries(e)){const o=t[i];s=a(o),s||(s=!1)}return()=>s};class ${constructor(e){ae(this,"record"),this.record=e}static from(e){const t=e.filter(s=>s.value===void 0?!1:Array.isArray(s.value)?s.value.length>0:!0).reduce((s,i)=>{const a=i.transform?i.transform(i.value):i.value;return{...s,...f.isPlainObject(a)?a:{[i.field]:a}}},{});return new $(t)}transform(e,t){const s=this.record[e],i=t(s);return delete this.record[e],this.record={...this.record,...i},this}toCondition(e){return{...this.record,...e}}}var ce=Object.defineProperty,ue=(r,e,t)=>e in r?ce(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,O=(r,e,t)=>ue(r,typeof e!="symbol"?e+"":e,t);class j{constructor(e){O(this,"config"),O(this,"_state"),O(this,"listeners",new Set),O(this,"debounceTimers",new Map),this.config=e,this._state={id:e.id,values:this.initValues(e.searches),tags:[],searching:!1},this.updateTags()}initValues(e){const t={};for(const s of e)t[s.field]=s.initValue;return t}getState(){return{...this._state}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){const e=this.getState();for(const t of this.listeners)t(e)}getValue(e){return this._state.values[e]}setValue(e,t,s){this._state.values[e]=t;const i=this.config.searches.find(a=>a.field===e);if(i!=null&&i.onChange)if(s){const a=this.debounceTimers.get(e);a&&clearTimeout(a),this.debounceTimers.set(e,setTimeout(()=>{i.onChange(t,this.createContext()),this.debounceTimers.delete(e)},s))}else i.onChange(t,this.createContext());this.notify()}createContext(){return{id:this.config.id,getValue:e=>this.getValue(e),setValue:(e,t)=>this.setValue(e,t),getSearchObject:()=>this.getSearchObject(),doSearch:()=>this.doSearch(),reset:()=>this.reset(),updateTags:()=>this.updateTags()}}getSearchObject(){const e={};for(const t of this.config.searches){const s=this._state.values[t.field];s!==void 0&&s!==""&&s!==null&&(t.transform?Object.assign(e,t.transform(s)):e[t.field]=s)}return e}async doSearch(){if(!this._state.searching)try{this._state.searching=!0,this.notify(),await this.config.onSearch(this.getSearchObject()),this.updateTags()}finally{this._state.searching=!1,this.notify()}}reset(){for(const e of this.config.searches)this._state.values[e.field]=e.initValue;this._state.tags=[],this.notify()}updateTags(){var e,t;const s=[];for(const i of this.config.searches){const a=this._state.values[i.field];(i.tagFilter?i.tagFilter(a):this.defaultHasValue(a))&&s.push({field:i.field,label:i.label,value:a,valueText:void 0,required:(e=i.required)!=null?e:!1,closable:!((t=i.required)!=null&&t)})}this._state.tags=s,this.notify()}defaultHasValue(e){return e==null?!1:typeof e=="number"||typeof e=="boolean"?!0:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim()!=="":!0}updateTagValueText(e,t){const s=this._state.tags.find(i=>i.field===e);s&&(s.valueText=t,this.notify())}getApi(){return{...this.createContext(),state:this.getState(),fields:this.config.searches}}}var he=Object.defineProperty,de=(r,e,t)=>e in r?he(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e,t)=>de(r,typeof e!="symbol"?e+"":e,t);let R=class q{constructor(e,t,s,i,a,o){this.id=e,m(this,"items"),m(this,"config"),m(this,"searching"),m(this,"tags"),m(this,"searchCallback"),m(this,"sourceSearchable"),m(this,"componentTextGetters"),m(this,"core"),m(this,"unsubscribe"),m(this,"_lastSearchObject",{time:0,data:null}),this.id=e,this.items=t.map((n,h)=>new V(n,h,i)),this.config=new E(this,t.map((n,h)=>S.formSearchConfig(n,h)),o),this.componentTextGetters=a,this.sourceSearchable=t,this.searching=!1,this.searchCallback=s,this.tags=[],this.core=new j({id:e,searches:t.map(n=>({field:n.field,label:n.label,render:n.render,initValue:n.initValue,required:n.required,visible:n.visible,pinned:n.pinned,span:n.span,disabled:n.disabled,enable:n.enable,tagFilter:n.tagFilter,transform:n.transform,onChange:n.onChange})),onSearch:s}),this.unsubscribe=this.core.subscribe(n=>{this.searching=n.searching})}static create(e){return new q(e.id,e.searches,e.onSearch,e.debounceFn,e.componentTextGetters,e.storage)}updateSearchTag(e){var t;(t=this.tags.find(s=>s.field===e))==null||t.updateValueText()}updateTags(){this.tags=this.items.filter(e=>e.tagFilter?e.tagFilter(e.value):D.hasValue(e)).map(e=>new D(this,e,this.componentTextGetters)).sort((e,t)=>this.config.itemLayouts[e.field].index-this.config.itemLayouts[t.field].index),this.core.updateTags()}getSearchObject(e){const t=Date.now();return this._lastSearchObject.data&&t-this._lastSearchObject.time<50?this._lastSearchObject.data:(this._lastSearchObject={time:t,data:$.from(this.items).toCondition(e)},this._lastSearchObject.data)}async doSearch(){if(!this.searching)try{this.searching=!0,await this.searchCallback(this.getSearchObject()),this.updateTags()}finally{this.searching=!1}}async reset(e){this.items.forEach(t=>t.reset()),this.core.reset(),e&&await this.doSearch()}setSearchValue(e,t,s=i=>!0){const i=this.items.find(a=>a.field===e);i&&s&&s(i.value)&&(i.value=t,this.core.setValue(e,t))}destroy(){var e;(e=this.unsubscribe)==null||e.call(this)}};const N=()=>{const r=l.shallowRef(),e=l.ref(),t=l.ref([]),s=l.ref(!1),i=l.ref(),a=l.ref([]),o=l.ref(300),n=u=>{r.value=u,t.value=[{label:"全部",id:"all",children:r.value.items.sort((d,_)=>u.config.itemLayouts[d.field].index-u.config.itemLayouts[_.field].index).map(d=>({label:d.label,id:d.field,disabled:!d.isEnable(u),pinned:u.config.itemLayouts[d.field].pinned}))}],i.value=Object.keys(u.config.itemLayouts).filter(d=>{var _;return(_=u.config.itemLayouts[d])==null?void 0:_.visible})};return{treeRef:e,visible:s,snapshot:t,defaultCheckedKeys:i,drawerWidth:o,updateSnapshot:n,show:u=>{n(u),s.value=!0},save:()=>{r.value.config.sync(t.value[0].children.map(u=>u.id),new Set(e.value.getCheckedKeys()),new Set(t.value[0].children.filter(u=>u.pinned).map(u=>u.id))),r.value.config.persistent(),s.value=!1},reset:()=>{r.value.config.reset(),n(r.value)},keepSelection:()=>{a.value=e.value.getCheckedKeys()},restoreSelection:()=>{e.value.setCheckedKeys(a.value),a.value=[]},allowDrop:(u,d,_)=>_!=="inner",allowDrag:u=>!u.disabled,onPinnedChange:u=>{u.data.pinned=!u.data.pinned}}},fe=[{isApply(r){return r.contains("el-radio-group")},getText(r){var e,t;return(t=(e=r.querySelector(".is-active"))==null?void 0:e.querySelector("input"))==null?void 0:t.value}},{isApply(r){return r.contains("el-checkbox-group")},getText(r){var e;const t=Array.from((e=r.querySelectorAll(".el-checkbox__input.is-checked"))!=null?e:[]).map(s=>{var i;return(i=s.querySelector("input"))==null?void 0:i.value}).filter(s=>s);if(t.length===1)return t[0];if(t.length>1)return`${t[0]} 等${t.length}条`}},{isApply(r){return r.contains("el-input")},getText(r,e){return e.value}},{isApply(r){return r.contains("el-input-number")},getText(r,e){return e.value}},{isApply(r){return r.contains("el-select")},getText(r,e){var t,s;const i=r.querySelectorAll(".el-select__tags-text");return i.length>0?e.value.length>1?`${i[0].textContent} 等${e.value.length}条`:(t=i[0].textContent)!=null?t:void 0:(s=r.querySelector("input"))==null?void 0:s.value}},{isApply(r){return r.contains("el-cascader")},getText(r){var e;return(e=r.querySelector("input"))==null?void 0:e.value}},{isApply(r){return r.contains("el-switch")},getText(r){const e=r.querySelector(".is-active");return e==null?void 0:e.innerHTML}},{isApply(r){return r.contains("el-slider")},getText(r,e){return e.value}},{isApply(r){return r.contains("el-date-editor")},getText(r,e){return Array.isArray(e.value)?e.value.join(" ~ "):e.value}}];class pe extends R{constructor(e,t,s,i){super(e,t,s,P.useDebounceFn,fe,i)}}const _e={name:"PinIcon",props:{active:{type:Boolean,default:!1}}};var ge=function(){var e=this,t=e._self._c;return t("svg",{class:["pin-icon",{"is-active":e.active}],attrs:{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},on:{click:function(s){return s.stopPropagation(),e.$emit("click")}}},[t("path",{attrs:{d:"M9.828.722a.5.5 0 0 1 .354.146l4.95 4.95a.5.5 0 0 1 0 .707c-.48.48-1.072.588-1.503.588-.177 0-.335-.018-.46-.039l-3.134 3.134a5.927 5.927 0 0 1 .16 1.013c.046.702-.032 1.687-.72 2.375a.5.5 0 0 1-.707 0l-2.829-2.828-3.182 3.182c-.195.195-1.219.902-1.414.707-.195-.195.512-1.22.707-1.414l3.182-3.182-2.828-2.829a.5.5 0 0 1 0-.707c.688-.688 1.673-.767 2.375-.72a5.922 5.922 0 0 1 1.013.16l3.134-3.133a2.772 2.772 0 0 1-.04-.461c0-.43.108-1.022.589-1.503a.5.5 0 0 1 .353-.146z"}})])},ve=[],me=C(_e,ge,ve,!1,null,"b04d59bb");const be=me.exports,Se=l.defineComponent({__name:"SearchSettingsDrawer",setup(r,{expose:e}){const{treeRef:t,visible:s,snapshot:i,drawerWidth:a,defaultCheckedKeys:o,show:n,allowDrop:h,allowDrag:g,keepSelection:y,restoreSelection:x,save:w,reset:T,onPinnedChange:L}=N();return e({show:n}),{__sfc:!0,treeRef:t,visible:s,snapshot:i,drawerWidth:a,defaultCheckedKeys:o,show:n,allowDrop:h,allowDrag:g,keepSelection:y,restoreSelection:x,save:w,reset:T,onPinnedChange:L,PinIcon:be}}});var ye=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("el-drawer",{attrs:{size:s.drawerWidth,title:"搜索项配置",visible:s.visible,"modal-append-to-body":!0,"append-to-body":!0},on:{"update:visible":function(i){s.visible=i}}},[t("div",{staticClass:"setting-container"},[t("el-tree",{ref:"treeRef",staticClass:"tree",attrs:{"default-expand-all":"","default-checked-keys":s.defaultCheckedKeys,"node-key":"id",draggable:"","show-checkbox":"",data:s.snapshot,"allow-drop":s.allowDrop,"allow-drag":s.allowDrag,"expand-on-click-node":!1},on:{"node-drag-start":s.keepSelection,"node-drag-end":s.restoreSelection},scopedSlots:e._u([{key:"default",fn:function({node:i}){return[t("span",{staticClass:"custom-tree-node"},[t("span",[e._v(e._s(i.label))]),i.data.id!=="all"?t(s.PinIcon,{attrs:{active:i.data.pinned},on:{click:function(a){return s.onPinnedChange(i)}}}):e._e()],1)]}}])}),t("div",{staticClass:"footer"},[t("el-button",{on:{click:s.reset}},[e._v("重置")]),t("el-button",{attrs:{type:"primary"},on:{click:s.save}},[e._v("保存")])],1)],1)])},we=[],Ce=C(Se,ye,we,!1,null,null);const xe=Ce.exports,Te=l.defineComponent({__name:"SettingButton",props:{state:null},setup(r){const e=r,t=l.ref();return{__sfc:!0,props:e,searchSettingDialogRef:t,showSearchLayoutDialog:()=>{t.value.show(e.state)},SearchSettingsDrawer:xe}}});var Le=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("el-button",{staticClass:"icon-button",on:{click:s.showSearchLayoutDialog}},[t("i",{staticClass:"el-icon-s-tools"}),t(s.SearchSettingsDrawer,{ref:"searchSettingDialogRef"})],1)},Pe=[],$e=C(Te,Le,Pe,!1,null,"2b748196");const Oe=$e.exports,Ae={functional:!0,props:{search:{type:Object,required:!0},api:{type:Object}},render(r,e){var t;const{props:s}=e,i=s.search.render(s.search);if(i.componentOptions.propsData||(i.componentOptions.propsData={}),i.componentOptions.listeners||(i.componentOptions.listeners={}),i.componentOptions.listeners||(i.componentOptions.listeners={}),(t=i.data)!=null&&t.attrs||(i.data.attrs={}),i.data.attrs.labelChange=()=>{s.api.updateSearchTag(s.search.field)},i.componentOptions.listeners.input){const a=i.componentOptions.listeners.input;i.componentOptions.listeners.input=o=>{s.search.onChange&&s.search.onChange(o,s.api),a(o)}}return i.componentOptions.propsData.disabled=s.search.isDisabled(s.api),i}},De=l.defineComponent({__name:"SearchBarItem",props:{item:null},setup(r){const e=r,t=l.inject("search-bar-state"),s=l.inject("search-bar-id");return{__sfc:!0,props:e,state:t,id:s,SearchItemRender:Ae}}});var Fe=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-item"},[t("div",{staticClass:"search-item-title"},[e._v(e._s(e.item.label))]),t("div",{staticClass:"search-item-content",attrs:{id:`${s.id}-${e.item.field}`}},[t(s.SearchItemRender,{attrs:{search:e.item,api:s.state}})],1)])},Ve=[],Be=C(De,Fe,Ve,!1,null,"73b72e60");const Ee=Be.exports,je=l.defineComponent({__name:"SearchBar",props:{searches:null,id:null,onSearch:{type:Function},defaultSpan:{default:6},maxRows:{default:2},itemHeight:{default:67},resetAutoSearch:{type:Boolean,default:!0}},emits:["change"],setup(r,{expose:e,emit:t}){const s=r,i=l.reactive(new pe(s.id,s.searches,s.onSearch)),a=l.ref(!1),o=l.ref(),n=l.ref();P.useMutationObserver(o,()=>{i.updateTags()},{childList:!0}),P.useMutationObserver(n,()=>{i.updateTags()},{childList:!0});const h=l.computed(()=>x.value.filter(d=>w(d).visible).length>0),g=l.ref([]),y=l.computed(()=>g.value.filter(d=>w(d).pinned)),x=l.computed(()=>g.value.filter(d=>!w(d).pinned));P.watchDebounced(()=>[i.items,i.config.itemLayouts],()=>{const d=[...i.items.filter(_=>_.pinned),...i.items.filter(_=>!_.pinned)];g.value=d.sort((_,Me)=>i.config.itemLayouts[_.field].index-i.config.itemLayouts[Me.field].index).filter(_=>_.isEnable(i)),t("change",i.getSearchObject(),i)},{debounce:100,immediate:!0,deep:!0});const w=d=>i.config.itemLayouts[d.field],T=()=>i.items,L=()=>i.getSearchObject(),F=d=>{i.searching=d},u=()=>i.updateTags();return l.provide("search-bar-state",i),l.provide("search-bar-id",s.id),e({getSearchItems:T,getSearchObject:L,updateSearching:F,updateTags:u}),{__sfc:!0,props:s,state:i,expanded:a,itemContainerRef:o,hideItemContainerRef:n,isShowSpanIcon:h,sortedItems:g,sortedPinnedItems:y,sortedNormalItems:x,emits:t,getLayout:w,getSearchItems:T,getSearchObject:L,updateSearching:F,updateTags:u,SearchTagsRender:G,SettingButton:Oe,SearchBarItem:Ee}}});var Re=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"search-bar-container"},[t("el-row",{ref:"itemContainerRef",class:"search",staticStyle:{"flex-wrap":"wrap"},attrs:{type:"flex",gutter:16}},[e._l(s.sortedPinnedItems,function(i){return t("el-col",{directives:[{name:"show",rawName:"v-show",value:s.getLayout(i).visible,expression:"getLayout(item).visible"}],key:i.field,attrs:{span:s.getLayout(i).span}},[t(s.SearchBarItem,{attrs:{item:i}})],1)}),t("el-collapse-transition",[t("div",{directives:[{name:"show",rawName:"v-show",value:s.expanded,expression:"expanded"}],ref:"hideItemContainerRef",staticStyle:{width:"100%"}},e._l(s.sortedNormalItems,function(i){return t("el-col",{directives:[{name:"show",rawName:"v-show",value:s.getLayout(i).visible,expression:"getLayout(item).visible"}],key:i.field,attrs:{span:s.getLayout(i).span}},[t(s.SearchBarItem,{attrs:{item:i}})],1)}),1)])],2),t("div",{staticClass:"search-bottom"},[s.state.tags.length>0?t(s.SearchTagsRender,{attrs:{tags:s.state.tags}}):e._e(),t("div",{staticClass:"actions"},[t("el-button",{directives:[{name:"show",rawName:"v-show",value:s.isShowSpanIcon,expression:"isShowSpanIcon"}],staticClass:"icon-button",on:{click:function(i){s.expanded=!s.expanded}}},[t("i",{class:[s.expanded?"el-icon-arrow-up":"el-icon-arrow-down"]})]),t(s.SettingButton,{attrs:{state:s.state}}),t("el-button",{attrs:{type:"primary",loading:s.state.searching,disabled:s.state.searching},on:{click:()=>s.state.doSearch()}},[e._v("查 询 ")]),t("el-button",{on:{click:()=>s.state.reset(e.resetAutoSearch)}},[e._v("重 置")])],1)],1)],1)},Ne=[],qe=C(je,Re,Ne,!1,null,null);const Ie=qe.exports,ke=(r,e,t)=>({refreshCallback:async s=>{const i=e.value.getSearchObject();try{return e.value.updateSearching(!0),await r(i,s)}finally{e.value.updateSearching(!1),e.value.updateTags()}},searchCallback:async()=>{var s;for(const i of t)await((s=i.value)==null?void 0:s.refresh())}});c.APPLY_ALWAYS=le,c.APPLY_WHEN_NOT_VALUE=ne,c.APPLY_WITH_MULTIPLE_VALUE=oe,c.DEFAULT_SEARCH_SPAN=A,c.LocalStorage=B,c.MemoryStorage=Q,c.SearchBar=Ie,c.SearchBarCore=j,c.SearchBarState=R,c.SearchConfig=E,c.SearchItem=V,c.SearchItemLayout=S,c.SearchTag=D,c.Searches=$,c.useSearchProxy=ke,c.useSetting=N,c.vModel=I,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
.tags-scroll-container{display:flex}.tags-scroll-container .pointer{cursor:pointer}.tags-scroll-container .search-tags{display:flex;flex-wrap:nowrap;overflow-x:auto;gap:10px;margin-top:2px;flex:1;align-items:center}.tags-scroll-container .search-tags::-webkit-scrollbar{display:none}.tags-scroll-container .scroll-left-bar{cursor:pointer;margin-right:10px;height:100%;display:flex;align-items:center;padding:0 4px}.tags-scroll-container .scroll-right-bar{cursor:pointer;margin-left:10px;height:100%;display:flex;align-items:center;padding:0 4px}.pin-icon[data-v-b04d59bb]{width:16px;height:16px;cursor:pointer;color:#909399;transition:color .2s}.pin-icon[data-v-b04d59bb]:hover,.pin-icon.is-active[data-v-b04d59bb]{color:#409eff}.setting-container{display:flex;flex-direction:column;height:100%}.setting-container .custom-tree-node{flex:1;display:flex;align-items:center;justify-content:space-between;font-size:14px;padding-right:8px}.setting-container .tree{flex:1;overflow-y:auto}.setting-container div[aria-disabled=true]{display:none}.setting-container .footer{margin-top:auto;margin-left:auto;padding:10px 15px;display:flex;gap:10px}.setting-container .footer .el-button{width:90px}.search-bar-container{font-size:14px;width:100%;display:flex;flex-direction:column}.search-bar-container .search,.search-bar-container .el-input-number,.search-bar-container .el-select,.search-bar-container .el-date-editor,.search-bar-container .el-cascader{width:100%}.search-bar-container .search-bottom{display:flex}.search-bar-container .search-bottom .tags-scroll-container{flex:1;min-width:0;margin-right:10px}.search-bar-container .search-bottom .actions{display:flex;flex-wrap:nowrap;gap:8px;margin-left:auto}.search-bar-container .search-bottom .actions .el-button{width:90px;margin:0}.search-bar-container .search-bottom .actions .icon-button{width:34px;padding:0 8px;font-size:larger}.search-bar-container .search-bottom .actions .icon-button i{position:relative;top:1px}.search-bar-container .search-item{margin-bottom:12px}.search-bar-container .search-item-content{margin-top:4px}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SearchItem } from './model/SearchItem';
|
|
2
|
+
import { SearchConfig } from './model/SearchConfig';
|
|
3
|
+
import { SearchTag, ComponentTextGetter } from './model/SearchTag';
|
|
4
|
+
import type { Searchable } from './types/Searchable';
|
|
5
|
+
import type { SearchBarStateLike } from './types/SearchBarState';
|
|
6
|
+
import { SearchValueApply } from './Searches';
|
|
7
|
+
import type { ConfigStorage } from './storage/ConfigStorage';
|
|
8
|
+
export interface SearchBarStateOptions {
|
|
9
|
+
id: string;
|
|
10
|
+
searches: Searchable[];
|
|
11
|
+
onSearch: (params: any) => Promise<void>;
|
|
12
|
+
debounceFn: (fn: any, wait: number) => any;
|
|
13
|
+
componentTextGetters: ComponentTextGetter[];
|
|
14
|
+
storage?: ConfigStorage;
|
|
15
|
+
}
|
|
16
|
+
export declare class SearchBarState implements SearchBarStateLike {
|
|
17
|
+
id: string;
|
|
18
|
+
items: SearchItem[];
|
|
19
|
+
config: SearchConfig;
|
|
20
|
+
searching: boolean;
|
|
21
|
+
tags: SearchTag[];
|
|
22
|
+
searchCallback: <T>(params: T) => Promise<void>;
|
|
23
|
+
sourceSearchable: Searchable[];
|
|
24
|
+
protected componentTextGetters: ComponentTextGetter[];
|
|
25
|
+
private core;
|
|
26
|
+
private unsubscribe?;
|
|
27
|
+
private _lastSearchObject;
|
|
28
|
+
constructor(id: string, searches: Searchable[], onSearch: (params: any) => Promise<void>, debounceFn: (fn: any, wait: number) => any, componentTextGetters: ComponentTextGetter[], storage?: ConfigStorage);
|
|
29
|
+
static create(options: SearchBarStateOptions): SearchBarState;
|
|
30
|
+
updateSearchTag(field: string): void;
|
|
31
|
+
updateTags(): void;
|
|
32
|
+
getSearchObject<T>(ext?: any): T;
|
|
33
|
+
doSearch(): Promise<void>;
|
|
34
|
+
reset(search?: boolean): Promise<void>;
|
|
35
|
+
setSearchValue<T>(field: string, value?: T, isApply?: SearchValueApply<T>): void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=SearchBarState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBarState.d.ts","sourceRoot":"","sources":["../../../../../shared/src/SearchBarState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAoB,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAY,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE5D,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,UAAU,EAAE,CAAA;IACtB,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,UAAU,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,CAAA;IAC1C,oBAAoB,EAAE,mBAAmB,EAAE,CAAA;IAC3C,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB;AAED,qBAAa,cAAe,YAAW,kBAAkB;IAe9C,EAAE,EAAE,MAAM;IAdnB,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,SAAS,EAAE,CAAA;IACjB,cAAc,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,gBAAgB,EAAE,UAAU,EAAE,CAAA;IAC9B,SAAS,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAAA;IAErD,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,WAAW,CAAC,CAAY;IAEhC,OAAO,CAAC,iBAAiB,CAAuD;gBAGvE,EAAE,EAAE,MAAM,EACjB,QAAQ,EAAE,UAAU,EAAE,EACtB,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,EACxC,UAAU,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,EAC1C,oBAAoB,EAAE,mBAAmB,EAAE,EAC3C,OAAO,CAAC,EAAE,aAAa;IAwCzB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc;IAW7D,eAAe,CAAC,KAAK,EAAE,MAAM;IAI7B,UAAU;IAkBH,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG;IAWtB,QAAQ;IAaR,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO;IAQ5B,cAAc,CAAC,CAAC,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,CAAC,EACT,OAAO,GAAE,gBAAgB,CAAC,CAAC,CAAmB;IAWzC,OAAO;CAGf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TransformCallback } from './types/Searchable';
|
|
2
|
+
import type { SearchValueLike } from './types/SearchValueLike';
|
|
3
|
+
export type SearchValueApply<T> = (value?: T) => boolean;
|
|
4
|
+
export declare const APPLY_WHEN_NOT_VALUE: SearchValueApply<any>;
|
|
5
|
+
export declare const APPLY_ALWAYS: SearchValueApply<any>;
|
|
6
|
+
export type SearchMultipleValueApply = Record<string, SearchValueApply<any>>;
|
|
7
|
+
export declare const APPLY_WITH_MULTIPLE_VALUE: (api: any, config: SearchMultipleValueApply) => SearchValueApply<any>;
|
|
8
|
+
export declare class Searches {
|
|
9
|
+
record: Record<string, any>;
|
|
10
|
+
constructor(record: Record<string, any>);
|
|
11
|
+
static from(searches: SearchValueLike[]): Searches;
|
|
12
|
+
transform<T>(field: string, transformCallback: TransformCallback<T>): Searches;
|
|
13
|
+
toCondition<T>(record?: Record<string, any>): T;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Searches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Searches.d.ts","sourceRoot":"","sources":["../../../../../shared/src/Searches.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE9D,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,CAAA;AAExD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,GAAG,CAEtD,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,GAAG,CAE9C,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAA;AAE5E,eAAO,MAAM,yBAAyB,EAAE,CACtC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,wBAAwB,KAC7B,gBAAgB,CAAC,GAAG,CAaxB,CAAA;AAED,qBAAa,QAAQ;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;gBAEf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIvC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE;IA0BvC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,QAAQ;IAQ9E,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACD,CAAC;CAE5C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SearchStateData, SearchBarConfig, SearchBarApi } from '../types';
|
|
2
|
+
type Listener = (state: SearchStateData) => void;
|
|
3
|
+
export declare class SearchBarCore {
|
|
4
|
+
private config;
|
|
5
|
+
private _state;
|
|
6
|
+
private listeners;
|
|
7
|
+
private debounceTimers;
|
|
8
|
+
constructor(config: SearchBarConfig);
|
|
9
|
+
private initValues;
|
|
10
|
+
getState(): SearchStateData;
|
|
11
|
+
subscribe(listener: Listener): () => void;
|
|
12
|
+
private notify;
|
|
13
|
+
getValue<T>(field: string): T | undefined;
|
|
14
|
+
setValue<T>(field: string, value: T, debounce?: number): void;
|
|
15
|
+
private createContext;
|
|
16
|
+
getSearchObject<T>(): T;
|
|
17
|
+
doSearch(): Promise<void>;
|
|
18
|
+
reset(): void;
|
|
19
|
+
updateTags(): void;
|
|
20
|
+
private defaultHasValue;
|
|
21
|
+
updateTagValueText(field: string, valueText: string): void;
|
|
22
|
+
getApi(): SearchBarApi;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=SearchBarCore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBarCore.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/core/SearchBarCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgC,eAAe,EAAoB,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE9H,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;AAEhD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,cAAc,CAAwD;gBAElE,MAAM,EAAE,eAAe;IAWnC,OAAO,CAAC,UAAU;IAQlB,QAAQ,IAAI,eAAe;IAI3B,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI;IAKzC,OAAO,CAAC,MAAM;IAOd,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIzC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAoB7D,OAAO,CAAC,aAAa;IAYrB,eAAe,CAAC,CAAC,KAAK,CAAC;IAejB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B,KAAK,IAAI,IAAI;IAQb,UAAU,IAAI,IAAI;IA0BlB,OAAO,CAAC,eAAe;IASvB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAQ1D,MAAM,IAAI,YAAY;CAQvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../shared/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { SearchItem } from './SearchItem';
|
|
2
|
-
import type {
|
|
3
|
-
import { Searchable } from '../types/Searchable';
|
|
4
|
-
|
|
5
|
-
* 搜索项布局
|
|
6
|
-
*/
|
|
2
|
+
import type { SearchBarStateLike } from '../types/SearchBarState';
|
|
3
|
+
import type { Searchable } from '../types/Searchable';
|
|
4
|
+
import type { ConfigStorage, LayoutData } from '../storage/ConfigStorage';
|
|
7
5
|
export declare class SearchItemLayout {
|
|
8
6
|
field: string;
|
|
9
7
|
span: number;
|
|
@@ -13,27 +11,22 @@ export declare class SearchItemLayout {
|
|
|
13
11
|
constructor(field: string, span: number, index: number, visible: boolean, pinned: boolean);
|
|
14
12
|
static fromSearchItem(searchItem: SearchItem, index?: number): SearchItemLayout;
|
|
15
13
|
static formSearchConfig(searchable: Searchable, index?: number): SearchItemLayout;
|
|
16
|
-
static
|
|
17
|
-
|
|
14
|
+
static fromLayoutData(data: LayoutData): SearchItemLayout;
|
|
15
|
+
toLayoutData(): LayoutData;
|
|
18
16
|
merge(layout: SearchItemLayout): void;
|
|
19
17
|
}
|
|
20
18
|
type Layout = Record<string, SearchItemLayout>;
|
|
21
|
-
/**
|
|
22
|
-
* 搜索配置
|
|
23
|
-
*/
|
|
24
19
|
export declare class SearchConfig {
|
|
25
20
|
id: string;
|
|
26
|
-
state:
|
|
21
|
+
state: SearchBarStateLike;
|
|
27
22
|
itemLayouts: Layout;
|
|
28
23
|
initialLayouts: SearchItemLayout[];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* 恢复自缓存中的布局信息
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
24
|
+
private storage;
|
|
25
|
+
constructor(state: SearchBarStateLike, initialLayouts: SearchItemLayout[], storage?: ConfigStorage);
|
|
34
26
|
private restoreCachedLayouts;
|
|
35
27
|
sync(sortedKeys: string[], visibleKeys: Set<string>, pinnedKeys: Set<string>): void;
|
|
36
|
-
persistent(): void
|
|
28
|
+
persistent(): Promise<void>;
|
|
37
29
|
reset(): void;
|
|
38
30
|
}
|
|
39
31
|
export {};
|
|
32
|
+
//# sourceMappingURL=SearchConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchConfig.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/model/SearchConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAIzE,qBAAa,gBAAgB;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;gBAEH,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO;IAQzF,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM;IAU5D,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM;IAU9D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU;IAItC,YAAY,IAAI,UAAU;IAU1B,KAAK,CAAC,MAAM,EAAE,gBAAgB;CAM/B;AAED,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAE9C,qBAAa,YAAY;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,kBAAkB,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,gBAAgB,EAAE,CAAA;IAClC,OAAO,CAAC,OAAO,CAAe;gBAG5B,KAAK,EAAE,kBAAkB,EACzB,cAAc,EAAE,gBAAgB,EAAE,EAClC,OAAO,CAAC,EAAE,aAAa;YAUX,oBAAoB;IAYlC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC;IAYtE,UAAU;IAQhB,KAAK;CAQN"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SearchValueLike } from '../types/SearchValueLike';
|
|
2
|
+
import type { PredicateCallback, Searchable, TransformCallback } from '../types/Searchable';
|
|
3
|
+
import type { SearchBarStateLike } from '../types/SearchBarState';
|
|
4
|
+
export declare const DEFAULT_SEARCH_SPAN = 6;
|
|
5
|
+
export type SearchItemRender = (value: SearchValueLike) => any;
|
|
6
|
+
export declare class SearchItem {
|
|
7
|
+
field: string;
|
|
8
|
+
label: string;
|
|
9
|
+
value?: any;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
index: number;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
disabled: boolean | PredicateCallback;
|
|
14
|
+
span: number;
|
|
15
|
+
initValue?: any;
|
|
16
|
+
enable: boolean | PredicateCallback;
|
|
17
|
+
pinned: boolean;
|
|
18
|
+
tagFilter?: (value: any) => boolean;
|
|
19
|
+
render: SearchItemRender;
|
|
20
|
+
transform?: TransformCallback<any>;
|
|
21
|
+
onChange?: (value: any, api: SearchBarStateLike) => void;
|
|
22
|
+
constructor(searchable: Searchable, index: number, debounceFn?: (fn: any, wait: number) => any);
|
|
23
|
+
clean(): void;
|
|
24
|
+
reset(): void;
|
|
25
|
+
isEnable(state: SearchBarStateLike): boolean;
|
|
26
|
+
isDisabled(state: SearchBarStateLike): boolean;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=SearchItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchItem.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/model/SearchItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAEpC,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,GAAG,CAAA;AAE9D,qBAAa,UAAU;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,OAAO,GAAG,iBAAiB,CAAA;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,MAAM,EAAE,OAAO,GAAG,iBAAiB,CAAA;IACnC,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;IACnC,MAAM,EAAE,gBAAgB,CAAA;IACxB,SAAS,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAA;IAClC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAA;gBAE5C,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG;IAoB9F,KAAK;IAQL,KAAK;IAIL,QAAQ,CAAC,KAAK,EAAE,kBAAkB;IAOlC,UAAU,CAAC,KAAK,EAAE,kBAAkB;CAMrC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SearchBarStateLike } from '../types/SearchBarState';
|
|
2
2
|
import type { SearchItem } from './SearchItem';
|
|
3
|
-
type ComponentTextGetter = {
|
|
3
|
+
export type ComponentTextGetter = {
|
|
4
4
|
isApply: (el: DOMTokenList) => boolean;
|
|
5
|
-
getText: (el: Element, search: SearchTag) => string;
|
|
5
|
+
getText: (el: Element, search: SearchTag) => string | undefined;
|
|
6
6
|
};
|
|
7
|
-
export declare const COMPONENT_TEXT_GETTER: ComponentTextGetter[];
|
|
8
7
|
export declare class SearchTag {
|
|
9
8
|
private readonly id;
|
|
10
9
|
field: string;
|
|
@@ -14,9 +13,10 @@ export declare class SearchTag {
|
|
|
14
13
|
required: boolean;
|
|
15
14
|
private item;
|
|
16
15
|
private state;
|
|
17
|
-
|
|
16
|
+
private componentTextGetters;
|
|
17
|
+
constructor(state: SearchBarStateLike, item: SearchItem, componentTextGetters: ComponentTextGetter[]);
|
|
18
18
|
static hasValue(item: SearchItem): boolean;
|
|
19
19
|
updateValueText(): void;
|
|
20
20
|
clean(): Promise<void>;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
//# sourceMappingURL=SearchTag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchTag.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/model/SearchTag.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAA;IACtC,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,KAAK,MAAM,GAAG,SAAS,CAAA;CAChE,CAAA;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAQ;IAE3B,KAAK,EAAE,MAAM,CAAA;IAEb,KAAK,EAAE,GAAG,CAAA;IAEV,KAAK,EAAE,MAAM,CAAA;IAEb,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,QAAQ,EAAE,OAAO,CAAA;IAEjB,OAAO,CAAC,IAAI,CAAY;IAExB,OAAO,CAAC,KAAK,CAAoB;IAEjC,OAAO,CAAC,oBAAoB,CAAuB;gBAGjD,KAAK,EAAE,kBAAkB,EACzB,IAAI,EAAE,UAAU,EAChB,oBAAoB,EAAE,mBAAmB,EAAE;IAa7C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU;IAUzB,eAAe;IAiBT,KAAK;CAInB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SearchBarStateLike } from '../types/SearchBarState';
|
|
2
|
+
type TreeNode = {
|
|
3
|
+
label: string;
|
|
4
|
+
id: string;
|
|
5
|
+
pinned?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
children?: TreeNode[];
|
|
8
|
+
};
|
|
9
|
+
type TreeKey = string | number;
|
|
10
|
+
type TreeRef = {
|
|
11
|
+
getCheckedKeys: () => TreeKey[];
|
|
12
|
+
setCheckedKeys: (keys: TreeKey[]) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const useSetting: () => {
|
|
15
|
+
treeRef: import("vue").Ref<TreeRef | undefined, TreeRef | undefined>;
|
|
16
|
+
visible: import("vue").Ref<boolean, boolean>;
|
|
17
|
+
snapshot: import("vue").Ref<{
|
|
18
|
+
label: string;
|
|
19
|
+
id: string;
|
|
20
|
+
pinned?: boolean | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
children?: /*elided*/ any[] | undefined;
|
|
23
|
+
}[], TreeNode[] | {
|
|
24
|
+
label: string;
|
|
25
|
+
id: string;
|
|
26
|
+
pinned?: boolean | undefined;
|
|
27
|
+
disabled?: boolean | undefined;
|
|
28
|
+
children?: /*elided*/ any[] | undefined;
|
|
29
|
+
}[]>;
|
|
30
|
+
defaultCheckedKeys: import("vue").Ref<string[] | undefined, string[] | undefined>;
|
|
31
|
+
drawerWidth: import("vue").Ref<number, number>;
|
|
32
|
+
updateSnapshot: (api: SearchBarStateLike) => void;
|
|
33
|
+
show: (api: SearchBarStateLike) => void;
|
|
34
|
+
save: () => void;
|
|
35
|
+
reset: () => void;
|
|
36
|
+
keepSelection: () => void;
|
|
37
|
+
restoreSelection: () => void;
|
|
38
|
+
allowDrop: (_: any, __: any, type: string) => boolean;
|
|
39
|
+
allowDrag: (node: any) => boolean;
|
|
40
|
+
onPinnedChange: (node: any) => void;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=use-setting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-setting.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/setting/use-setting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;CACtB,CAAA;AAED,KAAK,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AAE9B,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,OAAO,EAAE,CAAA;IAC/B,cAAc,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,UAAU;;;;eAdd,MAAM;YACT,MAAM;iBACD,OAAO;mBACL,OAAO;;;eAHX,MAAM;YACT,MAAM;iBACD,OAAO;mBACL,OAAO;;;;;0BA0BW,kBAAkB;gBAuB5B,kBAAkB;;;;;mBA6Bf,GAAG,MAAM,GAAG,QAAQ,MAAM;sBAIvB,GAAG;2BAIE,GAAG;CAoBlC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface LayoutData {
|
|
2
|
+
field: string;
|
|
3
|
+
span: number;
|
|
4
|
+
index: number;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
pinned: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ConfigStorage {
|
|
9
|
+
load(id: string): Promise<LayoutData[] | null>;
|
|
10
|
+
save(id: string, layouts: LayoutData[]): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare class LocalStorage implements ConfigStorage {
|
|
13
|
+
private cacheKey;
|
|
14
|
+
load(id: string): Promise<LayoutData[] | null>;
|
|
15
|
+
save(id: string, layouts: LayoutData[]): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class MemoryStorage implements ConfigStorage {
|
|
18
|
+
private cache;
|
|
19
|
+
load(id: string): Promise<LayoutData[] | null>;
|
|
20
|
+
save(id: string, layouts: LayoutData[]): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ConfigStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigStorage.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/storage/ConfigStorage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAA;IAC9C,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvD;AAED,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,CAAC,QAAQ;IAIV,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;IAgB9C,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAM7D;AAED,qBAAa,aAAc,YAAW,aAAa;IACjD,OAAO,CAAC,KAAK,CAAuC;IAE9C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;IAI9C,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ISearchBarState {
|
|
2
|
+
id: string;
|
|
3
|
+
items: any[];
|
|
4
|
+
config: any;
|
|
5
|
+
searching: boolean;
|
|
6
|
+
tags: any[];
|
|
7
|
+
searchCallback: (params: any) => Promise<void>;
|
|
8
|
+
sourceSearchable: any[];
|
|
9
|
+
updateSearchTag(field: string): void;
|
|
10
|
+
updateTags(): void;
|
|
11
|
+
getSearchObject<T>(ext?: any): T;
|
|
12
|
+
doSearch(): Promise<void>;
|
|
13
|
+
reset(search?: boolean): Promise<void>;
|
|
14
|
+
setSearchValue<T>(field: string, value?: T, isApply?: (value?: T) => boolean): void;
|
|
15
|
+
}
|
|
16
|
+
export type SearchBarStateLike = ISearchBarState;
|
|
17
|
+
//# sourceMappingURL=SearchBarState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBarState.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/SearchBarState.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,GAAG,EAAE,CAAA;IACZ,MAAM,EAAE,GAAG,CAAA;IACX,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,cAAc,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9C,gBAAgB,EAAE,GAAG,EAAE,CAAA;IACvB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,UAAU,IAAI,IAAI,CAAA;IAClB,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAA;IAChC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAA;CACpF;AAED,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchValueLike.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/SearchValueLike.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,MAAM,MAAM,eAAe,GAAG,GAAG,GAAG;IAClC,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,SAAS,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAA;CACnC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type TransformCallback<T> = (value: T) => Record<string, any>;
|
|
2
|
+
export type PredicateCallback = (value: any) => boolean;
|
|
3
|
+
export interface Searchable {
|
|
4
|
+
field: string;
|
|
5
|
+
label: string;
|
|
6
|
+
value?: any;
|
|
7
|
+
initValue?: any;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
disabled?: boolean | PredicateCallback;
|
|
10
|
+
index?: number;
|
|
11
|
+
visible?: boolean;
|
|
12
|
+
pinned?: boolean;
|
|
13
|
+
enable?: boolean | PredicateCallback;
|
|
14
|
+
span?: number;
|
|
15
|
+
render: (value: any) => any;
|
|
16
|
+
transform?: TransformCallback<any>;
|
|
17
|
+
tagFilter?: (value: any) => boolean;
|
|
18
|
+
onChange?: (value: any, api: any) => void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Searchable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Searchable.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/Searchable.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AACpE,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;AAEvD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAA;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAA;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;IAC3B,SAAS,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAA;IAClC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAC1C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SearchValueLike } from './SearchValueLike';
|
|
2
|
+
export * from './SearchValueLike';
|
|
3
|
+
export * from './Searchable';
|
|
4
|
+
export interface SearchContext {
|
|
5
|
+
id: string;
|
|
6
|
+
getValue: <T>(field: string) => T | undefined;
|
|
7
|
+
setValue: <T>(field: string, value: T) => void;
|
|
8
|
+
getSearchObject: <T>() => T;
|
|
9
|
+
doSearch: () => Promise<void>;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
updateTags: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface SearchTagData {
|
|
14
|
+
field: string;
|
|
15
|
+
label: string;
|
|
16
|
+
value: any;
|
|
17
|
+
valueText?: string;
|
|
18
|
+
required: boolean;
|
|
19
|
+
closable: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SearchStateData {
|
|
22
|
+
id: string;
|
|
23
|
+
values: Record<string, any>;
|
|
24
|
+
tags: SearchTagData[];
|
|
25
|
+
searching: boolean;
|
|
26
|
+
}
|
|
27
|
+
export type SearchItemRenderer = (value: SearchValueLike) => any;
|
|
28
|
+
export interface SearchableConfig {
|
|
29
|
+
field: string;
|
|
30
|
+
label: string;
|
|
31
|
+
render: SearchItemRenderer;
|
|
32
|
+
initValue?: any;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
visible?: boolean;
|
|
35
|
+
pinned?: boolean;
|
|
36
|
+
span?: number;
|
|
37
|
+
disabled?: boolean | ((context: SearchContext) => boolean);
|
|
38
|
+
enable?: boolean | ((context: SearchContext) => boolean);
|
|
39
|
+
tagFilter?: (value: any) => boolean;
|
|
40
|
+
transform?: (value: any) => Record<string, any>;
|
|
41
|
+
onChange?: (value: any, context: SearchContext) => void;
|
|
42
|
+
}
|
|
43
|
+
export interface SearchBarConfig {
|
|
44
|
+
id: string;
|
|
45
|
+
searches: SearchableConfig[];
|
|
46
|
+
onSearch: (params: any) => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export interface SearchBarApi extends SearchContext {
|
|
49
|
+
state: SearchStateData;
|
|
50
|
+
fields: SearchableConfig[];
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAE5B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAAA;IAC7C,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAC9C,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;IAC3B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,GAAG,CAAA;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,kBAAkB,CAAA;IAC1B,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,CAAA;IAC1D,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,CAAA;IACxD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;IACnC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;CACxD;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,gBAAgB,EAAE,CAAA;IAC5B,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACzC;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAC3B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Searchable } from './types/Searchable';
|
|
1
|
+
import type { Searchable } from '@element-plus-search/shared';
|
|
3
2
|
type __VLS_Props = {
|
|
4
3
|
searches: Searchable[];
|
|
5
4
|
id: string;
|
|
@@ -22,19 +21,19 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
22
21
|
required?: boolean | undefined;
|
|
23
22
|
index: number;
|
|
24
23
|
visible: boolean;
|
|
25
|
-
disabled: boolean | import("
|
|
24
|
+
disabled: boolean | import("@element-plus-search/shared").PredicateCallback;
|
|
26
25
|
span: number;
|
|
27
26
|
initValue?: any;
|
|
28
|
-
enable: boolean | import("
|
|
27
|
+
enable: boolean | import("@element-plus-search/shared").PredicateCallback;
|
|
29
28
|
pinned: boolean;
|
|
30
29
|
tagFilter?: ((value: any) => boolean) | undefined;
|
|
31
|
-
render: import("
|
|
32
|
-
transform?: import("
|
|
33
|
-
onChange?: ((value: any, api: SearchBarState) => void) | undefined;
|
|
30
|
+
render: import("@element-plus-search/shared").SearchItemRender;
|
|
31
|
+
transform?: import("@element-plus-search/shared").TransformCallback<any> | undefined;
|
|
32
|
+
onChange?: ((value: any, api: import("../../shared/src/types/SearchBarState.js").SearchBarStateLike) => void) | undefined;
|
|
34
33
|
clean: () => void;
|
|
35
34
|
reset: () => void;
|
|
36
|
-
isEnable: (state: SearchBarState) => boolean;
|
|
37
|
-
isDisabled: (state: SearchBarState) => boolean;
|
|
35
|
+
isEnable: (state: import("../../shared/src/types/SearchBarState.js").SearchBarStateLike) => boolean;
|
|
36
|
+
isDisabled: (state: import("../../shared/src/types/SearchBarState.js").SearchBarStateLike) => boolean;
|
|
38
37
|
}[];
|
|
39
38
|
getSearchObject: () => any;
|
|
40
39
|
updateSearching: (searching: boolean) => void;
|
|
@@ -70,3 +69,4 @@ type __VLS_TypePropsToOption<T> = {
|
|
|
70
69
|
type __VLS_PrettifyLocal<T> = {
|
|
71
70
|
[K in keyof T]: T[K];
|
|
72
71
|
} & {};
|
|
72
|
+
//# sourceMappingURL=SearchBar.vue.d.ts.map
|