@starasia/input 6.0.3 → 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 +156 -129
- package/dist/input.umd.js +34 -7
- package/package.json +1 -1
package/dist/input.es.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import Z, { forwardRef as mn, useState as I, useRef as
|
|
3
|
-
const $n =
|
|
1
|
+
import { jsx as s, jsxs as l, Fragment as Ln } from "react/jsx-runtime";
|
|
2
|
+
import Z, { forwardRef as mn, useState as I, useRef as S, useEffect as F, useImperativeHandle as En, useLayoutEffect as bn } from "react";
|
|
3
|
+
const $n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
|
|
4
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
5
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
6
|
+
@layer starasia.components {
|
|
7
|
+
|
|
8
|
+
|
|
4
9
|
:root {
|
|
5
10
|
/* Layer 3 — references Layer 2 semantic tokens */
|
|
6
11
|
--sa-input-text-primary: var(--sa-text-primary, #292a2e);
|
|
@@ -15,11 +20,14 @@ const $n = `
|
|
|
15
20
|
--sa-input-icon-disable: var(--sa-icon-disable, #181a198f);
|
|
16
21
|
|
|
17
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);
|
|
18
26
|
--sa-input-border-brand: var(--sa-border-focused, #1a4fa0);
|
|
19
27
|
--sa-input-border-brand-subtle: var(--sa-color-brand-200, #99b3db);
|
|
20
28
|
--sa-input-border-danger: var(--sa-border-danger, #c9184a);
|
|
21
29
|
--sa-input-border-danger-subtle: var(--sa-color-error-200, #ffb3c1);
|
|
22
|
-
--sa-input-border-success: var(--sa-
|
|
30
|
+
--sa-input-border-success: var(--sa-border-success, #208958);
|
|
23
31
|
--sa-input-border-disabled: var(--sa-border-disabled, #0515240e);
|
|
24
32
|
|
|
25
33
|
--sa-input-bg-neutral: var(--sa-background-neutral, #f0f1f2);
|
|
@@ -147,7 +155,7 @@ const $n = `
|
|
|
147
155
|
position: relative;
|
|
148
156
|
width: 100%;
|
|
149
157
|
background: transparent;
|
|
150
|
-
border: 1px solid var(--sa-input-border-
|
|
158
|
+
border: 1px solid var(--sa-input-border-field);
|
|
151
159
|
overflow: hidden;
|
|
152
160
|
transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
|
|
153
161
|
}
|
|
@@ -186,7 +194,7 @@ const $n = `
|
|
|
186
194
|
/* variants */
|
|
187
195
|
.sa-tf-variant-outline .sa-tf-box {
|
|
188
196
|
background: transparent;
|
|
189
|
-
border: 1px solid var(--sa-input-border-
|
|
197
|
+
border: 1px solid var(--sa-input-border-field);
|
|
190
198
|
}
|
|
191
199
|
.sa-tf-variant-standard .sa-tf-box {
|
|
192
200
|
background: var(--sa-input-bg-neutral);
|
|
@@ -195,7 +203,7 @@ const $n = `
|
|
|
195
203
|
.sa-tf-variant-flushed .sa-tf-box {
|
|
196
204
|
background: transparent;
|
|
197
205
|
border: 0;
|
|
198
|
-
border-bottom: 1px solid var(--sa-input-border-
|
|
206
|
+
border-bottom: 1px solid var(--sa-input-border-field);
|
|
199
207
|
border-radius: 0;
|
|
200
208
|
}
|
|
201
209
|
.sa-tf-variant-borderless .sa-tf-box {
|
|
@@ -613,31 +621,43 @@ const $n = `
|
|
|
613
621
|
.sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
|
|
614
622
|
min-height: 80px;
|
|
615
623
|
}
|
|
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
|
+
|
|
635
|
+
} /* @layer starasia.components */
|
|
616
636
|
`, z = (n) => n === "lg" || n === "xl" ? 18 : n === "xs" ? 14 : 16, J = {
|
|
617
637
|
default: "var(--sa-color-gray-800, #505258)",
|
|
618
638
|
error: "var(--sa-text-error, #a4133c)",
|
|
619
639
|
success: "var(--sa-text-success, #186742)",
|
|
620
640
|
disable: "var(--sa-icon-disable, #181a198f)"
|
|
621
|
-
}, xn = (n,
|
|
641
|
+
}, xn = (n, a) => a ? J.disable : J[n] ?? J.default;
|
|
622
642
|
function Dn(n) {
|
|
623
643
|
return Number(n.replace(/\./g, ""));
|
|
624
644
|
}
|
|
625
645
|
function Q(n) {
|
|
626
|
-
let
|
|
627
|
-
return
|
|
646
|
+
let a = n.replace(/[^\d]/g, "");
|
|
647
|
+
return a = a.replace(/^0+(?=\d)/, ""), a.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
628
648
|
}
|
|
629
|
-
function Fn(n,
|
|
630
|
-
if (
|
|
649
|
+
function Fn(n, a) {
|
|
650
|
+
if (a <= 0)
|
|
631
651
|
return 0;
|
|
632
652
|
let r = 0;
|
|
633
653
|
for (let o = 0; o < n.length; o++)
|
|
634
|
-
if (/\d/.test(n[o]) && (r += 1, r ===
|
|
654
|
+
if (/\d/.test(n[o]) && (r += 1, r === a))
|
|
635
655
|
return o + 1;
|
|
636
656
|
return n.length;
|
|
637
657
|
}
|
|
638
658
|
const Tn = mn(
|
|
639
|
-
({ options: n, value:
|
|
640
|
-
const [c, T] = I([]), u =
|
|
659
|
+
({ options: n, value: a, setValue: r, isComponentVisible: o, onOptionChange: d }, f) => {
|
|
660
|
+
const [c, T] = I([]), u = S(null), p = () => {
|
|
641
661
|
if (f != null && f.current && u.current) {
|
|
642
662
|
const g = window.innerHeight, b = f == null ? void 0 : f.current.getBoundingClientRect(), m = u.current.getBoundingClientRect(), v = b.bottom + m.height;
|
|
643
663
|
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`;
|
|
@@ -650,10 +670,10 @@ const Tn = mn(
|
|
|
650
670
|
}, [o]), F(() => {
|
|
651
671
|
T(
|
|
652
672
|
(n == null ? void 0 : n.filter(
|
|
653
|
-
(g) => g.toLowerCase().startsWith(
|
|
673
|
+
(g) => g.toLowerCase().startsWith(a.toLowerCase())
|
|
654
674
|
)) || []
|
|
655
675
|
);
|
|
656
|
-
}, [
|
|
676
|
+
}, [a, n]), /* @__PURE__ */ s(
|
|
657
677
|
"div",
|
|
658
678
|
{
|
|
659
679
|
ref: u,
|
|
@@ -668,13 +688,13 @@ const Tn = mn(
|
|
|
668
688
|
zIndex: 5e4
|
|
669
689
|
},
|
|
670
690
|
children: c == null ? void 0 : c.map(
|
|
671
|
-
(g) =>
|
|
691
|
+
(g) => jn(g, a, r, d)
|
|
672
692
|
)
|
|
673
693
|
}
|
|
674
694
|
);
|
|
675
695
|
}
|
|
676
|
-
),
|
|
677
|
-
const d = n.toLowerCase().indexOf(
|
|
696
|
+
), jn = (n, a, r, o) => {
|
|
697
|
+
const d = n.toLowerCase().indexOf(a.toLowerCase());
|
|
678
698
|
return /* @__PURE__ */ l(
|
|
679
699
|
"p",
|
|
680
700
|
{
|
|
@@ -690,28 +710,28 @@ const Tn = mn(
|
|
|
690
710
|
},
|
|
691
711
|
children: [
|
|
692
712
|
n.slice(0, d),
|
|
693
|
-
/* @__PURE__ */
|
|
694
|
-
n.slice(d +
|
|
713
|
+
/* @__PURE__ */ s("span", { style: { color: "var(--sa-text-primary, #292a2e)" }, children: n.slice(d, d + a.length) }),
|
|
714
|
+
n.slice(d + a.length)
|
|
695
715
|
]
|
|
696
716
|
}
|
|
697
717
|
);
|
|
698
718
|
};
|
|
699
|
-
function
|
|
700
|
-
const [
|
|
719
|
+
function Vn(n) {
|
|
720
|
+
const [a, r] = I(n), o = S(null), d = (f) => {
|
|
701
721
|
o.current && !o.current.contains(f.target) && r(!1);
|
|
702
722
|
};
|
|
703
723
|
return F(() => (document.addEventListener("click", d, !0), () => {
|
|
704
724
|
document.removeEventListener("click", d, !0);
|
|
705
|
-
}), []), { ref: o, isComponentVisible:
|
|
725
|
+
}), []), { ref: o, isComponentVisible: a, setIsComponentVisible: r };
|
|
706
726
|
}
|
|
707
|
-
const gn = "sa-input-styles",
|
|
727
|
+
const gn = "sa-input-styles", On = (n) => {
|
|
708
728
|
if (!(typeof document > "u") && !document.getElementById(gn)) {
|
|
709
|
-
const
|
|
710
|
-
|
|
729
|
+
const a = document.createElement("style");
|
|
730
|
+
a.id = gn, a.textContent = n, document.head.appendChild(a);
|
|
711
731
|
}
|
|
712
732
|
};
|
|
713
|
-
|
|
714
|
-
const
|
|
733
|
+
On($n);
|
|
734
|
+
const Wn = (n) => /* @__PURE__ */ l(
|
|
715
735
|
"svg",
|
|
716
736
|
{
|
|
717
737
|
viewBox: "0 0 16 16",
|
|
@@ -719,8 +739,8 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
719
739
|
xmlns: "http://www.w3.org/2000/svg",
|
|
720
740
|
...n,
|
|
721
741
|
children: [
|
|
722
|
-
/* @__PURE__ */
|
|
723
|
-
/* @__PURE__ */
|
|
742
|
+
/* @__PURE__ */ s("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
743
|
+
/* @__PURE__ */ s(
|
|
724
744
|
"path",
|
|
725
745
|
{
|
|
726
746
|
d: "M5.2 8.2l1.8 1.8 3.8-4.2",
|
|
@@ -740,8 +760,8 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
740
760
|
xmlns: "http://www.w3.org/2000/svg",
|
|
741
761
|
...n,
|
|
742
762
|
children: [
|
|
743
|
-
/* @__PURE__ */
|
|
744
|
-
/* @__PURE__ */
|
|
763
|
+
/* @__PURE__ */ s("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
|
|
764
|
+
/* @__PURE__ */ s(
|
|
745
765
|
"path",
|
|
746
766
|
{
|
|
747
767
|
d: "M5.5 5.5l5 5M10.5 5.5l-5 5",
|
|
@@ -752,8 +772,8 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
752
772
|
)
|
|
753
773
|
]
|
|
754
774
|
}
|
|
755
|
-
),
|
|
756
|
-
(n,
|
|
775
|
+
), Yn = mn(
|
|
776
|
+
(n, a) => {
|
|
757
777
|
const {
|
|
758
778
|
size: r = "sm",
|
|
759
779
|
variant: o = "outline",
|
|
@@ -767,36 +787,36 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
767
787
|
errorText: b,
|
|
768
788
|
leftIcon: m,
|
|
769
789
|
rightIcon: v,
|
|
770
|
-
leftAddons:
|
|
771
|
-
rightAddons:
|
|
790
|
+
leftAddons: R,
|
|
791
|
+
rightAddons: B,
|
|
772
792
|
onClickLeftIcon: nn,
|
|
773
|
-
onClickRightIcon:
|
|
793
|
+
onClickRightIcon: j,
|
|
774
794
|
fullWidth: vn = !0,
|
|
775
|
-
highlightPlaceholder:
|
|
795
|
+
highlightPlaceholder: V,
|
|
776
796
|
currency: L,
|
|
777
797
|
options: E,
|
|
778
|
-
onOptionChange:
|
|
798
|
+
onOptionChange: O,
|
|
779
799
|
clearable: wn = !0,
|
|
780
|
-
onClear:
|
|
781
|
-
...
|
|
782
|
-
} = n, A =
|
|
783
|
-
const t =
|
|
800
|
+
onClear: W,
|
|
801
|
+
...e
|
|
802
|
+
} = n, A = e.value !== void 0, [Y, k] = I(() => {
|
|
803
|
+
const t = e.value !== void 0 ? String(e.value ?? "") : String(e.defaultValue ?? "");
|
|
784
804
|
return L ? Q(t) : t;
|
|
785
|
-
}), [tn,
|
|
786
|
-
En(
|
|
787
|
-
const
|
|
788
|
-
|
|
805
|
+
}), [tn, an] = I(!1), [kn, en] = I(""), y = S(null), C = S(null);
|
|
806
|
+
En(a, () => C.current);
|
|
807
|
+
const sn = S(
|
|
808
|
+
e.id ?? `sa-input-${Math.random().toString(36).slice(2, 9)}`
|
|
789
809
|
), {
|
|
790
810
|
isComponentVisible: rn,
|
|
791
|
-
ref:
|
|
811
|
+
ref: H,
|
|
792
812
|
setIsComponentVisible: yn
|
|
793
|
-
} =
|
|
813
|
+
} = Vn(!1);
|
|
794
814
|
bn(() => {
|
|
795
815
|
if (!A)
|
|
796
816
|
return;
|
|
797
|
-
const t =
|
|
817
|
+
const t = e.value === void 0 || e.value === null ? "" : String(e.value), i = L ? Q(t) : t;
|
|
798
818
|
k((x) => x === i ? x : i);
|
|
799
|
-
}, [
|
|
819
|
+
}, [e.value, L, A]), bn(() => {
|
|
800
820
|
if (y.current === null)
|
|
801
821
|
return;
|
|
802
822
|
const t = C.current, i = y.current;
|
|
@@ -805,12 +825,12 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
805
825
|
t.setSelectionRange(i, i);
|
|
806
826
|
} catch {
|
|
807
827
|
}
|
|
808
|
-
}, [
|
|
809
|
-
const N =
|
|
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 = [
|
|
810
830
|
"sa-tf",
|
|
811
831
|
`sa-tf-variant-${o}`,
|
|
812
832
|
`sa-tf-size-${r}`,
|
|
813
|
-
`sa-tf-status-${
|
|
833
|
+
`sa-tf-status-${_}`,
|
|
814
834
|
`sa-tf-label-${c}`,
|
|
815
835
|
tn ? "sa-tf-focused" : "",
|
|
816
836
|
w ? "sa-tf-disabled" : "",
|
|
@@ -824,39 +844,39 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
824
844
|
var un, pn;
|
|
825
845
|
if (!L) {
|
|
826
846
|
const D = t.target.selectionStart;
|
|
827
|
-
D !== null && (y.current = D), k(t.target.value), (un =
|
|
847
|
+
D !== null && (y.current = D), k(t.target.value), (un = e.onChange) == null || un.call(e, t);
|
|
828
848
|
return;
|
|
829
849
|
}
|
|
830
850
|
const i = t.target.value;
|
|
831
851
|
let x = i, h = t.target.selectionStart ?? i.length;
|
|
832
852
|
if (kn === "Backspace") {
|
|
833
|
-
const D =
|
|
834
|
-
D.length ===
|
|
853
|
+
const D = Y.replace(/\D/g, ""), Bn = i.replace(/\D/g, "");
|
|
854
|
+
D.length === Bn.length && h > 0 && (x = i.slice(0, h - 1) + i.slice(h), h -= 1);
|
|
835
855
|
}
|
|
836
|
-
const
|
|
837
|
-
y.current =
|
|
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, {
|
|
838
858
|
...t,
|
|
839
859
|
target: {
|
|
840
860
|
...t.target,
|
|
841
|
-
value: String(Dn(
|
|
861
|
+
value: String(Dn(X)),
|
|
842
862
|
name: t.target.name
|
|
843
863
|
}
|
|
844
|
-
}),
|
|
864
|
+
}), en("");
|
|
845
865
|
}, K = (t) => f ? /* @__PURE__ */ l("div", { className: t, children: [
|
|
846
|
-
/* @__PURE__ */
|
|
866
|
+
/* @__PURE__ */ s(
|
|
847
867
|
"label",
|
|
848
868
|
{
|
|
849
|
-
htmlFor:
|
|
869
|
+
htmlFor: sn.current,
|
|
850
870
|
style: { cursor: w ? "not-allowed" : "pointer" },
|
|
851
871
|
children: f
|
|
852
872
|
}
|
|
853
873
|
),
|
|
854
|
-
u ? /* @__PURE__ */
|
|
855
|
-
T ? /* @__PURE__ */
|
|
874
|
+
u ? /* @__PURE__ */ s("span", { className: "sa-tf-optional", children: "Optional" }) : null,
|
|
875
|
+
T ? /* @__PURE__ */ s("span", { className: "sa-tf-required", "aria-hidden": "true", children: "*" }) : null
|
|
856
876
|
] }) : null, P = /* @__PURE__ */ l(Ln, { children: [
|
|
857
|
-
g ? /* @__PURE__ */
|
|
858
|
-
b && d === "error" ? /* @__PURE__ */
|
|
859
|
-
] }),
|
|
877
|
+
g ? /* @__PURE__ */ s("p", { className: "sa-tf-helper", children: g }) : null,
|
|
878
|
+
b && d === "error" ? /* @__PURE__ */ s("p", { className: "sa-tf-error", children: b }) : null
|
|
879
|
+
] }), G = (t, i) => /* @__PURE__ */ s(
|
|
860
880
|
"span",
|
|
861
881
|
{
|
|
862
882
|
className: `sa-tf-icon${i ? " sa-tf-icon-clickable" : ""}`,
|
|
@@ -864,27 +884,27 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
864
884
|
children: Z.cloneElement(t, {
|
|
865
885
|
width: z(r),
|
|
866
886
|
height: z(r),
|
|
867
|
-
color: xn(
|
|
868
|
-
style: { color: xn(
|
|
887
|
+
color: xn(_, w),
|
|
888
|
+
style: { color: xn(_, w) }
|
|
869
889
|
})
|
|
870
890
|
}
|
|
871
891
|
), on = () => {
|
|
872
892
|
var i;
|
|
873
|
-
return v == null ? null : !Z.isValidElement(v) || ((i = v.type) == null ? void 0 : i.__saRaw) === !0 ? /* @__PURE__ */
|
|
893
|
+
return v == null ? null : !Z.isValidElement(v) || ((i = v.type) == null ? void 0 : i.__saRaw) === !0 ? /* @__PURE__ */ s(
|
|
874
894
|
"span",
|
|
875
895
|
{
|
|
876
|
-
className: `sa-tf-icon${
|
|
877
|
-
onClick:
|
|
896
|
+
className: `sa-tf-icon${j ? " sa-tf-icon-clickable" : ""}`,
|
|
897
|
+
onClick: j,
|
|
878
898
|
children: v
|
|
879
899
|
}
|
|
880
|
-
) :
|
|
881
|
-
}, ln = d === "success" ? /* @__PURE__ */
|
|
882
|
-
|
|
900
|
+
) : G(v, j);
|
|
901
|
+
}, ln = d === "success" ? /* @__PURE__ */ s("span", { className: "sa-tf-icon sa-tf-success-mark", "aria-hidden": "true", children: /* @__PURE__ */ s(
|
|
902
|
+
Wn,
|
|
883
903
|
{
|
|
884
904
|
width: z(r),
|
|
885
905
|
height: z(r)
|
|
886
906
|
}
|
|
887
|
-
) }) : null, dn = wn && !w ? /* @__PURE__ */
|
|
907
|
+
) }) : null, dn = wn && !w ? /* @__PURE__ */ s(
|
|
888
908
|
"button",
|
|
889
909
|
{
|
|
890
910
|
type: "button",
|
|
@@ -896,16 +916,16 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
896
916
|
var x;
|
|
897
917
|
t.stopPropagation(), A || k("");
|
|
898
918
|
const i = {
|
|
899
|
-
target: { value: "", name:
|
|
900
|
-
currentTarget: { value: "", name:
|
|
919
|
+
target: { value: "", name: e.name },
|
|
920
|
+
currentTarget: { value: "", name: e.name }
|
|
901
921
|
};
|
|
902
|
-
(x =
|
|
922
|
+
(x = e.onChange) == null || x.call(e, i), W == null || W(), y.current = 0, requestAnimationFrame(() => {
|
|
903
923
|
var h;
|
|
904
924
|
return (h = C.current) == null ? void 0 : h.focus();
|
|
905
925
|
});
|
|
906
926
|
},
|
|
907
927
|
onMouseDown: (t) => t.preventDefault(),
|
|
908
|
-
children: /* @__PURE__ */
|
|
928
|
+
children: /* @__PURE__ */ s(
|
|
909
929
|
An,
|
|
910
930
|
{
|
|
911
931
|
width: z(r),
|
|
@@ -913,112 +933,117 @@ const Yn = (n) => /* @__PURE__ */ l(
|
|
|
913
933
|
}
|
|
914
934
|
)
|
|
915
935
|
}
|
|
916
|
-
) : null, In = !$ && !!
|
|
917
|
-
/* @__PURE__ */
|
|
936
|
+
) : null, In = !$ && !!e.placeholder && !!V, fn = /* @__PURE__ */ l("div", { className: "sa-tf-field-wrap", children: [
|
|
937
|
+
/* @__PURE__ */ s(
|
|
918
938
|
"input",
|
|
919
939
|
{
|
|
920
|
-
...
|
|
921
|
-
id:
|
|
940
|
+
...e,
|
|
941
|
+
id: sn.current,
|
|
922
942
|
ref: C,
|
|
923
943
|
className: "sa-tf-input",
|
|
924
944
|
disabled: w,
|
|
925
|
-
placeholder:
|
|
945
|
+
placeholder: V ? "" : e.placeholder,
|
|
926
946
|
value: N,
|
|
927
947
|
onFocus: (t) => {
|
|
928
948
|
var i;
|
|
929
|
-
|
|
949
|
+
an(!0), yn(!0), (i = e.onFocus) == null || i.call(e, t);
|
|
930
950
|
},
|
|
931
951
|
onBlur: (t) => {
|
|
932
952
|
var i;
|
|
933
|
-
|
|
953
|
+
an(!1), (i = e.onBlur) == null || i.call(e, t);
|
|
934
954
|
},
|
|
935
955
|
onKeyDown: (t) => {
|
|
936
956
|
var i;
|
|
937
|
-
t.key === "Backspace" &&
|
|
957
|
+
t.key === "Backspace" && en(t.key), (i = e.onKeyDown) == null || i.call(e, t);
|
|
938
958
|
},
|
|
939
959
|
onChange: Nn
|
|
940
960
|
}
|
|
941
961
|
),
|
|
942
|
-
In ?
|
|
943
|
-
] }), cn = N && rn && (E != null && E.length) ? /* @__PURE__ */
|
|
962
|
+
In ? Hn(e.placeholder, V) : null
|
|
963
|
+
] }), cn = N && rn && (E != null && E.length) ? /* @__PURE__ */ s(
|
|
944
964
|
Tn,
|
|
945
965
|
{
|
|
946
966
|
options: E,
|
|
947
967
|
value: N,
|
|
948
968
|
setValue: k,
|
|
949
|
-
ref:
|
|
969
|
+
ref: H,
|
|
950
970
|
isComponentVisible: rn,
|
|
951
971
|
onOptionChange: (t) => {
|
|
952
|
-
|
|
972
|
+
O == null || O(t), k(t);
|
|
953
973
|
}
|
|
954
974
|
}
|
|
955
|
-
) : null,
|
|
975
|
+
) : null, U = M ? /* @__PURE__ */ l(
|
|
956
976
|
"div",
|
|
957
977
|
{
|
|
958
978
|
className: "sa-tf-box",
|
|
959
|
-
ref:
|
|
979
|
+
ref: H,
|
|
960
980
|
onClick: Cn,
|
|
961
981
|
children: [
|
|
962
|
-
|
|
982
|
+
R ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: R }) : null,
|
|
963
983
|
/* @__PURE__ */ l("div", { className: "sa-tf-box-content", children: [
|
|
964
|
-
m ?
|
|
984
|
+
m ? G(m, nn) : null,
|
|
965
985
|
/* @__PURE__ */ l("div", { className: "sa-tf-inside-stack", children: [
|
|
966
986
|
K("sa-tf-inside-label-row"),
|
|
967
|
-
/* @__PURE__ */
|
|
987
|
+
/* @__PURE__ */ s("div", { className: "sa-tf-inside-row", children: fn })
|
|
968
988
|
] }),
|
|
969
989
|
dn,
|
|
970
990
|
ln,
|
|
971
991
|
on()
|
|
972
992
|
] }),
|
|
973
|
-
|
|
993
|
+
B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: B }) : null,
|
|
974
994
|
cn
|
|
975
995
|
]
|
|
976
996
|
}
|
|
977
|
-
) : /* @__PURE__ */ l("div", { className: "sa-tf-box", ref:
|
|
978
|
-
|
|
997
|
+
) : /* @__PURE__ */ l("div", { className: "sa-tf-box", ref: H, children: [
|
|
998
|
+
R ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: R }) : null,
|
|
979
999
|
/* @__PURE__ */ l("div", { className: "sa-tf-box-content", children: [
|
|
980
|
-
m ?
|
|
1000
|
+
m ? G(m, nn) : null,
|
|
981
1001
|
fn,
|
|
982
1002
|
dn,
|
|
983
1003
|
ln,
|
|
984
1004
|
on()
|
|
985
1005
|
] }),
|
|
986
|
-
|
|
1006
|
+
B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: B }) : null,
|
|
987
1007
|
cn
|
|
988
1008
|
] });
|
|
989
1009
|
return c === "outside-left" ? /* @__PURE__ */ l("div", { className: q, children: [
|
|
990
1010
|
/* @__PURE__ */ l("div", { className: "sa-tf-label-col", children: [
|
|
991
1011
|
K("sa-tf-label"),
|
|
992
|
-
p ? /* @__PURE__ */
|
|
1012
|
+
p ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: p }) : null
|
|
993
1013
|
] }),
|
|
994
1014
|
/* @__PURE__ */ l("div", { className: "sa-tf-input-col", children: [
|
|
995
|
-
|
|
1015
|
+
U,
|
|
996
1016
|
P
|
|
997
1017
|
] })
|
|
998
|
-
] }) :
|
|
999
|
-
|
|
1018
|
+
] }) : M ? /* @__PURE__ */ l("div", { className: q, children: [
|
|
1019
|
+
U,
|
|
1000
1020
|
P
|
|
1001
1021
|
] }) : /* @__PURE__ */ l("div", { className: q, children: [
|
|
1002
1022
|
K("sa-tf-label"),
|
|
1003
|
-
p ? /* @__PURE__ */
|
|
1004
|
-
|
|
1023
|
+
p ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: p }) : null,
|
|
1024
|
+
U,
|
|
1005
1025
|
P
|
|
1006
1026
|
] });
|
|
1007
1027
|
}
|
|
1008
|
-
),
|
|
1028
|
+
), Hn = (n, a) => {
|
|
1009
1029
|
if (!n)
|
|
1010
1030
|
return null;
|
|
1011
|
-
if (!
|
|
1012
|
-
return /* @__PURE__ */
|
|
1013
|
-
const r = n.toLowerCase().indexOf(
|
|
1014
|
-
return r === -1 ? /* @__PURE__ */
|
|
1031
|
+
if (!a)
|
|
1032
|
+
return /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n });
|
|
1033
|
+
const r = n.toLowerCase().indexOf(a.toLowerCase());
|
|
1034
|
+
return r === -1 ? /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n }) : /* @__PURE__ */ l("p", { className: "sa-tf-placeholder", children: [
|
|
1015
1035
|
n.slice(0, r),
|
|
1016
|
-
/* @__PURE__ */
|
|
1017
|
-
n.slice(r +
|
|
1036
|
+
/* @__PURE__ */ s("span", { className: "sa-tf-placeholder-highlight", children: n.slice(r, r + a.length) }),
|
|
1037
|
+
n.slice(r + a.length)
|
|
1018
1038
|
] });
|
|
1019
1039
|
};
|
|
1020
|
-
|
|
1021
|
-
const
|
|
1040
|
+
Yn.displayName = "Input";
|
|
1041
|
+
const _n = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
|
|
1042
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
1043
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
1044
|
+
@layer starasia.components {
|
|
1045
|
+
|
|
1046
|
+
.sa-kbd {
|
|
1022
1047
|
display: inline-flex;
|
|
1023
1048
|
align-items: center;
|
|
1024
1049
|
gap: var(--sa-spacing-4, 4px);
|
|
@@ -1096,28 +1121,30 @@ const Mn = `.sa-kbd {
|
|
|
1096
1121
|
.sa-kbd-size-lg .sa-kbd-sep {
|
|
1097
1122
|
font-size: 16px;
|
|
1098
1123
|
}
|
|
1099
|
-
|
|
1124
|
+
|
|
1125
|
+
} /* @layer starasia.components */
|
|
1126
|
+
`, hn = "sa-kbd-styles", Mn = (n) => {
|
|
1100
1127
|
if (!(typeof document > "u") && !document.getElementById(hn)) {
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1128
|
+
const a = document.createElement("style");
|
|
1129
|
+
a.id = hn, a.textContent = n, document.head.appendChild(a);
|
|
1103
1130
|
}
|
|
1104
1131
|
};
|
|
1105
|
-
|
|
1106
|
-
function qn({ keys: n, separator:
|
|
1107
|
-
return /* @__PURE__ */
|
|
1132
|
+
Mn(_n);
|
|
1133
|
+
function qn({ keys: n, separator: a, size: r = "sm", className: o, ...d }) {
|
|
1134
|
+
return /* @__PURE__ */ s(
|
|
1108
1135
|
"span",
|
|
1109
1136
|
{
|
|
1110
1137
|
className: `sa-kbd sa-kbd-size-${r}${o ? ` ${o}` : ""}`,
|
|
1111
1138
|
...d,
|
|
1112
1139
|
children: n.map((f, c) => /* @__PURE__ */ l(Z.Fragment, { children: [
|
|
1113
|
-
c > 0 &&
|
|
1114
|
-
/* @__PURE__ */
|
|
1140
|
+
c > 0 && a != null ? /* @__PURE__ */ s("span", { className: "sa-kbd-sep", "aria-hidden": "true", children: a }) : null,
|
|
1141
|
+
/* @__PURE__ */ s("kbd", { className: "sa-kbd-key", children: f })
|
|
1115
1142
|
] }, c))
|
|
1116
1143
|
}
|
|
1117
1144
|
);
|
|
1118
1145
|
}
|
|
1119
1146
|
qn.__saRaw = !0;
|
|
1120
1147
|
export {
|
|
1121
|
-
|
|
1148
|
+
Yn as Input,
|
|
1122
1149
|
qn as Kbd
|
|
1123
1150
|
};
|
package/dist/input.umd.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
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
|
|
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=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
|
|
2
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
3
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
4
|
+
@layer starasia.components {
|
|
5
|
+
|
|
6
|
+
|
|
2
7
|
:root {
|
|
3
8
|
/* Layer 3 — references Layer 2 semantic tokens */
|
|
4
9
|
--sa-input-text-primary: var(--sa-text-primary, #292a2e);
|
|
@@ -13,11 +18,14 @@
|
|
|
13
18
|
--sa-input-icon-disable: var(--sa-icon-disable, #181a198f);
|
|
14
19
|
|
|
15
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);
|
|
16
24
|
--sa-input-border-brand: var(--sa-border-focused, #1a4fa0);
|
|
17
25
|
--sa-input-border-brand-subtle: var(--sa-color-brand-200, #99b3db);
|
|
18
26
|
--sa-input-border-danger: var(--sa-border-danger, #c9184a);
|
|
19
27
|
--sa-input-border-danger-subtle: var(--sa-color-error-200, #ffb3c1);
|
|
20
|
-
--sa-input-border-success: var(--sa-
|
|
28
|
+
--sa-input-border-success: var(--sa-border-success, #208958);
|
|
21
29
|
--sa-input-border-disabled: var(--sa-border-disabled, #0515240e);
|
|
22
30
|
|
|
23
31
|
--sa-input-bg-neutral: var(--sa-background-neutral, #f0f1f2);
|
|
@@ -145,7 +153,7 @@
|
|
|
145
153
|
position: relative;
|
|
146
154
|
width: 100%;
|
|
147
155
|
background: transparent;
|
|
148
|
-
border: 1px solid var(--sa-input-border-
|
|
156
|
+
border: 1px solid var(--sa-input-border-field);
|
|
149
157
|
overflow: hidden;
|
|
150
158
|
transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
|
|
151
159
|
}
|
|
@@ -184,7 +192,7 @@
|
|
|
184
192
|
/* variants */
|
|
185
193
|
.sa-tf-variant-outline .sa-tf-box {
|
|
186
194
|
background: transparent;
|
|
187
|
-
border: 1px solid var(--sa-input-border-
|
|
195
|
+
border: 1px solid var(--sa-input-border-field);
|
|
188
196
|
}
|
|
189
197
|
.sa-tf-variant-standard .sa-tf-box {
|
|
190
198
|
background: var(--sa-input-bg-neutral);
|
|
@@ -193,7 +201,7 @@
|
|
|
193
201
|
.sa-tf-variant-flushed .sa-tf-box {
|
|
194
202
|
background: transparent;
|
|
195
203
|
border: 0;
|
|
196
|
-
border-bottom: 1px solid var(--sa-input-border-
|
|
204
|
+
border-bottom: 1px solid var(--sa-input-border-field);
|
|
197
205
|
border-radius: 0;
|
|
198
206
|
}
|
|
199
207
|
.sa-tf-variant-borderless .sa-tf-box {
|
|
@@ -611,7 +619,24 @@
|
|
|
611
619
|
.sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
|
|
612
620
|
min-height: 80px;
|
|
613
621
|
}
|
|
614
|
-
|
|
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
|
+
|
|
633
|
+
} /* @layer starasia.components */
|
|
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,
|
|
635
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
636
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
637
|
+
@layer starasia.components {
|
|
638
|
+
|
|
639
|
+
.sa-kbd {
|
|
615
640
|
display: inline-flex;
|
|
616
641
|
align-items: center;
|
|
617
642
|
gap: var(--sa-spacing-4, 4px);
|
|
@@ -689,4 +714,6 @@
|
|
|
689
714
|
.sa-kbd-size-lg .sa-kbd-sep {
|
|
690
715
|
font-size: 16px;
|
|
691
716
|
}
|
|
692
|
-
|
|
717
|
+
|
|
718
|
+
} /* @layer starasia.components */
|
|
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"})});
|