@starasia/dropdown 3.5.0 → 3.5.2

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);
@@ -114,6 +116,7 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
114
116
  background-color: transparent;
115
117
  border: 0.8px solid var(--sa-dropdown-border-subtle);
116
118
  border-radius: var(--borderRadius);
119
+ outline: none;
117
120
  }
118
121
  .sa-input-dropdown-container.outline.active {
119
122
  border: 1.2px solid var(--sa-dropdown-border-active);
@@ -176,7 +179,7 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
176
179
  padding-inline: 8px;
177
180
  padding-block: 2px;
178
181
  border-radius: 4px;
179
- background-color: var(--sa-color-brand-50, #e6edf6);
182
+ background-color: var(--sa-dropdown-bg-chip);
180
183
  color: var(--sa-dropdown-brand);
181
184
  height: max-content;
182
185
  font-size: 12px;
@@ -444,86 +447,13 @@ const sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
444
447
  margin: 0;
445
448
  }
446
449
 
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
450
  `;
521
451
  function ln(e) {
522
- const [p, d] = F(e), s = I(null), o = (r) => {
523
- s.current && !s.current.contains(r.target) && d(!1);
452
+ const [p, d] = F(e), s = I(null), r = (o) => {
453
+ s.current && !s.current.contains(o.target) && d(!1);
524
454
  };
525
- return x(() => (document.addEventListener("click", o, !0), () => {
526
- document.removeEventListener("click", o, !0);
455
+ return g(() => (document.addEventListener("click", r, !0), () => {
456
+ document.removeEventListener("click", r, !0);
527
457
  }), []), { ref: s, isComponentVisible: p, setIsComponentVisible: d };
528
458
  }
529
459
  const pn = ({ ...e }) => /* @__PURE__ */ l(
@@ -577,34 +507,34 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
577
507
  }
578
508
  )
579
509
  }
580
- ), hn = dn(
510
+ ), un = dn(
581
511
  ({
582
512
  positionDropdown: e,
583
513
  dropdownLists: p,
584
514
  isComponentVisible: d,
585
515
  searchAble: s,
586
- onSearch: o,
587
- value: r,
516
+ onSearch: r,
517
+ value: o,
588
518
  handleChangeValue: y,
589
- multiSelect: h,
519
+ multiSelect: u,
590
520
  searchValue: H,
591
521
  highlightedIndex: m,
592
522
  footer: A,
593
- groupLabel: O,
523
+ groupLabel: D,
594
524
  onSelectAll: j
595
525
  }, M) => {
596
- const z = I([]);
597
- x(() => {
526
+ const L = I([]);
527
+ g(() => {
598
528
  var a;
599
- m >= 0 && z.current[m] && ((a = z.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
529
+ m >= 0 && L.current[m] && ((a = L.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
600
530
  }, [m]);
601
- const D = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
531
+ const O = s ? /* @__PURE__ */ l("div", { className: "sa-input-dropdown-container-dropdown-search", children: [
602
532
  /* @__PURE__ */ n(pn, { strokeWidth: 2, width: 16, style: { flexShrink: 0, color: "var(--sa-dropdown-placeholder-subtle)" } }),
603
533
  /* @__PURE__ */ n(
604
534
  "input",
605
535
  {
606
536
  onChange: (a) => {
607
- o && o(a.target.value);
537
+ r && r(a.target.value);
608
538
  },
609
539
  value: H,
610
540
  autoFocus: !0,
@@ -619,15 +549,15 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
619
549
  onClick: (a) => a.stopPropagation(),
620
550
  ref: M,
621
551
  children: [
622
- e !== "top" && D,
552
+ e !== "top" && O,
623
553
  /* @__PURE__ */ l(
624
554
  "div",
625
555
  {
626
- className: `sa-input-dropdwon-item-container ${h ? "multi" : ""}`,
556
+ className: `sa-input-dropdwon-item-container ${u ? "multi" : ""}`,
627
557
  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(
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(
631
561
  "button",
632
562
  {
633
563
  className: "sa-input-dropdown-section-select-all",
@@ -638,24 +568,24 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
638
568
  }
639
569
  )
640
570
  ] }),
641
- p.map((a, B) => {
642
- const W = !!(r != null && r.find((L) => L.value === a.value)), R = !!a.description;
571
+ p.map((a, R) => {
572
+ const W = !!(o != null && o.find((S) => S.value === a.value)), z = !!a.description;
643
573
  return /* @__PURE__ */ l(
644
574
  "div",
645
575
  {
646
576
  className: [
647
577
  "sa-input-dropdwon-item",
648
- R ? "has-description" : "",
578
+ z ? "has-description" : "",
649
579
  W ? "active" : "",
650
- B === m ? "highlight" : "",
580
+ R === m ? "highlight" : "",
651
581
  a.disable ? "sa-input-dropdwon-item-disable" : ""
652
582
  ].filter(Boolean).join(" "),
653
- ref: (L) => {
654
- z.current[B] = L;
583
+ ref: (S) => {
584
+ L.current[R] = S;
655
585
  },
656
586
  onClick: () => y(a.label, a.value),
657
587
  children: [
658
- h && /* @__PURE__ */ n("div", { className: "sa-input-dropdwon-item-check", children: W && /* @__PURE__ */ n(cn, { width: 16 }) }),
588
+ u && /* @__PURE__ */ n("div", { className: "sa-input-dropdwon-item-check", children: W && /* @__PURE__ */ n(cn, { width: 16 }) }),
659
589
  a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: _.cloneElement(a.icon, { width: 16 }) }),
660
590
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
661
591
  /* @__PURE__ */ n(
@@ -681,13 +611,13 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
681
611
  ] })
682
612
  ]
683
613
  },
684
- B
614
+ R
685
615
  );
686
616
  })
687
617
  ]
688
618
  }
689
619
  ),
690
- e === "top" && D,
620
+ e === "top" && O,
691
621
  A && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-footer", onClick: (a) => a.stopPropagation(), children: A })
692
622
  ]
693
623
  }
@@ -698,115 +628,115 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
698
628
  handleChangePosition: p
699
629
  }) => {
700
630
  const d = I(null);
701
- x(() => {
631
+ g(() => {
702
632
  var y;
703
- const o = () => {
633
+ const r = () => {
704
634
  if (d.current) {
705
- let h = d.current.parentElement;
706
- for (; h && !s(h); )
707
- h = h.parentElement;
708
- h && p();
635
+ let u = d.current.parentElement;
636
+ for (; u && !s(u); )
637
+ u = u.parentElement;
638
+ u && p();
709
639
  }
710
640
  };
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);
641
+ let o = (y = d.current) == null ? void 0 : y.parentElement;
642
+ for (; o && !s(o); )
643
+ o = o.parentElement;
644
+ return o && o.addEventListener("scroll", r), r(), () => {
645
+ o && o.removeEventListener("scroll", r);
716
646
  };
717
647
  }, []);
718
- const s = (o) => o && (o.scrollHeight > o.clientHeight || o.scrollWidth > o.clientWidth);
648
+ const s = (r) => r && (r.scrollHeight > r.clientHeight || r.scrollWidth > r.clientWidth);
719
649
  return /* @__PURE__ */ n("div", { ref: d, children: e });
720
- }, Q = "sa-input-dropdown-styles", un = (e) => {
721
- if (!document.getElementById(Q)) {
650
+ }, X = "sa-input-dropdown-styles", hn = (e) => {
651
+ if (!document.getElementById(X)) {
722
652
  const p = document.createElement("style");
723
- p.id = Q, p.textContent = e, document.head.appendChild(p);
653
+ p.id = X, p.textContent = e, document.head.appendChild(p);
724
654
  }
725
655
  };
726
- un(sn);
656
+ hn(sn);
727
657
  const mn = ({
728
658
  dropdownLists: e,
729
659
  onChange: p,
730
660
  defaultValue: d,
731
661
  value: s,
732
- size: o = "sm",
733
- multiSelect: r,
662
+ size: r = "md",
663
+ multiSelect: o,
734
664
  searchAble: y,
735
- iconLeft: h,
665
+ iconLeft: u,
736
666
  placeholder: H,
737
667
  onSearch: m,
738
668
  error: A,
739
- onBlur: O,
669
+ onBlur: D,
740
670
  onFocus: j,
741
671
  disable: M,
742
- searchValue: z,
743
- variant: D = "outline",
672
+ searchValue: L,
673
+ variant: O = "outline",
744
674
  footer: a,
745
- groupLabel: B,
675
+ groupLabel: R,
746
676
  onSelectAll: W,
747
677
  /* field wrapper */
748
- label: R,
749
- labelPosition: L = "outside-top",
678
+ label: z,
679
+ labelPosition: S = "outside-top",
750
680
  required: U,
751
- optional: X,
681
+ optional: Z,
752
682
  description: N,
753
683
  helperText: E,
754
684
  errorText: w
755
685
  }) => {
756
- const C = s !== void 0, $ = I(), T = A || !!w, [c, S] = F(
686
+ const C = s !== void 0, $ = I(), T = A || !!w, [c, B] = F(
757
687
  C ? s || [] : d || []
758
- ), [nn, Z] = F(""), [g, V] = F(-1), u = I(null), { isComponentVisible: f, ref: q, setIsComponentVisible: P } = ln(!1), en = () => {
688
+ ), [nn, Q] = F(""), [x, V] = F(-1), h = I(null), { isComponentVisible: f, ref: q, setIsComponentVisible: P } = ln(!1), en = () => {
759
689
  P((t) => !t);
760
- }, K = (t, i) => {
761
- if (r)
690
+ }, G = (t, i) => {
691
+ if (o)
762
692
  if (c == null ? void 0 : c.find((b) => b.value === i)) {
763
693
  const b = c.filter((an) => an.value !== i);
764
- C || S(b), p(b);
694
+ C || B(b), p(b);
765
695
  } else {
766
696
  const b = [...c, { label: t, value: i }];
767
- C || S(b), p(b);
697
+ C || B(b), p(b);
768
698
  }
769
699
  else {
770
700
  const v = [{ label: t, value: i }];
771
- C || S(v), p(v), P(!1);
701
+ C || B(v), p(v), P(!1);
772
702
  }
773
703
  };
774
- x(() => {
775
- C && S(s || []);
776
- }, [s]), x(() => {
777
- C || JSON.stringify($.current) === JSON.stringify(d) || ($.current = d, S($.current || []));
704
+ g(() => {
705
+ C && B(s || []);
706
+ }, [s]), g(() => {
707
+ C || JSON.stringify($.current) === JSON.stringify(d) || ($.current = d, B($.current || []));
778
708
  }, [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: [
709
+ const on = () => c.length ? o ? c == null ? void 0 : c.map((t, i) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
780
710
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: t == null ? void 0 : t.label }),
781
711
  /* @__PURE__ */ n(
782
712
  fn,
783
713
  {
784
714
  onClick: (v) => {
785
- v.stopPropagation(), K(t.label, t.value);
715
+ v.stopPropagation(), G(t.label, t.value);
786
716
  }
787
717
  }
788
718
  )
789
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 = () => {
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"));
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"));
793
723
  }
794
724
  };
795
- x(() => (window.addEventListener("scroll", k), window.addEventListener("resize", k), () => {
725
+ g(() => (window.addEventListener("scroll", k), window.addEventListener("resize", k), () => {
796
726
  window.removeEventListener("scroll", k), window.removeEventListener("resize", k);
797
- }), []), x(() => {
727
+ }), []), g(() => {
798
728
  k();
799
- }, [f]), x(() => {
800
- if (!f || !u.current)
729
+ }, [f]), g(() => {
730
+ if (!f || !h.current)
801
731
  return;
802
732
  const t = new ResizeObserver(() => {
803
733
  k();
804
734
  });
805
- return t.observe(u.current), () => t.disconnect();
806
- }, [f]), x(() => {
735
+ return t.observe(h.current), () => t.disconnect();
736
+ }, [f]), g(() => {
807
737
  f || V(-1);
808
738
  }, [f]);
809
- const on = (t) => {
739
+ const rn = (t) => {
810
740
  if (!f) {
811
741
  (t.key === "ArrowDown" || t.key === "Enter") && (t.preventDefault(), P(!0));
812
742
  return;
@@ -814,20 +744,20 @@ const mn = ({
814
744
  switch (t.key) {
815
745
  case "ArrowDown": {
816
746
  t.preventDefault();
817
- const i = Y(e, g, 1);
747
+ const i = Y(e, x, 1);
818
748
  i !== -1 && V(i);
819
749
  break;
820
750
  }
821
751
  case "ArrowUp": {
822
752
  t.preventDefault();
823
- const i = Y(e, g, -1);
753
+ const i = Y(e, x, -1);
824
754
  i !== -1 && V(i);
825
755
  break;
826
756
  }
827
757
  case "Enter": {
828
- t.preventDefault(), g >= 0 && e[g] && !e[g].disable && K(
829
- e[g].label,
830
- e[g].value
758
+ t.preventDefault(), x >= 0 && e[x] && !e[x].disable && G(
759
+ e[x].label,
760
+ e[x].value
831
761
  );
832
762
  break;
833
763
  }
@@ -835,100 +765,100 @@ const mn = ({
835
765
  P(!1);
836
766
  break;
837
767
  }
838
- }, G = o === "lg" || o === "xl" ? 20 : 16, J = /* @__PURE__ */ n(wn, { handleChangePosition: k, children: /* @__PURE__ */ l(
768
+ }, J = r === "lg" || r === "xl" ? 20 : 16, K = /* @__PURE__ */ n(wn, { handleChangePosition: k, children: /* @__PURE__ */ l(
839
769
  "div",
840
770
  {
841
771
  className: [
842
772
  "sa-input-dropdown-container",
843
- D,
844
- `sa-input-dropdown-size-${o}`,
773
+ O,
774
+ `sa-input-dropdown-size-${r}`,
845
775
  f ? "active" : "",
846
776
  T ? "error" : "",
847
777
  M ? "disable" : ""
848
778
  ].filter(Boolean).join(" "),
849
779
  ref: q,
850
780
  onClick: en,
851
- onKeyDown: on,
781
+ onKeyDown: rn,
852
782
  tabIndex: 0,
853
- onBlur: O,
783
+ onBlur: D,
854
784
  onFocus: j,
855
785
  children: [
856
786
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
857
- h ? _.cloneElement(h, {
858
- width: G,
787
+ u ? _.cloneElement(u, {
788
+ width: J,
859
789
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
860
790
  }) : 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 })
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 })
863
793
  ] }),
864
794
  /* @__PURE__ */ n(
865
- hn,
795
+ un,
866
796
  {
867
797
  dropdownLists: e,
868
- handleChangeValue: K,
798
+ handleChangeValue: G,
869
799
  isComponentVisible: f,
870
800
  positionDropdown: nn,
871
801
  searchAble: !!y,
872
802
  value: c,
873
803
  onSearch: m,
874
- ref: u,
875
- multiSelect: r,
876
- searchValue: z,
877
- highlightedIndex: g,
804
+ ref: h,
805
+ multiSelect: o,
806
+ searchValue: L,
807
+ highlightedIndex: x,
878
808
  footer: a,
879
- groupLabel: B,
809
+ groupLabel: R,
880
810
  onSelectAll: W
881
811
  }
882
812
  )
883
813
  ]
884
814
  }
885
815
  ) });
886
- return R ? L === "outside-left" ? /* @__PURE__ */ l("div", { className: "sa-select-field sa-select-field-left", children: [
816
+ return z ? S === "outside-left" ? /* @__PURE__ */ l("div", { className: "sa-select-field sa-select-field-left", children: [
887
817
  /* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
888
818
  /* @__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" }),
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" }),
891
821
  U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
892
822
  ] }),
893
823
  N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N })
894
824
  ] }),
895
825
  /* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
896
- J,
826
+ K,
897
827
  E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
898
828
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
899
829
  ] })
900
830
  ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
901
831
  /* @__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" }),
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" }),
904
834
  U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
905
835
  ] }),
906
836
  N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
907
- J,
837
+ K,
908
838
  E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
909
839
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
910
840
  ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
911
841
  N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
912
- J,
842
+ K,
913
843
  E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
914
844
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
915
845
  ] });
916
846
  }, Y = (e, p, d) => {
917
847
  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;
848
+ let r = p + d;
849
+ for (; r >= 0 && r < s; ) {
850
+ if (!e[r].disable)
851
+ return r;
852
+ r += d;
923
853
  }
924
854
  if (d === 1) {
925
- for (let r = 0; r < s; r++)
926
- if (!e[r].disable)
927
- return r;
855
+ for (let o = 0; o < s; o++)
856
+ if (!e[o].disable)
857
+ return o;
928
858
  } else
929
- for (let r = s - 1; r >= 0; r--)
930
- if (!e[r].disable)
931
- return r;
859
+ for (let o = s - 1; o >= 0; o--)
860
+ if (!e[o].disable)
861
+ return o;
932
862
  return -1;
933
863
  }, fn = (e) => /* @__PURE__ */ n(
934
864
  "svg",
@@ -971,7 +901,7 @@ const mn = ({
971
901
  }
972
902
  )
973
903
  }
974
- ), xn = ({ width: e = 16 }) => /* @__PURE__ */ n(
904
+ ), gn = ({ width: e = 16 }) => /* @__PURE__ */ n(
975
905
  "svg",
976
906
  {
977
907
  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);
@@ -112,6 +114,7 @@
112
114
  background-color: transparent;
113
115
  border: 0.8px solid var(--sa-dropdown-border-subtle);
114
116
  border-radius: var(--borderRadius);
117
+ outline: none;
115
118
  }
116
119
  .sa-input-dropdown-container.outline.active {
117
120
  border: 1.2px solid var(--sa-dropdown-border-active);
@@ -174,7 +177,7 @@
174
177
  padding-inline: 8px;
175
178
  padding-block: 2px;
176
179
  border-radius: 4px;
177
- background-color: var(--sa-color-brand-50, #e6edf6);
180
+ background-color: var(--sa-dropdown-bg-chip);
178
181
  color: var(--sa-dropdown-brand);
179
182
  height: max-content;
180
183
  font-size: 12px;
@@ -442,77 +445,4 @@
442
445
  margin: 0;
443
446
  }
444
447
 
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"})});
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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "3.5.0",
3
+ "version": "3.5.2",
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;