@starasia/dropdown 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
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 x, forwardRef as dn } from "react";
2
+ import _, { useState as F, useRef as I, useEffect as g, forwardRef as dn } from "react";
3
3
  const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
4
4
  * {
5
5
  margin: 0;
@@ -9,26 +9,28 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
9
9
  }
10
10
 
11
11
  :root {
12
+ /* Component tokens — all values point to semantic tokens (Layer 2)
13
+ with primitive/raw fallbacks so the component still renders if the
14
+ theme stylesheet hasn't been loaded yet. */
12
15
  --sa-dropdown-brand: var(--sa-border-brand, #031f43);
13
16
  --sa-dropdown-brand-ring: var(--sa-color-brand-100, #90caf9);
14
- --sa-dropdown-brand-subtle: var(--sa-color-brand-200, #99b3db);
15
17
  --sa-dropdown-bg: var(--sa-background-primary, #ffffff);
16
18
  --sa-dropdown-bg-neutral: var(--sa-background-neutral, #f0f1f2);
17
- --sa-dropdown-bg-selected: #f8f8f8;
18
- --sa-dropdown-bg-hover: rgba(0, 0, 0, 0.04);
19
+ --sa-dropdown-bg-selected: var(--sa-background-primary-inverse, #f8f8f8);
20
+ --sa-dropdown-bg-hover: var(--sa-color-black-alpha-a5, rgba(0, 0, 0, 0.03));
19
21
  --sa-dropdown-bg-disabled: var(--sa-background-neutral, #f0f1f2);
20
- --sa-dropdown-bg-error: #fff0f3;
21
- --sa-dropdown-border-subtle: rgba(11, 18, 14, 0.14);
22
+ --sa-dropdown-bg-error: var(--sa-background-error-subtlest, #fff0f3);
23
+ --sa-dropdown-bg-chip: var(--sa-background-brand-subtlest, #e6edf6);
24
+ --sa-dropdown-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
22
25
  --sa-dropdown-border-active: var(--sa-border-brand, #031f43);
23
- --sa-dropdown-border-error-subtle: #ffb3c1;
24
- --sa-dropdown-border-error: var(--sa-color-error-500, #ff4d6d);
25
- --sa-dropdown-color-disable: var(--sa-color-gray-300, #dddee1);
26
+ --sa-dropdown-border-error-subtle: var(--sa-border-danger-subtle, #ffb3c1);
27
+ --sa-dropdown-color-disable: var(--sa-text-disable, rgba(24, 26, 25, 0.56));
26
28
  --sa-dropdown-placeholder: var(--sa-text-subtle, #505258);
27
- --sa-dropdown-placeholder-subtle: #6b6e76;
29
+ --sa-dropdown-placeholder-subtle: var(--sa-text-subtlest, #6b6e76);
28
30
  --sa-dropdown-text-primary: var(--sa-text-primary, #292a2e);
29
- --sa-dropdown-text-secondary: #6b6e76;
30
- --sa-dropdown-text-error: #a4133c;
31
- --sa-dropdown-text-info: #0073ab;
31
+ --sa-dropdown-text-secondary: var(--sa-text-subtlest, #6b6e76);
32
+ --sa-dropdown-text-error: var(--sa-text-error, #a4133c);
33
+ --sa-dropdown-text-info: var(--sa-text-info, #0073ab);
32
34
  --sa-dropdown-ring-active: 0px 0px 0px 1.2px var(--sa-dropdown-brand-ring);
33
35
  --sa-dropdown-shadow-panel: 0px 8px 12px 0px rgba(30, 31, 33, 0.15), 0px 0px 1px 0px rgba(30, 31, 33, 0.31);
34
36
  --sa-dropdown-radius: var(--sa-radii-sm, 6px);
@@ -176,7 +178,7 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
176
178
  padding-inline: 8px;
177
179
  padding-block: 2px;
178
180
  border-radius: 4px;
179
- background-color: var(--sa-color-brand-50, #e6edf6);
181
+ background-color: var(--sa-dropdown-bg-chip);
180
182
  color: var(--sa-dropdown-brand);
181
183
  height: max-content;
182
184
  font-size: 12px;
@@ -444,86 +446,13 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
444
446
  margin: 0;
445
447
  }
446
448
 
447
- /* === CHECKBOX === */
448
- .checkbox-wrapper-30 .checkbox {
449
- --bg: #fff;
450
- --brdr: #d1d6ee;
451
- --brdr-actv: var(--sa-background-brand, #04254f);
452
- --brdr-hovr: #bbc1e1;
453
- --dur: calc((var(--size, 2) / 2) * 0.6s);
454
- display: inline-block;
455
- width: 16px;
456
- height: 16px;
457
- position: relative;
458
- }
459
- .checkbox-wrapper-30 .checkbox:after {
460
- content: "";
461
- width: 100%;
462
- padding-top: 100%;
463
- display: block;
464
- }
465
- .checkbox-wrapper-30 .checkbox > * {
466
- position: absolute;
467
- }
468
- .checkbox-wrapper-30 .checkbox input {
469
- -webkit-appearance: none;
470
- -moz-appearance: none;
471
- -webkit-tap-highlight-color: transparent;
472
- cursor: pointer;
473
- background-color: var(--newBgClr, var(--bg));
474
- border-radius: calc(var(--size, 1) * 4px);
475
- border: calc(var(--newBrdr, var(--size, 1)) * 1px) solid;
476
- color: var(--newBrdrClr, var(--brdr));
477
- outline: none;
478
- margin: 0;
479
- padding: 0;
480
- transition: all calc(var(--dur) / 3) linear;
481
- }
482
- .checkbox-wrapper-30 .checkbox input:hover,
483
- .checkbox-wrapper-30 .checkbox input:checked {
484
- --newBrdr: calc(var(--size, 1) * 2);
485
- }
486
- .checkbox-wrapper-30 .checkbox input:hover {
487
- --newBrdrClr: var(--brdr-hovr);
488
- }
489
- .checkbox-wrapper-30 .checkbox input:checked {
490
- --newBrdrClr: var(--brdr-actv);
491
- --newBgClr: var(--brdr-actv);
492
- }
493
- .checkbox-wrapper-30 .checkbox input:checked + svg {
494
- --dashArray: 16 93;
495
- --dashOffset: 109;
496
- }
497
- .checkbox-wrapper-30 .checkbox input:checked + svg {
498
- color: white;
499
- transition-delay: 0.1s;
500
- }
501
- .checkbox-wrapper-30 .checkbox svg {
502
- fill: none;
503
- left: 0;
504
- pointer-events: none;
505
- stroke: var(--stroke, var(--border-active));
506
- stroke-dasharray: var(--dashArray, 93);
507
- stroke-dashoffset: var(--dashOffset, 94);
508
- stroke-linecap: round;
509
- stroke-linejoin: round;
510
- stroke-width: 2px;
511
- top: 0;
512
- transition: stroke-dasharray var(--dur), stroke-dashoffset var(--dur);
513
- }
514
- .checkbox-wrapper-30 .checkbox svg,
515
- .checkbox-wrapper-30 .checkbox input {
516
- display: block;
517
- height: 100%;
518
- width: 100%;
519
- }
520
449
  `;
521
450
  function ln(e) {
522
- const [p, d] = F(e), s = I(null), o = (r) => {
523
- s.current && !s.current.contains(r.target) && d(!1);
451
+ const [p, d] = F(e), s = I(null), r = (o) => {
452
+ s.current && !s.current.contains(o.target) && d(!1);
524
453
  };
525
- return x(() => (document.addEventListener("click", o, !0), () => {
526
- document.removeEventListener("click", o, !0);
454
+ return g(() => (document.addEventListener("click", r, !0), () => {
455
+ document.removeEventListener("click", r, !0);
527
456
  }), []), { ref: s, isComponentVisible: p, setIsComponentVisible: d };
528
457
  }
529
458
  const pn = ({ ...e }) => /* @__PURE__ */ l(
@@ -577,34 +506,34 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
577
506
  }
578
507
  )
579
508
  }
580
- ), hn = dn(
509
+ ), un = dn(
581
510
  ({
582
511
  positionDropdown: e,
583
512
  dropdownLists: p,
584
513
  isComponentVisible: d,
585
514
  searchAble: s,
586
- onSearch: o,
587
- value: r,
515
+ onSearch: r,
516
+ value: o,
588
517
  handleChangeValue: y,
589
- multiSelect: h,
518
+ multiSelect: u,
590
519
  searchValue: H,
591
520
  highlightedIndex: m,
592
521
  footer: A,
593
- groupLabel: O,
522
+ groupLabel: D,
594
523
  onSelectAll: j
595
524
  }, M) => {
596
- const z = I([]);
597
- x(() => {
525
+ const L = I([]);
526
+ g(() => {
598
527
  var a;
599
- m >= 0 && z.current[m] && ((a = z.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
528
+ m >= 0 && L.current[m] && ((a = L.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
600
529
  }, [m]);
601
- const D = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
530
+ const O = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
602
531
  /* @__PURE__ */ n(pn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
603
532
  /* @__PURE__ */ n(
604
533
  "input",
605
534
  {
606
535
  onChange: (a) => {
607
- o && o(a.target.value);
536
+ r && r(a.target.value);
608
537
  },
609
538
  value: H,
610
539
  autoFocus: !0,
@@ -619,15 +548,15 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
619
548
  onClick: (a) => a.stopPropagation(),
620
549
  ref: M,
621
550
  children: [
622
- e !== "top" && D,
551
+ e !== "top" && O,
623
552
  /* @__PURE__ */ l(
624
553
  "div",
625
554
  {
626
- className: `sa-input-dropdwon-item-container ${h ? "multi" : ""}`,
555
+ className: `sa-input-dropdwon-item-container ${u ? "multi" : ""}`,
627
556
  children: [
628
- O && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
629
- /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: O }),
630
- h && j && /* @__PURE__ */ n(
557
+ D && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
558
+ /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: D }),
559
+ u && j && /* @__PURE__ */ n(
631
560
  "button",
632
561
  {
633
562
  className: "sa-input-dropdown-section-select-all",
@@ -638,24 +567,24 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
638
567
  }
639
568
  )
640
569
  ] }),
641
- p.map((a, B) => {
642
- const W = !!(r != null && r.find((L) => L.value === a.value)), R = !!a.description;
570
+ p.map((a, R) => {
571
+ const W = !!(o != null && o.find((S) => S.value === a.value)), z = !!a.description;
643
572
  return /* @__PURE__ */ l(
644
573
  "div",
645
574
  {
646
575
  className: [
647
576
  "sa-input-dropdwon-item",
648
- R ? "has-description" : "",
577
+ z ? "has-description" : "",
649
578
  W ? "active" : "",
650
- B === m ? "highlight" : "",
579
+ R === m ? "highlight" : "",
651
580
  a.disable ? "sa-input-dropdwon-item-disable" : ""
652
581
  ].filter(Boolean).join(" "),
653
- ref: (L) => {
654
- z.current[B] = L;
582
+ ref: (S) => {
583
+ L.current[R] = S;
655
584
  },
656
585
  onClick: () => y(a.label, a.value),
657
586
  children: [
658
- h && /* @__PURE__ */ n("div", { className: "sa-input-dropdwon-item-check", children: W && /* @__PURE__ */ n(cn, { width: 16 }) }),
587
+ u && /* @__PURE__ */ n("div", { className: "sa-input-dropdwon-item-check", children: W && /* @__PURE__ */ n(cn, { width: 16 }) }),
659
588
  a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: _.cloneElement(a.icon, { width: 16 }) }),
660
589
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
661
590
  /* @__PURE__ */ n(
@@ -681,13 +610,13 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
681
610
  ] })
682
611
  ]
683
612
  },
684
- B
613
+ R
685
614
  );
686
615
  })
687
616
  ]
688
617
  }
689
618
  ),
690
- e === "top" && D,
619
+ e === "top" && O,
691
620
  A && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: A })
692
621
  ]
693
622
  }
@@ -698,115 +627,115 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
698
627
  handleChangePosition: p
699
628
  }) => {
700
629
  const d = I(null);
701
- x(() => {
630
+ g(() => {
702
631
  var y;
703
- const o = () => {
632
+ const r = () => {
704
633
  if (d.current) {
705
- let h = d.current.parentElement;
706
- for (; h && !s(h); )
707
- h = h.parentElement;
708
- h && p();
634
+ let u = d.current.parentElement;
635
+ for (; u && !s(u); )
636
+ u = u.parentElement;
637
+ u && p();
709
638
  }
710
639
  };
711
- let r = (y = d.current) == null ? void 0 : y.parentElement;
712
- for (; r && !s(r); )
713
- r = r.parentElement;
714
- return r && r.addEventListener("scroll", o), o(), () => {
715
- r && r.removeEventListener("scroll", o);
640
+ let o = (y = d.current) == null ? void 0 : y.parentElement;
641
+ for (; o && !s(o); )
642
+ o = o.parentElement;
643
+ return o && o.addEventListener("scroll", r), r(), () => {
644
+ o && o.removeEventListener("scroll", r);
716
645
  };
717
646
  }, []);
718
- const s = (o) => o && (o.scrollHeight > o.clientHeight || o.scrollWidth > o.clientWidth);
647
+ const s = (r) => r && (r.scrollHeight > r.clientHeight || r.scrollWidth > r.clientWidth);
719
648
  return /* @__PURE__ */ n("div", { ref: d, children: e });
720
- }, Q = "sa-input-dropdown-styles", un = (e) => {
721
- if (!document.getElementById(Q)) {
649
+ }, X = "sa-input-dropdown-styles", hn = (e) => {
650
+ if (!document.getElementById(X)) {
722
651
  const p = document.createElement("style");
723
- p.id = Q, p.textContent = e, document.head.appendChild(p);
652
+ p.id = X, p.textContent = e, document.head.appendChild(p);
724
653
  }
725
654
  };
726
- un(sn);
655
+ hn(sn);
727
656
  const mn = ({
728
657
  dropdownLists: e,
729
658
  onChange: p,
730
659
  defaultValue: d,
731
660
  value: s,
732
- size: o = "sm",
733
- multiSelect: r,
661
+ size: r = "md",
662
+ multiSelect: o,
734
663
  searchAble: y,
735
- iconLeft: h,
664
+ iconLeft: u,
736
665
  placeholder: H,
737
666
  onSearch: m,
738
667
  error: A,
739
- onBlur: O,
668
+ onBlur: D,
740
669
  onFocus: j,
741
670
  disable: M,
742
- searchValue: z,
743
- variant: D = "outline",
671
+ searchValue: L,
672
+ variant: O = "outline",
744
673
  footer: a,
745
- groupLabel: B,
674
+ groupLabel: R,
746
675
  onSelectAll: W,
747
676
  /* field wrapper */
748
- label: R,
749
- labelPosition: L = "outside-top",
677
+ label: z,
678
+ labelPosition: S = "outside-top",
750
679
  required: U,
751
- optional: X,
680
+ optional: Z,
752
681
  description: N,
753
682
  helperText: E,
754
683
  errorText: w
755
684
  }) => {
756
- const C = s !== void 0, $ = I(), T = A || !!w, [c, S] = F(
685
+ const C = s !== void 0, $ = I(), T = A || !!w, [c, B] = F(
757
686
  C ? s || [] : d || []
758
- ), [nn, Z] = F(""), [g, V] = F(-1), u = I(null), { isComponentVisible: f, ref: q, setIsComponentVisible: P } = ln(!1), en = () => {
687
+ ), [nn, Q] = F(""), [x, V] = F(-1), h = I(null), { isComponentVisible: f, ref: q, setIsComponentVisible: P } = ln(!1), en = () => {
759
688
  P((t) => !t);
760
- }, K = (t, i) => {
761
- if (r)
689
+ }, G = (t, i) => {
690
+ if (o)
762
691
  if (c == null ? void 0 : c.find((b) => b.value === i)) {
763
692
  const b = c.filter((an) => an.value !== i);
764
- C || S(b), p(b);
693
+ C || B(b), p(b);
765
694
  } else {
766
695
  const b = [...c, { label: t, value: i }];
767
- C || S(b), p(b);
696
+ C || B(b), p(b);
768
697
  }
769
698
  else {
770
699
  const v = [{ label: t, value: i }];
771
- C || S(v), p(v), P(!1);
700
+ C || B(v), p(v), P(!1);
772
701
  }
773
702
  };
774
- x(() => {
775
- C && S(s || []);
776
- }, [s]), x(() => {
777
- C || JSON.stringify($.current) === JSON.stringify(d) || ($.current = d, S($.current || []));
703
+ g(() => {
704
+ C && B(s || []);
705
+ }, [s]), g(() => {
706
+ C || JSON.stringify($.current) === JSON.stringify(d) || ($.current = d, B($.current || []));
778
707
  }, [d]);
779
- const rn = () => c.length ? r ? c == null ? void 0 : c.map((t, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
708
+ const on = () => c.length ? o ? c == null ? void 0 : c.map((t, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
780
709
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: t == null ? void 0 : t.label }),
781
710
  /* @__PURE__ */ n(
782
711
  fn,
783
712
  {
784
713
  onClick: (v) => {
785
- v.stopPropagation(), K(t.label, t.value);
714
+ v.stopPropagation(), G(t.label, t.value);
786
715
  }
787
716
  }
788
717
  )
789
718
  ] }, 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 = () => {
790
- if (q.current && u.current) {
791
- const t = window.innerHeight, i = q.current.getBoundingClientRect(), v = u.current.getBoundingClientRect(), b = i.bottom + v.height;
792
- u.current.style.left = `${i.left}px`, u.current.style.width = `${i.width}px`, b >= t - 10 ? (u.current.style.top = `${i.top - v.height - 5}px`, Z("top")) : (u.current.style.top = `${i.top + i.height + 4}px`, Z("bottom"));
719
+ if (q.current && h.current) {
720
+ const t = window.innerHeight, i = q.current.getBoundingClientRect(), v = h.current.getBoundingClientRect(), b = i.bottom + v.height;
721
+ 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"));
793
722
  }
794
723
  };
795
- x(() => (window.addEventListener("scroll", k), window.addEventListener("resize", k), () => {
724
+ g(() => (window.addEventListener("scroll", k), window.addEventListener("resize", k), () => {
796
725
  window.removeEventListener("scroll", k), window.removeEventListener("resize", k);
797
- }), []), x(() => {
726
+ }), []), g(() => {
798
727
  k();
799
- }, [f]), x(() => {
800
- if (!f || !u.current)
728
+ }, [f]), g(() => {
729
+ if (!f || !h.current)
801
730
  return;
802
731
  const t = new ResizeObserver(() => {
803
732
  k();
804
733
  });
805
- return t.observe(u.current), () => t.disconnect();
806
- }, [f]), x(() => {
734
+ return t.observe(h.current), () => t.disconnect();
735
+ }, [f]), g(() => {
807
736
  f || V(-1);
808
737
  }, [f]);
809
- const on = (t) => {
738
+ const rn = (t) => {
810
739
  if (!f) {
811
740
  (t.key === "ArrowDown" || t.key === "Enter") && (t.preventDefault(), P(!0));
812
741
  return;
@@ -814,20 +743,20 @@ const mn = ({
814
743
  switch (t.key) {
815
744
  case "ArrowDown": {
816
745
  t.preventDefault();
817
- const i = Y(e, g, 1);
746
+ const i = Y(e, x, 1);
818
747
  i !== -1 && V(i);
819
748
  break;
820
749
  }
821
750
  case "ArrowUp": {
822
751
  t.preventDefault();
823
- const i = Y(e, g, -1);
752
+ const i = Y(e, x, -1);
824
753
  i !== -1 && V(i);
825
754
  break;
826
755
  }
827
756
  case "Enter": {
828
- t.preventDefault(), g >= 0 && e[g] && !e[g].disable && K(
829
- e[g].label,
830
- e[g].value
757
+ t.preventDefault(), x >= 0 && e[x] && !e[x].disable && G(
758
+ e[x].label,
759
+ e[x].value
831
760
  );
832
761
  break;
833
762
  }
@@ -835,100 +764,100 @@ const mn = ({
835
764
  P(!1);
836
765
  break;
837
766
  }
838
- }, G = o === "lg" || o === "xl" ? 20 : 16, J = /* @__PURE__ */ n(wn, { handleChangePosition: k, children: /* @__PURE__ */ l(
767
+ }, J = r === "lg" || r === "xl" ? 20 : 16, K = /* @__PURE__ */ n(wn, { handleChangePosition: k, children: /* @__PURE__ */ l(
839
768
  "div",
840
769
  {
841
770
  className: [
842
771
  "sa-input-dropdown-container",
843
- D,
844
- `sa-input-dropdown-size-${o}`,
772
+ O,
773
+ `sa-input-dropdown-size-${r}`,
845
774
  f ? "active" : "",
846
775
  T ? "error" : "",
847
776
  M ? "disable" : ""
848
777
  ].filter(Boolean).join(" "),
849
778
  ref: q,
850
779
  onClick: en,
851
- onKeyDown: on,
780
+ onKeyDown: rn,
852
781
  tabIndex: 0,
853
- onBlur: O,
782
+ onBlur: D,
854
783
  onFocus: j,
855
784
  children: [
856
785
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
857
- h ? _.cloneElement(h, {
858
- width: G,
786
+ u ? _.cloneElement(u, {
787
+ width: J,
859
788
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
860
789
  }) : null,
861
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: rn() }),
862
- f ? /* @__PURE__ */ n(xn, { width: G }) : /* @__PURE__ */ n(bn, { width: G })
790
+ /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: on() }),
791
+ f ? /* @__PURE__ */ n(gn, { width: J }) : /* @__PURE__ */ n(bn, { width: J })
863
792
  ] }),
864
793
  /* @__PURE__ */ n(
865
- hn,
794
+ un,
866
795
  {
867
796
  dropdownLists: e,
868
- handleChangeValue: K,
797
+ handleChangeValue: G,
869
798
  isComponentVisible: f,
870
799
  positionDropdown: nn,
871
800
  searchAble: !!y,
872
801
  value: c,
873
802
  onSearch: m,
874
- ref: u,
875
- multiSelect: r,
876
- searchValue: z,
877
- highlightedIndex: g,
803
+ ref: h,
804
+ multiSelect: o,
805
+ searchValue: L,
806
+ highlightedIndex: x,
878
807
  footer: a,
879
- groupLabel: B,
808
+ groupLabel: R,
880
809
  onSelectAll: W
881
810
  }
882
811
  )
883
812
  ]
884
813
  }
885
814
  ) });
886
- return R ? L === "outside-left" ? /* @__PURE__ */ l("div", { className: "sa-select-field sa-select-field-left", children: [
815
+ return z ? S === "outside-left" ? /* @__PURE__ */ l("div", { className: "sa-select-field sa-select-field-left", children: [
887
816
  /* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
888
817
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
889
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: R }),
890
- X && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
818
+ /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: z }),
819
+ Z && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
891
820
  U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
892
821
  ] }),
893
822
  N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N })
894
823
  ] }),
895
824
  /* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
896
- J,
825
+ K,
897
826
  E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
898
827
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
899
828
  ] })
900
829
  ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
901
830
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
902
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: R }),
903
- X && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
831
+ /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: z }),
832
+ Z && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
904
833
  U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
905
834
  ] }),
906
835
  N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
907
- J,
836
+ K,
908
837
  E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
909
838
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
910
839
  ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
911
840
  N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
912
- J,
841
+ K,
913
842
  E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
914
843
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
915
844
  ] });
916
845
  }, Y = (e, p, d) => {
917
846
  const s = e.length;
918
- let o = p + d;
919
- for (; o >= 0 && o < s; ) {
920
- if (!e[o].disable)
921
- return o;
922
- o += d;
847
+ let r = p + d;
848
+ for (; r >= 0 && r < s; ) {
849
+ if (!e[r].disable)
850
+ return r;
851
+ r += d;
923
852
  }
924
853
  if (d === 1) {
925
- for (let r = 0; r < s; r++)
926
- if (!e[r].disable)
927
- return r;
854
+ for (let o = 0; o < s; o++)
855
+ if (!e[o].disable)
856
+ return o;
928
857
  } else
929
- for (let r = s - 1; r >= 0; r--)
930
- if (!e[r].disable)
931
- return r;
858
+ for (let o = s - 1; o >= 0; o--)
859
+ if (!e[o].disable)
860
+ return o;
932
861
  return -1;
933
862
  }, fn = (e) => /* @__PURE__ */ n(
934
863
  "svg",
@@ -971,7 +900,7 @@ const mn = ({
971
900
  }
972
901
  )
973
902
  }
974
- ), xn = ({ width: e = 16 }) => /* @__PURE__ */ n(
903
+ ), gn = ({ width: e = 16 }) => /* @__PURE__ */ n(
975
904
  "svg",
976
905
  {
977
906
  xmlns: "http://www.w3.org/2000/svg",
@@ -1,4 +1,4 @@
1
- (function(x,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):(x=typeof globalThis<"u"?globalThis:x||self,n(x.Dropdown={},x.jsxRuntime,x.React))})(this,function(x,n,s){"use strict";const Q=`@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 X=`@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;
@@ -7,26 +7,28 @@
7
7
  }
8
8
 
9
9
  :root {
10
+ /* Component tokens — all values point to semantic tokens (Layer 2)
11
+ with primitive/raw fallbacks so the component still renders if the
12
+ theme stylesheet hasn't been loaded yet. */
10
13
  --sa-dropdown-brand: var(--sa-border-brand, #031f43);
11
14
  --sa-dropdown-brand-ring: var(--sa-color-brand-100, #90caf9);
12
- --sa-dropdown-brand-subtle: var(--sa-color-brand-200, #99b3db);
13
15
  --sa-dropdown-bg: var(--sa-background-primary, #ffffff);
14
16
  --sa-dropdown-bg-neutral: var(--sa-background-neutral, #f0f1f2);
15
- --sa-dropdown-bg-selected: #f8f8f8;
16
- --sa-dropdown-bg-hover: rgba(0, 0, 0, 0.04);
17
+ --sa-dropdown-bg-selected: var(--sa-background-primary-inverse, #f8f8f8);
18
+ --sa-dropdown-bg-hover: var(--sa-color-black-alpha-a5, rgba(0, 0, 0, 0.03));
17
19
  --sa-dropdown-bg-disabled: var(--sa-background-neutral, #f0f1f2);
18
- --sa-dropdown-bg-error: #fff0f3;
19
- --sa-dropdown-border-subtle: rgba(11, 18, 14, 0.14);
20
+ --sa-dropdown-bg-error: var(--sa-background-error-subtlest, #fff0f3);
21
+ --sa-dropdown-bg-chip: var(--sa-background-brand-subtlest, #e6edf6);
22
+ --sa-dropdown-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
20
23
  --sa-dropdown-border-active: var(--sa-border-brand, #031f43);
21
- --sa-dropdown-border-error-subtle: #ffb3c1;
22
- --sa-dropdown-border-error: var(--sa-color-error-500, #ff4d6d);
23
- --sa-dropdown-color-disable: var(--sa-color-gray-300, #dddee1);
24
+ --sa-dropdown-border-error-subtle: var(--sa-border-danger-subtle, #ffb3c1);
25
+ --sa-dropdown-color-disable: var(--sa-text-disable, rgba(24, 26, 25, 0.56));
24
26
  --sa-dropdown-placeholder: var(--sa-text-subtle, #505258);
25
- --sa-dropdown-placeholder-subtle: #6b6e76;
27
+ --sa-dropdown-placeholder-subtle: var(--sa-text-subtlest, #6b6e76);
26
28
  --sa-dropdown-text-primary: var(--sa-text-primary, #292a2e);
27
- --sa-dropdown-text-secondary: #6b6e76;
28
- --sa-dropdown-text-error: #a4133c;
29
- --sa-dropdown-text-info: #0073ab;
29
+ --sa-dropdown-text-secondary: var(--sa-text-subtlest, #6b6e76);
30
+ --sa-dropdown-text-error: var(--sa-text-error, #a4133c);
31
+ --sa-dropdown-text-info: var(--sa-text-info, #0073ab);
30
32
  --sa-dropdown-ring-active: 0px 0px 0px 1.2px var(--sa-dropdown-brand-ring);
31
33
  --sa-dropdown-shadow-panel: 0px 8px 12px 0px rgba(30, 31, 33, 0.15), 0px 0px 1px 0px rgba(30, 31, 33, 0.31);
32
34
  --sa-dropdown-radius: var(--sa-radii-sm, 6px);
@@ -174,7 +176,7 @@
174
176
  padding-inline: 8px;
175
177
  padding-block: 2px;
176
178
  border-radius: 4px;
177
- background-color: var(--sa-color-brand-50, #e6edf6);
179
+ background-color: var(--sa-dropdown-bg-chip);
178
180
  color: var(--sa-dropdown-brand);
179
181
  height: max-content;
180
182
  font-size: 12px;
@@ -442,77 +444,4 @@
442
444
  margin: 0;
443
445
  }
444
446
 
445
- /* === CHECKBOX === */
446
- .checkbox-wrapper-30 .checkbox {
447
- --bg: #fff;
448
- --brdr: #d1d6ee;
449
- --brdr-actv: var(--sa-background-brand, #04254f);
450
- --brdr-hovr: #bbc1e1;
451
- --dur: calc((var(--size, 2) / 2) * 0.6s);
452
- display: inline-block;
453
- width: 16px;
454
- height: 16px;
455
- position: relative;
456
- }
457
- .checkbox-wrapper-30 .checkbox:after {
458
- content: "";
459
- width: 100%;
460
- padding-top: 100%;
461
- display: block;
462
- }
463
- .checkbox-wrapper-30 .checkbox > * {
464
- position: absolute;
465
- }
466
- .checkbox-wrapper-30 .checkbox input {
467
- -webkit-appearance: none;
468
- -moz-appearance: none;
469
- -webkit-tap-highlight-color: transparent;
470
- cursor: pointer;
471
- background-color: var(--newBgClr, var(--bg));
472
- border-radius: calc(var(--size, 1) * 4px);
473
- border: calc(var(--newBrdr, var(--size, 1)) * 1px) solid;
474
- color: var(--newBrdrClr, var(--brdr));
475
- outline: none;
476
- margin: 0;
477
- padding: 0;
478
- transition: all calc(var(--dur) / 3) linear;
479
- }
480
- .checkbox-wrapper-30 .checkbox input:hover,
481
- .checkbox-wrapper-30 .checkbox input:checked {
482
- --newBrdr: calc(var(--size, 1) * 2);
483
- }
484
- .checkbox-wrapper-30 .checkbox input:hover {
485
- --newBrdrClr: var(--brdr-hovr);
486
- }
487
- .checkbox-wrapper-30 .checkbox input:checked {
488
- --newBrdrClr: var(--brdr-actv);
489
- --newBgClr: var(--brdr-actv);
490
- }
491
- .checkbox-wrapper-30 .checkbox input:checked + svg {
492
- --dashArray: 16 93;
493
- --dashOffset: 109;
494
- }
495
- .checkbox-wrapper-30 .checkbox input:checked + svg {
496
- color: white;
497
- transition-delay: 0.1s;
498
- }
499
- .checkbox-wrapper-30 .checkbox svg {
500
- fill: none;
501
- left: 0;
502
- pointer-events: none;
503
- stroke: var(--stroke, var(--border-active));
504
- stroke-dasharray: var(--dashArray, 93);
505
- stroke-dashoffset: var(--dashOffset, 94);
506
- stroke-linecap: round;
507
- stroke-linejoin: round;
508
- stroke-width: 2px;
509
- top: 0;
510
- transition: stroke-dasharray var(--dur), stroke-dashoffset var(--dur);
511
- }
512
- .checkbox-wrapper-30 .checkbox svg,
513
- .checkbox-wrapper-30 .checkbox input {
514
- display: block;
515
- height: 100%;
516
- width: 100%;
517
- }
518
- `;function Y(e){const[p,i]=s.useState(e),l=s.useRef(null),o=r=>{l.current&&!l.current.contains(r.target)&&i(!1)};return s.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!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=s.forwardRef(({positionDropdown:e,dropdownLists:p,isComponentVisible:i,searchAble:l,onSearch:o,value:r,handleChangeValue:m,multiSelect:h,searchValue:F,highlightedIndex:k,footer:I,groupLabel:A,onSelectAll:D},H)=>{const z=s.useRef([]);s.useEffect(()=>{var a;k>=0&&z.current[k]&&((a=z.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=>{o&&o(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 ${h?"multi":""}`,children:[A&&n.jsxs("div",{className:"sa-input-dropdown-section-header",children:[n.jsx("span",{className:"sa-input-dropdown-section-label",children:A}),h&&D&&n.jsx("button",{className:"sa-input-dropdown-section-select-all",onClick:a=>{a.stopPropagation(),D()},children:"Select all"})]}),p.map((a,S)=>{const P=!!(r!=null&&r.find(L=>L.value===a.value)),B=!!a.description;return n.jsxs("div",{className:["sa-input-dropdwon-item",B?"has-description":"",P?"active":"",S===k?"highlight":"",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),ref:L=>{z.current[S]=L},onClick:()=>m(a.label,a.value),children:[h&&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:s.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})]})]},S)})]}),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=s.useRef(null);s.useEffect(()=>{var m;const o=()=>{if(i.current){let h=i.current.parentElement;for(;h&&!l(h);)h=h.parentElement;h&&p()}};let r=(m=i.current)==null?void 0:m.parentElement;for(;r&&!l(r);)r=r.parentElement;return r&&r.addEventListener("scroll",o),o(),()=>{r&&r.removeEventListener("scroll",o)}},[]);const l=o=>o&&(o.scrollHeight>o.clientHeight||o.scrollWidth>o.clientWidth);return n.jsx("div",{ref:i,children:e})},J="sa-input-dropdown-styles";(e=>{if(!document.getElementById(J)){const p=document.createElement("style");p.id=J,p.textContent=e,document.head.appendChild(p)}})(Q);const rn=({dropdownLists:e,onChange:p,defaultValue:i,value:l,size:o="sm",multiSelect:r,searchAble:m,iconLeft:h,placeholder:F,onSearch:k,error:I,onBlur:A,onFocus:D,disable:H,searchValue:z,variant:O="outline",footer:a,groupLabel:S,onSelectAll:P,label:B,labelPosition:L="outside-top",required:T,optional:X,description:E,helperText:N,errorText:w})=>{const C=l!==void 0,M=s.useRef(),sn=I||!!w,[c,j]=s.useState(C?l||[]:i||[]),[tn,Z]=s.useState(""),[g,q]=s.useState(-1),f=s.useRef(null),{isComponentVisible:b,ref:$,setIsComponentVisible:W}=Y(!1),ln=()=>{W(d=>!d)},V=(d,t)=>{if(r)if(c==null?void 0:c.find(u=>u.value===t)){const u=c.filter(hn=>hn.value!==t);C||j(u),p(u)}else{const u=[...c,{label:d,value:t}];C||j(u),p(u)}else{const v=[{label:d,value:t}];C||j(v),p(v),W(!1)}};s.useEffect(()=>{C&&j(l||[])},[l]),s.useEffect(()=>{C||JSON.stringify(M.current)===JSON.stringify(i)||(M.current=i,j(M.current||[]))},[i]);const pn=()=>c.length?r?c==null?void 0:c.map((d,t)=>n.jsxs("div",{className:"sa-input-dropdown-preview-item",children:[n.jsx("p",{style:{minWidth:"max-content"},children:d==null?void 0:d.label}),n.jsx(on,{onClick:v=>{v.stopPropagation(),V(d.label,d.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}),y=()=>{if($.current&&f.current){const d=window.innerHeight,t=$.current.getBoundingClientRect(),v=f.current.getBoundingClientRect(),u=t.bottom+v.height;f.current.style.left=`${t.left}px`,f.current.style.width=`${t.width}px`,u>=d-10?(f.current.style.top=`${t.top-v.height-5}px`,Z("top")):(f.current.style.top=`${t.top+t.height+4}px`,Z("bottom"))}};s.useEffect(()=>(window.addEventListener("scroll",y),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y),window.removeEventListener("resize",y)}),[]),s.useEffect(()=>{y()},[b]),s.useEffect(()=>{if(!b||!f.current)return;const d=new ResizeObserver(()=>{y()});return d.observe(f.current),()=>d.disconnect()},[b]),s.useEffect(()=>{b||q(-1)},[b]);const cn=d=>{if(!b){(d.key==="ArrowDown"||d.key==="Enter")&&(d.preventDefault(),W(!0));return}switch(d.key){case"ArrowDown":{d.preventDefault();const t=U(e,g,1);t!==-1&&q(t);break}case"ArrowUp":{d.preventDefault();const t=U(e,g,-1);t!==-1&&q(t);break}case"Enter":{d.preventDefault(),g>=0&&e[g]&&!e[g].disable&&V(e[g].label,e[g].value);break}case"Escape":W(!1);break}},K=o==="lg"||o==="xl"?20:16,G=n.jsx(en,{handleChangePosition:y,children:n.jsxs("div",{className:["sa-input-dropdown-container",O,`sa-input-dropdown-size-${o}`,b?"active":"",sn?"error":"",H?"disable":""].filter(Boolean).join(" "),ref:$,onClick:ln,onKeyDown:cn,tabIndex:0,onBlur:A,onFocus:D,children:[n.jsxs("div",{className:"sa-input-dropdown-preview-container",children:[h?s.cloneElement(h,{width:K,style:{color:"var(--sa-dropdown-placeholder)",flexShrink:0}}):null,n.jsx("div",{className:"sa-input-dropdown-container-preview-item",children:pn()}),b?n.jsx(dn,{width:K}):n.jsx(an,{width:K})]}),n.jsx(nn,{dropdownLists:e,handleChangeValue:V,isComponentVisible:b,positionDropdown:tn,searchAble:!!m,value:c,onSearch:k,ref:f,multiSelect:r,searchValue:z,highlightedIndex:g,footer:a,groupLabel:S,onSelectAll:P})]})});return B?L==="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:B}),X&&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:[G,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:B}),X&&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}),G,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}),G,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 o=p+i;for(;o>=0&&o<l;){if(!e[o].disable)return o;o+=i}if(i===1){for(let r=0;r<l;r++)if(!e[r].disable)return r}else for(let r=l-1;r>=0;r--)if(!e[r].disable)return r;return-1},on=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"})}),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"})});x.Dropdown=rn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
447
+ `;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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "dropdown component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/dropdown.umd.js",
@@ -1,6 +0,0 @@
1
- import React from "react";
2
- interface IProps {
3
- isChecked: boolean;
4
- }
5
- declare const Checkbox: ({ isChecked }: IProps) => React.JSX.Element;
6
- export default Checkbox;