Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xiaohaih/condition-core

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xiaohaih/condition-core - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

16

dist/index.cjs.js

@@ -949,3 +949,5 @@ 'use strict';

backfill: BACKFILL,
getOptions: GET_OPTIONS
getOptions: GET_OPTIONS,
depend: DEPEND,
dependFields: DEPEND_FIELDS
} = props;

@@ -1014,3 +1016,3 @@ const DATA_ASYNC = {

if (Array.isArray(value)) {
if (value.join('') === checked.value.join('')) return;
// if (value.join('') === checked.value.join('')) return;
updateCheckedValue(value);

@@ -1032,2 +1034,12 @@ } else {

}));
if (DEPEND && DEPEND_FIELDS && DEPEND_FIELDS.length) {
// 存在依赖项
unwatchs.push(vueDemi.watch(() => [].concat(DEPEND_FIELDS).map(k => props.query?.[k]).join(','), (val, oldVal) => {
if (val === oldVal) return;
updateCheckedValue(typeof checked.value === 'string' ? '' : []);
getOption();
}, {
deep: true
}));
}
/**

@@ -1034,0 +1046,0 @@ * 获取数据源发生变化事件

2

dist/index.cjs.min.js

@@ -1,2 +0,2 @@

"use strict";var e=require("vue-demi");function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t,i=1;i<arguments.length;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},t.apply(this,arguments)}var i=["attrs","props","domProps"],r=["class","style","directives"],a=["on","nativeOn"],n=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},l=function(e){return e.reduce((function(e,l){for(var u in l)if(e[u])if(-1!==i.indexOf(u))e[u]=t({},e[u],l[u]);else if(-1!==r.indexOf(u)){var s=e[u]instanceof Array?e[u]:[e[u]],o=l[u]instanceof Array?l[u]:[l[u]];e[u]=[].concat(s,o)}else if(-1!==a.indexOf(u))for(var d in l[u])if(e[u][d]){var p=e[u][d]instanceof Array?e[u][d]:[e[u][d]],c=l[u][d]instanceof Array?l[u][d]:[l[u][d]];e[u][d]=[].concat(p,c)}else e[u][d]=l[u][d];else if("hook"===u)for(var f in l[u])e[u][f]=e[u][f]?n(e[u][f],l[u][f]):l[u][f];else e[u]=l[u];else e[u]=l[u];return e}),{})};function u(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function o(e,t,i="children"){for(const r of e){if(t(r))return[r];if(r[i]?.length){const e=o(r[i],t);if(e.length)return e.unshift(r),e}}return[]}function d(e,t){return u(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const p={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]}},c={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:()=>{}}},f={...p,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function},filterMethod:{type:Function}},y={...p,realtime:{type:Boolean},waitTime:{type:Number,default:300}},h={...p,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},v={...p,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function}},m={search:e=>{},ready:e=>{}},g="condition-wrapper";var b=e.defineComponent({inheritAttrs:!1,name:"CoreWrapper",props:c,emits:m,setup(t,i){const r=[];e.onBeforeUnmount((()=>r.splice(0)));const a={realtime:e.toRef(t,"realtime"),register:t=>{r.push(t);const i=()=>{t.reset().updateWrapperQuery();const e=r.indexOf(t);-1!==e&&r.splice(e,1)},a=e.getCurrentInstance();return a&&e.onBeforeUnmount(i,a.proxy||a),i},updateQueryValue:(t,i)=>(e.set(n.value,t,i),a),insetSearch:()=>(t.realtime&&a.search(),a),search:s};e.provide(g,a);const n=e.ref({}),l=()=>({...n.value});function u(){const{backfill:e}=t;n.value={...e}}async function s(){const e=(await Promise.all(r.map((e=>e.validator?.(n.value))))).find((e=>e&&"string"==typeof e));if(e?t.toast(e):i.emit("search",l()),e)return e}function o(){r.forEach((e=>{e.reset().updateWrapperQuery()}))}return e.watch((()=>t.datum),e.nextTick.bind(null,u),{immediate:!0}),e.watch((()=>t.backfill),(t=>e.set(n,"value",{...t})),{immediate:!0}),e.onMounted((()=>{u(),t.immediateSearch&&i.emit("ready",l())})),{child:r,wrapperInstance:a,query:n,getQuery:l,initQuery:u,querySearch:s,resetAndSearch:function(){o(),s()},reset:o}},render(){const e=arguments[0],{resetToInitialValue:t,backfill:i,query:r,getQuery:a,initQuery:n,querySearch:s,resetAndSearch:o,reset:p}=this,c=this.tag,f=this.datum,y=d("default",this),h=d("btn",this),{class:v,style:m,...g}=this.$attrs,b={attrs:{class:v,style:m}};return u(this,"$listeners")&&(b.on=this.$listeners),e(c,l([{},b]),[Object.entries(f).map((([e,a])=>"function"==typeof y?y({...g,key:e,field:a.as||e,resetToInitialValue:t,backfill:i,query:r,...a}):y||"")),"function"==typeof h?h({search:s,getQuery:a,resetAndSearch:o,reset:p}):h])}});function Q(t,i){const r=e.ref("boolean"==typeof t.disabled&&t.disabled),a=e.ref("boolean"==typeof t.hide&&t.hide);return e.onBeforeUnmount(e.watch((()=>t.query),(()=>{if("function"==typeof t.hide){a.value!==t.hide(t.query)&&(a.value=t.hide(t.query),a.value&&i.reset().updateWrapperQuery())}else if("function"==typeof t.disabled){r.value!==t.disabled(t.query)&&(r.value=t.disabled(t.query))}}),{immediate:!0,deep:!0})),{insetDisabled:r,insetHide:a}}var V=e.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:f,setup(t,i){const{field:r,depend:a,dependFields:n}=t,l=e.inject(g),u=e.ref(t.multiple?[]:""),o=()=>({[t.field]:s(u.value,t.emptyValue)}),d=t.backfill?.[r]||u.value,p=e.ref([]),c=e.computed((()=>p.value.length?p.value:t.options)),f=e.ref(!1),y=e.ref([]),h=e.computed((()=>f.value?y.value:c.value)),v=e.computed((()=>t.filterMethod&&O)),m={reset:C,updateWrapperQuery:()=>(l?.updateQueryValue(t.field,s(u.value,t.emptyValue)),m),get validator(){return t.validator},getQuery:o};l?.register(m);const{insetDisabled:b,insetHide:V}=Q(t,m),k=[];function A(){t.getOptions?.((e=>{const t=u.value;u.value=void 0,p.value=e||[],u.value=t}),t.query||{})}function O(e){const{filterMethod:i}=t;""===e||void 0===e?(f.value=!1,y.value=[]):(f.value=!0,y.value=c.value.filter((t=>i(e,t))))}function S(e){e!==u.value&&(u.value=e,m.updateWrapperQuery())}function C(){const{multiple:e}=t;return u.value=t.resetToInitialValue?d:e?[]:"",m}return e.onBeforeUnmount((()=>k.forEach((e=>e())))),k.push(e.watch((()=>t.backfill?.[r]),S,{immediate:!0,deep:!0})),k.push(e.watch((()=>t.getOptions),A,{immediate:!0})),a&&n&&n.length&&k.push(e.watch((()=>[].concat(n).map((e=>t.query?.[e])).join(",")),((e,i)=>{e!==i&&(S(t.multiple?[]:""),A())}),{deep:!0,immediate:!0})),{checked:u,getQuery:o,insetDisabled:b,insetHide:V,finalOption:h,customFilterMethod:v,blur:function(){t.filterMethod&&O("")},updateCheckedValue:S,change:function(e){S(e),l?.insetSearch()},reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:i,insetHide:r,finalOption:a,blur:n,customFilterMethod:l,change:s,reset:o,valueKey:p,labelKey:c,multiple:f}=this;if(r)return;const y=d("default",this),h=u(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof y?y({...this.$attrs,listeners:h,value:e,options:a,disabled:i,blur:n,filterMethod:l,change:s,valueKey:p,labelKey:c,multiple:f}):y}}),k=e.defineComponent({inheritAttrs:!1,name:"CoreInput",props:y,setup(t,i){const{field:r}=t,a=e.inject(g),n=e.ref(""),l=()=>({[t.field]:s(n.value,t.emptyValue)}),u=t.backfill?.[r]||n.value,o={reset:y,updateWrapperQuery:()=>(a?.updateQueryValue(t.field,s(n.value,t.emptyValue)),o),get validator(){return t.validator},getQuery:l};a?.register(o);const{insetDisabled:d,insetHide:p}=Q(t,o),c=[];e.onBeforeUnmount((()=>c.forEach((e=>e())))),c.push(e.watch((()=>t.backfill?.[r]),(e=>{e!==n.value&&(n.value=e,o.updateWrapperQuery())}),{immediate:!0,deep:!0}));let f=0;function y(){return n.value=t.resetToInitialValue?u:"",o}return{checked:n,getQuery:l,insetDisabled:d,insetHide:p,debounceChange:function(e){const{realtime:i,waitTime:r}=t;n.value=e,f&&clearTimeout(f),i||!a?.realtime.value?(o.updateWrapperQuery(),a?.insetSearch()):f=setTimeout((()=>(o.updateWrapperQuery(),a?.insetSearch())),r)},enterHandler:function(e){n.value="string"==typeof e?e:e.target?.value||"",o.updateWrapperQuery(),a?.search()},reset:y}},render(){const{query:e,checked:t,getQuery:i,insetDisabled:r,insetHide:a,debounceChange:n,enterHandler:l,reset:s}=this;if(a)return;const o=d("default",this),p=u(this,"$listeners")?this.$listeners:null;return"function"==typeof o?o({...this.$attrs,listeners:p,value:t,disabled:r,debounceChange:n,enterHandler:l}):o}}),A=e.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:h,setup(t,i){const{field:r,range:a,beginField:n,endField:l}=t,u=e.inject(g),o=e.ref(a&&n&&l?["",""]:""),d=()=>t.range&&t.beginField&&t.endField?{[t.beginField]:s(o.value[0],t.emptyValue),[t.endField]:s(o.value[1],t.emptyValue)}:{[t.field]:Array.isArray(o.value)?[...o.value]:s(o.value,t.emptyValue)},p=(a&&n&&l?[t.backfill?.[n]||"",t.backfill?.[l]||""]:t.backfill?.[r])||"",c={reset:m,updateWrapperQuery(){const{range:e,field:i,beginField:r,endField:a}=t;return e&&r&&a?(u?.updateQueryValue(r,s(o.value[0],t.emptyValue)),u?.updateQueryValue(a,s(o.value[1],t.emptyValue))):u?.updateQueryValue(i,s(o.value,t.emptyValue)),c},get validator(){return t.validator},getQuery:d};u?.register(c);const{insetDisabled:f,insetHide:y}=Q(t,c),h=[];function v(e){const{range:i}=t;o.value=null===e?i?["",""]:"":e,c.updateWrapperQuery()}function m(){const{range:e}=t;return o.value=t.resetToInitialValue?p:e?["",""]:"",c}return e.onBeforeUnmount((()=>h.forEach((e=>e())))),a&&n&&l?(h.push(e.watch((()=>t.backfill?.[n]),(e=>{"string"==typeof o.value&&(o.value=[]),o.value.splice(0,1),e&&o.value.splice(0,0,e),c.updateWrapperQuery()}),{immediate:!0})),h.push(e.watch((()=>t.backfill?.[l]),(e=>{"string"==typeof o.value&&(o.value=[]),o.value.splice(1,1),e&&o.value.splice(1,0,e),c.updateWrapperQuery()}),{immediate:!0}))):h.push(e.watch((()=>t.backfill?.[r]),(e=>{o.value=s(e,t.emptyValue),c.updateWrapperQuery()}),{immediate:!0,deep:!0})),{checked:o,getQuery:d,insetDisabled:f,insetHide:y,updateCheckedValue:v,change:function(e){v(e),u?.insetSearch()},reset:m}},render(){const{checked:e,getQuery:t,insetHide:i,insetDisabled:r,updateCheckedValue:a,change:n,reset:l}=this;if(i)return;const s=d("default",this),o=u(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,listeners:o,value:e,disabled:r,updateCheckedValue:a,change:n}):s}});var O=e.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:v,setup(t,i){const{field:r,fields:a,backfill:n,getOptions:l}=t,u={initialize:!(d=n?.[r],(Array.isArray(d)?!d.length:d||0===d)&&"function"==typeof l),initialValue:n?.[r]};var d;const p=e.inject(g),c=e.ref([]),f=()=>a?.length?a.reduce(((e,t,i)=>Object.assign(e,{[t]:c.value[i]})),{}):{[r]:t.emitPath?[...c.value]:c.value.slice(-1)[0]},y=e.ref([]),h=e.computed((()=>y.value.length?y.value:t.options));let v=a?.length?a.reduce(((e,t)=>(n?.[t]&&e.push(n[t]),e)),[]):Array.isArray(n?.[r])?n[r]:u.initialize?S(n?.[r]):[];const m={reset:O,get validator(){return t.validator},updateWrapperQuery(){const{field:e,fields:i,emitPath:r}=t;return u.initialize?i?.length?i.forEach(((e,i)=>{p?.updateQueryValue(e,s(c.value[i],t.emptyValue))})):p?.updateQueryValue(e,s(r?[...c.value]:c.value.slice(-1)[0],t.emptyValue)):p?.updateQueryValue(e,u.initialValue),m},getQuery:f};p?.register(m);const{insetDisabled:b,insetHide:V}=Q(t,m),k=[];function A(e){const t=Array.isArray(e)?e:S(e);t.join("")!==c.value.join("")&&(c.value=t,m.updateWrapperQuery())}function O(){return c.value=t.resetToInitialValue?v:[],m}function S(e){if(!e&&0!==e)return[];const{valueKey:i,childrenKey:r}=t;return o(h.value,(t=>t[i]===e)).map((e=>e[i]),r)}return e.onBeforeUnmount((()=>k.forEach((e=>e())))),k.push(e.watch((()=>t.getOptions),(function(){t.getOptions?.((e=>{const t=c.value;c.value=[],y.value=e||[],c.value=t,u.initialize||(A(v=S(u.initialValue)),u.initialize=!0)}),t.query||{})}),{immediate:!0})),k.push(e.watch((()=>t.fields?.length?t.fields.reduce(((e,i)=>(t.backfill?.[i]&&e.push(t.backfill[i]),e)),[]):t.backfill?.[t.field]),(e=>{if(Array.isArray(e)){if(e.join("")===c.value.join(""))return;A(e)}else{if(!e&&0!==e)return void(c.value.length&&(c.value=[]));u.initialize?A(S(e)):m.updateWrapperQuery()}}),{immediate:!0,deep:!0})),{checked:c,getQuery:f,finalOption:h,insetDisabled:b,insetHide:V,change:function(e){A(e),p?.insetSearch()},reset:O}},render(){const{checked:e,getQuery:t,finalOption:i,insetHide:r,insetDisabled:a,change:n,reset:l}=this;if(r)return;const s=d("default",this),o=u(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,options:i,listeners:o,value:e,disabled:a,change:n}):s}});exports.CoreCascader=O,exports.CoreDatepicker=A,exports.CoreInput=k,exports.CoreSelect=V,exports.CoreWrapper=b;
"use strict";var e=require("vue-demi");function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t,i=1;i<arguments.length;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},t.apply(this,arguments)}var i=["attrs","props","domProps"],r=["class","style","directives"],a=["on","nativeOn"],n=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},l=function(e){return e.reduce((function(e,l){for(var u in l)if(e[u])if(-1!==i.indexOf(u))e[u]=t({},e[u],l[u]);else if(-1!==r.indexOf(u)){var s=e[u]instanceof Array?e[u]:[e[u]],o=l[u]instanceof Array?l[u]:[l[u]];e[u]=[].concat(s,o)}else if(-1!==a.indexOf(u))for(var d in l[u])if(e[u][d]){var p=e[u][d]instanceof Array?e[u][d]:[e[u][d]],c=l[u][d]instanceof Array?l[u][d]:[l[u][d]];e[u][d]=[].concat(p,c)}else e[u][d]=l[u][d];else if("hook"===u)for(var f in l[u])e[u][f]=e[u][f]?n(e[u][f],l[u][f]):l[u][f];else e[u]=l[u];else e[u]=l[u];return e}),{})};function u(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function o(e,t,i="children"){for(const r of e){if(t(r))return[r];if(r[i]?.length){const e=o(r[i],t);if(e.length)return e.unshift(r),e}}return[]}function d(e,t){return u(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const p={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]}},c={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:()=>{}}},f={...p,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function},filterMethod:{type:Function}},y={...p,realtime:{type:Boolean},waitTime:{type:Number,default:300}},h={...p,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},v={...p,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function}},m={search:e=>{},ready:e=>{}},g="condition-wrapper";var b=e.defineComponent({inheritAttrs:!1,name:"CoreWrapper",props:c,emits:m,setup(t,i){const r=[];e.onBeforeUnmount((()=>r.splice(0)));const a={realtime:e.toRef(t,"realtime"),register:t=>{r.push(t);const i=()=>{t.reset().updateWrapperQuery();const e=r.indexOf(t);-1!==e&&r.splice(e,1)},a=e.getCurrentInstance();return a&&e.onBeforeUnmount(i,a.proxy||a),i},updateQueryValue:(t,i)=>(e.set(n.value,t,i),a),insetSearch:()=>(t.realtime&&a.search(),a),search:s};e.provide(g,a);const n=e.ref({}),l=()=>({...n.value});function u(){const{backfill:e}=t;n.value={...e}}async function s(){const e=(await Promise.all(r.map((e=>e.validator?.(n.value))))).find((e=>e&&"string"==typeof e));if(e?t.toast(e):i.emit("search",l()),e)return e}function o(){r.forEach((e=>{e.reset().updateWrapperQuery()}))}return e.watch((()=>t.datum),e.nextTick.bind(null,u),{immediate:!0}),e.watch((()=>t.backfill),(t=>e.set(n,"value",{...t})),{immediate:!0}),e.onMounted((()=>{u(),t.immediateSearch&&i.emit("ready",l())})),{child:r,wrapperInstance:a,query:n,getQuery:l,initQuery:u,querySearch:s,resetAndSearch:function(){o(),s()},reset:o}},render(){const e=arguments[0],{resetToInitialValue:t,backfill:i,query:r,getQuery:a,initQuery:n,querySearch:s,resetAndSearch:o,reset:p}=this,c=this.tag,f=this.datum,y=d("default",this),h=d("btn",this),{class:v,style:m,...g}=this.$attrs,b={attrs:{class:v,style:m}};return u(this,"$listeners")&&(b.on=this.$listeners),e(c,l([{},b]),[Object.entries(f).map((([e,a])=>"function"==typeof y?y({...g,key:e,field:a.as||e,resetToInitialValue:t,backfill:i,query:r,...a}):y||"")),"function"==typeof h?h({search:s,getQuery:a,resetAndSearch:o,reset:p}):h])}});function Q(t,i){const r=e.ref("boolean"==typeof t.disabled&&t.disabled),a=e.ref("boolean"==typeof t.hide&&t.hide);return e.onBeforeUnmount(e.watch((()=>t.query),(()=>{if("function"==typeof t.hide){a.value!==t.hide(t.query)&&(a.value=t.hide(t.query),a.value&&i.reset().updateWrapperQuery())}else if("function"==typeof t.disabled){r.value!==t.disabled(t.query)&&(r.value=t.disabled(t.query))}}),{immediate:!0,deep:!0})),{insetDisabled:r,insetHide:a}}var V=e.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:f,setup(t,i){const{field:r,depend:a,dependFields:n}=t,l=e.inject(g),u=e.ref(t.multiple?[]:""),o=()=>({[t.field]:s(u.value,t.emptyValue)}),d=t.backfill?.[r]||u.value,p=e.ref([]),c=e.computed((()=>p.value.length?p.value:t.options)),f=e.ref(!1),y=e.ref([]),h=e.computed((()=>f.value?y.value:c.value)),v=e.computed((()=>t.filterMethod&&O)),m={reset:C,updateWrapperQuery:()=>(l?.updateQueryValue(t.field,s(u.value,t.emptyValue)),m),get validator(){return t.validator},getQuery:o};l?.register(m);const{insetDisabled:b,insetHide:V}=Q(t,m),k=[];function A(){t.getOptions?.((e=>{const t=u.value;u.value=void 0,p.value=e||[],u.value=t}),t.query||{})}function O(e){const{filterMethod:i}=t;""===e||void 0===e?(f.value=!1,y.value=[]):(f.value=!0,y.value=c.value.filter((t=>i(e,t))))}function S(e){e!==u.value&&(u.value=e,m.updateWrapperQuery())}function C(){const{multiple:e}=t;return u.value=t.resetToInitialValue?d:e?[]:"",m}return e.onBeforeUnmount((()=>k.forEach((e=>e())))),k.push(e.watch((()=>t.backfill?.[r]),S,{immediate:!0,deep:!0})),k.push(e.watch((()=>t.getOptions),A,{immediate:!0})),a&&n&&n.length&&k.push(e.watch((()=>[].concat(n).map((e=>t.query?.[e])).join(",")),((e,i)=>{e!==i&&(S(t.multiple?[]:""),A())}),{deep:!0,immediate:!0})),{checked:u,getQuery:o,insetDisabled:b,insetHide:V,finalOption:h,customFilterMethod:v,blur:function(){t.filterMethod&&O("")},updateCheckedValue:S,change:function(e){S(e),l?.insetSearch()},reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:i,insetHide:r,finalOption:a,blur:n,customFilterMethod:l,change:s,reset:o,valueKey:p,labelKey:c,multiple:f}=this;if(r)return;const y=d("default",this),h=u(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof y?y({...this.$attrs,listeners:h,value:e,options:a,disabled:i,blur:n,filterMethod:l,change:s,valueKey:p,labelKey:c,multiple:f}):y}}),k=e.defineComponent({inheritAttrs:!1,name:"CoreInput",props:y,setup(t,i){const{field:r}=t,a=e.inject(g),n=e.ref(""),l=()=>({[t.field]:s(n.value,t.emptyValue)}),u=t.backfill?.[r]||n.value,o={reset:y,updateWrapperQuery:()=>(a?.updateQueryValue(t.field,s(n.value,t.emptyValue)),o),get validator(){return t.validator},getQuery:l};a?.register(o);const{insetDisabled:d,insetHide:p}=Q(t,o),c=[];e.onBeforeUnmount((()=>c.forEach((e=>e())))),c.push(e.watch((()=>t.backfill?.[r]),(e=>{e!==n.value&&(n.value=e,o.updateWrapperQuery())}),{immediate:!0,deep:!0}));let f=0;function y(){return n.value=t.resetToInitialValue?u:"",o}return{checked:n,getQuery:l,insetDisabled:d,insetHide:p,debounceChange:function(e){const{realtime:i,waitTime:r}=t;n.value=e,f&&clearTimeout(f),i||!a?.realtime.value?(o.updateWrapperQuery(),a?.insetSearch()):f=setTimeout((()=>(o.updateWrapperQuery(),a?.insetSearch())),r)},enterHandler:function(e){n.value="string"==typeof e?e:e.target?.value||"",o.updateWrapperQuery(),a?.search()},reset:y}},render(){const{query:e,checked:t,getQuery:i,insetDisabled:r,insetHide:a,debounceChange:n,enterHandler:l,reset:s}=this;if(a)return;const o=d("default",this),p=u(this,"$listeners")?this.$listeners:null;return"function"==typeof o?o({...this.$attrs,listeners:p,value:t,disabled:r,debounceChange:n,enterHandler:l}):o}}),A=e.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:h,setup(t,i){const{field:r,range:a,beginField:n,endField:l}=t,u=e.inject(g),o=e.ref(a&&n&&l?["",""]:""),d=()=>t.range&&t.beginField&&t.endField?{[t.beginField]:s(o.value[0],t.emptyValue),[t.endField]:s(o.value[1],t.emptyValue)}:{[t.field]:Array.isArray(o.value)?[...o.value]:s(o.value,t.emptyValue)},p=(a&&n&&l?[t.backfill?.[n]||"",t.backfill?.[l]||""]:t.backfill?.[r])||"",c={reset:m,updateWrapperQuery(){const{range:e,field:i,beginField:r,endField:a}=t;return e&&r&&a?(u?.updateQueryValue(r,s(o.value[0],t.emptyValue)),u?.updateQueryValue(a,s(o.value[1],t.emptyValue))):u?.updateQueryValue(i,s(o.value,t.emptyValue)),c},get validator(){return t.validator},getQuery:d};u?.register(c);const{insetDisabled:f,insetHide:y}=Q(t,c),h=[];function v(e){const{range:i}=t;o.value=null===e?i?["",""]:"":e,c.updateWrapperQuery()}function m(){const{range:e}=t;return o.value=t.resetToInitialValue?p:e?["",""]:"",c}return e.onBeforeUnmount((()=>h.forEach((e=>e())))),a&&n&&l?(h.push(e.watch((()=>t.backfill?.[n]),(e=>{"string"==typeof o.value&&(o.value=[]),o.value.splice(0,1),e&&o.value.splice(0,0,e),c.updateWrapperQuery()}),{immediate:!0})),h.push(e.watch((()=>t.backfill?.[l]),(e=>{"string"==typeof o.value&&(o.value=[]),o.value.splice(1,1),e&&o.value.splice(1,0,e),c.updateWrapperQuery()}),{immediate:!0}))):h.push(e.watch((()=>t.backfill?.[r]),(e=>{o.value=s(e,t.emptyValue),c.updateWrapperQuery()}),{immediate:!0,deep:!0})),{checked:o,getQuery:d,insetDisabled:f,insetHide:y,updateCheckedValue:v,change:function(e){v(e),u?.insetSearch()},reset:m}},render(){const{checked:e,getQuery:t,insetHide:i,insetDisabled:r,updateCheckedValue:a,change:n,reset:l}=this;if(i)return;const s=d("default",this),o=u(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,listeners:o,value:e,disabled:r,updateCheckedValue:a,change:n}):s}});var O=e.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:v,setup(t,i){const{field:r,fields:a,backfill:n,getOptions:l,depend:u,dependFields:d}=t,p={initialize:!(c=n?.[r],(Array.isArray(c)?!c.length:c||0===c)&&"function"==typeof l),initialValue:n?.[r]};var c;const f=e.inject(g),y=e.ref([]),h=()=>a?.length?a.reduce(((e,t,i)=>Object.assign(e,{[t]:y.value[i]})),{}):{[r]:t.emitPath?[...y.value]:y.value.slice(-1)[0]},v=e.ref([]),m=e.computed((()=>v.value.length?v.value:t.options));let b=a?.length?a.reduce(((e,t)=>(n?.[t]&&e.push(n[t]),e)),[]):Array.isArray(n?.[r])?n[r]:p.initialize?q(n?.[r]):[];const V={reset:F,get validator(){return t.validator},updateWrapperQuery(){const{field:e,fields:i,emitPath:r}=t;return p.initialize?i?.length?i.forEach(((e,i)=>{f?.updateQueryValue(e,s(y.value[i],t.emptyValue))})):f?.updateQueryValue(e,s(r?[...y.value]:y.value.slice(-1)[0],t.emptyValue)):f?.updateQueryValue(e,p.initialValue),V},getQuery:h};f?.register(V);const{insetDisabled:k,insetHide:A}=Q(t,V),O=[];function S(){t.getOptions?.((e=>{const t=y.value;y.value=[],v.value=e||[],y.value=t,p.initialize||(C(b=q(p.initialValue)),p.initialize=!0)}),t.query||{})}function C(e){const t=Array.isArray(e)?e:q(e);t.join("")!==y.value.join("")&&(y.value=t,V.updateWrapperQuery())}function F(){return y.value=t.resetToInitialValue?b:[],V}function q(e){if(!e&&0!==e)return[];const{valueKey:i,childrenKey:r}=t;return o(m.value,(t=>t[i]===e)).map((e=>e[i]),r)}return e.onBeforeUnmount((()=>O.forEach((e=>e())))),O.push(e.watch((()=>t.getOptions),S,{immediate:!0})),O.push(e.watch((()=>t.fields?.length?t.fields.reduce(((e,i)=>(t.backfill?.[i]&&e.push(t.backfill[i]),e)),[]):t.backfill?.[t.field]),(e=>{if(Array.isArray(e))C(e);else{if(!e&&0!==e)return void(y.value.length&&(y.value=[]));p.initialize?C(q(e)):V.updateWrapperQuery()}}),{immediate:!0,deep:!0})),u&&d&&d.length&&O.push(e.watch((()=>[].concat(d).map((e=>t.query?.[e])).join(",")),((e,t)=>{e!==t&&(C("string"==typeof y.value?"":[]),S())}),{deep:!0})),{checked:y,getQuery:h,finalOption:m,insetDisabled:k,insetHide:A,change:function(e){C(e),f?.insetSearch()},reset:F}},render(){const{checked:e,getQuery:t,finalOption:i,insetHide:r,insetDisabled:a,change:n,reset:l}=this;if(r)return;const s=d("default",this),o=u(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,options:i,listeners:o,value:e,disabled:a,change:n}):s}});exports.CoreCascader=O,exports.CoreDatepicker=A,exports.CoreInput=k,exports.CoreSelect=V,exports.CoreWrapper=b;
//# sourceMappingURL=index.cjs.min.js.map

@@ -947,3 +947,5 @@ import { defineComponent, onBeforeUnmount, toRef, getCurrentInstance, set, provide, ref, watch, nextTick, onMounted, inject, computed } from 'vue-demi';

backfill: BACKFILL,
getOptions: GET_OPTIONS
getOptions: GET_OPTIONS,
depend: DEPEND,
dependFields: DEPEND_FIELDS
} = props;

@@ -1012,3 +1014,3 @@ const DATA_ASYNC = {

if (Array.isArray(value)) {
if (value.join('') === checked.value.join('')) return;
// if (value.join('') === checked.value.join('')) return;
updateCheckedValue(value);

@@ -1030,2 +1032,12 @@ } else {

}));
if (DEPEND && DEPEND_FIELDS && DEPEND_FIELDS.length) {
// 存在依赖项
unwatchs.push(watch(() => [].concat(DEPEND_FIELDS).map(k => props.query?.[k]).join(','), (val, oldVal) => {
if (val === oldVal) return;
updateCheckedValue(typeof checked.value === 'string' ? '' : []);
getOption();
}, {
deep: true
}));
}
/**

@@ -1032,0 +1044,0 @@ * 获取数据源发生变化事件

@@ -1,2 +0,2 @@

import{defineComponent as e,onBeforeUnmount as t,toRef as i,getCurrentInstance as r,set as a,provide as n,ref as l,watch as u,nextTick as s,onMounted as o,inject as d,computed as p}from"vue-demi";function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t,i=1;i<arguments.length;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},c.apply(this,arguments)}var y=["attrs","props","domProps"],f=["class","style","directives"],h=["on","nativeOn"],v=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},g=function(e){return e.reduce((function(e,t){for(var i in t)if(e[i])if(-1!==y.indexOf(i))e[i]=c({},e[i],t[i]);else if(-1!==f.indexOf(i)){var r=e[i]instanceof Array?e[i]:[e[i]],a=t[i]instanceof Array?t[i]:[t[i]];e[i]=[].concat(r,a)}else if(-1!==h.indexOf(i))for(var n in t[i])if(e[i][n]){var l=e[i][n]instanceof Array?e[i][n]:[e[i][n]],u=t[i][n]instanceof Array?t[i][n]:[t[i][n]];e[i][n]=[].concat(l,u)}else e[i][n]=t[i][n];else if("hook"===i)for(var s in t[i])e[i][s]=e[i][s]?v(e[i][s],t[i][s]):t[i][s];else e[i]=t[i];else e[i]=t[i];return e}),{})};function m(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function b(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function Q(e,t,i="children"){for(const r of e){if(t(r))return[r];if(r[i]?.length){const e=Q(r[i],t);if(e.length)return e.unshift(r),e}}return[]}function V(e,t){return m(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const k={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]}},A={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:()=>{}}},O={...k,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function},filterMethod:{type:Function}},S={...k,realtime:{type:Boolean},waitTime:{type:Number,default:300}},F={...k,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},q={...k,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function}},W="condition-wrapper";var C=e({inheritAttrs:!1,name:"CoreWrapper",props:A,emits:{search:e=>{},ready:e=>{}},setup(e,d){const p=[];t((()=>p.splice(0)));const c={realtime:i(e,"realtime"),register:e=>{p.push(e);const i=()=>{e.reset().updateWrapperQuery();const t=p.indexOf(e);-1!==t&&p.splice(t,1)},a=r();return a&&t(i,a.proxy||a),i},updateQueryValue:(e,t)=>(a(y.value,e,t),c),insetSearch:()=>(e.realtime&&c.search(),c),search:v};n(W,c);const y=l({}),f=()=>({...y.value});function h(){const{backfill:t}=e;y.value={...t}}async function v(){const t=(await Promise.all(p.map((e=>e.validator?.(y.value))))).find((e=>e&&"string"==typeof e));if(t?e.toast(t):d.emit("search",f()),t)return t}function g(){p.forEach((e=>{e.reset().updateWrapperQuery()}))}return u((()=>e.datum),s.bind(null,h),{immediate:!0}),u((()=>e.backfill),(e=>a(y,"value",{...e})),{immediate:!0}),o((()=>{h(),e.immediateSearch&&d.emit("ready",f())})),{child:p,wrapperInstance:c,query:y,getQuery:f,initQuery:h,querySearch:v,resetAndSearch:function(){g(),v()},reset:g}},render(){const e=arguments[0],{resetToInitialValue:t,backfill:i,query:r,getQuery:a,initQuery:n,querySearch:l,resetAndSearch:u,reset:s}=this,o=this.tag,d=this.datum,p=V("default",this),c=V("btn",this),{class:y,style:f,...h}=this.$attrs,v={attrs:{class:y,style:f}};return m(this,"$listeners")&&(v.on=this.$listeners),e(o,g([{},v]),[Object.entries(d).map((([e,a])=>"function"==typeof p?p({...h,key:e,field:a.as||e,resetToInitialValue:t,backfill:i,query:r,...a}):p||"")),"function"==typeof c?c({search:l,getQuery:a,resetAndSearch:u,reset:s}):c])}});function $(e,i){const r=l("boolean"==typeof e.disabled&&e.disabled),a=l("boolean"==typeof e.hide&&e.hide);return t(u((()=>e.query),(()=>{if("function"==typeof e.hide){a.value!==e.hide(e.query)&&(a.value=e.hide(e.query),a.value&&i.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:a}}var j=e({inheritAttrs:!1,name:"CoreSelect",props:O,setup(e,i){const{field:r,depend:a,dependFields:n}=e,s=d(W),o=l(e.multiple?[]:""),c=()=>({[e.field]:b(o.value,e.emptyValue)}),y=e.backfill?.[r]||o.value,f=l([]),h=p((()=>f.value.length?f.value:e.options)),v=l(!1),g=l([]),m=p((()=>v.value?g.value:h.value)),Q=p((()=>e.filterMethod&&F)),V={reset:C,updateWrapperQuery:()=>(s?.updateQueryValue(e.field,b(o.value,e.emptyValue)),V),get validator(){return e.validator},getQuery:c};s?.register(V);const{insetDisabled:k,insetHide:A}=$(e,V),O=[];function S(){e.getOptions?.((e=>{const t=o.value;o.value=void 0,f.value=e||[],o.value=t}),e.query||{})}function F(t){const{filterMethod:i}=e;""===t||void 0===t?(v.value=!1,g.value=[]):(v.value=!0,g.value=h.value.filter((e=>i(t,e))))}function q(e){e!==o.value&&(o.value=e,V.updateWrapperQuery())}function C(){const{multiple:t}=e;return o.value=e.resetToInitialValue?y:t?[]:"",V}return t((()=>O.forEach((e=>e())))),O.push(u((()=>e.backfill?.[r]),q,{immediate:!0,deep:!0})),O.push(u((()=>e.getOptions),S,{immediate:!0})),a&&n&&n.length&&O.push(u((()=>[].concat(n).map((t=>e.query?.[t])).join(",")),((t,i)=>{t!==i&&(q(e.multiple?[]:""),S())}),{deep:!0,immediate:!0})),{checked:o,getQuery:c,insetDisabled:k,insetHide:A,finalOption:m,customFilterMethod:Q,blur:function(){e.filterMethod&&F("")},updateCheckedValue:q,change:function(e){q(e),s?.insetSearch()},reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:i,insetHide:r,finalOption:a,blur:n,customFilterMethod:l,change:u,reset:s,valueKey:o,labelKey:d,multiple:p}=this;if(r)return;const c=V("default",this),y=m(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof c?c({...this.$attrs,listeners:y,value:e,options:a,disabled:i,blur:n,filterMethod:l,change:u,valueKey:o,labelKey:d,multiple:p}):c}}),H=e({inheritAttrs:!1,name:"CoreInput",props:S,setup(e,i){const{field:r}=e,a=d(W),n=l(""),s=()=>({[e.field]:b(n.value,e.emptyValue)}),o=e.backfill?.[r]||n.value,p={reset:v,updateWrapperQuery:()=>(a?.updateQueryValue(e.field,b(n.value,e.emptyValue)),p),get validator(){return e.validator},getQuery:s};a?.register(p);const{insetDisabled:c,insetHide:y}=$(e,p),f=[];t((()=>f.forEach((e=>e())))),f.push(u((()=>e.backfill?.[r]),(e=>{e!==n.value&&(n.value=e,p.updateWrapperQuery())}),{immediate:!0,deep:!0}));let h=0;function v(){return n.value=e.resetToInitialValue?o:"",p}return{checked:n,getQuery:s,insetDisabled:c,insetHide:y,debounceChange:function(t){const{realtime:i,waitTime:r}=e;n.value=t,h&&clearTimeout(h),i||!a?.realtime.value?(p.updateWrapperQuery(),a?.insetSearch()):h=setTimeout((()=>(p.updateWrapperQuery(),a?.insetSearch())),r)},enterHandler:function(e){n.value="string"==typeof e?e:e.target?.value||"",p.updateWrapperQuery(),a?.search()},reset:v}},render(){const{query:e,checked:t,getQuery:i,insetDisabled:r,insetHide:a,debounceChange:n,enterHandler:l,reset:u}=this;if(a)return;const s=V("default",this),o=m(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,listeners:o,value:t,disabled:r,debounceChange:n,enterHandler:l}):s}}),D=e({inheritAttrs:!1,name:"CoreDatepicker",props:F,setup(e,i){const{field:r,range:a,beginField:n,endField:s}=e,o=d(W),p=l(a&&n&&s?["",""]:""),c=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:b(p.value[0],e.emptyValue),[e.endField]:b(p.value[1],e.emptyValue)}:{[e.field]:Array.isArray(p.value)?[...p.value]:b(p.value,e.emptyValue)},y=(a&&n&&s?[e.backfill?.[n]||"",e.backfill?.[s]||""]:e.backfill?.[r])||"",f={reset:Q,updateWrapperQuery(){const{range:t,field:i,beginField:r,endField:a}=e;return t&&r&&a?(o?.updateQueryValue(r,b(p.value[0],e.emptyValue)),o?.updateQueryValue(a,b(p.value[1],e.emptyValue))):o?.updateQueryValue(i,b(p.value,e.emptyValue)),f},get validator(){return e.validator},getQuery:c};o?.register(f);const{insetDisabled:h,insetHide:v}=$(e,f),g=[];function m(t){const{range:i}=e;p.value=null===t?i?["",""]:"":t,f.updateWrapperQuery()}function Q(){const{range:t}=e;return p.value=e.resetToInitialValue?y:t?["",""]:"",f}return t((()=>g.forEach((e=>e())))),a&&n&&s?(g.push(u((()=>e.backfill?.[n]),(e=>{"string"==typeof p.value&&(p.value=[]),p.value.splice(0,1),e&&p.value.splice(0,0,e),f.updateWrapperQuery()}),{immediate:!0})),g.push(u((()=>e.backfill?.[s]),(e=>{"string"==typeof p.value&&(p.value=[]),p.value.splice(1,1),e&&p.value.splice(1,0,e),f.updateWrapperQuery()}),{immediate:!0}))):g.push(u((()=>e.backfill?.[r]),(t=>{p.value=b(t,e.emptyValue),f.updateWrapperQuery()}),{immediate:!0,deep:!0})),{checked:p,getQuery:c,insetDisabled:h,insetHide:v,updateCheckedValue:m,change:function(e){m(e),o?.insetSearch()},reset:Q}},render(){const{checked:e,getQuery:t,insetHide:i,insetDisabled:r,updateCheckedValue:a,change:n,reset:l}=this;if(i)return;const u=V("default",this),s=m(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,listeners:s,value:e,disabled:r,updateCheckedValue:a,change:n}):u}});var B=e({inheritAttrs:!1,name:"CoreCascader",props:q,setup(e,i){const{field:r,fields:a,backfill:n,getOptions:s}=e,o={initialize:!(c=n?.[r],(Array.isArray(c)?!c.length:c||0===c)&&"function"==typeof s),initialValue:n?.[r]};var c;const y=d(W),f=l([]),h=()=>a?.length?a.reduce(((e,t,i)=>Object.assign(e,{[t]:f.value[i]})),{}):{[r]:e.emitPath?[...f.value]:f.value.slice(-1)[0]},v=l([]),g=p((()=>v.value.length?v.value:e.options));let m=a?.length?a.reduce(((e,t)=>(n?.[t]&&e.push(n[t]),e)),[]):Array.isArray(n?.[r])?n[r]:o.initialize?q(n?.[r]):[];const V={reset:F,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:i,emitPath:r}=e;return o.initialize?i?.length?i.forEach(((t,i)=>{y?.updateQueryValue(t,b(f.value[i],e.emptyValue))})):y?.updateQueryValue(t,b(r?[...f.value]:f.value.slice(-1)[0],e.emptyValue)):y?.updateQueryValue(t,o.initialValue),V},getQuery:h};y?.register(V);const{insetDisabled:k,insetHide:A}=$(e,V),O=[];function S(e){const t=Array.isArray(e)?e:q(e);t.join("")!==f.value.join("")&&(f.value=t,V.updateWrapperQuery())}function F(){return f.value=e.resetToInitialValue?m:[],V}function q(t){if(!t&&0!==t)return[];const{valueKey:i,childrenKey:r}=e;return Q(g.value,(e=>e[i]===t)).map((e=>e[i]),r)}return t((()=>O.forEach((e=>e())))),O.push(u((()=>e.getOptions),(function(){e.getOptions?.((e=>{const t=f.value;f.value=[],v.value=e||[],f.value=t,o.initialize||(S(m=q(o.initialValue)),o.initialize=!0)}),e.query||{})}),{immediate:!0})),O.push(u((()=>e.fields?.length?e.fields.reduce(((t,i)=>(e.backfill?.[i]&&t.push(e.backfill[i]),t)),[]):e.backfill?.[e.field]),(e=>{if(Array.isArray(e)){if(e.join("")===f.value.join(""))return;S(e)}else{if(!e&&0!==e)return void(f.value.length&&(f.value=[]));o.initialize?S(q(e)):V.updateWrapperQuery()}}),{immediate:!0,deep:!0})),{checked:f,getQuery:h,finalOption:g,insetDisabled:k,insetHide:A,change:function(e){S(e),y?.insetSearch()},reset:F}},render(){const{checked:e,getQuery:t,finalOption:i,insetHide:r,insetDisabled:a,change:n,reset:l}=this;if(r)return;const u=V("default",this),s=m(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,options:i,listeners:s,value:e,disabled:a,change:n}):u}});export{B as CoreCascader,D as CoreDatepicker,H as CoreInput,j as CoreSelect,C as CoreWrapper};
import{defineComponent as e,onBeforeUnmount as t,toRef as i,getCurrentInstance as a,set as r,provide as n,ref as l,watch as u,nextTick as s,onMounted as o,inject as d,computed as p}from"vue-demi";function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t,i=1;i<arguments.length;i++)for(var a in t=arguments[i])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},c.apply(this,arguments)}var y=["attrs","props","domProps"],f=["class","style","directives"],h=["on","nativeOn"],v=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},g=function(e){return e.reduce((function(e,t){for(var i in t)if(e[i])if(-1!==y.indexOf(i))e[i]=c({},e[i],t[i]);else if(-1!==f.indexOf(i)){var a=e[i]instanceof Array?e[i]:[e[i]],r=t[i]instanceof Array?t[i]:[t[i]];e[i]=[].concat(a,r)}else if(-1!==h.indexOf(i))for(var n in t[i])if(e[i][n]){var l=e[i][n]instanceof Array?e[i][n]:[e[i][n]],u=t[i][n]instanceof Array?t[i][n]:[t[i][n]];e[i][n]=[].concat(l,u)}else e[i][n]=t[i][n];else if("hook"===i)for(var s in t[i])e[i][s]=e[i][s]?v(e[i][s],t[i][s]):t[i][s];else e[i]=t[i];else e[i]=t[i];return e}),{})};function m(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function b(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function Q(e,t,i="children"){for(const a of e){if(t(a))return[a];if(a[i]?.length){const e=Q(a[i],t);if(e.length)return e.unshift(a),e}}return[]}function V(e,t){return m(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const k={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]}},A={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:()=>{}}},O={...k,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function},filterMethod:{type:Function}},S={...k,realtime:{type:Boolean},waitTime:{type:Number,default:300}},F={...k,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},q={...k,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function}},W="condition-wrapper";var C=e({inheritAttrs:!1,name:"CoreWrapper",props:A,emits:{search:e=>{},ready:e=>{}},setup(e,d){const p=[];t((()=>p.splice(0)));const c={realtime:i(e,"realtime"),register:e=>{p.push(e);const i=()=>{e.reset().updateWrapperQuery();const t=p.indexOf(e);-1!==t&&p.splice(t,1)},r=a();return r&&t(i,r.proxy||r),i},updateQueryValue:(e,t)=>(r(y.value,e,t),c),insetSearch:()=>(e.realtime&&c.search(),c),search:v};n(W,c);const y=l({}),f=()=>({...y.value});function h(){const{backfill:t}=e;y.value={...t}}async function v(){const t=(await Promise.all(p.map((e=>e.validator?.(y.value))))).find((e=>e&&"string"==typeof e));if(t?e.toast(t):d.emit("search",f()),t)return t}function g(){p.forEach((e=>{e.reset().updateWrapperQuery()}))}return u((()=>e.datum),s.bind(null,h),{immediate:!0}),u((()=>e.backfill),(e=>r(y,"value",{...e})),{immediate:!0}),o((()=>{h(),e.immediateSearch&&d.emit("ready",f())})),{child:p,wrapperInstance:c,query:y,getQuery:f,initQuery:h,querySearch:v,resetAndSearch:function(){g(),v()},reset:g}},render(){const e=arguments[0],{resetToInitialValue:t,backfill:i,query:a,getQuery:r,initQuery:n,querySearch:l,resetAndSearch:u,reset:s}=this,o=this.tag,d=this.datum,p=V("default",this),c=V("btn",this),{class:y,style:f,...h}=this.$attrs,v={attrs:{class:y,style:f}};return m(this,"$listeners")&&(v.on=this.$listeners),e(o,g([{},v]),[Object.entries(d).map((([e,r])=>"function"==typeof p?p({...h,key:e,field:r.as||e,resetToInitialValue:t,backfill:i,query:a,...r}):p||"")),"function"==typeof c?c({search:l,getQuery:r,resetAndSearch:u,reset:s}):c])}});function $(e,i){const a=l("boolean"==typeof e.disabled&&e.disabled),r=l("boolean"==typeof e.hide&&e.hide);return t(u((()=>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){a.value!==e.disabled(e.query)&&(a.value=e.disabled(e.query))}}),{immediate:!0,deep:!0})),{insetDisabled:a,insetHide:r}}var H=e({inheritAttrs:!1,name:"CoreSelect",props:O,setup(e,i){const{field:a,depend:r,dependFields:n}=e,s=d(W),o=l(e.multiple?[]:""),c=()=>({[e.field]:b(o.value,e.emptyValue)}),y=e.backfill?.[a]||o.value,f=l([]),h=p((()=>f.value.length?f.value:e.options)),v=l(!1),g=l([]),m=p((()=>v.value?g.value:h.value)),Q=p((()=>e.filterMethod&&F)),V={reset:C,updateWrapperQuery:()=>(s?.updateQueryValue(e.field,b(o.value,e.emptyValue)),V),get validator(){return e.validator},getQuery:c};s?.register(V);const{insetDisabled:k,insetHide:A}=$(e,V),O=[];function S(){e.getOptions?.((e=>{const t=o.value;o.value=void 0,f.value=e||[],o.value=t}),e.query||{})}function F(t){const{filterMethod:i}=e;""===t||void 0===t?(v.value=!1,g.value=[]):(v.value=!0,g.value=h.value.filter((e=>i(t,e))))}function q(e){e!==o.value&&(o.value=e,V.updateWrapperQuery())}function C(){const{multiple:t}=e;return o.value=e.resetToInitialValue?y:t?[]:"",V}return t((()=>O.forEach((e=>e())))),O.push(u((()=>e.backfill?.[a]),q,{immediate:!0,deep:!0})),O.push(u((()=>e.getOptions),S,{immediate:!0})),r&&n&&n.length&&O.push(u((()=>[].concat(n).map((t=>e.query?.[t])).join(",")),((t,i)=>{t!==i&&(q(e.multiple?[]:""),S())}),{deep:!0,immediate:!0})),{checked:o,getQuery:c,insetDisabled:k,insetHide:A,finalOption:m,customFilterMethod:Q,blur:function(){e.filterMethod&&F("")},updateCheckedValue:q,change:function(e){q(e),s?.insetSearch()},reset:C}},render(){const{checked:e,getQuery:t,insetDisabled:i,insetHide:a,finalOption:r,blur:n,customFilterMethod:l,change:u,reset:s,valueKey:o,labelKey:d,multiple:p}=this;if(a)return;const c=V("default",this),y=m(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof c?c({...this.$attrs,listeners:y,value:e,options:r,disabled:i,blur:n,filterMethod:l,change:u,valueKey:o,labelKey:d,multiple:p}):c}}),j=e({inheritAttrs:!1,name:"CoreInput",props:S,setup(e,i){const{field:a}=e,r=d(W),n=l(""),s=()=>({[e.field]:b(n.value,e.emptyValue)}),o=e.backfill?.[a]||n.value,p={reset:v,updateWrapperQuery:()=>(r?.updateQueryValue(e.field,b(n.value,e.emptyValue)),p),get validator(){return e.validator},getQuery:s};r?.register(p);const{insetDisabled:c,insetHide:y}=$(e,p),f=[];t((()=>f.forEach((e=>e())))),f.push(u((()=>e.backfill?.[a]),(e=>{e!==n.value&&(n.value=e,p.updateWrapperQuery())}),{immediate:!0,deep:!0}));let h=0;function v(){return n.value=e.resetToInitialValue?o:"",p}return{checked:n,getQuery:s,insetDisabled:c,insetHide:y,debounceChange:function(t){const{realtime:i,waitTime:a}=e;n.value=t,h&&clearTimeout(h),i||!r?.realtime.value?(p.updateWrapperQuery(),r?.insetSearch()):h=setTimeout((()=>(p.updateWrapperQuery(),r?.insetSearch())),a)},enterHandler:function(e){n.value="string"==typeof e?e:e.target?.value||"",p.updateWrapperQuery(),r?.search()},reset:v}},render(){const{query:e,checked:t,getQuery:i,insetDisabled:a,insetHide:r,debounceChange:n,enterHandler:l,reset:u}=this;if(r)return;const s=V("default",this),o=m(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,listeners:o,value:t,disabled:a,debounceChange:n,enterHandler:l}):s}}),D=e({inheritAttrs:!1,name:"CoreDatepicker",props:F,setup(e,i){const{field:a,range:r,beginField:n,endField:s}=e,o=d(W),p=l(r&&n&&s?["",""]:""),c=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:b(p.value[0],e.emptyValue),[e.endField]:b(p.value[1],e.emptyValue)}:{[e.field]:Array.isArray(p.value)?[...p.value]:b(p.value,e.emptyValue)},y=(r&&n&&s?[e.backfill?.[n]||"",e.backfill?.[s]||""]:e.backfill?.[a])||"",f={reset:Q,updateWrapperQuery(){const{range:t,field:i,beginField:a,endField:r}=e;return t&&a&&r?(o?.updateQueryValue(a,b(p.value[0],e.emptyValue)),o?.updateQueryValue(r,b(p.value[1],e.emptyValue))):o?.updateQueryValue(i,b(p.value,e.emptyValue)),f},get validator(){return e.validator},getQuery:c};o?.register(f);const{insetDisabled:h,insetHide:v}=$(e,f),g=[];function m(t){const{range:i}=e;p.value=null===t?i?["",""]:"":t,f.updateWrapperQuery()}function Q(){const{range:t}=e;return p.value=e.resetToInitialValue?y:t?["",""]:"",f}return t((()=>g.forEach((e=>e())))),r&&n&&s?(g.push(u((()=>e.backfill?.[n]),(e=>{"string"==typeof p.value&&(p.value=[]),p.value.splice(0,1),e&&p.value.splice(0,0,e),f.updateWrapperQuery()}),{immediate:!0})),g.push(u((()=>e.backfill?.[s]),(e=>{"string"==typeof p.value&&(p.value=[]),p.value.splice(1,1),e&&p.value.splice(1,0,e),f.updateWrapperQuery()}),{immediate:!0}))):g.push(u((()=>e.backfill?.[a]),(t=>{p.value=b(t,e.emptyValue),f.updateWrapperQuery()}),{immediate:!0,deep:!0})),{checked:p,getQuery:c,insetDisabled:h,insetHide:v,updateCheckedValue:m,change:function(e){m(e),o?.insetSearch()},reset:Q}},render(){const{checked:e,getQuery:t,insetHide:i,insetDisabled:a,updateCheckedValue:r,change:n,reset:l}=this;if(i)return;const u=V("default",this),s=m(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,listeners:s,value:e,disabled:a,updateCheckedValue:r,change:n}):u}});var B=e({inheritAttrs:!1,name:"CoreCascader",props:q,setup(e,i){const{field:a,fields:r,backfill:n,getOptions:s,depend:o,dependFields:c}=e,y={initialize:!(f=n?.[a],(Array.isArray(f)?!f.length:f||0===f)&&"function"==typeof s),initialValue:n?.[a]};var f;const h=d(W),v=l([]),g=()=>r?.length?r.reduce(((e,t,i)=>Object.assign(e,{[t]:v.value[i]})),{}):{[a]:e.emitPath?[...v.value]:v.value.slice(-1)[0]},m=l([]),V=p((()=>m.value.length?m.value:e.options));let k=r?.length?r.reduce(((e,t)=>(n?.[t]&&e.push(n[t]),e)),[]):Array.isArray(n?.[a])?n[a]:y.initialize?j(n?.[a]):[];const A={reset:H,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:i,emitPath:a}=e;return y.initialize?i?.length?i.forEach(((t,i)=>{h?.updateQueryValue(t,b(v.value[i],e.emptyValue))})):h?.updateQueryValue(t,b(a?[...v.value]:v.value.slice(-1)[0],e.emptyValue)):h?.updateQueryValue(t,y.initialValue),A},getQuery:g};h?.register(A);const{insetDisabled:O,insetHide:S}=$(e,A),F=[];function q(){e.getOptions?.((e=>{const t=v.value;v.value=[],m.value=e||[],v.value=t,y.initialize||(C(k=j(y.initialValue)),y.initialize=!0)}),e.query||{})}function C(e){const t=Array.isArray(e)?e:j(e);t.join("")!==v.value.join("")&&(v.value=t,A.updateWrapperQuery())}function H(){return v.value=e.resetToInitialValue?k:[],A}function j(t){if(!t&&0!==t)return[];const{valueKey:i,childrenKey:a}=e;return Q(V.value,(e=>e[i]===t)).map((e=>e[i]),a)}return t((()=>F.forEach((e=>e())))),F.push(u((()=>e.getOptions),q,{immediate:!0})),F.push(u((()=>e.fields?.length?e.fields.reduce(((t,i)=>(e.backfill?.[i]&&t.push(e.backfill[i]),t)),[]):e.backfill?.[e.field]),(e=>{if(Array.isArray(e))C(e);else{if(!e&&0!==e)return void(v.value.length&&(v.value=[]));y.initialize?C(j(e)):A.updateWrapperQuery()}}),{immediate:!0,deep:!0})),o&&c&&c.length&&F.push(u((()=>[].concat(c).map((t=>e.query?.[t])).join(",")),((e,t)=>{e!==t&&(C("string"==typeof v.value?"":[]),q())}),{deep:!0})),{checked:v,getQuery:g,finalOption:V,insetDisabled:O,insetHide:S,change:function(e){C(e),h?.insetSearch()},reset:H}},render(){const{checked:e,getQuery:t,finalOption:i,insetHide:a,insetDisabled:r,change:n,reset:l}=this;if(a)return;const u=V("default",this),s=m(this,"$listeners")?this.$listeners:null;return"function"==typeof u?u({...this.$attrs,options:i,listeners:s,value:e,disabled:r,change:n}):u}});export{B as CoreCascader,D as CoreDatepicker,j as CoreInput,H as CoreSelect,C as CoreWrapper};
//# sourceMappingURL=index.esm.min.js.map

@@ -1065,3 +1065,5 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {

backfill: BACKFILL,
getOptions: GET_OPTIONS
getOptions: GET_OPTIONS,
depend: DEPEND,
dependFields: DEPEND_FIELDS
} = props;

@@ -1130,3 +1132,3 @@ const DATA_ASYNC = {

if (Array.isArray(value)) {
if (value.join('') === checked.value.join('')) return;
// if (value.join('') === checked.value.join('')) return;
updateCheckedValue(value);

@@ -1148,2 +1150,12 @@ } else {

}));
if (DEPEND && DEPEND_FIELDS && DEPEND_FIELDS.length) {
// 存在依赖项
unwatchs.push(vueDemi.watch(() => [].concat(DEPEND_FIELDS).map(k => props.query?.[k]).join(','), (val, oldVal) => {
if (val === oldVal) return;
updateCheckedValue(typeof checked.value === 'string' ? '' : []);
getOption();
}, {
deep: true
}));
}
/**

@@ -1150,0 +1162,0 @@ * 获取数据源发生变化事件

@@ -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.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}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(){return i=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},i.apply(this,arguments)}var n=["attrs","props","domProps"],r=["class","style","directives"],a=["on","nativeOn"],u=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},l=function(e){return e.reduce((function(e,t){for(var l in t)if(e[l])if(-1!==n.indexOf(l))e[l]=i({},e[l],t[l]);else if(-1!==r.indexOf(l)){var o=e[l]instanceof Array?e[l]:[e[l]],s=t[l]instanceof Array?t[l]:[t[l]];e[l]=[].concat(o,s)}else if(-1!==a.indexOf(l))for(var d in t[l])if(e[l][d]){var c=e[l][d]instanceof Array?e[l][d]:[e[l][d]],p=t[l][d]instanceof Array?t[l][d]:[t[l][d]];e[l][d]=[].concat(c,p)}else e[l][d]=t[l][d];else if("hook"===l)for(var f in t[l])e[l][f]=e[l][f]?u(e[l][f],t[l][f]):t[l][f];else e[l]=t[l];else e[l]=t[l];return e}),{})};function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e,t){return Array.isArray(e)?e.filter(Boolean).length?e:t:"number"==typeof e?e:e||t}function d(e,t,i="children"){for(const n of e){if(t(n))return[n];if(n[i]?.length){const e=d(n[i],t);if(e.length)return e.unshift(n),e}}return[]}function c(e,t){return o(t,"$scopedSlots")&&t.$scopedSlots[e]||t.$slots[e]}const p={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]}},f={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:()=>{}}},y={...p,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function},filterMethod:{type:Function}},h={...p,realtime:{type:Boolean},waitTime:{type:Number,default:300}},v={...p,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},m={...p,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function}},g={search:e=>{},ready:e=>{}},b="condition-wrapper";var V=t.defineComponent({inheritAttrs:!1,name:"CoreWrapper",props:f,emits:g,setup(e,i){const n=[];t.onBeforeUnmount((()=>n.splice(0)));const r={realtime:t.toRef(e,"realtime"),register:e=>{n.push(e);const i=()=>{e.reset().updateWrapperQuery();const t=n.indexOf(e);-1!==t&&n.splice(t,1)},r=t.getCurrentInstance();return r&&t.onBeforeUnmount(i,r.proxy||r),i},updateQueryValue:(e,i)=>(t.set(a.value,e,i),r),insetSearch:()=>(e.realtime&&r.search(),r),search:o};t.provide(b,r);const a=t.ref({}),u=()=>({...a.value});function l(){const{backfill:t}=e;a.value={...t}}async function o(){const t=(await Promise.all(n.map((e=>e.validator?.(a.value))))).find((e=>e&&"string"==typeof e));if(t?e.toast(t):i.emit("search",u()),t)return t}function s(){n.forEach((e=>{e.reset().updateWrapperQuery()}))}return t.watch((()=>e.datum),t.nextTick.bind(null,l),{immediate:!0}),t.watch((()=>e.backfill),(e=>t.set(a,"value",{...e})),{immediate:!0}),t.onMounted((()=>{l(),e.immediateSearch&&i.emit("ready",u())})),{child:n,wrapperInstance:r,query:a,getQuery:u,initQuery:l,querySearch:o,resetAndSearch:function(){s(),o()},reset:s}},render(){const e=arguments[0],{resetToInitialValue:t,backfill:i,query:n,getQuery:r,initQuery:a,querySearch:u,resetAndSearch:s,reset:d}=this,p=this.tag,f=this.datum,y=c("default",this),h=c("btn",this),{class:v,style:m,...g}=this.$attrs,b={attrs:{class:v,style:m}};return o(this,"$listeners")&&(b.on=this.$listeners),e(p,l([{},b]),[Object.entries(f).map((([e,r])=>"function"==typeof y?y({...g,key:e,field:r.as||e,resetToInitialValue:t,backfill:i,query:n,...r}):y||"")),"function"==typeof h?h({search:u,getQuery:r,resetAndSearch:s,reset:d}):h])}});function Q(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}}var A=t.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:y,setup(e,i){const{field:n,depend:r,dependFields:a}=e,u=t.inject(b),l=t.ref(e.multiple?[]:""),o=()=>({[e.field]:s(l.value,e.emptyValue)}),d=e.backfill?.[n]||l.value,c=t.ref([]),p=t.computed((()=>c.value.length?c.value:e.options)),f=t.ref(!1),y=t.ref([]),h=t.computed((()=>f.value?y.value:p.value)),v=t.computed((()=>e.filterMethod&&C)),m={reset:S,updateWrapperQuery:()=>(u?.updateQueryValue(e.field,s(l.value,e.emptyValue)),m),get validator(){return e.validator},getQuery:o};u?.register(m);const{insetDisabled:g,insetHide:V}=Q(e,m),A=[];function k(){e.getOptions?.((e=>{const t=l.value;l.value=void 0,c.value=e||[],l.value=t}),e.query||{})}function C(t){const{filterMethod:i}=e;""===t||void 0===t?(f.value=!1,y.value=[]):(f.value=!0,y.value=p.value.filter((e=>i(t,e))))}function O(e){e!==l.value&&(l.value=e,m.updateWrapperQuery())}function S(){const{multiple:t}=e;return l.value=e.resetToInitialValue?d:t?[]:"",m}return t.onBeforeUnmount((()=>A.forEach((e=>e())))),A.push(t.watch((()=>e.backfill?.[n]),O,{immediate:!0,deep:!0})),A.push(t.watch((()=>e.getOptions),k,{immediate:!0})),r&&a&&a.length&&A.push(t.watch((()=>[].concat(a).map((t=>e.query?.[t])).join(",")),((t,i)=>{t!==i&&(O(e.multiple?[]:""),k())}),{deep:!0,immediate:!0})),{checked:l,getQuery:o,insetDisabled:g,insetHide:V,finalOption:h,customFilterMethod:v,blur:function(){e.filterMethod&&C("")},updateCheckedValue:O,change:function(e){O(e),u?.insetSearch()},reset:S}},render(){const{checked:e,getQuery:t,insetDisabled:i,insetHide:n,finalOption:r,blur:a,customFilterMethod:u,change:l,reset:s,valueKey:d,labelKey:p,multiple:f}=this;if(n)return;const y=c("default",this),h=o(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof y?y({...this.$attrs,listeners:h,value:e,options:r,disabled:i,blur:a,filterMethod:u,change:l,valueKey:d,labelKey:p,multiple:f}):y}}),k=t.defineComponent({inheritAttrs:!1,name:"CoreInput",props:h,setup(e,i){const{field:n}=e,r=t.inject(b),a=t.ref(""),u=()=>({[e.field]:s(a.value,e.emptyValue)}),l=e.backfill?.[n]||a.value,o={reset:y,updateWrapperQuery:()=>(r?.updateQueryValue(e.field,s(a.value,e.emptyValue)),o),get validator(){return e.validator},getQuery:u};r?.register(o);const{insetDisabled:d,insetHide:c}=Q(e,o),p=[];t.onBeforeUnmount((()=>p.forEach((e=>e())))),p.push(t.watch((()=>e.backfill?.[n]),(e=>{e!==a.value&&(a.value=e,o.updateWrapperQuery())}),{immediate:!0,deep:!0}));let f=0;function y(){return a.value=e.resetToInitialValue?l:"",o}return{checked:a,getQuery:u,insetDisabled:d,insetHide:c,debounceChange:function(t){const{realtime:i,waitTime:n}=e;a.value=t,f&&clearTimeout(f),i||!r?.realtime.value?(o.updateWrapperQuery(),r?.insetSearch()):f=setTimeout((()=>(o.updateWrapperQuery(),r?.insetSearch())),n)},enterHandler:function(e){a.value="string"==typeof e?e:e.target?.value||"",o.updateWrapperQuery(),r?.search()},reset:y}},render(){const{query:e,checked:t,getQuery:i,insetDisabled:n,insetHide:r,debounceChange:a,enterHandler:u,reset:l}=this;if(r)return;const s=c("default",this),d=o(this,"$listeners")?this.$listeners:null;return"function"==typeof s?s({...this.$attrs,listeners:d,value:t,disabled:n,debounceChange:a,enterHandler:u}):s}}),C=t.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:v,setup(e,i){const{field:n,range:r,beginField:a,endField:u}=e,l=t.inject(b),o=t.ref(r&&a&&u?["",""]:""),d=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:s(o.value[0],e.emptyValue),[e.endField]:s(o.value[1],e.emptyValue)}:{[e.field]:Array.isArray(o.value)?[...o.value]:s(o.value,e.emptyValue)},c=(r&&a&&u?[e.backfill?.[a]||"",e.backfill?.[u]||""]:e.backfill?.[n])||"",p={reset:m,updateWrapperQuery(){const{range:t,field:i,beginField:n,endField:r}=e;return t&&n&&r?(l?.updateQueryValue(n,s(o.value[0],e.emptyValue)),l?.updateQueryValue(r,s(o.value[1],e.emptyValue))):l?.updateQueryValue(i,s(o.value,e.emptyValue)),p},get validator(){return e.validator},getQuery:d};l?.register(p);const{insetDisabled:f,insetHide:y}=Q(e,p),h=[];function v(t){const{range:i}=e;o.value=null===t?i?["",""]:"":t,p.updateWrapperQuery()}function m(){const{range:t}=e;return o.value=e.resetToInitialValue?c:t?["",""]:"",p}return t.onBeforeUnmount((()=>h.forEach((e=>e())))),r&&a&&u?(h.push(t.watch((()=>e.backfill?.[a]),(e=>{"string"==typeof o.value&&(o.value=[]),o.value.splice(0,1),e&&o.value.splice(0,0,e),p.updateWrapperQuery()}),{immediate:!0})),h.push(t.watch((()=>e.backfill?.[u]),(e=>{"string"==typeof o.value&&(o.value=[]),o.value.splice(1,1),e&&o.value.splice(1,0,e),p.updateWrapperQuery()}),{immediate:!0}))):h.push(t.watch((()=>e.backfill?.[n]),(t=>{o.value=s(t,e.emptyValue),p.updateWrapperQuery()}),{immediate:!0,deep:!0})),{checked:o,getQuery:d,insetDisabled:f,insetHide:y,updateCheckedValue:v,change:function(e){v(e),l?.insetSearch()},reset:m}},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),s=o(this,"$listeners")?this.$listeners:null;return"function"==typeof l?l({...this.$attrs,listeners:s,value:e,disabled:n,updateCheckedValue:r,change:a}):l}});var O=t.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:m,setup(e,i){const{field:n,fields:r,backfill:a,getOptions:u}=e,l={initialize:!(o=a?.[n],(Array.isArray(o)?!o.length:o||0===o)&&"function"==typeof u),initialValue:a?.[n]};var o;const c=t.inject(b),p=t.ref([]),f=()=>r?.length?r.reduce(((e,t,i)=>Object.assign(e,{[t]:p.value[i]})),{}):{[n]:e.emitPath?[...p.value]:p.value.slice(-1)[0]},y=t.ref([]),h=t.computed((()=>y.value.length?y.value:e.options));let v=r?.length?r.reduce(((e,t)=>(a?.[t]&&e.push(a[t]),e)),[]):Array.isArray(a?.[n])?a[n]:l.initialize?O(a?.[n]):[];const m={reset:C,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:i,emitPath:n}=e;return l.initialize?i?.length?i.forEach(((t,i)=>{c?.updateQueryValue(t,s(p.value[i],e.emptyValue))})):c?.updateQueryValue(t,s(n?[...p.value]:p.value.slice(-1)[0],e.emptyValue)):c?.updateQueryValue(t,l.initialValue),m},getQuery:f};c?.register(m);const{insetDisabled:g,insetHide:V}=Q(e,m),A=[];function k(e){const t=Array.isArray(e)?e:O(e);t.join("")!==p.value.join("")&&(p.value=t,m.updateWrapperQuery())}function C(){return p.value=e.resetToInitialValue?v:[],m}function O(t){if(!t&&0!==t)return[];const{valueKey:i,childrenKey:n}=e;return d(h.value,(e=>e[i]===t)).map((e=>e[i]),n)}return t.onBeforeUnmount((()=>A.forEach((e=>e())))),A.push(t.watch((()=>e.getOptions),(function(){e.getOptions?.((e=>{const t=p.value;p.value=[],y.value=e||[],p.value=t,l.initialize||(k(v=O(l.initialValue)),l.initialize=!0)}),e.query||{})}),{immediate:!0})),A.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(Array.isArray(e)){if(e.join("")===p.value.join(""))return;k(e)}else{if(!e&&0!==e)return void(p.value.length&&(p.value=[]));l.initialize?k(O(e)):m.updateWrapperQuery()}}),{immediate:!0,deep:!0})),{checked:p,getQuery:f,finalOption:h,insetDisabled:g,insetHide:V,change:function(e){k(e),c?.insetSearch()},reset:C}},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),s=o(this,"$listeners")?this.$listeners:null;return"function"==typeof l?l({...this.$attrs,options:i,listeners:s,value:e,disabled:r,change:a}):l}});e.CoreCascader=O,e.CoreDatepicker=C,e.CoreInput=k,e.CoreSelect=A,e.CoreWrapper=V}));
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.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}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(){return i=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},i.apply(this,arguments)}var n=["attrs","props","domProps"],r=["class","style","directives"],a=["on","nativeOn"],u=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},l=function(e){return e.reduce((function(e,t){for(var l in t)if(e[l])if(-1!==n.indexOf(l))e[l]=i({},e[l],t[l]);else if(-1!==r.indexOf(l)){var s=e[l]instanceof Array?e[l]:[e[l]],o=t[l]instanceof Array?t[l]:[t[l]];e[l]=[].concat(s,o)}else if(-1!==a.indexOf(l))for(var d in t[l])if(e[l][d]){var c=e[l][d]instanceof Array?e[l][d]:[e[l][d]],p=t[l][d]instanceof Array?t[l][d]:[t[l][d]];e[l][d]=[].concat(c,p)}else e[l][d]=t[l][d];else if("hook"===l)for(var f in t[l])e[l][f]=e[l][f]?u(e[l][f],t[l][f]):t[l][f];else e[l]=t[l];else e[l]=t[l];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,i="children"){for(const n of e){if(t(n))return[n];if(n[i]?.length){const e=d(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 p={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]}},f={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:()=>{}}},y={...p,valueKey:{type:String,required:!0},labelKey:{type:String,required:!0},options:{type:Array,default:()=>[]},multiple:{type:Boolean},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function},filterMethod:{type:Function}},h={...p,realtime:{type:Boolean},waitTime:{type:Number,default:300}},v={...p,range:{type:Boolean,default:!1},beginField:{type:String},endField:{type:String}},m={...p,fields:{type:[Array]},valueKey:{type:String,required:!0},childrenKey:{type:String},emitPath:{type:[Boolean],default:!1},options:{type:Array,default:()=>[]},depend:{type:Boolean},dependFields:{type:[String,Array]},getOptions:{type:Function}},g={search:e=>{},ready:e=>{}},b="condition-wrapper";var V=t.defineComponent({inheritAttrs:!1,name:"CoreWrapper",props:f,emits:g,setup(e,i){const n=[];t.onBeforeUnmount((()=>n.splice(0)));const r={realtime:t.toRef(e,"realtime"),register:e=>{n.push(e);const i=()=>{e.reset().updateWrapperQuery();const t=n.indexOf(e);-1!==t&&n.splice(t,1)},r=t.getCurrentInstance();return r&&t.onBeforeUnmount(i,r.proxy||r),i},updateQueryValue:(e,i)=>(t.set(a.value,e,i),r),insetSearch:()=>(e.realtime&&r.search(),r),search:s};t.provide(b,r);const a=t.ref({}),u=()=>({...a.value});function l(){const{backfill:t}=e;a.value={...t}}async function s(){const t=(await Promise.all(n.map((e=>e.validator?.(a.value))))).find((e=>e&&"string"==typeof e));if(t?e.toast(t):i.emit("search",u()),t)return t}function o(){n.forEach((e=>{e.reset().updateWrapperQuery()}))}return t.watch((()=>e.datum),t.nextTick.bind(null,l),{immediate:!0}),t.watch((()=>e.backfill),(e=>t.set(a,"value",{...e})),{immediate:!0}),t.onMounted((()=>{l(),e.immediateSearch&&i.emit("ready",u())})),{child:n,wrapperInstance:r,query:a,getQuery:u,initQuery:l,querySearch:s,resetAndSearch:function(){o(),s()},reset:o}},render(){const e=arguments[0],{resetToInitialValue:t,backfill:i,query:n,getQuery:r,initQuery:a,querySearch:u,resetAndSearch:o,reset:d}=this,p=this.tag,f=this.datum,y=c("default",this),h=c("btn",this),{class:v,style:m,...g}=this.$attrs,b={attrs:{class:v,style:m}};return s(this,"$listeners")&&(b.on=this.$listeners),e(p,l([{},b]),[Object.entries(f).map((([e,r])=>"function"==typeof y?y({...g,key:e,field:r.as||e,resetToInitialValue:t,backfill:i,query:n,...r}):y||"")),"function"==typeof h?h({search:u,getQuery:r,resetAndSearch:o,reset:d}):h])}});function Q(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}}var A=t.defineComponent({inheritAttrs:!1,name:"CoreSelect",props:y,setup(e,i){const{field:n,depend:r,dependFields:a}=e,u=t.inject(b),l=t.ref(e.multiple?[]:""),s=()=>({[e.field]:o(l.value,e.emptyValue)}),d=e.backfill?.[n]||l.value,c=t.ref([]),p=t.computed((()=>c.value.length?c.value:e.options)),f=t.ref(!1),y=t.ref([]),h=t.computed((()=>f.value?y.value:p.value)),v=t.computed((()=>e.filterMethod&&C)),m={reset:S,updateWrapperQuery:()=>(u?.updateQueryValue(e.field,o(l.value,e.emptyValue)),m),get validator(){return e.validator},getQuery:s};u?.register(m);const{insetDisabled:g,insetHide:V}=Q(e,m),A=[];function k(){e.getOptions?.((e=>{const t=l.value;l.value=void 0,c.value=e||[],l.value=t}),e.query||{})}function C(t){const{filterMethod:i}=e;""===t||void 0===t?(f.value=!1,y.value=[]):(f.value=!0,y.value=p.value.filter((e=>i(t,e))))}function O(e){e!==l.value&&(l.value=e,m.updateWrapperQuery())}function S(){const{multiple:t}=e;return l.value=e.resetToInitialValue?d:t?[]:"",m}return t.onBeforeUnmount((()=>A.forEach((e=>e())))),A.push(t.watch((()=>e.backfill?.[n]),O,{immediate:!0,deep:!0})),A.push(t.watch((()=>e.getOptions),k,{immediate:!0})),r&&a&&a.length&&A.push(t.watch((()=>[].concat(a).map((t=>e.query?.[t])).join(",")),((t,i)=>{t!==i&&(O(e.multiple?[]:""),k())}),{deep:!0,immediate:!0})),{checked:l,getQuery:s,insetDisabled:g,insetHide:V,finalOption:h,customFilterMethod:v,blur:function(){e.filterMethod&&C("")},updateCheckedValue:O,change:function(e){O(e),u?.insetSearch()},reset:S}},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 y=c("default",this),h=s(this,"$listeners")?{...this.$listeners}:null;return"function"==typeof y?y({...this.$attrs,listeners:h,value:e,options:r,disabled:i,blur:a,filterMethod:u,change:l,valueKey:d,labelKey:p,multiple:f}):y}}),k=t.defineComponent({inheritAttrs:!1,name:"CoreInput",props:h,setup(e,i){const{field:n}=e,r=t.inject(b),a=t.ref(""),u=()=>({[e.field]:o(a.value,e.emptyValue)}),l=e.backfill?.[n]||a.value,s={reset:y,updateWrapperQuery:()=>(r?.updateQueryValue(e.field,o(a.value,e.emptyValue)),s),get validator(){return e.validator},getQuery:u};r?.register(s);const{insetDisabled:d,insetHide:c}=Q(e,s),p=[];t.onBeforeUnmount((()=>p.forEach((e=>e())))),p.push(t.watch((()=>e.backfill?.[n]),(e=>{e!==a.value&&(a.value=e,s.updateWrapperQuery())}),{immediate:!0,deep:!0}));let f=0;function y(){return a.value=e.resetToInitialValue?l:"",s}return{checked:a,getQuery:u,insetDisabled:d,insetHide:c,debounceChange:function(t){const{realtime:i,waitTime:n}=e;a.value=t,f&&clearTimeout(f),i||!r?.realtime.value?(s.updateWrapperQuery(),r?.insetSearch()):f=setTimeout((()=>(s.updateWrapperQuery(),r?.insetSearch())),n)},enterHandler:function(e){a.value="string"==typeof e?e:e.target?.value||"",s.updateWrapperQuery(),r?.search()},reset:y}},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,value:t,disabled:n,debounceChange:a,enterHandler:u}):o}}),C=t.defineComponent({inheritAttrs:!1,name:"CoreDatepicker",props:v,setup(e,i){const{field:n,range:r,beginField:a,endField:u}=e,l=t.inject(b),s=t.ref(r&&a&&u?["",""]:""),d=()=>e.range&&e.beginField&&e.endField?{[e.beginField]:o(s.value[0],e.emptyValue),[e.endField]:o(s.value[1],e.emptyValue)}:{[e.field]:Array.isArray(s.value)?[...s.value]:o(s.value,e.emptyValue)},c=(r&&a&&u?[e.backfill?.[a]||"",e.backfill?.[u]||""]:e.backfill?.[n])||"",p={reset:m,updateWrapperQuery(){const{range:t,field:i,beginField:n,endField:r}=e;return t&&n&&r?(l?.updateQueryValue(n,o(s.value[0],e.emptyValue)),l?.updateQueryValue(r,o(s.value[1],e.emptyValue))):l?.updateQueryValue(i,o(s.value,e.emptyValue)),p},get validator(){return e.validator},getQuery:d};l?.register(p);const{insetDisabled:f,insetHide:y}=Q(e,p),h=[];function v(t){const{range:i}=e;s.value=null===t?i?["",""]:"":t,p.updateWrapperQuery()}function m(){const{range:t}=e;return s.value=e.resetToInitialValue?c:t?["",""]:"",p}return t.onBeforeUnmount((()=>h.forEach((e=>e())))),r&&a&&u?(h.push(t.watch((()=>e.backfill?.[a]),(e=>{"string"==typeof s.value&&(s.value=[]),s.value.splice(0,1),e&&s.value.splice(0,0,e),p.updateWrapperQuery()}),{immediate:!0})),h.push(t.watch((()=>e.backfill?.[u]),(e=>{"string"==typeof s.value&&(s.value=[]),s.value.splice(1,1),e&&s.value.splice(1,0,e),p.updateWrapperQuery()}),{immediate:!0}))):h.push(t.watch((()=>e.backfill?.[n]),(t=>{s.value=o(t,e.emptyValue),p.updateWrapperQuery()}),{immediate:!0,deep:!0})),{checked:s,getQuery:d,insetDisabled:f,insetHide:y,updateCheckedValue:v,change:function(e){v(e),l?.insetSearch()},reset:m}},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,value:e,disabled:n,updateCheckedValue:r,change:a}):l}});var O=t.defineComponent({inheritAttrs:!1,name:"CoreCascader",props:m,setup(e,i){const{field:n,fields:r,backfill:a,getOptions:u,depend:l,dependFields:s}=e,c={initialize:!(p=a?.[n],(Array.isArray(p)?!p.length:p||0===p)&&"function"==typeof u),initialValue:a?.[n]};var p;const f=t.inject(b),y=t.ref([]),h=()=>r?.length?r.reduce(((e,t,i)=>Object.assign(e,{[t]:y.value[i]})),{}):{[n]:e.emitPath?[...y.value]:y.value.slice(-1)[0]},v=t.ref([]),m=t.computed((()=>v.value.length?v.value:e.options));let g=r?.length?r.reduce(((e,t)=>(a?.[t]&&e.push(a[t]),e)),[]):Array.isArray(a?.[n])?a[n]:c.initialize?F(a?.[n]):[];const V={reset:w,get validator(){return e.validator},updateWrapperQuery(){const{field:t,fields:i,emitPath:n}=e;return c.initialize?i?.length?i.forEach(((t,i)=>{f?.updateQueryValue(t,o(y.value[i],e.emptyValue))})):f?.updateQueryValue(t,o(n?[...y.value]:y.value.slice(-1)[0],e.emptyValue)):f?.updateQueryValue(t,c.initialValue),V},getQuery:h};f?.register(V);const{insetDisabled:A,insetHide:k}=Q(e,V),C=[];function O(){e.getOptions?.((e=>{const t=y.value;y.value=[],v.value=e||[],y.value=t,c.initialize||(S(g=F(c.initialValue)),c.initialize=!0)}),e.query||{})}function S(e){const t=Array.isArray(e)?e:F(e);t.join("")!==y.value.join("")&&(y.value=t,V.updateWrapperQuery())}function w(){return y.value=e.resetToInitialValue?g:[],V}function F(t){if(!t&&0!==t)return[];const{valueKey:i,childrenKey:n}=e;return d(m.value,(e=>e[i]===t)).map((e=>e[i]),n)}return t.onBeforeUnmount((()=>C.forEach((e=>e())))),C.push(t.watch((()=>e.getOptions),O,{immediate:!0})),C.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(Array.isArray(e))S(e);else{if(!e&&0!==e)return void(y.value.length&&(y.value=[]));c.initialize?S(F(e)):V.updateWrapperQuery()}}),{immediate:!0,deep:!0})),l&&s&&s.length&&C.push(t.watch((()=>[].concat(s).map((t=>e.query?.[t])).join(",")),((e,t)=>{e!==t&&(S("string"==typeof y.value?"":[]),O())}),{deep:!0})),{checked:y,getQuery:h,finalOption:m,insetDisabled:A,insetHide:k,change:function(e){S(e),f?.insetSearch()},reset:w}},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,value:e,disabled:r,change:a}):l}});e.CoreCascader=O,e.CoreDatepicker=C,e.CoreInput=k,e.CoreSelect=A,e.CoreWrapper=V}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@xiaohaih/condition-core",
"version": "0.0.7",
"version": "0.0.8",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc