@atlure/ui 0.12.3 → 0.12.5
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlure/ui",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"description": "Atlure React Native component library: NativeWind primitives built on @atlure/tokens, shipped as untranspiled TypeScript source",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David Moreira",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"class-variance-authority": "0.7.1",
|
|
38
38
|
"clsx": "2.1.1",
|
|
39
39
|
"tailwind-merge": "2.6.0",
|
|
40
|
-
"@atlure/icons": "0.12.
|
|
41
|
-
"@atlure/tokens": "0.12.
|
|
42
|
-
"@atlure/types": "0.12.
|
|
40
|
+
"@atlure/icons": "0.12.5",
|
|
41
|
+
"@atlure/tokens": "0.12.5",
|
|
42
|
+
"@atlure/types": "0.12.5"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"nativewind": "^4.2.6",
|
|
@@ -4,8 +4,8 @@ import { Platform, TextInput, type TextInputProps, View } from "react-native";
|
|
|
4
4
|
import { cn } from "../../lib/cn";
|
|
5
5
|
import { touchTargetHitSlop } from "../../lib/touch-target";
|
|
6
6
|
import {
|
|
7
|
-
inputFieldWrapperClassName,
|
|
8
7
|
inputIconSlotVariants,
|
|
8
|
+
inputTextClassName,
|
|
9
9
|
inputVariants,
|
|
10
10
|
type InputVariantProps,
|
|
11
11
|
} from "../../variants/input-variants";
|
|
@@ -22,24 +22,22 @@ export interface InputProps extends Omit<TextInputProps, "editable" | "multiline
|
|
|
22
22
|
ref?: Ref<ComponentRef<typeof TextInput>>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
: base;
|
|
42
|
-
}
|
|
25
|
+
// `text-base` in the tailwind preset expands to `{ fontSize: 16, lineHeight:
|
|
26
|
+
// 24 }`. On Android that 24px line box is centered inside the fixed control
|
|
27
|
+
// height via gravity, but the visible glyph is drawn at the baseline INSIDE
|
|
28
|
+
// that line box, which biases it below the geometric middle of the input.
|
|
29
|
+
// Tighten the line height to just above the glyph height (fontSize × 1.15,
|
|
30
|
+
// enough room for descenders) so the line box is roughly equal to the glyph
|
|
31
|
+
// itself and the center of the line box IS the visible center of the text.
|
|
32
|
+
const TEXT_INPUT_RESET =
|
|
33
|
+
Platform.OS === "android"
|
|
34
|
+
? {
|
|
35
|
+
paddingTop: 0,
|
|
36
|
+
paddingBottom: 0,
|
|
37
|
+
includeFontPadding: false as const,
|
|
38
|
+
lineHeight: 18,
|
|
39
|
+
}
|
|
40
|
+
: { paddingTop: 0, paddingBottom: 0, lineHeight: 18 };
|
|
43
41
|
|
|
44
42
|
export function Input({
|
|
45
43
|
size = "md",
|
|
@@ -59,22 +57,8 @@ export function Input({
|
|
|
59
57
|
const isControlInvalid = isInvalid ?? field?.isInvalid ?? false;
|
|
60
58
|
const isControlRequired = isRequired ?? field?.isRequired ?? false;
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const control = (
|
|
65
|
-
<TextInput
|
|
66
|
-
accessibilityState={{ disabled: isControlDisabled }}
|
|
67
|
-
accessibilityLabelledBy={field?.labelledBy}
|
|
68
|
-
aria-labelledby={field?.labelledBy}
|
|
69
|
-
aria-describedby={field?.describedBy}
|
|
70
|
-
aria-disabled={isControlDisabled}
|
|
71
|
-
aria-invalid={isControlInvalid}
|
|
72
|
-
aria-required={isControlRequired}
|
|
73
|
-
nativeID={nativeID ?? field?.nativeID}
|
|
74
|
-
editable={!isControlDisabled}
|
|
75
|
-
multiline={isMultiline}
|
|
76
|
-
textAlignVertical={isMultiline ? "top" : "center"}
|
|
77
|
-
hitSlop={touchTargetHitSlop(size)}
|
|
60
|
+
return (
|
|
61
|
+
<View
|
|
78
62
|
className={cn(
|
|
79
63
|
inputVariants({
|
|
80
64
|
size,
|
|
@@ -86,21 +70,27 @@ export function Input({
|
|
|
86
70
|
}),
|
|
87
71
|
className,
|
|
88
72
|
)}
|
|
89
|
-
|
|
90
|
-
{...textInputProps}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
if (!leadingIcon && !trailingIcon) {
|
|
95
|
-
return control;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<View className={inputFieldWrapperClassName}>
|
|
73
|
+
>
|
|
100
74
|
{leadingIcon ? (
|
|
101
75
|
<View className={inputIconSlotVariants({ slot: "leading" })}>{leadingIcon}</View>
|
|
102
76
|
) : null}
|
|
103
|
-
|
|
77
|
+
<TextInput
|
|
78
|
+
accessibilityState={{ disabled: isControlDisabled }}
|
|
79
|
+
accessibilityLabelledBy={field?.labelledBy}
|
|
80
|
+
aria-labelledby={field?.labelledBy}
|
|
81
|
+
aria-describedby={field?.describedBy}
|
|
82
|
+
aria-disabled={isControlDisabled}
|
|
83
|
+
aria-invalid={isControlInvalid}
|
|
84
|
+
aria-required={isControlRequired}
|
|
85
|
+
nativeID={nativeID ?? field?.nativeID}
|
|
86
|
+
editable={!isControlDisabled}
|
|
87
|
+
multiline={isMultiline}
|
|
88
|
+
textAlignVertical={isMultiline ? "top" : "center"}
|
|
89
|
+
hitSlop={touchTargetHitSlop(size)}
|
|
90
|
+
className={inputTextClassName}
|
|
91
|
+
style={[TEXT_INPUT_RESET, style]}
|
|
92
|
+
{...textInputProps}
|
|
93
|
+
/>
|
|
104
94
|
{trailingIcon ? (
|
|
105
95
|
<View className={inputIconSlotVariants({ slot: "trailing" })}>{trailingIcon}</View>
|
|
106
96
|
) : null}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
2
|
|
|
3
3
|
export const inputVariants = cva(
|
|
4
|
-
"w-full rounded-md border bg-input-background px-md
|
|
4
|
+
"w-full flex-row items-center rounded-md border bg-input-background px-md",
|
|
5
5
|
{
|
|
6
6
|
variants: {
|
|
7
7
|
size: {
|
|
@@ -18,7 +18,7 @@ export const inputVariants = cva(
|
|
|
18
18
|
false: "",
|
|
19
19
|
},
|
|
20
20
|
isMultiline: {
|
|
21
|
-
true: "h-auto min-h-control-lg py-sm",
|
|
21
|
+
true: "h-auto min-h-control-lg py-sm items-start",
|
|
22
22
|
false: "",
|
|
23
23
|
},
|
|
24
24
|
hasLeadingIcon: {
|
|
@@ -41,6 +41,9 @@ export const inputVariants = cva(
|
|
|
41
41
|
},
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
+
export const inputTextClassName =
|
|
45
|
+
"flex-1 text-base text-foreground placeholder:text-muted-foreground";
|
|
46
|
+
|
|
44
47
|
export const inputIconSlotVariants = cva("absolute inset-y-0 justify-center", {
|
|
45
48
|
variants: {
|
|
46
49
|
slot: {
|