@xyo-network/react-form-group 7.5.7 → 7.5.11
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/browser/FormGroup.d.ts +2 -2
- package/dist/browser/FormGroup.d.ts.map +1 -1
- package/dist/browser/InputError.d.ts +2 -2
- package/dist/browser/InputError.d.ts.map +1 -1
- package/dist/browser/control/FormControl.d.ts +2 -2
- package/dist/browser/control/FormControl.d.ts.map +1 -1
- package/dist/browser/control/FormControlBase.d.ts.map +1 -1
- package/dist/browser/control/accessor/ControlValueAccessorBase.d.ts +4 -3
- package/dist/browser/control/accessor/ControlValueAccessorBase.d.ts.map +1 -1
- package/dist/browser/index.mjs +116 -152
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +55 -31
- package/src/FormGroup.ts +0 -227
- package/src/InputError.ts +0 -4
- package/src/context/Context.ts +0 -5
- package/src/context/Provider.tsx +0 -36
- package/src/context/State.ts +0 -8
- package/src/context/index.ts +0 -4
- package/src/context/use.ts +0 -5
- package/src/control/AbstractControl.ts +0 -127
- package/src/control/FormControl.ts +0 -31
- package/src/control/FormControlBase.ts +0 -84
- package/src/control/accessor/ControlValueAccessor.ts +0 -23
- package/src/control/accessor/ControlValueAccessorBase.ts +0 -191
- package/src/control/accessor/FormControlStatus.ts +0 -36
- package/src/control/accessor/ValidControlValue.ts +0 -1
- package/src/control/accessor/index.ts +0 -4
- package/src/control/index.ts +0 -4
- package/src/index.ts +0 -5
- package/src/storage/ArchivistFormGroupStorage.ts +0 -25
- package/src/storage/FormGroupStorage.ts +0 -8
- package/src/storage/index.ts +0 -2
- package/src/stories/test.stories.tsx +0 -17
- package/src/types/images.d.ts +0 -5
|
@@ -7,14 +7,14 @@ export type PayloadWithTimestamp = Payload<{
|
|
|
7
7
|
}>;
|
|
8
8
|
export type KeyOfString<T> = keyof T extends string ? keyof T : never;
|
|
9
9
|
type FormGroupErrors<TValue> = Record<KeyOfString<TValue>, string>;
|
|
10
|
-
export
|
|
10
|
+
export interface FormGroupParams<TStorageValue extends Payload = Payload> {
|
|
11
11
|
serialize?: boolean;
|
|
12
12
|
storage?: {
|
|
13
13
|
sensitive?: FormGroupStorage<TStorageValue>;
|
|
14
14
|
storage?: FormGroupStorage<TStorageValue>;
|
|
15
15
|
};
|
|
16
16
|
ttlStorage?: number;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
/**
|
|
19
19
|
* Organize form controls in a group.
|
|
20
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGroup.d.ts","sourceRoot":"","sources":["../../src/FormGroup.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,GAAG,KAAK,CAAA;AAErE,KAAK,eAAe,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;AAElE,MAAM,
|
|
1
|
+
{"version":3,"file":"FormGroup.d.ts","sourceRoot":"","sources":["../../src/FormGroup.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM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AAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAqBtF,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe;IAMtD,aAAa;IAMb,WAAW;IAMX,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAW9B,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS;IAWpD,OAAO,CAAC,qBAAqB;IAuC7B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,wBAAwB;CAcjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputError.d.ts","sourceRoot":"","sources":["../../src/InputError.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"InputError.d.ts","sourceRoot":"","sources":["../../src/InputError.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EmptyObject } from '@xylabs/sdk-js';
|
|
2
2
|
import type { AbstractControl } from './AbstractControl.ts';
|
|
3
|
-
export
|
|
3
|
+
export interface CursorPosition {
|
|
4
4
|
current: number | undefined;
|
|
5
5
|
previous: number | undefined;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
export interface FormControlValidator {
|
|
8
8
|
blurError?: (value: string) => void;
|
|
9
9
|
changeError?: (value: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormControl.d.ts","sourceRoot":"","sources":["../../../src/control/FormControl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,
|
|
1
|
+
{"version":3,"file":"FormControl.d.ts","sourceRoot":"","sources":["../../../src/control/FormControl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAErC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,cAAc,CAAA;IAC9B,iBAAiB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAC5C,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAChC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAA;IACrD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CACnC;AAED,MAAM,WAAW,WAAW,CAAC,MAAM,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,oBAAoB,EAAE,eAAe,EAAE,eAAe;IACnI,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormControlBase.d.ts","sourceRoot":"","sources":["../../../src/control/FormControlBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,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,YAAW,WAAW;IAC5H;;OAEG;IACH,cAAc,EAAE,cAAc,CAA8C;IAE5E,cAAc,SAAkB;IAChC,OAAO,SAAgB;IACvB,aAAa,SAAgB;IAC7B,KAAK,EAAS,MAAM,CAAA;IACpB,QAAQ,UAAQ;IAEhB,OAAO,CAAC,KAAK,CAAgC;;IAM7C,IAAI,IAAI,uBAEP;IAED,IAAa,QAAQ,gEAEpB;IAED,SAAS,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAC3C,WAAW,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IACjC,iBAAiB,CAAC,IAAI,MAAM,GAAG,SAAS;IACxC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAC5B,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAA+B;IAE1E,QAAQ,CAAC,KAAK,oBAAK,EAAE,UAAU,EAAE,UAAU;IA0BpD,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAGrB,QAAQ,IAAI,OAAO;IAQ5B,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;CAG3C"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { BaseParams } from '@xylabs/
|
|
1
|
+
import type { BaseParams } from '@xylabs/sdk-js';
|
|
2
2
|
import { ModuleBaseEmitter } from '@xyo-network/module-event-emitter';
|
|
3
3
|
import type { ControlSerializeSettings, ControlValueAccessor, SetOptions } from './ControlValueAccessor.ts';
|
|
4
4
|
import type { ValidControlValue } from './ValidControlValue.ts';
|
|
5
|
-
export
|
|
5
|
+
export interface ControlValueAccessorBaseConfig {
|
|
6
6
|
disableEvents?: boolean;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
export declare const DefaultSetOptions: SetOptions;
|
|
9
9
|
export type ControlValueAccessorBaseEvents<TValue = ValidControlValue> = {
|
|
10
|
+
[key: PropertyKey]: string | number | object;
|
|
10
11
|
errorChanged: {
|
|
11
12
|
error: string;
|
|
12
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlValueAccessorBase.d.ts","sourceRoot":"","sources":["../../../../src/control/accessor/ControlValueAccessorBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ControlValueAccessorBase.d.ts","sourceRoot":"","sources":["../../../../src/control/accessor/ControlValueAccessorBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAErE,OAAO,KAAK,EACV,wBAAwB,EAAE,oBAAoB,EAAE,UAAU,EAC3D,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,eAAO,MAAM,iBAAiB,EAAE,UAAmC,CAAA;AAGnE,MAAM,MAAM,8BAA8B,CAAC,MAAM,GAAG,iBAAiB,IAAI;IACvE,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IAC5C,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC/B,YAAY,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAA;IAClC,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAChC,CAAA;AAED;;GAEG;AACH,qBAAa,wBAAwB,CACnC,MAAM,GAAG,iBAAiB,EAC1B,UAAU,SAAS,8BAA8B,CAAC,MAAM,CAAC,GAAG,8BAA8B,CAAC,MAAM,CAAC,CAElG,SAAQ,iBAAiB,CAAC,UAAU,EAAE,UAAU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AAwB;CAGlE"}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/context/Context.ts
|
|
5
2
|
import { createContextEx } from "@xylabs/react-shared";
|
|
6
3
|
var FormGroupBaseContext = createContextEx();
|
|
7
4
|
|
|
8
5
|
// src/context/Provider.tsx
|
|
9
|
-
import
|
|
6
|
+
import { useMemo } from "react";
|
|
10
7
|
|
|
11
8
|
// src/FormGroup.ts
|
|
12
9
|
import { forget as forget3 } from "@xylabs/sdk-js";
|
|
@@ -17,19 +14,11 @@ import { forget as forget2 } from "@xylabs/sdk-js";
|
|
|
17
14
|
// src/control/accessor/ControlValueAccessorBase.ts
|
|
18
15
|
import { forget } from "@xylabs/sdk-js";
|
|
19
16
|
import { ModuleBaseEmitter } from "@xyo-network/module-event-emitter";
|
|
20
|
-
var DefaultSetOptions = {
|
|
21
|
-
disableEmit: false
|
|
22
|
-
};
|
|
17
|
+
var DefaultSetOptions = { disableEmit: false };
|
|
23
18
|
var ControlValueAccessorBase = class extends ModuleBaseEmitter {
|
|
24
|
-
static {
|
|
25
|
-
__name(this, "ControlValueAccessorBase");
|
|
26
|
-
}
|
|
27
19
|
_error = "";
|
|
28
20
|
_previousValue = void 0;
|
|
29
|
-
_serializeSettings = {
|
|
30
|
-
sensitive: false,
|
|
31
|
-
serializable: false
|
|
32
|
-
};
|
|
21
|
+
_serializeSettings = { sensitive: false, serializable: false };
|
|
33
22
|
_touched = false;
|
|
34
23
|
_value = void 0;
|
|
35
24
|
config;
|
|
@@ -38,94 +27,92 @@ var ControlValueAccessorBase = class extends ModuleBaseEmitter {
|
|
|
38
27
|
this.config = config;
|
|
39
28
|
}
|
|
40
29
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
* The error message for the control.
|
|
31
|
+
*/
|
|
43
32
|
get error() {
|
|
44
33
|
return this._error;
|
|
45
34
|
}
|
|
46
35
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
* The "previous value" of the input element.
|
|
37
|
+
*/
|
|
49
38
|
get previousValue() {
|
|
50
39
|
return this._previousValue;
|
|
51
40
|
}
|
|
52
41
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
* The serialize settings of the input element.
|
|
43
|
+
*/
|
|
55
44
|
get serializeSettings() {
|
|
56
45
|
return this._serializeSettings;
|
|
57
46
|
}
|
|
58
47
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
* The "touched" state of the input element.
|
|
49
|
+
*/
|
|
61
50
|
get touched() {
|
|
62
51
|
return this._touched;
|
|
63
52
|
}
|
|
64
53
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
* The current value of the input element.
|
|
55
|
+
*/
|
|
67
56
|
get value() {
|
|
68
57
|
return this._value;
|
|
69
58
|
}
|
|
70
59
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onChange =
|
|
75
|
-
}
|
|
60
|
+
* The registered callback function called when a change or input event occurs on the input
|
|
61
|
+
* element.
|
|
62
|
+
*/
|
|
63
|
+
onChange = (_) => {
|
|
64
|
+
};
|
|
76
65
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
onErrorChange =
|
|
80
|
-
}
|
|
66
|
+
* Registers a function called when the control error changes.
|
|
67
|
+
*/
|
|
68
|
+
onErrorChange = () => {
|
|
69
|
+
};
|
|
81
70
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
onTouched =
|
|
85
|
-
}
|
|
71
|
+
* The registered callback function called when a blur event occurs on the input element.
|
|
72
|
+
*/
|
|
73
|
+
onTouched = (_isTouched) => {
|
|
74
|
+
};
|
|
86
75
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
* Registers a function called when the control value changes.
|
|
77
|
+
* @param {(_value:ValidControlValue)=>void} fn
|
|
78
|
+
* @returns void
|
|
79
|
+
*/
|
|
91
80
|
registerOnChange(fn) {
|
|
92
81
|
this.onChange = fn;
|
|
93
82
|
}
|
|
94
83
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
* Registers a function called when the control error changes.
|
|
85
|
+
* @param {(error:string)=>void} fn
|
|
86
|
+
*/
|
|
98
87
|
registerOnErrorChange(fn) {
|
|
99
88
|
this.onErrorChange = fn;
|
|
100
89
|
}
|
|
101
90
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
* Registers a function called when the control is touched.
|
|
92
|
+
* @param {(isTouched:boolean)=>void} fn
|
|
93
|
+
* @returns void
|
|
94
|
+
*/
|
|
106
95
|
registerOnTouched(fn) {
|
|
107
96
|
this.onTouched = fn;
|
|
108
97
|
}
|
|
109
98
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
* Sets the "touched" state of the input element.
|
|
100
|
+
* @param {boolean} isTouched
|
|
101
|
+
*/
|
|
113
102
|
setTouched(isTouched) {
|
|
114
103
|
if (this.touched !== isTouched) {
|
|
115
104
|
this._touched = isTouched;
|
|
116
105
|
this.onTouched(isTouched);
|
|
117
106
|
if (this.config.disableEvents) return;
|
|
118
|
-
const emit =
|
|
119
|
-
touched: isTouched
|
|
120
|
-
}), "emit");
|
|
107
|
+
const emit = async () => await this.emit("touchChanged", { touched: isTouched });
|
|
121
108
|
forget(emit());
|
|
122
109
|
}
|
|
123
110
|
}
|
|
124
111
|
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
* Sets the "value" property on the input element.
|
|
113
|
+
* @param {ValidControlValue} value
|
|
114
|
+
* @returns void
|
|
115
|
+
*/
|
|
129
116
|
setValue(value, options = DefaultSetOptions) {
|
|
130
117
|
this._previousValue = this._value;
|
|
131
118
|
const normalizedValue = value == null ? "" : value;
|
|
@@ -133,39 +120,35 @@ var ControlValueAccessorBase = class extends ModuleBaseEmitter {
|
|
|
133
120
|
this._value = normalizedValue;
|
|
134
121
|
this.onChange(normalizedValue);
|
|
135
122
|
if (this.config.disableEvents || options.disableEmit) return;
|
|
136
|
-
const emit =
|
|
137
|
-
value: normalizedValue
|
|
138
|
-
}), "emit");
|
|
123
|
+
const emit = async () => await this.emit("valueChanged", { value: normalizedValue });
|
|
139
124
|
forget(emit());
|
|
140
125
|
}
|
|
141
126
|
}
|
|
142
127
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
128
|
+
* Set the error message for the control.
|
|
129
|
+
* @param {string} error
|
|
130
|
+
*/
|
|
146
131
|
setError(error) {
|
|
147
132
|
if (this.error !== error) {
|
|
148
133
|
this._error = error;
|
|
149
134
|
this.onErrorChange(error);
|
|
150
135
|
if (this.config.disableEvents) return;
|
|
151
|
-
const emit =
|
|
152
|
-
error
|
|
153
|
-
}), "emit");
|
|
136
|
+
const emit = async () => await this.emit("errorChanged", { error });
|
|
154
137
|
forget(emit());
|
|
155
138
|
}
|
|
156
139
|
}
|
|
157
140
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
141
|
+
* Sets the "previous value" of the input element.
|
|
142
|
+
* @param {ValidControlValue} value
|
|
143
|
+
* @returns void
|
|
144
|
+
*/
|
|
162
145
|
setPreviousValue(value) {
|
|
163
146
|
this._previousValue = value;
|
|
164
147
|
}
|
|
165
148
|
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
149
|
+
* Sets the serialize settings of the input element.
|
|
150
|
+
* @param {ControlSerializeSettings} settings
|
|
151
|
+
*/
|
|
169
152
|
setSerializeSettings(settings) {
|
|
170
153
|
this._serializeSettings = settings;
|
|
171
154
|
}
|
|
@@ -179,32 +162,29 @@ var DISABLED = "DISABLED";
|
|
|
179
162
|
|
|
180
163
|
// src/control/AbstractControl.ts
|
|
181
164
|
var AbstractControl = class extends ControlValueAccessorBase {
|
|
182
|
-
static {
|
|
183
|
-
__name(this, "AbstractControl");
|
|
184
|
-
}
|
|
185
165
|
_status = void 0;
|
|
186
166
|
constructor() {
|
|
187
167
|
super({});
|
|
188
168
|
}
|
|
189
169
|
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
170
|
+
* A control is `disabled` when its `status` is `DISABLED`.
|
|
171
|
+
*
|
|
172
|
+
* Disabled controls are exempt from validation checks and
|
|
173
|
+
* are not included in the aggregate value of their ancestor
|
|
174
|
+
* controls.
|
|
175
|
+
*
|
|
176
|
+
* @returns True if the control is disabled, false otherwise.
|
|
177
|
+
*/
|
|
198
178
|
/** @deprecated - disabled functionality not implemented */
|
|
199
179
|
get disabled() {
|
|
200
180
|
return this.status === DISABLED;
|
|
201
181
|
}
|
|
202
182
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
183
|
+
* A control is `enabled` as long as its `status` is not `DISABLED`.
|
|
184
|
+
*
|
|
185
|
+
* @returns True if the control has any status other than 'DISABLED',
|
|
186
|
+
* false if the status is 'DISABLED'.
|
|
187
|
+
*/
|
|
208
188
|
get enabled() {
|
|
209
189
|
return this.status !== DISABLED;
|
|
210
190
|
}
|
|
@@ -219,32 +199,32 @@ var AbstractControl = class extends ControlValueAccessorBase {
|
|
|
219
199
|
return this.status === INVALID;
|
|
220
200
|
}
|
|
221
201
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
202
|
+
* A control is `pending` when its `status` is `PENDING`.
|
|
203
|
+
*
|
|
204
|
+
* @returns True if this control is in the process of conducting a validation check,
|
|
205
|
+
* false otherwise.
|
|
206
|
+
*/
|
|
227
207
|
get pending() {
|
|
228
208
|
return this.status == PENDING;
|
|
229
209
|
}
|
|
230
210
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
211
|
+
* The raw value of the control.
|
|
212
|
+
*/
|
|
233
213
|
get rawValue() {
|
|
234
214
|
return this.value;
|
|
235
215
|
}
|
|
236
216
|
/**
|
|
237
|
-
|
|
238
|
-
|
|
217
|
+
* The current status of the control.
|
|
218
|
+
*/
|
|
239
219
|
get status() {
|
|
240
220
|
return this._status;
|
|
241
221
|
}
|
|
242
222
|
/**
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
223
|
+
* A control is `valid` when its `status` is `VALID`.
|
|
224
|
+
*
|
|
225
|
+
* @returns True if the control has passed all of its validation tests,
|
|
226
|
+
* false otherwise.
|
|
227
|
+
*/
|
|
248
228
|
get valid() {
|
|
249
229
|
return this.status === VALID;
|
|
250
230
|
}
|
|
@@ -255,9 +235,7 @@ var AbstractControl = class extends ControlValueAccessorBase {
|
|
|
255
235
|
setStatus(status) {
|
|
256
236
|
if (this._status === status) return;
|
|
257
237
|
this._status = status;
|
|
258
|
-
const emit =
|
|
259
|
-
status
|
|
260
|
-
}), "emit");
|
|
238
|
+
const emit = async () => await this.emit("statusChanged", { status });
|
|
261
239
|
forget2(emit());
|
|
262
240
|
}
|
|
263
241
|
validate() {
|
|
@@ -268,16 +246,10 @@ var AbstractControl = class extends ControlValueAccessorBase {
|
|
|
268
246
|
// src/control/FormControlBase.ts
|
|
269
247
|
var AllowAllRegex = /^.*$/s;
|
|
270
248
|
var FormControlBase = class extends AbstractControl {
|
|
271
|
-
static {
|
|
272
|
-
__name(this, "FormControlBase");
|
|
273
|
-
}
|
|
274
249
|
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
cursorPosition = {
|
|
278
|
-
current: void 0,
|
|
279
|
-
previous: void 0
|
|
280
|
-
};
|
|
250
|
+
* The current and previous cursor position of the input element.
|
|
251
|
+
*/
|
|
252
|
+
cursorPosition = { current: void 0, previous: void 0 };
|
|
281
253
|
invalidMessage = "Invalid input";
|
|
282
254
|
pattern = AllowAllRegex;
|
|
283
255
|
patternStrict = AllowAllRegex;
|
|
@@ -293,8 +265,8 @@ var FormControlBase = class extends AbstractControl {
|
|
|
293
265
|
get rawValue() {
|
|
294
266
|
return this.unmask && this.value ? this.unmask(this.value) : this.value;
|
|
295
267
|
}
|
|
296
|
-
onCursorChange =
|
|
297
|
-
}
|
|
268
|
+
onCursorChange = () => {
|
|
269
|
+
};
|
|
298
270
|
setValue(value = "", setOptions) {
|
|
299
271
|
if (this.unmask && this.pattern) {
|
|
300
272
|
const unmasked = this.unmask(value);
|
|
@@ -327,9 +299,6 @@ var FormControlBase = class extends AbstractControl {
|
|
|
327
299
|
|
|
328
300
|
// src/FormGroup.ts
|
|
329
301
|
var FormGroup = class extends AbstractControl {
|
|
330
|
-
static {
|
|
331
|
-
__name(this, "FormGroup");
|
|
332
|
-
}
|
|
333
302
|
_controls = {};
|
|
334
303
|
fgParams;
|
|
335
304
|
serializeListeners = {};
|
|
@@ -442,7 +411,7 @@ var FormGroup = class extends AbstractControl {
|
|
|
442
411
|
if (!shouldSerialize && (storage || sensitiveStorage)) console.warn("storage medium set but serialize is not enabled");
|
|
443
412
|
if (shouldSerialize && control.serializeSettings.serializable) {
|
|
444
413
|
this.setStateValueFromStorage(name, control);
|
|
445
|
-
const listener =
|
|
414
|
+
const listener = ({ value }) => {
|
|
446
415
|
if (control.serializeSettings.serializable) {
|
|
447
416
|
const targetStorage = control.serializeSettings.sensitive ? sensitiveStorage : storage;
|
|
448
417
|
const targetState = control.serializeSettings.sensitive ? this.serializedSensitiveState : this.serializedState;
|
|
@@ -451,63 +420,60 @@ var FormGroup = class extends AbstractControl {
|
|
|
451
420
|
payloadWithTimestamp.timestamp = Date.now();
|
|
452
421
|
this.serializeValues(targetStorage, targetState);
|
|
453
422
|
}
|
|
454
|
-
}
|
|
423
|
+
};
|
|
455
424
|
control.on("valueChanged", listener);
|
|
456
425
|
this.serializeListeners[name] = listener;
|
|
457
426
|
}
|
|
458
427
|
}
|
|
459
428
|
serializeValues(storage, values) {
|
|
460
429
|
if (storage && values) {
|
|
461
|
-
const write =
|
|
462
|
-
const clear =
|
|
430
|
+
const write = async () => await storage.insert(values);
|
|
431
|
+
const clear = async () => await storage.clear();
|
|
463
432
|
forget3(clear());
|
|
464
433
|
forget3(write());
|
|
465
434
|
}
|
|
466
435
|
}
|
|
467
436
|
setStateValueFromStorage(name, control) {
|
|
468
|
-
const read =
|
|
437
|
+
const read = async () => {
|
|
469
438
|
const savedValue = await this.getSerializedValue(name, control.serializeSettings.sensitive);
|
|
470
439
|
if (savedValue) {
|
|
471
440
|
const targetState = control.serializeSettings.sensitive ? this.serializedSensitiveState : this.serializedState;
|
|
472
441
|
targetState[name] = savedValue;
|
|
473
|
-
control.setValue(savedValue, {
|
|
474
|
-
disableEmit: true
|
|
475
|
-
});
|
|
442
|
+
control.setValue(savedValue, { disableEmit: true });
|
|
476
443
|
}
|
|
477
|
-
}
|
|
444
|
+
};
|
|
478
445
|
forget3(read());
|
|
479
446
|
}
|
|
480
447
|
};
|
|
481
448
|
|
|
482
449
|
// src/context/Provider.tsx
|
|
483
|
-
|
|
450
|
+
import { jsx } from "react/jsx-runtime";
|
|
451
|
+
var FormGroupPayloadProvider = ({
|
|
452
|
+
children,
|
|
453
|
+
params,
|
|
454
|
+
...props
|
|
455
|
+
}) => {
|
|
484
456
|
const formGroup = useMemo(() => {
|
|
485
457
|
const formGroup2 = new FormGroup(params);
|
|
486
458
|
return formGroup2;
|
|
487
|
-
}, [
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
...props
|
|
499
|
-
}, children);
|
|
500
|
-
}, "FormGroupPayloadProvider");
|
|
459
|
+
}, [params]);
|
|
460
|
+
const value = useMemo(() => ({ formGroup, provided: true }), [formGroup]);
|
|
461
|
+
return /* @__PURE__ */ jsx(
|
|
462
|
+
FormGroupBaseContext,
|
|
463
|
+
{
|
|
464
|
+
value,
|
|
465
|
+
...props,
|
|
466
|
+
children
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
};
|
|
501
470
|
|
|
502
471
|
// src/context/use.ts
|
|
503
472
|
import { useContextEx } from "@xylabs/react-shared";
|
|
504
|
-
var useFormGroup =
|
|
473
|
+
var useFormGroup = (required = false) => useContextEx(FormGroupBaseContext, "FormGroup", required);
|
|
505
474
|
|
|
506
475
|
// src/storage/ArchivistFormGroupStorage.ts
|
|
507
476
|
var ArchivistFormGroupStorage = class {
|
|
508
|
-
static {
|
|
509
|
-
__name(this, "ArchivistFormGroupStorage");
|
|
510
|
-
}
|
|
511
477
|
archivist;
|
|
512
478
|
constructor(archivist) {
|
|
513
479
|
this.archivist = archivist;
|
|
@@ -520,9 +486,7 @@ var ArchivistFormGroupStorage = class {
|
|
|
520
486
|
return all.at(-1);
|
|
521
487
|
}
|
|
522
488
|
async insert(value) {
|
|
523
|
-
await this.archivist.insert?.([
|
|
524
|
-
value
|
|
525
|
-
]);
|
|
489
|
+
await this.archivist.insert?.([value]);
|
|
526
490
|
}
|
|
527
491
|
};
|
|
528
492
|
export {
|