Skip to content

Commit 59ba101

Browse files
committed
fix: Added visibility option
1 parent db6567f commit 59ba101

13 files changed

Lines changed: 83 additions & 51 deletions

File tree

src/components/form-builder/canvas/sortable-row.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ export const RowColumn = ({
8282
[component]
8383
);
8484

85+
const visibilityClasses = useMemo(
86+
() => generateTWClassesForAllViewports(component, "visible"),
87+
[component]
88+
);
89+
90+
const isHidden = component.getField("properties.style.visible", viewport) === "no";
91+
8592
const handleClick = useCallback(
8693
(e: React.MouseEvent) => {
8794
if (mode === "editor" && !columnIsDragging) {
@@ -123,12 +130,14 @@ export const RowColumn = ({
123130
<div
124131
ref={setNodeRef}
125132
className={cn(
126-
"relative group ",
133+
"relative group",
127134
colSpanClasses,
128135
colStartClasses,
136+
mode === "preview" && visibilityClasses,
129137
mode === "editor" && "group/component hover:outline-1 hover:outline-offset-6 hover:outline-primary cursor-pointer",
130138
columnIsDragging && "cursor-grabbing",
131139
selectedComponent && "opacity-30",
140+
isHidden && "opacity-50",
132141
selectedComponent?.id === component.id &&
133142
"outline-1 outline-offset-6 outline-primary z-20 opacity-100",
134143
)}

src/components/form-builder/form-components/form-checkbox-group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const CheckboxGroupDesignProperties: DesignPropertiesViews = {
6969
base: null,
7070
grid: <GridGroup />,
7171
html: <HtmlGroup />,
72-
label: <LabelGroup whitelist={["label", "label_description"]} />,
72+
label: <LabelGroup whitelist={["label"]} />,
7373
input: <InputGroup whitelist={["description", "asCard"]} />,
7474
options: <OptionsGroup />,
7575
button: null,

src/components/form-builder/form-components/form-datepicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const DatePickerDesignProperties: DesignPropertiesViews = {
9696
base: null,
9797
grid: <GridGroup />,
9898
html: <HtmlGroup />,
99-
label: <LabelGroup />,
99+
label: <LabelGroup whitelist={["label", "labelPosition", "labelAlign", "showLabel"]} />,
100100
input: <InputGroup whitelist={["placeholder", "description"]} />,
101101
options: null,
102102
button: null,

src/components/form-builder/form-components/form-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const InputDesignProperties: DesignPropertiesViews = {
5151
base: null,
5252
grid: <GridGroup />,
5353
html: <HtmlGroup />,
54-
label: <LabelGroup />,
54+
label: <LabelGroup whitelist={["label", "labelPosition", "labelAlign", "showLabel"]} />,
5555
input: <InputGroup />,
5656
options: null,
5757
button: null,

src/components/form-builder/form-components/form-radio.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const RadioDesignProperties: DesignPropertiesViews = {
6969
base: null,
7070
grid: <GridGroup />,
7171
html: <HtmlGroup />,
72-
label: <LabelGroup />,
72+
label: <LabelGroup whitelist={["label", "labelPosition", "labelAlign", "showLabel"]} />,
7373
input: <InputGroup whitelist={["placeholder", "description", "value"]} />,
7474
options: <OptionsGroup />,
7575
button: null,

src/components/form-builder/form-components/form-select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const SelectDesignProperties: DesignPropertiesViews = {
7474
base: null,
7575
grid: <GridGroup />,
7676
html: <HtmlGroup />,
77-
label: <LabelGroup />,
77+
label: <LabelGroup whitelist={["label", "labelPosition", "labelAlign", "showLabel"]} />,
7878
input: <InputGroup whitelist={["placeholder", "description", "value"]} />,
7979
options: <OptionsGroup />,
8080
button: null,

src/components/form-builder/form-components/form-text.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export function Text(component: FormComponentModel) {
1919
key={component.id}
2020
className={cn(
2121
colSpanClasses,
22-
colStartClasses,
23-
component.getTWClasses("textAlign")
24-
)}
22+
colStartClasses )}
2523
dangerouslySetInnerHTML={{ __html: component.content || "" }}
2624
/>
2725
);
@@ -37,7 +35,8 @@ export function getReactCode(component: FormComponentModel): ReactCode {
3735
code: `
3836
<div
3937
key="${component.id}"
40-
className="${escapeHtml(component.getTWClasses("textAlign"))}">
38+
id="${component.getField("attributes.id")}"
39+
className="${component.getField("attributes.class")}">
4140
${component.content || ""}
4241
</div>
4342
`,
@@ -50,7 +49,7 @@ export function getReactCode(component: FormComponentModel): ReactCode {
5049
export const TextDesignProperties: DesignPropertiesViews = {
5150
base: null,
5251
grid: <GridGroup />,
53-
html: <HtmlGroup />,
52+
html: <HtmlGroup whitelist={["id", "class"]} />,
5453
label: null,
5554
input: null,
5655
options: null,

src/components/form-builder/form-components/form-textarea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const TextareaDesignProperties: DesignPropertiesViews = {
5050
base: null,
5151
grid: <GridGroup />,
5252
html: <HtmlGroup />,
53-
label: <LabelGroup />,
53+
label: <LabelGroup whitelist={["label", "labelPosition", "labelAlign", "showLabel"]} />,
5454
input: <InputGroup />,
5555
options: null,
5656
button: null,

src/components/form-builder/helpers/render-editor-component.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export function RenderEditorComponent({ form, component }: FormComponentProps) {
4444
>
4545
{component.getField("properties.style.showLabel", viewport) ===
4646
"yes" && component.getField("label", viewport)}
47+
{component.getField("properties.style.visible", viewport) ===
48+
"no" && <span className="text-xs text-muted-foreground">Hidden</span>}
4749
</FormLabel>
4850
</div>
4951
<FormControl>{componentViews?.render}</FormControl>

src/components/form-builder/sidebar/groups/grid-group.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function GridGroup() {
4949

5050
return (
5151
<>
52-
{/* <div className="grid grid-cols-2 gap-2 items-center">
52+
<div className="grid grid-cols-2 gap-2 items-center">
5353
<Label className="text-xs text-gray-400 flex-1 inline-block">
5454
Visible
5555
</Label>
@@ -70,7 +70,7 @@ export function GridGroup() {
7070
field="properties.style.visible"
7171
/>
7272
</div>
73-
</div> */}
73+
</div>
7474
<div className="grid grid-cols-2 gap-2 items-center">
7575
<Label className="text-xs text-gray-400 flex-1 inline-block">
7676
Column Span

0 commit comments

Comments
 (0)