@forms.expert/sdk 0.4.7 → 0.4.9

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.
@@ -679,6 +679,8 @@ function getPlaceholderFontSize(size) {
679
679
  }
680
680
  function getFieldSpacing(spacing) {
681
681
  switch (spacing) {
682
+ case "none":
683
+ return "0";
682
684
  case "compact":
683
685
  return "0.5rem";
684
686
  case "relaxed":
@@ -1080,6 +1082,7 @@ function FormsExpertForm({
1080
1082
  form[data-fe-scope="${formScopeId}"] button[type="submit"]:active:not(:disabled) { filter: brightness(0.85); transform: scale(0.98); }
1081
1083
  form[data-fe-scope="${formScopeId}"] a[href]:hover { filter: brightness(0.9); }
1082
1084
  form[data-fe-scope="${formScopeId}"] a[href]:active { filter: brightness(0.85); }
1085
+ ${styling.buttonAlign === "inline" ? `form[data-fe-scope="${formScopeId}"] .fe-fields-inline > * { margin-bottom: 0 !important; }` : ""}
1083
1086
  form[data-fe-scope="${formScopeId}"] input:not([type="checkbox"]):not([type="radio"]):focus,
1084
1087
  form[data-fe-scope="${formScopeId}"] textarea:focus,
1085
1088
  form[data-fe-scope="${formScopeId}"] select:focus {
@@ -1113,140 +1116,142 @@ function FormsExpertForm({
1113
1116
  marginBottom: "0.5rem",
1114
1117
  color: styling.textColor
1115
1118
  }, children: form.config.hostedConfig?.pageTitle || form.config.name }),
1116
- groupFieldsIntoRows(fields).map((group, idx) => {
1117
- if (group.type === "single") {
1118
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1119
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: styling.buttonAlign === "inline" ? { display: "flex", gap: "0.75rem", flexWrap: "wrap" } : void 0, children: [
1120
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: styling.buttonAlign === "inline" ? "fe-fields-inline" : void 0, style: styling.buttonAlign === "inline" ? { flex: "1 1 0", minWidth: "180px" } : void 0, children: groupFieldsIntoRows(fields).map((group, idx) => {
1121
+ if (group.type === "single") {
1122
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1123
+ FormFieldInput,
1124
+ {
1125
+ field: group.field,
1126
+ value: form.values[group.field.name],
1127
+ error: form.errors[group.field.name],
1128
+ onChange: handleChange,
1129
+ onValueChange: (name, val) => form.setValue(name, val),
1130
+ styling,
1131
+ fieldSpacing,
1132
+ labelSpacing,
1133
+ phFontSize
1134
+ },
1135
+ group.field.name
1136
+ );
1137
+ }
1138
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", gap: "0.75rem", flexWrap: "wrap", marginBottom: fieldSpacing }, children: group.fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { flex: getWidthPercent(f.width) ? `0 0 calc(${getWidthPercent(f.width)} - 0.75rem)` : "1 1 0", minWidth: "180px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1119
1139
  FormFieldInput,
1120
1140
  {
1121
- field: group.field,
1122
- value: form.values[group.field.name],
1123
- error: form.errors[group.field.name],
1141
+ field: f,
1142
+ value: form.values[f.name],
1143
+ error: form.errors[f.name],
1124
1144
  onChange: handleChange,
1125
1145
  onValueChange: (name, val) => form.setValue(name, val),
1126
1146
  styling,
1127
- fieldSpacing,
1147
+ fieldSpacing: "0",
1128
1148
  labelSpacing,
1129
1149
  phFontSize
1130
- },
1131
- group.field.name
1132
- );
1133
- }
1134
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", gap: "0.75rem", flexWrap: "wrap", marginBottom: fieldSpacing }, children: group.fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { flex: getWidthPercent(f.width) ? `0 0 calc(${getWidthPercent(f.width)} - 0.75rem)` : "1 1 0", minWidth: "180px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1135
- FormFieldInput,
1136
- {
1137
- field: f,
1138
- value: form.values[f.name],
1139
- error: form.errors[f.name],
1140
- onChange: handleChange,
1141
- onValueChange: (name, val) => form.setValue(name, val),
1142
- styling,
1143
- fieldSpacing: "0",
1144
- labelSpacing,
1145
- phFontSize
1146
- }
1147
- ) }, f.name)) }, `row-${idx}`);
1148
- }),
1149
- form.honeypotEnabled && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "absolute", left: "-9999px", opacity: 0, height: 0, overflow: "hidden" }, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "text", name: "_hp", tabIndex: -1, autoComplete: "off" }) }),
1150
- form.requiresCaptcha && form.captchaProvider !== "recaptcha" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: captchaContainerRef, style: { marginTop: "1rem" } }),
1151
- (() => {
1152
- const btnSizeMap = {
1153
- small: { px: "0.75rem", py: "0.375rem", fs: "0.875rem" },
1154
- medium: { px: "1.25rem", py: "0.625rem", fs: "1rem" },
1155
- large: { px: "1.75rem", py: "0.875rem", fs: "1.125rem" }
1156
- };
1157
- const btnSize = btnSizeMap[styling.buttonSize || "medium"];
1158
- const btnPx = styling.buttonPaddingX != null ? `${styling.buttonPaddingX}px` : btnSize.px;
1159
- const btnPy = styling.buttonPaddingY != null ? `${styling.buttonPaddingY}px` : btnSize.py;
1160
- const btnFs = styling.buttonFontSize != null ? `${styling.buttonFontSize}px` : btnSize.fs;
1161
- const btnBg = styling.buttonGradient || (styling.buttonStyle === "filled" ? btnBgColor : "transparent");
1162
- const sec = styling.secondaryButton;
1163
- const secColor = sec?.color || btnBgColor;
1164
- const secStyle = sec?.enabled ? {
1165
- display: "inline-flex",
1166
- alignItems: "center",
1167
- justifyContent: "center",
1168
- padding: `${btnPy} ${btnPx}`,
1169
- fontWeight: 500,
1170
- fontSize: sec.fontSize != null ? `${sec.fontSize}px` : btnFs,
1171
- fontFamily: "inherit",
1172
- borderRadius: btnRadius,
1173
- cursor: "pointer",
1174
- textDecoration: sec.style === "link" ? "underline" : "none",
1175
- background: sec.style === "filled" ? secColor : "transparent",
1176
- color: sec.textColor || (sec.style === "filled" ? "#ffffff" : secColor),
1177
- border: sec.style === "outlined" ? `2px solid ${secColor}` : "none",
1178
- marginTop: sec.marginTop != null ? `${sec.marginTop}px` : void 0,
1179
- marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0,
1180
- maxWidth: "100%",
1181
- boxSizing: "border-box",
1182
- flexShrink: 1,
1183
- minWidth: 0,
1184
- whiteSpace: "nowrap",
1185
- overflow: "hidden",
1186
- textOverflow: "ellipsis"
1187
- } : void 0;
1188
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1189
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", justifyContent: btnAlign, marginTop: "1rem", gap: "0.5rem", flexWrap: "wrap" }, children: [
1190
- sec?.enabled && secStyle && sec.position === "left" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: sec.href || "#", target: sec.openInNewTab ? "_blank" : void 0, rel: sec.openInNewTab ? "noopener noreferrer" : void 0, style: { ...secStyle, display: "inline-flex", alignItems: "center", gap: "0.5rem" }, children: [
1191
- sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1192
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: sec.text || "Learn More" }),
1193
- sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1150
+ }
1151
+ ) }, f.name)) }, `row-${idx}`);
1152
+ }) }),
1153
+ form.honeypotEnabled && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "absolute", left: "-9999px", opacity: 0, height: 0, overflow: "hidden" }, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "text", name: "_hp", tabIndex: -1, autoComplete: "off" }) }),
1154
+ form.requiresCaptcha && form.captchaProvider !== "recaptcha" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: captchaContainerRef, style: { marginTop: "1rem" } }),
1155
+ (() => {
1156
+ const btnSizeMap = {
1157
+ small: { px: "0.75rem", py: "0.375rem", fs: "0.875rem" },
1158
+ medium: { px: "1.25rem", py: "0.625rem", fs: "1rem" },
1159
+ large: { px: "1.75rem", py: "0.875rem", fs: "1.125rem" }
1160
+ };
1161
+ const btnSize = btnSizeMap[styling.buttonSize || "medium"];
1162
+ const btnPx = styling.buttonPaddingX != null ? `${styling.buttonPaddingX}px` : btnSize.px;
1163
+ const btnPy = styling.buttonPaddingY != null ? `${styling.buttonPaddingY}px` : btnSize.py;
1164
+ const btnFs = styling.buttonFontSize != null ? `${styling.buttonFontSize}px` : btnSize.fs;
1165
+ const btnBg = styling.buttonGradient || (styling.buttonStyle === "filled" ? btnBgColor : "transparent");
1166
+ const sec = styling.secondaryButton;
1167
+ const secColor = sec?.color || btnBgColor;
1168
+ const secStyle = sec?.enabled ? {
1169
+ display: "inline-flex",
1170
+ alignItems: "center",
1171
+ justifyContent: "center",
1172
+ padding: `${btnPy} ${btnPx}`,
1173
+ fontWeight: 500,
1174
+ fontSize: sec.fontSize != null ? `${sec.fontSize}px` : btnFs,
1175
+ fontFamily: "inherit",
1176
+ borderRadius: btnRadius,
1177
+ cursor: "pointer",
1178
+ textDecoration: sec.style === "link" ? "underline" : "none",
1179
+ background: sec.style === "filled" ? secColor : "transparent",
1180
+ color: sec.textColor || (sec.style === "filled" ? "#ffffff" : secColor),
1181
+ border: sec.style === "outlined" ? `2px solid ${secColor}` : "none",
1182
+ marginTop: sec.marginTop != null ? `${sec.marginTop}px` : void 0,
1183
+ marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0,
1184
+ maxWidth: "100%",
1185
+ boxSizing: "border-box",
1186
+ flexShrink: 1,
1187
+ minWidth: 0,
1188
+ whiteSpace: "nowrap",
1189
+ overflow: "hidden",
1190
+ textOverflow: "ellipsis"
1191
+ } : void 0;
1192
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1193
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", justifyContent: btnAlign, marginTop: styling.buttonAlign === "inline" ? void 0 : "1rem", gap: "0.5rem", flexWrap: "wrap", ...styling.buttonAlign === "inline" ? { alignSelf: "flex-end" } : {} }, children: [
1194
+ sec?.enabled && secStyle && sec.position === "left" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: sec.href || "#", target: sec.openInNewTab ? "_blank" : void 0, rel: sec.openInNewTab ? "noopener noreferrer" : void 0, style: { ...secStyle, display: "inline-flex", alignItems: "center", gap: "0.5rem" }, children: [
1195
+ sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1196
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: sec.text || "Learn More" }),
1197
+ sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1198
+ ] }),
1199
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1200
+ "button",
1201
+ {
1202
+ type: "submit",
1203
+ disabled: form.isLoading,
1204
+ className: styling.buttonClassName,
1205
+ style: {
1206
+ ...styling.buttonFullWidth ? { width: "100%" } : styling.buttonAlign ? {} : { width: "100%" },
1207
+ padding: `${btnPy} ${btnPx}`,
1208
+ fontWeight: 500,
1209
+ fontSize: btnFs,
1210
+ fontFamily: "inherit",
1211
+ borderRadius: btnRadius,
1212
+ cursor: form.isLoading ? "not-allowed" : "pointer",
1213
+ opacity: form.isLoading ? 0.5 : 1,
1214
+ background: btnBg,
1215
+ color: styling.buttonStyle === "filled" ? btnTextColor || "white" : btnBgColor,
1216
+ border: styling.buttonStyle === "filled" ? "none" : `2px solid ${btnBgColor}`,
1217
+ maxWidth: "100%",
1218
+ boxSizing: "border-box",
1219
+ flexShrink: 1,
1220
+ minWidth: 0,
1221
+ whiteSpace: "nowrap",
1222
+ overflow: "hidden",
1223
+ textOverflow: "ellipsis",
1224
+ display: "inline-flex",
1225
+ alignItems: "center",
1226
+ justifyContent: "center",
1227
+ gap: "0.5rem"
1228
+ },
1229
+ children: [
1230
+ !form.isLoading && styling.buttonIcon && styling.buttonIconPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } }),
1231
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: form.isLoading ? "Submitting..." : resolvedButtonText }),
1232
+ !form.isLoading && styling.buttonIcon && styling.buttonIconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } })
1233
+ ]
1234
+ }
1235
+ ),
1236
+ sec?.enabled && secStyle && sec.position !== "left" && sec.position !== "below" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: sec.href || "#", target: sec.openInNewTab ? "_blank" : void 0, rel: sec.openInNewTab ? "noopener noreferrer" : void 0, style: { ...secStyle, display: "inline-flex", alignItems: "center", gap: "0.5rem", marginLeft: "auto" }, children: [
1237
+ sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1238
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: sec.text || "Learn More" }),
1239
+ sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1240
+ ] })
1194
1241
  ] }),
1195
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1196
- "button",
1197
- {
1198
- type: "submit",
1199
- disabled: form.isLoading,
1200
- className: styling.buttonClassName,
1201
- style: {
1202
- ...styling.buttonFullWidth ? { width: "100%" } : styling.buttonAlign ? {} : { width: "100%" },
1203
- padding: `${btnPy} ${btnPx}`,
1204
- fontWeight: 500,
1205
- fontSize: btnFs,
1206
- fontFamily: "inherit",
1207
- borderRadius: btnRadius,
1208
- cursor: form.isLoading ? "not-allowed" : "pointer",
1209
- opacity: form.isLoading ? 0.5 : 1,
1210
- background: btnBg,
1211
- color: styling.buttonStyle === "filled" ? btnTextColor || "white" : btnBgColor,
1212
- border: styling.buttonStyle === "filled" ? "none" : `2px solid ${btnBgColor}`,
1213
- maxWidth: "100%",
1214
- boxSizing: "border-box",
1215
- flexShrink: 1,
1216
- minWidth: 0,
1217
- whiteSpace: "nowrap",
1218
- overflow: "hidden",
1219
- textOverflow: "ellipsis",
1220
- display: "inline-flex",
1221
- alignItems: "center",
1222
- justifyContent: "center",
1223
- gap: "0.5rem"
1224
- },
1225
- children: [
1226
- !form.isLoading && styling.buttonIcon && styling.buttonIconPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } }),
1227
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: form.isLoading ? "Submitting..." : resolvedButtonText }),
1228
- !form.isLoading && styling.buttonIcon && styling.buttonIconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } })
1229
- ]
1230
- }
1231
- ),
1232
- sec?.enabled && secStyle && sec.position !== "left" && sec.position !== "below" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: sec.href || "#", target: sec.openInNewTab ? "_blank" : void 0, rel: sec.openInNewTab ? "noopener noreferrer" : void 0, style: { ...secStyle, display: "inline-flex", alignItems: "center", gap: "0.5rem", marginLeft: "auto" }, children: [
1242
+ sec?.enabled && secStyle && sec.position === "below" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
1243
+ display: "flex",
1244
+ justifyContent: sec.align === "center" ? "center" : sec.align === "right" ? "flex-end" : sec.align === "left" ? "flex-start" : btnAlign,
1245
+ marginTop: sec.marginTop != null ? `${sec.marginTop}px` : "0.5rem",
1246
+ marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0
1247
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: sec.href || "#", target: sec.openInNewTab ? "_blank" : void 0, rel: sec.openInNewTab ? "noopener noreferrer" : void 0, style: { ...secStyle, display: "inline-flex", alignItems: "center", gap: "0.5rem", marginTop: 0, marginBottom: 0 }, children: [
1233
1248
  sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1234
1249
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: sec.text || "Learn More" }),
1235
1250
  sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1236
- ] })
1237
- ] }),
1238
- sec?.enabled && secStyle && sec.position === "below" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
1239
- display: "flex",
1240
- justifyContent: sec.align === "center" ? "center" : sec.align === "right" ? "flex-end" : sec.align === "left" ? "flex-start" : btnAlign,
1241
- marginTop: sec.marginTop != null ? `${sec.marginTop}px` : "0.5rem",
1242
- marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0
1243
- }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: sec.href || "#", target: sec.openInNewTab ? "_blank" : void 0, rel: sec.openInNewTab ? "noopener noreferrer" : void 0, style: { ...secStyle, display: "inline-flex", alignItems: "center", gap: "0.5rem", marginTop: 0, marginBottom: 0 }, children: [
1244
- sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1245
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: sec.text || "Learn More" }),
1246
- sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1247
- ] }) })
1248
- ] });
1249
- })(),
1251
+ ] }) })
1252
+ ] });
1253
+ })()
1254
+ ] }),
1250
1255
  showBranding && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1251
1256
  "div",
1252
1257
  {