@forms.expert/sdk 0.2.12 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +3 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +94 -16
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +3 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +94 -16
- package/dist/react/index.js.map +1 -1
- package/dist/vanilla/index.cjs +27 -27
- package/dist/vanilla/index.cjs.map +1 -1
- package/dist/vanilla/index.d.cts +3 -0
- package/dist/vanilla/index.d.ts +3 -0
- package/dist/vanilla/index.global.js +27 -27
- package/dist/vanilla/index.global.js.map +1 -1
- package/dist/vanilla/index.js +28 -28
- package/dist/vanilla/index.js.map +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +3 -0
- package/dist/vue/index.d.ts +3 -0
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ interface FormField {
|
|
|
49
49
|
operator: 'eq' | 'neq' | 'contains' | 'gt' | 'lt';
|
|
50
50
|
value: unknown;
|
|
51
51
|
};
|
|
52
|
+
row?: number;
|
|
53
|
+
width?: '1/4' | '1/3' | '1/2' | '2/3' | '3/4' | 'full';
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* Secondary button configuration
|
|
@@ -89,6 +91,7 @@ interface FormStyling {
|
|
|
89
91
|
formWidth?: 'narrow' | 'medium' | 'wide' | 'full';
|
|
90
92
|
fieldLayout?: 'stacked' | 'inline';
|
|
91
93
|
fieldBorderStyle?: 'full' | 'bottom';
|
|
94
|
+
fieldBorderRadius?: 'none' | 'small' | 'medium' | 'large' | 'full';
|
|
92
95
|
buttonColor?: string;
|
|
93
96
|
buttonText?: string;
|
|
94
97
|
buttonRadius?: 'none' | 'small' | 'medium' | 'large' | 'full';
|
package/dist/react/index.js
CHANGED
|
@@ -555,6 +555,65 @@ function getBorderRadius(radius) {
|
|
|
555
555
|
return "0.375rem";
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
+
function getFieldBorderRadius(radius) {
|
|
559
|
+
switch (radius) {
|
|
560
|
+
case "none":
|
|
561
|
+
return "0";
|
|
562
|
+
case "small":
|
|
563
|
+
return "0.25rem";
|
|
564
|
+
case "medium":
|
|
565
|
+
return "0.375rem";
|
|
566
|
+
case "large":
|
|
567
|
+
return "0.75rem";
|
|
568
|
+
case "full":
|
|
569
|
+
return "9999px";
|
|
570
|
+
default:
|
|
571
|
+
return "0.375rem";
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
function getWidthPercent(width) {
|
|
575
|
+
switch (width) {
|
|
576
|
+
case "1/4":
|
|
577
|
+
return "25%";
|
|
578
|
+
case "1/3":
|
|
579
|
+
return "33.333%";
|
|
580
|
+
case "1/2":
|
|
581
|
+
return "50%";
|
|
582
|
+
case "2/3":
|
|
583
|
+
return "66.666%";
|
|
584
|
+
case "3/4":
|
|
585
|
+
return "75%";
|
|
586
|
+
case "full":
|
|
587
|
+
return "100%";
|
|
588
|
+
default:
|
|
589
|
+
return void 0;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
function groupFieldsIntoRows(fields) {
|
|
593
|
+
const result = [];
|
|
594
|
+
let i = 0;
|
|
595
|
+
while (i < fields.length) {
|
|
596
|
+
const field = fields[i];
|
|
597
|
+
if (field.row != null) {
|
|
598
|
+
const rowFields = [field];
|
|
599
|
+
let j = i + 1;
|
|
600
|
+
while (j < fields.length && fields[j].row === field.row) {
|
|
601
|
+
rowFields.push(fields[j]);
|
|
602
|
+
j++;
|
|
603
|
+
}
|
|
604
|
+
if (rowFields.length > 1) {
|
|
605
|
+
result.push({ type: "row", fields: rowFields });
|
|
606
|
+
} else {
|
|
607
|
+
result.push({ type: "single", field });
|
|
608
|
+
}
|
|
609
|
+
i = j;
|
|
610
|
+
} else {
|
|
611
|
+
result.push({ type: "single", field });
|
|
612
|
+
i++;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return result;
|
|
616
|
+
}
|
|
558
617
|
function getButtonRadius(radius) {
|
|
559
618
|
switch (radius) {
|
|
560
619
|
case "none":
|
|
@@ -1029,21 +1088,39 @@ function FormsExpertForm({
|
|
|
1029
1088
|
marginBottom: "0.5rem",
|
|
1030
1089
|
color: styling.textColor
|
|
1031
1090
|
}, children: form.config.hostedConfig?.pageTitle || form.config.name }),
|
|
1032
|
-
fields.map((
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1091
|
+
groupFieldsIntoRows(fields).map((group, idx) => {
|
|
1092
|
+
if (group.type === "single") {
|
|
1093
|
+
return /* @__PURE__ */ jsx2(
|
|
1094
|
+
FormFieldInput,
|
|
1095
|
+
{
|
|
1096
|
+
field: group.field,
|
|
1097
|
+
value: form.values[group.field.name],
|
|
1098
|
+
error: form.errors[group.field.name],
|
|
1099
|
+
onChange: handleChange,
|
|
1100
|
+
onValueChange: (name, val) => form.setValue(name, val),
|
|
1101
|
+
styling,
|
|
1102
|
+
fieldSpacing,
|
|
1103
|
+
labelSpacing,
|
|
1104
|
+
phFontSize
|
|
1105
|
+
},
|
|
1106
|
+
group.field.name
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
return /* @__PURE__ */ jsx2("div", { style: { display: "flex", gap: "0.75rem", flexWrap: "wrap", marginBottom: fieldSpacing }, children: group.fields.map((f) => /* @__PURE__ */ jsx2("div", { style: { flex: getWidthPercent(f.width) ? `0 0 calc(${getWidthPercent(f.width)} - 0.75rem)` : "1 1 0", minWidth: "120px" }, children: /* @__PURE__ */ jsx2(
|
|
1110
|
+
FormFieldInput,
|
|
1111
|
+
{
|
|
1112
|
+
field: f,
|
|
1113
|
+
value: form.values[f.name],
|
|
1114
|
+
error: form.errors[f.name],
|
|
1115
|
+
onChange: handleChange,
|
|
1116
|
+
onValueChange: (name, val) => form.setValue(name, val),
|
|
1117
|
+
styling,
|
|
1118
|
+
fieldSpacing: "0",
|
|
1119
|
+
labelSpacing,
|
|
1120
|
+
phFontSize
|
|
1121
|
+
}
|
|
1122
|
+
) }, f.name)) }, `row-${idx}`);
|
|
1123
|
+
}),
|
|
1047
1124
|
form.honeypotEnabled && /* @__PURE__ */ jsx2("div", { style: { position: "absolute", left: "-9999px", opacity: 0, height: 0, overflow: "hidden" }, "aria-hidden": "true", children: /* @__PURE__ */ jsx2("input", { type: "text", name: "_hp", tabIndex: -1, autoComplete: "off" }) }),
|
|
1048
1125
|
form.requiresCaptcha && form.captchaProvider !== "recaptcha" && /* @__PURE__ */ jsx2("div", { ref: captchaContainerRef, style: { marginTop: "1rem" } }),
|
|
1049
1126
|
(() => {
|
|
@@ -1178,6 +1255,7 @@ function FormFieldInput({
|
|
|
1178
1255
|
phFontSize
|
|
1179
1256
|
}) {
|
|
1180
1257
|
const radius = getBorderRadius(styling.borderRadius);
|
|
1258
|
+
const fieldRadius = getFieldBorderRadius(styling.fieldBorderRadius);
|
|
1181
1259
|
const fontSize = getFontSize(styling.fontSize);
|
|
1182
1260
|
const isInline = styling.labelPosition === "left" || styling.fieldLayout === "inline";
|
|
1183
1261
|
const isBottomBorder = styling.fieldBorderStyle === "bottom";
|
|
@@ -1186,7 +1264,7 @@ function FormFieldInput({
|
|
|
1186
1264
|
padding: "0.5rem 0.75rem",
|
|
1187
1265
|
border: isBottomBorder ? "none" : `1px solid ${error ? "#ef4444" : styling.theme === "dark" ? "#4b5563" : "#d1d5db"}`,
|
|
1188
1266
|
...isBottomBorder ? { borderBottom: `1px solid ${error ? "#ef4444" : styling.theme === "dark" ? "#4b5563" : "#d1d5db"}` } : {},
|
|
1189
|
-
borderRadius: isBottomBorder ? 0 :
|
|
1267
|
+
borderRadius: isBottomBorder ? 0 : fieldRadius,
|
|
1190
1268
|
fontSize,
|
|
1191
1269
|
fontFamily: "inherit",
|
|
1192
1270
|
backgroundColor: styling.theme === "dark" ? "#374151" : "#ffffff",
|