@forms.expert/sdk 0.4.0 → 0.4.1

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.
@@ -42,6 +42,7 @@ interface FormField {
42
42
  paragraphFontSize?: number;
43
43
  consentText?: string;
44
44
  consentUrl?: string;
45
+ consentFontSize?: number;
45
46
  maxLength?: number;
46
47
  stepId?: string;
47
48
  visibleWhen?: {
@@ -75,15 +76,15 @@ interface SecondaryButton {
75
76
  * Form styling configuration
76
77
  */
77
78
  interface FormStyling {
78
- theme: 'light' | 'dark' | 'system';
79
+ theme: 'light' | 'dark' | 'system' | 'custom';
79
80
  primaryColor: string;
80
81
  backgroundColor: string;
81
82
  textColor: string;
82
83
  errorColor?: string;
83
84
  successColor?: string;
84
85
  borderRadius: 'none' | 'sm' | 'md' | 'lg';
85
- fontSize: 'sm' | 'md' | 'lg';
86
- buttonStyle: 'filled' | 'outline';
86
+ fontSize: 'sm' | 'md' | 'lg' | 'small' | 'medium' | 'large';
87
+ buttonStyle: 'filled' | 'outline' | 'outlined' | 'minimal';
87
88
  labelPosition: 'top' | 'left' | 'floating';
88
89
  labelClassName?: string;
89
90
  fieldClassName?: string;
@@ -42,6 +42,7 @@ interface FormField {
42
42
  paragraphFontSize?: number;
43
43
  consentText?: string;
44
44
  consentUrl?: string;
45
+ consentFontSize?: number;
45
46
  maxLength?: number;
46
47
  stepId?: string;
47
48
  visibleWhen?: {
@@ -75,15 +76,15 @@ interface SecondaryButton {
75
76
  * Form styling configuration
76
77
  */
77
78
  interface FormStyling {
78
- theme: 'light' | 'dark' | 'system';
79
+ theme: 'light' | 'dark' | 'system' | 'custom';
79
80
  primaryColor: string;
80
81
  backgroundColor: string;
81
82
  textColor: string;
82
83
  errorColor?: string;
83
84
  successColor?: string;
84
85
  borderRadius: 'none' | 'sm' | 'md' | 'lg';
85
- fontSize: 'sm' | 'md' | 'lg';
86
- buttonStyle: 'filled' | 'outline';
86
+ fontSize: 'sm' | 'md' | 'lg' | 'small' | 'medium' | 'large';
87
+ buttonStyle: 'filled' | 'outline' | 'outlined' | 'minimal';
87
88
  labelPosition: 'top' | 'left' | 'floating';
88
89
  labelClassName?: string;
89
90
  fieldClassName?: string;
@@ -633,10 +633,13 @@ function getButtonRadius(radius) {
633
633
  function getFontSize(size) {
634
634
  switch (size) {
635
635
  case "sm":
636
+ case "small":
636
637
  return "0.875rem";
637
638
  case "md":
639
+ case "medium":
638
640
  return "1rem";
639
641
  case "lg":
642
+ case "large":
640
643
  return "1.125rem";
641
644
  default:
642
645
  return "1rem";
@@ -1320,7 +1323,8 @@ function FormFieldInput({
1320
1323
  return /* @__PURE__ */ jsx2("input", { type: "hidden", name: field.name, value: String(value || field.defaultValue || "") });
1321
1324
  }
1322
1325
  if (field.type === "checkbox" || field.type === "toggle" || field.type === "consent") {
1323
- return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem", marginBottom: fieldSpacing }, children: [
1326
+ const consentSize = field.type === "consent" && field.consentFontSize ? `${field.consentFontSize}px` : void 0;
1327
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "flex-start", gap: "0.5rem", marginBottom: fieldSpacing }, children: [
1324
1328
  /* @__PURE__ */ jsx2(
1325
1329
  "input",
1326
1330
  {
@@ -1330,18 +1334,17 @@ function FormFieldInput({
1330
1334
  checked: Boolean(value),
1331
1335
  onChange,
1332
1336
  required: field.required,
1333
- style: { width: "1rem", height: "1rem", accentColor: styling.primaryColor }
1337
+ style: { width: "1rem", height: "1rem", accentColor: styling.primaryColor, marginTop: "0.125rem", flexShrink: 0 }
1334
1338
  }
1335
1339
  ),
1336
- (field.label || field.type === "consent" && field.consentText) && /* @__PURE__ */ jsxs("label", { htmlFor: field.name, className: styling.labelClassName, children: [
1337
- field.type === "consent" && field.consentText ? field.consentUrl ? /* @__PURE__ */ jsxs("span", { children: [
1338
- field.consentText,
1339
- " ",
1340
- /* @__PURE__ */ jsx2("a", { href: field.consentUrl, target: "_blank", rel: "noopener noreferrer", style: { color: styling.primaryColor }, children: "(link)" })
1341
- ] }) : field.consentText : field.label,
1342
- field.required && !styling.hideRequiredAsterisk && /* @__PURE__ */ jsx2("span", { style: { color: "#ef4444", marginLeft: "0.25rem" }, children: "*" })
1343
- ] }),
1344
- error && /* @__PURE__ */ jsx2("span", { style: { color: styling.errorColor || "#ef4444", fontSize: "0.875rem", marginLeft: "0.5rem" }, children: error })
1340
+ /* @__PURE__ */ jsxs("div", { children: [
1341
+ (field.label || field.type === "consent" && field.consentText) && /* @__PURE__ */ jsxs("label", { htmlFor: field.name, className: styling.labelClassName, style: { cursor: "pointer", ...consentSize ? { fontSize: consentSize } : {} }, children: [
1342
+ field.type === "consent" && field.consentText ? field.consentText : field.label,
1343
+ field.required && !styling.hideRequiredAsterisk && /* @__PURE__ */ jsx2("span", { style: { color: "#ef4444", marginLeft: "0.25rem" }, children: "*" })
1344
+ ] }),
1345
+ field.type === "consent" && field.consentUrl && /* @__PURE__ */ jsx2("a", { href: field.consentUrl, target: "_blank", rel: "noopener noreferrer", style: { color: styling.primaryColor, fontSize: "0.75rem", marginTop: "0.125rem", display: "inline-block" }, children: "View policy" }),
1346
+ error && /* @__PURE__ */ jsx2("div", { style: { color: styling.errorColor || "#ef4444", fontSize: "0.875rem", marginTop: "0.25rem" }, children: error })
1347
+ ] })
1345
1348
  ] });
1346
1349
  }
1347
1350
  const labelEl = field.label ? /* @__PURE__ */ jsxs(