@resistdesign/voltra 3.0.0-alpha.5 → 3.0.0-alpha.51

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 (222) hide show
  1. package/README.md +392 -14
  2. package/api/DBX/DBXAsserts.d.ts +95 -0
  3. package/api/DBX/DBXRequest.d.ts +5 -0
  4. package/api/DBX/DBXRuntime.d.ts +5 -0
  5. package/api/DBX/DBXScenarioConfig.d.ts +9 -0
  6. package/api/DBX/DBXSeed.d.ts +124 -0
  7. package/api/DBX/DBXTypes.d.ts +176 -0
  8. package/api/DBX/index.d.ts +8 -0
  9. package/api/DataAccessControl.d.ts +220 -0
  10. package/api/Indexing/API.d.ts +224 -0
  11. package/api/Indexing/Cursor.d.ts +101 -0
  12. package/api/Indexing/Handler/Config.d.ts +39 -0
  13. package/api/Indexing/Handler.d.ts +166 -0
  14. package/api/Indexing/Trace.d.ts +54 -0
  15. package/api/Indexing/Types.d.ts +204 -0
  16. package/api/Indexing/ddb/AwsSdkV3Adapter.d.ts +8 -0
  17. package/api/Indexing/ddb/Types.d.ts +209 -0
  18. package/api/Indexing/docId.d.ts +27 -0
  19. package/api/Indexing/exact/ExactDdb.d.ts +58 -0
  20. package/api/Indexing/exact/ExactIndex.d.ts +90 -0
  21. package/api/Indexing/exact/ExactS3.d.ts +41 -0
  22. package/api/Indexing/fieldQualification.d.ts +12 -0
  23. package/api/Indexing/fulltext/FullTextDdbBackend.d.ts +212 -0
  24. package/api/Indexing/fulltext/FullTextMemoryBackend.d.ts +93 -0
  25. package/api/Indexing/fulltext/Schema.d.ts +164 -0
  26. package/api/Indexing/hashUniversal.d.ts +13 -0
  27. package/api/Indexing/index.d.ts +45 -0
  28. package/api/Indexing/lossy/LossyDdb.d.ts +43 -0
  29. package/api/Indexing/lossy/LossyIndex.d.ts +72 -0
  30. package/api/Indexing/lossy/LossyS3.d.ts +40 -0
  31. package/api/Indexing/rel/Cursor.d.ts +25 -0
  32. package/api/Indexing/rel/Handlers.d.ts +144 -0
  33. package/api/Indexing/rel/RelationalDdb.d.ts +169 -0
  34. package/api/Indexing/rel/RelationalInMemoryBackend.d.ts +38 -0
  35. package/api/Indexing/rel/Types.d.ts +69 -0
  36. package/api/Indexing/structured/Cursor.d.ts +26 -0
  37. package/api/Indexing/structured/Handlers.d.ts +128 -0
  38. package/api/Indexing/structured/SearchStructured.d.ts +44 -0
  39. package/api/Indexing/structured/StructuredDdb.d.ts +184 -0
  40. package/api/Indexing/structured/StructuredDdbBackend.d.ts +112 -0
  41. package/api/Indexing/structured/StructuredInMemoryBackend.d.ts +40 -0
  42. package/api/Indexing/structured/StructuredInMemoryIndex.d.ts +61 -0
  43. package/api/Indexing/structured/StructuredStringLike.d.ts +54 -0
  44. package/api/Indexing/structured/StructuredWriter.d.ts +74 -0
  45. package/api/Indexing/structured/Types.d.ts +126 -0
  46. package/api/Indexing/structured/index.d.ts +9 -0
  47. package/api/Indexing/tokenize.d.ts +31 -0
  48. package/api/ORM/DACUtils.d.ts +270 -0
  49. package/api/ORM/ListItemUtils.d.ts +40 -0
  50. package/api/ORM/ORMRouteMap.d.ts +70 -0
  51. package/api/ORM/TypeInfoORMService.d.ts +879 -0
  52. package/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +229 -0
  53. package/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +90 -0
  54. package/api/ORM/drivers/InMemoryDataItemDBDriver/ConfigTypes.d.ts +4 -0
  55. package/api/ORM/drivers/InMemoryDataItemDBDriver.d.ts +56 -0
  56. package/api/ORM/drivers/InMemoryFileItemDBDriver/ConfigTypes.d.ts +13 -0
  57. package/api/ORM/drivers/InMemoryFileItemDBDriver.d.ts +98 -0
  58. package/api/ORM/drivers/InMemoryItemRelationshipDBDriver.d.ts +16 -0
  59. package/api/ORM/drivers/IndexingRelationshipDriver.d.ts +123 -0
  60. package/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +322 -0
  61. package/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +118 -0
  62. package/api/ORM/drivers/S3FileItemDBDriver.d.ts +71 -0
  63. package/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +36 -0
  64. package/api/ORM/drivers/common/Types.d.ts +202 -0
  65. package/api/ORM/drivers/common/index.d.ts +2 -0
  66. package/api/ORM/drivers/index.d.ts +8 -0
  67. package/api/ORM/getTypeInfoORMIndexingConfigFromTypeInfoMap.d.ts +31 -0
  68. package/api/ORM/index.d.ts +10 -0
  69. package/api/ORM/indexing/criteriaToStructuredWhere.d.ts +22 -0
  70. package/api/Router/AWS.d.ts +80 -0
  71. package/api/Router/Auth.d.ts +14 -0
  72. package/api/Router/CORS.d.ts +66 -0
  73. package/api/Router/Types.d.ts +138 -0
  74. package/api/Router/index.d.ts +89 -0
  75. package/api/index.d.ts +72 -6
  76. package/api/index.js +3553 -1948
  77. package/app/forms/Engine.d.ts +23 -0
  78. package/app/forms/UI.d.ts +83 -0
  79. package/app/forms/core/createAutoField.d.ts +43 -0
  80. package/app/forms/core/createFormRenderer.d.ts +25 -0
  81. package/app/forms/core/getFieldKind.d.ts +14 -0
  82. package/app/forms/core/index.d.ts +11 -0
  83. package/app/forms/core/mergeSuites.d.ts +23 -0
  84. package/app/forms/core/resolveSuite.d.ts +15 -0
  85. package/app/forms/core/types.d.ts +180 -0
  86. package/app/forms/index.d.ts +9 -0
  87. package/app/forms/types.d.ts +137 -0
  88. package/app/helpers/styled.d.ts +3 -0
  89. package/app/index.d.ts +116 -5
  90. package/app/index.js +120 -382
  91. package/app/utils/ApplicationState.d.ts +161 -0
  92. package/app/utils/ApplicationStateLoader.d.ts +91 -0
  93. package/app/utils/Controller.d.ts +10 -0
  94. package/app/utils/Debug.d.ts +14 -0
  95. package/app/utils/EasyLayout.d.ts +89 -0
  96. package/app/utils/History.d.ts +165 -0
  97. package/app/utils/Route.d.ts +207 -0
  98. package/app/utils/RouteHistory.d.ts +27 -0
  99. package/app/utils/Service.d.ts +45 -0
  100. package/app/utils/TypeInfoORMAPIUtils.d.ts +94 -0
  101. package/app/utils/TypeInfoORMClient.d.ts +104 -0
  102. package/app/utils/UniversalRouteAdapter.d.ts +73 -0
  103. package/app/utils/easy-layout/computeAreaBounds.d.ts +5 -0
  104. package/app/utils/easy-layout/computeTracks.d.ts +16 -0
  105. package/app/utils/easy-layout/index.d.ts +5 -0
  106. package/app/utils/easy-layout/parseTemplate.d.ts +12 -0
  107. package/app/utils/easy-layout/types.d.ts +52 -0
  108. package/app/utils/easy-layout/validateAreas.d.ts +5 -0
  109. package/app/utils/index.d.ts +24 -0
  110. package/build/TypeMapping.d.ts +17 -0
  111. package/build/TypeParsing.d.ts +10 -0
  112. package/build/index.d.ts +15 -0
  113. package/build/index.js +569 -0
  114. package/chunk-2JDOM6PB.js +138 -0
  115. package/chunk-3HVYVX3S.js +546 -0
  116. package/chunk-ATO2455Q.js +258 -0
  117. package/chunk-BSHQIRBV.js +71 -0
  118. package/chunk-I2KLQ2HA.js +19 -0
  119. package/chunk-K4R2PFNG.js +1258 -0
  120. package/chunk-TJFTWPXQ.js +39 -0
  121. package/chunk-XHOMAXLR.js +84 -0
  122. package/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +9 -0
  123. package/common/CommandLine/index.d.ts +6 -0
  124. package/common/HelperTypes.d.ts +9 -0
  125. package/common/IdGeneration/getSimpleId.d.ts +8 -0
  126. package/common/IdGeneration/index.d.ts +1 -0
  127. package/common/ItemRelationshipInfoTypes.d.ts +64 -0
  128. package/common/ItemRelationships/ItemRelationshipValidation.d.ts +21 -0
  129. package/common/ItemRelationships/index.d.ts +2 -0
  130. package/common/Logging/Utils.d.ts +10 -0
  131. package/common/Logging/index.d.ts +1 -0
  132. package/common/Routing.d.ts +81 -0
  133. package/common/SearchTypes.d.ts +227 -0
  134. package/common/SearchUtils.d.ts +55 -0
  135. package/common/SearchValidation.d.ts +27 -0
  136. package/common/StringTransformers.d.ts +28 -0
  137. package/common/Testing/CLI.d.ts +6 -0
  138. package/common/Testing/Types.d.ts +216 -0
  139. package/common/Testing/Utils.d.ts +112 -0
  140. package/common/Testing/index.d.ts +8 -0
  141. package/common/TypeInfoDataItemUtils.d.ts +39 -0
  142. package/{Types-C7XjUjoF.d.ts → common/TypeInfoORM/Types.d.ts} +150 -20
  143. package/common/TypeInfoORM/index.d.ts +3 -0
  144. package/common/TypeParsing/Constants.d.ts +4 -0
  145. package/common/TypeParsing/ParsingUtils/Constants.d.ts +8 -0
  146. package/common/TypeParsing/ParsingUtils/checkType.d.ts +14 -0
  147. package/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +12 -0
  148. package/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +8 -0
  149. package/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +12 -0
  150. package/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +14 -0
  151. package/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +18 -0
  152. package/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +9 -0
  153. package/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +9 -0
  154. package/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +11 -0
  155. package/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +12 -0
  156. package/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +11 -0
  157. package/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +9 -0
  158. package/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +11 -0
  159. package/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +8 -0
  160. package/common/TypeParsing/TypeInfo.d.ts +235 -0
  161. package/common/TypeParsing/Utils.d.ts +47 -0
  162. package/common/TypeParsing/Validation.d.ts +327 -0
  163. package/common/TypeParsing/index.d.ts +8 -0
  164. package/common/index.d.ts +47 -4
  165. package/common/index.js +25 -1737
  166. package/{index-BkFZlfit.d.ts → iac/SimpleCFT.d.ts} +5 -25
  167. package/iac/index.d.ts +40 -2
  168. package/iac/index.js +2 -1661
  169. package/iac/packs/auth.d.ts +131 -0
  170. package/iac/packs/build/utils.d.ts +289 -0
  171. package/iac/packs/build.d.ts +92 -0
  172. package/iac/packs/cdn.d.ts +33 -0
  173. package/iac/packs/cloud-function.d.ts +67 -0
  174. package/iac/packs/database.d.ts +32 -0
  175. package/iac/packs/dns.d.ts +34 -0
  176. package/iac/packs/file-storage.d.ts +46 -0
  177. package/iac/packs/gateway.d.ts +82 -0
  178. package/iac/packs/index.d.ts +60 -1
  179. package/iac/packs/index.js +391 -594
  180. package/iac/packs/repo.d.ts +28 -0
  181. package/iac/packs/ssl-certificate.d.ts +28 -0
  182. package/iac/types/Constants.d.ts +24 -0
  183. package/{index-DcvJOZ_c.d.ts → iac/types/IaCTypes.d.ts} +23 -1018
  184. package/iac/types/Renderers.d.ts +96 -0
  185. package/iac/types/Types.d.ts +131 -0
  186. package/iac/types/Utils.d.ts +9 -0
  187. package/iac/types/generate.d.ts +1 -0
  188. package/iac/utils/index.d.ts +87 -0
  189. package/iac/utils/patch-utils.d.ts +66 -0
  190. package/iac-packs/index.d.ts +6 -0
  191. package/native/forms/UI.d.ts +73 -0
  192. package/native/forms/createNativeFormRenderer.d.ts +21 -0
  193. package/native/forms/index.d.ts +25 -0
  194. package/native/forms/primitives/index.d.ts +38 -0
  195. package/native/forms/suite.d.ts +15 -0
  196. package/native/index.d.ts +19 -0
  197. package/native/index.js +792 -0
  198. package/native/testing/react-native.d.ts +46 -0
  199. package/native/utils/EasyLayout.d.ts +88 -0
  200. package/native/utils/History.d.ts +124 -0
  201. package/native/utils/NavButton.d.ts +25 -0
  202. package/native/utils/Route.d.ts +41 -0
  203. package/native/utils/index.d.ts +25 -0
  204. package/package.json +54 -21
  205. package/web/forms/UI.d.ts +74 -0
  206. package/web/forms/createWebFormRenderer.d.ts +21 -0
  207. package/web/forms/index.d.ts +9 -0
  208. package/web/forms/primitives/index.d.ts +21 -0
  209. package/web/forms/suite.d.ts +15 -0
  210. package/web/index.d.ts +15 -0
  211. package/web/index.js +701 -0
  212. package/web/utils/EasyLayout.d.ts +47 -0
  213. package/web/utils/NavLink.d.ts +24 -0
  214. package/web/utils/Route.d.ts +16 -0
  215. package/web/utils/index.d.ts +8 -0
  216. package/SearchTypes-DjN6YQzE.d.ts +0 -577
  217. package/Validation-CFP59oIP.d.ts +0 -226
  218. package/index-C3-iD9Mh.d.ts +0 -690
  219. package/index-CK5Qwvfb.d.ts +0 -5378
  220. package/index-IokxSNxm.d.ts +0 -745
  221. package/index.d.ts +0 -13
  222. package/index.js +0 -11005
@@ -0,0 +1,1258 @@
1
+ import { getErrorDescriptor, getNoErrorDescriptor, validateTypeInfoDataItem, getArrayItemErrorMap, getErrorDescriptors, ERROR_MESSAGE_CONSTANTS } from './chunk-3HVYVX3S.js';
2
+ import { resolveRouteAdapterPath, getPathString, mergeStringPaths, getParamsAndTestPath, getPathArray, PATH_DELIMITER } from './chunk-2JDOM6PB.js';
3
+ import { createContext, useContext, useMemo, useState, useEffect, useCallback, createElement, useRef } from 'react';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+
6
+ // src/app/utils/easy-layout/parseTemplate.ts
7
+ var parseTrackSpec = (token) => {
8
+ const trimmed = token.trim();
9
+ const numericMatch = trimmed.match(/^([0-9]*\.?[0-9]+)(fr|px|%)$/);
10
+ if (!numericMatch) {
11
+ throw new Error(
12
+ `Invalid track token "${trimmed}". Supported units are fr, px, and %.`
13
+ );
14
+ }
15
+ const value = Number(numericMatch[1]);
16
+ const suffix = numericMatch[2];
17
+ if (!Number.isFinite(value) || value < 0) {
18
+ throw new Error(`Track value must be a non-negative number. Received "${trimmed}".`);
19
+ }
20
+ if (suffix === "fr") {
21
+ return { kind: "fr", value };
22
+ }
23
+ if (suffix === "px") {
24
+ return { kind: "px", value };
25
+ }
26
+ return { kind: "pct", value };
27
+ };
28
+ var normalizeAreas = (areaPart) => {
29
+ return areaPart.trim().split(/\s+/g).map((token) => token.trim()).filter(Boolean);
30
+ };
31
+ var parseTemplate = (template = "") => {
32
+ const lines = template.split("\n").map((line) => line.trim()).filter(Boolean);
33
+ const areaGrid = [];
34
+ const rowTracks = [];
35
+ let colTracks = null;
36
+ for (const line of lines) {
37
+ if (line.startsWith("\\")) {
38
+ if (colTracks) {
39
+ throw new Error("Template can include only one column-track line.");
40
+ }
41
+ const colTokens = line.replace(/\\/g, " ").trim().split(/\s+/g).filter(Boolean);
42
+ colTracks = colTokens.map(parseTrackSpec);
43
+ continue;
44
+ }
45
+ const parts = line.split(",").map((part) => part.trim());
46
+ const areaPart = parts[0] || "";
47
+ if (!areaPart) {
48
+ continue;
49
+ }
50
+ if (parts.length > 2) {
51
+ throw new Error(
52
+ `Invalid row definition "${line}". Expected "<areas>, <row-track>".`
53
+ );
54
+ }
55
+ const areas = normalizeAreas(areaPart);
56
+ if (!areas.length) {
57
+ continue;
58
+ }
59
+ areaGrid.push(areas);
60
+ const rowTrack = parts[1];
61
+ if (rowTrack) {
62
+ rowTracks.push(parseTrackSpec(rowTrack));
63
+ }
64
+ }
65
+ if (!areaGrid.length) {
66
+ throw new Error("Template must include at least one area row.");
67
+ }
68
+ const expectedWidth = areaGrid[0].length;
69
+ for (let rowIndex = 0; rowIndex < areaGrid.length; rowIndex++) {
70
+ const width = areaGrid[rowIndex].length;
71
+ if (width !== expectedWidth) {
72
+ throw new Error(
73
+ `All area rows must have the same width. Expected ${expectedWidth}, received ${width} at row ${rowIndex + 1}.`
74
+ );
75
+ }
76
+ }
77
+ if (colTracks && colTracks.length !== expectedWidth) {
78
+ throw new Error(
79
+ `Column track count must match area width. Expected ${expectedWidth}, received ${colTracks.length}.`
80
+ );
81
+ }
82
+ const areaNames = Array.from(
83
+ new Set(
84
+ areaGrid.flat().map((name) => name.trim()).filter((name) => !!name && name !== ".")
85
+ )
86
+ );
87
+ return {
88
+ areaGrid,
89
+ rowTracks,
90
+ colTracks: colTracks || [],
91
+ areaNames
92
+ };
93
+ };
94
+
95
+ // src/app/utils/easy-layout/computeAreaBounds.ts
96
+ var computeAreaBounds = (parsed) => {
97
+ const result = {};
98
+ for (let rowIndex = 0; rowIndex < parsed.areaGrid.length; rowIndex++) {
99
+ const row = parsed.areaGrid[rowIndex];
100
+ for (let colIndex = 0; colIndex < row.length; colIndex++) {
101
+ const name = row[colIndex];
102
+ if (!name || name === ".") {
103
+ continue;
104
+ }
105
+ const row1 = rowIndex + 1;
106
+ const col1 = colIndex + 1;
107
+ const existing = result[name];
108
+ if (!existing) {
109
+ result[name] = {
110
+ name,
111
+ rowStart: row1,
112
+ rowEnd: row1,
113
+ colStart: col1,
114
+ colEnd: col1
115
+ };
116
+ continue;
117
+ }
118
+ existing.rowStart = Math.min(existing.rowStart, row1);
119
+ existing.rowEnd = Math.max(existing.rowEnd, row1);
120
+ existing.colStart = Math.min(existing.colStart, col1);
121
+ existing.colEnd = Math.max(existing.colEnd, col1);
122
+ }
123
+ }
124
+ return result;
125
+ };
126
+
127
+ // src/app/utils/easy-layout/validateAreas.ts
128
+ var validateAreas = (parsed) => {
129
+ const bounds = computeAreaBounds(parsed);
130
+ for (const areaName of parsed.areaNames) {
131
+ const bound = bounds[areaName];
132
+ if (!bound) {
133
+ continue;
134
+ }
135
+ for (let row = bound.rowStart; row <= bound.rowEnd; row++) {
136
+ for (let col = bound.colStart; col <= bound.colEnd; col++) {
137
+ const token = parsed.areaGrid[row - 1]?.[col - 1];
138
+ if (token !== areaName) {
139
+ throw new Error(
140
+ `Area "${areaName}" must be a rectangle. Missing "${areaName}" at row ${row}, col ${col}.`
141
+ );
142
+ }
143
+ }
144
+ }
145
+ }
146
+ };
147
+
148
+ // src/app/utils/History.ts
149
+ var createHistoryBackHandler = (history) => {
150
+ return {
151
+ /**
152
+ * @returns True when back navigation was handled by history.
153
+ */
154
+ handle: () => {
155
+ if (history.index > 0) {
156
+ history.back();
157
+ return true;
158
+ }
159
+ return false;
160
+ }
161
+ };
162
+ };
163
+ var ensurePrefix = (value, prefix) => value ? value.startsWith(prefix) ? value : `${prefix}${value}` : "";
164
+ var parseHistoryPath = (inputPath) => {
165
+ const raw = String(inputPath ?? "").trim();
166
+ if (!raw) {
167
+ return { path: "/" };
168
+ }
169
+ try {
170
+ const absoluteUrl = new URL(raw);
171
+ return {
172
+ path: absoluteUrl.pathname || "/",
173
+ ...absoluteUrl.search ? { search: absoluteUrl.search } : {},
174
+ ...absoluteUrl.hash ? { hash: absoluteUrl.hash } : {}
175
+ };
176
+ } catch (error) {
177
+ let target = raw;
178
+ let hash = "";
179
+ let search = "";
180
+ const hashIndex = target.indexOf("#");
181
+ if (hashIndex >= 0) {
182
+ hash = target.slice(hashIndex);
183
+ target = target.slice(0, hashIndex);
184
+ }
185
+ const searchIndex = target.indexOf("?");
186
+ if (searchIndex >= 0) {
187
+ search = target.slice(searchIndex);
188
+ target = target.slice(0, searchIndex);
189
+ }
190
+ const path = target ? target.startsWith("/") ? target : `/${target}` : "/";
191
+ return {
192
+ path,
193
+ ...search && search !== "?" ? { search } : {},
194
+ ...hash && hash !== "#" ? { hash } : {}
195
+ };
196
+ }
197
+ };
198
+ var buildHistoryPath = ({
199
+ path,
200
+ search,
201
+ hash
202
+ }) => {
203
+ const normalizedPath = path ? path.startsWith("/") ? path : `/${path}` : "/";
204
+ const normalizedSearch = search ? ensurePrefix(search, "?") : "";
205
+ const normalizedHash = hash ? ensurePrefix(hash, "#") : "";
206
+ return `${normalizedPath}${normalizedSearch}${normalizedHash}`;
207
+ };
208
+ var getHistoryLocation = (inputPath, state, getNextKey, currentLocation, replaceSearch = false) => {
209
+ const parsed = parseHistoryPath(inputPath);
210
+ const nextSearch = typeof parsed.search === "undefined" ? replaceSearch ? void 0 : currentLocation?.search : parsed.search;
211
+ return {
212
+ path: parsed.path,
213
+ ...typeof nextSearch !== "undefined" ? { search: nextSearch } : {},
214
+ ...parsed.hash ? { hash: parsed.hash } : {},
215
+ ...typeof state !== "undefined" ? { state } : {},
216
+ key: getNextKey()
217
+ };
218
+ };
219
+ var createMemoryHistory = (initialPath = "/") => {
220
+ let keyCounter = 0;
221
+ const getNextKey = () => `h${keyCounter++}`;
222
+ const listeners = /* @__PURE__ */ new Set();
223
+ const entries = [
224
+ {
225
+ location: getHistoryLocation(
226
+ initialPath,
227
+ void 0,
228
+ getNextKey,
229
+ void 0,
230
+ true
231
+ )
232
+ }
233
+ ];
234
+ let currentIndex = 0;
235
+ const getCurrentLocation = () => entries[currentIndex].location;
236
+ const notify = () => {
237
+ const location = getCurrentLocation();
238
+ listeners.forEach((listener) => listener(location));
239
+ };
240
+ const push = (path, opts) => {
241
+ const location = getHistoryLocation(
242
+ path,
243
+ opts?.state,
244
+ getNextKey,
245
+ getCurrentLocation(),
246
+ opts?.replaceSearch === true
247
+ );
248
+ if (currentIndex < entries.length - 1) {
249
+ entries.splice(currentIndex + 1);
250
+ }
251
+ entries.push({ location });
252
+ currentIndex = entries.length - 1;
253
+ notify();
254
+ };
255
+ const replace = (path, opts) => {
256
+ const location = getHistoryLocation(
257
+ path,
258
+ opts?.state,
259
+ getNextKey,
260
+ getCurrentLocation(),
261
+ opts?.replaceSearch === true
262
+ );
263
+ entries[currentIndex] = { location };
264
+ notify();
265
+ };
266
+ const go = (delta) => {
267
+ if (!Number.isFinite(delta)) {
268
+ return;
269
+ }
270
+ const targetIndex = Math.max(
271
+ 0,
272
+ Math.min(entries.length - 1, currentIndex + Math.trunc(delta))
273
+ );
274
+ if (targetIndex === currentIndex) {
275
+ return;
276
+ }
277
+ currentIndex = targetIndex;
278
+ notify();
279
+ };
280
+ return {
281
+ get location() {
282
+ return getCurrentLocation();
283
+ },
284
+ get length() {
285
+ return entries.length;
286
+ },
287
+ get index() {
288
+ return currentIndex;
289
+ },
290
+ push,
291
+ replace,
292
+ go,
293
+ back: () => go(-1),
294
+ forward: () => go(1),
295
+ listen: (listener) => {
296
+ listeners.add(listener);
297
+ return () => listeners.delete(listener);
298
+ }
299
+ };
300
+ };
301
+
302
+ // src/app/utils/RouteHistory.ts
303
+ var createRouteAdapterFromHistory = (history) => {
304
+ return {
305
+ getPath: () => history.location.path,
306
+ subscribe: (listener) => {
307
+ return history.listen((location) => {
308
+ listener(location.path);
309
+ });
310
+ },
311
+ push: (path) => {
312
+ history.push(resolveRouteAdapterPath(history.location.path, path), {
313
+ replaceSearch: true
314
+ });
315
+ },
316
+ replace: (path) => {
317
+ history.replace(resolveRouteAdapterPath(history.location.path, path), {
318
+ replaceSearch: true
319
+ });
320
+ },
321
+ back: history.back,
322
+ canGoBack: () => history.index > 0
323
+ };
324
+ };
325
+
326
+ // src/app/utils/UniversalRouteAdapter.ts
327
+ var getWindow = () => {
328
+ if (typeof globalThis === "undefined") {
329
+ return void 0;
330
+ }
331
+ if ("window" in globalThis) {
332
+ return globalThis.window;
333
+ }
334
+ return void 0;
335
+ };
336
+ var canUseBrowserHistory = () => {
337
+ const WINDOW = getWindow();
338
+ return Boolean(
339
+ WINDOW && WINDOW.location && WINDOW.history && typeof WINDOW.history.pushState === "function"
340
+ );
341
+ };
342
+ var createBrowserRouteAdapter = () => {
343
+ const WINDOW = getWindow();
344
+ const listeners = /* @__PURE__ */ new Set();
345
+ const notify = () => {
346
+ const path = WINDOW?.location?.pathname ?? "";
347
+ listeners.forEach((listener) => listener(path));
348
+ };
349
+ const handleHistoryEvent = () => {
350
+ notify();
351
+ };
352
+ return {
353
+ getPath: () => WINDOW?.location?.pathname ?? "",
354
+ subscribe: (listener) => {
355
+ listeners.add(listener);
356
+ if (WINDOW) {
357
+ WINDOW.addEventListener("popstate", handleHistoryEvent);
358
+ WINDOW.addEventListener("statechanged", handleHistoryEvent);
359
+ }
360
+ return () => {
361
+ listeners.delete(listener);
362
+ if (WINDOW) {
363
+ WINDOW.removeEventListener("popstate", handleHistoryEvent);
364
+ WINDOW.removeEventListener("statechanged", handleHistoryEvent);
365
+ }
366
+ };
367
+ },
368
+ push: (path, title = "") => {
369
+ if (!WINDOW?.history) {
370
+ return;
371
+ }
372
+ const resolvedPath = resolveRouteAdapterPath(
373
+ WINDOW.location?.pathname ?? "",
374
+ path
375
+ );
376
+ const targetPath = parseHistoryPath(resolvedPath).path;
377
+ if (targetPath === (WINDOW.location?.pathname ?? "")) {
378
+ return;
379
+ }
380
+ WINDOW.history.pushState({}, title, resolvedPath);
381
+ notify();
382
+ },
383
+ replace: (path, title = "") => {
384
+ if (!WINDOW?.history?.replaceState) {
385
+ return;
386
+ }
387
+ const resolvedPath = resolveRouteAdapterPath(
388
+ WINDOW.location?.pathname ?? "",
389
+ path
390
+ );
391
+ const targetPath = parseHistoryPath(resolvedPath).path;
392
+ if (targetPath === (WINDOW.location?.pathname ?? "")) {
393
+ return;
394
+ }
395
+ WINDOW.history.replaceState({}, title, resolvedPath);
396
+ notify();
397
+ },
398
+ back: () => WINDOW?.history?.back(),
399
+ canGoBack: () => (WINDOW?.history?.length ?? 0) > 1
400
+ };
401
+ };
402
+ var createNativeRouteAdapter = (initialPath = "/", ingress) => {
403
+ const mapURLToPath = ingress?.mapURLToPath ?? ((url) => buildHistoryPath(parseHistoryPath(url)));
404
+ const onIncomingURL = ingress?.onIncomingURL ?? "replace";
405
+ const history = createMemoryHistory(initialPath);
406
+ const adapter = createRouteAdapterFromHistory(history);
407
+ let stopIngress;
408
+ let ingressStarted = false;
409
+ let subscribers = 0;
410
+ const applyPath = (path, mode) => {
411
+ const normalizedPath = parseHistoryPath(path).path;
412
+ if (!normalizedPath || normalizedPath === history.location.path) {
413
+ return;
414
+ }
415
+ if (mode === "push") {
416
+ history.push(normalizedPath, { replaceSearch: true });
417
+ return;
418
+ }
419
+ history.replace(normalizedPath, { replaceSearch: true });
420
+ };
421
+ const startIngress = async () => {
422
+ if (ingressStarted || !ingress) {
423
+ return;
424
+ }
425
+ ingressStarted = true;
426
+ const startKey = history.location.key;
427
+ const startIndex = history.index;
428
+ if (ingress.subscribe) {
429
+ stopIngress = ingress.subscribe((url) => {
430
+ const nextPath = mapURLToPath(url);
431
+ if (!nextPath) {
432
+ return;
433
+ }
434
+ applyPath(nextPath, onIncomingURL);
435
+ });
436
+ }
437
+ const initialURL = await ingress.getInitialURL?.();
438
+ const userNavigated = history.location.key !== startKey || history.index !== startIndex;
439
+ if (!userNavigated && initialURL) {
440
+ const nextPath = mapURLToPath(initialURL);
441
+ if (nextPath) {
442
+ applyPath(nextPath, "replace");
443
+ }
444
+ }
445
+ };
446
+ return {
447
+ ...adapter,
448
+ push: (path, title) => {
449
+ const resolvedPath = resolveRouteAdapterPath(history.location.path, path);
450
+ if (parseHistoryPath(resolvedPath).path === history.location.path) {
451
+ return;
452
+ }
453
+ adapter.push?.(resolvedPath, title);
454
+ },
455
+ replace: (path, title) => {
456
+ const resolvedPath = resolveRouteAdapterPath(history.location.path, path);
457
+ if (parseHistoryPath(resolvedPath).path === history.location.path) {
458
+ return;
459
+ }
460
+ adapter.replace?.(resolvedPath, title);
461
+ },
462
+ subscribe: (listener) => {
463
+ subscribers += 1;
464
+ if (subscribers === 1) {
465
+ void startIngress();
466
+ }
467
+ const unlisten = adapter.subscribe(listener);
468
+ return () => {
469
+ unlisten();
470
+ subscribers = Math.max(0, subscribers - 1);
471
+ if (subscribers === 0) {
472
+ stopIngress?.();
473
+ stopIngress = void 0;
474
+ ingressStarted = false;
475
+ }
476
+ };
477
+ },
478
+ back: adapter.back,
479
+ canGoBack: adapter.canGoBack
480
+ };
481
+ };
482
+ var createUniversalAdapter = (options = {}) => {
483
+ const { strategy = "auto", initialPath = "/", ingress } = options;
484
+ if (strategy === "web") {
485
+ return createBrowserRouteAdapter();
486
+ }
487
+ if (strategy === "native") {
488
+ return createNativeRouteAdapter(initialPath, ingress);
489
+ }
490
+ return canUseBrowserHistory() ? createBrowserRouteAdapter() : createNativeRouteAdapter(initialPath, ingress);
491
+ };
492
+ var createManualRouteAdapter = (initialPath = "/") => {
493
+ let currentPath = initialPath;
494
+ const listeners = /* @__PURE__ */ new Set();
495
+ const updatePath = (nextPath) => {
496
+ currentPath = nextPath;
497
+ listeners.forEach((listener) => listener(nextPath));
498
+ };
499
+ const adapter = {
500
+ getPath: () => currentPath,
501
+ subscribe: (listener) => {
502
+ listeners.add(listener);
503
+ return () => {
504
+ listeners.delete(listener);
505
+ };
506
+ },
507
+ push: (path) => updatePath(resolveRouteAdapterPath(currentPath, path)),
508
+ replace: (path) => updatePath(resolveRouteAdapterPath(currentPath, path))
509
+ };
510
+ return {
511
+ adapter,
512
+ updatePath
513
+ };
514
+ };
515
+ var isDevelopmentMode = () => {
516
+ const env = globalThis?.process?.env?.NODE_ENV;
517
+ return env !== "production";
518
+ };
519
+ var buildQueryString = (query = {}) => {
520
+ const parts = [];
521
+ for (const [key, rawValue] of Object.entries(query)) {
522
+ if (rawValue === void 0) {
523
+ continue;
524
+ }
525
+ const values = Array.isArray(rawValue) ? rawValue : [rawValue];
526
+ for (const value of values) {
527
+ if (value === void 0) {
528
+ continue;
529
+ }
530
+ const encodedKey = encodeURIComponent(key);
531
+ const encodedValue = value === null ? "" : encodeURIComponent(String(value));
532
+ parts.push(`${encodedKey}=${encodedValue}`);
533
+ }
534
+ }
535
+ return parts.join("&");
536
+ };
537
+ var buildRoutePath = (segments, query) => {
538
+ const normalizedSegments = segments.map((segment) => String(segment));
539
+ const basePath = "/" + getPathString(normalizedSegments, "/", true, false, true);
540
+ const queryString = query ? buildQueryString(query) : "";
541
+ return queryString ? `${basePath}?${queryString}` : basePath;
542
+ };
543
+ var getReadableRoutePath = (path) => getPathString(
544
+ getPathArray(path, PATH_DELIMITER, true, true, true, false),
545
+ PATH_DELIMITER,
546
+ true,
547
+ false,
548
+ false
549
+ );
550
+ var RouteContext = createContext({
551
+ currentWindowPath: "",
552
+ parentPath: "",
553
+ parentPathInternal: "",
554
+ params: {},
555
+ isTopLevel: true,
556
+ adapterBasePath: "/"
557
+ });
558
+ var {
559
+ /**
560
+ * @ignore
561
+ */
562
+ Provider: RouteContextProvider,
563
+ /**
564
+ * @ignore
565
+ */
566
+ Consumer: RouteContextConsumer
567
+ } = RouteContext;
568
+ var useRouteContext = () => useContext(RouteContext);
569
+ var wrapRouteAdapterWithPathResolver = (adapter, getBasePath = () => adapter.getPath()) => {
570
+ if (!adapter.push && !adapter.replace) {
571
+ return adapter;
572
+ }
573
+ const wrappedAdapter = {
574
+ ...adapter,
575
+ push: adapter.push ? (path, title) => {
576
+ adapter.push?.(resolveRouteAdapterPath(getBasePath(), path), title);
577
+ } : void 0,
578
+ replace: adapter.replace ? (path, title) => {
579
+ adapter.replace?.(resolveRouteAdapterPath(getBasePath(), path), title);
580
+ } : void 0
581
+ };
582
+ return wrappedAdapter;
583
+ };
584
+ var getAdapterBasePath = (currentPath) => {
585
+ const normalizedPath = String(currentPath ?? "").trim();
586
+ if (normalizedPath === "") {
587
+ return "/";
588
+ }
589
+ const [pathOnly] = normalizedPath.split(/[?#]/, 1);
590
+ return pathOnly || "/";
591
+ };
592
+ var getMatchedRouteBasePath = (currentPath, matchedRoutePath) => {
593
+ const currentPathSegments = getPathArray(
594
+ getAdapterBasePath(currentPath),
595
+ PATH_DELIMITER,
596
+ true,
597
+ true,
598
+ false,
599
+ false
600
+ );
601
+ const matchedRouteSegments = getPathArray(matchedRoutePath);
602
+ const resolvedSegments = currentPathSegments.slice(0, matchedRouteSegments.length);
603
+ return resolvedSegments.length > 0 ? `/${resolvedSegments.join(PATH_DELIMITER)}` : "/";
604
+ };
605
+ var getWindow2 = () => {
606
+ if (typeof globalThis === "undefined") {
607
+ return void 0;
608
+ }
609
+ if ("window" in globalThis) {
610
+ return globalThis.window;
611
+ }
612
+ return void 0;
613
+ };
614
+ var useBrowserLinkInterceptor = (adapter) => {
615
+ useEffect(() => {
616
+ const WINDOW = getWindow2();
617
+ if (!WINDOW || !adapter?.push) {
618
+ return void 0;
619
+ }
620
+ const handleAnchorClick = (event) => {
621
+ let target = event.target;
622
+ while (target && target.nodeName !== "A") {
623
+ target = target.parentNode;
624
+ }
625
+ if (!target || target.nodeName !== "A") {
626
+ return;
627
+ }
628
+ const anchor = target;
629
+ const href = anchor.getAttribute("href");
630
+ const title = anchor.getAttribute("title") ?? "";
631
+ if (!href) {
632
+ return;
633
+ }
634
+ try {
635
+ new URL(href);
636
+ return;
637
+ } catch (error) {
638
+ const nextPath = resolveRouteAdapterPath(
639
+ WINDOW.location?.pathname ?? "",
640
+ href
641
+ );
642
+ event.preventDefault();
643
+ adapter.push?.(nextPath, title);
644
+ }
645
+ };
646
+ WINDOW.document?.addEventListener("click", handleAnchorClick);
647
+ return () => {
648
+ WINDOW.document?.removeEventListener("click", handleAnchorClick);
649
+ };
650
+ }, [adapter]);
651
+ };
652
+ var RouteProvider = ({
653
+ adapter,
654
+ initialPath,
655
+ children
656
+ }) => {
657
+ const normalizedAdapter = useMemo(
658
+ () => wrapRouteAdapterWithPathResolver(adapter),
659
+ [adapter]
660
+ );
661
+ const [currentPath, setCurrentPath] = useState(
662
+ initialPath ?? normalizedAdapter.getPath()
663
+ );
664
+ const adapterBasePath = useMemo(
665
+ () => getAdapterBasePath(currentPath),
666
+ [currentPath]
667
+ );
668
+ useEffect(() => {
669
+ return normalizedAdapter.subscribe((nextPath) => {
670
+ setCurrentPath(nextPath);
671
+ });
672
+ }, [normalizedAdapter]);
673
+ const contextValue = useMemo(
674
+ () => ({
675
+ currentWindowPath: currentPath,
676
+ parentPath: "",
677
+ parentPathInternal: "",
678
+ params: {},
679
+ isTopLevel: true,
680
+ adapterBasePath,
681
+ adapter: normalizedAdapter
682
+ }),
683
+ [currentPath, adapterBasePath, normalizedAdapter]
684
+ );
685
+ return /* @__PURE__ */ jsx(RouteContextProvider, { value: contextValue, children });
686
+ };
687
+ var RouteMatcher = ({
688
+ /**
689
+ * Use `:` as the first character to denote a parameter in the path.
690
+ */
691
+ path,
692
+ onParamsChange,
693
+ exact = false,
694
+ children
695
+ }) => {
696
+ const {
697
+ currentWindowPath = "",
698
+ parentPath = "",
699
+ parentPathInternal = "",
700
+ params: parentParams = {},
701
+ adapterBasePath: inheritedAdapterBasePath = "/",
702
+ adapter
703
+ } = useRouteContext();
704
+ const targetCurrentPath = useMemo(
705
+ () => currentWindowPath,
706
+ [currentWindowPath]
707
+ );
708
+ const normalizedPaths = useMemo(() => {
709
+ const routePaths = Array.isArray(path) ? path : [path];
710
+ return routePaths.map(
711
+ (routePath) => typeof routePath === "string" ? {
712
+ path: routePath,
713
+ exact
714
+ } : routePath
715
+ );
716
+ }, [path, exact]);
717
+ const matchedRoute = useMemo(
718
+ () => {
719
+ for (const routePathConfig of normalizedPaths) {
720
+ const fullPath = mergeStringPaths(
721
+ parentPathInternal,
722
+ routePathConfig.path
723
+ );
724
+ const newParams = getParamsAndTestPath(
725
+ targetCurrentPath,
726
+ fullPath,
727
+ routePathConfig.exact
728
+ );
729
+ if (newParams) {
730
+ return {
731
+ fullPath,
732
+ newParams
733
+ };
734
+ }
735
+ }
736
+ return null;
737
+ },
738
+ [targetCurrentPath, parentPathInternal, normalizedPaths]
739
+ );
740
+ const params = useMemo(
741
+ () => ({
742
+ ...parentParams,
743
+ ...matchedRoute?.newParams ? matchedRoute.newParams : {}
744
+ }),
745
+ [parentParams, matchedRoute]
746
+ );
747
+ const matchedAdapterBasePath = useMemo(
748
+ () => matchedRoute ? getMatchedRouteBasePath(targetCurrentPath, matchedRoute.fullPath) : inheritedAdapterBasePath,
749
+ [targetCurrentPath, matchedRoute, inheritedAdapterBasePath]
750
+ );
751
+ const scopedAdapter = useMemo(
752
+ () => adapter ? wrapRouteAdapterWithPathResolver(adapter, () => matchedAdapterBasePath) : adapter,
753
+ [adapter, matchedAdapterBasePath]
754
+ );
755
+ const newRouteContext = useMemo(
756
+ () => ({
757
+ currentWindowPath: targetCurrentPath,
758
+ parentPath: getReadableRoutePath(matchedRoute?.fullPath ?? parentPathInternal),
759
+ parentPathInternal: matchedRoute?.fullPath ?? parentPathInternal,
760
+ params,
761
+ isTopLevel: false,
762
+ adapterBasePath: matchedAdapterBasePath,
763
+ adapter: scopedAdapter
764
+ }),
765
+ [
766
+ targetCurrentPath,
767
+ matchedRoute,
768
+ parentPathInternal,
769
+ params,
770
+ matchedAdapterBasePath,
771
+ scopedAdapter
772
+ ]
773
+ );
774
+ useEffect(() => {
775
+ if (onParamsChange) {
776
+ onParamsChange(params);
777
+ }
778
+ }, [params, onParamsChange]);
779
+ return matchedRoute?.newParams ? /* @__PURE__ */ jsx(RouteContextProvider, { value: newRouteContext, children }) : null;
780
+ };
781
+ var RouteRootProvider = ({
782
+ children,
783
+ adapter,
784
+ initialPath,
785
+ ingress,
786
+ runtimeIntegration
787
+ }) => {
788
+ const routeContext = useRouteContext();
789
+ const autoAdapterRef = useRef(null);
790
+ if (typeof routeContext.adapter !== "undefined" && isDevelopmentMode()) {
791
+ throw new Error(
792
+ "Route provider mode is root-only. Nested Route requires a path."
793
+ );
794
+ }
795
+ if (!autoAdapterRef.current) {
796
+ autoAdapterRef.current = adapter ?? createUniversalAdapter({ initialPath, ingress });
797
+ }
798
+ useBrowserLinkInterceptor(autoAdapterRef.current);
799
+ useEffect(() => {
800
+ if (!runtimeIntegration || !autoAdapterRef.current) {
801
+ return void 0;
802
+ }
803
+ return runtimeIntegration.setup(autoAdapterRef.current);
804
+ }, [runtimeIntegration]);
805
+ return /* @__PURE__ */ jsx(RouteProvider, { adapter: autoAdapterRef.current, initialPath, children });
806
+ };
807
+ var Route = (props) => {
808
+ const hasMatcherProps = typeof props.path !== "undefined" || typeof props.exact !== "undefined" || typeof props.onParamsChange !== "undefined";
809
+ const hasProviderProps = typeof props.initialPath !== "undefined" || typeof props.adapter !== "undefined" || typeof props.ingress !== "undefined" || typeof props.runtimeIntegration !== "undefined";
810
+ if (hasMatcherProps) {
811
+ if (hasProviderProps && isDevelopmentMode()) {
812
+ throw new Error(
813
+ "Route matcher mode does not support provider props. Remove initialPath/adapter/ingress/runtimeIntegration or use a root Route without path."
814
+ );
815
+ }
816
+ return /* @__PURE__ */ jsx(
817
+ RouteMatcher,
818
+ {
819
+ path: props.path ?? "",
820
+ onParamsChange: props.onParamsChange,
821
+ exact: props.exact,
822
+ children: props.children
823
+ }
824
+ );
825
+ }
826
+ if (typeof props.path === "undefined") {
827
+ return /* @__PURE__ */ jsx(
828
+ RouteRootProvider,
829
+ {
830
+ adapter: props.adapter,
831
+ initialPath: props.initialPath,
832
+ ingress: props.ingress,
833
+ runtimeIntegration: props.runtimeIntegration,
834
+ children: props.children
835
+ }
836
+ );
837
+ }
838
+ return null;
839
+ };
840
+
841
+ // src/app/forms/core/getFieldKind.ts
842
+ var hasSelectableValues = (field) => {
843
+ const possibleValues = field.possibleValues ?? [];
844
+ return possibleValues.some(
845
+ (value) => typeof value === "string" || typeof value === "number"
846
+ );
847
+ };
848
+ var getFieldKind = (field) => {
849
+ if (field.typeReference) {
850
+ return field.array ? "relation_array" : "relation_single";
851
+ }
852
+ if (field.tags?.customType) {
853
+ return field.array ? "custom_array" : "custom_single";
854
+ }
855
+ if (field.array) {
856
+ return "array";
857
+ }
858
+ if (hasSelectableValues(field)) {
859
+ return "enum_select";
860
+ }
861
+ if (field.type === "boolean") {
862
+ return "boolean";
863
+ }
864
+ if (field.type === "number") {
865
+ return "number";
866
+ }
867
+ return "string";
868
+ };
869
+
870
+ // src/app/forms/core/resolveSuite.ts
871
+ var fieldKinds = [
872
+ "string",
873
+ "number",
874
+ "boolean",
875
+ "enum_select",
876
+ "array",
877
+ "relation_single",
878
+ "relation_array",
879
+ "custom_single",
880
+ "custom_array"
881
+ ];
882
+ var getMissingKinds = (renderers) => {
883
+ return fieldKinds.filter((kind) => !renderers[kind]);
884
+ };
885
+ var resolveSuite = (overrides, fallback) => {
886
+ const mergedRenderers = {
887
+ ...fallback.renderers ?? {},
888
+ ...overrides?.renderers ?? {}
889
+ };
890
+ const missingKinds = getMissingKinds(mergedRenderers);
891
+ if (missingKinds.length) {
892
+ throw new Error(
893
+ `Missing renderers for field kinds: ${missingKinds.join(", ")}`
894
+ );
895
+ }
896
+ const mergedPrimitives = {
897
+ ...fallback.primitives ?? {},
898
+ ...overrides?.primitives ?? {}
899
+ };
900
+ return {
901
+ renderers: mergedRenderers,
902
+ primitives: Object.keys(mergedPrimitives).length ? mergedPrimitives : void 0
903
+ };
904
+ };
905
+ var createAutoField = (suite) => {
906
+ const defaultTranslateValidationErrorCode2 = (error) => error.code === ERROR_MESSAGE_CONSTANTS.NONE ? "" : String(error.code);
907
+ const AutoField = (props) => {
908
+ const { field, fieldKey, value, onChange, error, disabled } = props;
909
+ const { tags } = field;
910
+ const resolvedErrors = props.errors ?? (error ? [error] : []);
911
+ const resolvedError = resolvedErrors.find((descriptor) => descriptor.code !== ERROR_MESSAGE_CONSTANTS.NONE) ?? getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.NONE);
912
+ const context = {
913
+ field,
914
+ fieldKey,
915
+ label: tags?.label ?? fieldKey,
916
+ required: !field.optional,
917
+ disabled: !!disabled,
918
+ error: resolvedError,
919
+ errors: resolvedErrors,
920
+ arrayItemErrorMap: props.arrayItemErrorMap,
921
+ translateValidationErrorCode: props.translateValidationErrorCode ?? defaultTranslateValidationErrorCode2,
922
+ value,
923
+ onChange,
924
+ constraints: tags?.constraints,
925
+ format: tags?.format,
926
+ possibleValues: field.possibleValues,
927
+ allowCustomSelection: tags?.allowCustomSelection,
928
+ customType: tags?.customType,
929
+ onRelationAction: props.onRelationAction,
930
+ onCustomTypeAction: props.onCustomTypeAction,
931
+ renderField: (input) => createElement(AutoField, {
932
+ field: input.field,
933
+ fieldKey: input.fieldKey,
934
+ value: input.value,
935
+ onChange: input.onChange,
936
+ error: input.error,
937
+ errors: input.errors,
938
+ arrayItemErrorMap: input.arrayItemErrorMap,
939
+ translateValidationErrorCode: input.translateValidationErrorCode,
940
+ disabled: input.disabled,
941
+ onRelationAction: input.onRelationAction,
942
+ onCustomTypeAction: input.onCustomTypeAction
943
+ })
944
+ };
945
+ const kind = getFieldKind(field);
946
+ return createElement(suite.renderers[kind], context);
947
+ };
948
+ return AutoField;
949
+ };
950
+
951
+ // src/app/forms/core/createFormRenderer.ts
952
+ var createFormRenderer = (options) => {
953
+ const resolvedSuite = resolveSuite(
954
+ options.suite,
955
+ options.fallbackSuite
956
+ );
957
+ const AutoField = createAutoField(resolvedSuite);
958
+ return {
959
+ AutoField,
960
+ suite: resolvedSuite
961
+ };
962
+ };
963
+ var getDeniedOperation = (deniedOperations, operation) => {
964
+ if (!deniedOperations) {
965
+ return false;
966
+ }
967
+ const denied = deniedOperations[operation];
968
+ if (typeof denied === "boolean") {
969
+ return denied;
970
+ }
971
+ return deniedOperations[operation.toLowerCase()] ?? false;
972
+ };
973
+ var buildInitialValues = (initialValues, typeInfo) => {
974
+ const values = { ...initialValues };
975
+ for (const [key, field] of Object.entries(typeInfo.fields ?? {})) {
976
+ if (values[key] !== void 0) {
977
+ continue;
978
+ }
979
+ const defaultValue = field.tags?.constraints?.defaultValue;
980
+ if (defaultValue !== void 0) {
981
+ let parsedDefaultValue = defaultValue;
982
+ try {
983
+ parsedDefaultValue = JSON.parse(defaultValue);
984
+ } catch (error) {
985
+ }
986
+ values[key] = parsedDefaultValue;
987
+ continue;
988
+ }
989
+ if (field.array && !field.typeReference && !field.optional) {
990
+ values[key] = [];
991
+ continue;
992
+ }
993
+ if (field.type === "boolean" && !field.optional) {
994
+ values[key] = false;
995
+ }
996
+ }
997
+ return values;
998
+ };
999
+ var FORM_ENGINE_TYPE_NAME = "__AUTO_FORM__";
1000
+ var useFormEngine = (initialValues = {}, typeInfo, options) => {
1001
+ const operation = options?.operation ?? "CREATE" /* CREATE */;
1002
+ const customValidatorMap = options?.customValidatorMap ?? {};
1003
+ const [values, setValues] = useState(
1004
+ buildInitialValues(initialValues, typeInfo)
1005
+ );
1006
+ const [errors, setErrorsState] = useState({});
1007
+ const normalizeErrorEntries = useCallback(
1008
+ (value) => {
1009
+ if (typeof value === "string") {
1010
+ return [getErrorDescriptor(value)];
1011
+ }
1012
+ if (Array.isArray(value)) {
1013
+ return value;
1014
+ }
1015
+ if (value && typeof value === "object") {
1016
+ if ("code" in value && typeof value.code === "string") {
1017
+ return [value];
1018
+ }
1019
+ const itemErrorMap = value;
1020
+ const numericKeys = Object.keys(itemErrorMap).filter(
1021
+ (key) => /^\d+$/.test(key)
1022
+ );
1023
+ if (numericKeys.length) {
1024
+ const normalizedItemErrorMap = {};
1025
+ for (const key of numericKeys) {
1026
+ const index = Number(key);
1027
+ const rawValue = itemErrorMap[key];
1028
+ if (!Array.isArray(rawValue)) {
1029
+ continue;
1030
+ }
1031
+ normalizedItemErrorMap[index] = rawValue.filter(
1032
+ (descriptor) => !!descriptor && typeof descriptor === "object" && "code" in descriptor && typeof descriptor.code === "string"
1033
+ );
1034
+ }
1035
+ return [{ itemErrorMap: normalizedItemErrorMap }];
1036
+ }
1037
+ }
1038
+ return [getNoErrorDescriptor()];
1039
+ },
1040
+ []
1041
+ );
1042
+ const normalizeErrorMap = useCallback(
1043
+ (pendingErrors) => Object.entries(pendingErrors).reduce((acc, [key, value]) => {
1044
+ acc[key] = normalizeErrorEntries(value);
1045
+ return acc;
1046
+ }, {}),
1047
+ [normalizeErrorEntries]
1048
+ );
1049
+ const setErrors = useCallback(
1050
+ (pendingErrors) => {
1051
+ setErrorsState(normalizeErrorMap(pendingErrors));
1052
+ },
1053
+ [normalizeErrorMap]
1054
+ );
1055
+ const setFieldValue = useCallback((path, value) => {
1056
+ setValues((prev) => {
1057
+ return {
1058
+ ...prev,
1059
+ [path]: value
1060
+ };
1061
+ });
1062
+ }, []);
1063
+ const validate = useCallback(() => {
1064
+ const fields2 = typeInfo.fields ?? {};
1065
+ const validationResults = validateTypeInfoDataItem(
1066
+ values,
1067
+ typeInfo,
1068
+ customValidatorMap,
1069
+ {
1070
+ typeName: FORM_ENGINE_TYPE_NAME,
1071
+ typeOperation: operation
1072
+ }
1073
+ );
1074
+ const newErrors = {};
1075
+ for (const key of Object.keys(fields2)) {
1076
+ newErrors[key] = validationResults.errorMap[key] ?? [getNoErrorDescriptor()];
1077
+ }
1078
+ setErrorsState(newErrors);
1079
+ return validationResults;
1080
+ }, [typeInfo, values, operation, customValidatorMap]);
1081
+ const fields = useMemo(() => {
1082
+ return Object.entries(typeInfo.fields ?? {}).map(([key, field]) => {
1083
+ const { tags } = field;
1084
+ const isPrimary = tags?.primaryField || typeInfo.primaryField === key;
1085
+ return {
1086
+ key,
1087
+ field,
1088
+ label: tags?.label ?? key,
1089
+ required: !field.optional,
1090
+ disabled: field.readonly || getDeniedOperation(typeInfo.tags?.deniedOperations, operation) || getDeniedOperation(tags?.deniedOperations, operation) || operation === "UPDATE" /* UPDATE */ && isPrimary,
1091
+ hidden: !!tags?.hidden,
1092
+ primary: isPrimary,
1093
+ format: tags?.format,
1094
+ constraints: tags?.constraints,
1095
+ value: values[key],
1096
+ onChange: (value) => setFieldValue(key, value),
1097
+ error: getErrorDescriptors(errors[key] ?? []).find(
1098
+ (descriptor) => descriptor.code !== ERROR_MESSAGE_CONSTANTS.NONE
1099
+ ) ?? getNoErrorDescriptor(),
1100
+ errors: getErrorDescriptors(errors[key] ?? []),
1101
+ arrayItemErrorMap: getArrayItemErrorMap(errors[key] ?? [])
1102
+ };
1103
+ });
1104
+ }, [typeInfo, values, errors, setFieldValue, operation]);
1105
+ return {
1106
+ typeInfo,
1107
+ typeTags: typeInfo.tags,
1108
+ operation,
1109
+ values,
1110
+ errors,
1111
+ fields,
1112
+ setFieldValue,
1113
+ validate,
1114
+ setErrors
1115
+ };
1116
+ };
1117
+ var fallbackFormRoot = ({
1118
+ children,
1119
+ onSubmit
1120
+ }) => {
1121
+ const handleSubmit = (event) => {
1122
+ event.preventDefault();
1123
+ onSubmit?.();
1124
+ };
1125
+ return /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, children });
1126
+ };
1127
+ var fallbackButton = ({
1128
+ children,
1129
+ disabled,
1130
+ type,
1131
+ onClick
1132
+ }) => {
1133
+ return /* @__PURE__ */ jsx("button", { type: type ?? "button", disabled, onClick, children });
1134
+ };
1135
+ var AutoFormView = ({
1136
+ controller,
1137
+ onSubmit,
1138
+ renderer,
1139
+ submitDisabled,
1140
+ onRelationAction,
1141
+ onCustomTypeAction,
1142
+ translateValidationErrorCode = defaultTranslateValidationErrorCode
1143
+ }) => {
1144
+ const FormRoot = renderer.suite.primitives?.FormRoot ?? fallbackFormRoot;
1145
+ const Button = renderer.suite.primitives?.Button ?? fallbackButton;
1146
+ const AutoField = renderer.AutoField;
1147
+ const submit = () => {
1148
+ const validationResults = controller.validate();
1149
+ if (validationResults.valid) {
1150
+ onSubmit(controller.values);
1151
+ }
1152
+ };
1153
+ return /* @__PURE__ */ jsx(FormRoot, { onSubmit: submit, children: /* @__PURE__ */ jsxs(Fragment, { children: [
1154
+ controller.fields.filter((fieldController) => !fieldController.hidden).map((fieldController) => /* @__PURE__ */ jsx(
1155
+ AutoField,
1156
+ {
1157
+ field: fieldController.field,
1158
+ fieldKey: fieldController.key,
1159
+ value: fieldController.value,
1160
+ onChange: fieldController.onChange,
1161
+ error: fieldController.error,
1162
+ errors: fieldController.errors,
1163
+ arrayItemErrorMap: fieldController.arrayItemErrorMap,
1164
+ translateValidationErrorCode,
1165
+ onRelationAction,
1166
+ disabled: fieldController.disabled,
1167
+ onCustomTypeAction
1168
+ },
1169
+ fieldController.key
1170
+ )),
1171
+ /* @__PURE__ */ jsx(Button, { type: "submit", onClick: submit, disabled: submitDisabled, children: /* @__PURE__ */ jsx(Fragment, { children: "Submit" }) })
1172
+ ] }) });
1173
+ };
1174
+ var defaultTranslateValidationErrorCode = (error) => {
1175
+ const { code, values = [] } = error;
1176
+ const [constraintValue] = values;
1177
+ switch (code) {
1178
+ case ERROR_MESSAGE_CONSTANTS.INVALID_CUSTOM_TYPE:
1179
+ return "Value failed custom validation";
1180
+ case ERROR_MESSAGE_CONSTANTS.NOT_A_STRING:
1181
+ return "Value must be a string";
1182
+ case ERROR_MESSAGE_CONSTANTS.NOT_A_NUMBER:
1183
+ return "Value must be a number";
1184
+ case ERROR_MESSAGE_CONSTANTS.NOT_A_BOOLEAN:
1185
+ return "Value must be a boolean";
1186
+ case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_CREATE:
1187
+ return "Create operation is not allowed for this value";
1188
+ case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_READ:
1189
+ return "Read operation is not allowed for this value";
1190
+ case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_UPDATE:
1191
+ return "Update operation is not allowed for this value";
1192
+ case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_DELETE:
1193
+ return "Delete operation is not allowed for this value";
1194
+ case ERROR_MESSAGE_CONSTANTS.MISSING_FIELD_VALUE:
1195
+ return "This field is required";
1196
+ case ERROR_MESSAGE_CONSTANTS.INVALID_FIELD:
1197
+ return "This field is not allowed";
1198
+ case ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN:
1199
+ return "Value does not match required pattern";
1200
+ case ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN:
1201
+ return "Field pattern configuration is invalid";
1202
+ case ERROR_MESSAGE_CONSTANTS.VALUE_BELOW_MINIMUM:
1203
+ return `Value must be at least ${constraintValue ?? "the minimum"}`;
1204
+ case ERROR_MESSAGE_CONSTANTS.VALUE_ABOVE_MAXIMUM:
1205
+ return `Value must be at most ${constraintValue ?? "the maximum"}`;
1206
+ case ERROR_MESSAGE_CONSTANTS.INVALID_OPTION:
1207
+ return "Value is not one of the allowed options";
1208
+ case ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED:
1209
+ return "Relationship values are not allowed for this operation";
1210
+ case ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED:
1211
+ return "Value does not match any allowed shape";
1212
+ case ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST:
1213
+ return "Type definition was not found";
1214
+ case ERROR_MESSAGE_CONSTANTS.INVALID_TYPE:
1215
+ return "Value has an invalid type";
1216
+ case ERROR_MESSAGE_CONSTANTS.NONE:
1217
+ return "";
1218
+ default:
1219
+ return String(code);
1220
+ }
1221
+ };
1222
+ var AutoForm = ({
1223
+ typeInfo,
1224
+ onSubmit,
1225
+ renderer,
1226
+ initialValues,
1227
+ onValuesChange,
1228
+ onRelationAction,
1229
+ onCustomTypeAction,
1230
+ operation,
1231
+ submitDisabled,
1232
+ translateValidationErrorCode = defaultTranslateValidationErrorCode,
1233
+ customValidatorMap
1234
+ }) => {
1235
+ const controller = useFormEngine(initialValues, typeInfo, {
1236
+ operation,
1237
+ customValidatorMap
1238
+ });
1239
+ useEffect(() => {
1240
+ if (onValuesChange) {
1241
+ onValuesChange(controller.values);
1242
+ }
1243
+ }, [controller.values, onValuesChange]);
1244
+ return /* @__PURE__ */ jsx(
1245
+ AutoFormView,
1246
+ {
1247
+ controller,
1248
+ onSubmit,
1249
+ renderer,
1250
+ onRelationAction,
1251
+ onCustomTypeAction,
1252
+ submitDisabled,
1253
+ translateValidationErrorCode
1254
+ }
1255
+ );
1256
+ };
1257
+
1258
+ export { AutoForm, AutoFormView, Route, RouteContext, RouteContextConsumer, RouteContextProvider, RouteProvider, buildHistoryPath, buildQueryString, buildRoutePath, canUseBrowserHistory, computeAreaBounds, createAutoField, createBrowserRouteAdapter, createFormRenderer, createHistoryBackHandler, createManualRouteAdapter, createMemoryHistory, createNativeRouteAdapter, createRouteAdapterFromHistory, createUniversalAdapter, defaultTranslateValidationErrorCode, getFieldKind, parseHistoryPath, parseTemplate, resolveSuite, useFormEngine, useRouteContext, validateAreas, wrapRouteAdapterWithPathResolver };