@orion-studios/payload-studio 0.6.0-beta.24 → 0.6.0-beta.26
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/admin/client.js +345 -102
- package/dist/admin/client.mjs +337 -94
- package/dist/studio-pages/client.js +26 -4
- package/dist/studio-pages/client.mjs +26 -4
- package/package.json +1 -1
package/dist/admin/client.js
CHANGED
|
@@ -749,7 +749,7 @@ var init_OrionBlocksFieldImpl = __esm({
|
|
|
749
749
|
const schemaPath = schemaPathFromProps ?? name;
|
|
750
750
|
const minRows = minRowsProp ?? (required ? 1 : 0);
|
|
751
751
|
const { setDocFieldPreferences } = (0, import_DocumentInfo.useDocumentInfo)();
|
|
752
|
-
const { addFieldRow, dispatchFields, getFields, moveFieldRow, removeFieldRow, replaceState, setModified } = (0, import_Form.useForm)();
|
|
752
|
+
const { addFieldRow, dispatchFields, getFields: getFields2, moveFieldRow, removeFieldRow, replaceState, setModified } = (0, import_Form.useForm)();
|
|
753
753
|
const { code: locale } = (0, import_Locale.useLocale)();
|
|
754
754
|
const configContext = (0, import_Config.useConfig)();
|
|
755
755
|
const config = configContext?.config ?? {};
|
|
@@ -911,7 +911,7 @@ var init_OrionBlocksFieldImpl = __esm({
|
|
|
911
911
|
(rowIndex) => {
|
|
912
912
|
const result = clipboardCopy({
|
|
913
913
|
getDataToCopy: () => reduceFormStateByPath({
|
|
914
|
-
formState:
|
|
914
|
+
formState: getFields2(),
|
|
915
915
|
path: safePath,
|
|
916
916
|
rowIndex
|
|
917
917
|
}),
|
|
@@ -929,13 +929,13 @@ var init_OrionBlocksFieldImpl = __esm({
|
|
|
929
929
|
import_sonner.toast.success(t("general:copied"));
|
|
930
930
|
}
|
|
931
931
|
},
|
|
932
|
-
[clientBlocks,
|
|
932
|
+
[clientBlocks, getFields2, safePath, t, type]
|
|
933
933
|
);
|
|
934
934
|
const pasteRow = (0, import_react10.useCallback)(
|
|
935
935
|
(rowIndex) => {
|
|
936
936
|
const result = clipboardPaste({
|
|
937
937
|
onPaste: (dataFromClipboard) => {
|
|
938
|
-
const formState =
|
|
938
|
+
const formState = getFields2();
|
|
939
939
|
const newState = mergeFormStateFromClipboard({
|
|
940
940
|
dataFromClipboard,
|
|
941
941
|
formState,
|
|
@@ -952,11 +952,11 @@ var init_OrionBlocksFieldImpl = __esm({
|
|
|
952
952
|
import_sonner.toast.error(result);
|
|
953
953
|
}
|
|
954
954
|
},
|
|
955
|
-
[clientBlocks,
|
|
955
|
+
[clientBlocks, getFields2, replaceState, safePath, setModified, t]
|
|
956
956
|
);
|
|
957
957
|
const pasteBlocks = (0, import_react10.useCallback)(
|
|
958
958
|
(dataFromClipboard) => {
|
|
959
|
-
const formState =
|
|
959
|
+
const formState = getFields2();
|
|
960
960
|
const newState = mergeFormStateFromClipboard({
|
|
961
961
|
dataFromClipboard,
|
|
962
962
|
formState,
|
|
@@ -965,7 +965,7 @@ var init_OrionBlocksFieldImpl = __esm({
|
|
|
965
965
|
replaceState(newState);
|
|
966
966
|
setModified(true);
|
|
967
967
|
},
|
|
968
|
-
[
|
|
968
|
+
[getFields2, replaceState, safePath, setModified]
|
|
969
969
|
);
|
|
970
970
|
const hasMaxRows = Boolean(maxRows && rows.length >= maxRows);
|
|
971
971
|
const fieldErrorCount = errorPaths.length;
|
|
@@ -1042,7 +1042,7 @@ var init_OrionBlocksFieldImpl = __esm({
|
|
|
1042
1042
|
className: `${baseClass}__header-action`,
|
|
1043
1043
|
disabled,
|
|
1044
1044
|
getDataToCopy: () => reduceFormStateByPath({
|
|
1045
|
-
formState:
|
|
1045
|
+
formState: getFields2(),
|
|
1046
1046
|
path: safePath
|
|
1047
1047
|
}),
|
|
1048
1048
|
onPaste: pasteBlocks,
|
|
@@ -8258,15 +8258,11 @@ var getFormTitle2 = (value) => {
|
|
|
8258
8258
|
// src/admin/components/studio/AdminStudioFormDetailView.tsx
|
|
8259
8259
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8260
8260
|
var getNonEmptyText = (value, fallback = "") => typeof value === "string" && value.trim().length > 0 ? value : fallback;
|
|
8261
|
-
var
|
|
8261
|
+
var normalizeSteps = (value) => {
|
|
8262
8262
|
if (!Array.isArray(value)) {
|
|
8263
|
-
return
|
|
8264
|
-
}
|
|
8265
|
-
try {
|
|
8266
|
-
return JSON.stringify(value, null, 2);
|
|
8267
|
-
} catch {
|
|
8268
|
-
return "[]";
|
|
8263
|
+
return [];
|
|
8269
8264
|
}
|
|
8265
|
+
return value.map((step) => step && typeof step === "object" && !Array.isArray(step) ? step : {});
|
|
8270
8266
|
};
|
|
8271
8267
|
var toEditorState = (doc) => {
|
|
8272
8268
|
const emails = doc.emails && typeof doc.emails === "object" ? doc.emails : null;
|
|
@@ -8282,7 +8278,7 @@ var toEditorState = (doc) => {
|
|
|
8282
8278
|
sendAdmin: emails?.sendAdmin !== false,
|
|
8283
8279
|
sendConfirmation: emails?.sendConfirmation !== false,
|
|
8284
8280
|
slug: getNonEmptyText(doc.slug),
|
|
8285
|
-
|
|
8281
|
+
steps: normalizeSteps(doc.steps),
|
|
8286
8282
|
submitLabel: getNonEmptyText(doc.submitLabel, "Submit"),
|
|
8287
8283
|
successMessage: getNonEmptyText(doc.successMessage),
|
|
8288
8284
|
title: getNonEmptyText(doc.title, "Untitled Form")
|
|
@@ -8293,25 +8289,54 @@ var checkboxLabelStyle = {
|
|
|
8293
8289
|
display: "flex",
|
|
8294
8290
|
gap: "0.6rem"
|
|
8295
8291
|
};
|
|
8296
|
-
var codeStyle = {
|
|
8297
|
-
background: "color-mix(in srgb, var(--orion-admin-card-bg) 82%, black)",
|
|
8298
|
-
border: "1px solid var(--orion-admin-card-border)",
|
|
8299
|
-
borderRadius: "var(--orion-admin-radius-sm)",
|
|
8300
|
-
color: "var(--orion-admin-text)",
|
|
8301
|
-
fontFamily: "ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, monospace",
|
|
8302
|
-
fontSize: "0.86rem",
|
|
8303
|
-
lineHeight: 1.55,
|
|
8304
|
-
margin: 0,
|
|
8305
|
-
maxHeight: "28rem",
|
|
8306
|
-
overflow: "auto",
|
|
8307
|
-
padding: "0.9rem",
|
|
8308
|
-
whiteSpace: "pre-wrap"
|
|
8309
|
-
};
|
|
8310
8292
|
var sectionGridStyle = {
|
|
8311
8293
|
display: "grid",
|
|
8312
8294
|
gap: "1rem",
|
|
8313
8295
|
gridTemplateColumns: "repeat(auto-fit, minmax(320px, 1fr))"
|
|
8314
8296
|
};
|
|
8297
|
+
var fieldTypeOptions = [
|
|
8298
|
+
"text",
|
|
8299
|
+
"textarea",
|
|
8300
|
+
"email",
|
|
8301
|
+
"phone",
|
|
8302
|
+
"url",
|
|
8303
|
+
"select",
|
|
8304
|
+
"radio",
|
|
8305
|
+
"checkbox",
|
|
8306
|
+
"checkbox-group",
|
|
8307
|
+
"date",
|
|
8308
|
+
"file"
|
|
8309
|
+
];
|
|
8310
|
+
var getFields = (step) => Array.isArray(step.fields) ? step.fields.map(
|
|
8311
|
+
(field) => field && typeof field === "object" && !Array.isArray(field) ? field : {}
|
|
8312
|
+
) : [];
|
|
8313
|
+
var toOptionsText = (value) => Array.isArray(value) ? value.map((entry) => {
|
|
8314
|
+
if (entry && typeof entry === "object" && !Array.isArray(entry)) {
|
|
8315
|
+
const record = entry;
|
|
8316
|
+
const label = typeof record.label === "string" ? record.label : "";
|
|
8317
|
+
const optionValue = typeof record.value === "string" ? record.value : label;
|
|
8318
|
+
return label && optionValue && label !== optionValue ? `${label} | ${optionValue}` : label || optionValue;
|
|
8319
|
+
}
|
|
8320
|
+
return typeof entry === "string" ? entry : "";
|
|
8321
|
+
}).filter(Boolean).join("\n") : "";
|
|
8322
|
+
var fromOptionsText = (value) => value.split("\n").map((entry) => entry.trim()).filter(Boolean).map((entry) => {
|
|
8323
|
+
const [label, optionValue] = entry.split("|").map((part) => part.trim());
|
|
8324
|
+
return {
|
|
8325
|
+
label,
|
|
8326
|
+
value: optionValue || label
|
|
8327
|
+
};
|
|
8328
|
+
});
|
|
8329
|
+
var slugifyFieldName = (value) => value.trim().replace(/[^a-z0-9]+/gi, " ").trim().replace(/\s+([a-z0-9])/gi, (_, char) => char.toUpperCase()).replace(/^./, (char) => char.toLowerCase());
|
|
8330
|
+
var blankField = () => ({
|
|
8331
|
+
label: "New field",
|
|
8332
|
+
name: "newField",
|
|
8333
|
+
required: false,
|
|
8334
|
+
type: "text"
|
|
8335
|
+
});
|
|
8336
|
+
var blankStep = () => ({
|
|
8337
|
+
fields: [blankField()],
|
|
8338
|
+
title: "New step"
|
|
8339
|
+
});
|
|
8315
8340
|
function getFormIDFromPathname(pathname) {
|
|
8316
8341
|
const marker = "/forms/";
|
|
8317
8342
|
const raw = getIDFromPathname(pathname, marker);
|
|
@@ -8404,10 +8429,6 @@ function AdminStudioFormDetailView(props) {
|
|
|
8404
8429
|
setError(null);
|
|
8405
8430
|
setSavedMessage(null);
|
|
8406
8431
|
try {
|
|
8407
|
-
const parsedSteps = JSON.parse(editorState.stepsText);
|
|
8408
|
-
if (!Array.isArray(parsedSteps)) {
|
|
8409
|
-
throw new Error("Structure JSON must be an array of steps.");
|
|
8410
|
-
}
|
|
8411
8432
|
const payload = {
|
|
8412
8433
|
emails: {
|
|
8413
8434
|
adminRecipients: editorState.adminRecipientsText.split("\n").map((value) => value.trim()).filter(Boolean).map((email) => ({ email })),
|
|
@@ -8419,7 +8440,7 @@ function AdminStudioFormDetailView(props) {
|
|
|
8419
8440
|
sendConfirmation: editorState.sendConfirmation
|
|
8420
8441
|
},
|
|
8421
8442
|
slug: editorState.slug.trim(),
|
|
8422
|
-
steps:
|
|
8443
|
+
steps: editorState.steps,
|
|
8423
8444
|
submitLabel: editorState.submitLabel.trim(),
|
|
8424
8445
|
successMessage: editorState.successMessage,
|
|
8425
8446
|
title: editorState.title.trim()
|
|
@@ -8465,8 +8486,33 @@ function AdminStudioFormDetailView(props) {
|
|
|
8465
8486
|
const toneStyle = getFormToneStyle2(slug, title || formID || "form");
|
|
8466
8487
|
const fieldLabels = doc ? buildFieldLabelMap2(doc) : /* @__PURE__ */ new Map();
|
|
8467
8488
|
const latestSubmission = submissions[0];
|
|
8468
|
-
const stepCount =
|
|
8469
|
-
const fieldCount = doc ? getFieldCount2(doc) : 0;
|
|
8489
|
+
const stepCount = editorState?.steps.length || 0;
|
|
8490
|
+
const fieldCount = editorState ? editorState.steps.reduce((count, step) => count + getFields(step).length, 0) : doc ? getFieldCount2(doc) : 0;
|
|
8491
|
+
const updateStep = (stepIndex, patch) => {
|
|
8492
|
+
setEditorState(
|
|
8493
|
+
(current) => current ? {
|
|
8494
|
+
...current,
|
|
8495
|
+
steps: current.steps.map(
|
|
8496
|
+
(step, index) => index === stepIndex ? { ...step, ...patch } : step
|
|
8497
|
+
)
|
|
8498
|
+
} : current
|
|
8499
|
+
);
|
|
8500
|
+
};
|
|
8501
|
+
const updateField = (stepIndex, fieldIndex, patch) => {
|
|
8502
|
+
setEditorState((current) => {
|
|
8503
|
+
if (!current) return current;
|
|
8504
|
+
return {
|
|
8505
|
+
...current,
|
|
8506
|
+
steps: current.steps.map((step, index) => {
|
|
8507
|
+
if (index !== stepIndex) return step;
|
|
8508
|
+
const fields = getFields(step).map(
|
|
8509
|
+
(field, currentFieldIndex) => currentFieldIndex === fieldIndex ? { ...field, ...patch } : field
|
|
8510
|
+
);
|
|
8511
|
+
return { ...step, fields };
|
|
8512
|
+
})
|
|
8513
|
+
};
|
|
8514
|
+
});
|
|
8515
|
+
};
|
|
8470
8516
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(StudioSectionLayout, { navProps: props, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8471
8517
|
AdminPage,
|
|
8472
8518
|
{
|
|
@@ -8545,10 +8591,9 @@ function AdminStudioFormDetailView(props) {
|
|
|
8545
8591
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { style: { display: "grid", gap: "1rem" }, children: [
|
|
8546
8592
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-card", children: [
|
|
8547
8593
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: "Step preview" }),
|
|
8548
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Review the
|
|
8549
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { style: { display: "grid", gap: "0.85rem", marginTop: "1rem" }, children:
|
|
8550
|
-
const
|
|
8551
|
-
const fields = Array.isArray(record?.fields) ? record.fields : [];
|
|
8594
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Review the public workflow as visitors will move through it." }),
|
|
8595
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { style: { display: "grid", gap: "0.85rem", marginTop: "1rem" }, children: editorState.steps.length > 0 ? editorState.steps.map((record, stepIndex) => {
|
|
8596
|
+
const fields = getFields(record);
|
|
8552
8597
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-form", children: [
|
|
8553
8598
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { children: [
|
|
8554
8599
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("strong", { children: [
|
|
@@ -8600,7 +8645,7 @@ function AdminStudioFormDetailView(props) {
|
|
|
8600
8645
|
] }, `step-${stepIndex}`);
|
|
8601
8646
|
}) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-empty-state", children: [
|
|
8602
8647
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: "No steps configured" }),
|
|
8603
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Add at least one step in
|
|
8648
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Add at least one step in Form settings to publish this form." })
|
|
8604
8649
|
] }) })
|
|
8605
8650
|
] }),
|
|
8606
8651
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-card", children: [
|
|
@@ -8782,32 +8827,226 @@ function AdminStudioFormDetailView(props) {
|
|
|
8782
8827
|
] })
|
|
8783
8828
|
] })
|
|
8784
8829
|
] }),
|
|
8785
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("
|
|
8786
|
-
"
|
|
8787
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8788
|
-
|
|
8789
|
-
{
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
),
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8830
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-card", children: [
|
|
8831
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: "Form steps" }),
|
|
8832
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Edit the public workflow with plain labels and field settings." }),
|
|
8833
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { style: { display: "grid", gap: "1rem", marginTop: "1rem" }, children: [
|
|
8834
|
+
editorState.steps.map((step, stepIndex) => {
|
|
8835
|
+
const fields = getFields(step);
|
|
8836
|
+
const title2 = getNonEmptyText(step.title, `Step ${stepIndex + 1}`);
|
|
8837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-form", children: [
|
|
8838
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-inline-actions", style: { justifyContent: "space-between" }, children: [
|
|
8839
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: title2 }),
|
|
8840
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8841
|
+
"button",
|
|
8842
|
+
{
|
|
8843
|
+
className: "orion-admin-action-button orion-admin-action-button--ghost",
|
|
8844
|
+
onClick: () => setEditorState(
|
|
8845
|
+
(current) => current ? {
|
|
8846
|
+
...current,
|
|
8847
|
+
steps: current.steps.filter((_, index) => index !== stepIndex)
|
|
8848
|
+
} : current
|
|
8849
|
+
),
|
|
8850
|
+
type: "button",
|
|
8851
|
+
children: "Remove step"
|
|
8852
|
+
}
|
|
8853
|
+
)
|
|
8854
|
+
] }),
|
|
8855
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
8856
|
+
"Step title",
|
|
8857
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8858
|
+
"input",
|
|
8859
|
+
{
|
|
8860
|
+
onChange: (event) => updateStep(stepIndex, { title: event.target.value }),
|
|
8861
|
+
type: "text",
|
|
8862
|
+
value: getNonEmptyText(step.title)
|
|
8863
|
+
}
|
|
8864
|
+
)
|
|
8865
|
+
] }),
|
|
8866
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
8867
|
+
"Step intro text",
|
|
8868
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8869
|
+
"textarea",
|
|
8870
|
+
{
|
|
8871
|
+
onChange: (event) => updateStep(stepIndex, { subtitle: event.target.value }),
|
|
8872
|
+
rows: 3,
|
|
8873
|
+
value: getNonEmptyText(step.subtitle)
|
|
8874
|
+
}
|
|
8875
|
+
)
|
|
8876
|
+
] }),
|
|
8877
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
8878
|
+
"Next button label",
|
|
8879
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8880
|
+
"input",
|
|
8881
|
+
{
|
|
8882
|
+
onChange: (event) => updateStep(stepIndex, { nextLabel: event.target.value }),
|
|
8883
|
+
placeholder: "Next",
|
|
8884
|
+
type: "text",
|
|
8885
|
+
value: getNonEmptyText(step.nextLabel)
|
|
8886
|
+
}
|
|
8887
|
+
)
|
|
8888
|
+
] }),
|
|
8889
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { style: checkboxLabelStyle, children: [
|
|
8890
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8891
|
+
"input",
|
|
8892
|
+
{
|
|
8893
|
+
checked: step.allowSkip === true,
|
|
8894
|
+
onChange: (event) => updateStep(stepIndex, { allowSkip: event.target.checked }),
|
|
8895
|
+
type: "checkbox"
|
|
8896
|
+
}
|
|
8897
|
+
),
|
|
8898
|
+
"Allow visitors to skip this step"
|
|
8899
|
+
] }),
|
|
8900
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { style: { display: "grid", gap: "0.85rem" }, children: [
|
|
8901
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: "Fields" }),
|
|
8902
|
+
fields.map((field, fieldIndex) => {
|
|
8903
|
+
const label = getNonEmptyText(field.label, `Field ${fieldIndex + 1}`);
|
|
8904
|
+
const fieldType = getNonEmptyText(field.type, "text");
|
|
8905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-card", children: [
|
|
8906
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8907
|
+
"div",
|
|
8908
|
+
{
|
|
8909
|
+
className: "orion-admin-inline-actions",
|
|
8910
|
+
style: { justifyContent: "space-between" },
|
|
8911
|
+
children: [
|
|
8912
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: label }),
|
|
8913
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8914
|
+
"button",
|
|
8915
|
+
{
|
|
8916
|
+
className: "orion-admin-action-button orion-admin-action-button--ghost",
|
|
8917
|
+
onClick: () => setEditorState((current) => {
|
|
8918
|
+
if (!current) return current;
|
|
8919
|
+
return {
|
|
8920
|
+
...current,
|
|
8921
|
+
steps: current.steps.map(
|
|
8922
|
+
(currentStep, index) => index === stepIndex ? {
|
|
8923
|
+
...currentStep,
|
|
8924
|
+
fields: getFields(currentStep).filter(
|
|
8925
|
+
(_, currentFieldIndex) => currentFieldIndex !== fieldIndex
|
|
8926
|
+
)
|
|
8927
|
+
} : currentStep
|
|
8928
|
+
)
|
|
8929
|
+
};
|
|
8930
|
+
}),
|
|
8931
|
+
type: "button",
|
|
8932
|
+
children: "Remove field"
|
|
8933
|
+
}
|
|
8934
|
+
)
|
|
8935
|
+
]
|
|
8936
|
+
}
|
|
8937
|
+
),
|
|
8938
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
8939
|
+
"Field label",
|
|
8940
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8941
|
+
"input",
|
|
8942
|
+
{
|
|
8943
|
+
onChange: (event) => {
|
|
8944
|
+
const nextLabel = event.target.value;
|
|
8945
|
+
const currentName = getNonEmptyText(field.name);
|
|
8946
|
+
updateField(stepIndex, fieldIndex, {
|
|
8947
|
+
label: nextLabel,
|
|
8948
|
+
name: currentName || slugifyFieldName(nextLabel)
|
|
8949
|
+
});
|
|
8950
|
+
},
|
|
8951
|
+
type: "text",
|
|
8952
|
+
value: label
|
|
8953
|
+
}
|
|
8954
|
+
)
|
|
8955
|
+
] }),
|
|
8956
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
8957
|
+
"Field key",
|
|
8958
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8959
|
+
"input",
|
|
8960
|
+
{
|
|
8961
|
+
onChange: (event) => updateField(stepIndex, fieldIndex, { name: event.target.value }),
|
|
8962
|
+
type: "text",
|
|
8963
|
+
value: getNonEmptyText(field.name)
|
|
8964
|
+
}
|
|
8965
|
+
)
|
|
8966
|
+
] }),
|
|
8967
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
8968
|
+
"Field type",
|
|
8969
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8970
|
+
"select",
|
|
8971
|
+
{
|
|
8972
|
+
onChange: (event) => updateField(stepIndex, fieldIndex, { type: event.target.value }),
|
|
8973
|
+
value: fieldType,
|
|
8974
|
+
children: fieldTypeOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("option", { value: option, children: option }, option))
|
|
8975
|
+
}
|
|
8976
|
+
)
|
|
8977
|
+
] }),
|
|
8978
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { style: checkboxLabelStyle, children: [
|
|
8979
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8980
|
+
"input",
|
|
8981
|
+
{
|
|
8982
|
+
checked: field.required === true,
|
|
8983
|
+
onChange: (event) => updateField(stepIndex, fieldIndex, { required: event.target.checked }),
|
|
8984
|
+
type: "checkbox"
|
|
8985
|
+
}
|
|
8986
|
+
),
|
|
8987
|
+
"Required"
|
|
8988
|
+
] }),
|
|
8989
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
8990
|
+
"Help text",
|
|
8991
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8992
|
+
"textarea",
|
|
8993
|
+
{
|
|
8994
|
+
onChange: (event) => updateField(stepIndex, fieldIndex, { helpText: event.target.value }),
|
|
8995
|
+
rows: 2,
|
|
8996
|
+
value: getNonEmptyText(field.helpText)
|
|
8997
|
+
}
|
|
8998
|
+
)
|
|
8999
|
+
] }),
|
|
9000
|
+
["select", "radio", "checkbox-group"].includes(fieldType) ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { children: [
|
|
9001
|
+
"Options",
|
|
9002
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
9003
|
+
"textarea",
|
|
9004
|
+
{
|
|
9005
|
+
onChange: (event) => updateField(stepIndex, fieldIndex, {
|
|
9006
|
+
options: fromOptionsText(event.target.value)
|
|
9007
|
+
}),
|
|
9008
|
+
placeholder: "Option one\nOption two",
|
|
9009
|
+
rows: 4,
|
|
9010
|
+
value: toOptionsText(field.options)
|
|
9011
|
+
}
|
|
9012
|
+
)
|
|
9013
|
+
] }) : null
|
|
9014
|
+
] }, `edit-field-${stepIndex}-${fieldIndex}`);
|
|
9015
|
+
}),
|
|
9016
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
9017
|
+
"button",
|
|
9018
|
+
{
|
|
9019
|
+
className: "orion-admin-action-button orion-admin-action-button--ghost",
|
|
9020
|
+
onClick: () => setEditorState(
|
|
9021
|
+
(current) => current ? {
|
|
9022
|
+
...current,
|
|
9023
|
+
steps: current.steps.map(
|
|
9024
|
+
(currentStep, index) => index === stepIndex ? { ...currentStep, fields: [...getFields(currentStep), blankField()] } : currentStep
|
|
9025
|
+
)
|
|
9026
|
+
} : current
|
|
9027
|
+
),
|
|
9028
|
+
type: "button",
|
|
9029
|
+
children: "Add field"
|
|
9030
|
+
}
|
|
9031
|
+
)
|
|
9032
|
+
] })
|
|
9033
|
+
] }, `edit-step-${stepIndex}`);
|
|
9034
|
+
}),
|
|
9035
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
9036
|
+
"button",
|
|
9037
|
+
{
|
|
9038
|
+
className: "orion-admin-action-button orion-admin-action-button--ghost",
|
|
9039
|
+
onClick: () => setEditorState(
|
|
9040
|
+
(current) => current ? { ...current, steps: [...current.steps, blankStep()] } : current
|
|
9041
|
+
),
|
|
9042
|
+
type: "button",
|
|
9043
|
+
children: "Add step"
|
|
9044
|
+
}
|
|
9045
|
+
)
|
|
9046
|
+
] })
|
|
8802
9047
|
] }),
|
|
8803
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "orion-admin-list-meta", children: "Edit the public workflow as JSON. The saved payload must remain an array of step objects compatible with the form collection schema." }),
|
|
8804
9048
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { disabled: saving, type: "submit", children: saving ? "Saving..." : "Save Form" })
|
|
8805
9049
|
] })
|
|
8806
|
-
] }),
|
|
8807
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "orion-admin-card", children: [
|
|
8808
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: "Current structure payload" }),
|
|
8809
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Reference snapshot of the form steps that will be written back on save." }),
|
|
8810
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("pre", { style: { ...codeStyle, marginTop: "1rem" }, children: editorState.stepsText })
|
|
8811
9050
|
] })
|
|
8812
9051
|
] }) : null
|
|
8813
9052
|
]
|
|
@@ -8819,25 +9058,17 @@ function AdminStudioFormDetailView(props) {
|
|
|
8819
9058
|
var import_link5 = __toESM(require("next/link"));
|
|
8820
9059
|
var import_react33 = require("react");
|
|
8821
9060
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8822
|
-
var codeStyle2 = {
|
|
8823
|
-
background: "color-mix(in srgb, var(--orion-admin-card-bg) 82%, black)",
|
|
8824
|
-
border: "1px solid var(--orion-admin-card-border)",
|
|
8825
|
-
borderRadius: "var(--orion-admin-radius-sm)",
|
|
8826
|
-
color: "var(--orion-admin-text)",
|
|
8827
|
-
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
8828
|
-
fontSize: "0.86rem",
|
|
8829
|
-
lineHeight: 1.55,
|
|
8830
|
-
margin: 0,
|
|
8831
|
-
maxHeight: "28rem",
|
|
8832
|
-
overflow: "auto",
|
|
8833
|
-
padding: "0.9rem",
|
|
8834
|
-
whiteSpace: "pre-wrap"
|
|
8835
|
-
};
|
|
8836
9061
|
var sectionGridStyle2 = {
|
|
8837
9062
|
display: "grid",
|
|
8838
9063
|
gap: "1rem",
|
|
8839
9064
|
gridTemplateColumns: "repeat(auto-fit, minmax(320px, 1fr))"
|
|
8840
9065
|
};
|
|
9066
|
+
var nestedListStyle = {
|
|
9067
|
+
display: "grid",
|
|
9068
|
+
gap: "0.45rem",
|
|
9069
|
+
margin: 0,
|
|
9070
|
+
padding: 0
|
|
9071
|
+
};
|
|
8841
9072
|
var renderFieldValue = (value) => {
|
|
8842
9073
|
if (value === null || value === void 0) {
|
|
8843
9074
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "orion-admin-list-meta", children: "No value" });
|
|
@@ -8851,7 +9082,26 @@ var renderFieldValue = (value) => {
|
|
|
8851
9082
|
if (typeof value === "string") {
|
|
8852
9083
|
return value.trim().length > 0 ? value : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "orion-admin-list-meta", children: "No value" });
|
|
8853
9084
|
}
|
|
8854
|
-
|
|
9085
|
+
if (Array.isArray(value)) {
|
|
9086
|
+
const entries = value.filter((entry) => entry !== null && entry !== void 0 && entry !== "");
|
|
9087
|
+
if (entries.length === 0) {
|
|
9088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "orion-admin-list-meta", children: "No value" });
|
|
9089
|
+
}
|
|
9090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("ul", { style: nestedListStyle, children: entries.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("li", { children: renderFieldValue(entry) }, index)) });
|
|
9091
|
+
}
|
|
9092
|
+
if (typeof value === "object") {
|
|
9093
|
+
const entries = Object.entries(value).filter(
|
|
9094
|
+
([, entryValue]) => entryValue !== null && entryValue !== void 0 && entryValue !== ""
|
|
9095
|
+
);
|
|
9096
|
+
if (entries.length === 0) {
|
|
9097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "orion-admin-list-meta", children: "No value" });
|
|
9098
|
+
}
|
|
9099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { style: { display: "grid", gap: "0.65rem" }, children: entries.map(([key, entryValue]) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "orion-admin-meta-row", children: [
|
|
9100
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "orion-admin-meta-label", children: humanizeKey2(key) }),
|
|
9101
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "orion-admin-meta-value", children: renderFieldValue(entryValue) })
|
|
9102
|
+
] }, key)) });
|
|
9103
|
+
}
|
|
9104
|
+
return String(value);
|
|
8855
9105
|
};
|
|
8856
9106
|
function getSubmissionIDFromPathname(pathname) {
|
|
8857
9107
|
return getIDFromPathname(pathname, "/forms/submissions/");
|
|
@@ -9003,31 +9253,24 @@ function AdminStudioFormSubmissionView(props) {
|
|
|
9003
9253
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("article", { className: "orion-admin-overview-stat", children: [
|
|
9004
9254
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "orion-admin-overview-stat-label", children: "Highlighted answers" }),
|
|
9005
9255
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: previewFields.length }),
|
|
9006
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { children: "Readable answer previews
|
|
9256
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { children: "Readable answer previews from this response." })
|
|
9007
9257
|
] })
|
|
9008
9258
|
] }),
|
|
9009
9259
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { style: sectionGridStyle2, children: [
|
|
9010
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.
|
|
9011
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.
|
|
9015
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
] }),
|
|
9025
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "orion-admin-card", children: [
|
|
9026
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: "Raw payload" }),
|
|
9027
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: "Verbatim submission data for troubleshooting or export checks." }),
|
|
9028
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("pre", { style: { ...codeStyle2, marginTop: "1rem" }, children: JSON.stringify(doc.data ?? {}, null, 2) })
|
|
9029
|
-
] })
|
|
9030
|
-
] }),
|
|
9260
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { style: { display: "grid", gap: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "orion-admin-card", children: [
|
|
9261
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: "Response details" }),
|
|
9262
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: "Formatted answers using the current form field labels when available." }),
|
|
9263
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { style: { display: "grid", gap: "0.85rem", marginTop: "1rem" }, children: answerEntries.length > 0 ? answerEntries.map(([key, value]) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "orion-admin-form", children: [
|
|
9264
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { children: [
|
|
9265
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: fieldLabels.get(key) || humanizeKey2(key) }),
|
|
9266
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "orion-admin-list-meta", children: key })
|
|
9267
|
+
] }),
|
|
9268
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { children: renderFieldValue(value) })
|
|
9269
|
+
] }, key)) : /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "orion-admin-empty-state", children: [
|
|
9270
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: "No answers available" }),
|
|
9271
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: "This submission does not contain visible response details." })
|
|
9272
|
+
] }) })
|
|
9273
|
+
] }) }),
|
|
9031
9274
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { style: { display: "grid", gap: "1rem" }, children: [
|
|
9032
9275
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "orion-admin-card orion-admin-meta-table", children: [
|
|
9033
9276
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "orion-admin-meta-row", children: [
|