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":["useDerivedValue","formatDatetime","useLineChart","useLineChartDatetime","format","locale","options","currentIndex","data","timestamp","value","timestampString","toString","formatted","formattedDatetime"],"mappings":"AAAA,SAASA,eAAT,QAAgC,yBAAhC;AAEA,SAASC,cAAT,QAA+B,aAA/B;
|
|
1
|
+
{"version":3,"sources":["useDatetime.ts"],"names":["useDerivedValue","formatDatetime","useLineChart","useLineChartDatetime","format","locale","options","currentIndex","data","timestamp","value","timestampString","toString","formatted","formattedDatetime"],"mappings":"AAAA,SAASA,eAAT,QAAgC,yBAAhC;AAEA,SAASC,cAAT,QAA+B,aAA/B;AAEA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,OAAO,SAASC,oBAAT,CAA8B;AACnCC,EAAAA,MADmC;AAEnCC,EAAAA,MAFmC;AAGnCC,EAAAA;AAHmC,IAQjC,EARG,EAQC;AACN,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAyBN,YAAY,EAA3C;AAEA,QAAMO,SAAS,GAAGT,eAAe,CAAC,MAAM;AACtC,QAAI,OAAOO,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,GAJgC,CAAjC;AAMA,QAAME,eAAe,GAAGX,eAAe,CAAC,MAAM;AAC5C,QAAIS,SAAS,CAACC,KAAV,KAAoB,EAAxB,EAA4B,OAAO,EAAP;AAC5B,WAAOD,SAAS,CAACC,KAAV,CAAgBE,QAAhB,EAAP;AACD,GAHsC,CAAvC;AAKA,QAAMC,SAAS,GAAGb,eAAe,CAAC,MAAM;AACtC,QAAIS,SAAS,CAACC,KAAV,KAAoB,EAAxB,EAA4B,OAAO,EAAP;AAC5B,UAAMI,iBAAiB,GAAGb,cAAc,CAAC;AACvCS,MAAAA,KAAK,EAAED,SAAS,CAACC,KADsB;AAEvCL,MAAAA,MAFuC;AAGvCC,MAAAA;AAHuC,KAAD,CAAxC;AAKA,WAAOF,MAAM,GACTA,MAAM,CAAC;AAAEM,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 { 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":["useDerivedValue","formatPrice","useLineChart","useLineChartPrice","format","precision","currentIndex","data","float","value","price","toFixed","toString","formatted","formattedPrice"],"mappings":"AAAA,SAASA,eAAT,QAAgC,yBAAhC;AAEA,SAASC,WAAT,QAA4B,aAA5B;
|
|
1
|
+
{"version":3,"sources":["usePrice.ts"],"names":["useDerivedValue","formatPrice","useLineChart","useLineChartPrice","format","precision","currentIndex","data","float","value","price","toFixed","toString","formatted","formattedPrice"],"mappings":"AAAA,SAASA,eAAT,QAAgC,yBAAhC;AAEA,SAASC,WAAT,QAA4B,aAA5B;AAEA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,OAAO,SAASC,iBAAT,CAA2B;AAChCC,EAAAA,MADgC;AAEhCC,EAAAA,SAAS,GAAG;AAFoB,IAGyB,EAHpD,EAGwD;AAC7D,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAyBL,YAAY,EAA3C;AAEA,QAAMM,KAAK,GAAGR,eAAe,CAAC,MAAM;AAClC,QAAI,OAAOM,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,GAN4B,CAA7B;AAOA,QAAMC,SAAS,GAAGb,eAAe,CAAC,MAAM;AACtC,QAAI,CAACQ,KAAK,CAACC,KAAX,EAAkB,OAAO,EAAP;AAClB,UAAMK,cAAc,GAAGb,WAAW,CAAC;AAAEQ,MAAAA,KAAK,EAAED,KAAK,CAACC;AAAf,KAAD,CAAlC;AACA,WAAOL,MAAM,GACTA,MAAM,CAAC;AAAEK,MAAAA,KAAK,EAAED,KAAK,CAACC,KAAf;AAAsBI,MAAAA,SAAS,EAAEC;AAAjC,KAAD,CADG,GAETA,cAFJ;AAGD,GANgC,CAAjC;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"]}
|
|
@@ -23,72 +23,7 @@ export function getPath({
|
|
|
23
23
|
}) => value);
|
|
24
24
|
const scaleX = scaleLinear().domain([Math.min(...timestamps), Math.max(...timestamps)]).range([0, width]);
|
|
25
25
|
const scaleY = scaleLinear().domain([Math.min(...values), Math.max(...values)]).range([height - gutter, gutter]);
|
|
26
|
-
const path = shape.line().x((_, i) => scaleX(i)).y(
|
|
26
|
+
const path = shape.line().x((_, i) => scaleX(i)).y(d => scaleY(d.value)).curve(_shape)(data);
|
|
27
27
|
return path;
|
|
28
28
|
}
|
|
29
|
-
export function syncChangingPaths({
|
|
30
|
-
pointsToAdd,
|
|
31
|
-
parsedPath,
|
|
32
|
-
curves
|
|
33
|
-
}) {
|
|
34
|
-
'worklet';
|
|
35
|
-
|
|
36
|
-
const firstPoint = curves === null || curves === void 0 ? void 0 : curves[0];
|
|
37
|
-
let newParsedPath = parsedPath;
|
|
38
|
-
|
|
39
|
-
for (let i = 0; i < Math.abs(pointsToAdd); i++) {
|
|
40
|
-
newParsedPath = { ...newParsedPath,
|
|
41
|
-
curves: [{
|
|
42
|
-
c1: {
|
|
43
|
-
x: firstPoint.c1.x,
|
|
44
|
-
y: firstPoint.c1.y
|
|
45
|
-
},
|
|
46
|
-
c2: {
|
|
47
|
-
x: firstPoint.c2.x,
|
|
48
|
-
y: firstPoint.c2.y
|
|
49
|
-
},
|
|
50
|
-
to: {
|
|
51
|
-
x: firstPoint.to.x,
|
|
52
|
-
y: firstPoint.to.y
|
|
53
|
-
}
|
|
54
|
-
}, ...newParsedPath.curves]
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return newParsedPath;
|
|
59
|
-
}
|
|
60
|
-
export function syncPaths({
|
|
61
|
-
parsedPath,
|
|
62
|
-
previousParsedPath
|
|
63
|
-
}) {
|
|
64
|
-
'worklet';
|
|
65
|
-
|
|
66
|
-
const previousCurves = previousParsedPath === null || previousParsedPath === void 0 ? void 0 : previousParsedPath.curves;
|
|
67
|
-
const nextCurves = parsedPath === null || parsedPath === void 0 ? void 0 : parsedPath.curves;
|
|
68
|
-
let newPreviousParsedPath = previousParsedPath || parsedPath;
|
|
69
|
-
let newParsedPath = parsedPath;
|
|
70
|
-
|
|
71
|
-
if ((previousCurves === null || previousCurves === void 0 ? void 0 : previousCurves.length) !== (nextCurves === null || nextCurves === void 0 ? void 0 : nextCurves.length)) {
|
|
72
|
-
const pointsToAdd = (nextCurves === null || nextCurves === void 0 ? void 0 : nextCurves.length) - (previousCurves === null || previousCurves === void 0 ? void 0 : previousCurves.length) || 0;
|
|
73
|
-
|
|
74
|
-
if (pointsToAdd > 0) {
|
|
75
|
-
newPreviousParsedPath = syncChangingPaths({
|
|
76
|
-
pointsToAdd,
|
|
77
|
-
parsedPath: newPreviousParsedPath,
|
|
78
|
-
curves: previousCurves
|
|
79
|
-
});
|
|
80
|
-
} else if (pointsToAdd < 0) {
|
|
81
|
-
newParsedPath = syncChangingPaths({
|
|
82
|
-
pointsToAdd,
|
|
83
|
-
parsedPath: newParsedPath,
|
|
84
|
-
curves: nextCurves
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
previousParsedPath: newPreviousParsedPath,
|
|
91
|
-
parsedPath: newParsedPath
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
29
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["shape","scaleLinear","getDomain","rows","values","map","value","flat","Math","min","max","getPath","data","width","height","gutter","_shape","curveBumpX","timestamps","i","scaleX","domain","range","scaleY","path","line","x","_","y","
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["shape","scaleLinear","getDomain","rows","values","map","value","flat","Math","min","max","getPath","data","width","height","gutter","_shape","curveBumpX","timestamps","i","scaleX","domain","range","scaleY","path","line","x","_","y","d","curve"],"mappings":"AAAA;AACA,OAAO,KAAKA,KAAZ,MAAuB,UAAvB,C,CACA;;AACA,SAASC,WAAT,QAA4B,UAA5B;AAIA,OAAO,SAASC,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,CAACC,GAAL,CAAS,GAAGL,MAAZ,CAAD,EAAsBI,IAAI,CAACE,GAAL,CAAS,GAAGN,MAAZ,CAAtB,CAAP;AACD;AAED,OAAO,SAASO,OAAT,CAAiB;AACtBC,EAAAA,IADsB;AAEtBC,EAAAA,KAFsB;AAGtBC,EAAAA,MAHsB;AAItBC,EAAAA,MAJsB;AAKtBf,EAAAA,KAAK,EAAEgB,MAAM,GAAGhB,KAAK,CAACiB;AALA,CAAjB,EAYI;AACT,QAAMC,UAAU,GAAGN,IAAI,CAACP,GAAL,CAAS,CAAC,EAAD,EAAKc,CAAL,KAAWA,CAApB,CAAnB;AACA,QAAMf,MAAM,GAAGQ,IAAI,CAACP,GAAL,CAAS,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAeA,KAAxB,CAAf;AACA,QAAMc,MAAM,GAAGnB,WAAW,GACvBoB,MADY,CACL,CAACb,IAAI,CAACC,GAAL,CAAS,GAAGS,UAAZ,CAAD,EAA0BV,IAAI,CAACE,GAAL,CAAS,GAAGQ,UAAZ,CAA1B,CADK,EAEZI,KAFY,CAEN,CAAC,CAAD,EAAIT,KAAJ,CAFM,CAAf;AAGA,QAAMU,MAAM,GAAGtB,WAAW,GACvBoB,MADY,CACL,CAACb,IAAI,CAACC,GAAL,CAAS,GAAGL,MAAZ,CAAD,EAAsBI,IAAI,CAACE,GAAL,CAAS,GAAGN,MAAZ,CAAtB,CADK,EAEZkB,KAFY,CAEN,CAACR,MAAM,GAAGC,MAAV,EAAkBA,MAAlB,CAFM,CAAf;AAGA,QAAMS,IAAI,GAAGxB,KAAK,CACfyB,IADU,GAEVC,CAFU,CAER,CAACC,CAAD,EAAaR,CAAb,KAA2BC,MAAM,CAACD,CAAD,CAFzB,EAGVS,CAHU,CAGPC,CAAD,IAA2BN,MAAM,CAACM,CAAC,CAACvB,KAAH,CAHzB,EAIVwB,KAJU,CAIJd,MAJI,EAIIJ,IAJJ,CAAb;AAKA,SAAOY,IAAP;AACD","sourcesContent":["// @ts-ignore\nimport * as shape from 'd3-shape';\n// @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,43 @@
|
|
|
1
|
+
// forked from https://github.com/wcandillon/react-native-redash/blob/master/src/ReText.tsx
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { TextInput } from 'react-native';
|
|
5
|
+
import Animated, { useAnimatedProps, useAnimatedReaction } from 'react-native-reanimated';
|
|
6
|
+
Animated.addWhitelistedNativeProps({
|
|
7
|
+
text: true
|
|
8
|
+
});
|
|
9
|
+
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
|
|
10
|
+
export const AnimatedText = ({
|
|
11
|
+
text,
|
|
12
|
+
style
|
|
13
|
+
}) => {
|
|
14
|
+
const inputRef = React.useRef(null);
|
|
15
|
+
useAnimatedReaction(() => {
|
|
16
|
+
// always return false unless web to prevent unnecessary reactions
|
|
17
|
+
return Platform.OS === 'web' && text.value;
|
|
18
|
+
}, (data, prevData) => {
|
|
19
|
+
if (Platform.OS === 'web' && data !== prevData && inputRef.current) {
|
|
20
|
+
inputRef.current.setNativeProps({
|
|
21
|
+
value: data
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const animatedProps = useAnimatedProps(() => {
|
|
26
|
+
return {
|
|
27
|
+
text: text.value // Here we use any because the text prop is not available in the type
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/React.createElement(AnimatedTextInput, {
|
|
33
|
+
underlineColorAndroid: "transparent",
|
|
34
|
+
editable: false,
|
|
35
|
+
ref: Platform.select({
|
|
36
|
+
web: inputRef
|
|
37
|
+
}),
|
|
38
|
+
value: text.value,
|
|
39
|
+
style: style,
|
|
40
|
+
animatedProps: animatedProps
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=AnimatedText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["AnimatedText.tsx"],"names":["React","Platform","TextInput","Animated","useAnimatedProps","useAnimatedReaction","addWhitelistedNativeProps","text","AnimatedTextInput","createAnimatedComponent","AnimatedText","style","inputRef","useRef","OS","value","data","prevData","current","setNativeProps","animatedProps","select","web"],"mappings":"AAAA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,QAAT,QAAmD,cAAnD;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,OAAOC,QAAP,IACEC,gBADF,EAEEC,mBAFF,QAGO,yBAHP;AAKAF,QAAQ,CAACG,yBAAT,CAAmC;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAAnC;AAOA,MAAMC,iBAAiB,GAAGL,QAAQ,CAACM,uBAAT,CAAiCP,SAAjC,CAA1B;AAEA,OAAO,MAAMQ,YAAY,GAAG,CAAC;AAAEH,EAAAA,IAAF;AAAQI,EAAAA;AAAR,CAAD,KAAwC;AAClE,QAAMC,QAAQ,GAAGZ,KAAK,CAACa,MAAN,CAAwB,IAAxB,CAAjB;AAEAR,EAAAA,mBAAmB,CACjB,MAAM;AACJ;AACA,WAAOJ,QAAQ,CAACa,EAAT,KAAgB,KAAhB,IAAyBP,IAAI,CAACQ,KAArC;AACD,GAJgB,EAKjB,CAACC,IAAD,EAAOC,QAAP,KAAoB;AAClB,QAAIhB,QAAQ,CAACa,EAAT,KAAgB,KAAhB,IAAyBE,IAAI,KAAKC,QAAlC,IAA8CL,QAAQ,CAACM,OAA3D,EAAoE;AAClEN,MAAAA,QAAQ,CAACM,OAAT,CAAiBC,cAAjB,CAAgC;AAC9BJ,QAAAA,KAAK,EAAEC;AADuB,OAAhC;AAGD;AACF,GAXgB,CAAnB;AAaA,QAAMI,aAAa,GAAGhB,gBAAgB,CAAC,MAAM;AAC3C,WAAO;AACLG,MAAAA,IAAI,EAAEA,IAAI,CAACQ,KADN,CAEL;AACA;;AAHK,KAAP;AAKD,GANqC,CAAtC;AAOA,sBACE,oBAAC,iBAAD;AACE,IAAA,qBAAqB,EAAC,aADxB;AAEE,IAAA,QAAQ,EAAE,KAFZ;AAGE,IAAA,GAAG,EAAEd,QAAQ,CAACoB,MAAT,CAAgB;AAAEC,MAAAA,GAAG,EAAEV;AAAP,KAAhB,CAHP;AAIE,IAAA,KAAK,EAAEL,IAAI,CAACQ,KAJd;AAKE,IAAA,KAAK,EAAEJ,KALT;AAME,IAAA,aAAa,EAAES;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"]}
|
package/lib/module/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["React","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","useRef","useEffect","current"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAO,SAASC,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;AAED,OAAO,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;AAED,OAAO,SAASI,WAAT,
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["React","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","useRef","useEffect","current"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAO,SAASC,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;AAED,OAAO,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;AAED,OAAO,SAASI,WAAT,CAAwBxB,KAAxB,EAAkC;AACvC;AACA;AACA,QAAMyB,GAAG,GAAG3B,KAAK,CAAC4B,MAAN,EAAZ,CAHuC,CAIvC;;AACA5B,EAAAA,KAAK,CAAC6B,SAAN,CAAgB,MAAM;AACpBF,IAAAA,GAAG,CAACG,OAAJ,GAAc5B,KAAd;AACD,GAFD,EAEG,CAACA,KAAD,CAFH,EALuC,CAO1B;AACb;;AACA,SAAOyB,GAAG,CAACG,OAAX;AACD","sourcesContent":["import * as React from 'react';\n\nexport function formatPrice({\n value: _value,\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"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { LongPressGestureHandlerProps } from 'react-native-gesture-handler';
|
|
4
4
|
import Animated from 'react-native-reanimated';
|
|
5
5
|
import { CandlestickChartLineProps } from './Line';
|
|
6
|
-
declare type CandlestickChartCrosshairProps =
|
|
6
|
+
declare type CandlestickChartCrosshairProps = LongPressGestureHandlerProps & {
|
|
7
7
|
color?: string;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
|
-
|
|
9
|
+
onCurrentXChange?: (value: number) => unknown;
|
|
10
10
|
horizontalCrosshairProps?: Animated.AnimateProps<ViewProps>;
|
|
11
11
|
verticalCrosshairProps?: Animated.AnimateProps<ViewProps>;
|
|
12
12
|
lineProps?: Partial<CandlestickChartLineProps>;
|
|
13
13
|
};
|
|
14
|
-
export declare function CandlestickChartCrosshair({ color,
|
|
14
|
+
export declare function CandlestickChartCrosshair({ color, onCurrentXChange, children, horizontalCrosshairProps, verticalCrosshairProps, lineProps, ...props }: CandlestickChartCrosshairProps): JSX.Element;
|
|
15
15
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TextProps as RNTextProps } from 'react-native';
|
|
3
3
|
import type Animated from 'react-native-reanimated';
|
|
4
|
+
import type { TFormatterFn } from 'react-native-wagmi-charts';
|
|
4
5
|
declare type CandlestickChartPriceTextProps = {
|
|
5
6
|
locale?: string;
|
|
6
7
|
options?: {
|
|
7
8
|
[key: string]: string;
|
|
8
9
|
};
|
|
9
|
-
format?:
|
|
10
|
+
format?: TFormatterFn<number>;
|
|
10
11
|
variant?: 'formatted' | 'value';
|
|
11
12
|
style?: Animated.AnimateProps<RNTextProps>['style'];
|
|
12
13
|
};
|
|
13
|
-
export declare function CandlestickChartDatetimeText({ locale, options, format, variant,
|
|
14
|
+
export declare function CandlestickChartDatetimeText({ locale, options, format, variant, style, }: CandlestickChartPriceTextProps): JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LineProps } from 'react-native-svg';
|
|
3
|
-
export declare type CandlestickChartLineProps = LineProps & {
|
|
3
|
+
export declare type CandlestickChartLineProps = Omit<LineProps, 'x' | 'y'> & {
|
|
4
4
|
color?: string;
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TextProps as RNTextProps } from 'react-native';
|
|
3
3
|
import type Animated from 'react-native-reanimated';
|
|
4
|
-
import type { TPriceType } from './types';
|
|
4
|
+
import type { TFormatterFn, TPriceType } from './types';
|
|
5
5
|
export declare type CandlestickChartPriceTextProps = {
|
|
6
|
-
format?:
|
|
6
|
+
format?: TFormatterFn<string>;
|
|
7
7
|
precision?: number;
|
|
8
8
|
variant?: 'formatted' | 'value';
|
|
9
9
|
type?: TPriceType;
|
|
10
10
|
style?: Animated.AnimateProps<RNTextProps>['style'];
|
|
11
11
|
};
|
|
12
|
-
export declare function CandlestickChartPriceText({ format, precision, variant, type,
|
|
12
|
+
export declare function CandlestickChartPriceText({ format, precision, variant, type, style, }: CandlestickChartPriceTextProps): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type React from 'react';
|
|
1
2
|
import type Animated from 'react-native-reanimated';
|
|
2
3
|
export declare type TCandle = {
|
|
3
4
|
timestamp: number;
|
|
@@ -7,7 +8,7 @@ export declare type TCandle = {
|
|
|
7
8
|
close: number;
|
|
8
9
|
};
|
|
9
10
|
export declare type TData = Array<TCandle>;
|
|
10
|
-
export declare type TDomain = [number, number];
|
|
11
|
+
export declare type TDomain = [min: number, max: number];
|
|
11
12
|
export declare type TContext = {
|
|
12
13
|
currentX: Animated.SharedValue<number>;
|
|
13
14
|
currentY: Animated.SharedValue<number>;
|
|
@@ -16,7 +17,11 @@ export declare type TContext = {
|
|
|
16
17
|
height: number;
|
|
17
18
|
domain: TDomain;
|
|
18
19
|
step: number;
|
|
19
|
-
setWidth:
|
|
20
|
-
setHeight:
|
|
20
|
+
setWidth: React.Dispatch<React.SetStateAction<number>>;
|
|
21
|
+
setHeight: React.Dispatch<React.SetStateAction<number>>;
|
|
21
22
|
};
|
|
22
23
|
export declare type TPriceType = 'crosshair' | 'open' | 'close' | 'low' | 'high';
|
|
24
|
+
export declare type TFormatterFn<T> = ({ value, formatted, }: {
|
|
25
|
+
value: T;
|
|
26
|
+
formatted: string;
|
|
27
|
+
}) => string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
import type { TCandle } from './types';
|
|
3
|
+
export declare function useCandleData(): Readonly<Animated.SharedValue<TCandle>>;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TContext } from './types';
|
|
2
|
+
export declare function useCandlestickChart(): TContext;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
import type { TFormatterFn } from './types';
|
|
1
3
|
export declare function useCandlestickChartDatetime({ format, locale, options, }?: {
|
|
2
|
-
format?:
|
|
4
|
+
format?: TFormatterFn<number>;
|
|
3
5
|
locale?: string;
|
|
4
6
|
options?: {
|
|
5
7
|
[key: string]: string;
|
|
6
8
|
};
|
|
7
9
|
}): {
|
|
8
|
-
value: Readonly<
|
|
9
|
-
|
|
10
|
-
}>;
|
|
11
|
-
formatted: Readonly<{
|
|
12
|
-
value: any;
|
|
13
|
-
}>;
|
|
10
|
+
value: Readonly<Animated.SharedValue<string>>;
|
|
11
|
+
formatted: Readonly<Animated.SharedValue<string>>;
|
|
14
12
|
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
import type { TFormatterFn, TPriceType } from './types';
|
|
2
3
|
export declare function useCandlestickChartPrice({ format, precision, type, }?: {
|
|
3
|
-
format?:
|
|
4
|
+
format?: TFormatterFn<string>;
|
|
4
5
|
precision?: number;
|
|
5
6
|
type?: TPriceType;
|
|
6
7
|
}): {
|
|
7
|
-
value: Readonly<
|
|
8
|
-
|
|
9
|
-
}>;
|
|
10
|
-
formatted: Readonly<{
|
|
11
|
-
value: any;
|
|
12
|
-
}>;
|
|
8
|
+
value: Readonly<Animated.SharedValue<string>>;
|
|
9
|
+
formatted: Readonly<Animated.SharedValue<string>>;
|
|
13
10
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TCandle, TDomain } from './types';
|
|
2
|
-
export declare function getDomain(rows: TCandle[]): [number, number];
|
|
2
|
+
export declare function getDomain(rows: TCandle[]): [min: number, max: number];
|
|
3
3
|
export declare function getY({ value, domain, maxHeight, }: {
|
|
4
4
|
value: number;
|
|
5
5
|
domain: TDomain;
|
|
@@ -11,7 +11,7 @@ declare type LineChartProps = ViewProps & {
|
|
|
11
11
|
yGutter?: number;
|
|
12
12
|
width?: number;
|
|
13
13
|
height?: number;
|
|
14
|
-
shape?:
|
|
14
|
+
shape?: string;
|
|
15
15
|
};
|
|
16
16
|
export declare function LineChart({ children, yGutter, width, height, shape, ...props }: LineChartProps): JSX.Element;
|
|
17
17
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { LongPressGestureHandlerProps } from 'react-native-gesture-handler';
|
|
3
|
-
declare type LineChartCursorProps = LongPressGestureHandlerProps & {
|
|
3
|
+
export declare type LineChartCursorProps = LongPressGestureHandlerProps & {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
type: 'line' | 'crosshair';
|
|
6
6
|
};
|
|
@@ -8,4 +8,3 @@ export declare const CursorContext: React.Context<{
|
|
|
8
8
|
type: string;
|
|
9
9
|
}>;
|
|
10
10
|
export declare function LineChartCursor({ children, type, ...props }: LineChartCursorProps): JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
3
|
import Animated from 'react-native-reanimated';
|
|
4
|
-
|
|
4
|
+
import { LineChartCursorProps } from './Cursor';
|
|
5
|
+
declare type LineChartCursorCrosshairProps = Omit<LineChartCursorProps, 'type'> & {
|
|
5
6
|
children?: React.ReactNode;
|
|
6
7
|
color?: string;
|
|
7
8
|
size?: number;
|
|
@@ -10,5 +11,5 @@ declare type LineChartCursorCrosshairProps = {
|
|
|
10
11
|
crosshairProps?: ViewProps;
|
|
11
12
|
crosshairOuterProps?: ViewProps;
|
|
12
13
|
};
|
|
13
|
-
export declare function LineChartCursorCrosshair({ children, color, size, outerSize, crosshairWrapperProps, crosshairProps, crosshairOuterProps, }: LineChartCursorCrosshairProps): JSX.Element;
|
|
14
|
+
export declare function LineChartCursorCrosshair({ children, color, size, outerSize, crosshairWrapperProps, crosshairProps, crosshairOuterProps, ...props }: LineChartCursorCrosshairProps): JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TextProps as RNTextProps } from 'react-native';
|
|
3
3
|
import type Animated from 'react-native-reanimated';
|
|
4
|
-
|
|
4
|
+
import type { TFormatterFn } from 'react-native-wagmi-charts';
|
|
5
|
+
declare type LineChartDatetimeProps = {
|
|
5
6
|
locale?: string;
|
|
6
|
-
options?:
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
format?: any;
|
|
7
|
+
options?: Intl.DateTimeFormatOptions;
|
|
8
|
+
format?: TFormatterFn<number>;
|
|
10
9
|
variant?: 'formatted' | 'value';
|
|
11
10
|
style?: Animated.AnimateProps<RNTextProps>['style'];
|
|
12
11
|
};
|
|
13
|
-
export declare function LineChartDatetimeText({ locale, options, format, variant,
|
|
12
|
+
export declare function LineChartDatetimeText({ locale, options, format, variant, style, }: LineChartDatetimeProps): JSX.Element;
|
|
14
13
|
export {};
|
|
@@ -5,5 +5,21 @@ export declare type LineChartPathProps = Animated.AnimateProps<PathProps> & {
|
|
|
5
5
|
color?: string;
|
|
6
6
|
width?: number;
|
|
7
7
|
isInactive?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Default: `true`.
|
|
10
|
+
*
|
|
11
|
+
* If `false`, changes in the chart's path will not animate.
|
|
12
|
+
*
|
|
13
|
+
* While this use case is rare, it may be useful on web, where animations might not work as well.
|
|
14
|
+
*
|
|
15
|
+
* **Example**
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <LineChart.Path
|
|
19
|
+
* pathProps={{ isTransitionEnabled: Platform.OS !== 'web' }}
|
|
20
|
+
* />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
isTransitionEnabled?: boolean;
|
|
8
24
|
};
|
|
9
|
-
export declare function LineChartPath({ color, width, isInactive, ...props }: LineChartPathProps): JSX.Element;
|
|
25
|
+
export declare function LineChartPath({ color, width, isInactive, isTransitionEnabled, ...props }: LineChartPathProps): JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TextProps as RNTextProps } from 'react-native';
|
|
3
3
|
import type Animated from 'react-native-reanimated';
|
|
4
|
+
import type { TFormatterFn } from '../candle/types';
|
|
4
5
|
export declare type LineChartPriceTextProps = {
|
|
5
|
-
format?:
|
|
6
|
+
format?: TFormatterFn<string>;
|
|
6
7
|
precision?: number;
|
|
7
8
|
variant?: 'formatted' | 'value';
|
|
8
9
|
style?: Animated.AnimateProps<RNTextProps>['style'];
|
|
9
10
|
};
|
|
10
|
-
export declare function LineChartPriceText({ format, precision, variant,
|
|
11
|
+
export declare function LineChartPriceText({ format, precision, variant, style, }: LineChartPriceTextProps): JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert command objects to arrays of points, run de Casteljau's algorithm on it
|
|
3
|
+
* to split into to the desired number of segments.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} commandStart The start command object
|
|
6
|
+
* @param {Object} commandEnd The end command object
|
|
7
|
+
* @param {Number} segmentCount The number of segments to create
|
|
8
|
+
* @return {Object[]} An array of commands representing the segments in sequence
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitCurve(commandStart: any, commandEnd: any, segmentCount: any): {}[];
|
|
11
|
+
/**
|
|
12
|
+
* Takes a path `d` string and converts it into an array of command
|
|
13
|
+
* objects. Drops the `Z` character.
|
|
14
|
+
*
|
|
15
|
+
* @param {String|null} d A path `d` string
|
|
16
|
+
*/
|
|
17
|
+
export declare function pathCommandsFromString(d: any): {
|
|
18
|
+
type: any;
|
|
19
|
+
}[];
|
|
20
|
+
/**
|
|
21
|
+
* Interpolate from A to B by extending A and B during interpolation to have
|
|
22
|
+
* the same number of points. This allows for a smooth transition when they
|
|
23
|
+
* have a different number of points.
|
|
24
|
+
*
|
|
25
|
+
* Ignores the `Z` command in paths unless both A and B end with it.
|
|
26
|
+
*
|
|
27
|
+
* This function works directly with arrays of command objects instead of with
|
|
28
|
+
* path `d` strings (see interpolatePath for working with `d` strings).
|
|
29
|
+
*
|
|
30
|
+
* @param {Object[]} aCommandsInput Array of path commands
|
|
31
|
+
* @param {Object[]} bCommandsInput Array of path commands
|
|
32
|
+
* @param {Function} excludeSegment a function that takes a start command object and
|
|
33
|
+
* end command object and returns true if the segment should be excluded from splitting.
|
|
34
|
+
* @returns {Function} Interpolation function that maps t ([0, 1]) to an array of path commands.
|
|
35
|
+
*/
|
|
36
|
+
export declare function interpolatePathCommands(aCommandsInput: any, bCommandsInput: any, excludeSegment: any): (t: any) => any;
|
|
37
|
+
/**
|
|
38
|
+
* Interpolate from A to B by extending A and B during interpolation to have
|
|
39
|
+
* the same number of points. This allows for a smooth transition when they
|
|
40
|
+
* have a different number of points.
|
|
41
|
+
*
|
|
42
|
+
* Ignores the `Z` character in paths unless both A and B end with it.
|
|
43
|
+
*
|
|
44
|
+
* @param {String} a The `d` attribute for a path
|
|
45
|
+
* @param {String} b The `d` attribute for a path
|
|
46
|
+
* @param {Function} excludeSegment a function that takes a start command object and
|
|
47
|
+
* end command object and returns true if the segment should be excluded from splitting.
|
|
48
|
+
* @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string.
|
|
49
|
+
*/
|
|
50
|
+
export default function interpolatePath(a: any, b: any, excludeSegment: any): (t: any) => any;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import type { TFormatterFn } from '../candle/types';
|
|
1
2
|
export declare function useLineChartDatetime({ format, locale, options, }?: {
|
|
2
|
-
format?:
|
|
3
|
+
format?: TFormatterFn<number>;
|
|
3
4
|
locale?: string;
|
|
4
|
-
options?:
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
};
|
|
5
|
+
options?: Intl.DateTimeFormatOptions;
|
|
7
6
|
}): {
|
|
8
7
|
value: Readonly<{
|
|
9
8
|
value: string;
|
|
10
9
|
}>;
|
|
11
10
|
formatted: Readonly<{
|
|
12
|
-
value:
|
|
11
|
+
value: string;
|
|
13
12
|
}>;
|
|
14
13
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { TFormatterFn } from '../candle/types';
|
|
1
2
|
export declare function useLineChartPrice({ format, precision, }?: {
|
|
2
|
-
format?:
|
|
3
|
+
format?: TFormatterFn<string>;
|
|
3
4
|
precision?: number;
|
|
4
5
|
}): {
|
|
5
6
|
value: Readonly<{
|
|
6
7
|
value: string;
|
|
7
8
|
}>;
|
|
8
9
|
formatted: Readonly<{
|
|
9
|
-
value:
|
|
10
|
+
value: string;
|
|
10
11
|
}>;
|
|
11
12
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TLineChartData, TLineChartPoint } from './types';
|
|
2
|
-
import type { Path } from 'react-native-redash';
|
|
3
2
|
export declare function getDomain(rows: TLineChartPoint[]): [number, number];
|
|
4
3
|
export declare function getPath({ data, width, height, gutter, shape: _shape, }: {
|
|
5
4
|
data: TLineChartData;
|
|
@@ -8,15 +7,3 @@ export declare function getPath({ data, width, height, gutter, shape: _shape, }:
|
|
|
8
7
|
gutter: number;
|
|
9
8
|
shape?: string;
|
|
10
9
|
}): string;
|
|
11
|
-
export declare function syncChangingPaths({ pointsToAdd, parsedPath, curves, }: {
|
|
12
|
-
pointsToAdd: number;
|
|
13
|
-
parsedPath: Path;
|
|
14
|
-
curves: Path['curves'];
|
|
15
|
-
}): Path;
|
|
16
|
-
export declare function syncPaths({ parsedPath, previousParsedPath, }: {
|
|
17
|
-
parsedPath: Path;
|
|
18
|
-
previousParsedPath: Path | undefined;
|
|
19
|
-
}): {
|
|
20
|
-
previousParsedPath: Path;
|
|
21
|
-
parsedPath: Path;
|
|
22
|
-
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextProps as RNTextProps } from 'react-native';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
4
|
+
interface AnimatedTextProps {
|
|
5
|
+
text: Animated.SharedValue<string>;
|
|
6
|
+
style?: Animated.AnimateProps<RNTextProps>['style'];
|
|
7
|
+
}
|
|
8
|
+
export declare const AnimatedText: ({ text, style }: AnimatedTextProps) => JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -6,8 +6,6 @@ export declare function formatPrice({ value: _value, defaultPrice: _defaultPrice
|
|
|
6
6
|
export declare function formatDatetime({ value, locale, options, }: {
|
|
7
7
|
value: number;
|
|
8
8
|
locale?: string;
|
|
9
|
-
options?:
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
};
|
|
9
|
+
options?: Intl.DateTimeFormatOptions;
|
|
12
10
|
}): string;
|
|
13
|
-
export declare function usePrevious(value:
|
|
11
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wagmi-charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A sweet candlestick chart for React Native",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"android"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"d3-interpolate-path": "^2.2.3",
|
|
39
40
|
"d3-scale": "^2",
|
|
40
41
|
"d3-shape": "^3.0.1",
|
|
41
42
|
"react-native-redash": "^16.1.1",
|
|
@@ -58,7 +59,6 @@
|
|
|
58
59
|
"react-native": "^0.64.2",
|
|
59
60
|
"react-native-builder-bob": "^0.18.1",
|
|
60
61
|
"react-native-gesture-handler": "^1.10.3",
|
|
61
|
-
"react-native-haptic-feedback": "^1.11.0",
|
|
62
62
|
"react-native-reanimated": "^2.2.0",
|
|
63
63
|
"typescript": "^4.3.5"
|
|
64
64
|
},
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"react": "*",
|
|
67
67
|
"react-native": "*",
|
|
68
68
|
"react-native-gesture-handler": "*",
|
|
69
|
-
"react-native-haptic-feedback": "*",
|
|
70
69
|
"react-native-reanimated": "*"
|
|
71
70
|
},
|
|
72
71
|
"jest": {
|
|
@@ -92,7 +91,8 @@
|
|
|
92
91
|
"trailingComma": "es5",
|
|
93
92
|
"useTabs": false
|
|
94
93
|
}
|
|
95
|
-
]
|
|
94
|
+
],
|
|
95
|
+
"@typescript-eslint/no-explicit-any": "error"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"eslintIgnore": [
|