@starasia/dropdown 6.0.1 → 6.0.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 dn, { useState as A, useRef as K, useEffect as g, forwardRef as En } from "react";
2
+ import sn, { useState as A, useRef as K, useEffect as g, forwardRef as En } from "react";
3
3
  const zn = `* {
4
4
  margin: 0;
5
5
  padding: 0;
@@ -199,7 +199,7 @@ const zn = `* {
199
199
  border: 1px solid var(--sa-dropdown-border-subtle);
200
200
  padding-inline: 8px;
201
201
  padding-block: 2px;
202
- border-radius: 4px;
202
+ border-radius: var(--sa-radii-xs, 4px);
203
203
  background-color: var(--sa-dropdown-bg-chip);
204
204
  color: var(--sa-dropdown-brand);
205
205
  height: max-content;
@@ -517,7 +517,7 @@ const zn = `* {
517
517
  align-items: center;
518
518
  padding: 0 8px;
519
519
  border: 1px solid var(--sa-dropdown-border-subtle);
520
- border-radius: 4px;
520
+ border-radius: var(--sa-radii-xs, 4px);
521
521
  background: var(--sa-dropdown-bg-neutral);
522
522
  font-size: 10px;
523
523
  font-weight: 500;
@@ -579,8 +579,8 @@ const zn = `* {
579
579
 
580
580
  `;
581
581
  function Rn(o) {
582
- const [t, i] = A(o), p = K(null), c = (d) => {
583
- p.current && !p.current.contains(d.target) && i(!1);
582
+ const [t, i] = A(o), p = K(null), c = (s) => {
583
+ p.current && !p.current.contains(s.target) && i(!1);
584
584
  };
585
585
  return g(() => (document.addEventListener("click", c, !0), () => {
586
586
  document.removeEventListener("click", c, !0);
@@ -644,7 +644,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
644
644
  isComponentVisible: i,
645
645
  searchAble: p,
646
646
  hideSearch: c,
647
- onSearch: d,
647
+ onSearch: s,
648
648
  value: M,
649
649
  handleChangeValue: F,
650
650
  multiSelect: y,
@@ -656,7 +656,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
656
656
  onSelectAll: T,
657
657
  emptyState: X
658
658
  }, Y) => {
659
- const S = K([]), q = k !== void 0, [Z, Q] = A(""), s = q ? k : Z, H = !t || t.length === 0;
659
+ const S = K([]), q = k !== void 0, [Z, Q] = A(""), d = q ? k : Z, H = !t || t.length === 0;
660
660
  g(() => {
661
661
  var a;
662
662
  N >= 0 && S.current[N] && ((a = S.current[N]) == null || a.scrollIntoView({ block: "nearest" }));
@@ -667,9 +667,9 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
667
667
  "input",
668
668
  {
669
669
  onChange: (a) => {
670
- q || Q(a.target.value), d && d(a.target.value);
670
+ q || Q(a.target.value), s && s(a.target.value);
671
671
  },
672
- value: s,
672
+ value: d,
673
673
  autoFocus: !0,
674
674
  placeholder: "Search..."
675
675
  }
@@ -699,12 +699,12 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
699
699
  id: O,
700
700
  "aria-multiselectable": y || void 0,
701
701
  children: [
702
- H && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-empty", children: X ?? (s ? /* @__PURE__ */ l(tn, { children: [
702
+ H && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-empty", children: X ?? (d ? /* @__PURE__ */ l(tn, { children: [
703
703
  "No results for",
704
704
  " ",
705
705
  /* @__PURE__ */ l("span", { className: "sa-input-dropdown-empty-query", children: [
706
706
  "“",
707
- s,
707
+ d,
708
708
  "”"
709
709
  ] })
710
710
  ] }) : "No data available") }),
@@ -743,7 +743,7 @@ const Bn = ({ ...o }) => /* @__PURE__ */ l(
743
743
  onClick: () => F(a.label, a.value),
744
744
  children: [
745
745
  y && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-item-check", children: E && /* @__PURE__ */ n(Dn, { width: 16 }) }),
746
- a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: dn.cloneElement(a.icon, { width: 16 }) }),
746
+ a.icon && /* @__PURE__ */ n("div", { style: { flexShrink: 0, display: "flex" }, children: sn.cloneElement(a.icon, { width: 16 }) }),
747
747
  /* @__PURE__ */ l("div", { style: { minWidth: 0, flex: 1 }, children: [
748
748
  /* @__PURE__ */ n(
749
749
  "p",
@@ -801,7 +801,7 @@ const Pn = ({
801
801
  defaultValue: i,
802
802
  value: p,
803
803
  size: c = "sm",
804
- multiSelect: d,
804
+ multiSelect: s,
805
805
  searchAble: M,
806
806
  iconLeft: F,
807
807
  placeholder: y,
@@ -817,7 +817,7 @@ const Pn = ({
817
817
  onSelectAll: q,
818
818
  emptyState: Z,
819
819
  fullWidth: Q = !0,
820
- triggerInput: s = !1,
820
+ triggerInput: d = !1,
821
821
  clearOnSelect: H = !1,
822
822
  hideChevronIcon: _ = !1,
823
823
  clearable: a = !1,
@@ -826,7 +826,7 @@ const Pn = ({
826
826
  label: E,
827
827
  labelPosition: V = "outside-top",
828
828
  required: B,
829
- optional: sn,
829
+ optional: dn,
830
830
  description: D,
831
831
  helperText: L,
832
832
  errorText: h
@@ -837,19 +837,19 @@ const Pn = ({
837
837
  Q ? "sa-select-field-fullwidth" : ""
838
838
  ].filter(Boolean).join(" "), z = p !== void 0, en = K(), vn = N || !!h, [u, j] = A(
839
839
  z ? p || [] : i || []
840
- ), [xn, ln] = A(""), [f, on] = A(-1), G = dn.useId(), pn = f >= 0 ? `${G}-opt-${f}` : void 0, [cn, U] = A(
840
+ ), [xn, ln] = A(""), [f, on] = A(-1), G = sn.useId(), pn = f >= 0 ? `${G}-opt-${f}` : void 0, [cn, U] = A(
841
841
  () => {
842
842
  var e, r;
843
- return !d && (p != null && p.length || i != null && i.length) ? ((e = p == null ? void 0 : p[0]) == null ? void 0 : e.label) ?? ((r = i == null ? void 0 : i[0]) == null ? void 0 : r.label) ?? "" : "";
843
+ return !s && (p != null && p.length || i != null && i.length) ? ((e = p == null ? void 0 : p[0]) == null ? void 0 : e.label) ?? ((r = i == null ? void 0 : i[0]) == null ? void 0 : r.label) ?? "" : "";
844
844
  }
845
845
  ), v = K(null), { isComponentVisible: w, ref: rn, setIsComponentVisible: R } = Rn(!1), I = o !== void 0, un = u.length > 0, gn = (e) => {
846
846
  e.stopPropagation();
847
847
  const r = [];
848
- z || j(r), t(r), s && U(""), m == null || m();
848
+ z || j(r), t(r), d && U(""), m == null || m();
849
849
  }, mn = () => {
850
850
  I && R((e) => !e);
851
851
  }, J = (e, r) => {
852
- if (d) {
852
+ if (s) {
853
853
  if (u == null ? void 0 : u.find((x) => x.value === r)) {
854
854
  const x = u.filter((Cn) => Cn.value !== r);
855
855
  z || j(x), t(x);
@@ -857,10 +857,10 @@ const Pn = ({
857
857
  const x = [...u, { label: e, value: r }];
858
858
  z || j(x), t(x);
859
859
  }
860
- s && U("");
860
+ d && U("");
861
861
  } else {
862
862
  const b = [{ label: e, value: r }];
863
- z || j(b), t(b), s && U(H ? "" : e), R(!1);
863
+ z || j(b), t(b), d && U(H ? "" : e), R(!1);
864
864
  }
865
865
  };
866
866
  g(() => {
@@ -868,7 +868,7 @@ const Pn = ({
868
868
  }, [p]), g(() => {
869
869
  z || JSON.stringify(en.current) === JSON.stringify(i) || (en.current = i, j(en.current || []));
870
870
  }, [i]);
871
- const yn = () => u.length ? d ? u == null ? void 0 : u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
871
+ const yn = () => u.length ? s ? u == null ? void 0 : u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
872
872
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
873
873
  /* @__PURE__ */ n(
874
874
  bn,
@@ -941,8 +941,8 @@ const Pn = ({
941
941
  onMouseDown: (e) => e.preventDefault(),
942
942
  children: /* @__PURE__ */ n(Mn, { width: P, height: P })
943
943
  }
944
- ) : null, Nn = s ? /* @__PURE__ */ l(tn, { children: [
945
- d && u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
944
+ ) : null, Nn = d ? /* @__PURE__ */ l(tn, { children: [
945
+ s && u.map((e, r) => /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-item", children: [
946
946
  /* @__PURE__ */ n("p", { style: { minWidth: "max-content" }, children: e == null ? void 0 : e.label }),
947
947
  /* @__PURE__ */ n(
948
948
  bn,
@@ -972,10 +972,10 @@ const Pn = ({
972
972
  !C && I && R(!0);
973
973
  },
974
974
  onBlur: () => {
975
- d || setTimeout(() => R(!1), 150);
975
+ s || setTimeout(() => R(!1), 150);
976
976
  },
977
977
  onKeyDown: wn,
978
- placeholder: u.length === 0 || d ? y : void 0,
978
+ placeholder: u.length === 0 || s ? y : void 0,
979
979
  disabled: C
980
980
  }
981
981
  )
@@ -991,29 +991,29 @@ const Pn = ({
991
991
  "sa-input-dropdown-container",
992
992
  X,
993
993
  `sa-input-dropdown-size-${c}`,
994
- s ? "trigger-input" : "",
994
+ d ? "trigger-input" : "",
995
995
  w ? "active" : "",
996
996
  vn ? "error" : "",
997
997
  C ? "disable" : ""
998
998
  ].filter(Boolean).join(" "),
999
999
  ref: rn,
1000
- role: s ? void 0 : "combobox",
1001
- "aria-haspopup": s ? void 0 : "listbox",
1002
- "aria-expanded": s ? void 0 : w,
1003
- "aria-controls": s ? void 0 : G,
1004
- "aria-activedescendant": s ? void 0 : pn,
1005
- onClick: s ? void 0 : mn,
1006
- onKeyDown: s ? void 0 : wn,
1007
- tabIndex: s ? void 0 : 0,
1008
- onBlur: s ? void 0 : O,
1009
- onFocus: s ? void 0 : $,
1000
+ role: d ? void 0 : "combobox",
1001
+ "aria-haspopup": d ? void 0 : "listbox",
1002
+ "aria-expanded": d ? void 0 : w,
1003
+ "aria-controls": d ? void 0 : G,
1004
+ "aria-activedescendant": d ? void 0 : pn,
1005
+ onClick: d ? void 0 : mn,
1006
+ onKeyDown: d ? void 0 : wn,
1007
+ tabIndex: d ? void 0 : 0,
1008
+ onBlur: d ? void 0 : O,
1009
+ onFocus: d ? void 0 : $,
1010
1010
  children: [
1011
1011
  /* @__PURE__ */ l("div", { className: "sa-input-dropdown-preview-container", children: [
1012
- F ? dn.cloneElement(F, {
1012
+ F ? sn.cloneElement(F, {
1013
1013
  width: P,
1014
1014
  style: { color: "var(--sa-dropdown-placeholder)", flexShrink: 0 }
1015
1015
  }) : null,
1016
- /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: s ? Nn : yn() }),
1016
+ /* @__PURE__ */ n("div", { className: "sa-input-dropdown-container-preview-item", children: d ? Nn : yn() }),
1017
1017
  kn,
1018
1018
  !_ && /* @__PURE__ */ n("div", { className: "sa-input-dropdown-chevron", children: w ? /* @__PURE__ */ n(Sn, { width: P }) : /* @__PURE__ */ n(On, { width: P }) })
1019
1019
  ] }),
@@ -1026,12 +1026,12 @@ const Pn = ({
1026
1026
  listboxId: G,
1027
1027
  positionDropdown: xn,
1028
1028
  searchAble: !!M,
1029
- hideSearch: s,
1029
+ hideSearch: d,
1030
1030
  value: u,
1031
1031
  onSearch: k,
1032
1032
  ref: v,
1033
- multiSelect: d,
1034
- searchValue: s ? cn : T,
1033
+ multiSelect: s,
1034
+ searchValue: d ? cn : T,
1035
1035
  highlightedIndex: f,
1036
1036
  footer: Y,
1037
1037
  groupLabel: S,
@@ -1048,7 +1048,7 @@ const Pn = ({
1048
1048
  /* @__PURE__ */ l("div", { className: "sa-select-field-left-label", children: [
1049
1049
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
1050
1050
  /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: E }),
1051
- sn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1051
+ dn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1052
1052
  B && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
1053
1053
  ] }),
1054
1054
  D && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: D })
@@ -1061,7 +1061,7 @@ const Pn = ({
1061
1061
  ] }) : /* @__PURE__ */ l("div", { className: nn, children: [
1062
1062
  /* @__PURE__ */ l("div", { className: "sa-select-field-label-row", children: [
1063
1063
  /* @__PURE__ */ n("span", { className: "sa-select-field-label-text", children: E }),
1064
- sn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1064
+ dn && /* @__PURE__ */ n("span", { className: "sa-select-field-optional-badge", children: "Optional" }),
1065
1065
  B && /* @__PURE__ */ n("span", { className: "sa-select-field-required", children: "*" })
1066
1066
  ] }),
1067
1067
  D && /* @__PURE__ */ n("p", { className: "sa-select-field-helper-top", children: D }),
@@ -1083,13 +1083,13 @@ const Pn = ({
1083
1083
  c += i;
1084
1084
  }
1085
1085
  if (i === 1) {
1086
- for (let d = 0; d < p; d++)
1087
- if (!o[d].disable)
1088
- return d;
1086
+ for (let s = 0; s < p; s++)
1087
+ if (!o[s].disable)
1088
+ return s;
1089
1089
  } else
1090
- for (let d = p - 1; d >= 0; d--)
1091
- if (!o[d].disable)
1092
- return d;
1090
+ for (let s = p - 1; s >= 0; s--)
1091
+ if (!o[s].disable)
1092
+ return s;
1093
1093
  return -1;
1094
1094
  }, Mn = (o) => /* @__PURE__ */ l("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o, children: [
1095
1095
  /* @__PURE__ */ n("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
@@ -197,7 +197,7 @@
197
197
  border: 1px solid var(--sa-dropdown-border-subtle);
198
198
  padding-inline: 8px;
199
199
  padding-block: 2px;
200
- border-radius: 4px;
200
+ border-radius: var(--sa-radii-xs, 4px);
201
201
  background-color: var(--sa-dropdown-bg-chip);
202
202
  color: var(--sa-dropdown-brand);
203
203
  height: max-content;
@@ -515,7 +515,7 @@
515
515
  align-items: center;
516
516
  padding: 0 8px;
517
517
  border: 1px solid var(--sa-dropdown-border-subtle);
518
- border-radius: 4px;
518
+ border-radius: var(--sa-radii-xs, 4px);
519
519
  background: var(--sa-dropdown-bg-neutral);
520
520
  font-size: 10px;
521
521
  font-weight: 500;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/dropdown",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "description": "dropdown component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/dropdown.umd.js",