@hrnec06/react_utils 1.4.1 → 1.4.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hrnec06/react_utils",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "A debugger component for react.",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -100,29 +100,32 @@ function DragArea({
100
100
  onMove,
101
101
  applyReposition = false,
102
102
 
103
- ...enabledSides
103
+ ...assignedSides
104
104
  }: DragAreaProps)
105
105
  {
106
106
  const box = useResizeableBox();
107
107
 
108
108
  const isAllowed = (side: RB.DragSide) => box.options.allowedSides.includes(side);
109
109
 
110
+ // Is a corner and allowCorners are either empty or false
110
111
  if (isCorner && !box.options.allowCorners)
111
112
  return undefined;
112
113
 
113
- if (
114
- (enabledSides.top && !isAllowed('top')) ||
115
- (enabledSides.right && !isAllowed('right')) ||
116
- (enabledSides.bottom && !isAllowed('bottom')) ||
117
- (enabledSides.left && !isAllowed('left'))
118
- )
119
- return undefined;
120
-
114
+ // Is corner and allowedCorners are array
121
115
  if (isCorner && Array.isArray(box.options.allowCorners))
122
116
  {
123
- if (!box.options.allowCorners.some((combo) => enabledSides[combo[0]] && enabledSides[combo[1]]))
117
+ if (!box.options.allowCorners.some((combo) => assignedSides[combo[0]] && assignedSides[combo[1]]))
124
118
  return undefined;
125
119
  }
120
+ else if (
121
+ (assignedSides.top && !isAllowed('top')) ||
122
+ (assignedSides.right && !isAllowed('right')) ||
123
+ (assignedSides.bottom && !isAllowed('bottom')) ||
124
+ (assignedSides.left && !isAllowed('left'))
125
+ )
126
+ {
127
+ return undefined;
128
+ }
126
129
 
127
130
  const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {
128
131
  if (box.drag.value !== null || !matchMouseEvent(e.nativeEvent, MouseButton.Left))
@@ -160,21 +163,21 @@ function DragArea({
160
163
  box.options.dragAreaSize === 'big' && 'w-6'
161
164
  ),
162
165
 
163
- enabledSides.top && clsx('bottom-full', box.options.insetAreas && 'translate-y-1/2'),
164
- enabledSides.right && clsx('left-full', box.options.insetAreas && '-translate-x-1/2'),
165
- enabledSides.bottom && clsx('top-full', box.options.insetAreas && '-translate-y-1/2'),
166
- enabledSides.left && clsx('right-full', box.options.insetAreas && 'translate-x-1/2'),
166
+ assignedSides.top && clsx('bottom-full', box.options.insetAreas && 'translate-y-1/2'),
167
+ assignedSides.right && clsx('left-full', box.options.insetAreas && '-translate-x-1/2'),
168
+ assignedSides.bottom && clsx('top-full', box.options.insetAreas && '-translate-y-1/2'),
169
+ assignedSides.left && clsx('right-full', box.options.insetAreas && 'translate-x-1/2'),
167
170
 
168
171
  matchBool({
169
- "cursor-nw-resize": enabledSides.top && enabledSides.left,
170
- "cursor-ne-resize": enabledSides.top && enabledSides.right,
171
- "cursor-se-resize": enabledSides.bottom && enabledSides.right,
172
- "cursor-sw-resize": enabledSides.bottom && enabledSides.left,
173
-
174
- "cursor-n-resize": enabledSides.top,
175
- "cursor-e-resize": enabledSides.right,
176
- "cursor-s-resize": enabledSides.bottom,
177
- "cursor-w-resize": enabledSides.left
172
+ "cursor-nw-resize": assignedSides.top && assignedSides.left,
173
+ "cursor-ne-resize": assignedSides.top && assignedSides.right,
174
+ "cursor-se-resize": assignedSides.bottom && assignedSides.right,
175
+ "cursor-sw-resize": assignedSides.bottom && assignedSides.left,
176
+
177
+ "cursor-n-resize": assignedSides.top,
178
+ "cursor-e-resize": assignedSides.right,
179
+ "cursor-s-resize": assignedSides.bottom,
180
+ "cursor-w-resize": assignedSides.left
178
181
  }),
179
182
  )}
180
183
  />
@@ -32,8 +32,12 @@ interface ResizeableBoxProps extends React.HTMLProps<HTMLDivElement>
32
32
  */
33
33
  $allowedSides?: RB.DragSide[],
34
34
  /**
35
- * Allow corner resizers?
36
- * A corner will be visible only if the 2 neighbouring sides are visible
35
+ * Allow corner resizers
36
+ *
37
+ * Possible values:
38
+ * - `true`: Corners will be applied automatically based on allowed sides
39
+ * - `false`: No corners
40
+ * - `Vector2<RB.DragSide>[]`: Explicitely define allowed corners
37
41
  */
38
42
  $allowCorners?: boolean | Vector2<RB.DragSide>[],
39
43
  /**