gridstack 12.2.2 → 12.3.0

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 (71) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -3
  3. package/dist/angular/README.md +2 -0
  4. package/dist/angular/esm2020/lib/base-widget.mjs +63 -7
  5. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +33 -4
  6. package/dist/angular/esm2020/lib/gridstack.component.mjs +97 -16
  7. package/dist/angular/esm2020/lib/gridstack.module.mjs +25 -3
  8. package/dist/angular/esm2020/lib/types.mjs +2 -2
  9. package/dist/angular/fesm2015/gridstack-angular.mjs +191 -25
  10. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  11. package/dist/angular/fesm2020/gridstack-angular.mjs +192 -26
  12. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  13. package/dist/angular/lib/base-widget.d.ts +42 -5
  14. package/dist/angular/lib/gridstack-item.component.d.ts +49 -7
  15. package/dist/angular/lib/gridstack.component.d.ts +137 -22
  16. package/dist/angular/lib/gridstack.module.d.ts +23 -0
  17. package/dist/angular/lib/types.d.ts +32 -5
  18. package/dist/angular/package.json +1 -1
  19. package/dist/angular/src/base-widget.ts +68 -9
  20. package/dist/angular/src/gridstack-item.component.ts +49 -7
  21. package/dist/angular/src/gridstack.component.ts +154 -23
  22. package/dist/angular/src/gridstack.module.ts +24 -2
  23. package/dist/angular/src/types.ts +54 -0
  24. package/dist/dd-base-impl.d.ts +52 -3
  25. package/dist/dd-base-impl.js +41 -3
  26. package/dist/dd-base-impl.js.map +1 -1
  27. package/dist/dd-draggable.d.ts +2 -2
  28. package/dist/dd-draggable.js +4 -2
  29. package/dist/dd-draggable.js.map +1 -1
  30. package/dist/dd-droppable.d.ts +2 -2
  31. package/dist/dd-droppable.js +2 -2
  32. package/dist/dd-droppable.js.map +1 -1
  33. package/dist/dd-element.d.ts +2 -2
  34. package/dist/dd-element.js +2 -2
  35. package/dist/dd-element.js.map +1 -1
  36. package/dist/dd-gridstack.d.ts +54 -6
  37. package/dist/dd-gridstack.js +32 -2
  38. package/dist/dd-gridstack.js.map +1 -1
  39. package/dist/dd-manager.d.ts +29 -8
  40. package/dist/dd-manager.js +7 -3
  41. package/dist/dd-manager.js.map +1 -1
  42. package/dist/dd-resizable-handle.d.ts +2 -2
  43. package/dist/dd-resizable-handle.js +2 -2
  44. package/dist/dd-resizable-handle.js.map +1 -1
  45. package/dist/dd-resizable.d.ts +2 -2
  46. package/dist/dd-resizable.js +2 -2
  47. package/dist/dd-resizable.js.map +1 -1
  48. package/dist/dd-touch.d.ts +2 -2
  49. package/dist/dd-touch.js +2 -2
  50. package/dist/dd-touch.js.map +1 -1
  51. package/dist/gridstack-all.js +1 -1
  52. package/dist/gridstack-all.js.LICENSE.txt +2 -2
  53. package/dist/gridstack-all.js.map +1 -1
  54. package/dist/gridstack-engine.d.ts +235 -26
  55. package/dist/gridstack-engine.js +275 -29
  56. package/dist/gridstack-engine.js.map +1 -1
  57. package/dist/gridstack.css +2 -2
  58. package/dist/gridstack.d.ts +424 -82
  59. package/dist/gridstack.js +408 -76
  60. package/dist/gridstack.js.map +1 -1
  61. package/dist/src/gridstack.scss +2 -2
  62. package/dist/types.d.ts +130 -29
  63. package/dist/types.js +6 -3
  64. package/dist/types.js.map +1 -1
  65. package/dist/utils.d.ts +208 -29
  66. package/dist/utils.js +275 -61
  67. package/dist/utils.js.map +1 -1
  68. package/doc/API.md +6192 -0
  69. package/package.json +14 -3
  70. package/doc/CHANGES.md +0 -962
  71. package/doc/README.md +0 -642
@@ -1,6 +1,6 @@
1
1
  /**
2
- * gridstack SASS styles 12.2.2
3
- * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
2
+ * gridstack SASS styles 12.3.0
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
4
  */
5
5
 
6
6
  $animation_speed: .3s !default;
package/dist/types.d.ts CHANGED
@@ -1,42 +1,108 @@
1
1
  /**
2
- * types.ts 12.2.2
3
- * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
2
+ * types.ts 12.3.0
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  import { GridStack } from './gridstack';
6
6
  import { GridStackEngine } from './gridstack-engine';
7
+ /**
8
+ * Default values for grid options - used during initialization and when saving out grid configuration.
9
+ * These values are applied when options are not explicitly provided.
10
+ */
7
11
  export declare const gridDefaults: GridStackOptions;
8
12
  /**
9
- * different layout options when changing # of columns, including a custom function that takes new/old column count, and array of new/old positions
10
- * 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.
11
- * Options are:
12
- * 'list' - treat items as sorted list, keeping items (un-sized unless too big for column count) sequentially reflowing them
13
- * 'compact' - similar to list, but using compact() method which will possibly re-order items if an empty slots are available due to a larger item needing to be pushed to next row
14
- * 'moveScale' - will scale and move items by the ratio new newColumnCount / oldColumnCount
15
- * 'move' | 'scale' - will only size or move items
16
- * 'none' will leave items unchanged, unless they don't fit in column count
13
+ * Different layout options when changing the number of columns.
14
+ *
15
+ * These options control how widgets are repositioned when the grid column count changes.
16
+ * Note: The new list may be partially filled if there's a cached layout for that size.
17
+ *
18
+ * Options:
19
+ * - `'list'`: Treat items as a sorted list, keeping them sequentially without resizing (unless too big)
20
+ * - `'compact'`: Similar to list, but uses compact() method to fill empty slots by reordering
21
+ * - `'moveScale'`: Scale and move items by the ratio of newColumnCount / oldColumnCount
22
+ * - `'move'`: Only move items, keep their sizes
23
+ * - `'scale'`: Only scale items, keep their positions
24
+ * - `'none'`: Leave items unchanged unless they don't fit in the new column count
25
+ * - Custom function: Provide your own layout logic
17
26
  */
18
27
  export type ColumnOptions = 'list' | 'compact' | 'moveScale' | 'move' | 'scale' | 'none' | ((column: number, oldColumn: number, nodes: GridStackNode[], oldNodes: GridStackNode[]) => void);
28
+ /**
29
+ * Options for the compact() method to reclaim empty space.
30
+ * - `'list'`: Keep items in order, move them up sequentially
31
+ * - `'compact'`: Find truly empty spaces, may reorder items for optimal fit
32
+ */
19
33
  export type CompactOptions = 'list' | 'compact';
34
+ /**
35
+ * Type representing values that can be either numbers or strings (e.g., dimensions with units).
36
+ * Used for properties like width, height, margins that accept both numeric and string values.
37
+ */
20
38
  export type numberOrString = number | string;
39
+ /**
40
+ * Extended HTMLElement interface for grid items.
41
+ * All grid item DOM elements implement this interface to provide access to their grid data.
42
+ */
21
43
  export interface GridItemHTMLElement extends HTMLElement {
22
- /** pointer to grid node instance */
44
+ /** Pointer to the associated grid node instance containing position, size, and other widget data */
23
45
  gridstackNode?: GridStackNode;
24
46
  }
47
+ /**
48
+ * Type representing various ways to specify grid elements.
49
+ * Can be a CSS selector string, HTMLElement, or GridItemHTMLElement.
50
+ */
25
51
  export type GridStackElement = string | HTMLElement | GridItemHTMLElement;
26
- /** specific and general event handlers for the .on() method */
52
+ /**
53
+ * Event handler function types for the .on() method.
54
+ * Different handlers receive different parameters based on the event type.
55
+ */
56
+ /** General event handler that receives only the event */
27
57
  export type GridStackEventHandler = (event: Event) => void;
58
+ /** Element-specific event handler that receives event and affected element */
28
59
  export type GridStackElementHandler = (event: Event, el: GridItemHTMLElement) => void;
60
+ /** Node-based event handler that receives event and array of affected nodes */
29
61
  export type GridStackNodesHandler = (event: Event, nodes: GridStackNode[]) => void;
62
+ /** Drop event handler that receives previous and new node states */
30
63
  export type GridStackDroppedHandler = (event: Event, previousNode: GridStackNode, newNode: GridStackNode) => void;
64
+ /** Union type of all possible event handler types */
31
65
  export type GridStackEventHandlerCallback = GridStackEventHandler | GridStackElementHandler | GridStackNodesHandler | GridStackDroppedHandler;
32
- /** optional function called during load() to callback the user on new added/remove grid items | grids */
66
+ /**
67
+ * Optional callback function called during load() operations.
68
+ * Allows custom handling of widget addition/removal for framework integration.
69
+ *
70
+ * @param parent - The parent HTML element
71
+ * @param w - The widget definition
72
+ * @param add - True if adding, false if removing
73
+ * @param grid - True if this is a grid operation
74
+ * @returns The created/modified HTML element, or undefined
75
+ */
33
76
  export type AddRemoveFcn = (parent: HTMLElement, w: GridStackWidget, add: boolean, grid: boolean) => HTMLElement | undefined;
34
- /** optional function called during save() to let the caller add additional custom data to the GridStackWidget structure that will get returned */
77
+ /**
78
+ * Optional callback function called during save() operations.
79
+ * Allows adding custom data to the saved widget structure.
80
+ *
81
+ * @param node - The internal grid node
82
+ * @param w - The widget structure being saved (can be modified)
83
+ */
35
84
  export type SaveFcn = (node: GridStackNode, w: GridStackWidget) => void;
36
- /** optional function called during load()/addWidget() to let the caller create custom content other than plan text */
85
+ /**
86
+ * Optional callback function for custom widget content rendering.
87
+ * Called during load()/addWidget() to create custom content beyond plain text.
88
+ *
89
+ * @param el - The widget's content container element
90
+ * @param w - The widget definition with content and other properties
91
+ */
37
92
  export type RenderFcn = (el: HTMLElement, w: GridStackWidget) => void;
93
+ /**
94
+ * Optional callback function for custom resize-to-content behavior.
95
+ * Called when a widget needs to resize to fit its content.
96
+ *
97
+ * @param el - The grid item element to resize
98
+ */
38
99
  export type ResizeToContentFcn = (el: GridItemHTMLElement) => void;
39
- /** describes the responsive nature of the grid. NOTE: make sure to have correct extra CSS to support this. */
100
+ /**
101
+ * Configuration for responsive grid behavior.
102
+ *
103
+ * Defines how the grid responds to different screen sizes by changing column counts.
104
+ * NOTE: Make sure to include the appropriate CSS (gridstack-extra.css) to support responsive behavior.
105
+ */
40
106
  export interface Responsive {
41
107
  /** wanted width to maintain (+-50%) to dynamically pick a column count. NOTE: make sure to have correct extra CSS to support this. */
42
108
  columnWidth?: number;
@@ -49,12 +115,16 @@ export interface Responsive {
49
115
  /** global re-layout mode when changing columns */
50
116
  layout?: ColumnOptions;
51
117
  }
118
+ /**
119
+ * Defines a responsive breakpoint for automatic column count changes.
120
+ * Used with the responsive.breakpoints option.
121
+ */
52
122
  export interface Breakpoint {
53
- /** <= width for the breakpoint to trigger */
123
+ /** Maximum width (in pixels) for this breakpoint to be active */
54
124
  w?: number;
55
- /** column count */
125
+ /** Number of columns to use when this breakpoint is active */
56
126
  c: number;
57
- /** re-layout mode if different from global one */
127
+ /** Layout mode for this specific breakpoint (overrides global responsive.layout) */
58
128
  layout?: ColumnOptions;
59
129
  }
60
130
  /**
@@ -62,10 +132,25 @@ export interface Breakpoint {
62
132
  */
63
133
  export interface GridStackOptions {
64
134
  /**
65
- * accept widgets dragged from other grids or from outside (default: `false`). Can be:
66
- * `true` (uses `'.grid-stack-item'` class filter) or `false`,
67
- * string for explicit class name,
68
- * function returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
135
+ * Accept widgets dragged from other grids or from outside (default: `false`). Can be:
136
+ * - `true`: will accept HTML elements having 'grid-stack-item' as class attribute
137
+ * - `false`: will not accept any external widgets
138
+ * - string: explicit class name to accept instead of default
139
+ * - function: callback called before an item will be accepted when entering a grid
140
+ *
141
+ * @example
142
+ * // Accept all grid items
143
+ * acceptWidgets: true
144
+ *
145
+ * // Accept only items with specific class
146
+ * acceptWidgets: 'my-draggable-item'
147
+ *
148
+ * // Custom validation function
149
+ * acceptWidgets: (el) => {
150
+ * return el.getAttribute('data-accept') === 'true';
151
+ * }
152
+ *
153
+ * @see {@link http://gridstack.github.io/gridstack.js/demo/two.html} for complete example
69
154
  */
70
155
  acceptWidgets?: boolean | string | ((element: Element) => boolean);
71
156
  /** possible values (default: `mobile`) - does not apply to non-resizable widgets
@@ -79,12 +164,28 @@ export interface GridStackOptions {
79
164
  /** if false gridstack will not initialize existing items (default?: true) */
80
165
  auto?: boolean;
81
166
  /**
82
- * one cell height (default?: 'auto'). Can be:
83
- * an integer (px)
84
- * a string (ex: '100px', '10em', '10rem'). Note: % doesn't work right - see demo/cell-height.html
85
- * 0, in which case the library will not generate styles for rows. Everything must be defined in your own CSS files.
86
- * 'auto' - height will be calculated for square cells (width / column) and updated live as you resize the window - also see `cellHeightThrottle`
87
- * 'initial' - similar to 'auto' (start at square cells) but stay that size during window resizing.
167
+ * One cell height (default: 'auto'). Can be:
168
+ * - an integer (px): fixed pixel height
169
+ * - a string (ex: '100px', '10em', '10rem'): CSS length value
170
+ * - 0: library will not generate styles for rows (define your own CSS)
171
+ * - 'auto': height calculated for square cells (width / column) and updated live on window resize
172
+ * - 'initial': similar to 'auto' but stays fixed size during window resizing
173
+ *
174
+ * Note: % values don't work correctly - see demo/cell-height.html
175
+ *
176
+ * @example
177
+ * // Fixed 100px height
178
+ * cellHeight: 100
179
+ *
180
+ * // CSS units
181
+ * cellHeight: '5rem'
182
+ * cellHeight: '100px'
183
+ *
184
+ * // Auto-sizing for square cells
185
+ * cellHeight: 'auto'
186
+ *
187
+ * // No CSS generation (custom styles)
188
+ * cellHeight: 0
88
189
  */
89
190
  cellHeight?: numberOrString;
90
191
  /** throttle time delay (in ms) used when cellHeight='auto' to improve performance vs usability (default?: 100).
package/dist/types.js CHANGED
@@ -1,8 +1,11 @@
1
1
  /**
2
- * types.ts 12.2.2
3
- * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
2
+ * types.ts 12.3.0
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ /**
6
+ * Default values for grid options - used during initialization and when saving out grid configuration.
7
+ * These values are applied when options are not explicitly provided.
4
8
  */
5
- // default values for grid options - used during init and when saving out
6
9
  export const gridDefaults = {
7
10
  alwaysShowResizeHandle: 'mobile',
8
11
  animate: true,
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,yEAAyE;AACzE,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,sBAAsB,EAAE,QAAQ;IAChC,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,MAAM;IAClB,kBAAkB,EAAE,GAAG;IACvB,cAAc,EAAE,IAAI;IACpB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IACjF,MAAM,EAAE,0BAA0B;IAClC,SAAS,EAAE,iBAAiB;IAC5B,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,gBAAgB,EAAE,wBAAwB;IAC1C,eAAe,EAAE,EAAE;IACnB,gBAAgB,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,0BAA0B,EAAC;IACnF,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5B,GAAG,EAAE,MAAM;IAEX,kCAAkC;IAClC,sBAAsB;IACtB,wBAAwB;IACxB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,qBAAqB;IACrB,WAAW;CACZ,CAAC","sourcesContent":["/**\r\n * types.ts 12.2.2\r\n * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridStack } from './gridstack';\r\nimport { GridStackEngine } from './gridstack-engine';\r\n\r\n// default values for grid options - used during init and when saving out\r\nexport const gridDefaults: GridStackOptions = {\r\n alwaysShowResizeHandle: 'mobile',\r\n animate: true,\r\n auto: true,\r\n cellHeight: 'auto',\r\n cellHeightThrottle: 100,\r\n cellHeightUnit: 'px',\r\n column: 12,\r\n draggable: { handle: '.grid-stack-item-content', appendTo: 'body', scroll: true },\r\n handle: '.grid-stack-item-content',\r\n itemClass: 'grid-stack-item',\r\n margin: 10,\r\n marginUnit: 'px',\r\n maxRow: 0,\r\n minRow: 0,\r\n placeholderClass: 'grid-stack-placeholder',\r\n placeholderText: '',\r\n removableOptions: { accept: 'grid-stack-item', decline: 'grid-stack-non-removable'},\r\n resizable: { handles: 'se' },\r\n rtl: 'auto',\r\n\r\n // **** same as not being set ****\r\n // disableDrag: false,\r\n // disableResize: false,\r\n // float: false,\r\n // handleClass: null,\r\n // removable: false,\r\n // staticGrid: false,\r\n //removable\r\n};\r\n\r\n/**\r\n * different layout options when changing # of columns, 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 * Options are:\r\n * 'list' - treat items as sorted list, keeping items (un-sized unless too big for column count) sequentially reflowing them\r\n * 'compact' - similar to list, but using compact() method which will possibly re-order items if an empty slots are available due to a larger item needing to be pushed to next row\r\n * 'moveScale' - will scale and move items by the ratio new newColumnCount / oldColumnCount\r\n * 'move' | 'scale' - will only size or move items\r\n * 'none' will leave items unchanged, unless they don't fit in column count\r\n */\r\nexport type ColumnOptions = 'list' | 'compact' | 'moveScale' | 'move' | 'scale' | 'none' |\r\n ((column: number, oldColumn: number, nodes: GridStackNode[], oldNodes: GridStackNode[]) => void);\r\nexport type CompactOptions = 'list' | 'compact';\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\n/** specific and general event handlers for the .on() method */\r\nexport type GridStackEventHandler = (event: Event) => void;\r\nexport type GridStackElementHandler = (event: Event, el: GridItemHTMLElement) => void;\r\nexport type GridStackNodesHandler = (event: Event, nodes: GridStackNode[]) => void;\r\nexport type GridStackDroppedHandler = (event: Event, previousNode: GridStackNode, newNode: GridStackNode) => void;\r\nexport type GridStackEventHandlerCallback = GridStackEventHandler | GridStackElementHandler | GridStackNodesHandler | GridStackDroppedHandler;\r\n\r\n/** optional function called during load() to callback the user on new added/remove grid items | grids */\r\nexport type AddRemoveFcn = (parent: HTMLElement, w: GridStackWidget, add: boolean, grid: boolean) => HTMLElement | undefined;\r\n\r\n/** optional function called during save() to let the caller add additional custom data to the GridStackWidget structure that will get returned */\r\nexport type SaveFcn = (node: GridStackNode, w: GridStackWidget) => void;\r\n\r\n/** optional function called during load()/addWidget() to let the caller create custom content other than plan text */\r\nexport type RenderFcn = (el: HTMLElement, w: GridStackWidget) => void;\r\n\r\nexport type ResizeToContentFcn = (el: GridItemHTMLElement) => void;\r\n\r\n/** describes the responsive nature of the grid. NOTE: make sure to have correct extra CSS to support this. */\r\nexport interface Responsive {\r\n /** wanted width to maintain (+-50%) to dynamically pick a column count. NOTE: make sure to have correct extra CSS to support this. */\r\n columnWidth?: number;\r\n /** maximum number of columns allowed (default: 12). NOTE: make sure to have correct extra CSS to support this. */\r\n columnMax?: number;\r\n /** explicit width:column breakpoints instead of automatic 'columnWidth'. NOTE: make sure to have correct extra CSS to support this. */\r\n breakpoints?: Breakpoint[];\r\n /** specify if breakpoints are for window size or grid size (default:false = grid) */\r\n breakpointForWindow?: boolean;\r\n /** global re-layout mode when changing columns */\r\n layout?: ColumnOptions;\r\n}\r\n\r\nexport interface Breakpoint {\r\n /** <= width for the breakpoint to trigger */\r\n w?: number;\r\n /** column count */\r\n c: number;\r\n /** re-layout mode if different from global one */\r\n layout?: ColumnOptions;\r\n /** TODO: children layout, which spells out exact locations and could omit/add some children */\r\n // children?: GridStackWidget[];\r\n}\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: `mobile`) - does not apply to non-resizable widgets\r\n * `false` the resizing handles are only shown while hovering over a widget\r\n * `true` the resizing handles are always shown\r\n * 'mobile' if running on a mobile device, default to `true` (since there is no hovering per say), else `false`.\r\n See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html) */\r\n alwaysShowResizeHandle?: true | false | 'mobile';\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 work 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 * Note: for nested grids, it is recommended to use 'auto' which will always match the container grid-item current width (in column) to keep inside and outside\r\n * items always the same. flag is NOT supported for regular non-nested grids.\r\n */\r\n column?: number | 'auto';\r\n\r\n /** responsive column layout for width:column behavior */\r\n columnOpts?: Responsive;\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 /** 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', appendTo?: 'body' }) */\r\n draggable?: DDDragOpt;\r\n\r\n /** let user drag nested grid items out of a parent or not (default true - not supported yet) */\r\n //dragOut?: boolean;\r\n\r\n /** the type of engine to create (so you can subclass) default to GridStackEngine */\r\n engineClass?: typeof GridStackEngine;\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 /** re-layout mode when we're a subgrid and we are being resized. default to 'list' */\r\n layout?: ColumnOptions;\r\n\r\n /** true when widgets are only created when they scroll into view (visible) */\r\n lazyLoad?: boolean;\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 which is handy to prevent grid from collapsing when empty. Default is `0`.\r\n * When no set the `min-height` CSS attribute on the grid div (in pixels) can be used, which will round to the closest row.\r\n */\r\n minRow?: number;\r\n\r\n /** If you are using a nonce-based Content Security Policy, pass your nonce here and\r\n * GridStack will add it to the <style> elements it creates. */\r\n nonce?: string;\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?: { 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/right-to-left(rtl).html)\r\n */\r\n rtl?: boolean | 'auto';\r\n\r\n /** set to true if all grid items (by default, but item can also override) height should be based on content size instead of WidgetItem.h to avoid v-scrollbars.\r\n * Note: this is still row based, not pixels, so it will use ceil(getBoundingClientRect().height / getCellHeight())\r\n */\r\n sizeToContent?: boolean;\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 /**\r\n * @deprecated Not used anymore, styles are now implemented with local CSS variables\r\n */\r\n styleInHead?: boolean;\r\n\r\n /** list of differences in options for automatically created sub-grids under us (inside our grid-items) */\r\n subGridOpts?: GridStackOptions;\r\n\r\n /** enable/disable the creation of sub-grids on the fly by dragging items completely\r\n * over others (nest) vs partially (push). Forces `DDDragOpt.pause=true` to accomplish that. */\r\n subGridDynamic?: boolean;\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 /** best node (most coverage) we collied with */\r\n collide?: GridStackNode;\r\n /** for collision check even if we don't move */\r\n forceCollide?: 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 direct resizing by the user (default?: undefined = un-constrained) */\r\n noResize?: boolean;\r\n /** prevents direct moving by the user (default?: undefined = un-constrained) */\r\n noMove?: boolean;\r\n /** prevents being pushed by other widgets or api (default?: undefined = un-constrained), which is different from `noMove` (user action only) */\r\n locked?: boolean;\r\n /** value for `gs-id` stored on the widget (default?: undefined) */\r\n id?: string;\r\n /** html to append inside as content */\r\n content?: string;\r\n /** true when widgets are only created when they scroll into view (visible) */\r\n lazyLoad?: boolean;\r\n /** local (vs grid) override - see GridStackOptions.\r\n * Note: This also allow you to set a maximum h value (but user changeable during normal resizing) to prevent unlimited content from taking too much space (get scrollbar) */\r\n sizeToContent?: boolean | number;\r\n /** local override of GridStack.resizeToContentParent that specify the class to use for the parent (actual) vs child (wanted) height */\r\n resizeToContentParent?: string;\r\n /** optional nested grid options and list of children, which then turns into actual instance at runtime to get options from */\r\n subGridOpts?: GridStackOptions;\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 on desktop, false on mobile*/\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 /** class that cannot be removed (default: 'grid-stack-non-removable') */\r\n decline?: 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 'body' */\r\n appendTo?: string;\r\n /** if set (true | msec), dragging placement (collision) will only happen after a pause by the user. Note: this is Global */\r\n pause?: boolean | number;\r\n /** default to `true` */\r\n scroll?: boolean;\r\n /** prevents dragging from starting on specified elements, listed as comma separated selectors (eg: '.no-drag'). default built in is 'input,textarea,button,select,option' */\r\n cancel?: string;\r\n /** helper function when dropping: 'clone' or your own method */\r\n helper?: 'clone' | ((el: HTMLElement) => HTMLElement);\r\n /** callbacks */\r\n start?: (event: Event, ui: DDUIData) => void;\r\n stop?: (event: Event) => void;\r\n drag?: (event: Event, ui: DDUIData) => void;\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 draggable?: HTMLElement;\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 runtime descriptions describing the widgets 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 parent Grid instance */\r\n grid?: GridStack;\r\n /** actual sub-grid instance */\r\n subGrid?: GridStack;\r\n /** allow delay creation when visible */\r\n visibleObservable?: IntersectionObserver;\r\n /** @internal internal id used to match when cloning engines or saving column layouts */\r\n _id?: number;\r\n /** @internal does the node attr ned to be updated due to changed x,y,w,h values */\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 Mouse event that's causing moving|resizing */\r\n _event?: MouseEvent;\r\n /** @internal moving vs resizing */\r\n _moving?: boolean;\r\n /** @internal is resizing? */\r\n _resizing?: 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 original position/size of item if dragged from sidebar */\r\n _sidebarOrig?: GridStackPosition;\r\n /** @internal had drag&drop been initialized */\r\n _initDD?: boolean;\r\n}\r\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,sBAAsB,EAAE,QAAQ;IAChC,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,MAAM;IAClB,kBAAkB,EAAE,GAAG;IACvB,cAAc,EAAE,IAAI;IACpB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IACjF,MAAM,EAAE,0BAA0B;IAClC,SAAS,EAAE,iBAAiB;IAC5B,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,gBAAgB,EAAE,wBAAwB;IAC1C,eAAe,EAAE,EAAE;IACnB,gBAAgB,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,0BAA0B,EAAC;IACnF,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5B,GAAG,EAAE,MAAM;IAEX,kCAAkC;IAClC,sBAAsB;IACtB,wBAAwB;IACxB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,qBAAqB;IACrB,WAAW;CACZ,CAAC","sourcesContent":["/**\r\n * types.ts 12.3.0\r\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridStack } from './gridstack';\r\nimport { GridStackEngine } from './gridstack-engine';\r\n\r\n/**\r\n * Default values for grid options - used during initialization and when saving out grid configuration.\r\n * These values are applied when options are not explicitly provided.\r\n */\r\nexport const gridDefaults: GridStackOptions = {\r\n alwaysShowResizeHandle: 'mobile',\r\n animate: true,\r\n auto: true,\r\n cellHeight: 'auto',\r\n cellHeightThrottle: 100,\r\n cellHeightUnit: 'px',\r\n column: 12,\r\n draggable: { handle: '.grid-stack-item-content', appendTo: 'body', scroll: true },\r\n handle: '.grid-stack-item-content',\r\n itemClass: 'grid-stack-item',\r\n margin: 10,\r\n marginUnit: 'px',\r\n maxRow: 0,\r\n minRow: 0,\r\n placeholderClass: 'grid-stack-placeholder',\r\n placeholderText: '',\r\n removableOptions: { accept: 'grid-stack-item', decline: 'grid-stack-non-removable'},\r\n resizable: { handles: 'se' },\r\n rtl: 'auto',\r\n\r\n // **** same as not being set ****\r\n // disableDrag: false,\r\n // disableResize: false,\r\n // float: false,\r\n // handleClass: null,\r\n // removable: false,\r\n // staticGrid: false,\r\n //removable\r\n};\r\n\r\n/**\r\n * Different layout options when changing the number of columns.\r\n * \r\n * These options control how widgets are repositioned when the grid column count changes.\r\n * Note: The new list may be partially filled if there's a cached layout for that size.\r\n * \r\n * Options:\r\n * - `'list'`: Treat items as a sorted list, keeping them sequentially without resizing (unless too big)\r\n * - `'compact'`: Similar to list, but uses compact() method to fill empty slots by reordering\r\n * - `'moveScale'`: Scale and move items by the ratio of newColumnCount / oldColumnCount\r\n * - `'move'`: Only move items, keep their sizes\r\n * - `'scale'`: Only scale items, keep their positions\r\n * - `'none'`: Leave items unchanged unless they don't fit in the new column count\r\n * - Custom function: Provide your own layout logic\r\n */\r\nexport type ColumnOptions = 'list' | 'compact' | 'moveScale' | 'move' | 'scale' | 'none' |\r\n ((column: number, oldColumn: number, nodes: GridStackNode[], oldNodes: GridStackNode[]) => void);\r\n/**\r\n * Options for the compact() method to reclaim empty space.\r\n * - `'list'`: Keep items in order, move them up sequentially\r\n * - `'compact'`: Find truly empty spaces, may reorder items for optimal fit\r\n */\r\nexport type CompactOptions = 'list' | 'compact';\r\n/**\r\n * Type representing values that can be either numbers or strings (e.g., dimensions with units).\r\n * Used for properties like width, height, margins that accept both numeric and string values.\r\n */\r\nexport type numberOrString = number | string;\r\n/**\r\n * Extended HTMLElement interface for grid items.\r\n * All grid item DOM elements implement this interface to provide access to their grid data.\r\n */\r\nexport interface GridItemHTMLElement extends HTMLElement {\r\n /** Pointer to the associated grid node instance containing position, size, and other widget data */\r\n gridstackNode?: GridStackNode;\r\n /** @internal Original node data (used for restoring during drag operations) */\r\n _gridstackNodeOrig?: GridStackNode;\r\n}\r\n\r\n/**\r\n * Type representing various ways to specify grid elements.\r\n * Can be a CSS selector string, HTMLElement, or GridItemHTMLElement.\r\n */\r\nexport type GridStackElement = string | HTMLElement | GridItemHTMLElement;\r\n\r\n/**\r\n * Event handler function types for the .on() method.\r\n * Different handlers receive different parameters based on the event type.\r\n */\r\n\r\n/** General event handler that receives only the event */\r\nexport type GridStackEventHandler = (event: Event) => void;\r\n\r\n/** Element-specific event handler that receives event and affected element */\r\nexport type GridStackElementHandler = (event: Event, el: GridItemHTMLElement) => void;\r\n\r\n/** Node-based event handler that receives event and array of affected nodes */\r\nexport type GridStackNodesHandler = (event: Event, nodes: GridStackNode[]) => void;\r\n\r\n/** Drop event handler that receives previous and new node states */\r\nexport type GridStackDroppedHandler = (event: Event, previousNode: GridStackNode, newNode: GridStackNode) => void;\r\n\r\n/** Union type of all possible event handler types */\r\nexport type GridStackEventHandlerCallback = GridStackEventHandler | GridStackElementHandler | GridStackNodesHandler | GridStackDroppedHandler;\r\n\r\n/**\r\n * Optional callback function called during load() operations.\r\n * Allows custom handling of widget addition/removal for framework integration.\r\n * \r\n * @param parent - The parent HTML element\r\n * @param w - The widget definition\r\n * @param add - True if adding, false if removing\r\n * @param grid - True if this is a grid operation\r\n * @returns The created/modified HTML element, or undefined\r\n */\r\nexport type AddRemoveFcn = (parent: HTMLElement, w: GridStackWidget, add: boolean, grid: boolean) => HTMLElement | undefined;\r\n\r\n/**\r\n * Optional callback function called during save() operations.\r\n * Allows adding custom data to the saved widget structure.\r\n * \r\n * @param node - The internal grid node\r\n * @param w - The widget structure being saved (can be modified)\r\n */\r\nexport type SaveFcn = (node: GridStackNode, w: GridStackWidget) => void;\r\n\r\n/**\r\n * Optional callback function for custom widget content rendering.\r\n * Called during load()/addWidget() to create custom content beyond plain text.\r\n * \r\n * @param el - The widget's content container element\r\n * @param w - The widget definition with content and other properties\r\n */\r\nexport type RenderFcn = (el: HTMLElement, w: GridStackWidget) => void;\r\n\r\n/**\r\n * Optional callback function for custom resize-to-content behavior.\r\n * Called when a widget needs to resize to fit its content.\r\n * \r\n * @param el - The grid item element to resize\r\n */\r\nexport type ResizeToContentFcn = (el: GridItemHTMLElement) => void;\r\n\r\n/**\r\n * Configuration for responsive grid behavior.\r\n * \r\n * Defines how the grid responds to different screen sizes by changing column counts.\r\n * NOTE: Make sure to include the appropriate CSS (gridstack-extra.css) to support responsive behavior.\r\n */\r\nexport interface Responsive {\r\n /** wanted width to maintain (+-50%) to dynamically pick a column count. NOTE: make sure to have correct extra CSS to support this. */\r\n columnWidth?: number;\r\n /** maximum number of columns allowed (default: 12). NOTE: make sure to have correct extra CSS to support this. */\r\n columnMax?: number;\r\n /** explicit width:column breakpoints instead of automatic 'columnWidth'. NOTE: make sure to have correct extra CSS to support this. */\r\n breakpoints?: Breakpoint[];\r\n /** specify if breakpoints are for window size or grid size (default:false = grid) */\r\n breakpointForWindow?: boolean;\r\n /** global re-layout mode when changing columns */\r\n layout?: ColumnOptions;\r\n}\r\n\r\n/**\r\n * Defines a responsive breakpoint for automatic column count changes.\r\n * Used with the responsive.breakpoints option.\r\n */\r\nexport interface Breakpoint {\r\n /** Maximum width (in pixels) for this breakpoint to be active */\r\n w?: number;\r\n /** Number of columns to use when this breakpoint is active */\r\n c: number;\r\n /** Layout mode for this specific breakpoint (overrides global responsive.layout) */\r\n layout?: ColumnOptions;\r\n /** TODO: Future feature - specific children layout for this breakpoint */\r\n // children?: GridStackWidget[];\r\n}\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`: will accept HTML elements having 'grid-stack-item' as class attribute\r\n * - `false`: will not accept any external widgets\r\n * - string: explicit class name to accept instead of default\r\n * - function: callback called before an item will be accepted when entering a grid\r\n * \r\n * @example\r\n * // Accept all grid items\r\n * acceptWidgets: true\r\n * \r\n * // Accept only items with specific class\r\n * acceptWidgets: 'my-draggable-item'\r\n * \r\n * // Custom validation function\r\n * acceptWidgets: (el) => {\r\n * return el.getAttribute('data-accept') === 'true';\r\n * }\r\n * \r\n * @see {@link http://gridstack.github.io/gridstack.js/demo/two.html} for complete example\r\n */\r\n acceptWidgets?: boolean | string | ((element: Element) => boolean);\r\n\r\n /** possible values (default: `mobile`) - does not apply to non-resizable widgets\r\n * `false` the resizing handles are only shown while hovering over a widget\r\n * `true` the resizing handles are always shown\r\n * 'mobile' if running on a mobile device, default to `true` (since there is no hovering per say), else `false`.\r\n See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html) */\r\n alwaysShowResizeHandle?: true | false | 'mobile';\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): fixed pixel height\r\n * - a string (ex: '100px', '10em', '10rem'): CSS length value\r\n * - 0: library will not generate styles for rows (define your own CSS)\r\n * - 'auto': height calculated for square cells (width / column) and updated live on window resize\r\n * - 'initial': similar to 'auto' but stays fixed size during window resizing\r\n * \r\n * Note: % values don't work correctly - see demo/cell-height.html\r\n * \r\n * @example\r\n * // Fixed 100px height\r\n * cellHeight: 100\r\n * \r\n * // CSS units\r\n * cellHeight: '5rem'\r\n * cellHeight: '100px'\r\n * \r\n * // Auto-sizing for square cells\r\n * cellHeight: 'auto'\r\n * \r\n * // No CSS generation (custom styles)\r\n * cellHeight: 0\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 * Note: for nested grids, it is recommended to use 'auto' which will always match the container grid-item current width (in column) to keep inside and outside\r\n * items always the same. flag is NOT supported for regular non-nested grids.\r\n */\r\n column?: number | 'auto';\r\n\r\n /** responsive column layout for width:column behavior */\r\n columnOpts?: Responsive;\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 /** 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', appendTo?: 'body' }) */\r\n draggable?: DDDragOpt;\r\n\r\n /** let user drag nested grid items out of a parent or not (default true - not supported yet) */\r\n //dragOut?: boolean;\r\n\r\n /** the type of engine to create (so you can subclass) default to GridStackEngine */\r\n engineClass?: typeof GridStackEngine;\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 /** re-layout mode when we're a subgrid and we are being resized. default to 'list' */\r\n layout?: ColumnOptions;\r\n\r\n /** true when widgets are only created when they scroll into view (visible) */\r\n lazyLoad?: boolean;\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 which is handy to prevent grid from collapsing when empty. Default is `0`.\r\n * When no set the `min-height` CSS attribute on the grid div (in pixels) can be used, which will round to the closest row.\r\n */\r\n minRow?: number;\r\n\r\n /** If you are using a nonce-based Content Security Policy, pass your nonce here and\r\n * GridStack will add it to the <style> elements it creates. */\r\n nonce?: string;\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?: { 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/right-to-left(rtl).html)\r\n */\r\n rtl?: boolean | 'auto';\r\n\r\n /** set to true if all grid items (by default, but item can also override) height should be based on content size instead of WidgetItem.h to avoid v-scrollbars.\r\n * Note: this is still row based, not pixels, so it will use ceil(getBoundingClientRect().height / getCellHeight())\r\n */\r\n sizeToContent?: boolean;\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 /**\r\n * @deprecated Not used anymore, styles are now implemented with local CSS variables\r\n */\r\n styleInHead?: boolean;\r\n\r\n /** list of differences in options for automatically created sub-grids under us (inside our grid-items) */\r\n subGridOpts?: GridStackOptions;\r\n\r\n /** enable/disable the creation of sub-grids on the fly by dragging items completely\r\n * over others (nest) vs partially (push). Forces `DDDragOpt.pause=true` to accomplish that. */\r\n subGridDynamic?: boolean;\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 /** best node (most coverage) we collied with */\r\n collide?: GridStackNode;\r\n /** for collision check even if we don't move */\r\n forceCollide?: 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 direct resizing by the user (default?: undefined = un-constrained) */\r\n noResize?: boolean;\r\n /** prevents direct moving by the user (default?: undefined = un-constrained) */\r\n noMove?: boolean;\r\n /** prevents being pushed by other widgets or api (default?: undefined = un-constrained), which is different from `noMove` (user action only) */\r\n locked?: boolean;\r\n /** value for `gs-id` stored on the widget (default?: undefined) */\r\n id?: string;\r\n /** html to append inside as content */\r\n content?: string;\r\n /** true when widgets are only created when they scroll into view (visible) */\r\n lazyLoad?: boolean;\r\n /** local (vs grid) override - see GridStackOptions.\r\n * Note: This also allow you to set a maximum h value (but user changeable during normal resizing) to prevent unlimited content from taking too much space (get scrollbar) */\r\n sizeToContent?: boolean | number;\r\n /** local override of GridStack.resizeToContentParent that specify the class to use for the parent (actual) vs child (wanted) height */\r\n resizeToContentParent?: string;\r\n /** optional nested grid options and list of children, which then turns into actual instance at runtime to get options from */\r\n subGridOpts?: GridStackOptions;\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 on desktop, false on mobile*/\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 /** class that cannot be removed (default: 'grid-stack-non-removable') */\r\n decline?: 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 'body' */\r\n appendTo?: string;\r\n /** if set (true | msec), dragging placement (collision) will only happen after a pause by the user. Note: this is Global */\r\n pause?: boolean | number;\r\n /** default to `true` */\r\n scroll?: boolean;\r\n /** prevents dragging from starting on specified elements, listed as comma separated selectors (eg: '.no-drag'). default built in is 'input,textarea,button,select,option' */\r\n cancel?: string;\r\n /** helper function when dropping: 'clone' or your own method */\r\n helper?: 'clone' | ((el: HTMLElement) => HTMLElement);\r\n /** callbacks */\r\n start?: (event: Event, ui: DDUIData) => void;\r\n stop?: (event: Event) => void;\r\n drag?: (event: Event, ui: DDUIData) => void;\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 draggable?: HTMLElement;\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 runtime descriptions describing the widgets 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 parent Grid instance */\r\n grid?: GridStack;\r\n /** actual sub-grid instance */\r\n subGrid?: GridStack;\r\n /** allow delay creation when visible */\r\n visibleObservable?: IntersectionObserver;\r\n /** @internal internal id used to match when cloning engines or saving column layouts */\r\n _id?: number;\r\n /** @internal does the node attr ned to be updated due to changed x,y,w,h values */\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 Mouse event that's causing moving|resizing */\r\n _event?: MouseEvent;\r\n /** @internal moving vs resizing */\r\n _moving?: boolean;\r\n /** @internal is resizing? */\r\n _resizing?: 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 original position/size of item if dragged from sidebar */\r\n _sidebarOrig?: GridStackPosition;\r\n /** @internal had drag&drop been initialized */\r\n _initDD?: boolean;\r\n}\r\n"]}
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * utils.ts 12.2.2
3
- * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
2
+ * utils.ts 12.3.0
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
4
  */
5
- import { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition, GridStackWidget } from './types';
5
+ import { GridStackElement, GridStackNode, numberOrString, GridStackPosition, GridStackWidget } from './types';
6
6
  export interface HeightData {
7
7
  h: number;
8
8
  unit: string;
@@ -13,52 +13,231 @@ export interface DragTransform {
13
13
  xOffset: number;
14
14
  yOffset: number;
15
15
  }
16
- /** checks for obsolete method names */
17
- export declare function obsolete(self: any, f: any, oldName: string, newName: string, rev: string): (...args: any[]) => any;
18
- /** checks for obsolete grid options (can be used for any fields, but msg is about options) */
19
- export declare function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: string, rev: string): void;
20
- /** checks for obsolete grid options which are gone */
21
- export declare function obsoleteOptsDel(opts: GridStackOptions, oldName: string, rev: string, info: string): void;
22
- /** checks for obsolete Jquery element attributes */
23
- export declare function obsoleteAttr(el: HTMLElement, oldName: string, newName: string, rev: string): void;
24
16
  /**
25
- * Utility methods
17
+ * Collection of utility methods used throughout GridStack.
18
+ * These are general-purpose helper functions for DOM manipulation,
19
+ * positioning calculations, object operations, and more.
26
20
  */
27
21
  export declare class Utils {
28
- /** convert a potential selector into actual list of html elements. optional root which defaults to document (for shadow dom) */
22
+ /**
23
+ * Convert a potential selector into an actual list of HTML elements.
24
+ * Supports CSS selectors, element references, and special ID handling.
25
+ *
26
+ * @param els selector string, HTMLElement, or array of elements
27
+ * @param root optional root element to search within (defaults to document, useful for shadow DOM)
28
+ * @returns array of HTML elements matching the selector
29
+ *
30
+ * @example
31
+ * const elements = Utils.getElements('.grid-item');
32
+ * const byId = Utils.getElements('#myWidget');
33
+ * const fromShadow = Utils.getElements('.item', shadowRoot);
34
+ */
29
35
  static getElements(els: GridStackElement, root?: HTMLElement | Document): HTMLElement[];
30
- /** convert a potential selector into actual single element. optional root which defaults to document (for shadow dom) */
36
+ /**
37
+ * Convert a potential selector into a single HTML element.
38
+ * Similar to getElements() but returns only the first match.
39
+ *
40
+ * @param els selector string or HTMLElement
41
+ * @param root optional root element to search within (defaults to document)
42
+ * @returns the first HTML element matching the selector, or null if not found
43
+ *
44
+ * @example
45
+ * const element = Utils.getElement('#myWidget');
46
+ * const first = Utils.getElement('.grid-item');
47
+ */
31
48
  static getElement(els: GridStackElement, root?: HTMLElement | Document): HTMLElement;
32
- /** true if widget (or grid) makes this item lazyLoad */
49
+ /**
50
+ * Check if a widget should be lazy loaded based on node or grid settings.
51
+ *
52
+ * @param n the grid node to check
53
+ * @returns true if the item should be lazy loaded
54
+ *
55
+ * @example
56
+ * if (Utils.lazyLoad(node)) {
57
+ * // Set up intersection observer for lazy loading
58
+ * }
59
+ */
33
60
  static lazyLoad(n: GridStackNode): boolean;
34
- /** create a div with the given classes */
61
+ /**
62
+ * Create a div element with the specified CSS classes.
63
+ *
64
+ * @param classes array of CSS class names to add
65
+ * @param parent optional parent element to append the div to
66
+ * @returns the created div element
67
+ *
68
+ * @example
69
+ * const div = Utils.createDiv(['grid-item', 'draggable']);
70
+ * const nested = Utils.createDiv(['content'], parentDiv);
71
+ */
35
72
  static createDiv(classes: string[], parent?: HTMLElement): HTMLElement;
36
- /** true if we should resize to content. strict=true when only 'sizeToContent:true' and not a number which lets user adjust */
73
+ /**
74
+ * Check if a widget should resize to fit its content.
75
+ *
76
+ * @param n the grid node to check (can be undefined)
77
+ * @param strict if true, only returns true for explicit sizeToContent:true (not numbers)
78
+ * @returns true if the widget should resize to content
79
+ *
80
+ * @example
81
+ * if (Utils.shouldSizeToContent(node)) {
82
+ * // Trigger content-based resizing
83
+ * }
84
+ */
37
85
  static shouldSizeToContent(n: GridStackNode | undefined, strict?: boolean): boolean;
38
- /** returns true if a and b overlap */
86
+ /**
87
+ * Check if two grid positions overlap/intersect.
88
+ *
89
+ * @param a first position with x, y, w, h properties
90
+ * @param b second position with x, y, w, h properties
91
+ * @returns true if the positions overlap
92
+ *
93
+ * @example
94
+ * const overlaps = Utils.isIntercepted(
95
+ * {x: 0, y: 0, w: 2, h: 1},
96
+ * {x: 1, y: 0, w: 2, h: 1}
97
+ * ); // true - they overlap
98
+ */
39
99
  static isIntercepted(a: GridStackPosition, b: GridStackPosition): boolean;
40
- /** returns true if a and b touch edges or corners */
100
+ /**
101
+ * Check if two grid positions are touching (edges or corners).
102
+ *
103
+ * @param a first position
104
+ * @param b second position
105
+ * @returns true if the positions are touching
106
+ *
107
+ * @example
108
+ * const touching = Utils.isTouching(
109
+ * {x: 0, y: 0, w: 2, h: 1},
110
+ * {x: 2, y: 0, w: 1, h: 1}
111
+ * ); // true - they share an edge
112
+ */
41
113
  static isTouching(a: GridStackPosition, b: GridStackPosition): boolean;
42
- /** returns the area a and b overlap */
114
+ /**
115
+ * Calculate the overlapping area between two grid positions.
116
+ *
117
+ * @param a first position
118
+ * @param b second position
119
+ * @returns the area of overlap (0 if no overlap)
120
+ *
121
+ * @example
122
+ * const overlap = Utils.areaIntercept(
123
+ * {x: 0, y: 0, w: 3, h: 2},
124
+ * {x: 1, y: 0, w: 3, h: 2}
125
+ * ); // returns 4 (2x2 overlap)
126
+ */
43
127
  static areaIntercept(a: GridStackPosition, b: GridStackPosition): number;
44
- /** returns the area */
128
+ /**
129
+ * Calculate the total area of a grid position.
130
+ *
131
+ * @param a position with width and height
132
+ * @returns the total area (width * height)
133
+ *
134
+ * @example
135
+ * const area = Utils.area({x: 0, y: 0, w: 3, h: 2}); // returns 6
136
+ */
45
137
  static area(a: GridStackPosition): number;
46
138
  /**
47
- * Sorts array of nodes
48
- * @param nodes array to sort
49
- * @param dir 1 for ascending, -1 for descending (optional)
50
- **/
139
+ * Sort an array of grid nodes by position (y first, then x).
140
+ *
141
+ * @param nodes array of nodes to sort
142
+ * @param dir sort direction: 1 for ascending (top-left first), -1 for descending
143
+ * @returns the sorted array (modifies original)
144
+ *
145
+ * @example
146
+ * const sorted = Utils.sort(nodes); // Sort top-left to bottom-right
147
+ * const reverse = Utils.sort(nodes, -1); // Sort bottom-right to top-left
148
+ */
51
149
  static sort(nodes: GridStackNode[], dir?: 1 | -1): GridStackNode[];
52
- /** find an item by id */
150
+ /**
151
+ * Find a grid node by its ID.
152
+ *
153
+ * @param nodes array of nodes to search
154
+ * @param id the ID to search for
155
+ * @returns the node with matching ID, or undefined if not found
156
+ *
157
+ * @example
158
+ * const node = Utils.find(nodes, 'widget-1');
159
+ * if (node) console.log('Found node at:', node.x, node.y);
160
+ */
53
161
  static find(nodes: GridStackNode[], id: string): GridStackNode | undefined;
162
+ /**
163
+ * Convert various value types to boolean.
164
+ * Handles strings like 'false', 'no', '0' as false.
165
+ *
166
+ * @param v value to convert
167
+ * @returns boolean representation
168
+ *
169
+ * @example
170
+ * Utils.toBool('true'); // true
171
+ * Utils.toBool('false'); // false
172
+ * Utils.toBool('no'); // false
173
+ * Utils.toBool('1'); // true
174
+ */
54
175
  static toBool(v: unknown): boolean;
176
+ /**
177
+ * Convert a string value to a number, handling null and empty strings.
178
+ *
179
+ * @param value string or null value to convert
180
+ * @returns number value, or undefined for null/empty strings
181
+ *
182
+ * @example
183
+ * Utils.toNumber('42'); // 42
184
+ * Utils.toNumber(''); // undefined
185
+ * Utils.toNumber(null); // undefined
186
+ */
55
187
  static toNumber(value: null | string): number;
188
+ /**
189
+ * Parse a height value with units into numeric value and unit string.
190
+ * Supports px, em, rem, vh, vw, %, cm, mm units.
191
+ *
192
+ * @param val height value as number or string with units
193
+ * @returns object with h (height) and unit properties
194
+ *
195
+ * @example
196
+ * Utils.parseHeight('100px'); // {h: 100, unit: 'px'}
197
+ * Utils.parseHeight('2rem'); // {h: 2, unit: 'rem'}
198
+ * Utils.parseHeight(50); // {h: 50, unit: 'px'}
199
+ */
56
200
  static parseHeight(val: numberOrString): HeightData;
57
- /** copies unset fields in target to use the given default sources values */
201
+ /**
202
+ * Copy unset fields from source objects to target object (shallow merge with defaults).
203
+ * Similar to Object.assign but only sets undefined/null fields.
204
+ *
205
+ * @param target the object to copy defaults into
206
+ * @param sources one or more source objects to copy defaults from
207
+ * @returns the modified target object
208
+ *
209
+ * @example
210
+ * const config = { width: 100 };
211
+ * Utils.defaults(config, { width: 200, height: 50 });
212
+ * // config is now { width: 100, height: 50 }
213
+ */
58
214
  static defaults(target: any, ...sources: any[]): {};
59
- /** given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) */
215
+ /**
216
+ * Compare two objects for equality (shallow comparison).
217
+ * Checks if objects have the same fields and values at one level deep.
218
+ *
219
+ * @param a first object to compare
220
+ * @param b second object to compare
221
+ * @returns true if objects have the same values
222
+ *
223
+ * @example
224
+ * Utils.same({x: 1, y: 2}, {x: 1, y: 2}); // true
225
+ * Utils.same({x: 1}, {x: 1, y: 2}); // false
226
+ */
60
227
  static same(a: unknown, b: unknown): boolean;
61
- /** copies over b size & position (GridStackPosition), and optionally min/max as well */
228
+ /**
229
+ * Copy position and size properties from one widget to another.
230
+ * Copies x, y, w, h and optionally min/max constraints.
231
+ *
232
+ * @param a target widget to copy to
233
+ * @param b source widget to copy from
234
+ * @param doMinMax if true, also copy min/max width/height constraints
235
+ * @returns the target widget (a)
236
+ *
237
+ * @example
238
+ * Utils.copyPos(widget1, widget2); // Copy position/size
239
+ * Utils.copyPos(widget1, widget2, true); // Also copy constraints
240
+ */
62
241
  static copyPos(a: GridStackWidget, b: GridStackWidget, doMinMax?: boolean): GridStackWidget;
63
242
  /** true if a and b has same size & position */
64
243
  static samePos(a: GridStackPosition, b: GridStackPosition): boolean;