@character-foundry/character-foundry 0.1.9-dev.1765936776 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-framework.cjs +95 -291
- package/dist/app-framework.cjs.map +1 -1
- package/dist/app-framework.d.cts +1 -1
- package/dist/app-framework.d.ts +1 -1
- package/dist/app-framework.js +96 -292
- package/dist/app-framework.js.map +1 -1
- package/dist/charx.cjs +23 -44
- package/dist/charx.cjs.map +1 -1
- package/dist/charx.d.cts +207 -368
- package/dist/charx.d.ts +207 -368
- package/dist/charx.js +23 -44
- package/dist/charx.js.map +1 -1
- package/dist/exporter.cjs +22 -27
- package/dist/exporter.cjs.map +1 -1
- package/dist/exporter.d.cts +207 -368
- package/dist/exporter.d.ts +207 -368
- package/dist/exporter.js +22 -27
- package/dist/exporter.js.map +1 -1
- package/dist/federation.cjs +4 -16
- package/dist/federation.cjs.map +1 -1
- package/dist/federation.d.cts +207 -368
- package/dist/federation.d.ts +207 -368
- package/dist/federation.js +4 -16
- package/dist/federation.js.map +1 -1
- package/dist/image-utils.cjs.map +1 -1
- package/dist/image-utils.d.cts +0 -12
- package/dist/image-utils.d.ts +0 -12
- package/dist/image-utils.js.map +1 -1
- package/dist/index.cjs +56 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +423 -708
- package/dist/index.d.ts +423 -708
- package/dist/index.js +56 -106
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +56 -106
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.d.cts +318 -564
- package/dist/loader.d.ts +318 -564
- package/dist/loader.js +56 -106
- package/dist/loader.js.map +1 -1
- package/dist/lorebook.cjs +5 -5
- package/dist/lorebook.cjs.map +1 -1
- package/dist/lorebook.d.cts +381 -674
- package/dist/lorebook.d.ts +381 -674
- package/dist/lorebook.js +5 -5
- package/dist/lorebook.js.map +1 -1
- package/dist/normalizer.cjs +23 -33
- package/dist/normalizer.cjs.map +1 -1
- package/dist/normalizer.d.cts +560 -896
- package/dist/normalizer.d.ts +560 -896
- package/dist/normalizer.js +23 -33
- package/dist/normalizer.js.map +1 -1
- package/dist/png.cjs +22 -27
- package/dist/png.cjs.map +1 -1
- package/dist/png.d.cts +312 -512
- package/dist/png.d.ts +312 -512
- package/dist/png.js +22 -27
- package/dist/png.js.map +1 -1
- package/dist/schemas.cjs +26 -41
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +899 -1447
- package/dist/schemas.d.ts +899 -1447
- package/dist/schemas.js +26 -41
- package/dist/schemas.js.map +1 -1
- package/dist/voxta.cjs +25 -48
- package/dist/voxta.cjs.map +1 -1
- package/dist/voxta.d.cts +318 -564
- package/dist/voxta.d.ts +318 -564
- package/dist/voxta.js +25 -48
- package/dist/voxta.js.map +1 -1
- package/package.json +4 -4
package/dist/app-framework.cjs
CHANGED
|
@@ -68,19 +68,16 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
|
68
68
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
69
69
|
var import_react3 = require("react");
|
|
70
70
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
71
|
+
var import_react4 = require("react");
|
|
71
72
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
73
|
+
var import_react5 = require("react");
|
|
72
74
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
75
|
+
var import_react6 = require("react");
|
|
73
76
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
74
|
-
var import_react4 = require("react");
|
|
75
77
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
76
|
-
var import_react5 = require("react");
|
|
77
78
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
78
|
-
var import_react6 = require("react");
|
|
79
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
80
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
81
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
82
79
|
var import_react7 = require("react");
|
|
83
|
-
var
|
|
80
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
84
81
|
var noopServices = {
|
|
85
82
|
toast: {
|
|
86
83
|
success: () => {
|
|
@@ -355,25 +352,20 @@ function analyzeField(name, zodType) {
|
|
|
355
352
|
let isNullable = false;
|
|
356
353
|
let defaultValue;
|
|
357
354
|
const description = getDescription(zodType);
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
unwrapping = true;
|
|
373
|
-
} else if (currentType instanceof import_zod3.z.ZodEffects) {
|
|
374
|
-
currentType = currentType._def.schema;
|
|
375
|
-
unwrapping = true;
|
|
376
|
-
}
|
|
355
|
+
if (currentType instanceof import_zod3.z.ZodOptional) {
|
|
356
|
+
isOptional = true;
|
|
357
|
+
currentType = currentType.unwrap();
|
|
358
|
+
}
|
|
359
|
+
if (currentType instanceof import_zod3.z.ZodNullable) {
|
|
360
|
+
isNullable = true;
|
|
361
|
+
currentType = currentType.unwrap();
|
|
362
|
+
}
|
|
363
|
+
if (currentType instanceof import_zod3.z.ZodDefault) {
|
|
364
|
+
defaultValue = currentType._def.defaultValue();
|
|
365
|
+
currentType = currentType._def.innerType;
|
|
366
|
+
}
|
|
367
|
+
if (currentType instanceof import_zod3.z.ZodEffects) {
|
|
368
|
+
currentType = currentType._def.schema;
|
|
377
369
|
}
|
|
378
370
|
if (currentType instanceof import_zod3.z.ZodUnion) {
|
|
379
371
|
const options = currentType._def.options;
|
|
@@ -978,7 +970,7 @@ function SearchableSelect({
|
|
|
978
970
|
type: "button",
|
|
979
971
|
id,
|
|
980
972
|
onClick: handleOpen,
|
|
981
|
-
disabled
|
|
973
|
+
disabled,
|
|
982
974
|
"aria-haspopup": "listbox",
|
|
983
975
|
"aria-expanded": isOpen,
|
|
984
976
|
"aria-labelledby": `${id}-label`,
|
|
@@ -1036,191 +1028,6 @@ function SearchableSelect({
|
|
|
1036
1028
|
}
|
|
1037
1029
|
);
|
|
1038
1030
|
}
|
|
1039
|
-
function RadioGroup({
|
|
1040
|
-
value,
|
|
1041
|
-
onChange,
|
|
1042
|
-
name,
|
|
1043
|
-
label,
|
|
1044
|
-
error,
|
|
1045
|
-
disabled,
|
|
1046
|
-
required,
|
|
1047
|
-
hint
|
|
1048
|
-
}) {
|
|
1049
|
-
const id = `field-${name}`;
|
|
1050
|
-
const errorId = `${id}-error`;
|
|
1051
|
-
const helperId = `${id}-helper`;
|
|
1052
|
-
const hasError = Boolean(error);
|
|
1053
|
-
const hasHelper = Boolean(hint?.helperText);
|
|
1054
|
-
const options = hint?.options ?? [];
|
|
1055
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: hint?.className, "data-field": name, "data-error": hasError, children: [
|
|
1056
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("fieldset", { "data-radio-group": true, children: [
|
|
1057
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("legend", { "data-radio-legend": true, children: [
|
|
1058
|
-
label,
|
|
1059
|
-
required && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", "data-required": true, children: "*" })
|
|
1060
|
-
] }),
|
|
1061
|
-
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { id: helperId, "data-helper": true, children: hint?.helperText }),
|
|
1062
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-radio-options": true, role: "radiogroup", "aria-required": required, children: options.map((opt, index) => {
|
|
1063
|
-
const optionId = `${id}-${index}`;
|
|
1064
|
-
const isChecked = value === opt.value;
|
|
1065
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1066
|
-
"label",
|
|
1067
|
-
{
|
|
1068
|
-
htmlFor: optionId,
|
|
1069
|
-
"data-radio-option": true,
|
|
1070
|
-
"data-checked": isChecked,
|
|
1071
|
-
children: [
|
|
1072
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1073
|
-
"input",
|
|
1074
|
-
{
|
|
1075
|
-
id: optionId,
|
|
1076
|
-
type: "radio",
|
|
1077
|
-
name,
|
|
1078
|
-
value: opt.value,
|
|
1079
|
-
checked: isChecked,
|
|
1080
|
-
onChange: (e) => onChange(e.target.value),
|
|
1081
|
-
disabled: disabled || hint?.readOnly,
|
|
1082
|
-
"aria-invalid": hasError,
|
|
1083
|
-
"aria-describedby": [hasError && errorId, hasHelper && helperId].filter(Boolean).join(" ") || void 0
|
|
1084
|
-
}
|
|
1085
|
-
),
|
|
1086
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "data-radio-label": true, children: opt.label })
|
|
1087
|
-
]
|
|
1088
|
-
},
|
|
1089
|
-
opt.value
|
|
1090
|
-
);
|
|
1091
|
-
}) })
|
|
1092
|
-
] }),
|
|
1093
|
-
hasError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { id: errorId, role: "alert", "data-error-message": true, children: error })
|
|
1094
|
-
] });
|
|
1095
|
-
}
|
|
1096
|
-
function Slider({
|
|
1097
|
-
value,
|
|
1098
|
-
onChange,
|
|
1099
|
-
name,
|
|
1100
|
-
label,
|
|
1101
|
-
error,
|
|
1102
|
-
disabled,
|
|
1103
|
-
required,
|
|
1104
|
-
hint
|
|
1105
|
-
}) {
|
|
1106
|
-
const id = `field-${name}`;
|
|
1107
|
-
const errorId = `${id}-error`;
|
|
1108
|
-
const helperId = `${id}-helper`;
|
|
1109
|
-
const valueId = `${id}-value`;
|
|
1110
|
-
const hasError = Boolean(error);
|
|
1111
|
-
const hasHelper = Boolean(hint?.helperText);
|
|
1112
|
-
const min = hint?.min ?? 0;
|
|
1113
|
-
const max = hint?.max ?? 100;
|
|
1114
|
-
const step = hint?.step ?? 1;
|
|
1115
|
-
const currentValue = value ?? min;
|
|
1116
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: hint?.className, "data-field": name, "data-error": hasError, children: [
|
|
1117
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { htmlFor: id, "data-slider-label": true, children: [
|
|
1118
|
-
label,
|
|
1119
|
-
required && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "aria-hidden": "true", "data-required": true, children: "*" })
|
|
1120
|
-
] }),
|
|
1121
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slider-container": true, children: [
|
|
1122
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1123
|
-
"input",
|
|
1124
|
-
{
|
|
1125
|
-
id,
|
|
1126
|
-
type: "range",
|
|
1127
|
-
name,
|
|
1128
|
-
value: currentValue,
|
|
1129
|
-
min,
|
|
1130
|
-
max,
|
|
1131
|
-
step,
|
|
1132
|
-
onChange: (e) => onChange(Number(e.target.value)),
|
|
1133
|
-
disabled: disabled || hint?.readOnly,
|
|
1134
|
-
"aria-invalid": hasError,
|
|
1135
|
-
"aria-valuemin": min,
|
|
1136
|
-
"aria-valuemax": max,
|
|
1137
|
-
"aria-valuenow": currentValue,
|
|
1138
|
-
"aria-describedby": [valueId, hasError && errorId, hasHelper && helperId].filter(Boolean).join(" ") || void 0,
|
|
1139
|
-
"aria-required": required
|
|
1140
|
-
}
|
|
1141
|
-
),
|
|
1142
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("output", { id: valueId, htmlFor: id, "data-slider-value": true, children: currentValue })
|
|
1143
|
-
] }),
|
|
1144
|
-
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { id: helperId, "data-helper": true, children: hint?.helperText }),
|
|
1145
|
-
hasError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { id: errorId, role: "alert", "data-error-message": true, children: error })
|
|
1146
|
-
] });
|
|
1147
|
-
}
|
|
1148
|
-
function ColorPicker({
|
|
1149
|
-
value,
|
|
1150
|
-
onChange,
|
|
1151
|
-
name,
|
|
1152
|
-
label,
|
|
1153
|
-
error,
|
|
1154
|
-
disabled,
|
|
1155
|
-
required,
|
|
1156
|
-
hint
|
|
1157
|
-
}) {
|
|
1158
|
-
const id = `field-${name}`;
|
|
1159
|
-
const textId = `${id}-text`;
|
|
1160
|
-
const errorId = `${id}-error`;
|
|
1161
|
-
const helperId = `${id}-helper`;
|
|
1162
|
-
const hasError = Boolean(error);
|
|
1163
|
-
const hasHelper = Boolean(hint?.helperText);
|
|
1164
|
-
const currentValue = value || "#000000";
|
|
1165
|
-
const normalizeHex = (hex) => {
|
|
1166
|
-
let clean = hex.replace(/^#/, "");
|
|
1167
|
-
if (clean.length === 3) {
|
|
1168
|
-
clean = clean.split("").map((c) => c + c).join("");
|
|
1169
|
-
}
|
|
1170
|
-
if (/^[0-9a-fA-F]{6}$/.test(clean)) {
|
|
1171
|
-
return `#${clean.toLowerCase()}`;
|
|
1172
|
-
}
|
|
1173
|
-
return currentValue;
|
|
1174
|
-
};
|
|
1175
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: hint?.className, "data-field": name, "data-error": hasError, children: [
|
|
1176
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: id, "data-color-label": true, children: [
|
|
1177
|
-
label,
|
|
1178
|
-
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": "true", "data-required": true, children: "*" })
|
|
1179
|
-
] }),
|
|
1180
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { "data-color-container": true, children: [
|
|
1181
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1182
|
-
"input",
|
|
1183
|
-
{
|
|
1184
|
-
id,
|
|
1185
|
-
type: "color",
|
|
1186
|
-
name,
|
|
1187
|
-
value: currentValue,
|
|
1188
|
-
onChange: (e) => onChange(e.target.value),
|
|
1189
|
-
disabled: disabled || hint?.readOnly,
|
|
1190
|
-
"aria-invalid": hasError,
|
|
1191
|
-
"aria-describedby": [hasError && errorId, hasHelper && helperId].filter(Boolean).join(" ") || void 0,
|
|
1192
|
-
"aria-required": required
|
|
1193
|
-
}
|
|
1194
|
-
),
|
|
1195
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1196
|
-
"input",
|
|
1197
|
-
{
|
|
1198
|
-
id: textId,
|
|
1199
|
-
type: "text",
|
|
1200
|
-
value: currentValue,
|
|
1201
|
-
onChange: (e) => {
|
|
1202
|
-
const normalized = normalizeHex(e.target.value);
|
|
1203
|
-
onChange(normalized);
|
|
1204
|
-
},
|
|
1205
|
-
onBlur: (e) => {
|
|
1206
|
-
const normalized = normalizeHex(e.target.value);
|
|
1207
|
-
if (normalized !== e.target.value) {
|
|
1208
|
-
onChange(normalized);
|
|
1209
|
-
}
|
|
1210
|
-
},
|
|
1211
|
-
disabled: disabled || hint?.readOnly,
|
|
1212
|
-
placeholder: "#000000",
|
|
1213
|
-
pattern: "^#[0-9a-fA-F]{6}$",
|
|
1214
|
-
maxLength: 7,
|
|
1215
|
-
"data-color-text": true,
|
|
1216
|
-
"aria-label": `${label} hex value`
|
|
1217
|
-
}
|
|
1218
|
-
)
|
|
1219
|
-
] }),
|
|
1220
|
-
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { id: helperId, "data-helper": true, children: hint?.helperText }),
|
|
1221
|
-
hasError && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { id: errorId, role: "alert", "data-error-message": true, children: error })
|
|
1222
|
-
] });
|
|
1223
|
-
}
|
|
1224
1031
|
function TagInput({
|
|
1225
1032
|
value,
|
|
1226
1033
|
onChange,
|
|
@@ -1270,15 +1077,15 @@ function TagInput({
|
|
|
1270
1077
|
addTag(inputValue);
|
|
1271
1078
|
}
|
|
1272
1079
|
}, [inputValue, addTag]);
|
|
1273
|
-
return /* @__PURE__ */ (0,
|
|
1274
|
-
label && /* @__PURE__ */ (0,
|
|
1080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: hint?.className, "data-field": name, "data-error": hasError, children: [
|
|
1081
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { htmlFor: id, children: [
|
|
1275
1082
|
label,
|
|
1276
|
-
required && /* @__PURE__ */ (0,
|
|
1083
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", "data-required": true, children: "*" })
|
|
1277
1084
|
] }),
|
|
1278
|
-
/* @__PURE__ */ (0,
|
|
1279
|
-
tags.map((tag, index) => /* @__PURE__ */ (0,
|
|
1085
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-tag-container": true, children: [
|
|
1086
|
+
tags.map((tag, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { "data-tag": true, children: [
|
|
1280
1087
|
tag,
|
|
1281
|
-
!disabled && !hint?.readOnly && /* @__PURE__ */ (0,
|
|
1088
|
+
!disabled && !hint?.readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1282
1089
|
"button",
|
|
1283
1090
|
{
|
|
1284
1091
|
type: "button",
|
|
@@ -1289,7 +1096,7 @@ function TagInput({
|
|
|
1289
1096
|
}
|
|
1290
1097
|
)
|
|
1291
1098
|
] }, `${tag}-${index}`)),
|
|
1292
|
-
/* @__PURE__ */ (0,
|
|
1099
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1293
1100
|
"input",
|
|
1294
1101
|
{
|
|
1295
1102
|
id,
|
|
@@ -1307,8 +1114,8 @@ function TagInput({
|
|
|
1307
1114
|
}
|
|
1308
1115
|
)
|
|
1309
1116
|
] }),
|
|
1310
|
-
hasHelper && /* @__PURE__ */ (0,
|
|
1311
|
-
hasError && /* @__PURE__ */ (0,
|
|
1117
|
+
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { id: helperId, "data-helper": true, children: hint?.helperText }),
|
|
1118
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { id: errorId, role: "alert", "data-error-message": true, children: error })
|
|
1312
1119
|
] });
|
|
1313
1120
|
}
|
|
1314
1121
|
function SecretInput({
|
|
@@ -1330,13 +1137,13 @@ function SecretInput({
|
|
|
1330
1137
|
const toggleVisibility = (0, import_react5.useCallback)(() => {
|
|
1331
1138
|
setShowValue((prev) => !prev);
|
|
1332
1139
|
}, []);
|
|
1333
|
-
return /* @__PURE__ */ (0,
|
|
1334
|
-
label && /* @__PURE__ */ (0,
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: hint?.className, "data-field": name, "data-error": hasError, children: [
|
|
1141
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { htmlFor: id, children: [
|
|
1335
1142
|
label,
|
|
1336
|
-
required && /* @__PURE__ */ (0,
|
|
1143
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "aria-hidden": "true", "data-required": true, children: "*" })
|
|
1337
1144
|
] }),
|
|
1338
|
-
/* @__PURE__ */ (0,
|
|
1339
|
-
/* @__PURE__ */ (0,
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-secret-container": true, children: [
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1340
1147
|
"input",
|
|
1341
1148
|
{
|
|
1342
1149
|
id,
|
|
@@ -1354,7 +1161,7 @@ function SecretInput({
|
|
|
1354
1161
|
"data-secret-input": true
|
|
1355
1162
|
}
|
|
1356
1163
|
),
|
|
1357
|
-
/* @__PURE__ */ (0,
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1358
1165
|
"button",
|
|
1359
1166
|
{
|
|
1360
1167
|
type: "button",
|
|
@@ -1366,8 +1173,8 @@ function SecretInput({
|
|
|
1366
1173
|
}
|
|
1367
1174
|
)
|
|
1368
1175
|
] }),
|
|
1369
|
-
hasHelper && /* @__PURE__ */ (0,
|
|
1370
|
-
hasError && /* @__PURE__ */ (0,
|
|
1176
|
+
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { id: helperId, "data-helper": true, children: hint?.helperText }),
|
|
1177
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { id: errorId, role: "alert", "data-error-message": true, children: error })
|
|
1371
1178
|
] });
|
|
1372
1179
|
}
|
|
1373
1180
|
function FileUpload({
|
|
@@ -1504,12 +1311,12 @@ function FileUpload({
|
|
|
1504
1311
|
);
|
|
1505
1312
|
const displayError = error ?? localError;
|
|
1506
1313
|
const files = multiple ? Array.isArray(value) ? value : [] : value instanceof File ? [value] : [];
|
|
1507
|
-
return /* @__PURE__ */ (0,
|
|
1508
|
-
label && /* @__PURE__ */ (0,
|
|
1314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: hint?.className, "data-field": name, "data-error": Boolean(displayError), children: [
|
|
1315
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: id, children: [
|
|
1509
1316
|
label,
|
|
1510
|
-
required && /* @__PURE__ */ (0,
|
|
1317
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": "true", "data-required": true, children: "*" })
|
|
1511
1318
|
] }),
|
|
1512
|
-
/* @__PURE__ */ (0,
|
|
1319
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1513
1320
|
"div",
|
|
1514
1321
|
{
|
|
1515
1322
|
"data-file-dropzone": true,
|
|
@@ -1520,10 +1327,10 @@ function FileUpload({
|
|
|
1520
1327
|
onDrop: handleDrop,
|
|
1521
1328
|
onClick: handleClick,
|
|
1522
1329
|
role: "button",
|
|
1523
|
-
tabIndex: disabled
|
|
1330
|
+
tabIndex: disabled ? -1 : 0,
|
|
1524
1331
|
"aria-describedby": [Boolean(displayError) && errorId, hasHelper && helperId].filter(Boolean).join(" ") || void 0,
|
|
1525
1332
|
children: [
|
|
1526
|
-
/* @__PURE__ */ (0,
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1527
1334
|
"input",
|
|
1528
1335
|
{
|
|
1529
1336
|
ref: inputRef,
|
|
@@ -1532,21 +1339,21 @@ function FileUpload({
|
|
|
1532
1339
|
name,
|
|
1533
1340
|
accept,
|
|
1534
1341
|
multiple,
|
|
1535
|
-
disabled
|
|
1342
|
+
disabled,
|
|
1536
1343
|
onChange: handleChange,
|
|
1537
1344
|
"aria-invalid": Boolean(displayError),
|
|
1538
1345
|
"aria-required": required,
|
|
1539
1346
|
"data-file-input": true
|
|
1540
1347
|
}
|
|
1541
1348
|
),
|
|
1542
|
-
files.length === 0 ? /* @__PURE__ */ (0,
|
|
1543
|
-
/* @__PURE__ */ (0,
|
|
1544
|
-
/* @__PURE__ */ (0,
|
|
1349
|
+
files.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { "data-file-placeholder": true, children: hint?.placeholder ?? (isDragging ? "Drop files here..." : "Click or drag files to upload") }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { "data-file-list": true, children: files.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { "data-file-item": true, children: [
|
|
1350
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "data-file-name": true, children: file.name }),
|
|
1351
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { "data-file-size": true, children: [
|
|
1545
1352
|
"(",
|
|
1546
1353
|
formatFileSize(file.size),
|
|
1547
1354
|
")"
|
|
1548
1355
|
] }),
|
|
1549
|
-
!disabled && !hint?.readOnly && /* @__PURE__ */ (0,
|
|
1356
|
+
!disabled && !hint?.readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1550
1357
|
"button",
|
|
1551
1358
|
{
|
|
1552
1359
|
type: "button",
|
|
@@ -1563,8 +1370,8 @@ function FileUpload({
|
|
|
1563
1370
|
]
|
|
1564
1371
|
}
|
|
1565
1372
|
),
|
|
1566
|
-
hasHelper && /* @__PURE__ */ (0,
|
|
1567
|
-
displayError && /* @__PURE__ */ (0,
|
|
1373
|
+
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { id: helperId, "data-helper": true, children: hint?.helperText }),
|
|
1374
|
+
displayError && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { id: errorId, role: "alert", "data-error-message": true, children: displayError })
|
|
1568
1375
|
] });
|
|
1569
1376
|
}
|
|
1570
1377
|
function formatFileSize(bytes) {
|
|
@@ -1580,15 +1387,15 @@ var BUILTIN_WIDGETS = {
|
|
|
1580
1387
|
checkbox: Switch,
|
|
1581
1388
|
select: Select,
|
|
1582
1389
|
"searchable-select": SearchableSelect,
|
|
1583
|
-
radio:
|
|
1584
|
-
|
|
1390
|
+
radio: Select,
|
|
1391
|
+
// Could be RadioGroup
|
|
1585
1392
|
password: SecretInput,
|
|
1586
1393
|
"tag-input": TagInput,
|
|
1587
1394
|
"file-upload": FileUpload,
|
|
1588
|
-
slider:
|
|
1589
|
-
|
|
1590
|
-
"color-picker":
|
|
1591
|
-
|
|
1395
|
+
slider: NumberInput,
|
|
1396
|
+
// Could be Slider widget
|
|
1397
|
+
"color-picker": TextInput
|
|
1398
|
+
// Could be ColorPicker widget
|
|
1592
1399
|
};
|
|
1593
1400
|
var TYPE_TO_WIDGET = {
|
|
1594
1401
|
ZodString: TextInput,
|
|
@@ -1611,16 +1418,16 @@ function FieldRenderer({
|
|
|
1611
1418
|
if (fieldInfo.typeName === "ZodObject" && fieldInfo.nestedFields && renderNestedField) {
|
|
1612
1419
|
const nestedFields = Array.from(fieldInfo.nestedFields.values());
|
|
1613
1420
|
const fieldBaseName2 = fieldInfo.name.split(".").pop() ?? fieldInfo.name;
|
|
1614
|
-
return /* @__PURE__ */ (0,
|
|
1615
|
-
/* @__PURE__ */ (0,
|
|
1616
|
-
hint?.helperText && /* @__PURE__ */ (0,
|
|
1617
|
-
/* @__PURE__ */ (0,
|
|
1421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "data-nested-object": true, "data-field": fieldInfo.name, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("fieldset", { "data-nested-fieldset": true, children: [
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("legend", { "data-nested-legend": true, children: hint?.label ?? fieldInfo.description ?? formatLabel(fieldBaseName2) }),
|
|
1423
|
+
hint?.helperText && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { "data-helper": true, children: hint.helperText }),
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "data-nested-fields": true, children: nestedFields.map((nestedInfo) => renderNestedField(nestedInfo)) })
|
|
1618
1425
|
] }) });
|
|
1619
1426
|
}
|
|
1620
1427
|
let Widget;
|
|
1621
1428
|
if (hint?.widget) {
|
|
1622
1429
|
if (typeof hint.widget === "string") {
|
|
1623
|
-
Widget =
|
|
1430
|
+
Widget = BUILTIN_WIDGETS[hint.widget] ?? widgetRegistry2.getComponent(hint.widget) ?? TextInput;
|
|
1624
1431
|
} else {
|
|
1625
1432
|
Widget = hint.widget;
|
|
1626
1433
|
}
|
|
@@ -1655,30 +1462,11 @@ function FieldRenderer({
|
|
|
1655
1462
|
max: hint?.max ?? fieldInfo.constraints?.max ?? fieldInfo.constraints?.maxLength
|
|
1656
1463
|
}
|
|
1657
1464
|
};
|
|
1658
|
-
return /* @__PURE__ */ (0,
|
|
1465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Widget, { ...props });
|
|
1659
1466
|
}
|
|
1660
1467
|
function formatLabel(name) {
|
|
1661
1468
|
return name.replace(/([A-Z])/g, " $1").replace(/_/g, " ").replace(/^\w/, (c) => c.toUpperCase()).trim();
|
|
1662
1469
|
}
|
|
1663
|
-
var HINT_KEYS = /* @__PURE__ */ new Set([
|
|
1664
|
-
"widget",
|
|
1665
|
-
"label",
|
|
1666
|
-
"placeholder",
|
|
1667
|
-
"helperText",
|
|
1668
|
-
"hidden",
|
|
1669
|
-
"readOnly",
|
|
1670
|
-
"className",
|
|
1671
|
-
"condition",
|
|
1672
|
-
"group",
|
|
1673
|
-
"rows",
|
|
1674
|
-
"accept",
|
|
1675
|
-
"multiple",
|
|
1676
|
-
"maxSize",
|
|
1677
|
-
"options",
|
|
1678
|
-
"searchable",
|
|
1679
|
-
"searchPlaceholder",
|
|
1680
|
-
"noResultsText"
|
|
1681
|
-
]);
|
|
1682
1470
|
function AutoForm({
|
|
1683
1471
|
schema,
|
|
1684
1472
|
values,
|
|
@@ -1738,9 +1526,7 @@ function AutoForm({
|
|
|
1738
1526
|
fields.add(condition.field);
|
|
1739
1527
|
}
|
|
1740
1528
|
}
|
|
1741
|
-
|
|
1742
|
-
const isHintObject = hintKeys.length > 0 && hintKeys.every((k) => HINT_KEYS.has(k));
|
|
1743
|
-
if (!isHintObject) {
|
|
1529
|
+
if (!("widget" in hint) && !("label" in hint) && !("condition" in hint)) {
|
|
1744
1530
|
extractConditionFields(hint, prefix ? `${prefix}.${key}` : key);
|
|
1745
1531
|
}
|
|
1746
1532
|
}
|
|
@@ -1792,10 +1578,28 @@ function AutoForm({
|
|
|
1792
1578
|
});
|
|
1793
1579
|
return () => subscription.unsubscribe();
|
|
1794
1580
|
}, [watch]);
|
|
1581
|
+
const HINT_KEYS = /* @__PURE__ */ new Set([
|
|
1582
|
+
"widget",
|
|
1583
|
+
"label",
|
|
1584
|
+
"placeholder",
|
|
1585
|
+
"helperText",
|
|
1586
|
+
"hidden",
|
|
1587
|
+
"readOnly",
|
|
1588
|
+
"className",
|
|
1589
|
+
"condition",
|
|
1590
|
+
"group",
|
|
1591
|
+
"rows",
|
|
1592
|
+
"accept",
|
|
1593
|
+
"multiple",
|
|
1594
|
+
"maxSize",
|
|
1595
|
+
"options",
|
|
1596
|
+
"searchable",
|
|
1597
|
+
"searchPlaceholder",
|
|
1598
|
+
"noResultsText"
|
|
1599
|
+
]);
|
|
1795
1600
|
const isFieldUIHint = (0, import_react.useCallback)((obj) => {
|
|
1796
1601
|
if (!obj || typeof obj !== "object") return false;
|
|
1797
|
-
|
|
1798
|
-
return keys.length > 0 && keys.every((key) => HINT_KEYS.has(key));
|
|
1602
|
+
return Object.keys(obj).some((key) => HINT_KEYS.has(key));
|
|
1799
1603
|
}, []);
|
|
1800
1604
|
const getHint = (0, import_react.useCallback)(
|
|
1801
1605
|
(fieldName) => {
|
|
@@ -1853,12 +1657,12 @@ function AutoForm({
|
|
|
1853
1657
|
const hint = getHint(fieldInfo.name);
|
|
1854
1658
|
if (hint?.hidden) return null;
|
|
1855
1659
|
if (!isConditionMet(hint?.condition)) return null;
|
|
1856
|
-
return /* @__PURE__ */ (0,
|
|
1660
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1857
1661
|
import_react_hook_form.Controller,
|
|
1858
1662
|
{
|
|
1859
1663
|
name: fieldInfo.name,
|
|
1860
1664
|
control,
|
|
1861
|
-
render: ({ field, fieldState }) => /* @__PURE__ */ (0,
|
|
1665
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1862
1666
|
FieldRenderer,
|
|
1863
1667
|
{
|
|
1864
1668
|
fieldInfo,
|
|
@@ -1903,7 +1707,7 @@ function AutoForm({
|
|
|
1903
1707
|
},
|
|
1904
1708
|
[flatFieldInfoMap, getField, getHint]
|
|
1905
1709
|
);
|
|
1906
|
-
const submitButton = withSubmit ? /* @__PURE__ */ (0,
|
|
1710
|
+
const submitButton = withSubmit ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1907
1711
|
"button",
|
|
1908
1712
|
{
|
|
1909
1713
|
type: "submit",
|
|
@@ -1912,7 +1716,7 @@ function AutoForm({
|
|
|
1912
1716
|
children: formState.isSubmitting ? "Submitting..." : submitText
|
|
1913
1717
|
}
|
|
1914
1718
|
) : null;
|
|
1915
|
-
const formContent = /* @__PURE__ */ (0,
|
|
1719
|
+
const formContent = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_hook_form.FormProvider, { ...methods, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("form", { onSubmit: onFormSubmit, className, "data-autoform": true, children: children ? children({
|
|
1916
1720
|
fields: renderedFields,
|
|
1917
1721
|
submit: submitButton,
|
|
1918
1722
|
formState: {
|
|
@@ -1922,12 +1726,12 @@ function AutoForm({
|
|
|
1922
1726
|
},
|
|
1923
1727
|
getField,
|
|
1924
1728
|
getFieldsByGroup
|
|
1925
|
-
}) : /* @__PURE__ */ (0,
|
|
1729
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
1926
1730
|
renderedFields,
|
|
1927
1731
|
submitButton
|
|
1928
1732
|
] }) }) });
|
|
1929
1733
|
if (widgetRegistry2) {
|
|
1930
|
-
return /* @__PURE__ */ (0,
|
|
1734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(WidgetRegistryContext.Provider, { value: widgetRegistry2, children: formContent });
|
|
1931
1735
|
}
|
|
1932
1736
|
return formContent;
|
|
1933
1737
|
}
|
|
@@ -2013,7 +1817,7 @@ function FieldGroup({
|
|
|
2013
1817
|
}, [collapsible]);
|
|
2014
1818
|
const headerId = `fieldgroup-${title.toLowerCase().replace(/\s+/g, "-")}`;
|
|
2015
1819
|
const contentId = `${headerId}-content`;
|
|
2016
|
-
return /* @__PURE__ */ (0,
|
|
1820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2017
1821
|
"fieldset",
|
|
2018
1822
|
{
|
|
2019
1823
|
className,
|
|
@@ -2021,7 +1825,7 @@ function FieldGroup({
|
|
|
2021
1825
|
"data-collapsible": collapsible,
|
|
2022
1826
|
"data-collapsed": isCollapsed,
|
|
2023
1827
|
children: [
|
|
2024
|
-
collapsible ? /* @__PURE__ */ (0,
|
|
1828
|
+
collapsible ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("legend", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2025
1829
|
"button",
|
|
2026
1830
|
{
|
|
2027
1831
|
type: "button",
|
|
@@ -2030,13 +1834,13 @@ function FieldGroup({
|
|
|
2030
1834
|
"aria-controls": contentId,
|
|
2031
1835
|
"data-fieldgroup-toggle": true,
|
|
2032
1836
|
children: [
|
|
2033
|
-
/* @__PURE__ */ (0,
|
|
2034
|
-
/* @__PURE__ */ (0,
|
|
1837
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { "data-fieldgroup-arrow": true, "aria-hidden": "true", children: isCollapsed ? "\u25B6" : "\u25BC" }),
|
|
1838
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { id: headerId, "data-fieldgroup-title": true, children: title })
|
|
2035
1839
|
]
|
|
2036
1840
|
}
|
|
2037
|
-
) }) : /* @__PURE__ */ (0,
|
|
2038
|
-
description && /* @__PURE__ */ (0,
|
|
2039
|
-
/* @__PURE__ */ (0,
|
|
1841
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("legend", { id: headerId, "data-fieldgroup-title": true, children: title }),
|
|
1842
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { "data-fieldgroup-description": true, children: description }),
|
|
1843
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2040
1844
|
"div",
|
|
2041
1845
|
{
|
|
2042
1846
|
id: contentId,
|