@wonderflow/react-components 12.11.0 → 14.0.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.
@@ -1,27 +1,32 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CartesianChartLayout, LineChart } from '@wonderflow/charts';
3
- import { Card } from '../../..';
3
+ import { Card, Menu } from '../../..';
4
4
  // import { CartesianChartLayout, LineChart, LineChartProps } from '../../../../../charts/src';
5
5
  import { channels, channelsB, feedbackCount, feedbackCountGaps, proCons, products, } from '../mock-data';
6
6
  import styles from './sb-charts.module.css';
7
+ export const FakeMenu = (_jsxs(Menu, { children: [_jsx(Menu.Item, { autoFocus: true, icon: "arrow-right", value: "1", description: _jsx(_Fragment, { children: "this is my description" }), children: "Sample long menu item" }), _jsx(Menu.ItemCheckbox, { onClick: () => ({}), checked: true, icon: "check", value: "2", children: "Checkbox item" }), _jsx(Menu.Item, { value: "3", icon: "right-from-bracket", children: "Item option 3" }), _jsx(Menu.Separator, {}), _jsx(Menu.Item, { value: "4", icon: "arrow-down-to-bracket", children: "Even shorter" }), _jsx(Menu.Item, { value: "5", disabled: true, children: "Really?" })] }));
7
8
  const story = {
8
9
  title: 'Charts/Line Chart',
9
10
  component: LineChart,
10
11
  args: {
11
12
  title: 'Line Charts',
12
13
  subtitle: 'A trend line chart',
13
- preventResponsive: false,
14
14
  isLoading: false,
15
15
  showMarker: false,
16
16
  showMarkerLabel: false,
17
- hideMissingDataConnection: false,
18
17
  showAverage: false,
18
+ showTrendline: false,
19
19
  showBrush: false,
20
+ hideMissingDataConnection: false,
20
21
  hideLegend: false,
21
22
  hidePadding: false,
23
+ preventTooltipDisplay: false,
24
+ preventResponsive: false,
22
25
  layout: CartesianChartLayout.HORIZONTAL,
23
26
  renderAs: 'curves',
24
27
  theme: 'light',
28
+ mirrorDomains: false,
29
+ reverseIndex: false,
25
30
  data: feedbackCount,
26
31
  index: {
27
32
  dataKey: 'date',
@@ -32,6 +37,7 @@ const story = {
32
37
  label: 'Feedback Count',
33
38
  },
34
39
  overlay: undefined,
40
+ menu: undefined,
35
41
  },
36
42
  argTypes: {
37
43
  layout: {
@@ -56,7 +62,15 @@ export const withOverlay = Template.bind({});
56
62
  withOverlay.args = {
57
63
  subtitle: 'A trend line chart with overlay',
58
64
  overlay: {
59
- dataKey: 'overlay',
65
+ dataKey: ['overlay'],
66
+ label: 'Overlay',
67
+ },
68
+ };
69
+ export const withMultipleOverlay = Template.bind({});
70
+ withMultipleOverlay.args = {
71
+ subtitle: 'A trend line chart with overlay',
72
+ overlay: {
73
+ dataKey: ['overlay', 'overlayB'],
60
74
  label: 'Overlay',
61
75
  },
62
76
  };
@@ -65,12 +79,21 @@ withAverage.args = {
65
79
  subtitle: 'A trend line chart with average',
66
80
  showAverage: true,
67
81
  };
82
+ export const withTrendline = Template.bind({});
83
+ withTrendline.args = {
84
+ subtitle: 'A trend line chart with overlay and trendlines',
85
+ overlay: {
86
+ dataKey: ['overlay'],
87
+ label: 'Overlay',
88
+ },
89
+ showTrendline: true,
90
+ };
68
91
  export const withMissingData = Template.bind({});
69
92
  withMissingData.args = {
70
93
  data: feedbackCountGaps,
71
94
  subtitle: 'A trend line chart with null values',
72
95
  overlay: {
73
- dataKey: 'overlay',
96
+ dataKey: ['overlay'],
74
97
  label: 'Overlay',
75
98
  },
76
99
  };
@@ -115,22 +138,20 @@ withNestedData.args = {
115
138
  },
116
139
  series: {
117
140
  dataKey: ['1 star.value', '2 stars.value', '3 stars.value', '4 stars.value', '5 stars.value'],
141
+ extraData: (datum) => `${datum.percentage}%`,
118
142
  label: 'Feedback count',
119
- rename: (_, i) => Array(i + 1).fill('⭐').join(),
143
+ rename: (_, i) => Array((i ?? 0) + 1).fill('⭐').join(),
120
144
  },
121
145
  overlay: {
122
- dataKey: 'overlay.value',
146
+ dataKey: ['overlay.value'],
147
+ extraData: (datum) => `${datum.percentage}%`,
123
148
  label: 'TGW',
124
149
  domain: [0, 5],
125
- style: {
126
- strokeDasharray: '2 4',
127
- },
128
- },
129
- tooltip: {
130
- extraSeriesData: (series) => `${series.percentage}%`,
131
- extraOverlayData: (overlay) => `${overlay.percentage}%`,
132
- extraContent: _jsx("div", { children: "some extra content" }),
150
+ style: [{
151
+ strokeDasharray: '2 4',
152
+ }],
133
153
  },
154
+ tooltipExtraContent: _jsx("div", { children: "some extra content" }),
134
155
  renderAs: 'lines',
135
156
  layout: CartesianChartLayout.VERTICAL,
136
157
  showMarker: true,
@@ -213,7 +234,7 @@ export const withVerticalLayout = Template.bind({});
213
234
  withVerticalLayout.args = {
214
235
  layout: CartesianChartLayout.VERTICAL,
215
236
  overlay: {
216
- dataKey: 'overlay',
237
+ dataKey: ['overlay'],
217
238
  label: 'Overlay',
218
239
  },
219
240
  index: {
@@ -232,6 +253,10 @@ withNoData.args = {
232
253
  subtitle: 'A trend line chart w/o data',
233
254
  emptyStateMessage: 'Please select items from the right menu to render the chart.',
234
255
  };
256
+ export const WithMenu = Template.bind({});
257
+ WithMenu.args = {
258
+ menu: FakeMenu,
259
+ };
235
260
  export const renderAsLines = Template.bind({});
236
261
  renderAsLines.args = {
237
262
  title: 'Multiple Series',
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { ComponentMeta, ComponentStory } from '@storybook/react';
3
+ import { BarChart, BarChartProps } from '@wonderflow/charts';
4
+ declare const story: ComponentMeta<typeof BarChart>;
5
+ export default story;
6
+ export declare const Default: ComponentStory<import("react").FC<BarChartProps>>;
7
+ export declare const withOverlay: ComponentStory<import("react").FC<BarChartProps>>;
8
+ export declare const withMultipleOverlay: ComponentStory<import("react").FC<BarChartProps>>;
9
+ export declare const withMultipleSeries: ComponentStory<import("react").FC<BarChartProps>>;
10
+ export declare const withCategoriesOnIndex: ComponentStory<import("react").FC<BarChartProps>>;
11
+ export declare const withNestedData: ComponentStory<import("react").FC<BarChartProps>>;
12
+ export declare const withBackground: ComponentStory<import("react").FC<BarChartProps>>;
13
+ export declare const withAscendingOrder: ComponentStory<import("react").FC<BarChartProps>>;
14
+ export declare const withDescendingOrder: ComponentStory<import("react").FC<BarChartProps>>;
15
+ export declare const PositiveAndNegative: ComponentStory<import("react").FC<BarChartProps>>;
16
+ export declare const withVerticalFixedBars: ComponentStory<import("react").FC<BarChartProps>>;
17
+ export declare const withMissingData: ComponentStory<import("react").FC<BarChartProps>>;
18
+ export declare const withCustomBarStyle: ComponentStory<import("react").FC<BarChartProps>>;
19
+ export declare const withBrush: ComponentStory<import("react").FC<BarChartProps>>;
20
+ export declare const WithMenu: ComponentStory<import("react").FC<BarChartProps>>;
21
+ export declare const WithinCard: ComponentStory<import("react").FC<BarChartProps>>;
22
+ //# sourceMappingURL=stack-bar-chart.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack-bar-chart.stories.d.ts","sourceRoot":"","sources":["../../../../src/examples/charts/storybook/stack-bar-chart.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAwB,MAAM,oBAAoB,CAAC;AAcnF,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,QAAQ,CAiDzC,CAAC;AAEF,eAAe,KAAK,CAAC;AAIrB,eAAO,MAAM,OAAO,mDAAoB,CAAC;AAGzC,eAAO,MAAM,WAAW,mDAAoB,CAAC;AAS7C,eAAO,MAAM,mBAAmB,mDAAoB,CAAC;AAiBrD,eAAO,MAAM,kBAAkB,mDAAoB,CAAC;AAiBpD,eAAO,MAAM,qBAAqB,mDAAoB,CAAC;AAcvD,eAAO,MAAM,cAAc,mDAAoB,CAAC;AAyBhD,eAAO,MAAM,cAAc,mDAAoB,CAAC;AAiBhD,eAAO,MAAM,kBAAkB,mDAAoB,CAAC;AAiBpD,eAAO,MAAM,mBAAmB,mDAAoB,CAAC;AAiBrD,eAAO,MAAM,mBAAmB,mDAAoB,CAAC;AAerD,eAAO,MAAM,qBAAqB,mDAAoB,CAAC;AAYvD,eAAO,MAAM,eAAe,mDAAoB,CAAC;AAUjD,eAAO,MAAM,kBAAkB,mDAAoB,CAAC;AAyBpD,eAAO,MAAM,SAAS,mDAAoB,CAAC;AAiC3C,eAAO,MAAM,QAAQ,mDAAoB,CAAC;AAuC1C,eAAO,MAAM,UAAU,mDAA8B,CAAC"}
@@ -0,0 +1,324 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { BarChart, CartesianChartLayout } from '@wonderflow/charts';
3
+ import { Card } from '../../..';
4
+ // import { BarChart, BarChartProps, CartesianChartLayout } from '../../../../../charts/src';
5
+ import { channels, channelsB, feedbackCount, feedbackCountGaps, proCons, products, } from '../mock-data';
6
+ import { positiveNegative } from '../mock-data/positiveNegative';
7
+ import { FakeMenu } from './line-chart.stories';
8
+ import styles from './sb-charts.module.css';
9
+ const story = {
10
+ title: 'Charts/Stacked Bar Chart',
11
+ component: BarChart,
12
+ args: {
13
+ title: 'Stacked Bar Chart',
14
+ subtitle: 'with a single series od data',
15
+ sortBy: 'as-is',
16
+ isStacked: true,
17
+ showLabel: false,
18
+ isLoading: false,
19
+ showAverage: false,
20
+ showTrendline: false,
21
+ showBrush: false,
22
+ showBackground: false,
23
+ hideLegend: false,
24
+ hidePadding: false,
25
+ preventTooltipDisplay: false,
26
+ preventResponsive: false,
27
+ layout: CartesianChartLayout.HORIZONTAL,
28
+ theme: 'light',
29
+ reverseIndex: false,
30
+ mirrorDomains: false,
31
+ fixedBarSize: false,
32
+ data: feedbackCount,
33
+ index: {
34
+ dataKey: 'date',
35
+ label: 'Year',
36
+ },
37
+ series: {
38
+ dataKey: ['feedback count'],
39
+ label: 'Feedback Count',
40
+ },
41
+ overlay: undefined,
42
+ menu: undefined,
43
+ },
44
+ argTypes: {
45
+ layout: {
46
+ options: ['horizontal', 'vertical'],
47
+ control: { type: 'radio' },
48
+ },
49
+ sortBy: {
50
+ options: ['descending-key', 'ascending-key', 'descending-value', 'ascending-value', 'as-is'],
51
+ control: { type: 'select' },
52
+ },
53
+ theme: {
54
+ options: ['light', 'dark'],
55
+ control: { type: 'radio' },
56
+ },
57
+ },
58
+ };
59
+ export default story;
60
+ const Template = (args) => _jsx(BarChart, { ...args });
61
+ export const Default = Template.bind({});
62
+ Default.args = {};
63
+ export const withOverlay = Template.bind({});
64
+ withOverlay.args = {
65
+ subtitle: 'with a series and one overlay',
66
+ overlay: {
67
+ dataKey: ['overlay'],
68
+ label: 'Overlay',
69
+ },
70
+ };
71
+ export const withMultipleOverlay = Template.bind({});
72
+ withMultipleOverlay.args = {
73
+ subtitle: 'with one series and two overlay',
74
+ series: {
75
+ dataKey: ['feedback count'],
76
+ label: 'Feedback Count',
77
+ domain: [0, 12000],
78
+ },
79
+ overlay: {
80
+ dataKey: ['overlay', 'overlayB'],
81
+ rename: ((o, i) => (i === 0 ? 'OverlayA' : o)),
82
+ label: 'Overlay',
83
+ domain: [0, 1],
84
+ },
85
+ data: feedbackCount.slice(11),
86
+ };
87
+ export const withMultipleSeries = Template.bind({});
88
+ withMultipleSeries.args = {
89
+ subtitle: 'with multiple series and trendlines',
90
+ data: proCons,
91
+ showTrendline: true,
92
+ index: {
93
+ dataKey: 'date',
94
+ label: 'Time',
95
+ },
96
+ series: {
97
+ domain: [0, 140],
98
+ dataKey: ['positive', 'negative', 'neutral'],
99
+ label: 'Pros & cons',
100
+ style: [undefined, undefined, { fill: 'gray' }],
101
+ },
102
+ };
103
+ export const withCategoriesOnIndex = Template.bind({});
104
+ withCategoriesOnIndex.args = {
105
+ subtitle: 'with categories on index axis',
106
+ data: channels,
107
+ index: {
108
+ dataKey: 'channel',
109
+ label: 'Channels',
110
+ },
111
+ series: {
112
+ dataKey: ['1 star', '2 stars', '3 stars', '4 stars', '5 stars'],
113
+ label: 'Stars count',
114
+ },
115
+ };
116
+ export const withNestedData = Template.bind({});
117
+ withNestedData.args = {
118
+ subtitle: 'rendered from nested data, showing average lines and values',
119
+ data: channelsB,
120
+ showAverage: true,
121
+ index: {
122
+ dataKey: 'channel',
123
+ label: 'Channels',
124
+ },
125
+ series: {
126
+ dataKey: ['1 star.value', '2 stars.value', '3 stars.value', '4 stars.value', '5 stars.value'],
127
+ extraData: (datum) => `${datum.percentage}%`,
128
+ label: 'Stars count',
129
+ domain: [0, 4000],
130
+ },
131
+ overlay: {
132
+ dataKey: ['overlay.value'],
133
+ extraData: (datum) => `${datum.percentage}%`,
134
+ rename: _ => 'Fanta KPI',
135
+ label: 'Fanta KPI',
136
+ domain: [0, 5],
137
+ },
138
+ tooltipExtraContent: _jsx("div", { children: "some extra content" }),
139
+ };
140
+ export const withBackground = Template.bind({});
141
+ withBackground.args = {
142
+ subtitle: 'with a background',
143
+ data: proCons,
144
+ showBackground: true,
145
+ index: {
146
+ dataKey: 'date',
147
+ label: 'Time',
148
+ },
149
+ series: {
150
+ domain: [0, 140],
151
+ dataKey: ['positive', 'negative', 'neutral'],
152
+ label: 'Pros & cons',
153
+ style: [undefined, undefined, { fill: 'gray' }],
154
+ },
155
+ };
156
+ export const withAscendingOrder = Template.bind({});
157
+ withAscendingOrder.args = {
158
+ subtitle: 'with values sorted in ascending order',
159
+ data: proCons,
160
+ sortBy: 'ascending-value',
161
+ index: {
162
+ dataKey: 'date',
163
+ label: 'Time',
164
+ },
165
+ series: {
166
+ domain: [0, 140],
167
+ dataKey: ['positive', 'negative', 'neutral'],
168
+ label: 'Pros & cons',
169
+ style: [undefined, undefined, { fill: 'gray' }],
170
+ },
171
+ };
172
+ export const withDescendingOrder = Template.bind({});
173
+ withDescendingOrder.args = {
174
+ subtitle: 'with values sorted in descending order',
175
+ data: proCons,
176
+ sortBy: 'descending-value',
177
+ index: {
178
+ dataKey: 'date',
179
+ label: 'Time',
180
+ },
181
+ series: {
182
+ domain: [0, 140],
183
+ dataKey: ['positive', 'negative', 'neutral'],
184
+ label: 'Pros & cons',
185
+ style: [undefined, undefined, { fill: 'gray' }],
186
+ },
187
+ };
188
+ export const PositiveAndNegative = Template.bind({});
189
+ PositiveAndNegative.args = {
190
+ subtitle: 'with positive and negative values and mirrored domains',
191
+ data: positiveNegative,
192
+ series: {
193
+ dataKey: ['feedback count'],
194
+ label: 'Feedback Count',
195
+ },
196
+ overlay: {
197
+ dataKey: ['overlay'],
198
+ label: 'Overlay',
199
+ },
200
+ mirrorDomains: true,
201
+ };
202
+ export const withVerticalFixedBars = Template.bind({});
203
+ withVerticalFixedBars.args = {
204
+ subtitle: 'with vertical layout and fixed thickness bars',
205
+ overlay: {
206
+ dataKey: ['overlay'],
207
+ label: 'Overlay',
208
+ domain: [0, 1],
209
+ },
210
+ fixedBarSize: true,
211
+ layout: CartesianChartLayout.VERTICAL,
212
+ };
213
+ export const withMissingData = Template.bind({});
214
+ withMissingData.args = {
215
+ data: feedbackCountGaps,
216
+ subtitle: 'with missing values',
217
+ overlay: {
218
+ dataKey: ['overlay'],
219
+ label: 'Overlay',
220
+ },
221
+ };
222
+ export const withCustomBarStyle = Template.bind({});
223
+ withCustomBarStyle.args = {
224
+ subtitle: 'with multiple series and custom colors',
225
+ data: proCons,
226
+ index: {
227
+ dataKey: 'date',
228
+ label: 'Time',
229
+ },
230
+ series: {
231
+ dataKey: ['positive', 'negative', 'neutral'],
232
+ label: 'Pros & cons',
233
+ style: [
234
+ {
235
+ fill: 'slateGray',
236
+ },
237
+ {
238
+ fill: 'salmon',
239
+ },
240
+ {
241
+ fill: 'lightBlue',
242
+ },
243
+ ],
244
+ },
245
+ };
246
+ export const withBrush = Template.bind({});
247
+ withBrush.args = {
248
+ data: products,
249
+ subtitle: 'with brush and twelve series, one for each color of the default theme',
250
+ sortBy: 'descending-value',
251
+ showBackground: true,
252
+ showBrush: true,
253
+ index: {
254
+ dataKey: 'date',
255
+ label: 'Year',
256
+ },
257
+ series: {
258
+ dataKey: [
259
+ 'QN95B Neo QLED 4K TV',
260
+ 'Q800A Neo QLED 4K TV',
261
+ 'Q60A QLED 4K TV',
262
+ 'C2 OLED 4K TV',
263
+ 'G2 OLED Evo 4K TV',
264
+ 'B2 OLED 4K TV',
265
+ 'A95K QD-OLED 4K TV',
266
+ 'X95J LED 4K TV',
267
+ 'X85J LED 4K TV',
268
+ 'R6485Q Mini-LED QLED 4K TV',
269
+ 'S546Q 4K QLED TV',
270
+ 'S435 4K Roku TV',
271
+ ],
272
+ label: 'Product Units',
273
+ tickFormat: (l) => `${l}K`,
274
+ domain: [0, 1000],
275
+ hideZero: true,
276
+ },
277
+ };
278
+ export const WithMenu = Template.bind({});
279
+ WithMenu.args = {
280
+ subtitle: 'with custom style and menu',
281
+ data: proCons,
282
+ index: {
283
+ dataKey: 'date',
284
+ label: 'Time',
285
+ },
286
+ series: {
287
+ dataKey: ['positive', 'negative', 'neutral'],
288
+ label: 'Pros & cons',
289
+ style: [
290
+ {
291
+ fill: 'slateGray',
292
+ },
293
+ {
294
+ fill: 'salmon',
295
+ },
296
+ {
297
+ fill: 'lightBlue',
298
+ },
299
+ ],
300
+ },
301
+ menu: FakeMenu,
302
+ };
303
+ const WithinCardTemplate = (args) => {
304
+ const { theme } = args;
305
+ return (_jsx(Card, { bordered: true, className: styles.Card, style: { backgroundColor: theme === 'dark' ? '#202227' : undefined }, children: _jsx(BarChart, { ...args }) }));
306
+ };
307
+ export const WithinCard = WithinCardTemplate.bind({});
308
+ WithinCard.args = {
309
+ subtitle: 'within a card 75vh and width 100%',
310
+ series: {
311
+ dataKey: ['feedback count'],
312
+ label: 'Feedback Count',
313
+ domain: [0, 12000],
314
+ },
315
+ overlay: {
316
+ dataKey: ['overlay', 'overlayB'],
317
+ rename: ((o, i) => (i === 0 ? 'OverlayA' : o)),
318
+ label: 'Overlay',
319
+ domain: [0, 1],
320
+ },
321
+ data: feedbackCount.slice(10, 15),
322
+ hidePadding: true,
323
+ theme: 'dark',
324
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "12.11.0",
3
+ "version": "14.0.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -63,8 +63,8 @@
63
63
  "react-dom": ">=17.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@babel/core": "7.19.3",
67
- "@babel/preset-typescript": "7.18.6",
66
+ "@babel/core": "7.24.3",
67
+ "@babel/preset-typescript": "7.24.1",
68
68
  "@storybook/addon-a11y": "6.5.16",
69
69
  "@storybook/addon-actions": "6.5.16",
70
70
  "@storybook/addon-coverage": "0.0.7",
@@ -80,15 +80,15 @@
80
80
  "@storybook/theming": "6.5.16",
81
81
  "@types/react": "17.0.43",
82
82
  "@types/react-dom": "17.0.14",
83
- "@types/react-table": "7.7.18",
83
+ "@types/react-table": "7.7.20",
84
84
  "@types/react-test-renderer": "18.0.7",
85
- "@wonderflow/config": "12.11.0",
86
- "@wonderflow/tokens": "12.11.0",
87
- "@wonderflow/charts": "12.11.0",
88
- "@types/uuid": "9.0.7",
85
+ "@wonderflow/config": "14.0.0",
86
+ "@wonderflow/tokens": "14.0.0",
87
+ "@wonderflow/charts": "14.0.0",
88
+ "@types/uuid": "9.0.8",
89
89
  "babel-loader": "8.2.5",
90
90
  "cpy-cli": "3.1.1",
91
- "postcss": "8.4.32",
91
+ "postcss": "8.4.38",
92
92
  "postcss-cli": "10.0.0",
93
93
  "react": "17.0.2",
94
94
  "react-dom": "17.0.2",
@@ -107,7 +107,7 @@
107
107
  "constate": "3.3.2",
108
108
  "framer-motion": "6.5.1",
109
109
  "lodash": "4.17.21",
110
- "react-focus-on": "3.9.1",
110
+ "react-focus-on": "3.9.2",
111
111
  "react-masonry-css": "1.0.16",
112
112
  "react-merge-refs": "2.1.1",
113
113
  "react-paginate": "8.2.0",