@dynamicforms/vue-forms 0.2.6 → 0.3.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,c){typeof exports=="object"&&typeof module!="undefined"?c(exports,require("lodash-es"),require("vue")):typeof define=="function"&&define.amd?define(["exports","lodash-es","vue"],c):(l=typeof globalThis!="undefined"?globalThis:l||self,c((l["dynamicforms-vue-forms"]=l["dynamicforms-vue-forms"]||{},l["dynamicforms-vue-forms"]["[name]"]={}),l["lodash-es"],l.vue))})(this,function(l,c,u){"use strict";var Bt=Object.defineProperty,$t=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols,Qt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,zt=Reflect.get;var et=(l,c,u)=>c in l?Bt(l,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[c]=u,H=(l,c)=>{for(var u in c||(c={}))ot.call(c,u)&&et(l,u,c[u]);if(Y)for(var u of Y(c))ht.call(c,u)&&et(l,u,c[u]);return l},G=(l,c)=>$t(l,kt(c));var X=(l,c)=>{var u={};for(var m in l)ot.call(l,m)&&c.indexOf(m)<0&&(u[m]=l[m]);if(l!=null&&Y)for(var m of Y(l))c.indexOf(m)<0&&ht.call(l,m)&&(u[m]=l[m]);return u};var f=(l,c,u)=>et(l,typeof c!="symbol"?c+"":c,u);var V=(l,c,u)=>zt(Qt(l),u,c);var h=(l,c,u)=>new Promise((m,R)=>{var C=I=>{try{F(u.next(I))}catch(b){R(b)}},p=I=>{try{F(u.throw(I))}catch(b){R(b)}},F=I=>I.done?m(I.value):Promise.resolve(I.value).then(C,p);F((u=u.apply(l,c)).next())});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 R=10;(s=>{function i(n){return n.toUpperCase()==="SUPPRESS"?1:n.toUpperCase()==="HIDDEN"?5:n.toUpperCase()==="INVISIBLE"?8:R}s.fromString=i;function t(n){const r=typeof n=="number"?n:s.fromString(n);return Object.values(s).includes(r)?r:R}s.fromAny=t;function e(n){const r=typeof n=="number"?n:s.fromString(n);return Object.values(s).includes(r)}s.isDefined=e})(m||(m={})),Object.freeze(m);const C=m;class p{constructor(i){f(this,"executorFn");this.executorFn=i}static get classIdentifier(){throw new Error("classIdentifier must be declared")}get classIdentifier(){return this.constructor.classIdentifier}execute(i,t,...e){return h(this,null,function*(){return this.executorFn(i,t,...e)})}get eager(){return!1}boundToField(i){}unregister(){}}class F extends Error{}const I=Symbol("ValueChangedAction");class b extends p{constructor(i){super(i)}static get classIdentifier(){return I}execute(i,t,e,n){return h(this,null,function*(){return V(b.prototype,this,"execute").call(this,i,t,e,n)})}}class T extends String{}function W(s){const i=u.unref(s);return typeof i=="object"&&"componentName"in i}class J{get componentName(){return"Comment"}get componentBindings(){return{}}get componentBody(){return""}}class it extends J{constructor(t){super();f(this,"text");this.text=t}get componentName(){return"template"}get componentBody(){return this.text}}class E extends J{constructor(t){super();f(this,"text");f(this,"textType");this.text=t,this.textType=u.computed(()=>this.getTextType)}get getTextType(){const t=u.unref(this.text);return t?t instanceof T?"md":W(t)?"component":"string":"string"}get componentName(){switch(u.unref(this.textType)){case"string":return"template";case"md":return"vue-markdown";case"component":return u.unref(this.text).componentName;default:return"template"}}get componentBindings(){switch(u.unref(this.textType)){case"string":return{};case"md":return{source:this.text.toString()};case"component":return u.unref(this.text).componentProps;default:return{}}}get componentBody(){switch(u.unref(this.textType)){case"string":return u.unref(this.text);default:return""}}}const ft=Symbol("Validator");class v extends b{constructor(t){super((n,r,a,o)=>h(this,null,function*(){const d=t(a,o,n)||[];d.forEach(g=>Object.defineProperty(g,"source",{value:this.source,enumerable:!1,configurable:!1}));for(let g=n.errors.length-1;g>=0;g--){const _=n.errors[g];if(_.source===this.source){const j=d.findIndex(tt=>c.isEqual(tt,_));j>=0?d.splice(j,1):n.errors.splice(g,1)}}return d.length>0&&n.errors.push(...d),n.validate(),r(n,a,o)}));f(this,"source");this.source=Symbol(this.constructor.name)}static get classIdentifier(){return ft}get eager(){return!0}replacePlaceholders(t,e){if(W(t))return t;let n=t;return Object.keys(e).forEach(r=>{n=n.replaceAll(`{${r}}`,e[r])}),t instanceof T?new T(n):n}}class U extends Map{constructor(){super(...arguments);f(this,"eagerActions",new Set);f(this,"registeredActions",[])}register(t){if(!(t instanceof p))throw new Error("Invalid action type");this.registeredActions.push(t);const e=t.classIdentifier,n=this.get(e)||(()=>null);function r(a,...o){return t.execute(a,n,...o)}this.set(e,r),t.eager&&this.eagerActions.add(t.classIdentifier)}trigger(t,e,...n){return h(this,null,function*(){const r=t.classIdentifier;r===I&&(yield this.triggerEager(e,...n));const a=this.get(r);try{if(a)return yield a(e,...n)}catch(o){if(!(o instanceof F))throw o}return null})}triggerEager(t,...e){return h(this,null,function*(){for(const n of this.eagerActions){const r=this.get(n);try{r&&(yield r(t,...e))}catch(a){if(!(a instanceof F))throw a}}})}cloneWithoutValidators(){const t=new U;return this.registeredActions.forEach(e=>{e instanceof v?e.unregister():t.register(e)}),t}}const gt=Symbol("ConditionalStatementAction");class D extends b{constructor(t,e){const n=(r,a,o,d)=>h(this,null,function*(){const g=t.evaluate();if(g!==this.lastResult){for(const _ of this.boundFields)yield e(_,g,this.lastResult);this.lastResult=g}return a(r,o,d)});super(n);f(this,"lastResult");f(this,"boundFields",new Set);t.collectFields().forEach(r=>r.registerAction(new b(n)))}static get classIdentifier(){return gt}get eager(){return!0}boundToField(t){this.boundFields.add(t)}}class nt extends D{constructor(i){super(i,(t,e)=>h(this,null,function*(){yield t.setVisibility(e?C.FULL:C.SUPPRESS)}))}}class st extends D{constructor(i){super(i,(t,e)=>h(this,null,function*(){yield t.setEnabled(e)}))}}class rt extends D{constructor(i,t){super(i,(e,n)=>h(this,null,function*(){n&&(yield e.setValue(t))}))}}var q=(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))(q||{});(s=>{function i(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=i;function t(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=t;function e(r){const a=typeof r=="number"?r:s.fromString(r);return Object.values(s).includes(a)}s.isDefined=e;function n(r){return r>=0}s.isLogicOperator=n})(q||(q={})),Object.freeze(q);const y=q,dt=Symbol("EnabledChangingAction");class M extends p{constructor(i){super(i)}static get classIdentifier(){return dt}execute(i,t,e,n){return h(this,null,function*(){return V(M.prototype,this,"execute").call(this,i,t,e,n)})}}const bt=Symbol("EnabledChangedAction");class L extends p{constructor(i){super(i)}static get classIdentifier(){return bt}execute(i,t,e,n){return h(this,null,function*(){return V(L.prototype,this,"execute").call(this,i,t,e,n)})}}const yt=Symbol("ValidChangedAction");class B extends p{constructor(i){super(i)}static get classIdentifier(){return yt}execute(i,t,e,n){return h(this,null,function*(){return V(B.prototype,this,"execute").call(this,i,t,e,n)})}}const mt=Symbol("VisibilityChangingAction");class $ extends p{constructor(i){super(i)}static get classIdentifier(){return mt}execute(i,t,e,n){return h(this,null,function*(){return V($.prototype,this,"execute").call(this,i,t,e,n)})}}const pt=Symbol("VisibilityChangedAction");class w extends p{constructor(i){super(i)}static get classIdentifier(){return pt}execute(i,t,e,n){return h(this,null,function*(){return V(w.prototype,this,"execute").call(this,i,t,e,n)})}}class A{constructor(){f(this,"reactiveValue",u.computed(()=>this.value));f(this,"valid",!0);f(this,"errors",[]);f(this,"actions",new U);f(this,"_visibility",C.FULL);f(this,"_enabled",!0)}get visibility(){return this._visibility}set visibility(i){const t=this._visibility;if(!C.isDefined(i))throw new Error("visibility must be a DisplayMode constant");this._visibility=C.fromAny(i),this.actions.trigger(w,this,this._visibility,t)}setVisibility(i){return h(this,null,function*(){const t=this._visibility,e=yield this.actions.trigger($,this,i,t);if(!C.isDefined(e!=null?e:i))throw new Error("visibility must be a DisplayMode constant");this._visibility=C.fromAny(e!=null?e:i),yield this.actions.trigger(w,this,this._visibility,t)})}get enabled(){return this._enabled}set enabled(i){const t=this._enabled;if(!c.isBoolean(i))throw new Error("Enabled value must be boolean");this._enabled=i,this.actions.trigger(L,this,this._enabled,t)}setEnabled(i){return h(this,null,function*(){const t=this._enabled,e=yield this.actions.trigger(M,this,i,t);if(!c.isBoolean(e!=null?e:i))throw new Error("Enabled value must be boolean");this._enabled=e!=null?e:i,yield this.actions.trigger(L,this,this._enabled,t)})}validate(){const i=this.valid;this.valid=this.errors.length===0,this.valid!==i&&this.actions.trigger(B,this,this.valid,i)}get fullValue(){return this.value}get isChanged(){return!c.isEqual(this.value,this.originalValue)}registerAction(i){const t=i;return this.actions.register(t),t.boundToField(this),t.eager&&this.actions.trigger(Object.getPrototypeOf(i).constructor,this,this.value,this.originalValue),this}triggerAction(i,...t){return this.actions.trigger(i,this,...t)}clearValidators(){this.actions=this.actions.cloneWithoutValidators(),this.errors=[],this.valid=!0}}function vt(s,i){return s?!i:i}class O{constructor(i,t,e){f(this,"operand1");f(this,"operator");f(this,"operand2");this.operand1=i,this.operator=t,this.operand2=e}get operand1Value(){return this.operand1 instanceof O?this.operand1.evaluate():this.operand1 instanceof A?u.unref(this.operand1.value):this.operand1}get operand2Value(){return this.operand2 instanceof O?this.operand2.evaluate():this.operand2 instanceof A?u.unref(this.operand2.value):this.operand2}evaluate(){var e,n,r,a;const i=this.operand1Value,t=this.operand2Value;switch(this.operator){case y.AND:return i&&t;case y.OR:return i||t;case y.NAND:return!(i&&t);case y.NOR:return!(i||t);case y.XOR:return vt(i,t);case y.NOT:return!i;case y.EQUALS:return i==t;case y.NOT_EQUALS:return i!=t;case y.LT:return i<t;case y.LE:return i<=t;case y.GE:return i>=t;case y.GT:return i>t;case y.IN:return(n=(e=t==null?void 0:t.includes)==null?void 0:e.call(t,i))!=null?n:!1;case y.NOT_IN:return!((a=(r=t==null?void 0:t.includes)==null?void 0:r.call(t,i))==null||a);case y.INCLUDES:return c.isString(i)&&c.isString(t)&&i.indexOf(t)>=0;case y.NOT_INCLUDES:return!(c.isString(i)&&c.isString(t)&&i.indexOf(t)>=0);default:throw new Error(`Operator not implemented ${this.operator}`)}}collectFields(){const i=new Set;function t(e){e instanceof A?i.add(e):e instanceof O&&e.collectFields().forEach(r=>i.add(r))}return t(this.operand1),t(this.operand2),i}}const Et=Symbol("ExecuteAction");class k extends p{constructor(i){super(i)}static get classIdentifier(){return Et}execute(i,t,e){return h(this,null,function*(){return V(k.prototype,this,"execute").call(this,i,t,e)})}}const Ct=Symbol("ListItemAddedAction");class P extends p{constructor(i){super(i)}static get classIdentifier(){return Ct}execute(i,t,e,n){return h(this,null,function*(){return V(P.prototype,this,"execute").call(this,i,t,e,n)})}}const At=Symbol("ListItemRemovedAction");class Q extends p{constructor(i){super(i)}static get classIdentifier(){return At}execute(i,t,e,n){return h(this,null,function*(){return V(Q.prototype,this,"execute").call(this,i,t,e,n)})}}function at(s,i){return(s==null?void 0:s.label)==null&&(s==null?void 0:s.icon)==null?i:s}class z extends A{constructor(t){super();f(this,"_value");if(t){const e=t,{value:n,originalValue:r,validators:a,actions:o}=e,d=X(e,["value","originalValue","validators","actions"]);[...a||[],...o||[]].forEach(j=>this.registerAction(j)),Object.assign(this,d);const g={label:n==null?void 0:n.label,icon:n==null?void 0:n.icon},_=Object.freeze({label:r==null?void 0:r.label,icon:r==null?void 0:r.icon});this._value=u.reactive(at(g,_)),this.originalValue=at(_,g)}else this._value=u.reactive({label:void 0,icon:void 0});this.actions.triggerEager(this,this.value,this.originalValue)}static create(t){return u.reactive(new z(t))}get value(){return this._value}set value(t){if(!this.enabled)return;const e=this._value;this._value.icon=t==null?void 0:t.icon,this._value.label=t==null?void 0:t.label,this.actions.trigger(b,this,t,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}setValue(t){return h(this,null,function*(){if(!this.enabled)return;const e=this._value;this._value.icon=t==null?void 0:t.icon,this._value.label=t==null?void 0:t.label,yield this.actions.trigger(b,this,t,e),this.parent&&(yield this.parent.notifyValueChanged()),this.validate()})}get icon(){return this.value.icon}set icon(t){this.value={label:this.label,icon:t}}get label(){return this.value.label}set label(t){this.value={label:t,icon:this.value.icon}}clone(t){var e,n,r,a;return z.create(G(H({value:(e=t==null?void 0:t.value)!=null?e:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(n=t==null?void 0:t.errors)!=null?n:this.errors],enabled:(r=t==null?void 0:t.enabled)!=null?r:this.enabled,visibility:(a=t==null?void 0:t.visibility)!=null?a:this.visibility}))}execute(t){this.actions.trigger(k,this,t)}}class N extends A{constructor(t){super();f(this,"_value");if(t){const e=t,{value:n,validators:r,actions:a}=e,o=X(e,["value","validators","actions"]);[...r||[],...a||[]].forEach(d=>this.registerAction(d)),Object.assign(this,o),this._value=n!=null?n:this.originalValue,this.originalValue===void 0&&(this.originalValue=this._value)}this.actions.triggerEager(this,this.value,this.originalValue)}static create(t){return u.reactive(new N(t))}get value(){return u.unref(this._value)}set value(t){const e=this._value;!this.enabled||e===t||(this._value=t,this.actions.trigger(b,this,t,e),this.parent&&this.parent.notifyValueChanged(),this.validate())}setValue(t){return h(this,null,function*(){const e=this._value;!this.enabled||e===t||(this._value=t,yield this.actions.trigger(b,this,t,e),this.parent&&(yield this.parent.notifyValueChanged()),this.validate())})}clone(t){var e,n,r,a;return N.create(G(H({value:(e=t==null?void 0:t.value)!=null?e:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(n=t==null?void 0:t.errors)!=null?n:this.errors],enabled:(r=t==null?void 0:t.enabled)!=null?r:this.enabled,visibility:(a=t==null?void 0:t.visibility)!=null?a:this.visibility}))}}const lt=N.create({value:"EmptyField"}).registerAction(new b(()=>h(this,null,function*(){console.warn("Working with EmptyField! This should not happen")})));class x extends A{constructor(t,e){super();f(this,"_fields");f(this,"_value",null);f(this,"suppressNotifyValueChanged",!1);if(!x.isValidFields(t))throw new Error("Invalid fields object provided");if(this._fields={},Object.entries(t).forEach(([r,a])=>this.addField(r,a)),e){const n=e,{value:r,validators:a,actions:o}=n,d=X(n,["value","validators","actions"]);[...a||[],...o||[]].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)}addField(t,e){if(this.fields[t]!==void 0)throw new Error(`Field ${t} is already in this form`);Object.defineProperty(e,"parent",{get:()=>this,configurable:!1,enumerable:!1}),Object.defineProperty(e,"fieldName",{get:()=>t,configurable:!1,enumerable:!1}),Object.defineProperty(this._fields,t,{get(){return e},configurable:!1,enumerable:!0})}static isValidFields(t){function e(n){return n instanceof A}return typeof t=="object"&&t!==null&&Object.entries(t).every(([,n])=>e(n))}static createFromFormData(t){if(t instanceof A)throw new Error("data is already a Form structure, should be a simple object");return new x(t==null?{}:Object.fromEntries(Object.entries(t).map(([e,n])=>[e,N.create({value:n})])))}field(t){var e;return(e=this._fields[t])!=null?e:null}get fields(){return this._fields}get value(){const t={};return Object.entries(this._fields).forEach(([e,n])=>{const r=n.value;(n.enabled||n instanceof x&&!c.isEmpty(r))&&(t[e]=r)}),c.isEmpty(t)?null:t}set value(t){this.suppressNotifyValueChanged=!0;try{Object.entries(this._fields).forEach(([e,n])=>{(t==null||e in t)&&(n.value=t==null?null:t[e])})}finally{this.suppressNotifyValueChanged=!1}this.notifyValueChanged()}setValue(t){return h(this,null,function*(){this.suppressNotifyValueChanged=!0;function e(n,r){return h(this,null,function*(){(t==null||n in t)&&(yield r.setValue(t==null?null:t[n]))})}try{for(const[n,r]of Object.entries(this._fields))yield e(n,r)}finally{this.suppressNotifyValueChanged=!1}yield this.notifyValueChanged()})}get fullValue(){const t={};return Object.entries(this._fields).forEach(([e,n])=>{t[e]=n.fullValue}),t}notifyValueChanged(){return h(this,null,function*(){if(this.suppressNotifyValueChanged)return;const t=this.value;if(!c.isEqual(t,this._value)){const e=this._value;this._value=t,yield this.actions.trigger(b,this,t,e),this.parent&&(yield this.parent.notifyValueChanged())}})}clone(t){var n,r,a,o;const e={};return Object.entries(this._fields).forEach(([d,g])=>{e[d]=g.clone()}),new x(e,G(H({value:(n=t==null?void 0:t.value)!=null?n:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(r=t==null?void 0:t.errors)!=null?r:[]],enabled:(a=t==null?void 0:t.enabled)!=null?a:this.enabled,visibility:(o=t==null?void 0:t.visibility)!=null?o:this.visibility}))}}class K extends A{constructor(t,e){super();f(this,"_value",null);f(this,"_itemTemplate");f(this,"_previousValue");if(this._itemTemplate=t,e){const n=e,{value:r,validators:a,actions:o}=n,d=X(n,["value","validators","actions"]);[...a||[],...o||[]].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)}processSetValueItem(t){let e;return t instanceof x?e=t:this._itemTemplate?e=this._itemTemplate.clone({value:t}):e=x.createFromFormData(t),Object.defineProperty(e,"parent",{get:()=>this,configurable:!1,enumerable:!1}),e}setValueInternal(t){Array.isArray(t)&&(this._value=t.map(e=>this.processSetValueItem(e)))}get value(){var e;const t=(e=this._value)==null?void 0:e.map(n=>n.value);return c.isEmpty(t)?null:t}set value(t){const e=this.value;this.setValueInternal(t),this.actions.trigger(b,this,this.value,e),this.parent&&this.parent.notifyValueChanged()}setValue(t){return h(this,null,function*(){const e=this.value;this.setValueInternal(t),yield this.actions.trigger(b,this,this.value,e),this.parent&&(yield this.parent.notifyValueChanged())})}clone(t){var e,n,r,a,o;return new K((e=this._itemTemplate)==null?void 0:e.clone(),G(H({value:[...(n=t==null?void 0:t.value)!=null?n:this.value]},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(r=t==null?void 0:t.errors)!=null?r:[]],enabled:(a=t==null?void 0:t.enabled)!=null?a:this.enabled,visibility:(o=t==null?void 0:t.visibility)!=null?o:this.visibility}))}notifyValueChanged(){const t=this.value;if(!c.isEqual(t,this._previousValue)){const e=this._previousValue;this._previousValue=t,this.actions.trigger(b,this,t,e),this.parent&&this.parent.notifyValueChanged()}}get(t){return this._value!=null?this._value[t]:void 0}push(t){var e,n;return this.insert(t,(n=(e=this._value)==null?void 0:e.length)!=null?n:0)+1}pop(){var t,e;return this.remove(((e=(t=this._value)==null?void 0:t.length)!=null?e:0)-1)}remove(t){var n;if(this._value==null||t<0||this._value.length<=t)return;let e=(n=this._value.splice(t,1))==null?void 0:n[0];return e&&(e=e.clone(),this.actions.trigger(Q,this,e,t),this.notifyValueChanged()),e}insert(t,e){for(this._value==null&&(this._value=[]);this._value.length<e;){const r=this.processSetValueItem(null),a=this._value.push(r);this.actions.trigger(P,this,r,a)}const n=this.processSetValueItem(t);return this._value.splice(e,0,n),this.actions.trigger(P,this,n,e),this.notifyValueChanged(),e}clear(){this._value=null,this.notifyValueChanged()}}const ct={useMarkdownInValidators:!0};function St(){return ct}function It(s){Object.assign(ct,s)}const _t={install(s,i){i&&It(i)}};function S(s){return St().useMarkdownInValidators?new T(s):s.replace(/[*_~`]/g,"").replace(/\[.*?\]\((.*?)\)/g,"$1").replace(/!\[.*?\]\((.*?)\)/g,"").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 Vt extends v{constructor(t,e,n){let r=!1,a,o;super((g,_,j)=>(a=g,o=_,r||(r=!0,this.otherField.registerAction(new b((tt,Dt,qt,Mt)=>h(this,null,function*(){yield Dt(tt,qt,Mt),this.unregistered||(yield this.execute(j,()=>h(this,null,function*(){return null}),a,o))})))),this.isValidComparison(u.unref(g),u.unref(this.otherField.value))?null:[new E(this.replacePlaceholders(n,{newValue:g,oldValue:_,field:j,otherField:this.otherField}))]));f(this,"unregistered",!1);this.otherField=t,this.isValidComparison=e}unregister(){this.unregistered=!0}}class xt extends v{constructor(i,t){const e=t||S("Must be one of [**{allowedAsText}**]");let n=i.join(", ");n.length>60&&(n=c.truncate(n,{length:40,separator:", ",omission:`... (${i.length} items total)`}));const r=(a,o,d)=>i.includes(u.unref(a))?null:[new E(this.replacePlaceholders(e,{newValue:a,oldValue:o,field:d,allowedValues:i,allowedAsText:n}))];super(r)}}function Ft(s){return s==null?0:c.isArray(s)||c.isString(s)?s.length:c.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class Nt extends v{constructor(i){const t=i||S("Please enter a value"),e=(n,r,a)=>Ft(u.unref(n))===0?[new E(this.replacePlaceholders(t,{newValue:n,oldValue:r,field:a}))]:null;super(e)}}class jt extends v{constructor(i,t){const e=t||S("Value must be larger or equal to **{minValue}**"),n=(r,a,o)=>r<i||r===void 0?[new E(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,minValue:i}))]:null;super(n)}}class Tt extends v{constructor(i,t){const e=t||S("Value must be less than or equal to **{maxValue}**"),n=(r,a,o)=>r>i||r===void 0?[new E(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,maxValue:i}))]:null;super(n)}}class Lt extends v{constructor(i,t,e){const n=e||S("Value must be between **{minValue}** and **{maxValue}**"),r=(a,o,d)=>a<i||a>t||a===void 0?[new E(this.replacePlaceholders(n,{newValue:a,oldValue:o,field:d,minValue:i,maxValue:t}))]:null;super(r)}}function Z(s){return s==null?0:c.isArray(s)||c.isString(s)?s.length:c.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class wt extends v{constructor(i,t){const e=t||S("Length must be larger or equal to **{minLength}**"),n=(r,a,o)=>Z(r)<i?[new E(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,minLength:i}))]:null;super(n)}}class Ot extends v{constructor(i,t){const e=t||S("Length must be less than or equal to **{maxLength}**"),n=(r,a,o)=>Z(r)>i?[new E(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,maxLength:i}))]:null;super(n)}}class Pt extends v{constructor(i,t,e){const n=e||S("Length must be between **{minLength}** and **{maxLength}**"),r=(a,o,d)=>{const g=Z(a);return g<i||g>t?[new E(this.replacePlaceholders(n,{newValue:a,oldValue:o,field:d,minLength:i,maxLength:t}))]:null};super(r)}}class Rt extends v{constructor(i,t){const e=t||S('Value must match pattern "**{pattern}**"'),n=(r,a,o)=>i.test(String(u.unref(r)))?null:[new E(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,pattern:i}))];super(n)}}const ut=Object.freeze(Object.defineProperty({__proto__:null,CompareTo:Vt,InAllowedValues:xt,LengthInRange:Pt,MaxLength:Ot,MaxValue:Tt,MinLength:wt,MinValue:jt,Pattern:Rt,Required:Nt,ValueInRange:Lt},Symbol.toStringTag,{value:"Module"})),Ut=Object.freeze(Object.defineProperty({__proto__:null,AbortEventHandlingException:F,Action:z,ActionsMap:U,ConditionalEnabledAction:st,ConditionalStatementAction:D,ConditionalValueAction:rt,ConditionalVisibilityAction:nt,DisplayMode:C,EmptyField:lt,EnabledChangedAction:L,EnabledChangingAction:M,ExecuteAction:k,Field:N,FieldActionBase:p,FieldBase:A,Group:x,List:K,ListItemAddedAction:P,ListItemRemovedAction:Q,MdString:T,Operator:y,Statement:O,ValidChangedAction:B,ValidationError:J,ValidationErrorRenderContent:E,ValidationErrorText:it,Validator:v,Validators:ut,ValueChangedAction:b,VisibilityChangedAction:w,VisibilityChangingAction:$,buildErrorMessage:S,isCustomModalContentComponentDef:W},Symbol.toStringTag,{value:"Module"}));l.AbortEventHandlingException=F,l.Action=z,l.ActionsMap=U,l.ConditionalEnabledAction=st,l.ConditionalStatementAction=D,l.ConditionalValueAction=rt,l.ConditionalVisibilityAction=nt,l.DisplayMode=C,l.EmptyField=lt,l.EnabledChangedAction=L,l.EnabledChangingAction=M,l.ExecuteAction=k,l.Field=N,l.FieldActionBase=p,l.FieldBase=A,l.Group=x,l.List=K,l.ListItemAddedAction=P,l.ListItemRemovedAction=Q,l.MdString=T,l.Operator=y,l.Statement=O,l.ValidChangedAction=B,l.ValidationError=J,l.ValidationErrorRenderContent=E,l.ValidationErrorText=it,l.Validator=v,l.Validators=ut,l.ValueChangedAction=b,l.VisibilityChangedAction=w,l.VisibilityChangingAction=$,l.buildErrorMessage=S,l.default=Ut,l.forms=_t,l.isCustomModalContentComponentDef=W,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(l,c){typeof exports=="object"&&typeof module!="undefined"?c(exports,require("lodash-es"),require("vue")):typeof define=="function"&&define.amd?define(["exports","lodash-es","vue"],c):(l=typeof globalThis!="undefined"?globalThis:l||self,c((l["dynamicforms-vue-forms"]=l["dynamicforms-vue-forms"]||{},l["dynamicforms-vue-forms"]["[name]"]={}),l["lodash-es"],l.vue))})(this,function(l,c,o){"use strict";var qt=Object.defineProperty,Mt=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var ht=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var et=(l,c,o)=>c in l?qt(l,c,{enumerable:!0,configurable:!0,writable:!0,value:o}):l[c]=o,P=(l,c)=>{for(var o in c||(c={}))ht.call(c,o)&&et(l,o,c[o]);if(Q)for(var o of Q(c))gt.call(c,o)&&et(l,o,c[o]);return l},O=(l,c)=>Mt(l,Bt(c));var R=(l,c)=>{var o={};for(var m in l)ht.call(l,m)&&c.indexOf(m)<0&&(o[m]=l[m]);if(l!=null&&Q)for(var m of Q(l))c.indexOf(m)<0&&gt.call(l,m)&&(o[m]=l[m]);return o};var h=(l,c,o)=>et(l,typeof c!="symbol"?c+"":c,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 it=10;(s=>{function n(i){return i.toUpperCase()==="SUPPRESS"?1:i.toUpperCase()==="HIDDEN"?5:i.toUpperCase()==="INVISIBLE"?8:it}s.fromString=n;function t(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)?r:it}s.fromAny=t;function e(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)}s.isDefined=e})(m||(m={})),Object.freeze(m);const _=m;class v{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,t,...e){return this.executorFn(n,t,...e)}get eager(){return!1}boundToField(n){}unregister(){}}class U extends Error{}const nt=Symbol("ValueChangedAction");class y extends v{constructor(n){super(n)}static get classIdentifier(){return nt}execute(n,t,e,i){return super.execute(n,t,e,i)}}class F extends String{}function D(s){const n=o.unref(s);return typeof n=="object"&&"componentName"in n}class q{get componentName(){return"Comment"}get componentBindings(){return{}}get componentBody(){return""}}class st extends q{constructor(t){super();h(this,"text");this.text=t}get componentName(){return"template"}get componentBody(){return this.text}}class A extends q{constructor(t){super();h(this,"text");h(this,"textType");this.text=t,this.textType=o.computed(()=>this.getTextType)}get getTextType(){const t=o.unref(this.text);return t?t instanceof F?"md":D(t)?"component":"string":"string"}get componentName(){switch(o.unref(this.textType)){case"string":return"template";case"md":return"vue-markdown";case"component":return o.unref(this.text).componentName;default:return"template"}}get componentBindings(){switch(o.unref(this.textType)){case"string":return{};case"md":return{source:this.text.toString()};case"component":return o.unref(this.text).componentProps;default:return{}}}get componentBody(){switch(o.unref(this.textType)){case"string":return o.unref(this.text);default:return""}}}const dt=Symbol("Validator");class p extends y{constructor(t){super((i,r,a,u)=>{const g=t(a,u,i)||[],d=f=>{var x;f==null||f.forEach(I=>Object.defineProperty(I,"source",{value:this.source,enumerable:!1,configurable:!1}));for(let I=i.errors.length-1;I>=0;I--){const $=i.errors[I];if($.source===this.source){const k=(x=f==null?void 0:f.findIndex(tt=>c.isEqual(tt,$)))!=null?x:-1;k>=0?f==null||f.splice(k,1):i.errors.splice(I,1)}}f&&f.length>0&&i.errors.push(...f),i.validate()};return g instanceof Promise?(i.validating=++i.validatingCount>0,g.then(f=>d(f)).finally(()=>{i.validatingCount=Math.max(0,i.validatingCount-1),i.validating=i.validatingCount>0})):d(g),r(i,a,u)});h(this,"source");this.source=Symbol(this.constructor.name)}static get classIdentifier(){return dt}get eager(){return!0}replacePlaceholders(t,e){if(D(t))return t;let i=t;return Object.keys(e).forEach(r=>{i=i.replaceAll(`{${r}}`,e[r])}),t instanceof F?new F(i):i}}class L extends Map{constructor(){super(...arguments);h(this,"eagerActions",new Set);h(this,"registeredActions",[])}register(t){if(!(t instanceof v))throw new Error("Invalid action type");this.registeredActions.push(t);const e=t.classIdentifier,i=this.get(e)||(()=>null);function r(a,...u){return t.execute(a,i,...u)}this.set(e,r),t.eager&&this.eagerActions.add(t.classIdentifier)}trigger(t,e,...i){const r=t.classIdentifier;r===nt&&this.triggerEager(e,...i);const a=this.get(r);try{if(a)return a(e,...i)}catch(u){if(!(u instanceof U))throw u}return null}triggerEager(t,...e){for(const i of this.eagerActions){const r=this.get(i);try{r&&r(t,...e)}catch(a){if(!(a instanceof U))throw a}}}clone(){const t=new L;return this.registeredActions.forEach(e=>t.register(e)),t}cloneWithoutValidators(){const t=new L;return this.registeredActions.forEach(e=>{e instanceof p?e.unregister():t.register(e)}),t}}const ft=Symbol("ConditionalStatementAction");class j extends y{constructor(t,e){const i=(r,a,u,g)=>{const d=t.evaluate();if(d!==this.lastResult){for(const f of this.boundFields)e(f,d,this.lastResult);this.lastResult=d}return a(r,u,g)};super(i);h(this,"lastResult");h(this,"boundFields",new Set);t.collectFields().forEach(r=>r.registerAction(new y(i)))}static get classIdentifier(){return ft}get eager(){return!0}boundToField(t){this.boundFields.add(t)}}class rt extends j{constructor(n){super(n,(t,e)=>{t.visibility=e?_.FULL:_.SUPPRESS})}}class at extends j{constructor(n){super(n,(t,e)=>{t.enabled=e})}}class lt extends j{constructor(n,t){super(n,(e,i)=>{i&&(e.value=t)})}}var T=(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))(T||{});(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 t(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=t;function e(r){const a=typeof r=="number"?r:s.fromString(r);return Object.values(s).includes(a)}s.isDefined=e;function i(r){return r>=0}s.isLogicOperator=i})(T||(T={})),Object.freeze(T);const b=T,bt=Symbol("EnabledChangingAction");class z extends v{constructor(n){super(n)}static get classIdentifier(){return bt}execute(n,t,e,i){return super.execute(n,t,e,i)}}const mt=Symbol("EnabledChangedAction");class H extends v{constructor(n){super(n)}static get classIdentifier(){return mt}execute(n,t,e,i){return super.execute(n,t,e,i)}}const pt=Symbol("ValidChangedAction");class G extends v{constructor(n){super(n)}static get classIdentifier(){return pt}execute(n,t,e,i){return super.execute(n,t,e,i)}}const vt=Symbol("VisibilityChangingAction");class X extends v{constructor(n){super(n)}static get classIdentifier(){return vt}execute(n,t,e,i){return super.execute(n,t,e,i)}}const yt=Symbol("VisibilityChangedAction");class W extends v{constructor(n){super(n)}static get classIdentifier(){return yt}execute(n,t,e,i){return super.execute(n,t,e,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 L);h(this,"_visibility",_.FULL);h(this,"_enabled",!0)}get visibility(){return this._visibility}set visibility(n){const t=this._visibility,e=this.actions.trigger(X,this,n,t);if(!_.isDefined(e!=null?e:n))throw new Error("visibility must be a DisplayMode constant");this._visibility=_.fromAny(e!=null?e:n),this.actions.trigger(W,this,this._visibility,t)}get enabled(){return this._enabled}set enabled(n){const t=this._enabled,e=this.actions.trigger(z,this,n,t);if(!c.isBoolean(e!=null?e:n))throw new Error("Enabled value must be boolean");this._enabled=e!=null?e:n,this.actions.trigger(H,this,this._enabled,t)}validate(){const n=this._valid;this._valid=this.valid,this._valid!==n&&this.actions.trigger(G,this,this.valid,n)}get valid(){return this.errors.length===0}get fullValue(){return this.value}get isChanged(){return!c.isEqual(this.value,this.originalValue)}registerAction(n){const t=n;return this.actions.register(t),t.boundToField(this),t.eager&&this.actions.trigger(Object.getPrototypeOf(n).constructor,this,this.value,this.originalValue),this}triggerAction(n,...t){return this.actions.trigger(n,this,...t)}clearValidators(){this.actions=this.actions.cloneWithoutValidators(),this.errors=[],this._valid=!0}}function At(s,n){return s?!n:n}class N{constructor(n,t,e){h(this,"operand1");h(this,"operator");h(this,"operand2");this.operand1=n,this.operator=t,this.operand2=e}get operand1Value(){return this.operand1 instanceof N?this.operand1.evaluate():this.operand1 instanceof V?o.unref(this.operand1.value):this.operand1}get operand2Value(){return this.operand2 instanceof N?this.operand2.evaluate():this.operand2 instanceof V?o.unref(this.operand2.value):this.operand2}evaluate(){var e,i,r,a;const n=this.operand1Value,t=this.operand2Value;switch(this.operator){case b.AND:return n&&t;case b.OR:return n||t;case b.NAND:return!(n&&t);case b.NOR:return!(n||t);case b.XOR:return At(n,t);case b.NOT:return!n;case b.EQUALS:return n==t;case b.NOT_EQUALS:return n!=t;case b.LT:return n<t;case b.LE:return n<=t;case b.GE:return n>=t;case b.GT:return n>t;case b.IN:return(i=(e=t==null?void 0:t.includes)==null?void 0:e.call(t,n))!=null?i:!1;case b.NOT_IN:return!((a=(r=t==null?void 0:t.includes)==null?void 0:r.call(t,n))==null||a);case b.INCLUDES:return c.isString(n)&&c.isString(t)&&n.indexOf(t)>=0;case b.NOT_INCLUDES:return!(c.isString(n)&&c.isString(t)&&n.indexOf(t)>=0);default:throw new Error(`Operator not implemented ${this.operator}`)}}collectFields(){const n=new Set;function t(e){e instanceof V?n.add(e):e instanceof N&&e.collectFields().forEach(r=>n.add(r))}return t(this.operand1),t(this.operand2),n}}const Vt=Symbol("ExecuteAction");class J extends v{constructor(n){super(n)}static get classIdentifier(){return Vt}execute(n,t,e){return super.execute(n,t,e)}}const Ct=Symbol("ListItemAddedAction");class M extends v{constructor(n){super(n)}static get classIdentifier(){return Ct}execute(n,t,e,i){return super.execute(n,t,e,i)}}const Et=Symbol("ListItemRemovedAction");class K extends v{constructor(n){super(n)}static get classIdentifier(){return Et}execute(n,t,e,i){return super.execute(n,t,e,i)}}function Y(s,n){return(s==null?void 0:s.label)==null&&(s==null?void 0:s.icon)==null?n:s}class w extends V{constructor(){super();h(this,"_value",{label:void 0,icon:void 0})}init(t){if(t){const e=t,{value:i,originalValue:r,validators:a,actions:u}=e,g=R(e,["value","originalValue","validators","actions"]);[...a||[],...u||[]].forEach(x=>this.registerAction(x)),Object.assign(this,g);const d=Y(i,this._value),f=Object.freeze({label:r==null?void 0:r.label,icon:r==null?void 0:r.icon});this._value=Y(d,f),this.originalValue=Y(f,d)}this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}static create(t){const e=o.reactive(new w);return e.init(t),e}get value(){return this._value}set value(t){if(!this.enabled)return;const e=this._value;this._value=t,this.actions.trigger(y,this,t,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}get icon(){return this.value.icon}set icon(t){this.value.icon=t}get label(){return this.value.label}set label(t){this.value.label=t}clone(t){var i,r,a;const e=w.create(O(P({value:(i=t==null?void 0:t.value)!=null?i:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{enabled:(r=t==null?void 0:t.enabled)!=null?r:this.enabled,visibility:(a=t==null?void 0:t.visibility)!=null?a:this.visibility}));return e.actions=this.actions.clone(),e.actions.triggerEager(e,e.value,e.originalValue),e}execute(t){this.actions.trigger(J,this,t)}}class S extends V{constructor(){super();h(this,"_value")}init(t){if(t){const e=t,{value:i,validators:r,actions:a}=e,u=R(e,["value","validators","actions"]);[...r||[],...a||[]].forEach(g=>this.registerAction(g)),Object.assign(this,u),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(t){const e=o.reactive(new S);return e.init(t),e}get value(){return o.unref(this._value)}set value(t){const e=this._value;!this.enabled||e===t||(this._value=t,this.actions.trigger(y,this,this._value,e),this.parent&&this.parent.notifyValueChanged(),this.validate())}clone(t){var i,r,a;const e=S.create(O(P({value:(i=t==null?void 0:t.value)!=null?i:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{enabled:(r=t==null?void 0:t.enabled)!=null?r:this.enabled,visibility:(a=t==null?void 0:t.visibility)!=null?a:this.visibility}));return e.actions=this.actions.clone(),e.actions.triggerEager(e,e.value,e.originalValue),e}}const ct=S.create({value:"EmptyField"}).registerAction(new y(()=>{console.warn("Working with EmptyField! This should not happen")}));class E extends V{constructor(t,e){super();h(this,"_fields");h(this,"_value",null);h(this,"suppressNotifyValueChanged",!1);if(!E.isValidFields(t))throw new Error("Invalid fields object provided");if(this._fields={},Object.entries(t).forEach(([r,a])=>this.addField(r,a)),e){const i=e,{value:r,validators:a,actions:u}=i,g=R(i,["value","validators","actions"]);[...a||[],...u||[]].forEach(d=>this.registerAction(d)),Object.assign(this,g),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(t,e){if(this.fields[t]!==void 0)throw new Error(`Field ${t} is already in this form`);Object.defineProperty(e,"parent",{get:()=>this,configurable:!1,enumerable:!1}),Object.defineProperty(e,"fieldName",{get:()=>t,configurable:!1,enumerable:!1}),Object.defineProperty(this._fields,t,{get(){return e},configurable:!1,enumerable:!0})}static isValidFields(t){function e(i){return i instanceof V}return typeof t=="object"&&t!==null&&Object.entries(t).every(([,i])=>e(i))}static createFromFormData(t){if(t instanceof V)throw new Error("data is already a Form structure, should be a simple object");return new E(t==null?{}:Object.fromEntries(Object.entries(t).map(([e,i])=>[e,S.create({value:i})])))}field(t){var e;return(e=this._fields[t])!=null?e:null}get fields(){return this._fields}get value(){const t={};return Object.entries(this._fields).forEach(([e,i])=>{const r=i.value;(i.enabled||i instanceof E&&!c.isEmpty(r))&&(t[e]=r)}),c.isEmpty(t)?null:t}set value(t){this.suppressNotifyValueChanged=!0;try{Object.entries(this._fields).forEach(([e,i])=>{(t==null||e in t)&&(i.value=t==null?null:t[e])})}finally{this.suppressNotifyValueChanged=!1}this.notifyValueChanged(),this.validate()}get fullValue(){const t={};return Object.entries(this._fields).forEach(([e,i])=>{t[e]=i.fullValue}),t}notifyValueChanged(){if(this.suppressNotifyValueChanged)return;const t=this.value;if(!c.isEqual(t,this._value)){const e=this._value;this._value=t,this.actions.trigger(y,this,t,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}}get valid(){return super.valid&&Object.values(this._fields).every(t=>t.valid)}clone(t){var r,a,u;const e={};Object.entries(this._fields).forEach(([g,d])=>{e[g]=d.clone()});const i=new E(e,O(P({value:(r=t==null?void 0:t.value)!=null?r:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{enabled:(a=t==null?void 0:t.enabled)!=null?a:this.enabled,visibility:(u=t==null?void 0:t.visibility)!=null?u:this.visibility}));return i.actions=this.actions.clone(),i.actions.triggerEager(i,i.value,i.originalValue),i}}class B extends V{constructor(t,e){super();h(this,"_value",null);h(this,"_itemTemplate");h(this,"_previousValue");if(this._itemTemplate=t,e){const i=e,{value:r,validators:a,actions:u}=i,g=R(i,["value","validators","actions"]);[...a||[],...u||[]].forEach(d=>this.registerAction(d)),Object.assign(this,g),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(t){let e;return t instanceof E?e=t:this._itemTemplate?e=this._itemTemplate.clone({value:t}):e=E.createFromFormData(t),Object.defineProperty(e,"parent",{get:()=>this,configurable:!1,enumerable:!1}),e}setValueInternal(t){Array.isArray(t)&&(this._value=t.map(e=>this.processSetValueItem(e)))}get value(){var e;const t=(e=this._value)==null?void 0:e.map(i=>i.value);return c.isEmpty(t)?null:t}set value(t){const e=this.value;this.setValueInternal(t),this.actions.trigger(y,this,this.value,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}clone(t){var i,r,a,u;const e=new B((i=this._itemTemplate)==null?void 0:i.clone(),O(P({value:[...(r=t==null?void 0:t.value)!=null?r:this.value]},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{enabled:(a=t==null?void 0:t.enabled)!=null?a:this.enabled,visibility:(u=t==null?void 0:t.visibility)!=null?u:this.visibility}));return e.actions=this.actions.clone(),e.actions.triggerEager(e,e.value,e.originalValue),e}notifyValueChanged(){const t=this.value;if(!c.isEqual(t,this._previousValue)){const e=this._previousValue;this._previousValue=t,this.actions.trigger(y,this,t,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}}get valid(){var t,e;return super.valid&&((e=(t=this._value)==null?void 0:t.every(i=>i.valid))!=null?e:!0)}get(t){return this._value!=null?this._value[t]:void 0}push(t){var e,i;return this.insert(t,(i=(e=this._value)==null?void 0:e.length)!=null?i:0)+1}pop(){var t,e;return this.remove(((e=(t=this._value)==null?void 0:t.length)!=null?e:0)-1)}remove(t){var i;if(this._value==null||t<0||this._value.length<=t)return;let e=(i=this._value.splice(t,1))==null?void 0:i[0];return e&&(e=e.clone(),this.actions.trigger(K,this,e,t),this.notifyValueChanged()),e}insert(t,e){for(this._value==null&&(this._value=[]);this._value.length<e;){const r=this.processSetValueItem(null),a=this._value.push(r);this.actions.trigger(M,this,r,a)}const i=this.processSetValueItem(t);return this._value.splice(e,0,i),this.actions.trigger(M,this,i,e),this.notifyValueChanged(),e}clear(){this._value=null,this.notifyValueChanged()}}const ut={useMarkdownInValidators:!0};function It(){return ut}function _t(s){Object.assign(ut,s)}const St={install(s,n){n&&_t(n)}};function C(s){return It().useMarkdownInValidators?new F(s):s.replace(/[*_~`]/g,"").replace(/\[.*?\]\((.*?)\)/g,"$1").replace(/!\[.*?\]\((.*?)\)/g,"").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 xt extends p{constructor(t,e,i){let r=!1,a,u;super((d,f,x)=>(a=d,u=f,r||(r=!0,this.otherField.registerAction(new y((I,$,k,tt)=>{$(I,k,tt),this.unregistered||this.execute(x,()=>null,a,u)}))),this.isValidComparison(o.unref(d),o.unref(this.otherField.value))?null:[new A(this.replacePlaceholders(i,{newValue:d,oldValue:f,field:x,otherField:this.otherField}))]));h(this,"unregistered",!1);this.otherField=t,this.isValidComparison=e}unregister(){this.unregistered=!0}}class Ft extends p{constructor(n,t){const e=t||C("Must be one of [**{allowedAsText}**]");let i=n.join(", ");i.length>60&&(i=c.truncate(i,{length:40,separator:", ",omission:`... (${n.length} items total)`}));const r=(a,u,g)=>n.includes(o.unref(a))?null:[new A(this.replacePlaceholders(e,{newValue:a,oldValue:u,field:g,allowedValues:n,allowedAsText:i}))];super(r)}}function Lt(s){return s==null?0:c.isArray(s)||c.isString(s)?s.length:c.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class Nt extends p{constructor(n){const t=n||C("Please enter a value"),e=(i,r,a)=>Lt(o.unref(i))===0?[new A(this.replacePlaceholders(t,{newValue:i,oldValue:r,field:a}))]:null;super(e)}}class jt extends p{constructor(n,t){const e=t||C("Value must be larger or equal to **{minValue}**"),i=(r,a,u)=>r<n||r===void 0?[new A(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,minValue:n}))]:null;super(i)}}class Tt extends p{constructor(n,t){const e=t||C("Value must be less than or equal to **{maxValue}**"),i=(r,a,u)=>r>n||r===void 0?[new A(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,maxValue:n}))]:null;super(i)}}class wt extends p{constructor(n,t,e){const i=e||C("Value must be between **{minValue}** and **{maxValue}**"),r=(a,u,g)=>a<n||a>t||a===void 0?[new A(this.replacePlaceholders(i,{newValue:a,oldValue:u,field:g,minValue:n,maxValue:t}))]:null;super(r)}}function Z(s){return s==null?0:c.isArray(s)||c.isString(s)?s.length:c.isObject(s)&&Object.getPrototypeOf(s)===Object.prototype?Object.keys(s).length:String(s).length}class Pt extends p{constructor(n,t){const e=t||C("Length must be larger or equal to **{minLength}**"),i=(r,a,u)=>Z(r)<n?[new A(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,minLength:n}))]:null;super(i)}}class Ot extends p{constructor(n,t){const e=t||C("Length must be less than or equal to **{maxLength}**"),i=(r,a,u)=>Z(r)>n?[new A(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,maxLength:n}))]:null;super(i)}}class Rt extends p{constructor(n,t,e){const i=e||C("Length must be between **{minLength}** and **{maxLength}**"),r=(a,u,g)=>{const d=Z(a);return d<n||d>t?[new A(this.replacePlaceholders(i,{newValue:a,oldValue:u,field:g,minLength:n,maxLength:t}))]:null};super(r)}}class Ut extends p{constructor(n,t){const e=t||C('Value must match pattern "**{pattern}**"'),i=(r,a,u)=>n.test(String(o.unref(r)))?null:[new A(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,pattern:n}))];super(i)}}const ot=Object.freeze(Object.defineProperty({__proto__:null,CompareTo:xt,InAllowedValues:Ft,LengthInRange:Rt,MaxLength:Ot,MaxValue:Tt,MinLength:Pt,MinValue:jt,Pattern:Ut,Required:Nt,Validator:p,ValueInRange:wt},Symbol.toStringTag,{value:"Module"})),Dt=Object.freeze(Object.defineProperty({__proto__:null,AbortEventHandlingException:U,Action:w,ActionsMap:L,ConditionalEnabledAction:at,ConditionalStatementAction:j,ConditionalValueAction:lt,ConditionalVisibilityAction:rt,DisplayMode:_,EmptyField:ct,EnabledChangedAction:H,EnabledChangingAction:z,ExecuteAction:J,Field:S,FieldActionBase:v,FieldBase:V,Group:E,List:B,ListItemAddedAction:M,ListItemRemovedAction:K,MdString:F,Operator:b,Statement:N,ValidChangedAction:G,ValidationError:q,ValidationErrorRenderContent:A,ValidationErrorText:st,Validator:p,Validators:ot,ValueChangedAction:y,VisibilityChangedAction:W,VisibilityChangingAction:X,buildErrorMessage:C,isCustomModalContentComponentDef:D},Symbol.toStringTag,{value:"Module"}));l.AbortEventHandlingException=U,l.Action=w,l.ActionsMap=L,l.ConditionalEnabledAction=at,l.ConditionalStatementAction=j,l.ConditionalValueAction=lt,l.ConditionalVisibilityAction=rt,l.DisplayMode=_,l.EmptyField=ct,l.EnabledChangedAction=H,l.EnabledChangingAction=z,l.ExecuteAction=J,l.Field=S,l.FieldActionBase=v,l.FieldBase=V,l.Group=E,l.List=B,l.ListItemAddedAction=M,l.ListItemRemovedAction=K,l.MdString=F,l.Operator=b,l.Statement=N,l.ValidChangedAction=G,l.ValidationError=q,l.ValidationErrorRenderContent=A,l.ValidationErrorText=st,l.Validator=p,l.Validators=ot,l.ValueChangedAction=y,l.VisibilityChangedAction=W,l.VisibilityChangingAction=X,l.buildErrorMessage=C,l.default=Dt,l.forms=St,l.isCustomModalContentComponentDef=D,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
3
3
  //# sourceMappingURL=dynamicforms-vue-forms.umd.cjs.map