@connectif/ui-components 1.0.9 → 1.0.11

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.
@@ -106,10 +106,14 @@ export type LineChartProps = CategorizedChartProps & {
106
106
  * Option to set the position of the Y axis when there is only one.
107
107
  */
108
108
  yAxisPosition?: 'left' | 'right';
109
+ /**
110
+ * Margin to add between labels and x axis. It will be in px
111
+ */
112
+ xAxisMargin?: number;
109
113
  };
110
114
  /**
111
115
  * A line chart component to display numeric data grouped by categories and series.
112
116
  * Commonly, categories use to be sorted dates.
113
117
  */
114
- 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;
115
119
  export default LineChart;
@@ -16,6 +16,10 @@ export type ChatProps = React.PropsWithChildren<{
16
16
  * Scrollbar color
17
17
  */
18
18
  scrollbarColor?: string;
19
+ /**
20
+ * Number that change to trigger scroll to class in scrollToLastClassName
21
+ */
22
+ triggerScroll?: number;
19
23
  }>;
20
- declare const Chat: ({ children, header, backgroundColor, scrollToLastClassName, scrollbarColor }: ChatProps) => import("react/jsx-runtime").JSX.Element;
24
+ declare const Chat: ({ children, header, backgroundColor, scrollToLastClassName, scrollbarColor, triggerScroll }: ChatProps) => import("react/jsx-runtime").JSX.Element;
21
25
  export default Chat;
package/dist/index.js CHANGED
@@ -11842,7 +11842,8 @@ var LineChart2 = ({
11842
11842
  fullGrid = false,
11843
11843
  axisFontSize = "11px",
11844
11844
  axisFontColor = grey400,
11845
- yAxisPosition = "right"
11845
+ yAxisPosition = "right",
11846
+ xAxisMargin
11846
11847
  }) => {
11847
11848
  const theme2 = useTheme3();
11848
11849
  const cursor = onClick ? "pointer" : "default";
@@ -12020,6 +12021,7 @@ var LineChart2 = ({
12020
12021
  show: false
12021
12022
  },
12022
12023
  axisLabel: {
12024
+ ...xAxisMargin && { margin: xAxisMargin },
12023
12025
  color: axisFontColor,
12024
12026
  fontSize: axisFontSize,
12025
12027
  show: true,
@@ -13458,14 +13460,17 @@ var ChatMessage_default = ChatMessage;
13458
13460
  import Stack5 from "@mui/material/Stack";
13459
13461
  import * as React35 from "react";
13460
13462
  import { jsx as jsx80, jsxs as jsxs35 } from "react/jsx-runtime";
13463
+ var PADDING_BOTTOM = 8;
13461
13464
  var Chat = ({
13462
13465
  children,
13463
13466
  header,
13464
13467
  backgroundColor: backgroundColor2,
13465
13468
  scrollToLastClassName,
13466
- scrollbarColor
13469
+ scrollbarColor,
13470
+ triggerScroll
13467
13471
  }) => {
13468
13472
  const ref = React35.useRef(null);
13473
+ const innerRef = React35.useRef(null);
13469
13474
  const [isInitialize, setIsInitialize] = React35.useState(false);
13470
13475
  const [hasVerticalScroll, setHasVerticalScroll] = React35.useState(false);
13471
13476
  React35.useEffect(() => {
@@ -13488,20 +13493,31 @@ var Chat = ({
13488
13493
  if (!container) {
13489
13494
  return;
13490
13495
  }
13491
- if (scrollToLastClassName) {
13492
- const elements = container.querySelectorAll(
13493
- `.${scrollToLastClassName}`
13496
+ if (innerRef.current && innerRef.current.style.paddingBottom !== "0px" && innerRef.current.style.paddingBottom !== `${PADDING_BOTTOM}px` && innerRef.current.style.paddingBottom !== "") {
13497
+ const paddingBottom = parseInt(
13498
+ innerRef.current.style.paddingBottom || "0",
13499
+ 10
13494
13500
  );
13495
- const last = elements[elements.length - 1];
13496
- if (last) {
13497
- last.scrollIntoView({ behavior: "smooth", block: "start" });
13498
- } else {
13499
- container.scrollTo(0, container.scrollHeight);
13500
- }
13501
- } else {
13502
- container.scrollTo(0, container.scrollHeight);
13501
+ const childrenHeight = innerRef.current.scrollHeight - paddingBottom;
13502
+ const childrenHeightVisible = childrenHeight - container.scrollTop;
13503
+ innerRef.current.style.paddingBottom = childrenHeightVisible > container.clientHeight ? "0px" : `${container.clientHeight - childrenHeightVisible}px`;
13504
+ }
13505
+ }, [children]);
13506
+ React35.useEffect(() => {
13507
+ const container = ref.current;
13508
+ if (!container || !scrollToLastClassName || !triggerScroll) {
13509
+ return;
13510
+ }
13511
+ const elements = container.querySelectorAll(
13512
+ `.${scrollToLastClassName}`
13513
+ );
13514
+ const last = elements[elements.length - 1];
13515
+ if (last && innerRef.current) {
13516
+ const paddingBottom = container.clientHeight - last.offsetHeight;
13517
+ innerRef.current.style.paddingBottom = `${paddingBottom}px`;
13518
+ last.scrollIntoView({ behavior: "smooth", block: "start" });
13503
13519
  }
13504
- }, [children, scrollToLastClassName]);
13520
+ }, [scrollToLastClassName, triggerScroll]);
13505
13521
  return /* @__PURE__ */ jsxs35(
13506
13522
  Stack5,
13507
13523
  {
@@ -13513,7 +13529,7 @@ var Chat = ({
13513
13529
  height: "calc(100% - 8px)",
13514
13530
  visibility: !isInitialize ? "hidden" : "visible",
13515
13531
  width: `calc(100% - ${hasVerticalScroll ? "4px" : "8px"})`,
13516
- paddingBottom: "8px",
13532
+ paddingBottom: `${PADDING_BOTTOM}px`,
13517
13533
  ...backgroundColor2 && { backgroundColor: backgroundColor2 },
13518
13534
  paddingRight: hasVerticalScroll ? "4px" : "8px",
13519
13535
  "::-webkit-scrollbar": {
@@ -13536,10 +13552,10 @@ var Chat = ({
13536
13552
  /* @__PURE__ */ jsx80(
13537
13553
  Stack5,
13538
13554
  {
13539
- justifyContent: "end",
13555
+ ref: innerRef,
13556
+ justifyContent: "start",
13540
13557
  ...!header && {
13541
- minHeight: "100%",
13542
- justifyContent: "end"
13558
+ minHeight: "100%"
13543
13559
  },
13544
13560
  sx: {
13545
13561
  "> *": { marginTop: "12px" },