@nextlyhq/plugin-form-builder 0.0.2-alpha.34 → 0.0.2-alpha.37

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 (38) hide show
  1. package/README.md +4 -5
  2. package/dist/admin/index.d.ts +122 -315
  3. package/dist/admin/index.js +3836 -3421
  4. package/dist/admin/index.js.map +1 -1
  5. package/dist/chunk-WVI7N3QO.js +559 -0
  6. package/dist/chunk-WVI7N3QO.js.map +1 -0
  7. package/dist/index.d.ts +8 -8
  8. package/dist/index.js +440 -611
  9. package/dist/index.js.map +1 -1
  10. package/dist/{index-BRumOEsE.d.ts → types-r8uBeB0u.d.ts} +97 -96
  11. package/package.json +23 -31
  12. package/dist/CheckboxFieldEditor-K4T6QX52.js +0 -121
  13. package/dist/CheckboxFieldEditor-K4T6QX52.js.map +0 -1
  14. package/dist/DateFieldEditor-JFJFAVOH.js +0 -187
  15. package/dist/DateFieldEditor-JFJFAVOH.js.map +0 -1
  16. package/dist/EmailFieldEditor-ZZ4VSKKB.js +0 -138
  17. package/dist/EmailFieldEditor-ZZ4VSKKB.js.map +0 -1
  18. package/dist/NumberFieldEditor-UISAYR6Z.js +0 -175
  19. package/dist/NumberFieldEditor-UISAYR6Z.js.map +0 -1
  20. package/dist/RadioFieldEditor-6UQFH4WT.js +0 -165
  21. package/dist/RadioFieldEditor-6UQFH4WT.js.map +0 -1
  22. package/dist/SelectFieldEditor-PSO4KHV4.js +0 -213
  23. package/dist/SelectFieldEditor-PSO4KHV4.js.map +0 -1
  24. package/dist/TextFieldEditor-5EU64EA5.js +0 -187
  25. package/dist/TextFieldEditor-5EU64EA5.js.map +0 -1
  26. package/dist/TextareaFieldEditor-773G3LNM.js +0 -190
  27. package/dist/TextareaFieldEditor-773G3LNM.js.map +0 -1
  28. package/dist/admin/index.css +0 -91
  29. package/dist/admin/index.css.map +0 -1
  30. package/dist/chunk-2LLUO3TV.js +0 -547
  31. package/dist/chunk-2LLUO3TV.js.map +0 -1
  32. package/dist/chunk-XTCEPJ7B.js +0 -256
  33. package/dist/chunk-XTCEPJ7B.js.map +0 -1
  34. package/dist/components/index.d.ts +0 -3
  35. package/dist/components/index.js +0 -9
  36. package/dist/components/index.js.map +0 -1
  37. package/dist/styles/form-builder.css +0 -128
  38. package/dist/styles/submissions-filter.css +0 -74
@@ -1,5 +1,5 @@
1
- import React, { ComponentType } from 'react';
2
1
  import { RequestContext, CollectionConfig, FieldDefinition } from 'nextly';
2
+ import { ComponentType } from 'react';
3
3
 
4
4
  /**
5
5
  * Form Builder Plugin Types
@@ -47,6 +47,13 @@ interface FormEmailNotification {
47
47
  variables: Record<string, unknown>;
48
48
  /** Email provider id; undefined = system default. */
49
49
  providerId?: string;
50
+ /**
51
+ * Resolved sender address (rule's senderEmail, else the plugin's
52
+ * defaultFrom); undefined = template/provider default.
53
+ */
54
+ from?: string;
55
+ /** Resolved Reply-To address, if the rule configured one. */
56
+ replyTo?: string;
50
57
  /** CC addresses, if any. */
51
58
  cc?: string[];
52
59
  /** BCC addresses, if any. */
@@ -55,19 +62,25 @@ interface FormEmailNotification {
55
62
  notificationId?: string;
56
63
  }
57
64
  /**
58
- * A single email notification integration stored on a form.
59
- * Matches the shape saved by the form builder admin UI.
65
+ * A single email notification rule stored on a form.
66
+ * Matches the shape saved by the form builder admin UI. This is the ONE
67
+ * notification rule type — the admin context re-exports it rather than
68
+ * keeping a parallel copy.
60
69
  */
61
- interface FormNotificationItem {
70
+ interface FormNotification {
62
71
  /** Unique ID for this notification */
63
72
  id: string;
64
- /** Display name for this integration */
73
+ /** Display name for this notification rule */
65
74
  name: string;
66
75
  /** Whether this notification is active */
67
76
  enabled: boolean;
68
77
  /** ID of the email provider to use; undefined = system default */
69
78
  providerId?: string;
70
- /** Sender email override; undefined = use provider's configured address */
79
+ /**
80
+ * Sender email override. Resolution order at send time:
81
+ * this value, else the plugin's `notifications.defaultFrom` option, else
82
+ * the template/provider default.
83
+ */
71
84
  senderEmail?: string;
72
85
  /** How the recipient address is determined */
73
86
  recipientType: "static" | "field";
@@ -77,9 +90,26 @@ interface FormNotificationItem {
77
90
  cc: string[];
78
91
  /** BCC email addresses */
79
92
  bcc: string[];
93
+ /**
94
+ * Reply-To address: a `{{fieldName}}` reference to one of the form's
95
+ * email fields (resolved against the submission) or a literal address.
96
+ */
97
+ replyTo?: string;
98
+ /**
99
+ * Optional send condition evaluated against the submitted data. When set
100
+ * and unmet, the rule is skipped for that submission. A single condition
101
+ * covers the common case; the JSON storage leaves room to grow into a
102
+ * multi-condition tree without a migration.
103
+ */
104
+ condition?: ConditionalLogicCondition;
80
105
  /** Slug of the email template to use */
81
106
  templateSlug?: string;
82
107
  }
108
+ /**
109
+ * @deprecated Use {@link FormNotification}. Alias kept so existing imports
110
+ * keep compiling during the alpha; will be removed before a stable release.
111
+ */
112
+ type FormNotificationItem = FormNotification;
83
113
  /**
84
114
  * Form document structure (stored in database).
85
115
  */
@@ -87,9 +117,9 @@ interface FormDocument {
87
117
  id: string;
88
118
  slug: string;
89
119
  name: string;
90
- fields: FormField[];
120
+ fields: AnyFormField[];
91
121
  settings: FormSettings;
92
- notifications: FormNotificationItem[];
122
+ notifications: FormNotification[];
93
123
  webhooks?: WebhookConfig[];
94
124
  status: "draft" | "published" | "closed";
95
125
  createdAt: Date;
@@ -413,7 +443,7 @@ interface FormConfig {
413
443
  /**
414
444
  * Form fields definition.
415
445
  */
416
- fields: FormField[];
446
+ fields: AnyFormField[];
417
447
  /**
418
448
  * Form settings and behavior.
419
449
  */
@@ -441,9 +471,32 @@ interface FormConfig {
441
471
  */
442
472
  type FormField = TextFormField | EmailFormField | NumberFormField | PhoneFormField | UrlFormField | TextareaFormField | SelectFormField | CheckboxFormField | RadioFormField | FileFormField | DateFormField | TimeFormField | HiddenFormField;
443
473
  /**
444
- * All available form field type identifiers.
474
+ * A form field of a built-in type OR a plugin-contributed type. Stored form
475
+ * data and the builder work with this; `isKnownFormField` narrows it back to
476
+ * the closed `FormField` union so `switch (field.type)` keeps discriminating
477
+ * the built-ins (a `CustomFormField` in the union itself would collapse that).
478
+ */
479
+ type AnyFormField = FormField | CustomFormField;
480
+ /**
481
+ * All available built-in form field type identifiers.
445
482
  */
446
483
  type FormFieldType = "text" | "email" | "number" | "phone" | "url" | "textarea" | "select" | "checkbox" | "radio" | "file" | "date" | "time" | "hidden";
484
+ /**
485
+ * A form field's type on the wire: a built-in or a plugin-contributed type id
486
+ * that opted into the forms surface. The `(string & {})` arm admits the plugin
487
+ * id while keeping built-in autocomplete. Built-in `case` narrowing still works
488
+ * because every field-type switch keeps a `default` for the custom arm.
489
+ */
490
+ type FormFieldTypeId = FormFieldType | (string & {});
491
+ /** Every built-in form field type, as a value list (the single source shared
492
+ * by the field-type guard and the config validator). */
493
+ declare const BUILT_IN_FORM_FIELD_TYPES: readonly FormFieldType[];
494
+ /**
495
+ * Narrow an `AnyFormField` to the closed built-in `FormField` union. Returns
496
+ * `false` for a plugin-contributed field, so callers handle it generically
497
+ * before switching on the built-in discriminant.
498
+ */
499
+ declare function isKnownFormField(field: AnyFormField): field is FormField;
447
500
  /**
448
501
  * Base form field properties.
449
502
  * All form field types extend this interface.
@@ -475,6 +528,16 @@ interface BaseFormField {
475
528
  width?: "25%" | "33%" | "50%" | "66%" | "75%" | "100%";
476
529
  };
477
530
  }
531
+ /**
532
+ * A plugin-contributed form field type (outside the built-in union). Carries
533
+ * only the base properties — the plugin owns its editor component and value
534
+ * semantics — and its `type` is the plugin's registered field-type id. Kept a
535
+ * distinct union member so built-in `case` narrowing is unaffected while a
536
+ * plugin field still type-checks as a `FormField`.
537
+ */
538
+ interface CustomFormField extends Omit<BaseFormField, "type"> {
539
+ type: string & {};
540
+ }
478
541
  /**
479
542
  * Text input field.
480
543
  */
@@ -650,11 +713,19 @@ interface FormSettings {
650
713
  /**
651
714
  * Confirmation type after successful submission.
652
715
  * - "message": Display a success message
653
- * - "redirect": Redirect to a URL or linked document
716
+ * - "redirect": Redirect to a URL
717
+ * - "relationship": Redirect to a linked document (requires
718
+ * `redirectRelationships` in the plugin options)
654
719
  *
655
720
  * @default "message"
656
721
  */
657
- confirmationType?: "message" | "redirect";
722
+ confirmationType?: "message" | "redirect" | "relationship";
723
+ /**
724
+ * Linked document for relationship-based redirects (the collection's
725
+ * `redirectPage` relationship value). Preserved verbatim — resolution
726
+ * happens where the relationship is rendered.
727
+ */
728
+ redirectPage?: unknown;
658
729
  /** Success message (supports HTML) - used when confirmationType is "message" */
659
730
  successMessage?: string;
660
731
  /** Redirect URL after successful submission - used when confirmationType is "redirect" */
@@ -667,13 +738,20 @@ interface FormSettings {
667
738
  relationTo: string;
668
739
  value: string;
669
740
  };
670
- /** Allow multiple submissions from same user/IP */
741
+ /** Allow multiple submissions from same IP (default true) */
671
742
  allowMultipleSubmissions?: boolean;
672
- /** reCAPTCHA configuration */
673
- captcha?: {
674
- enabled: boolean;
675
- siteKey?: string;
676
- };
743
+ /**
744
+ * Per-form honeypot override. Unset inherits the plugin's
745
+ * `spamProtection.honeypot`; the form wins where set.
746
+ */
747
+ honeypotEnabled?: boolean;
748
+ /**
749
+ * Per-form reCAPTCHA override. Unset inherits the plugin's
750
+ * `spamProtection.recaptcha.enabled`; the form wins where set.
751
+ */
752
+ captchaEnabled?: boolean;
753
+ /** reCAPTCHA site key (client-facing) when captcha is enabled per-form */
754
+ captchaSiteKey?: string;
677
755
  }
678
756
  /**
679
757
  * Email notification configuration for a form.
@@ -932,81 +1010,4 @@ declare function isCheckboxFormField(field: FormField): field is CheckboxFormFie
932
1010
  */
933
1011
  declare function isFileFormField(field: FormField): field is FileFormField;
934
1012
 
935
- /**
936
- * Props for the SubmissionList component.
937
- */
938
- interface SubmissionListProps {
939
- /** Form document containing field definitions */
940
- form: FormDocument;
941
- /** Array of submission documents to display */
942
- submissions: SubmissionDocument[];
943
- /** Whether data is currently loading */
944
- isLoading?: boolean;
945
- /** Callback when submission status is changed */
946
- onStatusChange?: (id: string, status: "new" | "read" | "archived") => Promise<void>;
947
- /** Callback when submission is deleted */
948
- onDelete?: (id: string) => Promise<void>;
949
- /** Callback when bulk delete is triggered */
950
- onBulkDelete?: (ids: string[]) => Promise<void>;
951
- /** Callback when bulk status change is triggered */
952
- onBulkStatusChange?: (ids: string[], status: "new" | "read" | "archived") => Promise<void>;
953
- /** Callback when export is triggered */
954
- onExport?: (format: "csv" | "json") => void;
955
- /** Callback when a submission is clicked for detail view */
956
- onViewDetail?: (submission: SubmissionDocument) => void;
957
- }
958
- /**
959
- * Submission List Component
960
- *
961
- * Displays form submissions in a table with filtering, selection, and actions.
962
- *
963
- * @example
964
- * ```tsx
965
- * <SubmissionList
966
- * form={form}
967
- * submissions={submissions}
968
- * onStatusChange={handleStatusChange}
969
- * onDelete={handleDelete}
970
- * onExport={handleExport}
971
- * onViewDetail={handleViewDetail}
972
- * />
973
- * ```
974
- */
975
- declare function SubmissionList({ form, submissions, isLoading, onStatusChange, onDelete, onBulkDelete, onBulkStatusChange, onExport, onViewDetail, }: SubmissionListProps): React.ReactElement;
976
-
977
- /**
978
- * Props for the SubmissionDetail component.
979
- */
980
- interface SubmissionDetailProps {
981
- /** Form document containing field definitions */
982
- form: FormDocument;
983
- /** Submission document to display */
984
- submission: SubmissionDocument;
985
- /** Callback when status is changed */
986
- onStatusChange?: (status: "new" | "read" | "archived") => Promise<void>;
987
- /** Callback when notes are updated */
988
- onNotesUpdate?: (notes: string) => Promise<void>;
989
- /** Callback when back button is clicked */
990
- onBack?: () => void;
991
- /** Callback when delete is triggered */
992
- onDelete?: () => Promise<void>;
993
- }
994
- /**
995
- * Submission Detail Component
996
- *
997
- * Displays full submission data with status management and notes.
998
- *
999
- * @example
1000
- * ```tsx
1001
- * <SubmissionDetail
1002
- * form={form}
1003
- * submission={submission}
1004
- * onStatusChange={handleStatusChange}
1005
- * onNotesUpdate={handleNotesUpdate}
1006
- * onBack={handleBack}
1007
- * />
1008
- * ```
1009
- */
1010
- declare function SubmissionDetail({ form, submission, onStatusChange, onNotesUpdate, onBack, onDelete, }: SubmissionDetailProps): React.ReactElement;
1011
-
1012
- export { isFormFieldType as A, type BaseFormField as B, type CheckboxFormField as C, type DateFormField as D, type EmailFormField as E, type FormBuilderPluginOptions as F, isSelectFormField as G, type HiddenFormField as H, isTextFormField as I, SubmissionDetail as J, SubmissionList as K, type NumberFormField as N, type PhoneFormField as P, type ResolvedFormBuilderConfig as R, type SelectFormField as S, type TextFormField as T, type UrlFormField as U, type ValidationRules as V, type WebhookEvent as W, type FormConfig as a, type FormSettings as b, type FormNotifications as c, type FileFormField as d, type RadioFormField as e, type TextareaFormField as f, type TimeFormField as g, type ConditionalLogic as h, type FormField as i, type SubmissionDocument as j, type FormDocument as k, type ConditionalLogicCondition as l, type EmailConfig as m, type FieldBlockConfig as n, type FormAccess as o, type FormFieldType as p, type FormHookContext as q, type FormHooks as r, type FormSubmission as s, type SubmissionDetailProps as t, type SubmissionListProps as u, type WebhookConfig as v, isCheckboxFormField as w, isEmailFormField as x, isFileFormField as y, isFormField as z };
1013
+ export { type AnyFormField as A, BUILT_IN_FORM_FIELD_TYPES as B, type CheckboxFormField as C, type DateFormField as D, type EmailFormField as E, type FormBuilderPluginOptions as F, isEmailFormField as G, type HiddenFormField as H, isFileFormField as I, isFormField as J, isFormFieldType as K, isKnownFormField as L, isSelectFormField as M, type NumberFormField as N, isTextFormField as O, type PhoneFormField as P, type ResolvedFormBuilderConfig as R, type SelectFormField as S, type TextFormField as T, type UrlFormField as U, type ValidationRules as V, type WebhookEvent as W, type FormConfig as a, type FormSettings as b, type FormNotifications as c, type FileFormField as d, type RadioFormField as e, type TextareaFormField as f, type TimeFormField as g, type ConditionalLogic as h, type SubmissionDocument as i, type FormDocument as j, type BaseFormField as k, type ConditionalLogicCondition as l, type CustomFormField as m, type EmailConfig as n, type FieldBlockConfig as o, type FormAccess as p, type FormField as q, type FormFieldType as r, type FormFieldTypeId as s, type FormHookContext as t, type FormHooks as u, type FormNotification as v, type FormNotificationItem as w, type FormSubmission as x, type WebhookConfig as y, isCheckboxFormField as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextlyhq/plugin-form-builder",
3
- "version": "0.0.2-alpha.34",
3
+ "version": "0.0.2-alpha.37",
4
4
  "description": "Visual form builder plugin for Nextly with Code-First and Schema Builder support",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,50 +17,42 @@
17
17
  "types": "./dist/admin/index.d.ts",
18
18
  "import": "./dist/admin/index.js",
19
19
  "default": "./dist/admin/index.js"
20
- },
21
- "./components": {
22
- "types": "./dist/components/index.d.ts",
23
- "import": "./dist/components/index.js",
24
- "default": "./dist/components/index.js"
25
- },
26
- "./styles/builder.css": "./dist/styles/form-builder.css",
27
- "./styles/submissions-filter.css": "./dist/styles/submissions-filter.css"
20
+ }
28
21
  },
29
22
  "files": [
30
23
  "dist",
31
24
  "README.md"
32
25
  ],
33
26
  "dependencies": {
34
- "@dnd-kit/core": "^6.1.0",
35
- "@dnd-kit/sortable": "^8.0.0",
27
+ "@dnd-kit/core": "^6.3.1",
28
+ "@dnd-kit/sortable": "^10.0.0",
36
29
  "@dnd-kit/utilities": "^3.2.2",
37
- "zod": "^3.22.4",
38
- "react-hook-form": "^7.50.0",
39
- "@hookform/resolvers": "^3.3.4"
30
+ "react-hook-form": "^7.66.0",
31
+ "zod": "^4.1.12"
40
32
  },
41
33
  "peerDependencies": {
42
- "@nextlyhq/admin": "0.0.2-alpha.34",
43
- "nextly": "0.0.2-alpha.34",
44
- "@nextlyhq/ui": "0.0.2-alpha.34",
34
+ "@nextlyhq/admin": "0.0.2-alpha.37",
35
+ "@nextlyhq/ui": "0.0.2-alpha.37",
45
36
  "@tanstack/react-query": ">=5.0.0",
46
37
  "lucide-react": ">=0.400.0",
47
- "react": "^18.0.0 || ^19.0.0",
48
38
  "next": "^14.0.0 || ^15.0.0 || ^16.0.0",
49
- "@nextlyhq/plugin-sdk": "0.0.2-alpha.34"
39
+ "nextly": "0.0.2-alpha.37",
40
+ "react": "^18.0.0 || ^19.0.0",
41
+ "@nextlyhq/plugin-sdk": "0.0.2-alpha.37"
50
42
  },
51
43
  "devDependencies": {
52
- "@tanstack/react-query": "^5.0.0",
53
- "@types/node": "^20.0.0",
44
+ "@tanstack/react-query": "^5.62.0",
45
+ "@types/node": "^20.19.17",
54
46
  "@types/react": "19.2.0",
55
- "lucide-react": "^0.469.0",
56
- "tsup": "^8.0.0",
57
- "typescript": "^5.3.0",
58
- "vitest": "^4.0.8",
59
- "@nextlyhq/tsconfig": "0.0.2-alpha.26",
60
- "@nextlyhq/admin": "0.0.2-alpha.34",
61
- "nextly": "0.0.2-alpha.34",
62
- "@nextlyhq/plugin-sdk": "0.0.2-alpha.34",
63
- "@nextlyhq/ui": "0.0.2-alpha.34"
47
+ "lucide-react": "^0.544.0",
48
+ "tsup": "^8.5.0",
49
+ "typescript": "^5.9.3",
50
+ "vitest": "^4.1.0",
51
+ "@nextlyhq/admin": "0.0.2-alpha.37",
52
+ "@nextlyhq/plugin-sdk": "0.0.2-alpha.37",
53
+ "@nextlyhq/ui": "0.0.2-alpha.37",
54
+ "@nextlyhq/tsconfig": "0.0.2-alpha.37",
55
+ "nextly": "0.0.2-alpha.37"
64
56
  },
65
57
  "engines": {
66
58
  "node": ">=20.0.0"
@@ -92,7 +84,7 @@
92
84
  "author": "Nextly <contact@nextlyhq.com> (https://nextlyhq.com)",
93
85
  "scripts": {
94
86
  "build": "tsup",
95
- "dev": "tsup src/index.ts src/admin/index.ts src/components/index.ts --format esm --dts --watch",
87
+ "dev": "tsup src/index.ts src/admin/index.ts --format esm --dts --watch",
96
88
  "check-types": "tsc --noEmit",
97
89
  "lint": "eslint . --max-warnings 0",
98
90
  "lint:fix": "eslint . --fix",
@@ -1,121 +0,0 @@
1
- "use client";
2
-
3
- // src/admin/fields/CheckboxFieldEditor.tsx
4
- import { Input } from "@nextlyhq/ui";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- function CheckboxFieldEditor({
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: "checkbox-field-editor", children: [
19
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__section", children: [
20
- /* @__PURE__ */ jsx("h4", { className: "checkbox-field-editor__section-title", children: "General" }),
21
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__field", children: [
22
- /* @__PURE__ */ jsx("label", { className: "checkbox-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: "I agree to the terms and conditions"
31
- }
32
- ),
33
- /* @__PURE__ */ jsx("p", { className: "checkbox-field-editor__hint", children: "Text displayed next to the checkbox" })
34
- ] }),
35
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__field", children: [
36
- /* @__PURE__ */ jsx("label", { className: "checkbox-field-editor__label", htmlFor: "field-name", children: "Field Name" }),
37
- /* @__PURE__ */ jsx(
38
- Input,
39
- {
40
- id: "field-name",
41
- type: "text",
42
- value: field.name || "",
43
- onChange: (e) => onUpdate({
44
- name: e.target.value.replace(/\s+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase()
45
- }),
46
- placeholder: "field_name",
47
- className: "checkbox-field-editor__input--mono"
48
- }
49
- ),
50
- /* @__PURE__ */ jsx("p", { className: "checkbox-field-editor__hint", children: "Used as the key in submission data. Only letters, numbers, and underscores." })
51
- ] }),
52
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__field", children: [
53
- /* @__PURE__ */ jsx("label", { className: "checkbox-field-editor__label", htmlFor: "field-help", children: "Help Text" }),
54
- /* @__PURE__ */ jsx(
55
- Input,
56
- {
57
- id: "field-help",
58
- type: "text",
59
- value: field.helpText || "",
60
- onChange: (e) => onUpdate({ helpText: e.target.value }),
61
- placeholder: "Additional guidance for users"
62
- }
63
- ),
64
- /* @__PURE__ */ jsx("p", { className: "checkbox-field-editor__hint", children: "Displayed below the field" })
65
- ] }),
66
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__field checkbox-field-editor__field--inline", children: [
67
- /* @__PURE__ */ jsxs("label", { className: "checkbox-field-editor__checkbox-label", children: [
68
- /* @__PURE__ */ jsx(
69
- "input",
70
- {
71
- type: "checkbox",
72
- checked: field.defaultValue || false,
73
- onChange: (e) => onUpdate({ defaultValue: e.target.checked }),
74
- className: "checkbox-field-editor__checkbox"
75
- }
76
- ),
77
- /* @__PURE__ */ jsx("span", { children: "Checked by default" })
78
- ] }),
79
- /* @__PURE__ */ jsx("p", { className: "checkbox-field-editor__hint", children: "Whether the checkbox is pre-checked when the form loads" })
80
- ] }),
81
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__field checkbox-field-editor__field--inline", children: [
82
- /* @__PURE__ */ jsxs("label", { className: "checkbox-field-editor__checkbox-label", children: [
83
- /* @__PURE__ */ jsx(
84
- "input",
85
- {
86
- type: "checkbox",
87
- checked: field.required || false,
88
- onChange: (e) => onUpdate({ required: e.target.checked }),
89
- className: "checkbox-field-editor__checkbox"
90
- }
91
- ),
92
- /* @__PURE__ */ jsx("span", { children: "Required field" })
93
- ] }),
94
- /* @__PURE__ */ jsx("p", { className: "checkbox-field-editor__hint", children: "User must check this box to submit the form (useful for terms acceptance)" })
95
- ] })
96
- ] }),
97
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__section", children: [
98
- /* @__PURE__ */ jsx("h4", { className: "checkbox-field-editor__section-title", children: "Validation" }),
99
- /* @__PURE__ */ jsxs("div", { className: "checkbox-field-editor__field", children: [
100
- /* @__PURE__ */ jsx("label", { className: "checkbox-field-editor__label", htmlFor: "field-error", children: "Error Message" }),
101
- /* @__PURE__ */ jsx(
102
- Input,
103
- {
104
- id: "field-error",
105
- type: "text",
106
- value: field.validation?.errorMessage || "",
107
- onChange: (e) => updateValidation("errorMessage", e.target.value || void 0),
108
- placeholder: "You must accept the terms to continue"
109
- }
110
- ),
111
- /* @__PURE__ */ jsx("p", { className: "checkbox-field-editor__hint", children: "Custom message shown when required checkbox is not checked" })
112
- ] })
113
- ] })
114
- ] });
115
- }
116
- var CheckboxFieldEditor_default = CheckboxFieldEditor;
117
- export {
118
- CheckboxFieldEditor,
119
- CheckboxFieldEditor_default as default
120
- };
121
- //# sourceMappingURL=CheckboxFieldEditor-K4T6QX52.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/admin/fields/CheckboxFieldEditor.tsx"],"sourcesContent":["/**\n * Checkbox Field Editor\n *\n * Editor component for configuring checkbox field properties.\n * Includes general settings (label, name, help text, required) and\n * default value configuration.\n *\n * Checkbox fields are typically used for:\n * - Terms and conditions acceptance\n * - Newsletter opt-in\n * - Boolean yes/no questions\n *\n * @module admin/fields/CheckboxFieldEditor\n * @since 0.1.0\n */\n\n\"use client\";\n\nimport { Input } from \"@nextlyhq/ui\";\n\nimport type { CheckboxFormField } from \"../../types\";\n\nimport type { FieldEditorProps } from \"./index\";\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * CheckboxFieldEditor - Configure checkbox field properties\n *\n * Provides configuration options for:\n * - Label: Text shown next to the checkbox (e.g., \"I agree to the terms\")\n * - Field Name: Key used in submission data (auto-formatted)\n * - Help Text: Additional guidance shown below the field\n * - Required: Whether the checkbox must be checked (for consent forms)\n * - Default Value: Whether the checkbox is checked by default\n * - Validation: error message\n *\n * @example\n * ```tsx\n * <CheckboxFieldEditor\n * field={checkboxField}\n * allFields={formFields}\n * onUpdate={(updates) => handleUpdate(updates)}\n * />\n * ```\n */\nexport function CheckboxFieldEditor({\n field,\n onUpdate,\n}: FieldEditorProps<CheckboxFormField>) {\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=\"checkbox-field-editor\">\n {/* General Settings Section */}\n <div className=\"checkbox-field-editor__section\">\n <h4 className=\"checkbox-field-editor__section-title\">General</h4>\n\n {/* Label */}\n <div className=\"checkbox-field-editor__field\">\n <label className=\"checkbox-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=\"I agree to the terms and conditions\"\n />\n <p className=\"checkbox-field-editor__hint\">\n Text displayed next to the checkbox\n </p>\n </div>\n\n {/* Field Name */}\n <div className=\"checkbox-field-editor__field\">\n <label className=\"checkbox-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=\"checkbox-field-editor__input--mono\"\n />\n <p className=\"checkbox-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=\"checkbox-field-editor__field\">\n <label className=\"checkbox-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=\"checkbox-field-editor__hint\">\n Displayed below the field\n </p>\n </div>\n\n {/* Default Value */}\n <div className=\"checkbox-field-editor__field checkbox-field-editor__field--inline\">\n <label className=\"checkbox-field-editor__checkbox-label\">\n <input\n type=\"checkbox\"\n checked={field.defaultValue || false}\n onChange={e => onUpdate({ defaultValue: e.target.checked })}\n className=\"checkbox-field-editor__checkbox\"\n />\n <span>Checked by default</span>\n </label>\n <p className=\"checkbox-field-editor__hint\">\n Whether the checkbox is pre-checked when the form loads\n </p>\n </div>\n\n {/* Required */}\n <div className=\"checkbox-field-editor__field checkbox-field-editor__field--inline\">\n <label className=\"checkbox-field-editor__checkbox-label\">\n <input\n type=\"checkbox\"\n checked={field.required || false}\n onChange={e => onUpdate({ required: e.target.checked })}\n className=\"checkbox-field-editor__checkbox\"\n />\n <span>Required field</span>\n </label>\n <p className=\"checkbox-field-editor__hint\">\n User must check this box to submit the form (useful for terms\n acceptance)\n </p>\n </div>\n </div>\n\n {/* Validation Section */}\n <div className=\"checkbox-field-editor__section\">\n <h4 className=\"checkbox-field-editor__section-title\">Validation</h4>\n\n {/* Error Message */}\n <div className=\"checkbox-field-editor__field\">\n <label className=\"checkbox-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=\"You must accept the terms to continue\"\n />\n <p className=\"checkbox-field-editor__hint\">\n Custom message shown when required checkbox is not checked\n </p>\n </div>\n </div>\n </div>\n );\n}\n\nexport default CheckboxFieldEditor;\n"],"mappings":";;;AAkBA,SAAS,aAAa;AAgDd,cAGA,YAHA;AAlBD,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAAwC;AAEtC,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,yBAEb;AAAA,yBAAC,SAAI,WAAU,kCACb;AAAA,0BAAC,QAAG,WAAU,wCAAuC,qBAAO;AAAA,MAG5D,qBAAC,SAAI,WAAU,gCACb;AAAA,4BAAC,WAAM,WAAU,gCAA+B,SAAQ,eAAc,mBAEtE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH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