diff --git a/src/package/website-blocks/box.tsx b/src/package/website-blocks/box.tsx deleted file mode 100644 index 7cba69b..0000000 --- a/src/package/website-blocks/box.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import * as React from "react"; -import { Image, SelectOption, Styles } from "../controls"; -import { registerChaiBlock } from "../runtime/builder-blocks"; -import { isEmpty } from "lodash-es"; -import EmptySlot from "./empty-slot"; - -const BoxBlock = React.memo( - ( - props: any & { - children: React.ReactNode; - styles: any; - tag: string; - backgroundImage: string; - blockProps: Record; - }, - ) => { - const { blockProps, backgroundImage, children, tag = "div", styles } = props; - - if (!children && isEmpty(styles?.className)) { - return ; - } - let cssStyles = {}; - if (backgroundImage) { - cssStyles = { backgroundImage: `url(${backgroundImage})` }; - } - - return React.createElement(tag, { ...blockProps, ...styles, style: cssStyles }, children); - }, -); - -registerChaiBlock(BoxBlock, { - type: "Box", - label: "Box", - category: "core", - group: "basic", - props: { - styles: Styles({ default: "" }), - tag: SelectOption({ - title: "Tag", - default: "div", - options: [ - { value: "div", title: "div" }, - { value: "header", title: "header" }, - { value: "footer", title: "footer" }, - { value: "section", title: "section" }, - { value: "article", title: "article" }, - { value: "aside", title: "aside" }, - { value: "main", title: "main" }, - { value: "nav", title: "nav" }, - { value: "figure", title: "figure" }, - { value: "details", title: "details" }, - { value: "summary", title: "summary" }, - { value: "dialog", title: "dialog" }, - { value: "strike", title: "strike" }, - { value: "caption", title: "caption" }, - { value: "legend", title: "legend" }, - { value: "figcaption", title: "figcaption" }, - { value: "mark", title: "mark" }, - ], - }), - backgroundImage: Image({ title: "Background Image" }), - }, -}); - -export default BoxBlock; diff --git a/src/package/website-blocks/button.tsx b/src/package/website-blocks/button.tsx deleted file mode 100644 index ccc7934..0000000 --- a/src/package/website-blocks/button.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import * as React from "react"; -import { ButtonIcon } from "@radix-ui/react-icons"; -import { Icon, Link, SelectOption, Numeric, SingleLineText, Styles } from "../controls"; -import { registerChaiBlock } from "../runtime/builder-blocks"; -import { ChaiBlock } from "../helper/types/ChaiBlock.ts"; - -const ButtonBlock = ( - block: ChaiBlock & { - blockProps: Record; - styles: Record; - }, -) => { - const { blockProps, iconSize, icon, content, iconPos, styles, children } = block; - const _icon = icon; - const child = children || ( - <> - {content} - {_icon && ( -
- )} - - ); - return React.createElement("button", { ...blockProps, ...styles, type: "button" }, child); -}; - -registerChaiBlock(ButtonBlock, { - type: "Button", - label: "Button", - category: "core", - icon: ButtonIcon, - group: "basic", - props: { - content: SingleLineText({ title: "Label", default: "Button", multiLingual: true }), - styles: Styles({ default: "text-white bg-primary px-4 py-2 rounded-global flex items-center" }), - link: Link({ title: "Link", default: { type: "page", href: "", target: "_blank" } }), - icon: Icon({ title: "Icon", default: "" }), - iconSize: Numeric({ title: "Icon Size", default: 24 }), - iconPos: SelectOption({ - title: "Icon Position", - default: "order-last", - options: [ - { title: "Start", value: "order-first" }, - { title: "End", value: "order-last" }, - ], - }), - }, -}); - -export default ButtonBlock; diff --git a/src/package/website-blocks/chaibuilder-link.tsx b/src/package/website-blocks/chaibuilder-link.tsx deleted file mode 100644 index ea91e37..0000000 --- a/src/package/website-blocks/chaibuilder-link.tsx +++ /dev/null @@ -1,28 +0,0 @@ -type LinkProps = { - inBuilder?: boolean; - style?: Record; - href: string; - children: any; -}; -const ChaiBuilderLink = ({ - inBuilder = false, - style = {}, - href, - children, -}: LinkProps) => { - if (inBuilder) { - return ( - - {children} - - ); - } - - return ( - - {children} - - ); -}; - -export default ChaiBuilderLink; diff --git a/src/package/website-blocks/custom-html.tsx b/src/package/website-blocks/custom-html.tsx deleted file mode 100644 index 165ba23..0000000 --- a/src/package/website-blocks/custom-html.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import * as React from "react"; -import { CodeIcon } from "@radix-ui/react-icons"; -import { MultilineText, Styles } from "../controls"; -import { registerChaiBlock } from "../runtime/builder-blocks"; -import { ChaiBlock } from "../helper/types/ChaiBlock.ts"; - -const CustomHTMLBlock = React.memo( - ( - props: ChaiBlock & { - blockProps: Record; - styles: Record; - }, - ) => { - const { blockProps, styles, content } = props; - return React.createElement("div", { - ...styles, - ...blockProps, - dangerouslySetInnerHTML: { __html: content }, - }); - }, -); - -registerChaiBlock(CustomHTMLBlock as React.FC, { - type: "CustomHTML", - label: "CustomHTML", - category: "core", - icon: CodeIcon, - group: "basic", - props: { - styles: Styles({ default: "" }), - content: MultilineText({ - title: "HTML Content", - default: "", - placeholder: "Enter custom HTML code here", - }), - }, -}); - -export default CustomHTMLBlock; diff --git a/src/package/website-blocks/divider.tsx b/src/package/website-blocks/divider.tsx deleted file mode 100644 index 1893ec5..0000000 --- a/src/package/website-blocks/divider.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import * as React from "react"; -import { DividerHorizontalIcon } from "@radix-ui/react-icons"; -import { Styles } from "../controls"; -import { registerChaiBlock } from "../runtime/builder-blocks"; -import { ChaiBlock } from "../helper/types/ChaiBlock.ts"; - -/** - * Divider component - * @param props - * @constructor - */ -const DividerBlock = ( - props: ChaiBlock & { - blockProps: Record; - styles: Record; - }, -) => { - const { blockProps, styles } = props; - return React.createElement("hr", { ...styles, ...blockProps }); -}; - -registerChaiBlock(DividerBlock, { - type: "Divider", - label: "Divider", - category: "core", - icon: DividerHorizontalIcon, - group: "basic", - props: { - styles: Styles({ default: "bg-gray-900 h-0.5 py-2 my-1" }), - }, -}); - -export default DividerBlock; diff --git a/src/package/website-blocks/empty-slot.tsx b/src/package/website-blocks/empty-slot.tsx deleted file mode 100644 index 041b45b..0000000 --- a/src/package/website-blocks/empty-slot.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { omit } from "lodash-es"; -import { cn } from "../helper/lib"; - -type EmptySlotProps = { - blockProps?: any; - className?: any; - text?: string; - styles?: any; -}; -const EmptySlot = ({ blockProps, className = "", styles = {} }: EmptySlotProps) => { - return ( -
-
- -
-
- ); -}; - -export default EmptySlot; diff --git a/src/package/website-blocks/form/checkbox.tsx b/src/package/website-blocks/form/checkbox.tsx deleted file mode 100644 index d6a00cf..0000000 --- a/src/package/website-blocks/form/checkbox.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { CheckboxIcon } from "@radix-ui/react-icons"; -import { Checkbox, SingleLineText, Styles } from "../../controls"; -import { ChaiBlock } from "../../helper/types/ChaiBlock.ts"; -import { generateUUID } from "../../helper/lib.ts"; -import { registerChaiBlock } from "../../runtime"; - -const CheckboxBlock = ( - block: ChaiBlock & { - blockProps: Record; - styles: Record; - inputStyles: Record; - required: boolean; - checked: boolean; - }, -) => { - const { blockProps, fieldName, label, styles, inputStyles, required, checked, showLabel = true } = block; - const fieldId = generateUUID(); - - if (!showLabel) - return ( - - ); - - return ( -
- - {label && label !== "Label" && } -
- ); -}; - -registerChaiBlock(CheckboxBlock, { - type: "Checkbox", - label: "Checkbox", - category: "core", - icon: CheckboxIcon, - group: "form", - hidden: true, - props: { - fieldName: SingleLineText({ title: "Field Name", default: "checkbox" }), - styles: Styles({ default: "flex items-center gap-x-2" }), - label: SingleLineText({ title: "Label", default: "Label" }), - checked: Checkbox({ title: "Checked", default: false }), - required: Checkbox({ title: "Required", default: false }), - }, -}); - -export default CheckboxBlock; diff --git a/src/package/website-blocks/form/form-button.tsx b/src/package/website-blocks/form/form-button.tsx deleted file mode 100644 index 74e27e9..0000000 --- a/src/package/website-blocks/form/form-button.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { ButtonIcon } from "@radix-ui/react-icons"; -import { Icon, SelectOption, SingleLineText, Styles } from "../../controls"; -import { registerChaiBlock } from "../../runtime"; -import { ChaiBlock } from "../../helper/types/ChaiBlock.ts"; -import { generateUUID } from "../../helper/lib.ts"; -const FormButtonBlock = ( - block: ChaiBlock & { - blockProps: Record; - styles: Record; - inputStyles: Record; - }, -) => { - const { blockProps, inBuilder, label, placeholder, styles, inputStyles, icon, iconPos } = block; - const fieldId = generateUUID(); - - // alpine js attrs - const attrs = { - "x-bind:disabled": "formLoading", - }; - - return ( - - ); -}; - -registerChaiBlock(FormButtonBlock, { - type: "FormButton", - label: "Submit Button", - category: "core", - icon: ButtonIcon, - group: "form", - hidden: true, - props: { - label: SingleLineText({ title: "Label", default: "Submit" }), - styles: Styles({ - default: "text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2", - }), - icon: Icon({ title: "Icon", default: "" }), - iconPos: SelectOption({ - title: "Icon Position", - default: "order-last", - options: [ - { title: "Start", value: "order-first" }, - { title: "End", value: "order-last" }, - ], - }), - }, -}); - -export default FormButtonBlock; diff --git a/src/package/website-blocks/form/form.tsx b/src/package/website-blocks/form/form.tsx deleted file mode 100644 index 96b0453..0000000 --- a/src/package/website-blocks/form/form.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import * as React from "react"; -import { isEmpty } from "lodash-es"; -import { GroupIcon, LetterCaseToggleIcon } from "@radix-ui/react-icons"; -import { RichText, SingleLineText, Styles } from "../../controls"; -import { registerChaiBlock } from "../../runtime"; -import EmptySlot from "../empty-slot.tsx"; -import { ChaiBlock } from "../../helper/types/ChaiBlock.ts"; - -const FormBlock = ( - props: ChaiBlock & { - children: React.ReactNode; - styles: any; - tag: string; - inBuilder: boolean; - blockProps: Record; - }, -) => { - const { blockProps, errorMessage, name, _type, successMessage, action, styles, children } = props; - - if (!children && isEmpty(styles?.className)) { - return ; - } - - const alpineAttrs = { - "x-data": "useForm", - "x-on:submit.prevent": "post", - }; - const formResponseAttr = { - "x-html": "formResponse", - ":class": "{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}", - }; - return ( -
-
- - {children} -
- ); -}; - -export default FormBlock; - -registerChaiBlock(FormBlock, { - type: "Form", - label: "Form", - category: "core", - icon: GroupIcon, - group: "form", - hidden: true, - props: { - styles: Styles({ default: "" }), - action: SingleLineText({ - title: "Submit URL", - default: "/api/form/submit", - }), - errorMessage: RichText({ - title: "Error Message", - default: "Something went wrong. Please try again", - }), - successMessage: RichText({ - title: "Success Message", - default: "Thank you for your submission.", - }), - }, -}); - -const LabelBlock = ( - props: ChaiBlock & { - children: React.ReactNode; - styles: any; - content: string; - blockProps: Record; - }, -) => { - const { blockProps, content, styles, children } = props; - const labelProps = { ...styles, ...blockProps }; - - if (children) return React.createElement("label", labelProps, children); - return React.createElement("label", { - ...labelProps, - dangerouslySetInnerHTML: { __html: content }, - }); -}; - -registerChaiBlock(LabelBlock, { - type: "Label", - label: "Label", - category: "core", - icon: LetterCaseToggleIcon, - group: "form", - hidden: true, - props: { - styles: Styles({ default: "" }), - content: SingleLineText({ title: "Content", default: "Label" }), - }, -}); diff --git a/src/package/website-blocks/form/input.tsx b/src/package/website-blocks/form/input.tsx deleted file mode 100644 index 9f8d7f2..0000000 --- a/src/package/website-blocks/form/input.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import * as React from "react"; -import { InputIcon } from "@radix-ui/react-icons"; -import { map } from "lodash-es"; -import { Checkbox, SelectOption, SingleLineText, Styles } from "../../controls"; -import { registerChaiBlock } from "../../runtime"; -import { ChaiBlock } from "../../helper/types/ChaiBlock.ts"; -import { generateUUID } from "../../helper/lib.ts"; - -const InputBlock = ( - block: ChaiBlock & { - inBuilder: boolean; - blockProps: Record; - styles: Record; - inputStyles: Record; - required: boolean; - value: string; - name: string; - }, -) => { - const { - blockProps, - label, - placeholder, - styles, - inputStyles, - showLabel, - required, - inputType = "text", - inBuilder, - fieldName, - } = block; - const fieldId = generateUUID(); - - if (!showLabel || inputType === "submit") { - if (inputType === "submit") blockProps.value = label; - - return ( - - ); - } - return ( -
- {showLabel && } - -
- ); -}; - -registerChaiBlock(InputBlock as React.FC, { - type: "Input", - label: "Input", - category: "core", - icon: InputIcon, - group: "form", - hidden: true, - props: { - styles: Styles({ default: "" }), - fieldName: SingleLineText({ title: "Field Name", default: "input" }), - inputType: SelectOption({ - title: "Type", - options: map( - ["text", "email", "password", "number", "tel", "file", "hidden", "range", "submit", "color", "date", "time"], - (type) => ({ - value: type, - title: type, - }), - ), - default: "text", - }), - value: SingleLineText({ title: "Value", default: "" }), - showLabel: Checkbox({ title: "Show label", default: true }), - inputStyles: Styles({ default: "w-full p-1" }), - label: SingleLineText({ title: "Label", default: "Label" }), - placeholder: SingleLineText({ - title: "Placeholder", - default: "Placeholder", - }), - required: Checkbox({ title: "Required", default: false }), - }, -}); - -export default InputBlock; diff --git a/src/package/website-blocks/form/radio.tsx b/src/package/website-blocks/form/radio.tsx deleted file mode 100644 index 4806aa4..0000000 --- a/src/package/website-blocks/form/radio.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { RadiobuttonIcon } from "@radix-ui/react-icons"; -import { Checkbox, SingleLineText, Styles } from "../../controls"; -import { registerChaiBlock } from "../../runtime"; -import { generateUUID } from "../../helper/lib.ts"; -import { ChaiBlock } from "../../helper/types/ChaiBlock.ts"; - -const RadioBlock = ( - block: ChaiBlock & { - blockProps: Record; - styles: Record; - inputStyles: Record; - required: boolean; - checked: boolean; - }, -) => { - const { blockProps, fieldName, label, styles, inputStyles, checked, required, showLabel = true } = block; - const fieldId = generateUUID(); - - if (!showLabel) - return ( - - ); - return ( -
- - {label && } -
- ); -}; - -registerChaiBlock(RadioBlock, { - type: "Radio", - label: "Radio", - category: "core", - icon: RadiobuttonIcon, - group: "form", - hidden: true, - props: { - styles: Styles({ default: "flex items-center w-max gap-x-2" }), - fieldName: SingleLineText({ title: "Field Name", default: "radio" }), - label: SingleLineText({ title: "Label", default: "Label" }), - checked: Checkbox({ title: "Checked", default: false }), - required: Checkbox({ title: "Required", default: false }), - }, -}); - -export default RadioBlock; diff --git a/src/package/website-blocks/form/select.tsx b/src/package/website-blocks/form/select.tsx deleted file mode 100644 index 269fabf..0000000 --- a/src/package/website-blocks/form/select.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import { DropdownMenuIcon } from "@radix-ui/react-icons"; -import { get, map } from "lodash-es"; -import { Checkbox, List, SingleLineText, Styles } from "../../controls"; -import { registerChaiBlock } from "../../runtime"; -import { ChaiBlock } from "../../helper/types/ChaiBlock.ts"; -import { generateUUID } from "../../helper/lib.ts"; - -const SelectBlock = ( - block: ChaiBlock & { - blockProps: Record; - styles: Record; - inputStyles: Record; - required: boolean; - options: { label: string; value: string }[]; - }, -) => { - const { - blockProps, - fieldName, - label, - placeholder, - styles, - inputStyles, - required, - showLabel, - _multiple = false, - } = block; - const fieldId = generateUUID(); - - if (!showLabel) { - return ( - - ); - } - - return ( -
- {showLabel && } - -
- ); -}; - -registerChaiBlock(SelectBlock, { - type: "Select", - label: "Select", - category: "core", - icon: DropdownMenuIcon, - group: "form", - hidden: true, - props: { - styles: Styles({ default: "" }), - fieldName: SingleLineText({ title: "Field Name", default: "select" }), - showLabel: Checkbox({ title: "Show label", default: true }), - inputStyles: Styles({ default: "w-full p-1" }), - label: SingleLineText({ title: "Label", default: "Label" }), - placeholder: SingleLineText({ - title: "Placeholder", - default: "Placeholder", - }), - required: Checkbox({ title: "Required", default: false }), - _multiple: Checkbox({ title: "Multiple Choice", default: false }), - options: List({ - title: "Options", - itemProperties: { - label: SingleLineText({ title: "Label", default: "" }), - value: SingleLineText({ title: "Value", default: "" }), - }, - }), - }, -}); - -export default SelectBlock; diff --git a/src/package/website-blocks/form/textarea.tsx b/src/package/website-blocks/form/textarea.tsx deleted file mode 100644 index efa8da4..0000000 --- a/src/package/website-blocks/form/textarea.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { InputIcon } from "@radix-ui/react-icons"; -import { Checkbox, Numeric, SingleLineText, Styles } from "../../controls"; -import { registerChaiBlock } from "../../runtime"; -import { ChaiBlock } from "../../helper/types/ChaiBlock.ts"; -import { generateUUID } from "../../helper/lib.ts"; - -const InputBlock = ( - block: ChaiBlock & { - blockProps: Record; - styles: Record; - inputStyles: Record; - required: boolean; - options: { label: string; value: string }[]; - _rows: number; - }, -) => { - const { blockProps, fieldName, label, placeholder, styles, inputStyles, _rows, showLabel } = block; - const fieldId = generateUUID(); - - if (!showLabel) { - return ( -