form-builder-pro 1.0.1 → 1.0.2
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/index.css +155 -20
- package/dist/index.js +30 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4499,7 +4499,7 @@ var FieldRenderer = class {
|
|
|
4499
4499
|
const wrapper = createElement("div", { className: "w-full" });
|
|
4500
4500
|
if (field.type !== "checkbox") {
|
|
4501
4501
|
const label = createElement("label", {
|
|
4502
|
-
className: "text-sm font-medium leading-none mb-2 block text-gray-900 dark:text-gray-100",
|
|
4502
|
+
className: "text-xs sm:text-sm font-medium leading-none mb-2 block text-gray-900 dark:text-gray-100",
|
|
4503
4503
|
text: field.label
|
|
4504
4504
|
});
|
|
4505
4505
|
if (field.required) {
|
|
@@ -4508,7 +4508,7 @@ var FieldRenderer = class {
|
|
|
4508
4508
|
wrapper.appendChild(label);
|
|
4509
4509
|
} else {
|
|
4510
4510
|
const label = createElement("label", {
|
|
4511
|
-
className: "text-sm font-medium leading-none mb-2 block text-gray-900 dark:text-gray-100",
|
|
4511
|
+
className: "text-xs sm:text-sm font-medium leading-none mb-2 block text-gray-900 dark:text-gray-100",
|
|
4512
4512
|
text: field.label
|
|
4513
4513
|
});
|
|
4514
4514
|
if (field.required) {
|
|
@@ -4520,7 +4520,7 @@ var FieldRenderer = class {
|
|
|
4520
4520
|
switch (field.type) {
|
|
4521
4521
|
case "textarea":
|
|
4522
4522
|
input = createElement("textarea", {
|
|
4523
|
-
className: "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4523
|
+
className: "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm sm:text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4524
4524
|
placeholder: field.placeholder,
|
|
4525
4525
|
value: value || "",
|
|
4526
4526
|
disabled: readOnly,
|
|
@@ -4529,7 +4529,7 @@ var FieldRenderer = class {
|
|
|
4529
4529
|
break;
|
|
4530
4530
|
case "select":
|
|
4531
4531
|
input = createElement("select", {
|
|
4532
|
-
className: "flex h-
|
|
4532
|
+
className: "flex min-h-touch w-full rounded-md border border-input bg-background px-3 py-2 text-sm sm:text-base ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4533
4533
|
value: value || "",
|
|
4534
4534
|
disabled: readOnly,
|
|
4535
4535
|
onchange: (e) => onChange?.(e.target.value)
|
|
@@ -4540,10 +4540,10 @@ var FieldRenderer = class {
|
|
|
4540
4540
|
});
|
|
4541
4541
|
break;
|
|
4542
4542
|
case "checkbox":
|
|
4543
|
-
input = createElement("div", { className: "flex items-center h-
|
|
4543
|
+
input = createElement("div", { className: "flex items-center min-h-touch" });
|
|
4544
4544
|
const checkbox = createElement("input", {
|
|
4545
4545
|
type: "checkbox",
|
|
4546
|
-
className: "h-5 w-5 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer",
|
|
4546
|
+
className: "h-5 w-5 sm:h-6 sm:w-6 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer",
|
|
4547
4547
|
checked: !!value,
|
|
4548
4548
|
disabled: readOnly,
|
|
4549
4549
|
onchange: (e) => onChange?.(e.target.checked)
|
|
@@ -4553,18 +4553,18 @@ var FieldRenderer = class {
|
|
|
4553
4553
|
case "radio":
|
|
4554
4554
|
input = createElement("div", { className: "space-y-2" });
|
|
4555
4555
|
field.options?.forEach((opt) => {
|
|
4556
|
-
const radioWrapper = createElement("div", { className: "flex items-center space-x-2" });
|
|
4556
|
+
const radioWrapper = createElement("div", { className: "flex items-center space-x-2 min-h-touch" });
|
|
4557
4557
|
const radio = createElement("input", {
|
|
4558
4558
|
type: "radio",
|
|
4559
4559
|
name: field.id,
|
|
4560
4560
|
value: opt.value,
|
|
4561
4561
|
checked: value === opt.value,
|
|
4562
4562
|
disabled: readOnly,
|
|
4563
|
-
className: "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4563
|
+
className: "aspect-square h-4 w-4 sm:h-5 sm:w-5 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4564
4564
|
onchange: (e) => onChange?.(e.target.value)
|
|
4565
4565
|
});
|
|
4566
4566
|
const radioLabel = createElement("label", {
|
|
4567
|
-
className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
4567
|
+
className: "text-xs sm:text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
4568
4568
|
text: opt.label
|
|
4569
4569
|
});
|
|
4570
4570
|
radioWrapper.appendChild(radio);
|
|
@@ -4575,7 +4575,7 @@ var FieldRenderer = class {
|
|
|
4575
4575
|
default:
|
|
4576
4576
|
input = createElement("input", {
|
|
4577
4577
|
type: field.type === "phone" ? "tel" : field.type,
|
|
4578
|
-
className: "flex h-
|
|
4578
|
+
className: "flex min-h-touch w-full rounded-md border border-input bg-background px-3 py-2 text-sm sm:text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4579
4579
|
placeholder: field.placeholder,
|
|
4580
4580
|
value: value || "",
|
|
4581
4581
|
disabled: readOnly,
|
|
@@ -4584,7 +4584,7 @@ var FieldRenderer = class {
|
|
|
4584
4584
|
}
|
|
4585
4585
|
wrapper.appendChild(input);
|
|
4586
4586
|
if (field.description) {
|
|
4587
|
-
wrapper.appendChild(createElement("p", { className: "text-sm text-muted-foreground mt-1", text: field.description }));
|
|
4587
|
+
wrapper.appendChild(createElement("p", { className: "text-xs sm:text-sm text-muted-foreground mt-1", text: field.description }));
|
|
4588
4588
|
}
|
|
4589
4589
|
return wrapper;
|
|
4590
4590
|
}
|
|
@@ -4608,11 +4608,11 @@ var FormRenderer = class {
|
|
|
4608
4608
|
}
|
|
4609
4609
|
render() {
|
|
4610
4610
|
this.container.innerHTML = "";
|
|
4611
|
-
const form = createElement("form", { className: "space-y-8" });
|
|
4612
|
-
form.appendChild(createElement("h1", { className: "text-2xl font-bold text-gray-900 dark:text-white", text: this.schema.title }));
|
|
4611
|
+
const form = createElement("form", { className: "space-y-6 md:space-y-8" });
|
|
4612
|
+
form.appendChild(createElement("h1", { className: "text-xl md:text-2xl font-bold text-gray-900 dark:text-white", text: this.schema.title }));
|
|
4613
4613
|
this.schema.sections.forEach((section) => {
|
|
4614
|
-
const sectionEl = createElement("div", { className: "space-y-4" });
|
|
4615
|
-
sectionEl.appendChild(createElement("h2", { className: "text-xl font-semibold text-gray-800 dark:text-gray-200 border-b pb-2", text: section.title }));
|
|
4614
|
+
const sectionEl = createElement("div", { className: "space-y-3 md:space-y-4" });
|
|
4615
|
+
sectionEl.appendChild(createElement("h2", { className: "text-lg md:text-xl font-semibold text-gray-800 dark:text-gray-200 border-b pb-2", text: section.title }));
|
|
4616
4616
|
const grid = createElement("div", { className: "form-builder-grid" });
|
|
4617
4617
|
section.fields.forEach((field) => {
|
|
4618
4618
|
const fieldWrapper = createElement("div");
|
|
@@ -4639,14 +4639,14 @@ var FormRenderer = class {
|
|
|
4639
4639
|
});
|
|
4640
4640
|
const submitBtn = createElement("button", {
|
|
4641
4641
|
type: "submit",
|
|
4642
|
-
className: "px-6 py-
|
|
4642
|
+
className: "w-full sm:w-auto px-6 py-3 min-h-touch bg-blue-600 text-white font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",
|
|
4643
4643
|
text: "Submit"
|
|
4644
4644
|
});
|
|
4645
4645
|
form.onsubmit = (e) => {
|
|
4646
4646
|
e.preventDefault();
|
|
4647
4647
|
this.onSubmit?.(this.data);
|
|
4648
4648
|
};
|
|
4649
|
-
const btnWrapper = createElement("div", { className: "pt-4" });
|
|
4649
|
+
const btnWrapper = createElement("div", { className: "pt-4 flex justify-center sm:justify-start" });
|
|
4650
4650
|
btnWrapper.appendChild(submitBtn);
|
|
4651
4651
|
form.appendChild(btnWrapper);
|
|
4652
4652
|
this.container.appendChild(form);
|
|
@@ -7005,7 +7005,7 @@ var FormBuilder = class {
|
|
|
7005
7005
|
this.container.innerHTML = "";
|
|
7006
7006
|
const wrapper = createElement("div", { className: "flex flex-col h-screen " });
|
|
7007
7007
|
wrapper.appendChild(this.renderToolbar(state));
|
|
7008
|
-
const main = createElement("div", { className: "flex flex-1 overflow-hidden" });
|
|
7008
|
+
const main = createElement("div", { className: "flex flex-col md:flex-row flex-1 overflow-hidden" });
|
|
7009
7009
|
if (state.isPreviewMode) {
|
|
7010
7010
|
const previewContainer = createElement("div", { className: "flex-1 p-8 overflow-y-auto bg-white dark:bg-gray-900 flex justify-center" });
|
|
7011
7011
|
const inner = createElement("div", { className: "w-full max-w-3xl" });
|
|
@@ -7013,9 +7013,15 @@ var FormBuilder = class {
|
|
|
7013
7013
|
previewContainer.appendChild(inner);
|
|
7014
7014
|
main.appendChild(previewContainer);
|
|
7015
7015
|
} else {
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
main.appendChild(
|
|
7016
|
+
const toolboxWrapper = createElement("div", { className: "form-builder-toolbox-wrapper w-full md:w-80 bg-white dark:bg-gray-900 border-r md:border-r border-b md:border-b-0 border-gray-200 dark:border-gray-800" });
|
|
7017
|
+
toolboxWrapper.appendChild(this.renderToolbox());
|
|
7018
|
+
main.appendChild(toolboxWrapper);
|
|
7019
|
+
const canvasWrapper = createElement("div", { className: "form-builder-canvas flex-1 overflow-y-auto" });
|
|
7020
|
+
canvasWrapper.appendChild(this.renderCanvas(state));
|
|
7021
|
+
main.appendChild(canvasWrapper);
|
|
7022
|
+
const configWrapper = createElement("div", { className: "form-builder-config-wrapper w-full md:w-80 bg-white dark:bg-gray-900 border-l md:border-l border-t md:border-t-0 border-gray-200 dark:border-gray-800" });
|
|
7023
|
+
configWrapper.appendChild(this.renderConfigPanel(state));
|
|
7024
|
+
main.appendChild(configWrapper);
|
|
7019
7025
|
}
|
|
7020
7026
|
wrapper.appendChild(main);
|
|
7021
7027
|
this.container.appendChild(wrapper);
|
|
@@ -7113,7 +7119,7 @@ var FormBuilder = class {
|
|
|
7113
7119
|
return toolbar;
|
|
7114
7120
|
}
|
|
7115
7121
|
renderToolbox() {
|
|
7116
|
-
const toolbox = createElement("div", { className: "
|
|
7122
|
+
const toolbox = createElement("div", { className: "bg-white dark:bg-gray-900 flex flex-col h-full" });
|
|
7117
7123
|
const tabs = createElement("div", { className: "flex border-b border-gray-200 dark:border-gray-800" });
|
|
7118
7124
|
const createTab = (id, label) => {
|
|
7119
7125
|
const isActive = this.activeTab === id;
|
|
@@ -7212,7 +7218,7 @@ var FormBuilder = class {
|
|
|
7212
7218
|
}
|
|
7213
7219
|
renderCanvas(state) {
|
|
7214
7220
|
const canvas = createElement("div", {
|
|
7215
|
-
className: "flex-1 bg-white dark:bg-gray-950 p-8 overflow-y-auto
|
|
7221
|
+
className: "flex-1 bg-white dark:bg-gray-950 p-4 md:p-8 overflow-y-auto",
|
|
7216
7222
|
onclick: (e) => {
|
|
7217
7223
|
if (e.target === canvas || e.target === canvas.firstElementChild) {
|
|
7218
7224
|
formStore.getState().selectField(null);
|
|
@@ -7329,7 +7335,7 @@ var FormBuilder = class {
|
|
|
7329
7335
|
return canvas;
|
|
7330
7336
|
}
|
|
7331
7337
|
renderConfigPanel(state) {
|
|
7332
|
-
const panel = createElement("div", { className: "
|
|
7338
|
+
const panel = createElement("div", { className: "bg-white dark:bg-gray-900 flex flex-col h-full" });
|
|
7333
7339
|
const selectedField = state.schema.sections.flatMap((s) => s.fields).find((f) => f.id === state.selectedFieldId);
|
|
7334
7340
|
if (!selectedField) {
|
|
7335
7341
|
panel.appendChild(createElement("div", { className: "p-6 text-center text-gray-500", text: "Select a field to configure" }));
|