@dynamicforms/vue-forms 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- (function(l,u){typeof exports=="object"&&typeof module!="undefined"?u(exports,require("lodash-es"),require("vue")):typeof define=="function"&&define.amd?define(["exports","lodash-es","vue"],u):(l=typeof globalThis!="undefined"?globalThis:l||self,u((l["dynamicforms-vue-forms"]=l["dynamicforms-vue-forms"]||{},l["dynamicforms-vue-forms"]["[name]"]={}),l["lodash-es"],l.vue))})(this,(function(l,u,o){"use strict";var $e=Object.defineProperty,He=Object.defineProperties;var Ge=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var te=(l,u,o)=>u in l?$e(l,u,{enumerable:!0,configurable:!0,writable:!0,value:o}):l[u]=o,w=(l,u)=>{for(var o in u||(u={}))pe.call(u,o)&&te(l,o,u[o]);if($)for(var o of $(u))me.call(u,o)&&te(l,o,u[o]);return l},H=(l,u)=>He(l,Ge(u));var O=(l,u)=>{var o={};for(var m in l)pe.call(l,m)&&u.indexOf(m)<0&&(o[m]=l[m]);if(l!=null&&$)for(var m of $(l))u.indexOf(m)<0&&me.call(l,m)&&(o[m]=l[m]);return o};var h=(l,u,o)=>te(l,typeof u!="symbol"?u+"":u,o);var m=(s=>(s[s.SUPPRESS=1]="SUPPRESS",s[s.HIDDEN=5]="HIDDEN",s[s.INVISIBLE=8]="INVISIBLE",s[s.FULL=10]="FULL",s))(m||{});const ne=10;(s=>{function n(i){return i.toUpperCase()==="SUPPRESS"?1:i.toUpperCase()==="HIDDEN"?5:i.toUpperCase()==="INVISIBLE"?8:ne}s.fromString=n;function e(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)?r:ne}s.fromAny=e;function t(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)}s.isDefined=t})(m||(m={})),Object.freeze(m);const S=m;class y{constructor(n){h(this,"executorFn");this.executorFn=n}static get classIdentifier(){throw new Error("classIdentifier must be declared")}get classIdentifier(){return this.constructor.classIdentifier}execute(n,e,...t){return this.executorFn(n,e,...t)}get eager(){return!1}boundToField(n){}unregister(){}}class R extends Error{}const ie=Symbol("ValueChangedAction");class A extends y{constructor(n){super(n)}static get classIdentifier(){return ie}execute(n,e,t,i){return super.execute(n,e,t,i)}}class I extends String{constructor(e,t,i){super(e);h(this,"plugins");h(this,"options");this.plugins=i,this.options=t}}function U(s){const n=o.unref(s);return typeof n=="object"&&"componentName"in n}function T(s){return typeof o.unref(s)=="function"}class k{get componentName(){return"Comment"}get componentBindings(){return{}}get componentBody(){return""}get extraClasses(){return""}}class se extends k{constructor(n,e=""){super(),this.text=n,this.classes=e}get componentName(){return"template"}get componentBody(){return this.text}get extraClasses(){return this.classes}}class v extends k{constructor(e,t=""){super();h(this,"text");h(this,"textType");this.classes=t,this.text=e,this.textType=o.computed(()=>this.getTextType)}get resolvedText(){const e=o.unref(this.text);return T(e)?e():e}get getTextType(){const e=this.resolvedText;return e?e instanceof I?"md":U(e)?"component":"string":"string"}get componentName(){switch(o.unref(this.textType)){case"string":return"template";case"md":return"vue-markdown";case"component":return this.resolvedText.componentName;default:return"template"}}get componentBindings(){switch(o.unref(this.textType)){case"string":return{};case"md":{const e=this.resolvedText;return{source:e.toString(),options:e.options,plugins:e.plugins}}case"component":return this.resolvedText.componentProps||{};default:return{}}}get componentBody(){switch(o.unref(this.textType)){case"string":return this.resolvedText;case"component":return this.resolvedText.componentVHtml||"";default:return""}}get extraClasses(){return this.classes}}class re extends v{}const be=Symbol("Validator");class b extends A{constructor(e){super((i,r,a,c)=>{const d=e(a,c,i)||[],g=f=>{var P;f==null||f.forEach(_=>Object.defineProperty(_,"source",{value:this.source,enumerable:!1,configurable:!1}));for(let _=i.errors.length-1;_>=0;_--){const q=i.errors[_];if(q.source===this.source){const M=(P=f==null?void 0:f.findIndex(ee=>u.isEqual(ee,q)))!=null?P:-1;M>=0?f==null||f.splice(M,1):i.errors.splice(_,1)}}f&&f.length>0&&i.errors.push(...f),i.validate()};return d instanceof Promise?(i.validating=++i.validatingCount>0,d.then(f=>g(f)).finally(()=>{i.validatingCount=Math.max(0,i.validatingCount-1),i.validating=i.validatingCount>0})):g(d),r(i,a,c)});h(this,"source");this.source=Symbol(this.constructor.name)}static get classIdentifier(){return be}get eager(){return!0}replacePlaceholdersFunction(e,t){return()=>{let i=o.unref(e);for(;T(i);)i=o.unref(this.replacePlaceholders(i(),t));return i}}replacePlaceholders(e,t){if(T(e))return this.replacePlaceholdersFunction(e,t);if(U(e))return e;let i=o.unref(e);return Object.keys(t).forEach(r=>{i=i.replaceAll(`{${r}}`,t[r])}),e instanceof I?new I(i.toString(),e.options,e.plugins):i}}class x extends Map{constructor(){super(...arguments);h(this,"eagerActions",new Set);h(this,"registeredActions",[])}register(e){if(!(e instanceof y))throw new Error("Invalid action type");this.registeredActions.push(e);const t=e.classIdentifier,i=this.get(t)||(()=>null);function r(a,...c){return e.execute(a,i,...c)}this.set(t,r),e.eager&&this.eagerActions.add(e.classIdentifier)}trigger(e,t,...i){const r=e.classIdentifier;r===ie&&this.triggerEager(t,...i);const a=this.get(r);try{if(a)return a(t,...i)}catch(c){if(!(c instanceof R))throw c}return null}triggerEager(e,...t){for(const i of this.eagerActions){const r=this.get(i);try{r&&r(e,...t)}catch(a){if(!(a instanceof R))throw a}}}clone(){const e=new x;return this.registeredActions.forEach(t=>e.register(t)),e}cloneWithoutValidators(){const e=new x;return this.registeredActions.forEach(t=>{t instanceof b?t.unregister():e.register(t)}),e}}const ve=Symbol("ConditionalStatementAction");class N extends A{constructor(e,t){const i=(r,a,c,d)=>{const g=e.evaluate();if(g!==this.lastResult){for(const f of this.boundFields)t(f,g,this.lastResult);this.lastResult=g}return a(r,c,d)};super(i);h(this,"lastResult");h(this,"boundFields",new Set);e.collectFields().forEach(r=>r.registerAction(new A(i)))}static get classIdentifier(){return ve}get eager(){return!0}boundToField(e){this.boundFields.add(e)}}class ae extends N{constructor(n){super(n,(e,t)=>{e.visibility=t?S.FULL:S.SUPPRESS})}}class le extends N{constructor(n){super(n,(e,t)=>{e.enabled=t})}}class oe extends N{constructor(n,e){super(n,(t,i)=>{i&&(t.value=e)})}}var L=(s=>(s[s.NOT=0]="NOT",s[s.OR=1]="OR",s[s.AND=2]="AND",s[s.XOR=3]="XOR",s[s.NAND=4]="NAND",s[s.NOR=5]="NOR",s[s.EQUALS=-1]="EQUALS",s[s.NOT_EQUALS=-2]="NOT_EQUALS",s[s.GT=-3]="GT",s[s.LT=-4]="LT",s[s.GE=-5]="GE",s[s.LE=-6]="LE",s[s.IN=-7]="IN",s[s.NOT_IN=-8]="NOT_IN",s[s.INCLUDES=-9]="INCLUDES",s[s.NOT_INCLUDES=-10]="NOT_INCLUDES",s))(L||{});(s=>{function n(r){const a=r.toLowerCase();if(a==="not")return 0;if(a==="or")return 1;if(a==="and")return 2;if(a==="xor")return 3;if(a==="nand")return 4;if(a==="nor")return 5;if(a==="equals")return-1;if(["not_equals","not-equals","not equals"].includes(a))return-2;if(a==="gt")return-3;if(a==="lt")return-4;if(a==="ge")return-5;if(a==="le")return-6;if(a==="in")return-7;if(["not_in","not-in","not in"].includes(a))return-8;if(a==="includes")return-9;if(["not_includes","not-includes","not includes"].includes(a))return-10;throw new Error(`Unrecognised operator ${a}`)}s.fromString=n;function e(r){const a=typeof r=="number"?r:s.fromString(r);if(Object.values(s).includes(a))return a;throw new Error(`Unrecognised operator ${r}`)}s.fromAny=e;function t(r){const a=typeof r=="number"?r:s.fromString(r);return Object.values(s).includes(a)}s.isDefined=t;function i(r){return r>=0}s.isLogicOperator=i})(L||(L={})),Object.freeze(L);const p=L,ye=Symbol("EnabledChangingAction");class G extends y{constructor(n){super(n)}static get classIdentifier(){return ye}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ae=Symbol("EnabledChangedAction");class Q extends y{constructor(n){super(n)}static get classIdentifier(){return Ae}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ce=Symbol("ValidChangedAction");class z extends y{constructor(n){super(n)}static get classIdentifier(){return Ce}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ee=Symbol("VisibilityChangingAction");class W extends y{constructor(n){super(n)}static get classIdentifier(){return Ee}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ve=Symbol("VisibilityChangedAction");class X extends y{constructor(n){super(n)}static get classIdentifier(){return Ve}execute(n,e,t,i){return super.execute(n,e,t,i)}}class E{constructor(){h(this,"reactiveValue",o.computed(()=>this.value));h(this,"validatingCount",0);h(this,"validating",!1);h(this,"_valid",!0);h(this,"errors",[]);h(this,"actions",new x);h(this,"_visibility",S.FULL);h(this,"_enabled",!0)}get visibility(){return this._visibility}set visibility(n){const e=this._visibility,t=this.actions.trigger(W,this,n,e);if(!S.isDefined(t!=null?t:n))throw new Error("visibility must be a DisplayMode constant");this._visibility=S.fromAny(t!=null?t:n),this.actions.trigger(X,this,this._visibility,e)}get enabled(){return this._enabled}set enabled(n){const e=this._enabled,t=this.actions.trigger(G,this,n,e);if(!u.isBoolean(t!=null?t:n))throw new Error("Enabled value must be boolean");this._enabled=t!=null?t:n,this.actions.trigger(Q,this,this._enabled,e)}validate(n=!1){n&&this.actions.triggerEager(this,this.value,this.value);const e=this._valid;this._valid=this.valid,this._valid!==e&&this.actions.trigger(z,this,this.valid,e)}get valid(){return this.errors.length===0}get fullValue(){return this.value}get isChanged(){return!u.isEqual(this.value,this.originalValue)}registerAction(n){const e=n;return this.actions.register(e),e.boundToField(this),e.eager&&this.actions.trigger(Object.getPrototypeOf(n).constructor,this,this.value,this.originalValue),this}triggerAction(n,...e){return this.actions.trigger(n,this,...e)}clearValidators(){this.actions=this.actions.cloneWithoutValidators(),this.errors=[],this._valid=!0}}function _e(s,n){return s?!n:n}class F{constructor(n,e,t){h(this,"operand1");h(this,"operator");h(this,"operand2");this.operand1=n,this.operator=e,this.operand2=t}get operand1Value(){return this.operand1 instanceof F?this.operand1.evaluate():this.operand1 instanceof E?o.unref(this.operand1.value):this.operand1}get operand2Value(){return this.operand2 instanceof F?this.operand2.evaluate():this.operand2 instanceof E?o.unref(this.operand2.value):this.operand2}evaluate(){var t,i,r,a;const n=this.operand1Value,e=this.operand2Value;switch(this.operator){case p.AND:return n&&e;case p.OR:return n||e;case p.NAND:return!(n&&e);case p.NOR:return!(n||e);case p.XOR:return _e(n,e);case p.NOT:return!n;case p.EQUALS:return n==e;case p.NOT_EQUALS:return n!=e;case p.LT:return n<e;case p.LE:return n<=e;case p.GE:return n>=e;case p.GT:return n>e;case p.IN:return(i=(t=e==null?void 0:e.includes)==null?void 0:t.call(e,n))!=null?i:!1;case p.NOT_IN:return!((a=(r=e==null?void 0:e.includes)==null?void 0:r.call(e,n))==null||a);case p.INCLUDES:return u.isString(n)&&u.isString(e)&&n.indexOf(e)>=0;case p.NOT_INCLUDES:return!(u.isString(n)&&u.isString(e)&&n.indexOf(e)>=0);default:throw new Error(`Operator not implemented ${this.operator}`)}}collectFields(){const n=new Set;function e(t){t instanceof E?n.add(t):t instanceof F&&t.collectFields().forEach(r=>n.add(r))}return e(this.operand1),e(this.operand2),n}}const Se=Symbol("ExecuteAction");class Y extends y{constructor(n){super(n)}static get classIdentifier(){return Se}execute(n,e,t){return super.execute(n,e,t)}}const Ie=Symbol("ListItemAddedAction");class B extends y{constructor(n){super(n)}static get classIdentifier(){return Ie}execute(n,e,t,i){return super.execute(n,e,t,i)}}const xe=Symbol("ListItemRemovedAction");class J extends y{constructor(n){super(n)}static get classIdentifier(){return xe}execute(n,e,t,i){return super.execute(n,e,t,i)}}const ce=Symbol("FieldConstructorGuard");class j extends E{constructor(e){super();h(this,"_value");h(this,"_touched",!1);if(e!==ce){const t=this.constructor.name;throw new TypeError(`Don't use constructor to instantiate ${t}. Use ${t}.create<T>`)}}init(e){if(e){const t=e,{value:i,validators:r,actions:a}=t,c=O(t,["value","validators","actions"]);[...r||[],...a||[]].forEach(d=>this.registerAction(d)),Object.assign(this,c),this._value=i!=null?i:this.originalValue,this.originalValue===void 0&&(this.originalValue=this._value)}this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}static create(e){const t=o.reactive(new this(ce));return t.init(e),t}get value(){return this._value}set value(e){const t=this._value;!this.enabled||t===e||(this._value=e,this.actions.trigger(A,this,this._value,t),this.parent&&this.parent.notifyValueChanged(),this.validate())}get touched(){return this._touched}set touched(e){this._touched=e}clone(e){var i,r,a;const t=this.constructor.create(H(w({value:(i=e==null?void 0:e.value)!=null?i:this.value},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(r=e==null?void 0:e.enabled)!=null?r:this.enabled,visibility:(a=e==null?void 0:e.visibility)!=null?a:this.visibility}));return t.actions=this.actions.clone(),t.actions.triggerEager(t,t.value,t.originalValue),t}}const ue=j.create({value:"EmptyField"}).registerAction(new A(()=>{console.warn("Working with EmptyField! This should not happen")}));function K(s,n){return(s==null?void 0:s.label)==null&&(s==null?void 0:s.icon)==null?n:s}class he extends j{constructor(n){super(n),this._value={label:void 0,icon:void 0}}init(n){if(n){const e=n,{value:t,originalValue:i,validators:r,actions:a}=e,c=O(e,["value","originalValue","validators","actions"]);[...r||[],...a||[]].forEach(f=>this.registerAction(f)),Object.assign(this,c);const d=K(t,this._value),g=Object.freeze({label:i==null?void 0:i.label,icon:i==null?void 0:i.icon});this._value=K(d,g),this.originalValue=K(g,d)}this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}static create(n){return super.create(n)}get icon(){return this.value.icon}set icon(n){this.value.icon=n}get label(){return this.value.label}set label(n){this.value.label=n}execute(n){this.actions.trigger(Y,this,n)}}const de=o.defineComponent({__name:"messages-widget",props:{message:{},classes:{}},setup(s){const n=s,e=o.resolveComponent("vue-markdown"),t=new Set(["div","span","p","h1","h2","h3","h4","h5","h6","section","article","aside","nav","header","footer","main","figure","figcaption","blockquote","pre","code","em","strong","small","mark","del","ins","sub","sup","i","b","u","s","a","img","button","input","textarea","select","option","label","form","table","tr","td","th","thead","tbody","tfoot","ul","ol","li","dl","dt","dd"]),i=()=>{if(typeof n.message=="string")return o.h("span",{class:n.classes},n.message);const r=[];return n.message.forEach(a=>{switch(a.componentName){case"template":r.push(o.h("div",{class:[n.classes,a.extraClasses]},a.componentBody));break;case"vue-markdown":if(typeof e=="string")console.warn("You are using markdown for messages-widget, but you haven't registered a vue-markdown component"),r.push(o.h("div",{class:[n.classes,a.extraClasses]},a.componentBindings.source));else{const c=a.componentBindings;r.push(o.h(e,{class:[n.classes,a.extraClasses,"df-messages-widget-markdown"],source:c.source,options:c.options,plugins:c.plugins}))}break;default:r.push(o.h(t.has(a.componentName.toLowerCase())?a.componentName:o.resolveComponent(a.componentName),w(w({class:[n.classes,a.extraClasses]},a.componentBindings),a.componentBody?{innerHTML:a.componentBody}:{})));break}}),r};return(r,a)=>(o.openBlock(),o.createBlock(i))}});class V extends E{constructor(e,t){super();h(this,"_fields");h(this,"_value",null);h(this,"reactiveValue",o.computed(()=>this.value));h(this,"suppressNotifyValueChanged",!1);if(!V.isValidFields(e))throw new Error("Invalid fields object provided");if(this._fields={},Object.entries(e).forEach(([r,a])=>this.addField(r,a)),t){const i=t,{value:r,validators:a,actions:c}=i,d=O(i,["value","validators","actions"]);[...a||[],...c||[]].forEach(g=>this.registerAction(g)),Object.assign(this,d),this.value=r!=null?r:this.originalValue}this.originalValue===void 0&&(this.originalValue=this.value),this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}addField(e,t){if(this.fields[e]!==void 0)throw new Error(`Field ${e} is already in this form`);Object.defineProperty(t,"parent",{get:()=>this,configurable:!1,enumerable:!1}),Object.defineProperty(t,"fieldName",{get:()=>e,configurable:!1,enumerable:!1}),Object.defineProperty(this._fields,e,{get(){return t},configurable:!1,enumerable:!0})}static isValidFields(e){function t(i){return i instanceof E}return typeof e=="object"&&e!==null&&Object.entries(e).every(([,i])=>t(i))}static createFromFormData(e){if(e instanceof E)throw new Error("data is already a Form structure, should be a simple object");return new V(e==null?{}:Object.fromEntries(Object.entries(e).map(([t,i])=>[t,j.create({value:i})])))}field(e){var t;return(t=this._fields[e])!=null?t:null}get fields(){return this._fields}get value(){const e={};return Object.entries(this._fields).forEach(([t,i])=>{const r=i.value;(i.enabled||i instanceof V&&!u.isEmpty(r))&&(e[t]=r)}),u.isEmpty(e)?null:e}set value(e){this.suppressNotifyValueChanged=!0;try{Object.entries(this._fields).forEach(([t,i])=>{(e==null||t in e)&&(i.value=e==null?null:e[t])})}finally{this.suppressNotifyValueChanged=!1}this.notifyValueChanged(),this.validate()}get touched(){return Object.values(this._fields).some(e=>e.touched)}set touched(e){Object.values(this._fields).forEach(t=>{t.touched=e})}get fullValue(){const e={};return Object.entries(this._fields).forEach(([t,i])=>{e[t]=i.fullValue}),e}notifyValueChanged(){if(this.suppressNotifyValueChanged)return;const e=this.value;if(!u.isEqual(e,this._value)){const t=this._value;this._value=e,this.actions.trigger(A,this,e,t),this.parent&&this.parent.notifyValueChanged(),this.validate()}}get valid(){return super.valid&&Object.values(this._fields).every(e=>e.valid)}validate(e=!1){e&&Object.values(this._fields).forEach(t=>t.validate(!0)),super.validate(e)}clone(e){var r,a,c;const t={};Object.entries(this._fields).forEach(([d,g])=>{t[d]=g.clone()});const i=new V(t,H(w({value:(r=e==null?void 0:e.value)!=null?r:this.value},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(a=e==null?void 0:e.enabled)!=null?a:this.enabled,visibility:(c=e==null?void 0:e.visibility)!=null?c:this.visibility}));return i.actions=this.actions.clone(),i.actions.triggerEager(i,i.value,i.originalValue),i}}class D extends E{constructor(e,t){super();h(this,"_value",null);h(this,"_itemTemplate");h(this,"_previousValue");if(this._itemTemplate=e,t){const i=t,{value:r,validators:a,actions:c}=i,d=O(i,["value","validators","actions"]);[...a||[],...c||[]].forEach(g=>this.registerAction(g)),Object.assign(this,d),r&&this.setValueInternal(r)}this.originalValue===void 0&&(this.originalValue=this.value),this._previousValue=this.value,this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}processSetValueItem(e){let t;return e instanceof V?t=e:this._itemTemplate?t=this._itemTemplate.clone({value:e}):t=V.createFromFormData(e),Object.defineProperty(t,"parent",{get:()=>this,configurable:!1,enumerable:!1}),t}setValueInternal(e){Array.isArray(e)&&(this._value=e.map(t=>this.processSetValueItem(t)))}get value(){var t;const e=(t=this._value)==null?void 0:t.map(i=>i.value);return u.isEmpty(e)?null:e}set value(e){const t=this.value;this.setValueInternal(e),this.actions.trigger(A,this,this.value,t),this.parent&&this.parent.notifyValueChanged(),this.validate()}get touched(){var e;return((e=this._value)==null?void 0:e.some(t=>t.touched))||!1}set touched(e){var t;(t=this._value)==null||t.forEach(i=>{i.touched=e})}clone(e){var i,r,a,c;const t=new D((i=this._itemTemplate)==null?void 0:i.clone(),H(w({value:[...(r=e==null?void 0:e.value)!=null?r:this.value]},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(a=e==null?void 0:e.enabled)!=null?a:this.enabled,visibility:(c=e==null?void 0:e.visibility)!=null?c:this.visibility}));return t.actions=this.actions.clone(),t.actions.triggerEager(t,t.value,t.originalValue),t}notifyValueChanged(){const e=this.value;if(!u.isEqual(e,this._previousValue)){const t=this._previousValue;this._previousValue=e,this.actions.trigger(A,this,e,t),this.parent&&this.parent.notifyValueChanged(),this.validate()}}get valid(){var e,t;return super.valid&&((t=(e=this._value)==null?void 0:e.every(i=>i.valid))!=null?t:!0)}validate(e=!1){var t;e&&((t=this._value)==null||t.forEach(i=>i.validate(!0))),super.validate(e)}get(e){return this._value!=null?this._value[e]:void 0}push(e){var t,i;return this.insert(e,(i=(t=this._value)==null?void 0:t.length)!=null?i:0)+1}pop(){var e,t;return this.remove(((t=(e=this._value)==null?void 0:e.length)!=null?t:0)-1)}remove(e){var i;if(this._value==null||e<0||this._value.length<=e)return;let t=(i=this._value.splice(e,1))==null?void 0:i[0];return t&&(t=t.clone(),this.actions.trigger(J,this,t,e),this.notifyValueChanged()),t}insert(e,t){for(this._value==null&&(this._value=[]);this._value.length<t;){const r=this.processSetValueItem(null),a=this._value.push(r);this.actions.trigger(B,this,r,a)}const i=this.processSetValueItem(e);return this._value.splice(t,0,i),this.actions.trigger(B,this,i,t),this.notifyValueChanged(),t}clear(){this._value=null,this.notifyValueChanged()}}const ge={useMarkdownInValidators:!0};function Fe(){return ge}function we(s){Object.assign(ge,s)}const Te={install(s,n){n&&we(n)}};function C(s){return Fe().useMarkdownInValidators?new I(s):s.replace(/[*_~`]/g,"").replace(/!\[(.*?)\]\(.*?\)/g,"$1").replace(/\[(.*?)\]\((.*?)\)/g,"$1").replace(/#+\s?/g,"").replace(/>\s?/g,"").replace(/(\*|-|\d+\.)\s+/g,"").replace(/`{3}[\s\S]*?`{3}/g,"").replace(/`([^`]+)`/g,"$1").replace(/\n{2,}/g,`
2
- `)}class Ne extends b{constructor(e,t,i){let r=!1,a,c;super((g,f,P)=>(a=g,c=f,r||(r=!0,this.otherField.registerAction(new A((_,q,M,ee)=>{q(_,M,ee),this.unregistered||this.execute(P,()=>null,a,c)}))),this.isValidComparison(o.unref(g),o.unref(this.otherField.value))?null:[new v(this.replacePlaceholders(i,{newValue:g,oldValue:f,field:P,otherField:this.otherField}))]));h(this,"unregistered",!1);this.otherField=e,this.isValidComparison=t}unregister(){this.unregistered=!0}}class Le extends b{constructor(n,e){const t=e||C("Must be one of [**{allowedAsText}**]");let i=n.join(", ");i.length>60&&(i=u.truncate(i,{length:40,separator:", ",omission:`... (${n.length} items total)`}));const r=(a,c,d)=>n.includes(o.unref(a))?null:[new v(this.replacePlaceholders(t,{newValue:a,oldValue:c,field:d,allowedValues:n,allowedAsText:i}))];super(r)}}function je(s){return s==null?0:u.isArray(s)||u.isString(s)?s.length:u.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class Pe extends b{constructor(n){const e=n||C("Please enter a value"),t=(i,r,a)=>je(o.unref(i))===0?[new v(this.replacePlaceholders(e,{newValue:i,oldValue:r,field:a}))]:null;super(t)}}class Oe extends b{constructor(n,e){const t=e||C("Value must be larger or equal to **{minValue}**"),i=(r,a,c)=>r<n||r===void 0?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,minValue:n}))]:null;super(i)}}class Re extends b{constructor(n,e){const t=e||C("Value must be less than or equal to **{maxValue}**"),i=(r,a,c)=>r>n||r===void 0?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,maxValue:n}))]:null;super(i)}}class Ue extends b{constructor(n,e,t){const i=t||C("Value must be between **{minValue}** and **{maxValue}**"),r=(a,c,d)=>a<n||a>e||a===void 0?[new v(this.replacePlaceholders(i,{newValue:a,oldValue:c,field:d,minValue:n,maxValue:e}))]:null;super(r)}}function Z(s){return s==null?0:u.isArray(s)||u.isString(s)?s.length:u.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class ke extends b{constructor(n,e){const t=e||C("Length must be larger or equal to **{minLength}**"),i=(r,a,c)=>Z(r)<n?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,minLength:n}))]:null;super(i)}}class Be extends b{constructor(n,e){const t=e||C("Length must be less than or equal to **{maxLength}**"),i=(r,a,c)=>Z(r)>n?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,maxLength:n}))]:null;super(i)}}class De extends b{constructor(n,e,t){const i=t||C("Length must be between **{minLength}** and **{maxLength}**"),r=(a,c,d)=>{const g=Z(a);return g<n||g>e?[new v(this.replacePlaceholders(i,{newValue:a,oldValue:c,field:d,minLength:n,maxLength:e}))]:null};super(r)}}class qe extends b{constructor(n,e){const t=e||C('Value must match pattern "**{pattern}**"'),i=(r,a,c)=>n.test(String(o.unref(r)))?null:[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,pattern:n}))];super(i)}}const fe=Object.freeze(Object.defineProperty({__proto__:null,CompareTo:Ne,InAllowedValues:Le,LengthInRange:De,MaxLength:Be,MaxValue:Re,MinLength:ke,MinValue:Oe,Pattern:qe,Required:Pe,Validator:b,ValueInRange:Ue},Symbol.toStringTag,{value:"Module"})),Me=Object.freeze(Object.defineProperty({__proto__:null,AbortEventHandlingException:R,Action:he,ActionsMap:x,ConditionalEnabledAction:le,ConditionalStatementAction:N,ConditionalValueAction:oe,ConditionalVisibilityAction:ae,DisplayMode:S,EmptyField:ue,EnabledChangedAction:Q,EnabledChangingAction:G,ExecuteAction:Y,Field:j,FieldActionBase:y,FieldBase:E,Group:V,List:D,ListItemAddedAction:B,ListItemRemovedAction:J,MdString:I,MessagesWidget:de,Operator:p,RenderableValue:re,Statement:F,ValidChangedAction:z,ValidationError:k,ValidationErrorRenderContent:v,ValidationErrorText:se,Validator:b,Validators:fe,ValueChangedAction:A,VisibilityChangedAction:X,VisibilityChangingAction:W,buildErrorMessage:C,isCallableFunction:T,isSimpleComponentDef:U},Symbol.toStringTag,{value:"Module"}));l.AbortEventHandlingException=R,l.Action=he,l.ActionsMap=x,l.ConditionalEnabledAction=le,l.ConditionalStatementAction=N,l.ConditionalValueAction=oe,l.ConditionalVisibilityAction=ae,l.DisplayMode=S,l.EmptyField=ue,l.EnabledChangedAction=Q,l.EnabledChangingAction=G,l.ExecuteAction=Y,l.Field=j,l.FieldActionBase=y,l.FieldBase=E,l.Group=V,l.List=D,l.ListItemAddedAction=B,l.ListItemRemovedAction=J,l.MdString=I,l.MessagesWidget=de,l.Operator=p,l.RenderableValue=re,l.Statement=F,l.ValidChangedAction=z,l.ValidationError=k,l.ValidationErrorRenderContent=v,l.ValidationErrorText=se,l.Validator=b,l.Validators=fe,l.ValueChangedAction=A,l.VisibilityChangedAction=X,l.VisibilityChangingAction=W,l.buildErrorMessage=C,l.default=Me,l.forms=Te,l.isCallableFunction=T,l.isSimpleComponentDef=U,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(l,u){typeof exports=="object"&&typeof module!="undefined"?u(exports,require("lodash-es"),require("vue")):typeof define=="function"&&define.amd?define(["exports","lodash-es","vue"],u):(l=typeof globalThis!="undefined"?globalThis:l||self,u((l["dynamicforms-vue-forms"]=l["dynamicforms-vue-forms"]||{},l["dynamicforms-vue-forms"]["[name]"]={}),l["lodash-es"],l.vue))})(this,(function(l,u,o){"use strict";var $e=Object.defineProperty,He=Object.defineProperties;var Ge=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var te=(l,u,o)=>u in l?$e(l,u,{enumerable:!0,configurable:!0,writable:!0,value:o}):l[u]=o,w=(l,u)=>{for(var o in u||(u={}))pe.call(u,o)&&te(l,o,u[o]);if($)for(var o of $(u))me.call(u,o)&&te(l,o,u[o]);return l},H=(l,u)=>He(l,Ge(u));var O=(l,u)=>{var o={};for(var m in l)pe.call(l,m)&&u.indexOf(m)<0&&(o[m]=l[m]);if(l!=null&&$)for(var m of $(l))u.indexOf(m)<0&&me.call(l,m)&&(o[m]=l[m]);return o};var h=(l,u,o)=>te(l,typeof u!="symbol"?u+"":u,o);var m=(s=>(s[s.SUPPRESS=1]="SUPPRESS",s[s.HIDDEN=5]="HIDDEN",s[s.INVISIBLE=8]="INVISIBLE",s[s.FULL=10]="FULL",s))(m||{});const ne=10;(s=>{function n(i){return i.toUpperCase()==="SUPPRESS"?1:i.toUpperCase()==="HIDDEN"?5:i.toUpperCase()==="INVISIBLE"?8:ne}s.fromString=n;function e(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)?r:ne}s.fromAny=e;function t(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)}s.isDefined=t})(m||(m={})),Object.freeze(m);const S=m;class y{constructor(n){h(this,"executorFn");this.executorFn=n}static get classIdentifier(){throw new Error("classIdentifier must be declared")}get classIdentifier(){return this.constructor.classIdentifier}execute(n,e,...t){return this.executorFn(n,e,...t)}get eager(){return!1}boundToField(n){}unregister(){}}class R extends Error{}const ie=Symbol("ValueChangedAction");class C extends y{constructor(n){super(n)}static get classIdentifier(){return ie}execute(n,e,t,i){return super.execute(n,e,t,i)}}class I extends String{constructor(e,t,i){super(e);h(this,"plugins");h(this,"options");this.plugins=i,this.options=t}}function U(s){const n=o.unref(s);return typeof n=="object"&&"componentName"in n}function T(s){return typeof o.unref(s)=="function"}class k{get componentName(){return"Comment"}get componentBindings(){return{}}get componentBody(){return""}get extraClasses(){return""}}class se extends k{constructor(e,t=""){super();h(this,"text");h(this,"classes");this.text=e,this.classes=t}get componentName(){return"template"}get componentBody(){return this.text}get extraClasses(){return this.classes}}class v extends k{constructor(e,t=""){super();h(this,"classes");h(this,"text");h(this,"textType");this.classes=t,this.text=e,this.textType=o.computed(()=>this.getTextType)}get resolvedText(){const e=o.unref(this.text);return T(e)?e():e}get getTextType(){const e=this.resolvedText;return e?e instanceof I?"md":U(e)?"component":"string":"string"}get componentName(){switch(o.unref(this.textType)){case"string":return"template";case"md":return"vue-markdown";case"component":return this.resolvedText.componentName;default:return"template"}}get componentBindings(){switch(o.unref(this.textType)){case"string":return{};case"md":{const e=this.resolvedText;return{source:e.toString(),options:e.options,plugins:e.plugins}}case"component":return this.resolvedText.componentProps||{};default:return{}}}get componentBody(){switch(o.unref(this.textType)){case"string":return this.resolvedText;case"component":return this.resolvedText.componentVHtml||"";default:return""}}get extraClasses(){return this.classes}}class re extends v{}const be=Symbol("Validator");class b extends C{constructor(e){super((i,r,a,c)=>{const d=e(a,c,i)||[],g=f=>{var P;f==null||f.forEach(_=>Object.defineProperty(_,"source",{value:this.source,enumerable:!1,configurable:!1}));for(let _=i.errors.length-1;_>=0;_--){const q=i.errors[_];if(q.source===this.source){const M=(P=f==null?void 0:f.findIndex(ee=>u.isEqual(ee,q)))!=null?P:-1;M>=0?f==null||f.splice(M,1):i.errors.splice(_,1)}}f&&f.length>0&&i.errors.push(...f),i.validate()};return d instanceof Promise?(i.validating=++i.validatingCount>0,d.then(f=>g(f)).finally(()=>{i.validatingCount=Math.max(0,i.validatingCount-1),i.validating=i.validatingCount>0})):g(d),r(i,a,c)});h(this,"source");this.source=Symbol(this.constructor.name)}static get classIdentifier(){return be}get eager(){return!0}replacePlaceholdersFunction(e,t){return()=>{let i=o.unref(e);for(;T(i);)i=o.unref(this.replacePlaceholders(i(),t));return i}}replacePlaceholders(e,t){if(T(e))return this.replacePlaceholdersFunction(e,t);if(U(e))return e;let i=o.unref(e);return Object.keys(t).forEach(r=>{i=i.replaceAll(`{${r}}`,t[r])}),e instanceof I?new I(i.toString(),e.options,e.plugins):i}}class x extends Map{constructor(){super(...arguments);h(this,"eagerActions",new Set);h(this,"registeredActions",[])}register(e){if(!(e instanceof y))throw new Error("Invalid action type");this.registeredActions.push(e);const t=e.classIdentifier,i=this.get(t)||(()=>null);function r(a,...c){return e.execute(a,i,...c)}this.set(t,r),e.eager&&this.eagerActions.add(e.classIdentifier)}trigger(e,t,...i){const r=e.classIdentifier;r===ie&&this.triggerEager(t,...i);const a=this.get(r);try{if(a)return a(t,...i)}catch(c){if(!(c instanceof R))throw c}return null}triggerEager(e,...t){for(const i of this.eagerActions){const r=this.get(i);try{r&&r(e,...t)}catch(a){if(!(a instanceof R))throw a}}}clone(){const e=new x;return this.registeredActions.forEach(t=>e.register(t)),e}cloneWithoutValidators(){const e=new x;return this.registeredActions.forEach(t=>{t instanceof b?t.unregister():e.register(t)}),e}}const ve=Symbol("ConditionalStatementAction");class N extends C{constructor(e,t){const i=(r,a,c,d)=>{const g=e.evaluate();if(g!==this.lastResult){for(const f of this.boundFields)t(f,g,this.lastResult);this.lastResult=g}return a(r,c,d)};super(i);h(this,"lastResult");h(this,"boundFields",new Set);e.collectFields().forEach(r=>r.registerAction(new C(i)))}static get classIdentifier(){return ve}get eager(){return!0}boundToField(e){this.boundFields.add(e)}}class ae extends N{constructor(n){super(n,(e,t)=>{e.visibility=t?S.FULL:S.SUPPRESS})}}class le extends N{constructor(n){super(n,(e,t)=>{e.enabled=t})}}class oe extends N{constructor(n,e){super(n,(t,i)=>{i&&(t.value=e)})}}var L=(s=>(s[s.NOT=0]="NOT",s[s.OR=1]="OR",s[s.AND=2]="AND",s[s.XOR=3]="XOR",s[s.NAND=4]="NAND",s[s.NOR=5]="NOR",s[s.EQUALS=-1]="EQUALS",s[s.NOT_EQUALS=-2]="NOT_EQUALS",s[s.GT=-3]="GT",s[s.LT=-4]="LT",s[s.GE=-5]="GE",s[s.LE=-6]="LE",s[s.IN=-7]="IN",s[s.NOT_IN=-8]="NOT_IN",s[s.INCLUDES=-9]="INCLUDES",s[s.NOT_INCLUDES=-10]="NOT_INCLUDES",s))(L||{});(s=>{function n(r){const a=r.toLowerCase();if(a==="not")return 0;if(a==="or")return 1;if(a==="and")return 2;if(a==="xor")return 3;if(a==="nand")return 4;if(a==="nor")return 5;if(a==="equals")return-1;if(["not_equals","not-equals","not equals"].includes(a))return-2;if(a==="gt")return-3;if(a==="lt")return-4;if(a==="ge")return-5;if(a==="le")return-6;if(a==="in")return-7;if(["not_in","not-in","not in"].includes(a))return-8;if(a==="includes")return-9;if(["not_includes","not-includes","not includes"].includes(a))return-10;throw new Error(`Unrecognised operator ${a}`)}s.fromString=n;function e(r){const a=typeof r=="number"?r:s.fromString(r);if(Object.values(s).includes(a))return a;throw new Error(`Unrecognised operator ${r}`)}s.fromAny=e;function t(r){const a=typeof r=="number"?r:s.fromString(r);return Object.values(s).includes(a)}s.isDefined=t;function i(r){return r>=0}s.isLogicOperator=i})(L||(L={})),Object.freeze(L);const p=L,ye=Symbol("EnabledChangingAction");class G extends y{constructor(n){super(n)}static get classIdentifier(){return ye}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ce=Symbol("EnabledChangedAction");class Q extends y{constructor(n){super(n)}static get classIdentifier(){return Ce}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ae=Symbol("ValidChangedAction");class z extends y{constructor(n){super(n)}static get classIdentifier(){return Ae}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ve=Symbol("VisibilityChangingAction");class W extends y{constructor(n){super(n)}static get classIdentifier(){return Ve}execute(n,e,t,i){return super.execute(n,e,t,i)}}const Ee=Symbol("VisibilityChangedAction");class X extends y{constructor(n){super(n)}static get classIdentifier(){return Ee}execute(n,e,t,i){return super.execute(n,e,t,i)}}class V{constructor(){h(this,"reactiveValue",o.computed(()=>this.value));h(this,"validatingCount",0);h(this,"validating",!1);h(this,"_valid",!0);h(this,"errors",[]);h(this,"actions",new x);h(this,"_visibility",S.FULL);h(this,"_enabled",!0)}get visibility(){return this._visibility}set visibility(n){const e=this._visibility,t=this.actions.trigger(W,this,n,e);if(!S.isDefined(t!=null?t:n))throw new Error("visibility must be a DisplayMode constant");this._visibility=S.fromAny(t!=null?t:n),this.actions.trigger(X,this,this._visibility,e)}get enabled(){return this._enabled}set enabled(n){const e=this._enabled,t=this.actions.trigger(G,this,n,e);if(!u.isBoolean(t!=null?t:n))throw new Error("Enabled value must be boolean");this._enabled=t!=null?t:n,this.actions.trigger(Q,this,this._enabled,e)}validate(n=!1){n&&this.actions.triggerEager(this,this.value,this.value);const e=this._valid;this._valid=this.valid,this._valid!==e&&this.actions.trigger(z,this,this.valid,e)}get valid(){return this.errors.length===0}get fullValue(){return this.value}get isChanged(){return!u.isEqual(this.value,this.originalValue)}registerAction(n){const e=n;return this.actions.register(e),e.boundToField(this),e.eager&&this.actions.trigger(Object.getPrototypeOf(n).constructor,this,this.value,this.originalValue),this}triggerAction(n,...e){return this.actions.trigger(n,this,...e)}clearValidators(){this.actions=this.actions.cloneWithoutValidators(),this.errors=[],this._valid=!0}}function _e(s,n){return s?!n:n}class F{constructor(n,e,t){h(this,"operand1");h(this,"operator");h(this,"operand2");this.operand1=n,this.operator=e,this.operand2=t}get operand1Value(){return this.operand1 instanceof F?this.operand1.evaluate():this.operand1 instanceof V?o.unref(this.operand1.value):this.operand1}get operand2Value(){return this.operand2 instanceof F?this.operand2.evaluate():this.operand2 instanceof V?o.unref(this.operand2.value):this.operand2}evaluate(){var t,i,r,a;const n=this.operand1Value,e=this.operand2Value;switch(this.operator){case p.AND:return n&&e;case p.OR:return n||e;case p.NAND:return!(n&&e);case p.NOR:return!(n||e);case p.XOR:return _e(n,e);case p.NOT:return!n;case p.EQUALS:return n==e;case p.NOT_EQUALS:return n!=e;case p.LT:return n<e;case p.LE:return n<=e;case p.GE:return n>=e;case p.GT:return n>e;case p.IN:return(i=(t=e==null?void 0:e.includes)==null?void 0:t.call(e,n))!=null?i:!1;case p.NOT_IN:return!((a=(r=e==null?void 0:e.includes)==null?void 0:r.call(e,n))==null||a);case p.INCLUDES:return u.isString(n)&&u.isString(e)&&n.indexOf(e)>=0;case p.NOT_INCLUDES:return!(u.isString(n)&&u.isString(e)&&n.indexOf(e)>=0);default:throw new Error(`Operator not implemented ${this.operator}`)}}collectFields(){const n=new Set;function e(t){t instanceof V?n.add(t):t instanceof F&&t.collectFields().forEach(r=>n.add(r))}return e(this.operand1),e(this.operand2),n}}const Se=Symbol("ExecuteAction");class Y extends y{constructor(n){super(n)}static get classIdentifier(){return Se}execute(n,e,t){return super.execute(n,e,t)}}const Ie=Symbol("ListItemAddedAction");class B extends y{constructor(n){super(n)}static get classIdentifier(){return Ie}execute(n,e,t,i){return super.execute(n,e,t,i)}}const xe=Symbol("ListItemRemovedAction");class J extends y{constructor(n){super(n)}static get classIdentifier(){return xe}execute(n,e,t,i){return super.execute(n,e,t,i)}}const ce=Symbol("FieldConstructorGuard");class j extends V{constructor(e){super();h(this,"_value");h(this,"_touched",!1);if(e!==ce){const t=this.constructor.name;throw new TypeError(`Don't use constructor to instantiate ${t}. Use ${t}.create<T>`)}}init(e){if(e){const t=e,{value:i,validators:r,actions:a}=t,c=O(t,["value","validators","actions"]);[...r||[],...a||[]].forEach(d=>this.registerAction(d)),Object.assign(this,c),this._value=i!=null?i:this.originalValue,this.originalValue===void 0&&(this.originalValue=this._value)}this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}static create(e){const t=o.reactive(new this(ce));return t.init(e),t}get value(){return this._value}set value(e){const t=this._value;!this.enabled||t===e||(this._value=e,this.actions.trigger(C,this,this._value,t),this.parent&&this.parent.notifyValueChanged(),this.validate())}get touched(){return this._touched}set touched(e){this._touched=e}clone(e){var i,r,a;const t=this.constructor.create(H(w({value:(i=e==null?void 0:e.value)!=null?i:this.value},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(r=e==null?void 0:e.enabled)!=null?r:this.enabled,visibility:(a=e==null?void 0:e.visibility)!=null?a:this.visibility}));return t.actions=this.actions.clone(),t.actions.triggerEager(t,t.value,t.originalValue),t}}const ue=j.create({value:"EmptyField"}).registerAction(new C(()=>{console.warn("Working with EmptyField! This should not happen")}));function K(s,n){return(s==null?void 0:s.label)==null&&(s==null?void 0:s.icon)==null?n:s}class he extends j{constructor(n){super(n),this._value={label:void 0,icon:void 0}}init(n){if(n){const e=n,{value:t,originalValue:i,validators:r,actions:a}=e,c=O(e,["value","originalValue","validators","actions"]);[...r||[],...a||[]].forEach(f=>this.registerAction(f)),Object.assign(this,c);const d=K(t,this._value),g=Object.freeze({label:i==null?void 0:i.label,icon:i==null?void 0:i.icon});this._value=K(d,g),this.originalValue=K(g,d)}this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}static create(n){return super.create(n)}get icon(){return this.value.icon}set icon(n){this.value.icon=n}get label(){return this.value.label}set label(n){this.value.label=n}execute(n){this.actions.trigger(Y,this,n)}}const de=o.defineComponent({__name:"messages-widget",props:{message:{},classes:{}},setup(s){const n=s,e=o.resolveComponent("vue-markdown"),t=new Set(["div","span","p","h1","h2","h3","h4","h5","h6","section","article","aside","nav","header","footer","main","figure","figcaption","blockquote","pre","code","em","strong","small","mark","del","ins","sub","sup","i","b","u","s","a","img","button","input","textarea","select","option","label","form","table","tr","td","th","thead","tbody","tfoot","ul","ol","li","dl","dt","dd"]),i=()=>{if(typeof n.message=="string")return o.h("span",{class:n.classes},n.message);const r=[];return n.message.forEach(a=>{switch(a.componentName){case"template":r.push(o.h("div",{class:[n.classes,a.extraClasses]},a.componentBody));break;case"vue-markdown":if(typeof e=="string")console.warn("You are using markdown for messages-widget, but you haven't registered a vue-markdown component"),r.push(o.h("div",{class:[n.classes,a.extraClasses]},a.componentBindings.source));else{const c=a.componentBindings;r.push(o.h(e,{class:[n.classes,a.extraClasses,"df-messages-widget-markdown"],source:c.source,options:c.options,plugins:c.plugins}))}break;default:r.push(o.h(t.has(a.componentName.toLowerCase())?a.componentName:o.resolveComponent(a.componentName),w(w({class:[n.classes,a.extraClasses]},a.componentBindings),a.componentBody?{innerHTML:a.componentBody}:{})));break}}),r};return(r,a)=>(o.openBlock(),o.createBlock(i))}});class E extends V{constructor(e,t){super();h(this,"_fields");h(this,"_value",null);h(this,"reactiveValue",o.computed(()=>this.value));h(this,"suppressNotifyValueChanged",!1);if(!E.isValidFields(e))throw new Error("Invalid fields object provided");if(this._fields={},Object.entries(e).forEach(([r,a])=>this.addField(r,a)),t){const i=t,{value:r,validators:a,actions:c}=i,d=O(i,["value","validators","actions"]);[...a||[],...c||[]].forEach(g=>this.registerAction(g)),Object.assign(this,d),this.value=r!=null?r:this.originalValue}this.originalValue===void 0&&(this.originalValue=this.value),this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}addField(e,t){if(this.fields[e]!==void 0)throw new Error(`Field ${e} is already in this form`);Object.defineProperty(t,"parent",{get:()=>this,configurable:!1,enumerable:!1}),Object.defineProperty(t,"fieldName",{get:()=>e,configurable:!1,enumerable:!1}),Object.defineProperty(this._fields,e,{get(){return t},configurable:!1,enumerable:!0})}static isValidFields(e){function t(i){return i instanceof V}return typeof e=="object"&&e!==null&&Object.entries(e).every(([,i])=>t(i))}static createFromFormData(e){if(e instanceof V)throw new Error("data is already a Form structure, should be a simple object");return new E(e==null?{}:Object.fromEntries(Object.entries(e).map(([t,i])=>[t,j.create({value:i})])))}field(e){var t;return(t=this._fields[e])!=null?t:null}get fields(){return this._fields}get value(){const e={};return Object.entries(this._fields).forEach(([t,i])=>{const r=i.value;(i.enabled||i instanceof E&&!u.isEmpty(r))&&(e[t]=r)}),u.isEmpty(e)?null:e}set value(e){this.suppressNotifyValueChanged=!0;try{Object.entries(this._fields).forEach(([t,i])=>{(e==null||t in e)&&(i.value=e==null?null:e[t])})}finally{this.suppressNotifyValueChanged=!1}this.notifyValueChanged(),this.validate()}get touched(){return Object.values(this._fields).some(e=>e.touched)}set touched(e){Object.values(this._fields).forEach(t=>{t.touched=e})}get fullValue(){const e={};return Object.entries(this._fields).forEach(([t,i])=>{e[t]=i.fullValue}),e}notifyValueChanged(){if(this.suppressNotifyValueChanged)return;const e=this.value;if(!u.isEqual(e,this._value)){const t=this._value;this._value=e,this.actions.trigger(C,this,e,t),this.parent&&this.parent.notifyValueChanged(),this.validate()}}get valid(){return super.valid&&Object.values(this._fields).every(e=>e.valid)}validate(e=!1){e&&Object.values(this._fields).forEach(t=>t.validate(!0)),super.validate(e)}clone(e){var r,a,c;const t={};Object.entries(this._fields).forEach(([d,g])=>{t[d]=g.clone()});const i=new E(t,H(w({value:(r=e==null?void 0:e.value)!=null?r:this.value},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(a=e==null?void 0:e.enabled)!=null?a:this.enabled,visibility:(c=e==null?void 0:e.visibility)!=null?c:this.visibility}));return i.actions=this.actions.clone(),i.actions.triggerEager(i,i.value,i.originalValue),i}}class D extends V{constructor(e,t){super();h(this,"_value",null);h(this,"_itemTemplate");h(this,"_previousValue");if(this._itemTemplate=e,t){const i=t,{value:r,validators:a,actions:c}=i,d=O(i,["value","validators","actions"]);[...a||[],...c||[]].forEach(g=>this.registerAction(g)),Object.assign(this,d),r&&this.setValueInternal(r)}this.originalValue===void 0&&(this.originalValue=this.value),this._previousValue=this.value,this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}processSetValueItem(e){let t;return e instanceof E?t=e:this._itemTemplate?t=this._itemTemplate.clone({value:e}):t=E.createFromFormData(e),Object.defineProperty(t,"parent",{get:()=>this,configurable:!1,enumerable:!1}),t}setValueInternal(e){Array.isArray(e)&&(this._value=e.map(t=>this.processSetValueItem(t)))}get value(){var t;const e=(t=this._value)==null?void 0:t.map(i=>i.value);return u.isEmpty(e)?null:e}set value(e){const t=this.value;this.setValueInternal(e),this.actions.trigger(C,this,this.value,t),this.parent&&this.parent.notifyValueChanged(),this.validate()}get touched(){var e;return((e=this._value)==null?void 0:e.some(t=>t.touched))||!1}set touched(e){var t;(t=this._value)==null||t.forEach(i=>{i.touched=e})}clone(e){var i,r,a,c;const t=new D((i=this._itemTemplate)==null?void 0:i.clone(),H(w({value:[...(r=e==null?void 0:e.value)!=null?r:this.value]},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(a=e==null?void 0:e.enabled)!=null?a:this.enabled,visibility:(c=e==null?void 0:e.visibility)!=null?c:this.visibility}));return t.actions=this.actions.clone(),t.actions.triggerEager(t,t.value,t.originalValue),t}notifyValueChanged(){const e=this.value;if(!u.isEqual(e,this._previousValue)){const t=this._previousValue;this._previousValue=e,this.actions.trigger(C,this,e,t),this.parent&&this.parent.notifyValueChanged(),this.validate()}}get valid(){var e,t;return super.valid&&((t=(e=this._value)==null?void 0:e.every(i=>i.valid))!=null?t:!0)}validate(e=!1){var t;e&&((t=this._value)==null||t.forEach(i=>i.validate(!0))),super.validate(e)}get(e){return this._value!=null?this._value[e]:void 0}push(e){var t,i;return this.insert(e,(i=(t=this._value)==null?void 0:t.length)!=null?i:0)+1}pop(){var e,t;return this.remove(((t=(e=this._value)==null?void 0:e.length)!=null?t:0)-1)}remove(e){var i;if(this._value==null||e<0||this._value.length<=e)return;let t=(i=this._value.splice(e,1))==null?void 0:i[0];return t&&(t=t.clone(),this.actions.trigger(J,this,t,e),this.notifyValueChanged()),t}insert(e,t){for(this._value==null&&(this._value=[]);this._value.length<t;){const r=this.processSetValueItem(null),a=this._value.push(r);this.actions.trigger(B,this,r,a)}const i=this.processSetValueItem(e);return this._value.splice(t,0,i),this.actions.trigger(B,this,i,t),this.notifyValueChanged(),t}clear(){this._value=null,this.notifyValueChanged()}}const ge={useMarkdownInValidators:!0};function Fe(){return ge}function we(s){Object.assign(ge,s)}const Te={install(s,n){n&&we(n)}};function A(s){return Fe().useMarkdownInValidators?new I(s):s.replace(/[*_~`]/g,"").replace(/!\[(.*?)\]\(.*?\)/g,"$1").replace(/\[(.*?)\]\((.*?)\)/g,"$1").replace(/#+\s?/g,"").replace(/>\s?/g,"").replace(/(\*|-|\d+\.)\s+/g,"").replace(/`{3}[\s\S]*?`{3}/g,"").replace(/`([^`]+)`/g,"$1").replace(/\n{2,}/g,`
2
+ `)}class Ne extends b{constructor(e,t,i){let r=!1,a,c;super((g,f,P)=>(a=g,c=f,r||(r=!0,this.otherField.registerAction(new C((_,q,M,ee)=>{q(_,M,ee),this.unregistered||this.execute(P,()=>null,a,c)}))),this.isValidComparison(o.unref(g),o.unref(this.otherField.value))?null:[new v(this.replacePlaceholders(i,{newValue:g,oldValue:f,field:P,otherField:this.otherField}))]));h(this,"otherField");h(this,"isValidComparison");h(this,"unregistered",!1);this.otherField=e,this.isValidComparison=t}unregister(){this.unregistered=!0}}class Le extends b{constructor(n,e){const t=e||A("Must be one of [**{allowedAsText}**]");let i=n.join(", ");i.length>60&&(i=u.truncate(i,{length:40,separator:", ",omission:`... (${n.length} items total)`}));const r=(a,c,d)=>n.includes(o.unref(a))?null:[new v(this.replacePlaceholders(t,{newValue:a,oldValue:c,field:d,allowedValues:n,allowedAsText:i}))];super(r)}}function je(s){return s==null?0:u.isArray(s)||u.isString(s)?s.length:u.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class Pe extends b{constructor(n){const e=n||A("Please enter a value"),t=(i,r,a)=>je(o.unref(i))===0?[new v(this.replacePlaceholders(e,{newValue:i,oldValue:r,field:a}))]:null;super(t)}}class Oe extends b{constructor(n,e){const t=e||A("Value must be larger or equal to **{minValue}**"),i=(r,a,c)=>r<n||r===void 0?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,minValue:n}))]:null;super(i)}}class Re extends b{constructor(n,e){const t=e||A("Value must be less than or equal to **{maxValue}**"),i=(r,a,c)=>r>n||r===void 0?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,maxValue:n}))]:null;super(i)}}class Ue extends b{constructor(n,e,t){const i=t||A("Value must be between **{minValue}** and **{maxValue}**"),r=(a,c,d)=>a<n||a>e||a===void 0?[new v(this.replacePlaceholders(i,{newValue:a,oldValue:c,field:d,minValue:n,maxValue:e}))]:null;super(r)}}function Z(s){return s==null?0:u.isArray(s)||u.isString(s)?s.length:u.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class ke extends b{constructor(n,e){const t=e||A("Length must be larger or equal to **{minLength}**"),i=(r,a,c)=>Z(r)<n?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,minLength:n}))]:null;super(i)}}class Be extends b{constructor(n,e){const t=e||A("Length must be less than or equal to **{maxLength}**"),i=(r,a,c)=>Z(r)>n?[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,maxLength:n}))]:null;super(i)}}class De extends b{constructor(n,e,t){const i=t||A("Length must be between **{minLength}** and **{maxLength}**"),r=(a,c,d)=>{const g=Z(a);return g<n||g>e?[new v(this.replacePlaceholders(i,{newValue:a,oldValue:c,field:d,minLength:n,maxLength:e}))]:null};super(r)}}class qe extends b{constructor(n,e){const t=e||A('Value must match pattern "**{pattern}**"'),i=(r,a,c)=>n.test(String(o.unref(r)))?null:[new v(this.replacePlaceholders(t,{newValue:r,oldValue:a,field:c,pattern:n}))];super(i)}}const fe=Object.freeze(Object.defineProperty({__proto__:null,CompareTo:Ne,InAllowedValues:Le,LengthInRange:De,MaxLength:Be,MaxValue:Re,MinLength:ke,MinValue:Oe,Pattern:qe,Required:Pe,Validator:b,ValueInRange:Ue},Symbol.toStringTag,{value:"Module"})),Me=Object.freeze(Object.defineProperty({__proto__:null,AbortEventHandlingException:R,Action:he,ActionsMap:x,ConditionalEnabledAction:le,ConditionalStatementAction:N,ConditionalValueAction:oe,ConditionalVisibilityAction:ae,DisplayMode:S,EmptyField:ue,EnabledChangedAction:Q,EnabledChangingAction:G,ExecuteAction:Y,Field:j,FieldActionBase:y,FieldBase:V,Group:E,List:D,ListItemAddedAction:B,ListItemRemovedAction:J,MdString:I,MessagesWidget:de,Operator:p,RenderableValue:re,Statement:F,ValidChangedAction:z,ValidationError:k,ValidationErrorRenderContent:v,ValidationErrorText:se,Validator:b,Validators:fe,ValueChangedAction:C,VisibilityChangedAction:X,VisibilityChangingAction:W,buildErrorMessage:A,isCallableFunction:T,isSimpleComponentDef:U},Symbol.toStringTag,{value:"Module"}));l.AbortEventHandlingException=R,l.Action=he,l.ActionsMap=x,l.ConditionalEnabledAction=le,l.ConditionalStatementAction=N,l.ConditionalValueAction=oe,l.ConditionalVisibilityAction=ae,l.DisplayMode=S,l.EmptyField=ue,l.EnabledChangedAction=Q,l.EnabledChangingAction=G,l.ExecuteAction=Y,l.Field=j,l.FieldActionBase=y,l.FieldBase=V,l.Group=E,l.List=D,l.ListItemAddedAction=B,l.ListItemRemovedAction=J,l.MdString=I,l.MessagesWidget=de,l.Operator=p,l.RenderableValue=re,l.Statement=F,l.ValidChangedAction=z,l.ValidationError=k,l.ValidationErrorRenderContent=v,l.ValidationErrorText=se,l.Validator=b,l.Validators=fe,l.ValueChangedAction=C,l.VisibilityChangedAction=X,l.VisibilityChangingAction=W,l.buildErrorMessage=A,l.default=Me,l.forms=Te,l.isCallableFunction=T,l.isSimpleComponentDef=U,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
3
3
  //# sourceMappingURL=dynamicforms-vue-forms.umd.cjs.map