MCPcopy Create free account
hub / github.com/PaulleDemon/PyUIBuilder / constructor

Function constructor

src/canvas/widgets/base.js:48–221  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

46 // static contextType = ActiveWidgetContext
47
48 constructor(props) {
49 super(props)
50
51 const { id, widgetName, canvasRef, canvasMetaData } = props
52 // console.log("Id: ", id)
53 // this id has to be unique inside the canvas, it will be set automatically and should never be changed
54 this.__id = id
55 this.canvas = canvasRef?.current || null // canvasContainerRef, because some events work properly only if attached to the container
56
57 this.canvasMetaData = canvasMetaData
58
59 // this._selected = false
60 this._disableResize = false
61 this._disableSelection = false
62
63 this.minSize = { width: 10, height: 10 } // disable resizing below this number
64 this.maxSize = { width: 2000, height: 2000 } // disable resizing above this number
65
66 this.cursor = Cursor.POINTER
67
68 this.icon = "" // antd icon name representing this widget
69
70 this.elementRef = React.createRef() // this is the outer ref for draggable area
71 this.swappableAreaRef = React.createRef() // helps identify if the users intent is to swap or drop inside the widget
72 this.innerAreaRef = React.createRef() // this is the inner area where swap is prevented and only drop is accepted
73
74 this.styleAreaRef = React.createRef() // use ref this where inner widget style is applied
75
76 this.functions = {
77 "load": { "args1": "number", "args2": "string" }
78 }
79
80 // This indicates if the draggable can be dropped on this widget, set this to null to disable drops
81 this.droppableTags = {}
82
83
84 this.state = {
85 zIndex: 0,
86 selected: false,
87 isWidgetVisible: true,
88
89 // forceRerenderId: "",
90
91 widgetName: widgetName || 'widget', // this will later be converted to variable name
92 enableRename: false, // will open the widgets editable div for renaming
93
94 parentLayout: null, // depending on the parents layout the child will behave
95
96 isDragging: false, // tells if the widget is currently being dragged
97 dragEnabled: true,
98
99 widgetContainer: WidgetContainer.CANVAS, // what is the parent of the widget
100
101 showDroppableStyle: { // shows the droppable indicator
102 allow: false,
103 show: false,
104 },
105

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected