@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.
@@ -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,9 +1383,68 @@ 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
1450
  fieldEl = /* @__PURE__ */ jsx2("div", { style: {