@starasia/input 6.1.0 → 6.2.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/input.es.js CHANGED
@@ -20,11 +20,14 @@ const $n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
20
20
  --sa-input-icon-disable: var(--sa-icon-disable, #181a198f);
21
21
 
22
22
  --sa-input-border-subtle: var(--sa-border-subtle, #0b120e24);
23
+ /* Batas field (outline/flushed) — ≥ 3:1 terhadap kanvas (WCAG 1.4.11).
24
+ border-subtle (≈1.2:1) tetap untuk badge optional & pemisah addon. */
25
+ --sa-input-border-field: var(--sa-border-input, #8c8f97);
23
26
  --sa-input-border-brand: var(--sa-border-focused, #1a4fa0);
24
27
  --sa-input-border-brand-subtle: var(--sa-color-brand-200, #99b3db);
25
28
  --sa-input-border-danger: var(--sa-border-danger, #c9184a);
26
29
  --sa-input-border-danger-subtle: var(--sa-color-error-200, #ffb3c1);
27
- --sa-input-border-success: var(--sa-background-success, #28ac6e);
30
+ --sa-input-border-success: var(--sa-border-success, #208958);
28
31
  --sa-input-border-disabled: var(--sa-border-disabled, #0515240e);
29
32
 
30
33
  --sa-input-bg-neutral: var(--sa-background-neutral, #f0f1f2);
@@ -152,7 +155,7 @@ const $n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
152
155
  position: relative;
153
156
  width: 100%;
154
157
  background: transparent;
155
- border: 1px solid var(--sa-input-border-subtle);
158
+ border: 1px solid var(--sa-input-border-field);
156
159
  overflow: hidden;
157
160
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
158
161
  }
@@ -191,7 +194,7 @@ const $n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
191
194
  /* variants */
192
195
  .sa-tf-variant-outline .sa-tf-box {
193
196
  background: transparent;
194
- border: 1px solid var(--sa-input-border-subtle);
197
+ border: 1px solid var(--sa-input-border-field);
195
198
  }
196
199
  .sa-tf-variant-standard .sa-tf-box {
197
200
  background: var(--sa-input-bg-neutral);
@@ -200,7 +203,7 @@ const $n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
200
203
  .sa-tf-variant-flushed .sa-tf-box {
201
204
  background: transparent;
202
205
  border: 0;
203
- border-bottom: 1px solid var(--sa-input-border-subtle);
206
+ border-bottom: 1px solid var(--sa-input-border-field);
204
207
  border-radius: 0;
205
208
  }
206
209
  .sa-tf-variant-borderless .sa-tf-box {
@@ -619,6 +622,16 @@ const $n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
619
622
  min-height: 80px;
620
623
  }
621
624
 
625
+ /* Forced colors (Windows High Contrast): fokus field ditandai ganti warna
626
+ border + ring box-shadow — keduanya hilang di mode ini (border dipaksa satu
627
+ warna, shadow dibuang). Ganti outline warna sistem. */
628
+ @media (forced-colors: active) {
629
+ .sa-tf-focused .sa-tf-box {
630
+ outline: 2px solid Highlight;
631
+ outline-offset: 1px;
632
+ }
633
+ }
634
+
622
635
  } /* @layer starasia.components */
623
636
  `, z = (n) => n === "lg" || n === "xl" ? 18 : n === "xs" ? 14 : 16, J = {
624
637
  default: "var(--sa-color-gray-800, #505258)",
@@ -718,7 +731,7 @@ const gn = "sa-input-styles", On = (n) => {
718
731
  }
719
732
  };
720
733
  On($n);
721
- const Yn = (n) => /* @__PURE__ */ l(
734
+ const Wn = (n) => /* @__PURE__ */ l(
722
735
  "svg",
723
736
  {
724
737
  viewBox: "0 0 16 16",
@@ -759,7 +772,7 @@ const Yn = (n) => /* @__PURE__ */ l(
759
772
  )
760
773
  ]
761
774
  }
762
- ), Wn = mn(
775
+ ), Yn = mn(
763
776
  (n, a) => {
764
777
  const {
765
778
  size: r = "sm",
@@ -784,9 +797,9 @@ const Yn = (n) => /* @__PURE__ */ l(
784
797
  options: E,
785
798
  onOptionChange: O,
786
799
  clearable: wn = !0,
787
- onClear: Y,
800
+ onClear: W,
788
801
  ...e
789
- } = n, A = e.value !== void 0, [W, k] = I(() => {
802
+ } = n, A = e.value !== void 0, [Y, k] = I(() => {
790
803
  const t = e.value !== void 0 ? String(e.value ?? "") : String(e.defaultValue ?? "");
791
804
  return L ? Q(t) : t;
792
805
  }), [tn, an] = I(!1), [kn, en] = I(""), y = S(null), C = S(null);
@@ -795,7 +808,7 @@ const Yn = (n) => /* @__PURE__ */ l(
795
808
  e.id ?? `sa-input-${Math.random().toString(36).slice(2, 9)}`
796
809
  ), {
797
810
  isComponentVisible: rn,
798
- ref: _,
811
+ ref: H,
799
812
  setIsComponentVisible: yn
800
813
  } = Vn(!1);
801
814
  bn(() => {
@@ -812,12 +825,12 @@ const Yn = (n) => /* @__PURE__ */ l(
812
825
  t.setSelectionRange(i, i);
813
826
  } catch {
814
827
  }
815
- }, [W]);
816
- const N = W, $ = N !== "" && N !== void 0, w = d === "disable" || e.disabled, M = w ? "disable" : d, H = c === "inside", zn = H && ($ || tn), q = [
828
+ }, [Y]);
829
+ const N = Y, $ = N !== "" && N !== void 0, w = d === "disable" || e.disabled, _ = w ? "disable" : d, M = c === "inside", zn = M && ($ || tn), q = [
817
830
  "sa-tf",
818
831
  `sa-tf-variant-${o}`,
819
832
  `sa-tf-size-${r}`,
820
- `sa-tf-status-${M}`,
833
+ `sa-tf-status-${_}`,
821
834
  `sa-tf-label-${c}`,
822
835
  tn ? "sa-tf-focused" : "",
823
836
  w ? "sa-tf-disabled" : "",
@@ -837,15 +850,15 @@ const Yn = (n) => /* @__PURE__ */ l(
837
850
  const i = t.target.value;
838
851
  let x = i, h = t.target.selectionStart ?? i.length;
839
852
  if (kn === "Backspace") {
840
- const D = W.replace(/\D/g, ""), Bn = i.replace(/\D/g, "");
853
+ const D = Y.replace(/\D/g, ""), Bn = i.replace(/\D/g, "");
841
854
  D.length === Bn.length && h > 0 && (x = i.slice(0, h - 1) + i.slice(h), h -= 1);
842
855
  }
843
- const G = Q(x), Sn = x.slice(0, h).replace(/\D/g, "").length, Rn = Fn(G, Sn);
844
- y.current = Rn, k(G), (pn = e.onChange) == null || pn.call(e, {
856
+ const X = Q(x), Sn = x.slice(0, h).replace(/\D/g, "").length, Rn = Fn(X, Sn);
857
+ y.current = Rn, k(X), (pn = e.onChange) == null || pn.call(e, {
845
858
  ...t,
846
859
  target: {
847
860
  ...t.target,
848
- value: String(Dn(G)),
861
+ value: String(Dn(X)),
849
862
  name: t.target.name
850
863
  }
851
864
  }), en("");
@@ -863,7 +876,7 @@ const Yn = (n) => /* @__PURE__ */ l(
863
876
  ] }) : null, P = /* @__PURE__ */ l(Ln, { children: [
864
877
  g ? /* @__PURE__ */ s("p", { className: "sa-tf-helper", children: g }) : null,
865
878
  b && d === "error" ? /* @__PURE__ */ s("p", { className: "sa-tf-error", children: b }) : null
866
- ] }), U = (t, i) => /* @__PURE__ */ s(
879
+ ] }), G = (t, i) => /* @__PURE__ */ s(
867
880
  "span",
868
881
  {
869
882
  className: `sa-tf-icon${i ? " sa-tf-icon-clickable" : ""}`,
@@ -871,8 +884,8 @@ const Yn = (n) => /* @__PURE__ */ l(
871
884
  children: Z.cloneElement(t, {
872
885
  width: z(r),
873
886
  height: z(r),
874
- color: xn(M, w),
875
- style: { color: xn(M, w) }
887
+ color: xn(_, w),
888
+ style: { color: xn(_, w) }
876
889
  })
877
890
  }
878
891
  ), on = () => {
@@ -884,9 +897,9 @@ const Yn = (n) => /* @__PURE__ */ l(
884
897
  onClick: j,
885
898
  children: v
886
899
  }
887
- ) : U(v, j);
900
+ ) : G(v, j);
888
901
  }, ln = d === "success" ? /* @__PURE__ */ s("span", { className: "sa-tf-icon sa-tf-success-mark", "aria-hidden": "true", children: /* @__PURE__ */ s(
889
- Yn,
902
+ Wn,
890
903
  {
891
904
  width: z(r),
892
905
  height: z(r)
@@ -906,7 +919,7 @@ const Yn = (n) => /* @__PURE__ */ l(
906
919
  target: { value: "", name: e.name },
907
920
  currentTarget: { value: "", name: e.name }
908
921
  };
909
- (x = e.onChange) == null || x.call(e, i), Y == null || Y(), y.current = 0, requestAnimationFrame(() => {
922
+ (x = e.onChange) == null || x.call(e, i), W == null || W(), y.current = 0, requestAnimationFrame(() => {
910
923
  var h;
911
924
  return (h = C.current) == null ? void 0 : h.focus();
912
925
  });
@@ -946,29 +959,29 @@ const Yn = (n) => /* @__PURE__ */ l(
946
959
  onChange: Nn
947
960
  }
948
961
  ),
949
- In ? _n(e.placeholder, V) : null
962
+ In ? Hn(e.placeholder, V) : null
950
963
  ] }), cn = N && rn && (E != null && E.length) ? /* @__PURE__ */ s(
951
964
  Tn,
952
965
  {
953
966
  options: E,
954
967
  value: N,
955
968
  setValue: k,
956
- ref: _,
969
+ ref: H,
957
970
  isComponentVisible: rn,
958
971
  onOptionChange: (t) => {
959
972
  O == null || O(t), k(t);
960
973
  }
961
974
  }
962
- ) : null, X = H ? /* @__PURE__ */ l(
975
+ ) : null, U = M ? /* @__PURE__ */ l(
963
976
  "div",
964
977
  {
965
978
  className: "sa-tf-box",
966
- ref: _,
979
+ ref: H,
967
980
  onClick: Cn,
968
981
  children: [
969
982
  R ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: R }) : null,
970
983
  /* @__PURE__ */ l("div", { className: "sa-tf-box-content", children: [
971
- m ? U(m, nn) : null,
984
+ m ? G(m, nn) : null,
972
985
  /* @__PURE__ */ l("div", { className: "sa-tf-inside-stack", children: [
973
986
  K("sa-tf-inside-label-row"),
974
987
  /* @__PURE__ */ s("div", { className: "sa-tf-inside-row", children: fn })
@@ -981,10 +994,10 @@ const Yn = (n) => /* @__PURE__ */ l(
981
994
  cn
982
995
  ]
983
996
  }
984
- ) : /* @__PURE__ */ l("div", { className: "sa-tf-box", ref: _, children: [
997
+ ) : /* @__PURE__ */ l("div", { className: "sa-tf-box", ref: H, children: [
985
998
  R ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: R }) : null,
986
999
  /* @__PURE__ */ l("div", { className: "sa-tf-box-content", children: [
987
- m ? U(m, nn) : null,
1000
+ m ? G(m, nn) : null,
988
1001
  fn,
989
1002
  dn,
990
1003
  ln,
@@ -999,20 +1012,20 @@ const Yn = (n) => /* @__PURE__ */ l(
999
1012
  p ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: p }) : null
1000
1013
  ] }),
1001
1014
  /* @__PURE__ */ l("div", { className: "sa-tf-input-col", children: [
1002
- X,
1015
+ U,
1003
1016
  P
1004
1017
  ] })
1005
- ] }) : H ? /* @__PURE__ */ l("div", { className: q, children: [
1006
- X,
1018
+ ] }) : M ? /* @__PURE__ */ l("div", { className: q, children: [
1019
+ U,
1007
1020
  P
1008
1021
  ] }) : /* @__PURE__ */ l("div", { className: q, children: [
1009
1022
  K("sa-tf-label"),
1010
1023
  p ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: p }) : null,
1011
- X,
1024
+ U,
1012
1025
  P
1013
1026
  ] });
1014
1027
  }
1015
- ), _n = (n, a) => {
1028
+ ), Hn = (n, a) => {
1016
1029
  if (!n)
1017
1030
  return null;
1018
1031
  if (!a)
@@ -1024,8 +1037,8 @@ const Yn = (n) => /* @__PURE__ */ l(
1024
1037
  n.slice(r + a.length)
1025
1038
  ] });
1026
1039
  };
1027
- Wn.displayName = "Input";
1028
- const Mn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
1040
+ Yn.displayName = "Input";
1041
+ const _n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
1029
1042
  starasia, components, utilities). CSS app/Tailwind utility selalu bisa
1030
1043
  menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
1031
1044
  @layer starasia.components {
@@ -1110,13 +1123,13 @@ const Mn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (ur
1110
1123
  }
1111
1124
 
1112
1125
  } /* @layer starasia.components */
1113
- `, hn = "sa-kbd-styles", Hn = (n) => {
1126
+ `, hn = "sa-kbd-styles", Mn = (n) => {
1114
1127
  if (!(typeof document > "u") && !document.getElementById(hn)) {
1115
1128
  const a = document.createElement("style");
1116
1129
  a.id = hn, a.textContent = n, document.head.appendChild(a);
1117
1130
  }
1118
1131
  };
1119
- Hn(Mn);
1132
+ Mn(_n);
1120
1133
  function qn({ keys: n, separator: a, size: r = "sm", className: o, ...d }) {
1121
1134
  return /* @__PURE__ */ s(
1122
1135
  "span",
@@ -1132,6 +1145,6 @@ function qn({ keys: n, separator: a, size: r = "sm", className: o, ...d }) {
1132
1145
  }
1133
1146
  qn.__saRaw = !0;
1134
1147
  export {
1135
- Wn as Input,
1148
+ Yn as Input,
1136
1149
  qn as Kbd
1137
1150
  };
package/dist/input.umd.js CHANGED
@@ -18,11 +18,14 @@
18
18
  --sa-input-icon-disable: var(--sa-icon-disable, #181a198f);
19
19
 
20
20
  --sa-input-border-subtle: var(--sa-border-subtle, #0b120e24);
21
+ /* Batas field (outline/flushed) — ≥ 3:1 terhadap kanvas (WCAG 1.4.11).
22
+ border-subtle (≈1.2:1) tetap untuk badge optional & pemisah addon. */
23
+ --sa-input-border-field: var(--sa-border-input, #8c8f97);
21
24
  --sa-input-border-brand: var(--sa-border-focused, #1a4fa0);
22
25
  --sa-input-border-brand-subtle: var(--sa-color-brand-200, #99b3db);
23
26
  --sa-input-border-danger: var(--sa-border-danger, #c9184a);
24
27
  --sa-input-border-danger-subtle: var(--sa-color-error-200, #ffb3c1);
25
- --sa-input-border-success: var(--sa-background-success, #28ac6e);
28
+ --sa-input-border-success: var(--sa-border-success, #208958);
26
29
  --sa-input-border-disabled: var(--sa-border-disabled, #0515240e);
27
30
 
28
31
  --sa-input-bg-neutral: var(--sa-background-neutral, #f0f1f2);
@@ -150,7 +153,7 @@
150
153
  position: relative;
151
154
  width: 100%;
152
155
  background: transparent;
153
- border: 1px solid var(--sa-input-border-subtle);
156
+ border: 1px solid var(--sa-input-border-field);
154
157
  overflow: hidden;
155
158
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
156
159
  }
@@ -189,7 +192,7 @@
189
192
  /* variants */
190
193
  .sa-tf-variant-outline .sa-tf-box {
191
194
  background: transparent;
192
- border: 1px solid var(--sa-input-border-subtle);
195
+ border: 1px solid var(--sa-input-border-field);
193
196
  }
194
197
  .sa-tf-variant-standard .sa-tf-box {
195
198
  background: var(--sa-input-bg-neutral);
@@ -198,7 +201,7 @@
198
201
  .sa-tf-variant-flushed .sa-tf-box {
199
202
  background: transparent;
200
203
  border: 0;
201
- border-bottom: 1px solid var(--sa-input-border-subtle);
204
+ border-bottom: 1px solid var(--sa-input-border-field);
202
205
  border-radius: 0;
203
206
  }
204
207
  .sa-tf-variant-borderless .sa-tf-box {
@@ -617,8 +620,18 @@
617
620
  min-height: 80px;
618
621
  }
619
622
 
623
+ /* Forced colors (Windows High Contrast): fokus field ditandai ganti warna
624
+ border + ring box-shadow — keduanya hilang di mode ini (border dipaksa satu
625
+ warna, shadow dibuang). Ganti outline warna sistem. */
626
+ @media (forced-colors: active) {
627
+ .sa-tf-focused .sa-tf-box {
628
+ outline: 2px solid Highlight;
629
+ outline-offset: 1px;
630
+ }
631
+ }
632
+
620
633
  } /* @layer starasia.components */
621
- `,k=s=>s==="lg"||s==="xl"?18:s==="xs"?14:16,T={default:"var(--sa-color-gray-800, #505258)",error:"var(--sa-text-error, #a4133c)",success:"var(--sa-text-success, #186742)",disable:"var(--sa-icon-disable, #181a198f)"},Q=(s,e)=>e?T.disable:T[s]??T.default;function hn(s){return Number(s.replace(/\./g,""))}function D(s){let e=s.replace(/[^\d]/g,"");return e=e.replace(/^0+(?=\d)/,""),e.replace(/\B(?=(\d{3})+(?!\d))/g,".")}function mn(s,e){if(e<=0)return 0;let r=0;for(let l=0;l<s.length;l++)if(/\d/.test(s[l])&&(r+=1,r===e))return l+1;return s.length}const vn=o.forwardRef(({options:s,value:e,setValue:r,isComponentVisible:l,onOptionChange:d},f)=>{const[c,F]=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(),v=u.current.getBoundingClientRect(),w=x.bottom+v.height;u.current.style.left=`${x.left}px`,u.current.style.width=`${x.width}px`,w>=h-10?u.current.style.top=`${x.top-v.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(()=>{F((s==null?void 0:s.filter(h=>h.toLowerCase().startsWith(e.toLowerCase())))||[])},[e,s]),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:"var(--sa-radii-md, 8px)",background:"var(--sa-background-primary, #ffffff)",overflow:"auto",zIndex:5e4},children:c==null?void 0:c.map(h=>wn(h,e,r,d))})}),wn=(s,e,r,l)=>{const d=s.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(s),l&&l(s)},children:[s.slice(0,d),n.jsx("span",{style:{color:"var(--sa-text-primary, #292a2e)"},children:s.slice(d,d+e.length)}),s.slice(d+e.length)]})};function yn(s){const[e,r]=o.useState(s),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";(s=>{if(!(typeof document>"u")&&!document.getElementById(Z)){const e=document.createElement("style");e.id=Z,e.textContent=s,document.head.appendChild(e)}})(gn);const kn=s=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s,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=s=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s,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((s,e)=>{const{size:r="sm",variant:l="outline",status:d="default",label:f,labelPosition:c="outside-top",required:F,optional:u,description:p,helperText:h,errorText:x,leftIcon:v,rightIcon:w,leftAddons:S,rightAddons:B,onClickLeftIcon:tn,onClickRightIcon:O,fullWidth:In=!0,highlightPlaceholder:V,currency:E,options:L,onOptionChange:Y,clearable:Sn=!0,onClear:A,...a}=s,M=a.value!==void 0,[W,z]=o.useState(()=>{const t=a.value!==void 0?String(a.value??""):String(a.defaultValue??"");return E?D(t):t}),[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}=yn(!1);o.useLayoutEffect(()=>{if(!M)return;const t=a.value===void 0||a.value===null?"":String(a.value),i=E?D(t):t;z(g=>g===i?g:i)},[a.value,E,M]),o.useLayoutEffect(()=>{if(C.current===null)return;const t=N.current,i=C.current;if(C.current=null,!!t)try{t.setSelectionRange(i,i)}catch{}},[W]);const I=W,$=I!==""&&I!==void 0,y=d==="disable"||a.disabled,q=y?"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":"",y?"sa-tf-disabled":"",Ln?"sa-tf-floating":"",f?"":"sa-tf-no-label",In?"sa-tf-fullwidth":""].filter(Boolean).join(" "),$n=()=>{var t;return(t=N.current)==null?void 0:t.focus()},jn=t=>{var bn,xn;if(!E){const j=t.target.selectionStart;j!==null&&(C.current=j),z(t.target.value),(bn=a.onChange)==null||bn.call(a,t);return}const i=t.target.value;let g=i,m=t.target.selectionStart??i.length;if(Bn==="Backspace"){const j=W.replace(/\D/g,""),Vn=i.replace(/\D/g,"");j.length===Vn.length&&m>0&&(g=i.slice(0,m-1)+i.slice(m),m-=1)}const J=D(g),Fn=g.slice(0,m).replace(/\D/g,"").length,On=mn(J,Fn);C.current=On,z(J),(xn=a.onChange)==null||xn.call(a,{...t,target:{...t.target,value:String(hn(J)),name:t.target.name}}),rn("")},P=t=>f?n.jsxs("div",{className:t,children:[n.jsx("label",{htmlFor:on.current,style:{cursor:y?"not-allowed":"pointer"},children:f}),u?n.jsx("span",{className:"sa-tf-optional",children:"Optional"}):null,F?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=(t,i)=>n.jsx("span",{className:`sa-tf-icon${i?" sa-tf-icon-clickable":""}`,onClick:i,children:o.cloneElement(t,{width:k(r),height:k(r),color:Q(q,y),style:{color:Q(q,y)}})}),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(kn,{width:k(r),height:k(r)})}):null,Tn=t=>{var g;t.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 m;return(m=N.current)==null?void 0:m.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:Tn,onMouseDown:t=>t.preventDefault(),children:n.jsx(zn,{width:k(r),height:k(r)})}):null,Dn=!$&&!!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:t=>{var i;an(!0),En(!0),(i=a.onFocus)==null||i.call(a,t)},onBlur:t=>{var i;an(!1),(i=a.onBlur)==null||i.call(a,t)},onKeyDown:t=>{var i;t.key==="Backspace"&&rn(t.key),(i=a.onKeyDown)==null||i.call(a,t)},onChange:jn}),Dn?Cn(a.placeholder,V):null]}),pn=I&&ln&&(L!=null&&L.length)?n.jsx(vn,{options:L,value:I,setValue:z,ref:_,isComponentVisible:ln,onOptionChange:t=>{Y==null||Y(t),z(t)}}):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:[v?X(v,tn):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:[v?X(v,tn):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=(s,e)=>{if(!s)return null;if(!e)return n.jsx("p",{className:"sa-tf-placeholder",children:s});const r=s.toLowerCase().indexOf(e.toLowerCase());return r===-1?n.jsx("p",{className:"sa-tf-placeholder",children:s}):n.jsxs("p",{className:"sa-tf-placeholder",children:[s.slice(0,r),n.jsx("span",{className:"sa-tf-placeholder-highlight",children:s.slice(r,r+e.length)}),s.slice(r+e.length)]})};R.displayName="Input";const Nn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
634
+ `,y=s=>s==="lg"||s==="xl"?18:s==="xs"?14:16,T={default:"var(--sa-color-gray-800, #505258)",error:"var(--sa-text-error, #a4133c)",success:"var(--sa-text-success, #186742)",disable:"var(--sa-icon-disable, #181a198f)"},Q=(s,a)=>a?T.disable:T[s]??T.default;function hn(s){return Number(s.replace(/\./g,""))}function D(s){let a=s.replace(/[^\d]/g,"");return a=a.replace(/^0+(?=\d)/,""),a.replace(/\B(?=(\d{3})+(?!\d))/g,".")}function mn(s,a){if(a<=0)return 0;let r=0;for(let l=0;l<s.length;l++)if(/\d/.test(s[l])&&(r+=1,r===a))return l+1;return s.length}const vn=o.forwardRef(({options:s,value:a,setValue:r,isComponentVisible:l,onOptionChange:d},f)=>{const[c,F]=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(),v=u.current.getBoundingClientRect(),w=x.bottom+v.height;u.current.style.left=`${x.left}px`,u.current.style.width=`${x.width}px`,w>=h-10?u.current.style.top=`${x.top-v.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(()=>{F((s==null?void 0:s.filter(h=>h.toLowerCase().startsWith(a.toLowerCase())))||[])},[a,s]),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:"var(--sa-radii-md, 8px)",background:"var(--sa-background-primary, #ffffff)",overflow:"auto",zIndex:5e4},children:c==null?void 0:c.map(h=>wn(h,a,r,d))})}),wn=(s,a,r,l)=>{const d=s.toLowerCase().indexOf(a.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(s),l&&l(s)},children:[s.slice(0,d),n.jsx("span",{style:{color:"var(--sa-text-primary, #292a2e)"},children:s.slice(d,d+a.length)}),s.slice(d+a.length)]})};function kn(s){const[a,r]=o.useState(s),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:a,setIsComponentVisible:r}}const Z="sa-input-styles";(s=>{if(!(typeof document>"u")&&!document.getElementById(Z)){const a=document.createElement("style");a.id=Z,a.textContent=s,document.head.appendChild(a)}})(gn);const yn=s=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s,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=s=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s,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((s,a)=>{const{size:r="sm",variant:l="outline",status:d="default",label:f,labelPosition:c="outside-top",required:F,optional:u,description:p,helperText:h,errorText:x,leftIcon:v,rightIcon:w,leftAddons:S,rightAddons:B,onClickLeftIcon:tn,onClickRightIcon:O,fullWidth:In=!0,highlightPlaceholder:V,currency:E,options:L,onOptionChange:W,clearable:Sn=!0,onClear:A,...e}=s,Y=e.value!==void 0,[H,z]=o.useState(()=>{const t=e.value!==void 0?String(e.value??""):String(e.defaultValue??"");return E?D(t):t}),[an,en]=o.useState(!1),[Bn,rn]=o.useState(""),C=o.useRef(null),N=o.useRef(null);o.useImperativeHandle(a,()=>N.current);const on=o.useRef(e.id??`sa-input-${Math.random().toString(36).slice(2,9)}`),{isComponentVisible:ln,ref:M,setIsComponentVisible:En}=kn(!1);o.useLayoutEffect(()=>{if(!Y)return;const t=e.value===void 0||e.value===null?"":String(e.value),i=E?D(t):t;z(g=>g===i?g:i)},[e.value,E,Y]),o.useLayoutEffect(()=>{if(C.current===null)return;const t=N.current,i=C.current;if(C.current=null,!!t)try{t.setSelectionRange(i,i)}catch{}},[H]);const I=H,$=I!==""&&I!==void 0,k=d==="disable"||e.disabled,_=k?"disable":d,q=c==="inside",Ln=q&&($||an),K=["sa-tf",`sa-tf-variant-${l}`,`sa-tf-size-${r}`,`sa-tf-status-${_}`,`sa-tf-label-${c}`,an?"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 t;return(t=N.current)==null?void 0:t.focus()},jn=t=>{var bn,xn;if(!E){const j=t.target.selectionStart;j!==null&&(C.current=j),z(t.target.value),(bn=e.onChange)==null||bn.call(e,t);return}const i=t.target.value;let g=i,m=t.target.selectionStart??i.length;if(Bn==="Backspace"){const j=H.replace(/\D/g,""),Vn=i.replace(/\D/g,"");j.length===Vn.length&&m>0&&(g=i.slice(0,m-1)+i.slice(m),m-=1)}const J=D(g),Fn=g.slice(0,m).replace(/\D/g,"").length,On=mn(J,Fn);C.current=On,z(J),(xn=e.onChange)==null||xn.call(e,{...t,target:{...t.target,value:String(hn(J)),name:t.target.name}}),rn("")},P=t=>f?n.jsxs("div",{className:t,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,F?n.jsx("span",{className:"sa-tf-required","aria-hidden":"true",children:"*"}):null]}):null,G=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]}),U=(t,i)=>n.jsx("span",{className:`sa-tf-icon${i?" sa-tf-icon-clickable":""}`,onClick:i,children:o.cloneElement(t,{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}):U(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,Tn=t=>{var g;t.stopPropagation(),Y||z("");const i={target:{value:"",name:e.name},currentTarget:{value:"",name:e.name}};(g=e.onChange)==null||g.call(e,i),A==null||A(),C.current=0,requestAnimationFrame(()=>{var m;return(m=N.current)==null?void 0:m.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:Tn,onMouseDown:t=>t.preventDefault(),children:n.jsx(zn,{width:y(r),height:y(r)})}):null,Dn=!$&&!!e.placeholder&&!!V,un=n.jsxs("div",{className:"sa-tf-field-wrap",children:[n.jsx("input",{...e,id:on.current,ref:N,className:"sa-tf-input",disabled:k,placeholder:V?"":e.placeholder,value:I,onFocus:t=>{var i;en(!0),En(!0),(i=e.onFocus)==null||i.call(e,t)},onBlur:t=>{var i;en(!1),(i=e.onBlur)==null||i.call(e,t)},onKeyDown:t=>{var i;t.key==="Backspace"&&rn(t.key),(i=e.onKeyDown)==null||i.call(e,t)},onChange:jn}),Dn?Cn(e.placeholder,V):null]}),pn=I&&ln&&(L!=null&&L.length)?n.jsx(vn,{options:L,value:I,setValue:z,ref:M,isComponentVisible:ln,onOptionChange:t=>{W==null||W(t),z(t)}}):null,X=q?n.jsxs("div",{className:"sa-tf-box",ref:M,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:[v?U(v,tn):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:M,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:[v?U(v,tn):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:[X,G]})]}):q?n.jsxs("div",{className:K,children:[X,G]}):n.jsxs("div",{className:K,children:[P("sa-tf-label"),p?n.jsx("p",{className:"sa-tf-desc-top",children:p}):null,X,G]})}),Cn=(s,a)=>{if(!s)return null;if(!a)return n.jsx("p",{className:"sa-tf-placeholder",children:s});const r=s.toLowerCase().indexOf(a.toLowerCase());return r===-1?n.jsx("p",{className:"sa-tf-placeholder",children:s}):n.jsxs("p",{className:"sa-tf-placeholder",children:[s.slice(0,r),n.jsx("span",{className:"sa-tf-placeholder-highlight",children:s.slice(r,r+a.length)}),s.slice(r+a.length)]})};R.displayName="Input";const Nn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
622
635
  starasia, components, utilities). CSS app/Tailwind utility selalu bisa
623
636
  menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
624
637
  @layer starasia.components {
@@ -703,4 +716,4 @@
703
716
  }
704
717
 
705
718
  } /* @layer starasia.components */
706
- `,nn="sa-kbd-styles";(s=>{if(!(typeof document>"u")&&!document.getElementById(nn)){const e=document.createElement("style");e.id=nn,e.textContent=s,document.head.appendChild(e)}})(Nn);function sn({keys:s,separator:e,size:r="sm",className:l,...d}){return n.jsx("span",{className:`sa-kbd sa-kbd-size-${r}${l?` ${l}`:""}`,...d,children:s.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))})}sn.__saRaw=!0,b.Input=R,b.Kbd=sn,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
719
+ `,nn="sa-kbd-styles";(s=>{if(!(typeof document>"u")&&!document.getElementById(nn)){const a=document.createElement("style");a.id=nn,a.textContent=s,document.head.appendChild(a)}})(Nn);function sn({keys:s,separator:a,size:r="sm",className:l,...d}){return n.jsx("span",{className:`sa-kbd sa-kbd-size-${r}${l?` ${l}`:""}`,...d,children:s.map((f,c)=>n.jsxs(o.Fragment,{children:[c>0&&a!=null?n.jsx("span",{className:"sa-kbd-sep","aria-hidden":"true",children:a}):null,n.jsx("kbd",{className:"sa-kbd-key",children:f})]},c))})}sn.__saRaw=!0,b.Input=R,b.Kbd=sn,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/input",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "description": "input component for starasia UI",
5
5
  "author": "Rizki Izzul Haq",
6
6
  "main": "dist/input.umd.js",