@dynamicforms/vue-forms 0.11.0 → 0.12.0

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.
package/dist/index.d.ts CHANGED
@@ -46,27 +46,44 @@ export declare class Action<T extends ActionValue = ActionValue, X extends objec
46
46
 
47
47
  declare type ActionExecutor = (field: FieldBase, supr: FieldActionExecute, ...params: any[]) => any;
48
48
 
49
- export declare class ActionsMap extends Map<symbol, FieldActionExecute> {
50
- private readonly eagerActions;
49
+ /**
50
+ * The actions one element has registered, grouped by the identifier they are triggered under. Within a group the
51
+ * actions stand in registration order and are run from the end backwards, so the newest registration is the
52
+ * outermost handler and reaches the ones before it through the `supr` it is handed. A handler that does not call
53
+ * `supr` ends the run there, and one that calls it may transform what it answers with.
54
+ */
55
+ export declare class ActionsMap {
56
+ /** every action registered here, in registration order across all identifiers */
51
57
  private readonly registeredActions;
52
- register(action: FieldActionBase): void;
58
+ /** the actions of one identifier, in registration order */
59
+ private readonly chains;
60
+ /** the eager actions of one identifier, in registration order; a subsequence of the chain under that identifier */
61
+ private readonly eagerChains;
53
62
  /**
54
- * True when triggering this action would run something: a handler registered under the identifier, or - on the
55
- * value change identifier, which trigger() answers with an eager pass as well - any eager action at all. A
56
- * caller that has to build the parameters before it can trigger asks this first and skips building them when
57
- * there is nothing to receive them.
63
+ * Registers `action`. It becomes the outermost handler of its identifier, or - where `before` is given and is
64
+ * registered here under the same identifier - takes that action's place in the order, so `before` wraps it and
65
+ * reaches it through `supr`. That is what lets an action be added to a chain someone else built and still sit
66
+ * inside a handler already there.
58
67
  */
68
+ register(action: FieldActionBase, before?: FieldActionBase): void;
69
+ /**
70
+ * Drops `action` from this map and answers whether it was in it. The lists it stood in are replaced rather than
71
+ * written, so a run already walking one finishes on the list it started with and the removal takes effect from
72
+ * the next trigger.
73
+ */
74
+ unregister(action: FieldActionBase): boolean;
75
+ /** True where something is registered under `identifier`. */
59
76
  willTrigger(identifier: symbol): boolean;
77
+ /** True where any eager action is registered, whatever identifier it stands under. */
78
+ get hasEager(): boolean;
79
+ /** Runs the actions registered under `ActionClass` and answers with what the outermost of them returned. */
60
80
  trigger<T extends FieldActionBase>(ActionClass: (abstract new (...args: any[]) => T) & {
61
81
  classIdentifier: symbol;
62
82
  }, field: FieldBase, ...params: any[]): any;
63
- /**
64
- * Runs the chain registered under one identifier and nothing else. A caller that has already run the eager
65
- * pass - a transaction runs it at the write, so that the validators have decided before it commits - reaches
66
- * the handlers through here, so the eager actions are not run a second time at the announcement.
67
- */
68
- triggerChain(identifier: symbol, field: FieldBase, ...params: any[]): any;
69
- triggerEager(field: FieldBase, ...params: any[]): any;
83
+ /** Runs the eager actions of every identifier, each group on its own. */
84
+ triggerEager(field: FieldBase, ...params: any[]): void;
85
+ /** Runs the eager actions registered under `identifier` and nothing else. */
86
+ triggerEagerFor(identifier: symbol, field: FieldBase, ...params: any[]): any;
70
87
  /** the validators registered in this map, in registration order */
71
88
  get validators(): Validator[];
72
89
  clone(): ActionsMap;
@@ -77,11 +94,15 @@ export declare class ActionsMap extends Map<symbol, FieldActionExecute> {
77
94
  */
78
95
  bindTo(owner: FieldBase): void;
79
96
  /**
80
- * A copy of this map carrying everything but the validators. It only leaves them out: releasing what a
81
- * validator installed elsewhere is the caller's to do, and only once the transaction that dropped them has
82
- * committed, because a rollback puts this map back with its validators in it.
97
+ * Walks `chain` from the end backwards, handing each action a `supr` that continues at the one before it. The
98
+ * closures exist for the length of the run and only as deep as the run actually goes, so a chain nobody walks to
99
+ * the bottom costs nothing for the part left unreached.
83
100
  */
84
- cloneWithoutValidators(): ActionsMap;
101
+ private step;
102
+ /** Walks a chain, answering null where there is none. An abort ends the run and is not an error to the caller. */
103
+ private run;
104
+ private insert;
105
+ private remove;
85
106
  }
86
107
 
87
108
  export declare interface ActionValue {
@@ -175,6 +196,7 @@ export declare class ConditionalStatementAction extends ValueChangedAction {
175
196
  static get classIdentifier(): symbol;
176
197
  get eager(): boolean;
177
198
  boundToBinding(binding: FieldBase): void;
199
+ unregisterFrom(binding: FieldBase): void;
178
200
  /**
179
201
  * The elements of `scope` this action controls: what each declaration it serves names within that record, and of
180
202
  * those the ones that took the action on. A row of a list that never took it on is not one this action drives.
@@ -357,8 +379,10 @@ export declare abstract class FieldActionBase {
357
379
  */
358
380
  boundToBinding(binding: FieldBase): void;
359
381
  /**
360
- * Announces that `binding` no longer holds this action. It names one element rather than the action as a whole,
361
- * because the instance goes on serving every other element it was registered on.
382
+ * Announces that `binding` no longer holds this action, and takes back what running it left there. It names one
383
+ * element rather than the action as a whole, because the instance goes on serving every other element it was
384
+ * registered on. It runs inside the operation that drops the registration, so an operation that unwinds puts the
385
+ * registration and what this took back both back.
362
386
  */
363
387
  unregisterFrom(binding: FieldBase): void;
364
388
  }
@@ -664,6 +688,25 @@ export declare abstract class FieldBase<T = any, X extends object = {}> {
664
688
  */
665
689
  protected registerInitialActions(actions: FieldActionBase[]): void;
666
690
  registerAction(action: FieldActionBase): this;
691
+ /**
692
+ * Registers `action` so that `before` wraps it: `before` reaches it through the `supr` it is handed, instead of
693
+ * ending the run there. It is how an action is added to a chain someone else built and still sits inside a
694
+ * handler already registered, which registration order alone cannot arrange. `before` has to be registered on
695
+ * this element under the same identifier.
696
+ */
697
+ registerActionBefore(action: FieldActionBase, before: FieldActionBase): this;
698
+ /**
699
+ * Drops `action` from this element and answers whether it held it. The instance goes on serving every other
700
+ * element it was registered on: what is dropped is this element's registration, not the action. A validator
701
+ * withdraws the errors it put on this element as it goes, so the verdict the element reports is the one the
702
+ * validators it still holds reach.
703
+ */
704
+ unregisterAction(action: FieldActionBase): boolean;
705
+ /**
706
+ * Records that `action` is now registered on this element, and that a rollback has to take that back. The
707
+ * registration is not one of the state slots the snapshot covers, so it hands its own undo in.
708
+ */
709
+ private registered;
667
710
  triggerAction<T2 extends FieldActionBase>(actionClass: (abstract new (...args: any[]) => T2) & {
668
711
  classIdentifier: symbol;
669
712
  }, ...params: any[]): any;
@@ -1100,8 +1143,6 @@ export declare class Statement {
1100
1143
 
1101
1144
  declare class Transaction {
1102
1145
  private readonly participants;
1103
- /** work that stands only where the transaction commits; a rollback simply never does it */
1104
- private readonly deferred;
1105
1146
  /** what a rollback has to put back beyond the state slots, newest last */
1106
1147
  private readonly undo;
1107
1148
  /** true once the transaction has been unwound, which is what tells a run started inside it to say nothing */
@@ -1130,12 +1171,6 @@ declare class Transaction {
1130
1171
  recordStructural(element: FieldBase, event: TxStructuralEvent): void;
1131
1172
  /** True where the commit still owes this element a value announcement. */
1132
1173
  willAnnounceValue(element: FieldBase): boolean;
1133
- /**
1134
- * Registers work the commit does once everything has been announced. It is for what a rollback could not take
1135
- * back: releasing a listener, dropping a registration. Held until the commit, it is simply never done where the
1136
- * transaction unwinds instead.
1137
- */
1138
- whenCommitted(work: () => void): void;
1139
1174
  /**
1140
1175
  * Registers what a rollback has to put back beyond the element's state slots. The snapshot covers the slots,
1141
1176
  * which is everything an ordinary write touches; an operation that replaces something else the element carries
@@ -1310,6 +1345,12 @@ export declare class Validator<T = any> extends ValueChangedAction {
1310
1345
  private claim;
1311
1346
  static get classIdentifier(): symbol;
1312
1347
  get eager(): boolean;
1348
+ /**
1349
+ * Takes this validator off `field`: the errors it put there are withdrawn and the verdict is re-formed over what
1350
+ * the validators the field still holds have to say. Withdrawing them is what keeps a field from staying invalid
1351
+ * on an error no validator is left to take back.
1352
+ */
1353
+ unregisterFrom(field: FieldBase): void;
1313
1354
  /**
1314
1355
  * What this validator remembers about one of the fields it validates. One instance may be registered on several
1315
1356
  * fields - every row of a list carries the instances the item template carries - so each field has a record of
package/package.json CHANGED
@@ -1,25 +1,18 @@
1
1
  {
2
2
  "name": "@dynamicforms/vue-forms",
3
3
  "private": false,
4
- "version": "0.11.0",
4
+ "version": "0.12.0",
5
5
  "type": "module",
6
6
  "description": "A lightweight Vue.js library for form state management with built-in validation, conditional logic, nested structures, and a rich event system. UI-agnostic and TypeScript-first.",
7
7
  "author": "Jure Erznožnik",
8
8
  "files": [
9
9
  "dist/*"
10
10
  ],
11
- "main": "dist/dynamicforms-vue-forms.umd.cjs",
12
11
  "types": "./dist/index.d.ts",
13
12
  "exports": {
14
13
  ".": {
15
- "import": {
16
- "types": "./dist/index.d.ts",
17
- "default": "./dist/dynamicforms-vue-forms.js"
18
- },
19
- "require": {
20
- "types": "./dist/index.d.cts",
21
- "default": "./dist/dynamicforms-vue-forms.umd.cjs"
22
- }
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/dynamicforms-vue-forms.js"
23
16
  },
24
17
  "./style.css": "./dist/dynamicforms-vue-forms.css",
25
18
  "./package.json": "./package.json"
@@ -28,7 +21,7 @@
28
21
  "docs"
29
22
  ],
30
23
  "scripts": {
31
- "build": "vite build && node -e \"require('fs').copyFileSync('dist/index.d.ts', 'dist/index.d.cts')\"",
24
+ "build": "vite build",
32
25
  "prepack": "npm run build",
33
26
  "test": "vitest run --coverage",
34
27
  "lint": "eslint src --fix && vue-tsc --noEmit",
@@ -59,14 +52,13 @@
59
52
  "url": "https://github.com/dynamicforms/vue-forms/issues"
60
53
  },
61
54
  "engines": {
62
- "node": ">=18"
55
+ "node": ">=22"
63
56
  },
64
57
  "dependencies": {
65
- "lodash": "^4.17.21",
66
58
  "lodash-es": "^4.17.21"
67
59
  },
68
60
  "peerDependencies": {
69
- "vue": "^3.4"
61
+ "vue": "^3.5.2"
70
62
  },
71
63
  "devDependencies": {
72
64
  "@types/lodash-es": "^4.17.12",
package/readme.md CHANGED
@@ -18,7 +18,7 @@ mechanism applies at every level of a nested form.
18
18
  - **Fields that react to each other**: Conditional visibility, enablement and values are declared as statements over other fields, and an action pipeline lets a handler intercept, transform or abort an event.
19
19
  - **Reactive & Type-Safe**: Every member of a field, group or list is a tracked read, and a group's value type is inferred from the fields it holds, nested structures included.
20
20
  - **Structural serialization**: A group's value is the shape of its fields, and `Group.createFromFormData()` turns a plain object back into a form.
21
- - **Lightweight**: `vue` (^3.4) is the only peer dependency, and `lodash` and `lodash-es` — one per build — the only runtime ones.
21
+ - **Lightweight**: `vue` (^3.5.2) is the only peer dependency and `lodash-es` the only runtime one.
22
22
 
23
23
  ## Features
24
24
 
@@ -30,8 +30,7 @@ mechanism applies at every level of a nested form.
30
30
  - **Transactional**: every mutating operation is atomic — events are announced once, over the net change, and a
31
31
  handler that throws leaves the form exactly as it was
32
32
  - **TypeScript support**: Full type definitions for excellent developer experience
33
- - **Lightweight**: `vue` (^3.4) is the only peer dependency; the runtime dependencies are `lodash` and `lodash-es`,
34
- one for each of the two builds
33
+ - **Lightweight**: `vue` (^3.5.2) is the only peer dependency and `lodash-es` the only runtime one
35
34
  - **Field types**: Core field types (Field, Action, Group, List) to represent any data structure
36
35
  - **Validation**: Comprehensive validation system with built-in validators and extensible error handling
37
36
  - **Conditional logic**: Dynamic form behavior based on field values and conditions
@@ -43,10 +42,10 @@ mechanism applies at every level of a nested form.
43
42
  npm install @dynamicforms/vue-forms
44
43
  ```
45
44
 
46
- The package ships two builds of the same source: an ESM build that imports `lodash-es` and a CJS/UMD build that
47
- requires `lodash`. Both lodash packages are declared as dependencies and install with the package, so an `import` and
48
- a `require()` both resolve without further setup. Node 18 or newer is required, and `vue` (^3.4) is the only peer
49
- dependency. Type definitions ship for both entry points; the stylesheet is `@dynamicforms/vue-forms/style.css`.
45
+ The package is ESM-only: it ships one build, which imports `lodash-es`, its only runtime dependency. Node 22 or newer
46
+ is required, and `vue` (^3.5.2) is the only peer dependency. A CommonJS consumer reaches it through `require()` of an
47
+ ES module, which Node supports. Type definitions ship with the build; the stylesheet is
48
+ `@dynamicforms/vue-forms/style.css`.
50
49
 
51
50
  ## Setup
52
51
 
@@ -1,3 +0,0 @@
1
- (function(o,u){typeof exports=="object"&&typeof module!="undefined"?u(exports,require("lodash"),require("vue")):typeof define=="function"&&define.amd?define(["exports","lodash","vue"],u):(o=typeof globalThis!="undefined"?globalThis:o||self,u(o.DynamicFormsVueForms={},o._,o.Vue))})(this,(function(o,u,c){"use strict";var Fe=Object.defineProperty,Pe=Object.defineProperties;var Ne=Object.getOwnPropertyDescriptors;var tt=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Xt=o=>{throw TypeError(o)};var mt=(o,u,c)=>u in o?Fe(o,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):o[u]=c,V=(o,u)=>{for(var c in u||(u={}))Ht.call(u,c)&&mt(o,c,u[c]);if(tt)for(var c of tt(u))Qt.call(u,c)&&mt(o,c,u[c]);return o},_=(o,u)=>Pe(o,Ne(u));var H=(o,u)=>{var c={};for(var v in o)Ht.call(o,v)&&u.indexOf(v)<0&&(c[v]=o[v]);if(o!=null&&tt)for(var v of tt(o))u.indexOf(v)<0&&Qt.call(o,v)&&(c[v]=o[v]);return c};var p=(o,u,c)=>mt(o,typeof u!="symbol"?u+"":u,c),Gt=(o,u,c)=>u.has(o)||Xt("Cannot "+c);var h=(o,u,c)=>(Gt(o,u,"read from private field"),c?c.call(o):u.get(o)),bt=(o,u,c)=>u.has(o)?Xt("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(o):u.set(o,c),vt=(o,u,c,v)=>(Gt(o,u,"write to private field"),v?v.call(o,c):u.set(o,c),c);var Yt=(o,u,c)=>new Promise((v,U)=>{var Q=S=>{try{y(c.next(S))}catch(x){U(x)}},T=S=>{try{y(c.throw(S))}catch(x){U(x)}},y=S=>S.done?v(S.value):Promise.resolve(S.value).then(Q,T);y((c=c.apply(o,u)).next())});var g,b;var v=(r=>(r[r.SUPPRESS=1]="SUPPRESS",r[r.HIDDEN=5]="HIDDEN",r[r.INVISIBLE=8]="INVISIBLE",r[r.FULL=10]="FULL",r))(v||{});const U=10,Q=new Set(Object.values(v).filter(r=>typeof r=="number"));(r=>{function i(s){return s.toUpperCase()==="SUPPRESS"?1:s.toUpperCase()==="HIDDEN"?5:s.toUpperCase()==="INVISIBLE"?8:U}r.fromString=i;function t(s){const n=typeof s=="number"?s:r.fromString(s);return Q.has(n)?n:U}r.fromAny=t;function e(s){const n=typeof s=="number"?s:r.fromString(s);return Q.has(n)}r.isDefined=e})(v||(v={})),Object.freeze(v);const T=v;class y{constructor(i){p(this,"executorFn");p(this,"states",new WeakMap);this.executorFn=i}static get classIdentifier(){throw new Error("classIdentifier must be declared")}get classIdentifier(){return this.constructor.classIdentifier}state(i,t){return this.states.has(i)||this.states.set(i,t()),this.states.get(i)}execute(i,t,...e){return this.executorFn(i,t,...e)}get eager(){return!1}boundToBinding(i){}unregisterFrom(i){}}class S extends Error{}const x=Symbol("ValueChangedAction");class N extends y{constructor(i){super(i)}static get classIdentifier(){return x}execute(i,t,e,s){return super.execute(i,t,e,s)}}const X=Symbol("Transaction.capture"),Vt=Symbol("Transaction.restore"),wt=Symbol("Transaction.announceValue"),yt=Symbol("Transaction.settleValidity");function ke(r){return r}function Ct(r){let i=0,t=r.parent;for(;t;)i++,t=t.parent;return i}class Jt{constructor(){p(this,"participants",new Map);p(this,"deferred",[]);p(this,"undo",[]);p(this,"unwound",!1);p(this,"passDepth",-1);p(this,"restartPass",!1)}get rolledBack(){return this.unwound}participant(i){let t=this.participants.get(i);return t||(t={element:i,valueDirty:!1,forceValue:!1,validityDirty:!1},this.participants.set(i,t)),t}touch(i){const t=this.participant(i);t.snapshot||(t.snapshot=i[X]())}markValueChanged(i,t){const e=this.participant(i);e.valueDirty=!0,t&&(e.forceValue=!0),this.noteDepth(i)}markValidityDirty(i){this.participant(i).validityDirty=!0,this.noteDepth(i)}recordStructural(i,t){var s;const e=this.participant(i);((s=e.structural)!=null?s:e.structural=[]).push(t),this.noteDepth(i)}willAnnounceValue(i){var t,e;return(e=(t=this.participants.get(i))==null?void 0:t.valueDirty)!=null?e:!1}whenCommitted(i){this.deferred.push(i)}whenRolledBack(i){this.undo.push(i)}noteDepth(i){this.passDepth<0||Ct(i)>=this.passDepth&&(this.restartPass=!0)}rollback(){this.unwound=!0,[...this.participants.values()].reverse().forEach(t=>{t.snapshot&&t.element[Vt](t.snapshot)}),this.participants.clear();for(let t=this.undo.length-1;t>=0;t--)this.undo[t]();this.undo.length=0,this.deferred.length=0}commit(){for(;!(!this.announceValues()&&!this.settleValidity()););this.deferred.splice(0).forEach(t=>t())}buckets(i){const t=[];return this.participants.forEach(e=>{var n;if(!i(e))return;const s=Ct(e.element);((n=t[s])!=null?n:t[s]=[]).push(e)}),t}pass(i,t){const e=this.buckets(i);if(!e.length)return!1;for(let s=e.length-1;s>=0;s--){const n=e[s];if(n){this.passDepth=s,this.restartPass=!1;try{for(let a=0;a<n.length;a++){if(this.restartPass)return!0;const l=n[a];i(l)&&t(l)}}finally{this.passDepth=-1}if(this.restartPass)return!0}}return!0}announceValues(){return this.pass(i=>i.valueDirty||i.structural!==void 0,i=>{const{structural:t}=i,e=i.valueDirty,s=i.forceValue;i.structural=void 0,i.valueDirty=!1,i.forceValue=!1,i.element[wt](this,e,s,t)})}settleValidity(){return this.pass(i=>i.validityDirty,i=>{i.validityDirty=!1,i.element[yt](this)})}}let k,et;function Et(){return k}class St{}class Kt{constructor(){p(this,"open",!0)}rollback(){throw this.open?new St:new TypeError("this transaction handle is spent: the transaction that handed it out has closed. A handle is only usable inside the call that received it.")}close(){this.open=!1}}function At(r){if(r!=null&&typeof r.then=="function")throw new TypeError("a transaction may not be asynchronous: the callback returned a thenable. Do the awaiting outside and open a transaction for each synchronous part.")}function G(r){if(k){const e=r(et);return At(e),e}const i=new Jt,t=new Kt;k=i,et=t;try{const e=r(t);return At(e),i.commit(),e}catch(e){if(i.rollback(),e instanceof St)return;throw e}finally{k=void 0,et=void 0,t.close()}}function m(r){return k?r(k):G(()=>r(k))}const It={useMarkdownInValidators:!0};function Zt(){return It}function te(r){Object.assign(It,r)}const ee={install(r,i){i&&te(i)}};class D extends String{constructor(t,e,s){super(t);p(this,"plugins");p(this,"options");this.plugins=s,this.options=e}}function Y(r){const i=c.unref(r);return typeof i=="object"&&"componentName"in i}function q(r){return typeof c.unref(r)=="function"}class J{get componentName(){return"Comment"}get componentBindings(){return{}}get componentBody(){return""}get extraClasses(){return""}}class _t extends J{constructor(t,e=""){super();p(this,"text");p(this,"classes");this.text=t,this.classes=e}get componentName(){return"template"}get componentBody(){return this.text}get extraClasses(){return this.classes}}class E extends J{constructor(t,e=""){super();p(this,"classes");p(this,"text");p(this,"textType");this.classes=e,this.text=t,this.textType=c.computed(()=>this.getTextType)}get resolvedText(){const t=c.unref(this.text);return q(t)?t():t}get getTextType(){const t=this.resolvedText;return t?t instanceof D?"md":Y(t)?"component":"string":"string"}get componentName(){switch(c.unref(this.textType)){case"string":return"template";case"md":return"vue-markdown";case"component":return this.resolvedText.componentName;default:return"template"}}get componentBindings(){switch(c.unref(this.textType)){case"string":return{};case"md":{const t=this.resolvedText;return{source:t.toString(),options:t.options,plugins:t.plugins}}case"component":return this.resolvedText.componentProps||{};default:return{}}}get componentBody(){switch(c.unref(this.textType)){case"string":return this.resolvedText;case"component":return this.resolvedText.componentVHtml||"";default:return""}}get extraClasses(){return this.classes}}class Tt extends E{}function A(r){return Zt().useMarkdownInValidators?new D(r):r.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
- `)}const ie=Symbol("Validator"),se=()=>A("Validation could not be completed");class C extends N{constructor(t){super((s,n,a,l)=>{const d=this.bindingState(s),f=++d.run,F=s.validationEpoch,gt=Et(),qt=()=>d.run===f&&s.validationEpoch===F&&!(gt!=null&&gt.rolledBack),ft=t(a,l,s)||[],pt=P=>G(()=>{var Wt;const Z=(Wt=P==null?void 0:P.map(M=>this.claim(M)))!=null?Wt:[];for(let M=s.errors.length-1;M>=0;M--){const $t=s.errors[M];if($t.source===this.source){const zt=Z.findIndex(je=>u.isEqual(je,$t));zt>=0?Z.splice(zt,1):s.errors.splice(M,1)}}Z.length>0&&s.errors.push(...Z),s.validate()});return ft instanceof Promise?(s.beginValidating(),ft.then(P=>{qt()&&pt(P)},P=>{qt()&&(pt([new E(se())]),console.error("Validation failed",P))}).finally(()=>s.endValidating()).catch(P=>console.error("Validation failed",P))):pt(ft),n(s,a,l)});p(this,"source");this.source=Symbol(this.constructor.name)}claim(t){const e=t.source;if(e===this.source)return t;const s={value:this.source,enumerable:!1,configurable:!1};if(e===void 0)return Object.defineProperty(t,"source",s),t;const n=Object.getOwnPropertyDescriptors(t);return Object.create(Object.getPrototypeOf(t),_(V({},n),{source:s}))}static get classIdentifier(){return ie}get eager(){return!0}bindingState(t){return this.state(t,()=>this.newBindingState())}newBindingState(){return{run:0}}replacePlaceholdersFunction(t,e){return()=>{let s=c.unref(t);for(;q(s);)s=c.unref(this.replacePlaceholders(s(),e));return s}}replacePlaceholders(t,e){if(q(t))return this.replacePlaceholdersFunction(t,e);if(Y(t))return t;if(c.isRef(t))return this.replacePlaceholdersFunction(()=>c.unref(t),e);let s=c.unref(t);return Object.keys(e).forEach(n=>{s=s.replaceAll(`{${n}}`,e[n])}),t instanceof D?new D(s.toString(),t.options,t.plugins):s}}class L extends Map{constructor(){super(...arguments);p(this,"eagerActions",new Set);p(this,"registeredActions",[])}register(t){if(!(t instanceof y))throw new Error("Invalid action type");this.registeredActions.push(t);const e=t.classIdentifier,s=this.get(e)||(()=>null);function n(a,...l){return t.execute(a,s,...l)}this.set(e,n),t.eager&&this.eagerActions.add(t.classIdentifier)}willTrigger(t){return this.has(t)?!0:t===x&&this.eagerActions.size>0}trigger(t,e,...s){const n=t.classIdentifier;return n===x&&this.triggerEager(e,...s),this.triggerChain(n,e,...s)}triggerChain(t,e,...s){const n=this.get(t);try{if(n)return n(e,...s)}catch(a){if(!(a instanceof S))throw a}return null}triggerEager(t,...e){for(const s of this.eagerActions){const n=this.get(s);try{n&&n(t,...e)}catch(a){if(!(a instanceof S))throw a}}}get validators(){return this.registeredActions.filter(t=>t instanceof C)}clone(){const t=new L;return this.registeredActions.forEach(e=>t.register(e)),t}bindTo(t){this.registeredActions.forEach(e=>e.boundToBinding(t))}cloneWithoutValidators(){const t=new L;return this.registeredActions.forEach(e=>{e instanceof C||t.register(e)}),t}}function R(r){let i=r;for(;i.fieldName!==void 0&&i.parent;)i=i.parent;return i}function ne(r){const i=[];let t=r;for(;t.fieldName!==void 0&&t.parent;)i.unshift(t.fieldName),t=t.parent;return i}function it(r,i){var e,s;let t=i;for(const n of ne(r))if(t=(s=(e=t.field)==null?void 0:e.call(t,n))!=null?s:void 0,!t)break;return(t==null?void 0:t.declaration)===r?t:R(r)===R(i.declaration)?void 0:r}function xt(r,i){const t=it(r,i);if(!t)return[];if(t!==r)return[t];const e=i.bindingsOf(r);return e.length>0?e:[r]}function re(r,i){var e;let t=i.parent;for(;t;){const s=(e=t.field)==null?void 0:e.call(t,r);if(s)return s;t=t.parent}}const ae=Symbol("ConditionalStatementAction");class W extends N{constructor(t,e){super((n,a,l,d)=>(this.applyIn(R(n))||n.markRecordIncomplete(),a(n,l,d)));p(this,"statement");p(this,"conditionalExecutor");p(this,"declarations",new Set);p(this,"registrations",new WeakSet);this.statement=t,this.conditionalExecutor=e;const s=new N((n,a,...l)=>(this.applyFrom(n),a(n,...l)));t.collectFields().forEach(n=>n.registerAction(s))}static get classIdentifier(){return ae}get eager(){return!0}boundToBinding(t){this.declarations.add(t.declaration),this.registrations.add(t)}targetsIn(t){const e=[];return this.declarations.forEach(s=>xt(s,t).forEach(n=>{this.registrations.has(n)&&e.push(n)})),e}applyIn(t){const e=this.targetsIn(t);if(e.length===0)return!1;const s=this.state(t,()=>({lastResult:void 0})),n=this.statement.evaluate(t);if(n===s.lastResult)return!0;const a=s.lastResult;return s.lastResult=n,e.forEach(l=>this.conditionalExecutor(l,n,a)),!0}applyFrom(t){const e=new Set;this.targetsIn(R(t)).forEach(s=>e.add(R(s))),e.forEach(s=>this.applyIn(s))}}class Ot extends W{constructor(i){super(i,(t,e)=>{t.visibility=e?T.FULL:T.SUPPRESS})}}class jt extends W{constructor(i){super(i,(t,e)=>{t.enabled=e})}}class Ft extends W{constructor(i,t){super(i,(e,s)=>{s&&(e.value=t)})}}var $=(r=>(r[r.NOT=0]="NOT",r[r.OR=1]="OR",r[r.AND=2]="AND",r[r.XOR=3]="XOR",r[r.NAND=4]="NAND",r[r.NOR=5]="NOR",r[r.EQUALS=-1]="EQUALS",r[r.NOT_EQUALS=-2]="NOT_EQUALS",r[r.GT=-3]="GT",r[r.LT=-4]="LT",r[r.GE=-5]="GE",r[r.LE=-6]="LE",r[r.IN=-7]="IN",r[r.NOT_IN=-8]="NOT_IN",r[r.INCLUDES=-9]="INCLUDES",r[r.NOT_INCLUDES=-10]="NOT_INCLUDES",r))($||{});(r=>{function i(n){const a=n.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}`)}r.fromString=i;function t(n){const a=typeof n=="number"?n:r.fromString(n);if(Object.values(r).includes(a))return a;throw new Error(`Unrecognised operator ${n}`)}r.fromAny=t;function e(n){const a=typeof n=="number"?n:r.fromString(n);return Object.values(r).includes(a)}r.isDefined=e;function s(n){return n>=0}r.isLogicOperator=s})($||($={})),Object.freeze($);const w=$,oe=Symbol("EnabledChangingAction");class st extends y{constructor(i){super(i)}static get classIdentifier(){return oe}execute(i,t,e,s){return super.execute(i,t,e,s)}}const le=Symbol("EnabledChangedAction");class nt extends y{constructor(i){super(i)}static get classIdentifier(){return le}execute(i,t,e,s){return super.execute(i,t,e,s)}}const ce=Symbol("ValidChangedAction");class rt extends y{constructor(i){super(i)}static get classIdentifier(){return ce}execute(i,t,e,s){return super.execute(i,t,e,s)}}const ue=Symbol("VisibilityChangingAction");class at extends y{constructor(i){super(i)}static get classIdentifier(){return ue}execute(i,t,e,s){return super.execute(i,t,e,s)}}const he=Symbol("VisibilityChangedAction");class ot extends y{constructor(i){super(i)}static get classIdentifier(){return he}execute(i,t,e,s){return super.execute(i,t,e,s)}}const Pt=new WeakMap,Nt=new Set(["validators","actions"]);let lt=0;class O{constructor(i){bt(this,g);bt(this,b);vt(this,b,i),vt(this,g,c.reactive(i))}get __v_skip(){return!0}get __v_isReactive(){return!0}get state(){return h(this,g)}get raw(){return h(this,b)}rebind(i){return m(t=>{t.touch(this);const e=t.willAnnounceValue(this),s=h(this,b).announcedValue;this.resetTo(this.declaration,i),h(this,b).announcedValue=e?s:this.value}),this}get originalValue(){return h(this,g).originalValue}set originalValue(i){this.touchState(),h(this,g).originalValue=i}get extra(){return h(this,g).extra}setExtendedValues(i){this.touchState(),h(this,g).extra=Object.freeze(V(V({},h(this,b).extra),i))}extendedOf(i){const t=Object.create(null);return Object.entries(i).forEach(([e,s])=>{Nt.has(e)||(!(e in this)||Object.hasOwn(Object.prototype,e))&&(t[e]=s)}),t}assignParams(i){const t=this.extendedOf(i);Object.entries(i).forEach(([e,s])=>{Object.hasOwn(t,e)||Nt.has(e)||(this[e]=s)}),u.isEmpty(t)||this.setExtendedValues(t)}touchState(){var i;(i=Et())==null||i.touch(this)}[X](){return _(V({},h(this,b)),{errors:[...h(this,b).errors]})}[Vt](i){const t=h(this,b).validatingCount;Object.assign(h(this,g),i),h(this,g).validatingCount=t}get validating(){return h(this,g).validatingCount>0}beginValidating(){h(this,g).validatingCount++}endValidating(){h(this,g).validatingCount=Math.max(0,h(this,g).validatingCount-1)}get errors(){return this.touchState(),h(this,g).errors}set errors(i){this.touchState(),h(this,g).errors=i}get parent(){return h(this,g).parent}get fieldName(){return h(this,g).fieldName}get declaration(){var i;return(i=h(this,b).declaration)!=null?i:this}get members(){return[]}bindingsOf(i){const t=i.declaration,e=[],s=n=>{n.declaration===t&&e.push(n),n.members.forEach(s)};return s(this),e}markRecordIncomplete(){this._recordPending||(this._recordPending=!0,lt++)}completeRecords(i=this){lt!==0&&m(()=>{const t=e=>{e._recordPending&&(e._recordPending=!1,lt--,e.rerunEagerActions()),e.members.forEach(t)};t(i)})}rerunEagerActions(){m(i=>{var t;(t=this._actions)==null||t.triggerEager(this,this.value,this.value),i.markValidityDirty(this)})}get actions(){return this._actions||(this._actions=new L),this._actions}set actions(i){this._actions=i}get valueVersion(){return h(this,g).valueVersion}bumpValueVersion(){m(i=>{i.touch(this),h(this,g).valueVersion++;let t=this.parent;for(;t;)i.touch(t),h(t,g).valueVersion++,t=t.parent})}propagateValueChanged(i=!1){m(t=>{var e;t.markValueChanged(this,i),t.markValidityDirty(this),(e=this.parent)==null||e.notifyValueChanged()})}refreshPreviousValue(){}get countedValid(){return h(this,b).errors.length===0&&h(this,b).invalidChildren===0}takeChild(i,t){m(e=>{if(i.parent)throw new TypeError("This element already belongs to a container - pass a bind() of it");e.touch(i),h(i,g).fieldName=t,h(i,g).parent=this,this.adoptChild(i)})}adoptChild(i){m(t=>{t.touch(this),h(i,b).valid||h(this,b).invalidChildren++,t.markValidityDirty(this)})}releaseChild(i){m(t=>{t.touch(this),t.touch(i),h(i,b).valid||h(this,b).invalidChildren--,h(i,g).parent=void 0,t.markValidityDirty(this)})}resetTo(i,t){m(()=>{const e=t===void 0?i.value:t,s=this.errors.length>0;s&&(this.errors=[]),this.touched=!1;const n=this.enabled&&this.value!==e;this.value=e,this.originalValue=this.value,this.validate(!n&&s)})}resetChild(i,t,e){i.resetTo(t,e)}childValidityChanged(i){h(this,b).invalidChildren+=i?-1:1}get validRead(){let i=Pt.get(this);return i||(i=c.computed(()=>this.composeValid()),Pt.set(this,i)),i.value}composeValid(){return h(this,g).errors.length===0}get visibility(){return h(this,g).visibility}set visibility(i){m(t=>{var n,a;const e=h(this,g).visibility,s=(n=this._actions)==null?void 0:n.trigger(at,this,i,e);if(!T.isDefined(s!=null?s:i))throw new Error("visibility must be a DisplayMode constant");t.touch(this),h(this,g).visibility=T.fromAny(s!=null?s:i),(a=this._actions)==null||a.trigger(ot,this,h(this,g).visibility,e)})}get enabled(){return h(this,g).enabled}set enabled(i){m(t=>{var n,a;const e=h(this,g).enabled,s=(n=this._actions)==null?void 0:n.trigger(st,this,i,e);if(!u.isBoolean(s!=null?s:i))throw new Error("Enabled value must be boolean");t.touch(this),h(this,g).enabled=s!=null?s:i,h(this,g).enabled!==e&&this.bumpValueVersion(),(a=this._actions)==null||a.trigger(nt,this,h(this,g).enabled,e)})}get composesValue(){return!1}[wt](i,t,e,s){if(s==null||s.forEach(d=>{var f;return(f=this._actions)==null?void 0:f.trigger(d.actionClass,this,d.item,d.index)}),!t)return;const n=this._actions;if(this.composesValue&&!(n!=null&&n.willTrigger(x)))return;const a=this.value,l=h(this,b).announcedValue;!e&&(this.composesValue?u.isEqual(a,l):a===l)||(i.touch(this),h(this,b).announcedValue=a,this.composesValue?n==null||n.trigger(N,this,a,l):n==null||n.triggerChain(x,this,a,l))}[yt](i){var n;const t=h(this,b).valid,e=this.countedValid;if(e===t)return;i.touch(this),h(this,b).valid=e;const s=this.parent;s&&(i.touch(s),s.childValidityChanged(e),i.markValidityDirty(s)),(n=this._actions)==null||n.trigger(rt,this,e,t)}validate(i=!1){m(t=>{var e;i&&((e=this._actions)==null||e.triggerEager(this,this.value,this.value)),t.markValidityDirty(this)})}get valid(){return h(this,g).errors.length===0}get fullValue(){return this.value}get isChanged(){return!u.isEqual(this.value,this.originalValue)}boundFrom(i,t,e,s){h(this,b).declaration=i.declaration;const n=V(V({},i.extra),s&&this.extendedOf(s));u.isEmpty(n)||this.setExtendedValues(n);const a=i._actions;a&&(this._actions=a.clone(),this._actions.bindTo(this),this._actions.triggerEager(this,t,e))}registerInitialActions(i){i.forEach(t=>{this.actions.register(t),t.boundToBinding(this)})}registerAction(i){return m(t=>{t.willAnnounceValue(this)||this.refreshPreviousValue(),this.actions.register(i),i.boundToBinding(this),i.eager&&this.actions.trigger(Object.getPrototypeOf(i).constructor,this,this.value,this.originalValue)}),this}triggerAction(i,...t){return this._actions?this._actions.trigger(i,this,...t):null}get validationEpoch(){return h(this,g).validationEpoch}clearValidators(){m(i=>{if(i.touch(this),h(this,g).validationEpoch++,this._actions){const t=this._actions,e=t.validators;i.whenRolledBack(()=>{this._actions=t}),this.actions=t.cloneWithoutValidators(),i.whenCommitted(()=>e.forEach(s=>s.unregisterFrom(this)))}this.errors=[],this.validate()})}}g=new WeakMap,b=new WeakMap;function de(r,i){return r?!i:i}class j{constructor(i,t,e){p(this,"operand1");p(this,"operator");p(this,"operand2");this.operand1=i,this.operator=t,this.operand2=e}static valueOf(i,t){if(i instanceof j)return i.evaluate(t);if(i instanceof O){const e=t?it(i,t):i;return e?c.unref(e.value):void 0}return i}get operand1Value(){return j.valueOf(this.operand1)}get operand2Value(){return j.valueOf(this.operand2)}evaluate(i){var s,n;const t=j.valueOf(this.operand1,i),e=j.valueOf(this.operand2,i);switch(this.operator){case w.AND:return!!(t&&e);case w.OR:return!!(t||e);case w.NAND:return!(t&&e);case w.NOR:return!(t||e);case w.XOR:return de(!!t,!!e);case w.NOT:return!t;case w.EQUALS:return t==e;case w.NOT_EQUALS:return t!=e;case w.LT:return t<e;case w.LE:return t<=e;case w.GE:return t>=e;case w.GT:return t>e;case w.IN:return!!((s=e==null?void 0:e.includes)!=null&&s.call(e,t));case w.NOT_IN:return!((n=e==null?void 0:e.includes)!=null&&n.call(e,t));case w.INCLUDES:return u.isString(t)&&u.isString(e)&&t.indexOf(e)>=0;case w.NOT_INCLUDES:return!(u.isString(t)&&u.isString(e)&&t.indexOf(e)>=0);default:throw new Error(`Operator not implemented ${this.operator}`)}}collectFields(){const i=new Set;function t(e){e instanceof O?i.add(e):e instanceof j&&e.collectFields().forEach(n=>i.add(n))}return t(this.operand1),t(this.operand2),i}}const ge=Symbol("ExecuteAction");class ct extends y{constructor(i){super(i)}static get classIdentifier(){return ge}execute(i,t,e){return super.execute(i,t,e)}}const fe=Symbol("ListItemAddedAction");class K extends y{constructor(i){super(i)}static get classIdentifier(){return fe}execute(i,t,e,s){return super.execute(i,t,e,s)}}const pe=Symbol("ListItemRemovedAction");class ut extends y{constructor(i){super(i)}static get classIdentifier(){return pe}execute(i,t,e,s){return super.execute(i,t,e,s)}}const me=Object.freeze({});function kt(){return{originalValue:void 0,announcedValue:void 0,errors:[],visibility:T.FULL,enabled:!0,valueVersion:0,validatingCount:0,parent:void 0,fieldName:void 0,validationEpoch:0,declaration:void 0,extra:me,valid:!0,invalidChildren:0}}function be(){return _(V({},kt()),{value:void 0,touched:!1})}function Rt(){return _(V({},kt()),{announcedValue:null,cachedValue:null,cachedValueVersion:-1})}function ve(){return _(V({},Rt()),{rows:null})}class z extends O{get state(){return super.state}get raw(){return super.raw}get _value(){return this.state.value}set _value(i){this.state.value=i}constructor(i){super(be()),this.init(i)}init(i){m(()=>{var e;if(i){const t=i,{value:s,validators:n,actions:a}=t,l=H(t,["value","validators","actions"]);this.registerInitialActions([...n||[],...a||[]]),this.assignParams(l),this._value=s!==void 0?s:this.originalValue,this.originalValue===void 0&&(this.originalValue=this._value)}this.raw.announcedValue=this._value,(e=this._actions)==null||e.triggerEager(this,this.value,this.originalValue),this.validate()})}get value(){return this._value}set value(i){const t=this._value;!this.enabled||t===i||m(e=>{var s;e.touch(this),this._value=i,this.bumpValueVersion(),(s=this._actions)==null||s.triggerEager(this,i,t),this.propagateValueChanged()})}get touched(){return this.state.touched}set touched(i){this.touchState(),this.state.touched=i}bind(i,t){var n,a;const e=this.constructor,s=new e(_(V({value:i!==void 0?i:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{enabled:(n=t==null?void 0:t.enabled)!=null?n:this.enabled,visibility:(a=t==null?void 0:t.visibility)!=null?a:this.visibility}));return s.boundFrom(this,s.value,s.originalValue,t),s}}const Dt=new z({value:"EmptyField"}).registerAction(new N(()=>{console.warn("Working with EmptyField! This should not happen")})),Lt=new WeakMap;function ht(r,i){return(r==null?void 0:r.label)==null&&(r==null?void 0:r.icon)==null?i:r}class Bt extends z{init(i){m(()=>{var e;if(this._value={label:void 0,icon:void 0},i){const t=i,{value:s,originalValue:n,validators:a,actions:l}=t,d=H(t,["value","originalValue","validators","actions"]);this.registerInitialActions([...a||[],...l||[]]),this.assignParams(d);const f=ht(s,this._value),F=Object.freeze({label:n==null?void 0:n.label,icon:n==null?void 0:n.icon});this._value=ht(f,V({},F)),this.originalValue=ht(F,f)}this.raw.announcedValue=this._value,(e=this._actions)==null||e.triggerEager(this,this.value,this.originalValue),this.validate()})}valueWith(i,t){const e=V({},this.value);return t===void 0?delete e[i]:e[i]=t,e}get icon(){return this.value.icon}set icon(i){this.value.icon!==i&&(this.value=this.valueWith("icon",i))}get label(){return this.value.label}set label(i){this.value.label!==i&&(this.value=this.valueWith("label",i))}get busyRuns(){let i=Lt.get(this);return i||(i=c.ref(0),Lt.set(this,i)),i}get busy(){return this.busyRuns.value>0}execute(i){return Yt(this,null,function*(){const t=this.busyRuns;t.value++;try{return yield this.triggerAction(ct,i)}finally{t.value--}})}}const Mt=c.defineComponent({__name:"messages-widget",props:{message:{},classes:{}},setup(r){const i=r,t=c.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"]),s=()=>{if(typeof i.message=="string")return c.h("span",{class:i.classes},i.message);const n=[];return i.message.forEach(a=>{switch(a.componentName){case"template":n.push(c.h("div",{class:[i.classes,a.extraClasses]},a.componentBody));break;case"vue-markdown":if(typeof t=="string")console.warn("You are using markdown for messages-widget, but you haven't registered a vue-markdown component"),n.push(c.h("div",{class:[i.classes,a.extraClasses]},a.componentBindings.source));else{const l=a.componentBindings;n.push(c.h(t,{class:[i.classes,a.extraClasses,"df-messages-widget-markdown"],source:l.source,options:l.options,plugins:l.plugins}))}break;default:n.push(c.h(e.has(a.componentName.toLowerCase())?a.componentName:c.resolveComponent(a.componentName),V(V({class:[i.classes,a.extraClasses]},a.componentBindings),a.componentBody?{innerHTML:a.componentBody}:{})));break}}),n};return(n,a)=>(c.openBlock(),c.createBlock(s))}});class I extends O{constructor(t,e){super(Rt());p(this,"_fields");if(!I.isValidFields(t))throw new Error("Invalid fields object provided");this._fields=Object.create(null),m(()=>{var a;if(Object.entries(t).forEach(([l,d])=>this.addField(l,d)),e){const n=e,{value:l,validators:d,actions:f}=n,F=H(n,["value","validators","actions"]);this.registerInitialActions([...d||[],...f||[]]),this.assignParams(F),l!==void 0?this.assignMembers(l):this.originalValue!==void 0&&this.assignMembers(this.originalValue)}this.completeRecords();const s=this.value;this.originalValue===void 0&&(this.originalValue=I.baseline(s)),this.raw.announcedValue=s,(a=this._actions)==null||a.triggerEager(this,s,this.originalValue),this.validate()})}get state(){return super.state}get raw(){return super.raw}static baseline(t){return t==null?t:V({},t)}addField(t,e){if(Object.hasOwn(this._fields,t))throw new Error(`Field ${t} is already in this form`);this.takeChild(e,t),Object.defineProperty(this._fields,t,{get:()=>e,configurable:!1,enumerable:!0})}static isValidFields(t){function e(s){return s instanceof O}return typeof t=="object"&&t!==null&&Object.entries(t).every(([,s])=>e(s))}static createFromFormData(t){if(t instanceof O)throw new Error("data is already a Form structure, should be a simple object");return new I(t==null?{}:Object.fromEntries(Object.entries(t).map(([e,s])=>[e,new z({value:s})])))}field(t){var e;return(e=this._fields[t])!=null?e:null}get fields(){return this._fields}get members(){return Object.values(this._fields)}get value(){const t=this.valueVersion;if(this.raw.cachedValueVersion===t)return this.raw.cachedValue;const e=Object.create(null);Object.entries(this._fields).forEach(([n,a])=>{const l=a.value;(a.enabled||a instanceof I&&!u.isEmpty(l))&&(e[n]=l)});const s=u.isEmpty(e)?null:Object.freeze(V({},e));return this.raw.cachedValue=s,this.raw.cachedValueVersion=t,s}assignMembers(t){m(()=>{Object.entries(this._fields).forEach(([e,s])=>{(t==null||Object.hasOwn(t,e))&&(s.value=t==null?null:t[e])})})}set value(t){m(e=>{this.assignMembers(t),e.markValidityDirty(this)})}resetTo(t,e){const s=t;m(n=>{n.touch(this),this.errors.length&&(this.errors=[]),Object.entries(this._fields).forEach(([l,d])=>{var F;let f;e===null?f=null:e!==void 0&&Object.hasOwn(e,l)&&(f=e[l]),this.resetChild(d,(F=s.field(l))!=null?F:d,f)});const a=this.value;this.raw.announcedValue=a,this.originalValue=I.baseline(a),super.validate(!0)})}get touched(){return Object.values(this._fields).some(t=>t.touched)}set touched(t){m(()=>{Object.values(this._fields).forEach(e=>{e.touched=t})})}get fullValue(){const t=Object.create(null);return Object.entries(this._fields).forEach(([e,s])=>{t[e]=s.fullValue}),V({},t)}notifyValueChanged(){this.propagateValueChanged()}get composesValue(){return!0}refreshPreviousValue(){this.raw.announcedValue=this.value}get valid(){return this.validRead}composeValid(){return this.state.errors.length===0&&Object.values(this._fields).every(t=>t.valid)}validate(t=!1){m(()=>{t&&Object.values(this._fields).forEach(e=>e.validate(!0)),super.validate(t)})}bind(t,e){var a,l;const s=Object.create(null);Object.entries(this._fields).forEach(([d,f])=>{s[d]=f.bind()});const n=new I(s,_(V({value:t!==void 0?t:this.value},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(a=e==null?void 0:e.enabled)!=null?a:this.enabled,visibility:(l=e==null?void 0:e.visibility)!=null?l:this.visibility}));return n.boundFrom(this,n.raw.announcedValue,n.originalValue,e),n}rebind(t){return super.rebind(t)}}class B extends O{constructor(t,e){super(ve());p(this,"_itemTemplate");this._itemTemplate=t,m(()=>{var n;if(e){const s=e,{value:a,validators:l,actions:d}=s,f=H(s,["value","validators","actions"]);this.registerInitialActions([...l||[],...d||[]]),this.assignParams(f),a!=null&&this.setValueInternal(a)}this.originalValue===void 0&&(this.originalValue=B.baseline(this.value)),this.raw.announcedValue=this.value,(n=this._actions)==null||n.triggerEager(this,this.value,this.originalValue),this.validate()})}get state(){return super.state}get raw(){return super.raw}[X](){const t=super[X]();return t.rows=this.raw.rows?[...this.raw.rows]:this.raw.rows,t}static baseline(t){return t==null?t:[...t]}processSetValueItem(t){let e;return t instanceof I?e=t:this._itemTemplate?e=this._itemTemplate.bind(t):e=I.createFromFormData(t),this.takeChild(e),this.completeRecords(e),e}createPaddingItem(){return this.processSetValueItem(this._itemTemplate?this._itemTemplate.bind():null)}setValueInternal(t){m(e=>{var s;if(e.touch(this),t==null)this.releaseRows(),this.state.rows=null;else if(Array.isArray(t)){const n=(s=this.state.rows)!=null?s:[],a=new Array(t.length);for(let l=0;l<t.length;l++){const d=t[l],f=n[l];f&&this._itemTemplate&&!(d instanceof I)?(this.resetChild(f,this._itemTemplate,d),a[l]=f):(f&&this.releaseChild(f),a[l]=this.processSetValueItem(d))}for(let l=t.length;l<n.length;l++)this.releaseChild(n[l]);this.state.rows=a}this.bumpValueVersion()})}get value(){var n;const t=this.valueVersion;if(this.raw.cachedValueVersion===t)return this.raw.cachedValue;const e=(n=this.state.rows)==null?void 0:n.map(a=>a.value),s=u.isEmpty(e)?null:Object.freeze(e);return this.raw.cachedValue=s,this.raw.cachedValueVersion=t,s}set value(t){m(()=>{this.setValueInternal(t),this.propagateValueChanged(!0)})}resetTo(t,e){m(s=>{s.touch(this),this.errors.length&&(this.errors=[]),this.setValueInternal(e===void 0?t.value:e);const n=this.value;this.raw.announcedValue=n,this.originalValue=B.baseline(n),super.validate(!0)})}get touched(){var t;return((t=this.state.rows)==null?void 0:t.some(e=>e.touched))||!1}set touched(t){m(()=>{var e;(e=this.state.rows)==null||e.forEach(s=>{s.touched=t})})}bind(t,e){var n,a,l,d;const s=new B((n=this._itemTemplate)==null?void 0:n.bind(),_(V({value:[...(a=t!==void 0?t:this.value)!=null?a:[]]},e&&"originalValue"in e?{originalValue:e.originalValue}:{}),{enabled:(l=e==null?void 0:e.enabled)!=null?l:this.enabled,visibility:(d=e==null?void 0:e.visibility)!=null?d:this.visibility}));return s.boundFrom(this,s.value,s.originalValue,e),s}notifyValueChanged(){this.propagateValueChanged()}get composesValue(){return!0}refreshPreviousValue(){this.raw.announcedValue=this.value}get valid(){return this.validRead}composeValid(){var t,e;return this.state.errors.length===0&&((e=(t=this.state.rows)==null?void 0:t.every(s=>s.valid))!=null?e:!0)}validate(t=!1){m(()=>{var e;t&&((e=this.state.rows)==null||e.forEach(s=>s.validate(!0))),super.validate(t)})}get members(){var t;return(t=this.raw.rows)!=null?t:[]}get(t){return this.state.rows!=null?this.state.rows[t]:void 0}push(t){var e,s;return this.insert(t,(s=(e=this.state.rows)==null?void 0:e.length)!=null?s:0)+1}pop(){var t,e;return this.remove(((e=(t=this.state.rows)==null?void 0:t.length)!=null?e:0)-1)}remove(t){let e;return m(s=>{var a;if(this.state.rows==null||t<0||this.state.rows.length<=t)return;s.touch(this);const n=(a=this.state.rows.splice(t,1))==null?void 0:a[0];n&&(this.releaseChild(n),this.bumpValueVersion(),e=n,s.recordStructural(this,{actionClass:ut,item:e,index:t}),this.propagateValueChanged(!0))}),e}insert(t,e){let s=0;return m(n=>{for(n.touch(this),this.state.rows==null&&(this.state.rows=[]),s=e<0?Math.max(this.state.rows.length+e,0):e;this.state.rows.length<s;){const l=this.createPaddingItem(),d=this.state.rows.push(l)-1;this.bumpValueVersion(),n.recordStructural(this,{actionClass:K,item:l,index:d})}const a=this.processSetValueItem(t);this.state.rows.splice(s,0,a),n.recordStructural(this,{actionClass:K,item:a,index:s}),this.bumpValueVersion(),this.propagateValueChanged(!0)}),s}releaseRows(){var t;(t=this.state.rows)==null||t.forEach(e=>this.releaseChild(e))}clear(){m(t=>{var s,n;const e=((n=(s=this.state.rows)==null?void 0:s.length)!=null?n:0)>0;t.touch(this),this.releaseRows(),this.state.rows=null,this.bumpValueVersion(),this.propagateValueChanged(e)})}}class Ve extends C{constructor(t,e,s){super((a,l,d)=>{this.comparisonState(d).oldValue=l;const f=this.resolve(d);return f?(this.listenOn(f),this.isValidComparison(c.unref(a),c.unref(f.value))?null:[new E(this.replacePlaceholders(s,{newValue:a,oldValue:l,field:d,otherField:f}))]):(d.markRecordIncomplete(),null)});p(this,"isValidComparison");p(this,"otherField");p(this,"registrations",new WeakSet);p(this,"listening",new WeakSet);p(this,"declarations",new Set);this.isValidComparison=e,this.otherField=t}resolve(t){var s;const e=this.otherField;return typeof e=="function"?(s=e(t))!=null?s:void 0:typeof e=="string"?re(e,t):it(e,R(t))}listenOn(t){this.listening.has(t)||this.listening.has(t.declaration)||(this.listening.add(t),t.registerAction(new N((e,s,n,a)=>{s(e,n,a);const l=R(e);this.declarations.forEach(d=>xt(d,l).forEach(f=>{this.registrations.has(f)&&this.execute(f,()=>null,f.value,this.comparisonState(f).oldValue)}))})))}boundToBinding(t){this.declarations.add(t.declaration),this.registrations.add(t)}comparisonState(t){return this.bindingState(t)}newBindingState(){return _(V({},super.newBindingState()),{oldValue:void 0})}unregisterFrom(t){this.registrations.delete(t)}}class we extends C{constructor(i,t){const e=t||A("Must be one of [**{allowedAsText}**]");let s=i.join(", ");s.length>60&&(s=u.truncate(s,{length:40,separator:", ",omission:`... (${i.length} items total)`}));const n=(a,l,d)=>i.includes(c.unref(a))?null:[new E(this.replacePlaceholders(e,{newValue:a,oldValue:l,field:d,allowedValues:i,allowedAsText:s}))];super(n)}}function ye(r){return r==null?0:u.isArray(r)||u.isString(r)?r.length:u.isObject(r)&&Object.getPrototypeOf(r)===Object.prototype?Object.keys(r).length:String(r).length}class Ce extends C{constructor(i){const t=i||A("Please enter a value"),e=(s,n,a)=>ye(c.unref(s))===0?[new E(this.replacePlaceholders(t,{newValue:s,oldValue:n,field:a}))]:null;super(e)}}class Ee extends C{constructor(i,t){const e=t||A("Value must be larger or equal to **{minValue}**"),s=(n,a,l)=>n<i||n===void 0?[new E(this.replacePlaceholders(e,{newValue:n,oldValue:a,field:l,minValue:i}))]:null;super(s)}}class Se extends C{constructor(i,t){const e=t||A("Value must be less than or equal to **{maxValue}**"),s=(n,a,l)=>n>i||n===void 0?[new E(this.replacePlaceholders(e,{newValue:n,oldValue:a,field:l,maxValue:i}))]:null;super(s)}}class Ae extends C{constructor(i,t,e){const s=e||A("Value must be between **{minValue}** and **{maxValue}**"),n=(a,l,d)=>a<i||a>t||a===void 0?[new E(this.replacePlaceholders(s,{newValue:a,oldValue:l,field:d,minValue:i,maxValue:t}))]:null;super(n)}}function dt(r){return r==null?0:u.isArray(r)||u.isString(r)?r.length:u.isObject(r)&&Object.getPrototypeOf(r)===Object.prototype?Object.keys(r).length:String(r).length}class Ie extends C{constructor(i,t){const e=t||A("Length must be larger or equal to **{minLength}**"),s=(n,a,l)=>dt(n)<i?[new E(this.replacePlaceholders(e,{newValue:n,oldValue:a,field:l,minLength:i}))]:null;super(s)}}class _e extends C{constructor(i,t){const e=t||A("Length must be less than or equal to **{maxLength}**"),s=(n,a,l)=>dt(n)>i?[new E(this.replacePlaceholders(e,{newValue:n,oldValue:a,field:l,maxLength:i}))]:null;super(s)}}class Te extends C{constructor(i,t,e){const s=e||A("Length must be between **{minLength}** and **{maxLength}**"),n=(a,l,d)=>{const f=dt(a);return f<i||f>t?[new E(this.replacePlaceholders(s,{newValue:a,oldValue:l,field:d,minLength:i,maxLength:t}))]:null};super(n)}}class xe extends C{constructor(i,t){const e=t||A('Value must match pattern "**{pattern}**"'),s=(n,a,l)=>i.test(String(c.unref(n)))?null:[new E(this.replacePlaceholders(e,{newValue:n,oldValue:a,field:l,pattern:i}))];super(s)}}const Ut=Object.freeze(Object.defineProperty({__proto__:null,CompareTo:Ve,InAllowedValues:we,LengthInRange:Te,MaxLength:_e,MaxValue:Se,MinLength:Ie,MinValue:Ee,Pattern:xe,Required:Ce,Validator:C,ValueInRange:Ae},Symbol.toStringTag,{value:"Module"})),Oe=Object.freeze(Object.defineProperty({__proto__:null,AbortEventHandlingException:S,Action:Bt,ActionsMap:L,ConditionalEnabledAction:jt,ConditionalStatementAction:W,ConditionalValueAction:Ft,ConditionalVisibilityAction:Ot,DisplayMode:T,EmptyField:Dt,EnabledChangedAction:nt,EnabledChangingAction:st,ExecuteAction:ct,Field:z,FieldActionBase:y,FieldBase:O,Group:I,List:B,ListItemAddedAction:K,ListItemRemovedAction:ut,MdString:D,MessagesWidget:Mt,Operator:w,RenderableValue:Tt,Statement:j,ValidChangedAction:rt,ValidationError:J,ValidationErrorRenderContent:E,ValidationErrorText:_t,Validator:C,Validators:Ut,ValueChangedAction:N,VisibilityChangedAction:ot,VisibilityChangingAction:at,buildErrorMessage:A,isCallableFunction:q,isSimpleComponentDef:Y,transaction:G},Symbol.toStringTag,{value:"Module"}));o.AbortEventHandlingException=S,o.Action=Bt,o.ActionsMap=L,o.ConditionalEnabledAction=jt,o.ConditionalStatementAction=W,o.ConditionalValueAction=Ft,o.ConditionalVisibilityAction=Ot,o.DisplayMode=T,o.EmptyField=Dt,o.EnabledChangedAction=nt,o.EnabledChangingAction=st,o.ExecuteAction=ct,o.Field=z,o.FieldActionBase=y,o.FieldBase=O,o.Group=I,o.List=B,o.ListItemAddedAction=K,o.ListItemRemovedAction=ut,o.MdString=D,o.MessagesWidget=Mt,o.Operator=w,o.RenderableValue=Tt,o.Statement=j,o.ValidChangedAction=rt,o.ValidationError=J,o.ValidationErrorRenderContent=E,o.ValidationErrorText=_t,o.Validator=C,o.Validators=Ut,o.ValueChangedAction=N,o.VisibilityChangedAction=ot,o.VisibilityChangingAction=at,o.buildErrorMessage=A,o.default=Oe,o.forms=ee,o.isCallableFunction=q,o.isSimpleComponentDef=Y,o.transaction=G,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
3
- //# sourceMappingURL=dynamicforms-vue-forms.umd.cjs.map