@forms.expert/sdk 0.4.5 → 0.4.7

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.
@@ -1284,6 +1284,7 @@ function FormFieldInput({
1284
1284
  const isBottomBorder = styling.fieldBorderStyle === "bottom";
1285
1285
  const fieldPadding = styling.fieldPaddingX != null || styling.fieldPaddingY != null ? `${styling.fieldPaddingY ?? 8}px ${styling.fieldPaddingX ?? 12}px` : "0.5rem 0.75rem";
1286
1286
  const defaultBorderColor = error ? "#ef4444" : styling.fieldBorderColor || (styling.theme === "dark" ? "#4b5563" : "#d1d5db");
1287
+ const [selectOpen, setSelectOpen] = useState2(false);
1287
1288
  const inputStyle = {
1288
1289
  width: "100%",
1289
1290
  padding: fieldPadding,
@@ -1382,12 +1383,77 @@ function FormFieldInput({
1382
1383
  }
1383
1384
  );
1384
1385
  } else if (field.type === "select" || field.type === "dropdown") {
1385
- fieldEl = /* @__PURE__ */ jsxs("select", { id: field.name, name: field.name, value: String(value || ""), onChange, required: field.required, style: inputStyle, className: styling.fieldClassName, children: [
1386
- /* @__PURE__ */ jsx2("option", { value: "", children: "Select an option..." }),
1387
- getOpts().map((opt) => /* @__PURE__ */ jsx2("option", { value: opt.value, children: opt.label }, opt.value))
1386
+ const opts = getOpts();
1387
+ const selectedLabel = opts.find((o) => o.value === String(value || ""))?.label;
1388
+ fieldEl = /* @__PURE__ */ jsxs("div", { style: { position: "relative", width: "100%" }, className: styling.fieldClassName, children: [
1389
+ /* @__PURE__ */ jsxs(
1390
+ "button",
1391
+ {
1392
+ type: "button",
1393
+ id: field.name,
1394
+ onClick: () => setSelectOpen((v) => !v),
1395
+ onBlur: () => setTimeout(() => setSelectOpen(false), 150),
1396
+ style: {
1397
+ ...inputStyle,
1398
+ display: "flex",
1399
+ alignItems: "center",
1400
+ justifyContent: "space-between",
1401
+ cursor: "pointer",
1402
+ textAlign: "left"
1403
+ },
1404
+ children: [
1405
+ /* @__PURE__ */ jsx2("span", { style: !selectedLabel ? { color: styling.placeholderColor || (styling.theme === "dark" ? "#9ca3af" : "#9ca3af") } : void 0, children: selectedLabel || field.placeholder || "Select an option..." }),
1406
+ /* @__PURE__ */ jsx2("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", style: { flexShrink: 0, opacity: 0.5 }, children: /* @__PURE__ */ jsx2("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
1407
+ ]
1408
+ }
1409
+ ),
1410
+ selectOpen && /* @__PURE__ */ jsx2("div", { style: {
1411
+ position: "absolute",
1412
+ top: "100%",
1413
+ left: 0,
1414
+ right: 0,
1415
+ zIndex: 50,
1416
+ marginTop: "4px",
1417
+ backgroundColor: inputStyle.backgroundColor,
1418
+ border: inputStyle.border,
1419
+ borderRadius: inputStyle.borderRadius,
1420
+ boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
1421
+ maxHeight: "200px",
1422
+ overflowY: "auto"
1423
+ }, children: opts.map((opt) => /* @__PURE__ */ jsx2(
1424
+ "div",
1425
+ {
1426
+ onMouseDown: (e) => {
1427
+ e.preventDefault();
1428
+ onValueChange(field.name, opt.value);
1429
+ setSelectOpen(false);
1430
+ },
1431
+ style: {
1432
+ padding: inputStyle.padding,
1433
+ cursor: "pointer",
1434
+ backgroundColor: String(value || "") === opt.value ? styling.primaryColor + "20" : "transparent",
1435
+ fontSize: inputStyle.fontSize
1436
+ },
1437
+ onMouseEnter: (e) => {
1438
+ e.currentTarget.style.backgroundColor = styling.primaryColor + "15";
1439
+ },
1440
+ onMouseLeave: (e) => {
1441
+ e.currentTarget.style.backgroundColor = String(value || "") === opt.value ? styling.primaryColor + "20" : "transparent";
1442
+ },
1443
+ children: opt.label
1444
+ },
1445
+ opt.value
1446
+ )) }),
1447
+ /* @__PURE__ */ jsx2("input", { type: "hidden", name: field.name, value: String(value || ""), required: field.required })
1388
1448
  ] });
1389
1449
  } else if (field.type === "radio") {
1390
- fieldEl = /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: getOpts().map((opt) => /* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", cursor: "pointer" }, children: [
1450
+ fieldEl = /* @__PURE__ */ jsx2("div", { style: {
1451
+ ...inputStyle,
1452
+ display: "flex",
1453
+ flexDirection: "column",
1454
+ gap: "0.5rem",
1455
+ width: "100%"
1456
+ }, children: getOpts().map((opt) => /* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", cursor: "pointer" }, children: [
1391
1457
  /* @__PURE__ */ jsx2(
1392
1458
  "input",
1393
1459
  {
@@ -1396,14 +1462,20 @@ function FormFieldInput({
1396
1462
  value: opt.value,
1397
1463
  checked: value === opt.value,
1398
1464
  onChange: () => onValueChange(field.name, opt.value),
1399
- style: { accentColor: styling.primaryColor }
1465
+ style: { accentColor: styling.primaryColor, backgroundColor: "transparent" }
1400
1466
  }
1401
1467
  ),
1402
1468
  opt.label
1403
1469
  ] }, opt.value)) });
1404
1470
  } else if (field.type === "multiselect") {
1405
1471
  const selected = Array.isArray(value) ? value : [];
1406
- fieldEl = /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: getOpts().map((opt) => /* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", cursor: "pointer" }, children: [
1472
+ fieldEl = /* @__PURE__ */ jsx2("div", { style: {
1473
+ ...inputStyle,
1474
+ display: "flex",
1475
+ flexDirection: "column",
1476
+ gap: "0.5rem",
1477
+ width: "100%"
1478
+ }, children: getOpts().map((opt) => /* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", cursor: "pointer" }, children: [
1407
1479
  /* @__PURE__ */ jsx2(
1408
1480
  "input",
1409
1481
  {
@@ -1413,7 +1485,7 @@ function FormFieldInput({
1413
1485
  const next = selected.includes(opt.value) ? selected.filter((v) => v !== opt.value) : [...selected, opt.value];
1414
1486
  onValueChange(field.name, next);
1415
1487
  },
1416
- style: { accentColor: styling.primaryColor }
1488
+ style: { accentColor: styling.primaryColor, backgroundColor: "transparent" }
1417
1489
  }
1418
1490
  ),
1419
1491
  opt.label