@form-engine-ts/react 2.2.0 → 2.3.0

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/index.js CHANGED
@@ -2,10 +2,11 @@
2
2
  import {
3
3
  populateSchemaTranslations
4
4
  } from "@form-engine-ts/core";
5
- import { useState } from "react";
5
+ import { createContext, useContext, useState } from "react";
6
6
 
7
7
  // src/hooks/useFormBuilder.ts
8
8
  import {
9
+ collectSchemaLocales,
9
10
  transformFieldType,
10
11
  validateFormSchema
11
12
  } from "@form-engine-ts/core";
@@ -488,6 +489,13 @@ function useFormBuilder({
488
489
  const normalized = locale.trim();
489
490
  if (normalized.length === 0)
490
491
  return { success: false, error: { type: "invalid_operation", message: "Locale must not be empty." } };
492
+ if (policy?.allowedLocales !== void 0 && !policy.allowedLocales.includes(normalized)) {
493
+ return { success: false, error: { type: "disallowed_locale", locale: normalized } };
494
+ }
495
+ const allUniqueLocales = collectSchemaLocales(schema).allUniqueLocales;
496
+ if (!allUniqueLocales.has(normalized) && policy?.maxLocales !== void 0 && allUniqueLocales.size >= policy.maxLocales) {
497
+ return { success: false, error: { type: "max_locales_exceeded", max: policy.maxLocales } };
498
+ }
491
499
  const error = textPolicyError(text);
492
500
  if (error !== void 0) return error;
493
501
  const supportedLocales = [.../* @__PURE__ */ new Set([...schema.supportedLocales ?? [], normalized])];
@@ -556,7 +564,7 @@ function useFormBuilder({
556
564
  onChange({ ...schema, supportedLocales, fields, ...pages === void 0 ? {} : { pages } });
557
565
  return { success: true };
558
566
  },
559
- [onChange, schema, textPolicyError]
567
+ [onChange, policy?.allowedLocales, policy?.maxLocales, schema, textPolicyError]
560
568
  );
561
569
  const addLocale = useCallback(
562
570
  (locale) => {
@@ -566,12 +574,10 @@ function useFormBuilder({
566
574
  if (policy?.allowedLocales !== void 0 && !policy.allowedLocales.includes(normalized)) {
567
575
  return { success: false, error: { type: "disallowed_locale", locale: normalized } };
568
576
  }
569
- const registeredLocales = /* @__PURE__ */ new Set([
570
- ...schema.defaultLocale === void 0 ? [] : [schema.defaultLocale],
571
- ...schema.supportedLocales ?? []
572
- ]);
573
- if (registeredLocales.has(normalized)) return { success: true };
574
- if (policy?.maxLocales !== void 0 && registeredLocales.size >= policy.maxLocales) {
577
+ const allUniqueLocales = collectSchemaLocales(schema).allUniqueLocales;
578
+ if ((schema.supportedLocales ?? []).includes(normalized) || schema.defaultLocale === normalized)
579
+ return { success: true };
580
+ if (policy?.maxLocales !== void 0 && !allUniqueLocales.has(normalized) && allUniqueLocales.size >= policy.maxLocales) {
575
581
  return { success: false, error: { type: "max_locales_exceeded", max: policy.maxLocales } };
576
582
  }
577
583
  onChange({
@@ -596,11 +602,8 @@ function useFormBuilder({
596
602
  if (policy?.allowedLocales !== void 0 && !policy.allowedLocales.includes(normalized)) {
597
603
  return { success: false, error: { type: "disallowed_locale", locale: normalized } };
598
604
  }
599
- const registeredLocales = /* @__PURE__ */ new Set([
600
- ...schema.defaultLocale === void 0 ? [] : [schema.defaultLocale],
601
- ...schema.supportedLocales ?? []
602
- ]);
603
- if (!registeredLocales.has(normalized) && policy?.maxLocales !== void 0 && registeredLocales.size >= policy.maxLocales) {
605
+ const allUniqueLocales = collectSchemaLocales(schema).allUniqueLocales;
606
+ if (!allUniqueLocales.has(normalized) && policy?.maxLocales !== void 0 && allUniqueLocales.size >= policy.maxLocales) {
604
607
  return { success: false, error: { type: "max_locales_exceeded", max: policy.maxLocales } };
605
608
  }
606
609
  onChange({
@@ -643,6 +646,260 @@ function useFormBuilder({
643
646
 
644
647
  // src/builder.tsx
645
648
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
649
+ function DefaultButton({
650
+ id,
651
+ className,
652
+ disabled,
653
+ "aria-label": ariaLabel,
654
+ onClick,
655
+ children,
656
+ title,
657
+ action,
658
+ targetId
659
+ }) {
660
+ return /* @__PURE__ */ jsx(
661
+ "button",
662
+ {
663
+ id,
664
+ className,
665
+ type: "button",
666
+ disabled,
667
+ "aria-label": ariaLabel,
668
+ title,
669
+ "data-builder-action": action,
670
+ "data-target-id": targetId,
671
+ onClick,
672
+ children
673
+ }
674
+ );
675
+ }
676
+ function DefaultIconButton(props) {
677
+ return /* @__PURE__ */ jsx(
678
+ DefaultButton,
679
+ {
680
+ ...props.id === void 0 ? {} : { id: props.id },
681
+ ...props.className === void 0 ? {} : { className: props.className },
682
+ ...props.disabled === void 0 ? {} : { disabled: props.disabled },
683
+ "aria-label": props["aria-label"] ?? props.title,
684
+ ...props.onClick === void 0 ? {} : { onClick: props.onClick },
685
+ children: props.icon
686
+ }
687
+ );
688
+ }
689
+ function DefaultTextInput({
690
+ id,
691
+ className,
692
+ disabled,
693
+ readOnly,
694
+ "aria-label": ariaLabel,
695
+ value,
696
+ onChange,
697
+ placeholder,
698
+ maxLength,
699
+ inputMode,
700
+ type = "text",
701
+ min,
702
+ max,
703
+ step
704
+ }) {
705
+ return /* @__PURE__ */ jsx(
706
+ "input",
707
+ {
708
+ id,
709
+ className,
710
+ disabled,
711
+ readOnly,
712
+ "aria-label": ariaLabel,
713
+ type: type === "text" ? void 0 : type,
714
+ inputMode,
715
+ min,
716
+ max,
717
+ step,
718
+ value,
719
+ placeholder,
720
+ maxLength,
721
+ onChange: (event) => onChange(event.currentTarget.value)
722
+ }
723
+ );
724
+ }
725
+ function DefaultTextArea({
726
+ id,
727
+ className,
728
+ disabled,
729
+ readOnly,
730
+ "aria-label": ariaLabel,
731
+ value,
732
+ onChange,
733
+ rows,
734
+ placeholder,
735
+ maxLength
736
+ }) {
737
+ return /* @__PURE__ */ jsx(
738
+ "textarea",
739
+ {
740
+ id,
741
+ className,
742
+ disabled,
743
+ readOnly,
744
+ "aria-label": ariaLabel,
745
+ value,
746
+ rows,
747
+ placeholder,
748
+ maxLength,
749
+ onChange: (event) => onChange(event.currentTarget.value)
750
+ }
751
+ );
752
+ }
753
+ function DefaultSelect({
754
+ id,
755
+ className,
756
+ disabled,
757
+ "aria-label": ariaLabel,
758
+ value,
759
+ onChange,
760
+ options
761
+ }) {
762
+ return /* @__PURE__ */ jsx(
763
+ "select",
764
+ {
765
+ id,
766
+ className,
767
+ disabled,
768
+ "aria-label": ariaLabel,
769
+ value,
770
+ onChange: (event) => onChange(event.currentTarget.value),
771
+ children: options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value))
772
+ }
773
+ );
774
+ }
775
+ function DefaultCheckbox({
776
+ id,
777
+ className,
778
+ disabled,
779
+ "aria-label": ariaLabel,
780
+ checked,
781
+ onChange,
782
+ label
783
+ }) {
784
+ return /* @__PURE__ */ jsxs("label", { className, children: [
785
+ /* @__PURE__ */ jsx(
786
+ "input",
787
+ {
788
+ id,
789
+ type: "checkbox",
790
+ disabled,
791
+ "aria-label": ariaLabel,
792
+ checked,
793
+ onChange: (event) => onChange(event.currentTarget.checked)
794
+ }
795
+ ),
796
+ label
797
+ ] });
798
+ }
799
+ function DefaultSection({
800
+ id,
801
+ className,
802
+ title,
803
+ description,
804
+ headingId,
805
+ "aria-label": ariaLabel,
806
+ onClickCapture,
807
+ children
808
+ }) {
809
+ return /* @__PURE__ */ jsxs(
810
+ "section",
811
+ {
812
+ id,
813
+ className,
814
+ "aria-label": ariaLabel,
815
+ "aria-labelledby": title === void 0 ? void 0 : headingId,
816
+ onClickCapture,
817
+ children: [
818
+ title === void 0 ? null : /* @__PURE__ */ jsx("h2", { id: headingId, children: title }),
819
+ description === void 0 ? null : /* @__PURE__ */ jsx("p", { children: description }),
820
+ children
821
+ ]
822
+ }
823
+ );
824
+ }
825
+ function DefaultFieldset({ className, legend, disabled, children }) {
826
+ return /* @__PURE__ */ jsxs("fieldset", { className, disabled, children: [
827
+ legend === void 0 ? null : /* @__PURE__ */ jsx("legend", { children: legend }),
828
+ children
829
+ ] });
830
+ }
831
+ function DefaultErrorMessage({ message }) {
832
+ return /* @__PURE__ */ jsx("p", { className: "form-engine-builder__error", children: message });
833
+ }
834
+ var DEFAULT_COMPONENTS = {
835
+ Button: DefaultButton,
836
+ IconButton: DefaultIconButton,
837
+ TextInput: DefaultTextInput,
838
+ TextArea: DefaultTextArea,
839
+ Select: DefaultSelect,
840
+ Checkbox: DefaultCheckbox,
841
+ Section: DefaultSection,
842
+ Fieldset: DefaultFieldset,
843
+ ErrorMessage: DefaultErrorMessage
844
+ };
845
+ var BuilderPrimitiveContext = createContext({
846
+ components: DEFAULT_COMPONENTS,
847
+ readOnly: false
848
+ });
849
+ function BuilderButton(props) {
850
+ const context = useContext(BuilderPrimitiveContext);
851
+ const Component = context.components.Button;
852
+ return /* @__PURE__ */ jsx(Component, { ...props, disabled: context.readOnly || props.disabled === true, readOnly: context.readOnly });
853
+ }
854
+ function BuilderIconButton(props) {
855
+ const context = useContext(BuilderPrimitiveContext);
856
+ const Component = context.components.IconButton;
857
+ return /* @__PURE__ */ jsx(Component, { ...props, disabled: context.readOnly || props.disabled === true, readOnly: context.readOnly });
858
+ }
859
+ function BuilderTextInput(props) {
860
+ const context = useContext(BuilderPrimitiveContext);
861
+ const Component = context.components.TextInput;
862
+ return /* @__PURE__ */ jsx(Component, { ...props, disabled: context.readOnly || props.disabled === true, readOnly: context.readOnly });
863
+ }
864
+ function BuilderTextArea(props) {
865
+ const context = useContext(BuilderPrimitiveContext);
866
+ const Component = context.components.TextArea;
867
+ return /* @__PURE__ */ jsx(Component, { ...props, disabled: context.readOnly || props.disabled === true, readOnly: context.readOnly });
868
+ }
869
+ function BuilderSelect(props) {
870
+ const context = useContext(BuilderPrimitiveContext);
871
+ const Component = context.components.Select;
872
+ return /* @__PURE__ */ jsx(Component, { ...props, disabled: context.readOnly || props.disabled === true, readOnly: context.readOnly });
873
+ }
874
+ function BuilderCheckbox(props) {
875
+ const context = useContext(BuilderPrimitiveContext);
876
+ const Component = context.components.Checkbox;
877
+ return /* @__PURE__ */ jsx(Component, { ...props, disabled: context.readOnly || props.disabled === true, readOnly: context.readOnly });
878
+ }
879
+ function BuilderSection(props) {
880
+ const Component = useContext(BuilderPrimitiveContext).components.Section;
881
+ return /* @__PURE__ */ jsx(Component, { ...props });
882
+ }
883
+ function BuilderFieldset(props) {
884
+ const context = useContext(BuilderPrimitiveContext);
885
+ const Component = context.components.Fieldset;
886
+ return /* @__PURE__ */ jsx(Component, { ...props, disabled: context.readOnly || props.disabled === true });
887
+ }
888
+ function BuilderErrorMessage(props) {
889
+ const Component = useContext(BuilderPrimitiveContext).components.ErrorMessage;
890
+ return /* @__PURE__ */ jsx(Component, { ...props });
891
+ }
892
+ var GUARDED_COMPONENTS = {
893
+ Button: BuilderButton,
894
+ IconButton: BuilderIconButton,
895
+ TextInput: BuilderTextInput,
896
+ TextArea: BuilderTextArea,
897
+ Select: BuilderSelect,
898
+ Checkbox: BuilderCheckbox,
899
+ Section: BuilderSection,
900
+ Fieldset: BuilderFieldset,
901
+ ErrorMessage: BuilderErrorMessage
902
+ };
646
903
  var FIELD_TYPES = [
647
904
  "text",
648
905
  "textarea",
@@ -741,37 +998,52 @@ function ConditionValueEditor({
741
998
  source,
742
999
  condition,
743
1000
  onChange,
744
- translate
1001
+ translate,
1002
+ components
745
1003
  }) {
1004
+ const { Select, TextInput } = components;
746
1005
  if (condition.operator === "not_empty") return null;
747
1006
  const update = (value) => onChange({ ...condition, value });
748
1007
  if (source.type === "checkbox") {
749
- return /* @__PURE__ */ jsxs("select", { value: String(condition.value), onChange: (event) => update(event.currentTarget.value === "true"), children: [
750
- /* @__PURE__ */ jsx("option", { value: "true", children: translate("builder.conditionTrue") }),
751
- /* @__PURE__ */ jsx("option", { value: "false", children: translate("builder.conditionFalse") })
752
- ] });
1008
+ return /* @__PURE__ */ jsx(
1009
+ Select,
1010
+ {
1011
+ value: String(condition.value),
1012
+ onChange: (value) => update(value === "true"),
1013
+ options: [
1014
+ { value: "true", label: translate("builder.conditionTrue") },
1015
+ { value: "false", label: translate("builder.conditionFalse") }
1016
+ ]
1017
+ }
1018
+ );
753
1019
  }
754
1020
  if (source.type === "number" || source.type === "rating") {
755
1021
  return /* @__PURE__ */ jsx(
756
- "input",
1022
+ TextInput,
757
1023
  {
758
1024
  "aria-label": translate("builder.conditionValue"),
759
1025
  type: "number",
760
- value: typeof condition.value === "number" ? condition.value : "",
761
- onChange: (event) => update(event.currentTarget.value === "" ? 0 : event.currentTarget.valueAsNumber)
1026
+ value: typeof condition.value === "number" ? String(condition.value) : "",
1027
+ onChange: (value) => update(value === "" ? 0 : Number(value))
762
1028
  }
763
1029
  );
764
1030
  }
765
1031
  if ("options" in source) {
766
- return /* @__PURE__ */ jsx("select", { value: String(condition.value ?? ""), onChange: (event) => update(event.currentTarget.value), children: source.options.map((option) => /* @__PURE__ */ jsx("option", { value: option.id, children: option.label }, option.id)) });
1032
+ return /* @__PURE__ */ jsx(
1033
+ Select,
1034
+ {
1035
+ value: String(condition.value ?? ""),
1036
+ onChange: update,
1037
+ options: source.options.map((option) => ({ value: option.id, label: option.label }))
1038
+ }
1039
+ );
767
1040
  }
768
1041
  return /* @__PURE__ */ jsx(
769
- "input",
1042
+ TextInput,
770
1043
  {
771
1044
  "aria-label": translate("builder.conditionValue"),
772
- type: "text",
773
1045
  value: typeof condition.value === "string" ? condition.value : "",
774
- onChange: (event) => update(event.currentTarget.value)
1046
+ onChange: update
775
1047
  }
776
1048
  );
777
1049
  }
@@ -799,8 +1071,19 @@ function FormBuilder({
799
1071
  onActionError,
800
1072
  createManualTranslationMetadata,
801
1073
  readOnly = false,
802
- features
1074
+ features,
1075
+ components: componentOverrides,
1076
+ slots
803
1077
  }) {
1078
+ const resolvedComponents = { ...DEFAULT_COMPONENTS, ...componentOverrides };
1079
+ const components = GUARDED_COMPONENTS;
1080
+ const { Button, Checkbox, ErrorMessage, Fieldset, IconButton, Section, Select, TextInput } = components;
1081
+ const ToolbarSlot = slots?.toolbar;
1082
+ const FieldEditorSlot = slots?.fieldEditor;
1083
+ const OptionEditorSlot = slots?.optionEditor;
1084
+ const PagesSlot = slots?.pages;
1085
+ const LocalizationSlot = slots?.localization;
1086
+ const TranslationActionsSlot = slots?.translationActions;
804
1087
  const headless = useFormBuilder({
805
1088
  schema,
806
1089
  onChange,
@@ -923,9 +1206,11 @@ function FormBuilder({
923
1206
  setIsTranslating(true);
924
1207
  setTranslationError(null);
925
1208
  try {
1209
+ const translationPolicy = policy ?? translationOptions?.policy;
926
1210
  const populated = await populateSchemaTranslations(schema, [editingLocale], translationAdapter, {
927
1211
  overwrite: "missing-only",
928
- ...translationOptions
1212
+ ...translationOptions,
1213
+ ...translationPolicy === void 0 ? {} : { policy: translationPolicy }
929
1214
  });
930
1215
  onChange(populated.schema);
931
1216
  onTranslationReport?.(populated.report);
@@ -998,8 +1283,81 @@ function FormBuilder({
998
1283
  ]);
999
1284
  const availableAllowedLocales = policy?.allowedLocales?.filter((candidate) => !registeredLocales.has(candidate));
1000
1285
  const localeLimitReached = policy?.maxLocales !== void 0 && registeredLocales.size >= policy.maxLocales;
1001
- return /* @__PURE__ */ jsx(
1002
- "section",
1286
+ const actions = {
1287
+ addField: (type, pageId) => executeAction(() => headless.addField(type, pageId), {
1288
+ action: "addField",
1289
+ ...pageId === void 0 ? { params: { type } } : { targetId: pageId, params: { type, pageId } }
1290
+ }),
1291
+ removeField: (fieldId) => executeAction(() => headless.removeField(fieldId), { action: "removeField", targetId: fieldId }),
1292
+ moveField: (fieldId, targetIndex) => executeAction(() => headless.moveField(fieldId, targetIndex), {
1293
+ action: "moveField",
1294
+ targetId: fieldId,
1295
+ params: { targetIndex }
1296
+ }),
1297
+ updateField: (fieldId, updater) => executeAction(() => headless.updateField(fieldId, updater), { action: "updateField", targetId: fieldId }),
1298
+ changeFieldType: (fieldId, type) => executeAction(() => headless.changeFieldType(fieldId, type), {
1299
+ action: "changeFieldType",
1300
+ targetId: fieldId,
1301
+ params: { type }
1302
+ }),
1303
+ addOption: (fieldId) => executeAction(() => headless.addOption(fieldId), { action: "addOption", targetId: fieldId }),
1304
+ updateOption: (fieldId, optionId, updater) => executeAction(() => headless.updateOption(fieldId, optionId, updater), {
1305
+ action: "updateOption",
1306
+ targetId: optionId,
1307
+ params: { fieldId }
1308
+ }),
1309
+ removeOption: (fieldId, optionId) => executeAction(() => headless.removeOption(fieldId, optionId), {
1310
+ action: "removeOption",
1311
+ targetId: optionId,
1312
+ params: { fieldId }
1313
+ }),
1314
+ moveOption: (fieldId, optionId, targetIndex) => executeAction(() => headless.moveOption(fieldId, optionId, targetIndex), {
1315
+ action: "moveOption",
1316
+ targetId: optionId,
1317
+ params: { fieldId, targetIndex }
1318
+ }),
1319
+ addPage: (questionId) => executeAction(() => headless.addPage(questionId), {
1320
+ action: "addPage",
1321
+ ...questionId === void 0 ? {} : { targetId: questionId, params: { questionId } }
1322
+ }),
1323
+ updatePage: (pageId, updater) => executeAction(() => headless.updatePage(pageId, updater), { action: "updatePage", targetId: pageId }),
1324
+ removePage: (pageId) => executeAction(() => headless.removePage(pageId), { action: "removePage", targetId: pageId }),
1325
+ movePage: (pageId, targetIndex) => executeAction(() => headless.movePage(pageId, targetIndex), {
1326
+ action: "movePage",
1327
+ targetId: pageId,
1328
+ params: { targetIndex }
1329
+ }),
1330
+ assignFieldToPage: (fieldId, pageId) => executeAction(() => headless.assignFieldToPage(fieldId, pageId), {
1331
+ action: "assignFieldToPage",
1332
+ targetId: fieldId,
1333
+ params: { pageId }
1334
+ }),
1335
+ setDisplayCondition: (fieldId, condition) => executeAction(() => headless.setDisplayCondition(fieldId, condition), {
1336
+ action: "setDisplayCondition",
1337
+ targetId: fieldId,
1338
+ ...condition === void 0 ? {} : { params: { condition } }
1339
+ }),
1340
+ setSourceText: (target, property, text) => executeAction(() => headless.setSourceText(target, property, text), {
1341
+ action: "setSourceText",
1342
+ ...target.id === void 0 ? {} : { targetId: target.id },
1343
+ params: { property, text }
1344
+ }),
1345
+ setLocaleTranslation: (targetLocale, target, property, text, options) => executeAction(() => headless.setLocaleTranslation(targetLocale, target, property, text, options), {
1346
+ action: "setLocaleTranslation",
1347
+ ...target.id === void 0 ? {} : { targetId: target.id },
1348
+ params: { locale: targetLocale, property }
1349
+ }),
1350
+ addLocale: (targetLocale) => executeAction(() => headless.addLocale(targetLocale), {
1351
+ action: "addLocale",
1352
+ params: { locale: targetLocale }
1353
+ }),
1354
+ setDefaultLocale: (targetLocale) => executeAction(() => headless.setDefaultLocale(targetLocale), {
1355
+ action: "setDefaultLocale",
1356
+ params: { locale: targetLocale }
1357
+ })
1358
+ };
1359
+ return /* @__PURE__ */ jsx(BuilderPrimitiveContext.Provider, { value: { components: resolvedComponents, readOnly }, children: /* @__PURE__ */ jsx(
1360
+ Section,
1003
1361
  {
1004
1362
  className: `form-engine-builder ${className}`.trim(),
1005
1363
  "aria-label": translate("builder.formBuilder"),
@@ -1018,362 +1376,451 @@ function FormBuilder({
1018
1376
  addOption(fieldId);
1019
1377
  }
1020
1378
  },
1021
- children: /* @__PURE__ */ jsxs("fieldset", { className: "form-engine-builder__controls", disabled: readOnly, children: [
1022
- pagesEnabled ? /* @__PURE__ */ jsxs("section", { className: "form-engine-builder__pages", "aria-labelledby": "builder-pages-heading", children: [
1023
- /* @__PURE__ */ jsx("h2", { id: "builder-pages-heading", children: translate("builder.pages") }),
1024
- schema.pages === void 0 ? /* @__PURE__ */ jsx("button", { type: "button", onClick: enablePages, children: translate("builder.enablePages") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1025
- schema.pages.map((page, pageIndex) => {
1026
- const priorQuestionIds = new Set(
1027
- schema.pages?.slice(0, pageIndex).flatMap((item) => item.questionIds)
1028
- );
1029
- const availableSources = schema.fields.filter((field) => priorQuestionIds.has(field.id));
1030
- const source = schema.fields.find((field) => field.id === page.displayCondition?.questionId);
1031
- return /* @__PURE__ */ jsxs("fieldset", { className: "form-engine-builder__page", children: [
1032
- /* @__PURE__ */ jsx("legend", { children: page.title ?? `${translate("builder.newPage")} ${pageIndex + 1}` }),
1033
- /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__toolbar", children: [
1379
+ children: /* @__PURE__ */ jsxs(Fieldset, { className: "form-engine-builder__controls", disabled: readOnly, children: [
1380
+ pagesEnabled ? PagesSlot === void 0 ? /* @__PURE__ */ jsx(
1381
+ Section,
1382
+ {
1383
+ className: "form-engine-builder__pages",
1384
+ headingId: "builder-pages-heading",
1385
+ title: translate("builder.pages"),
1386
+ children: schema.pages === void 0 ? /* @__PURE__ */ jsx(Button, { onClick: enablePages, children: translate("builder.enablePages") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1387
+ schema.pages.map((page, pageIndex) => {
1388
+ const priorQuestionIds = new Set(
1389
+ schema.pages?.slice(0, pageIndex).flatMap((item) => item.questionIds)
1390
+ );
1391
+ const availableSources = schema.fields.filter((field) => priorQuestionIds.has(field.id));
1392
+ const source = schema.fields.find((field) => field.id === page.displayCondition?.questionId);
1393
+ return /* @__PURE__ */ jsxs(
1394
+ Fieldset,
1395
+ {
1396
+ className: "form-engine-builder__page",
1397
+ legend: page.title ?? `${translate("builder.newPage")} ${pageIndex + 1}`,
1398
+ children: [
1399
+ /* @__PURE__ */ jsx("div", { className: "form-engine-builder__toolbar", children: ToolbarSlot === void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1400
+ /* @__PURE__ */ jsx(
1401
+ IconButton,
1402
+ {
1403
+ icon: "\u2191",
1404
+ title: translate("builder.moveUp", { title: page.title ?? page.id }),
1405
+ disabled: pageIndex === 0,
1406
+ onClick: () => movePage(pageIndex, -1)
1407
+ }
1408
+ ),
1409
+ /* @__PURE__ */ jsx(
1410
+ IconButton,
1411
+ {
1412
+ icon: "\u2193",
1413
+ title: translate("builder.moveDown", { title: page.title ?? page.id }),
1414
+ disabled: pageIndex === (schema.pages?.length ?? 0) - 1,
1415
+ onClick: () => movePage(pageIndex, 1)
1416
+ }
1417
+ ),
1418
+ /* @__PURE__ */ jsx(Button, { onClick: () => removePage(pageIndex), variant: "danger", children: translate("builder.deleteAction") })
1419
+ ] }) : /* @__PURE__ */ jsx(
1420
+ ToolbarSlot,
1421
+ {
1422
+ schema,
1423
+ kind: "page",
1424
+ targetId: page.id,
1425
+ index: pageIndex,
1426
+ total: schema.pages?.length ?? 0,
1427
+ title: page.title ?? page.id,
1428
+ onMoveUp: () => movePage(pageIndex, -1),
1429
+ onMoveDown: () => movePage(pageIndex, 1),
1430
+ onRemove: () => removePage(pageIndex),
1431
+ readOnly,
1432
+ actions,
1433
+ components
1434
+ }
1435
+ ) }),
1436
+ /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1437
+ /* @__PURE__ */ jsxs("label", { children: [
1438
+ translate("builder.pageTitle"),
1439
+ /* @__PURE__ */ jsx(
1440
+ TextInput,
1441
+ {
1442
+ value: page.title ?? "",
1443
+ onChange: (value) => {
1444
+ updatePage(page.id, (current) => {
1445
+ if (value.length > 0) return { ...current, title: value };
1446
+ const { title: _title, ...withoutTitle } = current;
1447
+ return withoutTitle;
1448
+ });
1449
+ }
1450
+ }
1451
+ )
1452
+ ] }),
1453
+ /* @__PURE__ */ jsxs("label", { children: [
1454
+ translate("builder.pageDescription"),
1455
+ /* @__PURE__ */ jsx(
1456
+ TextInput,
1457
+ {
1458
+ value: page.description ?? "",
1459
+ onChange: (value) => {
1460
+ updatePage(page.id, (current) => {
1461
+ if (value.length > 0) return { ...current, description: value };
1462
+ const { description: _description, ...withoutDescription } = current;
1463
+ return withoutDescription;
1464
+ });
1465
+ }
1466
+ }
1467
+ )
1468
+ ] })
1469
+ ] }),
1470
+ !localizationEnabled || editingLocale.length === 0 ? null : /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__translation-editor", children: [
1471
+ /* @__PURE__ */ jsx("strong", { children: editingLocale }),
1472
+ /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1473
+ /* @__PURE__ */ jsxs("label", { children: [
1474
+ translate("builder.pageTitle"),
1475
+ /* @__PURE__ */ jsx(
1476
+ TextInput,
1477
+ {
1478
+ value: page.translations?.[editingLocale]?.title ?? "",
1479
+ onChange: (value) => updateManualTranslation({
1480
+ locale: editingLocale,
1481
+ kind: "page",
1482
+ nodeId: page.id,
1483
+ property: "title",
1484
+ sourceText: page.title ?? "",
1485
+ translatedText: value,
1486
+ ...page.translationMetadata?.[editingLocale]?.title === void 0 ? {} : {
1487
+ existingTranslationMetadata: page.translationMetadata[editingLocale]?.title
1488
+ }
1489
+ })
1490
+ }
1491
+ )
1492
+ ] }),
1493
+ /* @__PURE__ */ jsxs("label", { children: [
1494
+ translate("builder.pageDescription"),
1495
+ /* @__PURE__ */ jsx(
1496
+ TextInput,
1497
+ {
1498
+ value: page.translations?.[editingLocale]?.description ?? "",
1499
+ onChange: (value) => updateManualTranslation({
1500
+ locale: editingLocale,
1501
+ kind: "page",
1502
+ nodeId: page.id,
1503
+ property: "description",
1504
+ sourceText: page.description ?? "",
1505
+ translatedText: value,
1506
+ ...page.translationMetadata?.[editingLocale]?.description === void 0 ? {} : {
1507
+ existingTranslationMetadata: page.translationMetadata[editingLocale]?.description
1508
+ }
1509
+ })
1510
+ }
1511
+ )
1512
+ ] })
1513
+ ] })
1514
+ ] }),
1515
+ conditionsEnabled ? /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__condition", children: [
1516
+ /* @__PURE__ */ jsxs("label", { children: [
1517
+ translate("builder.pageCondition"),
1518
+ /* @__PURE__ */ jsx(
1519
+ Select,
1520
+ {
1521
+ value: page.displayCondition?.questionId ?? "",
1522
+ onChange: (value) => {
1523
+ const selected = schema.fields.find((field) => field.id === value);
1524
+ updatePage(page.id, (current) => {
1525
+ if (selected === void 0) {
1526
+ const { displayCondition: _condition, ...withoutCondition } = current;
1527
+ return withoutCondition;
1528
+ }
1529
+ return {
1530
+ ...current,
1531
+ displayCondition: conditionWithValue(
1532
+ selected.id,
1533
+ conditionOperators(selected)[0] ?? "not_empty",
1534
+ defaultConditionValue(selected)
1535
+ )
1536
+ };
1537
+ });
1538
+ },
1539
+ options: [
1540
+ { value: "", label: translate("builder.alwaysVisible") },
1541
+ ...availableSources.map((field) => ({ value: field.id, label: field.title }))
1542
+ ]
1543
+ }
1544
+ )
1545
+ ] }),
1546
+ page.displayCondition !== void 0 && source !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1547
+ /* @__PURE__ */ jsx(
1548
+ Select,
1549
+ {
1550
+ "aria-label": translate("builder.conditionOperator"),
1551
+ value: page.displayCondition.operator,
1552
+ onChange: (value) => {
1553
+ const operator = value;
1554
+ updatePage(page.id, (current) => ({
1555
+ ...current,
1556
+ displayCondition: conditionWithValue(
1557
+ source.id,
1558
+ operator,
1559
+ defaultConditionValue(source)
1560
+ )
1561
+ }));
1562
+ },
1563
+ options: conditionOperators(source).map((operator) => ({
1564
+ value: operator,
1565
+ label: translate(operatorKey(operator))
1566
+ }))
1567
+ }
1568
+ ),
1569
+ /* @__PURE__ */ jsx(
1570
+ ConditionValueEditor,
1571
+ {
1572
+ source,
1573
+ condition: page.displayCondition,
1574
+ onChange: (condition) => updatePage(page.id, (current) => ({ ...current, displayCondition: condition })),
1575
+ translate,
1576
+ components
1577
+ }
1578
+ )
1579
+ ] }) : null
1580
+ ] }) : null
1581
+ ]
1582
+ },
1583
+ page.id
1584
+ );
1585
+ }),
1586
+ /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__page-add", children: [
1587
+ /* @__PURE__ */ jsxs("label", { children: [
1588
+ translate("builder.pageQuestion"),
1034
1589
  /* @__PURE__ */ jsx(
1035
- "button",
1590
+ Select,
1036
1591
  {
1037
- type: "button",
1038
- disabled: pageIndex === 0,
1039
- "aria-label": translate("builder.moveUp", { title: page.title ?? page.id }),
1040
- onClick: () => movePage(pageIndex, -1),
1041
- children: "\u2191"
1592
+ value: newPageQuestionId,
1593
+ disabled: movablePageQuestions.length === 0,
1594
+ onChange: setNewPageQuestionId,
1595
+ options: [
1596
+ { value: "", label: "\u2014" },
1597
+ ...schema.fields.filter((field) => movablePageQuestions.includes(field.id)).map((field) => ({ value: field.id, label: field.title }))
1598
+ ]
1042
1599
  }
1043
- ),
1044
- /* @__PURE__ */ jsx(
1045
- "button",
1600
+ )
1601
+ ] }),
1602
+ /* @__PURE__ */ jsx(Button, { disabled: movablePageQuestions.length === 0, onClick: addPage, children: translate("builder.addPage") })
1603
+ ] })
1604
+ ] })
1605
+ }
1606
+ ) : /* @__PURE__ */ jsx(
1607
+ PagesSlot,
1608
+ {
1609
+ schema,
1610
+ currentLocale: editingLocale,
1611
+ readOnly,
1612
+ actions,
1613
+ components
1614
+ }
1615
+ ) : null,
1616
+ localizationEnabled ? LocalizationSlot === void 0 ? /* @__PURE__ */ jsxs(
1617
+ Section,
1618
+ {
1619
+ className: "form-engine-builder__localization",
1620
+ headingId: "builder-localization-heading",
1621
+ title: translate("builder.localization"),
1622
+ children: [
1623
+ /* @__PURE__ */ jsxs("label", { children: [
1624
+ translate("builder.completionMessage"),
1625
+ /* @__PURE__ */ jsx(
1626
+ TextInput,
1627
+ {
1628
+ value: schema.completionMessage ?? "",
1629
+ onChange: (value) => setSourceText({ kind: "form" }, "completionMessage", value)
1630
+ }
1631
+ )
1632
+ ] }),
1633
+ /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1634
+ /* @__PURE__ */ jsxs("label", { children: [
1635
+ translate("builder.defaultLocale"),
1636
+ /* @__PURE__ */ jsx(TextInput, { value: schema.defaultLocale ?? "", onChange: setDefaultLocale })
1637
+ ] }),
1638
+ /* @__PURE__ */ jsxs("label", { htmlFor: "builder-new-locale", children: [
1639
+ translate("builder.addLocale"),
1640
+ availableAllowedLocales === void 0 ? /* @__PURE__ */ jsx(TextInput, { id: "builder-new-locale", value: newLocale, onChange: setNewLocale }) : /* @__PURE__ */ jsx(
1641
+ Select,
1046
1642
  {
1047
- type: "button",
1048
- disabled: pageIndex === (schema.pages?.length ?? 0) - 1,
1049
- "aria-label": translate("builder.moveDown", { title: page.title ?? page.id }),
1050
- onClick: () => movePage(pageIndex, 1),
1051
- children: "\u2193"
1643
+ id: "builder-new-locale",
1644
+ value: newLocale,
1645
+ onChange: setNewLocale,
1646
+ options: [
1647
+ { value: "", label: "\u2014" },
1648
+ ...availableAllowedLocales.map((candidate) => ({ value: candidate, label: candidate }))
1649
+ ]
1052
1650
  }
1053
- ),
1054
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => removePage(pageIndex), children: translate("builder.deleteAction") })
1055
- ] }),
1056
- /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1057
- /* @__PURE__ */ jsxs("label", { children: [
1058
- translate("builder.pageTitle"),
1059
- /* @__PURE__ */ jsx(
1060
- "input",
1061
- {
1062
- value: page.title ?? "",
1063
- onChange: (event) => {
1064
- const value = event.currentTarget.value;
1065
- updatePage(page.id, (current) => {
1066
- if (value.length > 0) return { ...current, title: value };
1067
- const { title: _title, ...withoutTitle } = current;
1068
- return withoutTitle;
1069
- });
1070
- }
1071
- }
1072
- )
1073
- ] }),
1074
- /* @__PURE__ */ jsxs("label", { children: [
1075
- translate("builder.pageDescription"),
1076
- /* @__PURE__ */ jsx(
1077
- "input",
1078
- {
1079
- value: page.description ?? "",
1080
- onChange: (event) => {
1081
- const value = event.currentTarget.value;
1082
- updatePage(page.id, (current) => {
1083
- if (value.length > 0) return { ...current, description: value };
1084
- const { description: _description, ...withoutDescription } = current;
1085
- return withoutDescription;
1086
- });
1087
- }
1088
- }
1089
- )
1090
- ] })
1651
+ )
1091
1652
  ] }),
1092
- !localizationEnabled || editingLocale.length === 0 ? null : /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__translation-editor", children: [
1093
- /* @__PURE__ */ jsx("strong", { children: editingLocale }),
1094
- /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1095
- /* @__PURE__ */ jsxs("label", { children: [
1096
- translate("builder.pageTitle"),
1097
- /* @__PURE__ */ jsx(
1098
- "input",
1099
- {
1100
- value: page.translations?.[editingLocale]?.title ?? "",
1101
- onChange: (event) => updateManualTranslation({
1102
- locale: editingLocale,
1103
- kind: "page",
1104
- nodeId: page.id,
1105
- property: "title",
1106
- sourceText: page.title ?? "",
1107
- translatedText: event.currentTarget.value,
1108
- ...page.translationMetadata?.[editingLocale]?.title === void 0 ? {} : {
1109
- existingTranslationMetadata: page.translationMetadata[editingLocale]?.title
1110
- }
1111
- })
1112
- }
1113
- )
1114
- ] }),
1115
- /* @__PURE__ */ jsxs("label", { children: [
1116
- translate("builder.pageDescription"),
1117
- /* @__PURE__ */ jsx(
1118
- "input",
1119
- {
1120
- value: page.translations?.[editingLocale]?.description ?? "",
1121
- onChange: (event) => updateManualTranslation({
1122
- locale: editingLocale,
1123
- kind: "page",
1124
- nodeId: page.id,
1125
- property: "description",
1126
- sourceText: page.description ?? "",
1127
- translatedText: event.currentTarget.value,
1128
- ...page.translationMetadata?.[editingLocale]?.description === void 0 ? {} : {
1129
- existingTranslationMetadata: page.translationMetadata[editingLocale]?.description
1130
- }
1131
- })
1132
- }
1133
- )
1134
- ] })
1135
- ] })
1653
+ /* @__PURE__ */ jsx(
1654
+ Button,
1655
+ {
1656
+ action: "addLocale",
1657
+ disabled: newLocale.trim().length === 0 || localeLimitReached,
1658
+ onClick: addLocale,
1659
+ children: translate("builder.addLocale")
1660
+ }
1661
+ ),
1662
+ /* @__PURE__ */ jsxs("label", { children: [
1663
+ translate("builder.editLocale"),
1664
+ /* @__PURE__ */ jsx(
1665
+ Select,
1666
+ {
1667
+ value: editingLocale,
1668
+ onChange: setEditingLocale,
1669
+ options: [
1670
+ { value: "", label: "\u2014" },
1671
+ ...(schema.supportedLocales ?? []).filter((item) => item !== schema.defaultLocale).map((item) => ({ value: item, label: item }))
1672
+ ]
1673
+ }
1674
+ )
1136
1675
  ] }),
1137
- conditionsEnabled ? /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__condition", children: [
1138
- /* @__PURE__ */ jsxs("label", { children: [
1139
- translate("builder.pageCondition"),
1140
- /* @__PURE__ */ jsxs(
1141
- "select",
1142
- {
1143
- value: page.displayCondition?.questionId ?? "",
1144
- onChange: (event) => {
1145
- const selected = schema.fields.find((field) => field.id === event.currentTarget.value);
1146
- updatePage(page.id, (current) => {
1147
- if (selected === void 0) {
1148
- const { displayCondition: _condition, ...withoutCondition } = current;
1149
- return withoutCondition;
1150
- }
1151
- return {
1152
- ...current,
1153
- displayCondition: conditionWithValue(
1154
- selected.id,
1155
- conditionOperators(selected)[0] ?? "not_empty",
1156
- defaultConditionValue(selected)
1157
- )
1158
- };
1159
- });
1160
- },
1161
- children: [
1162
- /* @__PURE__ */ jsx("option", { value: "", children: translate("builder.alwaysVisible") }),
1163
- availableSources.map((field) => /* @__PURE__ */ jsx("option", { value: field.id, children: field.title }, field.id))
1164
- ]
1165
- }
1166
- )
1167
- ] }),
1168
- page.displayCondition !== void 0 && source !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1169
- /* @__PURE__ */ jsx(
1170
- "select",
1171
- {
1172
- "aria-label": translate("builder.conditionOperator"),
1173
- value: page.displayCondition.operator,
1174
- onChange: (event) => {
1175
- const operator = event.currentTarget.value;
1176
- updatePage(page.id, (current) => ({
1177
- ...current,
1178
- displayCondition: conditionWithValue(
1179
- source.id,
1180
- operator,
1181
- defaultConditionValue(source)
1182
- )
1183
- }));
1184
- },
1185
- children: conditionOperators(source).map((operator) => /* @__PURE__ */ jsx("option", { value: operator, children: translate(operatorKey(operator)) }, operator))
1186
- }
1187
- ),
1188
- /* @__PURE__ */ jsx(
1189
- ConditionValueEditor,
1190
- {
1191
- source,
1192
- condition: page.displayCondition,
1193
- onChange: (condition) => updatePage(page.id, (current) => ({ ...current, displayCondition: condition })),
1194
- translate
1195
- }
1196
- )
1197
- ] }) : null
1198
- ] }) : null
1199
- ] }, page.id);
1200
- }),
1201
- /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__page-add", children: [
1202
- /* @__PURE__ */ jsxs("label", { children: [
1203
- translate("builder.pageQuestion"),
1204
- /* @__PURE__ */ jsxs(
1205
- "select",
1676
+ TranslationActionsSlot === void 0 ? /* @__PURE__ */ jsx(
1677
+ Button,
1206
1678
  {
1207
- value: newPageQuestionId,
1208
- disabled: movablePageQuestions.length === 0,
1209
- onChange: (event) => setNewPageQuestionId(event.currentTarget.value),
1210
- children: [
1211
- /* @__PURE__ */ jsx("option", { value: "", children: "\u2014" }),
1212
- schema.fields.filter((field) => movablePageQuestions.includes(field.id)).map((field) => /* @__PURE__ */ jsx("option", { value: field.id, children: field.title }, field.id))
1213
- ]
1679
+ disabled: translationAdapter === void 0 || editingLocale.length === 0 || isTranslating,
1680
+ onClick: () => void translateAll(),
1681
+ children: translate("builder.autoTranslate")
1682
+ }
1683
+ ) : /* @__PURE__ */ jsx(
1684
+ TranslationActionsSlot,
1685
+ {
1686
+ schema,
1687
+ currentLocale: editingLocale,
1688
+ onAutoTranslate: () => void translateAll(),
1689
+ isTranslating,
1690
+ readOnly,
1691
+ actions,
1692
+ components
1214
1693
  }
1215
1694
  )
1216
1695
  ] }),
1217
- /* @__PURE__ */ jsx("button", { type: "button", disabled: movablePageQuestions.length === 0, onClick: addPage, children: translate("builder.addPage") })
1218
- ] })
1219
- ] })
1220
- ] }) : null,
1221
- localizationEnabled ? /* @__PURE__ */ jsxs("section", { className: "form-engine-builder__localization", "aria-labelledby": "builder-localization-heading", children: [
1222
- /* @__PURE__ */ jsx("h2", { id: "builder-localization-heading", children: translate("builder.localization") }),
1223
- /* @__PURE__ */ jsxs("label", { children: [
1224
- translate("builder.completionMessage"),
1225
- /* @__PURE__ */ jsx(
1226
- "input",
1227
- {
1228
- value: schema.completionMessage ?? "",
1229
- onChange: (event) => setSourceText({ kind: "form" }, "completionMessage", event.currentTarget.value)
1230
- }
1231
- )
1232
- ] }),
1233
- /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1234
- /* @__PURE__ */ jsxs("label", { children: [
1235
- translate("builder.defaultLocale"),
1236
- /* @__PURE__ */ jsx(
1237
- "input",
1238
- {
1239
- value: schema.defaultLocale ?? "",
1240
- onChange: (event) => setDefaultLocale(event.currentTarget.value)
1241
- }
1242
- )
1243
- ] }),
1244
- /* @__PURE__ */ jsxs("label", { htmlFor: "builder-new-locale", children: [
1245
- translate("builder.addLocale"),
1246
- availableAllowedLocales === void 0 ? /* @__PURE__ */ jsx(
1247
- "input",
1248
- {
1249
- id: "builder-new-locale",
1250
- value: newLocale,
1251
- onChange: (event) => setNewLocale(event.currentTarget.value)
1252
- }
1253
- ) : /* @__PURE__ */ jsxs(
1254
- "select",
1255
- {
1256
- id: "builder-new-locale",
1257
- value: newLocale,
1258
- onChange: (event) => setNewLocale(event.currentTarget.value),
1259
- children: [
1260
- /* @__PURE__ */ jsx("option", { value: "", children: "\u2014" }),
1261
- availableAllowedLocales.map((candidate) => /* @__PURE__ */ jsx("option", { value: candidate, children: candidate }, candidate))
1262
- ]
1263
- }
1264
- )
1265
- ] }),
1266
- /* @__PURE__ */ jsx(
1267
- "button",
1268
- {
1269
- type: "button",
1270
- "data-builder-action": "addLocale",
1271
- disabled: newLocale.trim().length === 0 || localeLimitReached,
1272
- onClick: addLocale,
1273
- children: translate("builder.addLocale")
1274
- }
1275
- ),
1276
- /* @__PURE__ */ jsxs("label", { children: [
1277
- translate("builder.editLocale"),
1278
- /* @__PURE__ */ jsxs("select", { value: editingLocale, onChange: (event) => setEditingLocale(event.currentTarget.value), children: [
1279
- /* @__PURE__ */ jsx("option", { value: "", children: "\u2014" }),
1280
- (schema.supportedLocales ?? []).filter((item) => item !== schema.defaultLocale).map((item) => /* @__PURE__ */ jsx("option", { value: item, children: item }, item))
1696
+ translationAdapter === void 0 ? /* @__PURE__ */ jsx("p", { children: translate("builder.translationUnavailable") }) : null,
1697
+ translationError === null ? null : /* @__PURE__ */ jsx(ErrorMessage, { message: translationError }),
1698
+ editingLocale.length === 0 ? null : /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1699
+ /* @__PURE__ */ jsxs("label", { children: [
1700
+ translate("builder.questionTitle"),
1701
+ /* @__PURE__ */ jsx(
1702
+ TextInput,
1703
+ {
1704
+ value: schema.translations?.[editingLocale]?.title ?? "",
1705
+ onChange: (value) => updateFormTranslation("title", value)
1706
+ }
1707
+ )
1708
+ ] }),
1709
+ /* @__PURE__ */ jsxs("label", { children: [
1710
+ translate("builder.pageDescription"),
1711
+ /* @__PURE__ */ jsx(
1712
+ TextInput,
1713
+ {
1714
+ value: schema.translations?.[editingLocale]?.description ?? "",
1715
+ onChange: (value) => updateFormTranslation("description", value)
1716
+ }
1717
+ )
1718
+ ] }),
1719
+ /* @__PURE__ */ jsxs("label", { children: [
1720
+ translate("builder.completionMessage"),
1721
+ /* @__PURE__ */ jsx(
1722
+ TextInput,
1723
+ {
1724
+ value: schema.translations?.[editingLocale]?.completionMessage ?? "",
1725
+ onChange: (value) => updateFormTranslation("completionMessage", value)
1726
+ }
1727
+ )
1728
+ ] })
1281
1729
  ] })
1282
- ] }),
1283
- /* @__PURE__ */ jsx(
1284
- "button",
1285
- {
1286
- type: "button",
1287
- disabled: translationAdapter === void 0 || editingLocale.length === 0 || isTranslating,
1288
- onClick: () => void translateAll(),
1289
- children: translate("builder.autoTranslate")
1290
- }
1291
- )
1292
- ] }),
1293
- translationAdapter === void 0 ? /* @__PURE__ */ jsx("p", { children: translate("builder.translationUnavailable") }) : null,
1294
- translationError === null ? null : /* @__PURE__ */ jsx("p", { className: "form-engine-builder__error", children: translationError }),
1295
- editingLocale.length === 0 ? null : /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1296
- /* @__PURE__ */ jsxs("label", { children: [
1297
- translate("builder.questionTitle"),
1298
- /* @__PURE__ */ jsx(
1299
- "input",
1300
- {
1301
- value: schema.translations?.[editingLocale]?.title ?? "",
1302
- onChange: (event) => updateFormTranslation("title", event.currentTarget.value)
1303
- }
1304
- )
1305
- ] }),
1306
- /* @__PURE__ */ jsxs("label", { children: [
1307
- translate("builder.pageDescription"),
1308
- /* @__PURE__ */ jsx(
1309
- "input",
1310
- {
1311
- value: schema.translations?.[editingLocale]?.description ?? "",
1312
- onChange: (event) => updateFormTranslation("description", event.currentTarget.value)
1313
- }
1314
- )
1315
- ] }),
1316
- /* @__PURE__ */ jsxs("label", { children: [
1317
- translate("builder.completionMessage"),
1318
- /* @__PURE__ */ jsx(
1319
- "input",
1320
- {
1321
- value: schema.translations?.[editingLocale]?.completionMessage ?? "",
1322
- onChange: (event) => updateFormTranslation("completionMessage", event.currentTarget.value)
1323
- }
1324
- )
1325
- ] })
1326
- ] })
1327
- ] }) : null,
1730
+ ]
1731
+ }
1732
+ ) : /* @__PURE__ */ jsx(
1733
+ LocalizationSlot,
1734
+ {
1735
+ schema,
1736
+ currentLocale: editingLocale,
1737
+ onCurrentLocaleChange: setEditingLocale,
1738
+ onAutoTranslate: () => void translateAll(),
1739
+ isTranslating,
1740
+ ...translationError === null ? {} : { translationError },
1741
+ readOnly,
1742
+ actions,
1743
+ components
1744
+ }
1745
+ ) : null,
1328
1746
  /* @__PURE__ */ jsx("div", { className: "form-engine-builder__list", children: schema.fields.map((field, index) => {
1329
1747
  const condition = field.displayCondition;
1330
1748
  const source = condition === void 0 ? void 0 : schema.fields.find((item) => item.id === condition.questionId);
1331
1749
  const availableSources = schema.fields.slice(0, index);
1332
- return /* @__PURE__ */ jsxs("fieldset", { className: "form-engine-builder__question", children: [
1333
- /* @__PURE__ */ jsx("legend", { children: field.title }),
1334
- /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__toolbar", children: [
1750
+ if (FieldEditorSlot !== void 0) {
1751
+ return /* @__PURE__ */ jsx(
1752
+ FieldEditorSlot,
1753
+ {
1754
+ schema,
1755
+ field,
1756
+ index,
1757
+ currentLocale: editingLocale,
1758
+ ...policy === void 0 ? {} : { policy },
1759
+ readOnly,
1760
+ actions,
1761
+ components
1762
+ },
1763
+ field.id
1764
+ );
1765
+ }
1766
+ return /* @__PURE__ */ jsxs(Fieldset, { className: "form-engine-builder__question", legend: field.title, children: [
1767
+ /* @__PURE__ */ jsx("div", { className: "form-engine-builder__toolbar", children: ToolbarSlot === void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1335
1768
  /* @__PURE__ */ jsx(
1336
- "button",
1769
+ IconButton,
1337
1770
  {
1338
- type: "button",
1771
+ icon: "\u2191",
1772
+ title: translate("builder.moveUp", { title: field.title }),
1339
1773
  disabled: index === 0,
1340
- onClick: () => moveField(index, -1),
1341
- "aria-label": translate("builder.moveUp", { title: field.title }),
1342
- children: "\u2191"
1774
+ onClick: () => moveField(index, -1)
1343
1775
  }
1344
1776
  ),
1345
1777
  /* @__PURE__ */ jsx(
1346
- "button",
1778
+ IconButton,
1347
1779
  {
1348
- type: "button",
1780
+ icon: "\u2193",
1781
+ title: translate("builder.moveDown", { title: field.title }),
1349
1782
  disabled: index === schema.fields.length - 1,
1350
- onClick: () => moveField(index, 1),
1351
- "aria-label": translate("builder.moveDown", { title: field.title }),
1352
- children: "\u2193"
1783
+ onClick: () => moveField(index, 1)
1353
1784
  }
1354
1785
  ),
1355
1786
  /* @__PURE__ */ jsx(
1356
- "button",
1787
+ Button,
1357
1788
  {
1358
- type: "button",
1359
1789
  disabled: schema.fields.length === 1,
1360
1790
  onClick: () => removeField(field.id),
1361
1791
  "aria-label": translate("builder.delete", { title: field.title }),
1792
+ variant: "danger",
1362
1793
  children: translate("builder.deleteAction")
1363
1794
  }
1364
1795
  )
1365
- ] }),
1796
+ ] }) : /* @__PURE__ */ jsx(
1797
+ ToolbarSlot,
1798
+ {
1799
+ schema,
1800
+ kind: "field",
1801
+ targetId: field.id,
1802
+ index,
1803
+ total: schema.fields.length,
1804
+ title: field.title,
1805
+ onMoveUp: () => moveField(index, -1),
1806
+ onMoveDown: () => moveField(index, 1),
1807
+ onRemove: () => removeField(field.id),
1808
+ readOnly,
1809
+ actions,
1810
+ components
1811
+ }
1812
+ ) }),
1366
1813
  /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__grid", children: [
1367
1814
  /* @__PURE__ */ jsxs("label", { children: [
1368
1815
  translate("builder.questionTitle"),
1369
1816
  /* @__PURE__ */ jsx(
1370
- "input",
1817
+ TextInput,
1371
1818
  {
1372
1819
  value: field.title,
1373
1820
  placeholder: translate("builder.questionTitlePlaceholder"),
1374
- onChange: (event) => updateField(field.id, (current) => ({
1821
+ onChange: (value) => updateField(field.id, (current) => ({
1375
1822
  ...current,
1376
- title: event.currentTarget.value.trim().length === 0 ? current.title : event.currentTarget.value
1823
+ title: value.trim().length === 0 ? current.title : value
1377
1824
  }))
1378
1825
  }
1379
1826
  )
@@ -1381,36 +1828,37 @@ function FormBuilder({
1381
1828
  /* @__PURE__ */ jsxs("label", { children: [
1382
1829
  translate("builder.type"),
1383
1830
  /* @__PURE__ */ jsx(
1384
- "select",
1831
+ Select,
1385
1832
  {
1386
1833
  value: field.type,
1387
- onChange: (event) => changeType(field.id, event.currentTarget.value),
1388
- children: FIELD_TYPES.filter(
1834
+ onChange: (value) => changeType(field.id, value),
1835
+ options: FIELD_TYPES.filter(
1389
1836
  (type) => policy?.allowedFieldTypes === void 0 || policy.allowedFieldTypes.includes(type)
1390
- ).map((type) => /* @__PURE__ */ jsx("option", { value: type, children: translate(fieldTypeKey(type)) }, type))
1837
+ ).map((type) => ({ value: type, label: translate(fieldTypeKey(type)) }))
1391
1838
  }
1392
1839
  )
1393
1840
  ] }),
1394
- /* @__PURE__ */ jsxs("label", { className: "form-engine-builder__check", children: [
1395
- /* @__PURE__ */ jsx(
1396
- "input",
1397
- {
1398
- type: "checkbox",
1399
- checked: field.required === true,
1400
- onChange: (event) => updateField(field.id, (current) => ({ ...current, required: event.currentTarget.checked }))
1401
- }
1402
- ),
1403
- translate("builder.required")
1404
- ] })
1841
+ /* @__PURE__ */ jsx(
1842
+ Checkbox,
1843
+ {
1844
+ className: "form-engine-builder__check",
1845
+ checked: field.required === true,
1846
+ onChange: (checked) => updateField(field.id, (current) => ({ ...current, required: checked })),
1847
+ label: translate("builder.required")
1848
+ }
1849
+ )
1405
1850
  ] }),
1406
1851
  !pagesEnabled || schema.pages === void 0 ? null : /* @__PURE__ */ jsxs("label", { children: [
1407
1852
  translate("builder.questionPage"),
1408
1853
  /* @__PURE__ */ jsx(
1409
- "select",
1854
+ Select,
1410
1855
  {
1411
1856
  value: pageForField(field.id)?.id ?? "",
1412
- onChange: (event) => assignFieldToPage(field.id, event.currentTarget.value),
1413
- children: schema.pages.map((page, pageIndex) => /* @__PURE__ */ jsx("option", { value: page.id, children: page.title ?? `${translate("builder.newPage")} ${pageIndex + 1}` }, page.id))
1857
+ onChange: (value) => assignFieldToPage(field.id, value),
1858
+ options: schema.pages.map((page, pageIndex) => ({
1859
+ value: page.id,
1860
+ label: page.title ?? `${translate("builder.newPage")} ${pageIndex + 1}`
1861
+ }))
1414
1862
  }
1415
1863
  )
1416
1864
  ] }),
@@ -1420,16 +1868,16 @@ function FormBuilder({
1420
1868
  /* @__PURE__ */ jsxs("label", { children: [
1421
1869
  translate("builder.questionTitle"),
1422
1870
  /* @__PURE__ */ jsx(
1423
- "input",
1871
+ TextInput,
1424
1872
  {
1425
1873
  value: field.translations?.[editingLocale]?.title ?? "",
1426
- onChange: (event) => updateManualTranslation({
1874
+ onChange: (value) => updateManualTranslation({
1427
1875
  locale: editingLocale,
1428
1876
  kind: "field",
1429
1877
  nodeId: field.id,
1430
1878
  property: "title",
1431
1879
  sourceText: field.title,
1432
- translatedText: event.currentTarget.value,
1880
+ translatedText: value,
1433
1881
  ...field.translationMetadata?.[editingLocale]?.title === void 0 ? {} : {
1434
1882
  existingTranslationMetadata: field.translationMetadata[editingLocale]?.title
1435
1883
  }
@@ -1440,16 +1888,16 @@ function FormBuilder({
1440
1888
  /* @__PURE__ */ jsxs("label", { children: [
1441
1889
  translate("builder.pageDescription"),
1442
1890
  /* @__PURE__ */ jsx(
1443
- "input",
1891
+ TextInput,
1444
1892
  {
1445
1893
  value: field.translations?.[editingLocale]?.description ?? "",
1446
- onChange: (event) => updateManualTranslation({
1894
+ onChange: (value) => updateManualTranslation({
1447
1895
  locale: editingLocale,
1448
1896
  kind: "field",
1449
1897
  nodeId: field.id,
1450
1898
  property: "description",
1451
1899
  sourceText: field.description ?? "",
1452
- translatedText: event.currentTarget.value,
1900
+ translatedText: value,
1453
1901
  ...field.translationMetadata?.[editingLocale]?.description === void 0 ? {} : {
1454
1902
  existingTranslationMetadata: field.translationMetadata[editingLocale]?.description
1455
1903
  }
@@ -1464,16 +1912,16 @@ function FormBuilder({
1464
1912
  editingLocale,
1465
1913
  ")",
1466
1914
  /* @__PURE__ */ jsx(
1467
- "input",
1915
+ TextInput,
1468
1916
  {
1469
1917
  value: option.translations?.[editingLocale] ?? "",
1470
- onChange: (event) => updateManualTranslation({
1918
+ onChange: (value) => updateManualTranslation({
1471
1919
  locale: editingLocale,
1472
1920
  kind: "option",
1473
1921
  nodeId: option.id,
1474
1922
  property: "label",
1475
1923
  sourceText: option.label,
1476
- translatedText: event.currentTarget.value,
1924
+ translatedText: value,
1477
1925
  ...option.translationMetadata?.[editingLocale]?.label === void 0 ? {} : {
1478
1926
  existingTranslationMetadata: option.translationMetadata[editingLocale]?.label
1479
1927
  }
@@ -1486,12 +1934,12 @@ function FormBuilder({
1486
1934
  /* @__PURE__ */ jsxs("label", { children: [
1487
1935
  translate("builder.minimum"),
1488
1936
  /* @__PURE__ */ jsx(
1489
- "input",
1937
+ TextInput,
1490
1938
  {
1491
1939
  type: "number",
1492
- value: field.min ?? 1,
1493
- onChange: (event) => {
1494
- const min = event.currentTarget.valueAsNumber;
1940
+ value: String(field.min ?? 1),
1941
+ onChange: (value) => {
1942
+ const min = Number(value);
1495
1943
  if (!Number.isInteger(min)) return;
1496
1944
  updateField(
1497
1945
  field.id,
@@ -1504,12 +1952,12 @@ function FormBuilder({
1504
1952
  /* @__PURE__ */ jsxs("label", { children: [
1505
1953
  translate("builder.maximum"),
1506
1954
  /* @__PURE__ */ jsx(
1507
- "input",
1955
+ TextInput,
1508
1956
  {
1509
1957
  type: "number",
1510
- value: field.max ?? 5,
1511
- onChange: (event) => {
1512
- const max = event.currentTarget.valueAsNumber;
1958
+ value: String(field.max ?? 5),
1959
+ onChange: (value) => {
1960
+ const max = Number(value);
1513
1961
  if (!Number.isInteger(max)) return;
1514
1962
  updateField(
1515
1963
  field.id,
@@ -1522,52 +1970,82 @@ function FormBuilder({
1522
1970
  ] }) : null,
1523
1971
  "options" in field ? /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__options", children: [
1524
1972
  /* @__PURE__ */ jsx("strong", { children: translate("builder.options") }),
1525
- field.options.map((option, optionIndex) => /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__option", children: [
1526
- /* @__PURE__ */ jsx(
1527
- "input",
1528
- {
1529
- "aria-label": translate("builder.optionLabel", { index: optionIndex + 1 }),
1530
- value: option.label,
1531
- placeholder: translate("builder.optionLabelPlaceholder"),
1532
- onChange: (event) => event.currentTarget.value.trim().length === 0 ? void 0 : updateOption(field.id, option.id, event.currentTarget.value)
1533
- }
1534
- ),
1535
- /* @__PURE__ */ jsx(
1536
- "button",
1537
- {
1538
- type: "button",
1539
- disabled: optionIndex === 0,
1540
- "aria-label": translate("builder.moveUp", { title: option.label }),
1541
- onClick: () => moveOption(field.id, option.id, optionIndex - 1),
1542
- children: "\u2191"
1543
- }
1544
- ),
1545
- /* @__PURE__ */ jsx(
1546
- "button",
1547
- {
1548
- type: "button",
1549
- disabled: optionIndex === field.options.length - 1,
1550
- "aria-label": translate("builder.moveDown", { title: option.label }),
1551
- onClick: () => moveOption(field.id, option.id, optionIndex + 1),
1552
- children: "\u2193"
1553
- }
1554
- ),
1555
- /* @__PURE__ */ jsx(
1556
- "button",
1973
+ field.options.map(
1974
+ (option, optionIndex) => OptionEditorSlot === void 0 ? /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__option", children: [
1975
+ /* @__PURE__ */ jsx(
1976
+ TextInput,
1977
+ {
1978
+ "aria-label": translate("builder.optionLabel", { index: optionIndex + 1 }),
1979
+ value: option.label,
1980
+ placeholder: translate("builder.optionLabelPlaceholder"),
1981
+ onChange: (value) => value.trim().length === 0 ? void 0 : updateOption(field.id, option.id, value)
1982
+ }
1983
+ ),
1984
+ ToolbarSlot === void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1985
+ /* @__PURE__ */ jsx(
1986
+ IconButton,
1987
+ {
1988
+ icon: "\u2191",
1989
+ title: translate("builder.moveUp", { title: option.label }),
1990
+ disabled: optionIndex === 0,
1991
+ onClick: () => moveOption(field.id, option.id, optionIndex - 1)
1992
+ }
1993
+ ),
1994
+ /* @__PURE__ */ jsx(
1995
+ IconButton,
1996
+ {
1997
+ icon: "\u2193",
1998
+ title: translate("builder.moveDown", { title: option.label }),
1999
+ disabled: optionIndex === field.options.length - 1,
2000
+ onClick: () => moveOption(field.id, option.id, optionIndex + 1)
2001
+ }
2002
+ ),
2003
+ /* @__PURE__ */ jsx(
2004
+ Button,
2005
+ {
2006
+ disabled: field.options.length === 1,
2007
+ onClick: () => removeOption(field.id, option.id),
2008
+ variant: "danger",
2009
+ children: translate("builder.remove")
2010
+ }
2011
+ )
2012
+ ] }) : /* @__PURE__ */ jsx(
2013
+ ToolbarSlot,
2014
+ {
2015
+ schema,
2016
+ kind: "option",
2017
+ targetId: option.id,
2018
+ index: optionIndex,
2019
+ total: field.options.length,
2020
+ title: option.label,
2021
+ onMoveUp: () => moveOption(field.id, option.id, optionIndex - 1),
2022
+ onMoveDown: () => moveOption(field.id, option.id, optionIndex + 1),
2023
+ onRemove: () => removeOption(field.id, option.id),
2024
+ readOnly,
2025
+ actions,
2026
+ components
2027
+ }
2028
+ )
2029
+ ] }, option.id) : /* @__PURE__ */ jsx(
2030
+ OptionEditorSlot,
1557
2031
  {
1558
- type: "button",
1559
- disabled: field.options.length === 1,
1560
- onClick: () => removeOption(field.id, option.id),
1561
- children: translate("builder.remove")
1562
- }
2032
+ schema,
2033
+ field,
2034
+ option,
2035
+ index: optionIndex,
2036
+ currentLocale: editingLocale,
2037
+ readOnly,
2038
+ actions,
2039
+ components
2040
+ },
2041
+ option.id
1563
2042
  )
1564
- ] }, option.id)),
2043
+ ),
1565
2044
  /* @__PURE__ */ jsx(
1566
- "button",
2045
+ Button,
1567
2046
  {
1568
- type: "button",
1569
- "data-builder-action": "addOption",
1570
- "data-target-id": field.id,
2047
+ action: "addOption",
2048
+ targetId: field.id,
1571
2049
  disabled: policy?.maxOptionsPerField !== void 0 && field.options.length >= policy.maxOptionsPerField,
1572
2050
  onClick: () => addOption(field.id),
1573
2051
  children: translate("builder.addOption")
@@ -1577,12 +2055,12 @@ function FormBuilder({
1577
2055
  conditionsEnabled ? /* @__PURE__ */ jsxs("div", { className: "form-engine-builder__condition", children: [
1578
2056
  /* @__PURE__ */ jsxs("label", { children: [
1579
2057
  translate("builder.displayCondition"),
1580
- /* @__PURE__ */ jsxs(
1581
- "select",
2058
+ /* @__PURE__ */ jsx(
2059
+ Select,
1582
2060
  {
1583
2061
  value: condition?.questionId ?? "",
1584
- onChange: (event) => {
1585
- const selected = schema.fields.find((item) => item.id === event.currentTarget.value);
2062
+ onChange: (value) => {
2063
+ const selected = schema.fields.find((item) => item.id === value);
1586
2064
  setDisplayCondition(
1587
2065
  field.id,
1588
2066
  selected === void 0 ? void 0 : conditionWithValue(
@@ -1592,27 +2070,30 @@ function FormBuilder({
1592
2070
  )
1593
2071
  );
1594
2072
  },
1595
- children: [
1596
- /* @__PURE__ */ jsx("option", { value: "", children: translate("builder.alwaysVisible") }),
1597
- availableSources.map((candidate) => /* @__PURE__ */ jsx("option", { value: candidate.id, children: candidate.title }, candidate.id))
2073
+ options: [
2074
+ { value: "", label: translate("builder.alwaysVisible") },
2075
+ ...availableSources.map((candidate) => ({ value: candidate.id, label: candidate.title }))
1598
2076
  ]
1599
2077
  }
1600
2078
  )
1601
2079
  ] }),
1602
2080
  condition !== void 0 && source !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1603
2081
  /* @__PURE__ */ jsx(
1604
- "select",
2082
+ Select,
1605
2083
  {
1606
2084
  "aria-label": translate("builder.conditionOperator"),
1607
2085
  value: condition.operator,
1608
- onChange: (event) => {
1609
- const operator = event.currentTarget.value;
2086
+ onChange: (value) => {
2087
+ const operator = value;
1610
2088
  setDisplayCondition(
1611
2089
  field.id,
1612
2090
  conditionWithValue(source.id, operator, defaultConditionValue(source))
1613
2091
  );
1614
2092
  },
1615
- children: conditionOperators(source).map((operator) => /* @__PURE__ */ jsx("option", { value: operator, children: translate(operatorKey(operator)) }, operator))
2093
+ options: conditionOperators(source).map((operator) => ({
2094
+ value: operator,
2095
+ label: translate(operatorKey(operator))
2096
+ }))
1616
2097
  }
1617
2098
  ),
1618
2099
  /* @__PURE__ */ jsx(
@@ -1621,7 +2102,8 @@ function FormBuilder({
1621
2102
  source,
1622
2103
  condition,
1623
2104
  onChange: (next) => setDisplayCondition(field.id, next),
1624
- translate
2105
+ translate,
2106
+ components
1625
2107
  }
1626
2108
  )
1627
2109
  ] }) : null
@@ -1629,11 +2111,10 @@ function FormBuilder({
1629
2111
  ] }, field.id);
1630
2112
  }) }),
1631
2113
  /* @__PURE__ */ jsx(
1632
- "button",
2114
+ Button,
1633
2115
  {
1634
2116
  className: "form-engine-builder__add",
1635
- type: "button",
1636
- "data-builder-action": "addField",
2117
+ action: "addField",
1637
2118
  disabled: initialFieldType === null || maxFieldsReached,
1638
2119
  onClick: addField,
1639
2120
  children: translate("builder.addQuestion")
@@ -1641,7 +2122,7 @@ function FormBuilder({
1641
2122
  )
1642
2123
  ] })
1643
2124
  }
1644
- );
2125
+ ) });
1645
2126
  }
1646
2127
 
1647
2128
  // src/context.tsx
@@ -1654,9 +2135,9 @@ import {
1654
2135
  validateAnswers,
1655
2136
  validatePageAnswers
1656
2137
  } from "@form-engine-ts/core";
1657
- import { createContext, useCallback as useCallback2, useContext, useEffect, useMemo as useMemo2, useState as useState2 } from "react";
2138
+ import { createContext as createContext2, useCallback as useCallback2, useContext as useContext2, useEffect, useMemo as useMemo2, useState as useState2 } from "react";
1658
2139
  import { jsx as jsx2 } from "react/jsx-runtime";
1659
- var FormContext = createContext(null);
2140
+ var FormContext = createContext2(null);
1660
2141
  function issuesByField(issues) {
1661
2142
  const result = {};
1662
2143
  for (const issue of issues) result[issue.fieldId] ??= issue;
@@ -1810,7 +2291,7 @@ function FormProvider({
1810
2291
  return /* @__PURE__ */ jsx2(FormContext.Provider, { value: contextValue, children });
1811
2292
  }
1812
2293
  function useForm() {
1813
- const context = useContext(FormContext);
2294
+ const context = useContext2(FormContext);
1814
2295
  if (context === null) throw new Error("useForm must be called inside a FormProvider.");
1815
2296
  return context;
1816
2297
  }