feat: added checkbox and other widgets for tkinter
This commit is contained in:
@@ -29,7 +29,7 @@ export function SidebarWidgetCard({ name, img, url, widgetClass, innerRef}){
|
||||
return (
|
||||
// <Draggable className="tw-cursor-pointer" id={name}>
|
||||
<DraggableWrapper data-container={"sidebar"}
|
||||
dragElementType={"widget"}
|
||||
dragElementType={widgetClass.widgetType}
|
||||
dragWidgetClass={widgetClass}
|
||||
className="tw-cursor-pointer tw-w-fit tw-h-fit">
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useDragContext } from "./draggableContext"
|
||||
|
||||
|
||||
/**
|
||||
* @param {{include: [], exclude: []} || {}} - droppableTags - if empty object, allows everything to be dropped, define include to allow only included widgets, define exclude to exclude
|
||||
* @param {{include: [], exclude: []} || {} || null} - droppableTags - if empty object, allows everything to be dropped, if null nothing can be dropped, define include to allow only included widgets, define exclude to exclude
|
||||
*/
|
||||
const DroppableWrapper = memo(({onDrop, droppableTags={}, ...props}) => {
|
||||
|
||||
@@ -20,11 +20,10 @@ const DroppableWrapper = memo(({onDrop, droppableTags={}, ...props}) => {
|
||||
|
||||
const dragElementType = draggedElement.getAttribute("data-draggable-type")
|
||||
|
||||
console.log("Current target: ", droppableTags, Object.keys(droppableTags))
|
||||
|
||||
setOverElement(e.currentTarget)
|
||||
|
||||
const allowDrop = (droppableTags && (Object.keys(droppableTags).length === 0 ||
|
||||
const allowDrop = (droppableTags && droppableTags !== null && (Object.keys(droppableTags).length === 0 ||
|
||||
(droppableTags.include?.length > 0 && droppableTags.include?.includes(dragElementType)) ||
|
||||
(droppableTags.exclude?.length > 0 && !droppableTags.exclude?.includes(dragElementType))
|
||||
))
|
||||
@@ -46,7 +45,7 @@ const DroppableWrapper = memo(({onDrop, droppableTags={}, ...props}) => {
|
||||
// console.log("Drag over: ", e.dataTransfer.getData("text/plain"), e.dataTransfer)
|
||||
const dragElementType = draggedElement.getAttribute("data-draggable-type")
|
||||
|
||||
const allowDrop = (droppableTags && (Object.keys(droppableTags).length === 0 ||
|
||||
const allowDrop = (droppableTags && droppableTags !== null && (Object.keys(droppableTags).length === 0 ||
|
||||
(droppableTags.include?.length > 0 && droppableTags.include?.includes(dragElementType)) ||
|
||||
(droppableTags.exclude?.length > 0 && !droppableTags.exclude?.includes(dragElementType))
|
||||
))
|
||||
@@ -67,7 +66,7 @@ const DroppableWrapper = memo(({onDrop, droppableTags={}, ...props}) => {
|
||||
const dragElementType = draggedElement.getAttribute("data-draggable-type")
|
||||
|
||||
|
||||
const allowDrop = (droppableTags && (Object.keys(droppableTags).length === 0 ||
|
||||
const allowDrop = (droppableTags && droppableTags !== null && (Object.keys(droppableTags).length === 0 ||
|
||||
(droppableTags.include?.length > 0 && droppableTags.include?.includes(dragElementType)) ||
|
||||
(droppableTags.exclude?.length > 0 && !droppableTags.exclude?.includes(dragElementType))
|
||||
))
|
||||
|
||||
51
src/components/modals.js
Normal file
51
src/components/modals.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { useState } from "react"
|
||||
|
||||
import { Modal } from "antd"
|
||||
|
||||
/**
|
||||
* opens modal when clicked, acts as a wrapper
|
||||
* @param {string} - message
|
||||
* @param {string} - title
|
||||
* @param {string} - okText
|
||||
* @param {"default"|"danger"|"primary"} - okButtonType
|
||||
* @returns
|
||||
*/
|
||||
export const ButtonModal = ({ message, title, okText="OK", onOk, onCancel, okButtonType="default", children}) => {
|
||||
|
||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
||||
|
||||
const showModal = () => {
|
||||
setIsModalOpen(true)
|
||||
}
|
||||
|
||||
const handleOk = () => {
|
||||
setIsModalOpen(false)
|
||||
console.log("Ok pressed")
|
||||
if (onOk){
|
||||
onOk()
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = (e) => {
|
||||
e.stopPropagation()
|
||||
|
||||
setIsModalOpen(false)
|
||||
console.log("cancel pressed")
|
||||
|
||||
if (onCancel){
|
||||
onCancel()
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div onClick={showModal}>
|
||||
{children}
|
||||
<Modal title={title} open={isModalOpen} onClose={handleCancel}
|
||||
okText={okText}
|
||||
onOk={handleOk} okType={okButtonType} onCancel={handleCancel}>
|
||||
<p>{message}</p>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user