datastake-daf 0.6.382 → 0.6.384

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.
Files changed (33) hide show
  1. package/dist/components/index.js +222 -345
  2. package/dist/style/datastake/mapbox-gl.css +330 -0
  3. package/dist/utils/index.js +0 -24
  4. package/package.json +2 -2
  5. package/src/@daf/core/components/Charts/AreaChart/AreaChart.stories.jsx +1 -444
  6. package/src/@daf/core/components/Charts/AreaChart/index.jsx +12 -27
  7. package/src/@daf/core/components/Charts/BarChart/BarChart.stories.jsx +0 -88
  8. package/src/@daf/core/components/Charts/BarChart/index.jsx +12 -27
  9. package/src/@daf/core/components/Charts/ColumnChart/ColumnChart.stories.jsx +28 -23
  10. package/src/@daf/core/components/Charts/ColumnChart/index.jsx +20 -42
  11. package/src/@daf/core/components/Charts/DonutPie/DonutPie.stories.jsx +0 -55
  12. package/src/@daf/core/components/Charts/DonutPie/index.js +11 -21
  13. package/src/@daf/core/components/Charts/DualAxes/DualAxes.stories.js +0 -33
  14. package/src/@daf/core/components/Charts/DualAxes/index.js +0 -21
  15. package/src/@daf/core/components/Charts/LineChart/LineChart.stories.jsx +0 -81
  16. package/src/@daf/core/components/Charts/LineChart/index.jsx +12 -21
  17. package/src/@daf/core/components/Charts/PieChart/PieChart.stories.js +0 -52
  18. package/src/@daf/core/components/Charts/PieChart/chart.jsx +90 -20
  19. package/src/@daf/core/components/Charts/RadarChart/RadarChart.stories.jsx +0 -52
  20. package/src/@daf/core/components/Charts/RadarChart/index.jsx +0 -21
  21. package/src/@daf/core/components/Charts/RadialBarChart/RadialBarChart.stories.jsx +0 -56
  22. package/src/@daf/core/components/Charts/RadialBarChart/index.jsx +0 -22
  23. package/src/@daf/core/components/Charts/StackChart/StackChart.stories.jsx +0 -22
  24. package/src/@daf/core/components/Charts/StackChart/index.jsx +14 -22
  25. package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +4 -2
  26. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +23 -5
  27. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +12 -1
  28. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +2 -0
  29. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +2 -0
  30. package/src/helpers/StringHelper.js +0 -29
  31. package/src/utils.js +1 -1
  32. package/src/@daf/core/components/Charts/components/CustomLegend/index.js +0 -80
  33. package/src/@daf/core/components/Charts/helper.js +0 -25
@@ -1,7 +1,6 @@
1
1
  import ColumnChart from "./index";
2
2
  import ThemeLayout from "../../ThemeLayout";
3
3
  import Widget from "../../Dashboard/Widget";
4
- import { splitStringInMultipleLines } from "../../../../../helpers/StringHelper.js";
5
4
 
6
5
  export default {
7
6
  title: "Charts/ColumnChart",
@@ -457,29 +456,35 @@ export const Pdf = {
457
456
  renderTooltipContent: renderTooltipContent,
458
457
  showBackground: true,
459
458
  isPercentage: true,
460
- legendConfig: {
461
- enabled: false,
462
- position: 'bottom',
463
- layout: 'horizontal',
464
- items: [
465
- {
466
- id: 'baseline',
467
- label: 'Baseline',
468
- color: '#96b1ff',
469
- },
470
- {
471
- id: 'improvement',
472
- label: 'Improvement',
473
- color: '#4b6ae7',
474
- },
475
- {
476
- id: 'profit',
477
- label: 'Net Profit',
478
- color: '#52c41a',
459
+ shouldSeperateLegendName: true,
460
+ formattedXAxis: (s) => {
461
+ if (!s) return "";
462
+
463
+ const limit = 20;
464
+ let result = "";
465
+ let line = "";
466
+
467
+ for (let word of s.split(" ")) {
468
+ if ((line + word).length <= limit) {
469
+ line += (line ? " " : "") + word;
470
+ } else if (word.length > limit) {
471
+ // break long word with hyphen
472
+ while (word.length > limit) {
473
+ result += word.slice(0, limit - 1) + "-\n";
474
+ word = word.slice(limit - 1);
479
475
  }
480
- ]
481
- },
482
- formattedXAxis: (s) => splitStringInMultipleLines(s, 25),
476
+ line = word;
477
+ } else {
478
+ // move current line into result
479
+ if (line) result += line + "\n";
480
+ line = word;
481
+ }
482
+ }
483
+
484
+ if (line) result += line;
485
+
486
+ return result;
487
+ },
483
488
  },
484
489
  render: (args) => {
485
490
  return <Widget title="Pdf Column Chart" className={"with-border-header"}>
@@ -3,8 +3,6 @@ import Container from "../style";
3
3
  import { theme } from "antd";
4
4
  import { renderTooltip } from "../../../../utils/tooltip";
5
5
  import { Column } from "@antv/g2plot";
6
- import CustomLegend from "../components/CustomLegend/index.js";
7
- import { useLegendConfig } from "../helper";
8
6
 
9
7
  const { useToken } = theme;
10
8
 
@@ -68,22 +66,9 @@ const { useToken } = theme;
68
66
  * - `color` (string | string[] | function):
69
67
  * Custom color or color function for bars. If not provided, falls back to Ant Design's theme primary color.
70
68
  *
71
- * - `legendConfig` (object):
72
- * Configuration for the custom legend:
73
- * {
74
- * enabled: boolean, // Show/hide the legend (default: false)
75
- * position: 'top' | 'bottom', // Legend position (default: 'bottom')
76
- * items: Array<{ // Manual legend items (optional, auto-generated from data if not provided)
77
- * label: string, // Display label
78
- * color: string, // Color for this item
79
- * description?: string // Optional description/explanation
80
- * }>,
81
- * layout: 'horizontal' | 'vertical', // Legend layout (default: 'horizontal')
82
- * interactive: boolean, // Allow clicking to filter data (default: true)
83
- * style: object // Custom CSS styles for legend container
84
- * }
85
69
  */
86
70
 
71
+
87
72
  export default function ColumnChart({
88
73
  data = [],
89
74
  xFieldKey = "label",
@@ -101,23 +86,17 @@ export default function ColumnChart({
101
86
  color,
102
87
  height,
103
88
  groupField,
104
- width,
105
- legendConfig = {},
89
+ t = (s) => s,
106
90
  isPdf = false,
91
+ extraLegendConfig = {},
92
+ shouldSeperateLegendName = false,
93
+ width,
107
94
  ...rest
108
95
  }) {
109
96
  const containerRef = React.useRef(null);
110
97
  const chartRef = React.useRef(null);
111
98
  const { token } = useToken();
112
-
113
- const {
114
- legendEnabled,
115
- legendItems,
116
- legendPosition,
117
- legendLayout,
118
- legendInteractive,
119
- legendStyle
120
- } = useLegendConfig({legendConfig, isPdf});
99
+ const hasLegendConfig = Object.keys(extraLegendConfig).length > 0;
121
100
 
122
101
  React.useEffect(() => {
123
102
  if (!containerRef.current) {
@@ -165,7 +144,19 @@ export default function ColumnChart({
165
144
  : formattedYAxis,
166
145
  },
167
146
  },
168
- legend: false,
147
+ legend: isPdf
148
+ ? {
149
+ itemName: {
150
+ formatter: (text) => {
151
+ const textToTranslate = shouldSeperateLegendName ? text.split("-")[1].toLowerCase() : text
152
+ return t(textToTranslate)
153
+ },
154
+ },
155
+ position: 'bottom',
156
+ ...extraLegendConfig,
157
+ }
158
+ : hasLegendConfig || false,
159
+ // Add background pattern only when showBackground is true and isPercentage is true
169
160
  ...(showBackground && isPercentage && {
170
161
  columnBackground: {
171
162
  style: {},
@@ -210,21 +201,8 @@ export default function ColumnChart({
210
201
  return (
211
202
  <div className="flex flex-1 flex-column justify-content-center">
212
203
  <div className="flex justify-content-center">
213
- <Container
214
- ref={containerRef}
215
- height={height}
216
- isPdf={false}
217
- width={width}
218
- ></Container>
204
+ <Container ref={containerRef} height={height} isPdf={isPdf} width={width}></Container>
219
205
  </div>
220
- {legendEnabled && legendPosition === 'bottom' && (
221
- <CustomLegend
222
- items={legendItems}
223
- layout={legendLayout}
224
- interactive={legendInteractive}
225
- style={legendStyle}
226
- />
227
- )}
228
206
  </div>
229
207
  );
230
208
  }
@@ -126,59 +126,4 @@ export const MultipleSegments = {
126
126
  <DonutPie {...args} />
127
127
  </Widget>
128
128
  ),
129
- };
130
-
131
- export const Pdf = {
132
- name: "Pdf",
133
- args: {
134
- data: multiData,
135
- isPdf: true,
136
- angleField: "value",
137
- colorField: "type",
138
- color: ["#028788", "#E8ED13", "#F68D16", "#5B8F59"],
139
- tooltip: true,
140
- renderTooltipContent: (title, data) => {
141
- console.log("title", title, data);
142
- return {
143
- title,
144
- items: data.map((item) => ({
145
- label: "TEXT",
146
- value: item.value,
147
- })),
148
- };
149
- },
150
- tooltipConfig: {
151
- showTitle: false,
152
- },
153
- legendConfig: {
154
- enabled: false,
155
- position: 'bottom',
156
- layout: 'horizontal',
157
- items: [
158
- {
159
- id: 'baseline',
160
- label: 'Baseline',
161
- color: '#96b1ff',
162
- },
163
- {
164
- id: 'improvement',
165
- label: 'Improvement',
166
- color: '#4b6ae7',
167
- },
168
- {
169
- id: 'profit',
170
- label: 'Net Profit',
171
- color: '#52c41a',
172
- }
173
- ]
174
- },
175
- height: 220,
176
- innerRadius: 0.78,
177
- radius: 1,
178
- },
179
- render: (args) => (
180
- <Widget title="Donut Chart - Multiple Segments" className="with-border-header">
181
- <DonutPie {...args} />
182
- </Widget>
183
- ),
184
129
  };
@@ -3,8 +3,6 @@ import Container from "../style";
3
3
  import { theme } from "antd";
4
4
  import { Pie } from "@antv/g2plot";
5
5
  import { renderTooltip } from "../../../../utils/tooltip";
6
- import CustomLegend from "../components/CustomLegend/index.js";
7
- import { useLegendConfig } from "../helper.js";
8
6
 
9
7
  const { useToken } = theme;
10
8
 
@@ -75,21 +73,13 @@ export default function DonutPie({
75
73
  animation = false,
76
74
  t = (s) => s,
77
75
  isPdf = false,
78
- legendConfig = {},
76
+ extraLegendConfig = {},
79
77
  ...rest
80
78
  }) {
81
79
  const containerRef = useRef(null);
82
80
  const chartRef = useRef(null);
83
81
  const { token } = useToken();
84
-
85
- const {
86
- legendEnabled,
87
- legendItems,
88
- legendPosition,
89
- legendLayout,
90
- legendInteractive,
91
- legendStyle
92
- } = useLegendConfig({legendConfig, isPdf});
82
+ const hasLegendConfig = Object.keys(extraLegendConfig).length > 0;
93
83
 
94
84
  // Memoize processed data for progress mode
95
85
  const processedData = useMemo(() => {
@@ -122,7 +112,15 @@ export default function DonutPie({
122
112
  color: color || [token.colorPrimary7, "#E8EDF3"],
123
113
  radius,
124
114
  innerRadius,
125
- legend: false,
115
+ legend: isPdf
116
+ ? {
117
+ itemName: {
118
+ formatter: (text) => t(text),
119
+ },
120
+ position: 'bottom',
121
+ ...extraLegendConfig,
122
+ }
123
+ : hasLegendConfig || false,
126
124
  label,
127
125
  statistic,
128
126
  tooltip: tooltipOption,
@@ -170,14 +168,6 @@ export default function DonutPie({
170
168
  <div className="flex justify-content-center">
171
169
  <Container ref={containerRef} style={{ height }} isPdf={isPdf} />
172
170
  </div>
173
- {legendEnabled && legendPosition === 'bottom' && (
174
- <CustomLegend
175
- items={legendItems}
176
- layout={legendLayout}
177
- interactive={legendInteractive}
178
- style={legendStyle}
179
- />
180
- )}
181
171
  </div>
182
172
  );
183
173
  }
@@ -74,36 +74,3 @@ export const FormattedAxis = {
74
74
  },
75
75
  render: (args) => <DualAxesChart {...args} />,
76
76
  };
77
-
78
- export const Pdf = {
79
- name: " Pdf",
80
- args: {
81
- formattedLeftAxis: (s) => `${s} units`,
82
- formattedRightAxis: (s) => `${s} items`,
83
- formattedXAxis: (s) => `Year ${s}`,
84
- isPdf: true,
85
- legendConfig: {
86
- enabled: false,
87
- position: 'bottom',
88
- layout: 'horizontal',
89
- items: [
90
- {
91
- id: 'baseline',
92
- label: 'Baseline',
93
- color: '#96b1ff',
94
- },
95
- {
96
- id: 'improvement',
97
- label: 'Improvement',
98
- color: '#4b6ae7',
99
- },
100
- {
101
- id: 'profit',
102
- label: 'Net Profit',
103
- color: '#52c41a',
104
- }
105
- ]
106
- },
107
- },
108
- render: (args) => <DualAxesChart {...args} />,
109
- };
@@ -3,8 +3,6 @@ import Container from "../style";
3
3
  import { theme } from "antd";
4
4
  import { renderTooltip } from "../../../../utils/tooltip";
5
5
  import { DualAxes } from "@antv/g2plot";
6
- import { useLegendConfig } from "../helper";
7
- import CustomLegend from "../components/CustomLegend/index.js";
8
6
 
9
7
  const { useToken } = theme;
10
8
 
@@ -20,22 +18,11 @@ export default function DualAxesChart({
20
18
  formattedRightAxis = (s) => s,
21
19
  formattedXAxis = (s) => s,
22
20
  color,
23
- legendConfig = {},
24
- isPdf = false,
25
21
  }) {
26
22
  const containerRef = React.useRef(null);
27
23
  const chartRef = React.useRef(null);
28
24
  const { token } = useToken();
29
25
 
30
- const {
31
- legendEnabled,
32
- legendItems,
33
- legendPosition,
34
- legendLayout,
35
- legendInteractive,
36
- legendStyle
37
- } = useLegendConfig({legendConfig, isPdf});
38
-
39
26
  const _colours = useMemo(() => {
40
27
  const defaultColours = [token.colorPrimary7, token.colorPrimary6, token.colorPrimary8];
41
28
 
@@ -133,14 +120,6 @@ export default function DualAxesChart({
133
120
  <div className="flex justify-content-center">
134
121
  <Container ref={containerRef} data-testid="dual-axes-chart"></Container>
135
122
  </div>
136
- {legendEnabled && legendPosition === 'bottom' && (
137
- <CustomLegend
138
- items={legendItems}
139
- layout={legendLayout}
140
- interactive={legendInteractive}
141
- style={legendStyle}
142
- />
143
- )}
144
123
  </div>
145
124
  );
146
125
  }
@@ -156,8 +156,6 @@ export const MultipleLines = {
156
156
  },
157
157
  };
158
158
 
159
-
160
-
161
159
  export const AreaChart = {
162
160
  name: "Area Chart",
163
161
  args: {
@@ -245,82 +243,3 @@ export const AutoHideXLabel = {
245
243
  );
246
244
  },
247
245
  };
248
-
249
- export const Pdf = {
250
- name: "Pdf",
251
- args: {
252
- data: [
253
- { label: "Jan", value: 30, type: "gold" },
254
- { label: "Feb", value: 20, type: "gold" },
255
- { label: "Mar", value: 50, type: "gold" },
256
- { label: "Apr", value: 40, type: "gold" },
257
- { label: "May", value: 60, type: "gold" },
258
- { label: "Jun", value: 70, type: "gold" },
259
- { label: "Jul", value: 80, type: "gold" },
260
- { label: "Aug", value: 90, type: "gold" },
261
- { label: "Sep", value: 100, type: "gold" },
262
- { label: "Oct", value: 110, type: "gold" },
263
- { label: "Nov", value: 120, type: "gold" },
264
- { label: "Dec", value: 130, type: "gold" },
265
-
266
- { label: "Jan", value: 130, type: "silver" },
267
- { label: "Feb", value: 120, type: "silver" },
268
- { label: "Mar", value: 150, type: "silver" },
269
- { label: "Apr", value: 140, type: "silver" },
270
- { label: "May", value: 160, type: "silver" },
271
- { label: "Jun", value: 170, type: "silver" },
272
- { label: "Jul", value: 180, type: "silver" },
273
- { label: "Aug", value: 190, type: "silver" },
274
- { label: "Sep", value: 1100, type: "silver" },
275
- { label: "Oct", value: 1110, type: "silver" },
276
- { label: "Nov", value: 1120, type: "silver" },
277
- { label: "Dec", value: 1130, type: "silver" },
278
- ],
279
- xFieldKey: "label",
280
- yFieldKey: "value",
281
- formattedYAxis: (s) => `${s}`.replace(/\d{1,3}(?=(\d{3})+$)/g, (s) => `${s},`) + "g",
282
- renderTooltipContent: (title, data) => {
283
- return {
284
- title,
285
- items: data.map((item) => ({
286
- label: item.name,
287
- value: item.value,
288
- color: item.color,
289
- })),
290
- };
291
- },
292
- // isSmooth: true,
293
- seriesField: "type",
294
- color: ["#1890FF", "#2FC25B"], // Custom colors for different lines
295
- isPdf: true,
296
- legendConfig: {
297
- enabled: false,
298
- position: 'bottom',
299
- layout: 'horizontal',
300
- items: [
301
- {
302
- id: 'baseline',
303
- label: 'Baseline',
304
- color: '#96b1ff',
305
- },
306
- {
307
- id: 'improvement',
308
- label: 'Improvement',
309
- color: '#4b6ae7',
310
- },
311
- {
312
- id: 'profit',
313
- label: 'Net Profit',
314
- color: '#52c41a',
315
- }
316
- ]
317
- },
318
- },
319
- render: (args) => {
320
- return (
321
- <Widget title="Multiple Lines Chart" className={"with-border-header"}>
322
- <LineChart {...args} />
323
- </Widget>
324
- );
325
- },
326
- };
@@ -3,8 +3,6 @@ import Container from "../style";
3
3
  import { theme } from "antd";
4
4
  import { renderTooltip } from "../../../../utils/tooltip";
5
5
  import { Line } from "@antv/g2plot";
6
- import { useLegendConfig } from "../helper";
7
- import CustomLegend from "../components/CustomLegend/index.js";
8
6
 
9
7
  const { useToken } = theme;
10
8
 
@@ -86,22 +84,14 @@ export default function LineChart({
86
84
  autoHideXLabel = true,
87
85
  t = (s) => s,
88
86
  isPdf = false,
89
- legendConfig = {},
87
+ extraLegendConfig = {},
90
88
  width,
91
89
  ...rest
92
90
  }) {
93
91
  const containerRef = React.useRef(null);
94
92
  const chartRef = React.useRef(null);
95
93
  const { token } = useToken();
96
-
97
- const {
98
- legendEnabled,
99
- legendItems,
100
- legendPosition,
101
- legendLayout,
102
- legendInteractive,
103
- legendStyle
104
- } = useLegendConfig({legendConfig, isPdf});
94
+ const hasLegendConfig = Object.keys(extraLegendConfig).length > 0;
105
95
 
106
96
  React.useEffect(() => {
107
97
  if (!containerRef.current) {
@@ -156,7 +146,15 @@ export default function LineChart({
156
146
  fillOpacity: isArea ? 0.15 : 0,
157
147
  },
158
148
  },
159
- legend: false,
149
+ legend: isPdf
150
+ ? {
151
+ itemName: {
152
+ formatter: (text) => t(text),
153
+ },
154
+ position: 'bottom',
155
+ ...extraLegendConfig,
156
+ }
157
+ : hasLegendConfig || false,
160
158
  };
161
159
 
162
160
  if (!chartRef.current) {
@@ -182,6 +180,7 @@ export default function LineChart({
182
180
  renderTooltipContent,
183
181
  tooltipConfig,
184
182
  isPdf,
183
+ extraLegendConfig,
185
184
  t,
186
185
  ]);
187
186
 
@@ -199,14 +198,6 @@ export default function LineChart({
199
198
  <div className="flex justify-content-center">
200
199
  <Container ref={containerRef} height={height} isPdf={isPdf} width={width}></Container>
201
200
  </div>
202
- {legendEnabled && legendPosition === 'bottom' && (
203
- <CustomLegend
204
- items={legendItems}
205
- layout={legendLayout}
206
- interactive={legendInteractive}
207
- style={legendStyle}
208
- />
209
- )}
210
201
  </div>
211
202
  );
212
203
  }
@@ -44,55 +44,3 @@ export const Primary = {
44
44
  isPercentage: true,
45
45
  },
46
46
  };
47
-
48
- export const Pdf = {
49
- name: "Pdf",
50
- args: {
51
- data: [
52
- {
53
- "percent": 0.8333333333333334,
54
- "label": "Label 1",
55
- "color": "#F5C2AC"
56
- },
57
- {
58
- "percent": 0.06666666666666667,
59
- "label": "Label 2",
60
- "color": "#F0A888"
61
- },
62
- {
63
- "percent": 0.06666666666666667,
64
- "label": "Label 3",
65
- "color": "#DF571E"
66
- },
67
- {
68
- "percent": 0.03333333333333333,
69
- "label": "Label 4",
70
- "color": "#C04B19"
71
- }
72
- ],
73
- isPdf: true,
74
- legendConfig: {
75
- enabled: false,
76
- position: 'bottom',
77
- layout: 'horizontal',
78
- items: [
79
- {
80
- id: 'baseline',
81
- label: 'Baseline',
82
- color: '#96b1ff',
83
- },
84
- {
85
- id: 'improvement',
86
- label: 'Improvement',
87
- color: '#4b6ae7',
88
- },
89
- {
90
- id: 'profit',
91
- label: 'Net Profit',
92
- color: '#52c41a',
93
- }
94
- ]
95
- },
96
- isPercentage: true,
97
- },
98
- };