@dynamicforms/vue-forms 0.4.1 → 0.4.3

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,Mt=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var tt=(l,c,u)=>c in l?Bt(l,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[c]=u,M=(l,c)=>{for(var u in c||(c={}))gt.call(c,u)&&tt(l,u,c[u]);if(B)for(var u of B(c))ft.call(c,u)&&tt(l,u,c[u]);return l},k=(l,c)=>Mt(l,kt(c));var w=(l,c)=>{var u={};for(var m in l)gt.call(l,m)&&c.indexOf(m)<0&&(u[m]=l[m]);if(l!=null&&B)for(var m of B(l))c.indexOf(m)<0&&ft.call(l,m)&&(u[m]=l[m]);return u};var h=(l,c,u)=>tt(l,typeof c!="symbol"?c+"":c,u);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 et=10;(s=>{function i(n){return n.toUpperCase()==="SUPPRESS"?1:n.toUpperCase()==="HIDDEN"?5:n.toUpperCase()==="INVISIBLE"?8:et}s.fromString=i;function t(n){const r=typeof n=="number"?n:s.fromString(n);return Object.values(s).includes(r)?r:et}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 I=m;class y{constructor(i){h(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 this.executorFn(i,t,...e)}get eager(){return!1}boundToField(i){}unregister(){}}class P extends Error{}const it=Symbol("ValueChangedAction");class A extends y{constructor(i){super(i)}static get classIdentifier(){return it}execute(i,t,e,n){return super.execute(i,t,e,n)}}class _ extends String{}function O(s){const i=u.unref(s);return typeof i=="object"&&"componentName"in i}class R{get componentName(){return"Comment"}get componentBindings(){return{}}get componentBody(){return""}get extraClasses(){return""}}class nt extends R{constructor(i,t=""){super(),this.text=i,this.classes=t}get componentName(){return"template"}get componentBody(){return this.text}get extraClasses(){return this.classes}}class v extends R{constructor(t,e=""){super();h(this,"text");h(this,"textType");this.classes=e,this.text=t,this.textType=u.computed(()=>this.getTextType)}get getTextType(){const t=u.unref(this.text);return t?t instanceof _?"md":O(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);case"component":return u.unref(this.text).componentVHtml||"";default:return""}}get extraClasses(){return this.classes}}class st extends v{}const bt=Symbol("Validator");class p extends A{constructor(t){super((n,r,a,o)=>{const d=t(a,o,n)||[],g=f=>{var j;f==null||f.forEach(S=>Object.defineProperty(S,"source",{value:this.source,enumerable:!1,configurable:!1}));for(let S=n.errors.length-1;S>=0;S--){const q=n.errors[S];if(q.source===this.source){const $=(j=f==null?void 0:f.findIndex(Z=>c.isEqual(Z,q)))!=null?j:-1;$>=0?f==null||f.splice($,1):n.errors.splice(S,1)}}f&&f.length>0&&n.errors.push(...f),n.validate()};return d instanceof Promise?(n.validating=++n.validatingCount>0,d.then(f=>g(f)).finally(()=>{n.validatingCount=Math.max(0,n.validatingCount-1),n.validating=n.validatingCount>0})):g(d),r(n,a,o)});h(this,"source");this.source=Symbol(this.constructor.name)}static get classIdentifier(){return bt}get eager(){return!0}replacePlaceholders(t,e){if(O(t))return t;let n=t;return Object.keys(e).forEach(r=>{n=n.replaceAll(`{${r}}`,e[r])}),t instanceof _?new _(n):n}}class x extends Map{constructor(){super(...arguments);h(this,"eagerActions",new Set);h(this,"registeredActions",[])}register(t){if(!(t instanceof y))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){const r=t.classIdentifier;r===it&&this.triggerEager(e,...n);const a=this.get(r);try{if(a)return a(e,...n)}catch(o){if(!(o instanceof P))throw o}return null}triggerEager(t,...e){for(const n of this.eagerActions){const r=this.get(n);try{r&&r(t,...e)}catch(a){if(!(a instanceof P))throw a}}}clone(){const t=new x;return this.registeredActions.forEach(e=>t.register(e)),t}cloneWithoutValidators(){const t=new x;return this.registeredActions.forEach(e=>{e instanceof p?e.unregister():t.register(e)}),t}}const mt=Symbol("ConditionalStatementAction");class L extends A{constructor(t,e){const n=(r,a,o,d)=>{const g=t.evaluate();if(g!==this.lastResult){for(const f of this.boundFields)e(f,g,this.lastResult);this.lastResult=g}return a(r,o,d)};super(n);h(this,"lastResult");h(this,"boundFields",new Set);t.collectFields().forEach(r=>r.registerAction(new A(n)))}static get classIdentifier(){return mt}get eager(){return!0}boundToField(t){this.boundFields.add(t)}}class rt extends L{constructor(i){super(i,(t,e)=>{t.visibility=e?I.FULL:I.SUPPRESS})}}class at extends L{constructor(i){super(i,(t,e)=>{t.enabled=e})}}class lt extends L{constructor(i,t){super(i,(e,n)=>{n&&(e.value=t)})}}var N=(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))(N||{});(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})(N||(N={})),Object.freeze(N);const b=N,pt=Symbol("EnabledChangingAction");class G extends y{constructor(i){super(i)}static get classIdentifier(){return pt}execute(i,t,e,n){return super.execute(i,t,e,n)}}const vt=Symbol("EnabledChangedAction");class H extends y{constructor(i){super(i)}static get classIdentifier(){return vt}execute(i,t,e,n){return super.execute(i,t,e,n)}}const yt=Symbol("ValidChangedAction");class Q extends y{constructor(i){super(i)}static get classIdentifier(){return yt}execute(i,t,e,n){return super.execute(i,t,e,n)}}const At=Symbol("VisibilityChangingAction");class z extends y{constructor(i){super(i)}static get classIdentifier(){return At}execute(i,t,e,n){return super.execute(i,t,e,n)}}const Vt=Symbol("VisibilityChangedAction");class X extends y{constructor(i){super(i)}static get classIdentifier(){return Vt}execute(i,t,e,n){return super.execute(i,t,e,n)}}class C{constructor(){h(this,"reactiveValue",u.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",I.FULL);h(this,"_enabled",!0)}get visibility(){return this._visibility}set visibility(i){const t=this._visibility,e=this.actions.trigger(z,this,i,t);if(!I.isDefined(e!=null?e:i))throw new Error("visibility must be a DisplayMode constant");this._visibility=I.fromAny(e!=null?e:i),this.actions.trigger(X,this,this._visibility,t)}get enabled(){return this._enabled}set enabled(i){const t=this._enabled,e=this.actions.trigger(G,this,i,t);if(!c.isBoolean(e!=null?e:i))throw new Error("Enabled value must be boolean");this._enabled=e!=null?e:i,this.actions.trigger(H,this,this._enabled,t)}validate(){const i=this._valid;this._valid=this.valid,this._valid!==i&&this.actions.trigger(Q,this,this.valid,i)}get valid(){return this.errors.length===0}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 Ct(s,i){return s?!i:i}class F{constructor(i,t,e){h(this,"operand1");h(this,"operator");h(this,"operand2");this.operand1=i,this.operator=t,this.operand2=e}get operand1Value(){return this.operand1 instanceof F?this.operand1.evaluate():this.operand1 instanceof C?u.unref(this.operand1.value):this.operand1}get operand2Value(){return this.operand2 instanceof F?this.operand2.evaluate():this.operand2 instanceof C?u.unref(this.operand2.value):this.operand2}evaluate(){var e,n,r,a;const i=this.operand1Value,t=this.operand2Value;switch(this.operator){case b.AND:return i&&t;case b.OR:return i||t;case b.NAND:return!(i&&t);case b.NOR:return!(i||t);case b.XOR:return Ct(i,t);case b.NOT:return!i;case b.EQUALS:return i==t;case b.NOT_EQUALS:return i!=t;case b.LT:return i<t;case b.LE:return i<=t;case b.GE:return i>=t;case b.GT:return i>t;case b.IN:return(n=(e=t==null?void 0:t.includes)==null?void 0:e.call(t,i))!=null?n:!1;case b.NOT_IN:return!((a=(r=t==null?void 0:t.includes)==null?void 0:r.call(t,i))==null||a);case b.INCLUDES:return c.isString(i)&&c.isString(t)&&i.indexOf(t)>=0;case b.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 C?i.add(e):e instanceof F&&e.collectFields().forEach(r=>i.add(r))}return t(this.operand1),t(this.operand2),i}}const Et=Symbol("ExecuteAction");class W extends y{constructor(i){super(i)}static get classIdentifier(){return Et}execute(i,t,e){return super.execute(i,t,e)}}const St=Symbol("ListItemAddedAction");class U extends y{constructor(i){super(i)}static get classIdentifier(){return St}execute(i,t,e,n){return super.execute(i,t,e,n)}}const It=Symbol("ListItemRemovedAction");class J extends y{constructor(i){super(i)}static get classIdentifier(){return It}execute(i,t,e,n){return super.execute(i,t,e,n)}}const ct=Symbol("FieldConstructorGuard");class T extends C{constructor(t){super();h(this,"_value");if(t!==ct){const e=this.constructor.name;throw new TypeError(`Don't use constructor to instantiate ${e}. Use ${e}.create<T>`)}}init(t){if(t){const e=t,{value:n,validators:r,actions:a}=e,o=w(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),this.validate()}static create(t){const e=u.reactive(new this(ct));return e.init(t),e}get value(){return this._value}set value(t){const e=this._value;!this.enabled||e===t||(this._value=t,this.actions.trigger(A,this,this._value,e),this.parent&&this.parent.notifyValueChanged(),this.validate())}clone(t){var n,r,a;const e=this.constructor.create(k(M({value:(n=t==null?void 0:t.value)!=null?n: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 ot=T.create({value:"EmptyField"}).registerAction(new A(()=>{console.warn("Working with EmptyField! This should not happen")}));function K(s,i){return(s==null?void 0:s.label)==null&&(s==null?void 0:s.icon)==null?i:s}class ut extends T{constructor(i){super(i),this._value={label:void 0,icon:void 0}}init(i){if(i){const t=i,{value:e,originalValue:n,validators:r,actions:a}=t,o=w(t,["value","originalValue","validators","actions"]);[...r||[],...a||[]].forEach(f=>this.registerAction(f)),Object.assign(this,o);const d=K(e,this._value),g=Object.freeze({label:n==null?void 0:n.label,icon:n==null?void 0:n.icon});this._value=K(d,g),this.originalValue=K(g,d)}this.actions.triggerEager(this,this.value,this.originalValue),this.validate()}static create(i){return super.create(i)}get icon(){return this.value.icon}set icon(i){this.value.icon=i}get label(){return this.value.label}set label(i){this.value.label=i}execute(i){this.actions.trigger(W,this,i)}}class E extends C{constructor(t,e){super();h(this,"_fields");h(this,"_value",null);h(this,"reactiveValue",u.computed(()=>this.value));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 n=e,{value:r,validators:a,actions:o}=n,d=w(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),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(n){return n instanceof C}return typeof t=="object"&&t!==null&&Object.entries(t).every(([,n])=>e(n))}static createFromFormData(t){if(t instanceof C)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,n])=>[e,T.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 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,n])=>{(t==null||e in t)&&(n.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,n])=>{t[e]=n.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(A,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,o;const e={};Object.entries(this._fields).forEach(([d,g])=>{e[d]=g.clone()});const n=new E(e,k(M({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:(o=t==null?void 0:t.visibility)!=null?o:this.visibility}));return n.actions=this.actions.clone(),n.actions.triggerEager(n,n.value,n.originalValue),n}}class D extends C{constructor(t,e){super();h(this,"_value",null);h(this,"_itemTemplate");h(this,"_previousValue");if(this._itemTemplate=t,e){const n=e,{value:r,validators:a,actions:o}=n,d=w(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),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(n=>n.value);return c.isEmpty(t)?null:t}set value(t){const e=this.value;this.setValueInternal(t),this.actions.trigger(A,this,this.value,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}clone(t){var n,r,a,o;const e=new D((n=this._itemTemplate)==null?void 0:n.clone(),k(M({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:(o=t==null?void 0:t.visibility)!=null?o: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(A,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(n=>n.valid))!=null?e:!0)}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(J,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(U,this,r,a)}const n=this.processSetValueItem(t);return this._value.splice(e,0,n),this.actions.trigger(U,this,n,e),this.notifyValueChanged(),e}clear(){this._value=null,this.notifyValueChanged()}}const ht={useMarkdownInValidators:!0};function _t(){return ht}function xt(s){Object.assign(ht,s)}const Ft={install(s,i){i&&xt(i)}};function V(s){return _t().useMarkdownInValidators?new _(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 Lt extends p{constructor(t,e,n){let r=!1,a,o;super((g,f,j)=>(a=g,o=f,r||(r=!0,this.otherField.registerAction(new A((S,q,$,Z)=>{q(S,$,Z),this.unregistered||this.execute(j,()=>null,a,o)}))),this.isValidComparison(u.unref(g),u.unref(this.otherField.value))?null:[new v(this.replacePlaceholders(n,{newValue:g,oldValue:f,field:j,otherField:this.otherField}))]));h(this,"unregistered",!1);this.otherField=t,this.isValidComparison=e}unregister(){this.unregistered=!0}}class Nt extends p{constructor(i,t){const e=t||V("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 v(this.replacePlaceholders(e,{newValue:a,oldValue:o,field:d,allowedValues:i,allowedAsText:n}))];super(r)}}function Tt(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 jt extends p{constructor(i){const t=i||V("Please enter a value"),e=(n,r,a)=>Tt(u.unref(n))===0?[new v(this.replacePlaceholders(t,{newValue:n,oldValue:r,field:a}))]:null;super(e)}}class wt extends p{constructor(i,t){const e=t||V("Value must be larger or equal to **{minValue}**"),n=(r,a,o)=>r<i||r===void 0?[new v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,minValue:i}))]:null;super(n)}}class Pt extends p{constructor(i,t){const e=t||V("Value must be less than or equal to **{maxValue}**"),n=(r,a,o)=>r>i||r===void 0?[new v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,maxValue:i}))]:null;super(n)}}class Ot extends p{constructor(i,t,e){const n=e||V("Value must be between **{minValue}** and **{maxValue}**"),r=(a,o,d)=>a<i||a>t||a===void 0?[new v(this.replacePlaceholders(n,{newValue:a,oldValue:o,field:d,minValue:i,maxValue:t}))]:null;super(r)}}function Y(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 Rt extends p{constructor(i,t){const e=t||V("Length must be larger or equal to **{minLength}**"),n=(r,a,o)=>Y(r)<i?[new v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,minLength:i}))]:null;super(n)}}class Ut extends p{constructor(i,t){const e=t||V("Length must be less than or equal to **{maxLength}**"),n=(r,a,o)=>Y(r)>i?[new v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,maxLength:i}))]:null;super(n)}}class Dt extends p{constructor(i,t,e){const n=e||V("Length must be between **{minLength}** and **{maxLength}**"),r=(a,o,d)=>{const g=Y(a);return g<i||g>t?[new v(this.replacePlaceholders(n,{newValue:a,oldValue:o,field:d,minLength:i,maxLength:t}))]:null};super(r)}}class qt extends p{constructor(i,t){const e=t||V('Value must match pattern "**{pattern}**"'),n=(r,a,o)=>i.test(String(u.unref(r)))?null:[new v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:o,pattern:i}))];super(n)}}const dt=Object.freeze(Object.defineProperty({__proto__:null,CompareTo:Lt,InAllowedValues:Nt,LengthInRange:Dt,MaxLength:Ut,MaxValue:Pt,MinLength:Rt,MinValue:wt,Pattern:qt,Required:jt,Validator:p,ValueInRange:Ot},Symbol.toStringTag,{value:"Module"})),$t=Object.freeze(Object.defineProperty({__proto__:null,AbortEventHandlingException:P,Action:ut,ActionsMap:x,ConditionalEnabledAction:at,ConditionalStatementAction:L,ConditionalValueAction:lt,ConditionalVisibilityAction:rt,DisplayMode:I,EmptyField:ot,EnabledChangedAction:H,EnabledChangingAction:G,ExecuteAction:W,Field:T,FieldActionBase:y,FieldBase:C,Group:E,List:D,ListItemAddedAction:U,ListItemRemovedAction:J,MdString:_,Operator:b,RenderableValue:st,Statement:F,ValidChangedAction:Q,ValidationError:R,ValidationErrorRenderContent:v,ValidationErrorText:nt,Validator:p,Validators:dt,ValueChangedAction:A,VisibilityChangedAction:X,VisibilityChangingAction:z,buildErrorMessage:V,isSimpleComponentDef:O},Symbol.toStringTag,{value:"Module"}));l.AbortEventHandlingException=P,l.Action=ut,l.ActionsMap=x,l.ConditionalEnabledAction=at,l.ConditionalStatementAction=L,l.ConditionalValueAction=lt,l.ConditionalVisibilityAction=rt,l.DisplayMode=I,l.EmptyField=ot,l.EnabledChangedAction=H,l.EnabledChangingAction=G,l.ExecuteAction=W,l.Field=T,l.FieldActionBase=y,l.FieldBase=C,l.Group=E,l.List=D,l.ListItemAddedAction=U,l.ListItemRemovedAction=J,l.MdString=_,l.Operator=b,l.RenderableValue=st,l.Statement=F,l.ValidChangedAction=Q,l.ValidationError=R,l.ValidationErrorRenderContent=v,l.ValidationErrorText=nt,l.Validator=p,l.Validators=dt,l.ValueChangedAction=A,l.VisibilityChangedAction=X,l.VisibilityChangingAction=z,l.buildErrorMessage=V,l.default=$t,l.forms=Ft,l.isSimpleComponentDef=O,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 Mt=Object.defineProperty,$t=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var tt=(l,c,o)=>c in l?Mt(l,c,{enumerable:!0,configurable:!0,writable:!0,value:o}):l[c]=o,j=(l,c)=>{for(var o in c||(c={}))ft.call(c,o)&&tt(l,o,c[o]);if($)for(var o of $(c))mt.call(c,o)&&tt(l,o,c[o]);return l},P=(l,c)=>$t(l,Ht(c));var O=(l,c)=>{var o={};for(var b in l)ft.call(l,b)&&c.indexOf(b)<0&&(o[b]=l[b]);if(l!=null&&$)for(var b of $(l))c.indexOf(b)<0&&mt.call(l,b)&&(o[b]=l[b]);return o};var h=(l,c,o)=>tt(l,typeof c!="symbol"?c+"":c,o);var b=(s=>(s[s.SUPPRESS=1]="SUPPRESS",s[s.HIDDEN=5]="HIDDEN",s[s.INVISIBLE=8]="INVISIBLE",s[s.FULL=10]="FULL",s))(b||{});const et=10;(s=>{function n(i){return i.toUpperCase()==="SUPPRESS"?1:i.toUpperCase()==="HIDDEN"?5:i.toUpperCase()==="INVISIBLE"?8:et}s.fromString=n;function t(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)?r:et}s.fromAny=t;function e(i){const r=typeof i=="number"?i:s.fromString(i);return Object.values(s).includes(r)}s.isDefined=e})(b||(b={})),Object.freeze(b);const S=b;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,t,...e){return this.executorFn(n,t,...e)}get eager(){return!1}boundToField(n){}unregister(){}}class R extends Error{}const nt=Symbol("ValueChangedAction");class A extends y{constructor(n){super(n)}static get classIdentifier(){return nt}execute(n,t,e,i){return super.execute(n,t,e,i)}}class I extends String{}function U(s){const n=o.unref(s);return typeof n=="object"&&"componentName"in n}class k{get componentName(){return"Comment"}get componentBindings(){return{}}get componentBody(){return""}get extraClasses(){return""}}class it extends k{constructor(n,t=""){super(),this.text=n,this.classes=t}get componentName(){return"template"}get componentBody(){return this.text}get extraClasses(){return this.classes}}class v extends k{constructor(t,e=""){super();h(this,"text");h(this,"textType");this.classes=e,this.text=t,this.textType=o.computed(()=>this.getTextType)}get getTextType(){const t=o.unref(this.text);return t?t instanceof I?"md":U(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);case"component":return o.unref(this.text).componentVHtml||"";default:return""}}get extraClasses(){return this.classes}}class st extends v{}const bt=Symbol("Validator");class p extends A{constructor(t){super((i,r,a,u)=>{const d=t(a,u,i)||[],g=f=>{var T;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=(T=f==null?void 0:f.findIndex(Z=>c.isEqual(Z,q)))!=null?T:-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,u)});h(this,"source");this.source=Symbol(this.constructor.name)}static get classIdentifier(){return bt}get eager(){return!0}replacePlaceholders(t,e){if(U(t))return t;let i=t;return Object.keys(e).forEach(r=>{i=i.replaceAll(`{${r}}`,e[r])}),t instanceof I?new I(i):i}}class x extends Map{constructor(){super(...arguments);h(this,"eagerActions",new Set);h(this,"registeredActions",[])}register(t){if(!(t instanceof y))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 R))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 R))throw a}}}clone(){const t=new x;return this.registeredActions.forEach(e=>t.register(e)),t}cloneWithoutValidators(){const t=new x;return this.registeredActions.forEach(e=>{e instanceof p?e.unregister():t.register(e)}),t}}const pt=Symbol("ConditionalStatementAction");class w extends A{constructor(t,e){const i=(r,a,u,d)=>{const g=t.evaluate();if(g!==this.lastResult){for(const f of this.boundFields)e(f,g,this.lastResult);this.lastResult=g}return a(r,u,d)};super(i);h(this,"lastResult");h(this,"boundFields",new Set);t.collectFields().forEach(r=>r.registerAction(new A(i)))}static get classIdentifier(){return pt}get eager(){return!0}boundToField(t){this.boundFields.add(t)}}class rt extends w{constructor(n){super(n,(t,e)=>{t.visibility=e?S.FULL:S.SUPPRESS})}}class at extends w{constructor(n){super(n,(t,e)=>{t.enabled=e})}}class lt extends w{constructor(n,t){super(n,(e,i)=>{i&&(e.value=t)})}}var N=(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))(N||{});(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})(N||(N={})),Object.freeze(N);const m=N,vt=Symbol("EnabledChangingAction");class H extends y{constructor(n){super(n)}static get classIdentifier(){return vt}execute(n,t,e,i){return super.execute(n,t,e,i)}}const yt=Symbol("EnabledChangedAction");class G extends y{constructor(n){super(n)}static get classIdentifier(){return yt}execute(n,t,e,i){return super.execute(n,t,e,i)}}const At=Symbol("ValidChangedAction");class Q extends y{constructor(n){super(n)}static get classIdentifier(){return At}execute(n,t,e,i){return super.execute(n,t,e,i)}}const Ct=Symbol("VisibilityChangingAction");class z extends y{constructor(n){super(n)}static get classIdentifier(){return Ct}execute(n,t,e,i){return super.execute(n,t,e,i)}}const Vt=Symbol("VisibilityChangedAction");class W extends y{constructor(n){super(n)}static get classIdentifier(){return Vt}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 x);h(this,"_visibility",S.FULL);h(this,"_enabled",!0)}get visibility(){return this._visibility}set visibility(n){const t=this._visibility,e=this.actions.trigger(z,this,n,t);if(!S.isDefined(e!=null?e:n))throw new Error("visibility must be a DisplayMode constant");this._visibility=S.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(H,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(G,this,this._enabled,t)}validate(){const n=this._valid;this._valid=this.valid,this._valid!==n&&this.actions.trigger(Q,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 Et(s,n){return s?!n:n}class F{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 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 e,i,r,a;const n=this.operand1Value,t=this.operand2Value;switch(this.operator){case m.AND:return n&&t;case m.OR:return n||t;case m.NAND:return!(n&&t);case m.NOR:return!(n||t);case m.XOR:return Et(n,t);case m.NOT:return!n;case m.EQUALS:return n==t;case m.NOT_EQUALS:return n!=t;case m.LT:return n<t;case m.LE:return n<=t;case m.GE:return n>=t;case m.GT:return n>t;case m.IN:return(i=(e=t==null?void 0:t.includes)==null?void 0:e.call(t,n))!=null?i:!1;case m.NOT_IN:return!((a=(r=t==null?void 0:t.includes)==null?void 0:r.call(t,n))==null||a);case m.INCLUDES:return c.isString(n)&&c.isString(t)&&n.indexOf(t)>=0;case m.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 F&&e.collectFields().forEach(r=>n.add(r))}return t(this.operand1),t(this.operand2),n}}const _t=Symbol("ExecuteAction");class X extends y{constructor(n){super(n)}static get classIdentifier(){return _t}execute(n,t,e){return super.execute(n,t,e)}}const St=Symbol("ListItemAddedAction");class B extends y{constructor(n){super(n)}static get classIdentifier(){return St}execute(n,t,e,i){return super.execute(n,t,e,i)}}const It=Symbol("ListItemRemovedAction");class Y extends y{constructor(n){super(n)}static get classIdentifier(){return It}execute(n,t,e,i){return super.execute(n,t,e,i)}}const ot=Symbol("FieldConstructorGuard");class L extends V{constructor(t){super();h(this,"_value");if(t!==ot){const e=this.constructor.name;throw new TypeError(`Don't use constructor to instantiate ${e}. Use ${e}.create<T>`)}}init(t){if(t){const e=t,{value:i,validators:r,actions:a}=e,u=O(e,["value","validators","actions"]);[...r||[],...a||[]].forEach(d=>this.registerAction(d)),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 this(ot));return e.init(t),e}get value(){return this._value}set value(t){const e=this._value;!this.enabled||e===t||(this._value=t,this.actions.trigger(A,this,this._value,e),this.parent&&this.parent.notifyValueChanged(),this.validate())}clone(t){var i,r,a;const e=this.constructor.create(P(j({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=L.create({value:"EmptyField"}).registerAction(new A(()=>{console.warn("Working with EmptyField! This should not happen")}));function J(s,n){return(s==null?void 0:s.label)==null&&(s==null?void 0:s.icon)==null?n:s}class ut extends L{constructor(n){super(n),this._value={label:void 0,icon:void 0}}init(n){if(n){const t=n,{value:e,originalValue:i,validators:r,actions:a}=t,u=O(t,["value","originalValue","validators","actions"]);[...r||[],...a||[]].forEach(f=>this.registerAction(f)),Object.assign(this,u);const d=J(e,this._value),g=Object.freeze({label:i==null?void 0:i.label,icon:i==null?void 0:i.icon});this._value=J(d,g),this.originalValue=J(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(X,this,n)}}const ht=o.defineComponent({__name:"messages-widget",props:{message:{},classes:{default:"text-error"}},setup(s){const n=s,t=o.resolveComponent("vue-markdown"),e=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":typeof t=="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))):r.push(o.h(t,{class:[n.classes,a.extraClasses,"df-messages-widget-markdown"],source:a.componentBindings.source}));break;default:r.push(o.h(e.has(a.componentName.toLowerCase())?a.componentName:o.resolveComponent(a.componentName),P(j({class:[n.classes,a.extraClasses]},a.componentBindings),{innerHTML:a.componentBody})));break}}),r};return(r,a)=>(o.openBlock(),o.createBlock(i))}});class E extends V{constructor(t,e){super();h(this,"_fields");h(this,"_value",null);h(this,"reactiveValue",o.computed(()=>this.value));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,d=O(i,["value","validators","actions"]);[...a||[],...u||[]].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(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,L.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(A,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(([d,g])=>{e[d]=g.clone()});const i=new E(e,P(j({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 D 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,d=O(i,["value","validators","actions"]);[...a||[],...u||[]].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(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(A,this,this.value,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}clone(t){var i,r,a,u;const e=new D((i=this._itemTemplate)==null?void 0:i.clone(),P(j({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(A,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(Y,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(B,this,r,a)}const i=this.processSetValueItem(t);return this._value.splice(e,0,i),this.actions.trigger(B,this,i,e),this.notifyValueChanged(),e}clear(){this._value=null,this.notifyValueChanged()}}const dt={useMarkdownInValidators:!0};function xt(){return dt}function Ft(s){Object.assign(dt,s)}const wt={install(s,n){n&&Ft(n)}};function C(s){return xt().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 Nt extends p{constructor(t,e,i){let r=!1,a,u;super((g,f,T)=>(a=g,u=f,r||(r=!0,this.otherField.registerAction(new A((_,q,M,Z)=>{q(_,M,Z),this.unregistered||this.execute(T,()=>null,a,u)}))),this.isValidComparison(o.unref(g),o.unref(this.otherField.value))?null:[new v(this.replacePlaceholders(i,{newValue:g,oldValue:f,field:T,otherField:this.otherField}))]));h(this,"unregistered",!1);this.otherField=t,this.isValidComparison=e}unregister(){this.unregistered=!0}}class Lt 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,d)=>n.includes(o.unref(a))?null:[new v(this.replacePlaceholders(e,{newValue:a,oldValue:u,field:d,allowedValues:n,allowedAsText:i}))];super(r)}}function Tt(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 jt extends p{constructor(n){const t=n||C("Please enter a value"),e=(i,r,a)=>Tt(o.unref(i))===0?[new v(this.replacePlaceholders(t,{newValue:i,oldValue:r,field:a}))]:null;super(e)}}class Pt 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 v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,minValue:n}))]:null;super(i)}}class Ot 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 v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,maxValue:n}))]:null;super(i)}}class Rt extends p{constructor(n,t,e){const i=e||C("Value must be between **{minValue}** and **{maxValue}**"),r=(a,u,d)=>a<n||a>t||a===void 0?[new v(this.replacePlaceholders(i,{newValue:a,oldValue:u,field:d,minValue:n,maxValue:t}))]:null;super(r)}}function K(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 Ut extends p{constructor(n,t){const e=t||C("Length must be larger or equal to **{minLength}**"),i=(r,a,u)=>K(r)<n?[new v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,minLength:n}))]:null;super(i)}}class kt extends p{constructor(n,t){const e=t||C("Length must be less than or equal to **{maxLength}**"),i=(r,a,u)=>K(r)>n?[new v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,maxLength:n}))]:null;super(i)}}class Bt extends p{constructor(n,t,e){const i=e||C("Length must be between **{minLength}** and **{maxLength}**"),r=(a,u,d)=>{const g=K(a);return g<n||g>t?[new v(this.replacePlaceholders(i,{newValue:a,oldValue:u,field:d,minLength:n,maxLength:t}))]:null};super(r)}}class Dt 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 v(this.replacePlaceholders(e,{newValue:r,oldValue:a,field:u,pattern:n}))];super(i)}}const gt=Object.freeze(Object.defineProperty({__proto__:null,CompareTo:Nt,InAllowedValues:Lt,LengthInRange:Bt,MaxLength:kt,MaxValue:Ot,MinLength:Ut,MinValue:Pt,Pattern:Dt,Required:jt,Validator:p,ValueInRange:Rt},Symbol.toStringTag,{value:"Module"})),qt=Object.freeze(Object.defineProperty({__proto__:null,AbortEventHandlingException:R,Action:ut,ActionsMap:x,ConditionalEnabledAction:at,ConditionalStatementAction:w,ConditionalValueAction:lt,ConditionalVisibilityAction:rt,DisplayMode:S,EmptyField:ct,EnabledChangedAction:G,EnabledChangingAction:H,ExecuteAction:X,Field:L,FieldActionBase:y,FieldBase:V,Group:E,List:D,ListItemAddedAction:B,ListItemRemovedAction:Y,MdString:I,MessagesWidget:ht,Operator:m,RenderableValue:st,Statement:F,ValidChangedAction:Q,ValidationError:k,ValidationErrorRenderContent:v,ValidationErrorText:it,Validator:p,Validators:gt,ValueChangedAction:A,VisibilityChangedAction:W,VisibilityChangingAction:z,buildErrorMessage:C,isSimpleComponentDef:U},Symbol.toStringTag,{value:"Module"}));l.AbortEventHandlingException=R,l.Action=ut,l.ActionsMap=x,l.ConditionalEnabledAction=at,l.ConditionalStatementAction=w,l.ConditionalValueAction=lt,l.ConditionalVisibilityAction=rt,l.DisplayMode=S,l.EmptyField=ct,l.EnabledChangedAction=G,l.EnabledChangingAction=H,l.ExecuteAction=X,l.Field=L,l.FieldActionBase=y,l.FieldBase=V,l.Group=E,l.List=D,l.ListItemAddedAction=B,l.ListItemRemovedAction=Y,l.MdString=I,l.MessagesWidget=ht,l.Operator=m,l.RenderableValue=st,l.Statement=F,l.ValidChangedAction=Q,l.ValidationError=k,l.ValidationErrorRenderContent=v,l.ValidationErrorText=it,l.Validator=p,l.Validators=gt,l.ValueChangedAction=A,l.VisibilityChangedAction=W,l.VisibilityChangingAction=z,l.buildErrorMessage=C,l.default=qt,l.forms=wt,l.isSimpleComponentDef=U,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
3
3
  //# sourceMappingURL=dynamicforms-vue-forms.umd.cjs.map