@starasia/dropdown 3.4.2 → 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,
588
- handleChangeValue: k,
589
- multiSelect: h,
515
+ onSearch: r,
516
+ value: o,
517
+ handleChangeValue: y,
518
+ multiSelect: u,
590
519
  searchValue: H,
591
- highlightedIndex: g,
520
+ highlightedIndex: m,
592
521
  footer: A,
593
- groupLabel: j,
594
- onSelectAll: D
522
+ groupLabel: D,
523
+ onSelectAll: j
595
524
  }, M) => {
596
- const z = I([]);
597
- x(() => {
525
+ const L = I([]);
526
+ g(() => {
598
527
  var a;
599
- g >= 0 && z.current[g] && ((a = z.current[g]) == null || a.scrollIntoView({ block: "nearest" }));
600
- }, [g]);
528
+ m >= 0 && L.current[m] && ((a = L.current[m]) == null || a.scrollIntoView({ block: "nearest" }));
529
+ }, [m]);
601
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,
@@ -623,39 +552,39 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
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
- j && /* @__PURE__ */ l("div", { className: "sa-input-dropdown-section-header", children: [
629
- /* @__PURE__ */ n("span", { className: "sa-input-dropdown-section-label", children: j }),
630
- h && D && /* @__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",
634
563
  onClick: (a) => {
635
- a.stopPropagation(), D();
564
+ a.stopPropagation(), j();
636
565
  },
637
566
  children: "Select all"
638
567
  }
639
568
  )
640
569
  ] }),
641
- p.map((a, B) => {
642
- const W = !!(r != null && r.find((R) => R.value === a.value)), L = !!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
- L ? "has-description" : "",
577
+ z ? "has-description" : "",
649
578
  W ? "active" : "",
650
- B === g ? "highlight" : "",
579
+ R === m ? "highlight" : "",
651
580
  a.disable ? "sa-input-dropdwon-item-disable" : ""
652
581
  ].filter(Boolean).join(" "),
653
- ref: (R) => {
654
- z.current[B] = R;
582
+ ref: (S) => {
583
+ L.current[R] = S;
655
584
  },
656
- onClick: () => k(a.label, a.value),
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,7 +610,7 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
681
610
  ] })
682
611
  ]
683
612
  },
684
- B
613
+ R
685
614
  );
686
615
  })
687
616
  ]
@@ -698,129 +627,136 @@ const pn = ({ ...e }) => /* @__PURE__ */ l(
698
627
  handleChangePosition: p
699
628
  }) => {
700
629
  const d = I(null);
701
- x(() => {
702
- var k;
703
- const o = () => {
630
+ g(() => {
631
+ var y;
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 = (k = d.current) == null ? void 0 : k.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 = "md",
733
- multiSelect: r,
734
- searchAble: k,
735
- iconLeft: h,
661
+ size: r = "md",
662
+ multiSelect: o,
663
+ searchAble: y,
664
+ iconLeft: u,
736
665
  placeholder: H,
737
- onSearch: g,
666
+ onSearch: m,
738
667
  error: A,
739
- onBlur: j,
740
- onFocus: D,
668
+ onBlur: D,
669
+ onFocus: j,
741
670
  disable: M,
742
- searchValue: z,
671
+ searchValue: L,
743
672
  variant: O = "outline",
744
673
  footer: a,
745
- groupLabel: B,
674
+ groupLabel: R,
746
675
  onSelectAll: W,
747
676
  /* field wrapper */
748
- label: L,
749
- labelPosition: R = "outside-top",
677
+ label: z,
678
+ labelPosition: S = "outside-top",
750
679
  required: U,
751
- optional: X,
752
- description: y,
753
- helperText: N,
680
+ optional: Z,
681
+ description: N,
682
+ helperText: E,
754
683
  errorText: w
755
684
  }) => {
756
- const E = s !== void 0, $ = I(), T = A || !!w, [c, S] = F(
757
- E ? s || [] : d || []
758
- ), [nn, Z] = F(""), [f, V] = F(-1), v = I(null), { isComponentVisible: m, ref: q, setIsComponentVisible: P } = ln(!1), en = () => {
685
+ const C = s !== void 0, $ = I(), T = A || !!w, [c, B] = F(
686
+ C ? s || [] : d || []
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)
762
- if (c == null ? void 0 : c.find((u) => u.value === i)) {
763
- const u = c.filter((an) => an.value !== i);
764
- E || S(u), p(u);
689
+ }, G = (t, i) => {
690
+ if (o)
691
+ if (c == null ? void 0 : c.find((b) => b.value === i)) {
692
+ const b = c.filter((an) => an.value !== i);
693
+ C || B(b), p(b);
765
694
  } else {
766
- const u = [...c, { label: t, value: i }];
767
- E || S(u), p(u);
695
+ const b = [...c, { label: t, value: i }];
696
+ C || B(b), p(b);
768
697
  }
769
698
  else {
770
- const b = [{ label: t, value: i }];
771
- E || S(b), p(b), P(!1);
699
+ const v = [{ label: t, value: i }];
700
+ C || B(v), p(v), P(!1);
772
701
  }
773
702
  };
774
- x(() => {
775
- E && S(s || []);
776
- }, [s]), x(() => {
777
- E || 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
- onClick: (b) => {
785
- b.stopPropagation(), K(t.label, t.value);
713
+ onClick: (v) => {
714
+ v.stopPropagation(), G(t.label, t.value);
786
715
  }
787
716
  }
788
717
  )
789
- ] }, 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 }), C = () => {
790
- if (q.current && v.current) {
791
- const t = window.innerHeight, i = q.current.getBoundingClientRect(), b = v.current.getBoundingClientRect(), u = i.bottom + b.height;
792
- v.current.style.left = `${i.left}px`, v.current.style.width = `${i.width}px`, u >= t - 10 ? (v.current.style.top = `${i.top - b.height - 5}px`, Z("top")) : (v.current.style.top = `${i.top + i.height + 4}px`, Z("bottom"));
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 = () => {
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", C), window.addEventListener("resize", C), () => {
796
- window.removeEventListener("scroll", C), window.removeEventListener("resize", C);
797
- }), []), x(() => {
798
- C();
799
- }, [m]), x(() => {
800
- m || V(-1);
801
- }, [m]);
802
- const on = (t) => {
803
- if (!m) {
724
+ g(() => (window.addEventListener("scroll", k), window.addEventListener("resize", k), () => {
725
+ window.removeEventListener("scroll", k), window.removeEventListener("resize", k);
726
+ }), []), g(() => {
727
+ k();
728
+ }, [f]), g(() => {
729
+ if (!f || !h.current)
730
+ return;
731
+ const t = new ResizeObserver(() => {
732
+ k();
733
+ });
734
+ return t.observe(h.current), () => t.disconnect();
735
+ }, [f]), g(() => {
736
+ f || V(-1);
737
+ }, [f]);
738
+ const rn = (t) => {
739
+ if (!f) {
804
740
  (t.key === "ArrowDown" || t.key === "Enter") && (t.preventDefault(), P(!0));
805
741
  return;
806
742
  }
807
743
  switch (t.key) {
808
744
  case "ArrowDown": {
809
745
  t.preventDefault();
810
- const i = Y(e, f, 1);
746
+ const i = Y(e, x, 1);
811
747
  i !== -1 && V(i);
812
748
  break;
813
749
  }
814
750
  case "ArrowUp": {
815
751
  t.preventDefault();
816
- const i = Y(e, f, -1);
752
+ const i = Y(e, x, -1);
817
753
  i !== -1 && V(i);
818
754
  break;
819
755
  }
820
756
  case "Enter": {
821
- t.preventDefault(), f >= 0 && e[f] && !e[f].disable && K(
822
- e[f].label,
823
- e[f].value
757
+ t.preventDefault(), x >= 0 && e[x] && !e[x].disable && G(
758
+ e[x].label,
759
+ e[x].value
824
760
  );
825
761
  break;
826
762
  }
@@ -828,100 +764,100 @@ const mn = ({
828
764
  P(!1);
829
765
  break;
830
766
  }
831
- }, G = o === "lg" || o === "xl" ? 20 : 16, J = /* @__PURE__ */ n(wn, { handleChangePosition: C, children: /* @__PURE__ */ l(
767
+ }, J = r === "lg" || r === "xl" ? 20 : 16, K = /* @__PURE__ */ n(wn, { handleChangePosition: k, children: /* @__PURE__ */ l(
832
768
  "div",
833
769
  {
834
770
  className: [
835
771
  "sa-input-dropdown-container",
836
772
  O,
837
- `sa-input-dropdown-size-${o}`,
838
- m ? "active" : "",
773
+ `sa-input-dropdown-size-${r}`,
774
+ f ? "active" : "",
839
775
  T ? "error" : "",
840
776
  M ? "disable" : ""
841
777
  ].filter(Boolean).join(" "),
842
778
  ref: q,
843
779
  onClick: en,
844
- onKeyDown: on,
780
+ onKeyDown: rn,
845
781
  tabIndex: 0,
846
- onBlur: j,
847
- onFocus: D,
782
+ onBlur: D,
783
+ onFocus: j,
848
784
  children: [
849
785
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
850
- h ? _.cloneElement(h, {
851
- width: G,
786
+ u ? _.cloneElement(u, {
787
+ width: J,
852
788
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
853
789
  }) : null,
854
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: rn() }),
855
- m ? /* @__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 })
856
792
  ] }),
857
793
  /* @__PURE__ */ n(
858
- hn,
794
+ un,
859
795
  {
860
796
  dropdownLists: e,
861
- handleChangeValue: K,
862
- isComponentVisible: m,
797
+ handleChangeValue: G,
798
+ isComponentVisible: f,
863
799
  positionDropdown: nn,
864
- searchAble: !!k,
800
+ searchAble: !!y,
865
801
  value: c,
866
- onSearch: g,
867
- ref: v,
868
- multiSelect: r,
869
- searchValue: z,
870
- highlightedIndex: f,
802
+ onSearch: m,
803
+ ref: h,
804
+ multiSelect: o,
805
+ searchValue: L,
806
+ highlightedIndex: x,
871
807
  footer: a,
872
- groupLabel: B,
808
+ groupLabel: R,
873
809
  onSelectAll: W
874
810
  }
875
811
  )
876
812
  ]
877
813
  }
878
814
  ) });
879
- return L ? R === "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: [
880
816
  /* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
881
817
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
882
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: L }),
883
- 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" }),
884
820
  U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
885
821
  ] }),
886
- y && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: y })
822
+ N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N })
887
823
  ] }),
888
824
  /* @__PURE__ */ l("div", { className: "sa-select-field-input-wrap", children: [
889
- J,
890
- N && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: N }),
825
+ K,
826
+ E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
891
827
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
892
828
  ] })
893
829
  ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
894
830
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
895
- /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: L }),
896
- 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" }),
897
833
  U && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
898
834
  ] }),
899
- y && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: y }),
900
- J,
901
- N && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: N }),
835
+ N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
836
+ K,
837
+ E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
902
838
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
903
839
  ] }) : /* @__PURE__ */ l("div", { className: "sa-select-field", children: [
904
- y && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: y }),
905
- J,
906
- N && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: N }),
840
+ N && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: N }),
841
+ K,
842
+ E && !w && /* @__PURE__ */ n("p", { className: "sa-select-field-helper", children: E }),
907
843
  w && /* @__PURE__ */ n("p", { className: "sa-select-field-error-msg", children: w })
908
844
  ] });
909
845
  }, Y = (e, p, d) => {
910
846
  const s = e.length;
911
- let o = p + d;
912
- for (; o >= 0 && o < s; ) {
913
- if (!e[o].disable)
914
- return o;
915
- o += d;
847
+ let r = p + d;
848
+ for (; r >= 0 && r < s; ) {
849
+ if (!e[r].disable)
850
+ return r;
851
+ r += d;
916
852
  }
917
853
  if (d === 1) {
918
- for (let r = 0; r < s; r++)
919
- if (!e[r].disable)
920
- return r;
854
+ for (let o = 0; o < s; o++)
855
+ if (!e[o].disable)
856
+ return o;
921
857
  } else
922
- for (let r = s - 1; r >= 0; r--)
923
- if (!e[r].disable)
924
- return r;
858
+ for (let o = s - 1; o >= 0; o--)
859
+ if (!e[o].disable)
860
+ return o;
925
861
  return -1;
926
862
  }, fn = (e) => /* @__PURE__ */ n(
927
863
  "svg",
@@ -964,7 +900,7 @@ const mn = ({
964
900
  }
965
901
  )
966
902
  }
967
- ), xn = ({ width: e = 16 }) => /* @__PURE__ */ n(
903
+ ), gn = ({ width: e = 16 }) => /* @__PURE__ */ n(
968
904
  "svg",
969
905
  {
970
906
  xmlns: "http://www.w3.org/2000/svg",
@@ -1,4 +1,4 @@
1
- (function(b,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):(b=typeof globalThis<"u"?globalThis:b||self,n(b.Dropdown={},b.jsxRuntime,b.React))})(this,function(b,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:y,multiSelect:h,searchValue:F,highlightedIndex:g,footer:I,groupLabel:A,onSelectAll:D},H)=>{const z=s.useRef([]);s.useEffect(()=>{var a;g>=0&&z.current[g]&&((a=z.current[g])==null||a.scrollIntoView({block:"nearest"}))},[g]);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===g?"highlight":"",a.disable?"sa-input-dropdwon-item-disable":""].filter(Boolean).join(" "),ref:L=>{z.current[S]=L},onClick:()=>y(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 y;const o=()=>{if(i.current){let h=i.current.parentElement;for(;h&&!l(h);)h=h.parentElement;h&&p()}};let r=(y=i.current)==null?void 0:y.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="md",multiSelect:r,searchAble:y,iconLeft:h,placeholder:F,onSearch:g,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:m,helperText:E,errorText:w})=>{const N=l!==void 0,M=s.useRef(),sn=I||!!w,[c,j]=s.useState(N?l||[]:i||[]),[tn,Z]=s.useState(""),[u,q]=s.useState(-1),v=s.useRef(null),{isComponentVisible:k,ref:$,setIsComponentVisible:W}=Y(!1),ln=()=>{W(d=>!d)},V=(d,t)=>{if(r)if(c==null?void 0:c.find(f=>f.value===t)){const f=c.filter(hn=>hn.value!==t);N||j(f),p(f)}else{const f=[...c,{label:d,value:t}];N||j(f),p(f)}else{const x=[{label:d,value:t}];N||j(x),p(x),W(!1)}};s.useEffect(()=>{N&&j(l||[])},[l]),s.useEffect(()=>{N||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:x=>{x.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}),C=()=>{if($.current&&v.current){const d=window.innerHeight,t=$.current.getBoundingClientRect(),x=v.current.getBoundingClientRect(),f=t.bottom+x.height;v.current.style.left=`${t.left}px`,v.current.style.width=`${t.width}px`,f>=d-10?(v.current.style.top=`${t.top-x.height-5}px`,Z("top")):(v.current.style.top=`${t.top+t.height+4}px`,Z("bottom"))}};s.useEffect(()=>(window.addEventListener("scroll",C),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C),window.removeEventListener("resize",C)}),[]),s.useEffect(()=>{C()},[k]),s.useEffect(()=>{k||q(-1)},[k]);const cn=d=>{if(!k){(d.key==="ArrowDown"||d.key==="Enter")&&(d.preventDefault(),W(!0));return}switch(d.key){case"ArrowDown":{d.preventDefault();const t=U(e,u,1);t!==-1&&q(t);break}case"ArrowUp":{d.preventDefault();const t=U(e,u,-1);t!==-1&&q(t);break}case"Enter":{d.preventDefault(),u>=0&&e[u]&&!e[u].disable&&V(e[u].label,e[u].value);break}case"Escape":W(!1);break}},K=o==="lg"||o==="xl"?20:16,G=n.jsx(en,{handleChangePosition:C,children:n.jsxs("div",{className:["sa-input-dropdown-container",O,`sa-input-dropdown-size-${o}`,k?"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()}),k?n.jsx(dn,{width:K}):n.jsx(an,{width:K})]}),n.jsx(nn,{dropdownLists:e,handleChangeValue:V,isComponentVisible:k,positionDropdown:tn,searchAble:!!y,value:c,onSearch:g,ref:v,multiSelect:r,searchValue:z,highlightedIndex:u,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:"*"})]}),m&&n.jsx("p",{className:"sa-select-field-helper-top",children:m})]}),n.jsxs("div",{className:"sa-select-field-input-wrap",children:[G,E&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:E}),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:"*"})]}),m&&n.jsx("p",{className:"sa-select-field-helper-top",children:m}),G,E&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:E}),w&&n.jsx("p",{className:"sa-select-field-error-msg",children:w})]}):n.jsxs("div",{className:"sa-select-field",children:[m&&n.jsx("p",{className:"sa-select-field-helper-top",children:m}),G,E&&!w&&n.jsx("p",{className:"sa-select-field-helper",children:E}),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"})});b.Dropdown=rn,Object.defineProperty(b,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.4.2",
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;