@xiaohaih/condition-core
Advanced tools
Comparing version 0.1.17 to 0.1.18
# @xiaohaih/condition-core | ||
## 0.1.18 | ||
### Patch Changes | ||
- 1.修复依赖发生变化时, 依赖项的请求函数未重新请求 2.下拉框增加分组 | ||
## 0.1.17 | ||
@@ -4,0 +10,0 @@ |
@@ -616,8 +616,8 @@ 'use strict'; | ||
if (!flag.value) return; | ||
if (checked.value === undefined || checked.value.toString() === '') return; | ||
if (val === oldVal) return; | ||
getOption('depend'); | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (checked.value === undefined || checked.value.toString() === '') return; | ||
updateCheckedValue(props.multiple ? [] : ''); | ||
getOption('depend'); | ||
})); | ||
@@ -813,6 +813,6 @@ unwatchs.push(vueDemi.watch(() => props.getOptions, getOption.bind(null, 'initial'), { | ||
if (!flag.value) return; | ||
if (checked.value.toString() === '') return; | ||
if (val === oldVal) return; | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (checked.value.toString() === '') return; | ||
checked.value = []; | ||
@@ -1003,5 +1003,5 @@ option.updateWrapperQuery(); | ||
if (!flag.value) return; | ||
if (val === oldVal) return; | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
updateCheckedValue(null); | ||
@@ -1169,8 +1169,8 @@ })); | ||
if (!flag.value) return; | ||
if (!checked.value.length) return; | ||
if (val === oldVal) return; | ||
getOption('depend'); | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (!checked.value.length) return; | ||
updateCheckedValue(typeof checked.value === 'string' ? '' : []); | ||
getOption('depend'); | ||
})); | ||
@@ -1177,0 +1177,0 @@ unwatchs.push(vueDemi.watch(() => props.getOptions, getOption.bind(null, 'initial'), { |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("vue-demi");function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},r.apply(this,arguments)}var a=["attrs","props","domProps"],i=["class","style","directives"],n=["on","nativeOn"],l=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},u=t((function(e){return e.reduce((function(e,t){for(var u in t)if(e[u])if(-1!==a.indexOf(u))e[u]=r({},e[u],t[u]);else if(-1!==i.indexOf(u)){var s=e[u]instanceof Array?e[u]:[e[u]],o=t[u]instanceof Array?t[u]:[t[u]];e[u]=[].concat(s,o)}else if(-1!==n.indexOf(u))for(var d in t[u])if(e[u][d]){var p=e[u][d]instanceof Array?e[u][d]:[e[u][d]],c=t[u][d]instanceof Array?t[u][d]:[t[u][d]];e[u][d]=[].concat(p,c)}else e[u][d]=t[u][d];else if("hook"===u)for(var f in t[u])e[u][f]=e[u][f]?l(e[u][f],t[u][f]):t[u][f];else e[u]=t[u];else e[u]=t[u];return e}),{})}));function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function o(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function d(e,t,r="children"){for(const a of e){if(t(a))return[a];if(a[r]?.length){const e=d(a[r],t);if(e.length)return e.unshift(a),e}}return[]}function p(e,t){return s(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const c="2.7"===e.version.slice(0,3),f=e.isVue2?"value":"modelValue",y={field:{type:String,required:!0},as:{type:String},emptyValue:{type:[String,null,void 0],default:void 0},resetToInitialValue:{type:[Boolean]},query:{type:Object,required:!0},backfill:{type:Object},disabled:{type:[Boolean,Function]},hide:{type:[Boolean,Function]},validator:{type:[Function]},defaultValue:{type:[String,Array,Function]},depend:{type:Boolean},dependFields:{type:[String,Array]}},h={tag:{type:[String,Object],default:"div"},resetToInitialValue:{type:Boolean},datum:{type:Object,default:()=>({})},backfill:{type:Object},realtime:{type:Boolean},immediateSearch:{type:Boolean},toast:{type:Function,default:()=>{}},searchAtDatumChanged:{type:Boolean}},v={...y,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},getOptions:{type:Function},filterMethod:{type:Function}},g={...y,inputNum:{type:Number,default:1,validator:e=>e>=1},fields:{type:Array},realtime:{type:Boolean},waitTime:{type:Number,default:300}},m={...y,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},b={...y,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},getOptions:{type:Function}},F={search:e=>!0},Q={...F,ready:e=>!0,reset:e=>!0},S={...F,blur:(...e)=>!0},V={...F,triggerSearch:()=>!0},k={...F},O={...F},q="condition-wrapper";var w=e.defineComponent({name:"CoreWrapper",props:h,emits:Q,setup(t,r){const a=[];e.onBeforeUnmount((()=>a.splice(0)));let i=!1,n=[];const l={realtime:e.toRef(t,"realtime"),register:r=>{a.push(r);const s=()=>{i=!0,r.reset().updateWrapperQuery();const s=a.indexOf(r);-1!==s&&a.splice(s,1),t.searchAtDatumChanged&&l.search(),i=!1,n.forEach((t=>e.del(u.value,t))),n=[]},o=e.getCurrentInstance();return o&&e.onBeforeUnmount(s,c?o.proxy:o),s},updateQueryValue:(t,r)=>(i&&n.push(t),e.set(u.value,t,r),l),insetSearch:()=>(t.realtime&&l.search(),l),search:o,removeUnreferencedField(t){let r=0;return a.some((e=>(e.getQuery().hasOwnProperty(t)&&(r+=1),r))),r||e.del(u.value,t),l}};e.provide(q,l);const u=e.ref({}),s=()=>({...t.backfill,...u.value});async function o(){const e=(await Promise.all(a.map((e=>e.validator?.(u.value))))).find((e=>e&&"string"==typeof e));if(e?t.toast(e):r.emit("search",s()),e)return e}function d(){a.forEach((e=>{e.reset().updateWrapperQuery()})),r.emit("reset",s())}return e.onMounted((()=>{t.immediateSearch&&r.emit("ready",s())})),{child:a,wrapperInstance:l,query:u,getQuery:s,querySearch:o,resetAndSearch:function(){d(),o()},reset:d}},render(){const{resetToInitialValue:t,backfill:r,query:a,getQuery:i,querySearch:n,resetAndSearch:l,reset:o}=this,d=this.tag,c=this.datum,f=p("default",this),y=p("btn",this),{class:h,style:v,...g}=this.$attrs,m=(e.isVue2,{});return s(this,"$listeners")&&(m.on=this.$listeners),e.h(d,u([{},m]),[Object.entries(c).map((([e,i])=>i?"function"==typeof f?f({...g,key:e,field:i.as||e,resetToInitialValue:t,backfill:r,query:a,...i}):f||"":void 0)),"function"==typeof y?y({search:n,getQuery:i,resetAndSearch:l,reset:o}):y])}});function W(t){const r=e.ref();return e.computed({set(e){r.value=e},get:()=>void 0===r.value?void 0!==t.defaultValue?"function"==typeof t.defaultValue?t.defaultValue(t.query,t.backfill):t.defaultValue:void 0:r.value})}function C(t,r){const a=e.ref("boolean"==typeof t.disabled&&t.disabled),i=e.ref("boolean"==typeof t.hide&&t.hide);return e.onBeforeUnmount(e.watch((()=>t.query),(()=>{if("function"==typeof t.hide){i.value!==t.hide(t.query)&&(i.value=t.hide(t.query),i.value&&r.reset().updateWrapperQuery())}else if("function"==typeof t.disabled){a.value!==t.disabled(t.query)&&(a.value=t.disabled(t.query))}}),{immediate:!0,deep:!0})),{insetDisabled:a,insetHide:i}}function A(t=!0){const r=e.ref(t);return{flag:r,updateFlag:()=>{r.value=!t,e.nextTick((()=>{r.value=t}))}}}var j=e.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:v,setup(t,r){const a=e.inject(q),i=W(t),n=t.backfill&&t.backfill[t.field],l=e.ref(n||(void 0!==t.defaultValue?i.value:t.multiple?[]:"").slice()),{flag:u,updateFlag:s}=A(),d=()=>({[t.field]:o(l.value,t.emptyValue)}),p={reset:O,updateWrapperQuery:()=>(a?.updateQueryValue(t.field,o(l.value,t.emptyValue)),p),get validator(){return t.validator},getQuery:d};a?.register(p);const{insetDisabled:c,insetHide:f}=C(t,p);!n&&t.defaultValue&&p.updateWrapperQuery();const y=e.ref([]),h=e.computed((()=>y.value.length?y.value:t.options)),v=e.ref(!1),g=e.ref([]),m=e.computed((()=>v.value?g.value:h.value)),b=e.computed((()=>t.filterMethod&&S)),F=[];function Q(e){t.getOptions?.((e=>{const t=l.value;l.value=void 0,y.value=e||[],l.value=t}),t.query||{},{trigger:e,change:(e,t)=>{t&&(i.value=e),k(e)},search:(e,t)=>{t&&(i.value=e),V(e),a?.search()}})}function S(e){const{filterMethod:r}=t;""===e||void 0===e?(v.value=!1,g.value=[]):(v.value=!0,g.value=h.value.filter((t=>r(e,t))))}function V(e){e!==l.value&&(l.value=e,p.updateWrapperQuery())}function k(e){V(e),a?.insetSearch()}function O(){const{multiple:e}=t;return s(),l.value=t.resetToInitialValue&&i.value?.slice()||(e?[]:""),p}return e.onBeforeUnmount((()=>F.forEach((e=>e())))),F.push(e.watch((()=>t.field),((e,t)=>{e!==t&&a?.removeUnreferencedField(t),p.updateWrapperQuery()}))),F.push(e.watch((()=>[t.field,t.query[t.field]]),(([e,t],[r])=>{e===r&&t!==l.value&&(l.value=t)}))),F.push(e.watch((()=>[t.field,t.backfill?.[t.field]]),(([e,r],[a])=>{(e===a||t.backfill?.hasOwnProperty(e))&&(s(),V(r))}))),F.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,r,a],[i,n,s])=>{u.value&&void 0!==l.value&&""!==l.value.toString()&&e===i&&r?.toString()===n?.toString()&&a!==s&&(V(t.multiple?[]:""),Q("depend"))}))),F.push(e.watch((()=>t.getOptions),Q.bind(null,"initial"),{immediate:!0})),{checked:l,getQuery:d,insetDisabled:c,insetHide:f,finalOption:m,customFilterMethod:b,blur:function(){t.filterMethod&&S("")},updateCheckedValue:V,change:k,reset:O}},render(){const{checked:e,getQuery:t,insetDisabled:r,insetHide:a,finalOption:i,blur:n,customFilterMethod:l,change:u,reset:o,valueKey:d,labelKey:c,multiple:y}=this;if(a)return;const h=p("default",this),v=s(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof h?h({...this.$attrs,listeners:v,[f]:e,options:i,disabled:r,blur:n,filterMethod:l,change:u,valueKey:d,labelKey:c,multiple:y}):h}}),x=e.defineComponent({name:"CoreInput",props:g,setup(t,r){const a=e.inject(q),i=W(t),n=t.backfill&&t.backfill[t.field],l=e.ref([].concat(n||i.value||"")),{flag:u,updateFlag:s}=A(),d=()=>t.inputNum>1&&t.fields?t.fields.reduce(((e,r,a)=>(e[r]=o(l.value[a],t.emptyValue),e)),{}):{[t.field]:o(t.inputNum>1?l.value:l.value[0],t.emptyValue)},p={reset:v,updateWrapperQuery:()=>(a&&Object.entries(d()).forEach((([e,t])=>a.updateQueryValue(e,t))),p),get validator(){return t.validator},getQuery:d};a?.register(p);const{insetDisabled:c,insetHide:f}=C(t,p);!n&&t.defaultValue&&p.updateWrapperQuery();const y=[];e.onBeforeUnmount((()=>y.forEach((e=>e())))),y.push(e.watch((()=>t.inputNum>1&&t.fields?.length?t.fields:[t.field]),((e,t)=>{e.toString()!==t.toString()&&a&&t.forEach((e=>a.removeUnreferencedField(e))),p.updateWrapperQuery()}))),y.push(e.watch((()=>t.inputNum>1&&t.fields?.length?[t.fields,t.fields.map((e=>t.query[e]))]:[t.field,[t.query[t.field]]]),(([e,t],[r])=>{e.toString()===r.toString()&&t.toString()!==l.value.toString()&&(l.value=t)}))),y.push(e.watch((()=>t.inputNum>1&&t.fields?.length?t.fields.map((e=>t.backfill?.[e])):[t.backfill?.[t.field]]),(e=>{e.toString()!==l.value.toString()&&(s(),l.value=e,p.updateWrapperQuery())}))),y.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,t,r],[a,i,n])=>{u.value&&""!==l.value.toString()&&e===a&&t?.toString()===i?.toString()&&r!==n&&(l.value=[],p.updateWrapperQuery())})));let h=0;function v(){return s(),l.value=[].concat(t.resetToInitialValue&&i.value||""),p}return{checked:l,getQuery:d,insetDisabled:c,insetHide:f,debounceChange:function(r,i){const{realtime:n,waitTime:u}=t;e.set(l.value,i,r),l.value[i]=r,h&&clearTimeout(h),n||!a?.realtime.value?(p.updateWrapperQuery(),a?.insetSearch()):h=setTimeout((()=>(p.updateWrapperQuery(),a?.insetSearch())),u)},enterHandler:function(t,r){e.set(l.value,r,"string"==typeof t?t:t.target?.value||""),p.updateWrapperQuery(),a?.search()},reset:v}},render(){const{query:e,checked:t,getQuery:r,insetDisabled:a,insetHide:i,debounceChange:n,enterHandler:l,reset:u}=this;if(i)return;const o=p("default",this),d=s(this,"$listeners")?this.$listeners:null;return"function"==typeof o?o({...this.$attrs,listeners:d,[f]:t,disabled:a,debounceChange:n,enterHandler:l}):o}}),B=e.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:m,setup(t,r){const a=e.inject(q),i=W(t),n=t.backfill&&(t.range&&t.beginField&&t.endField?["",""]:t.backfill[t.field]),l=n&&("string"==typeof n?n:n.join("")),u=e.ref((l&&n||i.value||l||"").slice()),{flag:s,updateFlag:d}=A(),p=()=>t.range&&t.beginField&&t.endField?{[t.beginField]:o(u.value[0],t.emptyValue),[t.endField]:o(u.value[1],t.emptyValue)}:{[t.field]:Array.isArray(u.value)?[...u.value]:o(u.value,t.emptyValue)},c={reset:g,updateWrapperQuery(){const{range:e,field:r,beginField:i,endField:n}=t;return e&&i&&n?(a?.updateQueryValue(i,o(u.value[0],t.emptyValue)),a?.updateQueryValue(n,o(u.value[1],t.emptyValue))):a?.updateQueryValue(r,o(u.value,t.emptyValue)),c},get validator(){return t.validator},getQuery:p};a?.register(c);const{insetDisabled:f,insetHide:y}=C(t,c);!l&&t.defaultValue&&c.updateWrapperQuery();const h=[];function v(e){const{range:r}=t;u.value=null===e?r?["",""]:"":e,c.updateWrapperQuery()}function g(){const{range:e}=t;return d(),u.value=t.resetToInitialValue&&i.value?.slice()||(e?["",""]:""),c}return e.onBeforeUnmount((()=>h.forEach((e=>e())))),h.push(e.watch((()=>t.field),((e,t)=>{e!==t&&a?.removeUnreferencedField(t),c.updateWrapperQuery()}))),h.push(e.watch((()=>t.range&&t.beginField&&t.endField?[!0,[t.beginField,t.query[t.beginField]],[t.endField,t.query[t.endField]]]:[!1,[t.field,t.query[t.field]]]),(([e,...t],[r,...a])=>{t.some(((e,t)=>e[0]!==a[t][0]))||(e?("string"==typeof u.value&&(u.value=[]),t.forEach(((e,t)=>{u.value[t]!==e[1]&&e[1]!==a[t][1]&&(u.value[t]=e[1]||"")}))):u.value!==t[0][1]&&t[0][1]!==a[0][1]&&(u.value=t[0][1]||""))}))),h.push(e.watch((()=>t.range&&t.beginField&&t.endField?[!0,t.backfill?.[t.beginField],t.backfill?.[t.endField]]:[!1,t.backfill?.[t.field]]),(([e,...r],[a,...i])=>{if(e){let e=!1;r.forEach(((t,r)=>{t!==i[r]&&(d(),"string"==typeof u.value&&(u.value=[]),u.value.splice(r,1),t&&u.value.splice(r,0,t),e=!0)})),e&&c.updateWrapperQuery()}else{if(r[0]===i[0])return;d(),u.value=o(r[0],t.emptyValue),c.updateWrapperQuery()}}))),h.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,t,r],[a,i,n])=>{s.value&&e===a&&t?.toString()===i?.toString()&&r!==n&&v(null)}))),{checked:u,getQuery:p,insetDisabled:f,insetHide:y,updateCheckedValue:v,change:function(e){v(e),a?.insetSearch()},reset:g}},render(){const{checked:e,getQuery:t,insetHide:r,insetDisabled:a,updateCheckedValue:i,change:n,reset:l}=this;if(r)return;const u=p("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,listeners:o,[f]:e,disabled:a,updateCheckedValue:i,change:n}):u}}),E=e.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:b,setup(t,r){const a=e.inject(q),i=W(t),n=e.ref([]),l=e.ref([]),u=e.computed((()=>l.value.length?l.value:t.options)),s=()=>g.value||i.value?t.fields?.length?t.fields.reduce(((e,t,r)=>Object.assign(e,{[t]:n.value[r]})),{}):{[t.field]:t.emitPath?[...n.value]:n.value.slice(-1)[0]}:{},{flag:p,updateFlag:c}=A(),f={reset:Q,get validator(){return t.validator},updateWrapperQuery(){const{field:e,fields:r,emitPath:i}=t;return r?.length?r.forEach(((e,r)=>{a?.updateQueryValue(e,o(n.value[r],t.emptyValue))})):a?.updateQueryValue(e,o(i?[...n.value]:n.value.slice(-1)[0],t.emptyValue)),f},getQuery:s};a?.register(f);const{insetDisabled:y,insetHide:h}=C(t,f),v=[];e.onBeforeUnmount((()=>v.forEach((e=>e()))));const g=e.ref("function"!=typeof t.getOptions||!!t.fields?.length);function m(e){t.getOptions?.((e=>{l.value=e||[],g.value=!0}),t.query||{},{trigger:e,change:(e,t)=>{t&&(i.value=e),F(e)},search:(e,t)=>{t&&(i.value=e),b(e),a?.search()}})}function b(e){const t=Array.isArray(e)?e:S(e);t.join("")!==n.value.join("")&&(n.value=t,f.updateWrapperQuery())}function F(e){b(e),a?.insetSearch()}function Q(){return c(),n.value=t.resetToInitialValue&&i.value?.slice()||[],f}function S(e){if(!e&&0!==e)return[];const{valueKey:r,childrenKey:a}=t;return d(u.value,(t=>t[r]===e)).map((e=>e[r]),a)}return e.watch(g,(e=>e&&function(){const{backfill:e,field:r,fields:a}=t;if(e)if(a){const t=a.reduce(((t,r)=>(e[r]&&t.push(e[r]),t)),[]);if(t.length)return n.value=t,void f.updateWrapperQuery()}else if(e[r])return n.value=S(e[r]),void f.updateWrapperQuery();i.value?.length&&(n.value="string"==typeof i.value?S(i.value):i.value.slice(),"string"==typeof i.value&&(i.value=n.value.slice()),f.updateWrapperQuery())}()),{immediate:!0}),v.push(e.watch((()=>t.fields||[t.field]),((e,t)=>{e.toString()!==t.toString()&&a&&t.forEach((t=>e.includes(t)||a.removeUnreferencedField(t))),f.updateWrapperQuery()}))),v.push(e.watch((()=>[t.fields?.toString()||t.field,t.fields?.map((e=>t.query[e]))||t.field]),(([e,t],[r])=>{e===r&&(n.value="string"==typeof t?S(t):t)}))),v.push(e.watch((()=>t.fields?.length?t.fields.reduce(((e,r)=>(t.backfill?.[r]&&e.push(t.backfill[r]),e)),[]):t.backfill?.[t.field]),(e=>{if(g.value)if(c(),Array.isArray(e))b(e);else{if(!e&&0!==e)return void(n.value.length&&(n.value=[]));b(S(e))}}))),v.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,t,r],[a,i,l])=>{p.value&&n.value.length&&e===a&&t?.toString()===i?.toString()&&r!==l&&(b("string"==typeof n.value?"":[]),m("depend"))}))),v.push(e.watch((()=>t.getOptions),m.bind(null,"initial"),{immediate:!0})),{checked:n,getQuery:s,finalOption:u,insetDisabled:y,insetHide:h,change:F,reset:Q}},render(){const{checked:e,getQuery:t,finalOption:r,insetHide:a,insetDisabled:i,change:n,reset:l}=this;if(a)return;const u=p("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,options:r,listeners:o,[f]:e,disabled:i,change:n}):u}});exports.CoreCascader=E,exports.CoreDatepicker=B,exports.CoreInput=x,exports.CoreSelect=j,exports.CoreWrapper=w,exports.cascaderEmits=O,exports.cascaderProps=b,exports.commonEmits=F,exports.commonProps=y,exports.datepickerEmits=k,exports.datepickerProps=m,exports.inputEmits=V,exports.inputProps=g,exports.provideKey=q,exports.selectEmits=S,exports.selectProps=v,exports.wrapperEmits=Q,exports.wrapperProps=h; | ||
"use strict";var e=require("vue-demi");function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},r.apply(this,arguments)}var a=["attrs","props","domProps"],i=["class","style","directives"],n=["on","nativeOn"],l=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},u=t((function(e){return e.reduce((function(e,t){for(var u in t)if(e[u])if(-1!==a.indexOf(u))e[u]=r({},e[u],t[u]);else if(-1!==i.indexOf(u)){var s=e[u]instanceof Array?e[u]:[e[u]],o=t[u]instanceof Array?t[u]:[t[u]];e[u]=[].concat(s,o)}else if(-1!==n.indexOf(u))for(var d in t[u])if(e[u][d]){var p=e[u][d]instanceof Array?e[u][d]:[e[u][d]],c=t[u][d]instanceof Array?t[u][d]:[t[u][d]];e[u][d]=[].concat(p,c)}else e[u][d]=t[u][d];else if("hook"===u)for(var f in t[u])e[u][f]=e[u][f]?l(e[u][f],t[u][f]):t[u][f];else e[u]=t[u];else e[u]=t[u];return e}),{})}));function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function o(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function d(e,t,r="children"){for(const a of e){if(t(a))return[a];if(a[r]?.length){const e=d(a[r],t);if(e.length)return e.unshift(a),e}}return[]}function p(e,t){return s(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const c="2.7"===e.version.slice(0,3),f=e.isVue2?"value":"modelValue",y={field:{type:String,required:!0},as:{type:String},emptyValue:{type:[String,null,void 0],default:void 0},resetToInitialValue:{type:[Boolean]},query:{type:Object,required:!0},backfill:{type:Object},disabled:{type:[Boolean,Function]},hide:{type:[Boolean,Function]},validator:{type:[Function]},defaultValue:{type:[String,Array,Function]},depend:{type:Boolean},dependFields:{type:[String,Array]}},h={tag:{type:[String,Object],default:"div"},resetToInitialValue:{type:Boolean},datum:{type:Object,default:()=>({})},backfill:{type:Object},realtime:{type:Boolean},immediateSearch:{type:Boolean},toast:{type:Function,default:()=>{}},searchAtDatumChanged:{type:Boolean}},v={...y,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},getOptions:{type:Function},filterMethod:{type:Function}},g={...y,inputNum:{type:Number,default:1,validator:e=>e>=1},fields:{type:Array},realtime:{type:Boolean},waitTime:{type:Number,default:300}},m={...y,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},b={...y,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},getOptions:{type:Function}},F={search:e=>!0},Q={...F,ready:e=>!0,reset:e=>!0},S={...F,blur:(...e)=>!0},V={...F,triggerSearch:()=>!0},k={...F},O={...F},q="condition-wrapper";var w=e.defineComponent({name:"CoreWrapper",props:h,emits:Q,setup(t,r){const a=[];e.onBeforeUnmount((()=>a.splice(0)));let i=!1,n=[];const l={realtime:e.toRef(t,"realtime"),register:r=>{a.push(r);const s=()=>{i=!0,r.reset().updateWrapperQuery();const s=a.indexOf(r);-1!==s&&a.splice(s,1),t.searchAtDatumChanged&&l.search(),i=!1,n.forEach((t=>e.del(u.value,t))),n=[]},o=e.getCurrentInstance();return o&&e.onBeforeUnmount(s,c?o.proxy:o),s},updateQueryValue:(t,r)=>(i&&n.push(t),e.set(u.value,t,r),l),insetSearch:()=>(t.realtime&&l.search(),l),search:o,removeUnreferencedField(t){let r=0;return a.some((e=>(e.getQuery().hasOwnProperty(t)&&(r+=1),r))),r||e.del(u.value,t),l}};e.provide(q,l);const u=e.ref({}),s=()=>({...t.backfill,...u.value});async function o(){const e=(await Promise.all(a.map((e=>e.validator?.(u.value))))).find((e=>e&&"string"==typeof e));if(e?t.toast(e):r.emit("search",s()),e)return e}function d(){a.forEach((e=>{e.reset().updateWrapperQuery()})),r.emit("reset",s())}return e.onMounted((()=>{t.immediateSearch&&r.emit("ready",s())})),{child:a,wrapperInstance:l,query:u,getQuery:s,querySearch:o,resetAndSearch:function(){d(),o()},reset:d}},render(){const{resetToInitialValue:t,backfill:r,query:a,getQuery:i,querySearch:n,resetAndSearch:l,reset:o}=this,d=this.tag,c=this.datum,f=p("default",this),y=p("btn",this),{class:h,style:v,...g}=this.$attrs,m=(e.isVue2,{});return s(this,"$listeners")&&(m.on=this.$listeners),e.h(d,u([{},m]),[Object.entries(c).map((([e,i])=>i?"function"==typeof f?f({...g,key:e,field:i.as||e,resetToInitialValue:t,backfill:r,query:a,...i}):f||"":void 0)),"function"==typeof y?y({search:n,getQuery:i,resetAndSearch:l,reset:o}):y])}});function W(t){const r=e.ref();return e.computed({set(e){r.value=e},get:()=>void 0===r.value?void 0!==t.defaultValue?"function"==typeof t.defaultValue?t.defaultValue(t.query,t.backfill):t.defaultValue:void 0:r.value})}function C(t,r){const a=e.ref("boolean"==typeof t.disabled&&t.disabled),i=e.ref("boolean"==typeof t.hide&&t.hide);return e.onBeforeUnmount(e.watch((()=>t.query),(()=>{if("function"==typeof t.hide){i.value!==t.hide(t.query)&&(i.value=t.hide(t.query),i.value&&r.reset().updateWrapperQuery())}else if("function"==typeof t.disabled){a.value!==t.disabled(t.query)&&(a.value=t.disabled(t.query))}}),{immediate:!0,deep:!0})),{insetDisabled:a,insetHide:i}}function A(t=!0){const r=e.ref(t);return{flag:r,updateFlag:()=>{r.value=!t,e.nextTick((()=>{r.value=t}))}}}var j=e.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:v,setup(t,r){const a=e.inject(q),i=W(t),n=t.backfill&&t.backfill[t.field],l=e.ref(n||(void 0!==t.defaultValue?i.value:t.multiple?[]:"").slice()),{flag:u,updateFlag:s}=A(),d=()=>({[t.field]:o(l.value,t.emptyValue)}),p={reset:O,updateWrapperQuery:()=>(a?.updateQueryValue(t.field,o(l.value,t.emptyValue)),p),get validator(){return t.validator},getQuery:d};a?.register(p);const{insetDisabled:c,insetHide:f}=C(t,p);!n&&t.defaultValue&&p.updateWrapperQuery();const y=e.ref([]),h=e.computed((()=>y.value.length?y.value:t.options)),v=e.ref(!1),g=e.ref([]),m=e.computed((()=>v.value?g.value:h.value)),b=e.computed((()=>t.filterMethod&&S)),F=[];function Q(e){t.getOptions?.((e=>{const t=l.value;l.value=void 0,y.value=e||[],l.value=t}),t.query||{},{trigger:e,change:(e,t)=>{t&&(i.value=e),k(e)},search:(e,t)=>{t&&(i.value=e),V(e),a?.search()}})}function S(e){const{filterMethod:r}=t;""===e||void 0===e?(v.value=!1,g.value=[]):(v.value=!0,g.value=h.value.filter((t=>r(e,t))))}function V(e){e!==l.value&&(l.value=e,p.updateWrapperQuery())}function k(e){V(e),a?.insetSearch()}function O(){const{multiple:e}=t;return s(),l.value=t.resetToInitialValue&&i.value?.slice()||(e?[]:""),p}return e.onBeforeUnmount((()=>F.forEach((e=>e())))),F.push(e.watch((()=>t.field),((e,t)=>{e!==t&&a?.removeUnreferencedField(t),p.updateWrapperQuery()}))),F.push(e.watch((()=>[t.field,t.query[t.field]]),(([e,t],[r])=>{e===r&&t!==l.value&&(l.value=t)}))),F.push(e.watch((()=>[t.field,t.backfill?.[t.field]]),(([e,r],[a])=>{(e===a||t.backfill?.hasOwnProperty(e))&&(s(),V(r))}))),F.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,r,a],[i,n,s])=>{u.value&&a!==s&&(Q("depend"),e===i&&r?.toString()===n?.toString()&&void 0!==l.value&&""!==l.value.toString()&&V(t.multiple?[]:""))}))),F.push(e.watch((()=>t.getOptions),Q.bind(null,"initial"),{immediate:!0})),{checked:l,getQuery:d,insetDisabled:c,insetHide:f,finalOption:m,customFilterMethod:b,blur:function(){t.filterMethod&&S("")},updateCheckedValue:V,change:k,reset:O}},render(){const{checked:e,getQuery:t,insetDisabled:r,insetHide:a,finalOption:i,blur:n,customFilterMethod:l,change:u,reset:o,valueKey:d,labelKey:c,multiple:y}=this;if(a)return;const h=p("default",this),v=s(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof h?h({...this.$attrs,listeners:v,[f]:e,options:i,disabled:r,blur:n,filterMethod:l,change:u,valueKey:d,labelKey:c,multiple:y}):h}}),x=e.defineComponent({name:"CoreInput",props:g,setup(t,r){const a=e.inject(q),i=W(t),n=t.backfill&&t.backfill[t.field],l=e.ref([].concat(n||i.value||"")),{flag:u,updateFlag:s}=A(),d=()=>t.inputNum>1&&t.fields?t.fields.reduce(((e,r,a)=>(e[r]=o(l.value[a],t.emptyValue),e)),{}):{[t.field]:o(t.inputNum>1?l.value:l.value[0],t.emptyValue)},p={reset:v,updateWrapperQuery:()=>(a&&Object.entries(d()).forEach((([e,t])=>a.updateQueryValue(e,t))),p),get validator(){return t.validator},getQuery:d};a?.register(p);const{insetDisabled:c,insetHide:f}=C(t,p);!n&&t.defaultValue&&p.updateWrapperQuery();const y=[];e.onBeforeUnmount((()=>y.forEach((e=>e())))),y.push(e.watch((()=>t.inputNum>1&&t.fields?.length?t.fields:[t.field]),((e,t)=>{e.toString()!==t.toString()&&a&&t.forEach((e=>a.removeUnreferencedField(e))),p.updateWrapperQuery()}))),y.push(e.watch((()=>t.inputNum>1&&t.fields?.length?[t.fields,t.fields.map((e=>t.query[e]))]:[t.field,[t.query[t.field]]]),(([e,t],[r])=>{e.toString()===r.toString()&&t.toString()!==l.value.toString()&&(l.value=t)}))),y.push(e.watch((()=>t.inputNum>1&&t.fields?.length?t.fields.map((e=>t.backfill?.[e])):[t.backfill?.[t.field]]),(e=>{e.toString()!==l.value.toString()&&(s(),l.value=e,p.updateWrapperQuery())}))),y.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,t,r],[a,i,n])=>{u.value&&r!==n&&e===a&&t?.toString()===i?.toString()&&""!==l.value.toString()&&(l.value=[],p.updateWrapperQuery())})));let h=0;function v(){return s(),l.value=[].concat(t.resetToInitialValue&&i.value||""),p}return{checked:l,getQuery:d,insetDisabled:c,insetHide:f,debounceChange:function(r,i){const{realtime:n,waitTime:u}=t;e.set(l.value,i,r),l.value[i]=r,h&&clearTimeout(h),n||!a?.realtime.value?(p.updateWrapperQuery(),a?.insetSearch()):h=setTimeout((()=>(p.updateWrapperQuery(),a?.insetSearch())),u)},enterHandler:function(t,r){e.set(l.value,r,"string"==typeof t?t:t.target?.value||""),p.updateWrapperQuery(),a?.search()},reset:v}},render(){const{query:e,checked:t,getQuery:r,insetDisabled:a,insetHide:i,debounceChange:n,enterHandler:l,reset:u}=this;if(i)return;const o=p("default",this),d=s(this,"$listeners")?this.$listeners:null;return"function"==typeof o?o({...this.$attrs,listeners:d,[f]:t,disabled:a,debounceChange:n,enterHandler:l}):o}}),B=e.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:m,setup(t,r){const a=e.inject(q),i=W(t),n=t.backfill&&(t.range&&t.beginField&&t.endField?["",""]:t.backfill[t.field]),l=n&&("string"==typeof n?n:n.join("")),u=e.ref((l&&n||i.value||l||"").slice()),{flag:s,updateFlag:d}=A(),p=()=>t.range&&t.beginField&&t.endField?{[t.beginField]:o(u.value[0],t.emptyValue),[t.endField]:o(u.value[1],t.emptyValue)}:{[t.field]:Array.isArray(u.value)?[...u.value]:o(u.value,t.emptyValue)},c={reset:g,updateWrapperQuery(){const{range:e,field:r,beginField:i,endField:n}=t;return e&&i&&n?(a?.updateQueryValue(i,o(u.value[0],t.emptyValue)),a?.updateQueryValue(n,o(u.value[1],t.emptyValue))):a?.updateQueryValue(r,o(u.value,t.emptyValue)),c},get validator(){return t.validator},getQuery:p};a?.register(c);const{insetDisabled:f,insetHide:y}=C(t,c);!l&&t.defaultValue&&c.updateWrapperQuery();const h=[];function v(e){const{range:r}=t;u.value=null===e?r?["",""]:"":e,c.updateWrapperQuery()}function g(){const{range:e}=t;return d(),u.value=t.resetToInitialValue&&i.value?.slice()||(e?["",""]:""),c}return e.onBeforeUnmount((()=>h.forEach((e=>e())))),h.push(e.watch((()=>t.field),((e,t)=>{e!==t&&a?.removeUnreferencedField(t),c.updateWrapperQuery()}))),h.push(e.watch((()=>t.range&&t.beginField&&t.endField?[!0,[t.beginField,t.query[t.beginField]],[t.endField,t.query[t.endField]]]:[!1,[t.field,t.query[t.field]]]),(([e,...t],[r,...a])=>{t.some(((e,t)=>e[0]!==a[t][0]))||(e?("string"==typeof u.value&&(u.value=[]),t.forEach(((e,t)=>{u.value[t]!==e[1]&&e[1]!==a[t][1]&&(u.value[t]=e[1]||"")}))):u.value!==t[0][1]&&t[0][1]!==a[0][1]&&(u.value=t[0][1]||""))}))),h.push(e.watch((()=>t.range&&t.beginField&&t.endField?[!0,t.backfill?.[t.beginField],t.backfill?.[t.endField]]:[!1,t.backfill?.[t.field]]),(([e,...r],[a,...i])=>{if(e){let e=!1;r.forEach(((t,r)=>{t!==i[r]&&(d(),"string"==typeof u.value&&(u.value=[]),u.value.splice(r,1),t&&u.value.splice(r,0,t),e=!0)})),e&&c.updateWrapperQuery()}else{if(r[0]===i[0])return;d(),u.value=o(r[0],t.emptyValue),c.updateWrapperQuery()}}))),h.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,t,r],[a,i,n])=>{s.value&&r!==n&&e===a&&t?.toString()===i?.toString()&&v(null)}))),{checked:u,getQuery:p,insetDisabled:f,insetHide:y,updateCheckedValue:v,change:function(e){v(e),a?.insetSearch()},reset:g}},render(){const{checked:e,getQuery:t,insetHide:r,insetDisabled:a,updateCheckedValue:i,change:n,reset:l}=this;if(r)return;const u=p("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,listeners:o,[f]:e,disabled:a,updateCheckedValue:i,change:n}):u}}),E=e.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:b,setup(t,r){const a=e.inject(q),i=W(t),n=e.ref([]),l=e.ref([]),u=e.computed((()=>l.value.length?l.value:t.options)),s=()=>g.value||i.value?t.fields?.length?t.fields.reduce(((e,t,r)=>Object.assign(e,{[t]:n.value[r]})),{}):{[t.field]:t.emitPath?[...n.value]:n.value.slice(-1)[0]}:{},{flag:p,updateFlag:c}=A(),f={reset:Q,get validator(){return t.validator},updateWrapperQuery(){const{field:e,fields:r,emitPath:i}=t;return r?.length?r.forEach(((e,r)=>{a?.updateQueryValue(e,o(n.value[r],t.emptyValue))})):a?.updateQueryValue(e,o(i?[...n.value]:n.value.slice(-1)[0],t.emptyValue)),f},getQuery:s};a?.register(f);const{insetDisabled:y,insetHide:h}=C(t,f),v=[];e.onBeforeUnmount((()=>v.forEach((e=>e()))));const g=e.ref("function"!=typeof t.getOptions||!!t.fields?.length);function m(e){t.getOptions?.((e=>{l.value=e||[],g.value=!0}),t.query||{},{trigger:e,change:(e,t)=>{t&&(i.value=e),F(e)},search:(e,t)=>{t&&(i.value=e),b(e),a?.search()}})}function b(e){const t=Array.isArray(e)?e:S(e);t.join("")!==n.value.join("")&&(n.value=t,f.updateWrapperQuery())}function F(e){b(e),a?.insetSearch()}function Q(){return c(),n.value=t.resetToInitialValue&&i.value?.slice()||[],f}function S(e){if(!e&&0!==e)return[];const{valueKey:r,childrenKey:a}=t;return d(u.value,(t=>t[r]===e)).map((e=>e[r]),a)}return e.watch(g,(e=>e&&function(){const{backfill:e,field:r,fields:a}=t;if(e)if(a){const t=a.reduce(((t,r)=>(e[r]&&t.push(e[r]),t)),[]);if(t.length)return n.value=t,void f.updateWrapperQuery()}else if(e[r])return n.value=S(e[r]),void f.updateWrapperQuery();i.value?.length&&(n.value="string"==typeof i.value?S(i.value):i.value.slice(),"string"==typeof i.value&&(i.value=n.value.slice()),f.updateWrapperQuery())}()),{immediate:!0}),v.push(e.watch((()=>t.fields||[t.field]),((e,t)=>{e.toString()!==t.toString()&&a&&t.forEach((t=>e.includes(t)||a.removeUnreferencedField(t))),f.updateWrapperQuery()}))),v.push(e.watch((()=>[t.fields?.toString()||t.field,t.fields?.map((e=>t.query[e]))||t.field]),(([e,t],[r])=>{e===r&&(n.value="string"==typeof t?S(t):t)}))),v.push(e.watch((()=>t.fields?.length?t.fields.reduce(((e,r)=>(t.backfill?.[r]&&e.push(t.backfill[r]),e)),[]):t.backfill?.[t.field]),(e=>{if(g.value)if(c(),Array.isArray(e))b(e);else{if(!e&&0!==e)return void(n.value.length&&(n.value=[]));b(S(e))}}))),v.push(e.watch((()=>[t.depend,t.dependFields,t.dependFields&&[].concat(t.dependFields).map((e=>t.query?.[e])).join(",")||""]),(([e,t,r],[a,i,l])=>{p.value&&r!==l&&(m("depend"),e===a&&t?.toString()===i?.toString()&&n.value.length&&b("string"==typeof n.value?"":[]))}))),v.push(e.watch((()=>t.getOptions),m.bind(null,"initial"),{immediate:!0})),{checked:n,getQuery:s,finalOption:u,insetDisabled:y,insetHide:h,change:F,reset:Q}},render(){const{checked:e,getQuery:t,finalOption:r,insetHide:a,insetDisabled:i,change:n,reset:l}=this;if(a)return;const u=p("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,options:r,listeners:o,[f]:e,disabled:i,change:n}):u}});exports.CoreCascader=E,exports.CoreDatepicker=B,exports.CoreInput=x,exports.CoreSelect=j,exports.CoreWrapper=w,exports.cascaderEmits=O,exports.cascaderProps=b,exports.commonEmits=F,exports.commonProps=y,exports.datepickerEmits=k,exports.datepickerProps=m,exports.inputEmits=V,exports.inputProps=g,exports.provideKey=q,exports.selectEmits=S,exports.selectProps=v,exports.wrapperEmits=Q,exports.wrapperProps=h; | ||
//# sourceMappingURL=index.cjs.min.js.map |
@@ -614,8 +614,8 @@ import { version, isVue2, defineComponent, onBeforeUnmount, toRef, getCurrentInstance, set, del, provide, ref, onMounted, h, computed, watch, nextTick, inject } from 'vue-demi'; | ||
if (!flag.value) return; | ||
if (checked.value === undefined || checked.value.toString() === '') return; | ||
if (val === oldVal) return; | ||
getOption('depend'); | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (checked.value === undefined || checked.value.toString() === '') return; | ||
updateCheckedValue(props.multiple ? [] : ''); | ||
getOption('depend'); | ||
})); | ||
@@ -811,6 +811,6 @@ unwatchs.push(watch(() => props.getOptions, getOption.bind(null, 'initial'), { | ||
if (!flag.value) return; | ||
if (checked.value.toString() === '') return; | ||
if (val === oldVal) return; | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (checked.value.toString() === '') return; | ||
checked.value = []; | ||
@@ -1001,5 +1001,5 @@ option.updateWrapperQuery(); | ||
if (!flag.value) return; | ||
if (val === oldVal) return; | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
updateCheckedValue(null); | ||
@@ -1167,8 +1167,8 @@ })); | ||
if (!flag.value) return; | ||
if (!checked.value.length) return; | ||
if (val === oldVal) return; | ||
getOption('depend'); | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (!checked.value.length) return; | ||
updateCheckedValue(typeof checked.value === 'string' ? '' : []); | ||
getOption('depend'); | ||
})); | ||
@@ -1175,0 +1175,0 @@ unwatchs.push(watch(() => props.getOptions, getOption.bind(null, 'initial'), { |
@@ -1,2 +0,2 @@ | ||
import{version as e,isVue2 as t,defineComponent as r,onBeforeUnmount as a,toRef as i,getCurrentInstance as l,set as n,del as u,provide as s,ref as d,onMounted as o,h as p,computed as c,watch as f,nextTick as y,inject as v}from"vue-demi";function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},g.apply(this,arguments)}var m=["attrs","props","domProps"],b=["class","style","directives"],F=["on","nativeOn"],Q=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},S=function(e){return e.reduce((function(e,t){for(var r in t)if(e[r])if(-1!==m.indexOf(r))e[r]=g({},e[r],t[r]);else if(-1!==b.indexOf(r)){var a=e[r]instanceof Array?e[r]:[e[r]],i=t[r]instanceof Array?t[r]:[t[r]];e[r]=[].concat(a,i)}else if(-1!==F.indexOf(r))for(var l in t[r])if(e[r][l]){var n=e[r][l]instanceof Array?e[r][l]:[e[r][l]],u=t[r][l]instanceof Array?t[r][l]:[t[r][l]];e[r][l]=[].concat(n,u)}else e[r][l]=t[r][l];else if("hook"===r)for(var s in t[r])e[r][s]=e[r][s]?Q(e[r][s],t[r][s]):t[r][s];else e[r]=t[r];else e[r]=t[r];return e}),{})},V=h(S);function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function O(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function q(e,t,r="children"){for(const a of e){if(t(a))return[a];if(a[r]?.length){const e=q(a[r],t);if(e.length)return e.unshift(a),e}}return[]}function W(e,t){return k(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const A="2.7"===e.slice(0,3),C=t?"value":"modelValue",j={field:{type:String,required:!0},as:{type:String},emptyValue:{type:[String,null,void 0],default:void 0},resetToInitialValue:{type:[Boolean]},query:{type:Object,required:!0},backfill:{type:Object},disabled:{type:[Boolean,Function]},hide:{type:[Boolean,Function]},validator:{type:[Function]},defaultValue:{type:[String,Array,Function]},depend:{type:Boolean},dependFields:{type:[String,Array]}},$={tag:{type:[String,Object],default:"div"},resetToInitialValue:{type:Boolean},datum:{type:Object,default:()=>({})},backfill:{type:Object},realtime:{type:Boolean},immediateSearch:{type:Boolean},toast:{type:Function,default:()=>{}},searchAtDatumChanged:{type:Boolean}},D={...j,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},getOptions:{type:Function},filterMethod:{type:Function}},H={...j,inputNum:{type:Number,default:1,validator:e=>e>=1},fields:{type:Array},realtime:{type:Boolean},waitTime:{type:Number,default:300}},B={...j,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},E={...j,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},getOptions:{type:Function}},T={search:e=>!0},I={...T,ready:e=>!0,reset:e=>!0},w={...T,blur:(...e)=>!0},K={...T,triggerSearch:()=>!0},P={...T},M={...T},N="condition-wrapper";var x=r({name:"CoreWrapper",props:$,emits:I,setup(e,t){const r=[];a((()=>r.splice(0)));let p=!1,c=[];const f={realtime:i(e,"realtime"),register:t=>{r.push(t);const i=()=>{p=!0,t.reset().updateWrapperQuery();const a=r.indexOf(t);-1!==a&&r.splice(a,1),e.searchAtDatumChanged&&f.search(),p=!1,c.forEach((e=>u(y.value,e))),c=[]},n=l();return n&&a(i,A?n.proxy:n),i},updateQueryValue:(e,t)=>(p&&c.push(e),n(y.value,e,t),f),insetSearch:()=>(e.realtime&&f.search(),f),search:h,removeUnreferencedField(e){let t=0;return r.some((r=>(r.getQuery().hasOwnProperty(e)&&(t+=1),t))),t||u(y.value,e),f}};s(N,f);const y=d({}),v=()=>({...e.backfill,...y.value});async function h(){const a=(await Promise.all(r.map((e=>e.validator?.(y.value))))).find((e=>e&&"string"==typeof e));if(a?e.toast(a):t.emit("search",v()),a)return a}function g(){r.forEach((e=>{e.reset().updateWrapperQuery()})),t.emit("reset",v())}return o((()=>{e.immediateSearch&&t.emit("ready",v())})),{child:r,wrapperInstance:f,query:y,getQuery:v,querySearch:h,resetAndSearch:function(){g(),h()},reset:g}},render(){const{resetToInitialValue:e,backfill:t,query:r,getQuery:a,querySearch:i,resetAndSearch:l,reset:n}=this,u=this.tag,s=this.datum,d=W("default",this),o=W("btn",this),{class:c,style:f,...y}=this.$attrs,v={};return k(this,"$listeners")&&(v.on=this.$listeners),p(u,V([{},v]),[Object.entries(s).map((([a,i])=>i?"function"==typeof d?d({...y,key:a,field:i.as||a,resetToInitialValue:e,backfill:t,query:r,...i}):d||"":void 0)),"function"==typeof o?o({search:i,getQuery:a,resetAndSearch:l,reset:n}):o])}});function U(e){const t=d();return c({set(e){t.value=e},get:()=>void 0===t.value?void 0!==e.defaultValue?"function"==typeof e.defaultValue?e.defaultValue(e.query,e.backfill):e.defaultValue:void 0:t.value})}function _(e,t){const r=d("boolean"==typeof e.disabled&&e.disabled),i=d("boolean"==typeof e.hide&&e.hide);return a(f((()=>e.query),(()=>{if("function"==typeof e.hide){i.value!==e.hide(e.query)&&(i.value=e.hide(e.query),i.value&&t.reset().updateWrapperQuery())}else if("function"==typeof e.disabled){r.value!==e.disabled(e.query)&&(r.value=e.disabled(e.query))}}),{immediate:!0,deep:!0})),{insetDisabled:r,insetHide:i}}function z(e=!0){const t=d(e);return{flag:t,updateFlag:()=>{t.value=!e,y((()=>{t.value=e}))}}}var G=r({inheritAttrs:!1,name:"CoreSelect",props:D,setup(e,t){const r=v(N),i=U(e),l=e.backfill&&e.backfill[e.field],n=d(l||(void 0!==e.defaultValue?i.value:e.multiple?[]:"").slice()),{flag:u,updateFlag:s}=z(),o=()=>({[e.field]:O(n.value,e.emptyValue)}),p={reset:C,updateWrapperQuery:()=>(r?.updateQueryValue(e.field,O(n.value,e.emptyValue)),p),get validator(){return e.validator},getQuery:o};r?.register(p);const{insetDisabled:y,insetHide:h}=_(e,p);!l&&e.defaultValue&&p.updateWrapperQuery();const g=d([]),m=c((()=>g.value.length?g.value:e.options)),b=d(!1),F=d([]),Q=c((()=>b.value?F.value:m.value)),S=c((()=>e.filterMethod&&q)),V=[];function k(t){e.getOptions?.((e=>{const t=n.value;n.value=void 0,g.value=e||[],n.value=t}),e.query||{},{trigger:t,change:(e,t)=>{t&&(i.value=e),A(e)},search:(e,t)=>{t&&(i.value=e),W(e),r?.search()}})}function q(t){const{filterMethod:r}=e;""===t||void 0===t?(b.value=!1,F.value=[]):(b.value=!0,F.value=m.value.filter((e=>r(t,e))))}function W(e){e!==n.value&&(n.value=e,p.updateWrapperQuery())}function A(e){W(e),r?.insetSearch()}function C(){const{multiple:t}=e;return s(),n.value=e.resetToInitialValue&&i.value?.slice()||(t?[]:""),p}return a((()=>V.forEach((e=>e())))),V.push(f((()=>e.field),((e,t)=>{e!==t&&r?.removeUnreferencedField(t),p.updateWrapperQuery()}))),V.push(f((()=>[e.field,e.query[e.field]]),(([e,t],[r])=>{e===r&&t!==n.value&&(n.value=t)}))),V.push(f((()=>[e.field,e.backfill?.[e.field]]),(([t,r],[a])=>{(t===a||e.backfill?.hasOwnProperty(t))&&(s(),W(r))}))),V.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([t,r,a],[i,l,s])=>{u.value&&void 0!==n.value&&""!==n.value.toString()&&t===i&&r?.toString()===l?.toString()&&a!==s&&(W(e.multiple?[]:""),k("depend"))}))),V.push(f((()=>e.getOptions),k.bind(null,"initial"),{immediate:!0})),{checked:n,getQuery:o,insetDisabled:y,insetHide:h,finalOption:Q,customFilterMethod:S,blur:function(){e.filterMethod&&q("")},updateCheckedValue:W,change:A,reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:r,insetHide:a,finalOption:i,blur:l,customFilterMethod:n,change:u,reset:s,valueKey:d,labelKey:o,multiple:p}=this;if(a)return;const c=W("default",this),f=k(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof c?c({...this.$attrs,listeners:f,[C]:e,options:i,disabled:r,blur:l,filterMethod:n,change:u,valueKey:d,labelKey:o,multiple:p}):c}}),J=r({name:"CoreInput",props:H,setup(e,t){const r=v(N),i=U(e),l=e.backfill&&e.backfill[e.field],u=d([].concat(l||i.value||"")),{flag:s,updateFlag:o}=z(),p=()=>e.inputNum>1&&e.fields?e.fields.reduce(((t,r,a)=>(t[r]=O(u.value[a],e.emptyValue),t)),{}):{[e.field]:O(e.inputNum>1?u.value:u.value[0],e.emptyValue)},c={reset:b,updateWrapperQuery:()=>(r&&Object.entries(p()).forEach((([e,t])=>r.updateQueryValue(e,t))),c),get validator(){return e.validator},getQuery:p};r?.register(c);const{insetDisabled:y,insetHide:h}=_(e,c);!l&&e.defaultValue&&c.updateWrapperQuery();const g=[];a((()=>g.forEach((e=>e())))),g.push(f((()=>e.inputNum>1&&e.fields?.length?e.fields:[e.field]),((e,t)=>{e.toString()!==t.toString()&&r&&t.forEach((e=>r.removeUnreferencedField(e))),c.updateWrapperQuery()}))),g.push(f((()=>e.inputNum>1&&e.fields?.length?[e.fields,e.fields.map((t=>e.query[t]))]:[e.field,[e.query[e.field]]]),(([e,t],[r])=>{e.toString()===r.toString()&&t.toString()!==u.value.toString()&&(u.value=t)}))),g.push(f((()=>e.inputNum>1&&e.fields?.length?e.fields.map((t=>e.backfill?.[t])):[e.backfill?.[e.field]]),(e=>{e.toString()!==u.value.toString()&&(o(),u.value=e,c.updateWrapperQuery())}))),g.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,r],[a,i,l])=>{s.value&&""!==u.value.toString()&&e===a&&t?.toString()===i?.toString()&&r!==l&&(u.value=[],c.updateWrapperQuery())})));let m=0;function b(){return o(),u.value=[].concat(e.resetToInitialValue&&i.value||""),c}return{checked:u,getQuery:p,insetDisabled:y,insetHide:h,debounceChange:function(t,a){const{realtime:i,waitTime:l}=e;n(u.value,a,t),u.value[a]=t,m&&clearTimeout(m),i||!r?.realtime.value?(c.updateWrapperQuery(),r?.insetSearch()):m=setTimeout((()=>(c.updateWrapperQuery(),r?.insetSearch())),l)},enterHandler:function(e,t){n(u.value,t,"string"==typeof e?e:e.target?.value||""),c.updateWrapperQuery(),r?.search()},reset:b}},render(){const{query:e,checked:t,getQuery:r,insetDisabled:a,insetHide:i,debounceChange:l,enterHandler:n,reset:u}=this;if(i)return;const s=W("default",this),d=k(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,listeners:d,[C]:t,disabled:a,debounceChange:l,enterHandler:n}):s}}),L=r({inheritAttrs:!1,name:"CoreDatepicker",props:B,setup(e,t){const r=v(N),i=U(e),l=e.backfill&&(e.range&&e.beginField&&e.endField?["",""]:e.backfill[e.field]),n=l&&("string"==typeof l?l:l.join("")),u=d((n&&l||i.value||n||"").slice()),{flag:s,updateFlag:o}=z(),p=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:O(u.value[0],e.emptyValue),[e.endField]:O(u.value[1],e.emptyValue)}:{[e.field]:Array.isArray(u.value)?[...u.value]:O(u.value,e.emptyValue)},c={reset:b,updateWrapperQuery(){const{range:t,field:a,beginField:i,endField:l}=e;return t&&i&&l?(r?.updateQueryValue(i,O(u.value[0],e.emptyValue)),r?.updateQueryValue(l,O(u.value[1],e.emptyValue))):r?.updateQueryValue(a,O(u.value,e.emptyValue)),c},get validator(){return e.validator},getQuery:p};r?.register(c);const{insetDisabled:y,insetHide:h}=_(e,c);!n&&e.defaultValue&&c.updateWrapperQuery();const g=[];function m(t){const{range:r}=e;u.value=null===t?r?["",""]:"":t,c.updateWrapperQuery()}function b(){const{range:t}=e;return o(),u.value=e.resetToInitialValue&&i.value?.slice()||(t?["",""]:""),c}return a((()=>g.forEach((e=>e())))),g.push(f((()=>e.field),((e,t)=>{e!==t&&r?.removeUnreferencedField(t),c.updateWrapperQuery()}))),g.push(f((()=>e.range&&e.beginField&&e.endField?[!0,[e.beginField,e.query[e.beginField]],[e.endField,e.query[e.endField]]]:[!1,[e.field,e.query[e.field]]]),(([e,...t],[r,...a])=>{t.some(((e,t)=>e[0]!==a[t][0]))||(e?("string"==typeof u.value&&(u.value=[]),t.forEach(((e,t)=>{u.value[t]!==e[1]&&e[1]!==a[t][1]&&(u.value[t]=e[1]||"")}))):u.value!==t[0][1]&&t[0][1]!==a[0][1]&&(u.value=t[0][1]||""))}))),g.push(f((()=>e.range&&e.beginField&&e.endField?[!0,e.backfill?.[e.beginField],e.backfill?.[e.endField]]:[!1,e.backfill?.[e.field]]),(([t,...r],[a,...i])=>{if(t){let e=!1;r.forEach(((t,r)=>{t!==i[r]&&(o(),"string"==typeof u.value&&(u.value=[]),u.value.splice(r,1),t&&u.value.splice(r,0,t),e=!0)})),e&&c.updateWrapperQuery()}else{if(r[0]===i[0])return;o(),u.value=O(r[0],e.emptyValue),c.updateWrapperQuery()}}))),g.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,r],[a,i,l])=>{s.value&&e===a&&t?.toString()===i?.toString()&&r!==l&&m(null)}))),{checked:u,getQuery:p,insetDisabled:y,insetHide:h,updateCheckedValue:m,change:function(e){m(e),r?.insetSearch()},reset:b}},render(){const{checked:e,getQuery:t,insetHide:r,insetDisabled:a,updateCheckedValue:i,change:l,reset:n}=this;if(r)return;const u=W("default",this),s=k(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,listeners:s,[C]:e,disabled:a,updateCheckedValue:i,change:l}):u}}),R=r({inheritAttrs:!1,name:"CoreCascader",props:E,setup(e,t){const r=v(N),i=U(e),l=d([]),n=d([]),u=c((()=>n.value.length?n.value:e.options)),s=()=>b.value||i.value?e.fields?.length?e.fields.reduce(((e,t,r)=>Object.assign(e,{[t]:l.value[r]})),{}):{[e.field]:e.emitPath?[...l.value]:l.value.slice(-1)[0]}:{},{flag:o,updateFlag:p}=z(),y={reset:V,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:a,emitPath:i}=e;return a?.length?a.forEach(((t,a)=>{r?.updateQueryValue(t,O(l.value[a],e.emptyValue))})):r?.updateQueryValue(t,O(i?[...l.value]:l.value.slice(-1)[0],e.emptyValue)),y},getQuery:s};r?.register(y);const{insetDisabled:h,insetHide:g}=_(e,y),m=[];a((()=>m.forEach((e=>e()))));const b=d("function"!=typeof e.getOptions||!!e.fields?.length);function F(t){e.getOptions?.((e=>{n.value=e||[],b.value=!0}),e.query||{},{trigger:t,change:(e,t)=>{t&&(i.value=e),S(e)},search:(e,t)=>{t&&(i.value=e),Q(e),r?.search()}})}function Q(e){const t=Array.isArray(e)?e:k(e);t.join("")!==l.value.join("")&&(l.value=t,y.updateWrapperQuery())}function S(e){Q(e),r?.insetSearch()}function V(){return p(),l.value=e.resetToInitialValue&&i.value?.slice()||[],y}function k(t){if(!t&&0!==t)return[];const{valueKey:r,childrenKey:a}=e;return q(u.value,(e=>e[r]===t)).map((e=>e[r]),a)}return f(b,(t=>t&&function(){const{backfill:t,field:r,fields:a}=e;if(t)if(a){const e=a.reduce(((e,r)=>(t[r]&&e.push(t[r]),e)),[]);if(e.length)return l.value=e,void y.updateWrapperQuery()}else if(t[r])return l.value=k(t[r]),void y.updateWrapperQuery();i.value?.length&&(l.value="string"==typeof i.value?k(i.value):i.value.slice(),"string"==typeof i.value&&(i.value=l.value.slice()),y.updateWrapperQuery())}()),{immediate:!0}),m.push(f((()=>e.fields||[e.field]),((e,t)=>{e.toString()!==t.toString()&&r&&t.forEach((t=>e.includes(t)||r.removeUnreferencedField(t))),y.updateWrapperQuery()}))),m.push(f((()=>[e.fields?.toString()||e.field,e.fields?.map((t=>e.query[t]))||e.field]),(([e,t],[r])=>{e===r&&(l.value="string"==typeof t?k(t):t)}))),m.push(f((()=>e.fields?.length?e.fields.reduce(((t,r)=>(e.backfill?.[r]&&t.push(e.backfill[r]),t)),[]):e.backfill?.[e.field]),(e=>{if(b.value)if(p(),Array.isArray(e))Q(e);else{if(!e&&0!==e)return void(l.value.length&&(l.value=[]));Q(k(e))}}))),m.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,r],[a,i,n])=>{o.value&&l.value.length&&e===a&&t?.toString()===i?.toString()&&r!==n&&(Q("string"==typeof l.value?"":[]),F("depend"))}))),m.push(f((()=>e.getOptions),F.bind(null,"initial"),{immediate:!0})),{checked:l,getQuery:s,finalOption:u,insetDisabled:h,insetHide:g,change:S,reset:V}},render(){const{checked:e,getQuery:t,finalOption:r,insetHide:a,insetDisabled:i,change:l,reset:n}=this;if(a)return;const u=W("default",this),s=k(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,options:r,listeners:s,[C]:e,disabled:i,change:l}):u}});export{R as CoreCascader,L as CoreDatepicker,J as CoreInput,G as CoreSelect,x as CoreWrapper,M as cascaderEmits,E as cascaderProps,T as commonEmits,j as commonProps,P as datepickerEmits,B as datepickerProps,K as inputEmits,H as inputProps,N as provideKey,w as selectEmits,D as selectProps,I as wrapperEmits,$ as wrapperProps}; | ||
import{version as e,isVue2 as t,defineComponent as r,onBeforeUnmount as a,toRef as i,getCurrentInstance as l,set as n,del as u,provide as s,ref as d,onMounted as o,h as p,computed as c,watch as f,nextTick as y,inject as v}from"vue-demi";function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},g.apply(this,arguments)}var m=["attrs","props","domProps"],b=["class","style","directives"],F=["on","nativeOn"],Q=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},S=function(e){return e.reduce((function(e,t){for(var r in t)if(e[r])if(-1!==m.indexOf(r))e[r]=g({},e[r],t[r]);else if(-1!==b.indexOf(r)){var a=e[r]instanceof Array?e[r]:[e[r]],i=t[r]instanceof Array?t[r]:[t[r]];e[r]=[].concat(a,i)}else if(-1!==F.indexOf(r))for(var l in t[r])if(e[r][l]){var n=e[r][l]instanceof Array?e[r][l]:[e[r][l]],u=t[r][l]instanceof Array?t[r][l]:[t[r][l]];e[r][l]=[].concat(n,u)}else e[r][l]=t[r][l];else if("hook"===r)for(var s in t[r])e[r][s]=e[r][s]?Q(e[r][s],t[r][s]):t[r][s];else e[r]=t[r];else e[r]=t[r];return e}),{})},V=h(S);function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function O(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function q(e,t,r="children"){for(const a of e){if(t(a))return[a];if(a[r]?.length){const e=q(a[r],t);if(e.length)return e.unshift(a),e}}return[]}function W(e,t){return k(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const A="2.7"===e.slice(0,3),C=t?"value":"modelValue",j={field:{type:String,required:!0},as:{type:String},emptyValue:{type:[String,null,void 0],default:void 0},resetToInitialValue:{type:[Boolean]},query:{type:Object,required:!0},backfill:{type:Object},disabled:{type:[Boolean,Function]},hide:{type:[Boolean,Function]},validator:{type:[Function]},defaultValue:{type:[String,Array,Function]},depend:{type:Boolean},dependFields:{type:[String,Array]}},$={tag:{type:[String,Object],default:"div"},resetToInitialValue:{type:Boolean},datum:{type:Object,default:()=>({})},backfill:{type:Object},realtime:{type:Boolean},immediateSearch:{type:Boolean},toast:{type:Function,default:()=>{}},searchAtDatumChanged:{type:Boolean}},D={...j,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},getOptions:{type:Function},filterMethod:{type:Function}},H={...j,inputNum:{type:Number,default:1,validator:e=>e>=1},fields:{type:Array},realtime:{type:Boolean},waitTime:{type:Number,default:300}},B={...j,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},E={...j,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},getOptions:{type:Function}},T={search:e=>!0},I={...T,ready:e=>!0,reset:e=>!0},w={...T,blur:(...e)=>!0},K={...T,triggerSearch:()=>!0},P={...T},M={...T},N="condition-wrapper";var x=r({name:"CoreWrapper",props:$,emits:I,setup(e,t){const r=[];a((()=>r.splice(0)));let p=!1,c=[];const f={realtime:i(e,"realtime"),register:t=>{r.push(t);const i=()=>{p=!0,t.reset().updateWrapperQuery();const a=r.indexOf(t);-1!==a&&r.splice(a,1),e.searchAtDatumChanged&&f.search(),p=!1,c.forEach((e=>u(y.value,e))),c=[]},n=l();return n&&a(i,A?n.proxy:n),i},updateQueryValue:(e,t)=>(p&&c.push(e),n(y.value,e,t),f),insetSearch:()=>(e.realtime&&f.search(),f),search:h,removeUnreferencedField(e){let t=0;return r.some((r=>(r.getQuery().hasOwnProperty(e)&&(t+=1),t))),t||u(y.value,e),f}};s(N,f);const y=d({}),v=()=>({...e.backfill,...y.value});async function h(){const a=(await Promise.all(r.map((e=>e.validator?.(y.value))))).find((e=>e&&"string"==typeof e));if(a?e.toast(a):t.emit("search",v()),a)return a}function g(){r.forEach((e=>{e.reset().updateWrapperQuery()})),t.emit("reset",v())}return o((()=>{e.immediateSearch&&t.emit("ready",v())})),{child:r,wrapperInstance:f,query:y,getQuery:v,querySearch:h,resetAndSearch:function(){g(),h()},reset:g}},render(){const{resetToInitialValue:e,backfill:t,query:r,getQuery:a,querySearch:i,resetAndSearch:l,reset:n}=this,u=this.tag,s=this.datum,d=W("default",this),o=W("btn",this),{class:c,style:f,...y}=this.$attrs,v={};return k(this,"$listeners")&&(v.on=this.$listeners),p(u,V([{},v]),[Object.entries(s).map((([a,i])=>i?"function"==typeof d?d({...y,key:a,field:i.as||a,resetToInitialValue:e,backfill:t,query:r,...i}):d||"":void 0)),"function"==typeof o?o({search:i,getQuery:a,resetAndSearch:l,reset:n}):o])}});function U(e){const t=d();return c({set(e){t.value=e},get:()=>void 0===t.value?void 0!==e.defaultValue?"function"==typeof e.defaultValue?e.defaultValue(e.query,e.backfill):e.defaultValue:void 0:t.value})}function _(e,t){const r=d("boolean"==typeof e.disabled&&e.disabled),i=d("boolean"==typeof e.hide&&e.hide);return a(f((()=>e.query),(()=>{if("function"==typeof e.hide){i.value!==e.hide(e.query)&&(i.value=e.hide(e.query),i.value&&t.reset().updateWrapperQuery())}else if("function"==typeof e.disabled){r.value!==e.disabled(e.query)&&(r.value=e.disabled(e.query))}}),{immediate:!0,deep:!0})),{insetDisabled:r,insetHide:i}}function z(e=!0){const t=d(e);return{flag:t,updateFlag:()=>{t.value=!e,y((()=>{t.value=e}))}}}var G=r({inheritAttrs:!1,name:"CoreSelect",props:D,setup(e,t){const r=v(N),i=U(e),l=e.backfill&&e.backfill[e.field],n=d(l||(void 0!==e.defaultValue?i.value:e.multiple?[]:"").slice()),{flag:u,updateFlag:s}=z(),o=()=>({[e.field]:O(n.value,e.emptyValue)}),p={reset:C,updateWrapperQuery:()=>(r?.updateQueryValue(e.field,O(n.value,e.emptyValue)),p),get validator(){return e.validator},getQuery:o};r?.register(p);const{insetDisabled:y,insetHide:h}=_(e,p);!l&&e.defaultValue&&p.updateWrapperQuery();const g=d([]),m=c((()=>g.value.length?g.value:e.options)),b=d(!1),F=d([]),Q=c((()=>b.value?F.value:m.value)),S=c((()=>e.filterMethod&&q)),V=[];function k(t){e.getOptions?.((e=>{const t=n.value;n.value=void 0,g.value=e||[],n.value=t}),e.query||{},{trigger:t,change:(e,t)=>{t&&(i.value=e),A(e)},search:(e,t)=>{t&&(i.value=e),W(e),r?.search()}})}function q(t){const{filterMethod:r}=e;""===t||void 0===t?(b.value=!1,F.value=[]):(b.value=!0,F.value=m.value.filter((e=>r(t,e))))}function W(e){e!==n.value&&(n.value=e,p.updateWrapperQuery())}function A(e){W(e),r?.insetSearch()}function C(){const{multiple:t}=e;return s(),n.value=e.resetToInitialValue&&i.value?.slice()||(t?[]:""),p}return a((()=>V.forEach((e=>e())))),V.push(f((()=>e.field),((e,t)=>{e!==t&&r?.removeUnreferencedField(t),p.updateWrapperQuery()}))),V.push(f((()=>[e.field,e.query[e.field]]),(([e,t],[r])=>{e===r&&t!==n.value&&(n.value=t)}))),V.push(f((()=>[e.field,e.backfill?.[e.field]]),(([t,r],[a])=>{(t===a||e.backfill?.hasOwnProperty(t))&&(s(),W(r))}))),V.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([t,r,a],[i,l,s])=>{u.value&&a!==s&&(k("depend"),t===i&&r?.toString()===l?.toString()&&void 0!==n.value&&""!==n.value.toString()&&W(e.multiple?[]:""))}))),V.push(f((()=>e.getOptions),k.bind(null,"initial"),{immediate:!0})),{checked:n,getQuery:o,insetDisabled:y,insetHide:h,finalOption:Q,customFilterMethod:S,blur:function(){e.filterMethod&&q("")},updateCheckedValue:W,change:A,reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:r,insetHide:a,finalOption:i,blur:l,customFilterMethod:n,change:u,reset:s,valueKey:d,labelKey:o,multiple:p}=this;if(a)return;const c=W("default",this),f=k(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof c?c({...this.$attrs,listeners:f,[C]:e,options:i,disabled:r,blur:l,filterMethod:n,change:u,valueKey:d,labelKey:o,multiple:p}):c}}),J=r({name:"CoreInput",props:H,setup(e,t){const r=v(N),i=U(e),l=e.backfill&&e.backfill[e.field],u=d([].concat(l||i.value||"")),{flag:s,updateFlag:o}=z(),p=()=>e.inputNum>1&&e.fields?e.fields.reduce(((t,r,a)=>(t[r]=O(u.value[a],e.emptyValue),t)),{}):{[e.field]:O(e.inputNum>1?u.value:u.value[0],e.emptyValue)},c={reset:b,updateWrapperQuery:()=>(r&&Object.entries(p()).forEach((([e,t])=>r.updateQueryValue(e,t))),c),get validator(){return e.validator},getQuery:p};r?.register(c);const{insetDisabled:y,insetHide:h}=_(e,c);!l&&e.defaultValue&&c.updateWrapperQuery();const g=[];a((()=>g.forEach((e=>e())))),g.push(f((()=>e.inputNum>1&&e.fields?.length?e.fields:[e.field]),((e,t)=>{e.toString()!==t.toString()&&r&&t.forEach((e=>r.removeUnreferencedField(e))),c.updateWrapperQuery()}))),g.push(f((()=>e.inputNum>1&&e.fields?.length?[e.fields,e.fields.map((t=>e.query[t]))]:[e.field,[e.query[e.field]]]),(([e,t],[r])=>{e.toString()===r.toString()&&t.toString()!==u.value.toString()&&(u.value=t)}))),g.push(f((()=>e.inputNum>1&&e.fields?.length?e.fields.map((t=>e.backfill?.[t])):[e.backfill?.[e.field]]),(e=>{e.toString()!==u.value.toString()&&(o(),u.value=e,c.updateWrapperQuery())}))),g.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,r],[a,i,l])=>{s.value&&r!==l&&e===a&&t?.toString()===i?.toString()&&""!==u.value.toString()&&(u.value=[],c.updateWrapperQuery())})));let m=0;function b(){return o(),u.value=[].concat(e.resetToInitialValue&&i.value||""),c}return{checked:u,getQuery:p,insetDisabled:y,insetHide:h,debounceChange:function(t,a){const{realtime:i,waitTime:l}=e;n(u.value,a,t),u.value[a]=t,m&&clearTimeout(m),i||!r?.realtime.value?(c.updateWrapperQuery(),r?.insetSearch()):m=setTimeout((()=>(c.updateWrapperQuery(),r?.insetSearch())),l)},enterHandler:function(e,t){n(u.value,t,"string"==typeof e?e:e.target?.value||""),c.updateWrapperQuery(),r?.search()},reset:b}},render(){const{query:e,checked:t,getQuery:r,insetDisabled:a,insetHide:i,debounceChange:l,enterHandler:n,reset:u}=this;if(i)return;const s=W("default",this),d=k(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,listeners:d,[C]:t,disabled:a,debounceChange:l,enterHandler:n}):s}}),L=r({inheritAttrs:!1,name:"CoreDatepicker",props:B,setup(e,t){const r=v(N),i=U(e),l=e.backfill&&(e.range&&e.beginField&&e.endField?["",""]:e.backfill[e.field]),n=l&&("string"==typeof l?l:l.join("")),u=d((n&&l||i.value||n||"").slice()),{flag:s,updateFlag:o}=z(),p=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:O(u.value[0],e.emptyValue),[e.endField]:O(u.value[1],e.emptyValue)}:{[e.field]:Array.isArray(u.value)?[...u.value]:O(u.value,e.emptyValue)},c={reset:b,updateWrapperQuery(){const{range:t,field:a,beginField:i,endField:l}=e;return t&&i&&l?(r?.updateQueryValue(i,O(u.value[0],e.emptyValue)),r?.updateQueryValue(l,O(u.value[1],e.emptyValue))):r?.updateQueryValue(a,O(u.value,e.emptyValue)),c},get validator(){return e.validator},getQuery:p};r?.register(c);const{insetDisabled:y,insetHide:h}=_(e,c);!n&&e.defaultValue&&c.updateWrapperQuery();const g=[];function m(t){const{range:r}=e;u.value=null===t?r?["",""]:"":t,c.updateWrapperQuery()}function b(){const{range:t}=e;return o(),u.value=e.resetToInitialValue&&i.value?.slice()||(t?["",""]:""),c}return a((()=>g.forEach((e=>e())))),g.push(f((()=>e.field),((e,t)=>{e!==t&&r?.removeUnreferencedField(t),c.updateWrapperQuery()}))),g.push(f((()=>e.range&&e.beginField&&e.endField?[!0,[e.beginField,e.query[e.beginField]],[e.endField,e.query[e.endField]]]:[!1,[e.field,e.query[e.field]]]),(([e,...t],[r,...a])=>{t.some(((e,t)=>e[0]!==a[t][0]))||(e?("string"==typeof u.value&&(u.value=[]),t.forEach(((e,t)=>{u.value[t]!==e[1]&&e[1]!==a[t][1]&&(u.value[t]=e[1]||"")}))):u.value!==t[0][1]&&t[0][1]!==a[0][1]&&(u.value=t[0][1]||""))}))),g.push(f((()=>e.range&&e.beginField&&e.endField?[!0,e.backfill?.[e.beginField],e.backfill?.[e.endField]]:[!1,e.backfill?.[e.field]]),(([t,...r],[a,...i])=>{if(t){let e=!1;r.forEach(((t,r)=>{t!==i[r]&&(o(),"string"==typeof u.value&&(u.value=[]),u.value.splice(r,1),t&&u.value.splice(r,0,t),e=!0)})),e&&c.updateWrapperQuery()}else{if(r[0]===i[0])return;o(),u.value=O(r[0],e.emptyValue),c.updateWrapperQuery()}}))),g.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,r],[a,i,l])=>{s.value&&r!==l&&e===a&&t?.toString()===i?.toString()&&m(null)}))),{checked:u,getQuery:p,insetDisabled:y,insetHide:h,updateCheckedValue:m,change:function(e){m(e),r?.insetSearch()},reset:b}},render(){const{checked:e,getQuery:t,insetHide:r,insetDisabled:a,updateCheckedValue:i,change:l,reset:n}=this;if(r)return;const u=W("default",this),s=k(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,listeners:s,[C]:e,disabled:a,updateCheckedValue:i,change:l}):u}}),R=r({inheritAttrs:!1,name:"CoreCascader",props:E,setup(e,t){const r=v(N),i=U(e),l=d([]),n=d([]),u=c((()=>n.value.length?n.value:e.options)),s=()=>b.value||i.value?e.fields?.length?e.fields.reduce(((e,t,r)=>Object.assign(e,{[t]:l.value[r]})),{}):{[e.field]:e.emitPath?[...l.value]:l.value.slice(-1)[0]}:{},{flag:o,updateFlag:p}=z(),y={reset:V,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:a,emitPath:i}=e;return a?.length?a.forEach(((t,a)=>{r?.updateQueryValue(t,O(l.value[a],e.emptyValue))})):r?.updateQueryValue(t,O(i?[...l.value]:l.value.slice(-1)[0],e.emptyValue)),y},getQuery:s};r?.register(y);const{insetDisabled:h,insetHide:g}=_(e,y),m=[];a((()=>m.forEach((e=>e()))));const b=d("function"!=typeof e.getOptions||!!e.fields?.length);function F(t){e.getOptions?.((e=>{n.value=e||[],b.value=!0}),e.query||{},{trigger:t,change:(e,t)=>{t&&(i.value=e),S(e)},search:(e,t)=>{t&&(i.value=e),Q(e),r?.search()}})}function Q(e){const t=Array.isArray(e)?e:k(e);t.join("")!==l.value.join("")&&(l.value=t,y.updateWrapperQuery())}function S(e){Q(e),r?.insetSearch()}function V(){return p(),l.value=e.resetToInitialValue&&i.value?.slice()||[],y}function k(t){if(!t&&0!==t)return[];const{valueKey:r,childrenKey:a}=e;return q(u.value,(e=>e[r]===t)).map((e=>e[r]),a)}return f(b,(t=>t&&function(){const{backfill:t,field:r,fields:a}=e;if(t)if(a){const e=a.reduce(((e,r)=>(t[r]&&e.push(t[r]),e)),[]);if(e.length)return l.value=e,void y.updateWrapperQuery()}else if(t[r])return l.value=k(t[r]),void y.updateWrapperQuery();i.value?.length&&(l.value="string"==typeof i.value?k(i.value):i.value.slice(),"string"==typeof i.value&&(i.value=l.value.slice()),y.updateWrapperQuery())}()),{immediate:!0}),m.push(f((()=>e.fields||[e.field]),((e,t)=>{e.toString()!==t.toString()&&r&&t.forEach((t=>e.includes(t)||r.removeUnreferencedField(t))),y.updateWrapperQuery()}))),m.push(f((()=>[e.fields?.toString()||e.field,e.fields?.map((t=>e.query[t]))||e.field]),(([e,t],[r])=>{e===r&&(l.value="string"==typeof t?k(t):t)}))),m.push(f((()=>e.fields?.length?e.fields.reduce(((t,r)=>(e.backfill?.[r]&&t.push(e.backfill[r]),t)),[]):e.backfill?.[e.field]),(e=>{if(b.value)if(p(),Array.isArray(e))Q(e);else{if(!e&&0!==e)return void(l.value.length&&(l.value=[]));Q(k(e))}}))),m.push(f((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,r],[a,i,n])=>{o.value&&r!==n&&(F("depend"),e===a&&t?.toString()===i?.toString()&&l.value.length&&Q("string"==typeof l.value?"":[]))}))),m.push(f((()=>e.getOptions),F.bind(null,"initial"),{immediate:!0})),{checked:l,getQuery:s,finalOption:u,insetDisabled:h,insetHide:g,change:S,reset:V}},render(){const{checked:e,getQuery:t,finalOption:r,insetHide:a,insetDisabled:i,change:l,reset:n}=this;if(a)return;const u=W("default",this),s=k(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,options:r,listeners:s,[C]:e,disabled:i,change:l}):u}});export{R as CoreCascader,L as CoreDatepicker,J as CoreInput,G as CoreSelect,x as CoreWrapper,M as cascaderEmits,E as cascaderProps,T as commonEmits,j as commonProps,P as datepickerEmits,B as datepickerProps,K as inputEmits,H as inputProps,N as provideKey,w as selectEmits,D as selectProps,I as wrapperEmits,$ as wrapperProps}; | ||
//# sourceMappingURL=index.esm.min.js.map |
@@ -734,8 +734,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) { | ||
if (!flag.value) return; | ||
if (checked.value === undefined || checked.value.toString() === '') return; | ||
if (val === oldVal) return; | ||
getOption('depend'); | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (checked.value === undefined || checked.value.toString() === '') return; | ||
updateCheckedValue(props.multiple ? [] : ''); | ||
getOption('depend'); | ||
})); | ||
@@ -931,6 +931,6 @@ unwatchs.push(vueDemi.watch(() => props.getOptions, getOption.bind(null, 'initial'), { | ||
if (!flag.value) return; | ||
if (checked.value.toString() === '') return; | ||
if (val === oldVal) return; | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (checked.value.toString() === '') return; | ||
checked.value = []; | ||
@@ -1121,5 +1121,5 @@ option.updateWrapperQuery(); | ||
if (!flag.value) return; | ||
if (val === oldVal) return; | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
updateCheckedValue(null); | ||
@@ -1287,8 +1287,8 @@ })); | ||
if (!flag.value) return; | ||
if (!checked.value.length) return; | ||
if (val === oldVal) return; | ||
getOption('depend'); | ||
// 更新依赖条件时不做改动 | ||
if (_depend !== __depend || _dependFields?.toString() !== __dependFields?.toString()) return; | ||
if (val === oldVal) return; | ||
if (!checked.value.length) return; | ||
updateCheckedValue(typeof checked.value === 'string' ? '' : []); | ||
getOption('depend'); | ||
})); | ||
@@ -1295,0 +1295,0 @@ unwatchs.push(vueDemi.watch(() => props.getOptions, getOption.bind(null, 'initial'), { |
@@ -1,2 +0,2 @@ | ||
var VueDemi=function(e,t,i){if(e.install)return e;if(!t)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if("2.7."===t.version.slice(0,4)){for(var n in t)e[n]=t[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.warn=t.util.warn,e.hasInjectionContext=()=>!!e.getCurrentInstance(),e.createApp=function(e,i){var n,r={},a={config:t.config,use:t.use.bind(t),mixin:t.mixin.bind(t),component:t.component.bind(t),provide:function(e,t){return r[e]=t,this},directive:function(e,i){return i?(t.directive(e,i),a):t.directive(e)},mount:function(a,u){return n||((n=new t(Object.assign({propsData:i},e,{provide:Object.assign(r,e.provide)}))).$mount(a,u),n)},unmount:function(){n&&(n.$destroy(),n=void 0)}};return a}}else if("2."===t.version.slice(0,2))if(i){for(var n in i)e[n]=i[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.hasInjectionContext=()=>!!e.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if("3."===t.version.slice(0,2)){for(var n in t)e[n]=t[n];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=t,e.Vue2=void 0,e.version=t.version,e.set=function(e,t,i){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,i),i):(e[t]=i,i)},e.del=function(e,t){Array.isArray(e)?e.splice(t,1):delete e[t]}}else console.error("[vue-demi] Vue version "+t.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(void 0!==VueDemi?VueDemi:{}),this.Vue||("undefined"!=typeof Vue?Vue:void 0),this.VueCompositionAPI||("undefined"!=typeof VueCompositionAPI?VueCompositionAPI:void 0));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoreCondition={},e.VueDemi)}(this,(function(e,t){"use strict";function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t,i=1;i<arguments.length;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},n.apply(this,arguments)}var r=["attrs","props","domProps"],a=["class","style","directives"],u=["on","nativeOn"],l=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},o=i((function(e){return e.reduce((function(e,t){for(var i in t)if(e[i])if(-1!==r.indexOf(i))e[i]=n({},e[i],t[i]);else if(-1!==a.indexOf(i)){var o=e[i]instanceof Array?e[i]:[e[i]],s=t[i]instanceof Array?t[i]:[t[i]];e[i]=[].concat(o,s)}else if(-1!==u.indexOf(i))for(var d in t[i])if(e[i][d]){var p=e[i][d]instanceof Array?e[i][d]:[e[i][d]],c=t[i][d]instanceof Array?t[i][d]:[t[i][d]];e[i][d]=[].concat(p,c)}else e[i][d]=t[i][d];else if("hook"===i)for(var f in t[i])e[i][f]=e[i][f]?l(e[i][f],t[i][f]):t[i][f];else e[i]=t[i];else e[i]=t[i];return e}),{})}));function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function d(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function p(e,t,i="children"){for(const n of e){if(t(n))return[n];if(n[i]?.length){const e=p(n[i],t);if(e.length)return e.unshift(n),e}}return[]}function c(e,t){return s(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const f="2.7"===t.version.slice(0,3),y=t.isVue2?"value":"modelValue",v={field:{type:String,required:!0},as:{type:String},emptyValue:{type:[String,null,void 0],default:void 0},resetToInitialValue:{type:[Boolean]},query:{type:Object,required:!0},backfill:{type:Object},disabled:{type:[Boolean,Function]},hide:{type:[Boolean,Function]},validator:{type:[Function]},defaultValue:{type:[String,Array,Function]},depend:{type:Boolean},dependFields:{type:[String,Array]}},h={tag:{type:[String,Object],default:"div"},resetToInitialValue:{type:Boolean},datum:{type:Object,default:()=>({})},backfill:{type:Object},realtime:{type:Boolean},immediateSearch:{type:Boolean},toast:{type:Function,default:()=>{}},searchAtDatumChanged:{type:Boolean}},g={...v,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},getOptions:{type:Function},filterMethod:{type:Function}},m={...v,inputNum:{type:Number,default:1,validator:e=>e>=1},fields:{type:Array},realtime:{type:Boolean},waitTime:{type:Number,default:300}},b={...v,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},V={...v,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},getOptions:{type:Function}},F={search:e=>!0},Q={...F,ready:e=>!0,reset:e=>!0},S={...F,blur:(...e)=>!0},k={...F,triggerSearch:()=>!0},C={...F},O={...F},w="condition-wrapper";var A=t.defineComponent({name:"CoreWrapper",props:h,emits:Q,setup(e,i){const n=[];t.onBeforeUnmount((()=>n.splice(0)));let r=!1,a=[];const u={realtime:t.toRef(e,"realtime"),register:i=>{n.push(i);const o=()=>{r=!0,i.reset().updateWrapperQuery();const o=n.indexOf(i);-1!==o&&n.splice(o,1),e.searchAtDatumChanged&&u.search(),r=!1,a.forEach((e=>t.del(l.value,e))),a=[]},s=t.getCurrentInstance();return s&&t.onBeforeUnmount(o,f?s.proxy:s),o},updateQueryValue:(e,i)=>(r&&a.push(e),t.set(l.value,e,i),u),insetSearch:()=>(e.realtime&&u.search(),u),search:s,removeUnreferencedField(e){let i=0;return n.some((t=>(t.getQuery().hasOwnProperty(e)&&(i+=1),i))),i||t.del(l.value,e),u}};t.provide(w,u);const l=t.ref({}),o=()=>({...e.backfill,...l.value});async function s(){const t=(await Promise.all(n.map((e=>e.validator?.(l.value))))).find((e=>e&&"string"==typeof e));if(t?e.toast(t):i.emit("search",o()),t)return t}function d(){n.forEach((e=>{e.reset().updateWrapperQuery()})),i.emit("reset",o())}return t.onMounted((()=>{e.immediateSearch&&i.emit("ready",o())})),{child:n,wrapperInstance:u,query:l,getQuery:o,querySearch:s,resetAndSearch:function(){d(),s()},reset:d}},render(){const{resetToInitialValue:e,backfill:i,query:n,getQuery:r,querySearch:a,resetAndSearch:u,reset:l}=this,d=this.tag,p=this.datum,f=c("default",this),y=c("btn",this),{class:v,style:h,...g}=this.$attrs,m=(t.isVue2,{});return s(this,"$listeners")&&(m.on=this.$listeners),t.h(d,o([{},m]),[Object.entries(p).map((([t,r])=>r?"function"==typeof f?f({...g,key:t,field:r.as||t,resetToInitialValue:e,backfill:i,query:n,...r}):f||"":void 0)),"function"==typeof y?y({search:a,getQuery:r,resetAndSearch:u,reset:l}):y])}});function q(e){const i=t.ref();return t.computed({set(e){i.value=e},get:()=>void 0===i.value?void 0!==e.defaultValue?"function"==typeof e.defaultValue?e.defaultValue(e.query,e.backfill):e.defaultValue:void 0:i.value})}function j(e,i){const n=t.ref("boolean"==typeof e.disabled&&e.disabled),r=t.ref("boolean"==typeof e.hide&&e.hide);return t.onBeforeUnmount(t.watch((()=>e.query),(()=>{if("function"==typeof e.hide){r.value!==e.hide(e.query)&&(r.value=e.hide(e.query),r.value&&i.reset().updateWrapperQuery())}else if("function"==typeof e.disabled){n.value!==e.disabled(e.query)&&(n.value=e.disabled(e.query))}}),{immediate:!0,deep:!0})),{insetDisabled:n,insetHide:r}}function W(e=!0){const i=t.ref(e);return{flag:i,updateFlag:()=>{i.value=!e,t.nextTick((()=>{i.value=e}))}}}var D=t.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:g,setup(e,i){const n=t.inject(w),r=q(e),a=e.backfill&&e.backfill[e.field],u=t.ref(a||(void 0!==e.defaultValue?r.value:e.multiple?[]:"").slice()),{flag:l,updateFlag:o}=W(),s=()=>({[e.field]:d(u.value,e.emptyValue)}),p={reset:C,updateWrapperQuery:()=>(n?.updateQueryValue(e.field,d(u.value,e.emptyValue)),p),get validator(){return e.validator},getQuery:s};n?.register(p);const{insetDisabled:c,insetHide:f}=j(e,p);!a&&e.defaultValue&&p.updateWrapperQuery();const y=t.ref([]),v=t.computed((()=>y.value.length?y.value:e.options)),h=t.ref(!1),g=t.ref([]),m=t.computed((()=>h.value?g.value:v.value)),b=t.computed((()=>e.filterMethod&&Q)),V=[];function F(t){e.getOptions?.((e=>{const t=u.value;u.value=void 0,y.value=e||[],u.value=t}),e.query||{},{trigger:t,change:(e,t)=>{t&&(r.value=e),k(e)},search:(e,t)=>{t&&(r.value=e),S(e),n?.search()}})}function Q(t){const{filterMethod:i}=e;""===t||void 0===t?(h.value=!1,g.value=[]):(h.value=!0,g.value=v.value.filter((e=>i(t,e))))}function S(e){e!==u.value&&(u.value=e,p.updateWrapperQuery())}function k(e){S(e),n?.insetSearch()}function C(){const{multiple:t}=e;return o(),u.value=e.resetToInitialValue&&r.value?.slice()||(t?[]:""),p}return t.onBeforeUnmount((()=>V.forEach((e=>e())))),V.push(t.watch((()=>e.field),((e,t)=>{e!==t&&n?.removeUnreferencedField(t),p.updateWrapperQuery()}))),V.push(t.watch((()=>[e.field,e.query[e.field]]),(([e,t],[i])=>{e===i&&t!==u.value&&(u.value=t)}))),V.push(t.watch((()=>[e.field,e.backfill?.[e.field]]),(([t,i],[n])=>{(t===n||e.backfill?.hasOwnProperty(t))&&(o(),S(i))}))),V.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([t,i,n],[r,a,o])=>{l.value&&void 0!==u.value&&""!==u.value.toString()&&t===r&&i?.toString()===a?.toString()&&n!==o&&(S(e.multiple?[]:""),F("depend"))}))),V.push(t.watch((()=>e.getOptions),F.bind(null,"initial"),{immediate:!0})),{checked:u,getQuery:s,insetDisabled:c,insetHide:f,finalOption:m,customFilterMethod:b,blur:function(){e.filterMethod&&Q("")},updateCheckedValue:S,change:k,reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:i,insetHide:n,finalOption:r,blur:a,customFilterMethod:u,change:l,reset:o,valueKey:d,labelKey:p,multiple:f}=this;if(n)return;const v=c("default",this),h=s(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof v?v({...this.$attrs,listeners:h,[y]:e,options:r,disabled:i,blur:a,filterMethod:u,change:l,valueKey:d,labelKey:p,multiple:f}):v}}),B=t.defineComponent({name:"CoreInput",props:m,setup(e,i){const n=t.inject(w),r=q(e),a=e.backfill&&e.backfill[e.field],u=t.ref([].concat(a||r.value||"")),{flag:l,updateFlag:o}=W(),s=()=>e.inputNum>1&&e.fields?e.fields.reduce(((t,i,n)=>(t[i]=d(u.value[n],e.emptyValue),t)),{}):{[e.field]:d(e.inputNum>1?u.value:u.value[0],e.emptyValue)},p={reset:h,updateWrapperQuery:()=>(n&&Object.entries(s()).forEach((([e,t])=>n.updateQueryValue(e,t))),p),get validator(){return e.validator},getQuery:s};n?.register(p);const{insetDisabled:c,insetHide:f}=j(e,p);!a&&e.defaultValue&&p.updateWrapperQuery();const y=[];t.onBeforeUnmount((()=>y.forEach((e=>e())))),y.push(t.watch((()=>e.inputNum>1&&e.fields?.length?e.fields:[e.field]),((e,t)=>{e.toString()!==t.toString()&&n&&t.forEach((e=>n.removeUnreferencedField(e))),p.updateWrapperQuery()}))),y.push(t.watch((()=>e.inputNum>1&&e.fields?.length?[e.fields,e.fields.map((t=>e.query[t]))]:[e.field,[e.query[e.field]]]),(([e,t],[i])=>{e.toString()===i.toString()&&t.toString()!==u.value.toString()&&(u.value=t)}))),y.push(t.watch((()=>e.inputNum>1&&e.fields?.length?e.fields.map((t=>e.backfill?.[t])):[e.backfill?.[e.field]]),(e=>{e.toString()!==u.value.toString()&&(o(),u.value=e,p.updateWrapperQuery())}))),y.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,i],[n,r,a])=>{l.value&&""!==u.value.toString()&&e===n&&t?.toString()===r?.toString()&&i!==a&&(u.value=[],p.updateWrapperQuery())})));let v=0;function h(){return o(),u.value=[].concat(e.resetToInitialValue&&r.value||""),p}return{checked:u,getQuery:s,insetDisabled:c,insetHide:f,debounceChange:function(i,r){const{realtime:a,waitTime:l}=e;t.set(u.value,r,i),u.value[r]=i,v&&clearTimeout(v),a||!n?.realtime.value?(p.updateWrapperQuery(),n?.insetSearch()):v=setTimeout((()=>(p.updateWrapperQuery(),n?.insetSearch())),l)},enterHandler:function(e,i){t.set(u.value,i,"string"==typeof e?e:e.target?.value||""),p.updateWrapperQuery(),n?.search()},reset:h}},render(){const{query:e,checked:t,getQuery:i,insetDisabled:n,insetHide:r,debounceChange:a,enterHandler:u,reset:l}=this;if(r)return;const o=c("default",this),d=s(this,"$listeners")?this.$listeners:null;return"function"==typeof o?o({...this.$attrs,listeners:d,[y]:t,disabled:n,debounceChange:a,enterHandler:u}):o}}),I=t.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:b,setup(e,i){const n=t.inject(w),r=q(e),a=e.backfill&&(e.range&&e.beginField&&e.endField?["",""]:e.backfill[e.field]),u=a&&("string"==typeof a?a:a.join("")),l=t.ref((u&&a||r.value||u||"").slice()),{flag:o,updateFlag:s}=W(),p=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:d(l.value[0],e.emptyValue),[e.endField]:d(l.value[1],e.emptyValue)}:{[e.field]:Array.isArray(l.value)?[...l.value]:d(l.value,e.emptyValue)},c={reset:g,updateWrapperQuery(){const{range:t,field:i,beginField:r,endField:a}=e;return t&&r&&a?(n?.updateQueryValue(r,d(l.value[0],e.emptyValue)),n?.updateQueryValue(a,d(l.value[1],e.emptyValue))):n?.updateQueryValue(i,d(l.value,e.emptyValue)),c},get validator(){return e.validator},getQuery:p};n?.register(c);const{insetDisabled:f,insetHide:y}=j(e,c);!u&&e.defaultValue&&c.updateWrapperQuery();const v=[];function h(t){const{range:i}=e;l.value=null===t?i?["",""]:"":t,c.updateWrapperQuery()}function g(){const{range:t}=e;return s(),l.value=e.resetToInitialValue&&r.value?.slice()||(t?["",""]:""),c}return t.onBeforeUnmount((()=>v.forEach((e=>e())))),v.push(t.watch((()=>e.field),((e,t)=>{e!==t&&n?.removeUnreferencedField(t),c.updateWrapperQuery()}))),v.push(t.watch((()=>e.range&&e.beginField&&e.endField?[!0,[e.beginField,e.query[e.beginField]],[e.endField,e.query[e.endField]]]:[!1,[e.field,e.query[e.field]]]),(([e,...t],[i,...n])=>{t.some(((e,t)=>e[0]!==n[t][0]))||(e?("string"==typeof l.value&&(l.value=[]),t.forEach(((e,t)=>{l.value[t]!==e[1]&&e[1]!==n[t][1]&&(l.value[t]=e[1]||"")}))):l.value!==t[0][1]&&t[0][1]!==n[0][1]&&(l.value=t[0][1]||""))}))),v.push(t.watch((()=>e.range&&e.beginField&&e.endField?[!0,e.backfill?.[e.beginField],e.backfill?.[e.endField]]:[!1,e.backfill?.[e.field]]),(([t,...i],[n,...r])=>{if(t){let e=!1;i.forEach(((t,i)=>{t!==r[i]&&(s(),"string"==typeof l.value&&(l.value=[]),l.value.splice(i,1),t&&l.value.splice(i,0,t),e=!0)})),e&&c.updateWrapperQuery()}else{if(i[0]===r[0])return;s(),l.value=d(i[0],e.emptyValue),c.updateWrapperQuery()}}))),v.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,i],[n,r,a])=>{o.value&&e===n&&t?.toString()===r?.toString()&&i!==a&&h(null)}))),{checked:l,getQuery:p,insetDisabled:f,insetHide:y,updateCheckedValue:h,change:function(e){h(e),n?.insetSearch()},reset:g}},render(){const{checked:e,getQuery:t,insetHide:i,insetDisabled:n,updateCheckedValue:r,change:a,reset:u}=this;if(i)return;const l=c("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof l?l({...this.$attrs,listeners:o,[y]:e,disabled:n,updateCheckedValue:r,change:a}):l}}),P=t.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:V,setup(e,i){const n=t.inject(w),r=q(e),a=t.ref([]),u=t.ref([]),l=t.computed((()=>u.value.length?u.value:e.options)),o=()=>g.value||r.value?e.fields?.length?e.fields.reduce(((e,t,i)=>Object.assign(e,{[t]:a.value[i]})),{}):{[e.field]:e.emitPath?[...a.value]:a.value.slice(-1)[0]}:{},{flag:s,updateFlag:c}=W(),f={reset:F,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:i,emitPath:r}=e;return i?.length?i.forEach(((t,i)=>{n?.updateQueryValue(t,d(a.value[i],e.emptyValue))})):n?.updateQueryValue(t,d(r?[...a.value]:a.value.slice(-1)[0],e.emptyValue)),f},getQuery:o};n?.register(f);const{insetDisabled:y,insetHide:v}=j(e,f),h=[];t.onBeforeUnmount((()=>h.forEach((e=>e()))));const g=t.ref("function"!=typeof e.getOptions||!!e.fields?.length);function m(t){e.getOptions?.((e=>{u.value=e||[],g.value=!0}),e.query||{},{trigger:t,change:(e,t)=>{t&&(r.value=e),V(e)},search:(e,t)=>{t&&(r.value=e),b(e),n?.search()}})}function b(e){const t=Array.isArray(e)?e:Q(e);t.join("")!==a.value.join("")&&(a.value=t,f.updateWrapperQuery())}function V(e){b(e),n?.insetSearch()}function F(){return c(),a.value=e.resetToInitialValue&&r.value?.slice()||[],f}function Q(t){if(!t&&0!==t)return[];const{valueKey:i,childrenKey:n}=e;return p(l.value,(e=>e[i]===t)).map((e=>e[i]),n)}return t.watch(g,(t=>t&&function(){const{backfill:t,field:i,fields:n}=e;if(t)if(n){const e=n.reduce(((e,i)=>(t[i]&&e.push(t[i]),e)),[]);if(e.length)return a.value=e,void f.updateWrapperQuery()}else if(t[i])return a.value=Q(t[i]),void f.updateWrapperQuery();r.value?.length&&(a.value="string"==typeof r.value?Q(r.value):r.value.slice(),"string"==typeof r.value&&(r.value=a.value.slice()),f.updateWrapperQuery())}()),{immediate:!0}),h.push(t.watch((()=>e.fields||[e.field]),((e,t)=>{e.toString()!==t.toString()&&n&&t.forEach((t=>e.includes(t)||n.removeUnreferencedField(t))),f.updateWrapperQuery()}))),h.push(t.watch((()=>[e.fields?.toString()||e.field,e.fields?.map((t=>e.query[t]))||e.field]),(([e,t],[i])=>{e===i&&(a.value="string"==typeof t?Q(t):t)}))),h.push(t.watch((()=>e.fields?.length?e.fields.reduce(((t,i)=>(e.backfill?.[i]&&t.push(e.backfill[i]),t)),[]):e.backfill?.[e.field]),(e=>{if(g.value)if(c(),Array.isArray(e))b(e);else{if(!e&&0!==e)return void(a.value.length&&(a.value=[]));b(Q(e))}}))),h.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,i],[n,r,u])=>{s.value&&a.value.length&&e===n&&t?.toString()===r?.toString()&&i!==u&&(b("string"==typeof a.value?"":[]),m("depend"))}))),h.push(t.watch((()=>e.getOptions),m.bind(null,"initial"),{immediate:!0})),{checked:a,getQuery:o,finalOption:l,insetDisabled:y,insetHide:v,change:V,reset:F}},render(){const{checked:e,getQuery:t,finalOption:i,insetHide:n,insetDisabled:r,change:a,reset:u}=this;if(n)return;const l=c("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof l?l({...this.$attrs,options:i,listeners:o,[y]:e,disabled:r,change:a}):l}});e.CoreCascader=P,e.CoreDatepicker=I,e.CoreInput=B,e.CoreSelect=D,e.CoreWrapper=A,e.cascaderEmits=O,e.cascaderProps=V,e.commonEmits=F,e.commonProps=v,e.datepickerEmits=C,e.datepickerProps=b,e.inputEmits=k,e.inputProps=m,e.provideKey=w,e.selectEmits=S,e.selectProps=g,e.wrapperEmits=Q,e.wrapperProps=h})); | ||
var VueDemi=function(e,t,i){if(e.install)return e;if(!t)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if("2.7."===t.version.slice(0,4)){for(var n in t)e[n]=t[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.warn=t.util.warn,e.hasInjectionContext=()=>!!e.getCurrentInstance(),e.createApp=function(e,i){var n,r={},a={config:t.config,use:t.use.bind(t),mixin:t.mixin.bind(t),component:t.component.bind(t),provide:function(e,t){return r[e]=t,this},directive:function(e,i){return i?(t.directive(e,i),a):t.directive(e)},mount:function(a,u){return n||((n=new t(Object.assign({propsData:i},e,{provide:Object.assign(r,e.provide)}))).$mount(a,u),n)},unmount:function(){n&&(n.$destroy(),n=void 0)}};return a}}else if("2."===t.version.slice(0,2))if(i){for(var n in i)e[n]=i[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.hasInjectionContext=()=>!!e.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if("3."===t.version.slice(0,2)){for(var n in t)e[n]=t[n];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=t,e.Vue2=void 0,e.version=t.version,e.set=function(e,t,i){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,i),i):(e[t]=i,i)},e.del=function(e,t){Array.isArray(e)?e.splice(t,1):delete e[t]}}else console.error("[vue-demi] Vue version "+t.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(void 0!==VueDemi?VueDemi:{}),this.Vue||("undefined"!=typeof Vue?Vue:void 0),this.VueCompositionAPI||("undefined"!=typeof VueCompositionAPI?VueCompositionAPI:void 0));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoreCondition={},e.VueDemi)}(this,(function(e,t){"use strict";function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t,i=1;i<arguments.length;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},n.apply(this,arguments)}var r=["attrs","props","domProps"],a=["class","style","directives"],u=["on","nativeOn"],l=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},o=i((function(e){return e.reduce((function(e,t){for(var i in t)if(e[i])if(-1!==r.indexOf(i))e[i]=n({},e[i],t[i]);else if(-1!==a.indexOf(i)){var o=e[i]instanceof Array?e[i]:[e[i]],s=t[i]instanceof Array?t[i]:[t[i]];e[i]=[].concat(o,s)}else if(-1!==u.indexOf(i))for(var d in t[i])if(e[i][d]){var p=e[i][d]instanceof Array?e[i][d]:[e[i][d]],c=t[i][d]instanceof Array?t[i][d]:[t[i][d]];e[i][d]=[].concat(p,c)}else e[i][d]=t[i][d];else if("hook"===i)for(var f in t[i])e[i][f]=e[i][f]?l(e[i][f],t[i][f]):t[i][f];else e[i]=t[i];else e[i]=t[i];return e}),{})}));function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function d(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function p(e,t,i="children"){for(const n of e){if(t(n))return[n];if(n[i]?.length){const e=p(n[i],t);if(e.length)return e.unshift(n),e}}return[]}function c(e,t){return s(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const f="2.7"===t.version.slice(0,3),y=t.isVue2?"value":"modelValue",v={field:{type:String,required:!0},as:{type:String},emptyValue:{type:[String,null,void 0],default:void 0},resetToInitialValue:{type:[Boolean]},query:{type:Object,required:!0},backfill:{type:Object},disabled:{type:[Boolean,Function]},hide:{type:[Boolean,Function]},validator:{type:[Function]},defaultValue:{type:[String,Array,Function]},depend:{type:Boolean},dependFields:{type:[String,Array]}},h={tag:{type:[String,Object],default:"div"},resetToInitialValue:{type:Boolean},datum:{type:Object,default:()=>({})},backfill:{type:Object},realtime:{type:Boolean},immediateSearch:{type:Boolean},toast:{type:Function,default:()=>{}},searchAtDatumChanged:{type:Boolean}},g={...v,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},getOptions:{type:Function},filterMethod:{type:Function}},m={...v,inputNum:{type:Number,default:1,validator:e=>e>=1},fields:{type:Array},realtime:{type:Boolean},waitTime:{type:Number,default:300}},b={...v,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},V={...v,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},getOptions:{type:Function}},F={search:e=>!0},Q={...F,ready:e=>!0,reset:e=>!0},S={...F,blur:(...e)=>!0},k={...F,triggerSearch:()=>!0},C={...F},O={...F},w="condition-wrapper";var A=t.defineComponent({name:"CoreWrapper",props:h,emits:Q,setup(e,i){const n=[];t.onBeforeUnmount((()=>n.splice(0)));let r=!1,a=[];const u={realtime:t.toRef(e,"realtime"),register:i=>{n.push(i);const o=()=>{r=!0,i.reset().updateWrapperQuery();const o=n.indexOf(i);-1!==o&&n.splice(o,1),e.searchAtDatumChanged&&u.search(),r=!1,a.forEach((e=>t.del(l.value,e))),a=[]},s=t.getCurrentInstance();return s&&t.onBeforeUnmount(o,f?s.proxy:s),o},updateQueryValue:(e,i)=>(r&&a.push(e),t.set(l.value,e,i),u),insetSearch:()=>(e.realtime&&u.search(),u),search:s,removeUnreferencedField(e){let i=0;return n.some((t=>(t.getQuery().hasOwnProperty(e)&&(i+=1),i))),i||t.del(l.value,e),u}};t.provide(w,u);const l=t.ref({}),o=()=>({...e.backfill,...l.value});async function s(){const t=(await Promise.all(n.map((e=>e.validator?.(l.value))))).find((e=>e&&"string"==typeof e));if(t?e.toast(t):i.emit("search",o()),t)return t}function d(){n.forEach((e=>{e.reset().updateWrapperQuery()})),i.emit("reset",o())}return t.onMounted((()=>{e.immediateSearch&&i.emit("ready",o())})),{child:n,wrapperInstance:u,query:l,getQuery:o,querySearch:s,resetAndSearch:function(){d(),s()},reset:d}},render(){const{resetToInitialValue:e,backfill:i,query:n,getQuery:r,querySearch:a,resetAndSearch:u,reset:l}=this,d=this.tag,p=this.datum,f=c("default",this),y=c("btn",this),{class:v,style:h,...g}=this.$attrs,m=(t.isVue2,{});return s(this,"$listeners")&&(m.on=this.$listeners),t.h(d,o([{},m]),[Object.entries(p).map((([t,r])=>r?"function"==typeof f?f({...g,key:t,field:r.as||t,resetToInitialValue:e,backfill:i,query:n,...r}):f||"":void 0)),"function"==typeof y?y({search:a,getQuery:r,resetAndSearch:u,reset:l}):y])}});function q(e){const i=t.ref();return t.computed({set(e){i.value=e},get:()=>void 0===i.value?void 0!==e.defaultValue?"function"==typeof e.defaultValue?e.defaultValue(e.query,e.backfill):e.defaultValue:void 0:i.value})}function j(e,i){const n=t.ref("boolean"==typeof e.disabled&&e.disabled),r=t.ref("boolean"==typeof e.hide&&e.hide);return t.onBeforeUnmount(t.watch((()=>e.query),(()=>{if("function"==typeof e.hide){r.value!==e.hide(e.query)&&(r.value=e.hide(e.query),r.value&&i.reset().updateWrapperQuery())}else if("function"==typeof e.disabled){n.value!==e.disabled(e.query)&&(n.value=e.disabled(e.query))}}),{immediate:!0,deep:!0})),{insetDisabled:n,insetHide:r}}function W(e=!0){const i=t.ref(e);return{flag:i,updateFlag:()=>{i.value=!e,t.nextTick((()=>{i.value=e}))}}}var D=t.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:g,setup(e,i){const n=t.inject(w),r=q(e),a=e.backfill&&e.backfill[e.field],u=t.ref(a||(void 0!==e.defaultValue?r.value:e.multiple?[]:"").slice()),{flag:l,updateFlag:o}=W(),s=()=>({[e.field]:d(u.value,e.emptyValue)}),p={reset:C,updateWrapperQuery:()=>(n?.updateQueryValue(e.field,d(u.value,e.emptyValue)),p),get validator(){return e.validator},getQuery:s};n?.register(p);const{insetDisabled:c,insetHide:f}=j(e,p);!a&&e.defaultValue&&p.updateWrapperQuery();const y=t.ref([]),v=t.computed((()=>y.value.length?y.value:e.options)),h=t.ref(!1),g=t.ref([]),m=t.computed((()=>h.value?g.value:v.value)),b=t.computed((()=>e.filterMethod&&Q)),V=[];function F(t){e.getOptions?.((e=>{const t=u.value;u.value=void 0,y.value=e||[],u.value=t}),e.query||{},{trigger:t,change:(e,t)=>{t&&(r.value=e),k(e)},search:(e,t)=>{t&&(r.value=e),S(e),n?.search()}})}function Q(t){const{filterMethod:i}=e;""===t||void 0===t?(h.value=!1,g.value=[]):(h.value=!0,g.value=v.value.filter((e=>i(t,e))))}function S(e){e!==u.value&&(u.value=e,p.updateWrapperQuery())}function k(e){S(e),n?.insetSearch()}function C(){const{multiple:t}=e;return o(),u.value=e.resetToInitialValue&&r.value?.slice()||(t?[]:""),p}return t.onBeforeUnmount((()=>V.forEach((e=>e())))),V.push(t.watch((()=>e.field),((e,t)=>{e!==t&&n?.removeUnreferencedField(t),p.updateWrapperQuery()}))),V.push(t.watch((()=>[e.field,e.query[e.field]]),(([e,t],[i])=>{e===i&&t!==u.value&&(u.value=t)}))),V.push(t.watch((()=>[e.field,e.backfill?.[e.field]]),(([t,i],[n])=>{(t===n||e.backfill?.hasOwnProperty(t))&&(o(),S(i))}))),V.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([t,i,n],[r,a,o])=>{l.value&&n!==o&&(F("depend"),t===r&&i?.toString()===a?.toString()&&void 0!==u.value&&""!==u.value.toString()&&S(e.multiple?[]:""))}))),V.push(t.watch((()=>e.getOptions),F.bind(null,"initial"),{immediate:!0})),{checked:u,getQuery:s,insetDisabled:c,insetHide:f,finalOption:m,customFilterMethod:b,blur:function(){e.filterMethod&&Q("")},updateCheckedValue:S,change:k,reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:i,insetHide:n,finalOption:r,blur:a,customFilterMethod:u,change:l,reset:o,valueKey:d,labelKey:p,multiple:f}=this;if(n)return;const v=c("default",this),h=s(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof v?v({...this.$attrs,listeners:h,[y]:e,options:r,disabled:i,blur:a,filterMethod:u,change:l,valueKey:d,labelKey:p,multiple:f}):v}}),B=t.defineComponent({name:"CoreInput",props:m,setup(e,i){const n=t.inject(w),r=q(e),a=e.backfill&&e.backfill[e.field],u=t.ref([].concat(a||r.value||"")),{flag:l,updateFlag:o}=W(),s=()=>e.inputNum>1&&e.fields?e.fields.reduce(((t,i,n)=>(t[i]=d(u.value[n],e.emptyValue),t)),{}):{[e.field]:d(e.inputNum>1?u.value:u.value[0],e.emptyValue)},p={reset:h,updateWrapperQuery:()=>(n&&Object.entries(s()).forEach((([e,t])=>n.updateQueryValue(e,t))),p),get validator(){return e.validator},getQuery:s};n?.register(p);const{insetDisabled:c,insetHide:f}=j(e,p);!a&&e.defaultValue&&p.updateWrapperQuery();const y=[];t.onBeforeUnmount((()=>y.forEach((e=>e())))),y.push(t.watch((()=>e.inputNum>1&&e.fields?.length?e.fields:[e.field]),((e,t)=>{e.toString()!==t.toString()&&n&&t.forEach((e=>n.removeUnreferencedField(e))),p.updateWrapperQuery()}))),y.push(t.watch((()=>e.inputNum>1&&e.fields?.length?[e.fields,e.fields.map((t=>e.query[t]))]:[e.field,[e.query[e.field]]]),(([e,t],[i])=>{e.toString()===i.toString()&&t.toString()!==u.value.toString()&&(u.value=t)}))),y.push(t.watch((()=>e.inputNum>1&&e.fields?.length?e.fields.map((t=>e.backfill?.[t])):[e.backfill?.[e.field]]),(e=>{e.toString()!==u.value.toString()&&(o(),u.value=e,p.updateWrapperQuery())}))),y.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,i],[n,r,a])=>{l.value&&i!==a&&e===n&&t?.toString()===r?.toString()&&""!==u.value.toString()&&(u.value=[],p.updateWrapperQuery())})));let v=0;function h(){return o(),u.value=[].concat(e.resetToInitialValue&&r.value||""),p}return{checked:u,getQuery:s,insetDisabled:c,insetHide:f,debounceChange:function(i,r){const{realtime:a,waitTime:l}=e;t.set(u.value,r,i),u.value[r]=i,v&&clearTimeout(v),a||!n?.realtime.value?(p.updateWrapperQuery(),n?.insetSearch()):v=setTimeout((()=>(p.updateWrapperQuery(),n?.insetSearch())),l)},enterHandler:function(e,i){t.set(u.value,i,"string"==typeof e?e:e.target?.value||""),p.updateWrapperQuery(),n?.search()},reset:h}},render(){const{query:e,checked:t,getQuery:i,insetDisabled:n,insetHide:r,debounceChange:a,enterHandler:u,reset:l}=this;if(r)return;const o=c("default",this),d=s(this,"$listeners")?this.$listeners:null;return"function"==typeof o?o({...this.$attrs,listeners:d,[y]:t,disabled:n,debounceChange:a,enterHandler:u}):o}}),I=t.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:b,setup(e,i){const n=t.inject(w),r=q(e),a=e.backfill&&(e.range&&e.beginField&&e.endField?["",""]:e.backfill[e.field]),u=a&&("string"==typeof a?a:a.join("")),l=t.ref((u&&a||r.value||u||"").slice()),{flag:o,updateFlag:s}=W(),p=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:d(l.value[0],e.emptyValue),[e.endField]:d(l.value[1],e.emptyValue)}:{[e.field]:Array.isArray(l.value)?[...l.value]:d(l.value,e.emptyValue)},c={reset:g,updateWrapperQuery(){const{range:t,field:i,beginField:r,endField:a}=e;return t&&r&&a?(n?.updateQueryValue(r,d(l.value[0],e.emptyValue)),n?.updateQueryValue(a,d(l.value[1],e.emptyValue))):n?.updateQueryValue(i,d(l.value,e.emptyValue)),c},get validator(){return e.validator},getQuery:p};n?.register(c);const{insetDisabled:f,insetHide:y}=j(e,c);!u&&e.defaultValue&&c.updateWrapperQuery();const v=[];function h(t){const{range:i}=e;l.value=null===t?i?["",""]:"":t,c.updateWrapperQuery()}function g(){const{range:t}=e;return s(),l.value=e.resetToInitialValue&&r.value?.slice()||(t?["",""]:""),c}return t.onBeforeUnmount((()=>v.forEach((e=>e())))),v.push(t.watch((()=>e.field),((e,t)=>{e!==t&&n?.removeUnreferencedField(t),c.updateWrapperQuery()}))),v.push(t.watch((()=>e.range&&e.beginField&&e.endField?[!0,[e.beginField,e.query[e.beginField]],[e.endField,e.query[e.endField]]]:[!1,[e.field,e.query[e.field]]]),(([e,...t],[i,...n])=>{t.some(((e,t)=>e[0]!==n[t][0]))||(e?("string"==typeof l.value&&(l.value=[]),t.forEach(((e,t)=>{l.value[t]!==e[1]&&e[1]!==n[t][1]&&(l.value[t]=e[1]||"")}))):l.value!==t[0][1]&&t[0][1]!==n[0][1]&&(l.value=t[0][1]||""))}))),v.push(t.watch((()=>e.range&&e.beginField&&e.endField?[!0,e.backfill?.[e.beginField],e.backfill?.[e.endField]]:[!1,e.backfill?.[e.field]]),(([t,...i],[n,...r])=>{if(t){let e=!1;i.forEach(((t,i)=>{t!==r[i]&&(s(),"string"==typeof l.value&&(l.value=[]),l.value.splice(i,1),t&&l.value.splice(i,0,t),e=!0)})),e&&c.updateWrapperQuery()}else{if(i[0]===r[0])return;s(),l.value=d(i[0],e.emptyValue),c.updateWrapperQuery()}}))),v.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,i],[n,r,a])=>{o.value&&i!==a&&e===n&&t?.toString()===r?.toString()&&h(null)}))),{checked:l,getQuery:p,insetDisabled:f,insetHide:y,updateCheckedValue:h,change:function(e){h(e),n?.insetSearch()},reset:g}},render(){const{checked:e,getQuery:t,insetHide:i,insetDisabled:n,updateCheckedValue:r,change:a,reset:u}=this;if(i)return;const l=c("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof l?l({...this.$attrs,listeners:o,[y]:e,disabled:n,updateCheckedValue:r,change:a}):l}}),P=t.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:V,setup(e,i){const n=t.inject(w),r=q(e),a=t.ref([]),u=t.ref([]),l=t.computed((()=>u.value.length?u.value:e.options)),o=()=>g.value||r.value?e.fields?.length?e.fields.reduce(((e,t,i)=>Object.assign(e,{[t]:a.value[i]})),{}):{[e.field]:e.emitPath?[...a.value]:a.value.slice(-1)[0]}:{},{flag:s,updateFlag:c}=W(),f={reset:F,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:i,emitPath:r}=e;return i?.length?i.forEach(((t,i)=>{n?.updateQueryValue(t,d(a.value[i],e.emptyValue))})):n?.updateQueryValue(t,d(r?[...a.value]:a.value.slice(-1)[0],e.emptyValue)),f},getQuery:o};n?.register(f);const{insetDisabled:y,insetHide:v}=j(e,f),h=[];t.onBeforeUnmount((()=>h.forEach((e=>e()))));const g=t.ref("function"!=typeof e.getOptions||!!e.fields?.length);function m(t){e.getOptions?.((e=>{u.value=e||[],g.value=!0}),e.query||{},{trigger:t,change:(e,t)=>{t&&(r.value=e),V(e)},search:(e,t)=>{t&&(r.value=e),b(e),n?.search()}})}function b(e){const t=Array.isArray(e)?e:Q(e);t.join("")!==a.value.join("")&&(a.value=t,f.updateWrapperQuery())}function V(e){b(e),n?.insetSearch()}function F(){return c(),a.value=e.resetToInitialValue&&r.value?.slice()||[],f}function Q(t){if(!t&&0!==t)return[];const{valueKey:i,childrenKey:n}=e;return p(l.value,(e=>e[i]===t)).map((e=>e[i]),n)}return t.watch(g,(t=>t&&function(){const{backfill:t,field:i,fields:n}=e;if(t)if(n){const e=n.reduce(((e,i)=>(t[i]&&e.push(t[i]),e)),[]);if(e.length)return a.value=e,void f.updateWrapperQuery()}else if(t[i])return a.value=Q(t[i]),void f.updateWrapperQuery();r.value?.length&&(a.value="string"==typeof r.value?Q(r.value):r.value.slice(),"string"==typeof r.value&&(r.value=a.value.slice()),f.updateWrapperQuery())}()),{immediate:!0}),h.push(t.watch((()=>e.fields||[e.field]),((e,t)=>{e.toString()!==t.toString()&&n&&t.forEach((t=>e.includes(t)||n.removeUnreferencedField(t))),f.updateWrapperQuery()}))),h.push(t.watch((()=>[e.fields?.toString()||e.field,e.fields?.map((t=>e.query[t]))||e.field]),(([e,t],[i])=>{e===i&&(a.value="string"==typeof t?Q(t):t)}))),h.push(t.watch((()=>e.fields?.length?e.fields.reduce(((t,i)=>(e.backfill?.[i]&&t.push(e.backfill[i]),t)),[]):e.backfill?.[e.field]),(e=>{if(g.value)if(c(),Array.isArray(e))b(e);else{if(!e&&0!==e)return void(a.value.length&&(a.value=[]));b(Q(e))}}))),h.push(t.watch((()=>[e.depend,e.dependFields,e.dependFields&&[].concat(e.dependFields).map((t=>e.query?.[t])).join(",")||""]),(([e,t,i],[n,r,u])=>{s.value&&i!==u&&(m("depend"),e===n&&t?.toString()===r?.toString()&&a.value.length&&b("string"==typeof a.value?"":[]))}))),h.push(t.watch((()=>e.getOptions),m.bind(null,"initial"),{immediate:!0})),{checked:a,getQuery:o,finalOption:l,insetDisabled:y,insetHide:v,change:V,reset:F}},render(){const{checked:e,getQuery:t,finalOption:i,insetHide:n,insetDisabled:r,change:a,reset:u}=this;if(n)return;const l=c("default",this),o=s(this,"$listeners")?this.$listeners:null;return"function"==typeof l?l({...this.$attrs,options:i,listeners:o,[y]:e,disabled:r,change:a}):l}});e.CoreCascader=P,e.CoreDatepicker=I,e.CoreInput=B,e.CoreSelect=D,e.CoreWrapper=A,e.cascaderEmits=O,e.cascaderProps=V,e.commonEmits=F,e.commonProps=v,e.datepickerEmits=C,e.datepickerProps=b,e.inputEmits=k,e.inputProps=m,e.provideKey=w,e.selectEmits=S,e.selectProps=g,e.wrapperEmits=Q,e.wrapperProps=h})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@xiaohaih/condition-core", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
615331