@homecode/ui 4.22.5 → 4.22.7

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,18 @@
1
+ import * as React from 'react';
2
+
3
+ var _path, _path2;
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 SvgCheckers = function SvgCheckers(props) {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ viewBox: "0 0 200 150"
9
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
10
+ fill: "#fff",
11
+ fillOpacity: 0.8,
12
+ d: "M0 0h200v150H0z"
13
+ })), _path2 || (_path2 = /*#__PURE__*/React.createElement("path", {
14
+ d: "M0 0h50v50H0zm100 0h50v50h-50zM50 50h50v50H50zm100 0h50v50h-50zM0 100h50v50H0zm100 0h50v50h-50z"
15
+ })));
16
+ };
17
+
18
+ export { SvgCheckers as default };
@@ -2,14 +2,14 @@ import * as React from 'react';
2
2
 
3
3
  var _linearGradient, _path;
4
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 SvgCompas = function SvgCompas(props) {
5
+ var SvgCompass = function SvgCompass(props) {
6
6
  return /*#__PURE__*/React.createElement("svg", _extends({
7
7
  xmlns: "http://www.w3.org/2000/svg",
8
8
  xmlnsXlink: "http://www.w3.org/1999/xlink",
9
9
  fill: "currentColor",
10
10
  viewBox: "0 0 24 24"
11
11
  }, props), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
12
- id: "compas_svg__a"
12
+ id: "compass_svg__a"
13
13
  }, /*#__PURE__*/React.createElement("stop", {
14
14
  offset: 0,
15
15
  style: {
@@ -35,8 +35,8 @@ var SvgCompas = function SvgCompas(props) {
35
35
  stopOpacity: 1
36
36
  }
37
37
  })), _linearGradient || (_linearGradient = /*#__PURE__*/React.createElement("linearGradient", {
38
- xlinkHref: "#compas_svg__a",
39
- id: "compas_svg__b",
38
+ xlinkHref: "#compass_svg__a",
39
+ id: "compass_svg__b",
40
40
  x1: 16.621,
41
41
  x2: 40.144,
42
42
  y1: 9.343,
@@ -48,9 +48,9 @@ var SvgCompas = function SvgCompas(props) {
48
48
  })), /*#__PURE__*/React.createElement("path", {
49
49
  d: "M12.06.27c-.589 0-.96.601-1.7 1.8-1.872 3.052-4.625 7.886-4.626 9.96s2.744 6.917 4.611 9.97c.735 1.202 1.105 1.804 1.694 1.803.588 0 .958-.602 1.698-1.8 1.873-3.053 4.627-7.886 4.627-9.96.001-2.074-2.743-6.914-4.611-9.964C13.018.873 12.648.268 12.059.269",
50
50
  style: {
51
- fill: "url(#compas_svg__b)"
51
+ fill: "url(#compass_svg__b)"
52
52
  }
53
53
  }));
54
54
  };
55
55
 
56
- export { SvgCompas as default };
56
+ export { SvgCompass as default };
@@ -8,8 +8,9 @@ var ICONS = {
8
8
  check: () => import('./check.svg.js'),
9
9
  close: () => import('./close.svg.js'),
10
10
  colors: () => import('./colors.svg.js'),
11
- compas: () => import('./compas.svg.js'),
11
+ compass: () => import('./compass.svg.js'),
12
12
  copy: () => import('./copy.svg.js'),
13
+ checkers: () => import('./checkers.svg.js'),
13
14
  chevronUp: () => import('./chevronUp.svg.js'),
14
15
  chevronDown: () => import('./chevronDown.svg.js'),
15
16
  chevronRight: () => import('./chevronRight.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;
@@ -8,8 +8,9 @@ declare const _default: {
8
8
  check: () => Promise<any>;
9
9
  close: () => Promise<any>;
10
10
  colors: () => Promise<any>;
11
- compas: () => Promise<any>;
11
+ compass: () => Promise<any>;
12
12
  copy: () => Promise<any>;
13
+ checkers: () => Promise<any>;
13
14
  chevronUp: () => Promise<any>;
14
15
  chevronDown: () => Promise<any>;
15
16
  chevronRight: () => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.22.5",
3
+ "version": "4.22.7",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "jest",