@starasia/input 4.2.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/input.es.js +73 -68
- package/dist/input.umd.js +8 -3
- package/package.json +1 -1
package/dist/input.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import Z, { forwardRef as mn, useState as I, useRef as R, useEffect as
|
|
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
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 {
|
|
@@ -256,6 +256,11 @@ const $n = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
256
256
|
border: 0 !important;
|
|
257
257
|
box-shadow: none !important;
|
|
258
258
|
}
|
|
259
|
+
/* Borderless: tanpa padding (flush ke container) — override base + size padding.
|
|
260
|
+
Ditempatkan setelah aturan size agar menang pada specificity yang setara. */
|
|
261
|
+
.sa-tf-variant-borderless .sa-tf-box-content {
|
|
262
|
+
padding: 0;
|
|
263
|
+
}
|
|
259
264
|
.sa-tf-variant-standard.sa-tf-status-error .sa-tf-box {
|
|
260
265
|
background: var(--sa-input-bg-error-subtlest);
|
|
261
266
|
}
|
|
@@ -615,14 +620,14 @@ const $n = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
615
620
|
success: "var(--sa-text-success, #208958)",
|
|
616
621
|
disable: "var(--sa-icon-disable, #181a198f)"
|
|
617
622
|
}, xn = (n, e) => e ? J.disable : J[n] ?? J.default;
|
|
618
|
-
function
|
|
623
|
+
function Dn(n) {
|
|
619
624
|
return Number(n.replace(/\./g, ""));
|
|
620
625
|
}
|
|
621
626
|
function Q(n) {
|
|
622
627
|
let e = n.replace(/[^\d]/g, "");
|
|
623
628
|
return e = e.replace(/^0+(?=\d)/, ""), e.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
624
629
|
}
|
|
625
|
-
function
|
|
630
|
+
function Fn(n, e) {
|
|
626
631
|
if (e <= 0)
|
|
627
632
|
return 0;
|
|
628
633
|
let r = 0;
|
|
@@ -639,17 +644,17 @@ const Tn = mn(
|
|
|
639
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
645
|
}
|
|
641
646
|
};
|
|
642
|
-
return
|
|
647
|
+
return F(() => (window.addEventListener("scroll", u), window.addEventListener("resize", u), () => {
|
|
643
648
|
window.removeEventListener("scroll", u), window.removeEventListener("resize", u);
|
|
644
|
-
}), [f, c]),
|
|
649
|
+
}), [f, c]), F(() => {
|
|
645
650
|
u();
|
|
646
|
-
}, [l]),
|
|
651
|
+
}, [l]), F(() => {
|
|
647
652
|
T(
|
|
648
653
|
(n == null ? void 0 : n.filter(
|
|
649
654
|
(x) => x.toLowerCase().startsWith(e.toLowerCase())
|
|
650
655
|
)) || []
|
|
651
656
|
);
|
|
652
|
-
}, [e, n]), /* @__PURE__ */
|
|
657
|
+
}, [e, n]), /* @__PURE__ */ s(
|
|
653
658
|
"div",
|
|
654
659
|
{
|
|
655
660
|
ref: c,
|
|
@@ -686,7 +691,7 @@ const Tn = mn(
|
|
|
686
691
|
},
|
|
687
692
|
children: [
|
|
688
693
|
n.slice(0, d),
|
|
689
|
-
/* @__PURE__ */
|
|
694
|
+
/* @__PURE__ */ s("span", { style: { color: "var(--sa-text-primary, #292a2e)" }, children: n.slice(d, d + e.length) }),
|
|
690
695
|
n.slice(d + e.length)
|
|
691
696
|
]
|
|
692
697
|
}
|
|
@@ -696,7 +701,7 @@ function On(n) {
|
|
|
696
701
|
const [e, r] = I(n), l = R(null), d = (f) => {
|
|
697
702
|
l.current && !l.current.contains(f.target) && r(!1);
|
|
698
703
|
};
|
|
699
|
-
return
|
|
704
|
+
return F(() => (document.addEventListener("click", d, !0), () => {
|
|
700
705
|
document.removeEventListener("click", d, !0);
|
|
701
706
|
}), []), { ref: l, isComponentVisible: e, setIsComponentVisible: r };
|
|
702
707
|
}
|
|
@@ -715,8 +720,8 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
715
720
|
xmlns: "http://www.w3.org/2000/svg",
|
|
716
721
|
...n,
|
|
717
722
|
children: [
|
|
718
|
-
/* @__PURE__ */
|
|
719
|
-
/* @__PURE__ */
|
|
723
|
+
/* @__PURE__ */ s("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
724
|
+
/* @__PURE__ */ s(
|
|
720
725
|
"path",
|
|
721
726
|
{
|
|
722
727
|
d: "M5.2 8.2l1.8 1.8 3.8-4.2",
|
|
@@ -736,8 +741,8 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
736
741
|
xmlns: "http://www.w3.org/2000/svg",
|
|
737
742
|
...n,
|
|
738
743
|
children: [
|
|
739
|
-
/* @__PURE__ */
|
|
740
|
-
/* @__PURE__ */
|
|
744
|
+
/* @__PURE__ */ s("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
|
|
745
|
+
/* @__PURE__ */ s(
|
|
741
746
|
"path",
|
|
742
747
|
{
|
|
743
748
|
d: "M5.5 5.5l5 5M10.5 5.5l-5 5",
|
|
@@ -774,14 +779,14 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
774
779
|
onOptionChange: j,
|
|
775
780
|
clearable: wn = !0,
|
|
776
781
|
onClear: Y,
|
|
777
|
-
...
|
|
778
|
-
} = n, A =
|
|
779
|
-
const t =
|
|
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 ?? "");
|
|
780
785
|
return S ? Q(t) : t;
|
|
781
|
-
}), [tn, en] = I(!1), [yn,
|
|
786
|
+
}), [tn, en] = I(!1), [yn, an] = I(""), k = R(null), C = R(null);
|
|
782
787
|
En(e, () => C.current);
|
|
783
|
-
const
|
|
784
|
-
|
|
788
|
+
const sn = R(
|
|
789
|
+
a.id ?? `sa-input-${Math.random().toString(36).slice(2, 9)}`
|
|
785
790
|
), {
|
|
786
791
|
isComponentVisible: rn,
|
|
787
792
|
ref: _,
|
|
@@ -790,9 +795,9 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
790
795
|
pn(() => {
|
|
791
796
|
if (!A)
|
|
792
797
|
return;
|
|
793
|
-
const t =
|
|
798
|
+
const t = a.value === void 0 || a.value === null ? "" : String(a.value), i = S ? Q(t) : t;
|
|
794
799
|
y((p) => p === i ? p : i);
|
|
795
|
-
}, [
|
|
800
|
+
}, [a.value, S, A]), pn(() => {
|
|
796
801
|
if (k.current === null)
|
|
797
802
|
return;
|
|
798
803
|
const t = C.current, i = k.current;
|
|
@@ -802,7 +807,7 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
802
807
|
} catch {
|
|
803
808
|
}
|
|
804
809
|
}, [W]);
|
|
805
|
-
const N = W, $ = N !== "" && N !== void 0, w = d === "disable" ||
|
|
810
|
+
const N = W, $ = N !== "" && N !== void 0, w = d === "disable" || a.disabled, M = w ? "disable" : d, P = h === "inside", zn = P && ($ || tn), H = [
|
|
806
811
|
"sa-tf",
|
|
807
812
|
`sa-tf-variant-${l}`,
|
|
808
813
|
`sa-tf-size-${r}`,
|
|
@@ -819,40 +824,40 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
819
824
|
}, Nn = (t) => {
|
|
820
825
|
var un, bn;
|
|
821
826
|
if (!S) {
|
|
822
|
-
const
|
|
823
|
-
|
|
827
|
+
const D = t.target.selectionStart;
|
|
828
|
+
D !== null && (k.current = D), y(t.target.value), (un = a.onChange) == null || un.call(a, t);
|
|
824
829
|
return;
|
|
825
830
|
}
|
|
826
831
|
const i = t.target.value;
|
|
827
832
|
let p = i, g = t.target.selectionStart ?? i.length;
|
|
828
833
|
if (yn === "Backspace") {
|
|
829
|
-
const
|
|
830
|
-
|
|
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
836
|
}
|
|
832
|
-
const G = Q(p), Rn = p.slice(0, g).replace(/\D/g, "").length, Bn =
|
|
833
|
-
k.current = Bn, y(G), (bn =
|
|
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, {
|
|
834
839
|
...t,
|
|
835
840
|
target: {
|
|
836
841
|
...t.target,
|
|
837
|
-
value: String(
|
|
842
|
+
value: String(Dn(G)),
|
|
838
843
|
name: t.target.name
|
|
839
844
|
}
|
|
840
|
-
}),
|
|
845
|
+
}), an("");
|
|
841
846
|
}, q = (t) => f ? /* @__PURE__ */ o("div", { className: t, children: [
|
|
842
|
-
/* @__PURE__ */
|
|
847
|
+
/* @__PURE__ */ s(
|
|
843
848
|
"label",
|
|
844
849
|
{
|
|
845
|
-
htmlFor:
|
|
850
|
+
htmlFor: sn.current,
|
|
846
851
|
style: { cursor: w ? "not-allowed" : "pointer" },
|
|
847
852
|
children: f
|
|
848
853
|
}
|
|
849
854
|
),
|
|
850
|
-
c ? /* @__PURE__ */
|
|
851
|
-
T ? /* @__PURE__ */
|
|
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
|
|
852
857
|
] }) : null, K = /* @__PURE__ */ o(Sn, { children: [
|
|
853
|
-
x ? /* @__PURE__ */
|
|
854
|
-
b && d === "error" ? /* @__PURE__ */
|
|
855
|
-
] }), U = (t, i) => /* @__PURE__ */
|
|
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(
|
|
856
861
|
"span",
|
|
857
862
|
{
|
|
858
863
|
className: `sa-tf-icon${i ? " sa-tf-icon-clickable" : ""}`,
|
|
@@ -866,7 +871,7 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
866
871
|
}
|
|
867
872
|
), on = () => {
|
|
868
873
|
var i;
|
|
869
|
-
return v == null ? null : !Z.isValidElement(v) || ((i = v.type) == null ? void 0 : i.__saRaw) === !0 ? /* @__PURE__ */
|
|
874
|
+
return v == null ? null : !Z.isValidElement(v) || ((i = v.type) == null ? void 0 : i.__saRaw) === !0 ? /* @__PURE__ */ s(
|
|
870
875
|
"span",
|
|
871
876
|
{
|
|
872
877
|
className: `sa-tf-icon${V ? " sa-tf-icon-clickable" : ""}`,
|
|
@@ -874,13 +879,13 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
874
879
|
children: v
|
|
875
880
|
}
|
|
876
881
|
) : U(v, V);
|
|
877
|
-
}, ln = d === "success" ? /* @__PURE__ */
|
|
882
|
+
}, ln = d === "success" ? /* @__PURE__ */ s("span", { className: "sa-tf-icon sa-tf-success-mark", "aria-hidden": "true", children: /* @__PURE__ */ s(
|
|
878
883
|
Yn,
|
|
879
884
|
{
|
|
880
885
|
width: z(r),
|
|
881
886
|
height: z(r)
|
|
882
887
|
}
|
|
883
|
-
) }) : null, dn = wn && !w ? /* @__PURE__ */
|
|
888
|
+
) }) : null, dn = wn && !w ? /* @__PURE__ */ s(
|
|
884
889
|
"button",
|
|
885
890
|
{
|
|
886
891
|
type: "button",
|
|
@@ -892,16 +897,16 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
892
897
|
var p;
|
|
893
898
|
t.stopPropagation(), A || y("");
|
|
894
899
|
const i = {
|
|
895
|
-
target: { value: "", name:
|
|
896
|
-
currentTarget: { value: "", name:
|
|
900
|
+
target: { value: "", name: a.name },
|
|
901
|
+
currentTarget: { value: "", name: a.name }
|
|
897
902
|
};
|
|
898
|
-
(p =
|
|
903
|
+
(p = a.onChange) == null || p.call(a, i), Y == null || Y(), k.current = 0, requestAnimationFrame(() => {
|
|
899
904
|
var g;
|
|
900
905
|
return (g = C.current) == null ? void 0 : g.focus();
|
|
901
906
|
});
|
|
902
907
|
},
|
|
903
908
|
onMouseDown: (t) => t.preventDefault(),
|
|
904
|
-
children: /* @__PURE__ */
|
|
909
|
+
children: /* @__PURE__ */ s(
|
|
905
910
|
An,
|
|
906
911
|
{
|
|
907
912
|
width: z(r),
|
|
@@ -909,34 +914,34 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
909
914
|
}
|
|
910
915
|
)
|
|
911
916
|
}
|
|
912
|
-
) : null, In = !$ && !!
|
|
913
|
-
/* @__PURE__ */
|
|
917
|
+
) : null, In = !$ && !!a.placeholder && !!O, fn = /* @__PURE__ */ o("div", { className: "sa-tf-field-wrap", children: [
|
|
918
|
+
/* @__PURE__ */ s(
|
|
914
919
|
"input",
|
|
915
920
|
{
|
|
916
|
-
...
|
|
917
|
-
id:
|
|
921
|
+
...a,
|
|
922
|
+
id: sn.current,
|
|
918
923
|
ref: C,
|
|
919
924
|
className: "sa-tf-input",
|
|
920
925
|
disabled: w,
|
|
921
|
-
placeholder: O ? "" :
|
|
926
|
+
placeholder: O ? "" : a.placeholder,
|
|
922
927
|
value: N,
|
|
923
928
|
onFocus: (t) => {
|
|
924
929
|
var i;
|
|
925
|
-
en(!0), kn(!0), (i =
|
|
930
|
+
en(!0), kn(!0), (i = a.onFocus) == null || i.call(a, t);
|
|
926
931
|
},
|
|
927
932
|
onBlur: (t) => {
|
|
928
933
|
var i;
|
|
929
|
-
en(!1), (i =
|
|
934
|
+
en(!1), (i = a.onBlur) == null || i.call(a, t);
|
|
930
935
|
},
|
|
931
936
|
onKeyDown: (t) => {
|
|
932
937
|
var i;
|
|
933
|
-
t.key === "Backspace" &&
|
|
938
|
+
t.key === "Backspace" && an(t.key), (i = a.onKeyDown) == null || i.call(a, t);
|
|
934
939
|
},
|
|
935
940
|
onChange: Nn
|
|
936
941
|
}
|
|
937
942
|
),
|
|
938
|
-
In ? _n(
|
|
939
|
-
] }), cn = N && rn && (E != null && E.length) ? /* @__PURE__ */
|
|
943
|
+
In ? _n(a.placeholder, O) : null
|
|
944
|
+
] }), cn = N && rn && (E != null && E.length) ? /* @__PURE__ */ s(
|
|
940
945
|
Tn,
|
|
941
946
|
{
|
|
942
947
|
options: E,
|
|
@@ -955,23 +960,23 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
955
960
|
ref: _,
|
|
956
961
|
onClick: Cn,
|
|
957
962
|
children: [
|
|
958
|
-
B ? /* @__PURE__ */
|
|
963
|
+
B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
|
|
959
964
|
/* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
|
|
960
965
|
m ? U(m, nn) : null,
|
|
961
966
|
/* @__PURE__ */ o("div", { className: "sa-tf-inside-stack", children: [
|
|
962
967
|
q("sa-tf-inside-label-row"),
|
|
963
|
-
/* @__PURE__ */
|
|
968
|
+
/* @__PURE__ */ s("div", { className: "sa-tf-inside-row", children: fn })
|
|
964
969
|
] }),
|
|
965
970
|
dn,
|
|
966
971
|
ln,
|
|
967
972
|
on()
|
|
968
973
|
] }),
|
|
969
|
-
L ? /* @__PURE__ */
|
|
974
|
+
L ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: L }) : null,
|
|
970
975
|
cn
|
|
971
976
|
]
|
|
972
977
|
}
|
|
973
978
|
) : /* @__PURE__ */ o("div", { className: "sa-tf-box", ref: _, children: [
|
|
974
|
-
B ? /* @__PURE__ */
|
|
979
|
+
B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
|
|
975
980
|
/* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
|
|
976
981
|
m ? U(m, nn) : null,
|
|
977
982
|
fn,
|
|
@@ -979,13 +984,13 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
979
984
|
ln,
|
|
980
985
|
on()
|
|
981
986
|
] }),
|
|
982
|
-
L ? /* @__PURE__ */
|
|
987
|
+
L ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: L }) : null,
|
|
983
988
|
cn
|
|
984
989
|
] });
|
|
985
990
|
return h === "outside-left" ? /* @__PURE__ */ o("div", { className: H, children: [
|
|
986
991
|
/* @__PURE__ */ o("div", { className: "sa-tf-label-col", children: [
|
|
987
992
|
q("sa-tf-label"),
|
|
988
|
-
u ? /* @__PURE__ */
|
|
993
|
+
u ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: u }) : null
|
|
989
994
|
] }),
|
|
990
995
|
/* @__PURE__ */ o("div", { className: "sa-tf-input-col", children: [
|
|
991
996
|
X,
|
|
@@ -996,7 +1001,7 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
996
1001
|
K
|
|
997
1002
|
] }) : /* @__PURE__ */ o("div", { className: H, children: [
|
|
998
1003
|
q("sa-tf-label"),
|
|
999
|
-
u ? /* @__PURE__ */
|
|
1004
|
+
u ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: u }) : null,
|
|
1000
1005
|
X,
|
|
1001
1006
|
K
|
|
1002
1007
|
] });
|
|
@@ -1005,11 +1010,11 @@ const Yn = (n) => /* @__PURE__ */ o(
|
|
|
1005
1010
|
if (!n)
|
|
1006
1011
|
return null;
|
|
1007
1012
|
if (!e)
|
|
1008
|
-
return /* @__PURE__ */
|
|
1013
|
+
return /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n });
|
|
1009
1014
|
const r = n.toLowerCase().indexOf(e.toLowerCase());
|
|
1010
|
-
return r === -1 ? /* @__PURE__ */
|
|
1015
|
+
return r === -1 ? /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n }) : /* @__PURE__ */ o("p", { className: "sa-tf-placeholder", children: [
|
|
1011
1016
|
n.slice(0, r),
|
|
1012
|
-
/* @__PURE__ */
|
|
1017
|
+
/* @__PURE__ */ s("span", { className: "sa-tf-placeholder-highlight", children: n.slice(r, r + e.length) }),
|
|
1013
1018
|
n.slice(r + e.length)
|
|
1014
1019
|
] });
|
|
1015
1020
|
};
|
|
@@ -1053,9 +1058,9 @@ const Mn = `.sa-kbd {
|
|
|
1053
1058
|
};
|
|
1054
1059
|
Pn(Mn);
|
|
1055
1060
|
function Hn({ keys: n, separator: e, className: r, ...l }) {
|
|
1056
|
-
return /* @__PURE__ */
|
|
1057
|
-
f > 0 && e != null ? /* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
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 })
|
|
1059
1064
|
] }, f)) });
|
|
1060
1065
|
}
|
|
1061
1066
|
Hn.__saRaw = !0;
|
package/dist/input.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
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
2
|
|
|
3
3
|
:root {
|
|
4
4
|
/* Layer 3 — references Layer 2 semantic tokens */
|
|
@@ -254,6 +254,11 @@
|
|
|
254
254
|
border: 0 !important;
|
|
255
255
|
box-shadow: none !important;
|
|
256
256
|
}
|
|
257
|
+
/* Borderless: tanpa padding (flush ke container) — override base + size padding.
|
|
258
|
+
Ditempatkan setelah aturan size agar menang pada specificity yang setara. */
|
|
259
|
+
.sa-tf-variant-borderless .sa-tf-box-content {
|
|
260
|
+
padding: 0;
|
|
261
|
+
}
|
|
257
262
|
.sa-tf-variant-standard.sa-tf-status-error .sa-tf-box {
|
|
258
263
|
background: var(--sa-input-bg-error-subtlest);
|
|
259
264
|
}
|
|
@@ -607,7 +612,7 @@
|
|
|
607
612
|
.sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
|
|
608
613
|
min-height: 80px;
|
|
609
614
|
}
|
|
610
|
-
`,k=t=>t==="lg"||t==="xl"?18:t==="xs"?14:16,
|
|
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 {
|
|
611
616
|
display: inline-flex;
|
|
612
617
|
align-items: center;
|
|
613
618
|
gap: var(--sa-spacing-4, 4px);
|
|
@@ -638,4 +643,4 @@
|
|
|
638
643
|
font-size: var(--sa-font-size-sm, 12px);
|
|
639
644
|
user-select: none;
|
|
640
645
|
}
|
|
641
|
-
`,nn="sa-kbd-styles";(t=>{if(!(typeof document>"u")&&!document.getElementById(nn)){const
|
|
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"})});
|