react-native-wagmi-charts 1.0.4 → 1.2.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.
- package/.DS_Store +0 -0
- package/.prettierrc.js +5 -0
- package/README.md +171 -121
- package/example/.DS_Store +0 -0
- package/example/README.md +32 -0
- package/example/package.json +1 -1
- package/example/src/App.tsx +32 -7
- package/example/src/CandlestickChart.tsx +23 -11
- package/example/src/LineChart.tsx +51 -20
- package/example/src/{candlestick-data.json → data/candlestick-data.json} +0 -0
- package/example/src/{candlestick-data2.json → data/candlestick-data2.json} +0 -0
- package/example/src/{line-data.json → data/line-data.json} +0 -0
- package/example/src/{line-data2.json → data/line-data2.json} +0 -0
- package/example/yarn.lock +5 -5
- package/lib/commonjs/charts/candle/Crosshair.js +6 -17
- package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
- package/lib/commonjs/charts/candle/CrosshairTooltip.js +12 -8
- package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/commonjs/charts/candle/DatetimeText.js +7 -8
- package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/candle/Line.js.map +1 -1
- package/lib/commonjs/charts/candle/PriceText.js +7 -8
- package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandleData.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
- package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils.js.map +1 -1
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +4 -3
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +8 -1
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/DatetimeText.js +7 -8
- package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/line/Path.js +13 -16
- package/lib/commonjs/charts/line/Path.js.map +1 -1
- package/lib/commonjs/charts/line/PriceText.js +7 -8
- package/lib/commonjs/charts/line/PriceText.js.map +1 -1
- package/lib/commonjs/charts/line/interpolatePath.js +600 -0
- package/lib/commonjs/charts/line/interpolatePath.js.map +1 -0
- package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/line/usePrice.js.map +1 -1
- package/lib/commonjs/charts/line/utils.js +1 -70
- package/lib/commonjs/charts/line/utils.js.map +1 -1
- package/lib/commonjs/components/AnimatedText.js +63 -0
- package/lib/commonjs/components/AnimatedText.js.map +1 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/charts/candle/Crosshair.js +7 -16
- package/lib/module/charts/candle/Crosshair.js.map +1 -1
- package/lib/module/charts/candle/CrosshairTooltip.js +10 -8
- package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/module/charts/candle/DatetimeText.js +6 -7
- package/lib/module/charts/candle/DatetimeText.js.map +1 -1
- package/lib/module/charts/candle/Line.js.map +1 -1
- package/lib/module/charts/candle/PriceText.js +6 -7
- package/lib/module/charts/candle/PriceText.js.map +1 -1
- package/lib/module/charts/candle/useCandleData.js.map +1 -1
- package/lib/module/charts/candle/useCandlestickChart.js.map +1 -1
- package/lib/module/charts/candle/useDatetime.js.map +1 -1
- package/lib/module/charts/candle/usePrice.js.map +1 -1
- package/lib/module/charts/candle/utils.js.map +1 -1
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +4 -3
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +7 -1
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/DatetimeText.js +6 -7
- package/lib/module/charts/line/DatetimeText.js.map +1 -1
- package/lib/module/charts/line/Path.js +11 -15
- package/lib/module/charts/line/Path.js.map +1 -1
- package/lib/module/charts/line/PriceText.js +6 -7
- package/lib/module/charts/line/PriceText.js.map +1 -1
- package/lib/module/charts/line/interpolatePath.js +587 -0
- package/lib/module/charts/line/interpolatePath.js.map +1 -0
- package/lib/module/charts/line/useDatetime.js.map +1 -1
- package/lib/module/charts/line/usePrice.js.map +1 -1
- package/lib/module/charts/line/utils.js +1 -66
- package/lib/module/charts/line/utils.js.map +1 -1
- package/lib/module/components/AnimatedText.js +43 -0
- package/lib/module/components/AnimatedText.js.map +1 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/charts/candle/Crosshair.d.ts +4 -4
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts +3 -2
- package/lib/typescript/src/charts/candle/Line.d.ts +1 -1
- package/lib/typescript/src/charts/candle/PriceText.d.ts +3 -3
- package/lib/typescript/src/charts/candle/types.d.ts +8 -3
- package/lib/typescript/src/charts/candle/useCandleData.d.ts +3 -3
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +2 -1
- package/lib/typescript/src/charts/candle/useDatetime.d.ts +5 -7
- package/lib/typescript/src/charts/candle/usePrice.d.ts +5 -8
- package/lib/typescript/src/charts/candle/utils.d.ts +1 -1
- package/lib/typescript/src/charts/line/Chart.d.ts +1 -1
- package/lib/typescript/src/charts/line/Cursor.d.ts +1 -2
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +3 -2
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +5 -6
- package/lib/typescript/src/charts/line/Path.d.ts +17 -1
- package/lib/typescript/src/charts/line/PriceText.d.ts +3 -2
- package/lib/typescript/src/charts/line/interpolatePath.d.ts +50 -0
- package/lib/typescript/src/charts/line/useDatetime.d.ts +4 -5
- package/lib/typescript/src/charts/line/usePrice.d.ts +3 -2
- package/lib/typescript/src/charts/line/utils.d.ts +0 -13
- package/lib/typescript/src/components/AnimatedText.d.ts +9 -0
- package/lib/typescript/src/utils.d.ts +2 -4
- package/package.json +4 -4
- package/src/charts/candle/Crosshair.tsx +20 -20
- package/src/charts/candle/CrosshairTooltip.tsx +11 -4
- package/src/charts/candle/DatetimeText.tsx +5 -4
- package/src/charts/candle/Line.tsx +1 -1
- package/src/charts/candle/PriceText.tsx +5 -5
- package/src/charts/candle/types.ts +11 -3
- package/src/charts/candle/useCandleData.ts +3 -2
- package/src/charts/candle/useCandlestickChart.ts +2 -1
- package/src/charts/candle/useDatetime.ts +7 -3
- package/src/charts/candle/usePrice.ts +10 -3
- package/src/charts/candle/utils.ts +1 -1
- package/src/charts/line/Chart.tsx +1 -1
- package/src/charts/line/Cursor.tsx +7 -3
- package/src/charts/line/CursorCrosshair.tsx +4 -3
- package/src/charts/line/CursorLine.tsx +9 -1
- package/src/charts/line/DatetimeText.tsx +8 -7
- package/src/charts/line/Path.tsx +25 -21
- package/src/charts/line/PriceText.tsx +5 -4
- package/src/charts/line/interpolatePath.ts +650 -0
- package/src/charts/line/useDatetime.ts +3 -2
- package/src/charts/line/usePrice.ts +2 -1
- package/src/charts/line/utils.ts +2 -79
- package/src/components/AnimatedText.tsx +53 -0
- package/src/utils.ts +3 -3
- package/yarn.lock +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDatetime.ts"],"names":["useLineChartDatetime","format","locale","options","currentIndex","data","timestamp","value","timestampString","toString","formatted","formattedDatetime"],"mappings":";;;;;;;AAAA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["useDatetime.ts"],"names":["useLineChartDatetime","format","locale","options","currentIndex","data","timestamp","value","timestampString","toString","formatted","formattedDatetime"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEO,SAASA,oBAAT,CAA8B;AACnCC,EAAAA,MADmC;AAEnCC,EAAAA,MAFmC;AAGnCC,EAAAA;AAHmC,IAQjC,EARG,EAQC;AACN,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAyB,iCAA/B;AAEA,QAAMC,SAAS,GAAG,4CAAgB,MAAM;AACtC,QAAI,OAAOF,YAAY,CAACG,KAApB,KAA8B,WAA9B,IAA6CH,YAAY,CAACG,KAAb,KAAuB,CAAC,CAAzE,EACE,OAAO,EAAP;AACF,WAAOF,IAAI,CAACD,YAAY,CAACG,KAAd,CAAJ,CAAyBD,SAAhC;AACD,GAJiB,CAAlB;AAMA,QAAME,eAAe,GAAG,4CAAgB,MAAM;AAC5C,QAAIF,SAAS,CAACC,KAAV,KAAoB,EAAxB,EAA4B,OAAO,EAAP;AAC5B,WAAOD,SAAS,CAACC,KAAV,CAAgBE,QAAhB,EAAP;AACD,GAHuB,CAAxB;AAKA,QAAMC,SAAS,GAAG,4CAAgB,MAAM;AACtC,QAAIJ,SAAS,CAACC,KAAV,KAAoB,EAAxB,EAA4B,OAAO,EAAP;AAC5B,UAAMI,iBAAiB,GAAG,2BAAe;AACvCJ,MAAAA,KAAK,EAAED,SAAS,CAACC,KADsB;AAEvCL,MAAAA,MAFuC;AAGvCC,MAAAA;AAHuC,KAAf,CAA1B;AAKA,WAAOF,MAAM,GACTA,MAAM,CAAC;AAAEM,MAAAA,KAAK,EAAED,SAAS,CAACC,KAAnB;AAA0BG,MAAAA,SAAS,EAAEC;AAArC,KAAD,CADG,GAETA,iBAFJ;AAGD,GAViB,CAAlB;AAYA,SAAO;AAAEJ,IAAAA,KAAK,EAAEC,eAAT;AAA0BE,IAAAA;AAA1B,GAAP;AACD","sourcesContent":["import { useDerivedValue } from 'react-native-reanimated';\n\nimport { formatDatetime } from '../../utils';\nimport type { TFormatterFn } from '../candle/types';\nimport { useLineChart } from './useLineChart';\n\nexport function useLineChartDatetime({\n format,\n locale,\n options,\n}: {\n format?: TFormatterFn<number>;\n locale?: string;\n options?: Intl.DateTimeFormatOptions;\n} = {}) {\n const { currentIndex, data } = useLineChart();\n\n const timestamp = useDerivedValue(() => {\n if (typeof currentIndex.value === 'undefined' || currentIndex.value === -1)\n return '';\n return data[currentIndex.value].timestamp;\n });\n\n const timestampString = useDerivedValue(() => {\n if (timestamp.value === '') return '';\n return timestamp.value.toString();\n });\n\n const formatted = useDerivedValue(() => {\n if (timestamp.value === '') return '';\n const formattedDatetime = formatDatetime({\n value: timestamp.value,\n locale,\n options,\n });\n return format\n ? format({ value: timestamp.value, formatted: formattedDatetime })\n : formattedDatetime;\n });\n\n return { value: timestampString, formatted };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["usePrice.ts"],"names":["useLineChartPrice","format","precision","currentIndex","data","float","value","price","toFixed","toString","formatted","formattedPrice"],"mappings":";;;;;;;AAAA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["usePrice.ts"],"names":["useLineChartPrice","format","precision","currentIndex","data","float","value","price","toFixed","toString","formatted","formattedPrice"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEO,SAASA,iBAAT,CAA2B;AAChCC,EAAAA,MADgC;AAEhCC,EAAAA,SAAS,GAAG;AAFoB,IAGyB,EAHpD,EAGwD;AAC7D,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAyB,iCAA/B;AAEA,QAAMC,KAAK,GAAG,4CAAgB,MAAM;AAClC,QAAI,OAAOF,YAAY,CAACG,KAApB,KAA8B,WAA9B,IAA6CH,YAAY,CAACG,KAAb,KAAuB,CAAC,CAAzE,EACE,OAAO,EAAP;AACF,QAAIC,KAAK,GAAG,CAAZ;AACAA,IAAAA,KAAK,GAAGH,IAAI,CAACD,YAAY,CAACG,KAAd,CAAJ,CAAyBA,KAAjC;AACA,WAAOC,KAAK,CAACC,OAAN,CAAcN,SAAd,EAAyBO,QAAzB,EAAP;AACD,GANa,CAAd;AAOA,QAAMC,SAAS,GAAG,4CAAgB,MAAM;AACtC,QAAI,CAACL,KAAK,CAACC,KAAX,EAAkB,OAAO,EAAP;AAClB,UAAMK,cAAc,GAAG,wBAAY;AAAEL,MAAAA,KAAK,EAAED,KAAK,CAACC;AAAf,KAAZ,CAAvB;AACA,WAAOL,MAAM,GACTA,MAAM,CAAC;AAAEK,MAAAA,KAAK,EAAED,KAAK,CAACC,KAAf;AAAsBI,MAAAA,SAAS,EAAEC;AAAjC,KAAD,CADG,GAETA,cAFJ;AAGD,GANiB,CAAlB;AAQA,SAAO;AAAEL,IAAAA,KAAK,EAAED,KAAT;AAAgBK,IAAAA;AAAhB,GAAP;AACD","sourcesContent":["import { useDerivedValue } from 'react-native-reanimated';\n\nimport { formatPrice } from '../../utils';\nimport type { TFormatterFn } from '../candle/types';\nimport { useLineChart } from './useLineChart';\n\nexport function useLineChartPrice({\n format,\n precision = 2,\n}: { format?: TFormatterFn<string>; precision?: number } = {}) {\n const { currentIndex, data } = useLineChart();\n\n const float = useDerivedValue(() => {\n if (typeof currentIndex.value === 'undefined' || currentIndex.value === -1)\n return '';\n let price = 0;\n price = data[currentIndex.value].value;\n return price.toFixed(precision).toString();\n });\n const formatted = useDerivedValue(() => {\n if (!float.value) return '';\n const formattedPrice = formatPrice({ value: float.value });\n return format\n ? format({ value: float.value, formatted: formattedPrice })\n : formattedPrice;\n });\n\n return { value: float, formatted };\n}\n"]}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getDomain = getDomain;
|
|
7
7
|
exports.getPath = getPath;
|
|
8
|
-
exports.syncChangingPaths = syncChangingPaths;
|
|
9
|
-
exports.syncPaths = syncPaths;
|
|
10
8
|
|
|
11
9
|
var shape = _interopRequireWildcard(require("d3-shape"));
|
|
12
10
|
|
|
@@ -40,74 +38,7 @@ function getPath({
|
|
|
40
38
|
}) => value);
|
|
41
39
|
const scaleX = (0, _d3Scale.scaleLinear)().domain([Math.min(...timestamps), Math.max(...timestamps)]).range([0, width]);
|
|
42
40
|
const scaleY = (0, _d3Scale.scaleLinear)().domain([Math.min(...values), Math.max(...values)]).range([height - gutter, gutter]);
|
|
43
|
-
const path = shape.line().x((_, i) => scaleX(i)).y(
|
|
41
|
+
const path = shape.line().x((_, i) => scaleX(i)).y(d => scaleY(d.value)).curve(_shape)(data);
|
|
44
42
|
return path;
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
function syncChangingPaths({
|
|
48
|
-
pointsToAdd,
|
|
49
|
-
parsedPath,
|
|
50
|
-
curves
|
|
51
|
-
}) {
|
|
52
|
-
'worklet';
|
|
53
|
-
|
|
54
|
-
const firstPoint = curves === null || curves === void 0 ? void 0 : curves[0];
|
|
55
|
-
let newParsedPath = parsedPath;
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < Math.abs(pointsToAdd); i++) {
|
|
58
|
-
newParsedPath = { ...newParsedPath,
|
|
59
|
-
curves: [{
|
|
60
|
-
c1: {
|
|
61
|
-
x: firstPoint.c1.x,
|
|
62
|
-
y: firstPoint.c1.y
|
|
63
|
-
},
|
|
64
|
-
c2: {
|
|
65
|
-
x: firstPoint.c2.x,
|
|
66
|
-
y: firstPoint.c2.y
|
|
67
|
-
},
|
|
68
|
-
to: {
|
|
69
|
-
x: firstPoint.to.x,
|
|
70
|
-
y: firstPoint.to.y
|
|
71
|
-
}
|
|
72
|
-
}, ...newParsedPath.curves]
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return newParsedPath;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function syncPaths({
|
|
80
|
-
parsedPath,
|
|
81
|
-
previousParsedPath
|
|
82
|
-
}) {
|
|
83
|
-
'worklet';
|
|
84
|
-
|
|
85
|
-
const previousCurves = previousParsedPath === null || previousParsedPath === void 0 ? void 0 : previousParsedPath.curves;
|
|
86
|
-
const nextCurves = parsedPath === null || parsedPath === void 0 ? void 0 : parsedPath.curves;
|
|
87
|
-
let newPreviousParsedPath = previousParsedPath || parsedPath;
|
|
88
|
-
let newParsedPath = parsedPath;
|
|
89
|
-
|
|
90
|
-
if ((previousCurves === null || previousCurves === void 0 ? void 0 : previousCurves.length) !== (nextCurves === null || nextCurves === void 0 ? void 0 : nextCurves.length)) {
|
|
91
|
-
const pointsToAdd = (nextCurves === null || nextCurves === void 0 ? void 0 : nextCurves.length) - (previousCurves === null || previousCurves === void 0 ? void 0 : previousCurves.length) || 0;
|
|
92
|
-
|
|
93
|
-
if (pointsToAdd > 0) {
|
|
94
|
-
newPreviousParsedPath = syncChangingPaths({
|
|
95
|
-
pointsToAdd,
|
|
96
|
-
parsedPath: newPreviousParsedPath,
|
|
97
|
-
curves: previousCurves
|
|
98
|
-
});
|
|
99
|
-
} else if (pointsToAdd < 0) {
|
|
100
|
-
newParsedPath = syncChangingPaths({
|
|
101
|
-
pointsToAdd,
|
|
102
|
-
parsedPath: newParsedPath,
|
|
103
|
-
curves: nextCurves
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
previousParsedPath: newPreviousParsedPath,
|
|
110
|
-
parsedPath: newParsedPath
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
44
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["getDomain","rows","values","map","value","flat","Math","min","max","getPath","data","width","height","gutter","shape","_shape","curveBumpX","timestamps","i","scaleX","domain","range","scaleY","path","line","x","_","y","
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["getDomain","rows","values","map","value","flat","Math","min","max","getPath","data","width","height","gutter","shape","_shape","curveBumpX","timestamps","i","scaleX","domain","range","scaleY","path","line","x","_","y","d","curve"],"mappings":";;;;;;;;AACA;;AAEA;;;;;;AAHA;AAEA;AAKO,SAASA,SAAT,CAAmBC,IAAnB,EAA8D;AACnE;;AACA,QAAMC,MAAM,GAAGD,IAAI,CAACE,GAAL,CAAS,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAe,CAACA,KAAD,CAAxB,EAAiCC,IAAjC,EAAf;AACA,SAAO,CAACC,IAAI,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@ts-ignore\nimport { scaleLinear } from 'd3-scale';\n\nimport type { TLineChartData, TLineChartPoint } from './types';\n\nexport function getDomain(rows: TLineChartPoint[]): [number, number] {\n 'worklet';\n const values = rows.map(({ value }) => [value]).flat();\n return [Math.min(...values), Math.max(...values)];\n}\n\nexport function getPath({\n data,\n width,\n height,\n gutter,\n shape: _shape = shape.curveBumpX,\n}: {\n data: TLineChartData;\n width: number;\n height: number;\n gutter: number;\n shape?: string;\n}): string {\n const timestamps = data.map(({}, i) => i);\n const values = data.map(({ value }) => value);\n const scaleX = scaleLinear()\n .domain([Math.min(...timestamps), Math.max(...timestamps)])\n .range([0, width]);\n const scaleY = scaleLinear()\n .domain([Math.min(...values), Math.max(...values)])\n .range([height - gutter, gutter]);\n const path = shape\n .line()\n .x((_: unknown, i: number) => scaleX(i))\n .y((d: { value: unknown }) => scaleY(d.value))\n .curve(_shape)(data);\n return path;\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AnimatedText = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
// forked from https://github.com/wcandillon/react-native-redash/blob/master/src/ReText.tsx
|
|
21
|
+
_reactNativeReanimated.default.addWhitelistedNativeProps({
|
|
22
|
+
text: true
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const AnimatedTextInput = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.TextInput);
|
|
26
|
+
|
|
27
|
+
const AnimatedText = ({
|
|
28
|
+
text,
|
|
29
|
+
style
|
|
30
|
+
}) => {
|
|
31
|
+
const inputRef = _react.default.useRef(null);
|
|
32
|
+
|
|
33
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => {
|
|
34
|
+
// always return false unless web to prevent unnecessary reactions
|
|
35
|
+
return _reactNative.Platform.OS === 'web' && text.value;
|
|
36
|
+
}, (data, prevData) => {
|
|
37
|
+
if (_reactNative.Platform.OS === 'web' && data !== prevData && inputRef.current) {
|
|
38
|
+
inputRef.current.setNativeProps({
|
|
39
|
+
value: data
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
|
|
44
|
+
return {
|
|
45
|
+
text: text.value // Here we use any because the text prop is not available in the type
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(AnimatedTextInput, {
|
|
51
|
+
underlineColorAndroid: "transparent",
|
|
52
|
+
editable: false,
|
|
53
|
+
ref: _reactNative.Platform.select({
|
|
54
|
+
web: inputRef
|
|
55
|
+
}),
|
|
56
|
+
value: text.value,
|
|
57
|
+
style: style,
|
|
58
|
+
animatedProps: animatedProps
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.AnimatedText = AnimatedText;
|
|
63
|
+
//# sourceMappingURL=AnimatedText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["AnimatedText.tsx"],"names":["Animated","addWhitelistedNativeProps","text","AnimatedTextInput","createAnimatedComponent","TextInput","AnimatedText","style","inputRef","React","useRef","Platform","OS","value","data","prevData","current","setNativeProps","animatedProps","select","web"],"mappings":";;;;;;;AAEA;;AACA;;AAEA;;;;;;;;AALA;AAUAA,+BAASC,yBAAT,CAAmC;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAAnC;;AAOA,MAAMC,iBAAiB,GAAGH,+BAASI,uBAAT,CAAiCC,sBAAjC,CAA1B;;AAEO,MAAMC,YAAY,GAAG,CAAC;AAAEJ,EAAAA,IAAF;AAAQK,EAAAA;AAAR,CAAD,KAAwC;AAClE,QAAMC,QAAQ,GAAGC,eAAMC,MAAN,CAAwB,IAAxB,CAAjB;;AAEA,kDACE,MAAM;AACJ;AACA,WAAOC,sBAASC,EAAT,KAAgB,KAAhB,IAAyBV,IAAI,CAACW,KAArC;AACD,GAJH,EAKE,CAACC,IAAD,EAAOC,QAAP,KAAoB;AAClB,QAAIJ,sBAASC,EAAT,KAAgB,KAAhB,IAAyBE,IAAI,KAAKC,QAAlC,IAA8CP,QAAQ,CAACQ,OAA3D,EAAoE;AAClER,MAAAA,QAAQ,CAACQ,OAAT,CAAiBC,cAAjB,CAAgC;AAC9BJ,QAAAA,KAAK,EAAEC;AADuB,OAAhC;AAGD;AACF,GAXH;AAaA,QAAMI,aAAa,GAAG,6CAAiB,MAAM;AAC3C,WAAO;AACLhB,MAAAA,IAAI,EAAEA,IAAI,CAACW,KADN,CAEL;AACA;;AAHK,KAAP;AAKD,GANqB,CAAtB;AAOA,sBACE,6BAAC,iBAAD;AACE,IAAA,qBAAqB,EAAC,aADxB;AAEE,IAAA,QAAQ,EAAE,KAFZ;AAGE,IAAA,GAAG,EAAEF,sBAASQ,MAAT,CAAgB;AAAEC,MAAAA,GAAG,EAAEZ;AAAP,KAAhB,CAHP;AAIE,IAAA,KAAK,EAAEN,IAAI,CAACW,KAJd;AAKE,IAAA,KAAK,EAAEN,KALT;AAME,IAAA,aAAa,EAAEW;AANjB,IADF;AAUD,CAjCM","sourcesContent":["// forked from https://github.com/wcandillon/react-native-redash/blob/master/src/ReText.tsx\n\nimport React from 'react';\nimport { Platform, TextProps as RNTextProps } from 'react-native';\nimport { TextInput } from 'react-native';\nimport Animated, {\n useAnimatedProps,\n useAnimatedReaction,\n} from 'react-native-reanimated';\n\nAnimated.addWhitelistedNativeProps({ text: true });\n\ninterface AnimatedTextProps {\n text: Animated.SharedValue<string>;\n style?: Animated.AnimateProps<RNTextProps>['style'];\n}\n\nconst AnimatedTextInput = Animated.createAnimatedComponent(TextInput);\n\nexport const AnimatedText = ({ text, style }: AnimatedTextProps) => {\n const inputRef = React.useRef<TextInput>(null);\n\n useAnimatedReaction(\n () => {\n // always return false unless web to prevent unnecessary reactions\n return Platform.OS === 'web' && text.value;\n },\n (data, prevData) => {\n if (Platform.OS === 'web' && data !== prevData && inputRef.current) {\n inputRef.current.setNativeProps({\n value: data,\n });\n }\n }\n );\n const animatedProps = useAnimatedProps(() => {\n return {\n text: text.value,\n // Here we use any because the text prop is not available in the type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any;\n });\n return (\n <AnimatedTextInput\n underlineColorAndroid=\"transparent\"\n editable={false}\n ref={Platform.select({ web: inputRef })}\n value={text.value}\n style={style}\n animatedProps={animatedProps}\n />\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["formatPrice","value","_value","defaultPrice","_defaultPrice","precision","toString","replace","decimals","Number","Math","min","slice","search","res","toFixed","vals","split","length","formatDatetime","locale","options","d","Date","toLocaleString","usePrevious","ref","React","useRef","useEffect","current"],"mappings":";;;;;;;;;AAAA;;;;;;AAEO,SAASA,WAAT,CAAqB;AAC1BC,EAAAA,KAAK,EAAEC,MADmB;AAE1BC,EAAAA,YAAY,EAAEC,aAAa,GAAG,EAFJ;AAG1BC,EAAAA;AAH0B,CAArB,EAQJ;AACD;;AADC;;AAGD,MAAIF,YAAY,GAAGC,aAAnB;;AACA,MAAI,OAAOD,YAAP,KAAwB,QAA5B,EAAsC;AACpCA,IAAAA,YAAY,GAAIA,YAAD,CAAyBG,QAAzB,EAAf;AACD;;AAED,MAAIL,KAAK,GAAGC,MAAM,uBAAIC,YAAJ,4EAAI,eAAcI,OAAlB,0DAAI,2CAAwB,GAAxB,EAA6B,EAA7B,CAAJ,CAAlB;;AACA,MAAI,CAACN,KAAL,EAAY;AACV,WAAQ,MAAR;AACD;;AAED,MAAIO,QAAQ,GACVH,SAAS,KACRI,MAAM,CAACR,KAAD,CAAN,GAAgB,CAAhB,GACGS,IAAI,CAACC,GAAL,CAAS,CAAT,EAAYV,KAAK,CAACK,QAAN,GAAiBM,KAAjB,CAAuB,CAAvB,EAA0BC,MAA1B,CAAiC,OAAjC,IAA4C,CAAxD,CADH,GAEG,CAHK,CADX;AAMA,MAAIC,GAAG,GAAI,GAAEL,MAAM,CAACR,KAAD,CAAN,CAAcc,OAAd,CAAsBP,QAAtB,CAAgC,EAA7C;AACA,QAAMQ,IAAI,GAAGF,GAAG,CAACG,KAAJ,CAAU,GAAV,CAAb;;AACA,MAAID,IAAI,CAACE,MAAL,GAAc,CAAlB,EAAqB;AACnBJ,IAAAA,GAAG,GAAGE,IAAI,CAAC,CAAD,CAAJ,CAAQT,OAAR,CAAgB,uBAAhB,EAAyC,GAAzC,CAAN;;AACA,QAAIS,IAAI,CAACE,MAAL,KAAgB,CAApB,EAAuB;AACrB,aAAOJ,GAAG,GAAG,GAAN,GAAYE,IAAI,CAAC,CAAD,CAAvB;AACD;AACF;;AACD,SAAOF,GAAP;AACD;;AAEM,SAASK,cAAT,CAAwB;AAC7BlB,EAAAA,KAD6B;AAE7BmB,EAAAA,MAAM,GAAG,OAFoB;AAG7BC,EAAAA,OAAO,GAAG;AAHmB,CAAxB,EAQJ;AACD;;AACA,QAAMC,CAAC,GAAG,IAAIC,IAAJ,CAAStB,KAAT,CAAV;AACA,SAAOqB,CAAC,CAACE,cAAF,CAAiBJ,MAAjB,EAAyBC,OAAzB,CAAP;AACD;;AAEM,SAASI,WAAT,
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["formatPrice","value","_value","defaultPrice","_defaultPrice","precision","toString","replace","decimals","Number","Math","min","slice","search","res","toFixed","vals","split","length","formatDatetime","locale","options","d","Date","toLocaleString","usePrevious","ref","React","useRef","useEffect","current"],"mappings":";;;;;;;;;AAAA;;;;;;AAEO,SAASA,WAAT,CAAqB;AAC1BC,EAAAA,KAAK,EAAEC,MADmB;AAE1BC,EAAAA,YAAY,EAAEC,aAAa,GAAG,EAFJ;AAG1BC,EAAAA;AAH0B,CAArB,EAQJ;AACD;;AADC;;AAGD,MAAIF,YAAY,GAAGC,aAAnB;;AACA,MAAI,OAAOD,YAAP,KAAwB,QAA5B,EAAsC;AACpCA,IAAAA,YAAY,GAAIA,YAAD,CAAyBG,QAAzB,EAAf;AACD;;AAED,MAAIL,KAAK,GAAGC,MAAM,uBAAIC,YAAJ,4EAAI,eAAcI,OAAlB,0DAAI,2CAAwB,GAAxB,EAA6B,EAA7B,CAAJ,CAAlB;;AACA,MAAI,CAACN,KAAL,EAAY;AACV,WAAQ,MAAR;AACD;;AAED,MAAIO,QAAQ,GACVH,SAAS,KACRI,MAAM,CAACR,KAAD,CAAN,GAAgB,CAAhB,GACGS,IAAI,CAAC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,\n defaultPrice: _defaultPrice = '',\n precision,\n}: {\n value: string;\n defaultPrice?: string;\n precision?: number;\n}) {\n 'worklet';\n\n let defaultPrice = _defaultPrice;\n if (typeof defaultPrice === 'number') {\n defaultPrice = (defaultPrice as number).toString();\n }\n\n let value = _value || defaultPrice?.replace?.(',', '');\n if (!value) {\n return `0.00`;\n }\n\n let decimals =\n precision ||\n (Number(value) < 1\n ? Math.min(8, value.toString().slice(2).search(/[^0]/g) + 3)\n : 2);\n\n let res = `${Number(value).toFixed(decimals)}`;\n const vals = res.split('.');\n if (vals.length > 0) {\n res = vals[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n if (vals.length === 2) {\n return res + '.' + vals[1];\n }\n }\n return res;\n}\n\nexport function formatDatetime({\n value,\n locale = 'en-US',\n options = {},\n}: {\n value: number;\n locale?: string;\n options?: Intl.DateTimeFormatOptions;\n}) {\n 'worklet';\n const d = new Date(value);\n return d.toLocaleString(locale, options);\n}\n\nexport function usePrevious<T>(value: T) {\n // The ref object is a generic container whose current property is mutable ...\n // ... and can hold any value, similar to an instance property on a class\n const ref = React.useRef<T>();\n // Store current value in ref\n React.useEffect(() => {\n ref.current = value;\n }, [value]); // Only re-run if value changes\n // Return previous value (happens before update in useEffect above)\n return ref.current;\n}\n"]}
|
|
@@ -2,25 +2,16 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { StyleSheet } from 'react-native';
|
|
5
|
-
import
|
|
6
|
-
import { PanGestureHandler } from 'react-native-gesture-handler';
|
|
5
|
+
import { LongPressGestureHandler } from 'react-native-gesture-handler';
|
|
7
6
|
import Animated, { useAnimatedGestureHandler, useSharedValue, useAnimatedStyle, useAnimatedReaction, runOnJS } from 'react-native-reanimated';
|
|
8
7
|
import { clamp } from 'react-native-redash';
|
|
9
8
|
import { CandlestickChartDimensionsContext } from './Chart';
|
|
10
9
|
import { CandlestickChartLine } from './Line';
|
|
11
10
|
import { useCandlestickChart } from './useCandlestickChart';
|
|
12
11
|
import { CandlestickChartCrosshairTooltipContext } from './CrosshairTooltip';
|
|
13
|
-
|
|
14
|
-
function invokeHaptic() {
|
|
15
|
-
ReactNativeHapticFeedback.trigger('impactLight', {
|
|
16
|
-
enableVibrateFallback: true,
|
|
17
|
-
ignoreAndroidSystemSettings: false
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
12
|
export function CandlestickChartCrosshair({
|
|
22
13
|
color,
|
|
23
|
-
|
|
14
|
+
onCurrentXChange,
|
|
24
15
|
children,
|
|
25
16
|
horizontalCrosshairProps = {},
|
|
26
17
|
verticalCrosshairProps = {},
|
|
@@ -73,13 +64,13 @@ export function CandlestickChartCrosshair({
|
|
|
73
64
|
translateX: currentX.value
|
|
74
65
|
}]
|
|
75
66
|
}));
|
|
76
|
-
useAnimatedReaction(() =>
|
|
77
|
-
if (data !==
|
|
78
|
-
runOnJS(
|
|
67
|
+
useAnimatedReaction(() => currentX.value, (data, prevData) => {
|
|
68
|
+
if (data !== -1 && data !== prevData && onCurrentXChange) {
|
|
69
|
+
runOnJS(onCurrentXChange)(data);
|
|
79
70
|
}
|
|
80
71
|
});
|
|
81
|
-
return /*#__PURE__*/React.createElement(
|
|
82
|
-
|
|
72
|
+
return /*#__PURE__*/React.createElement(LongPressGestureHandler, _extends({
|
|
73
|
+
minDurationMs: 0,
|
|
83
74
|
onGestureEvent: onGestureEvent
|
|
84
75
|
}, props), /*#__PURE__*/React.createElement(Animated.View, {
|
|
85
76
|
style: StyleSheet.absoluteFill
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Crosshair.tsx"],"names":["React","StyleSheet","
|
|
1
|
+
{"version":3,"sources":["Crosshair.tsx"],"names":["React","StyleSheet","LongPressGestureHandler","Animated","useAnimatedGestureHandler","useSharedValue","useAnimatedStyle","useAnimatedReaction","runOnJS","clamp","CandlestickChartDimensionsContext","CandlestickChartLine","useCandlestickChart","CandlestickChartCrosshairTooltipContext","CandlestickChartCrosshair","color","onCurrentXChange","children","horizontalCrosshairProps","verticalCrosshairProps","lineProps","props","width","height","useContext","currentX","currentY","step","tooltipPosition","opacity","onGestureEvent","onActive","x","y","boundedX","value","onEnd","horizontal","transform","translateY","vertical","translateX","data","prevData","absoluteFill","position"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,QAAsC,cAAtC;AACA,SAEEC,uBAFF,QAKO,8BALP;AAMA,OAAOC,QAAP,IACEC,yBADF,EAEEC,cAFF,EAGEC,gBAHF,EAIEC,mBAJF,EAKEC,OALF,QAMO,yBANP;AAOA,SAASC,KAAT,QAAsB,qBAAtB;AAEA,SAASC,iCAAT,QAAkD,SAAlD;AACA,SAASC,oBAAT,QAAgE,QAAhE;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,uCAAT,QAAwD,oBAAxD;AAWA,OAAO,SAASC,yBAAT,CAAmC;AACxCC,EAAAA,KADwC;AAExCC,EAAAA,gBAFwC;AAGxCC,EAAAA,QAHwC;AAIxCC,EAAAA,wBAAwB,GAAG,EAJa;AAKxCC,EAAAA,sBAAsB,GAAG,EALe;AAMxCC,EAAAA,SAAS,GAAG,EAN4B;AAOxC,KAAGC;AAPqC,CAAnC,EAQ4B;AACjC,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAoBvB,KAAK,CAACwB,UAAN,CAAiBd,iCAAjB,CAA1B;AACA,QAAM;AAAEe,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA;AAAtB,MAA+Bf,mBAAmB,EAAxD;AAEA,QAAMgB,eAAe,GAAGvB,cAAc,CAAmB,MAAnB,CAAtC;AAEA,QAAMwB,OAAO,GAAGxB,cAAc,CAAC,CAAD,CAA9B;AACA,QAAMyB,cAAc,GAAG1B,yBAAyB,CAE9C;AACA2B,IAAAA,QAAQ,EAAE,CAAC;AAAEC,MAAAA,CAAF;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KADE,EAEjB,CAACO,IAAD,EAAOC,QAAP,KAAoB;AAClB,QAAID,IAAI,KAAK,CAAC,CAAV,IAAeA,IAAI,KAAKC,QAAxB,IAAoC3B,gBAAxC,EAA0D;AACxDR,MAAAA,OAAO,CAACQ,gBAAD,CAAP,CAA0B0B,IAA1B;AACD;AACF,GANgB,CAAnB;AASA,sBACE,oBAAC,uBAAD;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,cAAc,EAAEZ;AAFlB,KAGMT,KAHN,gBAKE,oBAAC,QAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEpB,UAAU,CAAC2C;AAAjC,kBACE,oBAAC,QAAD,CAAU,IAAV;AACE,IAAA,KAAK,EAAE,CAAC3C,UAAU,CAAC2C,YAAZ,EAA0BP,UAA1B;AADT,KAEMnB,wBAFN,gBAIE,oBAAC,oBAAD;AAAsB,IAAA,KAAK,EAAEH,KAA7B;AAAoC,IAAA,CAAC,EAAEO,KAAvC;AAA8C,IAAA,CAAC,EAAE;AAAjD,KAAwDF,SAAxD,EAJF,eAKE,oBAAC,uCAAD,CAAyC,QAAzC;AACE,IAAA,KAAK,EAAE;AAAEyB,MAAAA,QAAQ,EAAEjB;AAAZ;AADT,KAGGX,QAHH,CALF,CADF,eAYE,oBAAC,QAAD,CAAU,IAAV;AACE,IAAA,KAAK,EAAE,CAAChB,UAAU,CAAC2C,YAAZ,EAA0BJ,QAA1B;AADT,KAEMrB,sBAFN,gBAIE,oBAAC,oBAAD;AAAsB,IAAA,KAAK,EAAEJ,KAA7B;AAAoC,IAAA,CAAC,EAAE,CAAvC;AAA0C,IAAA,CAAC,EAAEQ;AAA7C,KAAyDH,SAAzD,EAJF,CAZF,CALF,CADF;AA2BD","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, ViewProps } from 'react-native';\nimport {\n GestureEvent,\n LongPressGestureHandler,\n LongPressGestureHandlerEventPayload,\n LongPressGestureHandlerProps,\n} from 'react-native-gesture-handler';\nimport Animated, {\n useAnimatedGestureHandler,\n useSharedValue,\n useAnimatedStyle,\n useAnimatedReaction,\n runOnJS,\n} from 'react-native-reanimated';\nimport { clamp } from 'react-native-redash';\n\nimport { CandlestickChartDimensionsContext } from './Chart';\nimport { CandlestickChartLine, CandlestickChartLineProps } from './Line';\nimport { useCandlestickChart } from './useCandlestickChart';\nimport { CandlestickChartCrosshairTooltipContext } from './CrosshairTooltip';\n\ntype CandlestickChartCrosshairProps = LongPressGestureHandlerProps & {\n color?: string;\n children?: React.ReactNode;\n onCurrentXChange?: (value: number) => unknown;\n horizontalCrosshairProps?: Animated.AnimateProps<ViewProps>;\n verticalCrosshairProps?: Animated.AnimateProps<ViewProps>;\n lineProps?: Partial<CandlestickChartLineProps>;\n};\n\nexport function CandlestickChartCrosshair({\n color,\n onCurrentXChange,\n children,\n horizontalCrosshairProps = {},\n verticalCrosshairProps = {},\n lineProps = {},\n ...props\n}: CandlestickChartCrosshairProps) {\n const { width, height } = React.useContext(CandlestickChartDimensionsContext);\n const { currentX, currentY, step } = useCandlestickChart();\n\n const tooltipPosition = useSharedValue<'left' | 'right'>('left');\n\n const opacity = useSharedValue(0);\n const onGestureEvent = useAnimatedGestureHandler<\n GestureEvent<LongPressGestureHandlerEventPayload>\n >({\n onActive: ({ x, y }) => {\n const boundedX = x <= width - 1 ? x : width - 1;\n if (boundedX < 100) {\n tooltipPosition.value = 'right';\n } else {\n tooltipPosition.value = 'left';\n }\n opacity.value = 1;\n currentY.value = clamp(y, 0, height);\n currentX.value = boundedX - (boundedX % step) + step / 2;\n },\n onEnd: () => {\n opacity.value = 0;\n currentY.value = -1;\n currentX.value = -1;\n },\n });\n const horizontal = useAnimatedStyle(() => ({\n opacity: opacity.value,\n transform: [{ translateY: currentY.value }],\n }));\n const vertical = useAnimatedStyle(() => ({\n opacity: opacity.value,\n transform: [{ translateX: currentX.value }],\n }));\n\n useAnimatedReaction(\n () => currentX.value,\n (data, prevData) => {\n if (data !== -1 && data !== prevData && onCurrentXChange) {\n runOnJS(onCurrentXChange)(data);\n }\n }\n );\n\n return (\n <LongPressGestureHandler\n minDurationMs={0}\n onGestureEvent={onGestureEvent}\n {...props}\n >\n <Animated.View style={StyleSheet.absoluteFill}>\n <Animated.View\n style={[StyleSheet.absoluteFill, horizontal]}\n {...horizontalCrosshairProps}\n >\n <CandlestickChartLine color={color} x={width} y={0} {...lineProps} />\n <CandlestickChartCrosshairTooltipContext.Provider\n value={{ position: tooltipPosition }}\n >\n {children}\n </CandlestickChartCrosshairTooltipContext.Provider>\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, vertical]}\n {...verticalCrosshairProps}\n >\n <CandlestickChartLine color={color} x={0} y={height} {...lineProps} />\n </Animated.View>\n </Animated.View>\n </LongPressGestureHandler>\n );\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || 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); }
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
4
5
|
import Animated, { useAnimatedStyle, useDerivedValue, useSharedValue } from 'react-native-reanimated';
|
|
5
6
|
import { CandlestickChartDimensionsContext } from './Chart';
|
|
6
7
|
import { useCandlestickChart } from './useCandlestickChart';
|
|
@@ -14,8 +15,8 @@ export function CandlestickChartCrosshairTooltip({
|
|
|
14
15
|
children,
|
|
15
16
|
xGutter = 8,
|
|
16
17
|
yGutter = 8,
|
|
17
|
-
tooltipTextProps
|
|
18
|
-
textStyle
|
|
18
|
+
tooltipTextProps,
|
|
19
|
+
textStyle,
|
|
19
20
|
...props
|
|
20
21
|
}) {
|
|
21
22
|
const {
|
|
@@ -66,15 +67,16 @@ export function CandlestickChartCrosshairTooltip({
|
|
|
66
67
|
}, props, {
|
|
67
68
|
style: [tooltip, leftTooltip, props.style]
|
|
68
69
|
}), children || /*#__PURE__*/React.createElement(CandlestickChartPriceText, _extends({}, tooltipTextProps, {
|
|
69
|
-
style: [
|
|
70
|
-
fontSize: 14
|
|
71
|
-
}, tooltipTextProps.style, textStyle]
|
|
70
|
+
style: [styles.text, tooltipTextProps === null || tooltipTextProps === void 0 ? void 0 : tooltipTextProps.style, textStyle]
|
|
72
71
|
}))), /*#__PURE__*/React.createElement(Animated.View, _extends({}, props, {
|
|
73
72
|
style: [tooltip, rightTooltip, props.style]
|
|
74
73
|
}), children || /*#__PURE__*/React.createElement(CandlestickChartPriceText, _extends({}, tooltipTextProps, {
|
|
75
|
-
style: [
|
|
76
|
-
fontSize: 14
|
|
77
|
-
}, tooltipTextProps.style, textStyle]
|
|
74
|
+
style: [styles.text, tooltipTextProps === null || tooltipTextProps === void 0 ? void 0 : tooltipTextProps.style, textStyle]
|
|
78
75
|
}))));
|
|
79
76
|
}
|
|
77
|
+
const styles = StyleSheet.create({
|
|
78
|
+
text: {
|
|
79
|
+
fontSize: 14
|
|
80
|
+
}
|
|
81
|
+
});
|
|
80
82
|
//# sourceMappingURL=CrosshairTooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CrosshairTooltip.tsx"],"names":["React","Animated","useAnimatedStyle","useDerivedValue","useSharedValue","CandlestickChartDimensionsContext","useCandlestickChart","CandlestickChartPriceText","CandlestickChartCrosshairTooltipContext","createContext","position","value","CandlestickChartCrosshairTooltip","children","xGutter","yGutter","tooltipTextProps","textStyle","props","width","height","useContext","currentY","elementHeight","elementWidth","handleLayout","useCallback","event","nativeEvent","layout","topOffset","offset","tooltip","backgroundColor","display","padding","leftTooltip","left","top","opacity","rightTooltip","style","fontSize"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,QAAP,IACEC,gBADF,EAEEC,eAFF,EAGEC,cAHF,QAIO,yBAJP;AAMA,SAASC,iCAAT,QAAkD,SAAlD;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SACEC,yBADF,QAGO,aAHP;AAiBA,OAAO,MAAMC,uCAAuC,
|
|
1
|
+
{"version":3,"sources":["CrosshairTooltip.tsx"],"names":["React","StyleSheet","Animated","useAnimatedStyle","useDerivedValue","useSharedValue","CandlestickChartDimensionsContext","useCandlestickChart","CandlestickChartPriceText","CandlestickChartCrosshairTooltipContext","createContext","position","value","CandlestickChartCrosshairTooltip","children","xGutter","yGutter","tooltipTextProps","textStyle","props","width","height","useContext","currentY","elementHeight","elementWidth","handleLayout","useCallback","event","nativeEvent","layout","topOffset","offset","tooltip","backgroundColor","display","padding","leftTooltip","left","top","opacity","rightTooltip","style","styles","text","create","fontSize"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,QAAP,IACEC,gBADF,EAEEC,eAFF,EAGEC,cAHF,QAIO,yBAJP;AAMA,SAASC,iCAAT,QAAkD,SAAlD;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SACEC,yBADF,QAGO,aAHP;AAiBA,OAAO,MAAMC,uCAAuC,gBAClDT,KAAK,CAACU,aAAN,CAA6D;AAC3DC,EAAAA,QAAQ,EAAE;AAAEC,IAAAA,KAAK,EAAE;AAAT;AADiD,CAA7D,CADK;AAKP,OAAO,SAASC,gCAAT,CAA0C;AAC/CC,EAAAA,QAD+C;AAE/CC,EAAAA,OAAO,GAAG,CAFqC;AAG/CC,EAAAA,OAAO,GAAG,CAHqC;AAI/CC,EAAAA,gBAJ+C;AAK/CC,EAAAA,SAL+C;AAM/C,KAAGC;AAN4C,CAA1C,EAOmC;AACxC,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAoBrB,KAAK,CAACsB,UAAN,CAAiBhB,iCAAjB,CAA1B;AACA,QAAM;AAAEiB,IAAAA;AAAF,MAAehB,mBAAmB,EAAxC;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAeX,K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AR,EAAc3B,gBAAd,aAAcA,gBAAd,uBAAcA,gBAAgB,CAAEyB,KAAhC,EAAuCxB,SAAvC;AAFT,KAFJ,CAbF,CADF;AAwBD;AAED,MAAMyB,MAAM,GAAG1C,UAAU,CAAC4C,MAAX,CAAkB;AAC/BD,EAAAA,IAAI,EAAE;AACJE,IAAAA,QAAQ,EAAE;AADN;AADyB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport type { StyleProp, TextStyle, ViewProps } from 'react-native';\nimport { StyleSheet } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from 'react-native-reanimated';\n\nimport { CandlestickChartDimensionsContext } from './Chart';\nimport { useCandlestickChart } from './useCandlestickChart';\nimport {\n CandlestickChartPriceText,\n CandlestickChartPriceTextProps,\n} from './PriceText';\n\nexport type CandlestickChartCrosshairTooltipProps = ViewProps & {\n children?: React.ReactNode;\n xGutter?: number;\n yGutter?: number;\n tooltipTextProps?: CandlestickChartPriceTextProps;\n textStyle?: Animated.AnimateStyle<StyleProp<TextStyle>>;\n};\n\nexport type CandlestickChartCrosshairTooltipContext = {\n position: Animated.SharedValue<'left' | 'right'>;\n};\n\nexport const CandlestickChartCrosshairTooltipContext =\n React.createContext<CandlestickChartCrosshairTooltipContext>({\n position: { value: 'left' },\n });\n\nexport function CandlestickChartCrosshairTooltip({\n children,\n xGutter = 8,\n yGutter = 8,\n tooltipTextProps,\n textStyle,\n ...props\n}: CandlestickChartCrosshairTooltipProps) {\n const { width, height } = React.useContext(CandlestickChartDimensionsContext);\n const { currentY } = useCandlestickChart();\n const { position } = React.useContext(\n CandlestickChartCrosshairTooltipContext\n );\n\n const elementHeight = useSharedValue(0);\n const elementWidth = useSharedValue(0);\n\n const handleLayout = React.useCallback(\n (event) => {\n elementHeight.value = event.nativeEvent.layout.height;\n elementWidth.value = event.nativeEvent.layout.width;\n },\n [elementHeight, elementWidth]\n );\n\n const topOffset = useDerivedValue(() => {\n let offset = 0;\n if (currentY.value < elementHeight.value / 2 + yGutter) {\n offset = currentY.value - (elementHeight.value / 2 + yGutter);\n } else if (currentY.value + elementHeight.value / 2 > height - yGutter) {\n offset = currentY.value + elementHeight.value / 2 - height + yGutter;\n }\n\n return offset;\n });\n\n const tooltip = useAnimatedStyle(() => ({\n backgroundColor: 'white',\n position: 'absolute',\n display: 'flex',\n padding: 4,\n }));\n const leftTooltip = useAnimatedStyle(() => ({\n left: xGutter,\n top: -(elementHeight.value / 2) - topOffset.value,\n opacity: position.value === 'left' ? 1 : 0,\n }));\n const rightTooltip = useAnimatedStyle(() => ({\n left: width - elementWidth.value - xGutter,\n top: -(elementHeight.value / 2) - topOffset.value,\n opacity: position.value === 'right' ? 1 : 0,\n }));\n\n return (\n <>\n <Animated.View\n onLayout={handleLayout}\n {...props}\n style={[tooltip, leftTooltip, props.style]}\n >\n {children || (\n <CandlestickChartPriceText\n {...tooltipTextProps}\n style={[styles.text, tooltipTextProps?.style, textStyle]}\n />\n )}\n </Animated.View>\n <Animated.View {...props} style={[tooltip, rightTooltip, props.style]}>\n {children || (\n <CandlestickChartPriceText\n {...tooltipTextProps}\n style={[styles.text, tooltipTextProps?.style, textStyle]}\n />\n )}\n </Animated.View>\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n text: {\n fontSize: 14,\n },\n});\n"]}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || 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); }
|
|
2
|
-
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
import { ReText } from 'react-native-redash';
|
|
5
2
|
import { useCandlestickChartDatetime } from './useDatetime';
|
|
3
|
+
import { AnimatedText } from '../../components/AnimatedText';
|
|
6
4
|
export function CandlestickChartDatetimeText({
|
|
7
5
|
locale,
|
|
8
6
|
options,
|
|
9
7
|
format,
|
|
10
8
|
variant = 'formatted',
|
|
11
|
-
|
|
9
|
+
style
|
|
12
10
|
}) {
|
|
13
11
|
const datetime = useCandlestickChartDatetime({
|
|
14
12
|
format,
|
|
15
13
|
locale,
|
|
16
14
|
options
|
|
17
15
|
});
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
19
|
-
text: datetime[variant]
|
|
20
|
-
|
|
16
|
+
return /*#__PURE__*/React.createElement(AnimatedText, {
|
|
17
|
+
text: datetime[variant],
|
|
18
|
+
style: style
|
|
19
|
+
});
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=DatetimeText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DatetimeText.tsx"],"names":["React","
|
|
1
|
+
{"version":3,"sources":["DatetimeText.tsx"],"names":["React","useCandlestickChartDatetime","AnimatedText","CandlestickChartDatetimeText","locale","options","format","variant","style","datetime"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAIA,SAASC,2BAAT,QAA4C,eAA5C;AAEA,SAASC,YAAT,QAA6B,+BAA7B;AAUA,OAAO,SAASC,4BAAT,CAAsC;AAC3CC,EAAAA,MAD2C;AAE3CC,EAAAA,OAF2C;AAG3CC,EAAAA,MAH2C;AAI3CC,EAAAA,OAAO,GAAG,WAJiC;AAK3CC,EAAAA;AAL2C,CAAtC,EAM4B;AACjC,QAAMC,QAAQ,GAAGR,2BAA2B,CAAC;AAAEK,IAAAA,MAAF;AAAUF,IAAAA,MAAV;AAAkBC,IAAAA;AAAlB,GAAD,CAA5C;AACA,sBAAO,oBAAC,YAAD;AAAc,IAAA,IAAI,EAAEI,QAAQ,CAACF,OAAD,CAA5B;AAAuC,IAAA,KAAK,EAAEC;AAA9C,IAAP;AACD","sourcesContent":["import * as React from 'react';\nimport type { TextProps as RNTextProps } from 'react-native';\nimport type Animated from 'react-native-reanimated';\n\nimport { useCandlestickChartDatetime } from './useDatetime';\nimport type { TFormatterFn } from 'react-native-wagmi-charts';\nimport { AnimatedText } from '../../components/AnimatedText';\n\ntype CandlestickChartPriceTextProps = {\n locale?: string;\n options?: { [key: string]: string };\n format?: TFormatterFn<number>;\n variant?: 'formatted' | 'value';\n style?: Animated.AnimateProps<RNTextProps>['style'];\n};\n\nexport function CandlestickChartDatetimeText({\n locale,\n options,\n format,\n variant = 'formatted',\n style,\n}: CandlestickChartPriceTextProps) {\n const datetime = useCandlestickChartDatetime({ format, locale, options });\n return <AnimatedText text={datetime[variant]} style={style} />;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Line.tsx"],"names":["React","StyleSheet","Svg","Line","SVGLine","CandlestickChartLine","color","x","y","props","absoluteFill"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,GAAP,IAAcC,IAAI,IAAIC,OAAtB,QAAgD,kBAAhD;AAQA,OAAO,MAAMC,oBAAoB,GAAG,CAAC;AACnCC,EAAAA,KAAK,GAAG,MAD2B;AAEnCC,EAAAA,CAFmC;AAGnCC,EAAAA,CAHmC;AAInC,KAAGC;AAJgC,CAAD,KAKH;AAC/B,sBACE,oBAAC,GAAD;AAAK,IAAA,KAAK,EAAER,UAAU,CAACS;AAAvB,kBACE,oBAAC,OAAD;AACE,IAAA,EAAE,EAAE,CADN;AAEE,IAAA,EAAE,EAAE,CAFN;AAGE,IAAA,EAAE,EAAEH,CAHN;AAIE,IAAA,EAAE,EAAEC,CAJN;AAKE,IAAA,WAAW,EAAE,CALf;AAME,IAAA,MAAM,EAAEF,KANV;AAOE,IAAA,eAAe,EAAC;AAPlB,KAQMG,KARN,EADF,CADF;AAcD,CApBM","sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Svg, { Line as SVGLine, LineProps } from 'react-native-svg';\n\nexport type CandlestickChartLineProps = LineProps & {\n color?: string;\n x: number;\n y: number;\n};\n\nexport const CandlestickChartLine = ({\n color = 'gray',\n x,\n y,\n ...props\n}: CandlestickChartLineProps) => {\n return (\n <Svg style={StyleSheet.absoluteFill}>\n <SVGLine\n x1={0}\n y1={0}\n x2={x}\n y2={y}\n strokeWidth={2}\n stroke={color}\n strokeDasharray=\"6 6\"\n {...props}\n />\n </Svg>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["Line.tsx"],"names":["React","StyleSheet","Svg","Line","SVGLine","CandlestickChartLine","color","x","y","props","absoluteFill"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,GAAP,IAAcC,IAAI,IAAIC,OAAtB,QAAgD,kBAAhD;AAQA,OAAO,MAAMC,oBAAoB,GAAG,CAAC;AACnCC,EAAAA,KAAK,GAAG,MAD2B;AAEnCC,EAAAA,CAFmC;AAGnCC,EAAAA,CAHmC;AAInC,KAAGC;AAJgC,CAAD,KAKH;AAC/B,sBACE,oBAAC,GAAD;AAAK,IAAA,KAAK,EAAER,UAAU,CAACS;AAAvB,kBACE,oBAAC,OAAD;AACE,IAAA,EAAE,EAAE,CADN;AAEE,IAAA,EAAE,EAAE,CAFN;AAGE,IAAA,EAAE,EAAEH,CAHN;AAIE,IAAA,EAAE,EAAEC,CAJN;AAKE,IAAA,WAAW,EAAE,CALf;AAME,IAAA,MAAM,EAAEF,KANV;AAOE,IAAA,eAAe,EAAC;AAPlB,KAQMG,KARN,EADF,CADF;AAcD,CApBM","sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Svg, { Line as SVGLine, LineProps } from 'react-native-svg';\n\nexport type CandlestickChartLineProps = Omit<LineProps, 'x' | 'y'> & {\n color?: string;\n x: number;\n y: number;\n};\n\nexport const CandlestickChartLine = ({\n color = 'gray',\n x,\n y,\n ...props\n}: CandlestickChartLineProps) => {\n return (\n <Svg style={StyleSheet.absoluteFill}>\n <SVGLine\n x1={0}\n y1={0}\n x2={x}\n y2={y}\n strokeWidth={2}\n stroke={color}\n strokeDasharray=\"6 6\"\n {...props}\n />\n </Svg>\n );\n};\n"]}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || 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); }
|
|
2
|
-
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
import { ReText } from 'react-native-redash';
|
|
5
2
|
import { useCandlestickChartPrice } from './usePrice';
|
|
3
|
+
import { AnimatedText } from '../../components/AnimatedText';
|
|
6
4
|
export function CandlestickChartPriceText({
|
|
7
5
|
format,
|
|
8
6
|
precision = 2,
|
|
9
7
|
variant = 'formatted',
|
|
10
8
|
type = 'crosshair',
|
|
11
|
-
|
|
9
|
+
style
|
|
12
10
|
}) {
|
|
13
11
|
const price = useCandlestickChartPrice({
|
|
14
12
|
format,
|
|
15
13
|
precision,
|
|
16
14
|
type
|
|
17
15
|
});
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
19
|
-
text: price[variant]
|
|
20
|
-
|
|
16
|
+
return /*#__PURE__*/React.createElement(AnimatedText, {
|
|
17
|
+
text: price[variant],
|
|
18
|
+
style: style
|
|
19
|
+
});
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=PriceText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PriceText.tsx"],"names":["React","
|
|
1
|
+
{"version":3,"sources":["PriceText.tsx"],"names":["React","useCandlestickChartPrice","AnimatedText","CandlestickChartPriceText","format","precision","variant","type","style","price"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAKA,SAASC,wBAAT,QAAyC,YAAzC;AACA,SAASC,YAAT,QAA6B,+BAA7B;AAUA,OAAO,SAASC,yBAAT,CAAmC;AACxCC,EAAAA,MADwC;AAExCC,EAAAA,SAAS,GAAG,CAF4B;AAGxCC,EAAAA,OAAO,GAAG,WAH8B;AAIxCC,EAAAA,IAAI,GAAG,WAJiC;AAKxCC,EAAAA;AALwC,CAAnC,EAM4B;AACjC,QAAMC,KAAK,GAAGR,wBAAwB,CAAC;AAAEG,IAAAA,MAAF;AAAUC,IAAAA,SAAV;AAAqBE,IAAAA;AAArB,GAAD,CAAtC;AACA,sBAAO,oBAAC,YAAD;AAAc,IAAA,IAAI,EAAEE,KAAK,CAACH,OAAD,CAAzB;AAAoC,IAAA,KAAK,EAAEE;AAA3C,IAAP;AACD","sourcesContent":["import * as React from 'react';\nimport type { TextProps as RNTextProps } from 'react-native';\nimport type Animated from 'react-native-reanimated';\nimport type { TFormatterFn, TPriceType } from './types';\n\nimport { useCandlestickChartPrice } from './usePrice';\nimport { AnimatedText } from '../../components/AnimatedText';\n\nexport type CandlestickChartPriceTextProps = {\n format?: TFormatterFn<string>;\n precision?: number;\n variant?: 'formatted' | 'value';\n type?: TPriceType;\n style?: Animated.AnimateProps<RNTextProps>['style'];\n};\n\nexport function CandlestickChartPriceText({\n format,\n precision = 2,\n variant = 'formatted',\n type = 'crosshair',\n style,\n}: CandlestickChartPriceTextProps) {\n const price = useCandlestickChartPrice({ format, precision, type });\n return <AnimatedText text={price[variant]} style={style} />;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCandleData.ts"],"names":["useDerivedValue","useCandlestickChart","useCandleData","currentX","data","step","candle","value","timestamp","low","open","high","close","Math","floor"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["useCandleData.ts"],"names":["useDerivedValue","useCandlestickChart","useCandleData","currentX","data","step","candle","value","timestamp","low","open","high","close","Math","floor"],"mappings":"AAAA,SAAmBA,eAAnB,QAA0C,yBAA1C;AAGA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAO,SAASC,aAAT,GAAkE;AACvE,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,IAAZ;AAAkBC,IAAAA;AAAlB,MAA2BJ,mBAAmB,EAApD;AAEA,QAAMK,MAAM,GAAGN,eAAe,CAAC,MAAM;AACnC,QAAIG,QAAQ,CAACI,KAAT,KAAmB,CAAC,CAAxB,EAA2B;AACzB,aAAO;AAAEC,QAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,QAAAA,GAAG,EAAE,CAAC,CAAvB;AAA0BC,QAAAA,IAAI,EAAE,CAAC,CAAjC;AAAoCC,QAAAA,IAAI,EAAE,CAAC,CAA3C;AAA8CC,QAAAA,KAAK,EAAE,CAAC;AAAtD,OAAP;AACD;;AACD,WAAOR,IAAI,CAACS,IAAI,CAACC,KAAL,CAAWX,QAAQ,CAACI,KAAT,GAAiBF,IAA5B,CAAD,CAAX;AACD,GAL6B,CAA9B;AAOA,SAAOC,MAAP;AACD","sourcesContent":["import Animated, { useDerivedValue } from 'react-native-reanimated';\nimport type { TCandle } from './types';\n\nimport { useCandlestickChart } from './useCandlestickChart';\n\nexport function useCandleData(): Readonly<Animated.SharedValue<TCandle>> {\n const { currentX, data, step } = useCandlestickChart();\n\n const candle = useDerivedValue(() => {\n if (currentX.value === -1) {\n return { timestamp: -1, low: -1, open: -1, high: -1, close: -1 };\n }\n return data[Math.floor(currentX.value / step)];\n });\n\n return candle;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCandlestickChart.ts"],"names":["React","CandlestickChartContext","useCandlestickChart","useContext"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,uBAAT,QAAwC,WAAxC;
|
|
1
|
+
{"version":3,"sources":["useCandlestickChart.ts"],"names":["React","CandlestickChartContext","useCandlestickChart","useContext"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,uBAAT,QAAwC,WAAxC;AAGA,OAAO,SAASC,mBAAT,GAAyC;AAC9C,SAAOF,KAAK,CAACG,UAAN,CAAiBF,uBAAjB,CAAP;AACD","sourcesContent":["import * as React from 'react';\n\nimport { CandlestickChartContext } from './Context';\nimport type { TContext } from './types';\n\nexport function useCandlestickChart(): TContext {\n return React.useContext(CandlestickChartContext);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDatetime.ts"],"names":["useDerivedValue","formatDatetime","useCandleData","useCandlestickChartDatetime","format","locale","options","candle","timestamp","value","timestampString","toString","formatted","formattedDatetime"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["useDatetime.ts"],"names":["useDerivedValue","formatDatetime","useCandleData","useCandlestickChartDatetime","format","locale","options","candle","timestamp","value","timestampString","toString","formatted","formattedDatetime"],"mappings":"AAAA,SAAmBA,eAAnB,QAA0C,yBAA1C;AAEA,SAASC,cAAT,QAA+B,aAA/B;AAEA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,OAAO,SAASC,2BAAT,CAAqC;AAC1CC,EAAAA,MAD0C;AAE1CC,EAAAA,MAF0C;AAG1CC,EAAAA;AAH0C,IAQxC,EARG,EAWL;AACA,QAAMC,MAAM,GAAGL,aAAa,EAA5B;AAEA,QAAMM,SAAS,GAAGR,eAAe,CAAC,MAAM;AACtC,WAAOO,MAAM,CAACE,KAAP,CAAaD,SAApB;AACD,GAFgC,CAAjC;AAIA,QAAME,eAAe,GAAGV,eAAe,CAAC,MAAM;AAC5C,QAAIQ,SAAS,CAACC,KAAV,KAAoB,CAAC,CAAzB,EAA4B,OAAO,EAAP;AAC5B,WAAOD,SAAS,CAACC,KAAV,CAAgBE,QAAhB,EAAP;AACD,GAHsC,CAAvC;AAKA,QAAMC,SAAS,GAAGZ,eAAe,CAAC,MAAM;AACtC,QAAIQ,SAAS,CAACC,KAAV,KAAoB,CAAC,CAAzB,EAA4B,OAAO,EAAP;AAC5B,UAAMI,iBAAiB,GAAGZ,cAAc,CAAC;AACvCQ,MAAAA,KAAK,EAAED,SAAS,CAACC,KADsB;AAEvCJ,MAAAA,MAFuC;AAGvCC,MAAAA;AAHuC,KAAD,CAAxC;AAKA,WAAOF,MAAM,GACTA,MAAM,CAAC;AAAEK,MAAAA,KAAK,EAAED,SAAS,CAACC,KAAnB;AAA0BG,MAAAA,SAAS,EAAEC;AAArC,KAAD,CADG,GAETA,iBAFJ;AAGD,GAVgC,CAAjC;AAYA,SAAO;AAAEJ,IAAAA,KAAK,EAAEC,eAAT;AAA0BE,IAAAA;AAA1B,GAAP;AACD","sourcesContent":["import Animated, { useDerivedValue } from 'react-native-reanimated';\n\nimport { formatDatetime } from '../../utils';\nimport type { TFormatterFn } from './types';\nimport { useCandleData } from './useCandleData';\n\nexport function useCandlestickChartDatetime({\n format,\n locale,\n options,\n}: {\n format?: TFormatterFn<number>;\n locale?: string;\n options?: { [key: string]: string };\n} = {}): {\n value: Readonly<Animated.SharedValue<string>>;\n formatted: Readonly<Animated.SharedValue<string>>;\n} {\n const candle = useCandleData();\n\n const timestamp = useDerivedValue(() => {\n return candle.value.timestamp;\n });\n\n const timestampString = useDerivedValue(() => {\n if (timestamp.value === -1) return '';\n return timestamp.value.toString();\n });\n\n const formatted = useDerivedValue(() => {\n if (timestamp.value === -1) return '';\n const formattedDatetime = formatDatetime({\n value: timestamp.value,\n locale,\n options,\n });\n return format\n ? format({ value: timestamp.value, formatted: formattedDatetime })\n : formattedDatetime;\n });\n\n return { value: timestampString, formatted };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["usePrice.ts"],"names":["useDerivedValue","formatPrice","useCandlestickChart","getPrice","useCandleData","useCandlestickChartPrice","format","precision","type","currentY","domain","height","candle","float","price","y","value","Math","min","max","maxHeight","toFixed","toString","formatted","formattedPrice"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["usePrice.ts"],"names":["useDerivedValue","formatPrice","useCandlestickChart","getPrice","useCandleData","useCandlestickChartPrice","format","precision","type","currentY","domain","height","candle","float","price","y","value","Math","min","max","maxHeight","toFixed","toString","formatted","formattedPrice"],"mappings":"AAAA,SAAmBA,eAAnB,QAA0C,yBAA1C;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MAAM,GACTA,MAAM,CAAC;AAAEU,MAAAA,KAAK,EAAEH,KAAK,CAACG,KAAf;AAAsBO,MAAAA,SAAS,EAAEC;AAAjC,KAAD,CADG,GAETA,cAFJ;AAGD,GANgC,CAAjC;AAQA,SAAO;AAAER,IAAAA,KAAK,EAAEH,KAAT;AAAgBU,IAAAA;AAAhB,GAAP;AACD","sourcesContent":["import Animated, { useDerivedValue } from 'react-native-reanimated';\n\nimport { formatPrice } from '../../utils';\nimport { useCandlestickChart } from './useCandlestickChart';\nimport { getPrice } from './utils';\nimport type { TFormatterFn, TPriceType } from './types';\nimport { useCandleData } from './useCandleData';\n\nexport function useCandlestickChartPrice({\n format,\n precision = 2,\n type = 'crosshair',\n}: {\n format?: TFormatterFn<string>;\n precision?: number;\n type?: TPriceType;\n} = {}): {\n value: Readonly<Animated.SharedValue<string>>;\n formatted: Readonly<Animated.SharedValue<string>>;\n} {\n const { currentY, domain, height } = useCandlestickChart();\n const candle = useCandleData();\n\n const float = useDerivedValue(() => {\n let price = 0;\n if (type === 'crosshair') {\n price = getPrice({\n y: currentY.value,\n domain: [Math.min(...domain), Math.max(...domain)],\n maxHeight: height,\n });\n } else {\n price = candle.value[type];\n }\n if (price === -1) return '';\n return price.toFixed(precision).toString();\n });\n const formatted = useDerivedValue(() => {\n if (!float.value) return '';\n const formattedPrice = formatPrice({ value: float.value });\n return format\n ? format({ value: float.value, formatted: formattedPrice })\n : formattedPrice;\n });\n\n return { value: float, formatted };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["interpolate","Extrapolate","getDomain","rows","values","map","high","low","flat","min","Math","max","getY","value","domain","maxHeight","CLAMP","getHeight","getPrice","y","reverse"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,yBAAzC;AAIA,OAAO,SAASC,SAAT,CAAmBC,IAAnB,
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["interpolate","Extrapolate","getDomain","rows","values","map","high","low","flat","min","Math","max","getY","value","domain","maxHeight","CLAMP","getHeight","getPrice","y","reverse"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,yBAAzC;AAIA,OAAO,SAASC,SAAT,CAAmBC,IAAnB,EAAgE;AACrE;;AACA,QAAMC,MAAM,GAAGD,IAAI,CAACE,GAAL,CAAS,CAAC;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAD,KAAmB,CAACD,IAAD,EAAOC,GAAP,CAA5B,EAAyCC,IAAzC,EAAf;AACA,QAAMC,GAAG,GAAGC,IAAI,CAACD,GAAL,CAAS,GAAGL,MAAZ,CAAZ;AACA,QAAMO,GAAG,GAAGD,IAAI,CAACC,GAAL,CAAS,GAAGP,MAAZ,CAAZ;AACA,SAAO,CAACK,GAAG,GAAG,CAACE,GAAG,GAAGF,GAAP,IAAc,KAArB,EAA4BE,GAAG,GAAG,CAACA,GAAG,GAAGF,GAAP,IAAc,KAAhD,CAAP;AACD;AAED,OAAO,SAASG,IAAT,CAAc;AACnBC,EAAAA,KADmB;AAEnBC,EAAAA,MAFmB;AAGnBC,EAAAA;AAHmB,CAAd,EAQJ;AACD;;AACA,SAAOf,WAAW,CAACa,KAAD,EAAQC,MAAR,EAAgB,CAACC,SAAD,EAAY,CAAZ,CAAhB,EAAgCd,WAAW,CAACe,KAA5C,CAAlB;AACD;AAED,OAAO,SAASC,SAAT,CAAmB;AACxBJ,EAAAA,KADwB;AAExBC,EAAAA,MAFwB;AAGxBC,EAAAA;AAHwB,CAAnB,EAQJ;AACD;;AACA,SAAOf,WAAW,CAChBa,KADgB,EAEhB,CAAC,CAAD,EAAIH,IAAI,CAACC,GAAL,CAAS,GAAGG,MAAZ,IAAsBJ,IAAI,CAACD,GAAL,CAAS,GAAGK,MAAZ,CAA1B,CAFgB,EAGhB,CAAC,CAAD,EAAIC,SAAJ,CAHgB,EAIhBd,WAAW,CAACe,KAJI,CAAlB;AAMD;AAED,OAAO,SAASE,QAAT,CAAkB;AACvBC,EAAAA,CADuB;AAEvBL,EAAAA,MAFuB;AAGvBC,EAAAA;AAHuB,CAAlB,EAQJ;AACD;;AACA,MAAII,CAAC,KAAK,CAAC,CAAX,EAAc,OAAO,CAAC,CAAR;AACd,SAAOnB,WAAW,CAACmB,CAAD,EAAI,CAAC,CAAD,EAAIJ,SAAJ,CAAJ,EAAoBD,MAAM,CAACM,OAAP,EAApB,EAAsCnB,WAAW,CAACe,KAAlD,CAAlB;AACD","sourcesContent":["import { interpolate, Extrapolate } from 'react-native-reanimated';\n\nimport type { TCandle, TDomain } from './types';\n\nexport function getDomain(rows: TCandle[]): [min: number, max: number] {\n 'worklet';\n const values = rows.map(({ high, low }) => [high, low]).flat();\n const min = Math.min(...values);\n const max = Math.max(...values);\n return [min - (max - min) * 0.025, max + (max - min) * 0.025];\n}\n\nexport function getY({\n value,\n domain,\n maxHeight,\n}: {\n value: number;\n domain: TDomain;\n maxHeight: number;\n}) {\n 'worklet';\n return interpolate(value, domain, [maxHeight, 0], Extrapolate.CLAMP);\n}\n\nexport function getHeight({\n value,\n domain,\n maxHeight,\n}: {\n value: number;\n domain: TDomain;\n maxHeight: number;\n}) {\n 'worklet';\n return interpolate(\n value,\n [0, Math.max(...domain) - Math.min(...domain)],\n [0, maxHeight],\n Extrapolate.CLAMP\n );\n}\n\nexport function getPrice({\n y,\n domain,\n maxHeight,\n}: {\n y: number;\n domain: TDomain;\n maxHeight: number;\n}) {\n 'worklet';\n if (y === -1) return -1;\n return interpolate(y, [0, maxHeight], domain.reverse(), Extrapolate.CLAMP);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Chart.tsx"],"names":["React","Dimensions","View","useLineChart","getPath","LineChartDimensionsContext","createContext","width","height","path","gutter","screenWidth","get","LineChart","children","yGutter","shape","props","data","useMemo","length","contextValue"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,EAAqBC,IAArB,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ASC,IAAT,EAAeF,KAAf,EAAsBQ,OAAtB,CAPmB,CAArB;AAUA,sBACE,oBAAC,0BAAD,CAA4B,QAA5B;AAAqC,IAAA,KAAK,EAAEM;AAA5C,kBACE,oBAAC,IAAD,EAAUJ,KAAV,EAAkBH,QAAlB,CADF,CADF;AAKD","sourcesContent":["import * as React from 'react';\nimport { Dimensions, View, ViewProps } from 'react-native';\n\nimport { useLineChart } from './useLineChart';\nimport { getPath } from './utils';\n\nexport const LineChartDimensionsContext = React.createContext({\n width: 0,\n height: 0,\n path: '',\n gutter: 0,\n});\n\ntype LineChartProps = ViewProps & {\n children: React.ReactNode;\n yGutter?: number;\n width?: number;\n height?: number;\n shape?:
|
|
1
|
+
{"version":3,"sources":["Chart.tsx"],"names":["React","Dimensions","View","useLineChart","getPath","LineChartDimensionsContext","createContext","width","height","path","gutter","screenWidth","get","LineChart","children","yGutter","shape","props","data","useMemo","length","contextValue"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,EAAqBC,IAArB,QAA4C,cAA5C;AAEA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,OAAT,QAAwB,SAAxB;AAEA,OAAO,MAAMC,0BAA0B,gBAAGL,KAAK,CAACM,aAAN,CAAoB;AAC5DC,EAAAA,KAAK,EAAE,CADqD;AAE5DC,EAAAA,MAAM,EAAE,CAFoD;AAG5DC,EAAAA,IAAI,EAAE,EAHsD;AAI5DC,EAAAA,MAAM,EAAE;AAJoD,CAApB,CAAnC;AAeP,MAAM;AAAEH,EAAAA,KAAK,EAAEI;AAAT,IAAyBV,UAAU,CAACW,GAAX,CAAe,QAAf,CAA/B;AAEA,OAAO,SAASC,SAAT,CAAmB;AACxBC,EAAAA,QADwB;AAExBC,EAAAA,OAAO,GAAG,EAFc;AAGxBR,EAAAA,KAAK,GAAGI,WAHgB;AAIxBH,EAAAA,MAAM,GAAGG,WAJe;AAKxBK,EAAAA,KALwB;AAMxB,KAAGC;AANqB,CAAnB,EAOY;AACjB,QAAM;AAAEC,IAAAA;AAAF,MAAWf,YAAY,EAA7B;AAEA,QAAMM,IAAI,GAAGT,KAAK,CAACmB,OAAN,CAAc,MAAM;AAC/B,QAAID,IAAI,IAAIA,IAAI,CAACE,MAAL,GAAc,CAA1B,EAA6B;AAC3B,aAAOhB,OAAO,CAAC;AAAEc,QAAAA,IAAF;AAAQX,QAAAA,KAAR;AAAeC,QAAAA,MAAf;AAAuBE,QAAAA,MAAM,EAAEK,OAA/B;AAAwCC,QAAAA;AAAxC,OAAD,CAAd;AACD;;AACD,WAAO,EAAP;AACD,GALY,EAKV,CAACE,IAAD,EAAOX,KAAP,EAAcC,MAAd,EAAsBO,OAAtB,EAA+BC,KAA/B,CALU,CAAb;AAOA,QAAMK,YAAY,GAAGrB,KAAK,CAACmB,OAAN,CACnB,OAAO;AACLT,IAAAA,MAAM,EAAEK,OADH;AAELN,IAAAA,IAFK;AAGLF,IAAAA,KAHK;AAILC,IAAAA;AAJK,GAAP,CADmB,EAOnB,CAACA,MAAD,EAASC,IAAT,EAAeF,KAAf,EAAsBQ,OAAtB,CAPmB,CAArB;AAUA,sBACE,oBAAC,0BAAD,CAA4B,QAA5B;AAAqC,IAAA,KAAK,EAAEM;AAA5C,kBACE,oBAAC,IAAD,EAAUJ,KAAV,EAAkBH,QAAlB,CADF,CADF;AAKD","sourcesContent":["import * as React from 'react';\nimport { Dimensions, View, ViewProps } from 'react-native';\n\nimport { useLineChart } from './useLineChart';\nimport { getPath } from './utils';\n\nexport const LineChartDimensionsContext = React.createContext({\n width: 0,\n height: 0,\n path: '',\n gutter: 0,\n});\n\ntype LineChartProps = ViewProps & {\n children: React.ReactNode;\n yGutter?: number;\n width?: number;\n height?: number;\n shape?: string;\n};\n\nconst { width: screenWidth } = Dimensions.get('window');\n\nexport function LineChart({\n children,\n yGutter = 16,\n width = screenWidth,\n height = screenWidth,\n shape,\n ...props\n}: LineChartProps) {\n const { data } = useLineChart();\n\n const path = React.useMemo(() => {\n if (data && data.length > 0) {\n return getPath({ data, width, height, gutter: yGutter, shape });\n }\n return '';\n }, [data, width, height, yGutter, shape]);\n\n const contextValue = React.useMemo(\n () => ({\n gutter: yGutter,\n path,\n width,\n height,\n }),\n [height, path, width, yGutter]\n );\n\n return (\n <LineChartDimensionsContext.Provider value={contextValue}>\n <View {...props}>{children}</View>\n </LineChartDimensionsContext.Provider>\n );\n}\n"]}
|