diff --git a/bun.lockb b/bun.lockb index ae27f9d..ee0571e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/lib/editors/AceEditor.tsx b/components/lib/editors/AceEditor.tsx old mode 100755 new mode 100644 diff --git a/components/lib/elements/Border.tsx b/components/lib/elements/Border.tsx index 88290fe..01dd3cf 100644 --- a/components/lib/elements/Border.tsx +++ b/components/lib/elements/Border.tsx @@ -17,7 +17,7 @@ export default function Border({ spacing, ...props }: TWUI_BORDER_PROPS) {
, + HTMLDivElement +> & { + variant?: "normal"; + href?: string; + linkProps?: DetailedHTMLProps< + React.AnchorHTMLAttributes, + HTMLAnchorElement + >; + noHover?: boolean; +}; + /** * # General Card * @className twui-card @@ -13,22 +26,18 @@ export default function Card({ href, variant, linkProps, + noHover, ...props -}: DetailedHTMLProps, HTMLDivElement> & { - variant?: "normal"; - href?: string; - linkProps?: DetailedHTMLProps< - React.AnchorHTMLAttributes, - HTMLAnchorElement - >; -}) { +}: Props) { const component = (
; debounce?: number; hoverOpen?: boolean; + above?: boolean; position?: (typeof TWUIDropdownContentPositions)[number]; topOffset?: number; externalSetOpen?: React.Dispatch>; @@ -41,6 +42,7 @@ export default function Dropdown({ contentWrapperProps, targetWrapperProps, hoverOpen, + above, debounce = 500, target, position = "center", @@ -122,6 +124,7 @@ export default function Dropdown({ : position == "right" ? "right-0" : "", + above ? "-translate-y-[120%]" : "", open ? "flex" : "hidden", "twui-dropdown-content", contentWrapperProps?.className diff --git a/components/lib/elements/Tag.tsx b/components/lib/elements/Tag.tsx index fae2eff..6bd6f23 100644 --- a/components/lib/elements/Tag.tsx +++ b/components/lib/elements/Tag.tsx @@ -15,6 +15,7 @@ export type TWUI_TOGGLE_PROPS = PropsWithChildren & > & { color?: "normal" | "secondary" | "error" | "success" | "gray"; variant?: "normal" | "outlined" | "ghost"; + href?: string; }; /** @@ -25,13 +26,15 @@ export default function Tag({ color, variant, children, + href, ...props }: TWUI_TOGGLE_PROPS) { - return ( + const mainComponent = (
); + + if (href) { + return ( + + {mainComponent} + + ); + } + + return mainComponent; } diff --git a/components/lib/form/Form.tsx b/components/lib/form/Form.tsx index 4baecd1..dce0147 100644 --- a/components/lib/form/Form.tsx +++ b/components/lib/form/Form.tsx @@ -27,6 +27,7 @@ export default function Form({ const formData = new FormData(formEl); const data = Object.fromEntries(formData.entries()) as T; props.submitHandler?.(e, data); + props.onSubmit?.(e); }} > {props.children} diff --git a/components/lib/form/ImageUpload.tsx b/components/lib/form/ImageUpload.tsx index f87f096..ec3d290 100644 --- a/components/lib/form/ImageUpload.tsx +++ b/components/lib/form/ImageUpload.tsx @@ -14,7 +14,9 @@ type ImageUploadProps = DetailedHTMLProps< React.HTMLAttributes, HTMLDivElement > & { - onChange?: (imgData: ImageInputToBase64FunctionReturn | undefined) => any; + onChangeHandler?: ( + imgData: ImageInputToBase64FunctionReturn | undefined + ) => any; fileInputProps?: DetailedHTMLProps< React.InputHTMLAttributes, HTMLInputElement @@ -35,8 +37,11 @@ type ImageUploadProps = DetailedHTMLProps< disablePreview?: boolean; }; +/** + * @note use the `onChangeHandler` prop to grab the parsed base64 image object + */ export default function ImageUpload({ - onChange, + onChangeHandler, fileInputProps, placeHolderWrapper, previewImageWrapperProps, @@ -60,7 +65,7 @@ export default function ImageUpload({ onChange={(e) => { imageInputToBase64({ imageInput: e.target }).then((res) => { setSrc(res.imageBase64Full); - onChange?.(res); + onChangeHandler?.(res); fileInputProps?.onChange?.(e); }); }} @@ -88,7 +93,7 @@ export default function ImageUpload({ className="absolute p-2 top-2 right-2 z-20" onClick={(e) => { setSrc(undefined); - onChange?.(undefined); + onChangeHandler?.(undefined); }} > diff --git a/components/lib/form/Input.tsx b/components/lib/form/Input.tsx index 7e145de..84b1516 100644 --- a/components/lib/form/Input.tsx +++ b/components/lib/form/Input.tsx @@ -107,6 +107,7 @@ export type InputProps = DetailedHTMLProps< validationFunction?: (value: string) => Promise; autoComplete?: (typeof autocompleteOptions)[number]; name?: KeyType; + valueUpdate?: string; }; /** @@ -130,11 +131,16 @@ export default function Input({ autoComplete, validationFunction, validationRegex, + valueUpdate, ...props }: InputProps) { const [focus, setFocus] = React.useState(false); const [value, setValue] = React.useState( - props.defaultValue ? String(props.defaultValue) : "" + props.value + ? String(props.value) + : props.defaultValue + ? String(props.defaultValue) + : "" ); delete props.defaultValue; @@ -163,6 +169,11 @@ export default function Input({ } }, [value]); + React.useEffect(() => { + if (!props.value) return; + setValue(String(props.value)); + }, [props.value]); + const targetComponent = istextarea ? (