@lincle/react-native-interactive 0.4.0-next.18 → 0.4.0-next.19
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/dist/cjs/base.js +11 -1
- package/dist/cjs/base.js.map +1 -1
- package/dist/cjs/components/Edge/Path/index.js +5 -1
- package/dist/cjs/components/Edge/Path/index.js.map +1 -1
- package/dist/cjs/components/Edge/index.js +7 -2
- package/dist/cjs/components/Edge/index.js.map +1 -1
- package/dist/cjs/components/Edges/Connections/index.js +15 -13
- package/dist/cjs/components/Edges/Connections/index.js.map +1 -1
- package/dist/cjs/components/Edges/index.js +16 -10
- package/dist/cjs/components/Edges/index.js.map +1 -1
- package/dist/cjs/components/Graph/Grid/index.js +19 -17
- package/dist/cjs/components/Graph/Grid/index.js.map +1 -1
- package/dist/cjs/components/Graph/index.js +13 -7
- package/dist/cjs/components/Graph/index.js.map +1 -1
- package/dist/cjs/components/Interaction/index.js +23 -21
- package/dist/cjs/components/Interaction/index.js.map +1 -1
- package/dist/cjs/components/Node/Draggable.js +35 -33
- package/dist/cjs/components/Node/Draggable.js.map +1 -1
- package/dist/cjs/components/Node/MoveNode/index.js +18 -13
- package/dist/cjs/components/Node/MoveNode/index.js.map +1 -1
- package/dist/cjs/components/Node/PullNode/index.js +25 -20
- package/dist/cjs/components/Node/PullNode/index.js.map +1 -1
- package/dist/cjs/components/Node/index.js +42 -34
- package/dist/cjs/components/Node/index.js.map +1 -1
- package/dist/cjs/components/Nodes/Interaction/index.js +12 -10
- package/dist/cjs/components/Nodes/Interaction/index.js.map +1 -1
- package/dist/cjs/components/Nodes/index.js +11 -5
- package/dist/cjs/components/Nodes/index.js.map +1 -1
- package/dist/cjs/components/index.js +21 -5
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/index.js +18 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/shared.js +33 -2
- package/dist/cjs/shared.js.map +1 -1
- package/dist/esm/components/Interaction/index.js.map +1 -1
- package/package.json +22 -22
package/dist/cjs/base.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Path = exports.Nodes = exports.Node = exports.Grid = exports.Graph = exports.Edges = exports.Edge = void 0;
|
|
4
|
+
var react_native_base_1 = require("@lincle/react-native-base");
|
|
5
|
+
Object.defineProperty(exports, "Edge", { enumerable: true, get: function () { return react_native_base_1.Edge; } });
|
|
6
|
+
Object.defineProperty(exports, "Edges", { enumerable: true, get: function () { return react_native_base_1.Edges; } });
|
|
7
|
+
Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return react_native_base_1.Graph; } });
|
|
8
|
+
Object.defineProperty(exports, "Grid", { enumerable: true, get: function () { return react_native_base_1.Grid; } });
|
|
9
|
+
Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return react_native_base_1.Node; } });
|
|
10
|
+
Object.defineProperty(exports, "Nodes", { enumerable: true, get: function () { return react_native_base_1.Nodes; } });
|
|
11
|
+
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return react_native_base_1.Path; } });
|
|
2
12
|
//# sourceMappingURL=base.js.map
|
package/dist/cjs/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":";;;AAAA,+DAQmC;AAPjC,yGAAA,IAAI,OAAA;AACJ,0GAAA,KAAK,OAAA;AACL,0GAAA,KAAK,OAAA;AACL,yGAAA,IAAI,OAAA;AACJ,yGAAA,IAAI,OAAA;AACJ,0GAAA,KAAK,OAAA;AACL,yGAAA,IAAI,OAAA"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Path = void 0;
|
|
4
|
+
var base_1 = require("../../../base");
|
|
5
|
+
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return base_1.Path; } });
|
|
2
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Edge/Path/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Edge/Path/index.tsx"],"names":[],"mappings":";;;AAAA,sCAEuB;AADrB,4FAAA,IAAI,OAAA"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Path = exports.Edge = void 0;
|
|
4
|
+
var base_1 = require("../../base");
|
|
5
|
+
Object.defineProperty(exports, "Edge", { enumerable: true, get: function () { return base_1.Edge; } });
|
|
6
|
+
var Path_1 = require("./Path");
|
|
7
|
+
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return Path_1.Path; } });
|
|
3
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Edge/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Edge/index.tsx"],"names":[],"mappings":";;;AAAA,mCAEoB;AADlB,4FAAA,IAAI,OAAA;AAEN,+BAEgB;AADd,4FAAA,IAAI,OAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const shared_1 = require("../../../shared");
|
|
5
|
+
const Edge_1 = require("../../Edge");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const react_native_svg_1 = require("react-native-svg");
|
|
9
|
+
const { svgStyle } = react_native_1.StyleSheet.create({
|
|
8
10
|
svgStyle: {
|
|
9
11
|
height: '100%',
|
|
10
12
|
overflow: 'visible',
|
|
@@ -22,16 +24,16 @@ const Connections = ({ scale = 1, translate = {
|
|
|
22
24
|
x: 0,
|
|
23
25
|
y: 0
|
|
24
26
|
} }) => {
|
|
25
|
-
const connections = useConnections();
|
|
26
|
-
const paths = useMemo(() => {
|
|
27
|
+
const connections = (0, shared_1.useConnections)();
|
|
28
|
+
const paths = (0, react_1.useMemo)(() => {
|
|
27
29
|
return Object.keys(connections).map((sourceId) => {
|
|
28
30
|
const { line, source, target } = connections[sourceId] ?? {};
|
|
29
|
-
return (
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(Edge_1.Path, { edgeId: sourceId + 'temp', isConnecting: isConnecting, line: line, source: source, target: target }, sourceId));
|
|
30
32
|
});
|
|
31
33
|
}, [
|
|
32
34
|
connections
|
|
33
35
|
]);
|
|
34
|
-
const translateXYZ = useMemo(() => {
|
|
36
|
+
const translateXYZ = (0, react_1.useMemo)(() => {
|
|
35
37
|
const tx = translate.x;
|
|
36
38
|
const ty = translate.y;
|
|
37
39
|
const tz = scale;
|
|
@@ -41,8 +43,8 @@ const Connections = ({ scale = 1, translate = {
|
|
|
41
43
|
translate.y,
|
|
42
44
|
scale
|
|
43
45
|
]);
|
|
44
|
-
return (
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(react_native_svg_1.Svg, { style: svgStyle, children: (0, jsx_runtime_1.jsxs)(react_native_svg_1.G, { transform: translateXYZ, children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Defs, { children: (0, jsx_runtime_1.jsx)(shared_1.Marker, {}) }), paths] }) }));
|
|
45
47
|
};
|
|
46
48
|
Connections.displayName = 'LincleInteractiveConnections';
|
|
47
|
-
|
|
49
|
+
exports.default = Connections;
|
|
48
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Edges/Connections/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Edges/Connections/index.tsx"],"names":[],"mappings":";;;AAAA,4CAIyB;AACzB,qCAEoB;AACpB,iCAGe;AACf,+CAEsB;AACtB,uDAI0B;AAE1B,MAAM,EACJ,QAAQ,EACT,GAAG,yBAAU,CAAC,MAAM,CAAC;IACpB,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,SAAS;QACnB,aAAa,EAAE,UAAU;QACzB,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,CAAC;KACV;CACF,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG;IACnB,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,WAAW,GAAwC,CAAC,EACxD,KAAK,GAAG,CAAC,EACT,SAAS,GAAG;IACV,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;CACL,EACF,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,IAAA,uBAAc,GAAE,CAAC;IAErC,MAAM,KAAK,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CACjC,CACE,QAAQ,EACR,EAAE;YACF,MAAM,EACJ,IAAI,EACJ,MAAM,EACN,MAAM,EACP,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEhC,OAAO,CACL,uBAAC,WAAI,IACH,MAAM,EAAE,QAAQ,GAAG,MAAM,EACzB,YAAY,EAAE,YAAY,EAE1B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,IAHT,QAAQ,CAIb,CACH,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC,EACD;QACE,WAAW;KACZ,CACF,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,eAAO,EAC1B,GAAG,EAAE;QACH,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;QACvB,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;QACvB,MAAM,EAAE,GAAG,KAAK,CAAC;QAEjB,OAAO,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,CAAC;IAChD,CAAC,EACD;QACE,SAAS,CAAC,CAAC;QACX,SAAS,CAAC,CAAC;QACX,KAAK;KACN,CACF,CAAC;IAEF,OAAO,CACL,uBAAC,sBAAG,IACF,KAAK,EAAE,QAAQ,YAEf,wBAAC,oBAAC,IACA,SAAS,EAAE,YAAY,aAEvB,uBAAC,uBAAI,cACH,uBAAC,eAAM,KAAG,GACL,EACN,KAAK,IACJ,GACA,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,WAAW,CAAC,WAAW,GAAG,8BAA8B,CAAC;AAEzD,kBAAe,WAAW,CAAC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Edges = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const base_1 = require("../../base");
|
|
9
|
+
const shared_1 = require("../../shared");
|
|
10
|
+
const Connections_1 = __importDefault(require("./Connections"));
|
|
11
|
+
const react_native_1 = require("react-native");
|
|
12
|
+
const { edgesStyle } = react_native_1.StyleSheet.create({
|
|
7
13
|
edgesStyle: {
|
|
8
14
|
height: '100%',
|
|
9
15
|
pointerEvents: 'box-none',
|
|
@@ -12,10 +18,10 @@ const { edgesStyle } = StyleSheet.create({
|
|
|
12
18
|
}
|
|
13
19
|
});
|
|
14
20
|
const Edges = ({ children, ...props }) => {
|
|
15
|
-
const scale = useScale();
|
|
16
|
-
const translate = useTranslate();
|
|
17
|
-
return (
|
|
21
|
+
const scale = (0, shared_1.useScale)();
|
|
22
|
+
const translate = (0, shared_1.useTranslate)();
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: edgesStyle, children: [(0, jsx_runtime_1.jsx)(base_1.Edges, { scale: scale, translate: translate, ...props, children: children }), (0, jsx_runtime_1.jsx)(Connections_1.default, { scale: scale, translate: translate })] }));
|
|
18
24
|
};
|
|
25
|
+
exports.Edges = Edges;
|
|
19
26
|
Edges.displayName = 'LincleInteractiveEdges';
|
|
20
|
-
export { Edges };
|
|
21
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Edges/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Edges/index.tsx"],"names":[],"mappings":";;;;;;;AAAA,qCAEoB;AACpB,yCAIsB;AACtB,gEAAwC;AAIxC,+CAGsB;AAEtB,MAAM,EACJ,UAAU,EACX,GAAG,yBAAU,CAAC,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,MAAM,EAAE,MAAM;QACd,aAAa,EAAE,UAAU;QACzB,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,MAAM;KACd;CACF,CAAC,CAAC;AAEH,MAAM,KAAK,GAAkC,CAAC,EAC5C,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;IACzB,MAAM,SAAS,GAAG,IAAA,qBAAY,GAAE,CAAC;IAEjC,OAAO,CACL,wBAAC,mBAAI,IACH,KAAK,EAAE,UAAU,aAEjB,uBAAC,YAAS,IACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,KAChB,KAAK,YAER,QAAQ,GACC,EACZ,uBAAC,qBAAW,IACV,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,GACpB,IACG,CACR,CAAC;AACJ,CAAC,CAAC;AAKA,sBAAK;AAHP,KAAK,CAAC,WAAW,GAAG,wBAAwB,CAAC"}
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const base_1 = require("../../../base");
|
|
5
|
+
const shared_1 = require("../../../shared");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_native_svg_1 = require("react-native-svg");
|
|
6
8
|
const WIDTH = 0.4;
|
|
7
9
|
const Grid = ({ children }) => {
|
|
8
|
-
const scale = useScale();
|
|
9
|
-
const translate = useTranslate();
|
|
10
|
-
const mode = useMode();
|
|
11
|
-
const line = useMemo(() => {
|
|
10
|
+
const scale = (0, shared_1.useScale)();
|
|
11
|
+
const translate = (0, shared_1.useTranslate)();
|
|
12
|
+
const mode = (0, shared_1.useMode)();
|
|
13
|
+
const line = (0, react_1.useMemo)(() => {
|
|
12
14
|
const t1 = 1 + scale;
|
|
13
15
|
const t2 = 4 * scale;
|
|
14
|
-
return (
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(react_native_svg_1.Line, { stroke: 'black', strokeWidth: WIDTH, x1: t1, x2: t2, y1: t1, y2: t2 }));
|
|
15
17
|
}, [
|
|
16
18
|
scale
|
|
17
19
|
]);
|
|
18
|
-
const plus = useMemo(() => {
|
|
20
|
+
const plus = (0, react_1.useMemo)(() => {
|
|
19
21
|
const t1 = scale;
|
|
20
22
|
const t2 = 4 * scale;
|
|
21
|
-
return (
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Line, { stroke: 'black', strokeWidth: WIDTH, x1: t1, x2: t2, y1: t2, y2: t2 }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Line, { stroke: 'black', strokeWidth: WIDTH, x1: t2, x2: t2, y1: t1, y2: t2 })] }));
|
|
22
24
|
}, [
|
|
23
25
|
scale
|
|
24
26
|
]);
|
|
25
|
-
const circle = useMemo(() => {
|
|
27
|
+
const circle = (0, react_1.useMemo)(() => {
|
|
26
28
|
const t2 = 4 * scale;
|
|
27
|
-
return (
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(react_native_svg_1.Circle, { cx: t2, cy: t2, fill: 'black', r: WIDTH }));
|
|
28
30
|
}, [
|
|
29
31
|
scale
|
|
30
32
|
]);
|
|
31
|
-
const child = useMemo(() => {
|
|
33
|
+
const child = (0, react_1.useMemo)(() => {
|
|
32
34
|
if (!children) {
|
|
33
35
|
switch (mode) {
|
|
34
36
|
case 'move': {
|
|
@@ -50,8 +52,8 @@ const Grid = ({ children }) => {
|
|
|
50
52
|
mode,
|
|
51
53
|
plus
|
|
52
54
|
]);
|
|
53
|
-
return (
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(base_1.Grid, { scale: scale, xOffset: translate.x, yOffset: translate.y, children: child }));
|
|
54
56
|
};
|
|
55
57
|
Grid.displayName = 'LincleInteractiveGrid';
|
|
56
|
-
|
|
58
|
+
exports.default = Grid;
|
|
57
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Graph/Grid/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Graph/Grid/index.tsx"],"names":[],"mappings":";;;AAAA,wCAEuB;AACvB,4CAKyB;AACzB,iCAGe;AACf,uDAG0B;AAE1B,MAAM,KAAK,GAAG,GAAG,CAAC;AAElB,MAAM,IAAI,GAAiC,CAAC,EAC1C,QAAQ,EACT,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;IACzB,MAAM,SAAS,GAAG,IAAA,qBAAY,GAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAA,gBAAO,GAAE,CAAC;IAEvB,MAAM,IAAI,GAAG,IAAA,eAAO,EAClB,GAAG,EAAE;QACH,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;QACrB,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;QAErB,OAAO,CACL,uBAAC,uBAAI,IACH,MAAM,EAAC,OAAO,EACd,WAAW,EAAE,KAAK,EAClB,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,GACN,CACH,CAAC;IACJ,CAAC,EACD;QACE,KAAK;KACN,CACF,CAAC;IAEF,MAAM,IAAI,GAAG,IAAA,eAAO,EAClB,GAAG,EAAE;QACH,MAAM,EAAE,GAAG,KAAK,CAAC;QACjB,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;QAErB,OAAO,CACL,6DACE,uBAAC,uBAAI,IACH,MAAM,EAAC,OAAO,EACd,WAAW,EAAE,KAAK,EAClB,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,GACN,EACF,uBAAC,uBAAI,IACH,MAAM,EAAC,OAAO,EACd,WAAW,EAAE,KAAK,EAClB,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,EAAE,EACN,EAAE,EAAE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
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Graph = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const shared_1 = require("../../shared");
|
|
9
|
+
const Interaction_1 = __importDefault(require("../Interaction"));
|
|
10
|
+
const Grid_1 = __importDefault(require("./Grid"));
|
|
5
11
|
const Graph = ({ children, edgeFrequency, grid, id, line, maxScale, minScale, mode, move, nodeFrequency, nodeHeight, nodeWidth, onNodeDrag, onNodeEdgeDrop, onNodeSelect, onNodeStart, onNodeStop, onScale, onTranslate, pan, pull, scale, shape, showGrid, snap, translate, zoom }) => {
|
|
6
12
|
if (!id) {
|
|
7
13
|
console.error('No ID provided to @lincle/interactive Graph!');
|
|
@@ -9,9 +15,9 @@ const Graph = ({ children, edgeFrequency, grid, id, line, maxScale, minScale, mo
|
|
|
9
15
|
}
|
|
10
16
|
const gird = showGrid === false ?
|
|
11
17
|
null :
|
|
12
|
-
|
|
13
|
-
return (
|
|
18
|
+
(0, jsx_runtime_1.jsx)(Grid_1.default, {});
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(shared_1.GraphBase, { edgeFrequency: edgeFrequency, grid: grid, id: id, line: line, nodeFrequency: nodeFrequency, nodeHeight: nodeHeight, nodeWidth: nodeWidth, shape: shape, showGrid: false, children: (0, jsx_runtime_1.jsxs)(shared_1.Providers, { maxScale: maxScale, minScale: minScale, mode: mode, move: move, onNodeDrag: onNodeDrag, onNodeEdgeDrop: onNodeEdgeDrop, onNodeSelect: onNodeSelect, onNodeStart: onNodeStart, onNodeStop: onNodeStop, onScale: onScale, onTranslate: onTranslate, pan: pan, pull: pull, scale: scale, snap: snap, translate: translate, zoom: zoom, children: [gird, (0, jsx_runtime_1.jsx)(Interaction_1.default, {}), children] }) }));
|
|
14
20
|
};
|
|
21
|
+
exports.Graph = Graph;
|
|
15
22
|
Graph.displayName = 'LincleInteractiveGraph';
|
|
16
|
-
export { Graph };
|
|
17
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Graph/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Graph/index.tsx"],"names":[],"mappings":";;;;;;;AAAA,yCAIsB;AACtB,iEAAyC;AACzC,kDAA0B;AAK1B,MAAM,KAAK,GAAkC,CAAC,EAC5C,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,UAAU,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,GAAG,EACH,IAAI,EACJ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,IAAI,EACL,EAAE,EAAE;IACH,IACE,CAAC,EAAE,EACH,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAE9D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,CAAC;QACN,uBAAC,cAAI,KAAG,CAAC;IAEX,OAAO,CACL,uBAAC,kBAAS,IACR,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,KAAK,YAEf,wBAAC,kBAAS,IACR,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,aAET,IAAI,EACL,uBAAC,qBAAW,KAAG,EACd,QAAQ,IACC,GACF,CACb,CAAC;AACJ,CAAC,CAAC;AAKA,sBAAK;AAHP,KAAK,CAAC,WAAW,GAAG,wBAAwB,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
5
|
+
const react_native_zoomable_view_1 = require("@openspacelabs/react-native-zoomable-view");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
6
8
|
const CLICK_TIME = 500;
|
|
7
9
|
const useDoubleTap = () => {
|
|
8
|
-
const timer = useRef(null);
|
|
9
|
-
useEffect(() => {
|
|
10
|
+
const timer = (0, react_1.useRef)(null);
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
10
12
|
return () => {
|
|
11
13
|
if (timer.current) {
|
|
12
14
|
clearTimeout(timer.current);
|
|
@@ -14,7 +16,7 @@ const useDoubleTap = () => {
|
|
|
14
16
|
}
|
|
15
17
|
};
|
|
16
18
|
}, []);
|
|
17
|
-
return useCallback((callback, threshold = CLICK_TIME) => {
|
|
19
|
+
return (0, react_1.useCallback)((callback, threshold = CLICK_TIME) => {
|
|
18
20
|
if (timer.current) {
|
|
19
21
|
clearTimeout(timer.current);
|
|
20
22
|
timer.current = null;
|
|
@@ -27,7 +29,7 @@ const useDoubleTap = () => {
|
|
|
27
29
|
}
|
|
28
30
|
}, []);
|
|
29
31
|
};
|
|
30
|
-
const styles = StyleSheet.create({
|
|
32
|
+
const styles = react_native_1.StyleSheet.create({
|
|
31
33
|
container: {
|
|
32
34
|
bottom: 0,
|
|
33
35
|
height: '100%',
|
|
@@ -43,20 +45,20 @@ const styles = StyleSheet.create({
|
|
|
43
45
|
}
|
|
44
46
|
});
|
|
45
47
|
const Interaction = ({ onPointerUp }) => {
|
|
46
|
-
const scale = useScale();
|
|
47
|
-
const translate = useTranslate();
|
|
48
|
-
const onScale = useOnScale();
|
|
49
|
-
const onTranslateThrottle = useOnTranslateThrottle();
|
|
50
|
-
const graphMode = useMode() ?? 'move';
|
|
51
|
-
const onMode = useOnMode();
|
|
48
|
+
const scale = (0, shared_1.useScale)();
|
|
49
|
+
const translate = (0, shared_1.useTranslate)();
|
|
50
|
+
const onScale = (0, shared_1.useOnScale)();
|
|
51
|
+
const onTranslateThrottle = (0, shared_1.useOnTranslateThrottle)();
|
|
52
|
+
const graphMode = (0, shared_1.useMode)() ?? 'move';
|
|
53
|
+
const onMode = (0, shared_1.useOnMode)();
|
|
52
54
|
const handleDoubleTap = useDoubleTap();
|
|
53
|
-
const handleOnTransform = useCallback((event) => {
|
|
55
|
+
const handleOnTransform = (0, react_1.useCallback)((event) => {
|
|
54
56
|
const { offsetX, offsetY, originalHeight, originalWidth, zoomLevel } = event;
|
|
55
57
|
onTranslateThrottle(originalWidth, originalHeight, offsetX, offsetY, zoomLevel);
|
|
56
58
|
}, [
|
|
57
59
|
onTranslateThrottle
|
|
58
60
|
]);
|
|
59
|
-
const handleZoom = useCallback((_event, _gestureState, zoomableViewEventObject) => {
|
|
61
|
+
const handleZoom = (0, react_1.useCallback)((_event, _gestureState, zoomableViewEventObject) => {
|
|
60
62
|
const { offsetX, offsetY, originalHeight, originalWidth, zoomLevel } = zoomableViewEventObject;
|
|
61
63
|
onTranslateThrottle(originalWidth, originalHeight, offsetX, offsetY, zoomLevel);
|
|
62
64
|
if (onScale) {
|
|
@@ -66,7 +68,7 @@ const Interaction = ({ onPointerUp }) => {
|
|
|
66
68
|
onScale,
|
|
67
69
|
onTranslateThrottle
|
|
68
70
|
]);
|
|
69
|
-
const handleTapEnd = useCallback(() => {
|
|
71
|
+
const handleTapEnd = (0, react_1.useCallback)(() => {
|
|
70
72
|
if (onMode) {
|
|
71
73
|
switch (graphMode) {
|
|
72
74
|
case 'move': {
|
|
@@ -93,7 +95,7 @@ const Interaction = ({ onPointerUp }) => {
|
|
|
93
95
|
handleDoubleTap,
|
|
94
96
|
onMode
|
|
95
97
|
]);
|
|
96
|
-
const handlePointerUp = useCallback((event) => {
|
|
98
|
+
const handlePointerUp = (0, react_1.useCallback)((event) => {
|
|
97
99
|
handleTapEnd();
|
|
98
100
|
if (onPointerUp) {
|
|
99
101
|
onPointerUp(event);
|
|
@@ -102,8 +104,8 @@ const Interaction = ({ onPointerUp }) => {
|
|
|
102
104
|
handleTapEnd,
|
|
103
105
|
onPointerUp
|
|
104
106
|
]);
|
|
105
|
-
return (
|
|
107
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.container, children: (0, jsx_runtime_1.jsx)(react_native_zoomable_view_1.ReactNativeZoomableView, { bindToBorders: false, doubleTapDelay: 1, doubleTapZoomToCenter: false, initialOffsetX: translate.x, initialOffsetY: translate.y, initialZoom: scale, maxZoom: 1.5, minZoom: 0.5, movementSensibility: 1, onSingleTap: handlePointerUp, onTransform: handleOnTransform, onZoomAfter: handleZoom, panEnabled: true, style: styles.zoomable, visualTouchFeedbackEnabled: false, zoomStep: 0.5 }) }));
|
|
106
108
|
};
|
|
107
109
|
Interaction.displayName = 'LincleInteractiveInteraction';
|
|
108
|
-
|
|
110
|
+
exports.default = Interaction;
|
|
109
111
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Interaction/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Interaction/index.tsx"],"names":[],"mappings":";;;AAAA,yCAQsB;AACtB,0FAGmD;AACnD,iCAKe;AACf,+CAKsB;AAEtB,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,KAAK,GAAG,IAAA,cAAM,EAAgC,IAAI,CAAC,CAAC;IAE1D,IAAA,iBAAS,EACP,GAAG,EAAE;QACH,OAAO,GAAG,EAAE;YACV,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAClB,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC5B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;YACvB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,IAAA,mBAAW,EAChB,CACE,QAAoB,EAEpB,SAAS,GAAG,UAAU,EACtB,EAAE;QACF,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;YAGrB,QAAQ,EAAE,CAAC;QACb,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,OAAO,GAAG,UAAU,CACxB,GAAG,EAAE;gBACH,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;YACvB,CAAC,EACD,SAAS,CACV,CAAC;QACJ,CAAC;IACH,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,MAAM,EAAE,CAAC;QACT,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,CAAC;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ACZ,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,CAAC,EACtB,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,UAAU,EACvB,UAAU,QACV,KAAK,EAAE,MAAM,CAAC,QAAQ,EACtB,0BAA0B,EAAE,KAAK,EACjC,QAAQ,EAAE,GAAG,GACb,GACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,WAAW,CAAC,WAAW,GAAG,8BAA8B,CAAC;AAEzD,kBAAe,WAAW,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
4
6
|
const clamp = (number, min, max) => {
|
|
5
7
|
return Math.max(min, Math.min(number, max));
|
|
6
8
|
};
|
|
7
|
-
const styles = StyleSheet.create({
|
|
9
|
+
const styles = react_native_1.StyleSheet.create({
|
|
8
10
|
debugView: {
|
|
9
11
|
backgroundColor: '#ff000044',
|
|
10
12
|
borderColor: '#fced0ecc',
|
|
@@ -17,23 +19,23 @@ const styles = StyleSheet.create({
|
|
|
17
19
|
}
|
|
18
20
|
});
|
|
19
21
|
const Draggable = ({ animatedViewProps, children, debug = false, disabled = false, imageSource, isCircle, maxX, maxY, minX, minY, onDrag, onDragRelease, onLongPress, onPressIn, onPressOut, onRelease, onShortPressRelease, renderColor, renderSize = 36, renderText = '+', scale = 1, shouldReverse = false, touchableOpacityProps, x = 0, y = 0, zIndex = 1 }) => {
|
|
20
|
-
const pan = useRef(new Animated.ValueXY());
|
|
21
|
-
const offsetFromStart = useRef({
|
|
22
|
+
const pan = (0, react_1.useRef)(new react_native_1.Animated.ValueXY());
|
|
23
|
+
const offsetFromStart = (0, react_1.useRef)({
|
|
22
24
|
x: 0,
|
|
23
25
|
y: 0
|
|
24
26
|
});
|
|
25
|
-
const childSize = useRef({
|
|
27
|
+
const childSize = (0, react_1.useRef)({
|
|
26
28
|
x: renderSize,
|
|
27
29
|
y: renderSize
|
|
28
30
|
});
|
|
29
|
-
const startBounds = useRef({
|
|
31
|
+
const startBounds = (0, react_1.useRef)({
|
|
30
32
|
bottom: 0,
|
|
31
33
|
left: 0,
|
|
32
34
|
right: 0,
|
|
33
35
|
top: 0
|
|
34
36
|
});
|
|
35
|
-
const isDragging = useRef(false);
|
|
36
|
-
const getBounds = useCallback(() => {
|
|
37
|
+
const isDragging = (0, react_1.useRef)(false);
|
|
38
|
+
const getBounds = (0, react_1.useCallback)(() => {
|
|
37
39
|
const left = x + offsetFromStart.current.x;
|
|
38
40
|
const top = y + offsetFromStart.current.y;
|
|
39
41
|
return {
|
|
@@ -46,13 +48,13 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
46
48
|
x,
|
|
47
49
|
y
|
|
48
50
|
]);
|
|
49
|
-
const shouldStartDrag = useCallback((gs) => {
|
|
51
|
+
const shouldStartDrag = (0, react_1.useCallback)((gs) => {
|
|
50
52
|
return !disabled && (Math.abs(gs.dx) > 2 || Math.abs(gs.dy) > 2);
|
|
51
53
|
}, [
|
|
52
54
|
disabled
|
|
53
55
|
]);
|
|
54
|
-
const reversePosition = useCallback(() => {
|
|
55
|
-
Animated.spring(pan.current, {
|
|
56
|
+
const reversePosition = (0, react_1.useCallback)(() => {
|
|
57
|
+
react_native_1.Animated.spring(pan.current, {
|
|
56
58
|
toValue: {
|
|
57
59
|
x: 0,
|
|
58
60
|
y: 0
|
|
@@ -62,7 +64,7 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
62
64
|
}, [
|
|
63
65
|
pan
|
|
64
66
|
]);
|
|
65
|
-
const onPanResponderRelease = useCallback((event, gestureState) => {
|
|
67
|
+
const onPanResponderRelease = (0, react_1.useCallback)((event, gestureState) => {
|
|
66
68
|
isDragging.current = false;
|
|
67
69
|
if (onDragRelease) {
|
|
68
70
|
onDragRelease(event, gestureState, getBounds());
|
|
@@ -83,7 +85,7 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
83
85
|
reversePosition,
|
|
84
86
|
shouldReverse
|
|
85
87
|
]);
|
|
86
|
-
const onPanResponderGrant = useCallback((_event, _gestureState) => {
|
|
88
|
+
const onPanResponderGrant = (0, react_1.useCallback)((_event, _gestureState) => {
|
|
87
89
|
startBounds.current = getBounds();
|
|
88
90
|
isDragging.current = true;
|
|
89
91
|
if (!shouldReverse) {
|
|
@@ -97,7 +99,7 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
97
99
|
getBounds,
|
|
98
100
|
shouldReverse
|
|
99
101
|
]);
|
|
100
|
-
const handleOnDrag = useCallback((event, gestureState) => {
|
|
102
|
+
const handleOnDrag = (0, react_1.useCallback)((event, gestureState) => {
|
|
101
103
|
const { dx, dy } = gestureState;
|
|
102
104
|
const { bottom, left, right, top } = startBounds.current;
|
|
103
105
|
const far = 999999999;
|
|
@@ -130,8 +132,8 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
130
132
|
onDrag,
|
|
131
133
|
scale
|
|
132
134
|
]);
|
|
133
|
-
const panResponder = useMemo(() => {
|
|
134
|
-
return PanResponder.create({
|
|
135
|
+
const panResponder = (0, react_1.useMemo)(() => {
|
|
136
|
+
return react_native_1.PanResponder.create({
|
|
135
137
|
onMoveShouldSetPanResponder: (_, gestureState) => {
|
|
136
138
|
return shouldStartDrag(gestureState);
|
|
137
139
|
},
|
|
@@ -139,7 +141,7 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
139
141
|
return shouldStartDrag(gestureState);
|
|
140
142
|
},
|
|
141
143
|
onPanResponderGrant,
|
|
142
|
-
onPanResponderMove: Animated.event([], {
|
|
144
|
+
onPanResponderMove: react_native_1.Animated.event([], {
|
|
143
145
|
listener: handleOnDrag,
|
|
144
146
|
useNativeDriver: false
|
|
145
147
|
}),
|
|
@@ -151,7 +153,7 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
151
153
|
onPanResponderRelease,
|
|
152
154
|
shouldStartDrag
|
|
153
155
|
]);
|
|
154
|
-
useEffect(() => {
|
|
156
|
+
(0, react_1.useEffect)(() => {
|
|
155
157
|
const currentPan = pan.current;
|
|
156
158
|
if (!shouldReverse) {
|
|
157
159
|
currentPan.addListener((cp) => {
|
|
@@ -165,8 +167,8 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
165
167
|
}, [
|
|
166
168
|
shouldReverse
|
|
167
169
|
]);
|
|
168
|
-
const positionCss = useMemo(() => {
|
|
169
|
-
const Window = Dimensions.get('window');
|
|
170
|
+
const positionCss = (0, react_1.useMemo)(() => {
|
|
171
|
+
const Window = react_native_1.Dimensions.get('window');
|
|
170
172
|
return {
|
|
171
173
|
height: Window.height,
|
|
172
174
|
left: 0,
|
|
@@ -176,7 +178,7 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
176
178
|
};
|
|
177
179
|
}, []);
|
|
178
180
|
const hasChildren = Boolean(children);
|
|
179
|
-
const dragItemCss = useMemo(() => {
|
|
181
|
+
const dragItemCss = (0, react_1.useMemo)(() => {
|
|
180
182
|
const style = {
|
|
181
183
|
elevation: zIndex,
|
|
182
184
|
left: x,
|
|
@@ -208,30 +210,30 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
208
210
|
y,
|
|
209
211
|
zIndex
|
|
210
212
|
]);
|
|
211
|
-
const touchableContent = useMemo(() => {
|
|
213
|
+
const touchableContent = (0, react_1.useMemo)(() => {
|
|
212
214
|
if (imageSource) {
|
|
213
215
|
const style = {
|
|
214
216
|
height: renderSize,
|
|
215
217
|
width: renderSize
|
|
216
218
|
};
|
|
217
|
-
return (
|
|
219
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Image, { source: imageSource, style: style }));
|
|
218
220
|
}
|
|
219
221
|
else {
|
|
220
|
-
return (
|
|
222
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.text, children: renderText }));
|
|
221
223
|
}
|
|
222
224
|
}, [
|
|
223
225
|
imageSource,
|
|
224
226
|
renderSize,
|
|
225
227
|
renderText
|
|
226
228
|
]);
|
|
227
|
-
const handleOnLayout = useCallback((event) => {
|
|
229
|
+
const handleOnLayout = (0, react_1.useCallback)((event) => {
|
|
228
230
|
const { height, width } = event.nativeEvent.layout;
|
|
229
231
|
childSize.current = {
|
|
230
232
|
x: width,
|
|
231
233
|
y: height
|
|
232
234
|
};
|
|
233
235
|
}, []);
|
|
234
|
-
const handlePressOut = useCallback((event) => {
|
|
236
|
+
const handlePressOut = (0, react_1.useCallback)((event) => {
|
|
235
237
|
if (onPressOut) {
|
|
236
238
|
onPressOut(event);
|
|
237
239
|
}
|
|
@@ -243,8 +245,8 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
243
245
|
onPressOut,
|
|
244
246
|
onRelease
|
|
245
247
|
]);
|
|
246
|
-
const getDebugView = useCallback(() => {
|
|
247
|
-
const { height, width } = Dimensions.get('window');
|
|
248
|
+
const getDebugView = (0, react_1.useCallback)(() => {
|
|
249
|
+
const { height, width } = react_native_1.Dimensions.get('window');
|
|
248
250
|
const far = 9999;
|
|
249
251
|
const constrained = minX ?? maxX ?? minY ?? maxY;
|
|
250
252
|
if (!constrained) {
|
|
@@ -265,15 +267,15 @@ const Draggable = ({ animatedViewProps, children, debug = false, disabled = fals
|
|
|
265
267
|
top,
|
|
266
268
|
...styles.debugView
|
|
267
269
|
};
|
|
268
|
-
return (
|
|
270
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { pointerEvents: 'box-none', style: style }));
|
|
269
271
|
}, [
|
|
270
272
|
maxX,
|
|
271
273
|
maxY,
|
|
272
274
|
minX,
|
|
273
275
|
minY
|
|
274
276
|
]);
|
|
275
|
-
return (
|
|
277
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { pointerEvents: 'box-none', style: positionCss, children: [debug && getDebugView(), (0, jsx_runtime_1.jsx)(react_native_1.Animated.View, { pointerEvents: 'box-none', ...animatedViewProps, ...panResponder.panHandlers, style: pan.current.getLayout(), children: (0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { ...touchableOpacityProps, activeOpacity: 1, disabled: disabled, onLayout: handleOnLayout, onLongPress: onLongPress, onPress: onShortPressRelease, onPressIn: onPressIn, onPressOut: handlePressOut, style: dragItemCss, children: children ?? touchableContent }) })] }));
|
|
276
278
|
};
|
|
277
279
|
Draggable.displayName = 'ReactNativeDraggable';
|
|
278
|
-
|
|
280
|
+
exports.default = Draggable;
|
|
279
281
|
//# sourceMappingURL=Draggable.js.map
|