Removed wrapper span from Draggable
All checks were successful
armco-org/shared-components/pipeline/head This commit looks good

This commit is contained in:
2025-11-13 16:08:04 +05:30
parent e7f4b1f984
commit 052f0b83c1
2 changed files with 9 additions and 29 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "@armco/shared-components",
"description": "React Component Lib of independent components that can be utilised by sophisticated ones in @armco/components",
"version": "0.0.59",
"version": "0.0.60",
"type": "module",
"author": "Armco (@restruct-corporate-advantage)",
"types": "build/types/index.d.ts",

View File

@@ -10,16 +10,10 @@ import React, {
} from "react"
import { useDrag } from "react-dnd"
import { getEmptyImage } from "react-dnd-html5-backend"
import { ArDndItemTypes } from "./enums"
import { BaseProps } from "@armco/types"
import { ArDndItemTypes } from "./enums"
import "./Draggable.component.scss"
const dummyChildren = (
<div
style={{ width: "10rem", height: "10rem", backgroundColor: "white" }}
></div>
)
export interface DraggableProps extends BaseProps {
itemType?: ArDndItemTypes | string
@@ -102,7 +96,6 @@ const Draggable = forwardRef((props: DraggableProps, ref) => {
return styleObj as { [key: string]: string }
}
const isDOMElement = typeof (firstChild as any)?.type === "string"
const mergedStyle = {
...toPlainStyle(childStyles),
...toPlainStyle(style),
@@ -110,26 +103,13 @@ const Draggable = forwardRef((props: DraggableProps, ref) => {
opacity: isDragging ? 0.5 : 1,
} as React.CSSProperties
if (isDOMElement) {
return cloneElement(firstChild as ReactElement<any>, {
ref: dragRef,
style: mergedStyle,
className: `ar-Draggable ${childClasses || ""}`.trim(),
...(restProps || {}),
})
} else {
const spanRef: Ref<HTMLSpanElement> = dragRef as Ref<HTMLSpanElement>
return (
<span
ref={spanRef}
style={mergedStyle}
className={`ar-Draggable ${childClasses || ""}`.trim()}
{...restProps}
>
{firstChild}
</span>
)
}
return cloneElement(firstChild as ReactElement<any>, {
ref: dragRef,
style: mergedStyle,
className: `ar-Draggable ${childClasses || ""}`.trim(),
...(restProps || {}),
})
})
export default Draggable