grid-layout.d.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /**
  2. * @descriptin Api docs https://jbaysolutions.github.io/vue-grid-layout/zh/guide/properties.html#griditem
  3. */
  4. declare module 'vue3-grid-layout' {
  5. import type { CSSProperties } from 'vue';
  6. interface Layout {
  7. i: string;
  8. x: number;
  9. y: number;
  10. w: number;
  11. h: number;
  12. static?: boolean;
  13. }
  14. interface BreakPoints {
  15. lg?: number;
  16. md?: number;
  17. sm?: number;
  18. xs?: number;
  19. xxs?: number;
  20. }
  21. interface GridLayoutProps {
  22. layout: Layout[];
  23. responsiveLayouts?: any;
  24. /**
  25. * @description Define Col Number, Need A Integer Number
  26. * @type number
  27. * @default 12
  28. */
  29. colNum?: number;
  30. /**
  31. * @description Define Row Height
  32. * @type number
  33. * @default 150
  34. */
  35. rowHeight?: number;
  36. /**
  37. * @description Define Max Rows
  38. * @type number
  39. * @default infinity
  40. */
  41. maxRows?: number;
  42. /**
  43. * @description Define Marign Distance In Grid Layout
  44. * @type [number, number]
  45. * @default [10, 10]
  46. */
  47. margin?: [number, number];
  48. /**
  49. * @description Define Element Can Draggable In Grid Layout
  50. * @type boolean
  51. * @default true
  52. */
  53. isDraggable?: boolean;
  54. /**
  55. * @description Define Element Can Resizeable In Grid Layout
  56. * @type boolean
  57. * @default true
  58. */
  59. isResizable?: boolean;
  60. /**
  61. * @description Define Element Can Mirrored In Grid Layout
  62. * @type boolean
  63. * @default false
  64. */
  65. isMirrored?: boolean;
  66. /**
  67. * @descripion Define Element Can Auto Size In Grid Layout
  68. * @type boolean
  69. * @default true
  70. */
  71. autoSize?: boolean;
  72. /**
  73. * @description Define Element Can Compact On Vertical Direction
  74. * @type boolean
  75. * @default false
  76. */
  77. verticalCompact?: boolean;
  78. /**
  79. * @description Define Element Prevent Collision
  80. * @type {boolean}
  81. * @default false
  82. */
  83. preventCollision?: boolean;
  84. /**
  85. * @description Define Element Use Css Transforms
  86. * @type {boolean}
  87. * @default true
  88. */
  89. useCssTransforms?: boolean;
  90. /**
  91. * @description Define Whether Is Responsive Layout
  92. * @type {boolean}
  93. * @default false
  94. */
  95. responsive?: boolean;
  96. /**
  97. * @description Setting Screen Break Points
  98. * @type {BreakPoints}
  99. * @default lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0
  100. */
  101. breakPoints?: BreakPoints;
  102. /**
  103. * @description Setting Column Break Points
  104. * @type {BreakPoints}
  105. * @default lg: 12, md: 10, sm: 6, xs: 4, xxs: 2
  106. */
  107. cols?: BreakPoints;
  108. /**
  109. * @descritpion Use Dynamic Cursor Style
  110. * @type {boolean}
  111. * @default false
  112. * @deprecated
  113. */
  114. useStyleCursor?: boolean;
  115. [key: string]: any;
  116. }
  117. interface GridItemProps extends Layout {
  118. /**
  119. * @description Min Width
  120. * @type {number}
  121. * @default 1
  122. */
  123. minW?: number;
  124. /**
  125. * @description Min Height
  126. * @type {number}
  127. * @default 1
  128. */
  129. minH?: number;
  130. /**
  131. * @description Max Width
  132. * @type {number}
  133. * @default 1
  134. */
  135. maxW?: number;
  136. /**
  137. * @description Min Height
  138. * @type {number}
  139. * @default 1
  140. */
  141. maxH?: number;
  142. /**
  143. * @description Flag Grid Element Can Draggable
  144. * @type {boolean | null}
  145. * @default null
  146. */
  147. isDraggable?: boolean;
  148. /**
  149. * @descrition Flag Grid Element Can Resizeable
  150. * @type {boolean | null}
  151. * @default null
  152. */
  153. isResizeable?: boolean;
  154. /**
  155. * @description Flag Grid Element Is Static , Can't Draggable Resizeable Move
  156. * @type {boolean}
  157. * @default false
  158. */
  159. static?: boolean;
  160. /**
  161. * @description Flag What Are The Element Can't Draggable, Usage Css Picker
  162. * @type {string}
  163. * @default 'a button'
  164. */
  165. dragIgnoreFrom?: string;
  166. /**
  167. * @description Flag What Are The Element Allow Draggable, Usage Css Picker
  168. * @type {string}
  169. * @default null
  170. */
  171. dragAllowFrom?: string;
  172. /**
  173. * @description Flag What Are The Element Can't Trigger Resize, Usage Css Picker
  174. * @type {string}
  175. * @deafult 'a button'
  176. */
  177. resizeIgnoreFrom?: string;
  178. style?: CSSProperties;
  179. onLayoutCreate?: (newLayout: Layout[]) => void;
  180. [key: string]: any;
  181. }
  182. type GirdLayoutEvent =
  183. | 'layoutCreate'
  184. | 'layoutBeforeMount'
  185. | 'layoutMounted'
  186. | 'layoutReady'
  187. | 'layoutUpdate'
  188. | 'breakpointChanged';
  189. interface LayoutBaseParams {
  190. newLayout: Layout[];
  191. }
  192. interface GridLayoutEmit {
  193. layoutCreate: LayoutBaseParams;
  194. layoutBeforeMount: LayoutBeforeMountParams;
  195. layoutMounted: LayoutMountedParams;
  196. layoutReady: layoutUpdateParams;
  197. layoutUpdate: layoutUpdateParams;
  198. breakpointChanged: breakpointChangedParams;
  199. }
  200. /**
  201. * @description Grid Item Event Name
  202. */
  203. type GridItemEvent = 'move' | 'moved' | 'resize' | 'resized' | 'containerResized';
  204. interface MoveParams {
  205. i: number;
  206. newX?: number;
  207. newY?: number;
  208. }
  209. interface ResizeParams {
  210. i: number;
  211. newH: number;
  212. newW: number;
  213. newHPx: number;
  214. newWPx: number;
  215. }
  216. interface GridItemEmit {
  217. move: MoveParams;
  218. moved: MoveParams;
  219. resize: ResizeParams;
  220. resized: ResizeParams;
  221. containerResized: MoveParams;
  222. }
  223. // const GridLayout: DefineComponent<GridLayoutProps, void, unknown>
  224. // const GridItem: DefineComponent<GridItemProps, void, unknown>
  225. const GridLayout: {
  226. new (): {
  227. $props: GridLayoutProps;
  228. $emit: <T extends GirdLayoutEvent>(event: T, ...args: GridLayoutEmit[T]) => void;
  229. };
  230. };
  231. const GridItem: {
  232. new (): {
  233. $props: GridItemProps;
  234. $emit: <T extends GridItemEvent>(event: T, ...args: GridItemEmit[T]) => void;
  235. };
  236. };
  237. export { GridLayout, GridItem, BreakPoints, Layout, LayoutBaseParams, ResizeParams };
  238. }