Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -20,7 +20,7 @@ import {
type DragEndEvent,
} from "@dnd-kit/core";
import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable";
import type { FormField } from "@toolctrl/form-widget";
import type { FormField } from "@hivegrid/form-widget";
import { SortableField } from "./SortableField";
export type CanvasProps = {
@@ -2,7 +2,7 @@
* Right-rail field-properties editor for the form-builder. Renders the
* full editable surface for the currently-selected field — label, key,
* required, placeholder, help-text, length validation and per-option
* editing for select/radio types.
* editing for select/multiselect types.
*
* The component is a controlled view: every input change calls back
* through `onChange` with a fresh field object so the parent
@@ -10,7 +10,7 @@
*/
import type * as React from "react";
import { useTranslation } from "react-i18next";
import type { FormField } from "@toolctrl/form-widget";
import type { ConditionalLogicRule, FormField } from "@hivegrid/form-widget";
export type FieldPropertiesProps = {
field: FormField | null;
@@ -109,6 +109,72 @@ function OptionsEditor({
);
}
function ConditionalLogicEditor({
field,
onChange,
}: {
field: FormField;
onChange: (next: FormField) => void;
}): React.JSX.Element {
const { t } = useTranslation();
const rules = field.conditionalLogic ?? [];
function updateRule(index: number, patch: Partial<ConditionalLogicRule>) {
const next = rules.slice();
next[index] = { ...next[index], ...patch };
onChange({ ...field, conditionalLogic: next });
}
return (
<div className="space-y-2">
<span className="block text-xs uppercase tracking-wide text-gray-500">
{t("settings.forms.builder.properties.conditional.title")}
</span>
{rules.map((rule, index) => (
<div key={index} className="grid grid-cols-[1fr_1fr_auto] gap-2">
<input
className="border rounded px-2 py-1 text-xs font-mono"
placeholder={t("settings.forms.builder.properties.conditional.fieldKey")}
value={rule.fieldKey}
onChange={(e) => updateRule(index, { fieldKey: e.target.value })}
/>
<select
className="border rounded px-2 py-1 text-xs"
value={rule.operator}
onChange={(e) => updateRule(index, { operator: e.target.value as ConditionalLogicRule["operator"] })}
>
{["equals", "not_equals", "contains", "not_empty", "empty", "in"].map((op) => (
<option key={op} value={op}>
{t(`settings.forms.builder.properties.conditional.operators.${op}`)}
</option>
))}
</select>
<button
type="button"
className="text-red-600 px-2 text-xs"
onClick={() => onChange({ ...field, conditionalLogic: rules.filter((_, i) => i !== index) })}
>
{"x"}
</button>
{rule.operator !== "empty" && rule.operator !== "not_empty" ? (
<input
className="col-span-3 border rounded px-2 py-1 text-xs"
placeholder={t("settings.forms.builder.properties.conditional.value")}
value={Array.isArray(rule.value) ? rule.value.join(",") : String(rule.value ?? "")}
onChange={(e) => updateRule(index, { value: rule.operator === "in" ? e.target.value.split(",").map((v) => v.trim()).filter(Boolean) : e.target.value })}
/>
) : null}
</div>
))}
<button
type="button"
className="text-sm border rounded px-2 py-1"
onClick={() => onChange({ ...field, conditionalLogic: [...rules, { fieldKey: "", operator: "equals", value: "" }] })}
>
{t("settings.forms.builder.properties.conditional.add")}
</button>
</div>
);
}
export function FieldProperties({ field, onChange }: FieldPropertiesProps): React.JSX.Element {
const { t } = useTranslation();
if (!field) {
@@ -119,8 +185,8 @@ export function FieldProperties({ field, onChange }: FieldPropertiesProps): Reac
</aside>
);
}
const supportsOptions = field.type === "select" || field.type === "radio";
const supportsPlaceholder = field.type === "text" || field.type === "email" || field.type === "number" || field.type === "textarea" || field.type === "select";
const supportsOptions = field.type === "select" || field.type === "multiselect";
const supportsPlaceholder = ["text", "email", "phone", "number", "textarea", "select", "date", "time"].includes(field.type);
const supportsLength = field.type === "text" || field.type === "email" || field.type === "textarea";
return (
<aside className="w-full shrink-0 border rounded p-3 bg-white space-y-3 lg:w-72" aria-label={t("settings.forms.builder.properties.ariaLabel")}>
@@ -193,6 +259,26 @@ export function FieldProperties({ field, onChange }: FieldPropertiesProps): Reac
</label>
</div>
) : null}
{field.type === "number" ? (
<div className="grid grid-cols-2 gap-2">
<label className="block text-sm">
<span className="block text-xs uppercase tracking-wide text-gray-500">{t("settings.forms.builder.properties.min")}</span>
<NumericInput
fieldId={`${field.key}-min-number`}
value={field.validationRules?.min}
onChange={(next) => onChange({ ...field, validationRules: { ...(field.validationRules ?? {}), min: next } })}
/>
</label>
<label className="block text-sm">
<span className="block text-xs uppercase tracking-wide text-gray-500">{t("settings.forms.builder.properties.max")}</span>
<NumericInput
fieldId={`${field.key}-max-number`}
value={field.validationRules?.max}
onChange={(next) => onChange({ ...field, validationRules: { ...(field.validationRules ?? {}), max: next } })}
/>
</label>
</div>
) : null}
{supportsOptions ? (
<div>
<span className="block text-xs uppercase tracking-wide text-gray-500 mb-1">{t("settings.forms.builder.properties.options.title")}</span>
@@ -202,6 +288,7 @@ export function FieldProperties({ field, onChange }: FieldPropertiesProps): Reac
/>
</div>
) : null}
<ConditionalLogicEditor field={field} onChange={onChange} />
</aside>
);
}
@@ -1,7 +1,7 @@
import "@testing-library/jest-dom";
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import type { FormDefinition, FormField, FormTheme } from "@toolctrl/form-widget";
import type { FormDefinition, FormField, FormTheme } from "@hivegrid/form-widget";
import { FormBuilder } from "./FormBuilder";
import type { FormSettingsValue } from "./SettingsTab";
@@ -41,6 +41,8 @@ const definition: FormDefinition = {
title: "Contact",
submitLabel: "Submit",
successMessage: "Thanks",
gdprConsentLabel: "I agree",
captchaEnabled: true,
fields: [{ key: "email", type: "email", label: "Email", required: true }],
};
@@ -52,6 +54,7 @@ const settings: FormSettingsValue = {
webhookUrl: "",
targetType: "generic",
fieldMapping: {},
actions: [],
};
function renderBuilder() {
@@ -10,7 +10,7 @@
import type * as React from "react";
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import type { FormDefinition, FormField, FormTheme } from "@toolctrl/form-widget";
import type { FormDefinition, FormField, FormTheme } from "@hivegrid/form-widget";
import { FieldPalette } from "./FieldPalette";
import { Canvas } from "./Canvas";
import { FieldProperties } from "./FieldProperties";
@@ -13,7 +13,7 @@
import type * as React from "react";
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { HONEYPOT_FIELD_KEY, type FormDefinition, type FormField, type FormTheme } from "@toolctrl/form-widget";
import { filterVisibleFields, HONEYPOT_FIELD_KEY, type FormDefinition, type FormField, type FormTheme } from "@hivegrid/form-widget";
export type PreviewTabProps = {
definition: FormDefinition;
@@ -36,8 +36,8 @@ function PreviewField({
onChange,
}: {
field: FormField;
value: string | boolean;
onChange: (next: string | boolean) => void;
value: string | boolean | string[];
onChange: (next: string | boolean | string[]) => void;
}): React.JSX.Element | null {
const inputId = `tcform-preview-${field.key}`;
if (field.type === "honeypot") {
@@ -85,7 +85,7 @@ function PreviewField({
</div>
);
}
if (field.type === "select") {
if (field.type === "select" || field.type === "multiselect") {
const options = field.options ?? [];
return (
<div className="tcform-row">
@@ -94,10 +94,17 @@ function PreviewField({
id={inputId}
name={field.key}
required={field.required}
value={typeof value === "string" ? value : ""}
onChange={(e) => onChange(e.target.value)}
multiple={field.type === "multiselect"}
value={Array.isArray(value) ? value : typeof value === "string" ? value : ""}
onChange={(e) =>
onChange(
field.type === "multiselect"
? Array.from(e.currentTarget.selectedOptions).map((opt) => opt.value)
: e.currentTarget.value,
)
}
>
<option value="">{field.placeholder ?? ""}</option>
{field.type === "select" ? <option value="">{field.placeholder ?? ""}</option> : null}
{options.map((opt) => (
<option key={opt.value} value={opt.value}>
{opt.label}
@@ -108,29 +115,7 @@ function PreviewField({
</div>
);
}
if (field.type === "radio") {
const options = field.options ?? [];
return (
<fieldset className="tcform-row tcform-radio-group" aria-describedby={helpEl ? `${inputId}-help` : undefined}>
<legend>{field.label}</legend>
{options.map((opt) => (
<label key={opt.value} className="tcform-radio">
<input
type="radio"
name={field.key}
value={opt.value}
checked={value === opt.value}
onChange={() => onChange(opt.value)}
required={field.required}
/>
<span>{opt.label}</span>
</label>
))}
{helpEl}
</fieldset>
);
}
if (field.type === "checkbox") {
if (field.type === "boolean") {
return (
<div className="tcform-row tcform-checkbox">
<label className="tcform-label">
@@ -147,7 +132,24 @@ function PreviewField({
</div>
);
}
const inputType = field.type === "email" ? "email" : field.type === "number" ? "number" : "text";
if (field.type === "file" || field.type === "photo") {
return (
<div className="tcform-row">
{labelEl}
<input
id={inputId}
type="file"
name={field.key}
required={field.required}
accept={field.type === "photo" ? "image/*" : field.validationRules?.acceptedFileTypes?.join(",")}
aria-describedby={helpEl ? `${inputId}-help` : undefined}
disabled
/>
{helpEl}
</div>
);
}
const inputType = field.type === "email" ? "email" : field.type === "number" ? "number" : field.type === "date" ? "date" : field.type === "time" ? "time" : field.type === "phone" ? "tel" : "text";
return (
<div className="tcform-row">
{labelEl}
@@ -171,13 +173,14 @@ function PreviewField({
export function PreviewTab({ definition, theme }: PreviewTabProps): React.JSX.Element {
const { t } = useTranslation();
const styleVars = useMemo(() => themeCssVars(theme), [theme]);
const [values, setValues] = useState<Record<string, string | boolean>>(() => {
const init: Record<string, string | boolean> = {};
const [values, setValues] = useState<Record<string, string | boolean | string[]>>(() => {
const init: Record<string, string | boolean | string[]> = {};
for (const f of definition.fields) {
init[f.key] = f.type === "checkbox" ? false : "";
init[f.key] = f.type === "boolean" ? false : f.type === "multiselect" ? [] : "";
}
return init;
});
const visibleFields = filterVisibleFields(definition.fields, values);
return (
<div className="border rounded bg-white p-3 max-w-xl">
@@ -206,11 +209,11 @@ export function PreviewTab({ definition, theme }: PreviewTabProps): React.JSX.El
e.preventDefault();
}}
>
{definition.fields.map((field) => (
{visibleFields.map((field) => (
<PreviewField
key={field.key}
field={field}
value={values[field.key] ?? (field.type === "checkbox" ? false : "")}
value={values[field.key] ?? (field.type === "boolean" ? false : field.type === "multiselect" ? [] : "")}
onChange={(next) => setValues((prev) => ({ ...prev, [field.key]: next }))}
/>
))}
@@ -5,8 +5,8 @@
* - allowedOrigins → array of hostnames the submit API accepts
* - notifyEmails → mail recipients for new submissions
* - webhookUrl → optional outbound webhook
* - targetType → routing target (generic FormSubmission, CRM
* contact, or entity-row)
* - targetType → legacy routing target (generic store, CRM contact,
* or typed lead compatibility)
* - fieldMapping → field → target-column mapping for non-generic
* target types
*
@@ -15,7 +15,35 @@
*/
import type * as React from "react";
import { useTranslation } from "react-i18next";
import type { FormField } from "@toolctrl/form-widget";
import type { FormField } from "@hivegrid/form-widget";
export type FormActionJsonValue =
| string
| number
| boolean
| null
| FormActionJsonValue[]
| { [key: string]: FormActionJsonValue };
export type FormActionJsonObject = { [key: string]: FormActionJsonValue };
export type FormActionSetting = {
id?: string;
actionType:
| "auto_match"
| "create_lead"
| "create_contact"
| "create_project"
| "create_task"
| "send_email_to_team"
| "send_email_to_submitter"
| "webhook"
| "trigger_automation";
name: string;
enabled: boolean;
fieldMapping: Record<string, string>;
actionConfig: FormActionJsonObject;
};
export type FormSettingsValue = {
allowedOrigins: string[];
@@ -23,6 +51,7 @@ export type FormSettingsValue = {
webhookUrl: string;
targetType: string;
fieldMapping: Record<string, string>;
actions: FormActionSetting[];
};
export type SettingsTabProps = {
@@ -34,7 +63,19 @@ export type SettingsTabProps = {
const TARGET_OPTIONS = [
{ value: "generic", labelKey: "settings.forms.builder.settings.targets.generic" },
{ value: "crm-contact", labelKey: "settings.forms.builder.settings.targets.crmContact" },
{ value: "entity-row", labelKey: "settings.forms.builder.settings.targets.entityRow" },
{ value: "create-lead", labelKey: "settings.forms.builder.settings.targets.createLead" },
];
const ACTION_OPTIONS: Array<{ value: FormActionSetting["actionType"]; labelKey: string }> = [
{ value: "auto_match", labelKey: "settings.forms.builder.settings.actions.types.autoMatch" },
{ value: "create_lead", labelKey: "settings.forms.builder.settings.actions.types.createLead" },
{ value: "create_contact", labelKey: "settings.forms.builder.settings.actions.types.createContact" },
{ value: "create_project", labelKey: "settings.forms.builder.settings.actions.types.createProject" },
{ value: "create_task", labelKey: "settings.forms.builder.settings.actions.types.createTask" },
{ value: "send_email_to_team", labelKey: "settings.forms.builder.settings.actions.types.sendEmailToTeam" },
{ value: "send_email_to_submitter", labelKey: "settings.forms.builder.settings.actions.types.sendEmailToSubmitter" },
{ value: "webhook", labelKey: "settings.forms.builder.settings.actions.types.webhook" },
{ value: "trigger_automation", labelKey: "settings.forms.builder.settings.actions.types.triggerAutomation" },
];
function joinLines(values: string[]): string {
@@ -55,9 +96,40 @@ function parseCsvOrLines(raw: string): string[] {
.filter((s) => s.length > 0);
}
function isJsonValue(value: unknown): value is FormActionJsonValue {
if (value === null) return true;
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return true;
if (Array.isArray(value)) return value.every(isJsonValue);
if (typeof value !== "object") return false;
return Object.values(value as Record<string, unknown>).every(isJsonValue);
}
function parseJsonObject(raw: string): FormActionJsonObject {
if (!raw.trim()) return {};
try {
const parsed = JSON.parse(raw) as unknown;
return parsed && typeof parsed === "object" && !Array.isArray(parsed) && isJsonValue(parsed) ? (parsed as FormActionJsonObject) : {};
} catch {
return {};
}
}
function addDefaultAction(actions: FormActionSetting[]): FormActionSetting[] {
return [
...actions,
{
actionType: "create_lead",
name: "Create lead",
enabled: true,
fieldMapping: {},
actionConfig: {},
},
];
}
export function SettingsTab({ value, fields, onChange }: SettingsTabProps): React.JSX.Element {
const { t } = useTranslation();
const showMapping = value.targetType === "crm-contact" || value.targetType === "entity-row";
const showMapping = value.targetType === "crm-contact" || value.targetType === "create-lead";
return (
<div className="space-y-4 max-w-2xl">
<label className="block">
@@ -140,6 +212,104 @@ export function SettingsTab({ value, fields, onChange }: SettingsTabProps): Reac
</div>
</div>
) : null}
<section className="space-y-2">
<div className="flex items-center justify-between gap-2">
<div>
<h3 className="text-sm font-medium">{t("settings.forms.builder.settings.actions.title")}</h3>
<p className="text-[11px] text-gray-500">{t("settings.forms.builder.settings.actions.description")}</p>
</div>
<button
type="button"
className="rounded border px-2 py-1 text-xs"
onClick={() => onChange({ ...value, actions: addDefaultAction(value.actions) })}
>
{t("settings.forms.builder.settings.actions.add")}
</button>
</div>
{value.actions.length === 0 ? (
<p className="text-sm text-gray-500 italic">{t("settings.forms.builder.settings.actions.empty")}</p>
) : (
<div className="space-y-3">
{value.actions.map((action, index) => (
<div key={action.id ?? index} className="rounded border p-3 space-y-2">
<div className="grid gap-2 md:grid-cols-[1fr_180px_auto]">
<input
className="rounded border px-2 py-1 text-sm"
value={action.name}
aria-label={t("settings.forms.builder.settings.actions.name")}
onChange={(e) => {
const next = [...value.actions];
next[index] = { ...action, name: e.target.value };
onChange({ ...value, actions: next });
}}
/>
<select
className="rounded border px-2 py-1 text-sm"
value={action.actionType}
aria-label={t("settings.forms.builder.settings.actions.type")}
onChange={(e) => {
const next = [...value.actions];
next[index] = { ...action, actionType: e.target.value as FormActionSetting["actionType"] };
onChange({ ...value, actions: next });
}}
>
{ACTION_OPTIONS.map((opt) => (
<option key={opt.value} value={opt.value}>
{t(opt.labelKey)}
</option>
))}
</select>
<label className="flex items-center gap-2 text-sm">
<input
type="checkbox"
checked={action.enabled}
onChange={(e) => {
const next = [...value.actions];
next[index] = { ...action, enabled: e.target.checked };
onChange({ ...value, actions: next });
}}
/>
{t("settings.forms.builder.settings.actions.enabled")}
</label>
</div>
<label className="block">
<span className="block text-xs uppercase tracking-wide text-gray-500">{t("settings.forms.builder.settings.actions.mappingJson")}</span>
<textarea
rows={3}
className="w-full rounded border px-2 py-1 font-mono text-xs"
value={JSON.stringify(action.fieldMapping, null, 2)}
onChange={(e) => {
const next = [...value.actions];
next[index] = { ...action, fieldMapping: parseJsonObject(e.target.value) as Record<string, string> };
onChange({ ...value, actions: next });
}}
/>
</label>
<label className="block">
<span className="block text-xs uppercase tracking-wide text-gray-500">{t("settings.forms.builder.settings.actions.configJson")}</span>
<textarea
rows={3}
className="w-full rounded border px-2 py-1 font-mono text-xs"
value={JSON.stringify(action.actionConfig, null, 2)}
onChange={(e) => {
const next = [...value.actions];
next[index] = { ...action, actionConfig: parseJsonObject(e.target.value) };
onChange({ ...value, actions: next });
}}
/>
</label>
<button
type="button"
className="rounded border px-2 py-1 text-xs text-red-700"
onClick={() => onChange({ ...value, actions: value.actions.filter((_, actionIndex) => actionIndex !== index) })}
>
{t("settings.forms.builder.settings.actions.remove")}
</button>
</div>
))}
</div>
)}
</section>
</div>
);
}
@@ -12,7 +12,7 @@ import type * as React from "react";
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { useTranslation } from "react-i18next";
import type { FormField } from "@toolctrl/form-widget";
import type { FormField } from "@hivegrid/form-widget";
export type SortableFieldProps = {
field: FormField;
@@ -1,16 +1,11 @@
/**
* Static palette definition for the form-builder. Each entry exposes a
* factory that returns a fresh `FormField` shape (matching the
* `@toolctrl/form-widget` zod schema) so the canvas can append without
* `@hivegrid/form-widget` zod schema) so the canvas can append without
* having to deep-clone a frozen prototype.
*
* The palette deliberately exposes a superset of `FormFieldType` —
* `heading` + `paragraph` are presentational items the renderer treats
* as `text` fields with `helpText` carrying the body. They keep parity
* with the original spec ("Heading, Paragraph" callouts in the
* drag-drop UX) without expanding the storage schema.
*/
import { HONEYPOT_FIELD_KEY } from "@toolctrl/form-widget";
import { HONEYPOT_FIELD_KEY } from "@hivegrid/form-widget";
import type { FormField } from "@hivegrid/form-widget";
import type { PaletteItem } from "./types";
export const paletteDefaultLanguage = "en";
@@ -23,71 +18,107 @@ function defaultOptionLabelKey(value: string): string {
return `settings.forms.builder.defaults.options.${value}`;
}
function withFieldDefaults(field: Omit<FormField, "conditionalLogic" | "validationRules">): FormField {
return { ...field, conditionalLogic: [], validationRules: {} };
}
export const paletteItems: PaletteItem[] = [
{
type: "text",
labelKey: "settings.forms.builder.palette.text.label",
helpKey: "settings.forms.builder.palette.text.help",
defaults: () => ({ key: "text_field", type: "text", label: defaultLabelKey("text"), required: false }),
},
{
type: "email",
labelKey: "settings.forms.builder.palette.email.label",
helpKey: "settings.forms.builder.palette.email.help",
defaults: () => ({ key: "email", type: "email", label: defaultLabelKey("email"), required: true }),
defaults: () => withFieldDefaults({ key: "text_field", type: "text", label: defaultLabelKey("text"), required: false }),
},
{
type: "textarea",
labelKey: "settings.forms.builder.palette.textarea.label",
helpKey: "settings.forms.builder.palette.textarea.help",
defaults: () => ({ key: "message", type: "textarea", label: defaultLabelKey("textarea"), required: false }),
},
{
type: "select",
labelKey: "settings.forms.builder.palette.select.label",
helpKey: "settings.forms.builder.palette.select.help",
defaults: () => ({
key: "choice",
type: "select",
label: defaultLabelKey("select"),
required: false,
options: [
{ value: "option_a", label: defaultOptionLabelKey("option_a") },
{ value: "option_b", label: defaultOptionLabelKey("option_b") },
],
}),
},
{
type: "checkbox",
labelKey: "settings.forms.builder.palette.checkbox.label",
helpKey: "settings.forms.builder.palette.checkbox.help",
defaults: () => ({ key: "consent", type: "checkbox", label: defaultLabelKey("checkbox"), required: false }),
},
{
type: "radio",
labelKey: "settings.forms.builder.palette.radio.label",
helpKey: "settings.forms.builder.palette.radio.help",
defaults: () => ({
key: "pick",
type: "radio",
label: defaultLabelKey("radio"),
required: false,
options: [
{ value: "option_a", label: defaultOptionLabelKey("option_a") },
{ value: "option_b", label: defaultOptionLabelKey("option_b") },
],
}),
defaults: () => withFieldDefaults({ key: "message", type: "textarea", label: defaultLabelKey("textarea"), required: false }),
},
{
type: "number",
labelKey: "settings.forms.builder.palette.number.label",
helpKey: "settings.forms.builder.palette.number.help",
defaults: () => ({ key: "amount", type: "number", label: defaultLabelKey("number"), required: false }),
defaults: () => withFieldDefaults({ key: "amount", type: "number", label: defaultLabelKey("number"), required: false }),
},
{
type: "date",
labelKey: "settings.forms.builder.palette.date.label",
helpKey: "settings.forms.builder.palette.date.help",
defaults: () => withFieldDefaults({ key: "date", type: "date", label: defaultLabelKey("date"), required: false }),
},
{
type: "time",
labelKey: "settings.forms.builder.palette.time.label",
helpKey: "settings.forms.builder.palette.time.help",
defaults: () => withFieldDefaults({ key: "time", type: "time", label: defaultLabelKey("time"), required: false }),
},
{
type: "select",
labelKey: "settings.forms.builder.palette.select.label",
helpKey: "settings.forms.builder.palette.select.help",
defaults: () =>
withFieldDefaults({
key: "choice",
type: "select",
label: defaultLabelKey("select"),
required: false,
options: [
{ value: "option_a", label: defaultOptionLabelKey("option_a") },
{ value: "option_b", label: defaultOptionLabelKey("option_b") },
],
}),
},
{
type: "multiselect",
labelKey: "settings.forms.builder.palette.multiselect.label",
helpKey: "settings.forms.builder.palette.multiselect.help",
defaults: () =>
withFieldDefaults({
key: "choices",
type: "multiselect",
label: defaultLabelKey("multiselect"),
required: false,
options: [
{ value: "option_a", label: defaultOptionLabelKey("option_a") },
{ value: "option_b", label: defaultOptionLabelKey("option_b") },
],
}),
},
{
type: "boolean",
labelKey: "settings.forms.builder.palette.boolean.label",
helpKey: "settings.forms.builder.palette.boolean.help",
defaults: () => withFieldDefaults({ key: "consent", type: "boolean", label: defaultLabelKey("boolean"), required: false }),
},
{
type: "email",
labelKey: "settings.forms.builder.palette.email.label",
helpKey: "settings.forms.builder.palette.email.help",
defaults: () => withFieldDefaults({ key: "email", type: "email", label: defaultLabelKey("email"), required: true }),
},
{
type: "phone",
labelKey: "settings.forms.builder.palette.phone.label",
helpKey: "settings.forms.builder.palette.phone.help",
defaults: () => withFieldDefaults({ key: "phone", type: "phone", label: defaultLabelKey("phone"), required: false }),
},
{
type: "file",
labelKey: "settings.forms.builder.palette.file.label",
helpKey: "settings.forms.builder.palette.file.help",
defaults: () => withFieldDefaults({ key: "attachment", type: "file", label: defaultLabelKey("file"), required: false }),
},
{
type: "photo",
labelKey: "settings.forms.builder.palette.photo.label",
helpKey: "settings.forms.builder.palette.photo.help",
defaults: () => withFieldDefaults({ key: "photo", type: "photo", label: defaultLabelKey("photo"), required: false }),
},
{
type: "honeypot",
labelKey: "settings.forms.builder.palette.honeypot.label",
helpKey: "settings.forms.builder.palette.honeypot.help",
defaults: () => ({ key: HONEYPOT_FIELD_KEY, type: "honeypot", label: defaultLabelKey("honeypot"), required: false }),
defaults: () => withFieldDefaults({ key: HONEYPOT_FIELD_KEY, type: "honeypot", label: defaultLabelKey("honeypot"), required: false }),
},
];
@@ -7,7 +7,7 @@
import { describe, expect, it } from "vitest";
import { uniqueKey } from "./types";
import { paletteItems } from "./palette";
import { FormFieldSchema } from "@toolctrl/form-widget";
import { FormFieldSchema } from "@hivegrid/form-widget";
import enTranslations from "../../../../public/locales/en/translations.json";
import deTranslations from "../../../../public/locales/de/translations.json";
@@ -1,10 +1,10 @@
/**
* Shared types for the form-widget drag-drop builder (Phase 05 #58
* follow-up). The runtime contract still flows through the canonical
* `@toolctrl/form-widget` zod schemas — these helpers exist to make the
* `@hivegrid/form-widget` zod schemas — these helpers exist to make the
* UI components terse and to keep palette definitions in one place.
*/
import type { FormField, FormFieldType, FormDefinition, FormTheme } from "@toolctrl/form-widget";
import type { FormField, FormFieldType, FormDefinition, FormTheme } from "@hivegrid/form-widget";
export type BuilderFieldType = FormFieldType | "heading" | "paragraph";