feature-form 0.0.13 → 0.0.15
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/LICENSE +1 -1
- package/README.md +21 -20
- package/dist/cjs/create-form.js +1 -1
- package/dist/cjs/form-field/create-form-field.js +1 -1
- package/dist/cjs/helper/from-validator.js +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/esm/create-form.js +1 -1
- package/dist/esm/form-field/create-form-field.js +1 -1
- package/dist/esm/helper/{from-validation-adapter.js → from-validator.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/types/create-form.d.ts +1 -1
- package/dist/types/create-form.d.ts.map +1 -1
- package/dist/types/helper/from-validator.d.ts +4 -0
- package/dist/types/helper/from-validator.d.ts.map +1 -0
- package/dist/types/helper/index.d.ts +1 -1
- package/dist/types/helper/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/features.d.ts +1 -1
- package/dist/types/types/features.d.ts.map +1 -1
- package/dist/types/types/form-field.d.ts +1 -1
- package/dist/types/types/form-field.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/cjs/helper/from-validation-adapter.js +0 -1
- package/dist/types/helper/from-validation-adapter.d.ts +0 -4
- package/dist/types/helper/from-validation-adapter.d.ts.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/
|
|
2
|
+
<img src="https://raw.githubusercontent.com/builder-group/monorepo/develop/packages/feature-form/.github/banner.svg" alt="feature-form banner">
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
5
|
<p align="left">
|
|
6
|
-
<a href="https://github.com/
|
|
7
|
-
<img src="https://img.shields.io/github/license/
|
|
6
|
+
<a href="https://github.com/builder-group/monorepo/blob/develop/LICENSE">
|
|
7
|
+
<img src="https://img.shields.io/github/license/builder-group/monorepo.svg?label=license&style=flat&colorA=293140&colorB=FDE200" alt="GitHub License"/>
|
|
8
8
|
</a>
|
|
9
9
|
<a href="https://www.npmjs.com/package/feature-form">
|
|
10
|
-
<img src="https://img.shields.io/bundlephobia/minzip/feature-form.svg?label=minzipped%20size&style=flat&colorA=293140&colorB=
|
|
10
|
+
<img src="https://img.shields.io/bundlephobia/minzip/feature-form.svg?label=minzipped%20size&style=flat&colorA=293140&colorB=FDE200" alt="NPM bundle minzipped size"/>
|
|
11
11
|
</a>
|
|
12
12
|
<a href="https://www.npmjs.com/package/feature-form">
|
|
13
|
-
<img src="https://img.shields.io/npm/dt/feature-form.svg?label=downloads&style=flat&colorA=293140&colorB=
|
|
13
|
+
<img src="https://img.shields.io/npm/dt/feature-form.svg?label=downloads&style=flat&colorA=293140&colorB=FDE200" alt="NPM total downloads"/>
|
|
14
14
|
</a>
|
|
15
|
-
<a href="https://
|
|
16
|
-
<img src="https://img.shields.io/discord/795291052897992724.svg?label=&logo=discord&logoColor=000000&color=293140&labelColor=
|
|
15
|
+
<a href="https://discord.gg/w4xE3bSjhQ">
|
|
16
|
+
<img src="https://img.shields.io/discord/795291052897992724.svg?label=&logo=discord&logoColor=000000&color=293140&labelColor=FDE200" alt="Join Discord"/>
|
|
17
17
|
</a>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
@@ -27,22 +27,23 @@
|
|
|
27
27
|
- **Typesafe**: Build with TypeScript for strong type safety
|
|
28
28
|
- **Standalone**: Zero external dependencies, ensuring ease of use in various environments
|
|
29
29
|
|
|
30
|
-
###
|
|
31
|
-
- [ReactJs Basic](https://codesandbox.io/p/sandbox/basic-c4gd3t)
|
|
30
|
+
### 📚 Examples
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
- [ReactJs Basic](https://github.com/builder-group/monorepo/tree/develop/examples/feature-form/react/basic) ([Code Sandbox](https://codesandbox.io/p/sandbox/basic-c4gd3t))
|
|
33
|
+
|
|
34
|
+
### 🌟 Motivation
|
|
34
35
|
|
|
35
36
|
Provide a typesafe, straightforward, and lightweight form library designed to be modular and extendable with features.
|
|
36
37
|
|
|
37
|
-
### Alternatives
|
|
38
|
+
### ⚖️ Alternatives
|
|
38
39
|
- [react-hook-form](https://github.com/react-hook-form/react-hook-form)
|
|
39
40
|
|
|
40
41
|
## 📖 Usage
|
|
41
42
|
|
|
42
43
|
```tsx
|
|
43
44
|
import { createForm } from 'feature-form';
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
45
|
+
import { zValidator } from 'validation-adapters/zod';
|
|
46
|
+
import { vValidator } from 'validation-adapters/valibot';
|
|
46
47
|
import { useForm } from 'feature-react/form';
|
|
47
48
|
import * as z from 'zod';
|
|
48
49
|
import * as v from 'valibot';
|
|
@@ -55,11 +56,11 @@ interface TFormData {
|
|
|
55
56
|
const $form = createForm<TFormData>({
|
|
56
57
|
fields: {
|
|
57
58
|
name: {
|
|
58
|
-
validator:
|
|
59
|
+
validator: zValidator(z.string().min(2).max(10)),
|
|
59
60
|
defaultValue: ''
|
|
60
61
|
},
|
|
61
62
|
email: {
|
|
62
|
-
validator:
|
|
63
|
+
validator: vValidator(v.pipe(v.string(), v.email())),
|
|
63
64
|
defaultValue: ''
|
|
64
65
|
}
|
|
65
66
|
},
|
|
@@ -88,21 +89,21 @@ export const MyFormComponent: React.FC = () => {
|
|
|
88
89
|
}
|
|
89
90
|
```
|
|
90
91
|
|
|
91
|
-
### Validators ([`validation-adapters`](https://github.com/
|
|
92
|
+
### Validators ([`validation-adapters`](https://github.com/builder-group/monorepo/tree/develop/packages/validation-adapters))
|
|
92
93
|
|
|
93
94
|
`feature-form` supports various validators such as [Zod](https://github.com/colinhacks/zod), [Yup](https://github.com/jquense/yup), [Valibot](https://github.com/fabian-hiller/valibot) and more.
|
|
94
95
|
|
|
95
96
|
```ts
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
97
|
+
import { zValidator } from 'validation-adapters/zod';
|
|
98
|
+
import { vValidator } from 'validation-adapters/valibot';
|
|
98
99
|
import * as z from 'zod';
|
|
99
100
|
import * as v from 'valibot';
|
|
100
101
|
|
|
101
|
-
const zodNameValidator =
|
|
102
|
+
const zodNameValidator = zValidator(
|
|
102
103
|
z.string().min(2).max(10).regex(/^([^0-9]*)$/)
|
|
103
104
|
);
|
|
104
105
|
|
|
105
|
-
const valibotNameValidator =
|
|
106
|
+
const valibotNameValidator = vValidator(
|
|
106
107
|
v.pipe(v.string(), v.minLength(2), v.maxLength(10), v.regex(/^([^0-9]*)$/))
|
|
107
108
|
);
|
|
108
109
|
```
|
package/dist/cjs/create-form.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=require("@
|
|
1
|
+
"use strict";var y=require("@blgc/utils"),p=require("./form-field/create-form-field.js");require("feature-state");var o=require("./types/form-field.js"),h=(g,S,r)=>new Promise((V,b)=>{var F=l=>{try{n(r.next(l))}catch(d){b(d)}},v=l=>{try{n(r.throw(l))}catch(d){b(d)}},n=l=>l.done?V(l.value):Promise.resolve(l.value).then(F,v);n((r=r.apply(g,S)).next())});function O(g){const{fields:S,collectErrorMode:r="firstError",disabled:V=!1,validateMode:b=y.bitwiseFlag(o.FormFieldValidateMode.OnSubmit),reValidateMode:F=y.bitwiseFlag(o.FormFieldReValidateMode.OnBlur),onValidSubmit:v,onInvalidSubmit:n,notifyOnStatusChange:l=!0}=g,d={_:null,_features:["base"],_config:{collectErrorMode:r,disabled:V},_validSubmitCallbacks:v!=null?[v]:[],_invalidSubmitCallbacks:n!=null?[n]:[],fields:Object.fromEntries(Object.entries(S).map(([e,t])=>{var i,c,m,f;return[e,p.createFormField(t.defaultValue,{key:e,validator:t.validator,collectErrorMode:(i=t.collectErrorMode)!=null?i:r,validateMode:(c=t.validateMode)!=null?c:b,reValidateMode:(m=t.reValidateMode)!=null?m:F,editable:(f=t.editable)!=null?f:!0,notifyOnStatusChange:l})]})),isValid:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,_revalidate(e=!1){return h(this,null,function*(){const t=Object.values(this.fields);return e||(this.isValidating=!0,yield Promise.all(t.map(i=>i.validate())),this.isValidating=!1),this.isValid=t.every(i=>i.isValid()),this.isValid})},submit(){return h(this,arguments,function*(e={}){const{additionalData:t,assignToInitial:i=!1,onInvalidSubmit:c,onValidSubmit:m}=e;this.isSubmitting=!0;const f=[];for(const a of Object.values(this.fields))(a.isSubmitted&&a._config.reValidateMode.has(o.FormFieldReValidateMode.OnSubmit)||!a.isSubmitted&&a._config.validateMode.has(o.FormFieldValidateMode.OnSubmit))&&f.push(a.validate()),this.isSubmitting=!0;yield Promise.all(f);const u=this.getData();if(u!=null){const a=this._validSubmitCallbacks.map(s=>s(u,t));typeof m=="function"&&a.push(m(u,t)),yield Promise.all(a)}else{const a=this.getErrors(),s=this._invalidSubmitCallbacks.map(M=>M(a,t));typeof c=="function"&&s.push(c(a,t)),yield Promise.all(s)}for(const[a,s]of Object.entries(this.fields))u!=null&&Object.prototype.hasOwnProperty.call(u,a)&&i&&(s._intialValue=y.deepCopy(u[a])),s.isSubmitted=!0,s.isSubmitting=!1;return this.isSubmitted=!0,this.isSubmitting=!1,this.isValid})},validate(){return h(this,null,function*(){return this._revalidate(!1)})},getField(e){return this.fields[e]},getData(){if(!this.isValid)return null;const e={};for(const[t,i]of Object.entries(this.fields))e[t]=i.get();return e},getErrors(){const e={};for(const[t,i]of Object.entries(this.fields))switch(i.status._value.type){case"INVALID":e[t]=i.status._value.errors;break;case"UNVALIDATED":e[t]=[{code:"unvalidated",message:`${t.toString()} was not yet validated!`,path:t}];break}return e},reset(){for(const e of Object.values(this.fields))e.reset();this.isSubmitted=!1}};for(const e of Object.values(d.fields))e.listen(t=>h(this,[t],function*({source:i}){i==="set"&&(e.isSubmitted&&e._config.reValidateMode.has(o.FormFieldReValidateMode.OnChange)||!e.isSubmitted&&e._config.validateMode.has(o.FormFieldValidateMode.OnChange)||e._config.validateMode.has(o.FormFieldValidateMode.OnTouched)&&e.isTouched)&&(yield e.validate())}),{key:"form"}),e.status.listen(()=>h(this,null,function*(){yield d._revalidate(!0)}),{key:"form"});return d}exports.createForm=O;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var F=require("feature-state"),f=require("validation-adapter"),
|
|
1
|
+
"use strict";var h=require("@blgc/utils"),F=require("feature-state"),f=require("validation-adapter"),s=require("../types/form-field.js"),g=require("./create-form-field-validation-context.js"),y=require("./create-status.js"),M=(d,l,i)=>new Promise((o,r)=>{var u=t=>{try{a(i.next(t))}catch(e){r(e)}},n=t=>{try{a(i.throw(t))}catch(e){r(e)}},a=t=>t.done?o(t.value):Promise.resolve(t.value).then(u,n);a((i=i.apply(d,l)).next())});function _(d,l){const{key:i,validator:o=f.createValidator([]),editable:r=!0,reValidateMode:u=h.bitwiseFlag(s.FormFieldReValidateMode.OnBlur),validateMode:n=h.bitwiseFlag(s.FormFieldValidateMode.OnSubmit),collectErrorMode:a="firstError",notifyOnStatusChange:t=!0}=l,e=F.createState(d,{deferred:!1}),c=y.createStatus({type:"UNVALIDATED"});t&&c.listen(()=>{e._notify({additionalData:{source:"status"}})},{key:"form-field"});const v={_config:{editable:r,validateMode:n,reValidateMode:u,collectErrorMode:a},_intialValue:h.deepCopy(e._value),_validator:o,key:i,isTouched:!1,isSubmitted:!1,isSubmitting:!1,isValidating:!1,status:c,validate(){return M(this,null,function*(){const m=g.createFormFieldValidationContext(this);return this.isValidating=!0,yield this._validator.validate(m),this.isValidating=!1,this.status._nextValue==null?this.status.set({type:"VALID"}):this.status.set(this.status._nextValue),this.status._nextValue=void 0,this.status.get().type==="VALID"})},isValid(){return this.status.get().type==="VALID"},blur(){(this.isSubmitted&&this._config.reValidateMode.has(s.FormFieldReValidateMode.OnBlur)||!this.isSubmitted&&(this._config.validateMode.has(s.FormFieldValidateMode.OnBlur)||this._config.validateMode.has(s.FormFieldValidateMode.OnTouched)&&!this.isTouched))&&this.validate(),this.isTouched=!0},reset(){this.set(this._intialValue),this.isTouched=!1,this.isSubmitted=!1,this.isSubmitting=!1,this.status.set({type:"UNVALIDATED"})}},V=Object.assign(e,v);return V._features.push("form-field"),V}exports.createFormField=_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty,e=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,o=(a,r,t)=>r in a?l(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t,b=(a,r)=>{for(var t in r||(r={}))i.call(r,t)&&o(a,t,r[t]);if(e)for(var t of e(r))n.call(r,t)&&o(a,t,r[t]);return a};function c(a,r){return b({validator:a},r)}exports.fromValidator=c;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@
|
|
1
|
+
"use strict";var e=require("@blgc/utils"),t=require("validation-adapter"),a=require("./create-form.js"),i=require("./form-field/create-form-field.js"),o=require("./form-field/create-status.js"),d=require("./form-field/is-form-field.js"),l=require("./helper/from-validator.js"),r=require("./types/form-field.js");Object.defineProperty(exports,"BitwiseFlag",{enumerable:!0,get:function(){return e.BitwiseFlag}}),Object.defineProperty(exports,"bitwiseFlag",{enumerable:!0,get:function(){return e.bitwiseFlag}}),Object.defineProperty(exports,"createValidator",{enumerable:!0,get:function(){return t.createValidator}}),exports.createForm=a.createForm,exports.createFormField=i.createFormField,exports.createStatus=o.createStatus,exports.isFormField=d.isFormField,exports.fromValidator=l.fromValidator,exports.FormFieldReValidateMode=r.FormFieldReValidateMode,exports.FormFieldValidateMode=r.FormFieldValidateMode;
|
package/dist/esm/create-form.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bitwiseFlag as O,deepCopy as M}from"@
|
|
1
|
+
import{bitwiseFlag as O,deepCopy as M}from"@blgc/utils";import{createFormField as F}from"./form-field/create-form-field.js";import"feature-state";import{FormFieldValidateMode as v,FormFieldReValidateMode as V}from"./types/form-field.js";var m=(g,S,n)=>new Promise((p,h)=>{var y=l=>{try{r(n.next(l))}catch(o){h(o)}},b=l=>{try{r(n.throw(l))}catch(o){h(o)}},r=l=>l.done?p(l.value):Promise.resolve(l.value).then(y,b);r((n=n.apply(g,S)).next())});function j(g){const{fields:S,collectErrorMode:n="firstError",disabled:p=!1,validateMode:h=O(v.OnSubmit),reValidateMode:y=O(V.OnBlur),onValidSubmit:b,onInvalidSubmit:r,notifyOnStatusChange:l=!0}=g,o={_:null,_features:["base"],_config:{collectErrorMode:n,disabled:p},_validSubmitCallbacks:b!=null?[b]:[],_invalidSubmitCallbacks:r!=null?[r]:[],fields:Object.fromEntries(Object.entries(S).map(([t,i])=>{var e,u,c,f;return[t,F(i.defaultValue,{key:t,validator:i.validator,collectErrorMode:(e=i.collectErrorMode)!=null?e:n,validateMode:(u=i.validateMode)!=null?u:h,reValidateMode:(c=i.reValidateMode)!=null?c:y,editable:(f=i.editable)!=null?f:!0,notifyOnStatusChange:l})]})),isValid:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,_revalidate(t=!1){return m(this,null,function*(){const i=Object.values(this.fields);return t||(this.isValidating=!0,yield Promise.all(i.map(e=>e.validate())),this.isValidating=!1),this.isValid=i.every(e=>e.isValid()),this.isValid})},submit(){return m(this,arguments,function*(t={}){const{additionalData:i,assignToInitial:e=!1,onInvalidSubmit:u,onValidSubmit:c}=t;this.isSubmitting=!0;const f=[];for(const a of Object.values(this.fields))(a.isSubmitted&&a._config.reValidateMode.has(V.OnSubmit)||!a.isSubmitted&&a._config.validateMode.has(v.OnSubmit))&&f.push(a.validate()),this.isSubmitting=!0;yield Promise.all(f);const d=this.getData();if(d!=null){const a=this._validSubmitCallbacks.map(s=>s(d,i));typeof c=="function"&&a.push(c(d,i)),yield Promise.all(a)}else{const a=this.getErrors(),s=this._invalidSubmitCallbacks.map(_=>_(a,i));typeof u=="function"&&s.push(u(a,i)),yield Promise.all(s)}for(const[a,s]of Object.entries(this.fields))d!=null&&Object.prototype.hasOwnProperty.call(d,a)&&e&&(s._intialValue=M(d[a])),s.isSubmitted=!0,s.isSubmitting=!1;return this.isSubmitted=!0,this.isSubmitting=!1,this.isValid})},validate(){return m(this,null,function*(){return this._revalidate(!1)})},getField(t){return this.fields[t]},getData(){if(!this.isValid)return null;const t={};for(const[i,e]of Object.entries(this.fields))t[i]=e.get();return t},getErrors(){const t={};for(const[i,e]of Object.entries(this.fields))switch(e.status._value.type){case"INVALID":t[i]=e.status._value.errors;break;case"UNVALIDATED":t[i]=[{code:"unvalidated",message:`${i.toString()} was not yet validated!`,path:i}];break}return t},reset(){for(const t of Object.values(this.fields))t.reset();this.isSubmitted=!1}};for(const t of Object.values(o.fields))t.listen(i=>m(this,[i],function*({source:e}){e==="set"&&(t.isSubmitted&&t._config.reValidateMode.has(V.OnChange)||!t.isSubmitted&&t._config.validateMode.has(v.OnChange)||t._config.validateMode.has(v.OnTouched)&&t.isTouched)&&(yield t.validate())}),{key:"form"}),t.status.listen(()=>m(this,null,function*(){yield o._revalidate(!0)}),{key:"form"});return o}export{j as createForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{bitwiseFlag as m,deepCopy as v}from"@blgc/utils";import{createState as y}from"feature-state";import{createValidator as g}from"validation-adapter";import{FormFieldReValidateMode as f,FormFieldValidateMode as n}from"../types/form-field.js";import{createFormFieldValidationContext as _}from"./create-form-field-validation-context.js";import{createStatus as b}from"./create-status.js";var M=(r,o,i)=>new Promise((d,s)=>{var l=t=>{try{a(i.next(t))}catch(e){s(e)}},u=t=>{try{a(i.throw(t))}catch(e){s(e)}},a=t=>t.done?d(t.value):Promise.resolve(t.value).then(l,u);a((i=i.apply(r,o)).next())});function F(r,o){const{key:i,validator:d=g([]),editable:s=!0,reValidateMode:l=m(f.OnBlur),validateMode:u=m(n.OnSubmit),collectErrorMode:a="firstError",notifyOnStatusChange:t=!0}=o,e=y(r,{deferred:!1}),h=b({type:"UNVALIDATED"});t&&h.listen(()=>{e._notify({additionalData:{source:"status"}})},{key:"form-field"});const V={_config:{editable:s,validateMode:u,reValidateMode:l,collectErrorMode:a},_intialValue:v(e._value),_validator:d,key:i,isTouched:!1,isSubmitted:!1,isSubmitting:!1,isValidating:!1,status:h,validate(){return M(this,null,function*(){const p=_(this);return this.isValidating=!0,yield this._validator.validate(p),this.isValidating=!1,this.status._nextValue==null?this.status.set({type:"VALID"}):this.status.set(this.status._nextValue),this.status._nextValue=void 0,this.status.get().type==="VALID"})},isValid(){return this.status.get().type==="VALID"},blur(){(this.isSubmitted&&this._config.reValidateMode.has(f.OnBlur)||!this.isSubmitted&&(this._config.validateMode.has(n.OnBlur)||this._config.validateMode.has(n.OnTouched)&&!this.isTouched))&&this.validate(),this.isTouched=!0},reset(){this.set(this._intialValue),this.isTouched=!1,this.isSubmitted=!1,this.isSubmitting=!1,this.status.set({type:"UNVALIDATED"})}},c=Object.assign(e,V);return c._features.push("form-field"),c}export{F as createFormField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var l=Object.defineProperty,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,o=(e,r,t)=>r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,p=(e,r)=>{for(var t in r||(r={}))n.call(r,t)&&o(e,t,r[t]);if(a)for(var t of a(r))i.call(r,t)&&o(e,t,r[t]);return e};function b(e,r){return p({validator:e},r)}export{b as
|
|
1
|
+
var l=Object.defineProperty,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,o=(e,r,t)=>r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,p=(e,r)=>{for(var t in r||(r={}))n.call(r,t)&&o(e,t,r[t]);if(a)for(var t of a(r))i.call(r,t)&&o(e,t,r[t]);return e};function b(e,r){return p({validator:e},r)}export{b as fromValidator};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BitwiseFlag as o,bitwiseFlag as t}from"@
|
|
1
|
+
import{BitwiseFlag as o,bitwiseFlag as t}from"@blgc/utils";import{createValidator as m}from"validation-adapter";import{createForm as F}from"./create-form.js";import{createFormField as l}from"./form-field/create-form-field.js";import{createStatus as p}from"./form-field/create-status.js";import{isFormField as c}from"./form-field/is-form-field.js";import{fromValidator as V}from"./helper/from-validator.js";import{FormFieldReValidateMode as w,FormFieldValidateMode as M}from"./types/form-field.js";export{o as BitwiseFlag,w as FormFieldReValidateMode,M as FormFieldValidateMode,t as bitwiseFlag,F as createForm,l as createFormField,p as createStatus,m as createValidator,V as fromValidator,c as isFormField};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BitwiseFlag } from '@
|
|
1
|
+
import { type BitwiseFlag } from '@blgc/utils';
|
|
2
2
|
import { FormFieldReValidateMode, FormFieldValidateMode, type TForm, type TFormConfig, type TFormData, type TFormFieldStateConfig, type TFormFieldValidator, type TInvalidSubmitCallback, type TValidSubmitCallback } from './types';
|
|
3
3
|
export declare function createForm<GFormData extends TFormData>(config: TCreateFormConfig<GFormData>): TForm<GFormData, ['base']>;
|
|
4
4
|
export interface TCreateFormConfig<GFormData extends TFormData> extends Partial<TFormConfig> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-form.d.ts","sourceRoot":"","sources":["../../src/create-form.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"create-form.d.ts","sourceRoot":"","sources":["../../src/create-form.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGtE,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,KAAK,EACV,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAGxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,UAAU,CAAC,SAAS,SAAS,SAAS,EACrD,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAClC,KAAK,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,CAwM5B;AAED,MAAM,WAAW,iBAAiB,CAAC,SAAS,SAAS,SAAS,CAAE,SAAQ,OAAO,CAAC,WAAW,CAAC;IAC3F;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAC/C;;OAEG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAClD;;OAEG;IACH,cAAc,CAAC,EAAE,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACtD;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,eAAe,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IACpD,aAAa,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,2BAA2B,CAAC,SAAS,SAAS,SAAS,IAAI;KACrE,GAAG,IAAI,MAAM,SAAS,GAAG,0BAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;CACpE,CAAC;AAEF,MAAM,WAAW,0BAA0B,CAAC,MAAM,CAAE,SAAQ,OAAO,CAAC,qBAAqB,CAAC;IACzF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type TCreateFormConfigFormField } from '../create-form';
|
|
2
|
+
import { type TFormFieldValidator } from '../types';
|
|
3
|
+
export declare function fromValidator<GValue>(validator: TFormFieldValidator<GValue>, config: Omit<TCreateFormConfigFormField<GValue>, 'validator'>): TCreateFormConfigFormField<GValue>;
|
|
4
|
+
//# sourceMappingURL=from-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-validator.d.ts","sourceRoot":"","sources":["../../../src/helper/from-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD,wBAAgB,aAAa,CAAC,MAAM,EACnC,SAAS,EAAE,mBAAmB,CAAC,MAAM,CAAC,EACtC,MAAM,EAAE,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,GAC3D,0BAA0B,CAAC,MAAM,CAAC,CAEpC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './from-
|
|
1
|
+
export * from './from-validator';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helper/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helper/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TFormFieldStateFeature, TFormFielStatusStateFeature } from './types';
|
|
2
|
-
export { BitwiseFlag, bitwiseFlag } from '@
|
|
2
|
+
export { BitwiseFlag, bitwiseFlag } from '@blgc/utils';
|
|
3
3
|
export { createValidator } from 'validation-adapter';
|
|
4
4
|
export * from './create-form';
|
|
5
5
|
export * from './form-field';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AAExB,OAAO,QAAQ,eAAe,CAAC;IAC9B,UAAU,mBAAmB,CAAC,MAAM;QACnC,YAAY,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC7C,mBAAmB,EAAE,2BAA2B,CAAC;KACjD;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../src/types/features.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../src/types/features.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,SAAS,CAAC,SAAS,SAAS,SAAS,GAAG,SAAS,IAAI;IAChE,IAAI,EAAE;QAAE,CAAC,EAAE,IAAI,CAAA;KAAE,CAAC;CAClB,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;AAInC,MAAM,WAAW,mBAAmB,CAAC,SAAS;CAAI;AAElD,MAAM,MAAM,YAAY,CAAC,SAAS,SAAS,SAAS,GAAG,SAAS,IAAI,MAAM,SAAS,CAAC,SAAS,CAAC,CAAC;AAE/F,MAAM,MAAM,qBAAqB,CAChC,SAAS,SAAS,SAAS,EAC3B,oBAAoB,SAAS,YAAY,EAAE,IACxC;KACF,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,eAAe,CAC1B,SAAS,SAAS,SAAS,EAC3B,oBAAoB,SAAS,YAAY,EAAE,EAC3C,uBAAuB,SAAS,qBAAqB,CACpD,SAAS,EACT,oBAAoB,CACpB,GAAG,qBAAqB,CAAC,SAAS,EAAE,oBAAoB,CAAC,IACvD,oBAAoB,CAAC,uBAAuB,CAAC,MAAM,uBAAuB,CAAC,CAAC,CAAC;AAEjF,MAAM,MAAM,gBAAgB,CAC3B,YAAY,SAAS,YAAY,EAAE,EACnC,qBAAqB,SAAS,YAAY,EAAE,IAE5C,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,SAAS,KAAK,GACvE,YAAY,GACZ,YAAY,GAAG,qBAAqB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type BitwiseFlag } from '@blgc/utils';
|
|
1
2
|
import { type TState } from 'feature-state';
|
|
2
3
|
import { type TBaseValidationContext, type TCollectErrorMode, type TValidator } from 'validation-adapter';
|
|
3
|
-
import { type BitwiseFlag } from '@ibg/utils';
|
|
4
4
|
export type TFormField<GValue> = TState<GValue | undefined, ['base', 'form-field']>;
|
|
5
5
|
export interface TFormFieldStateFeature<GValue> {
|
|
6
6
|
_config: TFormFieldStateConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-field.d.ts","sourceRoot":"","sources":["../../../src/types/form-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"form-field.d.ts","sourceRoot":"","sources":["../../../src/types/form-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,UAAU,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAEpF,MAAM,WAAW,sBAAsB,CAAC,MAAM;IAC7C,OAAO,EAAE,qBAAqB,CAAC;IAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IAEH,YAAY,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAC;IACjD;;OAEG;IAEH,cAAc,EAAE,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACrD,gBAAgB,EAAE,iBAAiB,CAAC;CACpC;AAED,oBAAY,qBAAqB;IAEhC,MAAM,IAAS,CAAE,IAAI;IAErB,QAAQ,IAAS,CAAE,IAAI;IAEvB,QAAQ,IAAS,CAAE,IAAI;IAEvB,SAAS,IAAS;CAClB;AAED,oBAAY,uBAAuB;IAElC,MAAM,IAAS,CAAE,IAAI;IAErB,QAAQ,IAAS,CAAE,IAAI;IAEvB,QAAQ,IAAS;CACjB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAE5F,MAAM,WAAW,2BAA2B;IAC3C,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,iBAAiB,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,MAAM,qBAAqB,GAC9B,uBAAuB,GACvB,qBAAqB,GACrB,2BAA2B,CAAC;AAE/B,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,sBAAsB,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,2BAA2B;IAC3C,IAAI,EAAE,aAAa,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;AAElG,MAAM,MAAM,2BAA2B,CAAC,MAAM,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feature-form",
|
|
3
3
|
"description": "Straightforward, typesafe, and feature-based form library for ReactJs",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./dist/cjs/index.js",
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
"types": "./dist/types/index.d.ts",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/builder-group/monorepo.git"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [],
|
|
15
|
-
"author": "@
|
|
15
|
+
"author": "@bennobuilder",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"bugs": {
|
|
18
|
-
"url": "https://github.com/
|
|
18
|
+
"url": "https://github.com/builder-group/monorepo/issues"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://
|
|
20
|
+
"homepage": "https://builder.group/?source=github",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"feature-state": "0.0.
|
|
25
|
-
"validation-adapter": "0.0.
|
|
22
|
+
"@blgc/types": "0.0.6",
|
|
23
|
+
"@blgc/utils": "0.0.15",
|
|
24
|
+
"feature-state": "0.0.19",
|
|
25
|
+
"validation-adapter": "0.0.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^20.14.1",
|
|
29
|
-
"@
|
|
29
|
+
"@blgc/config": "0.0.16"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty,e=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,o=(a,t,r)=>t in a?i(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,p=(a,t)=>{for(var r in t||(t={}))l.call(t,r)&&o(a,r,t[r]);if(e)for(var r of e(t))n.call(t,r)&&o(a,r,t[r]);return a};function b(a,t){return p({validator:a},t)}exports.fromValidationAdapter=b;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type TCreateFormConfigFormField } from '../create-form';
|
|
2
|
-
import { type TFormFieldValidator } from '../types';
|
|
3
|
-
export declare function fromValidationAdapter<GValue>(validator: TFormFieldValidator<GValue>, config: Omit<TCreateFormConfigFormField<GValue>, 'validator'>): TCreateFormConfigFormField<GValue>;
|
|
4
|
-
//# sourceMappingURL=from-validation-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"from-validation-adapter.d.ts","sourceRoot":"","sources":["../../../src/helper/from-validation-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD,wBAAgB,qBAAqB,CAAC,MAAM,EAC3C,SAAS,EAAE,mBAAmB,CAAC,MAAM,CAAC,EACtC,MAAM,EAAE,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,GAC3D,0BAA0B,CAAC,MAAM,CAAC,CAEpC"}
|