@resistdesign/voltra 3.0.0-alpha.4 → 3.0.0-alpha.41
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/README.md +379 -14
- package/api/DBX/DBXAsserts.d.ts +95 -0
- package/api/DBX/DBXRequest.d.ts +5 -0
- package/api/DBX/DBXRuntime.d.ts +5 -0
- package/api/DBX/DBXScenarioConfig.d.ts +9 -0
- package/api/DBX/DBXSeed.d.ts +124 -0
- package/api/DBX/DBXTypes.d.ts +176 -0
- package/api/DBX/index.d.ts +8 -0
- package/api/DataAccessControl.d.ts +220 -0
- package/api/Indexing/API.d.ts +224 -0
- package/api/Indexing/Cursor.d.ts +101 -0
- package/api/Indexing/Handler/Config.d.ts +39 -0
- package/api/Indexing/Handler.d.ts +166 -0
- package/api/Indexing/Trace.d.ts +54 -0
- package/api/Indexing/Types.d.ts +204 -0
- package/api/Indexing/ddb/AwsSdkV3Adapter.d.ts +8 -0
- package/api/Indexing/ddb/Types.d.ts +209 -0
- package/api/Indexing/docId.d.ts +27 -0
- package/api/Indexing/exact/ExactDdb.d.ts +58 -0
- package/api/Indexing/exact/ExactIndex.d.ts +90 -0
- package/api/Indexing/exact/ExactS3.d.ts +41 -0
- package/api/Indexing/fieldQualification.d.ts +12 -0
- package/api/Indexing/fulltext/FullTextDdbBackend.d.ts +212 -0
- package/api/Indexing/fulltext/FullTextMemoryBackend.d.ts +93 -0
- package/api/Indexing/fulltext/Schema.d.ts +164 -0
- package/api/Indexing/hashUniversal.d.ts +13 -0
- package/api/Indexing/index.d.ts +45 -0
- package/api/Indexing/lossy/LossyDdb.d.ts +43 -0
- package/api/Indexing/lossy/LossyIndex.d.ts +72 -0
- package/api/Indexing/lossy/LossyS3.d.ts +40 -0
- package/api/Indexing/rel/Cursor.d.ts +25 -0
- package/api/Indexing/rel/Handlers.d.ts +144 -0
- package/api/Indexing/rel/RelationalDdb.d.ts +169 -0
- package/api/Indexing/rel/RelationalInMemoryBackend.d.ts +38 -0
- package/api/Indexing/rel/Types.d.ts +69 -0
- package/api/Indexing/structured/Cursor.d.ts +26 -0
- package/api/Indexing/structured/Handlers.d.ts +128 -0
- package/api/Indexing/structured/SearchStructured.d.ts +44 -0
- package/api/Indexing/structured/StructuredDdb.d.ts +184 -0
- package/api/Indexing/structured/StructuredDdbBackend.d.ts +112 -0
- package/api/Indexing/structured/StructuredInMemoryBackend.d.ts +40 -0
- package/api/Indexing/structured/StructuredInMemoryIndex.d.ts +61 -0
- package/api/Indexing/structured/StructuredStringLike.d.ts +54 -0
- package/api/Indexing/structured/StructuredWriter.d.ts +74 -0
- package/api/Indexing/structured/Types.d.ts +126 -0
- package/api/Indexing/structured/index.d.ts +9 -0
- package/api/Indexing/tokenize.d.ts +31 -0
- package/api/ORM/DACUtils.d.ts +270 -0
- package/api/ORM/ListItemUtils.d.ts +40 -0
- package/api/ORM/ORMRouteMap.d.ts +55 -0
- package/api/ORM/TypeInfoORMService.d.ts +740 -0
- package/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +229 -0
- package/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +89 -0
- package/api/ORM/drivers/InMemoryDataItemDBDriver/ConfigTypes.d.ts +4 -0
- package/api/ORM/drivers/InMemoryDataItemDBDriver.d.ts +55 -0
- package/api/ORM/drivers/InMemoryFileItemDBDriver/ConfigTypes.d.ts +13 -0
- package/api/ORM/drivers/InMemoryFileItemDBDriver.d.ts +98 -0
- package/api/ORM/drivers/InMemoryItemRelationshipDBDriver.d.ts +16 -0
- package/api/ORM/drivers/IndexingRelationshipDriver.d.ts +123 -0
- package/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +322 -0
- package/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +118 -0
- package/api/ORM/drivers/S3FileItemDBDriver.d.ts +71 -0
- package/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +36 -0
- package/api/ORM/drivers/common/Types.d.ts +197 -0
- package/api/ORM/drivers/common/index.d.ts +2 -0
- package/api/ORM/drivers/index.d.ts +8 -0
- package/api/ORM/index.d.ts +9 -0
- package/api/ORM/indexing/criteriaToStructuredWhere.d.ts +22 -0
- package/api/Router/AWS.d.ts +80 -0
- package/api/Router/Auth.d.ts +14 -0
- package/api/Router/CORS.d.ts +66 -0
- package/api/Router/Types.d.ts +138 -0
- package/api/Router/index.d.ts +89 -0
- package/api/index.d.ts +72 -6
- package/api/index.js +3291 -1954
- package/app/forms/Engine.d.ts +23 -0
- package/app/forms/UI.d.ts +83 -0
- package/app/forms/core/createAutoField.d.ts +43 -0
- package/app/forms/core/createFormRenderer.d.ts +25 -0
- package/app/forms/core/getFieldKind.d.ts +14 -0
- package/app/forms/core/index.d.ts +11 -0
- package/app/forms/core/mergeSuites.d.ts +23 -0
- package/app/forms/core/resolveSuite.d.ts +15 -0
- package/app/forms/core/types.d.ts +180 -0
- package/app/forms/index.d.ts +9 -0
- package/app/forms/types.d.ts +137 -0
- package/app/helpers/styled.d.ts +3 -0
- package/app/index.d.ts +102 -5
- package/app/index.js +98 -327
- package/app/utils/ApplicationState.d.ts +167 -0
- package/app/utils/ApplicationStateLoader.d.ts +86 -0
- package/app/utils/Controller.d.ts +10 -0
- package/app/utils/Debug.d.ts +14 -0
- package/app/utils/EasyLayout.d.ts +89 -0
- package/app/utils/History.d.ts +165 -0
- package/app/utils/Route.d.ts +173 -0
- package/app/utils/RouteHistory.d.ts +27 -0
- package/app/utils/Service.d.ts +45 -0
- package/app/utils/TypeInfoORMAPIUtils.d.ts +94 -0
- package/app/utils/TypeInfoORMClient.d.ts +103 -0
- package/app/utils/UniversalRouteAdapter.d.ts +73 -0
- package/app/utils/easy-layout/computeAreaBounds.d.ts +5 -0
- package/app/utils/easy-layout/computeTracks.d.ts +16 -0
- package/app/utils/easy-layout/index.d.ts +5 -0
- package/app/utils/easy-layout/parseTemplate.d.ts +12 -0
- package/app/utils/easy-layout/types.d.ts +52 -0
- package/app/utils/easy-layout/validateAreas.d.ts +5 -0
- package/app/utils/index.d.ts +24 -0
- package/build/TypeMapping.d.ts +17 -0
- package/build/TypeParsing.d.ts +10 -0
- package/build/index.d.ts +15 -0
- package/build/index.js +569 -0
- package/chunk-2MOLWZMQ.js +71 -0
- package/chunk-7AMEFPPP.js +78 -0
- package/chunk-ATO2455Q.js +258 -0
- package/chunk-DT6WWJUI.js +1185 -0
- package/chunk-I2KLQ2HA.js +19 -0
- package/chunk-TJFTWPXQ.js +39 -0
- package/chunk-WNFRDIBW.js +121 -0
- package/chunk-YCTVEW2I.js +546 -0
- package/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +9 -0
- package/common/CommandLine/index.d.ts +6 -0
- package/common/HelperTypes.d.ts +9 -0
- package/common/IdGeneration/getSimpleId.d.ts +8 -0
- package/common/IdGeneration/index.d.ts +1 -0
- package/common/ItemRelationshipInfoTypes.d.ts +64 -0
- package/common/ItemRelationships/ItemRelationshipValidation.d.ts +21 -0
- package/common/ItemRelationships/index.d.ts +2 -0
- package/common/Logging/Utils.d.ts +10 -0
- package/common/Logging/index.d.ts +1 -0
- package/common/Routing.d.ts +81 -0
- package/common/SearchTypes.d.ts +227 -0
- package/common/SearchUtils.d.ts +55 -0
- package/common/SearchValidation.d.ts +27 -0
- package/common/StringTransformers.d.ts +28 -0
- package/common/Testing/CLI.d.ts +6 -0
- package/common/Testing/Types.d.ts +216 -0
- package/common/Testing/Utils.d.ts +112 -0
- package/common/Testing/index.d.ts +8 -0
- package/common/TypeInfoDataItemUtils.d.ts +39 -0
- package/{Types-C7XjUjoF.d.ts → common/TypeInfoORM/Types.d.ts} +117 -15
- package/common/TypeInfoORM/index.d.ts +3 -0
- package/common/TypeParsing/Constants.d.ts +4 -0
- package/common/TypeParsing/ParsingUtils/Constants.d.ts +8 -0
- package/common/TypeParsing/ParsingUtils/checkType.d.ts +14 -0
- package/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +12 -0
- package/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +8 -0
- package/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +12 -0
- package/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +14 -0
- package/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +18 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +9 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +9 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +11 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +12 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +11 -0
- package/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +9 -0
- package/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +11 -0
- package/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +8 -0
- package/common/TypeParsing/TypeInfo.d.ts +222 -0
- package/common/TypeParsing/Utils.d.ts +47 -0
- package/common/TypeParsing/Validation.d.ts +327 -0
- package/common/TypeParsing/index.d.ts +8 -0
- package/common/index.d.ts +40 -4
- package/common/index.js +25 -1737
- package/{index-BkFZlfit.d.ts → iac/SimpleCFT.d.ts} +5 -25
- package/iac/index.d.ts +40 -2
- package/iac/index.js +2 -1661
- package/iac/packs/auth.d.ts +131 -0
- package/iac/packs/build/utils.d.ts +289 -0
- package/iac/packs/build.d.ts +92 -0
- package/iac/packs/cdn.d.ts +33 -0
- package/iac/packs/cloud-function.d.ts +67 -0
- package/iac/packs/database.d.ts +32 -0
- package/iac/packs/dns.d.ts +34 -0
- package/iac/packs/file-storage.d.ts +46 -0
- package/iac/packs/gateway.d.ts +82 -0
- package/iac/packs/index.d.ts +60 -1
- package/iac/packs/index.js +391 -594
- package/iac/packs/repo.d.ts +28 -0
- package/iac/packs/ssl-certificate.d.ts +28 -0
- package/iac/types/Constants.d.ts +24 -0
- package/{index-DcvJOZ_c.d.ts → iac/types/IaCTypes.d.ts} +23 -1018
- package/iac/types/Renderers.d.ts +96 -0
- package/iac/types/Types.d.ts +131 -0
- package/iac/types/Utils.d.ts +9 -0
- package/iac/types/generate.d.ts +1 -0
- package/iac/utils/index.d.ts +87 -0
- package/iac/utils/patch-utils.d.ts +66 -0
- package/iac-packs/index.d.ts +6 -0
- package/native/forms/UI.d.ts +73 -0
- package/native/forms/createNativeFormRenderer.d.ts +21 -0
- package/native/forms/index.d.ts +25 -0
- package/native/forms/primitives/index.d.ts +38 -0
- package/native/forms/suite.d.ts +15 -0
- package/native/index.d.ts +19 -0
- package/native/index.js +748 -0
- package/native/testing/react-native.d.ts +46 -0
- package/native/utils/EasyLayout.d.ts +88 -0
- package/native/utils/History.d.ts +102 -0
- package/native/utils/Route.d.ts +80 -0
- package/native/utils/index.d.ts +20 -0
- package/package.json +54 -21
- package/web/forms/UI.d.ts +74 -0
- package/web/forms/createWebFormRenderer.d.ts +21 -0
- package/web/forms/index.d.ts +9 -0
- package/web/forms/primitives/index.d.ts +21 -0
- package/web/forms/suite.d.ts +15 -0
- package/web/index.d.ts +15 -0
- package/web/index.js +668 -0
- package/web/utils/EasyLayout.d.ts +47 -0
- package/web/utils/Route.d.ts +16 -0
- package/web/utils/index.d.ts +7 -0
- package/SearchTypes-DjN6YQzE.d.ts +0 -577
- package/Validation-CFP59oIP.d.ts +0 -226
- package/index-C3-iD9Mh.d.ts +0 -690
- package/index-DZ2BB4iX.d.ts +0 -5357
- package/index-IokxSNxm.d.ts +0 -745
- package/index.d.ts +0 -13
- package/index.js +0 -10973
|
@@ -0,0 +1,1185 @@
|
|
|
1
|
+
import { getErrorDescriptor, getNoErrorDescriptor, validateTypeInfoDataItem, getArrayItemErrorMap, getErrorDescriptors, ERROR_MESSAGE_CONSTANTS } from './chunk-YCTVEW2I.js';
|
|
2
|
+
import { resolveRouteAdapterPath, getPathString, mergeStringPaths, getParamsAndTestPath } from './chunk-WNFRDIBW.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 RouteContext = createContext({
|
|
544
|
+
currentWindowPath: "",
|
|
545
|
+
parentPath: "",
|
|
546
|
+
params: {},
|
|
547
|
+
isTopLevel: true
|
|
548
|
+
});
|
|
549
|
+
var {
|
|
550
|
+
/**
|
|
551
|
+
* @ignore
|
|
552
|
+
*/
|
|
553
|
+
Provider: RouteContextProvider,
|
|
554
|
+
/**
|
|
555
|
+
* @ignore
|
|
556
|
+
*/
|
|
557
|
+
Consumer: RouteContextConsumer
|
|
558
|
+
} = RouteContext;
|
|
559
|
+
var useRouteContext = () => useContext(RouteContext);
|
|
560
|
+
var wrappedRouteAdapterCache = /* @__PURE__ */ new WeakMap();
|
|
561
|
+
var wrapRouteAdapterWithPathResolver = (adapter) => {
|
|
562
|
+
if (!adapter.push && !adapter.replace) {
|
|
563
|
+
return adapter;
|
|
564
|
+
}
|
|
565
|
+
const cachedAdapter = wrappedRouteAdapterCache.get(adapter);
|
|
566
|
+
if (cachedAdapter) {
|
|
567
|
+
return cachedAdapter;
|
|
568
|
+
}
|
|
569
|
+
const wrappedAdapter = {
|
|
570
|
+
...adapter,
|
|
571
|
+
push: adapter.push ? (path, title) => {
|
|
572
|
+
adapter.push?.(resolveRouteAdapterPath(adapter.getPath(), path), title);
|
|
573
|
+
} : void 0,
|
|
574
|
+
replace: adapter.replace ? (path, title) => {
|
|
575
|
+
adapter.replace?.(resolveRouteAdapterPath(adapter.getPath(), path), title);
|
|
576
|
+
} : void 0
|
|
577
|
+
};
|
|
578
|
+
wrappedRouteAdapterCache.set(adapter, wrappedAdapter);
|
|
579
|
+
return wrappedAdapter;
|
|
580
|
+
};
|
|
581
|
+
var getWindow2 = () => {
|
|
582
|
+
if (typeof globalThis === "undefined") {
|
|
583
|
+
return void 0;
|
|
584
|
+
}
|
|
585
|
+
if ("window" in globalThis) {
|
|
586
|
+
return globalThis.window;
|
|
587
|
+
}
|
|
588
|
+
return void 0;
|
|
589
|
+
};
|
|
590
|
+
var useBrowserLinkInterceptor = (adapter) => {
|
|
591
|
+
useEffect(() => {
|
|
592
|
+
const WINDOW = getWindow2();
|
|
593
|
+
if (!WINDOW || !adapter?.push) {
|
|
594
|
+
return void 0;
|
|
595
|
+
}
|
|
596
|
+
const handleAnchorClick = (event) => {
|
|
597
|
+
let target = event.target;
|
|
598
|
+
while (target && target.nodeName !== "A") {
|
|
599
|
+
target = target.parentNode;
|
|
600
|
+
}
|
|
601
|
+
if (!target || target.nodeName !== "A") {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
const anchor = target;
|
|
605
|
+
const href = anchor.getAttribute("href");
|
|
606
|
+
const title = anchor.getAttribute("title") ?? "";
|
|
607
|
+
if (!href) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
try {
|
|
611
|
+
new URL(href);
|
|
612
|
+
return;
|
|
613
|
+
} catch (error) {
|
|
614
|
+
const nextPath = resolveRouteAdapterPath(
|
|
615
|
+
WINDOW.location?.pathname ?? "",
|
|
616
|
+
href
|
|
617
|
+
);
|
|
618
|
+
event.preventDefault();
|
|
619
|
+
adapter.push?.(nextPath, title);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
WINDOW.document?.addEventListener("click", handleAnchorClick);
|
|
623
|
+
return () => {
|
|
624
|
+
WINDOW.document?.removeEventListener("click", handleAnchorClick);
|
|
625
|
+
};
|
|
626
|
+
}, [adapter]);
|
|
627
|
+
};
|
|
628
|
+
var RouteProvider = ({
|
|
629
|
+
adapter,
|
|
630
|
+
initialPath,
|
|
631
|
+
children
|
|
632
|
+
}) => {
|
|
633
|
+
const normalizedAdapter = useMemo(
|
|
634
|
+
() => wrapRouteAdapterWithPathResolver(adapter),
|
|
635
|
+
[adapter]
|
|
636
|
+
);
|
|
637
|
+
const [currentPath, setCurrentPath] = useState(
|
|
638
|
+
initialPath ?? normalizedAdapter.getPath()
|
|
639
|
+
);
|
|
640
|
+
useEffect(() => {
|
|
641
|
+
return normalizedAdapter.subscribe((nextPath) => {
|
|
642
|
+
setCurrentPath(nextPath);
|
|
643
|
+
});
|
|
644
|
+
}, [normalizedAdapter]);
|
|
645
|
+
const contextValue = useMemo(
|
|
646
|
+
() => ({
|
|
647
|
+
currentWindowPath: currentPath,
|
|
648
|
+
parentPath: "",
|
|
649
|
+
params: {},
|
|
650
|
+
isTopLevel: true,
|
|
651
|
+
adapter: normalizedAdapter
|
|
652
|
+
}),
|
|
653
|
+
[currentPath, normalizedAdapter]
|
|
654
|
+
);
|
|
655
|
+
return /* @__PURE__ */ jsx(RouteContextProvider, { value: contextValue, children });
|
|
656
|
+
};
|
|
657
|
+
var RouteMatcher = ({
|
|
658
|
+
/**
|
|
659
|
+
* Use `:` as the first character to denote a parameter in the path.
|
|
660
|
+
*/
|
|
661
|
+
path,
|
|
662
|
+
onParamsChange,
|
|
663
|
+
exact = false,
|
|
664
|
+
children
|
|
665
|
+
}) => {
|
|
666
|
+
const {
|
|
667
|
+
currentWindowPath = "",
|
|
668
|
+
parentPath = "",
|
|
669
|
+
params: parentParams = {},
|
|
670
|
+
adapter
|
|
671
|
+
} = useRouteContext();
|
|
672
|
+
const targetCurrentPath = useMemo(
|
|
673
|
+
() => currentWindowPath,
|
|
674
|
+
[currentWindowPath]
|
|
675
|
+
);
|
|
676
|
+
const fullPath = useMemo(
|
|
677
|
+
() => mergeStringPaths(parentPath, path),
|
|
678
|
+
[parentPath, path]
|
|
679
|
+
);
|
|
680
|
+
const newParams = useMemo(
|
|
681
|
+
() => getParamsAndTestPath(targetCurrentPath, fullPath, exact),
|
|
682
|
+
[targetCurrentPath, fullPath, exact]
|
|
683
|
+
);
|
|
684
|
+
const params = useMemo(
|
|
685
|
+
() => ({
|
|
686
|
+
...parentParams,
|
|
687
|
+
...newParams ? newParams : {}
|
|
688
|
+
}),
|
|
689
|
+
[parentParams, newParams]
|
|
690
|
+
);
|
|
691
|
+
const newRouteContext = useMemo(
|
|
692
|
+
() => ({
|
|
693
|
+
currentWindowPath: targetCurrentPath,
|
|
694
|
+
parentPath: fullPath,
|
|
695
|
+
params,
|
|
696
|
+
isTopLevel: false,
|
|
697
|
+
adapter
|
|
698
|
+
}),
|
|
699
|
+
[targetCurrentPath, fullPath, params, adapter]
|
|
700
|
+
);
|
|
701
|
+
useEffect(() => {
|
|
702
|
+
if (onParamsChange) {
|
|
703
|
+
onParamsChange(params);
|
|
704
|
+
}
|
|
705
|
+
}, [params, onParamsChange]);
|
|
706
|
+
return newParams ? /* @__PURE__ */ jsx(RouteContextProvider, { value: newRouteContext, children }) : null;
|
|
707
|
+
};
|
|
708
|
+
var RouteRootProvider = ({
|
|
709
|
+
children,
|
|
710
|
+
adapter,
|
|
711
|
+
initialPath,
|
|
712
|
+
ingress,
|
|
713
|
+
runtimeIntegration
|
|
714
|
+
}) => {
|
|
715
|
+
const routeContext = useRouteContext();
|
|
716
|
+
const autoAdapterRef = useRef(null);
|
|
717
|
+
if (typeof routeContext.adapter !== "undefined" && isDevelopmentMode()) {
|
|
718
|
+
throw new Error(
|
|
719
|
+
"Route provider mode is root-only. Nested Route requires a path."
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
if (!autoAdapterRef.current) {
|
|
723
|
+
autoAdapterRef.current = adapter ?? createUniversalAdapter({ initialPath, ingress });
|
|
724
|
+
}
|
|
725
|
+
useBrowserLinkInterceptor(autoAdapterRef.current);
|
|
726
|
+
useEffect(() => {
|
|
727
|
+
if (!runtimeIntegration || !autoAdapterRef.current) {
|
|
728
|
+
return void 0;
|
|
729
|
+
}
|
|
730
|
+
return runtimeIntegration.setup(autoAdapterRef.current);
|
|
731
|
+
}, [runtimeIntegration]);
|
|
732
|
+
return /* @__PURE__ */ jsx(RouteProvider, { adapter: autoAdapterRef.current, initialPath, children });
|
|
733
|
+
};
|
|
734
|
+
var Route = (props) => {
|
|
735
|
+
const hasMatcherProps = typeof props.path !== "undefined" || typeof props.exact !== "undefined" || typeof props.onParamsChange !== "undefined";
|
|
736
|
+
const hasProviderProps = typeof props.initialPath !== "undefined" || typeof props.adapter !== "undefined" || typeof props.ingress !== "undefined" || typeof props.runtimeIntegration !== "undefined";
|
|
737
|
+
if (hasMatcherProps) {
|
|
738
|
+
if (hasProviderProps && isDevelopmentMode()) {
|
|
739
|
+
throw new Error(
|
|
740
|
+
"Route matcher mode does not support provider props. Remove initialPath/adapter/ingress/runtimeIntegration or use a root Route without path."
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
return /* @__PURE__ */ jsx(
|
|
744
|
+
RouteMatcher,
|
|
745
|
+
{
|
|
746
|
+
path: props.path ?? "",
|
|
747
|
+
onParamsChange: props.onParamsChange,
|
|
748
|
+
exact: props.exact,
|
|
749
|
+
children: props.children
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
if (typeof props.path === "undefined") {
|
|
754
|
+
return /* @__PURE__ */ jsx(
|
|
755
|
+
RouteRootProvider,
|
|
756
|
+
{
|
|
757
|
+
adapter: props.adapter,
|
|
758
|
+
initialPath: props.initialPath,
|
|
759
|
+
ingress: props.ingress,
|
|
760
|
+
runtimeIntegration: props.runtimeIntegration,
|
|
761
|
+
children: props.children
|
|
762
|
+
}
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
return null;
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
// src/app/forms/core/getFieldKind.ts
|
|
769
|
+
var hasSelectableValues = (field) => {
|
|
770
|
+
const possibleValues = field.possibleValues ?? [];
|
|
771
|
+
return possibleValues.some(
|
|
772
|
+
(value) => typeof value === "string" || typeof value === "number"
|
|
773
|
+
);
|
|
774
|
+
};
|
|
775
|
+
var getFieldKind = (field) => {
|
|
776
|
+
if (field.typeReference) {
|
|
777
|
+
return field.array ? "relation_array" : "relation_single";
|
|
778
|
+
}
|
|
779
|
+
if (field.tags?.customType) {
|
|
780
|
+
return field.array ? "custom_array" : "custom_single";
|
|
781
|
+
}
|
|
782
|
+
if (field.array) {
|
|
783
|
+
return "array";
|
|
784
|
+
}
|
|
785
|
+
if (hasSelectableValues(field)) {
|
|
786
|
+
return "enum_select";
|
|
787
|
+
}
|
|
788
|
+
if (field.type === "boolean") {
|
|
789
|
+
return "boolean";
|
|
790
|
+
}
|
|
791
|
+
if (field.type === "number") {
|
|
792
|
+
return "number";
|
|
793
|
+
}
|
|
794
|
+
return "string";
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// src/app/forms/core/resolveSuite.ts
|
|
798
|
+
var fieldKinds = [
|
|
799
|
+
"string",
|
|
800
|
+
"number",
|
|
801
|
+
"boolean",
|
|
802
|
+
"enum_select",
|
|
803
|
+
"array",
|
|
804
|
+
"relation_single",
|
|
805
|
+
"relation_array",
|
|
806
|
+
"custom_single",
|
|
807
|
+
"custom_array"
|
|
808
|
+
];
|
|
809
|
+
var getMissingKinds = (renderers) => {
|
|
810
|
+
return fieldKinds.filter((kind) => !renderers[kind]);
|
|
811
|
+
};
|
|
812
|
+
var resolveSuite = (overrides, fallback) => {
|
|
813
|
+
const mergedRenderers = {
|
|
814
|
+
...fallback.renderers ?? {},
|
|
815
|
+
...overrides?.renderers ?? {}
|
|
816
|
+
};
|
|
817
|
+
const missingKinds = getMissingKinds(mergedRenderers);
|
|
818
|
+
if (missingKinds.length) {
|
|
819
|
+
throw new Error(
|
|
820
|
+
`Missing renderers for field kinds: ${missingKinds.join(", ")}`
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
const mergedPrimitives = {
|
|
824
|
+
...fallback.primitives ?? {},
|
|
825
|
+
...overrides?.primitives ?? {}
|
|
826
|
+
};
|
|
827
|
+
return {
|
|
828
|
+
renderers: mergedRenderers,
|
|
829
|
+
primitives: Object.keys(mergedPrimitives).length ? mergedPrimitives : void 0
|
|
830
|
+
};
|
|
831
|
+
};
|
|
832
|
+
var createAutoField = (suite) => {
|
|
833
|
+
const defaultTranslateValidationErrorCode2 = (error) => error.code === ERROR_MESSAGE_CONSTANTS.NONE ? "" : String(error.code);
|
|
834
|
+
const AutoField = (props) => {
|
|
835
|
+
const { field, fieldKey, value, onChange, error, disabled } = props;
|
|
836
|
+
const { tags } = field;
|
|
837
|
+
const resolvedErrors = props.errors ?? (error ? [error] : []);
|
|
838
|
+
const resolvedError = resolvedErrors.find((descriptor) => descriptor.code !== ERROR_MESSAGE_CONSTANTS.NONE) ?? getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.NONE);
|
|
839
|
+
const context = {
|
|
840
|
+
field,
|
|
841
|
+
fieldKey,
|
|
842
|
+
label: tags?.label ?? fieldKey,
|
|
843
|
+
required: !field.optional,
|
|
844
|
+
disabled: !!disabled,
|
|
845
|
+
error: resolvedError,
|
|
846
|
+
errors: resolvedErrors,
|
|
847
|
+
arrayItemErrorMap: props.arrayItemErrorMap,
|
|
848
|
+
translateValidationErrorCode: props.translateValidationErrorCode ?? defaultTranslateValidationErrorCode2,
|
|
849
|
+
value,
|
|
850
|
+
onChange,
|
|
851
|
+
constraints: tags?.constraints,
|
|
852
|
+
format: tags?.format,
|
|
853
|
+
possibleValues: field.possibleValues,
|
|
854
|
+
allowCustomSelection: tags?.allowCustomSelection,
|
|
855
|
+
customType: tags?.customType,
|
|
856
|
+
onRelationAction: props.onRelationAction,
|
|
857
|
+
onCustomTypeAction: props.onCustomTypeAction,
|
|
858
|
+
renderField: (input) => createElement(AutoField, {
|
|
859
|
+
field: input.field,
|
|
860
|
+
fieldKey: input.fieldKey,
|
|
861
|
+
value: input.value,
|
|
862
|
+
onChange: input.onChange,
|
|
863
|
+
error: input.error,
|
|
864
|
+
errors: input.errors,
|
|
865
|
+
arrayItemErrorMap: input.arrayItemErrorMap,
|
|
866
|
+
translateValidationErrorCode: input.translateValidationErrorCode,
|
|
867
|
+
disabled: input.disabled,
|
|
868
|
+
onRelationAction: input.onRelationAction,
|
|
869
|
+
onCustomTypeAction: input.onCustomTypeAction
|
|
870
|
+
})
|
|
871
|
+
};
|
|
872
|
+
const kind = getFieldKind(field);
|
|
873
|
+
return createElement(suite.renderers[kind], context);
|
|
874
|
+
};
|
|
875
|
+
return AutoField;
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// src/app/forms/core/createFormRenderer.ts
|
|
879
|
+
var createFormRenderer = (options) => {
|
|
880
|
+
const resolvedSuite = resolveSuite(
|
|
881
|
+
options.suite,
|
|
882
|
+
options.fallbackSuite
|
|
883
|
+
);
|
|
884
|
+
const AutoField = createAutoField(resolvedSuite);
|
|
885
|
+
return {
|
|
886
|
+
AutoField,
|
|
887
|
+
suite: resolvedSuite
|
|
888
|
+
};
|
|
889
|
+
};
|
|
890
|
+
var getDeniedOperation = (deniedOperations, operation) => {
|
|
891
|
+
if (!deniedOperations) {
|
|
892
|
+
return false;
|
|
893
|
+
}
|
|
894
|
+
const denied = deniedOperations[operation];
|
|
895
|
+
if (typeof denied === "boolean") {
|
|
896
|
+
return denied;
|
|
897
|
+
}
|
|
898
|
+
return deniedOperations[operation.toLowerCase()] ?? false;
|
|
899
|
+
};
|
|
900
|
+
var buildInitialValues = (initialValues, typeInfo) => {
|
|
901
|
+
const values = { ...initialValues };
|
|
902
|
+
for (const [key, field] of Object.entries(typeInfo.fields ?? {})) {
|
|
903
|
+
if (values[key] !== void 0) {
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
const defaultValue = field.tags?.constraints?.defaultValue;
|
|
907
|
+
if (defaultValue !== void 0) {
|
|
908
|
+
let parsedDefaultValue = defaultValue;
|
|
909
|
+
try {
|
|
910
|
+
parsedDefaultValue = JSON.parse(defaultValue);
|
|
911
|
+
} catch (error) {
|
|
912
|
+
}
|
|
913
|
+
values[key] = parsedDefaultValue;
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
if (field.array && !field.typeReference && !field.optional) {
|
|
917
|
+
values[key] = [];
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
if (field.type === "boolean" && !field.optional) {
|
|
921
|
+
values[key] = false;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return values;
|
|
925
|
+
};
|
|
926
|
+
var FORM_ENGINE_TYPE_NAME = "__AUTO_FORM__";
|
|
927
|
+
var useFormEngine = (initialValues = {}, typeInfo, options) => {
|
|
928
|
+
const operation = options?.operation ?? "CREATE" /* CREATE */;
|
|
929
|
+
const customValidatorMap = options?.customValidatorMap ?? {};
|
|
930
|
+
const [values, setValues] = useState(
|
|
931
|
+
buildInitialValues(initialValues, typeInfo)
|
|
932
|
+
);
|
|
933
|
+
const [errors, setErrorsState] = useState({});
|
|
934
|
+
const normalizeErrorEntries = useCallback(
|
|
935
|
+
(value) => {
|
|
936
|
+
if (typeof value === "string") {
|
|
937
|
+
return [getErrorDescriptor(value)];
|
|
938
|
+
}
|
|
939
|
+
if (Array.isArray(value)) {
|
|
940
|
+
return value;
|
|
941
|
+
}
|
|
942
|
+
if (value && typeof value === "object") {
|
|
943
|
+
if ("code" in value && typeof value.code === "string") {
|
|
944
|
+
return [value];
|
|
945
|
+
}
|
|
946
|
+
const itemErrorMap = value;
|
|
947
|
+
const numericKeys = Object.keys(itemErrorMap).filter(
|
|
948
|
+
(key) => /^\d+$/.test(key)
|
|
949
|
+
);
|
|
950
|
+
if (numericKeys.length) {
|
|
951
|
+
const normalizedItemErrorMap = {};
|
|
952
|
+
for (const key of numericKeys) {
|
|
953
|
+
const index = Number(key);
|
|
954
|
+
const rawValue = itemErrorMap[key];
|
|
955
|
+
if (!Array.isArray(rawValue)) {
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
normalizedItemErrorMap[index] = rawValue.filter(
|
|
959
|
+
(descriptor) => !!descriptor && typeof descriptor === "object" && "code" in descriptor && typeof descriptor.code === "string"
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
return [{ itemErrorMap: normalizedItemErrorMap }];
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return [getNoErrorDescriptor()];
|
|
966
|
+
},
|
|
967
|
+
[]
|
|
968
|
+
);
|
|
969
|
+
const normalizeErrorMap = useCallback(
|
|
970
|
+
(pendingErrors) => Object.entries(pendingErrors).reduce((acc, [key, value]) => {
|
|
971
|
+
acc[key] = normalizeErrorEntries(value);
|
|
972
|
+
return acc;
|
|
973
|
+
}, {}),
|
|
974
|
+
[normalizeErrorEntries]
|
|
975
|
+
);
|
|
976
|
+
const setErrors = useCallback(
|
|
977
|
+
(pendingErrors) => {
|
|
978
|
+
setErrorsState(normalizeErrorMap(pendingErrors));
|
|
979
|
+
},
|
|
980
|
+
[normalizeErrorMap]
|
|
981
|
+
);
|
|
982
|
+
const setFieldValue = useCallback((path, value) => {
|
|
983
|
+
setValues((prev) => {
|
|
984
|
+
return {
|
|
985
|
+
...prev,
|
|
986
|
+
[path]: value
|
|
987
|
+
};
|
|
988
|
+
});
|
|
989
|
+
}, []);
|
|
990
|
+
const validate = useCallback(() => {
|
|
991
|
+
const fields2 = typeInfo.fields ?? {};
|
|
992
|
+
const validationResults = validateTypeInfoDataItem(
|
|
993
|
+
values,
|
|
994
|
+
typeInfo,
|
|
995
|
+
customValidatorMap,
|
|
996
|
+
{
|
|
997
|
+
typeName: FORM_ENGINE_TYPE_NAME,
|
|
998
|
+
typeOperation: operation
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
1001
|
+
const newErrors = {};
|
|
1002
|
+
for (const key of Object.keys(fields2)) {
|
|
1003
|
+
newErrors[key] = validationResults.errorMap[key] ?? [getNoErrorDescriptor()];
|
|
1004
|
+
}
|
|
1005
|
+
setErrorsState(newErrors);
|
|
1006
|
+
return validationResults;
|
|
1007
|
+
}, [typeInfo, values, operation, customValidatorMap]);
|
|
1008
|
+
const fields = useMemo(() => {
|
|
1009
|
+
return Object.entries(typeInfo.fields ?? {}).map(([key, field]) => {
|
|
1010
|
+
const { tags } = field;
|
|
1011
|
+
const isPrimary = tags?.primaryField || typeInfo.primaryField === key;
|
|
1012
|
+
return {
|
|
1013
|
+
key,
|
|
1014
|
+
field,
|
|
1015
|
+
label: tags?.label ?? key,
|
|
1016
|
+
required: !field.optional,
|
|
1017
|
+
disabled: field.readonly || getDeniedOperation(typeInfo.tags?.deniedOperations, operation) || getDeniedOperation(tags?.deniedOperations, operation) || operation === "UPDATE" /* UPDATE */ && isPrimary,
|
|
1018
|
+
hidden: !!tags?.hidden,
|
|
1019
|
+
primary: isPrimary,
|
|
1020
|
+
format: tags?.format,
|
|
1021
|
+
constraints: tags?.constraints,
|
|
1022
|
+
value: values[key],
|
|
1023
|
+
onChange: (value) => setFieldValue(key, value),
|
|
1024
|
+
error: getErrorDescriptors(errors[key] ?? []).find(
|
|
1025
|
+
(descriptor) => descriptor.code !== ERROR_MESSAGE_CONSTANTS.NONE
|
|
1026
|
+
) ?? getNoErrorDescriptor(),
|
|
1027
|
+
errors: getErrorDescriptors(errors[key] ?? []),
|
|
1028
|
+
arrayItemErrorMap: getArrayItemErrorMap(errors[key] ?? [])
|
|
1029
|
+
};
|
|
1030
|
+
});
|
|
1031
|
+
}, [typeInfo, values, errors, setFieldValue, operation]);
|
|
1032
|
+
return {
|
|
1033
|
+
typeInfo,
|
|
1034
|
+
typeTags: typeInfo.tags,
|
|
1035
|
+
operation,
|
|
1036
|
+
values,
|
|
1037
|
+
errors,
|
|
1038
|
+
fields,
|
|
1039
|
+
setFieldValue,
|
|
1040
|
+
validate,
|
|
1041
|
+
setErrors
|
|
1042
|
+
};
|
|
1043
|
+
};
|
|
1044
|
+
var fallbackFormRoot = ({
|
|
1045
|
+
children,
|
|
1046
|
+
onSubmit
|
|
1047
|
+
}) => {
|
|
1048
|
+
const handleSubmit = (event) => {
|
|
1049
|
+
event.preventDefault();
|
|
1050
|
+
onSubmit?.();
|
|
1051
|
+
};
|
|
1052
|
+
return /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, children });
|
|
1053
|
+
};
|
|
1054
|
+
var fallbackButton = ({
|
|
1055
|
+
children,
|
|
1056
|
+
disabled,
|
|
1057
|
+
type,
|
|
1058
|
+
onClick
|
|
1059
|
+
}) => {
|
|
1060
|
+
return /* @__PURE__ */ jsx("button", { type: type ?? "button", disabled, onClick, children });
|
|
1061
|
+
};
|
|
1062
|
+
var AutoFormView = ({
|
|
1063
|
+
controller,
|
|
1064
|
+
onSubmit,
|
|
1065
|
+
renderer,
|
|
1066
|
+
submitDisabled,
|
|
1067
|
+
onRelationAction,
|
|
1068
|
+
onCustomTypeAction,
|
|
1069
|
+
translateValidationErrorCode = defaultTranslateValidationErrorCode
|
|
1070
|
+
}) => {
|
|
1071
|
+
const FormRoot = renderer.suite.primitives?.FormRoot ?? fallbackFormRoot;
|
|
1072
|
+
const Button = renderer.suite.primitives?.Button ?? fallbackButton;
|
|
1073
|
+
const AutoField = renderer.AutoField;
|
|
1074
|
+
const submit = () => {
|
|
1075
|
+
const validationResults = controller.validate();
|
|
1076
|
+
if (validationResults.valid) {
|
|
1077
|
+
onSubmit(controller.values);
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
return /* @__PURE__ */ jsx(FormRoot, { onSubmit: submit, children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1081
|
+
controller.fields.filter((fieldController) => !fieldController.hidden).map((fieldController) => /* @__PURE__ */ jsx(
|
|
1082
|
+
AutoField,
|
|
1083
|
+
{
|
|
1084
|
+
field: fieldController.field,
|
|
1085
|
+
fieldKey: fieldController.key,
|
|
1086
|
+
value: fieldController.value,
|
|
1087
|
+
onChange: fieldController.onChange,
|
|
1088
|
+
error: fieldController.error,
|
|
1089
|
+
errors: fieldController.errors,
|
|
1090
|
+
arrayItemErrorMap: fieldController.arrayItemErrorMap,
|
|
1091
|
+
translateValidationErrorCode,
|
|
1092
|
+
onRelationAction,
|
|
1093
|
+
disabled: fieldController.disabled,
|
|
1094
|
+
onCustomTypeAction
|
|
1095
|
+
},
|
|
1096
|
+
fieldController.key
|
|
1097
|
+
)),
|
|
1098
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", onClick: submit, disabled: submitDisabled, children: /* @__PURE__ */ jsx(Fragment, { children: "Submit" }) })
|
|
1099
|
+
] }) });
|
|
1100
|
+
};
|
|
1101
|
+
var defaultTranslateValidationErrorCode = (error) => {
|
|
1102
|
+
const { code, values = [] } = error;
|
|
1103
|
+
const [constraintValue] = values;
|
|
1104
|
+
switch (code) {
|
|
1105
|
+
case ERROR_MESSAGE_CONSTANTS.INVALID_CUSTOM_TYPE:
|
|
1106
|
+
return "Value failed custom validation";
|
|
1107
|
+
case ERROR_MESSAGE_CONSTANTS.NOT_A_STRING:
|
|
1108
|
+
return "Value must be a string";
|
|
1109
|
+
case ERROR_MESSAGE_CONSTANTS.NOT_A_NUMBER:
|
|
1110
|
+
return "Value must be a number";
|
|
1111
|
+
case ERROR_MESSAGE_CONSTANTS.NOT_A_BOOLEAN:
|
|
1112
|
+
return "Value must be a boolean";
|
|
1113
|
+
case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_CREATE:
|
|
1114
|
+
return "Create operation is not allowed for this value";
|
|
1115
|
+
case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_READ:
|
|
1116
|
+
return "Read operation is not allowed for this value";
|
|
1117
|
+
case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_UPDATE:
|
|
1118
|
+
return "Update operation is not allowed for this value";
|
|
1119
|
+
case ERROR_MESSAGE_CONSTANTS.DENIED_TYPE_OPERATION_DELETE:
|
|
1120
|
+
return "Delete operation is not allowed for this value";
|
|
1121
|
+
case ERROR_MESSAGE_CONSTANTS.MISSING_FIELD_VALUE:
|
|
1122
|
+
return "This field is required";
|
|
1123
|
+
case ERROR_MESSAGE_CONSTANTS.INVALID_FIELD:
|
|
1124
|
+
return "This field is not allowed";
|
|
1125
|
+
case ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN:
|
|
1126
|
+
return "Value does not match required pattern";
|
|
1127
|
+
case ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN:
|
|
1128
|
+
return "Field pattern configuration is invalid";
|
|
1129
|
+
case ERROR_MESSAGE_CONSTANTS.VALUE_BELOW_MINIMUM:
|
|
1130
|
+
return `Value must be at least ${constraintValue ?? "the minimum"}`;
|
|
1131
|
+
case ERROR_MESSAGE_CONSTANTS.VALUE_ABOVE_MAXIMUM:
|
|
1132
|
+
return `Value must be at most ${constraintValue ?? "the maximum"}`;
|
|
1133
|
+
case ERROR_MESSAGE_CONSTANTS.INVALID_OPTION:
|
|
1134
|
+
return "Value is not one of the allowed options";
|
|
1135
|
+
case ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED:
|
|
1136
|
+
return "Relationship values are not allowed for this operation";
|
|
1137
|
+
case ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED:
|
|
1138
|
+
return "Value does not match any allowed shape";
|
|
1139
|
+
case ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST:
|
|
1140
|
+
return "Type definition was not found";
|
|
1141
|
+
case ERROR_MESSAGE_CONSTANTS.INVALID_TYPE:
|
|
1142
|
+
return "Value has an invalid type";
|
|
1143
|
+
case ERROR_MESSAGE_CONSTANTS.NONE:
|
|
1144
|
+
return "";
|
|
1145
|
+
default:
|
|
1146
|
+
return String(code);
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
var AutoForm = ({
|
|
1150
|
+
typeInfo,
|
|
1151
|
+
onSubmit,
|
|
1152
|
+
renderer,
|
|
1153
|
+
initialValues,
|
|
1154
|
+
onValuesChange,
|
|
1155
|
+
onRelationAction,
|
|
1156
|
+
onCustomTypeAction,
|
|
1157
|
+
operation,
|
|
1158
|
+
submitDisabled,
|
|
1159
|
+
translateValidationErrorCode = defaultTranslateValidationErrorCode,
|
|
1160
|
+
customValidatorMap
|
|
1161
|
+
}) => {
|
|
1162
|
+
const controller = useFormEngine(initialValues, typeInfo, {
|
|
1163
|
+
operation,
|
|
1164
|
+
customValidatorMap
|
|
1165
|
+
});
|
|
1166
|
+
useEffect(() => {
|
|
1167
|
+
if (onValuesChange) {
|
|
1168
|
+
onValuesChange(controller.values);
|
|
1169
|
+
}
|
|
1170
|
+
}, [controller.values, onValuesChange]);
|
|
1171
|
+
return /* @__PURE__ */ jsx(
|
|
1172
|
+
AutoFormView,
|
|
1173
|
+
{
|
|
1174
|
+
controller,
|
|
1175
|
+
onSubmit,
|
|
1176
|
+
renderer,
|
|
1177
|
+
onRelationAction,
|
|
1178
|
+
onCustomTypeAction,
|
|
1179
|
+
submitDisabled,
|
|
1180
|
+
translateValidationErrorCode
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
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 };
|