@starasia/input 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Kbd.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/input.es.js +226 -170
- package/dist/input.umd.js +39 -8
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/Kbd.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface KbdProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
/** Keys to render, one cap each. e.g. ['⌘', 'K'] */
|
|
4
|
+
keys: React.ReactNode[];
|
|
5
|
+
/** Optional separator rendered between caps. Default: none (gap only). */
|
|
6
|
+
separator?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function Kbd({ keys, separator, className, ...rest }: KbdProps): React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
package/dist/input.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as s, jsxs as o, Fragment as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
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 D, useImperativeHandle as En, useLayoutEffect as pn } from "react";
|
|
3
|
+
const $n = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
|
|
4
4
|
|
|
5
5
|
:root {
|
|
6
6
|
/* Layer 3 — references Layer 2 semantic tokens */
|
|
@@ -143,7 +143,7 @@ const Sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
143
143
|
position: relative;
|
|
144
144
|
width: 100%;
|
|
145
145
|
background: transparent;
|
|
146
|
-
border:
|
|
146
|
+
border: 1px solid var(--sa-input-border-subtle);
|
|
147
147
|
overflow: hidden;
|
|
148
148
|
transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
|
|
149
149
|
}
|
|
@@ -176,16 +176,16 @@ const Sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
176
176
|
/* variants */
|
|
177
177
|
.sa-tf-variant-outline .sa-tf-box {
|
|
178
178
|
background: transparent;
|
|
179
|
-
border:
|
|
179
|
+
border: 1px solid var(--sa-input-border-subtle);
|
|
180
180
|
}
|
|
181
181
|
.sa-tf-variant-standard .sa-tf-box {
|
|
182
182
|
background: var(--sa-input-bg-neutral);
|
|
183
|
-
border:
|
|
183
|
+
border: 1px solid transparent;
|
|
184
184
|
}
|
|
185
185
|
.sa-tf-variant-flushed .sa-tf-box {
|
|
186
186
|
background: transparent;
|
|
187
187
|
border: 0;
|
|
188
|
-
border-bottom:
|
|
188
|
+
border-bottom: 1px solid var(--sa-input-border-subtle);
|
|
189
189
|
border-radius: 0;
|
|
190
190
|
}
|
|
191
191
|
.sa-tf-variant-borderless .sa-tf-box {
|
|
@@ -352,10 +352,10 @@ const Sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
352
352
|
align-self: stretch;
|
|
353
353
|
}
|
|
354
354
|
.sa-tf-addon-left {
|
|
355
|
-
border-right:
|
|
355
|
+
border-right: 1px solid var(--sa-input-border-subtle);
|
|
356
356
|
}
|
|
357
357
|
.sa-tf-addon-right {
|
|
358
|
-
border-left:
|
|
358
|
+
border-left: 1px solid var(--sa-input-border-subtle);
|
|
359
359
|
}
|
|
360
360
|
.sa-tf-size-sm .sa-tf-addon {
|
|
361
361
|
font-size: 12px;
|
|
@@ -593,50 +593,50 @@ const Sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
593
593
|
.sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
|
|
594
594
|
min-height: 80px;
|
|
595
595
|
}
|
|
596
|
-
`, z = (n) => n === "lg" || n === "xl" ? 18 : 16,
|
|
596
|
+
`, z = (n) => n === "lg" || n === "xl" ? 18 : 16, J = {
|
|
597
597
|
default: "var(--sa-color-gray-800, #505258)",
|
|
598
598
|
error: "var(--sa-text-error, #a4133c)",
|
|
599
599
|
success: "var(--sa-text-success, #208958)",
|
|
600
600
|
disable: "var(--sa-icon-disable, #181a198f)"
|
|
601
|
-
},
|
|
602
|
-
function
|
|
601
|
+
}, gn = (n, e) => e ? J.disable : J[n] ?? J.default;
|
|
602
|
+
function Fn(n) {
|
|
603
603
|
return Number(n.replace(/\./g, ""));
|
|
604
604
|
}
|
|
605
|
-
function
|
|
606
|
-
let
|
|
607
|
-
return
|
|
605
|
+
function Q(n) {
|
|
606
|
+
let e = n.replace(/[^\d]/g, "");
|
|
607
|
+
return e = e.replace(/^0+(?=\d)/, ""), e.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
608
608
|
}
|
|
609
|
-
function Dn(n,
|
|
610
|
-
if (
|
|
609
|
+
function Dn(n, e) {
|
|
610
|
+
if (e <= 0)
|
|
611
611
|
return 0;
|
|
612
612
|
let r = 0;
|
|
613
613
|
for (let l = 0; l < n.length; l++)
|
|
614
|
-
if (/\d/.test(n[l]) && (r += 1, r ===
|
|
614
|
+
if (/\d/.test(n[l]) && (r += 1, r === e))
|
|
615
615
|
return l + 1;
|
|
616
616
|
return n.length;
|
|
617
617
|
}
|
|
618
|
-
const
|
|
619
|
-
({ options: n, value:
|
|
620
|
-
const [
|
|
621
|
-
if (
|
|
622
|
-
const
|
|
623
|
-
|
|
618
|
+
const Tn = mn(
|
|
619
|
+
({ options: n, value: e, setValue: r, isComponentVisible: l, onOptionChange: d }, c) => {
|
|
620
|
+
const [x, T] = I([]), f = R(null), u = () => {
|
|
621
|
+
if (c != null && c.current && f.current) {
|
|
622
|
+
const g = window.innerHeight, b = c == null ? void 0 : c.current.getBoundingClientRect(), m = f.current.getBoundingClientRect(), v = b.bottom + m.height;
|
|
623
|
+
f.current.style.left = `${b.left}px`, f.current.style.width = `${b.width}px`, v >= g - 10 ? f.current.style.top = `${b.top - m.height - 5}px` : f.current.style.top = `${b.top + b.height}px`;
|
|
624
624
|
}
|
|
625
625
|
};
|
|
626
|
-
return
|
|
626
|
+
return D(() => (window.addEventListener("scroll", u), window.addEventListener("resize", u), () => {
|
|
627
627
|
window.removeEventListener("scroll", u), window.removeEventListener("resize", u);
|
|
628
|
-
}), [
|
|
628
|
+
}), [c, f]), D(() => {
|
|
629
629
|
u();
|
|
630
|
-
}, [l]),
|
|
631
|
-
|
|
630
|
+
}, [l]), D(() => {
|
|
631
|
+
T(
|
|
632
632
|
(n == null ? void 0 : n.filter(
|
|
633
|
-
(
|
|
633
|
+
(g) => g.toLowerCase().startsWith(e.toLowerCase())
|
|
634
634
|
)) || []
|
|
635
635
|
);
|
|
636
|
-
}, [
|
|
636
|
+
}, [e, n]), /* @__PURE__ */ s(
|
|
637
637
|
"div",
|
|
638
638
|
{
|
|
639
|
-
ref:
|
|
639
|
+
ref: f,
|
|
640
640
|
style: {
|
|
641
641
|
position: "fixed",
|
|
642
642
|
padding: "8px",
|
|
@@ -647,14 +647,14 @@ const Fn = xn(
|
|
|
647
647
|
overflow: "auto",
|
|
648
648
|
zIndex: 5e4
|
|
649
649
|
},
|
|
650
|
-
children:
|
|
651
|
-
(
|
|
650
|
+
children: x == null ? void 0 : x.map(
|
|
651
|
+
(g) => Vn(g, e, r, d)
|
|
652
652
|
)
|
|
653
653
|
}
|
|
654
654
|
);
|
|
655
655
|
}
|
|
656
|
-
),
|
|
657
|
-
const d = n.toLowerCase().indexOf(
|
|
656
|
+
), Vn = (n, e, r, l) => {
|
|
657
|
+
const d = n.toLowerCase().indexOf(e.toLowerCase());
|
|
658
658
|
return /* @__PURE__ */ o(
|
|
659
659
|
"p",
|
|
660
660
|
{
|
|
@@ -670,28 +670,28 @@ const Fn = xn(
|
|
|
670
670
|
},
|
|
671
671
|
children: [
|
|
672
672
|
n.slice(0, d),
|
|
673
|
-
/* @__PURE__ */ s("span", { style: { color: "var(--sa-text-primary, #292a2e)" }, children: n.slice(d, d +
|
|
674
|
-
n.slice(d +
|
|
673
|
+
/* @__PURE__ */ s("span", { style: { color: "var(--sa-text-primary, #292a2e)" }, children: n.slice(d, d + e.length) }),
|
|
674
|
+
n.slice(d + e.length)
|
|
675
675
|
]
|
|
676
676
|
}
|
|
677
677
|
);
|
|
678
678
|
};
|
|
679
679
|
function On(n) {
|
|
680
|
-
const [
|
|
681
|
-
l.current && !l.current.contains(
|
|
680
|
+
const [e, r] = I(n), l = R(null), d = (c) => {
|
|
681
|
+
l.current && !l.current.contains(c.target) && r(!1);
|
|
682
682
|
};
|
|
683
|
-
return
|
|
683
|
+
return D(() => (document.addEventListener("click", d, !0), () => {
|
|
684
684
|
document.removeEventListener("click", d, !0);
|
|
685
|
-
}), []), { ref: l, isComponentVisible:
|
|
685
|
+
}), []), { ref: l, isComponentVisible: e, setIsComponentVisible: r };
|
|
686
686
|
}
|
|
687
|
-
const
|
|
688
|
-
if (!(typeof document > "u") && !document.getElementById(
|
|
689
|
-
const
|
|
690
|
-
|
|
687
|
+
const hn = "sa-input-styles", jn = (n) => {
|
|
688
|
+
if (!(typeof document > "u") && !document.getElementById(hn)) {
|
|
689
|
+
const e = document.createElement("style");
|
|
690
|
+
e.id = hn, e.textContent = n, document.head.appendChild(e);
|
|
691
691
|
}
|
|
692
692
|
};
|
|
693
|
-
|
|
694
|
-
const
|
|
693
|
+
jn($n);
|
|
694
|
+
const Yn = (n) => /* @__PURE__ */ o(
|
|
695
695
|
"svg",
|
|
696
696
|
{
|
|
697
697
|
viewBox: "0 0 16 16",
|
|
@@ -712,7 +712,7 @@ const $n = (n) => /* @__PURE__ */ o(
|
|
|
712
712
|
)
|
|
713
713
|
]
|
|
714
714
|
}
|
|
715
|
-
),
|
|
715
|
+
), An = (n) => /* @__PURE__ */ o(
|
|
716
716
|
"svg",
|
|
717
717
|
{
|
|
718
718
|
viewBox: "0 0 16 16",
|
|
@@ -732,51 +732,51 @@ const $n = (n) => /* @__PURE__ */ o(
|
|
|
732
732
|
)
|
|
733
733
|
]
|
|
734
734
|
}
|
|
735
|
-
),
|
|
736
|
-
(n,
|
|
735
|
+
), Wn = mn(
|
|
736
|
+
(n, e) => {
|
|
737
737
|
const {
|
|
738
738
|
size: r = "md",
|
|
739
739
|
variant: l = "outline",
|
|
740
740
|
status: d = "default",
|
|
741
|
-
label:
|
|
742
|
-
labelPosition:
|
|
743
|
-
required:
|
|
744
|
-
optional:
|
|
741
|
+
label: c,
|
|
742
|
+
labelPosition: x = "outside-top",
|
|
743
|
+
required: T,
|
|
744
|
+
optional: f,
|
|
745
745
|
description: u,
|
|
746
|
-
helperText:
|
|
746
|
+
helperText: g,
|
|
747
747
|
errorText: b,
|
|
748
748
|
leftIcon: m,
|
|
749
|
-
rightIcon:
|
|
749
|
+
rightIcon: v,
|
|
750
750
|
leftAddons: B,
|
|
751
|
-
rightAddons:
|
|
752
|
-
onClickLeftIcon:
|
|
753
|
-
onClickRightIcon:
|
|
754
|
-
fullWidth:
|
|
755
|
-
highlightPlaceholder:
|
|
751
|
+
rightAddons: L,
|
|
752
|
+
onClickLeftIcon: nn,
|
|
753
|
+
onClickRightIcon: V,
|
|
754
|
+
fullWidth: vn = !0,
|
|
755
|
+
highlightPlaceholder: O,
|
|
756
756
|
currency: S,
|
|
757
757
|
options: E,
|
|
758
758
|
onOptionChange: j,
|
|
759
|
-
clearable:
|
|
759
|
+
clearable: wn = !0,
|
|
760
760
|
onClear: Y,
|
|
761
|
-
...
|
|
762
|
-
} = n, A =
|
|
763
|
-
const t =
|
|
764
|
-
return S ?
|
|
765
|
-
}), [
|
|
766
|
-
|
|
767
|
-
const
|
|
768
|
-
|
|
761
|
+
...a
|
|
762
|
+
} = n, A = a.value !== void 0, [W, y] = I(() => {
|
|
763
|
+
const t = a.value !== void 0 ? String(a.value ?? "") : String(a.defaultValue ?? "");
|
|
764
|
+
return S ? Q(t) : t;
|
|
765
|
+
}), [tn, en] = I(!1), [yn, an] = I(""), k = R(null), C = R(null);
|
|
766
|
+
En(e, () => C.current);
|
|
767
|
+
const sn = R(
|
|
768
|
+
a.id ?? `sa-input-${Math.random().toString(36).slice(2, 9)}`
|
|
769
769
|
), {
|
|
770
|
-
isComponentVisible:
|
|
771
|
-
ref:
|
|
772
|
-
setIsComponentVisible:
|
|
770
|
+
isComponentVisible: rn,
|
|
771
|
+
ref: _,
|
|
772
|
+
setIsComponentVisible: kn
|
|
773
773
|
} = On(!1);
|
|
774
|
-
|
|
774
|
+
pn(() => {
|
|
775
775
|
if (!A)
|
|
776
776
|
return;
|
|
777
|
-
const t =
|
|
777
|
+
const t = a.value === void 0 || a.value === null ? "" : String(a.value), i = S ? Q(t) : t;
|
|
778
778
|
y((p) => p === i ? p : i);
|
|
779
|
-
}, [
|
|
779
|
+
}, [a.value, S, A]), pn(() => {
|
|
780
780
|
if (k.current === null)
|
|
781
781
|
return;
|
|
782
782
|
const t = C.current, i = k.current;
|
|
@@ -786,208 +786,264 @@ const $n = (n) => /* @__PURE__ */ o(
|
|
|
786
786
|
} catch {
|
|
787
787
|
}
|
|
788
788
|
}, [W]);
|
|
789
|
-
const N = W,
|
|
789
|
+
const N = W, $ = N !== "" && N !== void 0, w = d === "disable" || a.disabled, M = w ? "disable" : d, P = x === "inside", zn = P && ($ || tn), H = [
|
|
790
790
|
"sa-tf",
|
|
791
791
|
`sa-tf-variant-${l}`,
|
|
792
792
|
`sa-tf-size-${r}`,
|
|
793
|
-
`sa-tf-status-${
|
|
794
|
-
`sa-tf-label-${
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
].filter(Boolean).join(" "),
|
|
793
|
+
`sa-tf-status-${M}`,
|
|
794
|
+
`sa-tf-label-${x}`,
|
|
795
|
+
tn ? "sa-tf-focused" : "",
|
|
796
|
+
w ? "sa-tf-disabled" : "",
|
|
797
|
+
zn ? "sa-tf-floating" : "",
|
|
798
|
+
c ? "" : "sa-tf-no-label",
|
|
799
|
+
vn ? "sa-tf-fullwidth" : ""
|
|
800
|
+
].filter(Boolean).join(" "), Cn = () => {
|
|
801
801
|
var t;
|
|
802
802
|
return (t = C.current) == null ? void 0 : t.focus();
|
|
803
|
-
},
|
|
804
|
-
var
|
|
803
|
+
}, Nn = (t) => {
|
|
804
|
+
var un, bn;
|
|
805
805
|
if (!S) {
|
|
806
|
-
const
|
|
807
|
-
|
|
806
|
+
const F = t.target.selectionStart;
|
|
807
|
+
F !== null && (k.current = F), y(t.target.value), (un = a.onChange) == null || un.call(a, t);
|
|
808
808
|
return;
|
|
809
809
|
}
|
|
810
810
|
const i = t.target.value;
|
|
811
|
-
let p = i,
|
|
812
|
-
if (
|
|
813
|
-
const
|
|
814
|
-
|
|
811
|
+
let p = i, h = t.target.selectionStart ?? i.length;
|
|
812
|
+
if (yn === "Backspace") {
|
|
813
|
+
const F = W.replace(/\D/g, ""), Ln = i.replace(/\D/g, "");
|
|
814
|
+
F.length === Ln.length && h > 0 && (p = i.slice(0, h - 1) + i.slice(h), h -= 1);
|
|
815
815
|
}
|
|
816
|
-
const
|
|
817
|
-
k.current =
|
|
816
|
+
const G = Q(p), Rn = p.slice(0, h).replace(/\D/g, "").length, Bn = Dn(G, Rn);
|
|
817
|
+
k.current = Bn, y(G), (bn = a.onChange) == null || bn.call(a, {
|
|
818
818
|
...t,
|
|
819
819
|
target: {
|
|
820
820
|
...t.target,
|
|
821
|
-
value: String(
|
|
821
|
+
value: String(Fn(G)),
|
|
822
822
|
name: t.target.name
|
|
823
823
|
}
|
|
824
|
-
}),
|
|
825
|
-
},
|
|
824
|
+
}), an("");
|
|
825
|
+
}, q = (t) => c ? /* @__PURE__ */ o("div", { className: t, children: [
|
|
826
826
|
/* @__PURE__ */ s(
|
|
827
827
|
"label",
|
|
828
828
|
{
|
|
829
|
-
htmlFor:
|
|
830
|
-
style: { cursor:
|
|
831
|
-
children:
|
|
829
|
+
htmlFor: sn.current,
|
|
830
|
+
style: { cursor: w ? "not-allowed" : "pointer" },
|
|
831
|
+
children: c
|
|
832
832
|
}
|
|
833
833
|
),
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
] }) : null,
|
|
837
|
-
|
|
834
|
+
f ? /* @__PURE__ */ s("span", { className: "sa-tf-optional", children: "Optional" }) : null,
|
|
835
|
+
T ? /* @__PURE__ */ s("span", { className: "sa-tf-required", "aria-hidden": "true", children: "*" }) : null
|
|
836
|
+
] }) : null, K = /* @__PURE__ */ o(Sn, { children: [
|
|
837
|
+
g ? /* @__PURE__ */ s("p", { className: "sa-tf-helper", children: g }) : null,
|
|
838
838
|
b && d === "error" ? /* @__PURE__ */ s("p", { className: "sa-tf-error", children: b }) : null
|
|
839
|
-
] }),
|
|
839
|
+
] }), U = (t, i) => /* @__PURE__ */ s(
|
|
840
840
|
"span",
|
|
841
841
|
{
|
|
842
842
|
className: `sa-tf-icon${i ? " sa-tf-icon-clickable" : ""}`,
|
|
843
843
|
onClick: i,
|
|
844
|
-
children:
|
|
844
|
+
children: Z.cloneElement(t, {
|
|
845
845
|
width: z(r),
|
|
846
846
|
height: z(r),
|
|
847
|
-
color:
|
|
848
|
-
style: { color:
|
|
847
|
+
color: gn(M, w),
|
|
848
|
+
style: { color: gn(M, w) }
|
|
849
849
|
})
|
|
850
850
|
}
|
|
851
|
-
),
|
|
852
|
-
|
|
851
|
+
), on = () => {
|
|
852
|
+
var i;
|
|
853
|
+
return v == null ? null : !Z.isValidElement(v) || ((i = v.type) == null ? void 0 : i.__saRaw) === !0 ? /* @__PURE__ */ s(
|
|
854
|
+
"span",
|
|
855
|
+
{
|
|
856
|
+
className: `sa-tf-icon${V ? " sa-tf-icon-clickable" : ""}`,
|
|
857
|
+
onClick: V,
|
|
858
|
+
children: v
|
|
859
|
+
}
|
|
860
|
+
) : U(v, V);
|
|
861
|
+
}, ln = d === "success" ? /* @__PURE__ */ s("span", { className: "sa-tf-icon sa-tf-success-mark", "aria-hidden": "true", children: /* @__PURE__ */ s(
|
|
862
|
+
Yn,
|
|
853
863
|
{
|
|
854
864
|
width: z(r),
|
|
855
865
|
height: z(r)
|
|
856
866
|
}
|
|
857
|
-
) }) : null,
|
|
867
|
+
) }) : null, dn = wn && !w ? /* @__PURE__ */ s(
|
|
858
868
|
"button",
|
|
859
869
|
{
|
|
860
870
|
type: "button",
|
|
861
|
-
className: `sa-tf-icon sa-tf-clear${
|
|
871
|
+
className: `sa-tf-icon sa-tf-clear${$ ? "" : " sa-tf-clear-hidden"}`,
|
|
862
872
|
"aria-label": "Clear input",
|
|
863
|
-
"aria-hidden":
|
|
873
|
+
"aria-hidden": !$,
|
|
864
874
|
tabIndex: -1,
|
|
865
875
|
onClick: (t) => {
|
|
866
876
|
var p;
|
|
867
877
|
t.stopPropagation(), A || y("");
|
|
868
878
|
const i = {
|
|
869
|
-
target: { value: "", name:
|
|
870
|
-
currentTarget: { value: "", name:
|
|
879
|
+
target: { value: "", name: a.name },
|
|
880
|
+
currentTarget: { value: "", name: a.name }
|
|
871
881
|
};
|
|
872
|
-
(p =
|
|
873
|
-
var
|
|
874
|
-
return (
|
|
882
|
+
(p = a.onChange) == null || p.call(a, i), Y == null || Y(), k.current = 0, requestAnimationFrame(() => {
|
|
883
|
+
var h;
|
|
884
|
+
return (h = C.current) == null ? void 0 : h.focus();
|
|
875
885
|
});
|
|
876
886
|
},
|
|
877
887
|
onMouseDown: (t) => t.preventDefault(),
|
|
878
888
|
children: /* @__PURE__ */ s(
|
|
879
|
-
|
|
889
|
+
An,
|
|
880
890
|
{
|
|
881
891
|
width: z(r),
|
|
882
892
|
height: z(r)
|
|
883
893
|
}
|
|
884
894
|
)
|
|
885
895
|
}
|
|
886
|
-
) : null,
|
|
896
|
+
) : null, In = !$ && !!a.placeholder && !!O, cn = /* @__PURE__ */ o("div", { className: "sa-tf-field-wrap", children: [
|
|
887
897
|
/* @__PURE__ */ s(
|
|
888
898
|
"input",
|
|
889
899
|
{
|
|
890
|
-
...
|
|
891
|
-
id:
|
|
900
|
+
...a,
|
|
901
|
+
id: sn.current,
|
|
892
902
|
ref: C,
|
|
893
903
|
className: "sa-tf-input",
|
|
894
|
-
disabled:
|
|
895
|
-
placeholder:
|
|
904
|
+
disabled: w,
|
|
905
|
+
placeholder: O ? "" : a.placeholder,
|
|
896
906
|
value: N,
|
|
897
907
|
onFocus: (t) => {
|
|
898
908
|
var i;
|
|
899
|
-
|
|
909
|
+
en(!0), kn(!0), (i = a.onFocus) == null || i.call(a, t);
|
|
900
910
|
},
|
|
901
911
|
onBlur: (t) => {
|
|
902
912
|
var i;
|
|
903
|
-
|
|
913
|
+
en(!1), (i = a.onBlur) == null || i.call(a, t);
|
|
904
914
|
},
|
|
905
915
|
onKeyDown: (t) => {
|
|
906
916
|
var i;
|
|
907
|
-
t.key === "Backspace" &&
|
|
917
|
+
t.key === "Backspace" && an(t.key), (i = a.onKeyDown) == null || i.call(a, t);
|
|
908
918
|
},
|
|
909
|
-
onChange:
|
|
919
|
+
onChange: Nn
|
|
910
920
|
}
|
|
911
921
|
),
|
|
912
|
-
|
|
913
|
-
] }),
|
|
914
|
-
|
|
922
|
+
In ? _n(a.placeholder, O) : null
|
|
923
|
+
] }), fn = N && rn && (E != null && E.length) ? /* @__PURE__ */ s(
|
|
924
|
+
Tn,
|
|
915
925
|
{
|
|
916
926
|
options: E,
|
|
917
927
|
value: N,
|
|
918
928
|
setValue: y,
|
|
919
|
-
ref:
|
|
920
|
-
isComponentVisible:
|
|
929
|
+
ref: _,
|
|
930
|
+
isComponentVisible: rn,
|
|
921
931
|
onOptionChange: (t) => {
|
|
922
932
|
j == null || j(t), y(t);
|
|
923
933
|
}
|
|
924
934
|
}
|
|
925
|
-
) : null,
|
|
935
|
+
) : null, X = P ? /* @__PURE__ */ o(
|
|
926
936
|
"div",
|
|
927
937
|
{
|
|
928
938
|
className: "sa-tf-box",
|
|
929
|
-
ref:
|
|
930
|
-
onClick:
|
|
939
|
+
ref: _,
|
|
940
|
+
onClick: Cn,
|
|
931
941
|
children: [
|
|
932
942
|
B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
|
|
933
943
|
/* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
|
|
934
|
-
m ?
|
|
944
|
+
m ? U(m, nn) : null,
|
|
935
945
|
/* @__PURE__ */ o("div", { className: "sa-tf-inside-stack", children: [
|
|
936
|
-
|
|
937
|
-
/* @__PURE__ */ s("div", { className: "sa-tf-inside-row", children:
|
|
946
|
+
q("sa-tf-inside-label-row"),
|
|
947
|
+
/* @__PURE__ */ s("div", { className: "sa-tf-inside-row", children: cn })
|
|
938
948
|
] }),
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
949
|
+
dn,
|
|
950
|
+
ln,
|
|
951
|
+
on()
|
|
942
952
|
] }),
|
|
943
|
-
|
|
944
|
-
|
|
953
|
+
L ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: L }) : null,
|
|
954
|
+
fn
|
|
945
955
|
]
|
|
946
956
|
}
|
|
947
|
-
) : /* @__PURE__ */ o("div", { className: "sa-tf-box", ref:
|
|
957
|
+
) : /* @__PURE__ */ o("div", { className: "sa-tf-box", ref: _, children: [
|
|
948
958
|
B ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-left", children: B }) : null,
|
|
949
959
|
/* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
|
|
950
|
-
m ?
|
|
960
|
+
m ? U(m, nn) : null,
|
|
961
|
+
cn,
|
|
962
|
+
dn,
|
|
951
963
|
ln,
|
|
952
|
-
on
|
|
953
|
-
rn,
|
|
954
|
-
w ? F(w, Z) : null
|
|
964
|
+
on()
|
|
955
965
|
] }),
|
|
956
|
-
|
|
957
|
-
|
|
966
|
+
L ? /* @__PURE__ */ s("div", { className: "sa-tf-addon sa-tf-addon-right", children: L }) : null,
|
|
967
|
+
fn
|
|
958
968
|
] });
|
|
959
|
-
return
|
|
969
|
+
return x === "outside-left" ? /* @__PURE__ */ o("div", { className: H, children: [
|
|
960
970
|
/* @__PURE__ */ o("div", { className: "sa-tf-label-col", children: [
|
|
961
|
-
|
|
971
|
+
q("sa-tf-label"),
|
|
962
972
|
u ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: u }) : null
|
|
963
973
|
] }),
|
|
964
974
|
/* @__PURE__ */ o("div", { className: "sa-tf-input-col", children: [
|
|
965
|
-
|
|
966
|
-
|
|
975
|
+
X,
|
|
976
|
+
K
|
|
967
977
|
] })
|
|
968
|
-
] }) :
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
] }) : /* @__PURE__ */ o("div", { className:
|
|
972
|
-
|
|
978
|
+
] }) : P ? /* @__PURE__ */ o("div", { className: H, children: [
|
|
979
|
+
X,
|
|
980
|
+
K
|
|
981
|
+
] }) : /* @__PURE__ */ o("div", { className: H, children: [
|
|
982
|
+
q("sa-tf-label"),
|
|
973
983
|
u ? /* @__PURE__ */ s("p", { className: "sa-tf-desc-top", children: u }) : null,
|
|
974
|
-
|
|
975
|
-
|
|
984
|
+
X,
|
|
985
|
+
K
|
|
976
986
|
] });
|
|
977
987
|
}
|
|
978
|
-
),
|
|
988
|
+
), _n = (n, e) => {
|
|
979
989
|
if (!n)
|
|
980
990
|
return null;
|
|
981
|
-
if (!
|
|
991
|
+
if (!e)
|
|
982
992
|
return /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n });
|
|
983
|
-
const r = n.toLowerCase().indexOf(
|
|
993
|
+
const r = n.toLowerCase().indexOf(e.toLowerCase());
|
|
984
994
|
return r === -1 ? /* @__PURE__ */ s("p", { className: "sa-tf-placeholder", children: n }) : /* @__PURE__ */ o("p", { className: "sa-tf-placeholder", children: [
|
|
985
995
|
n.slice(0, r),
|
|
986
|
-
/* @__PURE__ */ s("span", { className: "sa-tf-placeholder-highlight", children: n.slice(r, r +
|
|
987
|
-
n.slice(r +
|
|
996
|
+
/* @__PURE__ */ s("span", { className: "sa-tf-placeholder-highlight", children: n.slice(r, r + e.length) }),
|
|
997
|
+
n.slice(r + e.length)
|
|
988
998
|
] });
|
|
989
999
|
};
|
|
990
|
-
|
|
1000
|
+
Wn.displayName = "Input";
|
|
1001
|
+
const Mn = `.sa-kbd {
|
|
1002
|
+
display: inline-flex;
|
|
1003
|
+
align-items: center;
|
|
1004
|
+
gap: var(--sa-spacing-4, 4px);
|
|
1005
|
+
vertical-align: middle;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
.sa-kbd-key {
|
|
1009
|
+
display: inline-flex;
|
|
1010
|
+
align-items: center;
|
|
1011
|
+
justify-content: center;
|
|
1012
|
+
min-width: 1.5em;
|
|
1013
|
+
padding: 0 var(--sa-spacing-6, 6px);
|
|
1014
|
+
background-color: var(--sa-background-neutral, #f0f1f2);
|
|
1015
|
+
border: 1px solid var(--sa-border-subtle, #0b120e24);
|
|
1016
|
+
border-radius: var(--sa-radii-xs, 4px);
|
|
1017
|
+
color: var(--sa-text-subtle, #505258);
|
|
1018
|
+
font-family: inherit;
|
|
1019
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
1020
|
+
font-weight: var(--sa-font-weight-medium, 400);
|
|
1021
|
+
line-height: 1.6;
|
|
1022
|
+
white-space: nowrap;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
.sa-kbd-sep {
|
|
1026
|
+
display: inline-flex;
|
|
1027
|
+
align-items: center;
|
|
1028
|
+
color: var(--sa-text-subtlest, #6b6e76);
|
|
1029
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
1030
|
+
user-select: none;
|
|
1031
|
+
}
|
|
1032
|
+
`, xn = "sa-kbd-styles", Pn = (n) => {
|
|
1033
|
+
if (!(typeof document > "u") && !document.getElementById(xn)) {
|
|
1034
|
+
const e = document.createElement("style");
|
|
1035
|
+
e.id = xn, e.textContent = n, document.head.appendChild(e);
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
Pn(Mn);
|
|
1039
|
+
function Hn({ keys: n, separator: e, className: r, ...l }) {
|
|
1040
|
+
return /* @__PURE__ */ s("span", { className: `sa-kbd${r ? ` ${r}` : ""}`, ...l, children: n.map((d, c) => /* @__PURE__ */ o(Z.Fragment, { children: [
|
|
1041
|
+
c > 0 && e != null ? /* @__PURE__ */ s("span", { className: "sa-kbd-sep", "aria-hidden": "true", children: e }) : null,
|
|
1042
|
+
/* @__PURE__ */ s("kbd", { className: "sa-kbd-key", children: d })
|
|
1043
|
+
] }, c)) });
|
|
1044
|
+
}
|
|
1045
|
+
Hn.__saRaw = !0;
|
|
991
1046
|
export {
|
|
992
|
-
|
|
1047
|
+
Wn as Input,
|
|
1048
|
+
Hn as Kbd
|
|
993
1049
|
};
|
package/dist/input.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(b,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(b=typeof globalThis<"u"?globalThis:b||self,n(b.Input={},b.jsxRuntime,b.React))})(this,function(b,n,o){"use strict";const gn=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
4
|
/* Layer 3 — references Layer 2 semantic tokens */
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
position: relative;
|
|
142
142
|
width: 100%;
|
|
143
143
|
background: transparent;
|
|
144
|
-
border:
|
|
144
|
+
border: 1px solid var(--sa-input-border-subtle);
|
|
145
145
|
overflow: hidden;
|
|
146
146
|
transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
|
|
147
147
|
}
|
|
@@ -174,16 +174,16 @@
|
|
|
174
174
|
/* variants */
|
|
175
175
|
.sa-tf-variant-outline .sa-tf-box {
|
|
176
176
|
background: transparent;
|
|
177
|
-
border:
|
|
177
|
+
border: 1px solid var(--sa-input-border-subtle);
|
|
178
178
|
}
|
|
179
179
|
.sa-tf-variant-standard .sa-tf-box {
|
|
180
180
|
background: var(--sa-input-bg-neutral);
|
|
181
|
-
border:
|
|
181
|
+
border: 1px solid transparent;
|
|
182
182
|
}
|
|
183
183
|
.sa-tf-variant-flushed .sa-tf-box {
|
|
184
184
|
background: transparent;
|
|
185
185
|
border: 0;
|
|
186
|
-
border-bottom:
|
|
186
|
+
border-bottom: 1px solid var(--sa-input-border-subtle);
|
|
187
187
|
border-radius: 0;
|
|
188
188
|
}
|
|
189
189
|
.sa-tf-variant-borderless .sa-tf-box {
|
|
@@ -350,10 +350,10 @@
|
|
|
350
350
|
align-self: stretch;
|
|
351
351
|
}
|
|
352
352
|
.sa-tf-addon-left {
|
|
353
|
-
border-right:
|
|
353
|
+
border-right: 1px solid var(--sa-input-border-subtle);
|
|
354
354
|
}
|
|
355
355
|
.sa-tf-addon-right {
|
|
356
|
-
border-left:
|
|
356
|
+
border-left: 1px solid var(--sa-input-border-subtle);
|
|
357
357
|
}
|
|
358
358
|
.sa-tf-size-sm .sa-tf-addon {
|
|
359
359
|
font-size: 12px;
|
|
@@ -591,4 +591,35 @@
|
|
|
591
591
|
.sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
|
|
592
592
|
min-height: 80px;
|
|
593
593
|
}
|
|
594
|
-
`,
|
|
594
|
+
`,k=t=>t==="lg"||t==="xl"?18:16,F={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?F.disable:F[t]??F.default;function xn(t){return Number(t.replace(/\./g,""))}function T(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,D]=o.useState([]),c=o.useRef(null),u=()=>{if(f!=null&&f.current&&c.current){const g=window.innerHeight,p=f==null?void 0:f.current.getBoundingClientRect(),m=c.current.getBoundingClientRect(),w=p.bottom+m.height;c.current.style.left=`${p.left}px`,c.current.style.width=`${p.width}px`,w>=g-10?c.current.style.top=`${p.top-m.height-5}px`:c.current.style.top=`${p.top+p.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(()=>{D((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="md",variant:l="outline",status:d="default",label:f,labelPosition:v="outside-top",required:D,optional:c,description:u,helperText:g,errorText:p,leftIcon:m,rightIcon:w,leftAddons:S,rightAddons:E,onClickLeftIcon:en,onClickRightIcon:O,fullWidth:In=!0,highlightPlaceholder:V,currency:L,options:B,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 L?T(e):e}),[sn,an]=o.useState(!1),[En,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:Ln}=yn(!1);o.useLayoutEffect(()=>{if(!M)return;const e=a.value===void 0||a.value===null?"":String(a.value),r=L?T(e):e;z(h=>h===r?h:r)},[a.value,L,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",Bn=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":"",Bn?"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 pn,hn;if(!L){const j=e.target.selectionStart;j!==null&&(C.current=j),z(e.target.value),(pn=a.onChange)==null||pn.call(a,e);return}const r=e.target.value;let h=r,x=e.target.selectionStart??r.length;if(En==="Backspace"){const j=P.replace(/\D/g,""),Vn=r.replace(/\D/g,"");j.length===Vn.length&&x>0&&(h=r.slice(0,x-1)+r.slice(x),x-=1)}const J=T(h),Dn=h.slice(0,x).replace(/\D/g,"").length,On=vn(J,Dn);C.current=On,z(J),(hn=a.onChange)==null||hn.call(a,{...e,target:{...e.target,value:String(xn(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,D?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,p&&d==="error"?n.jsx("p",{className:"sa-tf-error",children:p}):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,Fn=e=>{var h;e.stopPropagation(),M||z("");const r={target:{value:"",name:a.name},currentTarget:{value:"",name:a.name}};(h=a.onChange)==null||h.call(a,r),A==null||A(),C.current=0,requestAnimationFrame(()=>{var x;return(x=N.current)==null?void 0:x.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:Fn,onMouseDown:e=>e.preventDefault(),children:n.jsx(zn,{width:k(i),height:k(i)})}):null,Tn=!$&&!!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),Ln(!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}),Tn?Cn(a.placeholder,V):null]}),bn=I&&ln&&(B!=null&&B.length)?n.jsx(mn,{options:B,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()]}),E?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:E}):null,bn]}):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()]}),E?n.jsx("div",{className:"sa-tf-addon sa-tf-addon-right",children:E}):null,bn]});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 {
|
|
595
|
+
display: inline-flex;
|
|
596
|
+
align-items: center;
|
|
597
|
+
gap: var(--sa-spacing-4, 4px);
|
|
598
|
+
vertical-align: middle;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.sa-kbd-key {
|
|
602
|
+
display: inline-flex;
|
|
603
|
+
align-items: center;
|
|
604
|
+
justify-content: center;
|
|
605
|
+
min-width: 1.5em;
|
|
606
|
+
padding: 0 var(--sa-spacing-6, 6px);
|
|
607
|
+
background-color: var(--sa-background-neutral, #f0f1f2);
|
|
608
|
+
border: 1px solid var(--sa-border-subtle, #0b120e24);
|
|
609
|
+
border-radius: var(--sa-radii-xs, 4px);
|
|
610
|
+
color: var(--sa-text-subtle, #505258);
|
|
611
|
+
font-family: inherit;
|
|
612
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
613
|
+
font-weight: var(--sa-font-weight-medium, 400);
|
|
614
|
+
line-height: 1.6;
|
|
615
|
+
white-space: nowrap;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.sa-kbd-sep {
|
|
619
|
+
display: inline-flex;
|
|
620
|
+
align-items: center;
|
|
621
|
+
color: var(--sa-text-subtlest, #6b6e76);
|
|
622
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
623
|
+
user-select: none;
|
|
624
|
+
}
|
|
625
|
+
`,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,b.Input=R,b.Kbd=tn,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
CHANGED
|
@@ -17,7 +17,11 @@ export interface IInputProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
17
17
|
helperText?: string;
|
|
18
18
|
errorText?: string;
|
|
19
19
|
leftIcon?: ReactElement<IconInputProps>;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Right-side slot. Accepts an SVG icon (sized/colored automatically) or any
|
|
22
|
+
* ReactNode such as a <Kbd /> keycap (rendered as-is).
|
|
23
|
+
*/
|
|
24
|
+
rightIcon?: ReactNode;
|
|
21
25
|
leftAddons?: ReactNode;
|
|
22
26
|
rightAddons?: ReactNode;
|
|
23
27
|
onClickLeftIcon?: () => void;
|