react-reorder-list 0.8.0 → 0.8.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/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Sahil Aggawal, <aggarwalsahil2004@gmail.com>
3
+ Copyright (c) Sahil Aggawal, <aggarwalsahil2004@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
7
7
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
8
 
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -212,6 +212,6 @@ type PositionChangeParams = {
212
212
  type PositionChangeHandler = (params?: PositionChangeParams) => void;
213
213
  ```
214
214
 
215
- ## Author
215
+ ## License
216
216
 
217
- [Sahil Aggarwal](https://www.github.com/SahilAggarwal2004)
217
+ This project is licensed under the [MIT License](LICENSE).
package/dist/animation.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useState, useLayoutEffect, Children } from "react";
2
- import { usePrevious } from "./hooks.js";
1
+ import { useLayoutEffect, Children } from "react";
2
+ import { useStateWithHistory } from "./hooks.js";
3
3
  import { getKey } from "./utils.js";
4
4
  function calculateBoundingBoxes(children) {
5
5
  const boundingBoxes = {};
@@ -11,8 +11,7 @@ function calculateBoundingBoxes(children) {
11
11
  return boundingBoxes;
12
12
  }
13
13
  export default function Animation({ duration, children }) {
14
- const [boundingBox, setBoundingBox] = useState({});
15
- const prevBoundingBox = usePrevious(boundingBox);
14
+ const [boundingBox, prevBoundingBox, setBoundingBox] = useStateWithHistory({});
16
15
  useLayoutEffect(() => {
17
16
  if (duration > 0)
18
17
  setBoundingBox(calculateBoundingBoxes(children));
package/dist/hooks.d.ts CHANGED
@@ -4,4 +4,4 @@ export declare function useDraggable(initValue?: boolean): readonly [boolean, {
4
4
  onTouchStart: () => void;
5
5
  onTouchEnd: () => void;
6
6
  }];
7
- export declare function usePrevious<T>(value: T): T | null;
7
+ export declare function useStateWithHistory<T>(initValue: T): readonly [T, T | undefined, (value: T) => void];
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef, useState } from "react";
1
+ import { useState } from "react";
2
2
  export function useDraggable(initValue = false) {
3
3
  const [draggable, setDraggable] = useState(initValue);
4
4
  const enableDragging = () => setDraggable(true);
@@ -6,10 +6,12 @@ export function useDraggable(initValue = false) {
6
6
  const draggableProps = { onMouseEnter: enableDragging, onMouseLeave: disableDragging, onTouchStart: enableDragging, onTouchEnd: disableDragging };
7
7
  return [draggable, draggableProps];
8
8
  }
9
- export function usePrevious(value) {
10
- const prevChildrenRef = useRef(null);
11
- useEffect(() => {
12
- prevChildrenRef.current = value;
13
- }, [value]);
14
- return prevChildrenRef.current;
9
+ export function useStateWithHistory(initValue) {
10
+ const [state, setState] = useState(initValue);
11
+ const [prevState, setPrevState] = useState();
12
+ function setStateWithHistory(value) {
13
+ setPrevState(state);
14
+ setState(value);
15
+ }
16
+ return [state, prevState, setStateWithHistory];
15
17
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CSSProperties, DetailedHTMLProps, DragEventHandler, HTMLAttributes, JSX, ReactNode, RefObject, TouchEventHandler } from "react";
2
2
  export type Props = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
3
- export type PositionChangeHandler = (params?: {
3
+ export type PositionChangeHandler = (event: {
4
4
  start?: number;
5
5
  end?: number;
6
6
  oldItems?: ReactNode[];
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "react-reorder-list",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "A simple react component that facilitates the reordering of JSX/HTML elements through drag-and-drop functionality, allowing for easy position changes.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
- "scripts": {
9
- "build": "bun i && tsc"
10
- },
11
8
  "repository": {
12
9
  "type": "git",
13
10
  "url": "git+https://github.com/SahilAggarwal2004/react-reorder-list.git"
@@ -29,12 +26,16 @@
29
26
  },
30
27
  "homepage": "https://github.com/SahilAggarwal2004/react-reorder-list#readme",
31
28
  "peerDependencies": {
32
- "react": ">=17.0.0"
29
+ "react": "^19.0.0"
33
30
  },
34
31
  "devDependencies": {
35
- "@types/react": "^19.0.0"
32
+ "@types/react": "^19.1.3",
33
+ "typescript": "^5.8.3"
36
34
  },
37
35
  "dependencies": {
38
36
  "drag-drop-touch": "^1.3.1"
37
+ },
38
+ "scripts": {
39
+ "build": "pnpm i && tsc"
39
40
  }
40
- }
41
+ }
package/CHANGELOG.md DELETED
@@ -1,56 +0,0 @@
1
- # 0.8.0 (06-12-2024)
2
-
3
- - **breaking:** Dropped support for React.js v18 in favor of React.js v19.
4
-
5
- ## 0.7.2 (16-04-2024)
6
-
7
- - **change:** Switched from [pnpm](https://pnpm.io/) to [bun](https://bun.sh).
8
-
9
- ## 0.7.0 (24-03-2024)
10
-
11
- - **feat:** Added `data-disable-reorder` prop for children of the `<ReorderList>` component. See [usage with data-disable-reorder](https://www.npmjs.com/package/react-reorder-list#disable-reordering-for-individual-children).
12
-
13
- ## 0.6.7 (21-03-2024)
14
-
15
- - **remove:** Support for invalid React elements.
16
-
17
- ## 0.6.3 (05-02-2024)
18
-
19
- - **fix:** Minor scrolling bug occurring on touch devices.
20
-
21
- ## 0.6.1 (03-02-2024)
22
-
23
- - **fix:** Minor bugs.
24
-
25
- ## 0.6.0 (27-01-2024)
26
-
27
- - **feat:** Added support for touch devices.
28
-
29
- ## 0.5.0 (26-01-2024)
30
-
31
- - **feat:** Added `preserveOrder` prop in the `<ReorderList>` component. See [ReorderList Component API Reference](https://www.npmjs.com/package/react-reorder-list#reorderlist-component-api-reference).
32
- - **fix:** A bug where the library would not work in production if `useOnlyIconToDrag` was set to `true`.
33
-
34
- ## 0.4.0 (26-01-2024)
35
-
36
- - **feat:** Added `revert` handler/function in the params of the `onPositionChange` handler. See type [PositionChangeHandler](https://www.npmjs.com/package/react-reorder-list#positionchangehandler).
37
-
38
- ## 0.3.1 (25-01-2024)
39
-
40
- - **change:** Renamed `disable` prop to `disabled`. See [ReorderList Component API Reference](https://www.npmjs.com/package/react-reorder-list#reorderlist-component-api-reference).
41
- - **fixed:** Minor bugs.
42
-
43
- ## 0.3.0 (24-01-2024)
44
-
45
- - **feat:** Added `watchChildrenUpdates` prop in `<ReorderList>`. See [ReorderList Component API Reference](https://www.npmjs.com/package/react-reorder-list#reorderlist-component-api-reference).
46
- - **improve:** Overall stability.
47
-
48
- ## 0.2.0 (23-01-2024)
49
-
50
- - **feat:** Added `animationDuration` prop in `<ReorderList>` component. See [ReorderList Component API Reference](https://www.npmjs.com/package/react-reorder-list#reorderlist-component-api-reference).
51
- - **change:** Default value of the `useOnlyIconToDrag` prop to `false`. See [ReorderList Component API Reference](https://www.npmjs.com/package/react-reorder-list#reorderlist-component-api-reference).
52
- - **improve:** Overall stability.
53
-
54
- ## 0.1.2 (21-01-2024)
55
-
56
- - **docs:** Added more details on [usage with ReorderIcon](https://www.npmjs.com/package/react-reorder-list#usage-with-reordericon).