@connectif/ui-components 1.0.8 → 1.0.10

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,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import './EchartsConfig';
3
+ import { sizes } from '../../theme/Typography';
3
4
  import { IncrementLabelType } from '../../propTypes/IncrementLabel';
4
5
  import { ChartTooltipEntryFormatter } from '../../utils/ChartUtils';
5
6
  type YAxisLabelFormatter = (value: number) => string;
@@ -13,6 +14,18 @@ export type BarChartProps = {
13
14
  * The categories to display on the x axis.
14
15
  */
15
16
  categories: string[];
17
+ /**
18
+ * labels color
19
+ */
20
+ labelColor?: string;
21
+ /**
22
+ * font size to X labels
23
+ */
24
+ gridLabelSize?: keyof typeof sizes;
25
+ /**
26
+ * Grid lines color
27
+ */
28
+ gridLineColor?: string;
16
29
  /**
17
30
  * Optional callback to be called when the chart is clicked.
18
31
  */
@@ -49,6 +62,10 @@ export type BarChartProps = {
49
62
  * The text to use for this item as name in tooltip.
50
63
  */
51
64
  comparisonTooltipName?: string;
65
+ /**
66
+ * Set to show background color in bar when not is comparison
67
+ */
68
+ showBackgroundColorBar?: boolean;
52
69
  data: {
53
70
  /**
54
71
  * The value to display in the chart for this serie item.
@@ -80,5 +97,5 @@ export type BarChartProps = {
80
97
  /**
81
98
  * A bar chart component to display numeric data grouped by categories and series.
82
99
  */
83
- declare const BarChart: ({ style, isLoading, series, categories, yAxisLabelFormatter, tooltipEntryFormatter, onClick }: BarChartProps) => import("react/jsx-runtime").JSX.Element;
100
+ declare const BarChart: ({ style, isLoading, series, categories, labelColor, gridLineColor, gridLabelSize, yAxisLabelFormatter, tooltipEntryFormatter, onClick }: BarChartProps) => import("react/jsx-runtime").JSX.Element;
84
101
  export default BarChart;
@@ -59,6 +59,24 @@ export type LineChartProps = CategorizedChartProps & {
59
59
  * The yAxis for this serie
60
60
  */
61
61
  yAxisIndex: number;
62
+ /**
63
+ * The area color. With color will be a solid color. With startColor and endColor will be gradient color.
64
+ */
65
+ areaColor?: {
66
+ color: string;
67
+ startColor?: never;
68
+ endColor?: never;
69
+ } | {
70
+ color?: never;
71
+ startColor: {
72
+ offset: number;
73
+ color: string;
74
+ };
75
+ endColor: {
76
+ offset: number;
77
+ color: string;
78
+ };
79
+ };
62
80
  }[];
63
81
  /**
64
82
  * Option to disable the display of series names.
@@ -88,10 +106,14 @@ export type LineChartProps = CategorizedChartProps & {
88
106
  * Option to set the position of the Y axis when there is only one.
89
107
  */
90
108
  yAxisPosition?: 'left' | 'right';
109
+ /**
110
+ * Margin to add between labels and x axis. It will be in px
111
+ */
112
+ xAxisMargin?: number;
91
113
  };
92
114
  /**
93
115
  * A line chart component to display numeric data grouped by categories and series.
94
116
  * Commonly, categories use to be sorted dates.
95
117
  */
96
- declare const LineChart: ({ style, isLoading, series, categories, yAxisLabelFormatter, ySecondaryAxisLabelFormatter, onClick, disableSeriesNames, disableAxes, disableSplitLine, fullGrid, axisFontSize, axisFontColor, yAxisPosition }: LineChartProps) => import("react/jsx-runtime").JSX.Element;
118
+ declare const LineChart: ({ style, isLoading, series, categories, yAxisLabelFormatter, ySecondaryAxisLabelFormatter, onClick, disableSeriesNames, disableAxes, disableSplitLine, fullGrid, axisFontSize, axisFontColor, yAxisPosition, xAxisMargin }: LineChartProps) => import("react/jsx-runtime").JSX.Element;
97
119
  export default LineChart;
@@ -8,10 +8,14 @@ export type ChatProps = React.PropsWithChildren<{
8
8
  * Background color
9
9
  */
10
10
  backgroundColor?: string;
11
+ /**
12
+ * Class name to move scroll on new message. If undefined, scroll to bottom.
13
+ */
14
+ scrollToLastClassName?: string;
15
+ /**
16
+ * Scrollbar color
17
+ */
18
+ scrollbarColor?: string;
11
19
  }>;
12
- /**
13
- * Shows a list of chat message, in a vertical layout.
14
- *
15
- */
16
- declare const Chat: ({ children, header, backgroundColor }: ChatProps) => import("react/jsx-runtime").JSX.Element;
20
+ declare const Chat: ({ children, header, backgroundColor, scrollToLastClassName, scrollbarColor }: ChatProps) => import("react/jsx-runtime").JSX.Element;
17
21
  export default Chat;
package/dist/index.js CHANGED
@@ -7767,7 +7767,7 @@ function createBox(options = {}) {
7767
7767
  const BoxRoot = styled2("div", {
7768
7768
  shouldForwardProp: (prop) => prop !== "theme" && prop !== "sx" && prop !== "as"
7769
7769
  })(styleFunctionSx_default);
7770
- const Box8 = /* @__PURE__ */ React16.forwardRef(function Box9(inProps, ref) {
7770
+ const Box7 = /* @__PURE__ */ React16.forwardRef(function Box8(inProps, ref) {
7771
7771
  const theme2 = useTheme_default(defaultTheme);
7772
7772
  const _extendSxProp = extendSxProp(inProps), {
7773
7773
  className,
@@ -7780,7 +7780,7 @@ function createBox(options = {}) {
7780
7780
  theme: themeId ? theme2[themeId] || theme2 : theme2
7781
7781
  }, other));
7782
7782
  });
7783
- return Box8;
7783
+ return Box7;
7784
7784
  }
7785
7785
 
7786
7786
  // node_modules/@mui/utils/esm/generateUtilityClass/generateUtilityClass.js
@@ -11557,6 +11557,9 @@ var BarChart2 = ({
11557
11557
  isLoading,
11558
11558
  series = [],
11559
11559
  categories = [],
11560
+ labelColor = grey400,
11561
+ gridLineColor = grey200,
11562
+ gridLabelSize = "sm",
11560
11563
  yAxisLabelFormatter = (value) => `${value}`,
11561
11564
  tooltipEntryFormatter = ({ data }) => ({
11562
11565
  text: `${data.tooltipName}: ${data.tooltipValue}`
@@ -11690,8 +11693,8 @@ var BarChart2 = ({
11690
11693
  show: false
11691
11694
  },
11692
11695
  axisLabel: {
11693
- color: grey400,
11694
- fontSize: sizes3.sm,
11696
+ color: labelColor,
11697
+ fontSize: sizes3[gridLabelSize],
11695
11698
  width: (width2 - estimatedYAxisWidth) / categories.length,
11696
11699
  overflow: "truncate",
11697
11700
  hideOverlap: false,
@@ -11703,7 +11706,7 @@ var BarChart2 = ({
11703
11706
  boundaryGap: ["0", "10%"],
11704
11707
  splitLine: {
11705
11708
  lineStyle: {
11706
- color: grey200
11709
+ color: gridLineColor
11707
11710
  }
11708
11711
  },
11709
11712
  axisLine: {
@@ -11713,8 +11716,8 @@ var BarChart2 = ({
11713
11716
  show: false
11714
11717
  },
11715
11718
  axisLabel: {
11716
- color: grey400,
11717
- fontSize: sizes3.sm,
11719
+ color: labelColor,
11720
+ fontSize: sizes3[gridLabelSize],
11718
11721
  formatter: yAxisLabelFormatter
11719
11722
  }
11720
11723
  },
@@ -11724,14 +11727,15 @@ var BarChart2 = ({
11724
11727
  data,
11725
11728
  tooltipName,
11726
11729
  comparisonColor,
11727
- comparisonTooltipName
11730
+ comparisonTooltipName,
11731
+ showBackgroundColorBar
11728
11732
  }, serieIndex) => [
11729
11733
  ...isComparison ? [
11730
11734
  {
11731
11735
  ...defaultBarSeriesOptions,
11732
11736
  cursor,
11733
11737
  silent,
11734
- showBackground: false,
11738
+ showBackground: showBackgroundColorBar ?? false,
11735
11739
  stack: `${serieIndex}`,
11736
11740
  data: data.map(
11737
11741
  ({
@@ -11763,7 +11767,7 @@ var BarChart2 = ({
11763
11767
  ...defaultBarSeriesOptions,
11764
11768
  cursor,
11765
11769
  silent,
11766
- showBackground: true,
11770
+ showBackground: showBackgroundColorBar ?? true,
11767
11771
  stack: `${serieIndex}`,
11768
11772
  data: data.map(
11769
11773
  ({
@@ -11838,7 +11842,8 @@ var LineChart2 = ({
11838
11842
  fullGrid = false,
11839
11843
  axisFontSize = "11px",
11840
11844
  axisFontColor = grey400,
11841
- yAxisPosition = "right"
11845
+ yAxisPosition = "right",
11846
+ xAxisMargin
11842
11847
  }) => {
11843
11848
  const theme2 = useTheme3();
11844
11849
  const cursor = onClick ? "pointer" : "default";
@@ -12016,6 +12021,7 @@ var LineChart2 = ({
12016
12021
  show: false
12017
12022
  },
12018
12023
  axisLabel: {
12024
+ ...xAxisMargin && { margin: xAxisMargin },
12019
12025
  color: axisFontColor,
12020
12026
  fontSize: axisFontSize,
12021
12027
  show: true,
@@ -12057,7 +12063,13 @@ var LineChart2 = ({
12057
12063
  ],
12058
12064
  series: [
12059
12065
  ...series.map(
12060
- ({ name, data, color: color2, yAxisIndex }) => ({
12066
+ ({
12067
+ name,
12068
+ data,
12069
+ color: color2,
12070
+ yAxisIndex,
12071
+ areaColor
12072
+ }) => ({
12061
12073
  type: "line",
12062
12074
  name,
12063
12075
  yAxisIndex,
@@ -12069,6 +12081,30 @@ var LineChart2 = ({
12069
12081
  type: "solid",
12070
12082
  width: 3
12071
12083
  },
12084
+ ...areaColor && {
12085
+ areaStyle: {
12086
+ ...areaColor.color && { color: areaColor.color },
12087
+ ...areaColor.startColor && areaColor.endColor && {
12088
+ color: new echarts3.graphic.LinearGradient(
12089
+ 0,
12090
+ 0,
12091
+ 0,
12092
+ 1,
12093
+ [
12094
+ {
12095
+ offset: areaColor.startColor.offset,
12096
+ color: areaColor.startColor.color
12097
+ },
12098
+ {
12099
+ offset: areaColor.endColor.offset,
12100
+ color: areaColor.endColor.color
12101
+ },
12102
+ { offset: 1, color: "transparent" }
12103
+ ]
12104
+ )
12105
+ }
12106
+ }
12107
+ },
12072
12108
  showSymbol: true,
12073
12109
  symbol: "circle",
12074
12110
  symbolSize: 3,
@@ -13328,9 +13364,10 @@ var ChatMessage = React34.forwardRef(function ChatMessage2({
13328
13364
  padding: "8px 16px",
13329
13365
  paddingBottom: !cancelableButtonText ? "8px" : "40px",
13330
13366
  marginLeft: 0,
13331
- marginRight: "10px",
13367
+ marginRight: "0",
13332
13368
  minHeight: "22px",
13333
- justifyContent: "center"
13369
+ justifyContent: "center",
13370
+ wordBreak: "break-all"
13334
13371
  },
13335
13372
  children: [
13336
13373
  /* @__PURE__ */ jsx79(
@@ -13420,55 +13457,99 @@ var ChatMessage = React34.forwardRef(function ChatMessage2({
13420
13457
  var ChatMessage_default = ChatMessage;
13421
13458
 
13422
13459
  // src/components/chat/Chat.tsx
13423
- import Box3 from "@mui/material/Box";
13424
13460
  import Stack5 from "@mui/material/Stack";
13425
13461
  import * as React35 from "react";
13426
13462
  import { jsx as jsx80, jsxs as jsxs35 } from "react/jsx-runtime";
13427
- var Chat = ({ children, header, backgroundColor: backgroundColor2 }) => {
13428
- let ref = void 0;
13429
- const [justifyContent, setJustifyContent] = React35.useState(true);
13463
+ var Chat = ({
13464
+ children,
13465
+ header,
13466
+ backgroundColor: backgroundColor2,
13467
+ scrollToLastClassName,
13468
+ scrollbarColor
13469
+ }) => {
13470
+ const ref = React35.useRef(null);
13430
13471
  const [isInitialize, setIsInitialize] = React35.useState(false);
13472
+ const [hasVerticalScroll, setHasVerticalScroll] = React35.useState(false);
13431
13473
  React35.useEffect(() => {
13432
- if (ref && ref.offsetHeight <= ref.scrollHeight) {
13433
- setJustifyContent(ref.offsetHeight >= ref.scrollHeight);
13474
+ const container = ref.current;
13475
+ if (!container) {
13476
+ return;
13434
13477
  }
13435
- ref?.scrollTo(0, ref?.scrollHeight);
13478
+ const observer = new ResizeObserver(() => {
13479
+ requestAnimationFrame(() => {
13480
+ const needsScroll = container.scrollHeight > container.clientHeight;
13481
+ setHasVerticalScroll(needsScroll);
13482
+ });
13483
+ });
13484
+ observer.observe(container);
13436
13485
  setIsInitialize(true);
13437
- }, [children, ref]);
13486
+ return () => observer.disconnect();
13487
+ }, []);
13438
13488
  React35.useEffect(() => {
13439
- if (ref && ref.offsetHeight < ref.scrollHeight) {
13440
- setJustifyContent(false);
13489
+ const container = ref.current;
13490
+ if (!container) {
13491
+ return;
13492
+ }
13493
+ if (scrollToLastClassName) {
13494
+ const elements = container.querySelectorAll(
13495
+ `.${scrollToLastClassName}`
13496
+ );
13497
+ const last = elements[elements.length - 1];
13498
+ if (last) {
13499
+ last.scrollIntoView({ behavior: "smooth", block: "start" });
13500
+ } else {
13501
+ container.scrollTo(0, container.scrollHeight);
13502
+ }
13503
+ } else {
13504
+ container.scrollTo(0, container.scrollHeight);
13441
13505
  }
13442
- ref?.scrollTo(0, ref?.scrollHeight);
13443
- }, [ref]);
13506
+ }, [children, scrollToLastClassName]);
13444
13507
  return /* @__PURE__ */ jsxs35(
13445
13508
  Stack5,
13446
13509
  {
13447
13510
  className: "Slim-Vertical-Scroll",
13511
+ ref,
13448
13512
  sx: {
13449
13513
  overflow: "hidden",
13450
13514
  overflowY: "auto",
13451
13515
  height: "calc(100% - 8px)",
13452
- visibility: !isInitialize ? "hidden" : null,
13516
+ visibility: !isInitialize ? "hidden" : "visible",
13517
+ width: `calc(100% - ${hasVerticalScroll ? "4px" : "8px"})`,
13453
13518
  paddingBottom: "8px",
13454
- ...isInitialize && justifyContent && {
13455
- justifyContent: header ? "space-between" : "end"
13456
- },
13457
- ":active::-webkit-scrollbar-thumb, :focus::-webkit-scrollbar-thumb, :hover::-webkit-scrollbar-thumb": {
13458
- visibility: "visible"
13519
+ ...backgroundColor2 && { backgroundColor: backgroundColor2 },
13520
+ paddingRight: hasVerticalScroll ? "4px" : "8px",
13521
+ "::-webkit-scrollbar": {
13522
+ width: "4px !important"
13459
13523
  },
13460
13524
  "::-webkit-scrollbar-thumb": {
13525
+ ...scrollbarColor && {
13526
+ backgroundColor: `${scrollbarColor} !important`
13527
+ },
13528
+ borderRadius: "4px",
13461
13529
  visibility: "hidden"
13462
13530
  },
13463
- ...backgroundColor2 && {
13464
- backgroundColor: backgroundColor2
13531
+ ":hover::-webkit-scrollbar-thumb": {
13532
+ visibility: "visible"
13465
13533
  }
13466
13534
  },
13467
13535
  spacing: "12px",
13468
- ref: (el) => ref = el,
13469
13536
  children: [
13470
13537
  header,
13471
- /* @__PURE__ */ jsx80(Box3, { sx: { "> *": { marginTop: "12px" } }, children })
13538
+ /* @__PURE__ */ jsx80(
13539
+ Stack5,
13540
+ {
13541
+ justifyContent: "end",
13542
+ ...!header && {
13543
+ minHeight: "100%",
13544
+ justifyContent: "end"
13545
+ },
13546
+ sx: {
13547
+ "> *": { marginTop: "12px" },
13548
+ flexShrink: 0
13549
+ },
13550
+ children
13551
+ }
13552
+ )
13472
13553
  ]
13473
13554
  }
13474
13555
  );
@@ -17549,9 +17630,9 @@ var ImageEditor_default = ImageEditor;
17549
17630
  import React45 from "react";
17550
17631
 
17551
17632
  // src/hooks/useResizeObserver.ts
17552
- import { useEffect as useEffect8, useState as useState13, useRef as useRef11 } from "react";
17633
+ import { useEffect as useEffect8, useState as useState13, useRef as useRef12 } from "react";
17553
17634
  function useResizeObserver() {
17554
- const ref = useRef11(null);
17635
+ const ref = useRef12(null);
17555
17636
  const [width2, setWidth] = useState13(0);
17556
17637
  const [height2, setHeight] = useState13(0);
17557
17638
  const [contentWidth, setContentWidth] = useState13(0);
@@ -17729,10 +17810,10 @@ var TextFieldContainer_default = TextFieldContainer;
17729
17810
  import * as React50 from "react";
17730
17811
 
17731
17812
  // src/hooks/useDebouncedCallback.ts
17732
- import { useEffect as useEffect9, useRef as useRef12 } from "react";
17813
+ import { useEffect as useEffect9, useRef as useRef13 } from "react";
17733
17814
  function useDebouncedCallback(callback, wait) {
17734
- const argsRef = useRef12();
17735
- const timeout = useRef12();
17815
+ const argsRef = useRef13();
17816
+ const timeout = useRef13();
17736
17817
  function cleanup() {
17737
17818
  if (timeout.current) {
17738
17819
  clearTimeout(timeout.current);
@@ -20289,14 +20370,14 @@ var ColorPicker = React59.forwardRef(function ColorPickerWrapper({
20289
20370
  var ColorPicker_default = ColorPicker;
20290
20371
 
20291
20372
  // src/components/input/UploadClickableArea.tsx
20292
- import { Box as Box4 } from "@mui/material";
20373
+ import { Box as Box3 } from "@mui/material";
20293
20374
  import { jsx as jsx115, jsxs as jsxs52 } from "react/jsx-runtime";
20294
20375
  var UploadClickableArea = ({
20295
20376
  accept,
20296
20377
  onFilesChanged,
20297
20378
  children
20298
20379
  }) => /* @__PURE__ */ jsxs52(
20299
- Box4,
20380
+ Box3,
20300
20381
  {
20301
20382
  component: "label",
20302
20383
  style: {
@@ -23334,7 +23415,7 @@ var LinearProgress_default = LinearProgress;
23334
23415
  import * as React74 from "react";
23335
23416
  import MuiCircularProgress from "@mui/material/CircularProgress";
23336
23417
  import Typography3 from "@mui/material/Typography";
23337
- import Box5 from "@mui/material/Box";
23418
+ import Box4 from "@mui/material/Box";
23338
23419
  import { jsx as jsx133, jsxs as jsxs66 } from "react/jsx-runtime";
23339
23420
  var circularSizes = {
23340
23421
  XS: "20px",
@@ -23361,7 +23442,7 @@ var CircularProgress = ({
23361
23442
  gradientColors ? crypto.randomUUID() : void 0
23362
23443
  );
23363
23444
  return /* @__PURE__ */ jsxs66(
23364
- Box5,
23445
+ Box4,
23365
23446
  {
23366
23447
  sx: {
23367
23448
  position: "relative",
@@ -23401,7 +23482,7 @@ var CircularProgress = ({
23401
23482
  }
23402
23483
  ) }) }),
23403
23484
  showCircularBackground && /* @__PURE__ */ jsx133(
23404
- Box5,
23485
+ Box4,
23405
23486
  {
23406
23487
  sx: {
23407
23488
  position: "absolute",
@@ -23455,7 +23536,7 @@ var CircularProgress = ({
23455
23536
  }
23456
23537
  ),
23457
23538
  variant !== "indeterminate" && /* @__PURE__ */ jsx133(
23458
- Box5,
23539
+ Box4,
23459
23540
  {
23460
23541
  sx: {
23461
23542
  top: 0,
@@ -23487,7 +23568,7 @@ var CircularProgress = ({
23487
23568
  var CircularProgress_default = CircularProgress;
23488
23569
 
23489
23570
  // src/components/progress/DonutProgress.tsx
23490
- import Box6 from "@mui/material/Box";
23571
+ import Box5 from "@mui/material/Box";
23491
23572
  import { Stack as Stack10 } from "@mui/material";
23492
23573
  import { jsx as jsx134, jsxs as jsxs67 } from "react/jsx-runtime";
23493
23574
  var CIRCULAR_PROGRESS_PERCENTAGE = 85;
@@ -23539,7 +23620,7 @@ var DonutProgress = ({
23539
23620
  )
23540
23621
  ] });
23541
23622
  return /* @__PURE__ */ jsxs67(
23542
- Box6,
23623
+ Box5,
23543
23624
  {
23544
23625
  sx: {
23545
23626
  position: "relative",
@@ -23563,7 +23644,7 @@ var DonutProgress = ({
23563
23644
  }
23564
23645
  ),
23565
23646
  /* @__PURE__ */ jsx134(
23566
- Box6,
23647
+ Box5,
23567
23648
  {
23568
23649
  sx: {
23569
23650
  position: "absolute",
@@ -23586,7 +23667,7 @@ var DonutProgress = ({
23586
23667
  }
23587
23668
  ),
23588
23669
  variant !== "empty" && labelChip && /* @__PURE__ */ jsx134(
23589
- Box6,
23670
+ Box5,
23590
23671
  {
23591
23672
  sx: {
23592
23673
  position: "absolute",
@@ -23669,6 +23750,7 @@ var MarkdownContainer = styled9("div")(
23669
23750
  margin: "0.5em 0"
23670
23751
  },
23671
23752
  "& ul, & ol": {
23753
+ ...variants[variant || "body2"],
23672
23754
  paddingLeft: "1.5em",
23673
23755
  margin: "0.5em 0"
23674
23756
  },
@@ -23781,7 +23863,7 @@ var Navbar_default = Navbar;
23781
23863
 
23782
23864
  // src/components/navbar/NavbarButton.tsx
23783
23865
  import * as React75 from "react";
23784
- import { Box as Box7, ButtonBase as ButtonBase2 } from "@mui/material";
23866
+ import { Box as Box6, ButtonBase as ButtonBase2 } from "@mui/material";
23785
23867
  import { jsx as jsx138, jsxs as jsxs69 } from "react/jsx-runtime";
23786
23868
  var NavbarButton = React75.forwardRef(
23787
23869
  function NavbarButton2({
@@ -23798,7 +23880,7 @@ var NavbarButton = React75.forwardRef(
23798
23880
  return element;
23799
23881
  }
23800
23882
  return /* @__PURE__ */ jsxs69(
23801
- Box7,
23883
+ Box6,
23802
23884
  {
23803
23885
  sx: {
23804
23886
  backgroundImage: `linear-gradient(to left, ${cornflowerBlue}, ${electricLavender})`,
@@ -23808,7 +23890,7 @@ var NavbarButton = React75.forwardRef(
23808
23890
  },
23809
23891
  children: [
23810
23892
  /* @__PURE__ */ jsx138(
23811
- Box7,
23893
+ Box6,
23812
23894
  {
23813
23895
  sx: {
23814
23896
  position: "absolute",
@@ -23824,7 +23906,7 @@ var NavbarButton = React75.forwardRef(
23824
23906
  }
23825
23907
  ),
23826
23908
  /* @__PURE__ */ jsx138(
23827
- Box7,
23909
+ Box6,
23828
23910
  {
23829
23911
  sx: {
23830
23912
  backgroundColor: white,