@gravity-ui/dashkit 8.26.0 → 8.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,10 @@
19
19
  border: solid 1px var(--_-dashkit-overlay-border-color);
20
20
  opacity: var(--_-dashkit-overlay-opacity);
21
21
  }
22
+ .dashkit-grid-item__overlay-placeholder {
23
+ position: absolute;
24
+ inset: 0;
25
+ }
22
26
  .dashkit-grid-item__item {
23
27
  --_-dashkit-grid-item-border-radius: var(
24
28
  --dashkit-grid-item-border-radius,
@@ -35,12 +39,15 @@
35
39
  pointer-events: none;
36
40
  }
37
41
  .dashkit-grid-item_is-dragged-out {
42
+ user-select: none;
38
43
  pointer-events: none;
44
+ touch-action: none;
39
45
  }
40
46
 
41
47
  .react-grid-item.dropping {
42
48
  user-select: none;
43
49
  pointer-events: none;
50
+ touch-action: none;
44
51
  }
45
52
 
46
53
  .react-grid-layout {
@@ -94,6 +94,10 @@ class GridItem extends react_1.default.PureComponent {
94
94
  renderOverlay() {
95
95
  const { isPlaceholder } = this.props;
96
96
  const { editMode } = this.context;
97
+ if (editMode && this.props.item.data._editActive) {
98
+ // needed for correst pointer-events: none work in firefox
99
+ return react_1.default.createElement("div", { className: b('overlay-placeholder') });
100
+ }
97
101
  if (!editMode || this.props.item.data._editActive || isPlaceholder) {
98
102
  return null;
99
103
  }
@@ -107,6 +111,7 @@ class GridItem extends react_1.default.PureComponent {
107
111
  // https://github.com/STRML/react-grid-layout/issues/721
108
112
  const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, isDraggedOut, noOverlay, focusable, withCustomHandle, isPlaceholder = false, } = this.props;
109
113
  const { editMode } = this.context;
114
+ const { isFocused } = this.state;
110
115
  const width = Number.parseInt(style.width, 10);
111
116
  const height = Number.parseInt(style.height, 10);
112
117
  const transform = style.transform;
@@ -116,24 +121,26 @@ class GridItem extends react_1.default.PureComponent {
116
121
  .replace('react-resizable', '')
117
122
  .replace('react-draggable', '')
118
123
  .replace(constants_1.FOCUSED_CLASS_NAME, '')) +
119
- (this.state.isFocused ? ` ${constants_1.FOCUSED_CLASS_NAME}` : '');
124
+ (isFocused ? ` ${constants_1.FOCUSED_CLASS_NAME}` : '');
125
+ const computedClassName = b({
126
+ 'is-dragging': isDragging,
127
+ 'is-dragged-out': isDraggedOut,
128
+ 'is-focused': isFocused,
129
+ 'with-custom-handle': withCustomHandle,
130
+ }, preparedClassName);
120
131
  const preparedChildren = editMode ? children : null;
121
132
  const reactGridLayoutProps = editMode
122
133
  ? { onMouseDown, onMouseUp, onTouchEnd, onTouchStart }
123
134
  : {};
124
- const { _editActive } = this.props.item.data;
125
- return (react_1.default.createElement("div", Object.assign({ className: b({
126
- 'is-dragging': isDragging,
127
- 'is-dragged-out': isDraggedOut,
128
- 'is-focused': this.state.isFocused,
129
- 'with-custom-handle': withCustomHandle,
130
- }, preparedClassName), "data-qa": "dashkit-grid-item", style: style, ref: this.props.forwardedRef }, reactGridLayoutProps, (focusable
135
+ const reactFocusProps = focusable
131
136
  ? {
132
137
  onFocus: this.onFocusHandler,
133
138
  onBlur: this.onBlurHandler,
134
139
  tabIndex: -1,
135
140
  }
136
- : {})),
141
+ : {};
142
+ const { _editActive } = this.props.item.data;
143
+ return (react_1.default.createElement("div", Object.assign({ className: computedClassName, "data-qa": "dashkit-grid-item", style: style, ref: this.props.forwardedRef }, reactGridLayoutProps, reactFocusProps),
137
144
  react_1.default.createElement("div", { className: b('item', { editMode: editMode && !_editActive && !noOverlay }) },
138
145
  react_1.default.createElement(Item_1.default, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, isPlaceholder: isPlaceholder, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef, onItemMountChange: this.props.onItemMountChange, onItemRender: this.props.onItemRender, gridLayout: this.props.gridLayout })),
139
146
  !noOverlay && this.renderOverlay(),
@@ -292,7 +292,12 @@ class GridLayout extends react_1.default.PureComponent {
292
292
  const item = temporaryLayout
293
293
  ? temporaryLayout.dragProps
294
294
  : this.context.config.items.find(({ id }) => id === layoutId);
295
- const { offsetX, offsetY } = e.nativeEvent;
295
+ let { offsetX, offsetY } = e.nativeEvent || {};
296
+ if (offsetX === undefined || offsetY === undefined) {
297
+ const gridRect = e.currentTarget.getBoundingClientRect();
298
+ offsetX = e.clientX - gridRect.left;
299
+ offsetY = e.clientY - gridRect.top;
300
+ }
296
301
  currentDraggingElement = {
297
302
  group,
298
303
  layoutItem,
@@ -94,6 +94,15 @@ class DragOverLayout extends react_grid_layout_1.default {
94
94
  };
95
95
  this.mouseMoveHandler = (e) => {
96
96
  if (this.props.hasSharedDragItem) {
97
+ if (!e.nativeEvent) {
98
+ // Emulate nativeEvent for firefox
99
+ const target = this.getInnerElement() || e.target;
100
+ e.nativeEvent = {
101
+ clientX: e.clientX,
102
+ clientY: e.clientY,
103
+ target,
104
+ };
105
+ }
97
106
  this.onDragOver(e);
98
107
  }
99
108
  };
@@ -19,6 +19,10 @@
19
19
  border: solid 1px var(--_-dashkit-overlay-border-color);
20
20
  opacity: var(--_-dashkit-overlay-opacity);
21
21
  }
22
+ .dashkit-grid-item__overlay-placeholder {
23
+ position: absolute;
24
+ inset: 0;
25
+ }
22
26
  .dashkit-grid-item__item {
23
27
  --_-dashkit-grid-item-border-radius: var(
24
28
  --dashkit-grid-item-border-radius,
@@ -35,12 +39,15 @@
35
39
  pointer-events: none;
36
40
  }
37
41
  .dashkit-grid-item_is-dragged-out {
42
+ user-select: none;
38
43
  pointer-events: none;
44
+ touch-action: none;
39
45
  }
40
46
 
41
47
  .react-grid-item.dropping {
42
48
  user-select: none;
43
49
  pointer-events: none;
50
+ touch-action: none;
44
51
  }
45
52
 
46
53
  .react-grid-layout {
@@ -92,6 +92,10 @@ class GridItem extends React.PureComponent {
92
92
  renderOverlay() {
93
93
  const { isPlaceholder } = this.props;
94
94
  const { editMode } = this.context;
95
+ if (editMode && this.props.item.data._editActive) {
96
+ // needed for correst pointer-events: none work in firefox
97
+ return React.createElement("div", { className: b('overlay-placeholder') });
98
+ }
95
99
  if (!editMode || this.props.item.data._editActive || isPlaceholder) {
96
100
  return null;
97
101
  }
@@ -105,6 +109,7 @@ class GridItem extends React.PureComponent {
105
109
  // https://github.com/STRML/react-grid-layout/issues/721
106
110
  const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, isDraggedOut, noOverlay, focusable, withCustomHandle, isPlaceholder = false, } = this.props;
107
111
  const { editMode } = this.context;
112
+ const { isFocused } = this.state;
108
113
  const width = Number.parseInt(style.width, 10);
109
114
  const height = Number.parseInt(style.height, 10);
110
115
  const transform = style.transform;
@@ -114,24 +119,26 @@ class GridItem extends React.PureComponent {
114
119
  .replace('react-resizable', '')
115
120
  .replace('react-draggable', '')
116
121
  .replace(FOCUSED_CLASS_NAME, '')) +
117
- (this.state.isFocused ? ` ${FOCUSED_CLASS_NAME}` : '');
122
+ (isFocused ? ` ${FOCUSED_CLASS_NAME}` : '');
123
+ const computedClassName = b({
124
+ 'is-dragging': isDragging,
125
+ 'is-dragged-out': isDraggedOut,
126
+ 'is-focused': isFocused,
127
+ 'with-custom-handle': withCustomHandle,
128
+ }, preparedClassName);
118
129
  const preparedChildren = editMode ? children : null;
119
130
  const reactGridLayoutProps = editMode
120
131
  ? { onMouseDown, onMouseUp, onTouchEnd, onTouchStart }
121
132
  : {};
122
- const { _editActive } = this.props.item.data;
123
- return (React.createElement("div", Object.assign({ className: b({
124
- 'is-dragging': isDragging,
125
- 'is-dragged-out': isDraggedOut,
126
- 'is-focused': this.state.isFocused,
127
- 'with-custom-handle': withCustomHandle,
128
- }, preparedClassName), "data-qa": "dashkit-grid-item", style: style, ref: this.props.forwardedRef }, reactGridLayoutProps, (focusable
133
+ const reactFocusProps = focusable
129
134
  ? {
130
135
  onFocus: this.onFocusHandler,
131
136
  onBlur: this.onBlurHandler,
132
137
  tabIndex: -1,
133
138
  }
134
- : {})),
139
+ : {};
140
+ const { _editActive } = this.props.item.data;
141
+ return (React.createElement("div", Object.assign({ className: computedClassName, "data-qa": "dashkit-grid-item", style: style, ref: this.props.forwardedRef }, reactGridLayoutProps, reactFocusProps),
135
142
  React.createElement("div", { className: b('item', { editMode: editMode && !_editActive && !noOverlay }) },
136
143
  React.createElement(Item, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, isPlaceholder: isPlaceholder, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef, onItemMountChange: this.props.onItemMountChange, onItemRender: this.props.onItemRender, gridLayout: this.props.gridLayout })),
137
144
  !noOverlay && this.renderOverlay(),
@@ -289,7 +289,12 @@ class GridLayout extends React.PureComponent {
289
289
  const item = temporaryLayout
290
290
  ? temporaryLayout.dragProps
291
291
  : this.context.config.items.find(({ id }) => id === layoutId);
292
- const { offsetX, offsetY } = e.nativeEvent;
292
+ let { offsetX, offsetY } = e.nativeEvent || {};
293
+ if (offsetX === undefined || offsetY === undefined) {
294
+ const gridRect = e.currentTarget.getBoundingClientRect();
295
+ offsetX = e.clientX - gridRect.left;
296
+ offsetY = e.clientY - gridRect.top;
297
+ }
293
298
  currentDraggingElement = {
294
299
  group,
295
300
  layoutItem,
@@ -90,6 +90,15 @@ class DragOverLayout extends ReactGridLayout {
90
90
  };
91
91
  this.mouseMoveHandler = (e) => {
92
92
  if (this.props.hasSharedDragItem) {
93
+ if (!e.nativeEvent) {
94
+ // Emulate nativeEvent for firefox
95
+ const target = this.getInnerElement() || e.target;
96
+ e.nativeEvent = {
97
+ clientX: e.clientX,
98
+ clientY: e.clientY,
99
+ target,
100
+ };
101
+ }
93
102
  this.onDragOver(e);
94
103
  }
95
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "8.26.0",
3
+ "version": "8.26.1",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {