gridstack 4.2.7 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +28 -19
  2. package/dist/es5/gridstack-dd.d.ts +35 -0
  3. package/dist/es5/gridstack-dd.js +683 -0
  4. package/dist/es5/gridstack-dd.js.map +1 -0
  5. package/dist/es5/gridstack-ddi.d.ts +17 -0
  6. package/dist/es5/gridstack-ddi.js +31 -0
  7. package/dist/es5/gridstack-ddi.js.map +1 -0
  8. package/dist/es5/gridstack-engine.d.ts +93 -0
  9. package/dist/es5/gridstack-engine.js +955 -0
  10. package/dist/es5/gridstack-engine.js.map +1 -0
  11. package/dist/es5/gridstack-h5.d.ts +10 -0
  12. package/dist/es5/gridstack-h5.js +3 -0
  13. package/dist/es5/gridstack-h5.js.LICENSE.txt +7 -0
  14. package/dist/es5/gridstack-h5.js.map +1 -0
  15. package/dist/es5/gridstack-jq.d.ts +10 -0
  16. package/dist/es5/gridstack-jq.js +3 -0
  17. package/dist/es5/gridstack-jq.js.LICENSE.txt +99 -0
  18. package/dist/es5/gridstack-jq.js.map +1 -0
  19. package/dist/{gridstack-poly.js → es5/gridstack-poly.js} +152 -1
  20. package/dist/es5/gridstack-static.d.ts +9 -0
  21. package/dist/es5/gridstack-static.js +3 -0
  22. package/dist/es5/gridstack-static.js.LICENSE.txt +7 -0
  23. package/dist/es5/gridstack-static.js.map +1 -0
  24. package/dist/es5/gridstack.d.ts +346 -0
  25. package/dist/es5/gridstack.js +1482 -0
  26. package/dist/es5/gridstack.js.map +1 -0
  27. package/dist/es5/h5/dd-base-impl.d.ts +20 -0
  28. package/dist/es5/h5/dd-base-impl.js +43 -0
  29. package/dist/es5/h5/dd-base-impl.js.map +1 -0
  30. package/dist/es5/h5/dd-draggable.d.ts +30 -0
  31. package/dist/es5/h5/dd-draggable.js +319 -0
  32. package/dist/es5/h5/dd-draggable.js.map +1 -0
  33. package/dist/es5/h5/dd-droppable.d.ts +23 -0
  34. package/dist/es5/h5/dd-droppable.js +182 -0
  35. package/dist/es5/h5/dd-droppable.js.map +1 -0
  36. package/dist/es5/h5/dd-element.d.ts +27 -0
  37. package/dist/es5/h5/dd-element.js +96 -0
  38. package/dist/es5/h5/dd-element.js.map +1 -0
  39. package/dist/es5/h5/dd-manager.d.ts +8 -0
  40. package/dist/es5/h5/dd-manager.js +14 -0
  41. package/dist/es5/h5/dd-manager.js.map +1 -0
  42. package/dist/es5/h5/dd-resizable-handle.d.ts +14 -0
  43. package/dist/es5/h5/dd-resizable-handle.js +83 -0
  44. package/dist/es5/h5/dd-resizable-handle.js.map +1 -0
  45. package/dist/es5/h5/dd-resizable.d.ts +29 -0
  46. package/dist/es5/h5/dd-resizable.js +302 -0
  47. package/dist/es5/h5/dd-resizable.js.map +1 -0
  48. package/dist/es5/h5/dd-utils.d.ts +17 -0
  49. package/dist/es5/h5/dd-utils.js +99 -0
  50. package/dist/es5/h5/dd-utils.js.map +1 -0
  51. package/dist/es5/h5/gridstack-dd-native.d.ts +26 -0
  52. package/dist/es5/h5/gridstack-dd-native.js +175 -0
  53. package/dist/es5/h5/gridstack-dd-native.js.map +1 -0
  54. package/dist/es5/jq/gridstack-dd-jqueryui.d.ts +22 -0
  55. package/dist/es5/jq/gridstack-dd-jqueryui.js +162 -0
  56. package/dist/es5/jq/gridstack-dd-jqueryui.js.map +1 -0
  57. package/dist/es5/types.d.ts +258 -0
  58. package/dist/es5/types.js +7 -0
  59. package/dist/es5/types.js.map +1 -0
  60. package/dist/es5/utils.d.ts +73 -0
  61. package/dist/es5/utils.js +444 -0
  62. package/dist/es5/utils.js.map +1 -0
  63. package/dist/gridstack-dd.d.ts +1 -1
  64. package/dist/gridstack-dd.js +15 -7
  65. package/dist/gridstack-dd.js.map +1 -1
  66. package/dist/gridstack-ddi.d.ts +1 -1
  67. package/dist/gridstack-ddi.js +1 -1
  68. package/dist/gridstack-ddi.js.map +1 -1
  69. package/dist/gridstack-engine.d.ts +3 -2
  70. package/dist/gridstack-engine.js +100 -60
  71. package/dist/gridstack-engine.js.map +1 -1
  72. package/dist/gridstack-extra.css +800 -530
  73. package/dist/gridstack-extra.min.css +1 -1
  74. package/dist/gridstack-h5.d.ts +1 -1
  75. package/dist/gridstack-h5.js +1 -1
  76. package/dist/gridstack-h5.js.LICENSE.txt +1 -1
  77. package/dist/gridstack-h5.js.map +1 -1
  78. package/dist/gridstack-jq.d.ts +1 -1
  79. package/dist/gridstack-jq.js +1 -1
  80. package/dist/gridstack-jq.js.LICENSE.txt +1 -1
  81. package/dist/gridstack-jq.js.map +1 -1
  82. package/dist/gridstack-static.d.ts +1 -1
  83. package/dist/gridstack-static.js +1 -1
  84. package/dist/gridstack-static.js.LICENSE.txt +1 -1
  85. package/dist/gridstack-static.js.map +1 -1
  86. package/dist/gridstack.css +305 -228
  87. package/dist/gridstack.d.ts +1 -1
  88. package/dist/gridstack.js +13 -11
  89. package/dist/gridstack.js.map +1 -1
  90. package/dist/gridstack.min.css +1 -1
  91. package/dist/h5/dd-base-impl.d.ts +1 -1
  92. package/dist/h5/dd-base-impl.js +1 -1
  93. package/dist/h5/dd-base-impl.js.map +1 -1
  94. package/dist/h5/dd-draggable.d.ts +1 -1
  95. package/dist/h5/dd-draggable.js +1 -1
  96. package/dist/h5/dd-draggable.js.map +1 -1
  97. package/dist/h5/dd-droppable.d.ts +1 -1
  98. package/dist/h5/dd-droppable.js +1 -1
  99. package/dist/h5/dd-droppable.js.map +1 -1
  100. package/dist/h5/dd-element.d.ts +1 -1
  101. package/dist/h5/dd-element.js +1 -1
  102. package/dist/h5/dd-element.js.map +1 -1
  103. package/dist/h5/dd-manager.d.ts +1 -1
  104. package/dist/h5/dd-manager.js +1 -1
  105. package/dist/h5/dd-manager.js.map +1 -1
  106. package/dist/h5/dd-resizable-handle.d.ts +1 -1
  107. package/dist/h5/dd-resizable-handle.js +1 -1
  108. package/dist/h5/dd-resizable-handle.js.map +1 -1
  109. package/dist/h5/dd-resizable.d.ts +1 -1
  110. package/dist/h5/dd-resizable.js +2 -1
  111. package/dist/h5/dd-resizable.js.map +1 -1
  112. package/dist/h5/dd-utils.d.ts +1 -1
  113. package/dist/h5/dd-utils.js +1 -1
  114. package/dist/h5/dd-utils.js.map +1 -1
  115. package/dist/h5/gridstack-dd-native.d.ts +1 -1
  116. package/dist/h5/gridstack-dd-native.js +1 -1
  117. package/dist/h5/gridstack-dd-native.js.map +1 -1
  118. package/dist/jq/gridstack-dd-jqueryui.js.map +1 -1
  119. package/dist/src/gridstack-extra.scss +7 -5
  120. package/dist/src/gridstack.scss +9 -7
  121. package/dist/types.d.ts +5 -2
  122. package/dist/types.js +1 -1
  123. package/dist/types.js.map +1 -1
  124. package/dist/utils.d.ts +3 -1
  125. package/dist/utils.js +7 -5
  126. package/dist/utils.js.map +1 -1
  127. package/doc/CHANGES.md +22 -0
  128. package/package.json +6 -5
@@ -0,0 +1,258 @@
1
+ /**
2
+ * types.ts 4.4.1
3
+ * Copyright (c) 2021 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { GridStack } from './gridstack';
6
+ /** different layout options when changing # of columns,
7
+ * including a custom function that takes new/old column count, and array of new/old positions
8
+ * Note: new list may be partially already filled if we have a cache of the layout at that size and new items were added later.
9
+ */
10
+ export declare type ColumnOptions = 'moveScale' | 'move' | 'scale' | 'none' | ((column: number, oldColumn: number, nodes: GridStackNode[], oldNodes: GridStackNode[]) => void);
11
+ export declare type numberOrString = number | string;
12
+ export interface GridItemHTMLElement extends HTMLElement {
13
+ /** pointer to grid node instance */
14
+ gridstackNode?: GridStackNode;
15
+ }
16
+ export declare type GridStackElement = string | HTMLElement | GridItemHTMLElement;
17
+ export declare type GridStackEventHandlerCallback = (event: Event, arg2?: GridItemHTMLElement | GridStackNode | GridStackNode[], newNode?: GridStackNode) => void;
18
+ /**
19
+ * Defines the options for a Grid
20
+ */
21
+ export interface GridStackOptions {
22
+ /**
23
+ * accept widgets dragged from other grids or from outside (default: `false`). Can be:
24
+ * `true` (uses `'.grid-stack-item'` class filter) or `false`,
25
+ * string for explicit class name,
26
+ * function returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
27
+ */
28
+ acceptWidgets?: boolean | string | ((element: Element) => boolean);
29
+ /** possible values (default: `false` only show on hover)
30
+ * `true` the resizing handles are always shown even if the user is not hovering over the widget
31
+ * advance condition such as this mobile browser agent check:
32
+ `alwaysShowResizeHandle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent )`
33
+ See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html) */
34
+ alwaysShowResizeHandle?: boolean;
35
+ /** turns animation on (default?: true) */
36
+ animate?: boolean;
37
+ /** if false gridstack will not initialize existing items (default?: true) */
38
+ auto?: boolean;
39
+ /**
40
+ * one cell height (default?: 'auto'). Can be:
41
+ * an integer (px)
42
+ * a string (ex: '100px', '10em', '10rem'). Note: % doesn't right - see demo/cell-height.html
43
+ * 0, in which case the library will not generate styles for rows. Everything must be defined in your own CSS files.
44
+ * 'auto' - height will be calculated for square cells (width / column) and updated live as you resize the window - also see `cellHeightThrottle`
45
+ * 'initial' - similar to 'auto' (start at square cells) but stay that size during window resizing.
46
+ */
47
+ cellHeight?: numberOrString;
48
+ /** throttle time delay (in ms) used when cellHeight='auto' to improve performance vs usability (default?: 100).
49
+ * A value of 0 will make it instant at a cost of re-creating the CSS file at ever window resize event!
50
+ * */
51
+ cellHeightThrottle?: number;
52
+ /** (internal) unit for cellHeight (default? 'px') which is set when a string cellHeight with a unit is passed (ex: '10rem') */
53
+ cellHeightUnit?: string;
54
+ /** list of children item to create when calling load() or addGrid() */
55
+ children?: GridStackWidget[];
56
+ /** number of columns (default?: 12). Note: IF you change this, CSS also have to change. See https://github.com/gridstack/gridstack.js#change-grid-columns */
57
+ column?: number;
58
+ /** additional class on top of '.grid-stack' (which is required for our CSS) to differentiate this instance.
59
+ Note: only used by addGrid(), else your element should have the needed class */
60
+ class?: string;
61
+ /** disallows dragging of widgets (default?: false) */
62
+ disableDrag?: boolean;
63
+ /** disables the onColumnMode when the grid width is less than minWidth (default?: false) */
64
+ disableOneColumnMode?: boolean;
65
+ /** disallows resizing of widgets (default?: false). */
66
+ disableResize?: boolean;
67
+ /** allows to override UI draggable options. (default?: { handle?: '.grid-stack-item-content', scroll?: true, appendTo?: 'body', containment: null }) */
68
+ draggable?: DDDragOpt;
69
+ /** allows to drag external items using this selector - see dragInOptions. (default: undefined) */
70
+ dragIn?: string;
71
+ /** allows to drag external items using these options. See `GridStack.setupDragIn()` instead (not per grid really).
72
+ * (default?: { handle: '.grid-stack-item-content', revert: 'invalid', scroll: false, appendTo: 'body' })
73
+ * helper can be 'clone' or your own function (set what the drag/dropped item will be instead)
74
+ */
75
+ dragInOptions?: DDDragInOpt;
76
+ /** let user drag nested grid items out of a parent or not (default false) */
77
+ dragOut?: boolean;
78
+ /** enable floating widgets (default?: false) See example (http://gridstack.github.io/gridstack.js/demo/float.html) */
79
+ float?: boolean;
80
+ /** draggable handle selector (default?: '.grid-stack-item-content') */
81
+ handle?: string;
82
+ /** draggable handle class (e.g. 'grid-stack-item-content'). If set 'handle' is ignored (default?: null) */
83
+ handleClass?: string;
84
+ /** additional widget class (default?: 'grid-stack-item') */
85
+ itemClass?: string;
86
+ /**
87
+ * gap between grid item and content (default?: 10). This will set all 4 sides and support the CSS formats below
88
+ * an integer (px)
89
+ * a string with possible units (ex: '2em', '20px', '2rem')
90
+ * string with space separated values (ex: '5px 10px 0 20px' for all 4 sides, or '5em 10em' for top/bottom and left/right pairs like CSS).
91
+ * Note: all sides must have same units (last one wins, default px)
92
+ */
93
+ margin?: numberOrString;
94
+ /** OLD way to optionally set each side - use margin: '5px 10px 0 20px' instead. Used internally to store each side. */
95
+ marginTop?: numberOrString;
96
+ marginRight?: numberOrString;
97
+ marginBottom?: numberOrString;
98
+ marginLeft?: numberOrString;
99
+ /** (internal) unit for margin (default? 'px') set when `margin` is set as string with unit (ex: 2rem') */
100
+ marginUnit?: string;
101
+ /** maximum rows amount. Default? is 0 which means no maximum rows */
102
+ maxRow?: number;
103
+ /** minimum rows amount. Default is `0`. You can also do this with `min-height` CSS attribute
104
+ * on the grid div in pixels, which will round to the closest row.
105
+ */
106
+ minRow?: number;
107
+ /** minimal width. If grid width is less, grid will be shown in one column mode (default?: 768) */
108
+ minWidth?: number;
109
+ /**
110
+ * set to true if you want oneColumnMode to use the DOM order and ignore x,y from normal multi column
111
+ * layouts during sorting. This enables you to have custom 1 column layout that differ from the rest. (default?: false)
112
+ */
113
+ oneColumnModeDomSort?: boolean;
114
+ /** class for placeholder (default?: 'grid-stack-placeholder') */
115
+ placeholderClass?: string;
116
+ /** placeholder default content (default?: '') */
117
+ placeholderText?: string;
118
+ /** allows to override UI resizable options. (default?: { autoHide: true, handles: 'se' }) */
119
+ resizable?: DDResizeOpt;
120
+ /**
121
+ * if true widgets could be removed by dragging outside of the grid. It could also be a selector string (ex: ".trash"),
122
+ * in this case widgets will be removed by dropping them there (default?: false)
123
+ * See example (http://gridstack.github.io/gridstack.js/demo/two.html)
124
+ */
125
+ removable?: boolean | string;
126
+ /** allows to override UI removable options. (default?: { accept: '.grid-stack-item' }) */
127
+ removableOptions?: DDRemoveOpt;
128
+ /** fix grid number of rows. This is a shortcut of writing `minRow:N, maxRow:N`. (default `0` no constrain) */
129
+ row?: number;
130
+ /**
131
+ * if true turns grid to RTL. Possible values are true, false, 'auto' (default?: 'auto')
132
+ * See [example](http://gridstack.github.io/gridstack.js/demo/rtl.html)
133
+ */
134
+ rtl?: boolean | 'auto';
135
+ /**
136
+ * makes grid static (default?: false). If `true` widgets are not movable/resizable.
137
+ * You don't even need draggable/resizable. A CSS class
138
+ * 'grid-stack-static' is also added to the element.
139
+ */
140
+ staticGrid?: boolean;
141
+ /** if `true` will add style element to `<head>` otherwise will add it to element's parent node (default `false`). */
142
+ styleInHead?: boolean;
143
+ }
144
+ /** options used during GridStackEngine.moveNode() */
145
+ export interface GridStackMoveOpts extends GridStackPosition {
146
+ /** node to skip collision */
147
+ skip?: GridStackNode;
148
+ /** do we pack (default true) */
149
+ pack?: boolean;
150
+ /** true if we are calling this recursively to prevent simple swap or coverage collision - default false*/
151
+ nested?: boolean;
152
+ /** vars to calculate other cells coordinates */
153
+ cellWidth?: number;
154
+ cellHeight?: number;
155
+ marginTop?: number;
156
+ marginBottom?: number;
157
+ marginLeft?: number;
158
+ marginRight?: number;
159
+ /** position in pixels of the currently dragged items (for overlap check) */
160
+ rect?: GridStackPosition;
161
+ /** true if we're live resizing */
162
+ resizing?: boolean;
163
+ }
164
+ export interface GridStackPosition {
165
+ /** widget position x (default?: 0) */
166
+ x?: number;
167
+ /** widget position y (default?: 0) */
168
+ y?: number;
169
+ /** widget dimension width (default?: 1) */
170
+ w?: number;
171
+ /** widget dimension height (default?: 1) */
172
+ h?: number;
173
+ }
174
+ /**
175
+ * GridStack Widget creation options
176
+ */
177
+ export interface GridStackWidget extends GridStackPosition {
178
+ /** if true then x, y parameters will be ignored and widget will be places on the first available position (default?: false) */
179
+ autoPosition?: boolean;
180
+ /** minimum width allowed during resize/creation (default?: undefined = un-constrained) */
181
+ minW?: number;
182
+ /** maximum width allowed during resize/creation (default?: undefined = un-constrained) */
183
+ maxW?: number;
184
+ /** minimum height allowed during resize/creation (default?: undefined = un-constrained) */
185
+ minH?: number;
186
+ /** maximum height allowed during resize/creation (default?: undefined = un-constrained) */
187
+ maxH?: number;
188
+ /** prevent resizing (default?: undefined = un-constrained) */
189
+ noResize?: boolean;
190
+ /** prevents moving (default?: undefined = un-constrained) */
191
+ noMove?: boolean;
192
+ /** prevents being moved by others during their (default?: undefined = un-constrained) */
193
+ locked?: boolean;
194
+ /** widgets can have their own custom resize handles. For example 'e,w' will make that particular widget only resize east and west. See `resizable: {handles: string}` option */
195
+ resizeHandles?: string;
196
+ /** value for `gs-id` stored on the widget (default?: undefined) */
197
+ id?: numberOrString;
198
+ /** html to append inside as content */
199
+ content?: string;
200
+ /** optional nested grid options and list of children, which then turns into actual instance at runtime */
201
+ subGrid?: GridStackOptions | GridStack;
202
+ }
203
+ /** Drag&Drop resize options */
204
+ export interface DDResizeOpt {
205
+ /** do resize handle hide by default until mouse over ? - default: true */
206
+ autoHide?: boolean;
207
+ /**
208
+ * sides where you can resize from (ex: 'e, se, s, sw, w') - default 'se' (south-east)
209
+ * Note: it is not recommended to resize from the top sides as weird side effect may occur.
210
+ */
211
+ handles?: string;
212
+ }
213
+ /** Drag&Drop remove options */
214
+ export interface DDRemoveOpt {
215
+ /** class that can be removed (default?: '.' + opts.itemClass) */
216
+ accept?: string;
217
+ }
218
+ /** Drag&Drop dragging options */
219
+ export interface DDDragOpt {
220
+ /** class selector of items that can be dragged. default to '.grid-stack-item-content' */
221
+ handle?: string;
222
+ /** default to `true` */
223
+ scroll?: boolean;
224
+ /** default to 'body' */
225
+ appendTo?: string;
226
+ /** parent constraining where item can be dragged out from (default: null = no constrain) */
227
+ containment?: string;
228
+ }
229
+ export interface DDDragInOpt extends DDDragOpt {
230
+ /** used when dragging item from the outside, and canceling (ex: 'invalid' or your own method)*/
231
+ revert?: string | ((event: Event) => HTMLElement);
232
+ /** helper function when dropping (ex: 'clone' or your own method) */
233
+ helper?: string | ((event: Event) => HTMLElement);
234
+ }
235
+ export interface Size {
236
+ width: number;
237
+ height: number;
238
+ }
239
+ export interface Position {
240
+ top: number;
241
+ left: number;
242
+ }
243
+ export interface Rect extends Size, Position {
244
+ }
245
+ /** data that is passed during drag and resizing callbacks */
246
+ export interface DDUIData {
247
+ position?: Position;
248
+ size?: Size;
249
+ }
250
+ /**
251
+ * internal descriptions describing the items in the grid
252
+ */
253
+ export interface GridStackNode extends GridStackWidget {
254
+ /** pointer back to HTML element */
255
+ el?: GridItemHTMLElement;
256
+ /** pointer back to Grid instance */
257
+ grid?: GridStack;
258
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * types.ts 4.4.1
4
+ * Copyright (c) 2021 Alain Dumesny - see GridStack root license
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\r\n * types.ts 4.4.1\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridStack } from './gridstack';\r\n\r\n\r\n/** different layout options when changing # of columns,\r\n * including a custom function that takes new/old column count, and array of new/old positions\r\n * Note: new list may be partially already filled if we have a cache of the layout at that size and new items were added later.\r\n */\r\nexport type ColumnOptions = 'moveScale' | 'move' | 'scale' | 'none' |\r\n ((column: number, oldColumn: number, nodes: GridStackNode[], oldNodes: GridStackNode[]) => void);\r\n\r\nexport type numberOrString = number | string;\r\nexport interface GridItemHTMLElement extends HTMLElement {\r\n /** pointer to grid node instance */\r\n gridstackNode?: GridStackNode;\r\n /** @internal */\r\n _gridstackNodeOrig?: GridStackNode;\r\n}\r\n\r\nexport type GridStackElement = string | HTMLElement | GridItemHTMLElement;\r\n\r\nexport type GridStackEventHandlerCallback = (event: Event, arg2?: GridItemHTMLElement | GridStackNode | GridStackNode[], newNode?: GridStackNode) => void;\r\n\r\n/**\r\n * Defines the options for a Grid\r\n */\r\nexport interface GridStackOptions {\r\n /**\r\n * accept widgets dragged from other grids or from outside (default: `false`). Can be:\r\n * `true` (uses `'.grid-stack-item'` class filter) or `false`,\r\n * string for explicit class name,\r\n * function returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)\r\n */\r\n acceptWidgets?: boolean | string | ((element: Element) => boolean);\r\n\r\n /** possible values (default: `false` only show on hover)\r\n * `true` the resizing handles are always shown even if the user is not hovering over the widget\r\n * advance condition such as this mobile browser agent check:\r\n `alwaysShowResizeHandle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent )`\r\n See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html) */\r\n alwaysShowResizeHandle?: boolean;\r\n\r\n /** turns animation on (default?: true) */\r\n animate?: boolean;\r\n\r\n /** if false gridstack will not initialize existing items (default?: true) */\r\n auto?: boolean;\r\n\r\n /**\r\n * one cell height (default?: 'auto'). Can be:\r\n * an integer (px)\r\n * a string (ex: '100px', '10em', '10rem'). Note: % doesn't right - see demo/cell-height.html\r\n * 0, in which case the library will not generate styles for rows. Everything must be defined in your own CSS files.\r\n * 'auto' - height will be calculated for square cells (width / column) and updated live as you resize the window - also see `cellHeightThrottle`\r\n * 'initial' - similar to 'auto' (start at square cells) but stay that size during window resizing.\r\n */\r\n cellHeight?: numberOrString;\r\n\r\n /** throttle time delay (in ms) used when cellHeight='auto' to improve performance vs usability (default?: 100).\r\n * A value of 0 will make it instant at a cost of re-creating the CSS file at ever window resize event!\r\n * */\r\n cellHeightThrottle?: number;\r\n\r\n /** (internal) unit for cellHeight (default? 'px') which is set when a string cellHeight with a unit is passed (ex: '10rem') */\r\n cellHeightUnit?: string;\r\n\r\n /** list of children item to create when calling load() or addGrid() */\r\n children?: GridStackWidget[];\r\n\r\n /** number of columns (default?: 12). Note: IF you change this, CSS also have to change. See https://github.com/gridstack/gridstack.js#change-grid-columns */\r\n column?: number;\r\n\r\n /** additional class on top of '.grid-stack' (which is required for our CSS) to differentiate this instance.\r\n Note: only used by addGrid(), else your element should have the needed class */\r\n class?: string;\r\n\r\n /** disallows dragging of widgets (default?: false) */\r\n disableDrag?: boolean;\r\n\r\n /** disables the onColumnMode when the grid width is less than minWidth (default?: false) */\r\n disableOneColumnMode?: boolean;\r\n\r\n /** disallows resizing of widgets (default?: false). */\r\n disableResize?: boolean;\r\n\r\n /** allows to override UI draggable options. (default?: { handle?: '.grid-stack-item-content', scroll?: true, appendTo?: 'body', containment: null }) */\r\n draggable?: DDDragOpt;\r\n\r\n /** allows to drag external items using this selector - see dragInOptions. (default: undefined) */\r\n dragIn?: string;\r\n\r\n /** allows to drag external items using these options. See `GridStack.setupDragIn()` instead (not per grid really).\r\n * (default?: { handle: '.grid-stack-item-content', revert: 'invalid', scroll: false, appendTo: 'body' })\r\n * helper can be 'clone' or your own function (set what the drag/dropped item will be instead)\r\n */\r\n dragInOptions?: DDDragInOpt;\r\n\r\n /** let user drag nested grid items out of a parent or not (default false) */\r\n dragOut?: boolean;\r\n\r\n /** enable floating widgets (default?: false) See example (http://gridstack.github.io/gridstack.js/demo/float.html) */\r\n float?: boolean;\r\n\r\n /** draggable handle selector (default?: '.grid-stack-item-content') */\r\n handle?: string;\r\n\r\n /** draggable handle class (e.g. 'grid-stack-item-content'). If set 'handle' is ignored (default?: null) */\r\n handleClass?: string;\r\n\r\n /** additional widget class (default?: 'grid-stack-item') */\r\n itemClass?: string;\r\n\r\n /**\r\n * gap between grid item and content (default?: 10). This will set all 4 sides and support the CSS formats below\r\n * an integer (px)\r\n * a string with possible units (ex: '2em', '20px', '2rem')\r\n * string with space separated values (ex: '5px 10px 0 20px' for all 4 sides, or '5em 10em' for top/bottom and left/right pairs like CSS).\r\n * Note: all sides must have same units (last one wins, default px)\r\n */\r\n margin?: numberOrString;\r\n\r\n /** OLD way to optionally set each side - use margin: '5px 10px 0 20px' instead. Used internally to store each side. */\r\n marginTop?: numberOrString;\r\n marginRight?: numberOrString;\r\n marginBottom?: numberOrString;\r\n marginLeft?: numberOrString;\r\n\r\n /** (internal) unit for margin (default? 'px') set when `margin` is set as string with unit (ex: 2rem') */\r\n marginUnit?: string;\r\n\r\n /** maximum rows amount. Default? is 0 which means no maximum rows */\r\n maxRow?: number;\r\n\r\n /** minimum rows amount. Default is `0`. You can also do this with `min-height` CSS attribute\r\n * on the grid div in pixels, which will round to the closest row.\r\n */\r\n minRow?: number;\r\n\r\n /** minimal width. If grid width is less, grid will be shown in one column mode (default?: 768) */\r\n minWidth?: number;\r\n\r\n /**\r\n * set to true if you want oneColumnMode to use the DOM order and ignore x,y from normal multi column\r\n * layouts during sorting. This enables you to have custom 1 column layout that differ from the rest. (default?: false)\r\n */\r\n oneColumnModeDomSort?: boolean;\r\n\r\n /** class for placeholder (default?: 'grid-stack-placeholder') */\r\n placeholderClass?: string;\r\n\r\n /** placeholder default content (default?: '') */\r\n placeholderText?: string;\r\n\r\n /** allows to override UI resizable options. (default?: { autoHide: true, handles: 'se' }) */\r\n resizable?: DDResizeOpt;\r\n\r\n /**\r\n * if true widgets could be removed by dragging outside of the grid. It could also be a selector string (ex: \".trash\"),\r\n * in this case widgets will be removed by dropping them there (default?: false)\r\n * See example (http://gridstack.github.io/gridstack.js/demo/two.html)\r\n */\r\n removable?: boolean | string;\r\n\r\n /** allows to override UI removable options. (default?: { accept: '.grid-stack-item' }) */\r\n removableOptions?: DDRemoveOpt;\r\n\r\n /** fix grid number of rows. This is a shortcut of writing `minRow:N, maxRow:N`. (default `0` no constrain) */\r\n row?: number;\r\n\r\n /**\r\n * if true turns grid to RTL. Possible values are true, false, 'auto' (default?: 'auto')\r\n * See [example](http://gridstack.github.io/gridstack.js/demo/rtl.html)\r\n */\r\n rtl?: boolean | 'auto';\r\n\r\n /**\r\n * makes grid static (default?: false). If `true` widgets are not movable/resizable.\r\n * You don't even need draggable/resizable. A CSS class\r\n * 'grid-stack-static' is also added to the element.\r\n */\r\n staticGrid?: boolean;\r\n\r\n /** if `true` will add style element to `<head>` otherwise will add it to element's parent node (default `false`). */\r\n styleInHead?: boolean;\r\n\r\n /** @internal point to a parent grid item if we're nested */\r\n _isNested?: GridStackNode;\r\n /** @internal unique class name for our generated CSS style sheet */\r\n _styleSheetClass?: string;\r\n}\r\n\r\n/** options used during GridStackEngine.moveNode() */\r\nexport interface GridStackMoveOpts extends GridStackPosition {\r\n /** node to skip collision */\r\n skip?: GridStackNode;\r\n /** do we pack (default true) */\r\n pack?: boolean;\r\n /** true if we are calling this recursively to prevent simple swap or coverage collision - default false*/\r\n nested?: boolean;\r\n /** vars to calculate other cells coordinates */\r\n cellWidth?: number;\r\n cellHeight?: number;\r\n marginTop?: number;\r\n marginBottom?: number;\r\n marginLeft?: number;\r\n marginRight?: number;\r\n /** position in pixels of the currently dragged items (for overlap check) */\r\n rect?: GridStackPosition;\r\n /** true if we're live resizing */\r\n resizing?: boolean;\r\n}\r\n\r\nexport interface GridStackPosition {\r\n /** widget position x (default?: 0) */\r\n x?: number;\r\n /** widget position y (default?: 0) */\r\n y?: number;\r\n /** widget dimension width (default?: 1) */\r\n w?: number;\r\n /** widget dimension height (default?: 1) */\r\n h?: number;\r\n}\r\n\r\n/**\r\n * GridStack Widget creation options\r\n */\r\nexport interface GridStackWidget extends GridStackPosition {\r\n /** if true then x, y parameters will be ignored and widget will be places on the first available position (default?: false) */\r\n autoPosition?: boolean;\r\n /** minimum width allowed during resize/creation (default?: undefined = un-constrained) */\r\n minW?: number;\r\n /** maximum width allowed during resize/creation (default?: undefined = un-constrained) */\r\n maxW?: number;\r\n /** minimum height allowed during resize/creation (default?: undefined = un-constrained) */\r\n minH?: number;\r\n /** maximum height allowed during resize/creation (default?: undefined = un-constrained) */\r\n maxH?: number;\r\n /** prevent resizing (default?: undefined = un-constrained) */\r\n noResize?: boolean;\r\n /** prevents moving (default?: undefined = un-constrained) */\r\n noMove?: boolean;\r\n /** prevents being moved by others during their (default?: undefined = un-constrained) */\r\n locked?: boolean;\r\n /** widgets can have their own custom resize handles. For example 'e,w' will make that particular widget only resize east and west. See `resizable: {handles: string}` option */\r\n resizeHandles?: string;\r\n /** value for `gs-id` stored on the widget (default?: undefined) */\r\n id?: numberOrString;\r\n /** html to append inside as content */\r\n content?: string;\r\n /** optional nested grid options and list of children, which then turns into actual instance at runtime */\r\n subGrid?: GridStackOptions | GridStack;\r\n}\r\n\r\n/** Drag&Drop resize options */\r\nexport interface DDResizeOpt {\r\n /** do resize handle hide by default until mouse over ? - default: true */\r\n autoHide?: boolean;\r\n /**\r\n * sides where you can resize from (ex: 'e, se, s, sw, w') - default 'se' (south-east)\r\n * Note: it is not recommended to resize from the top sides as weird side effect may occur.\r\n */\r\n handles?: string;\r\n}\r\n\r\n/** Drag&Drop remove options */\r\nexport interface DDRemoveOpt {\r\n /** class that can be removed (default?: '.' + opts.itemClass) */\r\n accept?: string;\r\n}\r\n\r\n/** Drag&Drop dragging options */\r\nexport interface DDDragOpt {\r\n /** class selector of items that can be dragged. default to '.grid-stack-item-content' */\r\n handle?: string;\r\n /** default to `true` */\r\n scroll?: boolean;\r\n /** default to 'body' */\r\n appendTo?: string;\r\n /** parent constraining where item can be dragged out from (default: null = no constrain) */\r\n containment?: string;\r\n}\r\nexport interface DDDragInOpt extends DDDragOpt {\r\n /** used when dragging item from the outside, and canceling (ex: 'invalid' or your own method)*/\r\n revert?: string | ((event: Event) => HTMLElement);\r\n /** helper function when dropping (ex: 'clone' or your own method) */\r\n helper?: string | ((event: Event) => HTMLElement);\r\n}\r\n\r\nexport interface Size {\r\n width: number;\r\n height: number;\r\n}\r\nexport interface Position {\r\n top: number;\r\n left: number;\r\n}\r\nexport interface Rect extends Size, Position {}\r\n\r\n/** data that is passed during drag and resizing callbacks */\r\nexport interface DDUIData {\r\n position?: Position;\r\n size?: Size;\r\n /* fields not used by GridStack but sent by jq ? leave in case we go back to them...\r\n originalPosition? : Position;\r\n offset?: Position;\r\n originalSize?: Size;\r\n element?: HTMLElement[];\r\n helper?: HTMLElement[];\r\n originalElement?: HTMLElement[];\r\n */\r\n}\r\n\r\n/**\r\n * internal descriptions describing the items in the grid\r\n */\r\nexport interface GridStackNode extends GridStackWidget {\r\n /** pointer back to HTML element */\r\n el?: GridItemHTMLElement;\r\n /** pointer back to Grid instance */\r\n grid?: GridStack;\r\n /** @internal internal id used to match when cloning engines or saving column layouts */\r\n _id?: number;\r\n /** @internal */\r\n _dirty?: boolean;\r\n /** @internal */\r\n _updating?: boolean;\r\n /** @internal true when over trash/another grid so we don't bother removing drag CSS style that would animate back to old position */\r\n _isAboutToRemove?: boolean;\r\n /** @internal true if item came from outside of the grid -> actual item need to be moved over */\r\n _isExternal?: boolean;\r\n /** @internal moving vs resizing */\r\n _moving?: boolean;\r\n /** @internal true if we jumped down past item below (one time jump so we don't have to totally pass it) */\r\n _skipDown?: boolean;\r\n /** @internal original values before a drag/size */\r\n _orig?: GridStackPosition;\r\n /** @internal position in pixels used during collision check */\r\n _rect?: GridStackPosition;\r\n /** @internal top/left pixel location before a drag so we can detect direction of move from last position*/\r\n _lastUiPosition?: Position;\r\n /** @internal set on the item being dragged/resized remember the last positions we've tried (but failed) so we don't try again during drag/resize */\r\n _lastTried?: GridStackPosition;\r\n /** @internal position willItFit() will use to position the item */\r\n _willFitPos?: GridStackPosition;\r\n /** @internal last drag Y pixel position used to incrementally update V scroll bar */\r\n _prevYPix?: number;\r\n /** @internal true if we've remove the item from ourself (dragging out) but might revert it back (release on nothing -> goes back) */\r\n _temporaryRemoved?: boolean;\r\n /** @internal true if we should remove DOM element on _notify() rather than clearing _id (old way) */\r\n _removeDOM?: boolean;\r\n /** @internal */\r\n _initDD?: boolean;\r\n}\r\n"]}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * utils.ts 4.4.1
3
+ * Copyright (c) 2021 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition, GridStackWidget } from './types';
6
+ export interface HeightData {
7
+ h: number;
8
+ unit: string;
9
+ }
10
+ /** checks for obsolete method names */
11
+ export declare function obsolete(self: any, f: any, oldName: string, newName: string, rev: string): (...args: any[]) => any;
12
+ /** checks for obsolete grid options (can be used for any fields, but msg is about options) */
13
+ export declare function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: string, rev: string): void;
14
+ /** checks for obsolete grid options which are gone */
15
+ export declare function obsoleteOptsDel(opts: GridStackOptions, oldName: string, rev: string, info: string): void;
16
+ /** checks for obsolete Jquery element attributes */
17
+ export declare function obsoleteAttr(el: HTMLElement, oldName: string, newName: string, rev: string): void;
18
+ /**
19
+ * Utility methods
20
+ */
21
+ export declare class Utils {
22
+ /** convert a potential selector into actual list of html elements */
23
+ static getElements(els: GridStackElement): HTMLElement[];
24
+ /** convert a potential selector into actual single element */
25
+ static getElement(els: GridStackElement): HTMLElement;
26
+ /** returns true if a and b overlap */
27
+ static isIntercepted(a: GridStackPosition, b: GridStackPosition): boolean;
28
+ /** returns true if a and b touch edges or corners */
29
+ static isTouching(a: GridStackPosition, b: GridStackPosition): boolean;
30
+ /**
31
+ * Sorts array of nodes
32
+ * @param nodes array to sort
33
+ * @param dir 1 for asc, -1 for desc (optional)
34
+ * @param width width of the grid. If undefined the width will be calculated automatically (optional).
35
+ **/
36
+ static sort(nodes: GridStackNode[], dir?: -1 | 1, column?: number): GridStackNode[];
37
+ /**
38
+ * creates a style sheet with style id under given parent
39
+ * @param id will set the 'gs-style-id' attribute to that id
40
+ * @param parent to insert the stylesheet as first child,
41
+ * if none supplied it will be appended to the document head instead.
42
+ */
43
+ static createStylesheet(id: string, parent?: HTMLElement): CSSStyleSheet;
44
+ /** removed the given stylesheet id */
45
+ static removeStylesheet(id: string): void;
46
+ /** inserts a CSS rule */
47
+ static addCSSRule(sheet: CSSStyleSheet, selector: string, rules: string): void;
48
+ static toBool(v: unknown): boolean;
49
+ static toNumber(value: null | string): number;
50
+ static parseHeight(val: numberOrString): HeightData;
51
+ /** copies unset fields in target to use the given default sources values */
52
+ static defaults(target: any, ...sources: any[]): {};
53
+ /** given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) */
54
+ static same(a: unknown, b: unknown): boolean;
55
+ /** copies over b size & position (GridStackPosition), and possibly min/max as well */
56
+ static copyPos(a: GridStackWidget, b: GridStackWidget, minMax?: boolean): GridStackWidget;
57
+ /** true if a and b has same size & position */
58
+ static samePos(a: GridStackPosition, b: GridStackPosition): boolean;
59
+ /** removes field from the first object if same as the second objects (like diffing) and internal '_' for saving */
60
+ static removeInternalAndSame(a: unknown, b: unknown): void;
61
+ /** return the closest parent matching the given class */
62
+ static closestByClass(el: HTMLElement, name: string): HTMLElement;
63
+ /** delay calling the given function for given delay, preventing new calls from happening while waiting */
64
+ static throttle(func: () => void, delay: number): () => void;
65
+ static removePositioningStyles(el: HTMLElement): void;
66
+ /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */
67
+ static clone<T>(obj: T): T;
68
+ /**
69
+ * Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY.
70
+ * Note: this will use as-is any key starting with double __ (and not copy inside) some lib have circular dependencies.
71
+ */
72
+ static cloneDeep<T>(obj: T): T;
73
+ }