react-native-drax 0.10.2 → 0.11.0-alpha.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.
Files changed (48) hide show
  1. package/.eslintrc.js +2 -73
  2. package/.prettierrc +16 -0
  3. package/CHANGELOG.md +8 -1
  4. package/README.md +81 -1
  5. package/build/AllHoverViews.d.ts +0 -0
  6. package/build/AllHoverViews.js +30 -0
  7. package/build/DraxContext.d.ts +0 -1
  8. package/build/DraxList.d.ts +3 -3
  9. package/build/DraxList.js +231 -216
  10. package/build/DraxListItem.d.ts +7 -0
  11. package/build/DraxListItem.js +121 -0
  12. package/build/DraxProvider.d.ts +1 -3
  13. package/build/DraxProvider.js +322 -259
  14. package/build/DraxScrollView.d.ts +1 -1
  15. package/build/DraxScrollView.js +29 -90
  16. package/build/DraxSubprovider.d.ts +2 -2
  17. package/build/DraxSubprovider.js +1 -1
  18. package/build/DraxView.d.ts +7 -2
  19. package/build/DraxView.js +61 -384
  20. package/build/HoverView.d.ts +8 -0
  21. package/build/HoverView.js +40 -0
  22. package/build/PanGestureDetector.d.ts +3 -0
  23. package/build/PanGestureDetector.js +49 -0
  24. package/build/hooks/useContent.d.ts +23 -0
  25. package/build/hooks/useContent.js +212 -0
  26. package/build/hooks/useDraxProtocol.d.ts +5 -0
  27. package/build/hooks/useDraxProtocol.js +32 -0
  28. package/build/hooks/useDraxRegistry.d.ts +21 -20
  29. package/build/hooks/useDraxRegistry.js +195 -182
  30. package/build/hooks/useDraxScrollHandler.d.ts +25 -0
  31. package/build/hooks/useDraxScrollHandler.js +89 -0
  32. package/build/hooks/useDraxState.d.ts +1 -1
  33. package/build/hooks/useDraxState.js +9 -6
  34. package/build/hooks/useMeasurements.d.ts +8 -0
  35. package/build/hooks/useMeasurements.js +118 -0
  36. package/build/hooks/useStatus.d.ts +11 -0
  37. package/build/hooks/useStatus.js +96 -0
  38. package/build/index.d.ts +2 -0
  39. package/build/index.js +4 -1
  40. package/build/math.d.ts +2 -2
  41. package/build/math.js +14 -10
  42. package/build/params.d.ts +9 -0
  43. package/build/params.js +7 -1
  44. package/build/transform.d.ts +11 -4
  45. package/build/transform.js +50 -8
  46. package/build/types.d.ts +238 -87
  47. package/build/types.js +10 -7
  48. package/package.json +43 -45
package/.eslintrc.js CHANGED
@@ -1,75 +1,4 @@
1
1
  module.exports = {
2
- root: true,
3
- parser: '@typescript-eslint/parser',
4
- parserOptions: {
5
- project: [
6
- './tsconfig.json',
7
- ],
8
- ecmaFeatures: {
9
- jsx: true,
10
- },
11
- },
12
- plugins: [
13
- '@typescript-eslint',
14
- 'react',
15
- 'react-native',
16
- 'react-hooks',
17
- ],
18
- extends: [
19
- // 'plugin:@typescript-eslint/recommended', <-- consider this when time permits
20
- 'plugin:react/recommended',
21
- 'plugin:react-native/all',
22
- 'airbnb-typescript',
23
- ],
24
- env: {
25
- es6: true,
26
- jest: true,
27
- 'react-native/react-native': true,
28
- },
29
- settings: {
30
- react: {
31
- version: 'detect',
32
- },
33
- },
34
- rules: {
35
- 'no-undef': 0, // TS handles this; https://github.com/eslint/eslint/issues/13699#issuecomment-694223066
36
- 'no-tabs': 0,
37
- 'no-shadow': 0,
38
- 'arrow-body-style': 0,
39
- 'arrow-parens': [2, 'always'],
40
- 'no-console': 0,
41
- 'max-len': [2, {
42
- code: 120,
43
- tabWidth: 4,
44
- ignoreComments: true,
45
- ignoreUrls: true,
46
- ignoreStrings: true,
47
- ignoreTemplateLiterals: true,
48
- ignoreRegExpLiterals: true,
49
- }],
50
- '@typescript-eslint/indent': [2, 'tab', { SwitchCase: 1 }],
51
- '@typescript-eslint/no-use-before-define': [2, { variables: false }],
52
- 'import/no-unresolved': 0, // ts already provides errors for this and updates more quickly in VSCode
53
- 'import/prefer-default-export': 0,
54
- 'import/no-extraneous-dependencies': [2, { devDependencies: true }], // allows import of type def libs
55
- 'react/destructuring-assignment': 0,
56
- 'react/jsx-props-no-spreading': 0,
57
- 'react/jsx-indent': [2, 'tab'],
58
- 'react/jsx-indent-props': [2, 'tab'],
59
- 'react/jsx-one-expression-per-line': 0,
60
- 'react/no-unused-state': 0,
61
- 'react/prop-types': 0,
62
- 'react/require-default-props': 0,
63
- 'react/no-unused-prop-types': 0,
64
- 'react/sort-comp': 0,
65
- 'react/state-in-constructor': 0,
66
- 'react-native/sort-styles': 0,
67
- 'react-native/no-color-literals': 0,
68
- 'react-hooks/rules-of-hooks': 2,
69
- 'react-hooks/exhaustive-deps': 1,
70
- '@typescript-eslint/comma-dangle': [2, "always-multiline"],
71
- },
72
- ignorePatterns: [
73
- '.eslintrc.js',
74
- ],
2
+ extends: ['universe/web', 'universe/native'],
3
+ plugins: ['prettier'],
75
4
  };
package/.prettierrc ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "bracketSameLine": false,
4
+ "printWidth": 120,
5
+ "useTabs": false,
6
+ "semi": true,
7
+ "singleQuote": true,
8
+ "trailingComma": "es5",
9
+ "bracketSpacing": true,
10
+ "rangeStart": 0,
11
+ "rangeEnd": 9007199254740991,
12
+ "requirePragma": false,
13
+ "insertPragma": false,
14
+ "proseWrap": "preserve",
15
+ "endOfLine": "auto"
16
+ }
package/CHANGELOG.md CHANGED
@@ -9,6 +9,12 @@ Changes marked as (BREAKING) may break your app logic. Changes marked as (BREAKI
9
9
  ## [Unreleased]
10
10
  - Nothing yet
11
11
 
12
+
13
+ ## [0.10.3] - 2022-09-06
14
+
15
+ ### Fixed
16
+ - Fix clipping sizes to properly take position into account (#151) - Thank you @FrancoisDupayrat!
17
+
12
18
  ## [0.10.2] - 2022-06-10
13
19
 
14
20
  ### Added
@@ -235,7 +241,8 @@ Changes marked as (BREAKING) may break your app logic. Changes marked as (BREAKI
235
241
 
236
242
  *(More history to be added later?)*
237
243
 
238
- [Unreleased]: https://github.com/nuclearpasta/react-native-drax/compare/v0.10.2...HEAD
244
+ [Unreleased]: https://github.com/nuclearpasta/react-native-drax/compare/v0.10.3...HEAD
245
+ [0.10.3]: https://github.com/nuclearpasta/react-native-drax/compare/v0.10.2...v0.10.3
239
246
  [0.10.2]: https://github.com/nuclearpasta/react-native-drax/compare/v0.10.1...v0.10.2
240
247
  [0.10.1]: https://github.com/nuclearpasta/react-native-drax/compare/v0.10.0...v0.10.1
241
248
  [0.10.0]: https://github.com/nuclearpasta/react-native-drax/compare/v0.9.3...v0.10.0
package/README.md CHANGED
@@ -11,7 +11,33 @@
11
11
 
12
12
  Drax is a declarative drag-and-drop system for React Native, written in TypeScript. It is designed to be flexible and powerful with the goal of supporting many use cases, while its stock components and default settings should cover the most common scenarios with minimal configuration.
13
13
 
14
- **Note: as of version 0.10.0, React Native 0.65 or higher is required. For RN 0.62-0.64 projects, you may be able to use 0.9.3, but it will no longer be supported. For RN 0.61 projects, you may be able to use 0.6.0, but it will no longer be supported.**
14
+ **Note: We currently only support the latest Expo and React Native versions. Other older version might work just fine, but we won't respond to bug reports or feature requests for them.**
15
+
16
+ ### Experimental Alpha Version (v0.11.0)
17
+
18
+ An experimental alpha version is now available that introduces significant updates and breaking changes. This version focuses on:
19
+
20
+ - Integration with latest React Native Reanimated and React Native Gesture Handler by SoftwareMansion
21
+ - Enhanced animation performance and capabilities
22
+ - Works with New Architecture
23
+
24
+ **Installation:** To install the experimental alpha version:
25
+
26
+ ```bash
27
+ # npm
28
+ npm install react-native-drax@alpha
29
+
30
+ # or yarn
31
+ yarn add react-native-drax@alpha
32
+ ```
33
+
34
+ You'll also need to ensure you have the required peer dependencies:
35
+
36
+ ```bash
37
+ yarn add react-native-reanimated react-native-gesture-handler
38
+ ```
39
+
40
+ **Important:** This alpha version contains breaking changes, especially to the `DraxList` component. See the [Alpha Version Breaking Changes](#alpha-version-breaking-changes) section for details.
15
41
 
16
42
  *Personal note from Joe: this project is in need of additional [contributors/shepherds](#contributing). I have not been focused on React Native over the past year, and the state of the library has fallen behind the times. At a minimum, it should be updated to use the latest RNGH and take advantage of any fixes and new features in that and RN. I apologize that I do not have the availability to maintain this project to my own high standards and thank everyone who has been understanding of that.*
17
43
 
@@ -19,6 +45,7 @@ Drax is a declarative drag-and-drop system for React Native, written in TypeScri
19
45
 
20
46
  * [Screenshots](#screenshots)
21
47
  * [Status](#status)
48
+ * [Alpha Version Breaking Changes](#alpha-version-breaking-changes)
22
49
  * [Background](#background)
23
50
  * [Concept](#concept)
24
51
  * [Installation](#installation)
@@ -47,6 +74,59 @@ This library adheres to [Semantic Versioning (semver)](https://semver.org/) and
47
74
 
48
75
  The author of this library has not had significant availability to work on it for quite a while now, due to higher priority life and work concerns. Newer versions of Drax's major dependencies have been released in that time, and many people have opened issues asking questions about usage and potential features. Relatively small fixes and easy questions are handled reasonably often, but ultimately another round of research, testing, and architecture are what would take this library to the next level of usability. It is not clear when that might happen, but [contributors are welcome](#contributing).
49
76
 
77
+ <a name="alpha-version-breaking-changes"></a>
78
+ ## Alpha Version Breaking Changes
79
+
80
+ The experimental alpha version (v0.11.0) includes significant updates to modernize the library and improve performance. However, these changes introduce breaking changes, particularly to the `DraxList` component.
81
+
82
+ ### DraxList Breaking Changes
83
+
84
+ - `renderItem` property signature receives different props than before and has replaced `renderItemContent` and `renderHoverContent`
85
+ - Receives incoming external drag items inside the list.
86
+ - Added `monitoringExternalDragStyle` prop for styling during incoming external drags
87
+ - `parentDraxViewProps` prop for customizing the parent DraxView wrapping the FlatList. You should use this prop if you were using the `style` prop on `DraxList`. (see example below)
88
+
89
+ ### DraxListItem Component
90
+
91
+ The alpha version introduces a new `DraxListItem` component that works with `DraxList` to simplify implementation of reorderable lists. This component handles animations, measurement caching, and shift calculations internally.
92
+
93
+ #### Usage Example
94
+
95
+ ```jsx
96
+ import { DraxList, DraxListItem } from 'react-native-drax';
97
+
98
+ const MyReorderableList = () => (
99
+ <DraxList
100
+ data={items}
101
+ // BREAKING CHANGE: `style` prop is now applied to internal FlatList, not to the parent DraxView
102
+ style={styles.list}
103
+
104
+ // should use this prop if you were using the `style` prop on `DraxList` on v0.10.3.
105
+ parentDraxViewProps={{
106
+ style: styles.list,
107
+ }}
108
+ renderItem={(info, itemProps) => (
109
+ <DraxListItem
110
+ itemProps={itemProps}
111
+ style={styles.listItem}
112
+ draggingStyle={styles.itemDragging}
113
+ dragReleasedStyle={styles.itemReleased}
114
+ // Any other DraxView props
115
+ >
116
+ <Text>{info.item.text}</Text>
117
+ </DraxListItem>
118
+ )}
119
+ onItemReorder={({fromIndex, toIndex}) => {
120
+ // Update your data here
121
+ const newData = [...items];
122
+ const item = newData.splice(fromIndex, 1)[0];
123
+ newData.splice(toIndex, 0, item);
124
+ setItems(newData);
125
+ }}
126
+ />
127
+ );
128
+ ```
129
+
50
130
  <a name="background"></a>
51
131
  ## Background
52
132
 
File without changes
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // import React, { useMemo } from "react";
3
+ //
4
+ // import { ReanimatedHoverView } from "./HoverView";
5
+ // import { useDraxContext } from "./hooks";
6
+ //
7
+ // export const AllHoverViews = ({ allViewIds }: { allViewIds: string[] }) => {
8
+ // const { getHoverItems } = useDraxContext();
9
+ //
10
+ // const hoverViews = useMemo(
11
+ // () => allViewIds && getHoverItems(allViewIds),
12
+ // [allViewIds, getHoverItems],
13
+ // );
14
+ // // const updateHoverViews = () => {
15
+ // // console.log('getAllViewIds()', allViewIds);
16
+ // // console.log('getHoverItems(getAllViewIds())', allViewIds && getHoverItems(allViewIds));
17
+ // // allViewIds && setAllHoverViews(getHoverItems(allViewIds));
18
+ // // };
19
+ // return hoverViews?.map(
20
+ // (viewData, index) =>
21
+ // viewData?.protocol.hoverPosition?.value && (
22
+ // <ReanimatedHoverView
23
+ // key={viewData.id || index}
24
+ // hoverPosition={viewData?.protocol.hoverPosition}
25
+ // scrollPosition={viewData?.scrollPosition}
26
+ // {...(viewData?.protocol || {})}
27
+ // />
28
+ // ),
29
+ // );
30
+ // };
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { DraxContextValue } from './types';
3
2
  export declare const DraxContext: import("react").Context<DraxContextValue | undefined>;
@@ -1,8 +1,8 @@
1
- import { PropsWithChildren, Ref } from 'react';
1
+ import { PropsWithChildren, ReactNode, Ref } from 'react';
2
2
  import { FlatList } from 'react-native';
3
3
  import { DraxListProps } from './types';
4
- declare type DraxListType = <T extends unknown>(props: PropsWithChildren<DraxListProps<T>> & {
4
+ type DraxListType = <T extends unknown>(props: PropsWithChildren<DraxListProps<T>> & {
5
5
  ref?: Ref<FlatList>;
6
- }) => JSX.Element;
6
+ }) => ReactNode;
7
7
  export declare const DraxList: DraxListType;
8
8
  export {};