@nextlyhq/plugin-form-builder 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +122 -0
  3. package/dist/CheckboxFieldEditor-K4T6QX52.js +121 -0
  4. package/dist/CheckboxFieldEditor-K4T6QX52.js.map +1 -0
  5. package/dist/DateFieldEditor-JFJFAVOH.js +187 -0
  6. package/dist/DateFieldEditor-JFJFAVOH.js.map +1 -0
  7. package/dist/EmailFieldEditor-MMOXXL7P.js +138 -0
  8. package/dist/EmailFieldEditor-MMOXXL7P.js.map +1 -0
  9. package/dist/NumberFieldEditor-UISAYR6Z.js +175 -0
  10. package/dist/NumberFieldEditor-UISAYR6Z.js.map +1 -0
  11. package/dist/RadioFieldEditor-6UQFH4WT.js +165 -0
  12. package/dist/RadioFieldEditor-6UQFH4WT.js.map +1 -0
  13. package/dist/SelectFieldEditor-PSO4KHV4.js +213 -0
  14. package/dist/SelectFieldEditor-PSO4KHV4.js.map +1 -0
  15. package/dist/TextFieldEditor-5EU64EA5.js +187 -0
  16. package/dist/TextFieldEditor-5EU64EA5.js.map +1 -0
  17. package/dist/TextareaFieldEditor-773G3LNM.js +190 -0
  18. package/dist/TextareaFieldEditor-773G3LNM.js.map +1 -0
  19. package/dist/admin/index.css +934 -0
  20. package/dist/admin/index.css.map +1 -0
  21. package/dist/admin/index.d.ts +547 -0
  22. package/dist/admin/index.js +4030 -0
  23. package/dist/admin/index.js.map +1 -0
  24. package/dist/chunk-ABNZFTQK.js +586 -0
  25. package/dist/chunk-ABNZFTQK.js.map +1 -0
  26. package/dist/chunk-XTCEPJ7B.js +256 -0
  27. package/dist/chunk-XTCEPJ7B.js.map +1 -0
  28. package/dist/components/index.d.ts +3 -0
  29. package/dist/components/index.js +9 -0
  30. package/dist/components/index.js.map +1 -0
  31. package/dist/index-C0kBvYjm.d.ts +1012 -0
  32. package/dist/index.d.ts +1663 -0
  33. package/dist/index.js +2470 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/styles/form-builder.css +1150 -0
  36. package/dist/styles/submissions-filter.css +75 -0
  37. package/package.json +96 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/admin/fields/EmailFieldEditor.tsx"],"sourcesContent":["/**\n * Email Field Editor\n *\n * Editor component for configuring email field properties.\n * Includes general settings (label, name, placeholder, required) and\n * validation options (pattern, error message).\n *\n * Email validation is automatic - the browser enforces email format.\n * Custom pattern allows additional restrictions (e.g., corporate domains only).\n *\n * @module admin/fields/EmailFieldEditor\n * @since 0.1.0\n */\n\n\"use client\";\n\nimport { Input } from \"@nextlyhq/ui\";\n\nimport type { EmailFormField } from \"../../types\";\n\nimport type { FieldEditorProps } from \"./index\";\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * EmailFieldEditor - Configure email field properties\n *\n * Provides configuration options for:\n * - Label: Display text shown above the field\n * - Field Name: Key used in submission data (auto-formatted)\n * - Placeholder: Hint text shown when field is empty\n * - Help Text: Additional guidance shown below the field\n * - Required: Whether the field must be filled\n * - Validation: pattern (optional extra regex), error message\n *\n * Note: Basic email format validation is automatic via HTML5 email input type.\n *\n * @example\n * ```tsx\n * <EmailFieldEditor\n * field={emailField}\n * allFields={formFields}\n * onUpdate={(updates) => handleUpdate(updates)}\n * />\n * ```\n */\nexport function EmailFieldEditor({\n field,\n onUpdate,\n}: FieldEditorProps<EmailFormField>) {\n // Helper to update validation properties\n const updateValidation = (key: string, value: unknown) => {\n onUpdate({\n validation: {\n ...field.validation,\n [key]: value,\n },\n });\n };\n\n return (\n <div className=\"email-field-editor\">\n {/* General Settings Section */}\n <div className=\"email-field-editor__section\">\n <h4 className=\"email-field-editor__section-title\">General</h4>\n\n {/* Label */}\n <div className=\"email-field-editor__field\">\n <label className=\"email-field-editor__label\" htmlFor=\"field-label\">\n Label\n </label>\n <Input\n id=\"field-label\"\n type=\"text\"\n value={field.label || \"\"}\n onChange={e => onUpdate({ label: e.target.value })}\n placeholder=\"Enter field label\"\n />\n </div>\n\n {/* Field Name */}\n <div className=\"email-field-editor__field\">\n <label className=\"email-field-editor__label\" htmlFor=\"field-name\">\n Field Name\n </label>\n <Input\n id=\"field-name\"\n type=\"text\"\n value={field.name || \"\"}\n onChange={e =>\n onUpdate({\n name: e.target.value\n .replace(/\\s+/g, \"_\")\n .replace(/[^a-zA-Z0-9_]/g, \"\")\n .toLowerCase(),\n })\n }\n placeholder=\"field_name\"\n className=\"email-field-editor__input--mono\"\n />\n <p className=\"email-field-editor__hint\">\n Used as the key in submission data. Only letters, numbers, and\n underscores.\n </p>\n </div>\n\n {/* Placeholder */}\n <div className=\"email-field-editor__field\">\n <label\n className=\"email-field-editor__label\"\n htmlFor=\"field-placeholder\"\n >\n Placeholder\n </label>\n <Input\n id=\"field-placeholder\"\n type=\"text\"\n value={field.placeholder || \"\"}\n onChange={e => onUpdate({ placeholder: e.target.value })}\n placeholder=\"email@example.com\"\n />\n </div>\n\n {/* Help Text */}\n <div className=\"email-field-editor__field\">\n <label className=\"email-field-editor__label\" htmlFor=\"field-help\">\n Help Text\n </label>\n <Input\n id=\"field-help\"\n type=\"text\"\n value={field.helpText || \"\"}\n onChange={e => onUpdate({ helpText: e.target.value })}\n placeholder=\"Additional guidance for users\"\n />\n <p className=\"email-field-editor__hint\">Displayed below the field</p>\n </div>\n\n {/* Required */}\n <div className=\"email-field-editor__field email-field-editor__field--inline\">\n <label className=\"email-field-editor__checkbox-label\">\n <input\n type=\"checkbox\"\n checked={field.required || false}\n onChange={e => onUpdate({ required: e.target.checked })}\n className=\"email-field-editor__checkbox\"\n />\n <span>Required field</span>\n </label>\n </div>\n </div>\n\n {/* Validation Section */}\n <div className=\"email-field-editor__section\">\n <h4 className=\"email-field-editor__section-title\">Validation</h4>\n\n {/* Info about automatic validation */}\n <div className=\"email-field-editor__info\">\n <p className=\"email-field-editor__info-text\">\n Email format validation is automatic. Use the pattern field below\n for additional restrictions (e.g., corporate domains only).\n </p>\n </div>\n\n {/* Pattern */}\n <div className=\"email-field-editor__field\">\n <label className=\"email-field-editor__label\" htmlFor=\"field-pattern\">\n Pattern (Regex)\n </label>\n <Input\n id=\"field-pattern\"\n type=\"text\"\n value={field.validation?.pattern || \"\"}\n onChange={e =>\n updateValidation(\"pattern\", e.target.value || undefined)\n }\n placeholder=\".*@company\\.com$\"\n className=\"email-field-editor__input--mono\"\n />\n <p className=\"email-field-editor__hint\">\n Optional: Additional regex pattern (e.g., restrict to specific\n domains)\n </p>\n </div>\n\n {/* Error Message */}\n <div className=\"email-field-editor__field\">\n <label className=\"email-field-editor__label\" htmlFor=\"field-error\">\n Error Message\n </label>\n <Input\n id=\"field-error\"\n type=\"text\"\n value={field.validation?.errorMessage || \"\"}\n onChange={e =>\n updateValidation(\"errorMessage\", e.target.value || undefined)\n }\n placeholder=\"Please enter a valid email address\"\n />\n <p className=\"email-field-editor__hint\">\n Custom message shown when validation fails\n </p>\n </div>\n </div>\n </div>\n );\n}\n\nexport default EmailFieldEditor;\n"],"mappings":";;;AAgBA,SAAS,aAAa;AAkDd,cAGA,YAHA;AAlBD,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AACF,GAAqC;AAEnC,QAAM,mBAAmB,CAAC,KAAa,UAAmB;AACxD,aAAS;AAAA,MACP,YAAY;AAAA,QACV,GAAG,MAAM;AAAA,QACT,CAAC,GAAG,GAAG;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SACE,qBAAC,SAAI,WAAU,sBAEb;AAAA,yBAAC,SAAI,WAAU,+BACb;AAAA,0BAAC,QAAG,WAAU,qCAAoC,qBAAO;AAAA,MAGzD,qBAAC,SAAI,WAAU,6BACb;AAAA,4BAAC,WAAM,WAAU,6BAA4B,SAAQ,eAAc,mBAEnE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACL,OAAO,MAAM,SAAS;AAAA,YACtB,UAAU,OAAK,SA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/admin/fields/NumberFieldEditor.tsx
4
+ import { Input } from "@nextlyhq/ui";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ function NumberFieldEditor({
7
+ field,
8
+ onUpdate
9
+ }) {
10
+ const updateValidation = (key, value) => {
11
+ onUpdate({
12
+ validation: {
13
+ ...field.validation,
14
+ [key]: value
15
+ }
16
+ });
17
+ };
18
+ return /* @__PURE__ */ jsxs("div", { className: "number-field-editor", children: [
19
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__section", children: [
20
+ /* @__PURE__ */ jsx("h4", { className: "number-field-editor__section-title", children: "General" }),
21
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field", children: [
22
+ /* @__PURE__ */ jsx("label", { className: "number-field-editor__label", htmlFor: "field-label", children: "Label" }),
23
+ /* @__PURE__ */ jsx(
24
+ Input,
25
+ {
26
+ id: "field-label",
27
+ type: "text",
28
+ value: field.label || "",
29
+ onChange: (e) => onUpdate({ label: e.target.value }),
30
+ placeholder: "Enter field label"
31
+ }
32
+ )
33
+ ] }),
34
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field", children: [
35
+ /* @__PURE__ */ jsx("label", { className: "number-field-editor__label", htmlFor: "field-name", children: "Field Name" }),
36
+ /* @__PURE__ */ jsx(
37
+ Input,
38
+ {
39
+ id: "field-name",
40
+ type: "text",
41
+ value: field.name || "",
42
+ onChange: (e) => onUpdate({
43
+ name: e.target.value.replace(/\s+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase()
44
+ }),
45
+ placeholder: "field_name",
46
+ className: "number-field-editor__input--mono"
47
+ }
48
+ ),
49
+ /* @__PURE__ */ jsx("p", { className: "number-field-editor__hint", children: "Used as the key in submission data. Only letters, numbers, and underscores." })
50
+ ] }),
51
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field", children: [
52
+ /* @__PURE__ */ jsx(
53
+ "label",
54
+ {
55
+ className: "number-field-editor__label",
56
+ htmlFor: "field-placeholder",
57
+ children: "Placeholder"
58
+ }
59
+ ),
60
+ /* @__PURE__ */ jsx(
61
+ Input,
62
+ {
63
+ id: "field-placeholder",
64
+ type: "text",
65
+ value: field.placeholder || "",
66
+ onChange: (e) => onUpdate({ placeholder: e.target.value }),
67
+ placeholder: "0"
68
+ }
69
+ )
70
+ ] }),
71
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field", children: [
72
+ /* @__PURE__ */ jsx("label", { className: "number-field-editor__label", htmlFor: "field-help", children: "Help Text" }),
73
+ /* @__PURE__ */ jsx(
74
+ Input,
75
+ {
76
+ id: "field-help",
77
+ type: "text",
78
+ value: field.helpText || "",
79
+ onChange: (e) => onUpdate({ helpText: e.target.value }),
80
+ placeholder: "Additional guidance for users"
81
+ }
82
+ ),
83
+ /* @__PURE__ */ jsx("p", { className: "number-field-editor__hint", children: "Displayed below the field" })
84
+ ] }),
85
+ /* @__PURE__ */ jsx("div", { className: "number-field-editor__field number-field-editor__field--inline", children: /* @__PURE__ */ jsxs("label", { className: "number-field-editor__checkbox-label", children: [
86
+ /* @__PURE__ */ jsx(
87
+ "input",
88
+ {
89
+ type: "checkbox",
90
+ checked: field.required || false,
91
+ onChange: (e) => onUpdate({ required: e.target.checked }),
92
+ className: "number-field-editor__checkbox"
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsx("span", { children: "Required field" })
96
+ ] }) })
97
+ ] }),
98
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__section", children: [
99
+ /* @__PURE__ */ jsx("h4", { className: "number-field-editor__section-title", children: "Validation" }),
100
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field-row", children: [
101
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field number-field-editor__field--half", children: [
102
+ /* @__PURE__ */ jsx("label", { className: "number-field-editor__label", htmlFor: "field-min", children: "Min Value" }),
103
+ /* @__PURE__ */ jsx(
104
+ Input,
105
+ {
106
+ id: "field-min",
107
+ type: "number",
108
+ value: field.validation?.min ?? "",
109
+ onChange: (e) => updateValidation(
110
+ "min",
111
+ e.target.value ? parseFloat(e.target.value) : void 0
112
+ ),
113
+ placeholder: "No minimum"
114
+ }
115
+ )
116
+ ] }),
117
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field number-field-editor__field--half", children: [
118
+ /* @__PURE__ */ jsx("label", { className: "number-field-editor__label", htmlFor: "field-max", children: "Max Value" }),
119
+ /* @__PURE__ */ jsx(
120
+ Input,
121
+ {
122
+ id: "field-max",
123
+ type: "number",
124
+ value: field.validation?.max ?? "",
125
+ onChange: (e) => updateValidation(
126
+ "max",
127
+ e.target.value ? parseFloat(e.target.value) : void 0
128
+ ),
129
+ placeholder: "No maximum"
130
+ }
131
+ )
132
+ ] })
133
+ ] }),
134
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field", children: [
135
+ /* @__PURE__ */ jsx("label", { className: "number-field-editor__label", htmlFor: "field-step", children: "Step" }),
136
+ /* @__PURE__ */ jsx(
137
+ Input,
138
+ {
139
+ id: "field-step",
140
+ type: "number",
141
+ min: 0,
142
+ step: "any",
143
+ value: field.validation?.step ?? "",
144
+ onChange: (e) => updateValidation(
145
+ "step",
146
+ e.target.value ? parseFloat(e.target.value) : void 0
147
+ ),
148
+ placeholder: "1"
149
+ }
150
+ ),
151
+ /* @__PURE__ */ jsx("p", { className: "number-field-editor__hint", children: "Increment/decrement step (e.g., 0.01 for decimals, 5 for multiples of 5)" })
152
+ ] }),
153
+ /* @__PURE__ */ jsxs("div", { className: "number-field-editor__field", children: [
154
+ /* @__PURE__ */ jsx("label", { className: "number-field-editor__label", htmlFor: "field-error", children: "Error Message" }),
155
+ /* @__PURE__ */ jsx(
156
+ Input,
157
+ {
158
+ id: "field-error",
159
+ type: "text",
160
+ value: field.validation?.errorMessage || "",
161
+ onChange: (e) => updateValidation("errorMessage", e.target.value || void 0),
162
+ placeholder: "Please enter a valid number"
163
+ }
164
+ ),
165
+ /* @__PURE__ */ jsx("p", { className: "number-field-editor__hint", children: "Custom message shown when validation fails" })
166
+ ] })
167
+ ] })
168
+ ] });
169
+ }
170
+ var NumberFieldEditor_default = NumberFieldEditor;
171
+ export {
172
+ NumberFieldEditor,
173
+ NumberFieldEditor_default as default
174
+ };
175
+ //# sourceMappingURL=NumberFieldEditor-UISAYR6Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/admin/fields/NumberFieldEditor.tsx"],"sourcesContent":["/**\n * Number Field Editor\n *\n * Editor component for configuring number field properties.\n * Includes general settings (label, name, placeholder, required) and\n * validation options (min, max, step).\n *\n * @module admin/fields/NumberFieldEditor\n * @since 0.1.0\n */\n\n\"use client\";\n\nimport { Input } from \"@nextlyhq/ui\";\n\nimport type { NumberFormField } from \"../../types\";\n\nimport type { FieldEditorProps } from \"./index\";\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * NumberFieldEditor - Configure number field properties\n *\n * Provides configuration options for:\n * - Label: Display text shown above the field\n * - Field Name: Key used in submission data (auto-formatted)\n * - Placeholder: Hint text shown when field is empty\n * - Help Text: Additional guidance shown below the field\n * - Required: Whether the field must be filled\n * - Validation: min, max, step, error message\n *\n * @example\n * ```tsx\n * <NumberFieldEditor\n * field={numberField}\n * allFields={formFields}\n * onUpdate={(updates) => handleUpdate(updates)}\n * />\n * ```\n */\nexport function NumberFieldEditor({\n field,\n onUpdate,\n}: FieldEditorProps<NumberFormField>) {\n // Helper to update validation properties\n const updateValidation = (key: string, value: unknown) => {\n onUpdate({\n validation: {\n ...field.validation,\n [key]: value,\n },\n });\n };\n\n return (\n <div className=\"number-field-editor\">\n {/* General Settings Section */}\n <div className=\"number-field-editor__section\">\n <h4 className=\"number-field-editor__section-title\">General</h4>\n\n {/* Label */}\n <div className=\"number-field-editor__field\">\n <label className=\"number-field-editor__label\" htmlFor=\"field-label\">\n Label\n </label>\n <Input\n id=\"field-label\"\n type=\"text\"\n value={field.label || \"\"}\n onChange={e => onUpdate({ label: e.target.value })}\n placeholder=\"Enter field label\"\n />\n </div>\n\n {/* Field Name */}\n <div className=\"number-field-editor__field\">\n <label className=\"number-field-editor__label\" htmlFor=\"field-name\">\n Field Name\n </label>\n <Input\n id=\"field-name\"\n type=\"text\"\n value={field.name || \"\"}\n onChange={e =>\n onUpdate({\n name: e.target.value\n .replace(/\\s+/g, \"_\")\n .replace(/[^a-zA-Z0-9_]/g, \"\")\n .toLowerCase(),\n })\n }\n placeholder=\"field_name\"\n className=\"number-field-editor__input--mono\"\n />\n <p className=\"number-field-editor__hint\">\n Used as the key in submission data. Only letters, numbers, and\n underscores.\n </p>\n </div>\n\n {/* Placeholder */}\n <div className=\"number-field-editor__field\">\n <label\n className=\"number-field-editor__label\"\n htmlFor=\"field-placeholder\"\n >\n Placeholder\n </label>\n <Input\n id=\"field-placeholder\"\n type=\"text\"\n value={field.placeholder || \"\"}\n onChange={e => onUpdate({ placeholder: e.target.value })}\n placeholder=\"0\"\n />\n </div>\n\n {/* Help Text */}\n <div className=\"number-field-editor__field\">\n <label className=\"number-field-editor__label\" htmlFor=\"field-help\">\n Help Text\n </label>\n <Input\n id=\"field-help\"\n type=\"text\"\n value={field.helpText || \"\"}\n onChange={e => onUpdate({ helpText: e.target.value })}\n placeholder=\"Additional guidance for users\"\n />\n <p className=\"number-field-editor__hint\">Displayed below the field</p>\n </div>\n\n {/* Required */}\n <div className=\"number-field-editor__field number-field-editor__field--inline\">\n <label className=\"number-field-editor__checkbox-label\">\n <input\n type=\"checkbox\"\n checked={field.required || false}\n onChange={e => onUpdate({ required: e.target.checked })}\n className=\"number-field-editor__checkbox\"\n />\n <span>Required field</span>\n </label>\n </div>\n </div>\n\n {/* Validation Section */}\n <div className=\"number-field-editor__section\">\n <h4 className=\"number-field-editor__section-title\">Validation</h4>\n\n {/* Min/Max Value */}\n <div className=\"number-field-editor__field-row\">\n <div className=\"number-field-editor__field number-field-editor__field--half\">\n <label className=\"number-field-editor__label\" htmlFor=\"field-min\">\n Min Value\n </label>\n <Input\n id=\"field-min\"\n type=\"number\"\n value={field.validation?.min ?? \"\"}\n onChange={e =>\n updateValidation(\n \"min\",\n e.target.value ? parseFloat(e.target.value) : undefined\n )\n }\n placeholder=\"No minimum\"\n />\n </div>\n <div className=\"number-field-editor__field number-field-editor__field--half\">\n <label className=\"number-field-editor__label\" htmlFor=\"field-max\">\n Max Value\n </label>\n <Input\n id=\"field-max\"\n type=\"number\"\n value={field.validation?.max ?? \"\"}\n onChange={e =>\n updateValidation(\n \"max\",\n e.target.value ? parseFloat(e.target.value) : undefined\n )\n }\n placeholder=\"No maximum\"\n />\n </div>\n </div>\n\n {/* Step */}\n <div className=\"number-field-editor__field\">\n <label className=\"number-field-editor__label\" htmlFor=\"field-step\">\n Step\n </label>\n <Input\n id=\"field-step\"\n type=\"number\"\n min={0}\n step=\"any\"\n value={field.validation?.step ?? \"\"}\n onChange={e =>\n updateValidation(\n \"step\",\n e.target.value ? parseFloat(e.target.value) : undefined\n )\n }\n placeholder=\"1\"\n />\n <p className=\"number-field-editor__hint\">\n Increment/decrement step (e.g., 0.01 for decimals, 5 for multiples\n of 5)\n </p>\n </div>\n\n {/* Error Message */}\n <div className=\"number-field-editor__field\">\n <label className=\"number-field-editor__label\" htmlFor=\"field-error\">\n Error Message\n </label>\n <Input\n id=\"field-error\"\n type=\"text\"\n value={field.validation?.errorMessage || \"\"}\n onChange={e =>\n updateValidation(\"errorMessage\", e.target.value || undefined)\n }\n placeholder=\"Please enter a valid number\"\n />\n <p className=\"number-field-editor__hint\">\n Custom message shown when validation fails\n </p>\n </div>\n </div>\n </div>\n );\n}\n\nexport default NumberFieldEditor;\n"],"mappings":";;;AAaA,SAAS,aAAa;AAgDd,cAGA,YAHA;AAlBD,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAsC;AAEpC,QAAM,mBAAmB,CAAC,KAAa,UAAmB;AACxD,aAAS;AAAA,MACP,YAAY;AAAA,QACV,GAAG,MAAM;AAAA,QACT,CAAC,GAAG,GAAG;AAAA,MACT;AAAA,IACF,CAAC;AAA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AAAA,cAChC,UAAU,OACR;AAAA,gBACE;AAAA,gBACA,EAAE,OAAO,QAAQ,WAAW,EAAE,OAAO,KAAK,IAAI;AAAA,cAChD;AAAA,cAEF,aAAY;AAAA;AAAA,UACd;AAAA,WACF;AAAA,SACF;AAAA,MAGA,qBAAC,SAAI,WAAU,8BACb;AAAA,4BAAC,WAAM,WAAU,8BAA6B,SAAQ,cAAa,kBAEnE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACL,KAAK;AAAA,YACL,MAAK;AAAA,YACL,OAAO,MAAM,YAAY,QAAQ;AAAA,YACjC,UAAU,OACR;AAAA,cACE;AAAA,cACA,EAAE,OAAO,QAAQ,WAAW,EAAE,OAAO,KAAK,IAAI;AAAA,YAChD;AAAA,YAEF,aAAY;AAAA;AAAA,QACd;AAAA,QACA,oBAAC,OAAE,WAAU,6BAA4B,sFAGzC;AAAA,SACF;AAAA,MAGA,qBAAC,SAAI,WAAU,8BACb;AAAA,4BAAC,WAAM,WAAU,8BAA6B,SAAQ,eAAc,2BAEpE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACL,OAAO,MAAM,YAAY,gBAAgB;AAAA,YACzC,UAAU,OACR,iBAAiB,gBAAgB,EAAE,OAAO,SAAS,MAAS;AAAA,YAE9D,aAAY;AAAA;AAAA,QACd;AAAA,QACA,oBAAC,OAAE,WAAU,6BAA4B,wDAEzC;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;AAEA,IAAO,4BAAQ;","names":[]}
@@ -0,0 +1,165 @@
1
+ "use client";
2
+ import {
3
+ OptionsEditor
4
+ } from "./chunk-XTCEPJ7B.js";
5
+
6
+ // src/admin/fields/RadioFieldEditor.tsx
7
+ import { Input } from "@nextlyhq/ui";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ function RadioFieldEditor({
10
+ field,
11
+ onUpdate
12
+ }) {
13
+ const updateValidation = (key, value) => {
14
+ onUpdate({
15
+ validation: {
16
+ ...field.validation,
17
+ [key]: value
18
+ }
19
+ });
20
+ };
21
+ const availableOptions = field.options || [];
22
+ return /* @__PURE__ */ jsxs("div", { className: "radio-field-editor", children: [
23
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__section", children: [
24
+ /* @__PURE__ */ jsx("h4", { className: "radio-field-editor__section-title", children: "General" }),
25
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__field", children: [
26
+ /* @__PURE__ */ jsx("label", { className: "radio-field-editor__label", htmlFor: "field-label", children: "Label" }),
27
+ /* @__PURE__ */ jsx(
28
+ Input,
29
+ {
30
+ id: "field-label",
31
+ type: "text",
32
+ value: field.label || "",
33
+ onChange: (e) => onUpdate({ label: e.target.value }),
34
+ placeholder: "Enter field label"
35
+ }
36
+ )
37
+ ] }),
38
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__field", children: [
39
+ /* @__PURE__ */ jsx("label", { className: "radio-field-editor__label", htmlFor: "field-name", children: "Field Name" }),
40
+ /* @__PURE__ */ jsx(
41
+ Input,
42
+ {
43
+ id: "field-name",
44
+ type: "text",
45
+ value: field.name || "",
46
+ onChange: (e) => onUpdate({
47
+ name: e.target.value.replace(/\s+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase()
48
+ }),
49
+ placeholder: "field_name",
50
+ className: "radio-field-editor__input--mono"
51
+ }
52
+ ),
53
+ /* @__PURE__ */ jsx("p", { className: "radio-field-editor__hint", children: "Used as the key in submission data. Only letters, numbers, and underscores." })
54
+ ] }),
55
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__field", children: [
56
+ /* @__PURE__ */ jsx("label", { className: "radio-field-editor__label", htmlFor: "field-help", children: "Help Text" }),
57
+ /* @__PURE__ */ jsx(
58
+ Input,
59
+ {
60
+ id: "field-help",
61
+ type: "text",
62
+ value: field.helpText || "",
63
+ onChange: (e) => onUpdate({ helpText: e.target.value }),
64
+ placeholder: "Additional guidance for users"
65
+ }
66
+ ),
67
+ /* @__PURE__ */ jsx("p", { className: "radio-field-editor__hint", children: "Displayed below the field" })
68
+ ] }),
69
+ /* @__PURE__ */ jsx("div", { className: "radio-field-editor__field radio-field-editor__field--inline", children: /* @__PURE__ */ jsxs("label", { className: "radio-field-editor__checkbox-label", children: [
70
+ /* @__PURE__ */ jsx(
71
+ "input",
72
+ {
73
+ type: "checkbox",
74
+ checked: field.required || false,
75
+ onChange: (e) => onUpdate({ required: e.target.checked }),
76
+ className: "radio-field-editor__checkbox"
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsx("span", { children: "Required field" })
80
+ ] }) })
81
+ ] }),
82
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__section", children: [
83
+ /* @__PURE__ */ jsx("h4", { className: "radio-field-editor__section-title", children: "Options" }),
84
+ /* @__PURE__ */ jsx(
85
+ OptionsEditor,
86
+ {
87
+ options: field.options || [],
88
+ onOptionsChange: (options) => onUpdate({ options })
89
+ }
90
+ )
91
+ ] }),
92
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__section", children: [
93
+ /* @__PURE__ */ jsx("h4", { className: "radio-field-editor__section-title", children: "Settings" }),
94
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__field", children: [
95
+ /* @__PURE__ */ jsx(
96
+ "label",
97
+ {
98
+ className: "radio-field-editor__label",
99
+ htmlFor: "field-default-value",
100
+ children: "Default Value"
101
+ }
102
+ ),
103
+ availableOptions.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__default-options", children: [
104
+ /* @__PURE__ */ jsxs("label", { className: "radio-field-editor__default-option", children: [
105
+ /* @__PURE__ */ jsx(
106
+ "input",
107
+ {
108
+ type: "radio",
109
+ name: "default-value",
110
+ checked: !field.defaultValue,
111
+ onChange: () => onUpdate({ defaultValue: void 0 }),
112
+ className: "radio-field-editor__radio"
113
+ }
114
+ ),
115
+ /* @__PURE__ */ jsx("span", { className: "radio-field-editor__default-option-label", children: "No default" })
116
+ ] }),
117
+ availableOptions.map((opt) => /* @__PURE__ */ jsxs(
118
+ "label",
119
+ {
120
+ className: "radio-field-editor__default-option",
121
+ children: [
122
+ /* @__PURE__ */ jsx(
123
+ "input",
124
+ {
125
+ type: "radio",
126
+ name: "default-value",
127
+ checked: field.defaultValue === opt.value,
128
+ onChange: () => onUpdate({ defaultValue: opt.value }),
129
+ className: "radio-field-editor__radio"
130
+ }
131
+ ),
132
+ /* @__PURE__ */ jsx("span", { className: "radio-field-editor__default-option-label", children: opt.label })
133
+ ]
134
+ },
135
+ opt.value
136
+ ))
137
+ ] }) : /* @__PURE__ */ jsx("p", { className: "radio-field-editor__hint", children: "Add options above to set a default value" }),
138
+ /* @__PURE__ */ jsx("p", { className: "radio-field-editor__hint", children: "Pre-selected when the form loads" })
139
+ ] })
140
+ ] }),
141
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__section", children: [
142
+ /* @__PURE__ */ jsx("h4", { className: "radio-field-editor__section-title", children: "Validation" }),
143
+ /* @__PURE__ */ jsxs("div", { className: "radio-field-editor__field", children: [
144
+ /* @__PURE__ */ jsx("label", { className: "radio-field-editor__label", htmlFor: "field-error", children: "Error Message" }),
145
+ /* @__PURE__ */ jsx(
146
+ Input,
147
+ {
148
+ id: "field-error",
149
+ type: "text",
150
+ value: field.validation?.errorMessage || "",
151
+ onChange: (e) => updateValidation("errorMessage", e.target.value || void 0),
152
+ placeholder: "Please select an option"
153
+ }
154
+ ),
155
+ /* @__PURE__ */ jsx("p", { className: "radio-field-editor__hint", children: "Custom message shown when validation fails" })
156
+ ] })
157
+ ] })
158
+ ] });
159
+ }
160
+ var RadioFieldEditor_default = RadioFieldEditor;
161
+ export {
162
+ RadioFieldEditor,
163
+ RadioFieldEditor_default as default
164
+ };
165
+ //# sourceMappingURL=RadioFieldEditor-6UQFH4WT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/admin/fields/RadioFieldEditor.tsx"],"sourcesContent":["/**\n * Radio Field Editor\n *\n * Editor component for configuring radio button group field properties.\n * Includes general settings, options management with drag-and-drop,\n * default value selection, and validation.\n *\n * @module admin/fields/RadioFieldEditor\n * @since 0.1.0\n */\n\n\"use client\";\n\nimport { Input } from \"@nextlyhq/ui\";\n\nimport type { RadioFormField } from \"../../types\";\n\nimport { OptionsEditor } from \"./OptionsEditor\";\n\nimport type { FieldEditorProps } from \"./index\";\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * RadioFieldEditor - Configure radio button group field properties\n *\n * Provides configuration options for:\n * - Label: Display text shown above the field\n * - Field Name: Key used in submission data (auto-formatted)\n * - Help Text: Additional guidance shown below the field\n * - Required: Whether the field must be filled\n * - Options: List of label/value pairs with drag-and-drop reordering\n * - Default Value: Pre-selected option\n * - Validation: Custom error message\n *\n * Note: Radio buttons only allow single selection (unlike Select with allowMultiple).\n *\n * @example\n * ```tsx\n * <RadioFieldEditor\n * field={radioField}\n * allFields={formFields}\n * onUpdate={(updates) => handleUpdate(updates)}\n * />\n * ```\n */\nexport function RadioFieldEditor({\n field,\n onUpdate,\n}: FieldEditorProps<RadioFormField>) {\n // Helper to update validation properties\n const updateValidation = (key: string, value: unknown) => {\n onUpdate({\n validation: {\n ...field.validation,\n [key]: value,\n },\n });\n };\n\n // Get available options for default value dropdown\n const availableOptions = field.options || [];\n\n return (\n <div className=\"radio-field-editor\">\n {/* General Settings Section */}\n <div className=\"radio-field-editor__section\">\n <h4 className=\"radio-field-editor__section-title\">General</h4>\n\n {/* Label */}\n <div className=\"radio-field-editor__field\">\n <label className=\"radio-field-editor__label\" htmlFor=\"field-label\">\n Label\n </label>\n <Input\n id=\"field-label\"\n type=\"text\"\n value={field.label || \"\"}\n onChange={e => onUpdate({ label: e.target.value })}\n placeholder=\"Enter field label\"\n />\n </div>\n\n {/* Field Name */}\n <div className=\"radio-field-editor__field\">\n <label className=\"radio-field-editor__label\" htmlFor=\"field-name\">\n Field Name\n </label>\n <Input\n id=\"field-name\"\n type=\"text\"\n value={field.name || \"\"}\n onChange={e =>\n onUpdate({\n name: e.target.value\n .replace(/\\s+/g, \"_\")\n .replace(/[^a-zA-Z0-9_]/g, \"\")\n .toLowerCase(),\n })\n }\n placeholder=\"field_name\"\n className=\"radio-field-editor__input--mono\"\n />\n <p className=\"radio-field-editor__hint\">\n Used as the key in submission data. Only letters, numbers, and\n underscores.\n </p>\n </div>\n\n {/* Help Text */}\n <div className=\"radio-field-editor__field\">\n <label className=\"radio-field-editor__label\" htmlFor=\"field-help\">\n Help Text\n </label>\n <Input\n id=\"field-help\"\n type=\"text\"\n value={field.helpText || \"\"}\n onChange={e => onUpdate({ helpText: e.target.value })}\n placeholder=\"Additional guidance for users\"\n />\n <p className=\"radio-field-editor__hint\">Displayed below the field</p>\n </div>\n\n {/* Required */}\n <div className=\"radio-field-editor__field radio-field-editor__field--inline\">\n <label className=\"radio-field-editor__checkbox-label\">\n <input\n type=\"checkbox\"\n checked={field.required || false}\n onChange={e => onUpdate({ required: e.target.checked })}\n className=\"radio-field-editor__checkbox\"\n />\n <span>Required field</span>\n </label>\n </div>\n </div>\n\n {/* Options Section */}\n <div className=\"radio-field-editor__section\">\n <h4 className=\"radio-field-editor__section-title\">Options</h4>\n\n <OptionsEditor\n options={field.options || []}\n onOptionsChange={options => onUpdate({ options })}\n />\n </div>\n\n {/* Settings Section */}\n <div className=\"radio-field-editor__section\">\n <h4 className=\"radio-field-editor__section-title\">Settings</h4>\n\n {/* Default Value */}\n <div className=\"radio-field-editor__field\">\n <label\n className=\"radio-field-editor__label\"\n htmlFor=\"field-default-value\"\n >\n Default Value\n </label>\n {availableOptions.length > 0 ? (\n <div className=\"radio-field-editor__default-options\">\n {/* No default option */}\n <label className=\"radio-field-editor__default-option\">\n <input\n type=\"radio\"\n name=\"default-value\"\n checked={!field.defaultValue}\n onChange={() => onUpdate({ defaultValue: undefined })}\n className=\"radio-field-editor__radio\"\n />\n <span className=\"radio-field-editor__default-option-label\">\n No default\n </span>\n </label>\n\n {/* Options as radio buttons */}\n {availableOptions.map(opt => (\n <label\n key={opt.value}\n className=\"radio-field-editor__default-option\"\n >\n <input\n type=\"radio\"\n name=\"default-value\"\n checked={field.defaultValue === opt.value}\n onChange={() => onUpdate({ defaultValue: opt.value })}\n className=\"radio-field-editor__radio\"\n />\n <span className=\"radio-field-editor__default-option-label\">\n {opt.label}\n </span>\n </label>\n ))}\n </div>\n ) : (\n <p className=\"radio-field-editor__hint\">\n Add options above to set a default value\n </p>\n )}\n <p className=\"radio-field-editor__hint\">\n Pre-selected when the form loads\n </p>\n </div>\n </div>\n\n {/* Validation Section */}\n <div className=\"radio-field-editor__section\">\n <h4 className=\"radio-field-editor__section-title\">Validation</h4>\n\n {/* Error Message */}\n <div className=\"radio-field-editor__field\">\n <label className=\"radio-field-editor__label\" htmlFor=\"field-error\">\n Error Message\n </label>\n <Input\n id=\"field-error\"\n type=\"text\"\n value={field.validation?.errorMessage || \"\"}\n onChange={e =>\n updateValidation(\"errorMessage\", e.target.value || undefined)\n }\n placeholder=\"Please select an option\"\n />\n <p className=\"radio-field-editor__hint\">\n Custom message shown when validation fails\n </p>\n </div>\n </div>\n </div>\n );\n}\n\nexport default RadioFieldEditor;\n"],"mappings":";;;;;;AAaA,SAAS,aAAa;AAwDd,cAGA,YAHA;AArBD,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AACF,GAAqC;AAEnC,QAAM,mBAAmB,CAAC,KAAa,UAAmB;AACxD,aAAS;AAAA,MACP,YAAY;AAAA,QACV,GAAG,MAAM;AAAA,QACT,CAAC,GAAG,GAAG;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAGA,QAAM,mBAAmB,MAAM,WAAW,CAAC;AAE3C,SACE,qBAAC,SAAI,WAAU,sBAEb;AAAA,yBAAC,SAAI,WAAU,+BACb;AAAA,0BAAC,QAAG,WAAU,qCAAoC,qBAAO;AAAA,MAGzD,qBAAC,SAAI,WAAU,6BACb;AAAA,4BAAC,WAAM,WAA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A,oBAAC,OAAE,WAAU,4BAA2B,sDAExC;AAAA,QAEF,oBAAC,OAAE,WAAU,4BAA2B,8CAExC;AAAA,SACF;AAAA,OACF;AAAA,IAGA,qBAAC,SAAI,WAAU,+BACb;AAAA,0BAAC,QAAG,WAAU,qCAAoC,wBAAU;AAAA,MAG5D,qBAAC,SAAI,WAAU,6BACb;AAAA,4BAAC,WAAM,WAAU,6BAA4B,SAAQ,eAAc,2BAEnE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACL,OAAO,MAAM,YAAY,gBAAgB;AAAA,YACzC,UAAU,OACR,iBAAiB,gBAAgB,EAAE,OAAO,SAAS,MAAS;AAAA,YAE9D,aAAY;AAAA;AAAA,QACd;AAAA,QACA,oBAAC,OAAE,WAAU,4BAA2B,wDAExC;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;AAEA,IAAO,2BAAQ;","names":[]}
@@ -0,0 +1,213 @@
1
+ "use client";
2
+ import {
3
+ OptionsEditor
4
+ } from "./chunk-XTCEPJ7B.js";
5
+
6
+ // src/admin/fields/SelectFieldEditor.tsx
7
+ import { Input } from "@nextlyhq/ui";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ function SelectFieldEditor({
10
+ field,
11
+ onUpdate
12
+ }) {
13
+ const updateValidation = (key, value) => {
14
+ onUpdate({
15
+ validation: {
16
+ ...field.validation,
17
+ [key]: value
18
+ }
19
+ });
20
+ };
21
+ const availableOptions = field.options || [];
22
+ return /* @__PURE__ */ jsxs("div", { className: "select-field-editor", children: [
23
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__section", children: [
24
+ /* @__PURE__ */ jsx("h4", { className: "select-field-editor__section-title", children: "General" }),
25
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__field", children: [
26
+ /* @__PURE__ */ jsx("label", { className: "select-field-editor__label", htmlFor: "field-label", children: "Label" }),
27
+ /* @__PURE__ */ jsx(
28
+ Input,
29
+ {
30
+ id: "field-label",
31
+ type: "text",
32
+ value: field.label || "",
33
+ onChange: (e) => onUpdate({ label: e.target.value }),
34
+ placeholder: "Enter field label"
35
+ }
36
+ )
37
+ ] }),
38
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__field", children: [
39
+ /* @__PURE__ */ jsx("label", { className: "select-field-editor__label", htmlFor: "field-name", children: "Field Name" }),
40
+ /* @__PURE__ */ jsx(
41
+ Input,
42
+ {
43
+ id: "field-name",
44
+ type: "text",
45
+ value: field.name || "",
46
+ onChange: (e) => onUpdate({
47
+ name: e.target.value.replace(/\s+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase()
48
+ }),
49
+ placeholder: "field_name",
50
+ className: "select-field-editor__input--mono"
51
+ }
52
+ ),
53
+ /* @__PURE__ */ jsx("p", { className: "select-field-editor__hint", children: "Used as the key in submission data. Only letters, numbers, and underscores." })
54
+ ] }),
55
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__field", children: [
56
+ /* @__PURE__ */ jsx(
57
+ "label",
58
+ {
59
+ className: "select-field-editor__label",
60
+ htmlFor: "field-placeholder",
61
+ children: "Placeholder"
62
+ }
63
+ ),
64
+ /* @__PURE__ */ jsx(
65
+ Input,
66
+ {
67
+ id: "field-placeholder",
68
+ type: "text",
69
+ value: field.placeholder || "",
70
+ onChange: (e) => onUpdate({ placeholder: e.target.value }),
71
+ placeholder: "Choose an option..."
72
+ }
73
+ )
74
+ ] }),
75
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__field", children: [
76
+ /* @__PURE__ */ jsx("label", { className: "select-field-editor__label", htmlFor: "field-help", children: "Help Text" }),
77
+ /* @__PURE__ */ jsx(
78
+ Input,
79
+ {
80
+ id: "field-help",
81
+ type: "text",
82
+ value: field.helpText || "",
83
+ onChange: (e) => onUpdate({ helpText: e.target.value }),
84
+ placeholder: "Additional guidance for users"
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsx("p", { className: "select-field-editor__hint", children: "Displayed below the field" })
88
+ ] }),
89
+ /* @__PURE__ */ jsx("div", { className: "select-field-editor__field select-field-editor__field--inline", children: /* @__PURE__ */ jsxs("label", { className: "select-field-editor__checkbox-label", children: [
90
+ /* @__PURE__ */ jsx(
91
+ "input",
92
+ {
93
+ type: "checkbox",
94
+ checked: field.required || false,
95
+ onChange: (e) => onUpdate({ required: e.target.checked }),
96
+ className: "select-field-editor__checkbox"
97
+ }
98
+ ),
99
+ /* @__PURE__ */ jsx("span", { children: "Required field" })
100
+ ] }) })
101
+ ] }),
102
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__section", children: [
103
+ /* @__PURE__ */ jsx("h4", { className: "select-field-editor__section-title", children: "Options" }),
104
+ /* @__PURE__ */ jsx(
105
+ OptionsEditor,
106
+ {
107
+ options: field.options || [],
108
+ onOptionsChange: (options) => onUpdate({ options })
109
+ }
110
+ )
111
+ ] }),
112
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__section", children: [
113
+ /* @__PURE__ */ jsx("h4", { className: "select-field-editor__section-title", children: "Settings" }),
114
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__field select-field-editor__field--inline", children: [
115
+ /* @__PURE__ */ jsxs("label", { className: "select-field-editor__checkbox-label", children: [
116
+ /* @__PURE__ */ jsx(
117
+ "input",
118
+ {
119
+ type: "checkbox",
120
+ checked: field.allowMultiple || false,
121
+ onChange: (e) => onUpdate({ allowMultiple: e.target.checked }),
122
+ className: "select-field-editor__checkbox"
123
+ }
124
+ ),
125
+ /* @__PURE__ */ jsx("span", { children: "Allow multiple selections" })
126
+ ] }),
127
+ /* @__PURE__ */ jsx("p", { className: "select-field-editor__hint", children: "Users can select more than one option" })
128
+ ] }),
129
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__field", children: [
130
+ /* @__PURE__ */ jsx(
131
+ "label",
132
+ {
133
+ className: "select-field-editor__label",
134
+ htmlFor: "field-default-value",
135
+ children: "Default Value"
136
+ }
137
+ ),
138
+ field.allowMultiple ? (
139
+ /* Multi-select: Checkboxes for default values */
140
+ /* @__PURE__ */ jsx("div", { className: "select-field-editor__default-multi", children: availableOptions.length > 0 ? availableOptions.map((opt) => {
141
+ const currentDefaults = Array.isArray(field.defaultValue) ? field.defaultValue : [];
142
+ const isSelected = currentDefaults.includes(opt.value);
143
+ return /* @__PURE__ */ jsxs(
144
+ "label",
145
+ {
146
+ className: "select-field-editor__default-option",
147
+ children: [
148
+ /* @__PURE__ */ jsx(
149
+ "input",
150
+ {
151
+ type: "checkbox",
152
+ checked: isSelected,
153
+ onChange: (e) => {
154
+ const newDefaults = e.target.checked ? [...currentDefaults, opt.value] : currentDefaults.filter((v) => v !== opt.value);
155
+ onUpdate({
156
+ defaultValue: newDefaults.length > 0 ? newDefaults : void 0
157
+ });
158
+ },
159
+ className: "select-field-editor__checkbox"
160
+ }
161
+ ),
162
+ /* @__PURE__ */ jsx("span", { children: opt.label })
163
+ ]
164
+ },
165
+ opt.value
166
+ );
167
+ }) : /* @__PURE__ */ jsx("p", { className: "select-field-editor__hint", children: "Add options above to set default values" }) })
168
+ ) : (
169
+ /* Single-select: Dropdown for default value */
170
+ /* @__PURE__ */ jsxs(
171
+ "select",
172
+ {
173
+ id: "field-default-value",
174
+ value: field.defaultValue || "",
175
+ onChange: (e) => onUpdate({
176
+ defaultValue: e.target.value || void 0
177
+ }),
178
+ className: "select-field-editor__select",
179
+ children: [
180
+ /* @__PURE__ */ jsx("option", { value: "", children: "No default" }),
181
+ availableOptions.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value))
182
+ ]
183
+ }
184
+ )
185
+ ),
186
+ /* @__PURE__ */ jsx("p", { className: "select-field-editor__hint", children: "Pre-selected when the form loads" })
187
+ ] })
188
+ ] }),
189
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__section", children: [
190
+ /* @__PURE__ */ jsx("h4", { className: "select-field-editor__section-title", children: "Validation" }),
191
+ /* @__PURE__ */ jsxs("div", { className: "select-field-editor__field", children: [
192
+ /* @__PURE__ */ jsx("label", { className: "select-field-editor__label", htmlFor: "field-error", children: "Error Message" }),
193
+ /* @__PURE__ */ jsx(
194
+ Input,
195
+ {
196
+ id: "field-error",
197
+ type: "text",
198
+ value: field.validation?.errorMessage || "",
199
+ onChange: (e) => updateValidation("errorMessage", e.target.value || void 0),
200
+ placeholder: "Please select an option"
201
+ }
202
+ ),
203
+ /* @__PURE__ */ jsx("p", { className: "select-field-editor__hint", children: "Custom message shown when validation fails" })
204
+ ] })
205
+ ] })
206
+ ] });
207
+ }
208
+ var SelectFieldEditor_default = SelectFieldEditor;
209
+ export {
210
+ SelectFieldEditor,
211
+ SelectFieldEditor_default as default
212
+ };
213
+ //# sourceMappingURL=SelectFieldEditor-PSO4KHV4.js.map