@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.
- package/dist/react/index.cjs +79 -7
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +79 -7
- package/dist/react/index.js.map +1 -1
- package/dist/vanilla/index.cjs +74 -33
- package/dist/vanilla/index.cjs.map +1 -1
- package/dist/vanilla/index.global.js +74 -33
- package/dist/vanilla/index.global.js.map +1 -1
- package/dist/vanilla/index.js +71 -30
- package/dist/vanilla/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -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,12 +1405,77 @@ function FormFieldInput({
|
|
|
1404
1405
|
}
|
|
1405
1406
|
);
|
|
1406
1407
|
} else if (field.type === "select" || field.type === "dropdown") {
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
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
|
-
fieldEl = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
|
|
1472
|
+
fieldEl = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
|
|
1473
|
+
...inputStyle,
|
|
1474
|
+
display: "flex",
|
|
1475
|
+
flexDirection: "column",
|
|
1476
|
+
gap: "0.5rem",
|
|
1477
|
+
width: "100%"
|
|
1478
|
+
}, children: getOpts().map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", cursor: "pointer" }, children: [
|
|
1413
1479
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1414
1480
|
"input",
|
|
1415
1481
|
{
|
|
@@ -1418,14 +1484,20 @@ function FormFieldInput({
|
|
|
1418
1484
|
value: opt.value,
|
|
1419
1485
|
checked: value === opt.value,
|
|
1420
1486
|
onChange: () => onValueChange(field.name, opt.value),
|
|
1421
|
-
style: { accentColor: styling.primaryColor }
|
|
1487
|
+
style: { accentColor: styling.primaryColor, backgroundColor: "transparent" }
|
|
1422
1488
|
}
|
|
1423
1489
|
),
|
|
1424
1490
|
opt.label
|
|
1425
1491
|
] }, opt.value)) });
|
|
1426
1492
|
} else if (field.type === "multiselect") {
|
|
1427
1493
|
const selected = Array.isArray(value) ? value : [];
|
|
1428
|
-
fieldEl = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
|
|
1494
|
+
fieldEl = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
|
|
1495
|
+
...inputStyle,
|
|
1496
|
+
display: "flex",
|
|
1497
|
+
flexDirection: "column",
|
|
1498
|
+
gap: "0.5rem",
|
|
1499
|
+
width: "100%"
|
|
1500
|
+
}, children: getOpts().map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", cursor: "pointer" }, children: [
|
|
1429
1501
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1430
1502
|
"input",
|
|
1431
1503
|
{
|
|
@@ -1435,7 +1507,7 @@ function FormFieldInput({
|
|
|
1435
1507
|
const next = selected.includes(opt.value) ? selected.filter((v) => v !== opt.value) : [...selected, opt.value];
|
|
1436
1508
|
onValueChange(field.name, next);
|
|
1437
1509
|
},
|
|
1438
|
-
style: { accentColor: styling.primaryColor }
|
|
1510
|
+
style: { accentColor: styling.primaryColor, backgroundColor: "transparent" }
|
|
1439
1511
|
}
|
|
1440
1512
|
),
|
|
1441
1513
|
opt.label
|