@nextlyhq/plugin-form-builder 0.0.2-alpha.50 → 0.0.2-alpha.52

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.
@@ -1,6 +1,6 @@
1
1
  import { ComponentPath } from '@nextlyhq/plugin-sdk/admin';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { q as FormField, s as FormFieldTypeId, A as AnyFormField, b as FormSettings, v as FormNotification } from '../types-r8uBeB0u.js';
3
+ import { q as FormField, s as FormFieldTypeId, A as AnyFormField, b as FormSettings, v as FormNotification } from '../types-DuEFdLNU.js';
4
4
  import { FormFieldCatalogType, FieldTypeCatalogEntry } from 'nextly/field-catalog';
5
5
  import { ReactNode } from 'react';
6
6
  import 'nextly';
@@ -4,7 +4,7 @@ import {
4
4
  formatExportValue,
5
5
  isKnownFormField,
6
6
  normalizeFormSettings
7
- } from "../chunk-WVI7N3QO.js";
7
+ } from "../chunk-XCICDELK.js";
8
8
 
9
9
  // src/admin/index.ts
10
10
  import {
@@ -880,7 +880,7 @@ function SubmissionsView({ collectionSlug }) {
880
880
  // src/admin/FormBuilderView.tsx
881
881
  import {
882
882
  Button as Button8,
883
- Input as Input7,
883
+ Input as Input6,
884
884
  toast,
885
885
  Tabs as Tabs4,
886
886
  TabsList as TabsList4,
@@ -1351,7 +1351,7 @@ import {
1351
1351
  } from "@nextlyhq/plugin-sdk/admin";
1352
1352
  import {
1353
1353
  FormLabelWithTooltip as FormLabelWithTooltip2,
1354
- Input as Input3,
1354
+ Input as Input2,
1355
1355
  Checkbox as Checkbox2,
1356
1356
  Tabs as Tabs2,
1357
1357
  TabsContent,
@@ -1366,9 +1366,11 @@ import {
1366
1366
  import { useState as useState5, useCallback as useCallback4, useMemo as useMemo4 } from "react";
1367
1367
 
1368
1368
  // src/admin/components/builder/ConditionalLogicEditor.tsx
1369
+ import {
1370
+ ConditionRow
1371
+ } from "@nextlyhq/plugin-sdk/admin";
1369
1372
  import {
1370
1373
  FormLabelWithTooltip,
1371
- Input as Input2,
1372
1374
  Button as Button4,
1373
1375
  Checkbox,
1374
1376
  Select as Select3,
@@ -1379,19 +1381,52 @@ import {
1379
1381
  } from "@nextlyhq/ui";
1380
1382
  import { useCallback as useCallback3, useMemo as useMemo3 } from "react";
1381
1383
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1382
- var COMPARISON_OPERATORS = [
1383
- { value: "equals", label: "Equals" },
1384
- { value: "notEquals", label: "Does not equal" },
1385
- { value: "contains", label: "Contains" },
1386
- { value: "isEmpty", label: "Is empty" },
1387
- { value: "isNotEmpty", label: "Is not empty" },
1388
- { value: "greaterThan", label: "Greater than" },
1389
- { value: "lessThan", label: "Less than" }
1384
+ var SUPPORTED_COMPARISONS = [
1385
+ "equals",
1386
+ "notEquals",
1387
+ "contains",
1388
+ "isEmpty",
1389
+ "isNotEmpty",
1390
+ "greaterThan",
1391
+ "lessThan"
1390
1392
  ];
1391
- function conditionValueToString(value) {
1392
- if (value === null || value === void 0) return "";
1393
- if (typeof value === "object") return JSON.stringify(value);
1394
- return String(value);
1393
+ var SUPPORTED_SET = new Set(SUPPORTED_COMPARISONS);
1394
+ function isSupportedComparison(operator) {
1395
+ return SUPPORTED_SET.has(operator);
1396
+ }
1397
+ var TEXT_TYPES = /* @__PURE__ */ new Set([
1398
+ "text",
1399
+ "textarea",
1400
+ "email",
1401
+ "url",
1402
+ "phone",
1403
+ "hidden"
1404
+ ]);
1405
+ function comparisonsForType(sourceType) {
1406
+ if (sourceType === "checkbox") return ["equals", "notEquals"];
1407
+ if (sourceType === "number") {
1408
+ return ["equals", "notEquals", "greaterThan", "lessThan"];
1409
+ }
1410
+ if (sourceType !== void 0 && TEXT_TYPES.has(sourceType)) {
1411
+ return ["equals", "notEquals", "contains", "isEmpty", "isNotEmpty"];
1412
+ }
1413
+ return [...SUPPORTED_COMPARISONS];
1414
+ }
1415
+ function toSource(field) {
1416
+ const options = "options" in field && Array.isArray(field.options) ? field.options.filter((option) => option.value !== "").map((option) => ({ value: option.value, label: option.label })) : void 0;
1417
+ return {
1418
+ name: field.name,
1419
+ label: field.label || field.name,
1420
+ type: field.type,
1421
+ options
1422
+ };
1423
+ }
1424
+ function toRowValue(value) {
1425
+ if (value === null || value === void 0) return void 0;
1426
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1427
+ return value;
1428
+ }
1429
+ return void 0;
1395
1430
  }
1396
1431
  function ConditionalLogicEditor({
1397
1432
  field,
@@ -1447,9 +1482,6 @@ function ConditionalLogicEditor({
1447
1482
  },
1448
1483
  [logic.conditions, updateLogic]
1449
1484
  );
1450
- const needsValue = (comparison) => {
1451
- return comparison !== "isEmpty" && comparison !== "isNotEmpty";
1452
- };
1453
1485
  return /* @__PURE__ */ jsxs4("div", { className: "space-y-6 pt-2", children: [
1454
1486
  /* @__PURE__ */ jsx5("div", { className: "space-y-2", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-3", children: [
1455
1487
  /* @__PURE__ */ jsx5(
@@ -1513,46 +1545,28 @@ function ConditionalLogicEditor({
1513
1545
  {
1514
1546
  className: "flex flex-col gap-2 p-3 rounded-none bg-muted border border-border relative group",
1515
1547
  children: [
1516
- /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-1 gap-2", children: [
1517
- /* @__PURE__ */ jsxs4(
1518
- Select3,
1519
- {
1520
- value: condition.field,
1521
- onValueChange: (value) => handleUpdateCondition(index, { field: value }),
1522
- children: [
1523
- /* @__PURE__ */ jsx5(SelectTrigger3, { className: "w-full bg-transparent border-input dark:bg-muted/50", children: /* @__PURE__ */ jsx5(SelectValue3, { placeholder: "Select field" }) }),
1524
- /* @__PURE__ */ jsx5(SelectContent3, { children: availableFields.map((f) => /* @__PURE__ */ jsx5(SelectItem3, { value: f.name, children: f.label || f.name }, f.name)) })
1525
- ]
1548
+ /* @__PURE__ */ jsx5(
1549
+ ConditionRow,
1550
+ {
1551
+ className: "grid grid-cols-1 gap-2",
1552
+ condition: {
1553
+ field: condition.field,
1554
+ operator: condition.comparison,
1555
+ value: toRowValue(condition.value)
1556
+ },
1557
+ sources: availableFields.map(toSource),
1558
+ operatorsFor: comparisonsForType,
1559
+ onChange: (next) => {
1560
+ if (!next || !isSupportedComparison(next.operator))
1561
+ return;
1562
+ handleUpdateCondition(index, {
1563
+ field: next.field,
1564
+ comparison: next.operator,
1565
+ value: toRowValue(next.value)
1566
+ });
1526
1567
  }
1527
- ),
1528
- /* @__PURE__ */ jsxs4("div", { className: "flex gap-2", children: [
1529
- /* @__PURE__ */ jsxs4(
1530
- Select3,
1531
- {
1532
- value: condition.comparison,
1533
- onValueChange: (value) => handleUpdateCondition(index, {
1534
- comparison: value
1535
- }),
1536
- children: [
1537
- /* @__PURE__ */ jsx5(SelectTrigger3, { className: "flex-1 h-9 bg-transparent border-input dark:bg-muted/50", children: /* @__PURE__ */ jsx5(SelectValue3, { placeholder: "Compare operator" }) }),
1538
- /* @__PURE__ */ jsx5(SelectContent3, { children: COMPARISON_OPERATORS.map((op) => /* @__PURE__ */ jsx5(SelectItem3, { value: op.value, children: op.label }, op.value)) })
1539
- ]
1540
- }
1541
- ),
1542
- needsValue(condition.comparison) && /* @__PURE__ */ jsx5(
1543
- Input2,
1544
- {
1545
- type: "text",
1546
- value: conditionValueToString(condition.value),
1547
- onChange: (e) => handleUpdateCondition(index, {
1548
- value: e.target.value
1549
- }),
1550
- placeholder: "Value",
1551
- className: "flex-1 h-9 bg-transparent"
1552
- }
1553
- )
1554
- ] })
1555
- ] }),
1568
+ }
1569
+ ),
1556
1570
  /* @__PURE__ */ jsx5(
1557
1571
  Button4,
1558
1572
  {
@@ -1612,7 +1626,7 @@ function GeneralTab({
1612
1626
  }
1613
1627
  ),
1614
1628
  /* @__PURE__ */ jsx6(
1615
- Input3,
1629
+ Input2,
1616
1630
  {
1617
1631
  id: "field-name",
1618
1632
  type: "text",
@@ -1634,7 +1648,7 @@ function GeneralTab({
1634
1648
  }
1635
1649
  ),
1636
1650
  /* @__PURE__ */ jsx6(
1637
- Input3,
1651
+ Input2,
1638
1652
  {
1639
1653
  id: "field-label",
1640
1654
  type: "text",
@@ -1654,7 +1668,7 @@ function GeneralTab({
1654
1668
  }
1655
1669
  ),
1656
1670
  /* @__PURE__ */ jsx6(
1657
- Input3,
1671
+ Input2,
1658
1672
  {
1659
1673
  id: "field-placeholder",
1660
1674
  type: "text",
@@ -1674,7 +1688,7 @@ function GeneralTab({
1674
1688
  }
1675
1689
  ),
1676
1690
  /* @__PURE__ */ jsx6(
1677
- Input3,
1691
+ Input2,
1678
1692
  {
1679
1693
  id: "field-help",
1680
1694
  type: "text",
@@ -1758,7 +1772,7 @@ function TypeSpecificOptions({
1758
1772
  }
1759
1773
  ),
1760
1774
  /* @__PURE__ */ jsx6(
1761
- Input3,
1775
+ Input2,
1762
1776
  {
1763
1777
  id: "field-rows",
1764
1778
  type: "number",
@@ -1784,7 +1798,7 @@ function TypeSpecificOptions({
1784
1798
  }
1785
1799
  ),
1786
1800
  /* @__PURE__ */ jsx6(
1787
- Input3,
1801
+ Input2,
1788
1802
  {
1789
1803
  id: "field-accept",
1790
1804
  type: "text",
@@ -1845,7 +1859,7 @@ function TypeSpecificOptions({
1845
1859
  }
1846
1860
  ),
1847
1861
  /* @__PURE__ */ jsx6(
1848
- Input3,
1862
+ Input2,
1849
1863
  {
1850
1864
  id: "field-default",
1851
1865
  type: "text",
@@ -1869,7 +1883,7 @@ function TypeSpecificOptions({
1869
1883
  }
1870
1884
  ),
1871
1885
  /* @__PURE__ */ jsx6(
1872
- Input3,
1886
+ Input2,
1873
1887
  {
1874
1888
  id: "min-date",
1875
1889
  type: "date",
@@ -1889,7 +1903,7 @@ function TypeSpecificOptions({
1889
1903
  }
1890
1904
  ),
1891
1905
  /* @__PURE__ */ jsx6(
1892
- Input3,
1906
+ Input2,
1893
1907
  {
1894
1908
  id: "max-date",
1895
1909
  type: "date",
@@ -1913,7 +1927,7 @@ function TypeSpecificOptions({
1913
1927
  }
1914
1928
  ),
1915
1929
  /* @__PURE__ */ jsx6(
1916
- Input3,
1930
+ Input2,
1917
1931
  {
1918
1932
  id: "field-step",
1919
1933
  type: "number",
@@ -1992,7 +2006,7 @@ function ValidationTab({
1992
2006
  }
1993
2007
  ),
1994
2008
  /* @__PURE__ */ jsx6(
1995
- Input3,
2009
+ Input2,
1996
2010
  {
1997
2011
  id: "error-message",
1998
2012
  type: "text",
@@ -2014,7 +2028,7 @@ function ValidationTab({
2014
2028
  }
2015
2029
  ),
2016
2030
  /* @__PURE__ */ jsx6(
2017
- Input3,
2031
+ Input2,
2018
2032
  {
2019
2033
  id: "min-len",
2020
2034
  type: "number",
@@ -2038,7 +2052,7 @@ function ValidationTab({
2038
2052
  }
2039
2053
  ),
2040
2054
  /* @__PURE__ */ jsx6(
2041
- Input3,
2055
+ Input2,
2042
2056
  {
2043
2057
  id: "max-len",
2044
2058
  type: "number",
@@ -2064,7 +2078,7 @@ function ValidationTab({
2064
2078
  }
2065
2079
  ),
2066
2080
  /* @__PURE__ */ jsx6(
2067
- Input3,
2081
+ Input2,
2068
2082
  {
2069
2083
  id: "min-val",
2070
2084
  type: "number",
@@ -2087,7 +2101,7 @@ function ValidationTab({
2087
2101
  }
2088
2102
  ),
2089
2103
  /* @__PURE__ */ jsx6(
2090
- Input3,
2104
+ Input2,
2091
2105
  {
2092
2106
  id: "max-val",
2093
2107
  type: "number",
@@ -2111,7 +2125,7 @@ function ValidationTab({
2111
2125
  }
2112
2126
  ),
2113
2127
  /* @__PURE__ */ jsx6(
2114
- Input3,
2128
+ Input2,
2115
2129
  {
2116
2130
  id: "val-pattern",
2117
2131
  type: "text",
@@ -2132,7 +2146,7 @@ function ValidationTab({
2132
2146
  }
2133
2147
  ),
2134
2148
  /* @__PURE__ */ jsx6(
2135
- Input3,
2149
+ Input2,
2136
2150
  {
2137
2151
  id: "max-file-size",
2138
2152
  type: "number",
@@ -2537,7 +2551,7 @@ import {
2537
2551
  DropdownMenuItem as DropdownMenuItem3,
2538
2552
  DropdownMenuSeparator as DropdownMenuSeparator2,
2539
2553
  DropdownMenuTrigger as DropdownMenuTrigger3,
2540
- Input as Input4,
2554
+ Input as Input3,
2541
2555
  Label as Label2,
2542
2556
  Select as Select5,
2543
2557
  SelectContent as SelectContent5,
@@ -2822,7 +2836,7 @@ function AddressChipList({
2822
2836
  )) }),
2823
2837
  /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
2824
2838
  /* @__PURE__ */ jsx8(
2825
- Input4,
2839
+ Input3,
2826
2840
  {
2827
2841
  id,
2828
2842
  type: "email",
@@ -2935,7 +2949,7 @@ function NotificationSheet({
2935
2949
  /* @__PURE__ */ jsxs7("div", { className: "space-y-1.5", children: [
2936
2950
  /* @__PURE__ */ jsx8(Label2, { htmlFor: "notification-name", children: "Name" }),
2937
2951
  /* @__PURE__ */ jsx8(
2938
- Input4,
2952
+ Input3,
2939
2953
  {
2940
2954
  id: "notification-name",
2941
2955
  type: "text",
@@ -3008,7 +3022,7 @@ function NotificationSheet({
3008
3022
  /* @__PURE__ */ jsxs7("div", { className: "space-y-1.5", children: [
3009
3023
  /* @__PURE__ */ jsx8(Label2, { htmlFor: "notification-sender", children: "Sender email" }),
3010
3024
  /* @__PURE__ */ jsx8(
3011
- Input4,
3025
+ Input3,
3012
3026
  {
3013
3027
  id: "notification-sender",
3014
3028
  type: "email",
@@ -3075,7 +3089,7 @@ function NotificationSheet({
3075
3089
  ]
3076
3090
  }
3077
3091
  ) : /* @__PURE__ */ jsx8(
3078
- Input4,
3092
+ Input3,
3079
3093
  {
3080
3094
  id: "notification-to",
3081
3095
  type: "email",
@@ -3149,7 +3163,7 @@ function NotificationSheet({
3149
3163
  replyToMode === "custom" && /* @__PURE__ */ jsxs7("div", { className: "space-y-1.5", children: [
3150
3164
  /* @__PURE__ */ jsx8(Label2, { htmlFor: "notification-replyto", children: "Reply-To address" }),
3151
3165
  /* @__PURE__ */ jsx8(
3152
- Input4,
3166
+ Input3,
3153
3167
  {
3154
3168
  id: "notification-replyto",
3155
3169
  type: "email",
@@ -3266,7 +3280,7 @@ function NotificationSheet({
3266
3280
  !VALUELESS_COMPARISONS.has(condition.comparison) && /* @__PURE__ */ jsxs7("div", { className: "min-w-36 flex-1 space-y-1.5", children: [
3267
3281
  /* @__PURE__ */ jsx8(Label2, { htmlFor: "notification-condition-value", children: "Value" }),
3268
3282
  /* @__PURE__ */ jsx8(
3269
- Input4,
3283
+ Input3,
3270
3284
  {
3271
3285
  id: "notification-condition-value",
3272
3286
  type: "text",
@@ -3429,7 +3443,7 @@ import {
3429
3443
  Badge as Badge4,
3430
3444
  Button as Button7,
3431
3445
  Checkbox as Checkbox3,
3432
- Input as Input5,
3446
+ Input as Input4,
3433
3447
  Label as Label3,
3434
3448
  RadioGroup,
3435
3449
  RadioGroupItem,
@@ -3517,7 +3531,7 @@ function PreviewFieldInput({
3517
3531
  }
3518
3532
  case "number":
3519
3533
  return /* @__PURE__ */ jsx9(
3520
- Input5,
3534
+ Input4,
3521
3535
  {
3522
3536
  id,
3523
3537
  type: "number",
@@ -3529,7 +3543,7 @@ function PreviewFieldInput({
3529
3543
  case "date":
3530
3544
  case "time":
3531
3545
  return /* @__PURE__ */ jsx9(
3532
- Input5,
3546
+ Input4,
3533
3547
  {
3534
3548
  id,
3535
3549
  type: field.type,
@@ -3544,7 +3558,7 @@ function PreviewFieldInput({
3544
3558
  ] });
3545
3559
  default:
3546
3560
  return /* @__PURE__ */ jsx9(
3547
- Input5,
3561
+ Input4,
3548
3562
  {
3549
3563
  id,
3550
3564
  type: field.type === "email" ? "email" : field.type === "url" ? "url" : field.type === "phone" ? "tel" : "text",
@@ -3724,7 +3738,7 @@ function FormPreview({ fields, formData }) {
3724
3738
 
3725
3739
  // src/admin/components/builder/FormSettingsTab.tsx
3726
3740
  import {
3727
- Input as Input6,
3741
+ Input as Input5,
3728
3742
  Label as Label4,
3729
3743
  RadioGroup as RadioGroup2,
3730
3744
  RadioGroupItem as RadioGroupItem2,
@@ -3804,7 +3818,7 @@ function FormSettingsTab({ spamDefaults }) {
3804
3818
  description: "Label on the form's primary action button",
3805
3819
  htmlFor: "settings-submit-text",
3806
3820
  children: /* @__PURE__ */ jsx10(
3807
- Input6,
3821
+ Input5,
3808
3822
  {
3809
3823
  id: "settings-submit-text",
3810
3824
  type: "text",
@@ -3881,7 +3895,7 @@ function FormSettingsTab({ spamDefaults }) {
3881
3895
  /* @__PURE__ */ jsxs9("div", { className: "w-full space-y-2", children: [
3882
3896
  /* @__PURE__ */ jsx10(Label4, { htmlFor: "settings-confirm-redirect", children: "Redirect to a URL" }),
3883
3897
  settings.confirmationType === "redirect" && /* @__PURE__ */ jsx10(
3884
- Input6,
3898
+ Input5,
3885
3899
  {
3886
3900
  "aria-label": "Redirect URL",
3887
3901
  type: "url",
@@ -3943,7 +3957,7 @@ function FormSettingsTab({ spamDefaults }) {
3943
3957
  description: "The client-facing site key for this form",
3944
3958
  htmlFor: "settings-captcha-key",
3945
3959
  children: /* @__PURE__ */ jsx10(
3946
- Input6,
3960
+ Input5,
3947
3961
  {
3948
3962
  id: "settings-captcha-key",
3949
3963
  type: "text",
@@ -4230,7 +4244,7 @@ function FormBuilderViewInner({
4230
4244
  }
4231
4245
  ),
4232
4246
  /* @__PURE__ */ jsx11(
4233
- Input7,
4247
+ Input6,
4234
4248
  {
4235
4249
  id: "form-name",
4236
4250
  type: "text",
@@ -4251,7 +4265,7 @@ function FormBuilderViewInner({
4251
4265
  }
4252
4266
  ),
4253
4267
  /* @__PURE__ */ jsx11(
4254
- Input7,
4268
+ Input6,
4255
4269
  {
4256
4270
  id: "form-slug",
4257
4271
  type: "text",