@livechat/design-system-react-components 1.0.0-alpha.24 → 1.0.0-alpha.25

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.
package/dist/dsrc.es.js CHANGED
@@ -686,62 +686,58 @@ const Button = (_g) => {
686
686
  className: styles$t[`${baseClass$D}__content`]
687
687
  }, children));
688
688
  };
689
- const btn = "lc-ButtonGroup-module__btn___bXPrU";
689
+ const btn = "lc-SegmentedControl-module__btn___tfsvL";
690
690
  var styles$s = {
691
- "btn-group": "lc-ButtonGroup-module__btn-group___R-lZQ",
691
+ "segmented-control": "lc-SegmentedControl-module__segmented-control___LHWSk",
692
692
  btn,
693
- "btn--active": "lc-ButtonGroup-module__btn--active___VAc37",
694
- "btn--compact": "lc-ButtonGroup-module__btn--compact___t1whe",
695
- "btn--medium": "lc-ButtonGroup-module__btn--medium___XFRBP",
696
- "btn--large": "lc-ButtonGroup-module__btn--large___OtNUz"
693
+ "btn--active": "lc-SegmentedControl-module__btn--active___Za-th",
694
+ "btn--compact": "lc-SegmentedControl-module__btn--compact___gcSwq",
695
+ "btn--medium": "lc-SegmentedControl-module__btn--medium___w3UzC",
696
+ "btn--large": "lc-SegmentedControl-module__btn--large___yHPw4"
697
697
  };
698
698
  function noop() {
699
699
  }
700
- const baseClass$C = "btn-group";
701
- const ButtonGroup = (_i) => {
702
- var _j = _i, {
703
- size = "medium",
704
- fullWidth = false,
705
- onIndexChange = noop,
706
- className,
707
- children,
708
- currentIndex,
709
- initialIndex = -1
710
- } = _j, restProps = __objRest(_j, [
711
- "size",
712
- "fullWidth",
713
- "onIndexChange",
714
- "className",
715
- "children",
716
- "currentIndex",
717
- "initialIndex"
718
- ]);
700
+ const baseClass$C = "segmented-control";
701
+ const SegmentedControl = ({
702
+ size = "medium",
703
+ buttons,
704
+ className,
705
+ initialId,
706
+ currentId,
707
+ fullWidth = false,
708
+ onButtonClick = noop
709
+ }) => {
719
710
  const mergedClassName = cx(styles$s[baseClass$C], className);
720
- const [currentStateIndex, setCurrentStateIndex] = React.useState(initialIndex);
721
- const isControlled = typeof currentIndex === "number";
722
- const _currentIndex = isControlled ? currentIndex : currentStateIndex;
723
- const handleClick = (index2, event) => {
711
+ const [currentStateId, setCurrentStateId] = React.useState(() => initialId);
712
+ const isControlled = typeof currentId === "string";
713
+ React.useEffect(() => {
714
+ isControlled && setCurrentStateId(currentId);
715
+ }, [currentId]);
716
+ const handleClick = (id, event) => {
724
717
  if (!isControlled) {
725
- setCurrentStateIndex(index2);
718
+ setCurrentStateId(id);
726
719
  }
727
- onIndexChange(index2, event);
720
+ onButtonClick(id, event);
728
721
  };
729
- return /* @__PURE__ */ React.createElement("div", __spreadValues({
722
+ const buttonSet = buttons.map(({ id, label, loading, disabled }) => {
723
+ const activityStyles = id === currentStateId ? styles$s["btn--active"] : "";
724
+ const loadingStatus = id === currentStateId ? false : loading;
725
+ return /* @__PURE__ */ React.createElement(Button, {
726
+ key: id,
727
+ fullWidth,
728
+ loading: loadingStatus,
729
+ disabled,
730
+ kind: "secondary",
731
+ className: cx(styles$s["btn"], styles$s[`btn--${size}`], activityStyles),
732
+ onClick: (event) => {
733
+ handleClick(id, event);
734
+ }
735
+ }, label);
736
+ });
737
+ return /* @__PURE__ */ React.createElement("div", {
730
738
  role: "group",
731
739
  className: mergedClassName
732
- }, restProps), React.Children.map(children, (child, i) => React.cloneElement(child, {
733
- fullWidth,
734
- size,
735
- kind: "secondary",
736
- type: "button",
737
- onClick: (event) => {
738
- handleClick(i, event);
739
- if (child.props.onClick) {
740
- child.props.onClick(event);
741
- }
742
- },
743
- className: cx(styles$s["btn"], styles$s[`btn--${size}`], i === _currentIndex && styles$s["btn--active"])
744
- })));
740
+ }, buttonSet);
745
741
  };
746
742
  const card = "lc-Card-module__card___GqMm2";
747
743
  const card__header = "lc-Card-module__card__header___0ptfD";
@@ -771,8 +767,8 @@ const baseClass$B = "card";
771
767
  const headerClass = `${baseClass$B}__header`;
772
768
  const headingClass = `${headerClass}__heading`;
773
769
  const actionsClass = `${baseClass$B}__actions`;
774
- const Card = (_k) => {
775
- var _l = _k, {
770
+ const Card = (_i) => {
771
+ var _j = _i, {
776
772
  alt,
777
773
  buttonsOptions = [],
778
774
  children,
@@ -781,7 +777,7 @@ const Card = (_k) => {
781
777
  expandableContent,
782
778
  src,
783
779
  title
784
- } = _l, divProps = __objRest(_l, [
780
+ } = _j, divProps = __objRest(_j, [
785
781
  "alt",
786
782
  "buttonsOptions",
787
783
  "children",
@@ -845,11 +841,11 @@ var styles$q = {
845
841
  "field-description": "lc-FieldDescription-module__field-description___IcRDH"
846
842
  };
847
843
  const baseClass$A = "field-description";
848
- const FieldDescription = (_m) => {
849
- var _n = _m, {
844
+ const FieldDescription = (_k) => {
845
+ var _l = _k, {
850
846
  children,
851
847
  className = ""
852
- } = _n, props = __objRest(_n, [
848
+ } = _l, props = __objRest(_l, [
853
849
  "children",
854
850
  "className"
855
851
  ]);
@@ -880,8 +876,8 @@ var styles$p = {
880
876
  checkbox__helper
881
877
  };
882
878
  const baseClass$z = "checkbox";
883
- const Checkbox = React.forwardRef((_o, ref) => {
884
- var _p = _o, { checked, disabled, children, description, className } = _p, restInputProps = __objRest(_p, ["checked", "disabled", "children", "description", "className"]);
879
+ const Checkbox = React.forwardRef((_m, ref) => {
880
+ var _n = _m, { checked, disabled, children, description, className } = _n, restInputProps = __objRest(_n, ["checked", "disabled", "children", "description", "className"]);
885
881
  return /* @__PURE__ */ React.createElement("div", {
886
882
  className: cx(styles$p[baseClass$z], className, {
887
883
  [styles$p[`${baseClass$z}--selected`]]: checked,
@@ -1476,11 +1472,11 @@ var styles$n = {
1476
1472
  "field-error": "lc-FieldError-module__field-error___IDkPT"
1477
1473
  };
1478
1474
  const baseClass$v = "field-error";
1479
- const FieldError = (_q) => {
1480
- var _r = _q, {
1475
+ const FieldError = (_o) => {
1476
+ var _p = _o, {
1481
1477
  children,
1482
1478
  className = ""
1483
- } = _r, props = __objRest(_r, [
1479
+ } = _p, props = __objRest(_p, [
1484
1480
  "children",
1485
1481
  "className"
1486
1482
  ]);
@@ -1498,15 +1494,15 @@ var styles$m = {
1498
1494
  "field-group--stretched": "lc-FieldGroup-module__field-group--stretched___6rkuO"
1499
1495
  };
1500
1496
  const baseClass$u = "field-group";
1501
- const FieldGroup = (_s) => {
1502
- var _t = _s, {
1497
+ const FieldGroup = (_q) => {
1498
+ var _r = _q, {
1503
1499
  className = "",
1504
1500
  children,
1505
1501
  description,
1506
1502
  error,
1507
1503
  inline,
1508
1504
  stretch
1509
- } = _t, props = __objRest(_t, [
1505
+ } = _r, props = __objRest(_r, [
1510
1506
  "className",
1511
1507
  "children",
1512
1508
  "description",
@@ -1535,14 +1531,14 @@ var styles$l = {
1535
1531
  form__helper
1536
1532
  };
1537
1533
  const baseClass$t = "form";
1538
- const Form = (_u) => {
1539
- var _v = _u, {
1534
+ const Form = (_s) => {
1535
+ var _t = _s, {
1540
1536
  className,
1541
1537
  children,
1542
1538
  labelText,
1543
1539
  helperText,
1544
1540
  formFooter
1545
- } = _v, restProps = __objRest(_v, [
1541
+ } = _t, restProps = __objRest(_t, [
1546
1542
  "className",
1547
1543
  "children",
1548
1544
  "labelText",
@@ -1627,13 +1623,13 @@ var styles$j = {
1627
1623
  "form-group__helper": "lc-FormGroup-module__form-group__helper___SRuxe"
1628
1624
  };
1629
1625
  const baseClass$r = "form-group";
1630
- const FormGroup = (_w) => {
1631
- var _x = _w, {
1626
+ const FormGroup = (_u) => {
1627
+ var _v = _u, {
1632
1628
  className = "",
1633
1629
  children,
1634
1630
  labelText,
1635
1631
  helperText
1636
- } = _x, props = __objRest(_x, [
1632
+ } = _v, props = __objRest(_v, [
1637
1633
  "className",
1638
1634
  "children",
1639
1635
  "labelText",
@@ -1666,8 +1662,8 @@ var styles$i = {
1666
1662
  "input--large": "lc-Input-module__input--large___jX5RW"
1667
1663
  };
1668
1664
  const baseClass$q = "input";
1669
- const Input = React.forwardRef((_y, ref) => {
1670
- var _z = _y, { size = "medium", error = false, className } = _z, inputProps = __objRest(_z, ["size", "error", "className"]);
1665
+ const Input = React.forwardRef((_w, ref) => {
1666
+ var _x = _w, { size = "medium", error = false, className } = _x, inputProps = __objRest(_x, ["size", "error", "className"]);
1671
1667
  return /* @__PURE__ */ React.createElement("input", __spreadValues({
1672
1668
  className: cx(className, styles$i[baseClass$q], styles$i[`${baseClass$q}--${size}`], {
1673
1669
  [styles$i[`${baseClass$q}--error`]]: error
@@ -1682,11 +1678,11 @@ var styles$h = {
1682
1678
  "link--bold": "lc-Link-module__link--bold___1rGdO"
1683
1679
  };
1684
1680
  const baseClass$p = "link";
1685
- const Link = (_A) => {
1686
- var _B = _A, {
1681
+ const Link = (_y) => {
1682
+ var _z = _y, {
1687
1683
  bold = false,
1688
1684
  className = ""
1689
- } = _B, rest = __objRest(_B, [
1685
+ } = _z, rest = __objRest(_z, [
1690
1686
  "bold",
1691
1687
  "className"
1692
1688
  ]);
@@ -1737,14 +1733,14 @@ const KeyCodes = {
1737
1733
  arrowDown: "ArrowDown"
1738
1734
  };
1739
1735
  const baseClass$o = "modal-base";
1740
- const ModalBase = (_C) => {
1741
- var _D = _C, {
1736
+ const ModalBase = (_A) => {
1737
+ var _B = _A, {
1742
1738
  children,
1743
1739
  className = "",
1744
1740
  onClose,
1745
1741
  closeOnEscPress = true,
1746
1742
  closeOnOverlayPress = true
1747
- } = _D, props = __objRest(_D, [
1743
+ } = _B, props = __objRest(_B, [
1748
1744
  "children",
1749
1745
  "className",
1750
1746
  "onClose",
@@ -1785,14 +1781,14 @@ const ModalBase = (_C) => {
1785
1781
  }), children));
1786
1782
  };
1787
1783
  const baseClass$n = "action-modal";
1788
- const ActionModal = (_E) => {
1789
- var _F = _E, {
1784
+ const ActionModal = (_C) => {
1785
+ var _D = _C, {
1790
1786
  children,
1791
1787
  className = "",
1792
1788
  icon: icon2,
1793
1789
  heading,
1794
1790
  actions
1795
- } = _F, props = __objRest(_F, [
1791
+ } = _D, props = __objRest(_D, [
1796
1792
  "children",
1797
1793
  "className",
1798
1794
  "icon",
@@ -1813,13 +1809,13 @@ const ActionModal = (_E) => {
1813
1809
  }, actions));
1814
1810
  };
1815
1811
  const baseClass$m = "modal";
1816
- const Modal = (_G) => {
1817
- var _H = _G, {
1812
+ const Modal = (_E) => {
1813
+ var _F = _E, {
1818
1814
  children,
1819
1815
  className = "",
1820
1816
  heading,
1821
1817
  footer
1822
- } = _H, props = __objRest(_H, [
1818
+ } = _F, props = __objRest(_F, [
1823
1819
  "children",
1824
1820
  "className",
1825
1821
  "heading",
@@ -1872,8 +1868,8 @@ var styles$f = {
1872
1868
  "numeric-input--error": "lc-NumericInput-module__numeric-input--error___TMxRx"
1873
1869
  };
1874
1870
  const baseClass$l = "numeric-input";
1875
- const NumericInput = (_I) => {
1876
- var _J = _I, {
1871
+ const NumericInput = (_G) => {
1872
+ var _H = _G, {
1877
1873
  className,
1878
1874
  error,
1879
1875
  value,
@@ -1883,7 +1879,7 @@ const NumericInput = (_I) => {
1883
1879
  noControls,
1884
1880
  style,
1885
1881
  onChange
1886
- } = _J, restProps = __objRest(_J, [
1882
+ } = _H, restProps = __objRest(_H, [
1887
1883
  "className",
1888
1884
  "error",
1889
1885
  "value",
@@ -2329,6 +2325,7 @@ const Popover = (props) => {
2329
2325
  children,
2330
2326
  className,
2331
2327
  placement,
2328
+ flipOptions,
2332
2329
  isVisible = false
2333
2330
  } = props;
2334
2331
  const [visible, setVisibility] = React.useState(false);
@@ -2342,7 +2339,7 @@ const Popover = (props) => {
2342
2339
  update,
2343
2340
  placement: updatedPlacement
2344
2341
  } = useFloating({
2345
- middleware: [offset(4), flip()],
2342
+ middleware: [offset(4), flip(flipOptions)],
2346
2343
  placement
2347
2344
  });
2348
2345
  React.useEffect(() => {
@@ -2437,13 +2434,13 @@ const SIZE_VALUE_FROM_SIZE = {
2437
2434
  large: 56
2438
2435
  };
2439
2436
  const baseClass$h = "progress-circle";
2440
- const ProgressCircle = React.forwardRef((_K, ref) => {
2441
- var _L = _K, {
2437
+ const ProgressCircle = React.forwardRef((_I, ref) => {
2438
+ var _J = _I, {
2442
2439
  status = "normal",
2443
2440
  progressValue,
2444
2441
  className,
2445
2442
  size = "medium"
2446
- } = _L, restProps = __objRest(_L, [
2443
+ } = _J, restProps = __objRest(_J, [
2447
2444
  "status",
2448
2445
  "progressValue",
2449
2446
  "className",
@@ -2498,13 +2495,13 @@ var styles$a = {
2498
2495
  "progress-bar__indicator--normal": "lc-ProgressBar-module__progress-bar__indicator--normal___0Uhle"
2499
2496
  };
2500
2497
  const baseClass$g = "progress-bar";
2501
- const ProgressBar = React.forwardRef((_M, ref) => {
2502
- var _N = _M, {
2498
+ const ProgressBar = React.forwardRef((_K, ref) => {
2499
+ var _L = _K, {
2503
2500
  status = "normal",
2504
2501
  percent,
2505
2502
  size = "medium",
2506
2503
  className = ""
2507
- } = _N, restProps = __objRest(_N, [
2504
+ } = _L, restProps = __objRest(_L, [
2508
2505
  "status",
2509
2506
  "percent",
2510
2507
  "size",
@@ -2624,8 +2621,8 @@ var styles$8 = {
2624
2621
  "radio-button--disabled": "lc-RadioButton-module__radio-button--disabled___wHSA7"
2625
2622
  };
2626
2623
  const baseClass$e = "radio-button";
2627
- const RadioButton = React.forwardRef((_O, ref) => {
2628
- var _P = _O, { children, className = "", description, checked, disabled } = _P, props = __objRest(_P, ["children", "className", "description", "checked", "disabled"]);
2624
+ const RadioButton = React.forwardRef((_M, ref) => {
2625
+ var _N = _M, { children, className = "", description, checked, disabled } = _N, props = __objRest(_N, ["children", "className", "description", "checked", "disabled"]);
2629
2626
  const mergedClassNames = cx(styles$8[baseClass$e], className, {
2630
2627
  [styles$8[`${baseClass$e}--selected`]]: checked,
2631
2628
  [styles$8[`${baseClass$e}--disabled`]]: disabled
@@ -2674,13 +2671,14 @@ const SearchInput = ({
2674
2671
  placeholder = "Search ...",
2675
2672
  size = "medium",
2676
2673
  value,
2674
+ className,
2677
2675
  onChange
2678
2676
  }) => {
2679
2677
  const [searchValue, setSearchValue] = React.useState(value || "");
2680
2678
  const [isCollapsed, setIsCollapsed] = React.useState(true);
2681
2679
  const inputRef = React.useRef(null);
2682
2680
  const isCloseIconVisible = !!searchValue && !isDisabled && !isLoading;
2683
- const mergedClassNames = cx(styles$7[`${inputBaseClass}`], styles$7[`${inputBaseClass}--${size}`], (isDisabled || isLoading) && styles$7[`${inputBaseClass}--disabled`], isCollapsable && styles$7[`${inputBaseClass}--collapsable`], !isCollapsed && styles$7[`${inputBaseClass}--collapsable--open`]);
2681
+ const mergedClassNames = cx(className, styles$7[`${inputBaseClass}`], styles$7[`${inputBaseClass}--${size}`], (isDisabled || isLoading) && styles$7[`${inputBaseClass}--disabled`], isCollapsable && styles$7[`${inputBaseClass}--collapsable`], !isCollapsed && styles$7[`${inputBaseClass}--collapsable--open`]);
2684
2682
  React.useEffect(() => {
2685
2683
  if (typeof value === "string") {
2686
2684
  setSearchValue(value);
@@ -2784,8 +2782,8 @@ var styles$6 = {
2784
2782
  switch__icon
2785
2783
  };
2786
2784
  const baseClass$c = "switch";
2787
- const Switch = (_Q) => {
2788
- var _R = _Q, {
2785
+ const Switch = (_O) => {
2786
+ var _P = _O, {
2789
2787
  className = "",
2790
2788
  defaultOn = false,
2791
2789
  disabled = false,
@@ -2794,8 +2792,9 @@ const Switch = (_Q) => {
2794
2792
  onChange = noop,
2795
2793
  size = "large",
2796
2794
  state = "regular",
2797
- innerRef
2798
- } = _R, props = __objRest(_R, [
2795
+ innerRef,
2796
+ ariaLabel
2797
+ } = _P, props = __objRest(_P, [
2799
2798
  "className",
2800
2799
  "defaultOn",
2801
2800
  "disabled",
@@ -2804,7 +2803,8 @@ const Switch = (_Q) => {
2804
2803
  "onChange",
2805
2804
  "size",
2806
2805
  "state",
2807
- "innerRef"
2806
+ "innerRef",
2807
+ "ariaLabel"
2808
2808
  ]);
2809
2809
  const [checked, setChecked] = React.useState(() => on !== void 0 ? on : defaultOn);
2810
2810
  React.useEffect(() => {
@@ -2838,7 +2838,7 @@ const Switch = (_Q) => {
2838
2838
  name,
2839
2839
  ref: innerRef,
2840
2840
  disabled: shouldBehaveAsDisabled,
2841
- "test-id": "foo"
2841
+ "aria-label": ariaLabel
2842
2842
  }, props)), /* @__PURE__ */ React.createElement("span", {
2843
2843
  className: styles$6[`${baseClass$c}__container`]
2844
2844
  }, /* @__PURE__ */ React.createElement("span", {
@@ -2863,13 +2863,13 @@ var styles$5 = {
2863
2863
  "tab--selected": "lc-Tab-module__tab--selected___c0EkL"
2864
2864
  };
2865
2865
  const baseClass$b = "tab";
2866
- const Tab = (_S) => {
2867
- var _T = _S, {
2866
+ const Tab = (_Q) => {
2867
+ var _R = _Q, {
2868
2868
  children,
2869
2869
  className,
2870
2870
  description,
2871
2871
  isSelected
2872
- } = _T, restProps = __objRest(_T, [
2872
+ } = _R, restProps = __objRest(_R, [
2873
2873
  "children",
2874
2874
  "className",
2875
2875
  "description",
@@ -2939,8 +2939,8 @@ const getCustomTextClass = (customColor) => {
2939
2939
  }
2940
2940
  return getContrast(customColor, "#FFFFFF") > 4.5 ? "text-white" : "text-black";
2941
2941
  };
2942
- const Tag = (_U) => {
2943
- var _V = _U, {
2942
+ const Tag = (_S) => {
2943
+ var _T = _S, {
2944
2944
  className = "",
2945
2945
  children,
2946
2946
  dismissible = false,
@@ -2951,7 +2951,7 @@ const Tag = (_U) => {
2951
2951
  icon: icon2,
2952
2952
  avatar: avatar2,
2953
2953
  customColor
2954
- } = _V, restProps = __objRest(_V, [
2954
+ } = _T, restProps = __objRest(_T, [
2955
2955
  "className",
2956
2956
  "children",
2957
2957
  "dismissible",
@@ -3271,15 +3271,15 @@ const iconConfig = {
3271
3271
  }
3272
3272
  };
3273
3273
  const baseClass$6 = "toast";
3274
- const Toast = (_W) => {
3275
- var _X = _W, {
3274
+ const Toast = (_U) => {
3275
+ var _V = _U, {
3276
3276
  action,
3277
3277
  className,
3278
3278
  children,
3279
3279
  removable,
3280
3280
  kind = "info",
3281
3281
  onClose
3282
- } = _X, divProps = __objRest(_X, [
3282
+ } = _V, divProps = __objRest(_V, [
3283
3283
  "action",
3284
3284
  "className",
3285
3285
  "children",
@@ -3823,4 +3823,4 @@ const UserGuide = (props) => {
3823
3823
  })
3824
3824
  }), props.children)) : null;
3825
3825
  };
3826
- export { ANIMATION_TIME, ActionModal, Alert, Avatar, Badge, Button, ButtonGroup, Card, Checkbox, DatePicker, DesignToken, EmailTagInput, FieldDescription, FieldError, FieldGroup, Form, FormField, FormGroup, Heading, Icon, Info, Input, Interactive, Link, Loader, Modal, ModalBase, ModalCloseButton, ModalPortal, NumericInput, Picker, Popover, ProgressBar, ProgressCircle, PromoBanner, RadioButton, RangeDatePicker, SearchInput, ShadowToken, Simple, SpacingToken, Switch, Tab, TabsList, TabsWrapper, Tag, TagInput, Text, Toast, ToastWrapper, Tooltip, UserGuide };
3826
+ export { ANIMATION_TIME, ActionModal, Alert, Avatar, Badge, Button, Card, Checkbox, DatePicker, DesignToken, EmailTagInput, FieldDescription, FieldError, FieldGroup, Form, FormField, FormGroup, Heading, Icon, Info, Input, Interactive, Link, Loader, Modal, ModalBase, ModalCloseButton, ModalPortal, NumericInput, Picker, Popover, ProgressBar, ProgressCircle, PromoBanner, RadioButton, RangeDatePicker, SearchInput, SegmentedControl, ShadowToken, Simple, SpacingToken, Switch, Tab, TabsList, TabsWrapper, Tag, TagInput, Text, Toast, ToastWrapper, Tooltip, UserGuide };