@starasia/dropdown 3.5.2 → 4.0.0

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,6 +1,6 @@
1
- import { jsxs as l, jsx as n, Fragment as tn } from "react/jsx-runtime";
2
- import _, { useState as F, useRef as I, useEffect as g, forwardRef as dn } from "react";
3
- const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
1
+ import { jsxs as l, jsx as n, Fragment as sn } from "react/jsx-runtime";
2
+ import T, { useState as P, useRef as B, useEffect as g, forwardRef as ln } from "react";
3
+ const pn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
4
4
  * {
5
5
  margin: 0;
6
6
  padding: 0;
@@ -366,9 +366,12 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
366
366
  display: flex;
367
367
  flex-direction: column;
368
368
  gap: 6px;
369
- width: 100%;
369
+ width: max-content;
370
370
  font-family: "Poppins", sans-serif;
371
371
  }
372
+ .sa-select-field-fullwidth {
373
+ width: 100%;
374
+ }
372
375
  .sa-select-field-left {
373
376
  flex-direction: row;
374
377
  align-items: flex-start;
@@ -448,15 +451,15 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
448
451
  }
449
452
 
450
453
  `;
451
- function ln(e) {
452
- const [p, d] = F(e), s = I(null), r = (o) => {
454
+ function cn(e) {
455
+ const [p, d] = P(e), s = B(null), r = (o) => {
453
456
  s.current && !s.current.contains(o.target) && d(!1);
454
457
  };
455
458
  return g(() => (document.addEventListener("click", r, !0), () => {
456
459
  document.removeEventListener("click", r, !0);
457
460
  }), []), { ref: s, isComponentVisible: p, setIsComponentVisible: d };
458
461
  }
459
- const pn = ({ ...e }) => /* @__PURE__ */ l(
462
+ const un = ({ ...e }) => /* @__PURE__ */ l(
460
463
  "svg",
461
464
  {
462
465
  xmlns: "http://www.w3.org/2000/svg",
@@ -488,7 +491,7 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
488
491
  )
489
492
  ]
490
493
  }
491
- ), cn = ({ width: e = 16 }) => /* @__PURE__ */ n(
494
+ ), wn = ({ width: e = 16 }) => /* @__PURE__ */ n(
492
495
  "svg",
493
496
  {
494
497
  xmlns: "http://www.w3.org/2000/svg",
@@ -507,7 +510,7 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
507
510
  }
508
511
  )
509
512
  }
510
- ), un = dn(
513
+ ), hn = ln(
511
514
  ({
512
515
  positionDropdown: e,
513
516
  dropdownLists: p,
@@ -515,78 +518,78 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
515
518
  searchAble: s,
516
519
  onSearch: r,
517
520
  value: o,
518
- handleChangeValue: y,
521
+ handleChangeValue: N,
519
522
  multiSelect: u,
520
- searchValue: H,
523
+ searchValue: F,
521
524
  highlightedIndex: m,
522
- footer: A,
523
- groupLabel: D,
524
- onSelectAll: j
525
- }, M) => {
526
- const L = I([]);
525
+ footer: I,
526
+ groupLabel: j,
527
+ onSelectAll: A
528
+ }, H) => {
529
+ const R = B([]);
527
530
  g(() => {
528
531
  var a;
529
- m >= 0 && L.current[m] && ((a = L.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
532
+ m >= 0 && R.current[m] && ((a = R.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
530
533
  }, [m]);
531
- const O = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
532
- /* @__PURE__ */ n(pn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
534
+ const D = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
535
+ /* @__PURE__ */ n(un, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
533
536
  /* @__PURE__ */ n(
534
537
  "input",
535
538
  {
536
539
  onChange: (a) => {
537
540
  r && r(a.target.value);
538
541
  },
539
- value: H,
542
+ value: F,
540
543
  autoFocus: !0,
541
544
  placeholder: "Search..."
542
545
  }
543
546
  )
544
547
  ] }) : null;
545
- return /* @__PURE__ */ n(tn, { children: d ? /* @__PURE__ */ l(
548
+ return /* @__PURE__ */ n(sn, { children: d ? /* @__PURE__ */ l(
546
549
  "div",
547
550
  {
548
551
  className: "sa-input-dropdown-lists-container",
549
552
  onClick: (a) => a.stopPropagation(),
550
- ref: M,
553
+ ref: H,
551
554
  children: [
552
- e !== "top" && O,
555
+ e !== "top" && D,
553
556
  /* @__PURE__ */ l(
554
557
  "div",
555
558
  {
556
559
  className: `sa-input-dropdwon-item-container ${u ? "multi" : ""}`,
557
560
  children: [
558
- D && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
559
- /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: D }),
560
- u && j && /* @__PURE__ */ n(
561
+ j && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
562
+ /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: j }),
563
+ u && A && /* @__PURE__ */ n(
561
564
  "button",
562
565
  {
563
566
  className: "sa-input-dropdown-section-select-all",
564
567
  onClick: (a) => {
565
- a.stopPropagation(), j();
568
+ a.stopPropagation(), A();
566
569
  },
567
570
  children: "Select all"
568
571
  }
569
572
  )
570
573
  ] }),
571
- p.map((a, R) => {
572
- const W = !!(o != null && o.find((S) => S.value === a.value)), z = !!a.description;
574
+ p.map((a, z) => {
575
+ const O = !!(o != null && o.find((k) => k.value === a.value)), M = !!a.description;
573
576
  return /* @__PURE__ */ l(
574
577
  "div",
575
578
  {
576
579
  className: [
577
580
  "sa-input-dropdwon-item",
578
- z ? "has-description" : "",
579
- W ? "active" : "",
580
- R === m ? "highlight" : "",
581
+ M ? "has-description" : "",
582
+ O ? "active" : "",
583
+ z === m ? "highlight" : "",
581
584
  a.disable ? "sa-input-dropdwon-item-disable" : ""
582
585
  ].filter(Boolean).join(" "),
583
- ref: (S) => {
584
- L.current[R] = S;
586
+ ref: (k) => {
587
+ R.current[z] = k;
585
588
  },
586
- onClick: () => y(a.label, a.value),
589
+ onClick: () => N(a.label, a.value),
587
590
  children: [
588
- u && /* @__PURE__ */ n("div", { className: "sa-input-dropdwon-item-check", children: W && /* @__PURE__ */ n(cn, { width: 16 }) }),
589
- a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: _.cloneElement(a.icon, { width: 16 }) }),
591
+ u && /* @__PURE__ */ n("div", { className: "sa-input-dropdwon-item-check", children: O && /* @__PURE__ */ n(wn, { width: 16 }) }),
592
+ a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: T.cloneElement(a.icon, { width: 16 }) }),
590
593
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
591
594
  /* @__PURE__ */ n(
592
595
  "p",
@@ -611,25 +614,25 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
611
614
  ] })
612
615
  ]
613
616
  },
614
- R
617
+ z
615
618
  );
616
619
  })
617
620
  ]
618
621
  }
619
622
  ),
620
- e === "top" && O,
621
- A && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: A })
623
+ e === "top" && D,
624
+ I && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: I })
622
625
  ]
623
626
  }
624
627
  ) : null });
625
628
  }
626
- ), wn = ({
629
+ ), fn = ({
627
630
  children: e,
628
631
  handleChangePosition: p
629
632
  }) => {
630
- const d = I(null);
633
+ const d = B(null);
631
634
  g(() => {
632
- var y;
635
+ var N;
633
636
  const r = () => {
634
637
  if (d.current) {
635
638
  let u = d.current.parentElement;
@@ -638,7 +641,7 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
638
641
  u && p();
639
642
  }
640
643
  };
641
- let o = (y = d.current) == null ? void 0 : y.parentElement;
644
+ let o = (N = d.current) == null ? void 0 : N.parentElement;
642
645
  for (; o && !s(o); )
643
646
  o = o.parentElement;
644
647
  return o && o.addEventListener("scroll", r), r(), () => {
@@ -647,203 +650,207 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
647
650
  }, []);
648
651
  const s = (r) => r && (r.scrollHeight > r.clientHeight || r.scrollWidth > r.clientWidth);
649
652
  return /* @__PURE__ */ n("div", { ref: d, children: e });
650
- }, X = "sa-input-dropdown-styles", hn = (e) => {
651
- if (!document.getElementById(X)) {
653
+ }, Y = "sa-input-dropdown-styles", bn = (e) => {
654
+ if (!document.getElementById(Y)) {
652
655
  const p = document.createElement("style");
653
- p.id = X, p.textContent = e, document.head.appendChild(p);
656
+ p.id = Y, p.textContent = e, document.head.appendChild(p);
654
657
  }
655
658
  };
656
- hn(sn);
657
- const mn = ({
659
+ bn(pn);
660
+ const yn = ({
658
661
  dropdownLists: e,
659
662
  onChange: p,
660
663
  defaultValue: d,
661
664
  value: s,
662
665
  size: r = "md",
663
666
  multiSelect: o,
664
- searchAble: y,
667
+ searchAble: N,
665
668
  iconLeft: u,
666
- placeholder: H,
669
+ placeholder: F,
667
670
  onSearch: m,
668
- error: A,
669
- onBlur: D,
670
- onFocus: j,
671
- disable: M,
672
- searchValue: L,
673
- variant: O = "outline",
671
+ error: I,
672
+ onBlur: j,
673
+ onFocus: A,
674
+ disable: H,
675
+ searchValue: R,
676
+ variant: D = "outline",
674
677
  footer: a,
675
- groupLabel: R,
676
- onSelectAll: W,
678
+ groupLabel: z,
679
+ onSelectAll: O,
680
+ fullWidth: M = !1,
677
681
  /* field wrapper */
678
- label: z,
679
- labelPosition: S = "outside-top",
680
- required: U,
681
- optional: Z,
682
- description: N,
683
- helperText: E,
682
+ label: k,
683
+ labelPosition: nn = "outside-top",
684
+ required: Z,
685
+ optional: Q,
686
+ description: E,
687
+ helperText: C,
684
688
  errorText: w
685
689
  }) => {
686
- const C = s !== void 0, $ = I(), T = A || !!w, [c, B] = F(
687
- C ? s || [] : d || []
688
- ), [nn, Q] = F(""), [x, V] = F(-1), h = I(null), { isComponentVisible: f, ref: q, setIsComponentVisible: P } = ln(!1), en = () => {
689
- P((t) => !t);
690
- }, G = (t, i) => {
690
+ const $ = [
691
+ "sa-select-field",
692
+ M ? "sa-select-field-fullwidth" : ""
693
+ ].filter(Boolean).join(" "), L = s !== void 0, V = B(), en = I || !!w, [c, S] = P(
694
+ L ? s || [] : d || []
695
+ ), [on, X] = P(""), [x, q] = P(-1), h = B(null), { isComponentVisible: f, ref: G, setIsComponentVisible: W } = cn(!1), rn = () => {
696
+ W((t) => !t);
697
+ }, J = (t, i) => {
691
698
  if (o)
692
699
  if (c == null ? void 0 : c.find((b) => b.value === i)) {
693
- const b = c.filter((an) => an.value !== i);
694
- C || B(b), p(b);
700
+ const b = c.filter((dn) => dn.value !== i);
701
+ L || S(b), p(b);
695
702
  } else {
696
703
  const b = [...c, { label: t, value: i }];
697
- C || B(b), p(b);
704
+ L || S(b), p(b);
698
705
  }
699
706
  else {
700
707
  const v = [{ label: t, value: i }];
701
- C || B(v), p(v), P(!1);
708
+ L || S(v), p(v), W(!1);
702
709
  }
703
710
  };
704
711
  g(() => {
705
- C && B(s || []);
712
+ L && S(s || []);
706
713
  }, [s]), g(() => {
707
- C || JSON.stringify($.current) === JSON.stringify(d) || ($.current = d, B($.current || []));
714
+ L || JSON.stringify(V.current) === JSON.stringify(d) || (V.current = d, S(V.current || []));
708
715
  }, [d]);
709
- const on = () => c.length ? o ? c == null ? void 0 : c.map((t, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
716
+ const an = () => c.length ? o ? c == null ? void 0 : c.map((t, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
710
717
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: t == null ? void 0 : t.label }),
711
718
  /* @__PURE__ */ n(
712
- fn,
719
+ gn,
713
720
  {
714
721
  onClick: (v) => {
715
- v.stopPropagation(), G(t.label, t.value);
722
+ v.stopPropagation(), J(t.label, t.value);
716
723
  }
717
724
  }
718
725
  )
719
- ] }, i)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: c == null ? void 0 : c[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: H }), k = () => {
720
- if (q.current && h.current) {
721
- const t = window.innerHeight, i = q.current.getBoundingClientRect(), v = h.current.getBoundingClientRect(), b = i.bottom + v.height;
722
- h.current.style.left = `${i.left}px`, h.current.style.width = `${i.width}px`, b >= t - 10 ? (h.current.style.top = `${i.top - v.height - 5}px`, Q("top")) : (h.current.style.top = `${i.top + i.height + 4}px`, Q("bottom"));
726
+ ] }, i)) : /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: c == null ? void 0 : c[0].label }) : /* @__PURE__ */ n("p", { className: "sa-input-dropdown-placeholder", children: F }), y = () => {
727
+ if (G.current && h.current) {
728
+ const t = window.innerHeight, i = G.current.getBoundingClientRect(), v = h.current.getBoundingClientRect(), b = i.bottom + v.height;
729
+ h.current.style.left = `${i.left}px`, h.current.style.width = `${i.width}px`, b >= t - 10 ? (h.current.style.top = `${i.top - v.height - 5}px`, X("top")) : (h.current.style.top = `${i.top + i.height + 4}px`, X("bottom"));
723
730
  }
724
731
  };
725
- g(() => (window.addEventListener("scroll", k), window.addEventListener("resize", k), () => {
726
- window.removeEventListener("scroll", k), window.removeEventListener("resize", k);
732
+ g(() => (window.addEventListener("scroll", y), window.addEventListener("resize", y), () => {
733
+ window.removeEventListener("scroll", y), window.removeEventListener("resize", y);
727
734
  }), []), g(() => {
728
- k();
735
+ y();
729
736
  }, [f]), g(() => {
730
737
  if (!f || !h.current)
731
738
  return;
732
739
  const t = new ResizeObserver(() => {
733
- k();
740
+ y();
734
741
  });
735
742
  return t.observe(h.current), () => t.disconnect();
736
743
  }, [f]), g(() => {
737
- f || V(-1);
744
+ f || q(-1);
738
745
  }, [f]);
739
- const rn = (t) => {
746
+ const tn = (t) => {
740
747
  if (!f) {
741
- (t.key === "ArrowDown" || t.key === "Enter") && (t.preventDefault(), P(!0));
748
+ (t.key === "ArrowDown" || t.key === "Enter") && (t.preventDefault(), W(!0));
742
749
  return;
743
750
  }
744
751
  switch (t.key) {
745
752
  case "ArrowDown": {
746
753
  t.preventDefault();
747
- const i = Y(e, x, 1);
748
- i !== -1 && V(i);
754
+ const i = _(e, x, 1);
755
+ i !== -1 && q(i);
749
756
  break;
750
757
  }
751
758
  case "ArrowUp": {
752
759
  t.preventDefault();
753
- const i = Y(e, x, -1);
754
- i !== -1 && V(i);
760
+ const i = _(e, x, -1);
761
+ i !== -1 && q(i);
755
762
  break;
756
763
  }
757
764
  case "Enter": {
758
- t.preventDefault(), x >= 0 && e[x] && !e[x].disable && G(
765
+ t.preventDefault(), x >= 0 && e[x] && !e[x].disable && J(
759
766
  e[x].label,
760
767
  e[x].value
761
768
  );
762
769
  break;
763
770
  }
764
771
  case "Escape":
765
- P(!1);
772
+ W(!1);
766
773
  break;
767
774
  }
768
- }, J = r === "lg" || r === "xl" ? 20 : 16, K = /* @__PURE__ */ n(wn, { handleChangePosition: k, children: /* @__PURE__ */ l(
775
+ }, K = r === "lg" || r === "xl" ? 20 : 16, U = /* @__PURE__ */ n(fn, { handleChangePosition: y, children: /* @__PURE__ */ l(
769
776
  "div",
770
777
  {
771
778
  className: [
772
779
  "sa-input-dropdown-container",
773
- O,
780
+ D,
774
781
  `sa-input-dropdown-size-${r}`,
775
782
  f ? "active" : "",
776
- T ? "error" : "",
777
- M ? "disable" : ""
783
+ en ? "error" : "",
784
+ H ? "disable" : ""
778
785
  ].filter(Boolean).join(" "),
779
- ref: q,
780
- onClick: en,
781
- onKeyDown: rn,
786
+ ref: G,
787
+ onClick: rn,
788
+ onKeyDown: tn,
782
789
  tabIndex: 0,
783
- onBlur: D,
784
- onFocus: j,
790
+ onBlur: j,
791
+ onFocus: A,
785
792
  children: [
786
793
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
787
- u ? _.cloneElement(u, {
788
- width: J,
794
+ u ? T.cloneElement(u, {
795
+ width: K,
789
796
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
790
797
  }) : null,
791
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: on() }),
792
- f ? /* @__PURE__ */ n(gn, { width: J }) : /* @__PURE__ */ n(bn, { width: J })
798
+ /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: an() }),
799
+ f ? /* @__PURE__ */ n(vn, { width: K }) : /* @__PURE__ */ n(xn, { width: K })
793
800
  ] }),
794
801
  /* @__PURE__ */ n(
795
- un,
802
+ hn,
796
803
  {
797
804
  dropdownLists: e,
798
- handleChangeValue: G,
805
+ handleChangeValue: J,
799
806
  isComponentVisible: f,
800
- positionDropdown: nn,
801
- searchAble: !!y,
807
+ positionDropdown: on,
808
+ searchAble: !!N,
802
809
  value: c,
803
810
  onSearch: m,
804
811
  ref: h,
805
812
  multiSelect: o,
806
- searchValue: L,
813
+ searchValue: R,
807
814
  highlightedIndex: x,
808
815
  footer: a,
809
- groupLabel: R,
810
- onSelectAll: W
816
+ groupLabel: z,
817
+ onSelectAll: O
811
818
  }
812
819
  )
813
820
  ]
814
821
  }
815
822
  ) });
816
- return z ? S === "outside-left" ? /* @__PURE__ */ l("div", { className: "sa-select-field sa-select-field-left", children: [
823
+ return k ? nn === "outside-left" ? /* @__PURE__ */ l("div", { className: `${$} sa-select-field-left`, children: [
817
824
  /* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
818
825
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
819
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: z }),
820
- Z && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
821
- U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
826
+ /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: k }),
827
+ Q && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
828
+ Z && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
822
829
  ] }),
823
- N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N })
830
+ E && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: E })
824
831
  ] }),
825
832
  /* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
826
- K,
827
- E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
833
+ U,
834
+ C && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: C }),
828
835
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
829
836
  ] })
830
- ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
837
+ ] }) : /* @__PURE__ */ l("div", { className: $, children: [
831
838
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
832
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: z }),
833
- Z && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
834
- U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
839
+ /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: k }),
840
+ Q && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
841
+ Z && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
835
842
  ] }),
836
- N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
837
- K,
838
- E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
843
+ E && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: E }),
844
+ U,
845
+ C && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: C }),
839
846
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
840
- ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
841
- N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
842
- K,
843
- E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
847
+ ] }) : /* @__PURE__ */ l("div", { className: $, children: [
848
+ E && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: E }),
849
+ U,
850
+ C && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: C }),
844
851
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
845
852
  ] });
846
- }, Y = (e, p, d) => {
853
+ }, _ = (e, p, d) => {
847
854
  const s = e.length;
848
855
  let r = p + d;
849
856
  for (; r >= 0 && r < s; ) {
@@ -860,7 +867,7 @@ const mn = ({
860
867
  if (!e[o].disable)
861
868
  return o;
862
869
  return -1;
863
- }, fn = (e) => /* @__PURE__ */ n(
870
+ }, gn = (e) => /* @__PURE__ */ n(
864
871
  "svg",
865
872
  {
866
873
  xmlns: "http://www.w3.org/2000/svg",
@@ -881,7 +888,7 @@ const mn = ({
881
888
  }
882
889
  )
883
890
  }
884
- ), bn = ({ width: e = 16 }) => /* @__PURE__ */ n(
891
+ ), xn = ({ width: e = 16 }) => /* @__PURE__ */ n(
885
892
  "svg",
886
893
  {
887
894
  xmlns: "http://www.w3.org/2000/svg",
@@ -901,7 +908,7 @@ const mn = ({
901
908
  }
902
909
  )
903
910
  }
904
- ), gn = ({ width: e = 16 }) => /* @__PURE__ */ n(
911
+ ), vn = ({ width: e = 16 }) => /* @__PURE__ */ n(
905
912
  "svg",
906
913
  {
907
914
  xmlns: "http://www.w3.org/2000/svg",
@@ -923,5 +930,5 @@ const mn = ({
923
930
  }
924
931
  );
925
932
  export {
926
- mn as Dropdown
933
+ yn as Dropdown
927
934
  };
@@ -1,4 +1,4 @@
1
- (function(g,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(g=typeof globalThis<"u"?globalThis:g||self,n(g.Dropdown={},g.jsxRuntime,g.React))})(this,function(g,n,d){"use strict";const X=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
1
+ (function(g,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(g=typeof globalThis<"u"?globalThis:g||self,n(g.Dropdown={},g.jsxRuntime,g.React))})(this,function(g,n,d){"use strict";const Y=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
2
2
  * {
3
3
  margin: 0;
4
4
  padding: 0;
@@ -364,9 +364,12 @@
364
364
  display: flex;
365
365
  flex-direction: column;
366
366
  gap: 6px;
367
- width: 100%;
367
+ width: max-content;
368
368
  font-family: "Poppins", sans-serif;
369
369
  }
370
+ .sa-select-field-fullwidth {
371
+ width: 100%;
372
+ }
370
373
  .sa-select-field-left {
371
374
  flex-direction: row;
372
375
  align-items: flex-start;
@@ -445,4 +448,4 @@
445
448
  margin: 0;
446
449
  }
447
450
 
448
- `;function Y(e){const[p,i]=d.useState(e),l=d.useRef(null),r=o=>{l.current&&!l.current.contains(o.target)&&i(!1)};return d.useEffect(()=>(document.addEventListener("click",r,!0),()=>{document.removeEventListener("click",r,!0)}),[]),{ref:l,isComponentVisible:p,setIsComponentVisible:i}}const _=({...e})=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...e,viewBox:"0 0 20 20",fill:"none",children:[n.jsx("circle",{cx:"9.80547",cy:"9.8055",r:"7.49047",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M15.0153 15.4043L17.9519 18.3333",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),R=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:n.jsx("path",{d:"M3.5 8L6.5 11L12.5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),nn=d.forwardRef(({positionDropdown:e,dropdownLists:p,isComponentVisible:i,searchAble:l,onSearch:r,value:o,handleChangeValue:y,multiSelect:f,searchValue:F,highlightedIndex:k,footer:I,groupLabel:D,onSelectAll:A},H)=>{const S=d.useRef([]);d.useEffect(()=>{var a;k>=0&&S.current[k]&&((a=S.current[k])==null||a.scrollIntoView({block:"nearest"}))},[k]);const O=l?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(_,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:a=>{r&&r(a.target.value)},value:F,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:i?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:a=>a.stopPropagation(),ref:H,children:[e!=="top"&&O,n.jsxs("div",{className:`sa-input-dropdwon-item-container ${f?"multi":""}`,children:[D&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:D}),f&&A&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),A()},children:"Select all"})]}),p.map((a,L)=>{const P=!!(o!=null&&o.find(B=>B.value===a.value)),z=!!a.description;return n.jsxs("div",{className:["sa-input-dropdwon-item",z?"has-description":"",P?"active":"",L===k?"highlight":"",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),ref:B=>{S.current[L]=B},onClick:()=>y(a.label,a.value),children:[f&&n.jsx("div",{className:"sa-input-dropdwon-item-check",children:P&&n.jsx(R,{width:16})}),a.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:d.cloneElement(a.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdwon-item-text",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),children:a.label}),a.description&&n.jsx("p",{className:["sa-input-dropdwon-item-text-description",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),children:a.description})]})]},L)})]}),e==="top"&&O,I&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:a=>a.stopPropagation(),children:I})]}):null})}),en=({children:e,handleChangePosition:p})=>{const i=d.useRef(null);d.useEffect(()=>{var y;const r=()=>{if(i.current){let f=i.current.parentElement;for(;f&&!l(f);)f=f.parentElement;f&&p()}};let o=(y=i.current)==null?void 0:y.parentElement;for(;o&&!l(o);)o=o.parentElement;return o&&o.addEventListener("scroll",r),r(),()=>{o&&o.removeEventListener("scroll",r)}},[]);const l=r=>r&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth);return n.jsx("div",{ref:i,children:e})},K="sa-input-dropdown-styles";(e=>{if(!document.getElementById(K)){const p=document.createElement("style");p.id=K,p.textContent=e,document.head.appendChild(p)}})(X);const on=({dropdownLists:e,onChange:p,defaultValue:i,value:l,size:r="md",multiSelect:o,searchAble:y,iconLeft:f,placeholder:F,onSearch:k,error:I,onBlur:D,onFocus:A,disable:H,searchValue:S,variant:O="outline",footer:a,groupLabel:L,onSelectAll:P,label:z,labelPosition:B="outside-top",required:T,optional:Z,description:E,helperText:N,errorText:w})=>{const C=l!==void 0,M=d.useRef(),dn=I||!!w,[c,j]=d.useState(C?l||[]:i||[]),[tn,Q]=d.useState(""),[x,q]=d.useState(-1),h=d.useRef(null),{isComponentVisible:u,ref:$,setIsComponentVisible:W}=Y(!1),ln=()=>{W(s=>!s)},V=(s,t)=>{if(o)if(c==null?void 0:c.find(b=>b.value===t)){const b=c.filter(fn=>fn.value!==t);C||j(b),p(b)}else{const b=[...c,{label:s,value:t}];C||j(b),p(b)}else{const v=[{label:s,value:t}];C||j(v),p(v),W(!1)}};d.useEffect(()=>{C&&j(l||[])},[l]),d.useEffect(()=>{C||JSON.stringify(M.current)===JSON.stringify(i)||(M.current=i,j(M.current||[]))},[i]);const pn=()=>c.length?o?c==null?void 0:c.map((s,t)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:s==null?void 0:s.label}),n.jsx(rn,{onClick:v=>{v.stopPropagation(),V(s.label,s.value)}})]},t)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:F}),m=()=>{if($.current&&h.current){const s=window.innerHeight,t=$.current.getBoundingClientRect(),v=h.current.getBoundingClientRect(),b=t.bottom+v.height;h.current.style.left=`${t.left}px`,h.current.style.width=`${t.width}px`,b>=s-10?(h.current.style.top=`${t.top-v.height-5}px`,Q("top")):(h.current.style.top=`${t.top+t.height+4}px`,Q("bottom"))}};d.useEffect(()=>(window.addEventListener("scroll",m),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m),window.removeEventListener("resize",m)}),[]),d.useEffect(()=>{m()},[u]),d.useEffect(()=>{if(!u||!h.current)return;const s=new ResizeObserver(()=>{m()});return s.observe(h.current),()=>s.disconnect()},[u]),d.useEffect(()=>{u||q(-1)},[u]);const cn=s=>{if(!u){(s.key==="ArrowDown"||s.key==="Enter")&&(s.preventDefault(),W(!0));return}switch(s.key){case"ArrowDown":{s.preventDefault();const t=U(e,x,1);t!==-1&&q(t);break}case"ArrowUp":{s.preventDefault();const t=U(e,x,-1);t!==-1&&q(t);break}case"Enter":{s.preventDefault(),x>=0&&e[x]&&!e[x].disable&&V(e[x].label,e[x].value);break}case"Escape":W(!1);break}},G=r==="lg"||r==="xl"?20:16,J=n.jsx(en,{handleChangePosition:m,children:n.jsxs("div",{className:["sa-input-dropdown-container",O,`sa-input-dropdown-size-${r}`,u?"active":"",dn?"error":"",H?"disable":""].filter(Boolean).join(" "),ref:$,onClick:ln,onKeyDown:cn,tabIndex:0,onBlur:D,onFocus:A,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[f?d.cloneElement(f,{width:G,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:pn()}),u?n.jsx(sn,{width:G}):n.jsx(an,{width:G})]}),n.jsx(nn,{dropdownLists:e,handleChangeValue:V,isComponentVisible:u,positionDropdown:tn,searchAble:!!y,value:c,onSearch:k,ref:h,multiSelect:o,searchValue:S,highlightedIndex:x,footer:a,groupLabel:L,onSelectAll:P})]})});return z?B==="outside-left"?n.jsxs("div",{className:"sa-select-field sa-select-field-left",children:[n.jsxs("div",{className:"sa-select-field-left-label",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:z}),Z&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),T&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),E&&n.jsx("p",{className:"sa-select-field-helper-top",children:E})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[J,N&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:N}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]})]}):n.jsxs("div",{className:"sa-select-field",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:z}),Z&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),T&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),E&&n.jsx("p",{className:"sa-select-field-helper-top",children:E}),J,N&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:N}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]}):n.jsxs("div",{className:"sa-select-field",children:[E&&n.jsx("p",{className:"sa-select-field-helper-top",children:E}),J,N&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:N}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]})},U=(e,p,i)=>{const l=e.length;let r=p+i;for(;r>=0&&r<l;){if(!e[r].disable)return r;r+=i}if(i===1){for(let o=0;o<l;o++)if(!e[o].disable)return o}else for(let o=l-1;o>=0;o--)if(!e[o].disable)return o;return-1},rn=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 18 18",fill:"none",style:{flexShrink:0,cursor:"pointer"},...e,children:n.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),an=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),sn=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});g.Dropdown=on,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
451
+ `;function _(e){const[p,i]=d.useState(e),l=d.useRef(null),r=o=>{l.current&&!l.current.contains(o.target)&&i(!1)};return d.useEffect(()=>(document.addEventListener("click",r,!0),()=>{document.removeEventListener("click",r,!0)}),[]),{ref:l,isComponentVisible:p,setIsComponentVisible:i}}const R=({...e})=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...e,viewBox:"0 0 20 20",fill:"none",children:[n.jsx("circle",{cx:"9.80547",cy:"9.8055",r:"7.49047",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M15.0153 15.4043L17.9519 18.3333",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),nn=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:n.jsx("path",{d:"M3.5 8L6.5 11L12.5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),en=d.forwardRef(({positionDropdown:e,dropdownLists:p,isComponentVisible:i,searchAble:l,onSearch:r,value:o,handleChangeValue:E,multiSelect:f,searchValue:W,highlightedIndex:k,footer:j,groupLabel:I,onSelectAll:D},F)=>{const L=d.useRef([]);d.useEffect(()=>{var a;k>=0&&L.current[k]&&((a=L.current[k])==null||a.scrollIntoView({block:"nearest"}))},[k]);const A=l?n.jsxs("div",{className:"sa-input-dropdown-container-dropdown-search",children:[n.jsx(R,{strokeWidth:2,width:16,style:{flexShrink:0,color:"var(--sa-dropdown-placeholder-subtle)"}}),n.jsx("input",{onChange:a=>{r&&r(a.target.value)},value:W,autoFocus:!0,placeholder:"Search..."})]}):null;return n.jsx(n.Fragment,{children:i?n.jsxs("div",{className:"sa-input-dropdown-lists-container",onClick:a=>a.stopPropagation(),ref:F,children:[e!=="top"&&A,n.jsxs("div",{className:`sa-input-dropdwon-item-container ${f?"multi":""}`,children:[I&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:I}),f&&D&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),D()},children:"Select all"})]}),p.map((a,z)=>{const O=!!(o!=null&&o.find(m=>m.value===a.value)),H=!!a.description;return n.jsxs("div",{className:["sa-input-dropdwon-item",H?"has-description":"",O?"active":"",z===k?"highlight":"",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),ref:m=>{L.current[z]=m},onClick:()=>E(a.label,a.value),children:[f&&n.jsx("div",{className:"sa-input-dropdwon-item-check",children:O&&n.jsx(nn,{width:16})}),a.icon&&n.jsx("div",{style:{flexShrink:0,display:"flex"},children:d.cloneElement(a.icon,{width:16})}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("p",{className:["sa-input-dropdwon-item-text",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),children:a.label}),a.description&&n.jsx("p",{className:["sa-input-dropdwon-item-text-description",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),children:a.description})]})]},z)})]}),e==="top"&&A,j&&n.jsx("div",{className:"sa-input-dropdown-footer",onClick:a=>a.stopPropagation(),children:j})]}):null})}),on=({children:e,handleChangePosition:p})=>{const i=d.useRef(null);d.useEffect(()=>{var E;const r=()=>{if(i.current){let f=i.current.parentElement;for(;f&&!l(f);)f=f.parentElement;f&&p()}};let o=(E=i.current)==null?void 0:E.parentElement;for(;o&&!l(o);)o=o.parentElement;return o&&o.addEventListener("scroll",r),r(),()=>{o&&o.removeEventListener("scroll",r)}},[]);const l=r=>r&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth);return n.jsx("div",{ref:i,children:e})},U="sa-input-dropdown-styles";(e=>{if(!document.getElementById(U)){const p=document.createElement("style");p.id=U,p.textContent=e,document.head.appendChild(p)}})(Y);const rn=({dropdownLists:e,onChange:p,defaultValue:i,value:l,size:r="md",multiSelect:o,searchAble:E,iconLeft:f,placeholder:W,onSearch:k,error:j,onBlur:I,onFocus:D,disable:F,searchValue:L,variant:A="outline",footer:a,groupLabel:z,onSelectAll:O,fullWidth:H=!1,label:m,labelPosition:tn="outside-top",required:Z,optional:Q,description:N,helperText:C,errorText:w})=>{const M=["sa-select-field",H?"sa-select-field-fullwidth":""].filter(Boolean).join(" "),S=l!==void 0,$=d.useRef(),ln=j||!!w,[c,B]=d.useState(S?l||[]:i||[]),[pn,X]=d.useState(""),[x,q]=d.useState(-1),h=d.useRef(null),{isComponentVisible:u,ref:V,setIsComponentVisible:P}=_(!1),cn=()=>{P(s=>!s)},G=(s,t)=>{if(o)if(c==null?void 0:c.find(b=>b.value===t)){const b=c.filter(hn=>hn.value!==t);S||B(b),p(b)}else{const b=[...c,{label:s,value:t}];S||B(b),p(b)}else{const v=[{label:s,value:t}];S||B(v),p(v),P(!1)}};d.useEffect(()=>{S&&B(l||[])},[l]),d.useEffect(()=>{S||JSON.stringify($.current)===JSON.stringify(i)||($.current=i,B($.current||[]))},[i]);const fn=()=>c.length?o?c==null?void 0:c.map((s,t)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:s==null?void 0:s.label}),n.jsx(an,{onClick:v=>{v.stopPropagation(),G(s.label,s.value)}})]},t)):n.jsx("p",{style:{minWidth:"max-content"},children:c==null?void 0:c[0].label}):n.jsx("p",{className:"sa-input-dropdown-placeholder",children:W}),y=()=>{if(V.current&&h.current){const s=window.innerHeight,t=V.current.getBoundingClientRect(),v=h.current.getBoundingClientRect(),b=t.bottom+v.height;h.current.style.left=`${t.left}px`,h.current.style.width=`${t.width}px`,b>=s-10?(h.current.style.top=`${t.top-v.height-5}px`,X("top")):(h.current.style.top=`${t.top+t.height+4}px`,X("bottom"))}};d.useEffect(()=>(window.addEventListener("scroll",y),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y),window.removeEventListener("resize",y)}),[]),d.useEffect(()=>{y()},[u]),d.useEffect(()=>{if(!u||!h.current)return;const s=new ResizeObserver(()=>{y()});return s.observe(h.current),()=>s.disconnect()},[u]),d.useEffect(()=>{u||q(-1)},[u]);const wn=s=>{if(!u){(s.key==="ArrowDown"||s.key==="Enter")&&(s.preventDefault(),P(!0));return}switch(s.key){case"ArrowDown":{s.preventDefault();const t=T(e,x,1);t!==-1&&q(t);break}case"ArrowUp":{s.preventDefault();const t=T(e,x,-1);t!==-1&&q(t);break}case"Enter":{s.preventDefault(),x>=0&&e[x]&&!e[x].disable&&G(e[x].label,e[x].value);break}case"Escape":P(!1);break}},J=r==="lg"||r==="xl"?20:16,K=n.jsx(on,{handleChangePosition:y,children:n.jsxs("div",{className:["sa-input-dropdown-container",A,`sa-input-dropdown-size-${r}`,u?"active":"",ln?"error":"",F?"disable":""].filter(Boolean).join(" "),ref:V,onClick:cn,onKeyDown:wn,tabIndex:0,onBlur:I,onFocus:D,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[f?d.cloneElement(f,{width:J,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:fn()}),u?n.jsx(dn,{width:J}):n.jsx(sn,{width:J})]}),n.jsx(en,{dropdownLists:e,handleChangeValue:G,isComponentVisible:u,positionDropdown:pn,searchAble:!!E,value:c,onSearch:k,ref:h,multiSelect:o,searchValue:L,highlightedIndex:x,footer:a,groupLabel:z,onSelectAll:O})]})});return m?tn==="outside-left"?n.jsxs("div",{className:`${M} sa-select-field-left`,children:[n.jsxs("div",{className:"sa-select-field-left-label",children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:m}),Q&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),Z&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[K,C&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:C}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]})]}):n.jsxs("div",{className:M,children:[n.jsxs("div",{className:"sa-select-field-label-row",children:[n.jsx("span",{className:"sa-select-field-label-text",children:m}),Q&&n.jsx("span",{className:"sa-select-field-optional-badge",children:"Optional"}),Z&&n.jsx("span",{className:"sa-select-field-required",children:"*"})]}),N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N}),K,C&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:C}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]}):n.jsxs("div",{className:M,children:[N&&n.jsx("p",{className:"sa-select-field-helper-top",children:N}),K,C&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:C}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]})},T=(e,p,i)=>{const l=e.length;let r=p+i;for(;r>=0&&r<l;){if(!e[r].disable)return r;r+=i}if(i===1){for(let o=0;o<l;o++)if(!e[o].disable)return o}else for(let o=l-1;o>=0;o--)if(!e[o].disable)return o;return-1},an=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 18 18",fill:"none",style:{flexShrink:0,cursor:"pointer"},...e,children:n.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),sn=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),dn=({width:e=16})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",fill:"none",style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0},children:n.jsx("path",{d:"M4 10L8 6L12 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});g.Dropdown=rn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
@@ -40,6 +40,7 @@ export interface IDropdown {
40
40
  footer?: React.ReactNode;
41
41
  groupLabel?: string;
42
42
  onSelectAll?: () => void;
43
+ fullWidth?: boolean;
43
44
  label?: React.ReactNode;
44
45
  labelPosition?: DropdownLabelPosition;
45
46
  required?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "3.5.2",
3
+ "version": "4.0.0",
4
4
  "description": "dropdown component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/dropdown.umd.js",