@logixjs/form 0.0.1 → 1.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.
- package/LICENSE +201 -0
- package/dist/Form.cjs +110 -140
- package/dist/Form.cjs.map +1 -1
- package/dist/Form.d.cts +20 -17
- package/dist/Form.d.ts +20 -17
- package/dist/Form.js +2 -2
- package/dist/Rule.cjs +0 -1
- package/dist/Rule.cjs.map +1 -1
- package/dist/Rule.js +1 -1
- package/dist/{chunk-YVHXLY63.js → chunk-3U6VHYYQ.js} +2 -3
- package/dist/chunk-3U6VHYYQ.js.map +1 -0
- package/dist/{chunk-YHDEJ47V.js → chunk-WGBRLVRO.js} +80 -109
- package/dist/chunk-WGBRLVRO.js.map +1 -0
- package/dist/{impl-Ccdm5eDF.d.cts → impl-DWIHAuQq.d.cts} +29 -29
- package/dist/{impl-BfSlyM58.d.ts → impl-DXbfEc3o.d.ts} +29 -29
- package/dist/index.cjs +110 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/package.json +13 -7
- package/dist/chunk-YHDEJ47V.js.map +0 -1
- package/dist/chunk-YVHXLY63.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/Form.cjs
CHANGED
|
@@ -42,7 +42,7 @@ module.exports = __toCommonJS(Form_exports);
|
|
|
42
42
|
|
|
43
43
|
// src/internal/form/impl.ts
|
|
44
44
|
var Logix4 = __toESM(require("@logixjs/core"), 1);
|
|
45
|
-
var
|
|
45
|
+
var import_effect3 = require("effect");
|
|
46
46
|
|
|
47
47
|
// src/internal/form/traits.ts
|
|
48
48
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -1006,8 +1006,14 @@ var makeFormController = (params) => {
|
|
|
1006
1006
|
});
|
|
1007
1007
|
const state = yield* runtime.getState;
|
|
1008
1008
|
const { errors: _errors, ui: _ui, $form: _meta, ...values } = state;
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1009
|
+
const schemaTree = (() => {
|
|
1010
|
+
try {
|
|
1011
|
+
import_effect.Schema.decodeUnknownSync(params.valuesSchema)(values);
|
|
1012
|
+
return {};
|
|
1013
|
+
} catch (error) {
|
|
1014
|
+
return toSchemaErrorTree(error);
|
|
1015
|
+
}
|
|
1016
|
+
})();
|
|
1011
1017
|
yield* runtime.dispatch({
|
|
1012
1018
|
_tag: "setValue",
|
|
1013
1019
|
payload: { path: "errors.$schema", value: schemaTree }
|
|
@@ -1049,8 +1055,14 @@ var makeFormController = (params) => {
|
|
|
1049
1055
|
$form: _metaAfterRules,
|
|
1050
1056
|
...valuesAfterRules
|
|
1051
1057
|
} = stateAfterRules;
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1058
|
+
const schemaTree = (() => {
|
|
1059
|
+
try {
|
|
1060
|
+
import_effect.Schema.decodeUnknownSync(params.valuesSchema)(valuesAfterRules);
|
|
1061
|
+
return {};
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
return toSchemaErrorTree(error);
|
|
1064
|
+
}
|
|
1065
|
+
})();
|
|
1054
1066
|
yield* runtime.dispatch({
|
|
1055
1067
|
_tag: "setValue",
|
|
1056
1068
|
payload: { path: "errors.$schema", value: schemaTree }
|
|
@@ -1166,7 +1178,7 @@ var install = (module2, config) => module2.logic(($) => {
|
|
|
1166
1178
|
const prev = pending.get(path);
|
|
1167
1179
|
if (!prev) return;
|
|
1168
1180
|
pending.delete(path);
|
|
1169
|
-
yield* import_effect2.Fiber.
|
|
1181
|
+
yield* import_effect2.Fiber.interrupt(prev);
|
|
1170
1182
|
});
|
|
1171
1183
|
const scheduleDebouncedValidate = (path) => import_effect2.Effect.gen(function* () {
|
|
1172
1184
|
const ms = debounceMs ?? 0;
|
|
@@ -1177,9 +1189,9 @@ var install = (module2, config) => module2.logic(($) => {
|
|
|
1177
1189
|
yield* cancelPending(path);
|
|
1178
1190
|
const fiber = yield* import_effect2.Effect.forkScoped(
|
|
1179
1191
|
import_effect2.Effect.sleep(import_effect2.Duration.millis(ms)).pipe(
|
|
1180
|
-
import_effect2.Effect.
|
|
1192
|
+
import_effect2.Effect.flatMap(() => validate("valueChange", path)),
|
|
1181
1193
|
import_effect2.Effect.ensuring(import_effect2.Effect.sync(() => pending.delete(path))),
|
|
1182
|
-
import_effect2.Effect.
|
|
1194
|
+
import_effect2.Effect.catchCause(() => import_effect2.Effect.void)
|
|
1183
1195
|
)
|
|
1184
1196
|
);
|
|
1185
1197
|
pending.set(path, fiber);
|
|
@@ -1316,7 +1328,6 @@ var makeFormRulesManifestArtifactExporter = (params) => ({
|
|
|
1316
1328
|
});
|
|
1317
1329
|
|
|
1318
1330
|
// src/internal/validators/index.ts
|
|
1319
|
-
var import_effect3 = require("effect");
|
|
1320
1331
|
var ERROR_VALUE_MAX_BYTES = 256;
|
|
1321
1332
|
var textEncoder = new TextEncoder();
|
|
1322
1333
|
var jsonByteSize = (value) => {
|
|
@@ -1411,7 +1422,7 @@ var pattern = (decl) => {
|
|
|
1411
1422
|
var schemaErrorMessage = (schemaError) => {
|
|
1412
1423
|
let message;
|
|
1413
1424
|
try {
|
|
1414
|
-
message =
|
|
1425
|
+
message = schemaError instanceof Error ? schemaError.message || "schema invalid" : String(schemaError);
|
|
1415
1426
|
} catch {
|
|
1416
1427
|
message = "schema invalid";
|
|
1417
1428
|
}
|
|
@@ -1549,28 +1560,28 @@ var list = (listPath, spec) => ({
|
|
|
1549
1560
|
|
|
1550
1561
|
// src/internal/form/impl.ts
|
|
1551
1562
|
var FormActions = {
|
|
1552
|
-
setValue:
|
|
1553
|
-
blur:
|
|
1554
|
-
submit:
|
|
1555
|
-
validate:
|
|
1556
|
-
validatePaths:
|
|
1557
|
-
submitAttempt:
|
|
1558
|
-
setSubmitting:
|
|
1559
|
-
reset:
|
|
1560
|
-
setError:
|
|
1561
|
-
clearErrors:
|
|
1562
|
-
arrayAppend:
|
|
1563
|
-
arrayPrepend:
|
|
1564
|
-
arrayRemove:
|
|
1565
|
-
arraySwap:
|
|
1566
|
-
path:
|
|
1567
|
-
indexA:
|
|
1568
|
-
indexB:
|
|
1563
|
+
setValue: import_effect3.Schema.Struct({ path: import_effect3.Schema.String, value: import_effect3.Schema.Unknown }),
|
|
1564
|
+
blur: import_effect3.Schema.Struct({ path: import_effect3.Schema.String }),
|
|
1565
|
+
submit: import_effect3.Schema.Void,
|
|
1566
|
+
validate: import_effect3.Schema.Void,
|
|
1567
|
+
validatePaths: import_effect3.Schema.Array(import_effect3.Schema.String),
|
|
1568
|
+
submitAttempt: import_effect3.Schema.Void,
|
|
1569
|
+
setSubmitting: import_effect3.Schema.Boolean,
|
|
1570
|
+
reset: import_effect3.Schema.UndefinedOr(import_effect3.Schema.Unknown),
|
|
1571
|
+
setError: import_effect3.Schema.Struct({ path: import_effect3.Schema.String, error: import_effect3.Schema.Unknown }),
|
|
1572
|
+
clearErrors: import_effect3.Schema.UndefinedOr(import_effect3.Schema.Array(import_effect3.Schema.String)),
|
|
1573
|
+
arrayAppend: import_effect3.Schema.Struct({ path: import_effect3.Schema.String, value: import_effect3.Schema.Unknown }),
|
|
1574
|
+
arrayPrepend: import_effect3.Schema.Struct({ path: import_effect3.Schema.String, value: import_effect3.Schema.Unknown }),
|
|
1575
|
+
arrayRemove: import_effect3.Schema.Struct({ path: import_effect3.Schema.String, index: import_effect3.Schema.Number }),
|
|
1576
|
+
arraySwap: import_effect3.Schema.Struct({
|
|
1577
|
+
path: import_effect3.Schema.String,
|
|
1578
|
+
indexA: import_effect3.Schema.Number,
|
|
1579
|
+
indexB: import_effect3.Schema.Number
|
|
1569
1580
|
}),
|
|
1570
|
-
arrayMove:
|
|
1571
|
-
path:
|
|
1572
|
-
from:
|
|
1573
|
-
to:
|
|
1581
|
+
arrayMove: import_effect3.Schema.Struct({
|
|
1582
|
+
path: import_effect3.Schema.String,
|
|
1583
|
+
from: import_effect3.Schema.Number,
|
|
1584
|
+
to: import_effect3.Schema.Number
|
|
1574
1585
|
})
|
|
1575
1586
|
};
|
|
1576
1587
|
var initialMeta2 = () => ({
|
|
@@ -1580,22 +1591,20 @@ var initialMeta2 = () => ({
|
|
|
1580
1591
|
errorCount: 0
|
|
1581
1592
|
});
|
|
1582
1593
|
var make2 = (id, config, extend) => {
|
|
1583
|
-
const ErrorsSchema =
|
|
1584
|
-
const UiSchema =
|
|
1585
|
-
const MetaSchema =
|
|
1586
|
-
submitCount:
|
|
1587
|
-
isSubmitting:
|
|
1588
|
-
isDirty:
|
|
1589
|
-
errorCount:
|
|
1594
|
+
const ErrorsSchema = import_effect3.Schema.Unknown;
|
|
1595
|
+
const UiSchema = import_effect3.Schema.Unknown;
|
|
1596
|
+
const MetaSchema = import_effect3.Schema.Struct({
|
|
1597
|
+
submitCount: import_effect3.Schema.Number,
|
|
1598
|
+
isSubmitting: import_effect3.Schema.Boolean,
|
|
1599
|
+
isDirty: import_effect3.Schema.Boolean,
|
|
1600
|
+
errorCount: import_effect3.Schema.Number
|
|
1601
|
+
});
|
|
1602
|
+
const StateSchema = import_effect3.Schema.Struct({
|
|
1603
|
+
...config.values.fields ?? {},
|
|
1604
|
+
errors: ErrorsSchema,
|
|
1605
|
+
ui: UiSchema,
|
|
1606
|
+
$form: MetaSchema
|
|
1590
1607
|
});
|
|
1591
|
-
const StateSchema = import_effect4.Schema.extend(
|
|
1592
|
-
config.values,
|
|
1593
|
-
import_effect4.Schema.Struct({
|
|
1594
|
-
errors: ErrorsSchema,
|
|
1595
|
-
ui: UiSchema,
|
|
1596
|
-
$form: MetaSchema
|
|
1597
|
-
})
|
|
1598
|
-
);
|
|
1599
1608
|
const Actions = FormActions;
|
|
1600
1609
|
const reducers = makeFormReducers({
|
|
1601
1610
|
initialValues: config.initialValues
|
|
@@ -1637,67 +1646,60 @@ var make2 = (id, config, extend) => {
|
|
|
1637
1646
|
if (mode === "store" || mode === "index") return;
|
|
1638
1647
|
throw new Error(`[Form.make] Invalid identity.mode for "${listPath}" (got "${String(mode)}")`);
|
|
1639
1648
|
};
|
|
1649
|
+
const isRelativeRuleDep = (dep, options) => {
|
|
1650
|
+
const allowNumericRelativeDep = options?.allowNumericRelativeDep ?? true;
|
|
1651
|
+
if (dep === "$root") return false;
|
|
1652
|
+
if (dep.includes("[") || dep.includes("]") || dep.includes(".")) return false;
|
|
1653
|
+
if (!allowNumericRelativeDep && /^[0-9]+$/.test(dep)) return false;
|
|
1654
|
+
return true;
|
|
1655
|
+
};
|
|
1656
|
+
const prefixRuleDeps = (deps, prefix, options) => {
|
|
1657
|
+
if (!Array.isArray(deps)) return void 0;
|
|
1658
|
+
const out = [];
|
|
1659
|
+
for (const raw of deps) {
|
|
1660
|
+
if (typeof raw !== "string") continue;
|
|
1661
|
+
const dep = raw.trim();
|
|
1662
|
+
if (!dep) continue;
|
|
1663
|
+
out.push(isRelativeRuleDep(dep, options) && prefix ? `${prefix}.${dep}` : dep);
|
|
1664
|
+
}
|
|
1665
|
+
return out;
|
|
1666
|
+
};
|
|
1667
|
+
const prefixRuleInputDeps = (input, prefix, options) => {
|
|
1668
|
+
if (!input || typeof input !== "object") return input;
|
|
1669
|
+
if (Array.isArray(input)) return input;
|
|
1670
|
+
const anyInput = input;
|
|
1671
|
+
const deps = prefixRuleDeps(anyInput.deps, prefix, options);
|
|
1672
|
+
const validate = anyInput.validate;
|
|
1673
|
+
if (typeof validate === "function") {
|
|
1674
|
+
return deps !== void 0 ? { ...anyInput, deps } : input;
|
|
1675
|
+
}
|
|
1676
|
+
if (validate && typeof validate === "object" && !Array.isArray(validate)) {
|
|
1677
|
+
const nextValidate = { ...validate };
|
|
1678
|
+
for (const [name, raw] of Object.entries(validate)) {
|
|
1679
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
1680
|
+
const entryDeps = prefixRuleDeps(raw.deps, prefix, options);
|
|
1681
|
+
if (entryDeps !== void 0) {
|
|
1682
|
+
nextValidate[name] = { ...raw, deps: entryDeps };
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
return {
|
|
1686
|
+
...anyInput,
|
|
1687
|
+
...deps !== void 0 ? { deps } : {},
|
|
1688
|
+
validate: nextValidate
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
return deps !== void 0 ? { ...anyInput, deps } : input;
|
|
1692
|
+
};
|
|
1640
1693
|
const compileRulesToTraitSpec = (rulesSpec2) => {
|
|
1641
1694
|
if (!rulesSpec2 || rulesSpec2._tag !== "FormRulesSpec") {
|
|
1642
1695
|
throw new Error(`[Form.make] "rules" must be a FormRulesSpec (from Form.rules(...)/rules.schema(...))`);
|
|
1643
1696
|
}
|
|
1644
|
-
const joinPath2 = (prefix, suffix) => {
|
|
1645
|
-
if (!prefix) return suffix;
|
|
1646
|
-
if (!suffix) return prefix;
|
|
1647
|
-
return `${prefix}.${suffix}`;
|
|
1648
|
-
};
|
|
1649
1697
|
const dirnamePath = (path) => {
|
|
1650
1698
|
const p = String(path ?? "").trim();
|
|
1651
1699
|
if (!p) return "";
|
|
1652
1700
|
const idx = p.lastIndexOf(".");
|
|
1653
1701
|
return idx >= 0 ? p.slice(0, idx) : "";
|
|
1654
1702
|
};
|
|
1655
|
-
const isRelativeDep = (dep) => {
|
|
1656
|
-
if (typeof dep !== "string") return false;
|
|
1657
|
-
const d = dep.trim();
|
|
1658
|
-
if (!d) return false;
|
|
1659
|
-
if (d === "$root") return false;
|
|
1660
|
-
if (d.includes("[") || d.includes("]")) return false;
|
|
1661
|
-
if (d.includes(".")) return false;
|
|
1662
|
-
return true;
|
|
1663
|
-
};
|
|
1664
|
-
const prefixDeps = (deps, prefix) => {
|
|
1665
|
-
if (!Array.isArray(deps)) return void 0;
|
|
1666
|
-
const out = [];
|
|
1667
|
-
for (const raw of deps) {
|
|
1668
|
-
if (typeof raw !== "string") continue;
|
|
1669
|
-
const d = raw.trim();
|
|
1670
|
-
if (!d) continue;
|
|
1671
|
-
out.push(isRelativeDep(d) ? joinPath2(prefix, d) : d);
|
|
1672
|
-
}
|
|
1673
|
-
return out;
|
|
1674
|
-
};
|
|
1675
|
-
const prefixRuleInputDeps = (input, prefix) => {
|
|
1676
|
-
if (!input || typeof input !== "object") return input;
|
|
1677
|
-
if (Array.isArray(input)) return input;
|
|
1678
|
-
const anyInput = input;
|
|
1679
|
-
const deps = prefixDeps(anyInput.deps, prefix);
|
|
1680
|
-
const validate = anyInput.validate;
|
|
1681
|
-
if (typeof validate === "function") {
|
|
1682
|
-
return deps !== void 0 ? { ...anyInput, deps } : input;
|
|
1683
|
-
}
|
|
1684
|
-
if (validate && typeof validate === "object" && !Array.isArray(validate)) {
|
|
1685
|
-
const nextValidate = { ...validate };
|
|
1686
|
-
for (const [name, raw] of Object.entries(validate)) {
|
|
1687
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
1688
|
-
const entryDeps = prefixDeps(raw.deps, prefix);
|
|
1689
|
-
if (entryDeps !== void 0) {
|
|
1690
|
-
nextValidate[name] = { ...raw, deps: entryDeps };
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
return {
|
|
1694
|
-
...anyInput,
|
|
1695
|
-
...deps !== void 0 ? { deps } : {},
|
|
1696
|
-
validate: nextValidate
|
|
1697
|
-
};
|
|
1698
|
-
}
|
|
1699
|
-
return deps !== void 0 ? { ...anyInput, deps } : input;
|
|
1700
|
-
};
|
|
1701
1703
|
const decls = Array.isArray(rulesSpec2.decls) ? rulesSpec2.decls : [];
|
|
1702
1704
|
const spec = {};
|
|
1703
1705
|
const declared = /* @__PURE__ */ new Set();
|
|
@@ -1872,45 +1874,9 @@ var make2 = (id, config, extend) => {
|
|
|
1872
1874
|
const idx = valuePath.lastIndexOf(".");
|
|
1873
1875
|
return idx >= 0 ? valuePath.slice(0, idx) : "";
|
|
1874
1876
|
})();
|
|
1875
|
-
const
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
for (const raw of deps) {
|
|
1879
|
-
if (typeof raw !== "string") continue;
|
|
1880
|
-
const d = raw.trim();
|
|
1881
|
-
if (!d) continue;
|
|
1882
|
-
const isRelative = d !== "$root" && !d.includes("[") && !d.includes("]") && !d.includes(".") && !/^[0-9]+$/.test(d);
|
|
1883
|
-
out.push(isRelative && prefix ? `${prefix}.${d}` : d);
|
|
1884
|
-
}
|
|
1885
|
-
return out;
|
|
1886
|
-
};
|
|
1887
|
-
const prefixRuleInputDeps = (input, prefix) => {
|
|
1888
|
-
if (!input || typeof input !== "object") return input;
|
|
1889
|
-
if (Array.isArray(input)) return input;
|
|
1890
|
-
const anyInput = input;
|
|
1891
|
-
const deps = prefixDeps(anyInput.deps, prefix);
|
|
1892
|
-
const validate = anyInput.validate;
|
|
1893
|
-
if (typeof validate === "function") {
|
|
1894
|
-
return deps !== void 0 ? { ...anyInput, deps } : input;
|
|
1895
|
-
}
|
|
1896
|
-
if (validate && typeof validate === "object" && !Array.isArray(validate)) {
|
|
1897
|
-
const nextValidate = { ...validate };
|
|
1898
|
-
for (const [ruleName, raw] of Object.entries(validate)) {
|
|
1899
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
1900
|
-
const entryDeps = prefixDeps(raw.deps, prefix);
|
|
1901
|
-
if (entryDeps !== void 0) {
|
|
1902
|
-
nextValidate[ruleName] = { ...raw, deps: entryDeps };
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
return {
|
|
1906
|
-
...anyInput,
|
|
1907
|
-
...deps !== void 0 ? { deps } : {},
|
|
1908
|
-
validate: nextValidate
|
|
1909
|
-
};
|
|
1910
|
-
}
|
|
1911
|
-
return deps !== void 0 ? { ...anyInput, deps } : input;
|
|
1912
|
-
};
|
|
1913
|
-
const ruleInput = prefixRuleInputDeps(decl.rule, depsPrefix);
|
|
1877
|
+
const ruleInput = prefixRuleInputDeps(decl.rule, depsPrefix, {
|
|
1878
|
+
allowNumericRelativeDep: false
|
|
1879
|
+
});
|
|
1914
1880
|
const rules3 = make(ruleInput);
|
|
1915
1881
|
emitRuleSet({
|
|
1916
1882
|
source: "rules",
|
|
@@ -2137,7 +2103,7 @@ var derived = (_valuesSchema) => {
|
|
|
2137
2103
|
};
|
|
2138
2104
|
|
|
2139
2105
|
// src/internal/dsl/rules.ts
|
|
2140
|
-
var
|
|
2106
|
+
var import_effect4 = require("effect");
|
|
2141
2107
|
var normalizePrefix = (prefix) => {
|
|
2142
2108
|
const p = String(prefix ?? "").trim();
|
|
2143
2109
|
if (!p) return "";
|
|
@@ -2190,8 +2156,12 @@ var makeFieldNode = (rule) => ({
|
|
|
2190
2156
|
var fieldFromSchema = (schema) => ({
|
|
2191
2157
|
validate: {
|
|
2192
2158
|
schema: (value) => {
|
|
2193
|
-
|
|
2194
|
-
|
|
2159
|
+
try {
|
|
2160
|
+
import_effect4.Schema.decodeUnknownSync(schema)(value);
|
|
2161
|
+
return void 0;
|
|
2162
|
+
} catch (error) {
|
|
2163
|
+
return schemaErrorMessage(error);
|
|
2164
|
+
}
|
|
2195
2165
|
}
|
|
2196
2166
|
}
|
|
2197
2167
|
});
|
|
@@ -2415,7 +2385,7 @@ var rules = (_valuesSchema) => {
|
|
|
2415
2385
|
return field(args[0], args[1], args[2]);
|
|
2416
2386
|
}
|
|
2417
2387
|
const input = args[0];
|
|
2418
|
-
if (
|
|
2388
|
+
if (import_effect4.Schema.isSchema(input)) return makeFieldNode(fieldFromSchema(input));
|
|
2419
2389
|
return makeFieldNode(input);
|
|
2420
2390
|
}
|
|
2421
2391
|
build.field = field2;
|