@starasia/input 4.2.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Kbd.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import React from "react";
2
+ export type KbdSize = "xs" | "sm" | "md" | "lg";
2
3
  export interface KbdProps extends React.HTMLAttributes<HTMLSpanElement> {
3
4
  /** Keys to render, one cap each. e.g. ['⌘', 'K'] */
4
5
  keys: React.ReactNode[];
5
6
  /** Optional separator rendered between caps. Default: none (gap only). */
6
7
  separator?: React.ReactNode;
8
+ /**
9
+ * Cap size — matches Input's scale so a `<Kbd>` embedded as an Input icon
10
+ * pairs 1:1. Default `"sm"` (12px, unchanged from before this prop existed).
11
+ */
12
+ size?: KbdSize;
7
13
  }
8
- export declare function Kbd({ keys, separator, className, ...rest }: KbdProps): React.JSX.Element;
14
+ export declare function Kbd({ keys, separator, size, className, ...rest }: KbdProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Input } from "./Input";
2
2
  export { Kbd } from "./Kbd";
3
- export type { KbdProps } from "./Kbd";
3
+ export type { KbdProps, KbdSize } from "./Kbd";
4
4
  export * from "./types";
package/dist/input.es.js CHANGED
@@ -1,7 +1,6 @@
1
- import { jsx as s, jsxs as o, Fragment as Sn } from "react/jsx-runtime";
2
- import Z, { forwardRef as mn, useState as I, useRef as R, useEffect as F, useImperativeHandle as En, useLayoutEffect as pn } from "react";
3
- const $n = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
4
-
1
+ import { jsx as a, jsxs as l, Fragment as Ln } from "react/jsx-runtime";
2
+ import Z, { forwardRef as mn, useState as I, useRef as R, useEffect as F, useImperativeHandle as En, useLayoutEffect as bn } from "react";
3
+ const $n = `
5
4
  :root {
6
5
  /* Layer 3 — references Layer 2 semantic tokens */
7
6
  --sa-input-text-primary: var(--sa-text-primary, #292a2e);
@@ -44,7 +43,7 @@ const $n = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
44
43
  flex-direction: column;
45
44
  align-items: stretch;
46
45
  gap: 8px;
47
- font-family: "Poppins", sans-serif;
46
+ font-family: var(--sa-font-family, "Inter", sans-serif);
48
47
  width: max-content;
49
48
  }
50
49
  .sa-tf *,
@@ -631,33 +630,33 @@ function Fn(n, e) {
631
630
  if (e <= 0)
632
631
  return 0;
633
632
  let r = 0;
634
- for (let l = 0; l < n.length; l++)
635
- if (/\d/.test(n[l]) && (r += 1, r === e))
636
- return l + 1;
633
+ for (let o = 0; o < n.length; o++)
634
+ if (/\d/.test(n[o]) && (r += 1, r === e))
635
+ return o + 1;
637
636
  return n.length;
638
637
  }
639
638
  const Tn = mn(
640
- ({ options: n, value: e, setValue: r, isComponentVisible: l, onOptionChange: d }, f) => {
641
- const [h, T] = I([]), c = R(null), u = () => {
642
- if (f != null && f.current && c.current) {
643
- const x = window.innerHeight, b = f == null ? void 0 : f.current.getBoundingClientRect(), m = c.current.getBoundingClientRect(), v = b.bottom + m.height;
644
- c.current.style.left = `${b.left}px`, c.current.style.width = `${b.width}px`, v >= x - 10 ? c.current.style.top = `${b.top - m.height - 5}px` : c.current.style.top = `${b.top + b.height}px`;
639
+ ({ options: n, value: e, setValue: r, isComponentVisible: o, onOptionChange: d }, f) => {
640
+ const [c, T] = I([]), u = R(null), p = () => {
641
+ if (f != null && f.current && u.current) {
642
+ const g = window.innerHeight, b = f == null ? void 0 : f.current.getBoundingClientRect(), m = u.current.getBoundingClientRect(), v = b.bottom + m.height;
643
+ u.current.style.left = `${b.left}px`, u.current.style.width = `${b.width}px`, v >= g - 10 ? u.current.style.top = `${b.top - m.height - 5}px` : u.current.style.top = `${b.top + b.height}px`;
645
644
  }
646
645
  };
647
- return F(() => (window.addEventListener("scroll", u), window.addEventListener("resize", u), () => {
648
- window.removeEventListener("scroll", u), window.removeEventListener("resize", u);
649
- }), [f, c]), F(() => {
650
- u();
651
- }, [l]), F(() => {
646
+ return F(() => (window.addEventListener("scroll", p), window.addEventListener("resize", p), () => {
647
+ window.removeEventListener("scroll", p), window.removeEventListener("resize", p);
648
+ }), [f, u]), F(() => {
649
+ p();
650
+ }, [o]), F(() => {
652
651
  T(
653
652
  (n == null ? void 0 : n.filter(
654
- (x) => x.toLowerCase().startsWith(e.toLowerCase())
653
+ (g) => g.toLowerCase().startsWith(e.toLowerCase())
655
654
  )) || []
656
655
  );
657
- }, [e, n]), /* @__PURE__ */ s(
656
+ }, [e, n]), /* @__PURE__ */ a(
658
657
  "div",
659
658
  {
660
- ref: c,
659
+ ref: u,
661
660
  style: {
662
661
  position: "fixed",
663
662
  padding: "8px",
@@ -668,42 +667,42 @@ const Tn = mn(
668
667
  overflow: "auto",
669
668
  zIndex: 5e4
670
669
  },
671
- children: h == null ? void 0 : h.map(
672
- (x) => Vn(x, e, r, d)
670
+ children: c == null ? void 0 : c.map(
671
+ (g) => Vn(g, e, r, d)
673
672
  )
674
673
  }
675
674
  );
676
675
  }
677
- ), Vn = (n, e, r, l) => {
676
+ ), Vn = (n, e, r, o) => {
678
677
  const d = n.toLowerCase().indexOf(e.toLowerCase());
679
- return /* @__PURE__ */ o(
678
+ return /* @__PURE__ */ l(
680
679
  "p",
681
680
  {
682
681
  style: {
683
- fontFamily: "Poppins",
682
+ fontFamily: 'var(--sa-font-family, "Inter", sans-serif)',
684
683
  color: "var(--sa-color-gray-400, #b7b9be)",
685
684
  fontWeight: 500,
686
685
  padding: "8px 14px",
687
686
  cursor: "pointer"
688
687
  },
689
688
  onClick: () => {
690
- r(n), l && l(n);
689
+ r(n), o && o(n);
691
690
  },
692
691
  children: [
693
692
  n.slice(0, d),
694
- /* @__PURE__ */ s("span", { style: { color: "var(--sa-text-primary, #292a2e)" }, children: n.slice(d, d + e.length) }),
693
+ /* @__PURE__ */ a("span", { style: { color: "var(--sa-text-primary, #292a2e)" }, children: n.slice(d, d + e.length) }),
695
694
  n.slice(d + e.length)
696
695
  ]
697
696
  }
698
697
  );
699
698
  };
700
699
  function On(n) {
701
- const [e, r] = I(n), l = R(null), d = (f) => {
702
- l.current && !l.current.contains(f.target) && r(!1);
700
+ const [e, r] = I(n), o = R(null), d = (f) => {
701
+ o.current && !o.current.contains(f.target) && r(!1);
703
702
  };
704
703
  return F(() => (document.addEventListener("click", d, !0), () => {
705
704
  document.removeEventListener("click", d, !0);
706
- }), []), { ref: l, isComponentVisible: e, setIsComponentVisible: r };
705
+ }), []), { ref: o, isComponentVisible: e, setIsComponentVisible: r };
707
706
  }
708
707
  const gn = "sa-input-styles", jn = (n) => {
709
708
  if (!(typeof document > "u") && !document.getElementById(gn)) {
@@ -712,7 +711,7 @@ const gn = "sa-input-styles", jn = (n) => {
712
711
  }
713
712
  };
714
713
  jn($n);
715
- const Yn = (n) => /* @__PURE__ */ o(
714
+ const Yn = (n) => /* @__PURE__ */ l(
716
715
  "svg",
717
716
  {
718
717
  viewBox: "0 0 16 16",
@@ -720,8 +719,8 @@ const Yn = (n) => /* @__PURE__ */ o(
720
719
  xmlns: "http://www.w3.org/2000/svg",
721
720
  ...n,
722
721
  children: [
723
- /* @__PURE__ */ s("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeWidth: "1.2" }),
724
- /* @__PURE__ */ s(
722
+ /* @__PURE__ */ a("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeWidth: "1.2" }),
723
+ /* @__PURE__ */ a(
725
724
  "path",
726
725
  {
727
726
  d: "M5.2 8.2l1.8 1.8 3.8-4.2",
@@ -733,7 +732,7 @@ const Yn = (n) => /* @__PURE__ */ o(
733
732
  )
734
733
  ]
735
734
  }
736
- ), An = (n) => /* @__PURE__ */ o(
735
+ ), An = (n) => /* @__PURE__ */ l(
737
736
  "svg",
738
737
  {
739
738
  viewBox: "0 0 16 16",
@@ -741,8 +740,8 @@ const Yn = (n) => /* @__PURE__ */ o(
741
740
  xmlns: "http://www.w3.org/2000/svg",
742
741
  ...n,
743
742
  children: [
744
- /* @__PURE__ */ s("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
745
- /* @__PURE__ */ s(
743
+ /* @__PURE__ */ a("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
744
+ /* @__PURE__ */ a(
746
745
  "path",
747
746
  {
748
747
  d: "M5.5 5.5l5 5M10.5 5.5l-5 5",
@@ -757,62 +756,62 @@ const Yn = (n) => /* @__PURE__ */ o(
757
756
  (n, e) => {
758
757
  const {
759
758
  size: r = "sm",
760
- variant: l = "outline",
759
+ variant: o = "outline",
761
760
  status: d = "default",
762
761
  label: f,
763
- labelPosition: h = "outside-top",
762
+ labelPosition: c = "outside-top",
764
763
  required: T,
765
- optional: c,
766
- description: u,
767
- helperText: x,
764
+ optional: u,
765
+ description: p,
766
+ helperText: g,
768
767
  errorText: b,
769
768
  leftIcon: m,
770
769
  rightIcon: v,
771
770
  leftAddons: B,
772
- rightAddons: L,
771
+ rightAddons: S,
773
772
  onClickLeftIcon: nn,
774
773
  onClickRightIcon: V,
775
774
  fullWidth: vn = !0,
776
775
  highlightPlaceholder: O,
777
- currency: S,
776
+ currency: L,
778
777
  options: E,
779
778
  onOptionChange: j,
780
779
  clearable: wn = !0,
781
780
  onClear: Y,
782
- ...a
783
- } = n, A = a.value !== void 0, [W, y] = I(() => {
784
- const t = a.value !== void 0 ? String(a.value ?? "") : String(a.defaultValue ?? "");
785
- return S ? Q(t) : t;
786
- }), [tn, en] = I(!1), [yn, an] = I(""), k = R(null), C = R(null);
781
+ ...s
782
+ } = n, A = s.value !== void 0, [W, k] = I(() => {
783
+ const t = s.value !== void 0 ? String(s.value ?? "") : String(s.defaultValue ?? "");
784
+ return L ? Q(t) : t;
785
+ }), [tn, en] = I(!1), [kn, sn] = I(""), y = R(null), C = R(null);
787
786
  En(e, () => C.current);
788
- const sn = R(
789
- a.id ?? `sa-input-${Math.random().toString(36).slice(2, 9)}`
787
+ const an = R(
788
+ s.id ?? `sa-input-${Math.random().toString(36).slice(2, 9)}`
790
789
  ), {
791
790
  isComponentVisible: rn,
792
791
  ref: _,
793
- setIsComponentVisible: kn
792
+ setIsComponentVisible: yn
794
793
  } = On(!1);
795
- pn(() => {
794
+ bn(() => {
796
795
  if (!A)
797
796
  return;
798
- const t = a.value === void 0 || a.value === null ? "" : String(a.value), i = S ? Q(t) : t;
799
- y((p) => p === i ? p : i);
800
- }, [a.value, S, A]), pn(() => {
801
- if (k.current === null)
797
+ const t = s.value === void 0 || s.value === null ? "" : String(s.value), i = L ? Q(t) : t;
798
+ k((x) => x === i ? x : i);
799
+ }, [s.value, L, A]), bn(() => {
800
+ if (y.current === null)
802
801
  return;
803
- const t = C.current, i = k.current;
804
- if (k.current = null, !!t)
802
+ const t = C.current, i = y.current;
803
+ if (y.current = null, !!t)
805
804
  try {
806
805
  t.setSelectionRange(i, i);
807
806
  } catch {
808
807
  }
809
808
  }, [W]);
810
- const N = W, $ = N !== "" && N !== void 0, w = d === "disable" || a.disabled, M = w ? "disable" : d, P = h === "inside", zn = P && ($ || tn), H = [
809
+ const N = W, $ = N !== "" && N !== void 0, w = d === "disable" || s.disabled, M = w ? "disable" : d, H = c === "inside", zn = H && ($ || tn), q = [
811
810
  "sa-tf",
812
- `sa-tf-variant-${l}`,
811
+ `sa-tf-variant-${o}`,
813
812
  `sa-tf-size-${r}`,
814
813
  `sa-tf-status-${M}`,
815
- `sa-tf-label-${h}`,
814
+ `sa-tf-label-${c}`,
816
815
  tn ? "sa-tf-focused" : "",
817
816
  w ? "sa-tf-disabled" : "",
818
817
  zn ? "sa-tf-floating" : "",
@@ -822,42 +821,42 @@ const Yn = (n) => /* @__PURE__ */ o(
822
821
  var t;
823
822
  return (t = C.current) == null ? void 0 : t.focus();
824
823
  }, Nn = (t) => {
825
- var un, bn;
826
- if (!S) {
824
+ var un, pn;
825
+ if (!L) {
827
826
  const D = t.target.selectionStart;
828
- D !== null && (k.current = D), y(t.target.value), (un = a.onChange) == null || un.call(a, t);
827
+ D !== null && (y.current = D), k(t.target.value), (un = s.onChange) == null || un.call(s, t);
829
828
  return;
830
829
  }
831
830
  const i = t.target.value;
832
- let p = i, g = t.target.selectionStart ?? i.length;
833
- if (yn === "Backspace") {
834
- const D = W.replace(/\D/g, ""), Ln = i.replace(/\D/g, "");
835
- D.length === Ln.length && g > 0 && (p = i.slice(0, g - 1) + i.slice(g), g -= 1);
831
+ let x = i, h = t.target.selectionStart ?? i.length;
832
+ if (kn === "Backspace") {
833
+ const D = W.replace(/\D/g, ""), Sn = i.replace(/\D/g, "");
834
+ D.length === Sn.length && h > 0 && (x = i.slice(0, h - 1) + i.slice(h), h -= 1);
836
835
  }
837
- const G = Q(p), Rn = p.slice(0, g).replace(/\D/g, "").length, Bn = Fn(G, Rn);
838
- k.current = Bn, y(G), (bn = a.onChange) == null || bn.call(a, {
836
+ const G = Q(x), Rn = x.slice(0, h).replace(/\D/g, "").length, Bn = Fn(G, Rn);
837
+ y.current = Bn, k(G), (pn = s.onChange) == null || pn.call(s, {
839
838
  ...t,
840
839
  target: {
841
840
  ...t.target,
842
841
  value: String(Dn(G)),
843
842
  name: t.target.name
844
843
  }
845
- }), an("");
846
- }, q = (t) => f ? /* @__PURE__ */ o("div", { className: t, children: [
847
- /* @__PURE__ */ s(
844
+ }), sn("");
845
+ }, K = (t) => f ? /* @__PURE__ */ l("div", { className: t, children: [
846
+ /* @__PURE__ */ a(
848
847
  "label",
849
848
  {
850
- htmlFor: sn.current,
849
+ htmlFor: an.current,
851
850
  style: { cursor: w ? "not-allowed" : "pointer" },
852
851
  children: f
853
852
  }
854
853
  ),
855
- c ? /* @__PURE__ */ s("span", { className: "sa-tf-optional", children: "Optional" }) : null,
856
- T ? /* @__PURE__ */ s("span", { className: "sa-tf-required", "aria-hidden": "true", children: "*" }) : null
857
- ] }) : null, K = /* @__PURE__ */ o(Sn, { children: [
858
- x ? /* @__PURE__ */ s("p", { className: "sa-tf-helper", children: x }) : null,
859
- b && d === "error" ? /* @__PURE__ */ s("p", { className: "sa-tf-error", children: b }) : null
860
- ] }), U = (t, i) => /* @__PURE__ */ s(
854
+ u ? /* @__PURE__ */ a("span", { className: "sa-tf-optional", children: "Optional" }) : null,
855
+ T ? /* @__PURE__ */ a("span", { className: "sa-tf-required", "aria-hidden": "true", children: "*" }) : null
856
+ ] }) : null, P = /* @__PURE__ */ l(Ln, { children: [
857
+ g ? /* @__PURE__ */ a("p", { className: "sa-tf-helper", children: g }) : null,
858
+ b && d === "error" ? /* @__PURE__ */ a("p", { className: "sa-tf-error", children: b }) : null
859
+ ] }), U = (t, i) => /* @__PURE__ */ a(
861
860
  "span",
862
861
  {
863
862
  className: `sa-tf-icon${i ? " sa-tf-icon-clickable" : ""}`,
@@ -871,7 +870,7 @@ const Yn = (n) => /* @__PURE__ */ o(
871
870
  }
872
871
  ), on = () => {
873
872
  var i;
874
- return v == null ? null : !Z.isValidElement(v) || ((i = v.type) == null ? void 0 : i.__saRaw) === !0 ? /* @__PURE__ */ s(
873
+ return v == null ? null : !Z.isValidElement(v) || ((i = v.type) == null ? void 0 : i.__saRaw) === !0 ? /* @__PURE__ */ a(
875
874
  "span",
876
875
  {
877
876
  className: `sa-tf-icon${V ? " sa-tf-icon-clickable" : ""}`,
@@ -879,13 +878,13 @@ const Yn = (n) => /* @__PURE__ */ o(
879
878
  children: v
880
879
  }
881
880
  ) : U(v, V);
882
- }, ln = d === "success" ? /* @__PURE__ */ s("span", { className: "sa-tf-icon sa-tf-success-mark", "aria-hidden": "true", children: /* @__PURE__ */ s(
881
+ }, ln = d === "success" ? /* @__PURE__ */ a("span", { className: "sa-tf-icon sa-tf-success-mark", "aria-hidden": "true", children: /* @__PURE__ */ a(
883
882
  Yn,
884
883
  {
885
884
  width: z(r),
886
885
  height: z(r)
887
886
  }
888
- ) }) : null, dn = wn && !w ? /* @__PURE__ */ s(
887
+ ) }) : null, dn = wn && !w ? /* @__PURE__ */ a(
889
888
  "button",
890
889
  {
891
890
  type: "button",
@@ -894,19 +893,19 @@ const Yn = (n) => /* @__PURE__ */ o(
894
893
  "aria-hidden": !$,
895
894
  tabIndex: -1,
896
895
  onClick: (t) => {
897
- var p;
898
- t.stopPropagation(), A || y("");
896
+ var x;
897
+ t.stopPropagation(), A || k("");
899
898
  const i = {
900
- target: { value: "", name: a.name },
901
- currentTarget: { value: "", name: a.name }
899
+ target: { value: "", name: s.name },
900
+ currentTarget: { value: "", name: s.name }
902
901
  };
903
- (p = a.onChange) == null || p.call(a, i), Y == null || Y(), k.current = 0, requestAnimationFrame(() => {
904
- var g;
905
- return (g = C.current) == null ? void 0 : g.focus();
902
+ (x = s.onChange) == null || x.call(s, i), Y == null || Y(), y.current = 0, requestAnimationFrame(() => {
903
+ var h;
904
+ return (h = C.current) == null ? void 0 : h.focus();
906
905
  });
907
906
  },
908
907
  onMouseDown: (t) => t.preventDefault(),
909
- children: /* @__PURE__ */ s(
908
+ children: /* @__PURE__ */ a(
910
909
  An,
911
910
  {
912
911
  width: z(r),
@@ -914,107 +913,107 @@ const Yn = (n) => /* @__PURE__ */ o(
914
913
  }
915
914
  )
916
915
  }
917
- ) : null, In = !$ && !!a.placeholder && !!O, fn = /* @__PURE__ */ o("div", { className: "sa-tf-field-wrap", children: [
918
- /* @__PURE__ */ s(
916
+ ) : null, In = !$ && !!s.placeholder && !!O, fn = /* @__PURE__ */ l("div", { className: "sa-tf-field-wrap", children: [
917
+ /* @__PURE__ */ a(
919
918
  "input",
920
919
  {
921
- ...a,
922
- id: sn.current,
920
+ ...s,
921
+ id: an.current,
923
922
  ref: C,
924
923
  className: "sa-tf-input",
925
924
  disabled: w,
926
- placeholder: O ? "" : a.placeholder,
925
+ placeholder: O ? "" : s.placeholder,
927
926
  value: N,
928
927
  onFocus: (t) => {
929
928
  var i;
930
- en(!0), kn(!0), (i = a.onFocus) == null || i.call(a, t);
929
+ en(!0), yn(!0), (i = s.onFocus) == null || i.call(s, t);
931
930
  },
932
931
  onBlur: (t) => {
933
932
  var i;
934
- en(!1), (i = a.onBlur) == null || i.call(a, t);
933
+ en(!1), (i = s.onBlur) == null || i.call(s, t);
935
934
  },
936
935
  onKeyDown: (t) => {
937
936
  var i;
938
- t.key === "Backspace" && an(t.key), (i = a.onKeyDown) == null || i.call(a, t);
937
+ t.key === "Backspace" && sn(t.key), (i = s.onKeyDown) == null || i.call(s, t);
939
938
  },
940
939
  onChange: Nn
941
940
  }
942
941
  ),
943
- In ? _n(a.placeholder, O) : null
944
- ] }), cn = N && rn && (E != null && E.length) ? /* @__PURE__ */ s(
942
+ In ? _n(s.placeholder, O) : null
943
+ ] }), cn = N && rn && (E != null && E.length) ? /* @__PURE__ */ a(
945
944
  Tn,
946
945
  {
947
946
  options: E,
948
947
  value: N,
949
- setValue: y,
948
+ setValue: k,
950
949
  ref: _,
951
950
  isComponentVisible: rn,
952
951
  onOptionChange: (t) => {
953
- j == null || j(t), y(t);
952
+ j == null || j(t), k(t);
954
953
  }
955
954
  }
956
- ) : null, X = P ? /* @__PURE__ */ o(
955
+ ) : null, X = H ? /* @__PURE__ */ l(
957
956
  "div",
958
957
  {
959
958
  className: "sa-tf-box",
960
959
  ref: _,
961
960
  onClick: Cn,
962
961
  children: [
963
- B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
964
- /* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
962
+ B ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
963
+ /* @__PURE__ */ l("div", { className: "sa-tf-box-content", children: [
965
964
  m ? U(m, nn) : null,
966
- /* @__PURE__ */ o("div", { className: "sa-tf-inside-stack", children: [
967
- q("sa-tf-inside-label-row"),
968
- /* @__PURE__ */ s("div", { className: "sa-tf-inside-row", children: fn })
965
+ /* @__PURE__ */ l("div", { className: "sa-tf-inside-stack", children: [
966
+ K("sa-tf-inside-label-row"),
967
+ /* @__PURE__ */ a("div", { className: "sa-tf-inside-row", children: fn })
969
968
  ] }),
970
969
  dn,
971
970
  ln,
972
971
  on()
973
972
  ] }),
974
- L ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: L }) : null,
973
+ S ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-right", children: S }) : null,
975
974
  cn
976
975
  ]
977
976
  }
978
- ) : /* @__PURE__ */ o("div", { className: "sa-tf-box", ref: _, children: [
979
- B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
980
- /* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
977
+ ) : /* @__PURE__ */ l("div", { className: "sa-tf-box", ref: _, children: [
978
+ B ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
979
+ /* @__PURE__ */ l("div", { className: "sa-tf-box-content", children: [
981
980
  m ? U(m, nn) : null,
982
981
  fn,
983
982
  dn,
984
983
  ln,
985
984
  on()
986
985
  ] }),
987
- L ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: L }) : null,
986
+ S ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-right", children: S }) : null,
988
987
  cn
989
988
  ] });
990
- return h === "outside-left" ? /* @__PURE__ */ o("div", { className: H, children: [
991
- /* @__PURE__ */ o("div", { className: "sa-tf-label-col", children: [
992
- q("sa-tf-label"),
993
- u ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: u }) : null
989
+ return c === "outside-left" ? /* @__PURE__ */ l("div", { className: q, children: [
990
+ /* @__PURE__ */ l("div", { className: "sa-tf-label-col", children: [
991
+ K("sa-tf-label"),
992
+ p ? /* @__PURE__ */ a("p", { className: "sa-tf-desc-top", children: p }) : null
994
993
  ] }),
995
- /* @__PURE__ */ o("div", { className: "sa-tf-input-col", children: [
994
+ /* @__PURE__ */ l("div", { className: "sa-tf-input-col", children: [
996
995
  X,
997
- K
996
+ P
998
997
  ] })
999
- ] }) : P ? /* @__PURE__ */ o("div", { className: H, children: [
998
+ ] }) : H ? /* @__PURE__ */ l("div", { className: q, children: [
1000
999
  X,
1001
- K
1002
- ] }) : /* @__PURE__ */ o("div", { className: H, children: [
1003
- q("sa-tf-label"),
1004
- u ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: u }) : null,
1000
+ P
1001
+ ] }) : /* @__PURE__ */ l("div", { className: q, children: [
1002
+ K("sa-tf-label"),
1003
+ p ? /* @__PURE__ */ a("p", { className: "sa-tf-desc-top", children: p }) : null,
1005
1004
  X,
1006
- K
1005
+ P
1007
1006
  ] });
1008
1007
  }
1009
1008
  ), _n = (n, e) => {
1010
1009
  if (!n)
1011
1010
  return null;
1012
1011
  if (!e)
1013
- return /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n });
1012
+ return /* @__PURE__ */ a("p", { className: "sa-tf-placeholder", children: n });
1014
1013
  const r = n.toLowerCase().indexOf(e.toLowerCase());
1015
- return r === -1 ? /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n }) : /* @__PURE__ */ o("p", { className: "sa-tf-placeholder", children: [
1014
+ return r === -1 ? /* @__PURE__ */ a("p", { className: "sa-tf-placeholder", children: n }) : /* @__PURE__ */ l("p", { className: "sa-tf-placeholder", children: [
1016
1015
  n.slice(0, r),
1017
- /* @__PURE__ */ s("span", { className: "sa-tf-placeholder-highlight", children: n.slice(r, r + e.length) }),
1016
+ /* @__PURE__ */ a("span", { className: "sa-tf-placeholder-highlight", children: n.slice(r, r + e.length) }),
1018
1017
  n.slice(r + e.length)
1019
1018
  ] });
1020
1019
  };
@@ -1030,7 +1029,7 @@ const Mn = `.sa-kbd {
1030
1029
  display: inline-flex;
1031
1030
  align-items: center;
1032
1031
  justify-content: center;
1033
- min-width: 1.5em;
1032
+ min-width: 1.5em; /* relative to font-size → scales with \`size\` */
1034
1033
  padding: 0 var(--sa-spacing-6, 6px);
1035
1034
  background-color: var(--sa-background-neutral, #f0f1f2);
1036
1035
  border: 1px solid var(--sa-border-subtle, #0b120e24);
@@ -1050,21 +1049,75 @@ const Mn = `.sa-kbd {
1050
1049
  font-size: var(--sa-font-size-sm, 12px);
1051
1050
  user-select: none;
1052
1051
  }
1053
- `, hn = "sa-kbd-styles", Pn = (n) => {
1052
+
1053
+ /* ── Sizes (matches Input's xs/sm/md/lg). \`min-width: 1.5em\` auto-scales;
1054
+ font-size + horizontal padding + gap driven per size. Default \`sm\` keeps
1055
+ the pre-existing look. ── */
1056
+ .sa-kbd-size-xs {
1057
+ gap: 3px;
1058
+ }
1059
+ .sa-kbd-size-xs .sa-kbd-key {
1060
+ padding: 0 4px;
1061
+ font-size: 10px;
1062
+ }
1063
+ .sa-kbd-size-xs .sa-kbd-sep {
1064
+ font-size: 10px;
1065
+ }
1066
+
1067
+ .sa-kbd-size-sm {
1068
+ gap: var(--sa-spacing-4, 4px);
1069
+ }
1070
+ .sa-kbd-size-sm .sa-kbd-key {
1071
+ padding: 0 var(--sa-spacing-6, 6px);
1072
+ font-size: var(--sa-font-size-sm, 12px);
1073
+ }
1074
+ .sa-kbd-size-sm .sa-kbd-sep {
1075
+ font-size: var(--sa-font-size-sm, 12px);
1076
+ }
1077
+
1078
+ .sa-kbd-size-md {
1079
+ gap: 5px;
1080
+ }
1081
+ .sa-kbd-size-md .sa-kbd-key {
1082
+ padding: 0 8px;
1083
+ font-size: 14px;
1084
+ }
1085
+ .sa-kbd-size-md .sa-kbd-sep {
1086
+ font-size: 14px;
1087
+ }
1088
+
1089
+ .sa-kbd-size-lg {
1090
+ gap: 6px;
1091
+ }
1092
+ .sa-kbd-size-lg .sa-kbd-key {
1093
+ padding: 0 10px;
1094
+ font-size: 16px;
1095
+ }
1096
+ .sa-kbd-size-lg .sa-kbd-sep {
1097
+ font-size: 16px;
1098
+ }
1099
+ `, hn = "sa-kbd-styles", Hn = (n) => {
1054
1100
  if (!(typeof document > "u") && !document.getElementById(hn)) {
1055
1101
  const e = document.createElement("style");
1056
1102
  e.id = hn, e.textContent = n, document.head.appendChild(e);
1057
1103
  }
1058
1104
  };
1059
- Pn(Mn);
1060
- function Hn({ keys: n, separator: e, className: r, ...l }) {
1061
- return /* @__PURE__ */ s("span", { className: `sa-kbd${r ? ` ${r}` : ""}`, ...l, children: n.map((d, f) => /* @__PURE__ */ o(Z.Fragment, { children: [
1062
- f > 0 && e != null ? /* @__PURE__ */ s("span", { className: "sa-kbd-sep", "aria-hidden": "true", children: e }) : null,
1063
- /* @__PURE__ */ s("kbd", { className: "sa-kbd-key", children: d })
1064
- ] }, f)) });
1065
- }
1066
- Hn.__saRaw = !0;
1105
+ Hn(Mn);
1106
+ function qn({ keys: n, separator: e, size: r = "sm", className: o, ...d }) {
1107
+ return /* @__PURE__ */ a(
1108
+ "span",
1109
+ {
1110
+ className: `sa-kbd sa-kbd-size-${r}${o ? ` ${o}` : ""}`,
1111
+ ...d,
1112
+ children: n.map((f, c) => /* @__PURE__ */ l(Z.Fragment, { children: [
1113
+ c > 0 && e != null ? /* @__PURE__ */ a("span", { className: "sa-kbd-sep", "aria-hidden": "true", children: e }) : null,
1114
+ /* @__PURE__ */ a("kbd", { className: "sa-kbd-key", children: f })
1115
+ ] }, c))
1116
+ }
1117
+ );
1118
+ }
1119
+ qn.__saRaw = !0;
1067
1120
  export {
1068
1121
  Wn as Input,
1069
- Hn as Kbd
1122
+ qn as Kbd
1070
1123
  };
package/dist/input.umd.js CHANGED
@@ -1,5 +1,4 @@
1
- (function(p,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):(p=typeof globalThis<"u"?globalThis:p||self,n(p.Input={},p.jsxRuntime,p.React))})(this,function(p,n,o){"use strict";const gn=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
2
-
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.Input={},b.jsxRuntime,b.React))})(this,function(b,n,o){"use strict";const gn=`
3
2
  :root {
4
3
  /* Layer 3 — references Layer 2 semantic tokens */
5
4
  --sa-input-text-primary: var(--sa-text-primary, #292a2e);
@@ -42,7 +41,7 @@
42
41
  flex-direction: column;
43
42
  align-items: stretch;
44
43
  gap: 8px;
45
- font-family: "Poppins", sans-serif;
44
+ font-family: var(--sa-font-family, "Inter", sans-serif);
46
45
  width: max-content;
47
46
  }
48
47
  .sa-tf *,
@@ -612,7 +611,7 @@
612
611
  .sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
613
612
  min-height: 80px;
614
613
  }
615
- `,k=t=>t==="lg"||t==="xl"?18:t==="xs"?14:16,D={default:"var(--sa-color-gray-800, #505258)",error:"var(--sa-text-error, #a4133c)",success:"var(--sa-text-success, #208958)",disable:"var(--sa-icon-disable, #181a198f)"},Q=(t,s)=>s?D.disable:D[t]??D.default;function hn(t){return Number(t.replace(/\./g,""))}function F(t){let s=t.replace(/[^\d]/g,"");return s=s.replace(/^0+(?=\d)/,""),s.replace(/\B(?=(\d{3})+(?!\d))/g,".")}function vn(t,s){if(s<=0)return 0;let i=0;for(let l=0;l<t.length;l++)if(/\d/.test(t[l])&&(i+=1,i===s))return l+1;return t.length}const mn=o.forwardRef(({options:t,value:s,setValue:i,isComponentVisible:l,onOptionChange:d},f)=>{const[v,T]=o.useState([]),c=o.useRef(null),u=()=>{if(f!=null&&f.current&&c.current){const g=window.innerHeight,b=f==null?void 0:f.current.getBoundingClientRect(),m=c.current.getBoundingClientRect(),w=b.bottom+m.height;c.current.style.left=`${b.left}px`,c.current.style.width=`${b.width}px`,w>=g-10?c.current.style.top=`${b.top-m.height-5}px`:c.current.style.top=`${b.top+b.height}px`}};return o.useEffect(()=>(window.addEventListener("scroll",u),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u),window.removeEventListener("resize",u)}),[f,c]),o.useEffect(()=>{u()},[l]),o.useEffect(()=>{T((t==null?void 0:t.filter(g=>g.toLowerCase().startsWith(s.toLowerCase())))||[])},[s,t]),n.jsx("div",{ref:c,style:{position:"fixed",padding:"8px",boxSizing:"border-box",boxShadow:"0px 8px 12px 0px var(--sa-color-black-alpha-a8, #00000014)",borderRadius:"8px",background:"white",overflow:"auto",zIndex:5e4},children:v==null?void 0:v.map(g=>wn(g,s,i,d))})}),wn=(t,s,i,l)=>{const d=t.toLowerCase().indexOf(s.toLowerCase());return n.jsxs("p",{style:{fontFamily:"Poppins",color:"var(--sa-color-gray-400, #b7b9be)",fontWeight:500,padding:"8px 14px",cursor:"pointer"},onClick:()=>{i(t),l&&l(t)},children:[t.slice(0,d),n.jsx("span",{style:{color:"var(--sa-text-primary, #292a2e)"},children:t.slice(d,d+s.length)}),t.slice(d+s.length)]})};function yn(t){const[s,i]=o.useState(t),l=o.useRef(null),d=f=>{l.current&&!l.current.contains(f.target)&&i(!1)};return o.useEffect(()=>(document.addEventListener("click",d,!0),()=>{document.removeEventListener("click",d,!0)}),[]),{ref:l,isComponentVisible:s,setIsComponentVisible:i}}const Z="sa-input-styles";(t=>{if(!(typeof document>"u")&&!document.getElementById(Z)){const s=document.createElement("style");s.id=Z,s.textContent=t,document.head.appendChild(s)}})(gn);const kn=t=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M5.2 8.2l1.8 1.8 3.8-4.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),zn=t=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"currentColor",opacity:"0.2"}),n.jsx("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]}),R=o.forwardRef((t,s)=>{const{size:i="sm",variant:l="outline",status:d="default",label:f,labelPosition:v="outside-top",required:T,optional:c,description:u,helperText:g,errorText:b,leftIcon:m,rightIcon:w,leftAddons:S,rightAddons:B,onClickLeftIcon:en,onClickRightIcon:O,fullWidth:In=!0,highlightPlaceholder:V,currency:E,options:L,onOptionChange:Y,clearable:Sn=!0,onClear:A,...a}=t,M=a.value!==void 0,[P,z]=o.useState(()=>{const e=a.value!==void 0?String(a.value??""):String(a.defaultValue??"");return E?F(e):e}),[sn,an]=o.useState(!1),[Bn,rn]=o.useState(""),C=o.useRef(null),N=o.useRef(null);o.useImperativeHandle(s,()=>N.current);const on=o.useRef(a.id??`sa-input-${Math.random().toString(36).slice(2,9)}`),{isComponentVisible:ln,ref:W,setIsComponentVisible:En}=yn(!1);o.useLayoutEffect(()=>{if(!M)return;const e=a.value===void 0||a.value===null?"":String(a.value),r=E?F(e):e;z(x=>x===r?x:r)},[a.value,E,M]),o.useLayoutEffect(()=>{if(C.current===null)return;const e=N.current,r=C.current;if(C.current=null,!!e)try{e.setSelectionRange(r,r)}catch{}},[P]);const I=P,$=I!==""&&I!==void 0,y=d==="disable"||a.disabled,_=y?"disable":d,q=v==="inside",Ln=q&&($||sn),H=["sa-tf",`sa-tf-variant-${l}`,`sa-tf-size-${i}`,`sa-tf-status-${_}`,`sa-tf-label-${v}`,sn?"sa-tf-focused":"",y?"sa-tf-disabled":"",Ln?"sa-tf-floating":"",f?"":"sa-tf-no-label",In?"sa-tf-fullwidth":""].filter(Boolean).join(" "),$n=()=>{var e;return(e=N.current)==null?void 0:e.focus()},jn=e=>{var bn,xn;if(!E){const j=e.target.selectionStart;j!==null&&(C.current=j),z(e.target.value),(bn=a.onChange)==null||bn.call(a,e);return}const r=e.target.value;let x=r,h=e.target.selectionStart??r.length;if(Bn==="Backspace"){const j=P.replace(/\D/g,""),Vn=r.replace(/\D/g,"");j.length===Vn.length&&h>0&&(x=r.slice(0,h-1)+r.slice(h),h-=1)}const J=F(x),Tn=x.slice(0,h).replace(/\D/g,"").length,On=vn(J,Tn);C.current=On,z(J),(xn=a.onChange)==null||xn.call(a,{...e,target:{...e.target,value:String(hn(J)),name:e.target.name}}),rn("")},K=e=>f?n.jsxs("div",{className:e,children:[n.jsx("label",{htmlFor:on.current,style:{cursor:y?"not-allowed":"pointer"},children:f}),c?n.jsx("span",{className:"sa-tf-optional",children:"Optional"}):null,T?n.jsx("span",{className:"sa-tf-required","aria-hidden":"true",children:"*"}):null]}):null,U=n.jsxs(n.Fragment,{children:[g?n.jsx("p",{className:"sa-tf-helper",children:g}):null,b&&d==="error"?n.jsx("p",{className:"sa-tf-error",children:b}):null]}),X=(e,r)=>n.jsx("span",{className:`sa-tf-icon${r?" sa-tf-icon-clickable":""}`,onClick:r,children:o.cloneElement(e,{width:k(i),height:k(i),color:Q(_,y),style:{color:Q(_,y)}})}),dn=()=>{var r;return w==null?null:!o.isValidElement(w)||((r=w.type)==null?void 0:r.__saRaw)===!0?n.jsx("span",{className:`sa-tf-icon${O?" sa-tf-icon-clickable":""}`,onClick:O,children:w}):X(w,O)},fn=d==="success"?n.jsx("span",{className:"sa-tf-icon sa-tf-success-mark","aria-hidden":"true",children:n.jsx(kn,{width:k(i),height:k(i)})}):null,Dn=e=>{var x;e.stopPropagation(),M||z("");const r={target:{value:"",name:a.name},currentTarget:{value:"",name:a.name}};(x=a.onChange)==null||x.call(a,r),A==null||A(),C.current=0,requestAnimationFrame(()=>{var h;return(h=N.current)==null?void 0:h.focus()})},cn=Sn&&!y?n.jsx("button",{type:"button",className:`sa-tf-icon sa-tf-clear${$?"":" sa-tf-clear-hidden"}`,"aria-label":"Clear input","aria-hidden":!$,tabIndex:-1,onClick:Dn,onMouseDown:e=>e.preventDefault(),children:n.jsx(zn,{width:k(i),height:k(i)})}):null,Fn=!$&&!!a.placeholder&&!!V,un=n.jsxs("div",{className:"sa-tf-field-wrap",children:[n.jsx("input",{...a,id:on.current,ref:N,className:"sa-tf-input",disabled:y,placeholder:V?"":a.placeholder,value:I,onFocus:e=>{var r;an(!0),En(!0),(r=a.onFocus)==null||r.call(a,e)},onBlur:e=>{var r;an(!1),(r=a.onBlur)==null||r.call(a,e)},onKeyDown:e=>{var r;e.key==="Backspace"&&rn(e.key),(r=a.onKeyDown)==null||r.call(a,e)},onChange:jn}),Fn?Cn(a.placeholder,V):null]}),pn=I&&ln&&(L!=null&&L.length)?n.jsx(mn,{options:L,value:I,setValue:z,ref:W,isComponentVisible:ln,onOptionChange:e=>{Y==null||Y(e),z(e)}}):null,G=q?n.jsxs("div",{className:"sa-tf-box",ref:W,onClick:$n,children:[S?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-left",children:S}):null,n.jsxs("div",{className:"sa-tf-box-content",children:[m?X(m,en):null,n.jsxs("div",{className:"sa-tf-inside-stack",children:[K("sa-tf-inside-label-row"),n.jsx("div",{className:"sa-tf-inside-row",children:un})]}),cn,fn,dn()]}),B?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:B}):null,pn]}):n.jsxs("div",{className:"sa-tf-box",ref:W,children:[S?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-left",children:S}):null,n.jsxs("div",{className:"sa-tf-box-content",children:[m?X(m,en):null,un,cn,fn,dn()]}),B?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:B}):null,pn]});return v==="outside-left"?n.jsxs("div",{className:H,children:[n.jsxs("div",{className:"sa-tf-label-col",children:[K("sa-tf-label"),u?n.jsx("p",{className:"sa-tf-desc-top",children:u}):null]}),n.jsxs("div",{className:"sa-tf-input-col",children:[G,U]})]}):q?n.jsxs("div",{className:H,children:[G,U]}):n.jsxs("div",{className:H,children:[K("sa-tf-label"),u?n.jsx("p",{className:"sa-tf-desc-top",children:u}):null,G,U]})}),Cn=(t,s)=>{if(!t)return null;if(!s)return n.jsx("p",{className:"sa-tf-placeholder",children:t});const i=t.toLowerCase().indexOf(s.toLowerCase());return i===-1?n.jsx("p",{className:"sa-tf-placeholder",children:t}):n.jsxs("p",{className:"sa-tf-placeholder",children:[t.slice(0,i),n.jsx("span",{className:"sa-tf-placeholder-highlight",children:t.slice(i,i+s.length)}),t.slice(i+s.length)]})};R.displayName="Input";const Nn=`.sa-kbd {
614
+ `,y=t=>t==="lg"||t==="xl"?18:t==="xs"?14:16,j={default:"var(--sa-color-gray-800, #505258)",error:"var(--sa-text-error, #a4133c)",success:"var(--sa-text-success, #208958)",disable:"var(--sa-icon-disable, #181a198f)"},Q=(t,e)=>e?j.disable:j[t]??j.default;function hn(t){return Number(t.replace(/\./g,""))}function F(t){let e=t.replace(/[^\d]/g,"");return e=e.replace(/^0+(?=\d)/,""),e.replace(/\B(?=(\d{3})+(?!\d))/g,".")}function vn(t,e){if(e<=0)return 0;let r=0;for(let l=0;l<t.length;l++)if(/\d/.test(t[l])&&(r+=1,r===e))return l+1;return t.length}const mn=o.forwardRef(({options:t,value:e,setValue:r,isComponentVisible:l,onOptionChange:d},f)=>{const[c,T]=o.useState([]),u=o.useRef(null),p=()=>{if(f!=null&&f.current&&u.current){const h=window.innerHeight,x=f==null?void 0:f.current.getBoundingClientRect(),m=u.current.getBoundingClientRect(),w=x.bottom+m.height;u.current.style.left=`${x.left}px`,u.current.style.width=`${x.width}px`,w>=h-10?u.current.style.top=`${x.top-m.height-5}px`:u.current.style.top=`${x.top+x.height}px`}};return o.useEffect(()=>(window.addEventListener("scroll",p),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p),window.removeEventListener("resize",p)}),[f,u]),o.useEffect(()=>{p()},[l]),o.useEffect(()=>{T((t==null?void 0:t.filter(h=>h.toLowerCase().startsWith(e.toLowerCase())))||[])},[e,t]),n.jsx("div",{ref:u,style:{position:"fixed",padding:"8px",boxSizing:"border-box",boxShadow:"0px 8px 12px 0px var(--sa-color-black-alpha-a8, #00000014)",borderRadius:"8px",background:"white",overflow:"auto",zIndex:5e4},children:c==null?void 0:c.map(h=>wn(h,e,r,d))})}),wn=(t,e,r,l)=>{const d=t.toLowerCase().indexOf(e.toLowerCase());return n.jsxs("p",{style:{fontFamily:'var(--sa-font-family, "Inter", sans-serif)',color:"var(--sa-color-gray-400, #b7b9be)",fontWeight:500,padding:"8px 14px",cursor:"pointer"},onClick:()=>{r(t),l&&l(t)},children:[t.slice(0,d),n.jsx("span",{style:{color:"var(--sa-text-primary, #292a2e)"},children:t.slice(d,d+e.length)}),t.slice(d+e.length)]})};function kn(t){const[e,r]=o.useState(t),l=o.useRef(null),d=f=>{l.current&&!l.current.contains(f.target)&&r(!1)};return o.useEffect(()=>(document.addEventListener("click",d,!0),()=>{document.removeEventListener("click",d,!0)}),[]),{ref:l,isComponentVisible:e,setIsComponentVisible:r}}const Z="sa-input-styles";(t=>{if(!(typeof document>"u")&&!document.getElementById(Z)){const e=document.createElement("style");e.id=Z,e.textContent=t,document.head.appendChild(e)}})(gn);const yn=t=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M5.2 8.2l1.8 1.8 3.8-4.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),zn=t=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[n.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"currentColor",opacity:"0.2"}),n.jsx("path",{d:"M5.5 5.5l5 5M10.5 5.5l-5 5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]}),R=o.forwardRef((t,e)=>{const{size:r="sm",variant:l="outline",status:d="default",label:f,labelPosition:c="outside-top",required:T,optional:u,description:p,helperText:h,errorText:x,leftIcon:m,rightIcon:w,leftAddons:S,rightAddons:B,onClickLeftIcon:sn,onClickRightIcon:O,fullWidth:In=!0,highlightPlaceholder:V,currency:E,options:L,onOptionChange:Y,clearable:Sn=!0,onClear:A,...a}=t,M=a.value!==void 0,[W,z]=o.useState(()=>{const s=a.value!==void 0?String(a.value??""):String(a.defaultValue??"");return E?F(s):s}),[en,an]=o.useState(!1),[Bn,rn]=o.useState(""),C=o.useRef(null),N=o.useRef(null);o.useImperativeHandle(e,()=>N.current);const on=o.useRef(a.id??`sa-input-${Math.random().toString(36).slice(2,9)}`),{isComponentVisible:ln,ref:_,setIsComponentVisible:En}=kn(!1);o.useLayoutEffect(()=>{if(!M)return;const s=a.value===void 0||a.value===null?"":String(a.value),i=E?F(s):s;z(g=>g===i?g:i)},[a.value,E,M]),o.useLayoutEffect(()=>{if(C.current===null)return;const s=N.current,i=C.current;if(C.current=null,!!s)try{s.setSelectionRange(i,i)}catch{}},[W]);const I=W,$=I!==""&&I!==void 0,k=d==="disable"||a.disabled,q=k?"disable":d,H=c==="inside",Ln=H&&($||en),K=["sa-tf",`sa-tf-variant-${l}`,`sa-tf-size-${r}`,`sa-tf-status-${q}`,`sa-tf-label-${c}`,en?"sa-tf-focused":"",k?"sa-tf-disabled":"",Ln?"sa-tf-floating":"",f?"":"sa-tf-no-label",In?"sa-tf-fullwidth":""].filter(Boolean).join(" "),$n=()=>{var s;return(s=N.current)==null?void 0:s.focus()},Dn=s=>{var bn,xn;if(!E){const D=s.target.selectionStart;D!==null&&(C.current=D),z(s.target.value),(bn=a.onChange)==null||bn.call(a,s);return}const i=s.target.value;let g=i,v=s.target.selectionStart??i.length;if(Bn==="Backspace"){const D=W.replace(/\D/g,""),Vn=i.replace(/\D/g,"");D.length===Vn.length&&v>0&&(g=i.slice(0,v-1)+i.slice(v),v-=1)}const J=F(g),Tn=g.slice(0,v).replace(/\D/g,"").length,On=vn(J,Tn);C.current=On,z(J),(xn=a.onChange)==null||xn.call(a,{...s,target:{...s.target,value:String(hn(J)),name:s.target.name}}),rn("")},P=s=>f?n.jsxs("div",{className:s,children:[n.jsx("label",{htmlFor:on.current,style:{cursor:k?"not-allowed":"pointer"},children:f}),u?n.jsx("span",{className:"sa-tf-optional",children:"Optional"}):null,T?n.jsx("span",{className:"sa-tf-required","aria-hidden":"true",children:"*"}):null]}):null,U=n.jsxs(n.Fragment,{children:[h?n.jsx("p",{className:"sa-tf-helper",children:h}):null,x&&d==="error"?n.jsx("p",{className:"sa-tf-error",children:x}):null]}),X=(s,i)=>n.jsx("span",{className:`sa-tf-icon${i?" sa-tf-icon-clickable":""}`,onClick:i,children:o.cloneElement(s,{width:y(r),height:y(r),color:Q(q,k),style:{color:Q(q,k)}})}),dn=()=>{var i;return w==null?null:!o.isValidElement(w)||((i=w.type)==null?void 0:i.__saRaw)===!0?n.jsx("span",{className:`sa-tf-icon${O?" sa-tf-icon-clickable":""}`,onClick:O,children:w}):X(w,O)},fn=d==="success"?n.jsx("span",{className:"sa-tf-icon sa-tf-success-mark","aria-hidden":"true",children:n.jsx(yn,{width:y(r),height:y(r)})}):null,jn=s=>{var g;s.stopPropagation(),M||z("");const i={target:{value:"",name:a.name},currentTarget:{value:"",name:a.name}};(g=a.onChange)==null||g.call(a,i),A==null||A(),C.current=0,requestAnimationFrame(()=>{var v;return(v=N.current)==null?void 0:v.focus()})},cn=Sn&&!k?n.jsx("button",{type:"button",className:`sa-tf-icon sa-tf-clear${$?"":" sa-tf-clear-hidden"}`,"aria-label":"Clear input","aria-hidden":!$,tabIndex:-1,onClick:jn,onMouseDown:s=>s.preventDefault(),children:n.jsx(zn,{width:y(r),height:y(r)})}):null,Fn=!$&&!!a.placeholder&&!!V,un=n.jsxs("div",{className:"sa-tf-field-wrap",children:[n.jsx("input",{...a,id:on.current,ref:N,className:"sa-tf-input",disabled:k,placeholder:V?"":a.placeholder,value:I,onFocus:s=>{var i;an(!0),En(!0),(i=a.onFocus)==null||i.call(a,s)},onBlur:s=>{var i;an(!1),(i=a.onBlur)==null||i.call(a,s)},onKeyDown:s=>{var i;s.key==="Backspace"&&rn(s.key),(i=a.onKeyDown)==null||i.call(a,s)},onChange:Dn}),Fn?Cn(a.placeholder,V):null]}),pn=I&&ln&&(L!=null&&L.length)?n.jsx(mn,{options:L,value:I,setValue:z,ref:_,isComponentVisible:ln,onOptionChange:s=>{Y==null||Y(s),z(s)}}):null,G=H?n.jsxs("div",{className:"sa-tf-box",ref:_,onClick:$n,children:[S?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-left",children:S}):null,n.jsxs("div",{className:"sa-tf-box-content",children:[m?X(m,sn):null,n.jsxs("div",{className:"sa-tf-inside-stack",children:[P("sa-tf-inside-label-row"),n.jsx("div",{className:"sa-tf-inside-row",children:un})]}),cn,fn,dn()]}),B?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:B}):null,pn]}):n.jsxs("div",{className:"sa-tf-box",ref:_,children:[S?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-left",children:S}):null,n.jsxs("div",{className:"sa-tf-box-content",children:[m?X(m,sn):null,un,cn,fn,dn()]}),B?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:B}):null,pn]});return c==="outside-left"?n.jsxs("div",{className:K,children:[n.jsxs("div",{className:"sa-tf-label-col",children:[P("sa-tf-label"),p?n.jsx("p",{className:"sa-tf-desc-top",children:p}):null]}),n.jsxs("div",{className:"sa-tf-input-col",children:[G,U]})]}):H?n.jsxs("div",{className:K,children:[G,U]}):n.jsxs("div",{className:K,children:[P("sa-tf-label"),p?n.jsx("p",{className:"sa-tf-desc-top",children:p}):null,G,U]})}),Cn=(t,e)=>{if(!t)return null;if(!e)return n.jsx("p",{className:"sa-tf-placeholder",children:t});const r=t.toLowerCase().indexOf(e.toLowerCase());return r===-1?n.jsx("p",{className:"sa-tf-placeholder",children:t}):n.jsxs("p",{className:"sa-tf-placeholder",children:[t.slice(0,r),n.jsx("span",{className:"sa-tf-placeholder-highlight",children:t.slice(r,r+e.length)}),t.slice(r+e.length)]})};R.displayName="Input";const Nn=`.sa-kbd {
616
615
  display: inline-flex;
617
616
  align-items: center;
618
617
  gap: var(--sa-spacing-4, 4px);
@@ -623,7 +622,7 @@
623
622
  display: inline-flex;
624
623
  align-items: center;
625
624
  justify-content: center;
626
- min-width: 1.5em;
625
+ min-width: 1.5em; /* relative to font-size → scales with \`size\` */
627
626
  padding: 0 var(--sa-spacing-6, 6px);
628
627
  background-color: var(--sa-background-neutral, #f0f1f2);
629
628
  border: 1px solid var(--sa-border-subtle, #0b120e24);
@@ -643,4 +642,51 @@
643
642
  font-size: var(--sa-font-size-sm, 12px);
644
643
  user-select: none;
645
644
  }
646
- `,nn="sa-kbd-styles";(t=>{if(!(typeof document>"u")&&!document.getElementById(nn)){const s=document.createElement("style");s.id=nn,s.textContent=t,document.head.appendChild(s)}})(Nn);function tn({keys:t,separator:s,className:i,...l}){return n.jsx("span",{className:`sa-kbd${i?` ${i}`:""}`,...l,children:t.map((d,f)=>n.jsxs(o.Fragment,{children:[f>0&&s!=null?n.jsx("span",{className:"sa-kbd-sep","aria-hidden":"true",children:s}):null,n.jsx("kbd",{className:"sa-kbd-key",children:d})]},f))})}tn.__saRaw=!0,p.Input=R,p.Kbd=tn,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
645
+
646
+ /* ── Sizes (matches Input's xs/sm/md/lg). \`min-width: 1.5em\` auto-scales;
647
+ font-size + horizontal padding + gap driven per size. Default \`sm\` keeps
648
+ the pre-existing look. ── */
649
+ .sa-kbd-size-xs {
650
+ gap: 3px;
651
+ }
652
+ .sa-kbd-size-xs .sa-kbd-key {
653
+ padding: 0 4px;
654
+ font-size: 10px;
655
+ }
656
+ .sa-kbd-size-xs .sa-kbd-sep {
657
+ font-size: 10px;
658
+ }
659
+
660
+ .sa-kbd-size-sm {
661
+ gap: var(--sa-spacing-4, 4px);
662
+ }
663
+ .sa-kbd-size-sm .sa-kbd-key {
664
+ padding: 0 var(--sa-spacing-6, 6px);
665
+ font-size: var(--sa-font-size-sm, 12px);
666
+ }
667
+ .sa-kbd-size-sm .sa-kbd-sep {
668
+ font-size: var(--sa-font-size-sm, 12px);
669
+ }
670
+
671
+ .sa-kbd-size-md {
672
+ gap: 5px;
673
+ }
674
+ .sa-kbd-size-md .sa-kbd-key {
675
+ padding: 0 8px;
676
+ font-size: 14px;
677
+ }
678
+ .sa-kbd-size-md .sa-kbd-sep {
679
+ font-size: 14px;
680
+ }
681
+
682
+ .sa-kbd-size-lg {
683
+ gap: 6px;
684
+ }
685
+ .sa-kbd-size-lg .sa-kbd-key {
686
+ padding: 0 10px;
687
+ font-size: 16px;
688
+ }
689
+ .sa-kbd-size-lg .sa-kbd-sep {
690
+ font-size: 16px;
691
+ }
692
+ `,nn="sa-kbd-styles";(t=>{if(!(typeof document>"u")&&!document.getElementById(nn)){const e=document.createElement("style");e.id=nn,e.textContent=t,document.head.appendChild(e)}})(Nn);function tn({keys:t,separator:e,size:r="sm",className:l,...d}){return n.jsx("span",{className:`sa-kbd sa-kbd-size-${r}${l?` ${l}`:""}`,...d,children:t.map((f,c)=>n.jsxs(o.Fragment,{children:[c>0&&e!=null?n.jsx("span",{className:"sa-kbd-sep","aria-hidden":"true",children:e}):null,n.jsx("kbd",{className:"sa-kbd-key",children:f})]},c))})}tn.__saRaw=!0,b.Input=R,b.Kbd=tn,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/input",
3
- "version": "4.2.2",
3
+ "version": "5.0.0",
4
4
  "description": "input component for starasia UI",
5
5
  "author": "Rizki Izzul Haq",
6
6
  "main": "dist/input.umd.js",