@gravity-ui/dashkit 9.3.2 → 10.0.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 (94) hide show
  1. package/README.md +1 -1
  2. package/build/cjs/components/DashKit/DashKit.d.ts +2 -2
  3. package/build/cjs/components/DashKit/DashKit.js +2 -2
  4. package/build/cjs/components/DashKit/DashKit.js.map +1 -1
  5. package/build/cjs/components/DashKitView/DashKitView.d.ts +3 -5
  6. package/build/cjs/components/DashKitView/DashKitView.js.map +1 -1
  7. package/build/cjs/components/GridItem/GridItem.d.ts +32 -2
  8. package/build/cjs/components/GridItem/GridItem.js +9 -42
  9. package/build/cjs/components/GridItem/GridItem.js.map +1 -1
  10. package/build/cjs/components/GridLayout/GridLayout.d.ts +55 -65
  11. package/build/cjs/components/GridLayout/GridLayout.js +39 -17
  12. package/build/cjs/components/GridLayout/GridLayout.js.map +1 -1
  13. package/build/cjs/components/GridLayout/ReactGridLayout.d.ts +13 -2
  14. package/build/cjs/components/GridLayout/ReactGridLayout.js +27 -6
  15. package/build/cjs/components/GridLayout/ReactGridLayout.js.map +1 -1
  16. package/build/cjs/components/GridLayout/types.d.ts +59 -0
  17. package/build/cjs/components/GridLayout/types.js +3 -0
  18. package/build/cjs/components/GridLayout/types.js.map +1 -0
  19. package/build/cjs/components/Item/Item.d.ts +17 -72
  20. package/build/cjs/components/Item/Item.js +3 -12
  21. package/build/cjs/components/Item/Item.js.map +1 -1
  22. package/build/cjs/components/Item/types.d.ts +14 -0
  23. package/build/cjs/components/Item/types.js +3 -0
  24. package/build/cjs/components/Item/types.js.map +1 -0
  25. package/build/cjs/components/MobileLayout/MobileLayout.d.ts +7 -7
  26. package/build/cjs/components/MobileLayout/MobileLayout.js.map +1 -1
  27. package/build/cjs/components/OverlayControls/OverlayControls.d.ts +1 -1
  28. package/build/cjs/components/OverlayControls/OverlayControls.js.map +1 -1
  29. package/build/cjs/context/DashKitContext.d.ts +24 -14
  30. package/build/cjs/context/DashKitContext.js.map +1 -1
  31. package/build/cjs/hocs/prepareItem.d.ts +21 -71
  32. package/build/cjs/hocs/prepareItem.js +8 -29
  33. package/build/cjs/hocs/prepareItem.js.map +1 -1
  34. package/build/cjs/hocs/withContext.d.ts +12 -2
  35. package/build/cjs/hocs/withContext.js +35 -14
  36. package/build/cjs/hocs/withContext.js.map +1 -1
  37. package/build/cjs/package.json +1 -1
  38. package/build/cjs/typings/common.d.ts +6 -4
  39. package/build/cjs/typings/common.js.map +1 -1
  40. package/build/cjs/typings/config.d.ts +3 -7
  41. package/build/cjs/typings/config.js.map +1 -1
  42. package/build/cjs/typings/plugin.d.ts +7 -7
  43. package/build/cjs/typings/plugin.js.map +1 -1
  44. package/build/cjs/utils/register-manager.d.ts +2 -3
  45. package/build/cjs/utils/register-manager.js.map +1 -1
  46. package/build/cjs/utils/update-manager.d.ts +2 -2
  47. package/build/cjs/utils/update-manager.js.map +1 -1
  48. package/build/esm/components/DashKit/DashKit.d.ts +2 -2
  49. package/build/esm/components/DashKit/DashKit.js +2 -2
  50. package/build/esm/components/DashKit/DashKit.js.map +1 -1
  51. package/build/esm/components/DashKitView/DashKitView.d.ts +3 -5
  52. package/build/esm/components/DashKitView/DashKitView.js.map +1 -1
  53. package/build/esm/components/GridItem/GridItem.d.ts +32 -2
  54. package/build/esm/components/GridItem/GridItem.js +9 -42
  55. package/build/esm/components/GridItem/GridItem.js.map +1 -1
  56. package/build/esm/components/GridLayout/GridLayout.d.ts +55 -65
  57. package/build/esm/components/GridLayout/GridLayout.js +39 -17
  58. package/build/esm/components/GridLayout/GridLayout.js.map +1 -1
  59. package/build/esm/components/GridLayout/ReactGridLayout.d.ts +13 -2
  60. package/build/esm/components/GridLayout/ReactGridLayout.js +27 -6
  61. package/build/esm/components/GridLayout/ReactGridLayout.js.map +1 -1
  62. package/build/esm/components/GridLayout/types.d.ts +59 -0
  63. package/build/esm/components/GridLayout/types.js +2 -0
  64. package/build/esm/components/GridLayout/types.js.map +1 -0
  65. package/build/esm/components/Item/Item.d.ts +17 -72
  66. package/build/esm/components/Item/Item.js +3 -12
  67. package/build/esm/components/Item/Item.js.map +1 -1
  68. package/build/esm/components/Item/types.d.ts +14 -0
  69. package/build/esm/components/Item/types.js +2 -0
  70. package/build/esm/components/Item/types.js.map +1 -0
  71. package/build/esm/components/MobileLayout/MobileLayout.d.ts +7 -7
  72. package/build/esm/components/MobileLayout/MobileLayout.js.map +1 -1
  73. package/build/esm/components/OverlayControls/OverlayControls.d.ts +1 -1
  74. package/build/esm/components/OverlayControls/OverlayControls.js.map +1 -1
  75. package/build/esm/context/DashKitContext.d.ts +24 -14
  76. package/build/esm/context/DashKitContext.js.map +1 -1
  77. package/build/esm/hocs/prepareItem.d.ts +21 -71
  78. package/build/esm/hocs/prepareItem.js +8 -29
  79. package/build/esm/hocs/prepareItem.js.map +1 -1
  80. package/build/esm/hocs/withContext.d.ts +12 -2
  81. package/build/esm/hocs/withContext.js +35 -14
  82. package/build/esm/hocs/withContext.js.map +1 -1
  83. package/build/esm/package.json +1 -1
  84. package/build/esm/typings/common.d.ts +6 -4
  85. package/build/esm/typings/common.js.map +1 -1
  86. package/build/esm/typings/config.d.ts +3 -7
  87. package/build/esm/typings/config.js.map +1 -1
  88. package/build/esm/typings/plugin.d.ts +7 -7
  89. package/build/esm/typings/plugin.js.map +1 -1
  90. package/build/esm/utils/register-manager.d.ts +2 -3
  91. package/build/esm/utils/register-manager.js.map +1 -1
  92. package/build/esm/utils/update-manager.d.ts +2 -2
  93. package/build/esm/utils/update-manager.js.map +1 -1
  94. package/package.json +1 -1
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { FOCUSED_CLASS_NAME } from "../../constants/index.js";
4
3
  import { DashKitContext } from "../../context/index.js";
5
4
  import { cn } from "../../utils/cn.js";
@@ -9,6 +8,8 @@ import "./GridItem.css";
9
8
  const b = cn('dashkit-grid-item');
10
9
  class WindowFocusObserver {
11
10
  constructor() {
11
+ this.subscribers = 0;
12
+ this.isFocused = !document.hidden;
12
13
  this.blurHandler = (e) => {
13
14
  if (e.target === window) {
14
15
  this.isFocused = false;
@@ -19,8 +20,6 @@ class WindowFocusObserver {
19
20
  this.isFocused = true;
20
21
  }
21
22
  };
22
- this.subscribers = 0;
23
- this.isFocused = !document.hidden;
24
23
  window.addEventListener('blur', this.blurHandler, true);
25
24
  window.addEventListener('focus', this.focusHandler, true);
26
25
  }
@@ -38,22 +37,20 @@ class GridItem extends React.PureComponent {
38
37
  constructor() {
39
38
  super(...arguments);
40
39
  this._isAsyncItem = false;
40
+ this.controller = null;
41
41
  this.state = {
42
42
  isFocused: false,
43
43
  };
44
44
  this.onOverlayItemClick = () => {
45
45
  // Creating button element to trigger focus out
46
46
  const focusDummy = document.createElement('button');
47
- const styles = {
47
+ Object.assign(focusDummy.style, {
48
48
  width: '0',
49
49
  height: '0',
50
50
  opacity: '0',
51
51
  position: 'fixed',
52
52
  top: '0',
53
53
  left: '0',
54
- };
55
- Object.entries(styles).forEach(([key, value]) => {
56
- focusDummy.style[key] = value;
57
54
  });
58
55
  // requestAnimationFrame to make call after alert() or confirm()
59
56
  requestAnimationFrame(() => {
@@ -102,7 +99,7 @@ class GridItem extends React.PureComponent {
102
99
  const { item, focusable } = this.props;
103
100
  return (React.createElement(React.Fragment, null,
104
101
  React.createElement("div", { className: b('overlay') }),
105
- React.createElement(OverlayControls, { configItem: item, onItemClick: focusable ? this.onOverlayItemClick : null })));
102
+ React.createElement(OverlayControls, { configItem: item, onItemClick: focusable ? this.onOverlayItemClick : undefined })));
106
103
  }
107
104
  render() {
108
105
  // из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable
@@ -110,15 +107,12 @@ class GridItem extends React.PureComponent {
110
107
  const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, isDraggedOut, noOverlay, focusable, withCustomHandle, isPlaceholder = false, } = this.props;
111
108
  const { editMode } = this.context;
112
109
  const { isFocused } = this.state;
113
- const width = Number.parseInt(style.width, 10);
114
- const height = Number.parseInt(style.height, 10);
115
- const transform = style.transform;
110
+ const width = (style === null || style === void 0 ? void 0 : style.width) === undefined ? undefined : Number.parseInt(String(style.width), 10);
111
+ const height = (style === null || style === void 0 ? void 0 : style.height) === undefined ? undefined : Number.parseInt(String(style.height), 10);
112
+ const transform = style === null || style === void 0 ? void 0 : style.transform;
116
113
  const preparedClassName = (editMode
117
114
  ? className
118
- : className
119
- .replace('react-resizable', '')
120
- .replace('react-draggable', '')
121
- .replace(FOCUSED_CLASS_NAME, '')) +
115
+ : className === null || className === void 0 ? void 0 : className.replace('react-resizable', '').replace('react-draggable', '').replace(FOCUSED_CLASS_NAME, '')) +
122
116
  (isFocused ? ` ${FOCUSED_CLASS_NAME}` : '');
123
117
  const computedClassName = b({
124
118
  'is-dragging': isDragging,
@@ -145,33 +139,6 @@ class GridItem extends React.PureComponent {
145
139
  preparedChildren));
146
140
  }
147
141
  }
148
- GridItem.propTypes = {
149
- adjustWidgetLayout: PropTypes.func.isRequired,
150
- gridLayout: PropTypes.object,
151
- id: PropTypes.string,
152
- item: PropTypes.object,
153
- isDragging: PropTypes.bool,
154
- isDraggedOut: PropTypes.bool,
155
- layout: PropTypes.array,
156
- forwardedRef: PropTypes.any,
157
- forwardedPluginRef: PropTypes.any,
158
- isPlaceholder: PropTypes.bool,
159
- onItemMountChange: PropTypes.func,
160
- onItemRender: PropTypes.func,
161
- // from react-grid-layout:
162
- children: PropTypes.node,
163
- className: PropTypes.string,
164
- style: PropTypes.object,
165
- noOverlay: PropTypes.bool,
166
- focusable: PropTypes.bool,
167
- withCustomHandle: PropTypes.bool,
168
- onMouseDown: PropTypes.func,
169
- onMouseUp: PropTypes.func,
170
- onTouchEnd: PropTypes.func,
171
- onTouchStart: PropTypes.func,
172
- onItemFocus: PropTypes.func,
173
- onItemBlur: PropTypes.func,
174
- };
175
142
  GridItem.contextType = DashKitContext;
176
143
  const GridItemForwarderRef = React.forwardRef((props, ref) => {
177
144
  return React.createElement(GridItem, Object.assign({}, props, { forwardedRef: ref }));
@@ -1 +1 @@
1
- {"version":3,"file":"GridItem.js","sourceRoot":"../../../../src","sources":["components/GridItem/GridItem.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,kBAAkB,EAAC,iCAAwB;AACnD,OAAO,EAAC,cAAc,EAAC,+BAAsB;AAC7C,OAAO,EAAC,EAAE,EAAC,0BAAuB;AAClC,OAAO,IAAI,wBAAqB;AAChC,OAAO,eAAe,8CAA2C;AAEjE,wBAAyB;AAEzB,MAAM,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAC;AAElC,MAAM,mBAAmB;IACrB;QAQA,gBAAW,GAAG,CAAC,CAAC,EAAE,EAAE;YAChB,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YAC3B,CAAC;QACL,CAAC,CAAC;QAEF,iBAAY,GAAG,CAAC,CAAC,EAAE,EAAE;YACjB,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YAC1B,CAAC;QACL,CAAC,CAAC;QAjBE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;QAElC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACxD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAcD,4EAA4E;IAC5E,KAAK,CAAC,eAAe;QACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,qB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;IACvB,SAAS,EAAE,SAAS,CAAC,IAAI;IACzB,SAAS,EAAE,SAAS,CAAC,IAAI;IACzB,gBAAgB,EAAE,SAAS,CAAC,IAAI;IAChC,WAAW,EAAE,SAAS,CAAC,IAAI;IAC3B,SAAS,EAAE,SAAS,CAAC,IAAI;IACzB,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,YAAY,EAAE,SAAS,CAAC,IAAI;IAC5B,WAAW,EAAE,SAAS,CAAC,IAAI;IAC3B,UAAU,EAAE,SAAS,CAAC,IAAI;CAC7B,AA7Be,CA6Bd;AAEK,oBAAW,GAAG,cAAc,AAAjB,CAAkB;AAiLxC,MAAM,oBAAoB,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACzD,OAAO,oBAAC,QAAQ,oBAAK,KAAK,IAAE,YAAY,EAAE,GAAG,IAAI,CAAC;AACtD,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAE1D,eAAe,oBAAoB,CAAC","sourcesContent":["import React from 'react';\n\nimport PropTypes from 'prop-types';\n\nimport {FOCUSED_CLASS_NAME} from '../../constants';\nimport {DashKitContext} from '../../context';\nimport {cn} from '../../utils/cn';\nimport Item from '../Item/Item';\nimport OverlayControls from '../OverlayControls/OverlayControls';\n\nimport './GridItem.scss';\n\nconst b = cn('dashkit-grid-item');\n\nclass WindowFocusObserver {\n constructor() {\n this.subscribers = 0;\n this.isFocused = !document.hidden;\n\n window.addEventListener('blur', this.blurHandler, true);\n window.addEventListener('focus', this.focusHandler, true);\n }\n\n blurHandler = (e) => {\n if (e.target === window) {\n this.isFocused = false;\n }\n };\n\n focusHandler = (e) => {\n if (e.target === window) {\n this.isFocused = true;\n }\n };\n\n // Method to get state after all blur\\focus events in document are triggered\n async getFocusedState() {\n return new Promise((resolve) => {\n requestAnimationFrame(() => {\n resolve(this.isFocused);\n });\n });\n }\n}\n\nconst windowFocusObserver = new WindowFocusObserver();\n\nclass GridItem extends React.PureComponent {\n static propTypes = {\n adjustWidgetLayout: PropTypes.func.isRequired,\n gridLayout: PropTypes.object,\n id: PropTypes.string,\n item: PropTypes.object,\n isDragging: PropTypes.bool,\n isDraggedOut: PropTypes.bool,\n layout: PropTypes.array,\n\n forwardedRef: PropTypes.any,\n forwardedPluginRef: PropTypes.any,\n isPlaceholder: PropTypes.bool,\n\n onItemMountChange: PropTypes.func,\n onItemRender: PropTypes.func,\n\n // from react-grid-layout:\n children: PropTypes.node,\n className: PropTypes.string,\n style: PropTypes.object,\n noOverlay: PropTypes.bool,\n focusable: PropTypes.bool,\n withCustomHandle: PropTypes.bool,\n onMouseDown: PropTypes.func,\n onMouseUp: PropTypes.func,\n onTouchEnd: PropTypes.func,\n onTouchStart: PropTypes.func,\n onItemFocus: PropTypes.func,\n onItemBlur: PropTypes.func,\n };\n\n static contextType = DashKitContext;\n\n _isAsyncItem = false;\n\n state = {\n isFocused: false,\n };\n\n renderOverlay() {\n const {isPlaceholder} = this.props;\n const {editMode} = this.context;\n\n if (editMode && this.props.item.data._editActive) {\n // needed for correst pointer-events: none work in firefox\n return <div className={b('overlay-placeholder')} />;\n }\n\n if (!editMode || this.props.item.data._editActive || isPlaceholder) {\n return null;\n }\n\n const {item, focusable} = this.props;\n\n return (\n <React.Fragment>\n <div className={b('overlay')} />\n <OverlayControls\n configItem={item}\n onItemClick={focusable ? this.onOverlayItemClick : null}\n />\n </React.Fragment>\n );\n }\n\n onOverlayItemClick = () => {\n // Creating button element to trigger focus out\n const focusDummy = document.createElement('button');\n const styles = {\n width: '0',\n height: '0',\n opacity: '0',\n position: 'fixed',\n top: '0',\n left: '0',\n };\n\n Object.entries(styles).forEach(([key, value]) => {\n focusDummy.style[key] = value;\n });\n\n // requestAnimationFrame to make call after alert() or confirm()\n requestAnimationFrame(() => {\n // Adding elment an changing focus\n document.body.appendChild(focusDummy);\n focusDummy.focus();\n document.body.removeChild(focusDummy);\n\n this.setState({isFocused: false});\n });\n };\n\n onFocusHandler = () => {\n this.setState({isFocused: true});\n\n if (this.props.onItemFocus) {\n // Sync focus and blur handlers\n windowFocusObserver.getFocusedState().then(() => {\n this.props.onItemFocus?.(this.props.item);\n });\n }\n\n if (this.controller) {\n this.controller.abort();\n }\n };\n\n onBlurHandler = () => {\n this.controller = new AbortController();\n\n windowFocusObserver.getFocusedState().then((isWindowFocused) => {\n if (!this.controller?.signal.aborted && isWindowFocused) {\n this.setState({isFocused: false});\n this.props.onItemBlur?.(this.props.item);\n }\n\n this.controller = null;\n });\n };\n\n render() {\n // из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable\n // https://github.com/STRML/react-grid-layout/issues/721\n const {\n style,\n onMouseDown,\n onMouseUp,\n onTouchEnd,\n onTouchStart,\n children,\n className,\n isDragging,\n isDraggedOut,\n noOverlay,\n focusable,\n withCustomHandle,\n isPlaceholder = false,\n } = this.props;\n const {editMode} = this.context;\n const {isFocused} = this.state;\n\n const width = Number.parseInt(style.width, 10);\n const height = Number.parseInt(style.height, 10);\n const transform = style.transform;\n const preparedClassName =\n (editMode\n ? className\n : className\n .replace('react-resizable', '')\n .replace('react-draggable', '')\n .replace(FOCUSED_CLASS_NAME, '')) +\n (isFocused ? ` ${FOCUSED_CLASS_NAME}` : '');\n const computedClassName = b(\n {\n 'is-dragging': isDragging,\n 'is-dragged-out': isDraggedOut,\n 'is-focused': isFocused,\n 'with-custom-handle': withCustomHandle,\n },\n preparedClassName,\n );\n\n const preparedChildren = editMode ? children : null;\n const reactGridLayoutProps = editMode\n ? {onMouseDown, onMouseUp, onTouchEnd, onTouchStart}\n : {};\n const reactFocusProps = focusable\n ? {\n onFocus: this.onFocusHandler,\n onBlur: this.onBlurHandler,\n tabIndex: -1,\n }\n : {};\n const {_editActive} = this.props.item.data;\n\n return (\n <div\n className={computedClassName}\n data-qa=\"dashkit-grid-item\"\n style={style}\n ref={this.props.forwardedRef}\n {...reactGridLayoutProps}\n {...reactFocusProps}\n >\n <div className={b('item', {editMode: editMode && !_editActive && !noOverlay})}>\n <Item\n id={this.props.id}\n item={this.props.item}\n shouldItemUpdate={!isDragging}\n width={width}\n height={height}\n transform={transform}\n isPlaceholder={isPlaceholder}\n adjustWidgetLayout={this.props.adjustWidgetLayout}\n layout={this.props.layout}\n forwardedPluginRef={this.props.forwardedPluginRef}\n onItemMountChange={this.props.onItemMountChange}\n onItemRender={this.props.onItemRender}\n gridLayout={this.props.gridLayout}\n />\n </div>\n {!noOverlay && this.renderOverlay()}\n {preparedChildren}\n </div>\n );\n }\n}\n\nconst GridItemForwarderRef = React.forwardRef((props, ref) => {\n return <GridItem {...props} forwardedRef={ref} />;\n});\n\nGridItemForwarderRef.displayName = 'forwardRef(GridItem)';\n\nexport default GridItemForwarderRef;\n"]}
1
+ {"version":3,"file":"GridItem.js","sourceRoot":"../../../../src","sources":["components/GridItem/GridItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,kBAAkB,EAAC,iCAAwB;AACnD,OAAO,EAAC,cAAc,EAAC,+BAAsB;AAG7C,OAAO,EAAC,EAAE,EAAC,0BAAuB;AAElC,OAAO,IAAI,wBAAqB;AAChC,OAAO,eAAe,8CAA2C;AAEjE,wBAAyB;AAEzB,MAAM,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAC;AAElC,MAAM,mBAAmB;IAIrB;QAHA,gBAAW,GAAG,CAAC,CAAC;QAChB,cAAS,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;QAO7B,gBAAW,GAAG,CAAC,CAAa,EAAE,EAAE;YAC5B,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YAC3B,CAAC;QACL,CAAC,CAAC;QAEF,iBAAY,GAAG,CAAC,CAAa,EAAE,EAAE;YAC7B,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,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KAAK,EAAE,GAAG,EAAE,EAAE;IACX,OAAO,oBAAC,QAAQ,oBAAK,KAAK,IAAE,YAAY,EAAE,GAAG,IAAI,CAAC;AACtD,CAAC,CACJ,CAAC;AAEF,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAE1D,eAAe,oBAAoB,CAAC","sourcesContent":["import React from 'react';\n\nimport {FOCUSED_CLASS_NAME} from '../../constants';\nimport {DashKitContext} from '../../context';\nimport type {ConfigItem, ConfigLayout} from '../../shared';\nimport type {PluginRef, PluginWidgetProps, ReactGridLayoutProps} from '../../typings';\nimport {cn} from '../../utils/cn';\nimport type {DashKitProps} from '../DashKit';\nimport Item from '../Item/Item';\nimport OverlayControls from '../OverlayControls/OverlayControls';\n\nimport './GridItem.scss';\n\nconst b = cn('dashkit-grid-item');\n\nclass WindowFocusObserver {\n subscribers = 0;\n isFocused = !document.hidden;\n\n constructor() {\n window.addEventListener('blur', this.blurHandler, true);\n window.addEventListener('focus', this.focusHandler, true);\n }\n\n blurHandler = (e: FocusEvent) => {\n if (e.target === window) {\n this.isFocused = false;\n }\n };\n\n focusHandler = (e: FocusEvent) => {\n if (e.target === window) {\n this.isFocused = true;\n }\n };\n\n // Method to get state after all blur\\focus events in document are triggered\n async getFocusedState(): Promise<boolean> {\n return new Promise((resolve) => {\n requestAnimationFrame(() => {\n resolve(this.isFocused);\n });\n });\n }\n}\n\nconst windowFocusObserver = new WindowFocusObserver();\n\ntype GridItemProps = {\n adjustWidgetLayout: PluginWidgetProps['adjustWidgetLayout'];\n gridLayout?: ReactGridLayoutProps;\n id: string;\n item: ConfigItem;\n isDragging?: boolean;\n isDraggedOut?: boolean;\n layout: ConfigLayout[];\n\n forwardedRef?: React.Ref<HTMLDivElement>;\n forwardedPluginRef?: (pluginRef: PluginRef) => void;\n isPlaceholder?: boolean;\n\n onItemMountChange?: DashKitProps['onItemMountChange'];\n onItemRender?: DashKitProps['onItemRender'];\n\n // from react-grid-layout:\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n noOverlay?: boolean;\n focusable?: boolean;\n withCustomHandle?: boolean;\n onMouseDown?: (e: React.MouseEvent<HTMLDivElement>) => void;\n onMouseUp?: (e: React.MouseEvent<HTMLDivElement>) => void;\n onTouchEnd?: (e: React.TouchEvent<HTMLDivElement>) => void;\n onTouchStart?: (e: React.TouchEvent<HTMLDivElement>) => void;\n onItemFocus?: DashKitProps['onItemFocus'];\n onItemBlur?: DashKitProps['onItemBlur'];\n};\n\ntype GridItemState = {\n isFocused: boolean;\n};\n\nclass GridItem extends React.PureComponent<GridItemProps, GridItemState> {\n static contextType = DashKitContext;\n context!: React.ContextType<typeof DashKitContext>;\n\n _isAsyncItem = false;\n controller: AbortController | null = null;\n\n state: GridItemState = {\n isFocused: false,\n };\n\n renderOverlay() {\n const {isPlaceholder} = this.props;\n const {editMode} = this.context;\n\n if (editMode && this.props.item.data._editActive) {\n // needed for correst pointer-events: none work in firefox\n return <div className={b('overlay-placeholder')} />;\n }\n\n if (!editMode || this.props.item.data._editActive || isPlaceholder) {\n return null;\n }\n\n const {item, focusable} = this.props;\n\n return (\n <React.Fragment>\n <div className={b('overlay')} />\n <OverlayControls\n configItem={item}\n onItemClick={focusable ? this.onOverlayItemClick : undefined}\n />\n </React.Fragment>\n );\n }\n\n onOverlayItemClick = () => {\n // Creating button element to trigger focus out\n const focusDummy = document.createElement('button');\n Object.assign(focusDummy.style, {\n width: '0',\n height: '0',\n opacity: '0',\n position: 'fixed',\n top: '0',\n left: '0',\n });\n\n // requestAnimationFrame to make call after alert() or confirm()\n requestAnimationFrame(() => {\n // Adding elment an changing focus\n document.body.appendChild(focusDummy);\n focusDummy.focus();\n document.body.removeChild(focusDummy);\n\n this.setState({isFocused: false});\n });\n };\n\n onFocusHandler = () => {\n this.setState({isFocused: true});\n\n if (this.props.onItemFocus) {\n // Sync focus and blur handlers\n windowFocusObserver.getFocusedState().then(() => {\n this.props.onItemFocus?.(this.props.item);\n });\n }\n\n if (this.controller) {\n this.controller.abort();\n }\n };\n\n onBlurHandler = () => {\n this.controller = new AbortController();\n\n windowFocusObserver.getFocusedState().then((isWindowFocused) => {\n if (!this.controller?.signal.aborted && isWindowFocused) {\n this.setState({isFocused: false});\n this.props.onItemBlur?.(this.props.item);\n }\n\n this.controller = null;\n });\n };\n\n render() {\n // из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable\n // https://github.com/STRML/react-grid-layout/issues/721\n const {\n style,\n onMouseDown,\n onMouseUp,\n onTouchEnd,\n onTouchStart,\n children,\n className,\n isDragging,\n isDraggedOut,\n noOverlay,\n focusable,\n withCustomHandle,\n isPlaceholder = false,\n } = this.props;\n const {editMode} = this.context;\n const {isFocused} = this.state;\n\n const width =\n style?.width === undefined ? undefined : Number.parseInt(String(style.width), 10);\n const height =\n style?.height === undefined ? undefined : Number.parseInt(String(style.height), 10);\n const transform = style?.transform;\n const preparedClassName =\n (editMode\n ? className\n : className\n ?.replace('react-resizable', '')\n .replace('react-draggable', '')\n .replace(FOCUSED_CLASS_NAME, '')) +\n (isFocused ? ` ${FOCUSED_CLASS_NAME}` : '');\n const computedClassName = b(\n {\n 'is-dragging': isDragging,\n 'is-dragged-out': isDraggedOut,\n 'is-focused': isFocused,\n 'with-custom-handle': withCustomHandle,\n },\n preparedClassName,\n );\n\n const preparedChildren = editMode ? children : null;\n const reactGridLayoutProps = editMode\n ? {onMouseDown, onMouseUp, onTouchEnd, onTouchStart}\n : {};\n const reactFocusProps = focusable\n ? {\n onFocus: this.onFocusHandler,\n onBlur: this.onBlurHandler,\n tabIndex: -1,\n }\n : {};\n const {_editActive} = this.props.item.data;\n\n return (\n <div\n className={computedClassName}\n data-qa=\"dashkit-grid-item\"\n style={style}\n ref={this.props.forwardedRef}\n {...reactGridLayoutProps}\n {...reactFocusProps}\n >\n <div className={b('item', {editMode: editMode && !_editActive && !noOverlay})}>\n <Item\n id={this.props.id}\n item={this.props.item}\n shouldItemUpdate={!isDragging}\n width={width}\n height={height}\n transform={transform}\n isPlaceholder={isPlaceholder}\n adjustWidgetLayout={this.props.adjustWidgetLayout}\n layout={this.props.layout}\n forwardedPluginRef={this.props.forwardedPluginRef}\n onItemMountChange={this.props.onItemMountChange}\n onItemRender={this.props.onItemRender}\n gridLayout={this.props.gridLayout}\n />\n </div>\n {!noOverlay && this.renderOverlay()}\n {preparedChildren}\n </div>\n );\n }\n}\n\nconst GridItemForwarderRef = React.forwardRef<HTMLDivElement, Omit<GridItemProps, 'forwardedRef'>>(\n (props, ref) => {\n return <GridItem {...props} forwardedRef={ref} />;\n },\n);\n\nGridItemForwarderRef.displayName = 'forwardRef(GridItem)';\n\nexport default GridItemForwarderRef;\n"]}
@@ -1,73 +1,63 @@
1
- export default class GridLayout extends React.PureComponent<any, any, any> {
2
- static contextType: React.Context<import("../../context/index.js").DashKitCtxShape>;
3
- constructor(props: any, context: any);
4
- pluginsRefs: any[];
5
- state: {
6
- isDragging: boolean;
7
- isDraggedOut: boolean;
8
- isPageHidden: boolean;
9
- currentDraggingElement: null;
10
- draggedOverGroup: null;
11
- };
1
+ import React from 'react';
2
+ import type { DragOverEvent } from 'react-grid-layout';
3
+ import type { PluginRef, PluginWidgetProps, ReactGridLayoutProps } from 'src/typings';
4
+ import type { DashKitCtxShape } from "../../context/index.js";
5
+ import type { ConfigItem, ConfigLayout } from "../../shared/index.js";
6
+ import type { GridLayoutProps, GridLayoutState, GroupCallbacks, LayoutAndPropsByGroup, ManipulationCallbackArgs, MemoGroupLayout, ReloadItemsOptions } from "./types.js";
7
+ export default class GridLayout extends React.PureComponent<GridLayoutProps, GridLayoutState> {
8
+ static contextType: React.Context<DashKitCtxShape>;
9
+ context: DashKitCtxShape;
10
+ pluginsRefs: Array<PluginRef>;
11
+ private _memoForwardedPluginRef;
12
+ private _memoGroupsProps;
13
+ private _memoGroupsLayouts;
14
+ private _memoCallbacksForGroups;
15
+ private _timeout?;
16
+ private _lastReloadAt?;
17
+ private _parendDragNode;
18
+ constructor(props: GridLayoutProps, context: DashKitCtxShape);
12
19
  componentDidMount(): void;
13
20
  componentDidUpdate(): void;
14
21
  componentWillUnmount(): void;
15
- _memoCallbacksForGroups: {};
16
- _memoGroupsProps: {};
17
- _memoGroupsLayouts: {};
18
- _memoForwardedPluginRef: any[];
19
- _timeout: any;
20
- _lastReloadAt: any;
21
22
  onVisibilityChange: () => void;
22
- adjustWidgetLayout: ({ widgetId, needSetDefault, adjustedWidgetLayout }: {
23
- widgetId: any;
24
- needSetDefault: any;
25
- adjustedWidgetLayout: any;
26
- }) => void;
27
- getItemsMeta: () => any;
28
- getActiveLayout(): any;
29
- getMemoGroupLayout(group: any, layout: any): any;
30
- getMemoGroupCallbacks(group: any): any;
31
- getMemoGroupProps: (group: any, renderLayout: any, properties: any) => {
32
- layout: any;
33
- callbacks: any;
34
- };
35
- getLayoutAndPropsByGroup: (group: any) => {
36
- properties: any;
37
- layout: any;
23
+ adjustWidgetLayout: PluginWidgetProps['adjustWidgetLayout'];
24
+ getItemsMeta: () => Promise<any>[];
25
+ getActiveLayout(): ConfigLayout[];
26
+ getMemoGroupLayout(group: string, layout: ConfigLayout[]): MemoGroupLayout;
27
+ getMemoGroupCallbacks(group: string): GroupCallbacks;
28
+ getMemoGroupProps: (group: string, renderLayout: ConfigLayout[], properties: Partial<ReactGridLayoutProps>) => {
29
+ layout: ConfigLayout[];
30
+ callbacks: GroupCallbacks;
38
31
  };
39
- getMemoForwardRefCallback: (refIndex: any) => any;
40
- mergeGroupsLayout(group: any, newLayout: any, temporaryItem: any): any;
41
- reloadItems(options: any): void;
42
- prepareDefaultArguments(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): {
43
- group: any;
44
- layout: any;
45
- oldItem: any;
46
- newItem: any;
47
- placeholder: any;
48
- e: any;
49
- element: any;
50
- };
51
- updateDraggingElementState(group: any, layoutItem: any, e: any): void;
52
- _initDragCoordinatesWatcher(element: any): void;
53
- _parendDragNode: any;
54
- _forceCursorCapture(parentElement: any, position: any, parentRect: any): void;
55
- _updateDragCoordinates(e: any): void;
32
+ getLayoutAndPropsByGroup: (group: string) => LayoutAndPropsByGroup;
33
+ getMemoForwardRefCallback: (refIndex: number) => (pluginRef: PluginRef) => void;
34
+ mergeGroupsLayout(group: string, newLayout: ConfigLayout[], temporaryItem?: ConfigLayout): ConfigLayout[];
35
+ reloadItems(options?: ReloadItemsOptions): void;
36
+ prepareDefaultArguments(group: string, layout: ConfigLayout[], oldItem: ConfigLayout, newItem: ConfigLayout, placeholder: ConfigLayout, e: MouseEvent, element: HTMLElement): ManipulationCallbackArgs;
37
+ updateDraggingElementState(group: string, layoutItem: ConfigLayout, e: MouseEvent): void;
38
+ _initDragCoordinatesWatcher(element: HTMLElement): void;
39
+ _forceCursorCapture(parentElement: HTMLElement, position: {
40
+ top: number;
41
+ left: number;
42
+ }, parentRect: DOMRect): void;
43
+ _updateDragCoordinates(e: MouseEvent): void;
56
44
  _resetDragWatcher(): void;
57
- _onDragStart(group: any, _newLayout: any, layoutItem: any, _newItem: any, _placeholder: any, e: any, element: any): void;
58
- _onDrag(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): void;
59
- _onDragStop(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): void;
60
- _onResizeStart(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): void;
61
- _onResize(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): void;
62
- _onResizeStop(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): void;
45
+ _onDragStart(group: string, _newLayout: ConfigLayout[], layoutItem: ConfigLayout, _newItem: ConfigLayout, _placeholder: ConfigLayout, e: MouseEvent, element: HTMLElement): void;
46
+ _onDrag(group: string, layout: ConfigLayout[], oldItem: ConfigLayout, newItem: ConfigLayout, placeholder: ConfigLayout, e: MouseEvent, element: HTMLElement): void;
47
+ _onDragStop(group: string, layout: ConfigLayout[], oldItem: ConfigLayout, newItem: ConfigLayout, placeholder: ConfigLayout, e: MouseEvent, element: HTMLElement): void;
48
+ _onResizeStart(group: string, layout: ConfigLayout[], oldItem: ConfigLayout, newItem: ConfigLayout, placeholder: ConfigLayout, e: MouseEvent, element: HTMLElement): void;
49
+ _onResize(group: string, layout: ConfigLayout[], oldItem: ConfigLayout, newItem: ConfigLayout, placeholder: ConfigLayout, e: MouseEvent, element: HTMLElement): void;
50
+ _onResizeStop(group: string, layout: ConfigLayout[], oldItem: ConfigLayout, newItem: ConfigLayout, placeholder: ConfigLayout, e: MouseEvent, element: HTMLElement): void;
63
51
  _onTargetRestore(): void;
64
- _onStop: (group: any, newLayout: any) => void;
65
- _onSharedDrop: (targetGroup: any, newLayout: any, tempItem: any) => void;
66
- _onExternalDrop: (group: any, newLayout: any, item: any, e: any) => void;
67
- _onDrop: (group: any, newLayout: any, item: any, e: any) => false | undefined;
68
- _onDropDragOver: (group: any, e: any) => any;
69
- renderTemporaryPlaceholder(gridLayout: any): JSX.Element | null;
70
- renderGroup(group: any, renderLayout: any, renderItems: any, offset: number | undefined, groupGridProperties: any): JSX.Element;
71
- render(): any;
52
+ _onStop: (group: string, newLayout: ConfigLayout[]) => void;
53
+ _onSharedDrop: (targetGroup: string, newLayout: ConfigLayout[], tempItem: ConfigLayout) => void;
54
+ _onExternalDrop: (group: string, newLayout: ConfigLayout[], item: ConfigLayout, e: MouseEvent) => void;
55
+ _onDrop: (group: string, newLayout: ConfigLayout[], item: ConfigLayout | undefined, e: MouseEvent) => void | false;
56
+ _onDropDragOver: (group: string, e: DragOverEvent) => {
57
+ w?: number;
58
+ h?: number;
59
+ } | false | undefined;
60
+ renderTemporaryPlaceholder(gridLayout: Partial<ReactGridLayoutProps>): JSX.Element | null;
61
+ renderGroup(group: string, renderLayout: ConfigLayout[], renderItems: ConfigItem[], offset?: number, groupGridProperties?: (props: ReactGridLayoutProps) => ReactGridLayoutProps): JSX.Element;
62
+ render(): JSX.Element | (string | number | boolean | JSX.Element | React.ReactFragment | null | undefined)[];
72
63
  }
73
- import React from 'react';
@@ -4,6 +4,14 @@ import { DashKitContext } from "../../context/index.js";
4
4
  import { resolveLayoutGroup } from "../../utils/index.js";
5
5
  import GridItem from "../GridItem/GridItem.js";
6
6
  import { Layout } from "./ReactGridLayout.js";
7
+ const hasPluginId = (value) => {
8
+ return (value !== null &&
9
+ 'props' in value &&
10
+ typeof value.props === 'object' &&
11
+ value.props !== null &&
12
+ 'id' in value.props &&
13
+ typeof value.props.id === 'string');
14
+ };
7
15
  class GridLayout extends React.PureComponent {
8
16
  constructor(props, context) {
9
17
  super(props, context);
@@ -11,12 +19,13 @@ class GridLayout extends React.PureComponent {
11
19
  this._memoGroupsProps = {};
12
20
  this._memoGroupsLayouts = {};
13
21
  this._memoCallbacksForGroups = {};
22
+ this._parendDragNode = null;
14
23
  this.onVisibilityChange = () => {
15
24
  this.setState({
16
25
  isPageHidden: document.hidden,
17
26
  });
18
27
  };
19
- this.adjustWidgetLayout = ({ widgetId, needSetDefault, adjustedWidgetLayout }) => {
28
+ this.adjustWidgetLayout = ({ widgetId, needSetDefault, adjustedWidgetLayout, }) => {
20
29
  const { layout, memorizeOriginalLayout, revertToOriginalLayout } = this.context;
21
30
  if (needSetDefault) {
22
31
  revertToOriginalLayout(widgetId);
@@ -71,7 +80,10 @@ class GridLayout extends React.PureComponent {
71
80
  draggedOverGroup: null,
72
81
  });
73
82
  if (temporaryLayout) {
74
- onDrop === null || onDrop === void 0 ? void 0 : onDrop(groupedLayout, groupedLayout.find(({ i }) => i === TEMPORARY_ITEM_ID));
83
+ const temporaryItem = groupedLayout.find(({ i }) => i === TEMPORARY_ITEM_ID);
84
+ if (onDrop && temporaryItem) {
85
+ onDrop(groupedLayout, temporaryItem);
86
+ }
75
87
  }
76
88
  else {
77
89
  layoutChange(groupedLayout);
@@ -212,7 +224,7 @@ class GridLayout extends React.PureComponent {
212
224
  const onResizeStop = this._onResizeStop.bind(this, group);
213
225
  const onDrop = this._onDrop.bind(this, group);
214
226
  const onDropDragOver = this._onDropDragOver.bind(this, group);
215
- const onDragTargetRestore = this._onTargetRestore.bind(this, group);
227
+ const onDragTargetRestore = this._onTargetRestore.bind(this);
216
228
  this._memoCallbacksForGroups[group] = {
217
229
  onDragStart,
218
230
  onDrag,
@@ -234,7 +246,8 @@ class GridLayout extends React.PureComponent {
234
246
  return memo;
235
247
  }, temporaryItem ? { [temporaryItem.i]: temporaryItem } : {});
236
248
  const newItemsLayoutById = newLayout.reduce((memo, item) => {
237
- const parent = itemsByGroup[item.i].parent;
249
+ var _a;
250
+ const parent = (_a = itemsByGroup[item.i]) === null || _a === void 0 ? void 0 : _a.parent;
238
251
  memo[item.i] = Object.assign({}, item);
239
252
  if (parent) {
240
253
  memo[item.i].parent = parent;
@@ -255,19 +268,19 @@ class GridLayout extends React.PureComponent {
255
268
  const { isPageHidden } = this.state;
256
269
  const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
257
270
  const targetPlugins = targetIds
258
- ? this.pluginsRefs.filter((plugin) => targetIds.includes(plugin.props.id))
271
+ ? this.pluginsRefs.filter((plugin) => hasPluginId(plugin) && targetIds.includes(plugin.props.id))
259
272
  : this.pluginsRefs;
260
273
  if (autoupdateIntervalMs) {
261
274
  const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
262
275
  const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
263
276
  if (force || (!isPageHidden && !editMode && reloadIntervalRemains <= 0)) {
264
277
  this._lastReloadAt = new Date().getTime();
265
- reloadItems(targetPlugins, { silentLoading, noVeil: true });
278
+ reloadItems(targetPlugins, { silentLoading: Boolean(silentLoading), noVeil: true });
266
279
  }
267
280
  this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
268
281
  }
269
282
  else if (force) {
270
- reloadItems(targetPlugins, { silentLoading, noVeil: true });
283
+ reloadItems(targetPlugins, { silentLoading: Boolean(silentLoading), noVeil: true });
271
284
  }
272
285
  }
273
286
  prepareDefaultArguments(group, layout, oldItem, newItem, placeholder, e, element) {
@@ -289,11 +302,15 @@ class GridLayout extends React.PureComponent {
289
302
  const item = temporaryLayout
290
303
  ? temporaryLayout.dragProps
291
304
  : this.context.configItems.find(({ id }) => id === layoutId);
305
+ if (!item) {
306
+ return;
307
+ }
292
308
  let { offsetX, offsetY } = e.nativeEvent || {};
293
309
  if (offsetX === undefined || offsetY === undefined) {
294
- const gridRect = e.currentTarget.getBoundingClientRect();
295
- offsetX = e.clientX - gridRect.left;
296
- offsetY = e.clientY - gridRect.top;
310
+ const target = e.currentTarget;
311
+ const gridRect = target === null || target === void 0 ? void 0 : target.getBoundingClientRect();
312
+ offsetX = e.clientX - ((gridRect === null || gridRect === void 0 ? void 0 : gridRect.left) || 0);
313
+ offsetY = e.clientY - ((gridRect === null || gridRect === void 0 ? void 0 : gridRect.top) || 0);
297
314
  }
298
315
  currentDraggingElement = {
299
316
  group,
@@ -331,6 +348,9 @@ class GridLayout extends React.PureComponent {
331
348
  }
332
349
  _updateDragCoordinates(e) {
333
350
  const parent = this._parendDragNode;
351
+ if (!parent) {
352
+ return;
353
+ }
334
354
  const parentRect = parent.getBoundingClientRect();
335
355
  const { clientX, clientY } = e;
336
356
  let isDraggedOut = this.state.isDraggedOut;
@@ -431,13 +451,13 @@ class GridLayout extends React.PureComponent {
431
451
  }
432
452
  const { callbacks, layout } = this.getMemoGroupProps(group, renderLayout, properties);
433
453
  const hasSharedDragItem = Boolean(currentDraggingElement && currentDraggingElement.group !== group);
434
- const isDragCaptured = currentDraggingElement &&
454
+ const isDragCaptured = Boolean(currentDraggingElement &&
435
455
  group === currentDraggingElement.group &&
436
456
  draggedOverGroup !== null &&
437
- draggedOverGroup !== group;
438
- return (React.createElement(Layout, Object.assign({ isDraggable: editMode, isResizable: editMode }, properties, { key: `group_${group}`,
457
+ draggedOverGroup !== group);
458
+ return (React.createElement(Layout, Object.assign({ key: `group_${group}`, isDraggable: editMode, isResizable: editMode }, properties, {
439
459
  // Layout props
440
- compactType: compactType, layout: layout, draggableCancel: `.${DRAGGABLE_CANCEL_CLASS_NAME}`, draggableHandle: draggableHandleClassName ? `.${draggableHandleClassName}` : null,
460
+ compactType: compactType, layout: layout, draggableCancel: `.${DRAGGABLE_CANCEL_CLASS_NAME}`, draggableHandle: draggableHandleClassName ? `.${draggableHandleClassName}` : undefined,
441
461
  // Default callbacks
442
462
  onDragStart: callbacks.onDragStart, onDrag: callbacks.onDrag, onDragStop: callbacks.onDragStop, onResizeStart: callbacks.onResizeStart, onResize: callbacks.onResize, onResizeStop: callbacks.onResizeStop,
443
463
  // External Drag N Drop options
@@ -445,12 +465,14 @@ class GridLayout extends React.PureComponent {
445
465
  renderItems.map((item, i) => {
446
466
  const keyId = item.id;
447
467
  const isDragging = this.state.isDragging;
448
- const isCurrentDraggedItem = (currentDraggingElement === null || currentDraggingElement === void 0 ? void 0 : currentDraggingElement.item.id) === keyId;
468
+ const isCurrentDraggedItem = currentDraggingElement &&
469
+ 'id' in currentDraggingElement.item &&
470
+ currentDraggingElement.item.id === keyId;
449
471
  const isDraggedOut = isCurrentDraggedItem && this.state.isDraggedOut;
450
472
  const itemNoOverlay = hasOwnGroupProperties && 'noOverlay' in properties
451
473
  ? properties.noOverlay
452
474
  : noOverlay;
453
- return (React.createElement(GridItem, { forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), key: keyId, id: keyId, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: isDragging, isDraggedOut: isDraggedOut, noOverlay: itemNoOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender, gridLayout: properties, onItemFocus: onItemFocus, onItemBlur: onItemBlur }));
475
+ return (React.createElement(GridItem, { key: keyId, forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), id: keyId, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: isDragging, isDraggedOut: isDraggedOut || undefined, noOverlay: itemNoOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender, gridLayout: properties, onItemFocus: onItemFocus, onItemBlur: onItemBlur }));
454
476
  }),
455
477
  this.renderTemporaryPlaceholder(properties)));
456
478
  }
@@ -472,7 +494,7 @@ class GridLayout extends React.PureComponent {
472
494
  defaultRenderLayout.push(item);
473
495
  }
474
496
  return memo;
475
- }, []);
497
+ }, {});
476
498
  const itemsByGroup = this.context.configItems.reduce((memo, item) => {
477
499
  const group = layoutMap[item.id];
478
500
  if (group) {