@rolster/forms 2.0.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/helpers.js +73 -0
  3. package/dist/cjs/helpers.js.map +1 -0
  4. package/dist/cjs/index.js +476 -0
  5. package/dist/cjs/index.js.map +1 -0
  6. package/dist/es/helpers.js +61 -0
  7. package/dist/es/helpers.js.map +1 -0
  8. package/dist/es/index.js +465 -0
  9. package/dist/es/index.js.map +1 -0
  10. package/dist/esm/arguments.d.ts +18 -0
  11. package/dist/esm/arguments.js +37 -0
  12. package/dist/esm/arguments.js.map +1 -0
  13. package/dist/esm/form-array/form-array-control.d.ts +11 -0
  14. package/dist/esm/form-array/form-array-control.js +11 -0
  15. package/dist/esm/form-array/form-array-control.js.map +1 -0
  16. package/dist/esm/form-array/form-array-group.d.ts +11 -0
  17. package/dist/esm/form-array/form-array-group.js +12 -0
  18. package/dist/esm/form-array/form-array-group.js.map +1 -0
  19. package/dist/esm/form-array/form-array.d.ts +46 -0
  20. package/dist/esm/form-array/form-array.js +127 -0
  21. package/dist/esm/form-array/form-array.js.map +1 -0
  22. package/dist/esm/form-array/index.d.ts +3 -0
  23. package/dist/esm/form-array/index.js +4 -0
  24. package/dist/esm/form-array/index.js.map +1 -0
  25. package/dist/esm/form-control.d.ts +44 -0
  26. package/dist/esm/form-control.js +114 -0
  27. package/dist/esm/form-control.js.map +1 -0
  28. package/dist/esm/form-group.d.ts +33 -0
  29. package/dist/esm/form-group.js +94 -0
  30. package/dist/esm/form-group.js.map +1 -0
  31. package/dist/esm/helpers.d.ts +24 -0
  32. package/dist/esm/helpers.js +59 -0
  33. package/dist/esm/helpers.js.map +1 -0
  34. package/dist/esm/index.d.ts +5 -0
  35. package/dist/esm/index.js +6 -0
  36. package/dist/esm/index.js.map +1 -0
  37. package/dist/esm/types.d.ts +127 -0
  38. package/dist/esm/types.js +2 -0
  39. package/dist/esm/types.js.map +1 -0
  40. package/helpers/package.json +8 -0
  41. package/package.json +76 -0
  42. package/readme.md +13 -0
@@ -0,0 +1,6 @@
1
+ export { createFormArrayProps, createFormControlProps, createFormGroupProps } from './arguments';
2
+ export { FormArray, FormArrayControl, FormArrayGroup } from './form-array';
3
+ export { FormControl } from './form-control';
4
+ export { FormGroup } from './form-group';
5
+ export * from './types';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,gBAAgB,EAEhB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAgB,SAAS,EAAE,MAAM,cAAc,CAAC;AACvD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { ValidatorError, ValidatorFn, ValidatorResult } from '@rolster/validators';
2
+ export type FormState<T = any> = T | undefined | null;
3
+ export type ValidationFormType = 'control' | 'group' | 'array';
4
+ export interface ValidationFormError<T = any> extends ValidatorError<T> {
5
+ type: ValidationFormType;
6
+ }
7
+ export type SubscriberControl<T> = (state?: FormState<T>) => void;
8
+ export interface AbstractControl<T = any> {
9
+ dirty: boolean;
10
+ errors: ValidatorError[];
11
+ invalid: boolean;
12
+ pristine: boolean;
13
+ touched: boolean;
14
+ untouched: boolean;
15
+ valid: boolean;
16
+ value: T;
17
+ wrong: boolean;
18
+ error?: ValidatorError;
19
+ state?: FormState<T>;
20
+ }
21
+ export type AbstractControls<T extends AbstractControl = AbstractControl> = Record<string, T>;
22
+ export interface AbstractGroupControl<T = any> extends AbstractControl<T> {
23
+ reset: () => void;
24
+ subscribe: (subscriber: SubscriberControl<T>) => Unsubscription;
25
+ }
26
+ export interface AbstractBaseControl<T = any> extends AbstractGroupControl<T> {
27
+ blur: () => void;
28
+ disable: () => void;
29
+ disabled: boolean;
30
+ enable: () => void;
31
+ enabled: boolean;
32
+ focus: () => void;
33
+ focused: boolean;
34
+ setState: (state?: FormState<T>) => void;
35
+ touch: () => void;
36
+ unfocused: boolean;
37
+ untouch: () => void;
38
+ }
39
+ export interface AbstractFormControl<T = any> extends AbstractBaseControl<T> {
40
+ setValidators: (validators?: ValidatorFn<T>[]) => void;
41
+ }
42
+ export type AbstractGroupControls<T extends AbstractGroupControl = AbstractGroupControl> = Record<string, T>;
43
+ export interface AbstractGroup<T extends AbstractGroupControls = AbstractGroupControls> {
44
+ controls: T;
45
+ dirty: boolean;
46
+ dirties: boolean;
47
+ errors: ValidatorError[];
48
+ invalid: boolean;
49
+ pristine: boolean;
50
+ pristines: boolean;
51
+ touched: boolean;
52
+ toucheds: boolean;
53
+ untouched: boolean;
54
+ untoucheds: boolean;
55
+ valid: boolean;
56
+ wrong: boolean;
57
+ error?: ValidatorError;
58
+ }
59
+ export type StateGroup<C extends AbstractGroupControls = AbstractGroupControls> = {
60
+ [K in keyof C]: C[K]['state'];
61
+ };
62
+ export type ValueGroup<C extends AbstractGroupControls = AbstractGroupControls> = {
63
+ [K in keyof C]: C[K]['value'];
64
+ };
65
+ export type ValidatorGroupFn<C extends AbstractGroupControls = AbstractGroupControls, V = any> = (controls: C) => ValidatorResult<V>;
66
+ export type SubscriberGroup<C extends AbstractGroupControls = AbstractGroupControls> = (state: StateGroup<C>) => void;
67
+ export interface AbstractFormGroup<C extends AbstractGroupControls = AbstractGroupControls> extends AbstractGroup<C> {
68
+ reset: () => void;
69
+ setValidators: (validators: ValidatorGroupFn<C>[]) => void;
70
+ state: StateGroup<C>;
71
+ subscribe: (subscriber: SubscriberGroup<C>) => Unsubscription;
72
+ value: ValueGroup<C>;
73
+ }
74
+ export interface AbstractArrayControl<T = any> extends AbstractFormControl<T> {
75
+ uuid: string;
76
+ }
77
+ export type AbstractArrayGroupControls<T extends AbstractArrayControl = AbstractArrayControl> = AbstractControls<T>;
78
+ export interface AbstractArrayGroup<C extends AbstractArrayGroupControls, R = any> extends AbstractGroup<C> {
79
+ setValidators: (validators: ValidatorGroupFn<C>[]) => void;
80
+ state: ArrayStateGroup<C>;
81
+ subscribe: (subscriber: SubscriberGroup<C>) => Unsubscription;
82
+ uuid: string;
83
+ value: ArrayValueGroup<C>;
84
+ resource?: R;
85
+ }
86
+ export type ArrayStateGroup<C extends AbstractArrayGroupControls> = {
87
+ [K in keyof C]: C[K]['state'];
88
+ };
89
+ export type ArrayValueGroup<C extends AbstractArrayGroupControls> = {
90
+ [K in keyof C]: C[K]['value'];
91
+ };
92
+ export type ValidatorArrayFn<T extends AbstractArrayGroupControls = AbstractArrayGroupControls, R = any, G extends AbstractArrayGroup<T, R> = AbstractArrayGroup<T, R>, V = any> = (groups: G[]) => ValidatorResult<V>;
93
+ export interface AbstractArray<T extends AbstractArrayGroupControls = AbstractArrayGroupControls, R = any, G extends AbstractArrayGroup<T, R> = AbstractArrayGroup<T, R>> extends AbstractGroupControl<ArrayStateGroup<T>[]> {
94
+ controls: T[];
95
+ dirties: boolean;
96
+ groups: G[];
97
+ merge: (groups: G[]) => void;
98
+ pristines: boolean;
99
+ push: (group: G) => void;
100
+ remove: (group: G) => void;
101
+ set: (groups: G[]) => void;
102
+ setValidators: (validators: ValidatorArrayFn<T, R>[]) => void;
103
+ state: ArrayStateGroup<T>[];
104
+ toucheds: boolean;
105
+ untoucheds: boolean;
106
+ value: ArrayValueGroup<T>[];
107
+ wrong: boolean;
108
+ }
109
+ export interface FormControlProps<T = any> {
110
+ state?: FormState<T>;
111
+ validators?: ValidatorFn<T>[];
112
+ }
113
+ export interface FormGroupProps<C extends AbstractGroupControls = AbstractGroupControls> {
114
+ controls: C;
115
+ validators?: ValidatorGroupFn<C>[];
116
+ }
117
+ export interface FormArrayControlProps<T = any> extends FormControlProps<T> {
118
+ uuid: string;
119
+ }
120
+ export interface FormArrayGroupProps<C extends AbstractArrayGroupControls = AbstractArrayGroupControls, R = any> extends FormGroupProps<C> {
121
+ uuid: string;
122
+ resource?: R;
123
+ }
124
+ export interface FormArrayProps<C extends AbstractArrayGroupControls = AbstractArrayGroupControls, R = any, G extends AbstractArrayGroup<C, R> = AbstractArrayGroup<C, R>> {
125
+ groups?: G[];
126
+ validators?: ValidatorArrayFn<C, R>[];
127
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@rolster/forms/helpers",
3
+ "types": "../dist/esm/helpers.d.ts",
4
+ "main": "../dist/cjs/helpers.js",
5
+ "module": "../dist/esm/helpers.js",
6
+ "unpkg": "../dist/es/helpers.js",
7
+ "sideEffects": false
8
+ }
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@rolster/forms",
3
+ "version": "2.0.0",
4
+ "description": "It implements a set of classes that allow managing the control of states of the input components of the UI.",
5
+ "module": "dist/esm/index.js",
6
+ "main": "dist/cjs/index.js",
7
+ "unpkg": "dist/es/index.js",
8
+ "types": "dist/esm/index.d.ts",
9
+ "license": "MIT",
10
+ "author": "Rolster Technology <rolster.developments@gmail.com>",
11
+ "contributors": [
12
+ {
13
+ "name": "Daniel Andrés Castillo Pedroza",
14
+ "email": "ing.dacastillop@gmail.com"
15
+ }
16
+ ],
17
+ "files": [
18
+ "dist/",
19
+ "helpers/"
20
+ ],
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/esm/index.d.ts",
24
+ "node": "./dist/cjs/index.js",
25
+ "require": "./dist/cjs/index.js",
26
+ "default": "./dist/esm/index.js"
27
+ },
28
+ "./helpers": {
29
+ "types": "./dist/esm/helpers.d.ts",
30
+ "node": "./dist/cjs/helpers.js",
31
+ "require": "./dist/cjs/helpers.js",
32
+ "default": "./dist/esm/helpers.js"
33
+ }
34
+ },
35
+ "scripts": {
36
+ "prettier": "prettier . --write",
37
+ "clean": "rimraf ./dist",
38
+ "build": "npm run clean && tsc -p tsconfig.app.json && rollup -c rollup.config.js",
39
+ "test": "jest --coverage",
40
+ "test:watch": "jest --coverage --watch",
41
+ "prepublishOnly": "npm run build"
42
+ },
43
+ "dependencies": {
44
+ "@rolster/commons": "^2.0.2",
45
+ "@rolster/validators": "^2.0.0",
46
+ "rxjs": "^7.8.1",
47
+ "uuid": "^9.0.1"
48
+ },
49
+ "devDependencies": {
50
+ "@rollup/plugin-commonjs": "^25.0.4",
51
+ "@rollup/plugin-node-resolve": "^15.2.1",
52
+ "@rollup/plugin-typescript": "^11.1.3",
53
+ "@rolster/types": "^1.0.9",
54
+ "@types/jest": "^29.5.1",
55
+ "@types/uuid": "^9.0.7",
56
+ "jest": "^29.5.0",
57
+ "prettier": "^3.0.3",
58
+ "rimraf": "^3.0.2",
59
+ "rollup": "^2.32.0",
60
+ "ts-jest": "^29.1.0",
61
+ "tslib": "^2.4.0",
62
+ "typescript": "^4.9.0"
63
+ },
64
+ "repository": {
65
+ "type": "git",
66
+ "url": "https://github.com/rolster-developments/typescript-forms.git"
67
+ },
68
+ "keywords": [
69
+ "rolster",
70
+ "typescript",
71
+ "forms"
72
+ ],
73
+ "publishConfig": {
74
+ "access": "public"
75
+ }
76
+ }
package/readme.md ADDED
@@ -0,0 +1,13 @@
1
+ # Rolster Helpers Forms
2
+
3
+ It implements a set of classes that allow managing the control of states of the input components of the UI.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ npm i @rolster/helpers-forms
9
+ ```
10
+
11
+ ## Contributing
12
+
13
+ - Daniel Andrés Castillo Pedroza :rocket: