@dynamicforms/vue-forms 0.11.0 → 0.13.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/dynamicforms-vue-forms.js +1444 -1163
- package/dist/dynamicforms-vue-forms.js.map +1 -1
- package/dist/index.d.ts +312 -53
- package/package.json +6 -14
- package/readme.md +53 -32
- package/dist/dynamicforms-vue-forms.umd.cjs +0 -3
- package/dist/dynamicforms-vue-forms.umd.cjs.map +0 -1
- package/dist/index.d.cts +0 -1382
package/package.json
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamicforms/vue-forms",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.13.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
|
-
"
|
|
16
|
-
|
|
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
|
|
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": ">=
|
|
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.
|
|
61
|
+
"vue": "^3.5.2"
|
|
70
62
|
},
|
|
71
63
|
"devDependencies": {
|
|
72
64
|
"@types/lodash-es": "^4.17.12",
|
package/readme.md
CHANGED
|
@@ -18,24 +18,29 @@ 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.
|
|
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
|
|
|
25
|
-
- **UI-agnostic**:
|
|
25
|
+
- **UI-agnostic**: a logic layer for form state, validation and dynamic behaviour. Any Vue components render it,
|
|
26
|
+
your own included
|
|
27
|
+
- **Transactional**: every mutating operation is atomic — events are announced once, over the net change, and a
|
|
28
|
+
handler that throws leaves the form exactly as it was. `transaction()` makes several writes one operation, and
|
|
29
|
+
`tx.rollback()` withdraws one without an error
|
|
30
|
+
- **Lists that scale**: a `List` is meant to hold thousands of rows. Writing one field of one row costs that row
|
|
31
|
+
and the depth it sits at, a `push()` costs one row, and reading `value` or `valid` again costs nothing
|
|
32
|
+
- **Declared once, bound per record**: the `Group` handed to `new List(template)` is the declaration every row is
|
|
33
|
+
built from. One validator instance and one conditional rule serve every row, and each row answers for itself
|
|
26
34
|
- **Reactive**: every member of a field, group or list is a tracked read — assign a property directly, with no
|
|
27
35
|
`ref` to unwrap and no computed mirror to keep in sync
|
|
28
|
-
- **Nested structures**:
|
|
29
|
-
- **Event system**:
|
|
30
|
-
- **
|
|
31
|
-
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
34
|
-
|
|
35
|
-
- **
|
|
36
|
-
- **Validation**: Comprehensive validation system with built-in validators and extensible error handling
|
|
37
|
-
- **Conditional logic**: Dynamic form behavior based on field values and conditions
|
|
38
|
-
- **Display modes**: Control field visibility with different display modes (Full, Hidden, Invisible, Suppress)
|
|
36
|
+
- **Nested structures**: fields, groups and lists compose recursively, at every level
|
|
37
|
+
- **Event system**: every change travels through an action pipeline; a handler may pass it on, reshape it or stop it
|
|
38
|
+
- **Validation**: built-in validators, custom synchronous and asynchronous rules, cross-field comparisons, and
|
|
39
|
+
errors that carry a `code` and render as text, markdown or a component of your own
|
|
40
|
+
- **Conditional logic**: visibility, enablement and values declared as statements over other fields
|
|
41
|
+
- **Display modes**: control field visibility with different display modes (Full, Hidden, Invisible, Suppress)
|
|
42
|
+
- **TypeScript support**: full type definitions, and a group's value type inferred from the fields it holds
|
|
43
|
+
- **Lightweight**: `vue` (^3.5.2) is the only peer dependency and `lodash-es` the only runtime one
|
|
39
44
|
|
|
40
45
|
## Installation
|
|
41
46
|
|
|
@@ -43,10 +48,10 @@ mechanism applies at every level of a nested form.
|
|
|
43
48
|
npm install @dynamicforms/vue-forms
|
|
44
49
|
```
|
|
45
50
|
|
|
46
|
-
The package
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
The package is ESM-only: it ships one build, which imports `lodash-es`, its only runtime dependency. Node 22 or newer
|
|
52
|
+
is required, and `vue` (^3.5.2) is the only peer dependency. A CommonJS consumer reaches it through `require()` of an
|
|
53
|
+
ES module, which Node supports. Type definitions ship with the build; the stylesheet is
|
|
54
|
+
`@dynamicforms/vue-forms/style.css`.
|
|
50
55
|
|
|
51
56
|
## Setup
|
|
52
57
|
|
|
@@ -64,6 +69,10 @@ The import must be a named one — the default export is a namespace of the libr
|
|
|
64
69
|
(`MdString`). Rendering those requires a globally registered `vue-markdown` component; set the option to `false` if you
|
|
65
70
|
want plain text instead.
|
|
66
71
|
|
|
72
|
+
The configuration is module-global rather than per app, and `getConfig()`, `setConfig()` and the `FormsConfig` type
|
|
73
|
+
are exported beside the plugin, so the options can be read and written where there is no app to install a plugin
|
|
74
|
+
on.
|
|
75
|
+
|
|
67
76
|
## Basic Usage Example
|
|
68
77
|
|
|
69
78
|
Every form element is created with the constructor: `new Field({ ... })`, `new Action({ ... })`,
|
|
@@ -212,13 +221,22 @@ const validatedForm = new Group({
|
|
|
212
221
|
```
|
|
213
222
|
|
|
214
223
|
Validators run eagerly — a field is validated the moment it is created, so a form built from empty required fields is
|
|
215
|
-
invalid immediately. Use `field.touched` to decide when to show the errors in the UI.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
invalid immediately. Use `field.touched` to decide when to show the errors in the UI. `Required` trims a string
|
|
225
|
+
before it measures it, so a value of spaces alone is no value; `new Validators.Required({ trim: false })` keeps the
|
|
226
|
+
spaces where they are part of what the field holds.
|
|
227
|
+
|
|
228
|
+
Every error a built-in validator produces carries a `code` — `required`, `pattern`, `min-length`, … — so a program
|
|
229
|
+
reacting to one particular failure need not match message text that is translated and configurable.
|
|
230
|
+
|
|
231
|
+
A validation function may return a `Promise`. `field.validating` is `true` while such a run is pending — on the
|
|
232
|
+
field and on every container above it, so a form answers for the whole tree — and the verdict applied to the field
|
|
233
|
+
is always the one belonging to the newest run, so a slow check cannot overwrite a faster one started after it. The
|
|
234
|
+
function receives an `AbortSignal` as its fourth argument, which aborts the moment the run's verdict stops
|
|
235
|
+
counting, so the request behind it can be called off. `form.busy` is the same question with the `Action.execute()`
|
|
236
|
+
runs below it included — what a submit button binds to. A validator message given as a `Ref` or `computed` is
|
|
237
|
+
resolved when the message is rendered, so a translated message follows a locale switch without revalidating.
|
|
238
|
+
`field.clearValidators()` drops the validators, empties the errors and cancels whatever validation is still in
|
|
239
|
+
flight.
|
|
222
240
|
|
|
223
241
|
## Messages Widget Component
|
|
224
242
|
|
|
@@ -327,7 +345,8 @@ const contactsList = new List(contactTemplate);
|
|
|
327
345
|
contactsList.push({ name: 'John Doe', email: 'john@example.com', phone: '123-456-7890' });
|
|
328
346
|
contactsList.push({ name: 'Jane Doe', email: 'jane@example.com', phone: '987-654-3210' });
|
|
329
347
|
|
|
330
|
-
// Access list items: get()
|
|
348
|
+
// Access list items: items hands out the rows, get() answers undefined for an invalid index
|
|
349
|
+
console.log(contactsList.length); // 2
|
|
331
350
|
const firstContact = contactsList.get(0)!;
|
|
332
351
|
console.log(firstContact.fields.name.value); // 'John Doe'
|
|
333
352
|
|
|
@@ -338,8 +357,9 @@ firstContact.fields.email.value = 'john.doe@example.com';
|
|
|
338
357
|
contactsList.remove(1);
|
|
339
358
|
```
|
|
340
359
|
|
|
341
|
-
Every list mutation is tracked, so a `v-for` over `contactsList.
|
|
342
|
-
`remove()`, `pop()` and `clear()` without any extra wiring.
|
|
360
|
+
Every list mutation is tracked, so a `v-for` over `contactsList.items` re-renders on `push()`, `insert()`,
|
|
361
|
+
`remove()`, `pop()` and `clear()` without any extra wiring. `items` hands out a frozen array of the live rows,
|
|
362
|
+
rebuilt once per change of the set.
|
|
343
363
|
|
|
344
364
|
## TypeScript Support
|
|
345
365
|
|
|
@@ -389,10 +409,11 @@ const email: string = userForm.fields.email.value;
|
|
|
389
409
|
const age: number = userForm.fields.age.value;
|
|
390
410
|
const darkMode: boolean = userForm.fields.preferences.fields.darkMode.value;
|
|
391
411
|
|
|
392
|
-
// The serialized value is typed too, member by member
|
|
412
|
+
// The serialized value is typed too, member by member. Every member is optional, because a disabled field is
|
|
413
|
+
// left out of the object the group builds
|
|
393
414
|
const values = userForm.value!;
|
|
394
|
-
const emailFromValue: string = values.email;
|
|
395
|
-
const prefs: { darkMode
|
|
415
|
+
const emailFromValue: string | undefined = values.email;
|
|
416
|
+
const prefs: { darkMode?: boolean; notifications?: boolean } | null | undefined = values.preferences;
|
|
396
417
|
|
|
397
418
|
// Type safety prevents errors
|
|
398
419
|
// userForm.fields.age.value = 'not a number'; // Error: Type 'string' is not assignable to type 'number'
|
|
@@ -444,8 +465,8 @@ For more detailed documentation and examples, check out the [documentation](http
|
|
|
444
465
|
declarations, transactions, where validity comes from and how a `List` builds its rows.
|
|
445
466
|
|
|
446
467
|
Upgrading an existing project? The
|
|
447
|
-
[migration guide](https://docs.velis.si/dynamicforms/vue-forms/guide/migration) walks the journey from 0.6.1
|
|
448
|
-
|
|
468
|
+
[migration guide](https://docs.velis.si/dynamicforms/vue-forms/guide/migration) walks the journey from 0.6.1
|
|
469
|
+
onwards, silent breaks first, and keeps a section per release for a project crossing one.
|
|
449
470
|
|
|
450
471
|
## Conclusion
|
|
451
472
|
|
|
@@ -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&>.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
|