@form-engine-ts/react 4.8.0 → 5.0.1
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 +11 -1
- package/dist/index.cjs +546 -411
- package/dist/index.d.cts +62 -9
- package/dist/index.d.ts +62 -9
- package/dist/index.js +391 -258
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,8 @@ __export(index_exports, {
|
|
|
23
23
|
BUILDER_TRANSLATION_ALIASES: () => BUILDER_TRANSLATION_ALIASES,
|
|
24
24
|
BUILDER_TRANSLATION_KEYS: () => BUILDER_TRANSLATION_KEYS,
|
|
25
25
|
FormBuilder: () => FormBuilder,
|
|
26
|
+
FormEngineI18nContext: () => FormEngineI18nContext,
|
|
27
|
+
FormEngineI18nProvider: () => FormEngineI18nProvider,
|
|
26
28
|
FormProvider: () => FormProvider,
|
|
27
29
|
FormRenderer: () => FormRenderer,
|
|
28
30
|
FormSubmissionError: () => FormSubmissionError,
|
|
@@ -38,6 +40,7 @@ __export(index_exports, {
|
|
|
38
40
|
useField: () => useField,
|
|
39
41
|
useForm: () => useForm,
|
|
40
42
|
useFormBuilder: () => useFormBuilder,
|
|
43
|
+
useFormEngineI18n: () => useFormEngineI18n,
|
|
41
44
|
useSubmissionReceipts: () => useSubmissionReceipts,
|
|
42
45
|
useTranslationWorkspace: () => useTranslationWorkspace,
|
|
43
46
|
validateLocalePipeline: () => validateLocalePipeline
|
|
@@ -144,8 +147,8 @@ function createLocalStorageSubmissionAttemptStore(options = {}) {
|
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
// src/builder.tsx
|
|
147
|
-
var
|
|
148
|
-
var
|
|
150
|
+
var import_core3 = require("@form-engine-ts/core");
|
|
151
|
+
var import_react3 = require("react");
|
|
149
152
|
|
|
150
153
|
// src/hooks/useFormBuilder.ts
|
|
151
154
|
var import_core = require("@form-engine-ts/core");
|
|
@@ -960,8 +963,42 @@ function resolveTranslation(key, aliases, adapter, defaultCatalog, params = {},
|
|
|
960
963
|
return key;
|
|
961
964
|
}
|
|
962
965
|
|
|
963
|
-
// src/
|
|
966
|
+
// src/i18n/provider.tsx
|
|
967
|
+
var import_core2 = require("@form-engine-ts/core");
|
|
968
|
+
var import_react2 = require("react");
|
|
964
969
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
970
|
+
var defaultTranslator = (0, import_core2.createFormEngineTranslator)({ locale: "ja" });
|
|
971
|
+
var FormEngineI18nContext = (0, import_react2.createContext)({
|
|
972
|
+
uiLocale: "ja",
|
|
973
|
+
translator: defaultTranslator
|
|
974
|
+
});
|
|
975
|
+
var FormEngineI18nProviderScopeContext = (0, import_react2.createContext)(false);
|
|
976
|
+
function FormEngineI18nProvider({
|
|
977
|
+
locale = "ja",
|
|
978
|
+
fallbackLocale = "en",
|
|
979
|
+
messages,
|
|
980
|
+
customCatalogs,
|
|
981
|
+
translator: customTranslator,
|
|
982
|
+
children
|
|
983
|
+
}) {
|
|
984
|
+
const translator = (0, import_react2.useMemo)(() => {
|
|
985
|
+
if (customTranslator !== void 0) return customTranslator;
|
|
986
|
+
return (0, import_core2.createFormEngineTranslator)({
|
|
987
|
+
locale,
|
|
988
|
+
fallbackLocale,
|
|
989
|
+
...messages === void 0 ? {} : { messages },
|
|
990
|
+
...customCatalogs === void 0 ? {} : { customCatalogs }
|
|
991
|
+
});
|
|
992
|
+
}, [customCatalogs, customTranslator, fallbackLocale, locale, messages]);
|
|
993
|
+
const value = (0, import_react2.useMemo)(() => ({ uiLocale: locale, translator }), [locale, translator]);
|
|
994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormEngineI18nProviderScopeContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormEngineI18nContext.Provider, { value, children }) });
|
|
995
|
+
}
|
|
996
|
+
function useFormEngineI18n() {
|
|
997
|
+
return (0, import_react2.useContext)(FormEngineI18nContext);
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// src/builder.tsx
|
|
1001
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
965
1002
|
function DefaultButton({
|
|
966
1003
|
id,
|
|
967
1004
|
className,
|
|
@@ -975,7 +1012,7 @@ function DefaultButton({
|
|
|
975
1012
|
action,
|
|
976
1013
|
targetId
|
|
977
1014
|
}) {
|
|
978
|
-
return /* @__PURE__ */ (0,
|
|
1015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
979
1016
|
"button",
|
|
980
1017
|
{
|
|
981
1018
|
id,
|
|
@@ -994,7 +1031,7 @@ function DefaultButton({
|
|
|
994
1031
|
);
|
|
995
1032
|
}
|
|
996
1033
|
function DefaultIconButton(props) {
|
|
997
|
-
return /* @__PURE__ */ (0,
|
|
1034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
998
1035
|
DefaultButton,
|
|
999
1036
|
{
|
|
1000
1037
|
...props.id === void 0 ? {} : { id: props.id },
|
|
@@ -1073,10 +1110,10 @@ function DefaultTextInput({
|
|
|
1073
1110
|
max,
|
|
1074
1111
|
step
|
|
1075
1112
|
}) {
|
|
1076
|
-
const labelElement = label === void 0 ? null : id === void 0 ? /* @__PURE__ */ (0,
|
|
1077
|
-
return /* @__PURE__ */ (0,
|
|
1113
|
+
const labelElement = label === void 0 ? null : id === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: id, children: label });
|
|
1114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1078
1115
|
labelElement,
|
|
1079
|
-
/* @__PURE__ */ (0,
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1080
1117
|
"input",
|
|
1081
1118
|
{
|
|
1082
1119
|
id,
|
|
@@ -1100,7 +1137,7 @@ function DefaultTextInput({
|
|
|
1100
1137
|
onChange: (event) => onChange(event.currentTarget.value)
|
|
1101
1138
|
}
|
|
1102
1139
|
),
|
|
1103
|
-
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1140
|
+
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { id: ariaDescribedBy, children: helperText })
|
|
1104
1141
|
] });
|
|
1105
1142
|
}
|
|
1106
1143
|
function DefaultTextArea({
|
|
@@ -1122,10 +1159,10 @@ function DefaultTextArea({
|
|
|
1122
1159
|
placeholder,
|
|
1123
1160
|
maxLength
|
|
1124
1161
|
}) {
|
|
1125
|
-
const labelElement = label === void 0 ? null : id === void 0 ? /* @__PURE__ */ (0,
|
|
1126
|
-
return /* @__PURE__ */ (0,
|
|
1162
|
+
const labelElement = label === void 0 ? null : id === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: id, children: label });
|
|
1163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1127
1164
|
labelElement,
|
|
1128
|
-
/* @__PURE__ */ (0,
|
|
1165
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1129
1166
|
"textarea",
|
|
1130
1167
|
{
|
|
1131
1168
|
id,
|
|
@@ -1145,7 +1182,7 @@ function DefaultTextArea({
|
|
|
1145
1182
|
onChange: (event) => onChange(event.currentTarget.value)
|
|
1146
1183
|
}
|
|
1147
1184
|
),
|
|
1148
|
-
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1185
|
+
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { id: ariaDescribedBy, children: helperText })
|
|
1149
1186
|
] });
|
|
1150
1187
|
}
|
|
1151
1188
|
function DefaultSelect({
|
|
@@ -1171,10 +1208,10 @@ function DefaultSelect({
|
|
|
1171
1208
|
(option) => typeof option === "string" ? { value: option, label: option } : option
|
|
1172
1209
|
);
|
|
1173
1210
|
const selectedOption = normalizedOptions.find((option) => option.value === value);
|
|
1174
|
-
const labelElement = label === void 0 ? null : id === void 0 ? /* @__PURE__ */ (0,
|
|
1175
|
-
return /* @__PURE__ */ (0,
|
|
1211
|
+
const labelElement = label === void 0 ? null : id === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: id, children: label });
|
|
1212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1176
1213
|
labelElement,
|
|
1177
|
-
/* @__PURE__ */ (0,
|
|
1214
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1178
1215
|
"select",
|
|
1179
1216
|
{
|
|
1180
1217
|
id,
|
|
@@ -1189,11 +1226,11 @@ function DefaultSelect({
|
|
|
1189
1226
|
value,
|
|
1190
1227
|
onChange: (event) => onChange(event.currentTarget.value),
|
|
1191
1228
|
onKeyDown,
|
|
1192
|
-
children: normalizedOptions.map((option) => /* @__PURE__ */ (0,
|
|
1229
|
+
children: normalizedOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: option.value, disabled: option.disabled, children: renderOption === void 0 ? option.label : renderOption(option) }, option.value))
|
|
1193
1230
|
}
|
|
1194
1231
|
),
|
|
1195
|
-
renderValue === void 0 ? null : /* @__PURE__ */ (0,
|
|
1196
|
-
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1232
|
+
renderValue === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("output", { children: renderValue(selectedOption) }),
|
|
1233
|
+
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { id: ariaDescribedBy, children: helperText })
|
|
1197
1234
|
] });
|
|
1198
1235
|
}
|
|
1199
1236
|
function DefaultCheckbox({
|
|
@@ -1212,9 +1249,9 @@ function DefaultCheckbox({
|
|
|
1212
1249
|
onChange,
|
|
1213
1250
|
label
|
|
1214
1251
|
}) {
|
|
1215
|
-
return /* @__PURE__ */ (0,
|
|
1216
|
-
/* @__PURE__ */ (0,
|
|
1217
|
-
/* @__PURE__ */ (0,
|
|
1252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className, children: [
|
|
1254
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1218
1255
|
"input",
|
|
1219
1256
|
{
|
|
1220
1257
|
id,
|
|
@@ -1232,7 +1269,7 @@ function DefaultCheckbox({
|
|
|
1232
1269
|
),
|
|
1233
1270
|
label
|
|
1234
1271
|
] }),
|
|
1235
|
-
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1272
|
+
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { id: ariaDescribedBy, children: helperText })
|
|
1236
1273
|
] });
|
|
1237
1274
|
}
|
|
1238
1275
|
function DefaultSection({
|
|
@@ -1245,7 +1282,7 @@ function DefaultSection({
|
|
|
1245
1282
|
onClickCapture,
|
|
1246
1283
|
children
|
|
1247
1284
|
}) {
|
|
1248
|
-
return /* @__PURE__ */ (0,
|
|
1285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1249
1286
|
"section",
|
|
1250
1287
|
{
|
|
1251
1288
|
id,
|
|
@@ -1254,21 +1291,21 @@ function DefaultSection({
|
|
|
1254
1291
|
"aria-labelledby": title === void 0 ? void 0 : headingId,
|
|
1255
1292
|
onClickCapture,
|
|
1256
1293
|
children: [
|
|
1257
|
-
title === void 0 ? null : /* @__PURE__ */ (0,
|
|
1258
|
-
description === void 0 ? null : /* @__PURE__ */ (0,
|
|
1294
|
+
title === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { id: headingId, children: title }),
|
|
1295
|
+
description === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description }),
|
|
1259
1296
|
children
|
|
1260
1297
|
]
|
|
1261
1298
|
}
|
|
1262
1299
|
);
|
|
1263
1300
|
}
|
|
1264
1301
|
function DefaultFieldset({ className, legend, disabled, children }) {
|
|
1265
|
-
return /* @__PURE__ */ (0,
|
|
1266
|
-
legend === void 0 ? null : /* @__PURE__ */ (0,
|
|
1302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", { className, disabled, children: [
|
|
1303
|
+
legend === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { children: legend }),
|
|
1267
1304
|
children
|
|
1268
1305
|
] });
|
|
1269
1306
|
}
|
|
1270
1307
|
function DefaultErrorMessage({ className, message }) {
|
|
1271
|
-
return /* @__PURE__ */ (0,
|
|
1308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className, children: message });
|
|
1272
1309
|
}
|
|
1273
1310
|
var DEFAULT_COMPONENTS = {
|
|
1274
1311
|
Button: DefaultButton,
|
|
@@ -1283,7 +1320,7 @@ var DEFAULT_COMPONENTS = {
|
|
|
1283
1320
|
renderIcon: defaultIconFor,
|
|
1284
1321
|
renderFieldTypeIcon: defaultFieldTypeIcon
|
|
1285
1322
|
};
|
|
1286
|
-
var BuilderPrimitiveContext = (0,
|
|
1323
|
+
var BuilderPrimitiveContext = (0, import_react3.createContext)({
|
|
1287
1324
|
components: DEFAULT_COMPONENTS,
|
|
1288
1325
|
readOnly: false,
|
|
1289
1326
|
unstyled: false
|
|
@@ -1297,9 +1334,9 @@ function primitiveClassName(className, defaultClassName, unstyled) {
|
|
|
1297
1334
|
return [unstyled ? void 0 : defaultClassName, userClassName].filter((value) => value !== void 0).join(" ") || void 0;
|
|
1298
1335
|
}
|
|
1299
1336
|
function BuilderButton(props) {
|
|
1300
|
-
const context = (0,
|
|
1337
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1301
1338
|
const Component = context.components.Button;
|
|
1302
|
-
return /* @__PURE__ */ (0,
|
|
1339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1303
1340
|
Component,
|
|
1304
1341
|
{
|
|
1305
1342
|
...props,
|
|
@@ -1310,10 +1347,10 @@ function BuilderButton(props) {
|
|
|
1310
1347
|
);
|
|
1311
1348
|
}
|
|
1312
1349
|
function BuilderIconButton(props) {
|
|
1313
|
-
const context = (0,
|
|
1350
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1314
1351
|
const Component = context.components.IconButton;
|
|
1315
1352
|
const icon = props.actionType === void 0 ? props.icon ?? void 0 : context.components.renderIcon(props.actionType) ?? props.icon ?? defaultIconFor(props.actionType);
|
|
1316
|
-
return /* @__PURE__ */ (0,
|
|
1353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1317
1354
|
Component,
|
|
1318
1355
|
{
|
|
1319
1356
|
...props,
|
|
@@ -1325,9 +1362,9 @@ function BuilderIconButton(props) {
|
|
|
1325
1362
|
);
|
|
1326
1363
|
}
|
|
1327
1364
|
function BuilderTextInput(props) {
|
|
1328
|
-
const context = (0,
|
|
1365
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1329
1366
|
const Component = context.components.TextInput;
|
|
1330
|
-
return /* @__PURE__ */ (0,
|
|
1367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1331
1368
|
Component,
|
|
1332
1369
|
{
|
|
1333
1370
|
...props,
|
|
@@ -1338,9 +1375,9 @@ function BuilderTextInput(props) {
|
|
|
1338
1375
|
);
|
|
1339
1376
|
}
|
|
1340
1377
|
function BuilderTextArea(props) {
|
|
1341
|
-
const context = (0,
|
|
1378
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1342
1379
|
const Component = context.components.TextArea;
|
|
1343
|
-
return /* @__PURE__ */ (0,
|
|
1380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1344
1381
|
Component,
|
|
1345
1382
|
{
|
|
1346
1383
|
...props,
|
|
@@ -1351,9 +1388,9 @@ function BuilderTextArea(props) {
|
|
|
1351
1388
|
);
|
|
1352
1389
|
}
|
|
1353
1390
|
function BuilderSelect(props) {
|
|
1354
|
-
const context = (0,
|
|
1391
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1355
1392
|
const Component = context.components.Select;
|
|
1356
|
-
return /* @__PURE__ */ (0,
|
|
1393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1357
1394
|
Component,
|
|
1358
1395
|
{
|
|
1359
1396
|
...props,
|
|
@@ -1364,9 +1401,9 @@ function BuilderSelect(props) {
|
|
|
1364
1401
|
);
|
|
1365
1402
|
}
|
|
1366
1403
|
function BuilderCheckbox(props) {
|
|
1367
|
-
const context = (0,
|
|
1404
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1368
1405
|
const Component = context.components.Checkbox;
|
|
1369
|
-
return /* @__PURE__ */ (0,
|
|
1406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1370
1407
|
Component,
|
|
1371
1408
|
{
|
|
1372
1409
|
...props,
|
|
@@ -1377,18 +1414,18 @@ function BuilderCheckbox(props) {
|
|
|
1377
1414
|
);
|
|
1378
1415
|
}
|
|
1379
1416
|
function BuilderSection(props) {
|
|
1380
|
-
const Component = (0,
|
|
1381
|
-
return /* @__PURE__ */ (0,
|
|
1417
|
+
const Component = (0, import_react3.useContext)(BuilderPrimitiveContext).components.Section;
|
|
1418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { ...props });
|
|
1382
1419
|
}
|
|
1383
1420
|
function BuilderFieldset(props) {
|
|
1384
|
-
const context = (0,
|
|
1421
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1385
1422
|
const Component = context.components.Fieldset;
|
|
1386
|
-
return /* @__PURE__ */ (0,
|
|
1423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { ...props, disabled: context.readOnly || props.disabled === true });
|
|
1387
1424
|
}
|
|
1388
1425
|
function BuilderErrorMessage(props) {
|
|
1389
|
-
const context = (0,
|
|
1426
|
+
const context = (0, import_react3.useContext)(BuilderPrimitiveContext);
|
|
1390
1427
|
const Component = context.components.ErrorMessage;
|
|
1391
|
-
return /* @__PURE__ */ (0,
|
|
1428
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: primitiveClassName(props.className, "form-engine-builder__error", context.unstyled), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { message: props.message }) });
|
|
1392
1429
|
}
|
|
1393
1430
|
var GUARDED_COMPONENTS = {
|
|
1394
1431
|
Button: BuilderButton,
|
|
@@ -1556,7 +1593,7 @@ function BuilderSectionGroup({ children }) {
|
|
|
1556
1593
|
return children;
|
|
1557
1594
|
}
|
|
1558
1595
|
function sectionGroupName(node) {
|
|
1559
|
-
if (!(0,
|
|
1596
|
+
if (!(0, import_react3.isValidElement)(node) || node.type !== BuilderSectionGroup) return void 0;
|
|
1560
1597
|
return node.props.name;
|
|
1561
1598
|
}
|
|
1562
1599
|
function OrderedBuilderSections({
|
|
@@ -1565,11 +1602,11 @@ function OrderedBuilderSections({
|
|
|
1565
1602
|
}) {
|
|
1566
1603
|
if (order === void 0) return children;
|
|
1567
1604
|
const ranks = new Map(order.map((name, index) => [name, index]));
|
|
1568
|
-
const groups =
|
|
1605
|
+
const groups = import_react3.Children.toArray(children);
|
|
1569
1606
|
return groups.map((group, index) => ({ group, index, rank: ranks.get(sectionGroupName(group) ?? "questions") ?? order.length })).sort((left, right) => left.rank - right.rank || left.index - right.index).map(({ group }) => group);
|
|
1570
1607
|
}
|
|
1571
1608
|
function fieldTypeKey(type) {
|
|
1572
|
-
return
|
|
1609
|
+
return import_core3.DEFAULT_FIELD_TYPE_DEFINITIONS.find((definition) => definition.type === type)?.labelKey ?? `builder.fieldType.${type}`;
|
|
1573
1610
|
}
|
|
1574
1611
|
function operatorKey(operator) {
|
|
1575
1612
|
return `builder.operator.${operator}`;
|
|
@@ -1654,7 +1691,7 @@ function ConditionValueEditor({
|
|
|
1654
1691
|
if (condition.operator === "not_empty") return null;
|
|
1655
1692
|
const update = (value) => onChange({ ...condition, value });
|
|
1656
1693
|
if (source.type === "checkbox") {
|
|
1657
|
-
return /* @__PURE__ */ (0,
|
|
1694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1658
1695
|
Select,
|
|
1659
1696
|
{
|
|
1660
1697
|
value: String(condition.value),
|
|
@@ -1667,7 +1704,7 @@ function ConditionValueEditor({
|
|
|
1667
1704
|
);
|
|
1668
1705
|
}
|
|
1669
1706
|
if (source.type === "number" || source.type === "rating") {
|
|
1670
|
-
return /* @__PURE__ */ (0,
|
|
1707
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1671
1708
|
TextInput,
|
|
1672
1709
|
{
|
|
1673
1710
|
"aria-label": translate("builder.conditionValue"),
|
|
@@ -1678,7 +1715,7 @@ function ConditionValueEditor({
|
|
|
1678
1715
|
);
|
|
1679
1716
|
}
|
|
1680
1717
|
if ("options" in source) {
|
|
1681
|
-
return /* @__PURE__ */ (0,
|
|
1718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1682
1719
|
Select,
|
|
1683
1720
|
{
|
|
1684
1721
|
value: String(condition.value ?? ""),
|
|
@@ -1687,7 +1724,7 @@ function ConditionValueEditor({
|
|
|
1687
1724
|
}
|
|
1688
1725
|
);
|
|
1689
1726
|
}
|
|
1690
|
-
return /* @__PURE__ */ (0,
|
|
1727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1691
1728
|
TextInput,
|
|
1692
1729
|
{
|
|
1693
1730
|
"aria-label": translate("builder.conditionValue"),
|
|
@@ -1707,7 +1744,7 @@ function resolveInitialFieldType(defaultType, allowedTypes) {
|
|
|
1707
1744
|
function FormBuilder({
|
|
1708
1745
|
schema,
|
|
1709
1746
|
onChange,
|
|
1710
|
-
locale
|
|
1747
|
+
locale: explicitLocale,
|
|
1711
1748
|
translator,
|
|
1712
1749
|
translationAdapter,
|
|
1713
1750
|
translationOptions,
|
|
@@ -1734,6 +1771,12 @@ function FormBuilder({
|
|
|
1734
1771
|
onActiveFieldChange,
|
|
1735
1772
|
submissionSettingsOptions
|
|
1736
1773
|
}) {
|
|
1774
|
+
const i18n = useFormEngineI18n();
|
|
1775
|
+
const isProviderValue = (0, import_react3.useContext)(FormEngineI18nProviderScopeContext);
|
|
1776
|
+
const locale = explicitLocale ?? (isProviderValue ? i18n.uiLocale : "en");
|
|
1777
|
+
const resolvedTranslator = translator ?? (isProviderValue ? {
|
|
1778
|
+
translate: (key, _locale, params) => params === void 0 ? i18n.translator(key) : i18n.translator(key, { ...params })
|
|
1779
|
+
} : void 0);
|
|
1737
1780
|
const resolvedComponents = { ...DEFAULT_COMPONENTS, ...componentOverrides };
|
|
1738
1781
|
const components = {
|
|
1739
1782
|
...GUARDED_COMPONENTS,
|
|
@@ -1761,16 +1804,16 @@ function FormBuilder({
|
|
|
1761
1804
|
...defaultActiveFieldId === void 0 ? {} : { defaultActiveFieldId },
|
|
1762
1805
|
...onActiveFieldChange === void 0 ? {} : { onActiveFieldChange }
|
|
1763
1806
|
});
|
|
1764
|
-
const [newPageQuestionId, setNewPageQuestionId] = (0,
|
|
1765
|
-
const [newLocale, setNewLocale] = (0,
|
|
1766
|
-
const [editingLocale, setEditingLocale] = (0,
|
|
1767
|
-
const [isTranslating, setIsTranslating] = (0,
|
|
1768
|
-
const [translationError, setTranslationError] = (0,
|
|
1769
|
-
const [translationReport, setTranslationReport] = (0,
|
|
1807
|
+
const [newPageQuestionId, setNewPageQuestionId] = (0, import_react3.useState)("");
|
|
1808
|
+
const [newLocale, setNewLocale] = (0, import_react3.useState)("");
|
|
1809
|
+
const [editingLocale, setEditingLocale] = (0, import_react3.useState)("");
|
|
1810
|
+
const [isTranslating, setIsTranslating] = (0, import_react3.useState)(false);
|
|
1811
|
+
const [translationError, setTranslationError] = (0, import_react3.useState)(null);
|
|
1812
|
+
const [translationReport, setTranslationReport] = (0, import_react3.useState)();
|
|
1770
1813
|
const translate = (key, params = {}) => resolveTranslation(
|
|
1771
1814
|
key,
|
|
1772
1815
|
BUILDER_TRANSLATION_ALIASES[key] === void 0 ? [] : [BUILDER_TRANSLATION_ALIASES[key]],
|
|
1773
|
-
|
|
1816
|
+
resolvedTranslator,
|
|
1774
1817
|
BUILDER_DEFAULTS,
|
|
1775
1818
|
params,
|
|
1776
1819
|
locale
|
|
@@ -1882,7 +1925,7 @@ function FormBuilder({
|
|
|
1882
1925
|
setTranslationError(null);
|
|
1883
1926
|
try {
|
|
1884
1927
|
const translationPolicy = policy ?? translationOptions?.policy;
|
|
1885
|
-
const populated = await (0,
|
|
1928
|
+
const populated = await (0, import_core3.populateSchemaTranslations)(schema, [editingLocale], translationAdapter, {
|
|
1886
1929
|
overwrite: "missing-only",
|
|
1887
1930
|
...translationOptions,
|
|
1888
1931
|
...translationPolicy === void 0 ? {} : { policy: translationPolicy }
|
|
@@ -2039,11 +2082,11 @@ function FormBuilder({
|
|
|
2039
2082
|
params: { locale: targetLocale }
|
|
2040
2083
|
})
|
|
2041
2084
|
};
|
|
2042
|
-
return /* @__PURE__ */ (0,
|
|
2085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2043
2086
|
BuilderPrimitiveContext.Provider,
|
|
2044
2087
|
{
|
|
2045
2088
|
value: { components: resolvedComponents, readOnly, unstyled: defaultStylesDisabled },
|
|
2046
|
-
children: /* @__PURE__ */ (0,
|
|
2089
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2047
2090
|
Section,
|
|
2048
2091
|
{
|
|
2049
2092
|
className: defaultStylesDisabled ? className || void 0 : `form-engine-builder ${className}`.trim(),
|
|
@@ -2063,15 +2106,15 @@ function FormBuilder({
|
|
|
2063
2106
|
addOption(fieldId);
|
|
2064
2107
|
}
|
|
2065
2108
|
},
|
|
2066
|
-
children: /* @__PURE__ */ (0,
|
|
2067
|
-
/* @__PURE__ */ (0,
|
|
2109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fieldset, { className: builderClass("form-engine-builder__controls"), disabled: readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(OrderedBuilderSections, { ...resolvedSectionOrder === void 0 ? {} : { order: resolvedSectionOrder }, children: [
|
|
2110
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BuilderSectionGroup, { name: "basicSettings", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2068
2111
|
Section,
|
|
2069
2112
|
{
|
|
2070
2113
|
className: builderClass("form-engine-builder__basic-settings"),
|
|
2071
2114
|
headingId: "builder-basic-settings-heading",
|
|
2072
2115
|
title: translate("builder.basicSettings"),
|
|
2073
|
-
children: /* @__PURE__ */ (0,
|
|
2074
|
-
/* @__PURE__ */ (0,
|
|
2116
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2117
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2075
2118
|
TextInput,
|
|
2076
2119
|
{
|
|
2077
2120
|
id: "builder-form-title",
|
|
@@ -2085,7 +2128,7 @@ function FormBuilder({
|
|
|
2085
2128
|
onChange: (value) => setSourceText({ kind: "form" }, "title", value)
|
|
2086
2129
|
}
|
|
2087
2130
|
) }),
|
|
2088
|
-
/* @__PURE__ */ (0,
|
|
2131
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2089
2132
|
TextArea,
|
|
2090
2133
|
{
|
|
2091
2134
|
id: "builder-form-description",
|
|
@@ -2099,13 +2142,13 @@ function FormBuilder({
|
|
|
2099
2142
|
] })
|
|
2100
2143
|
}
|
|
2101
2144
|
) }),
|
|
2102
|
-
/* @__PURE__ */ (0,
|
|
2145
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BuilderSectionGroup, { name: "submissionSettings", children: submissionSettingsOptions?.enabled ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2103
2146
|
Section,
|
|
2104
2147
|
{
|
|
2105
2148
|
className: builderClass("form-engine-builder__submission-settings"),
|
|
2106
2149
|
title: translate("builder.submissionSettings"),
|
|
2107
2150
|
children: [
|
|
2108
|
-
/* @__PURE__ */ (0,
|
|
2151
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2109
2152
|
Checkbox,
|
|
2110
2153
|
{
|
|
2111
2154
|
id: "builder-show-confirmation",
|
|
@@ -2117,7 +2160,7 @@ function FormBuilder({
|
|
|
2117
2160
|
})
|
|
2118
2161
|
}
|
|
2119
2162
|
),
|
|
2120
|
-
/* @__PURE__ */ (0,
|
|
2163
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2121
2164
|
Select,
|
|
2122
2165
|
{
|
|
2123
2166
|
id: "builder-confirmation-render-mode",
|
|
@@ -2140,7 +2183,7 @@ function FormBuilder({
|
|
|
2140
2183
|
]
|
|
2141
2184
|
}
|
|
2142
2185
|
) : null }),
|
|
2143
|
-
resolvedSectionOrder === void 0 ? null : /* @__PURE__ */ (0,
|
|
2186
|
+
resolvedSectionOrder === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BuilderSectionGroup, { name: "completionMessage", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Section, { headingId: "builder-completion-message-heading", title: translate("builder.completionMessage"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2144
2187
|
TextInput,
|
|
2145
2188
|
{
|
|
2146
2189
|
id: "builder-completion-message",
|
|
@@ -2149,27 +2192,27 @@ function FormBuilder({
|
|
|
2149
2192
|
onChange: (value) => setSourceText({ kind: "form" }, "completionMessage", value)
|
|
2150
2193
|
}
|
|
2151
2194
|
) }) }),
|
|
2152
|
-
/* @__PURE__ */ (0,
|
|
2195
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BuilderSectionGroup, { name: "questions", children: pagesEnabled ? PagesSlot === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2153
2196
|
Section,
|
|
2154
2197
|
{
|
|
2155
2198
|
className: builderClass("form-engine-builder__pages"),
|
|
2156
2199
|
headingId: "builder-pages-heading",
|
|
2157
2200
|
title: translate("builder.pages"),
|
|
2158
|
-
children: schema.pages === void 0 ? /* @__PURE__ */ (0,
|
|
2201
|
+
children: schema.pages === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { onClick: enablePages, children: translate("builder.enablePages") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2159
2202
|
schema.pages.map((page, pageIndex) => {
|
|
2160
2203
|
const priorQuestionIds = new Set(
|
|
2161
2204
|
schema.pages?.slice(0, pageIndex).flatMap((item) => item.questionIds)
|
|
2162
2205
|
);
|
|
2163
2206
|
const availableSources = schema.fields.filter((field) => priorQuestionIds.has(field.id));
|
|
2164
2207
|
const source = schema.fields.find((field) => field.id === page.displayCondition?.questionId);
|
|
2165
|
-
return /* @__PURE__ */ (0,
|
|
2208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2166
2209
|
Fieldset,
|
|
2167
2210
|
{
|
|
2168
2211
|
className: builderClass("form-engine-builder__page"),
|
|
2169
2212
|
legend: page.title ?? `${translate("builder.newPage")} ${pageIndex + 1}`,
|
|
2170
2213
|
children: [
|
|
2171
|
-
/* @__PURE__ */ (0,
|
|
2172
|
-
/* @__PURE__ */ (0,
|
|
2214
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__toolbar"), children: ToolbarSlot === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2173
2216
|
IconButton,
|
|
2174
2217
|
{
|
|
2175
2218
|
actionType: "moveUp",
|
|
@@ -2178,7 +2221,7 @@ function FormBuilder({
|
|
|
2178
2221
|
onClick: () => movePage(pageIndex, -1)
|
|
2179
2222
|
}
|
|
2180
2223
|
),
|
|
2181
|
-
/* @__PURE__ */ (0,
|
|
2224
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2182
2225
|
IconButton,
|
|
2183
2226
|
{
|
|
2184
2227
|
actionType: "moveDown",
|
|
@@ -2187,7 +2230,7 @@ function FormBuilder({
|
|
|
2187
2230
|
onClick: () => movePage(pageIndex, 1)
|
|
2188
2231
|
}
|
|
2189
2232
|
),
|
|
2190
|
-
/* @__PURE__ */ (0,
|
|
2233
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2191
2234
|
IconButton,
|
|
2192
2235
|
{
|
|
2193
2236
|
actionType: "delete",
|
|
@@ -2195,7 +2238,7 @@ function FormBuilder({
|
|
|
2195
2238
|
onClick: () => removePage(pageIndex)
|
|
2196
2239
|
}
|
|
2197
2240
|
)
|
|
2198
|
-
] }) : /* @__PURE__ */ (0,
|
|
2241
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2199
2242
|
ToolbarSlot,
|
|
2200
2243
|
{
|
|
2201
2244
|
schema,
|
|
@@ -2213,8 +2256,8 @@ function FormBuilder({
|
|
|
2213
2256
|
components
|
|
2214
2257
|
}
|
|
2215
2258
|
) }),
|
|
2216
|
-
/* @__PURE__ */ (0,
|
|
2217
|
-
/* @__PURE__ */ (0,
|
|
2259
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2260
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2218
2261
|
TextInput,
|
|
2219
2262
|
{
|
|
2220
2263
|
id: `builder-page-${page.id}-title`,
|
|
@@ -2229,7 +2272,7 @@ function FormBuilder({
|
|
|
2229
2272
|
}
|
|
2230
2273
|
}
|
|
2231
2274
|
) }),
|
|
2232
|
-
/* @__PURE__ */ (0,
|
|
2275
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2233
2276
|
TextInput,
|
|
2234
2277
|
{
|
|
2235
2278
|
id: `builder-page-${page.id}-description`,
|
|
@@ -2245,10 +2288,10 @@ function FormBuilder({
|
|
|
2245
2288
|
}
|
|
2246
2289
|
) })
|
|
2247
2290
|
] }),
|
|
2248
|
-
!localizationEnabled || editingLocale.length === 0 ? null : /* @__PURE__ */ (0,
|
|
2249
|
-
/* @__PURE__ */ (0,
|
|
2250
|
-
/* @__PURE__ */ (0,
|
|
2251
|
-
/* @__PURE__ */ (0,
|
|
2291
|
+
!localizationEnabled || editingLocale.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__translation-editor"), children: [
|
|
2292
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: editingLocale }),
|
|
2293
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2294
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2252
2295
|
TextInput,
|
|
2253
2296
|
{
|
|
2254
2297
|
id: `builder-page-${page.id}-${editingLocale}-title`,
|
|
@@ -2267,7 +2310,7 @@ function FormBuilder({
|
|
|
2267
2310
|
})
|
|
2268
2311
|
}
|
|
2269
2312
|
) }),
|
|
2270
|
-
/* @__PURE__ */ (0,
|
|
2313
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2271
2314
|
TextInput,
|
|
2272
2315
|
{
|
|
2273
2316
|
id: `builder-page-${page.id}-${editingLocale}-description`,
|
|
@@ -2288,8 +2331,8 @@ function FormBuilder({
|
|
|
2288
2331
|
) })
|
|
2289
2332
|
] })
|
|
2290
2333
|
] }),
|
|
2291
|
-
conditionsEnabled ? /* @__PURE__ */ (0,
|
|
2292
|
-
/* @__PURE__ */ (0,
|
|
2334
|
+
conditionsEnabled ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__condition"), children: [
|
|
2335
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2293
2336
|
Select,
|
|
2294
2337
|
{
|
|
2295
2338
|
id: `builder-page-${page.id}-condition`,
|
|
@@ -2318,8 +2361,8 @@ function FormBuilder({
|
|
|
2318
2361
|
]
|
|
2319
2362
|
}
|
|
2320
2363
|
) }),
|
|
2321
|
-
page.displayCondition !== void 0 && source !== void 0 ? /* @__PURE__ */ (0,
|
|
2322
|
-
/* @__PURE__ */ (0,
|
|
2364
|
+
page.displayCondition !== void 0 && source !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2365
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2323
2366
|
Select,
|
|
2324
2367
|
{
|
|
2325
2368
|
"aria-label": translate("builder.conditionOperator"),
|
|
@@ -2341,7 +2384,7 @@ function FormBuilder({
|
|
|
2341
2384
|
}))
|
|
2342
2385
|
}
|
|
2343
2386
|
),
|
|
2344
|
-
/* @__PURE__ */ (0,
|
|
2387
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2345
2388
|
ConditionValueEditor,
|
|
2346
2389
|
{
|
|
2347
2390
|
source,
|
|
@@ -2361,8 +2404,8 @@ function FormBuilder({
|
|
|
2361
2404
|
page.id
|
|
2362
2405
|
);
|
|
2363
2406
|
}),
|
|
2364
|
-
/* @__PURE__ */ (0,
|
|
2365
|
-
/* @__PURE__ */ (0,
|
|
2407
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__page-add"), children: [
|
|
2408
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2366
2409
|
Select,
|
|
2367
2410
|
{
|
|
2368
2411
|
id: "builder-page-question",
|
|
@@ -2376,11 +2419,11 @@ function FormBuilder({
|
|
|
2376
2419
|
]
|
|
2377
2420
|
}
|
|
2378
2421
|
) }),
|
|
2379
|
-
/* @__PURE__ */ (0,
|
|
2422
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { disabled: movablePageQuestions.length === 0, onClick: addPage, children: translate("builder.addPage") })
|
|
2380
2423
|
] })
|
|
2381
2424
|
] })
|
|
2382
2425
|
}
|
|
2383
|
-
) : /* @__PURE__ */ (0,
|
|
2426
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2384
2427
|
PagesSlot,
|
|
2385
2428
|
{
|
|
2386
2429
|
schema,
|
|
@@ -2392,14 +2435,14 @@ function FormBuilder({
|
|
|
2392
2435
|
components
|
|
2393
2436
|
}
|
|
2394
2437
|
) : null }),
|
|
2395
|
-
/* @__PURE__ */ (0,
|
|
2438
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BuilderSectionGroup, { name: "localization", children: localizationEnabled ? LocalizationSlot === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2396
2439
|
Section,
|
|
2397
2440
|
{
|
|
2398
2441
|
className: builderClass("form-engine-builder__localization"),
|
|
2399
2442
|
headingId: "builder-localization-heading",
|
|
2400
2443
|
title: translate("builder.localization"),
|
|
2401
2444
|
children: [
|
|
2402
|
-
resolvedSectionOrder === void 0 ? /* @__PURE__ */ (0,
|
|
2445
|
+
resolvedSectionOrder === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2403
2446
|
TextInput,
|
|
2404
2447
|
{
|
|
2405
2448
|
id: "builder-completion-message",
|
|
@@ -2408,8 +2451,8 @@ function FormBuilder({
|
|
|
2408
2451
|
onChange: (value) => setSourceText({ kind: "form" }, "completionMessage", value)
|
|
2409
2452
|
}
|
|
2410
2453
|
) }) : null,
|
|
2411
|
-
/* @__PURE__ */ (0,
|
|
2412
|
-
/* @__PURE__ */ (0,
|
|
2454
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2455
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2413
2456
|
TextInput,
|
|
2414
2457
|
{
|
|
2415
2458
|
id: "builder-default-locale",
|
|
@@ -2418,7 +2461,7 @@ function FormBuilder({
|
|
|
2418
2461
|
onChange: setDefaultLocale
|
|
2419
2462
|
}
|
|
2420
2463
|
) }),
|
|
2421
|
-
/* @__PURE__ */ (0,
|
|
2464
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: availableAllowedLocales === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2422
2465
|
TextInput,
|
|
2423
2466
|
{
|
|
2424
2467
|
id: "builder-new-locale",
|
|
@@ -2426,7 +2469,7 @@ function FormBuilder({
|
|
|
2426
2469
|
value: newLocale,
|
|
2427
2470
|
onChange: setNewLocale
|
|
2428
2471
|
}
|
|
2429
|
-
) : /* @__PURE__ */ (0,
|
|
2472
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2430
2473
|
Select,
|
|
2431
2474
|
{
|
|
2432
2475
|
id: "builder-new-locale",
|
|
@@ -2439,7 +2482,7 @@ function FormBuilder({
|
|
|
2439
2482
|
]
|
|
2440
2483
|
}
|
|
2441
2484
|
) }),
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
2485
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2443
2486
|
Button,
|
|
2444
2487
|
{
|
|
2445
2488
|
action: "addLocale",
|
|
@@ -2448,7 +2491,7 @@ function FormBuilder({
|
|
|
2448
2491
|
children: translate("builder.addLocale")
|
|
2449
2492
|
}
|
|
2450
2493
|
),
|
|
2451
|
-
/* @__PURE__ */ (0,
|
|
2494
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2452
2495
|
Select,
|
|
2453
2496
|
{
|
|
2454
2497
|
id: "builder-edit-locale",
|
|
@@ -2461,14 +2504,14 @@ function FormBuilder({
|
|
|
2461
2504
|
]
|
|
2462
2505
|
}
|
|
2463
2506
|
) }),
|
|
2464
|
-
TranslationActionsSlot === void 0 ? /* @__PURE__ */ (0,
|
|
2507
|
+
TranslationActionsSlot === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2465
2508
|
Button,
|
|
2466
2509
|
{
|
|
2467
2510
|
disabled: translationAdapter === void 0 || editingLocale.length === 0 || isTranslating,
|
|
2468
2511
|
onClick: () => void translateAll(),
|
|
2469
2512
|
children: translate("builder.autoTranslate")
|
|
2470
2513
|
}
|
|
2471
|
-
) : /* @__PURE__ */ (0,
|
|
2514
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2472
2515
|
TranslationActionsSlot,
|
|
2473
2516
|
{
|
|
2474
2517
|
schema,
|
|
@@ -2486,10 +2529,10 @@ function FormBuilder({
|
|
|
2486
2529
|
}
|
|
2487
2530
|
)
|
|
2488
2531
|
] }),
|
|
2489
|
-
translationAdapter === void 0 ? /* @__PURE__ */ (0,
|
|
2490
|
-
translationError === null ? null : /* @__PURE__ */ (0,
|
|
2491
|
-
editingLocale.length === 0 ? null : /* @__PURE__ */ (0,
|
|
2492
|
-
/* @__PURE__ */ (0,
|
|
2532
|
+
translationAdapter === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: translate("builder.translationUnavailable") }) : null,
|
|
2533
|
+
translationError === null ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorMessage, { message: translationError }),
|
|
2534
|
+
editingLocale.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2535
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2493
2536
|
TextInput,
|
|
2494
2537
|
{
|
|
2495
2538
|
id: `builder-${editingLocale}-form-title`,
|
|
@@ -2498,7 +2541,7 @@ function FormBuilder({
|
|
|
2498
2541
|
onChange: (value) => updateFormTranslation("title", value)
|
|
2499
2542
|
}
|
|
2500
2543
|
) }),
|
|
2501
|
-
/* @__PURE__ */ (0,
|
|
2544
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2502
2545
|
TextInput,
|
|
2503
2546
|
{
|
|
2504
2547
|
id: `builder-${editingLocale}-form-description`,
|
|
@@ -2507,7 +2550,7 @@ function FormBuilder({
|
|
|
2507
2550
|
onChange: (value) => updateFormTranslation("description", value)
|
|
2508
2551
|
}
|
|
2509
2552
|
) }),
|
|
2510
|
-
/* @__PURE__ */ (0,
|
|
2553
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2511
2554
|
TextInput,
|
|
2512
2555
|
{
|
|
2513
2556
|
id: `builder-${editingLocale}-completion-message`,
|
|
@@ -2519,7 +2562,7 @@ function FormBuilder({
|
|
|
2519
2562
|
] })
|
|
2520
2563
|
]
|
|
2521
2564
|
}
|
|
2522
|
-
) : /* @__PURE__ */ (0,
|
|
2565
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2523
2566
|
LocalizationSlot,
|
|
2524
2567
|
{
|
|
2525
2568
|
schema,
|
|
@@ -2536,7 +2579,7 @@ function FormBuilder({
|
|
|
2536
2579
|
components
|
|
2537
2580
|
}
|
|
2538
2581
|
) : null }),
|
|
2539
|
-
/* @__PURE__ */ (0,
|
|
2582
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BuilderSectionGroup, { name: "questions", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__list"), children: schema.fields.map((field, index) => {
|
|
2540
2583
|
const controls = resolveFieldEditorControls(fieldEditorControls);
|
|
2541
2584
|
const editorState = headless.getFieldEditorProps?.(field.id) ?? {
|
|
2542
2585
|
isActive: true,
|
|
@@ -2547,18 +2590,18 @@ function FormBuilder({
|
|
|
2547
2590
|
const source = condition === void 0 ? void 0 : schema.fields.find((item) => item.id === condition.questionId);
|
|
2548
2591
|
const availableSources = schema.fields.slice(0, index);
|
|
2549
2592
|
if (!editorState.isVisible) {
|
|
2550
|
-
return /* @__PURE__ */ (0,
|
|
2593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2551
2594
|
"div",
|
|
2552
2595
|
{
|
|
2553
2596
|
className: builderClass("form-engine-builder__question-preview"),
|
|
2554
2597
|
"data-field-id": field.id,
|
|
2555
|
-
children: /* @__PURE__ */ (0,
|
|
2598
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: editorState.onSelect, children: field.title })
|
|
2556
2599
|
},
|
|
2557
2600
|
field.id
|
|
2558
2601
|
);
|
|
2559
2602
|
}
|
|
2560
2603
|
if (FieldEditorSlot !== void 0) {
|
|
2561
|
-
return /* @__PURE__ */ (0,
|
|
2604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2562
2605
|
FieldEditorSlot,
|
|
2563
2606
|
{
|
|
2564
2607
|
schema,
|
|
@@ -2578,14 +2621,14 @@ function FormBuilder({
|
|
|
2578
2621
|
field.id
|
|
2579
2622
|
);
|
|
2580
2623
|
}
|
|
2581
|
-
return /* @__PURE__ */ (0,
|
|
2624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2582
2625
|
Fieldset,
|
|
2583
2626
|
{
|
|
2584
2627
|
className: builderClass("form-engine-builder__question"),
|
|
2585
2628
|
legend: field.title,
|
|
2586
2629
|
children: [
|
|
2587
|
-
/* @__PURE__ */ (0,
|
|
2588
|
-
/* @__PURE__ */ (0,
|
|
2630
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__toolbar"), children: ToolbarSlot === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2631
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2589
2632
|
IconButton,
|
|
2590
2633
|
{
|
|
2591
2634
|
actionType: "moveUp",
|
|
@@ -2594,7 +2637,7 @@ function FormBuilder({
|
|
|
2594
2637
|
onClick: () => moveField(index, -1)
|
|
2595
2638
|
}
|
|
2596
2639
|
),
|
|
2597
|
-
/* @__PURE__ */ (0,
|
|
2640
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2598
2641
|
IconButton,
|
|
2599
2642
|
{
|
|
2600
2643
|
actionType: "moveDown",
|
|
@@ -2603,7 +2646,7 @@ function FormBuilder({
|
|
|
2603
2646
|
onClick: () => moveField(index, 1)
|
|
2604
2647
|
}
|
|
2605
2648
|
),
|
|
2606
|
-
/* @__PURE__ */ (0,
|
|
2649
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2607
2650
|
IconButton,
|
|
2608
2651
|
{
|
|
2609
2652
|
actionType: "delete",
|
|
@@ -2613,7 +2656,7 @@ function FormBuilder({
|
|
|
2613
2656
|
title: translate("builder.delete", { title: field.title })
|
|
2614
2657
|
}
|
|
2615
2658
|
)
|
|
2616
|
-
] }) : /* @__PURE__ */ (0,
|
|
2659
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2617
2660
|
ToolbarSlot,
|
|
2618
2661
|
{
|
|
2619
2662
|
schema,
|
|
@@ -2631,8 +2674,8 @@ function FormBuilder({
|
|
|
2631
2674
|
components
|
|
2632
2675
|
}
|
|
2633
2676
|
) }),
|
|
2634
|
-
/* @__PURE__ */ (0,
|
|
2635
|
-
controls.title === "hidden" ? null : /* @__PURE__ */ (0,
|
|
2677
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2678
|
+
controls.title === "hidden" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2636
2679
|
TextInput,
|
|
2637
2680
|
{
|
|
2638
2681
|
id: `builder-field-${field.id}-title`,
|
|
@@ -2651,7 +2694,7 @@ function FormBuilder({
|
|
|
2651
2694
|
}))
|
|
2652
2695
|
}
|
|
2653
2696
|
) }),
|
|
2654
|
-
controls.typeSelect === "hidden" ? null : /* @__PURE__ */ (0,
|
|
2697
|
+
controls.typeSelect === "hidden" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2655
2698
|
Select,
|
|
2656
2699
|
{
|
|
2657
2700
|
id: `builder-field-${field.id}-type`,
|
|
@@ -2668,7 +2711,7 @@ function FormBuilder({
|
|
|
2668
2711
|
)
|
|
2669
2712
|
}
|
|
2670
2713
|
) }),
|
|
2671
|
-
controls.required === "hidden" ? null : /* @__PURE__ */ (0,
|
|
2714
|
+
controls.required === "hidden" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2672
2715
|
Checkbox,
|
|
2673
2716
|
{
|
|
2674
2717
|
className: builderClass("form-engine-builder__check"),
|
|
@@ -2679,7 +2722,7 @@ function FormBuilder({
|
|
|
2679
2722
|
}
|
|
2680
2723
|
)
|
|
2681
2724
|
] }),
|
|
2682
|
-
controls.description === "hidden" ? null : /* @__PURE__ */ (0,
|
|
2725
|
+
controls.description === "hidden" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2683
2726
|
TextArea,
|
|
2684
2727
|
{
|
|
2685
2728
|
id: `builder-field-${field.id}-description`,
|
|
@@ -2694,7 +2737,7 @@ function FormBuilder({
|
|
|
2694
2737
|
})
|
|
2695
2738
|
}
|
|
2696
2739
|
) }),
|
|
2697
|
-
!pagesEnabled || schema.pages === void 0 ? null : /* @__PURE__ */ (0,
|
|
2740
|
+
!pagesEnabled || schema.pages === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2698
2741
|
Select,
|
|
2699
2742
|
{
|
|
2700
2743
|
id: `builder-field-${field.id}-page`,
|
|
@@ -2707,10 +2750,10 @@ function FormBuilder({
|
|
|
2707
2750
|
}))
|
|
2708
2751
|
}
|
|
2709
2752
|
) }),
|
|
2710
|
-
!localizationEnabled || editingLocale.length === 0 ? null : /* @__PURE__ */ (0,
|
|
2711
|
-
/* @__PURE__ */ (0,
|
|
2712
|
-
/* @__PURE__ */ (0,
|
|
2713
|
-
/* @__PURE__ */ (0,
|
|
2753
|
+
!localizationEnabled || editingLocale.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__translation-editor"), children: [
|
|
2754
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: editingLocale }),
|
|
2755
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2756
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2714
2757
|
TextInput,
|
|
2715
2758
|
{
|
|
2716
2759
|
id: `builder-field-${field.id}-${editingLocale}-title`,
|
|
@@ -2729,7 +2772,7 @@ function FormBuilder({
|
|
|
2729
2772
|
})
|
|
2730
2773
|
}
|
|
2731
2774
|
) }),
|
|
2732
|
-
controls.description === "hidden" ? null : /* @__PURE__ */ (0,
|
|
2775
|
+
controls.description === "hidden" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2733
2776
|
TextInput,
|
|
2734
2777
|
{
|
|
2735
2778
|
id: `builder-field-${field.id}-${editingLocale}-description`,
|
|
@@ -2750,7 +2793,7 @@ function FormBuilder({
|
|
|
2750
2793
|
}
|
|
2751
2794
|
) })
|
|
2752
2795
|
] }),
|
|
2753
|
-
"options" in field ? field.options.map((option, optionIndex) => /* @__PURE__ */ (0,
|
|
2796
|
+
"options" in field ? field.options.map((option, optionIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2754
2797
|
TextInput,
|
|
2755
2798
|
{
|
|
2756
2799
|
id: `builder-option-${option.id}-${editingLocale}`,
|
|
@@ -2770,8 +2813,8 @@ function FormBuilder({
|
|
|
2770
2813
|
}
|
|
2771
2814
|
) }, option.id)) : null
|
|
2772
2815
|
] }),
|
|
2773
|
-
field.type === "rating" && controls.ratingBounds !== "hidden" ? /* @__PURE__ */ (0,
|
|
2774
|
-
/* @__PURE__ */ (0,
|
|
2816
|
+
field.type === "rating" && controls.ratingBounds !== "hidden" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2775
2818
|
TextInput,
|
|
2776
2819
|
{
|
|
2777
2820
|
id: `builder-field-${field.id}-minimum`,
|
|
@@ -2789,7 +2832,7 @@ function FormBuilder({
|
|
|
2789
2832
|
}
|
|
2790
2833
|
}
|
|
2791
2834
|
) }),
|
|
2792
|
-
/* @__PURE__ */ (0,
|
|
2835
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2793
2836
|
TextInput,
|
|
2794
2837
|
{
|
|
2795
2838
|
id: `builder-field-${field.id}-maximum`,
|
|
@@ -2808,8 +2851,8 @@ function FormBuilder({
|
|
|
2808
2851
|
}
|
|
2809
2852
|
) })
|
|
2810
2853
|
] }) : null,
|
|
2811
|
-
(field.type === "text" || field.type === "textarea") && controls.textLimits !== "hidden" ? /* @__PURE__ */ (0,
|
|
2812
|
-
/* @__PURE__ */ (0,
|
|
2854
|
+
(field.type === "text" || field.type === "textarea") && controls.textLimits !== "hidden" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__grid"), children: [
|
|
2855
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2813
2856
|
TextInput,
|
|
2814
2857
|
{
|
|
2815
2858
|
id: `builder-field-${field.id}-min-length`,
|
|
@@ -2824,7 +2867,7 @@ function FormBuilder({
|
|
|
2824
2867
|
})
|
|
2825
2868
|
}
|
|
2826
2869
|
) }),
|
|
2827
|
-
/* @__PURE__ */ (0,
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2828
2871
|
TextInput,
|
|
2829
2872
|
{
|
|
2830
2873
|
id: `builder-field-${field.id}-max-length`,
|
|
@@ -2839,7 +2882,7 @@ function FormBuilder({
|
|
|
2839
2882
|
})
|
|
2840
2883
|
}
|
|
2841
2884
|
) }),
|
|
2842
|
-
/* @__PURE__ */ (0,
|
|
2885
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2843
2886
|
TextInput,
|
|
2844
2887
|
{
|
|
2845
2888
|
id: `builder-field-${field.id}-pattern`,
|
|
@@ -2853,7 +2896,7 @@ function FormBuilder({
|
|
|
2853
2896
|
}
|
|
2854
2897
|
) })
|
|
2855
2898
|
] }) : null,
|
|
2856
|
-
field.type === "number" && controls.numberLimits !== "hidden" ? /* @__PURE__ */ (0,
|
|
2899
|
+
field.type === "number" && controls.numberLimits !== "hidden" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__grid"), children: ["min", "max", "step"].map((property) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2857
2900
|
TextInput,
|
|
2858
2901
|
{
|
|
2859
2902
|
id: `builder-field-${field.id}-${property}`,
|
|
@@ -2874,11 +2917,11 @@ function FormBuilder({
|
|
|
2874
2917
|
})
|
|
2875
2918
|
}
|
|
2876
2919
|
) }, property)) }) : null,
|
|
2877
|
-
"options" in field && controls.options !== "hidden" ? /* @__PURE__ */ (0,
|
|
2878
|
-
/* @__PURE__ */ (0,
|
|
2920
|
+
"options" in field && controls.options !== "hidden" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__options"), children: [
|
|
2921
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: translate("builder.options") }),
|
|
2879
2922
|
field.options.map(
|
|
2880
|
-
(option, optionIndex) => OptionEditorSlot === void 0 ? /* @__PURE__ */ (0,
|
|
2881
|
-
/* @__PURE__ */ (0,
|
|
2923
|
+
(option, optionIndex) => OptionEditorSlot === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__option"), children: [
|
|
2924
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2882
2925
|
TextInput,
|
|
2883
2926
|
{
|
|
2884
2927
|
id: `builder-option-${option.id}`,
|
|
@@ -2889,8 +2932,8 @@ function FormBuilder({
|
|
|
2889
2932
|
onChange: (value) => value.trim().length === 0 ? void 0 : updateOption(field.id, option.id, value)
|
|
2890
2933
|
}
|
|
2891
2934
|
),
|
|
2892
|
-
ToolbarSlot === void 0 ? /* @__PURE__ */ (0,
|
|
2893
|
-
/* @__PURE__ */ (0,
|
|
2935
|
+
ToolbarSlot === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2936
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2894
2937
|
IconButton,
|
|
2895
2938
|
{
|
|
2896
2939
|
actionType: "moveUp",
|
|
@@ -2899,7 +2942,7 @@ function FormBuilder({
|
|
|
2899
2942
|
onClick: () => moveOption(field.id, option.id, optionIndex - 1)
|
|
2900
2943
|
}
|
|
2901
2944
|
),
|
|
2902
|
-
/* @__PURE__ */ (0,
|
|
2945
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2903
2946
|
IconButton,
|
|
2904
2947
|
{
|
|
2905
2948
|
actionType: "moveDown",
|
|
@@ -2908,7 +2951,7 @@ function FormBuilder({
|
|
|
2908
2951
|
onClick: () => moveOption(field.id, option.id, optionIndex + 1)
|
|
2909
2952
|
}
|
|
2910
2953
|
),
|
|
2911
|
-
/* @__PURE__ */ (0,
|
|
2954
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2912
2955
|
IconButton,
|
|
2913
2956
|
{
|
|
2914
2957
|
actionType: "delete",
|
|
@@ -2917,7 +2960,7 @@ function FormBuilder({
|
|
|
2917
2960
|
title: translate("builder.remove")
|
|
2918
2961
|
}
|
|
2919
2962
|
)
|
|
2920
|
-
] }) : /* @__PURE__ */ (0,
|
|
2963
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2921
2964
|
ToolbarSlot,
|
|
2922
2965
|
{
|
|
2923
2966
|
schema,
|
|
@@ -2935,7 +2978,7 @@ function FormBuilder({
|
|
|
2935
2978
|
components
|
|
2936
2979
|
}
|
|
2937
2980
|
)
|
|
2938
|
-
] }, option.id) : /* @__PURE__ */ (0,
|
|
2981
|
+
] }, option.id) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2939
2982
|
OptionEditorSlot,
|
|
2940
2983
|
{
|
|
2941
2984
|
schema,
|
|
@@ -2951,7 +2994,7 @@ function FormBuilder({
|
|
|
2951
2994
|
option.id
|
|
2952
2995
|
)
|
|
2953
2996
|
),
|
|
2954
|
-
/* @__PURE__ */ (0,
|
|
2997
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2955
2998
|
Button,
|
|
2956
2999
|
{
|
|
2957
3000
|
action: "addOption",
|
|
@@ -2962,8 +3005,8 @@ function FormBuilder({
|
|
|
2962
3005
|
}
|
|
2963
3006
|
)
|
|
2964
3007
|
] }) : null,
|
|
2965
|
-
conditionsEnabled && controls.displayConditions !== "hidden" ? /* @__PURE__ */ (0,
|
|
2966
|
-
/* @__PURE__ */ (0,
|
|
3008
|
+
conditionsEnabled && controls.displayConditions !== "hidden" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: builderClass("form-engine-builder__condition"), children: [
|
|
3009
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: builderClass("form-engine-builder__field"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2967
3010
|
Select,
|
|
2968
3011
|
{
|
|
2969
3012
|
id: `builder-field-${field.id}-condition`,
|
|
@@ -2989,8 +3032,8 @@ function FormBuilder({
|
|
|
2989
3032
|
]
|
|
2990
3033
|
}
|
|
2991
3034
|
) }),
|
|
2992
|
-
condition !== void 0 && source !== void 0 ? /* @__PURE__ */ (0,
|
|
2993
|
-
/* @__PURE__ */ (0,
|
|
3035
|
+
condition !== void 0 && source !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3036
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2994
3037
|
Select,
|
|
2995
3038
|
{
|
|
2996
3039
|
"aria-label": translate("builder.conditionOperator"),
|
|
@@ -3008,7 +3051,7 @@ function FormBuilder({
|
|
|
3008
3051
|
}))
|
|
3009
3052
|
}
|
|
3010
3053
|
),
|
|
3011
|
-
/* @__PURE__ */ (0,
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3012
3055
|
ConditionValueEditor,
|
|
3013
3056
|
{
|
|
3014
3057
|
source,
|
|
@@ -3025,7 +3068,7 @@ function FormBuilder({
|
|
|
3025
3068
|
field.id
|
|
3026
3069
|
);
|
|
3027
3070
|
}) }) }),
|
|
3028
|
-
/* @__PURE__ */ (0,
|
|
3071
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BuilderSectionGroup, { name: "addQuestion", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3029
3072
|
Button,
|
|
3030
3073
|
{
|
|
3031
3074
|
className: builderClass("form-engine-builder__add"),
|
|
@@ -3043,8 +3086,8 @@ function FormBuilder({
|
|
|
3043
3086
|
}
|
|
3044
3087
|
|
|
3045
3088
|
// src/context.tsx
|
|
3046
|
-
var
|
|
3047
|
-
var
|
|
3089
|
+
var import_core4 = require("@form-engine-ts/core");
|
|
3090
|
+
var import_react4 = require("react");
|
|
3048
3091
|
|
|
3049
3092
|
// src/types.ts
|
|
3050
3093
|
var FormSubmissionError = class extends Error {
|
|
@@ -3057,8 +3100,8 @@ var FormSubmissionError = class extends Error {
|
|
|
3057
3100
|
};
|
|
3058
3101
|
|
|
3059
3102
|
// src/context.tsx
|
|
3060
|
-
var
|
|
3061
|
-
var FormContext = (0,
|
|
3103
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
3104
|
+
var FormContext = (0, import_react4.createContext)(null);
|
|
3062
3105
|
function issuesByField(issues) {
|
|
3063
3106
|
const result = {};
|
|
3064
3107
|
for (const issue of issues) result[issue.fieldId] ??= issue;
|
|
@@ -3085,31 +3128,31 @@ function FormProvider({
|
|
|
3085
3128
|
onSubmit,
|
|
3086
3129
|
children
|
|
3087
3130
|
}) {
|
|
3088
|
-
const validSchema = (0,
|
|
3089
|
-
(0,
|
|
3090
|
-
const localized = (0,
|
|
3091
|
-
(0,
|
|
3131
|
+
const validSchema = (0, import_react4.useMemo)(() => {
|
|
3132
|
+
(0, import_core4.assertValidFormSchema)(schema);
|
|
3133
|
+
const localized = (0, import_core4.resolveLocalizedSchema)(schema, locale);
|
|
3134
|
+
(0, import_core4.assertValidFormSchema)(localized);
|
|
3092
3135
|
return localized;
|
|
3093
3136
|
}, [locale, schema]);
|
|
3094
|
-
const [values, setValues] = (0,
|
|
3095
|
-
const [errors, setErrors] = (0,
|
|
3096
|
-
const [submitStatus, setSubmitStatus] = (0,
|
|
3097
|
-
const [submitError, setSubmitError] = (0,
|
|
3098
|
-
const [validationPageIndex, setValidationPageIndex] = (0,
|
|
3099
|
-
const submissionInFlight = (0,
|
|
3100
|
-
const visibility = (0,
|
|
3101
|
-
const pageVisibility = (0,
|
|
3102
|
-
(0,
|
|
3137
|
+
const [values, setValues] = (0, import_react4.useState)(() => ({ ...initialValues }));
|
|
3138
|
+
const [errors, setErrors] = (0, import_react4.useState)({});
|
|
3139
|
+
const [submitStatus, setSubmitStatus] = (0, import_react4.useState)("idle");
|
|
3140
|
+
const [submitError, setSubmitError] = (0, import_react4.useState)(null);
|
|
3141
|
+
const [validationPageIndex, setValidationPageIndex] = (0, import_react4.useState)(null);
|
|
3142
|
+
const submissionInFlight = (0, import_react4.useRef)(false);
|
|
3143
|
+
const visibility = (0, import_react4.useMemo)(() => (0, import_core4.calculateFieldVisibility)(validSchema, values), [validSchema, values]);
|
|
3144
|
+
const pageVisibility = (0, import_react4.useMemo)(() => (0, import_core4.calculatePageVisibility)(validSchema, values), [validSchema, values]);
|
|
3145
|
+
(0, import_react4.useEffect)(() => {
|
|
3103
3146
|
const fieldIds = new Set(validSchema.fields.map((field) => field.id));
|
|
3104
3147
|
setValues((current) => Object.fromEntries(Object.entries(current).filter(([fieldId]) => fieldIds.has(fieldId))));
|
|
3105
3148
|
}, [validSchema]);
|
|
3106
|
-
const setValue = (0,
|
|
3149
|
+
const setValue = (0, import_react4.useCallback)(
|
|
3107
3150
|
(fieldId, value) => {
|
|
3108
3151
|
setValues((current) => {
|
|
3109
3152
|
const next = { ...current, [fieldId]: value };
|
|
3110
3153
|
setErrors((currentErrors) => {
|
|
3111
3154
|
if (Object.keys(currentErrors).length === 0) return currentErrors;
|
|
3112
|
-
const result = validationPageIndex === null ? (0,
|
|
3155
|
+
const result = validationPageIndex === null ? (0, import_core4.validateAnswers)(validSchema, next) : (0, import_core4.validatePageAnswers)(validSchema, validationPageIndex, next);
|
|
3113
3156
|
return issuesByField(result.issues);
|
|
3114
3157
|
});
|
|
3115
3158
|
return next;
|
|
@@ -3119,7 +3162,7 @@ function FormProvider({
|
|
|
3119
3162
|
},
|
|
3120
3163
|
[validSchema, validationPageIndex]
|
|
3121
3164
|
);
|
|
3122
|
-
const setServerErrors = (0,
|
|
3165
|
+
const setServerErrors = (0, import_react4.useCallback)((fieldErrors) => {
|
|
3123
3166
|
setErrors(
|
|
3124
3167
|
Object.fromEntries(
|
|
3125
3168
|
Object.entries(fieldErrors).map(([fieldId, message]) => [
|
|
@@ -3130,7 +3173,7 @@ function FormProvider({
|
|
|
3130
3173
|
);
|
|
3131
3174
|
setValidationPageIndex(null);
|
|
3132
3175
|
}, []);
|
|
3133
|
-
const restoreValues = (0,
|
|
3176
|
+
const restoreValues = (0, import_react4.useCallback)(
|
|
3134
3177
|
(restoredValues) => {
|
|
3135
3178
|
const fieldIds = new Set(validSchema.fields.map((field) => field.id));
|
|
3136
3179
|
setValues(Object.fromEntries(Object.entries(restoredValues).filter(([fieldId]) => fieldIds.has(fieldId))));
|
|
@@ -3141,9 +3184,9 @@ function FormProvider({
|
|
|
3141
3184
|
},
|
|
3142
3185
|
[validSchema]
|
|
3143
3186
|
);
|
|
3144
|
-
const validatePage = (0,
|
|
3187
|
+
const validatePage = (0, import_react4.useCallback)(
|
|
3145
3188
|
(pageIndex) => {
|
|
3146
|
-
const result = (0,
|
|
3189
|
+
const result = (0, import_core4.validatePageAnswers)(validSchema, pageIndex, values);
|
|
3147
3190
|
setErrors(issuesByField(result.issues));
|
|
3148
3191
|
setValidationPageIndex(result.valid ? null : pageIndex);
|
|
3149
3192
|
setSubmitStatus("idle");
|
|
@@ -3152,17 +3195,17 @@ function FormProvider({
|
|
|
3152
3195
|
},
|
|
3153
3196
|
[validSchema, values]
|
|
3154
3197
|
);
|
|
3155
|
-
const reset = (0,
|
|
3198
|
+
const reset = (0, import_react4.useCallback)(() => {
|
|
3156
3199
|
setValues({ ...initialValues });
|
|
3157
3200
|
setErrors({});
|
|
3158
3201
|
setValidationPageIndex(null);
|
|
3159
3202
|
setSubmitStatus("idle");
|
|
3160
3203
|
setSubmitError(null);
|
|
3161
3204
|
}, [initialValues]);
|
|
3162
|
-
const submit = (0,
|
|
3205
|
+
const submit = (0, import_react4.useCallback)(
|
|
3163
3206
|
async (beforeSubmit, submitContext) => {
|
|
3164
3207
|
if (submissionInFlight.current) return { status: "cancelled" };
|
|
3165
|
-
const validation = (0,
|
|
3208
|
+
const validation = (0, import_core4.validateAnswers)(validSchema, values);
|
|
3166
3209
|
if (!validation.valid) {
|
|
3167
3210
|
setErrors(issuesByField(validation.issues));
|
|
3168
3211
|
setValidationPageIndex(null);
|
|
@@ -3173,7 +3216,7 @@ function FormProvider({
|
|
|
3173
3216
|
setErrors({});
|
|
3174
3217
|
setValidationPageIndex(null);
|
|
3175
3218
|
setSubmitError(null);
|
|
3176
|
-
const visibleValues = (0,
|
|
3219
|
+
const visibleValues = (0, import_core4.selectVisibleAnswers)(validSchema, values);
|
|
3177
3220
|
submissionInFlight.current = true;
|
|
3178
3221
|
try {
|
|
3179
3222
|
setSubmitStatus("submitting");
|
|
@@ -3206,11 +3249,11 @@ function FormProvider({
|
|
|
3206
3249
|
},
|
|
3207
3250
|
[initialValues, locale, onSubmit, resetOnSuccess, validSchema, values]
|
|
3208
3251
|
);
|
|
3209
|
-
const translate = (0,
|
|
3252
|
+
const translate = (0, import_react4.useCallback)(
|
|
3210
3253
|
(key, params) => translator.translate(key, locale, params) ?? key,
|
|
3211
3254
|
[locale, translator]
|
|
3212
3255
|
);
|
|
3213
|
-
const contextValue = (0,
|
|
3256
|
+
const contextValue = (0, import_react4.useMemo)(
|
|
3214
3257
|
() => ({
|
|
3215
3258
|
schema: validSchema,
|
|
3216
3259
|
locale,
|
|
@@ -3249,10 +3292,10 @@ function FormProvider({
|
|
|
3249
3292
|
visibility
|
|
3250
3293
|
]
|
|
3251
3294
|
);
|
|
3252
|
-
return /* @__PURE__ */ (0,
|
|
3295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FormContext.Provider, { value: contextValue, children });
|
|
3253
3296
|
}
|
|
3254
3297
|
function useForm() {
|
|
3255
|
-
const context = (0,
|
|
3298
|
+
const context = (0, import_react4.useContext)(FormContext);
|
|
3256
3299
|
if (context === null) throw new Error("useForm must be called inside a FormProvider.");
|
|
3257
3300
|
return context;
|
|
3258
3301
|
}
|
|
@@ -3260,13 +3303,13 @@ function useField(fieldId) {
|
|
|
3260
3303
|
const form = useForm();
|
|
3261
3304
|
const field = form.schema.fields.find((item) => item.id === fieldId);
|
|
3262
3305
|
if (field === void 0) throw new Error(`Unknown form field: ${fieldId}`);
|
|
3263
|
-
const setValue = (0,
|
|
3306
|
+
const setValue = (0, import_react4.useCallback)((value) => form.setValue(fieldId, value), [fieldId, form]);
|
|
3264
3307
|
return { field, value: form.values[fieldId], error: form.errors[fieldId], setValue };
|
|
3265
3308
|
}
|
|
3266
3309
|
|
|
3267
3310
|
// src/hooks/useTranslationWorkspace.ts
|
|
3268
|
-
var
|
|
3269
|
-
var
|
|
3311
|
+
var import_core5 = require("@form-engine-ts/core");
|
|
3312
|
+
var import_react5 = require("react");
|
|
3270
3313
|
function updateTranslationMap(translations, locale, property, text) {
|
|
3271
3314
|
if (property === "label") return translations ?? {};
|
|
3272
3315
|
const current = translations?.[locale];
|
|
@@ -3283,7 +3326,7 @@ function asAsyncAdapter(adapter) {
|
|
|
3283
3326
|
};
|
|
3284
3327
|
}
|
|
3285
3328
|
var validateLocalePipeline = (locale, schema, policy, customValidator) => {
|
|
3286
|
-
const canonicalLocale = (0,
|
|
3329
|
+
const canonicalLocale = (0, import_core5.normalizeLocale)(locale);
|
|
3287
3330
|
if (canonicalLocale === null) {
|
|
3288
3331
|
return {
|
|
3289
3332
|
valid: false,
|
|
@@ -3293,8 +3336,8 @@ var validateLocalePipeline = (locale, schema, policy, customValidator) => {
|
|
|
3293
3336
|
}
|
|
3294
3337
|
};
|
|
3295
3338
|
}
|
|
3296
|
-
const currentLocales = (schema.supportedLocales ?? []).map((candidate) => (0,
|
|
3297
|
-
const defaultLocale = schema.defaultLocale === void 0 ? "" : (0,
|
|
3339
|
+
const currentLocales = (schema.supportedLocales ?? []).map((candidate) => (0, import_core5.normalizeLocale)(candidate) ?? candidate);
|
|
3340
|
+
const defaultLocale = schema.defaultLocale === void 0 ? "" : (0, import_core5.normalizeLocale)(schema.defaultLocale) ?? schema.defaultLocale;
|
|
3298
3341
|
if (canonicalLocale === defaultLocale || currentLocales.includes(canonicalLocale)) {
|
|
3299
3342
|
return {
|
|
3300
3343
|
valid: false,
|
|
@@ -3304,7 +3347,7 @@ var validateLocalePipeline = (locale, schema, policy, customValidator) => {
|
|
|
3304
3347
|
}
|
|
3305
3348
|
};
|
|
3306
3349
|
}
|
|
3307
|
-
if (policy?.allowedLocales !== void 0 && !policy.allowedLocales.some((candidate) => (0,
|
|
3350
|
+
if (policy?.allowedLocales !== void 0 && !policy.allowedLocales.some((candidate) => (0, import_core5.normalizeLocale)(candidate) === canonicalLocale)) {
|
|
3308
3351
|
return {
|
|
3309
3352
|
valid: false,
|
|
3310
3353
|
error: {
|
|
@@ -3350,20 +3393,26 @@ var validateLocalePipeline = (locale, schema, policy, customValidator) => {
|
|
|
3350
3393
|
}
|
|
3351
3394
|
return { valid: true };
|
|
3352
3395
|
};
|
|
3353
|
-
function
|
|
3354
|
-
|
|
3355
|
-
|
|
3396
|
+
function workspaceLocaleValidationError(validation, currentLocales, requestedLocale) {
|
|
3397
|
+
const error = validation.error;
|
|
3398
|
+
if (error === void 0) return { type: "invalid_locale_format", locale: requestedLocale };
|
|
3399
|
+
if (error.type === "locale_not_allowed") return { type: "locale_not_allowed", locale: requestedLocale };
|
|
3400
|
+
if (error.type === "locale_already_exists") {
|
|
3401
|
+
return { type: "locale_already_exists", locale: requestedLocale };
|
|
3356
3402
|
}
|
|
3357
|
-
if (
|
|
3358
|
-
|
|
3359
|
-
return maximum === void 0 ? validation.error.message : `At most ${maximum} locales are allowed by the form policy.`;
|
|
3403
|
+
if (error.type === "invalid_locale_format") {
|
|
3404
|
+
return { type: "invalid_locale_format", locale: requestedLocale };
|
|
3360
3405
|
}
|
|
3361
|
-
|
|
3406
|
+
if (error.type === "max_locales_exceeded") {
|
|
3407
|
+
const max = Number(error.message.match(/\((\d+)\)/u)?.[1] ?? 0);
|
|
3408
|
+
return { type: "max_locales_exceeded", max, current: currentLocales };
|
|
3409
|
+
}
|
|
3410
|
+
return { type: "custom_validation_failed", message: error.message };
|
|
3362
3411
|
}
|
|
3363
3412
|
function manualMetadata(sourceText, sourceLocale) {
|
|
3364
3413
|
return {
|
|
3365
3414
|
sourceLocale,
|
|
3366
|
-
sourceTextHash: (0,
|
|
3415
|
+
sourceTextHash: (0, import_core5.computeSourceTextHash)(sourceText),
|
|
3367
3416
|
translationSource: "manual",
|
|
3368
3417
|
editedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3369
3418
|
};
|
|
@@ -3429,25 +3478,26 @@ function useTranslationWorkspace({
|
|
|
3429
3478
|
translationAdapter,
|
|
3430
3479
|
readOnly = false,
|
|
3431
3480
|
policy,
|
|
3481
|
+
beforeRemoveLocale,
|
|
3432
3482
|
validateLocale
|
|
3433
3483
|
}) {
|
|
3434
|
-
const [draftSchema, setDraftSchema] = (0,
|
|
3435
|
-
const [selectedLocale, setSelectedLocale] = (0,
|
|
3436
|
-
const [isTranslating, setIsTranslating] = (0,
|
|
3437
|
-
const [error, setError] = (0,
|
|
3484
|
+
const [draftSchema, setDraftSchema] = (0, import_react5.useState)(schema);
|
|
3485
|
+
const [selectedLocale, setSelectedLocale] = (0, import_react5.useState)(targetLocale ?? "");
|
|
3486
|
+
const [isTranslating, setIsTranslating] = (0, import_react5.useState)(false);
|
|
3487
|
+
const [error, setError] = (0, import_react5.useState)();
|
|
3438
3488
|
const currentSchema = onChange === void 0 ? draftSchema : schema;
|
|
3439
|
-
const targetLocales = (0,
|
|
3440
|
-
const locales = (0,
|
|
3489
|
+
const targetLocales = (0, import_react5.useMemo)(() => {
|
|
3490
|
+
const locales = (0, import_core5.collectSchemaLocales)(currentSchema).allUniqueLocales;
|
|
3441
3491
|
return [.../* @__PURE__ */ new Set([...currentSchema.supportedLocales ?? [], ...locales])].filter(
|
|
3442
3492
|
(locale) => locale !== sourceLocale
|
|
3443
3493
|
);
|
|
3444
3494
|
}, [currentSchema, sourceLocale]);
|
|
3445
3495
|
const activeLocale = selectedLocale.length > 0 ? selectedLocale : targetLocales[0] ?? "";
|
|
3446
|
-
const slots = (0,
|
|
3447
|
-
() => activeLocale.length === 0 ? [] : (0,
|
|
3496
|
+
const slots = (0, import_react5.useMemo)(
|
|
3497
|
+
() => activeLocale.length === 0 ? [] : (0, import_core5.collectTranslationSlots)(currentSchema, activeLocale),
|
|
3448
3498
|
[activeLocale, currentSchema]
|
|
3449
3499
|
);
|
|
3450
|
-
const summary = (0,
|
|
3500
|
+
const summary = (0, import_react5.useMemo)(() => {
|
|
3451
3501
|
const counts = {
|
|
3452
3502
|
missing: 0,
|
|
3453
3503
|
translated: 0,
|
|
@@ -3466,32 +3516,48 @@ function useTranslationWorkspace({
|
|
|
3466
3516
|
completionPercentage: slots.length === 0 ? 100 : Math.round(complete / slots.length * 100)
|
|
3467
3517
|
};
|
|
3468
3518
|
}, [slots]);
|
|
3469
|
-
const commit = (0,
|
|
3519
|
+
const commit = (0, import_react5.useCallback)(
|
|
3470
3520
|
(next) => {
|
|
3471
3521
|
setDraftSchema(next);
|
|
3472
3522
|
onChange?.(next);
|
|
3473
3523
|
},
|
|
3474
3524
|
[onChange]
|
|
3475
3525
|
);
|
|
3476
|
-
const setTranslation = (0,
|
|
3526
|
+
const setTranslation = (0, import_react5.useCallback)(
|
|
3477
3527
|
(slot, text) => {
|
|
3478
3528
|
if (readOnly) return;
|
|
3479
3529
|
commit(updateSchemaTranslation(currentSchema, slot, text, sourceLocale));
|
|
3480
3530
|
},
|
|
3481
3531
|
[commit, currentSchema, readOnly, sourceLocale]
|
|
3482
3532
|
);
|
|
3483
|
-
const addLocale = (0,
|
|
3533
|
+
const addLocale = (0, import_react5.useCallback)(
|
|
3484
3534
|
(locale) => {
|
|
3485
|
-
if (readOnly)
|
|
3486
|
-
|
|
3535
|
+
if (readOnly) {
|
|
3536
|
+
const workspaceError = { type: "read_only_mode" };
|
|
3537
|
+
setError(workspaceError);
|
|
3538
|
+
return { success: false, error: workspaceError };
|
|
3539
|
+
}
|
|
3540
|
+
const normalized = (0, import_core5.normalizeLocale)(locale);
|
|
3487
3541
|
if (normalized === null) {
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3542
|
+
const workspaceError = workspaceLocaleValidationError(
|
|
3543
|
+
validateLocalePipeline(locale, currentSchema, policy, validateLocale),
|
|
3544
|
+
(0, import_core5.collectSchemaLocales)(currentSchema).allUniqueLocales.size,
|
|
3545
|
+
locale
|
|
3546
|
+
);
|
|
3547
|
+
setError(workspaceError);
|
|
3548
|
+
return { success: false, error: workspaceError };
|
|
3492
3549
|
}
|
|
3493
3550
|
const validation = validateLocalePipeline(normalized, currentSchema, policy, validateLocale);
|
|
3494
|
-
if (!validation.valid)
|
|
3551
|
+
if (!validation.valid) {
|
|
3552
|
+
const workspaceError = workspaceLocaleValidationError(
|
|
3553
|
+
validation,
|
|
3554
|
+
(0, import_core5.collectSchemaLocales)(currentSchema).allUniqueLocales.size,
|
|
3555
|
+
normalized
|
|
3556
|
+
);
|
|
3557
|
+
setError(workspaceError);
|
|
3558
|
+
return { success: false, error: workspaceError };
|
|
3559
|
+
}
|
|
3560
|
+
setError(void 0);
|
|
3495
3561
|
commit({
|
|
3496
3562
|
...currentSchema,
|
|
3497
3563
|
supportedLocales: [.../* @__PURE__ */ new Set([...currentSchema.supportedLocales ?? [], normalized])]
|
|
@@ -3501,31 +3567,72 @@ function useTranslationWorkspace({
|
|
|
3501
3567
|
},
|
|
3502
3568
|
[commit, currentSchema, policy, readOnly, validateLocale]
|
|
3503
3569
|
);
|
|
3504
|
-
const isAddLocaleAllowed = (0,
|
|
3570
|
+
const isAddLocaleAllowed = (0, import_react5.useCallback)(
|
|
3505
3571
|
(locale) => {
|
|
3506
3572
|
if (readOnly) return false;
|
|
3507
|
-
const normalized = (0,
|
|
3573
|
+
const normalized = (0, import_core5.normalizeLocale)(locale);
|
|
3508
3574
|
if (normalized === null) return false;
|
|
3509
3575
|
return validateLocalePipeline(normalized, currentSchema, policy, validateLocale).valid;
|
|
3510
3576
|
},
|
|
3511
3577
|
[currentSchema, policy, readOnly, validateLocale]
|
|
3512
3578
|
);
|
|
3513
|
-
const removeLocale = (0,
|
|
3579
|
+
const removeLocale = (0, import_react5.useCallback)(
|
|
3514
3580
|
(locale) => {
|
|
3515
|
-
if (readOnly || locale === sourceLocale || locale === currentSchema.defaultLocale) return;
|
|
3516
|
-
|
|
3517
|
-
|
|
3581
|
+
if (readOnly || locale === sourceLocale || locale === currentSchema.defaultLocale) return false;
|
|
3582
|
+
const remove = () => {
|
|
3583
|
+
commit((0, import_core5.removeLocaleFromSchema)(currentSchema, locale));
|
|
3584
|
+
if (activeLocale === locale) setSelectedLocale("");
|
|
3585
|
+
};
|
|
3586
|
+
const slotCount = (0, import_core5.collectTranslationSlots)(currentSchema, locale).length;
|
|
3587
|
+
if (beforeRemoveLocale === void 0) {
|
|
3588
|
+
remove();
|
|
3589
|
+
return true;
|
|
3590
|
+
}
|
|
3591
|
+
try {
|
|
3592
|
+
const decision = beforeRemoveLocale(locale, { slotCount });
|
|
3593
|
+
if (typeof decision === "boolean") {
|
|
3594
|
+
if (!decision) return false;
|
|
3595
|
+
remove();
|
|
3596
|
+
return true;
|
|
3597
|
+
}
|
|
3598
|
+
return decision.then((allowed) => {
|
|
3599
|
+
if (!allowed) return false;
|
|
3600
|
+
remove();
|
|
3601
|
+
return true;
|
|
3602
|
+
});
|
|
3603
|
+
} catch (cause) {
|
|
3604
|
+
const workspaceError = {
|
|
3605
|
+
type: "translation_failed",
|
|
3606
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
3607
|
+
cause
|
|
3608
|
+
};
|
|
3609
|
+
setError(workspaceError);
|
|
3610
|
+
return Promise.reject(cause);
|
|
3611
|
+
}
|
|
3518
3612
|
},
|
|
3519
|
-
[activeLocale, commit, currentSchema, readOnly, sourceLocale]
|
|
3613
|
+
[activeLocale, beforeRemoveLocale, commit, currentSchema, readOnly, sourceLocale]
|
|
3520
3614
|
);
|
|
3521
|
-
const translateAll = (0,
|
|
3615
|
+
const translateAll = (0, import_react5.useCallback)(
|
|
3522
3616
|
async (options = {}) => {
|
|
3523
|
-
if (
|
|
3524
|
-
|
|
3617
|
+
if (readOnly) {
|
|
3618
|
+
const workspaceError = { type: "read_only_mode" };
|
|
3619
|
+
setError(workspaceError);
|
|
3620
|
+
return { success: false, error: workspaceError };
|
|
3621
|
+
}
|
|
3622
|
+
if (translationAdapter === void 0) {
|
|
3623
|
+
const workspaceError = { type: "adapter_not_configured" };
|
|
3624
|
+
setError(workspaceError);
|
|
3625
|
+
return { success: false, error: workspaceError };
|
|
3626
|
+
}
|
|
3627
|
+
if (activeLocale.length === 0) {
|
|
3628
|
+
const workspaceError = { type: "target_locale_missing" };
|
|
3629
|
+
setError(workspaceError);
|
|
3630
|
+
return { success: false, error: workspaceError };
|
|
3631
|
+
}
|
|
3525
3632
|
setIsTranslating(true);
|
|
3526
3633
|
setError(void 0);
|
|
3527
3634
|
try {
|
|
3528
|
-
const populated = await (0,
|
|
3635
|
+
const populated = await (0, import_core5.populateSchemaTranslations)(
|
|
3529
3636
|
currentSchema,
|
|
3530
3637
|
[activeLocale],
|
|
3531
3638
|
asAsyncAdapter(translationAdapter),
|
|
@@ -3536,30 +3643,47 @@ function useTranslationWorkspace({
|
|
|
3536
3643
|
}
|
|
3537
3644
|
);
|
|
3538
3645
|
commit(populated.schema);
|
|
3539
|
-
return populated.report;
|
|
3646
|
+
return { success: true, report: populated.report };
|
|
3540
3647
|
} catch (cause) {
|
|
3541
|
-
const
|
|
3542
|
-
|
|
3543
|
-
|
|
3648
|
+
const workspaceError = {
|
|
3649
|
+
type: "translation_failed",
|
|
3650
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
3651
|
+
cause
|
|
3652
|
+
};
|
|
3653
|
+
setError(workspaceError);
|
|
3654
|
+
return { success: false, error: workspaceError };
|
|
3544
3655
|
} finally {
|
|
3545
3656
|
setIsTranslating(false);
|
|
3546
3657
|
}
|
|
3547
3658
|
},
|
|
3548
|
-
[activeLocale, commit, currentSchema, translationAdapter]
|
|
3659
|
+
[activeLocale, commit, currentSchema, readOnly, translationAdapter]
|
|
3549
3660
|
);
|
|
3550
|
-
const translateSlot = (0,
|
|
3661
|
+
const translateSlot = (0, import_react5.useCallback)(
|
|
3551
3662
|
async (slot) => {
|
|
3552
|
-
if (translationAdapter === void 0)
|
|
3553
|
-
|
|
3663
|
+
if (translationAdapter === void 0) {
|
|
3664
|
+
const workspaceError = { type: "adapter_not_configured" };
|
|
3665
|
+
setError(workspaceError);
|
|
3666
|
+
return { success: false, error: workspaceError };
|
|
3667
|
+
}
|
|
3668
|
+
if (readOnly) {
|
|
3669
|
+
const workspaceError = { type: "read_only_mode" };
|
|
3670
|
+
setError(workspaceError);
|
|
3671
|
+
return { success: false, error: workspaceError };
|
|
3672
|
+
}
|
|
3554
3673
|
setIsTranslating(true);
|
|
3555
3674
|
setError(void 0);
|
|
3556
3675
|
try {
|
|
3557
3676
|
const text = await asAsyncAdapter(translationAdapter).translateText(slot.sourceText, slot.locale, sourceLocale);
|
|
3558
3677
|
commit(updateSchemaTranslation(currentSchema, slot, text, sourceLocale));
|
|
3678
|
+
return { success: true };
|
|
3559
3679
|
} catch (cause) {
|
|
3560
|
-
const
|
|
3561
|
-
|
|
3562
|
-
|
|
3680
|
+
const workspaceError = {
|
|
3681
|
+
type: "translation_failed",
|
|
3682
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
3683
|
+
cause
|
|
3684
|
+
};
|
|
3685
|
+
setError(workspaceError);
|
|
3686
|
+
return { success: false, error: workspaceError };
|
|
3563
3687
|
} finally {
|
|
3564
3688
|
setIsTranslating(false);
|
|
3565
3689
|
}
|
|
@@ -3585,7 +3709,7 @@ function useTranslationWorkspace({
|
|
|
3585
3709
|
}
|
|
3586
3710
|
|
|
3587
3711
|
// src/receipt.ts
|
|
3588
|
-
var
|
|
3712
|
+
var import_react6 = require("react");
|
|
3589
3713
|
function submissionReceiptQueryKey(formId, formVersion) {
|
|
3590
3714
|
return `${formId}:v${formVersion}`;
|
|
3591
3715
|
}
|
|
@@ -3656,19 +3780,19 @@ function createLocalStorageSubmissionReceiptStore(options = {}) {
|
|
|
3656
3780
|
}
|
|
3657
3781
|
function useSubmissionReceipts(store, queries) {
|
|
3658
3782
|
const querySignature = JSON.stringify(queries.map(({ formId, formVersion }) => [formId, formVersion]));
|
|
3659
|
-
const stableQueries = (0,
|
|
3783
|
+
const stableQueries = (0, import_react6.useMemo)(() => {
|
|
3660
3784
|
const parsed = JSON.parse(querySignature);
|
|
3661
3785
|
if (!Array.isArray(parsed)) return [];
|
|
3662
3786
|
return parsed.flatMap(
|
|
3663
3787
|
(entry) => Array.isArray(entry) && typeof entry[0] === "string" && typeof entry[1] === "number" && Number.isSafeInteger(entry[1]) ? [{ formId: entry[0], formVersion: entry[1] }] : []
|
|
3664
3788
|
);
|
|
3665
3789
|
}, [querySignature]);
|
|
3666
|
-
const [state, setState] = (0,
|
|
3790
|
+
const [state, setState] = (0, import_react6.useState)({
|
|
3667
3791
|
receipts: /* @__PURE__ */ new Map(),
|
|
3668
3792
|
isLoading: stableQueries.length > 0,
|
|
3669
3793
|
error: null
|
|
3670
3794
|
});
|
|
3671
|
-
(0,
|
|
3795
|
+
(0, import_react6.useEffect)(() => {
|
|
3672
3796
|
let active = true;
|
|
3673
3797
|
if (stableQueries.length === 0) {
|
|
3674
3798
|
setState({ receipts: /* @__PURE__ */ new Map(), isLoading: false, error: null });
|
|
@@ -3702,9 +3826,9 @@ function useSubmissionReceipts(store, queries) {
|
|
|
3702
3826
|
}
|
|
3703
3827
|
|
|
3704
3828
|
// src/renderer.tsx
|
|
3705
|
-
var
|
|
3706
|
-
var
|
|
3707
|
-
var
|
|
3829
|
+
var import_core6 = require("@form-engine-ts/core");
|
|
3830
|
+
var import_react7 = require("react");
|
|
3831
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3708
3832
|
var isChoiceFieldType = (type) => type === "radio" || type === "checkbox" || type === "multi-select" || type === "select";
|
|
3709
3833
|
function resolveChoiceFieldLayout(type, appearance, groupedChoiceFieldsLegacy = false) {
|
|
3710
3834
|
if (groupedChoiceFieldsLegacy) return "grouped";
|
|
@@ -3723,22 +3847,22 @@ function RequiredMark({
|
|
|
3723
3847
|
required,
|
|
3724
3848
|
className = "fe-required"
|
|
3725
3849
|
}) {
|
|
3726
|
-
return required ? /* @__PURE__ */ (0,
|
|
3850
|
+
return required ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className, "aria-hidden": "true", children: [
|
|
3727
3851
|
" ",
|
|
3728
3852
|
"*"
|
|
3729
3853
|
] }) : null;
|
|
3730
3854
|
}
|
|
3731
3855
|
function FieldMessage({ props }) {
|
|
3732
|
-
return /* @__PURE__ */ (0,
|
|
3733
|
-
props.field.description === void 0 ? null : /* @__PURE__ */ (0,
|
|
3734
|
-
props.error === void 0 ? null : /* @__PURE__ */ (0,
|
|
3856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
3857
|
+
props.field.description === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: props.helpId, className: "fe-help", children: props.field.description }),
|
|
3858
|
+
props.error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: props.errorId, className: "fe-error", children: props.translate(props.error.messageKey, props.error.params) })
|
|
3735
3859
|
] });
|
|
3736
3860
|
}
|
|
3737
3861
|
function GroupedChoiceDescription({ props }) {
|
|
3738
|
-
return props.field.description === void 0 ? null : /* @__PURE__ */ (0,
|
|
3862
|
+
return props.field.description === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: props.helpId, className: "fe-field-description", children: props.field.description });
|
|
3739
3863
|
}
|
|
3740
3864
|
function GroupedChoiceError({ props }) {
|
|
3741
|
-
return props.error === void 0 ? null : /* @__PURE__ */ (0,
|
|
3865
|
+
return props.error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: props.errorId, className: "fe-field-error", role: "alert", children: props.translate(props.error.messageKey, props.error.params) });
|
|
3742
3866
|
}
|
|
3743
3867
|
function ChoiceGroupFrame({
|
|
3744
3868
|
props,
|
|
@@ -3762,10 +3886,10 @@ function ChoiceGroupFrame({
|
|
|
3762
3886
|
children,
|
|
3763
3887
|
className
|
|
3764
3888
|
};
|
|
3765
|
-
if (renderChoiceGroup !== void 0) return /* @__PURE__ */ (0,
|
|
3889
|
+
if (renderChoiceGroup !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: renderChoiceGroup(groupProps) });
|
|
3766
3890
|
return (
|
|
3767
3891
|
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: The grouped fieldset exposes the required state for the complete choice question.
|
|
3768
|
-
/* @__PURE__ */ (0,
|
|
3892
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3769
3893
|
"fieldset",
|
|
3770
3894
|
{
|
|
3771
3895
|
className,
|
|
@@ -3776,13 +3900,13 @@ function ChoiceGroupFrame({
|
|
|
3776
3900
|
"aria-required": field.required,
|
|
3777
3901
|
style: slotProps?.style,
|
|
3778
3902
|
children: [
|
|
3779
|
-
/* @__PURE__ */ (0,
|
|
3903
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("legend", { className: "fe-choice-legend", children: [
|
|
3780
3904
|
field.title,
|
|
3781
|
-
/* @__PURE__ */ (0,
|
|
3905
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RequiredMark, { required: field.required, className: "fe-required-badge" })
|
|
3782
3906
|
] }),
|
|
3783
|
-
/* @__PURE__ */ (0,
|
|
3907
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GroupedChoiceDescription, { props }),
|
|
3784
3908
|
children,
|
|
3785
|
-
/* @__PURE__ */ (0,
|
|
3909
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GroupedChoiceError, { props })
|
|
3786
3910
|
]
|
|
3787
3911
|
}
|
|
3788
3912
|
)
|
|
@@ -3806,7 +3930,7 @@ function DefaultField({
|
|
|
3806
3930
|
};
|
|
3807
3931
|
if (field.type === "checkbox") {
|
|
3808
3932
|
if (isGroupedChoiceField) {
|
|
3809
|
-
return /* @__PURE__ */ (0,
|
|
3933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3810
3934
|
ChoiceGroupFrame,
|
|
3811
3935
|
{
|
|
3812
3936
|
props,
|
|
@@ -3815,8 +3939,8 @@ function DefaultField({
|
|
|
3815
3939
|
renderChoiceGroup,
|
|
3816
3940
|
disabled,
|
|
3817
3941
|
readOnly,
|
|
3818
|
-
children: /* @__PURE__ */ (0,
|
|
3819
|
-
/* @__PURE__ */ (0,
|
|
3942
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "fe-choice-options", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "fe-choice-option", htmlFor: inputId, children: [
|
|
3943
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3820
3944
|
"input",
|
|
3821
3945
|
{
|
|
3822
3946
|
id: inputId,
|
|
@@ -3829,14 +3953,14 @@ function DefaultField({
|
|
|
3829
3953
|
onChange: (event) => setValue(event.currentTarget.checked)
|
|
3830
3954
|
}
|
|
3831
3955
|
),
|
|
3832
|
-
/* @__PURE__ */ (0,
|
|
3956
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: field.title })
|
|
3833
3957
|
] }) })
|
|
3834
3958
|
}
|
|
3835
3959
|
);
|
|
3836
3960
|
}
|
|
3837
|
-
return /* @__PURE__ */ (0,
|
|
3838
|
-
/* @__PURE__ */ (0,
|
|
3839
|
-
/* @__PURE__ */ (0,
|
|
3961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-field fe-field--checkbox", "data-field-id": field.id, children: [
|
|
3962
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "fe-check-label", htmlFor: inputId, children: [
|
|
3963
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3840
3964
|
"input",
|
|
3841
3965
|
{
|
|
3842
3966
|
...ariaProps,
|
|
@@ -3847,19 +3971,19 @@ function DefaultField({
|
|
|
3847
3971
|
onChange: (event) => setValue(event.currentTarget.checked)
|
|
3848
3972
|
}
|
|
3849
3973
|
),
|
|
3850
|
-
/* @__PURE__ */ (0,
|
|
3974
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
3851
3975
|
field.title,
|
|
3852
|
-
/* @__PURE__ */ (0,
|
|
3976
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RequiredMark, { required: field.required })
|
|
3853
3977
|
] })
|
|
3854
3978
|
] }),
|
|
3855
|
-
/* @__PURE__ */ (0,
|
|
3979
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldMessage, { props })
|
|
3856
3980
|
] });
|
|
3857
3981
|
}
|
|
3858
3982
|
if (field.type === "radio" || field.type === "multi-select") {
|
|
3859
3983
|
const selected = Array.isArray(value) ? value : [];
|
|
3860
3984
|
if (isGroupedChoiceField) {
|
|
3861
3985
|
const isRadio = field.type === "radio";
|
|
3862
|
-
return /* @__PURE__ */ (0,
|
|
3986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3863
3987
|
ChoiceGroupFrame,
|
|
3864
3988
|
{
|
|
3865
3989
|
props,
|
|
@@ -3868,11 +3992,11 @@ function DefaultField({
|
|
|
3868
3992
|
renderChoiceGroup,
|
|
3869
3993
|
disabled,
|
|
3870
3994
|
readOnly,
|
|
3871
|
-
children: /* @__PURE__ */ (0,
|
|
3995
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "fe-choice-options", children: field.options.map((option, index) => {
|
|
3872
3996
|
const optionId = `${inputId}-${index}`;
|
|
3873
3997
|
const checked = isRadio ? value === option.id : selected.includes(option.id);
|
|
3874
|
-
return /* @__PURE__ */ (0,
|
|
3875
|
-
/* @__PURE__ */ (0,
|
|
3998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "fe-choice-option", htmlFor: optionId, children: [
|
|
3999
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3876
4000
|
"input",
|
|
3877
4001
|
{
|
|
3878
4002
|
id: optionId,
|
|
@@ -3902,22 +4026,22 @@ function DefaultField({
|
|
|
3902
4026
|
}
|
|
3903
4027
|
}
|
|
3904
4028
|
),
|
|
3905
|
-
/* @__PURE__ */ (0,
|
|
4029
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: option.label })
|
|
3906
4030
|
] }, option.id);
|
|
3907
4031
|
}) })
|
|
3908
4032
|
}
|
|
3909
4033
|
);
|
|
3910
4034
|
}
|
|
3911
4035
|
if (field.type === "radio") {
|
|
3912
|
-
return /* @__PURE__ */ (0,
|
|
3913
|
-
/* @__PURE__ */ (0,
|
|
4036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-field fe-field--radio", "data-field-id": field.id, children: [
|
|
4037
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-label", children: [
|
|
3914
4038
|
field.title,
|
|
3915
|
-
/* @__PURE__ */ (0,
|
|
4039
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RequiredMark, { required: field.required })
|
|
3916
4040
|
] }),
|
|
3917
4041
|
field.options.map((option, index) => {
|
|
3918
4042
|
const optionId = `${inputId}-${index}`;
|
|
3919
|
-
return /* @__PURE__ */ (0,
|
|
3920
|
-
/* @__PURE__ */ (0,
|
|
4043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "fe-check-label", htmlFor: optionId, children: [
|
|
4044
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3921
4045
|
"input",
|
|
3922
4046
|
{
|
|
3923
4047
|
...ariaProps,
|
|
@@ -3929,22 +4053,22 @@ function DefaultField({
|
|
|
3929
4053
|
onChange: () => setValue(option.id)
|
|
3930
4054
|
}
|
|
3931
4055
|
),
|
|
3932
|
-
/* @__PURE__ */ (0,
|
|
4056
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: option.label })
|
|
3933
4057
|
] }, option.id);
|
|
3934
4058
|
}),
|
|
3935
|
-
/* @__PURE__ */ (0,
|
|
4059
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldMessage, { props })
|
|
3936
4060
|
] });
|
|
3937
4061
|
}
|
|
3938
|
-
return /* @__PURE__ */ (0,
|
|
3939
|
-
/* @__PURE__ */ (0,
|
|
4062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { className: `fe-field fe-field--${field.type}`, "data-field-id": field.id, ...ariaProps, children: [
|
|
4063
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("legend", { className: "fe-label", children: [
|
|
3940
4064
|
field.title,
|
|
3941
|
-
/* @__PURE__ */ (0,
|
|
4065
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RequiredMark, { required: field.required })
|
|
3942
4066
|
] }),
|
|
3943
4067
|
field.options.map((option, index) => {
|
|
3944
4068
|
const optionId = `${inputId}-${index}`;
|
|
3945
4069
|
const checked = field.type === "radio" ? value === option.id : selected.includes(option.id);
|
|
3946
|
-
return /* @__PURE__ */ (0,
|
|
3947
|
-
/* @__PURE__ */ (0,
|
|
4070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "fe-check-label", htmlFor: optionId, children: [
|
|
4071
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3948
4072
|
"input",
|
|
3949
4073
|
{
|
|
3950
4074
|
id: optionId,
|
|
@@ -3961,24 +4085,24 @@ function DefaultField({
|
|
|
3961
4085
|
}
|
|
3962
4086
|
}
|
|
3963
4087
|
),
|
|
3964
|
-
/* @__PURE__ */ (0,
|
|
4088
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: option.label })
|
|
3965
4089
|
] }, option.id);
|
|
3966
4090
|
}),
|
|
3967
|
-
/* @__PURE__ */ (0,
|
|
4091
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldMessage, { props })
|
|
3968
4092
|
] });
|
|
3969
4093
|
}
|
|
3970
4094
|
if (field.type === "rating") {
|
|
3971
4095
|
const min = field.min ?? 1;
|
|
3972
4096
|
const max = field.max ?? 5;
|
|
3973
|
-
return /* @__PURE__ */ (0,
|
|
3974
|
-
/* @__PURE__ */ (0,
|
|
4097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { className: "fe-field fe-field--rating", "data-field-id": field.id, ...ariaProps, children: [
|
|
4098
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("legend", { className: "fe-label", children: [
|
|
3975
4099
|
field.title,
|
|
3976
|
-
/* @__PURE__ */ (0,
|
|
4100
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RequiredMark, { required: field.required })
|
|
3977
4101
|
] }),
|
|
3978
|
-
/* @__PURE__ */ (0,
|
|
4102
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "fe-rating-options", children: Array.from({ length: max - min + 1 }, (_, index) => min + index).map((rating) => {
|
|
3979
4103
|
const optionId = `${inputId}-${rating}`;
|
|
3980
|
-
return /* @__PURE__ */ (0,
|
|
3981
|
-
/* @__PURE__ */ (0,
|
|
4104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "fe-rating-label", htmlFor: optionId, children: [
|
|
4105
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3982
4106
|
"input",
|
|
3983
4107
|
{
|
|
3984
4108
|
id: optionId,
|
|
@@ -3989,15 +4113,15 @@ function DefaultField({
|
|
|
3989
4113
|
onChange: () => setValue(rating)
|
|
3990
4114
|
}
|
|
3991
4115
|
),
|
|
3992
|
-
/* @__PURE__ */ (0,
|
|
4116
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: rating })
|
|
3993
4117
|
] }, rating);
|
|
3994
4118
|
}) }),
|
|
3995
|
-
/* @__PURE__ */ (0,
|
|
4119
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldMessage, { props })
|
|
3996
4120
|
] });
|
|
3997
4121
|
}
|
|
3998
|
-
const label = /* @__PURE__ */ (0,
|
|
4122
|
+
const label = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "fe-label", htmlFor: inputId, children: [
|
|
3999
4123
|
field.title,
|
|
4000
|
-
/* @__PURE__ */ (0,
|
|
4124
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RequiredMark, { required: field.required })
|
|
4001
4125
|
] });
|
|
4002
4126
|
let control;
|
|
4003
4127
|
const textConstraints = field.type === "text" || field.type === "textarea" ? {
|
|
@@ -4006,7 +4130,7 @@ function DefaultField({
|
|
|
4006
4130
|
...field.pattern === void 0 ? {} : { pattern: field.pattern }
|
|
4007
4131
|
} : {};
|
|
4008
4132
|
if (field.type === "textarea") {
|
|
4009
|
-
control = /* @__PURE__ */ (0,
|
|
4133
|
+
control = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4010
4134
|
"textarea",
|
|
4011
4135
|
{
|
|
4012
4136
|
...ariaProps,
|
|
@@ -4019,7 +4143,7 @@ function DefaultField({
|
|
|
4019
4143
|
}
|
|
4020
4144
|
);
|
|
4021
4145
|
} else if (field.type === "number") {
|
|
4022
|
-
control = /* @__PURE__ */ (0,
|
|
4146
|
+
control = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4023
4147
|
"input",
|
|
4024
4148
|
{
|
|
4025
4149
|
...ariaProps,
|
|
@@ -4036,7 +4160,7 @@ function DefaultField({
|
|
|
4036
4160
|
}
|
|
4037
4161
|
);
|
|
4038
4162
|
} else if (field.type === "select") {
|
|
4039
|
-
control = /* @__PURE__ */ (0,
|
|
4163
|
+
control = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
4040
4164
|
"select",
|
|
4041
4165
|
{
|
|
4042
4166
|
...ariaProps,
|
|
@@ -4046,14 +4170,14 @@ function DefaultField({
|
|
|
4046
4170
|
value: typeof value === "string" ? value : "",
|
|
4047
4171
|
onChange: (event) => setValue(event.currentTarget.value || void 0),
|
|
4048
4172
|
children: [
|
|
4049
|
-
/* @__PURE__ */ (0,
|
|
4050
|
-
field.options.map((option) => /* @__PURE__ */ (0,
|
|
4173
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: "\u2014" }),
|
|
4174
|
+
field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: option.id, children: option.label }, option.id))
|
|
4051
4175
|
]
|
|
4052
4176
|
}
|
|
4053
4177
|
);
|
|
4054
4178
|
} else {
|
|
4055
4179
|
const placeholderKey = "placeholderKey" in field ? field.placeholderKey : void 0;
|
|
4056
|
-
control = /* @__PURE__ */ (0,
|
|
4180
|
+
control = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4057
4181
|
"input",
|
|
4058
4182
|
{
|
|
4059
4183
|
...ariaProps,
|
|
@@ -4067,7 +4191,7 @@ function DefaultField({
|
|
|
4067
4191
|
);
|
|
4068
4192
|
}
|
|
4069
4193
|
if (isGroupedChoiceField) {
|
|
4070
|
-
return /* @__PURE__ */ (0,
|
|
4194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4071
4195
|
ChoiceGroupFrame,
|
|
4072
4196
|
{
|
|
4073
4197
|
props,
|
|
@@ -4076,23 +4200,23 @@ function DefaultField({
|
|
|
4076
4200
|
renderChoiceGroup,
|
|
4077
4201
|
disabled,
|
|
4078
4202
|
readOnly,
|
|
4079
|
-
children: /* @__PURE__ */ (0,
|
|
4203
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "fe-choice-options", children: control })
|
|
4080
4204
|
}
|
|
4081
4205
|
);
|
|
4082
4206
|
}
|
|
4083
|
-
return /* @__PURE__ */ (0,
|
|
4207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `fe-field fe-field--${field.type}`, "data-field-id": field.id, children: [
|
|
4084
4208
|
label,
|
|
4085
4209
|
control,
|
|
4086
4210
|
(field.type === "text" || field.type === "textarea") && field.maxLength !== void 0 ? props.renderCharacterCount?.({
|
|
4087
4211
|
fieldId: field.id,
|
|
4088
4212
|
current: typeof value === "string" ? value.length : 0,
|
|
4089
4213
|
max: field.maxLength
|
|
4090
|
-
}) ?? /* @__PURE__ */ (0,
|
|
4214
|
+
}) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-character-count", "aria-live": "polite", children: [
|
|
4091
4215
|
typeof value === "string" ? value.length : 0,
|
|
4092
4216
|
" / ",
|
|
4093
4217
|
field.maxLength
|
|
4094
4218
|
] }) : null,
|
|
4095
|
-
/* @__PURE__ */ (0,
|
|
4219
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldMessage, { props })
|
|
4096
4220
|
] });
|
|
4097
4221
|
}
|
|
4098
4222
|
function isRecord(value) {
|
|
@@ -4214,32 +4338,34 @@ function ContextFormRenderer({
|
|
|
4214
4338
|
slots = {}
|
|
4215
4339
|
}) {
|
|
4216
4340
|
const form = useForm();
|
|
4217
|
-
const
|
|
4218
|
-
const
|
|
4219
|
-
const
|
|
4220
|
-
const
|
|
4221
|
-
const
|
|
4222
|
-
const [
|
|
4223
|
-
const [
|
|
4224
|
-
const [
|
|
4225
|
-
const [
|
|
4226
|
-
const [
|
|
4227
|
-
const [
|
|
4228
|
-
const [
|
|
4229
|
-
const
|
|
4230
|
-
const
|
|
4231
|
-
const
|
|
4232
|
-
const
|
|
4341
|
+
const i18n = useFormEngineI18n();
|
|
4342
|
+
const isProviderValue = (0, import_react7.useContext)(FormEngineI18nProviderScopeContext);
|
|
4343
|
+
const prefix = (0, import_react7.useId)().replace(/:/g, "");
|
|
4344
|
+
const formRef = (0, import_react7.useRef)(null);
|
|
4345
|
+
const loadedDraftKey = (0, import_react7.useRef)(null);
|
|
4346
|
+
const [draftRestored, setDraftRestored] = (0, import_react7.useState)(false);
|
|
4347
|
+
const [currentPageIndex, setCurrentPageIndex] = (0, import_react7.useState)(0);
|
|
4348
|
+
const [focusFieldId, setFocusFieldId] = (0, import_react7.useState)(null);
|
|
4349
|
+
const [confirmation, setConfirmation] = (0, import_react7.useState)(null);
|
|
4350
|
+
const [guardMessage, setGuardMessage] = (0, import_react7.useState)(null);
|
|
4351
|
+
const [guardsPending, setGuardsPending] = (0, import_react7.useState)(false);
|
|
4352
|
+
const [receipt, setReceipt] = (0, import_react7.useState)(null);
|
|
4353
|
+
const [completionData, setCompletionData] = (0, import_react7.useState)(null);
|
|
4354
|
+
const [receiptLoaded, setReceiptLoaded] = (0, import_react7.useState)(receiptStore === void 0);
|
|
4355
|
+
const rendererSubmissionInFlight = (0, import_react7.useRef)(false);
|
|
4356
|
+
const fallbackAttemptId = (0, import_react7.useRef)(null);
|
|
4357
|
+
const completionRef = (0, import_react7.useRef)(null);
|
|
4358
|
+
const confirmationRef = (0, import_react7.useRef)(null);
|
|
4233
4359
|
const pages = form.schema.pages;
|
|
4234
|
-
const visiblePageIndexes = (0,
|
|
4360
|
+
const visiblePageIndexes = (0, import_react7.useMemo)(
|
|
4235
4361
|
() => pages === void 0 ? [] : pages.flatMap((page, index) => form.pageVisibility[page.id] === true ? [index] : []),
|
|
4236
4362
|
[form.pageVisibility, pages]
|
|
4237
4363
|
);
|
|
4238
4364
|
const activePage = pages?.[currentPageIndex];
|
|
4239
4365
|
const activeVisibleIndex = visiblePageIndexes.indexOf(currentPageIndex);
|
|
4240
4366
|
const fieldIds = activePage === void 0 ? void 0 : new Set(activePage.questionIds);
|
|
4241
|
-
const visibleValues = (0,
|
|
4242
|
-
const visibleItems = (0,
|
|
4367
|
+
const visibleValues = (0, import_react7.useMemo)(() => (0, import_core6.selectVisibleAnswers)(form.schema, form.values), [form.schema, form.values]);
|
|
4368
|
+
const visibleItems = (0, import_react7.useMemo)(
|
|
4243
4369
|
() => buildSubmittedItems(form.schema, form.values, form.visibility, (key) => form.translate(key), false),
|
|
4244
4370
|
[form.schema, form.translate, form.values, form.visibility]
|
|
4245
4371
|
);
|
|
@@ -4248,23 +4374,24 @@ function ContextFormRenderer({
|
|
|
4248
4374
|
const submitState = confirmation === null && !guardsPending ? form.submitStatus : "confirming";
|
|
4249
4375
|
const interactionLocked = submitState === "confirming" || submitState === "submitting";
|
|
4250
4376
|
const isReplaceMode = successRenderMode === "replace" || hideFormOnSuccess;
|
|
4251
|
-
const resolveMessage = (0,
|
|
4377
|
+
const resolveMessage = (0, import_react7.useCallback)(
|
|
4252
4378
|
(key, fallback) => {
|
|
4253
|
-
const
|
|
4379
|
+
const providerDefault = isProviderValue ? i18n.translator(`renderer.${key}`) : void 0;
|
|
4380
|
+
const defaultText = fallback ?? (providerDefault === "" ? void 0 : providerDefault) ?? DEFAULT_RENDERER_MESSAGES[form.locale.toLowerCase().startsWith("ja") ? "ja" : "en"][key] ?? key;
|
|
4254
4381
|
const configured = messages[key];
|
|
4255
4382
|
return messageResolver?.(key, configured ?? defaultText) ?? configured ?? defaultText;
|
|
4256
4383
|
},
|
|
4257
|
-
[form.locale, messageResolver, messages]
|
|
4384
|
+
[form.locale, i18n, isProviderValue, messageResolver, messages]
|
|
4258
4385
|
);
|
|
4259
|
-
const fieldTranslate = (0,
|
|
4386
|
+
const fieldTranslate = (0, import_react7.useCallback)(
|
|
4260
4387
|
(key, params) => key === "validation.required" && (messages.requiredField !== void 0 || messageResolver !== void 0) ? resolveMessage("requiredField") : form.translate(key, params),
|
|
4261
4388
|
[form.translate, messageResolver, messages.requiredField, resolveMessage]
|
|
4262
4389
|
);
|
|
4263
|
-
const focusSubmitButton = (0,
|
|
4390
|
+
const focusSubmitButton = (0, import_react7.useCallback)(() => {
|
|
4264
4391
|
const button = formRef.current?.querySelector(".fe-submit, button[type='submit'], button");
|
|
4265
4392
|
button?.focus();
|
|
4266
4393
|
}, []);
|
|
4267
|
-
(0,
|
|
4394
|
+
(0, import_react7.useEffect)(() => {
|
|
4268
4395
|
let active = true;
|
|
4269
4396
|
if (receiptStore === void 0) {
|
|
4270
4397
|
setReceipt(null);
|
|
@@ -4285,14 +4412,14 @@ function ContextFormRenderer({
|
|
|
4285
4412
|
active = false;
|
|
4286
4413
|
};
|
|
4287
4414
|
}, [form.schema.id, form.schema.version, receiptStore]);
|
|
4288
|
-
(0,
|
|
4415
|
+
(0, import_react7.useEffect)(() => {
|
|
4289
4416
|
if (pages === void 0 || visiblePageIndexes.length === 0) {
|
|
4290
4417
|
setCurrentPageIndex(0);
|
|
4291
4418
|
return;
|
|
4292
4419
|
}
|
|
4293
4420
|
if (!visiblePageIndexes.includes(currentPageIndex)) setCurrentPageIndex(visiblePageIndexes[0] ?? 0);
|
|
4294
4421
|
}, [currentPageIndex, pages, visiblePageIndexes]);
|
|
4295
|
-
(0,
|
|
4422
|
+
(0, import_react7.useEffect)(() => {
|
|
4296
4423
|
if (focusFieldId === null) return;
|
|
4297
4424
|
const fieldContainer = [...formRef.current?.querySelectorAll("[data-field-id]") ?? []].find(
|
|
4298
4425
|
(element) => element.dataset.fieldId === focusFieldId
|
|
@@ -4304,11 +4431,11 @@ function ContextFormRenderer({
|
|
|
4304
4431
|
setFocusFieldId(null);
|
|
4305
4432
|
}
|
|
4306
4433
|
}, [focusFieldId]);
|
|
4307
|
-
(0,
|
|
4434
|
+
(0, import_react7.useEffect)(() => {
|
|
4308
4435
|
if (!isReplaceMode || form.submitStatus !== "success") return;
|
|
4309
4436
|
completionRef.current?.focus();
|
|
4310
4437
|
}, [form.submitStatus, isReplaceMode]);
|
|
4311
|
-
(0,
|
|
4438
|
+
(0, import_react7.useEffect)(() => {
|
|
4312
4439
|
if (confirmation === null) return;
|
|
4313
4440
|
const confirmButton = confirmationRef.current?.querySelector("[data-fe-confirm], button");
|
|
4314
4441
|
confirmButton?.focus();
|
|
@@ -4340,7 +4467,7 @@ function ContextFormRenderer({
|
|
|
4340
4467
|
globalThis.addEventListener("keydown", onKeyDown);
|
|
4341
4468
|
return () => globalThis.removeEventListener("keydown", onKeyDown);
|
|
4342
4469
|
}, [confirmation, confirmationRenderMode, focusSubmitButton]);
|
|
4343
|
-
(0,
|
|
4470
|
+
(0, import_react7.useEffect)(() => {
|
|
4344
4471
|
if (autoSaveKey === void 0 || typeof globalThis.localStorage === "undefined") return;
|
|
4345
4472
|
const loadIdentity = `${autoSaveKey}:${form.schema.id}:${form.schema.version}`;
|
|
4346
4473
|
if (loadedDraftKey.current === loadIdentity) return;
|
|
@@ -4352,7 +4479,7 @@ function ContextFormRenderer({
|
|
|
4352
4479
|
form.restoreValues(draft.values);
|
|
4353
4480
|
setDraftRestored(true);
|
|
4354
4481
|
}, [autoSaveKey, form.restoreValues, form.schema.id, form.schema.version]);
|
|
4355
|
-
(0,
|
|
4482
|
+
(0, import_react7.useEffect)(() => {
|
|
4356
4483
|
if (form.submitStatus === "success") return;
|
|
4357
4484
|
const timeout = globalThis.setTimeout(() => {
|
|
4358
4485
|
onDraftSave?.(form.values);
|
|
@@ -4408,7 +4535,7 @@ function ContextFormRenderer({
|
|
|
4408
4535
|
if (rendererSubmissionInFlight.current || submitState === "submitting" || submitState === "success" || confirmation !== null && !guardsConfirmed) {
|
|
4409
4536
|
return { status: "cancelled" };
|
|
4410
4537
|
}
|
|
4411
|
-
const validation = (0,
|
|
4538
|
+
const validation = (0, import_core6.validateAnswers)(form.schema, form.values);
|
|
4412
4539
|
const firstInvalidFieldId = validation.issues[0]?.fieldId;
|
|
4413
4540
|
if (validation.valid && !guardsConfirmed) {
|
|
4414
4541
|
rendererSubmissionInFlight.current = true;
|
|
@@ -4562,8 +4689,8 @@ function ContextFormRenderer({
|
|
|
4562
4689
|
disabled: interactionLocked || submitState === "success",
|
|
4563
4690
|
onSubmit: () => void submitValues()
|
|
4564
4691
|
};
|
|
4565
|
-
return slots.renderSubmitButton?.(submitButtonProps) ?? /* @__PURE__ */ (0,
|
|
4566
|
-
submitState === "submitting" ? /* @__PURE__ */ (0,
|
|
4692
|
+
return slots.renderSubmitButton?.(submitButtonProps) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { className: "fe-submit", type: "submit", disabled: submitButtonProps.disabled, children: [
|
|
4693
|
+
submitState === "submitting" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fe-spinner", "aria-hidden": "true" }) : null,
|
|
4567
4694
|
submitState === "submitting" ? resolveMessage("submittingButton") : resolveMessage("submitButton", form.translate(form.schema.submitLabelKey ?? "form.submit"))
|
|
4568
4695
|
] });
|
|
4569
4696
|
};
|
|
@@ -4586,11 +4713,11 @@ function ContextFormRenderer({
|
|
|
4586
4713
|
...activeCompletionData.response === void 0 ? {} : { response: activeCompletionData.response },
|
|
4587
4714
|
onReset: form.reset
|
|
4588
4715
|
};
|
|
4589
|
-
const completionRegion = /* @__PURE__ */ (0,
|
|
4590
|
-
slots.renderCompletion?.(completionProps) ?? /* @__PURE__ */ (0,
|
|
4716
|
+
const completionRegion = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: completionRef, className: "fe-completion", role: "status", "aria-live": "polite", tabIndex: -1, children: [
|
|
4717
|
+
slots.renderCompletion?.(completionProps) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: completionMessage }),
|
|
4591
4718
|
slots.renderSubmittedValues?.({ items: activeCompletionData.submittedItems, schema: form.schema })
|
|
4592
4719
|
] });
|
|
4593
|
-
const confirmationContent = /* @__PURE__ */ (0,
|
|
4720
|
+
const confirmationContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4594
4721
|
"div",
|
|
4595
4722
|
{
|
|
4596
4723
|
ref: confirmationRef,
|
|
@@ -4604,53 +4731,53 @@ function ContextFormRenderer({
|
|
|
4604
4731
|
visibleItems,
|
|
4605
4732
|
onConfirm: confirmSubmission,
|
|
4606
4733
|
onCancel: cancelSubmission
|
|
4607
|
-
}) ?? /* @__PURE__ */ (0,
|
|
4608
|
-
/* @__PURE__ */ (0,
|
|
4609
|
-
/* @__PURE__ */ (0,
|
|
4610
|
-
(confirmation?.findings ?? []).length === 0 ? null : /* @__PURE__ */ (0,
|
|
4734
|
+
}) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
4735
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { children: confirmation?.generic === true ? form.locale.toLowerCase().startsWith("ja") ? "\u56DE\u7B54\u5185\u5BB9\u306E\u78BA\u8A8D" : "Review your answers" : resolveMessage("confirmSensitiveDataTitle") }),
|
|
4736
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: confirmation?.message ?? (confirmation?.generic === true ? form.locale.toLowerCase().startsWith("ja") ? "\u56DE\u7B54\u5185\u5BB9\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001\u9001\u4FE1\u3057\u3066\u304F\u3060\u3055\u3044\u3002" : "Please review your answers before submitting." : resolveMessage("confirmSensitiveDataMessage", form.translate("form.confirmSensitiveData"))) }),
|
|
4737
|
+
(confirmation?.findings ?? []).length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { children: (confirmation?.findings ?? []).map((finding, index) => {
|
|
4611
4738
|
const field = form.schema.fields.find((candidate) => candidate.id === finding.fieldId);
|
|
4612
4739
|
const typeLabels = form.locale.toLowerCase().startsWith("ja") ? { email: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9", phone: "\u96FB\u8A71\u756A\u53F7", url: "URL", postal_code: "\u90F5\u4FBF\u756A\u53F7" } : { email: "Email address", phone: "Phone number", url: "URL", postal_code: "Postal code" };
|
|
4613
4740
|
const typeLabel = finding.typeLabel ?? typeLabels[finding.type] ?? finding.type;
|
|
4614
4741
|
const value = maskSensitiveValue(finding);
|
|
4615
|
-
return /* @__PURE__ */ (0,
|
|
4616
|
-
/* @__PURE__ */ (0,
|
|
4742
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
|
|
4743
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: finding.fieldTitle ?? field?.title ?? finding.fieldId }),
|
|
4617
4744
|
" ",
|
|
4618
|
-
/* @__PURE__ */ (0,
|
|
4619
|
-
value === void 0 ? null : /* @__PURE__ */ (0,
|
|
4745
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "fe-sensitive-type", children: typeLabel }),
|
|
4746
|
+
value === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "fe-sensitive-value", children: [
|
|
4620
4747
|
" ",
|
|
4621
4748
|
value
|
|
4622
4749
|
] })
|
|
4623
4750
|
] }, `${finding.fieldId}-${finding.type}-${finding.start ?? index}`);
|
|
4624
4751
|
}) }),
|
|
4625
|
-
confirmation?.generic === true ? /* @__PURE__ */ (0,
|
|
4626
|
-
/* @__PURE__ */ (0,
|
|
4752
|
+
confirmation?.generic === true ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "fe-submission-summary", children: visibleItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
|
|
4753
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: item.title }),
|
|
4627
4754
|
": ",
|
|
4628
|
-
/* @__PURE__ */ (0,
|
|
4755
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: item.displayValue })
|
|
4629
4756
|
] }, item.fieldId)) }) : null,
|
|
4630
|
-
/* @__PURE__ */ (0,
|
|
4631
|
-
/* @__PURE__ */ (0,
|
|
4757
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "data-fe-confirm": "true", onClick: confirmSubmission, children: resolveMessage("confirmButton", form.translate("form.confirmSubmission")) }),
|
|
4758
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: cancelSubmission, children: resolveMessage("cancelButton", form.translate("form.cancelSubmission")) })
|
|
4632
4759
|
] })
|
|
4633
4760
|
}
|
|
4634
4761
|
);
|
|
4635
4762
|
if (!receiptLoaded) return null;
|
|
4636
4763
|
if (receipt !== null) {
|
|
4637
|
-
return /* @__PURE__ */ (0,
|
|
4764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `fe-form fe-already-submitted ${className}`.trim(), children: slots.renderAlreadySubmitted?.({
|
|
4638
4765
|
receipt,
|
|
4639
4766
|
...receiptStore === void 0 ? {} : { onReset: () => void resetReceipt() }
|
|
4640
|
-
}) ?? /* @__PURE__ */ (0,
|
|
4641
|
-
/* @__PURE__ */ (0,
|
|
4642
|
-
/* @__PURE__ */ (0,
|
|
4643
|
-
receiptStore === void 0 ? null : /* @__PURE__ */ (0,
|
|
4767
|
+
}) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "status", children: [
|
|
4768
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { children: resolveMessage("alreadySubmittedTitle") }),
|
|
4769
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: resolveMessage("alreadySubmittedMessage", form.translate("form.alreadySubmitted")) }),
|
|
4770
|
+
receiptStore === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => void resetReceipt(), children: resolveMessage("submitButton", form.translate("form.submitAnother")) })
|
|
4644
4771
|
] }) });
|
|
4645
4772
|
}
|
|
4646
4773
|
if (form.submitStatus === "success" && isReplaceMode) {
|
|
4647
|
-
return /* @__PURE__ */ (0,
|
|
4774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `fe-form ${className}`.trim(), children: completionRegion });
|
|
4648
4775
|
}
|
|
4649
4776
|
if (confirmation !== null && confirmationRenderMode === "replace") {
|
|
4650
|
-
return /* @__PURE__ */ (0,
|
|
4777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `fe-form ${className}`.trim(), children: confirmationContent });
|
|
4651
4778
|
}
|
|
4652
|
-
return /* @__PURE__ */ (0,
|
|
4653
|
-
/* @__PURE__ */ (0,
|
|
4779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
4780
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
4654
4781
|
"form",
|
|
4655
4782
|
{
|
|
4656
4783
|
ref: formRef,
|
|
@@ -4662,11 +4789,11 @@ function ContextFormRenderer({
|
|
|
4662
4789
|
slots.renderHeader?.({
|
|
4663
4790
|
title: form.schema.title,
|
|
4664
4791
|
...form.schema.description === void 0 ? {} : { description: form.schema.description }
|
|
4665
|
-
}) ?? /* @__PURE__ */ (0,
|
|
4666
|
-
/* @__PURE__ */ (0,
|
|
4667
|
-
form.schema.description === void 0 ? null : /* @__PURE__ */ (0,
|
|
4668
|
-
pages === void 0 ? null : /* @__PURE__ */ (0,
|
|
4669
|
-
/* @__PURE__ */ (0,
|
|
4792
|
+
}) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("header", { className: "fe-header", children: [
|
|
4793
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h1", { children: form.schema.title }),
|
|
4794
|
+
form.schema.description === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: form.schema.description }),
|
|
4795
|
+
pages === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-progress", children: [
|
|
4796
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4670
4797
|
"div",
|
|
4671
4798
|
{
|
|
4672
4799
|
className: "form-progress-bar",
|
|
@@ -4674,7 +4801,7 @@ function ContextFormRenderer({
|
|
|
4674
4801
|
"aria-valuemin": 1,
|
|
4675
4802
|
"aria-valuemax": visiblePageIndexes.length,
|
|
4676
4803
|
"aria-valuenow": activeVisibleIndex + 1,
|
|
4677
|
-
children: /* @__PURE__ */ (0,
|
|
4804
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4678
4805
|
"div",
|
|
4679
4806
|
{
|
|
4680
4807
|
className: "form-progress-fill",
|
|
@@ -4683,17 +4810,17 @@ function ContextFormRenderer({
|
|
|
4683
4810
|
)
|
|
4684
4811
|
}
|
|
4685
4812
|
),
|
|
4686
|
-
/* @__PURE__ */ (0,
|
|
4813
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: form.translate("form.step", { current: activeVisibleIndex + 1, total: visiblePageIndexes.length }) })
|
|
4687
4814
|
] }),
|
|
4688
|
-
draftRestored ? /* @__PURE__ */ (0,
|
|
4815
|
+
draftRestored ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "form-draft-badge", children: form.translate("form.draftRestored") }) : null
|
|
4689
4816
|
] }),
|
|
4690
4817
|
activePage === void 0 ? null : slots.renderPageHeader?.({
|
|
4691
4818
|
page: activePage,
|
|
4692
4819
|
pageIndex: activeVisibleIndex,
|
|
4693
4820
|
totalPages: visiblePageIndexes.length
|
|
4694
|
-
}) ?? /* @__PURE__ */ (0,
|
|
4695
|
-
activePage.title === void 0 ? null : /* @__PURE__ */ (0,
|
|
4696
|
-
activePage.description === void 0 ? null : /* @__PURE__ */ (0,
|
|
4821
|
+
}) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-page-header", children: [
|
|
4822
|
+
activePage.title === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "fe-page-title", children: activePage.title }),
|
|
4823
|
+
activePage.description === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "fe-page-description", children: activePage.description })
|
|
4697
4824
|
] }),
|
|
4698
4825
|
(() => {
|
|
4699
4826
|
const fieldChildren = form.schema.fields.filter((field) => form.visibility[field.id] === true && (fieldIds === void 0 || fieldIds.has(field.id))).map((field) => {
|
|
@@ -4710,7 +4837,7 @@ function ContextFormRenderer({
|
|
|
4710
4837
|
...slots.renderCharacterCount === void 0 ? {} : { renderCharacterCount: slots.renderCharacterCount }
|
|
4711
4838
|
};
|
|
4712
4839
|
if (slots.renderField !== void 0) {
|
|
4713
|
-
return /* @__PURE__ */ (0,
|
|
4840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react7.Fragment, { children: slots.renderField({
|
|
4714
4841
|
question: field,
|
|
4715
4842
|
value: form.values[field.id],
|
|
4716
4843
|
onChange: (value) => {
|
|
@@ -4720,7 +4847,7 @@ function ContextFormRenderer({
|
|
|
4720
4847
|
}) }, field.id);
|
|
4721
4848
|
}
|
|
4722
4849
|
const Component = components[field.type];
|
|
4723
|
-
return Component === void 0 ? /* @__PURE__ */ (0,
|
|
4850
|
+
return Component === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4724
4851
|
DefaultField,
|
|
4725
4852
|
{
|
|
4726
4853
|
...props,
|
|
@@ -4731,20 +4858,20 @@ function ContextFormRenderer({
|
|
|
4731
4858
|
disabled: interactionLocked
|
|
4732
4859
|
},
|
|
4733
4860
|
field.id
|
|
4734
|
-
) : /* @__PURE__ */ (0,
|
|
4861
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, { ...props }, field.id);
|
|
4735
4862
|
});
|
|
4736
4863
|
const fieldClassName = `fe-fields${fieldsClassName === void 0 ? "" : ` ${fieldsClassName}`}`;
|
|
4737
|
-
return slots.renderFields?.({ children: fieldChildren, className: fieldClassName }) ?? /* @__PURE__ */ (0,
|
|
4864
|
+
return slots.renderFields?.({ children: fieldChildren, className: fieldClassName }) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: fieldClassName, children: fieldChildren });
|
|
4738
4865
|
})(),
|
|
4739
|
-
guardMessage === null ? null : /* @__PURE__ */ (0,
|
|
4866
|
+
guardMessage === null ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "alert", children: guardMessage }),
|
|
4740
4867
|
confirmation !== null && confirmationRenderMode === "inline" ? confirmationContent : null,
|
|
4741
|
-
validationIssues.length === 0 ? null : slots.renderValidationSummary?.({ issues: validationIssues }) ?? /* @__PURE__ */ (0,
|
|
4868
|
+
validationIssues.length === 0 ? null : slots.renderValidationSummary?.({ issues: validationIssues }) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-validation-summary", role: "alert", children: [
|
|
4742
4869
|
validationIssues.length,
|
|
4743
4870
|
" validation error",
|
|
4744
4871
|
validationIssues.length === 1 ? "" : "s",
|
|
4745
4872
|
"."
|
|
4746
4873
|
] }),
|
|
4747
|
-
pages === void 0 ? /* @__PURE__ */ (0,
|
|
4874
|
+
pages === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
4748
4875
|
slots.renderNavigation?.({
|
|
4749
4876
|
currentPage: 0,
|
|
4750
4877
|
totalPages: 1,
|
|
@@ -4754,7 +4881,7 @@ function ContextFormRenderer({
|
|
|
4754
4881
|
onNext: () => void 0
|
|
4755
4882
|
}),
|
|
4756
4883
|
renderSubmitButton()
|
|
4757
|
-
] }) : /* @__PURE__ */ (0,
|
|
4884
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "form-step-navigation", children: [
|
|
4758
4885
|
slots.renderNavigation?.({
|
|
4759
4886
|
currentPage: activeVisibleIndex,
|
|
4760
4887
|
totalPages: visiblePageIndexes.length,
|
|
@@ -4764,8 +4891,8 @@ function ContextFormRenderer({
|
|
|
4764
4891
|
if (!interactionLocked) setCurrentPageIndex(visiblePageIndexes[activeVisibleIndex - 1] ?? 0);
|
|
4765
4892
|
},
|
|
4766
4893
|
onNext: handleNext
|
|
4767
|
-
}) ?? /* @__PURE__ */ (0,
|
|
4768
|
-
canPrev ? /* @__PURE__ */ (0,
|
|
4894
|
+
}) ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
4895
|
+
canPrev ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4769
4896
|
"button",
|
|
4770
4897
|
{
|
|
4771
4898
|
className: "btn-prev",
|
|
@@ -4775,24 +4902,24 @@ function ContextFormRenderer({
|
|
|
4775
4902
|
children: form.translate("form.back")
|
|
4776
4903
|
}
|
|
4777
4904
|
) : null,
|
|
4778
|
-
canNext ? /* @__PURE__ */ (0,
|
|
4905
|
+
canNext ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "btn-next", type: "button", disabled: interactionLocked, onClick: handleNext, children: form.translate("form.next") }) : null
|
|
4779
4906
|
] }),
|
|
4780
4907
|
canNext ? null : renderSubmitButton()
|
|
4781
4908
|
] }),
|
|
4782
|
-
/* @__PURE__ */ (0,
|
|
4909
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fe-status", "aria-live": "polite", children: [
|
|
4783
4910
|
form.submitStatus === "success" ? completionRegion : null,
|
|
4784
|
-
form.submitStatus === "error" && form.submitError !== null ? slots.renderSubmitError?.({ error: form.submitError, onRetry: () => void submitValues() }) ?? (form.submitError instanceof FormSubmissionError && form.submitError.payload.formError !== void 0 ? /* @__PURE__ */ (0,
|
|
4911
|
+
form.submitStatus === "error" && form.submitError !== null ? slots.renderSubmitError?.({ error: form.submitError, onRetry: () => void submitValues() }) ?? (form.submitError instanceof FormSubmissionError && form.submitError.payload.formError !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "alert", children: [
|
|
4785
4912
|
form.submitError.payload.formError,
|
|
4786
|
-
/* @__PURE__ */ (0,
|
|
4787
|
-
] }) : /* @__PURE__ */ (0,
|
|
4913
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => void submitValues(), children: resolveMessage("retryButton") })
|
|
4914
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "alert", children: [
|
|
4788
4915
|
errorMessageKey === void 0 ? resolveMessage("serverErrorSummary") : form.translate(errorMessageKey),
|
|
4789
|
-
/* @__PURE__ */ (0,
|
|
4916
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => void submitValues(), children: resolveMessage("retryButton") })
|
|
4790
4917
|
] })) : null
|
|
4791
4918
|
] })
|
|
4792
4919
|
]
|
|
4793
4920
|
}
|
|
4794
4921
|
),
|
|
4795
|
-
confirmation !== null && confirmationRenderMode === "dialog" ? /* @__PURE__ */ (0,
|
|
4922
|
+
confirmation !== null && confirmationRenderMode === "dialog" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "fe-confirmation-dialog-backdrop", role: "dialog", "aria-modal": "true", children: confirmationContent }) : null
|
|
4796
4923
|
] });
|
|
4797
4924
|
}
|
|
4798
4925
|
var RENDERER_MESSAGES = {
|
|
@@ -4837,17 +4964,22 @@ var defaultRendererTranslator = {
|
|
|
4837
4964
|
}
|
|
4838
4965
|
};
|
|
4839
4966
|
function FormRenderer(props) {
|
|
4840
|
-
|
|
4967
|
+
const i18n = useFormEngineI18n();
|
|
4968
|
+
const isProviderValue = (0, import_react7.useContext)(FormEngineI18nProviderScopeContext);
|
|
4969
|
+
if (!("schema" in props)) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ContextFormRenderer, { ...props });
|
|
4841
4970
|
const {
|
|
4842
4971
|
schema,
|
|
4843
4972
|
locale = schema.defaultLocale ?? "en",
|
|
4844
|
-
translator
|
|
4973
|
+
translator: explicitTranslator,
|
|
4845
4974
|
initialValues,
|
|
4846
4975
|
resetOnSuccess,
|
|
4847
4976
|
onSubmit,
|
|
4848
4977
|
...rendererProps
|
|
4849
4978
|
} = props;
|
|
4850
|
-
|
|
4979
|
+
const translator = explicitTranslator ?? (isProviderValue ? {
|
|
4980
|
+
translate: (key, _locale, params) => params === void 0 ? i18n.translator(key) : i18n.translator(key, { ...params })
|
|
4981
|
+
} : defaultRendererTranslator);
|
|
4982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4851
4983
|
FormProvider,
|
|
4852
4984
|
{
|
|
4853
4985
|
schema,
|
|
@@ -4856,7 +4988,7 @@ function FormRenderer(props) {
|
|
|
4856
4988
|
onSubmit,
|
|
4857
4989
|
...initialValues === void 0 ? {} : { initialValues },
|
|
4858
4990
|
...resetOnSuccess === void 0 ? {} : { resetOnSuccess },
|
|
4859
|
-
children: /* @__PURE__ */ (0,
|
|
4991
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ContextFormRenderer, { ...rendererProps })
|
|
4860
4992
|
}
|
|
4861
4993
|
);
|
|
4862
4994
|
}
|
|
@@ -4865,6 +4997,8 @@ function FormRenderer(props) {
|
|
|
4865
4997
|
BUILDER_TRANSLATION_ALIASES,
|
|
4866
4998
|
BUILDER_TRANSLATION_KEYS,
|
|
4867
4999
|
FormBuilder,
|
|
5000
|
+
FormEngineI18nContext,
|
|
5001
|
+
FormEngineI18nProvider,
|
|
4868
5002
|
FormProvider,
|
|
4869
5003
|
FormRenderer,
|
|
4870
5004
|
FormSubmissionError,
|
|
@@ -4880,6 +5014,7 @@ function FormRenderer(props) {
|
|
|
4880
5014
|
useField,
|
|
4881
5015
|
useForm,
|
|
4882
5016
|
useFormBuilder,
|
|
5017
|
+
useFormEngineI18n,
|
|
4883
5018
|
useSubmissionReceipts,
|
|
4884
5019
|
useTranslationWorkspace,
|
|
4885
5020
|
validateLocalePipeline
|