@homecode/ui 4.22.6 → 4.22.8

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.
@@ -30,10 +30,23 @@ class Draggable extends Component {
30
30
  if (prevProps.items.join(',') !== this.props.items.join(',')) {
31
31
  this.dropUnder();
32
32
  }
33
+ if (prevProps.disabled !== this.props.disabled) {
34
+ this.dropUnder();
35
+ if (this.props.disabled)
36
+ this.unsubscribeMoveUp();
37
+ }
33
38
  }
34
39
  componentWillUnmount() {
35
40
  this.timers.clear();
36
41
  }
42
+ subscribeMoveUp = () => {
43
+ document.addEventListener('pointermove', this.onPointerMove);
44
+ document.addEventListener('pointerup', this.onPointerUp);
45
+ };
46
+ unsubscribeMoveUp = () => {
47
+ document.removeEventListener('pointermove', this.onPointerMove);
48
+ document.removeEventListener('pointerup', this.onPointerUp);
49
+ };
37
50
  onPointerDown = e => {
38
51
  const { clientX: x, clientY: y, currentTarget } = e;
39
52
  e.stopPropagation();
@@ -41,11 +54,10 @@ class Draggable extends Component {
41
54
  this.startPos = { x, y };
42
55
  this.draggingElem = currentTarget;
43
56
  this.draggingElemBounds = currentTarget.getBoundingClientRect();
44
- document.addEventListener('pointermove', this.onPointerMove);
45
- document.addEventListener('pointerup', this.onPointerUp);
57
+ this.subscribeMoveUp();
46
58
  };
47
59
  onPointerMove = e => {
48
- if (!this.draggingElem)
60
+ if (!this.draggingElem || this.props.disabled)
49
61
  return;
50
62
  const { clientX: x, clientY: y } = e;
51
63
  if (!this.store.draggingId) {
@@ -94,8 +106,7 @@ class Draggable extends Component {
94
106
  e.stopPropagation();
95
107
  e.preventDefault();
96
108
  }
97
- document.removeEventListener('pointermove', this.onPointerMove);
98
- document.removeEventListener('pointerup', this.onPointerUp);
109
+ this.unsubscribeMoveUp();
99
110
  this.dragStartFired = false;
100
111
  this.startPos = null;
101
112
  this.store.draggingId = null;
@@ -127,9 +138,9 @@ class Draggable extends Component {
127
138
  this.store.underOffset = null;
128
139
  }
129
140
  render() {
130
- const { items, className, itemClassName, renderItem, children } = this.props;
141
+ const { items, className, itemClassName, renderItem, children, disabled } = this.props;
131
142
  const { draggingId, underId, underOffset } = this.store;
132
- return (jsxs("div", { className: cn(S.root, draggingId && S.isDragging, className), children: [items.map((id, index) => (jsx("div", { "data-id": id, className: cn(S.item, itemClassName, id === draggingId && S.active), onPointerDown: this.onPointerDown, children: jsx("div", { className: S.inner, style: underId === id ? { transform: underOffset } : null, children: renderItem(id, index, id === draggingId) }) }, id))), children] }));
143
+ return (jsxs("div", { className: cn(S.root, draggingId && S.isDragging, className), children: [items.map((id, index) => (jsx("div", { "data-id": id, className: cn(S.item, itemClassName, id === draggingId && S.active), onPointerDown: disabled ? undefined : this.onPointerDown, children: jsx("div", { className: S.inner, style: underId === id ? { transform: underOffset } : null, children: renderItem(id, index, id === draggingId) }) }, id))), children] }));
133
144
  }
134
145
  }
135
146
 
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+
3
+ var _path;
4
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
+ var SvgDragHandlerHorizontal = function SvgDragHandlerHorizontal(props) {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ fill: "currentColor",
9
+ viewBox: "0 0 24 24"
10
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
11
+ d: "M16 9.293a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 20 9.297a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 16 9.293m-2-.003a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 10 9.286a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 14 9.29m-6-.007a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 4 9.28a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 8 9.283m8 6.01a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 20 15.297a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 16 15.293m-2-.003a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 10 15.286a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 14 15.29m-6-.007a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 4 15.28a2.006 2.006 0 0 0 1.998 2.002A2.006 2.006 0 0 0 8 15.283"
12
+ })));
13
+ };
14
+
15
+ export { SvgDragHandlerHorizontal as default };
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+
3
+ var _path;
4
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
+ var SvgDragHandlerVertical = function SvgDragHandlerVertical(props) {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ fill: "currentColor",
9
+ viewBox: "0 0 24 24"
10
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
11
+ d: "M14.995 16.288a2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002 2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002m.003-2A2.006 2.006 0 0 0 17 12.29a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 13 12.286a2.006 2.006 0 0 0 1.998 2.002m.007-6a2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002 2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002m-6.01 8a2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002 2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002m.003-2A2.006 2.006 0 0 0 11 12.29a2.006 2.006 0 0 0-1.998-2.002A2.006 2.006 0 0 0 7 12.286a2.006 2.006 0 0 0 1.998 2.002m.007-6a2.006 2.006 0 0 0 2.002-1.998 2.006 2.006 0 0 0-1.998-2.002 2.006 2.006 0 0 0-2.002 1.998 2.006 2.006 0 0 0 1.998 2.002"
12
+ })));
13
+ };
14
+
15
+ export { SvgDragHandlerVertical as default };
@@ -18,6 +18,8 @@ var ICONS = {
18
18
  clearAll: () => import('./clearAll.svg.js'),
19
19
  delete: () => import('./delete.svg.js'),
20
20
  draft: () => import('./draft.svg.js'),
21
+ dragHandlerHorizontal: () => import('./dragHandlerHorizontal.svg.js'),
22
+ dragHandlerVertical: () => import('./dragHandlerVertical.svg.js'),
21
23
  edit: () => import('./edit.svg.js'),
22
24
  email: () => import('./email.svg.js'),
23
25
  externalLink: () => import('./externalLink.svg.js'),
@@ -10,6 +10,8 @@ export declare class Draggable extends Component<T.Props> {
10
10
  constructor(props: any);
11
11
  componentDidUpdate(prevProps: any): void;
12
12
  componentWillUnmount(): void;
13
+ subscribeMoveUp: () => void;
14
+ unsubscribeMoveUp: () => void;
13
15
  onPointerDown: (e: any) => void;
14
16
  onPointerMove: (e: any) => void;
15
17
  checkUnderElem: any;
@@ -3,6 +3,7 @@ export type Props = {
3
3
  items: string[];
4
4
  className?: string;
5
5
  itemClassName?: string;
6
+ disabled?: boolean;
6
7
  renderItem: (id: string, index: number, isActive: boolean) => ReactNode;
7
8
  onDragStart?: (id: string) => void;
8
9
  onDragEnd?: (id: string) => void;
@@ -18,6 +18,8 @@ declare const _default: {
18
18
  clearAll: () => Promise<any>;
19
19
  delete: () => Promise<any>;
20
20
  draft: () => Promise<any>;
21
+ dragHandlerHorizontal: () => Promise<any>;
22
+ dragHandlerVertical: () => Promise<any>;
21
23
  edit: () => Promise<any>;
22
24
  email: () => Promise<any>;
23
25
  externalLink: () => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.22.6",
3
+ "version": "4.22.8",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "jest",