@anyknown/ui 0.8.0 → 0.8.1
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.
|
@@ -44,7 +44,9 @@ export declare const controlStyles: Readonly<{
|
|
|
44
44
|
export type InputProps = Omit<ComponentProps<"input">, "size"> & {
|
|
45
45
|
size?: "sm" | "md";
|
|
46
46
|
invalid?: boolean;
|
|
47
|
+
/** Keys, URLs, ids: anything read character by character. */
|
|
48
|
+
mono?: boolean;
|
|
47
49
|
leadingIcon?: ReactNode;
|
|
48
50
|
sx?: StyleArg;
|
|
49
51
|
};
|
|
50
|
-
export declare function Input({ size, invalid, leadingIcon, sx, ...props }: InputProps): import("react").JSX.Element;
|
|
52
|
+
export declare function Input({ size, invalid, mono, leadingIcon, sx, ...props }: InputProps): import("react").JSX.Element;
|
|
@@ -41,6 +41,7 @@ export const controlStyles = stylex.create({
|
|
|
41
41
|
sm: { minHeight: "1.75rem", paddingBlock: space.xxs, paddingInline: space.xs, fontSize: text.xs },
|
|
42
42
|
});
|
|
43
43
|
const styles = stylex.create({
|
|
44
|
+
mono: { fontFamily: font.mono },
|
|
44
45
|
affix: { position: "relative", display: "block", width: "100%" },
|
|
45
46
|
icon: {
|
|
46
47
|
position: "absolute",
|
|
@@ -54,10 +55,10 @@ const styles = stylex.create({
|
|
|
54
55
|
withIconMd: { paddingInlineStart: space.xl },
|
|
55
56
|
withIconSm: { paddingInlineStart: space.lg },
|
|
56
57
|
});
|
|
57
|
-
export function Input({ size = "md", invalid, leadingIcon, sx, ...props }) {
|
|
58
|
+
export function Input({ size = "md", invalid, mono = false, leadingIcon, sx, ...props }) {
|
|
58
59
|
const { invalid: fieldInvalid, ...field } = useFieldControl(props);
|
|
59
60
|
const isInvalid = invalid ?? fieldInvalid;
|
|
60
|
-
const input = (_jsx("input", { ...props, ...field, "aria-invalid": isInvalid || undefined, ...styled(props, controlStyles.base, controlStyles[size], isInvalid && controlStyles.invalid, Boolean(leadingIcon) && (size === "sm" ? styles.withIconSm : styles.withIconMd), sx) }));
|
|
61
|
+
const input = (_jsx("input", { ...props, ...field, "aria-invalid": isInvalid || undefined, ...styled(props, controlStyles.base, controlStyles[size], isInvalid && controlStyles.invalid, mono && styles.mono, Boolean(leadingIcon) && (size === "sm" ? styles.withIconSm : styles.withIconMd), sx) }));
|
|
61
62
|
if (!leadingIcon)
|
|
62
63
|
return input;
|
|
63
64
|
return (_jsxs("span", { ...stylex.props(styles.affix), children: [_jsx("span", { "aria-hidden": "true", ...stylex.props(styles.icon), children: leadingIcon }), input] }));
|