@livechat/design-system-react-components 1.0.0-alpha.22 → 1.0.0-alpha.23

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
@@ -34,10 +34,13 @@ var __publicField = (obj, key, value) => {
34
34
  return value;
35
35
  };
36
36
  import * as React from "react";
37
+ import { useReducer, useRef, useEffect, useCallback, useMemo } from "react";
37
38
  import cx from "clsx";
38
- import { Close, Info as Info$1, Warning, CheckCircleSolid, Block, Person, ChevronUp, ChevronDown, Check, Error as Error2, Search, LockBlack } from "@livechat/design-system-icons/react/material";
39
+ import { Close, Info as Info$1, Warning, CheckCircleSolid, Block, Person, ChevronUp, ChevronDown, Check, DoubleArrowLeft, ChevronLeft, ChevronRight, DoubleArrowRight, Error as Error2, Search, LockBlack } from "@livechat/design-system-icons/react/material";
39
40
  import debounce from "lodash.debounce";
40
41
  import { getContrast } from "polished";
42
+ import ReactDayPicker from "react-day-picker";
43
+ import { subMonths, differenceInCalendarMonths, addMonths, isSameMonth, isSameDay, isAfter, differenceInCalendarDays } from "date-fns";
41
44
  import * as ReactDOM from "react-dom";
42
45
  import { useFloating, offset, flip, autoUpdate, arrow } from "@floating-ui/react-dom";
43
46
  import escape from "lodash.escape";
@@ -192,7 +195,7 @@ const ShadowToken = {
192
195
  Modal: "--shadow-modal"
193
196
  };
194
197
  const caps = "lc-Typography-module__caps___c3eNJ";
195
- var styles$y = {
198
+ var styles$z = {
196
199
  "heading-xl": "lc-Typography-module__heading-xl___nhr-6",
197
200
  "heading-lg": "lc-Typography-module__heading-lg___XYF7l",
198
201
  "heading-md": "lc-Typography-module__heading-md___wHOIs",
@@ -228,7 +231,7 @@ const Heading = (_a) => {
228
231
  "children",
229
232
  "className"
230
233
  ]);
231
- return React.createElement(as || SIZE_TO_ELEMENT_MAP[size], __spreadValues({ className: cx(styles$y[`heading-${size}`], className) }, props), children);
234
+ return React.createElement(as || SIZE_TO_ELEMENT_MAP[size], __spreadValues({ className: cx(styles$z[`heading-${size}`], className) }, props), children);
232
235
  };
233
236
  const Text = (_c) => {
234
237
  var _d = _c, {
@@ -253,15 +256,15 @@ const Text = (_c) => {
253
256
  const baseClassPrefix = caps2 ? "caps" : `paragraph-${size}`;
254
257
  return React.createElement(as, __spreadValues({
255
258
  className: cx({
256
- [styles$y[`${baseClassPrefix}`]]: true,
257
- [styles$y[`${baseClassPrefix}--bold`]]: bold,
258
- [styles$y[`${baseClassPrefix}--strike`]]: strike,
259
- [styles$y[`${baseClassPrefix}--underline`]]: underline
259
+ [styles$z[`${baseClassPrefix}`]]: true,
260
+ [styles$z[`${baseClassPrefix}--bold`]]: bold,
261
+ [styles$z[`${baseClassPrefix}--strike`]]: strike,
262
+ [styles$z[`${baseClassPrefix}--underline`]]: underline
260
263
  }, className)
261
264
  }, props), children);
262
265
  };
263
266
  const icon$1 = "lc-Icon-module__icon___tw31R";
264
- var styles$x = {
267
+ var styles$y = {
265
268
  icon: icon$1,
266
269
  "icon--primary": "lc-Icon-module__icon--primary___JJnBV",
267
270
  "icon--subtle": "lc-Icon-module__icon--subtle___sZIzL",
@@ -302,7 +305,7 @@ const IconSizeMap = {
302
305
  height: 32
303
306
  }
304
307
  };
305
- const baseClass$F = "icon";
308
+ const baseClass$I = "icon";
306
309
  const Icon = (props) => {
307
310
  const _a = props, {
308
311
  source,
@@ -322,7 +325,7 @@ const Icon = (props) => {
322
325
  const GeneratedIcon = React.createElement(source, __spreadProps(__spreadValues({}, IconSizeMap[size]), {
323
326
  color: customColor
324
327
  }));
325
- const mergedClassNames = cx(className, styles$x[baseClass$F], kind && styles$x[`${baseClass$F}--${disabled ? "disabled--" : ""}${kind}`]);
328
+ const mergedClassNames = cx(className, styles$y[baseClass$I], kind && styles$y[`${baseClass$I}--${disabled ? "disabled--" : ""}${kind}`]);
326
329
  return /* @__PURE__ */ React.createElement("span", __spreadProps(__spreadValues({}, restProps), {
327
330
  className: mergedClassNames
328
331
  }), GeneratedIcon);
@@ -330,7 +333,7 @@ const Icon = (props) => {
330
333
  const alert = "lc-Alert-module__alert___HBTns";
331
334
  const alert__content = "lc-Alert-module__alert__content___9nZdf";
332
335
  const alert__icon = "lc-Alert-module__alert__icon___8TaAH";
333
- var styles$w = {
336
+ var styles$x = {
334
337
  alert,
335
338
  alert__content,
336
339
  "alert__content-text": "lc-Alert-module__alert__content-text___x2Un5",
@@ -362,7 +365,7 @@ const IconConfig = {
362
365
  kind: "error"
363
366
  }
364
367
  };
365
- const baseClass$E = "alert";
368
+ const baseClass$H = "alert";
366
369
  const Alert = ({
367
370
  children,
368
371
  className,
@@ -371,7 +374,7 @@ const Alert = ({
371
374
  }) => {
372
375
  const containerRef = React.useRef(null);
373
376
  const [isSmallContainer, setIsSmallContainer] = React.useState(false);
374
- const mergedClassNames = cx(styles$w[baseClass$E], styles$w[`${baseClass$E}--${kind}`], isSmallContainer && styles$w[`${baseClass$E}--small`], className);
377
+ const mergedClassNames = cx(styles$x[baseClass$H], styles$x[`${baseClass$H}--${kind}`], isSmallContainer && styles$x[`${baseClass$H}--small`], className);
375
378
  React.useEffect(() => {
376
379
  const handleResize = debounce(() => {
377
380
  if (containerRef.current && containerRef.current.offsetWidth <= 400) {
@@ -386,16 +389,16 @@ const Alert = ({
386
389
  ref: containerRef,
387
390
  className: mergedClassNames
388
391
  }, /* @__PURE__ */ React.createElement("div", {
389
- className: styles$w[`${baseClass$E}__content`]
392
+ className: styles$x[`${baseClass$H}__content`]
390
393
  }, /* @__PURE__ */ React.createElement(Icon, __spreadProps(__spreadValues({}, IconConfig[kind]), {
391
394
  size: "large",
392
- className: styles$w[`${baseClass$E}__content-icon`]
395
+ className: styles$x[`${baseClass$H}__content-icon`]
393
396
  })), /* @__PURE__ */ React.createElement(Text, {
394
397
  as: "div",
395
- className: cx(styles$w[`${baseClass$E}__content-text`], onClose && styles$w[`${baseClass$E}__content-text--margin`])
398
+ className: cx(styles$x[`${baseClass$H}__content-text`], onClose && styles$x[`${baseClass$H}__content-text--margin`])
396
399
  }, children)), onClose && /* @__PURE__ */ React.createElement("button", {
397
400
  type: "button",
398
- className: styles$w[`${baseClass$E}__close-icon`],
401
+ className: styles$x[`${baseClass$H}__close-icon`],
399
402
  onClick: onClose
400
403
  }, /* @__PURE__ */ React.createElement(Icon, {
401
404
  source: Close,
@@ -413,7 +416,7 @@ const avatar = "lc-Avatar-module__avatar___1zTCE";
413
416
  const avatar__status = "lc-Avatar-module__avatar__status___nX2Ls";
414
417
  const avatar__rim = "lc-Avatar-module__avatar__rim___RCQ8Q";
415
418
  const avatar__image = "lc-Avatar-module__avatar__image___YqfqE";
416
- var styles$v = {
419
+ var styles$w = {
417
420
  avatar,
418
421
  avatar__status,
419
422
  "avatar__status--available": "lc-Avatar-module__avatar__status--available___tcpFg",
@@ -459,7 +462,7 @@ var styles$v = {
459
462
  "avatar--xlarge": "lc-Avatar-module__avatar--xlarge___zwgeW",
460
463
  "avatar--xxlarge": "lc-Avatar-module__avatar--xxlarge___Ur0ul"
461
464
  };
462
- const baseClass$D = "avatar";
465
+ const baseClass$G = "avatar";
463
466
  const defaultBackgroundColor = "var(--surface-basic-disabled)";
464
467
  const defaultFontColor = "var(--content-subtle)";
465
468
  const Avatar = ({
@@ -483,15 +486,15 @@ const Avatar = ({
483
486
  const backgroundColor = color || defaultBackgroundColor;
484
487
  const fontColor = color ? getFontColor(color) : defaultFontColor;
485
488
  const mergedClassNames = cx({
486
- [styles$v[baseClass$D]]: true,
487
- [styles$v[`${baseClass$D}--${shape}`]]: true,
488
- [styles$v[`${baseClass$D}--${size}`]]: true,
489
- [styles$v[`${baseClass$D}--with-rim`]]: withRim,
489
+ [styles$w[baseClass$G]]: true,
490
+ [styles$w[`${baseClass$G}--${shape}`]]: true,
491
+ [styles$w[`${baseClass$G}--${size}`]]: true,
492
+ [styles$w[`${baseClass$G}--with-rim`]]: withRim,
490
493
  [`${className}`]: className
491
494
  });
492
- const mergedStatusClassNames = cx(styles$v[`${baseClass$D}__status`], styles$v[`${baseClass$D}__status--${shape}`], styles$v[`${baseClass$D}__status--${size}`], styles$v[`${baseClass$D}__status--${status}`]);
493
- const mergedIconClassNames = cx(styles$v[`${baseClass$D}__icon`], styles$v[`${baseClass$D}__icon--${size}`]);
494
- const mergedRimClassNames = cx(styles$v[`${baseClass$D}__rim`], styles$v[`${baseClass$D}__rim--${size}`]);
495
+ const mergedStatusClassNames = cx(styles$w[`${baseClass$G}__status`], styles$w[`${baseClass$G}__status--${shape}`], styles$w[`${baseClass$G}__status--${size}`], styles$w[`${baseClass$G}__status--${status}`]);
496
+ const mergedIconClassNames = cx(styles$w[`${baseClass$G}__icon`], styles$w[`${baseClass$G}__icon--${size}`]);
497
+ const mergedRimClassNames = cx(styles$w[`${baseClass$G}__rim`], styles$w[`${baseClass$G}__rim--${size}`]);
495
498
  const handleError = React.useCallback(() => setShouldDisplayFallbackAvatar(true), []);
496
499
  React.useEffect(() => {
497
500
  setShouldDisplayFallbackAvatar(isImproperImageSetup);
@@ -500,20 +503,20 @@ const Avatar = ({
500
503
  className: mergedClassNames,
501
504
  style: { backgroundColor }
502
505
  }, withRim && /* @__PURE__ */ React.createElement("div", {
503
- "data-testid": `${baseClass$D}__rim`,
506
+ "data-testid": `${baseClass$G}__rim`,
504
507
  className: mergedRimClassNames
505
508
  }), status && /* @__PURE__ */ React.createElement("div", {
506
- "data-testid": `${baseClass$D}__status`,
509
+ "data-testid": `${baseClass$G}__status`,
507
510
  className: mergedStatusClassNames
508
511
  }), shouldDisplayImage && /* @__PURE__ */ React.createElement("img", {
509
- className: styles$v[`${baseClass$D}__image`],
512
+ className: styles$w[`${baseClass$G}__image`],
510
513
  src,
511
514
  alt,
512
515
  onError: handleError
513
516
  }), shouldDisplayInitials && /* @__PURE__ */ React.createElement("span", {
514
517
  style: { color: fontColor }
515
518
  }, initials), shouldDisplayFallbackAvatar && /* @__PURE__ */ React.createElement(Icon, {
516
- "data-testid": `${baseClass$D}__icon`,
519
+ "data-testid": `${baseClass$G}__icon`,
517
520
  className: mergedIconClassNames,
518
521
  source: Person,
519
522
  kind: "primary"
@@ -521,7 +524,7 @@ const Avatar = ({
521
524
  };
522
525
  const badge = "lc-Badge-module__badge___GhLnu";
523
526
  const badge__dot = "lc-Badge-module__badge__dot___z6RO6";
524
- var styles$u = {
527
+ var styles$v = {
525
528
  badge,
526
529
  badge__dot,
527
530
  "badge--large": "lc-Badge-module__badge--large___B131q",
@@ -534,7 +537,7 @@ var styles$u = {
534
537
  function formatCount(count, max) {
535
538
  return count > max ? `${max}+` : `${count}`;
536
539
  }
537
- const baseClass$C = "badge";
540
+ const baseClass$F = "badge";
538
541
  const Badge = (_e) => {
539
542
  var _f = _e, {
540
543
  className,
@@ -551,12 +554,12 @@ const Badge = (_e) => {
551
554
  "size",
552
555
  "type"
553
556
  ]);
554
- const mergedClassNames = cx(className, styles$u[baseClass$C], styles$u[`${baseClass$C}--${kind}`], styles$u[`${baseClass$C}--${size}`]);
557
+ const mergedClassNames = cx(className, styles$v[baseClass$F], styles$v[`${baseClass$F}--${kind}`], styles$v[`${baseClass$F}--${size}`]);
555
558
  const content = {
556
559
  ["counter"]: formatCount(count, max),
557
560
  ["alert"]: "!",
558
561
  ["dot"]: /* @__PURE__ */ React.createElement("span", {
559
- className: styles$u[`${baseClass$C}__dot`]
562
+ className: styles$v[`${baseClass$F}__dot`]
560
563
  })
561
564
  }[type];
562
565
  return /* @__PURE__ */ React.createElement("span", __spreadValues({
@@ -567,7 +570,7 @@ const loader = "lc-Loader-module__loader___LRflD";
567
570
  const loader__spinner = "lc-Loader-module__loader__spinner___l3C1g";
568
571
  const rotate = "lc-Loader-module__rotate___Tlni-";
569
572
  const loader__label = "lc-Loader-module__loader__label___R74f6";
570
- var styles$t = {
573
+ var styles$u = {
571
574
  loader,
572
575
  loader__spinner,
573
576
  "loader__spinner--small": "lc-Loader-module__loader__spinner--small___dGFFt",
@@ -577,8 +580,8 @@ var styles$t = {
577
580
  rotate,
578
581
  loader__label
579
582
  };
580
- const baseClass$B = "loader";
581
- const spinnerClass = `${baseClass$B}__spinner`;
583
+ const baseClass$E = "loader";
584
+ const spinnerClass = `${baseClass$E}__spinner`;
582
585
  const Loader = ({
583
586
  primaryColor,
584
587
  secondaryColor,
@@ -587,11 +590,11 @@ const Loader = ({
587
590
  size = "medium"
588
591
  }) => {
589
592
  return /* @__PURE__ */ React.createElement("div", {
590
- className: cx(styles$t[baseClass$B], className)
593
+ className: cx(styles$u[baseClass$E], className)
591
594
  }, /* @__PURE__ */ React.createElement("div", {
592
- className: cx(styles$t[spinnerClass], styles$t[`${spinnerClass}--${size}`])
595
+ className: cx(styles$u[spinnerClass], styles$u[`${spinnerClass}--${size}`])
593
596
  }, /* @__PURE__ */ React.createElement("div", {
594
- className: styles$t["loader__spinner-circle"],
597
+ className: styles$u["loader__spinner-circle"],
595
598
  style: {
596
599
  borderColor: secondaryColor,
597
600
  borderTopColor: primaryColor
@@ -599,14 +602,14 @@ const Loader = ({
599
602
  })), label && /* @__PURE__ */ React.createElement(Text, {
600
603
  as: "div",
601
604
  size: "md",
602
- className: styles$t["loader__label"]
605
+ className: styles$u["loader__label"]
603
606
  }, label));
604
607
  };
605
608
  const btn$1 = "lc-Button-module__btn___aijZJ";
606
609
  const btn__loader = "lc-Button-module__btn__loader___c8zZz";
607
610
  const btn__content = "lc-Button-module__btn__content___wefl2";
608
611
  const btn__icon = "lc-Button-module__btn__icon___GVExB";
609
- var styles$s = {
612
+ var styles$t = {
610
613
  btn: btn$1,
611
614
  "btn--disabled": "lc-Button-module__btn--disabled___lXBav",
612
615
  "btn--icon-only": "lc-Button-module__btn--icon-only___bF5pW",
@@ -627,7 +630,7 @@ var styles$s = {
627
630
  btn__content,
628
631
  btn__icon
629
632
  };
630
- const baseClass$A = "btn";
633
+ const baseClass$D = "btn";
631
634
  const Button = (_g) => {
632
635
  var _h = _g, {
633
636
  loading = false,
@@ -660,11 +663,11 @@ const Button = (_g) => {
660
663
  ]);
661
664
  const isDisabled = loading || disabled;
662
665
  const Component = href ? "a" : "button";
663
- const mergedClassNames = cx(className, styles$s[baseClass$A], styles$s[`${baseClass$A}--${kind}`], styles$s[`${baseClass$A}--${size}`], {
664
- [styles$s[`${baseClass$A}--loading`]]: loading,
665
- [styles$s[`${baseClass$A}--full-width`]]: fullWidth,
666
- [styles$s[`${baseClass$A}--icon-only`]]: !children && icon2,
667
- [styles$s[`${baseClass$A}--disabled`]]: isDisabled
666
+ const mergedClassNames = cx(className, styles$t[baseClass$D], styles$t[`${baseClass$D}--${kind}`], styles$t[`${baseClass$D}--${size}`], {
667
+ [styles$t[`${baseClass$D}--loading`]]: loading,
668
+ [styles$t[`${baseClass$D}--full-width`]]: fullWidth,
669
+ [styles$t[`${baseClass$D}--icon-only`]]: !children && icon2,
670
+ [styles$t[`${baseClass$D}--disabled`]]: isDisabled
668
671
  });
669
672
  return /* @__PURE__ */ React.createElement(Component, __spreadValues({
670
673
  className: mergedClassNames,
@@ -675,16 +678,16 @@ const Button = (_g) => {
675
678
  }, props), loading && /* @__PURE__ */ React.createElement(Loader, {
676
679
  size: "small",
677
680
  label: loaderLabel,
678
- className: styles$s[`${baseClass$A}__loader`]
681
+ className: styles$t[`${baseClass$D}__loader`]
679
682
  }), icon2 && React.cloneElement(icon2, {
680
- className: cx(styles$s[`${baseClass$A}__icon`], styles$s[`${baseClass$A}__icon--${iconPosition}`]),
683
+ className: cx(styles$t[`${baseClass$D}__icon`], styles$t[`${baseClass$D}__icon--${iconPosition}`]),
681
684
  disabled
682
685
  }), /* @__PURE__ */ React.createElement("div", {
683
- className: styles$s[`${baseClass$A}__content`]
686
+ className: styles$t[`${baseClass$D}__content`]
684
687
  }, children));
685
688
  };
686
689
  const btn = "lc-ButtonGroup-module__btn___bXPrU";
687
- var styles$r = {
690
+ var styles$s = {
688
691
  "btn-group": "lc-ButtonGroup-module__btn-group___R-lZQ",
689
692
  btn,
690
693
  "btn--active": "lc-ButtonGroup-module__btn--active___VAc37",
@@ -694,7 +697,7 @@ var styles$r = {
694
697
  };
695
698
  function noop() {
696
699
  }
697
- const baseClass$z = "btn-group";
700
+ const baseClass$C = "btn-group";
698
701
  const ButtonGroup = (_i) => {
699
702
  var _j = _i, {
700
703
  size = "medium",
@@ -713,7 +716,7 @@ const ButtonGroup = (_i) => {
713
716
  "currentIndex",
714
717
  "initialIndex"
715
718
  ]);
716
- const mergedClassName = cx(styles$r[baseClass$z], className);
719
+ const mergedClassName = cx(styles$s[baseClass$C], className);
717
720
  const [currentStateIndex, setCurrentStateIndex] = React.useState(initialIndex);
718
721
  const isControlled = typeof currentIndex === "number";
719
722
  const _currentIndex = isControlled ? currentIndex : currentStateIndex;
@@ -737,7 +740,7 @@ const ButtonGroup = (_i) => {
737
740
  child.props.onClick(event);
738
741
  }
739
742
  },
740
- className: cx(styles$r["btn"], styles$r[`btn--${size}`], i === _currentIndex && styles$r["btn--active"])
743
+ className: cx(styles$s["btn"], styles$s[`btn--${size}`], i === _currentIndex && styles$s["btn--active"])
741
744
  })));
742
745
  };
743
746
  const card = "lc-Card-module__card___GqMm2";
@@ -750,7 +753,7 @@ const card__content = "lc-Card-module__card__content___KuDcc";
750
753
  const card__actions = "lc-Card-module__card__actions___q9sAo";
751
754
  const card__actions__line = "lc-Card-module__card__actions__line___TF1bt";
752
755
  const card__actions__buttons = "lc-Card-module__card__actions__buttons___PDMMR";
753
- var styles$q = {
756
+ var styles$r = {
754
757
  card,
755
758
  card__header,
756
759
  card__header__image,
@@ -764,10 +767,10 @@ var styles$q = {
764
767
  card__actions__buttons,
765
768
  "card__actions__buttons-expander": "lc-Card-module__card__actions__buttons-expander___lz4h-"
766
769
  };
767
- const baseClass$y = "card";
768
- const headerClass = `${baseClass$y}__header`;
770
+ const baseClass$B = "card";
771
+ const headerClass = `${baseClass$B}__header`;
769
772
  const headingClass = `${headerClass}__heading`;
770
- const actionsClass = `${baseClass$y}__actions`;
773
+ const actionsClass = `${baseClass$B}__actions`;
771
774
  const Card = (_k) => {
772
775
  var _l = _k, {
773
776
  alt,
@@ -795,41 +798,41 @@ const Card = (_k) => {
795
798
  const shouldShowExpandAction = !!expandableContent;
796
799
  const shouldShowActions = shouldShowActionButtons || shouldShowExpandAction;
797
800
  return /* @__PURE__ */ React.createElement("div", __spreadValues({
798
- className: cx(styles$q[baseClass$y], className)
801
+ className: cx(styles$r[baseClass$B], className)
799
802
  }, divProps), /* @__PURE__ */ React.createElement("div", {
800
- className: styles$q[headerClass]
803
+ className: styles$r[headerClass]
801
804
  }, src && /* @__PURE__ */ React.createElement("img", {
802
805
  alt,
803
- className: styles$q[`${headerClass}__image`],
806
+ className: styles$r[`${headerClass}__image`],
804
807
  src
805
808
  }), /* @__PURE__ */ React.createElement("div", {
806
- className: styles$q[headingClass]
809
+ className: styles$r[headingClass]
807
810
  }, /* @__PURE__ */ React.createElement(Heading, {
808
811
  size: "sm",
809
- className: styles$q[`${headingClass}__title`]
812
+ className: styles$r[`${headingClass}__title`]
810
813
  }, title), /* @__PURE__ */ React.createElement(Text, {
811
814
  size: "sm",
812
- className: styles$q[`${headingClass}__description`]
815
+ className: styles$r[`${headingClass}__description`]
813
816
  }, description))), /* @__PURE__ */ React.createElement(Text, {
814
817
  as: "div",
815
818
  size: "md",
816
- className: styles$q[`${baseClass$y}__content`]
819
+ className: styles$r[`${baseClass$B}__content`]
817
820
  }, children), isExpanded && /* @__PURE__ */ React.createElement(Text, {
818
821
  as: "div",
819
822
  size: "md",
820
- className: styles$q[`${baseClass$y}__expanded-content`]
823
+ className: styles$r[`${baseClass$B}__expanded-content`]
821
824
  }, expandableContent), shouldShowActions && /* @__PURE__ */ React.createElement("div", {
822
- className: styles$q[actionsClass]
825
+ className: styles$r[actionsClass]
823
826
  }, /* @__PURE__ */ React.createElement("div", {
824
- className: styles$q[`${actionsClass}__line`]
827
+ className: styles$r[`${actionsClass}__line`]
825
828
  }), /* @__PURE__ */ React.createElement("div", {
826
- className: styles$q[`${actionsClass}__buttons`]
829
+ className: styles$r[`${actionsClass}__buttons`]
827
830
  }, shouldShowActionButtons && buttonsOptions.map(({ kind, onClick, children: buttonChildren }) => /* @__PURE__ */ React.createElement(Button, {
828
831
  size: "compact",
829
832
  kind,
830
833
  onClick
831
834
  }, buttonChildren)), shouldShowExpandAction && /* @__PURE__ */ React.createElement(Button, {
832
- className: styles$q[`${actionsClass}__buttons-expander`],
835
+ className: styles$r[`${actionsClass}__buttons-expander`],
833
836
  kind: "plain",
834
837
  iconPosition: "right",
835
838
  icon: /* @__PURE__ */ React.createElement(Icon, {
@@ -838,10 +841,10 @@ const Card = (_k) => {
838
841
  onClick: () => setIsExpanded(!isExpanded)
839
842
  }, expandButtonText))));
840
843
  };
841
- var styles$p = {
844
+ var styles$q = {
842
845
  "field-description": "lc-FieldDescription-module__field-description___IcRDH"
843
846
  };
844
- const baseClass$x = "field-description";
847
+ const baseClass$A = "field-description";
845
848
  const FieldDescription = (_m) => {
846
849
  var _n = _m, {
847
850
  children,
@@ -850,7 +853,7 @@ const FieldDescription = (_m) => {
850
853
  "children",
851
854
  "className"
852
855
  ]);
853
- const mergedClassNames = cx(styles$p[baseClass$x], className);
856
+ const mergedClassNames = cx(styles$q[baseClass$A], className);
854
857
  return /* @__PURE__ */ React.createElement(Text, __spreadProps(__spreadValues({
855
858
  as: "span",
856
859
  size: "sm"
@@ -865,7 +868,7 @@ const checkbox__checkmark = "lc-Checkbox-module__checkbox__checkmark___16pfY";
865
868
  const checkbox__input = "lc-Checkbox-module__checkbox__input___YLbVF";
866
869
  const checkbox__text = "lc-Checkbox-module__checkbox__text___P2SIq";
867
870
  const checkbox__helper = "lc-Checkbox-module__checkbox__helper___YSJ-n";
868
- var styles$o = {
871
+ var styles$p = {
869
872
  checkbox,
870
873
  checkbox__label,
871
874
  checkbox__square,
@@ -876,37 +879,599 @@ var styles$o = {
876
879
  "checkbox--disabled": "lc-Checkbox-module__checkbox--disabled___-lAqW",
877
880
  checkbox__helper
878
881
  };
879
- const baseClass$w = "checkbox";
882
+ const baseClass$z = "checkbox";
880
883
  const Checkbox = React.forwardRef((_o, ref) => {
881
884
  var _p = _o, { checked, disabled, children, description, className } = _p, restInputProps = __objRest(_p, ["checked", "disabled", "children", "description", "className"]);
882
885
  return /* @__PURE__ */ React.createElement("div", {
883
- className: cx(styles$o[baseClass$w], className, {
884
- [styles$o[`${baseClass$w}--selected`]]: checked,
885
- [styles$o[`${baseClass$w}--disabled`]]: disabled
886
+ className: cx(styles$p[baseClass$z], className, {
887
+ [styles$p[`${baseClass$z}--selected`]]: checked,
888
+ [styles$p[`${baseClass$z}--disabled`]]: disabled
886
889
  })
887
890
  }, /* @__PURE__ */ React.createElement("label", {
888
- className: styles$o[`${baseClass$w}__label`]
891
+ className: styles$p[`${baseClass$z}__label`]
889
892
  }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({}, restInputProps), {
890
893
  ref,
891
894
  checked,
892
895
  disabled,
893
- className: styles$o[`${baseClass$w}__input`],
896
+ className: styles$p[`${baseClass$z}__input`],
894
897
  type: "checkbox"
895
898
  })), /* @__PURE__ */ React.createElement("div", {
896
- className: styles$o[`${baseClass$w}__square`]
899
+ className: styles$p[`${baseClass$z}__square`]
897
900
  }, /* @__PURE__ */ React.createElement(Icon, {
898
901
  source: Check,
899
902
  kind: "inverted",
900
903
  size: "xsmall",
901
- className: styles$o[`${baseClass$w}__checkmark`]
904
+ className: styles$p[`${baseClass$z}__checkmark`]
902
905
  }))), children && /* @__PURE__ */ React.createElement(Text, {
903
906
  as: "div",
904
907
  size: "md",
905
- className: styles$o[`${baseClass$w}__text`]
908
+ className: styles$p[`${baseClass$z}__text`]
906
909
  }, children)), description && /* @__PURE__ */ React.createElement(FieldDescription, {
907
- className: styles$o[`${baseClass$w}__helper`]
910
+ className: styles$p[`${baseClass$z}__helper`]
908
911
  }, description));
909
912
  });
913
+ var styles$o = {
914
+ "date-picker": "lc-DatePicker-module__date-picker___9AqJ2",
915
+ "date-picker__wrapper": "lc-DatePicker-module__date-picker__wrapper___tNp4l",
916
+ "date-picker__months": "lc-DatePicker-module__date-picker__months___QuPb0",
917
+ "date-picker__month": "lc-DatePicker-module__date-picker__month___239nh",
918
+ "date-picker__nav-bar": "lc-DatePicker-module__date-picker__nav-bar___u-l17",
919
+ "date-picker__nav-button": "lc-DatePicker-module__date-picker__nav-button___1Ysdp",
920
+ "date-picker__nav-button--interaction-disabled": "lc-DatePicker-module__date-picker__nav-button--interaction-disabled___Ivjrx",
921
+ "date-picker__caption": "lc-DatePicker-module__date-picker__caption___XPgZJ",
922
+ "date-picker__weekdays": "lc-DatePicker-module__date-picker__weekdays___kpTY9",
923
+ "date-picker__weekdays-row": "lc-DatePicker-module__date-picker__weekdays-row___tGgay",
924
+ "date-picker__weekday": "lc-DatePicker-module__date-picker__weekday___3FCx8",
925
+ "date-picker__body": "lc-DatePicker-module__date-picker__body___toP1u",
926
+ "date-picker__week": "lc-DatePicker-module__date-picker__week___nZI1x",
927
+ "date-picker__day": "lc-DatePicker-module__date-picker__day___ZTSw9",
928
+ "date-picker__day-content": "lc-DatePicker-module__date-picker__day-content___rDIa0",
929
+ "date-picker__day-wrapper": "lc-DatePicker-module__date-picker__day-wrapper___gGeeJ",
930
+ "date-picker__day--today": "lc-DatePicker-module__date-picker__day--today___LL51c",
931
+ "date-picker__day--selected": "lc-DatePicker-module__date-picker__day--selected___1D1tC",
932
+ "date-picker__day--outside": "lc-DatePicker-module__date-picker__day--outside___ptNdC",
933
+ "date-picker__day--disabled": "lc-DatePicker-module__date-picker__day--disabled___4O6yW",
934
+ "date-picker--interaction-disabled": "lc-DatePicker-module__date-picker--interaction-disabled___-zn8o",
935
+ "date-picker__footer": "lc-DatePicker-module__date-picker__footer___cXMQ5",
936
+ "date-picker__input": "lc-DatePicker-module__date-picker__input___r6qih",
937
+ "date-picker__input-overlay-wrapper": "lc-DatePicker-module__date-picker__input-overlay-wrapper___vmC0M",
938
+ "date-picker__input-overlay": "lc-DatePicker-module__date-picker__input-overlay___eJ9D0",
939
+ "date-picker--range": "lc-DatePicker-module__date-picker--range___ZU-7k",
940
+ "date-picker__day--start": "lc-DatePicker-module__date-picker__day--start___-oB8U",
941
+ "date-picker__day--end": "lc-DatePicker-module__date-picker__day--end___TtN5P",
942
+ "date-picker__day--single": "lc-DatePicker-module__date-picker__day--single___biWcB",
943
+ "date-picker__day--sunday": "lc-DatePicker-module__date-picker__day--sunday___JEnhV",
944
+ "date-picker__day--monday": "lc-DatePicker-module__date-picker__day--monday___NXYIr",
945
+ "date-picker--range__select-input": "lc-DatePicker-module__date-picker--range__select-input___6pyj3",
946
+ "date-picker--range__calendars-wrapper": "lc-DatePicker-module__date-picker--range__calendars-wrapper___8nWaW",
947
+ "date-picker__navbar-buttons-wrapper": "lc-DatePicker-module__date-picker__navbar-buttons-wrapper___Hnksb"
948
+ };
949
+ const baseClass$y = "date-picker";
950
+ const DatePickerNavbar = (props) => {
951
+ const {
952
+ onPreviousClick,
953
+ onMonthChange,
954
+ onNextClick,
955
+ showNextButton,
956
+ showPreviousButton,
957
+ className,
958
+ classNames,
959
+ numberOfMonths,
960
+ month,
961
+ fromMonth,
962
+ toMonth
963
+ } = props;
964
+ const handlePrevClick = () => {
965
+ if (typeof onPreviousClick === "function") {
966
+ onPreviousClick();
967
+ }
968
+ };
969
+ const handleNextClick = () => {
970
+ if (typeof onNextClick === "function") {
971
+ onNextClick();
972
+ }
973
+ };
974
+ const handlePrevYearClick = () => {
975
+ if (!fromMonth) {
976
+ const newMonth2 = subMonths(month, 12);
977
+ return onMonthChange(newMonth2);
978
+ }
979
+ const diff = Math.abs(differenceInCalendarMonths(month, fromMonth));
980
+ const newMonth = subMonths(month, !Number.isNaN(diff) && diff > 12 ? 12 : diff);
981
+ return onMonthChange(newMonth);
982
+ };
983
+ const handleNextYearClick = () => {
984
+ if (!toMonth) {
985
+ const newMonth2 = addMonths(month, 12);
986
+ return onMonthChange(newMonth2);
987
+ }
988
+ const diff = Math.abs(differenceInCalendarMonths(toMonth, month));
989
+ const newMonth = addMonths(month, !Number.isNaN(diff) && diff > 12 ? 12 : diff);
990
+ if (numberOfMonths === 2 && isSameMonth(newMonth, toMonth)) {
991
+ return onMonthChange(subMonths(newMonth, 1));
992
+ }
993
+ return onMonthChange(newMonth);
994
+ };
995
+ return /* @__PURE__ */ React.createElement("div", {
996
+ className
997
+ }, /* @__PURE__ */ React.createElement("div", {
998
+ className: styles$o[`${baseClass$y}__navbar-buttons-wrapper`]
999
+ }, /* @__PURE__ */ React.createElement("button", {
1000
+ "data-testid": "date-picker-prev-year-button",
1001
+ className: cx({
1002
+ [classNames.navButtonPrev]: true,
1003
+ [classNames.navButtonInteractionDisabled]: !showPreviousButton
1004
+ }),
1005
+ onClick: handlePrevYearClick
1006
+ }, /* @__PURE__ */ React.createElement(Icon, {
1007
+ source: DoubleArrowLeft,
1008
+ kind: "subtle"
1009
+ })), /* @__PURE__ */ React.createElement("button", {
1010
+ "data-testid": "date-picker-prev-month-button",
1011
+ className: cx({
1012
+ [classNames.navButtonPrev]: true,
1013
+ [classNames.navButtonInteractionDisabled]: !showPreviousButton
1014
+ }),
1015
+ onClick: handlePrevClick
1016
+ }, /* @__PURE__ */ React.createElement(Icon, {
1017
+ source: ChevronLeft,
1018
+ kind: "subtle"
1019
+ }))), /* @__PURE__ */ React.createElement("div", {
1020
+ className: styles$o[`${baseClass$y}__navbar-buttons-wrapper`]
1021
+ }, /* @__PURE__ */ React.createElement("button", {
1022
+ "data-testid": "date-picker-next-month-button",
1023
+ className: cx({
1024
+ [classNames.navButtonNext]: true,
1025
+ [classNames.navButtonInteractionDisabled]: !showNextButton
1026
+ }),
1027
+ onClick: handleNextClick
1028
+ }, /* @__PURE__ */ React.createElement(Icon, {
1029
+ source: ChevronRight,
1030
+ kind: "subtle"
1031
+ })), /* @__PURE__ */ React.createElement("button", {
1032
+ "data-testid": "date-picker-next-year-button",
1033
+ className: cx({
1034
+ [classNames.navButtonNext]: true,
1035
+ [classNames.navButtonInteractionDisabled]: !showNextButton
1036
+ }),
1037
+ onClick: handleNextYearClick
1038
+ }, /* @__PURE__ */ React.createElement(Icon, {
1039
+ source: DoubleArrowRight,
1040
+ kind: "subtle"
1041
+ }))));
1042
+ };
1043
+ const baseClass$x = "date-picker";
1044
+ const isDateWithinRange = (date, range) => {
1045
+ const { from, to } = range;
1046
+ if (to && !isSameDay(date, to) && isAfter(date, to)) {
1047
+ return false;
1048
+ }
1049
+ if (from && !isSameDay(date, from) && !isAfter(date, from)) {
1050
+ return false;
1051
+ }
1052
+ return true;
1053
+ };
1054
+ const calculateDatePickerMonth = (initialFromDate, initialToDate, toMonth) => {
1055
+ if (!initialToDate) {
1056
+ return subMonths(toMonth || new Date(), 1);
1057
+ }
1058
+ const forcePreviousMonth = initialFromDate && !isSameMonth(initialFromDate, initialToDate);
1059
+ if (forcePreviousMonth || toMonth && isSameMonth(initialToDate, toMonth)) {
1060
+ return subMonths(initialToDate, 1);
1061
+ }
1062
+ return initialToDate;
1063
+ };
1064
+ const getRangeDatePickerModifiers = (from, to) => {
1065
+ const base = {
1066
+ [styles$o[`${baseClass$x}__day--monday`]]: { daysOfWeek: [1] },
1067
+ [styles$o[`${baseClass$x}__day--sunday`]]: { daysOfWeek: [0] },
1068
+ [styles$o[`${baseClass$x}__day--start`]]: from,
1069
+ [styles$o[`${baseClass$x}__day--end`]]: from
1070
+ };
1071
+ if (!to || !from)
1072
+ return base;
1073
+ const diff = differenceInCalendarDays(to, from);
1074
+ if (diff > 0) {
1075
+ return __spreadProps(__spreadValues({}, base), {
1076
+ [styles$o[`${baseClass$x}__day--end`]]: to
1077
+ });
1078
+ }
1079
+ if (diff < 0) {
1080
+ return __spreadProps(__spreadValues({}, base), {
1081
+ [styles$o[`${baseClass$x}__day--start`]]: to
1082
+ });
1083
+ }
1084
+ return base;
1085
+ };
1086
+ const getSelectedOption = (itemId, options) => {
1087
+ const selectedOption = options.find((item) => {
1088
+ return item.id === itemId;
1089
+ });
1090
+ return selectedOption ? selectedOption : void 0;
1091
+ };
1092
+ const isSelectingFirstDay = (from, to) => {
1093
+ const isRangeSelected = from && to;
1094
+ return Boolean(!from || isRangeSelected);
1095
+ };
1096
+ const getInitialStateFromProps = (props) => {
1097
+ const state = {};
1098
+ if (!props.initialSelectedItemKey) {
1099
+ return state;
1100
+ }
1101
+ const selectedOption = getSelectedOption(props.initialSelectedItemKey, props.options);
1102
+ if (!selectedOption) {
1103
+ return {};
1104
+ }
1105
+ state.selectedItem = props.initialSelectedItemKey;
1106
+ if (!selectedOption.isManual) {
1107
+ return state;
1108
+ }
1109
+ if (props.initialFromDate) {
1110
+ state.from = props.initialFromDate;
1111
+ }
1112
+ if (props.initialToDate) {
1113
+ state.to = props.initialToDate;
1114
+ state.temporaryTo = props.initialToDate;
1115
+ }
1116
+ return state;
1117
+ };
1118
+ const getDatePickerClassNames = (range, classNames) => __spreadValues({
1119
+ container: cx({
1120
+ [styles$o[`${baseClass$x}`]]: true,
1121
+ [styles$o[`${baseClass$x}--range`]]: range
1122
+ }),
1123
+ wrapper: styles$o[`${baseClass$x}__wrapper`],
1124
+ interactionDisabled: styles$o[`${baseClass$x}--interaction-disabled`],
1125
+ months: styles$o[`${baseClass$x}__months`],
1126
+ month: styles$o[`${baseClass$x}__month`],
1127
+ navBar: styles$o[`${baseClass$x}__nav-bar`],
1128
+ navButtonPrev: cx(styles$o[`${baseClass$x}__nav-button`], styles$o[`${baseClass$x}__nav-button--prev`]),
1129
+ navButtonNext: cx(styles$o[`${baseClass$x}__nav-button`], styles$o[`${baseClass$x}__nav-button--next`]),
1130
+ navButtonInteractionDisabled: styles$o[`${baseClass$x}__nav-button--interaction-disabled`],
1131
+ caption: styles$o[`${baseClass$x}__caption`],
1132
+ weekdays: styles$o[`${baseClass$x}__weekdays`],
1133
+ weekdaysRow: styles$o[`${baseClass$x}__weekdays-row`],
1134
+ weekday: styles$o[`${baseClass$x}__weekday`],
1135
+ body: styles$o[`${baseClass$x}__body`],
1136
+ week: styles$o[`${baseClass$x}__week`],
1137
+ weekNumber: styles$o[`${baseClass$x}__week-number`],
1138
+ day: styles$o[`${baseClass$x}__day`],
1139
+ footer: styles$o[`${baseClass$x}__footer`],
1140
+ todayButton: styles$o[`${baseClass$x}__today-button`],
1141
+ today: styles$o[`${baseClass$x}__day--today`],
1142
+ selected: styles$o[`${baseClass$x}__day--selected`],
1143
+ disabled: styles$o[`${baseClass$x}__day--disabled`],
1144
+ outside: styles$o[`${baseClass$x}__day--outside`],
1145
+ start: styles$o[`${baseClass$x}__day--start`],
1146
+ end: styles$o[`${baseClass$x}__day--end`]
1147
+ }, classNames);
1148
+ const baseClass$w = "date-picker";
1149
+ const defaultDayRenderer = (day) => {
1150
+ const date = day.getDate();
1151
+ return /* @__PURE__ */ React.createElement("div", {
1152
+ className: styles$o[`${baseClass$w}__day-wrapper`]
1153
+ }, /* @__PURE__ */ React.createElement("div", {
1154
+ className: styles$o[`${baseClass$w}__day-content`]
1155
+ }, date));
1156
+ };
1157
+ const DatePickerComponent = (props) => {
1158
+ const _a = props, {
1159
+ classNames,
1160
+ range,
1161
+ toMonth,
1162
+ month,
1163
+ fromMonth,
1164
+ firstDayOfWeek: propsFirstDayOfWeek,
1165
+ numberOfMonths,
1166
+ navbarElement,
1167
+ renderDay,
1168
+ innerRef
1169
+ } = _a, restProps = __objRest(_a, [
1170
+ "classNames",
1171
+ "range",
1172
+ "toMonth",
1173
+ "month",
1174
+ "fromMonth",
1175
+ "firstDayOfWeek",
1176
+ "numberOfMonths",
1177
+ "navbarElement",
1178
+ "renderDay",
1179
+ "innerRef"
1180
+ ]);
1181
+ const [currentMonth, setCurrentMonth] = React.useState(month || new Date());
1182
+ React.useEffect(() => {
1183
+ if (month && month !== currentMonth) {
1184
+ setCurrentMonth(month);
1185
+ }
1186
+ }, [month, currentMonth]);
1187
+ React.useEffect(() => {
1188
+ if (toMonth) {
1189
+ if (!isDateWithinRange(currentMonth, { from: fromMonth, to: toMonth })) {
1190
+ setCurrentMonth(toMonth);
1191
+ }
1192
+ }
1193
+ }, [currentMonth, props.toMonth, props.fromMonth]);
1194
+ const handleMonthChange = React.useCallback((month2) => {
1195
+ if (props.onMonthChange && month2) {
1196
+ props.onMonthChange(month2);
1197
+ return;
1198
+ }
1199
+ setCurrentMonth(month2);
1200
+ }, [month, props.onMonthChange]);
1201
+ let firstDayOfWeek = 1;
1202
+ if (propsFirstDayOfWeek === 0 || propsFirstDayOfWeek && propsFirstDayOfWeek < 7) {
1203
+ firstDayOfWeek = propsFirstDayOfWeek;
1204
+ }
1205
+ const datePickerClassNames = React.useMemo(() => getDatePickerClassNames(range, classNames), [range, classNames]);
1206
+ return /* @__PURE__ */ React.createElement(ReactDayPicker, __spreadValues({
1207
+ navbarElement: navbarElement || /* @__PURE__ */ React.createElement(DatePickerNavbar, {
1208
+ month: currentMonth,
1209
+ classNames: datePickerClassNames,
1210
+ numberOfMonths,
1211
+ onMonthChange: handleMonthChange,
1212
+ toMonth,
1213
+ fromMonth
1214
+ }),
1215
+ ref: innerRef,
1216
+ classNames: datePickerClassNames,
1217
+ numberOfMonths,
1218
+ toMonth,
1219
+ fromMonth,
1220
+ firstDayOfWeek,
1221
+ month: currentMonth,
1222
+ renderDay: renderDay || defaultDayRenderer
1223
+ }, restProps));
1224
+ };
1225
+ const DatePicker = React.forwardRef((props, ref) => /* @__PURE__ */ React.createElement(DatePickerComponent, __spreadValues({
1226
+ innerRef: ref
1227
+ }, props)));
1228
+ DatePicker.displayName = "DatePicker";
1229
+ var RangeDatePickerAction = /* @__PURE__ */ ((RangeDatePickerAction2) => {
1230
+ RangeDatePickerAction2["NEW_SELECTED_ITEM"] = "NEW_SELECTED_ITEM";
1231
+ RangeDatePickerAction2["NEW_TEMPORARY_TO_VALUE"] = "NEW_TEMPORARY_TO_VALUE";
1232
+ RangeDatePickerAction2["CLEAR"] = "CLEAR";
1233
+ RangeDatePickerAction2["SET_FROM"] = "SET_FROM";
1234
+ RangeDatePickerAction2["SET_TO"] = "SET_TO";
1235
+ RangeDatePickerAction2["SELECT_FIRST_DAY"] = "SELECT_FIRST_DAY";
1236
+ RangeDatePickerAction2["SELECT_SECOND_DAY_AS_FROM"] = "SELECT_SECOND_DAY_AS_FROM";
1237
+ RangeDatePickerAction2["SELECT_SECOND_DAY_AS_TO"] = "SELECT_SECOND_DAY_AS_TO";
1238
+ RangeDatePickerAction2["CURRENT_MONTH_CHANGE"] = "CURRENT_MONTH_CHANGE";
1239
+ return RangeDatePickerAction2;
1240
+ })(RangeDatePickerAction || {});
1241
+ const useRangeDatePickerState = (props) => {
1242
+ const initialCurrentMonth = calculateDatePickerMonth(props.initialFromDate, props.initialToDate, props.toMonth);
1243
+ const defaultInitialState = {
1244
+ selectedItem: null,
1245
+ from: void 0,
1246
+ to: void 0,
1247
+ temporaryTo: void 0,
1248
+ currentMonth: initialCurrentMonth
1249
+ };
1250
+ const initialState = __spreadValues(__spreadValues({}, defaultInitialState), getInitialStateFromProps(props));
1251
+ function reducer(state, action) {
1252
+ switch (action.type) {
1253
+ case RangeDatePickerAction.NEW_SELECTED_ITEM:
1254
+ return {
1255
+ selectedItem: action.payload.selectedItem,
1256
+ from: void 0,
1257
+ to: void 0,
1258
+ temporaryTo: void 0,
1259
+ currentMonth: initialCurrentMonth
1260
+ };
1261
+ case RangeDatePickerAction.NEW_TEMPORARY_TO_VALUE:
1262
+ return __spreadProps(__spreadValues({}, state), {
1263
+ temporaryTo: action.payload.date
1264
+ });
1265
+ case RangeDatePickerAction.SELECT_FIRST_DAY:
1266
+ return __spreadProps(__spreadValues({}, state), {
1267
+ from: action.payload.date,
1268
+ to: void 0,
1269
+ temporaryTo: void 0
1270
+ });
1271
+ case RangeDatePickerAction.SELECT_SECOND_DAY_AS_FROM:
1272
+ return __spreadProps(__spreadValues({}, state), {
1273
+ from: action.payload.date,
1274
+ to: state.from,
1275
+ temporaryTo: state.from
1276
+ });
1277
+ case RangeDatePickerAction.SELECT_SECOND_DAY_AS_TO:
1278
+ return __spreadProps(__spreadValues({}, state), {
1279
+ to: action.payload.date,
1280
+ temporaryTo: action.payload.date
1281
+ });
1282
+ case RangeDatePickerAction.CURRENT_MONTH_CHANGE:
1283
+ return __spreadProps(__spreadValues({}, state), {
1284
+ currentMonth: action.payload.date
1285
+ });
1286
+ case RangeDatePickerAction.SET_FROM:
1287
+ return __spreadProps(__spreadValues({}, state), {
1288
+ from: action.payload.date
1289
+ });
1290
+ case RangeDatePickerAction.SET_TO:
1291
+ return __spreadProps(__spreadValues({}, state), {
1292
+ to: action.payload.date
1293
+ });
1294
+ default:
1295
+ return state;
1296
+ }
1297
+ }
1298
+ return useReducer(reducer, initialState);
1299
+ };
1300
+ const RangeDatePicker = ({
1301
+ options,
1302
+ initialSelectedItemKey,
1303
+ initialFromDate,
1304
+ initialToDate,
1305
+ toMonth,
1306
+ onChange,
1307
+ children
1308
+ }) => {
1309
+ const prevSelectedItem = useRef(initialSelectedItemKey || null);
1310
+ const [state, dispatch] = useRangeDatePickerState({
1311
+ options,
1312
+ initialSelectedItemKey,
1313
+ initialFromDate,
1314
+ initialToDate,
1315
+ toMonth,
1316
+ onChange,
1317
+ children
1318
+ });
1319
+ useEffect(() => {
1320
+ dispatch({
1321
+ type: RangeDatePickerAction.SET_FROM,
1322
+ payload: { date: initialFromDate }
1323
+ });
1324
+ }, [initialFromDate]);
1325
+ useEffect(() => {
1326
+ dispatch({
1327
+ type: RangeDatePickerAction.SET_TO,
1328
+ payload: { date: initialToDate }
1329
+ });
1330
+ }, [initialToDate]);
1331
+ useEffect(() => {
1332
+ const currentMonth = calculateDatePickerMonth(initialFromDate, initialToDate, toMonth);
1333
+ dispatch({
1334
+ type: RangeDatePickerAction.CURRENT_MONTH_CHANGE,
1335
+ payload: { date: currentMonth }
1336
+ });
1337
+ }, [toMonth, initialFromDate, initialToDate]);
1338
+ useEffect(() => {
1339
+ const { from, selectedItem, to } = state;
1340
+ if (!(from && to)) {
1341
+ return;
1342
+ }
1343
+ const selectedOption = getSelectedOption(selectedItem, options);
1344
+ if (!selectedOption)
1345
+ return;
1346
+ onChange && onChange(__spreadProps(__spreadValues({}, selectedOption), {
1347
+ value: {
1348
+ from,
1349
+ to
1350
+ }
1351
+ }));
1352
+ }, [state.from, state.to, state.selectedItem, options, onChange]);
1353
+ useEffect(() => {
1354
+ const { selectedItem } = state;
1355
+ if (selectedItem === prevSelectedItem.current) {
1356
+ return;
1357
+ }
1358
+ if (!selectedItem) {
1359
+ onChange(null);
1360
+ return;
1361
+ }
1362
+ const selectedOption = getSelectedOption(selectedItem, options);
1363
+ if (!selectedOption) {
1364
+ return;
1365
+ }
1366
+ const optionsHash = options.reduce((acc, option) => __spreadProps(__spreadValues({}, acc), { [option.id]: option }), {});
1367
+ onChange(optionsHash[selectedItem]);
1368
+ }, [onChange, state.selectedItem, options]);
1369
+ const handleDayMouseEnter = useCallback((day) => {
1370
+ const isInRange = toMonth ? differenceInCalendarDays(toMonth, day) >= 0 : true;
1371
+ if (!isSelectingFirstDay(state.from, state.to) && isInRange) {
1372
+ dispatch({
1373
+ type: RangeDatePickerAction.NEW_TEMPORARY_TO_VALUE,
1374
+ payload: { date: day }
1375
+ });
1376
+ }
1377
+ }, [toMonth, state.from, state.to]);
1378
+ const handleDayClick = useCallback((day) => {
1379
+ const { from, to } = state;
1380
+ if (!isDateWithinRange(day, { to: toMonth })) {
1381
+ return;
1382
+ }
1383
+ if (isSelectingFirstDay(from, to)) {
1384
+ dispatch({
1385
+ type: RangeDatePickerAction.SELECT_FIRST_DAY,
1386
+ payload: { date: day }
1387
+ });
1388
+ } else if (from && isSameDay(day, from) || from && isAfter(day, from)) {
1389
+ dispatch({
1390
+ type: RangeDatePickerAction.SELECT_SECOND_DAY_AS_TO,
1391
+ payload: { date: day }
1392
+ });
1393
+ } else {
1394
+ dispatch({
1395
+ type: RangeDatePickerAction.SELECT_SECOND_DAY_AS_FROM,
1396
+ payload: { date: day }
1397
+ });
1398
+ }
1399
+ }, [toMonth, state.from, state.to]);
1400
+ const handleItemSelect = useCallback((itemKey) => {
1401
+ if (itemKey === null) {
1402
+ dispatch({
1403
+ type: RangeDatePickerAction.NEW_SELECTED_ITEM,
1404
+ payload: { selectedItem: null }
1405
+ });
1406
+ return;
1407
+ }
1408
+ const selectedOption = getSelectedOption(itemKey, options);
1409
+ if (!selectedOption) {
1410
+ return;
1411
+ }
1412
+ dispatch({
1413
+ type: RangeDatePickerAction.NEW_SELECTED_ITEM,
1414
+ payload: { selectedItem: itemKey }
1415
+ });
1416
+ }, [options]);
1417
+ const handleMonthChange = useCallback((date) => {
1418
+ dispatch({
1419
+ type: RangeDatePickerAction.CURRENT_MONTH_CHANGE,
1420
+ payload: { date }
1421
+ });
1422
+ }, []);
1423
+ const getRangeDatePickerApi = () => {
1424
+ const { currentMonth, from, selectedItem, temporaryTo, to } = state;
1425
+ const modifiers = useMemo(() => getRangeDatePickerModifiers(from, temporaryTo), [from, temporaryTo]);
1426
+ const selectedOption = useMemo(() => {
1427
+ return getSelectedOption(selectedItem, options);
1428
+ }, [options, selectedItem]);
1429
+ const selectedDays = useMemo(() => {
1430
+ return [from, { from, to: temporaryTo }];
1431
+ }, [from, temporaryTo]);
1432
+ const disabledDays = useMemo(() => {
1433
+ return toMonth ? { after: toMonth } : void 0;
1434
+ }, [toMonth]);
1435
+ return {
1436
+ select: {
1437
+ onItemSelect: handleItemSelect,
1438
+ selected: selectedItem || ""
1439
+ },
1440
+ inputs: {
1441
+ fromDate: from,
1442
+ toDate: to
1443
+ },
1444
+ datepicker: {
1445
+ range: true,
1446
+ month: currentMonth,
1447
+ numberOfMonths: 2,
1448
+ onDayClick: handleDayClick,
1449
+ selectedDays,
1450
+ modifiers,
1451
+ initialMonth: toMonth && subMonths(toMonth, 1),
1452
+ toMonth,
1453
+ disabledDays,
1454
+ onDayMouseEnter: handleDayMouseEnter,
1455
+ onMonthChange: handleMonthChange
1456
+ },
1457
+ selectedOption
1458
+ };
1459
+ };
1460
+ return children(getRangeDatePickerApi());
1461
+ };
1462
+ RangeDatePicker.defaultProps = {
1463
+ options: [
1464
+ {
1465
+ id: "default",
1466
+ label: "Default option",
1467
+ isManual: true,
1468
+ value: {
1469
+ from: void 0,
1470
+ to: void 0
1471
+ }
1472
+ }
1473
+ ]
1474
+ };
910
1475
  var styles$n = {
911
1476
  "field-error": "lc-FieldError-module__field-error___IDkPT"
912
1477
  };
@@ -3252,4 +3817,4 @@ const UserGuide = (props) => {
3252
3817
  })
3253
3818
  }), props.children)) : null;
3254
3819
  };
3255
- export { ANIMATION_TIME, ActionModal, Alert, Avatar, Badge, Button, ButtonGroup, Card, Checkbox, 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, SearchInput, ShadowToken, Simple, SpacingToken, Switch, Tab, TabsList, TabsWrapper, Tag, TagInput, Text, Toast, ToastWrapper, Tooltip, UserGuide };
3820
+ 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 };