intelicoreact 2.0.7 → 2.0.9

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 (77) hide show
  1. package/charts/package.json +5 -0
  2. package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.d.ts +1 -1
  3. package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.d.ts +7 -7
  4. package/dist/Atomic/FormElements/Input/Input.d.ts +1 -1
  5. package/dist/Atomic/FormElements/Input/types.d.ts +0 -5
  6. package/dist/Atomic/FormElements/InputMask3/InputMask3.interface.d.ts +0 -3
  7. package/dist/Atomic/FormElements/NumericInput/NumericInput.d.ts +15 -15
  8. package/dist/Atomic/FormElements/RangeSlider/RangeSlider.d.ts +11 -11
  9. package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.interface.d.ts +1 -1
  10. package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.interface.d.ts +4 -4
  11. package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.d.ts +2 -2
  12. package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.d.ts +4 -4
  13. package/dist/Atomic/UI/AccordionTable/AccordionTable.d.ts +1 -1
  14. package/dist/Atomic/UI/AccordionText/AccordionText.d.ts +4 -4
  15. package/dist/Atomic/UI/Alert/Alert.interface.d.ts +0 -2
  16. package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.d.ts +4 -4
  17. package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.d.ts +1 -1
  18. package/dist/Atomic/UI/MonoAccordion/MonoAccordion.d.ts +2 -2
  19. package/dist/Atomic/UI/PieChart/PieChart.d.ts +3 -3
  20. package/dist/Atomic/UI/Table/Partials/TdHeader.d.ts +1 -1
  21. package/dist/Atomic/UI/Table/Partials/TdRow.d.ts +1 -1
  22. package/dist/Atomic/UI/Table/Table.d.ts +1 -1
  23. package/dist/Classes/AbortableFetch.d.ts +17 -17
  24. package/dist/Classes/RESTAPI/index.d.ts +1 -1
  25. package/dist/Classes/RESTAPI/partials/AbortableFetch.d.ts +17 -17
  26. package/dist/Classes/RESTAPI/partials/CredentialsProcessing.d.ts +4 -4
  27. package/dist/Functions/hooks/useFormFieldsChangesManager.d.ts +2 -2
  28. package/dist/Functions/sdk/runtime-sdk/transport.d.ts +2 -2
  29. package/dist/Functions/useFieldFocus.d.ts +2 -2
  30. package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.d.ts +1 -1
  31. package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.d.ts +1 -1
  32. package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.d.ts +2 -2
  33. package/dist/Functions/useFormTools/functions/General.d.ts +3 -3
  34. package/dist/Functions/useFormTools/functions/RenderFields.d.ts +5 -5
  35. package/dist/Functions/useFormTools/index.d.ts +20 -20
  36. package/dist/Functions/useMetaInfo.d.ts +2 -2
  37. package/dist/Functions/usePasswordChecker.d.ts +1 -1
  38. package/dist/Functions/utils.d.ts +11 -11
  39. package/dist/charts.cjs +927 -0
  40. package/dist/charts.cjs.map +7 -0
  41. package/dist/charts.d.ts +7 -0
  42. package/dist/charts.js +911 -0
  43. package/dist/charts.js.map +7 -0
  44. package/dist/form.cjs +1498 -1933
  45. package/dist/form.cjs.map +4 -4
  46. package/dist/form.js +1114 -1549
  47. package/dist/form.js.map +4 -4
  48. package/dist/hooks.cjs +8 -324
  49. package/dist/hooks.cjs.map +4 -4
  50. package/dist/hooks.js +8 -324
  51. package/dist/hooks.js.map +4 -4
  52. package/dist/index.cjs +2507 -9293
  53. package/dist/index.cjs.map +4 -4
  54. package/dist/index.js +2059 -8861
  55. package/dist/index.js.map +4 -4
  56. package/dist/layout.cjs +207 -6308
  57. package/dist/layout.cjs.map +4 -4
  58. package/dist/layout.js +202 -6303
  59. package/dist/layout.js.map +4 -4
  60. package/dist/presets.cjs +0 -643
  61. package/dist/presets.cjs.map +4 -4
  62. package/dist/presets.js +0 -633
  63. package/dist/presets.js.map +4 -4
  64. package/dist/ui.cjs +711 -7854
  65. package/dist/ui.cjs.map +4 -4
  66. package/dist/ui.d.ts +0 -5
  67. package/dist/ui.js +722 -7881
  68. package/dist/ui.js.map +4 -4
  69. package/dist/utils.cjs +4 -51
  70. package/dist/utils.cjs.map +3 -3
  71. package/dist/utils.js +4 -51
  72. package/dist/utils.js.map +3 -3
  73. package/package.json +19 -3
  74. package/styles.css +1 -0
  75. package/dist/Atomic/UI/DynamicIcon/DynamicIcon.d.ts +0 -4
  76. package/dist/Atomic/UI/DynamicIcon/DynamicIcon.interface.d.ts +0 -6
  77. package/dist/Atomic/UI/DynamicIcon/index.d.ts +0 -3
package/dist/charts.js ADDED
@@ -0,0 +1,911 @@
1
+ // src/Atomic/UI/Chart/Chart.tsx
2
+ import {
3
+ BarElement,
4
+ CategoryScale,
5
+ Chart as ChartJS,
6
+ Filler,
7
+ LinearScale,
8
+ LineElement,
9
+ PointElement,
10
+ Tooltip
11
+ } from "chart.js";
12
+ import cn2 from "classnames";
13
+ import React, {
14
+ useCallback,
15
+ useEffect as useEffect2,
16
+ useLayoutEffect,
17
+ useMemo,
18
+ useRef,
19
+ useState
20
+ } from "react";
21
+ import * as ChartComponents from "react-chartjs-2";
22
+
23
+ // src/Functions/utils.js
24
+ import { useEffect } from "react";
25
+ import moment from "moment-timezone";
26
+ var clone = (input) => {
27
+ if (input === null || typeof input !== "object") return input;
28
+ const data = input instanceof Array ? [] : {};
29
+ for (const i in input) data[i] = clone(input[i]);
30
+ return data;
31
+ };
32
+ var omitKeys = (obj = {}, keys = []) => keys.reduce((acc, key) => {
33
+ const { [key]: omit, ...rest } = acc;
34
+ return rest;
35
+ }, obj);
36
+ String.prototype.longerThan = function(compareWith) {
37
+ return this?.length > compareWith?.length;
38
+ };
39
+ String.prototype.lastIndexEqualsTo = function(index) {
40
+ return this?.length - 1 === index;
41
+ };
42
+
43
+ // src/Atomic/UI/Chart/partial/Chart.constants.js
44
+ var CHART_TYPES = ["Bar", "Line"];
45
+ var DEFAULT_CHART_MODEL = "emptyLayout";
46
+ var FINTURF_ADD_GRADIENT_COLORS_POSITIVE = ["#53D1AD", "#389AA3"];
47
+ var FINTURF_ADD_GRADIENT_COLORS_NEGATIVE = ["#FDB4DB", "#FA2E69"];
48
+ var GRADIENTS_OBJECTS = {
49
+ finturf: {
50
+ bar: [
51
+ {
52
+ gradientTargetPropertyName: "backgroundColor",
53
+ colors: FINTURF_ADD_GRADIENT_COLORS_POSITIVE,
54
+ direction: "toBottom",
55
+ typeDistributionOfGradientPoints: "personalBase",
56
+ collorStopPoints: [0.2, 1]
57
+ }
58
+ ],
59
+ line: [
60
+ {
61
+ gradientTargetPropertyName: "borderColor",
62
+ colors: FINTURF_ADD_GRADIENT_COLORS_POSITIVE,
63
+ direction: "toRight"
64
+ },
65
+ {
66
+ gradientTargetPropertyName: "backgroundColor",
67
+ colors: [
68
+ "rgba(84, 210, 173, 0.2)",
69
+ "rgba(84, 210, 173, 0.1)",
70
+ "rgba(84, 210, 173, 0)"
71
+ ],
72
+ direction: "toBottom",
73
+ collorStopPoints: [0.31, 0.72, 1],
74
+ isAddFill: true
75
+ }
76
+ ],
77
+ positiveLineIcon: [
78
+ {
79
+ gradientTargetPropertyName: "borderColor",
80
+ colors: FINTURF_ADD_GRADIENT_COLORS_POSITIVE,
81
+ direction: "toRight"
82
+ }
83
+ ],
84
+ negativeLineIcon: [
85
+ {
86
+ gradientTargetPropertyName: "borderColor",
87
+ colors: FINTURF_ADD_GRADIENT_COLORS_NEGATIVE,
88
+ direction: "toRight"
89
+ }
90
+ ]
91
+ }
92
+ };
93
+ var FINTURF_TOOLTIP_OPTIONS = {
94
+ enabled: true,
95
+ mode: "index",
96
+ intersect: false,
97
+ padding: 8,
98
+ backgroundColor: "#FFFFFF",
99
+ titleColor: "#757F8C",
100
+ borderColor: "#D6D9E4",
101
+ titleFont: {
102
+ family: "Sarabun",
103
+ style: "normal",
104
+ weight: 500,
105
+ size: 12
106
+ // line-height: 18px;
107
+ },
108
+ titleAlign: "center",
109
+ bodyColor: "#1E1E2D",
110
+ bodyFont: {
111
+ family: "Sarabun",
112
+ style: "normal",
113
+ weight: 400,
114
+ size: 14
115
+ },
116
+ bodyAlign: "center",
117
+ caretSize: 0,
118
+ displayColors: false,
119
+ borderWidth: 1,
120
+ borderRadius: 6,
121
+ callbacks: {
122
+ label: (context) => context.raw || "0"
123
+ }
124
+ };
125
+ var ICON_MODELS = [
126
+ "lineIconLayout",
127
+ "finturfPositiveLineIcon",
128
+ "finturfNegativeLineIcon"
129
+ ];
130
+ var COMPONENT_OPTIONS = {
131
+ disableDescriptionsFor: [...ICON_MODELS],
132
+ disableChartTypeSwitcherFor: [...ICON_MODELS, "barLayout", "lineLayout"]
133
+ };
134
+
135
+ // src/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.tsx
136
+ import cn from "classnames";
137
+ import { jsx, jsxs } from "react/jsx-runtime";
138
+ var RC = "chart__type-switcher-icon";
139
+ function getIcon(type) {
140
+ switch (type) {
141
+ case "Bar":
142
+ return /* @__PURE__ */ jsxs(
143
+ "svg",
144
+ {
145
+ width: "24",
146
+ height: "24",
147
+ viewBox: "0 0 24 25",
148
+ fill: "none",
149
+ xmlns: "http://www.w3.org/2000/svg",
150
+ children: [
151
+ /* @__PURE__ */ jsx("rect", { y: "0.5", width: "24", height: "24", rx: "4", fill: "#EAF2FF" }),
152
+ /* @__PURE__ */ jsx(
153
+ "path",
154
+ {
155
+ d: "M18 18V11",
156
+ stroke: "#1F7499",
157
+ strokeWidth: "2",
158
+ strokeLinecap: "round",
159
+ strokeLinejoin: "round"
160
+ }
161
+ ),
162
+ /* @__PURE__ */ jsx(
163
+ "path",
164
+ {
165
+ d: "M12 18V6",
166
+ stroke: "#1F7499",
167
+ strokeWidth: "2",
168
+ strokeLinecap: "round",
169
+ strokeLinejoin: "round"
170
+ }
171
+ ),
172
+ /* @__PURE__ */ jsx(
173
+ "path",
174
+ {
175
+ d: "M6 18V13",
176
+ stroke: "#1F7499",
177
+ strokeWidth: "2",
178
+ strokeLinecap: "round",
179
+ strokeLinejoin: "round"
180
+ }
181
+ )
182
+ ]
183
+ }
184
+ );
185
+ case "Line":
186
+ return /* @__PURE__ */ jsxs(
187
+ "svg",
188
+ {
189
+ width: "24",
190
+ height: "24",
191
+ viewBox: "0 0 24 25",
192
+ fill: "none",
193
+ xmlns: "http://www.w3.org/2000/svg",
194
+ children: [
195
+ /* @__PURE__ */ jsx("rect", { y: "0.5", width: "24", height: "24", rx: "4", fill: "#EAF2FF" }),
196
+ /* @__PURE__ */ jsx(
197
+ "path",
198
+ {
199
+ d: "M21 8L15.2544 13.2668C14.1075 14.3181 12.3288 14.3014 11.1818\n 13.25V13.25C10.0349 12.1986 8.25615 12.1819 7.10919 13.2332L3 17",
200
+ stroke: "#1F7499",
201
+ strokeWidth: "2",
202
+ strokeLinecap: "round",
203
+ strokeLinejoin: "round"
204
+ }
205
+ )
206
+ ]
207
+ }
208
+ );
209
+ default:
210
+ return null;
211
+ }
212
+ }
213
+ var ChartTypeSwitcherIcon = ({
214
+ iconType,
215
+ isActive,
216
+ className,
217
+ onClick
218
+ }) => {
219
+ return /* @__PURE__ */ jsx(
220
+ "div",
221
+ {
222
+ className: cn(RC, { [`${RC}_active`]: isActive }, className),
223
+ onClick,
224
+ children: getIcon(iconType)
225
+ }
226
+ );
227
+ };
228
+ var ChartTypeSwitcherIcon_default = ChartTypeSwitcherIcon;
229
+
230
+ // src/Atomic/UI/Chart/partial/datasetSetters.js
231
+ var addDatasetsObjects = (currentData, mutation) => ({
232
+ ...currentData,
233
+ datasets: currentData.datasets?.map?.((dataset) => ({
234
+ ...dataset,
235
+ ...typeof mutation === "function" ? mutation(dataset) : mutation
236
+ }))
237
+ });
238
+ var createGradient = ({
239
+ ctx,
240
+ area,
241
+ colors,
242
+ direction,
243
+ correctionFactors,
244
+ collorStopPoints
245
+ }) => {
246
+ const getStartGradient = () => {
247
+ switch (direction) {
248
+ case "toTop-toRight":
249
+ return ctx.createLinearGradient(
250
+ area.left,
251
+ area.bottom,
252
+ area.right,
253
+ area.top
254
+ );
255
+ case "toTop-toLeft":
256
+ return ctx.createLinearGradient(
257
+ area.right,
258
+ area.bottom,
259
+ area.left,
260
+ area.top
261
+ );
262
+ case "toBottom-toRight":
263
+ return ctx.createLinearGradient(
264
+ area.left,
265
+ area.top,
266
+ area.right,
267
+ area.bottom
268
+ );
269
+ case "toBottom-toLeft":
270
+ return ctx.createLinearGradient(
271
+ area.right,
272
+ area.top,
273
+ area.left,
274
+ area.bottom
275
+ );
276
+ case "toBottom":
277
+ return ctx.createLinearGradient(0, area.top, 0, area.bottom);
278
+ case "toTop":
279
+ return ctx.createLinearGradient(0, area.bottom, 0, area.top);
280
+ case "toLeft":
281
+ return ctx.createLinearGradient(area.right, 0, area.left, 0);
282
+ case "toRight":
283
+ default:
284
+ return ctx.createLinearGradient(area.left, 0, area.right, 0);
285
+ }
286
+ };
287
+ const getGradientWithPoints = (corection) => {
288
+ const newGradient = getStartGradient();
289
+ const staptPoint = corection ? 1 - corection : 0;
290
+ colors.forEach((color, idx) => {
291
+ const point = (() => {
292
+ if (idx === colors.length - 1) return 1;
293
+ return collorStopPoints && Array.isArray(collorStopPoints) ? staptPoint + collorStopPoints[idx] * (corection || 1) : staptPoint + 1 / colors.length * (corection || 1);
294
+ })();
295
+ newGradient.addColorStop(point.toFixed(2), color);
296
+ });
297
+ return newGradient;
298
+ };
299
+ return correctionFactors ? correctionFactors.map((corection) => getGradientWithPoints(corection)) : getGradientWithPoints();
300
+ };
301
+ var addGradientsObject = (currentData, gradientSettingsObj, chartInstance) => addDatasetsObjects(currentData, (dataset) => ({
302
+ [gradientSettingsObj.gradientTargetPropertyName]: createGradient({
303
+ ctx: chartInstance.ctx,
304
+ area: chartInstance.chartArea,
305
+ colors: gradientSettingsObj.colors,
306
+ direction: gradientSettingsObj.direction,
307
+ correctionFactors: gradientSettingsObj.typeDistributionOfGradientPoints === "personalBase" ? dataset.data.map(
308
+ (value) => value / Math.max.apply(null, dataset.data)
309
+ ) : null,
310
+ collorStopPoints: gradientSettingsObj.collorStopPoints
311
+ }),
312
+ ...gradientSettingsObj.isAddFill ? { fill: true } : {}
313
+ }));
314
+ var addNotLibraryAnimation = (currentData, animationObj, chartInstance) => {
315
+ const { type, ...restAnimationObj } = animationObj || {};
316
+ switch (type) {
317
+ case "runningColumns":
318
+ const runningColumnsDefaultFromValue = 25;
319
+ const runningColumnsDefaultToValue = 75;
320
+ const runningColumnsDefaultAverageValue = 50;
321
+ const runningColumnsDefaultColumnsDelayCoef = 50;
322
+ return addDatasetsObjects(currentData, (dataset) => ({
323
+ animations: dataset.data.map((item, idx) => ({
324
+ y: {
325
+ duration: animationObj.duration,
326
+ easing: animationObj.easing || "linear",
327
+ from: animationObj.isFixExtremeColumns && (!idx || idx === dataset.data.length - 1) ? runningColumnsDefaultAverageValue : animationObj.from || runningColumnsDefaultFromValue,
328
+ to: animationObj.isFixExtremeColumns && (!idx || idx === dataset.data.length - 1) ? runningColumnsDefaultAverageValue : animationObj.to || runningColumnsDefaultToValue,
329
+ loop: true,
330
+ delay: Math.random().toFixed(1) * (animationObj.columnsDelayCoef || runningColumnsDefaultColumnsDelayCoef)
331
+ }
332
+ }))
333
+ }));
334
+ default:
335
+ return currentData;
336
+ }
337
+ };
338
+ function changeData(currentData, iterationKey, settingsForChange, chartInstance) {
339
+ switch (iterationKey) {
340
+ case "setMaxBarThickness":
341
+ return addDatasetsObjects(currentData, {
342
+ maxBarThickness: settingsForChange
343
+ });
344
+ case "addGradientsObjects":
345
+ return settingsForChange.reduce(
346
+ (acc, gradientSettingsObj) => addGradientsObject(acc, gradientSettingsObj, chartInstance),
347
+ clone(currentData)
348
+ );
349
+ case "addNotLibraryAnimations":
350
+ return settingsForChange.reduce(
351
+ (acc, animationObj) => addNotLibraryAnimation(acc, animationObj, chartInstance),
352
+ currentData
353
+ );
354
+ default:
355
+ return currentData;
356
+ }
357
+ }
358
+ var datasetSetters_default = changeData;
359
+
360
+ // src/Atomic/UI/Chart/partial/optionsSetters.js
361
+ var addGradientsSettings = (currentOptions, gradientsSettings) => ({
362
+ ...currentOptions,
363
+ notLibraryOptions: {
364
+ ...currentOptions.notLibraryOptions,
365
+ changeData: {
366
+ ...currentOptions.notLibraryOptions?.changeData,
367
+ addGradientsObjects: gradientsSettings
368
+ }
369
+ }
370
+ });
371
+ var addTooltipOptions = (currentOptions, tooltipOptions) => ({
372
+ ...currentOptions,
373
+ options: {
374
+ ...currentOptions.options,
375
+ plugins: {
376
+ ...currentOptions.options.plugins,
377
+ tooltip: tooltipOptions
378
+ }
379
+ }
380
+ });
381
+ var addAdditionalOptions = (currentOptions, optionsToAdd) => {
382
+ const addOption = (currentOptions2, optionKey, optionData) => {
383
+ switch (optionKey) {
384
+ case "addGradientsSettings":
385
+ return addGradientsSettings(currentOptions2, optionData);
386
+ case "addTooltipOptions":
387
+ return addTooltipOptions(currentOptions2, optionData);
388
+ default:
389
+ return currentOptions2;
390
+ }
391
+ };
392
+ const iterator = Object.keys(optionsToAdd);
393
+ return iterator.reduce(
394
+ (acc, key) => addOption(acc, key, optionsToAdd[key]),
395
+ currentOptions
396
+ );
397
+ };
398
+ var optionsSetters_default = addAdditionalOptions;
399
+
400
+ // src/Atomic/UI/Chart/partial/optionsConstructor.js
401
+ var reactChartJsOptionsLayouts = {
402
+ lineIconLayout: {
403
+ options: {
404
+ responsive: true,
405
+ maintainAspectRatio: false,
406
+ scales: {
407
+ x: { display: false },
408
+ y: { display: false }
409
+ },
410
+ elements: {
411
+ point: { radius: 0 },
412
+ line: {
413
+ tension: 0.45,
414
+ borderJoinStyle: "round",
415
+ borderWidth: 2,
416
+ capBezierPoints: true
417
+ }
418
+ }
419
+ },
420
+ redraw: true,
421
+ notLibraryOptions: {
422
+ // Этот ключ должен быть в любой итоговой конфигурации для нормальной работы компонента именно в такой вложенности
423
+ // На основании этого ключа будет приниматься решение какой компонет будет использован (<Line />, <Bar /> и т.д.)
424
+ // => Файл Chart.js => определение ChartComponent
425
+ chartTypeKey: "Line",
426
+ setCanvasDimensions: {
427
+ width: "75px",
428
+ height: "35px"
429
+ }
430
+ }
431
+ },
432
+ lineLayout: {
433
+ options: {
434
+ responsive: true,
435
+ elements: {
436
+ point: {
437
+ radius: 4,
438
+ pointStyle: "circle",
439
+ backgroundColor: "#FFFFFF",
440
+ color: "#FFFFFF"
441
+ },
442
+ line: {
443
+ tension: 0.45,
444
+ borderJoinStyle: "round",
445
+ borderWidth: 2,
446
+ capBezierPoints: true
447
+ }
448
+ }
449
+ },
450
+ redraw: true,
451
+ notLibraryOptions: {
452
+ // Этот ключ должен быть в любой итоговой конфигурации для нормальной работы компонента именно в такой вложенности
453
+ // На основании этого ключа будет приниматься решение какой компонет будет использован (<Line />, <Bar /> и т.д.)
454
+ // => Файл Chart.js => определение ChartComponent
455
+ chartTypeKey: "Line"
456
+ }
457
+ },
458
+ barLayout: {
459
+ options: {
460
+ responsive: true,
461
+ elements: {
462
+ bar: {
463
+ borderRadius: 10
464
+ }
465
+ }
466
+ },
467
+ redraw: true,
468
+ notLibraryOptions: {
469
+ // Этот ключ должен быть в любой итоговой конфигурации для нормальной работы компонента именно в такой вложенности
470
+ // На основании этого ключа будет приниматься решение какой компонет будет использован (<Line />, <Bar /> и т.д.)
471
+ // => Файл Chart.js => определение ChartComponent
472
+ chartTypeKey: "Bar"
473
+ }
474
+ },
475
+ emptyLayout: {
476
+ options: {
477
+ responsive: true,
478
+ maintainAspectRatio: false,
479
+ scales: {
480
+ x: { display: false },
481
+ y: { display: false }
482
+ },
483
+ elements: {
484
+ point: { radius: 0 },
485
+ line: { borderWidth: 0 }
486
+ }
487
+ },
488
+ notLibraryOptions: {
489
+ // Этот ключ должен быть в любой итоговой конфигурации для нормальной работы компонента именно в такой вложенности
490
+ // На основании этого ключа будет приниматься решение какой компонет будет использован (<Line />, <Bar /> и т.д.)
491
+ // => Файл Chart.js => определение подкомпонента ChartComponent => строка const Component = ...
492
+ chartTypeKey: "Line"
493
+ }
494
+ }
495
+ };
496
+ var finturfChartLayouts = (() => {
497
+ return ["barLayout", "lineLayout"].reduce(
498
+ (acc, key) => ({
499
+ ...acc,
500
+ [key]: {
501
+ ...reactChartJsOptionsLayouts[key],
502
+ options: {
503
+ ...reactChartJsOptionsLayouts[key].options,
504
+ scales: {
505
+ ...reactChartJsOptionsLayouts[key].options?.scales,
506
+ x: {
507
+ ...reactChartJsOptionsLayouts[key].options?.scales?.x,
508
+ grid: {
509
+ ...reactChartJsOptionsLayouts[key].options?.scales?.x?.grid,
510
+ display: false,
511
+ offset: true
512
+ },
513
+ ticks: {
514
+ ...reactChartJsOptionsLayouts[key].options?.scales?.y?.ticks,
515
+ autoSkipPadding: 10,
516
+ align: "center",
517
+ color: "#757F8C",
518
+ lineHeight: 18,
519
+ font: {
520
+ family: "Sarabun",
521
+ style: "normal",
522
+ weight: 400,
523
+ size: 8
524
+ }
525
+ // callback: (value, index, ticks) => {
526
+ // console.log(value);
527
+ // console.log(index);
528
+ // console.log(ticks);
529
+ // console.log('***********');
530
+ // return value;
531
+ // },
532
+ }
533
+ },
534
+ y: {
535
+ ...reactChartJsOptionsLayouts[key].options?.scales?.y,
536
+ min: 0,
537
+ // grace: '5%',
538
+ bounds: "data",
539
+ grid: {
540
+ ...reactChartJsOptionsLayouts[key].options?.scales?.y?.grid,
541
+ borderColor: "#E1E8F1",
542
+ color: "#E1E8F1",
543
+ borderDash: [5],
544
+ // borderDashOffset: 12,
545
+ drawTicks: false,
546
+ z: -1
547
+ },
548
+ ticks: {
549
+ ...reactChartJsOptionsLayouts[key].options?.scales?.y?.ticks,
550
+ autoSkipPadding: 10,
551
+ align: "center",
552
+ color: "#A0A4B0",
553
+ lineHeight: 18,
554
+ padding: 6,
555
+ font: {
556
+ family: "Sarabun",
557
+ style: "normal",
558
+ weight: 400,
559
+ size: 10
560
+ }
561
+ }
562
+ }
563
+ }
564
+ },
565
+ notLibraryOptions: {
566
+ ...reactChartJsOptionsLayouts[key].notLibraryOptions,
567
+ setCanvasDimensions: {
568
+ height: "194px"
569
+ }
570
+ }
571
+ }
572
+ }),
573
+ {}
574
+ );
575
+ })();
576
+ var finturfChartBar = {
577
+ ...finturfChartLayouts.barLayout,
578
+ options: {
579
+ ...finturfChartLayouts.barLayout?.options,
580
+ maintainAspectRatio: false,
581
+ elements: {
582
+ ...finturfChartLayouts.barLayout?.options?.elements,
583
+ bar: {
584
+ ...finturfChartLayouts.barLayout?.options?.elements?.bar,
585
+ borderRadius: 4
586
+ }
587
+ }
588
+ },
589
+ notLibraryOptions: {
590
+ ...finturfChartLayouts.barLayout?.notLibraryOptions,
591
+ changeData: {
592
+ ...finturfChartLayouts.barLayout?.notLibraryOptions?.changeData,
593
+ setMaxBarThickness: 16
594
+ }
595
+ }
596
+ };
597
+ var finturfChartLine = {
598
+ ...finturfChartLayouts.lineLayout,
599
+ options: {
600
+ ...finturfChartLayouts.lineLayout?.options,
601
+ maintainAspectRatio: false,
602
+ elements: {
603
+ ...finturfChartLayouts.lineLayout.options?.elements,
604
+ point: {
605
+ ...finturfChartLayouts.lineLayout.options?.elements?.point,
606
+ radius: 2,
607
+ borderColor: "#32A784",
608
+ borderWidth: 4
609
+ }
610
+ }
611
+ }
612
+ };
613
+ var finturfReactChartJsOptions = {
614
+ finturfChartBar: optionsSetters_default(finturfChartBar, {
615
+ addGradientsSettings: GRADIENTS_OBJECTS.finturf.bar,
616
+ addTooltipOptions: FINTURF_TOOLTIP_OPTIONS
617
+ }),
618
+ finturfLoadingModeBar: {
619
+ ...finturfChartBar,
620
+ options: {
621
+ ...finturfChartBar.options,
622
+ animations: {
623
+ ...finturfChartBar.options?.animations,
624
+ y: {
625
+ ...finturfChartBar.options?.animations?.y,
626
+ duration: 0
627
+ }
628
+ }
629
+ },
630
+ notLibraryOptions: {
631
+ ...finturfChartBar.notLibraryOptions,
632
+ changeData: {
633
+ ...finturfChartBar.notLibraryOptions?.changeData,
634
+ addNotLibraryAnimations: [
635
+ {
636
+ type: "runningColumns",
637
+ // duration - ms
638
+ duration: 600,
639
+ // default easing - 'linear',
640
+ // easing: 'easeInOutExpo',
641
+ // ToDo - предусмотреть 'auto' и default для from и to
642
+ from: 10,
643
+ to: 75,
644
+ columnsDelayCoef: 500
645
+ }
646
+ ]
647
+ }
648
+ }
649
+ },
650
+ finturfChartLine: optionsSetters_default(finturfChartLine, {
651
+ addGradientsSettings: GRADIENTS_OBJECTS.finturf.line,
652
+ addTooltipOptions: FINTURF_TOOLTIP_OPTIONS
653
+ // consoleCurrentData: true,
654
+ }),
655
+ finturfLoadingModeLine: {
656
+ ...finturfChartLine,
657
+ options: {
658
+ ...finturfChartLine.options,
659
+ elements: {
660
+ ...finturfChartLine.options?.elements,
661
+ point: {
662
+ ...finturfChartLine.options?.elements?.point,
663
+ radius: 4,
664
+ borderWidth: 1,
665
+ borderColor: "#E1E8F1"
666
+ }
667
+ },
668
+ animations: {
669
+ ...finturfChartLine.options?.animations,
670
+ y: {
671
+ ...finturfChartLine.options?.animations?.y,
672
+ duration: 0
673
+ }
674
+ }
675
+ },
676
+ notLibraryOptions: {
677
+ ...finturfChartLine.notLibraryOptions,
678
+ changeData: {
679
+ ...finturfChartLine.notLibraryOptions?.changeData,
680
+ addNotLibraryAnimations: [
681
+ {
682
+ type: "runningColumns",
683
+ // duration - ms
684
+ duration: 600,
685
+ // default easing - 'linear',
686
+ // easing: 'easeInOutExpo',
687
+ columnsDelayCoef: 500,
688
+ isFixExtremeColumns: true
689
+ }
690
+ ]
691
+ }
692
+ }
693
+ },
694
+ finturfPositiveLineIcon: optionsSetters_default(
695
+ reactChartJsOptionsLayouts.lineIconLayout,
696
+ {
697
+ addGradientsSettings: GRADIENTS_OBJECTS.finturf.positiveLineIcon
698
+ }
699
+ ),
700
+ finturfNegativeLineIcon: optionsSetters_default(
701
+ reactChartJsOptionsLayouts.lineIconLayout,
702
+ {
703
+ addGradientsSettings: GRADIENTS_OBJECTS.finturf.negativeLineIcon
704
+ }
705
+ )
706
+ };
707
+ var optionsConstructor_default = {
708
+ ...finturfReactChartJsOptions,
709
+ emptyLayout: reactChartJsOptionsLayouts.emptyLayout
710
+ };
711
+
712
+ // src/Atomic/UI/Chart/partial/utils.ts
713
+ function getChartTypeKey(model) {
714
+ return optionsConstructor_default[model]?.notLibraryOptions?.chartTypeKey;
715
+ }
716
+ function correctModelKey(model) {
717
+ if (!model) return DEFAULT_CHART_MODEL;
718
+ const options = optionsConstructor_default[model];
719
+ if (!options) return DEFAULT_CHART_MODEL;
720
+ const chartTypeKey = getChartTypeKey(model);
721
+ return chartTypeKey && CHART_TYPES.includes(chartTypeKey) ? model : DEFAULT_CHART_MODEL;
722
+ }
723
+ function getOptions(model) {
724
+ const modelOptions = optionsConstructor_default[model] || optionsConstructor_default[DEFAULT_CHART_MODEL];
725
+ return omitKeys(modelOptions, ["notLibraryOptions"]);
726
+ }
727
+ function getNotLibraryOptionsOptions(model) {
728
+ const modelOptions = optionsConstructor_default[model] || optionsConstructor_default[DEFAULT_CHART_MODEL];
729
+ const { notLibraryOptions } = modelOptions || {};
730
+ return notLibraryOptions ? clone(notLibraryOptions) : void 0;
731
+ }
732
+ function prepareData(model, data, chartInstance, addToDatasets) {
733
+ if (!chartInstance) return data;
734
+ const notLibraryOptions = getNotLibraryOptionsOptions(model);
735
+ const iterator = notLibraryOptions?.changeData ? Object.keys(notLibraryOptions.changeData) : [];
736
+ const changedData = iterator.reduce(
737
+ (acc, dataChangeKey) => datasetSetters_default(
738
+ acc,
739
+ dataChangeKey,
740
+ notLibraryOptions.changeData[dataChangeKey],
741
+ chartInstance
742
+ ),
743
+ clone(data)
744
+ );
745
+ return addToDatasets && typeof addToDatasets === "object" && !Array.isArray(addToDatasets) ? {
746
+ ...changedData,
747
+ datasets: changedData.datasets.map((dataset) => ({
748
+ ...dataset,
749
+ ...addToDatasets
750
+ }))
751
+ } : changedData;
752
+ }
753
+
754
+ // src/Atomic/UI/Chart/Chart.tsx
755
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
756
+ var RC2 = "chart";
757
+ ChartJS.register(
758
+ CategoryScale,
759
+ LinearScale,
760
+ BarElement,
761
+ PointElement,
762
+ LineElement,
763
+ Filler,
764
+ Tooltip
765
+ );
766
+ var Chart = ({
767
+ className,
768
+ initialModel,
769
+ modelsForSwitch,
770
+ setModelExternalValue,
771
+ description,
772
+ customOptions,
773
+ data,
774
+ addToDatasets,
775
+ modifyOptions
776
+ }) => {
777
+ const { label, value } = description || {};
778
+ const [model, setModel] = useState(DEFAULT_CHART_MODEL);
779
+ const [localData, setLocalData] = useState();
780
+ const chartRef = useRef(null);
781
+ const charContainertRef = useRef(null);
782
+ const options = useMemo(
783
+ () => customOptions || (modifyOptions ? modifyOptions(getOptions(model)) : getOptions(model)),
784
+ [customOptions, model, modifyOptions?.toString?.(), data]
785
+ );
786
+ const notLibraryOptionsOptions = useMemo(
787
+ () => customOptions ? customOptions?.notLibraryOptions : getNotLibraryOptionsOptions(model),
788
+ [customOptions, model, data]
789
+ );
790
+ const ChartComponent = useCallback(
791
+ (props) => {
792
+ const chartType = getChartTypeKey(model);
793
+ const Component = ChartComponents[chartType];
794
+ return React.createElement(Component, { ...props, ref: chartRef });
795
+ },
796
+ [model]
797
+ );
798
+ const isExcludeDescription = COMPONENT_OPTIONS.disableDescriptionsFor.includes(model);
799
+ const isExcludeChartTypeSwitcher = COMPONENT_OPTIONS.disableChartTypeSwitcherFor.includes(model);
800
+ useLayoutEffect(() => {
801
+ if (setModelExternalValue && model !== "emptyLayout")
802
+ setModelExternalValue(model);
803
+ }, [model]);
804
+ useLayoutEffect(() => {
805
+ const { setCanvasDimensions } = notLibraryOptionsOptions || {};
806
+ if (charContainertRef.current) {
807
+ charContainertRef.current.style.width = setCanvasDimensions?.width ?? "";
808
+ charContainertRef.current.style.height = setCanvasDimensions?.height ?? "";
809
+ }
810
+ }, [notLibraryOptionsOptions]);
811
+ useEffect2(() => {
812
+ setModel(correctModelKey(initialModel));
813
+ }, [initialModel]);
814
+ useEffect2(() => {
815
+ if (data) {
816
+ setLocalData(
817
+ prepareData(model, clone(data), chartRef.current, addToDatasets)
818
+ );
819
+ }
820
+ }, [model, data]);
821
+ if (!data || !localData) return null;
822
+ return /* @__PURE__ */ jsxs2(
823
+ "div",
824
+ {
825
+ className: cn2(
826
+ RC2,
827
+ { [`${RC2}_icon-mode`]: ICON_MODELS.includes(model) },
828
+ className
829
+ ),
830
+ children: [
831
+ /* @__PURE__ */ jsxs2(
832
+ "div",
833
+ {
834
+ className: cn2(`${RC2}__header`, {
835
+ [`${RC2}__header_only-switcher`]: !description
836
+ }),
837
+ children: [
838
+ description && !isExcludeDescription ? /* @__PURE__ */ jsxs2("div", { className: cn2(`${RC2}__description`), children: [
839
+ label ? /* @__PURE__ */ jsx2("span", { className: cn2(`${RC2}__description-title`), children: label }) : null,
840
+ value ? /* @__PURE__ */ jsx2("div", { className: cn2(`${RC2}__description-value`), children: value }) : null
841
+ ] }) : null,
842
+ !isExcludeChartTypeSwitcher ? /* @__PURE__ */ jsxs2("div", { className: cn2(`${RC2}__type-switcher`), children: [
843
+ /* @__PURE__ */ jsx2(
844
+ ChartTypeSwitcherIcon_default,
845
+ {
846
+ iconType: "Bar",
847
+ isActive: getChartTypeKey(model) === "Bar",
848
+ onClick: () => setModel(modelsForSwitch?.[0] || "barLayout")
849
+ }
850
+ ),
851
+ /* @__PURE__ */ jsx2(
852
+ ChartTypeSwitcherIcon_default,
853
+ {
854
+ iconType: "Line",
855
+ isActive: getChartTypeKey(model) === "Line",
856
+ onClick: () => setModel(modelsForSwitch?.[1] || "lineLayout")
857
+ }
858
+ )
859
+ ] }) : null
860
+ ]
861
+ }
862
+ ),
863
+ /* @__PURE__ */ jsx2("div", { ref: charContainertRef, className: cn2(`${RC2}__chart-wrapper`), children: /* @__PURE__ */ jsx2(ChartComponent, { ...options, data: localData }) })
864
+ ]
865
+ }
866
+ );
867
+ };
868
+ var Chart_default = Chart;
869
+
870
+ // src/Atomic/UI/Chart/index.ts
871
+ var Chart_default2 = Chart_default;
872
+
873
+ // src/Atomic/UI/PieChart/PieChart.js
874
+ import React2 from "react";
875
+ import { ArcElement, Chart as ChartJS2, Tooltip as Tooltip2 } from "chart.js";
876
+ import { Pie } from "react-chartjs-2";
877
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
878
+ ChartJS2.register(ArcElement, Tooltip2);
879
+ var PieChart = ({
880
+ data,
881
+ cutout = "80%",
882
+ resultLabel,
883
+ resultValue = 0,
884
+ withLegend = false
885
+ }) => {
886
+ const options = {
887
+ cutout,
888
+ plugins: {
889
+ legend: {
890
+ display: withLegend
891
+ }
892
+ }
893
+ };
894
+ return /* @__PURE__ */ jsxs3("div", { className: "pie-chart-box", style: { maxWidth: `320px` }, children: [
895
+ /* @__PURE__ */ jsx3(Pie, { data, options }),
896
+ Boolean(resultLabel) && /* @__PURE__ */ jsxs3("div", { className: "pie-chart__result", children: [
897
+ /* @__PURE__ */ jsxs3("div", { className: "pie-chart__result-value", children: [
898
+ resultValue,
899
+ /* @__PURE__ */ jsx3("span", { className: "pie-chart__result-percent", children: "%" }),
900
+ " "
901
+ ] }),
902
+ /* @__PURE__ */ jsx3("div", { className: "pie-chart__result-label", children: resultLabel })
903
+ ] })
904
+ ] });
905
+ };
906
+ var PieChart_default = PieChart;
907
+ export {
908
+ Chart_default2 as Chart,
909
+ PieChart_default as PieChart
910
+ };
911
+ //# sourceMappingURL=charts.js.map