@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.
@@ -102,7 +102,7 @@ interface FormStyling {
102
102
  buttonColor?: string;
103
103
  buttonText?: string;
104
104
  buttonRadius?: 'none' | 'small' | 'medium' | 'large' | 'full';
105
- buttonAlign?: 'left' | 'center' | 'right';
105
+ buttonAlign?: 'left' | 'center' | 'right' | 'inline';
106
106
  buttonSize?: 'small' | 'medium' | 'large';
107
107
  buttonPaddingX?: number;
108
108
  buttonPaddingY?: number;
@@ -111,7 +111,7 @@ interface FormStyling {
111
111
  buttonFontSize?: number;
112
112
  buttonIcon?: string;
113
113
  buttonIconPosition?: 'left' | 'right';
114
- fieldSpacing?: 'compact' | 'normal' | 'relaxed' | 'spacious';
114
+ fieldSpacing?: 'none' | 'compact' | 'normal' | 'relaxed' | 'spacious';
115
115
  formPadding?: 'none' | 'compact' | 'normal' | 'relaxed' | 'spacious';
116
116
  labelSpacing?: 'compact' | 'normal' | 'relaxed';
117
117
  placeholderFontSize?: 'small' | 'medium' | 'large';
@@ -102,7 +102,7 @@ interface FormStyling {
102
102
  buttonColor?: string;
103
103
  buttonText?: string;
104
104
  buttonRadius?: 'none' | 'small' | 'medium' | 'large' | 'full';
105
- buttonAlign?: 'left' | 'center' | 'right';
105
+ buttonAlign?: 'left' | 'center' | 'right' | 'inline';
106
106
  buttonSize?: 'small' | 'medium' | 'large';
107
107
  buttonPaddingX?: number;
108
108
  buttonPaddingY?: number;
@@ -111,7 +111,7 @@ interface FormStyling {
111
111
  buttonFontSize?: number;
112
112
  buttonIcon?: string;
113
113
  buttonIconPosition?: 'left' | 'right';
114
- fieldSpacing?: 'compact' | 'normal' | 'relaxed' | 'spacious';
114
+ fieldSpacing?: 'none' | 'compact' | 'normal' | 'relaxed' | 'spacious';
115
115
  formPadding?: 'none' | 'compact' | 'normal' | 'relaxed' | 'spacious';
116
116
  labelSpacing?: 'compact' | 'normal' | 'relaxed';
117
117
  placeholderFontSize?: 'small' | 'medium' | 'large';
@@ -657,6 +657,8 @@ function getPlaceholderFontSize(size) {
657
657
  }
658
658
  function getFieldSpacing(spacing) {
659
659
  switch (spacing) {
660
+ case "none":
661
+ return "0";
660
662
  case "compact":
661
663
  return "0.5rem";
662
664
  case "relaxed":
@@ -1058,6 +1060,7 @@ function FormsExpertForm({
1058
1060
  form[data-fe-scope="${formScopeId}"] button[type="submit"]:active:not(:disabled) { filter: brightness(0.85); transform: scale(0.98); }
1059
1061
  form[data-fe-scope="${formScopeId}"] a[href]:hover { filter: brightness(0.9); }
1060
1062
  form[data-fe-scope="${formScopeId}"] a[href]:active { filter: brightness(0.85); }
1063
+ ${styling.buttonAlign === "inline" ? `form[data-fe-scope="${formScopeId}"] .fe-fields-inline > * { margin-bottom: 0 !important; }` : ""}
1061
1064
  form[data-fe-scope="${formScopeId}"] input:not([type="checkbox"]):not([type="radio"]):focus,
1062
1065
  form[data-fe-scope="${formScopeId}"] textarea:focus,
1063
1066
  form[data-fe-scope="${formScopeId}"] select:focus {
@@ -1091,140 +1094,142 @@ function FormsExpertForm({
1091
1094
  marginBottom: "0.5rem",
1092
1095
  color: styling.textColor
1093
1096
  }, children: form.config.hostedConfig?.pageTitle || form.config.name }),
1094
- groupFieldsIntoRows(fields).map((group, idx) => {
1095
- if (group.type === "single") {
1096
- return /* @__PURE__ */ jsx2(
1097
+ /* @__PURE__ */ jsxs("div", { style: styling.buttonAlign === "inline" ? { display: "flex", gap: "0.75rem", flexWrap: "wrap" } : void 0, children: [
1098
+ /* @__PURE__ */ jsx2("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) => {
1099
+ if (group.type === "single") {
1100
+ return /* @__PURE__ */ jsx2(
1101
+ FormFieldInput,
1102
+ {
1103
+ field: group.field,
1104
+ value: form.values[group.field.name],
1105
+ error: form.errors[group.field.name],
1106
+ onChange: handleChange,
1107
+ onValueChange: (name, val) => form.setValue(name, val),
1108
+ styling,
1109
+ fieldSpacing,
1110
+ labelSpacing,
1111
+ phFontSize
1112
+ },
1113
+ group.field.name
1114
+ );
1115
+ }
1116
+ 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: "180px" }, children: /* @__PURE__ */ jsx2(
1097
1117
  FormFieldInput,
1098
1118
  {
1099
- field: group.field,
1100
- value: form.values[group.field.name],
1101
- error: form.errors[group.field.name],
1119
+ field: f,
1120
+ value: form.values[f.name],
1121
+ error: form.errors[f.name],
1102
1122
  onChange: handleChange,
1103
1123
  onValueChange: (name, val) => form.setValue(name, val),
1104
1124
  styling,
1105
- fieldSpacing,
1125
+ fieldSpacing: "0",
1106
1126
  labelSpacing,
1107
1127
  phFontSize
1108
- },
1109
- group.field.name
1110
- );
1111
- }
1112
- 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: "180px" }, children: /* @__PURE__ */ jsx2(
1113
- FormFieldInput,
1114
- {
1115
- field: f,
1116
- value: form.values[f.name],
1117
- error: form.errors[f.name],
1118
- onChange: handleChange,
1119
- onValueChange: (name, val) => form.setValue(name, val),
1120
- styling,
1121
- fieldSpacing: "0",
1122
- labelSpacing,
1123
- phFontSize
1124
- }
1125
- ) }, f.name)) }, `row-${idx}`);
1126
- }),
1127
- 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" }) }),
1128
- form.requiresCaptcha && form.captchaProvider !== "recaptcha" && /* @__PURE__ */ jsx2("div", { ref: captchaContainerRef, style: { marginTop: "1rem" } }),
1129
- (() => {
1130
- const btnSizeMap = {
1131
- small: { px: "0.75rem", py: "0.375rem", fs: "0.875rem" },
1132
- medium: { px: "1.25rem", py: "0.625rem", fs: "1rem" },
1133
- large: { px: "1.75rem", py: "0.875rem", fs: "1.125rem" }
1134
- };
1135
- const btnSize = btnSizeMap[styling.buttonSize || "medium"];
1136
- const btnPx = styling.buttonPaddingX != null ? `${styling.buttonPaddingX}px` : btnSize.px;
1137
- const btnPy = styling.buttonPaddingY != null ? `${styling.buttonPaddingY}px` : btnSize.py;
1138
- const btnFs = styling.buttonFontSize != null ? `${styling.buttonFontSize}px` : btnSize.fs;
1139
- const btnBg = styling.buttonGradient || (styling.buttonStyle === "filled" ? btnBgColor : "transparent");
1140
- const sec = styling.secondaryButton;
1141
- const secColor = sec?.color || btnBgColor;
1142
- const secStyle = sec?.enabled ? {
1143
- display: "inline-flex",
1144
- alignItems: "center",
1145
- justifyContent: "center",
1146
- padding: `${btnPy} ${btnPx}`,
1147
- fontWeight: 500,
1148
- fontSize: sec.fontSize != null ? `${sec.fontSize}px` : btnFs,
1149
- fontFamily: "inherit",
1150
- borderRadius: btnRadius,
1151
- cursor: "pointer",
1152
- textDecoration: sec.style === "link" ? "underline" : "none",
1153
- background: sec.style === "filled" ? secColor : "transparent",
1154
- color: sec.textColor || (sec.style === "filled" ? "#ffffff" : secColor),
1155
- border: sec.style === "outlined" ? `2px solid ${secColor}` : "none",
1156
- marginTop: sec.marginTop != null ? `${sec.marginTop}px` : void 0,
1157
- marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0,
1158
- maxWidth: "100%",
1159
- boxSizing: "border-box",
1160
- flexShrink: 1,
1161
- minWidth: 0,
1162
- whiteSpace: "nowrap",
1163
- overflow: "hidden",
1164
- textOverflow: "ellipsis"
1165
- } : void 0;
1166
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1167
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: btnAlign, marginTop: "1rem", gap: "0.5rem", flexWrap: "wrap" }, children: [
1168
- sec?.enabled && secStyle && sec.position === "left" && /* @__PURE__ */ 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: [
1169
- sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1170
- /* @__PURE__ */ jsx2("span", { children: sec.text || "Learn More" }),
1171
- sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1128
+ }
1129
+ ) }, f.name)) }, `row-${idx}`);
1130
+ }) }),
1131
+ 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" }) }),
1132
+ form.requiresCaptcha && form.captchaProvider !== "recaptcha" && /* @__PURE__ */ jsx2("div", { ref: captchaContainerRef, style: { marginTop: "1rem" } }),
1133
+ (() => {
1134
+ const btnSizeMap = {
1135
+ small: { px: "0.75rem", py: "0.375rem", fs: "0.875rem" },
1136
+ medium: { px: "1.25rem", py: "0.625rem", fs: "1rem" },
1137
+ large: { px: "1.75rem", py: "0.875rem", fs: "1.125rem" }
1138
+ };
1139
+ const btnSize = btnSizeMap[styling.buttonSize || "medium"];
1140
+ const btnPx = styling.buttonPaddingX != null ? `${styling.buttonPaddingX}px` : btnSize.px;
1141
+ const btnPy = styling.buttonPaddingY != null ? `${styling.buttonPaddingY}px` : btnSize.py;
1142
+ const btnFs = styling.buttonFontSize != null ? `${styling.buttonFontSize}px` : btnSize.fs;
1143
+ const btnBg = styling.buttonGradient || (styling.buttonStyle === "filled" ? btnBgColor : "transparent");
1144
+ const sec = styling.secondaryButton;
1145
+ const secColor = sec?.color || btnBgColor;
1146
+ const secStyle = sec?.enabled ? {
1147
+ display: "inline-flex",
1148
+ alignItems: "center",
1149
+ justifyContent: "center",
1150
+ padding: `${btnPy} ${btnPx}`,
1151
+ fontWeight: 500,
1152
+ fontSize: sec.fontSize != null ? `${sec.fontSize}px` : btnFs,
1153
+ fontFamily: "inherit",
1154
+ borderRadius: btnRadius,
1155
+ cursor: "pointer",
1156
+ textDecoration: sec.style === "link" ? "underline" : "none",
1157
+ background: sec.style === "filled" ? secColor : "transparent",
1158
+ color: sec.textColor || (sec.style === "filled" ? "#ffffff" : secColor),
1159
+ border: sec.style === "outlined" ? `2px solid ${secColor}` : "none",
1160
+ marginTop: sec.marginTop != null ? `${sec.marginTop}px` : void 0,
1161
+ marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0,
1162
+ maxWidth: "100%",
1163
+ boxSizing: "border-box",
1164
+ flexShrink: 1,
1165
+ minWidth: 0,
1166
+ whiteSpace: "nowrap",
1167
+ overflow: "hidden",
1168
+ textOverflow: "ellipsis"
1169
+ } : void 0;
1170
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1171
+ /* @__PURE__ */ 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: [
1172
+ sec?.enabled && secStyle && sec.position === "left" && /* @__PURE__ */ 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: [
1173
+ sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1174
+ /* @__PURE__ */ jsx2("span", { children: sec.text || "Learn More" }),
1175
+ sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1176
+ ] }),
1177
+ /* @__PURE__ */ jsxs(
1178
+ "button",
1179
+ {
1180
+ type: "submit",
1181
+ disabled: form.isLoading,
1182
+ className: styling.buttonClassName,
1183
+ style: {
1184
+ ...styling.buttonFullWidth ? { width: "100%" } : styling.buttonAlign ? {} : { width: "100%" },
1185
+ padding: `${btnPy} ${btnPx}`,
1186
+ fontWeight: 500,
1187
+ fontSize: btnFs,
1188
+ fontFamily: "inherit",
1189
+ borderRadius: btnRadius,
1190
+ cursor: form.isLoading ? "not-allowed" : "pointer",
1191
+ opacity: form.isLoading ? 0.5 : 1,
1192
+ background: btnBg,
1193
+ color: styling.buttonStyle === "filled" ? btnTextColor || "white" : btnBgColor,
1194
+ border: styling.buttonStyle === "filled" ? "none" : `2px solid ${btnBgColor}`,
1195
+ maxWidth: "100%",
1196
+ boxSizing: "border-box",
1197
+ flexShrink: 1,
1198
+ minWidth: 0,
1199
+ whiteSpace: "nowrap",
1200
+ overflow: "hidden",
1201
+ textOverflow: "ellipsis",
1202
+ display: "inline-flex",
1203
+ alignItems: "center",
1204
+ justifyContent: "center",
1205
+ gap: "0.5rem"
1206
+ },
1207
+ children: [
1208
+ !form.isLoading && styling.buttonIcon && styling.buttonIconPosition !== "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } }),
1209
+ /* @__PURE__ */ jsx2("span", { children: form.isLoading ? "Submitting..." : resolvedButtonText }),
1210
+ !form.isLoading && styling.buttonIcon && styling.buttonIconPosition === "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } })
1211
+ ]
1212
+ }
1213
+ ),
1214
+ sec?.enabled && secStyle && sec.position !== "left" && sec.position !== "below" && /* @__PURE__ */ 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: [
1215
+ sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1216
+ /* @__PURE__ */ jsx2("span", { children: sec.text || "Learn More" }),
1217
+ sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1218
+ ] })
1172
1219
  ] }),
1173
- /* @__PURE__ */ jsxs(
1174
- "button",
1175
- {
1176
- type: "submit",
1177
- disabled: form.isLoading,
1178
- className: styling.buttonClassName,
1179
- style: {
1180
- ...styling.buttonFullWidth ? { width: "100%" } : styling.buttonAlign ? {} : { width: "100%" },
1181
- padding: `${btnPy} ${btnPx}`,
1182
- fontWeight: 500,
1183
- fontSize: btnFs,
1184
- fontFamily: "inherit",
1185
- borderRadius: btnRadius,
1186
- cursor: form.isLoading ? "not-allowed" : "pointer",
1187
- opacity: form.isLoading ? 0.5 : 1,
1188
- background: btnBg,
1189
- color: styling.buttonStyle === "filled" ? btnTextColor || "white" : btnBgColor,
1190
- border: styling.buttonStyle === "filled" ? "none" : `2px solid ${btnBgColor}`,
1191
- maxWidth: "100%",
1192
- boxSizing: "border-box",
1193
- flexShrink: 1,
1194
- minWidth: 0,
1195
- whiteSpace: "nowrap",
1196
- overflow: "hidden",
1197
- textOverflow: "ellipsis",
1198
- display: "inline-flex",
1199
- alignItems: "center",
1200
- justifyContent: "center",
1201
- gap: "0.5rem"
1202
- },
1203
- children: [
1204
- !form.isLoading && styling.buttonIcon && styling.buttonIconPosition !== "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } }),
1205
- /* @__PURE__ */ jsx2("span", { children: form.isLoading ? "Submitting..." : resolvedButtonText }),
1206
- !form.isLoading && styling.buttonIcon && styling.buttonIconPosition === "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: styling.buttonIcon } })
1207
- ]
1208
- }
1209
- ),
1210
- sec?.enabled && secStyle && sec.position !== "left" && sec.position !== "below" && /* @__PURE__ */ 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: [
1220
+ sec?.enabled && secStyle && sec.position === "below" && /* @__PURE__ */ jsx2("div", { style: {
1221
+ display: "flex",
1222
+ justifyContent: sec.align === "center" ? "center" : sec.align === "right" ? "flex-end" : sec.align === "left" ? "flex-start" : btnAlign,
1223
+ marginTop: sec.marginTop != null ? `${sec.marginTop}px` : "0.5rem",
1224
+ marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0
1225
+ }, children: /* @__PURE__ */ 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: [
1211
1226
  sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1212
1227
  /* @__PURE__ */ jsx2("span", { children: sec.text || "Learn More" }),
1213
1228
  sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1214
- ] })
1215
- ] }),
1216
- sec?.enabled && secStyle && sec.position === "below" && /* @__PURE__ */ jsx2("div", { style: {
1217
- display: "flex",
1218
- justifyContent: sec.align === "center" ? "center" : sec.align === "right" ? "flex-end" : sec.align === "left" ? "flex-start" : btnAlign,
1219
- marginTop: sec.marginTop != null ? `${sec.marginTop}px` : "0.5rem",
1220
- marginBottom: sec.marginBottom != null ? `${sec.marginBottom}px` : void 0
1221
- }, children: /* @__PURE__ */ 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: [
1222
- sec.icon && sec.iconPosition !== "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } }),
1223
- /* @__PURE__ */ jsx2("span", { children: sec.text || "Learn More" }),
1224
- sec.icon && sec.iconPosition === "right" && /* @__PURE__ */ jsx2("span", { style: { display: "inline-flex", flexShrink: 0 }, dangerouslySetInnerHTML: { __html: sec.icon } })
1225
- ] }) })
1226
- ] });
1227
- })(),
1229
+ ] }) })
1230
+ ] });
1231
+ })()
1232
+ ] }),
1228
1233
  showBranding && /* @__PURE__ */ jsx2(
1229
1234
  "div",
1230
1235
  {