|
| 1 | +import type { AllowedComponentProps, App, ComponentCustomProps, DefineComponent, VNodeProps } from "vue"; |
| 2 | + |
| 3 | +export type AxisType = "both" | "x" | "y"; |
| 4 | +export type HandleType = "bl" | "bm" | "br" | "ml" | "mr" | "tl" | "tm" | "tr"; |
| 5 | + |
| 6 | +export interface VueDraggableResizableProps { |
| 7 | + /** |
| 8 | + * Whether the component is active (selected) |
| 9 | + * @default false |
| 10 | + */ |
| 11 | + active?: boolean; |
| 12 | + /** |
| 13 | + * Restrict drag/resize to a specific axis |
| 14 | + * @default 'both' |
| 15 | + */ |
| 16 | + axis?: AxisType; |
| 17 | + /** |
| 18 | + * Base class name for the component |
| 19 | + * @default 'vdr' |
| 20 | + */ |
| 21 | + className?: string; |
| 22 | + /** |
| 23 | + * Class added when component is active |
| 24 | + * @default 'active' |
| 25 | + */ |
| 26 | + classNameActive?: string; |
| 27 | + /** |
| 28 | + * Class added when component is draggable |
| 29 | + * @default 'draggable' |
| 30 | + */ |
| 31 | + classNameDraggable?: string; |
| 32 | + /** |
| 33 | + * Class added during dragging |
| 34 | + * @default 'dragging' |
| 35 | + */ |
| 36 | + classNameDragging?: string; |
| 37 | + /** |
| 38 | + * Common class for resize handles |
| 39 | + * @default 'handle' |
| 40 | + */ |
| 41 | + classNameHandle?: string; |
| 42 | + /** |
| 43 | + * Class added when component is resizable |
| 44 | + * @default 'resizable' |
| 45 | + */ |
| 46 | + classNameResizable?: string; |
| 47 | + /** |
| 48 | + * Class added during resizing |
| 49 | + * @default 'resizing' |
| 50 | + */ |
| 51 | + classNameResizing?: string; |
| 52 | + /** |
| 53 | + * Disable text selection during drag/resize |
| 54 | + * @default true |
| 55 | + */ |
| 56 | + disableUserSelect?: boolean; |
| 57 | + /** |
| 58 | + * CSS selector for elements that should cancel drag |
| 59 | + */ |
| 60 | + dragCancel?: string | null; |
| 61 | + /** |
| 62 | + * Whether the component can be dragged |
| 63 | + * @default true |
| 64 | + */ |
| 65 | + draggable?: boolean; |
| 66 | + /** |
| 67 | + * CSS selector for drag handle element |
| 68 | + */ |
| 69 | + dragHandle?: string | null; |
| 70 | + /** |
| 71 | + * Enable native HTML5 drag and drop |
| 72 | + * @default false |
| 73 | + */ |
| 74 | + enableNativeDrag?: boolean; |
| 75 | + /** |
| 76 | + * Snap grid [x, y] |
| 77 | + * @default [1, 1] |
| 78 | + */ |
| 79 | + grid?: [number, number]; |
| 80 | + /** |
| 81 | + * Initial height (number in px or 'auto') |
| 82 | + * @default 200 |
| 83 | + */ |
| 84 | + h?: number | "auto"; |
| 85 | + /** |
| 86 | + * Which resize handles to show |
| 87 | + * @default ['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml'] |
| 88 | + */ |
| 89 | + handles?: HandleType[]; |
| 90 | + /** |
| 91 | + * Lock aspect ratio during resize |
| 92 | + * @default false |
| 93 | + */ |
| 94 | + lockAspectRatio?: boolean; |
| 95 | + /** |
| 96 | + * Maximum height constraint |
| 97 | + * @default null |
| 98 | + */ |
| 99 | + maxHeight?: number | null; |
| 100 | + /** |
| 101 | + * Maximum width constraint |
| 102 | + * @default null |
| 103 | + */ |
| 104 | + maxWidth?: number | null; |
| 105 | + /** |
| 106 | + * Minimum height constraint |
| 107 | + * @default 0 |
| 108 | + */ |
| 109 | + minHeight?: number; |
| 110 | + /** |
| 111 | + * Minimum width constraint |
| 112 | + * @default 0 |
| 113 | + */ |
| 114 | + minWidth?: number; |
| 115 | + /** |
| 116 | + * Called during drag, return false to cancel |
| 117 | + * @default () => true |
| 118 | + */ |
| 119 | + onDrag?: (x: number, y: number) => boolean | undefined; |
| 120 | + /** |
| 121 | + * Called when drag starts, return false to cancel |
| 122 | + * @default () => true |
| 123 | + */ |
| 124 | + onDragStart?: (x: number, y: number) => boolean | undefined; |
| 125 | + /** |
| 126 | + * Called when drag stops |
| 127 | + */ |
| 128 | + onDragStop?: (x: number, y: number) => void; |
| 129 | + /** |
| 130 | + * Called during resize, return false to cancel |
| 131 | + * @default () => true |
| 132 | + */ |
| 133 | + onResize?: (handle: HandleType, x: number, y: number, width: number, height: number) => boolean | undefined; |
| 134 | + /** |
| 135 | + * Called when resize starts, return false to cancel |
| 136 | + * @default () => true |
| 137 | + */ |
| 138 | + onResizeStart?: (handle: HandleType, x: number, y: number, width: number, height: number) => boolean | undefined; |
| 139 | + /** |
| 140 | + * Called when resize stops |
| 141 | + */ |
| 142 | + onResizeStop?: (x: number, y: number, width: number, height: number) => void; |
| 143 | + /** |
| 144 | + * Constrain movement/resize to parent element |
| 145 | + * @default false |
| 146 | + */ |
| 147 | + parent?: boolean; |
| 148 | + /** |
| 149 | + * Prevent deactivation when clicking outside |
| 150 | + * @default false |
| 151 | + */ |
| 152 | + preventDeactivation?: boolean; |
| 153 | + /** |
| 154 | + * Whether the component can be resized |
| 155 | + * @default true |
| 156 | + */ |
| 157 | + resizable?: boolean; |
| 158 | + /** |
| 159 | + * Scale factor for CSS transforms (number or [scaleX, scaleY]) |
| 160 | + * @default 1 |
| 161 | + */ |
| 162 | + scale?: number | [number, number]; |
| 163 | + /** |
| 164 | + * Initial width (number in px or 'auto') |
| 165 | + * @default 200 |
| 166 | + */ |
| 167 | + w?: number | "auto"; |
| 168 | + /** |
| 169 | + * Initial X position |
| 170 | + * @default 0 |
| 171 | + */ |
| 172 | + x?: number; |
| 173 | + /** |
| 174 | + * Initial Y position |
| 175 | + * @default 0 |
| 176 | + */ |
| 177 | + y?: number; |
| 178 | + /** |
| 179 | + * Z-index value |
| 180 | + * @default 'auto' |
| 181 | + */ |
| 182 | + z?: number | "auto"; |
| 183 | +} |
| 184 | + |
| 185 | +export interface VueDraggableResizableSlots { |
| 186 | + /** Default slot for component content */ |
| 187 | + default?: () => VNodeProps[]; |
| 188 | +} |
| 189 | + |
| 190 | +declare const VueDraggableResizable: |
| 191 | + & DefineComponent<VueDraggableResizableProps> |
| 192 | + & AllowedComponentProps |
| 193 | + & ComponentCustomProps; |
| 194 | + |
| 195 | +/** Vue plugin install function */ |
| 196 | +export function install(app: App): void; |
| 197 | + |
| 198 | +export default VueDraggableResizable; |
0 commit comments