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