@efiche/design 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -117,6 +117,112 @@ Override any `--ds-*` variable on `:root` (or `.ds-theme-dark` for dark mode) in
117
117
 
118
118
  ---
119
119
 
120
+ ## Charts
121
+
122
+ Charts are built on top of [Recharts](https://recharts.org). Make sure it is installed:
123
+
124
+ ```bash
125
+ npm install recharts
126
+ ```
127
+
128
+ ```tsx
129
+ import { LineChart, BarChart, AreaChart, PieChart } from '@efiche/design'
130
+ import { useTheme } from '@efiche/design'
131
+
132
+ const { theme } = useTheme() // pass to charts for dark mode awareness
133
+ ```
134
+
135
+ ### LineChart
136
+
137
+ ```tsx
138
+ // Single line
139
+ <LineChart data={data} xKey="month" lines={[{ dataKey: 'value' }]} />
140
+
141
+ // Multi-line with legend
142
+ <LineChart
143
+ data={data}
144
+ xKey="month"
145
+ lines={[
146
+ { dataKey: 'revenue', color: '#22c55e', label: 'Revenue' },
147
+ { dataKey: 'expenses', color: '#ef4444', label: 'Expenses' },
148
+ ]}
149
+ legend
150
+ theme={theme}
151
+ />
152
+ ```
153
+
154
+ ### BarChart
155
+
156
+ ```tsx
157
+ // Single bar
158
+ <BarChart data={data} xKey="month" bars={[{ dataKey: 'sales' }]} />
159
+
160
+ // Stacked bars
161
+ <BarChart
162
+ data={data}
163
+ xKey="month"
164
+ bars={[
165
+ { dataKey: 'online', color: '#3b82f6', stackId: 'a', label: 'Online' },
166
+ { dataKey: 'offline', color: '#94a3b8', stackId: 'a', label: 'Offline' },
167
+ ]}
168
+ legend
169
+ theme={theme}
170
+ />
171
+ ```
172
+
173
+ ### AreaChart
174
+
175
+ ```tsx
176
+ // Single area
177
+ <AreaChart data={data} xKey="month" areas={[{ dataKey: 'visitors' }]} />
178
+
179
+ // Stacked areas
180
+ <AreaChart
181
+ data={data}
182
+ xKey="month"
183
+ areas={[
184
+ { dataKey: 'mobile', color: '#3b82f6', stackId: '1', label: 'Mobile' },
185
+ { dataKey: 'desktop', color: '#22c55e', stackId: '1', label: 'Desktop' },
186
+ ]}
187
+ legend
188
+ theme={theme}
189
+ />
190
+ ```
191
+
192
+ ### PieChart
193
+
194
+ ```tsx
195
+ // Pie
196
+ <PieChart
197
+ data={[
198
+ { name: 'Direct', value: 400, fill: '#3b82f6' },
199
+ { name: 'Social', value: 300, fill: '#22c55e' },
200
+ { name: 'Email', value: 200, fill: '#f59e0b' },
201
+ ]}
202
+ label
203
+ />
204
+
205
+ // Donut with legend
206
+ <PieChart data={pieData} donut legend theme={theme} />
207
+ ```
208
+
209
+ ### Chart props reference
210
+
211
+ | Prop | Type | Default | Description |
212
+ |------|------|---------|-------------|
213
+ | `data` | `object[]` | required | Array of data objects |
214
+ | `xKey` | `string` | required | Key used for the X axis *(LineChart, BarChart, AreaChart)* |
215
+ | `lines` / `bars` / `areas` | `config[]` | required | Series definitions — see per-component docs above |
216
+ | `data` | `{ name, value, fill? }[]` | required | Slice definitions *(PieChart)* |
217
+ | `height` | `number` | `250` | Chart height in px |
218
+ | `legend` | `boolean` | `false` | Show the legend |
219
+ | `grid` | `boolean` | `true` | Show the background grid *(LineChart, BarChart, AreaChart)* |
220
+ | `label` | `boolean` | `false` | Show percentage labels on slices *(PieChart)* |
221
+ | `donut` | `boolean` | `false` | Hollow centre *(PieChart)* |
222
+ | `theme` | `"light" \| "dark"` | `"light"` | Controls axis, grid, and tooltip colours |
223
+
224
+ ---
225
+
120
226
  ## Components
121
227
 
122
228
  | Component | Import |
@@ -146,6 +252,10 @@ Override any `--ds-*` variable on `:root` (or `.ds-theme-dark` for dark mode) in
146
252
  | `Textarea` | `import { Textarea } from '@efiche/design'` |
147
253
  | `Tooltip` | `import { Tooltip } from '@efiche/design'` |
148
254
  | `ThemeProvider` | `import { ThemeProvider, useTheme } from '@efiche/design'` |
255
+ | `LineChart` | `import { LineChart } from '@efiche/design'` |
256
+ | `BarChart` | `import { BarChart } from '@efiche/design'` |
257
+ | `AreaChart` | `import { AreaChart } from '@efiche/design'` |
258
+ | `PieChart` | `import { PieChart } from '@efiche/design'` |
149
259
 
150
260
  ---
151
261
 
package/dist/index.cjs CHANGED
@@ -157,10 +157,12 @@ var LineChart = ({
157
157
  height = 250,
158
158
  legend = false,
159
159
  grid = true,
160
- theme = "light"
160
+ theme = "light",
161
+ className,
162
+ style
161
163
  }) => {
162
164
  const { gridColor, axisStroke, axisTick, tooltipStyle } = getChartTheme(theme);
163
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_recharts.LineChart, { data, children: [
165
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className, style: __spreadValues({ minWidth: 250, width: "100%" }, style), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_recharts.LineChart, { data, children: [
164
166
  grid && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3", stroke: gridColor }),
165
167
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_recharts.XAxis, { dataKey: xKey, stroke: axisStroke, tick: axisTick }),
166
168
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_recharts.YAxis, { stroke: axisStroke, tick: axisTick }),
@@ -183,7 +185,7 @@ var LineChart = ({
183
185
  line.dataKey
184
186
  );
185
187
  })
186
- ] }) });
188
+ ] }) }) });
187
189
  };
188
190
  var LineChart_default = LineChart;
189
191
 
@@ -197,10 +199,12 @@ var BarChart = ({
197
199
  height = 250,
198
200
  legend = false,
199
201
  grid = true,
200
- theme = "light"
202
+ theme = "light",
203
+ className,
204
+ style
201
205
  }) => {
202
206
  const { gridColor, axisStroke, axisTick, tooltipStyle } = getChartTheme(theme);
203
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_recharts2.BarChart, { data, children: [
207
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className, style: __spreadValues({ minWidth: 250, width: "100%" }, style), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_recharts2.BarChart, { data, children: [
204
208
  grid && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts2.CartesianGrid, { strokeDasharray: "3 3", stroke: gridColor }),
205
209
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts2.XAxis, { dataKey: xKey, stroke: axisStroke, tick: axisTick }),
206
210
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts2.YAxis, { stroke: axisStroke, tick: axisTick }),
@@ -222,7 +226,7 @@ var BarChart = ({
222
226
  bar.dataKey
223
227
  );
224
228
  })
225
- ] }) });
229
+ ] }) }) });
226
230
  };
227
231
  var BarChart_default = BarChart;
228
232
 
@@ -236,10 +240,12 @@ var AreaChart = ({
236
240
  height = 250,
237
241
  legend = false,
238
242
  grid = true,
239
- theme = "light"
243
+ theme = "light",
244
+ className,
245
+ style
240
246
  }) => {
241
247
  const { gridColor, axisStroke, axisTick, tooltipStyle } = getChartTheme(theme);
242
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_recharts3.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_recharts3.AreaChart, { data, children: [
248
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, style: __spreadValues({ minWidth: 250, width: "100%" }, style), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_recharts3.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_recharts3.AreaChart, { data, children: [
243
249
  grid && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_recharts3.CartesianGrid, { strokeDasharray: "3 3", stroke: gridColor }),
244
250
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_recharts3.XAxis, { dataKey: xKey, stroke: axisStroke, tick: axisTick }),
245
251
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_recharts3.YAxis, { stroke: axisStroke, tick: axisTick }),
@@ -264,7 +270,7 @@ var AreaChart = ({
264
270
  area.dataKey
265
271
  );
266
272
  })
267
- ] }) });
273
+ ] }) }) });
268
274
  };
269
275
  var AreaChart_default = AreaChart;
270
276
 
@@ -277,7 +283,9 @@ var PieChart = ({
277
283
  donut = false,
278
284
  legend = false,
279
285
  label = false,
280
- theme = "light"
286
+ theme = "light",
287
+ className,
288
+ style
281
289
  }) => {
282
290
  const { tooltipStyle } = getChartTheme(theme);
283
291
  const dataWithColors = data.map((item, i) => {
@@ -288,7 +296,7 @@ var PieChart = ({
288
296
  });
289
297
  const outerRadius = 90;
290
298
  const innerRadius = donut ? 55 : 0;
291
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_recharts4.PieChart, { children: [
299
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, style: __spreadValues({ minWidth: 250, width: "100%" }, style), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_recharts4.PieChart, { children: [
292
300
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
293
301
  import_recharts4.Pie,
294
302
  {
@@ -304,7 +312,7 @@ var PieChart = ({
304
312
  ),
305
313
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.Tooltip, { contentStyle: tooltipStyle }),
306
314
  legend && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.Legend, {})
307
- ] }) });
315
+ ] }) }) });
308
316
  };
309
317
  var PieChart_default = PieChart;
310
318