@forms.expert/sdk 0.4.6 → 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.
@@ -1306,6 +1306,7 @@ function FormFieldInput({
1306
1306
  const isBottomBorder = styling.fieldBorderStyle === "bottom";
1307
1307
  const fieldPadding = styling.fieldPaddingX != null || styling.fieldPaddingY != null ? `${styling.fieldPaddingY ?? 8}px ${styling.fieldPaddingX ?? 12}px` : "0.5rem 0.75rem";
1308
1308
  const defaultBorderColor = error ? "#ef4444" : styling.fieldBorderColor || (styling.theme === "dark" ? "#4b5563" : "#d1d5db");
1309
+ const [selectOpen, setSelectOpen] = (0, import_react2.useState)(false);
1309
1310
  const inputStyle = {
1310
1311
  width: "100%",
1311
1312
  padding: fieldPadding,
@@ -1404,9 +1405,68 @@ function FormFieldInput({
1404
1405
  }
1405
1406
  );
1406
1407
  } else if (field.type === "select" || field.type === "dropdown") {
1407
- fieldEl = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { id: field.name, name: field.name, value: String(value || ""), onChange, required: field.required, style: inputStyle, className: styling.fieldClassName, children: [
1408
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "Select an option..." }),
1409
- getOpts().map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
1408
+ const opts = getOpts();
1409
+ const selectedLabel = opts.find((o) => o.value === String(value || ""))?.label;
1410
+ fieldEl = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { position: "relative", width: "100%" }, className: styling.fieldClassName, children: [
1411
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1412
+ "button",
1413
+ {
1414
+ type: "button",
1415
+ id: field.name,
1416
+ onClick: () => setSelectOpen((v) => !v),
1417
+ onBlur: () => setTimeout(() => setSelectOpen(false), 150),
1418
+ style: {
1419
+ ...inputStyle,
1420
+ display: "flex",
1421
+ alignItems: "center",
1422
+ justifyContent: "space-between",
1423
+ cursor: "pointer",
1424
+ textAlign: "left"
1425
+ },
1426
+ children: [
1427
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: !selectedLabel ? { color: styling.placeholderColor || (styling.theme === "dark" ? "#9ca3af" : "#9ca3af") } : void 0, children: selectedLabel || field.placeholder || "Select an option..." }),
1428
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", style: { flexShrink: 0, opacity: 0.5 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
1429
+ ]
1430
+ }
1431
+ ),
1432
+ selectOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
1433
+ position: "absolute",
1434
+ top: "100%",
1435
+ left: 0,
1436
+ right: 0,
1437
+ zIndex: 50,
1438
+ marginTop: "4px",
1439
+ backgroundColor: inputStyle.backgroundColor,
1440
+ border: inputStyle.border,
1441
+ borderRadius: inputStyle.borderRadius,
1442
+ boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
1443
+ maxHeight: "200px",
1444
+ overflowY: "auto"
1445
+ }, children: opts.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1446
+ "div",
1447
+ {
1448
+ onMouseDown: (e) => {
1449
+ e.preventDefault();
1450
+ onValueChange(field.name, opt.value);
1451
+ setSelectOpen(false);
1452
+ },
1453
+ style: {
1454
+ padding: inputStyle.padding,
1455
+ cursor: "pointer",
1456
+ backgroundColor: String(value || "") === opt.value ? styling.primaryColor + "20" : "transparent",
1457
+ fontSize: inputStyle.fontSize
1458
+ },
1459
+ onMouseEnter: (e) => {
1460
+ e.currentTarget.style.backgroundColor = styling.primaryColor + "15";
1461
+ },
1462
+ onMouseLeave: (e) => {
1463
+ e.currentTarget.style.backgroundColor = String(value || "") === opt.value ? styling.primaryColor + "20" : "transparent";
1464
+ },
1465
+ children: opt.label
1466
+ },
1467
+ opt.value
1468
+ )) }),
1469
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "hidden", name: field.name, value: String(value || ""), required: field.required })
1410
1470
  ] });
1411
1471
  } else if (field.type === "radio") {
1412
1472
  fieldEl = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {