@ledgerhq/react-ui 0.14.18 → 0.15.0-next.0
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/lib/cjs/components/asorted/Text/Text.stories.js.map +2 -2
- package/lib/cjs/components/cta/Button/index.js +1 -1
- package/lib/cjs/components/cta/Button/index.js.map +2 -2
- package/lib/cjs/components/form/BaseInput/index.js +2 -1
- package/lib/cjs/components/form/BaseInput/index.js.map +2 -2
- package/lib/cjs/components/form/Radio/RadioListElement.js.map +2 -2
- package/lib/cjs/components/index.js +0 -2
- package/lib/cjs/components/index.js.map +2 -2
- package/lib/cjs/components/layout/List/VerticalTimeline/TimelineItem.js.map +2 -2
- package/lib/components/Table/index.js.map +1 -1
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/animations/GlitchText/index.js.map +1 -1
- package/lib/components/asorted/Icon/CryptoIcon.js.map +1 -1
- package/lib/components/asorted/Icon/Icon.js.map +1 -1
- package/lib/components/cta/Button/index.js +1 -1
- package/lib/components/cta/Button/index.js.map +1 -1
- package/lib/components/cta/Link/index.d.ts +1 -39
- package/lib/components/form/BaseInput/index.d.ts +2 -36
- package/lib/components/form/BaseInput/index.js +3 -2
- package/lib/components/form/BaseInput/index.js.map +1 -1
- package/lib/components/form/DropdownGeneric/index.js.map +1 -1
- package/lib/components/form/NumberInput/index.js.map +1 -1
- package/lib/components/form/Radio/RadioListElement.js.map +1 -1
- package/lib/components/form/SelectInput/Option.js.map +1 -1
- package/lib/components/form/SelectInput/VirtualMenuList.js.map +1 -1
- package/lib/components/form/SplitInput/index.js.map +1 -1
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -1
- package/lib/components/index.js.map +1 -1
- package/lib/components/layout/Box/index.d.ts +1 -5
- package/lib/components/layout/Carousel/Footer/Pagination/utils.js.map +1 -1
- package/lib/components/layout/Drawer/index.js.map +1 -1
- package/lib/components/layout/List/VerticalTimeline/TimelineIndicator.js.map +1 -1
- package/lib/components/layout/List/VerticalTimeline/TimelineItem.js.map +1 -1
- package/lib/components/layout/Popin/index.js.map +1 -1
- package/lib/components/layout/Side/index.js.map +1 -1
- package/lib/components/message/Alert/index.js.map +1 -1
- package/lib/components/message/Tip/index.js.map +1 -1
- package/lib/components/message/Tooltip/index.js.map +1 -1
- package/lib/components/navigation/FlowStepper/index.js.map +1 -1
- package/lib/components/navigation/progress/Stepper/index.js.map +1 -1
- package/lib/components/styled.js.map +1 -1
- package/lib/components/tabs/Tabs/index.js.map +1 -1
- package/lib/styles/helpers.js.map +1 -1
- package/lib/styles/styled/fontFamily.js.map +1 -1
- package/package.json +3 -7
- package/lib/cjs/components/Chart/Chart.stories.js +0 -116
- package/lib/cjs/components/Chart/Chart.stories.js.map +0 -7
- package/lib/cjs/components/Chart/index.js +0 -150
- package/lib/cjs/components/Chart/index.js.map +0 -7
- package/lib/cjs/components/Chart/types.js +0 -17
- package/lib/cjs/components/Chart/types.js.map +0 -7
- package/lib/cjs/components/Chart/utils.js +0 -42
- package/lib/cjs/components/Chart/utils.js.map +0 -7
- package/lib/components/Chart/index.d.ts +0 -17
- package/lib/components/Chart/index.js +0 -125
- package/lib/components/Chart/index.js.map +0 -1
- package/lib/components/Chart/types.d.ts +0 -14
- package/lib/components/Chart/types.js +0 -2
- package/lib/components/Chart/types.js.map +0 -1
- package/lib/components/Chart/utils.d.ts +0 -19
- package/lib/components/Chart/utils.js +0 -30
- package/lib/components/Chart/utils.js.map +0 -1
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var Chart_exports = {};
|
|
30
|
-
__export(Chart_exports, {
|
|
31
|
-
default: () => Chart_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(Chart_exports);
|
|
34
|
-
var import_react = __toESM(require("react"));
|
|
35
|
-
var import_react_chartjs_2 = require("react-chartjs-2");
|
|
36
|
-
var import_color = __toESM(require("color"));
|
|
37
|
-
var import_styled_components = require("styled-components");
|
|
38
|
-
var import_chartjs_adapter_moment = require("chartjs-adapter-moment");
|
|
39
|
-
var import_utils = require("./utils");
|
|
40
|
-
const getConfig = (variant, options) => {
|
|
41
|
-
const config = {
|
|
42
|
-
small: {
|
|
43
|
-
gradient: { alpha: 0.3 },
|
|
44
|
-
scales: { y: { display: false }, x: { display: false, type: "time" } }
|
|
45
|
-
},
|
|
46
|
-
default: {
|
|
47
|
-
gradient: { alpha: 0.1 },
|
|
48
|
-
scales: {
|
|
49
|
-
y: {
|
|
50
|
-
display: true,
|
|
51
|
-
grid: {
|
|
52
|
-
color: options.gridColor,
|
|
53
|
-
borderDash: [4, 4],
|
|
54
|
-
tickWidth: 0,
|
|
55
|
-
tickLength: 18,
|
|
56
|
-
// This is an hack to don't render a duplicate axis
|
|
57
|
-
borderWidth: 0
|
|
58
|
-
},
|
|
59
|
-
ticks: { callback: import_utils.valueFormatter, labelOffset: -3 }
|
|
60
|
-
},
|
|
61
|
-
x: {
|
|
62
|
-
display: true,
|
|
63
|
-
grid: {
|
|
64
|
-
color: options.gridColor,
|
|
65
|
-
borderDash: [4, 4],
|
|
66
|
-
tickWidth: 0,
|
|
67
|
-
tickLength: 15,
|
|
68
|
-
// Don't render a duplicate axis
|
|
69
|
-
borderWidth: 0
|
|
70
|
-
},
|
|
71
|
-
// always display first/last ticks
|
|
72
|
-
bounds: "ticks",
|
|
73
|
-
type: "time",
|
|
74
|
-
// control how the tickers on the x-axis are formatted
|
|
75
|
-
time: options.timeOptions
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
return config[variant];
|
|
81
|
-
};
|
|
82
|
-
const defaultValue = {
|
|
83
|
-
variant: "default",
|
|
84
|
-
valueKey: "value",
|
|
85
|
-
timeOptions: { unit: "month", displayFormats: { month: "MMM." } }
|
|
86
|
-
};
|
|
87
|
-
var Chart_default = ({
|
|
88
|
-
data,
|
|
89
|
-
color,
|
|
90
|
-
variant = defaultValue.variant,
|
|
91
|
-
valueKey = defaultValue.valueKey,
|
|
92
|
-
timeOptions = defaultValue.timeOptions,
|
|
93
|
-
...chartProps
|
|
94
|
-
}) => {
|
|
95
|
-
const theme = (0, import_styled_components.useTheme)();
|
|
96
|
-
const config = (0, import_react.useMemo)(
|
|
97
|
-
() => getConfig(variant, { gridColor: theme.colors.neutral.c40, timeOptions }),
|
|
98
|
-
[variant, theme.colors.neutral.c40, timeOptions]
|
|
99
|
-
);
|
|
100
|
-
(0, import_react.useEffect)(() => {
|
|
101
|
-
import_react_chartjs_2.defaults.font = import_utils.fontConfig;
|
|
102
|
-
}, []);
|
|
103
|
-
const chartData = (0, import_react.useMemo)(
|
|
104
|
-
() => ({
|
|
105
|
-
datasets: [
|
|
106
|
-
{
|
|
107
|
-
borderColor: color,
|
|
108
|
-
borderWidth: 2,
|
|
109
|
-
fill: "start",
|
|
110
|
-
backgroundColor: (context) => {
|
|
111
|
-
const chart = context.chart;
|
|
112
|
-
const { ctx, chartArea } = chart;
|
|
113
|
-
if (!chartArea)
|
|
114
|
-
return null;
|
|
115
|
-
const gradient = ctx.createLinearGradient(0, 0, 0, chartArea.height / 1.2);
|
|
116
|
-
gradient.addColorStop(0, (0, import_color.default)(color).alpha(config.gradient.alpha).string());
|
|
117
|
-
gradient.addColorStop(1, (0, import_color.default)(color).alpha(0).string());
|
|
118
|
-
return gradient;
|
|
119
|
-
},
|
|
120
|
-
// prevent points rendering
|
|
121
|
-
pointRadius: 0,
|
|
122
|
-
pointHitRadius: 0,
|
|
123
|
-
data: data.map(({ date: x, [`${valueKey}`]: y }) => ({ x, y }))
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}),
|
|
127
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
|
-
[color, data, valueKey, variant]
|
|
129
|
-
);
|
|
130
|
-
const options = (0, import_react.useMemo)(
|
|
131
|
-
() => ({
|
|
132
|
-
// Responsive options use the parent element to create the canvas
|
|
133
|
-
responsive: true,
|
|
134
|
-
maintainAspectRatio: false,
|
|
135
|
-
plugins: { tooltips: { enabled: false }, legend: { display: false } },
|
|
136
|
-
animation: false,
|
|
137
|
-
elements: {
|
|
138
|
-
points: { radius: 0 },
|
|
139
|
-
line: {
|
|
140
|
-
// Bezier curve tension of the line. Set to 0 to draw straightlines.
|
|
141
|
-
tension: 0.2
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
scales: config.scales
|
|
145
|
-
}),
|
|
146
|
-
[config.scales]
|
|
147
|
-
);
|
|
148
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_chartjs_2.Line, { data: chartData, options, ...chartProps, redraw: true });
|
|
149
|
-
};
|
|
150
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/Chart/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect, useMemo } from \"react\";\nimport { Line, defaults, ChartProps } from \"react-chartjs-2\";\nimport type { ScriptableContext } from \"chart.js\";\nimport Color from \"color\";\nimport { useTheme } from \"styled-components\";\nimport \"chartjs-adapter-moment\";\n\nimport type { Item, timeOptions } from \"./types\";\nimport { fontConfig, valueFormatter } from \"./utils\";\n\ntype LineProps = React.ComponentProps<typeof Line>;\n\nexport type Props = Omit<ChartProps, \"type\" | \"data\" | \"options\"> & {\n data: Array<Item>;\n color: string;\n variant?: \"default\" | \"small\";\n valueKey?: string;\n /*\n ** This prop is used to format the x-axis using time options from chart.js.\n ** See https://www.chartjs.org/docs/latest/axes/cartesian/time.html#time-units\n */\n timeOptions?: timeOptions;\n};\n\n/*\n ** @DEV: I'm sorry, I spent too much time to try to type scales. Types from chart.js\n ** are horrible. I hope someone in the future will have more luck than me.\n */\ntype GetConfigOutput = { gradient: { alpha: number }; scales: unknown };\n\n/*\n ** Returns the correct config based on the variant\n */\nconst getConfig = (\n variant: NonNullable<Props[\"variant\"]>,\n options: NonNullable<Pick<Props, \"timeOptions\">> & { gridColor: string },\n): GetConfigOutput => {\n const config: { small: GetConfigOutput; default: GetConfigOutput } = {\n small: {\n gradient: { alpha: 0.3 },\n scales: { y: { display: false }, x: { display: false, type: \"time\" } },\n },\n default: {\n gradient: { alpha: 0.1 },\n scales: {\n y: {\n display: true,\n grid: {\n color: options.gridColor,\n borderDash: [4, 4],\n tickWidth: 0,\n tickLength: 18,\n\n // This is an hack to don't render a duplicate axis\n borderWidth: 0,\n },\n ticks: { callback: valueFormatter, labelOffset: -3 },\n },\n x: {\n display: true,\n grid: {\n color: options.gridColor,\n borderDash: [4, 4],\n tickWidth: 0,\n tickLength: 15,\n\n // Don't render a duplicate axis\n borderWidth: 0,\n },\n // always display first/last ticks\n bounds: \"ticks\",\n type: \"time\",\n // control how the tickers on the x-axis are formatted\n time: options.timeOptions,\n },\n },\n },\n };\n\n return config[variant];\n};\n\nconst defaultValue: {\n variant: NonNullable<Props[\"variant\"]>;\n valueKey: NonNullable<Props[\"valueKey\"]>;\n timeOptions: NonNullable<Props[\"timeOptions\"]>;\n} = {\n variant: \"default\",\n valueKey: \"value\",\n timeOptions: { unit: \"month\", displayFormats: { month: \"MMM.\" } },\n};\n\n/**\n * @remarks This component must have a parent that has only it as a child and it must be in relative position!\n * @privateRemarks Don't name this component \"Chart\", that will conflict with the Chart.js library cuz of the adapter\n */\nexport default ({\n data,\n color,\n variant = defaultValue.variant,\n valueKey = defaultValue.valueKey,\n timeOptions = defaultValue.timeOptions,\n ...chartProps\n}: Props): JSX.Element => {\n const theme = useTheme();\n const config = useMemo(\n () => getConfig(variant, { gridColor: theme.colors.neutral.c40, timeOptions }),\n [variant, theme.colors.neutral.c40, timeOptions],\n );\n\n // inject default font configuration at mount\n useEffect(() => {\n defaults.font = fontConfig;\n }, []);\n\n const chartData = useMemo(\n () => ({\n datasets: [\n {\n borderColor: color,\n borderWidth: 2,\n fill: \"start\",\n backgroundColor: (context: ScriptableContext<\"bar\">) => {\n const chart = context.chart;\n const { ctx, chartArea } = chart;\n\n // This case happens on initial chart load\n if (!chartArea) return null;\n\n // Create gradient based on the props color\n const gradient = ctx.createLinearGradient(0, 0, 0, chartArea.height / 1.2);\n gradient.addColorStop(0, Color(color).alpha(config.gradient.alpha).string());\n gradient.addColorStop(1, Color(color).alpha(0.0).string());\n return gradient;\n },\n\n // prevent points rendering\n pointRadius: 0,\n pointHitRadius: 0,\n\n data: data.map(({ date: x, [`${valueKey}`]: y }) => ({ x, y })),\n },\n ],\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [color, data, valueKey, variant],\n ) as unknown as LineProps[\"data\"];\n\n const options: ChartProps[\"options\"] = useMemo(\n () => ({\n // Responsive options use the parent element to create the canvas\n responsive: true,\n maintainAspectRatio: false,\n\n plugins: { tooltips: { enabled: false }, legend: { display: false } },\n animation: false,\n elements: {\n points: { radius: 0 },\n line: {\n // Bezier curve tension of the line. Set to 0 to draw straightlines.\n tension: 0.2,\n },\n },\n scales: config.scales,\n }),\n [config.scales],\n ) as unknown as LineProps[\"options\"];\n\n // The redraw is needed to allow the chart to be updated with new value\n return <Line data={chartData} options={options} {...chartProps} redraw />;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAC1C,6BAA2C;AAE3C,mBAAkB;AAClB,+BAAyB;AACzB,oCAAO;AAGP,mBAA2C;AAyB3C,MAAM,YAAY,CAChB,SACA,YACoB;AACpB,QAAM,SAA+D;AAAA,IACnE,OAAO;AAAA,MACL,UAAU,EAAE,OAAO,IAAI;AAAA,MACvB,QAAQ,EAAE,GAAG,EAAE,SAAS,MAAM,GAAG,GAAG,EAAE,SAAS,OAAO,MAAM,OAAO,EAAE;AAAA,IACvE;AAAA,IACA,SAAS;AAAA,MACP,UAAU,EAAE,OAAO,IAAI;AAAA,MACvB,QAAQ;AAAA,QACN,GAAG;AAAA,UACD,SAAS;AAAA,UACT,MAAM;AAAA,YACJ,OAAO,QAAQ;AAAA,YACf,YAAY,CAAC,GAAG,CAAC;AAAA,YACjB,WAAW;AAAA,YACX,YAAY;AAAA;AAAA,YAGZ,aAAa;AAAA,UACf;AAAA,UACA,OAAO,EAAE,UAAU,6BAAgB,aAAa,GAAG;AAAA,QACrD;AAAA,QACA,GAAG;AAAA,UACD,SAAS;AAAA,UAC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AAC3E,qBAAS,aAAa,OAAG,aAAAA,SAAM,KAAK,EAAE,MAAM,CAAG,EAAE,OAAO,CAAC;AACzD,mBAAO;AAAA,UACT;AAAA;AAAA,UAGA,aAAa;AAAA,UACb,gBAAgB;AAAA,UAEhB,MAAM,KAAK,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,QAAQ,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;AAAA,QAChE;AAAA,MACF;AAAA,IACF;AAAA;AAAA,IAEA,CAAC,OAAO,MAAM,UAAU,OAAO;AAAA,EACjC;AAEA,QAAM,cAAiC;AAAA,IACrC,OAAO;AAAA;AAAA,MAEL,YAAY;AAAA,MACZ,qBAAqB;AAAA,MAErB,SAAS,EAAE,UAAU,EAAE,SAAS,MAAM,GAAG,QAAQ,EAAE,SAAS,MAAM,EAAE;AAAA,MACpE,WAAW;AAAA,MACX,UAAU;AAAA,QACR,QAAQ,EAAE,QAAQ,EAAE;AAAA,QACpB,MAAM;AAAA;AAAA,UAEJ,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,QAAQ,OAAO;AAAA,IACjB;AAAA,IACA,CAAC,OAAO,MAAM;AAAA,EAChB;AAGA,SAAO,6BAAAC,QAAA,cAAC,+BAAK,MAAM,WAAW,SAAmB,GAAG,YAAY,QAAM,MAAC;AACzE;",
|
|
6
|
-
"names": ["Color", "React"]
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(types_exports);
|
|
17
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/Chart/types.ts"],
|
|
4
|
-
"sourcesContent": ["export type Item = {\n date: Date;\n value?: number | string;\n} & { [key: string]: number | string };\n\ntype Unit =\n | \"millisecond\"\n | \"second\"\n | \"minute\"\n | \"hour\"\n | \"day\"\n | \"week\"\n | \"month\"\n | \"quarter\"\n | \"year\";\n\nexport type timeOptions = {\n unit?: Unit;\n displayFormats?: { [unit in Unit]?: string };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var utils_exports = {};
|
|
20
|
-
__export(utils_exports, {
|
|
21
|
-
fontConfig: () => fontConfig,
|
|
22
|
-
valueFormatter: () => valueFormatter
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(utils_exports);
|
|
25
|
-
const valueFormatter = (value) => {
|
|
26
|
-
const breakpoints = [
|
|
27
|
-
{ value: 1e6, unit: "M" },
|
|
28
|
-
{ value: 1e3, unit: "K" },
|
|
29
|
-
{ value: 1, unit: "" }
|
|
30
|
-
];
|
|
31
|
-
const formattedValue = typeof value === "number" ? value : parseFloat(value);
|
|
32
|
-
const item = breakpoints.find((item2) => formattedValue >= item2.value);
|
|
33
|
-
return item ? `${(formattedValue / item.value).toFixed(1).replace(".0", "")} ${item.unit}` : "0";
|
|
34
|
-
};
|
|
35
|
-
const fontConfig = {
|
|
36
|
-
family: "Inter, Arial",
|
|
37
|
-
size: 11,
|
|
38
|
-
weight: "600",
|
|
39
|
-
lineHeight: 1.21,
|
|
40
|
-
style: "normal"
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/Chart/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Returns the value fixed to 1 decimals when needed with his associated unit (e.g. \"1.5K\" or \"1.5M\")\n * @param value - Value displayed on the y-axis as a tick\n * @example\n * ```\n * valueFormatter(1500) // \"1.5K\"\n * valueFormatter(1567) // \"1.5K\"\n * valueFormatter(1567657) // \"1.5M\"\n * valueFormatter(156) // \"156\"\n * ```\n */\nexport const valueFormatter = (value: string | number): string => {\n const breakpoints = [\n { value: 1e6, unit: \"M\" },\n { value: 1e3, unit: \"K\" },\n { value: 1, unit: \"\" },\n ];\n const formattedValue = typeof value === \"number\" ? value : parseFloat(value);\n const item = breakpoints.find(item => formattedValue >= item.value);\n return item ? `${(formattedValue / item.value).toFixed(1).replace(\".0\", \"\")} ${item.unit}` : \"0\";\n};\n\n// set default font configuration for the chart - I used ll-text_subTitle class from our theme\nexport const fontConfig: {\n family: string;\n size: number;\n weight: string;\n lineHeight: number;\n style: \"normal\" | \"italic\";\n} = {\n family: \"Inter, Arial\",\n size: 11,\n weight: \"600\",\n lineHeight: 1.21,\n style: \"normal\",\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,MAAM,iBAAiB,CAAC,UAAmC;AAChE,QAAM,cAAc;AAAA,IAClB,EAAE,OAAO,KAAK,MAAM,IAAI;AAAA,IACxB,EAAE,OAAO,KAAK,MAAM,IAAI;AAAA,IACxB,EAAE,OAAO,GAAG,MAAM,GAAG;AAAA,EACvB;AACA,QAAM,iBAAiB,OAAO,UAAU,WAAW,QAAQ,WAAW,KAAK;AAC3E,QAAM,OAAO,YAAY,KAAK,CAAAA,UAAQ,kBAAkBA,MAAK,KAAK;AAClE,SAAO,OAAO,IAAI,iBAAiB,KAAK,OAAO,QAAQ,CAAC,EAAE,QAAQ,MAAM,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK;AAC/F;AAGO,MAAM,aAMT;AAAA,EACF,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,OAAO;AACT;",
|
|
6
|
-
"names": ["item"]
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ChartProps } from "react-chartjs-2";
|
|
3
|
-
import "chartjs-adapter-moment";
|
|
4
|
-
import type { Item, timeOptions } from "./types";
|
|
5
|
-
export type Props = Omit<ChartProps, "type" | "data" | "options"> & {
|
|
6
|
-
data: Array<Item>;
|
|
7
|
-
color: string;
|
|
8
|
-
variant?: "default" | "small";
|
|
9
|
-
valueKey?: string;
|
|
10
|
-
timeOptions?: timeOptions;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* @remarks This component must have a parent that has only it as a child and it must be in relative position!
|
|
14
|
-
* @privateRemarks Don't name this component "Chart", that will conflict with the Chart.js library cuz of the adapter
|
|
15
|
-
*/
|
|
16
|
-
declare const _default: ({ data, color, variant, valueKey, timeOptions, ...chartProps }: Props) => JSX.Element;
|
|
17
|
-
export default _default;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useEffect, useMemo } from "react";
|
|
13
|
-
import { Line, defaults } from "react-chartjs-2";
|
|
14
|
-
import Color from "color";
|
|
15
|
-
import { useTheme } from "styled-components";
|
|
16
|
-
import "chartjs-adapter-moment";
|
|
17
|
-
import { fontConfig, valueFormatter } from "./utils";
|
|
18
|
-
/*
|
|
19
|
-
** Returns the correct config based on the variant
|
|
20
|
-
*/
|
|
21
|
-
const getConfig = (variant, options) => {
|
|
22
|
-
const config = {
|
|
23
|
-
small: {
|
|
24
|
-
gradient: { alpha: 0.3 },
|
|
25
|
-
scales: { y: { display: false }, x: { display: false, type: "time" } },
|
|
26
|
-
},
|
|
27
|
-
default: {
|
|
28
|
-
gradient: { alpha: 0.1 },
|
|
29
|
-
scales: {
|
|
30
|
-
y: {
|
|
31
|
-
display: true,
|
|
32
|
-
grid: {
|
|
33
|
-
color: options.gridColor,
|
|
34
|
-
borderDash: [4, 4],
|
|
35
|
-
tickWidth: 0,
|
|
36
|
-
tickLength: 18,
|
|
37
|
-
// This is an hack to don't render a duplicate axis
|
|
38
|
-
borderWidth: 0,
|
|
39
|
-
},
|
|
40
|
-
ticks: { callback: valueFormatter, labelOffset: -3 },
|
|
41
|
-
},
|
|
42
|
-
x: {
|
|
43
|
-
display: true,
|
|
44
|
-
grid: {
|
|
45
|
-
color: options.gridColor,
|
|
46
|
-
borderDash: [4, 4],
|
|
47
|
-
tickWidth: 0,
|
|
48
|
-
tickLength: 15,
|
|
49
|
-
// Don't render a duplicate axis
|
|
50
|
-
borderWidth: 0,
|
|
51
|
-
},
|
|
52
|
-
// always display first/last ticks
|
|
53
|
-
bounds: "ticks",
|
|
54
|
-
type: "time",
|
|
55
|
-
// control how the tickers on the x-axis are formatted
|
|
56
|
-
time: options.timeOptions,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
return config[variant];
|
|
62
|
-
};
|
|
63
|
-
const defaultValue = {
|
|
64
|
-
variant: "default",
|
|
65
|
-
valueKey: "value",
|
|
66
|
-
timeOptions: { unit: "month", displayFormats: { month: "MMM." } },
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* @remarks This component must have a parent that has only it as a child and it must be in relative position!
|
|
70
|
-
* @privateRemarks Don't name this component "Chart", that will conflict with the Chart.js library cuz of the adapter
|
|
71
|
-
*/
|
|
72
|
-
export default (_a) => {
|
|
73
|
-
var { data, color, variant = defaultValue.variant, valueKey = defaultValue.valueKey, timeOptions = defaultValue.timeOptions } = _a, chartProps = __rest(_a, ["data", "color", "variant", "valueKey", "timeOptions"]);
|
|
74
|
-
const theme = useTheme();
|
|
75
|
-
const config = useMemo(() => getConfig(variant, { gridColor: theme.colors.neutral.c40, timeOptions }), [variant, theme.colors.neutral.c40, timeOptions]);
|
|
76
|
-
// inject default font configuration at mount
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
defaults.font = fontConfig;
|
|
79
|
-
}, []);
|
|
80
|
-
const chartData = useMemo(() => ({
|
|
81
|
-
datasets: [
|
|
82
|
-
{
|
|
83
|
-
borderColor: color,
|
|
84
|
-
borderWidth: 2,
|
|
85
|
-
fill: "start",
|
|
86
|
-
backgroundColor: (context) => {
|
|
87
|
-
const chart = context.chart;
|
|
88
|
-
const { ctx, chartArea } = chart;
|
|
89
|
-
// This case happens on initial chart load
|
|
90
|
-
if (!chartArea)
|
|
91
|
-
return null;
|
|
92
|
-
// Create gradient based on the props color
|
|
93
|
-
const gradient = ctx.createLinearGradient(0, 0, 0, chartArea.height / 1.2);
|
|
94
|
-
gradient.addColorStop(0, Color(color).alpha(config.gradient.alpha).string());
|
|
95
|
-
gradient.addColorStop(1, Color(color).alpha(0.0).string());
|
|
96
|
-
return gradient;
|
|
97
|
-
},
|
|
98
|
-
// prevent points rendering
|
|
99
|
-
pointRadius: 0,
|
|
100
|
-
pointHitRadius: 0,
|
|
101
|
-
data: data.map(({ date: x, [`${valueKey}`]: y }) => ({ x, y })),
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
}),
|
|
105
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
|
-
[color, data, valueKey, variant]);
|
|
107
|
-
const options = useMemo(() => ({
|
|
108
|
-
// Responsive options use the parent element to create the canvas
|
|
109
|
-
responsive: true,
|
|
110
|
-
maintainAspectRatio: false,
|
|
111
|
-
plugins: { tooltips: { enabled: false }, legend: { display: false } },
|
|
112
|
-
animation: false,
|
|
113
|
-
elements: {
|
|
114
|
-
points: { radius: 0 },
|
|
115
|
-
line: {
|
|
116
|
-
// Bezier curve tension of the line. Set to 0 to draw straightlines.
|
|
117
|
-
tension: 0.2,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
scales: config.scales,
|
|
121
|
-
}), [config.scales]);
|
|
122
|
-
// The redraw is needed to allow the chart to be updated with new value
|
|
123
|
-
return React.createElement(Line, Object.assign({ data: chartData, options: options }, chartProps, { redraw: true }));
|
|
124
|
-
};
|
|
125
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Chart/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAc,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,wBAAwB,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAsBrD;;GAEG;AACH,MAAM,SAAS,GAAG,CAChB,OAAsC,EACtC,OAAwE,EACvD,EAAE;IACnB,MAAM,MAAM,GAAyD;QACnE,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;YACxB,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;SACvE;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;YACxB,MAAM,EAAE;gBACN,CAAC,EAAE;oBACD,OAAO,EAAE,IAAI;oBACb,IAAI,EAAE;wBACJ,KAAK,EAAE,OAAO,CAAC,SAAS;wBACxB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;wBAClB,SAAS,EAAE,CAAC;wBACZ,UAAU,EAAE,EAAE;wBAEd,mDAAmD;wBACnD,WAAW,EAAE,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C,EAAE,CAAC,EAAE,CAAC,CAAC;aAChE;SACF;KACF,CAAC;IACF,uDAAuD;IACvD,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CACD,CAAC;IAElC,MAAM,OAAO,GAA0B,OAAO,CAC5C,GAAG,EAAE,CAAC,CAAC;QACL,iEAAiE;QACjE,UAAU,EAAE,IAAI;QAChB,mBAAmB,EAAE,KAAK;QAE1B,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACrE,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE;YACR,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;YACrB,IAAI,EAAE;gBACJ,oEAAoE;gBACpE,OAAO,EAAE,GAAG;aACb;SACF;QACD,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,EACF,CAAC,MAAM,CAAC,MAAM,CAAC,CACmB,CAAC;IAErC,uEAAuE;IACvE,OAAO,oBAAC,IAAI,kBAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,IAAM,UAAU,IAAE,MAAM,UAAG,CAAC;AAC5E,CAAC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type Item = {
|
|
2
|
-
date: Date;
|
|
3
|
-
value?: number | string;
|
|
4
|
-
} & {
|
|
5
|
-
[key: string]: number | string;
|
|
6
|
-
};
|
|
7
|
-
type Unit = "millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
8
|
-
export type timeOptions = {
|
|
9
|
-
unit?: Unit;
|
|
10
|
-
displayFormats?: {
|
|
11
|
-
[unit in Unit]?: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Chart/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the value fixed to 1 decimals when needed with his associated unit (e.g. "1.5K" or "1.5M")
|
|
3
|
-
* @param value - Value displayed on the y-axis as a tick
|
|
4
|
-
* @example
|
|
5
|
-
* ```
|
|
6
|
-
* valueFormatter(1500) // "1.5K"
|
|
7
|
-
* valueFormatter(1567) // "1.5K"
|
|
8
|
-
* valueFormatter(1567657) // "1.5M"
|
|
9
|
-
* valueFormatter(156) // "156"
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare const valueFormatter: (value: string | number) => string;
|
|
13
|
-
export declare const fontConfig: {
|
|
14
|
-
family: string;
|
|
15
|
-
size: number;
|
|
16
|
-
weight: string;
|
|
17
|
-
lineHeight: number;
|
|
18
|
-
style: "normal" | "italic";
|
|
19
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the value fixed to 1 decimals when needed with his associated unit (e.g. "1.5K" or "1.5M")
|
|
3
|
-
* @param value - Value displayed on the y-axis as a tick
|
|
4
|
-
* @example
|
|
5
|
-
* ```
|
|
6
|
-
* valueFormatter(1500) // "1.5K"
|
|
7
|
-
* valueFormatter(1567) // "1.5K"
|
|
8
|
-
* valueFormatter(1567657) // "1.5M"
|
|
9
|
-
* valueFormatter(156) // "156"
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export const valueFormatter = (value) => {
|
|
13
|
-
const breakpoints = [
|
|
14
|
-
{ value: 1e6, unit: "M" },
|
|
15
|
-
{ value: 1e3, unit: "K" },
|
|
16
|
-
{ value: 1, unit: "" },
|
|
17
|
-
];
|
|
18
|
-
const formattedValue = typeof value === "number" ? value : parseFloat(value);
|
|
19
|
-
const item = breakpoints.find(item => formattedValue >= item.value);
|
|
20
|
-
return item ? `${(formattedValue / item.value).toFixed(1).replace(".0", "")} ${item.unit}` : "0";
|
|
21
|
-
};
|
|
22
|
-
// set default font configuration for the chart - I used ll-text_subTitle class from our theme
|
|
23
|
-
export const fontConfig = {
|
|
24
|
-
family: "Inter, Arial",
|
|
25
|
-
size: 11,
|
|
26
|
-
weight: "600",
|
|
27
|
-
lineHeight: 1.21,
|
|
28
|
-
style: "normal",
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Chart/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAU,EAAE;IAC/D,MAAM,WAAW,GAAG;QAClB,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE;QACzB,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE;QACzB,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;KACvB,CAAC;IACF,MAAM,cAAc,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AACnG,CAAC,CAAC;AAEF,8FAA8F;AAC9F,MAAM,CAAC,MAAM,UAAU,GAMnB;IACF,MAAM,EAAE,cAAc;IACtB,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,IAAI;IAChB,KAAK,EAAE,QAAQ;CAChB,CAAC"}
|